@stll/folio-core 0.76.0 → 0.78.0
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/ai-edits/headless.d.ts +6 -4
- package/dist/ai-edits/headless.js +32 -15
- package/dist/ai-edits/pending-suggestions.d.ts +9 -0
- package/dist/ai-edits/pending-suggestions.js +11 -0
- package/dist/ai-edits/read.js +24 -1
- package/dist/ai-edits/table-geometry.js +12 -4
- package/dist/canonical/canonicalBatchReview.js +7 -6
- package/dist/canonical/canonicalInlineProjection.d.ts +2 -2
- package/dist/canonical/canonicalInlineProjection.js +2 -2
- package/dist/canonical/canonicalProjectionBlocks.d.ts +10 -1
- package/dist/canonical/canonicalPublicOperations.js +19 -40
- package/dist/canonical/canonicalSeedContent.d.ts +18 -3
- package/dist/canonical/canonicalSeedContent.js +28 -15
- package/dist/canonical/canonicalSession.d.ts +22 -12
- package/dist/canonical/canonicalSession.js +190 -194
- package/dist/compare/inline-provenance.js +8 -1
- package/dist/controller/canonicalClipboard.d.ts +2 -1
- package/dist/controller/canonicalClipboard.js +312 -47
- package/dist/controller/canonicalComposition.js +67 -14
- package/dist/controller/canonicalStoryEditor.js +2 -0
- package/dist/controller/hiddenEditorManager.js +2 -0
- package/dist/docx/importedIdCollisions.js +29 -4
- package/dist/docx/paragraphParser.js +1 -1
- package/dist/docx/reviewResolutionProvenance.d.ts +2 -0
- package/dist/docx/reviewResolutionProvenance.js +22 -2
- package/dist/docx/server/templatePlan/apply.js +47 -2
- package/dist/docx/server/templatePlan/blocks.d.ts +34 -7
- package/dist/docx/server/templatePlan/blocks.js +190 -13
- package/dist/docx/server/templatePlan/builders.d.ts +8 -1
- package/dist/docx/server/templatePlan/builders.js +21 -5
- package/dist/docx/server/templatePlan/emit.d.ts +2 -0
- package/dist/docx/server/templatePlan/emit.js +108 -6
- package/dist/docx/server/templatePlan/plan.d.ts +26 -1
- package/dist/docx/server/templatePlan/plan.js +181 -21
- package/dist/docx/server/templatePlan/planShape.js +15 -3
- package/dist/docx/server/templatePlan/revisions.d.ts +55 -0
- package/dist/docx/server/templatePlan/revisions.js +276 -2
- package/dist/docx/server/templatePlan/story.d.ts +58 -1
- package/dist/docx/server/templatePlan/story.js +176 -12
- package/dist/docx/server/templatePlan/types.d.ts +153 -1
- package/dist/docx/server/templatePlan/verify.js +58 -15
- package/dist/docx/settingsHeaderFooterUpdate.d.ts +1 -1
- package/dist/docx/tableGridXml.d.ts +3 -7
- package/dist/docx/tableGridXml.js +23 -15
- package/dist/docx/tableParser.js +3 -1
- package/dist/layout-bridge/convert/footnoteLayout.js +34 -8
- package/dist/prosemirror/canonicalMarkupDocument.d.ts +20 -0
- package/dist/prosemirror/canonicalMarkupDocument.js +73 -0
- package/dist/prosemirror/canonicalTableCommands.d.ts +1 -1
- package/dist/prosemirror/canonicalTableCommands.js +7 -9
- package/dist/prosemirror/conversion/markupViewSource.d.ts +17 -0
- package/dist/prosemirror/conversion/markupViewSource.js +11 -0
- package/dist/prosemirror/conversion/toProseDoc.d.ts +8 -0
- package/dist/prosemirror/conversion/toProseDoc.js +43 -19
- package/dist/prosemirror/independentMarkupProjection.d.ts +27 -0
- package/dist/prosemirror/independentMarkupProjection.js +147 -0
- package/dist/prosemirror/markupViewNotes.d.ts +1 -1
- package/dist/prosemirror/markupViewNotes.js +24 -27
- package/dist/prosemirror/markupViewPositionMap.d.ts +16 -0
- package/dist/prosemirror/markupViewPositionMap.js +316 -0
- package/dist/prosemirror/markupViewProjection.d.ts +3 -46
- package/dist/prosemirror/markupViewProjection.js +90 -17
- package/dist/prosemirror/replacedAnnotations.d.ts +4 -78
- package/dist/prosemirror/replacedAnnotations.js +11 -194
- package/dist/prosemirror/styles/styleResolver.d.ts +1 -0
- package/dist/prosemirror/styles/styleResolver.js +4 -1
- package/dist/server.d.ts +2 -2
- package/dist/types/canonicalCapabilities.d.ts +3 -10
- package/dist/types/canonicalCapabilities.js +3 -10
- package/package.json +2 -2
- package/dist/internal/revisionResolutionEdits.d.ts +0 -11
- package/dist/internal/revisionResolutionEdits.js +0 -18
- package/dist/internal/revisionResolutionInline.d.ts +0 -24
- package/dist/internal/revisionResolutionInline.js +0 -302
- package/dist/internal/revisionResolutionStep.d.ts +0 -3
- package/dist/internal/revisionResolutionStep.js +0 -113
- package/dist/internal/revisionResolutionTracking.d.ts +0 -9
- package/dist/internal/revisionResolutionTracking.js +0 -124
- package/dist/internal/wholeStoryRevisionResolution.d.ts +0 -56
- package/dist/internal/wholeStoryRevisionResolution.js +0 -783
- package/dist/prosemirror/commands/resolveAllTableChanges.d.ts +0 -38
- package/dist/prosemirror/commands/resolveAllTableChanges.js +0 -642
- package/dist/prosemirror/commands/resolveNodePropertyChangeAttrs.d.ts +0 -13
- package/dist/prosemirror/commands/resolveNodePropertyChangeAttrs.js +0 -45
- package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +0 -8
- package/dist/prosemirror/commands/tableCellMergeResolution.js +0 -56
- package/dist/prosemirror/commands/tableMergeFoldDecisions.d.ts +0 -60
- package/dist/prosemirror/commands/tableMergeFoldDecisions.js +0 -78
- package/dist/prosemirror/rejoinRunCarriers.d.ts +0 -42
- package/dist/prosemirror/rejoinRunCarriers.js +0 -65
- package/dist/prosemirror/runPropertyChangeResolution.d.ts +0 -15
- package/dist/prosemirror/runPropertyChangeResolution.js +0 -34
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isNumberingReference } from "../../numberingReference.js";
|
|
2
2
|
import { parseSettings } from "../../settingsParser.js";
|
|
3
3
|
import { validateDocxConformance } from "../validateDocxConformance.js";
|
|
4
|
-
import { analyzeDocument, analyzeSource, viewOf } from "./blocks.js";
|
|
4
|
+
import { analyzeDocument, analyzeKeptForm, analyzeSource, bookmarkEncloses, viewOf } from "./blocks.js";
|
|
5
5
|
import { applyRefCaseFormat, fieldBookmarkOf, keepsShiftReturnSpacing, refCaseFormat } from "./builders.js";
|
|
6
6
|
import { countEffects, findInvisibleEffects } from "./effects.js";
|
|
7
7
|
import { linkAddress, linkAddressKey, templateCharacterStyles } from "./emit.js";
|
|
@@ -11,6 +11,7 @@ import { styleNumbering } from "./labels.js";
|
|
|
11
11
|
import { guarded, readPartText } from "./package.js";
|
|
12
12
|
import { hyperlinkFieldLink, paragraphPieces, piecesContent, resolvePlan, segmentPieces } from "./plan.js";
|
|
13
13
|
import { objectFingerprint, objectTargets, readStoryResources, relationshipIdsOf } from "./resources.js";
|
|
14
|
+
import { tableRowRevisions } from "./revisions.js";
|
|
14
15
|
import { createStoryState, endStory, isSelfNumberingField, readParagraph, toggleOf, walkBlocks } from "./story.js";
|
|
15
16
|
import { integerOrNull, isW, rangeOf, readRawPart, twipsOrNull, wAttr, wChild, wChildVal, wChildren, wName, walkElements } from "./xml.js";
|
|
16
17
|
import { Result } from "better-result";
|
|
@@ -47,13 +48,30 @@ const emptyContent = () => ({
|
|
|
47
48
|
links: [],
|
|
48
49
|
marks: []
|
|
49
50
|
});
|
|
50
|
-
|
|
51
|
+
/**
|
|
52
|
+
* A kept tracked change as marks of a content: an insertion marks every
|
|
53
|
+
* unit of its text (or its place, for content without text), a deletion its
|
|
54
|
+
* place and what was deleted, a paragraph mark its place; each with its
|
|
55
|
+
* author and date. Two contents
|
|
56
|
+
* that read the same then show the same changes by the same hands.
|
|
57
|
+
*/
|
|
58
|
+
const revisionMarks = ({ kind, author, date, deleted, mark, within }, at, length) => {
|
|
59
|
+
const by = `${author}:${date ?? ""}`;
|
|
60
|
+
if (kind === "del") {
|
|
61
|
+
const inside = within === void 0 ? "" : `:in:${within.author}:${within.date ?? ""}`;
|
|
62
|
+
return [`${at}:del:${by}:${deleted ?? ""}${inside}`];
|
|
63
|
+
}
|
|
64
|
+
if (mark === true) return [`${at}:mark:${by}`];
|
|
65
|
+
return Array.from({ length: Math.max(length, 1) }, (_unused, offset) => `${at + offset}:ins:${by}`);
|
|
66
|
+
};
|
|
67
|
+
const appendUnit = (content, { kind, text, signature, link, element, instruction, revision, origin }, resources) => {
|
|
51
68
|
content.text += text;
|
|
52
69
|
for (let unit = 0; unit < text.length; unit += 1) {
|
|
53
70
|
content.signatures.push(signature);
|
|
54
71
|
content.links.push(link);
|
|
55
72
|
}
|
|
56
73
|
const at = content.text.length - text.length;
|
|
74
|
+
if (revision !== null) content.marks.push(...revisionMarks(revision, at, text.length));
|
|
57
75
|
if (kind === "pageBreak") content.marks.push(`${at}:break:${wAttr(element, "type") ?? "page"}`);
|
|
58
76
|
else if (kind === "selfNumber") content.marks.push(`${at}:number:${instruction ?? ""}`);
|
|
59
77
|
else if (kind === "object" && element !== null) content.marks.push(`${at}:object:${objectFingerprint(element)}:${objectTargets(element, origin, resources).join(",")}`);
|
|
@@ -73,6 +91,7 @@ const expectedContent = (pieces, resources, content = emptyContent()) => {
|
|
|
73
91
|
link: linkAddressKey(linkAddress(piece.link, resources.relationships[piece.origin])),
|
|
74
92
|
element: piece.atom?.element ?? null,
|
|
75
93
|
instruction: piece.atom?.instruction ?? null,
|
|
94
|
+
revision: piece.atom?.revision ?? null,
|
|
76
95
|
origin: piece.origin
|
|
77
96
|
}, resources);
|
|
78
97
|
return content;
|
|
@@ -99,6 +118,7 @@ const outputContent = ({ read, origin, resources, styles, content = emptyContent
|
|
|
99
118
|
link,
|
|
100
119
|
element: atom.element,
|
|
101
120
|
instruction: atom.instruction ?? null,
|
|
121
|
+
revision: atom.revision ?? null,
|
|
102
122
|
origin
|
|
103
123
|
}, resources);
|
|
104
124
|
}
|
|
@@ -208,6 +228,7 @@ const indentKey = (left, hanging, firstLine) => [
|
|
|
208
228
|
hanging,
|
|
209
229
|
firstLine
|
|
210
230
|
].map((side) => side ?? "").join(":");
|
|
231
|
+
const spacingKey = (before, after) => before === null && after === null ? null : `${before === null ? "" : String(before)}:${after === null ? "" : String(after)}`;
|
|
211
232
|
/** The sides of an indent counted in characters: they override the
|
|
212
233
|
* measured ones, so a paragraph that states one is another paragraph. */
|
|
213
234
|
const CHARACTER_INDENTS = [
|
|
@@ -233,15 +254,12 @@ const statedProperties = (paragraph) => {
|
|
|
233
254
|
indent: indent === null ? null : `${indentKey(twipsOrNull(wAttr(indent, "left") ?? wAttr(indent, "start")), twipsOrNull(wAttr(indent, "hanging")), twipsOrNull(wAttr(indent, "firstLine")))}${characterIndentKey(indent)}`,
|
|
234
255
|
tabStops: tabStopsKey(wChild(properties, "tabs")),
|
|
235
256
|
alignment: wChildVal(properties, "jc"),
|
|
257
|
+
spacing: spacingKey(twipsOrNull(wAttr(wChild(properties, "spacing"), "before")), twipsOrNull(wAttr(wChild(properties, "spacing"), "after"))),
|
|
236
258
|
endsSection: wChild(properties, "sectPr") !== null
|
|
237
259
|
};
|
|
238
260
|
};
|
|
239
|
-
/** Whether a
|
|
240
|
-
const
|
|
241
|
-
const start = read?.bookmarks.find((bookmark) => bookmark.name === name);
|
|
242
|
-
const end = start === void 0 ? void 0 : read?.bookmarkEnds.find(({ id }) => id === start.id);
|
|
243
|
-
return read !== null && start !== void 0 && end !== void 0 && start.atomIndex === 0 && end.atomIndex === read.atoms.length;
|
|
244
|
-
};
|
|
261
|
+
/** Whether a kept paragraph states what the template's states. */
|
|
262
|
+
const sameStated = (before, after) => before.styleId === after.styleId && before.pageBreakBefore === after.pageBreakBefore && before.keepNext === after.keepNext && before.indent === after.indent && before.tabStops === after.tabStops && before.alignment === after.alignment && before.spacing === after.spacing && before.endsSection === after.endsSection && before.numId === after.numId && before.ilvl === after.ilvl;
|
|
245
263
|
const segmentLength = (segment) => piecesContent(segment.kind === "piece" ? [segment.piece] : segment.pieces).text.length;
|
|
246
264
|
/** The rows and cells of a table, without the ids of what they hold. */
|
|
247
265
|
const tableShape = (block) => JSON.stringify((block.block.cells ?? []).map(({ row, col, blockIds }) => [
|
|
@@ -251,10 +269,16 @@ const tableShape = (block) => JSON.stringify((block.block.cells ?? []).map(({ ro
|
|
|
251
269
|
]));
|
|
252
270
|
/** Read `output` back and report how it compares with the resolved plan. */
|
|
253
271
|
const reportTemplatePlanOutput = async ({ source, template, output, plan, resolved, options }) => {
|
|
254
|
-
const
|
|
272
|
+
const keepsRevisions = source.manifest.trackedChangesKept !== void 0;
|
|
273
|
+
const analyzedOutput = keepsRevisions ? await analyzeKeptForm(output) : await analyzeDocument(output);
|
|
255
274
|
if (Result.isError(analyzedOutput)) return analyzedOutput;
|
|
256
275
|
const out = analyzedOutput.value;
|
|
257
276
|
const issues = [];
|
|
277
|
+
const leftUntagged = out.story.state.formattingRevisions + out.story.state.untaggedRevisions + out.footnotes.state.formattingRevisions + out.footnotes.state.untaggedRevisions + out.endnotes.state.formattingRevisions + out.endnotes.state.untaggedRevisions;
|
|
278
|
+
if (keepsRevisions && leftUntagged > 0) issues.push({
|
|
279
|
+
code: "revision-left",
|
|
280
|
+
message: `The output holds ${String(leftUntagged)} tracked change(s) the source's kept changes do not account for.`
|
|
281
|
+
});
|
|
258
282
|
if (source.manifest.trackedChangesResolved !== void 0 && out.manifest.trackedChanges > 0) issues.push({
|
|
259
283
|
code: "revision-left",
|
|
260
284
|
message: `The output holds ${String(out.manifest.trackedChanges)} tracked change(s).`
|
|
@@ -274,10 +298,13 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
274
298
|
for (const item of resolved.items) if (item.kind === "slot") slotBlocks.set(item.paragraph, item.templateBlock);
|
|
275
299
|
for (const slot of resolved.nestedSlots) slotBlocks.set(slot.paragraph, slot.templateBlock);
|
|
276
300
|
const slottedTemplateBlocks = new Set(slotBlocks.values());
|
|
301
|
+
const emptiedTemplateBlocks = new Set(resolved.emptied);
|
|
302
|
+
const { emptiedContents } = resolved;
|
|
277
303
|
const plannedProperties = (paragraph) => {
|
|
278
304
|
const slot = slotBlocks.get(paragraph);
|
|
279
305
|
if (slot !== void 0) return statedProperties(slot.element);
|
|
280
306
|
const { styleId, numbering, pageBreakBefore, keepNext, alignment } = paragraph;
|
|
307
|
+
const spacing = paragraph.spacing === null ? null : spacingKey(paragraph.spacing.before ?? null, paragraph.spacing.after ?? null);
|
|
281
308
|
const endsSection = paragraph.endsSection !== null;
|
|
282
309
|
const indent = paragraph.indent === null ? null : indentKey(paragraph.indent.left, paragraph.indent.hanging, paragraph.indent.firstLine);
|
|
283
310
|
const tabStops = paragraph.tabStops === null ? null : paragraph.tabStops.map((stop) => `left@${String(stop)}`).join(",");
|
|
@@ -290,6 +317,7 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
290
317
|
indent,
|
|
291
318
|
tabStops,
|
|
292
319
|
alignment,
|
|
320
|
+
spacing,
|
|
293
321
|
endsSection
|
|
294
322
|
};
|
|
295
323
|
return {
|
|
@@ -301,6 +329,7 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
301
329
|
indent,
|
|
302
330
|
tabStops,
|
|
303
331
|
alignment,
|
|
332
|
+
spacing,
|
|
304
333
|
endsSection
|
|
305
334
|
};
|
|
306
335
|
};
|
|
@@ -320,9 +349,9 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
320
349
|
message: planned.pageBreakBefore ? `Block ${blockId} does not start the new page the plan gives it.` : `Block ${blockId} starts a new page the plan does not give it.`,
|
|
321
350
|
blockId
|
|
322
351
|
});
|
|
323
|
-
if (stated.keepNext !== planned.keepNext || stated.indent !== planned.indent || stated.tabStops !== planned.tabStops || stated.alignment !== planned.alignment) issues.push({
|
|
352
|
+
if (stated.keepNext !== planned.keepNext || stated.indent !== planned.indent || stated.tabStops !== planned.tabStops || stated.alignment !== planned.alignment || stated.spacing !== planned.spacing) issues.push({
|
|
324
353
|
code: "paragraph-format-mismatch",
|
|
325
|
-
message: `Block ${blockId} does not carry the keep-with-next, the indent, the tab stops or the
|
|
354
|
+
message: `Block ${blockId} does not carry the keep-with-next, the indent, the tab stops, the alignment or the spacing the plan gives it.`,
|
|
326
355
|
blockId
|
|
327
356
|
});
|
|
328
357
|
if (stated.endsSection !== planned.endsSection) issues.push({
|
|
@@ -351,6 +380,10 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
351
380
|
const mapTable = (cells, sourceTable, outputTable) => {
|
|
352
381
|
const tableId = sourceTable.block.id;
|
|
353
382
|
tableOutputs.set(tableId, outputTable.block.id);
|
|
383
|
+
if (!sameList(tableRowRevisions(sourceTable.element), tableRowRevisions(outputTable.element))) {
|
|
384
|
+
missing(`Source table ${tableId} does not keep its inserted and deleted rows.`);
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
354
387
|
const sourceCells = sourceTable.block.cells ?? [];
|
|
355
388
|
const outputCells = outputTable.block.cells ?? [];
|
|
356
389
|
if (sourceCells.length !== outputCells.length || sourceCells.some(({ row, col }, index) => outputCells[index]?.row !== row || outputCells[index]?.col !== col)) {
|
|
@@ -392,8 +425,11 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
392
425
|
const outputParagraph = outputNested[index];
|
|
393
426
|
if (outputParagraph === void 0 || templateParagraph.read === null || outputParagraph.read === null) return false;
|
|
394
427
|
if (slottedTemplateBlocks.has(templateParagraph)) return true;
|
|
428
|
+
if (emptiedTemplateBlocks.has(templateParagraph)) return outputParagraph.read.text === "" && outputParagraph.read.inlineObjects === 0;
|
|
395
429
|
const before = statedProperties(templateParagraph.element);
|
|
396
430
|
const after = statedProperties(outputParagraph.element);
|
|
431
|
+
const textKept = emptiedContents.get(templateParagraph);
|
|
432
|
+
if (textKept !== void 0) return sameStated(before, after) && outputParagraph.read.text === templateParagraph.read.text.slice(0, textKept);
|
|
397
433
|
const was = outputContent({
|
|
398
434
|
read: templateParagraph.read,
|
|
399
435
|
origin: "document",
|
|
@@ -406,7 +442,7 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
406
442
|
resources: outputResources,
|
|
407
443
|
styles: characterStyles
|
|
408
444
|
});
|
|
409
|
-
return before
|
|
445
|
+
return sameStated(before, after) && sameReading(was, is) && sameList(was.signatures, is.signatures);
|
|
410
446
|
}))) issues.push({
|
|
411
447
|
code: "template-mismatch",
|
|
412
448
|
message: `Template block ${item.block.block.id} does not read as the template has it.`,
|
|
@@ -620,7 +656,7 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
620
656
|
const usesNumber = /\\n\b/u.test(entry.reference.instruction);
|
|
621
657
|
let predictedText = null;
|
|
622
658
|
if (targetBlock !== void 0) {
|
|
623
|
-
if (!hasNumberSwitch) predictedText = targetBlock.block.text;
|
|
659
|
+
if (!hasNumberSwitch) predictedText = targetBlock.block.selfNumbers === void 0 ? targetBlock.block.text : null;
|
|
624
660
|
else if (usesNumber) {
|
|
625
661
|
const number = /\\t\b/u.test(entry.reference.instruction) ? targetBlock.label?.numberOnly ?? null : targetBlock.label?.paragraphNumber ?? null;
|
|
626
662
|
predictedText = number === null ? null : applyRefCaseFormat(number, refCaseFormat(entry.reference.instruction));
|
|
@@ -837,7 +873,9 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
837
873
|
if (bookmark !== null && !bookmarkNames.has(bookmark)) warnings.push(`A kept ${field.kind} field points at the bookmark ${bookmark}, which the output does not hold; its cached text is stale until fields update.`);
|
|
838
874
|
}
|
|
839
875
|
const keptToc = templateFields.filter(({ kind }) => kind === "TOC").length;
|
|
840
|
-
|
|
876
|
+
const emptiedToc = Math.min(keptToc, resolved.emptiedContents.size);
|
|
877
|
+
if (emptiedToc > 0) warnings.push(`${emptiedToc} table of contents field(s) show no entries until fields update: the template's cached entries were taken out.`);
|
|
878
|
+
if (keptToc > emptiedToc) warnings.push(`${keptToc - emptiedToc} table of contents field(s) keep the template's cached entries until fields update.`);
|
|
841
879
|
const keptTemplateIds = new Set(resolved.keptTemplateBlocks.map(({ block }) => block.id));
|
|
842
880
|
const frozenFields = [];
|
|
843
881
|
if (resolved.freezeKinds.size > 0) {
|
|
@@ -1001,6 +1039,7 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
1001
1039
|
text,
|
|
1002
1040
|
emphasis,
|
|
1003
1041
|
...part === void 0 || part.strippedPrefix === "" ? {} : { strippedPrefix: part.strippedPrefix },
|
|
1042
|
+
...part === void 0 || part.droppedLead === null ? {} : { droppedLead: part.droppedLead },
|
|
1004
1043
|
...labelAsText === null ? {} : { labelAsText },
|
|
1005
1044
|
sourceLabel,
|
|
1006
1045
|
outputLabel
|
|
@@ -1011,6 +1050,8 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
1011
1050
|
if (counts.labelChanged > 0) warnings.push(`${counts.labelChanged} block(s) render a label that differs from the source's.`);
|
|
1012
1051
|
const placedReads = resolvedParagraphs.flatMap(({ parts }) => parts.flatMap(({ block }) => block.read === null ? [] : [block.read]));
|
|
1013
1052
|
const droppedFields = /* @__PURE__ */ new Map();
|
|
1053
|
+
let pageShapes = 0;
|
|
1054
|
+
for (const paragraph of new Set(resolved.byBlockId.values())) for (const part of paragraph.parts) pageShapes += part.droppedPageShapes;
|
|
1014
1055
|
let internalHyperlinks = 0;
|
|
1015
1056
|
for (const read of placedReads) {
|
|
1016
1057
|
for (const index of read.fieldIndices) {
|
|
@@ -1054,6 +1095,7 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
1054
1095
|
templateSha256: template.manifest.sha256,
|
|
1055
1096
|
outputSha256: out.manifest.sha256,
|
|
1056
1097
|
...source.manifest.trackedChangesResolved === void 0 ? {} : { trackedChanges: source.manifest.trackedChangesResolved },
|
|
1098
|
+
...source.manifest.trackedChangesKept === void 0 ? {} : { trackedChangesKept: source.manifest.trackedChangesKept },
|
|
1057
1099
|
blocks,
|
|
1058
1100
|
counts,
|
|
1059
1101
|
footnotes,
|
|
@@ -1088,7 +1130,8 @@ const reportTemplatePlanOutput = async ({ source, template, output, plan, resolv
|
|
|
1088
1130
|
count
|
|
1089
1131
|
})),
|
|
1090
1132
|
internalHyperlinks,
|
|
1091
|
-
sectionBreaks
|
|
1133
|
+
sectionBreaks,
|
|
1134
|
+
pageShapes
|
|
1092
1135
|
},
|
|
1093
1136
|
textEffects,
|
|
1094
1137
|
updateFields,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** The on/off children of `w:settings` a caller may set without re-serializing the part. */
|
|
2
|
-
export type SettingsOnOffChild = "evenAndOddHeaders" | "updateFields";
|
|
2
|
+
export type SettingsOnOffChild = "evenAndOddHeaders" | "trackRevisions" | "updateFields";
|
|
3
3
|
/**
|
|
4
4
|
* Set (`true`), clear (`false`) or remove (`undefined`) one on/off child of
|
|
5
5
|
* `w:settings`, at its place in the schema's child order; the rest of the part
|
|
@@ -4,12 +4,7 @@
|
|
|
4
4
|
* grid differs from it, so a table without one reads back as it was written.
|
|
5
5
|
*/
|
|
6
6
|
import { document_d_exports } from "../types/document.js";
|
|
7
|
-
|
|
8
|
-
* The most grid columns a table declares. Far above what any editor lays out,
|
|
9
|
-
* it bounds a grid built from a source's skipped-column
|
|
10
|
-
* and span counts, which a file can state at any size.
|
|
11
|
-
*/
|
|
12
|
-
export declare const MAX_GRID_COLUMNS = 4096;
|
|
7
|
+
import { MAX_TABLE_GRID_COLUMNS as MAX_GRID_COLUMNS } from "@stll/docx-core/model";
|
|
13
8
|
/**
|
|
14
9
|
* Columns the grid has to declare: the widest row's total of skipped columns
|
|
15
10
|
* and spans, because a grid narrower than a row leaves cells with no column
|
|
@@ -27,4 +22,5 @@ export declare const gridColumnCount: (table: document_d_exports.Table) => numbe
|
|
|
27
22
|
* accepts the reviewer's change without saying so. The schema declares it
|
|
28
23
|
* after every `w:gridCol`, so it is appended.
|
|
29
24
|
*/
|
|
30
|
-
export declare const modelTableGrid: (table: document_d_exports.Table) => string;
|
|
25
|
+
export declare const modelTableGrid: (table: document_d_exports.Table) => string;
|
|
26
|
+
export { MAX_GRID_COLUMNS };
|
|
@@ -1,24 +1,31 @@
|
|
|
1
|
+
import { serializeTableGeometryChange } from "./reviewResolutionProvenance.js";
|
|
1
2
|
import { intAttr } from "./serializer/xmlUtils.js";
|
|
3
|
+
import { MAX_TABLE_GRID_COLUMNS as MAX_GRID_COLUMNS, gridColumnsInRows } from "@stll/docx-core/model";
|
|
2
4
|
// src/docx/tableGridXml.ts
|
|
3
5
|
/**
|
|
4
|
-
* The
|
|
5
|
-
* it
|
|
6
|
-
*
|
|
6
|
+
* The `w:tblGrid` a table's model writes when no capture stands in for it.
|
|
7
|
+
* The serializer writes it; the parser keeps a capture only when the source
|
|
8
|
+
* grid differs from it, so a table without one reads back as it was written.
|
|
7
9
|
*/
|
|
8
|
-
const MAX_GRID_COLUMNS = 4096;
|
|
9
10
|
/**
|
|
10
11
|
* Columns the grid has to declare: the widest row's total of skipped columns
|
|
11
12
|
* and spans, because a grid narrower than a row leaves cells with no column
|
|
12
13
|
* to sit in. At most {@link MAX_GRID_COLUMNS}.
|
|
13
14
|
*/
|
|
14
|
-
const gridColumnCount = (table) =>
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
const gridColumnCount = (table) => Math.min(gridColumnsInRows(table.rows), MAX_GRID_COLUMNS);
|
|
16
|
+
const currentGridColumnCount = (table, change) => {
|
|
17
|
+
const geometry = change?.geometryChange;
|
|
18
|
+
if (change === void 0 || geometry === void 0) return gridColumnCount(table);
|
|
19
|
+
if (geometry.type === "mergeCells") return change.columnWidths.length;
|
|
20
|
+
const ids = new Set(geometry.revisionIds);
|
|
21
|
+
const rows = table.rows.map((row) => ({
|
|
22
|
+
...row,
|
|
23
|
+
cells: row.cells.filter(({ structuralChange }) => structuralChange?.type !== "tableCellDeletion" || !ids.has(structuralChange.info.id))
|
|
24
|
+
}));
|
|
25
|
+
return gridColumnCount({
|
|
26
|
+
...table,
|
|
27
|
+
rows
|
|
28
|
+
});
|
|
22
29
|
};
|
|
23
30
|
/**
|
|
24
31
|
* Serialize `w:tblGridChange`: the grid a reviewer replaced, from the change's
|
|
@@ -28,9 +35,10 @@ const gridColumnCount = (table) => {
|
|
|
28
35
|
* measure for is written back without one; spelling it as a zero would claim a
|
|
29
36
|
* width the source never stated.
|
|
30
37
|
*/
|
|
31
|
-
const serializeTableGridChange = (
|
|
38
|
+
const serializeTableGridChange = (change) => {
|
|
39
|
+
const { id, columnWidths } = change;
|
|
32
40
|
const columns = columnWidths.map((width) => width === void 0 ? "<w:gridCol/>" : `<w:gridCol w:w="${intAttr(width)}"/>`).join("");
|
|
33
|
-
return `<w:tblGridChange w:id="${intAttr(id)}"><w:tblGrid>${columns}</w:tblGrid></w:tblGridChange>`;
|
|
41
|
+
return `<w:tblGridChange w:id="${intAttr(id)}"${serializeTableGeometryChange(change)}><w:tblGrid>${columns}</w:tblGrid></w:tblGridChange>`;
|
|
34
42
|
};
|
|
35
43
|
/**
|
|
36
44
|
* `w:tblGrid` from the model.
|
|
@@ -48,7 +56,7 @@ const modelTableGrid = (table) => {
|
|
|
48
56
|
const gridChange = change === void 0 ? "" : serializeTableGridChange(change);
|
|
49
57
|
const columnWidths = table.columnWidths;
|
|
50
58
|
if (columnWidths && columnWidths.length > 0) return `<w:tblGrid>${columnWidths.map((w) => `<w:gridCol w:w="${intAttr(w)}"/>`).join("")}${gridChange}</w:tblGrid>`;
|
|
51
|
-
const columns =
|
|
59
|
+
const columns = currentGridColumnCount(table, change);
|
|
52
60
|
return columns === 0 && gridChange === "" ? "<w:tblGrid/>" : `<w:tblGrid>${"<w:gridCol/>".repeat(columns)}${gridChange}</w:tblGrid>`;
|
|
53
61
|
};
|
|
54
62
|
export { MAX_GRID_COLUMNS, gridColumnCount, modelTableGrid };
|
package/dist/docx/tableParser.js
CHANGED
|
@@ -8,6 +8,7 @@ import { parseParagraph } from "./paragraphParser.js";
|
|
|
8
8
|
import { enrichParagraphTextBoxes } from "./paragraphTextBoxEnrichment.js";
|
|
9
9
|
import { FloatingTableXSpecSchema, FloatingTableYSpecSchema, TableAlignmentSchema, TextDirectionSchema, narrowEnum } from "./parserEnums.js";
|
|
10
10
|
import { standalonePreviewLedger } from "./previewBudget.js";
|
|
11
|
+
import { parseTableGeometryChange } from "./reviewResolutionProvenance.js";
|
|
11
12
|
import { captureSdtSiblingMarkers, parseSdtProperties } from "./sdtProperties.js";
|
|
12
13
|
import { parseShading } from "./shadingParser.js";
|
|
13
14
|
import { findChildAnySpelling } from "./strictNames.js";
|
|
@@ -1171,6 +1172,7 @@ function parseTableGridChange(gridElement) {
|
|
|
1171
1172
|
const snapshot = findChild(changeElement, "w", "tblGrid");
|
|
1172
1173
|
return {
|
|
1173
1174
|
id: parseTrackedChangeInfo(changeElement).id,
|
|
1175
|
+
...parseTableGeometryChange(changeElement),
|
|
1174
1176
|
columnWidths: (snapshot === null ? [] : findChildren(snapshot, "w", "gridCol")).map((column) => parseNumericAttribute(column, "w", "w"))
|
|
1175
1177
|
};
|
|
1176
1178
|
}
|
|
@@ -1359,7 +1361,7 @@ function parseTable(tblElement, styles, theme, numbering, rels, media, options)
|
|
|
1359
1361
|
if (table.rows.length === 0) return;
|
|
1360
1362
|
if (preservedChildren.length > 0) table.preserved = { children: preservedChildren };
|
|
1361
1363
|
if (bookmarks.length > 0) table.bookmarks = bookmarks;
|
|
1362
|
-
inferImplicitSingleCellRowSpans(table, rowsWithGridOffsets);
|
|
1364
|
+
if (table.formatting?.gridChange?.geometryChange === void 0) inferImplicitSingleCellRowSpans(table, rowsWithGridOffsets);
|
|
1363
1365
|
const captured = table.formatting;
|
|
1364
1366
|
if (captured?.gridSourceXml !== void 0 && captured.gridSourceXml === modelTableGrid(table)) {
|
|
1365
1367
|
const { gridSourceXml: _modelGrid, ...rest } = captured;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { expectNoteMarkerAttrs } from "../../internal/noteMarkerAttrs.js";
|
|
1
2
|
import { measureParagraph } from "../../layout-engine/measure/measureParagraph.js";
|
|
2
3
|
import { getExactTableRowBottomMargins } from "../../layout-engine/measure/tableCellGrid.js";
|
|
3
4
|
import { layoutTextBoxContent } from "../../layout-engine/measure/textBoxParagraphLayout.js";
|
|
4
5
|
import { DEFAULT_TEXTBOX_MARGINS, FOOTNOTE_ENTRY_MARGIN_BOTTOM, FOOTNOTE_FALLBACK_LINE_HEIGHT, FOOTNOTE_SEPARATOR_HEIGHT, isFloatingImageRun, resolveTableWidthPx } from "../../layout-engine/types.js";
|
|
6
|
+
import { markupViewSources } from "../../prosemirror/conversion/markupViewSource.js";
|
|
5
7
|
import { footnoteToProseDoc } from "../../prosemirror/conversion/toProseDoc.js";
|
|
6
8
|
import { projectStoryMarkupView } from "../../prosemirror/markupViewProjection.js";
|
|
7
9
|
import { remapMarkupViewBlocks } from "./markupViewFlow.js";
|
|
@@ -229,14 +231,38 @@ function convertNoteStoryToFlowBlocks(content, options, referenceMarkText) {
|
|
|
229
231
|
if (options.justificationCompatibility) flowOptions.justificationCompatibility = options.justificationCompatibility;
|
|
230
232
|
if (options.tableIndentCompatibility) flowOptions.tableIndentCompatibility = options.tableIndentCompatibility;
|
|
231
233
|
if (options.automaticHyphenation) flowOptions.automaticHyphenation = options.automaticHyphenation;
|
|
234
|
+
const markupView = options.markupView ?? "all-markup";
|
|
235
|
+
const kind = noteReferenceKind(pmDoc);
|
|
236
|
+
if (markupView !== "all-markup" && kind !== void 0) {
|
|
237
|
+
const id = 0;
|
|
238
|
+
markupViewSources.set(pmDoc, {
|
|
239
|
+
document: { package: {
|
|
240
|
+
document: { content: [] },
|
|
241
|
+
...kind === "footnote" ? { footnotes: [{
|
|
242
|
+
type: kind,
|
|
243
|
+
id,
|
|
244
|
+
content
|
|
245
|
+
}] } : { endnotes: [{
|
|
246
|
+
type: kind,
|
|
247
|
+
id,
|
|
248
|
+
content
|
|
249
|
+
}] }
|
|
250
|
+
} },
|
|
251
|
+
story: {
|
|
252
|
+
kind,
|
|
253
|
+
id
|
|
254
|
+
},
|
|
255
|
+
options: proseOptions
|
|
256
|
+
});
|
|
257
|
+
}
|
|
232
258
|
const projection = projectStoryMarkupView({
|
|
233
259
|
doc: pmDoc,
|
|
234
|
-
markupView
|
|
260
|
+
markupView,
|
|
235
261
|
styles: options.styles,
|
|
236
262
|
numbering: options.numbering
|
|
237
263
|
});
|
|
238
264
|
const viewDoc = projection.type === "resolved" ? projection.doc : pmDoc;
|
|
239
|
-
const hasReferenceMark =
|
|
265
|
+
const hasReferenceMark = (viewDoc === pmDoc ? kind : noteReferenceKind(viewDoc)) !== void 0;
|
|
240
266
|
if (hasReferenceMark && referenceMarkText !== void 0) flowOptions.noteReferenceMarkText = referenceMarkText;
|
|
241
267
|
const converted = toFlowBlocks(viewDoc, flowOptions);
|
|
242
268
|
return {
|
|
@@ -244,14 +270,14 @@ function convertNoteStoryToFlowBlocks(content, options, referenceMarkText) {
|
|
|
244
270
|
hasReferenceMark
|
|
245
271
|
};
|
|
246
272
|
}
|
|
247
|
-
function
|
|
248
|
-
let
|
|
273
|
+
function noteReferenceKind(doc) {
|
|
274
|
+
let kind;
|
|
249
275
|
doc.descendants((node) => {
|
|
250
|
-
if (
|
|
251
|
-
if (node.type.name === "noteMarker")
|
|
252
|
-
return
|
|
276
|
+
if (kind !== void 0) return false;
|
|
277
|
+
if (node.type.name === "noteMarker") kind = expectNoteMarkerAttrs(node).kind;
|
|
278
|
+
return kind === void 0;
|
|
253
279
|
});
|
|
254
|
-
return
|
|
280
|
+
return kind;
|
|
255
281
|
}
|
|
256
282
|
/** Restore an authored footnote line that the body-only terminal-table policy collapsed. */
|
|
257
283
|
function preserveAuthoredFootnoteTerminalParagraph(blocks) {
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { EditorState } from "prosemirror-state";
|
|
2
|
+
import { Node } from "prosemirror-model";
|
|
3
|
+
import { RevisionDecision } from "@stll/docx-core/ops";
|
|
4
|
+
import { StepMap } from "prosemirror-transform";
|
|
5
|
+
type CanonicalMarkupDocumentOptions = {
|
|
6
|
+
state: EditorState;
|
|
7
|
+
decision: RevisionDecision;
|
|
8
|
+
};
|
|
9
|
+
type CanonicalMarkupDocument = {
|
|
10
|
+
doc: Node;
|
|
11
|
+
partial: boolean;
|
|
12
|
+
positionMap?: StepMap;
|
|
13
|
+
changeBarRanges?: readonly {
|
|
14
|
+
from: number;
|
|
15
|
+
to: number;
|
|
16
|
+
}[];
|
|
17
|
+
};
|
|
18
|
+
/** Resolve a copy of the authored model and project the selected review view. */
|
|
19
|
+
export declare const canonicalMarkupDocument: ({ state, decision }: CanonicalMarkupDocumentOptions) => CanonicalMarkupDocument;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { writableCopy } from "../types/documentModel.js";
|
|
2
|
+
import { proseDocToBlocks } from "./conversion/fromProseDoc.js";
|
|
3
|
+
import { markupViewSources, markupViewStateSources } from "./conversion/markupViewSource.js";
|
|
4
|
+
import { storyConversionOptions } from "./conversion/storyConversionOptions.js";
|
|
5
|
+
import { footnoteToProseDoc, headerFooterToProseDoc, toProseDoc } from "./conversion/toProseDoc.js";
|
|
6
|
+
import { projectDetachedText, projectIndependentMarkup } from "./independentMarkupProjection.js";
|
|
7
|
+
import { getStatedDocumentNumbering } from "./plugins/documentNumbering.js";
|
|
8
|
+
import { getDocumentStyleResolver } from "./plugins/documentStyleState.js";
|
|
9
|
+
import { styleResolverSource } from "./styles/styleResolver.js";
|
|
10
|
+
import { OP_STORIES, findStoryBody, resolvedMarkupDocumentView, sameStory } from "@stll/docx-core/ops";
|
|
11
|
+
// src/prosemirror/canonicalMarkupDocument.ts
|
|
12
|
+
const detachedModel = (state) => {
|
|
13
|
+
const numbering = getStatedDocumentNumbering(state);
|
|
14
|
+
const resolver = getDocumentStyleResolver(state);
|
|
15
|
+
const definitions = resolver === null ? void 0 : styleResolverSource(resolver);
|
|
16
|
+
const styles = definitions === void 0 ? void 0 : writableCopy(definitions);
|
|
17
|
+
return { package: {
|
|
18
|
+
document: { content: proseDocToBlocks(state.doc, void 0, styles) },
|
|
19
|
+
...numbering === null ? {} : { numbering },
|
|
20
|
+
...styles === void 0 ? {} : { styles }
|
|
21
|
+
} };
|
|
22
|
+
};
|
|
23
|
+
/** Resolve a copy of the authored model and project the selected review view. */
|
|
24
|
+
const canonicalMarkupDocument = ({ state, decision }) => {
|
|
25
|
+
const converted = markupViewStateSources.get(state) ?? markupViewSources.get(state.doc);
|
|
26
|
+
const authoritative = converted?.document;
|
|
27
|
+
if (authoritative === void 0) {
|
|
28
|
+
const detached = projectDetachedText(state.doc, decision);
|
|
29
|
+
if (detached !== void 0) return {
|
|
30
|
+
...detached,
|
|
31
|
+
partial: false
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const source = authoritative ?? detachedModel(state);
|
|
35
|
+
const resolved = resolvedMarkupDocumentView(source, decision);
|
|
36
|
+
const story = converted?.story ?? OP_STORIES.MAIN;
|
|
37
|
+
const partial = resolved.unresolved.some((unresolved) => sameStory(unresolved, story));
|
|
38
|
+
if (resolved.document === source) return {
|
|
39
|
+
doc: state.doc,
|
|
40
|
+
partial
|
|
41
|
+
};
|
|
42
|
+
if (story === OP_STORIES.MAIN) {
|
|
43
|
+
const projected = resolved.independentInline === void 0 ? void 0 : projectIndependentMarkup({
|
|
44
|
+
doc: state.doc,
|
|
45
|
+
changes: resolved.independentInline
|
|
46
|
+
});
|
|
47
|
+
if (projected !== void 0) return {
|
|
48
|
+
...projected,
|
|
49
|
+
partial
|
|
50
|
+
};
|
|
51
|
+
const projectedDoc = toProseDoc(resolved.document, converted?.options);
|
|
52
|
+
return {
|
|
53
|
+
doc: authoritative === void 0 ? state.doc.type.create(state.doc.attrs, projectedDoc.content) : projectedDoc,
|
|
54
|
+
partial
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const body = findStoryBody(resolved.document, story);
|
|
58
|
+
if (body === void 0) return {
|
|
59
|
+
doc: state.doc,
|
|
60
|
+
partial: true
|
|
61
|
+
};
|
|
62
|
+
const { styles: storyStyles, theme, numbering: storyNumbering } = resolved.document.package;
|
|
63
|
+
const options = converted?.options ?? storyConversionOptions({
|
|
64
|
+
styles: storyStyles,
|
|
65
|
+
theme,
|
|
66
|
+
numbering: storyNumbering
|
|
67
|
+
});
|
|
68
|
+
return {
|
|
69
|
+
doc: story.kind === "header" || story.kind === "footer" ? headerFooterToProseDoc(body.content, options) : footnoteToProseDoc(body.content, options),
|
|
70
|
+
partial
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
export { canonicalMarkupDocument };
|
|
@@ -19,7 +19,7 @@ export declare const withCanonicalTableAttributeCommand: (command: Command) => C
|
|
|
19
19
|
* command that would change the document has no such description.
|
|
20
20
|
*/
|
|
21
21
|
export declare const withCanonicalSelectionCommand: (command: Command) => Command;
|
|
22
|
-
/** A paragraph
|
|
22
|
+
/** A paragraph in a cell with a slot outside the columns being removed. */
|
|
23
23
|
export declare const tableAnchor: (rect: TableRect, avoid?: {
|
|
24
24
|
left: number;
|
|
25
25
|
right: number;
|
|
@@ -154,7 +154,7 @@ const withCanonicalSelectionCommand = (command) => withCanonicalCommand(command,
|
|
|
154
154
|
}) || transaction === void 0 || transaction.docChanged) return void 0;
|
|
155
155
|
return [{ type: "selection" }];
|
|
156
156
|
});
|
|
157
|
-
/** A paragraph
|
|
157
|
+
/** A paragraph in a cell with a slot outside the columns being removed. */
|
|
158
158
|
const tableAnchor = (rect, avoid = {
|
|
159
159
|
left: 0,
|
|
160
160
|
right: 0
|
|
@@ -166,8 +166,6 @@ const tableAnchor = (rect, avoid = {
|
|
|
166
166
|
if (offset === void 0) continue;
|
|
167
167
|
const cell = table.nodeAt(offset);
|
|
168
168
|
if (cell === null || cell.attrs["_omittedGridSlot"] != null) continue;
|
|
169
|
-
const cellRect = map.findCell(offset);
|
|
170
|
-
if (cellRect.left < avoid.right && cellRect.right > avoid.left) continue;
|
|
171
169
|
const at = firstParagraphPosition(cell, tableStart + offset);
|
|
172
170
|
if (at !== void 0) return at;
|
|
173
171
|
}
|
|
@@ -206,23 +204,23 @@ const insertColumn = (side) => (rect, _state, changed) => {
|
|
|
206
204
|
}
|
|
207
205
|
}];
|
|
208
206
|
};
|
|
209
|
-
/**
|
|
207
|
+
/** One grid change covers the selection, including any spans it narrows. */
|
|
210
208
|
const deleteColumns = (rect) => {
|
|
211
209
|
const at = tableAnchor(rect, {
|
|
212
210
|
left: rect.left,
|
|
213
211
|
right: rect.right
|
|
214
212
|
});
|
|
215
213
|
if (at === void 0) return void 0;
|
|
216
|
-
const
|
|
217
|
-
|
|
214
|
+
const count = rect.right - rect.left;
|
|
215
|
+
return [{
|
|
218
216
|
type: "editTable",
|
|
219
217
|
at,
|
|
220
218
|
edit: {
|
|
221
219
|
type: DOCUMENT_OP_TYPES.DELETE_COLUMN,
|
|
222
|
-
column
|
|
220
|
+
column: rect.left,
|
|
221
|
+
...count > 1 ? { count } : {}
|
|
223
222
|
}
|
|
224
|
-
}
|
|
225
|
-
return intents;
|
|
223
|
+
}];
|
|
226
224
|
};
|
|
227
225
|
const mergeCells = (rect) => {
|
|
228
226
|
const at = tableAnchor(rect);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { document_d_exports } from "../../types/document.js";
|
|
2
|
+
import { ToProseDocOptions } from "./toProseDoc.js";
|
|
3
|
+
import { EditorState } from "prosemirror-state";
|
|
4
|
+
import { Node } from "prosemirror-model";
|
|
5
|
+
import { OpStory } from "@stll/docx-core/ops";
|
|
6
|
+
type MarkupViewSource = {
|
|
7
|
+
document: document_d_exports.Document;
|
|
8
|
+
story?: OpStory;
|
|
9
|
+
options?: ToProseDocOptions;
|
|
10
|
+
};
|
|
11
|
+
/** The model used to convert a story, keyed by the exact PM snapshot. */
|
|
12
|
+
export declare const markupViewSources: WeakMap<Node, MarkupViewSource>;
|
|
13
|
+
/** Two states can share a PM node while publishing different model snapshots. */
|
|
14
|
+
export declare const markupViewStateSources: WeakMap<EditorState, MarkupViewSource>;
|
|
15
|
+
/** Carry the published model through a transaction that preserves the story. */
|
|
16
|
+
export declare const retainMarkupViewSource: (before: EditorState, after: EditorState) => void;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// src/prosemirror/conversion/markupViewSource.ts
|
|
2
|
+
/** The model used to convert a story, keyed by the exact PM snapshot. */
|
|
3
|
+
const markupViewSources = /* @__PURE__ */ new WeakMap();
|
|
4
|
+
/** Two states can share a PM node while publishing different model snapshots. */
|
|
5
|
+
const markupViewStateSources = /* @__PURE__ */ new WeakMap();
|
|
6
|
+
/** Carry the published model through a transaction that preserves the story. */
|
|
7
|
+
const retainMarkupViewSource = (before, after) => {
|
|
8
|
+
const source = markupViewStateSources.get(before) ?? markupViewSources.get(before.doc);
|
|
9
|
+
if (source !== void 0) markupViewStateSources.set(after, source);
|
|
10
|
+
};
|
|
11
|
+
export { markupViewSources, markupViewStateSources, retainMarkupViewSource };
|