Behaviour SwRS-MDOKFSTUDIO-TOOLBAR-134
Export to HTML is a command and a toolbar button that save one file
When the writer runs Export to HTML from the command palette or presses the Export button of the preview toolbar, the extension SHALL ask where to save the file, offering the folder and name of the page with an html extension, and write the page there, writing nothing when the dialog is cancelled and telling the writer when the file is written or cannot be.
Step 1 of path 1 in StRS-MDOKFSTUDIO-TOOLBAR-014: from “A preview page is shown” to “The place to save is chosen”.
Scenarios 3
The situations the tests check; open one to read it.
nominalThe Export button saves the page
Givena preview of `notes/page.md`
Whenthe writer presses the Export button, the last button of the main toolbar row but one (Refresh, Edit, Export, collapse), and accepts the save dialog
Thenthe dialog offers `notes/page.html` with an HTML filter, one HTML file is written at the chosen path, and the extension shows an information message that names the file
nominalThe command exports the preview in use
Givena focused preview panel, or a Markdown file open in the editor with its preview
Whenthe writer runs Export to HTML from the command palette
Thenthat preview exports its page; with no preview of the active file the extension tells the writer to open it first
boundaryCancel, refusal and failure
| Input | Outcome |
|---|---|
| The save dialog is cancelled | Nothing is written and no message is shown |
| A request that no click and no command asked for | The host ignores it and shows no dialog |
| The write fails | An error message names the cause and no success message is shown |
| Restricted Mode | The export is available; images are read with the narrowed Restricted Mode reads |
| A page with no folder on disk | The dialog offers the first workspace folder |
| A page whose snapshot is over 50 million characters | The page shows "This page is too large to export." in its status region, sends nothing and the button works again |
| A snapshot the host cannot read (wrong shape) or that names another document | The host answers with a refusal and an error message, and the button works again |
Implemented in 10
- src/core/preview/previewToolbar.ts
- src/core/protocol/hostToPage.ts
- src/core/protocol/pageToHost.ts
- src/host-vscode/activation.ts
- src/host-vscode/vscodeHost.ts
- src/page/features/hostHandlers.ts
- src/page/modules/exportSnapshot.ts
- src/page/runtime.ts
- src/session/features/htmlExport.ts
- src/session/previewManager.ts