@stll/folio-core 0.52.0 → 0.53.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/README.md +23 -0
- package/dist/ai-edits/apply.d.ts +26 -1
- package/dist/ai-edits/apply.js +1519 -105
- package/dist/ai-edits/batch-claims.d.ts +130 -0
- package/dist/ai-edits/batch-claims.js +244 -0
- package/dist/ai-edits/blockRange.js +9 -3
- package/dist/ai-edits/character-boundaries.d.ts +43 -0
- package/dist/ai-edits/character-boundaries.js +95 -0
- package/dist/ai-edits/clean-text.d.ts +33 -3
- package/dist/ai-edits/clean-text.js +52 -6
- package/dist/ai-edits/comment-lifecycle.d.ts +18 -0
- package/dist/ai-edits/comment-lifecycle.js +52 -0
- package/dist/ai-edits/headless.d.ts +71 -7
- package/dist/ai-edits/headless.js +381 -41
- package/dist/ai-edits/index.d.ts +2 -1
- package/dist/ai-edits/index.js +2 -1
- package/dist/ai-edits/minimal-replacement.d.ts +21 -6
- package/dist/ai-edits/minimal-replacement.js +134 -15
- package/dist/ai-edits/newListNumbering.d.ts +23 -0
- package/dist/ai-edits/newListNumbering.js +94 -0
- package/dist/ai-edits/note-references.d.ts +96 -0
- package/dist/ai-edits/note-references.js +139 -0
- package/dist/ai-edits/pending-suggestions.d.ts +79 -0
- package/dist/ai-edits/pending-suggestions.js +306 -0
- package/dist/ai-edits/read.d.ts +1 -1
- package/dist/ai-edits/read.js +56 -43
- package/dist/ai-edits/result-validation.d.ts +29 -0
- package/dist/ai-edits/result-validation.js +164 -0
- package/dist/ai-edits/snapshot.d.ts +36 -3
- package/dist/ai-edits/snapshot.js +177 -23
- package/dist/ai-edits/table-cell-mutations.d.ts +1 -1
- package/dist/ai-edits/table-cell-mutations.js +4 -1
- package/dist/ai-edits/table-geometry.d.ts +1 -1
- package/dist/ai-edits/table-row-column-mutations.d.ts +38 -16
- package/dist/ai-edits/table-row-column-mutations.js +61 -26
- package/dist/ai-edits/types.d.ts +155 -16
- package/dist/compare/compare.d.ts +1 -1
- package/dist/compare/compare.js +65 -16
- package/dist/compare/content-alignment.js +13 -2
- package/dist/compare/content-types.d.ts +7 -0
- package/dist/compare/content.d.ts +4 -1
- package/dist/compare/content.js +6 -1
- package/dist/compare/formatting.js +2 -1
- package/dist/compare/inline-atoms.d.ts +21 -4
- package/dist/compare/inline-atoms.js +138 -16
- package/dist/compare/plan.js +10 -5
- package/dist/compare/scenario.js +14 -3
- package/dist/compare/section-boundary-properties.js +1 -1
- package/dist/compare/types.d.ts +4 -2
- package/dist/compare/types.js +2 -1
- package/dist/compare/verification.d.ts +1 -1
- package/dist/compare/verification.js +15 -3
- package/dist/controller/committedLayoutDiff.d.ts +25 -0
- package/dist/controller/committedLayoutDiff.js +71 -0
- package/dist/controller/contentControlWidgetController.d.ts +1 -1
- package/dist/controller/folioEditor.d.ts +1 -1
- package/dist/controller/fontReadiness.d.ts +70 -3
- package/dist/controller/fontReadiness.js +100 -10
- package/dist/controller/headerFooterEditorManager.js +6 -1
- package/dist/controller/layoutPipeline.d.ts +12 -10
- package/dist/controller/layoutPipeline.js +62 -9
- package/dist/controller/layoutRunOptions.d.ts +24 -0
- package/dist/controller/layoutRunOptions.js +17 -0
- package/dist/controller/layoutScheduler.d.ts +19 -14
- package/dist/controller/layoutScheduler.js +15 -12
- package/dist/controller/layoutSession.d.ts +26 -2
- package/dist/controller/layoutSession.js +1 -1
- package/dist/controller/noteEditorManager.js +8 -3
- package/dist/document-operations.d.ts +11 -2
- package/dist/document-operations.js +230 -21
- package/dist/docx/altChunk.d.ts +8 -0
- package/dist/docx/altChunk.js +17 -0
- package/dist/docx/attributeRemainder.d.ts +1 -1
- package/dist/docx/blockContentParser.d.ts +64 -1
- package/dist/docx/blockContentParser.js +17 -4
- package/dist/docx/blockCustomXmlShell.d.ts +7 -0
- package/dist/docx/blockCustomXmlShell.js +14 -0
- package/dist/docx/blockPlainText.js +7 -0
- package/dist/docx/commentAnchorIndex.js +1 -1
- package/dist/docx/commentRangeIntegrity.js +8 -3
- package/dist/docx/commentReferenceNormalization.js +1 -1
- package/dist/docx/commentReplyMarkers.js +20 -1
- package/dist/docx/compatibility.d.ts +1 -1
- package/dist/docx/compatibility.js +34 -13
- package/dist/docx/containerChildren.gen.d.ts +1 -1
- package/dist/docx/containerChildren.gen.js +1 -0
- package/dist/docx/documentParser.js +12 -12
- package/dist/docx/drawingIdNormalization.d.ts +3 -1
- package/dist/docx/drawingIdNormalization.js +6 -1
- package/dist/docx/ensureParaIds.js +119 -97
- package/dist/docx/footnoteParser.js +8 -4
- package/dist/docx/headerFooterParser.js +3 -3
- package/dist/docx/headerFooterReferenceNormalization.d.ts +20 -1
- package/dist/docx/headerFooterReferenceNormalization.js +52 -27
- package/dist/docx/hyperlinkParser.d.ts +1 -1
- package/dist/docx/index.d.ts +1 -1
- package/dist/docx/listNumberingInstances.d.ts +59 -0
- package/dist/docx/listNumberingInstances.js +249 -0
- package/dist/docx/normalizeBaseDirection.js +2 -1
- package/dist/docx/opaqueCarrier.d.ts +7 -0
- package/dist/docx/opaqueCarrier.js +38 -0
- package/dist/docx/packageParts.js +4 -1
- package/dist/docx/paragraphParser.js +91 -24
- package/dist/docx/paragraphPropertySource.d.ts +4 -2
- package/dist/docx/paragraphPropertySource.js +7 -1
- package/dist/docx/paragraphTraversal.js +1 -0
- package/dist/docx/parseWarningMessage.js +4 -1
- package/dist/docx/parser.js +173 -20
- package/dist/docx/rezip.js +27 -5
- package/dist/docx/sdtProperties.js +1 -1
- package/dist/docx/sdtPropertiesPatch.js +3 -0
- package/dist/docx/selectiveSave.js +16 -9
- package/dist/docx/selectiveXmlPatch.js +106 -37
- package/dist/docx/serializer/blockCustomXmlSerializer.d.ts +5 -0
- package/dist/docx/serializer/blockCustomXmlSerializer.js +4 -0
- package/dist/docx/serializer/documentSerializer.js +2 -0
- package/dist/docx/serializer/headerFooterSerializer.js +2 -0
- package/dist/docx/serializer/noteSerializer.js +3 -1
- package/dist/docx/serializer/paragraphSerializer.js +33 -9
- package/dist/docx/serializer/tableSerializer.js +25 -38
- package/dist/docx/server/createBilingualDocument.js +3 -3
- package/dist/docx/tableParser.d.ts +157 -1
- package/dist/docx/tableParser.js +89 -10
- package/dist/docx/textBoxParser.js +1 -1
- package/dist/docx/unzip.d.ts +2 -1
- package/dist/docx/unzip.js +1 -1
- package/dist/docx/wordprocessingPrefixes.d.ts +78 -0
- package/dist/docx/wordprocessingPrefixes.js +286 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +136 -0
- package/dist/i18n/messages/catalogs.gen.js +153 -17
- package/dist/i18n/messages/messages.gen.d.ts +8 -0
- package/dist/internal/compare/inline-presentation.d.ts +2 -1
- package/dist/internal/compare/inline-presentation.js +11 -10
- package/dist/internal/headlessRevisionResolutionGuard.d.ts +2 -8
- package/dist/internal/headlessRevisionResolutionGuard.js +2 -11
- package/dist/internal/indexedPositionMap.d.ts +11 -0
- package/dist/internal/indexedPositionMap.js +42 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +2 -1
- package/dist/internal/revisionResolutionEdits.d.ts +13 -0
- package/dist/internal/revisionResolutionEdits.js +19 -0
- package/dist/internal/revisionResolutionInline.d.ts +24 -0
- package/dist/internal/{headlessRevisionResolution.js → revisionResolutionInline.js} +61 -43
- package/dist/internal/revisionResolutionStep.d.ts +34 -0
- package/dist/internal/revisionResolutionStep.js +282 -0
- package/dist/internal/revisionResolutionTracking.d.ts +11 -0
- package/dist/internal/revisionResolutionTracking.js +124 -0
- package/dist/internal/wholeStoryRevisionResolution.d.ts +56 -0
- package/dist/internal/wholeStoryRevisionResolution.js +530 -0
- package/dist/layout-bridge/convert/markupViewFlow.d.ts +20 -0
- package/dist/layout-bridge/convert/markupViewFlow.js +123 -0
- package/dist/layout-bridge/convert/tableConversion.js +1 -1
- package/dist/layout-bridge/convert/toFlowBlocks.js +10 -1
- package/dist/layout-engine/layoutInstrumentation.d.ts +9 -1
- package/dist/layout-engine/layoutInstrumentation.js +4 -1
- package/dist/layout-engine/measure/cache.d.ts +18 -1
- package/dist/layout-engine/measure/cache.js +31 -1
- package/dist/layout-engine/measure/font-metrics.worker.js +3 -7
- package/dist/layout-engine/measure/measureContainer.js +7 -47
- package/dist/layout-engine/measure/measureHelpers.d.ts +6 -1
- package/dist/layout-engine/measure/measureHelpers.js +22 -2
- package/dist/layout-engine/measure/measureWorker.js +2 -3
- package/dist/layout-engine/measure/measureWorkerProtocol.d.ts +6 -7
- package/dist/layout-engine/measure/measureWorkerProtocol.js +1 -2
- package/dist/layout-engine/types.d.ts +6 -0
- package/dist/layout-painter/renderPage.js +1 -0
- package/dist/layout-painter/renderParagraph.js +1 -1
- package/dist/managers/ContextMenuManager.js +5 -2
- package/dist/managers/types.d.ts +3 -0
- package/dist/markdown/fromMarkdown.js +2 -1
- package/dist/markdown/internals.d.ts +11 -1
- package/dist/markdown/internals.js +24 -3
- package/dist/markdown/renderBlock.js +39 -9
- package/dist/markdown/renderParagraph.d.ts +13 -1
- package/dist/markdown/renderParagraph.js +85 -38
- package/dist/markdown/renderRuns.js +3 -10
- package/dist/markdown/renderTable.js +24 -12
- package/dist/markdown/trailers.js +2 -2
- package/dist/markdown/types.d.ts +29 -7
- package/dist/paged-layout/incrementalMeasure.d.ts +1 -2
- package/dist/paged-layout/incrementalMeasure.js +1 -9
- package/dist/paged-layout/transactionDirtyRange.d.ts +1 -3
- package/dist/paged-layout/transactionDirtyRange.js +29 -41
- package/dist/panel-layout.d.ts +83 -0
- package/dist/panel-layout.js +96 -0
- package/dist/prosemirror/anchoredTextBoxes.d.ts +37 -0
- package/dist/prosemirror/anchoredTextBoxes.js +156 -0
- package/dist/prosemirror/attrs/index.d.ts +6 -2
- package/dist/prosemirror/attrs/index.js +172 -1
- package/dist/prosemirror/commands/comments.d.ts +7 -8
- package/dist/prosemirror/commands/comments.js +241 -207
- package/dist/prosemirror/commands/contentControls.d.ts +1 -1
- package/dist/prosemirror/commands/formatPainter.d.ts +1 -1
- package/dist/prosemirror/commands/formatting.d.ts +1 -1
- package/dist/prosemirror/commands/index.d.ts +2 -2
- package/dist/prosemirror/commands/index.js +2 -2
- package/dist/prosemirror/commands/paragraph.d.ts +7 -1
- package/dist/prosemirror/commands/paragraph.js +9 -1
- package/dist/prosemirror/commands/paragraphBookmarkJoin.d.ts +13 -0
- package/dist/prosemirror/commands/paragraphBookmarkJoin.js +22 -0
- package/dist/prosemirror/commands/pastePlainText.d.ts +1 -1
- package/dist/prosemirror/commands/resolveAllTableChanges.d.ts +40 -0
- package/dist/prosemirror/commands/resolveAllTableChanges.js +615 -0
- package/dist/prosemirror/commands/resolveNodePropertyChangeAttrs.d.ts +15 -0
- package/dist/prosemirror/commands/resolveNodePropertyChangeAttrs.js +46 -0
- package/dist/prosemirror/commands/resolveParagraphProperties.d.ts +16 -0
- package/dist/prosemirror/commands/resolveParagraphProperties.js +59 -0
- package/dist/prosemirror/commands/sectionBreak.js +2 -1
- package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +8 -2
- package/dist/prosemirror/commands/tableCellMergeResolution.js +1 -1
- package/dist/prosemirror/contentControlRevisions.d.ts +1 -1
- package/dist/prosemirror/conversion/fromProseDoc.js +181 -31
- package/dist/prosemirror/conversion/toProseDoc.js +39 -4
- package/dist/prosemirror/emptyFieldResultRuns.d.ts +18 -0
- package/dist/prosemirror/emptyFieldResultRuns.js +33 -0
- package/dist/prosemirror/extensions/ExtensionManager.d.ts +1 -1
- package/dist/prosemirror/extensions/ExtensionManager.js +3 -1
- package/dist/prosemirror/extensions/StarterKit.js +3 -1
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +12 -0
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +3 -0
- package/dist/prosemirror/extensions/features/ListExtension.js +161 -123
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +19 -2
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +33 -20
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +31 -2
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +270 -99
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +3 -2
- package/dist/prosemirror/extensions/features/pasteCleanup.js +2 -1
- package/dist/prosemirror/extensions/features/pastedHtmlLists.d.ts +12 -0
- package/dist/prosemirror/extensions/features/pastedHtmlLists.js +126 -0
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +21 -5
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.d.ts +21 -18
- package/dist/prosemirror/extensions/marks/RunIdentityExtension.js +37 -17
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +7 -2
- package/dist/prosemirror/extensions/marks/markUtils.js +8 -2
- package/dist/prosemirror/extensions/marks/noteReferenceDeletion.d.ts +10 -0
- package/dist/prosemirror/extensions/marks/noteReferenceDeletion.js +35 -0
- package/dist/prosemirror/extensions/nodes/BlockCustomXmlExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/nodes/BlockCustomXmlExtension.js +52 -0
- package/dist/prosemirror/extensions/nodes/FieldExtension.d.ts +3 -3
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +50 -15
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.js +4 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.js +19 -18
- package/dist/prosemirror/extensions/types.d.ts +4 -1
- package/dist/prosemirror/findReplaceSelection.js +1 -1
- package/dist/prosemirror/index.d.ts +3 -2
- package/dist/prosemirror/index.js +3 -2
- package/dist/prosemirror/indexedNodeLookup.d.ts +17 -0
- package/dist/prosemirror/indexedNodeLookup.js +103 -0
- package/dist/prosemirror/listAutoformatMarkers.d.ts +19 -0
- package/dist/prosemirror/listAutoformatMarkers.js +98 -0
- package/dist/prosemirror/listInstanceReferences.d.ts +12 -0
- package/dist/prosemirror/listInstanceReferences.js +72 -0
- package/dist/prosemirror/listLabels.d.ts +24 -0
- package/dist/prosemirror/listLabels.js +111 -0
- package/dist/prosemirror/listNumbering.d.ts +110 -0
- package/dist/prosemirror/listNumbering.js +345 -0
- package/dist/prosemirror/listRenderingAttrs.d.ts +11 -2
- package/dist/prosemirror/listRenderingAttrs.js +8 -1
- package/dist/prosemirror/markupViewProjection.d.ts +95 -0
- package/dist/prosemirror/markupViewProjection.js +83 -0
- package/dist/prosemirror/numberingAttr.d.ts +9 -1
- package/dist/prosemirror/numberingAttr.js +9 -1
- package/dist/prosemirror/outlineLevelAttr.js +1 -1
- package/dist/prosemirror/paragraphIndentation.d.ts +10 -1
- package/dist/prosemirror/paragraphIndentation.js +29 -7
- package/dist/prosemirror/paragraphMarkJoin.d.ts +19 -0
- package/dist/prosemirror/paragraphMarkJoin.js +24 -0
- package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +1 -1
- package/dist/prosemirror/plugins/documentNumbering.d.ts +27 -1
- package/dist/prosemirror/plugins/documentNumbering.js +97 -11
- package/dist/prosemirror/plugins/documentStyles.d.ts +10 -1
- package/dist/prosemirror/plugins/documentStyles.js +14 -1
- package/dist/prosemirror/plugins/suggestionMode.d.ts +16 -2
- package/dist/prosemirror/plugins/suggestionMode.js +116 -52
- package/dist/prosemirror/plugins/templateDirectives.d.ts +1 -1
- package/dist/prosemirror/plugins/transactionInvariants.d.ts +32 -0
- package/dist/prosemirror/plugins/transactionInvariants.js +86 -0
- package/dist/prosemirror/positionSweep.d.ts +24 -0
- package/dist/prosemirror/positionSweep.js +222 -0
- package/dist/prosemirror/rebaseParagraphRunFormatting.d.ts +1 -1
- package/dist/prosemirror/rejoinRunCarriers.d.ts +1 -1
- package/dist/prosemirror/replacedAnnotations.d.ts +33 -1
- package/dist/prosemirror/replacedAnnotations.js +170 -1
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +1 -1
- package/dist/prosemirror/schema/index.d.ts +2 -2
- package/dist/prosemirror/schema/index.js +3 -0
- package/dist/prosemirror/schema/nodes.d.ts +42 -11
- package/dist/prosemirror/sectionMarkEdits.d.ts +20 -0
- package/dist/prosemirror/sectionMarkEdits.js +59 -0
- package/dist/prosemirror/storyListNumbering.d.ts +17 -0
- package/dist/prosemirror/storyListNumbering.js +102 -0
- package/dist/prosemirror/tableGridMutation.d.ts +48 -2
- package/dist/prosemirror/tableGridMutation.js +106 -1
- package/dist/prosemirror/validation.js +5 -1
- package/dist/redline.js +93 -9
- package/dist/render-dom/BodySelectionOverlay.d.ts +4 -1
- package/dist/render-dom/BodySelectionOverlay.js +3 -2
- package/dist/utils/findReplace.js +2 -2
- package/dist/utils/mergeDocumentContent.js +1 -1
- package/dist/utils/noteReferenceLabels.d.ts +36 -0
- package/dist/utils/noteReferenceLabels.js +32 -0
- package/dist/utils/replaceText.js +1 -1
- package/dist/version-comparison.d.ts +1 -0
- package/dist/version-comparison.js +1 -0
- package/package.json +3 -2
- package/dist/internal/headlessRevisionResolution.d.ts +0 -23
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RunStyleResolver } from "../runStyleFormatting.js";
|
|
2
|
+
import { NumberingMap } from "../../docx/numberingParser.js";
|
|
3
|
+
import { Node } from "prosemirror-model";
|
|
4
|
+
//#region src/prosemirror/commands/resolveParagraphProperties.d.ts
|
|
5
|
+
type ResolveParagraphPropertiesOptions = {
|
|
6
|
+
node: Node;
|
|
7
|
+
boundaryCovered: boolean;
|
|
8
|
+
mode: "accept" | "reject";
|
|
9
|
+
revisionSet: ReadonlySet<number> | null;
|
|
10
|
+
styleResolver: RunStyleResolver | null;
|
|
11
|
+
numbering: NumberingMap | null;
|
|
12
|
+
};
|
|
13
|
+
/** Resolve paragraph and section property records before resolving their inline content. */
|
|
14
|
+
declare const resolveParagraphChangeAttrs: ({ node, boundaryCovered, mode, revisionSet, styleResolver, numbering }: ResolveParagraphPropertiesOptions) => Record<string, unknown> | null;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { resolveParagraphChangeAttrs };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { expectParagraphAttrs } from "../attrs/index.js";
|
|
2
|
+
import { resolveParagraphDefaultTextFormatting } from "../conversion/toProseDoc.js";
|
|
3
|
+
import { rejectedListRenderingPatch } from "../listNumbering.js";
|
|
4
|
+
import { paragraphRejectAttrPatch, paragraphRejectOriginalFormatting, removeParagraphPropertyChanges, sectionRejectProperties } from "./propertyChangeScope.js";
|
|
5
|
+
//#region src/prosemirror/commands/resolveParagraphProperties.ts
|
|
6
|
+
/** Resolve paragraph and section property records before resolving their inline content. */
|
|
7
|
+
const resolveParagraphChangeAttrs = ({ node, boundaryCovered, mode, revisionSet, styleResolver, numbering }) => {
|
|
8
|
+
let nextAttrs = null;
|
|
9
|
+
const propertyChanges = expectParagraphAttrs(node)._propertyChanges;
|
|
10
|
+
if (Array.isArray(propertyChanges) && propertyChanges.length > 0 && boundaryCovered) {
|
|
11
|
+
const matchesPropertyChange = (change) => revisionSet === null || revisionSet.has(change.info.id);
|
|
12
|
+
if (propertyChanges.some(matchesPropertyChange)) {
|
|
13
|
+
const rejection = mode === "reject" ? removeParagraphPropertyChanges(propertyChanges, matchesPropertyChange) : null;
|
|
14
|
+
let remaining;
|
|
15
|
+
if (rejection === null) remaining = propertyChanges.filter((change) => !matchesPropertyChange(change));
|
|
16
|
+
else if (rejection.type === "unchanged") remaining = propertyChanges;
|
|
17
|
+
else remaining = rejection.remaining;
|
|
18
|
+
nextAttrs = {
|
|
19
|
+
...node.attrs,
|
|
20
|
+
_propertyChanges: remaining.length > 0 ? remaining : null
|
|
21
|
+
};
|
|
22
|
+
if (rejection?.type === "restore-previous") {
|
|
23
|
+
const inheritedAlignment = expectParagraphAttrs(node).alignmentFromStyle;
|
|
24
|
+
let previousFormattingFromStyle;
|
|
25
|
+
if (styleResolver) previousFormattingFromStyle = styleResolver.resolveParagraphStyle(rejection.previousFormatting?.styleId).paragraphFormatting;
|
|
26
|
+
else if (inheritedAlignment !== void 0) previousFormattingFromStyle = { alignment: inheritedAlignment };
|
|
27
|
+
Object.assign(nextAttrs, paragraphRejectAttrPatch(rejection.previousFormatting, previousFormattingFromStyle), rejectedListRenderingPatch({
|
|
28
|
+
current: expectParagraphAttrs(node),
|
|
29
|
+
previousFormatting: rejection.previousFormatting,
|
|
30
|
+
numbering
|
|
31
|
+
}));
|
|
32
|
+
const restoredFormatting = paragraphRejectOriginalFormatting(rejection.previousFormatting, node.attrs["_originalFormatting"]);
|
|
33
|
+
nextAttrs["_originalFormatting"] = restoredFormatting;
|
|
34
|
+
if (styleResolver) nextAttrs["defaultTextFormatting"] = resolveParagraphDefaultTextFormatting(rejection.previousFormatting?.styleId, restoredFormatting ?? void 0, styleResolver) ?? null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const sectionProperties = expectParagraphAttrs(node)._sectionProperties;
|
|
39
|
+
const sectionChanges = sectionProperties?.propertyChanges;
|
|
40
|
+
if (sectionProperties && Array.isArray(sectionChanges) && sectionChanges.length > 0 && boundaryCovered) {
|
|
41
|
+
const matches = sectionChanges.filter((c) => revisionSet === null || c.info && revisionSet.has(c.info.id));
|
|
42
|
+
if (matches.length > 0) {
|
|
43
|
+
const remaining = sectionChanges.filter((c) => revisionSet !== null && (!c.info || !revisionSet.has(c.info.id)));
|
|
44
|
+
let restored = { ...sectionProperties };
|
|
45
|
+
if (mode === "reject") for (const change of matches.toReversed()) restored = sectionRejectProperties({
|
|
46
|
+
live: restored,
|
|
47
|
+
previousProperties: change.previousProperties,
|
|
48
|
+
previousReferences: change.previousReferences
|
|
49
|
+
});
|
|
50
|
+
delete restored.propertyChanges;
|
|
51
|
+
if (remaining.length > 0) restored.propertyChanges = remaining;
|
|
52
|
+
nextAttrs = nextAttrs ?? { ...node.attrs };
|
|
53
|
+
nextAttrs["_sectionProperties"] = restored;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return nextAttrs;
|
|
57
|
+
};
|
|
58
|
+
//#endregion
|
|
59
|
+
export { resolveParagraphChangeAttrs };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { markSectionBreakRemoval } from "../extensions/features/ParagraphChangeTrackerExtension.js";
|
|
1
2
|
import { mintSectionProperties, sectionPropertiesOf } from "../sectionCarrier.js";
|
|
2
3
|
import { TextSelection } from "prosemirror-state";
|
|
3
4
|
//#region src/prosemirror/commands/sectionBreak.ts
|
|
@@ -150,7 +151,7 @@ const rewriteSelectedSectionRecords = (rewrite) => (state, dispatch) => {
|
|
|
150
151
|
const paragraph = transaction.doc.nodeAt(position);
|
|
151
152
|
if (paragraph) transaction.setNodeMarkup(position, void 0, withSectionProperties(paragraph.attrs, properties));
|
|
152
153
|
}
|
|
153
|
-
dispatch(transaction.scrollIntoView());
|
|
154
|
+
dispatch(markSectionBreakRemoval(transaction, state.doc).scrollIntoView());
|
|
154
155
|
}
|
|
155
156
|
return true;
|
|
156
157
|
};
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { document_d_exports } from "../../types/document.js";
|
|
2
|
+
import { DecodedTableCellParagraphSourcePayload } from "../../docx/paragraphPropertySource.js";
|
|
2
3
|
import { Node } from "prosemirror-model";
|
|
4
|
+
import { Transaction } from "prosemirror-state";
|
|
3
5
|
//#region src/prosemirror/commands/tableCellMergeResolution.d.ts
|
|
6
|
+
declare const tableCellContinuationPayload: (node: Node) => DecodedTableCellParagraphSourcePayload | null;
|
|
4
7
|
declare const hasMatchingCollapsedTableCellMerge: (node: Node, revisionSet: Set<number> | null) => boolean;
|
|
5
8
|
declare const resolveVisibleTableCellMerge: (tr: Transaction, cellPos: number, mode: "accept" | "reject") => boolean;
|
|
9
|
+
declare const tableCellContinuationCells: (cell: Node, rowspan: number) => document_d_exports.TableCell[];
|
|
10
|
+
declare const tableCellContinuationFromNode: (cell: Node) => document_d_exports.TableCell;
|
|
6
11
|
declare const resolveCollapsedTableCellMerge: (tr: Transaction, cellPos: number, mode: "accept" | "reject", revisionSet: Set<number> | null) => boolean;
|
|
12
|
+
declare const createRestoredTableCell: (origin: Node, source: document_d_exports.TableCell) => Node | null;
|
|
7
13
|
//#endregion
|
|
8
|
-
export { hasMatchingCollapsedTableCellMerge, resolveCollapsedTableCellMerge, resolveVisibleTableCellMerge };
|
|
14
|
+
export { createRestoredTableCell, hasMatchingCollapsedTableCellMerge, resolveCollapsedTableCellMerge, resolveVisibleTableCellMerge, tableCellContinuationCells, tableCellContinuationFromNode, tableCellContinuationPayload };
|
|
@@ -185,4 +185,4 @@ const createRestoredTableCell = (origin, source) => {
|
|
|
185
185
|
return Result.try(() => origin.type.schema.nodeFromJSON(restored.toJSON())).unwrapOr(null);
|
|
186
186
|
};
|
|
187
187
|
//#endregion
|
|
188
|
-
export { hasMatchingCollapsedTableCellMerge, resolveCollapsedTableCellMerge, resolveVisibleTableCellMerge };
|
|
188
|
+
export { createRestoredTableCell, hasMatchingCollapsedTableCellMerge, resolveCollapsedTableCellMerge, resolveVisibleTableCellMerge, tableCellContinuationCells, tableCellContinuationFromNode, tableCellContinuationPayload };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Transaction } from "prosemirror-state";
|
|
2
1
|
import { MarkType, Node } from "prosemirror-model";
|
|
2
|
+
import { Transaction } from "prosemirror-state";
|
|
3
3
|
//#region src/prosemirror/contentControlRevisions.d.ts
|
|
4
4
|
declare const ENCLOSING_REVISION_IDS_ATTR = "_docxEnclosingRevisionIds";
|
|
5
5
|
/** The revisions whose element encloses `control`. */
|
|
@@ -17,7 +17,7 @@ import { normalizeHorizontalScalePercent } from "../../utils/horizontalScale.js"
|
|
|
17
17
|
import { mergeTextFormatting } from "../../utils/textFormattingMerge.js";
|
|
18
18
|
import { emuToPixels, emuToStrokePixels, pixelsToEmu } from "../../utils/units.js";
|
|
19
19
|
import { unchangedAlternateContentXml } from "../alternateContentAttrs.js";
|
|
20
|
-
import { expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectInlineWrapperMarkAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectPageBreakRunAttrs, expectParagraphAttrs, expectPreservedBlockAttrs, expectPreservedXmlAttrs, expectRunFormattingOverrideMarkAttrs, expectRunIdentityMarkAttrs, expectRunPropertyChangeMarkAttrs, expectRunShadingMarkAttrs, expectSdtAttrs, expectShapeAttrs, expectStrikeMarkAttrs, expectSymbolAttrs, expectTabAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs } from "../attrs/index.js";
|
|
20
|
+
import { expectBlockCustomXmlAttrs, expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectInlineWrapperMarkAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectPageBreakRunAttrs, expectParagraphAttrs, expectPreservedBlockAttrs, expectPreservedXmlAttrs, expectRunFormattingOverrideMarkAttrs, expectRunIdentityMarkAttrs, expectRunPropertyChangeMarkAttrs, expectRunShadingMarkAttrs, expectSdtAttrs, expectShapeAttrs, expectStrikeMarkAttrs, expectSymbolAttrs, expectTabAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs } from "../attrs/index.js";
|
|
21
21
|
import { readAuthoredTransform } from "../authoredTransformAttrs.js";
|
|
22
22
|
import { autospacingMatchesBase, hasAutospacingBaseSide } from "../autospacingBase.js";
|
|
23
23
|
import { bookmarkMarkerFromAttrs, expectBookmarkBoundaryAttrs } from "../bookmarkBoundaryAttrs.js";
|
|
@@ -30,7 +30,8 @@ import { textFormattingToMarks } from "../extensions/marks/markUtils.js";
|
|
|
30
30
|
import "../extensions/nodes/MoveRangeBoundaryExtension.js";
|
|
31
31
|
import "../extensions/nodes/RangeAnchorExtension.js";
|
|
32
32
|
import { inlineWrapperMember, inlineWrapperStackKey } from "../inlineWrapperStack.js";
|
|
33
|
-
import {
|
|
33
|
+
import { completeNumberingForDoc } from "../listInstanceReferences.js";
|
|
34
|
+
import { hasListRendering, listRenderingFromAttrs as listRenderingFromAttrs$1 } from "../listRenderingAttrs.js";
|
|
34
35
|
import { expectMoveRangeBoundaryAttrs } from "../moveRangeBoundaryAttrs.js";
|
|
35
36
|
import { resolveNumberedRefFields } from "../numberedRefFields.js";
|
|
36
37
|
import { directParagraphAlignment } from "../paragraphAlignment.js";
|
|
@@ -280,18 +281,23 @@ function fromProseDoc(pmDoc, baseDocument, { reuse = "none" } = {}) {
|
|
|
280
281
|
if (baseDocument?.package.document.finalSectionProperties) documentBody.finalSectionProperties = baseDocument.package.document.finalSectionProperties;
|
|
281
282
|
if (baseDocument?.package.document.sections) documentBody.sections = baseDocument.package.document.sections;
|
|
282
283
|
if (baseDocument?.package.document.comments) documentBody.comments = baseDocument.package.document.comments;
|
|
284
|
+
const numbering = completeNumberingForDoc(baseDocument?.package.numbering, pmDoc);
|
|
283
285
|
if (baseDocument) {
|
|
284
286
|
const updatedDocument = {
|
|
285
287
|
...baseDocument,
|
|
286
288
|
package: {
|
|
287
289
|
...baseDocument.package,
|
|
288
|
-
document: documentBody
|
|
290
|
+
document: documentBody,
|
|
291
|
+
...numbering ? { numbering } : {}
|
|
289
292
|
}
|
|
290
293
|
};
|
|
291
294
|
copyDocumentParagraphPropertySourceContract(updatedDocument, baseDocument);
|
|
292
295
|
return updatedDocument;
|
|
293
296
|
}
|
|
294
|
-
return { package: {
|
|
297
|
+
return { package: {
|
|
298
|
+
document: documentBody,
|
|
299
|
+
...numbering ? { numbering } : {}
|
|
300
|
+
} };
|
|
295
301
|
}
|
|
296
302
|
const isSuggestedMark = (mark) => mark.attrs["provenance"] === "suggested";
|
|
297
303
|
const hasSuggestedInsertion = (marks) => marks.some((mark) => mark.type.name === "insertion" && isSuggestedMark(mark));
|
|
@@ -341,12 +347,30 @@ function stripSuggestedInlineMarks(marks, { baseParagraphFormatting, inheritedFo
|
|
|
341
347
|
}
|
|
342
348
|
return next;
|
|
343
349
|
}
|
|
350
|
+
/** A paragraph's attrs without its suggested property changes, or `null` when it has none. */
|
|
351
|
+
function stripSuggestedParagraphPropertyChanges(node) {
|
|
352
|
+
const propertyChanges = expectParagraphAttrs(node)._propertyChanges;
|
|
353
|
+
if (!Array.isArray(propertyChanges)) return null;
|
|
354
|
+
if (!propertyChanges.some(({ info }) => info.provenance === "suggested")) return null;
|
|
355
|
+
const removal = removeParagraphPropertyChanges(propertyChanges, ({ info }) => info.provenance === "suggested");
|
|
356
|
+
if (removal.type === "unchanged") return null;
|
|
357
|
+
const nextAttrs = {
|
|
358
|
+
...node.attrs,
|
|
359
|
+
_propertyChanges: removal.remaining.length > 0 ? removal.remaining : null
|
|
360
|
+
};
|
|
361
|
+
if (removal.type === "restore-previous") {
|
|
362
|
+
Object.assign(nextAttrs, paragraphRejectAttrPatch(removal.previousFormatting));
|
|
363
|
+
nextAttrs["_originalFormatting"] = paragraphRejectOriginalFormatting(removal.previousFormatting, nextAttrs["_originalFormatting"]);
|
|
364
|
+
}
|
|
365
|
+
return nextAttrs;
|
|
366
|
+
}
|
|
344
367
|
/**
|
|
345
368
|
* Compute the node attrs a block/structural node keeps once its suggested
|
|
346
369
|
* revision markers are neutralized. Returns `null` when nothing changes.
|
|
347
370
|
*
|
|
348
|
-
* - a suggested `trDel` / `cellMarker` (insertion or deletion)
|
|
349
|
-
* the
|
|
371
|
+
* - a suggested `trDel` / `cellMarker` (insertion or deletion) or paragraph
|
|
372
|
+
* mark revision (`pPrMark`) is cleared so the node serializes as though the
|
|
373
|
+
* proposed change never happened;
|
|
350
374
|
* merge markers never carry suggestion provenance (structurally excluded);
|
|
351
375
|
* - suggested INSERT markers are handled by the caller, which drops the whole
|
|
352
376
|
* node instead of clearing an attr.
|
|
@@ -356,20 +380,13 @@ function stripSuggestedInlineMarks(marks, { baseParagraphFormatting, inheritedFo
|
|
|
356
380
|
function stripSuggestedNodeAttrs(node) {
|
|
357
381
|
const name = node.type.name;
|
|
358
382
|
if (name === "paragraph") {
|
|
359
|
-
const
|
|
360
|
-
|
|
361
|
-
if (!
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
...node.attrs,
|
|
366
|
-
_propertyChanges: removal.remaining.length > 0 ? removal.remaining : null
|
|
383
|
+
const stripped = stripSuggestedParagraphPropertyChanges(node);
|
|
384
|
+
const markInfo = expectParagraphAttrs(node).pPrMark?.info;
|
|
385
|
+
if (!(typeof markInfo === "object" && markInfo !== null && "provenance" in markInfo && markInfo.provenance === "suggested")) return stripped;
|
|
386
|
+
return {
|
|
387
|
+
...stripped ?? node.attrs,
|
|
388
|
+
pPrMark: null
|
|
367
389
|
};
|
|
368
|
-
if (removal.type === "restore-previous") {
|
|
369
|
-
Object.assign(nextAttrs, paragraphRejectAttrPatch(removal.previousFormatting));
|
|
370
|
-
nextAttrs["_originalFormatting"] = paragraphRejectOriginalFormatting(removal.previousFormatting, nextAttrs["_originalFormatting"]);
|
|
371
|
-
}
|
|
372
|
-
return nextAttrs;
|
|
373
390
|
}
|
|
374
391
|
if (name === "tableRow") {
|
|
375
392
|
const rowAttrs = expectTableRowAttrs(node);
|
|
@@ -536,10 +553,15 @@ function extractBlocks(inputDoc, refResolution = "resolve", styleResolver = null
|
|
|
536
553
|
if (pendingPageBreaks > 0 && !appendPendingPageBreaksToPreviousParagraph()) flushPendingPageBreaks();
|
|
537
554
|
blocks.push(convertPMBlockSdt(node, styleResolver));
|
|
538
555
|
previousStandaloneTextBox = null;
|
|
556
|
+
} else if (node.type.name === "blockCustomXml") {
|
|
557
|
+
blocks.push(convertPMBlockCustomXml(node, styleResolver));
|
|
558
|
+
previousStandaloneTextBox = null;
|
|
539
559
|
} else if (node.type.name === "preservedBlock") {
|
|
560
|
+
const { xml, readerText } = expectPreservedBlockAttrs(node);
|
|
540
561
|
blocks.push({
|
|
541
562
|
type: "preservedBlock",
|
|
542
|
-
xml
|
|
563
|
+
xml,
|
|
564
|
+
...readerText === void 0 ? {} : { readerText }
|
|
543
565
|
});
|
|
544
566
|
previousStandaloneTextBox = null;
|
|
545
567
|
} else if (node.type.name === "blockBookmarkBoundary") {
|
|
@@ -669,6 +691,16 @@ function convertPMBlockSdt(node, styleResolver) {
|
|
|
669
691
|
content: attrs._originallyEmpty === true && isStillSyntheticFiller(extracted) ? [] : extracted
|
|
670
692
|
};
|
|
671
693
|
}
|
|
694
|
+
function convertPMBlockCustomXml(node, styleResolver) {
|
|
695
|
+
const { openingXml, closingXml, _originallyEmpty } = expectBlockCustomXmlAttrs(node);
|
|
696
|
+
const extracted = extractBlocks(node.type.schema.node("doc", null, node.content), "inherit", styleResolver);
|
|
697
|
+
return {
|
|
698
|
+
type: "blockCustomXml",
|
|
699
|
+
openingXml,
|
|
700
|
+
closingXml,
|
|
701
|
+
content: _originallyEmpty === true && isStillSyntheticFiller(extracted) ? [] : extracted
|
|
702
|
+
};
|
|
703
|
+
}
|
|
672
704
|
function isStillSyntheticFiller(blocks) {
|
|
673
705
|
if (blocks.length !== 1) return false;
|
|
674
706
|
const block = blocks[0];
|
|
@@ -776,7 +808,7 @@ function replaceTextBoxAnchorInBlocks(blocks, marker, textBoxRun) {
|
|
|
776
808
|
for (const row of block.rows) for (const cell of row.cells) if (replaceTextBoxAnchorInBlocks(cell.content, marker, textBoxRun)) return true;
|
|
777
809
|
continue;
|
|
778
810
|
}
|
|
779
|
-
if (block.type !== "blockSdt") continue;
|
|
811
|
+
if (block.type !== "blockSdt" && block.type !== "blockCustomXml") continue;
|
|
780
812
|
if (replaceTextBoxAnchorInBlocks(block.content, marker, textBoxRun)) return true;
|
|
781
813
|
}
|
|
782
814
|
return false;
|
|
@@ -845,7 +877,7 @@ function removeTextBoxAnchorFromBlocks(blocks, marker) {
|
|
|
845
877
|
for (const row of block.rows) for (const cell of row.cells) if (removeTextBoxAnchorFromBlocks(cell.content, marker)) return true;
|
|
846
878
|
continue;
|
|
847
879
|
}
|
|
848
|
-
if (block.type !== "blockSdt") continue;
|
|
880
|
+
if (block.type !== "blockSdt" && block.type !== "blockCustomXml") continue;
|
|
849
881
|
if (removeTextBoxAnchorFromBlocks(block.content, marker)) return true;
|
|
850
882
|
}
|
|
851
883
|
return false;
|
|
@@ -859,7 +891,7 @@ function removeTextBoxAnchorFromBlocks(blocks, marker) {
|
|
|
859
891
|
function listRenderingFromAttrs(attrs) {
|
|
860
892
|
const numId = paragraphNumberingReferenceId$1(attrs.numPr);
|
|
861
893
|
if (numId === void 0) return;
|
|
862
|
-
if (!(attrs
|
|
894
|
+
if (!hasListRendering(attrs)) return;
|
|
863
895
|
return listRenderingFromAttrs$1({
|
|
864
896
|
attrs,
|
|
865
897
|
numId
|
|
@@ -989,6 +1021,35 @@ function assignBooleanToggle(result, attrs, orig, key) {
|
|
|
989
1021
|
if (value === void 0) Reflect.deleteProperty(result, key);
|
|
990
1022
|
else result[key] = value;
|
|
991
1023
|
}
|
|
1024
|
+
const PARAGRAPH_INDENTATION_VALUE_FIELDS = [
|
|
1025
|
+
"indentLeft",
|
|
1026
|
+
"indentRight",
|
|
1027
|
+
"indentFirstLine"
|
|
1028
|
+
];
|
|
1029
|
+
/**
|
|
1030
|
+
* `w:ind` as the paragraph states it now.
|
|
1031
|
+
*
|
|
1032
|
+
* An indentation command edits the attrs and leaves `_originalFormatting`
|
|
1033
|
+
* alone, so a paragraph that arrived with any `w:pPr` of its own saved its
|
|
1034
|
+
* source indentation whatever the editor showed. A field the source stated is
|
|
1035
|
+
* written at its current value; one it did not is written only when the style
|
|
1036
|
+
* cascade does not already supply that value, as for a paragraph without
|
|
1037
|
+
* `_originalFormatting`.
|
|
1038
|
+
*/
|
|
1039
|
+
function assignParagraphIndentation(result, attrs, orig) {
|
|
1040
|
+
let changed = false;
|
|
1041
|
+
for (const key of PARAGRAPH_INDENTATION_VALUE_FIELDS) {
|
|
1042
|
+
const value = authoredParagraphValue(key, attrs[key] ?? void 0, orig, attrs._resolvedFormatting);
|
|
1043
|
+
if (value === (orig[key] ?? void 0)) continue;
|
|
1044
|
+
changed = true;
|
|
1045
|
+
if (value === void 0) Reflect.deleteProperty(result, key);
|
|
1046
|
+
else result[key] = value;
|
|
1047
|
+
}
|
|
1048
|
+
const hanging = result.indentFirstLine !== void 0 && attrs.hangingIndent === true;
|
|
1049
|
+
if (!changed && hanging === (orig.hangingIndent === true)) return;
|
|
1050
|
+
if (hanging) result.hangingIndent = true;
|
|
1051
|
+
else Reflect.deleteProperty(result, "hangingIndent");
|
|
1052
|
+
}
|
|
992
1053
|
function paragraphAttrsToFormatting(attrs) {
|
|
993
1054
|
const directAlignment = directParagraphAlignment(attrs);
|
|
994
1055
|
const directSpacing = directParagraphSpacing(attrs);
|
|
@@ -1042,6 +1103,7 @@ function paragraphAttrsToFormatting(attrs) {
|
|
|
1042
1103
|
}
|
|
1043
1104
|
if (attrs.styleId !== (orig.styleId ?? void 0)) if (attrs.styleId) result.styleId = attrs.styleId;
|
|
1044
1105
|
else delete result.styleId;
|
|
1106
|
+
assignParagraphIndentation(result, attrs, orig);
|
|
1045
1107
|
assignBooleanToggle(result, attrs, orig, "pageBreakBefore");
|
|
1046
1108
|
assignBooleanToggle(result, attrs, orig, "widowControl");
|
|
1047
1109
|
assignBooleanToggle(result, attrs, orig, "keepNext");
|
|
@@ -1217,6 +1279,21 @@ const nestRevisionAwareInlineWrappers = (items, stack, revisionOuterWrapperCount
|
|
|
1217
1279
|
return nested;
|
|
1218
1280
|
};
|
|
1219
1281
|
const sameRevisionLayer = (left, right) => left.type === right.type && left.revisionId === right.revisionId && left.author === right.author && left.date === right.date && left.utcDate === right.utcDate && left.initials === right.initials && left.outerWrapperCount === right.outerWrapperCount;
|
|
1282
|
+
/** The deletion's ancestor path, with the insertion it sits in as the outermost layer. */
|
|
1283
|
+
const enclosingInsertionAncestors = ({ insertionMark, ancestors, node }) => {
|
|
1284
|
+
if (!insertionMark) return ancestors;
|
|
1285
|
+
const attrs = expectTrackedChangeMarkAttrs(insertionMark);
|
|
1286
|
+
if (ancestors.some(({ revisionId }) => revisionId === attrs.revisionId)) return ancestors;
|
|
1287
|
+
return [{
|
|
1288
|
+
type: attrs.moveKind === "moveTo" ? "moveTo" : "insertion",
|
|
1289
|
+
revisionId: attrs.revisionId,
|
|
1290
|
+
author: attrs.author || "Unknown",
|
|
1291
|
+
...attrs.date ? { date: attrs.date } : {},
|
|
1292
|
+
...attrs.utcDate ? { utcDate: attrs.utcDate } : {},
|
|
1293
|
+
...attrs.initials ? { initials: attrs.initials } : {},
|
|
1294
|
+
outerWrapperCount: attrs._docxOuterWrapperCount ?? inlineWrapperStackOf(node).length
|
|
1295
|
+
}, ...ancestors];
|
|
1296
|
+
};
|
|
1220
1297
|
const revisionInfoFromLayer = (layer) => ({
|
|
1221
1298
|
id: layer.revisionId,
|
|
1222
1299
|
author: layer.author,
|
|
@@ -1505,9 +1582,14 @@ function extractParagraphContent(paragraph, _documentCounts, emptyHyperlinks, te
|
|
|
1505
1582
|
}
|
|
1506
1583
|
if (insertionMark || deletionMark) {
|
|
1507
1584
|
flushCurrentInline();
|
|
1508
|
-
const changeMark =
|
|
1585
|
+
const changeMark = deletionMark ?? insertionMark;
|
|
1509
1586
|
if (!changeMark) return;
|
|
1510
1587
|
const changeAttrs = expectTrackedChangeMarkAttrs(changeMark);
|
|
1588
|
+
const revisionAncestors = enclosingInsertionAncestors({
|
|
1589
|
+
insertionMark: deletionMark ? insertionMark : void 0,
|
|
1590
|
+
ancestors: changeAttrs._docxRevisionAncestors ?? [],
|
|
1591
|
+
node
|
|
1592
|
+
});
|
|
1511
1593
|
const otherMarks = node.marks.filter((m) => m.type.name !== "insertion" && m.type.name !== "deletion");
|
|
1512
1594
|
const info = {
|
|
1513
1595
|
id: changeAttrs.revisionId,
|
|
@@ -1520,17 +1602,17 @@ function extractParagraphContent(paragraph, _documentCounts, emptyHyperlinks, te
|
|
|
1520
1602
|
};
|
|
1521
1603
|
if (changeAttrs.initials) info.initials = changeAttrs.initials;
|
|
1522
1604
|
let type;
|
|
1523
|
-
if (insertionMark) type = changeAttrs.moveKind === "moveTo" ? "moveTo" : "insertion";
|
|
1605
|
+
if (changeMark === insertionMark) type = changeAttrs.moveKind === "moveTo" ? "moveTo" : "insertion";
|
|
1524
1606
|
else type = changeAttrs.moveKind === "moveFrom" ? "moveFrom" : "deletion";
|
|
1525
1607
|
const outerWrapperCount = changeAttrs._docxOuterWrapperCount ?? inlineWrapperStackOf(node).length;
|
|
1526
|
-
const trackedChangeKey = `${type}:${JSON.stringify(info)}:${outerWrapperCount}:${JSON.stringify(
|
|
1608
|
+
const trackedChangeKey = `${type}:${JSON.stringify(info)}:${outerWrapperCount}:${JSON.stringify(revisionAncestors)}`;
|
|
1527
1609
|
if (linkMark) {
|
|
1528
1610
|
const linkKey = getLinkKey(linkMark);
|
|
1529
1611
|
if (!currentTrackedChange || currentTrackedChange.type !== "hyperlink" || currentTrackedChange.key !== trackedChangeKey || currentTrackedChange.hyperlinkKey !== linkKey) {
|
|
1530
1612
|
const hyperlink = createIndexedHyperlink(linkMark);
|
|
1531
1613
|
const wrapper = createTrackedRunWrapper(type, info, hyperlink);
|
|
1532
1614
|
revisionOuterWrapperCounts.set(wrapper, outerWrapperCount);
|
|
1533
|
-
revisionAncestorsByWrapper.set(wrapper,
|
|
1615
|
+
revisionAncestorsByWrapper.set(wrapper, revisionAncestors);
|
|
1534
1616
|
content.push(wrapper);
|
|
1535
1617
|
currentTrackedChange = {
|
|
1536
1618
|
type: "hyperlink",
|
|
@@ -1565,7 +1647,7 @@ function extractParagraphContent(paragraph, _documentCounts, emptyHyperlinks, te
|
|
|
1565
1647
|
if (!currentTrackedChange || currentTrackedChange.type !== "direct" || currentTrackedChange.key !== trackedChangeKey) {
|
|
1566
1648
|
const wrapper = createTrackedRunWrapper(type, info);
|
|
1567
1649
|
revisionOuterWrapperCounts.set(wrapper, outerWrapperCount);
|
|
1568
|
-
revisionAncestorsByWrapper.set(wrapper,
|
|
1650
|
+
revisionAncestorsByWrapper.set(wrapper, revisionAncestors);
|
|
1569
1651
|
content.push(wrapper);
|
|
1570
1652
|
currentTrackedChange = {
|
|
1571
1653
|
type: "direct",
|
|
@@ -2255,18 +2337,19 @@ function createFieldFromNode(node, { baseParagraphFormatting, inheritedFormattin
|
|
|
2255
2337
|
};
|
|
2256
2338
|
if (marks && node.type.name === "field") restoreRunRecord(displayRun, marks);
|
|
2257
2339
|
const fieldContent = extractedContent.length > 0 ? synchronizeFieldDisplayText(extractedContent, displayText, displayRun) : [];
|
|
2258
|
-
const fallbackFieldContent = displayText ? [displayRun] :
|
|
2340
|
+
const fallbackFieldContent = displayText ? [displayRun] : reconcileEmptyFieldResultRuns(attrs._docxEmptyResultRuns, displayRun);
|
|
2259
2341
|
if (attrs.fieldKind === "complex") {
|
|
2260
2342
|
const complex = {
|
|
2261
2343
|
type: "complexField",
|
|
2262
2344
|
instruction: attrs.instruction,
|
|
2263
2345
|
fieldType: attrs.fieldType,
|
|
2264
|
-
fieldCode: [],
|
|
2346
|
+
fieldCode: attrs._docxFieldCode?.instruction === attrs.instruction ? attrs._docxFieldCode.runs : [],
|
|
2265
2347
|
fieldResult: fieldContent.length > 0 ? fieldContent.filter((content) => content.type === "run") : fallbackFieldContent
|
|
2266
2348
|
};
|
|
2267
2349
|
if (attrs.fldLock !== void 0) complex.fldLock = attrs.fldLock;
|
|
2268
2350
|
if (attrs.dirty !== void 0) complex.dirty = attrs.dirty;
|
|
2269
2351
|
if (attrs.fieldResultIsFallback !== void 0) complex.fieldResultIsFallback = attrs.fieldResultIsFallback;
|
|
2352
|
+
if (attrs.formFieldDataXml !== void 0) complex.formFieldDataXml = attrs.formFieldDataXml;
|
|
2270
2353
|
return complex;
|
|
2271
2354
|
}
|
|
2272
2355
|
const simple = {
|
|
@@ -2279,6 +2362,48 @@ function createFieldFromNode(node, { baseParagraphFormatting, inheritedFormattin
|
|
|
2279
2362
|
if (attrs.dirty !== void 0) simple.dirty = attrs.dirty;
|
|
2280
2363
|
return simple;
|
|
2281
2364
|
}
|
|
2365
|
+
const reconcileEmptyFieldResultRuns = (runs, displayRun) => {
|
|
2366
|
+
if (!runs?.length) return [];
|
|
2367
|
+
const firstFormatting = runs.findIndex((run) => run.formatting !== void 0);
|
|
2368
|
+
const formattingOwner = firstFormatting < 0 ? 0 : firstFormatting;
|
|
2369
|
+
const projectedChanges = displayRun.propertyChanges ?? [];
|
|
2370
|
+
const projectedById = /* @__PURE__ */ new Map();
|
|
2371
|
+
projectedChanges.forEach((change, index) => {
|
|
2372
|
+
const positions = projectedById.get(change.info.id) ?? [];
|
|
2373
|
+
positions.push(index);
|
|
2374
|
+
projectedById.set(change.info.id, positions);
|
|
2375
|
+
});
|
|
2376
|
+
const usedChanges = /* @__PURE__ */ new Set();
|
|
2377
|
+
const reconciled = runs.map((run, index) => {
|
|
2378
|
+
const propertyChanges = run.propertyChanges?.flatMap((change) => {
|
|
2379
|
+
const projectedIndex = projectedById.get(change.info.id)?.shift();
|
|
2380
|
+
if (projectedIndex === void 0) return [];
|
|
2381
|
+
usedChanges.add(projectedIndex);
|
|
2382
|
+
const projected = projectedChanges[projectedIndex];
|
|
2383
|
+
return projected ? [projected] : [];
|
|
2384
|
+
});
|
|
2385
|
+
if (index !== formattingOwner && !run.propertyChanges && index !== 0) return run;
|
|
2386
|
+
let formatting = index === formattingOwner ? displayRun.formatting : run.formatting;
|
|
2387
|
+
if (index === formattingOwner && !formatting && run.formatting && Object.keys(run.formatting).length === 0) formatting = run.formatting;
|
|
2388
|
+
const preservedAttributes = index === 0 ? displayRun.preservedAttributes ?? run.preservedAttributes : run.preservedAttributes;
|
|
2389
|
+
return {
|
|
2390
|
+
type: "run",
|
|
2391
|
+
content: run.content,
|
|
2392
|
+
...formatting ? { formatting } : {},
|
|
2393
|
+
...propertyChanges?.length ? { propertyChanges } : {},
|
|
2394
|
+
...preservedAttributes ? { preservedAttributes } : {}
|
|
2395
|
+
};
|
|
2396
|
+
});
|
|
2397
|
+
const newChanges = projectedChanges.filter((_, index) => !usedChanges.has(index));
|
|
2398
|
+
if (newChanges.length > 0) {
|
|
2399
|
+
const first = reconciled[0];
|
|
2400
|
+
if (first) reconciled[0] = {
|
|
2401
|
+
...first,
|
|
2402
|
+
propertyChanges: [...first.propertyChanges ?? [], ...newChanges]
|
|
2403
|
+
};
|
|
2404
|
+
}
|
|
2405
|
+
return reconciled;
|
|
2406
|
+
};
|
|
2282
2407
|
const synchronizeFieldDisplayText = (content, displayText, fallbackRun) => {
|
|
2283
2408
|
let currentText = "";
|
|
2284
2409
|
const visitRunsIn = (items, visit) => {
|
|
@@ -3214,6 +3339,7 @@ function restoreCarriedTableAttrs(table, attrs) {
|
|
|
3214
3339
|
if (Array.isArray(attrs.tblPrChange) && attrs.tblPrChange.length > 0) table.propertyChanges = [...attrs.tblPrChange];
|
|
3215
3340
|
if (attrs._bookmarks && attrs._bookmarks.length > 0) table.bookmarks = attrs._bookmarks;
|
|
3216
3341
|
if (hasSinkChildren(attrs._preserved)) table.preserved = attrs._preserved;
|
|
3342
|
+
if (attrs.carrierStack?.length) table.carrierStack = attrs.carrierStack;
|
|
3217
3343
|
}
|
|
3218
3344
|
function convertPMTableRows(node, documentCounts, styleResolver = null) {
|
|
3219
3345
|
const rows = [];
|
|
@@ -3316,7 +3442,7 @@ function convertPMTableRow(node, documentCounts, activeVerticalMerges, styleReso
|
|
|
3316
3442
|
let activeMerge = activeVerticalMerges.get(gridColumn);
|
|
3317
3443
|
while (activeMerge) {
|
|
3318
3444
|
const preservedCell = activeMerge.continuationCells?.shift();
|
|
3319
|
-
cells.push(preservedCell
|
|
3445
|
+
cells.push(preservedCell ? continuationCellSpanning(preservedCell, activeMerge.colspan) : createVerticalMergeContinuationCell(activeMerge.colspan));
|
|
3320
3446
|
activeMerge.remainingRows -= 1;
|
|
3321
3447
|
if (activeMerge.remainingRows <= 0) activeVerticalMerges.delete(gridColumn);
|
|
3322
3448
|
gridColumn += activeMerge.colspan;
|
|
@@ -3358,6 +3484,7 @@ function convertPMTableRow(node, documentCounts, activeVerticalMerges, styleReso
|
|
|
3358
3484
|
if (attrs._preservedAttributes && attrs._preservedAttributes.length > 0) row.preservedAttributes = attrs._preservedAttributes;
|
|
3359
3485
|
if (attrs._bookmarks && attrs._bookmarks.length > 0) row.bookmarks = attrs._bookmarks;
|
|
3360
3486
|
if (attrs.contentControls && attrs.contentControls.length > 0) row.contentControls = attrs.contentControls;
|
|
3487
|
+
if (attrs.carrierStack?.length) row.carrierStack = attrs.carrierStack;
|
|
3361
3488
|
if (hasSinkChildren(attrs._preserved)) row.preserved = attrs._preserved;
|
|
3362
3489
|
if (attrs.trIns) row.structuralChange = {
|
|
3363
3490
|
type: "tableRowInsertion",
|
|
@@ -3387,6 +3514,25 @@ function convertPMTableRow(node, documentCounts, activeVerticalMerges, styleReso
|
|
|
3387
3514
|
};
|
|
3388
3515
|
return row;
|
|
3389
3516
|
}
|
|
3517
|
+
/**
|
|
3518
|
+
* A continuation cell the package arrived with, spanning the columns its merge
|
|
3519
|
+
* spans NOW. The cell is carried whole for its `w:tcPr` and content, but a
|
|
3520
|
+
* column deleted or inserted through the merge changes the merge's width, and
|
|
3521
|
+
* a continuation still stating the old one leaves the row wider or narrower
|
|
3522
|
+
* than the grid and no longer under the cell it continues.
|
|
3523
|
+
*/
|
|
3524
|
+
function continuationCellSpanning(cell, colspan) {
|
|
3525
|
+
if ((cell.formatting?.gridSpan ?? 1) === colspan) return cell;
|
|
3526
|
+
const { gridSpan: _staleSpan, ...formatting } = cell.formatting ?? {};
|
|
3527
|
+
return {
|
|
3528
|
+
...cell,
|
|
3529
|
+
formatting: {
|
|
3530
|
+
...formatting,
|
|
3531
|
+
vMerge: "continue",
|
|
3532
|
+
...colspan > 1 && { gridSpan: colspan }
|
|
3533
|
+
}
|
|
3534
|
+
};
|
|
3535
|
+
}
|
|
3390
3536
|
function createVerticalMergeContinuationCell(colspan) {
|
|
3391
3537
|
const formatting = { vMerge: "continue" };
|
|
3392
3538
|
if (colspan > 1) formatting.gridSpan = colspan;
|
|
@@ -3448,6 +3594,9 @@ function convertPMTableCell(node, documentCounts, styleResolver = null) {
|
|
|
3448
3594
|
} else if (contentNode.type.name === "blockSdt") {
|
|
3449
3595
|
content.push(convertPMBlockSdt(contentNode, styleResolver));
|
|
3450
3596
|
previousStandaloneTextBox = null;
|
|
3597
|
+
} else if (contentNode.type.name === "blockCustomXml") {
|
|
3598
|
+
content.push(convertPMBlockCustomXml(contentNode, styleResolver));
|
|
3599
|
+
previousStandaloneTextBox = null;
|
|
3451
3600
|
} else if (contentNode.type.name === "textBox") previousStandaloneTextBox = appendTextBoxBlock(content, contentNode, {
|
|
3452
3601
|
pendingPageBreaks: 0,
|
|
3453
3602
|
previousStandaloneTextBox,
|
|
@@ -3475,6 +3624,7 @@ function convertPMTableCell(node, documentCounts, styleResolver = null) {
|
|
|
3475
3624
|
if (cellFormatting) cell.formatting = cellFormatting;
|
|
3476
3625
|
if (Array.isArray(attrs.tcPrChange) && attrs.tcPrChange.length > 0) cell.propertyChanges = [...attrs.tcPrChange];
|
|
3477
3626
|
if (attrs.contentControls && attrs.contentControls.length > 0) cell.contentControls = attrs.contentControls;
|
|
3627
|
+
if (attrs.carrierStack?.length) cell.carrierStack = attrs.carrierStack;
|
|
3478
3628
|
if (attrs.cellMarker) {
|
|
3479
3629
|
const info = {
|
|
3480
3630
|
id: attrs.cellMarker.info.revisionId,
|