开发者

WYSIWYG development bug with formatBlock in Mozilla

开发者 https://www.devze.com 2023-01-20 01:30 出处:网络
I\'am currently developing a WYSIWYG editor for my CMS and got serious bugs here. After switching from IFRAME to DIV contenteditable the behavior changed dramatically.

I'am currently developing a WYSIWYG editor for my CMS and got serious bugs here. After switching from IFRAME to DIV contenteditable the behavior changed dramatically.

Using execCommand('formatBlock') to create headlines causes unwanted BR tags to the source code, but only in Mozilla. I thought the reason could be <br _moz_dirty=""> but I 开发者_JS百科could be wrong and did not find a way to fix it.

See demo here: http://jsfiddle.net/Kj9Rp/


Definitely a bug. I've noticed that the relatively recently added contenteditable functionality in Mozilla has a number of quirks not present with designMode. I would stick with the <iframe> and designMode for now and file a bug at Mozilla's Bugzilla.

Your other option is to write your own DOM manipulation code that surrounds selected text within an <h1> element, but that will be relatively involved to get absolutely right.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号