@beyondwork/docx-react-component 1.0.125 → 1.0.127
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.d.cts +1 -1
- package/dist/api/public-types.d.ts +1 -1
- package/dist/api/v3.cjs +84 -25
- package/dist/api/v3.d.cts +2 -2
- package/dist/api/v3.d.ts +2 -2
- package/dist/api/v3.js +2 -2
- package/dist/{chunk-JN444Z5S.js → chunk-46KNRA4C.js} +34 -24
- package/dist/{chunk-4G3OS2H6.js → chunk-LZVBNDGU.js} +3 -0
- package/dist/{chunk-QT3LX4FA.js → chunk-PUMZWE2D.js} +311 -39
- package/dist/{chunk-OHTK7F3F.js → chunk-XRACP43Q.js} +51 -2
- 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.d.cts +1 -1
- package/dist/core/commands/image-commands.d.ts +1 -1
- 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.d.cts +1 -1
- package/dist/core/commands/table-structure-commands.d.ts +1 -1
- package/dist/core/commands/text-commands.cjs +3 -0
- package/dist/core/commands/text-commands.d.cts +2 -1
- package/dist/core/commands/text-commands.d.ts +2 -1
- package/dist/core/commands/text-commands.js +1 -1
- 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 +424 -72
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +27 -8
- package/dist/io/docx-session.d.cts +3 -3
- package/dist/io/docx-session.d.ts +3 -3
- package/dist/{loader-B1MxvbeV.d.ts → loader-CFICtb9m.d.ts} +2 -2
- package/dist/{loader-CJXsswcd.d.cts → loader-DveZOVuC.d.cts} +2 -2
- package/dist/{public-types-BEGhv2YR.d.ts → public-types-Cgl3efbO.d.ts} +51 -6
- package/dist/{public-types-DrhlQ5Zy.d.cts → public-types-beSYFJRR.d.cts} +51 -6
- package/dist/public-types.d.cts +1 -1
- package/dist/public-types.d.ts +1 -1
- package/dist/runtime/collab.d.cts +2 -2
- package/dist/runtime/collab.d.ts +2 -2
- package/dist/runtime/document-runtime.cjs +315 -38
- package/dist/runtime/document-runtime.d.cts +1 -1
- package/dist/runtime/document-runtime.d.ts +1 -1
- package/dist/runtime/document-runtime.js +3 -3
- package/dist/{session-Bp3zqnkS.d.cts → session-B7u82EJF.d.cts} +2 -2
- package/dist/{session-xMOU_NtL.d.ts → session-BWMJ9jm4.d.ts} +2 -2
- package/dist/session.d.cts +4 -4
- package/dist/session.d.ts +4 -4
- package/dist/tailwind.d.cts +1 -1
- package/dist/tailwind.d.ts +1 -1
- package/dist/{types-DDPxEygX.d.cts → types-BQjdVZsh.d.cts} +1 -1
- package/dist/{types-BFT8536T.d.ts → types-DvvmS5A7.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.d.cts +2 -2
- package/dist/ui-tailwind.d.ts +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -22001,19 +22001,19 @@ function clamp(value, min, max) {
|
|
|
22001
22001
|
}
|
|
22002
22002
|
|
|
22003
22003
|
// src/core/commands/list-commands.ts
|
|
22004
|
-
function toggleNumberedList(document2, paragraphIndexes, context) {
|
|
22005
|
-
return toggleListKind(document2, paragraphIndexes, "numbered", context);
|
|
22004
|
+
function toggleNumberedList(document2, paragraphIndexes, context, options = {}) {
|
|
22005
|
+
return toggleListKind(document2, paragraphIndexes, "numbered", context, options);
|
|
22006
22006
|
}
|
|
22007
|
-
function toggleBulletedList(document2, paragraphIndexes, context) {
|
|
22008
|
-
return toggleListKind(document2, paragraphIndexes, "bulleted", context);
|
|
22007
|
+
function toggleBulletedList(document2, paragraphIndexes, context, options = {}) {
|
|
22008
|
+
return toggleListKind(document2, paragraphIndexes, "bulleted", context, options);
|
|
22009
22009
|
}
|
|
22010
|
-
function indentListItems(document2, paragraphIndexes, context) {
|
|
22011
|
-
return adjustListLevels(document2, paragraphIndexes, 1, context);
|
|
22010
|
+
function indentListItems(document2, paragraphIndexes, context, options = {}) {
|
|
22011
|
+
return adjustListLevels(document2, paragraphIndexes, 1, context, options);
|
|
22012
22012
|
}
|
|
22013
|
-
function outdentListItems(document2, paragraphIndexes, context) {
|
|
22014
|
-
return adjustListLevels(document2, paragraphIndexes, -1, context);
|
|
22013
|
+
function outdentListItems(document2, paragraphIndexes, context, options = {}) {
|
|
22014
|
+
return adjustListLevels(document2, paragraphIndexes, -1, context, options);
|
|
22015
22015
|
}
|
|
22016
|
-
function splitListParagraph(document2, paragraphIndex, paragraphIsEmpty, context) {
|
|
22016
|
+
function splitListParagraph(document2, paragraphIndex, paragraphIsEmpty, context, options = {}) {
|
|
22017
22017
|
if (!paragraphIsEmpty) {
|
|
22018
22018
|
return {
|
|
22019
22019
|
document: document2,
|
|
@@ -22023,7 +22023,30 @@ function splitListParagraph(document2, paragraphIndex, paragraphIsEmpty, context
|
|
|
22023
22023
|
}
|
|
22024
22024
|
const working = cloneEnvelope(document2, context.timestamp);
|
|
22025
22025
|
const paragraphs = captureEditableParagraphs(working);
|
|
22026
|
-
const
|
|
22026
|
+
const resolved = resolveListCommandParagraphIndexes(
|
|
22027
|
+
working,
|
|
22028
|
+
paragraphs,
|
|
22029
|
+
[paragraphIndex],
|
|
22030
|
+
context,
|
|
22031
|
+
normalizeListCommandTargets(options)
|
|
22032
|
+
);
|
|
22033
|
+
if (resolved.blockedReason) {
|
|
22034
|
+
return {
|
|
22035
|
+
document: working,
|
|
22036
|
+
affectedParagraphIndexes: [],
|
|
22037
|
+
action: "blocked",
|
|
22038
|
+
blockedReason: resolved.blockedReason
|
|
22039
|
+
};
|
|
22040
|
+
}
|
|
22041
|
+
const resolvedParagraphIndex = resolved.paragraphIndexes[0];
|
|
22042
|
+
if (resolvedParagraphIndex === void 0) {
|
|
22043
|
+
return {
|
|
22044
|
+
document: working,
|
|
22045
|
+
affectedParagraphIndexes: [],
|
|
22046
|
+
action: "split"
|
|
22047
|
+
};
|
|
22048
|
+
}
|
|
22049
|
+
const target = paragraphs[resolvedParagraphIndex];
|
|
22027
22050
|
if (!target?.numbering) {
|
|
22028
22051
|
return {
|
|
22029
22052
|
document: working,
|
|
@@ -22038,21 +22061,44 @@ function splitListParagraph(document2, paragraphIndex, paragraphIsEmpty, context
|
|
|
22038
22061
|
};
|
|
22039
22062
|
return {
|
|
22040
22063
|
document: working,
|
|
22041
|
-
affectedParagraphIndexes: [
|
|
22064
|
+
affectedParagraphIndexes: [resolvedParagraphIndex],
|
|
22042
22065
|
action: "outdented"
|
|
22043
22066
|
};
|
|
22044
22067
|
}
|
|
22045
22068
|
delete target.numbering;
|
|
22046
22069
|
return {
|
|
22047
22070
|
document: working,
|
|
22048
|
-
affectedParagraphIndexes: [
|
|
22071
|
+
affectedParagraphIndexes: [resolvedParagraphIndex],
|
|
22049
22072
|
action: "removed"
|
|
22050
22073
|
};
|
|
22051
22074
|
}
|
|
22052
|
-
function backspaceAtListStart(document2, paragraphIndex, context) {
|
|
22075
|
+
function backspaceAtListStart(document2, paragraphIndex, context, options = {}) {
|
|
22053
22076
|
const working = cloneEnvelope(document2, context.timestamp);
|
|
22054
22077
|
const paragraphs = captureEditableParagraphs(working);
|
|
22055
|
-
const
|
|
22078
|
+
const resolved = resolveListCommandParagraphIndexes(
|
|
22079
|
+
working,
|
|
22080
|
+
paragraphs,
|
|
22081
|
+
[paragraphIndex],
|
|
22082
|
+
context,
|
|
22083
|
+
normalizeListCommandTargets(options)
|
|
22084
|
+
);
|
|
22085
|
+
if (resolved.blockedReason) {
|
|
22086
|
+
return {
|
|
22087
|
+
document: working,
|
|
22088
|
+
affectedParagraphIndexes: [],
|
|
22089
|
+
handled: true,
|
|
22090
|
+
blockedReason: resolved.blockedReason
|
|
22091
|
+
};
|
|
22092
|
+
}
|
|
22093
|
+
const resolvedParagraphIndex = resolved.paragraphIndexes[0];
|
|
22094
|
+
if (resolvedParagraphIndex === void 0) {
|
|
22095
|
+
return {
|
|
22096
|
+
document: working,
|
|
22097
|
+
affectedParagraphIndexes: [],
|
|
22098
|
+
handled: false
|
|
22099
|
+
};
|
|
22100
|
+
}
|
|
22101
|
+
const target = paragraphs[resolvedParagraphIndex];
|
|
22056
22102
|
if (!target?.numbering) {
|
|
22057
22103
|
return {
|
|
22058
22104
|
document: working,
|
|
@@ -22070,14 +22116,35 @@ function backspaceAtListStart(document2, paragraphIndex, context) {
|
|
|
22070
22116
|
}
|
|
22071
22117
|
return {
|
|
22072
22118
|
document: working,
|
|
22073
|
-
affectedParagraphIndexes: [
|
|
22119
|
+
affectedParagraphIndexes: [resolvedParagraphIndex],
|
|
22074
22120
|
handled: true
|
|
22075
22121
|
};
|
|
22076
22122
|
}
|
|
22077
|
-
function restartNumbering(document2, paragraphIndex, context, startAt = 1) {
|
|
22123
|
+
function restartNumbering(document2, paragraphIndex, context, startAt = 1, options = {}) {
|
|
22078
22124
|
const working = cloneEnvelope(document2, context.timestamp);
|
|
22079
22125
|
const paragraphs = captureEditableParagraphs(working);
|
|
22080
|
-
const
|
|
22126
|
+
const resolved = resolveListCommandParagraphIndexes(
|
|
22127
|
+
working,
|
|
22128
|
+
paragraphs,
|
|
22129
|
+
[paragraphIndex],
|
|
22130
|
+
context,
|
|
22131
|
+
normalizeListCommandTargets(options)
|
|
22132
|
+
);
|
|
22133
|
+
if (resolved.blockedReason) {
|
|
22134
|
+
return {
|
|
22135
|
+
document: working,
|
|
22136
|
+
affectedParagraphIndexes: [],
|
|
22137
|
+
blockedReason: resolved.blockedReason
|
|
22138
|
+
};
|
|
22139
|
+
}
|
|
22140
|
+
const resolvedParagraphIndex = resolved.paragraphIndexes[0];
|
|
22141
|
+
if (resolvedParagraphIndex === void 0) {
|
|
22142
|
+
return {
|
|
22143
|
+
document: working,
|
|
22144
|
+
affectedParagraphIndexes: []
|
|
22145
|
+
};
|
|
22146
|
+
}
|
|
22147
|
+
const target = paragraphs[resolvedParagraphIndex];
|
|
22081
22148
|
if (!target?.numbering) {
|
|
22082
22149
|
return {
|
|
22083
22150
|
document: working,
|
|
@@ -22102,7 +22169,7 @@ function restartNumbering(document2, paragraphIndex, context, startAt = 1) {
|
|
|
22102
22169
|
})
|
|
22103
22170
|
};
|
|
22104
22171
|
const affectedParagraphIndexes = [];
|
|
22105
|
-
for (let index =
|
|
22172
|
+
for (let index = resolvedParagraphIndex; index < paragraphs.length; index += 1) {
|
|
22106
22173
|
const paragraph = paragraphs[index];
|
|
22107
22174
|
if (!paragraph?.numbering) {
|
|
22108
22175
|
break;
|
|
@@ -22123,10 +22190,31 @@ function restartNumbering(document2, paragraphIndex, context, startAt = 1) {
|
|
|
22123
22190
|
createdNumberingInstanceId: numberingInstanceId
|
|
22124
22191
|
};
|
|
22125
22192
|
}
|
|
22126
|
-
function continueNumbering(document2, paragraphIndex, context) {
|
|
22193
|
+
function continueNumbering(document2, paragraphIndex, context, options = {}) {
|
|
22127
22194
|
const working = cloneEnvelope(document2, context.timestamp);
|
|
22128
22195
|
const paragraphs = captureEditableParagraphs(working);
|
|
22129
|
-
const
|
|
22196
|
+
const resolved = resolveListCommandParagraphIndexes(
|
|
22197
|
+
working,
|
|
22198
|
+
paragraphs,
|
|
22199
|
+
[paragraphIndex],
|
|
22200
|
+
context,
|
|
22201
|
+
normalizeListCommandTargets(options)
|
|
22202
|
+
);
|
|
22203
|
+
if (resolved.blockedReason) {
|
|
22204
|
+
return {
|
|
22205
|
+
document: working,
|
|
22206
|
+
affectedParagraphIndexes: [],
|
|
22207
|
+
blockedReason: resolved.blockedReason
|
|
22208
|
+
};
|
|
22209
|
+
}
|
|
22210
|
+
const resolvedParagraphIndex = resolved.paragraphIndexes[0];
|
|
22211
|
+
if (resolvedParagraphIndex === void 0) {
|
|
22212
|
+
return {
|
|
22213
|
+
document: working,
|
|
22214
|
+
affectedParagraphIndexes: []
|
|
22215
|
+
};
|
|
22216
|
+
}
|
|
22217
|
+
const target = paragraphs[resolvedParagraphIndex];
|
|
22130
22218
|
if (!target?.numbering) {
|
|
22131
22219
|
return {
|
|
22132
22220
|
document: working,
|
|
@@ -22145,7 +22233,7 @@ function continueNumbering(document2, paragraphIndex, context) {
|
|
|
22145
22233
|
const compatibleInstanceId = findPreviousCompatibleInstance(
|
|
22146
22234
|
paragraphs,
|
|
22147
22235
|
catalog,
|
|
22148
|
-
|
|
22236
|
+
resolvedParagraphIndex,
|
|
22149
22237
|
currentKind
|
|
22150
22238
|
);
|
|
22151
22239
|
if (!compatibleInstanceId || compatibleInstanceId === currentInstanceId) {
|
|
@@ -22155,7 +22243,7 @@ function continueNumbering(document2, paragraphIndex, context) {
|
|
|
22155
22243
|
};
|
|
22156
22244
|
}
|
|
22157
22245
|
const affectedParagraphIndexes = [];
|
|
22158
|
-
for (let index =
|
|
22246
|
+
for (let index = resolvedParagraphIndex; index < paragraphs.length; index += 1) {
|
|
22159
22247
|
const paragraph = paragraphs[index];
|
|
22160
22248
|
if (!paragraph?.numbering) {
|
|
22161
22249
|
break;
|
|
@@ -22176,10 +22264,24 @@ function continueNumbering(document2, paragraphIndex, context) {
|
|
|
22176
22264
|
createdNumberingInstanceId: compatibleInstanceId
|
|
22177
22265
|
};
|
|
22178
22266
|
}
|
|
22179
|
-
function toggleListKind(document2, paragraphIndexes, kind, context) {
|
|
22267
|
+
function toggleListKind(document2, paragraphIndexes, kind, context, options) {
|
|
22180
22268
|
const working = cloneEnvelope(document2, context.timestamp);
|
|
22181
22269
|
const paragraphs = captureEditableParagraphs(working);
|
|
22182
|
-
const
|
|
22270
|
+
const resolved = resolveListCommandParagraphIndexes(
|
|
22271
|
+
working,
|
|
22272
|
+
paragraphs,
|
|
22273
|
+
paragraphIndexes,
|
|
22274
|
+
context,
|
|
22275
|
+
normalizeListCommandTargets(options)
|
|
22276
|
+
);
|
|
22277
|
+
if (resolved.blockedReason) {
|
|
22278
|
+
return {
|
|
22279
|
+
document: working,
|
|
22280
|
+
affectedParagraphIndexes: [],
|
|
22281
|
+
blockedReason: resolved.blockedReason
|
|
22282
|
+
};
|
|
22283
|
+
}
|
|
22284
|
+
const normalizedIndexes = resolved.paragraphIndexes;
|
|
22183
22285
|
if (normalizedIndexes.length === 0) {
|
|
22184
22286
|
return {
|
|
22185
22287
|
document: working,
|
|
@@ -22216,10 +22318,24 @@ function toggleListKind(document2, paragraphIndexes, kind, context) {
|
|
|
22216
22318
|
createdNumberingInstanceId: numberingInstanceId
|
|
22217
22319
|
};
|
|
22218
22320
|
}
|
|
22219
|
-
function adjustListLevels(document2, paragraphIndexes, delta, context) {
|
|
22321
|
+
function adjustListLevels(document2, paragraphIndexes, delta, context, options) {
|
|
22220
22322
|
const working = cloneEnvelope(document2, context.timestamp);
|
|
22221
22323
|
const paragraphs = captureEditableParagraphs(working);
|
|
22222
|
-
const
|
|
22324
|
+
const resolved = resolveListCommandParagraphIndexes(
|
|
22325
|
+
working,
|
|
22326
|
+
paragraphs,
|
|
22327
|
+
paragraphIndexes,
|
|
22328
|
+
context,
|
|
22329
|
+
normalizeListCommandTargets(options)
|
|
22330
|
+
);
|
|
22331
|
+
if (resolved.blockedReason) {
|
|
22332
|
+
return {
|
|
22333
|
+
document: working,
|
|
22334
|
+
affectedParagraphIndexes: [],
|
|
22335
|
+
blockedReason: resolved.blockedReason
|
|
22336
|
+
};
|
|
22337
|
+
}
|
|
22338
|
+
const affectedParagraphIndexes = resolved.paragraphIndexes.filter(
|
|
22223
22339
|
(index) => Boolean(paragraphs[index]?.numbering)
|
|
22224
22340
|
);
|
|
22225
22341
|
for (const index of affectedParagraphIndexes) {
|
|
@@ -22237,6 +22353,121 @@ function adjustListLevels(document2, paragraphIndexes, delta, context) {
|
|
|
22237
22353
|
affectedParagraphIndexes
|
|
22238
22354
|
};
|
|
22239
22355
|
}
|
|
22356
|
+
function normalizeListCommandTargets(options) {
|
|
22357
|
+
if (options.editableTargets !== void 0) return options.editableTargets;
|
|
22358
|
+
return options.editableTarget ? [options.editableTarget] : [];
|
|
22359
|
+
}
|
|
22360
|
+
function resolveListCommandParagraphIndexes(document2, paragraphs, paragraphIndexes, context, editableTargets) {
|
|
22361
|
+
if (editableTargets.length === 0) {
|
|
22362
|
+
return { paragraphIndexes: normalizeParagraphIndexes(paragraphs, paragraphIndexes) };
|
|
22363
|
+
}
|
|
22364
|
+
const currentTargets = collectEditableTargetRefs(document2, context.editableTargetCache);
|
|
22365
|
+
const paragraphIndexByTargetKey = /* @__PURE__ */ new Map();
|
|
22366
|
+
let paragraphIndex = 0;
|
|
22367
|
+
for (const target of currentTargets) {
|
|
22368
|
+
if (!isParagraphTextTarget(target)) continue;
|
|
22369
|
+
if (!paragraphIndexByTargetKey.has(target.targetKey)) {
|
|
22370
|
+
paragraphIndexByTargetKey.set(target.targetKey, paragraphIndex);
|
|
22371
|
+
paragraphIndex += 1;
|
|
22372
|
+
}
|
|
22373
|
+
}
|
|
22374
|
+
const resolvedIndexes = [];
|
|
22375
|
+
for (const target of editableTargets) {
|
|
22376
|
+
const blockedReason = validateListCommandTarget(target, currentTargets, context);
|
|
22377
|
+
if (blockedReason) return { paragraphIndexes: [], blockedReason };
|
|
22378
|
+
const current = findCurrentListCommandTarget(target, currentTargets);
|
|
22379
|
+
if (!current) {
|
|
22380
|
+
return {
|
|
22381
|
+
paragraphIndexes: [],
|
|
22382
|
+
blockedReason: {
|
|
22383
|
+
code: "list_target_not_found",
|
|
22384
|
+
message: "List editable target no longer resolves in the current canonical document."
|
|
22385
|
+
}
|
|
22386
|
+
};
|
|
22387
|
+
}
|
|
22388
|
+
if (!sameResolvedListCommandTarget(target, current)) {
|
|
22389
|
+
return {
|
|
22390
|
+
paragraphIndexes: [],
|
|
22391
|
+
blockedReason: {
|
|
22392
|
+
code: "list_target_stale",
|
|
22393
|
+
message: "List editable target is stale for the current canonical document."
|
|
22394
|
+
}
|
|
22395
|
+
};
|
|
22396
|
+
}
|
|
22397
|
+
const currentIndex = paragraphIndexByTargetKey.get(current.targetKey);
|
|
22398
|
+
if (currentIndex === void 0) {
|
|
22399
|
+
return {
|
|
22400
|
+
paragraphIndexes: [],
|
|
22401
|
+
blockedReason: {
|
|
22402
|
+
code: "list_target_position_unavailable",
|
|
22403
|
+
message: "List editable target resolved but could not be mapped to a current paragraph."
|
|
22404
|
+
}
|
|
22405
|
+
};
|
|
22406
|
+
}
|
|
22407
|
+
resolvedIndexes.push(currentIndex);
|
|
22408
|
+
}
|
|
22409
|
+
return { paragraphIndexes: normalizeParagraphIndexes(paragraphs, resolvedIndexes) };
|
|
22410
|
+
}
|
|
22411
|
+
function validateListCommandTarget(target, currentTargets, context) {
|
|
22412
|
+
const shapeIssues = validateEditableTargetRef(target);
|
|
22413
|
+
if (shapeIssues.length > 0) {
|
|
22414
|
+
return {
|
|
22415
|
+
code: "list_target_malformed",
|
|
22416
|
+
message: `List editable target is malformed: ${shapeIssues[0]?.path ?? "$"}.`
|
|
22417
|
+
};
|
|
22418
|
+
}
|
|
22419
|
+
if (context.activeStoryKey !== void 0 && target.storyKey !== context.activeStoryKey) {
|
|
22420
|
+
return {
|
|
22421
|
+
code: "list_target_wrong_story",
|
|
22422
|
+
message: "List editable target does not belong to the active story."
|
|
22423
|
+
};
|
|
22424
|
+
}
|
|
22425
|
+
if (target.commandFamily !== "text-leaf" || target.listAddress === void 0) {
|
|
22426
|
+
return {
|
|
22427
|
+
code: "list_target_required",
|
|
22428
|
+
message: "List commands require a validated list item editable target."
|
|
22429
|
+
};
|
|
22430
|
+
}
|
|
22431
|
+
if (target.editability !== "editable" || target.posture.blockers.length > 0) {
|
|
22432
|
+
return {
|
|
22433
|
+
code: "list_target_non_editable",
|
|
22434
|
+
message: target.posture.blockers.length > 0 ? `List editable target is not editable: ${target.posture.blockers.join(", ")}.` : "List editable target is not editable."
|
|
22435
|
+
};
|
|
22436
|
+
}
|
|
22437
|
+
if (!findCurrentListCommandTarget(target, currentTargets)) {
|
|
22438
|
+
return {
|
|
22439
|
+
code: "list_target_not_found",
|
|
22440
|
+
message: "List editable target no longer resolves in the current canonical document."
|
|
22441
|
+
};
|
|
22442
|
+
}
|
|
22443
|
+
return void 0;
|
|
22444
|
+
}
|
|
22445
|
+
function findCurrentListCommandTarget(target, currentTargets) {
|
|
22446
|
+
return currentTargets.find(
|
|
22447
|
+
(candidate) => isParagraphTextTarget(candidate) && candidate.listAddress !== void 0 && (candidate.targetKey === target.targetKey || candidate.listAddress.addressKey === target.listAddress?.addressKey)
|
|
22448
|
+
);
|
|
22449
|
+
}
|
|
22450
|
+
function sameResolvedListCommandTarget(left, right) {
|
|
22451
|
+
return left.kind === right.kind && left.storyKey === right.storyKey && left.blockPath === right.blockPath && left.leafPath === right.leafPath && left.commandFamily === right.commandFamily && left.editability === right.editability && left.staleCheck.paragraphTextHash === right.staleCheck.paragraphTextHash && left.staleCheck.paragraphTextLength === right.staleCheck.paragraphTextLength && left.staleCheck.inlineCount === right.staleCheck.inlineCount && left.staleCheck.blockType === right.staleCheck.blockType && left.listAddress?.addressKey === right.listAddress?.addressKey && left.listAddress?.resolver?.staleHash === right.listAddress?.resolver?.staleHash && jsonStable(left.sourceRef) === jsonStable(right.sourceRef);
|
|
22452
|
+
}
|
|
22453
|
+
function isParagraphTextTarget(target) {
|
|
22454
|
+
return target.commandFamily === "text-leaf" && target.staleCheck.blockType === "paragraph" && target.leafPath.endsWith("/inline");
|
|
22455
|
+
}
|
|
22456
|
+
function jsonStable(value) {
|
|
22457
|
+
return JSON.stringify(sortJson(value));
|
|
22458
|
+
}
|
|
22459
|
+
function sortJson(value) {
|
|
22460
|
+
if (Array.isArray(value)) return value.map(sortJson);
|
|
22461
|
+
if (value && typeof value === "object") {
|
|
22462
|
+
const record = value;
|
|
22463
|
+
const sorted = {};
|
|
22464
|
+
for (const key of Object.keys(record).sort()) {
|
|
22465
|
+
sorted[key] = sortJson(record[key]);
|
|
22466
|
+
}
|
|
22467
|
+
return sorted;
|
|
22468
|
+
}
|
|
22469
|
+
return value;
|
|
22470
|
+
}
|
|
22240
22471
|
function ensureDefaultInstance(catalog, kind) {
|
|
22241
22472
|
const existing = Object.values(catalog.instances).find(
|
|
22242
22473
|
(instance) => getListKind(catalog, instance.numberingInstanceId) === kind
|
|
@@ -22402,7 +22633,8 @@ function applyListAwareTextCommand(context, command, deps) {
|
|
|
22402
22633
|
const result = indentListItems(
|
|
22403
22634
|
context.localDocument,
|
|
22404
22635
|
[paragraphContext.paragraphIndex],
|
|
22405
|
-
|
|
22636
|
+
listCommandContext(context),
|
|
22637
|
+
listCommandTargetOptions(context, paragraphContext)
|
|
22406
22638
|
);
|
|
22407
22639
|
return createListMutationResult(result, context.localSnapshot.selection, deps);
|
|
22408
22640
|
}
|
|
@@ -22410,7 +22642,8 @@ function applyListAwareTextCommand(context, command, deps) {
|
|
|
22410
22642
|
const result = outdentListItems(
|
|
22411
22643
|
context.localDocument,
|
|
22412
22644
|
[paragraphContext.paragraphIndex],
|
|
22413
|
-
|
|
22645
|
+
listCommandContext(context),
|
|
22646
|
+
listCommandTargetOptions(context, paragraphContext)
|
|
22414
22647
|
);
|
|
22415
22648
|
return createListMutationResult(result, context.localSnapshot.selection, deps);
|
|
22416
22649
|
}
|
|
@@ -22421,7 +22654,8 @@ function applyListAwareTextCommand(context, command, deps) {
|
|
|
22421
22654
|
const result = backspaceAtListStart(
|
|
22422
22655
|
context.localDocument,
|
|
22423
22656
|
paragraphContext.paragraphIndex,
|
|
22424
|
-
|
|
22657
|
+
listCommandContext(context),
|
|
22658
|
+
listCommandTargetOptions(context, paragraphContext)
|
|
22425
22659
|
);
|
|
22426
22660
|
return result.handled ? createListMutationResult(result, context.localSnapshot.selection, deps) : null;
|
|
22427
22661
|
}
|
|
@@ -22433,14 +22667,30 @@ function applyListAwareTextCommand(context, command, deps) {
|
|
|
22433
22667
|
context.localDocument,
|
|
22434
22668
|
paragraphContext.paragraphIndex,
|
|
22435
22669
|
true,
|
|
22436
|
-
|
|
22670
|
+
listCommandContext(context),
|
|
22671
|
+
listCommandTargetOptions(context, paragraphContext)
|
|
22437
22672
|
);
|
|
22673
|
+
if (result.blockedReason) {
|
|
22674
|
+
return createListMutationResult(result, context.localSnapshot.selection, deps);
|
|
22675
|
+
}
|
|
22438
22676
|
return result.action === "split" ? null : createListMutationResult(result, context.localSnapshot.selection, deps);
|
|
22439
22677
|
}
|
|
22440
22678
|
default:
|
|
22441
22679
|
return null;
|
|
22442
22680
|
}
|
|
22443
22681
|
}
|
|
22682
|
+
function listCommandContext(context) {
|
|
22683
|
+
return {
|
|
22684
|
+
timestamp: context.timestamp,
|
|
22685
|
+
...context.activeStory.kind === "main" ? { activeStoryKey: "main" } : {}
|
|
22686
|
+
};
|
|
22687
|
+
}
|
|
22688
|
+
function listCommandTargetOptions(context, paragraphContext) {
|
|
22689
|
+
if (context.activeStory.kind !== "main" || !paragraphContext.paragraph.editableTarget) {
|
|
22690
|
+
return {};
|
|
22691
|
+
}
|
|
22692
|
+
return { editableTargets: [paragraphContext.paragraph.editableTarget] };
|
|
22693
|
+
}
|
|
22444
22694
|
function createListMutationResult(result, selection, deps) {
|
|
22445
22695
|
return {
|
|
22446
22696
|
changed: result.affectedParagraphIndexes.length > 0,
|
|
@@ -27824,6 +28074,9 @@ function splitParagraph(document2, selection, context) {
|
|
|
27824
28074
|
if (scope?.kind !== "top-level") {
|
|
27825
28075
|
return result;
|
|
27826
28076
|
}
|
|
28077
|
+
if (context.preserveNumberingOnSplit && scope.paragraph.numbering) {
|
|
28078
|
+
return result;
|
|
28079
|
+
}
|
|
27827
28080
|
const originalStyleId = scope.paragraph.styleId;
|
|
27828
28081
|
const nextStyleId = originalStyleId !== void 0 ? resolveNextStyle(originalStyleId, document2.styles) : void 0;
|
|
27829
28082
|
if (nextStyleId !== void 0) {
|
|
@@ -33882,6 +34135,13 @@ function withCommandTextTarget(context, command) {
|
|
|
33882
34135
|
textTarget: command.textTarget
|
|
33883
34136
|
};
|
|
33884
34137
|
}
|
|
34138
|
+
function listCommandContext2(context) {
|
|
34139
|
+
return {
|
|
34140
|
+
timestamp: context.timestamp,
|
|
34141
|
+
...context.activeStoryKey !== void 0 ? { activeStoryKey: context.activeStoryKey } : {},
|
|
34142
|
+
...context.editableTargetCache !== void 0 ? { editableTargetCache: context.editableTargetCache } : {}
|
|
34143
|
+
};
|
|
34144
|
+
}
|
|
33885
34145
|
function executeEditorCommand(state, command, context) {
|
|
33886
34146
|
switch (command.type) {
|
|
33887
34147
|
case "selection.set":
|
|
@@ -34523,7 +34783,17 @@ function executeEditorCommand(state, command, context) {
|
|
|
34523
34783
|
});
|
|
34524
34784
|
}
|
|
34525
34785
|
case "list.toggle": {
|
|
34526
|
-
const result = command.kind === "bulleted" ? toggleBulletedList(
|
|
34786
|
+
const result = command.kind === "bulleted" ? toggleBulletedList(
|
|
34787
|
+
state.document,
|
|
34788
|
+
command.paragraphIndexes ?? [],
|
|
34789
|
+
listCommandContext2(context),
|
|
34790
|
+
{ editableTargets: command.editableTargets }
|
|
34791
|
+
) : toggleNumberedList(
|
|
34792
|
+
state.document,
|
|
34793
|
+
command.paragraphIndexes ?? [],
|
|
34794
|
+
listCommandContext2(context),
|
|
34795
|
+
{ editableTargets: command.editableTargets }
|
|
34796
|
+
);
|
|
34527
34797
|
return buildDocumentReplaceTransaction(state, context, {
|
|
34528
34798
|
changed: result.affectedParagraphIndexes.length > 0,
|
|
34529
34799
|
document: result.document,
|
|
@@ -34531,7 +34801,12 @@ function executeEditorCommand(state, command, context) {
|
|
|
34531
34801
|
});
|
|
34532
34802
|
}
|
|
34533
34803
|
case "list.indent": {
|
|
34534
|
-
const result = indentListItems(
|
|
34804
|
+
const result = indentListItems(
|
|
34805
|
+
state.document,
|
|
34806
|
+
command.paragraphIndexes ?? [],
|
|
34807
|
+
listCommandContext2(context),
|
|
34808
|
+
{ editableTargets: command.editableTargets }
|
|
34809
|
+
);
|
|
34535
34810
|
return buildDocumentReplaceTransaction(state, context, {
|
|
34536
34811
|
changed: result.affectedParagraphIndexes.length > 0,
|
|
34537
34812
|
document: result.document,
|
|
@@ -34539,7 +34814,12 @@ function executeEditorCommand(state, command, context) {
|
|
|
34539
34814
|
});
|
|
34540
34815
|
}
|
|
34541
34816
|
case "list.outdent": {
|
|
34542
|
-
const result = outdentListItems(
|
|
34817
|
+
const result = outdentListItems(
|
|
34818
|
+
state.document,
|
|
34819
|
+
command.paragraphIndexes ?? [],
|
|
34820
|
+
listCommandContext2(context),
|
|
34821
|
+
{ editableTargets: command.editableTargets }
|
|
34822
|
+
);
|
|
34543
34823
|
return buildDocumentReplaceTransaction(state, context, {
|
|
34544
34824
|
changed: result.affectedParagraphIndexes.length > 0,
|
|
34545
34825
|
document: result.document,
|
|
@@ -34549,9 +34829,10 @@ function executeEditorCommand(state, command, context) {
|
|
|
34549
34829
|
case "list.restart-numbering": {
|
|
34550
34830
|
const result = restartNumbering(
|
|
34551
34831
|
state.document,
|
|
34552
|
-
command.paragraphIndex,
|
|
34553
|
-
|
|
34554
|
-
command.startAt
|
|
34832
|
+
command.paragraphIndex ?? -1,
|
|
34833
|
+
listCommandContext2(context),
|
|
34834
|
+
command.startAt,
|
|
34835
|
+
{ editableTarget: command.editableTarget }
|
|
34555
34836
|
);
|
|
34556
34837
|
return buildDocumentReplaceTransaction(state, context, {
|
|
34557
34838
|
changed: result.affectedParagraphIndexes.length > 0,
|
|
@@ -34562,8 +34843,9 @@ function executeEditorCommand(state, command, context) {
|
|
|
34562
34843
|
case "list.continue-numbering": {
|
|
34563
34844
|
const result = continueNumbering(
|
|
34564
34845
|
state.document,
|
|
34565
|
-
command.paragraphIndex,
|
|
34566
|
-
|
|
34846
|
+
command.paragraphIndex ?? -1,
|
|
34847
|
+
listCommandContext2(context),
|
|
34848
|
+
{ editableTarget: command.editableTarget }
|
|
34567
34849
|
);
|
|
34568
34850
|
return buildDocumentReplaceTransaction(state, context, {
|
|
34569
34851
|
changed: result.affectedParagraphIndexes.length > 0,
|
|
@@ -51813,7 +52095,52 @@ function compileReplacement(inputs) {
|
|
|
51813
52095
|
|
|
51814
52096
|
// src/runtime/scopes/replacement/apply.ts
|
|
51815
52097
|
function documentHash2(doc) {
|
|
51816
|
-
|
|
52098
|
+
let hash = 2166136261;
|
|
52099
|
+
const mix = (value) => {
|
|
52100
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
52101
|
+
hash ^= value.charCodeAt(i);
|
|
52102
|
+
hash = Math.imul(hash, 16777619);
|
|
52103
|
+
}
|
|
52104
|
+
};
|
|
52105
|
+
const visit = (value) => {
|
|
52106
|
+
if (value === null) {
|
|
52107
|
+
mix("null");
|
|
52108
|
+
return;
|
|
52109
|
+
}
|
|
52110
|
+
switch (typeof value) {
|
|
52111
|
+
case "string":
|
|
52112
|
+
case "number":
|
|
52113
|
+
case "boolean":
|
|
52114
|
+
case "bigint":
|
|
52115
|
+
mix(`${typeof value}:${String(value)}`);
|
|
52116
|
+
return;
|
|
52117
|
+
case "undefined":
|
|
52118
|
+
mix("undefined");
|
|
52119
|
+
return;
|
|
52120
|
+
case "object":
|
|
52121
|
+
if (Array.isArray(value)) {
|
|
52122
|
+
mix(`[${value.length}`);
|
|
52123
|
+
for (const item of value) visit(item);
|
|
52124
|
+
mix("]");
|
|
52125
|
+
return;
|
|
52126
|
+
}
|
|
52127
|
+
{
|
|
52128
|
+
const record = value;
|
|
52129
|
+
const keys = Object.keys(record).sort();
|
|
52130
|
+
mix(`{${keys.length}`);
|
|
52131
|
+
for (const key of keys) {
|
|
52132
|
+
mix(key);
|
|
52133
|
+
visit(record[key]);
|
|
52134
|
+
}
|
|
52135
|
+
mix("}");
|
|
52136
|
+
}
|
|
52137
|
+
return;
|
|
52138
|
+
default:
|
|
52139
|
+
mix(typeof value);
|
|
52140
|
+
}
|
|
52141
|
+
};
|
|
52142
|
+
visit(doc.content);
|
|
52143
|
+
return (hash >>> 0).toString(36).padStart(7, "0");
|
|
51817
52144
|
}
|
|
51818
52145
|
function compileScopeById(document2, overlay, scopeId) {
|
|
51819
52146
|
const paragraphIndexByBlockIndex = buildParagraphIndexMap(document2);
|
|
@@ -66716,7 +67043,8 @@ function rejectCommand(code, message) {
|
|
|
66716
67043
|
};
|
|
66717
67044
|
}
|
|
66718
67045
|
function sameResolvedTarget2(left, right) {
|
|
66719
|
-
|
|
67046
|
+
const textTargetLengthDrift = hasTextTargetLengthDrift(left, right);
|
|
67047
|
+
return left.kind === right.kind && left.storyKey === right.storyKey && left.blockPath === right.blockPath && left.leafPath === right.leafPath && left.commandFamily === right.commandFamily && left.editability === right.editability && sameTextTargetStaleCheck(left, right) && left.staleCheck.inlineCount === right.staleCheck.inlineCount && left.staleCheck.targetHash === right.staleCheck.targetHash && left.staleCheck.targetTextLength === right.staleCheck.targetTextLength && left.staleCheck.childCount === right.staleCheck.childCount && left.staleCheck.blockType === right.staleCheck.blockType && left.staleCheck.wordParaId === right.staleCheck.wordParaId && left.staleCheck.wordTextId === right.staleCheck.wordTextId && (textTargetLengthDrift || jsonStable2(left.staleCheck.sourceRef) === jsonStable2(right.staleCheck.sourceRef)) && (textTargetLengthDrift || jsonStable2(left.sourceRef) === jsonStable2(right.sourceRef)) && jsonStable2(left.table) === jsonStable2(right.table) && jsonStable2(left.editableOwner) === jsonStable2(right.editableOwner);
|
|
66720
67048
|
}
|
|
66721
67049
|
function sameTextTargetStaleCheck(left, right) {
|
|
66722
67050
|
if (left.staleCheck.paragraphTextHash === right.staleCheck.paragraphTextHash && left.staleCheck.paragraphTextLength === right.staleCheck.paragraphTextLength) {
|
|
@@ -66724,6 +67052,9 @@ function sameTextTargetStaleCheck(left, right) {
|
|
|
66724
67052
|
}
|
|
66725
67053
|
return left.commandFamily === "text-leaf" && left.staleCheck.paragraphTextLength !== void 0 && right.staleCheck.paragraphTextLength !== void 0 && left.staleCheck.paragraphTextLength !== right.staleCheck.paragraphTextLength;
|
|
66726
67054
|
}
|
|
67055
|
+
function hasTextTargetLengthDrift(left, right) {
|
|
67056
|
+
return left.commandFamily === "text-leaf" && left.staleCheck.paragraphTextLength !== void 0 && right.staleCheck.paragraphTextLength !== void 0 && left.staleCheck.paragraphTextLength !== right.staleCheck.paragraphTextLength;
|
|
67057
|
+
}
|
|
66727
67058
|
function locateTargetRange(document2, surface, target) {
|
|
66728
67059
|
if (target.kind === "hyperlink-text") {
|
|
66729
67060
|
return locateHyperlinkDisplayRange(document2, surface, target);
|
|
@@ -67015,7 +67346,7 @@ function resolveBlockPathInSurfaceBlocks2(blocks, tokens, tokenIndex, hasVertica
|
|
|
67015
67346
|
hasVerticalMergeContinuation || cell.verticalMerge === "continue"
|
|
67016
67347
|
);
|
|
67017
67348
|
}
|
|
67018
|
-
function
|
|
67349
|
+
function jsonStable2(value) {
|
|
67019
67350
|
return value === void 0 ? "" : JSON.stringify(value);
|
|
67020
67351
|
}
|
|
67021
67352
|
|
|
@@ -67152,20 +67483,20 @@ function tableAnchorCell(table) {
|
|
|
67152
67483
|
};
|
|
67153
67484
|
}
|
|
67154
67485
|
function sameResolvedTableStructureTarget(left, right) {
|
|
67155
|
-
return left.kind === right.kind && left.storyKey === right.storyKey && left.blockPath === right.blockPath && left.leafPath === right.leafPath && left.commandFamily === right.commandFamily && left.editability === right.editability && left.staleCheck.targetHash === right.staleCheck.targetHash && left.staleCheck.childCount === right.staleCheck.childCount && left.staleCheck.blockType === right.staleCheck.blockType &&
|
|
67486
|
+
return left.kind === right.kind && left.storyKey === right.storyKey && left.blockPath === right.blockPath && left.leafPath === right.leafPath && left.commandFamily === right.commandFamily && left.editability === right.editability && left.staleCheck.targetHash === right.staleCheck.targetHash && left.staleCheck.childCount === right.staleCheck.childCount && left.staleCheck.blockType === right.staleCheck.blockType && jsonStable3(left.staleCheck.sourceRef) === jsonStable3(right.staleCheck.sourceRef) && jsonStable3(left.sourceRef) === jsonStable3(right.sourceRef) && jsonStable3(left.table) === jsonStable3(right.table);
|
|
67156
67487
|
}
|
|
67157
|
-
function
|
|
67158
|
-
return JSON.stringify(
|
|
67488
|
+
function jsonStable3(value) {
|
|
67489
|
+
return JSON.stringify(sortJson2(value));
|
|
67159
67490
|
}
|
|
67160
|
-
function
|
|
67491
|
+
function sortJson2(value) {
|
|
67161
67492
|
if (Array.isArray(value)) {
|
|
67162
|
-
return value.map(
|
|
67493
|
+
return value.map(sortJson2);
|
|
67163
67494
|
}
|
|
67164
67495
|
if (value && typeof value === "object") {
|
|
67165
67496
|
const record = value;
|
|
67166
67497
|
const sorted = {};
|
|
67167
67498
|
for (const key of Object.keys(record).sort()) {
|
|
67168
|
-
sorted[key] =
|
|
67499
|
+
sorted[key] = sortJson2(record[key]);
|
|
67169
67500
|
}
|
|
67170
67501
|
return sorted;
|
|
67171
67502
|
}
|
|
@@ -69247,6 +69578,8 @@ function createDocumentRuntime(options) {
|
|
|
69247
69578
|
documentMode: workflowCoordinator.getEffectiveDocumentMode(commandSelection),
|
|
69248
69579
|
defaultAuthorId: defaultAuthorId ?? void 0,
|
|
69249
69580
|
renderSnapshot: cachedRenderSnapshot,
|
|
69581
|
+
activeStoryKey: canonicalEditableTargetStoryKey(activeStory),
|
|
69582
|
+
editableTargetCache: editableTargetBlockCache,
|
|
69250
69583
|
...resolvedFragmentTextTarget ? { textTarget: resolvedFragmentTextTarget } : {}
|
|
69251
69584
|
};
|
|
69252
69585
|
const preSelection = commandSelection;
|
|
@@ -71840,14 +72173,18 @@ function createDocumentRuntime(options) {
|
|
|
71840
72173
|
blockedReasons: [blockedReason]
|
|
71841
72174
|
});
|
|
71842
72175
|
}
|
|
71843
|
-
const
|
|
72176
|
+
const listBoundaryDeleteUsesStoryText = targetResolution?.kind === "accepted" && editableTarget?.listAddress?.operationScope === "list-text" && isTopLevelMainStoryBlockPath(editableTarget.blockPath) && selection.isCollapsed && (commandForDispatch.type === "text.delete-backward" && selection.anchor === targetResolution.range.from || commandForDispatch.type === "text.delete-forward" && selection.anchor === targetResolution.range.to);
|
|
72177
|
+
const textTarget = targetResolution?.kind === "accepted" && !listBoundaryDeleteUsesStoryText ? targetResolution.textTarget : legacyTextTarget;
|
|
71844
72178
|
const context = {
|
|
71845
72179
|
timestamp,
|
|
71846
72180
|
documentMode: textOptions.documentModeOverride ?? workflowCoordinator.getEffectiveDocumentMode(selection),
|
|
71847
72181
|
defaultAuthorId: defaultAuthorId ?? void 0,
|
|
71848
72182
|
renderSnapshot: cachedRenderSnapshot,
|
|
72183
|
+
activeStoryKey: canonicalEditableTargetStoryKey(activeStory),
|
|
72184
|
+
editableTargetCache: editableTargetBlockCache,
|
|
71849
72185
|
activeStorySize: cachedRenderSnapshot.surface?.storySize,
|
|
71850
72186
|
textTarget,
|
|
72187
|
+
preserveNumberingOnSplit: commandForDispatch.type === "paragraph.split" && targetResolution?.kind === "accepted" && editableTarget?.listAddress?.operationScope === "list-text",
|
|
71851
72188
|
rejectTargetlessTableStructureInsert: true
|
|
71852
72189
|
};
|
|
71853
72190
|
const baseState = selection === state.selection ? state : {
|
|
@@ -72146,7 +72483,9 @@ function createDocumentRuntime(options) {
|
|
|
72146
72483
|
timestamp: clock(),
|
|
72147
72484
|
documentMode: workflowCoordinator.getEffectiveDocumentMode(state.selection),
|
|
72148
72485
|
defaultAuthorId: defaultAuthorId ?? void 0,
|
|
72149
|
-
renderSnapshot: cachedRenderSnapshot
|
|
72486
|
+
renderSnapshot: cachedRenderSnapshot,
|
|
72487
|
+
activeStoryKey: canonicalEditableTargetStoryKey(activeStory),
|
|
72488
|
+
editableTargetCache: editableTargetBlockCache
|
|
72150
72489
|
};
|
|
72151
72490
|
try {
|
|
72152
72491
|
const transaction = executeEditorCommand(
|
|
@@ -74694,6 +75033,9 @@ function stripStoryTarget2(selection) {
|
|
|
74694
75033
|
const { storyTarget: _storyTarget, ...rest } = selection;
|
|
74695
75034
|
return rest;
|
|
74696
75035
|
}
|
|
75036
|
+
function isTopLevelMainStoryBlockPath(blockPath) {
|
|
75037
|
+
return typeof blockPath === "string" && /^main\/block\[\d+\]$/u.test(blockPath);
|
|
75038
|
+
}
|
|
74697
75039
|
function toInternalSelectionSnapshot2(selection) {
|
|
74698
75040
|
return {
|
|
74699
75041
|
anchor: selection.anchor,
|
|
@@ -127618,6 +127960,18 @@ function createTableActionFamily(runtime) {
|
|
|
127618
127960
|
}
|
|
127619
127961
|
};
|
|
127620
127962
|
}
|
|
127963
|
+
function findTableActionDescriptor(runtime, actionHandle) {
|
|
127964
|
+
const document2 = runtime.getCanonicalDocument();
|
|
127965
|
+
const seed = documentSeed(runtime);
|
|
127966
|
+
const surface = runtime.getRenderSnapshot().surface?.blocks ?? [];
|
|
127967
|
+
for (const target of collectEditableTargetRefs(document2)) {
|
|
127968
|
+
if (!target.table || callableOperationsForScope(target.table.operationScope).length === 0 || tableActionHandle(seed, target.targetKey) !== actionHandle || !isResolvableCurrentTableActionTarget(runtime, surface, target)) {
|
|
127969
|
+
continue;
|
|
127970
|
+
}
|
|
127971
|
+
return projectCurrentTableTarget(document2, seed, target);
|
|
127972
|
+
}
|
|
127973
|
+
return null;
|
|
127974
|
+
}
|
|
127621
127975
|
function isSupportedTableActionEvidence(entry) {
|
|
127622
127976
|
return isSupportedTableStructureEvidence(entry) || isSupportedTableTextEvidence(entry);
|
|
127623
127977
|
}
|
|
@@ -127636,6 +127990,7 @@ function projectTableActionDescriptor(document2, seed, entry) {
|
|
|
127636
127990
|
const callableOperations = callableOperationsForScope(scope);
|
|
127637
127991
|
const supportedOperations = operationsForScope(scope);
|
|
127638
127992
|
if (callableOperations.length === 0) return [];
|
|
127993
|
+
const selectionRequiredOperations = selectionRequiredOperationsForScope(scope);
|
|
127639
127994
|
return [
|
|
127640
127995
|
{
|
|
127641
127996
|
actionHandle: tableActionHandle(seed, entry.targetKey),
|
|
@@ -127644,6 +127999,7 @@ function projectTableActionDescriptor(document2, seed, entry) {
|
|
|
127644
127999
|
relation: entry.relation,
|
|
127645
128000
|
operationScope: scope,
|
|
127646
128001
|
callableOperations,
|
|
128002
|
+
...selectionRequiredOperations.length > 0 ? { selectionRequiredOperations } : {},
|
|
127647
128003
|
supportedOperations,
|
|
127648
128004
|
...scope === "text" ? { readback: tableTextReadback(readBlockPathText(document2, entry.blockPath)) } : {},
|
|
127649
128005
|
reason: entry.runtimeCommand.reason
|
|
@@ -127655,6 +128011,7 @@ function projectCurrentTableTarget(document2, seed, target) {
|
|
|
127655
128011
|
if (!table) return null;
|
|
127656
128012
|
const callableOperations = callableOperationsForScope(table.operationScope);
|
|
127657
128013
|
if (callableOperations.length === 0) return null;
|
|
128014
|
+
const selectionRequiredOperations = selectionRequiredOperationsForScope(table.operationScope);
|
|
127658
128015
|
return {
|
|
127659
128016
|
actionHandle: tableActionHandle(seed, target.targetKey),
|
|
127660
128017
|
family: table.operationScope === "text" ? "table-text" : "table-structure",
|
|
@@ -127662,6 +128019,7 @@ function projectCurrentTableTarget(document2, seed, target) {
|
|
|
127662
128019
|
relation: "contained-by-scope",
|
|
127663
128020
|
operationScope: table.operationScope,
|
|
127664
128021
|
callableOperations,
|
|
128022
|
+
...selectionRequiredOperations.length > 0 ? { selectionRequiredOperations } : {},
|
|
127665
128023
|
supportedOperations: operationsForScope(table.operationScope),
|
|
127666
128024
|
...table.operationScope === "text" ? { readback: tableTextReadback(readEditableTargetText(document2, target)) } : {},
|
|
127667
128025
|
reason: table.operationScope === "text" ? "l07:table-text-target-supported" : "l07:table-structure-target-supported"
|
|
@@ -127739,11 +128097,14 @@ function callableOperationsForScope(scope) {
|
|
|
127739
128097
|
case "text":
|
|
127740
128098
|
return TEXT_TRANSFER_OPERATIONS;
|
|
127741
128099
|
case "cell":
|
|
127742
|
-
return
|
|
128100
|
+
return CELL_STRUCTURE_OPERATIONS;
|
|
127743
128101
|
default:
|
|
127744
128102
|
return operationsForScope(scope);
|
|
127745
128103
|
}
|
|
127746
128104
|
}
|
|
128105
|
+
function selectionRequiredOperationsForScope(scope) {
|
|
128106
|
+
return scope === "cell" ? ["merge-cells"] : [];
|
|
128107
|
+
}
|
|
127747
128108
|
function operationsForScope(scope) {
|
|
127748
128109
|
switch (scope) {
|
|
127749
128110
|
case "text":
|
|
@@ -128170,9 +128531,6 @@ var DEFAULT_LOCATE_LIMIT = 20;
|
|
|
128170
128531
|
var DEFAULT_REWRITE_ALL_LIMIT = 10;
|
|
128171
128532
|
var DEFAULT_TABLE_TEXT_SCOPE_LIMIT = 3;
|
|
128172
128533
|
var DEFAULT_PLAN_STEP_LIMIT = 20;
|
|
128173
|
-
function documentContentHash(runtime) {
|
|
128174
|
-
return JSON.stringify(runtime.getCanonicalDocument().content);
|
|
128175
|
-
}
|
|
128176
128534
|
function createActionsFamily(runtime) {
|
|
128177
128535
|
const category = {
|
|
128178
128536
|
discover(input) {
|
|
@@ -128645,10 +129003,10 @@ function runPlanStep(runtime, mode, step, plan) {
|
|
|
128645
129003
|
...before.readback ? { beforeReadback: before.readback } : {}
|
|
128646
129004
|
};
|
|
128647
129005
|
}
|
|
128648
|
-
const
|
|
129006
|
+
const documentBeforeApply = runtime.getCanonicalDocument();
|
|
128649
129007
|
const applied = applyPlanStep(runtime, step, plan);
|
|
128650
|
-
const
|
|
128651
|
-
const projectedApply = !applied.applied &&
|
|
129008
|
+
const documentAfterApply = runtime.getCanonicalDocument();
|
|
129009
|
+
const projectedApply = !applied.applied && documentAfterApply !== documentBeforeApply ? withSuspectMutationApplyResult(applied, step.id, applied.target ?? before.target) : applied;
|
|
128652
129010
|
const after = step.kind === "flag" ? before : step.target ? readPlanTarget(runtime, step.target) : before;
|
|
128653
129011
|
return {
|
|
128654
129012
|
id: step.id,
|
|
@@ -128699,7 +129057,8 @@ function runPlanTableActionStep(runtime, mode, step, plan) {
|
|
|
128699
129057
|
tableAction: tableAction2
|
|
128700
129058
|
});
|
|
128701
129059
|
}
|
|
128702
|
-
|
|
129060
|
+
const isSelectionRequiredOperation = step.kind === "tableSelection" && operationKind !== void 0 && (tableAction2.selectionRequiredOperations ?? []).includes(operationKind) && tableSelectionStepHasDescriptor(step.operation);
|
|
129061
|
+
if (!operationKind || !tableAction2.callableOperations.includes(operationKind) && !isSelectionRequiredOperation) {
|
|
128703
129062
|
return blockedPlanStepFromDetails(
|
|
128704
129063
|
step.id,
|
|
128705
129064
|
step.kind,
|
|
@@ -128963,7 +129322,7 @@ function applyRewrite(runtime, target, input) {
|
|
|
128963
129322
|
);
|
|
128964
129323
|
}
|
|
128965
129324
|
const beforeText = target.scope.content.text;
|
|
128966
|
-
const
|
|
129325
|
+
const documentBeforeApply = runtime.getCanonicalDocument();
|
|
128967
129326
|
const result = createReplacementFamily(runtime).applyReplacementScope({
|
|
128968
129327
|
targetScopeId: target.handle.scopeId,
|
|
128969
129328
|
operation: "replace",
|
|
@@ -128975,7 +129334,7 @@ function applyRewrite(runtime, target, input) {
|
|
|
128975
129334
|
...input.origin ? { origin: input.origin } : {},
|
|
128976
129335
|
...input.proposalId ? { proposalId: input.proposalId } : {}
|
|
128977
129336
|
});
|
|
128978
|
-
const documentMutated =
|
|
129337
|
+
const documentMutated = runtime.getCanonicalDocument() !== documentBeforeApply;
|
|
128979
129338
|
if (!result.applied) {
|
|
128980
129339
|
return documentMutated ? withSuspectMutationApplyResult(
|
|
128981
129340
|
projectApplyResult(result, target),
|
|
@@ -129232,19 +129591,7 @@ function findTableAction(runtime, actionHandle) {
|
|
|
129232
129591
|
return action?.family === "table-text" ? action : null;
|
|
129233
129592
|
}
|
|
129234
129593
|
function findAnyTableAction(runtime, actionHandle) {
|
|
129235
|
-
|
|
129236
|
-
for (const scope of compiler.compileAllScopes()) {
|
|
129237
|
-
if (scope.kind !== "table") continue;
|
|
129238
|
-
const result = createTableActionFamily(runtime).listTableActions({
|
|
129239
|
-
handle: scope.handle,
|
|
129240
|
-
nowUtc: currentAuditTimestamp(runtime)
|
|
129241
|
-
});
|
|
129242
|
-
const action = result.actions.find(
|
|
129243
|
-
(candidate) => candidate.actionHandle === actionHandle
|
|
129244
|
-
);
|
|
129245
|
-
if (action) return action;
|
|
129246
|
-
}
|
|
129247
|
-
return null;
|
|
129594
|
+
return findTableActionDescriptor(runtime, actionHandle);
|
|
129248
129595
|
}
|
|
129249
129596
|
function findEditableTextAction(runtime, actionHandle) {
|
|
129250
129597
|
if (!actionHandle.startsWith("scope-command:text-leaf:")) return null;
|
|
@@ -129812,6 +130159,11 @@ function tablePlanOperationFamilyBlocker(stepKind, operationKind) {
|
|
|
129812
130159
|
}
|
|
129813
130160
|
return null;
|
|
129814
130161
|
}
|
|
130162
|
+
function tableSelectionStepHasDescriptor(operation) {
|
|
130163
|
+
return Boolean(
|
|
130164
|
+
operation && "selectionDescriptor" in operation && operation.selectionDescriptor
|
|
130165
|
+
);
|
|
130166
|
+
}
|
|
129815
130167
|
function listCommandForOperation(operation, paragraphIndex, origin) {
|
|
129816
130168
|
switch (operation.kind) {
|
|
129817
130169
|
case "toggle":
|