Opened 10 years ago

Closed 10 years ago

Last modified 9 years ago

#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:


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 Piotrek Koszuliński

Resolution: invalid
Status: newclosed
Version: 4.4.3

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.

comment:2 Changed 9 years ago by dan turcu

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.

comment:3 Changed 9 years ago by dan turcu

It works with insertElement , thanks.

Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy