Opened 10 years ago

Closed 9 years ago

#13347 closed Bug (expired)

javascript error in widget plugin

Reported by: bjrke Owned by:
Priority: Normal Milestone:
Component: General Version:
Keywords: Cc:

Description

I have a widget plugin, which produces an error in widget plugin code, when it is used nested and the outer widget is removed in a special way by the user:

Uncaught TypeError: Cannot read property 'attributes' of null

In the debug version it is line 2509 of plugins/widget/plugin.js

given the following markup in the editor:

<div class="jc-contentbox align-center" style="width: 500px;">
  <p>outer</p>
  <div class="jc-contentbox align-center" style="width: 500px;">
    <p>inner</p>
  </div>
</div>

(tested in google chrome) Now do a double click to select the outer div, but not the inner. The div and the text must be selected (not easy). Then remove the div with the delete key from your keyboard. Then when trying to get the html markup again, the errors occur (for example when you want to view the source).

I have also done a pull request which fixes the problem: https://github.com/ckeditor/ckeditor-dev/pull/190

Attachments (6)

plugin.js (4.1 KB) - added by bjrke 10 years ago.
our plugin
en.js (226 bytes) - added by bjrke 10 years ago.
lang/en.js
de.js (234 bytes) - added by bjrke 10 years ago.
lang/de.js
contentbox.png (286 bytes) - added by bjrke 10 years ago.
icons/contentbox.png
selected_outer.png (16.0 KB) - added by bjrke 10 years ago.
selection of outer div must look like this (use double click to select)
typeerror.png (57.2 KB) - added by bjrke 10 years ago.
after clicking source

Download all attachments as: .zip

Change History (10)

Changed 10 years ago by bjrke

Attachment: plugin.js added

our plugin

Changed 10 years ago by bjrke

Attachment: en.js added

lang/en.js

Changed 10 years ago by bjrke

Attachment: de.js added

lang/de.js

Changed 10 years ago by bjrke

Attachment: contentbox.png added

icons/contentbox.png

Changed 10 years ago by bjrke

Attachment: selected_outer.png added

selection of outer div must look like this (use double click to select)

Changed 10 years ago by bjrke

Attachment: typeerror.png added

after clicking source

comment:1 Changed 10 years ago by Piotrek Koszuliński

The problem is that your widget definition isn't fully correct. It accepts the same kind of elements as widgets and nested editables at the same time. This creates an incorrect situation when the nested editable becomes a widget as well and then everything may happen.

So the first thing to fix is your widget definition.

At the same time CKEditor should not allow this. Let's assume that someone really needs such structure where nested editable has exactly the same classes as element which should become a widget. CKEditor could be smart enough to find that the outer most element of this kind should become a widget, its direct descendant of this kind can only become a nested editable and descendant of that nested editable can become a widget, etc. That may be possible and the fix should go in this direction.

So we can confirm this ticket, but the question is whether you really wanted to achieve this. Because it would be much better solution to fix the HTML and widget definition.

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

Status: newpending

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

Version: 4.4.7

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

Resolution: expired
Status: pendingclosed
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