@beyondwork/docx-react-component 1.0.132 → 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 +158 -67
- package/dist/api/public-types.d.cts +1 -1
- package/dist/api/public-types.d.ts +1 -1
- package/dist/api/public-types.js +3 -3
- package/dist/api/v3.cjs +9326 -7478
- package/dist/api/v3.d.cts +2 -2
- package/dist/api/v3.d.ts +2 -2
- package/dist/api/v3.js +10 -10
- package/dist/{chunk-XYTWOJII.js → chunk-224TSMEB.js} +635 -89
- package/dist/{chunk-43JAPM2F.js → chunk-3JEE5RJU.js} +92 -131
- package/dist/{chunk-UP2KDOYE.js → chunk-57HTKX3P.js} +6 -2
- package/dist/{chunk-RYMMKOFI.js → chunk-5KTJKTNE.js} +32 -0
- package/dist/{chunk-LPLJZJT2.js → chunk-CVSD3UNK.js} +128 -69
- package/dist/{chunk-JVTDBX67.js → chunk-EFEW7BTT.js} +2 -2
- package/dist/{chunk-UFPBYJMA.js → chunk-INLRCC4N.js} +2 -2
- package/dist/{chunk-6736GA6J.js → chunk-KL4TZSZV.js} +1 -1
- package/dist/{chunk-N5FTU4HZ.js → chunk-MQ5GAJ54.js} +68 -39
- package/dist/{chunk-W2I47J2Q.js → chunk-NJFKPDNG.js} +216 -2
- package/dist/{chunk-YUHNDEV5.js → chunk-OTRVGNZQ.js} +2934 -1815
- package/dist/{chunk-4HGFJ6Z2.js → chunk-PZIEOEJZ.js} +1 -1
- package/dist/{chunk-C5LXKR54.js → chunk-QTRJLKR2.js} +1 -1
- package/dist/{chunk-SZ6BJA4Q.js → chunk-REFHJ2FN.js} +3 -3
- package/dist/{chunk-ZDYGRO2Z.js → chunk-RP76USJE.js} +1 -1
- package/dist/{chunk-QUTVR72L.js → chunk-S3PEKX6H.js} +246 -43
- package/dist/{chunk-RBWJHRNP.js → chunk-T66OS7MN.js} +8 -3
- package/dist/{chunk-ALWXYGXP.js → chunk-V2JF42SI.js} +2 -2
- package/dist/{chunk-6TLZ6CMP.js → chunk-WDDFU2N2.js} +2 -2
- package/dist/{chunk-U3UMKA7B.js → chunk-XBQFDBXE.js} +1 -1
- package/dist/{chunk-CDEZGLQ3.js → chunk-ZFCZ7XXH.js} +1 -1
- package/dist/core/commands/formatting-commands.d.cts +1 -1
- package/dist/core/commands/formatting-commands.d.ts +1 -1
- package/dist/core/commands/image-commands.cjs +32 -0
- package/dist/core/commands/image-commands.d.cts +1 -1
- package/dist/core/commands/image-commands.d.ts +1 -1
- package/dist/core/commands/image-commands.js +5 -5
- package/dist/core/commands/section-layout-commands.d.cts +1 -1
- package/dist/core/commands/section-layout-commands.d.ts +1 -1
- package/dist/core/commands/style-commands.d.cts +1 -1
- package/dist/core/commands/style-commands.d.ts +1 -1
- package/dist/core/commands/table-structure-commands.cjs +32 -0
- package/dist/core/commands/table-structure-commands.d.cts +1 -1
- package/dist/core/commands/table-structure-commands.d.ts +1 -1
- package/dist/core/commands/table-structure-commands.js +4 -4
- package/dist/core/commands/text-commands.cjs +99 -38
- package/dist/core/commands/text-commands.d.cts +12 -1
- package/dist/core/commands/text-commands.d.ts +12 -1
- package/dist/core/commands/text-commands.js +5 -5
- package/dist/core/selection/mapping.d.cts +1 -1
- package/dist/core/selection/mapping.d.ts +1 -1
- package/dist/core/state/editor-state.d.cts +1 -1
- package/dist/core/state/editor-state.d.ts +1 -1
- package/dist/index.cjs +4827 -2434
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +292 -53
- package/dist/io/docx-session.cjs +7 -2
- package/dist/io/docx-session.d.cts +3 -3
- package/dist/io/docx-session.d.ts +3 -3
- package/dist/io/docx-session.js +4 -4
- package/dist/legal.js +3 -3
- package/dist/{loader-MAa8VpzW.d.cts → loader-B2H99237.d.cts} +2 -2
- package/dist/{loader-CfpeEPAa.d.ts → loader-DfTjqVwn.d.ts} +2 -2
- package/dist/{public-types-Cjs8glST.d.ts → public-types-B5lOUIrP.d.ts} +689 -232
- package/dist/{public-types-KBS6JnOs.d.cts → public-types-S8gTYwKo.d.cts} +689 -232
- package/dist/public-types.cjs +158 -67
- package/dist/public-types.d.cts +1 -1
- package/dist/public-types.d.ts +1 -1
- package/dist/public-types.js +3 -3
- package/dist/runtime/collab.d.cts +2 -2
- package/dist/runtime/collab.d.ts +2 -2
- package/dist/runtime/document-runtime.cjs +1032 -416
- package/dist/runtime/document-runtime.d.cts +1 -1
- package/dist/runtime/document-runtime.d.ts +1 -1
- package/dist/runtime/document-runtime.js +14 -14
- package/dist/{session-CkoH8FoY.d.ts → session-CBDIOYXA.d.ts} +2 -2
- package/dist/{session-wwe0Gib-.d.cts → session-CR2A1hGZ.d.cts} +2 -2
- package/dist/session.cjs +7 -2
- package/dist/session.d.cts +4 -4
- package/dist/session.d.ts +4 -4
- package/dist/session.js +5 -5
- package/dist/tailwind.cjs +398 -105
- package/dist/tailwind.d.cts +1 -1
- package/dist/tailwind.d.ts +1 -1
- package/dist/tailwind.js +7 -7
- package/dist/{types-CH7NWqVL.d.ts → types-B-90ywjU.d.ts} +1 -1
- package/dist/{types-B3SGRW0w.d.cts → types-yty2K-hk.d.cts} +1 -1
- package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +2 -2
- package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +2 -2
- package/dist/ui-tailwind/editor-surface/search-plugin.js +4 -4
- package/dist/ui-tailwind.cjs +398 -105
- package/dist/ui-tailwind.d.cts +3 -2
- package/dist/ui-tailwind.d.ts +3 -2
- package/dist/ui-tailwind.js +7 -7
- package/package.json +1 -1
|
@@ -7,32 +7,33 @@ import {
|
|
|
7
7
|
resolveSectionForStoryTarget,
|
|
8
8
|
searchSecondaryStories,
|
|
9
9
|
searchSurfaceBlocks
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-CVSD3UNK.js";
|
|
11
11
|
import {
|
|
12
12
|
createEditorSurfaceSnapshot,
|
|
13
13
|
createFormattingContext,
|
|
14
14
|
resolveTableStyleResolution
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-XBQFDBXE.js";
|
|
16
16
|
import {
|
|
17
17
|
createSelectionSnapshot
|
|
18
18
|
} from "./chunk-OYGMRRR7.js";
|
|
19
19
|
import {
|
|
20
20
|
normalizeParsedTextDocument
|
|
21
|
-
} from "./chunk-
|
|
21
|
+
} from "./chunk-PZIEOEJZ.js";
|
|
22
22
|
import {
|
|
23
23
|
buildFieldRegistry,
|
|
24
24
|
parseMainDocumentXml,
|
|
25
25
|
parseTocLevelRange
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-T66OS7MN.js";
|
|
27
27
|
import {
|
|
28
28
|
collectEditableTargetRefs,
|
|
29
29
|
collectLayoutInputIdentities,
|
|
30
30
|
validateEditableTargetRef
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-5KTJKTNE.js";
|
|
32
32
|
import {
|
|
33
33
|
serializeMainDocument
|
|
34
34
|
} from "./chunk-FM4K4XFJ.js";
|
|
35
35
|
import {
|
|
36
|
+
describeStructuredWrapperBlock,
|
|
36
37
|
findOpaqueFragmentsIntersectingRange
|
|
37
38
|
} from "./chunk-UFVDIR2C.js";
|
|
38
39
|
import {
|
|
@@ -43,15 +44,15 @@ import {
|
|
|
43
44
|
storyTargetsEqual
|
|
44
45
|
} from "./chunk-M2HUK3KF.js";
|
|
45
46
|
|
|
46
|
-
// src/
|
|
47
|
-
function
|
|
47
|
+
// src/core/commands/scope-coordinate-walk.ts
|
|
48
|
+
function inlineLengthForScopeCoordinates(node) {
|
|
48
49
|
switch (node.type) {
|
|
49
50
|
case "text":
|
|
50
51
|
return Array.from(node.text).length;
|
|
51
52
|
case "hyperlink":
|
|
52
53
|
case "field":
|
|
53
54
|
return node.children.reduce(
|
|
54
|
-
(total, child) => total +
|
|
55
|
+
(total, child) => total + inlineLengthForScopeCoordinates(child),
|
|
55
56
|
0
|
|
56
57
|
);
|
|
57
58
|
case "bookmark_start":
|
|
@@ -63,29 +64,241 @@ function inlineLength(node) {
|
|
|
63
64
|
return 1;
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
|
-
function
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
67
|
+
function paragraphLengthForScopeCoordinates(paragraph) {
|
|
68
|
+
return paragraph.children.reduce(
|
|
69
|
+
(total, child) => total + inlineLengthForScopeCoordinates(child),
|
|
70
|
+
0
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
function computeScopeStoryLayout(document) {
|
|
74
|
+
const root = document.content;
|
|
75
|
+
const paragraphSlots = [];
|
|
76
|
+
const blockSlots = [];
|
|
77
|
+
if (!root || root.type !== "doc") {
|
|
78
|
+
return { paragraphSlots, blockSlots, storyLength: 0 };
|
|
79
|
+
}
|
|
70
80
|
let cursor = 0;
|
|
71
81
|
for (let index = 0; index < root.children.length; index += 1) {
|
|
72
82
|
const block = root.children[index];
|
|
73
|
-
if (block
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
83
|
+
if (!block) continue;
|
|
84
|
+
cursor = walkBlockForScopeCoordinates(
|
|
85
|
+
block,
|
|
86
|
+
cursor,
|
|
87
|
+
[{ kind: "block", index }],
|
|
88
|
+
index,
|
|
89
|
+
paragraphSlots,
|
|
90
|
+
blockSlots
|
|
91
|
+
);
|
|
92
|
+
if (index < root.children.length - 1 && root.children[index + 1]?.type === "paragraph") {
|
|
82
93
|
cursor += 1;
|
|
83
94
|
}
|
|
84
|
-
|
|
85
|
-
|
|
95
|
+
}
|
|
96
|
+
return { paragraphSlots, blockSlots, storyLength: cursor };
|
|
97
|
+
}
|
|
98
|
+
function findParagraphSlotAtPosition(layout, position, edge) {
|
|
99
|
+
const matches = layout.paragraphSlots.filter(
|
|
100
|
+
(slot) => position >= slot.from && position <= slot.to
|
|
101
|
+
);
|
|
102
|
+
if (matches.length === 0) return null;
|
|
103
|
+
if (edge === "start") {
|
|
104
|
+
return matches.find((slot) => slot.from === position) ?? matches.find((slot) => position > slot.from && position <= slot.to) ?? matches[0];
|
|
105
|
+
}
|
|
106
|
+
return matches.find((slot) => slot.to === position) ?? matches.find((slot) => position >= slot.from && position < slot.to) ?? matches[matches.length - 1];
|
|
107
|
+
}
|
|
108
|
+
function findOwningBlockSlotAtPosition(layout, position) {
|
|
109
|
+
const matches = layout.blockSlots.filter(
|
|
110
|
+
(slot) => position >= slot.from && position <= slot.to
|
|
111
|
+
);
|
|
112
|
+
if (matches.length === 0) return null;
|
|
113
|
+
return matches.reduce(
|
|
114
|
+
(best, slot) => slot.path.length >= best.path.length ? slot : best
|
|
115
|
+
);
|
|
116
|
+
}
|
|
117
|
+
function sameScopeParagraphPath(a, b) {
|
|
118
|
+
return scopeParagraphPathKey(a) === scopeParagraphPathKey(b);
|
|
119
|
+
}
|
|
120
|
+
function replaceParagraphChildrenAtPath(root, path, children) {
|
|
121
|
+
return {
|
|
122
|
+
...root,
|
|
123
|
+
children: replaceInBlockList(root.children, path, children)
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function removeScopeMarkersFromBlockList(blocks, scopeId) {
|
|
127
|
+
let mutated = false;
|
|
128
|
+
const nextBlocks = blocks.map((block) => {
|
|
129
|
+
const result = removeScopeMarkersFromBlock(block, scopeId);
|
|
130
|
+
if (result.mutated) mutated = true;
|
|
131
|
+
return result.block;
|
|
132
|
+
});
|
|
133
|
+
return { blocks: nextBlocks, mutated };
|
|
134
|
+
}
|
|
135
|
+
function walkBlockForScopeCoordinates(block, cursor, path, rootBlockIndex, paragraphSlots, blockSlots) {
|
|
136
|
+
const from = cursor;
|
|
137
|
+
if (block.type === "paragraph") {
|
|
138
|
+
const to2 = cursor + paragraphLengthForScopeCoordinates(block);
|
|
139
|
+
const slot = { path, rootBlockIndex, kind: block.type, from, to: to2 };
|
|
140
|
+
blockSlots.push(slot);
|
|
141
|
+
paragraphSlots.push({ ...slot, paragraph: block });
|
|
142
|
+
return to2;
|
|
143
|
+
}
|
|
144
|
+
if (block.type === "table") {
|
|
145
|
+
let innerCursor = cursor;
|
|
146
|
+
for (let rowIndex = 0; rowIndex < block.rows.length; rowIndex += 1) {
|
|
147
|
+
const row = block.rows[rowIndex];
|
|
148
|
+
for (let cellIndex = 0; cellIndex < row.cells.length; cellIndex += 1) {
|
|
149
|
+
const cell = row.cells[cellIndex];
|
|
150
|
+
for (let childIndex = 0; childIndex < cell.children.length; childIndex += 1) {
|
|
151
|
+
const child = cell.children[childIndex];
|
|
152
|
+
innerCursor = walkBlockForScopeCoordinates(
|
|
153
|
+
child,
|
|
154
|
+
innerCursor,
|
|
155
|
+
[
|
|
156
|
+
...path,
|
|
157
|
+
{ kind: "tableCell", rowIndex, cellIndex },
|
|
158
|
+
{ kind: "block", index: childIndex }
|
|
159
|
+
],
|
|
160
|
+
rootBlockIndex,
|
|
161
|
+
paragraphSlots,
|
|
162
|
+
blockSlots
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
86
166
|
}
|
|
167
|
+
blockSlots.push({
|
|
168
|
+
path,
|
|
169
|
+
rootBlockIndex,
|
|
170
|
+
kind: block.type,
|
|
171
|
+
from,
|
|
172
|
+
to: innerCursor
|
|
173
|
+
});
|
|
174
|
+
return innerCursor;
|
|
87
175
|
}
|
|
88
|
-
|
|
176
|
+
if (block.type === "sdt") {
|
|
177
|
+
const descriptor = describeStructuredWrapperBlock(block, {
|
|
178
|
+
projectVisibleTocContentControls: true
|
|
179
|
+
});
|
|
180
|
+
if (descriptor) {
|
|
181
|
+
const to2 = cursor + 1;
|
|
182
|
+
blockSlots.push({ path, rootBlockIndex, kind: block.type, from, to: to2 });
|
|
183
|
+
return to2;
|
|
184
|
+
}
|
|
185
|
+
let innerCursor = cursor;
|
|
186
|
+
for (let childIndex = 0; childIndex < block.children.length; childIndex += 1) {
|
|
187
|
+
const child = block.children[childIndex];
|
|
188
|
+
innerCursor = walkBlockForScopeCoordinates(
|
|
189
|
+
child,
|
|
190
|
+
innerCursor,
|
|
191
|
+
[...path, { kind: "sdtChildren" }, { kind: "block", index: childIndex }],
|
|
192
|
+
rootBlockIndex,
|
|
193
|
+
paragraphSlots,
|
|
194
|
+
blockSlots
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
blockSlots.push({
|
|
198
|
+
path,
|
|
199
|
+
rootBlockIndex,
|
|
200
|
+
kind: block.type,
|
|
201
|
+
from,
|
|
202
|
+
to: innerCursor
|
|
203
|
+
});
|
|
204
|
+
return innerCursor;
|
|
205
|
+
}
|
|
206
|
+
const to = cursor + 1;
|
|
207
|
+
blockSlots.push({ path, rootBlockIndex, kind: block.type, from, to });
|
|
208
|
+
return to;
|
|
209
|
+
}
|
|
210
|
+
function replaceInBlockList(blocks, path, children) {
|
|
211
|
+
const [head, ...rest] = path;
|
|
212
|
+
if (!head || head.kind !== "block") return [...blocks];
|
|
213
|
+
return blocks.map((block, index) => {
|
|
214
|
+
if (index !== head.index) return block;
|
|
215
|
+
if (rest.length === 0) {
|
|
216
|
+
return block.type === "paragraph" ? { ...block, children } : block;
|
|
217
|
+
}
|
|
218
|
+
return replaceInsideBlock(block, rest, children);
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
function replaceInsideBlock(block, path, children) {
|
|
222
|
+
const [head, ...rest] = path;
|
|
223
|
+
if (!head) return block;
|
|
224
|
+
if (block.type === "table" && head.kind === "tableCell") {
|
|
225
|
+
const rows = block.rows.map((row, rowIndex) => {
|
|
226
|
+
if (rowIndex !== head.rowIndex) return row;
|
|
227
|
+
const cells = row.cells.map((cell, cellIndex) => {
|
|
228
|
+
if (cellIndex !== head.cellIndex) return cell;
|
|
229
|
+
return {
|
|
230
|
+
...cell,
|
|
231
|
+
children: replaceInBlockList(cell.children, rest, children)
|
|
232
|
+
};
|
|
233
|
+
});
|
|
234
|
+
return { ...row, cells };
|
|
235
|
+
});
|
|
236
|
+
return { ...block, rows };
|
|
237
|
+
}
|
|
238
|
+
if (block.type === "sdt" && head.kind === "sdtChildren") {
|
|
239
|
+
return {
|
|
240
|
+
...block,
|
|
241
|
+
children: replaceInBlockList(block.children, rest, children)
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
return block;
|
|
245
|
+
}
|
|
246
|
+
function removeScopeMarkersFromBlock(block, scopeId) {
|
|
247
|
+
if (block.type === "paragraph") {
|
|
248
|
+
const kept = block.children.filter((child) => {
|
|
249
|
+
return !((child.type === "scope_marker_start" || child.type === "scope_marker_end") && child.scopeId === scopeId);
|
|
250
|
+
});
|
|
251
|
+
if (kept.length === block.children.length) {
|
|
252
|
+
return { block, mutated: false };
|
|
253
|
+
}
|
|
254
|
+
return { block: { ...block, children: kept }, mutated: true };
|
|
255
|
+
}
|
|
256
|
+
if (block.type === "table") {
|
|
257
|
+
let mutated = false;
|
|
258
|
+
const rows = block.rows.map((row) => {
|
|
259
|
+
let rowMutated = false;
|
|
260
|
+
const cells = row.cells.map((cell) => {
|
|
261
|
+
const result = removeScopeMarkersFromBlockList(cell.children, scopeId);
|
|
262
|
+
if (result.mutated) {
|
|
263
|
+
mutated = true;
|
|
264
|
+
rowMutated = true;
|
|
265
|
+
}
|
|
266
|
+
return result.mutated ? { ...cell, children: result.blocks } : cell;
|
|
267
|
+
});
|
|
268
|
+
return rowMutated ? { ...row, cells } : row;
|
|
269
|
+
});
|
|
270
|
+
return mutated ? { block: { ...block, rows }, mutated: true } : { block, mutated: false };
|
|
271
|
+
}
|
|
272
|
+
if (block.type === "sdt") {
|
|
273
|
+
const result = removeScopeMarkersFromBlockList(block.children, scopeId);
|
|
274
|
+
return result.mutated ? { block: { ...block, children: result.blocks }, mutated: true } : { block, mutated: false };
|
|
275
|
+
}
|
|
276
|
+
if (block.type === "custom_xml") {
|
|
277
|
+
const result = removeScopeMarkersFromBlockList(block.children, scopeId);
|
|
278
|
+
return result.mutated ? { block: { ...block, children: result.blocks }, mutated: true } : { block, mutated: false };
|
|
279
|
+
}
|
|
280
|
+
return { block, mutated: false };
|
|
281
|
+
}
|
|
282
|
+
function scopeParagraphPathKey(path) {
|
|
283
|
+
return path.map((step) => {
|
|
284
|
+
if (step.kind === "block") return `b:${step.index}`;
|
|
285
|
+
if (step.kind === "tableCell") {
|
|
286
|
+
return `tc:${step.rowIndex}:${step.cellIndex}`;
|
|
287
|
+
}
|
|
288
|
+
return "sdt";
|
|
289
|
+
}).join("/");
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// src/runtime/workflow/scope-resolver.ts
|
|
293
|
+
function walkParagraphs(document) {
|
|
294
|
+
const envelope = document;
|
|
295
|
+
return computeScopeStoryLayout(envelope).paragraphSlots.map((slot) => ({
|
|
296
|
+
paragraph: slot.paragraph,
|
|
297
|
+
from: slot.from
|
|
298
|
+
}));
|
|
299
|
+
}
|
|
300
|
+
function inlineLength(node) {
|
|
301
|
+
return inlineLengthForScopeCoordinates(node);
|
|
89
302
|
}
|
|
90
303
|
function collectScopeLocations(document) {
|
|
91
304
|
const locations = /* @__PURE__ */ new Map();
|
|
@@ -611,9 +824,9 @@ function messageForPostureBlocker(blocker) {
|
|
|
611
824
|
return void 0;
|
|
612
825
|
}
|
|
613
826
|
}
|
|
614
|
-
function auditFact(target, category, reason,
|
|
827
|
+
function auditFact(target, category, reason, operation2) {
|
|
615
828
|
return {
|
|
616
|
-
operation:
|
|
829
|
+
operation: operation2 ?? auditOperationForTarget(target),
|
|
617
830
|
category,
|
|
618
831
|
dispatch: "blocked-before-mutation",
|
|
619
832
|
reason
|
|
@@ -704,25 +917,43 @@ function computeBlockPositions(document) {
|
|
|
704
917
|
let cursor = 0;
|
|
705
918
|
for (let index = 0; index < root.children.length; index += 1) {
|
|
706
919
|
const block = root.children[index];
|
|
920
|
+
if (!block) continue;
|
|
707
921
|
const from = cursor;
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
(total, child) => total + inlineLength2(child),
|
|
712
|
-
0
|
|
713
|
-
);
|
|
714
|
-
} else {
|
|
715
|
-
length = 1;
|
|
716
|
-
}
|
|
717
|
-
cursor += length;
|
|
718
|
-
const to = cursor;
|
|
719
|
-
out.push({ blockIndex: index, from, to });
|
|
720
|
-
if (index < root.children.length - 1) {
|
|
922
|
+
cursor += blockLength(block);
|
|
923
|
+
out.push({ blockIndex: index, from, to: cursor });
|
|
924
|
+
if (index < root.children.length - 1 && root.children[index + 1]?.type === "paragraph") {
|
|
721
925
|
cursor += 1;
|
|
722
926
|
}
|
|
723
927
|
}
|
|
724
928
|
return out;
|
|
725
929
|
}
|
|
930
|
+
function blockLength(block) {
|
|
931
|
+
if (block.type === "paragraph") {
|
|
932
|
+
return block.children.reduce(
|
|
933
|
+
(total, child) => total + inlineLength2(child),
|
|
934
|
+
0
|
|
935
|
+
);
|
|
936
|
+
}
|
|
937
|
+
if (block.type === "table") {
|
|
938
|
+
let total = 0;
|
|
939
|
+
for (const row of block.rows) {
|
|
940
|
+
for (const cell of row.cells) {
|
|
941
|
+
for (const child of cell.children) {
|
|
942
|
+
total += blockLength(child);
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
return total;
|
|
947
|
+
}
|
|
948
|
+
if (block.type === "sdt") {
|
|
949
|
+
const descriptor = describeStructuredWrapperBlock(block, {
|
|
950
|
+
projectVisibleTocContentControls: true
|
|
951
|
+
});
|
|
952
|
+
if (descriptor) return 1;
|
|
953
|
+
return block.children.reduce((total, child) => total + blockLength(child), 0);
|
|
954
|
+
}
|
|
955
|
+
return 1;
|
|
956
|
+
}
|
|
726
957
|
function computeInlinePositions(document, blocks) {
|
|
727
958
|
const envelope = document;
|
|
728
959
|
const root = "content" in envelope ? envelope.content : document;
|
|
@@ -970,8 +1201,8 @@ function deriveReplaceability(kind, provenance) {
|
|
|
970
1201
|
if (kind === "scope") {
|
|
971
1202
|
if (provenance === "marker-backed") {
|
|
972
1203
|
return {
|
|
973
|
-
level: "
|
|
974
|
-
reason: "multi-paragraph-
|
|
1204
|
+
level: "text-only",
|
|
1205
|
+
reason: "marker-backed-multi-paragraph-preserves-anchor"
|
|
975
1206
|
};
|
|
976
1207
|
}
|
|
977
1208
|
return {
|
|
@@ -2133,6 +2364,54 @@ function compileScopeKind(entry, options) {
|
|
|
2133
2364
|
partial: true
|
|
2134
2365
|
};
|
|
2135
2366
|
}
|
|
2367
|
+
function compileScopeReplacement(entry, proposed, options) {
|
|
2368
|
+
if (entry.handle.provenance !== "marker-backed" || proposed.operation !== "replace" || options.posture !== "direct-edit") {
|
|
2369
|
+
return null;
|
|
2370
|
+
}
|
|
2371
|
+
const markerRange = buildScopePositionMap(options.document).markerScopes.get(
|
|
2372
|
+
entry.handle.scopeId
|
|
2373
|
+
);
|
|
2374
|
+
if (!markerRange) return null;
|
|
2375
|
+
if (proposed.proposedContent.kind === "text") {
|
|
2376
|
+
const text = proposed.proposedContent.text ?? "";
|
|
2377
|
+
return {
|
|
2378
|
+
scopeId: entry.handle.scopeId,
|
|
2379
|
+
targetKind: "scope",
|
|
2380
|
+
operation: proposed.operation,
|
|
2381
|
+
steps: Object.freeze([
|
|
2382
|
+
{
|
|
2383
|
+
kind: "text-replace",
|
|
2384
|
+
summary: `replace multi-paragraph scope ${entry.handle.scopeId} text [${markerRange.from}..${markerRange.to}] (len ${text.length})`,
|
|
2385
|
+
range: { from: markerRange.from, to: markerRange.to },
|
|
2386
|
+
text,
|
|
2387
|
+
...proposed.formatting ? { formatting: proposed.formatting } : {}
|
|
2388
|
+
}
|
|
2389
|
+
]),
|
|
2390
|
+
...proposed.preserve ? { preserve: proposed.preserve } : {},
|
|
2391
|
+
posture: options.posture
|
|
2392
|
+
};
|
|
2393
|
+
}
|
|
2394
|
+
if (proposed.proposedContent.kind === "structured") {
|
|
2395
|
+
const fragment = proposed.proposedContent.structured;
|
|
2396
|
+
if (!isStructuredReplacementContent(fragment)) return null;
|
|
2397
|
+
return {
|
|
2398
|
+
scopeId: entry.handle.scopeId,
|
|
2399
|
+
targetKind: "scope",
|
|
2400
|
+
operation: proposed.operation,
|
|
2401
|
+
steps: Object.freeze([
|
|
2402
|
+
{
|
|
2403
|
+
kind: "fragment-replace",
|
|
2404
|
+
summary: `replace multi-paragraph scope ${entry.handle.scopeId} with structured fragment [${markerRange.from}..${markerRange.to}] (${fragment.blocks.length} block(s))`,
|
|
2405
|
+
range: { from: markerRange.from, to: markerRange.to },
|
|
2406
|
+
fragment
|
|
2407
|
+
}
|
|
2408
|
+
]),
|
|
2409
|
+
...proposed.preserve ? { preserve: proposed.preserve } : {},
|
|
2410
|
+
posture: options.posture
|
|
2411
|
+
};
|
|
2412
|
+
}
|
|
2413
|
+
return null;
|
|
2414
|
+
}
|
|
2136
2415
|
|
|
2137
2416
|
// src/runtime/scopes/scope-kinds/table.ts
|
|
2138
2417
|
function compileTableScope(entry, options = {}) {
|
|
@@ -3037,31 +3316,6 @@ function deriveScopeAdjacentGeometryEvidence(scope, entry, provider) {
|
|
|
3037
3316
|
};
|
|
3038
3317
|
}
|
|
3039
3318
|
|
|
3040
|
-
// src/runtime/scopes/multi-paragraph-refusal.ts
|
|
3041
|
-
var MULTI_PARAGRAPH_REPLACEMENT_REFUSAL = "compile-refused:scope:multi-paragraph-replace-not-implemented";
|
|
3042
|
-
function shapeBlocker(shape) {
|
|
3043
|
-
switch (shape) {
|
|
3044
|
-
case "text":
|
|
3045
|
-
return "compile-refused:scope:multi-paragraph-text-replace-not-implemented";
|
|
3046
|
-
case "fragment":
|
|
3047
|
-
return "compile-refused:scope:multi-paragraph-fragment-replace-not-implemented";
|
|
3048
|
-
default:
|
|
3049
|
-
return "compile-refused:scope:multi-paragraph-replace-shape-not-implemented";
|
|
3050
|
-
}
|
|
3051
|
-
}
|
|
3052
|
-
function multiParagraphReplacementBlockers(shape = "unknown") {
|
|
3053
|
-
return Object.freeze([
|
|
3054
|
-
MULTI_PARAGRAPH_REPLACEMENT_REFUSAL,
|
|
3055
|
-
shapeBlocker(shape),
|
|
3056
|
-
"capability:scope:block-granular-replacement-lowering-required",
|
|
3057
|
-
"capability:scope:provenance:marker-backed-required",
|
|
3058
|
-
"capability:scope:layout-completeness-required",
|
|
3059
|
-
"capability:scope:geometry-completeness-required",
|
|
3060
|
-
"capability:scope:continuation-state-required",
|
|
3061
|
-
"capability:scope:preservation-verdict-required"
|
|
3062
|
-
]);
|
|
3063
|
-
}
|
|
3064
|
-
|
|
3065
3319
|
// src/runtime/scopes/capabilities.ts
|
|
3066
3320
|
var PARAGRAPH_LIKE = /* @__PURE__ */ new Set([
|
|
3067
3321
|
"paragraph",
|
|
@@ -3278,10 +3532,9 @@ function replaceTextCapability(scope, context) {
|
|
|
3278
3532
|
if (guard) return blocked(guard);
|
|
3279
3533
|
if (scope.kind === "list-item") {
|
|
3280
3534
|
return blocked(
|
|
3281
|
-
"compile-blocked:list-text:
|
|
3535
|
+
"compile-blocked:list-text:exact-list-text-handle-required",
|
|
3282
3536
|
[
|
|
3283
|
-
"capability:list-item:
|
|
3284
|
-
"capability:list-text:export-persistent-target-required"
|
|
3537
|
+
"capability:list-item:exact-list-text-handle-required"
|
|
3285
3538
|
]
|
|
3286
3539
|
);
|
|
3287
3540
|
}
|
|
@@ -3296,6 +3549,19 @@ function replaceTextCapability(scope, context) {
|
|
|
3296
3549
|
generatedOrLinked
|
|
3297
3550
|
);
|
|
3298
3551
|
}
|
|
3552
|
+
if (scope.kind === "scope") {
|
|
3553
|
+
if (scope.workflow.effectiveMode === "suggest") {
|
|
3554
|
+
return unsupported(
|
|
3555
|
+
"compile-refused:scope:multi-paragraph-suggesting-not-implemented",
|
|
3556
|
+
["compile-refused:scope:multi-paragraph-suggesting-not-implemented"],
|
|
3557
|
+
["guard:suggest-mode", ...evidenceWarnings(context)]
|
|
3558
|
+
);
|
|
3559
|
+
}
|
|
3560
|
+
return supported(
|
|
3561
|
+
"compile-supported:scope:multi-paragraph-text-replace",
|
|
3562
|
+
evidenceWarnings(context)
|
|
3563
|
+
);
|
|
3564
|
+
}
|
|
3299
3565
|
if (!PARAGRAPH_LIKE.has(scope.kind)) {
|
|
3300
3566
|
if (scope.kind === "table-cell") {
|
|
3301
3567
|
if (context?.tableCellTextRange?.status === "ok") {
|
|
@@ -3317,12 +3583,8 @@ function replaceTextCapability(scope, context) {
|
|
|
3317
3583
|
]
|
|
3318
3584
|
);
|
|
3319
3585
|
}
|
|
3320
|
-
const reason =
|
|
3321
|
-
return unsupported(
|
|
3322
|
-
reason,
|
|
3323
|
-
scope.kind === "scope" ? multiParagraphReplacementBlockers("text") : [reason],
|
|
3324
|
-
evidenceWarnings(context)
|
|
3325
|
-
);
|
|
3586
|
+
const reason = `compile-refused:${scope.kind}`;
|
|
3587
|
+
return unsupported(reason, [reason], evidenceWarnings(context));
|
|
3326
3588
|
}
|
|
3327
3589
|
if (scope.replaceability.level === "blocked" || scope.replaceability.level === "preserve-only" || scope.replaceability.level === "formatting-only") {
|
|
3328
3590
|
const reason = scope.replaceability.reason ? `replaceability:${scope.replaceability.reason}` : `replaceability:${scope.replaceability.level}`;
|
|
@@ -3350,14 +3612,25 @@ function replaceFragmentCapability(scope, context) {
|
|
|
3350
3612
|
generatedOrLinked
|
|
3351
3613
|
);
|
|
3352
3614
|
}
|
|
3353
|
-
if (
|
|
3354
|
-
|
|
3355
|
-
|
|
3356
|
-
|
|
3357
|
-
|
|
3615
|
+
if (scope.kind === "scope") {
|
|
3616
|
+
if (scope.workflow.effectiveMode === "suggest") {
|
|
3617
|
+
return unsupported(
|
|
3618
|
+
"compile-refused:scope:multi-paragraph-structured-suggesting-not-implemented",
|
|
3619
|
+
[
|
|
3620
|
+
"compile-refused:scope:multi-paragraph-structured-suggesting-not-implemented"
|
|
3621
|
+
],
|
|
3622
|
+
["guard:suggest-mode", ...evidenceWarnings(context)]
|
|
3623
|
+
);
|
|
3624
|
+
}
|
|
3625
|
+
return supported(
|
|
3626
|
+
"compile-supported:scope:multi-paragraph-fragment-replace",
|
|
3358
3627
|
evidenceWarnings(context)
|
|
3359
3628
|
);
|
|
3360
3629
|
}
|
|
3630
|
+
if (!PARAGRAPH_LIKE.has(scope.kind)) {
|
|
3631
|
+
const reason = `compile-refused:${scope.kind}`;
|
|
3632
|
+
return unsupported(reason, [reason], evidenceWarnings(context));
|
|
3633
|
+
}
|
|
3361
3634
|
if (scope.workflow.effectiveMode === "suggest") {
|
|
3362
3635
|
return unsupported(
|
|
3363
3636
|
`compile-refused:${scope.kind}:structured-suggesting-not-implemented`,
|
|
@@ -5948,6 +6221,231 @@ function compileScopeBundleById(scopeId, inputs) {
|
|
|
5948
6221
|
return compileScopeBundle(compiled, { ...inputs, scopes });
|
|
5949
6222
|
}
|
|
5950
6223
|
|
|
6224
|
+
// src/runtime/scopes/editable-graph.ts
|
|
6225
|
+
function uniq(values) {
|
|
6226
|
+
return Object.freeze([...new Set(values.filter(Boolean))]);
|
|
6227
|
+
}
|
|
6228
|
+
function commandFamilyForTarget(target) {
|
|
6229
|
+
const intents = target.runtimeCommand.intents;
|
|
6230
|
+
if (target.table?.operationScope === "text" && target.runtimeCommand.commandFamily === "text-leaf") {
|
|
6231
|
+
return "table-text";
|
|
6232
|
+
}
|
|
6233
|
+
if (intents.some((intent) => intent.startsWith("table-"))) {
|
|
6234
|
+
if (intents.some((intent) => intent.includes("structure"))) {
|
|
6235
|
+
return "table-structure";
|
|
6236
|
+
}
|
|
6237
|
+
return "table-text";
|
|
6238
|
+
}
|
|
6239
|
+
if (intents.some((intent) => intent.startsWith("list-"))) {
|
|
6240
|
+
if (intents.some((intent) => intent.includes("structure"))) {
|
|
6241
|
+
return "list-structure";
|
|
6242
|
+
}
|
|
6243
|
+
return "list-text";
|
|
6244
|
+
}
|
|
6245
|
+
return target.runtimeCommand.commandFamily;
|
|
6246
|
+
}
|
|
6247
|
+
function familyForTarget(target) {
|
|
6248
|
+
if (target.runtimeCommand.intents.some(
|
|
6249
|
+
(intent) => intent === "table-structure-action" || intent === "table-merge-cells" || intent === "table-split-cell" || intent === "list-structure-action"
|
|
6250
|
+
)) {
|
|
6251
|
+
return "structure";
|
|
6252
|
+
}
|
|
6253
|
+
if (target.runtimeCommand.intents.some(
|
|
6254
|
+
(intent) => intent === "field-update" || intent === "toc-refresh" || intent === "hyperlink-update" || intent === "bookmark-update" || intent === "custom-xml-update"
|
|
6255
|
+
)) {
|
|
6256
|
+
return "value";
|
|
6257
|
+
}
|
|
6258
|
+
if (target.runtimeCommand.commandFamily === "object" || target.runtimeCommand.intents.some(
|
|
6259
|
+
(intent) => intent === "object-edit" || intent === "image-layout" || intent === "image-frame" || intent === "chart-edit" || intent === "embedded-content-update"
|
|
6260
|
+
)) {
|
|
6261
|
+
return "object";
|
|
6262
|
+
}
|
|
6263
|
+
if (target.runtimeCommand.commandFamily === "metadata") return "metadata";
|
|
6264
|
+
if (target.runtimeCommand.commandFamily === "preserve-only-refusal" || target.posture.preserveOnly || target.kind === "opaque-content") {
|
|
6265
|
+
return "preservation";
|
|
6266
|
+
}
|
|
6267
|
+
return "text";
|
|
6268
|
+
}
|
|
6269
|
+
function statusForTarget(target, family) {
|
|
6270
|
+
if (family === "preservation") return "preserve";
|
|
6271
|
+
if (target.runtimeCommand.status === "supported" && target.runtimeCommand.actionHandle) {
|
|
6272
|
+
return "ready";
|
|
6273
|
+
}
|
|
6274
|
+
if (target.runtimeCommand.status === "supported") return "diagnostic";
|
|
6275
|
+
return "needs-command";
|
|
6276
|
+
}
|
|
6277
|
+
function blockersForTarget(target) {
|
|
6278
|
+
return uniq([
|
|
6279
|
+
...target.posture.blockers,
|
|
6280
|
+
...target.runtimeTextCommand.blockers ?? [],
|
|
6281
|
+
...target.runtimeCommand.blockers ?? [],
|
|
6282
|
+
...target.workflowBlockers?.map((blocker) => blocker.blocker) ?? []
|
|
6283
|
+
]);
|
|
6284
|
+
}
|
|
6285
|
+
function projectEditableTarget(target) {
|
|
6286
|
+
const family = familyForTarget(target);
|
|
6287
|
+
const commandFamily = commandFamilyForTarget(target);
|
|
6288
|
+
return Object.freeze({
|
|
6289
|
+
targetId: target.targetKey,
|
|
6290
|
+
family,
|
|
6291
|
+
kind: target.kind,
|
|
6292
|
+
relation: target.relation,
|
|
6293
|
+
status: statusForTarget(target, family),
|
|
6294
|
+
commandFamily,
|
|
6295
|
+
...target.runtimeCommand.actionHandle ? { actionHandle: target.runtimeCommand.actionHandle } : {},
|
|
6296
|
+
...target.runtimeCommand.canonicalAddress ? { canonicalAddress: target.runtimeCommand.canonicalAddress } : {},
|
|
6297
|
+
...target.readback ? { readback: target.readback } : {},
|
|
6298
|
+
blockers: blockersForTarget(target),
|
|
6299
|
+
warnings: Object.freeze([]),
|
|
6300
|
+
intents: Object.freeze([...target.runtimeCommand.intents])
|
|
6301
|
+
});
|
|
6302
|
+
}
|
|
6303
|
+
function projectTableAction(action) {
|
|
6304
|
+
const family = action.family === "table-structure" ? "structure" : "text";
|
|
6305
|
+
const blockers = uniq(action.blockers ?? []);
|
|
6306
|
+
return Object.freeze({
|
|
6307
|
+
targetId: action.handle,
|
|
6308
|
+
family,
|
|
6309
|
+
kind: action.targetKind,
|
|
6310
|
+
relation: action.relation,
|
|
6311
|
+
status: action.status === "supported" && action.actionHandle ? "ready" : action.status === "supported" ? "diagnostic" : "needs-command",
|
|
6312
|
+
commandFamily: action.family,
|
|
6313
|
+
...action.actionHandle ? { actionHandle: action.actionHandle } : {},
|
|
6314
|
+
...action.canonicalAddress ? { canonicalAddress: action.canonicalAddress } : {},
|
|
6315
|
+
...action.readback ? { readback: action.readback } : {},
|
|
6316
|
+
blockers,
|
|
6317
|
+
warnings: Object.freeze([...action.warnings ?? []]),
|
|
6318
|
+
intents: Object.freeze([...action.intents])
|
|
6319
|
+
});
|
|
6320
|
+
}
|
|
6321
|
+
function metadataTarget(bundle) {
|
|
6322
|
+
return Object.freeze({
|
|
6323
|
+
targetId: `${bundle.scope.handle.scopeId}:metadata`,
|
|
6324
|
+
family: "metadata",
|
|
6325
|
+
kind: "scope-metadata",
|
|
6326
|
+
status: "ready",
|
|
6327
|
+
commandFamily: "metadata",
|
|
6328
|
+
actionHandle: `scope-metadata:${bundle.scope.handle.scopeId}`,
|
|
6329
|
+
blockers: Object.freeze([]),
|
|
6330
|
+
warnings: Object.freeze([]),
|
|
6331
|
+
intents: Object.freeze(["metadata-update"])
|
|
6332
|
+
});
|
|
6333
|
+
}
|
|
6334
|
+
function scopeReplacementTarget(bundle) {
|
|
6335
|
+
const verdict = bundle.evidence.capabilities?.canReplaceText;
|
|
6336
|
+
if (!verdict?.supported) return null;
|
|
6337
|
+
return Object.freeze({
|
|
6338
|
+
targetId: `${bundle.scope.handle.scopeId}:scope-replace-text`,
|
|
6339
|
+
family: "text",
|
|
6340
|
+
kind: `${bundle.scope.kind}:scope-replacement`,
|
|
6341
|
+
relation: "exact-scope",
|
|
6342
|
+
status: "ready",
|
|
6343
|
+
commandFamily: "scope-replacement",
|
|
6344
|
+
blockers: Object.freeze([]),
|
|
6345
|
+
warnings: Object.freeze([...verdict.warnings ?? []]),
|
|
6346
|
+
intents: Object.freeze(["text-leaf-edit"])
|
|
6347
|
+
});
|
|
6348
|
+
}
|
|
6349
|
+
function group(targets, family) {
|
|
6350
|
+
return Object.freeze(targets.filter((target) => target.family === family));
|
|
6351
|
+
}
|
|
6352
|
+
function operation(kind, targets) {
|
|
6353
|
+
const ready = targets.filter((target) => target.status === "ready");
|
|
6354
|
+
const pending = targets.filter((target) => target.status === "needs-command");
|
|
6355
|
+
return Object.freeze({
|
|
6356
|
+
kind,
|
|
6357
|
+
status: ready.length > 0 ? "ready" : pending.length > 0 ? "needs-command" : "needs-target",
|
|
6358
|
+
targetIds: Object.freeze(ready.map((target) => target.targetId)),
|
|
6359
|
+
commandFamilies: uniq(ready.map((target) => target.commandFamily ?? ""))
|
|
6360
|
+
});
|
|
6361
|
+
}
|
|
6362
|
+
function contentModelFor(textTargets, valueTargets, structureTargets, objectTargets) {
|
|
6363
|
+
const families = [
|
|
6364
|
+
textTargets.length > 0 ? "text" : "",
|
|
6365
|
+
valueTargets.length > 0 ? "value" : "",
|
|
6366
|
+
structureTargets.length > 0 ? "structure" : "",
|
|
6367
|
+
objectTargets.length > 0 ? "object" : ""
|
|
6368
|
+
].filter(Boolean);
|
|
6369
|
+
if (families.length === 0) return "metadata";
|
|
6370
|
+
if (families.length > 1) return "mixed";
|
|
6371
|
+
return families[0];
|
|
6372
|
+
}
|
|
6373
|
+
function summaryFor(model, targets) {
|
|
6374
|
+
const ready = targets.filter((target) => target.status === "ready").length;
|
|
6375
|
+
const needsCommand = targets.filter(
|
|
6376
|
+
(target) => target.status === "needs-command"
|
|
6377
|
+
).length;
|
|
6378
|
+
const preserve = targets.filter((target) => target.status === "preserve").length;
|
|
6379
|
+
return `${model} scope editable graph: ${ready} ready target(s), ${needsCommand} target(s) needing command, ${preserve} preserve target(s)`;
|
|
6380
|
+
}
|
|
6381
|
+
function compileScopeEditableGraph(bundle) {
|
|
6382
|
+
const scopeTextTarget = scopeReplacementTarget(bundle);
|
|
6383
|
+
const projected = [
|
|
6384
|
+
...bundle.evidence.editableTargets?.entries.map(projectEditableTarget) ?? [],
|
|
6385
|
+
...bundle.evidence.table?.actions.map(projectTableAction) ?? [],
|
|
6386
|
+
...scopeTextTarget ? [scopeTextTarget] : [],
|
|
6387
|
+
metadataTarget(bundle)
|
|
6388
|
+
];
|
|
6389
|
+
const byId = /* @__PURE__ */ new Map();
|
|
6390
|
+
for (const target of projected) {
|
|
6391
|
+
const existing = byId.get(target.targetId);
|
|
6392
|
+
if (!existing || existing.status !== "ready") {
|
|
6393
|
+
byId.set(target.targetId, target);
|
|
6394
|
+
}
|
|
6395
|
+
}
|
|
6396
|
+
const targets = Object.freeze([...byId.values()]);
|
|
6397
|
+
const textTargets = group(targets, "text");
|
|
6398
|
+
const valueTargets = group(targets, "value");
|
|
6399
|
+
const structureTargets = group(targets, "structure");
|
|
6400
|
+
const objectTargets = group(targets, "object");
|
|
6401
|
+
const metadataTargets = group(targets, "metadata");
|
|
6402
|
+
const preservationTargets = group(targets, "preservation");
|
|
6403
|
+
const contentModel = contentModelFor(
|
|
6404
|
+
textTargets,
|
|
6405
|
+
valueTargets,
|
|
6406
|
+
structureTargets,
|
|
6407
|
+
objectTargets
|
|
6408
|
+
);
|
|
6409
|
+
const operations = Object.freeze([
|
|
6410
|
+
operation("replace-text", textTargets),
|
|
6411
|
+
operation("replace-value", valueTargets),
|
|
6412
|
+
operation("edit-structure", structureTargets),
|
|
6413
|
+
operation("edit-object", objectTargets),
|
|
6414
|
+
operation("attach-metadata", metadataTargets)
|
|
6415
|
+
]);
|
|
6416
|
+
const readyTargetCount = targets.filter((target) => target.status === "ready").length;
|
|
6417
|
+
const needsCommandTargetCount = targets.filter(
|
|
6418
|
+
(target) => target.status === "needs-command"
|
|
6419
|
+
).length;
|
|
6420
|
+
const preserveTargetCount = targets.filter(
|
|
6421
|
+
(target) => target.status === "preserve"
|
|
6422
|
+
).length;
|
|
6423
|
+
const blockers = uniq(targets.flatMap((target) => target.blockers));
|
|
6424
|
+
const warnings = uniq(targets.flatMap((target) => target.warnings));
|
|
6425
|
+
const readiness = Object.freeze({
|
|
6426
|
+
status: readyTargetCount > metadataTargets.length ? needsCommandTargetCount > 0 || preserveTargetCount > 0 ? "partial" : "ready" : "metadata-only",
|
|
6427
|
+
readyTargetCount,
|
|
6428
|
+
needsCommandTargetCount,
|
|
6429
|
+
preserveTargetCount,
|
|
6430
|
+
blockers,
|
|
6431
|
+
warnings
|
|
6432
|
+
});
|
|
6433
|
+
return Object.freeze({
|
|
6434
|
+
scope: bundle.scope.handle,
|
|
6435
|
+
contentModel,
|
|
6436
|
+
targets,
|
|
6437
|
+
textTargets,
|
|
6438
|
+
valueTargets,
|
|
6439
|
+
structureTargets,
|
|
6440
|
+
objectTargets,
|
|
6441
|
+
metadataTargets,
|
|
6442
|
+
preservationTargets,
|
|
6443
|
+
operations,
|
|
6444
|
+
readiness,
|
|
6445
|
+
summary: summaryFor(contentModel, targets)
|
|
6446
|
+
});
|
|
6447
|
+
}
|
|
6448
|
+
|
|
5951
6449
|
// src/runtime/scopes/issue-lifecycle.ts
|
|
5952
6450
|
function documentHash(doc) {
|
|
5953
6451
|
let textLength = 0;
|
|
@@ -6499,11 +6997,11 @@ function computePreservationVerdict(document, range, positionMap) {
|
|
|
6499
6997
|
}
|
|
6500
6998
|
|
|
6501
6999
|
// src/runtime/scopes/action-validation.ts
|
|
6502
|
-
function inferActionId(
|
|
6503
|
-
if (
|
|
7000
|
+
function inferActionId(operation2, content) {
|
|
7001
|
+
if (operation2 === "formatting") {
|
|
6504
7002
|
return "fix_formatting";
|
|
6505
7003
|
}
|
|
6506
|
-
switch (
|
|
7004
|
+
switch (operation2) {
|
|
6507
7005
|
case "replace":
|
|
6508
7006
|
return content.kind === "text" ? "rewrite_paragraph" : "generate_text";
|
|
6509
7007
|
case "insert-before":
|
|
@@ -6654,11 +7152,11 @@ function collectCapabilityVerdict(inputs, blockedReasons, warnings) {
|
|
|
6654
7152
|
}
|
|
6655
7153
|
}
|
|
6656
7154
|
if (inputs.scope.kind === "list-item" && inputs.operation === "replace" && inputs.proposedContent.kind === "text") {
|
|
6657
|
-
const code = "capability:list-item:
|
|
7155
|
+
const code = "capability:list-item:exact-list-text-handle-required";
|
|
6658
7156
|
blockedReasons.push(code);
|
|
6659
7157
|
warnings.push({
|
|
6660
7158
|
code,
|
|
6661
|
-
message: "list-item flat text replacement is blocked
|
|
7159
|
+
message: "list-item flat text replacement is blocked unless the caller uses an exact list-text action handle",
|
|
6662
7160
|
source: "capability"
|
|
6663
7161
|
});
|
|
6664
7162
|
}
|
|
@@ -6895,11 +7393,44 @@ function compileReplacement(inputs) {
|
|
|
6895
7393
|
inputs.posture,
|
|
6896
7394
|
inputs.tableCellTextRange
|
|
6897
7395
|
);
|
|
7396
|
+
case "scope":
|
|
7397
|
+
if (inputs.enumeratedScope.kind === "scope") {
|
|
7398
|
+
return compileScopeReplacement(inputs.enumeratedScope, inputs.proposed, {
|
|
7399
|
+
document: inputs.document,
|
|
7400
|
+
posture: inputs.posture
|
|
7401
|
+
});
|
|
7402
|
+
}
|
|
7403
|
+
return null;
|
|
6898
7404
|
default:
|
|
6899
7405
|
return null;
|
|
6900
7406
|
}
|
|
6901
7407
|
}
|
|
6902
7408
|
|
|
7409
|
+
// src/runtime/scopes/multi-paragraph-refusal.ts
|
|
7410
|
+
var MULTI_PARAGRAPH_REPLACEMENT_REFUSAL = "compile-refused:scope:multi-paragraph-replace-not-implemented";
|
|
7411
|
+
function shapeBlocker(shape) {
|
|
7412
|
+
switch (shape) {
|
|
7413
|
+
case "text":
|
|
7414
|
+
return "compile-refused:scope:multi-paragraph-text-replace-not-implemented";
|
|
7415
|
+
case "fragment":
|
|
7416
|
+
return "compile-refused:scope:multi-paragraph-fragment-replace-not-implemented";
|
|
7417
|
+
default:
|
|
7418
|
+
return "compile-refused:scope:multi-paragraph-replace-shape-not-implemented";
|
|
7419
|
+
}
|
|
7420
|
+
}
|
|
7421
|
+
function multiParagraphReplacementBlockers(shape = "unknown") {
|
|
7422
|
+
return Object.freeze([
|
|
7423
|
+
MULTI_PARAGRAPH_REPLACEMENT_REFUSAL,
|
|
7424
|
+
shapeBlocker(shape),
|
|
7425
|
+
"capability:scope:block-granular-replacement-lowering-required",
|
|
7426
|
+
"capability:scope:provenance:marker-backed-required",
|
|
7427
|
+
"capability:scope:layout-completeness-required",
|
|
7428
|
+
"capability:scope:geometry-completeness-required",
|
|
7429
|
+
"capability:scope:continuation-state-required",
|
|
7430
|
+
"capability:scope:preservation-verdict-required"
|
|
7431
|
+
]);
|
|
7432
|
+
}
|
|
7433
|
+
|
|
6903
7434
|
// src/runtime/scopes/replacement/apply.ts
|
|
6904
7435
|
function documentHash2(doc) {
|
|
6905
7436
|
let hash = 2166136261;
|
|
@@ -7062,14 +7593,18 @@ function applyScopeReplacement(inputs) {
|
|
|
7062
7593
|
});
|
|
7063
7594
|
if (!plan) {
|
|
7064
7595
|
const paragraphLike = resolvedScope.kind === "paragraph" || resolvedScope.kind === "heading" || resolvedScope.kind === "list-item";
|
|
7065
|
-
const blockers = resolvedScope.kind === "scope" ?
|
|
7596
|
+
const blockers = resolvedScope.kind === "scope" && posture === "suggest-mode" ? [
|
|
7597
|
+
proposed.proposedContent.kind === "structured" ? "compile-refused:scope:multi-paragraph-structured-suggesting-not-implemented" : "compile-refused:scope:multi-paragraph-suggesting-not-implemented"
|
|
7598
|
+
] : resolvedScope.kind === "scope" && proposed.operation !== "replace" ? [
|
|
7599
|
+
`compile-refused:scope:operation-not-implemented:${proposed.operation}`
|
|
7600
|
+
] : resolvedScope.kind === "scope" ? multiParagraphReplacementBlockers(
|
|
7066
7601
|
proposed.proposedContent.kind === "structured" ? "fragment" : "text"
|
|
7067
7602
|
) : paragraphLike && proposed.operation === "replace" && proposed.preserve?.opaqueFragments === true ? [
|
|
7068
7603
|
`compile-refused:${resolvedScope.kind}:opaque-preserving-text-target-unavailable`
|
|
7069
7604
|
] : resolvedScope.kind === "table-cell" ? [tableCellRefusalBlocker(tableCellTextRange)] : paragraphLike && proposed.operation !== "replace" ? [
|
|
7070
7605
|
`compile-refused:${resolvedScope.kind}:operation-not-implemented:${proposed.operation}`
|
|
7071
7606
|
] : [`compile-refused:${resolvedScope.kind}`];
|
|
7072
|
-
const blocker =
|
|
7607
|
+
const blocker = blockers[0] ?? `compile-refused:${resolvedScope.kind}`;
|
|
7073
7608
|
const refused = {
|
|
7074
7609
|
safe: false,
|
|
7075
7610
|
posture: "hard-refusal",
|
|
@@ -7548,10 +8083,10 @@ function createScopeCompilerService(runtime) {
|
|
|
7548
8083
|
emitMetadataAudit(request) {
|
|
7549
8084
|
try {
|
|
7550
8085
|
const snapshot = request.targetScopeSnapshot;
|
|
7551
|
-
const
|
|
8086
|
+
const operation2 = "annotate";
|
|
7552
8087
|
const proposed = {
|
|
7553
8088
|
targetHandle: snapshot.handle,
|
|
7554
|
-
operation,
|
|
8089
|
+
operation: operation2,
|
|
7555
8090
|
proposedContent: {
|
|
7556
8091
|
kind: "structured",
|
|
7557
8092
|
structured: {
|
|
@@ -7626,6 +8161,10 @@ function createScopeCompilerService(runtime) {
|
|
|
7626
8161
|
...editableTargetCache ? { editableTargetCache } : {}
|
|
7627
8162
|
});
|
|
7628
8163
|
},
|
|
8164
|
+
compileEditableGraphById(scopeId, nowUtc) {
|
|
8165
|
+
const bundle = this.compileBundleById(scopeId, nowUtc);
|
|
8166
|
+
return bundle ? compileScopeEditableGraph(bundle) : null;
|
|
8167
|
+
},
|
|
7629
8168
|
buildReplacementScope(targetHandle, input) {
|
|
7630
8169
|
return proposeReplacement({
|
|
7631
8170
|
targetHandle,
|
|
@@ -9057,6 +9596,13 @@ export {
|
|
|
9057
9596
|
ensureDefaultListInstance,
|
|
9058
9597
|
allocateNumberingInstance,
|
|
9059
9598
|
setStartOverride,
|
|
9599
|
+
inlineLengthForScopeCoordinates,
|
|
9600
|
+
computeScopeStoryLayout,
|
|
9601
|
+
findParagraphSlotAtPosition,
|
|
9602
|
+
findOwningBlockSlotAtPosition,
|
|
9603
|
+
sameScopeParagraphPath,
|
|
9604
|
+
replaceParagraphChildrenAtPath,
|
|
9605
|
+
removeScopeMarkersFromBlockList,
|
|
9060
9606
|
collectScopeLocations,
|
|
9061
9607
|
resolveScope,
|
|
9062
9608
|
findAllScopesAt,
|