Markdown OKF-Schema Studio

Behaviour SwRS-MDOKFSTUDIO-LIFE-169

A view choice made on the page is stored for the workspace

When the writer changes a view choice on the page, the extension SHALL keep it in the saved state of the panel, post it to the host with the identity of the page, and let the host validate it and store it for the workspace according to the table of view choices.

Step 1 of path 2 in StRS-MDOKFSTUDIO-LIFE-014: from “The reader changes a view choice on the page” to “The view choice is stored”.

Another outcome at step 2 of path 1 in StRS-MDOKFSTUDIO-BLOCK-001, in the state “Edit mode is on”.

Scenarios 12

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

nominalOne row per view choice
Givena preview with the identity of its current render
Whenthe writer changes one of the view choices of the table
Thenthe page writes the saved-state field of the row next to the other saved fields, posts the message of the row with the document, revision and request identity of the page, and the host stores the value under the storage key of the row
View choicePage controlSaved-state fieldMessage and fieldAccepted valuesHost validationStorage keyPreview with restricted reads
Edit modeEdit buttoneditModepreviewEditModeChanged, editModebooleanDropped unless the value is a booleanmarkdownOkfSchemaStudio.editModeStored like any other
Palette modeMode select of the block editorpaletteModepreviewPaletteModeChanged, modestrict, gfm, myst, fullDropped unless the mode is one of the fourmarkdownOkfSchemaStudio.paletteModeStored like any other
Theme modeTheme buttonpreviewThemeModepreviewThemeModeChanged, previewThemeModecurrent, dark, white, creamDropped unless the value is one of the fourpreviewThemeModeStored
ZoomZoom in and Zoom outviewZoompreviewViewPreferenceChanged, preference zoominteger from 70 to 200Refused outside the range or when not an integermarkdownOkfSchemaStudio.viewPreferences, field zoomStored
Width modeWidth buttonviewWidthModepreviewViewPreferenceChanged, preference widthModemargin, auto, fullRefused for any other valuemarkdownOkfSchemaStudio.viewPreferences, field widthModeStored
Table of contentsTable of contents buttonviewTocpreviewViewPreferenceChanged, preference tocbooleanRefused when not a booleanmarkdownOkfSchemaStudio.viewPreferences, field tocStored
Toolbar collapsedChevron of the toolbarviewToolbarCollapsedpreviewViewPreferenceChanged, preference toolbarCollapsedbooleanRefused when not a booleanmarkdownOkfSchemaStudio.viewPreferences, field toolbarCollapsedStored
CommentsComments buttonviewCommentspreviewViewPreferenceChanged, preference commentsbooleanRefused when not a booleanmarkdownOkfSchemaStudio.viewPreferences, field commentsStored
Incoming changesDiff buttonviewIncomingChangespreviewViewPreferenceChanged, preference incomingChangesbooleanRefused when not a booleanmarkdownOkfSchemaStudio.viewPreferences, field incomingChangesStored
Anchor modeAnchor buttonanchorToEditorpreviewAnchorModeChanged, anchorToEditorbooleanDropped unless the value is a booleanNone: set as scrollPreviewWithEditor in the configuration and the loaded context of that preview onlyApplied to that preview
nominalThe page keeps its saved state
Givena saved state that already holds scroll fields and other view fields
Whenthe writer presses the Theme button, the Edit button, a Zoom button, the Width button, the Table of contents button or the chevron, or the page writes a state snapshot
Thenthe saved state holds the new value (previewThemeMode dark after Current, editMode true then false on two presses, viewZoom 110 from 100, viewWidthMode auto from margin, viewToc true, viewToolbarCollapsed true then false on a second press with a second message of value false) and keeps its other fields; after a patch to a newer revision the message carries the identity the patch moved the page to (untested for this message); the snapshot keeps previewThemeMode (cream in Cream mode), the TOC visibility and the folded sections
nominalThe host stores a preference as one normalized object
Givena workspace storage and a previewViewPreferenceChanged message with preference toc and value true
Whenthe host handles the message
Thenthe session preferences hold toc true and the key markdownOkfSchemaStudio.viewPreferences holds the whole normalized preferences object, not the one field
nominalThe host remembers a valid theme, edit mode or palette mode
Givenan open preview whose workspace holds no stored value
Whenthe page reports previewThemeModeChanged dark, previewEditModeChanged with editMode true, or previewPaletteModeChanged gfm
Thenthe value is held for the session where the row says so, written to the workspace storage, and carried by the boot context of the next page of the workspace (the theme mode dark; the palette mode gfm wins over the setting)
boundaryZoom and own-key rows of a view preference message
InputOutcome
zoom 70, 130 and 200all three are accepted
zoom 60, 210, 1.2, the text 100 and NaNall five are dropped without an answer and the stored zoom is unchanged
toc, incomingChanges, comments and toolbarCollapsed with a boolean; widthMode margin, auto or fulleach message is accepted
toc of the string true, comments of 1, widthMode wide or the number 1each message is refused and the host does not change a preference
an unknown preference name, or a name that is not an own key of the validatorsrefused
boundaryNo change, no message
Givena page at 200 percent zoom, or a page that has just started
WhenZoom in is clicked at 200 percent, or nothing is clicked, or the page calls setMode on the palette
Thenno zoom message and no previewPaletteModeChanged message is posted; a chosen palette mode in the select posts exactly one previewPaletteModeChanged (from the GFM mode choosing MyST: one message with mode myst, saved state paletteMode myst)
refusalThe host refuses a value outside the table
Givenan open preview
Whena message arrives with the width mode wide, a zoom outside 70 to 200, a preference name that is not in the table, a theme mode that is not one of the four, a palette mode that is not strict, gfm, myst or full, or an editMode or anchorToEditor that is not a boolean
Thenthe message is refused or ignored by the validator of its type and the stored value is unchanged
refusalA stale message stores nothing where the row says so
Givena message that names an older render than the page now holds, or an edit mode or palette mode report whose value is invalid
Whenthe host receives it
Thenthe stale message is dropped before its handler (by the page-state gate for previewThemeModeChanged, previewEditModeChanged and previewAnchorModeChanged, by the render gate for previewViewPreferenceChanged and previewPaletteModeChanged), an invalid edit mode or palette mode is not stored, and no preference changes
boundaryThe storage is missing or rejects the write
Givenworkspace storage whose update fails, or choices whose storage is not loaded or was released at deactivation
Whenthe host stores a theme mode or a view preference picked by the reader
Thenthe value is held for the session, a rejected write is logged to the output channel of the extension as "Failed to persist the Markdown preview theme mode." or "Failed to persist the Markdown preview view preferences." and shows the reader one warning, "The Markdown preview could not save your display choice; it holds until VS Code closes.", repeated only after a write succeeded in between, and with no storage nothing is written and nothing is logged
boundaryStored preferences are normalized field by field
Stored valueOutcome
widthMode bad and toc truewidthMode margin, toc stays true (only the bad field is replaced)
A list, or missingEvery field has its default: zoom 100, widthMode margin, toc off, incomingChanges on, comments on, toolbarCollapsed on
Any applied preferenceThe whole object is normalized again (applyViewPreference), so the stored object is always valid
refusalA palette mode or a theme mode outside the four is dropped
Givena workspace whose stored palette mode is gfm and an open preview
Whenthe page posts previewPaletteModeChanged with a mode of the table, or previewThemeModeChanged with a theme mode of the table
Thenthe message is rejected by the protocol validator of its type, nothing is stored, no result is posted to the page, and the next preview still starts in the stored mode
MessageField valueOutcome
previewPaletteModeChangedhtmlrejected
previewPaletteModeChangedthe empty textrejected
previewPaletteModeChangeda number or true (not a string)rejected
previewPaletteModeChangedmissingrejected
previewThemeModeChangedsepia (or neon)rejected
previewThemeModeChangedmissing previewThemeModerejected
nominalAn accepted palette mode or theme mode
Givena palette whose select changes to another of the modes strict, gfm, myst or full, or the Theme button pressed (any of current, dark, white and cream)
Whenthe page posts the message once, with the identity fields documentId, revision and requestId (the envelope is checked first, see SwRS-MDOKFSTUDIO-TRUST-052) and the field mode or previewThemeMode
Thenthe host accepts it through the gate of its type (see SwRS-MDOKFSTUDIO-TRUST-065), stores the mode for the workspace, and the next preview starts in it (see SwRS-MDOKFSTUDIO-LIFE-170)

Implemented in 14

Tested by 15

Replaces

SwRS-MDOKFSTUDIO-LAYOUT-021A width mode choice is saved for the workspace superseded superseded by SwRS-MDOKFSTUDIO-LIFE-169 Markdown file
SwRS-MDOKFSTUDIO-PALETTE-010An unknown palette mode is refused and stores nothing superseded superseded by SwRS-MDOKFSTUDIO-LIFE-169 Markdown file
SwRS-MDOKFSTUDIO-THEME-013The host drops a theme-mode message with an unknown mode superseded superseded by SwRS-MDOKFSTUDIO-LIFE-169 Markdown file
SwRS-MDOKFSTUDIO-TOOLBAR-013The host accepts only a known view preference with a valid value superseded superseded by SwRS-MDOKFSTUDIO-LIFE-169 Markdown file