@beyondwork/docx-react-component 1.0.131 → 1.0.133
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/dist/api/public-types.cjs +837 -224
- package/dist/api/public-types.d.cts +2 -2
- package/dist/api/public-types.d.ts +2 -2
- package/dist/api/public-types.js +5 -3
- package/dist/api/v3.cjs +9679 -7492
- package/dist/api/v3.d.cts +3 -3
- package/dist/api/v3.d.ts +3 -3
- package/dist/api/v3.js +10 -10
- package/dist/{canonical-document-BMtONpgf.d.cts → canonical-document-CfZIc-fC.d.cts} +1 -1
- package/dist/{canonical-document-BMtONpgf.d.ts → canonical-document-CfZIc-fC.d.ts} +1 -1
- package/dist/{chunk-7G5GR3VV.js → chunk-224TSMEB.js} +635 -89
- package/dist/{chunk-YLL7MF5C.js → chunk-3JEE5RJU.js} +103 -135
- package/dist/{chunk-35RHOE6I.js → chunk-57HTKX3P.js} +10 -1162
- package/dist/{chunk-A66ZVUAT.js → chunk-5KTJKTNE.js} +236 -10
- package/dist/{chunk-THVM6EP5.js → chunk-CVSD3UNK.js} +1322 -102
- package/dist/{chunk-VRKK2CSZ.js → chunk-EFEW7BTT.js} +2 -2
- package/dist/{chunk-KNHMXKC6.js → chunk-INLRCC4N.js} +2 -2
- package/dist/{chunk-HYHCRMR7.js → chunk-KL4TZSZV.js} +1 -1
- package/dist/{chunk-T5YYFDZB.js → chunk-MQ5GAJ54.js} +68 -39
- package/dist/{chunk-CI2TD3T4.js → chunk-NJFKPDNG.js} +216 -2
- package/dist/{chunk-WZDKNF37.js → chunk-OTRVGNZQ.js} +2934 -1815
- package/dist/{chunk-4YCWECLZ.js → chunk-PZIEOEJZ.js} +1 -1
- package/dist/{chunk-PHMWH23E.js → chunk-QTRJLKR2.js} +1 -1
- package/dist/{chunk-QXKQPUOM.js → chunk-REFHJ2FN.js} +3 -3
- package/dist/{chunk-ZVC23LKV.js → chunk-RP76USJE.js} +1 -1
- package/dist/{chunk-3YCQM2RV.js → chunk-S3PEKX6H.js} +249 -45
- package/dist/{chunk-M7YRJX6V.js → chunk-T66OS7MN.js} +8 -3
- package/dist/{chunk-DGA7M77X.js → chunk-V2JF42SI.js} +2 -2
- package/dist/{chunk-Q7Y57KOK.js → chunk-WDDFU2N2.js} +2 -2
- package/dist/{chunk-A3GSNB4G.js → chunk-XBQFDBXE.js} +147 -13
- package/dist/{chunk-6TBLDBCL.js → chunk-ZFCZ7XXH.js} +1 -1
- package/dist/compare.d.cts +1 -1
- package/dist/compare.d.ts +1 -1
- package/dist/core/commands/formatting-commands.d.cts +2 -2
- package/dist/core/commands/formatting-commands.d.ts +2 -2
- package/dist/core/commands/image-commands.cjs +344 -20
- package/dist/core/commands/image-commands.d.cts +2 -2
- package/dist/core/commands/image-commands.d.ts +2 -2
- package/dist/core/commands/image-commands.js +5 -5
- package/dist/core/commands/section-layout-commands.d.cts +2 -2
- package/dist/core/commands/section-layout-commands.d.ts +2 -2
- package/dist/core/commands/style-commands.d.cts +2 -2
- package/dist/core/commands/style-commands.d.ts +2 -2
- package/dist/core/commands/table-structure-commands.cjs +344 -20
- package/dist/core/commands/table-structure-commands.d.cts +2 -2
- package/dist/core/commands/table-structure-commands.d.ts +2 -2
- package/dist/core/commands/table-structure-commands.js +4 -4
- package/dist/core/commands/text-commands.cjs +411 -58
- package/dist/core/commands/text-commands.d.cts +13 -2
- package/dist/core/commands/text-commands.d.ts +13 -2
- package/dist/core/commands/text-commands.js +5 -5
- package/dist/core/selection/mapping.d.cts +2 -2
- package/dist/core/selection/mapping.d.ts +2 -2
- package/dist/core/state/editor-state.d.cts +2 -2
- package/dist/core/state/editor-state.d.ts +2 -2
- package/dist/index.cjs +7199 -4004
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +814 -120
- package/dist/io/docx-session.cjs +7 -2
- package/dist/io/docx-session.d.cts +4 -4
- package/dist/io/docx-session.d.ts +4 -4
- package/dist/io/docx-session.js +4 -4
- package/dist/legal.d.cts +1 -1
- package/dist/legal.d.ts +1 -1
- package/dist/legal.js +3 -3
- package/dist/{loader-DiY_ZgKl.d.cts → loader-B2H99237.d.cts} +3 -3
- package/dist/{loader-B-aL5HGD.d.ts → loader-DfTjqVwn.d.ts} +3 -3
- package/dist/{public-types-gvubspUI.d.cts → public-types-B5lOUIrP.d.ts} +930 -338
- package/dist/{public-types-DyqnxxO9.d.ts → public-types-S8gTYwKo.d.cts} +930 -338
- package/dist/public-types.cjs +837 -224
- package/dist/public-types.d.cts +2 -2
- package/dist/public-types.d.ts +2 -2
- package/dist/public-types.js +5 -3
- package/dist/runtime/collab.d.cts +3 -3
- package/dist/runtime/collab.d.ts +3 -3
- package/dist/runtime/document-runtime.cjs +1403 -438
- package/dist/runtime/document-runtime.d.cts +2 -2
- package/dist/runtime/document-runtime.d.ts +2 -2
- package/dist/runtime/document-runtime.js +14 -14
- package/dist/{session-CDB0hohT.d.ts → session-CBDIOYXA.d.ts} +3 -3
- package/dist/{session-BUN6B-Vj.d.cts → session-CR2A1hGZ.d.cts} +3 -3
- package/dist/session.cjs +7 -2
- package/dist/session.d.cts +5 -5
- package/dist/session.d.ts +5 -5
- package/dist/session.js +5 -5
- package/dist/tailwind.cjs +905 -322
- package/dist/tailwind.d.cts +2 -2
- package/dist/tailwind.d.ts +2 -2
- package/dist/tailwind.js +7 -7
- package/dist/{types-VWH6CRvG.d.ts → types-B-90ywjU.d.ts} +2 -2
- package/dist/{types-C4bz3kDU.d.cts → types-yty2K-hk.d.cts} +2 -2
- package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +3 -3
- package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +3 -3
- package/dist/ui-tailwind/editor-surface/search-plugin.js +4 -4
- package/dist/ui-tailwind.cjs +905 -322
- package/dist/ui-tailwind.d.cts +4 -3
- package/dist/ui-tailwind.d.ts +4 -3
- package/dist/ui-tailwind.js +7 -7
- package/package.json +1 -1
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
getRevisionActionability,
|
|
9
9
|
normalizeParsedTextDocument,
|
|
10
10
|
normalizeParsedTextDocumentAsync
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-PZIEOEJZ.js";
|
|
12
12
|
import {
|
|
13
13
|
OLE_RELATIONSHIP_TYPES,
|
|
14
14
|
buildFieldRegistry,
|
|
@@ -59,7 +59,7 @@ import {
|
|
|
59
59
|
resolveHighlightColor,
|
|
60
60
|
setActiveParseTelemetryBus,
|
|
61
61
|
toCanonicalNumberingInstanceId
|
|
62
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-T66OS7MN.js";
|
|
63
63
|
import {
|
|
64
64
|
createPersistedSourcePackage,
|
|
65
65
|
decodeBytesBase64,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TextTransactionError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MQ5GAJ54.js";
|
|
4
4
|
import {
|
|
5
5
|
replaceParagraphScope,
|
|
6
6
|
resolveParagraphScope
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-QTRJLKR2.js";
|
|
8
8
|
import {
|
|
9
9
|
cloneParagraphProperties,
|
|
10
10
|
cloneStoryUnit,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
NO_EDITABLE_TARGETS_INDEX,
|
|
12
12
|
createEditorSurfaceSnapshot
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-XBQFDBXE.js";
|
|
14
14
|
import {
|
|
15
15
|
createSelectionSnapshot
|
|
16
16
|
} from "./chunk-OYGMRRR7.js";
|
|
@@ -24,7 +24,38 @@ var TextTransactionError = class extends Error {
|
|
|
24
24
|
this.code = code;
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
|
+
function isUsableScopeSurface(surface, document) {
|
|
28
|
+
if (surface.viewportBlockRanges !== null) return false;
|
|
29
|
+
const root = document.content;
|
|
30
|
+
if (!root || root.type !== "doc" || !Array.isArray(root.children)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
return surface.blocks.length === root.children.length;
|
|
34
|
+
}
|
|
35
|
+
function createScopeSurfaceCache(document, selection, precomputedSurface, telemetry) {
|
|
36
|
+
let cached;
|
|
37
|
+
if (precomputedSurface && isUsableScopeSurface(precomputedSurface, document)) {
|
|
38
|
+
cached = precomputedSurface;
|
|
39
|
+
telemetry?.onPrecomputedSurfaceHit?.();
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
get() {
|
|
43
|
+
if (cached) return cached;
|
|
44
|
+
telemetry?.onScopeSurfaceBuild?.();
|
|
45
|
+
cached = createEditorSurfaceSnapshot(document, selection, void 0, {
|
|
46
|
+
editableTargetsByBlockPath: NO_EDITABLE_TARGETS_INDEX
|
|
47
|
+
});
|
|
48
|
+
return cached;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
}
|
|
27
52
|
function applyTextTransaction(document, selection, intent, options) {
|
|
53
|
+
const scopeSurfaceCache = createScopeSurfaceCache(
|
|
54
|
+
document,
|
|
55
|
+
selection,
|
|
56
|
+
options.precomputedSurface,
|
|
57
|
+
options.surfaceTelemetry
|
|
58
|
+
);
|
|
28
59
|
if (options.textTarget) {
|
|
29
60
|
if (options.textTarget.kind === "hyperlink-display") {
|
|
30
61
|
const targetedHyperlinkResult = tryApplyHyperlinkDisplayTransaction(
|
|
@@ -60,7 +91,8 @@ function applyTextTransaction(document, selection, intent, options) {
|
|
|
60
91
|
document,
|
|
61
92
|
selection,
|
|
62
93
|
intent,
|
|
63
|
-
options
|
|
94
|
+
options,
|
|
95
|
+
scopeSurfaceCache
|
|
64
96
|
);
|
|
65
97
|
if (targetedTableResult) {
|
|
66
98
|
return targetedTableResult;
|
|
@@ -74,7 +106,8 @@ function applyTextTransaction(document, selection, intent, options) {
|
|
|
74
106
|
const tableStructureRefusal = resolveTargetlessTableStructureInsertRefusal(
|
|
75
107
|
document,
|
|
76
108
|
selection,
|
|
77
|
-
intent
|
|
109
|
+
intent,
|
|
110
|
+
scopeSurfaceCache
|
|
78
111
|
);
|
|
79
112
|
if (tableStructureRefusal) {
|
|
80
113
|
throw new TextTransactionError("unsupported_content", tableStructureRefusal);
|
|
@@ -84,7 +117,8 @@ function applyTextTransaction(document, selection, intent, options) {
|
|
|
84
117
|
document,
|
|
85
118
|
selection,
|
|
86
119
|
intent,
|
|
87
|
-
options
|
|
120
|
+
options,
|
|
121
|
+
scopeSurfaceCache
|
|
88
122
|
);
|
|
89
123
|
if (topLevelParagraphResult) {
|
|
90
124
|
return topLevelParagraphResult;
|
|
@@ -93,7 +127,8 @@ function applyTextTransaction(document, selection, intent, options) {
|
|
|
93
127
|
document,
|
|
94
128
|
selection,
|
|
95
129
|
intent,
|
|
96
|
-
options
|
|
130
|
+
options,
|
|
131
|
+
scopeSurfaceCache
|
|
97
132
|
);
|
|
98
133
|
if (sdtScopedResult) {
|
|
99
134
|
return sdtScopedResult;
|
|
@@ -102,7 +137,8 @@ function applyTextTransaction(document, selection, intent, options) {
|
|
|
102
137
|
document,
|
|
103
138
|
selection,
|
|
104
139
|
intent,
|
|
105
|
-
options
|
|
140
|
+
options,
|
|
141
|
+
scopeSurfaceCache
|
|
106
142
|
);
|
|
107
143
|
if (tableScopedResult) {
|
|
108
144
|
return tableScopedResult;
|
|
@@ -155,9 +191,9 @@ function applyLinearTextTransaction(document, selection, intent, options) {
|
|
|
155
191
|
storyText: createPlainText(nextStory)
|
|
156
192
|
};
|
|
157
193
|
}
|
|
158
|
-
function tryApplyTableParagraphTransaction(document, selection, intent, options) {
|
|
194
|
+
function tryApplyTableParagraphTransaction(document, selection, intent, options, scopeSurfaceCache) {
|
|
159
195
|
const tableTarget = options.textTarget?.kind === "table-paragraph" ? options.textTarget : void 0;
|
|
160
|
-
const scope = resolveTableParagraphScope(document, selection, tableTarget);
|
|
196
|
+
const scope = resolveTableParagraphScope(document, selection, tableTarget, scopeSurfaceCache);
|
|
161
197
|
if (!scope) {
|
|
162
198
|
return null;
|
|
163
199
|
}
|
|
@@ -280,7 +316,11 @@ function tryApplyTargetedTextLeafTransaction(document, selection, intent, option
|
|
|
280
316
|
};
|
|
281
317
|
}
|
|
282
318
|
function tryApplyHyperlinkDisplayTransaction(document, selection, intent, options) {
|
|
283
|
-
const scope = resolveTargetedHyperlinkDisplayScope(
|
|
319
|
+
const scope = resolveTargetedHyperlinkDisplayScope(
|
|
320
|
+
document,
|
|
321
|
+
selection,
|
|
322
|
+
options.textTarget
|
|
323
|
+
);
|
|
284
324
|
if (!scope) {
|
|
285
325
|
return null;
|
|
286
326
|
}
|
|
@@ -338,8 +378,8 @@ function tryApplyHyperlinkDisplayTransaction(document, selection, intent, option
|
|
|
338
378
|
storyText: localResult.storyText
|
|
339
379
|
};
|
|
340
380
|
}
|
|
341
|
-
function tryApplyTopLevelSdtParagraphTransaction(document, selection, intent, options) {
|
|
342
|
-
const scope = resolveTopLevelSdtParagraphScope(document, selection);
|
|
381
|
+
function tryApplyTopLevelSdtParagraphTransaction(document, selection, intent, options, scopeSurfaceCache) {
|
|
382
|
+
const scope = resolveTopLevelSdtParagraphScope(document, selection, scopeSurfaceCache);
|
|
343
383
|
if (!scope) {
|
|
344
384
|
return null;
|
|
345
385
|
}
|
|
@@ -391,8 +431,8 @@ function tryApplyTopLevelSdtParagraphTransaction(document, selection, intent, op
|
|
|
391
431
|
storyText: localResult.storyText
|
|
392
432
|
};
|
|
393
433
|
}
|
|
394
|
-
function tryApplyTopLevelParagraphTransaction(document, selection, intent, options) {
|
|
395
|
-
const scope = resolveTopLevelParagraphScope(document, selection);
|
|
434
|
+
function tryApplyTopLevelParagraphTransaction(document, selection, intent, options, scopeSurfaceCache) {
|
|
435
|
+
const scope = resolveTopLevelParagraphScope(document, selection, scopeSurfaceCache);
|
|
396
436
|
if (!scope) {
|
|
397
437
|
return null;
|
|
398
438
|
}
|
|
@@ -502,17 +542,15 @@ function resolveTargetedHyperlinkDisplayScope(document, selection, target) {
|
|
|
502
542
|
replace: resolved.replace
|
|
503
543
|
};
|
|
504
544
|
}
|
|
505
|
-
function resolveTableParagraphScope(document, selection, target) {
|
|
545
|
+
function resolveTableParagraphScope(document, selection, target, scopeSurfaceCache) {
|
|
506
546
|
if (target) {
|
|
507
|
-
return resolveTargetedTableParagraphScope(document, selection, target);
|
|
547
|
+
return resolveTargetedTableParagraphScope(document, selection, target, scopeSurfaceCache);
|
|
508
548
|
}
|
|
509
549
|
const root = document.content;
|
|
510
550
|
if (!root || root.type !== "doc" || !Array.isArray(root.children)) {
|
|
511
551
|
return null;
|
|
512
552
|
}
|
|
513
|
-
const surface =
|
|
514
|
-
editableTargetsByBlockPath: NO_EDITABLE_TARGETS_INDEX
|
|
515
|
-
});
|
|
553
|
+
const surface = scopeSurfaceCache.get();
|
|
516
554
|
const selectionFrom = Math.min(selection.anchor, selection.head);
|
|
517
555
|
const selectionTo = Math.max(selection.anchor, selection.head);
|
|
518
556
|
for (let blockIndex = 0; blockIndex < root.children.length; blockIndex += 1) {
|
|
@@ -617,7 +655,7 @@ function resolveTableParagraphScope(document, selection, target) {
|
|
|
617
655
|
}
|
|
618
656
|
return null;
|
|
619
657
|
}
|
|
620
|
-
function resolveTargetlessTableStructureInsertRefusal(document, selection, intent) {
|
|
658
|
+
function resolveTargetlessTableStructureInsertRefusal(document, selection, intent, scopeSurfaceCache) {
|
|
621
659
|
if (!isCollapsedInsertIntent(intent, selection)) {
|
|
622
660
|
return null;
|
|
623
661
|
}
|
|
@@ -625,9 +663,7 @@ function resolveTargetlessTableStructureInsertRefusal(document, selection, inten
|
|
|
625
663
|
if (!root || root.type !== "doc" || !Array.isArray(root.children)) {
|
|
626
664
|
return null;
|
|
627
665
|
}
|
|
628
|
-
const surface =
|
|
629
|
-
editableTargetsByBlockPath: NO_EDITABLE_TARGETS_INDEX
|
|
630
|
-
});
|
|
666
|
+
const surface = scopeSurfaceCache.get();
|
|
631
667
|
if (!selectionTouchesTableStructureBoundary(surface.blocks, selection.anchor)) {
|
|
632
668
|
return null;
|
|
633
669
|
}
|
|
@@ -641,7 +677,7 @@ function isCollapsedInsertIntent(intent, selection) {
|
|
|
641
677
|
const rangeTo = intent.range ? Math.max(intent.range.from, intent.range.to) : Math.max(selection.anchor, selection.head);
|
|
642
678
|
return rangeFrom === rangeTo;
|
|
643
679
|
}
|
|
644
|
-
function resolveTargetedTableParagraphScope(document, selection, target) {
|
|
680
|
+
function resolveTargetedTableParagraphScope(document, selection, target, scopeSurfaceCache) {
|
|
645
681
|
const root = document.content;
|
|
646
682
|
if (!root || root.type !== "doc" || !Array.isArray(root.children)) {
|
|
647
683
|
return null;
|
|
@@ -654,7 +690,8 @@ function resolveTargetedTableParagraphScope(document, selection, target) {
|
|
|
654
690
|
root,
|
|
655
691
|
document,
|
|
656
692
|
selection,
|
|
657
|
-
target
|
|
693
|
+
target,
|
|
694
|
+
scopeSurfaceCache
|
|
658
695
|
);
|
|
659
696
|
if (targetScope) {
|
|
660
697
|
return targetScope;
|
|
@@ -677,9 +714,7 @@ function resolveTargetedTableParagraphScope(document, selection, target) {
|
|
|
677
714
|
if (cell.verticalMerge === "continue") {
|
|
678
715
|
return "unsupported";
|
|
679
716
|
}
|
|
680
|
-
const surface =
|
|
681
|
-
editableTargetsByBlockPath: NO_EDITABLE_TARGETS_INDEX
|
|
682
|
-
});
|
|
717
|
+
const surface = scopeSurfaceCache.get();
|
|
683
718
|
const surfaceBlock = surface.blocks[target.tableBlockIndex];
|
|
684
719
|
const surfaceRow = surfaceBlock?.kind === "table" ? surfaceBlock.rows[target.rowIndex] : void 0;
|
|
685
720
|
const surfaceCell = surfaceRow?.cells[target.cellIndex];
|
|
@@ -743,16 +778,14 @@ function resolveTargetedTableParagraphScope(document, selection, target) {
|
|
|
743
778
|
}
|
|
744
779
|
};
|
|
745
780
|
}
|
|
746
|
-
function resolveTargetedTableParagraphScopeByPath(root, document, selection, target) {
|
|
781
|
+
function resolveTargetedTableParagraphScopeByPath(root, document, selection, target, scopeSurfaceCache) {
|
|
747
782
|
if (!target.blockPath) return null;
|
|
748
783
|
const tokens = parseCanonicalBlockPath(target.blockPath);
|
|
749
784
|
if (!tokens) return null;
|
|
750
785
|
const resolved = resolveBlockPathInCanonicalBlocks(root.children, tokens, 0);
|
|
751
786
|
if (!resolved || resolved.block.type !== "paragraph") return null;
|
|
752
787
|
if (resolved.hasVerticalMergeContinuation) return null;
|
|
753
|
-
const surface =
|
|
754
|
-
editableTargetsByBlockPath: NO_EDITABLE_TARGETS_INDEX
|
|
755
|
-
});
|
|
788
|
+
const surface = scopeSurfaceCache.get();
|
|
756
789
|
const surfaceResolved = resolveBlockPathInSurfaceBlocks(surface.blocks, tokens, 0);
|
|
757
790
|
if (!surfaceResolved || surfaceResolved.kind !== "paragraph") return null;
|
|
758
791
|
if (surfaceResolved.hasVerticalMergeContinuation) return null;
|
|
@@ -1207,14 +1240,12 @@ function resolveBlockPathInSurfaceBlocks(blocks, tokens, tokenIndex, hasVertical
|
|
|
1207
1240
|
hasVerticalMergeContinuation || cell.verticalMerge === "continue"
|
|
1208
1241
|
);
|
|
1209
1242
|
}
|
|
1210
|
-
function resolveTopLevelParagraphScope(document, selection) {
|
|
1243
|
+
function resolveTopLevelParagraphScope(document, selection, scopeSurfaceCache) {
|
|
1211
1244
|
const root = document.content;
|
|
1212
1245
|
if (!root || root.type !== "doc" || !Array.isArray(root.children)) {
|
|
1213
1246
|
return null;
|
|
1214
1247
|
}
|
|
1215
|
-
const surface =
|
|
1216
|
-
editableTargetsByBlockPath: NO_EDITABLE_TARGETS_INDEX
|
|
1217
|
-
});
|
|
1248
|
+
const surface = scopeSurfaceCache.get();
|
|
1218
1249
|
const selectionFrom = Math.min(selection.anchor, selection.head);
|
|
1219
1250
|
const selectionTo = Math.max(selection.anchor, selection.head);
|
|
1220
1251
|
for (let blockIndex = 0; blockIndex < root.children.length; blockIndex += 1) {
|
|
@@ -1243,14 +1274,12 @@ function resolveTopLevelParagraphScope(document, selection) {
|
|
|
1243
1274
|
}
|
|
1244
1275
|
return null;
|
|
1245
1276
|
}
|
|
1246
|
-
function resolveTopLevelSdtParagraphScope(document, selection) {
|
|
1277
|
+
function resolveTopLevelSdtParagraphScope(document, selection, scopeSurfaceCache) {
|
|
1247
1278
|
const root = document.content;
|
|
1248
1279
|
if (!root || root.type !== "doc" || !Array.isArray(root.children)) {
|
|
1249
1280
|
return null;
|
|
1250
1281
|
}
|
|
1251
|
-
const surface =
|
|
1252
|
-
editableTargetsByBlockPath: NO_EDITABLE_TARGETS_INDEX
|
|
1253
|
-
});
|
|
1282
|
+
const surface = scopeSurfaceCache.get();
|
|
1254
1283
|
const selectionFrom = Math.min(selection.anchor, selection.head);
|
|
1255
1284
|
const selectionTo = Math.max(selection.anchor, selection.head);
|
|
1256
1285
|
for (let blockIndex = 0; blockIndex < root.children.length; blockIndex += 1) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
collectEditableTargetRefs
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5KTJKTNE.js";
|
|
4
4
|
|
|
5
5
|
// src/api/v3/_ux-response.ts
|
|
6
6
|
function emitUxResponse(runtime, res) {
|
|
@@ -2110,6 +2110,218 @@ function createScopeFamily(ctx) {
|
|
|
2110
2110
|
};
|
|
2111
2111
|
}
|
|
2112
2112
|
|
|
2113
|
+
// src/api/v3/ui/lists.ts
|
|
2114
|
+
var SUPPORTED_COMMANDS = [
|
|
2115
|
+
"toggle-numbered",
|
|
2116
|
+
"toggle-bulleted",
|
|
2117
|
+
"indent",
|
|
2118
|
+
"outdent",
|
|
2119
|
+
"restart-numbering",
|
|
2120
|
+
"continue-numbering"
|
|
2121
|
+
];
|
|
2122
|
+
var UNSUPPORTED_COMMANDS = [
|
|
2123
|
+
"create",
|
|
2124
|
+
"attach",
|
|
2125
|
+
"detach",
|
|
2126
|
+
"join",
|
|
2127
|
+
"separate",
|
|
2128
|
+
"split",
|
|
2129
|
+
"set-value",
|
|
2130
|
+
"apply-template",
|
|
2131
|
+
"capture-template",
|
|
2132
|
+
"apply-preset",
|
|
2133
|
+
"set-level-numbering",
|
|
2134
|
+
"set-level-bullet",
|
|
2135
|
+
"set-level-picture-bullet",
|
|
2136
|
+
"set-level-alignment",
|
|
2137
|
+
"set-level-indents",
|
|
2138
|
+
"set-level-trailing-character",
|
|
2139
|
+
"set-level-marker-font",
|
|
2140
|
+
"set-level-text",
|
|
2141
|
+
"set-level-start",
|
|
2142
|
+
"set-level-layout",
|
|
2143
|
+
"convert-to-text",
|
|
2144
|
+
"paste-fragment",
|
|
2145
|
+
"drop-fragment"
|
|
2146
|
+
];
|
|
2147
|
+
function createListsFamily(ctx) {
|
|
2148
|
+
return {
|
|
2149
|
+
list(filter) {
|
|
2150
|
+
const rows = collectListReadbacks(ctx);
|
|
2151
|
+
const filtered = filter?.storyKey === void 0 ? rows : rows.filter((row) => row.storyKey === filter.storyKey);
|
|
2152
|
+
if (typeof filter?.limit === "number") {
|
|
2153
|
+
return filtered.slice(0, Math.max(0, filter.limit));
|
|
2154
|
+
}
|
|
2155
|
+
return filtered;
|
|
2156
|
+
},
|
|
2157
|
+
get(target) {
|
|
2158
|
+
return findReadback(collectListReadbacks(ctx), target);
|
|
2159
|
+
},
|
|
2160
|
+
previewCommand(target) {
|
|
2161
|
+
const row = findReadback(collectListReadbacks(ctx), target);
|
|
2162
|
+
if (!row) {
|
|
2163
|
+
return {
|
|
2164
|
+
command: target.command,
|
|
2165
|
+
supported: false,
|
|
2166
|
+
blockers: [
|
|
2167
|
+
{
|
|
2168
|
+
command: target.command,
|
|
2169
|
+
enabled: false,
|
|
2170
|
+
reason: "list-target-not-found",
|
|
2171
|
+
ownerLayer: "L10"
|
|
2172
|
+
}
|
|
2173
|
+
]
|
|
2174
|
+
};
|
|
2175
|
+
}
|
|
2176
|
+
const command = row.commandSupport.find((candidate) => candidate.command === target.command);
|
|
2177
|
+
const blocker = command && !command.enabled ? [command] : [];
|
|
2178
|
+
return {
|
|
2179
|
+
command: target.command,
|
|
2180
|
+
supported: Boolean(command?.enabled),
|
|
2181
|
+
target: row,
|
|
2182
|
+
blockers: blocker,
|
|
2183
|
+
canJoin: row.canJoin,
|
|
2184
|
+
canContinuePrevious: row.canContinuePrevious
|
|
2185
|
+
};
|
|
2186
|
+
}
|
|
2187
|
+
};
|
|
2188
|
+
}
|
|
2189
|
+
function collectListReadbacks(ctx) {
|
|
2190
|
+
const surface = ctx.handle.getRenderSnapshot().surface;
|
|
2191
|
+
if (!surface) return [];
|
|
2192
|
+
const paragraphs = [];
|
|
2193
|
+
collectParagraphs(surface.blocks, paragraphs);
|
|
2194
|
+
for (const secondary of surface.secondaryStories) {
|
|
2195
|
+
collectParagraphs(secondary.blocks, paragraphs);
|
|
2196
|
+
}
|
|
2197
|
+
const rows = [];
|
|
2198
|
+
for (let index = 0; index < paragraphs.length; index += 1) {
|
|
2199
|
+
const entry = paragraphs[index];
|
|
2200
|
+
if (!entry) continue;
|
|
2201
|
+
const row = rowForParagraph(entry.block, paragraphs, index);
|
|
2202
|
+
if (row) rows.push(row);
|
|
2203
|
+
}
|
|
2204
|
+
return rows;
|
|
2205
|
+
}
|
|
2206
|
+
function collectParagraphs(blocks, out) {
|
|
2207
|
+
for (const block of blocks) {
|
|
2208
|
+
switch (block.kind) {
|
|
2209
|
+
case "paragraph":
|
|
2210
|
+
out.push({ block });
|
|
2211
|
+
break;
|
|
2212
|
+
case "table":
|
|
2213
|
+
for (const row of block.rows) {
|
|
2214
|
+
for (const cell of row.cells) {
|
|
2215
|
+
collectParagraphs(cell.content, out);
|
|
2216
|
+
}
|
|
2217
|
+
}
|
|
2218
|
+
break;
|
|
2219
|
+
case "sdt_block":
|
|
2220
|
+
collectParagraphs(block.children, out);
|
|
2221
|
+
break;
|
|
2222
|
+
default:
|
|
2223
|
+
break;
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
}
|
|
2227
|
+
function rowForParagraph(block, paragraphs, paragraphIndex) {
|
|
2228
|
+
const target = block.editableTarget;
|
|
2229
|
+
const listAddress = target?.listAddress;
|
|
2230
|
+
const numbering = block.numbering;
|
|
2231
|
+
if (!target || !listAddress || !numbering || !block.resolvedNumbering) return null;
|
|
2232
|
+
const listKind = inferListKind(block.resolvedNumbering);
|
|
2233
|
+
const previousParagraph = paragraphs[paragraphIndex - 1]?.block;
|
|
2234
|
+
const canJoin = Boolean(
|
|
2235
|
+
previousParagraph?.numbering && previousParagraph.numbering.numberingInstanceId !== numbering.numberingInstanceId && inferListKind(previousParagraph.resolvedNumbering) === listKind
|
|
2236
|
+
);
|
|
2237
|
+
const canContinuePrevious = paragraphs.slice(0, paragraphIndex).some(
|
|
2238
|
+
({ block: previous }) => Boolean(
|
|
2239
|
+
previous.numbering && previous.numbering.numberingInstanceId !== numbering.numberingInstanceId && inferListKind(previous.resolvedNumbering) === listKind
|
|
2240
|
+
)
|
|
2241
|
+
);
|
|
2242
|
+
const actionHandle = `list-action:${listAddress.addressKey}`;
|
|
2243
|
+
const blockers = target.posture.blockers;
|
|
2244
|
+
const commandSupport = commandAvailability({
|
|
2245
|
+
actionHandle,
|
|
2246
|
+
blockers,
|
|
2247
|
+
canContinuePrevious
|
|
2248
|
+
});
|
|
2249
|
+
return {
|
|
2250
|
+
source: "surface-render-snapshot",
|
|
2251
|
+
targetKey: target.targetKey,
|
|
2252
|
+
actionHandle,
|
|
2253
|
+
kind: target.kind,
|
|
2254
|
+
storyKey: target.storyKey,
|
|
2255
|
+
blockPath: target.blockPath,
|
|
2256
|
+
leafPath: target.leafPath,
|
|
2257
|
+
addressKey: listAddress.addressKey,
|
|
2258
|
+
hierarchyPath: [numbering.level],
|
|
2259
|
+
numberingInstanceId: numbering.numberingInstanceId,
|
|
2260
|
+
level: numbering.level,
|
|
2261
|
+
listKind,
|
|
2262
|
+
...block.resolvedNumbering.text !== void 0 ? { markerText: block.resolvedNumbering.text } : {},
|
|
2263
|
+
...block.resolvedNumbering.suffix !== void 0 ? { suffix: block.resolvedNumbering.suffix } : {},
|
|
2264
|
+
requestedFormat: block.resolvedNumbering.formatPosture?.requestedFormat ?? block.resolvedNumbering.format,
|
|
2265
|
+
renderedFormat: block.resolvedNumbering.formatPosture?.renderedFormat ?? block.resolvedNumbering.format,
|
|
2266
|
+
...block.resolvedNumbering.formatPosture ? { formatPosture: block.resolvedNumbering.formatPosture } : {},
|
|
2267
|
+
...block.resolvedNumbering.markerTextPosture ? { markerTextPosture: block.resolvedNumbering.markerTextPosture } : {},
|
|
2268
|
+
...block.resolvedNumbering.pictureBulletPosture ? { pictureBulletPosture: block.resolvedNumbering.pictureBulletPosture } : {},
|
|
2269
|
+
authoredTextRange: { from: block.from, to: block.to },
|
|
2270
|
+
editability: target.editability,
|
|
2271
|
+
blockers,
|
|
2272
|
+
supportedCommands: SUPPORTED_COMMANDS,
|
|
2273
|
+
unsupportedCommands: UNSUPPORTED_COMMANDS,
|
|
2274
|
+
commandSupport,
|
|
2275
|
+
canJoin,
|
|
2276
|
+
canContinuePrevious,
|
|
2277
|
+
staleDiscriminators: {
|
|
2278
|
+
paragraphTextHash: target.staleCheck.paragraphTextHash,
|
|
2279
|
+
paragraphTextLength: target.staleCheck.paragraphTextLength,
|
|
2280
|
+
inlineCount: target.staleCheck.inlineCount,
|
|
2281
|
+
listAddressStaleHash: listAddress.resolver?.staleHash
|
|
2282
|
+
},
|
|
2283
|
+
geometry: block.resolvedNumbering.geometry,
|
|
2284
|
+
...!block.resolvedNumbering.geometry.markerLane ? { geometryUnavailableReason: "marker-geometry-unavailable" } : {}
|
|
2285
|
+
};
|
|
2286
|
+
}
|
|
2287
|
+
function commandAvailability(input) {
|
|
2288
|
+
const out = [];
|
|
2289
|
+
for (const command of SUPPORTED_COMMANDS) {
|
|
2290
|
+
const blockedReason = input.blockers[0];
|
|
2291
|
+
const continueBlocked = command === "continue-numbering" && !input.canContinuePrevious;
|
|
2292
|
+
out.push({
|
|
2293
|
+
command,
|
|
2294
|
+
enabled: !blockedReason && !continueBlocked,
|
|
2295
|
+
...!blockedReason && !continueBlocked ? { actionHandle: input.actionHandle } : {},
|
|
2296
|
+
...blockedReason ? { reason: blockedReason, ownerLayer: "L07" } : {},
|
|
2297
|
+
...continueBlocked ? { reason: "list-continue-target-missing", ownerLayer: "L07" } : {}
|
|
2298
|
+
});
|
|
2299
|
+
}
|
|
2300
|
+
for (const command of UNSUPPORTED_COMMANDS) {
|
|
2301
|
+
out.push({
|
|
2302
|
+
command,
|
|
2303
|
+
enabled: false,
|
|
2304
|
+
reason: "list-command-unsupported",
|
|
2305
|
+
ownerLayer: "L07"
|
|
2306
|
+
});
|
|
2307
|
+
}
|
|
2308
|
+
return out;
|
|
2309
|
+
}
|
|
2310
|
+
function findReadback(rows, target) {
|
|
2311
|
+
const addressKey = target.addressKey ?? addressKeyFromActionHandle(target.actionHandle);
|
|
2312
|
+
return rows.find(
|
|
2313
|
+
(row) => target.targetKey !== void 0 && row.targetKey === target.targetKey || addressKey !== void 0 && row.addressKey === addressKey || target.actionHandle !== void 0 && row.actionHandle === target.actionHandle
|
|
2314
|
+
) ?? null;
|
|
2315
|
+
}
|
|
2316
|
+
function addressKeyFromActionHandle(actionHandle) {
|
|
2317
|
+
const prefix = "list-action:";
|
|
2318
|
+
return actionHandle?.startsWith(prefix) ? actionHandle.slice(prefix.length) : void 0;
|
|
2319
|
+
}
|
|
2320
|
+
function inferListKind(resolved) {
|
|
2321
|
+
if (!resolved) return "numbered";
|
|
2322
|
+
return resolved.format === "bullet" || resolved.picBulletId !== void 0 || resolved.pictureBulletPosture !== void 0 ? "bulleted" : "numbered";
|
|
2323
|
+
}
|
|
2324
|
+
|
|
2113
2325
|
// src/api/v3/ui/_create.ts
|
|
2114
2326
|
function createUiApi(handle, factory) {
|
|
2115
2327
|
const ctx = createUiApiContext(handle);
|
|
@@ -2124,7 +2336,8 @@ function createUiApi(handle, factory) {
|
|
|
2124
2336
|
overlays: createOverlaysFamily(ctx),
|
|
2125
2337
|
chrome: createChromeFamily(ctx),
|
|
2126
2338
|
debug: createDebugFamily(ctx),
|
|
2127
|
-
scope: createScopeFamily(ctx)
|
|
2339
|
+
scope: createScopeFamily(ctx),
|
|
2340
|
+
lists: createListsFamily(ctx)
|
|
2128
2341
|
};
|
|
2129
2342
|
Object.freeze(api.session);
|
|
2130
2343
|
Object.freeze(api.surface);
|
|
@@ -2133,6 +2346,7 @@ function createUiApi(handle, factory) {
|
|
|
2133
2346
|
Object.freeze(api.chrome);
|
|
2134
2347
|
Object.freeze(api.debug);
|
|
2135
2348
|
Object.freeze(api.scope);
|
|
2349
|
+
Object.freeze(api.lists);
|
|
2136
2350
|
return Object.freeze(api);
|
|
2137
2351
|
}
|
|
2138
2352
|
|