Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-TRUST-001

A document is editable whatever the trust; only its reads are restricted

When a preview is created for a document that lies in no workspace folder, or while the workspace is untrusted, the extension SHALL keep every editing affordance on, as in a trusted workspace, and narrow only what the preview reads.

Step 1 of path 1 in StRS-MDOKFSTUDIO-TRUST-001: from “A preview is created for a document in no workspace folder, or in an untrusted workspace” to “The document is editable”.

Part of StRS-MDOKFSTUDIO-BLOCK-001, outside the paths drawn on its map.

Scenarios 5

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

nominalRestricted reads at creation
Givena Markdown document and a window
Whenthe reader opens the preview with the Open Preview to Side command or with Open With
Thenthe preview has full reads when the document lies inside a folder of a trusted workspace, and restricted reads otherwise; in both cases it is editable
InputOutcome
Trusted workspace, document inside one of its foldersFull reads, editable
Window in Restricted Mode (untrusted workspace)Restricted reads, editable; the command preview and the Open With editor report restrictedReads true
Markdown file that lies in no workspace folder of a trusted window (standalone file)Restricted reads, editable
A file that VS Code holds read-only (files.readonlyInclude, or made read-only in the session)The preview offers the same controls; every write path (label rename, thread reply and delete, find and replace, block save, move, cut, paste, drop, checkbox and radio toggle, metadata save) checks that VS Code wrote the edit, and answers "This file is read-only in VS Code." when it accepted the edit and left the text unchanged; a pasted image whose block save fails that way is deleted again
nominalEvery editing affordance is present
Givena preview with restricted reads of a document with at least five frontmatter fields, a table and a paragraph
Whenthe reader looks at the page and acts on it
Theneach affordance below is present and works as in a trusted workspace
AffordanceIn a preview with restricted reads
Edit buttonEnabled: the toolbar holds the same four rows with 16 buttons, the Edit button has no aria-disabled attribute and its title and tooltip say "Edit mode"; a click toggles the edit mode
Edit mode at startOff, or on when the saved state of the same document holds edit mode true
Edition paletteBuilt, and the palette mode message previewPaletteModeChanged is posted and stored for the workspace
Comment buttonInstalled (the runtime context carries commentsEnabled true); Cmd+Alt+M or Ctrl+Alt+M opens the comment box
Thread popoverThe reply box and the Resolve and Delete buttons exist
Properties tableThe name and value cells carry data-okf-edit-cell and the rows say data-okf-editable true
Edit target under the pointerWith edit mode on, a paragraph under the pointer is outlined as the block a click would edit (see SwRS-MDOKFSTUDIO-BLOCK-017)
Click on a paragraph, a table cell, a frontmatter valueThe block, cell or field editor opens (see SwRS-MDOKFSTUDIO-TABLE-001 and SwRS-MDOKFSTUDIO-FMEDIT-001)
Checkboxes and radio optionsEnabled; a click is written to the source
boundaryWhat stays off because it needs trust
Givena preview with restricted reads
Whenthe reader uses a feature of the table
Thenthe feature is off, and the reason is shown where it is used or in the existing diagnostics; there is no banner
Feature that needs trustIn a preview with restricted reads
PlantUML with Java (the jar pipeline)No process starts; the diagram shows "PlantUML preview is disabled in an untrusted workspace." (see SwRS-MDOKFSTUDIO-DIAG-024)
Includes, images and resourcesRead from the folder of the document only, never below a dot-directory, images only outside it (see SwRS-MDOKFSTUDIO-TRUST-002)
Schema lookup of the properties tableNot resolved; the generic table shows an info row (see SwRS-MDOKFSTUDIO-FMSCHEMA-019)
Citation list of the paletteRefused with "Listing citations searches the workspace for .bib files, which needs a trusted workspace folder that holds this file." (see SwRS-MDOKFSTUDIO-TRUST-005)
Linked scripts of the documentNot allowed (the sanitizer removes them in every mode)
MyST extension warnings in the Problems view, and the incoming-change marksPublished only for a trusted workspace (see SwRS-MDOKFSTUDIO-MYST-078); the incoming-change marks are posted for a trusted, tracked file only
Workspace values of the restricted settingsIgnored (see the manifest scenario)
boundaryTrust granted or a folder added while a preview is open
InputOutcome
A preview created in an untrusted workspace, then the reader trusts the workspaceThe preview moves to a session with full reads without being reopened: it renders once and keeps its reading state; its resource roots and navigation roots become the workspace folders
A preview created in a trusted workspace, then trust is granted againIt keeps its session
A preview of a file in no workspace folder of a trusted window, then a folder that holds the file is added (in the Agents window, the folder of the agent session becomes active)The preview moves to a session of that folder with full reads on the same panel, renders once and keeps its reading state; the active preview stays the active one
The same, for a preview of a file that the added folder does not holdIt keeps restricted reads, on its own session
Any of the above while the preview has an open block, cell or field editorThe page is asked to save and close its editor first (the previewFlushEdit request, as before a document switch), then the session is replaced: the typed text is kept

A preview whose folder is removed gets restricted reads on the same panel: see SwRS-MDOKFSTUDIO-LIFE-143.

boundaryThe manifest declares limited support for untrusted workspaces
Giventhe package.json of the extension, which has a main entry point
WhenVS Code decides whether the extension runs in a window in Restricted Mode
Thenthe extension runs, because the manifest declares the limited support, and its description says that editing stays on and reads are narrowed
InputOutcome
capabilities.untrustedWorkspaces.supported in package.json"limited", with a description that says the reader can still edit, and does not call the preview read-only
capabilities.untrustedWorkspaces.restrictedConfigurationsThe PlantUML engine settings plantuml.useJar and plantuml.jarPath, and the frontmatter path settings frontmatter.bundleRoot, frontmatter.projectRoot and frontmatter.allowOutsideWorkspaceLinks: a value from the workspace is ignored in Restricted Mode. The list is generated from the settings registry by just generate-settings
A manifest without the declaration, or with another valueThe check fails (VS Code then disables a packaged extension in Restricted Mode)

Implemented in 13

Tested by 16