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.36k stars 3.68k forks source link

LinkImageEditing + ImageBlock in combination with ListEditing #16778

Open Joel-Levi opened 2 months ago

Joel-Levi commented 2 months ago

📝 Provide detailed reproduction steps (if any)

Reproduction repo (Open the index.html in the sample folder)

  1. Have an editor with LinkEditing, LinkImageEditing, ImageBlock, ListEditing. (No ImageInline)
  2. Paste the following as HTML ( or use setData() )
    <ul>
    <li>
    <a href="https://ckeditor.com" target="_blank" rel="noopener noreferrer">
    <img src="https://ckeditor.com/assets/images/illustration/home-banner.png" height="100px" width="100px">
    </a>
    </li>
    </ul>

✔️ Expected result

A list with an image link get pasted

❌ Actual result

The link is thrown out. There is only a list with an image I'm not 100% sure if this is a bug or not, it might be expected behavior on CK's end?

📃 Other details

If you'd like to see this fixed sooner, add a 👍 reaction to this post.

Witoso commented 1 month ago

Hmm, I reproduced it in the builder as well, it shouldn't result in such data change.

Curious, why do you use *Editing plugins, any particular reason?

Reinmar commented 1 month ago

This is a tricky one. Pasting a linked inline image inside a list, while there's no inline images support.

The expected behavior: this should be turned into a linked block image and either "leave" the list or stay within it. The latter would be better from data preservation perspective.

It's tricky because it's a combination of 3 features and it's not a happy path (it needs to be picked up by the block image converters).

Definitely a bug, but might not be an easy one to fix.

Joel-Levi commented 1 month ago

Hmm, I reproduced it in the builder as well, it shouldn't result in such data change.

Curious, why do you use *Editing plugins, any particular reason?

We are writing our own toolbar from scratch, so we do not need the UI part.

mabryl commented 1 month ago

This will work when the linked image is wrapped in the <figure> element that typically surrounds block images in CKE5. An example can be seen in this StackBlitz.

Removing the <figure> from initialData will make the issue appear.