Uploaded image for project: 'XWiki Platform'
  1. XWiki Platform
  2. XWIKI-25645

Images included in pasted HTML are not uploaded as attachments, and inline ones are lost

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • Major
    • None
    • 17.10.0
    • BlockNote
    • None
    • Unknown

    Description

      Steps to reproduce

      1. create a page A, attach an image to it and insert that image in its content
      2. add a second paragraph to page A containing an image inline inside the text
      3. save page A and view it
      4. open a page B in edit mode, with the BlockNote editor
      5. in page A's view mode, select everything and copy
      6. paste into the BlockNote editor of page B
      7. save page B

      Expected result

      • both images are attached to page B and referenced from its content as [[image:image.png]]

      Actual result

      • the block-level image is inserted as an external URL image, still pointing at page A's attachment. Nothing is attached to page B, so page A has no way of knowing that another page references its attachment, and the image breaks as soon as page A or its attachment is removed.
      • the inline image is silently dropped: no image, no external URL image, no warning

      Cause

      BlockNote only calls the uploadFile callback when the clipboard or the drop carries a Files entry:

      // @blocknote/core, handleFileInsertion
      if (i !== "Files") return;
      

      Content copied from a web page arrives as text/html, so that path is never taken and the <img src> of the pasted HTML is inserted as-is. The uploadFile callback added by XWIKI-24758 only ever sees the files dropped from the file manager or pasted from a screenshot tool.

      Attaching the referenced images needs a pass over the pasted HTML that fetches each external image, attaches it to the edited page and rewrites the reference.

      Notes

      • This is the BlockNote counterpart of XWIKI-20350 and XWIKI-22611, which fixed the same problem for CKEditor.
      • Reproduced on master as well.

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              nciausu Nicoleta Ciausu
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated: