@superdoc-dev/cli 0.2.0-next.56 → 0.2.0-next.58
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 +1684 -583
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1956,19 +1956,49 @@ var init_operation_definitions = __esm(() => {
|
|
|
1956
1956
|
referenceDocPath: "lists/insert.mdx",
|
|
1957
1957
|
referenceGroup: "lists"
|
|
1958
1958
|
},
|
|
1959
|
-
"lists.
|
|
1960
|
-
memberPath: "lists.
|
|
1961
|
-
description: "
|
|
1962
|
-
expectedResult: "Returns a
|
|
1959
|
+
"lists.create": {
|
|
1960
|
+
memberPath: "lists.create",
|
|
1961
|
+
description: "Create a new list from one or more paragraphs, or convert existing paragraphs into a new list.",
|
|
1962
|
+
expectedResult: "Returns a ListsCreateResult with the new listId and the first item address.",
|
|
1963
|
+
requiresDocumentContext: true,
|
|
1964
|
+
metadata: mutationOperation({
|
|
1965
|
+
idempotency: "non-idempotent",
|
|
1966
|
+
supportsDryRun: true,
|
|
1967
|
+
supportsTrackedMode: false,
|
|
1968
|
+
possibleFailureCodes: ["INVALID_TARGET", "LEVEL_OUT_OF_RANGE"],
|
|
1969
|
+
throws: [...T_NOT_FOUND_CAPABLE, "INVALID_TARGET"]
|
|
1970
|
+
}),
|
|
1971
|
+
referenceDocPath: "lists/create.mdx",
|
|
1972
|
+
referenceGroup: "lists"
|
|
1973
|
+
},
|
|
1974
|
+
"lists.attach": {
|
|
1975
|
+
memberPath: "lists.attach",
|
|
1976
|
+
description: "Convert non-list paragraphs to list items under an existing list sequence.",
|
|
1977
|
+
expectedResult: "Returns a ListsMutateItemResult confirming attachment.",
|
|
1978
|
+
requiresDocumentContext: true,
|
|
1979
|
+
metadata: mutationOperation({
|
|
1980
|
+
idempotency: "conditional",
|
|
1981
|
+
supportsDryRun: true,
|
|
1982
|
+
supportsTrackedMode: false,
|
|
1983
|
+
possibleFailureCodes: ["INVALID_TARGET", "NO_OP"],
|
|
1984
|
+
throws: [...T_NOT_FOUND_CAPABLE, "INVALID_TARGET"]
|
|
1985
|
+
}),
|
|
1986
|
+
referenceDocPath: "lists/attach.mdx",
|
|
1987
|
+
referenceGroup: "lists"
|
|
1988
|
+
},
|
|
1989
|
+
"lists.detach": {
|
|
1990
|
+
memberPath: "lists.detach",
|
|
1991
|
+
description: "Remove numbering properties from list items, converting them to plain paragraphs.",
|
|
1992
|
+
expectedResult: "Returns a ListsDetachResult confirming the item was converted to a plain paragraph.",
|
|
1963
1993
|
requiresDocumentContext: true,
|
|
1964
1994
|
metadata: mutationOperation({
|
|
1965
1995
|
idempotency: "conditional",
|
|
1966
1996
|
supportsDryRun: true,
|
|
1967
1997
|
supportsTrackedMode: false,
|
|
1968
|
-
possibleFailureCodes: ["
|
|
1998
|
+
possibleFailureCodes: ["INVALID_TARGET"],
|
|
1969
1999
|
throws: [...T_NOT_FOUND_CAPABLE, "INVALID_TARGET"]
|
|
1970
2000
|
}),
|
|
1971
|
-
referenceDocPath: "lists/
|
|
2001
|
+
referenceDocPath: "lists/detach.mdx",
|
|
1972
2002
|
referenceGroup: "lists"
|
|
1973
2003
|
},
|
|
1974
2004
|
"lists.indent": {
|
|
@@ -1980,7 +2010,7 @@ var init_operation_definitions = __esm(() => {
|
|
|
1980
2010
|
idempotency: "conditional",
|
|
1981
2011
|
supportsDryRun: true,
|
|
1982
2012
|
supportsTrackedMode: false,
|
|
1983
|
-
possibleFailureCodes: ["NO_OP", "INVALID_TARGET"],
|
|
2013
|
+
possibleFailureCodes: ["NO_OP", "INVALID_TARGET", "LEVEL_OUT_OF_RANGE"],
|
|
1984
2014
|
throws: [...T_NOT_FOUND_CAPABLE, "INVALID_TARGET"]
|
|
1985
2015
|
}),
|
|
1986
2016
|
referenceDocPath: "lists/indent.mdx",
|
|
@@ -1995,31 +2025,135 @@ var init_operation_definitions = __esm(() => {
|
|
|
1995
2025
|
idempotency: "conditional",
|
|
1996
2026
|
supportsDryRun: true,
|
|
1997
2027
|
supportsTrackedMode: false,
|
|
1998
|
-
possibleFailureCodes: ["NO_OP", "INVALID_TARGET"],
|
|
2028
|
+
possibleFailureCodes: ["NO_OP", "INVALID_TARGET", "LEVEL_OUT_OF_RANGE"],
|
|
1999
2029
|
throws: [...T_NOT_FOUND_CAPABLE, "INVALID_TARGET"]
|
|
2000
2030
|
}),
|
|
2001
2031
|
referenceDocPath: "lists/outdent.mdx",
|
|
2002
2032
|
referenceGroup: "lists"
|
|
2003
2033
|
},
|
|
2004
|
-
"lists.
|
|
2005
|
-
memberPath: "lists.
|
|
2006
|
-
description: "
|
|
2007
|
-
expectedResult: "Returns a
|
|
2034
|
+
"lists.join": {
|
|
2035
|
+
memberPath: "lists.join",
|
|
2036
|
+
description: "Merge two adjacent list sequences into one.",
|
|
2037
|
+
expectedResult: "Returns a ListsJoinResult with the resulting listId of the merged sequence.",
|
|
2008
2038
|
requiresDocumentContext: true,
|
|
2009
2039
|
metadata: mutationOperation({
|
|
2010
2040
|
idempotency: "conditional",
|
|
2011
2041
|
supportsDryRun: true,
|
|
2012
2042
|
supportsTrackedMode: false,
|
|
2013
|
-
possibleFailureCodes: [
|
|
2043
|
+
possibleFailureCodes: [
|
|
2044
|
+
"INVALID_TARGET",
|
|
2045
|
+
"NO_ADJACENT_SEQUENCE",
|
|
2046
|
+
"INCOMPATIBLE_DEFINITIONS",
|
|
2047
|
+
"ALREADY_SAME_SEQUENCE"
|
|
2048
|
+
],
|
|
2014
2049
|
throws: [...T_NOT_FOUND_CAPABLE, "INVALID_TARGET"]
|
|
2015
2050
|
}),
|
|
2016
|
-
referenceDocPath: "lists/
|
|
2051
|
+
referenceDocPath: "lists/join.mdx",
|
|
2017
2052
|
referenceGroup: "lists"
|
|
2018
2053
|
},
|
|
2019
|
-
"lists.
|
|
2020
|
-
memberPath: "lists.
|
|
2021
|
-
description: "
|
|
2022
|
-
expectedResult: "Returns a
|
|
2054
|
+
"lists.canJoin": {
|
|
2055
|
+
memberPath: "lists.canJoin",
|
|
2056
|
+
description: "Check whether two adjacent list sequences can be joined.",
|
|
2057
|
+
expectedResult: "Returns a ListsCanJoinResult indicating feasibility and reason if not possible.",
|
|
2058
|
+
requiresDocumentContext: true,
|
|
2059
|
+
metadata: readOperation({
|
|
2060
|
+
idempotency: "idempotent",
|
|
2061
|
+
throws: ["TARGET_NOT_FOUND", "INVALID_TARGET", "INVALID_INPUT"]
|
|
2062
|
+
}),
|
|
2063
|
+
referenceDocPath: "lists/can-join.mdx",
|
|
2064
|
+
referenceGroup: "lists"
|
|
2065
|
+
},
|
|
2066
|
+
"lists.separate": {
|
|
2067
|
+
memberPath: "lists.separate",
|
|
2068
|
+
description: "Split a list sequence at the target item, creating a new sequence from that point forward.",
|
|
2069
|
+
expectedResult: "Returns a ListsSeparateResult with the new listId and numId.",
|
|
2070
|
+
requiresDocumentContext: true,
|
|
2071
|
+
metadata: mutationOperation({
|
|
2072
|
+
idempotency: "conditional",
|
|
2073
|
+
supportsDryRun: true,
|
|
2074
|
+
supportsTrackedMode: false,
|
|
2075
|
+
possibleFailureCodes: ["INVALID_TARGET", "NO_OP"],
|
|
2076
|
+
throws: [...T_NOT_FOUND_CAPABLE, "INVALID_TARGET"]
|
|
2077
|
+
}),
|
|
2078
|
+
referenceDocPath: "lists/separate.mdx",
|
|
2079
|
+
referenceGroup: "lists"
|
|
2080
|
+
},
|
|
2081
|
+
"lists.setLevel": {
|
|
2082
|
+
memberPath: "lists.setLevel",
|
|
2083
|
+
description: "Set the absolute nesting level (0..8) of a list item.",
|
|
2084
|
+
expectedResult: "Returns a ListsMutateItemResult receipt; reports NO_OP if already at the target level.",
|
|
2085
|
+
requiresDocumentContext: true,
|
|
2086
|
+
metadata: mutationOperation({
|
|
2087
|
+
idempotency: "conditional",
|
|
2088
|
+
supportsDryRun: true,
|
|
2089
|
+
supportsTrackedMode: false,
|
|
2090
|
+
possibleFailureCodes: ["INVALID_TARGET", "LEVEL_OUT_OF_RANGE", "NO_OP"],
|
|
2091
|
+
throws: [...T_NOT_FOUND_CAPABLE, "INVALID_TARGET"]
|
|
2092
|
+
}),
|
|
2093
|
+
referenceDocPath: "lists/set-level.mdx",
|
|
2094
|
+
referenceGroup: "lists"
|
|
2095
|
+
},
|
|
2096
|
+
"lists.setValue": {
|
|
2097
|
+
memberPath: "lists.setValue",
|
|
2098
|
+
description: "Set an explicit numbering value at the target item. Mid-sequence targets are atomically separated first.",
|
|
2099
|
+
expectedResult: "Returns a ListsMutateItemResult receipt.",
|
|
2100
|
+
requiresDocumentContext: true,
|
|
2101
|
+
metadata: mutationOperation({
|
|
2102
|
+
idempotency: "conditional",
|
|
2103
|
+
supportsDryRun: true,
|
|
2104
|
+
supportsTrackedMode: false,
|
|
2105
|
+
possibleFailureCodes: ["INVALID_TARGET", "NO_OP"],
|
|
2106
|
+
throws: [...T_NOT_FOUND_CAPABLE, "INVALID_TARGET"]
|
|
2107
|
+
}),
|
|
2108
|
+
referenceDocPath: "lists/set-value.mdx",
|
|
2109
|
+
referenceGroup: "lists"
|
|
2110
|
+
},
|
|
2111
|
+
"lists.continuePrevious": {
|
|
2112
|
+
memberPath: "lists.continuePrevious",
|
|
2113
|
+
description: "Continue numbering from the nearest compatible previous list sequence.",
|
|
2114
|
+
expectedResult: "Returns a ListsMutateItemResult receipt.",
|
|
2115
|
+
requiresDocumentContext: true,
|
|
2116
|
+
metadata: mutationOperation({
|
|
2117
|
+
idempotency: "conditional",
|
|
2118
|
+
supportsDryRun: true,
|
|
2119
|
+
supportsTrackedMode: false,
|
|
2120
|
+
possibleFailureCodes: ["INVALID_TARGET", "NO_COMPATIBLE_PREVIOUS", "ALREADY_CONTINUOUS"],
|
|
2121
|
+
throws: [...T_NOT_FOUND_CAPABLE, "INVALID_TARGET"]
|
|
2122
|
+
}),
|
|
2123
|
+
referenceDocPath: "lists/continue-previous.mdx",
|
|
2124
|
+
referenceGroup: "lists"
|
|
2125
|
+
},
|
|
2126
|
+
"lists.canContinuePrevious": {
|
|
2127
|
+
memberPath: "lists.canContinuePrevious",
|
|
2128
|
+
description: "Check whether the target sequence can continue numbering from a previous compatible sequence.",
|
|
2129
|
+
expectedResult: "Returns a ListsCanContinuePreviousResult indicating feasibility.",
|
|
2130
|
+
requiresDocumentContext: true,
|
|
2131
|
+
metadata: readOperation({
|
|
2132
|
+
idempotency: "idempotent",
|
|
2133
|
+
throws: ["TARGET_NOT_FOUND", "INVALID_TARGET", "INVALID_INPUT"]
|
|
2134
|
+
}),
|
|
2135
|
+
referenceDocPath: "lists/can-continue-previous.mdx",
|
|
2136
|
+
referenceGroup: "lists"
|
|
2137
|
+
},
|
|
2138
|
+
"lists.setLevelRestart": {
|
|
2139
|
+
memberPath: "lists.setLevelRestart",
|
|
2140
|
+
description: "Set the restart behavior for a specific list level.",
|
|
2141
|
+
expectedResult: "Returns a ListsMutateItemResult receipt.",
|
|
2142
|
+
requiresDocumentContext: true,
|
|
2143
|
+
metadata: mutationOperation({
|
|
2144
|
+
idempotency: "conditional",
|
|
2145
|
+
supportsDryRun: true,
|
|
2146
|
+
supportsTrackedMode: false,
|
|
2147
|
+
possibleFailureCodes: ["INVALID_TARGET", "LEVEL_OUT_OF_RANGE"],
|
|
2148
|
+
throws: [...T_NOT_FOUND_CAPABLE, "INVALID_TARGET"]
|
|
2149
|
+
}),
|
|
2150
|
+
referenceDocPath: "lists/set-level-restart.mdx",
|
|
2151
|
+
referenceGroup: "lists"
|
|
2152
|
+
},
|
|
2153
|
+
"lists.convertToText": {
|
|
2154
|
+
memberPath: "lists.convertToText",
|
|
2155
|
+
description: "Convert list items to plain paragraphs, optionally prepending the rendered marker text.",
|
|
2156
|
+
expectedResult: "Returns a ListsConvertToTextResult confirming the conversion.",
|
|
2023
2157
|
requiresDocumentContext: true,
|
|
2024
2158
|
metadata: mutationOperation({
|
|
2025
2159
|
idempotency: "conditional",
|
|
@@ -2028,7 +2162,7 @@ var init_operation_definitions = __esm(() => {
|
|
|
2028
2162
|
possibleFailureCodes: ["INVALID_TARGET"],
|
|
2029
2163
|
throws: [...T_NOT_FOUND_CAPABLE, "INVALID_TARGET"]
|
|
2030
2164
|
}),
|
|
2031
|
-
referenceDocPath: "lists/
|
|
2165
|
+
referenceDocPath: "lists/convert-to-text.mdx",
|
|
2032
2166
|
referenceGroup: "lists"
|
|
2033
2167
|
},
|
|
2034
2168
|
"comments.create": {
|
|
@@ -3525,11 +3659,6 @@ function listsMutateItemResultSchemaFor(operationId) {
|
|
|
3525
3659
|
oneOf: [listsMutateItemSuccessSchema, listsFailureSchemaFor(operationId)]
|
|
3526
3660
|
};
|
|
3527
3661
|
}
|
|
3528
|
-
function listsExitResultSchemaFor(operationId) {
|
|
3529
|
-
return {
|
|
3530
|
-
oneOf: [listsExitSuccessSchema, listsFailureSchemaFor(operationId)]
|
|
3531
|
-
};
|
|
3532
|
-
}
|
|
3533
3662
|
function sectionMutationFailureSchemaFor(operationId) {
|
|
3534
3663
|
return objectSchema({
|
|
3535
3664
|
success: { const: false },
|
|
@@ -3802,7 +3931,19 @@ var init_schemas = __esm(() => {
|
|
|
3802
3931
|
}),
|
|
3803
3932
|
ref: { type: "string" },
|
|
3804
3933
|
runs: arraySchema(ref("MatchRun"))
|
|
3805
|
-
}, ["blockId", "nodeType", "range", "text", "ref", "runs"])
|
|
3934
|
+
}, ["blockId", "nodeType", "range", "text", "ref", "runs"]),
|
|
3935
|
+
BlockAddress: objectSchema({
|
|
3936
|
+
kind: { const: "block" },
|
|
3937
|
+
nodeType: { const: "paragraph" },
|
|
3938
|
+
nodeId: { type: "string" }
|
|
3939
|
+
}, ["kind", "nodeType", "nodeId"]),
|
|
3940
|
+
BlockRange: objectSchema({
|
|
3941
|
+
from: ref("BlockAddress"),
|
|
3942
|
+
to: ref("BlockAddress")
|
|
3943
|
+
}, ["from", "to"]),
|
|
3944
|
+
BlockAddressOrRange: {
|
|
3945
|
+
oneOf: [ref("BlockAddress"), ref("BlockRange")]
|
|
3946
|
+
}
|
|
3806
3947
|
};
|
|
3807
3948
|
rangeSchema = ref("Range");
|
|
3808
3949
|
positionSchema = ref("Position");
|
|
@@ -3957,22 +4098,24 @@ var init_schemas = __esm(() => {
|
|
|
3957
4098
|
listInsertPositionSchema = { enum: ["before", "after"] };
|
|
3958
4099
|
listItemInfoSchema = objectSchema({
|
|
3959
4100
|
address: listItemAddressSchema,
|
|
4101
|
+
listId: { type: "string" },
|
|
3960
4102
|
marker: { type: "string" },
|
|
3961
4103
|
ordinal: { type: "integer" },
|
|
3962
4104
|
path: arraySchema({ type: "integer" }),
|
|
3963
4105
|
level: { type: "integer" },
|
|
3964
4106
|
kind: listKindSchema,
|
|
3965
4107
|
text: { type: "string" }
|
|
3966
|
-
}, ["address"]);
|
|
4108
|
+
}, ["address", "listId"]);
|
|
3967
4109
|
listItemDomainItemSchema = discoveryItemSchema({
|
|
3968
4110
|
address: listItemAddressSchema,
|
|
4111
|
+
listId: { type: "string" },
|
|
3969
4112
|
marker: { type: "string" },
|
|
3970
4113
|
ordinal: { type: "integer" },
|
|
3971
4114
|
path: arraySchema({ type: "integer" }),
|
|
3972
4115
|
level: { type: "integer" },
|
|
3973
4116
|
kind: listKindSchema,
|
|
3974
4117
|
text: { type: "string" }
|
|
3975
|
-
}, ["address"]);
|
|
4118
|
+
}, ["address", "listId"]);
|
|
3976
4119
|
listsListResultSchema = discoveryResultSchema(listItemDomainItemSchema);
|
|
3977
4120
|
sectionBreakTypeSchema = { enum: ["continuous", "nextPage", "evenPage", "oddPage"] };
|
|
3978
4121
|
sectionOrientationSchema = { enum: ["portrait", "landscape"] };
|
|
@@ -5066,14 +5209,61 @@ var init_schemas = __esm(() => {
|
|
|
5066
5209
|
success: listsInsertSuccessSchema,
|
|
5067
5210
|
failure: listsFailureSchemaFor("lists.insert")
|
|
5068
5211
|
},
|
|
5069
|
-
"lists.
|
|
5212
|
+
"lists.create": {
|
|
5213
|
+
input: {
|
|
5214
|
+
type: "object",
|
|
5215
|
+
properties: {
|
|
5216
|
+
mode: { enum: ["empty", "fromParagraphs"] },
|
|
5217
|
+
at: ref("BlockAddress"),
|
|
5218
|
+
target: ref("BlockAddressOrRange"),
|
|
5219
|
+
kind: listKindSchema,
|
|
5220
|
+
level: { type: "integer", minimum: 0, maximum: 8 }
|
|
5221
|
+
},
|
|
5222
|
+
required: ["mode", "kind"],
|
|
5223
|
+
additionalProperties: false,
|
|
5224
|
+
if: { properties: { mode: { const: "empty" } } },
|
|
5225
|
+
then: { required: ["mode", "kind", "at"] },
|
|
5226
|
+
else: { required: ["mode", "kind", "target"] }
|
|
5227
|
+
},
|
|
5228
|
+
output: {
|
|
5229
|
+
oneOf: [
|
|
5230
|
+
objectSchema({ success: { const: true }, listId: { type: "string" }, item: listItemAddressSchema }, [
|
|
5231
|
+
"success",
|
|
5232
|
+
"listId",
|
|
5233
|
+
"item"
|
|
5234
|
+
]),
|
|
5235
|
+
listsFailureSchemaFor("lists.create")
|
|
5236
|
+
]
|
|
5237
|
+
},
|
|
5238
|
+
success: objectSchema({ success: { const: true }, listId: { type: "string" }, item: listItemAddressSchema }, [
|
|
5239
|
+
"success",
|
|
5240
|
+
"listId",
|
|
5241
|
+
"item"
|
|
5242
|
+
]),
|
|
5243
|
+
failure: listsFailureSchemaFor("lists.create")
|
|
5244
|
+
},
|
|
5245
|
+
"lists.attach": {
|
|
5070
5246
|
input: objectSchema({
|
|
5071
|
-
target:
|
|
5072
|
-
|
|
5073
|
-
|
|
5074
|
-
|
|
5247
|
+
target: ref("BlockAddressOrRange"),
|
|
5248
|
+
attachTo: listItemAddressSchema,
|
|
5249
|
+
level: { type: "integer", minimum: 0, maximum: 8 }
|
|
5250
|
+
}, ["target", "attachTo"]),
|
|
5251
|
+
output: listsMutateItemResultSchemaFor("lists.attach"),
|
|
5075
5252
|
success: listsMutateItemSuccessSchema,
|
|
5076
|
-
failure: listsFailureSchemaFor("lists.
|
|
5253
|
+
failure: listsFailureSchemaFor("lists.attach")
|
|
5254
|
+
},
|
|
5255
|
+
"lists.detach": {
|
|
5256
|
+
input: objectSchema({
|
|
5257
|
+
target: listItemAddressSchema
|
|
5258
|
+
}, ["target"]),
|
|
5259
|
+
output: {
|
|
5260
|
+
oneOf: [
|
|
5261
|
+
objectSchema({ success: { const: true }, paragraph: ref("ParagraphAddress") }, ["success", "paragraph"]),
|
|
5262
|
+
listsFailureSchemaFor("lists.detach")
|
|
5263
|
+
]
|
|
5264
|
+
},
|
|
5265
|
+
success: objectSchema({ success: { const: true }, paragraph: ref("ParagraphAddress") }, ["success", "paragraph"]),
|
|
5266
|
+
failure: listsFailureSchemaFor("lists.detach")
|
|
5077
5267
|
},
|
|
5078
5268
|
"lists.indent": {
|
|
5079
5269
|
input: objectSchema({
|
|
@@ -5091,21 +5281,113 @@ var init_schemas = __esm(() => {
|
|
|
5091
5281
|
success: listsMutateItemSuccessSchema,
|
|
5092
5282
|
failure: listsFailureSchemaFor("lists.outdent")
|
|
5093
5283
|
},
|
|
5094
|
-
"lists.
|
|
5284
|
+
"lists.join": {
|
|
5285
|
+
input: objectSchema({
|
|
5286
|
+
target: listItemAddressSchema,
|
|
5287
|
+
direction: { enum: ["withPrevious", "withNext"] }
|
|
5288
|
+
}, ["target", "direction"]),
|
|
5289
|
+
output: {
|
|
5290
|
+
oneOf: [
|
|
5291
|
+
objectSchema({ success: { const: true }, listId: { type: "string" } }, ["success", "listId"]),
|
|
5292
|
+
listsFailureSchemaFor("lists.join")
|
|
5293
|
+
]
|
|
5294
|
+
},
|
|
5295
|
+
success: objectSchema({ success: { const: true }, listId: { type: "string" } }, ["success", "listId"]),
|
|
5296
|
+
failure: listsFailureSchemaFor("lists.join")
|
|
5297
|
+
},
|
|
5298
|
+
"lists.canJoin": {
|
|
5299
|
+
input: objectSchema({
|
|
5300
|
+
target: listItemAddressSchema,
|
|
5301
|
+
direction: { enum: ["withPrevious", "withNext"] }
|
|
5302
|
+
}, ["target", "direction"]),
|
|
5303
|
+
output: objectSchema({
|
|
5304
|
+
canJoin: { type: "boolean" },
|
|
5305
|
+
reason: { enum: ["NO_ADJACENT_SEQUENCE", "INCOMPATIBLE_DEFINITIONS", "ALREADY_SAME_SEQUENCE"] },
|
|
5306
|
+
adjacentListId: { type: "string" }
|
|
5307
|
+
}, ["canJoin"])
|
|
5308
|
+
},
|
|
5309
|
+
"lists.separate": {
|
|
5310
|
+
input: objectSchema({
|
|
5311
|
+
target: listItemAddressSchema,
|
|
5312
|
+
copyOverrides: { type: "boolean" }
|
|
5313
|
+
}, ["target"]),
|
|
5314
|
+
output: {
|
|
5315
|
+
oneOf: [
|
|
5316
|
+
objectSchema({ success: { const: true }, listId: { type: "string" }, numId: { type: "integer" } }, [
|
|
5317
|
+
"success",
|
|
5318
|
+
"listId",
|
|
5319
|
+
"numId"
|
|
5320
|
+
]),
|
|
5321
|
+
listsFailureSchemaFor("lists.separate")
|
|
5322
|
+
]
|
|
5323
|
+
},
|
|
5324
|
+
success: objectSchema({ success: { const: true }, listId: { type: "string" }, numId: { type: "integer" } }, [
|
|
5325
|
+
"success",
|
|
5326
|
+
"listId",
|
|
5327
|
+
"numId"
|
|
5328
|
+
]),
|
|
5329
|
+
failure: listsFailureSchemaFor("lists.separate")
|
|
5330
|
+
},
|
|
5331
|
+
"lists.setLevel": {
|
|
5332
|
+
input: objectSchema({
|
|
5333
|
+
target: listItemAddressSchema,
|
|
5334
|
+
level: { type: "integer", minimum: 0, maximum: 8 }
|
|
5335
|
+
}, ["target", "level"]),
|
|
5336
|
+
output: listsMutateItemResultSchemaFor("lists.setLevel"),
|
|
5337
|
+
success: listsMutateItemSuccessSchema,
|
|
5338
|
+
failure: listsFailureSchemaFor("lists.setLevel")
|
|
5339
|
+
},
|
|
5340
|
+
"lists.setValue": {
|
|
5341
|
+
input: objectSchema({
|
|
5342
|
+
target: listItemAddressSchema,
|
|
5343
|
+
value: { type: ["integer", "null"] }
|
|
5344
|
+
}, ["target", "value"]),
|
|
5345
|
+
output: listsMutateItemResultSchemaFor("lists.setValue"),
|
|
5346
|
+
success: listsMutateItemSuccessSchema,
|
|
5347
|
+
failure: listsFailureSchemaFor("lists.setValue")
|
|
5348
|
+
},
|
|
5349
|
+
"lists.continuePrevious": {
|
|
5095
5350
|
input: objectSchema({
|
|
5096
5351
|
target: listItemAddressSchema
|
|
5097
5352
|
}, ["target"]),
|
|
5098
|
-
output: listsMutateItemResultSchemaFor("lists.
|
|
5353
|
+
output: listsMutateItemResultSchemaFor("lists.continuePrevious"),
|
|
5099
5354
|
success: listsMutateItemSuccessSchema,
|
|
5100
|
-
failure: listsFailureSchemaFor("lists.
|
|
5355
|
+
failure: listsFailureSchemaFor("lists.continuePrevious")
|
|
5101
5356
|
},
|
|
5102
|
-
"lists.
|
|
5357
|
+
"lists.canContinuePrevious": {
|
|
5103
5358
|
input: objectSchema({
|
|
5104
5359
|
target: listItemAddressSchema
|
|
5105
5360
|
}, ["target"]),
|
|
5106
|
-
output:
|
|
5107
|
-
|
|
5108
|
-
|
|
5361
|
+
output: objectSchema({
|
|
5362
|
+
canContinue: { type: "boolean" },
|
|
5363
|
+
reason: { enum: ["NO_PREVIOUS_LIST", "INCOMPATIBLE_DEFINITIONS", "ALREADY_CONTINUOUS"] },
|
|
5364
|
+
previousListId: { type: "string" }
|
|
5365
|
+
}, ["canContinue"])
|
|
5366
|
+
},
|
|
5367
|
+
"lists.setLevelRestart": {
|
|
5368
|
+
input: objectSchema({
|
|
5369
|
+
target: listItemAddressSchema,
|
|
5370
|
+
level: { type: "integer", minimum: 0, maximum: 8 },
|
|
5371
|
+
restartAfterLevel: { type: ["integer", "null"] },
|
|
5372
|
+
scope: { enum: ["definition", "instance"] }
|
|
5373
|
+
}, ["target", "level", "restartAfterLevel"]),
|
|
5374
|
+
output: listsMutateItemResultSchemaFor("lists.setLevelRestart"),
|
|
5375
|
+
success: listsMutateItemSuccessSchema,
|
|
5376
|
+
failure: listsFailureSchemaFor("lists.setLevelRestart")
|
|
5377
|
+
},
|
|
5378
|
+
"lists.convertToText": {
|
|
5379
|
+
input: objectSchema({
|
|
5380
|
+
target: listItemAddressSchema,
|
|
5381
|
+
includeMarker: { type: "boolean" }
|
|
5382
|
+
}, ["target"]),
|
|
5383
|
+
output: {
|
|
5384
|
+
oneOf: [
|
|
5385
|
+
objectSchema({ success: { const: true }, paragraph: ref("ParagraphAddress") }, ["success", "paragraph"]),
|
|
5386
|
+
listsFailureSchemaFor("lists.convertToText")
|
|
5387
|
+
]
|
|
5388
|
+
},
|
|
5389
|
+
success: objectSchema({ success: { const: true }, paragraph: ref("ParagraphAddress") }, ["success", "paragraph"]),
|
|
5390
|
+
failure: listsFailureSchemaFor("lists.convertToText")
|
|
5109
5391
|
},
|
|
5110
5392
|
"comments.create": {
|
|
5111
5393
|
input: objectSchema({
|
|
@@ -6757,10 +7039,6 @@ function executeListsInsert(adapter, input, options) {
|
|
|
6757
7039
|
validateListTarget(input, "lists.insert");
|
|
6758
7040
|
return adapter.insert(input, normalizeMutationOptions(options));
|
|
6759
7041
|
}
|
|
6760
|
-
function executeListsSetType(adapter, input, options) {
|
|
6761
|
-
validateListTarget(input, "lists.setType");
|
|
6762
|
-
return adapter.setType(input, normalizeMutationOptions(options));
|
|
6763
|
-
}
|
|
6764
7042
|
function executeListsIndent(adapter, input, options) {
|
|
6765
7043
|
validateListTarget(input, "lists.indent");
|
|
6766
7044
|
return adapter.indent(input, normalizeMutationOptions(options));
|
|
@@ -6769,13 +7047,52 @@ function executeListsOutdent(adapter, input, options) {
|
|
|
6769
7047
|
validateListTarget(input, "lists.outdent");
|
|
6770
7048
|
return adapter.outdent(input, normalizeMutationOptions(options));
|
|
6771
7049
|
}
|
|
6772
|
-
function
|
|
6773
|
-
|
|
6774
|
-
|
|
7050
|
+
function executeListsCreate(adapter, input, options) {
|
|
7051
|
+
return adapter.create(input, normalizeMutationOptions(options));
|
|
7052
|
+
}
|
|
7053
|
+
function executeListsAttach(adapter, input, options) {
|
|
7054
|
+
validateListTarget(input, "lists.attach");
|
|
7055
|
+
return adapter.attach(input, normalizeMutationOptions(options));
|
|
7056
|
+
}
|
|
7057
|
+
function executeListsDetach(adapter, input, options) {
|
|
7058
|
+
validateListTarget(input, "lists.detach");
|
|
7059
|
+
return adapter.detach(input, normalizeMutationOptions(options));
|
|
7060
|
+
}
|
|
7061
|
+
function executeListsJoin(adapter, input, options) {
|
|
7062
|
+
validateListTarget(input, "lists.join");
|
|
7063
|
+
return adapter.join(input, normalizeMutationOptions(options));
|
|
7064
|
+
}
|
|
7065
|
+
function executeListsCanJoin(adapter, input) {
|
|
7066
|
+
validateListTarget(input, "lists.canJoin");
|
|
7067
|
+
return adapter.canJoin(input);
|
|
7068
|
+
}
|
|
7069
|
+
function executeListsSeparate(adapter, input, options) {
|
|
7070
|
+
validateListTarget(input, "lists.separate");
|
|
7071
|
+
return adapter.separate(input, normalizeMutationOptions(options));
|
|
7072
|
+
}
|
|
7073
|
+
function executeListsSetLevel(adapter, input, options) {
|
|
7074
|
+
validateListTarget(input, "lists.setLevel");
|
|
7075
|
+
return adapter.setLevel(input, normalizeMutationOptions(options));
|
|
6775
7076
|
}
|
|
6776
|
-
function
|
|
6777
|
-
validateListTarget(input, "lists.
|
|
6778
|
-
return adapter.
|
|
7077
|
+
function executeListsSetValue(adapter, input, options) {
|
|
7078
|
+
validateListTarget(input, "lists.setValue");
|
|
7079
|
+
return adapter.setValue(input, normalizeMutationOptions(options));
|
|
7080
|
+
}
|
|
7081
|
+
function executeListsContinuePrevious(adapter, input, options) {
|
|
7082
|
+
validateListTarget(input, "lists.continuePrevious");
|
|
7083
|
+
return adapter.continuePrevious(input, normalizeMutationOptions(options));
|
|
7084
|
+
}
|
|
7085
|
+
function executeListsCanContinuePrevious(adapter, input) {
|
|
7086
|
+
validateListTarget(input, "lists.canContinuePrevious");
|
|
7087
|
+
return adapter.canContinuePrevious(input);
|
|
7088
|
+
}
|
|
7089
|
+
function executeListsSetLevelRestart(adapter, input, options) {
|
|
7090
|
+
validateListTarget(input, "lists.setLevelRestart");
|
|
7091
|
+
return adapter.setLevelRestart(input, normalizeMutationOptions(options));
|
|
7092
|
+
}
|
|
7093
|
+
function executeListsConvertToText(adapter, input, options) {
|
|
7094
|
+
validateListTarget(input, "lists.convertToText");
|
|
7095
|
+
return adapter.convertToText(input, normalizeMutationOptions(options));
|
|
6779
7096
|
}
|
|
6780
7097
|
var init_lists = __esm(() => {
|
|
6781
7098
|
init_errors2();
|
|
@@ -7094,11 +7411,20 @@ function buildDispatchTable(api) {
|
|
|
7094
7411
|
"lists.list": (input) => api.lists.list(input),
|
|
7095
7412
|
"lists.get": (input) => api.lists.get(input),
|
|
7096
7413
|
"lists.insert": (input, options) => api.lists.insert(input, options),
|
|
7097
|
-
"lists.
|
|
7414
|
+
"lists.create": (input, options) => api.lists.create(input, options),
|
|
7415
|
+
"lists.attach": (input, options) => api.lists.attach(input, options),
|
|
7416
|
+
"lists.detach": (input, options) => api.lists.detach(input, options),
|
|
7098
7417
|
"lists.indent": (input, options) => api.lists.indent(input, options),
|
|
7099
7418
|
"lists.outdent": (input, options) => api.lists.outdent(input, options),
|
|
7100
|
-
"lists.
|
|
7101
|
-
"lists.
|
|
7419
|
+
"lists.join": (input, options) => api.lists.join(input, options),
|
|
7420
|
+
"lists.canJoin": (input) => api.lists.canJoin(input),
|
|
7421
|
+
"lists.separate": (input, options) => api.lists.separate(input, options),
|
|
7422
|
+
"lists.setLevel": (input, options) => api.lists.setLevel(input, options),
|
|
7423
|
+
"lists.setValue": (input, options) => api.lists.setValue(input, options),
|
|
7424
|
+
"lists.continuePrevious": (input, options) => api.lists.continuePrevious(input, options),
|
|
7425
|
+
"lists.canContinuePrevious": (input) => api.lists.canContinuePrevious(input),
|
|
7426
|
+
"lists.setLevelRestart": (input, options) => api.lists.setLevelRestart(input, options),
|
|
7427
|
+
"lists.convertToText": (input, options) => api.lists.convertToText(input, options),
|
|
7102
7428
|
"sections.list": (input) => api.sections.list(input),
|
|
7103
7429
|
"sections.get": (input) => api.sections.get(input),
|
|
7104
7430
|
"sections.setBreakType": (input, options) => api.sections.setBreakType(input, options),
|
|
@@ -7864,8 +8190,14 @@ function createDocumentApi(adapters) {
|
|
|
7864
8190
|
insert(input, options) {
|
|
7865
8191
|
return executeListsInsert(adapters.lists, input, options);
|
|
7866
8192
|
},
|
|
7867
|
-
|
|
7868
|
-
return
|
|
8193
|
+
create(input, options) {
|
|
8194
|
+
return executeListsCreate(adapters.lists, input, options);
|
|
8195
|
+
},
|
|
8196
|
+
attach(input, options) {
|
|
8197
|
+
return executeListsAttach(adapters.lists, input, options);
|
|
8198
|
+
},
|
|
8199
|
+
detach(input, options) {
|
|
8200
|
+
return executeListsDetach(adapters.lists, input, options);
|
|
7869
8201
|
},
|
|
7870
8202
|
indent(input, options) {
|
|
7871
8203
|
return executeListsIndent(adapters.lists, input, options);
|
|
@@ -7873,11 +8205,32 @@ function createDocumentApi(adapters) {
|
|
|
7873
8205
|
outdent(input, options) {
|
|
7874
8206
|
return executeListsOutdent(adapters.lists, input, options);
|
|
7875
8207
|
},
|
|
7876
|
-
|
|
7877
|
-
return
|
|
8208
|
+
join(input, options) {
|
|
8209
|
+
return executeListsJoin(adapters.lists, input, options);
|
|
8210
|
+
},
|
|
8211
|
+
canJoin(input) {
|
|
8212
|
+
return executeListsCanJoin(adapters.lists, input);
|
|
7878
8213
|
},
|
|
7879
|
-
|
|
7880
|
-
return
|
|
8214
|
+
separate(input, options) {
|
|
8215
|
+
return executeListsSeparate(adapters.lists, input, options);
|
|
8216
|
+
},
|
|
8217
|
+
setLevel(input, options) {
|
|
8218
|
+
return executeListsSetLevel(adapters.lists, input, options);
|
|
8219
|
+
},
|
|
8220
|
+
setValue(input, options) {
|
|
8221
|
+
return executeListsSetValue(adapters.lists, input, options);
|
|
8222
|
+
},
|
|
8223
|
+
continuePrevious(input, options) {
|
|
8224
|
+
return executeListsContinuePrevious(adapters.lists, input, options);
|
|
8225
|
+
},
|
|
8226
|
+
canContinuePrevious(input) {
|
|
8227
|
+
return executeListsCanContinuePrevious(adapters.lists, input);
|
|
8228
|
+
},
|
|
8229
|
+
setLevelRestart(input, options) {
|
|
8230
|
+
return executeListsSetLevelRestart(adapters.lists, input, options);
|
|
8231
|
+
},
|
|
8232
|
+
convertToText(input, options) {
|
|
8233
|
+
return executeListsConvertToText(adapters.lists, input, options);
|
|
7881
8234
|
}
|
|
7882
8235
|
},
|
|
7883
8236
|
sections: {
|
|
@@ -8248,17 +8601,28 @@ async function pathExists(path) {
|
|
|
8248
8601
|
var init_guards = () => {};
|
|
8249
8602
|
|
|
8250
8603
|
// src/lib/context.ts
|
|
8604
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
8251
8605
|
import { copyFile, mkdir, open, readdir, readFile as readFile2, rename, rm, stat, unlink, writeFile } from "node:fs/promises";
|
|
8252
8606
|
import { createHash } from "node:crypto";
|
|
8253
8607
|
import { homedir, hostname } from "node:os";
|
|
8254
8608
|
import { join, resolve } from "node:path";
|
|
8255
8609
|
function getStateRoot() {
|
|
8610
|
+
const scopedOverride = STATE_DIR_OVERRIDE_STORAGE.getStore();
|
|
8611
|
+
if (scopedOverride && scopedOverride.length > 0) {
|
|
8612
|
+
return scopedOverride;
|
|
8613
|
+
}
|
|
8256
8614
|
const override = process.env.SUPERDOC_CLI_STATE_DIR;
|
|
8257
8615
|
if (override && override.length > 0) {
|
|
8258
8616
|
return resolve(override);
|
|
8259
8617
|
}
|
|
8260
8618
|
return join(homedir(), ".superdoc-cli", "state", CONTEXT_VERSION);
|
|
8261
8619
|
}
|
|
8620
|
+
async function withStateDirOverride(stateDir, operation) {
|
|
8621
|
+
if (stateDir == null || stateDir.length === 0) {
|
|
8622
|
+
return operation();
|
|
8623
|
+
}
|
|
8624
|
+
return STATE_DIR_OVERRIDE_STORAGE.run(resolve(stateDir), operation);
|
|
8625
|
+
}
|
|
8262
8626
|
function getContextPaths(contextId) {
|
|
8263
8627
|
const normalizedContextId = validateSessionId(contextId, "session id");
|
|
8264
8628
|
const stateRoot = getStateRoot();
|
|
@@ -8776,11 +9140,12 @@ function createInitialContextMetadata(io, paths, contextId, input) {
|
|
|
8776
9140
|
sourceSnapshot: input.sourceSnapshot
|
|
8777
9141
|
};
|
|
8778
9142
|
}
|
|
8779
|
-
var CONTEXT_VERSION = "v1", ACTIVE_SESSION_FILENAME = "active-session", DEFAULT_LOCK_TIMEOUT_MS = 5000, LOCK_RETRY_INTERVAL_MS = 50;
|
|
9143
|
+
var CONTEXT_VERSION = "v1", ACTIVE_SESSION_FILENAME = "active-session", DEFAULT_LOCK_TIMEOUT_MS = 5000, LOCK_RETRY_INTERVAL_MS = 50, STATE_DIR_OVERRIDE_STORAGE;
|
|
8780
9144
|
var init_context = __esm(() => {
|
|
8781
9145
|
init_errors();
|
|
8782
9146
|
init_guards();
|
|
8783
9147
|
init_session();
|
|
9148
|
+
STATE_DIR_OVERRIDE_STORAGE = new AsyncLocalStorage;
|
|
8784
9149
|
});
|
|
8785
9150
|
|
|
8786
9151
|
// src/cli/operation-hints.ts
|
|
@@ -8838,11 +9203,20 @@ var init_operation_hints = __esm(() => {
|
|
|
8838
9203
|
"lists.list": "listed items",
|
|
8839
9204
|
"lists.get": "resolved list item",
|
|
8840
9205
|
"lists.insert": "inserted list item",
|
|
8841
|
-
"lists.setType": "set list type",
|
|
8842
9206
|
"lists.indent": "indented list item",
|
|
8843
9207
|
"lists.outdent": "outdented list item",
|
|
8844
|
-
"lists.
|
|
8845
|
-
"lists.
|
|
9208
|
+
"lists.create": "created list",
|
|
9209
|
+
"lists.attach": "attached to list",
|
|
9210
|
+
"lists.detach": "detached from list",
|
|
9211
|
+
"lists.join": "joined lists",
|
|
9212
|
+
"lists.canJoin": "checked join feasibility",
|
|
9213
|
+
"lists.separate": "separated list",
|
|
9214
|
+
"lists.setLevel": "set list level",
|
|
9215
|
+
"lists.setValue": "set list value",
|
|
9216
|
+
"lists.continuePrevious": "continued previous list",
|
|
9217
|
+
"lists.canContinuePrevious": "checked continue feasibility",
|
|
9218
|
+
"lists.setLevelRestart": "set level restart",
|
|
9219
|
+
"lists.convertToText": "converted list to text",
|
|
8846
9220
|
"comments.create": "created comment",
|
|
8847
9221
|
"comments.patch": "patched comment",
|
|
8848
9222
|
"comments.delete": "deleted comment",
|
|
@@ -8929,11 +9303,20 @@ var init_operation_hints = __esm(() => {
|
|
|
8929
9303
|
"lists.list": "listResult",
|
|
8930
9304
|
"lists.get": "listItemInfo",
|
|
8931
9305
|
"lists.insert": "listsMutationResult",
|
|
8932
|
-
"lists.setType": "listsMutationResult",
|
|
8933
9306
|
"lists.indent": "listsMutationResult",
|
|
8934
9307
|
"lists.outdent": "listsMutationResult",
|
|
8935
|
-
"lists.
|
|
8936
|
-
"lists.
|
|
9308
|
+
"lists.create": "listsMutationResult",
|
|
9309
|
+
"lists.attach": "listsMutationResult",
|
|
9310
|
+
"lists.detach": "listsMutationResult",
|
|
9311
|
+
"lists.join": "listsMutationResult",
|
|
9312
|
+
"lists.canJoin": "plain",
|
|
9313
|
+
"lists.separate": "listsMutationResult",
|
|
9314
|
+
"lists.setLevel": "listsMutationResult",
|
|
9315
|
+
"lists.setValue": "listsMutationResult",
|
|
9316
|
+
"lists.continuePrevious": "listsMutationResult",
|
|
9317
|
+
"lists.canContinuePrevious": "plain",
|
|
9318
|
+
"lists.setLevelRestart": "listsMutationResult",
|
|
9319
|
+
"lists.convertToText": "listsMutationResult",
|
|
8937
9320
|
"comments.create": "commentReceipt",
|
|
8938
9321
|
"comments.patch": "commentReceipt",
|
|
8939
9322
|
"comments.delete": "commentReceipt",
|
|
@@ -9020,11 +9403,20 @@ var init_operation_hints = __esm(() => {
|
|
|
9020
9403
|
"lists.list": "result",
|
|
9021
9404
|
"lists.get": "item",
|
|
9022
9405
|
"lists.insert": "result",
|
|
9023
|
-
"lists.setType": "result",
|
|
9024
9406
|
"lists.indent": "result",
|
|
9025
9407
|
"lists.outdent": "result",
|
|
9026
|
-
"lists.
|
|
9027
|
-
"lists.
|
|
9408
|
+
"lists.create": "result",
|
|
9409
|
+
"lists.attach": "result",
|
|
9410
|
+
"lists.detach": "result",
|
|
9411
|
+
"lists.join": "result",
|
|
9412
|
+
"lists.canJoin": "result",
|
|
9413
|
+
"lists.separate": "result",
|
|
9414
|
+
"lists.setLevel": "result",
|
|
9415
|
+
"lists.setValue": "result",
|
|
9416
|
+
"lists.continuePrevious": "result",
|
|
9417
|
+
"lists.canContinuePrevious": "result",
|
|
9418
|
+
"lists.setLevelRestart": "result",
|
|
9419
|
+
"lists.convertToText": "result",
|
|
9028
9420
|
"comments.create": "receipt",
|
|
9029
9421
|
"comments.patch": "receipt",
|
|
9030
9422
|
"comments.delete": "receipt",
|
|
@@ -9118,11 +9510,20 @@ var init_operation_hints = __esm(() => {
|
|
|
9118
9510
|
"lists.list": "lists",
|
|
9119
9511
|
"lists.get": "lists",
|
|
9120
9512
|
"lists.insert": "lists",
|
|
9121
|
-
"lists.setType": "lists",
|
|
9122
9513
|
"lists.indent": "lists",
|
|
9123
9514
|
"lists.outdent": "lists",
|
|
9124
|
-
"lists.
|
|
9125
|
-
"lists.
|
|
9515
|
+
"lists.create": "lists",
|
|
9516
|
+
"lists.attach": "lists",
|
|
9517
|
+
"lists.detach": "lists",
|
|
9518
|
+
"lists.join": "lists",
|
|
9519
|
+
"lists.canJoin": "lists",
|
|
9520
|
+
"lists.separate": "lists",
|
|
9521
|
+
"lists.setLevel": "lists",
|
|
9522
|
+
"lists.setValue": "lists",
|
|
9523
|
+
"lists.continuePrevious": "lists",
|
|
9524
|
+
"lists.canContinuePrevious": "lists",
|
|
9525
|
+
"lists.setLevelRestart": "lists",
|
|
9526
|
+
"lists.convertToText": "lists",
|
|
9126
9527
|
"comments.create": "comments",
|
|
9127
9528
|
"comments.patch": "comments",
|
|
9128
9529
|
"comments.delete": "comments",
|
|
@@ -12156,11 +12557,18 @@ var init_capabilities_adapter = __esm(() => {
|
|
|
12156
12557
|
"create.paragraph": ["insertParagraphAt"],
|
|
12157
12558
|
"create.heading": ["insertHeadingAt"],
|
|
12158
12559
|
"lists.insert": ["insertListItemAt"],
|
|
12159
|
-
"lists.
|
|
12160
|
-
"lists.
|
|
12161
|
-
"lists.
|
|
12162
|
-
"lists.
|
|
12163
|
-
"lists.
|
|
12560
|
+
"lists.indent": [],
|
|
12561
|
+
"lists.outdent": [],
|
|
12562
|
+
"lists.create": [],
|
|
12563
|
+
"lists.attach": [],
|
|
12564
|
+
"lists.detach": [],
|
|
12565
|
+
"lists.join": [],
|
|
12566
|
+
"lists.separate": [],
|
|
12567
|
+
"lists.setLevel": [],
|
|
12568
|
+
"lists.setValue": [],
|
|
12569
|
+
"lists.continuePrevious": [],
|
|
12570
|
+
"lists.setLevelRestart": [],
|
|
12571
|
+
"lists.convertToText": [],
|
|
12164
12572
|
"blocks.delete": ["deleteBlockNodeById"],
|
|
12165
12573
|
"comments.create": ["addComment", "setTextSelection", "addCommentReply"],
|
|
12166
12574
|
"comments.patch": ["editComment", "moveComment", "resolveComment", "setCommentInternal"],
|
|
@@ -42299,11 +42707,6 @@ function eighthPointsToPixels(eighthPoints) {
|
|
|
42299
42707
|
const pixels = points * 1.3333;
|
|
42300
42708
|
return pixels;
|
|
42301
42709
|
}
|
|
42302
|
-
function pixelsToEightPoints(pixels) {
|
|
42303
|
-
if (pixels == null)
|
|
42304
|
-
return;
|
|
42305
|
-
return Math.round(pixels * 6);
|
|
42306
|
-
}
|
|
42307
42710
|
function twipsToPt(twips) {
|
|
42308
42711
|
if (twips == null)
|
|
42309
42712
|
return;
|
|
@@ -47993,16 +48396,9 @@ function handleTableCellNode({
|
|
|
47993
48396
|
table,
|
|
47994
48397
|
row,
|
|
47995
48398
|
tableProperties,
|
|
47996
|
-
rowBorders,
|
|
47997
|
-
baseTableBorders,
|
|
47998
|
-
tableLook,
|
|
47999
|
-
rowCnfStyle,
|
|
48000
48399
|
columnIndex,
|
|
48001
48400
|
columnWidth = null,
|
|
48002
48401
|
allColumnWidths = [],
|
|
48003
|
-
rowIndex = 0,
|
|
48004
|
-
totalRows = 1,
|
|
48005
|
-
totalColumns,
|
|
48006
48402
|
preferTableGridWidths = false,
|
|
48007
48403
|
_referencedStyles
|
|
48008
48404
|
}) {
|
|
@@ -48012,26 +48408,7 @@ function handleTableCellNode({
|
|
|
48012
48408
|
const tcPr = node3.elements.find((el) => el.name === "w:tcPr");
|
|
48013
48409
|
const tableCellProperties = tcPr ? translator116.encode({ ...params2, nodes: [tcPr] }) ?? {} : {};
|
|
48014
48410
|
attributes["tableCellProperties"] = tableCellProperties;
|
|
48015
|
-
const effectiveTotalColumns = totalColumns ?? (allColumnWidths.length || 1);
|
|
48016
|
-
const effectiveTotalRows = totalRows ?? (table?.elements?.filter((el) => el.name === "w:tr").length || 1);
|
|
48017
48411
|
const colspan = parseInt(tableCellProperties.gridSpan || 1, 10);
|
|
48018
|
-
const isFirstRow = rowIndex === 0;
|
|
48019
|
-
const isLastRow = rowIndex === effectiveTotalRows - 1;
|
|
48020
|
-
const isFirstColumn = columnIndex === 0;
|
|
48021
|
-
const isLastColumn = columnIndex + colspan >= effectiveTotalColumns;
|
|
48022
|
-
attributes["borders"] = processCellBorders({
|
|
48023
|
-
baseTableBorders,
|
|
48024
|
-
rowBorders,
|
|
48025
|
-
tableLook,
|
|
48026
|
-
rowCnfStyle,
|
|
48027
|
-
isFirstRow,
|
|
48028
|
-
isLastRow,
|
|
48029
|
-
isFirstColumn,
|
|
48030
|
-
isLastColumn,
|
|
48031
|
-
tableCellProperties,
|
|
48032
|
-
referencedStyles,
|
|
48033
|
-
hasBorderSpacing: !!tableProperties?.tableCellSpacing
|
|
48034
|
-
});
|
|
48035
48412
|
if (colspan > 1)
|
|
48036
48413
|
attributes["colspan"] = colspan;
|
|
48037
48414
|
let width = null;
|
|
@@ -48207,112 +48584,7 @@ function normalizeTableCellContent(content3, editor) {
|
|
|
48207
48584
|
}
|
|
48208
48585
|
return normalized;
|
|
48209
48586
|
}
|
|
48210
|
-
var
|
|
48211
|
-
if (!borders)
|
|
48212
|
-
return null;
|
|
48213
|
-
return ["bottom", "top", "left", "right"].reduce((acc, direction) => {
|
|
48214
|
-
const borderAttrs = borders[direction];
|
|
48215
|
-
const rowBorderAttrs = rowBorders[direction];
|
|
48216
|
-
if (borderAttrs && borderAttrs["val"] !== "none") {
|
|
48217
|
-
const color2 = borderAttrs["color"];
|
|
48218
|
-
let size2 = borderAttrs["size"];
|
|
48219
|
-
if (size2)
|
|
48220
|
-
size2 = eighthPointsToPixels(size2);
|
|
48221
|
-
acc[direction] = { color: color2, size: size2, val: borderAttrs["val"] };
|
|
48222
|
-
return acc;
|
|
48223
|
-
}
|
|
48224
|
-
if (borderAttrs && borderAttrs["val"] === "none") {
|
|
48225
|
-
const border = Object.assign({}, rowBorderAttrs || {});
|
|
48226
|
-
border["val"] = "none";
|
|
48227
|
-
acc[direction] = border;
|
|
48228
|
-
return acc;
|
|
48229
|
-
}
|
|
48230
|
-
return acc;
|
|
48231
|
-
}, {});
|
|
48232
|
-
}, processCellBorders = ({
|
|
48233
|
-
baseTableBorders,
|
|
48234
|
-
rowBorders,
|
|
48235
|
-
tableLook,
|
|
48236
|
-
rowCnfStyle,
|
|
48237
|
-
isFirstRow,
|
|
48238
|
-
isLastRow,
|
|
48239
|
-
isFirstColumn,
|
|
48240
|
-
isLastColumn,
|
|
48241
|
-
tableCellProperties,
|
|
48242
|
-
referencedStyles,
|
|
48243
|
-
hasBorderSpacing
|
|
48244
|
-
}) => {
|
|
48245
|
-
let cellBorders = {};
|
|
48246
|
-
if (baseTableBorders) {
|
|
48247
|
-
if ((isFirstRow || hasBorderSpacing) && baseTableBorders.top) {
|
|
48248
|
-
cellBorders.top = baseTableBorders.top;
|
|
48249
|
-
}
|
|
48250
|
-
if ((isLastRow || hasBorderSpacing) && baseTableBorders.bottom) {
|
|
48251
|
-
cellBorders.bottom = baseTableBorders.bottom;
|
|
48252
|
-
}
|
|
48253
|
-
if ((isFirstColumn || hasBorderSpacing) && baseTableBorders.left) {
|
|
48254
|
-
cellBorders.left = baseTableBorders.left;
|
|
48255
|
-
}
|
|
48256
|
-
if ((isLastColumn || hasBorderSpacing) && baseTableBorders.right) {
|
|
48257
|
-
cellBorders.right = baseTableBorders.right;
|
|
48258
|
-
}
|
|
48259
|
-
}
|
|
48260
|
-
if (rowBorders) {
|
|
48261
|
-
if (rowBorders.top?.val) {
|
|
48262
|
-
cellBorders.top = rowBorders.top;
|
|
48263
|
-
}
|
|
48264
|
-
if (rowBorders.bottom?.val) {
|
|
48265
|
-
cellBorders.bottom = rowBorders.bottom;
|
|
48266
|
-
}
|
|
48267
|
-
if (rowBorders.left?.val) {
|
|
48268
|
-
const applyLeftToAll = rowBorders.left.val === "none";
|
|
48269
|
-
if (applyLeftToAll || isFirstColumn) {
|
|
48270
|
-
cellBorders.left = rowBorders.left;
|
|
48271
|
-
}
|
|
48272
|
-
}
|
|
48273
|
-
if (rowBorders.right?.val) {
|
|
48274
|
-
const applyRightToAll = rowBorders.right.val === "none";
|
|
48275
|
-
if (applyRightToAll || isLastColumn) {
|
|
48276
|
-
cellBorders.right = rowBorders.right;
|
|
48277
|
-
}
|
|
48278
|
-
}
|
|
48279
|
-
if (!isLastRow && rowBorders.insideH) {
|
|
48280
|
-
cellBorders.bottom = rowBorders.insideH;
|
|
48281
|
-
}
|
|
48282
|
-
if (!isLastColumn && rowBorders.insideV) {
|
|
48283
|
-
cellBorders.right = rowBorders.insideV;
|
|
48284
|
-
}
|
|
48285
|
-
}
|
|
48286
|
-
const getStyleTableCellBorders = (styleVariant) => styleVariant?.tableCellProperties?.borders ?? null;
|
|
48287
|
-
const cellCnfStyle = tableCellProperties?.cnfStyle;
|
|
48288
|
-
const getFlag = (source, flag) => source && Object.prototype.hasOwnProperty.call(source, flag) ? source[flag] : undefined;
|
|
48289
|
-
const isStyleEnabled = (flag) => getFlag(cellCnfStyle, flag) ?? getFlag(rowCnfStyle, flag) ?? getFlag(tableLook, flag) ?? true;
|
|
48290
|
-
const applyStyleBorders = (styleVariant, allowedDirections) => {
|
|
48291
|
-
const styleBorders = getStyleTableCellBorders(styleVariant);
|
|
48292
|
-
if (!styleBorders)
|
|
48293
|
-
return;
|
|
48294
|
-
const filteredBorders = allowedDirections.reduce((acc, direction) => {
|
|
48295
|
-
if (styleBorders[direction])
|
|
48296
|
-
acc[direction] = styleBorders[direction];
|
|
48297
|
-
return acc;
|
|
48298
|
-
}, {});
|
|
48299
|
-
const styleOverrides = processInlineCellBorders(filteredBorders, cellBorders);
|
|
48300
|
-
if (styleOverrides)
|
|
48301
|
-
cellBorders = Object.assign(cellBorders, styleOverrides);
|
|
48302
|
-
};
|
|
48303
|
-
if (isFirstRow && isStyleEnabled("firstRow"))
|
|
48304
|
-
applyStyleBorders(referencedStyles?.firstRow, ["top", "bottom"]);
|
|
48305
|
-
if (isLastRow && isStyleEnabled("lastRow"))
|
|
48306
|
-
applyStyleBorders(referencedStyles?.lastRow, ["top", "bottom"]);
|
|
48307
|
-
if (isFirstColumn && isStyleEnabled("firstColumn"))
|
|
48308
|
-
applyStyleBorders(referencedStyles?.firstCol, ["left", "right"]);
|
|
48309
|
-
if (isLastColumn && isStyleEnabled("lastColumn"))
|
|
48310
|
-
applyStyleBorders(referencedStyles?.lastCol, ["left", "right"]);
|
|
48311
|
-
const inlineBorders = processInlineCellBorders(tableCellProperties.borders, cellBorders);
|
|
48312
|
-
if (inlineBorders)
|
|
48313
|
-
cellBorders = Object.assign(cellBorders, inlineBorders);
|
|
48314
|
-
return cellBorders;
|
|
48315
|
-
}, getTableCellVMerge = (node3) => {
|
|
48587
|
+
var getTableCellVMerge = (node3) => {
|
|
48316
48588
|
const tcPr = node3.elements.find((el) => el.name === "w:tcPr");
|
|
48317
48589
|
const vMerge = tcPr?.elements?.find((el) => el.name === "w:vMerge");
|
|
48318
48590
|
if (!vMerge)
|
|
@@ -48341,6 +48613,38 @@ var init_legacy_handle_table_cell_node = __esm(() => {
|
|
|
48341
48613
|
init_tcPr();
|
|
48342
48614
|
});
|
|
48343
48615
|
|
|
48616
|
+
// ../../packages/super-editor/src/extensions/table-cell/helpers/legacyBorderMigration.js
|
|
48617
|
+
function isLegacySchemaDefaultBorders(borders) {
|
|
48618
|
+
if (!borders || typeof borders !== "object")
|
|
48619
|
+
return false;
|
|
48620
|
+
return SIDES.every((side) => {
|
|
48621
|
+
const b = borders[side];
|
|
48622
|
+
if (!b || typeof b !== "object")
|
|
48623
|
+
return false;
|
|
48624
|
+
return !("val" in b) && b.size === 0.66665 && b.color === "#000000";
|
|
48625
|
+
});
|
|
48626
|
+
}
|
|
48627
|
+
function convertBordersToOoxmlFormat(borders) {
|
|
48628
|
+
const result = {};
|
|
48629
|
+
for (const side of SIDES) {
|
|
48630
|
+
const b = borders[side];
|
|
48631
|
+
if (!b || typeof b !== "object")
|
|
48632
|
+
continue;
|
|
48633
|
+
result[side] = {
|
|
48634
|
+
val: b.val || "single",
|
|
48635
|
+
size: typeof b.size === "number" ? pxToEighthPoints(b.size) : 4,
|
|
48636
|
+
space: b.space || 0,
|
|
48637
|
+
color: b.color === "#000000" ? "auto" : b.color || "auto"
|
|
48638
|
+
};
|
|
48639
|
+
}
|
|
48640
|
+
return result;
|
|
48641
|
+
}
|
|
48642
|
+
var PX_PER_PT, pxToEighthPoints = (px) => Math.round(px / PX_PER_PT * 8), SIDES;
|
|
48643
|
+
var init_legacyBorderMigration = __esm(() => {
|
|
48644
|
+
PX_PER_PT = 96 / 72;
|
|
48645
|
+
SIDES = ["top", "right", "bottom", "left"];
|
|
48646
|
+
});
|
|
48647
|
+
|
|
48344
48648
|
// ../../packages/super-editor/src/core/super-converter/v3/handlers/w/tc/helpers/translate-table-cell.js
|
|
48345
48649
|
function translateTableCell(params2) {
|
|
48346
48650
|
const elements = translateChildNodes({
|
|
@@ -48355,7 +48659,7 @@ function translateTableCell(params2) {
|
|
|
48355
48659
|
};
|
|
48356
48660
|
}
|
|
48357
48661
|
function generateTableCellProperties(node3) {
|
|
48358
|
-
|
|
48662
|
+
let tableCellProperties = { ...node3.attrs?.tableCellProperties || {} };
|
|
48359
48663
|
const { attrs } = node3;
|
|
48360
48664
|
const { colwidth: rawColwidth, widthUnit = "px" } = attrs;
|
|
48361
48665
|
const resolvedWidthType = attrs.cellWidthType ?? (attrs.widthType !== "auto" ? attrs.widthType : undefined) ?? tableCellProperties.cellWidth?.type ?? "dxa";
|
|
@@ -48412,32 +48716,13 @@ function generateTableCellProperties(node3) {
|
|
|
48412
48716
|
} else {
|
|
48413
48717
|
delete tableCellProperties.vMerge;
|
|
48414
48718
|
}
|
|
48415
|
-
|
|
48416
|
-
|
|
48417
|
-
|
|
48418
|
-
|
|
48419
|
-
|
|
48420
|
-
|
|
48421
|
-
|
|
48422
|
-
if (borders[side].color && color2 === "#000000") {
|
|
48423
|
-
color2 = "auto";
|
|
48424
|
-
}
|
|
48425
|
-
if (currentPropertySizePixels !== borders[side].size || currentPropertyValue?.color !== color2 || borders[side].val !== currentPropertyValue?.val) {
|
|
48426
|
-
if (!tableCellProperties.borders)
|
|
48427
|
-
tableCellProperties["borders"] = {};
|
|
48428
|
-
tableCellProperties.borders[side] = {
|
|
48429
|
-
size: pixelsToEightPoints(borders[side].size || 0),
|
|
48430
|
-
color: color2,
|
|
48431
|
-
space: borders[side].space || 0,
|
|
48432
|
-
val: borders[side].val || "single"
|
|
48433
|
-
};
|
|
48434
|
-
}
|
|
48435
|
-
} else if (tableCellProperties.borders?.[side]) {
|
|
48436
|
-
delete tableCellProperties.borders[side];
|
|
48437
|
-
}
|
|
48438
|
-
});
|
|
48439
|
-
} else if (tableCellProperties?.borders) {
|
|
48440
|
-
delete tableCellProperties.borders;
|
|
48719
|
+
if (!tableCellProperties?.borders && attrs.borders != null) {
|
|
48720
|
+
if (!isLegacySchemaDefaultBorders(attrs.borders)) {
|
|
48721
|
+
tableCellProperties = {
|
|
48722
|
+
...tableCellProperties ?? {},
|
|
48723
|
+
borders: convertBordersToOoxmlFormat(attrs.borders)
|
|
48724
|
+
};
|
|
48725
|
+
}
|
|
48441
48726
|
}
|
|
48442
48727
|
const result = translator116.decode({ node: { ...node3, attrs: { ...node3.attrs, tableCellProperties } } });
|
|
48443
48728
|
return result;
|
|
@@ -48446,6 +48731,7 @@ var init_translate_table_cell = __esm(() => {
|
|
|
48446
48731
|
init_helpers();
|
|
48447
48732
|
init_helpers2();
|
|
48448
48733
|
init_tcPr();
|
|
48734
|
+
init_legacyBorderMigration();
|
|
48449
48735
|
});
|
|
48450
48736
|
|
|
48451
48737
|
// ../../packages/super-editor/src/core/super-converter/v3/handlers/w/tc/tc-translator.js
|
|
@@ -48455,16 +48741,9 @@ function encode30(params2, encodedAttrs) {
|
|
|
48455
48741
|
table,
|
|
48456
48742
|
row,
|
|
48457
48743
|
tableProperties,
|
|
48458
|
-
rowBorders,
|
|
48459
|
-
baseTableBorders,
|
|
48460
|
-
tableLook,
|
|
48461
|
-
rowCnfStyle,
|
|
48462
48744
|
columnIndex,
|
|
48463
48745
|
columnWidth,
|
|
48464
48746
|
columnWidths: allColumnWidths,
|
|
48465
|
-
rowIndex,
|
|
48466
|
-
totalRows,
|
|
48467
|
-
totalColumns,
|
|
48468
48747
|
preferTableGridWidths,
|
|
48469
48748
|
_referencedStyles
|
|
48470
48749
|
} = params2.extraParams;
|
|
@@ -48474,16 +48753,9 @@ function encode30(params2, encodedAttrs) {
|
|
|
48474
48753
|
table,
|
|
48475
48754
|
row,
|
|
48476
48755
|
tableProperties,
|
|
48477
|
-
rowBorders,
|
|
48478
|
-
baseTableBorders,
|
|
48479
|
-
tableLook,
|
|
48480
|
-
rowCnfStyle,
|
|
48481
48756
|
columnIndex,
|
|
48482
48757
|
columnWidth,
|
|
48483
48758
|
allColumnWidths,
|
|
48484
|
-
rowIndex,
|
|
48485
|
-
totalRows,
|
|
48486
|
-
totalColumns,
|
|
48487
48759
|
preferTableGridWidths,
|
|
48488
48760
|
_referencedStyles
|
|
48489
48761
|
});
|
|
@@ -48813,50 +49085,12 @@ var createPlaceholderCell = (gridWidth, reason) => {
|
|
|
48813
49085
|
};
|
|
48814
49086
|
|
|
48815
49087
|
// ../../packages/super-editor/src/core/super-converter/v3/handlers/w/tr/tr-translator.js
|
|
48816
|
-
function getRowBorders({ params: params2, row, baseBorders }) {
|
|
48817
|
-
const tblPrEx = row?.elements?.find?.((el) => el.name === "w:tblPrEx");
|
|
48818
|
-
const tblBorders = tblPrEx?.elements?.find?.((el) => el.name === "w:tblBorders");
|
|
48819
|
-
const rowBaseBorders = {};
|
|
48820
|
-
if (baseBorders?.insideV) {
|
|
48821
|
-
rowBaseBorders.insideV = baseBorders?.insideV;
|
|
48822
|
-
}
|
|
48823
|
-
if (baseBorders?.insideH) {
|
|
48824
|
-
rowBaseBorders.insideH = baseBorders?.insideH;
|
|
48825
|
-
}
|
|
48826
|
-
if (!tblBorders) {
|
|
48827
|
-
return rowBaseBorders;
|
|
48828
|
-
}
|
|
48829
|
-
const rawOverrides = translator118.encode({ ...params2, nodes: [tblBorders] }) || {};
|
|
48830
|
-
const overrides = processRawTableBorders(rawOverrides);
|
|
48831
|
-
if (!Object.keys(overrides).length) {
|
|
48832
|
-
return rowBaseBorders;
|
|
48833
|
-
}
|
|
48834
|
-
const rowBorders = { ...rowBaseBorders, ...overrides };
|
|
48835
|
-
return rowBorders;
|
|
48836
|
-
}
|
|
48837
|
-
function processRawTableBorders(rawBorders) {
|
|
48838
|
-
const borders = {};
|
|
48839
|
-
Object.entries(rawBorders || {}).forEach(([name, attributes]) => {
|
|
48840
|
-
const attrs = {};
|
|
48841
|
-
const color2 = attributes?.color;
|
|
48842
|
-
const size2 = attributes?.size;
|
|
48843
|
-
const val = attributes?.val;
|
|
48844
|
-
if (color2 && color2 !== "auto")
|
|
48845
|
-
attrs.color = color2.startsWith("#") ? color2 : `#${color2}`;
|
|
48846
|
-
if (size2 != null && size2 !== "auto")
|
|
48847
|
-
attrs.size = eighthPointsToPixels(size2);
|
|
48848
|
-
if (val)
|
|
48849
|
-
attrs.val = val;
|
|
48850
|
-
borders[name] = attrs;
|
|
48851
|
-
});
|
|
48852
|
-
return borders;
|
|
48853
|
-
}
|
|
48854
49088
|
var XML_NODE_NAME10 = "w:tr", SD_NODE_NAME7 = "tableRow", validXmlAttributes4, getColspan = (cell) => {
|
|
48855
49089
|
const rawColspan = cell?.attrs?.colspan;
|
|
48856
49090
|
const numericColspan = typeof rawColspan === "string" ? parseInt(rawColspan, 10) : rawColspan;
|
|
48857
49091
|
return Number.isFinite(numericColspan) && numericColspan > 0 ? numericColspan : 1;
|
|
48858
49092
|
}, encode31 = (params2, encodedAttrs) => {
|
|
48859
|
-
const { row
|
|
49093
|
+
const { row } = params2.extraParams;
|
|
48860
49094
|
let tableRowProperties = {};
|
|
48861
49095
|
const tPr = row.elements.find((el) => el.name === "w:trPr");
|
|
48862
49096
|
if (tPr) {
|
|
@@ -48867,16 +49101,17 @@ var XML_NODE_NAME10 = "w:tr", SD_NODE_NAME7 = "tableRow", validXmlAttributes4, g
|
|
|
48867
49101
|
}
|
|
48868
49102
|
const gridBeforeRaw = tableRowProperties?.["gridBefore"];
|
|
48869
49103
|
const safeGridBefore = typeof gridBeforeRaw === "number" && Number.isFinite(gridBeforeRaw) && gridBeforeRaw > 0 ? gridBeforeRaw : 0;
|
|
49104
|
+
const tblPrEx = row.elements?.find((el) => el.name === "w:tblPrEx");
|
|
49105
|
+
const tblPrExBorders = tblPrEx?.elements?.find((el) => el.name === "w:tblBorders");
|
|
49106
|
+
if (tblPrExBorders) {
|
|
49107
|
+
const parsed = translator118.encode({ ...params2, nodes: [tblPrExBorders] });
|
|
49108
|
+
if (parsed && Object.keys(parsed).length > 0) {
|
|
49109
|
+
tableRowProperties = { ...tableRowProperties, tblPrExBorders: parsed };
|
|
49110
|
+
}
|
|
49111
|
+
}
|
|
48870
49112
|
encodedAttrs["tableRowProperties"] = Object.freeze(tableRowProperties);
|
|
48871
49113
|
encodedAttrs["rowHeight"] = twipsToPixels(tableRowProperties["rowHeight"]?.value);
|
|
48872
49114
|
encodedAttrs["cantSplit"] = tableRowProperties["cantSplit"];
|
|
48873
|
-
const rowCnfStyle = tableRowProperties?.cnfStyle;
|
|
48874
|
-
const baseBorders = params2.extraParams?.tableBorders;
|
|
48875
|
-
const rowBorders = getRowBorders({
|
|
48876
|
-
params: params2,
|
|
48877
|
-
row,
|
|
48878
|
-
baseBorders
|
|
48879
|
-
});
|
|
48880
49115
|
const { columnWidths: gridColumnWidths, activeRowSpans = [] } = params2.extraParams;
|
|
48881
49116
|
const totalColumns = Array.isArray(gridColumnWidths) ? gridColumnWidths.length : 0;
|
|
48882
49117
|
const pendingRowSpans = Array.isArray(activeRowSpans) ? activeRowSpans.slice() : [];
|
|
@@ -48911,10 +49146,6 @@ var XML_NODE_NAME10 = "w:tr", SD_NODE_NAME7 = "tableRow", validXmlAttributes4, g
|
|
|
48911
49146
|
path: [...params2.path || [], node3],
|
|
48912
49147
|
extraParams: {
|
|
48913
49148
|
...params2.extraParams,
|
|
48914
|
-
rowBorders,
|
|
48915
|
-
baseTableBorders: baseBorders,
|
|
48916
|
-
tableLook,
|
|
48917
|
-
rowCnfStyle,
|
|
48918
49149
|
node: node3,
|
|
48919
49150
|
columnIndex: startColumn,
|
|
48920
49151
|
columnWidth
|
|
@@ -49003,9 +49234,19 @@ var XML_NODE_NAME10 = "w:tr", SD_NODE_NAME7 = "tableRow", validXmlAttributes4, g
|
|
|
49003
49234
|
}
|
|
49004
49235
|
}
|
|
49005
49236
|
tableRowProperties["cantSplit"] = node3.attrs["cantSplit"];
|
|
49237
|
+
const { tblPrExBorders, ...trPrProperties } = tableRowProperties;
|
|
49238
|
+
if (tblPrExBorders && typeof tblPrExBorders === "object" && Object.keys(tblPrExBorders).length > 0) {
|
|
49239
|
+
const bordersXml = translator118.decode({
|
|
49240
|
+
...params2,
|
|
49241
|
+
node: { type: "tableRow", attrs: { borders: tblPrExBorders } }
|
|
49242
|
+
});
|
|
49243
|
+
if (bordersXml) {
|
|
49244
|
+
elements.unshift({ name: "w:tblPrEx", elements: [bordersXml] });
|
|
49245
|
+
}
|
|
49246
|
+
}
|
|
49006
49247
|
const trPr = translator128.decode({
|
|
49007
49248
|
...params2,
|
|
49008
|
-
node: { ...node3, attrs: { ...node3.attrs, tableRowProperties } }
|
|
49249
|
+
node: { ...node3, attrs: { ...node3.attrs, tableRowProperties: trPrProperties } }
|
|
49009
49250
|
});
|
|
49010
49251
|
if (trPr)
|
|
49011
49252
|
elements.unshift(trPr);
|
|
@@ -56360,6 +56601,20 @@ function combineIndentProperties(indentChain) {
|
|
|
56360
56601
|
});
|
|
56361
56602
|
}
|
|
56362
56603
|
|
|
56604
|
+
// ../../packages/layout-engine/style-engine/src/ooxml/table-style-selection.ts
|
|
56605
|
+
var TABLE_FALLBACK_BORDER, TABLE_FALLBACK_BORDERS;
|
|
56606
|
+
var init_table_style_selection = __esm(() => {
|
|
56607
|
+
TABLE_FALLBACK_BORDER = { val: "single", size: 4, color: "#000000" };
|
|
56608
|
+
TABLE_FALLBACK_BORDERS = {
|
|
56609
|
+
top: { ...TABLE_FALLBACK_BORDER },
|
|
56610
|
+
left: { ...TABLE_FALLBACK_BORDER },
|
|
56611
|
+
bottom: { ...TABLE_FALLBACK_BORDER },
|
|
56612
|
+
right: { ...TABLE_FALLBACK_BORDER },
|
|
56613
|
+
insideH: { ...TABLE_FALLBACK_BORDER },
|
|
56614
|
+
insideV: { ...TABLE_FALLBACK_BORDER }
|
|
56615
|
+
};
|
|
56616
|
+
});
|
|
56617
|
+
|
|
56363
56618
|
// ../../packages/layout-engine/style-engine/src/ooxml/index.ts
|
|
56364
56619
|
function resolveRunProperties(params2, inlineRpr, resolvedPpr, tableInfo = null, isListNumber = false, numberingDefinedInline = false) {
|
|
56365
56620
|
if (!params2.translatedLinkedStyles?.styles) {
|
|
@@ -56502,13 +56757,13 @@ function resolveStyleChain(propertyType, params2, styleId, followBasedOnChain =
|
|
|
56502
56757
|
const styleProps = styleDef[propertyType] ?? {};
|
|
56503
56758
|
const basedOn = styleDef.basedOn;
|
|
56504
56759
|
let styleChain = [styleProps];
|
|
56505
|
-
const seenStyles = new Set;
|
|
56760
|
+
const seenStyles = new Set([styleId]);
|
|
56506
56761
|
let nextBasedOn = basedOn;
|
|
56507
56762
|
while (followBasedOnChain && nextBasedOn) {
|
|
56508
56763
|
if (seenStyles.has(nextBasedOn)) {
|
|
56509
56764
|
break;
|
|
56510
56765
|
}
|
|
56511
|
-
seenStyles.add(
|
|
56766
|
+
seenStyles.add(nextBasedOn);
|
|
56512
56767
|
const basedOnStyleDef = params2.translatedLinkedStyles?.styles?.[nextBasedOn];
|
|
56513
56768
|
const basedOnProps = basedOnStyleDef?.[propertyType];
|
|
56514
56769
|
if (basedOnProps && Object.keys(basedOnProps).length) {
|
|
@@ -56663,7 +56918,9 @@ function determineCellStyleTypes(tblLook, rowIndex, cellIndex, numRows, numCells
|
|
|
56663
56918
|
}
|
|
56664
56919
|
return styleTypes;
|
|
56665
56920
|
}
|
|
56666
|
-
var init_ooxml = () => {
|
|
56921
|
+
var init_ooxml = __esm(() => {
|
|
56922
|
+
init_table_style_selection();
|
|
56923
|
+
});
|
|
56667
56924
|
|
|
56668
56925
|
// ../../packages/super-editor/src/core/super-converter/v3/handlers/wp/helpers/textbox-content-helpers.js
|
|
56669
56926
|
function collectTextBoxParagraphs(nodes, paragraphs = []) {
|
|
@@ -60121,7 +60378,6 @@ var validXmlAttributes9, XML_NODE_NAME16 = "w:tbl", SD_NODE_NAME12 = "table", IN
|
|
|
60121
60378
|
};
|
|
60122
60379
|
}
|
|
60123
60380
|
}
|
|
60124
|
-
const tableLook = encodedAttrs.tableProperties.tblLook;
|
|
60125
60381
|
const borderProps = _processTableBorders(encodedAttrs.tableProperties.borders || {});
|
|
60126
60382
|
const referencedStyles = _getReferencedTableStyles(encodedAttrs.tableStyleId, params2) || {};
|
|
60127
60383
|
encodedAttrs.borders = { ...referencedStyles.borders, ...borderProps };
|
|
@@ -60169,8 +60425,6 @@ var validXmlAttributes9, XML_NODE_NAME16 = "w:tbl", SD_NODE_NAME12 = "table", IN
|
|
|
60169
60425
|
row,
|
|
60170
60426
|
table: node3,
|
|
60171
60427
|
tableProperties: encodedAttrs.tableProperties,
|
|
60172
|
-
tableBorders: encodedAttrs.borders,
|
|
60173
|
-
tableLook,
|
|
60174
60428
|
columnWidths,
|
|
60175
60429
|
activeRowSpans: activeRowSpans.slice(),
|
|
60176
60430
|
rowIndex,
|
|
@@ -66400,7 +66654,7 @@ function translateContentBlock(params2) {
|
|
|
66400
66654
|
return wrapTextInRun(alternateContent);
|
|
66401
66655
|
}
|
|
66402
66656
|
function pxToPt(px) {
|
|
66403
|
-
const pt = Math.round(px /
|
|
66657
|
+
const pt = Math.round(px / PX_PER_PT2 * 10) / 10;
|
|
66404
66658
|
return `${pt}pt`;
|
|
66405
66659
|
}
|
|
66406
66660
|
function sizeToPt(value, options = {}) {
|
|
@@ -66503,7 +66757,7 @@ function translateVRectContentBlock(params2) {
|
|
|
66503
66757
|
};
|
|
66504
66758
|
return wrapTextInRun(pict);
|
|
66505
66759
|
}
|
|
66506
|
-
var FULL_WIDTH_PT = "468pt", FULL_WIDTH_PT_VALUE = 468,
|
|
66760
|
+
var FULL_WIDTH_PT = "468pt", FULL_WIDTH_PT_VALUE = 468, PX_PER_PT2 = 1.33;
|
|
66507
66761
|
var init_translate_content_block = __esm(() => {
|
|
66508
66762
|
init_altermateContent();
|
|
66509
66763
|
init_exporter();
|
|
@@ -67900,6 +68154,47 @@ var init_footnotesExporter = __esm(() => {
|
|
|
67900
68154
|
init_relationship_helpers();
|
|
67901
68155
|
});
|
|
67902
68156
|
|
|
68157
|
+
// ../../packages/super-editor/src/core/super-converter/export-helpers/strip-orphaned-numbering.js
|
|
68158
|
+
function collectReferencedNumIds(convertedXml) {
|
|
68159
|
+
const numIds = new Set;
|
|
68160
|
+
function walkElements(elements) {
|
|
68161
|
+
if (!Array.isArray(elements))
|
|
68162
|
+
return;
|
|
68163
|
+
for (const el of elements) {
|
|
68164
|
+
if (el.name === "w:numId" && el.attributes?.["w:val"] != null) {
|
|
68165
|
+
numIds.add(Number(el.attributes["w:val"]));
|
|
68166
|
+
}
|
|
68167
|
+
if (el.elements)
|
|
68168
|
+
walkElements(el.elements);
|
|
68169
|
+
}
|
|
68170
|
+
}
|
|
68171
|
+
for (const [path2, xml] of Object.entries(convertedXml)) {
|
|
68172
|
+
if (path2.startsWith("word/") && path2 !== "word/numbering.xml" && xml?.elements) {
|
|
68173
|
+
walkElements(xml.elements);
|
|
68174
|
+
}
|
|
68175
|
+
}
|
|
68176
|
+
return numIds;
|
|
68177
|
+
}
|
|
68178
|
+
function getAbstractNumIdFromDef(numDef) {
|
|
68179
|
+
const abstractEl = numDef.elements?.find((el) => el.name === "w:abstractNumId");
|
|
68180
|
+
if (abstractEl?.attributes?.["w:val"] != null) {
|
|
68181
|
+
return Number(abstractEl.attributes["w:val"]);
|
|
68182
|
+
}
|
|
68183
|
+
return;
|
|
68184
|
+
}
|
|
68185
|
+
function filterOrphanedNumberingDefinitions(numbering, referencedNumIds) {
|
|
68186
|
+
const liveDefinitions = Object.values(numbering.definitions).filter((def) => referencedNumIds.has(Number(def.attributes?.["w:numId"])));
|
|
68187
|
+
const referencedAbstractIds = new Set;
|
|
68188
|
+
for (const def of liveDefinitions) {
|
|
68189
|
+
const abstractId = getAbstractNumIdFromDef(def);
|
|
68190
|
+
if (abstractId != null) {
|
|
68191
|
+
referencedAbstractIds.add(abstractId);
|
|
68192
|
+
}
|
|
68193
|
+
}
|
|
68194
|
+
const liveAbstracts = Object.values(numbering.abstracts).filter((abs2) => referencedAbstractIds.has(Number(abs2.attributes?.["w:abstractNumId"])));
|
|
68195
|
+
return { liveAbstracts, liveDefinitions };
|
|
68196
|
+
}
|
|
68197
|
+
|
|
67903
68198
|
// ../../packages/super-editor/src/core/super-converter/SuperConverter.js
|
|
67904
68199
|
function generateCustomXml() {
|
|
67905
68200
|
return DEFAULT_CUSTOM_XML;
|
|
@@ -68690,13 +68985,12 @@ var init_SuperConverter = __esm(() => {
|
|
|
68690
68985
|
#exportNumberingFile() {
|
|
68691
68986
|
const numberingPath = "word/numbering.xml";
|
|
68692
68987
|
let numberingXml = this.convertedXml[numberingPath];
|
|
68693
|
-
const newNumbering = this.numbering;
|
|
68694
68988
|
if (!numberingXml)
|
|
68695
68989
|
numberingXml = baseNumbering;
|
|
68696
68990
|
const currentNumberingXml = numberingXml.elements[0];
|
|
68697
|
-
const
|
|
68698
|
-
const
|
|
68699
|
-
currentNumberingXml.elements = [...
|
|
68991
|
+
const referencedNumIds = collectReferencedNumIds(this.convertedXml);
|
|
68992
|
+
const { liveAbstracts, liveDefinitions } = filterOrphanedNumberingDefinitions(this.numbering, referencedNumIds);
|
|
68993
|
+
currentNumberingXml.elements = [...liveAbstracts, ...liveDefinitions];
|
|
68700
68994
|
this.convertedXml[numberingPath] = numberingXml;
|
|
68701
68995
|
}
|
|
68702
68996
|
#prepareCommentsXmlFilesForExport({ defs, exportType, commentsWithParaIds }) {
|
|
@@ -69463,21 +69757,6 @@ var init_InputRule = __esm(() => {
|
|
|
69463
69757
|
init_google_docs_paste();
|
|
69464
69758
|
});
|
|
69465
69759
|
|
|
69466
|
-
// ../../packages/super-editor/src/extensions/table-cell/helpers/createCellBorders.js
|
|
69467
|
-
var createCellBorders = (borderSpec = {}) => {
|
|
69468
|
-
borderSpec = {
|
|
69469
|
-
size: 0.66665,
|
|
69470
|
-
color: "#000000",
|
|
69471
|
-
...borderSpec
|
|
69472
|
-
};
|
|
69473
|
-
return {
|
|
69474
|
-
top: borderSpec,
|
|
69475
|
-
left: borderSpec,
|
|
69476
|
-
bottom: borderSpec,
|
|
69477
|
-
right: borderSpec
|
|
69478
|
-
};
|
|
69479
|
-
};
|
|
69480
|
-
|
|
69481
69760
|
// ../../packages/super-editor/src/core/helpers/catchAllSchema.js
|
|
69482
69761
|
function detectUnsupportedContent(element, schema) {
|
|
69483
69762
|
const itemsByTag = new Map;
|
|
@@ -69589,46 +69868,9 @@ function createDocFromHTML(content3, editor, options = {}) {
|
|
|
69589
69868
|
}
|
|
69590
69869
|
}
|
|
69591
69870
|
let doc = DOMParser2.fromSchema(editor.schema).parse(parsedContent);
|
|
69592
|
-
if (isImport) {
|
|
69593
|
-
doc = normalizeImportedHtmlTableHeaders(doc);
|
|
69594
|
-
}
|
|
69595
69871
|
doc = wrapTextsInRuns(doc);
|
|
69596
69872
|
return doc;
|
|
69597
69873
|
}
|
|
69598
|
-
var TABLE_HEADER_NODE_NAME = "tableHeader", hasMeaningfulCellBorders = (borderValue) => {
|
|
69599
|
-
if (!borderValue || typeof borderValue !== "object")
|
|
69600
|
-
return false;
|
|
69601
|
-
return Object.values(borderValue).some((side) => side && typeof side === "object" && Object.keys(side).length > 0);
|
|
69602
|
-
}, normalizeImportedHtmlTableHeaders = (doc) => {
|
|
69603
|
-
const normalizeNode = (node3) => {
|
|
69604
|
-
let nextNode = node3;
|
|
69605
|
-
if (node3.childCount > 0) {
|
|
69606
|
-
const nextChildren = [];
|
|
69607
|
-
let childrenChanged = false;
|
|
69608
|
-
node3.forEach((child) => {
|
|
69609
|
-
const normalizedChild = normalizeNode(child);
|
|
69610
|
-
if (normalizedChild !== child)
|
|
69611
|
-
childrenChanged = true;
|
|
69612
|
-
nextChildren.push(normalizedChild);
|
|
69613
|
-
});
|
|
69614
|
-
if (childrenChanged) {
|
|
69615
|
-
nextNode = node3.copy(Fragment.fromArray(nextChildren));
|
|
69616
|
-
}
|
|
69617
|
-
}
|
|
69618
|
-
if (nextNode.type.name !== TABLE_HEADER_NODE_NAME) {
|
|
69619
|
-
return nextNode;
|
|
69620
|
-
}
|
|
69621
|
-
if (hasMeaningfulCellBorders(nextNode.attrs?.borders)) {
|
|
69622
|
-
return nextNode;
|
|
69623
|
-
}
|
|
69624
|
-
const nextAttrs = {
|
|
69625
|
-
...nextNode.attrs,
|
|
69626
|
-
borders: createCellBorders()
|
|
69627
|
-
};
|
|
69628
|
-
return nextNode.type.create(nextAttrs, nextNode.content, nextNode.marks);
|
|
69629
|
-
};
|
|
69630
|
-
return normalizeNode(doc);
|
|
69631
|
-
};
|
|
69632
69874
|
var init_importHtml = __esm(() => {
|
|
69633
69875
|
init_dist();
|
|
69634
69876
|
init_InputRule();
|
|
@@ -69816,7 +70058,7 @@ var generateNewListDefinition = ({ numId, listType, level, start, text: text5, f
|
|
|
69816
70058
|
"w:abstractNumId": String(newAbstractId)
|
|
69817
70059
|
}
|
|
69818
70060
|
}));
|
|
69819
|
-
if (level && start && text5 && fmt) {
|
|
70061
|
+
if (level != null && start != null && text5 != null && fmt != null) {
|
|
69820
70062
|
if (newNumbering.definitions[numId]) {
|
|
69821
70063
|
const abstractId = newNumbering.definitions[numId]?.elements[0]?.attributes["w:val"];
|
|
69822
70064
|
newAbstractId = abstractId;
|
|
@@ -70094,6 +70336,153 @@ var generateNewListDefinition = ({ numId, listType, level, start, text: text5, f
|
|
|
70094
70336
|
return true;
|
|
70095
70337
|
}, replaceListWithNode = ({ tr, from: from3, to, newNode }) => {
|
|
70096
70338
|
tr.replaceWith(from3, to, newNode);
|
|
70339
|
+
}, setLvlOverride = (editor, numId, ilvl, overrides) => {
|
|
70340
|
+
const numbering = editor.converter.numbering;
|
|
70341
|
+
const numDef = numbering.definitions[numId];
|
|
70342
|
+
if (!numDef)
|
|
70343
|
+
return;
|
|
70344
|
+
const ilvlStr = String(ilvl);
|
|
70345
|
+
if (!numDef.elements)
|
|
70346
|
+
numDef.elements = [];
|
|
70347
|
+
let overrideEl = numDef.elements.find((el) => el.name === "w:lvlOverride" && el.attributes?.["w:ilvl"] === ilvlStr);
|
|
70348
|
+
if (!overrideEl) {
|
|
70349
|
+
overrideEl = {
|
|
70350
|
+
type: "element",
|
|
70351
|
+
name: "w:lvlOverride",
|
|
70352
|
+
attributes: { "w:ilvl": ilvlStr },
|
|
70353
|
+
elements: []
|
|
70354
|
+
};
|
|
70355
|
+
numDef.elements.push(overrideEl);
|
|
70356
|
+
}
|
|
70357
|
+
if (!overrideEl.elements)
|
|
70358
|
+
overrideEl.elements = [];
|
|
70359
|
+
if (overrides.startOverride != null) {
|
|
70360
|
+
const startEl = overrideEl.elements.find((el) => el.name === "w:startOverride");
|
|
70361
|
+
if (startEl) {
|
|
70362
|
+
startEl.attributes["w:val"] = String(overrides.startOverride);
|
|
70363
|
+
} else {
|
|
70364
|
+
overrideEl.elements.push({
|
|
70365
|
+
type: "element",
|
|
70366
|
+
name: "w:startOverride",
|
|
70367
|
+
attributes: { "w:val": String(overrides.startOverride) }
|
|
70368
|
+
});
|
|
70369
|
+
}
|
|
70370
|
+
}
|
|
70371
|
+
if ("lvlRestart" in overrides) {
|
|
70372
|
+
let lvlEl = overrideEl.elements.find((el) => el.name === "w:lvl");
|
|
70373
|
+
if (!lvlEl) {
|
|
70374
|
+
lvlEl = {
|
|
70375
|
+
type: "element",
|
|
70376
|
+
name: "w:lvl",
|
|
70377
|
+
attributes: { "w:ilvl": ilvlStr },
|
|
70378
|
+
elements: []
|
|
70379
|
+
};
|
|
70380
|
+
overrideEl.elements.push(lvlEl);
|
|
70381
|
+
}
|
|
70382
|
+
if (!lvlEl.elements)
|
|
70383
|
+
lvlEl.elements = [];
|
|
70384
|
+
if (overrides.lvlRestart === null) {
|
|
70385
|
+
lvlEl.elements = lvlEl.elements.filter((el) => el.name !== "w:lvlRestart");
|
|
70386
|
+
} else {
|
|
70387
|
+
const restartEl = lvlEl.elements.find((el) => el.name === "w:lvlRestart");
|
|
70388
|
+
if (restartEl) {
|
|
70389
|
+
restartEl.attributes["w:val"] = String(overrides.lvlRestart);
|
|
70390
|
+
} else {
|
|
70391
|
+
lvlEl.elements.push({
|
|
70392
|
+
type: "element",
|
|
70393
|
+
name: "w:lvlRestart",
|
|
70394
|
+
attributes: { "w:val": String(overrides.lvlRestart) }
|
|
70395
|
+
});
|
|
70396
|
+
}
|
|
70397
|
+
}
|
|
70398
|
+
}
|
|
70399
|
+
numbering.definitions[numId] = numDef;
|
|
70400
|
+
editor.converter.numbering = { ...numbering };
|
|
70401
|
+
syncTranslatedDefinition(editor, numId, numDef);
|
|
70402
|
+
emitDefinitionChange(editor, numDef);
|
|
70403
|
+
}, removeLvlOverride = (editor, numId, ilvl) => {
|
|
70404
|
+
const numbering = editor.converter.numbering;
|
|
70405
|
+
const numDef = numbering.definitions[numId];
|
|
70406
|
+
if (!numDef?.elements)
|
|
70407
|
+
return;
|
|
70408
|
+
const ilvlStr = String(ilvl);
|
|
70409
|
+
const idx = numDef.elements.findIndex((el) => el.name === "w:lvlOverride" && el.attributes?.["w:ilvl"] === ilvlStr);
|
|
70410
|
+
if (idx === -1)
|
|
70411
|
+
return;
|
|
70412
|
+
numDef.elements.splice(idx, 1);
|
|
70413
|
+
numbering.definitions[numId] = numDef;
|
|
70414
|
+
editor.converter.numbering = { ...numbering };
|
|
70415
|
+
syncTranslatedDefinition(editor, numId, numDef);
|
|
70416
|
+
emitDefinitionChange(editor, numDef);
|
|
70417
|
+
}, syncTranslatedDefinition = (editor, numId, rawNumDef) => {
|
|
70418
|
+
const translated = { ...editor.converter.translatedNumbering || {} };
|
|
70419
|
+
if (!translated.definitions)
|
|
70420
|
+
translated.definitions = {};
|
|
70421
|
+
translated.definitions[numId] = translator195.encode({ nodes: [rawNumDef] });
|
|
70422
|
+
editor.converter.translatedNumbering = translated;
|
|
70423
|
+
}, emitDefinitionChange = (editor, numDef) => {
|
|
70424
|
+
editor.emit("list-definitions-change", {
|
|
70425
|
+
change: { numDef, editor },
|
|
70426
|
+
numbering: editor.converter.numbering,
|
|
70427
|
+
editor
|
|
70428
|
+
});
|
|
70429
|
+
}, createNumDefinition = (editor, abstractNumId, options = {}) => {
|
|
70430
|
+
const numId = getNewListId(editor, "definitions");
|
|
70431
|
+
const numDef = getBasicNumIdTag(numId, abstractNumId);
|
|
70432
|
+
if (options.copyOverridesFrom != null) {
|
|
70433
|
+
const sourceNumDef = editor.converter.numbering.definitions[options.copyOverridesFrom];
|
|
70434
|
+
if (sourceNumDef?.elements) {
|
|
70435
|
+
const overrideEls = sourceNumDef.elements.filter((el) => el.name === "w:lvlOverride");
|
|
70436
|
+
if (overrideEls.length > 0) {
|
|
70437
|
+
numDef.elements = [...numDef.elements, ...JSON.parse(JSON.stringify(overrideEls))];
|
|
70438
|
+
}
|
|
70439
|
+
}
|
|
70440
|
+
}
|
|
70441
|
+
const numbering = editor.converter.numbering;
|
|
70442
|
+
numbering.definitions[numId] = numDef;
|
|
70443
|
+
editor.converter.numbering = { ...numbering };
|
|
70444
|
+
syncTranslatedDefinition(editor, numId, numDef);
|
|
70445
|
+
emitDefinitionChange(editor, numDef);
|
|
70446
|
+
return { numId, numDef };
|
|
70447
|
+
}, setLvlRestartOnAbstract = (editor, abstractNumId, ilvl, restartAfterLevel) => {
|
|
70448
|
+
const numbering = editor.converter.numbering;
|
|
70449
|
+
const abstract = numbering.abstracts[abstractNumId];
|
|
70450
|
+
if (!abstract?.elements)
|
|
70451
|
+
return;
|
|
70452
|
+
const ilvlStr = String(ilvl);
|
|
70453
|
+
const lvlEl = abstract.elements.find((el) => el.name === "w:lvl" && el.attributes?.["w:ilvl"] === ilvlStr);
|
|
70454
|
+
if (!lvlEl)
|
|
70455
|
+
return;
|
|
70456
|
+
if (!lvlEl.elements)
|
|
70457
|
+
lvlEl.elements = [];
|
|
70458
|
+
if (restartAfterLevel === null) {
|
|
70459
|
+
lvlEl.elements = lvlEl.elements.filter((el) => el.name !== "w:lvlRestart");
|
|
70460
|
+
} else {
|
|
70461
|
+
const restartEl = lvlEl.elements.find((el) => el.name === "w:lvlRestart");
|
|
70462
|
+
if (restartEl) {
|
|
70463
|
+
restartEl.attributes["w:val"] = String(restartAfterLevel);
|
|
70464
|
+
} else {
|
|
70465
|
+
lvlEl.elements.push({
|
|
70466
|
+
type: "element",
|
|
70467
|
+
name: "w:lvlRestart",
|
|
70468
|
+
attributes: { "w:val": String(restartAfterLevel) }
|
|
70469
|
+
});
|
|
70470
|
+
}
|
|
70471
|
+
}
|
|
70472
|
+
numbering.abstracts[abstractNumId] = abstract;
|
|
70473
|
+
editor.converter.numbering = { ...numbering };
|
|
70474
|
+
const translated = { ...editor.converter.translatedNumbering || {} };
|
|
70475
|
+
if (!translated.abstracts)
|
|
70476
|
+
translated.abstracts = {};
|
|
70477
|
+
translated.abstracts[abstractNumId] = translator181.encode({ nodes: [abstract] });
|
|
70478
|
+
editor.converter.translatedNumbering = translated;
|
|
70479
|
+
const definitions = numbering.definitions || {};
|
|
70480
|
+
for (const [, numDef] of Object.entries(definitions)) {
|
|
70481
|
+
const absId = numDef?.elements?.find((el) => el.name === "w:abstractNumId")?.attributes?.["w:val"];
|
|
70482
|
+
if (absId != null && Number(absId) === abstractNumId) {
|
|
70483
|
+
emitDefinitionChange(editor, numDef);
|
|
70484
|
+
}
|
|
70485
|
+
}
|
|
70097
70486
|
}, ListHelpers;
|
|
70098
70487
|
var init_list_numbering_helpers = __esm(() => {
|
|
70099
70488
|
init_listImporter();
|
|
@@ -70111,6 +70500,10 @@ var init_list_numbering_helpers = __esm(() => {
|
|
|
70111
70500
|
getNewListId,
|
|
70112
70501
|
hasListDefinition,
|
|
70113
70502
|
removeListDefinitions,
|
|
70503
|
+
setLvlOverride,
|
|
70504
|
+
removeLvlOverride,
|
|
70505
|
+
createNumDefinition,
|
|
70506
|
+
setLvlRestartOnAbstract,
|
|
70114
70507
|
createNewList,
|
|
70115
70508
|
createSchemaOrderedListNode,
|
|
70116
70509
|
createListItemNodeJSON,
|
|
@@ -70294,7 +70687,8 @@ function convertTable(node3, ctx) {
|
|
|
70294
70687
|
return {
|
|
70295
70688
|
type: "table",
|
|
70296
70689
|
attrs: {
|
|
70297
|
-
tableStyleId:
|
|
70690
|
+
tableStyleId: null,
|
|
70691
|
+
needsTableStyleNormalization: true,
|
|
70298
70692
|
tableProperties: {
|
|
70299
70693
|
tableWidth: {
|
|
70300
70694
|
value: FULL_WIDTH_TABLE_PCT,
|
|
@@ -73205,6 +73599,220 @@ var init_blocks_wrappers = __esm(() => {
|
|
|
73205
73599
|
REJECTED_NODE_TYPES = new Set(["tableRow", "tableCell"]);
|
|
73206
73600
|
});
|
|
73207
73601
|
|
|
73602
|
+
// ../../packages/super-editor/src/document-api-adapters/helpers/list-sequence-helpers.ts
|
|
73603
|
+
function resolveBlock(editor, nodeId) {
|
|
73604
|
+
const index2 = getBlockIndex(editor);
|
|
73605
|
+
const matches2 = index2.candidates.filter((c) => c.nodeId === nodeId && (c.nodeType === "paragraph" || c.nodeType === "listItem"));
|
|
73606
|
+
if (matches2.length === 0) {
|
|
73607
|
+
throw new DocumentApiAdapterError("TARGET_NOT_FOUND", "Block target was not found.", { nodeId });
|
|
73608
|
+
}
|
|
73609
|
+
if (matches2.length > 1) {
|
|
73610
|
+
throw new DocumentApiAdapterError("INVALID_TARGET", "Block target id is ambiguous.", {
|
|
73611
|
+
nodeId,
|
|
73612
|
+
count: matches2.length
|
|
73613
|
+
});
|
|
73614
|
+
}
|
|
73615
|
+
return matches2[0];
|
|
73616
|
+
}
|
|
73617
|
+
function resolveBlocksInRange(editor, fromId, toId2) {
|
|
73618
|
+
const from3 = resolveBlock(editor, fromId);
|
|
73619
|
+
const to = resolveBlock(editor, toId2);
|
|
73620
|
+
if (from3.pos > to.pos) {
|
|
73621
|
+
throw new DocumentApiAdapterError("INVALID_TARGET", 'Block range "from" must precede "to" in document order.', {
|
|
73622
|
+
from: fromId,
|
|
73623
|
+
to: toId2
|
|
73624
|
+
});
|
|
73625
|
+
}
|
|
73626
|
+
const index2 = getBlockIndex(editor);
|
|
73627
|
+
return index2.candidates.filter((c) => (c.nodeType === "paragraph" || c.nodeType === "listItem") && c.pos >= from3.pos && c.pos <= to.pos);
|
|
73628
|
+
}
|
|
73629
|
+
function getAbstractNumId(editor, numId) {
|
|
73630
|
+
const converter = editor;
|
|
73631
|
+
const definitions = converter.converter?.numbering?.definitions;
|
|
73632
|
+
if (!definitions)
|
|
73633
|
+
return;
|
|
73634
|
+
const numDef = definitions[numId];
|
|
73635
|
+
if (!numDef?.elements)
|
|
73636
|
+
return;
|
|
73637
|
+
const abstractEl = numDef.elements.find((el) => el.name === "w:abstractNumId");
|
|
73638
|
+
const val = abstractEl?.attributes?.["w:val"];
|
|
73639
|
+
return val != null ? Number(val) : undefined;
|
|
73640
|
+
}
|
|
73641
|
+
function getAllListItemProjections(editor) {
|
|
73642
|
+
const index2 = getBlockIndex(editor);
|
|
73643
|
+
return index2.candidates.filter((c) => c.nodeType === "listItem").map((c) => projectListItemCandidate(editor, c));
|
|
73644
|
+
}
|
|
73645
|
+
function getContiguousSequence(editor, target) {
|
|
73646
|
+
if (target.numId == null)
|
|
73647
|
+
return [target];
|
|
73648
|
+
const allItems = getAllListItemProjections(editor);
|
|
73649
|
+
const targetIdx = allItems.findIndex((item) => item.address.nodeId === target.address.nodeId);
|
|
73650
|
+
if (targetIdx === -1)
|
|
73651
|
+
return [target];
|
|
73652
|
+
const numId = target.numId;
|
|
73653
|
+
let startIdx = targetIdx;
|
|
73654
|
+
for (let i = targetIdx - 1;i >= 0; i--) {
|
|
73655
|
+
if (allItems[i].numId !== numId)
|
|
73656
|
+
break;
|
|
73657
|
+
startIdx = i;
|
|
73658
|
+
}
|
|
73659
|
+
let endIdx = targetIdx;
|
|
73660
|
+
for (let i = targetIdx + 1;i < allItems.length; i++) {
|
|
73661
|
+
if (allItems[i].numId !== numId)
|
|
73662
|
+
break;
|
|
73663
|
+
endIdx = i;
|
|
73664
|
+
}
|
|
73665
|
+
return allItems.slice(startIdx, endIdx + 1);
|
|
73666
|
+
}
|
|
73667
|
+
function getSequenceFromTarget(editor, target) {
|
|
73668
|
+
const sequence = getContiguousSequence(editor, target);
|
|
73669
|
+
const targetIdx = sequence.findIndex((item) => item.address.nodeId === target.address.nodeId);
|
|
73670
|
+
return sequence.slice(targetIdx);
|
|
73671
|
+
}
|
|
73672
|
+
function isFirstInSequence(editor, target) {
|
|
73673
|
+
const sequence = getContiguousSequence(editor, target);
|
|
73674
|
+
return sequence.length > 0 && sequence[0].address.nodeId === target.address.nodeId;
|
|
73675
|
+
}
|
|
73676
|
+
function computeSequenceId(editor, projection) {
|
|
73677
|
+
if (projection.numId == null)
|
|
73678
|
+
return "";
|
|
73679
|
+
const sequence = getContiguousSequence(editor, projection);
|
|
73680
|
+
const anchor = sequence[0]?.address.nodeId ?? projection.address.nodeId;
|
|
73681
|
+
return `${projection.numId}:${anchor}`;
|
|
73682
|
+
}
|
|
73683
|
+
function computeSequenceIdMap(items) {
|
|
73684
|
+
const map5 = new Map;
|
|
73685
|
+
let currentNumId;
|
|
73686
|
+
let currentAnchor;
|
|
73687
|
+
for (const item of items) {
|
|
73688
|
+
if (item.numId == null) {
|
|
73689
|
+
map5.set(item.address.nodeId, "");
|
|
73690
|
+
currentNumId = undefined;
|
|
73691
|
+
currentAnchor = undefined;
|
|
73692
|
+
continue;
|
|
73693
|
+
}
|
|
73694
|
+
if (item.numId !== currentNumId) {
|
|
73695
|
+
currentNumId = item.numId;
|
|
73696
|
+
currentAnchor = item.address.nodeId;
|
|
73697
|
+
}
|
|
73698
|
+
map5.set(item.address.nodeId, `${currentNumId}:${currentAnchor}`);
|
|
73699
|
+
}
|
|
73700
|
+
return map5;
|
|
73701
|
+
}
|
|
73702
|
+
function findAdjacentSequence(editor, target, direction) {
|
|
73703
|
+
if (target.numId == null)
|
|
73704
|
+
return null;
|
|
73705
|
+
const allItems = getAllListItemProjections(editor);
|
|
73706
|
+
const sequence = getContiguousSequence(editor, target);
|
|
73707
|
+
if (direction === "withNext") {
|
|
73708
|
+
const lastInSequence = sequence[sequence.length - 1];
|
|
73709
|
+
const lastIdx = allItems.findIndex((item) => item.address.nodeId === lastInSequence.address.nodeId);
|
|
73710
|
+
for (let i = lastIdx + 1;i < allItems.length; i++) {
|
|
73711
|
+
const item = allItems[i];
|
|
73712
|
+
if (item.numId != null) {
|
|
73713
|
+
const adjSequence = getContiguousSequence(editor, item);
|
|
73714
|
+
return {
|
|
73715
|
+
sequence: adjSequence,
|
|
73716
|
+
numId: item.numId,
|
|
73717
|
+
abstractNumId: getAbstractNumId(editor, item.numId)
|
|
73718
|
+
};
|
|
73719
|
+
}
|
|
73720
|
+
}
|
|
73721
|
+
} else {
|
|
73722
|
+
const firstInSequence = sequence[0];
|
|
73723
|
+
const firstIdx = allItems.findIndex((item) => item.address.nodeId === firstInSequence.address.nodeId);
|
|
73724
|
+
for (let i = firstIdx - 1;i >= 0; i--) {
|
|
73725
|
+
const item = allItems[i];
|
|
73726
|
+
if (item.numId != null) {
|
|
73727
|
+
const adjSequence = getContiguousSequence(editor, item);
|
|
73728
|
+
return {
|
|
73729
|
+
sequence: adjSequence,
|
|
73730
|
+
numId: item.numId,
|
|
73731
|
+
abstractNumId: getAbstractNumId(editor, item.numId)
|
|
73732
|
+
};
|
|
73733
|
+
}
|
|
73734
|
+
}
|
|
73735
|
+
}
|
|
73736
|
+
return null;
|
|
73737
|
+
}
|
|
73738
|
+
function findPreviousCompatibleSequence(editor, target) {
|
|
73739
|
+
if (target.numId == null)
|
|
73740
|
+
return null;
|
|
73741
|
+
const targetAbstractId = getAbstractNumId(editor, target.numId);
|
|
73742
|
+
if (targetAbstractId == null)
|
|
73743
|
+
return null;
|
|
73744
|
+
const allItems = getAllListItemProjections(editor);
|
|
73745
|
+
const sequence = getContiguousSequence(editor, target);
|
|
73746
|
+
const firstInSequence = sequence[0];
|
|
73747
|
+
const firstIdx = allItems.findIndex((item) => item.address.nodeId === firstInSequence.address.nodeId);
|
|
73748
|
+
for (let i = firstIdx - 1;i >= 0; i--) {
|
|
73749
|
+
const item = allItems[i];
|
|
73750
|
+
if (item.numId == null)
|
|
73751
|
+
continue;
|
|
73752
|
+
const itemAbstractId = getAbstractNumId(editor, item.numId);
|
|
73753
|
+
if (itemAbstractId === targetAbstractId && item.numId !== target.numId) {
|
|
73754
|
+
return {
|
|
73755
|
+
sequence: getContiguousSequence(editor, item),
|
|
73756
|
+
numId: item.numId
|
|
73757
|
+
};
|
|
73758
|
+
}
|
|
73759
|
+
}
|
|
73760
|
+
return null;
|
|
73761
|
+
}
|
|
73762
|
+
function evaluateCanJoin(editor, target, direction) {
|
|
73763
|
+
const adjacent = findAdjacentSequence(editor, target, direction);
|
|
73764
|
+
if (!adjacent) {
|
|
73765
|
+
return { canJoin: false, reason: "NO_ADJACENT_SEQUENCE" };
|
|
73766
|
+
}
|
|
73767
|
+
if (adjacent.numId === target.numId) {
|
|
73768
|
+
return { canJoin: false, reason: "ALREADY_SAME_SEQUENCE" };
|
|
73769
|
+
}
|
|
73770
|
+
const targetAbstractId = target.numId != null ? getAbstractNumId(editor, target.numId) : undefined;
|
|
73771
|
+
if (targetAbstractId == null || adjacent.abstractNumId == null || targetAbstractId !== adjacent.abstractNumId) {
|
|
73772
|
+
return { canJoin: false, reason: "INCOMPATIBLE_DEFINITIONS" };
|
|
73773
|
+
}
|
|
73774
|
+
const adjacentAnchor = adjacent.sequence[0]?.address.nodeId ?? "";
|
|
73775
|
+
return { canJoin: true, adjacentListId: `${adjacent.numId}:${adjacentAnchor}` };
|
|
73776
|
+
}
|
|
73777
|
+
function evaluateCanContinuePrevious(editor, target) {
|
|
73778
|
+
if (target.numId == null) {
|
|
73779
|
+
return { canContinue: false, reason: "NO_PREVIOUS_LIST" };
|
|
73780
|
+
}
|
|
73781
|
+
const targetAbstractId = getAbstractNumId(editor, target.numId);
|
|
73782
|
+
if (targetAbstractId == null) {
|
|
73783
|
+
return { canContinue: false, reason: "NO_PREVIOUS_LIST" };
|
|
73784
|
+
}
|
|
73785
|
+
const allItems = getAllListItemProjections(editor);
|
|
73786
|
+
const sequence = getContiguousSequence(editor, target);
|
|
73787
|
+
const firstInSequence = sequence[0];
|
|
73788
|
+
const firstIdx = allItems.findIndex((item) => item.address.nodeId === firstInSequence.address.nodeId);
|
|
73789
|
+
let foundAnyPrevious = false;
|
|
73790
|
+
for (let i = firstIdx - 1;i >= 0; i--) {
|
|
73791
|
+
const item = allItems[i];
|
|
73792
|
+
if (item.numId == null)
|
|
73793
|
+
continue;
|
|
73794
|
+
foundAnyPrevious = true;
|
|
73795
|
+
const itemAbstractId = getAbstractNumId(editor, item.numId);
|
|
73796
|
+
if (itemAbstractId !== targetAbstractId)
|
|
73797
|
+
continue;
|
|
73798
|
+
if (item.numId === target.numId) {
|
|
73799
|
+
return { canContinue: false, reason: "ALREADY_CONTINUOUS" };
|
|
73800
|
+
}
|
|
73801
|
+
const prevSequence = getContiguousSequence(editor, item);
|
|
73802
|
+
const prevAnchor = prevSequence[0]?.address.nodeId ?? item.address.nodeId;
|
|
73803
|
+
return { canContinue: true, previousListId: `${item.numId}:${prevAnchor}` };
|
|
73804
|
+
}
|
|
73805
|
+
if (!foundAnyPrevious) {
|
|
73806
|
+
return { canContinue: false, reason: "NO_PREVIOUS_LIST" };
|
|
73807
|
+
}
|
|
73808
|
+
return { canContinue: false, reason: "INCOMPATIBLE_DEFINITIONS" };
|
|
73809
|
+
}
|
|
73810
|
+
var init_list_sequence_helpers = __esm(() => {
|
|
73811
|
+
init_list_item_resolver();
|
|
73812
|
+
init_index_cache();
|
|
73813
|
+
init_errors3();
|
|
73814
|
+
});
|
|
73815
|
+
|
|
73208
73816
|
// ../../packages/super-editor/src/document-api-adapters/helpers/list-item-resolver.ts
|
|
73209
73817
|
function toPath(value) {
|
|
73210
73818
|
if (!Array.isArray(value))
|
|
@@ -73270,9 +73878,10 @@ function projectListItemCandidate(editor, candidate) {
|
|
|
73270
73878
|
text: getListText(candidate)
|
|
73271
73879
|
};
|
|
73272
73880
|
}
|
|
73273
|
-
function listItemProjectionToInfo(projection) {
|
|
73881
|
+
function listItemProjectionToInfo(projection, listId) {
|
|
73274
73882
|
return {
|
|
73275
73883
|
address: projection.address,
|
|
73884
|
+
listId,
|
|
73276
73885
|
marker: projection.marker,
|
|
73277
73886
|
ordinal: projection.ordinal,
|
|
73278
73887
|
path: projection.path,
|
|
@@ -73317,9 +73926,6 @@ function isWithinScope(candidate, scope) {
|
|
|
73317
73926
|
return true;
|
|
73318
73927
|
return candidate.pos >= scope.start && candidate.end <= scope.end;
|
|
73319
73928
|
}
|
|
73320
|
-
function listItemCandidatesInScope(index2, scope) {
|
|
73321
|
-
return index2.candidates.filter((candidate) => candidate.nodeType === "listItem" && isWithinScope(candidate, scope));
|
|
73322
|
-
}
|
|
73323
73929
|
function listListItems(editor, query2) {
|
|
73324
73930
|
if (query2?.within && query2.within.kind !== "block") {
|
|
73325
73931
|
throw new DocumentApiAdapterError("INVALID_TARGET", "lists.list only supports block within scopes.", {
|
|
@@ -73329,25 +73935,28 @@ function listListItems(editor, query2) {
|
|
|
73329
73935
|
validatePaginationInput(query2?.offset, query2?.limit);
|
|
73330
73936
|
const index2 = getBlockIndex(editor);
|
|
73331
73937
|
const scope = resolveBlockScopeRange(index2, query2?.within);
|
|
73332
|
-
const
|
|
73938
|
+
const allCandidates = index2.candidates.filter((candidate) => candidate.nodeType === "listItem");
|
|
73939
|
+
const allProjections = allCandidates.map((candidate) => projectListItemCandidate(editor, candidate));
|
|
73940
|
+
const projections = allProjections.filter((projection) => isWithinScope(projection.candidate, scope));
|
|
73333
73941
|
const safeOffset = query2?.offset ?? 0;
|
|
73334
73942
|
const safeLimit = query2?.limit ?? Number.POSITIVE_INFINITY;
|
|
73335
73943
|
const pageEnd = safeOffset + safeLimit;
|
|
73336
73944
|
const evaluatedRevision = getRevision(editor);
|
|
73945
|
+
const sequenceIds = computeSequenceIdMap(allProjections);
|
|
73337
73946
|
let total = 0;
|
|
73338
73947
|
const items = [];
|
|
73339
|
-
for (const
|
|
73340
|
-
const projection = projectListItemCandidate(editor, candidate);
|
|
73948
|
+
for (const projection of projections) {
|
|
73341
73949
|
if (!matchesListQuery(projection, query2))
|
|
73342
73950
|
continue;
|
|
73343
73951
|
const currentIndex = total;
|
|
73344
73952
|
total += 1;
|
|
73345
73953
|
if (currentIndex < safeOffset || currentIndex >= pageEnd)
|
|
73346
73954
|
continue;
|
|
73347
|
-
const
|
|
73955
|
+
const listId = sequenceIds.get(projection.address.nodeId) ?? "";
|
|
73956
|
+
const info = listItemProjectionToInfo(projection, listId);
|
|
73348
73957
|
const handle2 = buildResolvedHandle(info.address.nodeId, "stable", "list");
|
|
73349
73958
|
const { address: address2, marker, ordinal, path: path2, level, kind, text: text5 } = info;
|
|
73350
|
-
items.push(buildDiscoveryItem(info.address.nodeId, handle2, { address: address2, marker, ordinal, path: path2, level, kind, text: text5 }));
|
|
73959
|
+
items.push(buildDiscoveryItem(info.address.nodeId, handle2, { address: address2, listId, marker, ordinal, path: path2, level, kind, text: text5 }));
|
|
73351
73960
|
}
|
|
73352
73961
|
return buildDiscoveryResult({
|
|
73353
73962
|
evaluatedRevision,
|
|
@@ -73379,12 +73988,24 @@ var init_list_item_resolver = __esm(() => {
|
|
|
73379
73988
|
init_revision_tracker();
|
|
73380
73989
|
init_index_cache();
|
|
73381
73990
|
init_adapter_utils();
|
|
73991
|
+
init_list_sequence_helpers();
|
|
73382
73992
|
});
|
|
73383
73993
|
|
|
73384
73994
|
// ../../packages/super-editor/src/document-api-adapters/plan-engine/lists-wrappers.ts
|
|
73385
73995
|
function toListsFailure(code3, message, details) {
|
|
73386
73996
|
return { success: false, failure: { code: code3, message, details } };
|
|
73387
73997
|
}
|
|
73998
|
+
function dispatchEditorTransaction(editor, tr) {
|
|
73999
|
+
if (typeof editor.dispatch === "function") {
|
|
74000
|
+
editor.dispatch(tr);
|
|
74001
|
+
return;
|
|
74002
|
+
}
|
|
74003
|
+
if (typeof editor.view?.dispatch === "function") {
|
|
74004
|
+
editor.view.dispatch(tr);
|
|
74005
|
+
return;
|
|
74006
|
+
}
|
|
74007
|
+
throw new DocumentApiAdapterError("INTERNAL_ERROR", "Cannot apply list mutation because no transaction dispatcher is available.", { reason: "missing_dispatch" });
|
|
74008
|
+
}
|
|
73388
74009
|
function resolveInsertedListItem(editor, sdBlockId) {
|
|
73389
74010
|
const index2 = getBlockIndex(editor);
|
|
73390
74011
|
const byNodeId = index2.candidates.find((candidate) => candidate.nodeType === "listItem" && candidate.nodeId === sdBlockId);
|
|
@@ -73401,54 +74022,71 @@ function resolveInsertedListItem(editor, sdBlockId) {
|
|
|
73401
74022
|
}
|
|
73402
74023
|
throw new DocumentApiAdapterError("TARGET_NOT_FOUND", `Inserted list item with sdBlockId "${sdBlockId}" could not be resolved after insertion.`);
|
|
73403
74024
|
}
|
|
73404
|
-
function
|
|
73405
|
-
return
|
|
73406
|
-
}
|
|
73407
|
-
function setSelectionToListItem(editor, item) {
|
|
73408
|
-
const setTextSelection = requireEditorCommand(editor.commands?.setTextSelection, "lists (setTextSelection)");
|
|
73409
|
-
const anchor = selectionAnchorPos(item);
|
|
73410
|
-
return Boolean(setTextSelection({ from: anchor, to: anchor }));
|
|
74025
|
+
function withListTarget(editor, input) {
|
|
74026
|
+
return resolveListItem(editor, input.target);
|
|
73411
74027
|
}
|
|
73412
|
-
function
|
|
73413
|
-
|
|
73414
|
-
|
|
73415
|
-
|
|
74028
|
+
function hasLevelOverride(editor, numId, level) {
|
|
74029
|
+
const converter = editor;
|
|
74030
|
+
const definition3 = converter.converter?.numbering?.definitions?.[numId];
|
|
74031
|
+
const ilvl = String(level);
|
|
74032
|
+
return definition3?.elements?.some((element) => element.name === "w:lvlOverride" && element.attributes?.["w:ilvl"] === ilvl) ?? false;
|
|
73416
74033
|
}
|
|
73417
|
-
function
|
|
73418
|
-
if (
|
|
73419
|
-
return
|
|
73420
|
-
|
|
73421
|
-
|
|
73422
|
-
|
|
73423
|
-
|
|
73424
|
-
|
|
74034
|
+
function executeSetLevel(editor, target, newLevel, options) {
|
|
74035
|
+
if (target.numId == null) {
|
|
74036
|
+
return toListsFailure("INVALID_TARGET", "Target must have numbering metadata.", {
|
|
74037
|
+
target: target.address
|
|
74038
|
+
});
|
|
74039
|
+
}
|
|
74040
|
+
if (newLevel < 0 || newLevel > 8) {
|
|
74041
|
+
return toListsFailure("LEVEL_OUT_OF_RANGE", "Level must be between 0 and 8.", { level: newLevel });
|
|
74042
|
+
}
|
|
74043
|
+
if (target.level === newLevel) {
|
|
74044
|
+
return toListsFailure("NO_OP", "Item is already at the requested level.", {
|
|
74045
|
+
target: target.address,
|
|
74046
|
+
level: newLevel
|
|
74047
|
+
});
|
|
74048
|
+
}
|
|
74049
|
+
if (!ListHelpers.hasListDefinition(editor, target.numId, newLevel)) {
|
|
74050
|
+
return toListsFailure("LEVEL_OUT_OF_RANGE", "Target level is not defined in the active numbering definition.", {
|
|
74051
|
+
target: target.address,
|
|
74052
|
+
level: newLevel
|
|
74053
|
+
});
|
|
74054
|
+
}
|
|
74055
|
+
if (options?.dryRun) {
|
|
74056
|
+
return { success: true, item: target.address };
|
|
74057
|
+
}
|
|
74058
|
+
const receipt2 = executeDomainCommand(editor, () => {
|
|
74059
|
+
const { tr } = editor.state;
|
|
74060
|
+
updateNumberingProperties({ numId: target.numId, ilvl: newLevel }, target.candidate.node, target.candidate.pos, editor, tr);
|
|
74061
|
+
dispatchEditorTransaction(editor, tr);
|
|
74062
|
+
clearIndexCache(editor);
|
|
73425
74063
|
return true;
|
|
73426
|
-
|
|
73427
|
-
|
|
73428
|
-
|
|
73429
|
-
|
|
73430
|
-
|
|
73431
|
-
if (previous3.nodeType !== "listItem") {
|
|
73432
|
-
return true;
|
|
73433
|
-
}
|
|
73434
|
-
const previousProjection = resolveListItem(editor, {
|
|
73435
|
-
kind: "block",
|
|
73436
|
-
nodeType: "listItem",
|
|
73437
|
-
nodeId: previous3.nodeId
|
|
74064
|
+
}, { expectedRevision: options?.expectedRevision });
|
|
74065
|
+
if (receipt2.steps[0]?.effect !== "changed") {
|
|
74066
|
+
return toListsFailure("INVALID_TARGET", "Level change could not be applied.", {
|
|
74067
|
+
target: target.address,
|
|
74068
|
+
level: newLevel
|
|
73438
74069
|
});
|
|
73439
|
-
return previousProjection.numId !== item.numId || previousProjection.level !== item.level;
|
|
73440
74070
|
}
|
|
73441
|
-
return true;
|
|
74071
|
+
return { success: true, item: target.address };
|
|
73442
74072
|
}
|
|
73443
|
-
function
|
|
73444
|
-
return
|
|
74073
|
+
function isBlockRange(target) {
|
|
74074
|
+
return typeof target === "object" && target !== null && "from" in target;
|
|
73445
74075
|
}
|
|
73446
74076
|
function listsListWrapper(editor, query2) {
|
|
73447
74077
|
return listListItems(editor, query2);
|
|
73448
74078
|
}
|
|
73449
74079
|
function listsGetWrapper(editor, input) {
|
|
73450
74080
|
const item = resolveListItem(editor, input.address);
|
|
73451
|
-
return listItemProjectionToInfo(item);
|
|
74081
|
+
return listItemProjectionToInfo(item, computeSequenceId(editor, item));
|
|
74082
|
+
}
|
|
74083
|
+
function listsCanJoinWrapper(editor, input) {
|
|
74084
|
+
const target = resolveListItem(editor, input.target);
|
|
74085
|
+
return evaluateCanJoin(editor, target, input.direction);
|
|
74086
|
+
}
|
|
74087
|
+
function listsCanContinuePreviousWrapper(editor, input) {
|
|
74088
|
+
const target = resolveListItem(editor, input.target);
|
|
74089
|
+
return evaluateCanContinuePrevious(editor, target);
|
|
73452
74090
|
}
|
|
73453
74091
|
function listsInsertWrapper(editor, input, options) {
|
|
73454
74092
|
const target = withListTarget(editor, input);
|
|
@@ -73492,7 +74130,8 @@ function listsInsertWrapper(editor, input, options) {
|
|
|
73492
74130
|
position: input.position
|
|
73493
74131
|
});
|
|
73494
74132
|
}
|
|
73495
|
-
|
|
74133
|
+
const resolved = created;
|
|
74134
|
+
if (!resolved) {
|
|
73496
74135
|
return {
|
|
73497
74136
|
success: true,
|
|
73498
74137
|
item: { kind: "block", nodeType: "listItem", nodeId: createdId },
|
|
@@ -73505,143 +74144,416 @@ function listsInsertWrapper(editor, input, options) {
|
|
|
73505
74144
|
}
|
|
73506
74145
|
return {
|
|
73507
74146
|
success: true,
|
|
73508
|
-
item:
|
|
74147
|
+
item: resolved.address,
|
|
73509
74148
|
insertionPoint: {
|
|
73510
74149
|
kind: "text",
|
|
73511
|
-
blockId:
|
|
74150
|
+
blockId: resolved.address.nodeId,
|
|
73512
74151
|
range: { start: 0, end: 0 }
|
|
73513
74152
|
},
|
|
73514
|
-
trackedChangeRefs: mode === "tracked" ? collectTrackInsertRefsInRange(editor,
|
|
74153
|
+
trackedChangeRefs: mode === "tracked" ? collectTrackInsertRefsInRange(editor, resolved.candidate.pos, resolved.candidate.end) : undefined
|
|
73515
74154
|
};
|
|
73516
74155
|
}
|
|
73517
|
-
function
|
|
73518
|
-
rejectTrackedMode("lists.
|
|
74156
|
+
function listsIndentWrapper(editor, input, options) {
|
|
74157
|
+
rejectTrackedMode("lists.indent", options);
|
|
73519
74158
|
const target = withListTarget(editor, input);
|
|
73520
|
-
|
|
73521
|
-
|
|
74159
|
+
const currentLevel = target.level ?? 0;
|
|
74160
|
+
return executeSetLevel(editor, target, currentLevel + 1, options);
|
|
74161
|
+
}
|
|
74162
|
+
function listsOutdentWrapper(editor, input, options) {
|
|
74163
|
+
rejectTrackedMode("lists.outdent", options);
|
|
74164
|
+
const target = withListTarget(editor, input);
|
|
74165
|
+
const currentLevel = target.level ?? 0;
|
|
74166
|
+
if (currentLevel <= 0) {
|
|
74167
|
+
return toListsFailure("NO_OP", "List item is already at level 0.", { target: input.target });
|
|
74168
|
+
}
|
|
74169
|
+
return executeSetLevel(editor, target, currentLevel - 1, options);
|
|
74170
|
+
}
|
|
74171
|
+
function listsCreateWrapper(editor, input, options) {
|
|
74172
|
+
rejectTrackedMode("lists.create", options);
|
|
74173
|
+
const raw = input;
|
|
74174
|
+
if (input.mode === "empty" && raw.at == null) {
|
|
74175
|
+
return toListsFailure("INVALID_TARGET", 'Mode "empty" requires an "at" field.', { mode: "empty" });
|
|
74176
|
+
}
|
|
74177
|
+
if (input.mode === "fromParagraphs" && raw.target == null) {
|
|
74178
|
+
return toListsFailure("INVALID_TARGET", 'Mode "fromParagraphs" requires a "target" field.', {
|
|
74179
|
+
mode: "fromParagraphs"
|
|
74180
|
+
});
|
|
74181
|
+
}
|
|
74182
|
+
const level = input.level ?? 0;
|
|
74183
|
+
if (level < 0 || level > 8) {
|
|
74184
|
+
return toListsFailure("LEVEL_OUT_OF_RANGE", "Level must be between 0 and 8.", { level });
|
|
74185
|
+
}
|
|
74186
|
+
const listType = input.kind === "ordered" ? "orderedList" : "bulletList";
|
|
74187
|
+
if (input.mode === "empty") {
|
|
74188
|
+
const block = resolveBlock(editor, input.at.nodeId);
|
|
74189
|
+
if (block.nodeType === "listItem") {
|
|
74190
|
+
return toListsFailure("INVALID_TARGET", "Target paragraph is already a list item.", { target: input.at });
|
|
74191
|
+
}
|
|
74192
|
+
if (options?.dryRun) {
|
|
74193
|
+
return { success: true, listId: "(dry-run)", item: { kind: "block", nodeType: "listItem", nodeId: "(dry-run)" } };
|
|
74194
|
+
}
|
|
74195
|
+
let numId2;
|
|
74196
|
+
const receipt3 = executeDomainCommand(editor, () => {
|
|
74197
|
+
numId2 = ListHelpers.getNewListId(editor);
|
|
74198
|
+
ListHelpers.generateNewListDefinition({ numId: numId2, listType, editor });
|
|
74199
|
+
const { tr } = editor.state;
|
|
74200
|
+
updateNumberingProperties({ numId: numId2, ilvl: level }, block.node, block.pos, editor, tr);
|
|
74201
|
+
dispatchEditorTransaction(editor, tr);
|
|
74202
|
+
clearIndexCache(editor);
|
|
74203
|
+
return true;
|
|
74204
|
+
}, { expectedRevision: options?.expectedRevision });
|
|
74205
|
+
if (receipt3.steps[0]?.effect !== "changed") {
|
|
74206
|
+
return toListsFailure("INVALID_TARGET", "List creation could not be applied.", { mode: input.mode });
|
|
74207
|
+
}
|
|
74208
|
+
return {
|
|
74209
|
+
success: true,
|
|
74210
|
+
listId: `${numId2}:${block.nodeId}`,
|
|
74211
|
+
item: { kind: "block", nodeType: "listItem", nodeId: block.nodeId }
|
|
74212
|
+
};
|
|
74213
|
+
}
|
|
74214
|
+
const targets = isBlockRange(input.target) ? resolveBlocksInRange(editor, input.target.from.nodeId, input.target.to.nodeId) : [resolveBlock(editor, input.target.nodeId)];
|
|
74215
|
+
if (targets.length === 0) {
|
|
74216
|
+
return toListsFailure("INVALID_TARGET", "No paragraphs found in the specified range.", { target: input.target });
|
|
74217
|
+
}
|
|
74218
|
+
const alreadyListItem = targets.find((t) => t.nodeType === "listItem");
|
|
74219
|
+
if (alreadyListItem) {
|
|
74220
|
+
return toListsFailure("INVALID_TARGET", "One or more target paragraphs are already list items.", {
|
|
74221
|
+
nodeId: alreadyListItem.nodeId
|
|
74222
|
+
});
|
|
74223
|
+
}
|
|
74224
|
+
if (options?.dryRun) {
|
|
74225
|
+
return {
|
|
74226
|
+
success: true,
|
|
74227
|
+
listId: "(dry-run)",
|
|
74228
|
+
item: { kind: "block", nodeType: "listItem", nodeId: targets[0].nodeId }
|
|
74229
|
+
};
|
|
74230
|
+
}
|
|
74231
|
+
let numId;
|
|
74232
|
+
const receipt2 = executeDomainCommand(editor, () => {
|
|
74233
|
+
numId = ListHelpers.getNewListId(editor);
|
|
74234
|
+
ListHelpers.generateNewListDefinition({ numId, listType, editor });
|
|
74235
|
+
const { tr } = editor.state;
|
|
74236
|
+
for (const block of targets) {
|
|
74237
|
+
updateNumberingProperties({ numId, ilvl: level }, block.node, block.pos, editor, tr);
|
|
74238
|
+
}
|
|
74239
|
+
dispatchEditorTransaction(editor, tr);
|
|
74240
|
+
clearIndexCache(editor);
|
|
74241
|
+
return true;
|
|
74242
|
+
}, { expectedRevision: options?.expectedRevision });
|
|
74243
|
+
if (receipt2.steps[0]?.effect !== "changed") {
|
|
74244
|
+
return toListsFailure("INVALID_TARGET", "List creation could not be applied.", { mode: input.mode });
|
|
74245
|
+
}
|
|
74246
|
+
return {
|
|
74247
|
+
success: true,
|
|
74248
|
+
listId: `${numId}:${targets[0].nodeId}`,
|
|
74249
|
+
item: { kind: "block", nodeType: "listItem", nodeId: targets[0].nodeId }
|
|
74250
|
+
};
|
|
74251
|
+
}
|
|
74252
|
+
function listsAttachWrapper(editor, input, options) {
|
|
74253
|
+
rejectTrackedMode("lists.attach", options);
|
|
74254
|
+
const attachTo = resolveListItem(editor, input.attachTo);
|
|
74255
|
+
if (attachTo.numId == null) {
|
|
74256
|
+
return toListsFailure("INVALID_TARGET", "attachTo target must be a list item with numbering metadata.", {
|
|
74257
|
+
attachTo: input.attachTo
|
|
74258
|
+
});
|
|
74259
|
+
}
|
|
74260
|
+
const numId = attachTo.numId;
|
|
74261
|
+
const level = input.level ?? attachTo.level ?? 0;
|
|
74262
|
+
const targets = isBlockRange(input.target) ? resolveBlocksInRange(editor, input.target.from.nodeId, input.target.to.nodeId) : [resolveBlock(editor, input.target.nodeId)];
|
|
74263
|
+
if (targets.length === 0) {
|
|
74264
|
+
return toListsFailure("INVALID_TARGET", "No paragraphs found in the specified target.", { target: input.target });
|
|
74265
|
+
}
|
|
74266
|
+
const alreadyListItem = targets.find((t) => t.nodeType === "listItem");
|
|
74267
|
+
if (alreadyListItem) {
|
|
74268
|
+
return toListsFailure("INVALID_TARGET", "Target paragraphs are already list items.", {
|
|
74269
|
+
nodeId: alreadyListItem.nodeId
|
|
74270
|
+
});
|
|
74271
|
+
}
|
|
74272
|
+
if (options?.dryRun) {
|
|
74273
|
+
return { success: true, item: { kind: "block", nodeType: "listItem", nodeId: targets[0].nodeId } };
|
|
74274
|
+
}
|
|
74275
|
+
const receipt2 = executeDomainCommand(editor, () => {
|
|
74276
|
+
const { tr } = editor.state;
|
|
74277
|
+
for (const block of targets) {
|
|
74278
|
+
updateNumberingProperties({ numId, ilvl: level }, block.node, block.pos, editor, tr);
|
|
74279
|
+
}
|
|
74280
|
+
dispatchEditorTransaction(editor, tr);
|
|
74281
|
+
clearIndexCache(editor);
|
|
74282
|
+
return true;
|
|
74283
|
+
}, { expectedRevision: options?.expectedRevision });
|
|
74284
|
+
if (receipt2.steps[0]?.effect !== "changed") {
|
|
74285
|
+
return toListsFailure("INVALID_TARGET", "List attachment could not be applied.", { target: input.target });
|
|
74286
|
+
}
|
|
74287
|
+
return { success: true, item: { kind: "block", nodeType: "listItem", nodeId: targets[0].nodeId } };
|
|
74288
|
+
}
|
|
74289
|
+
function listsDetachWrapper(editor, input, options) {
|
|
74290
|
+
rejectTrackedMode("lists.detach", options);
|
|
74291
|
+
const target = resolveListItem(editor, input.target);
|
|
74292
|
+
if (options?.dryRun) {
|
|
74293
|
+
return { success: true, paragraph: { kind: "block", nodeType: "paragraph", nodeId: target.address.nodeId } };
|
|
74294
|
+
}
|
|
74295
|
+
const receipt2 = executeDomainCommand(editor, () => {
|
|
74296
|
+
const { tr } = editor.state;
|
|
74297
|
+
updateNumberingProperties(null, target.candidate.node, target.candidate.pos, editor, tr);
|
|
74298
|
+
dispatchEditorTransaction(editor, tr);
|
|
74299
|
+
clearIndexCache(editor);
|
|
74300
|
+
return true;
|
|
74301
|
+
}, { expectedRevision: options?.expectedRevision });
|
|
74302
|
+
if (receipt2.steps[0]?.effect !== "changed") {
|
|
74303
|
+
return toListsFailure("INVALID_TARGET", "List detach could not be applied.", { target: input.target });
|
|
74304
|
+
}
|
|
74305
|
+
return { success: true, paragraph: { kind: "block", nodeType: "paragraph", nodeId: target.address.nodeId } };
|
|
74306
|
+
}
|
|
74307
|
+
function listsJoinWrapper(editor, input, options) {
|
|
74308
|
+
rejectTrackedMode("lists.join", options);
|
|
74309
|
+
const target = resolveListItem(editor, input.target);
|
|
74310
|
+
if (target.numId == null) {
|
|
74311
|
+
return toListsFailure("INVALID_TARGET", "Target must have numbering metadata.", { target: input.target });
|
|
74312
|
+
}
|
|
74313
|
+
const canJoinResult = evaluateCanJoin(editor, target, input.direction);
|
|
74314
|
+
if (!canJoinResult.canJoin) {
|
|
74315
|
+
return toListsFailure(canJoinResult.reason, `Cannot join: ${canJoinResult.reason}`, {
|
|
73522
74316
|
target: input.target,
|
|
73523
|
-
|
|
74317
|
+
direction: input.direction
|
|
73524
74318
|
});
|
|
73525
74319
|
}
|
|
73526
|
-
const
|
|
74320
|
+
const adjacent = findAdjacentSequence(editor, target, input.direction);
|
|
74321
|
+
let absorbingNumId;
|
|
74322
|
+
let absorbedItems;
|
|
74323
|
+
let anchorNodeId;
|
|
74324
|
+
if (input.direction === "withPrevious") {
|
|
74325
|
+
absorbingNumId = adjacent.numId;
|
|
74326
|
+
absorbedItems = getContiguousSequence(editor, target);
|
|
74327
|
+
anchorNodeId = adjacent.sequence[0]?.address.nodeId ?? target.address.nodeId;
|
|
74328
|
+
} else {
|
|
74329
|
+
absorbingNumId = target.numId;
|
|
74330
|
+
absorbedItems = adjacent.sequence;
|
|
74331
|
+
const targetSequence = getContiguousSequence(editor, target);
|
|
74332
|
+
anchorNodeId = targetSequence[0]?.address.nodeId ?? target.address.nodeId;
|
|
74333
|
+
}
|
|
74334
|
+
const mergedListId = `${absorbingNumId}:${anchorNodeId}`;
|
|
73527
74335
|
if (options?.dryRun) {
|
|
73528
|
-
return { success: true,
|
|
74336
|
+
return { success: true, listId: mergedListId };
|
|
73529
74337
|
}
|
|
73530
|
-
const receipt2 = executeDomainCommand(editor, () =>
|
|
73531
|
-
|
|
73532
|
-
|
|
74338
|
+
const receipt2 = executeDomainCommand(editor, () => {
|
|
74339
|
+
const { tr } = editor.state;
|
|
74340
|
+
for (const item of absorbedItems) {
|
|
74341
|
+
const currentLevel = item.level ?? 0;
|
|
74342
|
+
updateNumberingProperties({ numId: absorbingNumId, ilvl: currentLevel }, item.candidate.node, item.candidate.pos, editor, tr);
|
|
74343
|
+
}
|
|
74344
|
+
dispatchEditorTransaction(editor, tr);
|
|
74345
|
+
clearIndexCache(editor);
|
|
74346
|
+
return true;
|
|
74347
|
+
}, { expectedRevision: options?.expectedRevision });
|
|
73533
74348
|
if (receipt2.steps[0]?.effect !== "changed") {
|
|
73534
|
-
return toListsFailure("INVALID_TARGET", "List
|
|
74349
|
+
return toListsFailure("INVALID_TARGET", "List join could not be applied.", {
|
|
73535
74350
|
target: input.target,
|
|
73536
|
-
|
|
74351
|
+
direction: input.direction
|
|
73537
74352
|
});
|
|
73538
74353
|
}
|
|
73539
|
-
return { success: true,
|
|
74354
|
+
return { success: true, listId: mergedListId };
|
|
73540
74355
|
}
|
|
73541
|
-
function
|
|
73542
|
-
rejectTrackedMode("lists.
|
|
73543
|
-
const target =
|
|
73544
|
-
if (
|
|
73545
|
-
return toListsFailure("
|
|
74356
|
+
function listsSeparateWrapper(editor, input, options) {
|
|
74357
|
+
rejectTrackedMode("lists.separate", options);
|
|
74358
|
+
const target = resolveListItem(editor, input.target);
|
|
74359
|
+
if (target.numId == null) {
|
|
74360
|
+
return toListsFailure("INVALID_TARGET", "Target must have numbering metadata.", { target: input.target });
|
|
73546
74361
|
}
|
|
73547
|
-
|
|
73548
|
-
|
|
73549
|
-
return { success: true, item: target.address };
|
|
74362
|
+
if (isFirstInSequence(editor, target)) {
|
|
74363
|
+
return toListsFailure("NO_OP", "Target is already the first item in its sequence.", { target: input.target });
|
|
73550
74364
|
}
|
|
73551
|
-
|
|
73552
|
-
|
|
74365
|
+
const copyOverrides = input.copyOverrides !== false;
|
|
74366
|
+
const abstractNumId = getAbstractNumId(editor, target.numId);
|
|
74367
|
+
if (abstractNumId == null) {
|
|
74368
|
+
return toListsFailure("INVALID_TARGET", "Could not resolve abstract definition for target.", {
|
|
73553
74369
|
target: input.target
|
|
73554
74370
|
});
|
|
73555
74371
|
}
|
|
73556
|
-
const
|
|
73557
|
-
|
|
73558
|
-
|
|
74372
|
+
const itemsToReassign = getSequenceFromTarget(editor, target);
|
|
74373
|
+
if (options?.dryRun) {
|
|
74374
|
+
return { success: true, listId: "(dry-run)", numId: 0 };
|
|
74375
|
+
}
|
|
74376
|
+
let newNumId;
|
|
74377
|
+
const receipt2 = executeDomainCommand(editor, () => {
|
|
74378
|
+
const result = ListHelpers.createNumDefinition(editor, abstractNumId, {
|
|
74379
|
+
copyOverridesFrom: copyOverrides ? target.numId : undefined
|
|
74380
|
+
});
|
|
74381
|
+
newNumId = result.numId;
|
|
74382
|
+
const { tr } = editor.state;
|
|
74383
|
+
for (const item of itemsToReassign) {
|
|
74384
|
+
const currentLevel = item.level ?? 0;
|
|
74385
|
+
updateNumberingProperties({ numId: newNumId, ilvl: currentLevel }, item.candidate.node, item.candidate.pos, editor, tr);
|
|
74386
|
+
}
|
|
74387
|
+
dispatchEditorTransaction(editor, tr);
|
|
74388
|
+
clearIndexCache(editor);
|
|
74389
|
+
return true;
|
|
74390
|
+
}, { expectedRevision: options?.expectedRevision });
|
|
73559
74391
|
if (receipt2.steps[0]?.effect !== "changed") {
|
|
73560
|
-
return toListsFailure("INVALID_TARGET", "List
|
|
74392
|
+
return toListsFailure("INVALID_TARGET", "List separation could not be applied.", { target: input.target });
|
|
73561
74393
|
}
|
|
73562
|
-
return { success: true,
|
|
74394
|
+
return { success: true, listId: `${newNumId}:${target.address.nodeId}`, numId: newNumId };
|
|
73563
74395
|
}
|
|
73564
|
-
function
|
|
73565
|
-
rejectTrackedMode("lists.
|
|
73566
|
-
const target =
|
|
73567
|
-
|
|
73568
|
-
|
|
74396
|
+
function listsSetLevelWrapper(editor, input, options) {
|
|
74397
|
+
rejectTrackedMode("lists.setLevel", options);
|
|
74398
|
+
const target = resolveListItem(editor, input.target);
|
|
74399
|
+
return executeSetLevel(editor, target, input.level, options);
|
|
74400
|
+
}
|
|
74401
|
+
function listsSetValueWrapper(editor, input, options) {
|
|
74402
|
+
rejectTrackedMode("lists.setValue", options);
|
|
74403
|
+
const target = resolveListItem(editor, input.target);
|
|
74404
|
+
if (target.numId == null) {
|
|
74405
|
+
return toListsFailure("INVALID_TARGET", "Target must have numbering metadata.", { target: input.target });
|
|
73569
74406
|
}
|
|
73570
|
-
const
|
|
74407
|
+
const level = target.level ?? 0;
|
|
73571
74408
|
if (options?.dryRun) {
|
|
73572
74409
|
return { success: true, item: target.address };
|
|
73573
74410
|
}
|
|
73574
|
-
if (
|
|
73575
|
-
|
|
74411
|
+
if (input.value === null) {
|
|
74412
|
+
if (!hasLevelOverride(editor, target.numId, level)) {
|
|
74413
|
+
return toListsFailure("NO_OP", "No startOverride to remove.", { target: input.target });
|
|
74414
|
+
}
|
|
74415
|
+
const receipt3 = executeDomainCommand(editor, () => {
|
|
74416
|
+
ListHelpers.removeLvlOverride(editor, target.numId, level);
|
|
74417
|
+
dispatchEditorTransaction(editor, editor.state.tr);
|
|
74418
|
+
return true;
|
|
74419
|
+
}, { expectedRevision: options?.expectedRevision });
|
|
74420
|
+
if (receipt3.steps[0]?.effect !== "changed") {
|
|
74421
|
+
return toListsFailure("NO_OP", "No startOverride to remove.", { target: input.target });
|
|
74422
|
+
}
|
|
74423
|
+
return { success: true, item: target.address };
|
|
74424
|
+
}
|
|
74425
|
+
const isFirst = isFirstInSequence(editor, target);
|
|
74426
|
+
if (isFirst) {
|
|
74427
|
+
const receipt3 = executeDomainCommand(editor, () => {
|
|
74428
|
+
ListHelpers.setLvlOverride(editor, target.numId, level, { startOverride: input.value });
|
|
74429
|
+
dispatchEditorTransaction(editor, editor.state.tr);
|
|
74430
|
+
return true;
|
|
74431
|
+
}, { expectedRevision: options?.expectedRevision });
|
|
74432
|
+
if (receipt3.steps[0]?.effect !== "changed") {
|
|
74433
|
+
return toListsFailure("INVALID_TARGET", "setValue could not be applied.", { target: input.target });
|
|
74434
|
+
}
|
|
74435
|
+
return { success: true, item: target.address };
|
|
74436
|
+
}
|
|
74437
|
+
const abstractNumId = getAbstractNumId(editor, target.numId);
|
|
74438
|
+
if (abstractNumId == null) {
|
|
74439
|
+
return toListsFailure("INVALID_TARGET", "Could not resolve abstract definition for target.", {
|
|
73576
74440
|
target: input.target
|
|
73577
74441
|
});
|
|
73578
74442
|
}
|
|
73579
|
-
const
|
|
73580
|
-
|
|
73581
|
-
|
|
74443
|
+
const itemsToReassign = getSequenceFromTarget(editor, target);
|
|
74444
|
+
const receipt2 = executeDomainCommand(editor, () => {
|
|
74445
|
+
const { numId: newNumId } = ListHelpers.createNumDefinition(editor, abstractNumId, {
|
|
74446
|
+
copyOverridesFrom: target.numId
|
|
74447
|
+
});
|
|
74448
|
+
ListHelpers.setLvlOverride(editor, newNumId, level, { startOverride: input.value });
|
|
74449
|
+
const { tr } = editor.state;
|
|
74450
|
+
for (const item of itemsToReassign) {
|
|
74451
|
+
const currentLevel = item.level ?? 0;
|
|
74452
|
+
updateNumberingProperties({ numId: newNumId, ilvl: currentLevel }, item.candidate.node, item.candidate.pos, editor, tr);
|
|
74453
|
+
}
|
|
74454
|
+
dispatchEditorTransaction(editor, tr);
|
|
74455
|
+
clearIndexCache(editor);
|
|
74456
|
+
return true;
|
|
74457
|
+
}, { expectedRevision: options?.expectedRevision });
|
|
73582
74458
|
if (receipt2.steps[0]?.effect !== "changed") {
|
|
73583
|
-
return toListsFailure("INVALID_TARGET", "
|
|
74459
|
+
return toListsFailure("INVALID_TARGET", "setValue could not be applied.", { target: input.target });
|
|
73584
74460
|
}
|
|
73585
74461
|
return { success: true, item: target.address };
|
|
73586
74462
|
}
|
|
73587
|
-
function
|
|
73588
|
-
rejectTrackedMode("lists.
|
|
73589
|
-
const target =
|
|
74463
|
+
function listsContinuePreviousWrapper(editor, input, options) {
|
|
74464
|
+
rejectTrackedMode("lists.continuePrevious", options);
|
|
74465
|
+
const target = resolveListItem(editor, input.target);
|
|
73590
74466
|
if (target.numId == null) {
|
|
73591
|
-
return toListsFailure("INVALID_TARGET", "
|
|
73592
|
-
|
|
73593
|
-
|
|
73594
|
-
|
|
73595
|
-
|
|
73596
|
-
|
|
74467
|
+
return toListsFailure("INVALID_TARGET", "Target must have numbering metadata.", { target: input.target });
|
|
74468
|
+
}
|
|
74469
|
+
const canContinue = evaluateCanContinuePrevious(editor, target);
|
|
74470
|
+
if (!canContinue.canContinue) {
|
|
74471
|
+
const reasonToFailureCode = {
|
|
74472
|
+
NO_PREVIOUS_LIST: "NO_COMPATIBLE_PREVIOUS",
|
|
74473
|
+
INCOMPATIBLE_DEFINITIONS: "NO_COMPATIBLE_PREVIOUS",
|
|
74474
|
+
ALREADY_CONTINUOUS: "ALREADY_CONTINUOUS"
|
|
74475
|
+
};
|
|
74476
|
+
const code3 = reasonToFailureCode[canContinue.reason] ?? "INVALID_TARGET";
|
|
74477
|
+
return toListsFailure(code3, `Cannot continue previous: ${canContinue.reason}`, {
|
|
73597
74478
|
target: input.target
|
|
73598
74479
|
});
|
|
73599
74480
|
}
|
|
73600
|
-
const
|
|
74481
|
+
const previous3 = findPreviousCompatibleSequence(editor, target);
|
|
73601
74482
|
if (options?.dryRun) {
|
|
73602
74483
|
return { success: true, item: target.address };
|
|
73603
74484
|
}
|
|
73604
|
-
|
|
73605
|
-
|
|
73606
|
-
|
|
73607
|
-
|
|
73608
|
-
|
|
73609
|
-
|
|
73610
|
-
|
|
73611
|
-
|
|
74485
|
+
const sequence = getContiguousSequence(editor, target);
|
|
74486
|
+
const level = target.level ?? 0;
|
|
74487
|
+
const receipt2 = executeDomainCommand(editor, () => {
|
|
74488
|
+
ListHelpers.removeLvlOverride(editor, target.numId, level);
|
|
74489
|
+
const { tr } = editor.state;
|
|
74490
|
+
for (const item of sequence) {
|
|
74491
|
+
const currentLevel = item.level ?? 0;
|
|
74492
|
+
updateNumberingProperties({ numId: previous3.numId, ilvl: currentLevel }, item.candidate.node, item.candidate.pos, editor, tr);
|
|
74493
|
+
}
|
|
74494
|
+
dispatchEditorTransaction(editor, tr);
|
|
74495
|
+
clearIndexCache(editor);
|
|
74496
|
+
return true;
|
|
74497
|
+
}, { expectedRevision: options?.expectedRevision });
|
|
73612
74498
|
if (receipt2.steps[0]?.effect !== "changed") {
|
|
73613
|
-
return toListsFailure("INVALID_TARGET", "
|
|
74499
|
+
return toListsFailure("INVALID_TARGET", "continuePrevious could not be applied.", { target: input.target });
|
|
73614
74500
|
}
|
|
73615
74501
|
return { success: true, item: target.address };
|
|
73616
74502
|
}
|
|
73617
|
-
function
|
|
73618
|
-
rejectTrackedMode("lists.
|
|
73619
|
-
const target =
|
|
73620
|
-
|
|
74503
|
+
function listsSetLevelRestartWrapper(editor, input, options) {
|
|
74504
|
+
rejectTrackedMode("lists.setLevelRestart", options);
|
|
74505
|
+
const target = resolveListItem(editor, input.target);
|
|
74506
|
+
if (target.numId == null) {
|
|
74507
|
+
return toListsFailure("INVALID_TARGET", "Target must have numbering metadata.", { target: input.target });
|
|
74508
|
+
}
|
|
74509
|
+
if (input.level < 0 || input.level > 8) {
|
|
74510
|
+
return toListsFailure("LEVEL_OUT_OF_RANGE", "Level must be between 0 and 8.", { level: input.level });
|
|
74511
|
+
}
|
|
73621
74512
|
if (options?.dryRun) {
|
|
73622
|
-
return {
|
|
73623
|
-
success: true,
|
|
73624
|
-
paragraph: {
|
|
73625
|
-
kind: "block",
|
|
73626
|
-
nodeType: "paragraph",
|
|
73627
|
-
nodeId: "(dry-run)"
|
|
73628
|
-
}
|
|
73629
|
-
};
|
|
74513
|
+
return { success: true, item: target.address };
|
|
73630
74514
|
}
|
|
73631
|
-
const
|
|
73632
|
-
|
|
73633
|
-
|
|
74515
|
+
const scope = input.scope ?? "definition";
|
|
74516
|
+
const receipt2 = executeDomainCommand(editor, () => {
|
|
74517
|
+
if (scope === "instance") {
|
|
74518
|
+
ListHelpers.setLvlOverride(editor, target.numId, input.level, {
|
|
74519
|
+
lvlRestart: input.restartAfterLevel
|
|
74520
|
+
});
|
|
74521
|
+
} else {
|
|
74522
|
+
const abstractNumId = getAbstractNumId(editor, target.numId);
|
|
74523
|
+
if (abstractNumId == null)
|
|
74524
|
+
return false;
|
|
74525
|
+
ListHelpers.setLvlRestartOnAbstract(editor, abstractNumId, input.level, input.restartAfterLevel);
|
|
74526
|
+
}
|
|
74527
|
+
dispatchEditorTransaction(editor, editor.state.tr);
|
|
74528
|
+
return true;
|
|
74529
|
+
}, { expectedRevision: options?.expectedRevision });
|
|
73634
74530
|
if (receipt2.steps[0]?.effect !== "changed") {
|
|
73635
|
-
return toListsFailure("INVALID_TARGET", "
|
|
74531
|
+
return toListsFailure("INVALID_TARGET", "setLevelRestart could not be applied.", { target: input.target });
|
|
73636
74532
|
}
|
|
73637
|
-
return {
|
|
73638
|
-
|
|
73639
|
-
|
|
73640
|
-
|
|
73641
|
-
|
|
73642
|
-
|
|
74533
|
+
return { success: true, item: target.address };
|
|
74534
|
+
}
|
|
74535
|
+
function listsConvertToTextWrapper(editor, input, options) {
|
|
74536
|
+
rejectTrackedMode("lists.convertToText", options);
|
|
74537
|
+
const target = resolveListItem(editor, input.target);
|
|
74538
|
+
const includeMarker = input.includeMarker ?? false;
|
|
74539
|
+
if (options?.dryRun) {
|
|
74540
|
+
return { success: true, paragraph: { kind: "block", nodeType: "paragraph", nodeId: target.address.nodeId } };
|
|
74541
|
+
}
|
|
74542
|
+
const receipt2 = executeDomainCommand(editor, () => {
|
|
74543
|
+
const { tr } = editor.state;
|
|
74544
|
+
if (includeMarker && target.marker) {
|
|
74545
|
+
const startPos = target.candidate.pos + 1;
|
|
74546
|
+
tr.insertText(target.marker, startPos);
|
|
73643
74547
|
}
|
|
73644
|
-
|
|
74548
|
+
updateNumberingProperties(null, target.candidate.node, target.candidate.pos, editor, tr);
|
|
74549
|
+
dispatchEditorTransaction(editor, tr);
|
|
74550
|
+
clearIndexCache(editor);
|
|
74551
|
+
return true;
|
|
74552
|
+
}, { expectedRevision: options?.expectedRevision });
|
|
74553
|
+
if (receipt2.steps[0]?.effect !== "changed") {
|
|
74554
|
+
return toListsFailure("INVALID_TARGET", "convertToText could not be applied.", { target: input.target });
|
|
74555
|
+
}
|
|
74556
|
+
return { success: true, paragraph: { kind: "block", nodeType: "paragraph", nodeId: target.address.nodeId } };
|
|
73645
74557
|
}
|
|
73646
74558
|
var init_lists_wrappers = __esm(() => {
|
|
73647
74559
|
init_wrapper();
|
|
@@ -73651,7 +74563,9 @@ var init_lists_wrappers = __esm(() => {
|
|
|
73651
74563
|
init_index_cache();
|
|
73652
74564
|
init_tracked_change_refs();
|
|
73653
74565
|
init_list_item_resolver();
|
|
74566
|
+
init_list_sequence_helpers();
|
|
73654
74567
|
init_list_numbering_helpers();
|
|
74568
|
+
init_changeListLevel();
|
|
73655
74569
|
});
|
|
73656
74570
|
|
|
73657
74571
|
// ../../packages/super-editor/src/document-api-adapters/plan-engine/preview.ts
|
|
@@ -75743,12 +76657,11 @@ function cellSidesForEdge(edge, row, col, lastRow, lastCol) {
|
|
|
75743
76657
|
function tableBorderToCellBorder(border) {
|
|
75744
76658
|
const val = typeof border.val === "string" ? border.val : "single";
|
|
75745
76659
|
const color2 = typeof border.color === "string" ? border.color : "auto";
|
|
75746
|
-
const
|
|
75747
|
-
const sizePx = val === "none" || val === "nil" ? 0 : sizeEighthPoints / 8 * POINTS_TO_PIXELS;
|
|
76660
|
+
const size2 = typeof border.size === "number" ? border.size : 0;
|
|
75748
76661
|
return {
|
|
75749
76662
|
val,
|
|
75750
76663
|
color: color2,
|
|
75751
|
-
size:
|
|
76664
|
+
size: val === "none" || val === "nil" ? 0 : size2,
|
|
75752
76665
|
space: 0
|
|
75753
76666
|
};
|
|
75754
76667
|
}
|
|
@@ -75773,13 +76686,16 @@ function applyTableEdgeToCellBorders(tr, tablePos, tableNode, edge, borderSpec)
|
|
|
75773
76686
|
if (!cellNode)
|
|
75774
76687
|
continue;
|
|
75775
76688
|
const cellAttrs = cellNode.attrs;
|
|
75776
|
-
const
|
|
76689
|
+
const tcp = { ...cellAttrs.tableCellProperties ?? {} };
|
|
76690
|
+
const borders = { ...tcp.borders ?? {} };
|
|
75777
76691
|
for (const side of targetSides) {
|
|
75778
76692
|
borders[side] = { ...cellBorder };
|
|
75779
76693
|
}
|
|
76694
|
+
tcp.borders = borders;
|
|
75780
76695
|
tr.setNodeMarkup(tr.mapping.slice(mapFrom).map(tableStart + relPos), null, {
|
|
75781
76696
|
...cellAttrs,
|
|
75782
|
-
borders
|
|
76697
|
+
borders: null,
|
|
76698
|
+
tableCellProperties: tcp
|
|
75783
76699
|
});
|
|
75784
76700
|
}
|
|
75785
76701
|
}
|
|
@@ -75805,7 +76721,8 @@ function applyTableBorderPresetToCellBorders(tr, tablePos, tableNode, preset) {
|
|
|
75805
76721
|
if (!cellNode)
|
|
75806
76722
|
continue;
|
|
75807
76723
|
const cellAttrs = cellNode.attrs;
|
|
75808
|
-
const
|
|
76724
|
+
const tcp = { ...cellAttrs.tableCellProperties ?? {} };
|
|
76725
|
+
const borders = { ...tcp.borders ?? {} };
|
|
75809
76726
|
if (preset === "none") {
|
|
75810
76727
|
borders.top = { ...noneBorder };
|
|
75811
76728
|
borders.bottom = { ...noneBorder };
|
|
@@ -75822,9 +76739,11 @@ function applyTableBorderPresetToCellBorders(tr, tablePos, tableNode, preset) {
|
|
|
75822
76739
|
borders.left = { ...singleBorder };
|
|
75823
76740
|
borders.right = { ...singleBorder };
|
|
75824
76741
|
}
|
|
76742
|
+
tcp.borders = borders;
|
|
75825
76743
|
tr.setNodeMarkup(tr.mapping.slice(mapFrom).map(tableStart + relPos), null, {
|
|
75826
76744
|
...cellAttrs,
|
|
75827
|
-
borders
|
|
76745
|
+
borders: null,
|
|
76746
|
+
tableCellProperties: tcp
|
|
75828
76747
|
});
|
|
75829
76748
|
}
|
|
75830
76749
|
}
|
|
@@ -77468,7 +78387,8 @@ function tablesSetBorderAdapter(editor, input, options) {
|
|
|
77468
78387
|
};
|
|
77469
78388
|
currentProps.borders = currentBorders;
|
|
77470
78389
|
const syncAttrs = resolved.scope === "table" ? syncExtractedTableAttrs(currentProps) : {};
|
|
77471
|
-
|
|
78390
|
+
const cellClear = resolved.scope === "cell" ? { borders: null } : {};
|
|
78391
|
+
tr.setNodeMarkup(resolved.pos, null, { ...currentAttrs, [propsKey]: currentProps, ...syncAttrs, ...cellClear });
|
|
77472
78392
|
if (resolved.scope === "table" && isBoundaryEdge(input.edge)) {
|
|
77473
78393
|
applyTableEdgeToCellBorders(tr, resolved.pos, resolved.node, input.edge, currentBorders[input.edge]);
|
|
77474
78394
|
}
|
|
@@ -77498,7 +78418,8 @@ function tablesClearBorderAdapter(editor, input, options) {
|
|
|
77498
78418
|
currentBorders[input.edge] = { val: "nil", size: 0, color: "auto" };
|
|
77499
78419
|
currentProps.borders = currentBorders;
|
|
77500
78420
|
const syncAttrs = resolved.scope === "table" ? syncExtractedTableAttrs(currentProps) : {};
|
|
77501
|
-
|
|
78421
|
+
const cellClear = resolved.scope === "cell" ? { borders: null } : {};
|
|
78422
|
+
tr.setNodeMarkup(resolved.pos, null, { ...currentAttrs, [propsKey]: currentProps, ...syncAttrs, ...cellClear });
|
|
77502
78423
|
if (resolved.scope === "table" && isBoundaryEdge(input.edge)) {
|
|
77503
78424
|
applyTableEdgeToCellBorders(tr, resolved.pos, resolved.node, input.edge, currentBorders[input.edge]);
|
|
77504
78425
|
}
|
|
@@ -80698,6 +81619,22 @@ function runTocCommand(editor, command, args2, expectedRevision) {
|
|
|
80698
81619
|
const executeCommand = toTocEditorCommand(command);
|
|
80699
81620
|
return runTocAction(editor, () => executeCommand(args2), expectedRevision);
|
|
80700
81621
|
}
|
|
81622
|
+
function normalizeTocContent(content3, editor) {
|
|
81623
|
+
if (!Array.isArray(content3))
|
|
81624
|
+
return null;
|
|
81625
|
+
return content3.map((entry) => entry && typeof entry === "object" && typeof entry.type === "string" ? editor.state.schema.nodeFromJSON(entry) : entry);
|
|
81626
|
+
}
|
|
81627
|
+
function dispatchEditorTransaction2(editor, tr) {
|
|
81628
|
+
if (typeof editor.dispatch === "function") {
|
|
81629
|
+
editor.dispatch(tr);
|
|
81630
|
+
return;
|
|
81631
|
+
}
|
|
81632
|
+
if (typeof editor.view?.dispatch === "function") {
|
|
81633
|
+
editor.view.dispatch(tr);
|
|
81634
|
+
return;
|
|
81635
|
+
}
|
|
81636
|
+
throw new Error("No transaction dispatcher available.");
|
|
81637
|
+
}
|
|
80701
81638
|
function receiptApplied(receipt2) {
|
|
80702
81639
|
return receipt2.steps[0]?.effect === "changed";
|
|
80703
81640
|
}
|
|
@@ -80733,20 +81670,49 @@ function withRightAlign(config33, rightAlignPageNumbers) {
|
|
|
80733
81670
|
return config33;
|
|
80734
81671
|
return { ...config33, display: { ...config33.display, rightAlignPageNumbers } };
|
|
80735
81672
|
}
|
|
80736
|
-
function
|
|
81673
|
+
function sanitizeTocContentForSchema(content3, editor) {
|
|
81674
|
+
if (editor.state.schema?.marks?.tocPageNumber)
|
|
81675
|
+
return content3;
|
|
81676
|
+
return content3.map((paragraph2) => {
|
|
81677
|
+
const paragraphContent = paragraph2.content;
|
|
81678
|
+
if (!Array.isArray(paragraphContent))
|
|
81679
|
+
return paragraph2;
|
|
81680
|
+
let changed = false;
|
|
81681
|
+
const sanitizedContent = paragraphContent.map((node3) => {
|
|
81682
|
+
if (!node3 || typeof node3 !== "object")
|
|
81683
|
+
return node3;
|
|
81684
|
+
const typedNode = node3;
|
|
81685
|
+
const marks = typedNode.marks;
|
|
81686
|
+
if (!Array.isArray(marks))
|
|
81687
|
+
return node3;
|
|
81688
|
+
const filteredMarks = marks.filter((mark) => mark?.type !== "tocPageNumber");
|
|
81689
|
+
if (filteredMarks.length === marks.length)
|
|
81690
|
+
return node3;
|
|
81691
|
+
changed = true;
|
|
81692
|
+
if (filteredMarks.length === 0) {
|
|
81693
|
+
const { marks: _removed, ...rest } = typedNode;
|
|
81694
|
+
return rest;
|
|
81695
|
+
}
|
|
81696
|
+
return { ...typedNode, marks: filteredMarks };
|
|
81697
|
+
});
|
|
81698
|
+
return changed ? { ...paragraph2, content: sanitizedContent } : paragraph2;
|
|
81699
|
+
});
|
|
81700
|
+
}
|
|
81701
|
+
function materializeTocContent(doc, config33, editor) {
|
|
80737
81702
|
const sources = collectTocSources(doc, config33);
|
|
80738
81703
|
const entryParagraphs = buildTocEntryParagraphs(sources, config33);
|
|
80739
|
-
|
|
81704
|
+
const content3 = entryParagraphs.length > 0 ? entryParagraphs : NO_ENTRIES_PLACEHOLDER;
|
|
81705
|
+
return sanitizeTocContentForSchema(content3, editor);
|
|
80740
81706
|
}
|
|
80741
81707
|
function tocConfigureWrapper(editor, input, options) {
|
|
80742
81708
|
rejectTrackedMode("toc.configure", options);
|
|
80743
|
-
const command = requireEditorCommand(editor.commands?.setTableOfContentsInstructionById, "toc.configure");
|
|
80744
81709
|
const resolved = resolveTocTarget(editor.state.doc, input.target);
|
|
80745
81710
|
const currentConfig = parseTocInstruction(resolved.node.attrs?.instruction ?? "");
|
|
80746
81711
|
const patched = applyTocPatchTyped(currentConfig, input.patch);
|
|
81712
|
+
const instruction = serializeTocInstruction(patched);
|
|
80747
81713
|
const rightAlignChanged = input.patch.rightAlignPageNumbers !== undefined && input.patch.rightAlignPageNumbers !== resolved.node.attrs?.rightAlignPageNumbers;
|
|
80748
81714
|
const effectiveRightAlign = input.patch.rightAlignPageNumbers ?? resolved.node.attrs?.rightAlignPageNumbers;
|
|
80749
|
-
const nextContent = materializeTocContent(editor.state.doc, withRightAlign(patched, effectiveRightAlign));
|
|
81715
|
+
const nextContent = materializeTocContent(editor.state.doc, withRightAlign(patched, effectiveRightAlign), editor);
|
|
80750
81716
|
if (areTocConfigsEqual(currentConfig, patched) && !rightAlignChanged) {
|
|
80751
81717
|
return tocFailure("NO_OP", "Configuration patch produced no change.");
|
|
80752
81718
|
}
|
|
@@ -80754,12 +81720,31 @@ function tocConfigureWrapper(editor, input, options) {
|
|
|
80754
81720
|
return tocSuccess(resolved.nodeId);
|
|
80755
81721
|
}
|
|
80756
81722
|
const shouldRefreshContent = !isTocContentUnchanged(resolved.node, nextContent);
|
|
81723
|
+
const command = editor.commands?.setTableOfContentsInstructionById;
|
|
80757
81724
|
const commandNodeId = resolved.commandNodeId ?? resolved.nodeId;
|
|
80758
|
-
const receipt2 = runTocCommand(editor, command, {
|
|
81725
|
+
const receipt2 = typeof command === "function" ? runTocCommand(editor, command, {
|
|
80759
81726
|
sdBlockId: commandNodeId,
|
|
80760
|
-
instruction
|
|
81727
|
+
instruction,
|
|
80761
81728
|
...shouldRefreshContent ? { content: nextContent } : {},
|
|
80762
81729
|
...rightAlignChanged ? { rightAlignPageNumbers: input.patch.rightAlignPageNumbers } : {}
|
|
81730
|
+
}, options?.expectedRevision) : runTocAction(editor, () => {
|
|
81731
|
+
try {
|
|
81732
|
+
const { tr } = editor.state;
|
|
81733
|
+
tr.setNodeMarkup(resolved.pos, undefined, {
|
|
81734
|
+
...resolved.node.attrs,
|
|
81735
|
+
instruction,
|
|
81736
|
+
...rightAlignChanged ? { rightAlignPageNumbers: input.patch.rightAlignPageNumbers } : {}
|
|
81737
|
+
});
|
|
81738
|
+
if (shouldRefreshContent) {
|
|
81739
|
+
const from3 = resolved.pos + 1;
|
|
81740
|
+
const to = resolved.pos + resolved.node.nodeSize - 1;
|
|
81741
|
+
tr.replaceWith(from3, to, normalizeTocContent(nextContent, editor) ?? []);
|
|
81742
|
+
}
|
|
81743
|
+
dispatchEditorTransaction2(editor, tr);
|
|
81744
|
+
return true;
|
|
81745
|
+
} catch {
|
|
81746
|
+
return false;
|
|
81747
|
+
}
|
|
80763
81748
|
}, options?.expectedRevision);
|
|
80764
81749
|
if (!receiptApplied(receipt2)) {
|
|
80765
81750
|
return tocFailure("NO_OP", "Configuration change could not be applied.");
|
|
@@ -80776,20 +81761,31 @@ function tocUpdateWrapper(editor, input, options) {
|
|
|
80776
81761
|
return tocUpdateAll(editor, input, options);
|
|
80777
81762
|
}
|
|
80778
81763
|
function tocUpdateAll(editor, input, options) {
|
|
80779
|
-
const command = requireEditorCommand(editor.commands?.replaceTableOfContentsContentById, "toc.update");
|
|
80780
81764
|
const resolved = resolveTocTarget(editor.state.doc, input.target);
|
|
80781
81765
|
const config33 = parseTocInstruction(resolved.node.attrs?.instruction ?? "");
|
|
80782
81766
|
const rightAlign = resolved.node.attrs?.rightAlignPageNumbers;
|
|
80783
|
-
const content3 = materializeTocContent(editor.state.doc, withRightAlign(config33, rightAlign));
|
|
81767
|
+
const content3 = materializeTocContent(editor.state.doc, withRightAlign(config33, rightAlign), editor);
|
|
80784
81768
|
if (isTocContentUnchanged(resolved.node, content3)) {
|
|
80785
81769
|
return tocFailure("NO_OP", "TOC update produced no change.");
|
|
80786
81770
|
}
|
|
80787
81771
|
if (options?.dryRun) {
|
|
80788
81772
|
return tocSuccess(resolved.nodeId);
|
|
80789
81773
|
}
|
|
80790
|
-
const
|
|
81774
|
+
const command = editor.commands?.replaceTableOfContentsContentById;
|
|
81775
|
+
const receipt2 = typeof command === "function" ? runTocCommand(editor, command, {
|
|
80791
81776
|
sdBlockId: resolved.commandNodeId ?? resolved.nodeId,
|
|
80792
81777
|
content: content3
|
|
81778
|
+
}, options?.expectedRevision) : runTocAction(editor, () => {
|
|
81779
|
+
try {
|
|
81780
|
+
const { tr } = editor.state;
|
|
81781
|
+
const from3 = resolved.pos + 1;
|
|
81782
|
+
const to = resolved.pos + resolved.node.nodeSize - 1;
|
|
81783
|
+
tr.replaceWith(from3, to, normalizeTocContent(content3, editor) ?? []);
|
|
81784
|
+
dispatchEditorTransaction2(editor, tr);
|
|
81785
|
+
return true;
|
|
81786
|
+
} catch {
|
|
81787
|
+
return false;
|
|
81788
|
+
}
|
|
80793
81789
|
}, options?.expectedRevision);
|
|
80794
81790
|
return receiptApplied(receipt2) ? tocSuccess(resolved.nodeId) : tocFailure("NO_OP", "TOC update produced no change.");
|
|
80795
81791
|
}
|
|
@@ -80806,7 +81802,6 @@ function getPageMap(editor) {
|
|
|
80806
81802
|
return tocStorage.pageMap;
|
|
80807
81803
|
}
|
|
80808
81804
|
function tocUpdatePageNumbers(editor, input, options) {
|
|
80809
|
-
const command = requireEditorCommand(editor.commands?.replaceTableOfContentsContentById, "toc.update");
|
|
80810
81805
|
const resolved = resolveTocTarget(editor.state.doc, input.target);
|
|
80811
81806
|
const config33 = parseTocInstruction(resolved.node.attrs?.instruction ?? "");
|
|
80812
81807
|
if (deriveIncludePageNumbers(config33.display.omitPageNumberLevels, config33.source.outlineLevels) === false) {
|
|
@@ -80826,9 +81821,21 @@ function tocUpdatePageNumbers(editor, input, options) {
|
|
|
80826
81821
|
if (options?.dryRun) {
|
|
80827
81822
|
return tocSuccess(resolved.nodeId);
|
|
80828
81823
|
}
|
|
80829
|
-
const
|
|
81824
|
+
const command = editor.commands?.replaceTableOfContentsContentById;
|
|
81825
|
+
const receipt2 = typeof command === "function" ? runTocCommand(editor, command, {
|
|
80830
81826
|
sdBlockId: resolved.commandNodeId ?? resolved.nodeId,
|
|
80831
81827
|
content: updatedContent
|
|
81828
|
+
}, options?.expectedRevision) : runTocAction(editor, () => {
|
|
81829
|
+
try {
|
|
81830
|
+
const { tr } = editor.state;
|
|
81831
|
+
const from3 = resolved.pos + 1;
|
|
81832
|
+
const to = resolved.pos + resolved.node.nodeSize - 1;
|
|
81833
|
+
tr.replaceWith(from3, to, normalizeTocContent(updatedContent, editor) ?? []);
|
|
81834
|
+
dispatchEditorTransaction2(editor, tr);
|
|
81835
|
+
return true;
|
|
81836
|
+
} catch {
|
|
81837
|
+
return false;
|
|
81838
|
+
}
|
|
80832
81839
|
}, options?.expectedRevision);
|
|
80833
81840
|
return receiptApplied(receipt2) ? tocSuccess(resolved.nodeId) : tocFailure("NO_OP", "Page number update produced no change.");
|
|
80834
81841
|
}
|
|
@@ -80872,19 +81879,27 @@ function buildPageNumberUpdatedContent(tocNode, pageMap) {
|
|
|
80872
81879
|
}
|
|
80873
81880
|
function tocRemoveWrapper(editor, input, options) {
|
|
80874
81881
|
rejectTrackedMode("toc.remove", options);
|
|
80875
|
-
const command = requireEditorCommand(editor.commands?.deleteTableOfContentsById, "toc.remove");
|
|
80876
81882
|
const resolved = resolveTocTarget(editor.state.doc, input.target);
|
|
80877
81883
|
if (options?.dryRun) {
|
|
80878
81884
|
return tocSuccess(resolved.nodeId);
|
|
80879
81885
|
}
|
|
80880
|
-
const
|
|
81886
|
+
const command = editor.commands?.deleteTableOfContentsById;
|
|
81887
|
+
const receipt2 = typeof command === "function" ? runTocCommand(editor, command, {
|
|
80881
81888
|
sdBlockId: resolved.commandNodeId ?? resolved.nodeId
|
|
81889
|
+
}, options?.expectedRevision) : runTocAction(editor, () => {
|
|
81890
|
+
try {
|
|
81891
|
+
const { tr } = editor.state;
|
|
81892
|
+
tr.delete(resolved.pos, resolved.pos + resolved.node.nodeSize);
|
|
81893
|
+
dispatchEditorTransaction2(editor, tr);
|
|
81894
|
+
return true;
|
|
81895
|
+
} catch {
|
|
81896
|
+
return false;
|
|
81897
|
+
}
|
|
80882
81898
|
}, options?.expectedRevision);
|
|
80883
81899
|
return receiptApplied(receipt2) ? tocSuccess(resolved.nodeId) : tocFailure("NO_OP", "TOC removal produced no change.");
|
|
80884
81900
|
}
|
|
80885
81901
|
function createTableOfContentsWrapper(editor, input, options) {
|
|
80886
81902
|
rejectTrackedMode("create.tableOfContents", options);
|
|
80887
|
-
const command = requireEditorCommand(editor.commands?.insertTableOfContentsAt, "create.tableOfContents");
|
|
80888
81903
|
const at = input.at ?? { kind: "documentEnd" };
|
|
80889
81904
|
let pos;
|
|
80890
81905
|
if (at.kind === "documentStart") {
|
|
@@ -80896,17 +81911,42 @@ function createTableOfContentsWrapper(editor, input, options) {
|
|
|
80896
81911
|
}
|
|
80897
81912
|
const config33 = input.config ? applyTocPatchTyped(DEFAULT_TOC_CONFIG, input.config) : DEFAULT_TOC_CONFIG;
|
|
80898
81913
|
const instruction = serializeTocInstruction(config33);
|
|
80899
|
-
const content3 = materializeTocContent(editor.state.doc, withRightAlign(config33, input.config?.rightAlignPageNumbers));
|
|
81914
|
+
const content3 = materializeTocContent(editor.state.doc, withRightAlign(config33, input.config?.rightAlignPageNumbers), editor);
|
|
80900
81915
|
const sdBlockId = v4();
|
|
80901
81916
|
if (options?.dryRun) {
|
|
80902
81917
|
return { success: true, toc: buildTocAddress("(dry-run)") };
|
|
80903
81918
|
}
|
|
80904
|
-
const
|
|
81919
|
+
const command = editor.commands?.insertTableOfContentsAt;
|
|
81920
|
+
const receipt2 = typeof command === "function" ? runTocCommand(editor, command, {
|
|
80905
81921
|
pos,
|
|
80906
81922
|
instruction,
|
|
80907
81923
|
sdBlockId,
|
|
80908
81924
|
content: content3,
|
|
80909
81925
|
...input.config?.rightAlignPageNumbers !== undefined ? { rightAlignPageNumbers: input.config.rightAlignPageNumbers } : {}
|
|
81926
|
+
}, options?.expectedRevision) : runTocAction(editor, () => {
|
|
81927
|
+
const tocType = editor.state.schema.nodes.tableOfContents;
|
|
81928
|
+
const paragraphType = editor.state.schema.nodes.paragraph;
|
|
81929
|
+
if (!tocType || !paragraphType)
|
|
81930
|
+
return false;
|
|
81931
|
+
const defaultContent = [
|
|
81932
|
+
paragraphType.create({}, editor.state.schema.text("Update table of contents to populate entries."))
|
|
81933
|
+
];
|
|
81934
|
+
const materializedContent = normalizeTocContent(content3, editor) ?? defaultContent;
|
|
81935
|
+
const tocNode = tocType.create({
|
|
81936
|
+
instruction,
|
|
81937
|
+
sdBlockId,
|
|
81938
|
+
...input.config?.rightAlignPageNumbers !== undefined ? { rightAlignPageNumbers: input.config.rightAlignPageNumbers } : {}
|
|
81939
|
+
}, materializedContent);
|
|
81940
|
+
try {
|
|
81941
|
+
const { tr } = editor.state;
|
|
81942
|
+
tr.insert(pos, tocNode);
|
|
81943
|
+
dispatchEditorTransaction2(editor, tr);
|
|
81944
|
+
return true;
|
|
81945
|
+
} catch (error) {
|
|
81946
|
+
if (error instanceof RangeError)
|
|
81947
|
+
return false;
|
|
81948
|
+
throw error;
|
|
81949
|
+
}
|
|
80910
81950
|
}, options?.expectedRevision);
|
|
80911
81951
|
if (!receiptApplied(receipt2)) {
|
|
80912
81952
|
return {
|
|
@@ -81282,11 +82322,20 @@ function assembleDocumentApiAdapters(editor) {
|
|
|
81282
82322
|
list: (query2) => listsListWrapper(editor, query2),
|
|
81283
82323
|
get: (input) => listsGetWrapper(editor, input),
|
|
81284
82324
|
insert: (input, options) => listsInsertWrapper(editor, input, options),
|
|
81285
|
-
|
|
82325
|
+
create: (input, options) => listsCreateWrapper(editor, input, options),
|
|
82326
|
+
attach: (input, options) => listsAttachWrapper(editor, input, options),
|
|
82327
|
+
detach: (input, options) => listsDetachWrapper(editor, input, options),
|
|
81286
82328
|
indent: (input, options) => listsIndentWrapper(editor, input, options),
|
|
81287
82329
|
outdent: (input, options) => listsOutdentWrapper(editor, input, options),
|
|
81288
|
-
|
|
81289
|
-
|
|
82330
|
+
join: (input, options) => listsJoinWrapper(editor, input, options),
|
|
82331
|
+
canJoin: (input) => listsCanJoinWrapper(editor, input),
|
|
82332
|
+
separate: (input, options) => listsSeparateWrapper(editor, input, options),
|
|
82333
|
+
setLevel: (input, options) => listsSetLevelWrapper(editor, input, options),
|
|
82334
|
+
setValue: (input, options) => listsSetValueWrapper(editor, input, options),
|
|
82335
|
+
continuePrevious: (input, options) => listsContinuePreviousWrapper(editor, input, options),
|
|
82336
|
+
canContinuePrevious: (input) => listsCanContinuePreviousWrapper(editor, input),
|
|
82337
|
+
setLevelRestart: (input, options) => listsSetLevelRestartWrapper(editor, input, options),
|
|
82338
|
+
convertToText: (input, options) => listsConvertToTextWrapper(editor, input, options)
|
|
81290
82339
|
},
|
|
81291
82340
|
sections: {
|
|
81292
82341
|
list: (query2) => sectionsListAdapter2(editor, query2),
|
|
@@ -85606,11 +86655,20 @@ var init_invoke_input = __esm(() => {
|
|
|
85606
86655
|
getNode: "address",
|
|
85607
86656
|
"lists.list": "query",
|
|
85608
86657
|
"lists.insert": "input",
|
|
85609
|
-
"lists.setType": "input",
|
|
85610
86658
|
"lists.indent": "input",
|
|
85611
86659
|
"lists.outdent": "input",
|
|
85612
|
-
"lists.
|
|
85613
|
-
"lists.
|
|
86660
|
+
"lists.create": "input",
|
|
86661
|
+
"lists.attach": "input",
|
|
86662
|
+
"lists.detach": "input",
|
|
86663
|
+
"lists.join": "input",
|
|
86664
|
+
"lists.canJoin": "input",
|
|
86665
|
+
"lists.separate": "input",
|
|
86666
|
+
"lists.setLevel": "input",
|
|
86667
|
+
"lists.setValue": "input",
|
|
86668
|
+
"lists.continuePrevious": "input",
|
|
86669
|
+
"lists.canContinuePrevious": "input",
|
|
86670
|
+
"lists.setLevelRestart": "input",
|
|
86671
|
+
"lists.convertToText": "input",
|
|
85614
86672
|
"create.paragraph": "input",
|
|
85615
86673
|
"create.heading": "input"
|
|
85616
86674
|
};
|
|
@@ -85633,11 +86691,15 @@ var init_invoke_input = __esm(() => {
|
|
|
85633
86691
|
]);
|
|
85634
86692
|
LIST_TARGET_OPERATIONS = new Set([
|
|
85635
86693
|
"lists.insert",
|
|
85636
|
-
"lists.setType",
|
|
85637
86694
|
"lists.indent",
|
|
85638
86695
|
"lists.outdent",
|
|
85639
|
-
"lists.
|
|
85640
|
-
"lists.
|
|
86696
|
+
"lists.detach",
|
|
86697
|
+
"lists.separate",
|
|
86698
|
+
"lists.setLevel",
|
|
86699
|
+
"lists.setValue",
|
|
86700
|
+
"lists.continuePrevious",
|
|
86701
|
+
"lists.canContinuePrevious",
|
|
86702
|
+
"lists.convertToText"
|
|
85641
86703
|
]);
|
|
85642
86704
|
});
|
|
85643
86705
|
|
|
@@ -86141,6 +87203,15 @@ function buildHelperSpecs() {
|
|
|
86141
87203
|
var CLI_HELPER_COMMANDS;
|
|
86142
87204
|
var init_helper_commands = __esm(() => {
|
|
86143
87205
|
CLI_HELPER_COMMANDS = [
|
|
87206
|
+
{
|
|
87207
|
+
tokens: ["lists", "exit"],
|
|
87208
|
+
canonicalOperationId: "lists.detach",
|
|
87209
|
+
defaultInput: {},
|
|
87210
|
+
description: "Alias for lists detach.",
|
|
87211
|
+
category: "lists",
|
|
87212
|
+
mutates: true,
|
|
87213
|
+
examples: [`superdoc lists exit --target-json '{"kind":"block","nodeType":"listItem","nodeId":"p1"}'`]
|
|
87214
|
+
},
|
|
86144
87215
|
{
|
|
86145
87216
|
tokens: ["format", "strikethrough"],
|
|
86146
87217
|
canonicalOperationId: "format.strike",
|
|
@@ -86761,23 +87832,47 @@ var init_operation_params = __esm(() => {
|
|
|
86761
87832
|
{ name: "input", kind: "jsonFlag", flag: "input-json", type: "json" },
|
|
86762
87833
|
...LIST_TARGET_FLAT_PARAMS
|
|
86763
87834
|
],
|
|
86764
|
-
"doc.lists.
|
|
87835
|
+
"doc.lists.indent": [
|
|
86765
87836
|
{ name: "input", kind: "jsonFlag", flag: "input-json", type: "json" },
|
|
86766
87837
|
...LIST_TARGET_FLAT_PARAMS
|
|
86767
87838
|
],
|
|
86768
|
-
"doc.lists.
|
|
87839
|
+
"doc.lists.outdent": [
|
|
86769
87840
|
{ name: "input", kind: "jsonFlag", flag: "input-json", type: "json" },
|
|
86770
87841
|
...LIST_TARGET_FLAT_PARAMS
|
|
86771
87842
|
],
|
|
86772
|
-
"doc.lists.
|
|
87843
|
+
"doc.lists.create": [{ name: "input", kind: "jsonFlag", flag: "input-json", type: "json" }],
|
|
87844
|
+
"doc.lists.attach": [{ name: "input", kind: "jsonFlag", flag: "input-json", type: "json" }],
|
|
87845
|
+
"doc.lists.detach": [
|
|
87846
|
+
{ name: "input", kind: "jsonFlag", flag: "input-json", type: "json" },
|
|
87847
|
+
...LIST_TARGET_FLAT_PARAMS
|
|
87848
|
+
],
|
|
87849
|
+
"doc.lists.join": [{ name: "input", kind: "jsonFlag", flag: "input-json", type: "json" }],
|
|
87850
|
+
"doc.lists.canJoin": [{ name: "input", kind: "jsonFlag", flag: "input-json", type: "json" }],
|
|
87851
|
+
"doc.lists.separate": [
|
|
86773
87852
|
{ name: "input", kind: "jsonFlag", flag: "input-json", type: "json" },
|
|
86774
87853
|
...LIST_TARGET_FLAT_PARAMS
|
|
86775
87854
|
],
|
|
86776
|
-
"doc.lists.
|
|
87855
|
+
"doc.lists.setLevel": [
|
|
87856
|
+
{ name: "input", kind: "jsonFlag", flag: "input-json", type: "json" },
|
|
87857
|
+
...LIST_TARGET_FLAT_PARAMS
|
|
87858
|
+
],
|
|
87859
|
+
"doc.lists.setValue": [
|
|
87860
|
+
{ name: "input", kind: "jsonFlag", flag: "input-json", type: "json" },
|
|
87861
|
+
...LIST_TARGET_FLAT_PARAMS
|
|
87862
|
+
],
|
|
87863
|
+
"doc.lists.continuePrevious": [
|
|
87864
|
+
{ name: "input", kind: "jsonFlag", flag: "input-json", type: "json" },
|
|
87865
|
+
...LIST_TARGET_FLAT_PARAMS
|
|
87866
|
+
],
|
|
87867
|
+
"doc.lists.canContinuePrevious": [
|
|
87868
|
+
{ name: "input", kind: "jsonFlag", flag: "input-json", type: "json" },
|
|
87869
|
+
...LIST_TARGET_FLAT_PARAMS
|
|
87870
|
+
],
|
|
87871
|
+
"doc.lists.setLevelRestart": [{ name: "input", kind: "jsonFlag", flag: "input-json", type: "json" }],
|
|
87872
|
+
"doc.lists.convertToText": [
|
|
86777
87873
|
{ name: "input", kind: "jsonFlag", flag: "input-json", type: "json" },
|
|
86778
87874
|
...LIST_TARGET_FLAT_PARAMS
|
|
86779
87875
|
],
|
|
86780
|
-
"doc.lists.exit": [{ name: "input", kind: "jsonFlag", flag: "input-json", type: "json" }, ...LIST_TARGET_FLAT_PARAMS],
|
|
86781
87876
|
"doc.blocks.delete": [
|
|
86782
87877
|
{ name: "nodeType", kind: "flag", flag: "node-type", type: "string" },
|
|
86783
87878
|
{ name: "nodeId", kind: "flag", flag: "node-id", type: "string" }
|
|
@@ -95286,8 +96381,11 @@ async function executeParsedInvocation(parsed, io, executionMode, collabSessionP
|
|
|
95286
96381
|
async function invokeCommand(argv, options = {}) {
|
|
95287
96382
|
const io = mergeIo(options.ioOverrides);
|
|
95288
96383
|
const startedAt = io.now();
|
|
95289
|
-
const parsed =
|
|
95290
|
-
|
|
96384
|
+
const { parsed, output } = await withStateDirOverride(options.stateDir, async () => {
|
|
96385
|
+
const parsedInvocation = parseInvocation(argv);
|
|
96386
|
+
const commandOutput = await executeParsedInvocation(parsedInvocation, io, options.executionMode ?? "oneshot", options.collabSessionPool);
|
|
96387
|
+
return { parsed: parsedInvocation, output: commandOutput };
|
|
96388
|
+
});
|
|
95291
96389
|
return {
|
|
95292
96390
|
globals: parsed.globals,
|
|
95293
96391
|
execution: output.execution,
|
|
@@ -95299,51 +96397,53 @@ async function runHostCommand(tokens, io) {
|
|
|
95299
96397
|
const { runHostStdio: runHostStdio2 } = await init_server().then(() => exports_server);
|
|
95300
96398
|
return runHostStdio2(tokens, io);
|
|
95301
96399
|
}
|
|
95302
|
-
async function run(argv, ioOverrides) {
|
|
96400
|
+
async function run(argv, ioOverrides, options = {}) {
|
|
95303
96401
|
const io = mergeIo(ioOverrides);
|
|
95304
96402
|
const startedAt = io.now();
|
|
95305
96403
|
let outputMode = "json";
|
|
95306
|
-
|
|
95307
|
-
|
|
95308
|
-
|
|
95309
|
-
|
|
95310
|
-
|
|
95311
|
-
|
|
95312
|
-
|
|
95313
|
-
|
|
95314
|
-
|
|
95315
|
-
if (parsed.rest[0] === "install" && !parsed.globals.help) {
|
|
95316
|
-
return await runInstall(parsed.rest.slice(1), io);
|
|
95317
|
-
}
|
|
95318
|
-
if (parsed.rest[0] === "uninstall" && !parsed.globals.help) {
|
|
95319
|
-
return await runUninstall(parsed.rest.slice(1), io);
|
|
95320
|
-
}
|
|
95321
|
-
if (parsed.rest[0] === "call" && outputMode !== "json") {
|
|
95322
|
-
throw new CliError("INVALID_ARGUMENT", "call: only --output json is supported.");
|
|
95323
|
-
}
|
|
95324
|
-
if (!parsed.globals.help) {
|
|
95325
|
-
const legacyCompat = await tryRunLegacyCompatCommand(argv, parsed.rest, io);
|
|
95326
|
-
if (legacyCompat.handled) {
|
|
95327
|
-
return legacyCompat.exitCode;
|
|
96404
|
+
return withStateDirOverride(options.stateDir, async () => {
|
|
96405
|
+
try {
|
|
96406
|
+
const parsed = parseInvocation(argv);
|
|
96407
|
+
outputMode = parsed.globals.output;
|
|
96408
|
+
if (parsed.rest[0] === "host") {
|
|
96409
|
+
const hostTokens = parsed.rest.slice(1);
|
|
96410
|
+
if (parsed.globals.help)
|
|
96411
|
+
hostTokens.push("--help");
|
|
96412
|
+
return await runHostCommand(hostTokens, io);
|
|
95328
96413
|
}
|
|
95329
|
-
|
|
95330
|
-
|
|
95331
|
-
|
|
95332
|
-
|
|
96414
|
+
if (parsed.rest[0] === "install" && !parsed.globals.help) {
|
|
96415
|
+
return await runInstall(parsed.rest.slice(1), io);
|
|
96416
|
+
}
|
|
96417
|
+
if (parsed.rest[0] === "uninstall" && !parsed.globals.help) {
|
|
96418
|
+
return await runUninstall(parsed.rest.slice(1), io);
|
|
96419
|
+
}
|
|
96420
|
+
if (parsed.rest[0] === "call" && outputMode !== "json") {
|
|
96421
|
+
throw new CliError("INVALID_ARGUMENT", "call: only --output json is supported.");
|
|
96422
|
+
}
|
|
96423
|
+
if (!parsed.globals.help) {
|
|
96424
|
+
const legacyCompat = await tryRunLegacyCompatCommand(argv, parsed.rest, io);
|
|
96425
|
+
if (legacyCompat.handled) {
|
|
96426
|
+
return legacyCompat.exitCode;
|
|
96427
|
+
}
|
|
96428
|
+
}
|
|
96429
|
+
const output = await executeParsedInvocation(parsed, io, "oneshot");
|
|
96430
|
+
if (output.helpText) {
|
|
96431
|
+
io.stdout(output.helpText);
|
|
96432
|
+
return 0;
|
|
96433
|
+
}
|
|
96434
|
+
if (!output.execution) {
|
|
96435
|
+
throw new CliError("COMMAND_FAILED", "Command produced no execution result and no help text.");
|
|
96436
|
+
}
|
|
96437
|
+
const elapsedMs = io.now() - startedAt;
|
|
96438
|
+
writeSuccess(io, outputMode, output.execution, elapsedMs);
|
|
95333
96439
|
return 0;
|
|
96440
|
+
} catch (error) {
|
|
96441
|
+
const cliError = toCliError(error);
|
|
96442
|
+
const elapsedMs = io.now() - startedAt;
|
|
96443
|
+
writeFailure(io, outputMode, cliError, elapsedMs);
|
|
96444
|
+
return cliError.exitCode;
|
|
95334
96445
|
}
|
|
95335
|
-
|
|
95336
|
-
throw new CliError("COMMAND_FAILED", "Command produced no execution result and no help text.");
|
|
95337
|
-
}
|
|
95338
|
-
const elapsedMs = io.now() - startedAt;
|
|
95339
|
-
writeSuccess(io, outputMode, output.execution, elapsedMs);
|
|
95340
|
-
return 0;
|
|
95341
|
-
} catch (error) {
|
|
95342
|
-
const cliError = toCliError(error);
|
|
95343
|
-
const elapsedMs = io.now() - startedAt;
|
|
95344
|
-
writeFailure(io, outputMode, cliError, elapsedMs);
|
|
95345
|
-
return cliError.exitCode;
|
|
95346
|
-
}
|
|
96446
|
+
});
|
|
95347
96447
|
}
|
|
95348
96448
|
var HELP, MANUAL_COMMANDS, EXTRA_COMMAND_KEYS, COMMAND_KEY_SET, CLI_COMMAND_KEY_SET, MANUAL_COMMAND_KEY_SET, COMMAND_OPERATION_ID_BY_KEY;
|
|
95349
96449
|
var init_src2 = __esm(async () => {
|
|
@@ -95365,6 +96465,7 @@ var init_src2 = __esm(async () => {
|
|
|
95365
96465
|
init_operation_args();
|
|
95366
96466
|
init_install();
|
|
95367
96467
|
init_uninstall();
|
|
96468
|
+
init_context();
|
|
95368
96469
|
init_cli();
|
|
95369
96470
|
HELP = [
|
|
95370
96471
|
CLI_HELP,
|