docblocks-react-ui 0.18.1 → 0.19.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 +82 -0
- package/README.md +30 -0
- package/dist/{Editor-DCzrR1FJ.mjs → Editor-C51vAW7_.mjs} +399 -113
- package/dist/{index-G44JW36p.d.mts → index-2gZyAsdf.d.mts} +2 -2
- package/dist/{index-sNhMaFHp.d.mts → index-BoKKzCxv.d.mts} +112 -72
- package/dist/index.d.mts +5 -19
- package/dist/index.mjs +2 -2
- package/dist/mermaid/index.d.mts +1 -1
- package/dist/mermaid/index.mjs +1 -1
- package/dist/pdf/index.d.mts +1 -1
- package/dist/styles.css +7 -0
- package/package.json +2 -2
|
@@ -6972,6 +6972,16 @@ function isFatalTableError(error) {
|
|
|
6972
6972
|
const code = errorCodeOf(error);
|
|
6973
6973
|
return code === "not_found" || code === "forbidden";
|
|
6974
6974
|
}
|
|
6975
|
+
/** The row's effective read (the write's pre-operation state source):
|
|
6976
|
+
* the committed page row, else the pending row (the filtered-out row the
|
|
6977
|
+
* page holds no reference to — the no-op guard and the undo entry's
|
|
6978
|
+
* pre-operation stand must not strand over its absent entry). */
|
|
6979
|
+
function rowOf(rowsRef, pendingRowRef, rowId) {
|
|
6980
|
+
const committed = rowsRef.current.find((row) => row.rowId === rowId);
|
|
6981
|
+
if (committed !== void 0) return committed;
|
|
6982
|
+
const pending = pendingRowRef.current;
|
|
6983
|
+
return pending !== null && pending.rowId === rowId ? pending : void 0;
|
|
6984
|
+
}
|
|
6975
6985
|
//#endregion
|
|
6976
6986
|
//#region src/database/use-database-table/column-ops.ts
|
|
6977
6987
|
/**
|
|
@@ -7295,7 +7305,7 @@ function createRowWriteOps(ctx) {
|
|
|
7295
7305
|
cells: { ...row.cells }
|
|
7296
7306
|
}));
|
|
7297
7307
|
const pendingSnapshot = pendingRowRef.current;
|
|
7298
|
-
const current = rowsRef
|
|
7308
|
+
const current = rowOf(rowsRef, pendingRowRef, rowId);
|
|
7299
7309
|
const cleaned = cleanCells(cells);
|
|
7300
7310
|
if (current !== void 0 && Object.entries(cleaned).every(([key, value]) => cellValueEqual(current.cells[key], value))) return;
|
|
7301
7311
|
setRows((rows) => rows.map((row) => row.rowId === rowId ? {
|
|
@@ -7389,12 +7399,13 @@ function createRowBatchOps(ctx) {
|
|
|
7389
7399
|
}));
|
|
7390
7400
|
const pendingSnapshot = pendingRowRef.current;
|
|
7391
7401
|
const before = new Map(rowsRef.current.map((row) => [row.rowId, row.cells]));
|
|
7402
|
+
seedPendingBefore(before, pendingSnapshot, updates);
|
|
7392
7403
|
const cleaned = updates.map(({ rowId, cells }) => ({
|
|
7393
7404
|
rowId,
|
|
7394
7405
|
cells: cleanCells(cells)
|
|
7395
7406
|
}));
|
|
7396
7407
|
if (cleaned.every(({ rowId, cells }) => {
|
|
7397
|
-
const row = rowsRef
|
|
7408
|
+
const row = rowOf(rowsRef, pendingRowRef, rowId);
|
|
7398
7409
|
return row !== void 0 && Object.entries(cells).every(([key, value]) => cellValueEqual(row.cells[key], value));
|
|
7399
7410
|
})) return;
|
|
7400
7411
|
applyOptimistic(ctx, cleaned);
|
|
@@ -7452,12 +7463,13 @@ function createRowBatchOps(ctx) {
|
|
|
7452
7463
|
}));
|
|
7453
7464
|
const pendingSnapshot = pendingRowRef.current;
|
|
7454
7465
|
const before = new Map(rowsRef.current.map((row) => [row.rowId, row.cells]));
|
|
7466
|
+
seedPendingBefore(before, pendingSnapshot, updates);
|
|
7455
7467
|
const cleaned = updates.map(({ rowId, cells }) => ({
|
|
7456
7468
|
rowId,
|
|
7457
7469
|
cells: cleanCells(cells)
|
|
7458
7470
|
}));
|
|
7459
7471
|
const updatesChanged = cleaned.some(({ rowId, cells }) => {
|
|
7460
|
-
const row = rowsRef
|
|
7472
|
+
const row = rowOf(rowsRef, pendingRowRef, rowId);
|
|
7461
7473
|
return row === void 0 || !Object.entries(cells).every(([key, value]) => cellValueEqual(row.cells[key], value));
|
|
7462
7474
|
});
|
|
7463
7475
|
if (!updatesChanged && creates.length === 0) return [];
|
|
@@ -7527,6 +7539,14 @@ function createRowBatchOps(ctx) {
|
|
|
7527
7539
|
pasteRows
|
|
7528
7540
|
};
|
|
7529
7541
|
}
|
|
7542
|
+
/** The pending row's pre-operation cells over the `before` map (the
|
|
7543
|
+
* inverse's restore stand): the page holds no reference to the
|
|
7544
|
+
* filtered-out row, so the map's seed is the write's pre-operation
|
|
7545
|
+
* source only when the batch touches the row's id. */
|
|
7546
|
+
function seedPendingBefore(before, pending, updates) {
|
|
7547
|
+
if (pending === null) return;
|
|
7548
|
+
if (updates.some(({ rowId }) => rowId === pending.rowId)) before.set(pending.rowId, pending.cells);
|
|
7549
|
+
}
|
|
7530
7550
|
/** The optimistic apply over the cleaned patches (the single-row / the
|
|
7531
7551
|
* batch's shared stand: the rows' cells + the pending row's cells). */
|
|
7532
7552
|
function applyOptimistic(ctx, cleaned) {
|
|
@@ -7583,11 +7603,11 @@ function restorePatchesOf(before, cleaned) {
|
|
|
7583
7603
|
* the refetched state).
|
|
7584
7604
|
*/
|
|
7585
7605
|
function createRowStructureOps(ctx) {
|
|
7586
|
-
const { bridge, tableId, rowsRef, capabilitiesRef, setRows, setPendingRow } = ctx;
|
|
7606
|
+
const { bridge, tableId, rowsRef, pendingRowRef, capabilitiesRef, setRows, setPendingRow } = ctx;
|
|
7587
7607
|
const { pushUndo, refresh, noteError, casOf, sameIdentity } = ctx;
|
|
7588
7608
|
const removeRow = async (rowId) => {
|
|
7589
7609
|
const snapshot = rowsRef.current;
|
|
7590
|
-
const row =
|
|
7610
|
+
const row = rowOf(rowsRef, pendingRowRef, rowId);
|
|
7591
7611
|
setRows((rows) => rows.filter((entry) => entry.rowId !== rowId));
|
|
7592
7612
|
try {
|
|
7593
7613
|
await bridge.batchRows(tableId, { ops: [{
|
|
@@ -10515,6 +10535,7 @@ function commitColumnFormEdit(ctx, draft) {
|
|
|
10515
10535
|
color: colorColumnId !== void 0 && typeof row.cells[colorColumnId] === "string" ? row.cells[colorColumnId] : null
|
|
10516
10536
|
}));
|
|
10517
10537
|
const draftOptions = (draft.enumOptions ?? []).filter((option) => option.name.trim() !== "");
|
|
10538
|
+
const seenRowIds = draft.enumSeenRowIds !== void 0 ? new Set(draft.enumSeenRowIds) : null;
|
|
10518
10539
|
const keptRowIds = /* @__PURE__ */ new Set();
|
|
10519
10540
|
const cellOf = (option) => {
|
|
10520
10541
|
const cells = Object.create(null);
|
|
@@ -10546,7 +10567,7 @@ function commitColumnFormEdit(ctx, draft) {
|
|
|
10546
10567
|
cells
|
|
10547
10568
|
});
|
|
10548
10569
|
}
|
|
10549
|
-
for (const entry of current) if (!keptRowIds.has(entry.rowId)) ops.push({
|
|
10570
|
+
for (const entry of current) if (!keptRowIds.has(entry.rowId) && (seenRowIds === null || seenRowIds.has(entry.rowId))) ops.push({
|
|
10550
10571
|
op: "delete",
|
|
10551
10572
|
rowId: entry.rowId
|
|
10552
10573
|
});
|
|
@@ -10575,7 +10596,7 @@ function commitColumnFormEdit(ctx, draft) {
|
|
|
10575
10596
|
cells
|
|
10576
10597
|
}] }, newMutationContext());
|
|
10577
10598
|
}
|
|
10578
|
-
for (const entry of current) if (!keptRowIds.has(entry.rowId)) await bridge.batchRows(refTableId, { ops: [{
|
|
10599
|
+
for (const entry of current) if (!keptRowIds.has(entry.rowId) && (seenRowIds === null || seenRowIds.has(entry.rowId))) await bridge.batchRows(refTableId, { ops: [{
|
|
10579
10600
|
op: "delete",
|
|
10580
10601
|
rowId: entry.rowId
|
|
10581
10602
|
}] }, newMutationContext());
|
|
@@ -10718,6 +10739,7 @@ function useColumnForm({ bridge, tableId, data, refTableData, readColumnOrder, o
|
|
|
10718
10739
|
refPick: column.refTableId,
|
|
10719
10740
|
newTableName: "",
|
|
10720
10741
|
enumOptions: options,
|
|
10742
|
+
enumSeenRowIds: options.map((option) => option.rowId),
|
|
10721
10743
|
editColumnId: column.id
|
|
10722
10744
|
});
|
|
10723
10745
|
setColumnFormError(null);
|
|
@@ -12188,45 +12210,167 @@ function FileCard({ id, fileId, blockType, url, name, subtype }) {
|
|
|
12188
12210
|
}
|
|
12189
12211
|
//#endregion
|
|
12190
12212
|
//#region src/blocks/blob-styles.ts
|
|
12191
|
-
/** The shared blob placeholder card's structural classes
|
|
12213
|
+
/** The shared blob placeholder card's structural classes (the vertical
|
|
12214
|
+
* spacing stands per caller: the image figure carries none of its own, the
|
|
12215
|
+
* file card carries the block spacing). */
|
|
12192
12216
|
const BLOB_PLACEHOLDER_CLASS = `
|
|
12193
|
-
mx-0
|
|
12217
|
+
mx-0 rounded-(--docblocks-radius)
|
|
12194
12218
|
border-(length:--docblocks-table-border-width) border-dashed border-(--docblocks-table-border-color)
|
|
12195
12219
|
outline-none
|
|
12196
12220
|
`;
|
|
12221
|
+
/** The block spacing the file placeholder mirrors (the file card's own
|
|
12222
|
+
* margins). */
|
|
12223
|
+
const BLOB_PLACEHOLDER_SPACING = "my-(--docblocks-block-spacing)";
|
|
12224
|
+
/**
|
|
12225
|
+
* The image placeholder's reserved height: the store's intrinsic dimensions
|
|
12226
|
+
* stand the card's aspect ratio, so the lazy resolution's landing never
|
|
12227
|
+
* shifts the page (the reader's scroll anchor stays put). Without the
|
|
12228
|
+
* dimensions the card keeps the status quo (the content's own height).
|
|
12229
|
+
*/
|
|
12230
|
+
function blobPlaceholderAspect(meta) {
|
|
12231
|
+
if (meta?.width === void 0 || meta.height === void 0) return void 0;
|
|
12232
|
+
if (meta.width <= 0 || meta.height <= 0) return void 0;
|
|
12233
|
+
return { aspectRatio: `${meta.width} / ${meta.height}` };
|
|
12234
|
+
}
|
|
12235
|
+
//#endregion
|
|
12236
|
+
//#region src/shared/hooks/use-in-view.ts
|
|
12237
|
+
/**
|
|
12238
|
+
* The viewport entry's hook (the lazy resolution's gate): tracks whether the
|
|
12239
|
+
* observed element stands in the viewport's preload band. The element's
|
|
12240
|
+
* bounding rect is measured once at mount — an element above the fold is
|
|
12241
|
+
* in view at once (no placeholder flash on the first screen); the rest
|
|
12242
|
+
* follow the `IntersectionObserver`'s first entry, which ends the tracking:
|
|
12243
|
+
* the caller's work stands over the in-view decision, so the box's later
|
|
12244
|
+
* moves (a resolved block's unmount, a scroll away) do not re-gate it.
|
|
12245
|
+
*
|
|
12246
|
+
* The band is the viewport grown by the preload margin (the
|
|
12247
|
+
* `--docblocks-image-preload-margin` token — 200% by default, so the
|
|
12248
|
+
* network runs well before the element enters the frame). Without an
|
|
12249
|
+
* `IntersectionObserver` in the runtime (SSR hydration, a test
|
|
12250
|
+
* environment) the hook reports in view: the resolution's eager fallback.
|
|
12251
|
+
*/
|
|
12252
|
+
/** The preload margin's CSS token (resolved on the observed element — the
|
|
12253
|
+
* editor root's token map stands in its ancestry). */
|
|
12254
|
+
const PRELOAD_MARGIN_TOKEN = "--docblocks-image-preload-margin";
|
|
12255
|
+
/** The fallback preload margin (two viewport heights on every side). */
|
|
12256
|
+
const DEFAULT_PRELOAD_MARGIN = "200%";
|
|
12257
|
+
/** The observed element's preload margin: the token's value, or the fallback
|
|
12258
|
+
* over the absent token. */
|
|
12259
|
+
function readPreloadMargin(node) {
|
|
12260
|
+
if (typeof getComputedStyle !== "function") return DEFAULT_PRELOAD_MARGIN;
|
|
12261
|
+
const value = getComputedStyle(node).getPropertyValue(PRELOAD_MARGIN_TOKEN).trim();
|
|
12262
|
+
return value === "" ? DEFAULT_PRELOAD_MARGIN : value;
|
|
12263
|
+
}
|
|
12264
|
+
/** True when the element's box touches the viewport at the mount's stand. */
|
|
12265
|
+
function standsAboveFold(node) {
|
|
12266
|
+
const rect = node.getBoundingClientRect();
|
|
12267
|
+
return rect.bottom > 0 && rect.top < window.innerHeight;
|
|
12268
|
+
}
|
|
12269
|
+
function useInView(options = {}) {
|
|
12270
|
+
const { disabled = false, ready = true } = options;
|
|
12271
|
+
const [inView, setInView] = useState(() => disabled || typeof IntersectionObserver === "undefined");
|
|
12272
|
+
const nodeRef = useRef(null);
|
|
12273
|
+
const ref = useCallback((node) => {
|
|
12274
|
+
nodeRef.current = node;
|
|
12275
|
+
}, []);
|
|
12276
|
+
useLayoutEffect(() => {
|
|
12277
|
+
const node = nodeRef.current;
|
|
12278
|
+
if (disabled || typeof IntersectionObserver === "undefined") {
|
|
12279
|
+
setInView(true);
|
|
12280
|
+
return;
|
|
12281
|
+
}
|
|
12282
|
+
if (!ready || node === null) return;
|
|
12283
|
+
if (standsAboveFold(node)) {
|
|
12284
|
+
setInView(true);
|
|
12285
|
+
return;
|
|
12286
|
+
}
|
|
12287
|
+
const observer = new IntersectionObserver((entries) => {
|
|
12288
|
+
const entry = entries[entries.length - 1];
|
|
12289
|
+
if (entry === void 0) return;
|
|
12290
|
+
if (entry.isIntersecting) observer.disconnect();
|
|
12291
|
+
setInView(entry.isIntersecting);
|
|
12292
|
+
}, { rootMargin: readPreloadMargin(node) });
|
|
12293
|
+
observer.observe(node);
|
|
12294
|
+
return () => observer.disconnect();
|
|
12295
|
+
}, [disabled, ready]);
|
|
12296
|
+
return {
|
|
12297
|
+
ref,
|
|
12298
|
+
inView
|
|
12299
|
+
};
|
|
12300
|
+
}
|
|
12197
12301
|
//#endregion
|
|
12198
12302
|
//#region src/blocks/use-blob-file.ts
|
|
12199
12303
|
/**
|
|
12200
12304
|
* Resolve a file id and keep the object URL synchronized with store
|
|
12201
|
-
* changes. The
|
|
12202
|
-
*
|
|
12203
|
-
*
|
|
12204
|
-
*
|
|
12205
|
-
*
|
|
12206
|
-
*
|
|
12207
|
-
*
|
|
12208
|
-
|
|
12209
|
-
|
|
12305
|
+
* changes. The resolution stands in two phases: the metadata's lookup (the
|
|
12306
|
+
* store's opt-in `getMeta` — no body transfer) runs at mount, and the
|
|
12307
|
+
* bytes' fetch (`get` + the object URL) runs only once the placeholder's
|
|
12308
|
+
* box stands in the viewport's preload band — the viewport-gated lazy
|
|
12309
|
+
* loading. The gate waits for the head's metadata over a store that offers
|
|
12310
|
+
* it: the reserved aspect ratio is the layout the band's decision is made
|
|
12311
|
+
* on (a document of images resolves its first screen only).
|
|
12312
|
+
*
|
|
12313
|
+
* With a `getMeta` member the non-renderable MIME (the predicate) stands
|
|
12314
|
+
* the meta-only view when the store supplies a `downloadUrl`; the
|
|
12315
|
+
* renderable MIME (and the absent `downloadUrl`) resolves the bytes over
|
|
12316
|
+
* `get` as before. Without `getMeta` the resolution stands the legacy
|
|
12317
|
+
* path's phases: no metadata before the bytes, the bytes over `get` once
|
|
12318
|
+
* the block is in view. A store change re-resolves over the current band,
|
|
12319
|
+
* and a view that already resolved never falls back to the placeholder
|
|
12320
|
+
* outside it.
|
|
12321
|
+
*/
|
|
12322
|
+
function useBlobFile(fileId, rendersBytes, options = {}) {
|
|
12210
12323
|
const { blobStore } = useEditorContext();
|
|
12324
|
+
const getMeta = blobStore.getMeta;
|
|
12211
12325
|
const [ref, setRef] = useState(null);
|
|
12212
12326
|
const [metaView, setMetaView] = useState(null);
|
|
12327
|
+
/** The head's metadata (the loading stand's aspect-ratio input). */
|
|
12328
|
+
const [headMeta, setHeadMeta] = useState(null);
|
|
12213
12329
|
/** The resolution's rejection (the missing stand) — a resolve clears it. */
|
|
12214
12330
|
const [failed, setFailed] = useState(false);
|
|
12215
12331
|
const [view, setView] = useState(null);
|
|
12332
|
+
const headSettled = options.eager === true || blobStore.getMeta === void 0 || headMeta !== null || metaView !== null || failed;
|
|
12333
|
+
const { ref: observeRef, inView } = useInView({
|
|
12334
|
+
disabled: options.eager === true,
|
|
12335
|
+
ready: headSettled
|
|
12336
|
+
});
|
|
12337
|
+
const inViewRef = useRef(inView);
|
|
12338
|
+
/** True once the bytes resolved: a later store change re-resolves them
|
|
12339
|
+
* only over the band (the previous view keeps standing outside it). */
|
|
12340
|
+
const loadedRef = useRef(false);
|
|
12341
|
+
const loadRef = useRef(null);
|
|
12342
|
+
const firstInViewRun = useRef(true);
|
|
12216
12343
|
useEffect(() => {
|
|
12217
12344
|
let alive = true;
|
|
12218
12345
|
let sequence = 0;
|
|
12219
12346
|
setRef(null);
|
|
12220
12347
|
setMetaView(null);
|
|
12348
|
+
setHeadMeta(null);
|
|
12221
12349
|
setFailed(false);
|
|
12222
|
-
|
|
12350
|
+
loadedRef.current = false;
|
|
12351
|
+
/** The head's resolved stand over this resolution's lifetime: the
|
|
12352
|
+
* band's entry reuses it (the store's change re-reads it fresh). */
|
|
12353
|
+
let head = null;
|
|
12354
|
+
/** The head's in-flight request: a non-fresh load joins it instead of
|
|
12355
|
+
* issuing a second lookup while one is pending. */
|
|
12356
|
+
let headRequest = null;
|
|
12357
|
+
/** The head decided the meta-only card (no bytes stand over any band). */
|
|
12358
|
+
let metaOnly = false;
|
|
12359
|
+
const load = async (freshHead) => {
|
|
12223
12360
|
const request = ++sequence;
|
|
12361
|
+
const current = () => alive && request === sequence;
|
|
12224
12362
|
try {
|
|
12225
|
-
if (
|
|
12226
|
-
|
|
12227
|
-
|
|
12363
|
+
if (getMeta !== void 0) {
|
|
12364
|
+
if (freshHead || head === null) {
|
|
12365
|
+
const pending = freshHead || headRequest === null ? getMeta(fileId) : headRequest;
|
|
12366
|
+
headRequest = pending;
|
|
12367
|
+
const meta = await pending;
|
|
12368
|
+
if (!current()) return;
|
|
12369
|
+
head = meta;
|
|
12370
|
+
setHeadMeta(meta);
|
|
12228
12371
|
const downloadUrl = blobStore.downloadUrl;
|
|
12229
12372
|
if (downloadUrl !== void 0 && rendersBytes !== void 0 && !rendersBytes(meta.mimeType)) {
|
|
12373
|
+
metaOnly = true;
|
|
12230
12374
|
setRef(null);
|
|
12231
12375
|
setMetaView({
|
|
12232
12376
|
meta,
|
|
@@ -12235,26 +12379,29 @@ function useBlobFile(fileId, rendersBytes) {
|
|
|
12235
12379
|
setFailed(false);
|
|
12236
12380
|
return;
|
|
12237
12381
|
}
|
|
12238
|
-
} else return;
|
|
12382
|
+
} else if (metaOnly) return;
|
|
12239
12383
|
}
|
|
12384
|
+
if (!inViewRef.current) return;
|
|
12240
12385
|
const next = await blobStore.get(fileId);
|
|
12241
|
-
if (
|
|
12242
|
-
|
|
12243
|
-
|
|
12244
|
-
|
|
12245
|
-
|
|
12386
|
+
if (!current()) return;
|
|
12387
|
+
loadedRef.current = true;
|
|
12388
|
+
setRef(next);
|
|
12389
|
+
setMetaView(null);
|
|
12390
|
+
setFailed(false);
|
|
12246
12391
|
} catch {
|
|
12247
|
-
if (
|
|
12248
|
-
|
|
12249
|
-
|
|
12250
|
-
|
|
12251
|
-
}
|
|
12392
|
+
if (!current()) return;
|
|
12393
|
+
setRef(null);
|
|
12394
|
+
setMetaView(null);
|
|
12395
|
+
setFailed(true);
|
|
12252
12396
|
}
|
|
12253
12397
|
};
|
|
12398
|
+
loadRef.current = () => {
|
|
12399
|
+
load(false);
|
|
12400
|
+
};
|
|
12254
12401
|
const unsubscribe = blobStore.subscribe(fileId, () => {
|
|
12255
|
-
load();
|
|
12402
|
+
load(true);
|
|
12256
12403
|
});
|
|
12257
|
-
load();
|
|
12404
|
+
load(false);
|
|
12258
12405
|
return () => {
|
|
12259
12406
|
alive = false;
|
|
12260
12407
|
unsubscribe();
|
|
@@ -12264,6 +12411,15 @@ function useBlobFile(fileId, rendersBytes) {
|
|
|
12264
12411
|
fileId,
|
|
12265
12412
|
rendersBytes
|
|
12266
12413
|
]);
|
|
12414
|
+
useEffect(() => {
|
|
12415
|
+
inViewRef.current = inView;
|
|
12416
|
+
if (firstInViewRun.current) {
|
|
12417
|
+
firstInViewRun.current = false;
|
|
12418
|
+
return;
|
|
12419
|
+
}
|
|
12420
|
+
if (!inView || loadedRef.current) return;
|
|
12421
|
+
loadRef.current?.();
|
|
12422
|
+
}, [inView]);
|
|
12267
12423
|
useEffect(() => {
|
|
12268
12424
|
if (ref === null) {
|
|
12269
12425
|
setView(null);
|
|
@@ -12277,15 +12433,30 @@ function useBlobFile(fileId, rendersBytes) {
|
|
|
12277
12433
|
return () => URL.revokeObjectURL(url);
|
|
12278
12434
|
}, [ref]);
|
|
12279
12435
|
if (view !== null) return {
|
|
12280
|
-
|
|
12281
|
-
|
|
12436
|
+
state: {
|
|
12437
|
+
status: "ready",
|
|
12438
|
+
...view
|
|
12439
|
+
},
|
|
12440
|
+
ref: observeRef
|
|
12282
12441
|
};
|
|
12283
12442
|
if (metaView !== null) return {
|
|
12284
|
-
|
|
12285
|
-
|
|
12443
|
+
state: {
|
|
12444
|
+
status: "ready-meta",
|
|
12445
|
+
...metaView
|
|
12446
|
+
},
|
|
12447
|
+
ref: observeRef
|
|
12448
|
+
};
|
|
12449
|
+
if (failed) return {
|
|
12450
|
+
state: { status: "missing" },
|
|
12451
|
+
ref: observeRef
|
|
12452
|
+
};
|
|
12453
|
+
return {
|
|
12454
|
+
state: {
|
|
12455
|
+
status: "loading",
|
|
12456
|
+
meta: headMeta
|
|
12457
|
+
},
|
|
12458
|
+
ref: observeRef
|
|
12286
12459
|
};
|
|
12287
|
-
if (failed) return { status: "missing" };
|
|
12288
|
-
return { status: "loading" };
|
|
12289
12460
|
}
|
|
12290
12461
|
//#endregion
|
|
12291
12462
|
//#region src/blocks/FileBlock.tsx
|
|
@@ -12298,16 +12469,17 @@ const FILE_RENDERS_BYTES = (mimeType) => mimeType === "application/pdf";
|
|
|
12298
12469
|
/** A consumer-owned file: the document carries only its file id. */
|
|
12299
12470
|
function FileBlock({ id, block }) {
|
|
12300
12471
|
const { t } = useTranslation("blocks");
|
|
12301
|
-
const { pdfPreview } = useEditorContext();
|
|
12472
|
+
const { pdfPreview, blobLoading } = useEditorContext();
|
|
12302
12473
|
const fileId = block.attrs.fileId;
|
|
12303
|
-
const view = useBlobFile(fileId, FILE_RENDERS_BYTES);
|
|
12474
|
+
const { state: view, ref: placeholderRef } = useBlobFile(fileId, FILE_RENDERS_BYTES, blobLoading === "eager" ? { eager: true } : {});
|
|
12304
12475
|
if (view.status === "loading" || view.status === "missing") return /* @__PURE__ */ jsx(Card, {
|
|
12476
|
+
ref: placeholderRef,
|
|
12305
12477
|
"data-slot": "docblocks/file-placeholder",
|
|
12306
12478
|
"data-block-type": "file",
|
|
12307
12479
|
"data-block-id": id,
|
|
12308
12480
|
"data-state": view.status,
|
|
12309
12481
|
"aria-busy": view.status === "loading",
|
|
12310
|
-
className: BLOB_PLACEHOLDER_CLASS
|
|
12482
|
+
className: `${BLOB_PLACEHOLDER_CLASS} ${BLOB_PLACEHOLDER_SPACING}`,
|
|
12311
12483
|
children: /* @__PURE__ */ jsxs(CardContent, {
|
|
12312
12484
|
className: "flex flex-col items-center gap-2 text-center",
|
|
12313
12485
|
children: [view.status === "loading" ? /* @__PURE__ */ jsx(LoaderCircle, { className: "size-6 animate-spin" }) : /* @__PURE__ */ jsx(File, { className: "size-6" }), t("file.placeholder")]
|
|
@@ -13218,7 +13390,7 @@ function isCanvasSubType(type) {
|
|
|
13218
13390
|
* `edgePointOf` lookups from a live reference.
|
|
13219
13391
|
*/
|
|
13220
13392
|
function isKnownPort(value) {
|
|
13221
|
-
return typeof value === "string" && value
|
|
13393
|
+
return typeof value === "string" && Object.hasOwn(PORT_NORMAL, value);
|
|
13222
13394
|
}
|
|
13223
13395
|
/**
|
|
13224
13396
|
* The positioned wrapper style of a canvas element.
|
|
@@ -16379,6 +16551,32 @@ function lineAnchorOf(root) {
|
|
|
16379
16551
|
* too: it carries no logical character.
|
|
16380
16552
|
*/
|
|
16381
16553
|
/**
|
|
16554
|
+
* The caret's seat at a mention chip's boundary over the ADJACENT editable
|
|
16555
|
+
* text: a text node's boundary where one stands on that side and reads
|
|
16556
|
+
* back at the same flat offset. The island's element slot (the chip's
|
|
16557
|
+
* parent) is the seat of last resort: the WebKit family handles a caret
|
|
16558
|
+
* next to a contenteditable=false inline island poorly (the seat collapses
|
|
16559
|
+
* toward the block's end), while a text node's boundary is every engine's
|
|
16560
|
+
* native path. A text that does not read back at the boundary (another
|
|
16561
|
+
* island stands in between) is not adjacent — the element slot stands then.
|
|
16562
|
+
*/
|
|
16563
|
+
function chipTextSeat(root, chipText, after, boundary) {
|
|
16564
|
+
const walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
|
|
16565
|
+
walker.currentNode = chipText;
|
|
16566
|
+
for (let node = after ? walker.nextNode() : walker.previousNode(); node !== null;) {
|
|
16567
|
+
if (node instanceof Text && !isLineAnchor$1(node) && mentionChipOf(node) === null) {
|
|
16568
|
+
const seat = {
|
|
16569
|
+
node,
|
|
16570
|
+
offset: after ? 0 : node.nodeValue?.length ?? 0
|
|
16571
|
+
};
|
|
16572
|
+
if (caretOffsetIn(root, seat.node, seat.offset) === boundary) return seat;
|
|
16573
|
+
return null;
|
|
16574
|
+
}
|
|
16575
|
+
node = after ? walker.nextNode() : walker.previousNode();
|
|
16576
|
+
}
|
|
16577
|
+
return null;
|
|
16578
|
+
}
|
|
16579
|
+
/**
|
|
16382
16580
|
* The flat character offset of a DOM position (node + offset) inside the
|
|
16383
16581
|
* block root. The node may be a text node (offset in characters) or an
|
|
16384
16582
|
* element (offset in child slots). A caret on the line anchor (the final
|
|
@@ -16457,7 +16655,11 @@ function locatePosition(root, flatOffset) {
|
|
|
16457
16655
|
const length = current.nodeValue?.length ?? 0;
|
|
16458
16656
|
const chip = mentionChipOf(current);
|
|
16459
16657
|
if (chip !== null) {
|
|
16460
|
-
if (flatOffset <= total + length)
|
|
16658
|
+
if (flatOffset <= total + length) {
|
|
16659
|
+
const after = flatOffset - total > length / 2 || flatOffset === total + length;
|
|
16660
|
+
const past = after && flatOffset > total;
|
|
16661
|
+
return chipTextSeat(root, current, after, past ? total + length : total) ?? chipSlot(chip, past);
|
|
16662
|
+
}
|
|
16461
16663
|
total += length;
|
|
16462
16664
|
return null;
|
|
16463
16665
|
}
|
|
@@ -17608,7 +17810,9 @@ function mentionMarkOf(chip) {
|
|
|
17608
17810
|
}
|
|
17609
17811
|
/** The editor root's mention card layer (the provider's `mentionInteractions`'
|
|
17610
17812
|
* stand; the null's stand renders nothing). The returned node is the
|
|
17611
|
-
* portaled host (or null) — the caller renders it over the root.
|
|
17813
|
+
* portaled host (or null) — the caller renders it over the root. `close`
|
|
17814
|
+
* drops a standing card (and its pending open) — the caller's view
|
|
17815
|
+
* switch's stand. */
|
|
17612
17816
|
function useMentionCard(rootRef) {
|
|
17613
17817
|
const { mentionInteractions } = useEditorContext();
|
|
17614
17818
|
const [open, setOpen] = useState(null);
|
|
@@ -17627,6 +17831,10 @@ function useMentionCard(rootRef) {
|
|
|
17627
17831
|
closeTimerRef.current = null;
|
|
17628
17832
|
}
|
|
17629
17833
|
};
|
|
17834
|
+
const close = useCallback(() => {
|
|
17835
|
+
cancelTimers();
|
|
17836
|
+
setOpen(null);
|
|
17837
|
+
}, []);
|
|
17630
17838
|
useEffect(() => {
|
|
17631
17839
|
if (mentionInteractions === null) return;
|
|
17632
17840
|
const interactions = mentionInteractions;
|
|
@@ -17756,23 +17964,29 @@ function useMentionCard(rootRef) {
|
|
|
17756
17964
|
}, [open]);
|
|
17757
17965
|
let content = null;
|
|
17758
17966
|
if (open !== null && mentionInteractions !== null) content = mentionInteractions.renderCard(open.mention);
|
|
17759
|
-
if (open === null || mentionInteractions === null || content === null) return
|
|
17760
|
-
|
|
17761
|
-
|
|
17762
|
-
|
|
17763
|
-
|
|
17764
|
-
"
|
|
17765
|
-
|
|
17766
|
-
|
|
17767
|
-
|
|
17768
|
-
|
|
17769
|
-
|
|
17770
|
-
|
|
17771
|
-
|
|
17772
|
-
|
|
17773
|
-
|
|
17774
|
-
|
|
17775
|
-
|
|
17967
|
+
if (open === null || mentionInteractions === null || content === null) return {
|
|
17968
|
+
node: null,
|
|
17969
|
+
close
|
|
17970
|
+
};
|
|
17971
|
+
return {
|
|
17972
|
+
node: createPortal(/* @__PURE__ */ jsx("div", {
|
|
17973
|
+
ref: hostRef,
|
|
17974
|
+
"data-slot": "docblocks/mention-card",
|
|
17975
|
+
"data-mention-kind": open.mention.kind,
|
|
17976
|
+
"data-mention-id": open.mention.id,
|
|
17977
|
+
"aria-hidden": true,
|
|
17978
|
+
className: "z-modal",
|
|
17979
|
+
style: {
|
|
17980
|
+
position: "fixed",
|
|
17981
|
+
left: open.left,
|
|
17982
|
+
top: open.top,
|
|
17983
|
+
width: "fit-content",
|
|
17984
|
+
visibility: open.placed ? "visible" : "hidden"
|
|
17985
|
+
},
|
|
17986
|
+
children: content
|
|
17987
|
+
}), document.body),
|
|
17988
|
+
close
|
|
17989
|
+
};
|
|
17776
17990
|
}
|
|
17777
17991
|
//#endregion
|
|
17778
17992
|
//#region src/editing/phrase/phrase.ts
|
|
@@ -18245,7 +18459,8 @@ function useMentionMenu(rootRef) {
|
|
|
18245
18459
|
onHover: hoverItem,
|
|
18246
18460
|
onPick: pick,
|
|
18247
18461
|
onClose: close
|
|
18248
|
-
}) : null
|
|
18462
|
+
}) : null,
|
|
18463
|
+
close
|
|
18249
18464
|
};
|
|
18250
18465
|
}
|
|
18251
18466
|
//#endregion
|
|
@@ -19066,10 +19281,11 @@ function sameAttrs(block, command) {
|
|
|
19066
19281
|
* its whole text. The replace path needs both an empty result and a type
|
|
19067
19282
|
* change — and a block that owns a derived segment cannot be removed (the
|
|
19068
19283
|
* removal cascades its followers), so it converts in place instead. The
|
|
19069
|
-
* divider over a phrase-only block
|
|
19070
|
-
*
|
|
19071
|
-
*
|
|
19072
|
-
*
|
|
19284
|
+
* divider over a phrase-only block without followers takes the replace
|
|
19285
|
+
* path (a contentless insert loses nothing); over any block whose text
|
|
19286
|
+
* survives the strip it is an insert after the block instead — the
|
|
19287
|
+
* divider cannot take the block's text (the core rejects the type change),
|
|
19288
|
+
* nor replace a segment-owning block (the removal cascades).
|
|
19073
19289
|
*/
|
|
19074
19290
|
function planSlashApply(command, block, text, slashOffset, hasFollowers) {
|
|
19075
19291
|
if (sameAttrs(block, command)) return { kind: "noop" };
|
|
@@ -19080,7 +19296,11 @@ function planSlashApply(command, block, text, slashOffset, hasFollowers) {
|
|
|
19080
19296
|
deleteTo: queryEnd
|
|
19081
19297
|
};
|
|
19082
19298
|
if (text.slice(0, slashOffset) + text.slice(queryEnd) === "" && !hasFollowers && command.type !== block.type) return { kind: "replace" };
|
|
19083
|
-
if (command.type === "divider") return {
|
|
19299
|
+
if (command.type === "divider") return {
|
|
19300
|
+
kind: "update",
|
|
19301
|
+
deleteFrom: slashOffset,
|
|
19302
|
+
deleteTo: queryEnd
|
|
19303
|
+
};
|
|
19084
19304
|
if (command.type === block.type) return {
|
|
19085
19305
|
kind: "update",
|
|
19086
19306
|
deleteFrom: slashOffset,
|
|
@@ -19205,6 +19425,10 @@ function applySlashPlan(doc, plan, command, blockId, parentId, indent, scope) {
|
|
|
19205
19425
|
parent: parentId,
|
|
19206
19426
|
after: blockId
|
|
19207
19427
|
}, indent);
|
|
19428
|
+
else if (command.type === "divider") insertCommand(doc, command, {
|
|
19429
|
+
parent: parentId,
|
|
19430
|
+
after: blockId
|
|
19431
|
+
}, indent);
|
|
19208
19432
|
});
|
|
19209
19433
|
} catch (error) {
|
|
19210
19434
|
if (error instanceof InvalidAttrsError || error instanceof InvalidOperationError) return;
|
|
@@ -19976,7 +20200,8 @@ function useSlashMenu(rootRef) {
|
|
|
19976
20200
|
embedForm,
|
|
19977
20201
|
cancelEmbedForm,
|
|
19978
20202
|
commitEmbed
|
|
19979
|
-
})
|
|
20203
|
+
}),
|
|
20204
|
+
close
|
|
19980
20205
|
};
|
|
19981
20206
|
}
|
|
19982
20207
|
//#endregion
|
|
@@ -22722,6 +22947,7 @@ function loadGrammar(grammar) {
|
|
|
22722
22947
|
/** The highlight grammar id of a block language, or null (plain text). */
|
|
22723
22948
|
function grammarOf(language) {
|
|
22724
22949
|
if (language === void 0 || language === "") return null;
|
|
22950
|
+
if (!Object.hasOwn(HIGHLIGHT_GRAMMARS, language)) return null;
|
|
22725
22951
|
return HIGHLIGHT_GRAMMARS[language] ?? null;
|
|
22726
22952
|
}
|
|
22727
22953
|
/** Whether the language carries a highlight (the curated set). */
|
|
@@ -23829,6 +24055,10 @@ function useLinkPopover(rootRef) {
|
|
|
23829
24055
|
suppressTransientSelection();
|
|
23830
24056
|
parkFocusRef.current = true;
|
|
23831
24057
|
}, [rootRef, selectionRef]);
|
|
24058
|
+
const dismiss = useCallback(() => {
|
|
24059
|
+
setPopover(null);
|
|
24060
|
+
setMenu(null);
|
|
24061
|
+
}, []);
|
|
23832
24062
|
useEffect(() => {
|
|
23833
24063
|
if (!parkFocusRef.current) return;
|
|
23834
24064
|
parkFocusRef.current = false;
|
|
@@ -23992,7 +24222,8 @@ function useLinkPopover(rootRef) {
|
|
|
23992
24222
|
rootRef,
|
|
23993
24223
|
state: popover,
|
|
23994
24224
|
onClose: closeAll
|
|
23995
|
-
})] })
|
|
24225
|
+
})] }),
|
|
24226
|
+
close: dismiss
|
|
23996
24227
|
};
|
|
23997
24228
|
}
|
|
23998
24229
|
//#endregion
|
|
@@ -24439,7 +24670,7 @@ const CALLOUT_PRESET_ICONS = {
|
|
|
24439
24670
|
* falls back to the preset rather than rendering nothing).
|
|
24440
24671
|
*/
|
|
24441
24672
|
function calloutIconName(icon, variant) {
|
|
24442
|
-
if (typeof icon === "string" && icon
|
|
24673
|
+
if (typeof icon === "string" && Object.hasOwn(CALLOUT_ICON_COMPONENTS, icon)) return icon;
|
|
24443
24674
|
return CALLOUT_PRESET_ICONS[variant ?? "info"];
|
|
24444
24675
|
}
|
|
24445
24676
|
//#endregion
|
|
@@ -27938,6 +28169,7 @@ const CanvasItem = memo(function CanvasItem({ id, pendingConnector = null, inter
|
|
|
27938
28169
|
const parts = ["translate(-50%, -50%)"];
|
|
27939
28170
|
if (moveActive) parts.push(`translate(${movePreview.dx}px, ${movePreview.dy}px)`);
|
|
27940
28171
|
style.transform = parts.join(" ");
|
|
28172
|
+
style.willChange = "transform";
|
|
27941
28173
|
}
|
|
27942
28174
|
if (block.type === "canvas-text") {
|
|
27943
28175
|
const attrs = block.attrs;
|
|
@@ -28234,10 +28466,10 @@ function FrameWindowContent({ surfaceId, offset, excludedIds = EMPTY_IDS$1, clas
|
|
|
28234
28466
|
* 1:1 (no fit/zoom controls — the v1 boundary). The canvas frame stands the
|
|
28235
28467
|
* boundary only (a region marker) — this page block is the sole renderer
|
|
28236
28468
|
* of the frame's content. The box's height is the
|
|
28237
|
-
* referenced frame's 1:1;
|
|
28238
|
-
* row's
|
|
28239
|
-
*
|
|
28240
|
-
*
|
|
28469
|
+
* referenced frame's 1:1; a frame wider than the row is drawn uniformly
|
|
28470
|
+
* downscaled to the row's width (the WHOLE frame area stands — a clipped
|
|
28471
|
+
* window would hide the frame's edges), the 1:1 stand otherwise. The
|
|
28472
|
+
* reference is a weak
|
|
28241
28473
|
* one: the absent / gone / surface-less reference stands the lenient
|
|
28242
28474
|
* placeholder (the dangling stand — the render never throws). The
|
|
28243
28475
|
* window's content is inert (the copies' pointer-transparent stand — the
|
|
@@ -28311,21 +28543,16 @@ function FramePageWindow({ id, frameId, surfaceId, referenced }) {
|
|
|
28311
28543
|
return () => observer.disconnect();
|
|
28312
28544
|
}, []);
|
|
28313
28545
|
const box = effectiveGeometry(referenced);
|
|
28314
|
-
const
|
|
28315
|
-
const
|
|
28546
|
+
const scale = rowWidth > 0 && box.w > rowWidth ? rowWidth / box.w : 1;
|
|
28547
|
+
const winW = box.w * scale;
|
|
28548
|
+
const winH = box.h * scale;
|
|
28316
28549
|
const offset = frameWindowOffset({
|
|
28317
28550
|
x: box.x,
|
|
28318
28551
|
y: box.y,
|
|
28319
|
-
w:
|
|
28320
|
-
h:
|
|
28552
|
+
w: box.w,
|
|
28553
|
+
h: box.h
|
|
28321
28554
|
});
|
|
28322
|
-
const
|
|
28323
|
-
backgroundColor: "var(--docblocks-canvas-background)",
|
|
28324
|
-
...frameDotBackground(box.x - boxW / 2, box.y - boxH / 2),
|
|
28325
|
-
boxShadow: "inset 0 0 0 1px var(--docblocks-canvas-group-border-color)",
|
|
28326
|
-
width: boxW,
|
|
28327
|
-
height: boxH
|
|
28328
|
-
};
|
|
28555
|
+
const dotStyle = frameDotBackground(box.x - box.w / 2, box.y - box.h / 2);
|
|
28329
28556
|
const title = referenced.attrs?.title ?? "";
|
|
28330
28557
|
const excludedIds = useMemo(() => [frameId], [frameId]);
|
|
28331
28558
|
return /* @__PURE__ */ jsx("div", {
|
|
@@ -28342,11 +28569,25 @@ function FramePageWindow({ id, frameId, surfaceId, referenced }) {
|
|
|
28342
28569
|
role: "img",
|
|
28343
28570
|
"aria-label": title !== "" ? t("page.windowTitle", { title }) : t("page.windowLabel"),
|
|
28344
28571
|
className: "relative mx-auto overflow-hidden rounded-(--docblocks-radius)",
|
|
28345
|
-
style:
|
|
28346
|
-
|
|
28347
|
-
|
|
28348
|
-
|
|
28349
|
-
|
|
28572
|
+
style: {
|
|
28573
|
+
width: winW,
|
|
28574
|
+
height: winH,
|
|
28575
|
+
boxShadow: "inset 0 0 0 1px var(--docblocks-canvas-group-border-color)"
|
|
28576
|
+
},
|
|
28577
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
28578
|
+
className: "absolute top-0 left-0 origin-top-left",
|
|
28579
|
+
style: {
|
|
28580
|
+
width: box.w,
|
|
28581
|
+
height: box.h,
|
|
28582
|
+
backgroundColor: "var(--docblocks-canvas-background)",
|
|
28583
|
+
...dotStyle,
|
|
28584
|
+
transform: scale === 1 ? void 0 : `scale(${scale})`
|
|
28585
|
+
},
|
|
28586
|
+
children: /* @__PURE__ */ jsx(FrameWindowContent, {
|
|
28587
|
+
surfaceId,
|
|
28588
|
+
offset,
|
|
28589
|
+
excludedIds
|
|
28590
|
+
})
|
|
28350
28591
|
})
|
|
28351
28592
|
})
|
|
28352
28593
|
});
|
|
@@ -28597,7 +28838,7 @@ function useImageResize({ id, block, figureRef, imgRef }) {
|
|
|
28597
28838
|
* keeps the aspect ratio (the width only) and the editor's content width
|
|
28598
28839
|
* is the upper bound (the figure never stretches past the editor).
|
|
28599
28840
|
*/
|
|
28600
|
-
function ImageFigure({ id, block, url, name }) {
|
|
28841
|
+
function ImageFigure({ id, block, url, name, width, height }) {
|
|
28601
28842
|
const { t } = useTranslation("blocks");
|
|
28602
28843
|
const { doc, store, selection: selectionRef } = useEditorContext();
|
|
28603
28844
|
const blockContext = useContext(BlockContext);
|
|
@@ -28677,6 +28918,10 @@ function ImageFigure({ id, block, url, name }) {
|
|
|
28677
28918
|
"data-subtype": "image",
|
|
28678
28919
|
src: url,
|
|
28679
28920
|
alt: "",
|
|
28921
|
+
width,
|
|
28922
|
+
height,
|
|
28923
|
+
loading: "lazy",
|
|
28924
|
+
decoding: "async",
|
|
28680
28925
|
draggable: false,
|
|
28681
28926
|
className: "block h-auto max-w-full rounded-(--docblocks-image-radius)",
|
|
28682
28927
|
style: { width: widthValue }
|
|
@@ -28735,16 +28980,18 @@ const IMAGE_RENDERS_BYTES = (mimeType) => mimeType.startsWith("image/") || mimeT
|
|
|
28735
28980
|
*/
|
|
28736
28981
|
function ImageBlock({ id, block }) {
|
|
28737
28982
|
const { t } = useTranslation("blocks");
|
|
28738
|
-
const { pdfPreview } = useEditorContext();
|
|
28983
|
+
const { pdfPreview, blobLoading } = useEditorContext();
|
|
28739
28984
|
const src = block.attrs.src;
|
|
28740
|
-
const file = useBlobFile(src, IMAGE_RENDERS_BYTES);
|
|
28985
|
+
const { state: file, ref: placeholderRef } = useBlobFile(src, IMAGE_RENDERS_BYTES, blobLoading === "eager" ? { eager: true } : {});
|
|
28741
28986
|
if (file.status === "loading" || file.status === "missing") return /* @__PURE__ */ jsx(Card, {
|
|
28987
|
+
ref: placeholderRef,
|
|
28742
28988
|
"data-slot": "docblocks/image-placeholder",
|
|
28743
28989
|
"data-block-type": "image",
|
|
28744
28990
|
"data-block-id": id,
|
|
28745
28991
|
"data-state": file.status,
|
|
28746
28992
|
"aria-busy": file.status === "loading",
|
|
28747
28993
|
className: BLOB_PLACEHOLDER_CLASS,
|
|
28994
|
+
style: file.status === "loading" ? blobPlaceholderAspect(file.meta) : void 0,
|
|
28748
28995
|
children: /* @__PURE__ */ jsxs(CardContent, {
|
|
28749
28996
|
className: "flex flex-col items-center gap-2 text-center",
|
|
28750
28997
|
children: [file.status === "loading" ? /* @__PURE__ */ jsx(LoaderCircle, { className: "size-6 animate-spin" }) : /* @__PURE__ */ jsx(Image$1, { className: "size-6" }), t("image.placeholder")]
|
|
@@ -28798,7 +29045,9 @@ function ImageBlock({ id, block }) {
|
|
|
28798
29045
|
id,
|
|
28799
29046
|
block,
|
|
28800
29047
|
url,
|
|
28801
|
-
name
|
|
29048
|
+
name,
|
|
29049
|
+
width: meta.width,
|
|
29050
|
+
height: meta.height
|
|
28802
29051
|
});
|
|
28803
29052
|
}
|
|
28804
29053
|
/**
|
|
@@ -28890,10 +29139,14 @@ function SyncEmbedBlock({ id, block }) {
|
|
|
28890
29139
|
* plain payload's markdown pipeline's distortion's guard — the newlines,
|
|
28891
29140
|
* the indentation, and the markdown-flavored lines stand verbatim).
|
|
28892
29141
|
*/
|
|
28893
|
-
/** The
|
|
28894
|
-
*
|
|
29142
|
+
/** The clipboard HTML's escape (the `&` / `<` / `>` / `"`'s escape over
|
|
29143
|
+
* the serialized html). The `"` closes the attribute context: the
|
|
29144
|
+
* `language` (a free data string) sits in the `class` attribute, so a
|
|
29145
|
+
* value written over the CRDT's raw (no command's validation) must not be
|
|
29146
|
+
* able to open a new attribute there — the escape stands the third-party
|
|
29147
|
+
* paste target (the local paste re-parses through the whitelist). */
|
|
28895
29148
|
function escapeHtml$1(text) {
|
|
28896
|
-
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
29149
|
+
return text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
28897
29150
|
}
|
|
28898
29151
|
/** The code block's `text/html` payload: the `PRE`'s stand (the rich
|
|
28899
29152
|
* pipeline's block) over the escaped's text, the language's class over
|
|
@@ -28915,6 +29168,8 @@ function codeBlockHtmlOf(text, language) {
|
|
|
28915
29168
|
* a toggle is an `updateBlock`, the menu's open's keep over the toggle's
|
|
28916
29169
|
* press).
|
|
28917
29170
|
*/
|
|
29171
|
+
/** The copy feedback's indicator reset (the circle-check's display window). */
|
|
29172
|
+
const COPY_RESET_MS = 1500;
|
|
28918
29173
|
function CodeHeaderActions({ id, block, open, onOpenChange }) {
|
|
28919
29174
|
const { t } = useTranslation("blocks");
|
|
28920
29175
|
const { doc, store, viewMode } = useEditorContext();
|
|
@@ -28941,7 +29196,7 @@ function CodeHeaderActions({ id, block, open, onOpenChange }) {
|
|
|
28941
29196
|
else await navigator.clipboard.writeText(text);
|
|
28942
29197
|
setCopied(true);
|
|
28943
29198
|
if (copyTimer.current !== null) window.clearTimeout(copyTimer.current);
|
|
28944
|
-
copyTimer.current = window.setTimeout(() => setCopied(false),
|
|
29199
|
+
copyTimer.current = window.setTimeout(() => setCopied(false), COPY_RESET_MS);
|
|
28945
29200
|
} catch {}
|
|
28946
29201
|
})();
|
|
28947
29202
|
};
|
|
@@ -32402,6 +32657,7 @@ function pageCardDisplayStyleOf(root, handleTarget, rootBlockId, viewport) {
|
|
|
32402
32657
|
const parts = ["translate(-50%, -50%)"];
|
|
32403
32658
|
if (isMoving) parts.push(`translate(${viewport.movePreview.dx}px, ${viewport.movePreview.dy}px)`);
|
|
32404
32659
|
style.transform = parts.join(" ");
|
|
32660
|
+
style.willChange = "transform";
|
|
32405
32661
|
return style;
|
|
32406
32662
|
}
|
|
32407
32663
|
//#endregion
|
|
@@ -33439,6 +33695,8 @@ function toolPress(ctx, event, point) {
|
|
|
33439
33695
|
/** The connector tool's press: a press on an item stands the block stand (the two-click's first pick; the press-drag's press on a block), a press off the items stands the FREE stand (the empty-canvas press — the press point is the first endpoint, the release commits). A press with a stand already standing cancels (the second stand commits on the release / the second click). The press's edge snap stands the pressed point — the port ref at the port's stick disk, the free point over the continuous edge (the frozen direction = the snapped side), the plain block ref over the interior (the auto anchor). */
|
|
33440
33696
|
function connectorToolPress(ctx, event, point) {
|
|
33441
33697
|
if (ctx.viewport.activeTool !== "connector") return false;
|
|
33698
|
+
ctx.cardPressRef.current = true;
|
|
33699
|
+
ctx.containerRef.current?.focus();
|
|
33442
33700
|
const id = ctx.standItemAt(event.target)?.getAttribute("data-block-id") ?? null;
|
|
33443
33701
|
const hasStand = ctx.viewport.pendingConnector !== null || ctx.viewport.pendingFree !== null;
|
|
33444
33702
|
const canvasPoint = screenToCanvas(point, ctx.viewport.zoom, ctx.viewport.pan);
|
|
@@ -34216,6 +34474,7 @@ function createEditorStore(doc, rootId) {
|
|
|
34216
34474
|
let blocks = state.blocks;
|
|
34217
34475
|
let blocksChanged = false;
|
|
34218
34476
|
const removed = /* @__PURE__ */ new Set();
|
|
34477
|
+
const rootChildIds = new Set(state.rootChildren);
|
|
34219
34478
|
for (const id of new Set(change.blockIds)) {
|
|
34220
34479
|
const fresh = doc.getBlock(id);
|
|
34221
34480
|
const prev = blocks[id];
|
|
@@ -34242,7 +34501,7 @@ function createEditorStore(doc, rootId) {
|
|
|
34242
34501
|
if (!deepEqual(prevRest, freshRest)) chromeChanged = true;
|
|
34243
34502
|
}
|
|
34244
34503
|
}
|
|
34245
|
-
if (prev !== void 0 && fresh !== null &&
|
|
34504
|
+
if (prev !== void 0 && fresh !== null && rootChildIds.has(id)) {
|
|
34246
34505
|
const prevAttrs = "attrs" in prev ? prev.attrs : void 0;
|
|
34247
34506
|
const freshAttrs = "attrs" in fresh ? fresh.attrs : void 0;
|
|
34248
34507
|
if (prev.type !== fresh.type || prevAttrs?.indent !== freshAttrs?.indent || prevAttrs?.list !== freshAttrs?.list) seqStructureAffected = true;
|
|
@@ -34820,7 +35079,7 @@ function publishedStandKey(doc) {
|
|
|
34820
35079
|
* its own. Safe under StrictMode double-mount: the cleanup detaches every
|
|
34821
35080
|
* subscription and destroys the view between the two mounts.
|
|
34822
35081
|
*/
|
|
34823
|
-
function EditorProviderStand({ doc, provider, blockRenderers, blobStore, databaseBridge, syncEmbedResolver, pdfPreview, mentionProvider, mentionInteractions, embedSandbox, rootBlockId, commandPalettePlaceholder, accessLevel, mode, publishedDoc, presence, hiddenAttributes, renderAttribute, attributeTypePicker, docTags, docDescription, coverPresets, children }) {
|
|
35082
|
+
function EditorProviderStand({ doc, provider, blockRenderers, blobStore, blobLoading, databaseBridge, syncEmbedResolver, pdfPreview, mentionProvider, mentionInteractions, embedSandbox, rootBlockId, commandPalettePlaceholder, accessLevel, mode, publishedDoc, presence, hiddenAttributes, renderAttribute, attributeTypePicker, docTags, docDescription, coverPresets, children }) {
|
|
34824
35083
|
const rootId = rootBlockId ?? doc.meta.id;
|
|
34825
35084
|
const [store] = useState(() => createEditorStore(doc, rootId));
|
|
34826
35085
|
const docRef = useRef(doc);
|
|
@@ -34855,6 +35114,7 @@ function EditorProviderStand({ doc, provider, blockRenderers, blobStore, databas
|
|
|
34855
35114
|
usePresenceReceive(provider, store, presence);
|
|
34856
35115
|
usePresencePublish(provider, store, presence, effectiveMode !== "edit");
|
|
34857
35116
|
const effectiveBlobStore = useMemo(() => blobStore ?? parentContext?.blobStore ?? getDefaultBlobStore(), [blobStore, parentContext]);
|
|
35117
|
+
const effectiveBlobLoading = blobLoading ?? parentContext?.blobLoading ?? "lazy";
|
|
34858
35118
|
const effectiveDatabaseBridge = useMemo(() => databaseBridge ?? parentContext?.databaseBridge, [databaseBridge, parentContext]);
|
|
34859
35119
|
const value = useMemo(() => {
|
|
34860
35120
|
const parent = parentContext;
|
|
@@ -34864,6 +35124,7 @@ function EditorProviderStand({ doc, provider, blockRenderers, blobStore, databas
|
|
|
34864
35124
|
selection: selectionRef.current,
|
|
34865
35125
|
renderers: blockRenderers ?? parent?.renderers ?? {},
|
|
34866
35126
|
blobStore: effectiveBlobStore,
|
|
35127
|
+
blobLoading: effectiveBlobLoading,
|
|
34867
35128
|
databaseBridge: effectiveDatabaseBridge,
|
|
34868
35129
|
syncEmbedResolver: syncEmbedResolver ?? parent?.syncEmbedResolver ?? null,
|
|
34869
35130
|
pdfPreview: pdfPreview ?? parent?.pdfPreview ?? null,
|
|
@@ -34890,6 +35151,7 @@ function EditorProviderStand({ doc, provider, blockRenderers, blobStore, databas
|
|
|
34890
35151
|
doc,
|
|
34891
35152
|
blockRenderers,
|
|
34892
35153
|
effectiveBlobStore,
|
|
35154
|
+
effectiveBlobLoading,
|
|
34893
35155
|
effectiveDatabaseBridge,
|
|
34894
35156
|
syncEmbedResolver,
|
|
34895
35157
|
rootId,
|
|
@@ -35983,7 +36245,7 @@ function editorWidthOf(anchor) {
|
|
|
35983
36245
|
* caller's mode (the upload's no stand — the consumer's catalog's curation
|
|
35984
36246
|
* is the gate's stand over the presets). */
|
|
35985
36247
|
function CoverPresetCell({ fileId, label, busy, onPick }) {
|
|
35986
|
-
const file = useBlobFile(fileId, COVER_RENDERS_BYTES);
|
|
36248
|
+
const { state: file } = useBlobFile(fileId, COVER_RENDERS_BYTES, { eager: true });
|
|
35987
36249
|
return /* @__PURE__ */ jsx("button", {
|
|
35988
36250
|
type: "button",
|
|
35989
36251
|
"data-slot": "docblocks/cover-preset",
|
|
@@ -36239,7 +36501,7 @@ function CoverUploadModal({ anchorRef, initialMode, onCommit, onClose }) {
|
|
|
36239
36501
|
* selector + the drop zone + the gate's stands live over it). */
|
|
36240
36502
|
function CoverEditor({ fileId, mode, readOnly, onCommit, onClear }) {
|
|
36241
36503
|
const { t } = useTranslation("editor");
|
|
36242
|
-
const file = useBlobFile(fileId ?? "", COVER_RENDERS_BYTES);
|
|
36504
|
+
const { state: file } = useBlobFile(fileId ?? "", COVER_RENDERS_BYTES, { eager: true });
|
|
36243
36505
|
const [open, setOpen] = useState(false);
|
|
36244
36506
|
const anchorRef = useRef(null);
|
|
36245
36507
|
return /* @__PURE__ */ jsxs("div", {
|
|
@@ -36302,7 +36564,7 @@ function CoverEditor({ fileId, mode, readOnly, onCommit, onClear }) {
|
|
|
36302
36564
|
const EDITOR_SELECTOR = "[data-slot=\"docblocks/editor\"]";
|
|
36303
36565
|
function CoverModeSelector({ coverId, mode, readOnly, onChange }) {
|
|
36304
36566
|
const { t } = useTranslation("editor");
|
|
36305
|
-
const file = useBlobFile(coverId, COVER_RENDERS_BYTES);
|
|
36567
|
+
const { state: file } = useBlobFile(coverId, COVER_RENDERS_BYTES, { eager: true });
|
|
36306
36568
|
const blob = file.status === "ready" ? file.blob : null;
|
|
36307
36569
|
/** The intrinsic dimensions' probe (the gate's input — the undecodable's
|
|
36308
36570
|
* payload keeps the gate's fail-open stand). */
|
|
@@ -36796,7 +37058,7 @@ function CoverBanner() {
|
|
|
36796
37058
|
/** The banner's body (the hooks' stand — the mount only over the cover's
|
|
36797
37059
|
* presence, so the resolution's hook never sees the empty's id). */
|
|
36798
37060
|
function CoverBannerBody({ coverId, mode }) {
|
|
36799
|
-
const file = useBlobFile(coverId, COVER_RENDERS_BYTES);
|
|
37061
|
+
const { state: file } = useBlobFile(coverId, COVER_RENDERS_BYTES, { eager: true });
|
|
36800
37062
|
const blob = file.status === "ready" ? file.blob : null;
|
|
36801
37063
|
/** The intrinsic dimensions' probe (the centering's slice's input — the
|
|
36802
37064
|
* width's scale over the container; the undecodable's payload stands
|
|
@@ -38330,6 +38592,8 @@ function useEnterAnimationGate(rootRef) {
|
|
|
38330
38592
|
}
|
|
38331
38593
|
//#endregion
|
|
38332
38594
|
//#region src/motion/drag-seat.ts
|
|
38595
|
+
/** The release's click guard's window (the moved drag's browser click's lifetime). */
|
|
38596
|
+
const RELEASE_CLICK_GUARD_MS = 2e3;
|
|
38333
38597
|
/** The user's text seat over the drag start (the release's restore input). */
|
|
38334
38598
|
function capturePreDragSeat() {
|
|
38335
38599
|
const selection = window.getSelection();
|
|
@@ -38375,7 +38639,7 @@ function installReleaseClickGuard(moved) {
|
|
|
38375
38639
|
capture: true,
|
|
38376
38640
|
once: true
|
|
38377
38641
|
});
|
|
38378
|
-
window.setTimeout(() => window.removeEventListener("click", suppress, true),
|
|
38642
|
+
window.setTimeout(() => window.removeEventListener("click", suppress, true), RELEASE_CLICK_GUARD_MS);
|
|
38379
38643
|
}
|
|
38380
38644
|
/**
|
|
38381
38645
|
* The seat's restore over the release: the focus stands over the
|
|
@@ -38859,6 +39123,28 @@ function Editor({ view = "page", formatPalette = FORMAT_PALETTE }) {
|
|
|
38859
39123
|
const mention = useMentionMenu(rootRef);
|
|
38860
39124
|
const mentionCard = useMentionCard(rootRef);
|
|
38861
39125
|
const format = useFormatToolbar(rootRef, formatPalette);
|
|
39126
|
+
const pageView = view === "page";
|
|
39127
|
+
const previousViewRef = useRef(view);
|
|
39128
|
+
const closeSlash = slash.close;
|
|
39129
|
+
const closeMention = mention.close;
|
|
39130
|
+
const closeMentionCard = mentionCard.close;
|
|
39131
|
+
const closeLink = linkPopover.close;
|
|
39132
|
+
useEffect(() => {
|
|
39133
|
+
const previous = previousViewRef.current;
|
|
39134
|
+
previousViewRef.current = view;
|
|
39135
|
+
if (previous !== "page" || pageView) return;
|
|
39136
|
+
closeSlash();
|
|
39137
|
+
closeMention();
|
|
39138
|
+
closeMentionCard();
|
|
39139
|
+
closeLink();
|
|
39140
|
+
}, [
|
|
39141
|
+
view,
|
|
39142
|
+
pageView,
|
|
39143
|
+
closeSlash,
|
|
39144
|
+
closeMention,
|
|
39145
|
+
closeMentionCard,
|
|
39146
|
+
closeLink
|
|
39147
|
+
]);
|
|
38862
39148
|
useTypingFlag(rootRef);
|
|
38863
39149
|
const enterGate = useEnterAnimationGate(rootRef);
|
|
38864
39150
|
const { order, draggingKey, previewIndent, layoutSlide, onRowDragStart, onRowDragMove, onRowDragEnd, onRowReorder } = useMotionDrag({
|
|
@@ -38930,14 +39216,14 @@ function Editor({ view = "page", formatPalette = FORMAT_PALETTE }) {
|
|
|
38930
39216
|
})
|
|
38931
39217
|
})
|
|
38932
39218
|
}),
|
|
38933
|
-
slash.menuNode,
|
|
38934
|
-
mention.menuNode,
|
|
38935
|
-
mentionCard,
|
|
39219
|
+
pageView ? slash.menuNode : null,
|
|
39220
|
+
pageView ? mention.menuNode : null,
|
|
39221
|
+
pageView ? mentionCard.node : null,
|
|
38936
39222
|
/* @__PURE__ */ jsx(LinkPopoverContext.Provider, {
|
|
38937
39223
|
value: linkPopover.api,
|
|
38938
|
-
children: viewMode ? null : format.toolbarNode
|
|
39224
|
+
children: viewMode || !pageView ? null : format.toolbarNode
|
|
38939
39225
|
}),
|
|
38940
|
-
linkPopover.node
|
|
39226
|
+
pageView ? linkPopover.node : null
|
|
38941
39227
|
] })]
|
|
38942
39228
|
})
|
|
38943
39229
|
})]
|