docblocks-react-ui 0.13.0 → 0.15.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 +81 -0
- package/dist/{Editor-dcSgC9ho.mjs → Editor-BF7wBMcp.mjs} +760 -600
- package/dist/{index-BA6ZzJK8.d.mts → index-C3vzW1Mv.d.mts} +181 -148
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/mermaid/index.mjs +74 -18
- package/dist/pdf/index.d.mts +1 -1
- package/dist/styles.css +31 -2
- package/package.json +1 -1
|
@@ -3006,7 +3006,7 @@ function editableOfNode$1(node) {
|
|
|
3006
3006
|
return (node === null ? null : node.nodeType === Node.ELEMENT_NODE ? node : node.parentElement)?.closest("[contenteditable=\"true\"]") ?? null;
|
|
3007
3007
|
}
|
|
3008
3008
|
//#endregion
|
|
3009
|
-
//#region src/editing/selection-mapping.ts
|
|
3009
|
+
//#region src/editing/selection-mapping/anchor-hint.ts
|
|
3010
3010
|
let writerAnchorHint = null;
|
|
3011
3011
|
/** The degenerate seat's intended anchor's record (the mapping's reverse's stand). */
|
|
3012
3012
|
function setWriterAnchorHint(root, anchorNode, anchorOffset, startNode, startOffset, endNode, endOffset) {
|
|
@@ -3029,112 +3029,48 @@ function writerAnchorHintFor(root, range) {
|
|
|
3029
3029
|
if (hint.anchorNode !== range.endContainer || hint.anchorOffset !== range.endOffset) return null;
|
|
3030
3030
|
return hint;
|
|
3031
3031
|
}
|
|
3032
|
+
//#endregion
|
|
3033
|
+
//#region src/editing/selection-mapping/blocks-dom.ts
|
|
3032
3034
|
/**
|
|
3033
|
-
*
|
|
3034
|
-
*
|
|
3035
|
-
*
|
|
3036
|
-
* - a selection with both endpoints in one text block maps to the per-block
|
|
3037
|
-
* text range (a caret when collapsed);
|
|
3038
|
-
* - a selection with endpoints in (possibly different) text blocks maps to
|
|
3039
|
-
* the text range over the resolved points;
|
|
3040
|
-
* - an endpoint in a non-text region (image, divider, table, …) resolves to
|
|
3041
|
-
* the nearest text boundary in reading order: the document-order-first
|
|
3042
|
-
* endpoint to the END of the nearest preceding text block (or the START
|
|
3043
|
-
* of the nearest following one when there is no preceding one), the
|
|
3044
|
-
* document-order-last endpoint the other way around; a range that reaches
|
|
3045
|
-
* into a non-text region only through its endpoints (the range itself
|
|
3046
|
-
* spans a text block) is resolved the same way;
|
|
3047
|
-
* - a selection touching no text block maps to a `blocks` selection over
|
|
3048
|
-
* the blocks the range touches (no per-block text range);
|
|
3049
|
-
* - a selection inside a nested editor (a sync-embed) or outside the
|
|
3050
|
-
* editor root maps to `none` (the nested editor owns the selection);
|
|
3051
|
-
* - a selection whose endpoint stands in the empty-cell activation layer
|
|
3052
|
-
* maps to `none` (the layer holds a view-local caret — the cell holds no
|
|
3053
|
-
* doc blocks while the layer stands);
|
|
3054
|
-
* - `reverse` comes from the anchor/focus order (a right-to-left drag).
|
|
3055
|
-
*
|
|
3056
|
-
* The engine fills the cross-block `blocks` chain on `set` — the mapping
|
|
3057
|
-
* never computes it. Offsets of boundary endpoints come from the doc
|
|
3058
|
-
* (getTextLength), not a DOM text walk.
|
|
3059
|
-
*
|
|
3060
|
-
* `readOnly` counts the view mode's inners (the non-editable block
|
|
3061
|
-
* content) as text blocks too: the read-only stand keeps no caret and no
|
|
3062
|
-
* live selection view, but its native range is still a range over the
|
|
3063
|
-
* document's text — the copy's read maps it (and the contenteditable
|
|
3064
|
-
* requirement stands over the edit's mode).
|
|
3035
|
+
* Whether the node sits in the editor root's own scope: inside a deeper
|
|
3036
|
+
* nested editor root (a sync-embed rendering another doc) the node
|
|
3037
|
+
* belongs to that editor, not this one.
|
|
3065
3038
|
*/
|
|
3066
|
-
function
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
to: null
|
|
3100
|
-
};
|
|
3101
|
-
let anchorIsFirst = range.startContainer === anchorNode && range.startOffset === anchorOffset;
|
|
3102
|
-
if (anchorIsFirst && writerAnchorHintFor(root, range) !== null) anchorIsFirst = false;
|
|
3103
|
-
return {
|
|
3104
|
-
kind: "text",
|
|
3105
|
-
from,
|
|
3106
|
-
to,
|
|
3107
|
-
...!anchorIsFirst ? { reverse: true } : {}
|
|
3108
|
-
};
|
|
3039
|
+
function ownScopeOf(node, root) {
|
|
3040
|
+
return ((node.nodeType === Node.ELEMENT_NODE ? node : node.parentElement)?.closest("[data-slot=\"docblocks/editor\"]") ?? null) === root;
|
|
3041
|
+
}
|
|
3042
|
+
/**
|
|
3043
|
+
* Whether the element is a text block (the inner contenteditable
|
|
3044
|
+
* [data-block-id] element). Over the read-only stand the inner is
|
|
3045
|
+
* non-editable (the view mode's copy stands the sole reader): its block
|
|
3046
|
+
* content element counts too.
|
|
3047
|
+
*/
|
|
3048
|
+
function isTextBlockElement(element, readOnly = false) {
|
|
3049
|
+
if (element.dataset.blockId === void 0) return false;
|
|
3050
|
+
if (element.getAttribute("contenteditable") === "true") return true;
|
|
3051
|
+
return readOnly && element.getAttribute("data-slot") === "docblocks/block-content";
|
|
3052
|
+
}
|
|
3053
|
+
/**
|
|
3054
|
+
* The text blocks of the editor's OWN scope (the inner text elements, in
|
|
3055
|
+
* DOM order). Blocks of a nested editor (a sync-embed rendering another
|
|
3056
|
+
* doc) are excluded: a boundary resolved to a foreign block id would not
|
|
3057
|
+
* exist in this doc's `doc`, so the mapping must never consider them
|
|
3058
|
+
* (compare the `ownScopeOf` endpoint guard in `mapDomSelection`).
|
|
3059
|
+
*/
|
|
3060
|
+
function textBlockElementsIn(root, readOnly = false) {
|
|
3061
|
+
return Array.from(root.querySelectorAll("[data-block-id]")).filter((element) => isTextBlockElement(element, readOnly) && ownScopeOf(element, root));
|
|
3062
|
+
}
|
|
3063
|
+
/**
|
|
3064
|
+
* The closest text block that contains the node; null when the node is in
|
|
3065
|
+
* a non-text block or outside the editor root.
|
|
3066
|
+
*/
|
|
3067
|
+
function textBlockOf(node, root, readOnly = false) {
|
|
3068
|
+
let current = node;
|
|
3069
|
+
while (current !== null && current !== root) {
|
|
3070
|
+
if (current instanceof HTMLElement && isTextBlockElement(current, readOnly)) return current;
|
|
3071
|
+
current = current.parentNode;
|
|
3109
3072
|
}
|
|
3110
|
-
|
|
3111
|
-
let anchorIsFirst = range.startContainer === anchorNode && range.startOffset === anchorOffset;
|
|
3112
|
-
if (anchorIsFirst && writerAnchorHintFor(root, range) !== null) anchorIsFirst = false;
|
|
3113
|
-
const first = {
|
|
3114
|
-
node: anchorIsFirst ? anchorNode : focusNode,
|
|
3115
|
-
offset: anchorIsFirst ? anchorOffset : focusOffset,
|
|
3116
|
-
textBlock: anchorIsFirst ? anchorBlock : focusBlock
|
|
3117
|
-
};
|
|
3118
|
-
const last = {
|
|
3119
|
-
node: anchorIsFirst ? focusNode : anchorNode,
|
|
3120
|
-
offset: anchorIsFirst ? focusOffset : anchorOffset,
|
|
3121
|
-
textBlock: anchorIsFirst ? focusBlock : anchorBlock
|
|
3122
|
-
};
|
|
3123
|
-
if (first.textBlock === null && last.textBlock === null && !rangeTouchesTextBlock(root, range, readOnly)) return mapBlocksSelection(root, domSelection, anchorBlock);
|
|
3124
|
-
const from = resolveEndpoint(doc, root, first, "first", readOnly);
|
|
3125
|
-
const to = resolveEndpoint(doc, root, last, "last", readOnly);
|
|
3126
|
-
if (from === null || to === null) return mapBlocksSelection(root, domSelection, anchorBlock);
|
|
3127
|
-
if (from.blockId === to.blockId && from.offset === to.offset) return {
|
|
3128
|
-
kind: "text",
|
|
3129
|
-
from,
|
|
3130
|
-
to: null
|
|
3131
|
-
};
|
|
3132
|
-
return {
|
|
3133
|
-
kind: "text",
|
|
3134
|
-
from,
|
|
3135
|
-
to,
|
|
3136
|
-
...!anchorIsFirst ? { reverse: true } : {}
|
|
3137
|
-
};
|
|
3073
|
+
return null;
|
|
3138
3074
|
}
|
|
3139
3075
|
/**
|
|
3140
3076
|
* Whether the endpoint stands inside the empty-cell activation layer: the
|
|
@@ -3155,6 +3091,34 @@ function inActivationLayer(node) {
|
|
|
3155
3091
|
function inDatabaseBlock(node) {
|
|
3156
3092
|
return (node.nodeType === Node.ELEMENT_NODE ? node : node.parentElement)?.closest("[data-slot=\"docblocks/database\"]") !== null;
|
|
3157
3093
|
}
|
|
3094
|
+
/** The block id of a text-editable element. */
|
|
3095
|
+
function blockIdOf(element) {
|
|
3096
|
+
return element.dataset.blockId;
|
|
3097
|
+
}
|
|
3098
|
+
/** The nearest text block strictly before the node in reading order. */
|
|
3099
|
+
function nearestBefore(node, blocks) {
|
|
3100
|
+
for (let i = blocks.length - 1; i >= 0; i--) {
|
|
3101
|
+
const element = blocks[i];
|
|
3102
|
+
if (node.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_PRECEDING) return element;
|
|
3103
|
+
}
|
|
3104
|
+
return null;
|
|
3105
|
+
}
|
|
3106
|
+
/** The nearest text block strictly after the node in reading order. */
|
|
3107
|
+
function nearestAfter(node, blocks) {
|
|
3108
|
+
for (const element of blocks) if (node.compareDocumentPosition(element) & Node.DOCUMENT_POSITION_FOLLOWING) return element;
|
|
3109
|
+
return null;
|
|
3110
|
+
}
|
|
3111
|
+
/** The contenteditable that owns a node (the node's element or its parent's), or null. */
|
|
3112
|
+
function editableOfNode(node) {
|
|
3113
|
+
return (node === null ? null : node.nodeType === Node.ELEMENT_NODE ? node : node.parentElement)?.closest("[contenteditable=\"true\"]") ?? null;
|
|
3114
|
+
}
|
|
3115
|
+
/** Whether the range intersects a text block of the editor. */
|
|
3116
|
+
function rangeTouchesTextBlock(root, range, readOnly = false) {
|
|
3117
|
+
for (const element of textBlockElementsIn(root, readOnly)) if (range.intersectsNode(element)) return true;
|
|
3118
|
+
return false;
|
|
3119
|
+
}
|
|
3120
|
+
//#endregion
|
|
3121
|
+
//#region src/editing/selection-mapping/mapping.ts
|
|
3158
3122
|
/** A selection with both endpoints in one text block. */
|
|
3159
3123
|
function mapTextSelection(block, anchorNode, anchorOffset, focusNode, focusOffset) {
|
|
3160
3124
|
const anchor = caretOffsetIn(block, anchorNode, anchorOffset);
|
|
@@ -3179,8 +3143,10 @@ function mapTextSelection(block, anchorNode, anchorOffset, focusNode, focusOffse
|
|
|
3179
3143
|
/**
|
|
3180
3144
|
* Resolve one endpoint to a text point. An endpoint inside a text block is
|
|
3181
3145
|
* its caret offset there. An endpoint in a non-text region takes the
|
|
3182
|
-
* nearest text boundary in reading order per the endpoint's role
|
|
3183
|
-
*
|
|
3146
|
+
* nearest text boundary in reading order per the endpoint's role: the
|
|
3147
|
+
* first endpoint takes the nearest preceding text block's end (the
|
|
3148
|
+
* following block's start when none precedes), the last endpoint the
|
|
3149
|
+
* other way around. Null when no boundary exists in either direction.
|
|
3184
3150
|
*/
|
|
3185
3151
|
function resolveEndpoint(doc, root, endpoint, role, readOnly = false) {
|
|
3186
3152
|
if (endpoint.textBlock !== null) return {
|
|
@@ -3211,10 +3177,6 @@ function resolveEndpoint(doc, root, endpoint, role, readOnly = false) {
|
|
|
3211
3177
|
offset: doc.getTextLength(blockIdOf(preceding))
|
|
3212
3178
|
};
|
|
3213
3179
|
}
|
|
3214
|
-
/** The block id of a text-editable element. */
|
|
3215
|
-
function blockIdOf(element) {
|
|
3216
|
-
return element.dataset.blockId;
|
|
3217
|
-
}
|
|
3218
3180
|
/** A selection spanning blocks: the touched block ids in document order. */
|
|
3219
3181
|
function mapBlocksSelection(root, domSelection, anchorBlock) {
|
|
3220
3182
|
const range = domSelection.getRangeAt(0);
|
|
@@ -3232,67 +3194,82 @@ function mapBlocksSelection(root, domSelection, anchorBlock) {
|
|
|
3232
3194
|
anchorId: ids.includes(anchorId) ? anchorId : ids[0]
|
|
3233
3195
|
};
|
|
3234
3196
|
}
|
|
3235
|
-
/**
|
|
3236
|
-
function
|
|
3237
|
-
|
|
3238
|
-
return
|
|
3239
|
-
}
|
|
3240
|
-
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
|
|
3252
|
-
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3256
|
-
|
|
3257
|
-
|
|
3258
|
-
|
|
3259
|
-
|
|
3260
|
-
|
|
3261
|
-
}
|
|
3262
|
-
|
|
3263
|
-
|
|
3264
|
-
|
|
3265
|
-
|
|
3266
|
-
if (
|
|
3267
|
-
|
|
3268
|
-
|
|
3269
|
-
|
|
3270
|
-
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
|
|
3275
|
-
|
|
3276
|
-
|
|
3277
|
-
|
|
3278
|
-
|
|
3279
|
-
*/
|
|
3280
|
-
function ownScopeOf(node, root) {
|
|
3281
|
-
return ((node.nodeType === Node.ELEMENT_NODE ? node : node.parentElement)?.closest("[data-slot=\"docblocks/editor\"]") ?? null) === root;
|
|
3282
|
-
}
|
|
3283
|
-
/**
|
|
3284
|
-
* The closest text block (a contenteditable [data-block-id] element) that
|
|
3285
|
-
* contains the node; null when the node is in a non-text block or outside
|
|
3286
|
-
* the editor root.
|
|
3287
|
-
*/
|
|
3288
|
-
function textBlockOf(node, root, readOnly = false) {
|
|
3289
|
-
let current = node;
|
|
3290
|
-
while (current !== null && current !== root) {
|
|
3291
|
-
if (current instanceof HTMLElement && isTextBlockElement(current, readOnly)) return current;
|
|
3292
|
-
current = current.parentNode;
|
|
3197
|
+
/** Map the DOM selection to a core Selection (the contract above). */
|
|
3198
|
+
function mapDomSelection(root, domSelection, doc, options = {}) {
|
|
3199
|
+
const readOnly = options.readOnly === true;
|
|
3200
|
+
if (domSelection === null || domSelection.rangeCount === 0) return { kind: "none" };
|
|
3201
|
+
const { anchorNode, anchorOffset, focusNode, focusOffset } = domSelection;
|
|
3202
|
+
if (anchorNode === null || focusNode === null) return { kind: "none" };
|
|
3203
|
+
if (!root.contains(anchorNode) || !root.contains(focusNode)) return { kind: "none" };
|
|
3204
|
+
if (!ownScopeOf(anchorNode, root) || !ownScopeOf(focusNode, root)) return { kind: "none" };
|
|
3205
|
+
if (inActivationLayer(anchorNode) || inActivationLayer(focusNode)) return { kind: "none" };
|
|
3206
|
+
if (inDatabaseBlock(anchorNode) || inDatabaseBlock(focusNode)) return { kind: "none" };
|
|
3207
|
+
const range = domSelection.getRangeAt(0);
|
|
3208
|
+
const anchorBlock = textBlockOf(anchorNode, root, readOnly);
|
|
3209
|
+
const focusBlock = textBlockOf(focusNode, root, readOnly);
|
|
3210
|
+
if ((anchorNode instanceof Element ? anchorNode : anchorNode.parentElement ?? null)?.closest("[data-slot=\"docblocks/canvas-view\"]") !== null && anchorBlock === null && editableOfNode(anchorNode) === null) return { kind: "none" };
|
|
3211
|
+
const startEditable = editableOfNode(range.startContainer);
|
|
3212
|
+
const endEditable = range.startContainer === range.endContainer ? startEditable : editableOfNode(range.endContainer);
|
|
3213
|
+
if (startEditable !== null && endEditable !== null && startEditable !== endEditable) {
|
|
3214
|
+
const first = {
|
|
3215
|
+
node: range.startContainer,
|
|
3216
|
+
offset: range.startOffset,
|
|
3217
|
+
textBlock: textBlockOf(range.startContainer, root, readOnly)
|
|
3218
|
+
};
|
|
3219
|
+
const last = {
|
|
3220
|
+
node: range.endContainer,
|
|
3221
|
+
offset: range.endOffset,
|
|
3222
|
+
textBlock: textBlockOf(range.endContainer, root, readOnly)
|
|
3223
|
+
};
|
|
3224
|
+
if (first.textBlock === null && last.textBlock === null && !rangeTouchesTextBlock(root, range, readOnly)) return mapBlocksSelection(root, domSelection, anchorBlock);
|
|
3225
|
+
const from = resolveEndpoint(doc, root, first, "first", readOnly);
|
|
3226
|
+
const to = resolveEndpoint(doc, root, last, "last", readOnly);
|
|
3227
|
+
if (from === null || to === null) return mapBlocksSelection(root, domSelection, anchorBlock);
|
|
3228
|
+
if (from.blockId === to.blockId && from.offset === to.offset) return {
|
|
3229
|
+
kind: "text",
|
|
3230
|
+
from,
|
|
3231
|
+
to: null
|
|
3232
|
+
};
|
|
3233
|
+
let anchorIsFirst = range.startContainer === anchorNode && range.startOffset === anchorOffset;
|
|
3234
|
+
if (anchorIsFirst && writerAnchorHintFor(root, range) !== null) anchorIsFirst = false;
|
|
3235
|
+
return {
|
|
3236
|
+
kind: "text",
|
|
3237
|
+
from,
|
|
3238
|
+
to,
|
|
3239
|
+
...!anchorIsFirst ? { reverse: true } : {}
|
|
3240
|
+
};
|
|
3293
3241
|
}
|
|
3294
|
-
return
|
|
3242
|
+
if (anchorBlock !== null && focusBlock === anchorBlock) return mapTextSelection(anchorBlock, anchorNode, anchorOffset, focusNode, focusOffset);
|
|
3243
|
+
let anchorIsFirst = range.startContainer === anchorNode && range.startOffset === anchorOffset;
|
|
3244
|
+
if (anchorIsFirst && writerAnchorHintFor(root, range) !== null) anchorIsFirst = false;
|
|
3245
|
+
const first = {
|
|
3246
|
+
node: anchorIsFirst ? anchorNode : focusNode,
|
|
3247
|
+
offset: anchorIsFirst ? anchorOffset : focusOffset,
|
|
3248
|
+
textBlock: anchorIsFirst ? anchorBlock : focusBlock
|
|
3249
|
+
};
|
|
3250
|
+
const last = {
|
|
3251
|
+
node: anchorIsFirst ? focusNode : anchorNode,
|
|
3252
|
+
offset: anchorIsFirst ? focusOffset : anchorOffset,
|
|
3253
|
+
textBlock: anchorIsFirst ? focusBlock : anchorBlock
|
|
3254
|
+
};
|
|
3255
|
+
if (first.textBlock === null && last.textBlock === null && !rangeTouchesTextBlock(root, range, readOnly)) return mapBlocksSelection(root, domSelection, anchorBlock);
|
|
3256
|
+
const from = resolveEndpoint(doc, root, first, "first", readOnly);
|
|
3257
|
+
const to = resolveEndpoint(doc, root, last, "last", readOnly);
|
|
3258
|
+
if (from === null || to === null) return mapBlocksSelection(root, domSelection, anchorBlock);
|
|
3259
|
+
if (from.blockId === to.blockId && from.offset === to.offset) return {
|
|
3260
|
+
kind: "text",
|
|
3261
|
+
from,
|
|
3262
|
+
to: null
|
|
3263
|
+
};
|
|
3264
|
+
return {
|
|
3265
|
+
kind: "text",
|
|
3266
|
+
from,
|
|
3267
|
+
to,
|
|
3268
|
+
...!anchorIsFirst ? { reverse: true } : {}
|
|
3269
|
+
};
|
|
3295
3270
|
}
|
|
3271
|
+
//#endregion
|
|
3272
|
+
//#region src/editing/selection-mapping/compare.ts
|
|
3296
3273
|
/**
|
|
3297
3274
|
* Structural equality over the fields a DOM mapping produces. The
|
|
3298
3275
|
* engine-maintained `blocks` chain of a text selection is derived from
|
|
@@ -3339,10 +3316,6 @@ function domSelectionInEditable(domSelection) {
|
|
|
3339
3316
|
};
|
|
3340
3317
|
return inText(domSelection?.anchorNode ?? null) && inText(domSelection?.focusNode ?? null);
|
|
3341
3318
|
}
|
|
3342
|
-
/** The contenteditable that owns a node (the node's element or its parent's), or null. */
|
|
3343
|
-
function editableOfNode(node) {
|
|
3344
|
-
return (node === null ? null : node.nodeType === Node.ELEMENT_NODE ? node : node.parentElement)?.closest("[contenteditable=\"true\"]") ?? null;
|
|
3345
|
-
}
|
|
3346
3319
|
//#endregion
|
|
3347
3320
|
//#region src/editing/block-commands/utils/focus.ts
|
|
3348
3321
|
/** Run `fn` in the next animation frame (setTimeout where frames do not exist). */
|
|
@@ -7457,10 +7430,23 @@ function Input({ className, size, variant, type, ...props }) {
|
|
|
7457
7430
|
* seated at the end (no select-all) on mount, the commit on the blur /
|
|
7458
7431
|
* the Enter (one write), the Escape cancels without a write (the guard
|
|
7459
7432
|
* stops the blur's commit over the unmount).
|
|
7433
|
+
*
|
|
7434
|
+
* The seed's reseed over an open edit: the incoming value may change
|
|
7435
|
+
* while the field stands (the built-in document path — a peer's write, a
|
|
7436
|
+
* command — or the consumer's own read, e.g. the description's). A
|
|
7437
|
+
* PRISTINE field (the user has not typed away from the seed) follows the
|
|
7438
|
+
* incoming value, the caret kept in place; a typed draft stands (the
|
|
7439
|
+
* user's text is never clobbered mid-edit — the input wins until the
|
|
7440
|
+
* commit or the cancel).
|
|
7460
7441
|
*/
|
|
7461
7442
|
function InlineEditInput({ initial, ariaLabel, slot, className, placeholder, invalid, variant, selectOnMount, onCommit, onCancel }) {
|
|
7462
7443
|
const inputRef = useRef(null);
|
|
7463
7444
|
const committedRef = useRef(false);
|
|
7445
|
+
const [value, setValue] = useState(initial);
|
|
7446
|
+
const valueRef = useRef(value);
|
|
7447
|
+
valueRef.current = value;
|
|
7448
|
+
const seedRef = useRef(initial);
|
|
7449
|
+
const caretRef = useRef(null);
|
|
7464
7450
|
const selectRef = useRef(selectOnMount);
|
|
7465
7451
|
useEffect(() => {
|
|
7466
7452
|
const input = inputRef.current;
|
|
@@ -7472,6 +7458,23 @@ function InlineEditInput({ initial, ariaLabel, slot, className, placeholder, inv
|
|
|
7472
7458
|
}
|
|
7473
7459
|
input.setSelectionRange(input.value.length, input.value.length);
|
|
7474
7460
|
}, []);
|
|
7461
|
+
useEffect(() => {
|
|
7462
|
+
if (initial === seedRef.current) return;
|
|
7463
|
+
const previous = seedRef.current;
|
|
7464
|
+
seedRef.current = initial;
|
|
7465
|
+
if (valueRef.current !== previous) return;
|
|
7466
|
+
const input = inputRef.current;
|
|
7467
|
+
caretRef.current = input !== null && document.activeElement === input ? input.selectionStart : null;
|
|
7468
|
+
setValue(initial);
|
|
7469
|
+
}, [initial]);
|
|
7470
|
+
useLayoutEffect(() => {
|
|
7471
|
+
const caret = caretRef.current;
|
|
7472
|
+
caretRef.current = null;
|
|
7473
|
+
const input = inputRef.current;
|
|
7474
|
+
if (caret === null || input === null) return;
|
|
7475
|
+
const offset = Math.min(caret, input.value.length);
|
|
7476
|
+
input.setSelectionRange(offset, offset);
|
|
7477
|
+
}, [value]);
|
|
7475
7478
|
const commit = (value) => {
|
|
7476
7479
|
if (committedRef.current) return;
|
|
7477
7480
|
committedRef.current = true;
|
|
@@ -7497,9 +7500,12 @@ function InlineEditInput({ initial, ariaLabel, slot, className, placeholder, inv
|
|
|
7497
7500
|
"aria-invalid": invalid ? true : void 0,
|
|
7498
7501
|
variant,
|
|
7499
7502
|
placeholder,
|
|
7500
|
-
|
|
7503
|
+
value,
|
|
7501
7504
|
className,
|
|
7502
|
-
onChange:
|
|
7505
|
+
onChange: (event) => {
|
|
7506
|
+
setValue(event.target.value);
|
|
7507
|
+
rearm();
|
|
7508
|
+
},
|
|
7503
7509
|
onBlur: onInputBlur,
|
|
7504
7510
|
onKeyDown: onInputKeyDown
|
|
7505
7511
|
});
|
|
@@ -15456,12 +15462,16 @@ function findParentSurface(doc, id) {
|
|
|
15456
15462
|
return null;
|
|
15457
15463
|
}
|
|
15458
15464
|
/**
|
|
15459
|
-
* The group creation: the selected canvas
|
|
15460
|
-
*
|
|
15461
|
-
*
|
|
15462
|
-
*
|
|
15463
|
-
*
|
|
15464
|
-
*
|
|
15465
|
+
* The group creation: the selected canvas items stand the new group's
|
|
15466
|
+
* members in ONE transact (one undo step, one wire update), and the
|
|
15467
|
+
* members leave every earlier owner — a figure stands in one container
|
|
15468
|
+
* at a time (the automatic membership's parity for the explicit
|
|
15469
|
+
* grouping; without the leave the figure would stay a member of its old
|
|
15470
|
+
* group too, and the two markers would both move it). Returns the new
|
|
15471
|
+
* group id, or null for the ineligible selection (one member, a
|
|
15472
|
+
* connector / a group in the set, a page block, or the members across
|
|
15473
|
+
* surfaces — the group is a flat marker over its siblings, never a
|
|
15474
|
+
* container). No throw: the hotkey's no-op posture.
|
|
15465
15475
|
*/
|
|
15466
15476
|
function makeGroup(doc, ids) {
|
|
15467
15477
|
if (ids.length < 2) return null;
|
|
@@ -15474,8 +15484,15 @@ function makeGroup(doc, ids) {
|
|
|
15474
15484
|
if (surface === null) surface = owner;
|
|
15475
15485
|
else if (owner !== surface) return null;
|
|
15476
15486
|
}
|
|
15487
|
+
const members = new Set(ids);
|
|
15477
15488
|
let created = null;
|
|
15478
15489
|
doc.transact(() => {
|
|
15490
|
+
for (const siblingId of doc.getChildren(surface)) {
|
|
15491
|
+
const sibling = doc.getBlock(siblingId);
|
|
15492
|
+
if (sibling === null || sibling.type !== "group") continue;
|
|
15493
|
+
const kept = sibling.attrs.members.filter((memberId) => !members.has(memberId));
|
|
15494
|
+
if (kept.length !== sibling.attrs.members.length) doc.updateBlock(siblingId, { members: kept });
|
|
15495
|
+
}
|
|
15479
15496
|
created = doc.insertBlock("group", { members: [...ids] }, { parent: surface });
|
|
15480
15497
|
});
|
|
15481
15498
|
return created;
|
|
@@ -22314,7 +22331,7 @@ function wrapperClassOf({ block, tag, selected, onSurface, calloutColorOverride,
|
|
|
22314
22331
|
*/
|
|
22315
22332
|
function innerClassOf({ block, doneTask, highlightableCode, codeWrap }) {
|
|
22316
22333
|
const align = alignOf(block);
|
|
22317
|
-
return cn("m-0 whitespace-pre-wrap outline-none", doneTask && "opacity-30", block.type === "code" && "font-(family-name:--docblocks-mono-font-family)", highlightableCode && "relative z-10 text-transparent caret-(--docblocks-text-color)", align === "center" && "text-center", align === "right" && "text-right", block.type === "code" && !codeWrap && "whitespace-pre");
|
|
22334
|
+
return cn("m-0 wrap-break-word whitespace-pre-wrap outline-none", doneTask && "opacity-30", block.type === "code" && "font-(family-name:--docblocks-mono-font-family)", highlightableCode && "relative z-10 text-transparent caret-(--docblocks-text-color)", align === "center" && "text-center", align === "right" && "text-right", block.type === "code" && !codeWrap && "whitespace-pre");
|
|
22318
22335
|
}
|
|
22319
22336
|
/**
|
|
22320
22337
|
* The gutter handle classes: the grip control in the left margin (the
|
|
@@ -28528,7 +28545,7 @@ function CellActivation({ cellId }) {
|
|
|
28528
28545
|
suppressContentEditableWarning: true,
|
|
28529
28546
|
spellCheck: false,
|
|
28530
28547
|
"data-slot": "docblocks/cell-activation",
|
|
28531
|
-
className: "my-(--docblocks-block-spacing) min-w-full whitespace-pre-wrap outline-none",
|
|
28548
|
+
className: "my-(--docblocks-block-spacing) min-w-full wrap-break-word whitespace-pre-wrap outline-none",
|
|
28532
28549
|
onInput,
|
|
28533
28550
|
onPaste,
|
|
28534
28551
|
onKeyDown
|
|
@@ -28629,7 +28646,7 @@ function CellContent({ id, block }) {
|
|
|
28629
28646
|
spellCheck: false,
|
|
28630
28647
|
"data-slot": "docblocks/block-content",
|
|
28631
28648
|
"data-block-id": id,
|
|
28632
|
-
className: cn("my-(--docblocks-block-spacing) whitespace-pre-wrap outline-none", align === "center" && "text-center", align === "right" && "text-right"),
|
|
28649
|
+
className: cn("my-(--docblocks-block-spacing) wrap-break-word whitespace-pre-wrap outline-none", align === "center" && "text-center", align === "right" && "text-right"),
|
|
28633
28650
|
onFocus: onLayerFocus,
|
|
28634
28651
|
onBlur: onLayerBlur,
|
|
28635
28652
|
onInput,
|
|
@@ -35056,6 +35073,368 @@ function CoverTintController({ cardRef }) {
|
|
|
35056
35073
|
return null;
|
|
35057
35074
|
}
|
|
35058
35075
|
//#endregion
|
|
35076
|
+
//#region src/editing/cross-drag/page-guards.ts
|
|
35077
|
+
/** The editor root's page-flow mousedown guard (the span model's native
|
|
35078
|
+
* selection suppression) and the triple press's whole-block select — the
|
|
35079
|
+
* module-level capture listeners, off over the read-only stand. */
|
|
35080
|
+
/**
|
|
35081
|
+
* The page flow's mousedown guard (the span model): the page container is
|
|
35082
|
+
* one shared editable, and over it the browser's native selection gesture
|
|
35083
|
+
* (the mousedown's default) outruns the user-select none (the editable's
|
|
35084
|
+
* selection stands over the grid's cells' display, the header's chrome,
|
|
35085
|
+
* the figure's frame — the drag's text's selection). The default is
|
|
35086
|
+
* suppressed over the island's chrome (the press's handlers own the
|
|
35087
|
+
* gesture); the controls (their focus stand) and the islands' own editables
|
|
35088
|
+
* (the cells' inners — the native editing stands, the word/line's select
|
|
35089
|
+
* over them) keep their defaults. The page's text inners stand the
|
|
35090
|
+
* session's own guard (the single press's suppression, the multi-click's
|
|
35091
|
+
* native word/line's select).
|
|
35092
|
+
*/
|
|
35093
|
+
function usePageMousedownGuard(rootRef, readOnly) {
|
|
35094
|
+
useEffect(() => {
|
|
35095
|
+
if (readOnly) return;
|
|
35096
|
+
const guard = (event) => {
|
|
35097
|
+
const root = rootRef.current;
|
|
35098
|
+
if (root === null || event.button !== 0) return;
|
|
35099
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
35100
|
+
if (target === null || !root.contains(target)) return;
|
|
35101
|
+
if (document.activeElement instanceof HTMLIFrameElement) return;
|
|
35102
|
+
if (target.closest("[data-slot=\"docblocks/page\"]") === null) return;
|
|
35103
|
+
if (target.closest("input, textarea, select, button") !== null) return;
|
|
35104
|
+
const island = target.closest("[contenteditable=\"false\"]");
|
|
35105
|
+
const editable = target.closest("[contenteditable=\"true\"]");
|
|
35106
|
+
if (island !== null && editable !== null && island.contains(editable)) return;
|
|
35107
|
+
const active = document.activeElement;
|
|
35108
|
+
const activeIsland = active instanceof HTMLElement ? active.closest("[contenteditable=\"false\"]") : null;
|
|
35109
|
+
const activeEditable = active instanceof HTMLElement ? active.closest("[contenteditable=\"true\"]") : null;
|
|
35110
|
+
if (active instanceof HTMLElement && (active.matches("input, textarea") || activeIsland !== null && activeEditable !== null && activeIsland.contains(activeEditable))) return;
|
|
35111
|
+
if (island === null && editable instanceof HTMLElement && isPageSurfaceInner(editable)) return;
|
|
35112
|
+
event.preventDefault();
|
|
35113
|
+
const a = document.activeElement;
|
|
35114
|
+
if (a === null || !root.contains(a)) root.focus();
|
|
35115
|
+
};
|
|
35116
|
+
window.addEventListener("mousedown", guard, true);
|
|
35117
|
+
return () => window.removeEventListener("mousedown", guard, true);
|
|
35118
|
+
}, [rootRef, readOnly]);
|
|
35119
|
+
}
|
|
35120
|
+
/**
|
|
35121
|
+
* The triple press's whole-block select: the browser's "paragraph" select
|
|
35122
|
+
* of a pre-wrap block stands at one visual line (the soft-break lines), so
|
|
35123
|
+
* a detail-3 press inside a text inner is suppressed and the editor stands
|
|
35124
|
+
* the whole-block selection (all the soft-break lines) itself — a
|
|
35125
|
+
* permanent capture listener, independent of the session (the real
|
|
35126
|
+
* pointer's third press starts no session: the pointer's detail stands 3
|
|
35127
|
+
* and the session guard returns).
|
|
35128
|
+
*/
|
|
35129
|
+
function useTripleSelect(rootRef, doc, readOnly) {
|
|
35130
|
+
useEffect(() => {
|
|
35131
|
+
if (readOnly) return;
|
|
35132
|
+
const triple = (event) => {
|
|
35133
|
+
const root = rootRef.current;
|
|
35134
|
+
if (root === null || event.button !== 0 || event.detail < 3) return;
|
|
35135
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
35136
|
+
if (target === null || !root.contains(target)) return;
|
|
35137
|
+
const inner = target.closest("[data-slot=\"docblocks/block-content\"]");
|
|
35138
|
+
if (inner === null || inner.closest("[data-slot=\"docblocks/editor\"]") !== root) return;
|
|
35139
|
+
if (document.activeElement instanceof HTMLIFrameElement) return;
|
|
35140
|
+
const blockId = inner.dataset.blockId;
|
|
35141
|
+
const head = locatePosition(inner, 0);
|
|
35142
|
+
const tail = locatePosition(inner, doc.getTextLength(blockId));
|
|
35143
|
+
event.preventDefault();
|
|
35144
|
+
window.getSelection()?.setBaseAndExtent(head.node, head.offset, tail.node, tail.offset);
|
|
35145
|
+
};
|
|
35146
|
+
window.addEventListener("mousedown", triple, true);
|
|
35147
|
+
return () => window.removeEventListener("mousedown", triple, true);
|
|
35148
|
+
}, [
|
|
35149
|
+
rootRef,
|
|
35150
|
+
doc,
|
|
35151
|
+
readOnly
|
|
35152
|
+
]);
|
|
35153
|
+
}
|
|
35154
|
+
//#endregion
|
|
35155
|
+
//#region src/editing/cross-drag/position.ts
|
|
35156
|
+
/**
|
|
35157
|
+
* The DOM selection from the drag anchor to the pointer position. Chromium
|
|
35158
|
+
* degenerates a reverse cross-editable selection whose base stands at
|
|
35159
|
+
* offset 0 (the base seats "before" the editable's content, and the range
|
|
35160
|
+
* collapses): that one case is seated forward instead — the from/to stay
|
|
35161
|
+
* correct, only the drag-direction flag is lost.
|
|
35162
|
+
*/
|
|
35163
|
+
function seatCrossSelection(anchor, position) {
|
|
35164
|
+
const base = (anchor.node.compareDocumentPosition(position.node) & Node.DOCUMENT_POSITION_FOLLOWING) !== 0 || anchor.offset !== 0 ? anchor : position;
|
|
35165
|
+
const focus = base === anchor ? position : anchor;
|
|
35166
|
+
applyDomSelection(base.node, base.offset, focus.node, focus.offset);
|
|
35167
|
+
}
|
|
35168
|
+
/**
|
|
35169
|
+
* The text position under (x, y) inside the editor's own scope: the
|
|
35170
|
+
* browser's caret position when the pointer stands in a text inner of
|
|
35171
|
+
* THIS editor (a nested sync-embed editor's inners are excluded — a
|
|
35172
|
+
* foreign position would seat the DOM selection across the boundary and
|
|
35173
|
+
* the mapping would drop the view), otherwise the nearest text edge by
|
|
35174
|
+
* geometry (the pointer over a gap, a marker, or a non-text block stands
|
|
35175
|
+
* at that block's head or tail by its horizontal position). Null when
|
|
35176
|
+
* there is no own-scope text to stand on.
|
|
35177
|
+
*/
|
|
35178
|
+
function positionAtPoint(doc, root, x, y) {
|
|
35179
|
+
const caretRange = typeof document.caretRangeFromPoint === "function" ? document.caretRangeFromPoint(x, y) : null;
|
|
35180
|
+
if (caretRange !== null) {
|
|
35181
|
+
const inner = (caretRange.startContainer instanceof Element ? caretRange.startContainer : caretRange.startContainer.parentElement ?? null)?.closest("[data-slot=\"docblocks/block-content\"]") ?? null;
|
|
35182
|
+
if (inner !== null && root.contains(inner) && inner.closest("[data-slot=\"docblocks/editor\"]") === root) return {
|
|
35183
|
+
blockId: inner.dataset.blockId,
|
|
35184
|
+
node: caretRange.startContainer,
|
|
35185
|
+
offset: caretRange.startOffset
|
|
35186
|
+
};
|
|
35187
|
+
}
|
|
35188
|
+
let best = null;
|
|
35189
|
+
for (const el of Array.from(root.querySelectorAll("[data-slot=\"docblocks/block-content\"]"))) {
|
|
35190
|
+
if (el.closest("[data-slot=\"docblocks/editor\"]") !== root) continue;
|
|
35191
|
+
const box = el.getBoundingClientRect();
|
|
35192
|
+
if (box.height === 0) continue;
|
|
35193
|
+
const distance = y < box.top ? box.top - y : y > box.bottom ? y - box.bottom : 0;
|
|
35194
|
+
if (best === null || distance < best.distance) best = {
|
|
35195
|
+
el,
|
|
35196
|
+
distance
|
|
35197
|
+
};
|
|
35198
|
+
}
|
|
35199
|
+
if (best === null) return null;
|
|
35200
|
+
const box = best.el.getBoundingClientRect();
|
|
35201
|
+
const blockId = best.el.dataset.blockId;
|
|
35202
|
+
const offset = x < box.left + Math.max(8, box.width / 4) ? 0 : doc.getTextLength(blockId);
|
|
35203
|
+
const position = locatePosition(best.el, offset);
|
|
35204
|
+
return {
|
|
35205
|
+
blockId,
|
|
35206
|
+
node: position.node,
|
|
35207
|
+
offset: position.offset
|
|
35208
|
+
};
|
|
35209
|
+
}
|
|
35210
|
+
//#endregion
|
|
35211
|
+
//#region src/editing/cross-drag/session.ts
|
|
35212
|
+
/** Tear the session's listeners down (the session ends, the pointer frees). */
|
|
35213
|
+
function teardownSession(handlers) {
|
|
35214
|
+
window.removeEventListener("pointermove", handlers.move);
|
|
35215
|
+
window.removeEventListener("pointerup", handlers.end);
|
|
35216
|
+
window.removeEventListener("pointercancel", handlers.end);
|
|
35217
|
+
window.removeEventListener("mousedown", handlers.mousedown, true);
|
|
35218
|
+
}
|
|
35219
|
+
/**
|
|
35220
|
+
* The session's listeners, built once for the hook's lifetime (they read
|
|
35221
|
+
* everything through refs, so a session that spans re-renders keeps the
|
|
35222
|
+
* very listeners it registered).
|
|
35223
|
+
*
|
|
35224
|
+
* The selection is seated from the pointer position on every move. The
|
|
35225
|
+
* anchor stands at the pointer position of the pointerdown (the
|
|
35226
|
+
* pointerdown fires before the browser would seat its caret, so the DOM
|
|
35227
|
+
* selection is not read), and the focus end follows the pointer through
|
|
35228
|
+
* the other blocks (the selectionchange mapping then keeps the view
|
|
35229
|
+
* selection in sync, per block). The session ends on pointerup/cancel: a
|
|
35230
|
+
* click without a drag re-seats the caret at the anchor (the plain click
|
|
35231
|
+
* behavior), a drag leaves the selection where the pointer left it.
|
|
35232
|
+
*
|
|
35233
|
+
* The browser's selection drag starts with the mousedown default action;
|
|
35234
|
+
* suppressing it (capture phase, the primary-button press inside the
|
|
35235
|
+
* editor — the mousedown of the session's own pointerdown, which Chromium
|
|
35236
|
+
* does not tag with a pointerId) leaves the editor the selection's sole
|
|
35237
|
+
* writer. The multi-click check stands on the mousedown's own detail (a
|
|
35238
|
+
* synthetic pointer stands 0 detail on the pointer events while the mouse
|
|
35239
|
+
* events carry the real count): the double press is the browser's native
|
|
35240
|
+
* word select, the shift's press the native extension's stand, and the
|
|
35241
|
+
* press over a focused iframe the browser's focus move — the session tears
|
|
35242
|
+
* down and the default action stands for all three.
|
|
35243
|
+
*/
|
|
35244
|
+
function createSessionHandlers(doc, rootRef, sessionRef) {
|
|
35245
|
+
const move = (event) => {
|
|
35246
|
+
const session = sessionRef.current;
|
|
35247
|
+
const root = rootRef.current;
|
|
35248
|
+
if (session === null || root === null || event.pointerId !== session.pointerId) return;
|
|
35249
|
+
const position = positionAtPoint(doc, root, event.clientX, event.clientY);
|
|
35250
|
+
if (position === null) return;
|
|
35251
|
+
session.moved = true;
|
|
35252
|
+
session.last = position;
|
|
35253
|
+
seatCrossSelection(session.anchor, position);
|
|
35254
|
+
};
|
|
35255
|
+
const end = (event) => {
|
|
35256
|
+
const session = sessionRef.current;
|
|
35257
|
+
const root = rootRef.current;
|
|
35258
|
+
if (session === null || root === null || event.pointerId !== session.pointerId) return;
|
|
35259
|
+
sessionRef.current = null;
|
|
35260
|
+
const seat = () => {
|
|
35261
|
+
if (session.moved && session.last !== null) seatCrossSelection(session.anchor, session.last);
|
|
35262
|
+
else window.getSelection()?.setBaseAndExtent(session.anchor.node, session.anchor.offset, session.anchor.node, session.anchor.offset);
|
|
35263
|
+
};
|
|
35264
|
+
seat();
|
|
35265
|
+
const seatNode = window.getSelection()?.anchorNode ?? session.anchor.node;
|
|
35266
|
+
const editable = (seatNode instanceof Element ? seatNode : seatNode.parentElement ?? null)?.closest("[contenteditable=\"true\"]") ?? null;
|
|
35267
|
+
if (editable !== null && document.activeElement !== editable) {
|
|
35268
|
+
editable.focus();
|
|
35269
|
+
seat();
|
|
35270
|
+
}
|
|
35271
|
+
teardownSession({
|
|
35272
|
+
move,
|
|
35273
|
+
end,
|
|
35274
|
+
mousedown
|
|
35275
|
+
});
|
|
35276
|
+
};
|
|
35277
|
+
const mousedown = (event) => {
|
|
35278
|
+
const session = sessionRef.current;
|
|
35279
|
+
const root = rootRef.current;
|
|
35280
|
+
if (session === null || root === null || event.button !== 0) return;
|
|
35281
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
35282
|
+
if (target === null || !root.contains(target)) return;
|
|
35283
|
+
const tearDown = () => {
|
|
35284
|
+
sessionRef.current = null;
|
|
35285
|
+
teardownSession({
|
|
35286
|
+
move,
|
|
35287
|
+
end,
|
|
35288
|
+
mousedown
|
|
35289
|
+
});
|
|
35290
|
+
};
|
|
35291
|
+
if (event.detail >= 2) {
|
|
35292
|
+
tearDown();
|
|
35293
|
+
return;
|
|
35294
|
+
}
|
|
35295
|
+
if (event.shiftKey) {
|
|
35296
|
+
tearDown();
|
|
35297
|
+
return;
|
|
35298
|
+
}
|
|
35299
|
+
if (document.activeElement instanceof HTMLIFrameElement) {
|
|
35300
|
+
tearDown();
|
|
35301
|
+
return;
|
|
35302
|
+
}
|
|
35303
|
+
event.preventDefault();
|
|
35304
|
+
};
|
|
35305
|
+
return {
|
|
35306
|
+
move,
|
|
35307
|
+
end,
|
|
35308
|
+
mousedown
|
|
35309
|
+
};
|
|
35310
|
+
}
|
|
35311
|
+
//#endregion
|
|
35312
|
+
//#region src/editing/cross-drag/use-cross-drag.ts
|
|
35313
|
+
/**
|
|
35314
|
+
* The text selection by mouse drag, in-block and across block boundaries:
|
|
35315
|
+
* the browser cannot extend a selection across a contenteditable boundary
|
|
35316
|
+
* (neither a drag nor a native shift+arrow), and its own drag session
|
|
35317
|
+
* would re-assert its (in-block-only) selection after the editor's, so
|
|
35318
|
+
* while a session is active the editor is the selection's sole writer —
|
|
35319
|
+
* the session's mousedown default action is suppressed (that is what
|
|
35320
|
+
* starts the browser's drag session; the caret seat and the focus move
|
|
35321
|
+
* with it, so both are stood up by the editor at the session end) and
|
|
35322
|
+
* the selection is seated from the pointer position on every move.
|
|
35323
|
+
*
|
|
35324
|
+
* The page flow's mousedown guard and the triple press's whole-block
|
|
35325
|
+
* select stand over the edit's mode. The read-only
|
|
35326
|
+
* stand (`readOnly`): no session starts and both capture listeners stand
|
|
35327
|
+
* off — the view mode's native range IS the copy's affordance (the
|
|
35328
|
+
* browser's selection gesture must own the presses; the guard's default's
|
|
35329
|
+
* suppression would kill it).
|
|
35330
|
+
*/
|
|
35331
|
+
/** The root's cross-drag handlers (the pointerdown starts the session). */
|
|
35332
|
+
function useCrossDrag(rootRef, doc, readOnly = false) {
|
|
35333
|
+
const sessionRef = useRef(null);
|
|
35334
|
+
const handlersRef = useRef(null);
|
|
35335
|
+
if (handlersRef.current === null) handlersRef.current = createSessionHandlers(doc, rootRef, sessionRef);
|
|
35336
|
+
const onPointerDown = useCallback((event) => {
|
|
35337
|
+
const root = rootRef.current;
|
|
35338
|
+
if (root === null || event.pointerType !== "mouse") return;
|
|
35339
|
+
if (event.detail >= 2) return;
|
|
35340
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
35341
|
+
if (target?.closest("[data-slot=\"docblocks/editor\"]") !== root) return;
|
|
35342
|
+
if (target.closest("[data-slot=\"docblocks/page-card\"]") !== null) return;
|
|
35343
|
+
const island = target.closest("[contenteditable=\"false\"]");
|
|
35344
|
+
const editable = target.closest("[contenteditable=\"true\"]");
|
|
35345
|
+
if (island !== null && (editable === null || !island.contains(editable))) return;
|
|
35346
|
+
if (target.closest("[data-slot=\"docblocks/block-content\"]") === null) return;
|
|
35347
|
+
const anchor = positionAtPoint(doc, root, event.clientX, event.clientY);
|
|
35348
|
+
if (anchor === null) return;
|
|
35349
|
+
sessionRef.current = {
|
|
35350
|
+
pointerId: event.pointerId,
|
|
35351
|
+
anchor,
|
|
35352
|
+
moved: false,
|
|
35353
|
+
last: null
|
|
35354
|
+
};
|
|
35355
|
+
const handlers = handlersRef.current;
|
|
35356
|
+
if (handlers === null) return;
|
|
35357
|
+
window.addEventListener("pointermove", handlers.move);
|
|
35358
|
+
window.addEventListener("pointerup", handlers.end);
|
|
35359
|
+
window.addEventListener("pointercancel", handlers.end);
|
|
35360
|
+
window.addEventListener("mousedown", handlers.mousedown, true);
|
|
35361
|
+
}, [doc, rootRef]);
|
|
35362
|
+
usePageMousedownGuard(rootRef, readOnly);
|
|
35363
|
+
useTripleSelect(rootRef, doc, readOnly);
|
|
35364
|
+
useEffect(() => () => {
|
|
35365
|
+
if (sessionRef.current === null) return;
|
|
35366
|
+
sessionRef.current = null;
|
|
35367
|
+
const handlers = handlersRef.current;
|
|
35368
|
+
if (handlers === null) return;
|
|
35369
|
+
teardownSession(handlers);
|
|
35370
|
+
}, []);
|
|
35371
|
+
return { onPointerDown };
|
|
35372
|
+
}
|
|
35373
|
+
//#endregion
|
|
35374
|
+
//#region src/editing/editor-root/blocks-keys.ts
|
|
35375
|
+
/**
|
|
35376
|
+
* The blocks selection's keys. A text row's own wrapper handles the same
|
|
35377
|
+
* keys earlier on the event path and resets the view to none, so the root
|
|
35378
|
+
* sees the non-text rows only — no double fire. True = consumed.
|
|
35379
|
+
*/
|
|
35380
|
+
function handleBlocksSelectionKeys(event, deps) {
|
|
35381
|
+
const { doc, rootBlockId, root, view } = deps;
|
|
35382
|
+
const selection = view.get();
|
|
35383
|
+
if (selection.kind !== "blocks") return false;
|
|
35384
|
+
if (event.key === "Delete" || event.key === "Backspace") {
|
|
35385
|
+
event.preventDefault();
|
|
35386
|
+
const first = selection.ids[0];
|
|
35387
|
+
if (selection.ids.length === 1 && first !== void 0 && doc.getBlock(first)?.type === "image") {
|
|
35388
|
+
doc.changeBlockType(first, "paragraph");
|
|
35389
|
+
root?.focus();
|
|
35390
|
+
focusCaretIn(first, 0, root ?? document);
|
|
35391
|
+
return true;
|
|
35392
|
+
}
|
|
35393
|
+
const caret = removeBlocksSelection(doc, entrySequenceParent(doc, rootBlockId), selection.ids);
|
|
35394
|
+
view.set({ kind: "none" });
|
|
35395
|
+
if (caret !== null) {
|
|
35396
|
+
focusCaretIn(caret.blockId, caret.offset, root ?? document);
|
|
35397
|
+
return true;
|
|
35398
|
+
}
|
|
35399
|
+
root?.focus();
|
|
35400
|
+
return true;
|
|
35401
|
+
}
|
|
35402
|
+
if (event.key === "Escape") {
|
|
35403
|
+
event.preventDefault();
|
|
35404
|
+
view.set({ kind: "none" });
|
|
35405
|
+
return true;
|
|
35406
|
+
}
|
|
35407
|
+
if (root === null) return false;
|
|
35408
|
+
const pageContainer = root.querySelector("[data-slot='docblocks/page']");
|
|
35409
|
+
if (!(event.target === root || event.target === pageContainer) || !(event.metaKey || event.ctrlKey) || !event.shiftKey || event.key !== "ArrowUp" && event.key !== "ArrowDown" || selection.ids.length !== 1 || selection.ids[0] === void 0) return false;
|
|
35410
|
+
const id = selection.ids[0];
|
|
35411
|
+
const siblings = doc.getChildren(rootBlockId);
|
|
35412
|
+
if (!siblings.includes(id)) return false;
|
|
35413
|
+
const segment = segmentRange(doc, rootBlockId, id);
|
|
35414
|
+
if (segment === null) return false;
|
|
35415
|
+
const length = segment.end - segment.start;
|
|
35416
|
+
const isSurface = (candidate) => doc.getBlock(candidate)?.type === "surface";
|
|
35417
|
+
let target = null;
|
|
35418
|
+
if (event.key === "ArrowUp") {
|
|
35419
|
+
let i = segment.start - 1;
|
|
35420
|
+
while (i >= 0 && isSurface(siblings[i])) i -= 1;
|
|
35421
|
+
if (i >= 0) target = i;
|
|
35422
|
+
} else {
|
|
35423
|
+
let j = segment.end;
|
|
35424
|
+
while (j < siblings.length && isSurface(siblings[j])) j += 1;
|
|
35425
|
+
if (j < siblings.length) target = j + 1;
|
|
35426
|
+
}
|
|
35427
|
+
if (target === null) return false;
|
|
35428
|
+
event.preventDefault();
|
|
35429
|
+
moveSegmentInSequence(doc, rootBlockId, segment.start, length, target);
|
|
35430
|
+
view.set({
|
|
35431
|
+
kind: "blocks",
|
|
35432
|
+
ids: [id],
|
|
35433
|
+
anchorId: id
|
|
35434
|
+
});
|
|
35435
|
+
return true;
|
|
35436
|
+
}
|
|
35437
|
+
//#endregion
|
|
35059
35438
|
//#region src/editing/copy-runs.ts
|
|
35060
35439
|
/**
|
|
35061
35440
|
* The copy payload's run primitives: the marks' html wrap, the runs'
|
|
@@ -35320,259 +35699,129 @@ function clipboardContentOf(doc, selection) {
|
|
|
35320
35699
|
return crossRangeClipboardContent(doc, selection);
|
|
35321
35700
|
}
|
|
35322
35701
|
//#endregion
|
|
35323
|
-
//#region src/editing/
|
|
35702
|
+
//#region src/editing/editor-root/copy-handler.ts
|
|
35324
35703
|
/**
|
|
35325
|
-
* The
|
|
35326
|
-
*
|
|
35327
|
-
*
|
|
35328
|
-
*
|
|
35329
|
-
*
|
|
35704
|
+
* The root's copy handler. The browser cannot copy a selection across a
|
|
35705
|
+
* contenteditable boundary, so a cross-block range is serialized from the
|
|
35706
|
+
* doc; a same-block range that includes a mention is serialized too (the
|
|
35707
|
+
* mention copies as `@label`, not the chip's bare label); everything else
|
|
35708
|
+
* keeps the default (native) copy. The edit's mode reads the live
|
|
35709
|
+
* selection view (the mapping owns it); the view's mode maps the DOM
|
|
35710
|
+
* selection at copy time — the read-only stand keeps no live view (the
|
|
35711
|
+
* browser's native range is the only selection there). The published
|
|
35712
|
+
* stand never intercepts (no selection, no copy).
|
|
35330
35713
|
*/
|
|
35331
|
-
function
|
|
35332
|
-
const
|
|
35333
|
-
|
|
35334
|
-
|
|
35714
|
+
function createCopyHandler(deps) {
|
|
35715
|
+
const { doc, mode, viewMode, rootRef, selectionRef } = deps;
|
|
35716
|
+
return (event) => {
|
|
35717
|
+
if (mode === "published") return;
|
|
35718
|
+
const root = rootRef.current;
|
|
35719
|
+
const view = selectionRef.view;
|
|
35720
|
+
if (root === null || view === null) return;
|
|
35721
|
+
const nearest = (event.target instanceof Element ? event.target : null)?.closest("[data-slot=\"docblocks/editor\"]") ?? null;
|
|
35722
|
+
if (nearest !== null && nearest !== root) return;
|
|
35723
|
+
const selection = viewMode ? mapDomSelection(root, window.getSelection(), doc, { readOnly: true }) : view.get();
|
|
35724
|
+
if (selection.kind === "text" && selection.to !== null && selection.to.blockId === selection.from.blockId && selection.from.offset < selection.to.offset) {
|
|
35725
|
+
const block = doc.getBlock(selection.from.blockId);
|
|
35726
|
+
const content = block !== null && "content" in block ? block.content : void 0;
|
|
35727
|
+
if (content !== void 0) {
|
|
35728
|
+
let runStart = 0;
|
|
35729
|
+
let hasMention = false;
|
|
35730
|
+
for (const run of content) {
|
|
35731
|
+
const runEnd = runStart + run.text.length;
|
|
35732
|
+
if (run.marks.mention !== void 0 && runStart < selection.to.offset && runEnd > selection.from.offset) {
|
|
35733
|
+
hasMention = true;
|
|
35734
|
+
break;
|
|
35735
|
+
}
|
|
35736
|
+
runStart = runEnd;
|
|
35737
|
+
}
|
|
35738
|
+
if (hasMention) {
|
|
35739
|
+
const segment = segmentOf(content, selection.from.offset, selection.to.offset);
|
|
35740
|
+
event.preventDefault();
|
|
35741
|
+
event.clipboardData.setData("text/plain", segment.text);
|
|
35742
|
+
event.clipboardData.setData("text/html", segment.html);
|
|
35743
|
+
return;
|
|
35744
|
+
}
|
|
35745
|
+
}
|
|
35746
|
+
}
|
|
35747
|
+
const payload = clipboardContentOf(doc, selection);
|
|
35748
|
+
if (payload === null) return;
|
|
35749
|
+
event.preventDefault();
|
|
35750
|
+
event.clipboardData.setData("text/plain", payload.text);
|
|
35751
|
+
event.clipboardData.setData("text/html", payload.html);
|
|
35752
|
+
};
|
|
35753
|
+
}
|
|
35754
|
+
//#endregion
|
|
35755
|
+
//#region src/editing/editor-root/document-keys.ts
|
|
35756
|
+
/** The text blocks of the document's page sequence (the document-zone span). */
|
|
35757
|
+
function textBlockIdsOf(doc, rootBlockId) {
|
|
35758
|
+
return doc.getChildren(rootBlockId).filter((id) => {
|
|
35759
|
+
const block = doc.getBlock(id);
|
|
35760
|
+
return block !== null && "content" in block;
|
|
35761
|
+
});
|
|
35335
35762
|
}
|
|
35336
35763
|
/**
|
|
35337
|
-
* The
|
|
35338
|
-
*
|
|
35339
|
-
*
|
|
35340
|
-
* foreign position would seat the DOM selection across the boundary and
|
|
35341
|
-
* the mapping would drop the view), otherwise the nearest text edge by
|
|
35342
|
-
* geometry (the pointer over a gap, a marker, or a non-text block stands
|
|
35343
|
-
* at that block's head or tail by its horizontal position). Null when
|
|
35344
|
-
* there is no own-scope text to stand on.
|
|
35764
|
+
* The form controls (their own select-all's stand — the cell's inputs, the
|
|
35765
|
+
* panel's) and the canvas view (its own keys' stand) keep the default; the
|
|
35766
|
+
* page's editables + the root's parked focus stand the document's stand.
|
|
35345
35767
|
*/
|
|
35346
|
-
function
|
|
35347
|
-
|
|
35348
|
-
|
|
35349
|
-
const inner = (caretRange.startContainer instanceof Element ? caretRange.startContainer : caretRange.startContainer.parentElement ?? null)?.closest("[data-slot=\"docblocks/block-content\"]") ?? null;
|
|
35350
|
-
if (inner !== null && root.contains(inner) && inner.closest("[data-slot=\"docblocks/editor\"]") === root) return {
|
|
35351
|
-
blockId: inner.dataset.blockId,
|
|
35352
|
-
node: caretRange.startContainer,
|
|
35353
|
-
offset: caretRange.startOffset
|
|
35354
|
-
};
|
|
35355
|
-
}
|
|
35356
|
-
let best = null;
|
|
35357
|
-
for (const el of Array.from(root.querySelectorAll("[data-slot=\"docblocks/block-content\"]"))) {
|
|
35358
|
-
if (el.closest("[data-slot=\"docblocks/editor\"]") !== root) continue;
|
|
35359
|
-
const box = el.getBoundingClientRect();
|
|
35360
|
-
if (box.height === 0) continue;
|
|
35361
|
-
const distance = y < box.top ? box.top - y : y > box.bottom ? y - box.bottom : 0;
|
|
35362
|
-
if (best === null || distance < best.distance) best = {
|
|
35363
|
-
el,
|
|
35364
|
-
distance
|
|
35365
|
-
};
|
|
35366
|
-
}
|
|
35367
|
-
if (best === null) return null;
|
|
35368
|
-
const box = best.el.getBoundingClientRect();
|
|
35369
|
-
const blockId = best.el.dataset.blockId;
|
|
35370
|
-
const offset = x < box.left + Math.max(8, box.width / 4) ? 0 : doc.getTextLength(blockId);
|
|
35371
|
-
const position = locatePosition(best.el, offset);
|
|
35372
|
-
return {
|
|
35373
|
-
blockId,
|
|
35374
|
-
node: position.node,
|
|
35375
|
-
offset: position.offset
|
|
35376
|
-
};
|
|
35768
|
+
function ownsDocumentKeys(target, root) {
|
|
35769
|
+
if (target === null || target === root) return true;
|
|
35770
|
+
return target.closest("input, textarea") === null && target.closest("[data-slot=\"docblocks/canvas-view\"]") === null;
|
|
35377
35771
|
}
|
|
35378
35772
|
/**
|
|
35379
|
-
* The
|
|
35380
|
-
*
|
|
35381
|
-
*
|
|
35382
|
-
*
|
|
35383
|
-
*
|
|
35384
|
-
* the
|
|
35385
|
-
*
|
|
35386
|
-
*
|
|
35387
|
-
* the selection is seated from the pointer position on every move. The
|
|
35388
|
-
* anchor stands at the pointer position of the pointerdown (the
|
|
35389
|
-
* pointerdown fires before the browser would seat its caret, so the DOM
|
|
35390
|
-
* selection is not read), and the focus end follows the pointer through
|
|
35391
|
-
* the other blocks (the selectionchange mapping then keeps the view
|
|
35392
|
-
* selection in sync, per block). The session ends on pointerup/cancel:
|
|
35393
|
-
* a click without a drag re-seats the caret at the anchor (the plain
|
|
35394
|
-
* click behavior), a drag leaves the selection where the pointer left it.
|
|
35395
|
-
*
|
|
35396
|
-
* The multi-click selects are the browser's own word select (the double
|
|
35397
|
-
* press) — the session's mousedown suppression stands only for the first
|
|
35398
|
-
* press (the multi-click's own mousedown tears the session down and lets
|
|
35399
|
-
* the default action stand; the pointer's detail stands 0 under synthetic
|
|
35400
|
-
* input, the mousedown's stands the real count, so the decision stands on
|
|
35401
|
-
* the mousedown's). The shift's press stands the same tear-down (the
|
|
35402
|
-
* shift+click's extension's parity — the native extension's stand over
|
|
35403
|
-
* the default's suppression), and the triple press is the editor's: the
|
|
35404
|
-
* browser's
|
|
35405
|
-
* "paragraph" select of a pre-wrap block stands at one visual line (the
|
|
35406
|
-
* soft-break lines), so a detail-3 press inside a text inner is
|
|
35407
|
-
* suppressed and the editor stands the whole-block selection (all the
|
|
35408
|
-
* soft-break lines) itself — a permanent capture listener, independent of
|
|
35409
|
-
* the session (the real pointer's third press starts no session: the
|
|
35410
|
-
* pointer's detail stands 3 and the session guard returns).
|
|
35411
|
-
*
|
|
35412
|
-
* The iframe's focus exception: a press while the document's focus stands
|
|
35413
|
-
* in a frame (the embed's iframe) tears the session down and lets the
|
|
35414
|
-
* mousedown's default stand — the default's focus move out of the frame
|
|
35415
|
-
* is the editor's document's focus, and suppressing it would seat the
|
|
35416
|
-
* caret over the unfocused document (no visible caret, the keys' no-
|
|
35417
|
-
* stand). The browser's native caret's seat stands the press; a double
|
|
35418
|
-
* press over the focused frame stands the same stand over the detail's
|
|
35419
|
-
* check.
|
|
35420
|
-
*
|
|
35421
|
-
* The read-only stand (`readOnly`): no session starts and the page
|
|
35422
|
-
* flow's mousedown guard / the triple press's stand stand off — the view
|
|
35423
|
-
* mode's native range IS the copy's affordance (the browser's selection
|
|
35424
|
-
* gesture must own the presses; the guard's default's suppression would
|
|
35425
|
-
* kill it).
|
|
35773
|
+
* The select-all's stand (both modes' stand — the read-only view's
|
|
35774
|
+
* selection stands the document's zone too): the browser's native
|
|
35775
|
+
* select-all degenerates to a collapsed caret (the edit's mode) or selects
|
|
35776
|
+
* the consumer's whole page (the read-only's mode), so the editor stands
|
|
35777
|
+
* the whole-document's selection itself — the first text block's start →
|
|
35778
|
+
* the last text block's end (the DOM's cross seat + the mapping's view
|
|
35779
|
+
* sync over the selectionchange; the copy/paste/delete's cross paths stand
|
|
35780
|
+
* over the range). True = consumed.
|
|
35426
35781
|
*/
|
|
35427
|
-
function
|
|
35428
|
-
|
|
35429
|
-
|
|
35430
|
-
|
|
35431
|
-
|
|
35432
|
-
|
|
35433
|
-
|
|
35434
|
-
|
|
35435
|
-
|
|
35436
|
-
|
|
35437
|
-
|
|
35438
|
-
|
|
35439
|
-
|
|
35440
|
-
|
|
35441
|
-
|
|
35442
|
-
|
|
35443
|
-
|
|
35444
|
-
|
|
35445
|
-
|
|
35446
|
-
|
|
35447
|
-
|
|
35448
|
-
|
|
35449
|
-
|
|
35450
|
-
|
|
35451
|
-
|
|
35452
|
-
|
|
35453
|
-
|
|
35454
|
-
|
|
35455
|
-
|
|
35456
|
-
|
|
35457
|
-
|
|
35458
|
-
|
|
35459
|
-
|
|
35460
|
-
|
|
35461
|
-
|
|
35462
|
-
|
|
35463
|
-
|
|
35464
|
-
|
|
35465
|
-
|
|
35466
|
-
|
|
35467
|
-
if (target === null || !root.contains(target)) return;
|
|
35468
|
-
const tearDown = () => {
|
|
35469
|
-
sessionRef.current = null;
|
|
35470
|
-
window.removeEventListener("pointermove", move);
|
|
35471
|
-
window.removeEventListener("pointerup", end);
|
|
35472
|
-
window.removeEventListener("pointercancel", end);
|
|
35473
|
-
window.removeEventListener("mousedown", mousedown, true);
|
|
35474
|
-
};
|
|
35475
|
-
if (event.detail >= 2) {
|
|
35476
|
-
tearDown();
|
|
35477
|
-
return;
|
|
35478
|
-
}
|
|
35479
|
-
if (event.shiftKey) {
|
|
35480
|
-
tearDown();
|
|
35481
|
-
return;
|
|
35482
|
-
}
|
|
35483
|
-
if (document.activeElement instanceof HTMLIFrameElement) {
|
|
35484
|
-
tearDown();
|
|
35485
|
-
return;
|
|
35486
|
-
}
|
|
35487
|
-
event.preventDefault();
|
|
35488
|
-
};
|
|
35489
|
-
handlersRef.current = {
|
|
35490
|
-
move,
|
|
35491
|
-
end,
|
|
35492
|
-
mousedown
|
|
35493
|
-
};
|
|
35494
|
-
}
|
|
35495
|
-
const onPointerDown = useCallback((event) => {
|
|
35496
|
-
const root = rootRef.current;
|
|
35497
|
-
if (root === null || event.pointerType !== "mouse") return;
|
|
35498
|
-
if (event.detail >= 2) return;
|
|
35499
|
-
const target = event.target instanceof Element ? event.target : null;
|
|
35500
|
-
if (target?.closest("[data-slot=\"docblocks/editor\"]") !== root) return;
|
|
35501
|
-
if (target.closest("[data-slot=\"docblocks/page-card\"]") !== null) return;
|
|
35502
|
-
if (target.closest("[data-slot=\"docblocks/block-content\"]") === null) return;
|
|
35503
|
-
const anchor = positionAtPoint(doc, root, event.clientX, event.clientY);
|
|
35504
|
-
if (anchor === null) return;
|
|
35505
|
-
sessionRef.current = {
|
|
35506
|
-
pointerId: event.pointerId,
|
|
35507
|
-
anchor,
|
|
35508
|
-
moved: false,
|
|
35509
|
-
last: null
|
|
35510
|
-
};
|
|
35511
|
-
const handlers = handlersRef.current;
|
|
35512
|
-
if (handlers === null) return;
|
|
35513
|
-
window.addEventListener("pointermove", handlers.move);
|
|
35514
|
-
window.addEventListener("pointerup", handlers.end);
|
|
35515
|
-
window.addEventListener("pointercancel", handlers.end);
|
|
35516
|
-
window.addEventListener("mousedown", handlers.mousedown, true);
|
|
35517
|
-
}, [doc, rootRef]);
|
|
35518
|
-
useEffect(() => {
|
|
35519
|
-
if (readOnly) return;
|
|
35520
|
-
const guard = (event) => {
|
|
35521
|
-
const root = rootRef.current;
|
|
35522
|
-
if (root === null || event.button !== 0) return;
|
|
35523
|
-
const target = event.target instanceof Element ? event.target : null;
|
|
35524
|
-
if (target === null || !root.contains(target)) return;
|
|
35525
|
-
if (document.activeElement instanceof HTMLIFrameElement) return;
|
|
35526
|
-
if (target.closest("[data-slot=\"docblocks/page\"]") === null) return;
|
|
35527
|
-
if (target.closest("input, textarea, select, button") !== null) return;
|
|
35528
|
-
const island = target.closest("[contenteditable=\"false\"]");
|
|
35529
|
-
const editable = target.closest("[contenteditable=\"true\"]");
|
|
35530
|
-
if (island !== null && editable !== null && island.contains(editable)) return;
|
|
35531
|
-
const active = document.activeElement;
|
|
35532
|
-
const activeIsland = active instanceof HTMLElement ? active.closest("[contenteditable=\"false\"]") : null;
|
|
35533
|
-
const activeEditable = active instanceof HTMLElement ? active.closest("[contenteditable=\"true\"]") : null;
|
|
35534
|
-
if (active instanceof HTMLElement && (active.matches("input, textarea") || activeIsland !== null && activeEditable !== null && activeIsland.contains(activeEditable))) return;
|
|
35535
|
-
if (island === null && editable instanceof HTMLElement && isPageSurfaceInner(editable)) return;
|
|
35536
|
-
event.preventDefault();
|
|
35537
|
-
const a = document.activeElement;
|
|
35538
|
-
if (root !== null && (a === null || !root.contains(a))) root.focus();
|
|
35539
|
-
};
|
|
35540
|
-
window.addEventListener("mousedown", guard, true);
|
|
35541
|
-
return () => window.removeEventListener("mousedown", guard, true);
|
|
35542
|
-
}, [rootRef, readOnly]);
|
|
35543
|
-
useEffect(() => {
|
|
35544
|
-
if (readOnly) return;
|
|
35545
|
-
const triple = (event) => {
|
|
35546
|
-
const root = rootRef.current;
|
|
35547
|
-
if (root === null || event.button !== 0 || event.detail < 3) return;
|
|
35548
|
-
const target = event.target instanceof Element ? event.target : null;
|
|
35549
|
-
if (target === null || !root.contains(target)) return;
|
|
35550
|
-
const inner = target.closest("[data-slot=\"docblocks/block-content\"]");
|
|
35551
|
-
if (inner === null || inner.closest("[data-slot=\"docblocks/editor\"]") !== root) return;
|
|
35552
|
-
if (document.activeElement instanceof HTMLIFrameElement) return;
|
|
35553
|
-
const blockId = inner.dataset.blockId;
|
|
35554
|
-
const head = locatePosition(inner, 0);
|
|
35555
|
-
const tail = locatePosition(inner, doc.getTextLength(blockId));
|
|
35556
|
-
event.preventDefault();
|
|
35557
|
-
window.getSelection()?.setBaseAndExtent(head.node, head.offset, tail.node, tail.offset);
|
|
35558
|
-
};
|
|
35559
|
-
window.addEventListener("mousedown", triple, true);
|
|
35560
|
-
return () => {
|
|
35561
|
-
window.removeEventListener("mousedown", triple, true);
|
|
35562
|
-
if (sessionRef.current === null) return;
|
|
35563
|
-
sessionRef.current = null;
|
|
35564
|
-
const handlers = handlersRef.current;
|
|
35565
|
-
if (handlers === null) return;
|
|
35566
|
-
window.removeEventListener("pointermove", handlers.move);
|
|
35567
|
-
window.removeEventListener("pointerup", handlers.end);
|
|
35568
|
-
window.removeEventListener("pointercancel", handlers.end);
|
|
35569
|
-
window.removeEventListener("mousedown", handlers.mousedown, true);
|
|
35570
|
-
};
|
|
35571
|
-
}, [doc, readOnly]);
|
|
35572
|
-
return { onPointerDown };
|
|
35782
|
+
function handleSelectAll(event, deps) {
|
|
35783
|
+
if (!(event.metaKey || event.ctrlKey) || event.key.toLowerCase() !== "a" || event.shiftKey) return false;
|
|
35784
|
+
if (!ownsDocumentKeys(deps.target, deps.root)) return false;
|
|
35785
|
+
event.preventDefault();
|
|
35786
|
+
const textIds = textBlockIdsOf(deps.doc, deps.rootBlockId);
|
|
35787
|
+
const firstId = textIds[0];
|
|
35788
|
+
const lastId = textIds[textIds.length - 1];
|
|
35789
|
+
if (firstId === void 0 || lastId === void 0) return true;
|
|
35790
|
+
const firstInner = deps.root.querySelector(`[data-block-id="${CSS.escape(firstId)}"][data-slot="docblocks/block-content"]`);
|
|
35791
|
+
const lastInner = firstId === lastId ? firstInner : deps.root.querySelector(`[data-block-id="${CSS.escape(lastId)}"][data-slot="docblocks/block-content"]`);
|
|
35792
|
+
if (firstInner === null || lastInner === null) return true;
|
|
35793
|
+
const head = locatePosition(firstInner, 0);
|
|
35794
|
+
const tail = locatePosition(lastInner, deps.doc.getTextLength(lastId));
|
|
35795
|
+
applyDomSelection(head.node, head.offset, tail.node, tail.offset);
|
|
35796
|
+
return true;
|
|
35797
|
+
}
|
|
35798
|
+
/**
|
|
35799
|
+
* The document's start/end's stand (the Chromium's native's degeneration
|
|
35800
|
+
* over the nested editables' stand): the native Ctrl+Home leaves the caret
|
|
35801
|
+
* standing (the outer editable's content start stands the panel's island's
|
|
35802
|
+
* position, not the document's first text block), so the editor stands the
|
|
35803
|
+
* caret's seat itself (the select-all's head/tail's parity — the first
|
|
35804
|
+
* text block's start / the last's end, the selection's collapse to the
|
|
35805
|
+
* document's edge's stand). The form controls + the canvas view keep their
|
|
35806
|
+
* own keys. True = consumed.
|
|
35807
|
+
*/
|
|
35808
|
+
function handleDocumentEdge(event, deps) {
|
|
35809
|
+
if (!(event.metaKey || event.ctrlKey) || event.shiftKey) return false;
|
|
35810
|
+
if (event.key !== "Home" && event.key !== "End") return false;
|
|
35811
|
+
if (!ownsDocumentKeys(deps.target, deps.root)) return false;
|
|
35812
|
+
event.preventDefault();
|
|
35813
|
+
const textIds = textBlockIdsOf(deps.doc, deps.rootBlockId);
|
|
35814
|
+
const targetId = event.key === "Home" ? textIds[0] : textIds[textIds.length - 1];
|
|
35815
|
+
if (targetId === void 0) return true;
|
|
35816
|
+
const inner = deps.root.querySelector(`[data-block-id="${CSS.escape(targetId)}"][data-slot="docblocks/block-content"]`);
|
|
35817
|
+
if (inner === null) return true;
|
|
35818
|
+
const position = locatePosition(inner, event.key === "Home" ? 0 : deps.doc.getTextLength(targetId));
|
|
35819
|
+
applyDomSelection(position.node, position.offset, position.node, position.offset);
|
|
35820
|
+
(position.node instanceof Element ? position.node : position.node.parentElement)?.scrollIntoView?.({ block: event.key === "Home" ? "start" : "end" });
|
|
35821
|
+
return true;
|
|
35573
35822
|
}
|
|
35574
35823
|
//#endregion
|
|
35575
|
-
//#region src/editing/
|
|
35824
|
+
//#region src/editing/editor-root/history-reseat.ts
|
|
35576
35825
|
/**
|
|
35577
35826
|
* The history reseat's window over the undo/redo (the remount's transient
|
|
35578
35827
|
* selection loss's stand): the window's end stands the mapping's none's
|
|
@@ -35611,22 +35860,16 @@ function scheduleHistoryReseat(doc, view, root) {
|
|
|
35611
35860
|
unsubscribe();
|
|
35612
35861
|
}, RESEAT_WINDOW_MS);
|
|
35613
35862
|
}
|
|
35863
|
+
//#endregion
|
|
35864
|
+
//#region src/editing/editor-root/selection-tracking.ts
|
|
35865
|
+
/** The editor root's `selectionchange` mapping: the DOM selection → the
|
|
35866
|
+
* core Selection view (the editing stand's tracking). */
|
|
35614
35867
|
/**
|
|
35615
|
-
*
|
|
35616
|
-
*
|
|
35617
|
-
*
|
|
35618
|
-
* the selection's payload (the keydown and copy listeners live on the
|
|
35619
|
-
* root, so they never fire outside the editor).
|
|
35620
|
-
*
|
|
35621
|
-
* The selection view is read at event time through the stable context
|
|
35622
|
-
* handle: the view becomes live when the provider's mount effect runs,
|
|
35623
|
-
* which is after this hook's effect subscribed (child effects run first),
|
|
35624
|
-
* so a render-time value would be a stale null.
|
|
35868
|
+
* Track the DOM selection into the view. The read-only stand (view /
|
|
35869
|
+
* published) stands no tracking: the mapping's editing path is off there
|
|
35870
|
+
* (the view mode's native range is mapped at copy time instead).
|
|
35625
35871
|
*/
|
|
35626
|
-
function
|
|
35627
|
-
const { doc, rootBlockId, selection: selectionRef, viewMode, mode } = useEditorContext();
|
|
35628
|
-
const rootRef = useRef(null);
|
|
35629
|
-
const crossDrag = useCrossDrag(rootRef, doc, viewMode);
|
|
35872
|
+
function useSelectionTracking(doc, rootRef, selectionRef, viewMode) {
|
|
35630
35873
|
useEffect(() => {
|
|
35631
35874
|
if (viewMode) return;
|
|
35632
35875
|
const onSelectionChange = () => {
|
|
@@ -35657,166 +35900,82 @@ function useEditing() {
|
|
|
35657
35900
|
selectionRef,
|
|
35658
35901
|
viewMode
|
|
35659
35902
|
]);
|
|
35660
|
-
|
|
35661
|
-
|
|
35662
|
-
|
|
35663
|
-
|
|
35664
|
-
|
|
35665
|
-
|
|
35666
|
-
|
|
35667
|
-
|
|
35668
|
-
|
|
35669
|
-
|
|
35670
|
-
|
|
35671
|
-
|
|
35672
|
-
|
|
35673
|
-
|
|
35674
|
-
|
|
35675
|
-
|
|
35676
|
-
|
|
35677
|
-
|
|
35678
|
-
|
|
35679
|
-
|
|
35680
|
-
|
|
35681
|
-
|
|
35682
|
-
|
|
35683
|
-
return;
|
|
35684
|
-
}
|
|
35685
|
-
if (root !== null && (event.metaKey || event.ctrlKey) && !event.shiftKey && (event.key === "Home" || event.key === "End")) {
|
|
35686
|
-
if (target !== null && target !== root && (target.closest("input, textarea") !== null || target.closest("[data-slot=\"docblocks/canvas-view\"]") !== null)) return;
|
|
35687
|
-
event.preventDefault();
|
|
35688
|
-
const textIds = doc.getChildren(rootBlockId).filter((id) => {
|
|
35689
|
-
const block = doc.getBlock(id);
|
|
35690
|
-
return block !== null && "content" in block;
|
|
35691
|
-
});
|
|
35692
|
-
const targetId = event.key === "Home" ? textIds[0] : textIds[textIds.length - 1];
|
|
35693
|
-
if (targetId === void 0) return;
|
|
35694
|
-
const inner = root.querySelector(`[data-block-id="${CSS.escape(targetId)}"][data-slot="docblocks/block-content"]`);
|
|
35695
|
-
if (inner === null) return;
|
|
35696
|
-
const position = locatePosition(inner, event.key === "Home" ? 0 : doc.getTextLength(targetId));
|
|
35697
|
-
applyDomSelection(position.node, position.offset, position.node, position.offset);
|
|
35698
|
-
(position.node instanceof Element ? position.node : position.node.parentElement)?.scrollIntoView?.({ block: event.key === "Home" ? "start" : "end" });
|
|
35699
|
-
return;
|
|
35700
|
-
}
|
|
35701
|
-
if (viewMode) return;
|
|
35702
|
-
const view = selectionRef.view;
|
|
35703
|
-
if (view !== null) {
|
|
35704
|
-
const selection = view.get();
|
|
35705
|
-
if (selection.kind === "blocks") {
|
|
35706
|
-
if (event.key === "Delete" || event.key === "Backspace") {
|
|
35707
|
-
event.preventDefault();
|
|
35708
|
-
const first = selection.ids[0];
|
|
35709
|
-
if (selection.ids.length === 1 && first !== void 0 && doc.getBlock(first)?.type === "image") {
|
|
35710
|
-
doc.changeBlockType(first, "paragraph");
|
|
35711
|
-
root?.focus();
|
|
35712
|
-
focusCaretIn(first, 0, root ?? document);
|
|
35713
|
-
return;
|
|
35714
|
-
}
|
|
35715
|
-
const caret = removeBlocksSelection(doc, entrySequenceParent(doc, rootBlockId), selection.ids);
|
|
35716
|
-
view.set({ kind: "none" });
|
|
35717
|
-
if (caret !== null) {
|
|
35718
|
-
focusCaretIn(caret.blockId, caret.offset, root ?? document);
|
|
35719
|
-
return;
|
|
35720
|
-
}
|
|
35721
|
-
root?.focus();
|
|
35722
|
-
return;
|
|
35723
|
-
}
|
|
35724
|
-
if (event.key === "Escape") {
|
|
35725
|
-
event.preventDefault();
|
|
35726
|
-
view.set({ kind: "none" });
|
|
35727
|
-
return;
|
|
35728
|
-
}
|
|
35729
|
-
if (root !== null) {
|
|
35730
|
-
const pageContainer = root.querySelector("[data-slot='docblocks/page']");
|
|
35731
|
-
if ((event.target === root || event.target === pageContainer) && (event.metaKey || event.ctrlKey) && event.shiftKey && (event.key === "ArrowUp" || event.key === "ArrowDown") && selection.ids.length === 1 && selection.ids[0] !== void 0) {
|
|
35732
|
-
const id = selection.ids[0];
|
|
35733
|
-
const siblings = doc.getChildren(rootBlockId);
|
|
35734
|
-
if (siblings.includes(id)) {
|
|
35735
|
-
const segment = segmentRange(doc, rootBlockId, id);
|
|
35736
|
-
if (segment !== null) {
|
|
35737
|
-
const length = segment.end - segment.start;
|
|
35738
|
-
const isSurface = (candidate) => doc.getBlock(candidate)?.type === "surface";
|
|
35739
|
-
let target = null;
|
|
35740
|
-
if (event.key === "ArrowUp") {
|
|
35741
|
-
let i = segment.start - 1;
|
|
35742
|
-
while (i >= 0 && isSurface(siblings[i])) i -= 1;
|
|
35743
|
-
if (i >= 0) target = i;
|
|
35744
|
-
} else {
|
|
35745
|
-
let j = segment.end;
|
|
35746
|
-
while (j < siblings.length && isSurface(siblings[j])) j += 1;
|
|
35747
|
-
if (j < siblings.length) target = j + 1;
|
|
35748
|
-
}
|
|
35749
|
-
if (target !== null) {
|
|
35750
|
-
event.preventDefault();
|
|
35751
|
-
moveSegmentInSequence(doc, rootBlockId, segment.start, length, target);
|
|
35752
|
-
view.set({
|
|
35753
|
-
kind: "blocks",
|
|
35754
|
-
ids: [id],
|
|
35755
|
-
anchorId: id
|
|
35756
|
-
});
|
|
35757
|
-
return;
|
|
35758
|
-
}
|
|
35759
|
-
}
|
|
35760
|
-
}
|
|
35761
|
-
}
|
|
35762
|
-
}
|
|
35763
|
-
}
|
|
35764
|
-
}
|
|
35765
|
-
if (!(event.metaKey || event.ctrlKey)) return;
|
|
35766
|
-
const key = event.key.toLowerCase();
|
|
35767
|
-
if (key === "z" && !event.shiftKey) {
|
|
35768
|
-
event.preventDefault();
|
|
35769
|
-
doc.undo();
|
|
35770
|
-
selectionRef.reseatUntil.current = Date.now() + RESEAT_WINDOW_MS;
|
|
35771
|
-
scheduleHistoryReseat(doc, view, root);
|
|
35772
|
-
} else if (key === "z" && event.shiftKey || key === "y") {
|
|
35773
|
-
event.preventDefault();
|
|
35774
|
-
doc.redo();
|
|
35775
|
-
selectionRef.reseatUntil.current = Date.now() + RESEAT_WINDOW_MS;
|
|
35776
|
-
scheduleHistoryReseat(doc, view, root);
|
|
35777
|
-
}
|
|
35778
|
-
};
|
|
35779
|
-
const onCopy = (event) => {
|
|
35780
|
-
if (mode === "published") return;
|
|
35781
|
-
const root = rootRef.current;
|
|
35782
|
-
const view = selectionRef.view;
|
|
35783
|
-
if (root === null || view === null) return;
|
|
35784
|
-
const nearest = (event.target instanceof Element ? event.target : null)?.closest("[data-slot=\"docblocks/editor\"]") ?? null;
|
|
35785
|
-
if (nearest !== null && nearest !== root) return;
|
|
35786
|
-
const selection = viewMode ? mapDomSelection(root, window.getSelection(), doc, { readOnly: true }) : view.get();
|
|
35787
|
-
if (selection.kind === "text" && selection.to !== null && selection.to.blockId === selection.from.blockId && selection.from.offset < selection.to.offset) {
|
|
35788
|
-
const block = doc.getBlock(selection.from.blockId);
|
|
35789
|
-
const content = block !== null && "content" in block ? block.content : void 0;
|
|
35790
|
-
if (content !== void 0) {
|
|
35791
|
-
let runStart = 0;
|
|
35792
|
-
let hasMention = false;
|
|
35793
|
-
for (const run of content) {
|
|
35794
|
-
const runEnd = runStart + run.text.length;
|
|
35795
|
-
if (run.marks.mention !== void 0 && runStart < selection.to.offset && runEnd > selection.from.offset) {
|
|
35796
|
-
hasMention = true;
|
|
35797
|
-
break;
|
|
35798
|
-
}
|
|
35799
|
-
runStart = runEnd;
|
|
35800
|
-
}
|
|
35801
|
-
if (hasMention) {
|
|
35802
|
-
const segment = segmentOf(content, selection.from.offset, selection.to.offset);
|
|
35803
|
-
event.preventDefault();
|
|
35804
|
-
event.clipboardData.setData("text/plain", segment.text);
|
|
35805
|
-
event.clipboardData.setData("text/html", segment.html);
|
|
35806
|
-
return;
|
|
35807
|
-
}
|
|
35808
|
-
}
|
|
35809
|
-
}
|
|
35810
|
-
const payload = clipboardContentOf(doc, selection);
|
|
35811
|
-
if (payload === null) return;
|
|
35812
|
-
event.preventDefault();
|
|
35813
|
-
event.clipboardData.setData("text/plain", payload.text);
|
|
35814
|
-
event.clipboardData.setData("text/html", payload.html);
|
|
35815
|
-
};
|
|
35903
|
+
}
|
|
35904
|
+
//#endregion
|
|
35905
|
+
//#region src/editing/editor-root/use-editing.ts
|
|
35906
|
+
/**
|
|
35907
|
+
* Document-level wiring owned by the editor root: `selectionchange` maps
|
|
35908
|
+
* the DOM selection to the core Selection view (`selection-tracking`), the
|
|
35909
|
+
* mod+z / mod+shift+z / mod+y hotkeys drive doc.undo()/doc.redo()
|
|
35910
|
+
* (`history-reseat`), the document-zone keys (select-all, ctrl+home/end)
|
|
35911
|
+
* and the blocks selection's keys stand in their own units, the copy event
|
|
35912
|
+
* carries the selection's payload (`copy-handler`), and the mouse drag's
|
|
35913
|
+
* cross selection runs the `cross-drag` session. The keydown and copy
|
|
35914
|
+
* listeners live on the root, so they never fire outside the editor.
|
|
35915
|
+
*
|
|
35916
|
+
* The selection view is read at event time through the stable context
|
|
35917
|
+
* handle: the view becomes live when the provider's mount effect runs,
|
|
35918
|
+
* which is after this hook's effect subscribed (child effects run first),
|
|
35919
|
+
* so a render-time value would be a stale null.
|
|
35920
|
+
*/
|
|
35921
|
+
function useEditing() {
|
|
35922
|
+
const { doc, rootBlockId, selection: selectionRef, viewMode, mode } = useEditorContext();
|
|
35923
|
+
const rootRef = useRef(null);
|
|
35924
|
+
const crossDrag = useCrossDrag(rootRef, doc, viewMode);
|
|
35925
|
+
useSelectionTracking(doc, rootRef, selectionRef, viewMode);
|
|
35816
35926
|
return {
|
|
35817
35927
|
rootRef,
|
|
35818
|
-
onKeyDown
|
|
35819
|
-
|
|
35928
|
+
onKeyDown: useCallback((event) => {
|
|
35929
|
+
const root = rootRef.current;
|
|
35930
|
+
const target = event.target instanceof Element ? event.target : null;
|
|
35931
|
+
const nearest = target?.closest("[data-slot=\"docblocks/editor\"]") ?? null;
|
|
35932
|
+
if (root !== null && nearest !== null && nearest !== root) return;
|
|
35933
|
+
const formControl = target?.closest("input, textarea, [contenteditable='true']") ?? null;
|
|
35934
|
+
if (root !== null && target !== null && formControl !== null && !root.contains(target)) return;
|
|
35935
|
+
if (root !== null) {
|
|
35936
|
+
const documentScope = {
|
|
35937
|
+
doc,
|
|
35938
|
+
rootBlockId,
|
|
35939
|
+
root,
|
|
35940
|
+
target
|
|
35941
|
+
};
|
|
35942
|
+
if (handleSelectAll(event, documentScope)) return;
|
|
35943
|
+
if (handleDocumentEdge(event, documentScope)) return;
|
|
35944
|
+
}
|
|
35945
|
+
if (viewMode) return;
|
|
35946
|
+
const view = selectionRef.view;
|
|
35947
|
+
if (view !== null && handleBlocksSelectionKeys(event, {
|
|
35948
|
+
doc,
|
|
35949
|
+
rootBlockId,
|
|
35950
|
+
root,
|
|
35951
|
+
view
|
|
35952
|
+
})) return;
|
|
35953
|
+
if (!(event.metaKey || event.ctrlKey)) return;
|
|
35954
|
+
const key = event.key.toLowerCase();
|
|
35955
|
+
if (key === "z" && !event.shiftKey) {
|
|
35956
|
+
event.preventDefault();
|
|
35957
|
+
doc.undo();
|
|
35958
|
+
selectionRef.reseatUntil.current = Date.now() + RESEAT_WINDOW_MS;
|
|
35959
|
+
scheduleHistoryReseat(doc, view, root);
|
|
35960
|
+
} else if (key === "z" && event.shiftKey || key === "y") {
|
|
35961
|
+
event.preventDefault();
|
|
35962
|
+
doc.redo();
|
|
35963
|
+
selectionRef.reseatUntil.current = Date.now() + RESEAT_WINDOW_MS;
|
|
35964
|
+
scheduleHistoryReseat(doc, view, root);
|
|
35965
|
+
}
|
|
35966
|
+
}, [
|
|
35967
|
+
doc,
|
|
35968
|
+
rootBlockId,
|
|
35969
|
+
selectionRef,
|
|
35970
|
+
viewMode
|
|
35971
|
+
]),
|
|
35972
|
+
onCopy: createCopyHandler({
|
|
35973
|
+
doc,
|
|
35974
|
+
mode,
|
|
35975
|
+
viewMode,
|
|
35976
|
+
rootRef,
|
|
35977
|
+
selectionRef
|
|
35978
|
+
}),
|
|
35820
35979
|
onPointerDown: (event) => {
|
|
35821
35980
|
if (viewMode) return;
|
|
35822
35981
|
crossDrag.onPointerDown(event);
|
|
@@ -36815,7 +36974,7 @@ function useMotionDrag({ doc, rootBlockId, store, rootRef, rowKeys, nodesById })
|
|
|
36815
36974
|
* palette.
|
|
36816
36975
|
*/
|
|
36817
36976
|
function Editor({ view = "page", formatPalette = FORMAT_PALETTE }) {
|
|
36818
|
-
const { doc, store, rootBlockId, viewMode, mode } = useEditorContext();
|
|
36977
|
+
const { doc, store, rootBlockId, viewMode, mode, mentionInteractions } = useEditorContext();
|
|
36819
36978
|
const rootChildren = useStore(store, (state) => state.rootChildren);
|
|
36820
36979
|
const attributes = useStore(store, (state) => state.meta.attributes);
|
|
36821
36980
|
const coverTintEnabled = (typeof attributes?.cover === "string" ? attributes.cover : void 0) !== void 0 && attributes?.coverTint !== false;
|
|
@@ -36902,6 +37061,7 @@ function Editor({ view = "page", formatPalette = FORMAT_PALETTE }) {
|
|
|
36902
37061
|
"data-view": view,
|
|
36903
37062
|
"data-mode": mode,
|
|
36904
37063
|
"data-readonly": viewMode ? "true" : void 0,
|
|
37064
|
+
"data-mention-interactive": mentionInteractions !== null ? "true" : void 0,
|
|
36905
37065
|
tabIndex: -1,
|
|
36906
37066
|
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)"),
|
|
36907
37067
|
onKeyDown,
|