@stll/folio-core 0.44.0 → 0.46.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/__fixtures__/paragraphs.js +2 -2
- package/dist/ai-edits/apply.js +59 -19
- package/dist/ai-edits/headless.js +2 -1
- package/dist/compare/compare.js +2 -5
- package/dist/compare/content-alignment.js +78 -53
- package/dist/compare/inline-atoms.js +34 -20
- package/dist/compare/scenario.js +2 -5
- package/dist/compare/types.d.ts +9 -1
- package/dist/compare/types.js +12 -1
- package/dist/compat/eigenpal.d.ts +2 -1
- package/dist/compat/eigenpal.js +2 -1
- package/dist/content-controls/checkboxDisplay.d.ts +11 -0
- package/dist/content-controls/checkboxDisplay.js +40 -0
- package/dist/content-controls/findContentControls.js +3 -1
- package/dist/content-controls/mutateContentControls.js +21 -4
- package/dist/controller/contentControlWidgetController.d.ts +1 -0
- package/dist/controller/contentControlWidgetController.js +3 -0
- package/dist/controller/hiddenEditorApi.js +3 -1
- package/dist/controller/hiddenEditorManager.d.ts +1 -1
- package/dist/controller/hiddenEditorManager.js +6 -3
- package/dist/display-list/build/buildDisplayList.js +20 -1
- package/dist/display-list/build/imagePrimitives.d.ts +1 -1
- package/dist/display-list/build/imagePrimitives.js +3 -1
- package/dist/display-list/build/paragraphPrimitives.js +21 -2
- package/dist/display-list/dom/renderDisplayListToDom.js +18 -10
- package/dist/display-list/types.d.ts +17 -0
- package/dist/document-operations.js +14 -3
- package/dist/docx/attributeRemainder.d.ts +43 -0
- package/dist/docx/attributeRemainder.js +65 -0
- package/dist/docx/blockContentParser.d.ts +1 -1
- package/dist/docx/blockContentParser.js +87 -63
- package/dist/docx/blockPlainText.d.ts +3 -4
- package/dist/docx/blockPlainText.js +1 -0
- package/dist/docx/bookmarkPlacement.js +2 -0
- package/dist/docx/borderParser.js +5 -5
- package/dist/docx/commentAnchorIndex.d.ts +30 -0
- package/dist/docx/commentAnchorIndex.js +50 -0
- package/dist/docx/commentParser.d.ts +1 -1
- package/dist/docx/commentParser.js +78 -50
- package/dist/docx/commentRangeIntegrity.d.ts +16 -1
- package/dist/docx/commentRangeIntegrity.js +42 -1
- package/dist/docx/commentRangeJoin.d.ts +9 -0
- package/dist/docx/commentRangeJoin.js +33 -0
- package/dist/docx/commentReferenceCompletion.d.ts +9 -0
- package/dist/docx/commentReferenceCompletion.js +47 -0
- package/dist/docx/commentReferenceNormalization.js +1 -0
- package/dist/docx/commentReplyMarkers.js +11 -19
- package/dist/docx/commentThreadKey.d.ts +18 -0
- package/dist/docx/commentThreadKey.js +22 -0
- package/dist/docx/compatibility.js +1 -0
- package/dist/docx/containerChildren.d.ts +111 -0
- package/dist/docx/containerChildren.gen.d.ts +28 -0
- package/dist/docx/containerChildren.gen.js +246 -0
- package/dist/docx/containerChildren.js +103 -0
- package/dist/docx/diagramPreview.js +87 -27
- package/dist/docx/documentParser.d.ts +1 -1
- package/dist/docx/documentParser.js +3 -3
- package/dist/docx/ensureParaIds.js +17 -7
- package/dist/docx/fieldParser.d.ts +1 -1
- package/dist/docx/fieldParser.js +4 -4
- package/dist/docx/fieldState.d.ts +26 -0
- package/dist/docx/fieldState.js +53 -0
- package/dist/docx/footnoteParser.d.ts +1 -1
- package/dist/docx/graphicFrameLocks.d.ts +16 -4
- package/dist/docx/graphicFrameLocks.js +19 -6
- package/dist/docx/groupDrawingParser.js +3 -3
- package/dist/docx/headerFooterParser.js +1 -1
- package/dist/docx/headerFooterReferenceNormalization.js +1 -0
- package/dist/docx/hyperlinkParser.d.ts +27 -8
- package/dist/docx/hyperlinkParser.js +78 -20
- package/dist/docx/imageParser.d.ts +9 -1
- package/dist/docx/imageParser.js +91 -20
- package/dist/docx/imageRawXml.d.ts +14 -1
- package/dist/docx/imageRawXml.js +30 -6
- package/dist/docx/inlineWrapperContent.d.ts +85 -0
- package/dist/docx/inlineWrapperContent.js +84 -0
- package/dist/docx/mathToMathml.js +12 -14
- package/dist/docx/nonVisualDrawingProps.d.ts +34 -0
- package/dist/docx/nonVisualDrawingProps.js +46 -0
- package/dist/docx/normalizeBaseDirection.js +10 -1
- package/dist/docx/paraIdAttribute.d.ts +21 -0
- package/dist/docx/paraIdAttribute.js +64 -0
- package/dist/docx/paragraphParser.d.ts +1 -1
- package/dist/docx/paragraphParser.js +277 -168
- package/dist/docx/paragraphPropertySource.js +5 -1
- package/dist/docx/paragraphTextBoxEnrichment.d.ts +1 -1
- package/dist/docx/paragraphTextBoxEnrichment.js +9 -52
- package/dist/docx/paragraphTraversal.js +7 -4
- package/dist/docx/parseWarningMessage.js +2 -1
- package/dist/docx/parser.js +2 -2
- package/dist/docx/preservedRunContent.d.ts +32 -0
- package/dist/docx/preservedRunContent.js +86 -0
- package/dist/docx/previewBudget.d.ts +64 -0
- package/dist/docx/previewBudget.js +88 -0
- package/dist/docx/renderedPageBreakNormalization.js +2 -4
- package/dist/docx/revisionIdNormalization.js +17 -5
- package/dist/docx/rezip.js +91 -36
- package/dist/docx/runParser.d.ts +1 -1
- package/dist/docx/runParser.js +16 -12
- package/dist/docx/sdtPropertiesPatch.js +24 -18
- package/dist/docx/sectionParser.js +8 -1
- package/dist/docx/sectionReferenceHistory.js +2 -2
- package/dist/docx/selectiveSave.js +6 -6
- package/dist/docx/selectiveXmlPatch.d.ts +46 -2
- package/dist/docx/selectiveXmlPatch.js +86 -39
- package/dist/docx/serializer/blockSdtSerializer.js +38 -26
- package/dist/docx/serializer/borderSerializer.d.ts +1 -1
- package/dist/docx/serializer/borderSerializer.js +15 -14
- package/dist/docx/serializer/commentSerializer.d.ts +41 -16
- package/dist/docx/serializer/commentSerializer.js +87 -92
- package/dist/docx/serializer/documentSerializer.js +8 -11
- package/dist/docx/serializer/fontTableSerializer.js +6 -6
- package/dist/docx/serializer/headerFooterSerializer.js +12 -14
- package/dist/docx/serializer/markupRangeAttributes.js +2 -2
- package/dist/docx/serializer/noteSerializer.js +8 -8
- package/dist/docx/serializer/numberingSerializer.js +7 -6
- package/dist/docx/serializer/paragraphSerializer.js +93 -72
- package/dist/docx/serializer/partNamespaces.js +2 -2
- package/dist/docx/serializer/runSerializer.js +73 -44
- package/dist/docx/serializer/sectionPropertiesSerializer.js +19 -14
- package/dist/docx/serializer/settingsSerializer.js +4 -3
- package/dist/docx/serializer/stylesSerializer.js +6 -6
- package/dist/docx/serializer/tableSerializer.js +28 -17
- package/dist/docx/serializer/textFormattingSerializer.js +29 -28
- package/dist/docx/serializer/themeSerializer.js +6 -6
- package/dist/docx/serializer/trackedChangeAttributes.js +2 -2
- package/dist/docx/serializer/xmlUtils.d.ts +1 -2
- package/dist/docx/serializer/xmlUtils.js +1 -13
- package/dist/docx/server/boundedArchive.d.ts +12 -0
- package/dist/docx/server/boundedArchive.js +20 -1
- package/dist/docx/server/createBilingualDocument.js +3 -1
- package/dist/docx/server/materializeYjsDocx.d.ts +1 -1
- package/dist/docx/server/materializeYjsDocx.js +9 -1
- package/dist/docx/server/migrateYjsAttrSchema.d.ts +55 -0
- package/dist/docx/server/migrateYjsAttrSchema.js +95 -0
- package/dist/docx/server/validateDocxConformance.js +22 -1
- package/dist/docx/shapeParser.js +12 -10
- package/dist/docx/tableParser.d.ts +1 -1
- package/dist/docx/tableParser.js +206 -85
- package/dist/docx/textBoxParser.d.ts +25 -2
- package/dist/docx/textBoxParser.js +59 -4
- package/dist/docx/unzip.d.ts +23 -0
- package/dist/docx/unzip.js +37 -26
- package/dist/docx/verbatimCapture.js +1 -1
- package/dist/docx/vmlImageParser.d.ts +17 -1
- package/dist/docx/vmlImageParser.js +20 -3
- package/dist/docx/vmlPreview.d.ts +1 -3
- package/dist/docx/vmlPreview.js +2 -30
- package/dist/docx/xmlEncoding.d.ts +5 -0
- package/dist/docx/xmlEncoding.js +12 -0
- package/dist/docx/xmlParser.d.ts +26 -2
- package/dist/docx/xmlParser.js +70 -27
- package/dist/docx/xmlResourceLimits.d.ts +89 -9
- package/dist/docx/xmlResourceLimits.js +105 -24
- package/dist/headless-layout.js +10 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/internal/pageBreakRunSourceDescendantIndex.js +5 -2
- package/dist/internal/paragraphFormattingSerialization.js +3 -2
- package/dist/layout-bridge/convert/toFlowBlocks.js +102 -12
- package/dist/layout-engine/measure/tableCellFloating.d.ts +2 -0
- package/dist/layout-engine/measure/tableCellFloating.js +2 -0
- package/dist/layout-engine/types.d.ts +23 -1
- package/dist/layout-painter/renderImage.d.ts +5 -1
- package/dist/layout-painter/renderImage.js +14 -6
- package/dist/layout-painter/renderPage.d.ts +2 -0
- package/dist/layout-painter/renderPage.js +4 -0
- package/dist/layout-painter/renderParagraph.d.ts +13 -1
- package/dist/layout-painter/renderParagraph.js +26 -6
- package/dist/managers/autoSaveCodec.d.ts +9 -1
- package/dist/managers/autoSaveCodec.js +14 -12
- package/dist/markdown/images.js +1 -4
- package/dist/markdown/renderBlock.js +1 -0
- package/dist/markdown/renderRuns.d.ts +1 -1
- package/dist/markdown/renderRuns.js +28 -5
- package/dist/markdown/renderTable.js +22 -5
- package/dist/markdown/trailers.js +4 -1
- package/dist/pdf/images.js +142 -6
- package/dist/prosemirror/attrs/index.d.ts +14 -3
- package/dist/prosemirror/attrs/index.js +224 -2
- package/dist/prosemirror/authoredTransformAttrs.d.ts +28 -0
- package/dist/prosemirror/authoredTransformAttrs.js +64 -0
- package/dist/prosemirror/commands/contentControls.js +10 -2
- package/dist/prosemirror/commands/image.d.ts +9 -2
- package/dist/prosemirror/commands/image.js +43 -28
- package/dist/prosemirror/commands/pageBreak.js +1 -1
- package/dist/prosemirror/commentReferenceAttrs.d.ts +8 -0
- package/dist/prosemirror/commentReferenceAttrs.js +33 -0
- package/dist/prosemirror/commentReferenceIntegrity.d.ts +47 -0
- package/dist/prosemirror/commentReferenceIntegrity.js +43 -0
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +2 -13
- package/dist/prosemirror/conversion/fromProseDoc.js +338 -99
- package/dist/prosemirror/conversion/index.d.ts +2 -2
- package/dist/prosemirror/conversion/toProseDoc.d.ts +7 -9
- package/dist/prosemirror/conversion/toProseDoc.js +551 -327
- package/dist/prosemirror/extensions/StarterKit.js +8 -58
- package/dist/prosemirror/extensions/core/DocExtension.js +1 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +2 -1
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +45 -27
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +3 -1
- package/dist/prosemirror/extensions/features/ImagePasteExtension.js +5 -3
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +1 -0
- package/dist/prosemirror/extensions/markRegistry.d.ts +41 -0
- package/dist/prosemirror/extensions/markRegistry.js +75 -0
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +2 -3
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.d.ts +18 -0
- package/dist/prosemirror/extensions/marks/InlineWrapperExtension.js +63 -0
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +2 -1
- package/dist/prosemirror/extensions/marks/markUtils.js +47 -4
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.d.ts +11 -0
- package/dist/prosemirror/extensions/nodes/CommentReferenceExtension.js +87 -0
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +9 -7
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +20 -0
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.d.ts +32 -0
- package/dist/prosemirror/extensions/nodes/PreservedBlockExtension.js +67 -0
- package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.d.ts +16 -0
- package/dist/prosemirror/extensions/nodes/PreservedXmlExtension.js +60 -0
- package/dist/prosemirror/extensions/nodes/ShapeExtension.js +10 -2
- package/dist/prosemirror/extensions/nodes/TableExtension.js +3 -2
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +13 -5
- package/dist/prosemirror/inlineWrapperStack.d.ts +39 -0
- package/dist/prosemirror/inlineWrapperStack.js +75 -0
- package/dist/prosemirror/pageBreakRunProjection.d.ts +17 -7
- package/dist/prosemirror/pageBreakRunProjection.js +19 -9
- package/dist/prosemirror/paragraphFormattingProvenance.d.ts +6 -3
- package/dist/prosemirror/paragraphFormattingProvenance.js +12 -3
- package/dist/prosemirror/replacedAnnotations.d.ts +59 -0
- package/dist/prosemirror/replacedAnnotations.js +165 -0
- package/dist/prosemirror/runFormattingInlineCarriers.d.ts +3 -1
- package/dist/prosemirror/runFormattingInlineCarriers.js +5 -1
- package/dist/prosemirror/schema/index.d.ts +3 -3
- package/dist/prosemirror/schema/marks.d.ts +25 -1
- package/dist/prosemirror/schema/nodes.d.ts +139 -3
- package/dist/prosemirror/schema/nodes.js +16 -1
- package/dist/prosemirror/trackedRunInlineAtoms.d.ts +2 -0
- package/dist/prosemirror/trackedRunInlineAtoms.js +2 -0
- package/dist/prosemirror/validation.js +16 -2
- package/dist/prosemirror/yjsDocumentMetadata.d.ts +73 -0
- package/dist/prosemirror/yjsDocumentMetadata.js +171 -0
- package/dist/prosemirror/zeroWidthAnchors.js +2 -0
- package/dist/render-dom/commentAnchorAttributes.d.ts +37 -0
- package/dist/render-dom/commentAnchorAttributes.js +54 -0
- package/dist/server.d.ts +3 -1
- package/dist/server.js +3 -1
- package/dist/types/content.d.ts +2 -2
- package/dist/utils/base64.d.ts +36 -0
- package/dist/utils/base64.js +40 -0
- package/dist/utils/clipboard.d.ts +9 -1
- package/dist/utils/clipboard.js +29 -2
- package/dist/utils/findReplace.js +1 -1
- package/dist/utils/imageLuminance.d.ts +15 -0
- package/dist/utils/imageLuminance.js +32 -0
- package/dist/utils/mergeDocumentContent.js +7 -17
- package/dist/utils/replaceText.js +1 -0
- package/dist/utils/units.d.ts +10 -1
- package/dist/utils/units.js +12 -1
- package/dist/utils/urlSecurity.d.ts +8 -2
- package/dist/utils/urlSecurity.js +21 -3
- package/package.json +2 -2
- package/dist/docx/blockRangeMarkers.d.ts +0 -36
- package/dist/docx/blockRangeMarkers.js +0 -59
- package/dist/prosemirror/yjsParagraphSourceContract.d.ts +0 -9
- package/dist/prosemirror/yjsParagraphSourceContract.js +0 -26
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { applyAttrSchemaMigrations, readYjsAttrSchemaVersion } from "../../prosemirror/yjsDocumentMetadata.js";
|
|
2
|
+
import { FOLIO_YJS_PROSEMIRROR_FRAGMENT_NAME } from "./materializeYjsDocx.js";
|
|
3
|
+
import { Result, TaggedError } from "better-result";
|
|
4
|
+
import * as Y from "yjs";
|
|
5
|
+
//#region src/docx/server/migrateYjsAttrSchema.ts
|
|
6
|
+
/** Stable failure codes returned by an offline snapshot migration. */
|
|
7
|
+
const FOLIO_YJS_SNAPSHOT_MIGRATION_ERROR_CODES = [
|
|
8
|
+
"invalid_update",
|
|
9
|
+
"unsupported_version",
|
|
10
|
+
"update_too_large"
|
|
11
|
+
];
|
|
12
|
+
/** Typed failure raised when a collaboration snapshot cannot be migrated. */
|
|
13
|
+
var FolioYjsSnapshotMigrationError = class extends TaggedError("FolioYjsSnapshotMigrationError") {};
|
|
14
|
+
/**
|
|
15
|
+
* Carry a stored collaboration snapshot forward to the attr schema this build
|
|
16
|
+
* writes, without a ProseMirror schema and without rebuilding a single node.
|
|
17
|
+
*
|
|
18
|
+
* A Yjs XML element's attributes are ordinary CRDT map entries holding JSON, so
|
|
19
|
+
* {@link applyAttrSchemaMigrations} rewrites values in the fragment directly.
|
|
20
|
+
* Nothing here can trip y-prosemirror's node rebuild, which deletes an element
|
|
21
|
+
* it fails to construct. The function is pure and offline: no network, no
|
|
22
|
+
* DOCX, no editor.
|
|
23
|
+
*
|
|
24
|
+
* A snapshot already at the current version is returned byte for byte, so a
|
|
25
|
+
* host may run this over its whole corpus repeatedly.
|
|
26
|
+
*
|
|
27
|
+
* **The contract a reseed must respect.** This function never reseeds and never
|
|
28
|
+
* touches the paragraph-source contract: it preserves whichever source binding
|
|
29
|
+
* the snapshot already carries. A reseed does the opposite, and Folio holds it
|
|
30
|
+
* to one rule: *the DOCX handed to the seeding editor must be the same bytes
|
|
31
|
+
* the host will later pass to `materializeYjsDocx` as that room's source*.
|
|
32
|
+
* The contract is a digest of those bytes, so seeding from one document while
|
|
33
|
+
* recording another as the room's source makes every later save fail with
|
|
34
|
+
* `source_mismatch`. The reverse mistake is worse and Folio cannot see it: a
|
|
35
|
+
* host that reseeds from the document a room was *created* from, rather than
|
|
36
|
+
* from the latest content it published, produces a perfectly well-formed
|
|
37
|
+
* snapshot whose collaborative history has been replaced by an older document.
|
|
38
|
+
* Rebind the recorded source in the same statement that clears the seed, or do
|
|
39
|
+
* not clear it.
|
|
40
|
+
*/
|
|
41
|
+
const migrateFolioYjsSnapshot = (update) => {
|
|
42
|
+
if (update.byteLength === 0) return Result.err(new FolioYjsSnapshotMigrationError({
|
|
43
|
+
code: "invalid_update",
|
|
44
|
+
message: "Cannot migrate an empty Yjs update."
|
|
45
|
+
}));
|
|
46
|
+
if (update.byteLength > 10485760) return Result.err(new FolioYjsSnapshotMigrationError({
|
|
47
|
+
code: "update_too_large",
|
|
48
|
+
message: "Yjs update exceeds the snapshot migration limit."
|
|
49
|
+
}));
|
|
50
|
+
const ydoc = new Y.Doc();
|
|
51
|
+
const applied = Result.try({
|
|
52
|
+
try: () => {
|
|
53
|
+
Y.applyUpdate(ydoc, update);
|
|
54
|
+
},
|
|
55
|
+
catch: (cause) => new FolioYjsSnapshotMigrationError({
|
|
56
|
+
cause,
|
|
57
|
+
code: "invalid_update",
|
|
58
|
+
message: "Yjs update is not a valid Folio collaboration snapshot."
|
|
59
|
+
})
|
|
60
|
+
});
|
|
61
|
+
if (applied.isErr()) {
|
|
62
|
+
ydoc.destroy();
|
|
63
|
+
return Result.err(applied.error);
|
|
64
|
+
}
|
|
65
|
+
const read = readYjsAttrSchemaVersion(ydoc);
|
|
66
|
+
if (read.isErr()) {
|
|
67
|
+
ydoc.destroy();
|
|
68
|
+
return Result.err(new FolioYjsSnapshotMigrationError({
|
|
69
|
+
cause: read.error,
|
|
70
|
+
code: "unsupported_version",
|
|
71
|
+
message: read.error.message
|
|
72
|
+
}));
|
|
73
|
+
}
|
|
74
|
+
const fromVersion = read.value;
|
|
75
|
+
if (fromVersion === 3) {
|
|
76
|
+
ydoc.destroy();
|
|
77
|
+
return Result.ok({
|
|
78
|
+
fromVersion,
|
|
79
|
+
paragraphsRewritten: 0,
|
|
80
|
+
toVersion: 3,
|
|
81
|
+
update
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
const paragraphsRewritten = applyAttrSchemaMigrations(ydoc, ydoc.getXmlFragment(FOLIO_YJS_PROSEMIRROR_FRAGMENT_NAME), fromVersion);
|
|
85
|
+
const migrated = Y.encodeStateAsUpdate(ydoc);
|
|
86
|
+
ydoc.destroy();
|
|
87
|
+
return Result.ok({
|
|
88
|
+
fromVersion,
|
|
89
|
+
paragraphsRewritten,
|
|
90
|
+
toVersion: 3,
|
|
91
|
+
update: migrated
|
|
92
|
+
});
|
|
93
|
+
};
|
|
94
|
+
//#endregion
|
|
95
|
+
export { FOLIO_YJS_SNAPSHOT_MIGRATION_ERROR_CODES, FolioYjsSnapshotMigrationError, migrateFolioYjsSnapshot };
|
|
@@ -3,6 +3,7 @@ import { DOCX_CONTAINER_TYPES, detectDocxContainerType } from "../encryption/con
|
|
|
3
3
|
import { DocxModelValidationError, validateFolioDocumentModel } from "../modelValidation.js";
|
|
4
4
|
import { DocxParseError, parseDocx } from "../parser.js";
|
|
5
5
|
import { findChildByLocalName, getAttributeAnyPrefix, getLocalName, getNamespacePrefix, parseXmlDocument } from "../xmlParser.js";
|
|
6
|
+
import { XmlResourceLimitError } from "../xmlResourceLimits.js";
|
|
6
7
|
import { getDocxXmlSafetyIssue } from "../xmlSafety.js";
|
|
7
8
|
import { DocxArchiveError, loadDocxArchive } from "./boundedArchive.js";
|
|
8
9
|
import { DOCX_CONFORMANCE_CLASSES } from "@stll/docx-core/model";
|
|
@@ -112,11 +113,31 @@ const XML_SAFETY_ISSUE = {
|
|
|
112
113
|
message: "An XML package part is not well formed."
|
|
113
114
|
}
|
|
114
115
|
};
|
|
116
|
+
/**
|
|
117
|
+
* Read a part for inspection, including one the safe reader declines.
|
|
118
|
+
*
|
|
119
|
+
* `readEntryString` runs the XML structure preflight, and the preflight
|
|
120
|
+
* refuses to scan markup it cannot count — a document type declaration, an
|
|
121
|
+
* unterminated tag — which is exactly the markup this check exists to report.
|
|
122
|
+
* Such a part is read raw and classified below, so the report names why the
|
|
123
|
+
* package is invalid instead of saying it could not tell. A part that overran
|
|
124
|
+
* a real bound still refuses, and the caller reports that as indeterminate,
|
|
125
|
+
* because a package too large to scan is not a package known to be wrong.
|
|
126
|
+
*/
|
|
127
|
+
const readPartForInspection = async (archive, part) => {
|
|
128
|
+
try {
|
|
129
|
+
return await archive.readEntryString(part);
|
|
130
|
+
} catch (error) {
|
|
131
|
+
if (!(error instanceof XmlResourceLimitError) || error.limit !== "syntax") throw error;
|
|
132
|
+
const bytes = await archive.readEntryUint8(part);
|
|
133
|
+
return bytes === null ? null : new TextDecoder("utf-8", { ignoreBOM: true }).decode(bytes);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
115
136
|
const validateXmlParts = async (archive, report) => {
|
|
116
137
|
const xmlByPath = /* @__PURE__ */ new Map();
|
|
117
138
|
let hasInvalidXml = false;
|
|
118
139
|
for (const part of archive.entries.filter((path) => XML_PART_PATTERN.test(path)).toSorted()) {
|
|
119
|
-
const xml = await archive
|
|
140
|
+
const xml = await readPartForInspection(archive, part);
|
|
120
141
|
if (xml === null) continue;
|
|
121
142
|
xmlByPath.set(part, xml);
|
|
122
143
|
const safetyIssue = getDocxXmlSafetyIssue(xml);
|
package/dist/docx/shapeParser.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { parseAnchorPosition, parseAnchorWrap, parseFill, parseOutline } from "./drawingUtils.js";
|
|
2
|
+
import { parseNonVisualDrawingNames } from "./nonVisualDrawingProps.js";
|
|
2
3
|
import { ShapeTypeSchema, narrowEnum } from "./parserEnums.js";
|
|
3
4
|
import { findAllDeep, findChildByLocalName, findChildren, getAttribute, getChildElements, parseNumericAttribute, parseOnOffAttribute } from "./xmlParser.js";
|
|
4
5
|
//#region src/docx/shapeParser.ts
|
|
@@ -26,13 +27,13 @@ function parseTransform(xfrm) {
|
|
|
26
27
|
height: parseNumericAttribute(ext, null, "cy") ?? 0
|
|
27
28
|
};
|
|
28
29
|
const rotation = rotToDegrees(getAttribute(xfrm, null, "rot"));
|
|
29
|
-
const flipH = parseOnOffAttribute(xfrm, null, "flipH")
|
|
30
|
-
const flipV = parseOnOffAttribute(xfrm, null, "flipV")
|
|
31
|
-
if (rotation === void 0 &&
|
|
30
|
+
const flipH = parseOnOffAttribute(xfrm, null, "flipH");
|
|
31
|
+
const flipV = parseOnOffAttribute(xfrm, null, "flipV");
|
|
32
|
+
if (rotation === void 0 && flipH === void 0 && flipV === void 0) return { size };
|
|
32
33
|
const transform = {};
|
|
33
34
|
if (rotation !== void 0) transform.rotation = rotation;
|
|
34
|
-
if (flipH) transform.flipH =
|
|
35
|
-
if (flipV) transform.flipV =
|
|
35
|
+
if (flipH !== void 0) transform.flipH = flipH;
|
|
36
|
+
if (flipV !== void 0) transform.flipV = flipV;
|
|
36
37
|
return {
|
|
37
38
|
size,
|
|
38
39
|
transform
|
|
@@ -139,16 +140,15 @@ function parseShape(node) {
|
|
|
139
140
|
const fill = parseShapeFill(spPr);
|
|
140
141
|
const outline = parseOutline(spPr);
|
|
141
142
|
const id = cNvPr ? getAttribute(cNvPr, null, "id") ?? void 0 : void 0;
|
|
142
|
-
const name = cNvPr ? getAttribute(cNvPr, null, "name") ?? void 0 : void 0;
|
|
143
143
|
const shape = {
|
|
144
144
|
type: "shape",
|
|
145
145
|
shapeType,
|
|
146
|
-
size
|
|
146
|
+
size,
|
|
147
|
+
...parseNonVisualDrawingNames(cNvPr)
|
|
147
148
|
};
|
|
148
149
|
const geometryAdjustments = parseGeometryAdjustments(spPr);
|
|
149
150
|
if (geometryAdjustments !== void 0) shape.geometryAdjustments = geometryAdjustments;
|
|
150
151
|
if (id !== void 0) shape.id = id;
|
|
151
|
-
if (name !== void 0) shape.name = name;
|
|
152
152
|
if (fill !== void 0) shape.fill = fill;
|
|
153
153
|
if (outline !== void 0) shape.outline = outline;
|
|
154
154
|
if (transform !== void 0) shape.transform = transform;
|
|
@@ -193,9 +193,11 @@ function parseShapeFromDrawing(drawingEl) {
|
|
|
193
193
|
const docPr = findChildByLocalName(container, "docPr");
|
|
194
194
|
if (docPr) {
|
|
195
195
|
const id = getAttribute(docPr, null, "id");
|
|
196
|
-
const name = getAttribute(docPr, null, "name");
|
|
197
196
|
if (id !== null) shape.id = id;
|
|
198
|
-
|
|
197
|
+
const names = parseNonVisualDrawingNames(docPr);
|
|
198
|
+
if (names.name !== void 0) shape.name = names.name;
|
|
199
|
+
if (names.alt !== void 0) shape.alt = names.alt;
|
|
200
|
+
if (names.title !== void 0) shape.title = names.title;
|
|
199
201
|
}
|
|
200
202
|
return shape;
|
|
201
203
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
2
|
import { NumberingMap } from "./numberingParser.js";
|
|
3
|
-
import { StyleMap } from "./styleParser.js";
|
|
4
3
|
import { XmlElement } from "./xmlParser.js";
|
|
4
|
+
import { StyleMap } from "./styleParser.js";
|
|
5
5
|
//#region src/docx/tableParser.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* Sanity cap on `w:gridSpan` (and the derived table column count). Word's
|
package/dist/docx/tableParser.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NO_MODELLED_ATTRIBUTES, attributeRemainder } from "./attributeRemainder.js";
|
|
2
2
|
import { parseBookmarkEnd, parseBookmarkStart } from "./bookmarkParser.js";
|
|
3
3
|
import { appendBookmarkMarkerToLastParagraphInBlocks, appendBookmarkMarkerToLastParagraphInCells, prependBookmarkMarkersToFirstParagraphInBlocks, prependBookmarkMarkersToFirstParagraphInCell } from "./bookmarkPlacement.js";
|
|
4
4
|
import { parseBorderSpec } from "./borderParser.js";
|
|
5
|
+
import { CAPTURE, OWNED_ELSEWHERE, dispatchChildren, withPreservedChildren } from "./containerChildren.js";
|
|
5
6
|
import { parseParagraph } from "./paragraphParser.js";
|
|
6
7
|
import { enrichParagraphTextBoxes } from "./paragraphTextBoxEnrichment.js";
|
|
7
8
|
import { FloatingTableXSpecSchema, FloatingTableYSpecSchema, TableCellTextDirectionSchema, narrowEnum } from "./parserEnums.js";
|
|
@@ -10,7 +11,7 @@ import { TABLE_LOOK_FLAGS } from "./tableLook.js";
|
|
|
10
11
|
import { parsePropertyChangeInfo, parseTrackedChangeInfo } from "./trackedChangeInfo.js";
|
|
11
12
|
import { percentageSpelling, transitionalSlotEncoding } from "./transitionalSpelling.js";
|
|
12
13
|
import { captureVerbatimXml } from "./verbatimCapture.js";
|
|
13
|
-
import { cloneElement, findChild, findChildByLocalName, findChildren, getAttribute,
|
|
14
|
+
import { cloneElement, findChild, findChildByLocalName, findChildren, getAttribute, getLocalName, mergeXmlnsDeclarations, parseBooleanElement, parseNumericAttribute, parseOnOffAttribute, parseTableMeasurementValue, selectAlternateContentBranch } from "./xmlParser.js";
|
|
14
15
|
//#region src/docx/tableParser.ts
|
|
15
16
|
/**
|
|
16
17
|
* Sanity cap on `w:gridSpan` (and the derived table column count). Word's
|
|
@@ -472,59 +473,87 @@ function withContainerXmlns(options, element) {
|
|
|
472
473
|
};
|
|
473
474
|
}
|
|
474
475
|
function parseCellContent(tcElement, styles, theme, numbering, rels, media, options) {
|
|
475
|
-
const
|
|
476
|
+
const modelled = [];
|
|
476
477
|
const pendingBookmarkMarkers = [];
|
|
477
|
-
const
|
|
478
|
-
const
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
478
|
+
const captured = [];
|
|
479
|
+
const dispatchCellChildren = (element, childOptions) => {
|
|
480
|
+
const preserved = dispatchChildren({
|
|
481
|
+
element,
|
|
482
|
+
container: "block-content",
|
|
483
|
+
modelledCount: () => modelled.length,
|
|
484
|
+
undeclared: { AlternateContent: (child) => {
|
|
485
|
+
const selectedBranch = selectAlternateContentBranch(child);
|
|
486
|
+
if (!selectedBranch) return;
|
|
487
|
+
dispatchCellChildren(selectedBranch, withContainerXmlns(withContainerXmlns(childOptions, child), selectedBranch));
|
|
488
|
+
} },
|
|
489
|
+
handlers: {
|
|
490
|
+
p: (child) => {
|
|
491
|
+
const para = parseParagraph(child, styles, theme, numbering, rels, media, childOptions);
|
|
492
|
+
enrichParagraphTextBoxes(para, child, styles, theme, numbering, rels, media, parseTable);
|
|
493
|
+
prependPendingBookmarkMarkers(para, pendingBookmarkMarkers);
|
|
494
|
+
modelled.push(para);
|
|
495
|
+
},
|
|
496
|
+
tbl: (child) => {
|
|
497
|
+
const table = parseTable(child, styles, theme, numbering, rels, media, childOptions);
|
|
498
|
+
if (!table) return;
|
|
499
|
+
if (prependBookmarkMarkersToFirstParagraphInBlocks([table], pendingBookmarkMarkers)) pendingBookmarkMarkers.length = 0;
|
|
500
|
+
modelled.push(table);
|
|
501
|
+
},
|
|
502
|
+
sdt: (child) => {
|
|
503
|
+
const sdtContent = findChildByLocalName(child, "sdtContent");
|
|
504
|
+
if (!sdtContent) return;
|
|
505
|
+
dispatchCellChildren(sdtContent, withContainerXmlns(withContainerXmlns(childOptions, child), sdtContent));
|
|
506
|
+
},
|
|
507
|
+
bookmarkStart: (child) => {
|
|
508
|
+
collectCellBookmarkMarker(child, "bookmarkStart", modelled, pendingBookmarkMarkers);
|
|
509
|
+
},
|
|
510
|
+
bookmarkEnd: (child) => {
|
|
511
|
+
collectCellBookmarkMarker(child, "bookmarkEnd", modelled, pendingBookmarkMarkers);
|
|
512
|
+
},
|
|
513
|
+
tcPr: OWNED_ELSEWHERE,
|
|
514
|
+
sectPr: CAPTURE,
|
|
515
|
+
altChunk: CAPTURE,
|
|
516
|
+
commentRangeEnd: CAPTURE,
|
|
517
|
+
commentRangeStart: CAPTURE,
|
|
518
|
+
customXml: CAPTURE,
|
|
519
|
+
customXmlDelRangeEnd: CAPTURE,
|
|
520
|
+
customXmlDelRangeStart: CAPTURE,
|
|
521
|
+
customXmlInsRangeEnd: CAPTURE,
|
|
522
|
+
customXmlInsRangeStart: CAPTURE,
|
|
523
|
+
customXmlMoveFromRangeEnd: CAPTURE,
|
|
524
|
+
customXmlMoveFromRangeStart: CAPTURE,
|
|
525
|
+
customXmlMoveToRangeEnd: CAPTURE,
|
|
526
|
+
customXmlMoveToRangeStart: CAPTURE,
|
|
527
|
+
del: CAPTURE,
|
|
528
|
+
ins: CAPTURE,
|
|
529
|
+
moveFrom: CAPTURE,
|
|
530
|
+
moveFromRangeEnd: CAPTURE,
|
|
531
|
+
moveFromRangeStart: CAPTURE,
|
|
532
|
+
moveTo: CAPTURE,
|
|
533
|
+
moveToRangeEnd: CAPTURE,
|
|
534
|
+
moveToRangeStart: CAPTURE,
|
|
535
|
+
permEnd: CAPTURE,
|
|
536
|
+
permStart: CAPTURE,
|
|
537
|
+
proofErr: CAPTURE
|
|
538
|
+
}
|
|
539
|
+
});
|
|
540
|
+
if (preserved?.children) captured.push(...preserved.children);
|
|
518
541
|
};
|
|
519
|
-
|
|
520
|
-
if (
|
|
542
|
+
dispatchCellChildren(tcElement, options);
|
|
543
|
+
if (modelled.length === 0) modelled.push({
|
|
521
544
|
type: "paragraph",
|
|
522
545
|
content: [...pendingBookmarkMarkers]
|
|
523
546
|
});
|
|
524
|
-
else if (pendingBookmarkMarkers.length > 0) appendBookmarkMarkersToLastParagraphInBlocks(
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
547
|
+
else if (pendingBookmarkMarkers.length > 0) appendBookmarkMarkersToLastParagraphInBlocks(modelled, pendingBookmarkMarkers);
|
|
548
|
+
return withPreservedChildren(modelled, { children: captured }, (xml) => ({
|
|
549
|
+
type: "preservedBlock",
|
|
550
|
+
xml
|
|
551
|
+
}));
|
|
552
|
+
}
|
|
553
|
+
const collectCellBookmarkMarker = (child, localName, content, pending) => {
|
|
554
|
+
const marker = parseBookmarkMarker(child, localName);
|
|
555
|
+
if (!appendBookmarkMarkerToLastParagraphInBlocks(content, marker)) pending.push(marker);
|
|
556
|
+
};
|
|
528
557
|
/**
|
|
529
558
|
* Parse a table cell (w:tc)
|
|
530
559
|
*
|
|
@@ -576,29 +605,79 @@ function parseTableRow(trElement, styles, theme, numbering, rels, media, options
|
|
|
576
605
|
if (rowStructChange !== void 0) row.structuralChange = rowStructChange;
|
|
577
606
|
const rowOptions = withContainerXmlns(options, trElement);
|
|
578
607
|
const pendingBookmarkMarkers = [];
|
|
579
|
-
const
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
608
|
+
const preservedChildren = [];
|
|
609
|
+
/**
|
|
610
|
+
* One row's children, or a row-level content control's.
|
|
611
|
+
*
|
|
612
|
+
* folio unwraps `w:sdt` here and splices its rows' content into the row, so
|
|
613
|
+
* the recursion walks the control's content with the same map; the sink is
|
|
614
|
+
* the row's either way, because the control keeps no wrapper to hold one.
|
|
615
|
+
*/
|
|
616
|
+
const dispatchRowChildren = (element, childOptions) => {
|
|
617
|
+
const captured = dispatchChildren({
|
|
618
|
+
element,
|
|
619
|
+
container: "row-content",
|
|
620
|
+
modelledCount: () => row.cells.length,
|
|
621
|
+
handlers: {
|
|
622
|
+
tc: (child) => {
|
|
623
|
+
const cell = parseTableCell(child, styles, theme, numbering, rels, media, childOptions);
|
|
624
|
+
if (pendingBookmarkMarkers.length > 0) {
|
|
625
|
+
prependBookmarkMarkersToFirstParagraphInCell(cell, pendingBookmarkMarkers);
|
|
626
|
+
pendingBookmarkMarkers.length = 0;
|
|
627
|
+
}
|
|
628
|
+
row.cells.push(cell);
|
|
629
|
+
},
|
|
630
|
+
sdt: (child) => {
|
|
631
|
+
const sdtContent = findChildByLocalName(child, "sdtContent");
|
|
632
|
+
if (!sdtContent) return;
|
|
633
|
+
const sdtOptions = withContainerXmlns(childOptions, child);
|
|
634
|
+
dispatchRowChildren(sdtContent, withContainerXmlns(sdtOptions, sdtContent));
|
|
635
|
+
},
|
|
636
|
+
bookmarkStart: (child) => {
|
|
637
|
+
placeBookmarkMarker(parseBookmarkStart(child));
|
|
638
|
+
},
|
|
639
|
+
bookmarkEnd: (child) => {
|
|
640
|
+
placeBookmarkMarker(parseBookmarkEnd(child));
|
|
641
|
+
},
|
|
642
|
+
trPr: OWNED_ELSEWHERE,
|
|
643
|
+
tblPrEx: OWNED_ELSEWHERE,
|
|
644
|
+
commentRangeEnd: CAPTURE,
|
|
645
|
+
commentRangeStart: CAPTURE,
|
|
646
|
+
customXml: CAPTURE,
|
|
647
|
+
customXmlDelRangeEnd: CAPTURE,
|
|
648
|
+
customXmlDelRangeStart: CAPTURE,
|
|
649
|
+
customXmlInsRangeEnd: CAPTURE,
|
|
650
|
+
customXmlInsRangeStart: CAPTURE,
|
|
651
|
+
customXmlMoveFromRangeEnd: CAPTURE,
|
|
652
|
+
customXmlMoveFromRangeStart: CAPTURE,
|
|
653
|
+
customXmlMoveToRangeEnd: CAPTURE,
|
|
654
|
+
customXmlMoveToRangeStart: CAPTURE,
|
|
655
|
+
del: CAPTURE,
|
|
656
|
+
ins: CAPTURE,
|
|
657
|
+
moveFrom: CAPTURE,
|
|
658
|
+
moveFromRangeEnd: CAPTURE,
|
|
659
|
+
moveFromRangeStart: CAPTURE,
|
|
660
|
+
moveTo: CAPTURE,
|
|
661
|
+
moveToRangeEnd: CAPTURE,
|
|
662
|
+
moveToRangeStart: CAPTURE,
|
|
663
|
+
permEnd: CAPTURE,
|
|
664
|
+
permStart: CAPTURE,
|
|
665
|
+
proofErr: CAPTURE,
|
|
666
|
+
tr: CAPTURE
|
|
586
667
|
}
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
const sdtContent = findChildByLocalName(child, "sdtContent");
|
|
592
|
-
if (!sdtContent) return;
|
|
593
|
-
const sdtContentOptions = withContainerXmlns(withContainerXmlns(childOptions, child), sdtContent);
|
|
594
|
-
for (const sdtChild of getChildElements(sdtContent)) parseRowChild(sdtChild, sdtContentOptions);
|
|
595
|
-
return;
|
|
596
|
-
}
|
|
597
|
-
if (localName !== "bookmarkStart" && localName !== "bookmarkEnd") return;
|
|
598
|
-
const marker = parseBookmarkMarker(child, localName);
|
|
668
|
+
});
|
|
669
|
+
if (captured?.children) preservedChildren.push(...captured.children);
|
|
670
|
+
};
|
|
671
|
+
const placeBookmarkMarker = (marker) => {
|
|
599
672
|
if (!appendBookmarkMarkerToLastParagraphInCells(row.cells, marker)) pendingBookmarkMarkers.push(marker);
|
|
600
673
|
};
|
|
601
|
-
|
|
674
|
+
dispatchRowChildren(trElement, rowOptions);
|
|
675
|
+
if (preservedChildren.length > 0) row.preserved = { children: preservedChildren };
|
|
676
|
+
const remainingAttributes = attributeRemainder({
|
|
677
|
+
element: trElement,
|
|
678
|
+
modelled: NO_MODELLED_ATTRIBUTES
|
|
679
|
+
});
|
|
680
|
+
if (remainingAttributes) row.preservedAttributes = remainingAttributes;
|
|
602
681
|
if (pendingBookmarkMarkers.length > 0) appendBookmarkMarkersToLastCell(row, pendingBookmarkMarkers);
|
|
603
682
|
return row;
|
|
604
683
|
}
|
|
@@ -707,23 +786,65 @@ function parseTable(tblElement, styles, theme, numbering, rels, media, options)
|
|
|
707
786
|
}
|
|
708
787
|
const tableOptions = withContainerXmlns(options, tblElement);
|
|
709
788
|
const rowsWithGridOffsets = /* @__PURE__ */ new Set();
|
|
710
|
-
const
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
789
|
+
const preservedChildren = [];
|
|
790
|
+
/**
|
|
791
|
+
* One table's children, or a row-level content control's.
|
|
792
|
+
*
|
|
793
|
+
* folio unwraps `w:sdt` here and splices its rows into the table, so the
|
|
794
|
+
* recursion walks the control's content with the same map; the sink is the
|
|
795
|
+
* table's either way, because the control keeps no wrapper to hold one.
|
|
796
|
+
*/
|
|
797
|
+
const dispatchTableChildren = (element, childOptions) => {
|
|
798
|
+
const captured = dispatchChildren({
|
|
799
|
+
element,
|
|
800
|
+
container: "table-content",
|
|
801
|
+
modelledCount: () => table.rows.length,
|
|
802
|
+
handlers: {
|
|
803
|
+
tr: (child) => {
|
|
804
|
+
const rowIndex = table.rows.length;
|
|
805
|
+
table.rows.push(parseTableRow(child, styles, theme, numbering, rels, media, childOptions));
|
|
806
|
+
if (hasRowGridOffsets(child)) rowsWithGridOffsets.add(rowIndex);
|
|
807
|
+
},
|
|
808
|
+
sdt: (child) => {
|
|
809
|
+
const sdtContent = findChildByLocalName(child, "sdtContent");
|
|
810
|
+
if (!sdtContent) return;
|
|
811
|
+
const sdtOptions = withContainerXmlns(childOptions, child);
|
|
812
|
+
dispatchTableChildren(sdtContent, withContainerXmlns(sdtOptions, sdtContent));
|
|
813
|
+
},
|
|
814
|
+
tblPr: OWNED_ELSEWHERE,
|
|
815
|
+
tblGrid: OWNED_ELSEWHERE,
|
|
816
|
+
bookmarkEnd: CAPTURE,
|
|
817
|
+
bookmarkStart: CAPTURE,
|
|
818
|
+
commentRangeEnd: CAPTURE,
|
|
819
|
+
commentRangeStart: CAPTURE,
|
|
820
|
+
customXml: CAPTURE,
|
|
821
|
+
customXmlPr: CAPTURE,
|
|
822
|
+
customXmlDelRangeEnd: CAPTURE,
|
|
823
|
+
customXmlDelRangeStart: CAPTURE,
|
|
824
|
+
customXmlInsRangeEnd: CAPTURE,
|
|
825
|
+
customXmlInsRangeStart: CAPTURE,
|
|
826
|
+
customXmlMoveFromRangeEnd: CAPTURE,
|
|
827
|
+
customXmlMoveFromRangeStart: CAPTURE,
|
|
828
|
+
customXmlMoveToRangeEnd: CAPTURE,
|
|
829
|
+
customXmlMoveToRangeStart: CAPTURE,
|
|
830
|
+
del: CAPTURE,
|
|
831
|
+
ins: CAPTURE,
|
|
832
|
+
moveFrom: CAPTURE,
|
|
833
|
+
moveFromRangeEnd: CAPTURE,
|
|
834
|
+
moveFromRangeStart: CAPTURE,
|
|
835
|
+
moveTo: CAPTURE,
|
|
836
|
+
moveToRangeEnd: CAPTURE,
|
|
837
|
+
moveToRangeStart: CAPTURE,
|
|
838
|
+
permEnd: CAPTURE,
|
|
839
|
+
permStart: CAPTURE,
|
|
840
|
+
proofErr: CAPTURE
|
|
841
|
+
}
|
|
842
|
+
});
|
|
843
|
+
if (captured?.children) preservedChildren.push(...captured.children);
|
|
724
844
|
};
|
|
725
|
-
|
|
845
|
+
dispatchTableChildren(tblElement, tableOptions);
|
|
726
846
|
if (table.rows.length === 0) return;
|
|
847
|
+
if (preservedChildren.length > 0) table.preserved = { children: preservedChildren };
|
|
727
848
|
inferImplicitSingleCellRowSpans(table, rowsWithGridOffsets);
|
|
728
849
|
return table;
|
|
729
850
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
2
|
import { NumberingMap } from "./numberingParser.js";
|
|
3
|
-
import { StyleMap } from "./styleParser.js";
|
|
4
3
|
import { XmlElement } from "./xmlParser.js";
|
|
4
|
+
import { StyleMap } from "./styleParser.js";
|
|
5
5
|
//#region src/docx/textBoxParser.d.ts
|
|
6
6
|
/**
|
|
7
7
|
* Extract raw paragraph elements from w:txbxContent
|
|
@@ -112,5 +112,28 @@ declare function resolveTextBoxOutlineColor(textBox: document_d_exports.TextBox)
|
|
|
112
112
|
* Get outline width in pixels
|
|
113
113
|
*/
|
|
114
114
|
declare function getTextBoxOutlineWidthPx(textBox: document_d_exports.TextBox): number;
|
|
115
|
+
type TextBoxRunScan = {
|
|
116
|
+
textBoxDrawings: XmlElement[];
|
|
117
|
+
vmlTextBoxes: XmlElement[];
|
|
118
|
+
hasNonTextBoxContent: boolean;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* What a run's markup holds for the text-box pass, by kind.
|
|
122
|
+
*
|
|
123
|
+
* Two readers need this answer and they must not drift: the enrichment pass
|
|
124
|
+
* claims these elements, and `parseParagraphContents` has to keep the run they
|
|
125
|
+
* sit in even though the run parses to nothing until the pass fills it. It
|
|
126
|
+
* lives here, with `isTextBoxDrawing` and `parseTextBox`, so there is one.
|
|
127
|
+
*/
|
|
128
|
+
type ScanRunForTextBoxDrawingsOptions = {
|
|
129
|
+
xmlRun: XmlElement;
|
|
130
|
+
/**
|
|
131
|
+
* `isVmlPictParsedByRunParser`, passed rather than imported: the run parser
|
|
132
|
+
* reaches this module through the image parsers, so reading it from here
|
|
133
|
+
* would close a cycle.
|
|
134
|
+
*/
|
|
135
|
+
claimedByRunParser: (pictElement: XmlElement) => boolean;
|
|
136
|
+
};
|
|
137
|
+
declare const scanRunForTextBoxDrawings: ({ xmlRun, claimedByRunParser }: ScanRunForTextBoxDrawingsOptions) => TextBoxRunScan;
|
|
115
138
|
//#endregion
|
|
116
|
-
export { ParagraphParserFn, TableParserFn, extractTextBoxContentElements, getTextBoxContentElement, getTextBoxDimensionsPx, getTextBoxHeightPx, getTextBoxMarginsPx, getTextBoxOutlineWidthPx, getTextBoxText, getTextBoxWidthPx, hasTextBoxContent, hasTextBoxFill, hasTextBoxOutline, isFloatingTextBox, isShapeTextBox, isTextBoxDrawing, parseTextBox, parseTextBoxContent, parseTextBoxFromShape, resolveTextBoxFillColor, resolveTextBoxOutlineColor };
|
|
139
|
+
export { ParagraphParserFn, ScanRunForTextBoxDrawingsOptions, TableParserFn, TextBoxRunScan, extractTextBoxContentElements, getTextBoxContentElement, getTextBoxDimensionsPx, getTextBoxHeightPx, getTextBoxMarginsPx, getTextBoxOutlineWidthPx, getTextBoxText, getTextBoxWidthPx, hasTextBoxContent, hasTextBoxFill, hasTextBoxOutline, isFloatingTextBox, isShapeTextBox, isTextBoxDrawing, parseTextBox, parseTextBoxContent, parseTextBoxFromShape, resolveTextBoxFillColor, resolveTextBoxOutlineColor, scanRunForTextBoxDrawings };
|