@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,99 @@
|
|
|
1
|
+
//#region src/utils/units.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Unit Conversion Utilities - Convert OOXML units to CSS/pixels
|
|
4
|
+
*
|
|
5
|
+
* OOXML uses various unit systems that need conversion for rendering:
|
|
6
|
+
* - Twips: 1/20 of a point (1440 twips = 1 inch)
|
|
7
|
+
* - EMUs (English Metric Units): 914400 EMUs = 1 inch
|
|
8
|
+
* - Half-points: 1/2 of a point (144 half-points = 1 inch)
|
|
9
|
+
* - Points: 72 points = 1 inch
|
|
10
|
+
* - Eighths of a point: 1/8 of a point (576 eighths = 1 inch)
|
|
11
|
+
*
|
|
12
|
+
* Standard assumption: 96 DPI (pixels per inch)
|
|
13
|
+
*/
|
|
14
|
+
/** Twips per inch (1 inch = 1440 twips) */
|
|
15
|
+
declare const TWIPS_PER_INCH = 1440;
|
|
16
|
+
/**
|
|
17
|
+
* Word's auto paragraph spacing in px. HTML-origin paragraphs use
|
|
18
|
+
* `w:beforeAutospacing`/`w:afterAutospacing` instead of explicit before/after;
|
|
19
|
+
* Word ignores any explicit value on such paragraphs and renders ~14px. The
|
|
20
|
+
* value is empirical (Word's rendered auto gap), not derivable from a twips
|
|
21
|
+
* conversion. See eigenpal/docx-editor#823.
|
|
22
|
+
*/
|
|
23
|
+
declare const AUTO_PARAGRAPH_SPACING_PX = 14;
|
|
24
|
+
/** Pixels per inch at standard DPI */
|
|
25
|
+
declare const PIXELS_PER_INCH = 96;
|
|
26
|
+
/**
|
|
27
|
+
* Convert twips to pixels (at 96 DPI)
|
|
28
|
+
*
|
|
29
|
+
* 1 inch = 1440 twips = 96 pixels
|
|
30
|
+
* → 1 twip = 96/1440 pixels = 1/15 pixels
|
|
31
|
+
*/
|
|
32
|
+
declare function twipsToPixels(twips: number): number;
|
|
33
|
+
/**
|
|
34
|
+
* Convert pixels to twips
|
|
35
|
+
*/
|
|
36
|
+
declare function pixelsToTwips(px: number): number;
|
|
37
|
+
/**
|
|
38
|
+
* Convert EMUs to pixels (at 96 DPI)
|
|
39
|
+
*
|
|
40
|
+
* 1 inch = 914400 EMUs = 96 pixels
|
|
41
|
+
* Returns 0 for null/undefined/NaN inputs.
|
|
42
|
+
*/
|
|
43
|
+
declare function emuToPixels(emu: number | undefined | null): number;
|
|
44
|
+
/**
|
|
45
|
+
* Convert pixels to EMUs.
|
|
46
|
+
*
|
|
47
|
+
* EMU coordinates in OOXML are integer-typed (xs:long); rounding here keeps
|
|
48
|
+
* floating-point drift (e.g. 52 px → 495299.99999999994) out of the document.
|
|
49
|
+
*/
|
|
50
|
+
declare function pixelsToEmu(px: number): number;
|
|
51
|
+
/**
|
|
52
|
+
* Convert EMUs to twips. Twips are integer-typed in OOXML; round here.
|
|
53
|
+
*/
|
|
54
|
+
declare function emuToTwips(emu: number): number;
|
|
55
|
+
/**
|
|
56
|
+
* Convert twips to EMUs. EMUs are integer-typed in OOXML; round here.
|
|
57
|
+
*/
|
|
58
|
+
declare function twipsToEmu(twips: number): number;
|
|
59
|
+
/**
|
|
60
|
+
* Convert points to pixels (at 96 DPI)
|
|
61
|
+
*
|
|
62
|
+
* 1 inch = 72 points = 96 pixels
|
|
63
|
+
* → 1 point = 96/72 pixels = 4/3 pixels
|
|
64
|
+
*/
|
|
65
|
+
declare function pointsToPixels(points: number): number;
|
|
66
|
+
/**
|
|
67
|
+
* Convert half-points to pixels (at 96 DPI)
|
|
68
|
+
*
|
|
69
|
+
* Half-points are commonly used for font sizes in OOXML (w:sz).
|
|
70
|
+
*/
|
|
71
|
+
declare function halfPointsToPixels(halfPoints: number): number;
|
|
72
|
+
/**
|
|
73
|
+
* Convert half-points to points
|
|
74
|
+
*/
|
|
75
|
+
declare function halfPointsToPoints(halfPoints: number): number;
|
|
76
|
+
/**
|
|
77
|
+
* Convert points to half-points
|
|
78
|
+
*/
|
|
79
|
+
declare function pointsToHalfPoints(points: number): number;
|
|
80
|
+
/**
|
|
81
|
+
* Convert eighths of a point to pixels (at 96 DPI)
|
|
82
|
+
*
|
|
83
|
+
* Eighths of a point are used for border widths in OOXML.
|
|
84
|
+
*/
|
|
85
|
+
declare function eighthsToPixels(eighths: number): number;
|
|
86
|
+
/**
|
|
87
|
+
* Round a pixel value to avoid sub-pixel rendering issues
|
|
88
|
+
*/
|
|
89
|
+
declare function roundPixels(px: number, decimalPlaces?: number): number;
|
|
90
|
+
/**
|
|
91
|
+
* Clamp a value between min and max
|
|
92
|
+
*/
|
|
93
|
+
declare function clamp(value: number, min: number, max: number): number;
|
|
94
|
+
/**
|
|
95
|
+
* Format a pixel value as CSS string
|
|
96
|
+
*/
|
|
97
|
+
declare function formatPx(px: number): string;
|
|
98
|
+
//#endregion
|
|
99
|
+
export { AUTO_PARAGRAPH_SPACING_PX, PIXELS_PER_INCH, TWIPS_PER_INCH, clamp, eighthsToPixels, emuToPixels, emuToTwips, formatPx, halfPointsToPixels, halfPointsToPoints, pixelsToEmu, pixelsToTwips, pointsToHalfPoints, pointsToPixels, roundPixels, twipsToEmu, twipsToPixels };
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
//#region src/utils/units.ts
|
|
2
|
+
/**
|
|
3
|
+
* Unit Conversion Utilities - Convert OOXML units to CSS/pixels
|
|
4
|
+
*
|
|
5
|
+
* OOXML uses various unit systems that need conversion for rendering:
|
|
6
|
+
* - Twips: 1/20 of a point (1440 twips = 1 inch)
|
|
7
|
+
* - EMUs (English Metric Units): 914400 EMUs = 1 inch
|
|
8
|
+
* - Half-points: 1/2 of a point (144 half-points = 1 inch)
|
|
9
|
+
* - Points: 72 points = 1 inch
|
|
10
|
+
* - Eighths of a point: 1/8 of a point (576 eighths = 1 inch)
|
|
11
|
+
*
|
|
12
|
+
* Standard assumption: 96 DPI (pixels per inch)
|
|
13
|
+
*/
|
|
14
|
+
/** Standard DPI for screen rendering */
|
|
15
|
+
const STANDARD_DPI = 96;
|
|
16
|
+
/** Twips per inch (1 inch = 1440 twips) */
|
|
17
|
+
const TWIPS_PER_INCH = 1440;
|
|
18
|
+
/**
|
|
19
|
+
* Word's auto paragraph spacing in px. HTML-origin paragraphs use
|
|
20
|
+
* `w:beforeAutospacing`/`w:afterAutospacing` instead of explicit before/after;
|
|
21
|
+
* Word ignores any explicit value on such paragraphs and renders ~14px. The
|
|
22
|
+
* value is empirical (Word's rendered auto gap), not derivable from a twips
|
|
23
|
+
* conversion. See eigenpal/docx-editor#823.
|
|
24
|
+
*/
|
|
25
|
+
const AUTO_PARAGRAPH_SPACING_PX = 14;
|
|
26
|
+
/** EMUs per inch (1 inch = 914400 EMUs) */
|
|
27
|
+
const EMUS_PER_INCH = 914400;
|
|
28
|
+
/** Points per inch (1 inch = 72 points) */
|
|
29
|
+
const POINTS_PER_INCH = 72;
|
|
30
|
+
/** Half-points per inch (1 inch = 144 half-points) */
|
|
31
|
+
const HALF_POINTS_PER_INCH = 144;
|
|
32
|
+
/** Eighths of a point per inch (1 inch = 576) */
|
|
33
|
+
const EIGHTHS_PER_INCH = 576;
|
|
34
|
+
/** Pixels per inch at standard DPI */
|
|
35
|
+
const PIXELS_PER_INCH = STANDARD_DPI;
|
|
36
|
+
/**
|
|
37
|
+
* Convert twips to pixels (at 96 DPI)
|
|
38
|
+
*
|
|
39
|
+
* 1 inch = 1440 twips = 96 pixels
|
|
40
|
+
* → 1 twip = 96/1440 pixels = 1/15 pixels
|
|
41
|
+
*/
|
|
42
|
+
function twipsToPixels(twips) {
|
|
43
|
+
return twips / TWIPS_PER_INCH * 96;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Convert pixels to twips
|
|
47
|
+
*/
|
|
48
|
+
function pixelsToTwips(px) {
|
|
49
|
+
return px / 96 * TWIPS_PER_INCH;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Convert EMUs to pixels (at 96 DPI)
|
|
53
|
+
*
|
|
54
|
+
* 1 inch = 914400 EMUs = 96 pixels
|
|
55
|
+
* Returns 0 for null/undefined/NaN inputs.
|
|
56
|
+
*/
|
|
57
|
+
function emuToPixels(emu) {
|
|
58
|
+
if (emu === void 0 || emu === null || Number.isNaN(emu)) return 0;
|
|
59
|
+
return Math.round(emu * 96 / EMUS_PER_INCH);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Convert pixels to EMUs.
|
|
63
|
+
*
|
|
64
|
+
* EMU coordinates in OOXML are integer-typed (xs:long); rounding here keeps
|
|
65
|
+
* floating-point drift (e.g. 52 px → 495299.99999999994) out of the document.
|
|
66
|
+
*/
|
|
67
|
+
function pixelsToEmu(px) {
|
|
68
|
+
return Math.round(px / 96 * EMUS_PER_INCH);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Convert EMUs to twips. Twips are integer-typed in OOXML; round here.
|
|
72
|
+
*/
|
|
73
|
+
function emuToTwips(emu) {
|
|
74
|
+
return Math.round(emu / EMUS_PER_INCH * TWIPS_PER_INCH);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Convert twips to EMUs. EMUs are integer-typed in OOXML; round here.
|
|
78
|
+
*/
|
|
79
|
+
function twipsToEmu(twips) {
|
|
80
|
+
return Math.round(twips / TWIPS_PER_INCH * EMUS_PER_INCH);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Convert points to pixels (at 96 DPI)
|
|
84
|
+
*
|
|
85
|
+
* 1 inch = 72 points = 96 pixels
|
|
86
|
+
* → 1 point = 96/72 pixels = 4/3 pixels
|
|
87
|
+
*/
|
|
88
|
+
function pointsToPixels(points) {
|
|
89
|
+
return points / POINTS_PER_INCH * 96;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Convert half-points to pixels (at 96 DPI)
|
|
93
|
+
*
|
|
94
|
+
* Half-points are commonly used for font sizes in OOXML (w:sz).
|
|
95
|
+
*/
|
|
96
|
+
function halfPointsToPixels(halfPoints) {
|
|
97
|
+
return halfPoints / HALF_POINTS_PER_INCH * 96;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Convert half-points to points
|
|
101
|
+
*/
|
|
102
|
+
function halfPointsToPoints(halfPoints) {
|
|
103
|
+
return halfPoints / 2;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Convert points to half-points
|
|
107
|
+
*/
|
|
108
|
+
function pointsToHalfPoints(points) {
|
|
109
|
+
return points * 2;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Convert eighths of a point to pixels (at 96 DPI)
|
|
113
|
+
*
|
|
114
|
+
* Eighths of a point are used for border widths in OOXML.
|
|
115
|
+
*/
|
|
116
|
+
function eighthsToPixels(eighths) {
|
|
117
|
+
return eighths / EIGHTHS_PER_INCH * 96;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Round a pixel value to avoid sub-pixel rendering issues
|
|
121
|
+
*/
|
|
122
|
+
function roundPixels(px, decimalPlaces = 2) {
|
|
123
|
+
const factor = 10 ** decimalPlaces;
|
|
124
|
+
return Math.round(px * factor) / factor;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Clamp a value between min and max
|
|
128
|
+
*/
|
|
129
|
+
function clamp(value, min, max) {
|
|
130
|
+
return Math.min(Math.max(value, min), max);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Format a pixel value as CSS string
|
|
134
|
+
*/
|
|
135
|
+
function formatPx(px) {
|
|
136
|
+
return `${roundPixels(px)}px`;
|
|
137
|
+
}
|
|
138
|
+
//#endregion
|
|
139
|
+
export { AUTO_PARAGRAPH_SPACING_PX, PIXELS_PER_INCH, TWIPS_PER_INCH, clamp, eighthsToPixels, emuToPixels, emuToTwips, formatPx, halfPointsToPixels, halfPointsToPoints, pixelsToEmu, pixelsToTwips, pointsToHalfPoints, pointsToPixels, roundPixels, twipsToEmu, twipsToPixels };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
//#region src/utils/urlSecurity.d.ts
|
|
2
|
+
declare function sanitizeExternalUrl(rawUrl: string | undefined): string | undefined;
|
|
3
|
+
declare function normalizeUserUrl(rawUrl: string): string;
|
|
4
|
+
declare function isAllowedUserUrl(rawUrl: string): boolean;
|
|
5
|
+
declare function sanitizeLinkTarget(target: string | undefined): string;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { isAllowedUserUrl, normalizeUserUrl, sanitizeExternalUrl, sanitizeLinkTarget };
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
//#region src/utils/urlSecurity.ts
|
|
2
|
+
const ALLOWED_URL_PROTOCOLS = /* @__PURE__ */ new Set([
|
|
3
|
+
"http:",
|
|
4
|
+
"https:",
|
|
5
|
+
"mailto:",
|
|
6
|
+
"tel:"
|
|
7
|
+
]);
|
|
8
|
+
const ALLOWED_TARGETS = /* @__PURE__ */ new Set([
|
|
9
|
+
"_blank",
|
|
10
|
+
"_self",
|
|
11
|
+
"_parent",
|
|
12
|
+
"_top"
|
|
13
|
+
]);
|
|
14
|
+
function sanitizeExternalUrl(rawUrl) {
|
|
15
|
+
if (!rawUrl) return;
|
|
16
|
+
const trimmed = rawUrl.trim();
|
|
17
|
+
if (!trimmed) return;
|
|
18
|
+
try {
|
|
19
|
+
const parsed = new URL(trimmed);
|
|
20
|
+
if (!ALLOWED_URL_PROTOCOLS.has(parsed.protocol)) return;
|
|
21
|
+
if ((parsed.protocol === "mailto:" || parsed.protocol === "tel:") && parsed.pathname.trim() === "") return;
|
|
22
|
+
return parsed.href;
|
|
23
|
+
} catch {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function normalizeUserUrl(rawUrl) {
|
|
28
|
+
const trimmed = rawUrl.trim();
|
|
29
|
+
if (!trimmed) return "";
|
|
30
|
+
const normalized = trimmed.toLowerCase();
|
|
31
|
+
if (normalized.startsWith("mailto:") || normalized.startsWith("tel:")) return sanitizeExternalUrl(trimmed) ?? "";
|
|
32
|
+
if (normalized.startsWith("http://") || normalized.startsWith("https://")) return sanitizeExternalUrl(trimmed) ?? "";
|
|
33
|
+
const colonIndex = trimmed.indexOf(":");
|
|
34
|
+
const firstPathSeparatorIndex = findFirstPathSeparatorIndex(trimmed);
|
|
35
|
+
if (colonIndex > 0 && !trimmed.startsWith("[") && (firstPathSeparatorIndex === -1 || colonIndex < firstPathSeparatorIndex)) {
|
|
36
|
+
const suffix = trimmed.slice(colonIndex + 1);
|
|
37
|
+
if (suffix.startsWith("//") || !startsWithPortSuffix(suffix)) return "";
|
|
38
|
+
}
|
|
39
|
+
return sanitizeExternalUrl(`https://${trimmed}`) ?? "";
|
|
40
|
+
}
|
|
41
|
+
function isAllowedUserUrl(rawUrl) {
|
|
42
|
+
return normalizeUserUrl(rawUrl) !== "";
|
|
43
|
+
}
|
|
44
|
+
function sanitizeLinkTarget(target) {
|
|
45
|
+
return target && ALLOWED_TARGETS.has(target) ? target : "_blank";
|
|
46
|
+
}
|
|
47
|
+
function findFirstPathSeparatorIndex(value) {
|
|
48
|
+
return [
|
|
49
|
+
value.indexOf("/"),
|
|
50
|
+
value.indexOf("?"),
|
|
51
|
+
value.indexOf("#")
|
|
52
|
+
].filter((index) => index >= 0).toSorted((a, b) => a - b).at(0) ?? -1;
|
|
53
|
+
}
|
|
54
|
+
function startsWithPortSuffix(value) {
|
|
55
|
+
if (value.length === 0) return false;
|
|
56
|
+
let index = 0;
|
|
57
|
+
while (index < value.length) {
|
|
58
|
+
const char = value.codePointAt(index) ?? 0;
|
|
59
|
+
if (char < 48 || char > 57) break;
|
|
60
|
+
index += 1;
|
|
61
|
+
}
|
|
62
|
+
return index > 0 && (index === value.length || "/?#".includes(value[index]));
|
|
63
|
+
}
|
|
64
|
+
//#endregion
|
|
65
|
+
export { isAllowedUserUrl, normalizeUserUrl, sanitizeExternalUrl, sanitizeLinkTarget };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
|
|
3
|
+
//#region src/watermark/index.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Read the document's watermark. Walks every header part and returns
|
|
6
|
+
* the first watermark encountered (header insertion order). Returns
|
|
7
|
+
* `undefined` when no header carries one.
|
|
8
|
+
*/
|
|
9
|
+
declare function getDocumentWatermark(doc: document_d_exports.Document): document_d_exports.Watermark | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Set (or clear) the document's watermark. Writes the modeled `watermark` to
|
|
12
|
+
* every existing header part (clearing the captured raw VML so the serializer
|
|
13
|
+
* synthesizes from the model), then extends coverage to the header parts a
|
|
14
|
+
* document needs but lacks — see {@link ensureWatermarkHeaderCoverage}. Pass
|
|
15
|
+
* `undefined` to remove the watermark from every header.
|
|
16
|
+
*/
|
|
17
|
+
declare function setDocumentWatermark(doc: document_d_exports.Document, watermark: document_d_exports.Watermark | undefined): document_d_exports.Document;
|
|
18
|
+
/**
|
|
19
|
+
* Ensure the watermark shows on every page it should, even when the header
|
|
20
|
+
* parts a section needs are missing:
|
|
21
|
+
*
|
|
22
|
+
* - A document with no headers at all gets a default header carrying the
|
|
23
|
+
* watermark.
|
|
24
|
+
* - A section with `w:titlePg` but no first-page header gets one (so the
|
|
25
|
+
* watermark appears on the cover page, which would otherwise be blank).
|
|
26
|
+
* - When `w:evenAndOddHeaders` is on but a section has no even header, one is
|
|
27
|
+
* created (so even pages are covered).
|
|
28
|
+
*
|
|
29
|
+
* A typed header is only created for a section that cannot inherit one of that
|
|
30
|
+
* type from itself or a preceding section (Word inherits forward only), so
|
|
31
|
+
* existing headers — and the watermark already written to them — are preserved.
|
|
32
|
+
* Created headers use freshly minted rIds that the save pipeline materializes
|
|
33
|
+
* into real parts.
|
|
34
|
+
*/
|
|
35
|
+
declare function ensureWatermarkHeaderCoverage(doc: document_d_exports.Document, watermark: document_d_exports.Watermark): document_d_exports.Document;
|
|
36
|
+
type PictureWatermark = document_d_exports.PictureWatermark;
|
|
37
|
+
type TextWatermark = document_d_exports.TextWatermark;
|
|
38
|
+
type Watermark = document_d_exports.Watermark;
|
|
39
|
+
export { type PictureWatermark, type TextWatermark, type Watermark, ensureWatermarkHeaderCoverage, getDocumentWatermark, setDocumentWatermark };
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
//#region src/watermark/index.ts
|
|
2
|
+
/**
|
|
3
|
+
* Read the document's watermark. Walks every header part and returns
|
|
4
|
+
* the first watermark encountered (header insertion order). Returns
|
|
5
|
+
* `undefined` when no header carries one.
|
|
6
|
+
*/
|
|
7
|
+
function getDocumentWatermark(doc) {
|
|
8
|
+
const headers = doc.package.headers;
|
|
9
|
+
if (!headers) return;
|
|
10
|
+
for (const header of headers.values()) if (header.watermark) return header.watermark;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Set (or clear) the document's watermark. Writes the modeled `watermark` to
|
|
14
|
+
* every existing header part (clearing the captured raw VML so the serializer
|
|
15
|
+
* synthesizes from the model), then extends coverage to the header parts a
|
|
16
|
+
* document needs but lacks — see {@link ensureWatermarkHeaderCoverage}. Pass
|
|
17
|
+
* `undefined` to remove the watermark from every header.
|
|
18
|
+
*/
|
|
19
|
+
function setDocumentWatermark(doc, watermark) {
|
|
20
|
+
const headers = doc.package.headers;
|
|
21
|
+
const nextHeaders = /* @__PURE__ */ new Map();
|
|
22
|
+
if (headers) for (const [rId, header] of headers) {
|
|
23
|
+
const next = { ...header };
|
|
24
|
+
if (watermark === void 0) {
|
|
25
|
+
delete next.watermark;
|
|
26
|
+
delete next.watermarkBlockIndex;
|
|
27
|
+
} else next.watermark = { ...watermark };
|
|
28
|
+
delete next.rawWatermarkXml;
|
|
29
|
+
nextHeaders.set(rId, next);
|
|
30
|
+
}
|
|
31
|
+
const withExisting = {
|
|
32
|
+
...doc,
|
|
33
|
+
package: {
|
|
34
|
+
...doc.package,
|
|
35
|
+
headers: nextHeaders
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
if (watermark === void 0) return withExisting;
|
|
39
|
+
return ensureWatermarkHeaderCoverage(withExisting, watermark);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Ensure the watermark shows on every page it should, even when the header
|
|
43
|
+
* parts a section needs are missing:
|
|
44
|
+
*
|
|
45
|
+
* - A document with no headers at all gets a default header carrying the
|
|
46
|
+
* watermark.
|
|
47
|
+
* - A section with `w:titlePg` but no first-page header gets one (so the
|
|
48
|
+
* watermark appears on the cover page, which would otherwise be blank).
|
|
49
|
+
* - When `w:evenAndOddHeaders` is on but a section has no even header, one is
|
|
50
|
+
* created (so even pages are covered).
|
|
51
|
+
*
|
|
52
|
+
* A typed header is only created for a section that cannot inherit one of that
|
|
53
|
+
* type from itself or a preceding section (Word inherits forward only), so
|
|
54
|
+
* existing headers — and the watermark already written to them — are preserved.
|
|
55
|
+
* Created headers use freshly minted rIds that the save pipeline materializes
|
|
56
|
+
* into real parts.
|
|
57
|
+
*/
|
|
58
|
+
function ensureWatermarkHeaderCoverage(doc, watermark) {
|
|
59
|
+
const body = doc.package.document;
|
|
60
|
+
const headers = new Map(doc.package.headers);
|
|
61
|
+
const evenOddMode = doc.package.settings?.evenAndOddHeaders === true;
|
|
62
|
+
const resolvesType = (props, type) => props.headerReferences?.some((ref) => ref.type === type && headers.has(ref.rId)) ?? false;
|
|
63
|
+
const usedRIds = /* @__PURE__ */ new Set([
|
|
64
|
+
...doc.package.relationships?.keys() ?? [],
|
|
65
|
+
...headers.keys(),
|
|
66
|
+
...doc.package.footers?.keys() ?? []
|
|
67
|
+
]);
|
|
68
|
+
const coverageRIdByType = /* @__PURE__ */ new Map();
|
|
69
|
+
const coverageRId = (type) => {
|
|
70
|
+
const existing = coverageRIdByType.get(type);
|
|
71
|
+
if (existing !== void 0) return existing;
|
|
72
|
+
let candidate = `rId_wm_${type}`;
|
|
73
|
+
let suffix = 1;
|
|
74
|
+
while (usedRIds.has(candidate)) {
|
|
75
|
+
suffix += 1;
|
|
76
|
+
candidate = `rId_wm_${type}_${suffix}`;
|
|
77
|
+
}
|
|
78
|
+
usedRIds.add(candidate);
|
|
79
|
+
coverageRIdByType.set(type, candidate);
|
|
80
|
+
return candidate;
|
|
81
|
+
};
|
|
82
|
+
const slots = [];
|
|
83
|
+
for (const [index, block] of body.content.entries()) if (block.type === "paragraph" && block.sectionProperties) slots.push({
|
|
84
|
+
props: block.sectionProperties,
|
|
85
|
+
blockIndex: index
|
|
86
|
+
});
|
|
87
|
+
slots.push({
|
|
88
|
+
props: body.finalSectionProperties ?? {},
|
|
89
|
+
blockIndex: null
|
|
90
|
+
});
|
|
91
|
+
const additions = slots.map(() => []);
|
|
92
|
+
const planType = (type, sectionNeedsType) => {
|
|
93
|
+
let inherited = false;
|
|
94
|
+
for (const [index, slot] of slots.entries()) {
|
|
95
|
+
if (resolvesType(slot.props, type)) {
|
|
96
|
+
inherited = true;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (sectionNeedsType(slot.props) && !inherited) {
|
|
100
|
+
additions[index]?.push({
|
|
101
|
+
type,
|
|
102
|
+
rId: coverageRId(type)
|
|
103
|
+
});
|
|
104
|
+
inherited = true;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
planType("default", () => true);
|
|
109
|
+
planType("first", (props) => props.titlePg === true);
|
|
110
|
+
if (evenOddMode) planType("even", () => true);
|
|
111
|
+
if (additions.every((refs) => refs.length === 0)) return doc;
|
|
112
|
+
const coverageTypeByRId = /* @__PURE__ */ new Map();
|
|
113
|
+
for (const ref of additions.flat()) coverageTypeByRId.set(ref.rId, ref.type);
|
|
114
|
+
for (const [rId, type] of coverageTypeByRId) if (!headers.has(rId)) headers.set(rId, {
|
|
115
|
+
type: "header",
|
|
116
|
+
hdrFtrType: type,
|
|
117
|
+
content: [],
|
|
118
|
+
watermark: { ...watermark }
|
|
119
|
+
});
|
|
120
|
+
const withRefs = (props, refs) => refs.length === 0 ? props : {
|
|
121
|
+
...props,
|
|
122
|
+
headerReferences: [...props.headerReferences ?? [], ...refs]
|
|
123
|
+
};
|
|
124
|
+
const additionsByBlock = /* @__PURE__ */ new Map();
|
|
125
|
+
for (const [index, slot] of slots.entries()) if (slot.blockIndex !== null) additionsByBlock.set(slot.blockIndex, additions[index] ?? []);
|
|
126
|
+
const newContent = body.content.map((block, index) => {
|
|
127
|
+
const refs = additionsByBlock.get(index);
|
|
128
|
+
if (block.type === "paragraph" && block.sectionProperties && refs !== void 0 && refs.length > 0) return {
|
|
129
|
+
...block,
|
|
130
|
+
sectionProperties: withRefs(block.sectionProperties, refs)
|
|
131
|
+
};
|
|
132
|
+
return block;
|
|
133
|
+
});
|
|
134
|
+
const newFinal = withRefs(body.finalSectionProperties ?? {}, additions.at(-1) ?? []);
|
|
135
|
+
return {
|
|
136
|
+
...doc,
|
|
137
|
+
package: {
|
|
138
|
+
...doc.package,
|
|
139
|
+
headers,
|
|
140
|
+
document: {
|
|
141
|
+
...body,
|
|
142
|
+
content: newContent,
|
|
143
|
+
finalSectionProperties: newFinal
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
//#endregion
|
|
149
|
+
export { ensureWatermarkHeaderCoverage, getDocumentWatermark, setDocumentWatermark };
|
package/package.json
CHANGED
|
@@ -1,5 +1,125 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stll/folio-core",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Headless, framework-neutral core of folio: the OOXML (.docx) parser, document model, ProseMirror integration, and page-layout engine. No React.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"document-model",
|
|
7
|
+
"docx",
|
|
8
|
+
"headless",
|
|
9
|
+
"ooxml",
|
|
10
|
+
"pagination",
|
|
11
|
+
"prosemirror",
|
|
12
|
+
"word"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/stella/folio",
|
|
15
|
+
"bugs": {
|
|
16
|
+
"url": "https://github.com/stella/folio/issues"
|
|
17
|
+
},
|
|
18
|
+
"license": "Apache-2.0",
|
|
19
|
+
"author": "STLL",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "https://github.com/stella/folio.git",
|
|
23
|
+
"directory": "packages/core"
|
|
24
|
+
},
|
|
25
|
+
"type": "module",
|
|
26
|
+
"sideEffects": false,
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./markdown": {
|
|
33
|
+
"types": "./dist/markdown/index.d.ts",
|
|
34
|
+
"import": "./dist/markdown/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./server": {
|
|
37
|
+
"types": "./dist/server.d.ts",
|
|
38
|
+
"import": "./dist/server.js"
|
|
39
|
+
},
|
|
40
|
+
"./ai-edits": {
|
|
41
|
+
"types": "./dist/ai-edits/index.d.ts",
|
|
42
|
+
"import": "./dist/ai-edits/index.js"
|
|
43
|
+
},
|
|
44
|
+
"./content-controls": {
|
|
45
|
+
"types": "./dist/content-controls/index.d.ts",
|
|
46
|
+
"import": "./dist/content-controls/index.js"
|
|
47
|
+
},
|
|
48
|
+
"./layout-engine": {
|
|
49
|
+
"types": "./dist/layout-engine/index.d.ts",
|
|
50
|
+
"import": "./dist/layout-engine/index.js"
|
|
51
|
+
},
|
|
52
|
+
"./layout-painter": {
|
|
53
|
+
"types": "./dist/layout-painter/index.d.ts",
|
|
54
|
+
"import": "./dist/layout-painter/index.js"
|
|
55
|
+
},
|
|
56
|
+
"./layout-bridge/engine/measuring": {
|
|
57
|
+
"types": "./dist/layout-bridge/engine/measuring/index.d.ts",
|
|
58
|
+
"import": "./dist/layout-bridge/engine/measuring/index.js"
|
|
59
|
+
},
|
|
60
|
+
"./prosemirror": {
|
|
61
|
+
"types": "./dist/prosemirror/index.d.ts",
|
|
62
|
+
"import": "./dist/prosemirror/index.js"
|
|
63
|
+
},
|
|
64
|
+
"./prosemirror/attrs": {
|
|
65
|
+
"types": "./dist/prosemirror/attrs/index.d.ts",
|
|
66
|
+
"import": "./dist/prosemirror/attrs/index.js"
|
|
67
|
+
},
|
|
68
|
+
"./prosemirror/conversion": {
|
|
69
|
+
"types": "./dist/prosemirror/conversion/index.d.ts",
|
|
70
|
+
"import": "./dist/prosemirror/conversion/index.js"
|
|
71
|
+
},
|
|
72
|
+
"./prosemirror/schema": {
|
|
73
|
+
"types": "./dist/prosemirror/schema/index.d.ts",
|
|
74
|
+
"import": "./dist/prosemirror/schema/index.js"
|
|
75
|
+
},
|
|
76
|
+
"./*": {
|
|
77
|
+
"types": "./dist/*.d.ts",
|
|
78
|
+
"import": "./dist/*.js"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"publishConfig": {
|
|
82
|
+
"access": "public"
|
|
83
|
+
},
|
|
84
|
+
"scripts": {
|
|
85
|
+
"build": "rm -rf dist && tsdown",
|
|
86
|
+
"prepack": "bun run build",
|
|
87
|
+
"pack:dry-run": "bun pm pack --dry-run",
|
|
88
|
+
"typecheck": "tsgo --noEmit -p tsconfig.build.json",
|
|
89
|
+
"test": "bun test src",
|
|
90
|
+
"test:property": "bun test $(grep -rlF 'fc.assert' src --include='*.test.ts')",
|
|
91
|
+
"perf": "bun scripts/profile-editor.ts"
|
|
92
|
+
},
|
|
93
|
+
"dependencies": {
|
|
94
|
+
"@stll/docx-core": "^0.1.0",
|
|
95
|
+
"@stll/docx-utils": "^0.1.0",
|
|
96
|
+
"@stll/template-conditions": "^0.1.0",
|
|
97
|
+
"better-result": "2.9.2",
|
|
98
|
+
"csstype": "^3.1.3",
|
|
99
|
+
"fast-xml-parser": "^5.9.3",
|
|
100
|
+
"jszip": "3.10.1",
|
|
101
|
+
"marked": "^18.0.5",
|
|
102
|
+
"prosemirror-commands": "^1.7.1",
|
|
103
|
+
"prosemirror-dropcursor": "^1.8.2",
|
|
104
|
+
"prosemirror-gapcursor": "^1.4.1",
|
|
105
|
+
"prosemirror-history": "^1.5.0",
|
|
106
|
+
"prosemirror-keymap": "^1.2.3",
|
|
107
|
+
"prosemirror-model": "^1.25.9",
|
|
108
|
+
"prosemirror-state": "^1.4.4",
|
|
109
|
+
"prosemirror-tables": "^1.8.5",
|
|
110
|
+
"prosemirror-transform": "^1.12.0",
|
|
111
|
+
"prosemirror-view": "^1.41.8",
|
|
112
|
+
"utif2": "^4.1.0",
|
|
113
|
+
"valibot": "1.4.1",
|
|
114
|
+
"y-prosemirror": "^1.3.7",
|
|
115
|
+
"yjs": "^13.6.31"
|
|
116
|
+
},
|
|
117
|
+
"main": "./dist/index.js",
|
|
118
|
+
"types": "./dist/index.d.ts",
|
|
119
|
+
"files": [
|
|
120
|
+
"dist",
|
|
121
|
+
"README.md",
|
|
122
|
+
"LICENSE",
|
|
123
|
+
"NOTICE.md"
|
|
124
|
+
]
|
|
5
125
|
}
|