@stll/folio-core 0.0.1-placeholder.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE.md +29 -0
- package/README.md +41 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/ai-edits/apply.d.ts +35 -0
- package/dist/ai-edits/apply.js +683 -0
- package/dist/ai-edits/clean-text.d.ts +28 -0
- package/dist/ai-edits/clean-text.js +23 -0
- package/dist/ai-edits/headless.d.ts +225 -0
- package/dist/ai-edits/headless.js +513 -0
- package/dist/ai-edits/index.d.ts +6 -0
- package/dist/ai-edits/index.js +5 -0
- package/dist/ai-edits/inline-emphasis.d.ts +38 -0
- package/dist/ai-edits/inline-emphasis.js +78 -0
- package/dist/ai-edits/snapshot.d.ts +9 -0
- package/dist/ai-edits/snapshot.js +195 -0
- package/dist/ai-edits/types.d.ts +156 -0
- package/dist/ai-edits/types.js +0 -0
- package/dist/ai-edits/word-diff.d.ts +20 -0
- package/dist/ai-edits/word-diff.js +77 -0
- package/dist/ai-suggestions/apply.d.ts +17 -0
- package/dist/ai-suggestions/apply.js +64 -0
- package/dist/ai-suggestions/conflict.d.ts +22 -0
- package/dist/ai-suggestions/conflict.js +67 -0
- package/dist/ai-suggestions/text-positions.d.ts +21 -0
- package/dist/ai-suggestions/text-positions.js +48 -0
- package/dist/ai-suggestions/types.d.ts +199 -0
- package/dist/ai-suggestions/types.js +59 -0
- package/dist/content-controls/errors.d.ts +52 -0
- package/dist/content-controls/errors.js +36 -0
- package/dist/content-controls/findContentControls.d.ts +55 -0
- package/dist/content-controls/findContentControls.js +75 -0
- package/dist/content-controls/index.d.ts +4 -0
- package/dist/content-controls/index.js +4 -0
- package/dist/content-controls/mutateContentControls.d.ts +51 -0
- package/dist/content-controls/mutateContentControls.js +377 -0
- package/dist/controller/folioEditor.d.ts +21 -0
- package/dist/controller/folioEditor.js +29 -0
- package/dist/controller/folioEditorEvents.d.ts +23 -0
- package/dist/controller/folioEditorEvents.js +24 -0
- package/dist/controller/hiddenEditorApi.d.ts +35 -0
- package/dist/controller/hiddenEditorApi.js +112 -0
- package/dist/controller/hiddenEditorManager.d.ts +93 -0
- package/dist/controller/hiddenEditorManager.js +308 -0
- package/dist/controller/layoutPipeline.d.ts +63 -0
- package/dist/controller/layoutPipeline.js +406 -0
- package/dist/controller/layoutScheduler.d.ts +41 -0
- package/dist/controller/layoutScheduler.js +59 -0
- package/dist/controller/layoutSession.d.ts +24 -0
- package/dist/controller/layoutSession.js +13 -0
- package/dist/docx/blockContentParser.d.ts +13 -0
- package/dist/docx/blockContentParser.js +289 -0
- package/dist/docx/bookmarkParser.d.ts +178 -0
- package/dist/docx/bookmarkParser.js +246 -0
- package/dist/docx/bookmarkPlacement.d.ts +10 -0
- package/dist/docx/bookmarkPlacement.js +50 -0
- package/dist/docx/bulletMarkers.d.ts +4 -0
- package/dist/docx/bulletMarkers.js +42 -0
- package/dist/docx/commentParser.d.ts +34 -0
- package/dist/docx/commentParser.js +127 -0
- package/dist/docx/commentReferenceNormalization.d.ts +25 -0
- package/dist/docx/commentReferenceNormalization.js +97 -0
- package/dist/docx/commentReplyMarkers.d.ts +20 -0
- package/dist/docx/commentReplyMarkers.js +123 -0
- package/dist/docx/compatibility.d.ts +12 -0
- package/dist/docx/compatibility.js +77 -0
- package/dist/docx/documentParser.d.ts +65 -0
- package/dist/docx/documentParser.js +209 -0
- package/dist/docx/drawingUtils.d.ts +56 -0
- package/dist/docx/drawingUtils.js +305 -0
- package/dist/docx/fieldParser.d.ts +228 -0
- package/dist/docx/fieldParser.js +559 -0
- package/dist/docx/footnoteParser.d.ts +109 -0
- package/dist/docx/footnoteParser.js +270 -0
- package/dist/docx/headerFooterParser.d.ts +119 -0
- package/dist/docx/headerFooterParser.js +266 -0
- package/dist/docx/headerFooterRefParser.d.ts +22 -0
- package/dist/docx/headerFooterRefParser.js +52 -0
- package/dist/docx/headerFooterReferenceNormalization.d.ts +19 -0
- package/dist/docx/headerFooterReferenceNormalization.js +64 -0
- package/dist/docx/hyperlinkParser.d.ts +108 -0
- package/dist/docx/hyperlinkParser.js +230 -0
- package/dist/docx/imageParser.d.ts +93 -0
- package/dist/docx/imageParser.js +522 -0
- package/dist/docx/mathToMathml.d.ts +15 -0
- package/dist/docx/mathToMathml.js +357 -0
- package/dist/docx/modelValidation.d.ts +13 -0
- package/dist/docx/modelValidation.js +21 -0
- package/dist/docx/normalizeBaseDirection.d.ts +12 -0
- package/dist/docx/normalizeBaseDirection.js +81 -0
- package/dist/docx/notePropertiesParser.d.ts +16 -0
- package/dist/docx/notePropertiesParser.js +99 -0
- package/dist/docx/numberingParser.d.ts +86 -0
- package/dist/docx/numberingParser.js +735 -0
- package/dist/docx/numberingReferenceNormalization.d.ts +25 -0
- package/dist/docx/numberingReferenceNormalization.js +22 -0
- package/dist/docx/paragraphParser.d.ts +86 -0
- package/dist/docx/paragraphParser.js +1132 -0
- package/dist/docx/paragraphTraversal.d.ts +19 -0
- package/dist/docx/paragraphTraversal.js +76 -0
- package/dist/docx/parser.d.ts +67 -0
- package/dist/docx/parser.js +391 -0
- package/dist/docx/parserEnums.d.ts +45 -0
- package/dist/docx/parserEnums.js +70 -0
- package/dist/docx/relsParser.d.ts +160 -0
- package/dist/docx/relsParser.js +235 -0
- package/dist/docx/replyToComment.d.ts +29 -0
- package/dist/docx/replyToComment.js +73 -0
- package/dist/docx/rezip.d.ts +166 -0
- package/dist/docx/rezip.js +1194 -0
- package/dist/docx/runConsolidator.d.ts +57 -0
- package/dist/docx/runConsolidator.js +224 -0
- package/dist/docx/runParser.d.ts +78 -0
- package/dist/docx/runParser.js +661 -0
- package/dist/docx/sdtProperties.d.ts +15 -0
- package/dist/docx/sdtProperties.js +290 -0
- package/dist/docx/sdtPropertiesPatch.d.ts +16 -0
- package/dist/docx/sdtPropertiesPatch.js +144 -0
- package/dist/docx/sectionParser.d.ts +95 -0
- package/dist/docx/sectionParser.js +534 -0
- package/dist/docx/selectiveSave.d.ts +25 -0
- package/dist/docx/selectiveSave.js +247 -0
- package/dist/docx/selectiveSaveFlags.d.ts +33 -0
- package/dist/docx/selectiveSaveFlags.js +11 -0
- package/dist/docx/selectiveSaveTripwire.d.ts +33 -0
- package/dist/docx/selectiveSaveTripwire.js +79 -0
- package/dist/docx/selectiveXmlPatch.d.ts +103 -0
- package/dist/docx/selectiveXmlPatch.js +493 -0
- package/dist/docx/serializer/blockSdtSerializer.d.ts +6 -0
- package/dist/docx/serializer/blockSdtSerializer.js +88 -0
- package/dist/docx/serializer/borderSerializer.d.ts +25 -0
- package/dist/docx/serializer/borderSerializer.js +44 -0
- package/dist/docx/serializer/commentSerializer.d.ts +31 -0
- package/dist/docx/serializer/commentSerializer.js +184 -0
- package/dist/docx/serializer/documentSerializer.d.ts +65 -0
- package/dist/docx/serializer/documentSerializer.js +199 -0
- package/dist/docx/serializer/headerFooterSerializer.d.ts +12 -0
- package/dist/docx/serializer/headerFooterSerializer.js +84 -0
- package/dist/docx/serializer/noteSerializer.d.ts +19 -0
- package/dist/docx/serializer/noteSerializer.js +70 -0
- package/dist/docx/serializer/numberingSerializer.d.ts +12 -0
- package/dist/docx/serializer/numberingSerializer.js +93 -0
- package/dist/docx/serializer/paragraphSerializer.d.ts +48 -0
- package/dist/docx/serializer/paragraphSerializer.js +559 -0
- package/dist/docx/serializer/runSerializer.d.ts +56 -0
- package/dist/docx/serializer/runSerializer.js +621 -0
- package/dist/docx/serializer/sectionPropertiesSerializer.d.ts +6 -0
- package/dist/docx/serializer/sectionPropertiesSerializer.js +187 -0
- package/dist/docx/serializer/tableSerializer.d.ts +79 -0
- package/dist/docx/serializer/tableSerializer.js +422 -0
- package/dist/docx/serializer/xmlUtils.d.ts +20 -0
- package/dist/docx/serializer/xmlUtils.js +25 -0
- package/dist/docx/settingsParser.d.ts +8 -0
- package/dist/docx/settingsParser.js +36 -0
- package/dist/docx/shapeParser.d.ts +20 -0
- package/dist/docx/shapeParser.js +272 -0
- package/dist/docx/styleParser.d.ts +50 -0
- package/dist/docx/styleParser.js +905 -0
- package/dist/docx/tableParser.d.ts +202 -0
- package/dist/docx/tableParser.js +811 -0
- package/dist/docx/textBoxParser.d.ts +117 -0
- package/dist/docx/textBoxParser.js +262 -0
- package/dist/docx/themeParser.d.ts +77 -0
- package/dist/docx/themeParser.js +330 -0
- package/dist/docx/trackedMoveRangeNormalization.d.ts +22 -0
- package/dist/docx/trackedMoveRangeNormalization.js +100 -0
- package/dist/docx/unzip.d.ts +118 -0
- package/dist/docx/unzip.js +383 -0
- package/dist/docx/vmlImageParser.d.ts +16 -0
- package/dist/docx/vmlImageParser.js +100 -0
- package/dist/docx/watermarkParser.d.ts +45 -0
- package/dist/docx/watermarkParser.js +348 -0
- package/dist/docx/wrapTypes.d.ts +29 -0
- package/dist/docx/wrapTypes.js +48 -0
- package/dist/docx/xmlParser.d.ts +297 -0
- package/dist/docx/xmlParser.js +527 -0
- package/dist/fields/bookmarkPages.d.ts +13 -0
- package/dist/fields/bookmarkPages.js +66 -0
- package/dist/fields/bookmarkText.d.ts +16 -0
- package/dist/fields/bookmarkText.js +61 -0
- package/dist/fields/evaluateField.d.ts +23 -0
- package/dist/fields/evaluateField.js +77 -0
- package/dist/fields/fieldContext.d.ts +21 -0
- package/dist/fields/fieldContext.js +0 -0
- package/dist/fields/resolveFieldValues.d.ts +44 -0
- package/dist/fields/resolveFieldValues.js +204 -0
- package/dist/fields/sectionPageCounts.d.ts +11 -0
- package/dist/fields/sectionPageCounts.js +16 -0
- package/dist/fields/seqValues.d.ts +14 -0
- package/dist/fields/seqValues.js +36 -0
- package/dist/fonts/embeddedFontTable.d.ts +42 -0
- package/dist/fonts/embeddedFontTable.js +80 -0
- package/dist/fonts/embeddedFonts.d.ts +46 -0
- package/dist/fonts/embeddedFonts.js +112 -0
- package/dist/fonts/fontDeobfuscation.d.ts +30 -0
- package/dist/fonts/fontDeobfuscation.js +57 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +23 -0
- package/dist/layout-bridge/convert/footnoteLayout.d.ts +57 -0
- package/dist/layout-bridge/convert/footnoteLayout.js +316 -0
- package/dist/layout-bridge/convert/headerFooterLayout.d.ts +74 -0
- package/dist/layout-bridge/convert/headerFooterLayout.js +432 -0
- package/dist/layout-bridge/convert/templatePreviewFlow.d.ts +36 -0
- package/dist/layout-bridge/convert/templatePreviewFlow.js +176 -0
- package/dist/layout-bridge/convert/toFlowBlocks.d.ts +65 -0
- package/dist/layout-bridge/convert/toFlowBlocks.js +1309 -0
- package/dist/layout-bridge/convert/wrapEditorViewAsSurface.d.ts +17 -0
- package/dist/layout-bridge/convert/wrapEditorViewAsSurface.js +36 -0
- package/dist/layout-bridge/dom/clickToPositionDom.d.ts +66 -0
- package/dist/layout-bridge/dom/clickToPositionDom.js +304 -0
- package/dist/layout-bridge/dom/findBodyPmSpans.d.ts +7 -0
- package/dist/layout-bridge/dom/findBodyPmSpans.js +17 -0
- package/dist/layout-bridge/dom/findHfPmSpans.d.ts +62 -0
- package/dist/layout-bridge/dom/findHfPmSpans.js +197 -0
- package/dist/layout-bridge/engine/clickToPosition.d.ts +66 -0
- package/dist/layout-bridge/engine/clickToPosition.js +403 -0
- package/dist/layout-bridge/engine/hitTest.d.ts +135 -0
- package/dist/layout-bridge/engine/hitTest.js +375 -0
- package/dist/layout-bridge/engine/measuring/index.d.ts +10 -0
- package/dist/layout-bridge/engine/measuring/index.js +9 -0
- package/dist/layout-bridge/engine/selectionRects.d.ts +59 -0
- package/dist/layout-bridge/engine/selectionRects.js +485 -0
- package/dist/layout-bridge/engine/tableWidthUtils.d.ts +7 -0
- package/dist/layout-bridge/engine/tableWidthUtils.js +25 -0
- package/dist/layout-engine/index.d.ts +44 -0
- package/dist/layout-engine/index.js +691 -0
- package/dist/layout-engine/keep-together.d.ts +43 -0
- package/dist/layout-engine/keep-together.js +98 -0
- package/dist/layout-engine/layoutInstrumentation.d.ts +50 -0
- package/dist/layout-engine/layoutInstrumentation.js +43 -0
- package/dist/layout-engine/lineFlow.d.ts +8 -0
- package/dist/layout-engine/lineFlow.js +17 -0
- package/dist/layout-engine/measure/cache.d.ts +93 -0
- package/dist/layout-engine/measure/cache.js +245 -0
- package/dist/layout-engine/measure/clampFloatingWrapMargins.d.ts +20 -0
- package/dist/layout-engine/measure/clampFloatingWrapMargins.js +29 -0
- package/dist/layout-engine/measure/featureFlags.d.ts +44 -0
- package/dist/layout-engine/measure/featureFlags.js +19 -0
- package/dist/layout-engine/measure/floatingZones.d.ts +89 -0
- package/dist/layout-engine/measure/floatingZones.js +152 -0
- package/dist/layout-engine/measure/font-metrics.worker.d.ts +17 -0
- package/dist/layout-engine/measure/font-metrics.worker.js +104 -0
- package/dist/layout-engine/measure/index.d.ts +9 -0
- package/dist/layout-engine/measure/index.js +8 -0
- package/dist/layout-engine/measure/listMarkerWidth.d.ts +40 -0
- package/dist/layout-engine/measure/listMarkerWidth.js +76 -0
- package/dist/layout-engine/measure/measureBlocks.d.ts +25 -0
- package/dist/layout-engine/measure/measureBlocks.js +450 -0
- package/dist/layout-engine/measure/measureContainer.d.ts +24 -0
- package/dist/layout-engine/measure/measureContainer.js +280 -0
- package/dist/layout-engine/measure/measureHelpers.d.ts +82 -0
- package/dist/layout-engine/measure/measureHelpers.js +156 -0
- package/dist/layout-engine/measure/measureParagraph.d.ts +61 -0
- package/dist/layout-engine/measure/measureParagraph.js +724 -0
- package/dist/layout-engine/measure/measureProvider.d.ts +23 -0
- package/dist/layout-engine/measure/measureProvider.js +35 -0
- package/dist/layout-engine/measure/measureTypes.d.ts +61 -0
- package/dist/layout-engine/measure/measureTypes.js +0 -0
- package/dist/layout-engine/measure/measureWorker.d.ts +54 -0
- package/dist/layout-engine/measure/measureWorker.js +249 -0
- package/dist/layout-engine/measure/measureWorkerProtocol.d.ts +88 -0
- package/dist/layout-engine/measure/measureWorkerProtocol.js +20 -0
- package/dist/layout-engine/measure/tableCellFloating.d.ts +26 -0
- package/dist/layout-engine/measure/tableCellFloating.js +99 -0
- package/dist/layout-engine/paginator.d.ts +84 -0
- package/dist/layout-engine/paginator.js +348 -0
- package/dist/layout-engine/paragraphFragmentRange.d.ts +9 -0
- package/dist/layout-engine/paragraphFragmentRange.js +40 -0
- package/dist/layout-engine/section-breaks.d.ts +78 -0
- package/dist/layout-engine/section-breaks.js +182 -0
- package/dist/layout-engine/tableRowBreak.d.ts +23 -0
- package/dist/layout-engine/tableRowBreak.js +147 -0
- package/dist/layout-engine/textBoxFlow.d.ts +50 -0
- package/dist/layout-engine/textBoxFlow.js +160 -0
- package/dist/layout-engine/types.d.ts +1031 -0
- package/dist/layout-engine/types.js +100 -0
- package/dist/layout-painter/documentColors.d.ts +4 -0
- package/dist/layout-painter/documentColors.js +40 -0
- package/dist/layout-painter/index.d.ts +110 -0
- package/dist/layout-painter/index.js +182 -0
- package/dist/layout-painter/registry/modules/image.d.ts +6 -0
- package/dist/layout-painter/registry/modules/image.js +17 -0
- package/dist/layout-painter/registry/modules/paragraph.d.ts +6 -0
- package/dist/layout-painter/registry/modules/paragraph.js +18 -0
- package/dist/layout-painter/registry/modules/table.d.ts +6 -0
- package/dist/layout-painter/registry/modules/table.js +16 -0
- package/dist/layout-painter/registry/modules/textBox.d.ts +6 -0
- package/dist/layout-painter/registry/modules/textBox.js +13 -0
- package/dist/layout-painter/registry/modules.d.ts +6 -0
- package/dist/layout-painter/registry/modules.js +26 -0
- package/dist/layout-painter/registry/registry.d.ts +24 -0
- package/dist/layout-painter/registry/registry.js +53 -0
- package/dist/layout-painter/registry/types.d.ts +61 -0
- package/dist/layout-painter/registry/types.js +0 -0
- package/dist/layout-painter/renderFragment.d.ts +32 -0
- package/dist/layout-painter/renderFragment.js +114 -0
- package/dist/layout-painter/renderImage.d.ts +88 -0
- package/dist/layout-painter/renderImage.js +130 -0
- package/dist/layout-painter/renderPage.d.ts +264 -0
- package/dist/layout-painter/renderPage.js +1795 -0
- package/dist/layout-painter/renderParagraph.d.ts +93 -0
- package/dist/layout-painter/renderParagraph.js +1300 -0
- package/dist/layout-painter/renderTable.d.ts +36 -0
- package/dist/layout-painter/renderTable.js +432 -0
- package/dist/layout-painter/renderTextBox.d.ts +22 -0
- package/dist/layout-painter/renderTextBox.js +67 -0
- package/dist/layout-painter/renderUtils.d.ts +42 -0
- package/dist/layout-painter/renderUtils.js +30 -0
- package/dist/layout-painter/renderWatermark.d.ts +16 -0
- package/dist/layout-painter/renderWatermark.js +61 -0
- package/dist/layout-painter/sdtBoundary.d.ts +6 -0
- package/dist/layout-painter/sdtBoundary.js +28 -0
- package/dist/managers/ContextMenuManager.d.ts +28 -0
- package/dist/managers/ContextMenuManager.js +48 -0
- package/dist/managers/DocumentLoaderManager.d.ts +47 -0
- package/dist/managers/DocumentLoaderManager.js +69 -0
- package/dist/managers/EditorModeManager.d.ts +28 -0
- package/dist/managers/EditorModeManager.js +50 -0
- package/dist/managers/ErrorManager.d.ts +26 -0
- package/dist/managers/ErrorManager.js +85 -0
- package/dist/managers/FindReplaceManager.d.ts +54 -0
- package/dist/managers/FindReplaceManager.js +104 -0
- package/dist/managers/HistoryManager.d.ts +92 -0
- package/dist/managers/HistoryManager.js +193 -0
- package/dist/managers/Subscribable.d.ts +34 -0
- package/dist/managers/Subscribable.js +46 -0
- package/dist/managers/TableSelectionManager.d.ts +74 -0
- package/dist/managers/TableSelectionManager.js +225 -0
- package/dist/managers/editorShortcuts.d.ts +42 -0
- package/dist/managers/editorShortcuts.js +60 -0
- package/dist/managers/types.d.ts +41 -0
- package/dist/managers/types.js +0 -0
- package/dist/markdown/annotations.d.ts +14 -0
- package/dist/markdown/annotations.js +42 -0
- package/dist/markdown/escape.d.ts +36 -0
- package/dist/markdown/escape.js +59 -0
- package/dist/markdown/fromMarkdown.d.ts +11 -0
- package/dist/markdown/fromMarkdown.js +223 -0
- package/dist/markdown/headings.d.ts +13 -0
- package/dist/markdown/headings.js +20 -0
- package/dist/markdown/images.d.ts +13 -0
- package/dist/markdown/images.js +63 -0
- package/dist/markdown/index.d.ts +18 -0
- package/dist/markdown/index.js +33 -0
- package/dist/markdown/internals.d.ts +15 -0
- package/dist/markdown/internals.js +35 -0
- package/dist/markdown/renderBlock.d.ts +7 -0
- package/dist/markdown/renderBlock.js +68 -0
- package/dist/markdown/renderParagraph.d.ts +11 -0
- package/dist/markdown/renderParagraph.js +64 -0
- package/dist/markdown/renderRuns.d.ts +11 -0
- package/dist/markdown/renderRuns.js +265 -0
- package/dist/markdown/renderTable.d.ts +8 -0
- package/dist/markdown/renderTable.js +229 -0
- package/dist/markdown/trailers.d.ts +13 -0
- package/dist/markdown/trailers.js +54 -0
- package/dist/markdown/types.d.ts +118 -0
- package/dist/markdown/types.js +0 -0
- package/dist/model.d.ts +13 -0
- package/dist/model.js +4 -0
- package/dist/paged-layout/LayoutSelectionGate.d.ts +80 -0
- package/dist/paged-layout/LayoutSelectionGate.js +131 -0
- package/dist/paged-layout/headerFooterMargins.d.ts +73 -0
- package/dist/paged-layout/headerFooterMargins.js +120 -0
- package/dist/paged-layout/hiddenEditorScroll.d.ts +4 -0
- package/dist/paged-layout/hiddenEditorScroll.js +4 -0
- package/dist/paged-layout/incrementalMeasure.d.ts +33 -0
- package/dist/paged-layout/incrementalMeasure.js +56 -0
- package/dist/paged-layout/rangeProjection.d.ts +51 -0
- package/dist/paged-layout/rangeProjection.js +153 -0
- package/dist/paged-layout/readOnlyEditAttempt.d.ts +5 -0
- package/dist/paged-layout/readOnlyEditAttempt.js +22 -0
- package/dist/paged-layout/scrollNavigation.d.ts +23 -0
- package/dist/paged-layout/scrollNavigation.js +31 -0
- package/dist/paged-layout/scrollPageInfo.d.ts +41 -0
- package/dist/paged-layout/scrollPageInfo.js +34 -0
- package/dist/paged-layout/scrollToPmPosition.d.ts +17 -0
- package/dist/paged-layout/scrollToPmPosition.js +95 -0
- package/dist/paged-layout/sectionBlockWidths.d.ts +35 -0
- package/dist/paged-layout/sectionBlockWidths.js +52 -0
- package/dist/paged-layout/sectionGeometry.d.ts +21 -0
- package/dist/paged-layout/sectionGeometry.js +36 -0
- package/dist/paged-layout/selectionViewportRect.d.ts +29 -0
- package/dist/paged-layout/selectionViewportRect.js +55 -0
- package/dist/paged-layout/tableColumnResize.d.ts +19 -0
- package/dist/paged-layout/tableColumnResize.js +28 -0
- package/dist/paged-layout/tableInsertButtonGeometry.d.ts +15 -0
- package/dist/paged-layout/tableInsertButtonGeometry.js +15 -0
- package/dist/paged-layout/transactionDirtyRange.d.ts +7 -0
- package/dist/paged-layout/transactionDirtyRange.js +27 -0
- package/dist/paged-layout/zoomScrollAnchor.d.ts +40 -0
- package/dist/paged-layout/zoomScrollAnchor.js +25 -0
- package/dist/prosemirror/attrs/index.d.ts +80 -0
- package/dist/prosemirror/attrs/index.js +1218 -0
- package/dist/prosemirror/autospacingBase.d.ts +11 -0
- package/dist/prosemirror/autospacingBase.js +16 -0
- package/dist/prosemirror/commands/comments.d.ts +93 -0
- package/dist/prosemirror/commands/comments.js +435 -0
- package/dist/prosemirror/commands/contentControls.d.ts +45 -0
- package/dist/prosemirror/commands/contentControls.js +294 -0
- package/dist/prosemirror/commands/contentControlsBlockFill.d.ts +15 -0
- package/dist/prosemirror/commands/contentControlsBlockFill.js +19 -0
- package/dist/prosemirror/commands/formatPainter.d.ts +31 -0
- package/dist/prosemirror/commands/formatPainter.js +130 -0
- package/dist/prosemirror/commands/formatting.d.ts +32 -0
- package/dist/prosemirror/commands/formatting.js +45 -0
- package/dist/prosemirror/commands/hyperlink.d.ts +31 -0
- package/dist/prosemirror/commands/hyperlink.js +79 -0
- package/dist/prosemirror/commands/image.d.ts +59 -0
- package/dist/prosemirror/commands/image.js +219 -0
- package/dist/prosemirror/commands/index.d.ts +13 -0
- package/dist/prosemirror/commands/index.js +13 -0
- package/dist/prosemirror/commands/pageBreak.d.ts +10 -0
- package/dist/prosemirror/commands/pageBreak.js +47 -0
- package/dist/prosemirror/commands/paragraph.d.ts +39 -0
- package/dist/prosemirror/commands/paragraph.js +64 -0
- package/dist/prosemirror/commands/pastePlainText.d.ts +39 -0
- package/dist/prosemirror/commands/pastePlainText.js +67 -0
- package/dist/prosemirror/commands/table.d.ts +83 -0
- package/dist/prosemirror/commands/table.js +105 -0
- package/dist/prosemirror/conversion/fromProseDoc.d.ts +27 -0
- package/dist/prosemirror/conversion/fromProseDoc.js +1550 -0
- package/dist/prosemirror/conversion/index.d.ts +4 -0
- package/dist/prosemirror/conversion/index.js +4 -0
- package/dist/prosemirror/conversion/runShadingMark.d.ts +16 -0
- package/dist/prosemirror/conversion/runShadingMark.js +39 -0
- package/dist/prosemirror/conversion/toProseDoc.d.ts +39 -0
- package/dist/prosemirror/conversion/toProseDoc.js +1404 -0
- package/dist/prosemirror/extensions/ExtensionManager.d.ts +43 -0
- package/dist/prosemirror/extensions/ExtensionManager.js +86 -0
- package/dist/prosemirror/extensions/StarterKit.d.ts +16 -0
- package/dist/prosemirror/extensions/StarterKit.js +132 -0
- package/dist/prosemirror/extensions/core/DocExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/core/DocExtension.js +12 -0
- package/dist/prosemirror/extensions/core/HistoryExtension.d.ts +13 -0
- package/dist/prosemirror/extensions/core/HistoryExtension.js +28 -0
- package/dist/prosemirror/extensions/core/ParagraphExtension.d.ts +25 -0
- package/dist/prosemirror/extensions/core/ParagraphExtension.js +619 -0
- package/dist/prosemirror/extensions/core/TextExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/core/TextExtension.js +12 -0
- package/dist/prosemirror/extensions/create.d.ts +17 -0
- package/dist/prosemirror/extensions/create.js +129 -0
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.d.ts +23 -0
- package/dist/prosemirror/extensions/features/AutoBidiDetectionExtension.js +106 -0
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.d.ts +8 -0
- package/dist/prosemirror/extensions/features/BaseKeymapExtension.js +172 -0
- package/dist/prosemirror/extensions/features/BidiShortcutExtension.d.ts +16 -0
- package/dist/prosemirror/extensions/features/BidiShortcutExtension.js +38 -0
- package/dist/prosemirror/extensions/features/ContentControlWidgetsExtension.d.ts +16 -0
- package/dist/prosemirror/extensions/features/ContentControlWidgetsExtension.js +21 -0
- package/dist/prosemirror/extensions/features/DropCursorExtension.d.ts +12 -0
- package/dist/prosemirror/extensions/features/DropCursorExtension.js +20 -0
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.d.ts +8 -0
- package/dist/prosemirror/extensions/features/EmptyParagraphFormatExtension.js +44 -0
- package/dist/prosemirror/extensions/features/GapCursorExtension.d.ts +19 -0
- package/dist/prosemirror/extensions/features/GapCursorExtension.js +24 -0
- package/dist/prosemirror/extensions/features/ImageDragExtension.d.ts +15 -0
- package/dist/prosemirror/extensions/features/ImageDragExtension.js +66 -0
- package/dist/prosemirror/extensions/features/ImagePasteExtension.d.ts +12 -0
- package/dist/prosemirror/extensions/features/ImagePasteExtension.js +91 -0
- package/dist/prosemirror/extensions/features/ListExtension.d.ts +14 -0
- package/dist/prosemirror/extensions/features/ListExtension.js +340 -0
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/features/ParaIdAllocatorExtension.js +60 -0
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.d.ts +35 -0
- package/dist/prosemirror/extensions/features/ParagraphChangeTrackerExtension.js +188 -0
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.d.ts +20 -0
- package/dist/prosemirror/extensions/features/PasteCleanupExtension.js +34 -0
- package/dist/prosemirror/extensions/features/PasteStyleInlinerExtension.d.ts +20 -0
- package/dist/prosemirror/extensions/features/PasteStyleInlinerExtension.js +145 -0
- package/dist/prosemirror/extensions/features/SelectionTrackerExtension.d.ts +10 -0
- package/dist/prosemirror/extensions/features/SelectionTrackerExtension.js +17 -0
- package/dist/prosemirror/extensions/features/bidiShortcutController.d.ts +31 -0
- package/dist/prosemirror/extensions/features/bidiShortcutController.js +27 -0
- package/dist/prosemirror/extensions/features/pasteCleanup.d.ts +31 -0
- package/dist/prosemirror/extensions/features/pasteCleanup.js +159 -0
- package/dist/prosemirror/extensions/marks/AllCapsExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/AllCapsExtension.js +24 -0
- package/dist/prosemirror/extensions/marks/BoldExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/BoldExtension.js +41 -0
- package/dist/prosemirror/extensions/marks/CharacterSpacingExtension.d.ts +14 -0
- package/dist/prosemirror/extensions/marks/CharacterSpacingExtension.js +64 -0
- package/dist/prosemirror/extensions/marks/CharacterStyleExtension.d.ts +23 -0
- package/dist/prosemirror/extensions/marks/CharacterStyleExtension.js +47 -0
- package/dist/prosemirror/extensions/marks/CommentExtension.d.ts +12 -0
- package/dist/prosemirror/extensions/marks/CommentExtension.js +38 -0
- package/dist/prosemirror/extensions/marks/FontFamilyExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/FontFamilyExtension.js +55 -0
- package/dist/prosemirror/extensions/marks/FontSizeExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/FontSizeExtension.js +47 -0
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.d.ts +11 -0
- package/dist/prosemirror/extensions/marks/FootnoteRefExtension.js +92 -0
- package/dist/prosemirror/extensions/marks/HiddenTextExtension.d.ts +23 -0
- package/dist/prosemirror/extensions/marks/HiddenTextExtension.js +35 -0
- package/dist/prosemirror/extensions/marks/HighlightExtension.d.ts +10 -0
- package/dist/prosemirror/extensions/marks/HighlightExtension.js +115 -0
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.d.ts +13 -0
- package/dist/prosemirror/extensions/marks/HyperlinkExtension.js +146 -0
- package/dist/prosemirror/extensions/marks/ItalicExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/ItalicExtension.js +34 -0
- package/dist/prosemirror/extensions/marks/RtlExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/marks/RtlExtension.js +21 -0
- package/dist/prosemirror/extensions/marks/RunFormattingOverrideExtension.d.ts +11 -0
- package/dist/prosemirror/extensions/marks/RunFormattingOverrideExtension.js +75 -0
- package/dist/prosemirror/extensions/marks/RunShadingExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/marks/RunShadingExtension.js +38 -0
- package/dist/prosemirror/extensions/marks/SmallCapsExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/SmallCapsExtension.js +24 -0
- package/dist/prosemirror/extensions/marks/StrikeExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/StrikeExtension.js +33 -0
- package/dist/prosemirror/extensions/marks/SubscriptExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/SubscriptExtension.js +25 -0
- package/dist/prosemirror/extensions/marks/SuperscriptExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/SuperscriptExtension.js +25 -0
- package/dist/prosemirror/extensions/marks/TextColorExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/TextColorExtension.js +50 -0
- package/dist/prosemirror/extensions/marks/TextEffectExtension.d.ts +6 -0
- package/dist/prosemirror/extensions/marks/TextEffectExtension.js +35 -0
- package/dist/prosemirror/extensions/marks/TextEffectsExtensions.d.ts +31 -0
- package/dist/prosemirror/extensions/marks/TextEffectsExtensions.js +134 -0
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.d.ts +22 -0
- package/dist/prosemirror/extensions/marks/TrackedChangeExtensions.js +113 -0
- package/dist/prosemirror/extensions/marks/UnderlineExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/marks/UnderlineExtension.js +60 -0
- package/dist/prosemirror/extensions/marks/markUtils.d.ts +34 -0
- package/dist/prosemirror/extensions/marks/markUtils.js +233 -0
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.d.ts +22 -0
- package/dist/prosemirror/extensions/nodes/BlockSdtExtension.js +122 -0
- package/dist/prosemirror/extensions/nodes/FieldExtension.d.ts +12 -0
- package/dist/prosemirror/extensions/nodes/FieldExtension.js +87 -0
- package/dist/prosemirror/extensions/nodes/HardBreakExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/nodes/HardBreakExtension.js +38 -0
- package/dist/prosemirror/extensions/nodes/HorizontalRuleExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/nodes/HorizontalRuleExtension.js +18 -0
- package/dist/prosemirror/extensions/nodes/ImageExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/nodes/ImageExtension.js +132 -0
- package/dist/prosemirror/extensions/nodes/MathExtension.d.ts +13 -0
- package/dist/prosemirror/extensions/nodes/MathExtension.js +56 -0
- package/dist/prosemirror/extensions/nodes/PageBreakExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/nodes/PageBreakExtension.js +20 -0
- package/dist/prosemirror/extensions/nodes/SdtExtension.d.ts +12 -0
- package/dist/prosemirror/extensions/nodes/SdtExtension.js +107 -0
- package/dist/prosemirror/extensions/nodes/ShapeExtension.d.ts +30 -0
- package/dist/prosemirror/extensions/nodes/ShapeExtension.js +502 -0
- package/dist/prosemirror/extensions/nodes/TabExtension.d.ts +9 -0
- package/dist/prosemirror/extensions/nodes/TabExtension.js +27 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.d.ts +34 -0
- package/dist/prosemirror/extensions/nodes/TableExtension.js +1972 -0
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.d.ts +34 -0
- package/dist/prosemirror/extensions/nodes/TextBoxExtension.js +150 -0
- package/dist/prosemirror/extensions/types.d.ts +101 -0
- package/dist/prosemirror/extensions/types.js +10 -0
- package/dist/prosemirror/findReplaceSelection.d.ts +23 -0
- package/dist/prosemirror/findReplaceSelection.js +86 -0
- package/dist/prosemirror/index.d.ts +25 -0
- package/dist/prosemirror/index.js +23 -0
- package/dist/prosemirror/insertOperations.d.ts +12 -0
- package/dist/prosemirror/insertOperations.js +19 -0
- package/dist/prosemirror/paragraphDirection.d.ts +42 -0
- package/dist/prosemirror/paragraphDirection.js +33 -0
- package/dist/prosemirror/plugins/aiCitationDecorations.d.ts +40 -0
- package/dist/prosemirror/plugins/aiCitationDecorations.js +90 -0
- package/dist/prosemirror/plugins/aiSuggestionDecorations.d.ts +42 -0
- package/dist/prosemirror/plugins/aiSuggestionDecorations.js +135 -0
- package/dist/prosemirror/plugins/anonymizationDecorations.d.ts +60 -0
- package/dist/prosemirror/plugins/anonymizationDecorations.js +120 -0
- package/dist/prosemirror/plugins/autocompleteSuggestion.d.ts +123 -0
- package/dist/prosemirror/plugins/autocompleteSuggestion.js +283 -0
- package/dist/prosemirror/plugins/contentControlWidgets.d.ts +56 -0
- package/dist/prosemirror/plugins/contentControlWidgets.js +192 -0
- package/dist/prosemirror/plugins/createDocScanPlugin.d.ts +37 -0
- package/dist/prosemirror/plugins/createDocScanPlugin.js +55 -0
- package/dist/prosemirror/plugins/documentStyles.d.ts +18 -0
- package/dist/prosemirror/plugins/documentStyles.js +46 -0
- package/dist/prosemirror/plugins/index.d.ts +3 -0
- package/dist/prosemirror/plugins/index.js +3 -0
- package/dist/prosemirror/plugins/pmTextScan.d.ts +19 -0
- package/dist/prosemirror/plugins/pmTextScan.js +39 -0
- package/dist/prosemirror/plugins/selectionTracker.d.ts +43 -0
- package/dist/prosemirror/plugins/selectionTracker.js +179 -0
- package/dist/prosemirror/plugins/suggestionMode.d.ts +70 -0
- package/dist/prosemirror/plugins/suggestionMode.js +489 -0
- package/dist/prosemirror/plugins/templateDirectives.d.ts +25 -0
- package/dist/prosemirror/plugins/templateDirectives.js +67 -0
- package/dist/prosemirror/plugins/templatePreviewValues.d.ts +49 -0
- package/dist/prosemirror/plugins/templatePreviewValues.js +117 -0
- package/dist/prosemirror/plugins/templateSlashMenu.d.ts +57 -0
- package/dist/prosemirror/plugins/templateSlashMenu.js +184 -0
- package/dist/prosemirror/schema/index.d.ts +15 -0
- package/dist/prosemirror/schema/index.js +20 -0
- package/dist/prosemirror/schema/marks.d.ts +118 -0
- package/dist/prosemirror/schema/marks.js +0 -0
- package/dist/prosemirror/schema/nodes.d.ts +389 -0
- package/dist/prosemirror/schema/nodes.js +0 -0
- package/dist/prosemirror/selectionState.d.ts +23 -0
- package/dist/prosemirror/selectionState.js +111 -0
- package/dist/prosemirror/styles/index.d.ts +2 -0
- package/dist/prosemirror/styles/index.js +2 -0
- package/dist/prosemirror/styles/resolvedStyleAttrs.d.ts +32 -0
- package/dist/prosemirror/styles/resolvedStyleAttrs.js +108 -0
- package/dist/prosemirror/styles/styleResolver.d.ts +94 -0
- package/dist/prosemirror/styles/styleResolver.js +200 -0
- package/dist/prosemirror/utils/findParagraphByParaId.d.ts +26 -0
- package/dist/prosemirror/utils/findParagraphByParaId.js +37 -0
- package/dist/prosemirror/utils/tabCalculator.d.ts +110 -0
- package/dist/prosemirror/utils/tabCalculator.js +137 -0
- package/dist/prosemirror/validation.d.ts +20 -0
- package/dist/prosemirror/validation.js +177 -0
- package/dist/server.d.ts +7 -0
- package/dist/server.js +6 -0
- package/dist/style-engine/index.d.ts +3 -0
- package/dist/style-engine/index.js +2 -0
- package/dist/style-engine/styleEngine.d.ts +67 -0
- package/dist/style-engine/styleEngine.js +70 -0
- package/dist/types/block-id.d.ts +58 -0
- package/dist/types/block-id.js +61 -0
- package/dist/types/colors.d.ts +2 -0
- package/dist/types/colors.js +0 -0
- package/dist/types/content.d.ts +2 -0
- package/dist/types/content.js +0 -0
- package/dist/types/document.d.ts +7 -0
- package/dist/types/document.js +0 -0
- package/dist/types/documentEnumValues.d.ts +89 -0
- package/dist/types/documentEnumValues.js +693 -0
- package/dist/types/formatting.d.ts +2 -0
- package/dist/types/formatting.js +0 -0
- package/dist/types/index.d.ts +107 -0
- package/dist/types/index.js +0 -0
- package/dist/utils/authorColors.d.ts +16 -0
- package/dist/utils/authorColors.js +30 -0
- package/dist/utils/baseDirection.d.ts +23 -0
- package/dist/utils/baseDirection.js +34 -0
- package/dist/utils/clipboard.d.ts +126 -0
- package/dist/utils/clipboard.js +622 -0
- package/dist/utils/colorResolver.d.ts +158 -0
- package/dist/utils/colorResolver.js +557 -0
- package/dist/utils/createDocument.d.ts +50 -0
- package/dist/utils/createDocument.js +262 -0
- package/dist/utils/documentLoaderBehavior.d.ts +22 -0
- package/dist/utils/documentLoaderBehavior.js +14 -0
- package/dist/utils/docxInput.d.ts +22 -0
- package/dist/utils/docxInput.js +16 -0
- package/dist/utils/domGuards.d.ts +59 -0
- package/dist/utils/domGuards.js +82 -0
- package/dist/utils/fontFamilyMerge.d.ts +7 -0
- package/dist/utils/fontFamilyMerge.js +31 -0
- package/dist/utils/fontLoader.d.ts +50 -0
- package/dist/utils/fontLoader.js +177 -0
- package/dist/utils/fontResolver.d.ts +61 -0
- package/dist/utils/fontResolver.js +651 -0
- package/dist/utils/fontWeights.d.ts +4 -0
- package/dist/utils/fontWeights.js +4 -0
- package/dist/utils/formatToStyle.d.ts +103 -0
- package/dist/utils/formatToStyle.js +289 -0
- package/dist/utils/headerFooter.d.ts +74 -0
- package/dist/utils/headerFooter.js +257 -0
- package/dist/utils/headingCollector.d.ts +22 -0
- package/dist/utils/headingCollector.js +36 -0
- package/dist/utils/hexId.d.ts +33 -0
- package/dist/utils/hexId.js +37 -0
- package/dist/utils/imageValidation.d.ts +5 -0
- package/dist/utils/imageValidation.js +31 -0
- package/dist/utils/paragraphFormattingMerge.d.ts +14 -0
- package/dist/utils/paragraphFormattingMerge.js +68 -0
- package/dist/utils/replaceText.d.ts +17 -0
- package/dist/utils/replaceText.js +161 -0
- package/dist/utils/rotationBoundingBox.d.ts +12 -0
- package/dist/utils/rotationBoundingBox.js +36 -0
- package/dist/utils/scriptSegments.d.ts +36 -0
- package/dist/utils/scriptSegments.js +52 -0
- package/dist/utils/tableOperations.d.ts +87 -0
- package/dist/utils/tableOperations.js +259 -0
- package/dist/utils/textFormattingMerge.d.ts +6 -0
- package/dist/utils/textFormattingMerge.js +31 -0
- package/dist/utils/tiffConverter.d.ts +18 -0
- package/dist/utils/tiffConverter.js +83 -0
- package/dist/utils/units.d.ts +99 -0
- package/dist/utils/units.js +139 -0
- package/dist/utils/urlSecurity.d.ts +7 -0
- package/dist/utils/urlSecurity.js +65 -0
- package/dist/watermark/index.d.ts +39 -0
- package/dist/watermark/index.js +149 -0
- package/package.json +122 -2
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { EditorState, Transaction } from "prosemirror-state";
|
|
2
|
+
|
|
3
|
+
//#region src/managers/editorShortcuts.d.ts
|
|
4
|
+
declare function isMacPlatform(): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* `target` is an input-like element that the user is typing into. We must
|
|
7
|
+
* not intercept Delete/Backspace there — only when focus is in the editor
|
|
8
|
+
* surface (or nowhere at all).
|
|
9
|
+
*/
|
|
10
|
+
declare function isFocusInInputLike(target: EventTarget | null, editorDom: HTMLElement | null | undefined): boolean;
|
|
11
|
+
/** The editor action a keydown maps to, or `none` when it is not a shortcut. */
|
|
12
|
+
type EditorKeydownIntent = {
|
|
13
|
+
type: "deleteSelectedTable";
|
|
14
|
+
} | {
|
|
15
|
+
type: "openFind";
|
|
16
|
+
} | {
|
|
17
|
+
type: "print";
|
|
18
|
+
} | {
|
|
19
|
+
type: "none";
|
|
20
|
+
};
|
|
21
|
+
type ClassifyEditorKeydownOptions = {
|
|
22
|
+
/** Whether the platform uses Cmd (Mac) rather than Ctrl as the primary modifier. */isMac: boolean; /** Whether focus is in a non-editor input/textarea/contenteditable. */
|
|
23
|
+
isInputLike: boolean;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Map a keydown to an editor intent:
|
|
27
|
+
* - Cmd/Ctrl+F or Cmd/Ctrl+H → open find
|
|
28
|
+
* - Cmd/Ctrl+P (no auto-repeat) → custom print
|
|
29
|
+
* - Delete/Backspace (no modifiers, focus not in an input) → delete selected table
|
|
30
|
+
*/
|
|
31
|
+
declare function classifyEditorKeydown(e: KeyboardEvent, {
|
|
32
|
+
isMac,
|
|
33
|
+
isInputLike
|
|
34
|
+
}: ClassifyEditorKeydownOptions): EditorKeydownIntent;
|
|
35
|
+
/**
|
|
36
|
+
* If the selection is a ProseMirror `CellSelection` covering every cell of its
|
|
37
|
+
* table, delete the table and return `true`. Returns `false` for any other
|
|
38
|
+
* selection so the caller can fall back to a layout-overlay table selection.
|
|
39
|
+
*/
|
|
40
|
+
declare function deleteSelectedTable(state: EditorState, dispatch: (tr: Transaction) => void): boolean;
|
|
41
|
+
//#endregion
|
|
42
|
+
export { ClassifyEditorKeydownOptions, EditorKeydownIntent, classifyEditorKeydown, deleteSelectedTable, isFocusInInputLike, isMacPlatform };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { getTableContext } from "../prosemirror/extensions/nodes/TableExtension.js";
|
|
2
|
+
import { deleteTable } from "../prosemirror/commands/table.js";
|
|
3
|
+
//#region src/managers/editorShortcuts.ts
|
|
4
|
+
function isMacPlatform() {
|
|
5
|
+
if (typeof navigator === "undefined") return false;
|
|
6
|
+
return /Mac|iPod|iPhone|iPad/u.test(navigator.platform);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* `target` is an input-like element that the user is typing into. We must
|
|
10
|
+
* not intercept Delete/Backspace there — only when focus is in the editor
|
|
11
|
+
* surface (or nowhere at all).
|
|
12
|
+
*/
|
|
13
|
+
function isFocusInInputLike(target, editorDom) {
|
|
14
|
+
if (!(target instanceof HTMLElement)) return false;
|
|
15
|
+
if (target.tagName === "INPUT" || target.tagName === "TEXTAREA") return true;
|
|
16
|
+
if (target.isContentEditable && target !== editorDom) return true;
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Map a keydown to an editor intent:
|
|
21
|
+
* - Cmd/Ctrl+F or Cmd/Ctrl+H → open find
|
|
22
|
+
* - Cmd/Ctrl+P (no auto-repeat) → custom print
|
|
23
|
+
* - Delete/Backspace (no modifiers, focus not in an input) → delete selected table
|
|
24
|
+
*/
|
|
25
|
+
function classifyEditorKeydown(e, { isMac, isInputLike }) {
|
|
26
|
+
const cmdOrCtrl = isMac ? e.metaKey : e.ctrlKey;
|
|
27
|
+
if (!cmdOrCtrl && !e.shiftKey && !e.altKey && (e.key === "Delete" || e.key === "Backspace") && !isInputLike) return { type: "deleteSelectedTable" };
|
|
28
|
+
if (cmdOrCtrl && !e.shiftKey && !e.altKey) {
|
|
29
|
+
const key = e.key.toLowerCase();
|
|
30
|
+
if (key === "f" || key === "h") return { type: "openFind" };
|
|
31
|
+
if (key === "p" && !e.repeat) return { type: "print" };
|
|
32
|
+
}
|
|
33
|
+
return { type: "none" };
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* If the selection is a ProseMirror `CellSelection` covering every cell of its
|
|
37
|
+
* table, delete the table and return `true`. Returns `false` for any other
|
|
38
|
+
* selection so the caller can fall back to a layout-overlay table selection.
|
|
39
|
+
*/
|
|
40
|
+
function deleteSelectedTable(state, dispatch) {
|
|
41
|
+
const sel = state.selection;
|
|
42
|
+
if (!("$anchorCell" in sel && typeof sel.forEachCell === "function")) return false;
|
|
43
|
+
const context = getTableContext(state);
|
|
44
|
+
if (!(context.isInTable && context.table)) return false;
|
|
45
|
+
let totalCells = 0;
|
|
46
|
+
context.table.descendants((node) => {
|
|
47
|
+
if (node.type.name === "tableCell" || node.type.name === "tableHeader") totalCells += 1;
|
|
48
|
+
});
|
|
49
|
+
let selectedCells = 0;
|
|
50
|
+
sel.forEachCell(() => {
|
|
51
|
+
selectedCells += 1;
|
|
52
|
+
});
|
|
53
|
+
if (totalCells > 0 && selectedCells >= totalCells) {
|
|
54
|
+
deleteTable(state, dispatch);
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
//#endregion
|
|
60
|
+
export { classifyEditorKeydown, deleteSelectedTable, isFocusInInputLike, isMacPlatform };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
//#region src/managers/types.d.ts
|
|
2
|
+
/** Cell coordinates in a table */
|
|
3
|
+
type CellCoordinates = {
|
|
4
|
+
tableIndex: number;
|
|
5
|
+
rowIndex: number;
|
|
6
|
+
columnIndex: number;
|
|
7
|
+
};
|
|
8
|
+
/** Viewport anchor (px) where the context menu opens. */
|
|
9
|
+
type ContextMenuAnchor = {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
};
|
|
13
|
+
/** ContextMenuManager snapshot. */
|
|
14
|
+
type ContextMenuSnapshot = {
|
|
15
|
+
isOpen: boolean;
|
|
16
|
+
position: ContextMenuAnchor;
|
|
17
|
+
hasSelection: boolean;
|
|
18
|
+
selectionRange: {
|
|
19
|
+
from: number;
|
|
20
|
+
to: number;
|
|
21
|
+
};
|
|
22
|
+
cursorInTable: boolean;
|
|
23
|
+
cursorInTrackedChange: boolean;
|
|
24
|
+
};
|
|
25
|
+
/** Error severity levels */
|
|
26
|
+
type ErrorSeverity = "error" | "warning" | "info";
|
|
27
|
+
/** Error notification */
|
|
28
|
+
type ErrorNotification = {
|
|
29
|
+
id: string;
|
|
30
|
+
message: string;
|
|
31
|
+
severity: ErrorSeverity;
|
|
32
|
+
details?: string;
|
|
33
|
+
timestamp: number;
|
|
34
|
+
dismissed?: boolean;
|
|
35
|
+
};
|
|
36
|
+
/** ErrorManager snapshot */
|
|
37
|
+
type ErrorManagerSnapshot = {
|
|
38
|
+
notifications: ErrorNotification[];
|
|
39
|
+
};
|
|
40
|
+
//#endregion
|
|
41
|
+
export { CellCoordinates, ContextMenuAnchor, ContextMenuSnapshot, ErrorManagerSnapshot, ErrorNotification, ErrorSeverity };
|
|
File without changes
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { RenderContext } from "./types.js";
|
|
3
|
+
|
|
4
|
+
//#region src/markdown/annotations.d.ts
|
|
5
|
+
declare function wrapInsertion(ctx: RenderContext, info: document_d_exports.TrackedChangeInfo, inner: string): string;
|
|
6
|
+
declare function wrapDeletion(ctx: RenderContext, info: document_d_exports.TrackedChangeInfo, inner: string): string;
|
|
7
|
+
declare function wrapMoveFrom(ctx: RenderContext, info: document_d_exports.TrackedChangeInfo, inner: string): string;
|
|
8
|
+
declare function wrapMoveTo(ctx: RenderContext, info: document_d_exports.TrackedChangeInfo, inner: string): string;
|
|
9
|
+
declare function wrapComment(ctx: RenderContext, meta: {
|
|
10
|
+
id: number;
|
|
11
|
+
author?: string;
|
|
12
|
+
}, inner: string): string;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { wrapComment, wrapDeletion, wrapInsertion, wrapMoveFrom, wrapMoveTo };
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
//#region src/markdown/annotations.ts
|
|
2
|
+
function escapeAttr(value) {
|
|
3
|
+
return value.replace(/&/gu, "&").replace(/</gu, "<").replace(/>/gu, ">").replace(/"/gu, """);
|
|
4
|
+
}
|
|
5
|
+
function attrString(info) {
|
|
6
|
+
const parts = [];
|
|
7
|
+
if (info.author) parts.push(`author="${escapeAttr(info.author)}"`);
|
|
8
|
+
if (info.date) parts.push(`date="${escapeAttr(info.date)}"`);
|
|
9
|
+
if (typeof info.id === "number") parts.push(`id="${info.id}"`);
|
|
10
|
+
return parts.length ? ` ${parts.join(" ")}` : "";
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Wrap `inner` with the active annotations mode's encoding.
|
|
14
|
+
*
|
|
15
|
+
* `keepWhenStripped` controls what to emit when `annotations === "strip"`:
|
|
16
|
+
* insertions and comments keep the visible text; deletions drop entirely.
|
|
17
|
+
*/
|
|
18
|
+
function wrap(ctx, inner, htmlTag, pandocClass, info, extraHtmlAttrs, mode, keepWhenStripped) {
|
|
19
|
+
if (ctx.opts.annotations === "strip") return keepWhenStripped ? inner : "";
|
|
20
|
+
if (ctx.opts.annotations === "pandoc") {
|
|
21
|
+
const author = info.author ? ` author="${escapeAttr(info.author)}"` : "";
|
|
22
|
+
return `[${inner}]{.${pandocClass}${mode === "comment" && typeof info.id === "number" ? ` id="${info.id}"` : ""}${author}}`;
|
|
23
|
+
}
|
|
24
|
+
return `<${htmlTag}${attrString(info)}${extraHtmlAttrs}>${inner}</${htmlTag}>`;
|
|
25
|
+
}
|
|
26
|
+
function wrapInsertion(ctx, info, inner) {
|
|
27
|
+
return wrap(ctx, inner, "ins", "ins", info, "", "tracked", true);
|
|
28
|
+
}
|
|
29
|
+
function wrapDeletion(ctx, info, inner) {
|
|
30
|
+
return wrap(ctx, inner, "del", "del", info, "", "tracked", false);
|
|
31
|
+
}
|
|
32
|
+
function wrapMoveFrom(ctx, info, inner) {
|
|
33
|
+
return wrap(ctx, inner, "del", "move-from", info, " data-move=\"from\"", "tracked", false);
|
|
34
|
+
}
|
|
35
|
+
function wrapMoveTo(ctx, info, inner) {
|
|
36
|
+
return wrap(ctx, inner, "ins", "move-to", info, " data-move=\"to\"", "tracked", true);
|
|
37
|
+
}
|
|
38
|
+
function wrapComment(ctx, meta, inner) {
|
|
39
|
+
return wrap(ctx, inner, "comment", "comment", meta, "", "comment", true);
|
|
40
|
+
}
|
|
41
|
+
//#endregion
|
|
42
|
+
export { wrapComment, wrapDeletion, wrapInsertion, wrapMoveFrom, wrapMoveTo };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
//#region src/markdown/escape.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Markdown escaping. Only characters that would change the parsed structure
|
|
4
|
+
* get escaped. Context-sensitive: pipes only matter inside table cells.
|
|
5
|
+
*
|
|
6
|
+
* Ported from eigenpal/docx-editor PR #595 (`@eigenpal/docx-editor-core/markdown`).
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Escape only characters that would change markdown structure mid-text:
|
|
10
|
+
* - backslash, backtick, asterisk, brackets (always)
|
|
11
|
+
* - underscore: only at word boundaries (emphasis trigger)
|
|
12
|
+
* - angle brackets: only when they look like a tag/autolink
|
|
13
|
+
*
|
|
14
|
+
* Characters like `.` `-` `+` `#` `(` `)` `!` are only meaningful at line
|
|
15
|
+
* starts or in specific adjacency; we let the block-level renderer decide
|
|
16
|
+
* when to escape those.
|
|
17
|
+
*/
|
|
18
|
+
declare function escapeInline(text: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Cells use `|` as the column separator. The input is already markdown (each
|
|
21
|
+
* cell is a rendered paragraph that ran through {@link escapeInline}), so a
|
|
22
|
+
* backslash escape would interact with existing escape sequences — encode the
|
|
23
|
+
* pipe as the HTML entity instead, which GFM renders as a literal `|` without
|
|
24
|
+
* treating it as a delimiter. Newlines become `<br>` to keep the row on one
|
|
25
|
+
* line.
|
|
26
|
+
*/
|
|
27
|
+
declare function escapeTableCell(text: string): string;
|
|
28
|
+
declare function escapeLinkUrl(url: string): string;
|
|
29
|
+
/**
|
|
30
|
+
* Alt text inside ``. Raw (un-escaped) text, so escape the backslash
|
|
31
|
+
* first, then the brackets that would confuse the link parser, and collapse
|
|
32
|
+
* newlines so the alt stays single-line.
|
|
33
|
+
*/
|
|
34
|
+
declare function escapeAltText(text: string): string;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { escapeAltText, escapeInline, escapeLinkUrl, escapeTableCell };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
//#region src/markdown/escape.ts
|
|
2
|
+
/**
|
|
3
|
+
* Markdown escaping. Only characters that would change the parsed structure
|
|
4
|
+
* get escaped. Context-sensitive: pipes only matter inside table cells.
|
|
5
|
+
*
|
|
6
|
+
* Ported from eigenpal/docx-editor PR #595 (`@eigenpal/docx-editor-core/markdown`).
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Escape only characters that would change markdown structure mid-text:
|
|
10
|
+
* - backslash, backtick, asterisk, brackets (always)
|
|
11
|
+
* - underscore: only at word boundaries (emphasis trigger)
|
|
12
|
+
* - angle brackets: only when they look like a tag/autolink
|
|
13
|
+
*
|
|
14
|
+
* Characters like `.` `-` `+` `#` `(` `)` `!` are only meaningful at line
|
|
15
|
+
* starts or in specific adjacency; we let the block-level renderer decide
|
|
16
|
+
* when to escape those.
|
|
17
|
+
*/
|
|
18
|
+
function escapeInline(text) {
|
|
19
|
+
let out = text.replace(/(?<ch>[\\`*[\]])/gu, "\\$<ch>");
|
|
20
|
+
out = out.replace(/(?<pre>^|\s)_/gu, "$<pre>\\_");
|
|
21
|
+
out = out.replace(/_(?<post>\s|$)/gu, "\\_$<post>");
|
|
22
|
+
out = out.replace(/<(?<tag>\/?[A-Za-z][\w-]*)(?=[\s/>])/gu, "\\<$<tag>");
|
|
23
|
+
return out;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Cells use `|` as the column separator. The input is already markdown (each
|
|
27
|
+
* cell is a rendered paragraph that ran through {@link escapeInline}), so a
|
|
28
|
+
* backslash escape would interact with existing escape sequences — encode the
|
|
29
|
+
* pipe as the HTML entity instead, which GFM renders as a literal `|` without
|
|
30
|
+
* treating it as a delimiter. Newlines become `<br>` to keep the row on one
|
|
31
|
+
* line.
|
|
32
|
+
*/
|
|
33
|
+
function escapeTableCell(text) {
|
|
34
|
+
return text.replace(/\|/gu, "|").replace(/\r?\n/gu, "<br>");
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Hyperlink URLs in inline form need parens balanced; we URL-encode the
|
|
38
|
+
* problematic characters rather than escape, so the link still resolves.
|
|
39
|
+
* `encodeURIComponent` leaves `(` and `)` untouched, so an unbalanced paren in
|
|
40
|
+
* a DOCX URL (e.g. `https://example.com/a)b`) would close the inline
|
|
41
|
+
* `[text](url)` destination early; encode the parens explicitly.
|
|
42
|
+
*/
|
|
43
|
+
const LINK_URL_ENCODED = {
|
|
44
|
+
"(": "%28",
|
|
45
|
+
")": "%29"
|
|
46
|
+
};
|
|
47
|
+
function escapeLinkUrl(url) {
|
|
48
|
+
return url.replace(/[()<>"\s]/gu, (ch) => LINK_URL_ENCODED[ch] ?? encodeURIComponent(ch));
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Alt text inside ``. Raw (un-escaped) text, so escape the backslash
|
|
52
|
+
* first, then the brackets that would confuse the link parser, and collapse
|
|
53
|
+
* newlines so the alt stays single-line.
|
|
54
|
+
*/
|
|
55
|
+
function escapeAltText(text) {
|
|
56
|
+
return text.replace(/(?<ch>[\\[\]])/gu, "\\$<ch>").replace(/\r?\n/gu, " ");
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
export { escapeAltText, escapeInline, escapeLinkUrl, escapeTableCell };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
|
|
3
|
+
//#region src/markdown/fromMarkdown.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Convert a markdown string to a parsed `Document`. Synchronous. The result is
|
|
6
|
+
* ready to hand to the editor (`<DocxEditor document={…} />`) and to re-export
|
|
7
|
+
* via {@link toMarkdown}.
|
|
8
|
+
*/
|
|
9
|
+
declare function fromMarkdown(markdown: string): document_d_exports.Document;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { fromMarkdown };
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
import { createEmptyDocument } from "../utils/createDocument.js";
|
|
2
|
+
import { sanitizeExternalUrl } from "../utils/urlSecurity.js";
|
|
3
|
+
import { marked } from "marked";
|
|
4
|
+
//#region src/markdown/fromMarkdown.ts
|
|
5
|
+
/**
|
|
6
|
+
* Markdown → DOCX-document import — the inverse of {@link toMarkdown} and the
|
|
7
|
+
* second half of the skills bridge. Parses the GFM subset skill bodies use
|
|
8
|
+
* (headings, paragraphs, bold/italic/strike, inline code, bullet + ordered
|
|
9
|
+
* lists incl. nesting, pipe tables, blockquotes, links) into the docx
|
|
10
|
+
* `Document` model so a skill's markdown can be edited in the Folio editor and
|
|
11
|
+
* re-exported with {@link toMarkdown} without drift.
|
|
12
|
+
*
|
|
13
|
+
* Round-trip notes:
|
|
14
|
+
* - Lists are emitted as real list paragraphs (`listRendering`), so the editor
|
|
15
|
+
* shows a marker and {@link toMarkdown} re-derives `- ` / `1. ` rather than
|
|
16
|
+
* leaking a literal bullet glyph into the text.
|
|
17
|
+
* - Inline code uses `Courier New` — a whitelisted monospace family that
|
|
18
|
+
* {@link toMarkdown} infers back to a backtick span (Folio renders it via its
|
|
19
|
+
* bundled Cousine substitute).
|
|
20
|
+
* - Markdown carries no page geometry, so the section is flattened to a
|
|
21
|
+
* continuous, header/footer-free band (a skill body is a document, not a
|
|
22
|
+
* Word page). Headers/footers live outside `document.content` and are never
|
|
23
|
+
* produced here.
|
|
24
|
+
*/
|
|
25
|
+
const MONO_FONT = {
|
|
26
|
+
ascii: "Courier New",
|
|
27
|
+
hAnsi: "Courier New"
|
|
28
|
+
};
|
|
29
|
+
const isTokenType = (token, type) => token.type === type;
|
|
30
|
+
const textRun = (text, fmt = {}) => {
|
|
31
|
+
const formatting = {
|
|
32
|
+
...fmt.bold ? { bold: true } : {},
|
|
33
|
+
...fmt.italic ? { italic: true } : {},
|
|
34
|
+
...fmt.strike ? { strike: true } : {},
|
|
35
|
+
...fmt.mono ? { fontFamily: MONO_FONT } : {}
|
|
36
|
+
};
|
|
37
|
+
const segments = text.split("\n");
|
|
38
|
+
const content = [];
|
|
39
|
+
for (const [index, segment] of segments.entries()) {
|
|
40
|
+
if (index > 0) content.push({ type: "break" });
|
|
41
|
+
if (segment.length > 0) content.push({
|
|
42
|
+
type: "text",
|
|
43
|
+
text: segment
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
if (content.length === 0) content.push({
|
|
47
|
+
type: "text",
|
|
48
|
+
text: ""
|
|
49
|
+
});
|
|
50
|
+
return {
|
|
51
|
+
type: "run",
|
|
52
|
+
formatting,
|
|
53
|
+
content
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
const sanitizeMarkdownHref = (rawHref) => {
|
|
57
|
+
const trimmed = rawHref.trim();
|
|
58
|
+
if (!trimmed) return;
|
|
59
|
+
if (trimmed.startsWith("#")) {
|
|
60
|
+
const anchor = trimmed.slice(1);
|
|
61
|
+
if (!anchor || hasUnsafeAnchorCharacter(anchor)) return;
|
|
62
|
+
return `#${anchor}`;
|
|
63
|
+
}
|
|
64
|
+
return sanitizeExternalUrl(trimmed);
|
|
65
|
+
};
|
|
66
|
+
const hasUnsafeAnchorCharacter = (anchor) => {
|
|
67
|
+
for (const char of anchor) {
|
|
68
|
+
const codePoint = char.codePointAt(0) ?? 0;
|
|
69
|
+
if (codePoint <= 32 || codePoint === 127 || char.trim() === "") return true;
|
|
70
|
+
}
|
|
71
|
+
return false;
|
|
72
|
+
};
|
|
73
|
+
const inlineToRuns = (tokens, fallback, base) => {
|
|
74
|
+
if (!tokens || tokens.length === 0) return [textRun(fallback, base)];
|
|
75
|
+
const runs = [];
|
|
76
|
+
for (const token of tokens) if (isTokenType(token, "strong")) runs.push(...inlineToRuns(token.tokens, token.text, {
|
|
77
|
+
...base,
|
|
78
|
+
bold: true
|
|
79
|
+
}));
|
|
80
|
+
else if (isTokenType(token, "em")) runs.push(...inlineToRuns(token.tokens, token.text, {
|
|
81
|
+
...base,
|
|
82
|
+
italic: true
|
|
83
|
+
}));
|
|
84
|
+
else if (isTokenType(token, "del")) runs.push(...inlineToRuns(token.tokens, token.text, {
|
|
85
|
+
...base,
|
|
86
|
+
strike: true
|
|
87
|
+
}));
|
|
88
|
+
else if (isTokenType(token, "codespan")) runs.push(textRun(token.text, {
|
|
89
|
+
...base,
|
|
90
|
+
mono: true
|
|
91
|
+
}));
|
|
92
|
+
else if (isTokenType(token, "link")) {
|
|
93
|
+
const children = inlineToRuns(token.tokens, token.text, base).filter((child) => child.type === "run");
|
|
94
|
+
const href = sanitizeMarkdownHref(token.href);
|
|
95
|
+
const linkChildren = children.length > 0 ? children : [textRun(token.text, base)];
|
|
96
|
+
if (!href) {
|
|
97
|
+
runs.push(...linkChildren);
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const anchor = href.startsWith("#") ? href.slice(1) : void 0;
|
|
101
|
+
runs.push({
|
|
102
|
+
type: "hyperlink",
|
|
103
|
+
href,
|
|
104
|
+
...anchor ? { anchor } : {},
|
|
105
|
+
children: linkChildren
|
|
106
|
+
});
|
|
107
|
+
} else if (isTokenType(token, "paragraph")) runs.push(...inlineToRuns(token.tokens, token.text, base));
|
|
108
|
+
else if (token.type === "br") runs.push({
|
|
109
|
+
type: "run",
|
|
110
|
+
content: [{ type: "break" }]
|
|
111
|
+
});
|
|
112
|
+
else if (token.type === "space") {
|
|
113
|
+
if (runs.length > 0 && token.raw.includes("\n")) runs.push(textRun("\n", base));
|
|
114
|
+
} else if (isTokenType(token, "text")) {
|
|
115
|
+
const nested = token.tokens;
|
|
116
|
+
if (nested && nested.length > 0) runs.push(...inlineToRuns(nested, token.text, base));
|
|
117
|
+
else runs.push(textRun(token.text, base));
|
|
118
|
+
} else if ("text" in token && typeof token.text === "string") runs.push(textRun(token.text, base));
|
|
119
|
+
return runs.length > 0 ? runs : [textRun(fallback, base)];
|
|
120
|
+
};
|
|
121
|
+
const para = (runs, styleId) => ({
|
|
122
|
+
type: "paragraph",
|
|
123
|
+
formatting: styleId ? { styleId } : {},
|
|
124
|
+
content: runs.length > 0 ? runs : [textRun("")]
|
|
125
|
+
});
|
|
126
|
+
const listPara = (runs, rendering) => ({
|
|
127
|
+
type: "paragraph",
|
|
128
|
+
formatting: { numPr: {
|
|
129
|
+
numId: rendering.numId,
|
|
130
|
+
ilvl: rendering.level
|
|
131
|
+
} },
|
|
132
|
+
listRendering: rendering,
|
|
133
|
+
content: runs.length > 0 ? runs : [textRun("")]
|
|
134
|
+
});
|
|
135
|
+
const cellOf = (cell) => ({
|
|
136
|
+
type: "tableCell",
|
|
137
|
+
content: [para(inlineToRuns(cell.tokens, cell.text, {}))]
|
|
138
|
+
});
|
|
139
|
+
const tableFromToken = (token) => ({
|
|
140
|
+
type: "table",
|
|
141
|
+
rows: [{
|
|
142
|
+
type: "tableRow",
|
|
143
|
+
cells: token.header.map((c) => cellOf(c))
|
|
144
|
+
}, ...token.rows.map((row) => ({
|
|
145
|
+
type: "tableRow",
|
|
146
|
+
cells: row.map((c) => cellOf(c))
|
|
147
|
+
}))]
|
|
148
|
+
});
|
|
149
|
+
const listBlocks = (list, level, numId) => {
|
|
150
|
+
const out = [];
|
|
151
|
+
const start = Number(list.start) || 1;
|
|
152
|
+
const decimalLevels = Array.from({ length: level + 1 }, () => "decimal");
|
|
153
|
+
for (const item of list.items) {
|
|
154
|
+
const rendering = list.ordered ? {
|
|
155
|
+
marker: `%${level + 1}.`,
|
|
156
|
+
level,
|
|
157
|
+
numId,
|
|
158
|
+
isBullet: false,
|
|
159
|
+
numFmt: "decimal",
|
|
160
|
+
levelNumFmts: decimalLevels,
|
|
161
|
+
...start !== 1 && { startOverride: start }
|
|
162
|
+
} : {
|
|
163
|
+
marker: "•",
|
|
164
|
+
level,
|
|
165
|
+
numId,
|
|
166
|
+
isBullet: true
|
|
167
|
+
};
|
|
168
|
+
const inlineTokens = [];
|
|
169
|
+
const nestedLists = [];
|
|
170
|
+
for (const child of item.tokens) if (isTokenType(child, "list")) nestedLists.push(child);
|
|
171
|
+
else inlineTokens.push(child);
|
|
172
|
+
out.push(listPara(inlineToRuns(inlineTokens, item.text, {}), rendering));
|
|
173
|
+
for (const nested of nestedLists) out.push(...listBlocks(nested, level + 1, numId));
|
|
174
|
+
}
|
|
175
|
+
return out;
|
|
176
|
+
};
|
|
177
|
+
const blocksFromTokens = (tokens, numIds) => {
|
|
178
|
+
const blocks = [];
|
|
179
|
+
for (const token of tokens ?? []) if (isTokenType(token, "heading")) {
|
|
180
|
+
const level = Math.min(Math.max(token.depth, 1), 4);
|
|
181
|
+
blocks.push(para(inlineToRuns(token.tokens, token.text, {}), `Heading${level}`));
|
|
182
|
+
} else if (isTokenType(token, "paragraph")) blocks.push(para(inlineToRuns(token.tokens, token.text, {})));
|
|
183
|
+
else if (isTokenType(token, "list")) blocks.push(...listBlocks(token, 0, numIds.next++));
|
|
184
|
+
else if (isTokenType(token, "table")) blocks.push(tableFromToken(token));
|
|
185
|
+
else if (isTokenType(token, "code")) for (const line of token.text.split("\n")) blocks.push(para([textRun(line.length > 0 ? line : " ", { mono: true })]));
|
|
186
|
+
else if (isTokenType(token, "blockquote")) for (const inner of blocksFromTokens(token.tokens, numIds)) {
|
|
187
|
+
const styled = inner.type === "paragraph" ? {
|
|
188
|
+
...inner,
|
|
189
|
+
formatting: {
|
|
190
|
+
...inner.formatting,
|
|
191
|
+
styleId: "Quote"
|
|
192
|
+
}
|
|
193
|
+
} : inner;
|
|
194
|
+
blocks.push(styled);
|
|
195
|
+
}
|
|
196
|
+
else if (token.type === "hr") blocks.push(para([textRun("———")]));
|
|
197
|
+
else if (token.type !== "space" && "text" in token && typeof token.text === "string" && token.text.trim().length > 0) blocks.push(para([textRun(token.text)]));
|
|
198
|
+
return blocks;
|
|
199
|
+
};
|
|
200
|
+
const applyMarkdownPageGeometry = (document) => {
|
|
201
|
+
const section = document.package.document.finalSectionProperties;
|
|
202
|
+
if (!section) return;
|
|
203
|
+
section.marginTop = 480;
|
|
204
|
+
section.marginBottom = 480;
|
|
205
|
+
section.marginLeft = 480;
|
|
206
|
+
section.marginRight = 480;
|
|
207
|
+
section.headerDistance = 0;
|
|
208
|
+
section.footerDistance = 0;
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* Convert a markdown string to a parsed `Document`. Synchronous. The result is
|
|
212
|
+
* ready to hand to the editor (`<DocxEditor document={…} />`) and to re-export
|
|
213
|
+
* via {@link toMarkdown}.
|
|
214
|
+
*/
|
|
215
|
+
function fromMarkdown(markdown) {
|
|
216
|
+
const document = createEmptyDocument();
|
|
217
|
+
const blocks = blocksFromTokens(marked.lexer(markdown), { next: 1 });
|
|
218
|
+
if (blocks.length > 0) document.package.document.content = blocks;
|
|
219
|
+
applyMarkdownPageGeometry(document);
|
|
220
|
+
return document;
|
|
221
|
+
}
|
|
222
|
+
//#endregion
|
|
223
|
+
export { fromMarkdown };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/markdown/headings.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Heading-style detection from a paragraph style id. Ported from eigenpal
|
|
4
|
+
* `agent/text-utils` (PR #595) so the markdown exporter stays self-contained
|
|
5
|
+
* (folio has no `agent/text-utils` module). Word's built-in heading styles are
|
|
6
|
+
* `Heading1`…`Heading9` (and localised aliases that still contain "heading").
|
|
7
|
+
*/
|
|
8
|
+
/** True when the style id denotes a Word heading style. */
|
|
9
|
+
declare function isHeadingStyle(styleId?: string): boolean;
|
|
10
|
+
/** Extract the 1-based heading level from a style id, or undefined. */
|
|
11
|
+
declare function parseHeadingLevel(styleId?: string): number | undefined;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { isHeadingStyle, parseHeadingLevel };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/markdown/headings.ts
|
|
2
|
+
/**
|
|
3
|
+
* Heading-style detection from a paragraph style id. Ported from eigenpal
|
|
4
|
+
* `agent/text-utils` (PR #595) so the markdown exporter stays self-contained
|
|
5
|
+
* (folio has no `agent/text-utils` module). Word's built-in heading styles are
|
|
6
|
+
* `Heading1`…`Heading9` (and localised aliases that still contain "heading").
|
|
7
|
+
*/
|
|
8
|
+
/** True when the style id denotes a Word heading style. */
|
|
9
|
+
function isHeadingStyle(styleId) {
|
|
10
|
+
if (!styleId) return false;
|
|
11
|
+
return styleId.toLowerCase().includes("heading");
|
|
12
|
+
}
|
|
13
|
+
/** Extract the 1-based heading level from a style id, or undefined. */
|
|
14
|
+
function parseHeadingLevel(styleId) {
|
|
15
|
+
if (!styleId) return;
|
|
16
|
+
const digit = /heading\s*(?<level>\d)/iu.exec(styleId)?.groups?.["level"];
|
|
17
|
+
if (digit) return Number.parseInt(digit, 10);
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
export { isHeadingStyle, parseHeadingLevel };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { ImageRef, RenderContext } from "./types.js";
|
|
3
|
+
|
|
4
|
+
//#region src/markdown/images.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Build an `ImageRef` from a `MediaFile` and store it in the context's image
|
|
7
|
+
* map. If the same `media.path` has already been registered for this render,
|
|
8
|
+
* the existing ref is returned without re-encoding base64 or assigning a new
|
|
9
|
+
* virtual path.
|
|
10
|
+
*/
|
|
11
|
+
declare function registerImage(ctx: RenderContext, media: document_d_exports.MediaFile, image: document_d_exports.Image | undefined, paraId: string | undefined): ImageRef;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { registerImage };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
//#region src/markdown/images.ts
|
|
2
|
+
const MIME_TO_EXT = {
|
|
3
|
+
"image/png": "png",
|
|
4
|
+
"image/jpeg": "jpg",
|
|
5
|
+
"image/jpg": "jpg",
|
|
6
|
+
"image/gif": "gif",
|
|
7
|
+
"image/svg+xml": "svg",
|
|
8
|
+
"image/webp": "webp",
|
|
9
|
+
"image/tiff": "tiff",
|
|
10
|
+
"image/bmp": "bmp",
|
|
11
|
+
"image/x-emf": "emf",
|
|
12
|
+
"image/x-wmf": "wmf"
|
|
13
|
+
};
|
|
14
|
+
function extFor(mimeType, fallback) {
|
|
15
|
+
return MIME_TO_EXT[mimeType] ?? fallback;
|
|
16
|
+
}
|
|
17
|
+
function bytesToBase64(bytes) {
|
|
18
|
+
if (typeof Buffer !== "undefined") return Buffer.from(bytes).toString("base64");
|
|
19
|
+
return btoa(new TextDecoder("latin1").decode(bytes));
|
|
20
|
+
}
|
|
21
|
+
function toUint8(data) {
|
|
22
|
+
if (data instanceof Uint8Array) return data;
|
|
23
|
+
return new Uint8Array(data);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Build an `ImageRef` from a `MediaFile` and store it in the context's image
|
|
27
|
+
* map. If the same `media.path` has already been registered for this render,
|
|
28
|
+
* the existing ref is returned without re-encoding base64 or assigning a new
|
|
29
|
+
* virtual path.
|
|
30
|
+
*/
|
|
31
|
+
function registerImage(ctx, media, image, paraId) {
|
|
32
|
+
const existing = ctx.imagesByPath.get(media.path);
|
|
33
|
+
if (existing) return existing;
|
|
34
|
+
ctx.imageCounter += 1;
|
|
35
|
+
const ext = extFor(media.mimeType, "png");
|
|
36
|
+
const meta = {
|
|
37
|
+
paraId,
|
|
38
|
+
index: ctx.imageCounter,
|
|
39
|
+
originalPath: media.path,
|
|
40
|
+
mimeType: media.mimeType,
|
|
41
|
+
alt: image?.alt ?? image?.title ?? image?.filename
|
|
42
|
+
};
|
|
43
|
+
const virtualPath = ctx.opts.imagePath ? ctx.opts.imagePath(meta) : defaultVirtualPath(meta, ext);
|
|
44
|
+
const data = toUint8(media.data);
|
|
45
|
+
const base64 = media.base64 ?? bytesToBase64(data);
|
|
46
|
+
const dataUrl = media.dataUrl ?? `data:${media.mimeType};base64,${base64}`;
|
|
47
|
+
const ref = {
|
|
48
|
+
...meta,
|
|
49
|
+
data,
|
|
50
|
+
base64,
|
|
51
|
+
dataUrl,
|
|
52
|
+
virtualPath
|
|
53
|
+
};
|
|
54
|
+
ctx.images.set(virtualPath, ref);
|
|
55
|
+
ctx.imagesByPath.set(media.path, ref);
|
|
56
|
+
return ref;
|
|
57
|
+
}
|
|
58
|
+
function defaultVirtualPath(meta, ext) {
|
|
59
|
+
if (meta.paraId) return `./images/${meta.paraId}-img${meta.index}.${ext}`;
|
|
60
|
+
return `./images/img${meta.index}.${ext}`;
|
|
61
|
+
}
|
|
62
|
+
//#endregion
|
|
63
|
+
export { registerImage };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { document_d_exports } from "../types/document.js";
|
|
2
|
+
import { ImageMeta, ImageRef, MarkdownOptions, MarkdownResult } from "./types.js";
|
|
3
|
+
import { fromMarkdown } from "./fromMarkdown.js";
|
|
4
|
+
|
|
5
|
+
//#region src/markdown/index.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Convert a parsed `Document` to a markdown string. Synchronous; pre-parse the
|
|
8
|
+
* DOCX (e.g. via the editor or `parseDocx`) before calling.
|
|
9
|
+
*/
|
|
10
|
+
declare function toMarkdown(doc: document_d_exports.Document, opts?: MarkdownOptions): string;
|
|
11
|
+
/**
|
|
12
|
+
* Like {@link toMarkdown}, but also returns the registered images and any
|
|
13
|
+
* non-fatal warnings. Use when post-processing image bytes or surfacing
|
|
14
|
+
* diagnostics; skill bodies only need {@link toMarkdown}.
|
|
15
|
+
*/
|
|
16
|
+
declare function toMarkdownResult(doc: document_d_exports.Document, opts?: MarkdownOptions): MarkdownResult;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { type ImageMeta, type ImageRef, type MarkdownOptions, type MarkdownResult, fromMarkdown, toMarkdown, toMarkdownResult };
|