Steps to reproduce
- create a page A, attach an image to it and insert that image in its content
- add a second paragraph to page A containing an image inline inside the text
- save page A and view it
- open a page B in edit mode, with the BlockNote editor
- in page A's view mode, select everything and copy
- paste into the BlockNote editor of page B
- 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:
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. The inline images are lost for a different reason: BlockNote's embed blocks (image, file, audio, video) are block-level only, so an image that cannot become a standalone block has nowhere to go and is discarded. Notes
- This is the BlockNote counterpart of
XWIKI-20350 and XWIKI-22611, which fixed the same problem for CKEditor.
- Reproduced on master as well.
|