Closed (fixed)
Project:
Scald: Media Management made easy
Version:
7.x-1.x-dev
Component:
Code
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
4 Aug 2015 at 13:50 UTC
Updated:
20 Aug 2015 at 15:54 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
nagy.balint commentedSeems like the trouble is caused by this fix:
http://dev.ckeditor.com/ticket/13397
As it fails on
if ( widgetsRepo._.draggedWidget.wrapper.contains( el ) ) {
in ckeditor/plugins/widget/plugin.js on line 2421
Comment #2
nagy.balint commentedSeems like the fix would be to add
just before our greedySearch call.
However we do not use this.repository, so first would need to get the repository.
The docs claim that
Yet i cannot find it there, and neither in the editor variable existing in the scope.
Comment #3
nagy.balint commentedSeems like
editor.widgets._.draggedWidgetWill work instead of
this.repository._.draggedWidgetHowever the
= thispart not sure yet how to replace.It needs something that it can do contains on
"Uncaught TypeError: Cannot read property 'contains' of undefined"
Comment #4
gifad commentedThe code in dndck4 drag and drop is derived from ckeditor widget drag and drop;
The problem is what is dragged is not (yet) a widget, so the expected "this" does not yet exist !
The attached patch is a quick and dirty attempt to create the widget at dragstart time...
Two unpleasant side effects:
at least, it fixes the "critical" aspect of the issue ;)
Comment #5
nagy.balint commentedI got to the same conclusion.
Here is a lightweight dirty workaround for the same thing.
Seems to be working in firefox, chrome and ie 9, although more testing is always welcome.
Comment #6
gifad commentedA cleaner implementation of #4 (#4 was working only on last ckeditor instance...)
Comment #7
nagy.balint commentedThanks gifad!
However I think It needs to be refactored cause now there are duplicate code when creating the widget in both the insertNewWidget function and separately when creating the dummy widget. Also snapshot should be included the same way as we have in the insertNewWidget function.
So the code would change quite a lot at the end. So maybe its better to have a more lightweight solution for now, and then later if we want to refactor the whole system, we can still do so.
@jcisio which one do you prefer? (comment #5 vs comment #6)
Comment #8
gifad commentedRefactored the code to avoid duplicate code...
About snapshots, I can't get the "Undo" command working in the current implementation, so I did not touch it...
Comment #9
nagy.balint commentedThanks!
I however started a new patch because I think we can create the widget before calling the onLibraryAtomDrag and we can even pass the widget as 'this' to the function just like the code it was derived from. So this would make the code a lot more similar to the original, and maybe reduce some future problems.
Needs a bit more testing, and maybe it could be simplified even more, for now only the editor could be removed from onLibraryAtomDrag as widget.editor works fine.
Comment #10
nagy.balint commentedPatch #9 passes my tests under chrome, firefox, and ie9, under ckeditor 4.5.2, 4.5.1, and 4.4.6
Comment #11
gifad commented#9 tested, works fine;
Added a clean-up of the unused widget(s), in case of multiple ckeditor instances (or just text with summary)
Comment #12
nagy.balint commentedSeems like you have not tested your code, as in javascript you cannot set a default value to a function parameter, that produces an error.
Also It seems that destroying those values are not really necessary. Because the widget variable will be destroyed after the scope of the dragstart ends. And anyways there is a different widget variable per editor.
Also the draggedWidget will have a value on dragstart right away (per editor again) so setting it to null seems unnecessary, of course maybe it frees up a tiny amount of memory space.
So I think i will commit #9
Comment #14
nagy.balint commentedComment #15
gifad commentedSorry, #11 was tested only with firefox, which did not complain...
About extra widgets, they are not automatically purged, as they have been inited;
You can follow them in the DOM :
CKEDITOR.instances["edit-body-und-0-summary"].widgets.instances[0]Attached corrected version, in case any one is interested to experiment...
Comment #16
nagy.balint commentedSo something like this.
However I get under IE 9 SCRIPT5007: Unable to get value of the property 'find': object is null or undefined
ckeditor.js: line 1129 character 190
Comment #17
gifad commentedAfter http://docs.ckeditor.com/#!/api/CKEDITOR.plugins.widget-method-destroy
one could use
widget.repository.destroy(widget, true);I have no IE at hand to check further...
Comment #18
nagy.balint commentedUnfortunately that seems to make no difference.
Comment #19
nagy.balint commentedMoved this to a followup, so we can close this issue.
#2546712: followup: ckeditor 4.5.2 compatibility - cleanup widget variable
Comment #21
nagy.balint commentedGood news, 4.5.3 seems to work fine as well.