ckeditor5 icon indicating copy to clipboard operation
ckeditor5 copied to clipboard

An error of unlinking block type images

Open v-ostrovsky opened this issue 3 years ago • 4 comments

If the Link plugin config parameter addTargetToExternalLinks = true, an error is thrown when the unlink command is executing for block type images (at least for the versions 29.1.0-31.0.0):

ckeditorerror.js:67 Uncaught TypeError: Cannot read properties of undefined (reading '_removeAttribute') at DowncastWriter.removeAttribute (downcastwriter.js:402) at DowncastDispatcher.eval (automaticdecorators.js:142) at DowncastDispatcher.fire (emittermixin.js:208) at DowncastDispatcher._testAndFire (downcastdispatcher.js:571) at DowncastDispatcher.convertAttribute (downcastdispatcher.js:256) at DowncastDispatcher.convertChanges (downcastdispatcher.js:168) at eval (editingcontroller.js:104) at View.change (view.js:508) at Document.EditingController.listenTo.priority (editingcontroller.js:103) at Document.fire (emittermixin.js:208)

v-ostrovsky avatar Nov 17 '21 23:11 v-ostrovsky

Steps for reproducing:

  • Compile manual tests from the link package
  • Add the following configuration to the linkimage.js manual test
      	link: {
      		addTargetToExternalLinks: true,
      	}
    
  • Open http://localhost:8125/ckeditor5-link/tests/manual/linkimage.html
  • Remove link from an image in the editor.
  • Most probably we should not execute a logic from the converter 👇 if the linkHref attribute was removed.

https://github.com/ckeditor/ckeditor5/blob/e391ddb70d6f55c2c7465a84fd3e830265b3279d/packages/ckeditor5-link/src/utils/automaticdecorators.js#L109-L152

pomek avatar Feb 16 '22 12:02 pomek

its trying delete twice the linkinmage and in the second try its crash first is remove by running downcastimagelink the second run is on automaticecorators dispatcher.on( 'attribute:linkHref:imageBlock'...

need add there condition if (!linkinimage) return..

kuku711 avatar Mar 01 '22 14:03 kuku711

its trying delete twice the linkinmage and in the second try its crash first is remove by running downcastimagelink the second run is on automaticecorators dispatcher.on( 'attribute:linkHref:imageBlock'...

need add there condition if (!linkinimage) return..

That's exactly what's happening, and a fix really seems trivial. I wonder why this still hasn't been fixed? Any comments on that, @Reinmar? Are we missing something here that make a fix more complex?

TobiasHartlehnert avatar Feb 15 '23 07:02 TobiasHartlehnert

There has been no activity on this issue for the past year. We've marked it as stale and will close it in 30 days. We understand it may still be relevant, so if you're interested in the solution, leave a comment or reaction under this issue.

CKEditorBot avatar Feb 16 '24 03:02 CKEditorBot

We've closed your issue due to inactivity. We understand that the issue may still be relevant. If so, feel free to open a new one (and link this issue to it).

CKEditorBot avatar Mar 18 '24 03:03 CKEditorBot