Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-TOOLBAR-077

A click or Enter on a link is routed to the host and opened or refused with a warning

When the reader clicks, middle-clicks or presses Enter or Space on a link that carries a navigation request, the extension SHALL cancel the default action, post previewLink with that request and have the host open the target or show a warning with the reason when it cannot; the host follows nothing when the message carries no request and refuses a malformed frontmatter link request with the reason The frontmatter link request is invalid.

Step 3 of path 1 in StRS-MDOKFSTUDIO-TOOLBAR-011: from “The tooltip names where the link leads” to “The target is open”.

Part of StRS-MDOKFSTUDIO-FMSCHEMA-014, outside the paths drawn on its map.

Scenarios 10

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

nominalClick, middle click and keys are posted
GivenWhenThen
a local link and a wiki link that the host has not been asked about yeteach is clicked, then the first is middle-clickedeach click posts previewLink with the link's request and the default action is cancelled
a focused linkEnter is pressedpreviewLink is posted
a focused linkSpace is pressedpreviewLink is posted
boundaryEdit mode keeps a plain click for editing
Given, edit mode onWhenThen
a link inside a mapped blockit is clicked, or Enter or Space is pressed on it, with no Cmd or Ctrl keyno previewLink is posted; the editor of the block opens (SwRS-MDOKFSTUDIO-BLOCK-014)
the same linkit is clicked with Cmd or Ctrl held, Cmd/Ctrl+Enter is pressed on it, or it is middle-clickedpreviewLink is posted
a link value of the properties table, in a comment thread or a label anchorit is clickedit keeps its own behaviour, as in reading mode
refusalOther buttons and keys are not posted
GivenWhenThen
an auxclick with button 2the event arrivesnothing is posted and the default action stays
a focused linkthe letter a is pressednothing is posted
nominalThe host opens the target
Link followedOutcome
second.md#targetsecond.md opens in the text editor with the lines of the heading selected
second.md#missingsecond.md opens with no selection
a normal Markdown fileit opens and no warning is shown
https://example.invalid/page (http, https or mailto)the system opener is called once with the URL and the preview and the history are unchanged
refusalThe host refuses with a warning
Link followedOutcome
javascript:alert(1)the warning "Markdown OKF-Schema Studio could not follow the link: {reason}" is shown with the scheme reason, the system opener is not called and the history is unchanged
a valid Markdown linkno such warning is shown
a link to a file that cannot be opened as a text documentthe warning "Markdown OKF-Schema Studio could not open {path}: {reason}" is shown with the path and the reason
a link whose resolution raises an errorthe warning "Preview link resolution failed: {error}" is shown and nothing is recorded
a resolvable linkno resolution warning is shown
nominalWith a request
Givena previewLink message with a request
Whenthe host receives it
Thenthe link is followed
refusalNo request
Givena previewLink message with no request field
Whenthe host receives it
Thenonly the page's scroll state is recorded, no link is resolved and nothing opens
refusalMalformed frontmatter link request
Givena navigation request okf-link: followed by text that is not valid JSON
Whenthe request is handled
Thenthe reason reads The frontmatter link request is invalid. and nothing opens
nominalWell-formed frontmatter link request
Givena request whose JSON names an existing link
Whenthe request is handled
Thenthe link is followed
refusalRequest that is not a string
Givena previewLink message whose request is not a string
Whenthe validator runs
Thenthe message is refused (see SwRS-MDOKFSTUDIO-TRUST-052)

Implemented in 3

Tested by 7

Replaces

SwRS-MDOKFSTUDIO-FMSCHEMA-083A malformed frontmatter link request is refused superseded superseded by SwRS-MDOKFSTUDIO-TOOLBAR-077 Markdown file
SwRS-MDOKFSTUDIO-TOOLBAR-113A link message needs a request, else it is ignored or refused superseded superseded by SwRS-MDOKFSTUDIO-TOOLBAR-077 Markdown file