When switching from the dnd to dndck4 plugin, existing embedded atoms are added to the Drupal.dnd.Atoms array when editing but are missing their contexts property. This breaks when subsequently calling the fetchAtom function which does an in array check on said property (dnd-library.js, line 70ish).

After saving the markup has been replaced with the new dndck4 embed_div markup, but the errors persist. I've added a patch which adds a typeof check on .contexts before running the in array check. Ideally I'd like to figure out where the already embedded atoms get added to the Atoms array and see if there isn't a better 'fix' to apply there, or just for knowledge's sake. Because knowledge is power!

I realize this isn't critical or even a bug, because I believe there isn't an upgrade path for switching from dnd to dndck4. But, you'll be happy to know, this was the only problem I ran into. The output has a different class, dnd-atom-rendered instead of dnd-drop-wrapper, but that's about it.

CommentFileSizeAuthor
typeof-check-contexts-dnd-library-js.patch964 bytesgrayle

Comments

Grayle created an issue. See original summary.

gifad’s picture

The dnd.fetchAtom() function is used only by the "old" plugin : plugins/ckeditor.
The "new" plugin plugins/dndck4 does not reference it at all.
So either you reverted the upgrade, or more likely the page has been edited first with an upgraded CKEditor profile, and later with a non upgraded profile (by a different user ?).
But your patch does not hurt...

nagy.balint’s picture

Version: 7.x-1.5 » 7.x-1.x-dev
Status: Active » Needs review

Actually there is an upgrade path from the legacy plugin to the new one (Starting at scald/modules/library/dnd/plugins/dndck4/plugin.js line 44), we have extra javascript to do so. It wont be perfect as you have to adjust to the fact that the class has changed, but it should work fine.

I also did not experience that issue before myself, and its true that the fetchAtom is only used by the legacy plugin (and the atom reference field)

I will check the patch, as it seems harmless indeed, and more checks never hurts :)

nagy.balint’s picture

Status: Needs review » Fixed

Thanks, committed.

  • nagy.balint committed d9c14b3 on 7.x-1.x authored by Grayle
    Issue #2578119 by Grayle: Extra condition in dnd library javascript to...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.