Enhancement
Critical
Major
Detail
Detail
Detail
#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 via drag and drop, then an error message occurs 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 exists when inserting 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. A fix for this problem is not yet available from the CKEditor team and the suggested plugin "Widget Selection" does not solve it either, unfortunately.
Improvement
As a workaround the selection is checked before inserting the image and if it is empty it is set again.
Test
On an empty doc page insert an image via drag and drop. No error message should appear and the image must be uploaded. Test the same again after entering text in the editor and then inserting an image at the end of the text.