Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-PALETTE-004

Files dropped from the Explorer become links or images at the drop point

When the writer drops one or more local files from the VS Code Explorer onto the preview in edit mode with no block editor open, the extension SHALL mark the insertion point nearest to the pointer while they are over the page and, on the drop, write there a new block with one relative Markdown reference per file, ![name](path) for a png, jpg, jpeg, gif, svg or webp image and [title](path) for any other file, with the first heading of a Markdown file as its title (not read in a preview with restricted reads), in one undo step, leaving the rest of the source unchanged.

Part of StRS-MDOKFSTUDIO-PALETTE-018, outside the paths drawn on its map.

Scenarios 4

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

nominalA Markdown file becomes a link titled by its first heading
Giventhe preview in edit mode with no editor open and a Markdown file whose first heading is "Getting started" in the folder of the document
Whenthe writer drags the file over the lower half of a paragraph and drops it
Thenthe insertion bar after that paragraph shows the drop marker while the file is over the page, and on the drop a new block `[Getting started](The%20Guide.md)` is written after the paragraph in one undo step
nominalAn image becomes an image reference
Giventhe same preview and a png file in a sibling folder, dropped together with a Markdown file that has no heading
Whenthe writer drops them after the last paragraph
Thenone new block `![logo](../img/logo.png) [plain](plain.md)` is written after it: the image takes its file name without extension as alt text, and the file without heading takes its name
boundaryWhat is refused or left alone
CaseOutcome
a drag that carries no file addresses, a block editor or property editor open, or edit mode offno marker, no message; the page does nothing
a file outside every workspace folder (a standalone document takes any file), or an address that is not `file:`not written; when none is left the host answers with a notice and the source is unchanged
a preview with restricted reads and a Markdown filethe file is not read: its link text is its name without extension
a file that VS Code holds read-onlyrefused with "This file is read-only in VS Code.", nothing written
a document that is not a saved file, a stale versionrefused with a notice, nothing written
the insertion point is next to a block that comes from an included filerefused with the notice of the paste of blocks
more than 50 files in one dropthe page sends the first 50
a file on another drive than the document, or a name with angle brackets or a line breakno reference for that file
boundaryThe written reference
PartOutcome
destinationrelative to the folder of the document (also for a file outside it, when the document is standalone), `/` separators, spaces and parentheses percent-encoded
link textfirst heading of a Markdown file (md, markdown, mdx; first 64 KiB, outside front matter and code, emphasis marks removed); else the name without extension; `[`, `]` and `\` escaped
several filestheir references on one line separated by a space, in drag order

Implemented in 5

Tested by 5