@superdoc-dev/cli 0.2.0-next.54 → 0.2.0-next.56
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +153 -62
- package/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -1210,7 +1210,7 @@ var init_operation_definitions = __esm(() => {
|
|
|
1210
1210
|
},
|
|
1211
1211
|
insert: {
|
|
1212
1212
|
memberPath: "insert",
|
|
1213
|
-
description: "Insert content at a target position. Supports text (default), markdown, and html content types via the `type` field.",
|
|
1213
|
+
description: "Insert content at a target position, or at the end of the document when target is omitted. Supports text (default), markdown, and html content types via the `type` field.",
|
|
1214
1214
|
expectedResult: "Returns a TextMutationReceipt with applied status; receipt reports NO_OP if the insertion point is invalid or content is empty.",
|
|
1215
1215
|
requiresDocumentContext: true,
|
|
1216
1216
|
metadata: mutationOperation({
|
|
@@ -1293,7 +1293,7 @@ var init_operation_definitions = __esm(() => {
|
|
|
1293
1293
|
...FORMAT_INLINE_ALIAS_OPERATION_DEFINITIONS,
|
|
1294
1294
|
"styles.apply": {
|
|
1295
1295
|
memberPath: "styles.apply",
|
|
1296
|
-
description: "Apply document-level default style changes to the stylesheet (word/styles.xml). Targets docDefaults run
|
|
1296
|
+
description: "Apply document-level default style changes to the stylesheet (word/styles.xml). Targets docDefaults run and paragraph channels with set-style patch semantics.",
|
|
1297
1297
|
expectedResult: "Returns a StylesApplyReceipt with per-channel success/failure details for each property change.",
|
|
1298
1298
|
requiresDocumentContext: true,
|
|
1299
1299
|
metadata: mutationOperation({
|
|
@@ -10185,6 +10185,36 @@ function resolveSegmentPosition(targetOffset, segmentStart, segmentLength, docFr
|
|
|
10185
10185
|
}
|
|
10186
10186
|
return docFrom + (targetOffset - segmentStart);
|
|
10187
10187
|
}
|
|
10188
|
+
function computeTextContentLength(blockNode) {
|
|
10189
|
+
let length = 0;
|
|
10190
|
+
const walk = (node2) => {
|
|
10191
|
+
if (node2.isText) {
|
|
10192
|
+
length += (node2.text ?? "").length;
|
|
10193
|
+
return;
|
|
10194
|
+
}
|
|
10195
|
+
if (node2.isLeaf) {
|
|
10196
|
+
length += 1;
|
|
10197
|
+
return;
|
|
10198
|
+
}
|
|
10199
|
+
let first2 = true;
|
|
10200
|
+
for (let i = 0;i < node2.childCount; i++) {
|
|
10201
|
+
const child = node2.child(i);
|
|
10202
|
+
if (child.isBlock && !first2)
|
|
10203
|
+
length += 1;
|
|
10204
|
+
walk(child);
|
|
10205
|
+
first2 = false;
|
|
10206
|
+
}
|
|
10207
|
+
};
|
|
10208
|
+
let first = true;
|
|
10209
|
+
for (let i = 0;i < blockNode.childCount; i++) {
|
|
10210
|
+
const child = blockNode.child(i);
|
|
10211
|
+
if (child.isBlock && !first)
|
|
10212
|
+
length += 1;
|
|
10213
|
+
walk(child);
|
|
10214
|
+
first = false;
|
|
10215
|
+
}
|
|
10216
|
+
return length;
|
|
10217
|
+
}
|
|
10188
10218
|
function resolveTextRangeInBlock(blockNode, blockPos, range) {
|
|
10189
10219
|
if (range.start < 0 || range.end < range.start)
|
|
10190
10220
|
return null;
|
|
@@ -10242,6 +10272,21 @@ function resolveTextRangeInBlock(blockNode, blockPos, range) {
|
|
|
10242
10272
|
return { from: fromPos, to: toPos };
|
|
10243
10273
|
}
|
|
10244
10274
|
|
|
10275
|
+
// ../../packages/super-editor/src/document-api-adapters/helpers/text-mutation-resolution.ts
|
|
10276
|
+
function readTextAtResolvedRange(editor, range) {
|
|
10277
|
+
return editor.state.doc.textBetween(range.from, range.to, `
|
|
10278
|
+
`, OBJECT_REPLACEMENT_CHAR);
|
|
10279
|
+
}
|
|
10280
|
+
function buildTextMutationResolution(input) {
|
|
10281
|
+
return {
|
|
10282
|
+
...input.requestedTarget ? { requestedTarget: input.requestedTarget } : {},
|
|
10283
|
+
target: input.target,
|
|
10284
|
+
range: { from: input.range.from, to: input.range.to },
|
|
10285
|
+
text: input.text
|
|
10286
|
+
};
|
|
10287
|
+
}
|
|
10288
|
+
var OBJECT_REPLACEMENT_CHAR = "";
|
|
10289
|
+
|
|
10245
10290
|
// ../../packages/super-editor/src/document-api-adapters/helpers/adapter-utils.ts
|
|
10246
10291
|
function findTextBlockCandidates(index, blockId) {
|
|
10247
10292
|
return index.candidates.filter((candidate) => candidate.nodeId === blockId && isTextBlockCandidate(candidate));
|
|
@@ -10268,22 +10313,100 @@ function resolveTextTarget(editor, target) {
|
|
|
10268
10313
|
return null;
|
|
10269
10314
|
return resolveTextRangeInBlock(block.node, block.pos, target.range);
|
|
10270
10315
|
}
|
|
10316
|
+
function collectTopLevelPositions(doc) {
|
|
10317
|
+
const positions = new Set;
|
|
10318
|
+
let offset = 0;
|
|
10319
|
+
for (let i = 0;i < doc.childCount; i++) {
|
|
10320
|
+
positions.add(offset);
|
|
10321
|
+
offset += doc.child(i).nodeSize;
|
|
10322
|
+
}
|
|
10323
|
+
return positions;
|
|
10324
|
+
}
|
|
10271
10325
|
function resolveDefaultInsertTarget(editor) {
|
|
10272
10326
|
const index = getBlockIndex(editor);
|
|
10273
|
-
const
|
|
10274
|
-
const
|
|
10275
|
-
|
|
10327
|
+
const doc = editor.state.doc;
|
|
10328
|
+
const topLevelPositions = collectTopLevelPositions(doc);
|
|
10329
|
+
for (let i = index.candidates.length - 1;i >= 0; i--) {
|
|
10330
|
+
const candidate = index.candidates[i];
|
|
10331
|
+
if (topLevelPositions.has(candidate.pos) && isTextBlockCandidate(candidate)) {
|
|
10332
|
+
const textLength = computeTextContentLength(candidate.node);
|
|
10333
|
+
const range = resolveTextRangeInBlock(candidate.node, candidate.pos, { start: textLength, end: textLength });
|
|
10334
|
+
if (!range)
|
|
10335
|
+
continue;
|
|
10336
|
+
return {
|
|
10337
|
+
kind: "text-block",
|
|
10338
|
+
target: {
|
|
10339
|
+
kind: "text",
|
|
10340
|
+
blockId: candidate.nodeId,
|
|
10341
|
+
range: { start: textLength, end: textLength }
|
|
10342
|
+
},
|
|
10343
|
+
range
|
|
10344
|
+
};
|
|
10345
|
+
}
|
|
10346
|
+
}
|
|
10347
|
+
if (doc.content.size > 0) {
|
|
10348
|
+
return { kind: "structural-end", insertPos: doc.content.size };
|
|
10349
|
+
}
|
|
10350
|
+
return null;
|
|
10351
|
+
}
|
|
10352
|
+
function insertParagraphAtEnd(editor, pos, text, applyMeta) {
|
|
10353
|
+
const schema = editor.state.schema;
|
|
10354
|
+
const textNode = schema.text(text);
|
|
10355
|
+
const paragraph = schema.nodes.paragraph.create(null, textNode);
|
|
10356
|
+
const tr = editor.state.tr;
|
|
10357
|
+
tr.insert(pos, paragraph);
|
|
10358
|
+
if (applyMeta)
|
|
10359
|
+
applyMeta(tr);
|
|
10360
|
+
editor.dispatch(tr);
|
|
10361
|
+
}
|
|
10362
|
+
function resolveWriteTarget(editor, request) {
|
|
10363
|
+
const requestedTarget = request.target;
|
|
10364
|
+
if (request.kind === "insert" && !request.target) {
|
|
10365
|
+
const fallback = resolveDefaultInsertTarget(editor);
|
|
10366
|
+
if (!fallback)
|
|
10367
|
+
return null;
|
|
10368
|
+
if (fallback.kind === "structural-end") {
|
|
10369
|
+
const pos = fallback.insertPos;
|
|
10370
|
+
const syntheticRange = { from: pos, to: pos };
|
|
10371
|
+
const syntheticTarget = { kind: "text", blockId: "", range: { start: 0, end: 0 } };
|
|
10372
|
+
return {
|
|
10373
|
+
requestedTarget,
|
|
10374
|
+
effectiveTarget: syntheticTarget,
|
|
10375
|
+
range: syntheticRange,
|
|
10376
|
+
resolution: buildTextMutationResolution({
|
|
10377
|
+
requestedTarget,
|
|
10378
|
+
target: syntheticTarget,
|
|
10379
|
+
range: syntheticRange,
|
|
10380
|
+
text: ""
|
|
10381
|
+
}),
|
|
10382
|
+
structuralEnd: true
|
|
10383
|
+
};
|
|
10384
|
+
}
|
|
10385
|
+
const text2 = readTextAtResolvedRange(editor, fallback.range);
|
|
10386
|
+
return {
|
|
10387
|
+
requestedTarget,
|
|
10388
|
+
effectiveTarget: fallback.target,
|
|
10389
|
+
range: fallback.range,
|
|
10390
|
+
resolution: buildTextMutationResolution({
|
|
10391
|
+
requestedTarget,
|
|
10392
|
+
target: fallback.target,
|
|
10393
|
+
range: fallback.range,
|
|
10394
|
+
text: text2
|
|
10395
|
+
})
|
|
10396
|
+
};
|
|
10397
|
+
}
|
|
10398
|
+
const target = request.target;
|
|
10399
|
+
if (!target)
|
|
10276
10400
|
return null;
|
|
10277
|
-
const range =
|
|
10401
|
+
const range = resolveTextTarget(editor, target);
|
|
10278
10402
|
if (!range)
|
|
10279
10403
|
return null;
|
|
10404
|
+
const text = readTextAtResolvedRange(editor, range);
|
|
10280
10405
|
return {
|
|
10281
|
-
|
|
10282
|
-
|
|
10283
|
-
|
|
10284
|
-
|
|
10285
|
-
},
|
|
10286
|
-
range
|
|
10406
|
+
requestedTarget,
|
|
10407
|
+
effectiveTarget: target,
|
|
10408
|
+
range,
|
|
10409
|
+
resolution: buildTextMutationResolution({ requestedTarget, target, range, text })
|
|
10287
10410
|
};
|
|
10288
10411
|
}
|
|
10289
10412
|
function addDiagnostic(diagnostics, message) {
|
|
@@ -24702,21 +24825,6 @@ var init_executor = __esm(() => {
|
|
|
24702
24825
|
TEXT_STYLE_KEYS = ["color", "fontSize", "letterSpacing", "vertAlign", "position"];
|
|
24703
24826
|
});
|
|
24704
24827
|
|
|
24705
|
-
// ../../packages/super-editor/src/document-api-adapters/helpers/text-mutation-resolution.ts
|
|
24706
|
-
function readTextAtResolvedRange(editor, range) {
|
|
24707
|
-
return editor.state.doc.textBetween(range.from, range.to, `
|
|
24708
|
-
`, OBJECT_REPLACEMENT_CHAR);
|
|
24709
|
-
}
|
|
24710
|
-
function buildTextMutationResolution(input) {
|
|
24711
|
-
return {
|
|
24712
|
-
...input.requestedTarget ? { requestedTarget: input.requestedTarget } : {},
|
|
24713
|
-
target: input.target,
|
|
24714
|
-
range: { from: input.range.from, to: input.range.to },
|
|
24715
|
-
text: input.text
|
|
24716
|
-
};
|
|
24717
|
-
}
|
|
24718
|
-
var OBJECT_REPLACEMENT_CHAR = "";
|
|
24719
|
-
|
|
24720
24828
|
// ../../node_modules/.pnpm/bail@2.0.2/node_modules/bail/index.js
|
|
24721
24829
|
function bail(error) {
|
|
24722
24830
|
if (error) {
|
|
@@ -70754,39 +70862,6 @@ function normalizeFormatLocator(input) {
|
|
|
70754
70862
|
};
|
|
70755
70863
|
return { target };
|
|
70756
70864
|
}
|
|
70757
|
-
function resolveWriteTarget(editor, request) {
|
|
70758
|
-
const requestedTarget = request.target;
|
|
70759
|
-
if (request.kind === "insert" && !request.target) {
|
|
70760
|
-
const fallback = resolveDefaultInsertTarget(editor);
|
|
70761
|
-
if (!fallback)
|
|
70762
|
-
return null;
|
|
70763
|
-
const text6 = readTextAtResolvedRange(editor, fallback.range);
|
|
70764
|
-
return {
|
|
70765
|
-
requestedTarget,
|
|
70766
|
-
effectiveTarget: fallback.target,
|
|
70767
|
-
range: fallback.range,
|
|
70768
|
-
resolution: buildTextMutationResolution({
|
|
70769
|
-
requestedTarget,
|
|
70770
|
-
target: fallback.target,
|
|
70771
|
-
range: fallback.range,
|
|
70772
|
-
text: text6
|
|
70773
|
-
})
|
|
70774
|
-
};
|
|
70775
|
-
}
|
|
70776
|
-
const target = request.target;
|
|
70777
|
-
if (!target)
|
|
70778
|
-
return null;
|
|
70779
|
-
const range = resolveTextTarget(editor, target);
|
|
70780
|
-
if (!range)
|
|
70781
|
-
return null;
|
|
70782
|
-
const text5 = readTextAtResolvedRange(editor, range);
|
|
70783
|
-
return {
|
|
70784
|
-
requestedTarget,
|
|
70785
|
-
effectiveTarget: target,
|
|
70786
|
-
range,
|
|
70787
|
-
resolution: buildTextMutationResolution({ requestedTarget, target, range, text: text5 })
|
|
70788
|
-
};
|
|
70789
|
-
}
|
|
70790
70865
|
function mapPlanReceiptToTextReceipt(_receipt, resolution) {
|
|
70791
70866
|
return { success: true, resolution };
|
|
70792
70867
|
}
|
|
@@ -70861,6 +70936,16 @@ function writeWrapper(editor, request, options) {
|
|
|
70861
70936
|
if (options?.dryRun) {
|
|
70862
70937
|
return { success: true, resolution: resolved.resolution };
|
|
70863
70938
|
}
|
|
70939
|
+
if (resolved.structuralEnd && normalizedRequest.kind === "insert") {
|
|
70940
|
+
const insertPos = resolved.range.from;
|
|
70941
|
+
const text5 = normalizedRequest.text ?? "";
|
|
70942
|
+
const receipt3 = executeDomainCommand(editor, () => {
|
|
70943
|
+
const meta = mode === "tracked" ? applyTrackedMutationMeta : applyDirectMutationMeta;
|
|
70944
|
+
insertParagraphAtEnd(editor, insertPos, text5, meta);
|
|
70945
|
+
return true;
|
|
70946
|
+
}, { expectedRevision: options?.expectedRevision });
|
|
70947
|
+
return mapPlanReceiptToTextReceipt(receipt3, resolved.resolution);
|
|
70948
|
+
}
|
|
70864
70949
|
const stepId = v4();
|
|
70865
70950
|
let op;
|
|
70866
70951
|
let stepDef;
|
|
@@ -71021,8 +71106,14 @@ function insertStructuredWrapper(editor, input, options) {
|
|
|
71021
71106
|
if (!fallback) {
|
|
71022
71107
|
throw new DocumentApiAdapterError("TARGET_NOT_FOUND", "No default insertion point available.");
|
|
71023
71108
|
}
|
|
71024
|
-
|
|
71025
|
-
|
|
71109
|
+
if (fallback.kind === "structural-end") {
|
|
71110
|
+
const pos = fallback.insertPos;
|
|
71111
|
+
resolvedRange = { from: pos, to: pos };
|
|
71112
|
+
effectiveTarget = { kind: "text", blockId: "", range: { start: 0, end: 0 } };
|
|
71113
|
+
} else {
|
|
71114
|
+
resolvedRange = fallback.range;
|
|
71115
|
+
effectiveTarget = fallback.target;
|
|
71116
|
+
}
|
|
71026
71117
|
}
|
|
71027
71118
|
const resolution = buildTextMutationResolution({
|
|
71028
71119
|
requestedTarget: target,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdoc-dev/cli",
|
|
3
|
-
"version": "0.2.0-next.
|
|
3
|
+
"version": "0.2.0-next.56",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"superdoc": "./dist/index.js"
|
|
@@ -29,11 +29,11 @@
|
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"optionalDependencies": {
|
|
32
|
-
"@superdoc-dev/cli-darwin-arm64": "0.2.0-next.
|
|
33
|
-
"@superdoc-dev/cli-darwin-x64": "0.2.0-next.
|
|
34
|
-
"@superdoc-dev/cli-
|
|
35
|
-
"@superdoc-dev/cli-
|
|
36
|
-
"@superdoc-dev/cli-linux-arm64": "0.2.0-next.
|
|
32
|
+
"@superdoc-dev/cli-darwin-arm64": "0.2.0-next.56",
|
|
33
|
+
"@superdoc-dev/cli-darwin-x64": "0.2.0-next.56",
|
|
34
|
+
"@superdoc-dev/cli-windows-x64": "0.2.0-next.56",
|
|
35
|
+
"@superdoc-dev/cli-linux-x64": "0.2.0-next.56",
|
|
36
|
+
"@superdoc-dev/cli-linux-arm64": "0.2.0-next.56"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"dev": "bun run src/index.ts",
|