@beyondwork/docx-react-component 1.0.132 → 1.0.134
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 +161 -68
- 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 +9878 -7387
- 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-QUTVR72L.js → chunk-3YR47WTD.js} +296 -587
- package/dist/{chunk-RYMMKOFI.js → chunk-5KTJKTNE.js} +32 -0
- package/dist/{chunk-UP2KDOYE.js → chunk-74R5B2EZ.js} +6 -2
- package/dist/{chunk-6736GA6J.js → chunk-7Y6JCIK3.js} +1 -1
- package/dist/{chunk-43JAPM2F.js → chunk-EBSI6VQX.js} +546 -144
- package/dist/{chunk-JVTDBX67.js → chunk-EFEW7BTT.js} +2 -2
- package/dist/{chunk-YUHNDEV5.js → chunk-ESEEWELA.js} +3534 -1870
- package/dist/{chunk-XYTWOJII.js → chunk-IJD6D7HU.js} +745 -103
- package/dist/{chunk-UFPBYJMA.js → chunk-INLRCC4N.js} +2 -2
- package/dist/{chunk-N5FTU4HZ.js → chunk-MQ5GAJ54.js} +68 -39
- package/dist/{chunk-W2I47J2Q.js → chunk-NJFKPDNG.js} +216 -2
- package/dist/{chunk-LPLJZJT2.js → chunk-O4EDZR44.js} +131 -70
- 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-RBWJHRNP.js → chunk-T66OS7MN.js} +8 -3
- package/dist/{chunk-ALWXYGXP.js → chunk-V2JF42SI.js} +2 -2
- package/dist/{chunk-CDEZGLQ3.js → chunk-VA24T4EB.js} +1 -1
- package/dist/{chunk-6TLZ6CMP.js → chunk-WDDFU2N2.js} +2 -2
- package/dist/{chunk-U3UMKA7B.js → chunk-XBQFDBXE.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 +5365 -2298
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +388 -63
- 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-CK3lZy4h.d.cts} +2 -2
- package/dist/{loader-CfpeEPAa.d.ts → loader-CQXplstv.d.ts} +2 -2
- package/dist/{public-types-KBS6JnOs.d.cts → public-types-BR1SYK2F.d.cts} +783 -189
- package/dist/{public-types-Cjs8glST.d.ts → public-types-DXNZVKrS.d.ts} +783 -189
- package/dist/public-types.cjs +161 -68
- 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 +1597 -444
- 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-C9UjrhJF.d.ts} +2 -2
- package/dist/{session-wwe0Gib-.d.cts → session-CSbwkgII.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 +451 -650
- package/dist/tailwind.d.cts +1 -1
- package/dist/tailwind.d.ts +1 -1
- package/dist/tailwind.js +7 -7
- package/dist/{types-B3SGRW0w.d.cts → types-CZtAueri.d.cts} +1 -1
- package/dist/{types-CH7NWqVL.d.ts → types-RzkCXDNV.d.ts} +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 +451 -650
- 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
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
createSearchPlugin,
|
|
5
5
|
performSearch,
|
|
6
6
|
searchPluginKey
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-VA24T4EB.js";
|
|
8
8
|
import {
|
|
9
9
|
CODE_METADATA_TABLE,
|
|
10
10
|
KNOWN_DIAGNOSTIC_CODES,
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
splitListParagraph,
|
|
27
27
|
toggleBulletedList,
|
|
28
28
|
toggleNumberedList
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-EBSI6VQX.js";
|
|
30
30
|
import {
|
|
31
31
|
applyParagraphStyleToDocument
|
|
32
32
|
} from "./chunk-6EXNNAO6.js";
|
|
@@ -37,7 +37,7 @@ import {
|
|
|
37
37
|
setSectionPageNumberingAtSectionIndex,
|
|
38
38
|
updateSectionLayoutAtSectionIndex
|
|
39
39
|
} from "./chunk-M6XR534O.js";
|
|
40
|
-
import "./chunk-
|
|
40
|
+
import "./chunk-RP76USJE.js";
|
|
41
41
|
import {
|
|
42
42
|
createRuntimeCollabSync,
|
|
43
43
|
createRuntimeCommandAppliedBridge
|
|
@@ -45,7 +45,7 @@ import {
|
|
|
45
45
|
import {
|
|
46
46
|
insertPageBreak,
|
|
47
47
|
insertTable
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-REFHJ2FN.js";
|
|
49
49
|
import {
|
|
50
50
|
getFormattingStateFromRenderSnapshot
|
|
51
51
|
} from "./chunk-Y4XZCMCS.js";
|
|
@@ -53,13 +53,13 @@ import {
|
|
|
53
53
|
insertImage,
|
|
54
54
|
repositionFloatingImage,
|
|
55
55
|
resizeImage
|
|
56
|
-
} from "./chunk-
|
|
57
|
-
import "./chunk-
|
|
56
|
+
} from "./chunk-INLRCC4N.js";
|
|
57
|
+
import "./chunk-MQ5GAJ54.js";
|
|
58
58
|
import {
|
|
59
59
|
getTableStructureContext,
|
|
60
60
|
tableStructureActionHandleForTarget
|
|
61
|
-
} from "./chunk-
|
|
62
|
-
import "./chunk-
|
|
61
|
+
} from "./chunk-WDDFU2N2.js";
|
|
62
|
+
import "./chunk-QTRJLKR2.js";
|
|
63
63
|
import {
|
|
64
64
|
MOUNTED_SURFACE_VIEWPORT_BLOCK_THRESHOLD,
|
|
65
65
|
OverlayAnchorBridgeProvider,
|
|
@@ -83,14 +83,15 @@ import {
|
|
|
83
83
|
resolveScopedChromePolicy,
|
|
84
84
|
resolveScrollTopForAnchor,
|
|
85
85
|
resolveSelectionToolRegistry,
|
|
86
|
+
sanitizeNumberingPictureBulletSrc,
|
|
86
87
|
shouldRenderAbsoluteFloatingImageInPageOverlay,
|
|
87
88
|
shouldRenderSelectionToolKind,
|
|
88
89
|
shouldUseMountedSurfaceViewportCulling,
|
|
89
90
|
useLayoutFacetRenderSignal
|
|
90
|
-
} from "./chunk-
|
|
91
|
+
} from "./chunk-3YR47WTD.js";
|
|
91
92
|
import {
|
|
92
93
|
createInertGeometryFacet
|
|
93
|
-
} from "./chunk-
|
|
94
|
+
} from "./chunk-74R5B2EZ.js";
|
|
94
95
|
import {
|
|
95
96
|
composeSeriesColor,
|
|
96
97
|
computeStructuralHash,
|
|
@@ -104,12 +105,12 @@ import {
|
|
|
104
105
|
resolveColor,
|
|
105
106
|
tryReadLaycacheEnvelope,
|
|
106
107
|
writeEnvelopeToOpcPackage
|
|
107
|
-
} from "./chunk-
|
|
108
|
+
} from "./chunk-ESEEWELA.js";
|
|
108
109
|
import {
|
|
109
110
|
findTextMatches,
|
|
110
111
|
parseCanonicalFragmentFromWordML,
|
|
111
112
|
searchDocument
|
|
112
|
-
} from "./chunk-
|
|
113
|
+
} from "./chunk-IJD6D7HU.js";
|
|
113
114
|
import {
|
|
114
115
|
clearLocalCursorState,
|
|
115
116
|
getCursorColorForUser,
|
|
@@ -119,7 +120,7 @@ import {
|
|
|
119
120
|
import {
|
|
120
121
|
resolveChromePreset,
|
|
121
122
|
resolveChromeVisibilityForPreset
|
|
122
|
-
} from "./chunk-
|
|
123
|
+
} from "./chunk-NJFKPDNG.js";
|
|
123
124
|
import {
|
|
124
125
|
CAPABILITY_BY_ID,
|
|
125
126
|
ISSUE_METADATA_ID,
|
|
@@ -141,7 +142,7 @@ import {
|
|
|
141
142
|
sanitizeMarkdown,
|
|
142
143
|
sha256Hex,
|
|
143
144
|
startPerfProbe
|
|
144
|
-
} from "./chunk-
|
|
145
|
+
} from "./chunk-O4EDZR44.js";
|
|
145
146
|
import "./chunk-OVLZQ6FZ.js";
|
|
146
147
|
import "./chunk-QIO6V46H.js";
|
|
147
148
|
import {
|
|
@@ -149,7 +150,7 @@ import {
|
|
|
149
150
|
getStoryBlocks,
|
|
150
151
|
replaceStoryBlocks,
|
|
151
152
|
stableChartId
|
|
152
|
-
} from "./chunk-
|
|
153
|
+
} from "./chunk-XBQFDBXE.js";
|
|
153
154
|
import "./chunk-SYQWQ6FE.js";
|
|
154
155
|
import {
|
|
155
156
|
createDefaultCanonicalDocument,
|
|
@@ -160,14 +161,14 @@ import {
|
|
|
160
161
|
SessionNotOpenError,
|
|
161
162
|
SessionNotWiredError,
|
|
162
163
|
isReopenBarrier
|
|
163
|
-
} from "./chunk-
|
|
164
|
+
} from "./chunk-V2JF42SI.js";
|
|
164
165
|
import {
|
|
165
166
|
createHmacSigner,
|
|
166
167
|
createHmacVerifier,
|
|
167
168
|
loadDocxSessionSync,
|
|
168
169
|
signWorkflowPayloadXml,
|
|
169
170
|
verifyWorkflowPayloadXml
|
|
170
|
-
} from "./chunk-
|
|
171
|
+
} from "./chunk-EFEW7BTT.js";
|
|
171
172
|
import {
|
|
172
173
|
EDITOR_SESSION_STATE_VERSION,
|
|
173
174
|
assertEditorSessionState,
|
|
@@ -176,8 +177,8 @@ import {
|
|
|
176
177
|
editorSessionStateFromPersistedSnapshot,
|
|
177
178
|
persistedSnapshotFromEditorSessionState,
|
|
178
179
|
validateEditorSessionState
|
|
179
|
-
} from "./chunk-
|
|
180
|
-
import "./chunk-
|
|
180
|
+
} from "./chunk-PZIEOEJZ.js";
|
|
181
|
+
import "./chunk-T66OS7MN.js";
|
|
181
182
|
import {
|
|
182
183
|
decodePersistedSourcePackageBytes,
|
|
183
184
|
hasValidPersistedSourcePackageDigest
|
|
@@ -189,7 +190,7 @@ import {
|
|
|
189
190
|
collectEditableTargetRefs,
|
|
190
191
|
createHeaderFooterStoryKey,
|
|
191
192
|
createNoteStoryKey
|
|
192
|
-
} from "./chunk-
|
|
193
|
+
} from "./chunk-5KTJKTNE.js";
|
|
193
194
|
import {
|
|
194
195
|
readOpcPackage
|
|
195
196
|
} from "./chunk-WUDSNHWF.js";
|
|
@@ -327,6 +328,9 @@ function applyListAwareTextCommand(context, command, deps) {
|
|
|
327
328
|
if (!paragraphContext.atParagraphStart || !context.localSnapshot.selection.isCollapsed) {
|
|
328
329
|
return null;
|
|
329
330
|
}
|
|
331
|
+
if (shouldRouteListBoundaryJoinThroughTextCommand(context, paragraphContext)) {
|
|
332
|
+
return null;
|
|
333
|
+
}
|
|
330
334
|
const result = backspaceAtListStart(
|
|
331
335
|
context.localDocument,
|
|
332
336
|
paragraphContext.paragraphIndex,
|
|
@@ -367,6 +371,39 @@ function listCommandTargetOptions(context, paragraphContext) {
|
|
|
367
371
|
}
|
|
368
372
|
return { editableTargets: [paragraphContext.paragraph.editableTarget] };
|
|
369
373
|
}
|
|
374
|
+
function shouldRouteListBoundaryJoinThroughTextCommand(context, paragraphContext) {
|
|
375
|
+
const currentNumbering = paragraphContext.paragraph.numbering;
|
|
376
|
+
const currentTarget = paragraphContext.paragraph.editableTarget;
|
|
377
|
+
if (context.activeStory.kind !== "main" || !currentNumbering || currentNumbering.level > 0 || currentTarget?.listAddress?.operationScope !== "list-text") {
|
|
378
|
+
return false;
|
|
379
|
+
}
|
|
380
|
+
const paragraphs = collectSurfaceParagraphs(context.localSnapshot.surface?.blocks ?? []);
|
|
381
|
+
const previous = paragraphs[paragraphContext.paragraphIndex - 1];
|
|
382
|
+
const previousNumbering = previous?.numbering;
|
|
383
|
+
return Boolean(
|
|
384
|
+
previousNumbering && previousNumbering.numberingInstanceId === currentNumbering.numberingInstanceId && previousNumbering.level === currentNumbering.level
|
|
385
|
+
);
|
|
386
|
+
}
|
|
387
|
+
function collectSurfaceParagraphs(blocks, output = []) {
|
|
388
|
+
for (const block of blocks) {
|
|
389
|
+
if (block.kind === "paragraph") {
|
|
390
|
+
output.push(block);
|
|
391
|
+
continue;
|
|
392
|
+
}
|
|
393
|
+
if (block.kind === "table") {
|
|
394
|
+
for (const row of block.rows) {
|
|
395
|
+
for (const cell of row.cells) {
|
|
396
|
+
collectSurfaceParagraphs(cell.content, output);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
continue;
|
|
400
|
+
}
|
|
401
|
+
if (block.kind === "sdt_block") {
|
|
402
|
+
collectSurfaceParagraphs(block.children, output);
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
return output;
|
|
406
|
+
}
|
|
370
407
|
function createListMutationResult(result, selection, deps) {
|
|
371
408
|
return {
|
|
372
409
|
changed: result.affectedParagraphIndexes.length > 0,
|
|
@@ -403,13 +440,23 @@ function dispatchTextCommand(runtime, command, deps) {
|
|
|
403
440
|
}
|
|
404
441
|
switch (command.type) {
|
|
405
442
|
case "insert-text":
|
|
406
|
-
runtime.applyActiveStoryTextCommand({
|
|
443
|
+
runtime.applyActiveStoryTextCommand({
|
|
444
|
+
type: "text.insert",
|
|
445
|
+
text: command.text,
|
|
446
|
+
...mountedListTextTarget(context, deps)
|
|
447
|
+
});
|
|
407
448
|
return;
|
|
408
449
|
case "delete-backward":
|
|
409
|
-
runtime.applyActiveStoryTextCommand({
|
|
450
|
+
runtime.applyActiveStoryTextCommand({
|
|
451
|
+
type: "text.delete-backward",
|
|
452
|
+
...mountedListTextTarget(context, deps)
|
|
453
|
+
});
|
|
410
454
|
return;
|
|
411
455
|
case "delete-forward":
|
|
412
|
-
runtime.applyActiveStoryTextCommand({
|
|
456
|
+
runtime.applyActiveStoryTextCommand({
|
|
457
|
+
type: "text.delete-forward",
|
|
458
|
+
...mountedListTextTarget(context, deps)
|
|
459
|
+
});
|
|
413
460
|
return;
|
|
414
461
|
case "insert-tab":
|
|
415
462
|
runtime.applyActiveStoryTextCommand({ type: "text.insert-tab" });
|
|
@@ -418,13 +465,30 @@ function dispatchTextCommand(runtime, command, deps) {
|
|
|
418
465
|
runtime.applyActiveStoryTextCommand({ type: "text.outdent-tab" });
|
|
419
466
|
return;
|
|
420
467
|
case "insert-hard-break":
|
|
421
|
-
runtime.applyActiveStoryTextCommand({
|
|
468
|
+
runtime.applyActiveStoryTextCommand({
|
|
469
|
+
type: "text.insert-hard-break",
|
|
470
|
+
...mountedListTextTarget(context, deps)
|
|
471
|
+
});
|
|
422
472
|
return;
|
|
423
473
|
case "split-paragraph":
|
|
424
|
-
runtime.applyActiveStoryTextCommand({
|
|
474
|
+
runtime.applyActiveStoryTextCommand({
|
|
475
|
+
type: "paragraph.split",
|
|
476
|
+
...mountedListTextTarget(context, deps)
|
|
477
|
+
});
|
|
425
478
|
return;
|
|
426
479
|
}
|
|
427
480
|
}
|
|
481
|
+
function mountedListTextTarget(context, deps) {
|
|
482
|
+
const selectionTarget = context.localSnapshot.selection.editableTarget;
|
|
483
|
+
if (selectionTarget?.listAddress?.operationScope === "list-text") {
|
|
484
|
+
return { editableTarget: selectionTarget };
|
|
485
|
+
}
|
|
486
|
+
const paragraphTarget = deps.resolveActiveParagraphContext(context.localSnapshot)?.paragraph.editableTarget;
|
|
487
|
+
if (paragraphTarget?.listAddress?.operationScope === "list-text") {
|
|
488
|
+
return { editableTarget: paragraphTarget };
|
|
489
|
+
}
|
|
490
|
+
return {};
|
|
491
|
+
}
|
|
428
492
|
function getMountedTextCommandName(command) {
|
|
429
493
|
switch (command.type) {
|
|
430
494
|
case "insert-text":
|
|
@@ -5333,7 +5397,7 @@ var editorSchema = new Schema({
|
|
|
5333
5397
|
if (typeof numberingMarkerStartTwips === "number") {
|
|
5334
5398
|
attrs["data-numbering-marker-start-twips"] = String(numberingMarkerStartTwips);
|
|
5335
5399
|
}
|
|
5336
|
-
const _numberingMarkerWidthTwips = node.attrs.numberingMarkerWidth;
|
|
5400
|
+
const _numberingMarkerWidthTwips = node.attrs.numberingMarkerWidth ?? node.attrs.indentHanging;
|
|
5337
5401
|
if (typeof _numberingMarkerWidthTwips === "number" && _numberingMarkerWidthTwips > 0) {
|
|
5338
5402
|
attrs["data-numbering-marker-width-twips"] = String(
|
|
5339
5403
|
_numberingMarkerWidthTwips
|
|
@@ -5349,7 +5413,9 @@ var editorSchema = new Schema({
|
|
|
5349
5413
|
const numberingMarkerWidth = node.attrs.numberingMarkerWidth;
|
|
5350
5414
|
const numberingMarkerStart = node.attrs.numberingMarkerStart;
|
|
5351
5415
|
const numberingMarkerJustification = node.attrs.numberingMarkerJustification;
|
|
5352
|
-
const numberingPicBulletSrc =
|
|
5416
|
+
const numberingPicBulletSrc = sanitizeNumberingPictureBulletSrc(
|
|
5417
|
+
node.attrs.numberingPicBulletSrc
|
|
5418
|
+
);
|
|
5353
5419
|
const children = [];
|
|
5354
5420
|
if (pageBreak) {
|
|
5355
5421
|
attrs["data-page-break-before"] = "true";
|
|
@@ -5405,6 +5471,7 @@ var editorSchema = new Schema({
|
|
|
5405
5471
|
{
|
|
5406
5472
|
class: baseClasses.join(" "),
|
|
5407
5473
|
contenteditable: "false",
|
|
5474
|
+
"data-numbering-marker": "true",
|
|
5408
5475
|
"data-numbering-prefix": numberingPicBulletSrc ? "" : numberingPrefix ?? "",
|
|
5409
5476
|
...typeof numberingLevel === "number" ? { "data-numbering-level": String(numberingLevel) } : {},
|
|
5410
5477
|
...numberingSuffix ? { "data-numbering-suffix": numberingSuffix } : {},
|
|
@@ -5776,13 +5843,17 @@ var editorSchema = new Schema({
|
|
|
5776
5843
|
},
|
|
5777
5844
|
toDOM(node) {
|
|
5778
5845
|
const refreshStatus = node.attrs.refreshStatus;
|
|
5846
|
+
const fieldTarget = node.attrs.fieldTarget;
|
|
5779
5847
|
const statusClass = refreshStatus === "current" ? "text-blue-700 bg-blue-50 border-blue-200" : refreshStatus === "unresolvable" ? "text-amber-800 bg-amber-50 border-amber-200" : "text-slate-700 bg-slate-50 border-slate-200";
|
|
5780
5848
|
return [
|
|
5781
5849
|
"span",
|
|
5782
5850
|
{
|
|
5783
5851
|
class: `inline-flex items-center gap-1 mx-0.5 px-1.5 py-0.5 rounded text-xs border ${statusClass}`,
|
|
5784
5852
|
"data-node-type": "field_ref_atom",
|
|
5853
|
+
"data-generated-field": "true",
|
|
5785
5854
|
"data-field-family": node.attrs.fieldFamily,
|
|
5855
|
+
...fieldTarget ? { "data-field-target": fieldTarget } : {},
|
|
5856
|
+
"data-field-refresh-status": refreshStatus,
|
|
5786
5857
|
title: node.attrs.instruction
|
|
5787
5858
|
},
|
|
5788
5859
|
node.attrs.label || "Field"
|
|
@@ -6463,8 +6534,39 @@ function buildPositionMap(surface) {
|
|
|
6463
6534
|
}
|
|
6464
6535
|
return lastStoryRestorableEntry(entries)?.pmEnd ?? 1;
|
|
6465
6536
|
};
|
|
6537
|
+
const runtimeToPmWithBias = (runtimePos, bias) => {
|
|
6538
|
+
if (bias > 0) return runtimeToPm(runtimePos);
|
|
6539
|
+
const firstEditable = entries.find(isStoryRuntimeRestorableEntry);
|
|
6540
|
+
if (runtimePos <= 0) {
|
|
6541
|
+
return firstEditable?.pmStart ?? 1;
|
|
6542
|
+
}
|
|
6543
|
+
if (runtimePos >= runtimeStorySize) {
|
|
6544
|
+
return lastStoryRestorableEntry(entries)?.pmEnd ?? pmDocSize - 1;
|
|
6545
|
+
}
|
|
6546
|
+
let previous = null;
|
|
6547
|
+
for (const entry of entries) {
|
|
6548
|
+
if (!isStoryRuntimeRestorableEntry(entry)) {
|
|
6549
|
+
continue;
|
|
6550
|
+
}
|
|
6551
|
+
if (entry.runtimeStart === entry.runtimeEnd && runtimePos === entry.runtimeStart) {
|
|
6552
|
+
return previous?.pmEnd ?? entry.pmStart;
|
|
6553
|
+
}
|
|
6554
|
+
if (runtimePos > entry.runtimeStart && runtimePos <= entry.runtimeEnd) {
|
|
6555
|
+
return entry.pmStart + (runtimePos - entry.runtimeStart);
|
|
6556
|
+
}
|
|
6557
|
+
if (runtimePos <= entry.runtimeStart) {
|
|
6558
|
+
if (runtimePos === entry.runtimeStart && previous) {
|
|
6559
|
+
return previous.pmEnd;
|
|
6560
|
+
}
|
|
6561
|
+
return nearestRuntimeGapPm(runtimePos, previous, entry);
|
|
6562
|
+
}
|
|
6563
|
+
previous = entry;
|
|
6564
|
+
}
|
|
6565
|
+
return lastStoryRestorableEntry(entries)?.pmEnd ?? 1;
|
|
6566
|
+
};
|
|
6466
6567
|
return {
|
|
6467
6568
|
runtimeToPm,
|
|
6569
|
+
runtimeToPmWithBias,
|
|
6468
6570
|
runtimeToPmWithContext(input) {
|
|
6469
6571
|
const targetEntry = input.editableTarget ? findRestorableEntryForTarget(entries, input.editableTarget, input.runtimePos) : void 0;
|
|
6470
6572
|
if (targetEntry) {
|
|
@@ -7274,7 +7376,7 @@ function buildParagraph(block, previousParagraph, nextParagraph, mediaPreviews,
|
|
|
7274
7376
|
numberingPicBulletSrc: (() => {
|
|
7275
7377
|
const mediaId = block.resolvedNumbering?.picBulletMediaId;
|
|
7276
7378
|
if (!mediaId) return null;
|
|
7277
|
-
return mediaPreviews[mediaId]?.src
|
|
7379
|
+
return sanitizeNumberingPictureBulletSrc(mediaPreviews[mediaId]?.src);
|
|
7278
7380
|
})(),
|
|
7279
7381
|
shadingFill: block.shading?.fill ?? cascade?.shading?.fill ?? null,
|
|
7280
7382
|
borderTop: block.borders?.top ?? cascadeBorders?.top ?? null,
|
|
@@ -7824,9 +7926,9 @@ function resolveDropSelectionFromCoordinates(view, event) {
|
|
|
7824
7926
|
if (selection.eq(view.state.selection)) return;
|
|
7825
7927
|
view.dispatch(view.state.tr.setSelection(selection));
|
|
7826
7928
|
}
|
|
7827
|
-
function applyPasteSegmentsToCallbacks(segments, callbacks) {
|
|
7929
|
+
function applyPasteSegmentsToCallbacks(segments, callbacks, context) {
|
|
7828
7930
|
if (callbacks.onPastePlainTextFragment && callbacks.shouldPastePlainTextAsFragment?.() !== false && segments.some((seg) => seg.kind === "split") && segments.some((seg) => seg.kind === "text" && seg.value.length > 0)) {
|
|
7829
|
-
callbacks.onPastePlainTextFragment(createPlainTextFragmentFromSegments(segments));
|
|
7931
|
+
callbacks.onPastePlainTextFragment(createPlainTextFragmentFromSegments(segments), context);
|
|
7830
7932
|
return;
|
|
7831
7933
|
}
|
|
7832
7934
|
for (const seg of segments) {
|
|
@@ -7896,6 +7998,34 @@ function applyContextMenuEvent(callbacks, event) {
|
|
|
7896
7998
|
return false;
|
|
7897
7999
|
}
|
|
7898
8000
|
}
|
|
8001
|
+
function elementFromEventTarget(target) {
|
|
8002
|
+
if (!target) return null;
|
|
8003
|
+
const maybeElement = target;
|
|
8004
|
+
if (typeof maybeElement.closest === "function") return maybeElement;
|
|
8005
|
+
const maybeNode = target;
|
|
8006
|
+
return maybeNode.parentElement ?? null;
|
|
8007
|
+
}
|
|
8008
|
+
function applyNumberingMarkerClick(view, event) {
|
|
8009
|
+
const targetElement = elementFromEventTarget(event.target);
|
|
8010
|
+
const marker = targetElement?.closest('[data-numbering-marker="true"]');
|
|
8011
|
+
if (!marker) return false;
|
|
8012
|
+
const paragraph = marker.closest('p[data-numbered="true"]');
|
|
8013
|
+
if (!paragraph) return false;
|
|
8014
|
+
const content = paragraph.querySelector(".pm-paragraph-content");
|
|
8015
|
+
if (!content) return false;
|
|
8016
|
+
let contentStart;
|
|
8017
|
+
try {
|
|
8018
|
+
contentStart = view.posAtDOM(content, 0);
|
|
8019
|
+
} catch {
|
|
8020
|
+
return false;
|
|
8021
|
+
}
|
|
8022
|
+
const docSize = view.state.doc.content.size;
|
|
8023
|
+
const boundedStart = Math.max(0, Math.min(contentStart, docSize));
|
|
8024
|
+
const selection = TextSelection2.near(view.state.doc.resolve(boundedStart), 1);
|
|
8025
|
+
event.preventDefault();
|
|
8026
|
+
view.dispatch(view.state.tr.setSelection(selection).scrollIntoView());
|
|
8027
|
+
return true;
|
|
8028
|
+
}
|
|
7899
8029
|
var bridgeKey = new PluginKey("command-bridge");
|
|
7900
8030
|
function createSelectionSyncPlugin(callbacks) {
|
|
7901
8031
|
return new Plugin({
|
|
@@ -8033,6 +8163,9 @@ function createCommandBridgePlugins(callbacks, options) {
|
|
|
8033
8163
|
// behavior (back-compat).
|
|
8034
8164
|
contextmenu(_view, event) {
|
|
8035
8165
|
return applyContextMenuEvent(callbacks, event);
|
|
8166
|
+
},
|
|
8167
|
+
click(view, event) {
|
|
8168
|
+
return applyNumberingMarkerClick(view, event);
|
|
8036
8169
|
}
|
|
8037
8170
|
},
|
|
8038
8171
|
handleTextInput(_view, _from, _to, text) {
|
|
@@ -8059,10 +8192,12 @@ function createCommandBridgePlugins(callbacks, options) {
|
|
|
8059
8192
|
// through to Tier A so the user isn't left with a silent no-op.
|
|
8060
8193
|
handlePaste(_view, event) {
|
|
8061
8194
|
if (isComposing) return true;
|
|
8062
|
-
|
|
8195
|
+
const positionMap = callbacks.getPositionMap();
|
|
8196
|
+
if (!isPmEditTargetEditable(_view.state, positionMap)) {
|
|
8063
8197
|
callbacks.onBlockedInput?.("paste", NON_EDITABLE_INPUT_MESSAGE);
|
|
8064
8198
|
return true;
|
|
8065
8199
|
}
|
|
8200
|
+
const editableTarget = resolveCurrentEditableTarget(_view.state, positionMap);
|
|
8066
8201
|
const clipboard = event.clipboardData;
|
|
8067
8202
|
if (!clipboard) {
|
|
8068
8203
|
callbacks.onBlockedInput?.("paste", "Clipboard data was not available.");
|
|
@@ -8084,7 +8219,11 @@ function createCommandBridgePlugins(callbacks, options) {
|
|
|
8084
8219
|
if (wordml) {
|
|
8085
8220
|
const parsed = options.pasteFragmentParser.parseWordML(wordml);
|
|
8086
8221
|
if (parsed.ok && parsed.fragment.blocks.length > 0) {
|
|
8087
|
-
callbacks.onPasteFragment({
|
|
8222
|
+
callbacks.onPasteFragment({
|
|
8223
|
+
fragment: parsed.fragment,
|
|
8224
|
+
source: "wordml",
|
|
8225
|
+
...editableTarget ? { editableTarget } : {}
|
|
8226
|
+
});
|
|
8088
8227
|
return true;
|
|
8089
8228
|
}
|
|
8090
8229
|
}
|
|
@@ -8094,7 +8233,11 @@ function createCommandBridgePlugins(callbacks, options) {
|
|
|
8094
8233
|
if (htmlPayload && htmlPayload.trim().length > 0) {
|
|
8095
8234
|
const parsed = options.pasteFragmentParser.parseHtml(htmlPayload);
|
|
8096
8235
|
if (parsed.ok && parsed.fragment.blocks.length > 0) {
|
|
8097
|
-
callbacks.onPasteFragment({
|
|
8236
|
+
callbacks.onPasteFragment({
|
|
8237
|
+
fragment: parsed.fragment,
|
|
8238
|
+
source: "html",
|
|
8239
|
+
...editableTarget ? { editableTarget } : {}
|
|
8240
|
+
});
|
|
8098
8241
|
return true;
|
|
8099
8242
|
}
|
|
8100
8243
|
}
|
|
@@ -8108,7 +8251,11 @@ function createCommandBridgePlugins(callbacks, options) {
|
|
|
8108
8251
|
return true;
|
|
8109
8252
|
}
|
|
8110
8253
|
const segments = extractPlainTextSegments(plain);
|
|
8111
|
-
applyPasteSegmentsToCallbacks(
|
|
8254
|
+
applyPasteSegmentsToCallbacks(
|
|
8255
|
+
segments,
|
|
8256
|
+
callbacks,
|
|
8257
|
+
editableTarget ? { editableTarget } : void 0
|
|
8258
|
+
);
|
|
8112
8259
|
callbacks.onPasteApplied?.({
|
|
8113
8260
|
segmentCount: segments.length,
|
|
8114
8261
|
charCount: totalTextCharCount(segments),
|
|
@@ -8169,7 +8316,11 @@ function createCommandBridgePlugins(callbacks, options) {
|
|
|
8169
8316
|
return true;
|
|
8170
8317
|
}
|
|
8171
8318
|
const segments = extractPlainTextSegments(plain);
|
|
8172
|
-
applyPasteSegmentsToCallbacks(
|
|
8319
|
+
applyPasteSegmentsToCallbacks(
|
|
8320
|
+
segments,
|
|
8321
|
+
callbacks,
|
|
8322
|
+
editableTarget ? { editableTarget } : void 0
|
|
8323
|
+
);
|
|
8173
8324
|
callbacks.onPasteApplied?.({
|
|
8174
8325
|
segmentCount: segments.length,
|
|
8175
8326
|
charCount: totalTextCharCount(segments),
|
|
@@ -8476,9 +8627,10 @@ function buildAnchorPmRange(anchor, positionMap) {
|
|
|
8476
8627
|
return null;
|
|
8477
8628
|
}
|
|
8478
8629
|
if (anchor.kind === "range") {
|
|
8630
|
+
const mapBoundary = (runtimePos, bias) => positionMap.runtimeToPmWithBias ? positionMap.runtimeToPmWithBias(runtimePos, bias) : positionMap.runtimeToPm(runtimePos);
|
|
8479
8631
|
return {
|
|
8480
|
-
from:
|
|
8481
|
-
to:
|
|
8632
|
+
from: mapBoundary(anchor.from, anchor.assoc?.start ?? 1),
|
|
8633
|
+
to: mapBoundary(anchor.to, anchor.assoc?.end ?? -1),
|
|
8482
8634
|
allowInline: true
|
|
8483
8635
|
};
|
|
8484
8636
|
}
|
|
@@ -9721,13 +9873,10 @@ function createSurfaceDecorationKey(input) {
|
|
|
9721
9873
|
|
|
9722
9874
|
// src/ui-tailwind/editor-surface/pm-page-body-patch.ts
|
|
9723
9875
|
function resolvePmPageBodyPatchPlan(input) {
|
|
9724
|
-
|
|
9725
|
-
|
|
9726
|
-
|
|
9727
|
-
|
|
9728
|
-
pageIds: [...input.patchPlan.addedPages, ...input.patchPlan.removedPages]
|
|
9729
|
-
};
|
|
9730
|
-
}
|
|
9876
|
+
const membershipChangedPageIds = [
|
|
9877
|
+
...input.patchPlan.addedPages,
|
|
9878
|
+
...input.patchPlan.removedPages
|
|
9879
|
+
];
|
|
9731
9880
|
if (input.currentDoc.childCount !== input.previousSurface.blocks.length || input.nextDoc.childCount !== input.nextSurface.blocks.length) {
|
|
9732
9881
|
return {
|
|
9733
9882
|
status: "fallback",
|
|
@@ -9780,17 +9929,53 @@ function resolvePmPageBodyPatchPlan(input) {
|
|
|
9780
9929
|
pageIds: [pageId]
|
|
9781
9930
|
};
|
|
9782
9931
|
}
|
|
9932
|
+
if (nestedSpan.status === "nested") {
|
|
9933
|
+
rawSpans.push(nestedSpan.span);
|
|
9934
|
+
continue;
|
|
9935
|
+
}
|
|
9936
|
+
const topLevelSpans = resolveTopLevelFragmentPatchSpans({
|
|
9937
|
+
pageId,
|
|
9938
|
+
changedFragmentIds: entry.fragmentChanges,
|
|
9939
|
+
previousSurface: input.previousSurface,
|
|
9940
|
+
nextSurface: input.nextSurface,
|
|
9941
|
+
previousRange,
|
|
9942
|
+
nextRange
|
|
9943
|
+
});
|
|
9783
9944
|
rawSpans.push(
|
|
9784
|
-
|
|
9785
|
-
|
|
9786
|
-
|
|
9787
|
-
|
|
9788
|
-
|
|
9789
|
-
|
|
9790
|
-
|
|
9945
|
+
...topLevelSpans ?? [
|
|
9946
|
+
{
|
|
9947
|
+
pageIds: [pageId],
|
|
9948
|
+
fromBlockIndex: previousRange.first,
|
|
9949
|
+
toBlockIndex: previousRange.last + 1,
|
|
9950
|
+
nextFromBlockIndex: nextRange.first,
|
|
9951
|
+
nextToBlockIndex: nextRange.last + 1
|
|
9952
|
+
}
|
|
9953
|
+
]
|
|
9791
9954
|
);
|
|
9792
9955
|
}
|
|
9956
|
+
if (membershipChangedPageIds.length > 0 && !input.currentDoc.eq(input.nextDoc)) {
|
|
9957
|
+
const membershipSpan = resolveTopLevelMembershipPatchSpan({
|
|
9958
|
+
pageIds: membershipChangedPageIds,
|
|
9959
|
+
previousSurface: input.previousSurface,
|
|
9960
|
+
nextSurface: input.nextSurface
|
|
9961
|
+
});
|
|
9962
|
+
if (!membershipSpan) {
|
|
9963
|
+
return {
|
|
9964
|
+
status: "fallback",
|
|
9965
|
+
reason: "page-membership-change",
|
|
9966
|
+
pageIds: membershipChangedPageIds
|
|
9967
|
+
};
|
|
9968
|
+
}
|
|
9969
|
+
rawSpans.push(membershipSpan);
|
|
9970
|
+
}
|
|
9793
9971
|
if (rawSpans.length === 0) {
|
|
9972
|
+
if (membershipChangedPageIds.length > 0 && !input.currentDoc.eq(input.nextDoc)) {
|
|
9973
|
+
return {
|
|
9974
|
+
status: "fallback",
|
|
9975
|
+
reason: "page-membership-change",
|
|
9976
|
+
pageIds: membershipChangedPageIds
|
|
9977
|
+
};
|
|
9978
|
+
}
|
|
9794
9979
|
return {
|
|
9795
9980
|
status: "fallback",
|
|
9796
9981
|
reason: "no-body-fragment-changes",
|
|
@@ -9859,17 +10044,17 @@ function resolveNestedPatchSpan(input) {
|
|
|
9859
10044
|
(id) => findNestedBlockSpanById(input.nextSurface.blocks, input.nextDoc, id)
|
|
9860
10045
|
);
|
|
9861
10046
|
if (previousLocated.some((span) => !span) || nextLocated.some((span) => !span)) {
|
|
9862
|
-
return { status: "
|
|
10047
|
+
return { status: "top-level" };
|
|
9863
10048
|
}
|
|
9864
|
-
if (previousLocated.some(
|
|
9865
|
-
return { status: "
|
|
10049
|
+
if (previousLocated.some(isUnpatchableVerticalMergeContinuationSpan) || nextLocated.some(isUnpatchableVerticalMergeContinuationSpan)) {
|
|
10050
|
+
return { status: "top-level" };
|
|
9866
10051
|
}
|
|
9867
10052
|
const previousSpans = previousLocated;
|
|
9868
10053
|
const nextSpans = nextLocated;
|
|
9869
10054
|
const previousKinds = new Set(previousSpans.map((span) => span.block.kind));
|
|
9870
10055
|
const nextKinds = new Set(nextSpans.map((span) => span.block.kind));
|
|
9871
10056
|
if (previousKinds.size !== nextKinds.size || [...previousKinds].some((kind) => !nextKinds.has(kind))) {
|
|
9872
|
-
return { status: "
|
|
10057
|
+
return { status: "top-level" };
|
|
9873
10058
|
}
|
|
9874
10059
|
return {
|
|
9875
10060
|
status: "nested",
|
|
@@ -9887,6 +10072,104 @@ function resolveNestedPatchSpan(input) {
|
|
|
9887
10072
|
}
|
|
9888
10073
|
};
|
|
9889
10074
|
}
|
|
10075
|
+
function isUnpatchableVerticalMergeContinuationSpan(span) {
|
|
10076
|
+
return Boolean(
|
|
10077
|
+
span?.insideVerticalMergeContinuation && span.fromPm >= span.toPm
|
|
10078
|
+
);
|
|
10079
|
+
}
|
|
10080
|
+
function resolveTopLevelMembershipPatchSpan(input) {
|
|
10081
|
+
const previousBlocks = input.previousSurface.blocks;
|
|
10082
|
+
const nextBlocks = input.nextSurface.blocks;
|
|
10083
|
+
let prefix = 0;
|
|
10084
|
+
while (prefix < previousBlocks.length && prefix < nextBlocks.length && sameTopLevelBlockIdentity(previousBlocks[prefix], nextBlocks[prefix])) {
|
|
10085
|
+
prefix += 1;
|
|
10086
|
+
}
|
|
10087
|
+
let suffix = 0;
|
|
10088
|
+
while (suffix < previousBlocks.length - prefix && suffix < nextBlocks.length - prefix && sameTopLevelBlockIdentity(
|
|
10089
|
+
previousBlocks[previousBlocks.length - 1 - suffix],
|
|
10090
|
+
nextBlocks[nextBlocks.length - 1 - suffix]
|
|
10091
|
+
)) {
|
|
10092
|
+
suffix += 1;
|
|
10093
|
+
}
|
|
10094
|
+
let fromBlockIndex = prefix;
|
|
10095
|
+
let toBlockIndex = previousBlocks.length - suffix;
|
|
10096
|
+
let nextFromBlockIndex = prefix;
|
|
10097
|
+
let nextToBlockIndex = nextBlocks.length - suffix;
|
|
10098
|
+
if (fromBlockIndex === toBlockIndex && nextFromBlockIndex === nextToBlockIndex) {
|
|
10099
|
+
if (previousBlocks.length === 0 && nextBlocks.length === 0) return null;
|
|
10100
|
+
fromBlockIndex = 0;
|
|
10101
|
+
toBlockIndex = previousBlocks.length;
|
|
10102
|
+
nextFromBlockIndex = 0;
|
|
10103
|
+
nextToBlockIndex = nextBlocks.length;
|
|
10104
|
+
}
|
|
10105
|
+
return {
|
|
10106
|
+
pageIds: [...input.pageIds],
|
|
10107
|
+
fromBlockIndex,
|
|
10108
|
+
toBlockIndex,
|
|
10109
|
+
nextFromBlockIndex,
|
|
10110
|
+
nextToBlockIndex,
|
|
10111
|
+
replacedBlockCount: Math.max(
|
|
10112
|
+
toBlockIndex - fromBlockIndex,
|
|
10113
|
+
nextToBlockIndex - nextFromBlockIndex
|
|
10114
|
+
)
|
|
10115
|
+
};
|
|
10116
|
+
}
|
|
10117
|
+
function sameTopLevelBlockIdentity(left, right) {
|
|
10118
|
+
return Boolean(left && right && left.blockId === right.blockId && left.kind === right.kind);
|
|
10119
|
+
}
|
|
10120
|
+
function resolveTopLevelFragmentPatchSpans(input) {
|
|
10121
|
+
const changedIds = uniqueStableFragmentIds(input.changedFragmentIds);
|
|
10122
|
+
if (changedIds.length !== input.changedFragmentIds.length || changedIds.length === 0) {
|
|
10123
|
+
return null;
|
|
10124
|
+
}
|
|
10125
|
+
const spans = [];
|
|
10126
|
+
for (const blockId of changedIds) {
|
|
10127
|
+
const previousIndex = findTopLevelBlockIndexById(
|
|
10128
|
+
input.previousSurface.blocks,
|
|
10129
|
+
input.previousRange,
|
|
10130
|
+
blockId
|
|
10131
|
+
);
|
|
10132
|
+
const nextIndex = findTopLevelBlockIndexById(
|
|
10133
|
+
input.nextSurface.blocks,
|
|
10134
|
+
input.nextRange,
|
|
10135
|
+
blockId
|
|
10136
|
+
);
|
|
10137
|
+
if (previousIndex === null || nextIndex === null) {
|
|
10138
|
+
return null;
|
|
10139
|
+
}
|
|
10140
|
+
const previousBlock = input.previousSurface.blocks[previousIndex];
|
|
10141
|
+
const nextBlock = input.nextSurface.blocks[nextIndex];
|
|
10142
|
+
if (!previousBlock || !nextBlock || previousBlock.kind !== nextBlock.kind) {
|
|
10143
|
+
return null;
|
|
10144
|
+
}
|
|
10145
|
+
spans.push({
|
|
10146
|
+
pageIds: [input.pageId],
|
|
10147
|
+
fromBlockIndex: previousIndex,
|
|
10148
|
+
toBlockIndex: previousIndex + 1,
|
|
10149
|
+
nextFromBlockIndex: nextIndex,
|
|
10150
|
+
nextToBlockIndex: nextIndex + 1,
|
|
10151
|
+
replacedBlockCount: 1
|
|
10152
|
+
});
|
|
10153
|
+
}
|
|
10154
|
+
return spans;
|
|
10155
|
+
}
|
|
10156
|
+
function uniqueStableFragmentIds(ids) {
|
|
10157
|
+
const result = [];
|
|
10158
|
+
const seen = /* @__PURE__ */ new Set();
|
|
10159
|
+
for (const id of ids) {
|
|
10160
|
+
if (id === "<added>" || id === "<removed>") continue;
|
|
10161
|
+
if (seen.has(id)) continue;
|
|
10162
|
+
seen.add(id);
|
|
10163
|
+
result.push(id);
|
|
10164
|
+
}
|
|
10165
|
+
return result;
|
|
10166
|
+
}
|
|
10167
|
+
function findTopLevelBlockIndexById(blocks, range, blockId) {
|
|
10168
|
+
for (let index = range.first; index <= range.last; index += 1) {
|
|
10169
|
+
if (blocks[index]?.blockId === blockId) return index;
|
|
10170
|
+
}
|
|
10171
|
+
return null;
|
|
10172
|
+
}
|
|
9890
10173
|
function findNestedBlockSpanById(blocks, doc, blockId) {
|
|
9891
10174
|
return findBlockSpanByIdInContainer({
|
|
9892
10175
|
blocks,
|
|
@@ -9901,6 +10184,7 @@ function findBlockSpanByIdInContainer(input) {
|
|
|
9901
10184
|
let cursor = input.contentStartPm;
|
|
9902
10185
|
for (let blockIndex = 0; blockIndex < input.blocks.length; blockIndex += 1) {
|
|
9903
10186
|
const block = input.blocks[blockIndex];
|
|
10187
|
+
if (blockIndex >= input.containerNode.childCount) return null;
|
|
9904
10188
|
const childNode = input.containerNode.child(blockIndex);
|
|
9905
10189
|
const fromPm = cursor;
|
|
9906
10190
|
const toPm = fromPm + childNode.nodeSize;
|
|
@@ -9940,10 +10224,12 @@ function findBlockSpanByIdInTable(input) {
|
|
|
9940
10224
|
let rowCursor = input.tableStartPm + 1;
|
|
9941
10225
|
for (let rowIndex = 0; rowIndex < input.table.rows.length; rowIndex += 1) {
|
|
9942
10226
|
const row = input.table.rows[rowIndex];
|
|
10227
|
+
if (rowIndex >= input.tableNode.childCount) return null;
|
|
9943
10228
|
const rowNode = input.tableNode.child(rowIndex);
|
|
9944
10229
|
let cellCursor = rowCursor + 1;
|
|
9945
10230
|
for (let cellIndex = 0; cellIndex < row.cells.length; cellIndex += 1) {
|
|
9946
10231
|
const cell = row.cells[cellIndex];
|
|
10232
|
+
if (cellIndex >= rowNode.childCount) return null;
|
|
9947
10233
|
const cellNode = rowNode.child(cellIndex);
|
|
9948
10234
|
const found = findBlockSpanByIdInContainer({
|
|
9949
10235
|
blocks: cell.content,
|
|
@@ -13518,8 +13804,17 @@ function pageIdsFromRenderFrame(frame) {
|
|
|
13518
13804
|
return frame.pages.map((page) => page.page.pageId);
|
|
13519
13805
|
}
|
|
13520
13806
|
function resolvePageBodyPatchForMountedState(input) {
|
|
13521
|
-
if (!input.previousSurface
|
|
13522
|
-
return { status: "fallback" };
|
|
13807
|
+
if (!input.previousSurface) {
|
|
13808
|
+
return { status: "fallback", reason: "previous-surface-missing" };
|
|
13809
|
+
}
|
|
13810
|
+
if (!input.previousFrame) {
|
|
13811
|
+
return { status: "fallback", reason: "previous-frame-missing" };
|
|
13812
|
+
}
|
|
13813
|
+
if (!input.nextFrame) {
|
|
13814
|
+
return { status: "fallback", reason: "next-frame-missing" };
|
|
13815
|
+
}
|
|
13816
|
+
if (input.previousPlugins !== input.plugins) {
|
|
13817
|
+
return { status: "fallback", reason: "plugin-set-changed" };
|
|
13523
13818
|
}
|
|
13524
13819
|
const patchPlan = createPagePatchPlan(input.previousFrame, input.nextFrame, void 0, {
|
|
13525
13820
|
mountedPageIds: pageIdsFromRenderFrame(input.previousFrame),
|
|
@@ -13720,8 +14015,12 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
|
|
|
13720
14015
|
onPasteFragment: (meta) => {
|
|
13721
14016
|
props.onPasteFragment?.(meta);
|
|
13722
14017
|
},
|
|
13723
|
-
onPastePlainTextFragment: (fragment) => {
|
|
13724
|
-
props.onPasteFragment?.({
|
|
14018
|
+
onPastePlainTextFragment: (fragment, context) => {
|
|
14019
|
+
props.onPasteFragment?.({
|
|
14020
|
+
fragment,
|
|
14021
|
+
source: "plain-text",
|
|
14022
|
+
...context?.editableTarget ? { editableTarget: context.editableTarget } : {}
|
|
14023
|
+
});
|
|
13725
14024
|
},
|
|
13726
14025
|
shouldPastePlainTextAsFragment: () => snapshotRef.current.documentMode !== "suggesting",
|
|
13727
14026
|
onPasteImage: (meta) => {
|
|
@@ -13863,7 +14162,7 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
|
|
|
13863
14162
|
onBlockedInput: (command, message) => callbacksRef.current?.onBlockedInput?.(command, message),
|
|
13864
14163
|
onPasteApplied: (meta) => callbacksRef.current?.onPasteApplied?.(meta),
|
|
13865
14164
|
onPasteFragment: (meta) => callbacksRef.current?.onPasteFragment?.(meta),
|
|
13866
|
-
onPastePlainTextFragment: (fragment) => callbacksRef.current?.onPastePlainTextFragment?.(fragment),
|
|
14165
|
+
onPastePlainTextFragment: (fragment, context) => callbacksRef.current?.onPastePlainTextFragment?.(fragment, context),
|
|
13867
14166
|
shouldPastePlainTextAsFragment: () => callbacksRef.current?.shouldPastePlainTextAsFragment?.() ?? true,
|
|
13868
14167
|
onPasteImage: (meta) => callbacksRef.current?.onPasteImage?.(meta),
|
|
13869
14168
|
onDropFragment: (meta) => callbacksRef.current?.onDropFragment?.(meta),
|
|
@@ -14065,6 +14364,7 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
|
|
|
14065
14364
|
useEffect4(() => {
|
|
14066
14365
|
if (!mountRef.current || !surface) return;
|
|
14067
14366
|
if (viewRef.current && documentBuildKeyRef.current === documentBuildKey) {
|
|
14367
|
+
incrementInvalidationCounter("pm.rebuild.skip.documentBuildKey");
|
|
14068
14368
|
pendingRebuildScrollAnchorRef.current = null;
|
|
14069
14369
|
return;
|
|
14070
14370
|
}
|
|
@@ -14073,6 +14373,7 @@ var TwProseMirrorSurface = forwardRef(function TwProseMirrorSurface2(props, ref)
|
|
|
14073
14373
|
positionMapRef.current = buildPositionMap(surface);
|
|
14074
14374
|
documentBuildKeyRef.current = documentBuildKey;
|
|
14075
14375
|
applyDecorationProps(viewRef.current, positionMapRef.current);
|
|
14376
|
+
incrementInvalidationCounter("pm.rebuild.skip.equivalentAck");
|
|
14076
14377
|
equivalentAckLedgerRef.current.delete(snapshot.revisionToken);
|
|
14077
14378
|
localEquivalentOpsRef.current = [];
|
|
14078
14379
|
pendingRebuildScrollAnchorRef.current = null;
|
|
@@ -15639,6 +15940,15 @@ function deriveShellPinnedSurfaces(chromePreset, chromeOptions) {
|
|
|
15639
15940
|
import { Fragment as Fragment4, jsx as jsx16, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
15640
15941
|
var EMU_PER_CSS_PX = 9525;
|
|
15641
15942
|
var nextObjectDragSessionId = 0;
|
|
15943
|
+
function preferListTextEditableTarget(primary, fallback) {
|
|
15944
|
+
if (primary?.listAddress?.operationScope === "list-text") {
|
|
15945
|
+
return primary;
|
|
15946
|
+
}
|
|
15947
|
+
if (fallback?.listAddress?.operationScope === "list-text") {
|
|
15948
|
+
return fallback;
|
|
15949
|
+
}
|
|
15950
|
+
return primary ?? fallback;
|
|
15951
|
+
}
|
|
15642
15952
|
function createMountedObjectDragSession(runtime, input) {
|
|
15643
15953
|
nextObjectDragSessionId += 1;
|
|
15644
15954
|
const sessionId = `object-drag-${nextObjectDragSessionId}`;
|
|
@@ -17911,7 +18221,10 @@ var WordReviewEditor = forwardRef3(
|
|
|
17911
18221
|
// auto-bracketing in insertFragment + our explicit startAction around
|
|
17912
18222
|
// the delete, so the undo history sees a single atomic action.
|
|
17913
18223
|
onDropFragment: (meta) => {
|
|
17914
|
-
const dropEditableTarget =
|
|
18224
|
+
const dropEditableTarget = preferListTextEditableTarget(
|
|
18225
|
+
meta.editableTarget,
|
|
18226
|
+
activeRuntime.getRenderSnapshot().selection.editableTarget
|
|
18227
|
+
);
|
|
17915
18228
|
if (meta.effect === "move" && meta.sourceRange) {
|
|
17916
18229
|
activeRuntime.startAction("drag-move");
|
|
17917
18230
|
try {
|
|
@@ -17922,7 +18235,10 @@ var WordReviewEditor = forwardRef3(
|
|
|
17922
18235
|
assoc: { start: -1, end: 1 }
|
|
17923
18236
|
});
|
|
17924
18237
|
const currentEditableTarget = activeRuntime.getRenderSnapshot().selection.editableTarget;
|
|
17925
|
-
const editableTarget =
|
|
18238
|
+
const editableTarget = preferListTextEditableTarget(
|
|
18239
|
+
currentEditableTarget?.targetKey === dropEditableTarget?.targetKey ? currentEditableTarget : void 0,
|
|
18240
|
+
dropEditableTarget
|
|
18241
|
+
);
|
|
17926
18242
|
activeRuntime.insertFragment(
|
|
17927
18243
|
meta.fragment,
|
|
17928
18244
|
void 0,
|
|
@@ -17961,7 +18277,10 @@ var WordReviewEditor = forwardRef3(
|
|
|
17961
18277
|
// insertFragment auto-bracket (R.5.a Phase 2) makes the paste a
|
|
17962
18278
|
// single-undo action.
|
|
17963
18279
|
onPasteFragment: (meta) => {
|
|
17964
|
-
const editableTarget =
|
|
18280
|
+
const editableTarget = preferListTextEditableTarget(
|
|
18281
|
+
meta.editableTarget,
|
|
18282
|
+
activeRuntime.getRenderSnapshot().selection.editableTarget
|
|
18283
|
+
);
|
|
17965
18284
|
activeRuntime.insertFragment(
|
|
17966
18285
|
meta.fragment,
|
|
17967
18286
|
void 0,
|
|
@@ -18314,6 +18633,12 @@ var WordReviewEditor = forwardRef3(
|
|
|
18314
18633
|
onDeleteTable: commands.onDeleteTable,
|
|
18315
18634
|
onMergeCells: commands.onMergeCells,
|
|
18316
18635
|
onSplitCell: commands.onSplitCell,
|
|
18636
|
+
onUpdateFields: () => {
|
|
18637
|
+
activeRuntime.updateFields();
|
|
18638
|
+
},
|
|
18639
|
+
onUpdateTableOfContents: () => {
|
|
18640
|
+
activeRuntime.updateTableOfContents();
|
|
18641
|
+
},
|
|
18317
18642
|
onAskAgentForSelection: () => {
|
|
18318
18643
|
const { selection } = snapshot;
|
|
18319
18644
|
onEventRef.current?.({
|