CKEditor 5 Paste from Word: image disappeared when reopening Edit tab

Created on 16 May 2024, 9 months ago

Problem/Motivation

I tested pasting from Word with CKEditor 5, and I noticed image disappeared when reopening Edit tab of content.
It seems <img src=file path> is missing when reopening Edit tab.
- When pasting at Edit tab: <img src="/sites/default/files/inline-images/filename"...> exists. (See CKE5_1_EditTab(pasting).png)
- When opening View tab: <img src="/sites/default/files/inline-images/filename"...> exists. (See CKE5_2_ViewTab.png)
- When reopening Edit tab: <img src="data-entity-uuid="> exists, but no file path. (See CKE5_3_EditTab(reopening).png)

Note. Unlike CKEditor 5, CKEditor 4 saves image data as Base64 encoded data when pasting from Word (<img src="data:image/jpeg;base64,xxxx...>), and this symptom is not reproduced.

Drupal: 10.2.3
Client OS: Windows 10 22H2 build 19045.4291
Chrome: 124.0.6367.203
Word: 16.0 (Microsoft Word for Microsoft 365 version 2308 build 16.0.16731.20542)
Word doc: TextAndImgForPasteTest.docx (from https://github.com/ckeditor/ckeditor5/issues/2493#issuecomment-703472432)

Steps to reproduce

1. Open TextAndImgForPasteTest.docx, copy text and image, paste it into CKEditor 5 field of Edit tab, and save the content.
2. Go to View tab, the image is appeared correctly.
3. Go to Edit tab, the image is disappeared.

๐Ÿ› Bug report
Status

Active

Version

10.2 โœจ

Component
CKEditor 5ย  โ†’

Last updated 3 days ago

Created by

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @kubokura
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia vinai_katiyar Delhi NCR

    vinaik โ†’ made their first commit to this issueโ€™s fork.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia vinai_katiyar Delhi NCR

    Hi,

    I was unable to reproduce this issue. I tried to reproduce the issue on Mac Sonoma 14.4.1 and Drupal 10.2.7-dev

    I have attached screenshots for reference.

    1. source-mode.png
    2.edit-mode.png
    3.view-mode.png

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia vinai_katiyar Delhi NCR
  • Status changed to Closed: cannot reproduce 9 months ago
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia vinai_katiyar Delhi NCR
  • Hi, @vinaik, thank you for your quick response.
    Could you try the Steps to reproduce ?
    1. Open TextAndImgForPasteTest.docx, copy text and image, paste it into CKEditor 5 field of Edit tab, and save the content.
    2. Go to View tab, the image is appeared correctly.
    3. Go to Edit tab, the image is disappeared.

    It looks you just uploaded "Screenshot%202024-05-16%20at%202.57.40%E2%80%AFPM.png" (shown on source-mode.png) with "Upload image" icon. In that way, you cannot reproduce this issue.

    Best regards,

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia vinai_katiyar Delhi NCR

    Hello kubokura,

    I tried to reproduce the issue as the steps you mentioned but still i am not able to reproduce the issue.
    Kindly refer to the attached recording video.

    Thanks!

  • Hello, @vinaik, thank you for attaching the video file, that helps a lot.
    Could you select "Full HTML" at the Text format field, and try the steps again?
    I confirmed the issue was not reproduced when I selected "Basic HTML" as your operation in the video.

  • Status changed to Active 9 months ago
  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand quietone

    Fixes are made on on 11.x (our main development branch) first, and are then back ported as needed according to our policies. Also, 10.2 is in security mode now.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom Jons

    Help request - I didn't know you could paste from a docx etc, so I tried it using the test file (TextAndImgForPasteTest.docx)
    I cannot get the image to be pasted/saved (I can upload images using the normal media upload route).

    After paste the ckeditor source is:

    <p class="western" style="line-height:100%;margin-bottom:0cm;">
        This<img src="file:///tmp/lu163963bh9t.tmp/lu163963bhcm_tmp_e67916f350c6bf59.jpg" name="Picture 3" align="bottom" width="172" height="129" border="0"> is a jpeg image
    </p>

    The text is present and the image is shown as a square with 'broken image' icon and 'HTML object' as a highlight.

    Looking at the console it immediately shows:
    Security Error: Content at https://mydomain/node/199/edit?destination=/admin/content may not load or link to file:///tmp/lu163963bh9t.tmp/lu163963bhcm_tmp_e67916f350c6bf59.jpg.

    I looked in drupaldata/xxx/tmp and it shows a recent update time on tmp which may be the file trying to be saved by ckeditor?
    (no new files present)

    I can't see any obvious issue with perms.
    Same issue with basic html as with full html
    Can anyone say what should happen - I believe the image should end up in sites/default/files/inline-images?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States eadamse

    I have also encountered this issue, and I wanted to note that you can replicate it on https://simplytest.me/.
    I was specifically looking into pasting images from Word, which is the key to replicating the issue.
    If you enable source editing you can even see the difference in image support. For instance, I can copy a gravatar from github the src is retained, but if I copy an image from word the src is immediately removed.

Production build 0.71.5 2024