CKEditor destroys widget while dragging

I use the CKEditor widget functions to create my own widget with the jquery component. However, when the widget is dragged and dropped, it is destroyed, and the entire state of the jquery component is lost. Can this behavior be avoided? Is this customizable? Why is this required (perhaps the CKEditor team can answer this question)?

+5
source share
1 answer

It is true that the widget is destroyed (and reinitialized) during drag and drop, this behavior cannot be avoided.

How do you bind your jQuery component to a widget object? What does your widget definition look like? (This is the object you pass in the editor.widgets.add() call). Do you Widget.setData() / How do you set this jQuery component as widget data?

If you find it difficult to answer these questions, you can simply copy the source code of your widget instance here (open the browser developer tools and find the element with the data-cke-widget-id attribute - do not confuse the source mode with CKEditor view). Paste it with all the content.

Widgets store their data in the data-cke-widget-data HTML attribute. A blind assumption would be that you either did not correctly set the data in the widgets, or when they are gated and then parsed back, it does not process the jQuery object properly. Perhaps you can initialize your jQuery component with widget.definition.init and save the data as a simple object ( Widget.setData )?

You can also see the documentation for the CKEditor widget for more information.

+8
source

Source: https://habr.com/ru/post/1242374/


All Articles