enhancement
critical
major
minor
minor
minor
#26271
TL-Doc: Drag and drop of images does not work in some situations
If there is no content in the editor and you try to add an image using drag-and-drop, an error message appears and the image is not inserted:
Client-side message: Uncaught JavaScript exception (exception: 'Uncaught TypeError: Cannot read properties of undefined (reading 'checkReadOnly')', component: 'rootLayout#masterFrame', source: 'http://localhost:8080/tl-doc-app/servlet/LayoutServlet/wb8b300a6d4cbfce9-653c65b014462250', layout: 'masterFrame.layout.xml', session: node0e0hvhat50dk8ap2hzq0k5ats1, UserAgent[Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.10 Safari/537.36])
The same problem occurs when you insert an image at the very end of the editor content.
The error occurs because, in some cases, the selection is lost, as also mentioned here: https://github.com/ckeditor/ckeditor4/issues/2517#issuecomment-465168856. The CKEditor team has not yet provided a fix for this issue, and unfortunately, the suggested “Widget Selection” plugin does not resolve it either.
Improvement
As a workaround, the selection is checked before inserting the image, and if it is empty, it is reset.
Test
Insert an image via drag-and-drop onto a blank Doc page. No error message should appear, and the image must be uploaded. Test this again after entering text into the editor and then inserting an image at the end of the text.