@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,12 @@
|
|
|
1
|
+
import { ImageRun } from "../layout-engine/types.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/rotationBoundingBox.d.ts
|
|
4
|
+
type BoundingBox = {
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
};
|
|
8
|
+
declare function parseRotationDegrees(transform: string | undefined): number;
|
|
9
|
+
declare function rotatedBoundingBox(w: number, h: number, deg: number): BoundingBox;
|
|
10
|
+
declare function inlineImageBoundingBox(run: ImageRun): BoundingBox;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { BoundingBox, inlineImageBoundingBox, parseRotationDegrees, rotatedBoundingBox };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//#region src/utils/rotationBoundingBox.ts
|
|
2
|
+
function parseRotationDegrees(transform) {
|
|
3
|
+
if (!transform) return 0;
|
|
4
|
+
const match = /rotate\(\s*(?<degrees>[-\d.]+)\s*deg\s*\)/iu.exec(transform);
|
|
5
|
+
if (!match) return 0;
|
|
6
|
+
const raw = Number.parseFloat(match.groups["degrees"]);
|
|
7
|
+
if (!Number.isFinite(raw)) return 0;
|
|
8
|
+
return (raw % 360 + 360) % 360;
|
|
9
|
+
}
|
|
10
|
+
function rotatedBoundingBox(w, h, deg) {
|
|
11
|
+
if (deg === 0 || deg === 180) return {
|
|
12
|
+
width: w,
|
|
13
|
+
height: h
|
|
14
|
+
};
|
|
15
|
+
if (deg === 90 || deg === 270) return {
|
|
16
|
+
width: h,
|
|
17
|
+
height: w
|
|
18
|
+
};
|
|
19
|
+
const rad = deg * Math.PI / 180;
|
|
20
|
+
const sinA = Math.abs(Math.sin(rad));
|
|
21
|
+
const cosA = Math.abs(Math.cos(rad));
|
|
22
|
+
return {
|
|
23
|
+
width: w * cosA + h * sinA,
|
|
24
|
+
height: w * sinA + h * cosA
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function inlineImageBoundingBox(run) {
|
|
28
|
+
const rotation = parseRotationDegrees(run.transform);
|
|
29
|
+
if (rotation === 0) return {
|
|
30
|
+
width: run.width,
|
|
31
|
+
height: run.height
|
|
32
|
+
};
|
|
33
|
+
return rotatedBoundingBox(run.width, run.height, rotation);
|
|
34
|
+
}
|
|
35
|
+
//#endregion
|
|
36
|
+
export { inlineImageBoundingBox, parseRotationDegrees, rotatedBoundingBox };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//#region src/utils/scriptSegments.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Script segmentation for per-character East-Asian font selection.
|
|
4
|
+
*
|
|
5
|
+
* Word resolves a run's font per character: East-Asian (CJK) code points use
|
|
6
|
+
* the run's `w:eastAsia` font slot, everything else uses `w:ascii`/`w:hAnsi`.
|
|
7
|
+
* folio mirrors this by splitting a run's text into maximal same-script
|
|
8
|
+
* segments that the measurer and the painter both consume, so line wrapping
|
|
9
|
+
* stays in sync with rendering.
|
|
10
|
+
*
|
|
11
|
+
* Ranges are authored with `\u` escapes only — never pasted glyphs (a pasted
|
|
12
|
+
* glyph once silently corrupted an RTL character class here).
|
|
13
|
+
*/
|
|
14
|
+
type ScriptSegment = {
|
|
15
|
+
text: string;
|
|
16
|
+
isCjk: boolean;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* True when a code point belongs to an East-Asian script that Word renders with
|
|
20
|
+
* the `w:eastAsia` font slot: CJK ideographs, kana, Hangul, CJK symbols and
|
|
21
|
+
* punctuation, and fullwidth/halfwidth forms.
|
|
22
|
+
*/
|
|
23
|
+
declare function isCjkCodePoint(cp: number): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* True when the text contains at least one East-Asian code point. Callers use
|
|
26
|
+
* this to skip segmentation entirely on the common all-Latin path.
|
|
27
|
+
*/
|
|
28
|
+
declare function hasCjk(text: string): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Split text into maximal runs of one script class (CJK vs. non-CJK). Iterates
|
|
31
|
+
* by code point so astral ideographs (surrogate pairs) are never split between
|
|
32
|
+
* fonts. Empty input yields no segments; single-class input yields one.
|
|
33
|
+
*/
|
|
34
|
+
declare function segmentByScript(text: string): ScriptSegment[];
|
|
35
|
+
//#endregion
|
|
36
|
+
export { ScriptSegment, hasCjk, isCjkCodePoint, segmentByScript };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//#region src/utils/scriptSegments.ts
|
|
2
|
+
/**
|
|
3
|
+
* True when a code point belongs to an East-Asian script that Word renders with
|
|
4
|
+
* the `w:eastAsia` font slot: CJK ideographs, kana, Hangul, CJK symbols and
|
|
5
|
+
* punctuation, and fullwidth/halfwidth forms.
|
|
6
|
+
*/
|
|
7
|
+
function isCjkCodePoint(cp) {
|
|
8
|
+
return cp >= 11904 && cp <= 12287 || cp >= 12288 && cp <= 13311 || cp >= 13312 && cp <= 19903 || cp >= 19968 && cp <= 40959 || cp >= 43360 && cp <= 43391 || cp >= 44032 && cp <= 55295 || cp >= 4352 && cp <= 4607 || cp >= 63744 && cp <= 64255 || cp >= 65072 && cp <= 65103 || cp >= 65280 && cp <= 65519 || cp >= 131072 && cp <= 262143;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* True when the text contains at least one East-Asian code point. Callers use
|
|
12
|
+
* this to skip segmentation entirely on the common all-Latin path.
|
|
13
|
+
*/
|
|
14
|
+
function hasCjk(text) {
|
|
15
|
+
for (const ch of text) if (isCjkCodePoint(ch.codePointAt(0))) return true;
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Split text into maximal runs of one script class (CJK vs. non-CJK). Iterates
|
|
20
|
+
* by code point so astral ideographs (surrogate pairs) are never split between
|
|
21
|
+
* fonts. Empty input yields no segments; single-class input yields one.
|
|
22
|
+
*/
|
|
23
|
+
function segmentByScript(text) {
|
|
24
|
+
const segments = [];
|
|
25
|
+
let current = "";
|
|
26
|
+
let currentIsCjk = false;
|
|
27
|
+
for (const ch of text) {
|
|
28
|
+
const cjk = isCjkCodePoint(ch.codePointAt(0));
|
|
29
|
+
if (current.length === 0) {
|
|
30
|
+
current = ch;
|
|
31
|
+
currentIsCjk = cjk;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (cjk === currentIsCjk) {
|
|
35
|
+
current += ch;
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
segments.push({
|
|
39
|
+
text: current,
|
|
40
|
+
isCjk: currentIsCjk
|
|
41
|
+
});
|
|
42
|
+
current = ch;
|
|
43
|
+
currentIsCjk = cjk;
|
|
44
|
+
}
|
|
45
|
+
if (current.length > 0) segments.push({
|
|
46
|
+
text: current,
|
|
47
|
+
isCjk: currentIsCjk
|
|
48
|
+
});
|
|
49
|
+
return segments;
|
|
50
|
+
}
|
|
51
|
+
//#endregion
|
|
52
|
+
export { hasCjk, isCjkCodePoint, segmentByScript };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/tableOperations.d.ts
|
|
4
|
+
type TableAction = "addRowAbove" | "addRowBelow" | "addColumnLeft" | "addColumnRight" | "deleteRow" | "deleteColumn" | "mergeCells" | "splitCell" | "deleteTable" | "selectTable" | "selectRow" | "selectColumn" | "borderAll" | "borderOutside" | "borderInside" | "borderNone" | "borderTop" | "borderBottom" | "borderLeft" | "borderRight" | {
|
|
5
|
+
type: "cellFillColor";
|
|
6
|
+
color: string | null;
|
|
7
|
+
} | {
|
|
8
|
+
type: "borderColor";
|
|
9
|
+
color: string;
|
|
10
|
+
} | {
|
|
11
|
+
type: "borderWidth";
|
|
12
|
+
size: number;
|
|
13
|
+
} | {
|
|
14
|
+
type: "cellBorder";
|
|
15
|
+
side: "top" | "bottom" | "left" | "right" | "all";
|
|
16
|
+
style: string;
|
|
17
|
+
size: number;
|
|
18
|
+
color: string;
|
|
19
|
+
} | {
|
|
20
|
+
type: "cellVerticalAlign";
|
|
21
|
+
align: "top" | "center" | "bottom";
|
|
22
|
+
} | {
|
|
23
|
+
type: "cellMargins";
|
|
24
|
+
margins: {
|
|
25
|
+
top?: number;
|
|
26
|
+
bottom?: number;
|
|
27
|
+
left?: number;
|
|
28
|
+
right?: number;
|
|
29
|
+
};
|
|
30
|
+
} | {
|
|
31
|
+
type: "cellTextDirection";
|
|
32
|
+
direction: string | null;
|
|
33
|
+
} | {
|
|
34
|
+
type: "toggleNoWrap";
|
|
35
|
+
} | {
|
|
36
|
+
type: "rowHeight";
|
|
37
|
+
height: number | null;
|
|
38
|
+
rule?: "auto" | "atLeast" | "exact";
|
|
39
|
+
} | {
|
|
40
|
+
type: "toggleHeaderRow";
|
|
41
|
+
} | {
|
|
42
|
+
type: "distributeColumns";
|
|
43
|
+
} | {
|
|
44
|
+
type: "autoFitContents";
|
|
45
|
+
} | {
|
|
46
|
+
type: "tableProperties";
|
|
47
|
+
props: {
|
|
48
|
+
width?: number | null;
|
|
49
|
+
widthType?: string | null;
|
|
50
|
+
justification?: "left" | "center" | "right" | null;
|
|
51
|
+
};
|
|
52
|
+
} | {
|
|
53
|
+
type: "openTableProperties";
|
|
54
|
+
} | {
|
|
55
|
+
type: "applyTableStyle";
|
|
56
|
+
styleId: string;
|
|
57
|
+
};
|
|
58
|
+
type TableSelection = {
|
|
59
|
+
tableIndex: number;
|
|
60
|
+
rowIndex: number;
|
|
61
|
+
columnIndex: number;
|
|
62
|
+
selectedCells?: {
|
|
63
|
+
startRow: number;
|
|
64
|
+
startCol: number;
|
|
65
|
+
endRow: number;
|
|
66
|
+
endCol: number;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
type TableContext = {
|
|
70
|
+
table: document_d_exports.Table;
|
|
71
|
+
selection: TableSelection;
|
|
72
|
+
hasMultiCellSelection: boolean;
|
|
73
|
+
canSplitCell: boolean;
|
|
74
|
+
rowCount: number;
|
|
75
|
+
columnCount: number;
|
|
76
|
+
};
|
|
77
|
+
declare const getColumnCount: (table: document_d_exports.Table) => number;
|
|
78
|
+
declare const getCellAt: (table: document_d_exports.Table, rowIndex: number, columnIndex: number) => document_d_exports.TableCell | null;
|
|
79
|
+
declare const createTableContext: (table: document_d_exports.Table, selection: TableSelection) => TableContext;
|
|
80
|
+
declare const addRow: (table: document_d_exports.Table, atIndex: number, position?: "before" | "after") => document_d_exports.Table;
|
|
81
|
+
declare const deleteRow: (table: document_d_exports.Table, rowIndex: number) => document_d_exports.Table;
|
|
82
|
+
declare const addColumn: (table: document_d_exports.Table, atIndex: number, position?: "before" | "after") => document_d_exports.Table;
|
|
83
|
+
declare const deleteColumn: (table: document_d_exports.Table, columnIndex: number) => document_d_exports.Table;
|
|
84
|
+
declare const mergeCells: (table: document_d_exports.Table, selection: TableSelection) => document_d_exports.Table;
|
|
85
|
+
declare const splitCell: (table: document_d_exports.Table, rowIndex: number, columnIndex: number) => document_d_exports.Table;
|
|
86
|
+
//#endregion
|
|
87
|
+
export { TableAction, TableContext, TableSelection, addColumn, addRow, createTableContext, deleteColumn, deleteRow, getCellAt, getColumnCount, mergeCells, splitCell };
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
//#region src/utils/tableOperations.ts
|
|
2
|
+
const getColumnCount = (table) => {
|
|
3
|
+
let maxCols = 0;
|
|
4
|
+
for (const row of table.rows) {
|
|
5
|
+
let colCount = 0;
|
|
6
|
+
for (const cell of row.cells) colCount += cell.formatting?.gridSpan ?? 1;
|
|
7
|
+
maxCols = Math.max(maxCols, colCount);
|
|
8
|
+
}
|
|
9
|
+
return maxCols;
|
|
10
|
+
};
|
|
11
|
+
const getCellAt = (table, rowIndex, columnIndex) => {
|
|
12
|
+
const row = table.rows[rowIndex];
|
|
13
|
+
if (!row) return null;
|
|
14
|
+
let currentCol = 0;
|
|
15
|
+
for (const cell of row.cells) {
|
|
16
|
+
const colspan = cell.formatting?.gridSpan ?? 1;
|
|
17
|
+
if (columnIndex >= currentCol && columnIndex < currentCol + colspan) return cell;
|
|
18
|
+
currentCol += colspan;
|
|
19
|
+
}
|
|
20
|
+
return null;
|
|
21
|
+
};
|
|
22
|
+
const createTableContext = (table, selection) => {
|
|
23
|
+
const rowCount = table.rows.length;
|
|
24
|
+
const columnCount = getColumnCount(table);
|
|
25
|
+
const hasMultiCellSelection = !!(selection.selectedCells && (selection.selectedCells.startRow !== selection.selectedCells.endRow || selection.selectedCells.startCol !== selection.selectedCells.endCol));
|
|
26
|
+
const currentCell = getCellAt(table, selection.rowIndex, selection.columnIndex);
|
|
27
|
+
return {
|
|
28
|
+
table,
|
|
29
|
+
selection,
|
|
30
|
+
hasMultiCellSelection,
|
|
31
|
+
canSplitCell: !!(currentCell && ((currentCell.formatting?.gridSpan ?? 1) > 1 || currentCell.formatting?.vMerge === "restart")),
|
|
32
|
+
rowCount,
|
|
33
|
+
columnCount
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
const createEmptyCell = () => ({
|
|
37
|
+
type: "tableCell",
|
|
38
|
+
content: [{
|
|
39
|
+
type: "paragraph",
|
|
40
|
+
content: [],
|
|
41
|
+
formatting: {}
|
|
42
|
+
}],
|
|
43
|
+
formatting: {}
|
|
44
|
+
});
|
|
45
|
+
const createEmptyRow = (templateRow, columnCount) => {
|
|
46
|
+
const cells = [];
|
|
47
|
+
let colIndex = 0;
|
|
48
|
+
for (const templateCell of templateRow.cells) {
|
|
49
|
+
cells.push({
|
|
50
|
+
type: "tableCell",
|
|
51
|
+
content: [{
|
|
52
|
+
type: "paragraph",
|
|
53
|
+
content: [],
|
|
54
|
+
formatting: {}
|
|
55
|
+
}],
|
|
56
|
+
formatting: (() => {
|
|
57
|
+
if (!templateCell.formatting) return {};
|
|
58
|
+
const { vMerge: _vm, ...rest } = templateCell.formatting;
|
|
59
|
+
return rest;
|
|
60
|
+
})()
|
|
61
|
+
});
|
|
62
|
+
colIndex += templateCell.formatting?.gridSpan ?? 1;
|
|
63
|
+
}
|
|
64
|
+
while (colIndex < columnCount) {
|
|
65
|
+
cells.push(createEmptyCell());
|
|
66
|
+
colIndex++;
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
type: "tableRow",
|
|
70
|
+
cells,
|
|
71
|
+
formatting: {
|
|
72
|
+
...templateRow.formatting,
|
|
73
|
+
header: false
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
const addRow = (table, atIndex, position = "after") => {
|
|
78
|
+
const newRows = [...table.rows];
|
|
79
|
+
const insertIndex = position === "before" ? atIndex : atIndex + 1;
|
|
80
|
+
const templateRow = table.rows[atIndex] ?? table.rows[0];
|
|
81
|
+
if (!templateRow) return table;
|
|
82
|
+
newRows.splice(insertIndex, 0, createEmptyRow(templateRow, getColumnCount(table)));
|
|
83
|
+
return {
|
|
84
|
+
...table,
|
|
85
|
+
rows: newRows
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
const deleteRow = (table, rowIndex) => {
|
|
89
|
+
if (table.rows.length <= 1) return table;
|
|
90
|
+
return {
|
|
91
|
+
...table,
|
|
92
|
+
rows: table.rows.filter((_, i) => i !== rowIndex)
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
const addColumn = (table, atIndex, position = "after") => {
|
|
96
|
+
const insertIndex = position === "before" ? atIndex : atIndex + 1;
|
|
97
|
+
const newRows = table.rows.map((row) => {
|
|
98
|
+
const newCells = [...row.cells];
|
|
99
|
+
let currentCol = 0;
|
|
100
|
+
let insertCellIndex = 0;
|
|
101
|
+
for (let i = 0; i < row.cells.length; i++) {
|
|
102
|
+
const colspan = row.cells[i]?.formatting?.gridSpan ?? 1;
|
|
103
|
+
if (insertIndex <= currentCol + colspan) {
|
|
104
|
+
insertCellIndex = position === "before" ? i : i + 1;
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
currentCol += colspan;
|
|
108
|
+
insertCellIndex = i + 1;
|
|
109
|
+
}
|
|
110
|
+
newCells.splice(insertCellIndex, 0, createEmptyCell());
|
|
111
|
+
return {
|
|
112
|
+
...row,
|
|
113
|
+
cells: newCells
|
|
114
|
+
};
|
|
115
|
+
});
|
|
116
|
+
let newColumnWidths = table.columnWidths;
|
|
117
|
+
if (table.columnWidths && table.columnWidths.length > 0) {
|
|
118
|
+
newColumnWidths = [...table.columnWidths];
|
|
119
|
+
const templateWidth = table.columnWidths[atIndex] ?? table.columnWidths[0] ?? 1440;
|
|
120
|
+
newColumnWidths.splice(insertIndex, 0, templateWidth);
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
...table,
|
|
124
|
+
rows: newRows,
|
|
125
|
+
...newColumnWidths !== void 0 ? { columnWidths: newColumnWidths } : {}
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
const deleteColumn = (table, columnIndex) => {
|
|
129
|
+
if (getColumnCount(table) <= 1) return table;
|
|
130
|
+
const newRows = table.rows.map((row) => {
|
|
131
|
+
let currentCol = 0;
|
|
132
|
+
const newCells = [];
|
|
133
|
+
for (const cell of row.cells) {
|
|
134
|
+
const colspan = cell.formatting?.gridSpan ?? 1;
|
|
135
|
+
if (columnIndex >= currentCol && columnIndex < currentCol + colspan) {
|
|
136
|
+
if (colspan > 1) newCells.push({
|
|
137
|
+
...cell,
|
|
138
|
+
formatting: {
|
|
139
|
+
...cell.formatting,
|
|
140
|
+
gridSpan: colspan - 1
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
} else newCells.push(cell);
|
|
144
|
+
currentCol += colspan;
|
|
145
|
+
}
|
|
146
|
+
return {
|
|
147
|
+
...row,
|
|
148
|
+
cells: newCells
|
|
149
|
+
};
|
|
150
|
+
});
|
|
151
|
+
let newColumnWidths = table.columnWidths;
|
|
152
|
+
if (table.columnWidths && table.columnWidths.length > columnIndex) newColumnWidths = table.columnWidths.filter((_, i) => i !== columnIndex);
|
|
153
|
+
return {
|
|
154
|
+
...table,
|
|
155
|
+
rows: newRows,
|
|
156
|
+
...newColumnWidths !== void 0 ? { columnWidths: newColumnWidths } : {}
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
const mergeCells = (table, selection) => {
|
|
160
|
+
if (!selection.selectedCells) return table;
|
|
161
|
+
const { startRow, startCol, endRow, endCol } = selection.selectedCells;
|
|
162
|
+
const rowSpan = endRow - startRow + 1;
|
|
163
|
+
const colSpan = endCol - startCol + 1;
|
|
164
|
+
const newRows = table.rows.map((row, rowIndex) => {
|
|
165
|
+
if (rowIndex < startRow || rowIndex > endRow) return row;
|
|
166
|
+
const newCells = [];
|
|
167
|
+
let currentCol = 0;
|
|
168
|
+
for (const cell of row.cells) {
|
|
169
|
+
const cellColSpan = cell.formatting?.gridSpan ?? 1;
|
|
170
|
+
const cellEndCol = currentCol + cellColSpan - 1;
|
|
171
|
+
if (!(currentCol <= endCol && cellEndCol >= startCol)) newCells.push(cell);
|
|
172
|
+
else if (rowIndex === startRow && currentCol === startCol) newCells.push({
|
|
173
|
+
...cell,
|
|
174
|
+
formatting: {
|
|
175
|
+
...cell.formatting,
|
|
176
|
+
gridSpan: colSpan,
|
|
177
|
+
...rowSpan > 1 ? { vMerge: "restart" } : {}
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
else if (rowIndex > startRow && currentCol === startCol) newCells.push({
|
|
181
|
+
...cell,
|
|
182
|
+
formatting: {
|
|
183
|
+
...cell.formatting,
|
|
184
|
+
gridSpan: colSpan,
|
|
185
|
+
vMerge: "continue"
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
currentCol += cellColSpan;
|
|
189
|
+
}
|
|
190
|
+
return {
|
|
191
|
+
...row,
|
|
192
|
+
cells: newCells
|
|
193
|
+
};
|
|
194
|
+
});
|
|
195
|
+
return {
|
|
196
|
+
...table,
|
|
197
|
+
rows: newRows
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
const splitCell = (table, rowIndex, columnIndex) => {
|
|
201
|
+
const cell = getCellAt(table, rowIndex, columnIndex);
|
|
202
|
+
if (!cell) return table;
|
|
203
|
+
const gridSpan = cell.formatting?.gridSpan ?? 1;
|
|
204
|
+
const isVMergeStart = cell.formatting?.vMerge === "restart";
|
|
205
|
+
if (gridSpan <= 1 && !isVMergeStart) return table;
|
|
206
|
+
const newRows = table.rows.map((row, rIndex) => {
|
|
207
|
+
if (rIndex !== rowIndex && !isVMergeStart) return row;
|
|
208
|
+
const newCells = [];
|
|
209
|
+
let currentCol = 0;
|
|
210
|
+
for (const rowCell of row.cells) {
|
|
211
|
+
const cellColSpan = rowCell.formatting?.gridSpan ?? 1;
|
|
212
|
+
if (currentCol === columnIndex || currentCol <= columnIndex && columnIndex < currentCol + cellColSpan) if (gridSpan > 1) for (let i = 0; i < gridSpan; i++) newCells.push({
|
|
213
|
+
type: "tableCell",
|
|
214
|
+
content: i === 0 ? rowCell.content : [{
|
|
215
|
+
type: "paragraph",
|
|
216
|
+
content: [],
|
|
217
|
+
formatting: {}
|
|
218
|
+
}],
|
|
219
|
+
formatting: (() => {
|
|
220
|
+
if (!rowCell.formatting) return {};
|
|
221
|
+
const { gridSpan: _gs, vMerge: _vm, ...rest } = rowCell.formatting;
|
|
222
|
+
return rest;
|
|
223
|
+
})()
|
|
224
|
+
});
|
|
225
|
+
else if (isVMergeStart && rIndex === rowIndex) newCells.push({
|
|
226
|
+
...rowCell,
|
|
227
|
+
formatting: (() => {
|
|
228
|
+
if (!rowCell.formatting) return {};
|
|
229
|
+
const { vMerge: _vm, ...rest } = rowCell.formatting;
|
|
230
|
+
return rest;
|
|
231
|
+
})()
|
|
232
|
+
});
|
|
233
|
+
else if (rowCell.formatting?.vMerge === "continue") {
|
|
234
|
+
const { vMerge: _vm, ...restFormatting } = rowCell.formatting;
|
|
235
|
+
newCells.push({
|
|
236
|
+
type: "tableCell",
|
|
237
|
+
content: [{
|
|
238
|
+
type: "paragraph",
|
|
239
|
+
content: [],
|
|
240
|
+
formatting: {}
|
|
241
|
+
}],
|
|
242
|
+
formatting: restFormatting
|
|
243
|
+
});
|
|
244
|
+
} else newCells.push(rowCell);
|
|
245
|
+
else newCells.push(rowCell);
|
|
246
|
+
currentCol += cellColSpan;
|
|
247
|
+
}
|
|
248
|
+
return {
|
|
249
|
+
...row,
|
|
250
|
+
cells: newCells
|
|
251
|
+
};
|
|
252
|
+
});
|
|
253
|
+
return {
|
|
254
|
+
...table,
|
|
255
|
+
rows: newRows
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
//#endregion
|
|
259
|
+
export { addColumn, addRow, createTableContext, deleteColumn, deleteRow, getCellAt, getColumnCount, mergeCells, splitCell };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
|
|
3
|
+
//#region src/utils/textFormattingMerge.d.ts
|
|
4
|
+
declare function mergeTextFormatting(target: document_d_exports.TextFormatting | undefined, source: document_d_exports.TextFormatting | undefined): document_d_exports.TextFormatting | undefined;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { mergeTextFormatting };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { mergeFontFamily } from "./fontFamilyMerge.js";
|
|
2
|
+
//#region src/utils/textFormattingMerge.ts
|
|
3
|
+
function mergeTextFormatting(target, source) {
|
|
4
|
+
if (!source && !target) return;
|
|
5
|
+
if (!source) return target;
|
|
6
|
+
if (!target) return { ...source };
|
|
7
|
+
const result = { ...target };
|
|
8
|
+
for (const key of Object.keys(source)) {
|
|
9
|
+
const value = source[key];
|
|
10
|
+
if (value === void 0) continue;
|
|
11
|
+
if (key === "fontFamily" && typeof value === "object") {
|
|
12
|
+
result["fontFamily"] = mergeFontFamily(target.fontFamily, value);
|
|
13
|
+
continue;
|
|
14
|
+
}
|
|
15
|
+
if (key === "color" && typeof value === "object") {
|
|
16
|
+
result["color"] = value;
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (typeof value === "object" && !Array.isArray(value)) {
|
|
20
|
+
result[key] = {
|
|
21
|
+
...target[key],
|
|
22
|
+
...value
|
|
23
|
+
};
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
result[key] = value;
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { mergeTextFormatting };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/utils/tiffConverter.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* TIFF to PNG Converter
|
|
4
|
+
*
|
|
5
|
+
* Browsers don't support TIFF in `<img>` tags, so DOCX-embedded TIFFs are
|
|
6
|
+
* decoded with utif2 and re-encoded as PNG via the Canvas API. Returns
|
|
7
|
+
* null in environments without Canvas (Node.js parsing); callers fall
|
|
8
|
+
* back to the raw TIFF data URL, which won't render in browsers but is
|
|
9
|
+
* fine for headless round-trips.
|
|
10
|
+
*/
|
|
11
|
+
declare function isTiffMimeType(mimeType: string): boolean;
|
|
12
|
+
type ConvertedTiff = {
|
|
13
|
+
dataUrl: string;
|
|
14
|
+
data: ArrayBuffer;
|
|
15
|
+
};
|
|
16
|
+
declare function convertTiffToPngDataUrl(tiffData: ArrayBuffer): Promise<ConvertedTiff | null>;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { ConvertedTiff, convertTiffToPngDataUrl, isTiffMimeType };
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
//#region src/utils/tiffConverter.ts
|
|
2
|
+
/**
|
|
3
|
+
* TIFF to PNG Converter
|
|
4
|
+
*
|
|
5
|
+
* Browsers don't support TIFF in `<img>` tags, so DOCX-embedded TIFFs are
|
|
6
|
+
* decoded with utif2 and re-encoded as PNG via the Canvas API. Returns
|
|
7
|
+
* null in environments without Canvas (Node.js parsing); callers fall
|
|
8
|
+
* back to the raw TIFF data URL, which won't render in browsers but is
|
|
9
|
+
* fine for headless round-trips.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Hard cap on the pixel count we'll attempt to decode. Each pixel costs 4 B
|
|
13
|
+
* for the intermediate RGBA buffer plus another canvas-managed bitmap, so
|
|
14
|
+
* 64 MP ≈ 256 MB before counting the PNG re-encode. A crafted TIFF whose
|
|
15
|
+
* declared dimensions exceed this is rejected without allocating the
|
|
16
|
+
* RGBA buffer, which would otherwise hang or OOM the tab.
|
|
17
|
+
*/
|
|
18
|
+
const MAX_TIFF_PIXELS = 64e6;
|
|
19
|
+
function isTiffMimeType(mimeType) {
|
|
20
|
+
const lower = mimeType.toLowerCase();
|
|
21
|
+
return lower === "image/tiff" || lower === "image/tif";
|
|
22
|
+
}
|
|
23
|
+
async function convertTiffToPngDataUrl(tiffData) {
|
|
24
|
+
if (typeof document === "undefined" || typeof document.createElement !== "function") return null;
|
|
25
|
+
try {
|
|
26
|
+
const UTIF = await import("utif2");
|
|
27
|
+
const firstImage = UTIF.decode(tiffData)[0];
|
|
28
|
+
if (!firstImage) return null;
|
|
29
|
+
const declaredWidth = readTiffTagNumber(firstImage["t256"]);
|
|
30
|
+
const declaredHeight = readTiffTagNumber(firstImage["t257"]);
|
|
31
|
+
if (!declaredWidth || !declaredHeight) return null;
|
|
32
|
+
if (declaredWidth * declaredHeight > MAX_TIFF_PIXELS) return null;
|
|
33
|
+
UTIF.decodeImage(tiffData, firstImage);
|
|
34
|
+
const rgba = UTIF.toRGBA8(firstImage);
|
|
35
|
+
if (rgba.length === 0) return null;
|
|
36
|
+
const width = firstImage.width;
|
|
37
|
+
const height = firstImage.height;
|
|
38
|
+
if (!width || !height) return null;
|
|
39
|
+
const canvas = document.createElement("canvas");
|
|
40
|
+
canvas.width = width;
|
|
41
|
+
canvas.height = height;
|
|
42
|
+
const ctx = canvas.getContext("2d");
|
|
43
|
+
if (!ctx) return null;
|
|
44
|
+
const clamped = new Uint8ClampedArray(rgba.length);
|
|
45
|
+
clamped.set(rgba);
|
|
46
|
+
const imageData = new ImageData(clamped, width, height);
|
|
47
|
+
ctx.putImageData(imageData, 0, 0);
|
|
48
|
+
const dataUrl = canvas.toDataURL("image/png");
|
|
49
|
+
const data = dataUrlToArrayBuffer(dataUrl);
|
|
50
|
+
if (!data) return null;
|
|
51
|
+
return {
|
|
52
|
+
dataUrl,
|
|
53
|
+
data
|
|
54
|
+
};
|
|
55
|
+
} catch {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Read a numeric TIFF tag value. utif2 stores tag values as arrays
|
|
61
|
+
* (typed or plain), so the cap-check helpers only need the first element.
|
|
62
|
+
*/
|
|
63
|
+
function readTiffTagNumber(tag) {
|
|
64
|
+
if (typeof tag === "number") return tag;
|
|
65
|
+
if (Array.isArray(tag) || tag instanceof Uint8Array || tag instanceof Uint16Array || tag instanceof Uint32Array) {
|
|
66
|
+
const first = tag[0];
|
|
67
|
+
if (typeof first === "number") return first;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function dataUrlToArrayBuffer(dataUrl) {
|
|
71
|
+
const base64 = dataUrl.split(",", 2)[1];
|
|
72
|
+
if (!base64) return null;
|
|
73
|
+
try {
|
|
74
|
+
const binary = atob(base64);
|
|
75
|
+
const bytes = new Uint8Array(binary.length);
|
|
76
|
+
for (let i = 0; i < binary.length; i++) bytes[i] = binary.codePointAt(i) ?? 0;
|
|
77
|
+
return bytes.buffer;
|
|
78
|
+
} catch {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
export { convertTiffToPngDataUrl, isTiffMimeType };
|