@stll/folio-core 0.0.1-placeholder.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +66 -0
- package/dist/types/block-id.js +73 -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,137 @@
|
|
|
1
|
+
//#region src/prosemirror/utils/tabCalculator.ts
|
|
2
|
+
/** Default tab interval: 720 twips = 0.5 inch */
|
|
3
|
+
const DEFAULT_TAB_INTERVAL_TWIPS = 720;
|
|
4
|
+
/** Twips per inch */
|
|
5
|
+
const TWIPS_PER_INCH = 1440;
|
|
6
|
+
/** Pixels per inch (96 dpi standard for CSS) */
|
|
7
|
+
const PIXELS_PER_INCH = 96;
|
|
8
|
+
/**
|
|
9
|
+
* Convert twips to pixels
|
|
10
|
+
* @param twips - Value in twips (1/1440 inch)
|
|
11
|
+
* @returns Value in pixels (at 96 dpi)
|
|
12
|
+
*/
|
|
13
|
+
function twipsToPixels(twips) {
|
|
14
|
+
return twips / TWIPS_PER_INCH * 96;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Convert pixels to twips
|
|
18
|
+
* @param pixels - Value in pixels (at 96 dpi)
|
|
19
|
+
* @returns Value in twips (1/1440 inch)
|
|
20
|
+
*/
|
|
21
|
+
function pixelsToTwips(pixels) {
|
|
22
|
+
return pixels / 96 * TWIPS_PER_INCH;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Compute the list of effective tab stops for a paragraph
|
|
26
|
+
*
|
|
27
|
+
* Merges explicit stops with default stops at regular intervals.
|
|
28
|
+
* Filters out stops that fall before the left indent.
|
|
29
|
+
*
|
|
30
|
+
* @param context - Tab context with explicit stops and settings
|
|
31
|
+
* @returns Sorted array of tab stops in twips
|
|
32
|
+
*/
|
|
33
|
+
function computeTabStops(context) {
|
|
34
|
+
const { explicitStops = [], defaultTabInterval = 720, leftIndent = 0 } = context;
|
|
35
|
+
const validExplicitStops = explicitStops.filter((stop) => stop.val !== "clear").filter((stop) => stop.pos >= leftIndent);
|
|
36
|
+
const clearPositions = explicitStops.filter((stop) => stop.val === "clear").map((stop) => stop.pos);
|
|
37
|
+
let maxExplicit = 0;
|
|
38
|
+
for (const stop of validExplicitStops) maxExplicit = Math.max(maxExplicit, stop.pos);
|
|
39
|
+
const stops = [...validExplicitStops];
|
|
40
|
+
if (leftIndent > 0 && !validExplicitStops.some((s) => s.pos <= leftIndent)) {
|
|
41
|
+
if (!clearPositions.some((p) => Math.abs(p - leftIndent) < 20)) stops.push({
|
|
42
|
+
val: "start",
|
|
43
|
+
pos: leftIndent,
|
|
44
|
+
leader: "none"
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
let pos = maxExplicit > 0 ? Math.max(maxExplicit, leftIndent) : leftIndent;
|
|
48
|
+
const limitPos = leftIndent + 14400;
|
|
49
|
+
while (pos < limitPos) {
|
|
50
|
+
pos += defaultTabInterval;
|
|
51
|
+
let hasExplicitStop = false;
|
|
52
|
+
for (const stop of validExplicitStops) if (Math.abs(stop.pos - pos) < 20) {
|
|
53
|
+
hasExplicitStop = true;
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
let hasClearStop = false;
|
|
57
|
+
for (const clearPos of clearPositions) if (Math.abs(clearPos - pos) < 20) {
|
|
58
|
+
hasClearStop = true;
|
|
59
|
+
break;
|
|
60
|
+
}
|
|
61
|
+
const isAtLeftIndent = leftIndent > 0 && Math.abs(pos - leftIndent) < 20;
|
|
62
|
+
if (!hasExplicitStop && !hasClearStop && !isAtLeftIndent) stops.push({
|
|
63
|
+
val: "start",
|
|
64
|
+
pos,
|
|
65
|
+
leader: "none"
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
return stops.toSorted((a, b) => a.pos - b.pos);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Calculate the width of a tab character.
|
|
72
|
+
*
|
|
73
|
+
* Finds the next tab stop after the current position and computes the width
|
|
74
|
+
* needed to reach it. For `end`/`center`/`decimal` stops the content after the
|
|
75
|
+
* tab is anchored against the stop, so the caller supplies its measured width
|
|
76
|
+
* via {@link TabFollowingContent}.
|
|
77
|
+
*
|
|
78
|
+
* @param currentXPx - Current horizontal position in pixels (from the content
|
|
79
|
+
* area's left edge — the same origin tab stop positions are measured from)
|
|
80
|
+
* @param context - Tab context with stops and settings
|
|
81
|
+
* @param following - Measured widths of the content after the tab
|
|
82
|
+
* @returns Tab width result with width in pixels
|
|
83
|
+
*/
|
|
84
|
+
function calculateTabWidth(currentXPx, context, following = {}) {
|
|
85
|
+
const { defaultTabInterval = 720 } = context;
|
|
86
|
+
const currentXTwips = pixelsToTwips(currentXPx);
|
|
87
|
+
const nextStop = computeTabStops(context).find((stop) => stop.pos > currentXTwips);
|
|
88
|
+
if (!nextStop) {
|
|
89
|
+
const defaultTabPx = twipsToPixels(defaultTabInterval);
|
|
90
|
+
let tabWidth = defaultTabPx - currentXPx % defaultTabPx;
|
|
91
|
+
if (tabWidth <= 0) tabWidth = defaultTabPx;
|
|
92
|
+
return {
|
|
93
|
+
width: tabWidth,
|
|
94
|
+
alignment: "default"
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
let width = twipsToPixels(nextStop.pos) - currentXPx;
|
|
98
|
+
if (nextStop.val === "center") width -= (following.followingWidth ?? 0) / 2;
|
|
99
|
+
else if (nextStop.val === "end") width -= following.followingWidth ?? 0;
|
|
100
|
+
else if (nextStop.val === "decimal") width -= following.decimalPrefixWidth ?? 0;
|
|
101
|
+
else if (nextStop.val === "bar") return {
|
|
102
|
+
width: 0,
|
|
103
|
+
...nextStop.leader !== void 0 ? { leader: nextStop.leader } : {},
|
|
104
|
+
alignment: "bar"
|
|
105
|
+
};
|
|
106
|
+
if (width < 1) {
|
|
107
|
+
const defaultTabPx = twipsToPixels(defaultTabInterval);
|
|
108
|
+
let fallbackWidth = defaultTabPx - currentXPx % defaultTabPx;
|
|
109
|
+
if (fallbackWidth <= 0) fallbackWidth = defaultTabPx;
|
|
110
|
+
return {
|
|
111
|
+
width: fallbackWidth,
|
|
112
|
+
alignment: "default"
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
return {
|
|
116
|
+
width,
|
|
117
|
+
...nextStop.leader !== void 0 ? { leader: nextStop.leader } : {},
|
|
118
|
+
alignment: nextStop.val
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Calculate tab width with simple default stops
|
|
123
|
+
*
|
|
124
|
+
* Simplified version for basic tab rendering without explicit stops.
|
|
125
|
+
* Uses the default 0.5 inch (48px) tab interval.
|
|
126
|
+
*
|
|
127
|
+
* @param currentXPx - Current horizontal position in pixels
|
|
128
|
+
* @returns Width of the tab in pixels
|
|
129
|
+
*/
|
|
130
|
+
function calculateSimpleTabWidth(currentXPx) {
|
|
131
|
+
const defaultTabPx = twipsToPixels(720);
|
|
132
|
+
let tabWidth = defaultTabPx - currentXPx % defaultTabPx;
|
|
133
|
+
if (tabWidth < defaultTabPx / 4) tabWidth += defaultTabPx;
|
|
134
|
+
return tabWidth;
|
|
135
|
+
}
|
|
136
|
+
//#endregion
|
|
137
|
+
export { DEFAULT_TAB_INTERVAL_TWIPS, PIXELS_PER_INCH, TWIPS_PER_INCH, calculateSimpleTabWidth, calculateTabWidth, computeTabStops, pixelsToTwips, twipsToPixels };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Node } from "prosemirror-model";
|
|
2
|
+
|
|
3
|
+
//#region src/prosemirror/validation.d.ts
|
|
4
|
+
type ProseMirrorDocumentValidationIssue = {
|
|
5
|
+
path: string;
|
|
6
|
+
message: string;
|
|
7
|
+
};
|
|
8
|
+
type ValidateProseMirrorDocumentResult = {
|
|
9
|
+
valid: boolean;
|
|
10
|
+
issues: ProseMirrorDocumentValidationIssue[];
|
|
11
|
+
};
|
|
12
|
+
declare class ProseMirrorDocumentValidationError extends Error {
|
|
13
|
+
readonly issues: ProseMirrorDocumentValidationIssue[];
|
|
14
|
+
constructor(context: string, issues: ProseMirrorDocumentValidationIssue[]);
|
|
15
|
+
}
|
|
16
|
+
declare const validateProseMirrorDocument: (doc: Node) => ValidateProseMirrorDocumentResult;
|
|
17
|
+
declare const assertValidProseMirrorDocument: (doc: Node, context: string) => void;
|
|
18
|
+
declare const formatProseMirrorDocumentIssues: (issues: ProseMirrorDocumentValidationIssue[]) => string[];
|
|
19
|
+
//#endregion
|
|
20
|
+
export { ProseMirrorDocumentValidationError, ProseMirrorDocumentValidationIssue, ValidateProseMirrorDocumentResult, assertValidProseMirrorDocument, formatProseMirrorDocumentIssues, validateProseMirrorDocument };
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { readBlockSdtAttrs, readCharacterSpacingMarkAttrs, readCharacterStyleMarkAttrs, readCommentMarkAttrs, readEmphasisMarkAttrs, readFieldAttrs, readFontFamilyMarkAttrs, readFontSizeMarkAttrs, readFootnoteRefMarkAttrs, readHardBreakAttrs, readHighlightMarkAttrs, readHyperlinkMarkAttrs, readImageAttrs, readMathAttrs, readParagraphAttrs, readRunFormattingOverrideMarkAttrs, readRunShadingMarkAttrs, readSdtAttrs, readShapeAttrs, readStrikeMarkAttrs, readTableAttrs, readTableCellAttrs, readTableRowAttrs, readTextBoxAttrs, readTextColorMarkAttrs, readTextEffectMarkAttrs, readTrackedChangeMarkAttrs, readUnderlineMarkAttrs } from "./attrs/index.js";
|
|
2
|
+
//#region src/prosemirror/validation.ts
|
|
3
|
+
var ProseMirrorDocumentValidationError = class extends Error {
|
|
4
|
+
issues;
|
|
5
|
+
constructor(context, issues) {
|
|
6
|
+
super(`${context}:\n${formatProseMirrorDocumentIssues(issues).join("\n")}`);
|
|
7
|
+
this.name = "ProseMirrorDocumentValidationError";
|
|
8
|
+
this.issues = issues;
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
const validDocumentCache = /* @__PURE__ */ new WeakSet();
|
|
12
|
+
const validNodeCache = /* @__PURE__ */ new WeakSet();
|
|
13
|
+
const validateProseMirrorDocument = (doc) => {
|
|
14
|
+
const issues = [];
|
|
15
|
+
if (doc.type.name !== "doc") issues.push({
|
|
16
|
+
path: "doc.type.name",
|
|
17
|
+
message: `Expected doc, got ${doc.type.name}.`
|
|
18
|
+
});
|
|
19
|
+
validateNode(doc, "doc", issues);
|
|
20
|
+
return {
|
|
21
|
+
valid: issues.length === 0,
|
|
22
|
+
issues
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
const assertValidProseMirrorDocument = (doc, context) => {
|
|
26
|
+
if (validDocumentCache.has(doc)) return;
|
|
27
|
+
const validation = validateProseMirrorDocument(doc);
|
|
28
|
+
if (validation.valid) {
|
|
29
|
+
validDocumentCache.add(doc);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
throw new ProseMirrorDocumentValidationError(context, validation.issues);
|
|
33
|
+
};
|
|
34
|
+
const formatProseMirrorDocumentIssues = (issues) => issues.map((issue) => `ProseMirror document error at ${issue.path}: ${issue.message}`);
|
|
35
|
+
const validateNode = (node, path, issues) => {
|
|
36
|
+
if (validNodeCache.has(node)) return;
|
|
37
|
+
const issueCountBeforeNode = issues.length;
|
|
38
|
+
validateNodeAttrs(node, path, issues);
|
|
39
|
+
validateMarks(node.marks, path, issues);
|
|
40
|
+
node.forEach((child, _offset, index) => {
|
|
41
|
+
validateNode(child, `${path}.content[${index}]`, issues);
|
|
42
|
+
});
|
|
43
|
+
if (issues.length === issueCountBeforeNode) validNodeCache.add(node);
|
|
44
|
+
};
|
|
45
|
+
const validateNodeAttrs = (node, path, issues) => {
|
|
46
|
+
switch (node.type.name) {
|
|
47
|
+
case "doc":
|
|
48
|
+
case "text":
|
|
49
|
+
case "horizontalRule":
|
|
50
|
+
case "pageBreak":
|
|
51
|
+
case "tab": return;
|
|
52
|
+
case "hardBreak":
|
|
53
|
+
appendAttrIssues(path, readHardBreakAttrs(node), issues);
|
|
54
|
+
return;
|
|
55
|
+
case "paragraph":
|
|
56
|
+
appendAttrIssues(path, readParagraphAttrs(node), issues);
|
|
57
|
+
return;
|
|
58
|
+
case "table":
|
|
59
|
+
appendAttrIssues(path, readTableAttrs(node), issues);
|
|
60
|
+
return;
|
|
61
|
+
case "tableRow":
|
|
62
|
+
appendAttrIssues(path, readTableRowAttrs(node), issues);
|
|
63
|
+
return;
|
|
64
|
+
case "tableCell":
|
|
65
|
+
case "tableHeader":
|
|
66
|
+
appendAttrIssues(path, readTableCellAttrs(node), issues);
|
|
67
|
+
return;
|
|
68
|
+
case "image":
|
|
69
|
+
appendAttrIssues(path, readImageAttrs(node), issues);
|
|
70
|
+
return;
|
|
71
|
+
case "field":
|
|
72
|
+
appendAttrIssues(path, readFieldAttrs(node), issues);
|
|
73
|
+
return;
|
|
74
|
+
case "math":
|
|
75
|
+
appendAttrIssues(path, readMathAttrs(node), issues);
|
|
76
|
+
return;
|
|
77
|
+
case "sdt":
|
|
78
|
+
appendAttrIssues(path, readSdtAttrs(node), issues);
|
|
79
|
+
return;
|
|
80
|
+
case "blockSdt":
|
|
81
|
+
appendAttrIssues(path, readBlockSdtAttrs(node), issues);
|
|
82
|
+
for (let i = 0; i < node.childCount; i += 1) validateNode(node.child(i), `${path}.content[${i}]`, issues);
|
|
83
|
+
return;
|
|
84
|
+
case "shape":
|
|
85
|
+
appendAttrIssues(path, readShapeAttrs(node), issues);
|
|
86
|
+
return;
|
|
87
|
+
case "textBox":
|
|
88
|
+
appendAttrIssues(path, readTextBoxAttrs(node), issues);
|
|
89
|
+
return;
|
|
90
|
+
default: issues.push({
|
|
91
|
+
path: `${path}.type.name`,
|
|
92
|
+
message: `Unsupported ProseMirror node type ${node.type.name}.`
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const validateMarks = (marks, path, issues) => {
|
|
97
|
+
for (const [index, mark] of marks.entries()) {
|
|
98
|
+
const markPath = `${path}.marks[${index}]`;
|
|
99
|
+
switch (mark.type.name) {
|
|
100
|
+
case "bold":
|
|
101
|
+
case "italic":
|
|
102
|
+
case "subscript":
|
|
103
|
+
case "superscript":
|
|
104
|
+
case "allCaps":
|
|
105
|
+
case "smallCaps":
|
|
106
|
+
case "emboss":
|
|
107
|
+
case "imprint":
|
|
108
|
+
case "hidden":
|
|
109
|
+
case "textShadow":
|
|
110
|
+
case "textOutline":
|
|
111
|
+
case "rtl": continue;
|
|
112
|
+
case "textEffect":
|
|
113
|
+
appendAttrIssues(markPath, readTextEffectMarkAttrs(mark), issues);
|
|
114
|
+
continue;
|
|
115
|
+
case "underline":
|
|
116
|
+
appendAttrIssues(markPath, readUnderlineMarkAttrs(mark), issues);
|
|
117
|
+
continue;
|
|
118
|
+
case "strike":
|
|
119
|
+
appendAttrIssues(markPath, readStrikeMarkAttrs(mark), issues);
|
|
120
|
+
continue;
|
|
121
|
+
case "textColor":
|
|
122
|
+
appendAttrIssues(markPath, readTextColorMarkAttrs(mark), issues);
|
|
123
|
+
continue;
|
|
124
|
+
case "highlight":
|
|
125
|
+
appendAttrIssues(markPath, readHighlightMarkAttrs(mark), issues);
|
|
126
|
+
continue;
|
|
127
|
+
case "runShading":
|
|
128
|
+
appendAttrIssues(markPath, readRunShadingMarkAttrs(mark), issues);
|
|
129
|
+
continue;
|
|
130
|
+
case "fontSize":
|
|
131
|
+
appendAttrIssues(markPath, readFontSizeMarkAttrs(mark), issues);
|
|
132
|
+
continue;
|
|
133
|
+
case "fontFamily":
|
|
134
|
+
appendAttrIssues(markPath, readFontFamilyMarkAttrs(mark), issues);
|
|
135
|
+
continue;
|
|
136
|
+
case "characterSpacing":
|
|
137
|
+
appendAttrIssues(markPath, readCharacterSpacingMarkAttrs(mark), issues);
|
|
138
|
+
continue;
|
|
139
|
+
case "characterStyle":
|
|
140
|
+
appendAttrIssues(markPath, readCharacterStyleMarkAttrs(mark), issues);
|
|
141
|
+
continue;
|
|
142
|
+
case "emphasisMark":
|
|
143
|
+
appendAttrIssues(markPath, readEmphasisMarkAttrs(mark), issues);
|
|
144
|
+
continue;
|
|
145
|
+
case "footnoteRef":
|
|
146
|
+
appendAttrIssues(markPath, readFootnoteRefMarkAttrs(mark), issues);
|
|
147
|
+
continue;
|
|
148
|
+
case "comment":
|
|
149
|
+
appendAttrIssues(markPath, readCommentMarkAttrs(mark), issues);
|
|
150
|
+
continue;
|
|
151
|
+
case "insertion":
|
|
152
|
+
case "deletion":
|
|
153
|
+
appendAttrIssues(markPath, readTrackedChangeMarkAttrs(mark), issues);
|
|
154
|
+
continue;
|
|
155
|
+
case "runFormattingOverride":
|
|
156
|
+
appendAttrIssues(markPath, readRunFormattingOverrideMarkAttrs(mark), issues);
|
|
157
|
+
continue;
|
|
158
|
+
case "hyperlink":
|
|
159
|
+
appendAttrIssues(markPath, readHyperlinkMarkAttrs(mark), issues);
|
|
160
|
+
continue;
|
|
161
|
+
default: issues.push({
|
|
162
|
+
path: `${markPath}.type.name`,
|
|
163
|
+
message: `Unsupported ProseMirror mark type ${mark.type.name}.`
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
const appendAttrIssues = (path, result, issues) => {
|
|
169
|
+
if (result.ok) return;
|
|
170
|
+
for (const issue of result.issues) issues.push(withPathPrefix(path, issue));
|
|
171
|
+
};
|
|
172
|
+
const withPathPrefix = (prefix, issue) => ({
|
|
173
|
+
path: `${prefix}.${issue.path}`,
|
|
174
|
+
message: issue.message
|
|
175
|
+
});
|
|
176
|
+
//#endregion
|
|
177
|
+
export { ProseMirrorDocumentValidationError, assertValidProseMirrorDocument, formatProseMirrorDocumentIssues, validateProseMirrorDocument };
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FolioAIBlock, FolioAIBlockAnchor, FolioAIBlockKind, FolioAIBlockPreviewRun, FolioAIComment, FolioAIEditApplyMode, FolioAIEditApplyResult, FolioAIEditOperation, FolioAIEditSnapshot } from "./ai-edits/types.js";
|
|
2
|
+
import { ApplyFolioAIEditsToBufferOptions, ApplyFolioAIEditsToBufferResult, FolioApplyOperationsOptions, FolioDocxReviewer, FolioDocxReviewerOptions, FolioReviewChange, FolioReviewChangeFilter, FolioReviewChangeKind, FolioReviewComment, FolioReviewCommentFilter, FolioReviewCommentReply, FolioReviewReplyInput, applyFolioAIEditsToBuffer } from "./ai-edits/headless.js";
|
|
3
|
+
import { DeriveBlockIdInput, FolioBlockId, deriveBlockId, getFolioParaIdFromBlockId, isFolioBlockId, isSequentialFolioBlockId } from "./types/block-id.js";
|
|
4
|
+
import { CreateCommentReplyInput, replyToComment } from "./docx/replyToComment.js";
|
|
5
|
+
import { createDocx } from "./docx/rezip.js";
|
|
6
|
+
import { CreateEmptyDocumentOptions, createEmptyDocument } from "./utils/createDocument.js";
|
|
7
|
+
export { type ApplyFolioAIEditsToBufferOptions, type ApplyFolioAIEditsToBufferResult, type CreateCommentReplyInput, type CreateEmptyDocumentOptions, type DeriveBlockIdInput, type FolioAIBlock, type FolioAIBlockAnchor, type FolioAIBlockKind, type FolioAIBlockPreviewRun, type FolioAIComment, type FolioAIEditApplyMode, type FolioAIEditApplyResult, type FolioAIEditOperation, type FolioAIEditSnapshot, type FolioApplyOperationsOptions, type FolioBlockId, FolioDocxReviewer, type FolioDocxReviewerOptions, type FolioReviewChange, type FolioReviewChangeFilter, type FolioReviewChangeKind, type FolioReviewComment, type FolioReviewCommentFilter, type FolioReviewCommentReply, type FolioReviewReplyInput, applyFolioAIEditsToBuffer, createDocx, createEmptyDocument, deriveBlockId, getFolioParaIdFromBlockId, isFolioBlockId, isSequentialFolioBlockId, replyToComment };
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createEmptyDocument } from "./utils/createDocument.js";
|
|
2
|
+
import { createDocx } from "./docx/rezip.js";
|
|
3
|
+
import { deriveBlockId, getFolioParaIdFromBlockId, isFolioBlockId, isSequentialFolioBlockId } from "./types/block-id.js";
|
|
4
|
+
import { replyToComment } from "./docx/replyToComment.js";
|
|
5
|
+
import { FolioDocxReviewer, applyFolioAIEditsToBuffer } from "./ai-edits/headless.js";
|
|
6
|
+
export { FolioDocxReviewer, applyFolioAIEditsToBuffer, createDocx, createEmptyDocument, deriveBlockId, getFolioParaIdFromBlockId, isFolioBlockId, isSequentialFolioBlockId, replyToComment };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ResolvedParagraphStyle } from "../prosemirror/styles/styleResolver.js";
|
|
2
|
+
import { StyleEngine, StyleEngineCacheStats, StyleEngineOptions, createStyleEngine } from "./styleEngine.js";
|
|
3
|
+
export { type ResolvedParagraphStyle, type StyleEngine, type StyleEngineCacheStats, type StyleEngineOptions, createStyleEngine };
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { ResolvedParagraphStyle } from "../prosemirror/styles/styleResolver.js";
|
|
3
|
+
|
|
4
|
+
//#region src/style-engine/styleEngine.d.ts
|
|
5
|
+
/** Engine construction options. */
|
|
6
|
+
type StyleEngineOptions = {
|
|
7
|
+
/**
|
|
8
|
+
* Toggle the memoization layer.
|
|
9
|
+
*
|
|
10
|
+
* Defaults to `true`. Set to `false` to force every call through the
|
|
11
|
+
* underlying {@link StyleResolver}; useful in tests where stale-cache
|
|
12
|
+
* bugs could mask real regressions, and for diagnosing cache-related
|
|
13
|
+
* behaviour without rebuilding the engine.
|
|
14
|
+
*/
|
|
15
|
+
cache?: boolean;
|
|
16
|
+
};
|
|
17
|
+
/** Lightweight observability for cache effectiveness. */
|
|
18
|
+
type StyleEngineCacheStats = {
|
|
19
|
+
hits: number;
|
|
20
|
+
misses: number; /** Total entries across all internal caches. */
|
|
21
|
+
size: number;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Cached, explicit style cascade engine.
|
|
25
|
+
*
|
|
26
|
+
* The engine exposes the same surface as {@link StyleResolver} for the
|
|
27
|
+
* methods folio currently consumes, plus cache controls. Returned
|
|
28
|
+
* objects are shared between cache hits — treat them as immutable.
|
|
29
|
+
*/
|
|
30
|
+
type StyleEngine = {
|
|
31
|
+
/** Look up a single named style by id. */getStyle: (styleId: string) => document_d_exports.Style | undefined; /** True if a style with the given id is registered. */
|
|
32
|
+
hasStyle: (styleId: string) => boolean; /** Return the document-wide defaults (`w:docDefaults`). */
|
|
33
|
+
getDocDefaults: () => document_d_exports.DocDefaults | undefined; /** The style flagged `w:default="1"` for paragraphs, else "Normal". */
|
|
34
|
+
getDefaultParagraphStyle: () => document_d_exports.Style | undefined; /** The style flagged `w:default="1"` for character styles. */
|
|
35
|
+
getDefaultCharacterStyle: () => document_d_exports.Style | undefined; /** The style flagged `w:default="1"` for tables. */
|
|
36
|
+
getDefaultTableStyle: () => document_d_exports.Style | undefined; /** All visible paragraph styles, sorted for toolbar use. */
|
|
37
|
+
getParagraphStyles: () => document_d_exports.Style[]; /** All visible table styles, sorted for the table-style gallery. */
|
|
38
|
+
getTableStyles: () => document_d_exports.Style[];
|
|
39
|
+
/**
|
|
40
|
+
* Resolve the full paragraph cascade for a given styleId.
|
|
41
|
+
* Returned object is cached and must not be mutated.
|
|
42
|
+
*/
|
|
43
|
+
resolveParagraphStyle: (styleId: string | undefined | null) => ResolvedParagraphStyle;
|
|
44
|
+
/**
|
|
45
|
+
* Resolve a run/character style with docDefaults applied.
|
|
46
|
+
* Returns `undefined` when the cascade yields nothing.
|
|
47
|
+
*/
|
|
48
|
+
resolveRunStyle: (styleId: string | undefined | null) => document_d_exports.TextFormatting | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Return a run style's own properties without docDefaults applied —
|
|
51
|
+
* used when the caller has already merged docDefaults via the
|
|
52
|
+
* paragraph cascade and would otherwise double-apply font defaults.
|
|
53
|
+
*/
|
|
54
|
+
getRunStyleOwnProperties: (styleId: string | undefined | null) => document_d_exports.TextFormatting | undefined; /** Drop every memoized cascade result. */
|
|
55
|
+
invalidate: () => void; /** Inspect cache effectiveness (hits, misses, current size). */
|
|
56
|
+
stats: () => StyleEngineCacheStats;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Build a {@link StyleEngine} from parsed style definitions.
|
|
60
|
+
*
|
|
61
|
+
* @param styleDefinitions - The parsed `styles.xml` package, or `undefined`
|
|
62
|
+
* for documents without a styles part.
|
|
63
|
+
* @param options - Engine-level toggles, see {@link StyleEngineOptions}.
|
|
64
|
+
*/
|
|
65
|
+
declare function createStyleEngine(styleDefinitions: document_d_exports.StyleDefinitions | undefined, options?: StyleEngineOptions): StyleEngine;
|
|
66
|
+
//#endregion
|
|
67
|
+
export { StyleEngine, StyleEngineCacheStats, StyleEngineOptions, createStyleEngine };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { createStyleResolver } from "../prosemirror/styles/styleResolver.js";
|
|
2
|
+
//#region src/style-engine/styleEngine.ts
|
|
3
|
+
/**
|
|
4
|
+
* Sentinel key used for null / undefined styleId queries so that
|
|
5
|
+
* {@link Map} lookups distinguish "cached an undefined result" from
|
|
6
|
+
* "never queried" without storing JS `undefined` as a key.
|
|
7
|
+
*/
|
|
8
|
+
const DEFAULT_KEY = "\0__default__";
|
|
9
|
+
function cacheKey(styleId) {
|
|
10
|
+
if (styleId === void 0 || styleId === null || styleId === "") return DEFAULT_KEY;
|
|
11
|
+
return styleId;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Build a {@link StyleEngine} from parsed style definitions.
|
|
15
|
+
*
|
|
16
|
+
* @param styleDefinitions - The parsed `styles.xml` package, or `undefined`
|
|
17
|
+
* for documents without a styles part.
|
|
18
|
+
* @param options - Engine-level toggles, see {@link StyleEngineOptions}.
|
|
19
|
+
*/
|
|
20
|
+
function createStyleEngine(styleDefinitions, options) {
|
|
21
|
+
const resolver = createStyleResolver(styleDefinitions);
|
|
22
|
+
const cacheEnabled = options?.cache ?? true;
|
|
23
|
+
const paragraphCache = /* @__PURE__ */ new Map();
|
|
24
|
+
const runCache = /* @__PURE__ */ new Map();
|
|
25
|
+
const ownPropsCache = /* @__PURE__ */ new Map();
|
|
26
|
+
let hits = 0;
|
|
27
|
+
let misses = 0;
|
|
28
|
+
const memoize = (cache, key, compute) => {
|
|
29
|
+
if (!cacheEnabled) {
|
|
30
|
+
misses += 1;
|
|
31
|
+
return compute();
|
|
32
|
+
}
|
|
33
|
+
const cached = cache.get(key);
|
|
34
|
+
if (cached !== void 0) {
|
|
35
|
+
hits += 1;
|
|
36
|
+
return cached.value;
|
|
37
|
+
}
|
|
38
|
+
misses += 1;
|
|
39
|
+
const value = compute();
|
|
40
|
+
cache.set(key, { value });
|
|
41
|
+
return value;
|
|
42
|
+
};
|
|
43
|
+
return {
|
|
44
|
+
getStyle: (styleId) => resolver.getStyle(styleId),
|
|
45
|
+
hasStyle: (styleId) => resolver.hasStyle(styleId),
|
|
46
|
+
getDocDefaults: () => resolver.getDocDefaults(),
|
|
47
|
+
getDefaultParagraphStyle: () => resolver.getDefaultParagraphStyle(),
|
|
48
|
+
getDefaultCharacterStyle: () => resolver.getDefaultCharacterStyle(),
|
|
49
|
+
getDefaultTableStyle: () => resolver.getDefaultTableStyle(),
|
|
50
|
+
getParagraphStyles: () => resolver.getParagraphStyles(),
|
|
51
|
+
getTableStyles: () => resolver.getTableStyles(),
|
|
52
|
+
resolveParagraphStyle: (styleId) => memoize(paragraphCache, cacheKey(styleId), () => resolver.resolveParagraphStyle(styleId)),
|
|
53
|
+
resolveRunStyle: (styleId) => memoize(runCache, cacheKey(styleId), () => resolver.resolveRunStyle(styleId)),
|
|
54
|
+
getRunStyleOwnProperties: (styleId) => memoize(ownPropsCache, cacheKey(styleId), () => resolver.getRunStyleOwnProperties(styleId)),
|
|
55
|
+
invalidate: () => {
|
|
56
|
+
paragraphCache.clear();
|
|
57
|
+
runCache.clear();
|
|
58
|
+
ownPropsCache.clear();
|
|
59
|
+
hits = 0;
|
|
60
|
+
misses = 0;
|
|
61
|
+
},
|
|
62
|
+
stats: () => ({
|
|
63
|
+
hits,
|
|
64
|
+
misses,
|
|
65
|
+
size: paragraphCache.size + runCache.size + ownPropsCache.size
|
|
66
|
+
})
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
//#endregion
|
|
70
|
+
export { createStyleEngine };
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
//#region src/types/block-id.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Single source of truth for folio block ids.
|
|
4
|
+
*
|
|
5
|
+
* Both the in-browser editor snapshot (`createFolioAIEditSnapshot`)
|
|
6
|
+
* and the server-side DOCX extractor (`apps/api/.../docx-blocks.ts`)
|
|
7
|
+
* import {@link deriveBlockId} so a citation written by the server
|
|
8
|
+
* resolves in the editor without a separate mapping table. Any other
|
|
9
|
+
* way of minting an id — `b-${n}`, `${idx}`, hand-rolled prefixes —
|
|
10
|
+
* is by definition unable to produce a {@link FolioBlockId}: the
|
|
11
|
+
* branded type makes the divergence a compile-time error rather
|
|
12
|
+
* than a silent "scrollToBlock retries 20 times and gives up".
|
|
13
|
+
*
|
|
14
|
+
* Two id shapes are allowed:
|
|
15
|
+
* - Word's `w14:paraId` (or any non-empty allocator-generated id),
|
|
16
|
+
* surfaced verbatim when the source paragraph carries one.
|
|
17
|
+
* - A zero-padded `seq-NNNN` fallback derived from document order,
|
|
18
|
+
* used when the paragraph has no paraId or the paraId collides
|
|
19
|
+
* with one already taken in the same derivation pass.
|
|
20
|
+
*/
|
|
21
|
+
type FolioBlockId = string & {
|
|
22
|
+
readonly __brand: "folio.blockId";
|
|
23
|
+
};
|
|
24
|
+
type DeriveBlockIdInput = {
|
|
25
|
+
/**
|
|
26
|
+
* Source paragraph's `w14:paraId` (or any equivalent stable id),
|
|
27
|
+
* or `null` when the paragraph has none.
|
|
28
|
+
*/
|
|
29
|
+
paraId: string | null; /** 1-based document order for the paragraph being derived. */
|
|
30
|
+
index: number;
|
|
31
|
+
/**
|
|
32
|
+
* Ids already minted in the same derivation pass. Used to bump
|
|
33
|
+
* the sequential fallback past any collisions (with the source
|
|
34
|
+
* paraId set OR with previous fallbacks).
|
|
35
|
+
*/
|
|
36
|
+
taken: ReadonlySet<string>;
|
|
37
|
+
};
|
|
38
|
+
declare const deriveBlockId: ({
|
|
39
|
+
paraId,
|
|
40
|
+
index,
|
|
41
|
+
taken
|
|
42
|
+
}: DeriveBlockIdInput) => FolioBlockId;
|
|
43
|
+
declare const isSequentialFolioBlockId: (id: string) => boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Extract the paraId an id was derived from, if any. Returns `null`
|
|
46
|
+
* for sequential fallbacks. Accepts plain `string` so consumers that
|
|
47
|
+
* have a raw id (snapshot anchors, operation blockIds) can call it
|
|
48
|
+
* without an upfront brand check.
|
|
49
|
+
*/
|
|
50
|
+
declare const getFolioParaIdFromBlockId: (id: string) => string | null;
|
|
51
|
+
/**
|
|
52
|
+
* The 1-based document position encoded in a sequential fallback id
|
|
53
|
+
* (`seq-0011` -> 11), or `null` for paraId-backed ids. The number is
|
|
54
|
+
* the block's position in the same non-empty-block walk both the
|
|
55
|
+
* server DOCX extractor and `createFolioAIEditSnapshot` use, so it
|
|
56
|
+
* indexes a snapshot's ordered `blocks` array directly.
|
|
57
|
+
*/
|
|
58
|
+
declare const getSequentialFolioBlockIdIndex: (id: string) => number | null;
|
|
59
|
+
/**
|
|
60
|
+
* Runtime refinement for ids coming back from the DB / API. Accepts
|
|
61
|
+
* the same two shapes {@link deriveBlockId} produces and nothing
|
|
62
|
+
* else — so legacy `b-NNNN` rows stop counting as valid here.
|
|
63
|
+
*/
|
|
64
|
+
declare const isFolioBlockId: (value: unknown) => value is FolioBlockId;
|
|
65
|
+
//#endregion
|
|
66
|
+
export { DeriveBlockIdInput, FolioBlockId, deriveBlockId, getFolioParaIdFromBlockId, getSequentialFolioBlockIdIndex, isFolioBlockId, isSequentialFolioBlockId };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
//#region src/types/block-id.ts
|
|
2
|
+
/**
|
|
3
|
+
* Single source of truth for folio block ids.
|
|
4
|
+
*
|
|
5
|
+
* Both the in-browser editor snapshot (`createFolioAIEditSnapshot`)
|
|
6
|
+
* and the server-side DOCX extractor (`apps/api/.../docx-blocks.ts`)
|
|
7
|
+
* import {@link deriveBlockId} so a citation written by the server
|
|
8
|
+
* resolves in the editor without a separate mapping table. Any other
|
|
9
|
+
* way of minting an id — `b-${n}`, `${idx}`, hand-rolled prefixes —
|
|
10
|
+
* is by definition unable to produce a {@link FolioBlockId}: the
|
|
11
|
+
* branded type makes the divergence a compile-time error rather
|
|
12
|
+
* than a silent "scrollToBlock retries 20 times and gives up".
|
|
13
|
+
*
|
|
14
|
+
* Two id shapes are allowed:
|
|
15
|
+
* - Word's `w14:paraId` (or any non-empty allocator-generated id),
|
|
16
|
+
* surfaced verbatim when the source paragraph carries one.
|
|
17
|
+
* - A zero-padded `seq-NNNN` fallback derived from document order,
|
|
18
|
+
* used when the paragraph has no paraId or the paraId collides
|
|
19
|
+
* with one already taken in the same derivation pass.
|
|
20
|
+
*/
|
|
21
|
+
const SEQUENTIAL_BLOCK_ID_PREFIX = "seq-";
|
|
22
|
+
const SEQUENTIAL_BLOCK_ID_PADDING = 4;
|
|
23
|
+
const SEQUENTIAL_BLOCK_ID_PATTERN = /^seq-\d{4,}$/u;
|
|
24
|
+
const formatSequentialBlockId = (index) => `${SEQUENTIAL_BLOCK_ID_PREFIX}${String(index).padStart(SEQUENTIAL_BLOCK_ID_PADDING, "0")}`;
|
|
25
|
+
/**
|
|
26
|
+
* The opaque `FolioBlockId` brand has no constructor; an unchecked
|
|
27
|
+
* cast is the runtime no-op that mints one. Centralising the cast
|
|
28
|
+
* here means every other site can keep `typescript/no-unsafe-type-assertion`
|
|
29
|
+
* on.
|
|
30
|
+
*/
|
|
31
|
+
const brand = (value) => value;
|
|
32
|
+
const deriveBlockId = ({ paraId, index, taken }) => {
|
|
33
|
+
if (paraId !== null && paraId.length > 0 && !taken.has(paraId)) return brand(paraId);
|
|
34
|
+
let candidate = index;
|
|
35
|
+
let formatted = formatSequentialBlockId(candidate);
|
|
36
|
+
while (taken.has(formatted)) {
|
|
37
|
+
candidate += 1;
|
|
38
|
+
formatted = formatSequentialBlockId(candidate);
|
|
39
|
+
}
|
|
40
|
+
return brand(formatted);
|
|
41
|
+
};
|
|
42
|
+
const isSequentialFolioBlockId = (id) => SEQUENTIAL_BLOCK_ID_PATTERN.test(id);
|
|
43
|
+
/**
|
|
44
|
+
* Extract the paraId an id was derived from, if any. Returns `null`
|
|
45
|
+
* for sequential fallbacks. Accepts plain `string` so consumers that
|
|
46
|
+
* have a raw id (snapshot anchors, operation blockIds) can call it
|
|
47
|
+
* without an upfront brand check.
|
|
48
|
+
*/
|
|
49
|
+
const getFolioParaIdFromBlockId = (id) => isSequentialFolioBlockId(id) ? null : id;
|
|
50
|
+
/**
|
|
51
|
+
* The 1-based document position encoded in a sequential fallback id
|
|
52
|
+
* (`seq-0011` -> 11), or `null` for paraId-backed ids. The number is
|
|
53
|
+
* the block's position in the same non-empty-block walk both the
|
|
54
|
+
* server DOCX extractor and `createFolioAIEditSnapshot` use, so it
|
|
55
|
+
* indexes a snapshot's ordered `blocks` array directly.
|
|
56
|
+
*/
|
|
57
|
+
const getSequentialFolioBlockIdIndex = (id) => {
|
|
58
|
+
if (!SEQUENTIAL_BLOCK_ID_PATTERN.test(id)) return null;
|
|
59
|
+
const index = Number(id.slice(4));
|
|
60
|
+
return Number.isInteger(index) && index > 0 ? index : null;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Runtime refinement for ids coming back from the DB / API. Accepts
|
|
64
|
+
* the same two shapes {@link deriveBlockId} produces and nothing
|
|
65
|
+
* else — so legacy `b-NNNN` rows stop counting as valid here.
|
|
66
|
+
*/
|
|
67
|
+
const isFolioBlockId = (value) => {
|
|
68
|
+
if (typeof value !== "string" || value.length === 0) return false;
|
|
69
|
+
if (value.startsWith(SEQUENTIAL_BLOCK_ID_PREFIX)) return SEQUENTIAL_BLOCK_ID_PATTERN.test(value);
|
|
70
|
+
return true;
|
|
71
|
+
};
|
|
72
|
+
//#endregion
|
|
73
|
+
export { deriveBlockId, getFolioParaIdFromBlockId, getSequentialFolioBlockIdIndex, isFolioBlockId, isSequentialFolioBlockId };
|
|
File without changes
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { BlockContent, BlockSdt, BookmarkEnd, BookmarkStart, BreakContent, Column, Comment, CommentRangeEnd, CommentRangeStart, CommentReference, ComplexField, Deletion, DocumentBody, DrawingContent, Endnote, EndnotePosition, EndnoteProperties, Field, FieldCharContent, FieldType, FooterReference, Footnote, FootnotePosition, FootnoteProperties, HeaderFooter, HeaderFooterType, HeaderReference, Hyperlink, Image, ImageCrop, ImagePadding, ImagePosition, ImageSize, ImageTransform, ImageWrap, InlineSdt, Insertion, InstrTextContent, LineNumberRestart, MathEquation, MoveFrom, MoveFromRangeEnd, MoveFromRangeStart, MoveTo, MoveToRangeEnd, MoveToRangeStart, NoBreakHyphenContent, NoteNumberRestart, NoteReferenceContent, PageOrientation, Paragraph, ParagraphContent, ParagraphPropertyChange, PropertyChangeInfo, Run, RunContent, RunPropertyChange, SdtProperties, SdtType, Section, SectionProperties, SectionStart, Shape, ShapeContent, ShapeFill, ShapeOutline, ShapeTextBody, ShapeType, SimpleField, SoftHyphenContent, SymbolContent, TabContent, Table, TableCell, TableCellPropertyChange, TableRow, TableRowPropertyChange, TableStructuralChangeInfo, TextBox, TextContent, TrackedChangeInfo, TrackedRunChange, VerticalAlign } from "@stll/docx-core/model";
|
|
2
|
+
export type { BlockContent, BlockSdt, BookmarkEnd, BookmarkStart, BreakContent, Column, Comment, CommentRangeEnd, CommentRangeStart, CommentReference, ComplexField, Deletion, DocumentBody, DrawingContent, Endnote, EndnotePosition, EndnoteProperties, Field, FieldCharContent, FieldType, FooterReference, Footnote, FootnotePosition, FootnoteProperties, HeaderFooter, HeaderFooterType, HeaderReference, Hyperlink, Image, ImageCrop, ImagePadding, ImagePosition, ImageSize, ImageTransform, ImageWrap, InlineSdt, Insertion, InstrTextContent, LineNumberRestart, MathEquation, MoveFrom, MoveFromRangeEnd, MoveFromRangeStart, MoveTo, MoveToRangeEnd, MoveToRangeStart, NoBreakHyphenContent, NoteNumberRestart, NoteReferenceContent, PageOrientation, Paragraph, ParagraphContent, ParagraphPropertyChange, PropertyChangeInfo, Run, RunContent, RunPropertyChange, SdtProperties, SdtType, Section, SectionProperties, SectionStart, Shape, ShapeContent, ShapeFill, ShapeOutline, ShapeTextBody, ShapeType, SimpleField, SoftHyphenContent, SymbolContent, TabContent, Table, TableCell, TableCellPropertyChange, TableRow, TableRowPropertyChange, TableStructuralChangeInfo, TextBox, TextContent, TrackedChangeInfo, TrackedRunChange, VerticalAlign };
|
|
File without changes
|
|
File without changes
|