@stll/folio-core 0.42.0 → 0.44.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.js +6 -5
- package/dist/ai-edits/index.d.ts +2 -2
- package/dist/ai-edits/index.js +2 -2
- package/dist/ai-edits/snapshot.js +13 -9
- package/dist/compare/content-alignment.js +16 -1
- package/dist/compare/inline-atoms.js +1 -1
- package/dist/compare/style-resources.js +6 -0
- package/dist/compat/eigenpal.d.ts +2 -2
- package/dist/controller/layoutPipeline.d.ts +2 -1
- package/dist/controller/layoutPipeline.js +5 -2
- package/dist/controller/layoutSession.d.ts +2 -1
- package/dist/controller/layoutSession.js +1 -0
- package/dist/docx/appVersionNormalization.d.ts +0 -18
- package/dist/docx/blockContentParser.js +10 -1
- package/dist/docx/blockRangeMarkers.d.ts +36 -0
- package/dist/docx/blockRangeMarkers.js +59 -0
- package/dist/docx/bookmarkParser.d.ts +2 -20
- package/dist/docx/bookmarkParser.js +6 -30
- package/dist/docx/borderParser.d.ts +13 -0
- package/dist/docx/borderParser.js +71 -0
- package/dist/docx/builtInStyles.d.ts +165 -0
- package/dist/docx/builtInStyles.js +239 -0
- package/dist/docx/commentIdNormalization.d.ts +10 -0
- package/dist/docx/commentIdNormalization.js +33 -0
- package/dist/docx/commentParser.d.ts +2 -1
- package/dist/docx/commentParser.js +34 -7
- package/dist/docx/commentReferenceNormalization.d.ts +4 -1
- package/dist/docx/commentReferenceNormalization.js +23 -14
- package/dist/docx/danglingRelationshipReferences.d.ts +15 -0
- package/dist/docx/danglingRelationshipReferences.js +30 -0
- package/dist/docx/defaultParagraphStyle.d.ts +39 -0
- package/dist/docx/defaultParagraphStyle.js +54 -0
- package/dist/docx/documentParser.d.ts +2 -1
- package/dist/docx/documentParser.js +2 -2
- package/dist/docx/drawingUtils.d.ts +8 -1
- package/dist/docx/drawingUtils.js +12 -3
- package/dist/docx/fieldParser.js +3 -5
- package/dist/docx/footnoteParser.d.ts +3 -2
- package/dist/docx/footnoteParser.js +19 -2
- package/dist/docx/groupDrawingParser.js +1 -1
- package/dist/docx/headerFooterRefParser.d.ts +15 -3
- package/dist/docx/headerFooterRefParser.js +51 -14
- package/dist/docx/headerFooterReferenceNormalization.d.ts +4 -1
- package/dist/docx/headerFooterReferenceNormalization.js +5 -1
- package/dist/docx/hyperlinkParser.js +11 -15
- package/dist/docx/imageParser.d.ts +1 -1
- package/dist/docx/imageParser.js +22 -18
- package/dist/docx/imageRawXml.js +5 -5
- package/dist/docx/markupRangeMarker.d.ts +15 -0
- package/dist/docx/markupRangeMarker.js +44 -0
- package/dist/docx/noteReferenceStyles.d.ts +29 -0
- package/dist/docx/noteReferenceStyles.js +70 -0
- package/dist/docx/numberingParser.js +2 -1
- package/dist/docx/numberingReference.d.ts +21 -0
- package/dist/docx/numberingReference.js +21 -0
- package/dist/docx/numberingReferenceNormalization.d.ts +14 -2
- package/dist/docx/numberingReferenceNormalization.js +51 -9
- package/dist/docx/paraIdRangeNormalization.d.ts +0 -19
- package/dist/docx/paragraphParser.js +69 -101
- package/dist/docx/paragraphPropertySource.js +1 -0
- package/dist/docx/paragraphTraversal.d.ts +37 -1
- package/dist/docx/paragraphTraversal.js +84 -1
- package/dist/docx/parseContext.d.ts +37 -0
- package/dist/docx/parseContext.js +67 -0
- package/dist/docx/parseWarningMessage.d.ts +6 -0
- package/dist/docx/parseWarningMessage.js +44 -0
- package/dist/docx/parser.js +86 -24
- package/dist/docx/relsParser.d.ts +28 -11
- package/dist/docx/relsParser.js +26 -13
- package/dist/docx/revisionIdNormalization.js +81 -7
- package/dist/docx/rezip.js +85 -27
- package/dist/docx/runConsolidator.js +1 -2
- package/dist/docx/runParser.d.ts +8 -1
- package/dist/docx/runParser.js +30 -48
- package/dist/docx/sectionParser.d.ts +2 -1
- package/dist/docx/sectionParser.js +21 -65
- package/dist/docx/serializer/borderSerializer.d.ts +1 -2
- package/dist/docx/serializer/commentSerializer.js +22 -9
- package/dist/docx/serializer/documentSerializer.d.ts +1 -5
- package/dist/docx/serializer/documentSerializer.js +6 -16
- package/dist/docx/serializer/headerFooterSerializer.js +5 -0
- package/dist/docx/serializer/markupRangeAttributes.d.ts +8 -0
- package/dist/docx/serializer/markupRangeAttributes.js +24 -0
- package/dist/docx/serializer/noteSerializer.js +5 -0
- package/dist/docx/serializer/paragraphSerializer.d.ts +1 -5
- package/dist/docx/serializer/paragraphSerializer.js +29 -35
- package/dist/docx/serializer/runSerializer.js +13 -7
- package/dist/docx/serializer/tableSerializer.js +28 -13
- package/dist/docx/serializer/textFormattingSerializer.d.ts +2 -3
- package/dist/docx/server/build.js +8 -1
- package/dist/docx/server/createBilingualDocument.js +15 -22
- package/dist/docx/server/extractDocxText.js +3 -4
- package/dist/docx/shadingParser.d.ts +6 -0
- package/dist/docx/shadingParser.js +32 -0
- package/dist/docx/shapeParser.js +3 -3
- package/dist/docx/styleParser.js +15 -89
- package/dist/docx/styleReferenceResolution.d.ts +36 -0
- package/dist/docx/styleReferenceResolution.js +51 -0
- package/dist/docx/tableLook.d.ts +57 -0
- package/dist/docx/tableLook.js +63 -0
- package/dist/docx/tableParser.d.ts +7 -9
- package/dist/docx/tableParser.js +64 -110
- package/dist/docx/textBoxParser.js +4 -4
- package/dist/docx/trackedMoveRangeNormalization.d.ts +3 -1
- package/dist/docx/trackedMoveRangeNormalization.js +11 -21
- package/dist/docx/transitionalSpelling.d.ts +13 -2
- package/dist/docx/transitionalSpelling.js +23 -1
- package/dist/docx/verbatimCapture.js +4 -11
- package/dist/docx/vmlImageParser.js +2 -2
- package/dist/docx/watermarkParser.js +2 -2
- package/dist/docx/xmlParser.d.ts +22 -32
- package/dist/docx/xmlParser.js +36 -21
- package/dist/index.d.ts +2 -2
- package/dist/internal/pageBreakRunSourceDescendantIndex.d.ts +2 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +9 -6
- package/dist/internal/paragraphFormattingSerialization.d.ts +2 -3
- package/dist/internal/paragraphFormattingSerialization.js +26 -6
- package/dist/layout-bridge/convert/footnoteLayout.js +2 -7
- package/dist/layout-bridge/convert/templatePreviewFlow.d.ts +19 -11
- package/dist/layout-bridge/convert/templatePreviewFlow.js +103 -38
- package/dist/layout-bridge/convert/toFlowBlocks.js +12 -3
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +2 -2
- package/dist/layout-engine/measure/measureBlocks.js +1 -6
- package/dist/layout-engine/types.d.ts +8 -2
- package/dist/layout-engine/types.js +35 -2
- package/dist/markdown/index.js +1 -1
- package/dist/markdown/internals.d.ts +6 -1
- package/dist/markdown/internals.js +14 -1
- package/dist/markdown/renderBlock.js +35 -21
- package/dist/markdown/renderParagraph.js +14 -5
- package/dist/markdown/renderRuns.js +4 -3
- package/dist/markdown/renderTable.js +4 -3
- package/dist/markdown/trailers.js +41 -7
- package/dist/markdown/types.d.ts +3 -7
- package/dist/prosemirror/attrs/index.js +2 -5
- package/dist/prosemirror/bookmarkBoundaryAttrs.d.ts +11 -1
- package/dist/prosemirror/bookmarkBoundaryAttrs.js +18 -3
- package/dist/prosemirror/commands/index.d.ts +3 -3
- package/dist/prosemirror/commands/index.js +2 -2
- package/dist/prosemirror/commands/pageBreak.js +12 -1
- package/dist/prosemirror/commands/paragraph.d.ts +3 -3
- package/dist/prosemirror/commands/paragraph.js +2 -2
- package/dist/prosemirror/commentIdAllocator.js +2 -7
- package/dist/prosemirror/conversion/fromProseDoc.js +131 -41
- package/dist/prosemirror/conversion/toProseDoc.d.ts +1 -14
- package/dist/prosemirror/conversion/toProseDoc.js +402 -328
- package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +14 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +11 -6
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +3 -3
- package/dist/prosemirror/extensions/features/ListExtension.js +42 -4
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +4 -1
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +6 -2
- package/dist/prosemirror/extensions/features/pastedHeadingStyles.d.ts +7 -0
- package/dist/prosemirror/extensions/features/pastedHeadingStyles.js +74 -0
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +11 -3
- package/dist/prosemirror/extensions/marks/markUtils.js +98 -19
- package/dist/prosemirror/extensions/nodes/BookmarkBoundaryExtension.js +7 -3
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +2 -1
- package/dist/prosemirror/extensions/nodes/ShapeExtension.js +1 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.js +15 -1
- package/dist/prosemirror/extensions/types.d.ts +2 -2
- package/dist/prosemirror/index.d.ts +3 -3
- package/dist/prosemirror/index.js +3 -3
- package/dist/prosemirror/insertOperations.d.ts +9 -2
- package/dist/prosemirror/insertOperations.js +9 -4
- package/dist/prosemirror/listMarker.js +2 -1
- package/dist/prosemirror/numberedRefFields.js +2 -1
- package/dist/prosemirror/pageBreakRunProjection.d.ts +11 -3
- package/dist/prosemirror/pageBreakRunProjection.js +16 -8
- package/dist/prosemirror/paragraphFormattingProvenance.d.ts +159 -0
- package/dist/prosemirror/paragraphFormattingProvenance.js +106 -0
- package/dist/prosemirror/plugins/documentStyles.d.ts +9 -1
- package/dist/prosemirror/plugins/documentStyles.js +11 -1
- package/dist/prosemirror/plugins/index.d.ts +2 -2
- package/dist/prosemirror/plugins/index.js +2 -2
- package/dist/prosemirror/plugins/revisionIds.d.ts +11 -2
- package/dist/prosemirror/plugins/revisionIds.js +21 -6
- package/dist/prosemirror/plugins/templatePreviewValues.d.ts +42 -1
- package/dist/prosemirror/plugins/templatePreviewValues.js +217 -14
- package/dist/prosemirror/runFormattingReconciliation.js +3 -2
- package/dist/prosemirror/runStyleFormatting.d.ts +1 -1
- package/dist/prosemirror/schema/nodes.d.ts +31 -0
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +4 -1
- package/dist/prosemirror/styles/styleResolver.d.ts +9 -0
- package/dist/prosemirror/styles/styleResolver.js +15 -6
- package/dist/prosemirror/utils/visualLineNavigation.d.ts +22 -2
- package/dist/prosemirror/utils/visualLineNavigation.js +80 -63
- package/dist/style-engine/styleEngine.d.ts +4 -1
- package/dist/style-engine/styleEngine.js +3 -0
- package/dist/style-sets/extract.js +35 -11
- package/dist/style-sets/stellaStyle.js +46 -39
- package/dist/style-sets/styleSetNormalization.d.ts +19 -0
- package/dist/style-sets/styleSetNormalization.js +99 -0
- package/dist/types/content.d.ts +2 -2
- package/dist/utils/createDocument.js +145 -20
- package/dist/utils/headingCollector.d.ts +8 -5
- package/dist/utils/headingCollector.js +23 -25
- package/dist/utils/tableOfContentsStyle.js +9 -2
- package/package.json +3 -2
- package/dist/docx/textWhitespace.d.ts +0 -4
- package/dist/docx/textWhitespace.js +0 -4
- package/dist/layout-bridge/engine/tableWidthUtils.d.ts +0 -6
- package/dist/layout-bridge/engine/tableWidthUtils.js +0 -25
- package/dist/markdown/headings.d.ts +0 -13
- package/dist/markdown/headings.js +0 -20
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { seedRevisionIdsAbove } from "./plugins/revisionIds.js";
|
|
1
|
+
import { maxAnnotationIdInDoc, seedRevisionIdsAbove } from "./plugins/revisionIds.js";
|
|
2
2
|
import { MAX_REVISION_ID } from "@stll/docx-core/model";
|
|
3
3
|
//#region src/prosemirror/commentIdAllocator.ts
|
|
4
4
|
/** Sentinel ID for a comment that hasn't been persisted yet (anchored to selection). */
|
|
@@ -32,12 +32,7 @@ function createCommentIdAllocator() {
|
|
|
32
32
|
function seedCommentAllocator(allocator, comments, view) {
|
|
33
33
|
let max = 0;
|
|
34
34
|
for (const comment of comments ?? []) if (Number.isInteger(comment.id) && comment.id > max && comment.id <= MAX_REVISION_ID) max = comment.id;
|
|
35
|
-
if (view) view.state.doc
|
|
36
|
-
for (const mark of node.marks) {
|
|
37
|
-
const revisionId = mark.attrs["revisionId"];
|
|
38
|
-
if (typeof revisionId === "number" && Number.isInteger(revisionId) && revisionId > max && revisionId <= MAX_REVISION_ID) max = revisionId;
|
|
39
|
-
}
|
|
40
|
-
});
|
|
35
|
+
if (view) max = Math.max(max, maxAnnotationIdInDoc(view.state.doc));
|
|
41
36
|
allocator.seedAbove(max);
|
|
42
37
|
seedRevisionIdsAbove(max);
|
|
43
38
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EDITED_PREVIEW_FINGERPRINT, imageRawXmlFingerprint } from "../../docx/imageRawXml.js";
|
|
2
|
+
import { isNumberingReference } from "../../docx/numberingReference.js";
|
|
2
3
|
import { PROSE_PARAGRAPH_SOURCE_CONTRACT_ATTR, ParagraphPropertySourceValidationError, copyDocumentParagraphPropertySourceContract, copyDocumentParagraphPropertySources, copyParagraphPropertyCapture, copyParagraphPropertySource, decodeTableCellParagraphSourcePayload, getDocumentParagraphPropertySourceContract, getParagraphPropertySource, getParagraphPropertySourceCandidate, getParagraphPropertySourceToken, getParagraphPropertySourceTransferId, getProseDocumentParagraphPropertySourceContract, getProseParagraphPropertySourceToken, isParagraphPropertySourceToken, linkParagraphPropertySourceCandidate, paragraphPropertySourceBelongsToDocument, paragraphPropertySourceTokenMatchesContract, recreateProseNodeWithParagraphPropertySource, restoreTableCellsWithParagraphPropertySources, visitDocumentStoryParagraphs, visitTableCellParagraphPropertySourceBindings } from "../../docx/paragraphPropertySource.js";
|
|
3
4
|
import { visitDocxParagraphs } from "../../docx/paragraphTraversal.js";
|
|
4
5
|
import { ShapeOutlineStyleSchema, narrowEnum } from "../../docx/parserEnums.js";
|
|
@@ -12,9 +13,10 @@ import { mergeTextFormatting } from "../../utils/textFormattingMerge.js";
|
|
|
12
13
|
import { pixelsToEmu } from "../../utils/units.js";
|
|
13
14
|
import { expectBlockSdtAttrs, expectCharacterSpacingMarkAttrs, expectCharacterStyleMarkAttrs, expectCommentMarkAttrs, expectEmphasisMarkAttrs, expectFieldAttrs, expectFontFamilyMarkAttrs, expectFontSizeMarkAttrs, expectFootnoteRefMarkAttrs, expectHardBreakAttrs, expectHighlightMarkAttrs, expectHyperlinkMarkAttrs, expectImageAttrs, expectLanguageMarkAttrs, expectMathAttrs, expectPageBreakRunAttrs, expectPageBreakRunOwnerMarkAttrs, expectParagraphAttrs, expectRunFormattingOverrideMarkAttrs, expectRunPropertyChangeMarkAttrs, expectRunShadingMarkAttrs, expectSdtAttrs, expectShapeAttrs, expectStrikeMarkAttrs, expectSymbolAttrs, expectTabAttrs, expectTableAttrs, expectTableCellAttrs, expectTableRowAttrs, expectTextBoxAttrs, expectTextColorMarkAttrs, expectTextEffectMarkAttrs, expectTrackedChangeMarkAttrs, expectUnderlineMarkAttrs } from "../attrs/index.js";
|
|
14
15
|
import { autospacingMatchesBase, hasAutospacingBaseSide } from "../autospacingBase.js";
|
|
15
|
-
import { expectBookmarkBoundaryAttrs } from "../bookmarkBoundaryAttrs.js";
|
|
16
|
+
import { bookmarkBoundaryDisplacement, expectBookmarkBoundaryAttrs } from "../bookmarkBoundaryAttrs.js";
|
|
16
17
|
import { paragraphRejectAttrPatch, paragraphRejectOriginalFormatting, removeParagraphPropertyChanges } from "../commands/propertyChangeScope.js";
|
|
17
18
|
import { applyRunFormattingOverrideAttrs, buildRunFormattingOverrideAttrs } from "../extensions/marks/RunFormattingOverrideExtension.js";
|
|
19
|
+
import { textFormattingToMarks } from "../extensions/marks/markUtils.js";
|
|
18
20
|
import { listRenderingFromAttrs as listRenderingFromAttrs$1 } from "../listRenderingAttrs.js";
|
|
19
21
|
import { resolveNumberedRefFields } from "../numberedRefFields.js";
|
|
20
22
|
import { directParagraphAlignment } from "../paragraphAlignment.js";
|
|
@@ -23,12 +25,12 @@ import { directParagraphSpacing } from "../paragraphSpacing.js";
|
|
|
23
25
|
import { RUN_FORMATTING_MARK_NAMES } from "../runFormattingMarkNames.js";
|
|
24
26
|
import { authoredRunFormattingFromAttrs, hasAuthoredRunFormattingProvenance } from "../runFormattingProvenance.js";
|
|
25
27
|
import { paragraphFormattingForRun, paragraphRunStyleContext, resolveEffectiveRunStyleFormatting, suppressParagraphMarkFormatting } from "../runStyleFormatting.js";
|
|
28
|
+
import { schema } from "../schema/index.js";
|
|
26
29
|
import { parseShapeGeometryAdjustments } from "../shapeGeometryAdjustments.js";
|
|
27
30
|
import { expectTextBoxAnchorAttrs } from "../textBoxAnchorAttrs.js";
|
|
28
31
|
import { assertValidProseMirrorDocument } from "../validation.js";
|
|
29
32
|
import { runShadingAttrsToShading, shadingToRunShadingAttrs } from "./runShadingMark.js";
|
|
30
33
|
import { decodeSdtListItems, sdtPropertiesFromAttrs, sdtPropertiesMatchAttrs } from "./sdtAttrs.js";
|
|
31
|
-
import { textFormattingToMarks } from "./toProseDoc.js";
|
|
32
34
|
import { panic } from "better-result";
|
|
33
35
|
import { Fragment } from "prosemirror-model";
|
|
34
36
|
import { DRAWING_RAW_XML_MODES } from "@stll/docx-core/model";
|
|
@@ -270,7 +272,7 @@ function stripSuggestedInlineMarks(marks, { baseParagraphFormatting, inheritedFo
|
|
|
270
272
|
styleResolver
|
|
271
273
|
}) : paragraphFormatting, previousFormatting);
|
|
272
274
|
next = next.filter((mark) => !RUN_FORMATTING_MARK_NAMES.has(mark.type.name));
|
|
273
|
-
for (const restored of textFormattingToMarks(effectivePreviousFormatting, {
|
|
275
|
+
for (const restored of textFormattingToMarks(effectivePreviousFormatting, schema, {
|
|
274
276
|
overrideFormatting: previousFormatting,
|
|
275
277
|
directFormatting: previousFormatting
|
|
276
278
|
})) next = restored.addToSet(next);
|
|
@@ -644,17 +646,47 @@ function replaceTextBoxAnchorInBlocks(blocks, marker, textBoxRun) {
|
|
|
644
646
|
}
|
|
645
647
|
return false;
|
|
646
648
|
}
|
|
649
|
+
/**
|
|
650
|
+
* The inline list a text-box anchor run can be spliced out of, or nothing when
|
|
651
|
+
* the item holds no such list.
|
|
652
|
+
*
|
|
653
|
+
* A complex field keeps its runs in `fieldCode`/`fieldResult`, two arrays
|
|
654
|
+
* rather than one, and an anchor has never been placed in either; splicing one
|
|
655
|
+
* would have to pick a side. The marker stays where it is and
|
|
656
|
+
* `removeUnresolvedTextBoxAnchors` leaves it, as before.
|
|
657
|
+
*/
|
|
658
|
+
const textBoxAnchorHost = (item) => {
|
|
659
|
+
switch (item.type) {
|
|
660
|
+
case "hyperlink": return item.children;
|
|
661
|
+
case "simpleField": return item.content;
|
|
662
|
+
case "inlineSdt":
|
|
663
|
+
case "insertion":
|
|
664
|
+
case "deletion":
|
|
665
|
+
case "moveFrom":
|
|
666
|
+
case "moveTo":
|
|
667
|
+
case "bidiWrapper": return item.content;
|
|
668
|
+
case "run":
|
|
669
|
+
case "complexField":
|
|
670
|
+
case "bookmarkStart":
|
|
671
|
+
case "bookmarkEnd":
|
|
672
|
+
case "commentRangeStart":
|
|
673
|
+
case "commentRangeEnd":
|
|
674
|
+
case "commentReference":
|
|
675
|
+
case "moveFromRangeStart":
|
|
676
|
+
case "moveFromRangeEnd":
|
|
677
|
+
case "moveToRangeStart":
|
|
678
|
+
case "moveToRangeEnd":
|
|
679
|
+
case "mathEquation": return;
|
|
680
|
+
default: panic(`Unsupported paragraph content: ${JSON.stringify(item)}`);
|
|
681
|
+
}
|
|
682
|
+
};
|
|
647
683
|
function editTextBoxAnchorInContent(content, marker, replacement) {
|
|
648
|
-
for (
|
|
649
|
-
const item = content[index];
|
|
684
|
+
for (const [index, item] of content.entries()) {
|
|
650
685
|
if (item === marker) {
|
|
651
686
|
content.splice(index, 1, ...replacement ? [replacement] : []);
|
|
652
687
|
return true;
|
|
653
688
|
}
|
|
654
|
-
|
|
655
|
-
if (item?.type === "hyperlink") nestedContent = item.children;
|
|
656
|
-
else if (item?.type === "simpleField") nestedContent = item.content;
|
|
657
|
-
else if (item?.type === "inlineSdt" || item?.type === "insertion" || item?.type === "deletion" || item?.type === "moveFrom" || item?.type === "moveTo") nestedContent = item.content;
|
|
689
|
+
const nestedContent = textBoxAnchorHost(item);
|
|
658
690
|
if (!nestedContent) continue;
|
|
659
691
|
const hadContent = nestedContent.length > 0;
|
|
660
692
|
if (editTextBoxAnchorInContent(nestedContent, marker, replacement)) {
|
|
@@ -689,7 +721,7 @@ function removeTextBoxAnchorFromBlocks(blocks, marker) {
|
|
|
689
721
|
*/
|
|
690
722
|
function listRenderingFromAttrs(attrs) {
|
|
691
723
|
const numId = attrs.numPr?.numId;
|
|
692
|
-
if (numId
|
|
724
|
+
if (!isNumberingReference(numId)) return;
|
|
693
725
|
if (!(attrs.listMarker != null || attrs.listIsBullet || attrs.listNumFmt != null)) return;
|
|
694
726
|
return listRenderingFromAttrs$1({
|
|
695
727
|
attrs,
|
|
@@ -799,8 +831,23 @@ const propertyChangeFromAttrs = (change) => {
|
|
|
799
831
|
...currentFormatting !== void 0 && { currentFormatting }
|
|
800
832
|
};
|
|
801
833
|
};
|
|
834
|
+
/**
|
|
835
|
+
* What the paragraph states itself for one `w:pPr` field, as opposed to what
|
|
836
|
+
* the style cascade resolved into the same attr.
|
|
837
|
+
*
|
|
838
|
+
* `undefined` means the paragraph states nothing and the field must stay
|
|
839
|
+
* absent: a materialised value is a direct override that outranks the style it
|
|
840
|
+
* was read from, and a later edit to that style no longer reaches the
|
|
841
|
+
* paragraph. A value the source stated directly is always authored, even when
|
|
842
|
+
* it happens to equal the style's.
|
|
843
|
+
*/
|
|
844
|
+
const authoredParagraphValue = (field, value, orig, resolved) => {
|
|
845
|
+
if (value === void 0) return;
|
|
846
|
+
if (orig?.[field] !== void 0) return value;
|
|
847
|
+
return sameResolvedValue(value, resolved?.[field]) ? void 0 : value;
|
|
848
|
+
};
|
|
802
849
|
function assignBooleanToggle(result, attrs, orig, key) {
|
|
803
|
-
const value = attrs[key] ?? void 0;
|
|
850
|
+
const value = authoredParagraphValue(key, attrs[key] ?? void 0, orig, attrs._resolvedFormatting);
|
|
804
851
|
if (value === (orig[key] ?? void 0)) return;
|
|
805
852
|
if (value === void 0) Reflect.deleteProperty(result, key);
|
|
806
853
|
else result[key] = value;
|
|
@@ -865,14 +912,29 @@ function paragraphAttrsToFormatting(attrs) {
|
|
|
865
912
|
assignBooleanToggle(result, attrs, orig, "suppressAutoHyphens");
|
|
866
913
|
if (attrs.spacingExplicit !== orig.spacingExplicit) if (attrs.spacingExplicit) result.spacingExplicit = attrs.spacingExplicit;
|
|
867
914
|
else delete result.spacingExplicit;
|
|
868
|
-
const bidi = directionToBidi(attrs.direction);
|
|
915
|
+
const bidi = authoredParagraphValue("bidi", directionToBidi(attrs.direction), orig, attrs._resolvedFormatting);
|
|
869
916
|
if (bidi !== (orig.bidi ?? void 0)) if (bidi === void 0) delete result.bidi;
|
|
870
917
|
else result.bidi = bidi;
|
|
871
918
|
return result;
|
|
872
919
|
}
|
|
873
|
-
const
|
|
874
|
-
const
|
|
875
|
-
|
|
920
|
+
const resolved = attrs._resolvedFormatting;
|
|
921
|
+
const authored = (field, value) => authoredParagraphValue(field, value ?? void 0, void 0, resolved);
|
|
922
|
+
const outlineLevel = authored("outlineLevel", Reflect.get(attrs, "outlineLevel"));
|
|
923
|
+
const bidi = authored("bidi", directionToBidi(attrs.direction));
|
|
924
|
+
const snapToGrid = authored("snapToGrid", attrs.snapToGrid);
|
|
925
|
+
const indentLeft = authored("indentLeft", attrs.indentLeft);
|
|
926
|
+
const indentRight = authored("indentRight", attrs.indentRight);
|
|
927
|
+
const indentFirstLine = authored("indentFirstLine", attrs.indentFirstLine);
|
|
928
|
+
const borders = authored("borders", attrs.borders);
|
|
929
|
+
const shading = authored("shading", attrs.shading);
|
|
930
|
+
const tabs = authored("tabs", attrs.tabs);
|
|
931
|
+
const contextualSpacing = authored("contextualSpacing", attrs.contextualSpacing);
|
|
932
|
+
const pageBreakBefore = authored("pageBreakBefore", attrs.pageBreakBefore);
|
|
933
|
+
const widowControl = authored("widowControl", attrs.widowControl);
|
|
934
|
+
const kinsoku = authored("kinsoku", attrs.kinsoku);
|
|
935
|
+
const overflowPunctuation = authored("overflowPunctuation", attrs.overflowPunctuation);
|
|
936
|
+
const suppressAutoHyphens = authored("suppressAutoHyphens", attrs.suppressAutoHyphens);
|
|
937
|
+
if (!(directAlignment !== void 0 || shouldSerializeSpaceBefore || shouldSerializeSpaceAfter || beforeAutospacingEdited || afterAutospacingEdited || hasDirectLineSpacing || hasDirectLineSpacingRule || snapToGrid != null || indentLeft || indentRight || indentFirstLine || attrs.numPr || attrs.styleId || borders || shading || tabs || typeof outlineLevel === "number" || contextualSpacing || attrs.spacingExplicit || bidi != null || pageBreakBefore != null || widowControl != null || kinsoku != null || overflowPunctuation != null || suppressAutoHyphens != null)) return;
|
|
876
938
|
const f = {};
|
|
877
939
|
if (directAlignment !== void 0) f.alignment = directAlignment;
|
|
878
940
|
if (shouldSerializeSpaceBefore) f.spaceBefore = spaceBefore;
|
|
@@ -881,25 +943,25 @@ function paragraphAttrsToFormatting(attrs) {
|
|
|
881
943
|
if (afterAutospacingEdited) f.afterAutospacing = false;
|
|
882
944
|
if (hasDirectLineSpacing && typeof attrs.lineSpacing === "number") f.lineSpacing = attrs.lineSpacing;
|
|
883
945
|
if (hasDirectLineSpacingRule && attrs.lineSpacingRule) f.lineSpacingRule = attrs.lineSpacingRule;
|
|
884
|
-
if (
|
|
946
|
+
if (snapToGrid != null) f.snapToGrid = snapToGrid;
|
|
885
947
|
if (attrs.spacingExplicit) f.spacingExplicit = attrs.spacingExplicit;
|
|
886
|
-
if (
|
|
887
|
-
if (
|
|
888
|
-
if (
|
|
889
|
-
if (attrs.hangingIndent) f.hangingIndent = attrs.hangingIndent;
|
|
948
|
+
if (indentLeft) f.indentLeft = indentLeft;
|
|
949
|
+
if (indentRight) f.indentRight = indentRight;
|
|
950
|
+
if (indentFirstLine) f.indentFirstLine = indentFirstLine;
|
|
951
|
+
if (attrs.hangingIndent && indentFirstLine) f.hangingIndent = attrs.hangingIndent;
|
|
890
952
|
if (attrs.numPr && !isStyleSourcedParagraphNumbering(attrs.numPr, attrs.numPrFromStyle)) f.numPr = attrs.numPr;
|
|
891
953
|
if (attrs.styleId) f.styleId = attrs.styleId;
|
|
892
|
-
if (
|
|
893
|
-
if (
|
|
894
|
-
if (
|
|
954
|
+
if (borders) f.borders = borders;
|
|
955
|
+
if (shading) f.shading = shading;
|
|
956
|
+
if (tabs) f.tabs = tabs;
|
|
895
957
|
if (typeof outlineLevel === "number") f.outlineLevel = outlineLevel;
|
|
896
|
-
if (
|
|
958
|
+
if (contextualSpacing) f.contextualSpacing = contextualSpacing;
|
|
897
959
|
if (bidi != null) f.bidi = bidi;
|
|
898
|
-
if (
|
|
899
|
-
if (
|
|
900
|
-
if (
|
|
901
|
-
if (
|
|
902
|
-
if (
|
|
960
|
+
if (pageBreakBefore != null) f.pageBreakBefore = pageBreakBefore;
|
|
961
|
+
if (widowControl != null) f.widowControl = widowControl;
|
|
962
|
+
if (kinsoku != null) f.kinsoku = kinsoku;
|
|
963
|
+
if (overflowPunctuation != null) f.overflowPunctuation = overflowPunctuation;
|
|
964
|
+
if (suppressAutoHyphens != null) f.suppressAutoHyphens = suppressAutoHyphens;
|
|
903
965
|
return f;
|
|
904
966
|
}
|
|
905
967
|
function createTrackedRunWrapper(type, info, child) {
|
|
@@ -1142,10 +1204,12 @@ function extractParagraphContent(paragraph, _documentCounts, emptyHyperlinks, te
|
|
|
1142
1204
|
id: attrs.id,
|
|
1143
1205
|
name: attrs.name,
|
|
1144
1206
|
...attrs.colFirst !== void 0 ? { colFirst: attrs.colFirst } : {},
|
|
1145
|
-
...attrs.colLast !== void 0 ? { colLast: attrs.colLast } : {}
|
|
1207
|
+
...attrs.colLast !== void 0 ? { colLast: attrs.colLast } : {},
|
|
1208
|
+
...bookmarkBoundaryDisplacement(attrs)
|
|
1146
1209
|
} : {
|
|
1147
1210
|
type: "bookmarkEnd",
|
|
1148
|
-
id: attrs.id
|
|
1211
|
+
id: attrs.id,
|
|
1212
|
+
...bookmarkBoundaryDisplacement(attrs)
|
|
1149
1213
|
};
|
|
1150
1214
|
currentTrackedChange.wrapper.content.push(boundary);
|
|
1151
1215
|
return;
|
|
@@ -1208,11 +1272,13 @@ function extractParagraphContent(paragraph, _documentCounts, emptyHyperlinks, te
|
|
|
1208
1272
|
id: attrs.id,
|
|
1209
1273
|
name: attrs.name,
|
|
1210
1274
|
...attrs.colFirst !== void 0 ? { colFirst: attrs.colFirst } : {},
|
|
1211
|
-
...attrs.colLast !== void 0 ? { colLast: attrs.colLast } : {}
|
|
1275
|
+
...attrs.colLast !== void 0 ? { colLast: attrs.colLast } : {},
|
|
1276
|
+
...bookmarkBoundaryDisplacement(attrs)
|
|
1212
1277
|
});
|
|
1213
1278
|
else content.push({
|
|
1214
1279
|
type: "bookmarkEnd",
|
|
1215
|
-
id: attrs.id
|
|
1280
|
+
id: attrs.id,
|
|
1281
|
+
...bookmarkBoundaryDisplacement(attrs)
|
|
1216
1282
|
});
|
|
1217
1283
|
} else if (node.isText) appendDirectRun(node, createRunFromText({
|
|
1218
1284
|
...formattingContext,
|
|
@@ -1425,11 +1491,13 @@ function addNodeToHyperlink({ baseParagraphFormatting, hyperlink, inheritedForma
|
|
|
1425
1491
|
id: attrs.id,
|
|
1426
1492
|
name: attrs.name,
|
|
1427
1493
|
...attrs.colFirst !== void 0 ? { colFirst: attrs.colFirst } : {},
|
|
1428
|
-
...attrs.colLast !== void 0 ? { colLast: attrs.colLast } : {}
|
|
1494
|
+
...attrs.colLast !== void 0 ? { colLast: attrs.colLast } : {},
|
|
1495
|
+
...bookmarkBoundaryDisplacement(attrs)
|
|
1429
1496
|
});
|
|
1430
1497
|
else hyperlink.children.push({
|
|
1431
1498
|
type: "bookmarkEnd",
|
|
1432
|
-
id: attrs.id
|
|
1499
|
+
id: attrs.id,
|
|
1500
|
+
...bookmarkBoundaryDisplacement(attrs)
|
|
1433
1501
|
});
|
|
1434
1502
|
return;
|
|
1435
1503
|
}
|
|
@@ -1817,6 +1885,14 @@ function createInlineSdtFromNode(node, textBoxAnchorMarkers, formattingContext)
|
|
|
1817
1885
|
/**
|
|
1818
1886
|
* Create a Run containing an image
|
|
1819
1887
|
*/
|
|
1888
|
+
/**
|
|
1889
|
+
* Restore the `w:rPr` an inline atom carried from its source run.
|
|
1890
|
+
*
|
|
1891
|
+
* Image and shape nodes do not hold the run's formatting marks
|
|
1892
|
+
* (`withRunBoundaryMarks` in toProseDoc keeps them off), so the run rebuilt
|
|
1893
|
+
* around one has no other record of the properties it was authored with.
|
|
1894
|
+
*/
|
|
1895
|
+
const carriedRunFormatting = (formatting) => formatting && Object.keys(formatting).length > 0 ? { formatting } : {};
|
|
1820
1896
|
function createImageRun(node) {
|
|
1821
1897
|
const attrs = expectImageAttrs(node);
|
|
1822
1898
|
const wrap = { type: attrs.wrapType || "inline" };
|
|
@@ -1887,6 +1963,7 @@ function createImageRun(node) {
|
|
|
1887
1963
|
}
|
|
1888
1964
|
return {
|
|
1889
1965
|
type: "run",
|
|
1966
|
+
...carriedRunFormatting(attrs._docxRunFormatting),
|
|
1890
1967
|
content: [drawingFromImageAttrs(image, attrs)]
|
|
1891
1968
|
};
|
|
1892
1969
|
}
|
|
@@ -1983,12 +2060,14 @@ function createShapeRun(node) {
|
|
|
1983
2060
|
if (attrs.outlineColor) shapeOutline.color = attrs.outlineColorValue ?? { rgb: attrs.outlineColor.replace("#", "") };
|
|
1984
2061
|
shape.outline = shapeOutline;
|
|
1985
2062
|
}
|
|
2063
|
+
const shapeContent = {
|
|
2064
|
+
type: "shape",
|
|
2065
|
+
shape
|
|
2066
|
+
};
|
|
1986
2067
|
return {
|
|
1987
2068
|
type: "run",
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
shape
|
|
1991
|
-
}]
|
|
2069
|
+
...carriedRunFormatting(attrs._docxRunFormatting),
|
|
2070
|
+
content: [shapeContent]
|
|
1992
2071
|
};
|
|
1993
2072
|
}
|
|
1994
2073
|
const RUN_FORMATTING_VISUAL_GROUPS = {
|
|
@@ -2549,6 +2628,17 @@ function marksToTextFormatting(marks, options) {
|
|
|
2549
2628
|
/**
|
|
2550
2629
|
* Convert a ProseMirror table node to our Table type
|
|
2551
2630
|
*/
|
|
2631
|
+
/**
|
|
2632
|
+
* A table the editor created carries no `w:tblPr`, so the borders its cells
|
|
2633
|
+
* were built with are the only record of what the table looks like. Lift the
|
|
2634
|
+
* first bordered cell's set to the table.
|
|
2635
|
+
*
|
|
2636
|
+
* Only for such a table: a table read from a package states its own
|
|
2637
|
+
* `w:tblBorders` or deliberately states none, and its cells' borders may be
|
|
2638
|
+
* the table style's rather than their own. Inferring there invents a
|
|
2639
|
+
* `w:tblBorders` the source never had, and it outranks the table style on
|
|
2640
|
+
* reload (`formatting.borders: absent became object` in the corpus census).
|
|
2641
|
+
*/
|
|
2552
2642
|
function inferTableBorders(rows) {
|
|
2553
2643
|
for (const row of rows) for (const cell of row.cells) {
|
|
2554
2644
|
const borders = cell.formatting?.borders;
|
|
@@ -2570,7 +2660,7 @@ function convertPMTable(node, documentCounts, styleResolver = null) {
|
|
|
2570
2660
|
const attrs = expectTableAttrs(node);
|
|
2571
2661
|
const rows = convertPMTableRows(node, documentCounts, styleResolver);
|
|
2572
2662
|
const formatting = tableAttrsToFormatting(attrs) || void 0;
|
|
2573
|
-
if (!formatting?.borders) {
|
|
2663
|
+
if (!formatting?.borders && !attrs._originalFormatting) {
|
|
2574
2664
|
const inferredBorders = inferTableBorders(rows);
|
|
2575
2665
|
if (inferredBorders) if (formatting) formatting.borders = inferredBorders;
|
|
2576
2666
|
else {
|
|
@@ -2589,7 +2679,7 @@ function convertPMTable(node, documentCounts, styleResolver = null) {
|
|
|
2589
2679
|
rows
|
|
2590
2680
|
};
|
|
2591
2681
|
if (attrs.columnWidths) table.columnWidths = attrs.columnWidths;
|
|
2592
|
-
if (formatting) table.formatting = formatting;
|
|
2682
|
+
if (formatting && Object.keys(formatting).length > 0) table.formatting = formatting;
|
|
2593
2683
|
restoreTablePropertyChanges(table, attrs);
|
|
2594
2684
|
return table;
|
|
2595
2685
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { document_d_exports } from "../../types/document.js";
|
|
2
2
|
import { StyleEngine } from "../../style-engine/styleEngine.js";
|
|
3
3
|
import "../../style-engine/index.js";
|
|
4
|
-
import { schema } from "../schema/index.js";
|
|
5
4
|
import { Node } from "prosemirror-model";
|
|
6
5
|
//#region src/prosemirror/conversion/toProseDoc.d.ts
|
|
7
6
|
type UnsupportedDocxToProseMirrorOwner = "complex-field-instruction" | "field-result" | "page-break-bearing-run" | "paragraph-borders" | "paragraph-frame" | "paragraph-outline" | "paragraph-text-box-anchor" | "table-cell" | "text-box";
|
|
@@ -39,18 +38,6 @@ declare function resolveParagraphDefaultTextFormatting(styleId: string | undefin
|
|
|
39
38
|
includeParagraphMarkRunProperties?: boolean;
|
|
40
39
|
}): document_d_exports.TextFormatting | undefined;
|
|
41
40
|
declare function standaloneTableCellToProseMirror(cell: document_d_exports.TableCell, nodeType: "tableCell" | "tableHeader"): Node;
|
|
42
|
-
type AuthoredRunFormattingCarrier = "preserve" | "reconstruct";
|
|
43
|
-
/**
|
|
44
|
-
* Convert TextFormatting to ProseMirror marks
|
|
45
|
-
*/
|
|
46
|
-
type TextFormattingToMarksOptions = {
|
|
47
|
-
overrideFormatting: document_d_exports.TextFormatting | undefined;
|
|
48
|
-
/** Direct standard font properties whose authored provenance must survive. */
|
|
49
|
-
directFormatting?: document_d_exports.TextFormatting | undefined;
|
|
50
|
-
/** Whether direct authorship is reconstructible from structural marks and the style context. */
|
|
51
|
-
authoredCarrier?: AuthoredRunFormattingCarrier;
|
|
52
|
-
};
|
|
53
|
-
declare function textFormattingToMarks(formatting: document_d_exports.TextFormatting | undefined, options?: TextFormattingToMarksOptions): ReturnType<typeof schema.mark>[];
|
|
54
41
|
/**
|
|
55
42
|
* Convert HeaderFooter content (array of Paragraph/Table blocks) to a ProseMirror document.
|
|
56
43
|
* Used for editing headers/footers in their own ProseMirror editor and for
|
|
@@ -66,4 +53,4 @@ declare function footnoteToProseDoc(content: document_d_exports.BlockContent[],
|
|
|
66
53
|
*/
|
|
67
54
|
declare function createEmptyDoc(): Node;
|
|
68
55
|
//#endregion
|
|
69
|
-
export { ToProseDocOptions, UnsupportedDocxToProseMirrorConversionError, createEmptyDoc, footnoteToProseDoc, headerFooterToProseDoc, resolveParagraphDefaultTextFormatting, standaloneTableCellToProseMirror,
|
|
56
|
+
export { ToProseDocOptions, UnsupportedDocxToProseMirrorConversionError, createEmptyDoc, footnoteToProseDoc, headerFooterToProseDoc, resolveParagraphDefaultTextFormatting, standaloneTableCellToProseMirror, toProseDoc };
|