Behaviour SwRS-MDOKFSTUDIO-PALETTE-203
A pasted image is sent to the host and its name inserted on its own paragraph
When the writer pastes into the block text box a clipboard that holds no text and a png, jpeg, gif or webp file of at most 10 MB, the extension SHALL take over the paste, remember the selection, read the first such file as base64, send it to the host with its type, and when the host answers a file name replace the remembered selection with  as a paragraph of its own, showing any refusal or read failure in the status line and inserting nothing.
Step 1 of path 1 in StRS-MDOKFSTUDIO-PALETTE-018: from “A block text box is open in edit mode” to “The host receives the image”.
Scenarios 5
The situations the tests check; open one to read it.
nominalA screenshot is saved and inserted
that request
the host answers image.png
the reference is inserted over the remembered selection (not the live one), the edit is autosaved and the status line shows its usual text again
The host side of this request is SwRS-MDOKFSTUDIO-PALETTE-196; the answer correlation is SwRS-MDOKFSTUDIO-TRUST-090.
boundaryWhat the paste hook takes over
| Clipboard | Outcome |
|---|---|
| text and an image | the paste stays native and nothing is sent to the host (text wins) |
| an item of another type, such as svg | the item is ignored and the paste stays native |
| no file at all | the paste stays native |
| several png, jpeg, gif or webp files, no text | the first such file is read and sent |
| an image of 1 MB | the image is sent to the host |
| an image of 11 MB | the paste is prevented, the status line shows The image is larger than 10 MB and was not pasted. and nothing is posted (the limit is 10 times 1024 times 1024 bytes) |
refusalThe image cannot be read or the host refuses it
Each case inserts nothing. The status line changes only while the editor and text box that received the paste are the open ones and not finishing.
| Case | Status line |
|---|---|
| the file reader fails (a failing reader) | The image could not be read. (nothing is posted) |
| the editor closed meanwhile and the reader fails | not touched |
| the host answers a refusal with a reason | that reason |
| the host answers a refusal without a reason | The image was not saved. |
| the host answers an edit id that is not the pending one | ignored |
| the editor closed or is finishing when the answer arrives | not touched and nothing is inserted |
nominalThe reference goes on a paragraph of its own
The alternative text equals the file name; no dialog asks for it.
| Text around the selection | Result |
|---|---|
| caret at the end of a paragraph | a blank line and the reference follow the paragraph, and a blank line follows the reference unless it ends the text |
| caret in the middle of a line | the line is split around a paragraph that holds only the reference |
| caret at the start of the text | no blank line before the reference |
| blank lines already there | they are reused, not doubled |
| the paragraph ends with a typed space, or spaces and tabs surround the caret | the spaces and tabs around the paste position go with the break, so no line keeps trailing blanks; line breaks are kept |
| caret directly at the end | the text before it is unchanged |
boundaryThe selection and the positions
| Remembered selection | Outcome |
|---|---|
| a selection of two words | the selection is replaced by the paragraph and the file name inside the reference is selected |
| a position beyond the text | the positions are clamped to the length of the text |