@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,283 @@
|
|
|
1
|
+
import { Plugin, PluginKey } from "prosemirror-state";
|
|
2
|
+
import { Decoration, DecorationSet } from "prosemirror-view";
|
|
3
|
+
//#region src/prosemirror/plugins/autocompleteSuggestion.ts
|
|
4
|
+
const IDLE = {
|
|
5
|
+
status: "idle",
|
|
6
|
+
anchor: null,
|
|
7
|
+
text: "",
|
|
8
|
+
requestId: null
|
|
9
|
+
};
|
|
10
|
+
const KEY_HOLDER_SYMBOL = Symbol.for("stll.folio.autocompleteSuggestionKey");
|
|
11
|
+
const keyHolder = globalThis;
|
|
12
|
+
const autocompleteSuggestionKey = keyHolder[KEY_HOLDER_SYMBOL] ?? (keyHolder[KEY_HOLDER_SYMBOL] = new PluginKey("autocompleteSuggestion"));
|
|
13
|
+
const buildAnchorWidget = () => {
|
|
14
|
+
const el = document.createElement("span");
|
|
15
|
+
el.dataset["folioAutocompleteAnchor"] = "true";
|
|
16
|
+
el.style.cssText = "display:inline-block;width:0;height:0;";
|
|
17
|
+
return el;
|
|
18
|
+
};
|
|
19
|
+
const buildInlineGhost = (text, isStreaming) => {
|
|
20
|
+
const ghost = document.createElement("span");
|
|
21
|
+
ghost.className = "folio-autocomplete-ghost";
|
|
22
|
+
ghost.append(document.createTextNode(text));
|
|
23
|
+
const caret = document.createElement("span");
|
|
24
|
+
caret.className = isStreaming ? "folio-autocomplete-caret folio-autocomplete-caret--streaming" : "folio-autocomplete-caret";
|
|
25
|
+
caret.setAttribute("aria-hidden", "true");
|
|
26
|
+
caret.append(document.createTextNode("stella"));
|
|
27
|
+
ghost.append(caret);
|
|
28
|
+
return ghost;
|
|
29
|
+
};
|
|
30
|
+
const buildDecorations = (state, doc, options) => {
|
|
31
|
+
if (state.status === "idle") return DecorationSet.empty;
|
|
32
|
+
const anchor = Math.max(0, Math.min(state.anchor, doc.content.size));
|
|
33
|
+
const isStreaming = state.status === "streaming";
|
|
34
|
+
const render = options.renderInline ? () => buildInlineGhost(state.text, isStreaming) : buildAnchorWidget;
|
|
35
|
+
return DecorationSet.create(doc, [Decoration.widget(anchor, render, {
|
|
36
|
+
side: 1,
|
|
37
|
+
ignoreSelection: true,
|
|
38
|
+
key: `stll-autocomplete:${state.text.length}:${state.requestId}`
|
|
39
|
+
})]);
|
|
40
|
+
};
|
|
41
|
+
const reduce = (prev, meta) => {
|
|
42
|
+
if (meta.type === "clear") return IDLE;
|
|
43
|
+
if (meta.type === "start") return {
|
|
44
|
+
status: "streaming",
|
|
45
|
+
anchor: meta.anchor,
|
|
46
|
+
text: "",
|
|
47
|
+
requestId: meta.requestId
|
|
48
|
+
};
|
|
49
|
+
if (meta.type === "token") {
|
|
50
|
+
if (prev.status === "idle" || prev.requestId !== meta.requestId) return prev;
|
|
51
|
+
return {
|
|
52
|
+
...prev,
|
|
53
|
+
status: "streaming",
|
|
54
|
+
text: prev.text + meta.delta
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
if (meta.type === "consume") {
|
|
58
|
+
if (prev.status === "idle" || prev.requestId !== meta.requestId) return prev;
|
|
59
|
+
if (meta.consumed.length >= prev.text.length) return IDLE;
|
|
60
|
+
return {
|
|
61
|
+
...prev,
|
|
62
|
+
anchor: prev.anchor + meta.consumed.length,
|
|
63
|
+
text: prev.text.slice(meta.consumed.length)
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
if (prev.status === "idle" || prev.requestId !== meta.requestId) return prev;
|
|
67
|
+
if (prev.text.length === 0) return IDLE;
|
|
68
|
+
return {
|
|
69
|
+
...prev,
|
|
70
|
+
status: "shown"
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
const autocompleteSuggestionPlugin = (options = {}) => {
|
|
74
|
+
const resolved = {
|
|
75
|
+
renderInline: options.renderInline ?? false,
|
|
76
|
+
keymap: options.keymap ?? false
|
|
77
|
+
};
|
|
78
|
+
return new Plugin({
|
|
79
|
+
key: autocompleteSuggestionKey,
|
|
80
|
+
state: {
|
|
81
|
+
init: (_config, instance) => ({
|
|
82
|
+
suggestion: IDLE,
|
|
83
|
+
decorations: buildDecorations(IDLE, instance.doc, resolved)
|
|
84
|
+
}),
|
|
85
|
+
apply: (tr, value, _oldState, newState) => {
|
|
86
|
+
const meta = tr.getMeta(autocompleteSuggestionKey);
|
|
87
|
+
if (!meta) {
|
|
88
|
+
if (tr.docChanged && value.suggestion.status !== "idle") return {
|
|
89
|
+
suggestion: IDLE,
|
|
90
|
+
decorations: DecorationSet.empty
|
|
91
|
+
};
|
|
92
|
+
return value;
|
|
93
|
+
}
|
|
94
|
+
const nextSuggestion = reduce(value.suggestion, meta);
|
|
95
|
+
return {
|
|
96
|
+
suggestion: nextSuggestion,
|
|
97
|
+
decorations: buildDecorations(nextSuggestion, newState.doc, resolved)
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
props: {
|
|
102
|
+
decorations(state) {
|
|
103
|
+
return autocompleteSuggestionKey.getState(state)?.decorations ?? null;
|
|
104
|
+
},
|
|
105
|
+
...resolved.keymap ? { handleKeyDown: (view, event) => {
|
|
106
|
+
const current = autocompleteSuggestionKey.getState(view.state)?.suggestion ?? IDLE;
|
|
107
|
+
if (current.status !== "shown" && current.status !== "streaming") return false;
|
|
108
|
+
const isMod = event.metaKey || event.ctrlKey;
|
|
109
|
+
if (event.key === "Tab" && !event.shiftKey && !isMod) {
|
|
110
|
+
if (acceptAutocompleteSuggestion(view.state, view.dispatch).accepted) {
|
|
111
|
+
event.preventDefault();
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
if (event.key === "ArrowRight" && isMod && !event.shiftKey) {
|
|
117
|
+
if (acceptAutocompleteWord(view.state, view.dispatch).accepted) {
|
|
118
|
+
event.preventDefault();
|
|
119
|
+
return true;
|
|
120
|
+
}
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
if (event.key === "Escape" && !isMod && !event.shiftKey) {
|
|
124
|
+
view.dispatch(clearAutocompleteSuggestion(view.state.tr));
|
|
125
|
+
event.preventDefault();
|
|
126
|
+
return true;
|
|
127
|
+
}
|
|
128
|
+
return false;
|
|
129
|
+
} } : {}
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
};
|
|
133
|
+
const getAutocompleteSuggestion = (state) => autocompleteSuggestionKey.getState(state)?.suggestion ?? IDLE;
|
|
134
|
+
const startAutocompleteSuggestion = (tr, anchor, requestId) => tr.setMeta(autocompleteSuggestionKey, {
|
|
135
|
+
type: "start",
|
|
136
|
+
anchor,
|
|
137
|
+
requestId
|
|
138
|
+
});
|
|
139
|
+
const appendAutocompleteToken = (tr, requestId, delta) => tr.setMeta(autocompleteSuggestionKey, {
|
|
140
|
+
type: "token",
|
|
141
|
+
requestId,
|
|
142
|
+
delta
|
|
143
|
+
});
|
|
144
|
+
const finishAutocompleteSuggestion = (tr, requestId) => tr.setMeta(autocompleteSuggestionKey, {
|
|
145
|
+
type: "finish",
|
|
146
|
+
requestId
|
|
147
|
+
});
|
|
148
|
+
const clearAutocompleteSuggestion = (tr) => tr.setMeta(autocompleteSuggestionKey, { type: "clear" });
|
|
149
|
+
/**
|
|
150
|
+
* Commit the current suggestion as a real text insertion at its
|
|
151
|
+
* anchor. Returns metadata so the caller can record the accept
|
|
152
|
+
* event (for telemetry / future training feedback) without
|
|
153
|
+
* re-reading plugin state after the dispatch.
|
|
154
|
+
*
|
|
155
|
+
* Single transaction: insert text + clear suggestion state, so
|
|
156
|
+
* undo restores both the doc and the (now-gone) ghost atomically.
|
|
157
|
+
*/
|
|
158
|
+
const acceptAutocompleteSuggestion = (state, dispatch) => {
|
|
159
|
+
const current = getAutocompleteSuggestion(state);
|
|
160
|
+
if (current.status !== "shown" && current.status !== "streaming") return { accepted: false };
|
|
161
|
+
if (current.text.length === 0) return { accepted: false };
|
|
162
|
+
if (dispatch) {
|
|
163
|
+
const tr = state.tr.insertText(current.text, current.anchor);
|
|
164
|
+
clearAutocompleteSuggestion(tr);
|
|
165
|
+
dispatch(tr);
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
accepted: true,
|
|
169
|
+
from: current.anchor,
|
|
170
|
+
to: current.anchor + current.text.length,
|
|
171
|
+
text: current.text
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* Consume the next "word" from the suggestion: insert it at the
|
|
176
|
+
* anchor in a single transaction and shrink the remaining ghost
|
|
177
|
+
* text. Lets the user "graze" through a long suggestion one word
|
|
178
|
+
* at a time with ⌘→ / Ctrl→ instead of accept-all-or-discard.
|
|
179
|
+
*
|
|
180
|
+
* A word here is "leading whitespace + the next non-whitespace
|
|
181
|
+
* run + an optional trailing space" — so successive calls eat the
|
|
182
|
+
* suggestion cleanly without leaving stray spaces. When the
|
|
183
|
+
* remaining suggestion is shorter than one word, this falls
|
|
184
|
+
* through to {@link acceptAutocompleteSuggestion}.
|
|
185
|
+
*/
|
|
186
|
+
const acceptAutocompleteWord = (state, dispatch) => {
|
|
187
|
+
const current = getAutocompleteSuggestion(state);
|
|
188
|
+
if (current.status !== "shown" && current.status !== "streaming") return { accepted: false };
|
|
189
|
+
if (current.text.length === 0) return { accepted: false };
|
|
190
|
+
const match = /^(?<word>\s*\S+\s?)/u.exec(current.text);
|
|
191
|
+
const word = match === null ? current.text : match.groups?.["word"];
|
|
192
|
+
if (word === void 0 || word.length === 0) return { accepted: false };
|
|
193
|
+
if (word.length >= current.text.length) return acceptAutocompleteSuggestion(state, dispatch);
|
|
194
|
+
if (dispatch) {
|
|
195
|
+
const tr = state.tr.insertText(word, current.anchor);
|
|
196
|
+
tr.setMeta(autocompleteSuggestionKey, {
|
|
197
|
+
type: "consume",
|
|
198
|
+
requestId: current.requestId,
|
|
199
|
+
consumed: word
|
|
200
|
+
});
|
|
201
|
+
dispatch(tr);
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
accepted: true,
|
|
205
|
+
from: current.anchor,
|
|
206
|
+
to: current.anchor + word.length,
|
|
207
|
+
text: word
|
|
208
|
+
};
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* Node type names that should suppress autocomplete entirely. The
|
|
212
|
+
* defaults cover prose-adjacent zones across ProseMirror schemas
|
|
213
|
+
* we encounter in folio + bare playgrounds. Pass a custom list via
|
|
214
|
+
* options to extend (citations, math, frontmatter, etc.).
|
|
215
|
+
*/
|
|
216
|
+
const DEFAULT_AUTOCOMPLETE_DEAD_ZONE_NODES = [
|
|
217
|
+
"heading",
|
|
218
|
+
"title",
|
|
219
|
+
"code",
|
|
220
|
+
"code_block",
|
|
221
|
+
"codeBlock",
|
|
222
|
+
"horizontal_rule",
|
|
223
|
+
"horizontalRule",
|
|
224
|
+
"math_block",
|
|
225
|
+
"math_inline",
|
|
226
|
+
"inline_math",
|
|
227
|
+
"inlineMath",
|
|
228
|
+
"equation",
|
|
229
|
+
"citation",
|
|
230
|
+
"citationPreview",
|
|
231
|
+
"pendingCitation",
|
|
232
|
+
"image",
|
|
233
|
+
"imageBlock"
|
|
234
|
+
];
|
|
235
|
+
const WORD_CONTINUATION_CHAR = /[\p{L}\p{N}_'-]/u;
|
|
236
|
+
/**
|
|
237
|
+
* Decide whether autocomplete should fire at the current cursor.
|
|
238
|
+
* Designed to be called from a debounced trigger in the host app
|
|
239
|
+
* before sending a request to the model. Returns a structured
|
|
240
|
+
* skip reason rather than a bare boolean so callers (and debug
|
|
241
|
+
* UIs) can explain why no suggestion appeared.
|
|
242
|
+
*
|
|
243
|
+
* Gates applied:
|
|
244
|
+
* - selection must be a collapsed caret (no range selection)
|
|
245
|
+
* - the cursor must not be inside a dead-zone node (heading,
|
|
246
|
+
* code, citation, math, etc.) anywhere in the ancestor chain
|
|
247
|
+
* - the character immediately before the cursor must not be a
|
|
248
|
+
* word-continuation char — if it is, the model would be
|
|
249
|
+
* completing a partial token and almost always misreads intent
|
|
250
|
+
*/
|
|
251
|
+
const shouldTriggerAutocomplete = (state, options) => {
|
|
252
|
+
const sel = state.selection;
|
|
253
|
+
if (!sel.empty) return {
|
|
254
|
+
ok: false,
|
|
255
|
+
reason: "selection-non-empty"
|
|
256
|
+
};
|
|
257
|
+
if (state.doc.content.size === 0) return {
|
|
258
|
+
ok: false,
|
|
259
|
+
reason: "empty-doc"
|
|
260
|
+
};
|
|
261
|
+
const $cursor = sel.$from;
|
|
262
|
+
const deadZones = /* @__PURE__ */ new Set([...DEFAULT_AUTOCOMPLETE_DEAD_ZONE_NODES, ...options?.extraDeadZoneNodes ?? []]);
|
|
263
|
+
for (let depth = $cursor.depth; depth >= 0; depth--) {
|
|
264
|
+
const nodeName = $cursor.node(depth).type.name;
|
|
265
|
+
if (deadZones.has(nodeName)) return {
|
|
266
|
+
ok: false,
|
|
267
|
+
reason: "deadzone",
|
|
268
|
+
detail: nodeName
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
const parentOffset = $cursor.parentOffset;
|
|
272
|
+
if (parentOffset > 0) {
|
|
273
|
+
const before = $cursor.parent.textBetween(parentOffset - 1, parentOffset, "\n", "\n");
|
|
274
|
+
if (before.length > 0 && WORD_CONTINUATION_CHAR.test(before)) return {
|
|
275
|
+
ok: false,
|
|
276
|
+
reason: "midword",
|
|
277
|
+
detail: before
|
|
278
|
+
};
|
|
279
|
+
}
|
|
280
|
+
return { ok: true };
|
|
281
|
+
};
|
|
282
|
+
//#endregion
|
|
283
|
+
export { DEFAULT_AUTOCOMPLETE_DEAD_ZONE_NODES, acceptAutocompleteSuggestion, acceptAutocompleteWord, appendAutocompleteToken, autocompleteSuggestionKey, autocompleteSuggestionPlugin, clearAutocompleteSuggestion, finishAutocompleteSuggestion, getAutocompleteSuggestion, shouldTriggerAutocomplete, startAutocompleteSuggestion };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ContentControlLockedError, ContentControlTypeError } from "../../content-controls/errors.js";
|
|
2
|
+
import { Plugin, PluginKey } from "prosemirror-state";
|
|
3
|
+
import { EditorView } from "prosemirror-view";
|
|
4
|
+
|
|
5
|
+
//#region src/prosemirror/plugins/contentControlWidgets.d.ts
|
|
6
|
+
type ContentControlWidgetEvent = {
|
|
7
|
+
kind: "dropdownOpen";
|
|
8
|
+
tag: string; /** PM position of the clicked SDT instance — disambiguates duplicates. */
|
|
9
|
+
pmPos: number;
|
|
10
|
+
sdtType: "dropdown" | "comboBox";
|
|
11
|
+
anchor: HTMLElement;
|
|
12
|
+
listItemsJson: string | undefined;
|
|
13
|
+
} | {
|
|
14
|
+
kind: "datePick";
|
|
15
|
+
tag: string;
|
|
16
|
+
pmPos: number;
|
|
17
|
+
anchor: HTMLElement;
|
|
18
|
+
currentValue: string | undefined;
|
|
19
|
+
} | {
|
|
20
|
+
/**
|
|
21
|
+
* The plugin refused a click because the control's `w:lock` or type
|
|
22
|
+
* forbade the interaction. The shell decides how to surface this —
|
|
23
|
+
* toast, telemetry, or no-op. The plugin itself never logs.
|
|
24
|
+
*/
|
|
25
|
+
kind: "refused";
|
|
26
|
+
tag: string;
|
|
27
|
+
pmPos: number;
|
|
28
|
+
sdtType: string;
|
|
29
|
+
anchor: HTMLElement;
|
|
30
|
+
error: ContentControlLockedError | ContentControlTypeError;
|
|
31
|
+
};
|
|
32
|
+
type ContentControlWidgetCallback = (event: ContentControlWidgetEvent) => void;
|
|
33
|
+
declare const contentControlWidgetsPluginKey: PluginKey<unknown>;
|
|
34
|
+
/**
|
|
35
|
+
* CustomEvent name dispatched on the editor view DOM whenever the plugin
|
|
36
|
+
* needs to surface a `ContentControlWidgetEvent` to the React shell. The
|
|
37
|
+
* shell subscribes via `addEventListener` and renders the matching chrome.
|
|
38
|
+
*
|
|
39
|
+
* Using a CustomEvent keeps the plugin from owning a React reference and
|
|
40
|
+
* makes the host's responsibility explicit: receive event → render UI →
|
|
41
|
+
* call dispatchDropdownPick / dispatchDatePick.
|
|
42
|
+
*/
|
|
43
|
+
declare const CONTENT_CONTROL_WIDGET_EVENT_NAME = "folio:content-control-widget";
|
|
44
|
+
declare function createContentControlWidgetsPlugin(onEvent?: ContentControlWidgetCallback): Plugin;
|
|
45
|
+
/**
|
|
46
|
+
* Stable resolver helpers exposed for the UI shell so a popover menu or
|
|
47
|
+
* date picker can dispatch the same transaction the plugin would.
|
|
48
|
+
*
|
|
49
|
+
* Both take the PM `pmPos` of the clicked SDT (from the widget event's
|
|
50
|
+
* `pmPos` field) so the dispatch lands on the exact instance the user
|
|
51
|
+
* interacted with — duplicate-tag SDTs are no longer ambiguous.
|
|
52
|
+
*/
|
|
53
|
+
declare function dispatchDropdownPick(view: EditorView, pmPos: number, value: string): boolean;
|
|
54
|
+
declare function dispatchDatePick(view: EditorView, pmPos: number, date: string): boolean;
|
|
55
|
+
//#endregion
|
|
56
|
+
export { CONTENT_CONTROL_WIDGET_EVENT_NAME, ContentControlWidgetCallback, ContentControlWidgetEvent, contentControlWidgetsPluginKey, createContentControlWidgetsPlugin, dispatchDatePick, dispatchDropdownPick };
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import { ContentControlLockedError, ContentControlTypeError } from "../../content-controls/errors.js";
|
|
2
|
+
import { findBlockSdtMatch, setContentControlValueTr } from "../commands/contentControls.js";
|
|
3
|
+
import { Plugin, PluginKey } from "prosemirror-state";
|
|
4
|
+
//#region src/prosemirror/plugins/contentControlWidgets.ts
|
|
5
|
+
/**
|
|
6
|
+
* Interactive content-control widget delegation.
|
|
7
|
+
*
|
|
8
|
+
* Painted blocks inside a typed SDT carry `data-sdt-type` (checkbox /
|
|
9
|
+
* dropdown / date) and `data-sdt-tag` thanks to `applySdtDataAttrs`. This
|
|
10
|
+
* plugin watches editor-region clicks: when the user clicks inside a typed
|
|
11
|
+
* control it dispatches the appropriate `setContentControlValueTr` so the
|
|
12
|
+
* mutation goes through the normal undo stack.
|
|
13
|
+
*
|
|
14
|
+
* The checkbox path is fully wired (a click toggles the modeled state and
|
|
15
|
+
* the rendered glyph). Dropdown and date paths emit the dispatch hook so the
|
|
16
|
+
* higher-level UI (a popover menu / date picker rendered by the editor
|
|
17
|
+
* shell) can subscribe; the plugin does not own the menu/picker chrome.
|
|
18
|
+
*/
|
|
19
|
+
const contentControlWidgetsPluginKey = new PluginKey("contentControlWidgets");
|
|
20
|
+
/**
|
|
21
|
+
* CustomEvent name dispatched on the editor view DOM whenever the plugin
|
|
22
|
+
* needs to surface a `ContentControlWidgetEvent` to the React shell. The
|
|
23
|
+
* shell subscribes via `addEventListener` and renders the matching chrome.
|
|
24
|
+
*
|
|
25
|
+
* Using a CustomEvent keeps the plugin from owning a React reference and
|
|
26
|
+
* makes the host's responsibility explicit: receive event → render UI →
|
|
27
|
+
* call dispatchDropdownPick / dispatchDatePick.
|
|
28
|
+
*/
|
|
29
|
+
const CONTENT_CONTROL_WIDGET_EVENT_NAME = "folio:content-control-widget";
|
|
30
|
+
function findSdtAncestor(target) {
|
|
31
|
+
if (!(target instanceof Element)) return null;
|
|
32
|
+
return target.closest("[data-sdt-type]");
|
|
33
|
+
}
|
|
34
|
+
function createContentControlWidgetsPlugin(onEvent = () => void 0) {
|
|
35
|
+
const emit = (view, payload) => {
|
|
36
|
+
onEvent(payload);
|
|
37
|
+
view.dom.dispatchEvent(new CustomEvent(CONTENT_CONTROL_WIDGET_EVENT_NAME, {
|
|
38
|
+
detail: payload,
|
|
39
|
+
bubbles: true
|
|
40
|
+
}));
|
|
41
|
+
};
|
|
42
|
+
return new Plugin({
|
|
43
|
+
key: contentControlWidgetsPluginKey,
|
|
44
|
+
props: { handleDOMEvents: { click(view, event) {
|
|
45
|
+
const anchor = findSdtAncestor(event.target);
|
|
46
|
+
if (!anchor) return false;
|
|
47
|
+
const tag = anchor.dataset["sdtTag"] ?? "";
|
|
48
|
+
const sdtType = anchor.dataset["sdtType"];
|
|
49
|
+
const pmPosRaw = anchor.dataset["sdtPmPos"];
|
|
50
|
+
const pmPos = pmPosRaw ? Number.parseInt(pmPosRaw, 10) : NaN;
|
|
51
|
+
if (!sdtType || Number.isNaN(pmPos)) return false;
|
|
52
|
+
try {
|
|
53
|
+
if (sdtType === "checkbox") {
|
|
54
|
+
const current = anchor.dataset["sdtChecked"] === "true";
|
|
55
|
+
const tr = setContentControlValueTr(view.state, { pmPos }, {
|
|
56
|
+
kind: "checkbox",
|
|
57
|
+
checked: !current
|
|
58
|
+
});
|
|
59
|
+
if (tr) {
|
|
60
|
+
view.dispatch(tr);
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
} else if (sdtType === "dropdown" || sdtType === "comboBox") {
|
|
65
|
+
const refusal = lockRefusalFor(view, pmPos);
|
|
66
|
+
if (refusal) {
|
|
67
|
+
emit(view, {
|
|
68
|
+
kind: "refused",
|
|
69
|
+
tag,
|
|
70
|
+
pmPos,
|
|
71
|
+
sdtType,
|
|
72
|
+
anchor,
|
|
73
|
+
error: refusal
|
|
74
|
+
});
|
|
75
|
+
event.preventDefault();
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
emit(view, {
|
|
79
|
+
kind: "dropdownOpen",
|
|
80
|
+
tag,
|
|
81
|
+
pmPos,
|
|
82
|
+
sdtType,
|
|
83
|
+
anchor,
|
|
84
|
+
listItemsJson: anchor.dataset["sdtListItems"]
|
|
85
|
+
});
|
|
86
|
+
event.preventDefault();
|
|
87
|
+
return true;
|
|
88
|
+
} else if (sdtType === "date") {
|
|
89
|
+
const refusal = lockRefusalFor(view, pmPos);
|
|
90
|
+
if (refusal) {
|
|
91
|
+
emit(view, {
|
|
92
|
+
kind: "refused",
|
|
93
|
+
tag,
|
|
94
|
+
pmPos,
|
|
95
|
+
sdtType,
|
|
96
|
+
anchor,
|
|
97
|
+
error: refusal
|
|
98
|
+
});
|
|
99
|
+
event.preventDefault();
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
emit(view, {
|
|
103
|
+
kind: "datePick",
|
|
104
|
+
tag,
|
|
105
|
+
pmPos,
|
|
106
|
+
anchor,
|
|
107
|
+
currentValue: void 0
|
|
108
|
+
});
|
|
109
|
+
event.preventDefault();
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
} catch (error) {
|
|
113
|
+
if (error instanceof ContentControlLockedError || error instanceof ContentControlTypeError) {
|
|
114
|
+
emit(view, {
|
|
115
|
+
kind: "refused",
|
|
116
|
+
tag,
|
|
117
|
+
pmPos,
|
|
118
|
+
sdtType,
|
|
119
|
+
anchor,
|
|
120
|
+
error
|
|
121
|
+
});
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
throw error;
|
|
125
|
+
}
|
|
126
|
+
return false;
|
|
127
|
+
} } },
|
|
128
|
+
view() {
|
|
129
|
+
return {};
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Stable resolver helpers exposed for the UI shell so a popover menu or
|
|
135
|
+
* date picker can dispatch the same transaction the plugin would.
|
|
136
|
+
*
|
|
137
|
+
* Both take the PM `pmPos` of the clicked SDT (from the widget event's
|
|
138
|
+
* `pmPos` field) so the dispatch lands on the exact instance the user
|
|
139
|
+
* interacted with — duplicate-tag SDTs are no longer ambiguous.
|
|
140
|
+
*/
|
|
141
|
+
function dispatchDropdownPick(view, pmPos, value) {
|
|
142
|
+
if (!findBlockSdtMatch(view.state.doc, { pmPos })) return false;
|
|
143
|
+
try {
|
|
144
|
+
const tr = setContentControlValueTr(view.state, { pmPos }, {
|
|
145
|
+
kind: "dropdown",
|
|
146
|
+
value
|
|
147
|
+
});
|
|
148
|
+
if (!tr) return false;
|
|
149
|
+
view.dispatch(tr);
|
|
150
|
+
return true;
|
|
151
|
+
} catch (error) {
|
|
152
|
+
if (error instanceof ContentControlLockedError || error instanceof ContentControlTypeError) return false;
|
|
153
|
+
throw error;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
function dispatchDatePick(view, pmPos, date) {
|
|
157
|
+
try {
|
|
158
|
+
const tr = setContentControlValueTr(view.state, { pmPos }, {
|
|
159
|
+
kind: "date",
|
|
160
|
+
date
|
|
161
|
+
});
|
|
162
|
+
if (!tr) return false;
|
|
163
|
+
view.dispatch(tr);
|
|
164
|
+
return true;
|
|
165
|
+
} catch (error) {
|
|
166
|
+
if (error instanceof ContentControlLockedError || error instanceof ContentControlTypeError) return false;
|
|
167
|
+
throw error;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Look up the clicked SDT by pmPos and return a typed refusal when the
|
|
172
|
+
* lock state forbids content mutation (`contentLocked`,
|
|
173
|
+
* `sdtContentLocked`). Returning `null` means "go ahead and open the
|
|
174
|
+
* picker." Preflight at click time so locked dropdowns / date pickers
|
|
175
|
+
* don't flash open just to close again when the user makes a selection.
|
|
176
|
+
*/
|
|
177
|
+
function lockRefusalFor(view, pmPos) {
|
|
178
|
+
const match = findBlockSdtMatch(view.state.doc, { pmPos });
|
|
179
|
+
if (!match) return null;
|
|
180
|
+
const lock = match.node.attrs["lock"];
|
|
181
|
+
if (lock !== "contentLocked" && lock !== "sdtContentLocked") return null;
|
|
182
|
+
const tag = match.node.attrs["tag"];
|
|
183
|
+
const alias = match.node.attrs["alias"];
|
|
184
|
+
return new ContentControlLockedError({
|
|
185
|
+
message: `Control "${tag ?? alias ?? "(unnamed)"}" has w:lock=${lock}.`,
|
|
186
|
+
lock,
|
|
187
|
+
...typeof tag === "string" ? { tag } : {},
|
|
188
|
+
...typeof alias === "string" ? { alias } : {}
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
//#endregion
|
|
192
|
+
export { CONTENT_CONTROL_WIDGET_EVENT_NAME, contentControlWidgetsPluginKey, createContentControlWidgetsPlugin, dispatchDatePick, dispatchDropdownPick };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { EditorState, Plugin, PluginKey } from "prosemirror-state";
|
|
2
|
+
import { Node } from "prosemirror-model";
|
|
3
|
+
|
|
4
|
+
//#region src/prosemirror/plugins/createDocScanPlugin.d.ts
|
|
5
|
+
declare const SET_META = "set";
|
|
6
|
+
type DocScanState<TConfig, TRange> = {
|
|
7
|
+
config: TConfig;
|
|
8
|
+
ranges: readonly TRange[];
|
|
9
|
+
};
|
|
10
|
+
type DocScanPluginOptions<TConfig, TRange> = {
|
|
11
|
+
key: PluginKey<DocScanState<TConfig, TRange>>;
|
|
12
|
+
initialConfig: TConfig; /** Recompute the ranges from the current doc + config. */
|
|
13
|
+
scan: (doc: Node, config: TConfig) => TRange[];
|
|
14
|
+
/**
|
|
15
|
+
* Push-side bridge for hosts that mirror the current range list
|
|
16
|
+
* outside the PM state tree (counters, inspector facets). Called
|
|
17
|
+
* on init, after every transaction that changes the range set,
|
|
18
|
+
* and on teardown (with an empty list).
|
|
19
|
+
*/
|
|
20
|
+
onRangesChange?: (ranges: readonly TRange[]) => void;
|
|
21
|
+
};
|
|
22
|
+
declare const createDocScanPlugin: <TConfig, TRange>({
|
|
23
|
+
key,
|
|
24
|
+
initialConfig,
|
|
25
|
+
scan,
|
|
26
|
+
onRangesChange
|
|
27
|
+
}: DocScanPluginOptions<TConfig, TRange>) => Plugin<DocScanState<TConfig, TRange>>;
|
|
28
|
+
declare const setDocScanConfigMeta: <TConfig, TRange>(key: PluginKey<DocScanState<TConfig, TRange>>, config: TConfig) => {
|
|
29
|
+
key: PluginKey<DocScanState<TConfig, TRange>>;
|
|
30
|
+
payload: {
|
|
31
|
+
type: typeof SET_META;
|
|
32
|
+
config: TConfig;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
declare const getDocScanRanges: <TConfig, TRange>(key: PluginKey<DocScanState<TConfig, TRange>>, state: EditorState) => readonly TRange[];
|
|
36
|
+
//#endregion
|
|
37
|
+
export { DocScanPluginOptions, DocScanState, createDocScanPlugin, getDocScanRanges, setDocScanConfigMeta };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Plugin } from "prosemirror-state";
|
|
2
|
+
//#region src/prosemirror/plugins/createDocScanPlugin.ts
|
|
3
|
+
const SET_META = "set";
|
|
4
|
+
const createDocScanPlugin = ({ key, initialConfig, scan, onRangesChange }) => {
|
|
5
|
+
const spec = {
|
|
6
|
+
key,
|
|
7
|
+
state: {
|
|
8
|
+
init(_config, instance) {
|
|
9
|
+
return {
|
|
10
|
+
config: initialConfig,
|
|
11
|
+
ranges: scan(instance.doc, initialConfig)
|
|
12
|
+
};
|
|
13
|
+
},
|
|
14
|
+
apply(tr, prev, _oldState, newState) {
|
|
15
|
+
const setMeta = tr.getMeta(key);
|
|
16
|
+
if (setMeta?.type === SET_META) return {
|
|
17
|
+
config: setMeta.config,
|
|
18
|
+
ranges: scan(newState.doc, setMeta.config)
|
|
19
|
+
};
|
|
20
|
+
if (tr.docChanged) return {
|
|
21
|
+
config: prev.config,
|
|
22
|
+
ranges: scan(newState.doc, prev.config)
|
|
23
|
+
};
|
|
24
|
+
return prev;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
if (onRangesChange) spec.view = (view) => {
|
|
29
|
+
let last = key.getState(view.state)?.ranges;
|
|
30
|
+
if (last) onRangesChange(last);
|
|
31
|
+
return {
|
|
32
|
+
update(updatedView) {
|
|
33
|
+
const next = key.getState(updatedView.state)?.ranges;
|
|
34
|
+
if (next && next !== last) {
|
|
35
|
+
last = next;
|
|
36
|
+
onRangesChange(next);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
destroy() {
|
|
40
|
+
onRangesChange([]);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
return new Plugin(spec);
|
|
45
|
+
};
|
|
46
|
+
const setDocScanConfigMeta = (key, config) => ({
|
|
47
|
+
key,
|
|
48
|
+
payload: {
|
|
49
|
+
type: SET_META,
|
|
50
|
+
config
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
const getDocScanRanges = (key, state) => key.getState(state)?.ranges ?? [];
|
|
54
|
+
//#endregion
|
|
55
|
+
export { createDocScanPlugin, getDocScanRanges, setDocScanConfigMeta };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { document_d_exports } from "../../types/document.js";
|
|
2
|
+
import { StyleResolver } from "../styles/styleResolver.js";
|
|
3
|
+
import { EditorState, Plugin, PluginKey } from "prosemirror-state";
|
|
4
|
+
|
|
5
|
+
//#region src/prosemirror/plugins/documentStyles.d.ts
|
|
6
|
+
declare const documentStylesKey: PluginKey<StyleResolver | null>;
|
|
7
|
+
/**
|
|
8
|
+
* Create the plugin holding a StyleResolver for the document's `styles` for
|
|
9
|
+
* the lifetime of the EditorState. The resolver is fixed per document load;
|
|
10
|
+
* loading a new document recreates the state (and thus this plugin) with a
|
|
11
|
+
* fresh resolver. Accepts a pre-built resolver too, for callers that already
|
|
12
|
+
* have one.
|
|
13
|
+
*/
|
|
14
|
+
declare function createDocumentStylesPlugin(styles: document_d_exports.StyleDefinitions | StyleResolver | null | undefined): Plugin;
|
|
15
|
+
/** Read the document's StyleResolver, or null when the plugin isn't installed. */
|
|
16
|
+
declare function getDocumentStyleResolver(state: EditorState): StyleResolver | null;
|
|
17
|
+
//#endregion
|
|
18
|
+
export { createDocumentStylesPlugin, documentStylesKey, getDocumentStyleResolver };
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { StyleResolver, createStyleResolver } from "../styles/styleResolver.js";
|
|
2
|
+
import { Plugin, PluginKey } from "prosemirror-state";
|
|
3
|
+
//#region src/prosemirror/plugins/documentStyles.ts
|
|
4
|
+
/**
|
|
5
|
+
* documentStyles plugin — makes the document's StyleResolver reachable from
|
|
6
|
+
* ProseMirror commands.
|
|
7
|
+
*
|
|
8
|
+
* Styles otherwise flow one way (Document → PM) at load time: `toProseDoc`
|
|
9
|
+
* bakes resolved formatting into nodes and discards the resolver. Some
|
|
10
|
+
* commands need the live style table though — the Enter handler looks up a
|
|
11
|
+
* paragraph style's `w:next` to switch to body text after a heading. This
|
|
12
|
+
* plugin parks the resolver in plugin state so those commands can read it
|
|
13
|
+
* via `getDocumentStyleResolver(state)`.
|
|
14
|
+
*
|
|
15
|
+
* The host (HiddenProseMirror / HiddenHeaderFooterPMs) passes the same
|
|
16
|
+
* styles it hands to `toProseDoc` and adds this plugin when creating the
|
|
17
|
+
* EditorState. When absent, style-aware commands fall back to their
|
|
18
|
+
* style-agnostic behavior.
|
|
19
|
+
*/
|
|
20
|
+
const documentStylesKey = new PluginKey("documentStyles");
|
|
21
|
+
/**
|
|
22
|
+
* Create the plugin holding a StyleResolver for the document's `styles` for
|
|
23
|
+
* the lifetime of the EditorState. The resolver is fixed per document load;
|
|
24
|
+
* loading a new document recreates the state (and thus this plugin) with a
|
|
25
|
+
* fresh resolver. Accepts a pre-built resolver too, for callers that already
|
|
26
|
+
* have one.
|
|
27
|
+
*/
|
|
28
|
+
function createDocumentStylesPlugin(styles) {
|
|
29
|
+
let resolver;
|
|
30
|
+
if (styles instanceof StyleResolver) resolver = styles;
|
|
31
|
+
else if (styles) resolver = createStyleResolver(styles);
|
|
32
|
+
else resolver = null;
|
|
33
|
+
return new Plugin({
|
|
34
|
+
key: documentStylesKey,
|
|
35
|
+
state: {
|
|
36
|
+
init: () => resolver,
|
|
37
|
+
apply: (_tr, value) => value
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/** Read the document's StyleResolver, or null when the plugin isn't installed. */
|
|
42
|
+
function getDocumentStyleResolver(state) {
|
|
43
|
+
return documentStylesKey.getState(state) ?? null;
|
|
44
|
+
}
|
|
45
|
+
//#endregion
|
|
46
|
+
export { createDocumentStylesPlugin, documentStylesKey, getDocumentStyleResolver };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { SelectionChangeCallback, SelectionContext, createSelectionTrackerPlugin, extractSelectionContext, getSelectionContext, selectionTrackerKey } from "./selectionTracker.js";
|
|
2
|
+
import { createDocumentStylesPlugin, documentStylesKey, getDocumentStyleResolver } from "./documentStyles.js";
|
|
3
|
+
export { type SelectionChangeCallback, type SelectionContext, createDocumentStylesPlugin, createSelectionTrackerPlugin, documentStylesKey, extractSelectionContext, getDocumentStyleResolver, getSelectionContext, selectionTrackerKey };
|