yabwe / medium-editor

Medium.com WYSIWYG editor clone. Uses contenteditable API to implement a rich text solution.
https://yabwe.github.io/medium-editor/
Other
16.07k stars 1.85k forks source link

Copy/paste ordered lists in <li/> tags produce inconsistent behavior in Chrome. #359

Open letnotimitateothers opened 9 years ago

letnotimitateothers commented 9 years ago

Hi, First of all, thanks a lot for this amazing plugin :+1: We are currently using it in my company and I'm facing some unexpected behaviors when using the editor. Here are the steps and pictures:

-------> Let's say I have this text. capture d ecran 2015-01-08 a 15 53 32

-------> When I paste an ordered list of texts, I end up with two ordered lists : capture d ecran 2015-01-08 a 15 56 50

-------> Correct me if I'm wrong, but I was hoping to have the following as results : capture d ecran 2015-01-08 a 15 59 27

For information, this bug does not happen in formal content editable.

I have created a jsFiddle for test. This problem happens immediately after the creation of an ordered list. So you need to create an ordered list, and then, between, create a new item and paste another ordered list.

http://jsfiddle.net/letnotimitateothers/juL978ey/1/

Thanks for the answer. Ls.

letnotimitateothers commented 9 years ago

Just found that this issue does not exist in Firefox. In fact, both Chrome and Firefox have different ways to deal with the action : insertOrderedList. For test, click here : http://jsbin.com/eFiRedUc/1/edit?html,js,output Chrome wraps "ol" tag inside a "p" tag, while Firefox does not. It seems it's a well known bug about Chrome. https://bugs.webkit.org/show_bug.cgi?id=45866

nchase commented 9 years ago

since this is a bug at the browser/contenteditable level, does it need to be fixed in medium-editor? this library only has cursory support for normalizing contenteditable behavior.

a separate module that normalizes contenteditable behavior between browsers would be preferable (or more ideally, browsers would implement all contenteditable commands the same way. :smile: )

mphasize commented 9 years ago

@nchase I believe this tool should (and does to some extent) normalize the contenteditable behavior. While it would be ideal to have a working implementation in every browser, that simply is not the case and some known bugs have been without fixes for ~2 years. If medium-editor itself does not normalize contenteditable behavior, than it should be built on top of another library that does exactly that.