Markdown OKF-Schema Studio

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
Givena block editor with a selection and a clipboard that holds HTML with a heading, bold text, a link and a list
that request
Whenthe writer pastes
the host answers the Markdown conversion
Thenthe default paste is prevented, previewPasteHtml is posted with the html and the selection of the moment of the paste is remembered
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
Givenan HTML fragment with a heading
a conversion that throws
WhenpreviewPasteHtml is accepted, in any preview, whatever the trust, since it edits nothing
the host answers
Thenthe answer previewPasteHtmlResult is ok true and holds the Markdown of the heading, and no file is touched
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.

CaseOutcome
Cmd+Shift+V or Ctrl+Shift+V pressed just before the pasteplain 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 htmlnative paste
clipboard with a blank html textnative paste
clipboard with 1,000,001 characters of htmlnative paste
clipboard that holds an image onlynot 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
CaseOutcome
answer with ok false or empty Markdownthe plain text of the clipboard is inserted instead, over the remembered selection, in one undo step
both the Markdown and the plain text emptynothing is inserted
editor closed, replaced or finishing when the answer arrivesnothing is inserted
answer for another editignored
remembered positions beyond the textclamped to the length of the text before the insertion
boundaryThe message shape
previewPasteHtml fieldAcceptedOtherwise
htmla non-empty string of at most 1,000,000 charactersthe protocol rejects the message (an empty text or one over 1,000,000 characters)
edit idas for every host requestthe protocol rejects the message

Implemented in 3

Tested by 4