@stll/folio-core 0.67.0 → 0.68.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/apply.d.ts +9 -1
- package/dist/ai-edits/apply.js +94 -8
- package/dist/ai-edits/headless.d.ts +36 -21
- package/dist/ai-edits/headless.js +104 -34
- package/dist/ai-edits/index.d.ts +2 -2
- package/dist/ai-edits/note-references.d.ts +6 -0
- package/dist/ai-edits/note-references.js +7 -1
- package/dist/ai-edits/read.d.ts +19 -0
- package/dist/ai-edits/snapshot.d.ts +6 -0
- package/dist/ai-edits/snapshot.js +8 -3
- package/dist/ai-edits/types.d.ts +9 -1
- package/dist/ai-suggestions/apply.js +13 -4
- package/dist/compare/compare.js +2 -1
- package/dist/compare/inserted-resource-snapshot.d.ts +4 -1
- package/dist/compare/inserted-resource-snapshot.js +7 -3
- package/dist/controller/canonicalClipboard.js +29 -12
- package/dist/controller/canonicalComposition.js +1 -1
- package/dist/controller/canonicalInlineProjection.d.ts +35 -10
- package/dist/controller/canonicalInlineProjection.js +192 -28
- package/dist/controller/canonicalInput.d.ts +2 -1
- package/dist/controller/canonicalInput.js +28 -1
- package/dist/controller/canonicalListRendering.d.ts +2 -1
- package/dist/controller/canonicalListRendering.js +1 -1
- package/dist/controller/canonicalLockGuard.d.ts +8 -0
- package/dist/controller/canonicalLockGuard.js +88 -0
- package/dist/controller/canonicalPublicOperations.d.ts +12 -4
- package/dist/controller/canonicalPublicOperations.js +274 -20
- package/dist/controller/canonicalSession.d.ts +87 -7
- package/dist/controller/canonicalSession.js +327 -73
- package/dist/controller/canonicalStoryEditor.d.ts +3 -2
- package/dist/controller/canonicalStoryEditor.js +4 -3
- package/dist/controller/canonicalStructure.d.ts +2 -1
- package/dist/controller/canonicalStructure.js +129 -7
- package/dist/controller/contentControlWidgetController.d.ts +5 -0
- package/dist/controller/contentControlWidgetController.js +13 -1
- package/dist/controller/folioEditor.js +1 -0
- package/dist/controller/headerFooterEditorManager.d.ts +2 -2
- package/dist/controller/headerFooterEditorManager.js +5 -5
- package/dist/controller/hiddenEditorApi.d.ts +6 -0
- package/dist/controller/hiddenEditorApi.js +1 -0
- package/dist/controller/hiddenEditorManager.d.ts +4 -3
- package/dist/controller/hiddenEditorManager.js +91 -37
- package/dist/controller/layoutPipeline.js +48 -15
- package/dist/controller/noteEditorManager.d.ts +2 -2
- package/dist/controller/noteEditorManager.js +5 -5
- package/dist/display-list/build/pageFurniture.js +41 -19
- package/dist/display-list/build/tablePrimitives.js +23 -4
- package/dist/display-list/dom/renderDisplayListToDom.js +4 -4
- package/dist/document-operations.d.ts +8 -0
- package/dist/document-operations.js +4 -3
- package/dist/docx/blockContentParser.d.ts +7 -3
- package/dist/docx/blockContentParser.js +2 -3
- package/dist/docx/blockPlainText.js +2 -0
- package/dist/docx/bookmarkRangeJoin.d.ts +6 -0
- package/dist/docx/bookmarkRangeJoin.js +43 -0
- package/dist/docx/canonicalSave.js +5 -1
- package/dist/docx/canonicalSessionInput.d.ts +5 -1
- package/dist/docx/canonicalSessionInput.js +7 -2
- package/dist/docx/commentAnchorIndex.d.ts +21 -5
- package/dist/docx/commentAnchorIndex.js +39 -11
- package/dist/docx/commentRangeIntegrity.js +30 -24
- package/dist/docx/commentRangeJoin.d.ts +4 -0
- package/dist/docx/commentRangeJoin.js +26 -12
- package/dist/docx/commentReferenceCompletion.js +5 -4
- package/dist/docx/commentReferenceNormalization.js +40 -18
- package/dist/docx/compatibility.js +9 -2
- package/dist/docx/containerChildren.js +22 -1
- package/dist/docx/encryption/compoundFile.js +9 -1
- package/dist/docx/encryption/encryptionInfo.js +16 -2
- package/dist/docx/ensureParaIds.js +46 -7
- package/dist/docx/ensureUniqueControlIds.d.ts +25 -0
- package/dist/docx/ensureUniqueControlIds.js +110 -0
- package/dist/docx/headerFooterVerbatim.d.ts +7 -0
- package/dist/docx/headerFooterVerbatim.js +13 -2
- package/dist/docx/hostCommentThreads.d.ts +17 -0
- package/dist/docx/hostCommentThreads.js +49 -0
- package/dist/docx/hyperlinkParser.js +9 -2
- package/dist/docx/inlineWrapperContent.d.ts +8 -1
- package/dist/docx/inlineWrapperContent.js +9 -2
- package/dist/docx/listMarkerComputation.d.ts +35 -1
- package/dist/docx/listMarkerComputation.js +39 -1
- package/dist/docx/listModelNormalization.d.ts +44 -1
- package/dist/docx/listModelNormalization.js +227 -96
- package/dist/docx/markupRangeMarker.d.ts +14 -0
- package/dist/docx/markupRangeMarker.js +15 -1
- package/dist/docx/metadataPrivacy.js +43 -22
- package/dist/docx/normalizeBaseDirection.js +3 -1
- package/dist/docx/paragraphParser.js +159 -48
- package/dist/docx/paragraphPropertySource.d.ts +7 -0
- package/dist/docx/paragraphPropertySource.js +22 -1
- package/dist/docx/paragraphTextBoxEnrichment.js +2 -1
- package/dist/docx/paragraphTraversal.js +2 -0
- package/dist/docx/parseWarningMessage.js +2 -1
- package/dist/docx/parser.js +6 -0
- package/dist/docx/renderedPageBreakNormalization.js +1 -1
- package/dist/docx/reviewProvenanceDiagnostics.d.ts +7 -0
- package/dist/docx/reviewProvenanceDiagnostics.js +39 -0
- package/dist/docx/reviewResolutionProvenance.d.ts +29 -3
- package/dist/docx/reviewResolutionProvenance.js +110 -25
- package/dist/docx/rezip.d.ts +6 -0
- package/dist/docx/rezip.js +38 -21
- package/dist/docx/selectiveSave.js +6 -10
- package/dist/docx/selectiveXmlPatch.d.ts +5 -4
- package/dist/docx/selectiveXmlPatch.js +11 -7
- package/dist/docx/serializer/documentSerializer.js +3 -1
- package/dist/docx/serializer/headerFooterSerializer.js +3 -1
- package/dist/docx/serializer/markupRangeAttributes.d.ts +6 -1
- package/dist/docx/serializer/markupRangeAttributes.js +6 -1
- package/dist/docx/serializer/noteSerializer.d.ts +17 -4
- package/dist/docx/serializer/noteSerializer.js +23 -16
- package/dist/docx/serializer/paragraphSerializer.js +56 -12
- package/dist/docx/serializer/runSerializer.d.ts +1 -3
- package/dist/docx/serializer/runSerializer.js +2 -2
- package/dist/docx/serializer/tableSerializer.d.ts +4 -0
- package/dist/docx/serializer/tableSerializer.js +4 -2
- package/dist/docx/server/applyDocxXmlPatchProposal.js +8 -4
- package/dist/docx/server/createBilingualDocument.js +27 -5
- package/dist/docx/server/migrateYjsAttrSchema.js +4 -0
- package/dist/docx/sessionListPruning.d.ts +2 -0
- package/dist/docx/sessionListPruning.js +50 -0
- package/dist/docx/splitRevisionPieces.d.ts +10 -0
- package/dist/docx/splitRevisionPieces.js +14 -0
- package/dist/docx/storyBlockReplay.js +4 -0
- package/dist/docx/structuralXmlPatch.js +19 -7
- package/dist/docx/tableParser.d.ts +6 -2
- package/dist/docx/tableParser.js +2 -3
- package/dist/docx/textBoxContentParser.d.ts +11 -0
- package/dist/docx/textBoxContentParser.js +51 -0
- package/dist/docx/textBoxParser.d.ts +0 -5
- package/dist/docx/textBoxParser.js +1 -23
- package/dist/docx/verticalMergeProjection.js +1 -1
- package/dist/fonts/fontsourceFaces.d.ts +2 -8
- package/dist/fonts/fontsourceFaces.js +1 -7
- package/dist/i18n/messages/ar.gen.js +2 -0
- package/dist/i18n/messages/catalogs.gen.d.ts +34 -0
- package/dist/i18n/messages/catalogs.gen.js +34 -0
- package/dist/i18n/messages/cs.gen.js +2 -0
- package/dist/i18n/messages/de.gen.js +2 -0
- package/dist/i18n/messages/en.gen.js +2 -0
- package/dist/i18n/messages/es.gen.js +2 -0
- package/dist/i18n/messages/et.gen.js +2 -0
- package/dist/i18n/messages/fr.gen.js +2 -0
- package/dist/i18n/messages/he.gen.js +2 -0
- package/dist/i18n/messages/hi.gen.js +2 -0
- package/dist/i18n/messages/hu.gen.js +2 -0
- package/dist/i18n/messages/lt.gen.js +2 -0
- package/dist/i18n/messages/lv.gen.js +2 -0
- package/dist/i18n/messages/messages.gen.d.ts +2 -0
- package/dist/i18n/messages/pl.gen.js +2 -0
- package/dist/i18n/messages/pt-BR.gen.js +2 -0
- package/dist/i18n/messages/sk.gen.js +2 -0
- package/dist/i18n/messages/tr.gen.js +2 -0
- package/dist/i18n/messages/zh-CN.gen.js +2 -0
- package/dist/internal/acceptedBlockProjection.js +2 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.d.ts +5 -0
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +5 -0
- package/dist/internal/revisionResolutionInline.js +1 -2
- package/dist/layout-bridge/convert/tableConversion.js +19 -8
- package/dist/layout-bridge/engine/blockIndex.d.ts +7 -0
- package/dist/layout-bridge/engine/blockIndex.js +12 -0
- package/dist/layout-bridge/engine/hitTest.js +9 -10
- package/dist/layout-bridge/engine/selectionRects.js +6 -6
- package/dist/layout-engine/footnoteContinuation.d.ts +36 -0
- package/dist/layout-engine/footnoteContinuation.js +210 -0
- package/dist/layout-engine/index.d.ts +2 -2
- package/dist/layout-engine/index.js +7 -2
- package/dist/layout-engine/measure/cache.js +10 -5
- package/dist/layout-engine/measure/measureParagraph.js +1 -1
- package/dist/layout-engine/tableLayout.js +29 -5
- package/dist/layout-engine/tableRowBreak.d.ts +36 -0
- package/dist/layout-engine/tableRowBreak.js +43 -1
- package/dist/layout-engine/types.d.ts +36 -1
- package/dist/layout-painter/renderPage.d.ts +4 -4
- package/dist/layout-painter/renderPage.js +46 -17
- package/dist/layout-painter/renderTable.js +7 -4
- package/dist/managers/AutoSaveManager.d.ts +5 -1
- package/dist/managers/FindReplaceManager.js +3 -10
- package/dist/markdown/escape.d.ts +20 -1
- package/dist/markdown/escape.js +43 -1
- package/dist/markdown/renderBlock.js +4 -1
- package/dist/markdown/renderParagraph.js +13 -27
- package/dist/markdown/renderTable.js +6 -2
- package/dist/markdown/trailers.js +1 -0
- package/dist/pdf/images.d.ts +17 -1
- package/dist/pdf/images.js +22 -4
- package/dist/pdf/writePdf.js +4 -2
- package/dist/prosemirror/attrs/index.js +1 -0
- package/dist/prosemirror/canonicalCommands.d.ts +39 -1
- package/dist/prosemirror/canonicalTableCommands.d.ts +28 -0
- package/dist/prosemirror/canonicalTableCommands.js +362 -0
- package/dist/prosemirror/commands/comments.d.ts +25 -0
- package/dist/prosemirror/commands/comments.js +102 -11
- package/dist/prosemirror/commands/formatting.d.ts +1 -1
- package/dist/prosemirror/commands/index.d.ts +1 -1
- package/dist/prosemirror/commentIdAllocator.js +2 -2
- package/dist/prosemirror/commentRangeBoundaryAttrs.d.ts +6 -0
- package/dist/prosemirror/commentRangeBoundaryAttrs.js +9 -3
- package/dist/prosemirror/commentReferenceIntegrity.js +3 -4
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -0
- package/dist/prosemirror/conversion/fromProseDoc.js +76 -31
- package/dist/prosemirror/conversion/index.d.ts +1 -1
- package/dist/prosemirror/conversion/toProseDoc.d.ts +128 -1
- package/dist/prosemirror/conversion/toProseDoc.js +319 -51
- package/dist/prosemirror/extensions/StarterKit.js +2 -0
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/JoinedRunStyleExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +1 -1
- package/dist/prosemirror/extensions/features/pastedHtmlLists.js +5 -4
- package/dist/prosemirror/extensions/marks/CommentExtension.js +6 -3
- package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.d.ts +4 -0
- package/dist/prosemirror/extensions/nodes/BlockCommentRangeBoundaryExtension.js +49 -0
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +12 -3
- package/dist/prosemirror/extensions/nodes/TableExtension.js +32 -31
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +1 -1
- package/dist/prosemirror/index.d.ts +2 -2
- package/dist/prosemirror/listLabels.js +3 -2
- package/dist/prosemirror/listNumbering.d.ts +6 -0
- package/dist/prosemirror/listNumbering.js +12 -9
- package/dist/prosemirror/lockedControls.d.ts +13 -0
- package/dist/prosemirror/lockedControls.js +106 -0
- package/dist/prosemirror/markupViewProjection.js +1 -1
- package/dist/prosemirror/noteReferenceReview.js +2 -2
- package/dist/prosemirror/plugins/documentNumbering.js +4 -1
- package/dist/prosemirror/plugins/suggestionMode.js +20 -9
- package/dist/prosemirror/plugins/templatePreviewValues.js +16 -1
- package/dist/prosemirror/rebaseParagraphRuns.js +1 -1
- package/dist/prosemirror/replacedAnnotations.js +1 -0
- package/dist/prosemirror/runFormattingFromMarks.d.ts +0 -1
- package/dist/prosemirror/runFormattingFromMarks.js +2 -4
- package/dist/prosemirror/runFormattingReconciliation.js +2 -2
- package/dist/prosemirror/runPropertyChangeResolution.js +1 -2
- package/dist/prosemirror/runStyleFormatting.d.ts +14 -4
- package/dist/prosemirror/runStyleFormatting.js +16 -13
- package/dist/prosemirror/schema/marks.d.ts +6 -0
- package/dist/prosemirror/styles/paragraphStyleCascade.js +2 -2
- package/dist/prosemirror/validation.js +1 -0
- package/dist/redline.js +23 -9
- package/dist/server.d.ts +2 -2
- package/dist/style-sets/extract.js +2 -2
- package/dist/types/canonicalCapabilities.d.ts +29 -8
- package/dist/types/canonicalCapabilities.js +13 -9
- package/dist/utils/cssString.d.ts +7 -0
- package/dist/utils/cssString.js +9 -0
- package/dist/utils/fontResolver.js +4 -1
- package/dist/utils/replaceText.d.ts +11 -0
- package/dist/utils/replaceText.js +39 -7
- package/dist/version-comparison.d.ts +9 -1
- package/dist/version-comparison.js +11 -5
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { hasNoteReferenceMark } from "../noteReferenceMark.js";
|
|
2
2
|
import { serializeBlockCustomXml } from "./blockCustomXmlSerializer.js";
|
|
3
3
|
import { serializeBlockSdt } from "./blockSdtSerializer.js";
|
|
4
|
-
import { serializeBookmarkMarker, serializeMoveRangeMarker } from "./markupRangeAttributes.js";
|
|
4
|
+
import { serializeBookmarkMarker, serializeCommentRangeMarker, serializeMoveRangeMarker } from "./markupRangeAttributes.js";
|
|
5
5
|
import { serializeParagraph } from "./paragraphSerializer.js";
|
|
6
6
|
import { serializePartElement } from "./partNamespaces.js";
|
|
7
7
|
import { serializeTable } from "./tableSerializer.js";
|
|
@@ -75,6 +75,8 @@ function serializeBlock(block) {
|
|
|
75
75
|
case "moveFromRangeEnd":
|
|
76
76
|
case "moveToRangeStart":
|
|
77
77
|
case "moveToRangeEnd": return serializeMoveRangeMarker(block);
|
|
78
|
+
case "commentRangeStart":
|
|
79
|
+
case "commentRangeEnd": return serializeCommentRangeMarker(block);
|
|
78
80
|
default: return block;
|
|
79
81
|
}
|
|
80
82
|
}
|
|
@@ -105,13 +107,16 @@ function insertNoteReferenceMark({ xml, elementName, note, customMark }) {
|
|
|
105
107
|
const referenceRun = `<w:r><w:rPr><w:rStyle w:val="${elementName === "footnote" ? "FootnoteReference" : "EndnoteReference"}"/></w:rPr><w:${elementName}Ref/></w:r>`;
|
|
106
108
|
return `${xml.slice(0, insertAt)}${referenceRun}${xml.slice(insertAt)}`;
|
|
107
109
|
}
|
|
108
|
-
function serializeNewNotePart({ elementName, notes, document }) {
|
|
109
|
-
const serializedNotes = notes.map((note) =>
|
|
110
|
-
xml
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
110
|
+
function serializeNewNotePart({ elementName, notes, document, sourceNoteIds }) {
|
|
111
|
+
const serializedNotes = notes.map((note) => {
|
|
112
|
+
const xml = serializeNote(elementName, note);
|
|
113
|
+
return sourceNoteIds?.has(note.id) === true ? xml : insertNoteReferenceMark({
|
|
114
|
+
xml,
|
|
115
|
+
elementName,
|
|
116
|
+
note,
|
|
117
|
+
customMark: document ? noteUsesCustomMark(document, note) : false
|
|
118
|
+
});
|
|
119
|
+
}).join("");
|
|
115
120
|
return serializeNotePart(elementName, serializeRequiredNoteSeparators(elementName) + serializedNotes);
|
|
116
121
|
}
|
|
117
122
|
/**
|
|
@@ -133,21 +138,23 @@ function serializeEndnotes(endnotes) {
|
|
|
133
138
|
return serializeNotePart("endnote", endnotes.map((en) => serializeNote("endnote", en)).join(""));
|
|
134
139
|
}
|
|
135
140
|
/** Serialize a brand-new footnote part, including Word's required separators
|
|
136
|
-
* and the automatic reference mark at the start of every normal note
|
|
137
|
-
|
|
141
|
+
* and the automatic reference mark at the start of every normal note new to
|
|
142
|
+
* the package. */
|
|
143
|
+
function serializeNewFootnotesPart(footnotes, context = {}) {
|
|
138
144
|
return serializeNewNotePart({
|
|
145
|
+
...context,
|
|
139
146
|
elementName: "footnote",
|
|
140
|
-
notes: footnotes
|
|
141
|
-
...document ? { document } : {}
|
|
147
|
+
notes: footnotes
|
|
142
148
|
});
|
|
143
149
|
}
|
|
144
150
|
/** Serialize a brand-new endnote part, including Word's required separators
|
|
145
|
-
* and the automatic reference mark at the start of every normal note
|
|
146
|
-
|
|
151
|
+
* and the automatic reference mark at the start of every normal note new to
|
|
152
|
+
* the package. */
|
|
153
|
+
function serializeNewEndnotesPart(endnotes, context = {}) {
|
|
147
154
|
return serializeNewNotePart({
|
|
155
|
+
...context,
|
|
148
156
|
elementName: "endnote",
|
|
149
|
-
notes: endnotes
|
|
150
|
-
...document ? { document } : {}
|
|
157
|
+
notes: endnotes
|
|
151
158
|
});
|
|
152
159
|
}
|
|
153
160
|
export { serializeEndnotes, serializeFootnotes, serializeNewEndnotesPart, serializeNewFootnotesPart };
|
|
@@ -4,13 +4,13 @@ import { CONTAINER_CHILDREN, TRACKED_RUN_WORDPROCESSING_CHILDREN } from "../cont
|
|
|
4
4
|
import { fieldStateAttributes } from "../fieldState.js";
|
|
5
5
|
import { serializeEmptyMarkProperties } from "../paragraphMarkPropertyPresence.js";
|
|
6
6
|
import { getParagraphPropertySource, paragraphFormattingWithAuthoredIndentation, paragraphPropertySourceMatchesAuthoredIndentation, paragraphPropertySourceMatchesEmission } from "../paragraphPropertySource.js";
|
|
7
|
-
import {
|
|
7
|
+
import { paragraphMarkResolutionJoinAttributes, serializeParagraphMarkResolutionJoin, serializeResolutionJoins, serializeSplitResolutionPiece } from "../reviewResolutionProvenance.js";
|
|
8
8
|
import { DATE_UTC_ATTRIBUTE } from "../trackedChangeInfo.js";
|
|
9
9
|
import { toTransitionalNamespaceUri } from "../transitionalSpelling.js";
|
|
10
10
|
import { captureVerbatimXml, createCapturedXmlSanitizer } from "../verbatimCapture.js";
|
|
11
11
|
import { NAMESPACES, OOXML_NAMESPACE_SCOPE, WORDPROCESSINGML_NAMESPACE_URIS, cloneElement, getChildElements, getLocalName, parseXml } from "../xmlParser.js";
|
|
12
12
|
import { writeGroupTextBoxesBack } from "./groupTextBoxWriteBack.js";
|
|
13
|
-
import {
|
|
13
|
+
import { serializeBookmarkMarker, serializeCommentRangeMarker, serializeMoveRangeMarker } from "./markupRangeAttributes.js";
|
|
14
14
|
import { serializeRun, serializeShapeTextBody } from "./runSerializer.js";
|
|
15
15
|
import { serializeSdtWrapper } from "./sdtPropertiesSerializer.js";
|
|
16
16
|
import { serializeSectionProperties } from "./sectionPropertiesSerializer.js";
|
|
@@ -314,6 +314,10 @@ function serializeHyperlinkChild(child, spelling) {
|
|
|
314
314
|
case "moveToRangeEnd": return serializeMoveRangeMarker(child);
|
|
315
315
|
case "inlineWrapper": return serializeParagraphContent(child, spelling);
|
|
316
316
|
case "preservedInline": return child.xml;
|
|
317
|
+
case "complexField": {
|
|
318
|
+
const xml = serializeComplexField(child);
|
|
319
|
+
return spelling === "deletedText" ? rewriteRunTextAsDeleted(xml) : xml;
|
|
320
|
+
}
|
|
317
321
|
default: return child;
|
|
318
322
|
}
|
|
319
323
|
}
|
|
@@ -572,14 +576,41 @@ const trackedChangeSegments = (change) => {
|
|
|
572
576
|
const tag = TRACKED_CHANGE_ELEMENT[change.type];
|
|
573
577
|
const spelling = TRACKED_CHANGE_TEXT_SPELLING[tag];
|
|
574
578
|
const segments = walkTrackedInlineContent(change.content, spelling);
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
579
|
+
const info = serializeTrackedChangeAttributes(change.info);
|
|
580
|
+
const joins = change.resolutionJoins;
|
|
581
|
+
const pieces = wrappedPieceCount(segments);
|
|
582
|
+
if (pieces > 1) {
|
|
583
|
+
let piece = 0;
|
|
584
|
+
return wrapTrackedInlineSegments(segments, (xml) => {
|
|
585
|
+
const split = serializeSplitResolutionPiece(piece === 0 && joins !== void 0 ? {
|
|
586
|
+
piece,
|
|
587
|
+
pieces,
|
|
588
|
+
joins
|
|
589
|
+
} : {
|
|
590
|
+
piece,
|
|
591
|
+
pieces
|
|
592
|
+
});
|
|
593
|
+
piece += 1;
|
|
594
|
+
return `<w:${tag} ${info}${split}>${xml}</w:${tag}>`;
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
const attrs = info + serializeResolutionJoins(joins);
|
|
581
598
|
return wrapTrackedInlineSegments(segments, (xml) => `<w:${tag} ${attrs}>${xml}</w:${tag}>`);
|
|
582
599
|
};
|
|
600
|
+
/** How many elements {@link wrapTrackedInlineSegments} writes for these segments. */
|
|
601
|
+
const wrappedPieceCount = (segments) => {
|
|
602
|
+
if (segments.length === 0) return 1;
|
|
603
|
+
let count = 0;
|
|
604
|
+
let plain = false;
|
|
605
|
+
for (const segment of segments) if (segment.type === "plain") {
|
|
606
|
+
if (!plain) count += 1;
|
|
607
|
+
plain = true;
|
|
608
|
+
} else {
|
|
609
|
+
count += 1;
|
|
610
|
+
plain = false;
|
|
611
|
+
}
|
|
612
|
+
return count;
|
|
613
|
+
};
|
|
583
614
|
const UnrepresentableNestedHyperlinkErrorBase = TaggedError("UnrepresentableNestedHyperlinkError");
|
|
584
615
|
var UnrepresentableNestedHyperlinkError = class extends UnrepresentableNestedHyperlinkErrorBase {};
|
|
585
616
|
/** One exhaustive recursive owner for all containers inside a tracked revision. */
|
|
@@ -605,9 +636,22 @@ const walkTrackedInlineContent = (content, spelling) => {
|
|
|
605
636
|
case "moveTo":
|
|
606
637
|
segments.push(...trackedChangeSegments(item));
|
|
607
638
|
break;
|
|
608
|
-
case "inlineWrapper":
|
|
609
|
-
|
|
639
|
+
case "inlineWrapper": {
|
|
640
|
+
const inner = walkTrackedInlineContent(item.content, spelling);
|
|
641
|
+
const pieces = wrappedPieceCount(inner);
|
|
642
|
+
let piece = 0;
|
|
643
|
+
segments.push(...wrapTrackedInlineSegments(inner, (xml) => {
|
|
644
|
+
const markup = serializeInlineWrapperMarkup(item, xml);
|
|
645
|
+
if (pieces === 1) return markup;
|
|
646
|
+
const split = serializeSplitResolutionPiece({
|
|
647
|
+
piece,
|
|
648
|
+
pieces
|
|
649
|
+
});
|
|
650
|
+
piece += 1;
|
|
651
|
+
return markup.replace(/^<([^\s>/]+)/u, `<$1${split}`);
|
|
652
|
+
}));
|
|
610
653
|
break;
|
|
654
|
+
}
|
|
611
655
|
case "inlineSdt":
|
|
612
656
|
segments.push({
|
|
613
657
|
type: "plain",
|
|
@@ -723,8 +767,8 @@ function serializeParagraphContent(content, spelling = "text") {
|
|
|
723
767
|
case "simpleField": return serializeSimpleField(content);
|
|
724
768
|
case "complexField": return serializeComplexField(content);
|
|
725
769
|
case "inlineSdt": return serializeInlineSdt(content, spelling);
|
|
726
|
-
case "commentRangeStart":
|
|
727
|
-
case "commentRangeEnd": return
|
|
770
|
+
case "commentRangeStart":
|
|
771
|
+
case "commentRangeEnd": return serializeCommentRangeMarker(content);
|
|
728
772
|
case "commentReference": return serializeCommentReferenceRun(content.id);
|
|
729
773
|
case "insertion":
|
|
730
774
|
case "deletion":
|
|
@@ -5,9 +5,7 @@ import { document_d_exports } from "../../types/document.js";
|
|
|
5
5
|
*/
|
|
6
6
|
export declare function resetAutoIdCounter(): void;
|
|
7
7
|
/** Serialize text body content for shapes/textboxes */
|
|
8
|
-
export declare function serializeShapeTextBody(blocks:
|
|
9
|
-
type: "paragraph" | "table";
|
|
10
|
-
}>[]): string;
|
|
8
|
+
export declare function serializeShapeTextBody(blocks: readonly document_d_exports.BlockContent[]): string;
|
|
11
9
|
/**
|
|
12
10
|
* Serialize a run to OOXML XML (w:r)
|
|
13
11
|
*
|
|
@@ -13,7 +13,7 @@ import { serializeEmptyRunProperties, serializePreviousRunProperties } from "../
|
|
|
13
13
|
import { replayableShapeAlternateContent, synchronizedTextShapeAlternateContent } from "../shapeAlternateContent.js";
|
|
14
14
|
import { requiredWrapPolygon, serializeWrapPolygon } from "../wrapPolygon.js";
|
|
15
15
|
import { serializeParagraph } from "./paragraphSerializer.js";
|
|
16
|
-
import {
|
|
16
|
+
import { serializeCellContent } from "./tableSerializer.js";
|
|
17
17
|
import { serializeTextFormatting } from "./textFormattingSerializer.js";
|
|
18
18
|
import { serializeTrackedChangeAttributes } from "./trackedChangeAttributes.js";
|
|
19
19
|
import { intAttr } from "./xmlUtils.js";
|
|
@@ -409,7 +409,7 @@ function serializeDrawingContent(content) {
|
|
|
409
409
|
}
|
|
410
410
|
/** Serialize text body content for shapes/textboxes */
|
|
411
411
|
function serializeShapeTextBody(blocks) {
|
|
412
|
-
return blocks.
|
|
412
|
+
return blocks.length === 0 ? "" : serializeCellContent(blocks, serializeParagraph);
|
|
413
413
|
}
|
|
414
414
|
const serializeTextBodyAnchor = (anchor) => {
|
|
415
415
|
switch (anchor) {
|
|
@@ -12,6 +12,10 @@ export declare function serializeTableRowFormatting(formatting: document_d_expor
|
|
|
12
12
|
* Serialize table cell formatting properties (w:tcPr)
|
|
13
13
|
*/
|
|
14
14
|
export declare function serializeTableCellFormatting(formatting: document_d_exports.TableCellFormatting | undefined, propertyChanges?: document_d_exports.TableCellPropertyChange[], structuralChange?: document_d_exports.TableStructuralChangeInfo): string;
|
|
15
|
+
/**
|
|
16
|
+
* Serialize cell content (paragraphs, nested tables)
|
|
17
|
+
*/
|
|
18
|
+
export declare function serializeCellContent(content: readonly document_d_exports.TableCellBlock[], serializeParagraph: ParagraphSerializer): string;
|
|
15
19
|
/**
|
|
16
20
|
* Serialize a table cell (w:tc)
|
|
17
21
|
*/
|
|
@@ -10,7 +10,7 @@ import { OOXML_NAMESPACE_SCOPE, parseXml } from "../xmlParser.js";
|
|
|
10
10
|
import { serializeBlockCustomXml } from "./blockCustomXmlSerializer.js";
|
|
11
11
|
import { serializeBlockSdt } from "./blockSdtSerializer.js";
|
|
12
12
|
import { serializeBorder } from "./borderSerializer.js";
|
|
13
|
-
import { serializeBookmarkMarker, serializeMoveRangeMarker } from "./markupRangeAttributes.js";
|
|
13
|
+
import { serializeBookmarkMarker, serializeCommentRangeMarker, serializeMoveRangeMarker } from "./markupRangeAttributes.js";
|
|
14
14
|
import { serializeSdtWrapper } from "./sdtPropertiesSerializer.js";
|
|
15
15
|
import { serializeTrackedChangeAttributes } from "./trackedChangeAttributes.js";
|
|
16
16
|
import { intAttr } from "./xmlUtils.js";
|
|
@@ -527,6 +527,8 @@ function serializeCellContent(content, serializeParagraph) {
|
|
|
527
527
|
case "moveFromRangeEnd":
|
|
528
528
|
case "moveToRangeStart":
|
|
529
529
|
case "moveToRangeEnd": return serializeMoveRangeMarker(block);
|
|
530
|
+
case "commentRangeStart":
|
|
531
|
+
case "commentRangeEnd": return serializeCommentRangeMarker(block);
|
|
530
532
|
default: return block;
|
|
531
533
|
}
|
|
532
534
|
};
|
|
@@ -697,4 +699,4 @@ function createTextCell(text, formatting) {
|
|
|
697
699
|
}]
|
|
698
700
|
};
|
|
699
701
|
}
|
|
700
|
-
export { createEmptyTable, createTextCell, getTableColumnCount, getTableRowCount, hasCellContent, hasCellFormatting, hasRowCells, hasRowFormatting, hasTableFormatting, hasTableRows, serializeTable, serializeTableCell, serializeTableCellFormatting, serializeTableFormatting, serializeTableRow, serializeTableRowFormatting, serializeTables };
|
|
702
|
+
export { createEmptyTable, createTextCell, getTableColumnCount, getTableRowCount, hasCellContent, hasCellFormatting, hasRowCells, hasRowFormatting, hasTableFormatting, hasTableRows, serializeCellContent, serializeTable, serializeTableCell, serializeTableCellFormatting, serializeTableFormatting, serializeTableRow, serializeTableRowFormatting, serializeTables };
|
|
@@ -14,13 +14,17 @@ const FolioDocxXmlPatchApplicationErrorBase = TaggedError("FolioDocxXmlPatchAppl
|
|
|
14
14
|
var FolioDocxXmlPatchApplicationError = class extends FolioDocxXmlPatchApplicationErrorBase {};
|
|
15
15
|
const sha256 = (bytes) => createHash("sha256").update(bytes).digest("hex");
|
|
16
16
|
const snapshotInput = (bytes) => Uint8Array.from(bytes instanceof Uint8Array ? bytes : new Uint8Array(bytes));
|
|
17
|
+
/**
|
|
18
|
+
* A copy of the caller's archive policy, taken before the first await so a
|
|
19
|
+
* later mutation cannot change it mid-call. Every field is carried: a field
|
|
20
|
+
* left out here would silently fall back to its default.
|
|
21
|
+
*/
|
|
17
22
|
const snapshotArchiveOptions = (archive) => {
|
|
18
23
|
if (archive === void 0) return;
|
|
24
|
+
const { xmlLimits, ...byteLimits } = archive;
|
|
19
25
|
return {
|
|
20
|
-
...
|
|
21
|
-
...
|
|
22
|
-
...archive.maxTotalBytes === void 0 ? {} : { maxTotalBytes: archive.maxTotalBytes },
|
|
23
|
-
...archive.maxEntries === void 0 ? {} : { maxEntries: archive.maxEntries }
|
|
26
|
+
...byteLimits,
|
|
27
|
+
...xmlLimits === void 0 ? {} : { xmlLimits: { ...xmlLimits } }
|
|
24
28
|
};
|
|
25
29
|
};
|
|
26
30
|
const snapshotProposalLimits = (limits) => {
|
|
@@ -241,6 +241,8 @@ const flattenBlocks = (content) => {
|
|
|
241
241
|
case "preservedBlock":
|
|
242
242
|
case "bookmarkStart":
|
|
243
243
|
case "bookmarkEnd":
|
|
244
|
+
case "commentRangeStart":
|
|
245
|
+
case "commentRangeEnd":
|
|
244
246
|
case "moveFromRangeStart":
|
|
245
247
|
case "moveFromRangeEnd":
|
|
246
248
|
case "moveToRangeStart":
|
|
@@ -509,6 +511,25 @@ const remapListRendering = (rendering, cloner) => {
|
|
|
509
511
|
...clonedAbstract !== void 0 && { abstractNumId: clonedAbstract }
|
|
510
512
|
};
|
|
511
513
|
};
|
|
514
|
+
/**
|
|
515
|
+
* The editable ids that name exactly one body paragraph. A package id that
|
|
516
|
+
* several paragraphs repeat is not a handle: the snapshot keeps it for the
|
|
517
|
+
* first and renumbers the rest, so a manifest row could point at the wrong
|
|
518
|
+
* paragraph.
|
|
519
|
+
*/
|
|
520
|
+
const uniqueParagraphHandles = (content, editableParagraphIds) => {
|
|
521
|
+
const counts = /* @__PURE__ */ new Map();
|
|
522
|
+
const visit = (blocks) => {
|
|
523
|
+
for (const item of blocks) if (item.type === "paragraph") {
|
|
524
|
+
if (item.paraId !== void 0) counts.set(item.paraId, (counts.get(item.paraId) ?? 0) + 1);
|
|
525
|
+
} else if (item.type === "table") for (const row of item.rows) for (const cell of row.cells) visit(cell.content);
|
|
526
|
+
else if (item.type === "blockSdt" || item.type === "blockCustomXml") visit(item.content);
|
|
527
|
+
};
|
|
528
|
+
visit(content);
|
|
529
|
+
const handles = /* @__PURE__ */ new Set();
|
|
530
|
+
for (const id of editableParagraphIds) if ((counts.get(id) ?? 0) <= 1) handles.add(id);
|
|
531
|
+
return handles;
|
|
532
|
+
};
|
|
512
533
|
const collectTableParagraphs = (table) => {
|
|
513
534
|
const out = [];
|
|
514
535
|
const collectBlocks = (blocks) => {
|
|
@@ -756,6 +777,7 @@ const createParaIdMinter = (taken) => {
|
|
|
756
777
|
* in document order.
|
|
757
778
|
*/
|
|
758
779
|
function readBilingualDocument(document, editableParagraphIds) {
|
|
780
|
+
const handles = uniqueParagraphHandles(document.package.document.content, editableParagraphIds);
|
|
759
781
|
const styleById = new Map((document.package.styles?.styles ?? []).map((style) => [style.styleId, style]));
|
|
760
782
|
const builtInStyles = createBuiltInStyleIndex(styleById.values(), document.package.styles?.docDefaults);
|
|
761
783
|
const numberingMap = document.package.numbering ? getCachedNumberingMap(document.package.numbering) : null;
|
|
@@ -784,9 +806,9 @@ function readBilingualDocument(document, editableParagraphIds) {
|
|
|
784
806
|
}
|
|
785
807
|
const paragraphs = [];
|
|
786
808
|
for (const [index, source] of sourceParagraphs.entries()) {
|
|
787
|
-
if (!isTranslatableParagraph(source,
|
|
809
|
+
if (!isTranslatableParagraph(source, handles)) continue;
|
|
788
810
|
const target = targetParagraphs.at(index);
|
|
789
|
-
if (target?.paraId === void 0 || target.paraId === source.paraId || !
|
|
811
|
+
if (target?.paraId === void 0 || target.paraId === source.paraId || !handles.has(target.paraId)) {
|
|
790
812
|
missingHandleCount += 1;
|
|
791
813
|
continue;
|
|
792
814
|
}
|
|
@@ -808,7 +830,7 @@ function readBilingualDocument(document, editableParagraphIds) {
|
|
|
808
830
|
missingHandleCount += 1;
|
|
809
831
|
continue;
|
|
810
832
|
}
|
|
811
|
-
const paragraphs = collectTableParagraphs(sourceTable).filter((paragraph) => isTranslatableParagraph(paragraph,
|
|
833
|
+
const paragraphs = collectTableParagraphs(sourceTable).filter((paragraph) => isTranslatableParagraph(paragraph, handles)).map((paragraph) => ({
|
|
812
834
|
paraId: paragraph.paraId,
|
|
813
835
|
sourceText: getParagraphText(paragraph)
|
|
814
836
|
}));
|
|
@@ -827,8 +849,8 @@ function readBilingualDocument(document, editableParagraphIds) {
|
|
|
827
849
|
missingHandleCount += 1;
|
|
828
850
|
continue;
|
|
829
851
|
}
|
|
830
|
-
const sourceMissing = source.paraId === void 0 || !
|
|
831
|
-
const targetMissing = !
|
|
852
|
+
const sourceMissing = source.paraId === void 0 || !handles.has(source.paraId);
|
|
853
|
+
const targetMissing = !handles.has(target.paraId);
|
|
832
854
|
if (sourceMissing) missingHandleCount += 1;
|
|
833
855
|
if (targetMissing) missingHandleCount += 1;
|
|
834
856
|
if (sourceMissing || targetMissing) continue;
|
|
@@ -97,6 +97,10 @@ const migrateFolioYjsSnapshot = (update) => {
|
|
|
97
97
|
const paragraphsRewritten = migratedAttrs.value;
|
|
98
98
|
const migrated = Y.encodeStateAsUpdate(ydoc);
|
|
99
99
|
ydoc.destroy();
|
|
100
|
+
if (migrated.byteLength > 10485760) return Result.err(new FolioYjsSnapshotMigrationError({
|
|
101
|
+
code: "update_too_large",
|
|
102
|
+
message: "The migrated Yjs update exceeds the snapshot size limit."
|
|
103
|
+
}));
|
|
100
104
|
return Result.ok({
|
|
101
105
|
fromVersion,
|
|
102
106
|
paragraphsRewritten,
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { getDocumentSourceNumberingIds } from "./headerFooterVerbatim.js";
|
|
2
|
+
// src/docx/sessionListPruning.ts
|
|
3
|
+
const SKIPPED_PACKAGE_KEYS = /* @__PURE__ */ new Set([
|
|
4
|
+
"numbering",
|
|
5
|
+
"media",
|
|
6
|
+
"fonts"
|
|
7
|
+
]);
|
|
8
|
+
/** Every `numId` a numbering reference outside the numbering part names. */
|
|
9
|
+
const referencedNumIds = (document) => {
|
|
10
|
+
const referenced = /* @__PURE__ */ new Set();
|
|
11
|
+
const visited = /* @__PURE__ */ new WeakSet();
|
|
12
|
+
const visit = (value) => {
|
|
13
|
+
if (typeof value !== "object" || value === null) return;
|
|
14
|
+
if (value instanceof ArrayBuffer || ArrayBuffer.isView(value)) return;
|
|
15
|
+
if (visited.has(value)) return;
|
|
16
|
+
visited.add(value);
|
|
17
|
+
if (value instanceof Map) {
|
|
18
|
+
for (const entry of value.values()) visit(entry);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const numId = Reflect.get(value, "numId");
|
|
22
|
+
if (Reflect.get(value, "kind") === "reference" && typeof numId === "number") referenced.add(numId);
|
|
23
|
+
for (const child of Object.values(value)) visit(child);
|
|
24
|
+
};
|
|
25
|
+
for (const [key, value] of Object.entries(document.package)) if (!SKIPPED_PACKAGE_KEYS.has(key)) visit(value);
|
|
26
|
+
return referenced;
|
|
27
|
+
};
|
|
28
|
+
const withoutUnusedSessionLists = (document) => {
|
|
29
|
+
const numbering = document.package.numbering;
|
|
30
|
+
const source = getDocumentSourceNumberingIds(document);
|
|
31
|
+
if (numbering === void 0 || source === void 0) return document;
|
|
32
|
+
const referenced = referencedNumIds(document);
|
|
33
|
+
const nums = numbering.nums.filter(({ numId }) => source.nums.has(numId) || referenced.has(numId));
|
|
34
|
+
const usedAbstracts = new Set(nums.map(({ abstractNumId }) => abstractNumId));
|
|
35
|
+
const abstractNums = numbering.abstractNums.filter(({ abstractNumId }) => source.abstractNums.has(abstractNumId) || usedAbstracts.has(abstractNumId));
|
|
36
|
+
if (nums.length === numbering.nums.length && abstractNums.length === numbering.abstractNums.length) return document;
|
|
37
|
+
const kept = {
|
|
38
|
+
...numbering,
|
|
39
|
+
nums,
|
|
40
|
+
abstractNums
|
|
41
|
+
};
|
|
42
|
+
return {
|
|
43
|
+
...document,
|
|
44
|
+
package: {
|
|
45
|
+
...document.package,
|
|
46
|
+
numbering: kept
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export { withoutUnusedSessionLists };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { XmlElement } from "./xmlParser.js";
|
|
2
|
+
import { SplitResolutionPiece } from "./reviewResolutionProvenance.js";
|
|
3
|
+
/**
|
|
4
|
+
* The pieces of changes and wrappers the serializer wrote as several
|
|
5
|
+
* elements around a lifted link, by the record each was read into. The
|
|
6
|
+
* paragraph parser puts them back together once a paragraph is read.
|
|
7
|
+
*/
|
|
8
|
+
export declare const splitPieces: WeakMap<object, SplitResolutionPiece>;
|
|
9
|
+
/** Record that `record` was read from `node`, a piece of a split element. */
|
|
10
|
+
export declare const tagSplitPiece: (node: XmlElement, record: object) => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { parseSplitResolutionPiece } from "./reviewResolutionProvenance.js";
|
|
2
|
+
// src/docx/splitRevisionPieces.ts
|
|
3
|
+
/**
|
|
4
|
+
* The pieces of changes and wrappers the serializer wrote as several
|
|
5
|
+
* elements around a lifted link, by the record each was read into. The
|
|
6
|
+
* paragraph parser puts them back together once a paragraph is read.
|
|
7
|
+
*/
|
|
8
|
+
const splitPieces = /* @__PURE__ */ new WeakMap();
|
|
9
|
+
/** Record that `record` was read from `node`, a piece of a split element. */
|
|
10
|
+
const tagSplitPiece = (node, record) => {
|
|
11
|
+
const split = parseSplitResolutionPiece(node);
|
|
12
|
+
if (split !== void 0) splitPieces.set(record, split);
|
|
13
|
+
};
|
|
14
|
+
export { splitPieces, tagSplitPiece };
|
|
@@ -15,6 +15,8 @@ const BLOCK_ELEMENT_NAMES = {
|
|
|
15
15
|
preservedBlock: null,
|
|
16
16
|
bookmarkStart: "bookmarkStart",
|
|
17
17
|
bookmarkEnd: "bookmarkEnd",
|
|
18
|
+
commentRangeStart: "commentRangeStart",
|
|
19
|
+
commentRangeEnd: "commentRangeEnd",
|
|
18
20
|
moveFromRangeStart: "moveFromRangeStart",
|
|
19
21
|
moveFromRangeEnd: "moveFromRangeEnd",
|
|
20
22
|
moveToRangeStart: "moveToRangeStart",
|
|
@@ -308,6 +310,8 @@ const replayNestedBlock = ({ sourceXml, serializedXml, sourceElement, generatedE
|
|
|
308
310
|
case "preservedBlock":
|
|
309
311
|
case "bookmarkStart":
|
|
310
312
|
case "bookmarkEnd":
|
|
313
|
+
case "commentRangeStart":
|
|
314
|
+
case "commentRangeEnd":
|
|
311
315
|
case "moveFromRangeStart":
|
|
312
316
|
case "moveFromRangeEnd":
|
|
313
317
|
case "moveToRangeStart":
|
|
@@ -133,12 +133,23 @@ const buildStructuralDocumentPatch = ({ originalXml, serializedXml, changedIds }
|
|
|
133
133
|
} else if (!isWordElement(element, "tbl") && !isWordElement(element, "sectPr")) return null;
|
|
134
134
|
const sourceBody = parseDocumentBody(originalXml);
|
|
135
135
|
const currentBody = parseDocumentBody(serializedXml);
|
|
136
|
-
const barriers = (body) => (
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
136
|
+
const barriers = (body) => body.content.filter((block) => block.type !== "paragraph");
|
|
137
|
+
const sourceBarriers = barriers(sourceBody);
|
|
138
|
+
const currentBarriers = barriers(currentBody);
|
|
139
|
+
if (sourceBarriers.length !== currentBarriers.length || canonicalJson({
|
|
140
|
+
finalSectionProperties: sourceBody.finalSectionProperties,
|
|
141
|
+
background: sourceBody.background
|
|
142
|
+
}) !== canonicalJson({
|
|
143
|
+
finalSectionProperties: currentBody.finalSectionProperties,
|
|
144
|
+
background: currentBody.background
|
|
145
|
+
})) return null;
|
|
146
|
+
const changedTables = /* @__PURE__ */ new Set();
|
|
147
|
+
for (const [index, block] of sourceBarriers.entries()) {
|
|
148
|
+
const next = currentBarriers[index];
|
|
149
|
+
if (canonicalJson(block) === canonicalJson(next)) continue;
|
|
150
|
+
if (block.type !== "table" || next?.type !== "table") return null;
|
|
151
|
+
changedTables.add(index);
|
|
152
|
+
}
|
|
142
153
|
const indexBlocks = (blocks) => {
|
|
143
154
|
let barrier = 0;
|
|
144
155
|
const indexed = /* @__PURE__ */ new Map();
|
|
@@ -148,6 +159,7 @@ const buildStructuralDocumentPatch = ({ originalXml, serializedXml, changedIds }
|
|
|
148
159
|
}
|
|
149
160
|
return indexed;
|
|
150
161
|
};
|
|
162
|
+
const barrierOf = (key) => key.startsWith("barrier:") ? Number(key.slice(8)) : -1;
|
|
151
163
|
const before = indexBlocks(source.blocks);
|
|
152
164
|
const after = indexBlocks(current.blocks);
|
|
153
165
|
const survivingBefore = [...before.keys()].filter((key) => after.has(key));
|
|
@@ -177,7 +189,7 @@ const buildStructuralDocumentPatch = ({ originalXml, serializedXml, changedIds }
|
|
|
177
189
|
continue;
|
|
178
190
|
}
|
|
179
191
|
const id = paraIdAttribute(block.element)?.toUpperCase();
|
|
180
|
-
const replacement = id !== void 0 && changed.has(id) ? fragmentFor(block) : originalXml.slice(original.start, original.end);
|
|
192
|
+
const replacement = id !== void 0 && changed.has(id) || changedTables.has(barrierOf(key)) ? fragmentFor(block) : originalXml.slice(original.start, original.end);
|
|
181
193
|
if (replacement === null) return null;
|
|
182
194
|
if (pending.length > 0 || replacement !== originalXml.slice(original.start, original.end)) splices.push({
|
|
183
195
|
start: original.start,
|
|
@@ -147,8 +147,12 @@ export declare const CELL_CONTENT_HANDLERS: {
|
|
|
147
147
|
readonly tcPr: OwnedElsewhere<"block-content", "tcPr">;
|
|
148
148
|
readonly sectPr: "capture";
|
|
149
149
|
readonly altChunk: "capture";
|
|
150
|
-
readonly commentRangeEnd:
|
|
151
|
-
|
|
150
|
+
readonly commentRangeEnd: (child: XmlElement, walk: {
|
|
151
|
+
modelled: document_d_exports.BlockContent[];
|
|
152
|
+
}) => void;
|
|
153
|
+
readonly commentRangeStart: (child: XmlElement, walk: {
|
|
154
|
+
modelled: document_d_exports.BlockContent[];
|
|
155
|
+
}) => void;
|
|
152
156
|
readonly customXmlDelRangeEnd: "capture";
|
|
153
157
|
readonly customXmlDelRangeStart: "capture";
|
|
154
158
|
readonly customXmlInsRangeEnd: "capture";
|
package/dist/docx/tableParser.js
CHANGED
|
@@ -3,7 +3,7 @@ import { blockCustomXmlShell } from "./blockCustomXmlShell.js";
|
|
|
3
3
|
import { parseBookmarkEnd, parseBookmarkStart } from "./bookmarkParser.js";
|
|
4
4
|
import { parseBorderSpec } from "./borderParser.js";
|
|
5
5
|
import { CAPTURE, dispatchChildrenWithContext, keptUnless, ownedElsewhere, sequencePositions, withPreservedChildren } from "./containerChildren.js";
|
|
6
|
-
import { BLOCK_MOVE_RANGE_MARKER_HANDLERS } from "./markupRangeMarker.js";
|
|
6
|
+
import { BLOCK_COMMENT_RANGE_MARKER_HANDLERS, BLOCK_MOVE_RANGE_MARKER_HANDLERS } from "./markupRangeMarker.js";
|
|
7
7
|
import { parseParagraph } from "./paragraphParser.js";
|
|
8
8
|
import { enrichParagraphTextBoxes } from "./paragraphTextBoxEnrichment.js";
|
|
9
9
|
import { FloatingTableXSpecSchema, FloatingTableYSpecSchema, TableAlignmentSchema, TextDirectionSchema, narrowEnum } from "./parserEnums.js";
|
|
@@ -879,11 +879,10 @@ const CELL_CONTENT_HANDLERS = {
|
|
|
879
879
|
modelled.push(parseBookmarkEnd(child));
|
|
880
880
|
},
|
|
881
881
|
...BLOCK_MOVE_RANGE_MARKER_HANDLERS,
|
|
882
|
+
...BLOCK_COMMENT_RANGE_MARKER_HANDLERS,
|
|
882
883
|
tcPr: CELL_PROPERTIES_OWNER,
|
|
883
884
|
sectPr: CAPTURE,
|
|
884
885
|
altChunk: CAPTURE,
|
|
885
|
-
commentRangeEnd: CAPTURE,
|
|
886
|
-
commentRangeStart: CAPTURE,
|
|
887
886
|
customXmlDelRangeEnd: CAPTURE,
|
|
888
887
|
customXmlDelRangeStart: CAPTURE,
|
|
889
888
|
customXmlInsRangeEnd: CAPTURE,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { NumberingMap } from "./numberingParser.js";
|
|
3
|
+
import { XmlElement } from "./xmlParser.js";
|
|
4
|
+
import { PreviewLedger } from "./previewBudget.js";
|
|
5
|
+
import { StyleMap } from "./styleParser.js";
|
|
6
|
+
import { ParagraphParserFn, TableParserFn } from "./textBoxParser.js";
|
|
7
|
+
/**
|
|
8
|
+
* Parse text box content with provided parser functions
|
|
9
|
+
* This avoids circular dependencies by accepting parser functions as parameters
|
|
10
|
+
*/
|
|
11
|
+
export declare function parseTextBoxContent(txbxContent: XmlElement | null, parseParagraph: ParagraphParserFn, parseTable: TableParserFn | null, styles: StyleMap | null, theme: document_d_exports.Theme | null, numbering: NumberingMap | null, rels: document_d_exports.RelationshipMap | null, media: Map<string, document_d_exports.MediaFile> | null, previews: PreviewLedger): document_d_exports.TableCellBlock[];
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { blockCustomXmlShell } from "./blockCustomXmlShell.js";
|
|
2
|
+
import { parseBookmarkEnd, parseBookmarkStart } from "./bookmarkParser.js";
|
|
3
|
+
import { captureSdtSiblingMarkers, parseSdtProperties } from "./sdtProperties.js";
|
|
4
|
+
import { captureVerbatimXml } from "./verbatimCapture.js";
|
|
5
|
+
import { WORDPROCESSINGML_NAMESPACE_URIS, findChildByLocalName, getChildElements } from "./xmlParser.js";
|
|
6
|
+
// src/docx/textBoxContentParser.ts
|
|
7
|
+
/**
|
|
8
|
+
* Parse text box content with provided parser functions
|
|
9
|
+
* This avoids circular dependencies by accepting parser functions as parameters
|
|
10
|
+
*/
|
|
11
|
+
function parseTextBoxContent(txbxContent, parseParagraph, parseTable, styles, theme, numbering, rels, media, previews) {
|
|
12
|
+
if (!txbxContent) return [];
|
|
13
|
+
const readBlocks = (container) => {
|
|
14
|
+
const blocks = [];
|
|
15
|
+
for (const child of getChildElements(container)) {
|
|
16
|
+
const name = child.name || "";
|
|
17
|
+
const colonIdx = name.indexOf(":");
|
|
18
|
+
const localName = colonIdx !== -1 ? name.slice(colonIdx + 1) : name;
|
|
19
|
+
const isWordElement = WORDPROCESSINGML_NAMESPACE_URIS.has(child.namespaceUri ?? "");
|
|
20
|
+
if (localName === "p") blocks.push(parseParagraph(child, styles, theme, numbering, rels, media, { previews }));
|
|
21
|
+
else if (localName === "tbl" && parseTable) {
|
|
22
|
+
const table = parseTable(child, styles, theme, numbering, rels, media, { previews });
|
|
23
|
+
if (table) blocks.push(table);
|
|
24
|
+
} else if (localName === "sdt" && isWordElement) {
|
|
25
|
+
const properties = parseSdtProperties(findChildByLocalName(child, "sdtPr"), findChildByLocalName(child, "sdtEndPr"));
|
|
26
|
+
const captured = captureSdtSiblingMarkers(child);
|
|
27
|
+
if (captured.before.length > 0) properties.rawSdtChildrenBeforeContent = captured.before;
|
|
28
|
+
if (captured.after.length > 0) properties.rawSdtChildrenAfterContent = captured.after;
|
|
29
|
+
const sdtContent = findChildByLocalName(child, "sdtContent");
|
|
30
|
+
blocks.push({
|
|
31
|
+
type: "blockSdt",
|
|
32
|
+
properties,
|
|
33
|
+
content: sdtContent ? readBlocks(sdtContent) : []
|
|
34
|
+
});
|
|
35
|
+
} else if (localName === "customXml" && isWordElement) blocks.push({
|
|
36
|
+
type: "blockCustomXml",
|
|
37
|
+
...blockCustomXmlShell(child),
|
|
38
|
+
content: readBlocks(child)
|
|
39
|
+
});
|
|
40
|
+
else if (localName === "bookmarkStart" && isWordElement) blocks.push(parseBookmarkStart(child));
|
|
41
|
+
else if (localName === "bookmarkEnd" && isWordElement) blocks.push(parseBookmarkEnd(child));
|
|
42
|
+
else blocks.push({
|
|
43
|
+
type: "preservedBlock",
|
|
44
|
+
xml: captureVerbatimXml(child)
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return blocks;
|
|
48
|
+
};
|
|
49
|
+
return readBlocks(txbxContent);
|
|
50
|
+
}
|
|
51
|
+
export { parseTextBoxContent };
|
|
@@ -24,11 +24,6 @@ export type ParagraphParserFn = (node: XmlElement, styles: StyleMap | null, them
|
|
|
24
24
|
export type TableParserFn = (node: XmlElement, styles: StyleMap | null, theme: document_d_exports.Theme | null, numbering: NumberingMap | null, rels: document_d_exports.RelationshipMap | null, media: Map<string, document_d_exports.MediaFile> | null, options: {
|
|
25
25
|
previews: PreviewLedger;
|
|
26
26
|
}) => document_d_exports.Table | undefined;
|
|
27
|
-
/**
|
|
28
|
-
* Parse text box content with provided parser functions
|
|
29
|
-
* This avoids circular dependencies by accepting parser functions as parameters
|
|
30
|
-
*/
|
|
31
|
-
export declare function parseTextBoxContent(txbxContent: XmlElement | null, parseParagraph: ParagraphParserFn, parseTable: TableParserFn | null, styles: StyleMap | null, theme: document_d_exports.Theme | null, numbering: NumberingMap | null, rels: document_d_exports.RelationshipMap | null, media: Map<string, document_d_exports.MediaFile> | null, previews: PreviewLedger): (document_d_exports.Paragraph | document_d_exports.Table)[];
|
|
32
27
|
/**
|
|
33
28
|
* Check if a drawing element contains a text box
|
|
34
29
|
* Text boxes are shapes with wps:txbx content
|