Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deleting in lists does not work properally if <br> tag is removed with "code" or "paste" plugins #3068

Closed
Jeff-14159 opened this issue Jul 15, 2016 · 4 comments

Comments

@Jeff-14159
Copy link

If you type out a list in an editor:

1. Test
2. Test
3. Test
4. Test
5. Test

then using the "code" plugin to view the source and click ok to apply changes then start pressing the delete button (at least 3 times) from the end of "1. Test" it will pull the next sibling element up to soon... and if you keep pressing delete it will continue to pull others early as well.


so far I have found that normally each <li> or any tag with text for that matter will have a <br data-mce-bogus="1"> after the text.

In the "code" plugin win.find('#code').value(editor.getContent({source_view: true})); strips out the <br> tags for viewing in the modal and does not put them back when it sets the contents back to the editor.

I also notice that if you paste content with a list in from word or some other source it will also not add the <br> tags to the markup during the paste processing....


So either the deleting needs to not care that the <br> tags are no longer there, maybe the bookmarks needs updated? as it seems to be one row ahead? or it needs something to check and add them back in if missing/removed


As a work around I have been able to manually add the <br> tags back in with the following code but is less than ideal....

     var missingBrTags = $('#editor iframe').contents().find('.mce-content-body').find('li,p,div,span').not(':has(>br)');
        $.each(missingBrTags, function(missingBrTagIndex, missingBrTag) {
            if ($(missingBrTag).children().length > 0) { // contains more that just text...
                var firstNestedDomElement = $(missingBrTag).children('ol,ul,p,div,span').first();
                if (firstNestedDomElement.length > 0 ) { // contains major dom elements insert before the first one
                    $('<br data-mce-bogus="1">').insertBefore(firstNestedDomElement);
                } else { // only has minor markup tags like <strong> or <em>... put br after them
                    $(missingBrTag).append('<br data-mce-bogus="1">');
                }
            } else { // contains only text
                $(missingBrTag).append('<br data-mce-bogus="1">');
            }
        });

using tinymce 4.4.0 & IE 11 or the editor on the main page of https://www.tinymce.com/

@jayarjo
Copy link
Contributor

jayarjo commented Jul 18, 2016

@Jeff-14159 I wasn't able to replicate "too soon" effect with bogus brs or without them. Tiny seems to operate properly both ways (tested in IE11 on Win 8.1). Could you record a quick video of the it happening?

@Jeff-14159
Copy link
Author

Here is a video showing the delete issue, this happens after you view the "source code" but it will also happen when pasting from an outside source that doesn't have the BR tags.

TinyMCE deleting list Issue.zip

@jayarjo
Copy link
Contributor

jayarjo commented Jul 21, 2016

Seems to be a bug in IE11 Selection object. When an "early pulling" occurs, Selection object reports LI as an anchorNode and 1 as anchorOffset, when in reality it obviously should be a text node and 3 correspondingly.

@lnewson
Copy link
Contributor

lnewson commented May 5, 2020

Hi,

I attempted to replicate this with TinyMCE 4.9.10 and 5.2.2, however it appeared to be working as expected. It's likely the issue has been fixed since this was originally reported and as such I'll go ahead and close this. If you're still able to reproduce the issue in the latest version, then please let us know and we'll reopen this issue.

Thanks!

@lnewson lnewson closed this as completed May 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants