Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-PALETTE-192

The host image picker answers a path relative to the document

When previewPickImage reaches the host for a saved document, whatever the trust, the extension SHALL open a native dialog in the folder of the document filtered to png, jpg, jpeg, gif, webp and svg with the label Insert image, answer the picked file as a path relative to the document with forward slashes and blanks kept, or cancelled, or refuse a file that is outside the allowed folders (the workspace folders, or the folder of a standalone document), is not a local image or cannot be written in a reference with a reason the page shows, and read or write nothing.

Step 2 of path 1 in StRS-MDOKFSTUDIO-PALETTE-007: from “The image dialog is open” to “A path relative to the document comes back”.

Scenarios 4

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

nominalPicked image
Giventhe document in a folder and the file my pics/a (1).png picked
Whenthe host answers
Thenthe path is my pics/a (1).png, the dialog opened in the folder of the document with the filter Images, and the document is unchanged
refusalCancelled
Giventhe dialog cancelled
Whenthe host answers
Thenthe answer is ok true with cancelled true
refusalRefused picks
InputOutcome
a file outside every workspace folderthe reason reads The image must be inside a workspace folder.
a file outside the folder of the document, for a standalone document that lies in no workspace folderthe reason reads The image must be inside the folder of the document.
a text file, or a file that is not localthe reason reads Pick a png, jpeg, gif, webp or svg image.
a file on another drive, with no relative path, or with a name that holds an angle bracket or a line breakthe reason reads That image cannot be referenced from this document (another drive, or an unusual name).
a document that is out of date or is not a fileok false with the reason The preview is out of date, or the document is not a file.
a failed dialogok false with the message of the error (a value that is not an Error as its string)
boundaryShape of the request
InputOutcome
a previewPickImage message with a non-empty editId of at most 100 charactershandled; previewPickImageResult repeats the editId (see SwRS-MDOKFSTUDIO-TRUST-090)
a message without a valid editIdignored by the envelope check (see SwRS-MDOKFSTUDIO-TRUST-052)
an SVG fileaccepted for a reference (unlike a pasted image)
a path with Windows separatorsaccepted and written with forward slashes

Implemented in 1

Tested by 4