ckeditor / ckeditor5

Powerful rich text editor framework with a modular architecture, modern integrations, and features like collaborative editing.
https://ckeditor.com/ckeditor-5
Other
9.56k stars 3.7k forks source link

TypeError: Cannot read properties of null (reading 'getTrimmed') in linkui.ts #17087

Open scotteuser opened 1 month ago

scotteuser commented 1 month ago

📝 Provide detailed reproduction steps (if any)

  1. Load CK Editor 5 Premium in Drupal
  2. Insert a media image
  3. Save the content
  4. Edit the media image, replacing it with a new image
  5. Click the image to select it within the editor
  6. It seems the 'selection' of the image triggers link.js even without a link, and the selected element check does not seem to be protective enough in its code

This is specifically in LinkUI (linkui.ts) in private._getSelectedLinkElement() it seems

Uncaught TypeError: Cannot read properties of null (reading 'getTrimmed')
    at Ee._getSelectedLinkElement (link.js?v=41.3.1:5:37052)
    at Object.<anonymous> (link.js?v=41.3.1:5:33342)
    at Object.fire (ckeditor5-dll.js?v=41.3.1:5:663135)
    at de (ckeditor5-dll.js?v=41.3.1:5:201940)
    at pe.fire (ckeditor5-dll.js?v=41.3.1:5:201331)
    at xn.fire (ckeditor5-dll.js?v=41.3.1:5:245580)
    at xn.onDomEvent (ckeditor5-dll.js?v=41.3.1:5:449592)
    at listenTo.useCapture (ckeditor5-dll.js?v=41.3.1:5:245450)
    at ue.fire (ckeditor5-dll.js?v=41.3.1:5:663135)
    at HTMLDivElement.t (ckeditor5-dll.js?v=41.3.1:5:673313)

To note I also see a separate console error, which is possibly also related to the 'selection' not existing:

TypeError: e.getCustomProperty(...).reduce is not a function
    at y (ckeditor5-dll.js?v=41.3.1:5:698296)
    at so.<anonymous> (ckeditor5-dll.js?v=41.3.1:5:711031)
    at so.fire (ckeditor5-dll.js?v=41.3.1:5:663135)
    at so.convertSelection (ckeditor5-dll.js?v=41.3.1:5:290903)
    at ckeditor5-dll.js?v=41.3.1:5:329452
    at St.change (ckeditor5-dll.js?v=41.3.1:5:258711)
    at listenTo.priority (ckeditor5-dll.js?v=41.3.1:5:329363)
    at zi.fire (ckeditor5-dll.js?v=41.3.1:5:663135)
    at zi._handleChangeBlock (ckeditor5-dll.js?v=41.3.1:5:414269)
    at vn._runPendingChanges (ckeditor5-dll.js?v=41.3.1:5:449137)

✔️ Expected result

No fatal error

❌ Actual result

Fatal error in the code along with

Oops...
It seems that the editor encountered an error. Save your content and refresh the page. If the error persists, contact your site administrator.

📃 Other details

image

Dawidols commented 1 month ago

Hello @scotteuser

We tried to reproduce this error but with no result. Can you attach your editor and filter format config file so we have the same configuration as you? Or please provide a list of contrib modules and filters you use in the text format.