简体   繁体   中英

CKEditor setData adding P tag

When i am passing HTML to a CKEditor instance, a P tag is being inserted within the HTML producing unexpected results.

For example, with the following code:

CKEDITOR.instances["myEditor"].setData("<div>1</div><div>2</div>");

the editor does not display them as block elements (it outputs as "12" inline). Calling getData() and i see the HTML is reformatted incorrectly as:

"<div>
<p>
    1</div><div>2</div></p>
" 

I've played with the enterMode configuration based on some research but haven't found a magic combination. Any suggestions? (I am using 3.6.5)

我想通了 - 我们在粘贴时使用正则表达式去除一些标签,这也会影响初始值。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM