@stll/folio-core 0.15.0 → 0.15.1
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 +2 -2
- package/dist/ai-edits/blockRange.d.ts +3 -17
- package/dist/ai-edits/clean-text.d.ts +0 -1
- package/dist/ai-edits/headless.d.ts +23 -19
- package/dist/ai-edits/read.d.ts +8 -5
- package/dist/ai-edits/scoped-reading.d.ts +0 -1
- package/dist/ai-edits/snapshot.d.ts +1 -7
- package/dist/ai-edits/table-cell-mutations.d.ts +4 -31
- package/dist/ai-edits/table-row-column-mutations.d.ts +9 -39
- package/dist/ai-edits/table-targets.d.ts +0 -1
- package/dist/ai-edits/types.d.ts +32 -17
- package/dist/ai-suggestions/apply.d.ts +0 -1
- package/dist/ai-suggestions/conflict.d.ts +0 -1
- package/dist/ai-suggestions/text-positions.d.ts +2 -2
- package/dist/ai-suggestions/types.d.ts +27 -13
- package/dist/content-controls/errors.d.ts +0 -1
- package/dist/content-controls/findContentControls.d.ts +6 -4
- package/dist/content-controls/mutateContentControls.d.ts +0 -1
- package/dist/controller/activeEditorStory.d.ts +1 -6
- package/dist/controller/collaborationModules.d.ts +0 -1
- package/dist/controller/contentControlWidgetController.d.ts +0 -1
- package/dist/controller/folioEditor.d.ts +2 -2
- package/dist/controller/folioEditorEvents.d.ts +5 -3
- package/dist/controller/fontReadiness.d.ts +0 -1
- package/dist/controller/headerFooterEditorManager.d.ts +1 -5
- package/dist/controller/hiddenEditorApi.d.ts +35 -18
- package/dist/controller/hiddenEditorManager.d.ts +5 -3
- package/dist/controller/latestRequestGate.d.ts +3 -1
- package/dist/controller/layoutPipeline.d.ts +1 -1
- package/dist/controller/layoutScheduler.d.ts +8 -5
- package/dist/controller/layoutSession.d.ts +0 -1
- package/dist/controller/noteEditorManager.d.ts +0 -1
- package/dist/document-operations.d.ts +5 -12
- package/dist/document-stories.d.ts +0 -1
- package/dist/docx/blockContentParser.d.ts +0 -1
- package/dist/docx/blockContentParser.js +1 -0
- package/dist/docx/bookmarkParser.d.ts +5 -3
- package/dist/docx/bookmarkPlacement.d.ts +0 -1
- package/dist/docx/commentParser.d.ts +0 -1
- package/dist/docx/commentRangeIntegrity.d.ts +0 -1
- package/dist/docx/commentReferenceNormalization.d.ts +1 -9
- package/dist/docx/commentReplyMarkers.d.ts +0 -1
- package/dist/docx/compatibility.d.ts +0 -1
- package/dist/docx/conformance.d.ts +0 -1
- package/dist/docx/corePropertiesParser.d.ts +0 -1
- package/dist/docx/documentParser.d.ts +0 -1
- package/dist/docx/documentParser.js +3 -1
- package/dist/docx/drawingUtils.d.ts +23 -2
- package/dist/docx/drawingUtils.js +23 -1
- package/dist/docx/encryption/agileDecryption.d.ts +0 -1
- package/dist/docx/encryption/cryptoBytes.js +4 -1
- package/dist/docx/encryption/openEncryptedDocx.d.ts +5 -2
- package/dist/docx/ensureParaIds.d.ts +7 -3
- package/dist/docx/fieldParser.d.ts +23 -11
- package/dist/docx/fontTableParser.d.ts +0 -1
- package/dist/docx/footnoteParser.d.ts +26 -13
- package/dist/docx/footnoteParser.js +4 -2
- package/dist/docx/groupDrawingParser.d.ts +0 -1
- package/dist/docx/headerFooterParser.d.ts +9 -5
- package/dist/docx/headerFooterRefParser.d.ts +0 -1
- package/dist/docx/headerFooterReferenceNormalization.d.ts +1 -6
- package/dist/docx/headerFooterVerbatim.d.ts +2 -2
- package/dist/docx/hyperlinkParser.d.ts +0 -1
- package/dist/docx/hyperlinkParser.js +1 -9
- package/dist/docx/imageParser.d.ts +0 -1
- package/dist/docx/imageParser.js +15 -7
- package/dist/docx/mathToMathml.d.ts +0 -1
- package/dist/docx/metadataPrivacy.d.ts +1 -3
- package/dist/docx/modelValidation.d.ts +0 -1
- package/dist/docx/newImage.d.ts +11 -0
- package/dist/docx/newImage.js +11 -0
- package/dist/docx/normalizeBaseDirection.d.ts +0 -1
- package/dist/docx/notePropertiesParser.d.ts +0 -1
- package/dist/docx/numberingParser.d.ts +10 -6
- package/dist/docx/numberingParser.js +4 -2
- package/dist/docx/numberingReferenceNormalization.d.ts +1 -9
- package/dist/docx/paragraphParser.d.ts +0 -1
- package/dist/docx/paragraphParser.js +27 -14
- package/dist/docx/paragraphTextBoxEnrichment.d.ts +0 -1
- package/dist/docx/paragraphTextBoxEnrichment.js +2 -1
- package/dist/docx/paragraphTraversal.d.ts +1 -8
- package/dist/docx/parser.d.ts +15 -8
- package/dist/docx/parser.js +12 -1
- package/dist/docx/parserEnums.d.ts +2 -2
- package/dist/docx/parserEnums.js +3 -2
- package/dist/docx/relsParser.d.ts +1 -0
- package/dist/docx/renderedPageBreakNormalization.d.ts +12 -0
- package/dist/docx/renderedPageBreakNormalization.js +59 -0
- package/dist/docx/replyToComment.d.ts +2 -2
- package/dist/docx/rezip.d.ts +6 -7
- package/dist/docx/rezip.js +136 -102
- package/dist/docx/runConsolidator.d.ts +0 -1
- package/dist/docx/runParser.d.ts +0 -1
- package/dist/docx/runParser.js +9 -12
- package/dist/docx/sdtProperties.d.ts +0 -1
- package/dist/docx/sdtPropertiesPatch.d.ts +0 -1
- package/dist/docx/sectionParser.d.ts +0 -1
- package/dist/docx/selectiveSave.d.ts +5 -3
- package/dist/docx/selectiveSave.js +2 -2
- package/dist/docx/selectiveSaveFlags.d.ts +4 -2
- package/dist/docx/selectiveXmlPatch.js +20 -8
- package/dist/docx/serializer/blockSdtSerializer.d.ts +0 -1
- package/dist/docx/serializer/blockSdtSerializer.js +2 -1
- package/dist/docx/serializer/borderSerializer.d.ts +0 -1
- package/dist/docx/serializer/commentSerializer.d.ts +0 -1
- package/dist/docx/serializer/commentSerializer.js +11 -37
- package/dist/docx/serializer/documentSerializer.d.ts +0 -1
- package/dist/docx/serializer/documentSerializer.js +1 -1
- package/dist/docx/serializer/fontTableSerializer.d.ts +0 -1
- package/dist/docx/serializer/headerFooterSerializer.d.ts +0 -1
- package/dist/docx/serializer/headerFooterSerializer.js +1 -1
- package/dist/docx/serializer/noteSerializer.d.ts +0 -1
- package/dist/docx/serializer/noteSerializer.js +1 -1
- package/dist/docx/serializer/numberingSerializer.d.ts +0 -1
- package/dist/docx/serializer/paragraphSerializer.d.ts +0 -1
- package/dist/docx/serializer/paragraphSerializer.js +10 -23
- package/dist/docx/serializer/runSerializer.d.ts +0 -1
- package/dist/docx/serializer/runSerializer.js +37 -22
- package/dist/docx/serializer/sectionPropertiesSerializer.d.ts +0 -1
- package/dist/docx/serializer/sectionPropertiesSerializer.js +5 -4
- package/dist/docx/serializer/settingsSerializer.d.ts +0 -1
- package/dist/docx/serializer/stylesSerializer.d.ts +0 -1
- package/dist/docx/serializer/tableSerializer.d.ts +0 -1
- package/dist/docx/serializer/tableSerializer.js +2 -0
- package/dist/docx/serializer/themeSerializer.d.ts +0 -1
- package/dist/docx/serializer/xmlUtils.js +10 -1
- package/dist/docx/server/applyDocxXmlPatchProposal.d.ts +3 -10
- package/dist/docx/server/docxToMarkdown.d.ts +0 -1
- package/dist/docx/server/evaluateDocxXmlPatchProposal.d.ts +3 -9
- package/dist/docx/server/inspectDocxPackage.d.ts +3 -8
- package/dist/docx/server/validateDocxConformance.d.ts +0 -1
- package/dist/docx/settingsParser.d.ts +2 -2
- package/dist/docx/shapeParser.d.ts +0 -1
- package/dist/docx/shapeParser.js +11 -10
- package/dist/docx/streamingXmlParser.d.ts +16 -0
- package/dist/docx/streamingXmlParser.js +248 -0
- package/dist/docx/styleParser.d.ts +0 -1
- package/dist/docx/styleParser.js +6 -4
- package/dist/docx/tableParser.d.ts +1 -2
- package/dist/docx/tableParser.js +3 -6
- package/dist/docx/textBoxParser.d.ts +1 -2
- package/dist/docx/textBoxParser.js +4 -1
- package/dist/docx/textWhitespace.d.ts +4 -0
- package/dist/docx/textWhitespace.js +4 -0
- package/dist/docx/themeParser.d.ts +0 -1
- package/dist/docx/trackedMoveRangeNormalization.d.ts +1 -8
- package/dist/docx/unzip.d.ts +6 -3
- package/dist/docx/unzip.js +96 -40
- package/dist/docx/vmlImageParser.d.ts +0 -1
- package/dist/docx/vmlImageParser.js +3 -1
- package/dist/docx/watermarkParser.d.ts +0 -1
- package/dist/docx/xmlParser.d.ts +21 -8
- package/dist/docx/xmlParser.js +126 -43
- package/dist/fields/bookmarkPages.d.ts +0 -1
- package/dist/fields/bookmarkText.d.ts +0 -1
- package/dist/fields/evaluateField.d.ts +5 -3
- package/dist/fields/fieldContext.d.ts +11 -5
- package/dist/fields/resolveFieldValues.d.ts +4 -3
- package/dist/fields/sectionPageCounts.d.ts +0 -1
- package/dist/fields/seqValues.d.ts +0 -1
- package/dist/fonts/embeddedFontTable.d.ts +5 -2
- package/dist/fonts/embeddedFonts.d.ts +15 -7
- package/dist/index.d.ts +1 -0
- package/dist/layout-bridge/cellSelectionHighlight.d.ts +0 -1
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +5 -3
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +2 -2
- package/dist/layout-bridge/convert/paragraphFrames.d.ts +0 -1
- package/dist/layout-bridge/convert/templatePreviewFlow.d.ts +8 -8
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +25 -13
- package/dist/layout-bridge/convert/wrapEditorViewAsSurface.d.ts +3 -2
- package/dist/layout-bridge/dom/findHfPmSpans.d.ts +2 -1
- package/dist/layout-bridge/dom/noteStoryDom.d.ts +0 -1
- package/dist/layout-bridge/engine/clickToPosition.d.ts +5 -3
- package/dist/layout-bridge/engine/hitTest.d.ts +40 -19
- package/dist/layout-bridge/engine/selectionRects.d.ts +16 -8
- package/dist/layout-bridge/engine/tableWidthUtils.d.ts +0 -1
- package/dist/layout-bridge/headerFooterLayout.d.ts +0 -1
- package/dist/layout-bridge/sectionColumns.d.ts +0 -1
- package/dist/layout-bridge/tableInsertHover.d.ts +8 -4
- package/dist/layout-engine/headerFooterRefs.d.ts +0 -1
- package/dist/layout-engine/index.d.ts +0 -1
- package/dist/layout-engine/justificationCompatibility.d.ts +0 -1
- package/dist/layout-engine/keep-together.d.ts +7 -4
- package/dist/layout-engine/layoutInstrumentation.d.ts +0 -1
- package/dist/layout-engine/lineFlow.d.ts +0 -1
- package/dist/layout-engine/measure/cache.d.ts +0 -1
- package/dist/layout-engine/measure/effectiveLineBreakPolicy.d.ts +6 -7
- package/dist/layout-engine/measure/floatingTablePosition.d.ts +0 -1
- package/dist/layout-engine/measure/floatingZones.d.ts +14 -6
- package/dist/layout-engine/measure/font-metrics.worker.d.ts +0 -1
- package/dist/layout-engine/measure/lineBreakProvider.d.ts +20 -9
- package/dist/layout-engine/measure/lineBreaks.d.ts +0 -1
- package/dist/layout-engine/measure/listMarkerWidth.d.ts +0 -1
- package/dist/layout-engine/measure/measureBlocks.d.ts +1 -0
- package/dist/layout-engine/measure/measureContainer.d.ts +0 -1
- package/dist/layout-engine/measure/measureHelpers.d.ts +0 -1
- package/dist/layout-engine/measure/measureParagraph.d.ts +3 -2
- package/dist/layout-engine/measure/measureParagraph.js +23 -3
- package/dist/layout-engine/measure/measureProvider.d.ts +0 -1
- package/dist/layout-engine/measure/measureTypes.d.ts +4 -2
- package/dist/layout-engine/measure/measureWorker.d.ts +0 -1
- package/dist/layout-engine/measure/measureWorkerProtocol.d.ts +0 -1
- package/dist/layout-engine/measure/tableCellFloating.d.ts +0 -1
- package/dist/layout-engine/measure/tableCellFlow.d.ts +0 -1
- package/dist/layout-engine/measure/tableCellGrid.d.ts +0 -1
- package/dist/layout-engine/measure/textBoxParagraphLayout.d.ts +0 -1
- package/dist/layout-engine/measure/textMeasurementPolicy.d.ts +0 -1
- package/dist/layout-engine/paginator.d.ts +66 -33
- package/dist/layout-engine/paragraphFragmentRange.d.ts +0 -1
- package/dist/layout-engine/paragraphFrame.d.ts +0 -1
- package/dist/layout-engine/paragraphSequence.d.ts +0 -1
- package/dist/layout-engine/paragraphSpacing.d.ts +1 -5
- package/dist/layout-engine/pmPageIndex.d.ts +0 -1
- package/dist/layout-engine/renderedBreakReconciliation.d.ts +2 -17
- package/dist/layout-engine/section-breaks.d.ts +34 -17
- package/dist/layout-engine/tableRowBreak.d.ts +4 -3
- package/dist/layout-engine/textBoxFlow.d.ts +0 -1
- package/dist/layout-engine/textBoxGroup.d.ts +0 -1
- package/dist/layout-engine/types.d.ts +382 -189
- package/dist/layout-painter/anchoredImagePosition.d.ts +0 -1
- package/dist/layout-painter/borderStroke.d.ts +0 -1
- package/dist/layout-painter/imageLayout.d.ts +14 -7
- package/dist/layout-painter/index.d.ts +9 -5
- package/dist/layout-painter/registry/modules/image.d.ts +0 -1
- package/dist/layout-painter/registry/modules/paragraph.d.ts +0 -1
- package/dist/layout-painter/registry/modules/table.d.ts +0 -1
- package/dist/layout-painter/registry/modules/textBox.d.ts +0 -1
- package/dist/layout-painter/registry/modules.d.ts +0 -1
- package/dist/layout-painter/registry/registry.d.ts +0 -1
- package/dist/layout-painter/registry/types.d.ts +0 -1
- package/dist/layout-painter/renderFragment.d.ts +2 -2
- package/dist/layout-painter/renderImage.d.ts +0 -1
- package/dist/layout-painter/renderPage.d.ts +71 -42
- package/dist/layout-painter/renderParagraph.d.ts +28 -14
- package/dist/layout-painter/renderParagraph.js +6 -2
- package/dist/layout-painter/renderTable.d.ts +0 -1
- package/dist/layout-painter/renderTextBox.d.ts +0 -1
- package/dist/layout-painter/renderUtils.d.ts +17 -9
- package/dist/layout-painter/renderWatermark.d.ts +2 -2
- package/dist/layout-painter/sdtBoundary.d.ts +0 -1
- package/dist/managers/AutoSaveManager.d.ts +22 -11
- package/dist/managers/ClipboardManager.d.ts +0 -1
- package/dist/managers/ContextMenuManager.d.ts +5 -8
- package/dist/managers/DocumentLoaderManager.d.ts +12 -6
- package/dist/managers/EditorModeManager.d.ts +3 -2
- package/dist/managers/ErrorManager.d.ts +0 -1
- package/dist/managers/FindReplaceManager.d.ts +0 -1
- package/dist/managers/HistoryManager.d.ts +19 -9
- package/dist/managers/TableSelectionManager.d.ts +0 -1
- package/dist/managers/editorShortcuts.d.ts +4 -6
- package/dist/markdown/annotations.d.ts +0 -1
- package/dist/markdown/fromMarkdown.d.ts +0 -1
- package/dist/markdown/images.d.ts +0 -1
- package/dist/markdown/index.d.ts +0 -1
- package/dist/markdown/internals.d.ts +0 -1
- package/dist/markdown/renderBlock.d.ts +0 -1
- package/dist/markdown/renderParagraph.d.ts +0 -1
- package/dist/markdown/renderRuns.d.ts +0 -1
- package/dist/markdown/renderTable.d.ts +0 -1
- package/dist/markdown/trailers.d.ts +0 -1
- package/dist/markdown/types.d.ts +39 -18
- package/dist/model.d.ts +3 -5
- package/dist/model.js +2 -2
- package/dist/paged-layout/incrementalMeasure.d.ts +1 -10
- package/dist/paged-layout/pageText.d.ts +1 -1
- package/dist/paged-layout/paragraphFlash.d.ts +0 -1
- package/dist/paged-layout/paragraphFlashTypes.d.ts +5 -2
- package/dist/paged-layout/rangeProjection.d.ts +10 -5
- package/dist/paged-layout/scrollNavigation.d.ts +0 -1
- package/dist/paged-layout/scrollPageInfo.d.ts +12 -13
- package/dist/paged-layout/scrollToPmPosition.d.ts +0 -1
- package/dist/paged-layout/sectionBlockWidths.d.ts +2 -11
- package/dist/paged-layout/sectionGeometry.d.ts +0 -1
- package/dist/paged-layout/selectionViewportRect.d.ts +0 -1
- package/dist/paged-layout/transactionDirtyRange.d.ts +0 -1
- package/dist/paged-layout/zoomScrollAnchor.d.ts +2 -12
- package/dist/prosemirror/attrs/index.d.ts +2 -2
- package/dist/prosemirror/attrs/index.js +5 -0
- package/dist/prosemirror/autospacingBase.d.ts +0 -1
- package/dist/prosemirror/cellDragSelection.d.ts +6 -4
- package/dist/prosemirror/commands/comments.d.ts +6 -4
- package/dist/prosemirror/commands/contentControls.d.ts +5 -3
- package/dist/prosemirror/commands/contentControlsBlockFill.d.ts +1 -1
- package/dist/prosemirror/commands/formatPainter.d.ts +0 -1
- package/dist/prosemirror/commands/formatting.d.ts +1 -1
- package/dist/prosemirror/commands/hyperlink.d.ts +4 -9
- package/dist/prosemirror/commands/image.d.ts +0 -1
- package/dist/prosemirror/commands/pageBreak.d.ts +0 -1
- package/dist/prosemirror/commands/paragraph.d.ts +0 -1
- package/dist/prosemirror/commands/pastePlainText.d.ts +0 -1
- package/dist/prosemirror/commands/propertyChangeScope.d.ts +0 -1
- package/dist/prosemirror/commands/sectionBreak.d.ts +0 -1
- package/dist/prosemirror/commands/table.d.ts +0 -1
- package/dist/prosemirror/commands/tableCellMergeResolution.d.ts +0 -1
- package/dist/prosemirror/commentIdAllocator.d.ts +2 -2
- package/dist/prosemirror/commentOps.d.ts +0 -1
- package/dist/prosemirror/conversion/effectiveTableCellFormatting.d.ts +1 -10
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +0 -1
- package/dist/prosemirror/conversion/fromProseDoc.js +7 -4
- package/dist/prosemirror/conversion/runShadingMark.d.ts +0 -1
- package/dist/prosemirror/conversion/sdtAttrs.d.ts +0 -1
- package/dist/prosemirror/conversion/toProseDoc.d.ts +3 -2
- package/dist/prosemirror/conversion/toProseDoc.js +16 -2
- package/dist/prosemirror/extensions/ExtensionManager.d.ts +0 -1
- package/dist/prosemirror/extensions/StarterKit.d.ts +7 -4
- package/dist/prosemirror/extensions/core/DocExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/core/HistoryExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/core/TextExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/create.d.ts +0 -1
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/features/BidiShortcutExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/features/ContentControlWidgetsExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/features/DropCursorExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/features/GapCursorExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/features/ImageDragExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/features/ImagePasteExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/features/ListExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +7 -4
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/features/PasteStyleInlinerExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/features/SelectionTrackerExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/features/bidiShortcutController.d.ts +3 -1
- package/dist/prosemirror/extensions/marks/AllCapsExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/marks/BoldExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/marks/CharacterSpacingExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/marks/CharacterStyleExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/marks/CommentExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/marks/FontFamilyExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/marks/FontFamilyExtension.js +1 -0
- package/dist/prosemirror/extensions/marks/FontSizeExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/marks/HiddenTextExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/marks/HighlightExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/marks/ItalicExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/marks/LanguageExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/marks/RtlExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/marks/RunFormattingOverrideExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/marks/RunShadingExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/marks/SmallCapsExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/marks/StrikeExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/marks/SubscriptExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/marks/SuperscriptExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/marks/TextColorExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/marks/TextEffectExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/marks/TextEffectsExtensions.d.ts +0 -1
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.d.ts +0 -1
- package/dist/prosemirror/extensions/marks/UnderlineExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +0 -1
- package/dist/prosemirror/extensions/marks/markUtils.js +4 -1
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/nodes/FieldExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/nodes/HardBreakExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/nodes/HorizontalRuleExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/nodes/ImageExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +2 -0
- package/dist/prosemirror/extensions/nodes/MathExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/nodes/PageBreakExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/nodes/RenderedPageBreakExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/nodes/SdtExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/nodes/ShapeExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/nodes/ShapeExtension.js +2 -0
- package/dist/prosemirror/extensions/nodes/TabExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/nodes/TableExtension.d.ts +4 -3
- package/dist/prosemirror/extensions/nodes/TextBoxAnchorExtension.d.ts +0 -1
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.d.ts +53 -27
- package/dist/prosemirror/extensions/types.d.ts +0 -1
- package/dist/prosemirror/findReplaceSelection.d.ts +5 -3
- package/dist/prosemirror/imageCommit.d.ts +0 -1
- package/dist/prosemirror/index.d.ts +4 -0
- package/dist/prosemirror/insertOperations.d.ts +0 -1
- package/dist/prosemirror/paraText.d.ts +0 -1
- package/dist/prosemirror/plugins/aiCitationDecorations.d.ts +2 -2
- package/dist/prosemirror/plugins/aiSuggestionDecorations.d.ts +0 -1
- package/dist/prosemirror/plugins/anonymizationDecorations.d.ts +9 -7
- package/dist/prosemirror/plugins/autocompleteSuggestion.d.ts +2 -2
- package/dist/prosemirror/plugins/contentControlWidgets.d.ts +4 -7
- package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +3 -8
- package/dist/prosemirror/plugins/documentStyles.d.ts +0 -1
- package/dist/prosemirror/plugins/pmTextScan.d.ts +2 -2
- package/dist/prosemirror/plugins/revisionIds.d.ts +0 -1
- package/dist/prosemirror/plugins/selectionTracker.d.ts +23 -12
- package/dist/prosemirror/plugins/suggestionMode.d.ts +0 -1
- package/dist/prosemirror/plugins/templateDirectives.d.ts +10 -8
- package/dist/prosemirror/plugins/templatePreviewValues.d.ts +10 -5
- package/dist/prosemirror/plugins/templateSlashMenu.d.ts +2 -2
- package/dist/prosemirror/queries.d.ts +0 -1
- package/dist/prosemirror/schema/index.d.ts +0 -1
- package/dist/prosemirror/schema/marks.d.ts +8 -5
- package/dist/prosemirror/schema/nodes.d.ts +340 -163
- package/dist/prosemirror/selectionState.d.ts +13 -7
- package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +0 -1
- package/dist/prosemirror/styles/styleResolver.d.ts +3 -2
- package/dist/prosemirror/tableCellMergeRevision.d.ts +0 -1
- package/dist/prosemirror/tableResize.d.ts +0 -1
- package/dist/prosemirror/textBoxAnchorAttrs.d.ts +0 -1
- package/dist/prosemirror/utils/extractTrackedChanges.d.ts +8 -5
- package/dist/prosemirror/utils/findParagraphByParaId.d.ts +0 -1
- package/dist/prosemirror/utils/tabCalculator.d.ts +18 -7
- package/dist/prosemirror/utils/visualLineNavigation.d.ts +0 -1
- package/dist/prosemirror/validation.d.ts +0 -1
- package/dist/redline.d.ts +16 -8
- package/dist/render-dom/BodySelectionOverlay.d.ts +1 -9
- package/dist/render-dom/HeaderFooterSelectionOverlay.d.ts +0 -1
- package/dist/render-dom/RemoteSelectionOverlay.d.ts +1 -8
- package/dist/render-dom/resolveSidebarItemPositions.d.ts +1 -9
- package/dist/style-engine/styleEngine.d.ts +21 -11
- package/dist/style-sets/extract.d.ts +4 -3
- package/dist/style-sets/stellaStyle.d.ts +0 -1
- package/dist/style-sets/types.d.ts +0 -1
- package/dist/symbols.d.ts +6 -2
- package/dist/types/block-id.d.ts +3 -6
- package/dist/types/document.d.ts +0 -3
- package/dist/types/documentEnumValues.d.ts +2 -1
- package/dist/types/documentEnumValues.js +6 -1
- package/dist/utils/clipboard.d.ts +17 -8
- package/dist/utils/colorResolver.d.ts +9 -5
- package/dist/utils/createDocument.d.ts +19 -10
- package/dist/utils/documentLoaderBehavior.d.ts +1 -5
- package/dist/utils/docxInput.js +1 -0
- package/dist/utils/findReplace.d.ts +0 -1
- package/dist/utils/fontFamilyMerge.d.ts +0 -1
- package/dist/utils/fontResolver.d.ts +10 -4
- package/dist/utils/formatToStyle.d.ts +0 -1
- package/dist/utils/headerFooter.d.ts +8 -16
- package/dist/utils/headingCollector.d.ts +7 -4
- package/dist/utils/mergeDocumentContent.d.ts +0 -1
- package/dist/utils/paragraphFormattingMerge.d.ts +0 -1
- package/dist/utils/replaceText.d.ts +0 -1
- package/dist/utils/rotationBoundingBox.d.ts +0 -1
- package/dist/utils/tableOperations.d.ts +0 -1
- package/dist/utils/textFormattingMerge.d.ts +0 -1
- package/dist/version-comparison.d.ts +12 -6
- package/dist/watermark/index.d.ts +0 -1
- package/package.json +3 -3
package/dist/docx/parser.js
CHANGED
|
@@ -10,12 +10,14 @@ import { detectDocxConformanceClass } from "./conformance.js";
|
|
|
10
10
|
import { parseCoreProperties } from "./corePropertiesParser.js";
|
|
11
11
|
import { extractAllTemplateVariables, parseDocumentBody } from "./documentParser.js";
|
|
12
12
|
import { parseEndnotes, parseFootnotes } from "./footnoteParser.js";
|
|
13
|
+
import { assignHeaderFooterVerbatimXml } from "./headerFooterVerbatim.js";
|
|
13
14
|
import { parseFooter, parseHeader } from "./headerFooterParser.js";
|
|
14
15
|
import { normalizeHeaderFooterReferences } from "./headerFooterReferenceNormalization.js";
|
|
15
16
|
import { DocxModelValidationError, formatDocumentModelIssues, validateFolioDocumentModel } from "./modelValidation.js";
|
|
16
17
|
import { extractMetafileRaster, isMetafileMimeType } from "./metafileRaster.js";
|
|
17
18
|
import { parseFontTable } from "./fontTableParser.js";
|
|
18
19
|
import { normalizeNumberingReferences } from "./numberingReferenceNormalization.js";
|
|
20
|
+
import { normalizeRenderedPageBreakHints } from "./renderedPageBreakNormalization.js";
|
|
19
21
|
import { parseSettings } from "./settingsParser.js";
|
|
20
22
|
import { parseStylesPackage } from "./styleParser.js";
|
|
21
23
|
import { normalizeTrackedMoveRanges } from "./trackedMoveRangeNormalization.js";
|
|
@@ -60,7 +62,8 @@ async function parseDocx(input, options = {}) {
|
|
|
60
62
|
onProgress("Extracting DOCX...", 0);
|
|
61
63
|
const raw = await timeStageAsync("unzip", () => unzipDocx(buffer, {
|
|
62
64
|
...unzipLimits,
|
|
63
|
-
password
|
|
65
|
+
password,
|
|
66
|
+
extractAllXml: false
|
|
64
67
|
}));
|
|
65
68
|
if (raw.wasEncrypted) warnings.push("Document was opened from password-protected storage; saving writes an unencrypted .docx file.");
|
|
66
69
|
warnings.push(...raw.warnings);
|
|
@@ -120,6 +123,13 @@ async function parseDocx(input, options = {}) {
|
|
|
120
123
|
onProgress("Parsing comments...", 75);
|
|
121
124
|
const comments = timeStage("comments", () => parseComments(raw.commentsXml, styles, theme, rels, media, raw.commentsExtensibleXml, raw.commentsExtendedXml));
|
|
122
125
|
if (comments.length > 0) documentBody.comments = comments;
|
|
126
|
+
normalizeRenderedPageBreakHints({
|
|
127
|
+
documentBody,
|
|
128
|
+
...headers !== void 0 ? { headers } : {},
|
|
129
|
+
...footers !== void 0 ? { footers } : {},
|
|
130
|
+
...footnotes !== void 0 ? { footnotes } : {},
|
|
131
|
+
...endnotes !== void 0 ? { endnotes } : {}
|
|
132
|
+
});
|
|
123
133
|
const commentReferenceNormalization = normalizeCommentReferences({
|
|
124
134
|
documentBody,
|
|
125
135
|
comments,
|
|
@@ -328,6 +338,7 @@ function parseHeadersAndFooters(raw, styles, theme, numbering, rels, media) {
|
|
|
328
338
|
watermark.imageTarget = imageRel.target;
|
|
329
339
|
watermark.imageTargetExternal = true;
|
|
330
340
|
} else watermark.imageTarget = resolveRelativePath(headerRelsPath, imageRel.target);
|
|
341
|
+
assignHeaderFooterVerbatimXml(header, headerXml);
|
|
331
342
|
}
|
|
332
343
|
headers.set(rId, header);
|
|
333
344
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as v from "valibot";
|
|
2
|
-
|
|
3
2
|
//#region src/docx/parserEnums.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* Narrow a raw attribute string to a picklist member, or `undefined`
|
|
@@ -15,6 +14,7 @@ declare const HighlightColorSchema: v.PicklistSchema<readonly ["black", "blue",
|
|
|
15
14
|
declare const TextEffectSchema: v.PicklistSchema<readonly ["none", "blinkBackground", "lights", "antsBlack", "antsRed", "shimmer", "sparkle"], undefined>;
|
|
16
15
|
declare const EmphasisMarkSchema: v.PicklistSchema<readonly ["none", "dot", "comma", "circle", "underDot"], undefined>;
|
|
17
16
|
declare const FontThemeSchema: v.PicklistSchema<readonly ["majorAscii", "majorHAnsi", "majorEastAsia", "majorBidi", "minorAscii", "minorHAnsi", "minorEastAsia", "minorBidi"], undefined>;
|
|
17
|
+
declare const FontHintSchema: v.PicklistSchema<readonly ["default", "eastAsia", "cs"], undefined>;
|
|
18
18
|
declare const ParagraphAlignmentSchema: v.PicklistSchema<readonly ["left", "center", "right", "both", "distribute", "mediumKashida", "highKashida", "lowKashida", "thaiDistribute"], undefined>;
|
|
19
19
|
declare const LineSpacingRuleSchema: v.PicklistSchema<readonly ["auto", "exact", "atLeast"], undefined>;
|
|
20
20
|
declare const TabStopAlignmentSchema: v.PicklistSchema<readonly ["left", "center", "right", "decimal", "bar", "clear", "num"], undefined>;
|
|
@@ -42,4 +42,4 @@ declare const ShapeTypeSchema: v.PicklistSchema<readonly ["rect", "roundRect", "
|
|
|
42
42
|
declare const NumberFormatSchema: v.PicklistSchema<readonly ["decimal", "upperRoman", "lowerRoman", "upperLetter", "lowerLetter", "ordinal", "cardinalText", "ordinalText", "hex", "chicago", "ideographDigital", "japaneseCounting", "aiueo", "iroha", "decimalFullWidth", "decimalHalfWidth", "japaneseLegal", "japaneseDigitalTenThousand", "decimalEnclosedCircle", "decimalFullWidth2", "aiueoFullWidth", "irohaFullWidth", "decimalZero", "decimalZero3", "decimalZero4", "decimalZero5", "bullet", "ganada", "chosung", "decimalEnclosedFullstop", "decimalEnclosedParen", "decimalEnclosedCircleChinese", "ideographEnclosedCircle", "ideographTraditional", "ideographZodiac", "ideographZodiacTraditional", "taiwaneseCounting", "ideographLegalTraditional", "taiwaneseCountingThousand", "taiwaneseDigital", "chineseCounting", "chineseLegalSimplified", "chineseCountingThousand", "koreanDigital", "koreanCounting", "koreanLegal", "koreanDigital2", "vietnameseCounting", "russianLower", "russianUpper", "none", "numberInDash", "hebrew1", "hebrew2", "arabicAlpha", "arabicAbjad", "hindiVowels", "hindiConsonants", "hindiNumbers", "hindiCounting", "thaiLetters", "thaiNumbers", "thaiCounting"], undefined>;
|
|
43
43
|
declare const LevelSuffixSchema: v.PicklistSchema<readonly ["tab", "space", "nothing"], undefined>;
|
|
44
44
|
//#endregion
|
|
45
|
-
export { BorderStyleSchema, ConditionalStyleTypeSchema, EmphasisMarkSchema, FieldTypeSchema, FloatingTableXSpecSchema, FloatingTableYSpecSchema, FontThemeSchema, FrameWrapSchema, FrameXAlignSchema, FrameYAlignSchema, HighlightColorSchema, ImageHorizontalAlignmentSchema, ImageHorizontalRelativeToSchema, ImageVerticalAlignmentSchema, ImageVerticalRelativeToSchema, ImageWrapTextSchema, LevelSuffixSchema, LineSpacingRuleSchema, NumberFormatSchema, ParagraphAlignmentSchema, SdtLockSchema, ShadingPatternSchema, ShapeOutlineStyleSchema, ShapeTypeSchema, StyleTypeSchema, TabLeaderSchema, TabStopAlignmentSchema, TableCellTextDirectionSchema, TableRowHeightRuleSchema, TableWidthTypeSchema, TextEffectSchema, ThemeColorSlotSchema, UnderlineStyleSchema, narrowEnum };
|
|
45
|
+
export { BorderStyleSchema, ConditionalStyleTypeSchema, EmphasisMarkSchema, FieldTypeSchema, FloatingTableXSpecSchema, FloatingTableYSpecSchema, FontHintSchema, FontThemeSchema, FrameWrapSchema, FrameXAlignSchema, FrameYAlignSchema, HighlightColorSchema, ImageHorizontalAlignmentSchema, ImageHorizontalRelativeToSchema, ImageVerticalAlignmentSchema, ImageVerticalRelativeToSchema, ImageWrapTextSchema, LevelSuffixSchema, LineSpacingRuleSchema, NumberFormatSchema, ParagraphAlignmentSchema, SdtLockSchema, ShadingPatternSchema, ShapeOutlineStyleSchema, ShapeTypeSchema, StyleTypeSchema, TabLeaderSchema, TabStopAlignmentSchema, TableCellTextDirectionSchema, TableRowHeightRuleSchema, TableWidthTypeSchema, TextEffectSchema, ThemeColorSlotSchema, UnderlineStyleSchema, narrowEnum };
|
package/dist/docx/parserEnums.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BORDER_STYLE_VALUES, CONDITIONAL_STYLE_TYPE_VALUES, EMPHASIS_MARK_VALUES, FIELD_TYPE_VALUES, FLOATING_TABLE_X_SPEC_VALUES, FLOATING_TABLE_Y_SPEC_VALUES, FONT_THEME_VALUES, FRAME_WRAP_VALUES, FRAME_X_ALIGN_VALUES, FRAME_Y_ALIGN_VALUES, HIGHLIGHT_COLOR_VALUES, IMAGE_HORIZONTAL_ALIGNMENT_VALUES, IMAGE_HORIZONTAL_RELATIVE_TO_VALUES, IMAGE_VERTICAL_ALIGNMENT_VALUES, IMAGE_VERTICAL_RELATIVE_TO_VALUES, IMAGE_WRAP_TEXT_VALUES, LEVEL_SUFFIX_VALUES, LINE_SPACING_RULE_VALUES, NUMBER_FORMAT_VALUES, PARAGRAPH_ALIGNMENT_VALUES, SDT_LOCK_VALUES, SHADING_PATTERN_VALUES, SHAPE_OUTLINE_STYLE_VALUES, SHAPE_TYPE_VALUES, STYLE_TYPE_VALUES, TABLE_CELL_TEXT_DIRECTION_VALUES, TABLE_ROW_HEIGHT_RULE_VALUES, TABLE_WIDTH_TYPE_VALUES, TAB_LEADER_VALUES, TAB_STOP_ALIGNMENT_VALUES, TEXT_EFFECT_VALUES, THEME_COLOR_SLOT_VALUES, UNDERLINE_STYLE_VALUES } from "../types/documentEnumValues.js";
|
|
1
|
+
import { BORDER_STYLE_VALUES, CONDITIONAL_STYLE_TYPE_VALUES, EMPHASIS_MARK_VALUES, FIELD_TYPE_VALUES, FLOATING_TABLE_X_SPEC_VALUES, FLOATING_TABLE_Y_SPEC_VALUES, FONT_HINT_VALUES, FONT_THEME_VALUES, FRAME_WRAP_VALUES, FRAME_X_ALIGN_VALUES, FRAME_Y_ALIGN_VALUES, HIGHLIGHT_COLOR_VALUES, IMAGE_HORIZONTAL_ALIGNMENT_VALUES, IMAGE_HORIZONTAL_RELATIVE_TO_VALUES, IMAGE_VERTICAL_ALIGNMENT_VALUES, IMAGE_VERTICAL_RELATIVE_TO_VALUES, IMAGE_WRAP_TEXT_VALUES, LEVEL_SUFFIX_VALUES, LINE_SPACING_RULE_VALUES, NUMBER_FORMAT_VALUES, PARAGRAPH_ALIGNMENT_VALUES, SDT_LOCK_VALUES, SHADING_PATTERN_VALUES, SHAPE_OUTLINE_STYLE_VALUES, SHAPE_TYPE_VALUES, STYLE_TYPE_VALUES, TABLE_CELL_TEXT_DIRECTION_VALUES, TABLE_ROW_HEIGHT_RULE_VALUES, TABLE_WIDTH_TYPE_VALUES, TAB_LEADER_VALUES, TAB_STOP_ALIGNMENT_VALUES, TEXT_EFFECT_VALUES, THEME_COLOR_SLOT_VALUES, UNDERLINE_STYLE_VALUES } from "../types/documentEnumValues.js";
|
|
2
2
|
import * as v from "valibot";
|
|
3
3
|
//#region src/docx/parserEnums.ts
|
|
4
4
|
/**
|
|
@@ -40,6 +40,7 @@ const HighlightColorSchema = v.picklist(HIGHLIGHT_COLOR_VALUES);
|
|
|
40
40
|
const TextEffectSchema = v.picklist(TEXT_EFFECT_VALUES);
|
|
41
41
|
const EmphasisMarkSchema = v.picklist(EMPHASIS_MARK_VALUES);
|
|
42
42
|
const FontThemeSchema = v.picklist(FONT_THEME_VALUES);
|
|
43
|
+
const FontHintSchema = v.picklist(FONT_HINT_VALUES);
|
|
43
44
|
const ParagraphAlignmentSchema = v.picklist(PARAGRAPH_ALIGNMENT_VALUES);
|
|
44
45
|
const LineSpacingRuleSchema = v.picklist(LINE_SPACING_RULE_VALUES);
|
|
45
46
|
const TabStopAlignmentSchema = v.picklist(TAB_STOP_ALIGNMENT_VALUES);
|
|
@@ -67,4 +68,4 @@ const ShapeTypeSchema = v.picklist(SHAPE_TYPE_VALUES);
|
|
|
67
68
|
const NumberFormatSchema = v.picklist(NUMBER_FORMAT_VALUES);
|
|
68
69
|
const LevelSuffixSchema = v.picklist(LEVEL_SUFFIX_VALUES);
|
|
69
70
|
//#endregion
|
|
70
|
-
export { BorderStyleSchema, ConditionalStyleTypeSchema, EmphasisMarkSchema, FieldTypeSchema, FloatingTableXSpecSchema, FloatingTableYSpecSchema, FontThemeSchema, FrameWrapSchema, FrameXAlignSchema, FrameYAlignSchema, HighlightColorSchema, ImageHorizontalAlignmentSchema, ImageHorizontalRelativeToSchema, ImageVerticalAlignmentSchema, ImageVerticalRelativeToSchema, ImageWrapTextSchema, LevelSuffixSchema, LineSpacingRuleSchema, NumberFormatSchema, ParagraphAlignmentSchema, SdtLockSchema, ShadingPatternSchema, ShapeOutlineStyleSchema, ShapeTypeSchema, StyleTypeSchema, TabLeaderSchema, TabStopAlignmentSchema, TableCellTextDirectionSchema, TableRowHeightRuleSchema, TableWidthTypeSchema, TextEffectSchema, ThemeColorSlotSchema, UnderlineStyleSchema, narrowEnum };
|
|
71
|
+
export { BorderStyleSchema, ConditionalStyleTypeSchema, EmphasisMarkSchema, FieldTypeSchema, FloatingTableXSpecSchema, FloatingTableYSpecSchema, FontHintSchema, FontThemeSchema, FrameWrapSchema, FrameXAlignSchema, FrameYAlignSchema, HighlightColorSchema, ImageHorizontalAlignmentSchema, ImageHorizontalRelativeToSchema, ImageVerticalAlignmentSchema, ImageVerticalRelativeToSchema, ImageWrapTextSchema, LevelSuffixSchema, LineSpacingRuleSchema, NumberFormatSchema, ParagraphAlignmentSchema, SdtLockSchema, ShadingPatternSchema, ShapeOutlineStyleSchema, ShapeTypeSchema, StyleTypeSchema, TabLeaderSchema, TabStopAlignmentSchema, TableCellTextDirectionSchema, TableRowHeightRuleSchema, TableWidthTypeSchema, TextEffectSchema, ThemeColorSlotSchema, UnderlineStyleSchema, narrowEnum };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
//#region src/docx/renderedPageBreakNormalization.d.ts
|
|
3
|
+
type NormalizeRenderedPageBreakHintsInput = {
|
|
4
|
+
documentBody: document_d_exports.DocumentBody;
|
|
5
|
+
headers?: Map<string, document_d_exports.HeaderFooter>;
|
|
6
|
+
footers?: Map<string, document_d_exports.HeaderFooter>;
|
|
7
|
+
footnotes?: readonly document_d_exports.Footnote[];
|
|
8
|
+
endnotes?: readonly document_d_exports.Endnote[];
|
|
9
|
+
};
|
|
10
|
+
declare const normalizeRenderedPageBreakHints: ({ documentBody, headers, footers, footnotes, endnotes }: NormalizeRenderedPageBreakHintsInput) => void;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { normalizeRenderedPageBreakHints };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { visitDocxParagraphs } from "./paragraphTraversal.js";
|
|
2
|
+
//#region src/docx/renderedPageBreakNormalization.ts
|
|
3
|
+
const normalizeRenderedPageBreakHints = ({ documentBody, headers, footers, footnotes, endnotes }) => {
|
|
4
|
+
visitDocxParagraphs({
|
|
5
|
+
documentBody,
|
|
6
|
+
headers,
|
|
7
|
+
footers,
|
|
8
|
+
footnotes,
|
|
9
|
+
endnotes
|
|
10
|
+
}, (paragraph) => {
|
|
11
|
+
if (paragraph.renderedPageBreakBefore === true && !retainsLeadingRenderedPageBreak(paragraph.content)) delete paragraph.renderedPageBreakBefore;
|
|
12
|
+
});
|
|
13
|
+
};
|
|
14
|
+
const retainsLeadingRenderedPageBreak = (content) => {
|
|
15
|
+
const scan = { sawRenderedPageBreak: false };
|
|
16
|
+
for (const item of content) {
|
|
17
|
+
const result = scanParagraphContent(item, scan);
|
|
18
|
+
if (result !== void 0) return result;
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
};
|
|
22
|
+
const scanRun = (run, scan) => {
|
|
23
|
+
for (const content of run.content) {
|
|
24
|
+
if (content.type === "renderedPageBreak") {
|
|
25
|
+
scan.sawRenderedPageBreak = true;
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
return scan.sawRenderedPageBreak;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
const scanHyperlink = (hyperlink, scan) => {
|
|
32
|
+
for (const child of hyperlink.children) {
|
|
33
|
+
if (child.type !== "run") continue;
|
|
34
|
+
const result = scanRun(child, scan);
|
|
35
|
+
if (result !== void 0) return result;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const scanInlineContent = (content, scan) => {
|
|
39
|
+
for (const child of content) {
|
|
40
|
+
const result = child.type === "run" ? scanRun(child, scan) : scanHyperlink(child, scan);
|
|
41
|
+
if (result !== void 0) return result;
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
const scanParagraphContent = (content, scan) => {
|
|
45
|
+
if (content.type === "run") return scanRun(content, scan);
|
|
46
|
+
if (content.type === "hyperlink") return scanHyperlink(content, scan);
|
|
47
|
+
if (content.type === "simpleField") return scanInlineContent(content.content, scan);
|
|
48
|
+
if (content.type === "insertion" || content.type === "deletion" || content.type === "moveFrom" || content.type === "moveTo") return scanInlineContent(content.content, scan);
|
|
49
|
+
if (content.type === "inlineSdt") {
|
|
50
|
+
for (const child of content.content) {
|
|
51
|
+
const result = scanParagraphContent(child, scan);
|
|
52
|
+
if (result !== void 0) return result;
|
|
53
|
+
}
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (content.type === "complexField") return scan.sawRenderedPageBreak;
|
|
57
|
+
};
|
|
58
|
+
//#endregion
|
|
59
|
+
export { normalizeRenderedPageBreakHints };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
|
-
|
|
3
2
|
//#region src/docx/replyToComment.d.ts
|
|
4
3
|
type CreateCommentReplyInput = {
|
|
5
4
|
author: string;
|
|
6
5
|
text: string;
|
|
7
|
-
initials?: string;
|
|
6
|
+
initials?: string;
|
|
7
|
+
/** ISO date; defaults to now. */
|
|
8
8
|
date?: string;
|
|
9
9
|
};
|
|
10
10
|
/**
|
package/dist/docx/rezip.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { document_d_exports } from "../types/document.js";
|
|
2
2
|
import { RawDocxContent } from "./unzip.js";
|
|
3
3
|
import JSZip from "jszip";
|
|
4
|
-
|
|
5
4
|
//#region src/docx/rezip.d.ts
|
|
6
5
|
declare class DocxPackageFidelityError extends Error {
|
|
7
6
|
constructor(message: string);
|
|
@@ -14,8 +13,11 @@ declare function findMaxRId(relsXml: string): number;
|
|
|
14
13
|
* Options for repacking DOCX
|
|
15
14
|
*/
|
|
16
15
|
type RepackOptions = {
|
|
17
|
-
/** Compression level (0-9, default: 6) */
|
|
18
|
-
|
|
16
|
+
/** Compression level (0-9, default: 6) */
|
|
17
|
+
compressionLevel?: number;
|
|
18
|
+
/** Whether to update modification date in docProps/core.xml */
|
|
19
|
+
updateModifiedDate?: boolean;
|
|
20
|
+
/** Custom modifier name for lastModifiedBy */
|
|
19
21
|
modifiedBy?: string;
|
|
20
22
|
};
|
|
21
23
|
/**
|
|
@@ -125,10 +127,7 @@ declare function hasUnmaterializedHeaderFooter(doc: document_d_exports.Document)
|
|
|
125
127
|
declare function hasModelDrivenPictureWatermark(doc: document_d_exports.Document): boolean;
|
|
126
128
|
declare function collectHeaderFooterUpdates(doc: document_d_exports.Document): Map<string, string>;
|
|
127
129
|
/** Update existing core-property values without synthesizing absent metadata. */
|
|
128
|
-
declare function updateCoreProperties(corePropsXml: string, {
|
|
129
|
-
updateModifiedDate,
|
|
130
|
-
modifiedBy
|
|
131
|
-
}: {
|
|
130
|
+
declare function updateCoreProperties(corePropsXml: string, { updateModifiedDate, modifiedBy }: {
|
|
132
131
|
updateModifiedDate?: boolean;
|
|
133
132
|
modifiedBy?: string;
|
|
134
133
|
}): string;
|
package/dist/docx/rezip.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { findChild, getChildElements, matchesName, parseXml } from "./xmlParser.js";
|
|
1
2
|
import { parseNumbering } from "./numberingParser.js";
|
|
2
3
|
import { RELATIONSHIP_TYPES, parseRelationships, resolveRelativePath } from "./relsParser.js";
|
|
3
4
|
import { parseEndnotes, parseFootnotes } from "./footnoteParser.js";
|
|
@@ -5,6 +6,7 @@ import { assertValidFolioDocumentModel } from "./modelValidation.js";
|
|
|
5
6
|
import { isPreservableDocxEntry } from "./unzip.js";
|
|
6
7
|
import { applyReplyThreadMarkers } from "./commentReplyMarkers.js";
|
|
7
8
|
import { withoutOrphanCommentRanges } from "./commentRangeIntegrity.js";
|
|
9
|
+
import { isNewDataUrlDrawing } from "./newImage.js";
|
|
8
10
|
import { buildParagraphOffsetIndex, buildPatchedNoteXml, buildPatchedNumberingXml, collectChangedNumberingDefs, collectParaIds } from "./selectiveXmlPatch.js";
|
|
9
11
|
import { escapeXml } from "./serializer/xmlUtils.js";
|
|
10
12
|
import { ensureThreadedCommentParaIds, serializeComments, serializeCommentsExtended } from "./serializer/commentSerializer.js";
|
|
@@ -95,11 +97,15 @@ function assertDocumentPackageFidelity(originalDocumentXml, serializedDocumentXm
|
|
|
95
97
|
}
|
|
96
98
|
async function serializeCommentsToZip(doc, zip, compressionLevel) {
|
|
97
99
|
const comments = doc.package.document.comments ?? [];
|
|
98
|
-
const
|
|
99
|
-
if (comments.length === 0
|
|
100
|
+
const sourceCommentsFile = findZipEntryCaseInsensitive(zip, "word/comments.xml");
|
|
101
|
+
if (comments.length === 0) {
|
|
102
|
+
if (!sourceCommentsFile) return;
|
|
103
|
+
const sourceCommentsXml = await sourceCommentsFile.async("text");
|
|
104
|
+
if (!hasCommentEntries(sourceCommentsXml)) return;
|
|
105
|
+
}
|
|
100
106
|
ensureThreadedCommentParaIds(comments);
|
|
101
107
|
const commentsXml = serializeComments(comments);
|
|
102
|
-
zip.file("word/comments.xml", commentsXml, {
|
|
108
|
+
zip.file(sourceCommentsFile?.name ?? "word/comments.xml", commentsXml, {
|
|
103
109
|
compression: "DEFLATE",
|
|
104
110
|
compressionOptions: { level: compressionLevel }
|
|
105
111
|
});
|
|
@@ -107,6 +113,10 @@ async function serializeCommentsToZip(doc, zip, compressionLevel) {
|
|
|
107
113
|
await ensureCommentsRelationship(zip, compressionLevel);
|
|
108
114
|
await syncCommentsExtendedPart(comments, zip, compressionLevel);
|
|
109
115
|
}
|
|
116
|
+
const hasCommentEntries = (xml) => {
|
|
117
|
+
const root = parseXml(xml);
|
|
118
|
+
return getChildElements(findChild(root, "w", "comments") ?? root).some((element) => matchesName(element, "w", "comment"));
|
|
119
|
+
};
|
|
110
120
|
/**
|
|
111
121
|
* Bring `word/commentsExtended.xml` and its packaging (content-type override +
|
|
112
122
|
* relationship) in line with the model: write the part when there is thread /
|
|
@@ -235,18 +245,10 @@ async function registerImageExtensions(zip, extensions, compressionLevel) {
|
|
|
235
245
|
compressionOptions: { level: compressionLevel }
|
|
236
246
|
});
|
|
237
247
|
}
|
|
238
|
-
/**
|
|
239
|
-
* Collect all newly inserted images with data-URL src from the document content.
|
|
240
|
-
* Existing DOCX images may also have a resolved data URL for preview; those must
|
|
241
|
-
* continue to reference their original media part. Editor-created images use a
|
|
242
|
-
* synthetic rId until they are assigned a real DOCX relationship here.
|
|
243
|
-
*/
|
|
244
|
-
const SYNTHETIC_IMAGE_RID_PREFIX = "rId_img_";
|
|
245
|
-
const isNewDataUrlImage = (image) => image.src?.startsWith("data:") && (!image.rId || image.rId.startsWith(SYNTHETIC_IMAGE_RID_PREFIX));
|
|
246
248
|
function collectNewImages(blocks) {
|
|
247
249
|
const images = [];
|
|
248
250
|
const collectFromRun = (run) => {
|
|
249
|
-
for (const c of run.content) if (
|
|
251
|
+
for (const c of run.content) if (isNewDataUrlDrawing(c)) images.push(c.image);
|
|
250
252
|
};
|
|
251
253
|
for (const block of blocks) if (block.type === "paragraph") {
|
|
252
254
|
for (const item of block.content) if (item.type === "run") collectFromRun(item);
|
|
@@ -270,13 +272,18 @@ const MIME_TO_EXT = {
|
|
|
270
272
|
* Decode a data URL to binary ArrayBuffer and file extension.
|
|
271
273
|
*/
|
|
272
274
|
function decodeDataUrl(dataUrl) {
|
|
273
|
-
const match = /^data:(?<mime>[
|
|
275
|
+
const match = /^data:(?<mime>[^;,]+)(?<parameters>(?:;[^,]*)?),(?<data>[\s\S]*)$/u.exec(dataUrl);
|
|
274
276
|
if (!match) panic("Invalid data URL");
|
|
275
|
-
const
|
|
276
|
-
const
|
|
277
|
-
|
|
277
|
+
const payload = match.groups["data"];
|
|
278
|
+
const parameters = match.groups["parameters"];
|
|
279
|
+
let bytes;
|
|
280
|
+
if (parameters.split(";").some((parameter) => parameter.toLowerCase() === "base64")) {
|
|
281
|
+
const binary = atob(payload);
|
|
282
|
+
bytes = new Uint8Array(binary.length);
|
|
283
|
+
for (let i = 0; i < binary.length; i++) bytes[i] = binary.codePointAt(i) ?? 0;
|
|
284
|
+
} else bytes = new TextEncoder().encode(decodeURIComponent(payload));
|
|
278
285
|
return {
|
|
279
|
-
data: bytes.buffer,
|
|
286
|
+
data: bytes.slice().buffer,
|
|
280
287
|
extension: MIME_TO_EXT[match.groups["mime"]] ?? "png"
|
|
281
288
|
};
|
|
282
289
|
}
|
|
@@ -360,6 +367,64 @@ async function processNewHyperlinks(newHyperlinks, zip, compressionLevel) {
|
|
|
360
367
|
});
|
|
361
368
|
}
|
|
362
369
|
}
|
|
370
|
+
const generateDocxZip = (zip, compressionLevel) => zip.generateAsync({
|
|
371
|
+
type: "arraybuffer",
|
|
372
|
+
compression: "DEFLATE",
|
|
373
|
+
compressionOptions: { level: compressionLevel }
|
|
374
|
+
});
|
|
375
|
+
const parsedZipSources = /* @__PURE__ */ new WeakMap();
|
|
376
|
+
const removeNonPreservableEntries = (zip) => {
|
|
377
|
+
for (const [path, file] of Object.entries(zip.files)) if (!file.dir && !isPreservableDocxEntry(path)) zip.remove(path);
|
|
378
|
+
};
|
|
379
|
+
const loadParsedZipSource = async (document, buffer) => {
|
|
380
|
+
const cached = parsedZipSources.get(document);
|
|
381
|
+
if (cached?.buffer === buffer) return cached;
|
|
382
|
+
const zip = await JSZip.loadAsync(buffer);
|
|
383
|
+
removeNonPreservableEntries(zip);
|
|
384
|
+
const [documentXml, corePropertiesXml] = await Promise.all([zip.file("word/document.xml")?.async("text"), zip.file("docProps/core.xml")?.async("text")]);
|
|
385
|
+
const source = {
|
|
386
|
+
buffer,
|
|
387
|
+
zip,
|
|
388
|
+
documentXml,
|
|
389
|
+
corePropertiesXml
|
|
390
|
+
};
|
|
391
|
+
parsedZipSources.set(document, source);
|
|
392
|
+
return source;
|
|
393
|
+
};
|
|
394
|
+
const cloneDocxZip = (source) => {
|
|
395
|
+
const clone = new JSZip();
|
|
396
|
+
clone.files = { ...source.files };
|
|
397
|
+
return clone;
|
|
398
|
+
};
|
|
399
|
+
const finishRepack = async ({ document, originalZip, outputZip, originalDocumentXml, originalCorePropertiesXml, compressionLevel, updateModifiedDate, modifiedBy }) => {
|
|
400
|
+
await materializeNewHeaderFooterParts(document, outputZip, compressionLevel);
|
|
401
|
+
await processNewImages(collectImageParts(document), outputZip, compressionLevel);
|
|
402
|
+
await processNewHyperlinks(collectHyperlinksWithoutRId(document.package.document.content), outputZip, compressionLevel);
|
|
403
|
+
assertValidFolioDocumentModel(document, "Cannot repack invalid DOCX document model");
|
|
404
|
+
applyReplyThreadMarkers(document);
|
|
405
|
+
const documentXml = serializeDocument(document);
|
|
406
|
+
if (originalDocumentXml) assertDocumentPackageFidelity(originalDocumentXml, documentXml, document);
|
|
407
|
+
outputZip.file("word/document.xml", documentXml, {
|
|
408
|
+
compression: "DEFLATE",
|
|
409
|
+
compressionOptions: { level: compressionLevel }
|
|
410
|
+
});
|
|
411
|
+
await rebindWatermarkRelIds(document, outputZip, compressionLevel);
|
|
412
|
+
serializeHeadersFootersToZip(document, outputZip, compressionLevel);
|
|
413
|
+
await serializeNotesToZip(document, originalZip, outputZip, compressionLevel);
|
|
414
|
+
await serializeNumberingIntoZip(document, originalZip, outputZip, compressionLevel);
|
|
415
|
+
await serializeCommentsToZip(document, outputZip, compressionLevel);
|
|
416
|
+
if (updateModifiedDate && originalCorePropertiesXml) {
|
|
417
|
+
const updatedCoreProperties = updateCoreProperties(originalCorePropertiesXml, {
|
|
418
|
+
updateModifiedDate,
|
|
419
|
+
...modifiedBy !== void 0 ? { modifiedBy } : {}
|
|
420
|
+
});
|
|
421
|
+
outputZip.file("docProps/core.xml", updatedCoreProperties, {
|
|
422
|
+
compression: "DEFLATE",
|
|
423
|
+
compressionOptions: { level: compressionLevel }
|
|
424
|
+
});
|
|
425
|
+
}
|
|
426
|
+
return generateDocxZip(outputZip, compressionLevel);
|
|
427
|
+
};
|
|
363
428
|
/**
|
|
364
429
|
* Repack a Document into a valid DOCX file
|
|
365
430
|
*
|
|
@@ -373,54 +438,18 @@ async function repackDocx(doc, options = {}) {
|
|
|
373
438
|
const { compressionLevel = 6, updateModifiedDate = true, modifiedBy } = options;
|
|
374
439
|
const exportDocument = withoutOrphanCommentRanges(doc);
|
|
375
440
|
const originalZip = await JSZip.loadAsync(doc.originalBuffer);
|
|
376
|
-
const
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
await materializeNewHeaderFooterParts(exportDocument, newZip, compressionLevel);
|
|
390
|
-
await processNewImages(collectImageParts(exportDocument), newZip, compressionLevel);
|
|
391
|
-
await processNewHyperlinks(collectHyperlinksWithoutRId(exportDocument.package.document.content), newZip, compressionLevel);
|
|
392
|
-
assertValidFolioDocumentModel(exportDocument, "Cannot repack invalid DOCX document model");
|
|
393
|
-
applyReplyThreadMarkers(exportDocument);
|
|
394
|
-
const documentXml = serializeDocument(exportDocument);
|
|
395
|
-
const originalDocumentXml = await originalZip.file("word/document.xml")?.async("text");
|
|
396
|
-
if (originalDocumentXml) assertDocumentPackageFidelity(originalDocumentXml, documentXml, exportDocument);
|
|
397
|
-
newZip.file("word/document.xml", documentXml, {
|
|
398
|
-
compression: "DEFLATE",
|
|
399
|
-
compressionOptions: { level: compressionLevel }
|
|
400
|
-
});
|
|
401
|
-
await rebindWatermarkRelIds(exportDocument, newZip, compressionLevel);
|
|
402
|
-
serializeHeadersFootersToZip(exportDocument, newZip, compressionLevel);
|
|
403
|
-
await serializeNotesToZip(exportDocument, originalZip, newZip, compressionLevel);
|
|
404
|
-
await serializeNumberingIntoZip(exportDocument, originalZip, newZip, compressionLevel);
|
|
405
|
-
await serializeCommentsToZip(exportDocument, newZip, compressionLevel);
|
|
406
|
-
if (updateModifiedDate) {
|
|
407
|
-
const corePropsPath = "docProps/core.xml";
|
|
408
|
-
const corePropsFile = originalZip.file(corePropsPath);
|
|
409
|
-
if (corePropsFile) {
|
|
410
|
-
const updatedCoreProps = updateCoreProperties(await corePropsFile.async("text"), {
|
|
411
|
-
updateModifiedDate,
|
|
412
|
-
...modifiedBy !== void 0 ? { modifiedBy } : {}
|
|
413
|
-
});
|
|
414
|
-
newZip.file(corePropsPath, updatedCoreProps, {
|
|
415
|
-
compression: "DEFLATE",
|
|
416
|
-
compressionOptions: { level: compressionLevel }
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
return await newZip.generateAsync({
|
|
421
|
-
type: "arraybuffer",
|
|
422
|
-
compression: "DEFLATE",
|
|
423
|
-
compressionOptions: { level: compressionLevel }
|
|
441
|
+
const [originalDocumentXml, originalCorePropertiesXml] = await Promise.all([originalZip.file("word/document.xml")?.async("text"), originalZip.file("docProps/core.xml")?.async("text")]);
|
|
442
|
+
removeNonPreservableEntries(originalZip);
|
|
443
|
+
const newZip = cloneDocxZip(originalZip);
|
|
444
|
+
return finishRepack({
|
|
445
|
+
document: exportDocument,
|
|
446
|
+
originalZip,
|
|
447
|
+
outputZip: newZip,
|
|
448
|
+
originalDocumentXml,
|
|
449
|
+
originalCorePropertiesXml,
|
|
450
|
+
compressionLevel,
|
|
451
|
+
updateModifiedDate,
|
|
452
|
+
...modifiedBy !== void 0 ? { modifiedBy } : {}
|
|
424
453
|
});
|
|
425
454
|
}
|
|
426
455
|
/**
|
|
@@ -953,32 +982,26 @@ async function serializeNotesToZip(doc, originalZip, newZip, compressionLevel) {
|
|
|
953
982
|
const endnotes = doc.package.endnotes ?? [];
|
|
954
983
|
if (endnotes.length > 0) await patchNotePartIntoZip("word/endnotes.xml", serializeEndnotes(endnotes), (xml) => serializeEndnotes(parseEndnotes(xml).getNormalEndnotes()), originalZip, newZip, compressionLevel);
|
|
955
984
|
}
|
|
956
|
-
|
|
957
|
-
* Write edited numbering definitions into word/numbering.xml.
|
|
958
|
-
*
|
|
959
|
-
* Like the note parts, numbering.xml is preserved verbatim by the copy loop:
|
|
960
|
-
* the model does not faithfully retain it (abstractNums drop `w:nsid`/`w:tmpl`,
|
|
961
|
-
* custom number formats collapse, level `w:pPr`/`w:rPr` keep only a subset), so
|
|
962
|
-
* re-emitting the whole part would lose those pieces. Instead each edited
|
|
963
|
-
* `w:abstractNum` / `w:num` is spliced by id into the ORIGINAL part.
|
|
964
|
-
*
|
|
965
|
-
* Full repack has no change-tracking signal, so "edited" is detected by
|
|
966
|
-
* comparing the model's numbering serialization against a BASELINE that
|
|
967
|
-
* re-parses and re-serializes the original part. Both go through the same
|
|
968
|
-
* (lossy) parse+serialize, so an unedited definition matches its baseline and
|
|
969
|
-
* is left byte-exact; only a genuine definition edit differs and is spliced.
|
|
970
|
-
*/
|
|
985
|
+
const numberingBaselines = /* @__PURE__ */ new WeakMap();
|
|
971
986
|
async function serializeNumberingIntoZip(doc, originalZip, newZip, compressionLevel) {
|
|
972
987
|
const numbering = doc.package.numbering;
|
|
973
988
|
if (!numbering || numbering.abstractNums.length === 0 && numbering.nums.length === 0) return;
|
|
974
989
|
const file = findNotePartEntry(originalZip, "word/numbering.xml");
|
|
975
990
|
if (!file) return;
|
|
976
|
-
|
|
977
|
-
|
|
991
|
+
let baseline = doc.originalBuffer ? numberingBaselines.get(doc) : void 0;
|
|
992
|
+
if (!baseline || baseline.originalBuffer !== doc.originalBuffer) {
|
|
993
|
+
const originalXml = await file.async("text");
|
|
994
|
+
baseline = {
|
|
995
|
+
originalBuffer: doc.originalBuffer,
|
|
996
|
+
originalXml,
|
|
997
|
+
serializedXml: serializeNumberingXml(parseNumbering(originalXml).definitions)
|
|
998
|
+
};
|
|
999
|
+
if (doc.originalBuffer) numberingBaselines.set(doc, baseline);
|
|
1000
|
+
}
|
|
978
1001
|
const currentXml = serializeNumberingXml(numbering);
|
|
979
|
-
const changed = collectChangedNumberingDefs(
|
|
1002
|
+
const changed = collectChangedNumberingDefs(baseline.serializedXml, currentXml);
|
|
980
1003
|
if (changed.abstractNums.size === 0 && changed.nums.size === 0) return;
|
|
981
|
-
const patched = buildPatchedNumberingXml(originalXml, currentXml, changed);
|
|
1004
|
+
const patched = buildPatchedNumberingXml(baseline.originalXml, currentXml, changed);
|
|
982
1005
|
if (patched === null) return;
|
|
983
1006
|
newZip.file(file.name, patched, {
|
|
984
1007
|
compression: "DEFLATE",
|
|
@@ -1119,6 +1142,9 @@ function isDocxBuffer(buffer) {
|
|
|
1119
1142
|
* @returns Promise resolving to minimal DOCX as ArrayBuffer
|
|
1120
1143
|
*/
|
|
1121
1144
|
function createEmptyDocx() {
|
|
1145
|
+
return generateDocxZip(createEmptyDocxZip(), 6);
|
|
1146
|
+
}
|
|
1147
|
+
const createEmptyDocxZip = () => {
|
|
1122
1148
|
const zip = new JSZip();
|
|
1123
1149
|
zip.file("[Content_Types].xml", `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
1124
1150
|
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types">
|
|
@@ -1184,12 +1210,8 @@ function createEmptyDocx() {
|
|
|
1184
1210
|
<Application>EigenPal DOCX Editor</Application>
|
|
1185
1211
|
<AppVersion>1.0000</AppVersion>
|
|
1186
1212
|
</Properties>`);
|
|
1187
|
-
return zip
|
|
1188
|
-
|
|
1189
|
-
compression: "DEFLATE",
|
|
1190
|
-
compressionOptions: { level: 6 }
|
|
1191
|
-
});
|
|
1192
|
-
}
|
|
1213
|
+
return zip;
|
|
1214
|
+
};
|
|
1193
1215
|
/**
|
|
1194
1216
|
* Create a new DOCX from a Document (without requiring original buffer)
|
|
1195
1217
|
*
|
|
@@ -1197,15 +1219,31 @@ function createEmptyDocx() {
|
|
|
1197
1219
|
* @returns Promise resolving to DOCX as ArrayBuffer
|
|
1198
1220
|
*/
|
|
1199
1221
|
async function createDocx(doc) {
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1222
|
+
if (doc.originalBuffer) {
|
|
1223
|
+
const source = await loadParsedZipSource(doc, doc.originalBuffer);
|
|
1224
|
+
return finishRepack({
|
|
1225
|
+
document: withoutOrphanCommentRanges(doc),
|
|
1226
|
+
originalZip: source.zip,
|
|
1227
|
+
outputZip: cloneDocxZip(source.zip),
|
|
1228
|
+
originalDocumentXml: source.documentXml,
|
|
1229
|
+
originalCorePropertiesXml: source.corePropertiesXml,
|
|
1230
|
+
compressionLevel: 6,
|
|
1231
|
+
updateModifiedDate: true
|
|
1232
|
+
});
|
|
1233
|
+
}
|
|
1234
|
+
const zip = await createDocumentSeedZip(doc);
|
|
1235
|
+
return finishRepack({
|
|
1236
|
+
document: withoutOrphanCommentRanges(doc),
|
|
1237
|
+
originalZip: zip,
|
|
1238
|
+
outputZip: zip,
|
|
1239
|
+
originalDocumentXml: void 0,
|
|
1240
|
+
originalCorePropertiesXml: await zip.file("docProps/core.xml")?.async("text"),
|
|
1241
|
+
compressionLevel: 6,
|
|
1242
|
+
updateModifiedDate: true
|
|
1204
1243
|
});
|
|
1205
1244
|
}
|
|
1206
|
-
const
|
|
1207
|
-
const
|
|
1208
|
-
const zip = await JSZip.loadAsync(buffer);
|
|
1245
|
+
const createDocumentSeedZip = async (doc) => {
|
|
1246
|
+
const zip = createEmptyDocxZip();
|
|
1209
1247
|
const relationships = ["<Relationship Id=\"rId1\" Type=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles\" Target=\"styles.xml\"/>"];
|
|
1210
1248
|
const overrides = [];
|
|
1211
1249
|
let nextRelationshipId = 2;
|
|
@@ -1244,11 +1282,7 @@ const createDocumentSeedDocx = async (doc) => {
|
|
|
1244
1282
|
const contentTypes = await contentTypesFile.async("string");
|
|
1245
1283
|
zip.file("[Content_Types].xml", contentTypes.replace("</Types>", `${overrides.join("")}\n</Types>`));
|
|
1246
1284
|
}
|
|
1247
|
-
return zip
|
|
1248
|
-
type: "arraybuffer",
|
|
1249
|
-
compression: "DEFLATE",
|
|
1250
|
-
compressionOptions: { level: 6 }
|
|
1251
|
-
});
|
|
1285
|
+
return zip;
|
|
1252
1286
|
};
|
|
1253
1287
|
const relationshipXml = (id, type, target) => `<Relationship Id="rId${id}" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/${type}" Target="${target}"/>`;
|
|
1254
1288
|
const overrideXml = (partName, contentType) => `<Override PartName="${partName}" ContentType="${contentType}"/>`;
|
package/dist/docx/runParser.d.ts
CHANGED
package/dist/docx/runParser.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { EmphasisMarkSchema, FontThemeSchema, HighlightColorSchema, ShadingPatternSchema, TextEffectSchema, ThemeColorSlotSchema, UnderlineStyleSchema, narrowEnum } from "./parserEnums.js";
|
|
2
|
-
import { cloneWithXmlnsDeclarations, elementToXml, findAllDeep, findChild, findChildren, getAttribute, getChildElements, getTextContent, mergeXmlnsDeclarations, parseBooleanElement, parseNumericAttribute } from "./xmlParser.js";
|
|
1
|
+
import { EmphasisMarkSchema, FontHintSchema, FontThemeSchema, HighlightColorSchema, ShadingPatternSchema, TextEffectSchema, ThemeColorSlotSchema, UnderlineStyleSchema, narrowEnum } from "./parserEnums.js";
|
|
2
|
+
import { cloneWithXmlnsDeclarations, elementToXml, findAllDeep, findChild, findChildren, getAttribute, getChildElements, getLocalName, getTextContent, mergeXmlnsDeclarations, parseBooleanElement, parseNumericAttribute } from "./xmlParser.js";
|
|
3
|
+
import { isTextBoxDrawing } from "./textBoxParser.js";
|
|
3
4
|
import { parseImage } from "./imageParser.js";
|
|
4
5
|
import { parseGroupDrawing } from "./groupDrawingParser.js";
|
|
5
6
|
import { parseShapeFromDrawing, shouldPreserveRawShapeDrawing } from "./shapeParser.js";
|
|
6
7
|
import { parseVmlImageContent } from "./vmlImageParser.js";
|
|
7
8
|
import { resolveThemeFontRef } from "./themeParser.js";
|
|
9
|
+
import { requiresXmlSpacePreserve } from "./textWhitespace.js";
|
|
8
10
|
import { normalizeRevisionId } from "@stll/docx-core/model";
|
|
9
11
|
//#region src/docx/runParser.ts
|
|
10
12
|
/**
|
|
@@ -240,6 +242,8 @@ function parseRunProperties(rPr, theme, _styles) {
|
|
|
240
242
|
if (eastAsia) fontFamily.eastAsia = eastAsia;
|
|
241
243
|
const csFont = getAttribute(rFonts, "w", "cs");
|
|
242
244
|
if (csFont) fontFamily.cs = csFont;
|
|
245
|
+
const hint = narrowEnum(getAttribute(rFonts, "w", "hint"), FontHintSchema);
|
|
246
|
+
if (hint) fontFamily.hint = hint;
|
|
243
247
|
const asciiTheme = narrowEnum(getAttribute(rFonts, "w", "asciiTheme"), FontThemeSchema);
|
|
244
248
|
if (asciiTheme) {
|
|
245
249
|
fontFamily.asciiTheme = asciiTheme;
|
|
@@ -368,7 +372,7 @@ function parseRunPropertyChanges(rPr, theme, styles, currentFormatting) {
|
|
|
368
372
|
*/
|
|
369
373
|
function parseTextContent(element) {
|
|
370
374
|
const text = getTextContent(element);
|
|
371
|
-
const preserveSpace = getAttribute(element, "xml", "space") === "preserve";
|
|
375
|
+
const preserveSpace = getAttribute(element, "xml", "space") === "preserve" || requiresXmlSpacePreserve(text);
|
|
372
376
|
const content = {
|
|
373
377
|
type: "text",
|
|
374
378
|
text
|
|
@@ -500,14 +504,6 @@ function parseDrawingContent(element, rels, media) {
|
|
|
500
504
|
return drawing;
|
|
501
505
|
}
|
|
502
506
|
/**
|
|
503
|
-
* Get the local name of an element (without namespace prefix)
|
|
504
|
-
*/
|
|
505
|
-
function getLocalName(name) {
|
|
506
|
-
if (!name) return "";
|
|
507
|
-
const colonIndex = name.indexOf(":");
|
|
508
|
-
return colonIndex !== -1 ? name.slice(colonIndex + 1) : name;
|
|
509
|
-
}
|
|
510
|
-
/**
|
|
511
507
|
* Parse all content within a run element
|
|
512
508
|
*/
|
|
513
509
|
function parseRunContents(runElement, rels, media, rootXmlns = {}) {
|
|
@@ -573,6 +569,7 @@ function parseRunContents(runElement, rels, media, rootXmlns = {}) {
|
|
|
573
569
|
const alternateChildren = getChildElements(child);
|
|
574
570
|
const choiceEl = alternateChildren.find((el) => getLocalName(el.name) === "Choice");
|
|
575
571
|
const fallbackEl = alternateChildren.find((el) => getLocalName(el.name) === "Fallback");
|
|
572
|
+
const choiceTextBoxDrawing = choiceEl ? getChildElements(choiceEl).find((element) => getLocalName(element.name) === "drawing" && isTextBoxDrawing(element)) : void 0;
|
|
576
573
|
const groupedChoiceDrawing = choiceEl ? getChildElements(choiceEl).find((element) => getLocalName(element.name) === "drawing" && findAllDeep(element, "wpg", "wgp").length > 0) : void 0;
|
|
577
574
|
if (groupedChoiceDrawing) {
|
|
578
575
|
const groupedDrawing = parseDrawingContent(groupedChoiceDrawing, rels, media);
|
|
@@ -583,7 +580,7 @@ function parseRunContents(runElement, rels, media, rootXmlns = {}) {
|
|
|
583
580
|
}
|
|
584
581
|
}
|
|
585
582
|
const fallbackPict = fallbackEl ? getChildElements(fallbackEl).find((el) => getLocalName(el.name) === "pict") : void 0;
|
|
586
|
-
const fallbackVml = fallbackPict ? parseVmlImageContent(fallbackPict, rels, media, rootXmlns) : null;
|
|
583
|
+
const fallbackVml = fallbackPict && !choiceTextBoxDrawing ? parseVmlImageContent(fallbackPict, rels, media, rootXmlns) : null;
|
|
587
584
|
if (fallbackVml?.image.src) {
|
|
588
585
|
fallbackVml.rawXml = elementToXml(cloneWithXmlnsDeclarations(child, rootXmlns));
|
|
589
586
|
contents.push(fallbackVml);
|