backdrop-contrib / insert

Utility that makes inserting images and links to files into text areas much easier.
GNU General Public License v2.0
3 stars 4 forks source link

Insert appears not to work with CKEditor 5 #22

Open nattywebdev opened 4 months ago

nattywebdev commented 4 months ago

When trying to insert a link to a document attached to a node (a pdf for example) into the Body field (CKEditor 5), it doesn't work.

Instead this message is displayed in the developer console of Google Chrome:

insert.js?sggjji:198
Uncaught TypeError: $pane.size is not a function
    at Object.activateTabPane (insert.js?sggjji:198:15)
    at Object.insertIntoActiveEditor (insert.js?sggjji:177:23)
    at HTMLInputElement.insert (insert.js?sggjji:106:21)
    at HTMLInputElement.dispatch (jquery.js?v=3.7.1:2:40035)
    at v.handle (jquery.js?v=3.7.1:2:38006)

I tested this with a fresh build in tugboat, but had experienced it on several recently-updated sites (to Backdrop 1.28.2).

nattywebdev commented 4 months ago

This also applies to TinyMCE - the error displayed in console is the same. According to @indigoxela :

size() has been deprecated in jQuery 1.8 (!!!) and removed in jQuery 3. That script is definitely broken with the most recent jQuery: https://github.com/backdrop-contrib/insert/blob/1.x-1.x/insert.js#L198

nattywebdev commented 4 months ago

I can confirm that the issue is not present if you switch back to jQuery 1 (Legacy), so at least there's a workaround, for now.

indigoxela commented 4 months ago

@jromine here's a PR that addresses the jQuery compatibility problem.

More info in the documentation: https://api.jquery.com/size/

This does not address the CKEditor5 compatibility problem, which seem a lot trickier, but at least with that small change the module works with jQuery 3 and TinyMCE. :wink: