.html/.htm/.xhtml op previews (read / write / edit, non-error) gain a Render/Raw toggle in the preview pane head: the render view loads the SAVED file through the same /sidebar/html route the editor's html viewer uses, so relative assets (./style.css, img/x.png) resolve inside the route and a segmented read still renders the whole document (the route serves the file, not the op snapshot — the file-trace-style srcDoc approach would render a cut-off document whose scripts never run). The frame is ALWAYS sandboxed (HTML_IFRAME_SANDBOX, moved to the shared html-preview.ts module — opaque origin, no allow-same-origin, no top-navigation) plus the route's CSP sandbox header as defense-in-depth; unlike the editor viewer this surface has no no-sandbox escape hatch. The contract is pinned by new sandbox-spec tests on the extracted HtmlRenderPreview component and the pane toggle (off by default; absent for non-html and error targets). Locales: zh/en + all 19 shipped third-language overrides (key-set-equal gate green). Typecheck + eslint clean; sandbox/redact/diff-rows/frontmatter suites 36/36 green. The full-suite host-side failures (fs-operations / pty smoke / git / install-powershell) are pre-existing on the base branch (verified via stash) and unrelated.
16 lines
705 B
TypeScript
16 lines
705 B
TypeScript
/**
|
|
* Shared vocabulary of the sidebar's HTML preview surfaces (the editor's
|
|
* html viewer and the changes tab's op render preview): the sandbox tokens
|
|
* both preview iframes load with.
|
|
*/
|
|
|
|
/**
|
|
* The sandbox tokens of an HTML preview iframe. NO allow-same-origin (the
|
|
* preview must stay in an opaque origin — with the route's own origin it
|
|
* could read session data) and NO allow-top-navigation (a previewed page
|
|
* must not hijack the GUI). The editor viewer can disable the sandbox
|
|
* per-feature in the side card settings (warned); the changes tab's op
|
|
* render preview always stays sandboxed.
|
|
*/
|
|
export const HTML_IFRAME_SANDBOX = 'allow-scripts allow-popups allow-downloads allow-modals'
|