Repository navigation
Paste a picture into a text block as an inline image (BL-17014) - #8499
StephenMcConnel wants to merge 1 commit into
Conversation
|
[Medium impact] The PR appears safe to merge; no new actionable issues were found.
|
|
[Claude Opus 5.5 from Steve McConnel's machine during preflight] Consulted Devin on 2026-10-23 16:35 UTC up to commit f4bc7d7.
|
|
[Claude Opus 5.5 from Steve McConnel's machine during preflight] @greptile-apps review |
|
[Claude Opus 5.5 from Steve McConnel's machine during preflight] Consulted Devin on 2026-10-23 17:24 UTC up to commit d7a39a1.
|
|
[Claude Opus 5.5 from Steve McConnel's machine during preflight] Consulted Devin on 2026-10-23 17:40 UTC up to commit 690f545. Re-review clean: nothing new. Devin marks both of its bugs resolved (save during a new paste, save during a paste over a selected image); its two flags are the earlier ones, already answered. |
StephenMcConnel
left a comment
There was a problem hiding this comment.
@StephenMcConnel reviewed 7 files and all commit messages, and resolved 3 discussions.
Reviewable status: 0 of 7 files reviewed, all discussions resolved.
|
[Claude Opus 5.5 from Steve McConnel's machine during preflight] @greptile-apps review |
|
[Claude Opus 5.5 from Steve McConnel's machine during preflight] Consulted Devin on 2026-10-23 18:30 UTC up to commit 8a7b201.
|
StephenMcConnel
left a comment
There was a problem hiding this comment.
@StephenMcConnel+CLAU resolved 2 discussions.
Reviewable status: 0 of 10 files reviewed, all discussions resolved.
StephenMcConnel
left a comment
There was a problem hiding this comment.
@StephenMcConnel reviewed 7 files and all commit messages.
Reviewable status: 0 of 10 files reviewed, all discussions resolved.
Pasting a picture into a text block pasted the picture's file path as text: Ctrl+V there was left to CKEditor, and Bloom's Copy Image, an Explorer file copy and a browser's "Copy image" all put the path or URL on the clipboard beside the picture. Now a paste of just a picture (Ctrl+V, or the top-bar Paste button) goes to inline images when the focus is in a text block that can take them, or when an inline image is selected: - With an inline image selected, the picture replaces its picture, through the image's own "Paste image" command (doImageCommand). - Otherwise it becomes a new inline image in the focused block. JS posts editView/pasteImage with an id starting "makeNewInlineImage" and unique to the paste; C# imports the picture and calls changeImage with that id, which inserts the image with the picture already in it (insertInlineImage's setUpPicture), so one Undo takes back the paste and a failed paste leaves nothing behind. - A clipboard with formatted text as well as a picture (Word, Excel) still pastes as text. Canvas text boxes, xmatter and data-book fields, image descriptions, and a paste with a canvas picture selected behave as before. Every paste of a picture now holds a page-content delay until C# answers, so a save waits for the picture, and doImageCommand drops a second paste over the same picture until the first is answered. So that C# always answers, EditingModel.ChangePicture now reports whether it worked, and OnPasteImage calls RemoveUnneededImageId when it didn't. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
8a7b201 to
72f33c5
Compare
Problem
Pasting a picture into a text block pasted the picture's file path as text instead of the picture (BL-17014). Ctrl+V in a text block is left to the browser and CKEditor, and most picture copies put the path or URL on the clipboard as text beside the picture: Bloom's own Copy Image, a file copied in Explorer, a browser's "Copy image". So the text is what got pasted. The top-bar Paste button sent the picture to the page's canvas, or pasted the same text when the page had no canvas.
What the PR does
editView/pasteImage). JS postseditView/pasteImagewith an id that starts withmakeNewInlineImageand is unique to that paste. C# copies the clipboard picture into the book folder as it always has and callschangeImagewith that id, which creates the inline image, with the picture already in it, in the block that paste was for. A failed or cancelled paste leaves nothing behind, and one Undo takes back the whole paste (insertInlineImagecan now fill in the picture before it records its undo entry).doImageCommand, so the image toolbar's "Paste image" (on canvas pictures too) gets it as well, and a second paste over the same picture before C# has answered the first is dropped (it would only bring the same clipboard picture again).EditingModel.ChangePicturereports whether importing the picture worked, so thatOnPasteImagetells the page (removeImageId) when it didn't. Before, a failed import left the page waiting for a picture that never came.The new code is in
bookEdit/js/inlineImagePaste.ts.Screenshots
A picture pasted into a text block, selected, with its toolbar:
Risk Evaluation
These shared paths change:
pastelistener on the page document sees every paste in the edit page. It returns at once unless the focus is in an eligible text block and the clipboard holds just a picture; only then does it stop the event. Every other paste (text, HTML, pastes in canvas text boxes and form fields) goes on as before.changeImageandremoveImageId, which C# calls for every picture change and every failed paste:changeImagegains an early branch for ids that start withmakeNewInlineImage, and both end any pending paste for their id (a lookup that does nothing for other ids).doImageCommand's paste, used by the "Paste image" command on every picture, canvas ones included, now holds a save delay and drops a second paste over the same picture until C# has answered.OnPasteImage(C#) now callsRemoveUnneededImageIdwhen importing the picture fails, as it already did for every other failure.pasteImpl(the Paste button) gains a check before its canvas branch.The
insertInlineImagechange only moves the undo commit after an optional callback; Insert Image passes none and behaves as before.Ecosystem Impact
None expected. The pasted picture is an ordinary inline image, the same markup that Insert Image followed by Change Image produces, so Bloom Player, publishing and older versions see nothing new. No API change (the C# change is internal to the edit view), no new dependency, no new localizable strings: the error messages are the existing paste-image ones.
E2E Coverage
No end-to-end test covers this. Driving it needs a picture on the Windows clipboard, which the e2e suite does not set up. Unit tests cover when a paste becomes an inline image or replaces a selected one (the clipboard checks for Ctrl+V and for the Paste button, and which text blocks qualify), the round trip through the paste's id (including two quick pastes, and a paste C# abandons), the page-save delay, and the single undo entry. It was also checked by hand in a running Bloom: an Explorer file copy, a Bloom-style picture plus path, the Paste button, a Word-style clipboard (left as text), and a paste over a selected inline image (replaced in every language, and undone by the Undo button).
Notion Test Suite
None.
Preflight report: https://bloombooks.github.io/dev-process-artifacts/deciders/bloomdesktop-bl-17014-pasteinlineimageintext.html
Ref: https://issues.bloomlibrary.org/youtrack/issue/BL-17014
Devin review
This change is