Behaviour SwRS-MDOKFSTUDIO-PALETTE-148
Document link picks a Markdown file and writes a doc role
When the writer presses Document link, the extension SHALL ask the host through previewPickDocument for a native file dialog on md and markdown files, keep the editor open while it is shown, and write {doc} with the picked path, relative to the document and without its extension, in place of the selection, or nothing when the dialog is cancelled.
Part of StRS-MDOKFSTUDIO-PALETTE-013, outside the paths drawn on its map.
Scenarios 5
The situations the tests check; open one to read it.
nominalPicked
Givenan open editor and the path ../guide/setup picked
Whenthe host answers
Thenthe text is {doc}`../guide/setup` and the editor stayed open during the dialog
nominalDialog and path of the host
Givena trusted, saved document docs/a.md, previewPickDocument with a valid editId and the file docs/guide/setup.md picked
Whenthe host handles it
Thenthe path is guide/setup; a native dialog opens in the folder of the document, filtered to md and markdown files, with the label Link document, and the answer is the picked file as a path relative to the document with forward slashes and without the md or markdown extension
refusalCancelled
Giventhe dialog cancelled
Whenthe host answers
Thenthe answer is ok true with cancelled true, nothing is inserted, the text box has the focus and the next blur saves again
refusalRefused answers
| Input | Outcome |
|---|---|
| a path on another Windows drive, or a name with a backtick, an angle bracket or a line break | ok false with the reason That file name cannot be written in a {doc} link. |
| a document that is out of date or is not a file | ok false with the reason The preview is out of date, or the document is not a file. |
| a failed dialog | ok false with the message of the error (a value that is not an Error as its string) |
| a previewPickDocument message without a non-empty editId of at most 100 characters | ignored by the envelope check |
See SwRS-MDOKFSTUDIO-TRUST-052, SwRS-MDOKFSTUDIO-TRUST-005, SwRS-MDOKFSTUDIO-TRUST-065 and SwRS-MDOKFSTUDIO-TRUST-090.
boundarySelection and path forms in the page
| Input | Outcome |
|---|---|
| a one-line selection | the role is written with the selected text and the path in angle brackets |
| a picked path with a backtick or an angle bracket | no edit |