docblocks-react-ui 0.17.0 → 0.18.1
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 +99 -0
- package/README.md +187 -38
- package/dist/{Editor-CbHCJZ6R.mjs → Editor-DCzrR1FJ.mjs} +13395 -12345
- package/dist/{constants-D8PSgkwi.mjs → constants-D_3p65rk.mjs} +90 -11
- package/dist/index-G44JW36p.d.mts +236 -0
- package/dist/{index-C3vzW1Mv.d.mts → index-sNhMaFHp.d.mts} +26 -209
- package/dist/index.d.mts +119 -49
- package/dist/index.mjs +4 -4
- package/dist/mermaid/index.d.mts +1 -1
- package/dist/mermaid/index.mjs +210 -147
- package/dist/pdf/index.d.mts +1 -1
- package/dist/pdf/index.mjs +421 -362
- package/package.json +4 -2
- package/dist/index-YJcgf8Hh.d.mts +0 -39
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,104 @@
|
|
|
1
1
|
# docblocks-react-ui
|
|
2
2
|
|
|
3
|
+
## 0.18.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2d9c34a: The database grid's data-keyed cell writes now build their cell maps over
|
|
8
|
+
the null-prototype's map everywhere the keys stand the bridge's column ids
|
|
9
|
+
(the enum column form's option cells, the multi-cell paste, the keyboard's
|
|
10
|
+
clear, the write's inverse / clean / batch restore): a hostile column id
|
|
11
|
+
(`__proto__`) stands the inert own entry, not the prototype's write —
|
|
12
|
+
the cell keeps its value over the write instead of standing silently
|
|
13
|
+
dropped.
|
|
14
|
+
- c71c306: The download-href gate stands the core's shared `normalizeHrefInput`
|
|
15
|
+
(the duplicated WHATWG normalization regexes stand removed — the link
|
|
16
|
+
href's parity). The data-keyed writes (the enum option's cell maps over
|
|
17
|
+
the bridge column ids, the persisted viewport's map over the doc id)
|
|
18
|
+
stand the null-prototype's maps (a hostile id stands the inert own entry,
|
|
19
|
+
not the prototype's write). The table stream's at-least-once dedup set
|
|
20
|
+
stands bounded (the stale check — the seq at or below the head's drop —
|
|
21
|
+
protects the pruned seqs; the long session's growth is bounded).
|
|
22
|
+
- 28b8f34: The download-href gate over the consumer's `BlobStore` url now normalizes the
|
|
23
|
+
browser's WHATWG control handling (the mid-string U+0009/U+000A/U+000D strip +
|
|
24
|
+
the leading / trailing C0 / space trim) before the scheme check, in parity with
|
|
25
|
+
the link-href's classifier — a `downloadUrl` carrying a control-split
|
|
26
|
+
`javascript:` scheme no longer stands an anchor.
|
|
27
|
+
- d32aeee: The slash Frame picker's ref-cached list now tracks the root's child blocks' refs alongside the frame blocks' refs: a frame added (or reordered) into an existing surface invalidates the cache — the list re-renders over the live change while the picker stands open.
|
|
28
|
+
- 461e4fc: The provider hooks' misuse now throws the typed `HookMisuseError` (the
|
|
29
|
+
`DocBlocksUiError` family, exported over the entry point) instead of a
|
|
30
|
+
raw `Error`: an editor hook rendered outside the `EditorProvider`, or a
|
|
31
|
+
block hook outside its block context, is catchable by class. The
|
|
32
|
+
`./motion` subpath's references in the shipped comments stand replaced
|
|
33
|
+
over the current stand (the base entry's row layer — framer-motion the
|
|
34
|
+
required peer).
|
|
35
|
+
- 46e525a: The imperative mention chip's renderer now falls back to the `doc`'s icon
|
|
36
|
+
geometry over an out-of-enum `mention` kind (the lenient reader keeps the
|
|
37
|
+
wire's value as-is; the kind's mark data is stored over the write's
|
|
38
|
+
validation, so a peer-written kind outside the enum stands the data). The
|
|
39
|
+
block no longer crashes to its error placeholder over such a run — the
|
|
40
|
+
chip renders with its label, the React's path's parity.
|
|
41
|
+
- 89004ef: The `./mermaid` subpath's entry now stands in the package's `sideEffects`
|
|
42
|
+
list (as the `./pdf`'s entry does): the entry runs the module-scope
|
|
43
|
+
mermaid's configuration, and a tree-shaking bundler over the absent
|
|
44
|
+
entry could drop its side effects.
|
|
45
|
+
- 6c49e41: The ref-table data provider (`useRefTables`) now coalesces its live
|
|
46
|
+
refreshes per entry: a bridge envelope that arrives over a running full
|
|
47
|
+
page-set load marks the entry pending instead of firing a parallel load,
|
|
48
|
+
and the pending re-run stands over the running load's write — a burst of
|
|
49
|
+
envelopes runs the running load plus one trailing load, and overlapping
|
|
50
|
+
loads never interleave their states.
|
|
51
|
+
- d751449: The page sequence's structural stamp (`seqStamp`) now sources a block's
|
|
52
|
+
`type` change over the entry sequence: a `changeBlockType` of a root
|
|
53
|
+
block (the `surface`'s filter input over the page children's derivation)
|
|
54
|
+
stands the stamp's bump, so the sequence re-derives its membership
|
|
55
|
+
instead of standing the stale row set until the next structural change.
|
|
56
|
+
- 691c46c: The `sideEffects` field now covers the base entry's top-level chunks
|
|
57
|
+
(`dist/*.mjs`): the module-scope initialization (the package's own i18next
|
|
58
|
+
instance + the legacy `<html lang>`'s runtime observer) stands declared
|
|
59
|
+
over the tree-shaking's bundlers instead of standing reachable only over
|
|
60
|
+
the subpath entries.
|
|
61
|
+
- Updated dependencies [2cd7f10]
|
|
62
|
+
- Updated dependencies [772a8a0]
|
|
63
|
+
- Updated dependencies [1a77fa3]
|
|
64
|
+
- Updated dependencies [a7610aa]
|
|
65
|
+
- Updated dependencies [ebe7313]
|
|
66
|
+
- Updated dependencies [f1f3679]
|
|
67
|
+
- docblocks-core@0.8.1
|
|
68
|
+
|
|
69
|
+
## 0.18.0
|
|
70
|
+
|
|
71
|
+
### Minor Changes
|
|
72
|
+
|
|
73
|
+
- d89891d: The editor stands a top-level render boundary: a throw of the editor's
|
|
74
|
+
chrome outside a block's renderer (the attributes panel, the canvas chrome,
|
|
75
|
+
the row list) is contained to the editor's content with a failure note and a
|
|
76
|
+
retry, so the consumer's application stays mounted. The boundary is exported
|
|
77
|
+
for the consumer's own wrappers (`fallback` and `resetKey` props); a block's
|
|
78
|
+
renderer keeps its narrower per-block boundary.
|
|
79
|
+
|
|
80
|
+
### Patch Changes
|
|
81
|
+
|
|
82
|
+
- dea90e3: The add-column form surfaces a failed commit's cause over its own error line:
|
|
83
|
+
the bridge's refusal (an in-use enum option's delete, a failed table or column
|
|
84
|
+
creation) no longer stands only in the console while the form shows nothing.
|
|
85
|
+
- ab7a859: The database table's row and column writes drop their late tail after the
|
|
86
|
+
block's table changes: a rollback, an error note or a post-commit refetch of
|
|
87
|
+
the previous table no longer overwrites the relinked grid's rows or leaves it
|
|
88
|
+
loading.
|
|
89
|
+
- 7e0e7c5: The markdown frontmatter drops a `__proto__` key: the entries live in plain
|
|
90
|
+
objects, where the assignment wrote the prototype chain instead of a value,
|
|
91
|
+
so a pasted or imported header could poison the parse's record. The key never
|
|
92
|
+
reaches the document's meta, and the rest of the header parses as usual.
|
|
93
|
+
- 16b251a: The react-ui layer stands a typed error family (`DocBlocksUiError` base +
|
|
94
|
+
the `EditorProviderError`, `BlobNotFoundError`, `PdfFetchError`,
|
|
95
|
+
`CanvasPasteError`, `UnknownSlashCommandError`, `UnhandledValueError`
|
|
96
|
+
conditions, all exported from the base entry): the former raw `Error`
|
|
97
|
+
throws of the provider's prop contract, the blob store's missing-id
|
|
98
|
+
rejections, the PDF fetch's non-ok response, and the internal invariant
|
|
99
|
+
guards now throw the named class — the messages are unchanged, so a
|
|
100
|
+
consumer can catch by class.
|
|
101
|
+
|
|
3
102
|
## 0.17.0
|
|
4
103
|
|
|
5
104
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -97,25 +97,25 @@ slash command is hidden without a bridge; the `sync-embed` block stands
|
|
|
97
97
|
its broken state without a resolver; the `@` stays plain text without a
|
|
98
98
|
mention catalog). The full props list:
|
|
99
99
|
|
|
100
|
-
| Prop | Contract
|
|
101
|
-
| ---------------------------- |
|
|
102
|
-
| `doc` | The core `Doc` to render. Must not change after mount (a throw on change is the contract). Required for the `editor` stand; over the `viewer`'s level the doc IS the published snapshot (the security model — the reader's browser never receives the live document), and an absent stand renders the "not published yet" placeholder.
|
|
103
|
-
| `provider?` | A core `SyncProvider` for the wire + presence. Without it the editor is a single-client document (local edits stand, nothing syncs).
|
|
104
|
-
| `blockRenderers?` | Per-type renderer overrides (see below).
|
|
105
|
-
| `blobStore?` | The blob bridge for image / pdf / file blocks and the document-attributes' cover (see below).
|
|
106
|
-
| `coverPresets?` | The cover's upload modal's preset gallery: the consumer's ready-made cover's file ids (the consumer's blob store's ids) per placement mode — the `tile` / the `center`'s set. A pick commits the id over the mode without an upload (see Blobs below).
|
|
107
|
-
| `databaseBridge?` | The table operations behind external-form database blocks (see below).
|
|
108
|
-
| `syncEmbedResolver?` | `(ref) => Doc \| null` — resolves a `sync-embed` block's ref to the master doc (see below).
|
|
109
|
-
| `embedSandbox?` | `(src) => string \| null` — the embed iframe's `sandbox` policy. The default grants the same-origin (the embedded app's own storage / cookies stand, so the real apps boot); `null` stands no sandbox (a fully trusted embed).
|
|
110
|
-
| `pdfPreview?` | A first-page preview component for PDF file blocks (and legacy PDF image blocks).
|
|
111
|
-
| `mentionProvider?` | The `@` mention picker's search catalog (see below).
|
|
112
|
-
| `mentionInteractions?` | The mention chip's hover card + the click's delivery (see below). Without the prop the chip stands inert (no card, the click is the browser's stand).
|
|
113
|
-
| `rootBlockId?` | Render the entry list of this block instead of the document root (the subtree view). Must not change after mount.
|
|
114
|
-
| `commandPalettePlaceholder?` | The empty-block hint override; the default is localized (en/ru).
|
|
115
|
-
| `accessLevel?` | The consumer's user access level (default `editor`): `viewer` forces the `published` mode (the current state is never rendered to a reader).
|
|
116
|
-
| `mode?` | The document mode (default `edit`): `view` is a read-only live document; `published` renders the `publishedDoc` snapshot read-only.
|
|
117
|
-
| `publishedDoc?` | The published snapshot (a hydrated core `Doc`; must not change after mount — remount over `key` for a new snapshot). The consumer owns the publish action and the snapshot storage.
|
|
118
|
-
| `presence?` | The local user's presence identity + the selection-sharing cipher (see Presence sharing below). Without the prop the editor keeps the legacy stand (the anonymous plaintext selection, always shared over the room).
|
|
100
|
+
| Prop | Contract |
|
|
101
|
+
| ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
102
|
+
| `doc` | The core `Doc` to render. Must not change after mount (a throw on change is the contract). Required for the `editor` stand; over the `viewer`'s level the doc IS the published snapshot (the security model — the reader's browser never receives the live document), and an absent stand renders the "not published yet" placeholder. |
|
|
103
|
+
| `provider?` | A core `SyncProvider` for the wire + presence. Without it the editor is a single-client document (local edits stand, nothing syncs). |
|
|
104
|
+
| `blockRenderers?` | Per-type renderer overrides (see below). |
|
|
105
|
+
| `blobStore?` | The blob bridge for image / pdf / file blocks and the document-attributes' cover (see below). |
|
|
106
|
+
| `coverPresets?` | The cover's upload modal's preset gallery: the consumer's ready-made cover's file ids (the consumer's blob store's ids) per placement mode — the `tile` / the `center`'s set. A pick commits the id over the mode without an upload (see Blobs below). |
|
|
107
|
+
| `databaseBridge?` | The table operations behind external-form database blocks (see below). |
|
|
108
|
+
| `syncEmbedResolver?` | `(ref) => Doc \| null` — resolves a `sync-embed` block's ref to the master doc (see below). |
|
|
109
|
+
| `embedSandbox?` | `(src) => string \| null` — the embed iframe's `sandbox` policy. The default grants the same-origin (the embedded app's own storage / cookies stand, so the real apps boot); `null` stands no sandbox (a fully trusted embed). Over an untrusted URL stand the `""`'s return (the opaque origin, no scripts); the opaque-origin's restriction stands over this policy. |
|
|
110
|
+
| `pdfPreview?` | A first-page preview component for PDF file blocks (and legacy PDF image blocks). |
|
|
111
|
+
| `mentionProvider?` | The `@` mention picker's search catalog (see below). |
|
|
112
|
+
| `mentionInteractions?` | The mention chip's hover card + the click's delivery (see below). Without the prop the chip stands inert (no card, the click is the browser's stand). |
|
|
113
|
+
| `rootBlockId?` | Render the entry list of this block instead of the document root (the subtree view). Must not change after mount. |
|
|
114
|
+
| `commandPalettePlaceholder?` | The empty-block hint override; the default is localized (en/ru). |
|
|
115
|
+
| `accessLevel?` | The consumer's user access level (default `editor`): `viewer` forces the `published` mode (the current state is never rendered to a reader). |
|
|
116
|
+
| `mode?` | The document mode (default `edit`): `view` is a read-only live document; `published` renders the `publishedDoc` snapshot read-only. |
|
|
117
|
+
| `publishedDoc?` | The published snapshot (a hydrated core `Doc`; must not change after mount — remount over `key` for a new snapshot). The consumer owns the publish action and the snapshot storage. |
|
|
118
|
+
| `presence?` | The local user's presence identity + the selection-sharing cipher (see Presence sharing below). Without the prop the editor keeps the legacy stand (the anonymous plaintext selection, always shared over the room). |
|
|
119
119
|
|
|
120
120
|
Two rules for the optional props:
|
|
121
121
|
|
|
@@ -226,6 +226,87 @@ document data, never on the wire):
|
|
|
226
226
|
its `doc` (the viewer's switcher stays off — the `accessLevel` stands no
|
|
227
227
|
`mode` stand over the `viewer` level).
|
|
228
228
|
|
|
229
|
+
### Document attributes
|
|
230
|
+
|
|
231
|
+
The `DocMeta.attributes` record is consumer-owned document metadata (the
|
|
232
|
+
markdown frontmatter's stand): arbitrary keys, typed values
|
|
233
|
+
(`string | number | boolean | string[] | MentionRef` — the id-only
|
|
234
|
+
`{ kind, id }` reference — `| { type, value }` over the
|
|
235
|
+
`ATTRIBUTE_TYPES` enum), a display order (`attributesOrder` — an
|
|
236
|
+
optional permutation of the keys; its absence stands the record's order),
|
|
237
|
+
and the core's commands `setAttribute` / `removeAttribute` /
|
|
238
|
+
`renameAttribute` / `reorderAttributes` (one transaction each). The panel
|
|
239
|
+
renders over the page column as a collapsible section: the system rows
|
|
240
|
+
(`id`, `created`, the live `last updated` — date-only, locale-formatted),
|
|
241
|
+
the preset rows (`description`, `tags`, `createdBy`, `cover` — including
|
|
242
|
+
the `coverMode` `tile`/`center` placement and the `coverTint` frame
|
|
243
|
+
accent, `status`, `publishedAt`), and the custom rows (added at the
|
|
244
|
+
list's tail over the type picker + the name's draft; a typed row's
|
|
245
|
+
initial form stands over the picked type). The custom rows are
|
|
246
|
+
drag-reorderable (the commit — one `reorderAttributes` command, one
|
|
247
|
+
undo step). The read-only modes render the rows display-only.
|
|
248
|
+
|
|
249
|
+
The panel is consumer-decoupled over the `EditorProvider` props:
|
|
250
|
+
|
|
251
|
+
```tsx
|
|
252
|
+
<EditorProvider
|
|
253
|
+
doc={doc}
|
|
254
|
+
// Hide the listed keys (the system, the preset or any custom key)
|
|
255
|
+
// from the panel over every mode (edit, view, and published).
|
|
256
|
+
hiddenAttributes={["cover"]}
|
|
257
|
+
// The tags' consumer contract (the document never stores tags).
|
|
258
|
+
docTags={{ tags: docTags, onTagAdd, onTagRemove, onTagClick }}
|
|
259
|
+
// The description's consumer contract (the document never stores it;
|
|
260
|
+
// without the prop the built-in stand reads `attributes.description`).
|
|
261
|
+
docDescription={{ value: description, onEdit: commitDescription }}
|
|
262
|
+
// The consumer's value-zone renderer over a key (null / absent = the
|
|
263
|
+
// built-in editors).
|
|
264
|
+
renderAttribute={({ key, value, onChange, onRemove, readOnly }) =>
|
|
265
|
+
key === "owner" ? <OwnerPicker value={value} onCommit={onChange} /> : null
|
|
266
|
+
}
|
|
267
|
+
// The consumer's type-picker UI over the add popover (absent = the
|
|
268
|
+
// built-in picker).
|
|
269
|
+
attributeTypePicker={({ value, onChange }) => <MyTypePicker value={value} onChange={onChange} />}
|
|
270
|
+
// The consumer's cover preset gallery (the file ids per placement mode;
|
|
271
|
+
// a pick commits the id without an upload; absent = no grid).
|
|
272
|
+
coverPresets={{ tile: ["cover-1", "cover-2"], center: ["cover-3"] }}
|
|
273
|
+
></EditorProvider>
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
Every customization value is read per render into the provider context:
|
|
277
|
+
pass a stable reference; a nested provider that supplies none inherits
|
|
278
|
+
the enclosing one.
|
|
279
|
+
|
|
280
|
+
### Document import
|
|
281
|
+
|
|
282
|
+
`importDocument` fills a FRESH document (the empty root) from a markdown
|
|
283
|
+
or HTML payload — the consumer's pre-attach write (the content stands in
|
|
284
|
+
the first full-state bootstrap the sync attach sends, so the first wire
|
|
285
|
+
sync persists it):
|
|
286
|
+
|
|
287
|
+
```ts
|
|
288
|
+
import { importDocument } from "docblocks-react-ui";
|
|
289
|
+
|
|
290
|
+
import { attach, createDoc } from "docblocks-core";
|
|
291
|
+
|
|
292
|
+
const doc = createDoc({ id: "new-doc-id" });
|
|
293
|
+
importDocument(doc, rawMarkdown, "markdown"); // one transaction: one undo step, one wire update
|
|
294
|
+
attach(doc, provider);
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
- `kind: "markdown" | "html"` — the paste parsers' shared materialization
|
|
298
|
+
(the same typed block / table / runs writes the paste pipeline uses);
|
|
299
|
+
- an empty or whitespace-only payload is a no-op (no transaction);
|
|
300
|
+
- a non-fresh document (the root has children) throws the typed
|
|
301
|
+
`ImportDocumentError` — the import fills the root, it never appends;
|
|
302
|
+
- the markdown's YAML frontmatter (a leading `--- … ---` fence, a hand-
|
|
303
|
+
rolled subset) is stripped before the blocks' parse and mapped to the
|
|
304
|
+
meta over the fresh document: `title` → the doc's title, the known
|
|
305
|
+
keys → the attribute's presets (`author` / `created_by` →
|
|
306
|
+
`createdBy`, …), the unknown keys → the custom attribute keys; a
|
|
307
|
+
frontmatter without a body is a meta-only import. The reserved
|
|
308
|
+
`__proto__` key is dropped (the entries live in plain objects).
|
|
309
|
+
|
|
229
310
|
### Sync and presence
|
|
230
311
|
|
|
231
312
|
The transport is a core concern: create the doc, build a provider, attach
|
|
@@ -263,9 +344,13 @@ function App() {
|
|
|
263
344
|
unmount.
|
|
264
345
|
- `WsSyncProvider` speaks standard y-protocols over WebSocket (the
|
|
265
346
|
y-websocket wire, wire-compatible with a standard y-websocket server);
|
|
266
|
-
`options: { token?, webSocketImpl? }
|
|
267
|
-
|
|
268
|
-
|
|
347
|
+
`options: { token?, webSocketImpl?, maxPendingBytes?, maxFrameBytes? }`
|
|
348
|
+
(the client-side backpressure ceilings — the buffered local updates
|
|
349
|
+
over the not-open socket, the one incoming frame; the defaults are
|
|
350
|
+
4 MiB each, and the overflow flag is reported through `getPendingStats`). Any object
|
|
351
|
+
implementing the core `SyncProvider` interface (connect / disconnect /
|
|
352
|
+
sendUpdate / onUpdate / getLocalStateVector / setAwareness / onAwareness)
|
|
353
|
+
works in its place.
|
|
269
354
|
- Presence rides the provider's awareness channel: the editor publishes its
|
|
270
355
|
own selection automatically (debounced) and renders the remote peers'
|
|
271
356
|
carets. `usePresence()` reads the per-peer state (peer id, selection,
|
|
@@ -450,7 +535,11 @@ package root: `BridgeError` (the structured error type) with
|
|
|
450
535
|
(the client-issued `operationId` per op), `PROTOCOL_VERSION` /
|
|
451
536
|
`BASELINE_CAPABILITIES` / `validateProtocolDescriptor` (the negotiation),
|
|
452
537
|
`isDatabaseBridge`, and `useDatabaseTable(bridge, tableId, filter?)` — the
|
|
453
|
-
grid controller for a consumer-owned grid over the bridge.
|
|
538
|
+
grid controller for a consumer-owned grid over the bridge. The filter's
|
|
539
|
+
utilities are exported as well: `emptyFilter`, `filterIsComplete`,
|
|
540
|
+
`conditionMatches` (the filter's evaluation over a row), `parseCellValue` /
|
|
541
|
+
`cellValueEqual` (the cell's typed comparison), and `columnAnnotation`
|
|
542
|
+
(the column's type annotation over the filter's value editor).
|
|
454
543
|
|
|
455
544
|
The grid's **Columns** control lists every column, restores hidden columns,
|
|
456
545
|
and reorders them by dragging their grips or pressing ArrowUp/ArrowDown on a
|
|
@@ -606,18 +695,25 @@ catalog and returns `{ id, label }` entries:
|
|
|
606
695
|
const mentionProvider = {
|
|
607
696
|
searchUsers: async (query: string) => [{ id: "u1", label: "Ada Lovelace" }],
|
|
608
697
|
searchDocs: async (query: string) => [{ id: "d1", label: "API Reference" }],
|
|
698
|
+
// The chip's live label over the target's id (the synchronous read —
|
|
699
|
+
// the consumer's cache over the catalog / the doc's meta); absent or
|
|
700
|
+
// null stand the insertion-time label.
|
|
701
|
+
resolveLabel: (kind, id) => labelFromCache(kind, id),
|
|
609
702
|
};
|
|
610
703
|
```
|
|
611
704
|
|
|
612
705
|
A pick replaces the `@query` phrase with the label and stands the `mention`
|
|
613
|
-
mark (the `kind` `"user"` or `"doc"
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
706
|
+
mark (the `kind` `"user"` or `"doc"` and the stable `id` — the id-only
|
|
707
|
+
stand; the legacy `label` snapshot is tolerated over the lenient read,
|
|
708
|
+
never written) in one transaction — one undo step. The mention renders as
|
|
709
|
+
an atomic, non-editable chip: the kind's inline icon (the `user`'s person,
|
|
710
|
+
the `doc`'s exit arrow) over the semibold, underlined label — an inline
|
|
711
|
+
run of the text line, no pill of its own. The chip carries the target id
|
|
712
|
+
(`data-mention-kind` + `data-mention-id`), so the consumer can stand a
|
|
713
|
+
"removed" state by id. The chip's text stands the consumer's
|
|
714
|
+
`resolveLabel(kind, id)` live resolution where it resolves (the rename's
|
|
715
|
+
live stand) and the insertion-time label (the run's text) otherwise — a
|
|
716
|
+
renamed / removed target never changes the document.
|
|
621
717
|
Copying a mention stands the `@label` plain text. Without the prop the `@`
|
|
622
718
|
is plain text (no picker). The mark is non-exclusive (it composes with the
|
|
623
719
|
other marks).
|
|
@@ -646,17 +742,18 @@ const mentionInteractions: MentionInteractions = {
|
|
|
646
742
|
```
|
|
647
743
|
|
|
648
744
|
The target stands the document's `mention` mark (the core's `MentionMark`
|
|
649
|
-
— the `kind
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
745
|
+
— the `kind` and the stable `id` — the id-only stand; the legacy `label`
|
|
746
|
+
snapshot is tolerated over the lenient read): resolve the current data
|
|
747
|
+
over the `id` (the catalog, the URL) and stand the removed state
|
|
748
|
+
yourself — the document stores the identity only. The value is read per
|
|
749
|
+
render into the provider context: pass a stable reference.
|
|
653
750
|
A nested provider that supplies none inherits the enclosing one.
|
|
654
751
|
|
|
655
752
|
### Links
|
|
656
753
|
|
|
657
|
-
The `link` mark's href stands one of four classes (the
|
|
658
|
-
`linkHrefKindOf` — the classifier the
|
|
659
|
-
click's open all stand on):
|
|
754
|
+
The `link` mark's href stands one of four classes (the core's
|
|
755
|
+
`linkHrefKindOf`, exported from `docblocks-core` — the classifier the
|
|
756
|
+
validator, the renderer, and the click's open all stand on):
|
|
660
757
|
|
|
661
758
|
| Class | Example | The click's open |
|
|
662
759
|
| ---------- | ------------------------------------------------ | ------------------------------------ |
|
|
@@ -792,6 +889,58 @@ value actually changes (the store's reference-stability contract):
|
|
|
792
889
|
| `view` | `"page"` (default) or `"canvas"` — the rendering the consumer switches |
|
|
793
890
|
| `formatPalette` | The format toolbar's color swatches (default `FORMAT_PALETTE`, exported) |
|
|
794
891
|
|
|
892
|
+
### Render failure containment
|
|
893
|
+
|
|
894
|
+
Two error boundaries keep a render failure contained:
|
|
895
|
+
|
|
896
|
+
- the per-block `BlockErrorBoundary` (internal) — a failed block's render
|
|
897
|
+
stands its placeholder; the rest of the document keeps working;
|
|
898
|
+
- the `EditorErrorBoundary` (exported) — the editor's content boundary for
|
|
899
|
+
a failure outside a block's renderer (the chrome, the row layer): the
|
|
900
|
+
failure note plus a retry, so the throw never unmounts the consumer's
|
|
901
|
+
application:
|
|
902
|
+
|
|
903
|
+
```tsx
|
|
904
|
+
import { EditorErrorBoundary } from "docblocks-react-ui";
|
|
905
|
+
|
|
906
|
+
<EditorErrorBoundary
|
|
907
|
+
fallback={({ error, retry }) => <MyErrorState error={error} onRetry={retry} />}
|
|
908
|
+
resetKey={retryKey} // change the key to force a clean remount
|
|
909
|
+
>
|
|
910
|
+
<Editor view={view} />
|
|
911
|
+
</EditorErrorBoundary>;
|
|
912
|
+
```
|
|
913
|
+
|
|
914
|
+
### Errors
|
|
915
|
+
|
|
916
|
+
The package's typed errors mirror `docblocks-core`'s typed command
|
|
917
|
+
errors: a failed prop contract, a failed blob-store lookup, or a failed
|
|
918
|
+
fetch throws a named class (never a raw `Error`), so a consumer can catch
|
|
919
|
+
by class and the error's identity survives the React boundary:
|
|
920
|
+
|
|
921
|
+
| Class | Meaning |
|
|
922
|
+
| -------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
|
|
923
|
+
| `DocBlocksUiError` | The base class for all docblocks-react-ui errors. |
|
|
924
|
+
| `EditorProviderError` | The `EditorProvider`'s prop contract was violated (a mount-immutable prop changed, or a required prop is absent). |
|
|
925
|
+
| `BlobNotFoundError` | The blob store has no stored object for the file id. |
|
|
926
|
+
| `PdfFetchError` | The PDF bytes could not be fetched (a non-ok HTTP response). |
|
|
927
|
+
| `CanvasPasteError` | The canvas paste's internal invariant was violated. |
|
|
928
|
+
| `UnknownSlashCommandError` | The slash command's block type is outside the known registry set. |
|
|
929
|
+
| `UnhandledValueError` | The exhaustiveness backstop: a value escaped a closed union's types. |
|
|
930
|
+
| `HookMisuseError` | A docblocks hook ran outside its provider (the editor's context / the block's context is absent — the mount shape's broken stand). |
|
|
931
|
+
|
|
932
|
+
```ts
|
|
933
|
+
import { BlobNotFoundError } from "docblocks-react-ui";
|
|
934
|
+
|
|
935
|
+
try {
|
|
936
|
+
await store.get(fileId);
|
|
937
|
+
} catch (error) {
|
|
938
|
+
if (error instanceof BlobNotFoundError) {
|
|
939
|
+
/* the file was deleted on the consumer's side */
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
```
|
|
943
|
+
|
|
795
944
|
The page view renders the flat page sequence — every page block is its
|
|
796
945
|
own row (the drag-reorder's pure framer `Reorder`, the insert/remove's
|
|
797
946
|
layout animation, the rendered list marker per row) — over the required
|