Behaviour SwRS-MDOKFSTUDIO-PALETTE-213
Pasted rich text is converted by the host and replaces the selection in one step
When the writer pastes into the block text box a clipboard that holds text/html of 1 to 1,000,000 characters and the paste is not a paste as plain text, the extension SHALL take over the paste, send the HTML to the host for conversion, and replace the selection of the moment of the paste with the Markdown answer in one undo step and autosave it, or with the plain text of the clipboard when the conversion fails or is empty, only if that editor is still open.
Step 1 of path 2 in StRS-MDOKFSTUDIO-PALETTE-018: from “A block text box is open in edit mode” to “The host converts the HTML”.
Scenarios 5
The situations the tests check; open one to read it.
nominalRich text becomes Markdown
that request
the host answers the Markdown conversion
the selection is replaced by the Markdown in one native edit with the caret after it, one undo restores the text and the edit is autosaved; the conversion rules are those of SwRS-MDOKFSTUDIO-PALETTE-217
The envelope, the render gate and the answer correlation (10 seconds) are those of SwRS-MDOKFSTUDIO-TRUST-052, SwRS-MDOKFSTUDIO-TRUST-065 and SwRS-MDOKFSTUDIO-TRUST-090.
nominalThe host converts without touching a file
a conversion that throws
the host answers
the answer is ok false with the message of the error as the reason
boundaryThe paste stays with the browser
No conversion is requested and the browser pastes the plain text.
| Case | Outcome |
|---|---|
| Cmd+Shift+V or Ctrl+Shift+V pressed just before the paste | plain paste; the mark is cleared by the next key that is not a modifier (Shift, Meta, Control, Alt) |
| clipboard with text only, or with no html | native paste |
| clipboard with a blank html text | native paste |
| clipboard with 1,000,001 characters of html | native paste |
| clipboard that holds an image only | not converted (the image paste is that of SwRS-MDOKFSTUDIO-PALETTE-203) |
| text box of a table cell editor, whatever the clipboard holds (an image or html) | native paste; no image is sent and no conversion is requested, since only the text box of the block editor installs the image and rich text paste hooks |
refusalThe conversion fails or the editor is gone
| Case | Outcome |
|---|---|
| answer with ok false or empty Markdown | the plain text of the clipboard is inserted instead, over the remembered selection, in one undo step |
| both the Markdown and the plain text empty | nothing is inserted |
| editor closed, replaced or finishing when the answer arrives | nothing is inserted |
| answer for another edit | ignored |
| remembered positions beyond the text | clamped to the length of the text before the insertion |
boundaryThe message shape
| previewPasteHtml field | Accepted | Otherwise |
|---|---|---|
| html | a non-empty string of at most 1,000,000 characters | the protocol rejects the message (an empty text or one over 1,000,000 characters) |
| edit id | as for every host request | the protocol rejects the message |