@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,229 @@
|
|
|
1
|
+
import { pushWarning } from "./internals.js";
|
|
2
|
+
import { escapeTableCell } from "./escape.js";
|
|
3
|
+
import { registerImage } from "./images.js";
|
|
4
|
+
import { renderParagraph } from "./renderParagraph.js";
|
|
5
|
+
//#region src/markdown/renderTable.ts
|
|
6
|
+
/** Render a `Table` as markdown. Picks GFM vs HTML based on cell features. */
|
|
7
|
+
function renderTable(ctx, pkg, table) {
|
|
8
|
+
const { rows } = table;
|
|
9
|
+
if (!rows.length) return "";
|
|
10
|
+
if (needsHtmlFallback(rows)) return renderHtmlTable(ctx, pkg, rows, true);
|
|
11
|
+
return renderGfmTable(ctx, pkg, rows, true);
|
|
12
|
+
}
|
|
13
|
+
function needsHtmlFallback(rows) {
|
|
14
|
+
for (const row of rows) for (const cell of row.cells) {
|
|
15
|
+
if ((cell.formatting?.gridSpan ?? 1) > 1) return true;
|
|
16
|
+
if (cell.formatting?.vMerge) return true;
|
|
17
|
+
if (cell.content.some((b) => b.type === "table")) return true;
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
function renderGfmTable(ctx, pkg, rows, firstRowIsHeader) {
|
|
22
|
+
const cellTexts = rows.map((row) => renderGfmRow(ctx, pkg, row));
|
|
23
|
+
let maxCols = 0;
|
|
24
|
+
for (const cells of cellTexts) if (cells.length > maxCols) maxCols = cells.length;
|
|
25
|
+
if (!maxCols) return "";
|
|
26
|
+
const padded = cellTexts.map((row) => {
|
|
27
|
+
const filled = row.slice();
|
|
28
|
+
while (filled.length < maxCols) filled.push("");
|
|
29
|
+
return filled;
|
|
30
|
+
});
|
|
31
|
+
const separator = `| ${Array.from({ length: maxCols }, () => "---").join(" | ")} |`;
|
|
32
|
+
const lines = [];
|
|
33
|
+
if (firstRowIsHeader) {
|
|
34
|
+
const [header, ...body] = padded;
|
|
35
|
+
if (header) lines.push(toRowLine(header));
|
|
36
|
+
lines.push(separator);
|
|
37
|
+
for (const row of body) lines.push(toRowLine(row));
|
|
38
|
+
} else {
|
|
39
|
+
lines.push(`| ${Array.from({ length: maxCols }, () => "").join(" | ")} |`);
|
|
40
|
+
lines.push(separator);
|
|
41
|
+
for (const row of padded) lines.push(toRowLine(row));
|
|
42
|
+
}
|
|
43
|
+
return lines.join("\n");
|
|
44
|
+
}
|
|
45
|
+
function toRowLine(cells) {
|
|
46
|
+
return `| ${cells.join(" | ")} |`;
|
|
47
|
+
}
|
|
48
|
+
function renderGfmRow(ctx, pkg, row) {
|
|
49
|
+
const out = [];
|
|
50
|
+
for (const cell of row.cells) out.push(renderGfmCell(ctx, pkg, cell));
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
function renderGfmCell(ctx, pkg, cell) {
|
|
54
|
+
const blocks = [];
|
|
55
|
+
for (const item of cell.content) if (item.type === "paragraph") {
|
|
56
|
+
const md = renderParagraph(ctx, pkg, item);
|
|
57
|
+
if (md.trim()) blocks.push(md);
|
|
58
|
+
}
|
|
59
|
+
return escapeTableCell(blocks.join("\n"));
|
|
60
|
+
}
|
|
61
|
+
function renderHtmlTable(ctx, pkg, rows, firstRowIsHeader) {
|
|
62
|
+
const out = ["<table>"];
|
|
63
|
+
for (const [rowIdx, row] of rows.entries()) {
|
|
64
|
+
const tag = firstRowIsHeader && rowIdx === 0 ? "th" : "td";
|
|
65
|
+
out.push(" <tr>");
|
|
66
|
+
let gridCol = 0;
|
|
67
|
+
for (const cell of row.cells) {
|
|
68
|
+
const colspan = cell.formatting?.gridSpan ?? 1;
|
|
69
|
+
if (cell.formatting?.vMerge !== "continue") {
|
|
70
|
+
const rowspan = countRowSpan(rows, rowIdx, gridCol, colspan);
|
|
71
|
+
const attrs = [];
|
|
72
|
+
if (colspan > 1) attrs.push(`colspan="${colspan}"`);
|
|
73
|
+
if (rowspan > 1) attrs.push(`rowspan="${rowspan}"`);
|
|
74
|
+
const attrStr = attrs.length ? ` ${attrs.join(" ")}` : "";
|
|
75
|
+
out.push(` <${tag}${attrStr}>${renderHtmlCell(ctx, pkg, cell)}</${tag}>`);
|
|
76
|
+
}
|
|
77
|
+
gridCol += colspan;
|
|
78
|
+
}
|
|
79
|
+
out.push(" </tr>");
|
|
80
|
+
}
|
|
81
|
+
out.push("</table>");
|
|
82
|
+
return out.join("\n");
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Count how many rows beyond `rowIdx` have a `vMerge: "continue"` cell aligned
|
|
86
|
+
* to the same grid column as the anchor. Cells are indexed by array position,
|
|
87
|
+
* but vertical merges align on the visual grid column, so a horizontal merge
|
|
88
|
+
* (`gridSpan > 1`) above shifts array indices — we walk by cumulative gridSpan.
|
|
89
|
+
*/
|
|
90
|
+
function countRowSpan(rows, rowIdx, gridCol, colspan) {
|
|
91
|
+
let span = 1;
|
|
92
|
+
for (let r = rowIdx + 1; r < rows.length; r++) {
|
|
93
|
+
const row = rows[r];
|
|
94
|
+
if (!row) break;
|
|
95
|
+
const target = cellAtGridColumn(row, gridCol);
|
|
96
|
+
if (target && target.formatting?.vMerge === "continue" && (target.formatting.gridSpan ?? 1) === colspan) span += 1;
|
|
97
|
+
else break;
|
|
98
|
+
}
|
|
99
|
+
return span;
|
|
100
|
+
}
|
|
101
|
+
function cellAtGridColumn(row, gridCol) {
|
|
102
|
+
let col = 0;
|
|
103
|
+
for (const cell of row.cells) {
|
|
104
|
+
if (col === gridCol) return cell;
|
|
105
|
+
col += cell.formatting?.gridSpan ?? 1;
|
|
106
|
+
if (col > gridCol) return;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
function renderHtmlCell(ctx, pkg, cell) {
|
|
110
|
+
const parts = [];
|
|
111
|
+
for (const item of cell.content) if (item.type === "paragraph") {
|
|
112
|
+
const inner = renderHtmlInline(ctx, pkg, item.content, item.paraId);
|
|
113
|
+
if (inner) parts.push(inner);
|
|
114
|
+
} else {
|
|
115
|
+
const nested = renderHtmlTable(ctx, pkg, item.rows, true);
|
|
116
|
+
if (nested) parts.push(nested);
|
|
117
|
+
}
|
|
118
|
+
return parts.join("<br>");
|
|
119
|
+
}
|
|
120
|
+
function escapeHtml(text) {
|
|
121
|
+
return text.replace(/&/gu, "&").replace(/</gu, "<").replace(/>/gu, ">").replace(/"/gu, """);
|
|
122
|
+
}
|
|
123
|
+
function renderHtmlInline(ctx, pkg, content, paraId) {
|
|
124
|
+
let out = "";
|
|
125
|
+
for (const item of content) switch (item.type) {
|
|
126
|
+
case "run":
|
|
127
|
+
out += renderHtmlRun(ctx, pkg, item, paraId);
|
|
128
|
+
break;
|
|
129
|
+
case "hyperlink":
|
|
130
|
+
out += renderHtmlHyperlink(ctx, pkg, item, paraId);
|
|
131
|
+
break;
|
|
132
|
+
case "insertion":
|
|
133
|
+
case "moveTo": {
|
|
134
|
+
const inner = renderHtmlChildren(ctx, pkg, item.content, paraId);
|
|
135
|
+
out += ctx.opts.trackedChanges === "annotate" ? `<ins>${inner}</ins>` : inner;
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
case "deletion":
|
|
139
|
+
case "moveFrom":
|
|
140
|
+
if (ctx.opts.trackedChanges === "annotate") out += `<del>${renderHtmlChildren(ctx, pkg, item.content, paraId)}</del>`;
|
|
141
|
+
break;
|
|
142
|
+
case "simpleField":
|
|
143
|
+
case "complexField": {
|
|
144
|
+
const runs = item.type === "simpleField" ? item.content : item.fieldResult;
|
|
145
|
+
out += renderHtmlChildren(ctx, pkg, runs, paraId);
|
|
146
|
+
break;
|
|
147
|
+
}
|
|
148
|
+
case "inlineSdt":
|
|
149
|
+
out += renderHtmlInline(ctx, pkg, item.content, paraId);
|
|
150
|
+
break;
|
|
151
|
+
case "mathEquation":
|
|
152
|
+
if (item.plainText) out += escapeHtml(item.plainText);
|
|
153
|
+
break;
|
|
154
|
+
default: break;
|
|
155
|
+
}
|
|
156
|
+
return out;
|
|
157
|
+
}
|
|
158
|
+
function renderHtmlChildren(ctx, pkg, children, paraId) {
|
|
159
|
+
return children.map((c) => c.type === "run" ? renderHtmlRun(ctx, pkg, c, paraId) : renderHtmlHyperlink(ctx, pkg, c, paraId)).join("");
|
|
160
|
+
}
|
|
161
|
+
function renderHtmlRun(ctx, pkg, run, paraId) {
|
|
162
|
+
if (run.formatting?.hidden) return "";
|
|
163
|
+
let text = "";
|
|
164
|
+
for (const item of run.content) switch (item.type) {
|
|
165
|
+
case "text":
|
|
166
|
+
text += escapeHtml(item.text);
|
|
167
|
+
break;
|
|
168
|
+
case "tab":
|
|
169
|
+
text += " ";
|
|
170
|
+
break;
|
|
171
|
+
case "break":
|
|
172
|
+
text += "<br>";
|
|
173
|
+
break;
|
|
174
|
+
case "symbol":
|
|
175
|
+
text += escapeHtml(item.char);
|
|
176
|
+
break;
|
|
177
|
+
case "noBreakHyphen":
|
|
178
|
+
text += "‑";
|
|
179
|
+
break;
|
|
180
|
+
case "softHyphen": break;
|
|
181
|
+
case "drawing": {
|
|
182
|
+
const ref = pkg?.relationships?.get(item.image.rId);
|
|
183
|
+
const media = ref ? pkg?.media?.get(ref.target) : void 0;
|
|
184
|
+
if (media) {
|
|
185
|
+
const reg = registerImage(ctx, media, item.image, paraId);
|
|
186
|
+
const alt = reg.alt ? escapeHtml(reg.alt) : "";
|
|
187
|
+
text += `<img src="${escapeHtml(reg.virtualPath)}" alt="${alt}">`;
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
if (item.image.src) {
|
|
191
|
+
const alt = escapeHtml(item.image.alt ?? item.image.title ?? item.image.filename ?? "");
|
|
192
|
+
text += `<img src="${escapeHtml(item.image.src)}" alt="${alt}">`;
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
pushWarning(ctx, `image rId=${item.image.rId} not resolvable`);
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
case "footnoteRef":
|
|
199
|
+
case "endnoteRef": {
|
|
200
|
+
if (ctx.opts.footnotes === "strip") break;
|
|
201
|
+
const markerNumber = ctx.footnoteRefs.length + 1;
|
|
202
|
+
ctx.footnoteRefs.push({
|
|
203
|
+
refId: item.id,
|
|
204
|
+
markerNumber,
|
|
205
|
+
kind: item.type === "endnoteRef" ? "endnote" : "footnote"
|
|
206
|
+
});
|
|
207
|
+
text += `<sup>[${markerNumber}]</sup>`;
|
|
208
|
+
break;
|
|
209
|
+
}
|
|
210
|
+
default: break;
|
|
211
|
+
}
|
|
212
|
+
if (!text) return "";
|
|
213
|
+
const f = run.formatting;
|
|
214
|
+
if (!f) return text;
|
|
215
|
+
if (f.bold) text = `<strong>${text}</strong>`;
|
|
216
|
+
if (f.italic) text = `<em>${text}</em>`;
|
|
217
|
+
if (f.strike) text = `<s>${text}</s>`;
|
|
218
|
+
if (f.underline?.style && f.underline.style !== "none") text = `<u>${text}</u>`;
|
|
219
|
+
return text;
|
|
220
|
+
}
|
|
221
|
+
function renderHtmlHyperlink(ctx, pkg, link, paraId) {
|
|
222
|
+
const inner = link.children.filter((c) => c.type === "run").map((r) => renderHtmlRun(ctx, pkg, r, paraId)).join("");
|
|
223
|
+
if (!inner) return "";
|
|
224
|
+
const href = link.href ?? (link.anchor ? `#${link.anchor}` : "");
|
|
225
|
+
if (!href) return inner;
|
|
226
|
+
return `<a href="${escapeHtml(href)}">${inner}</a>`;
|
|
227
|
+
}
|
|
228
|
+
//#endregion
|
|
229
|
+
export { renderTable };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { RenderContext } from "./types.js";
|
|
3
|
+
|
|
4
|
+
//#region src/markdown/trailers.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Append footnote definitions, the hyperlink reference list (for
|
|
7
|
+
* `hyperlinks: "reference"`), and the comments sidecar block (for
|
|
8
|
+
* `comments: "sidecar"`). Each section is emitted only when its corresponding
|
|
9
|
+
* refs accumulator has entries.
|
|
10
|
+
*/
|
|
11
|
+
declare function appendTrailers(ctx: RenderContext, doc: document_d_exports.Document, body: string): string;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { appendTrailers };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { escapeLinkUrl } from "./escape.js";
|
|
2
|
+
import { renderBlocks } from "./renderBlock.js";
|
|
3
|
+
//#region src/markdown/trailers.ts
|
|
4
|
+
/**
|
|
5
|
+
* Append footnote definitions, the hyperlink reference list (for
|
|
6
|
+
* `hyperlinks: "reference"`), and the comments sidecar block (for
|
|
7
|
+
* `comments: "sidecar"`). Each section is emitted only when its corresponding
|
|
8
|
+
* refs accumulator has entries.
|
|
9
|
+
*/
|
|
10
|
+
function appendTrailers(ctx, doc, body) {
|
|
11
|
+
const sections = body.trim() ? [body] : [];
|
|
12
|
+
if (ctx.footnoteRefs.length > 0) {
|
|
13
|
+
const refs = ctx.footnoteRefs.map(({ refId, markerNumber, kind }) => {
|
|
14
|
+
const note = kind === "endnote" ? doc.package.endnotes?.find((n) => n.id === refId) : doc.package.footnotes?.find((f) => f.id === refId);
|
|
15
|
+
return `[^${markerNumber}]: ${note ? noteText(ctx, doc, note) : ""}`;
|
|
16
|
+
});
|
|
17
|
+
sections.push(refs.join("\n"));
|
|
18
|
+
}
|
|
19
|
+
if (ctx.opts.hyperlinks === "reference" && ctx.hyperlinkRefs.length > 0) sections.push(ctx.hyperlinkRefs.map(({ href, refNumber }) => `[${refNumber}]: ${escapeLinkUrl(href)}`).join("\n"));
|
|
20
|
+
if (ctx.opts.comments === "sidecar" && ctx.commentRefs.length > 0) {
|
|
21
|
+
const lines = ["## Comments"];
|
|
22
|
+
for (const { commentId, markerNumber } of ctx.commentRefs) {
|
|
23
|
+
const c = doc.package.document.comments?.find((cm) => cm.id === commentId);
|
|
24
|
+
const author = c?.author ? `${c.author}: ` : "";
|
|
25
|
+
const text = c ? commentText(c) : "";
|
|
26
|
+
lines.push(`[^c${markerNumber}]: ${author}${text}`);
|
|
27
|
+
}
|
|
28
|
+
sections.push(lines.join("\n"));
|
|
29
|
+
}
|
|
30
|
+
return sections.join("\n\n");
|
|
31
|
+
}
|
|
32
|
+
function noteText(ctx, doc, note) {
|
|
33
|
+
return renderBlocks(ctx, doc.package, note.content).replace(/\n+/gu, " ").trim();
|
|
34
|
+
}
|
|
35
|
+
function commentText(comment) {
|
|
36
|
+
return comment.content.map((p) => inlineText(p.content)).join(" ").trim();
|
|
37
|
+
}
|
|
38
|
+
function runText(run) {
|
|
39
|
+
return run.content.map((x) => x.type === "text" ? x.text : "").join("");
|
|
40
|
+
}
|
|
41
|
+
/** Flatten paragraph inline content to plain text, recursing through wrappers. */
|
|
42
|
+
function inlineText(content) {
|
|
43
|
+
let out = "";
|
|
44
|
+
for (const item of content) if (item.type === "run") out += runText(item);
|
|
45
|
+
else if (item.type === "hyperlink") {
|
|
46
|
+
for (const child of item.children) if (child.type === "run") out += runText(child);
|
|
47
|
+
} else if (item.type === "simpleField") out += inlineText(item.content);
|
|
48
|
+
else if (item.type === "complexField") out += inlineText(item.fieldResult);
|
|
49
|
+
else if (item.type === "insertion" || item.type === "deletion" || item.type === "moveFrom" || item.type === "moveTo") out += inlineText(item.content);
|
|
50
|
+
else if (item.type === "inlineSdt") out += inlineText(item.content);
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { appendTrailers };
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
//#region src/markdown/types.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Types for the DOCX-document → Markdown converter (ported from eigenpal
|
|
4
|
+
* /docx-editor PR #595). This is folio's v1 surface: the synchronous,
|
|
5
|
+
* continuous (non-paged) `toMarkdown(Document)` path. The paged + async +
|
|
6
|
+
* image-handler variants from upstream are not ported (skills bodies have no
|
|
7
|
+
* images today); they can be added later if needed.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Metadata describing a single image registration. Owned by the markdown
|
|
11
|
+
* module so its public surface is independent of the docx model's drawing
|
|
12
|
+
* types.
|
|
13
|
+
*/
|
|
14
|
+
type ImageMeta = {
|
|
15
|
+
/** `paraId` of the containing paragraph, when the source paragraph has one. */paraId?: string | undefined; /** 1-based ordinal in registration order. Unique per render call. */
|
|
16
|
+
index: number; /** Path inside the DOCX zip (e.g. `word/media/image1.png`). */
|
|
17
|
+
originalPath: string; /** MIME type (`image/png`, `image/jpeg`, …). */
|
|
18
|
+
mimeType: string; /** Alt text from the drawing, when present. */
|
|
19
|
+
alt?: string | undefined;
|
|
20
|
+
};
|
|
21
|
+
/** Full registration record for an image, keyed by `virtualPath`. */
|
|
22
|
+
type ImageRef = {
|
|
23
|
+
/** Raw bytes as exposed by the DOCX parser. */data: Uint8Array; /** Base64-encoded contents, without the `data:` prefix. */
|
|
24
|
+
base64: string; /** `data:<mime>;base64,<base64>` URL. */
|
|
25
|
+
dataUrl: string; /** The path that appears inside the markdown's `` reference. */
|
|
26
|
+
virtualPath: string;
|
|
27
|
+
} & ImageMeta;
|
|
28
|
+
/**
|
|
29
|
+
* Options for {@link toMarkdown}. The clean-markdown preset skills use is
|
|
30
|
+
* `{ annotations: "strip", trackedChanges: "clean", comments: "strip",
|
|
31
|
+
* hyperlinks: "inline", footnotes: "strip" }`.
|
|
32
|
+
*/
|
|
33
|
+
type MarkdownOptions = {
|
|
34
|
+
/**
|
|
35
|
+
* How to encode constructs markdown can't express natively (comments,
|
|
36
|
+
* tracked changes).
|
|
37
|
+
* - `"html"` (default): emit `<ins>`, `<del>`, `<comment>` tags.
|
|
38
|
+
* - `"pandoc"`: Pandoc-flavoured bracketed spans (`[text]{.ins}`).
|
|
39
|
+
* - `"strip"`: drop the wrapper, keep the visible text.
|
|
40
|
+
*/
|
|
41
|
+
annotations?: "html" | "pandoc" | "strip";
|
|
42
|
+
/**
|
|
43
|
+
* Word tracked changes (`w:ins`, `w:del`, `w:moveFrom`, `w:moveTo`).
|
|
44
|
+
* - `"annotate"` (default): preserve via the `annotations` wrapper.
|
|
45
|
+
* - `"clean"`: flatten — insertions become text, deletions vanish.
|
|
46
|
+
*/
|
|
47
|
+
trackedChanges?: "clean" | "annotate";
|
|
48
|
+
/**
|
|
49
|
+
* Word margin comments.
|
|
50
|
+
* - `"inline"` (default): wrap the commented text via `annotations`.
|
|
51
|
+
* - `"strip"`: ignore comments entirely.
|
|
52
|
+
* - `"sidecar"`: inline marker + a `## Comments` trailer section.
|
|
53
|
+
*/
|
|
54
|
+
comments?: "strip" | "inline" | "sidecar";
|
|
55
|
+
/**
|
|
56
|
+
* Hyperlink rendering.
|
|
57
|
+
* - `"inline"` (default): `[text](https://url)`.
|
|
58
|
+
* - `"reference"`: `[text][N]` + a reference list trailer.
|
|
59
|
+
*/
|
|
60
|
+
hyperlinks?: "inline" | "reference";
|
|
61
|
+
/**
|
|
62
|
+
* Footnote/endnote references. Folio addition over upstream #595 (which
|
|
63
|
+
* always emitted `[^N]` markers + a definitions trailer).
|
|
64
|
+
* - `"keep"` (default): `[^N]` markers + a definitions trailer.
|
|
65
|
+
* - `"strip"`: drop footnote markers and their definitions entirely.
|
|
66
|
+
*/
|
|
67
|
+
footnotes?: "keep" | "strip";
|
|
68
|
+
/**
|
|
69
|
+
* Receives the {@link ImageMeta} for each image and returns the virtual path
|
|
70
|
+
* placed inside the markdown's `` reference. Defaults to
|
|
71
|
+
* `./images/{paraId}-img{n}.{ext}` (or `./images/img{n}.{ext}`).
|
|
72
|
+
*/
|
|
73
|
+
imagePath?: (info: ImageMeta) => string;
|
|
74
|
+
};
|
|
75
|
+
/** Result of a render, when the caller needs images/warnings as well as text. */
|
|
76
|
+
type MarkdownResult = {
|
|
77
|
+
/** The full rendered markdown string. */markdown: string; /** Every image referenced in `markdown`, keyed by its virtual path. */
|
|
78
|
+
images: Map<string, ImageRef>; /** Non-fatal diagnostics; recurring messages are deduped. */
|
|
79
|
+
warnings: string[];
|
|
80
|
+
};
|
|
81
|
+
/** Resolved option values with defaults applied. Used internally. */
|
|
82
|
+
type ResolvedOptions = {
|
|
83
|
+
annotations: "html" | "pandoc" | "strip";
|
|
84
|
+
trackedChanges: "clean" | "annotate";
|
|
85
|
+
comments: "strip" | "inline" | "sidecar";
|
|
86
|
+
hyperlinks: "inline" | "reference";
|
|
87
|
+
footnotes: "keep" | "strip";
|
|
88
|
+
imagePath?: ((info: ImageMeta) => string) | undefined;
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Internal rendering context threaded through every render call. Aggregates
|
|
92
|
+
* side-channel output: image map, warnings, and footnote/comment/hyperlink
|
|
93
|
+
* reference lists. Exported only so the split renderer files share the shape.
|
|
94
|
+
*/
|
|
95
|
+
type RenderContext = {
|
|
96
|
+
opts: ResolvedOptions; /** Accumulated images keyed by virtual path. */
|
|
97
|
+
images: Map<string, ImageRef>; /** Same images keyed by source `MediaFile.path` for dedupe on re-reference. */
|
|
98
|
+
imagesByPath: Map<string, ImageRef>; /** Diagnostics accumulator. */
|
|
99
|
+
warnings: string[]; /** Footnote/endnote refs collected during this render, in document order. */
|
|
100
|
+
footnoteRefs: {
|
|
101
|
+
refId: number;
|
|
102
|
+
markerNumber: number;
|
|
103
|
+
kind: "footnote" | "endnote";
|
|
104
|
+
}[]; /** Comment refs collected during this render (sidecar mode only). */
|
|
105
|
+
commentRefs: {
|
|
106
|
+
commentId: number;
|
|
107
|
+
markerNumber: number;
|
|
108
|
+
}[]; /** Hyperlink refs collected during this render (reference mode only). */
|
|
109
|
+
hyperlinkRefs: {
|
|
110
|
+
href: string;
|
|
111
|
+
refNumber: number;
|
|
112
|
+
}[]; /** 1-based counter for default virtual paths. */
|
|
113
|
+
imageCounter: number; /** Live list counters per numId, for resolving `%N` marker templates. */
|
|
114
|
+
listCounters: Map<number, number[]>; /** `numId:level` pairs already seen, so a start override applies once. */
|
|
115
|
+
listSeenLevels: Set<string>;
|
|
116
|
+
};
|
|
117
|
+
//#endregion
|
|
118
|
+
export { ImageMeta, ImageRef, MarkdownOptions, MarkdownResult, RenderContext, ResolvedOptions };
|
|
File without changes
|
package/dist/model.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { document_d_exports } from "./types/document.js";
|
|
2
|
+
import { DeriveBlockIdInput, FolioBlockId, deriveBlockId, getFolioParaIdFromBlockId, getSequentialFolioBlockIdIndex, isFolioBlockId, isSequentialFolioBlockId } from "./types/block-id.js";
|
|
3
|
+
import { BORDER_STYLE_VALUES, CONDITIONAL_STYLE_TYPE_VALUES, EMPHASIS_MARK_VALUES, FIELD_TYPE_VALUES, FLOATING_TABLE_X_SPEC_VALUES, FLOATING_TABLE_Y_SPEC_VALUES, FONT_THEME_VALUES, FRAME_WRAP_VALUES, FRAME_X_ALIGN_VALUES, FRAME_Y_ALIGN_VALUES, HIGHLIGHT_COLOR_VALUES, IMAGE_HORIZONTAL_ALIGNMENT_VALUES, IMAGE_HORIZONTAL_RELATIVE_TO_VALUES, IMAGE_VERTICAL_ALIGNMENT_VALUES, IMAGE_VERTICAL_RELATIVE_TO_VALUES, IMAGE_WRAP_TEXT_VALUES, IMAGE_WRAP_TYPE_VALUES, LEVEL_SUFFIX_VALUES, LINE_SPACING_RULE_VALUES, NUMBER_FORMAT_VALUES, OUTLINE_STYLE_ATTR_VALUES, OUTLINE_STYLE_CSS_ALIASES, OUTLINE_STYLE_CSS_ALIAS_VALUES, OutlineStyleAttr, OutlineStyleCssAlias, PARAGRAPH_ALIGNMENT_VALUES, SDT_LOCK_VALUES, SDT_TYPE_VALUES, SHADING_PATTERN_VALUES, SHAPE_OUTLINE_STYLE_VALUES, SHAPE_TYPE_VALUES, STYLE_TYPE_VALUES, TABLE_CELL_TEXT_DIRECTION_VALUES, TABLE_CELL_VERTICAL_ALIGNMENT_VALUES, TABLE_JUSTIFICATION_VALUES, TABLE_ROW_HEIGHT_RULE_VALUES, TABLE_WIDTH_TYPE_VALUES, TAB_LEADER_VALUES, TAB_STOP_ALIGNMENT_VALUES, TEXT_EFFECT_VALUES, THEME_COLOR_SLOT_VALUES, UNDERLINE_STYLE_VALUES } from "./types/documentEnumValues.js";
|
|
4
|
+
import { types_d_exports } from "./layout-engine/types.js";
|
|
5
|
+
import { measureTypes_d_exports } from "./layout-engine/measure/measureTypes.js";
|
|
6
|
+
export * from "@stll/docx-core/model";
|
|
7
|
+
|
|
8
|
+
//#region src/model.d.ts
|
|
9
|
+
declare namespace model_d_exports {
|
|
10
|
+
export { BORDER_STYLE_VALUES, CONDITIONAL_STYLE_TYPE_VALUES, DeriveBlockIdInput, EMPHASIS_MARK_VALUES, FIELD_TYPE_VALUES, FLOATING_TABLE_X_SPEC_VALUES, FLOATING_TABLE_Y_SPEC_VALUES, FONT_THEME_VALUES, FRAME_WRAP_VALUES, FRAME_X_ALIGN_VALUES, FRAME_Y_ALIGN_VALUES, FolioBlockId, HIGHLIGHT_COLOR_VALUES, IMAGE_HORIZONTAL_ALIGNMENT_VALUES, IMAGE_HORIZONTAL_RELATIVE_TO_VALUES, IMAGE_VERTICAL_ALIGNMENT_VALUES, IMAGE_VERTICAL_RELATIVE_TO_VALUES, IMAGE_WRAP_TEXT_VALUES, IMAGE_WRAP_TYPE_VALUES, LEVEL_SUFFIX_VALUES, LINE_SPACING_RULE_VALUES, types_d_exports as Layout, measureTypes_d_exports as Measure, NUMBER_FORMAT_VALUES, OUTLINE_STYLE_ATTR_VALUES, OUTLINE_STYLE_CSS_ALIASES, OUTLINE_STYLE_CSS_ALIAS_VALUES, OutlineStyleAttr, OutlineStyleCssAlias, PARAGRAPH_ALIGNMENT_VALUES, SDT_LOCK_VALUES, SDT_TYPE_VALUES, SHADING_PATTERN_VALUES, SHAPE_OUTLINE_STYLE_VALUES, SHAPE_TYPE_VALUES, STYLE_TYPE_VALUES, TABLE_CELL_TEXT_DIRECTION_VALUES, TABLE_CELL_VERTICAL_ALIGNMENT_VALUES, TABLE_JUSTIFICATION_VALUES, TABLE_ROW_HEIGHT_RULE_VALUES, TABLE_WIDTH_TYPE_VALUES, TAB_LEADER_VALUES, TAB_STOP_ALIGNMENT_VALUES, TEXT_EFFECT_VALUES, THEME_COLOR_SLOT_VALUES, UNDERLINE_STYLE_VALUES, deriveBlockId, getFolioParaIdFromBlockId, getSequentialFolioBlockIdIndex, isFolioBlockId, isSequentialFolioBlockId };
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { BORDER_STYLE_VALUES, CONDITIONAL_STYLE_TYPE_VALUES, DeriveBlockIdInput, EMPHASIS_MARK_VALUES, FIELD_TYPE_VALUES, FLOATING_TABLE_X_SPEC_VALUES, FLOATING_TABLE_Y_SPEC_VALUES, FONT_THEME_VALUES, FRAME_WRAP_VALUES, FRAME_X_ALIGN_VALUES, FRAME_Y_ALIGN_VALUES, FolioBlockId, HIGHLIGHT_COLOR_VALUES, IMAGE_HORIZONTAL_ALIGNMENT_VALUES, IMAGE_HORIZONTAL_RELATIVE_TO_VALUES, IMAGE_VERTICAL_ALIGNMENT_VALUES, IMAGE_VERTICAL_RELATIVE_TO_VALUES, IMAGE_WRAP_TEXT_VALUES, IMAGE_WRAP_TYPE_VALUES, LEVEL_SUFFIX_VALUES, LINE_SPACING_RULE_VALUES, types_d_exports as Layout, type measureTypes_d_exports as Measure, NUMBER_FORMAT_VALUES, OUTLINE_STYLE_ATTR_VALUES, OUTLINE_STYLE_CSS_ALIASES, OUTLINE_STYLE_CSS_ALIAS_VALUES, OutlineStyleAttr, OutlineStyleCssAlias, PARAGRAPH_ALIGNMENT_VALUES, SDT_LOCK_VALUES, SDT_TYPE_VALUES, SHADING_PATTERN_VALUES, SHAPE_OUTLINE_STYLE_VALUES, SHAPE_TYPE_VALUES, STYLE_TYPE_VALUES, TABLE_CELL_TEXT_DIRECTION_VALUES, TABLE_CELL_VERTICAL_ALIGNMENT_VALUES, TABLE_JUSTIFICATION_VALUES, TABLE_ROW_HEIGHT_RULE_VALUES, TABLE_WIDTH_TYPE_VALUES, TAB_LEADER_VALUES, TAB_STOP_ALIGNMENT_VALUES, TEXT_EFFECT_VALUES, THEME_COLOR_SLOT_VALUES, UNDERLINE_STYLE_VALUES, deriveBlockId, getFolioParaIdFromBlockId, getSequentialFolioBlockIdIndex, isFolioBlockId, isSequentialFolioBlockId };
|
package/dist/model.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { BORDER_STYLE_VALUES, CONDITIONAL_STYLE_TYPE_VALUES, EMPHASIS_MARK_VALUES, FIELD_TYPE_VALUES, FLOATING_TABLE_X_SPEC_VALUES, FLOATING_TABLE_Y_SPEC_VALUES, FONT_THEME_VALUES, FRAME_WRAP_VALUES, FRAME_X_ALIGN_VALUES, FRAME_Y_ALIGN_VALUES, HIGHLIGHT_COLOR_VALUES, IMAGE_HORIZONTAL_ALIGNMENT_VALUES, IMAGE_HORIZONTAL_RELATIVE_TO_VALUES, IMAGE_VERTICAL_ALIGNMENT_VALUES, IMAGE_VERTICAL_RELATIVE_TO_VALUES, IMAGE_WRAP_TEXT_VALUES, IMAGE_WRAP_TYPE_VALUES, LEVEL_SUFFIX_VALUES, LINE_SPACING_RULE_VALUES, NUMBER_FORMAT_VALUES, OUTLINE_STYLE_ATTR_VALUES, OUTLINE_STYLE_CSS_ALIASES, OUTLINE_STYLE_CSS_ALIAS_VALUES, PARAGRAPH_ALIGNMENT_VALUES, SDT_LOCK_VALUES, SDT_TYPE_VALUES, SHADING_PATTERN_VALUES, SHAPE_OUTLINE_STYLE_VALUES, SHAPE_TYPE_VALUES, STYLE_TYPE_VALUES, TABLE_CELL_TEXT_DIRECTION_VALUES, TABLE_CELL_VERTICAL_ALIGNMENT_VALUES, TABLE_JUSTIFICATION_VALUES, TABLE_ROW_HEIGHT_RULE_VALUES, TABLE_WIDTH_TYPE_VALUES, TAB_LEADER_VALUES, TAB_STOP_ALIGNMENT_VALUES, TEXT_EFFECT_VALUES, THEME_COLOR_SLOT_VALUES, UNDERLINE_STYLE_VALUES } from "./types/documentEnumValues.js";
|
|
2
|
+
import { deriveBlockId, getFolioParaIdFromBlockId, getSequentialFolioBlockIdIndex, isFolioBlockId, isSequentialFolioBlockId } from "./types/block-id.js";
|
|
3
|
+
import { types_exports } from "./layout-engine/types.js";
|
|
4
|
+
export { BORDER_STYLE_VALUES, CONDITIONAL_STYLE_TYPE_VALUES, EMPHASIS_MARK_VALUES, FIELD_TYPE_VALUES, FLOATING_TABLE_X_SPEC_VALUES, FLOATING_TABLE_Y_SPEC_VALUES, FONT_THEME_VALUES, FRAME_WRAP_VALUES, FRAME_X_ALIGN_VALUES, FRAME_Y_ALIGN_VALUES, HIGHLIGHT_COLOR_VALUES, IMAGE_HORIZONTAL_ALIGNMENT_VALUES, IMAGE_HORIZONTAL_RELATIVE_TO_VALUES, IMAGE_VERTICAL_ALIGNMENT_VALUES, IMAGE_VERTICAL_RELATIVE_TO_VALUES, IMAGE_WRAP_TEXT_VALUES, IMAGE_WRAP_TYPE_VALUES, LEVEL_SUFFIX_VALUES, LINE_SPACING_RULE_VALUES, types_exports as Layout, NUMBER_FORMAT_VALUES, OUTLINE_STYLE_ATTR_VALUES, OUTLINE_STYLE_CSS_ALIASES, OUTLINE_STYLE_CSS_ALIAS_VALUES, PARAGRAPH_ALIGNMENT_VALUES, SDT_LOCK_VALUES, SDT_TYPE_VALUES, SHADING_PATTERN_VALUES, SHAPE_OUTLINE_STYLE_VALUES, SHAPE_TYPE_VALUES, STYLE_TYPE_VALUES, TABLE_CELL_TEXT_DIRECTION_VALUES, TABLE_CELL_VERTICAL_ALIGNMENT_VALUES, TABLE_JUSTIFICATION_VALUES, TABLE_ROW_HEIGHT_RULE_VALUES, TABLE_WIDTH_TYPE_VALUES, TAB_LEADER_VALUES, TAB_STOP_ALIGNMENT_VALUES, TEXT_EFFECT_VALUES, THEME_COLOR_SLOT_VALUES, UNDERLINE_STYLE_VALUES, deriveBlockId, getFolioParaIdFromBlockId, getSequentialFolioBlockIdIndex, isFolioBlockId, isSequentialFolioBlockId };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
//#region src/paged-layout/LayoutSelectionGate.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Layout Selection Gate
|
|
4
|
+
*
|
|
5
|
+
* Guards selection rendering until layout is up-to-date.
|
|
6
|
+
* Uses sequenced versioning to prevent stale cursor positions.
|
|
7
|
+
*/
|
|
8
|
+
type RenderCallback = () => void;
|
|
9
|
+
/**
|
|
10
|
+
* LayoutSelectionGate coordinates the timing between document edits and
|
|
11
|
+
* layout reflow so that selection overlays are only painted against
|
|
12
|
+
* current DOM geometry.
|
|
13
|
+
*
|
|
14
|
+
* Workflow:
|
|
15
|
+
* 1. Document changes → setStateSeq(++seq)
|
|
16
|
+
* 2. Layout starts → onLayoutStart()
|
|
17
|
+
* 3. Layout completes → onLayoutComplete(seq)
|
|
18
|
+
* 4. Selection update requested → requestRender()
|
|
19
|
+
* 5. If safe → callback is called
|
|
20
|
+
*/
|
|
21
|
+
declare class LayoutSelectionGate {
|
|
22
|
+
#private;
|
|
23
|
+
/**
|
|
24
|
+
* Set the document state sequence (call when document changes).
|
|
25
|
+
* This should be called on every ProseMirror transaction that changes the doc.
|
|
26
|
+
*/
|
|
27
|
+
setStateSeq(seq: number): void;
|
|
28
|
+
/**
|
|
29
|
+
* Increment document state sequence (convenience method).
|
|
30
|
+
* Returns the new sequence value.
|
|
31
|
+
*/
|
|
32
|
+
incrementStateSeq(): number;
|
|
33
|
+
/**
|
|
34
|
+
* Get current document state sequence.
|
|
35
|
+
*/
|
|
36
|
+
getStateSeq(): number;
|
|
37
|
+
/**
|
|
38
|
+
* Get current layout render sequence.
|
|
39
|
+
*/
|
|
40
|
+
getRenderSeq(): number;
|
|
41
|
+
/**
|
|
42
|
+
* Called when layout computation starts.
|
|
43
|
+
*/
|
|
44
|
+
onLayoutStart(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Called when layout computation and DOM painting completes.
|
|
47
|
+
* @param seq - The document state sequence that was just painted
|
|
48
|
+
*/
|
|
49
|
+
onLayoutComplete(seq: number): void;
|
|
50
|
+
/**
|
|
51
|
+
* Check if it's safe to render selection.
|
|
52
|
+
* Safe when: layout is not updating AND render sequence >= state sequence
|
|
53
|
+
*/
|
|
54
|
+
isSafeToRender(): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Request a selection render. Will be executed when safe.
|
|
57
|
+
* If already safe, executes immediately.
|
|
58
|
+
*/
|
|
59
|
+
requestRender(): void;
|
|
60
|
+
/**
|
|
61
|
+
* Register a callback to be called on render events.
|
|
62
|
+
*/
|
|
63
|
+
onRender(callback: RenderCallback): () => void;
|
|
64
|
+
/**
|
|
65
|
+
* Reset the gate state (useful for testing or document reload).
|
|
66
|
+
*/
|
|
67
|
+
reset(): void;
|
|
68
|
+
/**
|
|
69
|
+
* Get debug info about current state.
|
|
70
|
+
*/
|
|
71
|
+
getDebugInfo(): {
|
|
72
|
+
stateSeq: number;
|
|
73
|
+
renderSeq: number;
|
|
74
|
+
layoutUpdating: boolean;
|
|
75
|
+
hasPendingRender: boolean;
|
|
76
|
+
isSafe: boolean;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
export { LayoutSelectionGate };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
//#region src/paged-layout/LayoutSelectionGate.ts
|
|
2
|
+
/**
|
|
3
|
+
* LayoutSelectionGate coordinates the timing between document edits and
|
|
4
|
+
* layout reflow so that selection overlays are only painted against
|
|
5
|
+
* current DOM geometry.
|
|
6
|
+
*
|
|
7
|
+
* Workflow:
|
|
8
|
+
* 1. Document changes → setStateSeq(++seq)
|
|
9
|
+
* 2. Layout starts → onLayoutStart()
|
|
10
|
+
* 3. Layout completes → onLayoutComplete(seq)
|
|
11
|
+
* 4. Selection update requested → requestRender()
|
|
12
|
+
* 5. If safe → callback is called
|
|
13
|
+
*/
|
|
14
|
+
var LayoutSelectionGate = class {
|
|
15
|
+
/** Current document state sequence */
|
|
16
|
+
#stateSeq = 0;
|
|
17
|
+
/** Last painted layout sequence */
|
|
18
|
+
#renderSeq = 0;
|
|
19
|
+
/** Whether layout is currently being computed/painted */
|
|
20
|
+
#layoutUpdating = false;
|
|
21
|
+
/** Pending render callback */
|
|
22
|
+
#pendingRender = null;
|
|
23
|
+
/** Registered render callbacks */
|
|
24
|
+
#renderCallbacks = /* @__PURE__ */ new Set();
|
|
25
|
+
/**
|
|
26
|
+
* Set the document state sequence (call when document changes).
|
|
27
|
+
* This should be called on every ProseMirror transaction that changes the doc.
|
|
28
|
+
*/
|
|
29
|
+
setStateSeq(seq) {
|
|
30
|
+
this.#stateSeq = seq;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Increment document state sequence (convenience method).
|
|
34
|
+
* Returns the new sequence value.
|
|
35
|
+
*/
|
|
36
|
+
incrementStateSeq() {
|
|
37
|
+
return ++this.#stateSeq;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get current document state sequence.
|
|
41
|
+
*/
|
|
42
|
+
getStateSeq() {
|
|
43
|
+
return this.#stateSeq;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Get current layout render sequence.
|
|
47
|
+
*/
|
|
48
|
+
getRenderSeq() {
|
|
49
|
+
return this.#renderSeq;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Called when layout computation starts.
|
|
53
|
+
*/
|
|
54
|
+
onLayoutStart() {
|
|
55
|
+
this.#layoutUpdating = true;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Called when layout computation and DOM painting completes.
|
|
59
|
+
* @param seq - The document state sequence that was just painted
|
|
60
|
+
*/
|
|
61
|
+
onLayoutComplete(seq) {
|
|
62
|
+
this.#renderSeq = seq;
|
|
63
|
+
this.#layoutUpdating = false;
|
|
64
|
+
this.#tryRender();
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Check if it's safe to render selection.
|
|
68
|
+
* Safe when: layout is not updating AND render sequence >= state sequence
|
|
69
|
+
*/
|
|
70
|
+
isSafeToRender() {
|
|
71
|
+
return !this.#layoutUpdating && this.#renderSeq >= this.#stateSeq;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Request a selection render. Will be executed when safe.
|
|
75
|
+
* If already safe, executes immediately.
|
|
76
|
+
*/
|
|
77
|
+
requestRender() {
|
|
78
|
+
if (this.isSafeToRender()) this.#executeRender();
|
|
79
|
+
else this.#pendingRender = () => this.#executeRender();
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Register a callback to be called on render events.
|
|
83
|
+
*/
|
|
84
|
+
onRender(callback) {
|
|
85
|
+
this.#renderCallbacks.add(callback);
|
|
86
|
+
return () => {
|
|
87
|
+
this.#renderCallbacks.delete(callback);
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Try to execute pending render if safe.
|
|
92
|
+
*/
|
|
93
|
+
#tryRender() {
|
|
94
|
+
if (this.#pendingRender && this.isSafeToRender()) {
|
|
95
|
+
const render = this.#pendingRender;
|
|
96
|
+
this.#pendingRender = null;
|
|
97
|
+
render();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Execute all registered render callbacks.
|
|
102
|
+
*/
|
|
103
|
+
#executeRender() {
|
|
104
|
+
for (const callback of this.#renderCallbacks) try {
|
|
105
|
+
callback();
|
|
106
|
+
} catch {}
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Reset the gate state (useful for testing or document reload).
|
|
110
|
+
*/
|
|
111
|
+
reset() {
|
|
112
|
+
this.#stateSeq = 0;
|
|
113
|
+
this.#renderSeq = 0;
|
|
114
|
+
this.#layoutUpdating = false;
|
|
115
|
+
this.#pendingRender = null;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Get debug info about current state.
|
|
119
|
+
*/
|
|
120
|
+
getDebugInfo() {
|
|
121
|
+
return {
|
|
122
|
+
stateSeq: this.#stateSeq,
|
|
123
|
+
renderSeq: this.#renderSeq,
|
|
124
|
+
layoutUpdating: this.#layoutUpdating,
|
|
125
|
+
hasPendingRender: this.#pendingRender !== null,
|
|
126
|
+
isSafe: this.isSafeToRender()
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
//#endregion
|
|
131
|
+
export { LayoutSelectionGate };
|