docblocks-react-ui 0.6.4 → 0.6.6
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 +12 -0
- package/dist/{Editor-DcQTuUsM.mjs → Editor-D_TogV4X.mjs} +148 -57
- package/dist/{constants-2VXoyPmd.mjs → constants-OOBlKSTr.mjs} +18 -1
- package/dist/{index-DyPFy2m5.d.mts → index-CeuUfoao.d.mts} +23 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +2 -2
- package/dist/mermaid/index.mjs +2 -3
- package/dist/pdf/index.d.mts +1 -1
- package/dist/pdf/index.mjs +1 -2
- package/package.json +1 -1
- package/dist/LoaderCircle-AGVFE4IP.mjs +0 -19
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# docblocks-react-ui
|
|
2
2
|
|
|
3
|
+
## 0.6.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- f730bec: The slash File command's pending upload stands the phrase block's skeleton (the spinner's rotation over the picker's open and the in-flight upload) over the closed popover instead of the menu's item stand; the refused upload's error line stands in the skeleton (the stand's click dismisses it) and a cancelled picker clears the stand over the page's focus.
|
|
8
|
+
|
|
9
|
+
## 0.6.5
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 7ebb9b4: The file and image blocks stand the placeholder's loading state (the spinner) over the in-flight blob resolution and the static placeholder over the rejected id; the slash File command stands the upload's spinner over the in-flight upload and the failed stand's error line over a refused one (the menu stays open on the phrase).
|
|
14
|
+
|
|
3
15
|
## 0.6.4
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as preventDefault, c as TriangleAlert, d as
|
|
1
|
+
import { a as preventDefault, c as TriangleAlert, d as LoaderCircle, f as ChevronRight, i as isSafeDownloadHref, l as Plus, m as cn, n as assertNever, o as stopPropagation, p as ChevronLeft, r as clamp, s as X, t as isEmbeddablePdfUrl, u as Minus } from "./constants-OOBlKSTr.mjs";
|
|
2
2
|
import { useStore } from "zustand";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { Component, Fragment, createContext, memo, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
@@ -1589,7 +1589,8 @@ const INIT_OPTIONS = {
|
|
|
1589
1589
|
embed: {
|
|
1590
1590
|
"urlPlaceholder": "Embed URL (https://…)",
|
|
1591
1591
|
"unsafeHint": "Only absolute http(s):// URLs are supported."
|
|
1592
|
-
}
|
|
1592
|
+
},
|
|
1593
|
+
file: { "uploadFailed": "Upload failed" }
|
|
1593
1594
|
},
|
|
1594
1595
|
table: {
|
|
1595
1596
|
handle: {
|
|
@@ -2048,7 +2049,8 @@ const INIT_OPTIONS = {
|
|
|
2048
2049
|
embed: {
|
|
2049
2050
|
"urlPlaceholder": "URL встраивания (https://…)",
|
|
2050
2051
|
"unsafeHint": "Поддерживаются только абсолютные URL http(s)://."
|
|
2051
|
-
}
|
|
2052
|
+
},
|
|
2053
|
+
file: { "uploadFailed": "Не удалось загрузить файл" }
|
|
2052
2054
|
},
|
|
2053
2055
|
table: {
|
|
2054
2056
|
handle: {
|
|
@@ -2591,6 +2593,7 @@ function createEditorStore(doc, rootId) {
|
|
|
2591
2593
|
presence: [],
|
|
2592
2594
|
sharing: "off",
|
|
2593
2595
|
canvasClipboard: null,
|
|
2596
|
+
fileUpload: null,
|
|
2594
2597
|
applyChange,
|
|
2595
2598
|
setPresence: (peers) => store.setState({ presence: peers }),
|
|
2596
2599
|
setSharing: (mode) => store.setState({ sharing: mode }),
|
|
@@ -2599,7 +2602,8 @@ function createEditorStore(doc, rootId) {
|
|
|
2599
2602
|
const ids = store.getState().collapsedIds;
|
|
2600
2603
|
store.setState({ collapsedIds: collapsed ? [...ids.includes(id) ? ids : [...ids, id]] : ids.filter((x) => x !== id) });
|
|
2601
2604
|
},
|
|
2602
|
-
setCanvasClipboard: (clipboard) => store.setState({ canvasClipboard: clipboard })
|
|
2605
|
+
setCanvasClipboard: (clipboard) => store.setState({ canvasClipboard: clipboard }),
|
|
2606
|
+
setFileUpload: (stand) => store.setState({ fileUpload: stand })
|
|
2603
2607
|
}));
|
|
2604
2608
|
return store;
|
|
2605
2609
|
}
|
|
@@ -6457,6 +6461,36 @@ var BlockErrorBoundary = class extends Component {
|
|
|
6457
6461
|
}
|
|
6458
6462
|
};
|
|
6459
6463
|
//#endregion
|
|
6464
|
+
//#region src/blocks/FileUploadSkeleton.tsx
|
|
6465
|
+
/** The slash File command's upload stand: while the popover stands closed
|
|
6466
|
+
* over the pending file (the OS dialog's open, the in-flight upload), the
|
|
6467
|
+
* phrase block's row stands the skeleton (the spinner's rotation) instead
|
|
6468
|
+
* of its content. The refused upload's failed stand stands the error line
|
|
6469
|
+
* (the stand's click dismisses it — the phrase's row returns). View stand
|
|
6470
|
+
* only: the doc stands untouched until the upload's commit. */
|
|
6471
|
+
function FileUploadSkeleton({ id, stand }) {
|
|
6472
|
+
const { t } = useTranslation("slash");
|
|
6473
|
+
const { store } = useEditorContext();
|
|
6474
|
+
const failed = stand.phase === "failed";
|
|
6475
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
6476
|
+
"data-slot": "docblocks/file-upload-skeleton",
|
|
6477
|
+
"data-block-id": id,
|
|
6478
|
+
"data-state": stand.phase,
|
|
6479
|
+
"aria-busy": !failed || void 0,
|
|
6480
|
+
className: cn("relative mx-0 my-(--docblocks-block-spacing) h-8 w-full", failed && "cursor-pointer"),
|
|
6481
|
+
onClick: failed ? () => store.getState().setFileUpload(null) : void 0,
|
|
6482
|
+
children: [/* @__PURE__ */ jsx(Skeleton, { className: "absolute inset-0 rounded-(--docblocks-radius)" }), /* @__PURE__ */ jsx("div", {
|
|
6483
|
+
className: "absolute inset-0 flex items-center justify-center",
|
|
6484
|
+
children: failed ? /* @__PURE__ */ jsx("span", {
|
|
6485
|
+
"data-slot": "docblocks/slash-file-error",
|
|
6486
|
+
role: "alert",
|
|
6487
|
+
className: "text-xs text-destructive",
|
|
6488
|
+
children: t("file.uploadFailed")
|
|
6489
|
+
}) : /* @__PURE__ */ jsx(LoaderCircle, { className: "size-4 animate-spin" })
|
|
6490
|
+
})]
|
|
6491
|
+
});
|
|
6492
|
+
}
|
|
6493
|
+
//#endregion
|
|
6460
6494
|
//#region src/blocks/flat.ts
|
|
6461
6495
|
/**
|
|
6462
6496
|
* The flat page model, derived at render time.
|
|
@@ -12716,18 +12750,27 @@ const BLOB_PLACEHOLDER_CLASS = `
|
|
|
12716
12750
|
function useBlobFile(fileId) {
|
|
12717
12751
|
const { blobStore } = useEditorContext();
|
|
12718
12752
|
const [ref, setRef] = useState(null);
|
|
12753
|
+
/** The get's rejection (the missing stand) — a resolve clears it. */
|
|
12754
|
+
const [failed, setFailed] = useState(false);
|
|
12719
12755
|
const [view, setView] = useState(null);
|
|
12720
12756
|
useEffect(() => {
|
|
12721
12757
|
let alive = true;
|
|
12722
12758
|
let sequence = 0;
|
|
12723
12759
|
setRef(null);
|
|
12760
|
+
setFailed(false);
|
|
12724
12761
|
const load = async () => {
|
|
12725
12762
|
const request = ++sequence;
|
|
12726
12763
|
try {
|
|
12727
12764
|
const next = await blobStore.get(fileId);
|
|
12728
|
-
if (alive && request === sequence)
|
|
12765
|
+
if (alive && request === sequence) {
|
|
12766
|
+
setRef(next);
|
|
12767
|
+
setFailed(false);
|
|
12768
|
+
}
|
|
12729
12769
|
} catch {
|
|
12730
|
-
if (alive && request === sequence)
|
|
12770
|
+
if (alive && request === sequence) {
|
|
12771
|
+
setRef(null);
|
|
12772
|
+
setFailed(true);
|
|
12773
|
+
}
|
|
12731
12774
|
}
|
|
12732
12775
|
};
|
|
12733
12776
|
const unsubscribe = blobStore.subscribe(fileId, () => {
|
|
@@ -12751,7 +12794,12 @@ function useBlobFile(fileId) {
|
|
|
12751
12794
|
});
|
|
12752
12795
|
return () => URL.revokeObjectURL(url);
|
|
12753
12796
|
}, [ref]);
|
|
12754
|
-
return
|
|
12797
|
+
if (view !== null) return {
|
|
12798
|
+
status: "ready",
|
|
12799
|
+
...view
|
|
12800
|
+
};
|
|
12801
|
+
if (failed) return { status: "missing" };
|
|
12802
|
+
return { status: "loading" };
|
|
12755
12803
|
}
|
|
12756
12804
|
//#endregion
|
|
12757
12805
|
//#region src/blocks/FileBlock.tsx
|
|
@@ -12761,14 +12809,16 @@ function FileBlock({ id, block }) {
|
|
|
12761
12809
|
const { pdfPreview } = useEditorContext();
|
|
12762
12810
|
const fileId = block.attrs.fileId;
|
|
12763
12811
|
const view = useBlobFile(fileId);
|
|
12764
|
-
if (view
|
|
12812
|
+
if (view.status !== "ready") return /* @__PURE__ */ jsx(Card, {
|
|
12765
12813
|
"data-slot": "docblocks/file-placeholder",
|
|
12766
12814
|
"data-block-type": "file",
|
|
12767
12815
|
"data-block-id": id,
|
|
12816
|
+
"data-state": view.status,
|
|
12817
|
+
"aria-busy": view.status === "loading",
|
|
12768
12818
|
className: BLOB_PLACEHOLDER_CLASS,
|
|
12769
12819
|
children: /* @__PURE__ */ jsxs(CardContent, {
|
|
12770
12820
|
className: "flex flex-col items-center gap-2 text-center",
|
|
12771
|
-
children: [/* @__PURE__ */ jsx(File, { className: "size-6" }), t("file.placeholder")]
|
|
12821
|
+
children: [view.status === "loading" ? /* @__PURE__ */ jsx(LoaderCircle, { className: "size-6 animate-spin" }) : /* @__PURE__ */ jsx(File, { className: "size-6" }), t("file.placeholder")]
|
|
12772
12822
|
})
|
|
12773
12823
|
});
|
|
12774
12824
|
const { url, meta } = view;
|
|
@@ -17295,16 +17345,9 @@ function applySlashPlan(doc, plan, command, blockId, parentId, indent, scope) {
|
|
|
17295
17345
|
* query back to a match brings the list back). The mousedown suppression
|
|
17296
17346
|
* keeps the block's selection (and focus) alive across an item click.
|
|
17297
17347
|
*/
|
|
17298
|
-
function SlashMenu({ rootRef, state, onHover, onPick, onClose,
|
|
17348
|
+
function SlashMenu({ rootRef, state, onHover, onPick, onClose, databasePick, databaseAvailable, onDatabasePickCancel, onDatabaseCommit, framePick, onFramePickCancel, onFrameCommit, embedForm, onEmbedCancel, onEmbedCommit }) {
|
|
17299
17349
|
const { t } = useTranslation("slash");
|
|
17300
17350
|
const text = blockTextOf(useBlock(state.blockId));
|
|
17301
|
-
const fileInputRef = useRef(null);
|
|
17302
|
-
useEffect(() => {
|
|
17303
|
-
fileClickRef.current = { open: () => fileInputRef.current?.click() };
|
|
17304
|
-
return () => {
|
|
17305
|
-
fileClickRef.current = null;
|
|
17306
|
-
};
|
|
17307
|
-
}, [fileClickRef]);
|
|
17308
17351
|
const [derived, setDerived] = useState(null);
|
|
17309
17352
|
useLayoutEffect(() => {
|
|
17310
17353
|
if (databasePick || framePick || embedForm) return;
|
|
@@ -17368,15 +17411,9 @@ function SlashMenu({ rootRef, state, onHover, onPick, onClose, onFile, fileClick
|
|
|
17368
17411
|
position
|
|
17369
17412
|
]);
|
|
17370
17413
|
if (!visible) return null;
|
|
17371
|
-
const onFileChange = (event) => {
|
|
17372
|
-
const files = event.target.files;
|
|
17373
|
-
const file = files !== null && files.length > 0 ? files[0] ?? null : null;
|
|
17374
|
-
event.target.value = "";
|
|
17375
|
-
onFile(file);
|
|
17376
|
-
};
|
|
17377
17414
|
const hoverAt = (index) => () => onHover(index);
|
|
17378
17415
|
const pickAt = (index) => () => onPick(index);
|
|
17379
|
-
return /* @__PURE__ */
|
|
17416
|
+
return /* @__PURE__ */ jsx(ScrollArea, {
|
|
17380
17417
|
ref: menuRef,
|
|
17381
17418
|
role: "menu",
|
|
17382
17419
|
"data-slot": "docblocks/slash-menu",
|
|
@@ -17385,13 +17422,7 @@ function SlashMenu({ rootRef, state, onHover, onPick, onClose, onFile, fileClick
|
|
|
17385
17422
|
left: position.left,
|
|
17386
17423
|
...position.top !== void 0 ? { top: position.top } : { bottom: position.bottom }
|
|
17387
17424
|
},
|
|
17388
|
-
children:
|
|
17389
|
-
ref: fileInputRef,
|
|
17390
|
-
type: "file",
|
|
17391
|
-
"data-slot": "docblocks/slash-file-input",
|
|
17392
|
-
className: "\n pointer-events-none absolute h-0 w-0 border-0 bg-transparent p-0 opacity-0 shadow-none\n file:h-0\n dark:bg-transparent\n ",
|
|
17393
|
-
onChange: onFileChange
|
|
17394
|
-
}), embedForm ? /* @__PURE__ */ jsx(SlashEmbedForm, {
|
|
17425
|
+
children: embedForm ? /* @__PURE__ */ jsx(SlashEmbedForm, {
|
|
17395
17426
|
onCommit: onEmbedCommit,
|
|
17396
17427
|
onCancel: onEmbedCancel
|
|
17397
17428
|
}) : framePick ? /* @__PURE__ */ jsx(FrameSlashPicker, {
|
|
@@ -17409,7 +17440,7 @@ function SlashMenu({ rootRef, state, onHover, onPick, onClose, onFile, fileClick
|
|
|
17409
17440
|
onMouseDown: preventDefault,
|
|
17410
17441
|
onClick: pickAt(index),
|
|
17411
17442
|
children: [/* @__PURE__ */ jsx(command.icon, { className: "size-4" }), t(command.labelKey)]
|
|
17412
|
-
}, command.label)) })
|
|
17443
|
+
}, command.label)) })
|
|
17413
17444
|
});
|
|
17414
17445
|
}
|
|
17415
17446
|
//#endregion
|
|
@@ -17429,6 +17460,7 @@ function useSlashMenu(rootRef) {
|
|
|
17429
17460
|
const [state, setState] = useState(null);
|
|
17430
17461
|
const stateRef = useRef(null);
|
|
17431
17462
|
stateRef.current = state;
|
|
17463
|
+
const fileInputRef = useRef(null);
|
|
17432
17464
|
const fileClickRef = useRef(null);
|
|
17433
17465
|
const pendingFileRef = useRef(null);
|
|
17434
17466
|
const [databasePick, setDatabasePick] = useState(false);
|
|
@@ -17517,6 +17549,11 @@ function useSlashMenu(rootRef) {
|
|
|
17517
17549
|
parentId: s.parentId,
|
|
17518
17550
|
slashOffset: s.slashOffset
|
|
17519
17551
|
};
|
|
17552
|
+
store.getState().setFileUpload({
|
|
17553
|
+
blockId: s.blockId,
|
|
17554
|
+
phase: "picker"
|
|
17555
|
+
});
|
|
17556
|
+
close();
|
|
17520
17557
|
fileClickRef.current?.open();
|
|
17521
17558
|
return;
|
|
17522
17559
|
}
|
|
@@ -17557,6 +17594,7 @@ function useSlashMenu(rootRef) {
|
|
|
17557
17594
|
doc,
|
|
17558
17595
|
openDerivation,
|
|
17559
17596
|
rootRef,
|
|
17597
|
+
store,
|
|
17560
17598
|
t
|
|
17561
17599
|
]);
|
|
17562
17600
|
/**
|
|
@@ -17566,21 +17604,35 @@ function useSlashMenu(rootRef) {
|
|
|
17566
17604
|
* path (they grow, shrink, or end the query).
|
|
17567
17605
|
*/
|
|
17568
17606
|
/**
|
|
17569
|
-
* The file pick of the slash
|
|
17607
|
+
* The file pick of the slash File command: the upload runs first (the
|
|
17570
17608
|
* doc holds only a committed key), then one transact — the trigger
|
|
17571
|
-
* phrase strip (when it still stands at its anchor) + the image
|
|
17572
|
-
* A phrase-only block without a derived segment is replaced at
|
|
17573
|
-
* otherwise the
|
|
17574
|
-
* paragraph stands when the
|
|
17575
|
-
* seats there). A
|
|
17576
|
-
*
|
|
17609
|
+
* phrase strip (when it still stands at its anchor) + the image / file
|
|
17610
|
+
* insert. A phrase-only block without a derived segment is replaced at
|
|
17611
|
+
* its slot; otherwise the attachment lands after the caret block. A
|
|
17612
|
+
* trailing empty paragraph stands when the attachment takes the
|
|
17613
|
+
* sequence's end (the caret seats there). A cancelled pick stands no
|
|
17614
|
+
* event of its own (the dialog's close's page-focus clears the stand,
|
|
17615
|
+
* the phrase's row returns); a refused upload commits nothing (the
|
|
17616
|
+
* failed stand's error line stands over the skeleton — the stand's
|
|
17617
|
+
* click dismisses it).
|
|
17577
17618
|
*/
|
|
17578
17619
|
const handleFile = useCallback((file) => {
|
|
17579
17620
|
const pending = pendingFileRef.current;
|
|
17580
17621
|
pendingFileRef.current = null;
|
|
17581
|
-
if (pending === null
|
|
17622
|
+
if (pending === null) return;
|
|
17582
17623
|
const { blockId, parentId, slashOffset } = pending;
|
|
17583
|
-
if (
|
|
17624
|
+
if (file === null) {
|
|
17625
|
+
store.getState().setFileUpload(null);
|
|
17626
|
+
return;
|
|
17627
|
+
}
|
|
17628
|
+
if (doc.getBlock(blockId) === null) {
|
|
17629
|
+
store.getState().setFileUpload(null);
|
|
17630
|
+
return;
|
|
17631
|
+
}
|
|
17632
|
+
store.getState().setFileUpload({
|
|
17633
|
+
blockId,
|
|
17634
|
+
phase: "uploading"
|
|
17635
|
+
});
|
|
17584
17636
|
(async () => {
|
|
17585
17637
|
try {
|
|
17586
17638
|
const fileId = await blobStore.upload(file);
|
|
@@ -17629,17 +17681,27 @@ function useSlashMenu(rootRef) {
|
|
|
17629
17681
|
} else focusCaretIn(blockId, slashOffset, scope);
|
|
17630
17682
|
});
|
|
17631
17683
|
} catch (error) {
|
|
17632
|
-
if (error instanceof InvalidAttrsError || error instanceof InvalidOperationError)
|
|
17684
|
+
if (error instanceof InvalidAttrsError || error instanceof InvalidOperationError) {
|
|
17685
|
+
store.getState().setFileUpload(null);
|
|
17686
|
+
return;
|
|
17687
|
+
}
|
|
17633
17688
|
throw error;
|
|
17634
17689
|
}
|
|
17635
17690
|
close();
|
|
17636
|
-
|
|
17691
|
+
store.getState().setFileUpload(null);
|
|
17692
|
+
} catch {
|
|
17693
|
+
store.getState().setFileUpload({
|
|
17694
|
+
blockId,
|
|
17695
|
+
phase: "failed"
|
|
17696
|
+
});
|
|
17697
|
+
}
|
|
17637
17698
|
})();
|
|
17638
17699
|
}, [
|
|
17639
17700
|
blobStore,
|
|
17640
17701
|
close,
|
|
17641
17702
|
doc,
|
|
17642
|
-
rootRef
|
|
17703
|
+
rootRef,
|
|
17704
|
+
store
|
|
17643
17705
|
]);
|
|
17644
17706
|
/**
|
|
17645
17707
|
* The table pick of the slash Database command: one transact — the
|
|
@@ -17892,6 +17954,17 @@ function useSlashMenu(rootRef) {
|
|
|
17892
17954
|
document.addEventListener("selectionchange", onSelectionChange);
|
|
17893
17955
|
return () => document.removeEventListener("selectionchange", onSelectionChange);
|
|
17894
17956
|
}, [openFlag, rootRef]);
|
|
17957
|
+
useEffect(() => {
|
|
17958
|
+
const onFocus = () => {
|
|
17959
|
+
const stand = store.getState().fileUpload;
|
|
17960
|
+
if (stand !== null && stand.phase === "picker") store.getState().setFileUpload(null);
|
|
17961
|
+
};
|
|
17962
|
+
window.addEventListener("focus", onFocus);
|
|
17963
|
+
return () => window.removeEventListener("focus", onFocus);
|
|
17964
|
+
}, [store]);
|
|
17965
|
+
useEffect(() => {
|
|
17966
|
+
fileClickRef.current = fileInputRef.current !== null ? { open: () => fileInputRef.current?.click() } : null;
|
|
17967
|
+
});
|
|
17895
17968
|
const cancelDatabasePick = () => {
|
|
17896
17969
|
setDatabasePick(false);
|
|
17897
17970
|
pendingDatabaseRef.current = null;
|
|
@@ -17904,19 +17977,30 @@ function useSlashMenu(rootRef) {
|
|
|
17904
17977
|
setEmbedForm(false);
|
|
17905
17978
|
pendingEmbedRef.current = null;
|
|
17906
17979
|
};
|
|
17980
|
+
const api = useMemo(() => ({
|
|
17981
|
+
onKeyDown,
|
|
17982
|
+
onSlashKey
|
|
17983
|
+
}), [onKeyDown, onSlashKey]);
|
|
17984
|
+
const onFileChange = (event) => {
|
|
17985
|
+
const files = event.target.files;
|
|
17986
|
+
const file = files !== null && files.length > 0 ? files[0] ?? null : null;
|
|
17987
|
+
event.target.value = "";
|
|
17988
|
+
handleFile(file);
|
|
17989
|
+
};
|
|
17907
17990
|
return {
|
|
17908
|
-
api
|
|
17909
|
-
|
|
17910
|
-
|
|
17911
|
-
|
|
17912
|
-
|
|
17991
|
+
api,
|
|
17992
|
+
menuNode: /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Input, {
|
|
17993
|
+
ref: fileInputRef,
|
|
17994
|
+
type: "file",
|
|
17995
|
+
"data-slot": "docblocks/slash-file-input",
|
|
17996
|
+
className: "\n pointer-events-none absolute h-0 w-0 border-0 bg-transparent p-0 opacity-0 shadow-none\n file:h-0\n dark:bg-transparent\n ",
|
|
17997
|
+
onChange: onFileChange
|
|
17998
|
+
}), state !== null ? /* @__PURE__ */ jsx(SlashMenu, {
|
|
17913
17999
|
rootRef,
|
|
17914
18000
|
state,
|
|
17915
18001
|
onHover: hover,
|
|
17916
18002
|
onPick: pick,
|
|
17917
18003
|
onClose: close,
|
|
17918
|
-
onFile: handleFile,
|
|
17919
|
-
fileClickRef,
|
|
17920
18004
|
databasePick,
|
|
17921
18005
|
databaseAvailable,
|
|
17922
18006
|
onDatabasePickCancel: cancelDatabasePick,
|
|
@@ -17927,7 +18011,7 @@ function useSlashMenu(rootRef) {
|
|
|
17927
18011
|
embedForm,
|
|
17928
18012
|
onEmbedCancel: cancelEmbedForm,
|
|
17929
18013
|
onEmbedCommit: commitEmbed
|
|
17930
|
-
}) : null
|
|
18014
|
+
}) : null] })
|
|
17931
18015
|
};
|
|
17932
18016
|
}
|
|
17933
18017
|
//#endregion
|
|
@@ -24909,18 +24993,20 @@ function ImageBlock({ id, block }) {
|
|
|
24909
24993
|
const { t } = useTranslation("blocks");
|
|
24910
24994
|
const { pdfPreview } = useEditorContext();
|
|
24911
24995
|
const src = block.attrs.src;
|
|
24912
|
-
const
|
|
24913
|
-
if (
|
|
24996
|
+
const file = useBlobFile(src);
|
|
24997
|
+
if (file.status !== "ready") return /* @__PURE__ */ jsx(Card, {
|
|
24914
24998
|
"data-slot": "docblocks/image-placeholder",
|
|
24915
24999
|
"data-block-type": "image",
|
|
24916
25000
|
"data-block-id": id,
|
|
25001
|
+
"data-state": file.status,
|
|
25002
|
+
"aria-busy": file.status === "loading",
|
|
24917
25003
|
className: BLOB_PLACEHOLDER_CLASS,
|
|
24918
25004
|
children: /* @__PURE__ */ jsxs(CardContent, {
|
|
24919
25005
|
className: "flex flex-col items-center gap-2 text-center",
|
|
24920
|
-
children: [/* @__PURE__ */ jsx(Image, { className: "size-6" }), t("image.placeholder")]
|
|
25006
|
+
children: [file.status === "loading" ? /* @__PURE__ */ jsx(LoaderCircle, { className: "size-6 animate-spin" }) : /* @__PURE__ */ jsx(Image, { className: "size-6" }), t("image.placeholder")]
|
|
24921
25007
|
})
|
|
24922
25008
|
});
|
|
24923
|
-
const { url, meta } =
|
|
25009
|
+
const { url, meta } = file;
|
|
24924
25010
|
const name = meta.name;
|
|
24925
25011
|
if (meta.mimeType === "application/pdf") {
|
|
24926
25012
|
if (pdfPreview !== null) return /* @__PURE__ */ jsx(pdfPreview, {
|
|
@@ -27264,9 +27350,14 @@ function BlockBody({ node, block, nested, collapsible, flat, renderers }) {
|
|
|
27264
27350
|
* missing (removed by a peer) renders nothing.
|
|
27265
27351
|
*/
|
|
27266
27352
|
const BlockNodeView = memo(function BlockNodeView({ node, flat = false, renderBlock }) {
|
|
27267
|
-
const { renderers } = useEditorContext();
|
|
27353
|
+
const { renderers, store } = useEditorContext();
|
|
27268
27354
|
const block = useBlock(node.id);
|
|
27355
|
+
const fileUpload = useStore(store, (state) => state.fileUpload !== null && state.fileUpload.blockId === node.id ? state.fileUpload : null);
|
|
27269
27356
|
if (block === void 0) return null;
|
|
27357
|
+
if (fileUpload !== null) return /* @__PURE__ */ jsx(FileUploadSkeleton, {
|
|
27358
|
+
id: node.id,
|
|
27359
|
+
stand: fileUpload
|
|
27360
|
+
});
|
|
27270
27361
|
const hasChildren = !flat && node.children.length > 0;
|
|
27271
27362
|
const isListItem = block.type === "list-item";
|
|
27272
27363
|
const collapsible = node.children.length > 0;
|
|
@@ -40,6 +40,23 @@ function ChevronRight(props) {
|
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
//#endregion
|
|
43
|
+
//#region src/shared/ui/icons/LoaderCircle.tsx
|
|
44
|
+
function LoaderCircle(props) {
|
|
45
|
+
return /* @__PURE__ */ jsx("svg", {
|
|
46
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
47
|
+
width: 24,
|
|
48
|
+
height: 24,
|
|
49
|
+
viewBox: "0 0 24 24",
|
|
50
|
+
fill: "none",
|
|
51
|
+
stroke: "currentColor",
|
|
52
|
+
strokeWidth: 2,
|
|
53
|
+
strokeLinecap: "round",
|
|
54
|
+
strokeLinejoin: "round",
|
|
55
|
+
...props,
|
|
56
|
+
children: /* @__PURE__ */ jsx("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" })
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
43
60
|
//#region src/shared/ui/icons/Minus.tsx
|
|
44
61
|
function Minus(props) {
|
|
45
62
|
return /* @__PURE__ */ jsx("svg", {
|
|
@@ -162,4 +179,4 @@ function isEmbeddablePdfUrl(url) {
|
|
|
162
179
|
}
|
|
163
180
|
}
|
|
164
181
|
//#endregion
|
|
165
|
-
export { preventDefault as a, TriangleAlert as c,
|
|
182
|
+
export { preventDefault as a, TriangleAlert as c, LoaderCircle as d, ChevronRight as f, isSafeDownloadHref as i, Plus as l, cn as m, assertNever as n, stopPropagation as o, ChevronLeft as p, clamp as r, X as s, isEmbeddablePdfUrl as t, Minus as u };
|
|
@@ -869,6 +869,20 @@ interface CanvasClipboard {
|
|
|
869
869
|
}
|
|
870
870
|
//#endregion
|
|
871
871
|
//#region src/state/models.d.ts
|
|
872
|
+
/**
|
|
873
|
+
* The slash File command's upload stand: the block the skeleton stands on
|
|
874
|
+
* + the phase. View state per editor (not doc data, no wire).
|
|
875
|
+
*/
|
|
876
|
+
interface FileUploadStand {
|
|
877
|
+
/** The block the skeleton stand stands on (the trigger phrase's block). */
|
|
878
|
+
blockId: BlockId;
|
|
879
|
+
/**
|
|
880
|
+
* The stand's phase: `picker` — the OS dialog's open (the file's not
|
|
881
|
+
* delivered yet), `uploading` — the in-flight upload, `failed` — the
|
|
882
|
+
* refused stand's error line (the stand's click dismisses it).
|
|
883
|
+
*/
|
|
884
|
+
phase: "picker" | "uploading" | "failed";
|
|
885
|
+
}
|
|
872
886
|
/**
|
|
873
887
|
* Per-instance editor state: a projection of one docblocks-core Doc.
|
|
874
888
|
*
|
|
@@ -923,6 +937,13 @@ interface EditorState {
|
|
|
923
937
|
* blocks.
|
|
924
938
|
*/
|
|
925
939
|
canvasClipboard: CanvasClipboard | null;
|
|
940
|
+
/**
|
|
941
|
+
* The slash File command's pending file upload stand (the phrase block's
|
|
942
|
+
* row stands the skeleton over its content while the popover stands
|
|
943
|
+
* closed). `null` when idle. A separate slice so a stand change never
|
|
944
|
+
* re-renders the other blocks.
|
|
945
|
+
*/
|
|
946
|
+
fileUpload: FileUploadStand | null;
|
|
926
947
|
}
|
|
927
948
|
/** Internal write functions, called by the EditorProvider subscriptions. */
|
|
928
949
|
interface EditorActions {
|
|
@@ -938,6 +959,8 @@ interface EditorActions {
|
|
|
938
959
|
setCollapsed: (id: BlockId, collapsed: boolean) => void;
|
|
939
960
|
/** Replaces the canvas clipboard slice (the copy / the clear). */
|
|
940
961
|
setCanvasClipboard: (clipboard: CanvasClipboard | null) => void;
|
|
962
|
+
/** Replaces the pending file upload stand (the set / the clear). */
|
|
963
|
+
setFileUpload: (stand: FileUploadStand | null) => void;
|
|
941
964
|
}
|
|
942
965
|
/** The per-instance vanilla store created by `createEditorStore`. */
|
|
943
966
|
type EditorStore = StoreApi<EditorState & EditorActions>;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as BlockRendererMap, r as BlockRendererProps, t as BlockRenderer } from "./index-YJcgf8Hh.mjs";
|
|
2
|
-
import { $ as ProtocolLimits, A as filterIsComplete, B as DatabaseBridge, C as DatabaseTableView, Ct as createMemoryBlobStore, D as DatabaseTableRow, E as DatabaseTablePhase, F as BridgeTableDescription, G as IsoInstant, H as FilterConditionInput, I as BridgeValueInput, J as OperationStatus, K as MutationContext, L as CellMap, M as BatchOp, N as BridgeColumn, O as UseDatabaseTable, P as BridgeColumnAnnotation, Q as ProtocolDescriptor, R as CellValueParse, S as DatabaseTableProps, St as BlobStore, T as useDatabaseTable, U as FilterInput, V as DomainEvent, W as Id, X as PageSnapshot, Y as PageQuery, Z as ProtocolCapability, _ as PresencePeer, _t as isBridgeError, a as EditorContextValue, at as SortInput, b as useTableList, bt as BlobMeta, c as EmbedSandboxPolicy, ct as SubscriptionStatus, d as PdfPreview, dt as TableEvent, et as QueryOperator, f as PdfPreviewProps, ft as TableRef, g as PresenceIdentity, gt as BridgeErrorCode, h as PresenceCrypto, ht as BridgeError, i as AccessLevel, it as RowWire, j as FilterBuilder, k as emptyFilter, l as MentionEntry, lt as TableDescription, m as SyncEmbedResolver, mt as BRIDGE_ERROR_CODES, n as DEFAULT_EMBED_SANDBOX, nt as Revision, o as EditorMode, ot as SubscriptionHandle, p as PresenceConfig, pt as TableSnapshot, q as MutationReceipt, r as EditorProvider, rt as RowPage, s as EditorProviderProps, st as SubscriptionObserver, t as useEditorContext, tt as QuerySemantics, u as MentionProvider, ut as TableEnvelopeBase, v as PresenceSharing, vt as isBridgeErrorCode, w as UseTableList, x as DatabaseTable, xt as BlobRef, y as PresenceSharingMode, yt as toBridgeError, z as Column } from "./index-
|
|
2
|
+
import { $ as ProtocolLimits, A as filterIsComplete, B as DatabaseBridge, C as DatabaseTableView, Ct as createMemoryBlobStore, D as DatabaseTableRow, E as DatabaseTablePhase, F as BridgeTableDescription, G as IsoInstant, H as FilterConditionInput, I as BridgeValueInput, J as OperationStatus, K as MutationContext, L as CellMap, M as BatchOp, N as BridgeColumn, O as UseDatabaseTable, P as BridgeColumnAnnotation, Q as ProtocolDescriptor, R as CellValueParse, S as DatabaseTableProps, St as BlobStore, T as useDatabaseTable, U as FilterInput, V as DomainEvent, W as Id, X as PageSnapshot, Y as PageQuery, Z as ProtocolCapability, _ as PresencePeer, _t as isBridgeError, a as EditorContextValue, at as SortInput, b as useTableList, bt as BlobMeta, c as EmbedSandboxPolicy, ct as SubscriptionStatus, d as PdfPreview, dt as TableEvent, et as QueryOperator, f as PdfPreviewProps, ft as TableRef, g as PresenceIdentity, gt as BridgeErrorCode, h as PresenceCrypto, ht as BridgeError, i as AccessLevel, it as RowWire, j as FilterBuilder, k as emptyFilter, l as MentionEntry, lt as TableDescription, m as SyncEmbedResolver, mt as BRIDGE_ERROR_CODES, n as DEFAULT_EMBED_SANDBOX, nt as Revision, o as EditorMode, ot as SubscriptionHandle, p as PresenceConfig, pt as TableSnapshot, q as MutationReceipt, r as EditorProvider, rt as RowPage, s as EditorProviderProps, st as SubscriptionObserver, t as useEditorContext, tt as QuerySemantics, u as MentionProvider, ut as TableEnvelopeBase, v as PresenceSharing, vt as isBridgeErrorCode, w as UseTableList, x as DatabaseTable, xt as BlobRef, y as PresenceSharingMode, yt as toBridgeError, z as Column } from "./index-CeuUfoao.mjs";
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { ComponentType, ReactNode } from "react";
|
|
5
5
|
import { Block, BlockId, BlockType, Doc, DocMeta, PresenceState, Selection, SelectionView, SyncEmbedRef, TextRun } from "docblocks-core";
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { $ as SelectValue, A as useBlock, At as CardFooter, B as DEFAULT_EMBED_SANDBOX, Bt as Badge, C as isBridgeError, Ct as PopoverTrigger, D as parseCellValue, Dt as CardAction, E as conditionMatches, Et as Card, F as useSelection, G as SelectContent, Gt as DocblocksI18nProvider, H as SegmentSelector, Ht as Alert, I as useSelectionView, It as BookOpen, J as SelectLabel, Jt as createMemoryBlobStore, K as SelectGroup, L as useText, Lt as Button, M as useMeta, Mt as CardTitle, N as usePresence, Nt as Pen, O as TEXT_TYPES, Ot as CardContent, P as usePresenceSharing, Pt as Eye, Q as SelectTrigger, R as EditorProvider, Rt as buttonVariants, S as BridgeError, St as PopoverTitle, T as toBridgeError, Tt as Checkbox, U as ScrollArea, Ut as AlertDescription, V as Skeleton, Vt as badgeVariants, W as Select, Wt as AlertTitle, X as SelectScrollUpButton, Y as SelectScrollDownButton, Z as SelectSeparator, _ as BASELINE_CAPABILITIES, _t as Popover, a as SHAPE_FONT_STACKS, at as DropdownMenuItem, b as validateProtocolDescriptor, bt as PopoverDescription, ct as DropdownMenuRadioGroup, d as useDatabaseTable, dt as DropdownMenuShortcut, et as Label, f as cellValueEqual, ft as DropdownMenuSub, g as filterIsComplete, gt as Separator, h as emptyFilter, ht as DropdownMenuTrigger, i as SHAPE_FONT_OPTIONS, it as DropdownMenuGroup, j as useDoc, jt as CardHeader, k as columnAnnotation, kt as CardDescription, l as markToggleAction, lt as DropdownMenuRadioItem, m as FilterBuilder, mt as DropdownMenuSubTrigger, nt as DropdownMenuCheckboxItem, ot as DropdownMenuLabel, p as newMutationContext, pt as DropdownMenuSubContent, q as SelectItem, qt as renderRuns, rt as DropdownMenuContent, s as FORMAT_PALETTE, st as DropdownMenuPortal, t as Editor, tt as DropdownMenu, u as GridBody, ut as DropdownMenuSeparator, v as PROTOCOL_VERSION, vt as PopoverAnchor, w as isBridgeErrorCode, wt as Input, x as BRIDGE_ERROR_CODES, xt as PopoverHeader, y as isDatabaseBridge, yt as PopoverContent, z as useEditorContext, zt as BareSelect } from "./Editor-
|
|
2
|
-
import { a as preventDefault,
|
|
1
|
+
import { $ as SelectValue, A as useBlock, At as CardFooter, B as DEFAULT_EMBED_SANDBOX, Bt as Badge, C as isBridgeError, Ct as PopoverTrigger, D as parseCellValue, Dt as CardAction, E as conditionMatches, Et as Card, F as useSelection, G as SelectContent, Gt as DocblocksI18nProvider, H as SegmentSelector, Ht as Alert, I as useSelectionView, It as BookOpen, J as SelectLabel, Jt as createMemoryBlobStore, K as SelectGroup, L as useText, Lt as Button, M as useMeta, Mt as CardTitle, N as usePresence, Nt as Pen, O as TEXT_TYPES, Ot as CardContent, P as usePresenceSharing, Pt as Eye, Q as SelectTrigger, R as EditorProvider, Rt as buttonVariants, S as BridgeError, St as PopoverTitle, T as toBridgeError, Tt as Checkbox, U as ScrollArea, Ut as AlertDescription, V as Skeleton, Vt as badgeVariants, W as Select, Wt as AlertTitle, X as SelectScrollUpButton, Y as SelectScrollDownButton, Z as SelectSeparator, _ as BASELINE_CAPABILITIES, _t as Popover, a as SHAPE_FONT_STACKS, at as DropdownMenuItem, b as validateProtocolDescriptor, bt as PopoverDescription, ct as DropdownMenuRadioGroup, d as useDatabaseTable, dt as DropdownMenuShortcut, et as Label, f as cellValueEqual, ft as DropdownMenuSub, g as filterIsComplete, gt as Separator, h as emptyFilter, ht as DropdownMenuTrigger, i as SHAPE_FONT_OPTIONS, it as DropdownMenuGroup, j as useDoc, jt as CardHeader, k as columnAnnotation, kt as CardDescription, l as markToggleAction, lt as DropdownMenuRadioItem, m as FilterBuilder, mt as DropdownMenuSubTrigger, nt as DropdownMenuCheckboxItem, ot as DropdownMenuLabel, p as newMutationContext, pt as DropdownMenuSubContent, q as SelectItem, qt as renderRuns, rt as DropdownMenuContent, s as FORMAT_PALETTE, st as DropdownMenuPortal, t as Editor, tt as DropdownMenu, u as GridBody, ut as DropdownMenuSeparator, v as PROTOCOL_VERSION, vt as PopoverAnchor, w as isBridgeErrorCode, wt as Input, x as BRIDGE_ERROR_CODES, xt as PopoverHeader, y as isDatabaseBridge, yt as PopoverContent, z as useEditorContext, zt as BareSelect } from "./Editor-D_TogV4X.mjs";
|
|
2
|
+
import { a as preventDefault, m as cn } from "./constants-OOBlKSTr.mjs";
|
|
3
3
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
4
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import { useTranslation } from "react-i18next";
|
package/dist/mermaid/index.mjs
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { Ft as CodeXml, H as SegmentSelector, Ht as Alert, Kt as INLINE_CODE_CLASS, Pt as Eye, Ut as AlertDescription, V as Skeleton, Wt as AlertTitle, c as textOf, n as childrenSlot, o as TextBlock, r as CodeHeader, z as useEditorContext } from "../Editor-
|
|
2
|
-
import { c as TriangleAlert } from "../constants-
|
|
3
|
-
import { t as LoaderCircle } from "../LoaderCircle-AGVFE4IP.mjs";
|
|
1
|
+
import { Ft as CodeXml, H as SegmentSelector, Ht as Alert, Kt as INLINE_CODE_CLASS, Pt as Eye, Ut as AlertDescription, V as Skeleton, Wt as AlertTitle, c as textOf, n as childrenSlot, o as TextBlock, r as CodeHeader, z as useEditorContext } from "../Editor-D_TogV4X.mjs";
|
|
2
|
+
import { c as TriangleAlert, d as LoaderCircle } from "../constants-OOBlKSTr.mjs";
|
|
4
3
|
import { useEffect, useRef, useState } from "react";
|
|
5
4
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
6
5
|
import { useTranslation } from "react-i18next";
|
package/dist/pdf/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { f as PdfPreviewProps } from "../index-
|
|
1
|
+
import { f as PdfPreviewProps } from "../index-CeuUfoao.mjs";
|
|
2
2
|
//#region src/pdf/PdfFirstPage.d.ts
|
|
3
3
|
declare function PdfFirstPage({ id, blockType, url, name }: PdfPreviewProps): import("react").JSX.Element;
|
|
4
4
|
//#endregion
|
package/dist/pdf/index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { c as TriangleAlert, d as
|
|
2
|
-
import { t as LoaderCircle } from "../LoaderCircle-AGVFE4IP.mjs";
|
|
1
|
+
import { c as TriangleAlert, d as LoaderCircle, f as ChevronRight, i as isSafeDownloadHref, l as Plus, m as cn, p as ChevronLeft, r as clamp, s as X, t as isEmbeddablePdfUrl, u as Minus } from "../constants-OOBlKSTr.mjs";
|
|
3
2
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
4
3
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
4
|
import { useTranslation } from "react-i18next";
|
package/package.json
CHANGED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { jsx } from "react/jsx-runtime";
|
|
2
|
-
//#region src/shared/ui/icons/LoaderCircle.tsx
|
|
3
|
-
function LoaderCircle(props) {
|
|
4
|
-
return /* @__PURE__ */ jsx("svg", {
|
|
5
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
6
|
-
width: 24,
|
|
7
|
-
height: 24,
|
|
8
|
-
viewBox: "0 0 24 24",
|
|
9
|
-
fill: "none",
|
|
10
|
-
stroke: "currentColor",
|
|
11
|
-
strokeWidth: 2,
|
|
12
|
-
strokeLinecap: "round",
|
|
13
|
-
strokeLinejoin: "round",
|
|
14
|
-
...props,
|
|
15
|
-
children: /* @__PURE__ */ jsx("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" })
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
//#endregion
|
|
19
|
-
export { LoaderCircle as t };
|