#12365 closed Bug (invalid)
insertHtml adds unwanted div or span tag with contentEditable="false"
Reported by: | dan turcu | Owned by: | |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | General | Version: | |
Keywords: | Cc: |
Description
In a javascript function I execute : CKEDITOR.instances[_editor].insertHtml(html); where html is a String containing html code in form : <div><a href="..."><img src="..."></a></div>
The img tag is taken from the editor current selection, and the div and a tags are added.
Actually I'm adding a link to an image in the editor.
In some cases, additional div or span tags with attribute contentEditable="false", are added surrounding the inserted html.
The problem is that after this tags are added if I execute the javascript again the insertHtml will make no change in the editor(because of the contentEditable="false").
Note that I'm using image2 plugin
Change History (3)
comment:1 Changed 10 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
Version: | 4.4.3 |
comment:2 Changed 10 years ago by
If I use the default link button of the editor, it works fine, and also this not happen for all images, just some rare cases, and I cannot see any difference. If i could see the code that is used by the default link button, I think I would manage this.
This is a correct behaviour. If you use image2, then all inserted images must be upcasted to widgets. Upcasting means wrapping with a widget wrapper which is a span or div with contenteditable=false attribute (and couple of other things).
I don't know what you want to achieve and what do you do exactly. But either you must accept that image was wrapped (that it became a widget) and handle it accordingly or you can use editor.insertElement method, which does not trigger upcasting automatically.