@stll/folio-core 0.0.1-placeholder.0 → 0.1.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/LICENSE +202 -0
- package/NOTICE.md +29 -0
- package/README.md +41 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/ai-edits/apply.d.ts +35 -0
- package/dist/ai-edits/apply.js +683 -0
- package/dist/ai-edits/clean-text.d.ts +28 -0
- package/dist/ai-edits/clean-text.js +23 -0
- package/dist/ai-edits/headless.d.ts +225 -0
- package/dist/ai-edits/headless.js +513 -0
- package/dist/ai-edits/index.d.ts +6 -0
- package/dist/ai-edits/index.js +5 -0
- package/dist/ai-edits/inline-emphasis.d.ts +38 -0
- package/dist/ai-edits/inline-emphasis.js +78 -0
- package/dist/ai-edits/snapshot.d.ts +9 -0
- package/dist/ai-edits/snapshot.js +195 -0
- package/dist/ai-edits/types.d.ts +156 -0
- package/dist/ai-edits/types.js +0 -0
- package/dist/ai-edits/word-diff.d.ts +20 -0
- package/dist/ai-edits/word-diff.js +77 -0
- package/dist/ai-suggestions/apply.d.ts +17 -0
- package/dist/ai-suggestions/apply.js +64 -0
- package/dist/ai-suggestions/conflict.d.ts +22 -0
- package/dist/ai-suggestions/conflict.js +67 -0
- package/dist/ai-suggestions/text-positions.d.ts +21 -0
- package/dist/ai-suggestions/text-positions.js +48 -0
- package/dist/ai-suggestions/types.d.ts +199 -0
- package/dist/ai-suggestions/types.js +59 -0
- package/dist/content-controls/errors.d.ts +52 -0
- package/dist/content-controls/errors.js +36 -0
- package/dist/content-controls/findContentControls.d.ts +55 -0
- package/dist/content-controls/findContentControls.js +75 -0
- package/dist/content-controls/index.d.ts +4 -0
- package/dist/content-controls/index.js +4 -0
- package/dist/content-controls/mutateContentControls.d.ts +51 -0
- package/dist/content-controls/mutateContentControls.js +377 -0
- package/dist/controller/folioEditor.d.ts +21 -0
- package/dist/controller/folioEditor.js +29 -0
- package/dist/controller/folioEditorEvents.d.ts +23 -0
- package/dist/controller/folioEditorEvents.js +24 -0
- package/dist/controller/hiddenEditorApi.d.ts +35 -0
- package/dist/controller/hiddenEditorApi.js +112 -0
- package/dist/controller/hiddenEditorManager.d.ts +93 -0
- package/dist/controller/hiddenEditorManager.js +308 -0
- package/dist/controller/layoutPipeline.d.ts +63 -0
- package/dist/controller/layoutPipeline.js +406 -0
- package/dist/controller/layoutScheduler.d.ts +41 -0
- package/dist/controller/layoutScheduler.js +59 -0
- package/dist/controller/layoutSession.d.ts +24 -0
- package/dist/controller/layoutSession.js +13 -0
- package/dist/docx/blockContentParser.d.ts +13 -0
- package/dist/docx/blockContentParser.js +289 -0
- package/dist/docx/bookmarkParser.d.ts +178 -0
- package/dist/docx/bookmarkParser.js +246 -0
- package/dist/docx/bookmarkPlacement.d.ts +10 -0
- package/dist/docx/bookmarkPlacement.js +50 -0
- package/dist/docx/bulletMarkers.d.ts +4 -0
- package/dist/docx/bulletMarkers.js +42 -0
- package/dist/docx/commentParser.d.ts +34 -0
- package/dist/docx/commentParser.js +127 -0
- package/dist/docx/commentReferenceNormalization.d.ts +25 -0
- package/dist/docx/commentReferenceNormalization.js +97 -0
- package/dist/docx/commentReplyMarkers.d.ts +20 -0
- package/dist/docx/commentReplyMarkers.js +123 -0
- package/dist/docx/compatibility.d.ts +12 -0
- package/dist/docx/compatibility.js +77 -0
- package/dist/docx/documentParser.d.ts +65 -0
- package/dist/docx/documentParser.js +209 -0
- package/dist/docx/drawingUtils.d.ts +56 -0
- package/dist/docx/drawingUtils.js +305 -0
- package/dist/docx/fieldParser.d.ts +228 -0
- package/dist/docx/fieldParser.js +559 -0
- package/dist/docx/footnoteParser.d.ts +109 -0
- package/dist/docx/footnoteParser.js +270 -0
- package/dist/docx/headerFooterParser.d.ts +119 -0
- package/dist/docx/headerFooterParser.js +266 -0
- package/dist/docx/headerFooterRefParser.d.ts +22 -0
- package/dist/docx/headerFooterRefParser.js +52 -0
- package/dist/docx/headerFooterReferenceNormalization.d.ts +19 -0
- package/dist/docx/headerFooterReferenceNormalization.js +64 -0
- package/dist/docx/hyperlinkParser.d.ts +108 -0
- package/dist/docx/hyperlinkParser.js +230 -0
- package/dist/docx/imageParser.d.ts +93 -0
- package/dist/docx/imageParser.js +522 -0
- package/dist/docx/mathToMathml.d.ts +15 -0
- package/dist/docx/mathToMathml.js +357 -0
- package/dist/docx/modelValidation.d.ts +13 -0
- package/dist/docx/modelValidation.js +21 -0
- package/dist/docx/normalizeBaseDirection.d.ts +12 -0
- package/dist/docx/normalizeBaseDirection.js +81 -0
- package/dist/docx/notePropertiesParser.d.ts +16 -0
- package/dist/docx/notePropertiesParser.js +99 -0
- package/dist/docx/numberingParser.d.ts +86 -0
- package/dist/docx/numberingParser.js +735 -0
- package/dist/docx/numberingReferenceNormalization.d.ts +25 -0
- package/dist/docx/numberingReferenceNormalization.js +22 -0
- package/dist/docx/paragraphParser.d.ts +86 -0
- package/dist/docx/paragraphParser.js +1132 -0
- package/dist/docx/paragraphTraversal.d.ts +19 -0
- package/dist/docx/paragraphTraversal.js +76 -0
- package/dist/docx/parser.d.ts +67 -0
- package/dist/docx/parser.js +391 -0
- package/dist/docx/parserEnums.d.ts +45 -0
- package/dist/docx/parserEnums.js +70 -0
- package/dist/docx/relsParser.d.ts +160 -0
- package/dist/docx/relsParser.js +235 -0
- package/dist/docx/replyToComment.d.ts +29 -0
- package/dist/docx/replyToComment.js +73 -0
- package/dist/docx/rezip.d.ts +166 -0
- package/dist/docx/rezip.js +1194 -0
- package/dist/docx/runConsolidator.d.ts +57 -0
- package/dist/docx/runConsolidator.js +224 -0
- package/dist/docx/runParser.d.ts +78 -0
- package/dist/docx/runParser.js +661 -0
- package/dist/docx/sdtProperties.d.ts +15 -0
- package/dist/docx/sdtProperties.js +290 -0
- package/dist/docx/sdtPropertiesPatch.d.ts +16 -0
- package/dist/docx/sdtPropertiesPatch.js +144 -0
- package/dist/docx/sectionParser.d.ts +95 -0
- package/dist/docx/sectionParser.js +534 -0
- package/dist/docx/selectiveSave.d.ts +25 -0
- package/dist/docx/selectiveSave.js +247 -0
- package/dist/docx/selectiveSaveFlags.d.ts +33 -0
- package/dist/docx/selectiveSaveFlags.js +11 -0
- package/dist/docx/selectiveSaveTripwire.d.ts +33 -0
- package/dist/docx/selectiveSaveTripwire.js +79 -0
- package/dist/docx/selectiveXmlPatch.d.ts +103 -0
- package/dist/docx/selectiveXmlPatch.js +493 -0
- package/dist/docx/serializer/blockSdtSerializer.d.ts +6 -0
- package/dist/docx/serializer/blockSdtSerializer.js +88 -0
- package/dist/docx/serializer/borderSerializer.d.ts +25 -0
- package/dist/docx/serializer/borderSerializer.js +44 -0
- package/dist/docx/serializer/commentSerializer.d.ts +31 -0
- package/dist/docx/serializer/commentSerializer.js +184 -0
- package/dist/docx/serializer/documentSerializer.d.ts +65 -0
- package/dist/docx/serializer/documentSerializer.js +199 -0
- package/dist/docx/serializer/headerFooterSerializer.d.ts +12 -0
- package/dist/docx/serializer/headerFooterSerializer.js +84 -0
- package/dist/docx/serializer/noteSerializer.d.ts +19 -0
- package/dist/docx/serializer/noteSerializer.js +70 -0
- package/dist/docx/serializer/numberingSerializer.d.ts +12 -0
- package/dist/docx/serializer/numberingSerializer.js +93 -0
- package/dist/docx/serializer/paragraphSerializer.d.ts +48 -0
- package/dist/docx/serializer/paragraphSerializer.js +559 -0
- package/dist/docx/serializer/runSerializer.d.ts +56 -0
- package/dist/docx/serializer/runSerializer.js +621 -0
- package/dist/docx/serializer/sectionPropertiesSerializer.d.ts +6 -0
- package/dist/docx/serializer/sectionPropertiesSerializer.js +187 -0
- package/dist/docx/serializer/tableSerializer.d.ts +79 -0
- package/dist/docx/serializer/tableSerializer.js +422 -0
- package/dist/docx/serializer/xmlUtils.d.ts +20 -0
- package/dist/docx/serializer/xmlUtils.js +25 -0
- package/dist/docx/settingsParser.d.ts +8 -0
- package/dist/docx/settingsParser.js +36 -0
- package/dist/docx/shapeParser.d.ts +20 -0
- package/dist/docx/shapeParser.js +272 -0
- package/dist/docx/styleParser.d.ts +50 -0
- package/dist/docx/styleParser.js +905 -0
- package/dist/docx/tableParser.d.ts +202 -0
- package/dist/docx/tableParser.js +811 -0
- package/dist/docx/textBoxParser.d.ts +117 -0
- package/dist/docx/textBoxParser.js +262 -0
- package/dist/docx/themeParser.d.ts +77 -0
- package/dist/docx/themeParser.js +330 -0
- package/dist/docx/trackedMoveRangeNormalization.d.ts +22 -0
- package/dist/docx/trackedMoveRangeNormalization.js +100 -0
- package/dist/docx/unzip.d.ts +118 -0
- package/dist/docx/unzip.js +383 -0
- package/dist/docx/vmlImageParser.d.ts +16 -0
- package/dist/docx/vmlImageParser.js +100 -0
- package/dist/docx/watermarkParser.d.ts +45 -0
- package/dist/docx/watermarkParser.js +348 -0
- package/dist/docx/wrapTypes.d.ts +29 -0
- package/dist/docx/wrapTypes.js +48 -0
- package/dist/docx/xmlParser.d.ts +297 -0
- package/dist/docx/xmlParser.js +527 -0
- package/dist/fields/bookmarkPages.d.ts +13 -0
- package/dist/fields/bookmarkPages.js +66 -0
- package/dist/fields/bookmarkText.d.ts +16 -0
- package/dist/fields/bookmarkText.js +61 -0
- package/dist/fields/evaluateField.d.ts +23 -0
- package/dist/fields/evaluateField.js +77 -0
- package/dist/fields/fieldContext.d.ts +21 -0
- package/dist/fields/fieldContext.js +0 -0
- package/dist/fields/resolveFieldValues.d.ts +44 -0
- package/dist/fields/resolveFieldValues.js +204 -0
- package/dist/fields/sectionPageCounts.d.ts +11 -0
- package/dist/fields/sectionPageCounts.js +16 -0
- package/dist/fields/seqValues.d.ts +14 -0
- package/dist/fields/seqValues.js +36 -0
- package/dist/fonts/embeddedFontTable.d.ts +42 -0
- package/dist/fonts/embeddedFontTable.js +80 -0
- package/dist/fonts/embeddedFonts.d.ts +46 -0
- package/dist/fonts/embeddedFonts.js +112 -0
- package/dist/fonts/fontDeobfuscation.d.ts +30 -0
- package/dist/fonts/fontDeobfuscation.js +57 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +23 -0
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +57 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +316 -0
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +74 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +432 -0
- package/dist/layout-bridge/convert/templatePreviewFlow.d.ts +36 -0
- package/dist/layout-bridge/convert/templatePreviewFlow.js +176 -0
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +65 -0
- package/dist/layout-bridge/convert/toFlowBlocks.js +1309 -0
- package/dist/layout-bridge/convert/wrapEditorViewAsSurface.d.ts +17 -0
- package/dist/layout-bridge/convert/wrapEditorViewAsSurface.js +36 -0
- package/dist/layout-bridge/dom/clickToPositionDom.d.ts +66 -0
- package/dist/layout-bridge/dom/clickToPositionDom.js +304 -0
- package/dist/layout-bridge/dom/findBodyPmSpans.d.ts +7 -0
- package/dist/layout-bridge/dom/findBodyPmSpans.js +17 -0
- package/dist/layout-bridge/dom/findHfPmSpans.d.ts +62 -0
- package/dist/layout-bridge/dom/findHfPmSpans.js +197 -0
- package/dist/layout-bridge/engine/clickToPosition.d.ts +66 -0
- package/dist/layout-bridge/engine/clickToPosition.js +403 -0
- package/dist/layout-bridge/engine/hitTest.d.ts +135 -0
- package/dist/layout-bridge/engine/hitTest.js +375 -0
- package/dist/layout-bridge/engine/measuring/index.d.ts +10 -0
- package/dist/layout-bridge/engine/measuring/index.js +9 -0
- package/dist/layout-bridge/engine/selectionRects.d.ts +59 -0
- package/dist/layout-bridge/engine/selectionRects.js +485 -0
- package/dist/layout-bridge/engine/tableWidthUtils.d.ts +7 -0
- package/dist/layout-bridge/engine/tableWidthUtils.js +25 -0
- package/dist/layout-engine/index.d.ts +44 -0
- package/dist/layout-engine/index.js +691 -0
- package/dist/layout-engine/keep-together.d.ts +43 -0
- package/dist/layout-engine/keep-together.js +98 -0
- package/dist/layout-engine/layoutInstrumentation.d.ts +50 -0
- package/dist/layout-engine/layoutInstrumentation.js +43 -0
- package/dist/layout-engine/lineFlow.d.ts +8 -0
- package/dist/layout-engine/lineFlow.js +17 -0
- package/dist/layout-engine/measure/cache.d.ts +93 -0
- package/dist/layout-engine/measure/cache.js +245 -0
- package/dist/layout-engine/measure/clampFloatingWrapMargins.d.ts +20 -0
- package/dist/layout-engine/measure/clampFloatingWrapMargins.js +29 -0
- package/dist/layout-engine/measure/featureFlags.d.ts +44 -0
- package/dist/layout-engine/measure/featureFlags.js +19 -0
- package/dist/layout-engine/measure/floatingZones.d.ts +89 -0
- package/dist/layout-engine/measure/floatingZones.js +152 -0
- package/dist/layout-engine/measure/font-metrics.worker.d.ts +17 -0
- package/dist/layout-engine/measure/font-metrics.worker.js +104 -0
- package/dist/layout-engine/measure/index.d.ts +9 -0
- package/dist/layout-engine/measure/index.js +8 -0
- package/dist/layout-engine/measure/listMarkerWidth.d.ts +40 -0
- package/dist/layout-engine/measure/listMarkerWidth.js +76 -0
- package/dist/layout-engine/measure/measureBlocks.d.ts +25 -0
- package/dist/layout-engine/measure/measureBlocks.js +450 -0
- package/dist/layout-engine/measure/measureContainer.d.ts +24 -0
- package/dist/layout-engine/measure/measureContainer.js +280 -0
- package/dist/layout-engine/measure/measureHelpers.d.ts +82 -0
- package/dist/layout-engine/measure/measureHelpers.js +156 -0
- package/dist/layout-engine/measure/measureParagraph.d.ts +61 -0
- package/dist/layout-engine/measure/measureParagraph.js +724 -0
- package/dist/layout-engine/measure/measureProvider.d.ts +23 -0
- package/dist/layout-engine/measure/measureProvider.js +35 -0
- package/dist/layout-engine/measure/measureTypes.d.ts +61 -0
- package/dist/layout-engine/measure/measureTypes.js +0 -0
- package/dist/layout-engine/measure/measureWorker.d.ts +54 -0
- package/dist/layout-engine/measure/measureWorker.js +249 -0
- package/dist/layout-engine/measure/measureWorkerProtocol.d.ts +88 -0
- package/dist/layout-engine/measure/measureWorkerProtocol.js +20 -0
- package/dist/layout-engine/measure/tableCellFloating.d.ts +26 -0
- package/dist/layout-engine/measure/tableCellFloating.js +99 -0
- package/dist/layout-engine/paginator.d.ts +84 -0
- package/dist/layout-engine/paginator.js +348 -0
- package/dist/layout-engine/paragraphFragmentRange.d.ts +9 -0
- package/dist/layout-engine/paragraphFragmentRange.js +40 -0
- package/dist/layout-engine/section-breaks.d.ts +78 -0
- package/dist/layout-engine/section-breaks.js +182 -0
- package/dist/layout-engine/tableRowBreak.d.ts +23 -0
- package/dist/layout-engine/tableRowBreak.js +147 -0
- package/dist/layout-engine/textBoxFlow.d.ts +50 -0
- package/dist/layout-engine/textBoxFlow.js +160 -0
- package/dist/layout-engine/types.d.ts +1031 -0
- package/dist/layout-engine/types.js +100 -0
- package/dist/layout-painter/documentColors.d.ts +4 -0
- package/dist/layout-painter/documentColors.js +40 -0
- package/dist/layout-painter/index.d.ts +110 -0
- package/dist/layout-painter/index.js +182 -0
- package/dist/layout-painter/registry/modules/image.d.ts +6 -0
- package/dist/layout-painter/registry/modules/image.js +17 -0
- package/dist/layout-painter/registry/modules/paragraph.d.ts +6 -0
- package/dist/layout-painter/registry/modules/paragraph.js +18 -0
- package/dist/layout-painter/registry/modules/table.d.ts +6 -0
- package/dist/layout-painter/registry/modules/table.js +16 -0
- package/dist/layout-painter/registry/modules/textBox.d.ts +6 -0
- package/dist/layout-painter/registry/modules/textBox.js +13 -0
- package/dist/layout-painter/registry/modules.d.ts +6 -0
- package/dist/layout-painter/registry/modules.js +26 -0
- package/dist/layout-painter/registry/registry.d.ts +24 -0
- package/dist/layout-painter/registry/registry.js +53 -0
- package/dist/layout-painter/registry/types.d.ts +61 -0
- package/dist/layout-painter/registry/types.js +0 -0
- package/dist/layout-painter/renderFragment.d.ts +32 -0
- package/dist/layout-painter/renderFragment.js +114 -0
- package/dist/layout-painter/renderImage.d.ts +88 -0
- package/dist/layout-painter/renderImage.js +130 -0
- package/dist/layout-painter/renderPage.d.ts +264 -0
- package/dist/layout-painter/renderPage.js +1795 -0
- package/dist/layout-painter/renderParagraph.d.ts +93 -0
- package/dist/layout-painter/renderParagraph.js +1300 -0
- package/dist/layout-painter/renderTable.d.ts +36 -0
- package/dist/layout-painter/renderTable.js +432 -0
- package/dist/layout-painter/renderTextBox.d.ts +22 -0
- package/dist/layout-painter/renderTextBox.js +67 -0
- package/dist/layout-painter/renderUtils.d.ts +42 -0
- package/dist/layout-painter/renderUtils.js +30 -0
- package/dist/layout-painter/renderWatermark.d.ts +16 -0
- package/dist/layout-painter/renderWatermark.js +61 -0
- package/dist/layout-painter/sdtBoundary.d.ts +6 -0
- package/dist/layout-painter/sdtBoundary.js +28 -0
- package/dist/managers/ContextMenuManager.d.ts +28 -0
- package/dist/managers/ContextMenuManager.js +48 -0
- package/dist/managers/DocumentLoaderManager.d.ts +47 -0
- package/dist/managers/DocumentLoaderManager.js +69 -0
- package/dist/managers/EditorModeManager.d.ts +28 -0
- package/dist/managers/EditorModeManager.js +50 -0
- package/dist/managers/ErrorManager.d.ts +26 -0
- package/dist/managers/ErrorManager.js +85 -0
- package/dist/managers/FindReplaceManager.d.ts +54 -0
- package/dist/managers/FindReplaceManager.js +104 -0
- package/dist/managers/HistoryManager.d.ts +92 -0
- package/dist/managers/HistoryManager.js +193 -0
- package/dist/managers/Subscribable.d.ts +34 -0
- package/dist/managers/Subscribable.js +46 -0
- package/dist/managers/TableSelectionManager.d.ts +74 -0
- package/dist/managers/TableSelectionManager.js +225 -0
- package/dist/managers/editorShortcuts.d.ts +42 -0
- package/dist/managers/editorShortcuts.js +60 -0
- package/dist/managers/types.d.ts +41 -0
- package/dist/managers/types.js +0 -0
- package/dist/markdown/annotations.d.ts +14 -0
- package/dist/markdown/annotations.js +42 -0
- package/dist/markdown/escape.d.ts +36 -0
- package/dist/markdown/escape.js +59 -0
- package/dist/markdown/fromMarkdown.d.ts +11 -0
- package/dist/markdown/fromMarkdown.js +223 -0
- package/dist/markdown/headings.d.ts +13 -0
- package/dist/markdown/headings.js +20 -0
- package/dist/markdown/images.d.ts +13 -0
- package/dist/markdown/images.js +63 -0
- package/dist/markdown/index.d.ts +18 -0
- package/dist/markdown/index.js +33 -0
- package/dist/markdown/internals.d.ts +15 -0
- package/dist/markdown/internals.js +35 -0
- package/dist/markdown/renderBlock.d.ts +7 -0
- package/dist/markdown/renderBlock.js +68 -0
- package/dist/markdown/renderParagraph.d.ts +11 -0
- package/dist/markdown/renderParagraph.js +64 -0
- package/dist/markdown/renderRuns.d.ts +11 -0
- package/dist/markdown/renderRuns.js +265 -0
- package/dist/markdown/renderTable.d.ts +8 -0
- package/dist/markdown/renderTable.js +229 -0
- package/dist/markdown/trailers.d.ts +13 -0
- package/dist/markdown/trailers.js +54 -0
- package/dist/markdown/types.d.ts +118 -0
- package/dist/markdown/types.js +0 -0
- package/dist/model.d.ts +13 -0
- package/dist/model.js +4 -0
- package/dist/paged-layout/LayoutSelectionGate.d.ts +80 -0
- package/dist/paged-layout/LayoutSelectionGate.js +131 -0
- package/dist/paged-layout/headerFooterMargins.d.ts +73 -0
- package/dist/paged-layout/headerFooterMargins.js +120 -0
- package/dist/paged-layout/hiddenEditorScroll.d.ts +4 -0
- package/dist/paged-layout/hiddenEditorScroll.js +4 -0
- package/dist/paged-layout/incrementalMeasure.d.ts +33 -0
- package/dist/paged-layout/incrementalMeasure.js +56 -0
- package/dist/paged-layout/rangeProjection.d.ts +51 -0
- package/dist/paged-layout/rangeProjection.js +153 -0
- package/dist/paged-layout/readOnlyEditAttempt.d.ts +5 -0
- package/dist/paged-layout/readOnlyEditAttempt.js +22 -0
- package/dist/paged-layout/scrollNavigation.d.ts +23 -0
- package/dist/paged-layout/scrollNavigation.js +31 -0
- package/dist/paged-layout/scrollPageInfo.d.ts +41 -0
- package/dist/paged-layout/scrollPageInfo.js +34 -0
- package/dist/paged-layout/scrollToPmPosition.d.ts +17 -0
- package/dist/paged-layout/scrollToPmPosition.js +95 -0
- package/dist/paged-layout/sectionBlockWidths.d.ts +35 -0
- package/dist/paged-layout/sectionBlockWidths.js +52 -0
- package/dist/paged-layout/sectionGeometry.d.ts +21 -0
- package/dist/paged-layout/sectionGeometry.js +36 -0
- package/dist/paged-layout/selectionViewportRect.d.ts +29 -0
- package/dist/paged-layout/selectionViewportRect.js +55 -0
- package/dist/paged-layout/tableColumnResize.d.ts +19 -0
- package/dist/paged-layout/tableColumnResize.js +28 -0
- package/dist/paged-layout/tableInsertButtonGeometry.d.ts +15 -0
- package/dist/paged-layout/tableInsertButtonGeometry.js +15 -0
- package/dist/paged-layout/transactionDirtyRange.d.ts +7 -0
- package/dist/paged-layout/transactionDirtyRange.js +27 -0
- package/dist/paged-layout/zoomScrollAnchor.d.ts +40 -0
- package/dist/paged-layout/zoomScrollAnchor.js +25 -0
- package/dist/prosemirror/attrs/index.d.ts +80 -0
- package/dist/prosemirror/attrs/index.js +1218 -0
- package/dist/prosemirror/autospacingBase.d.ts +11 -0
- package/dist/prosemirror/autospacingBase.js +16 -0
- package/dist/prosemirror/commands/comments.d.ts +93 -0
- package/dist/prosemirror/commands/comments.js +435 -0
- package/dist/prosemirror/commands/contentControls.d.ts +45 -0
- package/dist/prosemirror/commands/contentControls.js +294 -0
- package/dist/prosemirror/commands/contentControlsBlockFill.d.ts +15 -0
- package/dist/prosemirror/commands/contentControlsBlockFill.js +19 -0
- package/dist/prosemirror/commands/formatPainter.d.ts +31 -0
- package/dist/prosemirror/commands/formatPainter.js +130 -0
- package/dist/prosemirror/commands/formatting.d.ts +32 -0
- package/dist/prosemirror/commands/formatting.js +45 -0
- package/dist/prosemirror/commands/hyperlink.d.ts +31 -0
- package/dist/prosemirror/commands/hyperlink.js +79 -0
- package/dist/prosemirror/commands/image.d.ts +59 -0
- package/dist/prosemirror/commands/image.js +219 -0
- package/dist/prosemirror/commands/index.d.ts +13 -0
- package/dist/prosemirror/commands/index.js +13 -0
- package/dist/prosemirror/commands/pageBreak.d.ts +10 -0
- package/dist/prosemirror/commands/pageBreak.js +47 -0
- package/dist/prosemirror/commands/paragraph.d.ts +39 -0
- package/dist/prosemirror/commands/paragraph.js +64 -0
- package/dist/prosemirror/commands/pastePlainText.d.ts +39 -0
- package/dist/prosemirror/commands/pastePlainText.js +67 -0
- package/dist/prosemirror/commands/table.d.ts +83 -0
- package/dist/prosemirror/commands/table.js +105 -0
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +27 -0
- package/dist/prosemirror/conversion/fromProseDoc.js +1550 -0
- package/dist/prosemirror/conversion/index.d.ts +4 -0
- package/dist/prosemirror/conversion/index.js +4 -0
- package/dist/prosemirror/conversion/runShadingMark.d.ts +16 -0
- package/dist/prosemirror/conversion/runShadingMark.js +39 -0
- package/dist/prosemirror/conversion/toProseDoc.d.ts +39 -0
- package/dist/prosemirror/conversion/toProseDoc.js +1404 -0
- package/dist/prosemirror/extensions/ExtensionManager.d.ts +43 -0
- package/dist/prosemirror/extensions/ExtensionManager.js +86 -0
- package/dist/prosemirror/extensions/StarterKit.d.ts +16 -0
- package/dist/prosemirror/extensions/StarterKit.js +132 -0
- package/dist/prosemirror/extensions/core/DocExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/core/DocExtension.js +12 -0
- package/dist/prosemirror/extensions/core/HistoryExtension.d.ts +13 -0
- package/dist/prosemirror/extensions/core/HistoryExtension.js +28 -0
- package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +25 -0
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +619 -0
- package/dist/prosemirror/extensions/core/TextExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/core/TextExtension.js +12 -0
- package/dist/prosemirror/extensions/create.d.ts +17 -0
- package/dist/prosemirror/extensions/create.js +129 -0
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +23 -0
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +106 -0
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.d.ts +8 -0
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +172 -0
- package/dist/prosemirror/extensions/features/BidiShortcutExtension.d.ts +16 -0
- package/dist/prosemirror/extensions/features/BidiShortcutExtension.js +38 -0
- package/dist/prosemirror/extensions/features/ContentControlWidgetsExtension.d.ts +16 -0
- package/dist/prosemirror/extensions/features/ContentControlWidgetsExtension.js +21 -0
- package/dist/prosemirror/extensions/features/DropCursorExtension.d.ts +12 -0
- package/dist/prosemirror/extensions/features/DropCursorExtension.js +20 -0
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.d.ts +8 -0
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +44 -0
- package/dist/prosemirror/extensions/features/GapCursorExtension.d.ts +19 -0
- package/dist/prosemirror/extensions/features/GapCursorExtension.js +24 -0
- package/dist/prosemirror/extensions/features/ImageDragExtension.d.ts +15 -0
- package/dist/prosemirror/extensions/features/ImageDragExtension.js +66 -0
- package/dist/prosemirror/extensions/features/ImagePasteExtension.d.ts +12 -0
- package/dist/prosemirror/extensions/features/ImagePasteExtension.js +91 -0
- package/dist/prosemirror/extensions/features/ListExtension.d.ts +14 -0
- package/dist/prosemirror/extensions/features/ListExtension.js +340 -0
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +60 -0
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +35 -0
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +188 -0
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +20 -0
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +34 -0
- package/dist/prosemirror/extensions/features/PasteStyleInlinerExtension.d.ts +20 -0
- package/dist/prosemirror/extensions/features/PasteStyleInlinerExtension.js +145 -0
- package/dist/prosemirror/extensions/features/SelectionTrackerExtension.d.ts +10 -0
- package/dist/prosemirror/extensions/features/SelectionTrackerExtension.js +17 -0
- package/dist/prosemirror/extensions/features/bidiShortcutController.d.ts +31 -0
- package/dist/prosemirror/extensions/features/bidiShortcutController.js +27 -0
- package/dist/prosemirror/extensions/features/pasteCleanup.d.ts +31 -0
- package/dist/prosemirror/extensions/features/pasteCleanup.js +159 -0
- package/dist/prosemirror/extensions/marks/AllCapsExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/AllCapsExtension.js +24 -0
- package/dist/prosemirror/extensions/marks/BoldExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/BoldExtension.js +41 -0
- package/dist/prosemirror/extensions/marks/CharacterSpacingExtension.d.ts +14 -0
- package/dist/prosemirror/extensions/marks/CharacterSpacingExtension.js +64 -0
- package/dist/prosemirror/extensions/marks/CharacterStyleExtension.d.ts +23 -0
- package/dist/prosemirror/extensions/marks/CharacterStyleExtension.js +47 -0
- package/dist/prosemirror/extensions/marks/CommentExtension.d.ts +12 -0
- package/dist/prosemirror/extensions/marks/CommentExtension.js +38 -0
- package/dist/prosemirror/extensions/marks/FontFamilyExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/FontFamilyExtension.js +55 -0
- package/dist/prosemirror/extensions/marks/FontSizeExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/FontSizeExtension.js +47 -0
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.d.ts +11 -0
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +92 -0
- package/dist/prosemirror/extensions/marks/HiddenTextExtension.d.ts +23 -0
- package/dist/prosemirror/extensions/marks/HiddenTextExtension.js +35 -0
- package/dist/prosemirror/extensions/marks/HighlightExtension.d.ts +10 -0
- package/dist/prosemirror/extensions/marks/HighlightExtension.js +115 -0
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.d.ts +13 -0
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +146 -0
- package/dist/prosemirror/extensions/marks/ItalicExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/ItalicExtension.js +34 -0
- package/dist/prosemirror/extensions/marks/RtlExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/marks/RtlExtension.js +21 -0
- package/dist/prosemirror/extensions/marks/RunFormattingOverrideExtension.d.ts +11 -0
- package/dist/prosemirror/extensions/marks/RunFormattingOverrideExtension.js +75 -0
- package/dist/prosemirror/extensions/marks/RunShadingExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/marks/RunShadingExtension.js +38 -0
- package/dist/prosemirror/extensions/marks/SmallCapsExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/SmallCapsExtension.js +24 -0
- package/dist/prosemirror/extensions/marks/StrikeExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/StrikeExtension.js +33 -0
- package/dist/prosemirror/extensions/marks/SubscriptExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/SubscriptExtension.js +25 -0
- package/dist/prosemirror/extensions/marks/SuperscriptExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/SuperscriptExtension.js +25 -0
- package/dist/prosemirror/extensions/marks/TextColorExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/TextColorExtension.js +50 -0
- package/dist/prosemirror/extensions/marks/TextEffectExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/marks/TextEffectExtension.js +35 -0
- package/dist/prosemirror/extensions/marks/TextEffectsExtensions.d.ts +31 -0
- package/dist/prosemirror/extensions/marks/TextEffectsExtensions.js +134 -0
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.d.ts +22 -0
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +113 -0
- package/dist/prosemirror/extensions/marks/UnderlineExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/UnderlineExtension.js +60 -0
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +34 -0
- package/dist/prosemirror/extensions/marks/markUtils.js +233 -0
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.d.ts +22 -0
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.js +122 -0
- package/dist/prosemirror/extensions/nodes/FieldExtension.d.ts +12 -0
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +87 -0
- package/dist/prosemirror/extensions/nodes/HardBreakExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/nodes/HardBreakExtension.js +38 -0
- package/dist/prosemirror/extensions/nodes/HorizontalRuleExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/nodes/HorizontalRuleExtension.js +18 -0
- package/dist/prosemirror/extensions/nodes/ImageExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +132 -0
- package/dist/prosemirror/extensions/nodes/MathExtension.d.ts +13 -0
- package/dist/prosemirror/extensions/nodes/MathExtension.js +56 -0
- package/dist/prosemirror/extensions/nodes/PageBreakExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/nodes/PageBreakExtension.js +20 -0
- package/dist/prosemirror/extensions/nodes/SdtExtension.d.ts +12 -0
- package/dist/prosemirror/extensions/nodes/SdtExtension.js +107 -0
- package/dist/prosemirror/extensions/nodes/ShapeExtension.d.ts +30 -0
- package/dist/prosemirror/extensions/nodes/ShapeExtension.js +502 -0
- package/dist/prosemirror/extensions/nodes/TabExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/nodes/TabExtension.js +27 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.d.ts +34 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.js +1972 -0
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.d.ts +34 -0
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +150 -0
- package/dist/prosemirror/extensions/types.d.ts +101 -0
- package/dist/prosemirror/extensions/types.js +10 -0
- package/dist/prosemirror/findReplaceSelection.d.ts +23 -0
- package/dist/prosemirror/findReplaceSelection.js +86 -0
- package/dist/prosemirror/index.d.ts +25 -0
- package/dist/prosemirror/index.js +23 -0
- package/dist/prosemirror/insertOperations.d.ts +12 -0
- package/dist/prosemirror/insertOperations.js +19 -0
- package/dist/prosemirror/paragraphDirection.d.ts +42 -0
- package/dist/prosemirror/paragraphDirection.js +33 -0
- package/dist/prosemirror/plugins/aiCitationDecorations.d.ts +40 -0
- package/dist/prosemirror/plugins/aiCitationDecorations.js +90 -0
- package/dist/prosemirror/plugins/aiSuggestionDecorations.d.ts +42 -0
- package/dist/prosemirror/plugins/aiSuggestionDecorations.js +135 -0
- package/dist/prosemirror/plugins/anonymizationDecorations.d.ts +60 -0
- package/dist/prosemirror/plugins/anonymizationDecorations.js +120 -0
- package/dist/prosemirror/plugins/autocompleteSuggestion.d.ts +123 -0
- package/dist/prosemirror/plugins/autocompleteSuggestion.js +283 -0
- package/dist/prosemirror/plugins/contentControlWidgets.d.ts +56 -0
- package/dist/prosemirror/plugins/contentControlWidgets.js +192 -0
- package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +37 -0
- package/dist/prosemirror/plugins/createDocScanPlugin.js +55 -0
- package/dist/prosemirror/plugins/documentStyles.d.ts +18 -0
- package/dist/prosemirror/plugins/documentStyles.js +46 -0
- package/dist/prosemirror/plugins/index.d.ts +3 -0
- package/dist/prosemirror/plugins/index.js +3 -0
- package/dist/prosemirror/plugins/pmTextScan.d.ts +19 -0
- package/dist/prosemirror/plugins/pmTextScan.js +39 -0
- package/dist/prosemirror/plugins/selectionTracker.d.ts +43 -0
- package/dist/prosemirror/plugins/selectionTracker.js +179 -0
- package/dist/prosemirror/plugins/suggestionMode.d.ts +70 -0
- package/dist/prosemirror/plugins/suggestionMode.js +489 -0
- package/dist/prosemirror/plugins/templateDirectives.d.ts +25 -0
- package/dist/prosemirror/plugins/templateDirectives.js +67 -0
- package/dist/prosemirror/plugins/templatePreviewValues.d.ts +49 -0
- package/dist/prosemirror/plugins/templatePreviewValues.js +117 -0
- package/dist/prosemirror/plugins/templateSlashMenu.d.ts +57 -0
- package/dist/prosemirror/plugins/templateSlashMenu.js +184 -0
- package/dist/prosemirror/schema/index.d.ts +15 -0
- package/dist/prosemirror/schema/index.js +20 -0
- package/dist/prosemirror/schema/marks.d.ts +118 -0
- package/dist/prosemirror/schema/marks.js +0 -0
- package/dist/prosemirror/schema/nodes.d.ts +389 -0
- package/dist/prosemirror/schema/nodes.js +0 -0
- package/dist/prosemirror/selectionState.d.ts +23 -0
- package/dist/prosemirror/selectionState.js +111 -0
- package/dist/prosemirror/styles/index.d.ts +2 -0
- package/dist/prosemirror/styles/index.js +2 -0
- package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +32 -0
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +108 -0
- package/dist/prosemirror/styles/styleResolver.d.ts +94 -0
- package/dist/prosemirror/styles/styleResolver.js +200 -0
- package/dist/prosemirror/utils/findParagraphByParaId.d.ts +26 -0
- package/dist/prosemirror/utils/findParagraphByParaId.js +37 -0
- package/dist/prosemirror/utils/tabCalculator.d.ts +110 -0
- package/dist/prosemirror/utils/tabCalculator.js +137 -0
- package/dist/prosemirror/validation.d.ts +20 -0
- package/dist/prosemirror/validation.js +177 -0
- package/dist/server.d.ts +7 -0
- package/dist/server.js +6 -0
- package/dist/style-engine/index.d.ts +3 -0
- package/dist/style-engine/index.js +2 -0
- package/dist/style-engine/styleEngine.d.ts +67 -0
- package/dist/style-engine/styleEngine.js +70 -0
- package/dist/types/block-id.d.ts +58 -0
- package/dist/types/block-id.js +61 -0
- package/dist/types/colors.d.ts +2 -0
- package/dist/types/colors.js +0 -0
- package/dist/types/content.d.ts +2 -0
- package/dist/types/content.js +0 -0
- package/dist/types/document.d.ts +7 -0
- package/dist/types/document.js +0 -0
- package/dist/types/documentEnumValues.d.ts +89 -0
- package/dist/types/documentEnumValues.js +693 -0
- package/dist/types/formatting.d.ts +2 -0
- package/dist/types/formatting.js +0 -0
- package/dist/types/index.d.ts +107 -0
- package/dist/types/index.js +0 -0
- package/dist/utils/authorColors.d.ts +16 -0
- package/dist/utils/authorColors.js +30 -0
- package/dist/utils/baseDirection.d.ts +23 -0
- package/dist/utils/baseDirection.js +34 -0
- package/dist/utils/clipboard.d.ts +126 -0
- package/dist/utils/clipboard.js +622 -0
- package/dist/utils/colorResolver.d.ts +158 -0
- package/dist/utils/colorResolver.js +557 -0
- package/dist/utils/createDocument.d.ts +50 -0
- package/dist/utils/createDocument.js +262 -0
- package/dist/utils/documentLoaderBehavior.d.ts +22 -0
- package/dist/utils/documentLoaderBehavior.js +14 -0
- package/dist/utils/docxInput.d.ts +22 -0
- package/dist/utils/docxInput.js +16 -0
- package/dist/utils/domGuards.d.ts +59 -0
- package/dist/utils/domGuards.js +82 -0
- package/dist/utils/fontFamilyMerge.d.ts +7 -0
- package/dist/utils/fontFamilyMerge.js +31 -0
- package/dist/utils/fontLoader.d.ts +50 -0
- package/dist/utils/fontLoader.js +177 -0
- package/dist/utils/fontResolver.d.ts +61 -0
- package/dist/utils/fontResolver.js +651 -0
- package/dist/utils/fontWeights.d.ts +4 -0
- package/dist/utils/fontWeights.js +4 -0
- package/dist/utils/formatToStyle.d.ts +103 -0
- package/dist/utils/formatToStyle.js +289 -0
- package/dist/utils/headerFooter.d.ts +74 -0
- package/dist/utils/headerFooter.js +257 -0
- package/dist/utils/headingCollector.d.ts +22 -0
- package/dist/utils/headingCollector.js +36 -0
- package/dist/utils/hexId.d.ts +33 -0
- package/dist/utils/hexId.js +37 -0
- package/dist/utils/imageValidation.d.ts +5 -0
- package/dist/utils/imageValidation.js +31 -0
- package/dist/utils/paragraphFormattingMerge.d.ts +14 -0
- package/dist/utils/paragraphFormattingMerge.js +68 -0
- package/dist/utils/replaceText.d.ts +17 -0
- package/dist/utils/replaceText.js +161 -0
- package/dist/utils/rotationBoundingBox.d.ts +12 -0
- package/dist/utils/rotationBoundingBox.js +36 -0
- package/dist/utils/scriptSegments.d.ts +36 -0
- package/dist/utils/scriptSegments.js +52 -0
- package/dist/utils/tableOperations.d.ts +87 -0
- package/dist/utils/tableOperations.js +259 -0
- package/dist/utils/textFormattingMerge.d.ts +6 -0
- package/dist/utils/textFormattingMerge.js +31 -0
- package/dist/utils/tiffConverter.d.ts +18 -0
- package/dist/utils/tiffConverter.js +83 -0
- package/dist/utils/units.d.ts +99 -0
- package/dist/utils/units.js +139 -0
- package/dist/utils/urlSecurity.d.ts +7 -0
- package/dist/utils/urlSecurity.js +65 -0
- package/dist/watermark/index.d.ts +39 -0
- package/dist/watermark/index.js +149 -0
- package/package.json +122 -2
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
import { findChildren, getAttribute } from "./xmlParser.js";
|
|
2
|
+
import { FieldTypeSchema, narrowEnum } from "./parserEnums.js";
|
|
3
|
+
import { parseRun } from "./runParser.js";
|
|
4
|
+
//#region src/docx/fieldParser.ts
|
|
5
|
+
/**
|
|
6
|
+
* All known field types from OOXML specification
|
|
7
|
+
*/
|
|
8
|
+
const KNOWN_FIELD_TYPES = [
|
|
9
|
+
"PAGE",
|
|
10
|
+
"NUMPAGES",
|
|
11
|
+
"NUMWORDS",
|
|
12
|
+
"NUMCHARS",
|
|
13
|
+
"DATE",
|
|
14
|
+
"TIME",
|
|
15
|
+
"CREATEDATE",
|
|
16
|
+
"SAVEDATE",
|
|
17
|
+
"PRINTDATE",
|
|
18
|
+
"EDITTIME",
|
|
19
|
+
"AUTHOR",
|
|
20
|
+
"TITLE",
|
|
21
|
+
"SUBJECT",
|
|
22
|
+
"KEYWORDS",
|
|
23
|
+
"COMMENTS",
|
|
24
|
+
"FILENAME",
|
|
25
|
+
"FILESIZE",
|
|
26
|
+
"TEMPLATE",
|
|
27
|
+
"REVNUM",
|
|
28
|
+
"DOCPROPERTY",
|
|
29
|
+
"DOCVARIABLE",
|
|
30
|
+
"REF",
|
|
31
|
+
"PAGEREF",
|
|
32
|
+
"NOTEREF",
|
|
33
|
+
"HYPERLINK",
|
|
34
|
+
"TOC",
|
|
35
|
+
"TOA",
|
|
36
|
+
"INDEX",
|
|
37
|
+
"SEQ",
|
|
38
|
+
"STYLEREF",
|
|
39
|
+
"AUTONUM",
|
|
40
|
+
"AUTONUMLGL",
|
|
41
|
+
"AUTONUMOUT",
|
|
42
|
+
"LISTNUM",
|
|
43
|
+
"SECTION",
|
|
44
|
+
"SECTIONPAGES",
|
|
45
|
+
"USERADDRESS",
|
|
46
|
+
"USERNAME",
|
|
47
|
+
"USERINITIALS",
|
|
48
|
+
"IF",
|
|
49
|
+
"MERGEFIELD",
|
|
50
|
+
"NEXT",
|
|
51
|
+
"NEXTIF",
|
|
52
|
+
"ASK",
|
|
53
|
+
"SET",
|
|
54
|
+
"QUOTE",
|
|
55
|
+
"INCLUDETEXT",
|
|
56
|
+
"INCLUDEPICTURE",
|
|
57
|
+
"SYMBOL",
|
|
58
|
+
"ADVANCE"
|
|
59
|
+
];
|
|
60
|
+
/**
|
|
61
|
+
* Parse field type from instruction string
|
|
62
|
+
*
|
|
63
|
+
* Field instructions follow the format: FIELDNAME [arguments] [switches]
|
|
64
|
+
* Examples:
|
|
65
|
+
* - "PAGE \\* MERGEFORMAT"
|
|
66
|
+
* - "DATE \\@ \"MMMM d, yyyy\""
|
|
67
|
+
* - "MERGEFIELD client_name \\* Upper"
|
|
68
|
+
* - "REF _Ref123456 \\h"
|
|
69
|
+
*
|
|
70
|
+
* @param instruction - The field instruction string
|
|
71
|
+
* @returns The detected field type
|
|
72
|
+
*/
|
|
73
|
+
function parseFieldType(instruction) {
|
|
74
|
+
if (!instruction) return "UNKNOWN";
|
|
75
|
+
const trimmed = instruction.trim();
|
|
76
|
+
const match = /^\\?(?<name>[A-Z][A-Z0-9]*)/iu.exec(trimmed);
|
|
77
|
+
if (!match) return "UNKNOWN";
|
|
78
|
+
return narrowEnum(match.groups["name"].toUpperCase(), FieldTypeSchema) ?? "UNKNOWN";
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Check if a field type is a known type. The sentinel "UNKNOWN" value
|
|
82
|
+
* is not considered a "known" type even though it belongs to FieldType.
|
|
83
|
+
*
|
|
84
|
+
* @param type - Field type string to check
|
|
85
|
+
* @returns true if it's a known field type
|
|
86
|
+
*/
|
|
87
|
+
function isKnownFieldType(type) {
|
|
88
|
+
const narrowed = narrowEnum(type, FieldTypeSchema);
|
|
89
|
+
return narrowed !== void 0 && narrowed !== "UNKNOWN";
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Parse a complete field instruction into structured data
|
|
93
|
+
*
|
|
94
|
+
* @param instruction - Raw instruction string
|
|
95
|
+
* @returns Parsed instruction object
|
|
96
|
+
*/
|
|
97
|
+
function parseFieldInstruction(instruction) {
|
|
98
|
+
const type = parseFieldType(instruction);
|
|
99
|
+
const trimmed = instruction.trim();
|
|
100
|
+
const switches = [];
|
|
101
|
+
const nameMatch = /^\\?(?:[A-Z][A-Z0-9]*)/iu.exec(trimmed);
|
|
102
|
+
const fieldNameEnd = nameMatch ? nameMatch[0].length : 0;
|
|
103
|
+
const remaining = trimmed.slice(fieldNameEnd).trim();
|
|
104
|
+
const switchRegex = /\\(?<switch>\*|@|#|!|[a-z])\s*(?:"(?<quoted>[^"]*)"|(?<unquoted>[\S]*))?/giu;
|
|
105
|
+
let switchMatch;
|
|
106
|
+
const switchPositions = [];
|
|
107
|
+
while ((switchMatch = switchRegex.exec(remaining)) !== null) {
|
|
108
|
+
const groups = switchMatch.groups;
|
|
109
|
+
const sw = { switch: groups["switch"] };
|
|
110
|
+
if (groups["quoted"]) sw.value = groups["quoted"];
|
|
111
|
+
else if (groups["unquoted"]) sw.value = groups["unquoted"];
|
|
112
|
+
switches.push(sw);
|
|
113
|
+
switchPositions.push({
|
|
114
|
+
start: switchMatch.index,
|
|
115
|
+
end: switchMatch.index + switchMatch[0].length
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
let argument;
|
|
119
|
+
if (remaining.length > 0) {
|
|
120
|
+
const firstSwitchPos = switchPositions.length > 0 ? switchPositions[0].start : remaining.length;
|
|
121
|
+
const beforeSwitch = remaining.slice(0, firstSwitchPos).trim();
|
|
122
|
+
if (beforeSwitch.startsWith("\"") && beforeSwitch.endsWith("\"")) argument = beforeSwitch.slice(1, -1);
|
|
123
|
+
else if (beforeSwitch) argument = beforeSwitch;
|
|
124
|
+
}
|
|
125
|
+
return {
|
|
126
|
+
type,
|
|
127
|
+
raw: instruction,
|
|
128
|
+
...argument !== void 0 ? { argument } : {},
|
|
129
|
+
switches
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Get the format switch value (\* or \@)
|
|
134
|
+
*
|
|
135
|
+
* @param instruction - Parsed instruction
|
|
136
|
+
* @returns Format string or undefined
|
|
137
|
+
*/
|
|
138
|
+
function getFormatSwitch(instruction) {
|
|
139
|
+
return instruction.switches.find((s) => s.switch === "*" || s.switch === "@")?.value;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Check if field has MERGEFORMAT switch (preserve formatting)
|
|
143
|
+
*
|
|
144
|
+
* @param instruction - Parsed instruction
|
|
145
|
+
* @returns true if MERGEFORMAT is present
|
|
146
|
+
*/
|
|
147
|
+
function hasMergeFormat(instruction) {
|
|
148
|
+
return instruction.switches.find((s) => s.switch === "*")?.value?.toUpperCase() === "MERGEFORMAT";
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Parse a simple field element (w:fldSimple)
|
|
152
|
+
*
|
|
153
|
+
* @param node - The w:fldSimple XML element
|
|
154
|
+
* @param styles - Style definitions for parsing content runs
|
|
155
|
+
* @param theme - Theme for color/font resolution
|
|
156
|
+
* @returns Parsed SimpleField object
|
|
157
|
+
*/
|
|
158
|
+
function parseSimpleField(node, styles, theme) {
|
|
159
|
+
const instruction = getAttribute(node, "w", "instr") ?? "";
|
|
160
|
+
const field = {
|
|
161
|
+
type: "simpleField",
|
|
162
|
+
instruction,
|
|
163
|
+
fieldType: parseFieldType(instruction),
|
|
164
|
+
content: []
|
|
165
|
+
};
|
|
166
|
+
const fldLock = getAttribute(node, "w", "fldLock");
|
|
167
|
+
if (fldLock === "1" || fldLock === "true") field.fldLock = true;
|
|
168
|
+
const dirty = getAttribute(node, "w", "dirty");
|
|
169
|
+
if (dirty === "1" || dirty === "true") field.dirty = true;
|
|
170
|
+
const children = findChildren(node, "w", "r");
|
|
171
|
+
for (const child of children) {
|
|
172
|
+
const run = parseRun(child, styles, theme);
|
|
173
|
+
field.content.push(run);
|
|
174
|
+
}
|
|
175
|
+
return field;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Create a new complex field context
|
|
179
|
+
*/
|
|
180
|
+
function createComplexFieldContext() {
|
|
181
|
+
return {
|
|
182
|
+
state: "outside",
|
|
183
|
+
instruction: "",
|
|
184
|
+
codeRuns: [],
|
|
185
|
+
resultRuns: [],
|
|
186
|
+
fldLock: false,
|
|
187
|
+
dirty: false,
|
|
188
|
+
nestingLevel: 0
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Reset the context for a new field
|
|
193
|
+
*/
|
|
194
|
+
function resetComplexFieldContext(ctx) {
|
|
195
|
+
ctx.state = "code";
|
|
196
|
+
ctx.instruction = "";
|
|
197
|
+
ctx.codeRuns = [];
|
|
198
|
+
ctx.resultRuns = [];
|
|
199
|
+
ctx.fldLock = false;
|
|
200
|
+
ctx.dirty = false;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Finalize a complex field from its context
|
|
204
|
+
*
|
|
205
|
+
* @param ctx - The field context
|
|
206
|
+
* @returns The parsed ComplexField
|
|
207
|
+
*/
|
|
208
|
+
function finalizeComplexField(ctx) {
|
|
209
|
+
return {
|
|
210
|
+
type: "complexField",
|
|
211
|
+
instruction: ctx.instruction.trim(),
|
|
212
|
+
fieldType: parseFieldType(ctx.instruction),
|
|
213
|
+
fieldCode: ctx.codeRuns,
|
|
214
|
+
fieldResult: ctx.resultRuns,
|
|
215
|
+
...ctx.fldLock && { fldLock: true },
|
|
216
|
+
...ctx.dirty && { dirty: true }
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Get the current display value of a field
|
|
221
|
+
*
|
|
222
|
+
* @param field - The field (simple or complex)
|
|
223
|
+
* @returns The display text
|
|
224
|
+
*/
|
|
225
|
+
function getFieldDisplayValue(field) {
|
|
226
|
+
if (field.type === "simpleField") return field.content.filter((c) => "content" in c).map((run) => getRunText(run)).join("");
|
|
227
|
+
return field.fieldResult.map((run) => getRunText(run)).join("");
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Helper to get text from a run (simplified)
|
|
231
|
+
*/
|
|
232
|
+
function getRunText(run) {
|
|
233
|
+
return run.content.filter((c) => c.type === "text").map((c) => c.text).join("");
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Check if field represents a page number
|
|
237
|
+
*
|
|
238
|
+
* @param field - The field to check
|
|
239
|
+
* @returns true if this is a page number field
|
|
240
|
+
*/
|
|
241
|
+
function isPageNumberField(field) {
|
|
242
|
+
return field.fieldType === "PAGE";
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Check if field represents total page count
|
|
246
|
+
*
|
|
247
|
+
* @param field - The field to check
|
|
248
|
+
* @returns true if this is a total pages field
|
|
249
|
+
*/
|
|
250
|
+
function isTotalPagesField(field) {
|
|
251
|
+
return field.fieldType === "NUMPAGES";
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Check if field is a date/time field
|
|
255
|
+
*
|
|
256
|
+
* @param field - The field to check
|
|
257
|
+
* @returns true if this is a date/time field
|
|
258
|
+
*/
|
|
259
|
+
function isDateTimeField(field) {
|
|
260
|
+
return [
|
|
261
|
+
"DATE",
|
|
262
|
+
"TIME",
|
|
263
|
+
"CREATEDATE",
|
|
264
|
+
"SAVEDATE",
|
|
265
|
+
"PRINTDATE",
|
|
266
|
+
"EDITTIME"
|
|
267
|
+
].includes(field.fieldType);
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* Check if field is a document property field
|
|
271
|
+
*
|
|
272
|
+
* @param field - The field to check
|
|
273
|
+
* @returns true if this is a document property field
|
|
274
|
+
*/
|
|
275
|
+
function isDocPropertyField(field) {
|
|
276
|
+
return [
|
|
277
|
+
"AUTHOR",
|
|
278
|
+
"TITLE",
|
|
279
|
+
"SUBJECT",
|
|
280
|
+
"KEYWORDS",
|
|
281
|
+
"COMMENTS",
|
|
282
|
+
"FILENAME",
|
|
283
|
+
"FILESIZE",
|
|
284
|
+
"TEMPLATE",
|
|
285
|
+
"REVNUM",
|
|
286
|
+
"DOCPROPERTY",
|
|
287
|
+
"DOCVARIABLE"
|
|
288
|
+
].includes(field.fieldType);
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Check if field is a cross-reference field
|
|
292
|
+
*
|
|
293
|
+
* @param field - The field to check
|
|
294
|
+
* @returns true if this is a cross-reference field
|
|
295
|
+
*/
|
|
296
|
+
function isReferenceField(field) {
|
|
297
|
+
return [
|
|
298
|
+
"REF",
|
|
299
|
+
"PAGEREF",
|
|
300
|
+
"NOTEREF"
|
|
301
|
+
].includes(field.fieldType);
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Check if field is a mail merge field
|
|
305
|
+
*
|
|
306
|
+
* @param field - The field to check
|
|
307
|
+
* @returns true if this is a mail merge field
|
|
308
|
+
*/
|
|
309
|
+
function isMergeField(field) {
|
|
310
|
+
return [
|
|
311
|
+
"MERGEFIELD",
|
|
312
|
+
"IF",
|
|
313
|
+
"NEXT",
|
|
314
|
+
"NEXTIF",
|
|
315
|
+
"ASK",
|
|
316
|
+
"SET"
|
|
317
|
+
].includes(field.fieldType);
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Check if field is a hyperlink field
|
|
321
|
+
*
|
|
322
|
+
* @param field - The field to check
|
|
323
|
+
* @returns true if this is a hyperlink field
|
|
324
|
+
*/
|
|
325
|
+
function isHyperlinkField(field) {
|
|
326
|
+
return field.fieldType === "HYPERLINK";
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Check if field is a TOC/Index field
|
|
330
|
+
*
|
|
331
|
+
* @param field - The field to check
|
|
332
|
+
* @returns true if this is a TOC or index field
|
|
333
|
+
*/
|
|
334
|
+
function isTocField(field) {
|
|
335
|
+
return [
|
|
336
|
+
"TOC",
|
|
337
|
+
"TOA",
|
|
338
|
+
"INDEX"
|
|
339
|
+
].includes(field.fieldType);
|
|
340
|
+
}
|
|
341
|
+
/**
|
|
342
|
+
* Compute the value for a page number field
|
|
343
|
+
*
|
|
344
|
+
* @param pageNumber - Current page number
|
|
345
|
+
* @param instruction - Parsed instruction for format switches
|
|
346
|
+
* @returns Formatted page number string
|
|
347
|
+
*/
|
|
348
|
+
function computePageNumber(pageNumber, instruction) {
|
|
349
|
+
if (!instruction) return String(pageNumber);
|
|
350
|
+
const format = getFormatSwitch(instruction);
|
|
351
|
+
if (!format) return String(pageNumber);
|
|
352
|
+
switch (format.toUpperCase()) {
|
|
353
|
+
case "ROMAN": return toRoman(pageNumber);
|
|
354
|
+
case "ALPHABETIC": return toLetter(pageNumber);
|
|
355
|
+
default: return String(pageNumber);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Convert number to uppercase Roman numerals
|
|
360
|
+
*/
|
|
361
|
+
function toRoman(num) {
|
|
362
|
+
if (num <= 0 || num > 3999) return String(num);
|
|
363
|
+
const values = [
|
|
364
|
+
1e3,
|
|
365
|
+
900,
|
|
366
|
+
500,
|
|
367
|
+
400,
|
|
368
|
+
100,
|
|
369
|
+
90,
|
|
370
|
+
50,
|
|
371
|
+
40,
|
|
372
|
+
10,
|
|
373
|
+
9,
|
|
374
|
+
5,
|
|
375
|
+
4,
|
|
376
|
+
1
|
|
377
|
+
];
|
|
378
|
+
const symbols = [
|
|
379
|
+
"M",
|
|
380
|
+
"CM",
|
|
381
|
+
"D",
|
|
382
|
+
"CD",
|
|
383
|
+
"C",
|
|
384
|
+
"XC",
|
|
385
|
+
"L",
|
|
386
|
+
"XL",
|
|
387
|
+
"X",
|
|
388
|
+
"IX",
|
|
389
|
+
"V",
|
|
390
|
+
"IV",
|
|
391
|
+
"I"
|
|
392
|
+
];
|
|
393
|
+
let result = "";
|
|
394
|
+
let remaining = num;
|
|
395
|
+
for (let i = 0; i < values.length; i++) while (remaining >= values[i]) {
|
|
396
|
+
result += symbols[i];
|
|
397
|
+
remaining -= values[i];
|
|
398
|
+
}
|
|
399
|
+
return result;
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
402
|
+
* Convert number to letter (A, B, ... Z, AA, AB, ...)
|
|
403
|
+
*/
|
|
404
|
+
function toLetter(num) {
|
|
405
|
+
if (num <= 0) return String(num);
|
|
406
|
+
let result = "";
|
|
407
|
+
let n = num;
|
|
408
|
+
while (n > 0) {
|
|
409
|
+
n--;
|
|
410
|
+
result = String.fromCodePoint(65 + n % 26) + result;
|
|
411
|
+
n = Math.floor(n / 26);
|
|
412
|
+
}
|
|
413
|
+
return result;
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Format a date according to a format string
|
|
417
|
+
*
|
|
418
|
+
* Supports common OOXML date format codes:
|
|
419
|
+
* - M, MM, MMM, MMMM - Month
|
|
420
|
+
* - d, dd, ddd, dddd - Day
|
|
421
|
+
* - yy, yyyy - Year
|
|
422
|
+
* - h, hh, H, HH - Hour
|
|
423
|
+
* - m, mm - Minute (in time context)
|
|
424
|
+
* - s, ss - Second
|
|
425
|
+
* - AM/PM, am/pm - AM/PM indicator
|
|
426
|
+
*
|
|
427
|
+
* @param date - The date to format
|
|
428
|
+
* @param format - The format string
|
|
429
|
+
* @returns Formatted date string
|
|
430
|
+
*/
|
|
431
|
+
function formatDate(date, format) {
|
|
432
|
+
const months = [
|
|
433
|
+
"January",
|
|
434
|
+
"February",
|
|
435
|
+
"March",
|
|
436
|
+
"April",
|
|
437
|
+
"May",
|
|
438
|
+
"June",
|
|
439
|
+
"July",
|
|
440
|
+
"August",
|
|
441
|
+
"September",
|
|
442
|
+
"October",
|
|
443
|
+
"November",
|
|
444
|
+
"December"
|
|
445
|
+
];
|
|
446
|
+
const shortMonths = [
|
|
447
|
+
"Jan",
|
|
448
|
+
"Feb",
|
|
449
|
+
"Mar",
|
|
450
|
+
"Apr",
|
|
451
|
+
"May",
|
|
452
|
+
"Jun",
|
|
453
|
+
"Jul",
|
|
454
|
+
"Aug",
|
|
455
|
+
"Sep",
|
|
456
|
+
"Oct",
|
|
457
|
+
"Nov",
|
|
458
|
+
"Dec"
|
|
459
|
+
];
|
|
460
|
+
const days = [
|
|
461
|
+
"Sunday",
|
|
462
|
+
"Monday",
|
|
463
|
+
"Tuesday",
|
|
464
|
+
"Wednesday",
|
|
465
|
+
"Thursday",
|
|
466
|
+
"Friday",
|
|
467
|
+
"Saturday"
|
|
468
|
+
];
|
|
469
|
+
const shortDays = [
|
|
470
|
+
"Sun",
|
|
471
|
+
"Mon",
|
|
472
|
+
"Tue",
|
|
473
|
+
"Wed",
|
|
474
|
+
"Thu",
|
|
475
|
+
"Fri",
|
|
476
|
+
"Sat"
|
|
477
|
+
];
|
|
478
|
+
const pad = (n) => n.toString().padStart(2, "0");
|
|
479
|
+
const hour12 = date.getHours() % 12 || 12;
|
|
480
|
+
const ampm = date.getHours() >= 12 ? "PM" : "AM";
|
|
481
|
+
return format.replace(/AM\/PM|am\/pm|yyyy|yy|MMMM|MMM|MM|M|dddd|ddd|dd|d|hh|h|HH|H|mm|m|ss|s/gu, (token) => {
|
|
482
|
+
switch (token) {
|
|
483
|
+
case "yyyy": return date.getFullYear().toString();
|
|
484
|
+
case "yy": return (date.getFullYear() % 100).toString().padStart(2, "0");
|
|
485
|
+
case "MMMM": return months[date.getMonth()];
|
|
486
|
+
case "MMM": return shortMonths[date.getMonth()];
|
|
487
|
+
case "MM": return pad(date.getMonth() + 1);
|
|
488
|
+
case "M": return (date.getMonth() + 1).toString();
|
|
489
|
+
case "dddd": return days[date.getDay()];
|
|
490
|
+
case "ddd": return shortDays[date.getDay()];
|
|
491
|
+
case "dd": return pad(date.getDate());
|
|
492
|
+
case "d": return date.getDate().toString();
|
|
493
|
+
case "hh": return pad(hour12);
|
|
494
|
+
case "h": return hour12.toString();
|
|
495
|
+
case "HH": return pad(date.getHours());
|
|
496
|
+
case "H": return date.getHours().toString();
|
|
497
|
+
case "mm": return pad(date.getMinutes());
|
|
498
|
+
case "m": return date.getMinutes().toString();
|
|
499
|
+
case "ss": return pad(date.getSeconds());
|
|
500
|
+
case "s": return date.getSeconds().toString();
|
|
501
|
+
case "AM/PM": return ampm;
|
|
502
|
+
case "am/pm": return ampm.toLowerCase();
|
|
503
|
+
default: return token;
|
|
504
|
+
}
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Collect all fields from a document content array
|
|
509
|
+
*
|
|
510
|
+
* @param content - Array of paragraph content items
|
|
511
|
+
* @returns Array of all fields found
|
|
512
|
+
*/
|
|
513
|
+
function isField(item) {
|
|
514
|
+
return item !== null && typeof item === "object" && "type" in item && (item.type === "simpleField" || item.type === "complexField");
|
|
515
|
+
}
|
|
516
|
+
function collectFields(content) {
|
|
517
|
+
return content.filter(isField);
|
|
518
|
+
}
|
|
519
|
+
/**
|
|
520
|
+
* Get all fields of a specific type
|
|
521
|
+
*
|
|
522
|
+
* @param fields - Array of fields
|
|
523
|
+
* @param fieldType - The field type to filter by
|
|
524
|
+
* @returns Filtered array of fields
|
|
525
|
+
*/
|
|
526
|
+
function getFieldsByType(fields, fieldType) {
|
|
527
|
+
return fields.filter((f) => f.fieldType === fieldType);
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Find all page number fields
|
|
531
|
+
*
|
|
532
|
+
* @param fields - Array of fields
|
|
533
|
+
* @returns Array of PAGE fields
|
|
534
|
+
*/
|
|
535
|
+
function getPageNumberFields(fields) {
|
|
536
|
+
return getFieldsByType(fields, "PAGE");
|
|
537
|
+
}
|
|
538
|
+
/**
|
|
539
|
+
* Find all merge fields
|
|
540
|
+
*
|
|
541
|
+
* @param fields - Array of fields
|
|
542
|
+
* @returns Array of MERGEFIELD fields
|
|
543
|
+
*/
|
|
544
|
+
function getMergeFields(fields) {
|
|
545
|
+
return getFieldsByType(fields, "MERGEFIELD");
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Extract merge field names from fields
|
|
549
|
+
*
|
|
550
|
+
* @param fields - Array of fields
|
|
551
|
+
* @returns Array of merge field names
|
|
552
|
+
*/
|
|
553
|
+
function getMergeFieldNames(fields) {
|
|
554
|
+
return getMergeFields(fields).map((f) => {
|
|
555
|
+
return parseFieldInstruction(f.instruction).argument;
|
|
556
|
+
}).filter((name) => !!name);
|
|
557
|
+
}
|
|
558
|
+
//#endregion
|
|
559
|
+
export { KNOWN_FIELD_TYPES, collectFields, computePageNumber, createComplexFieldContext, finalizeComplexField, formatDate, getFieldDisplayValue, getFieldsByType, getFormatSwitch, getMergeFieldNames, getMergeFields, getPageNumberFields, hasMergeFormat, isDateTimeField, isDocPropertyField, isHyperlinkField, isKnownFieldType, isMergeField, isPageNumberField, isReferenceField, isTocField, isTotalPagesField, parseFieldInstruction, parseFieldType, parseSimpleField, resetComplexFieldContext };
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { NumberingMap } from "./numberingParser.js";
|
|
3
|
+
import { StyleMap } from "./styleParser.js";
|
|
4
|
+
import { parseEndnoteProperties, parseFootnoteProperties } from "./notePropertiesParser.js";
|
|
5
|
+
|
|
6
|
+
//#region src/docx/footnoteParser.d.ts
|
|
7
|
+
/**
|
|
8
|
+
* Footnote map returned by parseFootnotes
|
|
9
|
+
*/
|
|
10
|
+
type FootnoteMap = {
|
|
11
|
+
/** All footnotes indexed by ID */byId: Map<number, document_d_exports.Footnote>; /** Array of all footnotes in document order */
|
|
12
|
+
footnotes: document_d_exports.Footnote[]; /** Get footnote by ID */
|
|
13
|
+
getFootnote: (id: number) => document_d_exports.Footnote | undefined; /** Check if footnote exists */
|
|
14
|
+
hasFootnote: (id: number) => boolean; /** Get all normal (non-separator) footnotes */
|
|
15
|
+
getNormalFootnotes: () => document_d_exports.Footnote[]; /** Get separator footnote if exists */
|
|
16
|
+
getSeparator: () => document_d_exports.Footnote | undefined; /** Get continuation separator if exists */
|
|
17
|
+
getContinuationSeparator: () => document_d_exports.Footnote | undefined;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Endnote map returned by parseEndnotes
|
|
21
|
+
*/
|
|
22
|
+
type EndnoteMap = {
|
|
23
|
+
/** All endnotes indexed by ID */byId: Map<number, document_d_exports.Endnote>; /** Array of all endnotes in document order */
|
|
24
|
+
endnotes: document_d_exports.Endnote[]; /** Get endnote by ID */
|
|
25
|
+
getEndnote: (id: number) => document_d_exports.Endnote | undefined; /** Check if endnote exists */
|
|
26
|
+
hasEndnote: (id: number) => boolean; /** Get all normal (non-separator) endnotes */
|
|
27
|
+
getNormalEndnotes: () => document_d_exports.Endnote[]; /** Get separator endnote if exists */
|
|
28
|
+
getSeparator: () => document_d_exports.Endnote | undefined; /** Get continuation separator if exists */
|
|
29
|
+
getContinuationSeparator: () => document_d_exports.Endnote | undefined;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Parse footnotes.xml
|
|
33
|
+
*
|
|
34
|
+
* @param footnotesXml - The raw XML content of word/footnotes.xml
|
|
35
|
+
* @param styles - Parsed style map for applying styles
|
|
36
|
+
* @param theme - Parsed theme for color resolution
|
|
37
|
+
* @param numbering - Parsed numbering definitions for lists
|
|
38
|
+
* @param rels - Relationships for resolving hyperlinks
|
|
39
|
+
* @param media - Media files for images
|
|
40
|
+
* @returns FootnoteMap with all footnotes
|
|
41
|
+
*/
|
|
42
|
+
declare function parseFootnotes(footnotesXml: string | null, styles?: StyleMap | null, theme?: document_d_exports.Theme | null, numbering?: NumberingMap | null, rels?: document_d_exports.RelationshipMap | null, media?: Map<string, document_d_exports.MediaFile> | null): FootnoteMap;
|
|
43
|
+
/**
|
|
44
|
+
* Parse endnotes.xml
|
|
45
|
+
*
|
|
46
|
+
* @param endnotesXml - The raw XML content of word/endnotes.xml
|
|
47
|
+
* @param styles - Parsed style map for applying styles
|
|
48
|
+
* @param theme - Parsed theme for color resolution
|
|
49
|
+
* @param numbering - Parsed numbering definitions for lists
|
|
50
|
+
* @param rels - Relationships for resolving hyperlinks
|
|
51
|
+
* @param media - Media files for images
|
|
52
|
+
* @returns EndnoteMap with all endnotes
|
|
53
|
+
*/
|
|
54
|
+
declare function parseEndnotes(endnotesXml: string | null, styles?: StyleMap | null, theme?: document_d_exports.Theme | null, numbering?: NumberingMap | null, rels?: document_d_exports.RelationshipMap | null, media?: Map<string, document_d_exports.MediaFile> | null): EndnoteMap;
|
|
55
|
+
/**
|
|
56
|
+
* Get plain text content of a footnote.
|
|
57
|
+
*
|
|
58
|
+
* Recurses into block-level SDTs so a citation slot inside a note still
|
|
59
|
+
* contributes its text; without recursion, the BlockSdt addition from
|
|
60
|
+
* the previous commit would silently hide the slot's body from this
|
|
61
|
+
* helper.
|
|
62
|
+
*/
|
|
63
|
+
declare function getFootnoteText(footnote: document_d_exports.Footnote): string;
|
|
64
|
+
/**
|
|
65
|
+
* Get plain text content of an endnote.
|
|
66
|
+
*/
|
|
67
|
+
declare function getEndnoteText(endnote: document_d_exports.Endnote): string;
|
|
68
|
+
/**
|
|
69
|
+
* Check if a footnote is a separator (not regular content)
|
|
70
|
+
*/
|
|
71
|
+
declare function isSeparatorFootnote(footnote: document_d_exports.Footnote): boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Check if an endnote is a separator (not regular content)
|
|
74
|
+
*/
|
|
75
|
+
declare function isSeparatorEndnote(endnote: document_d_exports.Endnote): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Get footnote number for display (excluding separators)
|
|
78
|
+
* @param footnote - The footnote to get the number for
|
|
79
|
+
* @param footnoteMap - The footnote map
|
|
80
|
+
* @param startNumber - Starting number (default 1)
|
|
81
|
+
* @returns The display number, or null for separator footnotes
|
|
82
|
+
*/
|
|
83
|
+
declare function getFootnoteDisplayNumber(footnote: document_d_exports.Footnote, footnoteMap: FootnoteMap, startNumber?: number): number | null;
|
|
84
|
+
/**
|
|
85
|
+
* Get endnote number for display (excluding separators)
|
|
86
|
+
* @param endnote - The endnote to get the number for
|
|
87
|
+
* @param endnoteMap - The endnote map
|
|
88
|
+
* @param startNumber - Starting number (default 1)
|
|
89
|
+
* @returns The display number, or null for separator endnotes
|
|
90
|
+
*/
|
|
91
|
+
declare function getEndnoteDisplayNumber(endnote: document_d_exports.Endnote, endnoteMap: EndnoteMap, startNumber?: number): number | null;
|
|
92
|
+
/**
|
|
93
|
+
* Create an empty footnote map
|
|
94
|
+
*/
|
|
95
|
+
declare function createEmptyFootnoteMap(): FootnoteMap;
|
|
96
|
+
/**
|
|
97
|
+
* Create an empty endnote map
|
|
98
|
+
*/
|
|
99
|
+
declare function createEmptyEndnoteMap(): EndnoteMap;
|
|
100
|
+
/**
|
|
101
|
+
* Merge multiple footnote maps (e.g., from different documents)
|
|
102
|
+
*/
|
|
103
|
+
declare function mergeFootnoteMaps(...maps: FootnoteMap[]): FootnoteMap;
|
|
104
|
+
/**
|
|
105
|
+
* Merge multiple endnote maps (e.g., from different documents)
|
|
106
|
+
*/
|
|
107
|
+
declare function mergeEndnoteMaps(...maps: EndnoteMap[]): EndnoteMap;
|
|
108
|
+
//#endregion
|
|
109
|
+
export { EndnoteMap, FootnoteMap, createEmptyEndnoteMap, createEmptyFootnoteMap, getEndnoteDisplayNumber, getEndnoteText, getFootnoteDisplayNumber, getFootnoteText, isSeparatorEndnote, isSeparatorFootnote, mergeEndnoteMaps, mergeFootnoteMaps, parseEndnoteProperties, parseEndnotes, parseFootnoteProperties, parseFootnotes };
|