@aiquants/markdown-explorer 0.26.0 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +71 -0
- package/README.md +45 -26
- package/dist/{EditSurface-Blymamic.js → EditSurface-BYKUL-a1.js} +32 -32
- package/dist/{EditSurface-Co4Rvfa1.cjs → EditSurface-wXPvuB2n.cjs} +2 -2
- package/dist/{ExplorerSplit-BZ0PA3z3.js → ExplorerSplit-Bz-1G42e.js} +94 -94
- package/dist/{ExplorerSplit-WApgYMPb.cjs → ExplorerSplit-CLxr4_0K.cjs} +1 -1
- package/dist/MultiLayout-Coc-HQUb.cjs +1 -0
- package/dist/{MultiLayout-B5-1N3JD.js → MultiLayout-DpxzsXKz.js} +167 -168
- package/dist/NativeScrollBar-CDgYgxXK.cjs +1 -0
- package/dist/{NativeScrollBar-BraWuZvN.js → NativeScrollBar-DLdveoaN.js} +6 -7
- package/dist/{TreeLayout-CChoxh9W.js → TreeLayout-C8TuS9ue.js} +9 -9
- package/dist/{TreeLayout-C60lb9hP.cjs → TreeLayout-CJrJNZHq.cjs} +1 -1
- package/dist/core/config.d.cts +7 -0
- package/dist/core/config.d.ts +7 -0
- package/dist/core/contracts.d.cts +8 -2
- package/dist/core/contracts.d.ts +8 -2
- package/dist/core/dataRoute.d.cts +40 -0
- package/dist/core/dataRoute.d.ts +40 -0
- package/dist/core/labels.d.cts +10 -1
- package/dist/core/labels.d.ts +10 -1
- package/dist/{dataRoute-BEvesOvN.js → dataRoute-DLhQfdoW.js} +111 -103
- package/dist/dataRoute-DwYtgyt6.cjs +1 -0
- package/dist/index-CdYr9OQ-.js +4805 -0
- package/dist/index-CjyRD7qg.cjs +15 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +29 -28
- package/dist/{location-DIxIjqs7.js → location-CKuabtKl.js} +152 -147
- package/dist/location-l_HysaZR.cjs +1 -0
- package/dist/{merge-CgSp-0Dd.js → merge-BQgbDcHR.js} +1 -1
- package/dist/{merge-DRWmjC24.cjs → merge-DRLuveD9.cjs} +1 -1
- package/dist/{sanitizePolicy-gVKBhabq.js → sanitizePolicy-By0tKOpZ.js} +1 -1
- package/dist/{sanitizePolicy-CZwOaJ92.cjs → sanitizePolicy-T5T-3vV5.cjs} +1 -1
- package/dist/sanitizeWorker.cjs +1 -1
- package/dist/sanitizeWorker.js +1 -1
- package/dist/server/ports.d.cts +4 -3
- package/dist/server/ports.d.ts +4 -3
- package/dist/server.cjs +1 -1
- package/dist/server.js +500 -493
- package/dist/styles/markdown-explorer.css +1 -1
- package/dist/tapScrollCircle-B2A6CmmI.js +13 -0
- package/dist/tapScrollCircle-qD8iSmfq.cjs +1 -0
- package/dist/{useSplitPersistence-D-T75Hlh.cjs → useSplitPersistence-9Nu6J1WF.cjs} +1 -1
- package/dist/{useSplitPersistence-Df63lnQZ.js → useSplitPersistence-Bf4M35Il.js} +1 -1
- package/docs/behavior/dom-hooks.md +10 -6
- package/docs/behavior/layout.md +12 -4
- package/docs/behavior/localization.md +5 -2
- package/docs/behavior/security.md +7 -2
- package/docs/behavior/url-contract.md +3 -3
- package/package.json +5 -5
- package/dist/MultiLayout-dAW_JCzg.cjs +0 -1
- package/dist/NativeScrollBar-ThVMbI0Y.cjs +0 -1
- package/dist/dataRoute-Cv7fgCW7.cjs +0 -1
- package/dist/index-B6FkGD-p.cjs +0 -13
- package/dist/index-Bd6hgisa.js +0 -4097
- package/dist/location-D3DgoELB.cjs +0 -1
- package/dist/scrollBarGeometry-C46jBtmM.cjs +0 -1
- package/dist/scrollBarGeometry-DOBdGNV-.js +0 -4
- package/dist/tapScrollCircle-C5DGI-0H.cjs +0 -1
- package/dist/tapScrollCircle-u4EXeLhx.js +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,76 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.28.0 (2026-10-28) — The tap-scroll circle in a gutter of its own, clear of the document
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
|
|
7
|
+
- **The tap-scroll circle sits in a gutter beside its bar, and no content lies under it (readers).** Every document
|
|
8
|
+
scroller with a circle — the viewer's scroll container, the image, media, file and failure views and each multi-view
|
|
9
|
+
panel's scroll area — keeps a 54 px gutter at its inline end, outside its own padding: the circle (one control,
|
|
10
|
+
44 px) with 5 px on each side, so the circle now sits 49 px before its bar instead of 80 px. A right-aligned toolbar
|
|
11
|
+
(a Mermaid diagram's, a table block's, an SVG image's), a code block's copy button or a focused link is no longer
|
|
12
|
+
covered when the reader scrolls it to the circle's height; only an image zoomed wider than its canvas still passes
|
|
13
|
+
beneath the circle while it pans sideways. The wheel and touch scroll over the gutter as over the document, and the
|
|
14
|
+
gutter is kept while the content fits, so the text never re-wraps when the bar appears. The document's text column
|
|
15
|
+
is 54 px narrower for it. The tree's circle moves with the same setting and still lies over the rows (a gutter would
|
|
16
|
+
take 54 px from a 13rem pane); the stage keeps its bar without a circle.
|
|
17
|
+
- **The peer `@aiquants/markdown` is `^11.7.0` (hosts),** whose `scrollBarGutter` the explorer gives the viewer.
|
|
18
|
+
|
|
19
|
+
## 0.27.0 (2026-10-27) — Workbooks shown sheet by sheet: Excel and OpenDocument read in the browser
|
|
20
|
+
|
|
21
|
+
### Breaking
|
|
22
|
+
|
|
23
|
+
- **A spreadsheet document's `firstSheetOnly` is replaced by `firstSheetText` (hosts).** `format` is `"csv"`, `"tsv"`
|
|
24
|
+
or the new `"workbook"` (an Office Open XML workbook or an OpenDocument spreadsheet, which the browser reads), and
|
|
25
|
+
`firstSheetText` (`"csv"`, `"tsv"` or `null`; `null` for every CSV or TSV file and for a stored workbook) names the text
|
|
26
|
+
of the first sheet your storage delivers when it converts the file on read and cannot deliver the workbook. An answer
|
|
27
|
+
that still carries `firstSheetOnly` breaks the contract (logged, `failed`). A host that exported a Google Sheets
|
|
28
|
+
spreadsheet as CSV with `firstSheetOnly: true` answers `{ format: "workbook", firstSheetText: "csv" }` and exports it as
|
|
29
|
+
`.xlsx` when the `asset` port is asked for a workbook (below).
|
|
30
|
+
- **The `asset` port's fourth argument is `{ delivery }` instead of `{ redirect }` (hosts).** `delivery` is `"file"` for
|
|
31
|
+
the stored file (the only delivery a redirect may answer, where `redirect` was `true`), `"text"` for `&as=text` and the
|
|
32
|
+
`text` operation, and `"workbook"` for the new `&as=workbook`, for which a storage that converts the file on read
|
|
33
|
+
delivers a workbook.
|
|
34
|
+
- **The label `spreadsheetFirstSheetOnly` is gone (hosts).** A host that overrode it overrides
|
|
35
|
+
`spreadsheetWorkbookFirstSheet`, which says the whole workbook could not be read.
|
|
36
|
+
- **The peers `@aiquants/markdown` and `@aiquants/spreadsheet` are `^11.6.3` and `^0.17.2` (hosts).**
|
|
37
|
+
|
|
38
|
+
### Added
|
|
39
|
+
|
|
40
|
+
- **Workbooks show every shown sheet (readers).** An `.xlsx`, `.xlsm` or `.ods` file, and a workbook a storage converts
|
|
41
|
+
on read, is read whole through the workbook delivery and opened in the browser by the explorer's own reader (the
|
|
42
|
+
browser's built-ins only: no dependency); its shown sheets are tabs above the table (manual activation: the arrow keys,
|
|
43
|
+
Home and End move the focus, Enter, Space or a press selects; 44 px targets in a row that wraps), each read when first
|
|
44
|
+
shown and kept, the chosen one kept across a refresh. Hidden sheets and sheets without a table are left out and
|
|
45
|
+
counted in a note; a cell shows its stored value through its number format (dates and times in both date systems,
|
|
46
|
+
percentages, fixed decimals with grouping); a password-protected workbook, bytes that are no workbook (a legacy `.xls`
|
|
47
|
+
included) and a workbook past the budget show a note with the download. A document with `firstSheetText` whose
|
|
48
|
+
delivery brings no workbook shows its first sheet's text as before, below the note `spreadsheetWorkbookFirstSheet`.
|
|
49
|
+
- **`spreadsheets.maxWorkbookBytes`** (a positive integer up to 256 MiB, default 8 MiB, `WORKBOOK_BYTE_LIMITS`): the
|
|
50
|
+
most bytes the browser reads of a workbook.
|
|
51
|
+
- **The asset's workbook delivery (`&as=workbook`)**: the whole file the port delivers for `delivery: "workbook"`, as an
|
|
52
|
+
`application/octet-stream` attachment with the ETag `"workbook;<version>"` (a `Range` is ignored).
|
|
53
|
+
- **`createFileSystemSource` answers `.xlsx`, `.xlsm` and `.ods` files as `workbook` spreadsheet documents**, where they
|
|
54
|
+
were `file` documents (downloads).
|
|
55
|
+
- Exports: `WORKBOOK_BYTE_LIMITS` and the type `ExplorerSheetTextFormat`.
|
|
56
|
+
- Labels: `spreadsheetSheets`, `spreadsheetSheetName`, `spreadsheetUnshownSheets`, `spreadsheetUnlistedSheets`,
|
|
57
|
+
`spreadsheetSheetLoading`, `spreadsheetSheetEmpty`, `spreadsheetWorkbookEncrypted`, `spreadsheetNotWorkbook`,
|
|
58
|
+
`spreadsheetWorkbookTooLarge` and `spreadsheetWorkbookFirstSheet`.
|
|
59
|
+
|
|
60
|
+
### Changed
|
|
61
|
+
|
|
62
|
+
- **A workbook has no Source toggle, and its Open in a new tab opens the file itself (readers)**, unless the document
|
|
63
|
+
names its first sheet's text, which opens as plain text.
|
|
64
|
+
- **Tables take the 11.6.3 block and the 0.17.2 grid (readers).** A block without its toolbar starts with no highlight
|
|
65
|
+
bands; a refit of the columns reads a quoted font family name that holds a comma; a press into a tall grid keeps the
|
|
66
|
+
page still, and PageUp and PageDown measure what the reader sees and always move a row.
|
|
67
|
+
|
|
68
|
+
### Demo
|
|
69
|
+
|
|
70
|
+
- **`notes/tables/workbook.xlsx` (three sheets, a hidden sheet and a chart sheet) and `notes/tables/workbook.ods` (two
|
|
71
|
+
tables and a hidden one)**, linked from the guide; the guide's file the explorer cannot show is now
|
|
72
|
+
`notes/report.xls`, a legacy Excel workbook.
|
|
73
|
+
|
|
3
74
|
## 0.26.0 (2026-10-27) — Tables drawn as their original print, on @aiquants/markdown 11.6.1 and @aiquants/spreadsheet 0.17.1
|
|
4
75
|
|
|
5
76
|
### Breaking
|
package/README.md
CHANGED
|
@@ -28,10 +28,11 @@ Inside a rendered document, a storage SVG image that stands alone in a paragraph
|
|
|
28
28
|
a toolbar above it, at the row's end: the toggle shows the image's SVG in its place through the same operation, and the
|
|
29
29
|
image again on a second press, and Copy copies the image as a PNG that pastes as an image while the image shows, and the
|
|
30
30
|
SVG as written while the source shows.
|
|
31
|
-
A table file — a CSV or TSV file, or a workbook
|
|
32
|
-
|
|
33
|
-
encoding (a byte order mark's, UTF-8 or the configured
|
|
34
|
-
|
|
31
|
+
A table file — a CSV or TSV file, or a workbook: Excel `.xlsx` and `.xlsm`, OpenDocument `.ods`, and one the host
|
|
32
|
+
converts on read, such as a Google Sheets spreadsheet — shows as a read-only grid under its file header, named after
|
|
33
|
+
the file: the browser reads the file itself, a text file in its encoding (a byte order mark's, UTF-8 or the configured
|
|
34
|
+
legacy encoding) and a workbook with every shown sheet behind a tab, and stops once the table holds as much as a grid
|
|
35
|
+
shows, saying so (see [Table files](#table-files)).
|
|
35
36
|
With the server's `edit` ports, a Markdown document also offers **Edit**: the reader edits its Markdown in place
|
|
36
37
|
(CodeMirror, loaded on demand), from where they were reading or from the word they double-clicked, saves over the
|
|
37
38
|
version the draft started from (changes saved elsewhere are merged line by line, and conflicts are resolved in the
|
|
@@ -48,12 +49,13 @@ A single-view (embedding) page never downloads the tree and multi-panel views, w
|
|
|
48
49
|
|
|
49
50
|
- React 19.2.7 or later and React Router 8 in framework mode (route modules with `loader` / `headers`).
|
|
50
51
|
- Node.js 22.22 or later (the floor React Router 8 declares). The package ships ES modules and CommonJS; the CommonJS entries load the ESM-only `react-router` through `require(esm)`.
|
|
51
|
-
- The peer packages, at these versions or later within the caret ranges the package declares: `@aiquants/markdown` ^11.
|
|
52
|
+
- The peer packages, at these versions or later within the caret ranges the package declares: `@aiquants/markdown` ^11.7.0 (document rendering;
|
|
53
|
+
the gutter its scroll container keeps beside the explorer's bar for the tap-scroll circle (`scrollBarGutter`); the Source toggle of a storage SVG image that stands alone in a paragraph, read through `imageSource`, and a Copy that copies the image as a PNG image or its source, the source readable in every display style, a notice in place of a block that cannot render and plain text for a fence in a language it does not know; its components' stylesheet without utilities,
|
|
52
54
|
its controls' 44 px targets under every pointer, ```spreadsheets tables — inside list items and quotes too, and in a pane of their own (`layout="fill"`) never fewer than three rows, with the display options `toolbar=`, `zoom=`, `headings=` and `autofit=`, every row shown when `height` reaches the table's, and boxes no wider than the table — and their write-back through an editor that answers what came of each write (written, changed, a line that would close the fence, unwritable), reads a block's body back and tells them of its other changes,
|
|
53
55
|
the React-free `@aiquants/markdown/code-blocks` that names the `data-code-meta` the sanitizer keeps on `code`, holds the converter's reading of a fenced block's lines and the table labels with their placeholders,
|
|
54
56
|
its Mermaid labels and drawings that finish inside the document when a diagram's text changes or it unmounts mid-drawing, its math diagnostics, gantt sizing, embeds, link cards and their sizes, the React-free `@aiquants/markdown/embeds` the sanitizer worker loads and `@aiquants/markdown/source-lines` the editor and the sanitizer read, and the Node-only link-card handler of `@aiquants/markdown/server`, which needs Node.js 22.13 or later — below the explorer's own floor),
|
|
55
57
|
`@aiquants/directory-tree` ^5.0.1 (rows that take paint and text styles only and have no vertical padding, a `removeRootIndent` shift that keeps the root's icon whole, and reveals of rows under the scroll bar's buttons),
|
|
56
|
-
`@aiquants/drag-drop-panels` ^0.12.0 (the panel headers' move menu, named by the explorer's `panelMove`, their 44 px buttons under every pointer and the header arrangement the behavior docs follow), `@aiquants/resize-panels` ^2.2.0 (the source of each layout change, by which the tree pane's width is saved), `@aiquants/spreadsheet` ^0.17.
|
|
58
|
+
`@aiquants/drag-drop-panels` ^0.12.0 (the panel headers' move menu, named by the explorer's `panelMove`, their 44 px buttons under every pointer and the header arrangement the behavior docs follow), `@aiquants/resize-panels` ^2.2.0 (the source of each layout change, by which the tree pane's width is saved), `@aiquants/spreadsheet` ^0.17.3 (the grid of those tables — one `role="grid"` with header rows, the content size a box is fitted to and a keyboard move the document follows,
|
|
57
59
|
read-only where it cannot write and named by its block — which markdown loads only for a document that holds one, and the grid of a table file's preview, whose TSV grammar (`@aiquants/spreadsheet/tsv`) reads a TSV file — `iterateTsvPrefixRows` the rows of a file read partway — and whose operation budget (`SPREADSHEET_MAX_OPERATION_CELLS` of `@aiquants/spreadsheet/view`) bounds its table) and `@aiquants/virtualscroll` ^3.22.1 (44 px scroll-to-edge pills and tap-scroll circles, the pills' text at the body step).
|
|
58
60
|
The client depends on these floors, while a package manager may only warn about an older peer.
|
|
59
61
|
- A Markdown parser of your choice on the server that produces HTML and its headings (the explorer sanitizes the HTML before it is sent).
|
|
@@ -103,7 +105,7 @@ The source ids are not part of it: they are the ids of the server's `sources` (a
|
|
|
103
105
|
| `embeds?` | `{ providers?, linkCards?, linkCardSize? }` | What `@aiquants/markdown` makes of a link alone in a paragraph. `providers` lists the ids (`EMBED_PROVIDER_IDS` of `@aiquants/markdown/embeds`: `youtube`, `x`, `instagram`, `threads`, `tiktok`, `bluesky`, `linkedin`, `reddit`, `note`, `niconico`) whose posts and videos documents embed as cross-origin frames, whatever the link's text. `linkCards: true` turns a link written as its own URL into a card, which the data route's own `link-card` operation serves (see [Link cards](#link-cards)): no route of yours is needed. `linkCardSize` picks the size of every card, `compact`, `banner` or `full` (`LINK_CARD_SIZES` of `@aiquants/markdown/embeds`; `@aiquants/markdown`'s `banner` when omitted), and needs `linkCards: true`. Each field defaults to none (`[]`, `false`, omitted), also when given as `undefined`, so without the option such a link stays its paragraph. Repeated ids are removed. An unknown id, a `linkCards` that is not a boolean, an unknown size, a size without `linkCards: true` or an unknown key (`linkCardEndpoint` included) throws a `RangeError` (`[markdown-explorer] embeds…`), and anything but a plain object a `TypeError`. The resolved `config.embeds` is the `MarkdownEmbeds` the viewer takes: `linkCardEndpoint` is `<dataPath>/link-card` when link cards are on and `null` otherwise, and `linkCardSize` is present only when given. See `@aiquants/markdown`'s README (Embeds) for the URLs each provider recognizes, the frames' sizes and the cards' sizes. |
|
|
104
106
|
| `defaultTreeSettings?` | `Partial<TreeSettings>` | The reader's tree settings before they change any, merged over the package's `DEFAULT_TREE_SETTINGS` (the source's own order, folders and READMEs mixed among the files, Single selection, a recursive double click, 8 px expand icons, nothing kept expanded, the open document not revealed, the root indent kept, lines, expand icons and folder and file icons on). Each value is one the settings menu offers: `sortMode` `"native"`, `"asc"`, `"desc"`, `"oldest"` or `"newest"` (by the entries' `modifiedAt`); `folderPlacement` `"mixed"`, `"first"` or `"last"`; `readmePlacement` `"mixed"`, `"first"` or `"last"`; `selectionMode` `"single"`, `"multiple"` or `"none"`; `doubleClickAction` `"recursive"` or `"toggle"`; `expandIconSize` `8`, `13` or `5`; the other settings (`alwaysExpanded`, `revealDocument`, `removeRootIndent`, `lines`, `expandIcons`, `directoryIcons`, `fileIcons`) `true` or `false`. An unknown key or any other value throws a `RangeError`, and anything but a plain object (a `Map`, a class instance, an object inheriting its settings) throws a `TypeError`; a setting given as `undefined` keeps the package default. The server render and the hydration draw these defaults (see [Tree settings](#tree-settings)). |
|
|
105
107
|
| `legacyTextEncoding?` | `string` | The legacy encoding of the files the explorer reads as text: a WHATWG label `TextDecoder` knows (for example `Shift_JIS`, `sjis` or `windows-1252`), resolved to the encoding's written name (`Shift_JIS`; `legacyTextEncodingOf`). UTF-8 and UTF-16 (read before it, and only by a byte order mark), ISO-2022-JP (seven-bit, so UTF-8 always reads it first) and x-user-defined (no text encoding) are refused with a `RangeError` naming why. The explorer reads a file's bytes in it when they carry no byte order mark and are not UTF-8 — a table file it shows as a table and a document it shows as written alike (see [Table files](#table-files)); give `createFileSystemSource` the same encoding for its text and Markdown files. None when omitted: a table file of such bytes is then not shown as a table, and a document shown as written shows them as UTF-8, with U+FFFD for each sequence UTF-8 cannot read. |
|
|
106
|
-
| `spreadsheets?` | `{ maxBytes? }` | A table file's preview
|
|
108
|
+
| `spreadsheets?` | `{ maxBytes?, maxWorkbookBytes? }` | A table file's preview (see [Table files](#table-files)). `maxBytes`: the most bytes the browser reads of a CSV or TSV file (a positive integer up to 256 MiB; default 2 MiB, the most a Source view reads by default; `SPREADSHEET_BYTE_LIMITS`), which stops sooner once the table holds as many cells as a preview shows; the browser parses what it reads on its main thread, at a cost that grows with the bytes rather than with the cells it shows, so a larger value costs a pathological file (one long row, one long cell) more time. `maxWorkbookBytes`: the most bytes the browser reads of a workbook, which it needs whole (a positive integer up to 256 MiB; default 8 MiB; `WORKBOOK_BYTE_LIMITS`); a larger workbook shows a note with the download, or its first sheet as text when the document names one. Each field defaults on its own, also when given as `undefined`. |
|
|
107
109
|
|
|
108
110
|
For example, `defaultTreeSettings: { sortMode: "desc" }` lists every folder's entries by name, Z to A, until the reader picks another order.
|
|
109
111
|
|
|
@@ -327,7 +329,7 @@ In the tree view a folder can be selected as GitHub's file tree does, and the vi
|
|
|
327
329
|
| `scopeSecret` | `string` | The deployment's secret for the readers' scopes: at least 32 characters (a shorter one throws a `RangeError`) and the same on every server instance. |
|
|
328
330
|
| `sources` | `ExplorerSource<P>[]` | The sources in switcher order (at least one; the first is the default): `id` (lowercase letters, digits and `-`, starting with a letter or digit, unique; the URL's `source` value), `label` (a string, or a function of the principal), `boundary` (where the source's documents may lie, see [Source boundaries](#source-boundaries)), `tree(context)` (lists the source's roots), `children?(context, path, readPath)` for lazy folders (asked only while the tree shows the folder open — the reader opened it, Expand all opened it (a press keeps opening folders as their listings land, within `expandAll`), or a remembered expansion opened it — and only for a path inside the source's boundary; a listing no tree wants any more is aborted through `context.signal`, which the source should honour), `ancestors?(context, path, readPath, options)` (the folders down to a document, for the reader's reveal; see [Revealing the open document](#revealing-the-open-document)), `cacheScope?` (`"principal"`, the default, or `"shared"`). The `context` is described under [Entries and notices](#entries-and-notices). |
|
|
329
331
|
| `document` | `(context, path, readPath) => Promise<ExplorerHostDocument>` | Resolves a document path. Called only for a path inside at least one source's boundary; `readPath` is what the admitting source's `confirm` answered (`path` when that source has no `confirm`), so read `readPath` and show the document as `path`. An image, media, text or file document reports its file's `version`; the explorer writes its URL (see [Documents](#documents)). |
|
|
330
|
-
| `asset` | `(context, path, readPath, options) => Promise<ExplorerAssetFile \| ExplorerAssetRedirect>` | Finds the file behind the data route's `asset` operation (and its `text` operation, which reads a Markdown document's source through it): any regular file the document admission admits, whatever its kind. Called only after the path passed the deny rules and the same union admission as a document, with the same `readPath`; see [Serving files](#serving-files).
|
|
332
|
+
| `asset` | `(context, path, readPath, options) => Promise<ExplorerAssetFile \| ExplorerAssetRedirect>` | Finds the file behind the data route's `asset` operation (and its `text` operation, which reads a Markdown document's source through it): any regular file the document admission admits, whatever its kind. Called only after the path passed the deny rules and the same union admission as a document, with the same `readPath`; see [Serving files](#serving-files). `options.delivery` says what the explorer delivers of the file (`"file"`, `"text"` or `"workbook"`): with `"file"` it may answer a short-lived URL instead, see [Redirecting to the storage](#redirecting-to-the-storage), and with `"workbook"` a storage that converts the file on read delivers a workbook, see [Serving files](#serving-files). |
|
|
331
333
|
| `signedOutPage` | `(request, headers) => Response` | The page response for a signed-out reader, usually a redirect to sign-in. Data requests answer 401 instead. |
|
|
332
334
|
| `forbiddenPage?` | `(request, headers) => Response` | The page response for a reader without access (default: a 403 for the route's error boundary). |
|
|
333
335
|
| `notices?` | `(context) => Promise<ExplorerNotice[]>` | Callouts above the tree (a missing permission with a link that grants it, for example). |
|
|
@@ -404,18 +406,19 @@ type ExplorerDocument =
|
|
|
404
406
|
| { kind: "text"; name: string; text: string; truncated: boolean; url: string }
|
|
405
407
|
| { kind: "image"; name: string; url: string; imageType: "raster" | "svg" }
|
|
406
408
|
| { kind: "media"; name: string; url: string; mediaType: "video" | "audio" | "pdf" }
|
|
407
|
-
| { kind: "spreadsheet"; name: string; url: string; format: "csv" | "tsv";
|
|
409
|
+
| { kind: "spreadsheet"; name: string; url: string; format: "csv" | "tsv" | "workbook"; firstSheetText: "csv" | "tsv" | null; edit: ExplorerExternalEdit | null }
|
|
408
410
|
| { kind: "file"; name: string; url: string }
|
|
409
411
|
| ExplorerFailureDocument // { kind: "failure"; failure: { reason: ExplorerFailureReason; code?: string } }
|
|
410
412
|
```
|
|
411
413
|
|
|
412
414
|
This is the document the browser receives. Your `document` port answers `ExplorerHostDocument` (exported from the server entry), which is the same except that an image, media, text, spreadsheet or file document carries its file's `version` instead of a `url`:
|
|
413
|
-
`{ kind: "image"; name; imageType; version }`, `{ kind: "media"; name; mediaType; version }`, `{ kind: "text"; name; text; truncated; version }`, `{ kind: "spreadsheet"; name; format;
|
|
415
|
+
`{ kind: "image"; name; imageType; version }`, `{ kind: "media"; name; mediaType; version }`, `{ kind: "text"; name; text; truncated; version }`, `{ kind: "spreadsheet"; name; format; firstSheetText; edit; version }` and `{ kind: "file"; name; version }`.
|
|
414
416
|
`version` is an opaque validator of 1 to 256 visible ASCII characters other than `"`, the same one your `asset` port reports for the file; the explorer writes the document's `url` as its own asset URL with that version (`<dataPath>/asset?path=…&v=<version>`, see [URL contract](docs/behavior/url-contract.md#asset-urls)).
|
|
415
417
|
An answer of those kinds that carries a `url` key, or lacks a valid `version`, breaks the contract: it is logged and the reader sees `failed`.
|
|
416
418
|
An image document names its type in `imageType` (`ExplorerImageType`): `"svg"` for an SVG file, whose SVG the Source toggle shows as written, and `"raster"` for every other image format. Answer it from what your storage knows of the file's type, the type your `asset` port serves it with; the explorer never guesses it from the name, and an image answer without one of the two breaks the contract the same way.
|
|
417
|
-
A spreadsheet document is a table file the explorer shows as a table (see [Table files](#table-files)); it names the format of the bytes your `asset` port delivers for it in `format` (`ExplorerSpreadsheetFormat`: `"csv"
|
|
418
|
-
|
|
419
|
+
A spreadsheet document is a table file the explorer shows as a table (see [Table files](#table-files)); it names the format of the bytes your `asset` port delivers for it in `format` (`ExplorerSpreadsheetFormat`: `"csv"`, `"tsv"` or `"workbook"`, an Office Open XML workbook or an OpenDocument spreadsheet, which the browser tells apart by its bytes),
|
|
420
|
+
for a workbook your storage converts on read the format of the first sheet's text it delivers when it cannot deliver the workbook (`firstSheetText`, `ExplorerSheetTextFormat`: `"csv"` or `"tsv"`; a Google Sheets spreadsheet is `"csv"`; `null` for a stored workbook and for every CSV or TSV file), and the file's own editor in `edit` (`ExplorerExternalEdit`:
|
|
421
|
+
`null`, or `{ kind: "external", href }` with an absolute `https:` URL the bar opens in a new tab, as for a markdown document; the explorer edits no table file itself). Answer them from what your storage knows of the file, as for an image; a spreadsheet answer without a known `format`, with a `firstSheetText` other than those (or one on a CSV or TSV file) or without such an `edit` breaks the contract the same way.
|
|
419
422
|
`failureDocument(reason, code?)` returns an `ExplorerFailureDocument`, which both unions accept.
|
|
420
423
|
A markdown document says how the reader may edit it in `edit` (`ExplorerDocumentEdit`), which every markdown answer must carry: `null` (no editing), `{ kind: "inline" }` (in the explorer, through the server's `edit` ports; without them the answer breaks the contract), `{ kind: "draft" }` (in the explorer without saving, to try changes in the preview: the ports' `source` and `preview` only, and the same contract) or `{ kind: "external", href }` (the document's own editor, an absolute `https:` URL the bar opens in a new tab).
|
|
421
424
|
Decide it per document and per reader (see [Editing](#editing)); `createFileSystemSource` answers `null`.
|
|
@@ -443,7 +446,7 @@ The deny rules are checked on the document's path only: a parser that expands in
|
|
|
443
446
|
|
|
444
447
|
### Table files
|
|
445
448
|
|
|
446
|
-
A spreadsheet document shows its file under the file header (its name; Open in a new tab, which shows the file as plain text; Download) as a read-only table: `@aiquants/markdown`'s table block — the grid of `@aiquants/spreadsheet`, with its zoom, copy, save as TSV and full screen —, named after the file, in the UI language and the explorer's colour scheme, filling a page pane (the block's `fill` layout, never fewer than three rows at the grid's zoom) and taking the height of its rows in a multi-view panel.
|
|
449
|
+
A spreadsheet document shows its file under the file header (its name; Open in a new tab, which shows the file as plain text — a workbook's opens the file itself unless the document names its first sheet's text; Download) as a read-only table: `@aiquants/markdown`'s table block — the grid of `@aiquants/spreadsheet`, with its zoom, copy, save as TSV and full screen —, named after the file, in the UI language and the explorer's colour scheme, filling a page pane (the block's `fill` layout, never fewer than three rows at the grid's zoom) and taking the height of its rows in a multi-view panel.
|
|
447
450
|
The file's notes and its table share one scroller under the file header, the document's scroller: in a page pane the table fills what the notes leave, and the body scrolls only when the pane is shorter than the file header, the notes, the stage's padding and the table block at its fewest — its toolbar and notice line and those three rows (at a 400 % zoom, for example).
|
|
448
451
|
|
|
449
452
|
- **Reading**: the browser reads the file itself, through the asset's plain-text delivery (`&as=text`: one request on the page's origin, never redirected to the storage), as a stream. At looks that each wait for twice the bytes the one before saw (the first after 64 KiB) it makes the table of what it has, so the looks together parse less than twice the bytes read, and it stops reading — cancelling the rest of the request — once the cell budget refuses a row (the 100,000 cells a grid operates on at once, `SPREADSHEET_MAX_OPERATION_CELLS`)
|
|
@@ -456,9 +459,14 @@ The file's notes and its table share one scroller under the file header, the doc
|
|
|
456
459
|
- **States**: the skeleton until the first reading, after which a page view announces the document; a failure before anything was read (the asset answering one, or the connection breaking) shows the failure view with its retry and is announced as a document's failure, alone (in a multi-view panel through the panel's announcer), and a retry that succeeds moves the focus into the table's body and, in a page view, announces the document, as the pane does for a document that replaces a failure;
|
|
457
460
|
every new answer for the document reads the file again with the previous table on screen and the region busy (its progress line and `aria-busy`). Refresh document waits for that reading and reports it once: as reloaded, or, when the reading fails, in the bar's notice (`documentRefreshFailed`) with the table kept; a background answer whose reading fails keeps the table without a word, as a background failure keeps a loaded document. Leaving the view aborts the reading. A document shown as written (its Source) behaves the same way.
|
|
458
461
|
- **As written**: the document bar's Source toggle shows the file's CSV or TSV as written (its tooltip names which), read through the `text` operation by the same rule.
|
|
459
|
-
- **Workbooks**: a `
|
|
462
|
+
- **Workbooks**: a `workbook` document is read through the asset's workbook delivery (`&as=workbook`: one request on the page's origin, for which a storage that converts the file on read is asked for a workbook), whole up to `spreadsheets.maxWorkbookBytes` (default 8 MiB), and opened in the browser by the explorer's own reader, with no dependency: an Office Open XML workbook (`.xlsx`, `.xlsm`, a Google Sheets spreadsheet exported as `.xlsx`) or an OpenDocument spreadsheet (`.ods`), told apart by its bytes.
|
|
463
|
+
Its shown sheets are tabs above the table — hidden sheets and sheets without a table (chart, dialog and macro sheets) are left out and counted in a note (`spreadsheetUnshownSheets`), and at most 256 are listed (`spreadsheetUnlistedSheets`) —, in the APG tabs pattern with manual activation: the arrow keys, Home and End move the focus, Enter, Space or a press selects, every tab a 44 px target in a row that wraps.
|
|
464
|
+
Each sheet is read when first shown, within the same cell budget as a text file's table, and kept, so going back to it shows it at once; a reading again (Refresh document, a retry) shows the sheet the reader chose, by its name. A sheet's table is named after the file and the sheet (`spreadsheetSheetName`), and a sheet without data shows `spreadsheetSheetEmpty`.
|
|
465
|
+
A cell shows its stored value: a string (rich text joined, phonetic readings left out), a formula's last result (formulas are never evaluated), `TRUE` or `FALSE`, an error as written, and a number through its cell's number format — dates and times in the 1900 and the 1904 date systems (Excel's 29 February 1900 included), elapsed times, percentages, fixed decimals with grouping and scaling, and otherwise up to 15 significant digits; an OpenDocument cell shows the text its writer shows.
|
|
466
|
+
A password-protected workbook (`spreadsheetWorkbookEncrypted`), bytes that are no workbook the reader reads, a legacy `.xls` included (`spreadsheetNotWorkbook`), and a workbook past `spreadsheets.maxWorkbookBytes` or with a part that inflates past 64 MiB (`spreadsheetWorkbookTooLarge`) show a note with the download.
|
|
467
|
+
A document that names its first sheet's text (`firstSheetText`) is a workbook your storage converts on read: when the delivery brings no workbook package within the budget (your storage's own text when it could not convert the workbook) or one the reader refuses, the view reads that text (`&as=text`) instead and shows it as a CSV or TSV file's table, below the note `spreadsheetWorkbookFirstSheet`. An `external` edit puts the link to the workbook's own editor in the bar. A workbook has no Source toggle (its bytes are no text).
|
|
460
468
|
|
|
461
|
-
`createFileSystemSource` answers `.csv` files as `csv` and `.tsv` and `.
|
|
469
|
+
`createFileSystemSource` answers `.csv` files as `csv`, `.tsv` and `.tab` files as `tsv`, and `.xlsx`, `.xlsm` and `.ods` files as `workbook`, always without a `firstSheetText` and without an editor. A legacy `.xls` stays a `file` document (a download).
|
|
462
470
|
|
|
463
471
|
### Editing
|
|
464
472
|
|
|
@@ -576,9 +584,9 @@ export const explorer = createMarkdownExplorer({
|
|
|
576
584
|
|
|
577
585
|
### Serving files
|
|
578
586
|
|
|
579
|
-
The explorer serves every file it shows or offers for download itself, through the `asset` operation of its data route: `<dataPath>/asset?path=<document path>[&v=<version>][&as=text]` (GET and HEAD; see [URL contract](docs/behavior/url-contract.md#asset-urls)).
|
|
580
|
-
Images, audio, video and PDF are shown in place; every other file (Markdown, text, table files, workbooks, anything else) is delivered as a download, except that `&as=text` asks for any file as plain text shown in place (`text/plain; charset=<encoding>`, the encoding the explorer's one text rule reads the file's first 64 KiB in, under the same `nosniff` and sandboxing policy).
|
|
581
|
-
That is where a text viewer's Open in a new tab goes, since a browser downloads Markdown or cannot show it, and what a table file's preview reads (one request on the page's origin, since the operation reads the bytes itself and never redirects).
|
|
587
|
+
The explorer serves every file it shows or offers for download itself, through the `asset` operation of its data route: `<dataPath>/asset?path=<document path>[&v=<version>][&as=text|&as=workbook]` (GET and HEAD; see [URL contract](docs/behavior/url-contract.md#asset-urls)).
|
|
588
|
+
Images, audio, video and PDF are shown in place; every other file (Markdown, text, table files, workbooks, anything else) is delivered as a download, except that `&as=text` asks for any file as plain text shown in place (`text/plain; charset=<encoding>`, the encoding the explorer's one text rule reads the file's first 64 KiB in, under the same `nosniff` and sandboxing policy), and `&as=workbook` for a workbook's preview (always a download).
|
|
589
|
+
That is where a text viewer's Open in a new tab goes, since a browser downloads Markdown or cannot show it, and what a table file's preview reads (`&as=text` for a CSV or TSV file and `&as=workbook` for a workbook: one request on the page's origin, since the operation reads the bytes itself and never redirects).
|
|
582
590
|
The host supplies only the bytes, through the `asset` port:
|
|
583
591
|
|
|
584
592
|
| `ExplorerAssetFile` field | Type | Meaning |
|
|
@@ -621,6 +629,13 @@ The body of a 200 or 206 with a `Content-Length` carries exactly that many bytes
|
|
|
621
629
|
- A GET of the whole file opens it once and sends the bytes read to name the encoding first; a HEAD and a range read the first 64 KiB on their own (a range then opens its own bytes), so a ranged part carries the `charset` of the file's beginning.
|
|
622
630
|
The server holds the host's chunks that carry those 64 KiB until they are sent, and a beginning that ends before `size` is answered `failed` (logged) before any header, rather than with a body that breaks.
|
|
623
631
|
|
|
632
|
+
`&as=workbook` answers by the same table too, with these differences:
|
|
633
|
+
|
|
634
|
+
- The port is asked with `delivery: "workbook"`, so a storage that converts the file on read delivers a workbook (a Google Sheets spreadsheet as `.xlsx`, with every sheet); a stored file is delivered as stored.
|
|
635
|
+
- Every 200 and 304 carries `Content-Type: application/octet-stream` and `Content-Disposition: attachment; filename*=UTF-8''<name>`, whatever the declared type, with the same security and cache headers.
|
|
636
|
+
- The answer is always the whole file: a `Range` is ignored (the reader needs the whole package), so it is 200 or 304, never 206 or 416.
|
|
637
|
+
- The ETag is `"workbook;<version>"`, so a cached copy of the stored file never answers it, nor the other way round.
|
|
638
|
+
|
|
624
639
|
The URL carries the path in its query, so no name needs an extra escape and the request's own path never ends in `.data`; a document's URL carries `v=<version>` as a cache-buster, which the server never reads (the ETag always names the current version).
|
|
625
640
|
|
|
626
641
|
The data route's `text` operation reads a file through the same port for the Source toggles (the document bar's — a Markdown document, an SVG image, a table file — and that of an SVG image inside a rendered document) and that image's Copy:
|
|
@@ -632,18 +647,18 @@ It sends no refresh mark: the port receives `refresh: false`.
|
|
|
632
647
|
### Redirecting to the storage
|
|
633
648
|
|
|
634
649
|
A host whose storage issues short-lived URLs (a storage-api `gcs://` signed URL, for example) can let the browser read a file's bytes from the storage instead of through the explorer.
|
|
635
|
-
The `asset` port receives a fourth argument, `{
|
|
636
|
-
When it is `
|
|
650
|
+
The `asset` port receives a fourth argument, `{ delivery }`: it is `"file"` only when the `asset` operation delivers the stored file, `"text"` for `&as=text` and the `text` operation, and `"workbook"` for `&as=workbook`, which read the bytes themselves.
|
|
651
|
+
When it is `"file"` the port may answer an `ExplorerAssetRedirect`, `{ kind: "redirect", url }`, instead of an `ExplorerAssetFile`:
|
|
637
652
|
|
|
638
653
|
```ts
|
|
639
|
-
asset: async (context, path, readPath, {
|
|
640
|
-
|
|
654
|
+
asset: async (context, path, readPath, { delivery }) =>
|
|
655
|
+
delivery === "file" ? { kind: "redirect", url: await signedUrlOf(readPath, context.signal) } : fileOf(readPath, delivery, context.signal),
|
|
641
656
|
```
|
|
642
657
|
|
|
643
658
|
The explorer then answers `302` with `Location: <url>`, `Cache-Control: private, no-store` and `Referrer-Policy: no-referrer` (plus the headers authentication returned), for GET and HEAD alike and with or without `Range`: the storage answers ranges itself.
|
|
644
659
|
The deny rules and the source admission run before the port exactly as for a file, so a denied or unadmitted path never reaches the port and is never redirected; `If-None-Match` is not read for a redirect.
|
|
645
660
|
The page's HTML keeps pointing at the explorer's own `asset` operation.
|
|
646
|
-
The URL must be absolute `https:` without credentials (it is written as the URL parser serializes it); any other URL, a redirect
|
|
661
|
+
The URL must be absolute `https:` without credentials (it is written as the URL parser serializes it); any other URL, a redirect for any other `delivery`, or an answer whose `kind` is not `"redirect"` is a contract violation, logged and answered `failed` (500).
|
|
647
662
|
A host that never answers a redirect keeps streaming through `open`, unchanged.
|
|
648
663
|
|
|
649
664
|
What a host that redirects must allow and decide:
|
|
@@ -895,8 +910,11 @@ Every scroller of the explorer that the reader browses gets one pointer scroll b
|
|
|
895
910
|
| Multi view | The stage (bar without a circle) | drag-drop-panels' `renderStageScrollBar`, over the stage's inline-end edge, in 8 px the stage adds to its inline-end padding |
|
|
896
911
|
|
|
897
912
|
- Press the circle and pull it up or down: the scroller scrolls while the pointer is held, faster the farther it is pulled, and stops on release and at either end. A plain tap scrolls nothing.
|
|
898
|
-
- A circle sits
|
|
899
|
-
-
|
|
913
|
+
- A circle is one control wide (44 px) and sits 49 px before its bar, at the middle of the scroller's height. It scrolls the same with a Mermaid diagram or an embedded frame at its height, and a drag that starts on it selects no text.
|
|
914
|
+
- Every document scroller with a circle (the viewer's scroller, the image, medium, file and failure views, and each multi-view panel's scroll area) keeps a 54 px gutter at its inline end, outside its own padding: the circle with 5 px on each side.
|
|
915
|
+
So no content (a diagram's or a table's toolbar, a code block's copy button, a focused link) lies under the circle at any scroll position; only an image zoomed wider than its canvas passes beneath it while it pans sideways. The wheel and touch scroll over the gutter as over the rest of the document.
|
|
916
|
+
The gutter is kept while the content fits as well, so the text never re-wraps when the bar appears. For the viewer the explorer passes it as `@aiquants/markdown`'s `scrollBarGutter`. The tree's rows reach under the tree's circle, which has no gutter.
|
|
917
|
+
- The stage's bar has no circle: 49 px before the stage's bar a circle would cover the right-most panel's own bar and circle, and a gutter that holds it (54 px more of the stage's inline-end padding) would cost the stage a column (4 to 3 at a 1920 px window, 3 to 2 at 1440 px). The stage keeps its thumb, track and arrows, the plain wheel (which the panels hand to the stage), touch and the keyboard.
|
|
900
918
|
- Each bar drives its scroller's native scrolling, of which only the vertical scrollbar is hidden: a zoomed image keeps its native horizontal scrollbar, and the wheel, the keyboard, touch, find in page, fragments and the table of contents, the reading position a panel keeps, Ctrl/⌘ + wheel over a panel, and the browser's scroll anchoring work as without it, with the bar following each of them. The viewer's toolbar keeps clear of the document's bar.
|
|
901
919
|
- In a multi-view panel the document follows its content's height and the panel's scroll area scrolls, so the panel's viewer, image, medium, file and failure views have no bar of their own; the panel's bar is exempt from panel drags (`data-aqdd-no-panel-drag`). The stage's bar is not shown while a panel is maximized.
|
|
902
920
|
- Menus and popovers (the tree settings, the table of contents, the toolbars), the scrollers nested in a document (code blocks, tables, inline math) and embedded frames, a PDF's included, keep their native scrollbars and get no circle.
|
|
@@ -934,7 +952,8 @@ Tests and host styling may rely on the `data-testid` and `data-aqmx-*` attribute
|
|
|
934
952
|
The repeated keydowns end at the explorer's root, so a keydown listener the host attaches outside the explorer for the bubbling phase does not receive them either.
|
|
935
953
|
- A loop row (a folder met again among its own ancestors) shows an expand glyph and `aria-expanded="false"` like any closed folder, because `@aiquants/directory-tree` has no row that cannot expand; it never opens. The 4 listings in flight are counted per explorer, not across browser tabs.
|
|
936
954
|
- A ```spreadsheets table stays read-only in the preview, and says so, when its block holds a line the converter reads with a tab split at a container's edge or a tab right after `>`, or an info string whose first word holds a backslash or an ampersand: readings the editor does not reproduce, so it never writes such a block in a way the converter would read differently. Inside a list item, a line of spaces and tabs only reads as an empty line (CommonMark), so a row whose cells are all white space is written as an empty line and keeps no cells; the table then shows the row as the editor reads it.
|
|
937
|
-
- Document kinds are the six above; `createFileSystemSource` previews only files with a known text extension or name as text, shows `.csv`, `.tsv` and `.tab` files as tables, and offers any other file as a `file` document (a download).
|
|
955
|
+
- Document kinds are the six above; `createFileSystemSource` previews only files with a known text extension or name as text, shows `.csv`, `.tsv` and `.tab` files and `.xlsx`, `.xlsm` and `.ods` workbooks as tables, and offers any other file as a `file` document (a download).
|
|
956
|
+
- A workbook's preview shows stored values only: formulas are not evaluated, so a cell whose writer saved no result (some generators write formulas alone) shows empty, and the reader shows no cell styles, conditional formats, merged spans, comments, pictures or charts. It reads no legacy `.xls` (Excel 97–2003), no password-protected workbook, no `.xlsb` and no ZIP64 package, and it reads the whole workbook (at most `spreadsheets.maxWorkbookBytes`) before it shows a sheet.
|
|
938
957
|
- A table file's preview shows at most the 100,000 cells a grid operates on at once, 1,000 columns and 32,767 characters of a cell, and reads at most `spreadsheets.maxBytes` of the file, which it parses on the browser's main thread (a row of more cells than a preview shows is still read whole: a single 2 MiB row of commas or tabs takes a few tenths of a second, where 2 MiB of ordinary rows stops at the cell budget in about a hundredth). It reads no encoding the file does not mark or the configuration does not name:
|
|
939
958
|
a UTF-8 file with a few stray bytes shows the encoding note instead of a table (or, with a legacy encoding configured, is read in that encoding). The encoding is decided on the bytes each view reads, so the table and the Source view of a file whose encoding changes past where one of them stopped reading may read it differently.
|
|
940
959
|
- A TSV file read partway shows only the rows before the first cell that opens a quote the bytes read do not close (a lone `"` used as a ditto mark, for example), since the rest of the file could still close it: a TSV larger than `spreadsheets.maxBytes` with such a cell near its start shows only the rows above it — or, with no row above it, the note that no row ends within the part read (`spreadsheetLongRow`) —, where read whole it shows every row (an unclosed quote is literal in a whole TSV). A CSV is not affected (an unclosed quote holds the rest of a whole CSV too).
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { jsx as R, jsxs as le } from "react/jsx-runtime";
|
|
2
2
|
import { useState as te, useRef as D, useLayoutEffect as B, useEffectEvent as ve, useEffect as Pe, useImperativeHandle as je, useMemo as J, startTransition as Ye, useCallback as X, useId as Je } from "react";
|
|
3
|
-
import { v as ne,
|
|
3
|
+
import { v as ne, i as me, j as Qe, u as se, k as Ze, l as et, m as tt, n as De, o as nt, p as rt, q as ot, s as it, E as lt, t as st, w as ct, x as at, y as we, z as be, A as ut, B as Ee, G as dt, H as ft, I as mt, J as pt } from "./index-CdYr9OQ-.js";
|
|
4
4
|
import { fencedBodyAsRead as ht, planFencedBodyEdit as gt, fencedCodeLanguageOf as vt, SPREADSHEETS_LANGUAGE as wt, readFencedLine as bt, listItemWidthOn as Et, openingFenceOn as xt } from "@aiquants/markdown/code-blocks";
|
|
5
5
|
import { history as St, historyKeymap as yt, defaultKeymap as kt, historyField as Tt, redo as At, undo as It, isolateHistory as Lt } from "@codemirror/commands";
|
|
6
6
|
import { markdown as Ct, markdownLanguage as Ot } from "@codemirror/lang-markdown";
|
|
7
7
|
import { syntaxHighlighting as Mt, syntaxTreeAvailable as qt, HighlightStyle as Rt, ensureSyntaxTree as Be } from "@codemirror/language";
|
|
8
8
|
import { highlightSelectionMatches as _t, searchKeymap as Nt } from "@codemirror/search";
|
|
9
9
|
import { EditorState as Ve, EditorSelection as fe, StateField as Pt, RangeSetBuilder as Dt, MapMode as Bt } from "@codemirror/state";
|
|
10
|
-
import { EditorView as $, lineNumbers as Vt, highlightActiveLineGutter as Ht, drawSelection as zt, highlightActiveLine as Ft, keymap as
|
|
10
|
+
import { EditorView as $, lineNumbers as Vt, highlightActiveLineGutter as Ht, drawSelection as zt, highlightActiveLine as Ft, keymap as Gt, ViewPlugin as Ut, Decoration as ce, WidgetType as Wt } from "@codemirror/view";
|
|
11
11
|
import { tags as N } from "@lezer/highlight";
|
|
12
12
|
import { MarkdownViewer as $t } from "@aiquants/markdown";
|
|
13
13
|
import { SOURCE_LINES_ATTRIBUTE as He, parseSourceLines as Kt } from "@aiquants/markdown/source-lines";
|
|
14
|
-
import { d as Xt, f as re, E as jt } from "./dataRoute-
|
|
15
|
-
import { H as Yt, c as Jt, M as Qt } from "./sanitizePolicy-
|
|
14
|
+
import { d as Xt, f as re, E as jt } from "./dataRoute-DLhQfdoW.js";
|
|
15
|
+
import { H as Yt, c as Jt, M as Qt } from "./sanitizePolicy-By0tKOpZ.js";
|
|
16
16
|
import Zt from "isomorphic-dompurify";
|
|
17
17
|
import { PanelGroup as en, Panel as xe, PanelResizeHandle as tn } from "@aiquants/resize-panels";
|
|
18
|
-
import { C as nn, F as rn, E as on, a as ln, b as oe, d as sn } from "./location-
|
|
19
|
-
import { u as cn, a as an } from "./useSplitPersistence-
|
|
18
|
+
import { C as nn, F as rn, E as on, a as ln, b as oe, d as sn } from "./location-CKuabtKl.js";
|
|
19
|
+
import { u as cn, a as an } from "./useSplitPersistence-Bf4M35Il.js";
|
|
20
20
|
const ze = { history: Tt }, un = Rt.define([
|
|
21
21
|
{ tag: [N.heading1, N.heading2, N.heading3, N.heading4, N.heading5, N.heading6, N.heading], color: "var(--aqmx-syntax-heading)", fontWeight: "700" },
|
|
22
22
|
{ tag: N.strong, fontWeight: "700" },
|
|
@@ -61,7 +61,7 @@ class hn extends Wt {
|
|
|
61
61
|
const o = document.createElement("button");
|
|
62
62
|
o.type = "button", o.textContent = l, o.setAttribute("data-aqmx-conflict-choice", r), o.addEventListener("mousedown", (s) => s.preventDefault()), o.addEventListener("click", () => {
|
|
63
63
|
const s = ee(t.state.doc)[this.index];
|
|
64
|
-
s !== void 0 && (
|
|
64
|
+
s !== void 0 && (Ge(t, s, r), t.focus());
|
|
65
65
|
}), n.append(o);
|
|
66
66
|
}
|
|
67
67
|
return n;
|
|
@@ -84,7 +84,7 @@ const ee = (e) => Qe(e.iterLines()), Se = (e, t) => {
|
|
|
84
84
|
create: (t) => Se(t.doc, e),
|
|
85
85
|
update: (t, n) => n.docChanged ? Se(n.state.doc, e) : t,
|
|
86
86
|
provide: (t) => $.decorations.from(t)
|
|
87
|
-
}),
|
|
87
|
+
}), Ge = (e, t, n) => {
|
|
88
88
|
const { doc: r } = e.state, l = (y, c) => {
|
|
89
89
|
const w = [];
|
|
90
90
|
for (let u = y; u <= c; u += 1) w.push(r.line(u).text);
|
|
@@ -95,7 +95,7 @@ const ee = (e) => Qe(e.iterLines()), Se = (e, t) => {
|
|
|
95
95
|
const p = i.join(`
|
|
96
96
|
`);
|
|
97
97
|
e.dispatch({ changes: { from: d, to: f, insert: p }, selection: fe.cursor(d), scrollIntoView: !0, userEvent: "input.resolve" });
|
|
98
|
-
}, ye = "input.preview", vn = 20, wn =
|
|
98
|
+
}, ye = "input.preview", vn = 20, wn = Ut.fromClass(
|
|
99
99
|
class {
|
|
100
100
|
constructor(e) {
|
|
101
101
|
this.view = e, this.schedule();
|
|
@@ -193,7 +193,7 @@ const ee = (e) => Qe(e.iterLines()), Se = (e, t) => {
|
|
|
193
193
|
wn,
|
|
194
194
|
Mt(un),
|
|
195
195
|
gn(l),
|
|
196
|
-
|
|
196
|
+
Gt.of([
|
|
197
197
|
{
|
|
198
198
|
key: "Mod-s",
|
|
199
199
|
preventDefault: !0,
|
|
@@ -286,7 +286,7 @@ const ee = (e) => Qe(e.iterLines()), Se = (e, t) => {
|
|
|
286
286
|
conflicts: () => ee(c.state.doc),
|
|
287
287
|
resolveAtCursor: (u) => {
|
|
288
288
|
const m = ee(c.state.doc), g = c.state.doc.lineAt(c.state.selection.main.head).number, x = m.find((h) => h.end >= g);
|
|
289
|
-
return x === void 0 ? !1 : (
|
|
289
|
+
return x === void 0 ? !1 : (Ge(c, x, u), !0);
|
|
290
290
|
},
|
|
291
291
|
nextConflict: () => {
|
|
292
292
|
const u = ee(c.state.doc);
|
|
@@ -373,9 +373,9 @@ const ee = (e) => Qe(e.iterLines()), Se = (e, t) => {
|
|
|
373
373
|
}, P = () => {
|
|
374
374
|
if (t === null || c === null) return;
|
|
375
375
|
const v = c, S = [], C = { asset: /* @__PURE__ */ new Set(), doc: /* @__PURE__ */ new Set() };
|
|
376
|
-
let
|
|
376
|
+
let U;
|
|
377
377
|
try {
|
|
378
|
-
|
|
378
|
+
U = t.sanitize(v.html, (E) => {
|
|
379
379
|
const M = s[E.kind].get(E.path);
|
|
380
380
|
return M === void 0 && !C[E.kind].has(E.path) && (C[E.kind].add(E.path), S.push(E)), M ?? void 0;
|
|
381
381
|
});
|
|
@@ -384,7 +384,7 @@ const ee = (e) => Qe(e.iterLines()), Se = (e, t) => {
|
|
|
384
384
|
return;
|
|
385
385
|
}
|
|
386
386
|
w = S;
|
|
387
|
-
const b = i.parsed !== null && i.parsed.htmlContent ===
|
|
387
|
+
const b = i.parsed !== null && i.parsed.htmlContent === U && i.parsed.headings === v.headings ? i.parsed : { htmlContent: U, headings: v.headings };
|
|
388
388
|
h({ parsed: b, source: v.draft, failure: null, busy: !1, tier: "instant" }), F();
|
|
389
389
|
}, H = () => {
|
|
390
390
|
if (u = void 0, m || c === null || w.length === 0) return;
|
|
@@ -418,8 +418,8 @@ const ee = (e) => Qe(e.iterLines()), Se = (e, t) => {
|
|
|
418
418
|
} catch (b) {
|
|
419
419
|
return o.signal.aborted || k("the draft converter rejected a conversion, which its contract allows only once the signal aborted", b), Ae;
|
|
420
420
|
}
|
|
421
|
-
const
|
|
422
|
-
return
|
|
421
|
+
const U = Xt(C);
|
|
422
|
+
return U === null ? C : (k(`the draft converter answered outside its contract: ${U}`), Ae);
|
|
423
423
|
}, T = (v, S) => {
|
|
424
424
|
switch (S.kind) {
|
|
425
425
|
case "preview":
|
|
@@ -427,7 +427,7 @@ const ee = (e) => Qe(e.iterLines()), Se = (e, t) => {
|
|
|
427
427
|
_(), O(re("too-large"), "instant");
|
|
428
428
|
return;
|
|
429
429
|
}
|
|
430
|
-
c = { draft: v, html: S.htmlContent, headings: S.headings.map(({ text: C, depth:
|
|
430
|
+
c = { draft: v, html: S.htmlContent, headings: S.headings.map(({ text: C, depth: U, id: b }) => ({ text: C, depth: U, id: b })) }, P();
|
|
431
431
|
return;
|
|
432
432
|
case "failure":
|
|
433
433
|
A(), _(), O(re(S.failure.reason, S.failure.code), "instant");
|
|
@@ -556,7 +556,7 @@ const ee = (e) => Qe(e.iterLines()), Se = (e, t) => {
|
|
|
556
556
|
y = !0, p !== null && o(p), p = null, A(), _(), x();
|
|
557
557
|
}
|
|
558
558
|
};
|
|
559
|
-
}, Oe = Object.freeze(["wheel", "pointerdown", "keydown", "focusin"]),
|
|
559
|
+
}, Oe = Object.freeze(["wheel", "pointerdown", "keydown", "focusin"]), Ue = (e) => ({
|
|
560
560
|
position: () => e.scrollTop,
|
|
561
561
|
max: () => Math.max(e.scrollHeight - e.clientHeight, 0),
|
|
562
562
|
viewport: () => e.clientHeight,
|
|
@@ -571,7 +571,7 @@ const ee = (e) => Qe(e.iterLines()), Se = (e, t) => {
|
|
|
571
571
|
}), Z = "[data-aqmd-scroll-container]", Hn = "[data-aqmd-content]", zn = `[${He}]`, Fn = Object.freeze(["p1", "p2", "p3", "p4", "p5", "p6", "p7", "p8"]), We = (e, t) => {
|
|
572
572
|
const n = nt(e.peek(t));
|
|
573
573
|
return n !== null && n.document.kind === "markdown" ? { htmlContent: n.document.htmlContent, headings: n.document.headings } : null;
|
|
574
|
-
},
|
|
574
|
+
}, Gn = (e, t, n, r, l) => {
|
|
575
575
|
if (n === void 0) return null;
|
|
576
576
|
let o;
|
|
577
577
|
try {
|
|
@@ -580,7 +580,7 @@ const ee = (e) => Qe(e.iterLines()), Se = (e, t) => {
|
|
|
580
580
|
return console.error("[markdown-explorer] the draft sanitizer cannot run in this browser, so the server renders the preview", s), null;
|
|
581
581
|
}
|
|
582
582
|
return { converter: n, sanitize: o, marksOf: qn, seed: We(r, l)?.htmlContent ?? null };
|
|
583
|
-
},
|
|
583
|
+
}, Un = (e) => {
|
|
584
584
|
const t = [];
|
|
585
585
|
let n = null;
|
|
586
586
|
for (const r of e.querySelectorAll(zn)) {
|
|
@@ -598,7 +598,7 @@ const ee = (e) => Qe(e.iterLines()), Se = (e, t) => {
|
|
|
598
598
|
});
|
|
599
599
|
const h = ve(() => t());
|
|
600
600
|
Pe(() => {
|
|
601
|
-
const a =
|
|
601
|
+
const a = Gn(d.iframeHosts, d.dataPath, y, p, e), T = h(), L = Rn({ path: e, instant: a, preview: f.preview, initial: x.current, onView: (v) => Ye(() => u(v)) });
|
|
602
602
|
return g.current = L, L.update(T), () => {
|
|
603
603
|
L.dispose(), g.current = null;
|
|
604
604
|
};
|
|
@@ -626,11 +626,11 @@ const ee = (e) => Qe(e.iterLines()), Se = (e, t) => {
|
|
|
626
626
|
},
|
|
627
627
|
scrollPort: () => {
|
|
628
628
|
const a = m.current?.querySelector(Z);
|
|
629
|
-
return a instanceof HTMLElement ? (A.current?.scroller !== a && (A.current = { scroller: a, port:
|
|
629
|
+
return a instanceof HTMLElement ? (A.current?.scroller !== a && (A.current = { scroller: a, port: Ue(a) }), A.current.port) : null;
|
|
630
630
|
},
|
|
631
631
|
blocks: () => {
|
|
632
632
|
const a = m.current?.querySelector(Z);
|
|
633
|
-
return a instanceof HTMLElement ?
|
|
633
|
+
return a instanceof HTMLElement ? Un(a) : [];
|
|
634
634
|
},
|
|
635
635
|
focus: () => {
|
|
636
636
|
const a = m.current?.querySelector(Z);
|
|
@@ -662,7 +662,7 @@ const ee = (e) => Qe(e.iterLines()), Se = (e, t) => {
|
|
|
662
662
|
},
|
|
663
663
|
[r, O]
|
|
664
664
|
), P = J(() => ({ ...n.labels, spreadsheetReadOnly: c.previewTablePending }), [n.labels, c.previewTablePending]), H = J(
|
|
665
|
-
() => ({ ...n, labels: F === void 0 ? P : n.labels, showToc: !1, showStyle: !1, showAlign: !1, renderScrollBar: void 0, spreadsheetEditor: F }),
|
|
665
|
+
() => ({ ...n, labels: F === void 0 ? P : n.labels, showToc: !1, showStyle: !1, showAlign: !1, renderScrollBar: void 0, scrollBarGutter: void 0, spreadsheetEditor: F }),
|
|
666
666
|
[n, P, F]
|
|
667
667
|
), V = J(
|
|
668
668
|
() => w.parsed === null ? null : /* @__PURE__ */ R("div", { className: "aqmx-document-viewer", children: /* @__PURE__ */ R($t, { ...H, parseResult: w.parsed, content: null }) }),
|
|
@@ -843,7 +843,7 @@ const ee = (e) => Qe(e.iterLines()), Se = (e, t) => {
|
|
|
843
843
|
let W = null, j = null;
|
|
844
844
|
const ae = () => {
|
|
845
845
|
W !== null && clearTimeout(W), W = null, j !== null && i.setDraft(e, j.text());
|
|
846
|
-
},
|
|
846
|
+
}, G = Sn({
|
|
847
847
|
parent: b,
|
|
848
848
|
scroll: {
|
|
849
849
|
scrollerOf: (q) => {
|
|
@@ -866,18 +866,18 @@ const ee = (e) => Qe(e.iterLines()), Se = (e, t) => {
|
|
|
866
866
|
i.save(e);
|
|
867
867
|
}
|
|
868
868
|
});
|
|
869
|
-
j =
|
|
869
|
+
j = G, y.current = G;
|
|
870
870
|
const pe = () => {
|
|
871
|
-
const q =
|
|
871
|
+
const q = G.topLine();
|
|
872
872
|
return { line: q.line, clientTop: q.clientTop };
|
|
873
873
|
}, he = () => u.current?.anchor(a) ?? null, $e = i.bindEditor(e, {
|
|
874
874
|
flush: ae,
|
|
875
|
-
adopt: (q) =>
|
|
875
|
+
adopt: (q) => G.replaceText(q),
|
|
876
876
|
returnPoint: () => {
|
|
877
877
|
const q = O.current.view === "preview" && A.current.layout === "content" ? he() : null;
|
|
878
878
|
return q === null ? pe() : { line: q.lines.first, clientTop: q.clientTop };
|
|
879
879
|
},
|
|
880
|
-
nextConflict: () => O.current.view !== "preview" ?
|
|
880
|
+
nextConflict: () => O.current.view !== "preview" ? G.nextConflict() : G.conflicts().length === 0 ? !1 : (H.current = !0, i.setView(e, "editor"), !0),
|
|
881
881
|
beforeView: (q) => {
|
|
882
882
|
if (A.current.layout === "fill") return;
|
|
883
883
|
if (q === "preview") {
|
|
@@ -888,8 +888,8 @@ const ee = (e) => Qe(e.iterLines()), Se = (e, t) => {
|
|
|
888
888
|
F.current = Y === null ? null : { to: "editor", anchor: Y };
|
|
889
889
|
}
|
|
890
890
|
});
|
|
891
|
-
return z !== null &&
|
|
892
|
-
ae(), i.editorState.set(e, { state:
|
|
891
|
+
return z !== null && G.showLine(z.topLine), () => {
|
|
892
|
+
ae(), i.editorState.set(e, { state: G.save(), generation: _.current, topLine: G.topLine().line }), $e(), G.destroy(), j = null, y.current = null;
|
|
893
893
|
};
|
|
894
894
|
}, [i, e, V, a, c, w]);
|
|
895
895
|
const { request: T } = n;
|
|
@@ -933,7 +933,7 @@ const ee = (e) => Qe(e.iterLines()), Se = (e, t) => {
|
|
|
933
933
|
const b = y.current;
|
|
934
934
|
if (!I || b === null) return;
|
|
935
935
|
const E = Vn({
|
|
936
|
-
editor:
|
|
936
|
+
editor: Ue(b.scrollElement),
|
|
937
937
|
preview: () => u.current?.scrollPort() ?? null,
|
|
938
938
|
previewBlocks: () => u.current?.blocks() ?? [],
|
|
939
939
|
editorSpans: (M) => b.lineSpans(M),
|