Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-BLOCK-166

Cmd/Ctrl+C copies the exact Markdown of the selected blocks

When a writer presses the platform copy chord with blocks selected in edit mode and no editor open, the page SHALL post previewBlocksCopy with the first and last source line of the selection and take the key from the browser, so that the host puts the exact Markdown of those lines on the clipboard after the range's trailing blank lines (spaces and tabs only) are dropped.

Step 2 of path 1 in StRS-MDOKFSTUDIO-BLOCK-016: from “A run of blocks is selected” to “The Markdown of the blocks is on the clipboard”.

Scenarios 6

The situations the tests check; open one to read it.

nominalCtrl+C or Cmd+C posts the source lines of the selection
Giventwo selected blocks at lines 5 to 6 and 8 to 10
Whenthe writer presses Ctrl+C (Cmd+C on macOS)
ThenpreviewBlocksCopy carries line 5 and endLine 10 and the default action is prevented
nominalThe host puts the exact Markdown on the clipboard
InputOutcome
Lines 7 to 10 holding a paragraph, a blank line and a two-item listThe clipboard holds those four lines joined by the document's line breaks, with no trailing line break, and the document is unchanged
A document with CR LF line breaksThe clipboard text keeps CR LF between its lines
A list whose range ends on the blank lines after it (the renderer maps it so), followed by two blank linesThe clipboard holds the list's lines without the blank lines after it, and the document is unchanged
A selection that ends on a line holding only a no-break spaceRefused with "The preview is out of date. Refresh it and try again.", and nothing is copied
nominalThe page announces the answer
InputOutcome
A copy answered okThe selection status reads "Copied as Markdown" and returns to the selection count after four seconds (4000 ms)
A cut answered okThe selection is cleared instead of announcing a copy
refusalA refusal of the clipboard keys is shown for four seconds
InputOutcome
A copy, a cut or a paste answered ok false with a reason (for example a paste)The status region shows the reason, keeps the selection and returns to the selection count after four seconds (4000 ms)
A copy answered okThe copy message is shown instead
refusalThe keys stay with the browser
InputOutcome
Copy, cut or paste chord in reading mode (edit mode off, a selection left over)The page does nothing and the browser copies
Ctrl+V in a block text box with the focusThe text box pastes natively
The chord in a field, in the properties table or with an open editorThe page leaves the key to the browser
The chord with Shift or AltThe page leaves the key to the browser
The chord with no selection or focused barThe page leaves the key to the browser
Ctrl+C alone on macOS (the chord there is Cmd)The key is ignored by the page
refusalA held key sends one request until the host answers
InputOutcome
A copy, cut or paste request is in flight and the key repeatsNo second message is posted
The host never answers and five seconds passThe page accepts the chord again

Implemented in 4

Tested by 4