@superdoc-dev/cli 0.3.0-next.54 → 0.3.0-next.56
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/index.js +856 -325
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -1433,8 +1433,8 @@ var init_operation_definitions = __esm(() => {
|
|
|
1433
1433
|
},
|
|
1434
1434
|
insert: {
|
|
1435
1435
|
memberPath: "insert",
|
|
1436
|
-
description: "Insert content into the document. Two input shapes: " + "
|
|
1437
|
-
expectedResult: "Returns an SDMutationReceipt with applied status; resolution reports
|
|
1436
|
+
description: "Insert content into the document. Two input shapes: " + "text-based (value + type) inserts inline content at a SelectionTarget or ref position within an existing block; " + "structural SDFragment (content) inserts one or more blocks as siblings relative to a BlockNodeAddress target. " + "When target/ref is omitted, content appends at the end of the document. " + "Text mode supports text (default), markdown, and html content types via the `type` field. " + "Structural mode uses `placement` (before/after/insideStart/insideEnd) to position relative to the target block.",
|
|
1437
|
+
expectedResult: "Returns an SDMutationReceipt with applied status; resolution reports the inserted TextAddress for text insertion or a BlockNodeAddress for structural insertion. Receipt reports NO_OP if the insertion point is invalid or content is empty.",
|
|
1438
1438
|
requiresDocumentContext: true,
|
|
1439
1439
|
metadata: mutationOperation({
|
|
1440
1440
|
idempotency: "non-idempotent",
|
|
@@ -7329,6 +7329,27 @@ function targetLocatorWithPayload(payloadProperties, payloadRequired = []) {
|
|
|
7329
7329
|
]
|
|
7330
7330
|
};
|
|
7331
7331
|
}
|
|
7332
|
+
function optionalTargetLocatorWithPayload(payloadProperties, payloadRequired = []) {
|
|
7333
|
+
return {
|
|
7334
|
+
oneOf: [
|
|
7335
|
+
objectSchema({
|
|
7336
|
+
target: {
|
|
7337
|
+
...ref("SelectionTarget"),
|
|
7338
|
+
description: "Selection target: {kind:'selection', start:{kind:'text', blockId, offset}, end:{kind:'text', blockId, offset}}."
|
|
7339
|
+
},
|
|
7340
|
+
...payloadProperties
|
|
7341
|
+
}, ["target", ...payloadRequired]),
|
|
7342
|
+
objectSchema({
|
|
7343
|
+
ref: {
|
|
7344
|
+
type: "string",
|
|
7345
|
+
description: "Handle ref string returned by a prior search/query result."
|
|
7346
|
+
},
|
|
7347
|
+
...payloadProperties
|
|
7348
|
+
}, ["ref", ...payloadRequired]),
|
|
7349
|
+
objectSchema({ ...payloadProperties }, [...payloadRequired])
|
|
7350
|
+
]
|
|
7351
|
+
};
|
|
7352
|
+
}
|
|
7332
7353
|
function imagesMutationSchemaSet(inputSchema) {
|
|
7333
7354
|
return {
|
|
7334
7355
|
input: inputSchema,
|
|
@@ -8693,12 +8714,8 @@ var init_schemas = __esm(() => {
|
|
|
8693
8714
|
};
|
|
8694
8715
|
insertInputSchema = {
|
|
8695
8716
|
oneOf: [
|
|
8696
|
-
|
|
8717
|
+
optionalTargetLocatorWithPayload({
|
|
8697
8718
|
in: storyLocatorSchema,
|
|
8698
|
-
target: {
|
|
8699
|
-
...textAddressSchema,
|
|
8700
|
-
description: "Insertion point: {kind:'text', blockId:'...', range:{start, end}}."
|
|
8701
|
-
},
|
|
8702
8719
|
value: { type: "string", description: "Text content to insert." },
|
|
8703
8720
|
type: {
|
|
8704
8721
|
type: "string",
|
|
@@ -13082,8 +13099,8 @@ function validateTargetLocator(input, operation) {
|
|
|
13082
13099
|
value: input.target
|
|
13083
13100
|
});
|
|
13084
13101
|
}
|
|
13085
|
-
if (hasRef && typeof input.ref !== "string") {
|
|
13086
|
-
throw new DocumentApiValidationError("INVALID_TARGET", "ref must be a string.", {
|
|
13102
|
+
if (hasRef && (typeof input.ref !== "string" || input.ref === "")) {
|
|
13103
|
+
throw new DocumentApiValidationError("INVALID_TARGET", "ref must be a non-empty string.", {
|
|
13087
13104
|
field: "ref",
|
|
13088
13105
|
value: input.ref
|
|
13089
13106
|
});
|
|
@@ -13103,13 +13120,8 @@ function validateStyleApplyInput(input) {
|
|
|
13103
13120
|
}
|
|
13104
13121
|
function executeStyleApply(adapter, input, options) {
|
|
13105
13122
|
validateStyleApplyInput(input);
|
|
13106
|
-
|
|
13107
|
-
|
|
13108
|
-
target: input.target,
|
|
13109
|
-
ref: input.ref,
|
|
13110
|
-
inline: input.inline,
|
|
13111
|
-
in: input.in
|
|
13112
|
-
}, normalizeMutationOptions(options));
|
|
13123
|
+
const request = input.target ? { kind: "format", target: input.target, inline: input.inline, in: input.in } : { kind: "format", ref: input.ref, inline: input.inline, in: input.in };
|
|
13124
|
+
return adapter.execute(request, normalizeMutationOptions(options));
|
|
13113
13125
|
}
|
|
13114
13126
|
function acceptsImplicitTrue(key) {
|
|
13115
13127
|
return INLINE_PROPERTY_BY_KEY[key].type === "boolean" || key === "underline";
|
|
@@ -13134,13 +13146,8 @@ function executeInlineAlias(adapter, key, input, options) {
|
|
|
13134
13146
|
const value = normalizeInlineAliasValue(key, input.value);
|
|
13135
13147
|
const inline = { [key]: value };
|
|
13136
13148
|
validateInlineRunPatch(inline);
|
|
13137
|
-
|
|
13138
|
-
|
|
13139
|
-
target: input.target,
|
|
13140
|
-
ref: input.ref,
|
|
13141
|
-
inline,
|
|
13142
|
-
in: input.in
|
|
13143
|
-
}, normalizeMutationOptions(options));
|
|
13149
|
+
const request = input.target ? { kind: "format", target: input.target, inline, in: input.in } : { kind: "format", ref: input.ref, inline, in: input.in };
|
|
13150
|
+
return adapter.execute(request, normalizeMutationOptions(options));
|
|
13144
13151
|
}
|
|
13145
13152
|
var STYLE_APPLY_INPUT_ALLOWED_KEYS, INLINE_ALIAS_INPUT_ALLOWED_KEYS;
|
|
13146
13153
|
var init_format = __esm(() => {
|
|
@@ -13215,8 +13222,8 @@ function validateDeleteInput(input) {
|
|
|
13215
13222
|
value: target
|
|
13216
13223
|
});
|
|
13217
13224
|
}
|
|
13218
|
-
if (hasRef && typeof ref2 !== "string") {
|
|
13219
|
-
throw new DocumentApiValidationError("INVALID_TARGET", "ref must be a string.", {
|
|
13225
|
+
if (hasRef && (typeof ref2 !== "string" || ref2 === "")) {
|
|
13226
|
+
throw new DocumentApiValidationError("INVALID_TARGET", "ref must be a non-empty string.", {
|
|
13220
13227
|
field: "ref",
|
|
13221
13228
|
value: ref2
|
|
13222
13229
|
});
|
|
@@ -13227,13 +13234,8 @@ function validateDeleteInput(input) {
|
|
|
13227
13234
|
}
|
|
13228
13235
|
function executeDelete(adapter, input, options) {
|
|
13229
13236
|
validateDeleteInput(input);
|
|
13230
|
-
|
|
13231
|
-
|
|
13232
|
-
target: input.target,
|
|
13233
|
-
ref: input.ref,
|
|
13234
|
-
behavior: input.behavior ?? "selection",
|
|
13235
|
-
in: input.in
|
|
13236
|
-
}, normalizeMutationOptions(options));
|
|
13237
|
+
const request = input.target ? { kind: "delete", target: input.target, behavior: input.behavior ?? "selection", in: input.in } : { kind: "delete", ref: input.ref, behavior: input.behavior ?? "selection", in: input.in };
|
|
13238
|
+
return adapter.execute(request, normalizeMutationOptions(options));
|
|
13237
13239
|
}
|
|
13238
13240
|
var DELETE_INPUT_ALLOWED_KEYS, VALID_BEHAVIORS;
|
|
13239
13241
|
var init_delete = __esm(() => {
|
|
@@ -13811,33 +13813,42 @@ function validateInsertInput(input) {
|
|
|
13811
13813
|
const hasValue = "value" in input && input.value !== undefined;
|
|
13812
13814
|
const hasContent = "content" in input && input.content !== undefined;
|
|
13813
13815
|
if (hasValue && hasContent) {
|
|
13814
|
-
throw new DocumentApiValidationError("INVALID_INPUT", 'Insert input must provide either "value" (
|
|
13816
|
+
throw new DocumentApiValidationError("INVALID_INPUT", 'Insert input must provide either "value" (text) or "content" (structural), not both.', { fields: ["value", "content"] });
|
|
13815
13817
|
}
|
|
13816
13818
|
if (!hasValue && !hasContent) {
|
|
13817
|
-
throw new DocumentApiValidationError("INVALID_INPUT", 'Insert input must provide either "value" (
|
|
13819
|
+
throw new DocumentApiValidationError("INVALID_INPUT", 'Insert input must provide either "value" (text string) or "content" (SDFragment).', { fields: ["value", "content"] });
|
|
13818
13820
|
}
|
|
13819
13821
|
validateStoryLocator(input.in, "in");
|
|
13820
13822
|
if (hasContent) {
|
|
13821
13823
|
validateStructuralInsertInput(input);
|
|
13822
13824
|
} else {
|
|
13823
|
-
|
|
13825
|
+
validateTextInsertInput(input);
|
|
13824
13826
|
}
|
|
13825
13827
|
}
|
|
13826
|
-
function
|
|
13828
|
+
function validateTextInsertInput(input) {
|
|
13827
13829
|
if ("placement" in input && input.placement !== undefined) {
|
|
13828
13830
|
throw new DocumentApiValidationError("INVALID_INPUT", '"placement" is only valid with structural content input, not with "value".', { field: "placement" });
|
|
13829
13831
|
}
|
|
13830
13832
|
if ("nestingPolicy" in input && input.nestingPolicy !== undefined) {
|
|
13831
13833
|
throw new DocumentApiValidationError("INVALID_INPUT", '"nestingPolicy" is only valid with structural content input, not with "value".', { field: "nestingPolicy" });
|
|
13832
13834
|
}
|
|
13833
|
-
assertNoUnknownFields(input,
|
|
13834
|
-
const { target, value, type } = input;
|
|
13835
|
-
if (target !== undefined &&
|
|
13836
|
-
throw new DocumentApiValidationError("
|
|
13835
|
+
assertNoUnknownFields(input, TEXT_INSERT_ALLOWED_KEYS, "insert");
|
|
13836
|
+
const { target, ref: ref2, value, type } = input;
|
|
13837
|
+
if (target !== undefined && ref2 !== undefined) {
|
|
13838
|
+
throw new DocumentApiValidationError("INVALID_INPUT", 'Insert input must provide either "target" or "ref", not both.', { fields: ["target", "ref"] });
|
|
13839
|
+
}
|
|
13840
|
+
if (target !== undefined && !isSelectionTarget(target)) {
|
|
13841
|
+
throw new DocumentApiValidationError("INVALID_TARGET", "target must be a SelectionTarget object.", {
|
|
13837
13842
|
field: "target",
|
|
13838
13843
|
value: target
|
|
13839
13844
|
});
|
|
13840
13845
|
}
|
|
13846
|
+
if (ref2 !== undefined && (typeof ref2 !== "string" || ref2 === "")) {
|
|
13847
|
+
throw new DocumentApiValidationError("INVALID_TARGET", "ref must be a non-empty string.", {
|
|
13848
|
+
field: "ref",
|
|
13849
|
+
value: ref2
|
|
13850
|
+
});
|
|
13851
|
+
}
|
|
13841
13852
|
if (typeof value !== "string") {
|
|
13842
13853
|
throw new DocumentApiValidationError("INVALID_TARGET", `value must be a string, got ${typeof value}.`, {
|
|
13843
13854
|
field: "value",
|
|
@@ -13866,29 +13877,35 @@ function validateStructuralInsertInput(input) {
|
|
|
13866
13877
|
validateNestingPolicyValue(nestingPolicy);
|
|
13867
13878
|
validateDocumentFragment(content);
|
|
13868
13879
|
}
|
|
13869
|
-
function executeInsert(
|
|
13880
|
+
function executeInsert(selectionAdapter, writeAdapter, input, options) {
|
|
13870
13881
|
validateInsertInput(input);
|
|
13871
13882
|
if (isStructuralInsertInput(input)) {
|
|
13872
|
-
return
|
|
13883
|
+
return writeAdapter.insertStructured(input, normalizeMutationOptions(options));
|
|
13873
13884
|
}
|
|
13874
|
-
const { target, value } = input;
|
|
13885
|
+
const { target, ref: ref2, value } = input;
|
|
13875
13886
|
const contentType = input.type ?? "text";
|
|
13876
13887
|
if (contentType !== "text") {
|
|
13877
|
-
return
|
|
13888
|
+
return writeAdapter.insertStructured(input, normalizeMutationOptions(options));
|
|
13878
13889
|
}
|
|
13879
13890
|
const storyIn = input.in;
|
|
13880
|
-
|
|
13881
|
-
|
|
13891
|
+
if (target || ref2) {
|
|
13892
|
+
const request2 = target ? { kind: "insert", target, text: value, ...storyIn ? { in: storyIn } : {} } : { kind: "insert", ref: ref2, text: value, ...storyIn ? { in: storyIn } : {} };
|
|
13893
|
+
const textReceipt2 = selectionAdapter.execute(request2, normalizeMutationOptions(options));
|
|
13894
|
+
return textReceiptToSDReceipt(textReceipt2);
|
|
13895
|
+
}
|
|
13896
|
+
const request = { kind: "insert", text: value, ...storyIn ? { in: storyIn } : {} };
|
|
13897
|
+
const textReceipt = executeWrite(writeAdapter, request, options);
|
|
13882
13898
|
return textReceiptToSDReceipt(textReceipt);
|
|
13883
13899
|
}
|
|
13884
|
-
var
|
|
13900
|
+
var TEXT_INSERT_ALLOWED_KEYS, STRUCTURAL_INSERT_ALLOWED_KEYS, VALID_INSERT_TYPES;
|
|
13885
13901
|
var init_insert = __esm(() => {
|
|
13886
13902
|
init_placement();
|
|
13887
13903
|
init_errors2();
|
|
13888
13904
|
init_validation_primitives();
|
|
13905
|
+
init_selection_target_validator();
|
|
13889
13906
|
init_fragment_validator();
|
|
13890
13907
|
init_story_validator();
|
|
13891
|
-
|
|
13908
|
+
TEXT_INSERT_ALLOWED_KEYS = new Set(["value", "type", "target", "ref", "in"]);
|
|
13892
13909
|
STRUCTURAL_INSERT_ALLOWED_KEYS = new Set(["content", "target", "placement", "nestingPolicy", "in"]);
|
|
13893
13910
|
VALID_INSERT_TYPES = new Set(["text", "markdown", "html"]);
|
|
13894
13911
|
});
|
|
@@ -14065,8 +14082,8 @@ function validateTargetLocator2(input, operation) {
|
|
|
14065
14082
|
value: input.target
|
|
14066
14083
|
});
|
|
14067
14084
|
}
|
|
14068
|
-
if (hasRef && typeof input.ref !== "string") {
|
|
14069
|
-
throw new DocumentApiValidationError("INVALID_TARGET", "ref must be a string.", {
|
|
14085
|
+
if (hasRef && (typeof input.ref !== "string" || input.ref === "")) {
|
|
14086
|
+
throw new DocumentApiValidationError("INVALID_TARGET", "ref must be a non-empty string.", {
|
|
14070
14087
|
field: "ref",
|
|
14071
14088
|
value: input.ref
|
|
14072
14089
|
});
|
|
@@ -14140,13 +14157,8 @@ function executeReplace(selectionAdapter, writeAdapter, input, options) {
|
|
|
14140
14157
|
return writeAdapter.replaceStructured(input, normalizeMutationOptions(options));
|
|
14141
14158
|
}
|
|
14142
14159
|
const textInput = input;
|
|
14143
|
-
const
|
|
14144
|
-
|
|
14145
|
-
target: textInput.target,
|
|
14146
|
-
ref: textInput.ref,
|
|
14147
|
-
text: textInput.text,
|
|
14148
|
-
in: textInput.in
|
|
14149
|
-
}, normalizeMutationOptions(options));
|
|
14160
|
+
const request = textInput.target ? { kind: "replace", target: textInput.target, text: textInput.text, in: textInput.in } : { kind: "replace", ref: textInput.ref, text: textInput.text, in: textInput.in };
|
|
14161
|
+
const textReceipt = selectionAdapter.execute(request, normalizeMutationOptions(options));
|
|
14150
14162
|
return textReceiptToSDReceipt(textReceipt);
|
|
14151
14163
|
}
|
|
14152
14164
|
var TEXT_REPLACE_ALLOWED_KEYS, STRUCTURAL_REPLACE_ALLOWED_KEYS;
|
|
@@ -16664,7 +16676,7 @@ function createDocumentApi(adapters) {
|
|
|
16664
16676
|
}
|
|
16665
16677
|
},
|
|
16666
16678
|
insert(input, options) {
|
|
16667
|
-
return executeInsert(adapters.write, input, options);
|
|
16679
|
+
return executeInsert(adapters.selectionMutation, adapters.write, input, options);
|
|
16668
16680
|
},
|
|
16669
16681
|
replace(input, options) {
|
|
16670
16682
|
return executeReplace(adapters.selectionMutation, adapters.write, input, options);
|
|
@@ -40060,7 +40072,7 @@ var init_remark_gfm_z_sDF4ss_es = __esm(() => {
|
|
|
40060
40072
|
emptyOptions2 = {};
|
|
40061
40073
|
});
|
|
40062
40074
|
|
|
40063
|
-
// ../../packages/superdoc/dist/chunks/SuperConverter-
|
|
40075
|
+
// ../../packages/superdoc/dist/chunks/SuperConverter-C65zRR3r.es.js
|
|
40064
40076
|
function getExtensionConfigField(extension$1, field, context = { name: "" }) {
|
|
40065
40077
|
const fieldValue = extension$1.config[field];
|
|
40066
40078
|
if (typeof fieldValue === "function")
|
|
@@ -41859,6 +41871,25 @@ function targetLocatorWithPayload2(payloadProperties, payloadRequired = []) {
|
|
|
41859
41871
|
...payloadProperties
|
|
41860
41872
|
}, ["ref", ...payloadRequired])] };
|
|
41861
41873
|
}
|
|
41874
|
+
function optionalTargetLocatorWithPayload2(payloadProperties, payloadRequired = []) {
|
|
41875
|
+
return { oneOf: [
|
|
41876
|
+
objectSchema2({
|
|
41877
|
+
target: {
|
|
41878
|
+
...ref2("SelectionTarget"),
|
|
41879
|
+
description: "Selection target: {kind:'selection', start:{kind:'text', blockId, offset}, end:{kind:'text', blockId, offset}}."
|
|
41880
|
+
},
|
|
41881
|
+
...payloadProperties
|
|
41882
|
+
}, ["target", ...payloadRequired]),
|
|
41883
|
+
objectSchema2({
|
|
41884
|
+
ref: {
|
|
41885
|
+
type: "string",
|
|
41886
|
+
description: "Handle ref string returned by a prior search/query result."
|
|
41887
|
+
},
|
|
41888
|
+
...payloadProperties
|
|
41889
|
+
}, ["ref", ...payloadRequired]),
|
|
41890
|
+
objectSchema2({ ...payloadProperties }, [...payloadRequired])
|
|
41891
|
+
] };
|
|
41892
|
+
}
|
|
41862
41893
|
function imagesMutationSchemaSet2(inputSchema) {
|
|
41863
41894
|
return {
|
|
41864
41895
|
input: inputSchema,
|
|
@@ -42810,8 +42841,8 @@ function validateTargetLocator$1(input, operation) {
|
|
|
42810
42841
|
field: "target",
|
|
42811
42842
|
value: input.target
|
|
42812
42843
|
});
|
|
42813
|
-
if (hasRef && typeof input.ref !== "string")
|
|
42814
|
-
throw new DocumentApiValidationError2("INVALID_TARGET", "ref must be a string.", {
|
|
42844
|
+
if (hasRef && (typeof input.ref !== "string" || input.ref === ""))
|
|
42845
|
+
throw new DocumentApiValidationError2("INVALID_TARGET", "ref must be a non-empty string.", {
|
|
42815
42846
|
field: "ref",
|
|
42816
42847
|
value: input.ref
|
|
42817
42848
|
});
|
|
@@ -42828,13 +42859,18 @@ function validateStyleApplyInput2(input) {
|
|
|
42828
42859
|
}
|
|
42829
42860
|
function executeStyleApply2(adapter, input, options) {
|
|
42830
42861
|
validateStyleApplyInput2(input);
|
|
42831
|
-
|
|
42862
|
+
const request = input.target ? {
|
|
42832
42863
|
kind: "format",
|
|
42833
42864
|
target: input.target,
|
|
42865
|
+
inline: input.inline,
|
|
42866
|
+
in: input.in
|
|
42867
|
+
} : {
|
|
42868
|
+
kind: "format",
|
|
42834
42869
|
ref: input.ref,
|
|
42835
42870
|
inline: input.inline,
|
|
42836
42871
|
in: input.in
|
|
42837
|
-
}
|
|
42872
|
+
};
|
|
42873
|
+
return adapter.execute(request, normalizeMutationOptions2(options));
|
|
42838
42874
|
}
|
|
42839
42875
|
function acceptsImplicitTrue2(key) {
|
|
42840
42876
|
return INLINE_PROPERTY_BY_KEY2[key].type === "boolean" || key === "underline";
|
|
@@ -42858,13 +42894,18 @@ function executeInlineAlias2(adapter, key, input, options) {
|
|
|
42858
42894
|
const value = normalizeInlineAliasValue2(key, input.value);
|
|
42859
42895
|
const inline = { [key]: value };
|
|
42860
42896
|
validateInlineRunPatch2(inline);
|
|
42861
|
-
|
|
42897
|
+
const request = input.target ? {
|
|
42862
42898
|
kind: "format",
|
|
42863
42899
|
target: input.target,
|
|
42900
|
+
inline,
|
|
42901
|
+
in: input.in
|
|
42902
|
+
} : {
|
|
42903
|
+
kind: "format",
|
|
42864
42904
|
ref: input.ref,
|
|
42865
42905
|
inline,
|
|
42866
42906
|
in: input.in
|
|
42867
|
-
}
|
|
42907
|
+
};
|
|
42908
|
+
return adapter.execute(request, normalizeMutationOptions2(options));
|
|
42868
42909
|
}
|
|
42869
42910
|
function executeGetNode2(adapter, address2) {
|
|
42870
42911
|
return adapter.getNode(address2);
|
|
@@ -42907,8 +42948,8 @@ function validateDeleteInput2(input) {
|
|
|
42907
42948
|
field: "target",
|
|
42908
42949
|
value: target
|
|
42909
42950
|
});
|
|
42910
|
-
if (hasRef && typeof ref$1 !== "string")
|
|
42911
|
-
throw new DocumentApiValidationError2("INVALID_TARGET", "ref must be a string.", {
|
|
42951
|
+
if (hasRef && (typeof ref$1 !== "string" || ref$1 === ""))
|
|
42952
|
+
throw new DocumentApiValidationError2("INVALID_TARGET", "ref must be a non-empty string.", {
|
|
42912
42953
|
field: "ref",
|
|
42913
42954
|
value: ref$1
|
|
42914
42955
|
});
|
|
@@ -42920,13 +42961,18 @@ function validateDeleteInput2(input) {
|
|
|
42920
42961
|
}
|
|
42921
42962
|
function executeDelete$1(adapter, input, options) {
|
|
42922
42963
|
validateDeleteInput2(input);
|
|
42923
|
-
|
|
42964
|
+
const request = input.target ? {
|
|
42924
42965
|
kind: "delete",
|
|
42925
42966
|
target: input.target,
|
|
42967
|
+
behavior: input.behavior ?? "selection",
|
|
42968
|
+
in: input.in
|
|
42969
|
+
} : {
|
|
42970
|
+
kind: "delete",
|
|
42926
42971
|
ref: input.ref,
|
|
42927
42972
|
behavior: input.behavior ?? "selection",
|
|
42928
42973
|
in: input.in
|
|
42929
|
-
}
|
|
42974
|
+
};
|
|
42975
|
+
return adapter.execute(request, normalizeMutationOptions2(options));
|
|
42930
42976
|
}
|
|
42931
42977
|
function validateSDFragment2(fragment2) {
|
|
42932
42978
|
const nodes = normalizeToNodeArray2(fragment2, "INVALID_PAYLOAD");
|
|
@@ -43405,27 +43451,34 @@ function validateInsertInput2(input) {
|
|
|
43405
43451
|
const hasValue = "value" in input && input.value !== undefined;
|
|
43406
43452
|
const hasContent = "content" in input && input.content !== undefined;
|
|
43407
43453
|
if (hasValue && hasContent)
|
|
43408
|
-
throw new DocumentApiValidationError2("INVALID_INPUT", 'Insert input must provide either "value" (
|
|
43454
|
+
throw new DocumentApiValidationError2("INVALID_INPUT", 'Insert input must provide either "value" (text) or "content" (structural), not both.', { fields: ["value", "content"] });
|
|
43409
43455
|
if (!hasValue && !hasContent)
|
|
43410
|
-
throw new DocumentApiValidationError2("INVALID_INPUT", 'Insert input must provide either "value" (
|
|
43456
|
+
throw new DocumentApiValidationError2("INVALID_INPUT", 'Insert input must provide either "value" (text string) or "content" (SDFragment).', { fields: ["value", "content"] });
|
|
43411
43457
|
validateStoryLocator2(input.in, "in");
|
|
43412
43458
|
if (hasContent)
|
|
43413
43459
|
validateStructuralInsertInput2(input);
|
|
43414
43460
|
else
|
|
43415
|
-
|
|
43461
|
+
validateTextInsertInput2(input);
|
|
43416
43462
|
}
|
|
43417
|
-
function
|
|
43463
|
+
function validateTextInsertInput2(input) {
|
|
43418
43464
|
if ("placement" in input && input.placement !== undefined)
|
|
43419
43465
|
throw new DocumentApiValidationError2("INVALID_INPUT", '"placement" is only valid with structural content input, not with "value".', { field: "placement" });
|
|
43420
43466
|
if ("nestingPolicy" in input && input.nestingPolicy !== undefined)
|
|
43421
43467
|
throw new DocumentApiValidationError2("INVALID_INPUT", '"nestingPolicy" is only valid with structural content input, not with "value".', { field: "nestingPolicy" });
|
|
43422
|
-
assertNoUnknownFields3(input,
|
|
43423
|
-
const { target, value, type } = input;
|
|
43424
|
-
if (target !== undefined &&
|
|
43425
|
-
throw new DocumentApiValidationError2("
|
|
43468
|
+
assertNoUnknownFields3(input, TEXT_INSERT_ALLOWED_KEYS2, "insert");
|
|
43469
|
+
const { target, ref: ref$1, value, type } = input;
|
|
43470
|
+
if (target !== undefined && ref$1 !== undefined)
|
|
43471
|
+
throw new DocumentApiValidationError2("INVALID_INPUT", 'Insert input must provide either "target" or "ref", not both.', { fields: ["target", "ref"] });
|
|
43472
|
+
if (target !== undefined && !isSelectionTarget2(target))
|
|
43473
|
+
throw new DocumentApiValidationError2("INVALID_TARGET", "target must be a SelectionTarget object.", {
|
|
43426
43474
|
field: "target",
|
|
43427
43475
|
value: target
|
|
43428
43476
|
});
|
|
43477
|
+
if (ref$1 !== undefined && (typeof ref$1 !== "string" || ref$1 === ""))
|
|
43478
|
+
throw new DocumentApiValidationError2("INVALID_TARGET", "ref must be a non-empty string.", {
|
|
43479
|
+
field: "ref",
|
|
43480
|
+
value: ref$1
|
|
43481
|
+
});
|
|
43429
43482
|
if (typeof value !== "string")
|
|
43430
43483
|
throw new DocumentApiValidationError2("INVALID_TARGET", `value must be a string, got ${typeof value}.`, {
|
|
43431
43484
|
field: "value",
|
|
@@ -43455,23 +43508,32 @@ function validateStructuralInsertInput2(input) {
|
|
|
43455
43508
|
validateNestingPolicyValue2(nestingPolicy);
|
|
43456
43509
|
validateDocumentFragment2(content$2);
|
|
43457
43510
|
}
|
|
43458
|
-
function executeInsert2(
|
|
43511
|
+
function executeInsert2(selectionAdapter, writeAdapter, input, options) {
|
|
43459
43512
|
validateInsertInput2(input);
|
|
43460
43513
|
if (isStructuralInsertInput2(input))
|
|
43461
|
-
return
|
|
43462
|
-
const { target, value } = input;
|
|
43514
|
+
return writeAdapter.insertStructured(input, normalizeMutationOptions2(options));
|
|
43515
|
+
const { target, ref: ref$1, value } = input;
|
|
43463
43516
|
if ((input.type ?? "text") !== "text")
|
|
43464
|
-
return
|
|
43517
|
+
return writeAdapter.insertStructured(input, normalizeMutationOptions2(options));
|
|
43465
43518
|
const storyIn = input.in;
|
|
43466
|
-
|
|
43467
|
-
|
|
43468
|
-
|
|
43469
|
-
|
|
43470
|
-
|
|
43471
|
-
|
|
43519
|
+
if (target || ref$1) {
|
|
43520
|
+
const request = target ? {
|
|
43521
|
+
kind: "insert",
|
|
43522
|
+
target,
|
|
43523
|
+
text: value,
|
|
43524
|
+
...storyIn ? { in: storyIn } : {}
|
|
43525
|
+
} : {
|
|
43526
|
+
kind: "insert",
|
|
43527
|
+
ref: ref$1,
|
|
43528
|
+
text: value,
|
|
43529
|
+
...storyIn ? { in: storyIn } : {}
|
|
43530
|
+
};
|
|
43531
|
+
return textReceiptToSDReceipt2(selectionAdapter.execute(request, normalizeMutationOptions2(options)));
|
|
43532
|
+
}
|
|
43533
|
+
return textReceiptToSDReceipt2(executeWrite2(writeAdapter, {
|
|
43472
43534
|
kind: "insert",
|
|
43473
43535
|
text: value,
|
|
43474
|
-
...storyIn ? { in: storyIn } :
|
|
43536
|
+
...storyIn ? { in: storyIn } : {}
|
|
43475
43537
|
}, options));
|
|
43476
43538
|
}
|
|
43477
43539
|
function validateListTarget2(input, operationName) {
|
|
@@ -43634,8 +43696,8 @@ function validateTargetLocator3(input, operation) {
|
|
|
43634
43696
|
field: "target",
|
|
43635
43697
|
value: input.target
|
|
43636
43698
|
});
|
|
43637
|
-
if (hasRef && typeof input.ref !== "string")
|
|
43638
|
-
throw new DocumentApiValidationError2("INVALID_TARGET", "ref must be a string.", {
|
|
43699
|
+
if (hasRef && (typeof input.ref !== "string" || input.ref === ""))
|
|
43700
|
+
throw new DocumentApiValidationError2("INVALID_TARGET", "ref must be a non-empty string.", {
|
|
43639
43701
|
field: "ref",
|
|
43640
43702
|
value: input.ref
|
|
43641
43703
|
});
|
|
@@ -43693,13 +43755,18 @@ function executeReplace2(selectionAdapter, writeAdapter, input, options) {
|
|
|
43693
43755
|
if (isStructuralReplaceInput2(input))
|
|
43694
43756
|
return writeAdapter.replaceStructured(input, normalizeMutationOptions2(options));
|
|
43695
43757
|
const textInput = input;
|
|
43696
|
-
|
|
43758
|
+
const request = textInput.target ? {
|
|
43697
43759
|
kind: "replace",
|
|
43698
43760
|
target: textInput.target,
|
|
43761
|
+
text: textInput.text,
|
|
43762
|
+
in: textInput.in
|
|
43763
|
+
} : {
|
|
43764
|
+
kind: "replace",
|
|
43699
43765
|
ref: textInput.ref,
|
|
43700
43766
|
text: textInput.text,
|
|
43701
43767
|
in: textInput.in
|
|
43702
|
-
}
|
|
43768
|
+
};
|
|
43769
|
+
return textReceiptToSDReceipt2(selectionAdapter.execute(request, normalizeMutationOptions2(options)));
|
|
43703
43770
|
}
|
|
43704
43771
|
function validateTargetOnlyCreateLocation2(at, operationName) {
|
|
43705
43772
|
if (at.kind !== "before" && at.kind !== "after")
|
|
@@ -45832,7 +45899,7 @@ function createDocumentApi2(adapters) {
|
|
|
45832
45899
|
}
|
|
45833
45900
|
},
|
|
45834
45901
|
insert(input, options) {
|
|
45835
|
-
return executeInsert2(adapters.write, input, options);
|
|
45902
|
+
return executeInsert2(adapters.selectionMutation, adapters.write, input, options);
|
|
45836
45903
|
},
|
|
45837
45904
|
replace(input, options) {
|
|
45838
45905
|
return executeReplace2(adapters.selectionMutation, adapters.write, input, options);
|
|
@@ -68715,11 +68782,17 @@ function stableHash(input) {
|
|
|
68715
68782
|
}
|
|
68716
68783
|
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
68717
68784
|
}
|
|
68718
|
-
function
|
|
68785
|
+
function toFallbackEligibleBlockNodeType(nodeType) {
|
|
68719
68786
|
if (nodeType === "table")
|
|
68720
68787
|
return "table";
|
|
68721
68788
|
if (nodeType === "tableCell")
|
|
68722
68789
|
return "tableCell";
|
|
68790
|
+
if (nodeType === "paragraph")
|
|
68791
|
+
return "paragraph";
|
|
68792
|
+
if (nodeType === "heading")
|
|
68793
|
+
return "heading";
|
|
68794
|
+
if (nodeType === "listItem")
|
|
68795
|
+
return "listItem";
|
|
68723
68796
|
}
|
|
68724
68797
|
function serializeTraversalPath(path2, pos) {
|
|
68725
68798
|
if (Array.isArray(path2) && path2.length > 0)
|
|
@@ -68729,11 +68802,11 @@ function serializeTraversalPath(path2, pos) {
|
|
|
68729
68802
|
function isVolatileRuntimeBlockId(id) {
|
|
68730
68803
|
return typeof id === "string" && UUID_LIKE_PATTERN.test(id);
|
|
68731
68804
|
}
|
|
68732
|
-
function
|
|
68733
|
-
const
|
|
68734
|
-
if (!
|
|
68805
|
+
function buildFallbackBlockNodeId(nodeType, pos, path2) {
|
|
68806
|
+
const eligibleType = toFallbackEligibleBlockNodeType(nodeType);
|
|
68807
|
+
if (!eligibleType)
|
|
68735
68808
|
return;
|
|
68736
|
-
return `${
|
|
68809
|
+
return `${FALLBACK_PREFIX[eligibleType]}-${stableHash(`${eligibleType}:${serializeTraversalPath(path2, pos)}`)}`;
|
|
68737
68810
|
}
|
|
68738
68811
|
function isListItem(attrs) {
|
|
68739
68812
|
const numbering = attrs?.paragraphProperties?.numberingProperties;
|
|
@@ -68787,16 +68860,19 @@ function mapBlockNodeType(node3) {
|
|
|
68787
68860
|
function resolveLegacyTableIdentity(attrs) {
|
|
68788
68861
|
return toId(attrs.paraId) ?? toId(attrs.blockId) ?? toId(attrs.id) ?? toId(attrs.uuid);
|
|
68789
68862
|
}
|
|
68790
|
-
function
|
|
68863
|
+
function resolveTableRuntimeIdentity(nodeType, attrs, pos, path2) {
|
|
68791
68864
|
const sdBlockId = toId(attrs.sdBlockId);
|
|
68792
68865
|
if (sdBlockId && !isVolatileRuntimeBlockId(sdBlockId))
|
|
68793
68866
|
return sdBlockId;
|
|
68794
|
-
return
|
|
68867
|
+
return buildFallbackBlockNodeId(nodeType, pos, path2);
|
|
68868
|
+
}
|
|
68869
|
+
function resolveParagraphRuntimeIdentity(nodeType, attrs, pos, path2) {
|
|
68870
|
+
return toId(attrs.sdBlockId) ?? buildFallbackBlockNodeId(nodeType, pos, path2);
|
|
68795
68871
|
}
|
|
68796
68872
|
function resolveBlockNodeId(node3, pos, nodeType, path2) {
|
|
68797
68873
|
if (node3.type.name === "paragraph") {
|
|
68798
68874
|
const attrs$1 = node3.attrs;
|
|
68799
|
-
return toId(attrs$1?.paraId) ??
|
|
68875
|
+
return toId(attrs$1?.paraId) ?? resolveParagraphRuntimeIdentity(nodeType, attrs$1 ?? {}, pos, path2);
|
|
68800
68876
|
}
|
|
68801
68877
|
if (nodeType === "tableOfContents")
|
|
68802
68878
|
return resolvePublicTocNodeId(node3, pos);
|
|
@@ -68805,7 +68881,7 @@ function resolveBlockNodeId(node3, pos, nodeType, path2) {
|
|
|
68805
68881
|
if (typeName === "tableRow")
|
|
68806
68882
|
return toId(attrs.paraId) ?? toId(attrs.sdBlockId) ?? toId(attrs.blockId) ?? toId(attrs.id) ?? toId(attrs.uuid);
|
|
68807
68883
|
if (typeName === "table" || typeName === "tableCell" || typeName === "tableHeader")
|
|
68808
|
-
return resolveLegacyTableIdentity(attrs) ??
|
|
68884
|
+
return resolveLegacyTableIdentity(attrs) ?? resolveTableRuntimeIdentity(nodeType, attrs, pos, path2);
|
|
68809
68885
|
return toId(attrs.blockId) ?? toId(attrs.id) ?? toId(attrs.paraId) ?? toId(attrs.uuid) ?? toId(attrs.sdBlockId);
|
|
68810
68886
|
}
|
|
68811
68887
|
function toBlockAddress(candidate) {
|
|
@@ -68879,23 +68955,15 @@ function findBlockByIdStrict(index2, address2) {
|
|
|
68879
68955
|
throw new DocumentApiAdapterError("TARGET_NOT_FOUND", `Block "${key}" was not found.`, { target: address2 });
|
|
68880
68956
|
return candidate;
|
|
68881
68957
|
}
|
|
68882
|
-
function
|
|
68883
|
-
|
|
68884
|
-
|
|
68885
|
-
return matches$1[0];
|
|
68886
|
-
if (matches$1.length > 1)
|
|
68887
|
-
throw new DocumentApiAdapterError("AMBIGUOUS_TARGET", `Multiple blocks share nodeId "${nodeId}".`, {
|
|
68888
|
-
nodeId,
|
|
68889
|
-
count: matches$1.length
|
|
68890
|
-
});
|
|
68958
|
+
function resolveBlockAlias(index2, nodeId) {
|
|
68959
|
+
if (!index2.byId)
|
|
68960
|
+
return;
|
|
68891
68961
|
const aliasMatches = /* @__PURE__ */ new Map;
|
|
68892
68962
|
for (const [key, candidate] of index2.byId) {
|
|
68893
68963
|
if (!key.endsWith(`:${nodeId}`))
|
|
68894
68964
|
continue;
|
|
68895
68965
|
aliasMatches.set(`${candidate.nodeType}:${candidate.nodeId}`, candidate);
|
|
68896
68966
|
}
|
|
68897
|
-
if (aliasMatches.size === 1)
|
|
68898
|
-
return Array.from(aliasMatches.values())[0];
|
|
68899
68967
|
if (aliasMatches.size > 1)
|
|
68900
68968
|
throw new DocumentApiAdapterError("AMBIGUOUS_TARGET", `Multiple blocks share nodeId "${nodeId}" via aliases.`, {
|
|
68901
68969
|
nodeId,
|
|
@@ -68905,6 +68973,20 @@ function findBlockByNodeIdOnly(index2, nodeId) {
|
|
|
68905
68973
|
nodeId: candidate.nodeId
|
|
68906
68974
|
}))
|
|
68907
68975
|
});
|
|
68976
|
+
return aliasMatches.size === 1 ? Array.from(aliasMatches.values())[0] : undefined;
|
|
68977
|
+
}
|
|
68978
|
+
function findBlockByNodeIdOnly(index2, nodeId) {
|
|
68979
|
+
const matches$1 = index2.candidates.filter((candidate) => candidate.nodeId === nodeId);
|
|
68980
|
+
if (matches$1.length === 1)
|
|
68981
|
+
return matches$1[0];
|
|
68982
|
+
if (matches$1.length > 1)
|
|
68983
|
+
throw new DocumentApiAdapterError("AMBIGUOUS_TARGET", `Multiple blocks share nodeId "${nodeId}".`, {
|
|
68984
|
+
nodeId,
|
|
68985
|
+
count: matches$1.length
|
|
68986
|
+
});
|
|
68987
|
+
const alias = resolveBlockAlias(index2, nodeId);
|
|
68988
|
+
if (alias)
|
|
68989
|
+
return alias;
|
|
68908
68990
|
throw new DocumentApiAdapterError("TARGET_NOT_FOUND", `Block with nodeId "${nodeId}" was not found.`, { nodeId });
|
|
68909
68991
|
}
|
|
68910
68992
|
function isTextBlockCandidate(candidate) {
|
|
@@ -69170,66 +69252,46 @@ function insertParagraphAtEnd(editor, pos, text$2, applyMeta) {
|
|
|
69170
69252
|
editor.dispatch(tr);
|
|
69171
69253
|
}
|
|
69172
69254
|
function resolveWriteTarget(editor, request) {
|
|
69173
|
-
const
|
|
69174
|
-
if (
|
|
69175
|
-
|
|
69176
|
-
|
|
69177
|
-
|
|
69178
|
-
|
|
69179
|
-
|
|
69180
|
-
|
|
69181
|
-
|
|
69182
|
-
|
|
69183
|
-
|
|
69184
|
-
|
|
69185
|
-
|
|
69186
|
-
|
|
69187
|
-
|
|
69188
|
-
|
|
69189
|
-
|
|
69190
|
-
}
|
|
69191
|
-
};
|
|
69192
|
-
return {
|
|
69193
|
-
requestedTarget,
|
|
69194
|
-
effectiveTarget: syntheticTarget,
|
|
69195
|
-
range: syntheticRange,
|
|
69196
|
-
resolution: buildTextMutationResolution({
|
|
69197
|
-
requestedTarget,
|
|
69198
|
-
target: syntheticTarget,
|
|
69199
|
-
range: syntheticRange,
|
|
69200
|
-
text: ""
|
|
69201
|
-
}),
|
|
69202
|
-
structuralEnd: true
|
|
69203
|
-
};
|
|
69204
|
-
}
|
|
69205
|
-
const text$2 = readTextAtResolvedRange(editor, fallback.range);
|
|
69255
|
+
const fallback = resolveDefaultInsertTarget(editor);
|
|
69256
|
+
if (!fallback)
|
|
69257
|
+
return null;
|
|
69258
|
+
if (fallback.kind === "structural-end") {
|
|
69259
|
+
const pos = fallback.insertPos;
|
|
69260
|
+
const syntheticRange = {
|
|
69261
|
+
from: pos,
|
|
69262
|
+
to: pos
|
|
69263
|
+
};
|
|
69264
|
+
const syntheticTarget = {
|
|
69265
|
+
kind: "text",
|
|
69266
|
+
blockId: "",
|
|
69267
|
+
range: {
|
|
69268
|
+
start: 0,
|
|
69269
|
+
end: 0
|
|
69270
|
+
}
|
|
69271
|
+
};
|
|
69206
69272
|
return {
|
|
69207
|
-
requestedTarget,
|
|
69208
|
-
effectiveTarget:
|
|
69209
|
-
range:
|
|
69273
|
+
requestedTarget: undefined,
|
|
69274
|
+
effectiveTarget: syntheticTarget,
|
|
69275
|
+
range: syntheticRange,
|
|
69210
69276
|
resolution: buildTextMutationResolution({
|
|
69211
|
-
requestedTarget,
|
|
69212
|
-
target:
|
|
69213
|
-
range:
|
|
69214
|
-
text:
|
|
69215
|
-
})
|
|
69277
|
+
requestedTarget: undefined,
|
|
69278
|
+
target: syntheticTarget,
|
|
69279
|
+
range: syntheticRange,
|
|
69280
|
+
text: ""
|
|
69281
|
+
}),
|
|
69282
|
+
structuralEnd: true
|
|
69216
69283
|
};
|
|
69217
69284
|
}
|
|
69218
|
-
const
|
|
69219
|
-
if (!target)
|
|
69220
|
-
return null;
|
|
69221
|
-
const range = resolveTextTarget(editor, target);
|
|
69222
|
-
if (!range)
|
|
69223
|
-
return null;
|
|
69285
|
+
const text$2 = readTextAtResolvedRange(editor, fallback.range);
|
|
69224
69286
|
return {
|
|
69225
|
-
requestedTarget,
|
|
69226
|
-
effectiveTarget: target,
|
|
69227
|
-
range,
|
|
69287
|
+
requestedTarget: undefined,
|
|
69288
|
+
effectiveTarget: fallback.target,
|
|
69289
|
+
range: fallback.range,
|
|
69228
69290
|
resolution: buildTextMutationResolution({
|
|
69229
|
-
requestedTarget,
|
|
69230
|
-
target,
|
|
69231
|
-
range,
|
|
69232
|
-
text:
|
|
69291
|
+
requestedTarget: undefined,
|
|
69292
|
+
target: fallback.target,
|
|
69293
|
+
range: fallback.range,
|
|
69294
|
+
text: text$2
|
|
69233
69295
|
})
|
|
69234
69296
|
};
|
|
69235
69297
|
}
|
|
@@ -75030,7 +75092,7 @@ var isRegExp = (value) => {
|
|
|
75030
75092
|
tracked: false,
|
|
75031
75093
|
carrier: runAttributeCarrier2(runPropertyKey ?? key),
|
|
75032
75094
|
schema
|
|
75033
|
-
}), INLINE_PROPERTY_REGISTRY2, INLINE_PROPERTY_KEY_SET2, INLINE_PROPERTY_BY_KEY2, UNDERLINE_OBJECT_ALLOWED_KEYS2, SHADING_ALLOWED_KEYS2, BORDER_ALLOWED_KEYS2, FIT_TEXT_ALLOWED_KEYS2, LANG_ALLOWED_KEYS2, RFONTS_ALLOWED_KEYS2, EAST_ASIAN_LAYOUT_ALLOWED_KEYS2, STYLISTIC_SET_ALLOWED_KEYS2, VERT_ALIGN_VALUES2, PROPERTY_VALIDATOR_MAP2, NONE_FAILURES2, NONE_THROWS2, T_NOT_FOUND2, T_NOT_FOUND_CAPABLE2, T_PLAN_ENGINE2, T_NOT_FOUND_COMMAND2, T_IMAGE_COMMAND2, T_CC_READ2, T_CC_MUTATION2, T_CC_TYPED2, T_CC_TYPED_READ2, T_CC_RAW2, T_QUERY_MATCH2, T_SECTION_CREATE2, T_SECTION_READ2, T_PARAGRAPH_MUTATION2, T_SECTION_MUTATION2, T_SECTION_SETTINGS_MUTATION2, T_HEADER_FOOTER_MUTATION2, T_STORY2, T_REF_READ_LIST2, T_REF_MUTATION2, T_REF_MUTATION_REMOVE2, T_REF_INSERT2, FORMAT_INLINE_ALIAS_OPERATION_DEFINITIONS2, OPERATION_DEFINITIONS2, OPERATION_IDS2, COMMAND_CATALOG3, PARAGRAPH_ALIGNMENTS2, TAB_STOP_ALIGNMENTS2, TAB_STOP_LEADERS2, BORDER_SIDES2, CLEAR_BORDER_SIDES2, LINE_RULES2, PARAGRAPH_DIRECTIONS2, ALIGNMENT_POLICIES2, PARAGRAPH_BLOCK_TYPES2, SET_STYLE_KEYS2, CLEAR_STYLE_KEYS2, RESET_DIRECT_FORMATTING_KEYS2, SET_ALIGNMENT_KEYS2, CLEAR_ALIGNMENT_KEYS2, SET_INDENTATION_KEYS2, CLEAR_INDENTATION_KEYS2, SET_SPACING_KEYS2, CLEAR_SPACING_KEYS2, SET_KEEP_OPTIONS_KEYS2, SET_OUTLINE_LEVEL_KEYS2, SET_FLOW_OPTIONS_KEYS2, SET_TAB_STOP_KEYS2, CLEAR_TAB_STOP_KEYS2, CLEAR_ALL_TAB_STOPS_KEYS2, SET_BORDER_KEYS2, CLEAR_BORDER_KEYS2, SET_SHADING_KEYS2, CLEAR_SHADING_KEYS2, SET_DIRECTION_KEYS2, CLEAR_DIRECTION_KEYS2, ST_ON_OFF_ON_VALUES2, ST_ON_OFF_OFF_VALUES2, ST_UNDERLINE_VALUES2, ST_UNDERLINE_VALUE_SET2, ST_VERTICAL_ALIGN_RUN2, ST_EM2, ST_TEXT_ALIGNMENT2, ST_TEXT_DIRECTION2, ST_TEXTBOX_TIGHT_WRAP2, ST_TEXT_TRANSFORM2, ST_JUSTIFICATION2, FONT_FAMILY_SCHEMA2, COLOR_SCHEMA2, SPACING_SCHEMA2, INDENT_SCHEMA2, UNDERLINE_SCHEMA2, BORDER_PROPERTIES_SCHEMA2, SHADING_SCHEMA2, LANG_SCHEMA2, EAST_ASIAN_LAYOUT_SCHEMA2, FIT_TEXT_SCHEMA2, NUMBERING_PROPERTIES_SCHEMA2, FRAME_PR_SCHEMA2, PARAGRAPH_BORDERS_SCHEMA2, TAB_STOP_SCHEMA2, PROPERTY_REGISTRY2, ALLOWED_KEYS_BY_CHANNEL2, PROPERTY_INDEX2, EXCLUDED_KEYS2, INPUT_ALLOWED_KEYS2, TARGET_ALLOWED_KEYS2, OPTIONS_ALLOWED_KEYS2, VALID_CHANNELS2, Z_ORDER_RELATIVE_HEIGHT_MAX2 = 4294967295, nodeTypeValues2, blockNodeTypeValues2, deletableBlockNodeTypeValues2, inlineNodeTypeValues2, rangeSchema2, textAddressSchema2, textTargetSchema2, blockNodeAddressSchema2, deletableBlockNodeAddressSchema2, tableAddressSchema2, tableRowAddressSchema2, tableCellAddressSchema2, tableOrCellAddressSchema2, paragraphAddressSchema2, headingAddressSchema2, listItemAddressSchema2, paragraphTargetSchema2, sectionAddressSchema2, nodeAddressSchema2, commentAddressSchema2, trackedChangeAddressSchema2, entityAddressSchema2, selectionTargetSchema2, deleteBehaviorSchema2, resolvedHandleSchema2, pageInfoSchema2, receiptSuccessSchema2, textMutationRangeSchema2, textMutationResolutionSchema2, textMutationSuccessSchema2, matchBlockSchema2, storyLocatorSchema2, trackChangeRefSchema2, createParagraphSuccessSchema2, createHeadingSuccessSchema2, headingLevelSchema2, listsInsertSuccessSchema2, listsMutateItemSuccessSchema2, textSelectorSchema2, nodeSelectorSchema2, sdMutationResolutionSchema2, sdMutationSuccessSchema2, documentInfoCountsSchema2, documentInfoOutlineItemSchema2, documentInfoCapabilitiesSchema2, listKindSchema2, listInsertPositionSchema2, sectionBreakTypeSchema2, sectionOrientationSchema2, sectionVerticalAlignSchema2, sectionDirectionSchema2, sectionHeaderFooterKindSchema2, sectionHeaderFooterVariantSchema2, sectionLineNumberRestartSchema2, sectionPageNumberFormatSchema2, sectionRangeDomainSchema2, sectionPageMarginsSchema2, sectionHeaderFooterMarginsSchema2, sectionPageSetupSchema2, sectionColumnsSchema2, sectionLineNumberingSchema2, sectionPageNumberingSchema2, sectionHeaderFooterRefsSchema2, sectionBorderSpecSchema2, sectionPageBordersSchema2, sectionMutationSuccessSchema2, documentMutationSuccessSchema2, paragraphMutationTargetSchema2, paragraphMutationSuccessSchema2, createSectionBreakSuccessSchema2, capabilityReasonsSchema2, capabilityFlagSchema2, operationRuntimeCapabilitySchema2, operationCapabilitiesSchema2, inlinePropertyCapabilitySchema2, formatCapabilitiesSchema2, planEngineCapabilitiesSchema2, nullableTableBorderSpecSchema2, sdFragmentSchema2, placementSchema2, nestingPolicySchema2, tableCreateLocationSchema2, formatInlineAliasOperationSchemas2, tocMutationFailureSchema2, tocMutationSuccessSchema2, tocEntryMutationFailureSchema2, tocEntryMutationSuccessSchema2, hyperlinkTargetSchema2, hyperlinkReadPropertiesSchema2, hyperlinkSpecSchema2, hyperlinkPatchSchema2, hyperlinkDomainSchema2, hyperlinkMutationSuccessSchema2, hyperlinkMutationFailureSchema2, contentControlTargetSchema2, contentControlMutationSuccessSchema2, contentControlMutationFailureSchema2, ccListResultSchema2, ccInfoSchema2, refFailureSchema2, bookmarkAddressSchema2, bookmarkMutation2, footnoteAddressSchema2, footnoteConfigScopeSchema2, footnoteNumberingSchema2, footnoteMutation2, footnoteConfig2, crossRefAddressSchema2, crossRefTargetSchema2, crossRefDisplaySchema2, crossRefMutation2, indexAddressSchema2, indexEntryAddressSchema2, indexConfigSchema2, indexEntryDataSchema2, indexEntryPatchSchema2, indexMutation2, indexEntryMutation2, captionAddressSchema2, captionMutation2, captionConfig2, fieldAddressSchema2, fieldMutation2, citationAddressSchema2, citationSourceAddressSchema2, bibliographyAddressSchema2, citationMutation2, citationSourceMutation2, bibliographyMutation2, citationPersonSchema2, citationSourceFieldsSchema2, tocCreateLocationSchema2, authoritiesAddressSchema2, authorityEntryAddressSchema2, authoritiesConfigSchema2, authorityEntryDataSchema2, authorityEntryPatchSchema2, authoritiesMutation2, authorityEntryMutation2, diffCoverageSchema2, diffSummarySchema2, diffSnapshotSchema2, diffPayloadSchema2, GROUP_METADATA2, STEP_OP_CATALOG_UNFROZEN2, PUBLIC_STEP_OP_CATALOG_UNFROZEN2, PUBLIC_MUTATION_STEP_OP_IDS2, PUBLIC_MUTATION_STEP_OP_SET2, CAPABILITY_REASON_CODES, VALID_EDGE_VALUES2, VALID_EDGE_NODE_TYPES2, VALID_DOCUMENT_EDGES2, VALID_REF_BOUNDARIES2, VALID_ANCHOR_KINDS2, RESOLVE_RANGE_ALLOWED_KEYS2, CREATE_COMMENT_ALLOWED_KEYS2, PATCH_COMMENT_ALLOWED_KEYS2, STYLE_APPLY_INPUT_ALLOWED_KEYS2, INLINE_ALIAS_INPUT_ALLOWED_KEYS2, DELETE_INPUT_ALLOWED_KEYS2, VALID_BEHAVIORS2, CONTENT_KIND_SET2, INLINE_KIND_SET2, LEGACY_TOP_LEVEL_TYPES2,
|
|
75095
|
+
}), INLINE_PROPERTY_REGISTRY2, INLINE_PROPERTY_KEY_SET2, INLINE_PROPERTY_BY_KEY2, UNDERLINE_OBJECT_ALLOWED_KEYS2, SHADING_ALLOWED_KEYS2, BORDER_ALLOWED_KEYS2, FIT_TEXT_ALLOWED_KEYS2, LANG_ALLOWED_KEYS2, RFONTS_ALLOWED_KEYS2, EAST_ASIAN_LAYOUT_ALLOWED_KEYS2, STYLISTIC_SET_ALLOWED_KEYS2, VERT_ALIGN_VALUES2, PROPERTY_VALIDATOR_MAP2, NONE_FAILURES2, NONE_THROWS2, T_NOT_FOUND2, T_NOT_FOUND_CAPABLE2, T_PLAN_ENGINE2, T_NOT_FOUND_COMMAND2, T_IMAGE_COMMAND2, T_CC_READ2, T_CC_MUTATION2, T_CC_TYPED2, T_CC_TYPED_READ2, T_CC_RAW2, T_QUERY_MATCH2, T_SECTION_CREATE2, T_SECTION_READ2, T_PARAGRAPH_MUTATION2, T_SECTION_MUTATION2, T_SECTION_SETTINGS_MUTATION2, T_HEADER_FOOTER_MUTATION2, T_STORY2, T_REF_READ_LIST2, T_REF_MUTATION2, T_REF_MUTATION_REMOVE2, T_REF_INSERT2, FORMAT_INLINE_ALIAS_OPERATION_DEFINITIONS2, OPERATION_DEFINITIONS2, OPERATION_IDS2, COMMAND_CATALOG3, PARAGRAPH_ALIGNMENTS2, TAB_STOP_ALIGNMENTS2, TAB_STOP_LEADERS2, BORDER_SIDES2, CLEAR_BORDER_SIDES2, LINE_RULES2, PARAGRAPH_DIRECTIONS2, ALIGNMENT_POLICIES2, PARAGRAPH_BLOCK_TYPES2, SET_STYLE_KEYS2, CLEAR_STYLE_KEYS2, RESET_DIRECT_FORMATTING_KEYS2, SET_ALIGNMENT_KEYS2, CLEAR_ALIGNMENT_KEYS2, SET_INDENTATION_KEYS2, CLEAR_INDENTATION_KEYS2, SET_SPACING_KEYS2, CLEAR_SPACING_KEYS2, SET_KEEP_OPTIONS_KEYS2, SET_OUTLINE_LEVEL_KEYS2, SET_FLOW_OPTIONS_KEYS2, SET_TAB_STOP_KEYS2, CLEAR_TAB_STOP_KEYS2, CLEAR_ALL_TAB_STOPS_KEYS2, SET_BORDER_KEYS2, CLEAR_BORDER_KEYS2, SET_SHADING_KEYS2, CLEAR_SHADING_KEYS2, SET_DIRECTION_KEYS2, CLEAR_DIRECTION_KEYS2, ST_ON_OFF_ON_VALUES2, ST_ON_OFF_OFF_VALUES2, ST_UNDERLINE_VALUES2, ST_UNDERLINE_VALUE_SET2, ST_VERTICAL_ALIGN_RUN2, ST_EM2, ST_TEXT_ALIGNMENT2, ST_TEXT_DIRECTION2, ST_TEXTBOX_TIGHT_WRAP2, ST_TEXT_TRANSFORM2, ST_JUSTIFICATION2, FONT_FAMILY_SCHEMA2, COLOR_SCHEMA2, SPACING_SCHEMA2, INDENT_SCHEMA2, UNDERLINE_SCHEMA2, BORDER_PROPERTIES_SCHEMA2, SHADING_SCHEMA2, LANG_SCHEMA2, EAST_ASIAN_LAYOUT_SCHEMA2, FIT_TEXT_SCHEMA2, NUMBERING_PROPERTIES_SCHEMA2, FRAME_PR_SCHEMA2, PARAGRAPH_BORDERS_SCHEMA2, TAB_STOP_SCHEMA2, PROPERTY_REGISTRY2, ALLOWED_KEYS_BY_CHANNEL2, PROPERTY_INDEX2, EXCLUDED_KEYS2, INPUT_ALLOWED_KEYS2, TARGET_ALLOWED_KEYS2, OPTIONS_ALLOWED_KEYS2, VALID_CHANNELS2, Z_ORDER_RELATIVE_HEIGHT_MAX2 = 4294967295, nodeTypeValues2, blockNodeTypeValues2, deletableBlockNodeTypeValues2, inlineNodeTypeValues2, rangeSchema2, textAddressSchema2, textTargetSchema2, blockNodeAddressSchema2, deletableBlockNodeAddressSchema2, tableAddressSchema2, tableRowAddressSchema2, tableCellAddressSchema2, tableOrCellAddressSchema2, paragraphAddressSchema2, headingAddressSchema2, listItemAddressSchema2, paragraphTargetSchema2, sectionAddressSchema2, nodeAddressSchema2, commentAddressSchema2, trackedChangeAddressSchema2, entityAddressSchema2, selectionTargetSchema2, deleteBehaviorSchema2, resolvedHandleSchema2, pageInfoSchema2, receiptSuccessSchema2, textMutationRangeSchema2, textMutationResolutionSchema2, textMutationSuccessSchema2, matchBlockSchema2, storyLocatorSchema2, trackChangeRefSchema2, createParagraphSuccessSchema2, createHeadingSuccessSchema2, headingLevelSchema2, listsInsertSuccessSchema2, listsMutateItemSuccessSchema2, textSelectorSchema2, nodeSelectorSchema2, sdMutationResolutionSchema2, sdMutationSuccessSchema2, documentInfoCountsSchema2, documentInfoOutlineItemSchema2, documentInfoCapabilitiesSchema2, listKindSchema2, listInsertPositionSchema2, sectionBreakTypeSchema2, sectionOrientationSchema2, sectionVerticalAlignSchema2, sectionDirectionSchema2, sectionHeaderFooterKindSchema2, sectionHeaderFooterVariantSchema2, sectionLineNumberRestartSchema2, sectionPageNumberFormatSchema2, sectionRangeDomainSchema2, sectionPageMarginsSchema2, sectionHeaderFooterMarginsSchema2, sectionPageSetupSchema2, sectionColumnsSchema2, sectionLineNumberingSchema2, sectionPageNumberingSchema2, sectionHeaderFooterRefsSchema2, sectionBorderSpecSchema2, sectionPageBordersSchema2, sectionMutationSuccessSchema2, documentMutationSuccessSchema2, paragraphMutationTargetSchema2, paragraphMutationSuccessSchema2, createSectionBreakSuccessSchema2, capabilityReasonsSchema2, capabilityFlagSchema2, operationRuntimeCapabilitySchema2, operationCapabilitiesSchema2, inlinePropertyCapabilitySchema2, formatCapabilitiesSchema2, planEngineCapabilitiesSchema2, nullableTableBorderSpecSchema2, sdFragmentSchema2, placementSchema2, nestingPolicySchema2, tableCreateLocationSchema2, formatInlineAliasOperationSchemas2, tocMutationFailureSchema2, tocMutationSuccessSchema2, tocEntryMutationFailureSchema2, tocEntryMutationSuccessSchema2, hyperlinkTargetSchema2, hyperlinkReadPropertiesSchema2, hyperlinkSpecSchema2, hyperlinkPatchSchema2, hyperlinkDomainSchema2, hyperlinkMutationSuccessSchema2, hyperlinkMutationFailureSchema2, contentControlTargetSchema2, contentControlMutationSuccessSchema2, contentControlMutationFailureSchema2, ccListResultSchema2, ccInfoSchema2, refFailureSchema2, bookmarkAddressSchema2, bookmarkMutation2, footnoteAddressSchema2, footnoteConfigScopeSchema2, footnoteNumberingSchema2, footnoteMutation2, footnoteConfig2, crossRefAddressSchema2, crossRefTargetSchema2, crossRefDisplaySchema2, crossRefMutation2, indexAddressSchema2, indexEntryAddressSchema2, indexConfigSchema2, indexEntryDataSchema2, indexEntryPatchSchema2, indexMutation2, indexEntryMutation2, captionAddressSchema2, captionMutation2, captionConfig2, fieldAddressSchema2, fieldMutation2, citationAddressSchema2, citationSourceAddressSchema2, bibliographyAddressSchema2, citationMutation2, citationSourceMutation2, bibliographyMutation2, citationPersonSchema2, citationSourceFieldsSchema2, tocCreateLocationSchema2, authoritiesAddressSchema2, authorityEntryAddressSchema2, authoritiesConfigSchema2, authorityEntryDataSchema2, authorityEntryPatchSchema2, authoritiesMutation2, authorityEntryMutation2, diffCoverageSchema2, diffSummarySchema2, diffSnapshotSchema2, diffPayloadSchema2, GROUP_METADATA2, STEP_OP_CATALOG_UNFROZEN2, PUBLIC_STEP_OP_CATALOG_UNFROZEN2, PUBLIC_MUTATION_STEP_OP_IDS2, PUBLIC_MUTATION_STEP_OP_SET2, CAPABILITY_REASON_CODES, VALID_EDGE_VALUES2, VALID_EDGE_NODE_TYPES2, VALID_DOCUMENT_EDGES2, VALID_REF_BOUNDARIES2, VALID_ANCHOR_KINDS2, RESOLVE_RANGE_ALLOWED_KEYS2, CREATE_COMMENT_ALLOWED_KEYS2, PATCH_COMMENT_ALLOWED_KEYS2, STYLE_APPLY_INPUT_ALLOWED_KEYS2, INLINE_ALIAS_INPUT_ALLOWED_KEYS2, DELETE_INPUT_ALLOWED_KEYS2, VALID_BEHAVIORS2, CONTENT_KIND_SET2, INLINE_KIND_SET2, LEGACY_TOP_LEVEL_TYPES2, TEXT_INSERT_ALLOWED_KEYS2, STRUCTURAL_INSERT_ALLOWED_KEYS2, VALID_INSERT_TYPES2, TEXT_REPLACE_ALLOWED_KEYS2, STRUCTURAL_REPLACE_ALLOWED_KEYS2, SECTION_BREAK_TYPES$1, SUPPORTED_DELETE_NODE_TYPES2, REJECTED_DELETE_NODE_TYPES2, VALID_BLOCK_NODE_TYPES2, SNAPSHOT_VERSION2 = "sd-diff-snapshot/v1", PAYLOAD_VERSION2 = "sd-diff-payload/v1", VALID_STYLE_OPTION_FLAGS2, TABLE_BORDER_COLOR_PATTERN2, VALID_APPLY_TO_VALUES2, VALID_BORDER_EDGE_KEYS2, HEADER_FOOTER_KINDS$1, HEADER_FOOTER_VARIANTS$1, DEFAULT_SECTIONS_LIST_LIMIT2 = 250, SECTION_BREAK_TYPES3, SECTION_ORIENTATIONS2, SECTION_VERTICAL_ALIGNS2, SECTION_DIRECTIONS2, HEADER_FOOTER_KINDS3, HEADER_FOOTER_VARIANTS3, LINE_NUMBER_RESTARTS2, PAGE_NUMBER_FORMATS2, PAGE_BORDER_DISPLAYS2, PAGE_BORDER_OFFSET_FROM_VALUES2, PAGE_BORDER_Z_ORDER_VALUES2, VALID_WRAP_TYPES2, VALID_WRAP_SIDES2, VALID_IMAGE_SIZE_UNITS2, PATCH_FIELDS2, ADAPTER_GATED_PREFIXES2, _buffers, _defaultCollectionId = null, _nextCollectionId = 1, generateV2HandlerEntity = (handlerName, translator$216) => ({
|
|
75034
75096
|
handlerName,
|
|
75035
75097
|
handler: (params) => {
|
|
75036
75098
|
const { nodes } = params;
|
|
@@ -89102,7 +89164,7 @@ var isRegExp = (value) => {
|
|
|
89102
89164
|
candidate = candidate.prev;
|
|
89103
89165
|
}
|
|
89104
89166
|
}
|
|
89105
|
-
}, DocumentApiAdapterError, SectionType, DEFAULT_PARAGRAPH_SECTION_TYPE, DEFAULT_BODY_SECTION_TYPE, TWIPS_PER_INCH = 1440, PX_PER_INCH = 96, DEFAULT_COLUMN_GAP_INCHES = 0.5, DEFAULT_HEADER_FOOTER_MARGIN_PX = 0, CommentMarkName = "commentMark", LINK_MARK_NAME = "link", COMMENT_MARK_NAME, SUPPORTED_INLINE_TYPES,
|
|
89167
|
+
}, DocumentApiAdapterError, SectionType, DEFAULT_PARAGRAPH_SECTION_TYPE, DEFAULT_BODY_SECTION_TYPE, TWIPS_PER_INCH = 1440, PX_PER_INCH = 96, DEFAULT_COLUMN_GAP_INCHES = 0.5, DEFAULT_HEADER_FOOTER_MARGIN_PX = 0, CommentMarkName = "commentMark", LINK_MARK_NAME = "link", COMMENT_MARK_NAME, SUPPORTED_INLINE_TYPES, FALLBACK_PREFIX, UUID_LIKE_PATTERN, ALIAS_ELIGIBLE_TYPES, cacheByEditor, OBJECT_REPLACEMENT_CHAR = "", LINE_NUMBER_RESTART_VALUES, PAGE_NUMBER_FORMAT_VALUES, SECTION_ORIENTATION_VALUES, SECTION_VERTICAL_ALIGN_VALUES, readSectPrHeaderFooterRefs, PIXELS_PER_INCH = 96, DOCUMENT_RELS_PATH = "word/_rels/document.xml.rels", RELS_XMLNS = "http://schemas.openxmlformats.org/package/2006/relationships", HEADER_RELATIONSHIP_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", FOOTER_RELATIONSHIP_TYPE2 = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", WORDPROCESSINGML_XMLNS = "http://schemas.openxmlformats.org/wordprocessingml/2006/main", OFFICE_DOCUMENT_RELS_XMLNS = "http://schemas.openxmlformats.org/officeDocument/2006/relationships", RELATIONSHIP_ID_PATTERN, HEADER_FILE_PATTERN, FOOTER_FILE_PATTERN, SOURCE_HEADER_FOOTER_LOCAL = "header-footer-sync:local", HEADER_PATTERN, FOOTER_PATTERN, DEFAULT_HDR_FTR_ATTRS, HEADER_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/header", FOOTER_REL_TYPE = "http://schemas.openxmlformats.org/officeDocument/2006/relationships/footer", VALID_VARIANTS, FOOTNOTES_PART_ID = "word/footnotes.xml", ENDNOTES_PART_ID = "word/endnotes.xml", FOOTNOTES_CONFIG, ENDNOTES_CONFIG, NOTES_XMLNS, footnotesPartDescriptor, endnotesPartDescriptor, storeByEditor, cacheByHost, hostStoreSyncedKeys, BODY_LOCATOR, findMarkPosition = (doc$2, pos, markName) => {
|
|
89106
89168
|
const $pos = doc$2.resolve(pos);
|
|
89107
89169
|
const parent = $pos.parent;
|
|
89108
89170
|
const start = parent.childAfter($pos.parentOffset);
|
|
@@ -89204,7 +89266,7 @@ var isRegExp = (value) => {
|
|
|
89204
89266
|
state.kern = kernNode.attributes["w:val"];
|
|
89205
89267
|
}
|
|
89206
89268
|
}, SuperConverter;
|
|
89207
|
-
var
|
|
89269
|
+
var init_SuperConverter_C65zRR3r_es = __esm(() => {
|
|
89208
89270
|
init_rolldown_runtime_B2q5OVn9_es();
|
|
89209
89271
|
init_jszip_ChlR43oI_es();
|
|
89210
89272
|
init_xml_js_BtmJ6bNs_es();
|
|
@@ -92352,8 +92414,8 @@ var init_SuperConverter_Cukh7tk8_es = __esm(() => {
|
|
|
92352
92414
|
},
|
|
92353
92415
|
insert: {
|
|
92354
92416
|
memberPath: "insert",
|
|
92355
|
-
description: "Insert content into the document. Two input shapes:
|
|
92356
|
-
expectedResult: "Returns an SDMutationReceipt with applied status; resolution reports
|
|
92417
|
+
description: "Insert content into the document. Two input shapes: text-based (value + type) inserts inline content at a SelectionTarget or ref position within an existing block; structural SDFragment (content) inserts one or more blocks as siblings relative to a BlockNodeAddress target. When target/ref is omitted, content appends at the end of the document. Text mode supports text (default), markdown, and html content types via the `type` field. Structural mode uses `placement` (before/after/insideStart/insideEnd) to position relative to the target block.",
|
|
92418
|
+
expectedResult: "Returns an SDMutationReceipt with applied status; resolution reports the inserted TextAddress for text insertion or a BlockNodeAddress for structural insertion. Receipt reports NO_OP if the insertion point is invalid or content is empty.",
|
|
92357
92419
|
requiresDocumentContext: true,
|
|
92358
92420
|
metadata: mutationOperation2({
|
|
92359
92421
|
idempotency: "non-idempotent",
|
|
@@ -99293,12 +99355,8 @@ var init_SuperConverter_Cukh7tk8_es = __esm(() => {
|
|
|
99293
99355
|
...objectSchema2({ tables: { enum: ["forbid", "allow"] } }),
|
|
99294
99356
|
description: "Controls nesting behavior. tables: 'allow' permits inserting tables inside other tables."
|
|
99295
99357
|
};
|
|
99296
|
-
|
|
99358
|
+
optionalTargetLocatorWithPayload2({
|
|
99297
99359
|
in: storyLocatorSchema2,
|
|
99298
|
-
target: {
|
|
99299
|
-
...textAddressSchema2,
|
|
99300
|
-
description: "Insertion point: {kind:'text', blockId:'...', range:{start, end}}."
|
|
99301
|
-
},
|
|
99302
99360
|
value: {
|
|
99303
99361
|
type: "string",
|
|
99304
99362
|
description: "Text content to insert."
|
|
@@ -103298,10 +103356,11 @@ var init_SuperConverter_Cukh7tk8_es = __esm(() => {
|
|
|
103298
103356
|
"tableOfContents",
|
|
103299
103357
|
"sdt"
|
|
103300
103358
|
]);
|
|
103301
|
-
|
|
103359
|
+
TEXT_INSERT_ALLOWED_KEYS2 = new Set([
|
|
103302
103360
|
"value",
|
|
103303
103361
|
"type",
|
|
103304
103362
|
"target",
|
|
103363
|
+
"ref",
|
|
103305
103364
|
"in"
|
|
103306
103365
|
]);
|
|
103307
103366
|
STRUCTURAL_INSERT_ALLOWED_KEYS2 = new Set([
|
|
@@ -124540,9 +124599,12 @@ var init_SuperConverter_Cukh7tk8_es = __esm(() => {
|
|
|
124540
124599
|
"tab",
|
|
124541
124600
|
"lineBreak"
|
|
124542
124601
|
]);
|
|
124543
|
-
|
|
124602
|
+
FALLBACK_PREFIX = {
|
|
124544
124603
|
table: "table-auto",
|
|
124545
|
-
tableCell: "cell-auto"
|
|
124604
|
+
tableCell: "cell-auto",
|
|
124605
|
+
paragraph: "para-auto",
|
|
124606
|
+
heading: "heading-auto",
|
|
124607
|
+
listItem: "list-auto"
|
|
124546
124608
|
};
|
|
124547
124609
|
UUID_LIKE_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
124548
124610
|
ALIAS_ELIGIBLE_TYPES = new Set([
|
|
@@ -152177,7 +152239,7 @@ var init_remark_gfm_CjV8kaUy_es = __esm(() => {
|
|
|
152177
152239
|
init_remark_gfm_z_sDF4ss_es();
|
|
152178
152240
|
});
|
|
152179
152241
|
|
|
152180
|
-
// ../../packages/superdoc/dist/chunks/src-
|
|
152242
|
+
// ../../packages/superdoc/dist/chunks/src-BrT7SmAZ.es.js
|
|
152181
152243
|
function deleteProps(obj, propOrProps) {
|
|
152182
152244
|
const props = typeof propOrProps === "string" ? [propOrProps] : propOrProps;
|
|
152183
152245
|
const removeNested = (target, pathParts, index2 = 0) => {
|
|
@@ -156292,6 +156354,249 @@ function cellWrapping2($pos) {
|
|
|
156292
156354
|
}
|
|
156293
156355
|
return null;
|
|
156294
156356
|
}
|
|
156357
|
+
function findAncestorDepth($pos, predicate) {
|
|
156358
|
+
for (let depth = $pos.depth;depth > 0; depth -= 1)
|
|
156359
|
+
if (predicate($pos.node(depth)))
|
|
156360
|
+
return depth;
|
|
156361
|
+
return -1;
|
|
156362
|
+
}
|
|
156363
|
+
function findRunDepthWithinParagraph($pos, paragraphDepth) {
|
|
156364
|
+
for (let depth = $pos.depth;depth > paragraphDepth; depth -= 1)
|
|
156365
|
+
if ($pos.node(depth).type.name === "run")
|
|
156366
|
+
return depth;
|
|
156367
|
+
return -1;
|
|
156368
|
+
}
|
|
156369
|
+
function findParagraphDepth($pos) {
|
|
156370
|
+
return findAncestorDepth($pos, (node3) => node3.type.name === "paragraph");
|
|
156371
|
+
}
|
|
156372
|
+
function allInlineMarkersBetween(paragraph2, fromIndex, toIndex) {
|
|
156373
|
+
for (let i4 = fromIndex;i4 < toIndex; i4 += 1) {
|
|
156374
|
+
const child = paragraph2.child(i4);
|
|
156375
|
+
if (child.type.name === "run")
|
|
156376
|
+
return false;
|
|
156377
|
+
if (!child.isInline)
|
|
156378
|
+
return false;
|
|
156379
|
+
if (child.textContent !== "")
|
|
156380
|
+
return false;
|
|
156381
|
+
}
|
|
156382
|
+
return true;
|
|
156383
|
+
}
|
|
156384
|
+
function isAtEffectiveParagraphEnd($head) {
|
|
156385
|
+
const paragraphDepth = findParagraphDepth($head);
|
|
156386
|
+
if (paragraphDepth < 0)
|
|
156387
|
+
return false;
|
|
156388
|
+
const paragraph2 = $head.node(paragraphDepth);
|
|
156389
|
+
if (paragraph2.content.size === 0)
|
|
156390
|
+
return true;
|
|
156391
|
+
if ($head.pos === $head.end(paragraphDepth))
|
|
156392
|
+
return true;
|
|
156393
|
+
const runDepth = findRunDepthWithinParagraph($head, paragraphDepth);
|
|
156394
|
+
if (runDepth < 0)
|
|
156395
|
+
return false;
|
|
156396
|
+
if ($head.pos !== $head.end(runDepth))
|
|
156397
|
+
return false;
|
|
156398
|
+
return allInlineMarkersBetween(paragraph2, $head.index(paragraphDepth) + 1, paragraph2.childCount);
|
|
156399
|
+
}
|
|
156400
|
+
function isAtEffectiveParagraphStart($head) {
|
|
156401
|
+
const paragraphDepth = findParagraphDepth($head);
|
|
156402
|
+
if (paragraphDepth < 0)
|
|
156403
|
+
return false;
|
|
156404
|
+
const paragraph2 = $head.node(paragraphDepth);
|
|
156405
|
+
if (paragraph2.content.size === 0)
|
|
156406
|
+
return true;
|
|
156407
|
+
if ($head.pos === $head.start(paragraphDepth))
|
|
156408
|
+
return true;
|
|
156409
|
+
const runDepth = findRunDepthWithinParagraph($head, paragraphDepth);
|
|
156410
|
+
if (runDepth < 0)
|
|
156411
|
+
return false;
|
|
156412
|
+
if ($head.pos !== $head.start(runDepth))
|
|
156413
|
+
return false;
|
|
156414
|
+
return allInlineMarkersBetween(paragraph2, 0, $head.index(paragraphDepth));
|
|
156415
|
+
}
|
|
156416
|
+
function isInLastParagraphOfCell($head, cellDepth) {
|
|
156417
|
+
return $head.index(cellDepth) === $head.node(cellDepth).childCount - 1;
|
|
156418
|
+
}
|
|
156419
|
+
function isInFirstParagraphOfCell($head, cellDepth) {
|
|
156420
|
+
return $head.index(cellDepth) === 0;
|
|
156421
|
+
}
|
|
156422
|
+
function getTableContext($head) {
|
|
156423
|
+
const cellDepth = findAncestorDepth($head, (node3) => TABLE_CELL_ROLES.has(node3.type.spec.tableRole));
|
|
156424
|
+
if (cellDepth < 0)
|
|
156425
|
+
return null;
|
|
156426
|
+
const tableDepth = findAncestorDepth($head, (node3) => node3.type.spec.tableRole === "table");
|
|
156427
|
+
if (tableDepth < 0)
|
|
156428
|
+
return null;
|
|
156429
|
+
const table2 = $head.node(tableDepth);
|
|
156430
|
+
return {
|
|
156431
|
+
cellDepth,
|
|
156432
|
+
cellStart: $head.before(cellDepth),
|
|
156433
|
+
tableStart: $head.start(tableDepth),
|
|
156434
|
+
tablePos: $head.before(tableDepth),
|
|
156435
|
+
table: table2
|
|
156436
|
+
};
|
|
156437
|
+
}
|
|
156438
|
+
function getCellRect(context) {
|
|
156439
|
+
const map$12 = TableMap.get(context.table);
|
|
156440
|
+
return {
|
|
156441
|
+
map: map$12,
|
|
156442
|
+
rect: map$12.findCell(context.cellStart - context.tableStart)
|
|
156443
|
+
};
|
|
156444
|
+
}
|
|
156445
|
+
function isLastCellInTable(context) {
|
|
156446
|
+
if (!context)
|
|
156447
|
+
return false;
|
|
156448
|
+
const { map: map$12, rect } = getCellRect(context);
|
|
156449
|
+
return rect.right === map$12.width && rect.bottom === map$12.height;
|
|
156450
|
+
}
|
|
156451
|
+
function isFirstCellInTable(context) {
|
|
156452
|
+
if (!context)
|
|
156453
|
+
return false;
|
|
156454
|
+
const { rect } = getCellRect(context);
|
|
156455
|
+
return rect.left === 0 && rect.top === 0;
|
|
156456
|
+
}
|
|
156457
|
+
function findFirstTextPosInNode(node3, nodePos) {
|
|
156458
|
+
if (node3.isText)
|
|
156459
|
+
return nodePos;
|
|
156460
|
+
for (let index2 = 0, offset$1 = 0;index2 < node3.childCount; index2 += 1) {
|
|
156461
|
+
const child = node3.child(index2);
|
|
156462
|
+
const found2 = findFirstTextPosInNode(child, nodePos + 1 + offset$1);
|
|
156463
|
+
if (found2 != null)
|
|
156464
|
+
return found2;
|
|
156465
|
+
offset$1 += child.nodeSize;
|
|
156466
|
+
}
|
|
156467
|
+
return null;
|
|
156468
|
+
}
|
|
156469
|
+
function findLastTextPosInNode(node3, nodePos) {
|
|
156470
|
+
if (node3.isText)
|
|
156471
|
+
return nodePos + (node3.text?.length ?? 0);
|
|
156472
|
+
for (let index2 = node3.childCount - 1, offset$1 = node3.content.size;index2 >= 0; index2 -= 1) {
|
|
156473
|
+
const child = node3.child(index2);
|
|
156474
|
+
offset$1 -= child.nodeSize;
|
|
156475
|
+
const found2 = findLastTextPosInNode(child, nodePos + 1 + offset$1);
|
|
156476
|
+
if (found2 != null)
|
|
156477
|
+
return found2;
|
|
156478
|
+
}
|
|
156479
|
+
return null;
|
|
156480
|
+
}
|
|
156481
|
+
function findFirstTextPosAfterBoundary(state, boundaryPos) {
|
|
156482
|
+
const nextNode = state.doc.resolve(boundaryPos).nodeAfter;
|
|
156483
|
+
if (!nextNode)
|
|
156484
|
+
return null;
|
|
156485
|
+
return findFirstTextPosInNode(nextNode, boundaryPos);
|
|
156486
|
+
}
|
|
156487
|
+
function findLastTextPosBeforeBoundary(state, boundaryPos) {
|
|
156488
|
+
const prevNode = state.doc.resolve(boundaryPos).nodeBefore;
|
|
156489
|
+
if (!prevNode)
|
|
156490
|
+
return null;
|
|
156491
|
+
return findLastTextPosInNode(prevNode, boundaryPos - prevNode.nodeSize);
|
|
156492
|
+
}
|
|
156493
|
+
function findSelectionNearBoundary(state, boundaryPos, dir) {
|
|
156494
|
+
return Selection.findFrom(state.doc.resolve(boundaryPos), dir, true) ?? Selection.near(state.doc.resolve(boundaryPos), dir);
|
|
156495
|
+
}
|
|
156496
|
+
function getDirectionHelpers(dir) {
|
|
156497
|
+
if (dir > 0)
|
|
156498
|
+
return {
|
|
156499
|
+
isAtParagraphBoundary: isAtEffectiveParagraphEnd,
|
|
156500
|
+
isEdgeParagraphInCell: isInLastParagraphOfCell,
|
|
156501
|
+
isEdgeCellInTable: isLastCellInTable,
|
|
156502
|
+
findTextPosAcrossBoundary: findFirstTextPosAfterBoundary,
|
|
156503
|
+
getTableBoundaryPos: (context) => context.tablePos + context.table.nodeSize
|
|
156504
|
+
};
|
|
156505
|
+
return {
|
|
156506
|
+
isAtParagraphBoundary: isAtEffectiveParagraphStart,
|
|
156507
|
+
isEdgeParagraphInCell: isInFirstParagraphOfCell,
|
|
156508
|
+
isEdgeCellInTable: isFirstCellInTable,
|
|
156509
|
+
findTextPosAcrossBoundary: findLastTextPosBeforeBoundary,
|
|
156510
|
+
getTableBoundaryPos: (context) => context.tablePos
|
|
156511
|
+
};
|
|
156512
|
+
}
|
|
156513
|
+
function isInProtectedTrailingTableParagraph(state) {
|
|
156514
|
+
const selection = state.selection;
|
|
156515
|
+
if (!selection.empty)
|
|
156516
|
+
return false;
|
|
156517
|
+
const $head = selection.$head;
|
|
156518
|
+
const paragraphDepth = findParagraphDepth($head);
|
|
156519
|
+
if (paragraphDepth !== 1)
|
|
156520
|
+
return false;
|
|
156521
|
+
const paragraph2 = $head.node(paragraphDepth);
|
|
156522
|
+
if (paragraph2.type.name !== "paragraph" || paragraph2.textContent !== "")
|
|
156523
|
+
return false;
|
|
156524
|
+
const paragraphIndex = $head.index(0);
|
|
156525
|
+
if (paragraphIndex !== state.doc.childCount - 1 || paragraphIndex === 0)
|
|
156526
|
+
return false;
|
|
156527
|
+
return state.doc.child(paragraphIndex - 1)?.type.name === "table";
|
|
156528
|
+
}
|
|
156529
|
+
function getTableBoundaryExitSelection(state, dir) {
|
|
156530
|
+
const selection = state.selection;
|
|
156531
|
+
if (!selection.empty)
|
|
156532
|
+
return null;
|
|
156533
|
+
const context = getTableContext(selection.$head);
|
|
156534
|
+
if (!context)
|
|
156535
|
+
return null;
|
|
156536
|
+
const helpers = getDirectionHelpers(dir);
|
|
156537
|
+
if (!helpers.isEdgeParagraphInCell(selection.$head, context.cellDepth))
|
|
156538
|
+
return null;
|
|
156539
|
+
if (!helpers.isAtParagraphBoundary(selection.$head))
|
|
156540
|
+
return null;
|
|
156541
|
+
if (!helpers.isEdgeCellInTable(context))
|
|
156542
|
+
return null;
|
|
156543
|
+
const boundaryPos = helpers.getTableBoundaryPos(context);
|
|
156544
|
+
const targetPos = helpers.findTextPosAcrossBoundary(state, boundaryPos);
|
|
156545
|
+
if (targetPos != null)
|
|
156546
|
+
return TextSelection2.create(state.doc, targetPos);
|
|
156547
|
+
return findSelectionNearBoundary(state, boundaryPos, dir);
|
|
156548
|
+
}
|
|
156549
|
+
function getAdjacentTableEntrySelection(state, dir) {
|
|
156550
|
+
const selection = state.selection;
|
|
156551
|
+
if (!selection.empty)
|
|
156552
|
+
return null;
|
|
156553
|
+
const $head = selection.$head;
|
|
156554
|
+
const paragraphDepth = findParagraphDepth($head);
|
|
156555
|
+
if (paragraphDepth < 0)
|
|
156556
|
+
return null;
|
|
156557
|
+
if (!getDirectionHelpers(dir).isAtParagraphBoundary($head))
|
|
156558
|
+
return null;
|
|
156559
|
+
const boundaryPos = dir > 0 ? $head.end(paragraphDepth) + 1 : $head.start(paragraphDepth) - 1;
|
|
156560
|
+
const $boundary = state.doc.resolve(boundaryPos);
|
|
156561
|
+
const adjacentNode = dir > 0 ? $boundary.nodeAfter : $boundary.nodeBefore;
|
|
156562
|
+
if (!adjacentNode || adjacentNode.type.spec.tableRole !== "table")
|
|
156563
|
+
return null;
|
|
156564
|
+
if (dir > 0) {
|
|
156565
|
+
const targetPos$1 = findFirstTextPosInNode(adjacentNode, boundaryPos);
|
|
156566
|
+
if (targetPos$1 != null)
|
|
156567
|
+
return TextSelection2.create(state.doc, targetPos$1);
|
|
156568
|
+
return findSelectionNearBoundary(state, boundaryPos, 1);
|
|
156569
|
+
}
|
|
156570
|
+
const tablePos = boundaryPos - adjacentNode.nodeSize;
|
|
156571
|
+
const targetPos = findLastTextPosInNode(adjacentNode, tablePos);
|
|
156572
|
+
if (targetPos != null)
|
|
156573
|
+
return TextSelection2.create(state.doc, targetPos);
|
|
156574
|
+
return findSelectionNearBoundary(state, tablePos + adjacentNode.nodeSize, -1);
|
|
156575
|
+
}
|
|
156576
|
+
function createTableBoundaryNavigationPlugin() {
|
|
156577
|
+
return new Plugin({
|
|
156578
|
+
key: TableBoundaryNavigationPluginKey,
|
|
156579
|
+
props: { handleKeyDown(view, event) {
|
|
156580
|
+
if (event.defaultPrevented)
|
|
156581
|
+
return false;
|
|
156582
|
+
if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey)
|
|
156583
|
+
return false;
|
|
156584
|
+
if ((event.key === "Backspace" || event.key === "Delete") && isInProtectedTrailingTableParagraph(view.state)) {
|
|
156585
|
+
event.preventDefault();
|
|
156586
|
+
return true;
|
|
156587
|
+
}
|
|
156588
|
+
const dir = event.key === "ArrowRight" ? 1 : event.key === "ArrowLeft" ? -1 : 0;
|
|
156589
|
+
if (!dir)
|
|
156590
|
+
return false;
|
|
156591
|
+
const nextSelection = getTableBoundaryExitSelection(view.state, dir) ?? getAdjacentTableEntrySelection(view.state, dir);
|
|
156592
|
+
if (!nextSelection)
|
|
156593
|
+
return false;
|
|
156594
|
+
view.dispatch(view.state.tr.setSelection(nextSelection).scrollIntoView());
|
|
156595
|
+
event.preventDefault();
|
|
156596
|
+
return true;
|
|
156597
|
+
} }
|
|
156598
|
+
});
|
|
156599
|
+
}
|
|
156295
156600
|
function toggleHeaderRow(state, dispatch) {
|
|
156296
156601
|
const target = resolveTarget2(state);
|
|
156297
156602
|
if (!target)
|
|
@@ -156614,20 +156919,61 @@ function insertRowAtIndex({ tr, tablePos, tableNode, sourceRowIndex, insertIndex
|
|
|
156614
156919
|
}
|
|
156615
156920
|
return true;
|
|
156616
156921
|
}
|
|
156617
|
-
function tableSeparatorNeeds(doc$12, pos) {
|
|
156618
|
-
const
|
|
156619
|
-
|
|
156922
|
+
function tableSeparatorNeeds(doc$12, pos, replaceRange2 = {}) {
|
|
156923
|
+
const boundaryBefore = replaceRange2.from ?? pos;
|
|
156924
|
+
const boundaryAfter = replaceRange2.to ?? pos;
|
|
156925
|
+
const $before = doc$12.resolve(boundaryBefore);
|
|
156926
|
+
const $after = doc$12.resolve(boundaryAfter);
|
|
156927
|
+
if ($before.depth !== 0 || $after.depth !== 0)
|
|
156620
156928
|
return {
|
|
156621
156929
|
before: false,
|
|
156622
156930
|
after: false
|
|
156623
156931
|
};
|
|
156624
|
-
const
|
|
156625
|
-
const
|
|
156932
|
+
const beforeIndex = $before.index(0);
|
|
156933
|
+
const afterIndex = $after.index(0);
|
|
156934
|
+
const nodeBefore = beforeIndex > 0 ? doc$12.child(beforeIndex - 1) : null;
|
|
156935
|
+
const nodeAfter = afterIndex < doc$12.childCount ? doc$12.child(afterIndex) : null;
|
|
156626
156936
|
return {
|
|
156627
|
-
before:
|
|
156937
|
+
before: nodeBefore?.type.name === "table",
|
|
156628
156938
|
after: !nodeAfter || nodeAfter.type.name === "table"
|
|
156629
156939
|
};
|
|
156630
156940
|
}
|
|
156941
|
+
function createTableSeparatorParagraph(schema) {
|
|
156942
|
+
const attrs = {
|
|
156943
|
+
sdBlockId: v4_default(),
|
|
156944
|
+
paraId: generateDocxHexId()
|
|
156945
|
+
};
|
|
156946
|
+
return schema.nodes.paragraph.createAndFill(attrs);
|
|
156947
|
+
}
|
|
156948
|
+
function insertTopLevelTableWithSeparators(tr, doc$12, pos, tableNode, replaceRange2 = {}) {
|
|
156949
|
+
const replaceFrom = replaceRange2.from ?? pos;
|
|
156950
|
+
const replaceTo = replaceRange2.to ?? pos;
|
|
156951
|
+
const sep = tableSeparatorNeeds(doc$12, pos, replaceRange2);
|
|
156952
|
+
if (!sep.before && !sep.after) {
|
|
156953
|
+
tr.replaceWith(replaceFrom, replaceTo, tableNode);
|
|
156954
|
+
return { inserted: true };
|
|
156955
|
+
}
|
|
156956
|
+
const nodes = [];
|
|
156957
|
+
if (sep.before) {
|
|
156958
|
+
const before = createTableSeparatorParagraph(doc$12.type.schema);
|
|
156959
|
+
if (!before)
|
|
156960
|
+
return { inserted: false };
|
|
156961
|
+
nodes.push(before);
|
|
156962
|
+
}
|
|
156963
|
+
nodes.push(tableNode);
|
|
156964
|
+
if (sep.after) {
|
|
156965
|
+
const after = createTableSeparatorParagraph(doc$12.type.schema);
|
|
156966
|
+
if (!after)
|
|
156967
|
+
return { inserted: false };
|
|
156968
|
+
nodes.push(after);
|
|
156969
|
+
}
|
|
156970
|
+
tr.replaceWith(replaceFrom, replaceTo, Fragment.from(nodes));
|
|
156971
|
+
return { inserted: true };
|
|
156972
|
+
}
|
|
156973
|
+
function getFirstTableCellTextPos(tablePos, tableNode) {
|
|
156974
|
+
const map$12 = TableMap.get(tableNode);
|
|
156975
|
+
return tablePos + 1 + map$12.map[0] + 2;
|
|
156976
|
+
}
|
|
156631
156977
|
function getCellType({ node: node3, state }) {
|
|
156632
156978
|
return tableNodeTypes(state.schema)[node3.type.spec.tableRole];
|
|
156633
156979
|
}
|
|
@@ -168708,7 +169054,7 @@ function getAdjacentLineClientTarget(editor, coords, direction) {
|
|
|
168708
169054
|
const currentLine = findLineElementAtPoint(doc$12, caretX, coords.clientY + coords.height / 2);
|
|
168709
169055
|
if (!currentLine)
|
|
168710
169056
|
return null;
|
|
168711
|
-
const adjacentLine = findAdjacentLineElement(currentLine, direction);
|
|
169057
|
+
const adjacentLine = findAdjacentLineElement(currentLine, direction, caretX);
|
|
168712
169058
|
if (!adjacentLine)
|
|
168713
169059
|
return null;
|
|
168714
169060
|
const pageEl = adjacentLine.closest?.(`.${DOM_CLASS_NAMES.PAGE}`);
|
|
@@ -168753,33 +169099,17 @@ function findLineElementAtPoint(doc$12, x, y$1) {
|
|
|
168753
169099
|
return el;
|
|
168754
169100
|
return null;
|
|
168755
169101
|
}
|
|
168756
|
-
function findAdjacentLineElement(currentLine, direction) {
|
|
168757
|
-
const lineClass = DOM_CLASS_NAMES.LINE;
|
|
168758
|
-
const fragmentClass = DOM_CLASS_NAMES.FRAGMENT;
|
|
169102
|
+
function findAdjacentLineElement(currentLine, direction, caretX) {
|
|
168759
169103
|
const pageClass = DOM_CLASS_NAMES.PAGE;
|
|
168760
|
-
const headerClass = "superdoc-page-header";
|
|
168761
|
-
const footerClass = "superdoc-page-footer";
|
|
168762
|
-
const fragment2 = currentLine.closest?.(`.${fragmentClass}`);
|
|
168763
169104
|
const page = currentLine.closest?.(`.${pageClass}`);
|
|
168764
|
-
if (!
|
|
169105
|
+
if (!page)
|
|
168765
169106
|
return null;
|
|
168766
|
-
const
|
|
168767
|
-
|
|
168768
|
-
|
|
168769
|
-
|
|
168770
|
-
|
|
168771
|
-
|
|
168772
|
-
}
|
|
168773
|
-
const fragments = Array.from(page.querySelectorAll(`.${fragmentClass}`)).filter((frag) => {
|
|
168774
|
-
return !frag.closest?.(`.${headerClass}, .${footerClass}`);
|
|
168775
|
-
});
|
|
168776
|
-
const fragmentIndex = fragments.indexOf(fragment2);
|
|
168777
|
-
if (fragmentIndex !== -1) {
|
|
168778
|
-
const nextFragment = fragments[fragmentIndex + direction];
|
|
168779
|
-
const fallbackLine = getEdgeLineFromFragment(nextFragment, direction);
|
|
168780
|
-
if (fallbackLine)
|
|
168781
|
-
return fallbackLine;
|
|
168782
|
-
}
|
|
169107
|
+
const currentLineMetrics = getLineMetrics(currentLine);
|
|
169108
|
+
if (!currentLineMetrics)
|
|
169109
|
+
return null;
|
|
169110
|
+
const adjacentOnCurrentPage = findClosestLineInDirection(getPageLineElements(page), currentLine, currentLineMetrics, direction, caretX);
|
|
169111
|
+
if (adjacentOnCurrentPage)
|
|
169112
|
+
return adjacentOnCurrentPage;
|
|
168783
169113
|
const pages = Array.from(page.parentElement?.querySelectorAll?.(`.${pageClass}`) ?? []);
|
|
168784
169114
|
const pageIndex = pages.indexOf(page);
|
|
168785
169115
|
if (pageIndex === -1)
|
|
@@ -168787,12 +169117,7 @@ function findAdjacentLineElement(currentLine, direction) {
|
|
|
168787
169117
|
const nextPage = pages[pageIndex + direction];
|
|
168788
169118
|
if (!nextPage)
|
|
168789
169119
|
return null;
|
|
168790
|
-
|
|
168791
|
-
return !frag.closest?.(`.${headerClass}, .${footerClass}`);
|
|
168792
|
-
});
|
|
168793
|
-
if (direction > 0)
|
|
168794
|
-
return getEdgeLineFromFragment(pageFragments[0], direction);
|
|
168795
|
-
return getEdgeLineFromFragment(pageFragments[pageFragments.length - 1], direction);
|
|
169120
|
+
return findEdgeLineForPage(getPageLineElements(nextPage), direction, caretX);
|
|
168796
169121
|
}
|
|
168797
169122
|
function resolvePositionAtGoalX(editor, pmStart, pmEnd, goalX) {
|
|
168798
169123
|
const presentationEditor = editor.presentationEditor;
|
|
@@ -168821,13 +169146,105 @@ function resolvePositionAtGoalX(editor, pmStart, pmEnd, goalX) {
|
|
|
168821
169146
|
}
|
|
168822
169147
|
return { pos: bestPos };
|
|
168823
169148
|
}
|
|
168824
|
-
function
|
|
168825
|
-
|
|
169149
|
+
function getPageLineElements(page) {
|
|
169150
|
+
const fragmentClass = DOM_CLASS_NAMES.FRAGMENT;
|
|
169151
|
+
const lineClass = DOM_CLASS_NAMES.LINE;
|
|
169152
|
+
const headerClass = "superdoc-page-header";
|
|
169153
|
+
const footerClass = "superdoc-page-footer";
|
|
169154
|
+
return Array.from(page.querySelectorAll(`.${fragmentClass}`)).filter((fragment2) => !fragment2.closest?.(`.${headerClass}, .${footerClass}`)).flatMap((fragment2) => Array.from(fragment2.querySelectorAll(`.${lineClass}`)));
|
|
169155
|
+
}
|
|
169156
|
+
function findClosestLineInDirection(lineEls, currentLine, currentMetrics, direction, caretX) {
|
|
169157
|
+
const directionalCandidates = lineEls.filter((line) => line !== currentLine).map((line) => ({
|
|
169158
|
+
line,
|
|
169159
|
+
metrics: getLineMetrics(line)
|
|
169160
|
+
})).filter(({ metrics }) => metrics && isLineInDirection(metrics.centerY, currentMetrics.centerY, direction));
|
|
169161
|
+
if (directionalCandidates.length === 0)
|
|
168826
169162
|
return null;
|
|
168827
|
-
const
|
|
168828
|
-
|
|
169163
|
+
const nearestVerticalDistance = directionalCandidates.reduce((minDistance, { metrics }) => {
|
|
169164
|
+
const distance = Math.abs(metrics.centerY - currentMetrics.centerY);
|
|
169165
|
+
return Math.min(minDistance, distance);
|
|
169166
|
+
}, Infinity);
|
|
169167
|
+
const targetRowCenterY = directionalCandidates.filter(({ metrics }) => isWithinTolerance(Math.abs(metrics.centerY - currentMetrics.centerY), nearestVerticalDistance, 1)).reduce((bestCenterY, { metrics }) => {
|
|
169168
|
+
if (bestCenterY == null)
|
|
169169
|
+
return metrics.centerY;
|
|
169170
|
+
return direction > 0 ? Math.min(bestCenterY, metrics.centerY) : Math.max(bestCenterY, metrics.centerY);
|
|
169171
|
+
}, null);
|
|
169172
|
+
if (!Number.isFinite(targetRowCenterY))
|
|
168829
169173
|
return null;
|
|
168830
|
-
return
|
|
169174
|
+
return chooseLineClosestToX(directionalCandidates.filter(({ metrics }) => isWithinTolerance(metrics.centerY, targetRowCenterY, getRowTolerance(currentMetrics, metrics))), caretX);
|
|
169175
|
+
}
|
|
169176
|
+
function findEdgeLineForPage(lineEls, direction, caretX) {
|
|
169177
|
+
const candidates = lineEls.map((line) => ({
|
|
169178
|
+
line,
|
|
169179
|
+
metrics: getLineMetrics(line)
|
|
169180
|
+
})).filter(({ metrics }) => metrics);
|
|
169181
|
+
if (candidates.length === 0)
|
|
169182
|
+
return null;
|
|
169183
|
+
const targetRowCenterY = candidates.reduce((edgeCenterY, { metrics }) => {
|
|
169184
|
+
if (edgeCenterY == null)
|
|
169185
|
+
return metrics.centerY;
|
|
169186
|
+
return direction > 0 ? Math.min(edgeCenterY, metrics.centerY) : Math.max(edgeCenterY, metrics.centerY);
|
|
169187
|
+
}, null);
|
|
169188
|
+
if (!Number.isFinite(targetRowCenterY))
|
|
169189
|
+
return null;
|
|
169190
|
+
return chooseLineClosestToX(candidates.filter(({ metrics }) => isWithinTolerance(metrics.centerY, targetRowCenterY, Math.max(metrics.height / 2, 1))), caretX);
|
|
169191
|
+
}
|
|
169192
|
+
function chooseLineClosestToX(candidates, caretX) {
|
|
169193
|
+
if (candidates.length === 0)
|
|
169194
|
+
return null;
|
|
169195
|
+
let best = null;
|
|
169196
|
+
for (const candidate of candidates) {
|
|
169197
|
+
const horizontalDistance = getHorizontalDistanceToLine(candidate.metrics, caretX);
|
|
169198
|
+
const centerDistance = Math.abs(candidate.metrics.centerX - caretX);
|
|
169199
|
+
if (!best || horizontalDistance < best.horizontalDistance || horizontalDistance === best.horizontalDistance && centerDistance < best.centerDistance)
|
|
169200
|
+
best = {
|
|
169201
|
+
line: candidate.line,
|
|
169202
|
+
horizontalDistance,
|
|
169203
|
+
centerDistance
|
|
169204
|
+
};
|
|
169205
|
+
}
|
|
169206
|
+
return best?.line ?? null;
|
|
169207
|
+
}
|
|
169208
|
+
function getLineMetrics(line) {
|
|
169209
|
+
const rect = line?.getBoundingClientRect?.();
|
|
169210
|
+
if (!rect)
|
|
169211
|
+
return null;
|
|
169212
|
+
const { top: top$1, bottom: bottom$1, left: left$1, right: right$1, height, width } = rect;
|
|
169213
|
+
if (![
|
|
169214
|
+
top$1,
|
|
169215
|
+
bottom$1,
|
|
169216
|
+
left$1,
|
|
169217
|
+
right$1,
|
|
169218
|
+
height,
|
|
169219
|
+
width
|
|
169220
|
+
].every(Number.isFinite))
|
|
169221
|
+
return null;
|
|
169222
|
+
return {
|
|
169223
|
+
top: top$1,
|
|
169224
|
+
bottom: bottom$1,
|
|
169225
|
+
left: left$1,
|
|
169226
|
+
right: right$1,
|
|
169227
|
+
height,
|
|
169228
|
+
centerX: left$1 + width / 2,
|
|
169229
|
+
centerY: top$1 + height / 2
|
|
169230
|
+
};
|
|
169231
|
+
}
|
|
169232
|
+
function isLineInDirection(lineCenterY, currentCenterY, direction) {
|
|
169233
|
+
const epsilon = 1;
|
|
169234
|
+
return direction > 0 ? lineCenterY > currentCenterY + epsilon : lineCenterY < currentCenterY - epsilon;
|
|
169235
|
+
}
|
|
169236
|
+
function isWithinTolerance(value, expected, tolerance) {
|
|
169237
|
+
return Math.abs(value - expected) <= tolerance;
|
|
169238
|
+
}
|
|
169239
|
+
function getRowTolerance(currentMetrics, candidateMetrics) {
|
|
169240
|
+
return Math.max(Math.min(currentMetrics.height, candidateMetrics.height) / 2, 1);
|
|
169241
|
+
}
|
|
169242
|
+
function getHorizontalDistanceToLine(metrics, caretX) {
|
|
169243
|
+
if (caretX < metrics.left)
|
|
169244
|
+
return metrics.left - caretX;
|
|
169245
|
+
if (caretX > metrics.right)
|
|
169246
|
+
return caretX - metrics.right;
|
|
169247
|
+
return 0;
|
|
168831
169248
|
}
|
|
168832
169249
|
function getAttributesDiff(objectA = {}, objectB = {}, ignoreKeys = []) {
|
|
168833
169250
|
const diff = {
|
|
@@ -175538,7 +175955,16 @@ function findTextBlockByNodeId(index2, nodeId) {
|
|
|
175538
175955
|
blockId: nodeId,
|
|
175539
175956
|
matchCount: matches2.length
|
|
175540
175957
|
});
|
|
175541
|
-
|
|
175958
|
+
if (matches2.length === 1)
|
|
175959
|
+
return matches2[0];
|
|
175960
|
+
try {
|
|
175961
|
+
const resolved = findBlockByNodeIdOnly(index2, nodeId);
|
|
175962
|
+
if (isTextBlockCandidate(resolved))
|
|
175963
|
+
return resolved;
|
|
175964
|
+
} catch (e) {
|
|
175965
|
+
if (e instanceof DocumentApiAdapterError && e.code === "AMBIGUOUS_TARGET")
|
|
175966
|
+
throw e;
|
|
175967
|
+
}
|
|
175542
175968
|
}
|
|
175543
175969
|
function findBlockByTypeAndId(index2, nodeType, nodeId) {
|
|
175544
175970
|
const key$1 = `${nodeType}:${nodeId}`;
|
|
@@ -175547,7 +175973,15 @@ function findBlockByTypeAndId(index2, nodeType, nodeId) {
|
|
|
175547
175973
|
nodeType,
|
|
175548
175974
|
nodeId
|
|
175549
175975
|
});
|
|
175550
|
-
|
|
175976
|
+
const exact = index2.byId.get(key$1);
|
|
175977
|
+
if (exact)
|
|
175978
|
+
return exact;
|
|
175979
|
+
try {
|
|
175980
|
+
return findBlockByNodeIdOnly(index2, nodeId);
|
|
175981
|
+
} catch (e) {
|
|
175982
|
+
if (e instanceof DocumentApiAdapterError && e.code === "AMBIGUOUS_TARGET")
|
|
175983
|
+
throw e;
|
|
175984
|
+
}
|
|
175551
175985
|
}
|
|
175552
175986
|
function expandDeleteSelection(editor, absFrom, absTo, start$1, end$1) {
|
|
175553
175987
|
if (absFrom === absTo)
|
|
@@ -175987,7 +176421,13 @@ function resolveTextRef(editor, index2, step3, ref$1) {
|
|
|
175987
176421
|
return resolveV3TextRef(editor, index2, step3, decoded);
|
|
175988
176422
|
}
|
|
175989
176423
|
function resolveBlockRef(editor, index2, step3, ref$1) {
|
|
175990
|
-
const
|
|
176424
|
+
const primaryMatches = index2.candidates.filter((c) => c.nodeId === ref$1);
|
|
176425
|
+
if (primaryMatches.length > 1)
|
|
176426
|
+
throw planError("AMBIGUOUS_TARGET", `Multiple blocks share nodeId "${ref$1}".`, step3.id, {
|
|
176427
|
+
ref: ref$1,
|
|
176428
|
+
count: primaryMatches.length
|
|
176429
|
+
});
|
|
176430
|
+
const candidate = primaryMatches[0] ?? resolveBlockAlias(index2, ref$1);
|
|
175991
176431
|
if (!candidate)
|
|
175992
176432
|
return [];
|
|
175993
176433
|
const blockText = getBlockText(editor, candidate);
|
|
@@ -178396,6 +178836,18 @@ function resolveMutationStory(context) {
|
|
|
178396
178836
|
const effectiveTargetStory = context.target?.story ?? storyFromRef;
|
|
178397
178837
|
return resolveStoryFromInput({ in: context.in }, effectiveTargetStory ? { story: effectiveTargetStory } : undefined);
|
|
178398
178838
|
}
|
|
178839
|
+
function nodeEdgeAfterOffset(editor, nodeType, nodeId) {
|
|
178840
|
+
const index2 = getBlockIndex(editor);
|
|
178841
|
+
const key$1 = `${nodeType}:${nodeId}`;
|
|
178842
|
+
const block = index2.byId.get(key$1);
|
|
178843
|
+
if (!block || !block.node.isTextblock)
|
|
178844
|
+
return 0;
|
|
178845
|
+
const contentStart = block.pos + 1;
|
|
178846
|
+
const contentEnd = block.end - 1;
|
|
178847
|
+
if (contentEnd <= contentStart)
|
|
178848
|
+
return 0;
|
|
178849
|
+
return editor.state.doc.textBetween(contentStart, contentEnd, "", "").length;
|
|
178850
|
+
}
|
|
178399
178851
|
function editorHasDom(editor) {
|
|
178400
178852
|
const opts = editor.options;
|
|
178401
178853
|
return !!(opts?.document ?? opts?.mockDocument ?? (typeof document !== "undefined" ? document : null));
|
|
@@ -178466,31 +178918,6 @@ function toTextAddress$1(target) {
|
|
|
178466
178918
|
}
|
|
178467
178919
|
};
|
|
178468
178920
|
}
|
|
178469
|
-
function normalizeWriteLocator(request) {
|
|
178470
|
-
const hasBlockId = request.blockId !== undefined;
|
|
178471
|
-
const hasOffset = request.offset !== undefined;
|
|
178472
|
-
if (hasOffset && request.target)
|
|
178473
|
-
throw new DocumentApiAdapterError("INVALID_TARGET", "Cannot combine target with offset on insert request.", { fields: ["target", "offset"] });
|
|
178474
|
-
if (hasOffset && !hasBlockId)
|
|
178475
|
-
throw new DocumentApiAdapterError("INVALID_TARGET", "offset requires blockId on insert request.", { fields: ["offset", "blockId"] });
|
|
178476
|
-
if (!hasBlockId)
|
|
178477
|
-
return request;
|
|
178478
|
-
if (request.target)
|
|
178479
|
-
throw new DocumentApiAdapterError("INVALID_TARGET", "Cannot combine target with blockId on insert request.", { fields: ["target", "blockId"] });
|
|
178480
|
-
const effectiveOffset = request.offset ?? 0;
|
|
178481
|
-
return {
|
|
178482
|
-
kind: "insert",
|
|
178483
|
-
target: {
|
|
178484
|
-
kind: "text",
|
|
178485
|
-
blockId: request.blockId,
|
|
178486
|
-
range: {
|
|
178487
|
-
start: effectiveOffset,
|
|
178488
|
-
end: effectiveOffset
|
|
178489
|
-
}
|
|
178490
|
-
},
|
|
178491
|
-
text: request.text
|
|
178492
|
-
};
|
|
178493
|
-
}
|
|
178494
178921
|
function mapPlanReceiptToTextReceipt(_receipt, resolution) {
|
|
178495
178922
|
return {
|
|
178496
178923
|
success: true,
|
|
@@ -178547,11 +178974,10 @@ function writeWrapper(editor, request, options) {
|
|
|
178547
178974
|
const runtime = resolveWriteStoryRuntime(editor, request.in);
|
|
178548
178975
|
try {
|
|
178549
178976
|
const storyEditor = runtime.editor;
|
|
178550
|
-
const
|
|
178551
|
-
const resolved = resolveWriteTarget(storyEditor, normalizedRequest);
|
|
178977
|
+
const resolved = resolveWriteTarget(storyEditor, request);
|
|
178552
178978
|
if (!resolved)
|
|
178553
|
-
throw new DocumentApiAdapterError("TARGET_NOT_FOUND", "Mutation target could not be resolved.", {
|
|
178554
|
-
const validationFailure = validateWriteRequest(
|
|
178979
|
+
throw new DocumentApiAdapterError("TARGET_NOT_FOUND", "Mutation target could not be resolved.", {});
|
|
178980
|
+
const validationFailure = validateWriteRequest(request, resolved);
|
|
178555
178981
|
if (validationFailure)
|
|
178556
178982
|
return {
|
|
178557
178983
|
success: false,
|
|
@@ -178568,7 +178994,7 @@ function writeWrapper(editor, request, options) {
|
|
|
178568
178994
|
};
|
|
178569
178995
|
if (resolved.structuralEnd) {
|
|
178570
178996
|
const insertPos = resolved.range.from;
|
|
178571
|
-
const text5 =
|
|
178997
|
+
const text5 = request.text ?? "";
|
|
178572
178998
|
const receipt$1 = executeDomainCommand(storyEditor, () => {
|
|
178573
178999
|
insertParagraphAtEnd(storyEditor, insertPos, text5, mode === "tracked" ? applyTrackedMutationMeta : applyDirectMutationMeta);
|
|
178574
179000
|
return true;
|
|
@@ -178586,7 +179012,7 @@ function writeWrapper(editor, request, options) {
|
|
|
178586
179012
|
where: STUB_WHERE,
|
|
178587
179013
|
args: {
|
|
178588
179014
|
position: "before",
|
|
178589
|
-
content: { text:
|
|
179015
|
+
content: { text: request.text ?? "" }
|
|
178590
179016
|
}
|
|
178591
179017
|
},
|
|
178592
179018
|
targets: [toCompiledTarget(stepId, "text.insert", resolved)]
|
|
@@ -178648,6 +179074,16 @@ function buildSelectionStepDef(stepId, request, where) {
|
|
|
178648
179074
|
style: { inline: { mode: "preserve" } }
|
|
178649
179075
|
}
|
|
178650
179076
|
};
|
|
179077
|
+
case "insert":
|
|
179078
|
+
return {
|
|
179079
|
+
id: stepId,
|
|
179080
|
+
op: "text.insert",
|
|
179081
|
+
where,
|
|
179082
|
+
args: {
|
|
179083
|
+
position: "before",
|
|
179084
|
+
content: { text: request.text }
|
|
179085
|
+
}
|
|
179086
|
+
};
|
|
178651
179087
|
case "format":
|
|
178652
179088
|
return {
|
|
178653
179089
|
id: stepId,
|
|
@@ -178672,12 +179108,52 @@ function selectionMutationWrapper(editor, request, options) {
|
|
|
178672
179108
|
}
|
|
178673
179109
|
const stepId = v4_default();
|
|
178674
179110
|
const compiled = compilePlan(storyEditor, [buildSelectionStepDef(stepId, request, buildSelectionWhere(request))]);
|
|
179111
|
+
if (request.kind === "insert" && request.target) {
|
|
179112
|
+
if (request.target.start.kind === "nodeEdge" || request.target.end.kind === "nodeEdge")
|
|
179113
|
+
throw new DocumentApiAdapterError("INVALID_TARGET", "Text inserts do not support nodeEdge targets. Use a text-offset target inside a textblock.");
|
|
179114
|
+
}
|
|
179115
|
+
if (request.kind === "insert") {
|
|
179116
|
+
const target = compiled.mutationSteps.find((s2) => s2.step.id === stepId)?.targets[0];
|
|
179117
|
+
if (target) {
|
|
179118
|
+
if (target.kind === "span")
|
|
179119
|
+
return {
|
|
179120
|
+
success: false,
|
|
179121
|
+
resolution: buildSelectionResolutionFromCompiled(compiled, stepId),
|
|
179122
|
+
failure: {
|
|
179123
|
+
code: "INVALID_TARGET",
|
|
179124
|
+
message: "Insert operations require a single-block target, not a multi-segment span."
|
|
179125
|
+
}
|
|
179126
|
+
};
|
|
179127
|
+
if (target.kind === "range") {
|
|
179128
|
+
if (!storyEditor.state.doc.resolve(target.absFrom).parent.isTextblock)
|
|
179129
|
+
return {
|
|
179130
|
+
success: false,
|
|
179131
|
+
resolution: buildSelectionResolutionFromCompiled(compiled, stepId),
|
|
179132
|
+
failure: {
|
|
179133
|
+
code: "INVALID_TARGET",
|
|
179134
|
+
message: "Text insert target must be inside a textblock."
|
|
179135
|
+
}
|
|
179136
|
+
};
|
|
179137
|
+
}
|
|
179138
|
+
}
|
|
179139
|
+
}
|
|
178675
179140
|
checkRevision(storyEditor, options?.expectedRevision);
|
|
178676
|
-
if (options?.dryRun)
|
|
179141
|
+
if (options?.dryRun) {
|
|
179142
|
+
const resolution$1 = buildSelectionResolutionFromCompiled(compiled, stepId);
|
|
179143
|
+
if (request.kind === "insert" && !request.text)
|
|
179144
|
+
return {
|
|
179145
|
+
success: false,
|
|
179146
|
+
resolution: resolution$1,
|
|
179147
|
+
failure: {
|
|
179148
|
+
code: "NO_OP",
|
|
179149
|
+
message: "Insert text is empty."
|
|
179150
|
+
}
|
|
179151
|
+
};
|
|
178677
179152
|
return {
|
|
178678
179153
|
success: true,
|
|
178679
|
-
resolution:
|
|
179154
|
+
resolution: resolution$1
|
|
178680
179155
|
};
|
|
179156
|
+
}
|
|
178681
179157
|
const stepOutcome = executeCompiledPlan(storyEditor, compiled, {
|
|
178682
179158
|
changeMode: mode,
|
|
178683
179159
|
expectedRevision: options?.expectedRevision
|
|
@@ -178818,17 +179294,68 @@ function insertStructuredInner(editor, input2, options) {
|
|
|
178818
179294
|
if (isStructuralInsertInput2(input2))
|
|
178819
179295
|
return executeStructuralInsertWrapper(editor, input2, options);
|
|
178820
179296
|
const contentType = input2.type ?? "text";
|
|
178821
|
-
const { value, target } = input2;
|
|
179297
|
+
const { value, target, ref: ref$1 } = input2;
|
|
178822
179298
|
if ((options?.changeMode ?? "direct") === "tracked")
|
|
178823
179299
|
throw new DocumentApiAdapterError("CAPABILITY_UNAVAILABLE", `Tracked mode is not supported for type: '${contentType}' insert operations.`);
|
|
178824
179300
|
let resolvedRange;
|
|
178825
179301
|
let effectiveTarget;
|
|
179302
|
+
if (ref$1 !== undefined && ref$1 === "")
|
|
179303
|
+
throw new DocumentApiAdapterError("INVALID_TARGET", "ref must be a non-empty string.", { ref: ref$1 });
|
|
178826
179304
|
if (target) {
|
|
178827
|
-
const
|
|
178828
|
-
|
|
178829
|
-
|
|
178830
|
-
|
|
178831
|
-
|
|
179305
|
+
const resolved = resolveSelectionTarget(editor, target);
|
|
179306
|
+
resolvedRange = {
|
|
179307
|
+
from: resolved.absFrom,
|
|
179308
|
+
to: resolved.absTo
|
|
179309
|
+
};
|
|
179310
|
+
const startPoint = target.start;
|
|
179311
|
+
const blockId = startPoint.kind === "text" ? startPoint.blockId : startPoint.node.nodeId;
|
|
179312
|
+
let offset$1;
|
|
179313
|
+
if (startPoint.kind === "text")
|
|
179314
|
+
offset$1 = startPoint.offset;
|
|
179315
|
+
else if (startPoint.edge === "after")
|
|
179316
|
+
offset$1 = nodeEdgeAfterOffset(editor, startPoint.node.nodeType, startPoint.node.nodeId);
|
|
179317
|
+
else
|
|
179318
|
+
offset$1 = 0;
|
|
179319
|
+
effectiveTarget = {
|
|
179320
|
+
kind: "text",
|
|
179321
|
+
blockId,
|
|
179322
|
+
range: {
|
|
179323
|
+
start: offset$1,
|
|
179324
|
+
end: offset$1
|
|
179325
|
+
}
|
|
179326
|
+
};
|
|
179327
|
+
} else if (ref$1) {
|
|
179328
|
+
const dummyStepId = v4_default();
|
|
179329
|
+
const compiled = compilePlan(editor, [{
|
|
179330
|
+
id: dummyStepId,
|
|
179331
|
+
op: "text.insert",
|
|
179332
|
+
where: {
|
|
179333
|
+
by: "ref",
|
|
179334
|
+
ref: ref$1
|
|
179335
|
+
},
|
|
179336
|
+
args: {
|
|
179337
|
+
position: "before",
|
|
179338
|
+
content: { text: "" }
|
|
179339
|
+
}
|
|
179340
|
+
}]);
|
|
179341
|
+
const compiledTarget = compiled.mutationSteps.find((s2) => s2.step.id === dummyStepId)?.targets[0];
|
|
179342
|
+
if (!compiledTarget)
|
|
179343
|
+
throw new DocumentApiAdapterError("TARGET_NOT_FOUND", "Structured insert ref could not be resolved.", { ref: ref$1 });
|
|
179344
|
+
if (compiledTarget.kind === "span")
|
|
179345
|
+
throw new DocumentApiAdapterError("INVALID_TARGET", "Insert operations require a single-block ref. Multi-segment refs are not supported.", { ref: ref$1 });
|
|
179346
|
+
resolvedRange = {
|
|
179347
|
+
from: compiledTarget.absFrom,
|
|
179348
|
+
to: compiledTarget.absFrom
|
|
179349
|
+
};
|
|
179350
|
+
const refTarget = buildSelectionResolutionFromCompiled(compiled, dummyStepId).target;
|
|
179351
|
+
effectiveTarget = {
|
|
179352
|
+
kind: "text",
|
|
179353
|
+
blockId: refTarget.blockId,
|
|
179354
|
+
range: {
|
|
179355
|
+
start: refTarget.range.start,
|
|
179356
|
+
end: refTarget.range.start
|
|
179357
|
+
}
|
|
179358
|
+
};
|
|
178832
179359
|
} else {
|
|
178833
179360
|
const fallback = resolveDefaultInsertTarget(editor);
|
|
178834
179361
|
if (!fallback)
|
|
@@ -178853,13 +179380,13 @@ function insertStructuredInner(editor, input2, options) {
|
|
|
178853
179380
|
}
|
|
178854
179381
|
}
|
|
178855
179382
|
const resolution = buildTextMutationResolution({
|
|
178856
|
-
requestedTarget:
|
|
179383
|
+
requestedTarget: effectiveTarget,
|
|
178857
179384
|
target: effectiveTarget,
|
|
178858
179385
|
range: resolvedRange,
|
|
178859
179386
|
text: readTextAtResolvedRange(editor, resolvedRange)
|
|
178860
179387
|
});
|
|
178861
179388
|
const { from: from$1, to } = resolvedRange;
|
|
178862
|
-
if (from$1 !== to)
|
|
179389
|
+
if (target && from$1 !== to)
|
|
178863
179390
|
return {
|
|
178864
179391
|
success: false,
|
|
178865
179392
|
resolution,
|
|
@@ -210878,7 +211405,7 @@ var Node$13 = class Node$14 {
|
|
|
210878
211405
|
insideH: borderSpec,
|
|
210879
211406
|
insideV: borderSpec
|
|
210880
211407
|
};
|
|
210881
|
-
}, ZERO_WIDTH_SPACE = "", ROW_START_TO_TEXT_OFFSET = 3, CELL_TO_TEXT_OFFSET = 2, normalizeHeaderAttrsForBodyCell = (attrs) => {
|
|
211408
|
+
}, TABLE_CELL_ROLES, TableBoundaryNavigationPluginKey, ZERO_WIDTH_SPACE = "", ROW_START_TO_TEXT_OFFSET = 3, CELL_TO_TEXT_OFFSET = 2, normalizeHeaderAttrsForBodyCell = (attrs) => {
|
|
210882
211409
|
if (attrs?.borders !== null)
|
|
210883
211410
|
return attrs;
|
|
210884
211411
|
const nextAttrs = { ...attrs };
|
|
@@ -231035,9 +231562,9 @@ var Node$13 = class Node$14 {
|
|
|
231035
231562
|
return;
|
|
231036
231563
|
console.log(...args$1);
|
|
231037
231564
|
}, HEADER_FOOTER_INIT_BUDGET_MS = 200, MAX_ZOOM_WARNING_THRESHOLD = 10, MAX_SELECTION_RECTS_PER_USER = 100, SEMANTIC_RESIZE_DEBOUNCE_MS = 120, MIN_SEMANTIC_CONTENT_WIDTH_PX = 1, GLOBAL_PERFORMANCE, PresentationEditor, ICONS, TEXTS, tableActionsOptions;
|
|
231038
|
-
var
|
|
231565
|
+
var init_src_BrT7SmAZ_es = __esm(() => {
|
|
231039
231566
|
init_rolldown_runtime_B2q5OVn9_es();
|
|
231040
|
-
|
|
231567
|
+
init_SuperConverter_C65zRR3r_es();
|
|
231041
231568
|
init_jszip_ChlR43oI_es();
|
|
231042
231569
|
init_uuid_qzgm05fK_es();
|
|
231043
231570
|
init_constants_ep1_Gwqi_es();
|
|
@@ -234943,6 +235470,8 @@ ${err.toString()}`);
|
|
|
234943
235470
|
} };
|
|
234944
235471
|
}
|
|
234945
235472
|
});
|
|
235473
|
+
TABLE_CELL_ROLES = new Set(["cell", "header_cell"]);
|
|
235474
|
+
TableBoundaryNavigationPluginKey = new PluginKey("tableBoundaryNavigation");
|
|
234946
235475
|
Table = Node$13.create({
|
|
234947
235476
|
name: "table",
|
|
234948
235477
|
content: "tableRow+",
|
|
@@ -235119,7 +235648,7 @@ ${err.toString()}`);
|
|
|
235119
235648
|
return true;
|
|
235120
235649
|
}).run();
|
|
235121
235650
|
},
|
|
235122
|
-
insertTable: ({ rows = 3, cols = 3, withHeaderRow = false, columnWidths = null } = {}) => ({ tr, dispatch, editor }) => {
|
|
235651
|
+
insertTable: ({ rows = 3, cols = 3, withHeaderRow = false, columnWidths = null } = {}) => ({ tr, dispatch, editor, state }) => {
|
|
235123
235652
|
const widths = columnWidths ?? computeColumnWidths(editor, cols);
|
|
235124
235653
|
const resolved = normalizeNewTableAttrs(editor);
|
|
235125
235654
|
const tableAttrs = {
|
|
@@ -235129,10 +235658,34 @@ ${err.toString()}`);
|
|
|
235129
235658
|
};
|
|
235130
235659
|
const node3 = createTable(editor.schema, rows, cols, withHeaderRow, null, widths, tableAttrs);
|
|
235131
235660
|
if (dispatch) {
|
|
235132
|
-
let offset$1
|
|
235133
|
-
|
|
235134
|
-
|
|
235135
|
-
|
|
235661
|
+
let offset$1;
|
|
235662
|
+
let replaceRange2 = undefined;
|
|
235663
|
+
if (tr.selection.$from.depth === 0) {
|
|
235664
|
+
offset$1 = tr.selection.from;
|
|
235665
|
+
replaceRange2 = {
|
|
235666
|
+
from: tr.selection.from,
|
|
235667
|
+
to: tr.selection.to
|
|
235668
|
+
};
|
|
235669
|
+
} else {
|
|
235670
|
+
offset$1 = tr.selection.$from.end() + 1;
|
|
235671
|
+
const paragraphDepth = tr.selection.$from.parent?.type?.name === "run" ? tr.selection.$from.depth - 1 : tr.selection.$from.depth;
|
|
235672
|
+
const paragraph2 = tr.selection.$from.node(paragraphDepth);
|
|
235673
|
+
const isTopLevelParagraph = paragraphDepth === 1;
|
|
235674
|
+
const isEmptyParagraph = paragraph2.type.name === "paragraph" && paragraph2.textContent === "";
|
|
235675
|
+
if (isTopLevelParagraph && isEmptyParagraph) {
|
|
235676
|
+
offset$1 = tr.selection.$from.before(paragraphDepth);
|
|
235677
|
+
replaceRange2 = {
|
|
235678
|
+
from: tr.selection.$from.before(paragraphDepth),
|
|
235679
|
+
to: tr.selection.$from.after(paragraphDepth)
|
|
235680
|
+
};
|
|
235681
|
+
} else if (tr.selection.$from.parent?.type?.name === "run")
|
|
235682
|
+
offset$1 = tr.selection.$from.after(paragraphDepth);
|
|
235683
|
+
}
|
|
235684
|
+
const { inserted } = insertTopLevelTableWithSeparators(tr, state.doc, offset$1, node3, replaceRange2);
|
|
235685
|
+
if (!inserted)
|
|
235686
|
+
return false;
|
|
235687
|
+
const selectionPos = getFirstTableCellTextPos(offset$1, node3);
|
|
235688
|
+
tr.scrollIntoView().setSelection(TextSelection2.near(tr.doc.resolve(selectionPos)));
|
|
235136
235689
|
}
|
|
235137
235690
|
return true;
|
|
235138
235691
|
},
|
|
@@ -235172,30 +235725,9 @@ ${err.toString()}`);
|
|
|
235172
235725
|
};
|
|
235173
235726
|
const tableNode = tableType.createChecked(tableAttrs, rowNodes);
|
|
235174
235727
|
if (dispatch) {
|
|
235175
|
-
const
|
|
235176
|
-
|
|
235177
|
-
|
|
235178
|
-
sdBlockId: v4_default(),
|
|
235179
|
-
paraId: generateDocxHexId()
|
|
235180
|
-
};
|
|
235181
|
-
return state.schema.nodes.paragraph.createAndFill(attrs);
|
|
235182
|
-
};
|
|
235183
|
-
if (sep.before || sep.after) {
|
|
235184
|
-
const nodes = [];
|
|
235185
|
-
if (sep.before) {
|
|
235186
|
-
const s2 = makeSep();
|
|
235187
|
-
if (s2)
|
|
235188
|
-
nodes.push(s2);
|
|
235189
|
-
}
|
|
235190
|
-
nodes.push(tableNode);
|
|
235191
|
-
if (sep.after) {
|
|
235192
|
-
const s2 = makeSep();
|
|
235193
|
-
if (s2)
|
|
235194
|
-
nodes.push(s2);
|
|
235195
|
-
}
|
|
235196
|
-
tr.insert(pos, Fragment.from(nodes));
|
|
235197
|
-
} else
|
|
235198
|
-
tr.insert(pos, tableNode);
|
|
235728
|
+
const { inserted } = insertTopLevelTableWithSeparators(tr, state.doc, pos, tableNode);
|
|
235729
|
+
if (!inserted)
|
|
235730
|
+
return false;
|
|
235199
235731
|
tr.setMeta("inputType", "programmatic");
|
|
235200
235732
|
if (tracked === true)
|
|
235201
235733
|
tr.setMeta("forceTrackChanges", true);
|
|
@@ -235524,6 +236056,7 @@ ${err.toString()}`);
|
|
|
235524
236056
|
View: createTableView({ editor: this.editor })
|
|
235525
236057
|
})] : [],
|
|
235526
236058
|
tableEditing({ allowTableNodeSelection: this.options.allowTableNodeSelection }),
|
|
236059
|
+
createTableBoundaryNavigationPlugin(),
|
|
235527
236060
|
(() => {
|
|
235528
236061
|
let initialScanDone = false;
|
|
235529
236062
|
return new Plugin({
|
|
@@ -264336,8 +264869,8 @@ var init_zipper_DqXT7uTa_es = __esm(() => {
|
|
|
264336
264869
|
|
|
264337
264870
|
// ../../packages/superdoc/dist/super-editor.es.js
|
|
264338
264871
|
var init_super_editor_es = __esm(() => {
|
|
264339
|
-
|
|
264340
|
-
|
|
264872
|
+
init_src_BrT7SmAZ_es();
|
|
264873
|
+
init_SuperConverter_C65zRR3r_es();
|
|
264341
264874
|
init_jszip_ChlR43oI_es();
|
|
264342
264875
|
init_xml_js_BtmJ6bNs_es();
|
|
264343
264876
|
init_constants_ep1_Gwqi_es();
|
|
@@ -319674,10 +320207,11 @@ function normalizeFlatTargetFlags(operationId, apiInput) {
|
|
|
319674
320207
|
if (SELECTION_TARGET_OPERATIONS.has(operationId)) {
|
|
319675
320208
|
const blockId = apiInput.blockId;
|
|
319676
320209
|
if (typeof blockId === "string") {
|
|
319677
|
-
const
|
|
319678
|
-
const
|
|
320210
|
+
const hasOffset = typeof apiInput.offset === "number";
|
|
320211
|
+
const start3 = typeof apiInput.start === "number" ? apiInput.start : hasOffset ? apiInput.offset : 0;
|
|
320212
|
+
const end2 = typeof apiInput.end === "number" ? apiInput.end : hasOffset ? apiInput.offset : 0;
|
|
319679
320213
|
assertLegacySelectionTargetSupported(operationId, { range: { start: start3, end: end2 } });
|
|
319680
|
-
const { blockId: _2, start: _s, end: _e, ...rest } = apiInput;
|
|
320214
|
+
const { blockId: _2, start: _s, end: _e, offset: _o, ...rest } = apiInput;
|
|
319681
320215
|
return {
|
|
319682
320216
|
...rest,
|
|
319683
320217
|
target: textAddressToSelectionTarget({ blockId, range: { start: start3, end: end2 } })
|
|
@@ -319698,18 +320232,6 @@ function normalizeFlatTargetFlags(operationId, apiInput) {
|
|
|
319698
320232
|
}
|
|
319699
320233
|
return apiInput;
|
|
319700
320234
|
}
|
|
319701
|
-
if (operationId === INSERT_OPERATION) {
|
|
319702
|
-
const blockId = apiInput.blockId;
|
|
319703
|
-
if (typeof blockId === "string") {
|
|
319704
|
-
const offset3 = typeof apiInput.offset === "number" ? apiInput.offset : 0;
|
|
319705
|
-
const { blockId: _2, offset: _o, ...rest } = apiInput;
|
|
319706
|
-
return {
|
|
319707
|
-
...rest,
|
|
319708
|
-
target: { kind: "text", blockId, range: { start: offset3, end: offset3 } }
|
|
319709
|
-
};
|
|
319710
|
-
}
|
|
319711
|
-
return apiInput;
|
|
319712
|
-
}
|
|
319713
320235
|
if (operationId === "blocks.delete") {
|
|
319714
320236
|
const nodeType2 = apiInput.nodeType;
|
|
319715
320237
|
const nodeId = apiInput.nodeId;
|
|
@@ -319751,7 +320273,7 @@ function extractInvokeInput(operationId, cliInput) {
|
|
|
319751
320273
|
}
|
|
319752
320274
|
return normalizeFlatTargetFlags(operationId, apiInput);
|
|
319753
320275
|
}
|
|
319754
|
-
var WRAPPED_INPUT_KEY, PARAM_RENAMES, CLI_LEVEL_KEYS, CHANGEMODE_IN_INPUT, FORMAT_TARGET_OPERATIONS, SELECTION_TARGET_OPERATIONS, TEXT_ADDRESS_TARGET_OPERATIONS,
|
|
320276
|
+
var WRAPPED_INPUT_KEY, PARAM_RENAMES, CLI_LEVEL_KEYS, CHANGEMODE_IN_INPUT, FORMAT_TARGET_OPERATIONS, SELECTION_TARGET_OPERATIONS, TEXT_ADDRESS_TARGET_OPERATIONS, LIST_TARGET_OPERATIONS;
|
|
319755
320277
|
var init_invoke_input = __esm(() => {
|
|
319756
320278
|
init_errors();
|
|
319757
320279
|
init_operation_set();
|
|
@@ -319798,7 +320320,12 @@ var init_invoke_input = __esm(() => {
|
|
|
319798
320320
|
CLI_LEVEL_KEYS = new Set(["doc", "sessionId", "out", "dryRun", "force", "expectedRevision", "changeMode"]);
|
|
319799
320321
|
CHANGEMODE_IN_INPUT = new Set(["mutations.apply", "mutations.preview"]);
|
|
319800
320322
|
FORMAT_TARGET_OPERATIONS = CLI_DOC_OPERATIONS.filter((operationId) => operationId.startsWith("format."));
|
|
319801
|
-
SELECTION_TARGET_OPERATIONS = new Set([
|
|
320323
|
+
SELECTION_TARGET_OPERATIONS = new Set([
|
|
320324
|
+
"insert",
|
|
320325
|
+
"replace",
|
|
320326
|
+
"delete",
|
|
320327
|
+
...FORMAT_TARGET_OPERATIONS
|
|
320328
|
+
]);
|
|
319802
320329
|
TEXT_ADDRESS_TARGET_OPERATIONS = new Set(["comments.create", "comments.patch"]);
|
|
319803
320330
|
LIST_TARGET_OPERATIONS = new Set([
|
|
319804
320331
|
"lists.insert",
|
|
@@ -321027,7 +321554,7 @@ function deriveOptionSpecs(operationId, params4) {
|
|
|
321027
321554
|
}
|
|
321028
321555
|
return specs;
|
|
321029
321556
|
}
|
|
321030
|
-
var DOC_PARAM, SESSION_PARAM, OUT_PARAM, FORCE_PARAM, DRY_RUN_PARAM, CHANGE_MODE_PARAM, EXPECTED_REVISION_PARAM, USER_NAME_PARAM, USER_EMAIL_PARAM, AGENT_HIDDEN_PARAM_NAMES, OPERATION_CONSTRAINTS, PARAM_FLAG_OVERRIDES, PARAM_SCHEMA_OVERRIDES, PARAM_EXCLUSIONS, TEXT_TARGET_FLAT_PARAMS,
|
|
321557
|
+
var DOC_PARAM, SESSION_PARAM, OUT_PARAM, FORCE_PARAM, DRY_RUN_PARAM, CHANGE_MODE_PARAM, EXPECTED_REVISION_PARAM, USER_NAME_PARAM, USER_EMAIL_PARAM, AGENT_HIDDEN_PARAM_NAMES, OPERATION_CONSTRAINTS, PARAM_FLAG_OVERRIDES, PARAM_SCHEMA_OVERRIDES, PARAM_EXCLUSIONS, TEXT_TARGET_FLAT_PARAMS, LIST_TARGET_FLAT_PARAMS, FORMAT_OPERATION_IDS, EXTRA_CLI_PARAMS, CLI_ONLY_METADATA, CLI_OPERATION_METADATA, OPTION_FLAG_ALIASES, CLI_OPERATION_OPTION_SPECS;
|
|
321031
321558
|
var init_operation_params = __esm(() => {
|
|
321032
321559
|
init_src();
|
|
321033
321560
|
init_commands();
|
|
@@ -321132,10 +321659,6 @@ var init_operation_params = __esm(() => {
|
|
|
321132
321659
|
{ name: "start", kind: "flag", type: "number", description: "Start offset within the block (character index)." },
|
|
321133
321660
|
{ name: "end", kind: "flag", type: "number", description: "End offset within the block (character index)." }
|
|
321134
321661
|
];
|
|
321135
|
-
INSERT_FLAT_PARAMS = [
|
|
321136
|
-
{ name: "blockId", kind: "flag", flag: "block-id", type: "string", description: "Block ID of the target paragraph." },
|
|
321137
|
-
{ name: "offset", kind: "flag", type: "number", description: "Character offset within the block for insertion." }
|
|
321138
|
-
];
|
|
321139
321662
|
LIST_TARGET_FLAT_PARAMS = [
|
|
321140
321663
|
{ name: "nodeId", kind: "flag", flag: "node-id", type: "string", description: "Node ID of the target list item." }
|
|
321141
321664
|
];
|
|
@@ -321184,7 +321707,15 @@ var init_operation_params = __esm(() => {
|
|
|
321184
321707
|
description: "Node address to retrieve (block or inline address object)."
|
|
321185
321708
|
}
|
|
321186
321709
|
],
|
|
321187
|
-
"doc.insert": [
|
|
321710
|
+
"doc.insert": [
|
|
321711
|
+
...TEXT_TARGET_FLAT_PARAMS,
|
|
321712
|
+
{
|
|
321713
|
+
name: "offset",
|
|
321714
|
+
kind: "flag",
|
|
321715
|
+
type: "number",
|
|
321716
|
+
description: "Character offset for insertion (alias for --start/--end with same value)."
|
|
321717
|
+
}
|
|
321718
|
+
],
|
|
321188
321719
|
"doc.replace": [...TEXT_TARGET_FLAT_PARAMS],
|
|
321189
321720
|
"doc.delete": [...TEXT_TARGET_FLAT_PARAMS],
|
|
321190
321721
|
"doc.styles.apply": [
|
|
@@ -322203,7 +322734,7 @@ function acceptsLegacyTextAddressTarget(operationId, param, value2) {
|
|
|
322203
322734
|
if (param.name !== "target" || !isTextAddressLike2(value2))
|
|
322204
322735
|
return false;
|
|
322205
322736
|
const docApiId = toDocApiId(operationId);
|
|
322206
|
-
return docApiId === "replace" || docApiId === "delete" || docApiId?.startsWith("format.") === true;
|
|
322737
|
+
return docApiId === "insert" || docApiId === "replace" || docApiId === "delete" || docApiId?.startsWith("format.") === true;
|
|
322207
322738
|
}
|
|
322208
322739
|
function extractConstValues(variants) {
|
|
322209
322740
|
const values2 = [];
|