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
| Input | Outcome |
|---|---|
| Lines 7 to 10 holding a paragraph, a blank line and a two-item list | The 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 breaks | The 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 lines | The 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 space | Refused with "The preview is out of date. Refresh it and try again.", and nothing is copied |
nominalThe page announces the answer
| Input | Outcome |
|---|---|
| A copy answered ok | The selection status reads "Copied as Markdown" and returns to the selection count after four seconds (4000 ms) |
| A cut answered ok | The selection is cleared instead of announcing a copy |
refusalA refusal of the clipboard keys is shown for four seconds
| Input | Outcome |
|---|---|
| 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 ok | The copy message is shown instead |
refusalThe keys stay with the browser
| Input | Outcome |
|---|---|
| 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 focus | The text box pastes natively |
| The chord in a field, in the properties table or with an open editor | The page leaves the key to the browser |
| The chord with Shift or Alt | The page leaves the key to the browser |
| The chord with no selection or focused bar | The 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
| Input | Outcome |
|---|---|
| A copy, cut or paste request is in flight and the key repeats | No second message is posted |
| The host never answers and five seconds pass | The page accepts the chord again |