Opened 6 years ago

Closed 6 years ago

#10339 closed Bug (fixed)

Error is thrown when inserting custom element

Reported by: Piotrek Koszuliński Owned by: Olek Nowodziński
Priority: Must have (possibly next milestone) Milestone: CKEditor 4.1.2
Component: General Version: 4.1
Keywords: Cc:

Description

var currentDialog = CKEDITOR.dialog.getCurrent();
currentDialog._.editor.insertHtml("<customTag myAttr='var'></customTag>");

Throws an error, TypeError: Cannot read property 'isBlock' of undefined

Change History (10)

comment:1 Changed 6 years ago by Christian Beier

Version: 4.1

I have the same error if I try to insert an image tag to the editor with CKeditor 4.1 (or the latest nightly build).

If I run the code (insertHtml function):

CKEDITOR.instances[edit-field-body-und-0-value].insertHtml('<img src="/sites/default/files/styles/thumbnail/public/wysiwyg/images/bildschirmfoto_2012-09-28_um_12.34.44.png?itok=wMgqD_Pg" width="100" height="48" alt=""  class="image-thumbnail" />'); 

or

CKEDITOR.instances['edit-field-body-und-0-value'].insertHtml('<img src="/sites/default/files/styles/thumbnail/public/wysiwyg/images/bildschirmfoto_2012-09-28_um_12.34.44.png?itok=wMgqD_Pg" width="100" height="48" alt=""  class="image-thumbnail" />'); 

The error message:

Uncaught TypeError: Cannot read property 'isBlock' of undefined ckeditor.js:320
d ckeditor.js:320
i ckeditor.js:320
(anonymous function) ckeditor.js:325
CKEDITOR.editable.CKEDITOR.tools.createClass.proto.insertHtml ckeditor.js:300
(anonymous function) ckeditor.js:306
j ckeditor.js:10
CKEDITOR.event.CKEDITOR.event.fire ckeditor.js:12
CKEDITOR.editor.CKEDITOR.editor.fire ckeditor.js:13
CKEDITOR.tools.extend.insertHtml ckeditor.js:226
Drupal.insert.insertIntoActiveEditor insert.js:168
insert insert.js:106
c.event.handle jquery.js:64
h.handle.o

comment:2 Changed 6 years ago by Piotrek Koszuliński

Status: newconfirmed

Yep, I confirm this too. But to reproduce this I had to check it on basic preset (where image is not allowed).

comment:3 Changed 6 years ago by Piotrek Koszuliński

Priority: NormalHigh

Issue exists because insertHtml is not prepared that during filtering data my be completely emptied. It checks data string at the beginning, but does not repeat this after passing them through the filter.

Unfortunately it's a little bit too late to schedule this ticket for 4.1.1, so we'll fix it in next release.

comment:4 Changed 6 years ago by Christian Beier

I think the problem is related to the Advanced Content Filter. If I deactivate the filter (config.allowedContent = true;) all works.

comment:5 Changed 6 years ago by Piotrek Koszuliński

Yes, usually it is caused by ACF - that's what I meant by "passing them through the filter". But parser and data processor (which are used together with filter) may also strip some data in specific situations, so this is not only related to ACF.

comment:6 Changed 6 years ago by Frederico Caldeira Knabben

Milestone: CKEditor 4.1.2

comment:7 Changed 6 years ago by Olek Nowodziński

Owner: set to Olek Nowodziński
Status: confirmedassigned

comment:8 Changed 6 years ago by Olek Nowodziński

Status: assignedreview

DEV: Created fix in t/10339 branch.

TESTS: Added basic test to insertHtml and mt for the ticket.

Last edited 6 years ago by Olek Nowodziński (previous) (diff)

comment:9 Changed 6 years ago by Piotrek Koszuliński

Status: reviewreview_passed

I pushed additional test (it's always good to include ticket's tc) and minor fix for dev.

comment:10 Changed 6 years ago by Olek Nowodziński

Resolution: fixed
Status: review_passedclosed

Merged fix into master, dev git:7a702d809ddd8, tests: b5db5e71750e8.

Note: See TracTickets for help on using tickets.
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy