docblocks-react-ui 0.24.1 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -0
- package/README.md +56 -25
- package/dist/{Editor-Du_hrZ3E.mjs → Editor-DsnFHj1x.mjs} +325 -123
- package/dist/{index-CE8wKsue.d.mts → index-DAc-REs_.d.mts} +54 -3
- package/dist/index.d.mts +4 -4
- package/dist/index.mjs +15 -2
- package/dist/mermaid/index.mjs +1 -1
- package/dist/pdf/index.d.mts +1 -1
- package/dist/styles.css +33 -14
- package/package.json +2 -2
|
@@ -500,7 +500,8 @@ const INIT_OPTIONS = {
|
|
|
500
500
|
"editOptions": "Edit options",
|
|
501
501
|
"show": "Show column",
|
|
502
502
|
"hide": "Hide column",
|
|
503
|
-
"delete": "Delete column"
|
|
503
|
+
"delete": "Delete column",
|
|
504
|
+
"resizeHeight": "Resize the header row"
|
|
504
505
|
},
|
|
505
506
|
row: {
|
|
506
507
|
"moveUp": "Move up",
|
|
@@ -1043,7 +1044,8 @@ const INIT_OPTIONS = {
|
|
|
1043
1044
|
"editOptions": "Изменить варианты",
|
|
1044
1045
|
"show": "Показать столбец",
|
|
1045
1046
|
"hide": "Скрыть столбец",
|
|
1046
|
-
"delete": "Удалить столбец"
|
|
1047
|
+
"delete": "Удалить столбец",
|
|
1048
|
+
"resizeHeight": "Изменить высоту заголовка"
|
|
1047
1049
|
},
|
|
1048
1050
|
row: {
|
|
1049
1051
|
"moveUp": "Переместить вверх",
|
|
@@ -8545,6 +8547,77 @@ function AddColumnForm({ open, onOpenChange, form, formNumber, formRef, error, b
|
|
|
8545
8547
|
});
|
|
8546
8548
|
}
|
|
8547
8549
|
//#endregion
|
|
8550
|
+
//#region src/database/grid/column-type-icon.ts
|
|
8551
|
+
function columnTypeIcon(type, refKind, refMany) {
|
|
8552
|
+
if (refKind === "enum") return refMany ? ListChecks : CircleChevronDown;
|
|
8553
|
+
if (refKind === "row") return Cable;
|
|
8554
|
+
if (type === "integer" || type === "numeric") return Hash;
|
|
8555
|
+
if (type === "boolean") return CircleCheck;
|
|
8556
|
+
if (type === "date") return CalendarIcon;
|
|
8557
|
+
if (type === "timestamptz") return CalendarClock;
|
|
8558
|
+
return Type;
|
|
8559
|
+
}
|
|
8560
|
+
//#endregion
|
|
8561
|
+
//#region src/database/grid/AddColumnCell.tsx
|
|
8562
|
+
/** The grid's header-row "add column" cell: the plus chip (the type's menu)
|
|
8563
|
+
* and the create form over it. The cell carries its own explicit grid
|
|
8564
|
+
* placement (the header row's track after the last column) — the header's
|
|
8565
|
+
* resize strip occupies the same row across all tracks. The read-only
|
|
8566
|
+
* modes render the empty track (the primitive's stand: no chip, no form). */
|
|
8567
|
+
function AddColumnCell({ gridColumn, readOnly, form, OptionsEditor }) {
|
|
8568
|
+
const { t } = useTranslation("database");
|
|
8569
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
8570
|
+
"data-slot": "docblocks/database-add-column",
|
|
8571
|
+
className: "\n relative row-start-1 flex items-center justify-center border-b-(length:--docblocks-table-border-width)\n border-(--docblocks-table-border-color)\n ",
|
|
8572
|
+
style: { gridColumn },
|
|
8573
|
+
children: [!readOnly && /* @__PURE__ */ jsxs(DropdownMenu, {
|
|
8574
|
+
modal: false,
|
|
8575
|
+
open: form.addingColumn,
|
|
8576
|
+
onOpenChange: form.setAddingColumn,
|
|
8577
|
+
children: [/* @__PURE__ */ jsx(DropdownMenuTrigger, {
|
|
8578
|
+
asChild: true,
|
|
8579
|
+
children: /* @__PURE__ */ jsx(Button, {
|
|
8580
|
+
"data-slot": "docblocks/database-add-column-trigger",
|
|
8581
|
+
variant: "ghost",
|
|
8582
|
+
size: "icon",
|
|
8583
|
+
className: cn("rounded-(--docblocks-radius) border-(length:--docblocks-table-border-width) border-(--docblocks-table-border-color) bg-transparent dark:border-(--docblocks-table-border-color) dark:bg-transparent", "size-6 cursor-pointer p-1 text-(--docblocks-placeholder-color) hover:bg-transparent", "hover:text-(--docblocks-text-color) dark:hover:bg-transparent"),
|
|
8584
|
+
children: /* @__PURE__ */ jsx(Plus, { className: "size-4" })
|
|
8585
|
+
})
|
|
8586
|
+
}), /* @__PURE__ */ jsx(DropdownMenuContent, {
|
|
8587
|
+
align: "end",
|
|
8588
|
+
className: "min-w-32",
|
|
8589
|
+
children: ADD_COLUMN_TYPES.map((entry) => {
|
|
8590
|
+
const EntryIcon = columnTypeIcon(entry.type, entry.refKind, entry.refMany);
|
|
8591
|
+
return /* @__PURE__ */ jsxs(DropdownMenuItem, {
|
|
8592
|
+
"data-column-entry": entry.key,
|
|
8593
|
+
onClick: () => form.openCreateForm(entry),
|
|
8594
|
+
children: [/* @__PURE__ */ jsx(EntryIcon, { className: "size-4 shrink-0 text-muted-foreground" }), t(entry.labelKey)]
|
|
8595
|
+
}, entry.key);
|
|
8596
|
+
})
|
|
8597
|
+
})]
|
|
8598
|
+
}), /* @__PURE__ */ jsx(AddColumnForm, {
|
|
8599
|
+
open: form.columnFormOpen,
|
|
8600
|
+
onOpenChange: form.onColumnFormOpenChange,
|
|
8601
|
+
form: form.columnForm,
|
|
8602
|
+
formNumber: form.columnFormNumber,
|
|
8603
|
+
formRef: form.columnFormRef,
|
|
8604
|
+
error: form.columnFormError,
|
|
8605
|
+
bridgeTables: form.bridgeTables,
|
|
8606
|
+
OptionsEditor,
|
|
8607
|
+
onCommit: form.commitColumnForm,
|
|
8608
|
+
onNameChange: form.onColumnNameChange,
|
|
8609
|
+
onDecimalsChange: form.onColumnDecimalsChange,
|
|
8610
|
+
onThousandsChange: form.onColumnThousandsChange,
|
|
8611
|
+
onPrefixChange: form.onColumnPrefixChange,
|
|
8612
|
+
onSuffixChange: form.onColumnSuffixChange,
|
|
8613
|
+
onAllowNegativeChange: form.onColumnAllowNegativeChange,
|
|
8614
|
+
onEnumOptionsChange: form.onColumnEnumOptionsChange,
|
|
8615
|
+
onRefPickChange: form.onColumnRefPickChange,
|
|
8616
|
+
onNewTableNameChange: form.onColumnNewTableNameChange
|
|
8617
|
+
})]
|
|
8618
|
+
});
|
|
8619
|
+
}
|
|
8620
|
+
//#endregion
|
|
8548
8621
|
//#region src/database/grid/cells/CellDisplay.tsx
|
|
8549
8622
|
/** The cell's read-only display (the single-press stand: the value text or
|
|
8550
8623
|
* the empty stand). */
|
|
@@ -9659,17 +9732,6 @@ function GridRows({ rows, columns, data, selectedCells, editingCell, setEditingC
|
|
|
9659
9732
|
] });
|
|
9660
9733
|
}
|
|
9661
9734
|
//#endregion
|
|
9662
|
-
//#region src/database/grid/column-type-icon.ts
|
|
9663
|
-
function columnTypeIcon(type, refKind, refMany) {
|
|
9664
|
-
if (refKind === "enum") return refMany ? ListChecks : CircleChevronDown;
|
|
9665
|
-
if (refKind === "row") return Cable;
|
|
9666
|
-
if (type === "integer" || type === "numeric") return Hash;
|
|
9667
|
-
if (type === "boolean") return CircleCheck;
|
|
9668
|
-
if (type === "date") return CalendarIcon;
|
|
9669
|
-
if (type === "timestamptz") return CalendarClock;
|
|
9670
|
-
return Type;
|
|
9671
|
-
}
|
|
9672
|
-
//#endregion
|
|
9673
9735
|
//#region src/database/grid/HeaderCell.tsx
|
|
9674
9736
|
/** The grid's header cell (the column's name + the press menu + the
|
|
9675
9737
|
* right-edge resize seam). */
|
|
@@ -9683,6 +9745,12 @@ function HeaderCell({ readOnly = false, column, colIndex, first, resizing, dragD
|
|
|
9683
9745
|
const { t } = useTranslation("database");
|
|
9684
9746
|
const [nameDraft, setNameDraft] = useState(column.name);
|
|
9685
9747
|
const ColumnIcon = columnTypeIcon(column.type, column.refKind, column.refMany);
|
|
9748
|
+
const dragStyle = dragDx !== 0 ? {
|
|
9749
|
+
transform: `translateX(${dragDx}px)`,
|
|
9750
|
+
position: "relative",
|
|
9751
|
+
zIndex: dragShifted ? void 0 : 10,
|
|
9752
|
+
transition: dragShifted ? GRID_DRAG_TRANSITION : void 0
|
|
9753
|
+
} : null;
|
|
9686
9754
|
const commitRename = () => {
|
|
9687
9755
|
const trimmed = nameDraft.trim();
|
|
9688
9756
|
if (trimmed !== "" && trimmed !== column.name) onRename(trimmed);
|
|
@@ -9709,12 +9777,11 @@ function HeaderCell({ readOnly = false, column, colIndex, first, resizing, dragD
|
|
|
9709
9777
|
return /* @__PURE__ */ jsxs("div", {
|
|
9710
9778
|
"data-slot": "docblocks/database-header-cell",
|
|
9711
9779
|
"data-column-id": column.id,
|
|
9712
|
-
style:
|
|
9713
|
-
|
|
9714
|
-
|
|
9715
|
-
|
|
9716
|
-
|
|
9717
|
-
} : void 0,
|
|
9780
|
+
style: {
|
|
9781
|
+
gridRow: 1,
|
|
9782
|
+
gridColumn: colIndex + 1,
|
|
9783
|
+
...dragStyle
|
|
9784
|
+
},
|
|
9718
9785
|
className: cn(`
|
|
9719
9786
|
relative flex min-w-0 items-center gap-1 border-b-(length:--docblocks-table-border-width)
|
|
9720
9787
|
border-(--docblocks-table-border-color) bg-muted/40 px-2 py-1 select-none
|
|
@@ -9804,6 +9871,38 @@ function HeaderCell({ readOnly = false, column, colIndex, first, resizing, dragD
|
|
|
9804
9871
|
});
|
|
9805
9872
|
}
|
|
9806
9873
|
//#endregion
|
|
9874
|
+
//#region src/database/grid/HeaderResizeHandle.tsx
|
|
9875
|
+
/** The grid's header-row resize handle: the full-width strip over the
|
|
9876
|
+
* header row's bottom edge (it spans the header's track row — the header
|
|
9877
|
+
* cells carry their own explicit placement, so the strip stands the
|
|
9878
|
+
* overlay of the same row). The press-drag session is the hook's stand;
|
|
9879
|
+
* the read-only modes render no handle (the height itself still
|
|
9880
|
+
* applies). */
|
|
9881
|
+
/** The header's bottom edge: the 6 px strip straddles the border (the
|
|
9882
|
+
* seam idiom — the pointer over the edge stands the stable row-resize). */
|
|
9883
|
+
function HeaderResizeHandle({ resizing, onPointerDown, onPointerMove, onPointerUp, onPointerCancel }) {
|
|
9884
|
+
const { t } = useTranslation("database");
|
|
9885
|
+
return /* @__PURE__ */ jsx("div", {
|
|
9886
|
+
role: "separator",
|
|
9887
|
+
"aria-orientation": "horizontal",
|
|
9888
|
+
"aria-label": t("header.resizeHeight"),
|
|
9889
|
+
"data-slot": "docblocks/database-header-resize",
|
|
9890
|
+
className: cn(`
|
|
9891
|
+
z-10 col-span-full row-start-1 flex h-1.5 translate-y-1/2 cursor-row-resize items-center self-end opacity-0
|
|
9892
|
+
transition-opacity
|
|
9893
|
+
hover:opacity-100
|
|
9894
|
+
`, resizing && "opacity-100"),
|
|
9895
|
+
onPointerDown,
|
|
9896
|
+
onPointerMove,
|
|
9897
|
+
onPointerUp,
|
|
9898
|
+
onPointerCancel,
|
|
9899
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
9900
|
+
"data-slot": "docblocks/database-header-resize-line",
|
|
9901
|
+
className: "h-0.5 w-full rounded bg-(--muted-foreground)"
|
|
9902
|
+
})
|
|
9903
|
+
});
|
|
9904
|
+
}
|
|
9905
|
+
//#endregion
|
|
9807
9906
|
//#region src/database/grid/use-grid-column-drag.ts
|
|
9808
9907
|
/** The database grid's column drag: the header cell's press + drag (the
|
|
9809
9908
|
* live parting preview — the dragged column's own cells stand the pointer's
|
|
@@ -9889,6 +9988,99 @@ function useGridColumnDrag({ columns, allColumns, columnOrder, hiddenColumns, co
|
|
|
9889
9988
|
};
|
|
9890
9989
|
}
|
|
9891
9990
|
//#endregion
|
|
9991
|
+
//#region src/database/grid/header-height.ts
|
|
9992
|
+
/** The grid's header-row height stands: the resolution over the two
|
|
9993
|
+
* persistence levels (the block's own attr over the consumer's per-table
|
|
9994
|
+
* section value, an absent stand = the auto height), the drag's clamp, and
|
|
9995
|
+
* the auto height's live measurement. */
|
|
9996
|
+
/** The header row's height stand: the block's own attr wins over the
|
|
9997
|
+
* table section's value (the consumer's per-table persistence — the same
|
|
9998
|
+
* height over every block referencing the table); an absent stand keeps
|
|
9999
|
+
* the auto height. */
|
|
10000
|
+
function resolveDatabaseHeaderHeight(blockHeight, sectionHeight) {
|
|
10001
|
+
return blockHeight ?? sectionHeight;
|
|
10002
|
+
}
|
|
10003
|
+
/** The drag's clamp: the auto height is the floor (the column names never
|
|
10004
|
+
* render clipped), with the one-line fallback floor when the auto height
|
|
10005
|
+
* stands unmeasured; the ceiling is the drag's generous bound (the data
|
|
10006
|
+
* level checks the positivity only). */
|
|
10007
|
+
function clampDatabaseHeaderHeight(requested, natural) {
|
|
10008
|
+
return Math.max(Math.max(Math.round(natural), 28), Math.min(Math.round(requested), 600));
|
|
10009
|
+
}
|
|
10010
|
+
/** The header row's natural (auto) height in px, measured over the live
|
|
10011
|
+
* grid: the explicit track's height is lifted for the read and restored
|
|
10012
|
+
* before the frame paints, so the returned stand is the content's own.
|
|
10013
|
+
* A detached / unlaid-out grid (no layout in the runtime) stands 0. */
|
|
10014
|
+
function measureDatabaseHeaderHeight(grid) {
|
|
10015
|
+
if (grid === null) return 0;
|
|
10016
|
+
const previous = grid.style.gridTemplateRows;
|
|
10017
|
+
grid.style.gridTemplateRows = "auto";
|
|
10018
|
+
let natural = 0;
|
|
10019
|
+
for (const cell of grid.querySelectorAll("[data-slot=\"docblocks/database-header-cell\"]")) natural = Math.max(natural, cell.offsetHeight);
|
|
10020
|
+
grid.style.gridTemplateRows = previous;
|
|
10021
|
+
return natural;
|
|
10022
|
+
}
|
|
10023
|
+
//#endregion
|
|
10024
|
+
//#region src/database/grid/use-grid-header-resize.ts
|
|
10025
|
+
/** The database grid's header-row resize: the full-width handle's press +
|
|
10026
|
+
* drag (the live preview stands the row's height; no commit until the
|
|
10027
|
+
* release), the release (the clamped height commits over the caller's
|
|
10028
|
+
* write stand — the block's attr / the consumer's per-table section
|
|
10029
|
+
* setting; a drag back to the press's height stands a no-op), and the
|
|
10030
|
+
* cancel. The clamp's floor is the auto height measured at the press, so
|
|
10031
|
+
* the header's content never renders clipped. */
|
|
10032
|
+
function useGridHeaderResize({ tableRef, headerHeight, onCommit }) {
|
|
10033
|
+
const [headerPreview, setHeaderPreview] = useState(null);
|
|
10034
|
+
const session = useRef(null);
|
|
10035
|
+
/** The handle's press: starts the resize session (the native click /
|
|
10036
|
+
* the surrounding gestures are suppressed — the handle stands its own
|
|
10037
|
+
* session). */
|
|
10038
|
+
const onHeaderPointerDown = (event) => {
|
|
10039
|
+
if (event.button !== 0 || session.current !== null) return;
|
|
10040
|
+
event.preventDefault();
|
|
10041
|
+
event.stopPropagation();
|
|
10042
|
+
event.currentTarget.setPointerCapture?.(event.pointerId);
|
|
10043
|
+
const natural = measureDatabaseHeaderHeight(tableRef.current);
|
|
10044
|
+
const startHeight = clampDatabaseHeaderHeight(headerHeight ?? Math.max(natural, 28), natural);
|
|
10045
|
+
session.current = {
|
|
10046
|
+
startY: event.clientY,
|
|
10047
|
+
startHeight,
|
|
10048
|
+
natural,
|
|
10049
|
+
height: startHeight
|
|
10050
|
+
};
|
|
10051
|
+
setHeaderPreview(startHeight);
|
|
10052
|
+
};
|
|
10053
|
+
const onHeaderPointerMove = (event) => {
|
|
10054
|
+
const live = session.current;
|
|
10055
|
+
if (live === null) return;
|
|
10056
|
+
live.height = clampDatabaseHeaderHeight(live.startHeight + (event.clientY - live.startY), live.natural);
|
|
10057
|
+
setHeaderPreview(live.height);
|
|
10058
|
+
};
|
|
10059
|
+
/** The handle's release: the clamped height commits when it changed (one
|
|
10060
|
+
* write, one undo step over the block's stand); a drag back to the
|
|
10061
|
+
* press's height stands a no-op (no wire traffic). */
|
|
10062
|
+
const onHeaderPointerUp = (event) => {
|
|
10063
|
+
const live = session.current;
|
|
10064
|
+
session.current = null;
|
|
10065
|
+
setHeaderPreview(null);
|
|
10066
|
+
if (live === null) return;
|
|
10067
|
+
event.currentTarget.releasePointerCapture?.(event.pointerId);
|
|
10068
|
+
if (live.height === live.startHeight) return;
|
|
10069
|
+
onCommit(live.height);
|
|
10070
|
+
};
|
|
10071
|
+
const onHeaderPointerCancel = () => {
|
|
10072
|
+
session.current = null;
|
|
10073
|
+
setHeaderPreview(null);
|
|
10074
|
+
};
|
|
10075
|
+
return {
|
|
10076
|
+
headerPreview,
|
|
10077
|
+
onHeaderPointerDown,
|
|
10078
|
+
onHeaderPointerMove,
|
|
10079
|
+
onHeaderPointerUp,
|
|
10080
|
+
onHeaderPointerCancel
|
|
10081
|
+
};
|
|
10082
|
+
}
|
|
10083
|
+
//#endregion
|
|
9892
10084
|
//#region src/database/grid/use-grid-seam-resize.ts
|
|
9893
10085
|
/** The database grid's column-seam resize: the header cell's right-edge
|
|
9894
10086
|
* seam's press + drag (the live preview locks every column over its
|
|
@@ -9989,8 +10181,7 @@ function useGridSeamResize({ columns, columnWidths, updateView }) {
|
|
|
9989
10181
|
* model (the cell / column selection — the native text selection over the
|
|
9990
10182
|
* drag is suppressed).
|
|
9991
10183
|
*/
|
|
9992
|
-
function GridTable({ columns, allColumns, columnOrder, hiddenColumns, columnWidths, onViewChange, data, rows, selectedCells, editingCell, setEditingCell, onCellPointerDown, booleanPressRef, pendingRowId, refTableData, filter, readOnly = false, tableRef, onTableKeyDown, onTablePaste, onTableBlur, form, OptionsEditor }) {
|
|
9993
|
-
const { t } = useTranslation("database");
|
|
10184
|
+
function GridTable({ columns, allColumns, columnOrder, hiddenColumns, columnWidths, onViewChange, data, rows, selectedCells, editingCell, setEditingCell, onCellPointerDown, booleanPressRef, pendingRowId, refTableData, filter, readOnly = false, headerHeight, onHeaderHeightChange, tableRef, onTableKeyDown, onTablePaste, onTableBlur, form, OptionsEditor }) {
|
|
9994
10185
|
const [columnMenu, setColumnMenu] = useState(null);
|
|
9995
10186
|
const { resizePreview, onSeamPointerDown, onSeamPointerMove, onSeamPointerUp, onSeamPointerCancel } = useGridSeamResize({
|
|
9996
10187
|
columns,
|
|
@@ -10006,6 +10197,12 @@ function GridTable({ columns, allColumns, columnOrder, hiddenColumns, columnWidt
|
|
|
10006
10197
|
updateView: onViewChange,
|
|
10007
10198
|
tableRef
|
|
10008
10199
|
});
|
|
10200
|
+
const { headerPreview, onHeaderPointerDown, onHeaderPointerMove, onHeaderPointerUp, onHeaderPointerCancel } = useGridHeaderResize({
|
|
10201
|
+
tableRef,
|
|
10202
|
+
headerHeight,
|
|
10203
|
+
onCommit: onHeaderHeightChange ?? (() => void 0)
|
|
10204
|
+
});
|
|
10205
|
+
const headerRowHeight = headerPreview ?? headerHeight;
|
|
10009
10206
|
const dragFrom = drag === null ? -1 : columns.findIndex((entry) => entry.id === drag.id);
|
|
10010
10207
|
const dragShiftOf = (index) => {
|
|
10011
10208
|
if (drag === null || drag.toIndex === null || index === dragFrom) return 0;
|
|
@@ -10039,7 +10236,7 @@ function GridTable({ columns, allColumns, columnOrder, hiddenColumns, columnWidt
|
|
|
10039
10236
|
onPaste: onTablePaste,
|
|
10040
10237
|
onBlur: onTableBlur,
|
|
10041
10238
|
style: {
|
|
10042
|
-
gridTemplateRows: "auto",
|
|
10239
|
+
gridTemplateRows: headerRowHeight !== void 0 ? `${headerRowHeight}px` : "auto",
|
|
10043
10240
|
gridAutoRows: "var(--docblocks-database-row-height)",
|
|
10044
10241
|
gridTemplateColumns: `${columns.map((_, index) => {
|
|
10045
10242
|
const width = (resizePreview !== null ? resizePreview.widths[index] : void 0) ?? columnWidths?.[index];
|
|
@@ -10071,54 +10268,18 @@ function GridTable({ columns, allColumns, columnOrder, hiddenColumns, columnWidt
|
|
|
10071
10268
|
onPointerMove: onColumnPointerMove,
|
|
10072
10269
|
onPointerUp: columnPointerUp(column)
|
|
10073
10270
|
}, column.id)),
|
|
10074
|
-
/* @__PURE__ */
|
|
10075
|
-
|
|
10076
|
-
|
|
10077
|
-
|
|
10078
|
-
|
|
10079
|
-
|
|
10080
|
-
|
|
10081
|
-
|
|
10082
|
-
|
|
10083
|
-
|
|
10084
|
-
|
|
10085
|
-
|
|
10086
|
-
size: "icon",
|
|
10087
|
-
className: cn("rounded-(--docblocks-radius) border-(length:--docblocks-table-border-width) border-(--docblocks-table-border-color) bg-transparent dark:border-(--docblocks-table-border-color) dark:bg-transparent", "size-6 cursor-pointer p-1 text-(--docblocks-placeholder-color) hover:bg-transparent", "hover:text-(--docblocks-text-color) dark:hover:bg-transparent"),
|
|
10088
|
-
children: /* @__PURE__ */ jsx(Plus, { className: "size-4" })
|
|
10089
|
-
})
|
|
10090
|
-
}), /* @__PURE__ */ jsx(DropdownMenuContent, {
|
|
10091
|
-
align: "end",
|
|
10092
|
-
className: "min-w-32",
|
|
10093
|
-
children: ADD_COLUMN_TYPES.map((entry) => {
|
|
10094
|
-
const EntryIcon = columnTypeIcon(entry.type, entry.refKind, entry.refMany);
|
|
10095
|
-
return /* @__PURE__ */ jsxs(DropdownMenuItem, {
|
|
10096
|
-
"data-column-entry": entry.key,
|
|
10097
|
-
onClick: () => form.openCreateForm(entry),
|
|
10098
|
-
children: [/* @__PURE__ */ jsx(EntryIcon, { className: "size-4 shrink-0 text-muted-foreground" }), t(entry.labelKey)]
|
|
10099
|
-
}, entry.key);
|
|
10100
|
-
})
|
|
10101
|
-
})]
|
|
10102
|
-
}), /* @__PURE__ */ jsx(AddColumnForm, {
|
|
10103
|
-
open: form.columnFormOpen,
|
|
10104
|
-
onOpenChange: form.onColumnFormOpenChange,
|
|
10105
|
-
form: form.columnForm,
|
|
10106
|
-
formNumber: form.columnFormNumber,
|
|
10107
|
-
formRef: form.columnFormRef,
|
|
10108
|
-
error: form.columnFormError,
|
|
10109
|
-
bridgeTables: form.bridgeTables,
|
|
10110
|
-
OptionsEditor,
|
|
10111
|
-
onCommit: form.commitColumnForm,
|
|
10112
|
-
onNameChange: form.onColumnNameChange,
|
|
10113
|
-
onDecimalsChange: form.onColumnDecimalsChange,
|
|
10114
|
-
onThousandsChange: form.onColumnThousandsChange,
|
|
10115
|
-
onPrefixChange: form.onColumnPrefixChange,
|
|
10116
|
-
onSuffixChange: form.onColumnSuffixChange,
|
|
10117
|
-
onAllowNegativeChange: form.onColumnAllowNegativeChange,
|
|
10118
|
-
onEnumOptionsChange: form.onColumnEnumOptionsChange,
|
|
10119
|
-
onRefPickChange: form.onColumnRefPickChange,
|
|
10120
|
-
onNewTableNameChange: form.onColumnNewTableNameChange
|
|
10121
|
-
})]
|
|
10271
|
+
!readOnly && onHeaderHeightChange !== void 0 && /* @__PURE__ */ jsx(HeaderResizeHandle, {
|
|
10272
|
+
resizing: headerPreview !== null,
|
|
10273
|
+
onPointerDown: onHeaderPointerDown,
|
|
10274
|
+
onPointerMove: onHeaderPointerMove,
|
|
10275
|
+
onPointerUp: onHeaderPointerUp,
|
|
10276
|
+
onPointerCancel: onHeaderPointerCancel
|
|
10277
|
+
}),
|
|
10278
|
+
/* @__PURE__ */ jsx(AddColumnCell, {
|
|
10279
|
+
gridColumn: columns.length + 1,
|
|
10280
|
+
readOnly,
|
|
10281
|
+
form,
|
|
10282
|
+
OptionsEditor
|
|
10122
10283
|
}),
|
|
10123
10284
|
/* @__PURE__ */ jsx(GridRows, {
|
|
10124
10285
|
rows,
|
|
@@ -11190,7 +11351,7 @@ function useGridPendingRow({ pendingRow, data, columns, tableRef, setEditingCell
|
|
|
11190
11351
|
* toolbar over `GridToolbar`, the table over `GridTable` (+ `GridRows`),
|
|
11191
11352
|
* the pending row's lifecycle over `use-grid-pending-row`, the state's
|
|
11192
11353
|
* surfaces over `GridStateCards`. */
|
|
11193
|
-
function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns, columnWidths, onViewChange, readColumnOrder, readOnly = false }) {
|
|
11354
|
+
function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns, columnWidths, headerHeight, sectionHeaderHeight, onHeaderHeightChange, onViewChange, readColumnOrder, readOnly = false }) {
|
|
11194
11355
|
const { t } = useTranslation("database");
|
|
11195
11356
|
const data = useDatabaseTable(bridge, tableId, filter);
|
|
11196
11357
|
const tableRef = useRef(null);
|
|
@@ -11216,6 +11377,7 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
|
|
|
11216
11377
|
onViewChange
|
|
11217
11378
|
});
|
|
11218
11379
|
const columns = visibleColumns(data.table?.columns, columnOrder, hiddenColumns);
|
|
11380
|
+
const resolvedHeaderHeight = resolveDatabaseHeaderHeight(headerHeight, sectionHeaderHeight);
|
|
11219
11381
|
const updateView = (patch) => {
|
|
11220
11382
|
onViewChange(patch);
|
|
11221
11383
|
};
|
|
@@ -11288,6 +11450,8 @@ function GridBody({ blockId, bridge, tableId, filter, columnOrder, hiddenColumns
|
|
|
11288
11450
|
refTableData,
|
|
11289
11451
|
filter,
|
|
11290
11452
|
readOnly,
|
|
11453
|
+
headerHeight: resolvedHeaderHeight,
|
|
11454
|
+
onHeaderHeightChange,
|
|
11291
11455
|
tableRef,
|
|
11292
11456
|
onTableKeyDown,
|
|
11293
11457
|
onTablePaste,
|
|
@@ -11363,7 +11527,7 @@ function DatabaseDisconnected({ name }) {
|
|
|
11363
11527
|
});
|
|
11364
11528
|
}
|
|
11365
11529
|
function DatabaseGrid({ id, block }) {
|
|
11366
|
-
const { doc, databaseBridge, viewMode } = useEditorContext();
|
|
11530
|
+
const { doc, databaseBridge, databaseTableSection, viewMode } = useEditorContext();
|
|
11367
11531
|
const tableId = block.attrs.tableId;
|
|
11368
11532
|
if (tableId === void 0) return null;
|
|
11369
11533
|
if (databaseBridge === void 0) return /* @__PURE__ */ jsx(DatabaseDisconnected, { name: block.attrs.name });
|
|
@@ -11375,6 +11539,9 @@ function DatabaseGrid({ id, block }) {
|
|
|
11375
11539
|
columnOrder: block.attrs.columnOrder,
|
|
11376
11540
|
hiddenColumns: block.attrs.hiddenColumns,
|
|
11377
11541
|
columnWidths: block.attrs.columnWidths,
|
|
11542
|
+
headerHeight: block.attrs.headerHeight,
|
|
11543
|
+
sectionHeaderHeight: databaseTableSection?.getHeaderHeight?.(tableId),
|
|
11544
|
+
onHeaderHeightChange: (height) => doc.updateBlock(id, { headerHeight: height }),
|
|
11378
11545
|
onViewChange: (patch) => doc.updateBlock(id, patch),
|
|
11379
11546
|
readColumnOrder: () => {
|
|
11380
11547
|
const current = doc.getBlock(id);
|
|
@@ -17011,6 +17178,7 @@ function mapBlocksSelection(root, domSelection, anchorBlock) {
|
|
|
17011
17178
|
const range = domSelection.getRangeAt(0);
|
|
17012
17179
|
const ids = [];
|
|
17013
17180
|
for (const element of Array.from(root.querySelectorAll("[data-block-id]"))) {
|
|
17181
|
+
if (element.getAttribute("data-slot") === "docblocks/row") continue;
|
|
17014
17182
|
const blockId = element.dataset.blockId;
|
|
17015
17183
|
if (ids.includes(blockId)) continue;
|
|
17016
17184
|
if (range.intersectsNode(element)) ids.push(blockId);
|
|
@@ -17212,7 +17380,7 @@ function focusCellActivation(cellId, scope = document) {
|
|
|
17212
17380
|
//#region src/editing/block-commands/utils/focus-restore.ts
|
|
17213
17381
|
/** The parent block id per the DOM: the wrapper above the block's own wrapper; null at the doc root. */
|
|
17214
17382
|
function domParentBlockIdOf(el) {
|
|
17215
|
-
return (el.parentElement?.closest("[data-block-id]"))?.parentElement?.closest("[data-block-id]")?.dataset.blockId ?? null;
|
|
17383
|
+
return (el.parentElement?.closest("[data-block-id]"))?.parentElement?.closest("[data-block-id]:not([data-slot='docblocks/row'])")?.dataset.blockId ?? null;
|
|
17216
17384
|
}
|
|
17217
17385
|
/**
|
|
17218
17386
|
* Whether the candidate inner is the SURVIVOR of the remount, not a framer
|
|
@@ -24224,7 +24392,7 @@ const openLinkHref = (href) => {
|
|
|
24224
24392
|
* handler (the link's anchor's stand — the native menu's suppress over the
|
|
24225
24393
|
* link's own menu; the other's targets stand the native's stand). */
|
|
24226
24394
|
/** The selection's rect's bottom to the popover's anchor's gap (px). */
|
|
24227
|
-
const ANCHOR_GAP_PX = 8;
|
|
24395
|
+
const ANCHOR_GAP_PX$1 = 8;
|
|
24228
24396
|
/** The selection's reseat's window (the tracking's transient mapping's
|
|
24229
24397
|
* suppression over the popover / the menu's open's input's focus and the
|
|
24230
24398
|
* close's residue — the doc's selection's no-clobber's stand). */
|
|
@@ -24301,7 +24469,7 @@ function useLinkPopover(rootRef) {
|
|
|
24301
24469
|
const rootRect = root.getBoundingClientRect();
|
|
24302
24470
|
anchor = {
|
|
24303
24471
|
x: rect.left + rect.width / 2 - rootRect.left,
|
|
24304
|
-
y: rect.bottom - rootRect.top + ANCHOR_GAP_PX
|
|
24472
|
+
y: rect.bottom - rootRect.top + ANCHOR_GAP_PX$1
|
|
24305
24473
|
};
|
|
24306
24474
|
}
|
|
24307
24475
|
open(anchor, { target });
|
|
@@ -24661,6 +24829,39 @@ function createFormatToolbarActions({ doc, range, single, target, rootRef, onPal
|
|
|
24661
24829
|
};
|
|
24662
24830
|
}
|
|
24663
24831
|
//#endregion
|
|
24832
|
+
//#region src/editing/format-toolbar/format-toolbar-anchor.ts
|
|
24833
|
+
/** The format bar's anchoring: the placement over the selection's rect and
|
|
24834
|
+
* the root's stand. */
|
|
24835
|
+
/** The bar's inset from the editor root's edges and the selection's rect. */
|
|
24836
|
+
const ANCHOR_GAP_PX = 8;
|
|
24837
|
+
/** The upper room below which the bar stands under the selection. */
|
|
24838
|
+
const ABOVE_MIN_ROOM_PX = 4;
|
|
24839
|
+
/**
|
|
24840
|
+
* Places the bar above the selection's rect (below it when the upper room
|
|
24841
|
+
* is short) and never above the editor root's upper edge: the consumer's own
|
|
24842
|
+
* chrome stands there, and the bar is the editor's surface (it legitimately
|
|
24843
|
+
* overhangs the content's bottom — no chrome below). A model range the DOM
|
|
24844
|
+
* carries no rect for (the canvas/page switch re-seats the selection over a
|
|
24845
|
+
* re-mounted page, a parked focus) keeps the bar's last position: an empty
|
|
24846
|
+
* rect is no anchor, and its page-origin stand would put the bar over the
|
|
24847
|
+
* chrome above the editor. The unit runtime has no range geometry — the bar
|
|
24848
|
+
* keeps its default position there.
|
|
24849
|
+
*/
|
|
24850
|
+
function anchorFormatToolbar(el, root) {
|
|
24851
|
+
if (typeof Range.prototype.getBoundingClientRect !== "function") return;
|
|
24852
|
+
const selection = window.getSelection();
|
|
24853
|
+
if (selection === null || selection.rangeCount === 0 || !root.contains(selection.anchorNode)) return;
|
|
24854
|
+
const rect = selection.getRangeAt(0).getBoundingClientRect();
|
|
24855
|
+
if (rect.width === 0 && rect.height === 0) return;
|
|
24856
|
+
const rootRect = root.getBoundingClientRect();
|
|
24857
|
+
const width = el.offsetWidth;
|
|
24858
|
+
const height = el.offsetHeight;
|
|
24859
|
+
const above = rect.top - rootRect.top - height - ANCHOR_GAP_PX;
|
|
24860
|
+
const top = above < ABOVE_MIN_ROOM_PX ? rect.bottom - rootRect.top + ANCHOR_GAP_PX : above;
|
|
24861
|
+
el.style.left = `${clamp(rect.left + rect.width / 2 - width / 2 - rootRect.left, ANCHOR_GAP_PX, Math.max(ANCHOR_GAP_PX, rootRect.width - width - ANCHOR_GAP_PX))}px`;
|
|
24862
|
+
el.style.top = `${Math.max(top, ANCHOR_GAP_PX)}px`;
|
|
24863
|
+
}
|
|
24864
|
+
//#endregion
|
|
24664
24865
|
//#region src/editing/format-toolbar/FormatToolbar.tsx
|
|
24665
24866
|
/** The floating format toolbar — the selection's formatting affordance.
|
|
24666
24867
|
*
|
|
@@ -24672,7 +24873,10 @@ function createFormatToolbarActions({ doc, range, single, target, rootRef, onPal
|
|
|
24672
24873
|
* (below it when there is no room above) and disappears as soon as the
|
|
24673
24874
|
* selection collapses, leaves the target, or becomes a blocks selection —
|
|
24674
24875
|
* the visibility is derived from the selection state, so no key or mouse
|
|
24675
|
-
* capture is needed.
|
|
24876
|
+
* capture is needed. A model range the DOM carries no rect for (the
|
|
24877
|
+
* canvas/page switch re-seats the selection over a re-mounted page) keeps the
|
|
24878
|
+
* bar's last position — never the page origin's stand above the editor's own
|
|
24879
|
+
* box, over the consumer's chrome.
|
|
24676
24880
|
*
|
|
24677
24881
|
* Controls (shared/ui primitives): the five toggle marks (bold, monospace
|
|
24678
24882
|
* = the exclusive code mark, italic, underline, strikethrough) and the
|
|
@@ -24705,20 +24909,7 @@ function FormatToolbar({ rootRef, palette }) {
|
|
|
24705
24909
|
const el = barRef.current;
|
|
24706
24910
|
const root = rootRef.current;
|
|
24707
24911
|
if (el === null || root === null) return;
|
|
24708
|
-
|
|
24709
|
-
if (domSelection === null || domSelection.rangeCount === 0) return;
|
|
24710
|
-
if (!root.contains(domSelection.anchorNode)) return;
|
|
24711
|
-
const range = domSelection.getRangeAt(0);
|
|
24712
|
-
if (typeof range.getBoundingClientRect !== "function") return;
|
|
24713
|
-
const rect = range.getBoundingClientRect();
|
|
24714
|
-
const rootRect = root.getBoundingClientRect();
|
|
24715
|
-
const width = el.offsetWidth;
|
|
24716
|
-
const height = el.offsetHeight;
|
|
24717
|
-
const left = clamp(rect.left + rect.width / 2 - width / 2 - rootRect.left, 8, Math.max(8, rootRect.width - width - 8));
|
|
24718
|
-
const above = rect.top - rootRect.top - height - 8;
|
|
24719
|
-
const top = above < 4 ? rect.bottom - rootRect.top + 8 : above;
|
|
24720
|
-
el.style.left = `${left}px`;
|
|
24721
|
-
el.style.top = `${top}px`;
|
|
24912
|
+
anchorFormatToolbar(el, root);
|
|
24722
24913
|
});
|
|
24723
24914
|
if (range === null) return null;
|
|
24724
24915
|
if (range.kind === "single" && (block === void 0 || !TOOLBAR_BLOCK_TYPES.has(block.type))) return null;
|
|
@@ -30809,12 +31000,11 @@ const TableRow = memo(function TableRow({ id, rowTransform, columnTransforms, di
|
|
|
30809
31000
|
* and the add-column chip (the table's right edge). The add-row chip and
|
|
30810
31001
|
* the size's stand stand at the frame's level (they stay pinned while the
|
|
30811
31002
|
* content scrolls) — over the entry. */
|
|
30812
|
-
function TableSeams({
|
|
31003
|
+
function TableSeams({ widths, tableWidth, tableHeight, seamXs, resizePreview, addPreview, onSeamPointerDown, onSeamPointerMove, onSeamPointerUp, onSeamPointerCancel, onSeamKeyDown, onAddChipPointerDown, onAddChipPointerMove, onAddChipPointerUp, onAddChipPointerCancel, insertTableColumn }) {
|
|
30813
31004
|
const { t } = useTranslation("table");
|
|
30814
31005
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
30815
31006
|
widths.map((_, col) => {
|
|
30816
31007
|
const seamIndex = col + 1;
|
|
30817
|
-
if (blockedSeams.has(seamIndex)) return null;
|
|
30818
31008
|
const x = col + 1 < widths.length ? seamXs[seamIndex] ?? 20 + tableWidth : 20 + tableWidth;
|
|
30819
31009
|
return /* @__PURE__ */ jsx("div", {
|
|
30820
31010
|
"data-slot": "docblocks/table-col-resize",
|
|
@@ -31436,11 +31626,12 @@ function useTableMetrics({ scrollRef, tableWidth, rows }) {
|
|
|
31436
31626
|
//#endregion
|
|
31437
31627
|
//#region src/blocks/table/use-table-regions.ts
|
|
31438
31628
|
/**
|
|
31439
|
-
* The table's merged regions over the renderer's chrome:
|
|
31440
|
-
*
|
|
31441
|
-
*
|
|
31442
|
-
*
|
|
31443
|
-
*
|
|
31629
|
+
* The table's merged regions over the renderer's chrome: no reorder handle
|
|
31630
|
+
* for a column / row the region spans (a reorder through a region would shift
|
|
31631
|
+
* its rectangle; the core rejects it, and the chrome simply offers nothing).
|
|
31632
|
+
* The region's column seams stand unblocked — a covered column resizes on its
|
|
31633
|
+
* own seam, and the region's width follows the columns' sum (the core's
|
|
31634
|
+
* width set has no region guard).
|
|
31444
31635
|
*/
|
|
31445
31636
|
/**
|
|
31446
31637
|
* The region-derived chrome stands. The chrome stamp re-reads the grid over
|
|
@@ -31453,18 +31644,13 @@ function useTableRegions({ doc, tableId }) {
|
|
|
31453
31644
|
const chromeStamp = useStore(store, (state) => state.chromeStamp);
|
|
31454
31645
|
return useMemo(() => {
|
|
31455
31646
|
const grid = resolveTableGrid(doc.raw, tableId);
|
|
31456
|
-
const blockedSeams = /* @__PURE__ */ new Set();
|
|
31457
31647
|
const lockedColumns = /* @__PURE__ */ new Set();
|
|
31458
31648
|
const lockedRows = /* @__PURE__ */ new Set();
|
|
31459
31649
|
for (const anchor of grid?.rows.flat() ?? []) {
|
|
31460
|
-
if (anchor.colspan > 1)
|
|
31461
|
-
for (let col = anchor.col + 1; col < anchor.col + anchor.colspan; col += 1) blockedSeams.add(col);
|
|
31462
|
-
for (let col = anchor.col; col < anchor.col + anchor.colspan; col += 1) lockedColumns.add(col);
|
|
31463
|
-
}
|
|
31650
|
+
if (anchor.colspan > 1) for (let col = anchor.col; col < anchor.col + anchor.colspan; col += 1) lockedColumns.add(col);
|
|
31464
31651
|
if (anchor.rowspan > 1) for (let row = anchor.row; row < anchor.row + anchor.rowspan; row += 1) lockedRows.add(row);
|
|
31465
31652
|
}
|
|
31466
31653
|
return {
|
|
31467
|
-
blockedSeams,
|
|
31468
31654
|
lockedColumns,
|
|
31469
31655
|
lockedRows
|
|
31470
31656
|
};
|
|
@@ -31674,7 +31860,7 @@ function TableBlock({ id, block }) {
|
|
|
31674
31860
|
});
|
|
31675
31861
|
const columnCenters = columnCentersOf(widths);
|
|
31676
31862
|
const seamXs = seamXsOf(widths);
|
|
31677
|
-
const {
|
|
31863
|
+
const { lockedColumns, lockedRows } = useTableRegions({
|
|
31678
31864
|
doc,
|
|
31679
31865
|
tableId: id
|
|
31680
31866
|
});
|
|
@@ -31751,7 +31937,6 @@ function TableBlock({ id, block }) {
|
|
|
31751
31937
|
onRowHandleColor,
|
|
31752
31938
|
palette
|
|
31753
31939
|
}), /* @__PURE__ */ jsx(TableSeams, {
|
|
31754
|
-
blockedSeams,
|
|
31755
31940
|
widths,
|
|
31756
31941
|
tableWidth,
|
|
31757
31942
|
tableHeight,
|
|
@@ -35313,6 +35498,23 @@ function useEditorContext() {
|
|
|
35313
35498
|
return context;
|
|
35314
35499
|
}
|
|
35315
35500
|
//#endregion
|
|
35501
|
+
//#region src/editor-provider/published-stand.ts
|
|
35502
|
+
/** The published snapshot's stand key: one key per snapshot instance. A new
|
|
35503
|
+
* snapshot remounts the nested published provider (the doc's stand must not
|
|
35504
|
+
* change over a mounted provider — the doc's stand guard), while the same
|
|
35505
|
+
* snapshot keeps its stand over the re-renders. */
|
|
35506
|
+
const SNAPSHOT_KEYS = /* @__PURE__ */ new WeakMap();
|
|
35507
|
+
let SNAPSHOT_KEY_SEQ = 0;
|
|
35508
|
+
function publishedStandKey(doc) {
|
|
35509
|
+
let key = SNAPSHOT_KEYS.get(doc);
|
|
35510
|
+
if (key === void 0) {
|
|
35511
|
+
key = SNAPSHOT_KEY_SEQ;
|
|
35512
|
+
SNAPSHOT_KEY_SEQ += 1;
|
|
35513
|
+
SNAPSHOT_KEYS.set(doc, key);
|
|
35514
|
+
}
|
|
35515
|
+
return `published-${key}`;
|
|
35516
|
+
}
|
|
35517
|
+
//#endregion
|
|
35316
35518
|
//#region src/presence/utils.ts
|
|
35317
35519
|
/** Deterministic hue (0–359) from the peer id (pure function, no peer state). */
|
|
35318
35520
|
function peerHue(peerId) {
|
|
@@ -35482,7 +35684,7 @@ function PresenceCaretOverlay({ rootRef }) {
|
|
|
35482
35684
|
const next = [];
|
|
35483
35685
|
for (const peer of presence) {
|
|
35484
35686
|
for (const point of caretPointsOf(peer.selection)) {
|
|
35485
|
-
const block = root.querySelector(`[data-block-id="${CSS.escape(point.blockId)}"][data-slot="docblocks/block-content"]`) ?? root.querySelector(`[data-block-id="${CSS.escape(point.blockId)}"]`);
|
|
35687
|
+
const block = root.querySelector(`[data-block-id="${CSS.escape(point.blockId)}"][data-slot="docblocks/block-content"]`) ?? root.querySelector(`[data-block-id="${CSS.escape(point.blockId)}"]:not([data-slot="docblocks/row"])`);
|
|
35486
35688
|
if (block === null) continue;
|
|
35487
35689
|
next.push({
|
|
35488
35690
|
key: `${peer.peerId}:caret:${point.blockId}:${point.offset}`,
|
|
@@ -35749,17 +35951,6 @@ function useTrailingParagraph(doc, rootBlockId, editingStand) {
|
|
|
35749
35951
|
//#region src/editor-provider/EditorProvider.tsx
|
|
35750
35952
|
/** The per-instance editor provider: the doc + store + selection lifecycle
|
|
35751
35953
|
* + the per-instance customization context. */
|
|
35752
|
-
const SNAPSHOT_KEYS = /* @__PURE__ */ new WeakMap();
|
|
35753
|
-
let SNAPSHOT_KEY_SEQ = 0;
|
|
35754
|
-
function publishedStandKey(doc) {
|
|
35755
|
-
let key = SNAPSHOT_KEYS.get(doc);
|
|
35756
|
-
if (key === void 0) {
|
|
35757
|
-
key = SNAPSHOT_KEY_SEQ;
|
|
35758
|
-
SNAPSHOT_KEY_SEQ += 1;
|
|
35759
|
-
SNAPSHOT_KEYS.set(doc, key);
|
|
35760
|
-
}
|
|
35761
|
-
return `published-${key}`;
|
|
35762
|
-
}
|
|
35763
35954
|
/**
|
|
35764
35955
|
* The stand: owns the per-instance editor lifecycle — the zustand store
|
|
35765
35956
|
* (projection of the doc), the selection view, and the subscriptions that
|
|
@@ -35771,7 +35962,7 @@ function publishedStandKey(doc) {
|
|
|
35771
35962
|
* its own. Safe under StrictMode double-mount: the cleanup detaches every
|
|
35772
35963
|
* subscription and destroys the view between the two mounts.
|
|
35773
35964
|
*/
|
|
35774
|
-
function EditorProviderStand({ doc, provider, blockRenderers, blobStore, blobLoading, scrollContainer, databaseBridge, syncEmbedResolver, pdfPreview, mentionProvider, mentionInteractions, embedSandbox, rootBlockId, commandPalettePlaceholder, accessLevel, mode, publishedDoc, presence, hiddenAttributes, renderAttribute, attributeTypePicker, docTags, docDescription, coverPresets, children }) {
|
|
35965
|
+
function EditorProviderStand({ doc, provider, blockRenderers, blobStore, blobLoading, scrollContainer, databaseBridge, databaseTableSection, syncEmbedResolver, pdfPreview, mentionProvider, mentionInteractions, embedSandbox, rootBlockId, commandPalettePlaceholder, accessLevel, mode, publishedDoc, publishedCopyable, presence, hiddenAttributes, renderAttribute, attributeTypePicker, docTags, docDescription, coverPresets, children }) {
|
|
35775
35966
|
const rootId = rootBlockId ?? doc.meta.id;
|
|
35776
35967
|
const [store] = useState(() => createEditorStore(doc, rootId));
|
|
35777
35968
|
const docRef = useRef(doc);
|
|
@@ -35809,6 +36000,8 @@ function EditorProviderStand({ doc, provider, blockRenderers, blobStore, blobLoa
|
|
|
35809
36000
|
const effectiveBlobLoading = blobLoading ?? parentContext?.blobLoading ?? "lazy";
|
|
35810
36001
|
const effectiveScrollContainer = scrollContainer === void 0 ? parentContext?.scrollContainer ?? null : scrollContainer;
|
|
35811
36002
|
const effectiveDatabaseBridge = useMemo(() => databaseBridge ?? parentContext?.databaseBridge, [databaseBridge, parentContext]);
|
|
36003
|
+
const effectiveDatabaseTableSection = databaseTableSection ?? parentContext?.databaseTableSection ?? null;
|
|
36004
|
+
const effectivePublishedCopyable = publishedCopyable ?? parentContext?.publishedCopyable ?? false;
|
|
35812
36005
|
const value = useMemo(() => {
|
|
35813
36006
|
const parent = parentContext;
|
|
35814
36007
|
return {
|
|
@@ -35820,6 +36013,7 @@ function EditorProviderStand({ doc, provider, blockRenderers, blobStore, blobLoa
|
|
|
35820
36013
|
blobLoading: effectiveBlobLoading,
|
|
35821
36014
|
scrollContainer: effectiveScrollContainer,
|
|
35822
36015
|
databaseBridge: effectiveDatabaseBridge,
|
|
36016
|
+
databaseTableSection: effectiveDatabaseTableSection,
|
|
35823
36017
|
syncEmbedResolver: syncEmbedResolver ?? parent?.syncEmbedResolver ?? null,
|
|
35824
36018
|
pdfPreview: pdfPreview ?? parent?.pdfPreview ?? null,
|
|
35825
36019
|
mentionProvider: mentionProvider ?? parent?.mentionProvider ?? null,
|
|
@@ -35837,6 +36031,7 @@ function EditorProviderStand({ doc, provider, blockRenderers, blobStore, blobLoa
|
|
|
35837
36031
|
commandPalettePlaceholder: commandPalettePlaceholder ?? parent?.commandPalettePlaceholder ?? null,
|
|
35838
36032
|
accessLevel: effectiveAccessLevel,
|
|
35839
36033
|
mode: effectiveMode,
|
|
36034
|
+
publishedCopyable: effectivePublishedCopyable,
|
|
35840
36035
|
viewMode: effectiveMode !== "edit",
|
|
35841
36036
|
presence: presence ?? null
|
|
35842
36037
|
};
|
|
@@ -35848,6 +36043,7 @@ function EditorProviderStand({ doc, provider, blockRenderers, blobStore, blobLoa
|
|
|
35848
36043
|
effectiveBlobLoading,
|
|
35849
36044
|
effectiveScrollContainer,
|
|
35850
36045
|
effectiveDatabaseBridge,
|
|
36046
|
+
effectiveDatabaseTableSection,
|
|
35851
36047
|
syncEmbedResolver,
|
|
35852
36048
|
rootId,
|
|
35853
36049
|
parentContext,
|
|
@@ -35858,6 +36054,7 @@ function EditorProviderStand({ doc, provider, blockRenderers, blobStore, blobLoa
|
|
|
35858
36054
|
embedSandbox,
|
|
35859
36055
|
effectiveAccessLevel,
|
|
35860
36056
|
effectiveMode,
|
|
36057
|
+
effectivePublishedCopyable,
|
|
35861
36058
|
presence,
|
|
35862
36059
|
hiddenAttributes,
|
|
35863
36060
|
renderAttribute,
|
|
@@ -38593,12 +38790,13 @@ function clipboardContentOf(doc, selection) {
|
|
|
38593
38790
|
* selection view (the mapping owns it); the view's mode maps the DOM
|
|
38594
38791
|
* selection at copy time — the read-only stand keeps no live view (the
|
|
38595
38792
|
* browser's native range is the only selection there). The published
|
|
38596
|
-
* stand
|
|
38793
|
+
* stand intercepts only over the consumer's copyable policy — the default
|
|
38794
|
+
* keeps the reader's selection and copy off.
|
|
38597
38795
|
*/
|
|
38598
38796
|
function createCopyHandler(deps) {
|
|
38599
|
-
const { doc, mode, viewMode, rootRef, selectionRef } = deps;
|
|
38797
|
+
const { doc, mode, viewMode, publishedCopyable, rootRef, selectionRef } = deps;
|
|
38600
38798
|
return (event) => {
|
|
38601
|
-
if (mode === "published") return;
|
|
38799
|
+
if (mode === "published" && !publishedCopyable) return;
|
|
38602
38800
|
const root = rootRef.current;
|
|
38603
38801
|
const view = selectionRef.view;
|
|
38604
38802
|
if (root === null || view === null) return;
|
|
@@ -38766,7 +38964,7 @@ function useSelectionTracking(doc, rootRef, selectionRef, viewMode) {
|
|
|
38766
38964
|
* so a render-time value would be a stale null.
|
|
38767
38965
|
*/
|
|
38768
38966
|
function useEditing() {
|
|
38769
|
-
const { doc, rootBlockId, selection: selectionRef, viewMode, mode } = useEditorContext();
|
|
38967
|
+
const { doc, rootBlockId, selection: selectionRef, viewMode, mode, publishedCopyable } = useEditorContext();
|
|
38770
38968
|
const rootRef = useRef(null);
|
|
38771
38969
|
const crossDrag = useCrossDrag(rootRef, doc, viewMode);
|
|
38772
38970
|
useSelectionTracking(doc, rootRef, selectionRef, viewMode);
|
|
@@ -38820,6 +39018,7 @@ function useEditing() {
|
|
|
38820
39018
|
doc,
|
|
38821
39019
|
mode,
|
|
38822
39020
|
viewMode,
|
|
39021
|
+
publishedCopyable,
|
|
38823
39022
|
rootRef,
|
|
38824
39023
|
selectionRef
|
|
38825
39024
|
}),
|
|
@@ -39099,6 +39298,8 @@ const RowItem = memo(function RowItem({ node, layoutSlide, isDragged, animated,
|
|
|
39099
39298
|
as: "div",
|
|
39100
39299
|
ref: rowRef,
|
|
39101
39300
|
"data-slot": "docblocks/row",
|
|
39301
|
+
"data-block-id": node.id,
|
|
39302
|
+
"data-block-type": block !== void 0 ? block.type : void 0,
|
|
39102
39303
|
"data-selected": selected ? "true" : void 0,
|
|
39103
39304
|
"data-divider": block !== void 0 && block.type === "divider" ? "true" : void 0,
|
|
39104
39305
|
value: node.id,
|
|
@@ -39859,7 +40060,7 @@ function useMotionDrag({ doc, rootBlockId, store, rootRef, rowKeys, nodesById })
|
|
|
39859
40060
|
* palette.
|
|
39860
40061
|
*/
|
|
39861
40062
|
function Editor({ view = "page", formatPalette = FORMAT_PALETTE }) {
|
|
39862
|
-
const { doc, store, rootBlockId, viewMode, mode, mentionInteractions } = useEditorContext();
|
|
40063
|
+
const { doc, store, rootBlockId, viewMode, mode, publishedCopyable, mentionInteractions } = useEditorContext();
|
|
39863
40064
|
const rootChildren = useStore(store, (state) => state.rootChildren);
|
|
39864
40065
|
const attributes = useStore(store, (state) => state.meta.attributes);
|
|
39865
40066
|
const coverTintEnabled = (typeof attributes?.cover === "string" ? attributes.cover : void 0) !== void 0 && attributes?.coverTint !== false;
|
|
@@ -39937,6 +40138,7 @@ function Editor({ view = "page", formatPalette = FORMAT_PALETTE }) {
|
|
|
39937
40138
|
"data-view": view,
|
|
39938
40139
|
"data-mode": mode,
|
|
39939
40140
|
"data-readonly": viewMode ? "true" : void 0,
|
|
40141
|
+
"data-copyable": mode === "published" && publishedCopyable ? "true" : void 0,
|
|
39940
40142
|
"data-mention-interactive": mentionInteractions !== null ? "true" : void 0,
|
|
39941
40143
|
tabIndex: -1,
|
|
39942
40144
|
className: cn("relative min-h-0 flex-1 selection:bg-(--docblocks-selection-background)", "font-(family-name:--docblocks-font-family) text-(length:--docblocks-font-size)", "leading-(--docblocks-line-height) text-(--docblocks-text-color)"),
|