@ecsplico/editor 3.5.1 → 4.0.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/CHANGELOG.md +71 -0
- package/dist/adapters/direct-ai.d.ts +4 -4
- package/dist/adapters/direct-ai.js +2 -2
- package/dist/adapters/direct-ai.js.map +1 -1
- package/dist/adapters/document-state.d.ts +1 -1
- package/dist/adapters/document-state.js.map +1 -1
- package/dist/adapters/forge.d.ts +2 -2
- package/dist/adapters/forge.js.map +1 -1
- package/dist/adapters/nitro.d.ts +11 -3
- package/dist/adapters/nitro.js +3 -1
- package/dist/adapters/nitro.js.map +1 -1
- package/dist/adapters/shared.d.ts +6 -6
- package/dist/adapters/shared.js.map +1 -1
- package/dist/code/CodeSurface.vue.d.ts +3 -3
- package/dist/config/index.d.ts +14 -14
- package/dist/config/index.js +8 -8
- package/dist/config/index.js.map +1 -1
- package/dist/core/backend-types.d.ts +3 -3
- package/dist/core/backend-types.js.map +1 -1
- package/dist/core/backend.d.ts +4 -4
- package/dist/core/backend.js.map +1 -1
- package/dist/core/block-convert.d.ts +1 -1
- package/dist/core/block-convert.js +5 -5
- package/dist/core/block-convert.js.map +1 -1
- package/dist/core/block-transfer.d.ts +8 -4
- package/dist/core/block-transfer.js +23 -14
- package/dist/core/block-transfer.js.map +1 -1
- package/dist/core/capabilities.d.ts +113 -0
- package/dist/core/capabilities.js +155 -0
- package/dist/core/capabilities.js.map +1 -0
- package/dist/core/command-types.d.ts +1 -1
- package/dist/core/context.js.map +1 -1
- package/dist/core/convert.d.ts +5 -5
- package/dist/core/convert.js +5 -5
- package/dist/core/convert.js.map +1 -1
- package/dist/core/core-feature.js +1 -1
- package/dist/core/define-editor.d.ts +2 -2
- package/dist/core/define-editor.js +34 -6
- package/dist/core/define-editor.js.map +1 -1
- package/dist/core/derivation.d.ts +119 -0
- package/dist/core/derivation.js +187 -0
- package/dist/core/derivation.js.map +1 -0
- package/dist/core/derive.d.ts +61 -0
- package/dist/core/derive.js +69 -0
- package/dist/core/derive.js.map +1 -0
- package/dist/core/extension-points.d.ts +16 -0
- package/dist/core/feature-context.d.ts +5 -1
- package/dist/core/feature-context.js +10 -3
- package/dist/core/feature-context.js.map +1 -1
- package/dist/core/feature.d.ts +41 -19
- package/dist/core/feature.js.map +1 -1
- package/dist/core/fences.js +1 -1
- package/dist/core/fences.js.map +1 -1
- package/dist/core/index.d.ts +6 -2
- package/dist/core/index.js +5 -1
- package/dist/core/pipeline.d.ts +14 -5
- package/dist/core/pipeline.js +19 -7
- package/dist/core/pipeline.js.map +1 -1
- package/dist/core/properties.d.ts +22 -0
- package/dist/core/properties.js +17 -0
- package/dist/core/properties.js.map +1 -0
- package/dist/core/schema/block-ids.js +5 -5
- package/dist/core/schema/block-ids.js.map +1 -1
- package/dist/core/schema/index.d.ts +2 -1
- package/dist/core/schema/index.js +2 -1
- package/dist/core/schema/index.js.map +1 -1
- package/dist/core/schema/opaque-fence.d.ts +4 -4
- package/dist/core/schema/opaque-fence.js +7 -7
- package/dist/core/schema/opaque-fence.js.map +1 -1
- package/dist/core/schema/persisted-names.d.ts +58 -0
- package/dist/core/schema/persisted-names.js +96 -0
- package/dist/core/schema/persisted-names.js.map +1 -0
- package/dist/core/toolbar-items.js +1 -1
- package/dist/core/toolbar-items.js.map +1 -1
- package/dist/core/util.js +5 -1
- package/dist/core/util.js.map +1 -1
- package/dist/document/DocumentSurface.vue.d.ts +3 -3
- package/dist/features/ai/agent-ops.js +1 -1
- package/dist/features/ai/ai-review.js +1 -1
- package/dist/features/ai/assistant.d.ts +4 -4
- package/dist/features/ai/assistant.js +1 -1
- package/dist/features/ai/assistant.js.map +1 -1
- package/dist/features/ai/components/AiSelectionMenu.js +1 -1
- package/dist/features/ai/components/AiSelectionMenu.js.map +1 -1
- package/dist/features/ai/components/ModelQuickSwitch.js +7 -7
- package/dist/features/ai/components/ModelQuickSwitch.js.map +1 -1
- package/dist/features/ai/components/ModelQuickSwitch.vue.d.ts +4 -4
- package/dist/features/ai/components/SettingsAiTab.js +8 -8
- package/dist/features/ai/components/SettingsAiTab.js.map +1 -1
- package/dist/features/ai/components/SettingsModelProfiles.js +1 -1
- package/dist/features/ai/components/SettingsModelProfiles.js.map +1 -1
- package/dist/features/ai/document-chat-model.d.ts +2 -2
- package/dist/features/ai/document-chat-model.js +5 -5
- package/dist/features/ai/document-chat-model.js.map +1 -1
- package/dist/features/ai/document-chat.js +2 -2
- package/dist/features/ai/document-chat.js.map +1 -1
- package/dist/features/ai/feature.d.ts +2 -2
- package/dist/features/ai/feature.js +2 -2
- package/dist/features/ai/feature.js.map +1 -1
- package/dist/features/ai/ghost-autocomplete.d.ts +4 -4
- package/dist/features/ai/ghost-autocomplete.js +1 -1
- package/dist/features/ai/ghost-autocomplete.js.map +1 -1
- package/dist/features/ai/index.d.ts +3 -3
- package/dist/features/ai/index.js +2 -2
- package/dist/features/ai/model-profiles.d.ts +9 -9
- package/dist/features/ai/model-profiles.js +13 -13
- package/dist/features/ai/model-profiles.js.map +1 -1
- package/dist/features/ai/protocol/agent-ops.d.ts +2 -2
- package/dist/features/ai/protocol/agent-ops.js +1 -1
- package/dist/features/ai/protocol/agent-ops.js.map +1 -1
- package/dist/features/ai/protocol/block-lines.d.ts +7 -7
- package/dist/features/ai/protocol/block-lines.js +10 -10
- package/dist/features/ai/protocol/block-lines.js.map +1 -1
- package/dist/features/ai/protocol/chat.d.ts +5 -5
- package/dist/features/ai/protocol/chat.js +12 -12
- package/dist/features/ai/protocol/chat.js.map +1 -1
- package/dist/features/ai/protocol/generate.d.ts +1 -1
- package/dist/features/ai/protocol/generate.js +1 -1
- package/dist/features/ai/protocol/generate.js.map +1 -1
- package/dist/features/ai/protocol/index.d.ts +3 -3
- package/dist/features/ai/protocol/index.js +2 -2
- package/dist/features/ai/protocol/models.d.ts +3 -3
- package/dist/features/ai/protocol/models.js +3 -3
- package/dist/features/ai/protocol/models.js.map +1 -1
- package/dist/features/ai/protocol/schemas.d.ts +1 -1
- package/dist/features/ai/protocol/schemas.js +1 -1
- package/dist/features/ai/protocol/schemas.js.map +1 -1
- package/dist/features/ai/protocol/tasks.d.ts +5 -5
- package/dist/features/ai/protocol/tasks.js +12 -12
- package/dist/features/ai/protocol/tasks.js.map +1 -1
- package/dist/features/ai/react/AiSelectionMenu.js.map +1 -1
- package/dist/features/ai/react/ModelQuickSwitch.d.ts +4 -4
- package/dist/features/ai/react/ModelQuickSwitch.js +6 -6
- package/dist/features/ai/react/ModelQuickSwitch.js.map +1 -1
- package/dist/features/ai/react/SettingsAiTab.d.ts +1 -1
- package/dist/features/ai/react/SettingsAiTab.js +8 -8
- package/dist/features/ai/react/SettingsAiTab.js.map +1 -1
- package/dist/features/ai/react/SettingsModelProfiles.d.ts +1 -1
- package/dist/features/ai/react/SettingsModelProfiles.js +1 -1
- package/dist/features/ai/react/SettingsModelProfiles.js.map +1 -1
- package/dist/features/ai/react/use-ai-assistant.d.ts +1 -1
- package/dist/features/ai/react/use-ai-assistant.js +1 -1
- package/dist/features/ai/react/use-ai-assistant.js.map +1 -1
- package/dist/features/ai/react/use-model-profiles.d.ts +5 -5
- package/dist/features/ai/react/use-model-profiles.js +2 -2
- package/dist/features/ai/react/use-model-profiles.js.map +1 -1
- package/dist/features/ai/use-ai-assistant.d.ts +1 -1
- package/dist/features/ai/use-ai-assistant.js +1 -1
- package/dist/features/ai/use-ai-assistant.js.map +1 -1
- package/dist/features/ai/use-model-profiles.d.ts +4 -4
- package/dist/features/ai/use-model-profiles.js +2 -2
- package/dist/features/ai/use-model-profiles.js.map +1 -1
- package/dist/features/block-ui/block-actions.d.ts +8 -4
- package/dist/features/block-ui/block-actions.js +38 -22
- package/dist/features/block-ui/block-actions.js.map +1 -1
- package/dist/features/block-ui/block-target.d.ts +29 -0
- package/dist/features/block-ui/block-target.js +63 -0
- package/dist/features/block-ui/block-target.js.map +1 -0
- package/dist/features/block-ui/components/BlockHandles.js +3 -3
- package/dist/features/block-ui/components/BlockHandles.js.map +1 -1
- package/dist/features/block-ui/components/BlockUi.js +11 -23
- package/dist/features/block-ui/components/BlockUi.js.map +1 -1
- package/dist/features/block-ui/feature.d.ts +3 -2
- package/dist/features/block-ui/feature.js +3 -2
- package/dist/features/block-ui/feature.js.map +1 -1
- package/dist/features/block-ui/handle-geometry.js +12 -23
- package/dist/features/block-ui/handle-geometry.js.map +1 -1
- package/dist/features/block-ui/index.d.ts +2 -1
- package/dist/features/block-ui/index.js +2 -1
- package/dist/features/block-ui/react/BlockHandles.d.ts +1 -1
- package/dist/features/block-ui/react/BlockHandles.js +4 -4
- package/dist/features/block-ui/react/BlockHandles.js.map +1 -1
- package/dist/features/block-ui/react/BlockUi.js +13 -25
- package/dist/features/block-ui/react/BlockUi.js.map +1 -1
- package/dist/features/comments/model.js +1 -1
- package/dist/features/composites/accepted-children.d.ts +5 -4
- package/dist/features/composites/accepted-children.js +26 -26
- package/dist/features/composites/accepted-children.js.map +1 -1
- package/dist/features/composites/ai-brief.d.ts +4 -4
- package/dist/features/composites/ai-brief.js +14 -12
- package/dist/features/composites/ai-brief.js.map +1 -1
- package/dist/features/composites/anchors.d.ts +1 -1
- package/dist/features/composites/anchors.js.map +1 -1
- package/dist/features/composites/baskets.d.ts +1 -1
- package/dist/features/composites/baskets.js.map +1 -1
- package/dist/features/composites/bibliography-command.d.ts +1 -1
- package/dist/features/composites/bibliography-form.js +1 -1
- package/dist/features/composites/bibliography-form.js.map +1 -1
- package/dist/features/composites/bibliography.js.map +1 -1
- package/dist/features/composites/block-types-json.d.ts +38 -0
- package/dist/features/composites/block-types-json.js +122 -0
- package/dist/features/composites/block-types-json.js.map +1 -0
- package/dist/features/composites/block-types.d.ts +119 -0
- package/dist/features/composites/block-types.js +343 -0
- package/dist/features/composites/block-types.js.map +1 -0
- package/dist/features/composites/capabilities.js +109 -0
- package/dist/features/composites/capabilities.js.map +1 -0
- package/dist/features/composites/components/BibliographyEditor.js +5 -5
- package/dist/features/composites/components/BibliographyEditor.js.map +1 -1
- package/dist/features/composites/components/CompositeBasketMenu.js +2 -2
- package/dist/features/composites/components/CompositeBasketMenu.js.map +1 -1
- package/dist/features/composites/components/CompositeChrome.js +18 -8
- package/dist/features/composites/components/CompositeChrome.js.map +1 -1
- package/dist/features/composites/components/CompositeChrome.vue.d.ts +1 -1
- package/dist/features/composites/components/CompositeDetails.js +11 -10
- package/dist/features/composites/components/CompositeDetails.js.map +1 -1
- package/dist/features/composites/components/CompositeDetails.vue.d.ts +1 -1
- package/dist/features/composites/components/CompositeFieldEditor.js +7 -7
- package/dist/features/composites/components/CompositeFieldEditor.js.map +1 -1
- package/dist/features/composites/components/CompositeFieldEditor.vue.d.ts +5 -5
- package/dist/features/composites/components/CompositeInspector.js +136 -113
- package/dist/features/composites/components/CompositeInspector.js.map +1 -1
- package/dist/features/composites/components/CompositeInspector.vue.d.ts +3 -3
- package/dist/features/composites/components/CompositeStatusMenu.js +2 -2
- package/dist/features/composites/components/CompositeStatusMenu.js.map +1 -1
- package/dist/features/composites/components/CompositeSummaryEditor.js +1 -1
- package/dist/features/composites/components/CompositeSummaryEditor.js.map +1 -1
- package/dist/features/composites/components/CompositeSummaryEditor.vue.d.ts +1 -1
- package/dist/features/composites/components/CompositeTable.js +2 -2
- package/dist/features/composites/components/CompositeTable.js.map +1 -1
- package/dist/features/composites/components/CompositeTagsEditor.js +1 -1
- package/dist/features/composites/components/CompositeTagsEditor.js.map +1 -1
- package/dist/features/composites/components/CompositeTagsEditor.vue.d.ts +1 -1
- package/dist/features/composites/components/CompositeView.js +19 -17
- package/dist/features/composites/components/CompositeView.js.map +1 -1
- package/dist/features/composites/components/DerivationBadge.js +15 -6
- package/dist/features/composites/components/DerivationBadge.js.map +1 -1
- package/dist/features/composites/components/FocusChip.js +1 -1
- package/dist/features/composites/components/FocusChip.js.map +1 -1
- package/dist/features/composites/components/FocusChip.vue.d.ts +1 -1
- package/dist/features/composites/components/ReferenceFieldSelect.js +3 -3
- package/dist/features/composites/components/ReferenceFieldSelect.js.map +1 -1
- package/dist/features/composites/components/ReferenceView.js +1 -1
- package/dist/features/composites/components/ReferenceView.js.map +1 -1
- package/dist/features/composites/components/SettingsEditingTab.js +18 -18
- package/dist/features/composites/components/SettingsEditingTab.js.map +1 -1
- package/dist/features/composites/components/SettingsEditingTab.vue.d.ts +3 -3
- package/dist/features/composites/convert.d.ts +4 -4
- package/dist/features/composites/convert.js +27 -28
- package/dist/features/composites/convert.js.map +1 -1
- package/dist/features/composites/derived-chrome.js +34 -28
- package/dist/features/composites/derived-chrome.js.map +1 -1
- package/dist/features/composites/editing-settings-keys.js +6 -6
- package/dist/features/composites/editing-settings-keys.js.map +1 -1
- package/dist/features/composites/feature.d.ts +10 -10
- package/dist/features/composites/feature.js +58 -46
- package/dist/features/composites/feature.js.map +1 -1
- package/dist/features/composites/fences.d.ts +3 -3
- package/dist/features/composites/fences.js +18 -13
- package/dist/features/composites/fences.js.map +1 -1
- package/dist/features/composites/focus.d.ts +10 -10
- package/dist/features/composites/focus.js +11 -11
- package/dist/features/composites/focus.js.map +1 -1
- package/dist/features/composites/heading-composites.d.ts +5 -5
- package/dist/features/composites/heading-composites.js +13 -16
- package/dist/features/composites/heading-composites.js.map +1 -1
- package/dist/features/composites/index.d.ts +20 -18
- package/dist/features/composites/index.js +9 -7
- package/dist/features/composites/inspector-model.d.ts +45 -22
- package/dist/features/composites/inspector-model.js +53 -14
- package/dist/features/composites/inspector-model.js.map +1 -1
- package/dist/features/composites/legacy.d.ts +5 -4
- package/dist/features/composites/legacy.js +16 -23
- package/dist/features/composites/legacy.js.map +1 -1
- package/dist/features/composites/markdown-export.js +3 -3
- package/dist/features/composites/markdown-export.js.map +1 -1
- package/dist/features/composites/merge.d.ts +8 -7
- package/dist/features/composites/merge.js +39 -12
- package/dist/features/composites/merge.js.map +1 -1
- package/dist/features/composites/meta-display.js +5 -5
- package/dist/features/composites/meta-display.js.map +1 -1
- package/dist/features/composites/meta-keys.d.ts +5 -5
- package/dist/features/composites/meta-keys.js +8 -8
- package/dist/features/composites/meta-keys.js.map +1 -1
- package/dist/features/composites/node-views.d.ts +3 -3
- package/dist/features/composites/node-views.js +2 -2
- package/dist/features/composites/node-views.js.map +1 -1
- package/dist/features/composites/nodes.d.ts +13 -13
- package/dist/features/composites/nodes.js +100 -77
- package/dist/features/composites/nodes.js.map +1 -1
- package/dist/features/composites/outline.d.ts +15 -12
- package/dist/features/composites/outline.js +24 -21
- package/dist/features/composites/outline.js.map +1 -1
- package/dist/features/composites/properties.d.ts +51 -0
- package/dist/features/composites/properties.js +89 -0
- package/dist/features/composites/properties.js.map +1 -0
- package/dist/features/composites/react/BibliographyEditor.js +5 -5
- package/dist/features/composites/react/BibliographyEditor.js.map +1 -1
- package/dist/features/composites/react/CompositeBasketMenu.js +2 -2
- package/dist/features/composites/react/CompositeBasketMenu.js.map +1 -1
- package/dist/features/composites/react/CompositeChrome.d.ts +1 -1
- package/dist/features/composites/react/CompositeChrome.js +15 -6
- package/dist/features/composites/react/CompositeChrome.js.map +1 -1
- package/dist/features/composites/react/CompositeDetails.d.ts +1 -1
- package/dist/features/composites/react/CompositeDetails.js +11 -10
- package/dist/features/composites/react/CompositeDetails.js.map +1 -1
- package/dist/features/composites/react/CompositeFieldEditor.d.ts +5 -5
- package/dist/features/composites/react/CompositeFieldEditor.js +6 -6
- package/dist/features/composites/react/CompositeFieldEditor.js.map +1 -1
- package/dist/features/composites/react/CompositeInspector.d.ts +3 -3
- package/dist/features/composites/react/CompositeInspector.js +142 -128
- package/dist/features/composites/react/CompositeInspector.js.map +1 -1
- package/dist/features/composites/react/CompositeStatusMenu.js +2 -2
- package/dist/features/composites/react/CompositeStatusMenu.js.map +1 -1
- package/dist/features/composites/react/CompositeSummaryEditor.d.ts +1 -1
- package/dist/features/composites/react/CompositeSummaryEditor.js +1 -1
- package/dist/features/composites/react/CompositeSummaryEditor.js.map +1 -1
- package/dist/features/composites/react/CompositeTable.d.ts +1 -1
- package/dist/features/composites/react/CompositeTable.js +3 -3
- package/dist/features/composites/react/CompositeTable.js.map +1 -1
- package/dist/features/composites/react/CompositeTagsEditor.d.ts +1 -1
- package/dist/features/composites/react/CompositeTagsEditor.js +1 -1
- package/dist/features/composites/react/CompositeTagsEditor.js.map +1 -1
- package/dist/features/composites/react/CompositeView.js +17 -15
- package/dist/features/composites/react/CompositeView.js.map +1 -1
- package/dist/features/composites/react/DerivationBadge.js +13 -4
- package/dist/features/composites/react/DerivationBadge.js.map +1 -1
- package/dist/features/composites/react/FocusChip.d.ts +1 -1
- package/dist/features/composites/react/FocusChip.js +1 -1
- package/dist/features/composites/react/FocusChip.js.map +1 -1
- package/dist/features/composites/react/ReferenceFieldSelect.js +3 -3
- package/dist/features/composites/react/ReferenceFieldSelect.js.map +1 -1
- package/dist/features/composites/react/ReferenceView.d.ts +1 -1
- package/dist/features/composites/react/ReferenceView.js +1 -1
- package/dist/features/composites/react/ReferenceView.js.map +1 -1
- package/dist/features/composites/react/SettingsEditingTab.d.ts +4 -4
- package/dist/features/composites/react/SettingsEditingTab.js +20 -20
- package/dist/features/composites/react/SettingsEditingTab.js.map +1 -1
- package/dist/features/composites/react.js +1 -1
- package/dist/features/composites/react.js.map +1 -1
- package/dist/features/composites/reference-ai.js +1 -1
- package/dist/features/composites/reference-ai.js.map +1 -1
- package/dist/features/composites/reference-label.d.ts +3 -3
- package/dist/features/composites/reference-label.js +6 -6
- package/dist/features/composites/reference-label.js.map +1 -1
- package/dist/features/composites/reference-suggestion.d.ts +1 -1
- package/dist/features/composites/reference-suggestion.js +3 -3
- package/dist/features/composites/reference-suggestion.js.map +1 -1
- package/dist/features/composites/reference-text.d.ts +2 -2
- package/dist/features/composites/reference-text.js +4 -4
- package/dist/features/composites/reference-text.js.map +1 -1
- package/dist/features/composites/reference.d.ts +3 -3
- package/dist/features/composites/reference.js +1 -1
- package/dist/features/composites/reference.js.map +1 -1
- package/dist/features/composites/reveal-source.d.ts +3 -3
- package/dist/features/composites/reveal-source.js +6 -6
- package/dist/features/composites/reveal-source.js.map +1 -1
- package/dist/features/composites/rows-model.d.ts +2 -2
- package/dist/features/composites/rows-model.js +4 -3
- package/dist/features/composites/rows-model.js.map +1 -1
- package/dist/features/composites/rows.d.ts +16 -28
- package/dist/features/composites/rows.js +20 -54
- package/dist/features/composites/rows.js.map +1 -1
- package/dist/features/composites/schema.d.ts +12 -11
- package/dist/features/composites/schema.js +10 -9
- package/dist/features/composites/schema.js.map +1 -1
- package/dist/features/composites/source.d.ts +20 -0
- package/dist/features/composites/source.js +40 -0
- package/dist/features/composites/source.js.map +1 -0
- package/dist/features/composites/split.d.ts +11 -11
- package/dist/features/composites/split.js +20 -20
- package/dist/features/composites/split.js.map +1 -1
- package/dist/features/composites/structure-mode.js +3 -3
- package/dist/features/composites/structure-mode.js.map +1 -1
- package/dist/features/composites/table-model.js +2 -2
- package/dist/features/composites/table-model.js.map +1 -1
- package/dist/features/composites/use-composite-inspector.js +3 -1
- package/dist/features/composites/use-composite-inspector.js.map +1 -1
- package/dist/features/composites/use-composite-rows.d.ts +2 -2
- package/dist/features/composites/use-composite-rows.js.map +1 -1
- package/dist/features/composites/vue.js +1 -1
- package/dist/features/composites/vue.js.map +1 -1
- package/dist/features/image-studio/components/ImageStudioDialog.js +1 -1
- package/dist/features/image-studio/components/ImageStudioDialog.js.map +1 -1
- package/dist/features/image-studio/components/ImageStudioDialog.vue.d.ts +1 -1
- package/dist/features/image-studio/components/ImageStudioView.js.map +1 -1
- package/dist/features/image-studio/feature.d.ts +1 -1
- package/dist/features/image-studio/feature.js +1 -1
- package/dist/features/image-studio/feature.js.map +1 -1
- package/dist/features/image-studio/node-core.d.ts +3 -3
- package/dist/features/image-studio/node-core.js +1 -1
- package/dist/features/image-studio/node-core.js.map +1 -1
- package/dist/features/image-studio/node-store.d.ts +1 -1
- package/dist/features/image-studio/node-store.js +1 -1
- package/dist/features/image-studio/node-store.js.map +1 -1
- package/dist/features/image-studio/react/ImageStudioDialog.d.ts +1 -1
- package/dist/features/image-studio/react/ImageStudioDialog.js +1 -1
- package/dist/features/image-studio/react/ImageStudioDialog.js.map +1 -1
- package/dist/features/image-studio/react/ImageStudioView.js +1 -1
- package/dist/features/image-studio/react/ImageStudioView.js.map +1 -1
- package/dist/features/image-studio/react/store.d.ts +3 -3
- package/dist/features/image-studio/react/store.js.map +1 -1
- package/dist/features/image-studio/react.d.ts +1 -1
- package/dist/features/image-studio/react.js +1 -1
- package/dist/features/image-studio/react.js.map +1 -1
- package/dist/features/image-studio/schema.d.ts +1 -1
- package/dist/features/image-studio/schema.js +1 -1
- package/dist/features/image-studio/schema.js.map +1 -1
- package/dist/features/image-studio/state.d.ts +3 -3
- package/dist/features/image-studio/state.js +2 -2
- package/dist/features/image-studio/state.js.map +1 -1
- package/dist/features/image-studio/store.d.ts +3 -3
- package/dist/features/image-studio/vue.d.ts +1 -1
- package/dist/features/image-studio/vue.js +1 -1
- package/dist/features/image-studio/vue.js.map +1 -1
- package/dist/features/media/index.js +1 -1
- package/dist/features/media/react/AudioRecorderModal.js +1 -1
- package/dist/features/media/react.js +1 -1
- package/dist/features/mentions/tag.js +2 -1
- package/dist/features/mentions/tag.js.map +1 -1
- package/dist/features/themes/components/SettingsAppearanceTab.js +1 -1
- package/dist/features/themes/components/SettingsAppearanceTab.js.map +1 -1
- package/dist/features/themes/feature.d.ts +1 -1
- package/dist/features/themes/feature.js.map +1 -1
- package/dist/features/themes/react/SettingsAppearanceTab.d.ts +1 -1
- package/dist/features/themes/react/SettingsAppearanceTab.js +1 -1
- package/dist/features/themes/react/SettingsAppearanceTab.js.map +1 -1
- package/dist/features/themes/theme-runtime.js +1 -1
- package/dist/features/themes/theme-runtime.js.map +1 -1
- package/dist/features/transcript/TranscriptSegmentView.js +1 -1
- package/dist/features/transcript/TranscriptSegmentView.js.map +1 -1
- package/dist/features/transcript/react/TranscriptSegmentView.js +1 -1
- package/dist/features/transcript/react/TranscriptSegmentView.js.map +1 -1
- package/dist/features/transcript/segment-node.js.map +1 -1
- package/dist/features/transfer/feature.js +1 -1
- package/dist/features/transfer/feature.js.map +1 -1
- package/dist/features/transfer/transforms.d.ts +4 -4
- package/dist/features/transfer/transforms.js +12 -12
- package/dist/features/transfer/transforms.js.map +1 -1
- package/dist/i18n/de/ai.js +4 -4
- package/dist/i18n/de/ai.js.map +1 -1
- package/dist/i18n/de/authors.js +1 -1
- package/dist/i18n/de/authors.js.map +1 -1
- package/dist/i18n/de/comments.js +1 -1
- package/dist/i18n/de/comments.js.map +1 -1
- package/dist/i18n/de/composites.js +62 -59
- package/dist/i18n/de/composites.js.map +1 -1
- package/dist/i18n/de/image-studio.js +2 -2
- package/dist/i18n/de/image-studio.js.map +1 -1
- package/dist/i18n/de/integrations.js +20 -20
- package/dist/i18n/de/integrations.js.map +1 -1
- package/dist/i18n/de/markdown.js +1 -1
- package/dist/i18n/de/markdown.js.map +1 -1
- package/dist/i18n/de/palette.js +1 -1
- package/dist/i18n/de/palette.js.map +1 -1
- package/dist/i18n/de/themes.js +3 -3
- package/dist/i18n/de/themes.js.map +1 -1
- package/dist/i18n/de/transfer.js +2 -2
- package/dist/i18n/de/transfer.js.map +1 -1
- package/dist/i18n/de/tree.js +6 -6
- package/dist/i18n/de/tree.js.map +1 -1
- package/dist/i18n/de.d.ts +101 -98
- package/dist/i18n/en/ai.js +2 -2
- package/dist/i18n/en/ai.js.map +1 -1
- package/dist/i18n/en/composites.js +64 -61
- package/dist/i18n/en/composites.js.map +1 -1
- package/dist/i18n/en/integrations.js +9 -9
- package/dist/i18n/en/integrations.js.map +1 -1
- package/dist/i18n/en/markdown.js +1 -1
- package/dist/i18n/en/markdown.js.map +1 -1
- package/dist/i18n/en/palette.js +1 -1
- package/dist/i18n/en/palette.js.map +1 -1
- package/dist/i18n/en/themes.js +4 -4
- package/dist/i18n/en/themes.js.map +1 -1
- package/dist/i18n/en/tree.js +5 -5
- package/dist/i18n/en/tree.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/integrations/composite-ai/bibliography-fetch.d.ts +6 -6
- package/dist/integrations/composite-ai/bibliography-fetch.js +19 -19
- package/dist/integrations/composite-ai/bibliography-fetch.js.map +1 -1
- package/dist/integrations/composite-ai/composite-fill.d.ts +4 -4
- package/dist/integrations/composite-ai/composite-fill.js +5 -5
- package/dist/integrations/composite-ai/composite-fill.js.map +1 -1
- package/dist/integrations/composite-ai/composite-summary.d.ts +2 -2
- package/dist/integrations/composite-ai/composite-summary.js +5 -5
- package/dist/integrations/composite-ai/composite-summary.js.map +1 -1
- package/dist/integrations/composite-ai/derive.d.ts +17 -17
- package/dist/integrations/composite-ai/derive.js +27 -26
- package/dist/integrations/composite-ai/derive.js.map +1 -1
- package/dist/integrations/composite-ai/index.d.ts +14 -15
- package/dist/integrations/composite-ai/index.js +98 -77
- package/dist/integrations/composite-ai/index.js.map +1 -1
- package/dist/integrations/composite-ai/outline-sanitize.d.ts +1 -1
- package/dist/integrations/composite-ai/outline-sanitize.js +1 -1
- package/dist/integrations/composite-ai/outline-sanitize.js.map +1 -1
- package/dist/integrations/composite-ai/rendition.d.ts +9 -9
- package/dist/integrations/composite-ai/rendition.js +27 -27
- package/dist/integrations/composite-ai/rendition.js.map +1 -1
- package/dist/integrations/composite-ai/split.d.ts +8 -8
- package/dist/integrations/composite-ai/split.js +12 -12
- package/dist/integrations/composite-ai/split.js.map +1 -1
- package/dist/integrations/composite-ai/transfer-transforms.d.ts +2 -2
- package/dist/integrations/composite-ai/transfer-transforms.js +12 -12
- package/dist/integrations/composite-ai/transfer-transforms.js.map +1 -1
- package/dist/integrations/composite-media/index.d.ts +4 -3
- package/dist/integrations/composite-media/index.js +20 -14
- package/dist/integrations/composite-media/index.js.map +1 -1
- package/dist/markdown/MarkdownSurface.vue.d.ts +7 -7
- package/dist/markdown/document.js +1 -1
- package/dist/markdown/document.js.map +1 -1
- package/dist/nuxt/module.d.ts +30 -24
- package/dist/nuxt/module.js.map +1 -1
- package/dist/nuxt/runtime/server/plugins/editor-server.js +3 -2
- package/dist/nuxt/runtime/server/plugins/editor-server.js.map +1 -1
- package/dist/presets/compose.d.ts +6 -6
- package/dist/presets/compose.js +8 -5
- package/dist/presets/compose.js.map +1 -1
- package/dist/react/AdvancedEditor.d.ts +2 -2
- package/dist/react/AdvancedEditor.js +1 -1
- package/dist/react/AdvancedEditor.js.map +1 -1
- package/dist/react/compose.d.ts +1 -1
- package/dist/react/compose.js +2 -2
- package/dist/react/compose.js.map +1 -1
- package/dist/react/composed-surface.d.ts +5 -5
- package/dist/react/composed-surface.js +2 -2
- package/dist/react/composed-surface.js.map +1 -1
- package/dist/server/ai.d.ts +7 -7
- package/dist/server/ai.js +1 -1
- package/dist/server/ai.js.map +1 -1
- package/dist/server/auth.d.ts +1 -1
- package/dist/server/collab-state.d.ts +1 -1
- package/dist/server/collab-state.js.map +1 -1
- package/dist/server/collab.d.ts +4 -4
- package/dist/server/collab.js +22 -17
- package/dist/server/collab.js.map +1 -1
- package/dist/server/handlers/ai.d.ts +9 -6
- package/dist/server/handlers/ai.js +13 -17
- package/dist/server/handlers/ai.js.map +1 -1
- package/dist/server/handlers/context.d.ts +4 -0
- package/dist/server/handlers/context.js.map +1 -1
- package/dist/server/handlers/editor.d.ts +33 -32
- package/dist/server/handlers/editor.js +13 -8
- package/dist/server/handlers/editor.js.map +1 -1
- package/dist/server/handlers/images.d.ts +1 -1
- package/dist/server/handlers/images.js +1 -1
- package/dist/server/handlers/images.js.map +1 -1
- package/dist/server/host.d.ts +4 -0
- package/dist/server/host.js +10 -2
- package/dist/server/host.js.map +1 -1
- package/dist/server/index.d.ts +3 -3
- package/dist/server/ports.d.ts +8 -8
- package/dist/server/ports.js.map +1 -1
- package/dist/settings/index.d.ts +20 -19
- package/dist/settings/index.js +25 -24
- package/dist/settings/index.js.map +1 -1
- package/dist/settings/migrate.d.ts +18 -0
- package/dist/settings/migrate.js +46 -0
- package/dist/settings/migrate.js.map +1 -0
- package/dist/settings/values.d.ts +12 -12
- package/dist/settings/values.js +11 -11
- package/dist/settings/values.js.map +1 -1
- package/dist/styles/composites.css +10 -10
- package/dist/tree/DocumentTree.js +12 -5
- package/dist/tree/DocumentTree.js.map +1 -1
- package/dist/tree/drop-rules.js +5 -5
- package/dist/tree/drop-rules.js.map +1 -1
- package/dist/tree/react/DocumentTree.js +14 -5
- package/dist/tree/react/DocumentTree.js.map +1 -1
- package/dist/tree/tree-host.js +6 -6
- package/dist/tree/tree-host.js.map +1 -1
- package/dist/tree/tree-items.js +34 -28
- package/dist/tree/tree-items.js.map +1 -1
- package/dist/tree/tree-model.js +16 -16
- package/dist/tree/tree-model.js.map +1 -1
- package/dist/tree/tree-rows.js +2 -2
- package/dist/tree/tree-rows.js.map +1 -1
- package/dist/tree/tree-view-model.d.ts +2 -2
- package/dist/tree/tree-view-model.js.map +1 -1
- package/dist/vue/AdvancedEditor.js +2 -2
- package/dist/vue/AdvancedEditor.js.map +1 -1
- package/dist/vue/AdvancedEditor.vue.d.ts +10 -10
- package/dist/vue/SimpleEditor.vue.d.ts +4 -4
- package/dist/vue/components/EditorSurface.vue.d.ts +4 -4
- package/dist/vue/compose.d.ts +1 -1
- package/dist/vue/compose.js +2 -2
- package/dist/vue/compose.js.map +1 -1
- package/package.json +1 -1
- package/dist/features/composites/derivation.d.ts +0 -62
- package/dist/features/composites/derivation.js +0 -102
- package/dist/features/composites/derivation.js.map +0 -1
- package/dist/features/composites/kinds.d.ts +0 -83
- package/dist/features/composites/kinds.js +0 -285
- package/dist/features/composites/kinds.js.map +0 -1
|
@@ -32,6 +32,13 @@ interface BlockActionBase {
|
|
|
32
32
|
icon: string;
|
|
33
33
|
/** Shown only on blocks that have this ability; shown on every block when unset. */
|
|
34
34
|
ability?: Ability;
|
|
35
|
+
/**
|
|
36
|
+
* Block capabilities (`EditorFeature.blockCapabilities`, built-in `container` and `title`) the block must all have; hidden
|
|
37
|
+
* otherwise. Replaces node-name checks in `isVisible`. An id no Feature declares is an error when the actions are collected (`blockActionsOf`).
|
|
38
|
+
*/
|
|
39
|
+
requires?: readonly string[];
|
|
40
|
+
/** Block type ids (`attrs.blockType`) the action is for; hidden on blocks of any other type. Only for an action that is truly type-specific: what a block can do is a capability (`requires`). */
|
|
41
|
+
blockTypes?: readonly string[];
|
|
35
42
|
/** Further condition; hidden when it returns false. */
|
|
36
43
|
isVisible?: (ctx: BlockActionContext) => boolean;
|
|
37
44
|
/** Position among the actions (ascending, stable); built-ins use their visual sequence, host actions follow them. */
|
|
@@ -41,6 +48,15 @@ interface BlockActionBase {
|
|
|
41
48
|
* selection, or both (default). The block-ui feature decides which of these surfaces exist (`BlockUiOptions.actions`).
|
|
42
49
|
*/
|
|
43
50
|
placement?: 'hover' | 'toolbar' | 'both';
|
|
51
|
+
/**
|
|
52
|
+
* The block the action is about. `'block'` (default): the block the surface addresses (hover: the hovered block;
|
|
53
|
+
* toolbar: the block holding the selection, the innermost one). `'typedBlock'`: on the toolbar, the Typed block around that
|
|
54
|
+
* block (the block itself when it is a Typed block), so an action of a Typed block stays reachable while the caret is in
|
|
55
|
+
* a paragraph inside it. The action is then checked against that Typed block (`ability`, `requires`, `blockTypes`,
|
|
56
|
+
* `isVisible`) and gets its node and position in the context; with no Typed block around, it is absent. The hover bar
|
|
57
|
+
* ignores it: hovering a Typed block's chrome already addresses the Typed block.
|
|
58
|
+
*/
|
|
59
|
+
target?: 'block' | 'typedBlock';
|
|
44
60
|
}
|
|
45
61
|
/**
|
|
46
62
|
* An entry of the block actions shown top-right of a block (`BlockActionsOverlay`); hosts add their own via `blockActions`.
|
|
@@ -27,7 +27,11 @@ export interface FeatureContextOptions {
|
|
|
27
27
|
* list lazily (features' commands, then the host's transformer), once. Call it during component setup.
|
|
28
28
|
*/
|
|
29
29
|
export declare function createFeatureContext(options: FeatureContextOptions): FeatureContext;
|
|
30
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* The features' block actions and the actions of their derive methods (`deriveActionsOf`) in `order` (stable), followed by the
|
|
32
|
+
* host's. Throws when an action `requires` a capability no feature of `preset` declares (the actions only exist once a feature
|
|
33
|
+
* context does, so `defineEditor` cannot check them; a derive method's `requires` it does check).
|
|
34
|
+
*/
|
|
31
35
|
export declare function blockActionsOf(preset: EditorPreset, ctx: FeatureContext, hostActions?: readonly BlockAction[]): BlockAction[];
|
|
32
36
|
//#endregion
|
|
33
37
|
//# sourceMappingURL=feature-context.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { byOrder } from "./util.js";
|
|
1
|
+
import { byOrder, fail } from "./util.js";
|
|
2
|
+
import { deriveActionsOf } from "./derive.js";
|
|
2
3
|
import { contributions } from "./define-editor.js";
|
|
3
4
|
import { assertUniqueCommandIds, commandsOf } from "./commands.js";
|
|
4
5
|
//#region src/core/feature-context.ts
|
|
@@ -37,9 +38,15 @@ function createFeatureContext(options) {
|
|
|
37
38
|
for (const defaults of contributions(preset, "metadataDefaults")) ctx.metadata.defaults(defaults(ctx));
|
|
38
39
|
return ctx;
|
|
39
40
|
}
|
|
40
|
-
/**
|
|
41
|
+
/**
|
|
42
|
+
* The features' block actions and the actions of their derive methods (`deriveActionsOf`) in `order` (stable), followed by the
|
|
43
|
+
* host's. Throws when an action `requires` a capability no feature of `preset` declares (the actions only exist once a feature
|
|
44
|
+
* context does, so `defineEditor` cannot check them; a derive method's `requires` it does check).
|
|
45
|
+
*/
|
|
41
46
|
function blockActionsOf(preset, ctx, hostActions = []) {
|
|
42
|
-
|
|
47
|
+
const actions = [...[...contributions(preset, "blockActions").flatMap((factory) => factory(ctx)), ...deriveActionsOf(preset, ctx)].sort(byOrder), ...hostActions];
|
|
48
|
+
for (const action of actions) for (const required of action.requires ?? []) if (!preset.capabilities.has(required)) fail(`the block action "${action.id}" requires the capability "${required}", which no feature declares`, "blockActionsOf");
|
|
49
|
+
return actions;
|
|
43
50
|
}
|
|
44
51
|
//#endregion
|
|
45
52
|
export { blockActionsOf, createFeatureContext };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature-context.js","names":[],"sources":["../../src/core/feature-context.ts"],"sourcesContent":["import type { Editor } from '@tiptap/core'\nimport type { EditorContext } from './context'\nimport { assertUniqueCommandIds, type CommandDef, commandsOf } from './commands'\nimport { contributions } from './define-editor'\nimport type { EditorUi } from './editor-ui'\nimport type { AbilitiesOptions, BlockAction } from './extension-points'\nimport type { CollaborationSession, EditorPreset, FeatureContext } from './feature'\nimport type { MetadataRegistry } from './metadata'\nimport type { Notifier } from './notify'\nimport { byOrder } from './util'\n\nexport interface FeatureContextOptions {\n app: EditorContext\n preset: EditorPreset\n ui: EditorUi\n metadata: MetadataRegistry\n /** The surface's notice renderer (Nuxt UI toast, sonner). */\n notify: Notifier\n getEditor: () => Editor | undefined\n documentId?: string\n collaboration?: CollaborationSession\n abilities?: Partial<AbilitiesOptions>\n /** Host transformer of the command list (and with it the `/` menu): receives the features' commands, returns the final list. */\n commands?: (defaults: CommandDef[]) => CommandDef[]\n}\n\n/**\n * The context of one mounted surface (see `FeatureContext`). Resolves the preset's anchor resolver and builds the command\n * list lazily (features' commands, then the host's transformer), once. Call it during component setup.\n */\nexport function createFeatureContext(options: FeatureContextOptions): FeatureContext {\n const { app, preset } = options\n let list: CommandDef[] | undefined\n const ctx: { -readonly [K in keyof FeatureContext]: FeatureContext[K] } = {\n app,\n settings: app.settings,\n metadata: options.metadata,\n ui: options.ui,\n notify: options.notify,\n locale: app.locale,\n t: app.t,\n backend: app.backend,\n ai: app.ai,\n documentId: options.documentId,\n collaboration: options.collaboration,\n anchorResolver: null,\n abilities: options.abilities ?? {},\n commands: () => {\n if (!list) {\n const defaults = commandsOf(preset, ctx)\n list = options.commands ? options.commands(defaults) : defaults\n if (options.commands) assertUniqueCommandIds(list)\n }\n return list\n },\n getEditor: options.getEditor,\n }\n ctx.anchorResolver = contributions(preset, 'anchorResolver')[0]?.(ctx) ?? null\n for (const defaults of contributions(preset, 'metadataDefaults')) ctx.metadata.defaults(defaults(ctx))\n return ctx\n}\n\n
|
|
1
|
+
{"version":3,"file":"feature-context.js","names":[],"sources":["../../src/core/feature-context.ts"],"sourcesContent":["import type { Editor } from '@tiptap/core'\nimport type { EditorContext } from './context'\nimport { assertUniqueCommandIds, type CommandDef, commandsOf } from './commands'\nimport { contributions } from './define-editor'\nimport { deriveActionsOf } from './derive'\nimport type { EditorUi } from './editor-ui'\nimport type { AbilitiesOptions, BlockAction } from './extension-points'\nimport type { CollaborationSession, EditorPreset, FeatureContext } from './feature'\nimport type { MetadataRegistry } from './metadata'\nimport type { Notifier } from './notify'\nimport { byOrder, fail } from './util'\n\nexport interface FeatureContextOptions {\n app: EditorContext\n preset: EditorPreset\n ui: EditorUi\n metadata: MetadataRegistry\n /** The surface's notice renderer (Nuxt UI toast, sonner). */\n notify: Notifier\n getEditor: () => Editor | undefined\n documentId?: string\n collaboration?: CollaborationSession\n abilities?: Partial<AbilitiesOptions>\n /** Host transformer of the command list (and with it the `/` menu): receives the features' commands, returns the final list. */\n commands?: (defaults: CommandDef[]) => CommandDef[]\n}\n\n/**\n * The context of one mounted surface (see `FeatureContext`). Resolves the preset's anchor resolver and builds the command\n * list lazily (features' commands, then the host's transformer), once. Call it during component setup.\n */\nexport function createFeatureContext(options: FeatureContextOptions): FeatureContext {\n const { app, preset } = options\n let list: CommandDef[] | undefined\n const ctx: { -readonly [K in keyof FeatureContext]: FeatureContext[K] } = {\n app,\n settings: app.settings,\n metadata: options.metadata,\n ui: options.ui,\n notify: options.notify,\n locale: app.locale,\n t: app.t,\n backend: app.backend,\n ai: app.ai,\n documentId: options.documentId,\n collaboration: options.collaboration,\n anchorResolver: null,\n abilities: options.abilities ?? {},\n commands: () => {\n if (!list) {\n const defaults = commandsOf(preset, ctx)\n list = options.commands ? options.commands(defaults) : defaults\n if (options.commands) assertUniqueCommandIds(list)\n }\n return list\n },\n getEditor: options.getEditor,\n }\n ctx.anchorResolver = contributions(preset, 'anchorResolver')[0]?.(ctx) ?? null\n for (const defaults of contributions(preset, 'metadataDefaults')) ctx.metadata.defaults(defaults(ctx))\n return ctx\n}\n\n/**\n * The features' block actions and the actions of their derive methods (`deriveActionsOf`) in `order` (stable), followed by the\n * host's. Throws when an action `requires` a capability no feature of `preset` declares (the actions only exist once a feature\n * context does, so `defineEditor` cannot check them; a derive method's `requires` it does check).\n */\nexport function blockActionsOf(preset: EditorPreset, ctx: FeatureContext, hostActions: readonly BlockAction[] = []): BlockAction[] {\n const actions = [...[...contributions(preset, 'blockActions').flatMap(factory => factory(ctx)), ...deriveActionsOf(preset, ctx)].sort(byOrder), ...hostActions]\n for (const action of actions) {\n for (const required of action.requires ?? []) {\n if (!preset.capabilities.has(required)) fail(`the block action \"${action.id}\" requires the capability \"${required}\", which no feature declares`, 'blockActionsOf')\n }\n }\n return actions\n}\n"],"mappings":";;;;;;;;;AA+BA,SAAgB,qBAAqB,SAAgD;CACnF,MAAM,EAAE,KAAK,WAAW;CACxB,IAAI;CACJ,MAAM,MAAoE;EACxE;EACA,UAAU,IAAI;EACd,UAAU,QAAQ;EAClB,IAAI,QAAQ;EACZ,QAAQ,QAAQ;EAChB,QAAQ,IAAI;EACZ,GAAG,IAAI;EACP,SAAS,IAAI;EACb,IAAI,IAAI;EACR,YAAY,QAAQ;EACpB,eAAe,QAAQ;EACvB,gBAAgB;EAChB,WAAW,QAAQ,aAAa,CAAC;EACjC,gBAAgB;GACd,IAAI,CAAC,MAAM;IACT,MAAM,WAAW,WAAW,QAAQ,GAAG;IACvC,OAAO,QAAQ,WAAW,QAAQ,SAAS,QAAQ,IAAI;IACvD,IAAI,QAAQ,UAAU,uBAAuB,IAAI;GACnD;GACA,OAAO;EACT;EACA,WAAW,QAAQ;CACrB;CACA,IAAI,iBAAiB,cAAc,QAAQ,gBAAgB,CAAC,CAAC,EAAE,GAAG,GAAG,KAAK;CAC1E,KAAK,MAAM,YAAY,cAAc,QAAQ,kBAAkB,GAAG,IAAI,SAAS,SAAS,SAAS,GAAG,CAAC;CACrG,OAAO;AACT;;;;;;AAOA,SAAgB,eAAe,QAAsB,KAAqB,cAAsC,CAAC,GAAkB;CACjI,MAAM,UAAU,CAAC,GAAG,CAAC,GAAG,cAAc,QAAQ,cAAc,CAAC,CAAC,SAAQ,YAAW,QAAQ,GAAG,CAAC,GAAG,GAAG,gBAAgB,QAAQ,GAAG,CAAC,CAAC,CAAC,KAAK,OAAO,GAAG,GAAG,WAAW;CAC9J,KAAK,MAAM,UAAU,SACnB,KAAK,MAAM,YAAY,OAAO,YAAY,CAAC,GACzC,IAAI,CAAC,OAAO,aAAa,IAAI,QAAQ,GAAG,KAAK,qBAAqB,OAAO,GAAG,6BAA6B,SAAS,+BAA+B,gBAAgB;CAGrK,OAAO;AACT"}
|
package/dist/core/feature.d.ts
CHANGED
|
@@ -9,8 +9,11 @@ import { ConvertTarget } from "./convert.js";
|
|
|
9
9
|
import { CommandDef, InsertGuard, ToolbarGroupDef, TransactionGuard } from "./command-types.js";
|
|
10
10
|
import { AbilitiesOptions, BlockAction, BlockUiOptions } from "./extension-points.js";
|
|
11
11
|
import { EditorUi } from "./editor-ui.js";
|
|
12
|
+
import { BlockCapability, BlockTypeData, CapabilityRegistry } from "./capabilities.js";
|
|
13
|
+
import { DeriveMethod, DeriveRegistry } from "./derive.js";
|
|
12
14
|
import { EditorMetadata } from "./metadata-types.js";
|
|
13
15
|
import { MetadataRegistry } from "./metadata.js";
|
|
16
|
+
import { PropertyDefinition } from "./properties.js";
|
|
14
17
|
import { AnyExtension, Editor, JSONContent } from "@tiptap/core";
|
|
15
18
|
import { EditorState, Transaction } from "@tiptap/pm/state";
|
|
16
19
|
import { Node as Node$1, ResolvedPos } from "@tiptap/pm/model";
|
|
@@ -32,7 +35,7 @@ export interface CollaborationSession {
|
|
|
32
35
|
provider?: HocuspocusProvider;
|
|
33
36
|
user?: AuthorIdentity;
|
|
34
37
|
/**
|
|
35
|
-
* Token the collaboration server's `
|
|
38
|
+
* Token the collaboration server's `AccessControl.authenticate` receives (`{ headers, token }`), for clients without
|
|
36
39
|
* the session cookie of the server's origin (scripts, agents, cross-origin hosts). A string, or a function called
|
|
37
40
|
* every time the socket opens (so it can refresh an expired token). Applied to `provider`'s configuration when the
|
|
38
41
|
* surface is set up, which the provider reads when its socket opens: create the provider and mount the surface in the
|
|
@@ -99,7 +102,7 @@ export interface SettingsTab<C = unknown> {
|
|
|
99
102
|
label: string;
|
|
100
103
|
icon?: string;
|
|
101
104
|
component: C;
|
|
102
|
-
/** Props handed to `component`, e.g. the configured
|
|
105
|
+
/** Props handed to `component`, e.g. the configured Block types. */
|
|
103
106
|
props?: Record<string, unknown>;
|
|
104
107
|
}
|
|
105
108
|
/** The stages `parseBlocks` and the import/AI insertion paths run; features replace stages, defaults are identity/Markdown. */
|
|
@@ -109,6 +112,7 @@ export interface BlockPipeline {
|
|
|
109
112
|
segment: (editor: Editor, blocks: JSONContent[]) => JSONContent[];
|
|
110
113
|
structure: (editor: Editor, blocks: JSONContent[]) => JSONContent[];
|
|
111
114
|
wrapImport: (editor: Editor, file: File, blocks: JSONContent[]) => JSONContent[];
|
|
115
|
+
/** The loaded document as the current schema reads it. The rename of the old persisted names (`migratePersistedNames`) runs before it: `defineEditor` puts it in front of a contributed hook, so the hook sees current names only. */
|
|
112
116
|
migrateContent: (content: JSONContent) => JSONContent;
|
|
113
117
|
}
|
|
114
118
|
/** Pipeline hooks that allow a single contributor; `normalize` chains instead. */
|
|
@@ -137,22 +141,14 @@ export interface ConversionProvider {
|
|
|
137
141
|
} | null;
|
|
138
142
|
}
|
|
139
143
|
/**
|
|
140
|
-
* Inert public data AI reads about the editor's document model. A
|
|
141
|
-
*
|
|
144
|
+
* Inert public data AI reads about the editor's document model. A Block type's `fields` are its Property definitions: they carry
|
|
145
|
+
* what the model needs to write the properties (`type`, and the choices of a `select`).
|
|
142
146
|
*/
|
|
143
|
-
export interface
|
|
147
|
+
export interface AiContextBlockType {
|
|
144
148
|
id: string;
|
|
145
149
|
label: string;
|
|
146
|
-
fields: readonly
|
|
147
|
-
|
|
148
|
-
label: string;
|
|
149
|
-
type?: 'text' | 'textarea' | 'date' | 'number' | 'select' | 'multiselect' | 'reference' | 'bibliography' | 'derivation';
|
|
150
|
-
options?: readonly {
|
|
151
|
-
value: string;
|
|
152
|
-
label: string;
|
|
153
|
-
}[];
|
|
154
|
-
}[];
|
|
155
|
-
/** The kind's `ai.purpose`, when configured. */
|
|
150
|
+
fields: readonly PropertyDefinition[];
|
|
151
|
+
/** The Block type's `ai.purpose`, when configured. */
|
|
156
152
|
purpose?: string;
|
|
157
153
|
}
|
|
158
154
|
/** A host block as AI learns it: what it is for, its Markdown form and one example. `id` is the node type name and the `convert` target id. */
|
|
@@ -167,9 +163,9 @@ export interface AiBlock {
|
|
|
167
163
|
example: string;
|
|
168
164
|
}
|
|
169
165
|
export interface AiContext {
|
|
170
|
-
|
|
166
|
+
blockTypes?: readonly AiContextBlockType[];
|
|
171
167
|
blocks?: readonly AiBlock[];
|
|
172
|
-
structure?: 'flat' | '
|
|
168
|
+
structure?: 'flat' | 'structured';
|
|
173
169
|
}
|
|
174
170
|
/** One piece of material a feature fetched for a block before the model fills it (a host's examples, a record). */
|
|
175
171
|
export interface AiBlockDatum {
|
|
@@ -206,6 +202,26 @@ export interface EditorFeature<C = unknown> {
|
|
|
206
202
|
backend?: readonly BackendCapability[];
|
|
207
203
|
extensions?: (ctx: FeatureContext) => AnyExtension[];
|
|
208
204
|
blockActions?: (ctx: FeatureContext) => BlockAction[];
|
|
205
|
+
/**
|
|
206
|
+
* Block capabilities the feature declares (`container` and `title` are built in): descriptors of what a block is, which a
|
|
207
|
+
* `BlockAction.requires` names and `capabilitiesAt` answers. Ids are unique across features. A capability installs nothing:
|
|
208
|
+
* schema, extensions and node views stay with the feature that owns the mechanism.
|
|
209
|
+
*/
|
|
210
|
+
blockCapabilities?: readonly BlockCapability[];
|
|
211
|
+
/**
|
|
212
|
+
* Ways to make a new block or text from a block (transcription, text extraction, summary, AI fill, AI derivation, bibliography fetch):
|
|
213
|
+
* one registry across all features, each method declaring the capabilities the original must have (`requires`) and its backend
|
|
214
|
+
* flags (`available`). The block actions of the methods are generated from it. Ids are unique across features and every
|
|
215
|
+
* `requires` id must be a declared capability; `defineEditor` throws otherwise.
|
|
216
|
+
*/
|
|
217
|
+
deriveMethods?: readonly DeriveMethod[];
|
|
218
|
+
/**
|
|
219
|
+
* The Block types the feature's editor offers: data (an id and the capabilities each type lists with their config) the capability
|
|
220
|
+
* registry answers from. Additive: the contributions of all features concatenate in feature order. An editor created from the preset
|
|
221
|
+
* checks them against the declared capabilities (`validateBlockTypes`): an unknown capability id or an invalid config throws. Block
|
|
222
|
+
* types are per editor (the composites feature builds its defaults in the surface's language).
|
|
223
|
+
*/
|
|
224
|
+
blockTypes?: (editor: Editor) => readonly BlockTypeData[];
|
|
209
225
|
/**
|
|
210
226
|
* Options of the block UI (`BlockUiOptions`: which surfaces render block actions). Set by the block-ui feature; the
|
|
211
227
|
* overlay components are mounted by the surface without props, so they read it from the editor entry (`EditorEntry.blockUi`).
|
|
@@ -215,7 +231,7 @@ export interface EditorFeature<C = unknown> {
|
|
|
215
231
|
commands?: (ctx: FeatureContext) => CommandDef<C>[];
|
|
216
232
|
/** Toolbar groups the feature declares; every command's `toolbar.group` must be declared by some feature. Ids are unique across features. */
|
|
217
233
|
toolbarGroups?: ToolbarGroupDef[];
|
|
218
|
-
/** Rules a command's `creates` must pass at the caret besides the schema (e.g. a
|
|
234
|
+
/** Rules a command's `creates` must pass at the caret besides the schema (e.g. a Typed block's accepted children). */
|
|
219
235
|
insertGuards?: (ctx: FeatureContext) => InsertGuard[];
|
|
220
236
|
/**
|
|
221
237
|
* Refusals of whole transactions: every transaction that changes the document runs through the guards of all
|
|
@@ -240,7 +256,7 @@ export interface EditorFeature<C = unknown> {
|
|
|
240
256
|
anchorResolver?: (ctx: FeatureContext) => AnchorResolver;
|
|
241
257
|
/** Additive: the contributions of all features are merged (`kinds` and `blocks` concatenated in feature order; `structure` may be set by one feature only). Reads AI's view of the document model. */
|
|
242
258
|
aiContext?: (editor: Editor) => AiContext;
|
|
243
|
-
/** Additive: every contributor runs for the block (in parallel), their data concatenate in feature order; one rejection fails the whole fill. Read by „
|
|
259
|
+
/** Additive: every contributor runs for the block (in parallel), their data concatenate in feature order; one rejection fails the whole fill. Read by „Block füllen (KI)“. */
|
|
244
260
|
aiBlockData?: AiBlockDataProvider;
|
|
245
261
|
/** At most one contributor: formats an AI result's markdown before the generic pipeline. */
|
|
246
262
|
formatAiResult?: (editor: Editor, markdown: string, heading?: string) => string;
|
|
@@ -250,6 +266,12 @@ export interface EditorPreset<C = unknown> {
|
|
|
250
266
|
readonly features: readonly EditorFeature<C>[];
|
|
251
267
|
readonly pipeline: BlockPipeline;
|
|
252
268
|
readonly conversions: readonly ConversionProvider[];
|
|
269
|
+
/** The built-in and the features' block capabilities; each editor answers over them per node (`capabilitiesAt`). */
|
|
270
|
+
readonly capabilities: CapabilityRegistry;
|
|
271
|
+
/** The features' derive methods, merged (`deriveMethodsAt`, `blockActionsOf`). */
|
|
272
|
+
readonly deriveMethods: DeriveRegistry;
|
|
273
|
+
/** All `blockTypes` contributions merged (`capabilityIndexOf` answers from them). */
|
|
274
|
+
readonly blockTypes?: (editor: Editor) => readonly BlockTypeData[];
|
|
253
275
|
/** All `aiContext` contributions merged (`aiContextOf`). */
|
|
254
276
|
readonly aiContext?: EditorFeature['aiContext'];
|
|
255
277
|
/** All `aiBlockData` contributions merged (`aiBlockDataOf`). */
|
package/dist/core/feature.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"feature.js","names":[],"sources":["../../src/core/feature.ts"],"sourcesContent":["import type { HocuspocusProvider } from '@hocuspocus/provider'\nimport type { AnyExtension, Editor, JSONContent } from '@tiptap/core'\nimport type { Node as PMNode, ResolvedPos } from '@tiptap/pm/model'\nimport type { EditorState, Transaction } from '@tiptap/pm/state'\nimport type * as Y from 'yjs'\nimport type { Locale, Translate } from '../i18n'\nimport type { EditorSettings } from '../settings'\nimport type { EditorBackend } from './backend'\nimport type { BackendCapability } from './backend-capability'\nimport type { EditorAiConfig, EditorContext } from './context'\nimport type { ConvertTarget } from './convert'\nimport type { EditorUi } from './editor-ui'\nimport type { AbilitiesOptions, BlockAction, BlockUiOptions } from './extension-points'\nimport type { MetadataRegistry } from './metadata'\nimport type { CommandDef, InsertGuard, ToolbarGroupDef, TransactionGuard } from './command-types'\nimport type { Notifier } from './notify'\nimport type { EditorMetadata } from './metadata-types'\nimport type { Store } from './store'\n\n// The composition contracts: an `EditorFeature` contributes extensions and descriptors, `defineEditor` validates a\n// feature list into an immutable `EditorPreset`, and `EditorSurface` mounts one. Everything here is inert data and\n// types; features only differ by which of these seams they fill.\n\n/**\n * The user writing in an editor: the collaboration session's `user`, labelled on remote carets, and (authors and comments\n * features) copied into the author mark of every text run and into every comment the user writes.\n */\nexport interface AuthorIdentity {\n id: string\n name: string\n color: string\n}\n\n/** A host-owned collaboration session handed to the surface; only the collab feature turns it into extensions. */\nexport interface CollaborationSession {\n ydoc: Y.Doc\n provider?: HocuspocusProvider\n user?: AuthorIdentity\n /**\n * Token the collaboration server's `Identity.authenticate` receives (`{ headers, token }`), for clients without\n * the session cookie of the server's origin (scripts, agents, cross-origin hosts). A string, or a function called\n * every time the socket opens (so it can refresh an expired token). Applied to `provider`'s configuration when the\n * surface is set up, which the provider reads when its socket opens: create the provider and mount the surface in the\n * same tick, or give the provider its own `token` option instead.\n */\n token?: string | (() => string) | (() => Promise<string>)\n}\n\n/**\n * A mapping between document positions and positions that survive collaborative edits. The collab feature supplies\n * the Yjs implementation; without one, `DocAnchors` maps positions through local transactions only.\n */\nexport interface AnchorResolver {\n /** The transaction applies a Yjs change to the document: remote edits and Yjs undo/redo. */\n isYSync: (tr: Transaction) => boolean\n /** The transaction applies an edit of another client (excludes Yjs undo/redo). */\n isRemoteChange: (tr: Transaction) => boolean\n /** Opaque token of `range` that `resolve` can turn back into positions after remote changes; null when unavailable. */\n capture: (state: EditorState, range: { from: number, to: number }, startInside: boolean) => unknown | null\n resolve: (state: EditorState, token: unknown) => { from: number, to: number } | null\n /** Stops undo capturing around a programmatic change; true iff a Yjs undo manager exists. */\n stopUndoCapture: (state: EditorState) => boolean\n}\n\n/** Per-surface dependencies of a feature's factories. Created when a surface is set up; never shared between editors. */\nexport interface FeatureContext {\n /** The app context the surface belongs to (shared by all editors of the app): app-level models key on it. */\n readonly app: EditorContext\n /** The app's shared settings (see `createEditorContext`): read with `get()`, write with `update()`, observe with `subscribe()`. */\n readonly settings: Store<EditorSettings>\n readonly metadata: MetadataRegistry\n /** Chrome of the editor this context belongs to (settings, sidebar). */\n readonly ui: EditorUi\n /** Shows a notice through the surface's framework (Nuxt UI toast, sonner). */\n readonly notify: Notifier\n /** The app's UI language (`createEditorContext({ locale })`). */\n readonly locale: Locale\n /** Renders a catalog message in the app's language; every label a feature contributes goes through it. */\n readonly t: Translate\n /** The data layer of the app (`createEditorContext({ backend })`): uploads, mention lookups, themes, AI. */\n readonly backend: EditorBackend\n /** Inert public AI configuration of the app context; absent when none was supplied. */\n readonly ai: EditorAiConfig | undefined\n /** Document whose package stores uploads (media feature). */\n readonly documentId: string | undefined\n readonly collaboration: CollaborationSession | undefined\n /** The collaboration-aware position mapping of the preset's `anchorResolver` feature; null means local mapping only. */\n readonly anchorResolver: AnchorResolver | null\n /** Host options for the ability extension (`abilities` prop). */\n readonly abilities: Partial<AbilitiesOptions>\n /** The final command list: the features' commands after the host's `commands` transformer. The `/` menu lists the ones with a `slash` placement. */\n readonly commands: () => CommandDef[]\n /** Undefined while extensions are constructed; set once the editor exists. Use it in event handlers. */\n getEditor: () => Editor | undefined\n}\n\n/** A tab of the settings panel/modal, contributed by the feature that owns those settings. */\nexport interface SettingsTab<C = unknown> {\n id: string\n /** Already translated (`ctx.t(...)` in the feature's `settingsTabs` factory). */\n label: string\n icon?: string\n component: C\n /** Props handed to `component`, e.g. the configured composite kinds. */\n props?: Record<string, unknown>\n}\n\n/** The stages `parseBlocks` and the import/AI insertion paths run; features replace stages, defaults are identity/Markdown. */\nexport interface BlockPipeline {\n parseMarkdown: (editor: Editor, markdown: string) => JSONContent[]\n normalize: (editor: Editor, blocks: JSONContent[]) => JSONContent[]\n segment: (editor: Editor, blocks: JSONContent[]) => JSONContent[]\n structure: (editor: Editor, blocks: JSONContent[]) => JSONContent[]\n wrapImport: (editor: Editor, file: File, blocks: JSONContent[]) => JSONContent[]\n migrateContent: (content: JSONContent) => JSONContent\n}\n\n/** Pipeline hooks that allow a single contributor; `normalize` chains instead. */\nexport const SINGLETON_PIPELINE_HOOKS = ['parseMarkdown', 'segment', 'structure', 'wrapImport', 'migrateContent'] as const satisfies readonly (keyof BlockPipeline)[]\n\n/**\n * A feature's block conversions. Targets keep the inert `ConvertTarget` shapes; the provider that parses a target id\n * owns that target (labels, execution). `handlesSource` claims all conversions of source blocks it understands.\n */\nexport interface ConversionProvider {\n /** Source blocks this provider converts to any target it can; the first provider claiming a node executes. */\n handlesSource?: (node: PMNode) => boolean\n /** Targets offered for `node` in menus (excluding its current type). */\n targets: (editor: Editor, node: PMNode) => ConvertTarget[]\n /** The target of `id` when this provider owns it, else null. */\n parseTarget: (id: string) => ConvertTarget | null\n /** Menu label (in the language of `t`) and icon of a target this provider owns. */\n label: (target: ConvertTarget, t: Translate) => { label: string, icon: string } | null\n /** The conversion of the block after `start` into `target` (absolute range replaced and the converted blocks), or null. */\n convert: (state: EditorState, start: ResolvedPos, target: ConvertTarget) => { from: number, to: number, blocks: PMNode[] } | null\n}\n\n/**\n * Inert public data AI reads about the editor's document model. A kind's `fields` carry what the model needs to write\n * them (`type`, and the choices of a `select`).\n */\nexport interface AiContextKind {\n id: string\n label: string\n fields: readonly { key: string, label: string, type?: 'text' | 'textarea' | 'date' | 'number' | 'select' | 'multiselect' | 'reference' | 'bibliography' | 'derivation', options?: readonly { value: string, label: string }[] }[]\n /** The kind's `ai.purpose`, when configured. */\n purpose?: string\n}\n\n/** A host block as AI learns it: what it is for, its Markdown form and one example. `id` is the node type name and the `convert` target id. */\nexport interface AiBlock {\n id: string\n label: string\n /** One or two German sentences: purpose and what it may contain. */\n description: string\n /** The Markdown form, placeholders in angle brackets, e.g. `!!! <info|warning|success>\\n<Inhalt>`. */\n syntax: string\n /** One complete Markdown example of the block. */\n example: string\n}\n\nexport interface AiContext {\n kinds?: readonly AiContextKind[]\n blocks?: readonly AiBlock[]\n structure?: 'flat' | 'composite'\n}\n\n/** One piece of material a feature fetched for a block before the model fills it (a host's examples, a record). */\nexport interface AiBlockDatum { label: string, text: string }\nexport interface AiBlockDataRequest { editor: Editor, node: PMNode, pos: number, signal: AbortSignal }\n/** Material for one block; `signal` aborts when the editor is destroyed or the run is cancelled. */\nexport type AiBlockDataProvider = (request: AiBlockDataRequest) => Promise<readonly AiBlockDatum[]> | readonly AiBlockDatum[]\n\n/**\n * The axis a feature belongs to: `content` (nodes, marks and structure rules the document stores: the server schema comes\n * from here), `interaction` (editing UX, backend-bound UI such as comments and collaboration) or `ai`. A feature\n * belongs to the dimension without which it makes no sense.\n */\nexport type Dimension = 'content' | 'interaction' | 'ai'\n\n/** One named contribution to an editor (blocks, toolbar entries, menus, settings, AI knowledge). Every member is optional but `dimension`; identity and ordering come from the feature list. */\nexport interface EditorFeature<C = unknown> {\n id: string\n /** The feature's primary dimension. */\n dimension: Dimension\n /**\n * The Vue-free schema-bearing extensions of this feature (no node views, no UI), collected by `schemaExtensionsOf` for\n * the server schema. Present on every feature whose nodes or marks the stored document can contain.\n */\n schemaExtensions?: () => AnyExtension[]\n /** Ids of features that must also be installed (`defineEditor` does not install them). */\n requires?: readonly string[]\n /** Backend capabilities the feature cannot work without; a surface session over a backend lacking one throws. Optional capabilities (users and tags for mentions) are not listed. */\n backend?: readonly BackendCapability[]\n extensions?: (ctx: FeatureContext) => AnyExtension[]\n blockActions?: (ctx: FeatureContext) => BlockAction[]\n /**\n * Options of the block UI (`BlockUiOptions`: which surfaces render block actions). Set by the block-ui feature; the\n * overlay components are mounted by the surface without props, so they read it from the editor entry (`EditorEntry.blockUi`).\n */\n blockUi?: Readonly<BlockUiOptions>\n /** The feature's commands, each declared once with its toolbar and `/` placements (see `CommandDef`). */\n commands?: (ctx: FeatureContext) => CommandDef<C>[]\n /** Toolbar groups the feature declares; every command's `toolbar.group` must be declared by some feature. Ids are unique across features. */\n toolbarGroups?: ToolbarGroupDef[]\n /** Rules a command's `creates` must pass at the caret besides the schema (e.g. a Baustein's accepted children). */\n insertGuards?: (ctx: FeatureContext) => InsertGuard[]\n /**\n * Refusals of whole transactions: every transaction that changes the document runs through the guards of all\n * features, in feature order; the first one answering a string refuses it and shows that string as a notice. For rules\n * about the document as a whole that no schema expresses (a locked paragraph, a required document shape).\n */\n transactionGuards?: (ctx: FeatureContext) => TransactionGuard[]\n /** Components mounted beside the editor content; they receive `{ editor }`. `C` is the component type of the framework layer that renders them. */\n overlays?: readonly C[]\n /**\n * Runs once when a surface mounts (per-app side effects, e.g. a theme runtime; dedupe inside). Returns the teardown,\n * called when the surface unmounts; it must be idempotent (React StrictMode mounts twice).\n */\n setup?: (ctx: FeatureContext) => void | (() => void)\n /** The feature's settings tabs. A factory over the app context, so labels render in the context's language. */\n settingsTabs?: (ctx: EditorContext) => readonly SettingsTab<C>[]\n /** Built-in metadata lists (`mentions`, `hashtags`, `speakers`, …) used for every list name the host does not supply; searched only when a suggestion uses them. */\n metadataDefaults?: (ctx: FeatureContext) => EditorMetadata\n blocks?: Partial<BlockPipeline>\n conversions?: readonly ConversionProvider[]\n /** At most one contributor: supplies the collaboration-aware position mapping to `DocAnchors`. */\n anchorResolver?: (ctx: FeatureContext) => AnchorResolver\n /** Additive: the contributions of all features are merged (`kinds` and `blocks` concatenated in feature order; `structure` may be set by one feature only). Reads AI's view of the document model. */\n aiContext?: (editor: Editor) => AiContext\n /** Additive: every contributor runs for the block (in parallel), their data concatenate in feature order; one rejection fails the whole fill. Read by „Baustein füllen (KI)“. */\n aiBlockData?: AiBlockDataProvider\n /** At most one contributor: formats an AI result's markdown before the generic pipeline. */\n formatAiResult?: (editor: Editor, markdown: string, heading?: string) => string\n}\n\n/** An immutable, validated feature list with its resolved pipeline, conversion providers and AI hooks. */\nexport interface EditorPreset<C = unknown> {\n readonly features: readonly EditorFeature<C>[]\n readonly pipeline: BlockPipeline\n readonly conversions: readonly ConversionProvider[]\n /** All `aiContext` contributions merged (`aiContextOf`). */\n readonly aiContext?: EditorFeature['aiContext']\n /** All `aiBlockData` contributions merged (`aiBlockDataOf`). */\n readonly aiBlockData?: AiBlockDataProvider\n /** The single `formatAiResult` contributor, if any. */\n readonly formatAiResult?: EditorFeature['formatAiResult']\n}\n"],"mappings":";;AAsHA,MAAa,2BAA2B;CAAC;CAAiB;CAAW;CAAa;CAAc;AAAgB"}
|
|
1
|
+
{"version":3,"file":"feature.js","names":[],"sources":["../../src/core/feature.ts"],"sourcesContent":["import type { HocuspocusProvider } from '@hocuspocus/provider'\nimport type { AnyExtension, Editor, JSONContent } from '@tiptap/core'\nimport type { Node as PMNode, ResolvedPos } from '@tiptap/pm/model'\nimport type { EditorState, Transaction } from '@tiptap/pm/state'\nimport type * as Y from 'yjs'\nimport type { Locale, Translate } from '../i18n'\nimport type { EditorSettings } from '../settings'\nimport type { EditorBackend } from './backend'\nimport type { BackendCapability } from './backend-capability'\nimport type { EditorAiConfig, EditorContext } from './context'\nimport type { ConvertTarget } from './convert'\nimport type { EditorUi } from './editor-ui'\nimport type { BlockCapability, BlockTypeData, CapabilityRegistry } from './capabilities'\nimport type { DeriveMethod, DeriveRegistry } from './derive'\nimport type { AbilitiesOptions, BlockAction, BlockUiOptions } from './extension-points'\nimport type { MetadataRegistry } from './metadata'\nimport type { PropertyDefinition } from './properties'\nimport type { CommandDef, InsertGuard, ToolbarGroupDef, TransactionGuard } from './command-types'\nimport type { Notifier } from './notify'\nimport type { EditorMetadata } from './metadata-types'\nimport type { Store } from './store'\n\n// The composition contracts: an `EditorFeature` contributes extensions and descriptors, `defineEditor` validates a\n// feature list into an immutable `EditorPreset`, and `EditorSurface` mounts one. Everything here is inert data and\n// types; features only differ by which of these seams they fill.\n\n/**\n * The user writing in an editor: the collaboration session's `user`, labelled on remote carets, and (authors and comments\n * features) copied into the author mark of every text run and into every comment the user writes.\n */\nexport interface AuthorIdentity {\n id: string\n name: string\n color: string\n}\n\n/** A host-owned collaboration session handed to the surface; only the collab feature turns it into extensions. */\nexport interface CollaborationSession {\n ydoc: Y.Doc\n provider?: HocuspocusProvider\n user?: AuthorIdentity\n /**\n * Token the collaboration server's `AccessControl.authenticate` receives (`{ headers, token }`), for clients without\n * the session cookie of the server's origin (scripts, agents, cross-origin hosts). A string, or a function called\n * every time the socket opens (so it can refresh an expired token). Applied to `provider`'s configuration when the\n * surface is set up, which the provider reads when its socket opens: create the provider and mount the surface in the\n * same tick, or give the provider its own `token` option instead.\n */\n token?: string | (() => string) | (() => Promise<string>)\n}\n\n/**\n * A mapping between document positions and positions that survive collaborative edits. The collab feature supplies\n * the Yjs implementation; without one, `DocAnchors` maps positions through local transactions only.\n */\nexport interface AnchorResolver {\n /** The transaction applies a Yjs change to the document: remote edits and Yjs undo/redo. */\n isYSync: (tr: Transaction) => boolean\n /** The transaction applies an edit of another client (excludes Yjs undo/redo). */\n isRemoteChange: (tr: Transaction) => boolean\n /** Opaque token of `range` that `resolve` can turn back into positions after remote changes; null when unavailable. */\n capture: (state: EditorState, range: { from: number, to: number }, startInside: boolean) => unknown | null\n resolve: (state: EditorState, token: unknown) => { from: number, to: number } | null\n /** Stops undo capturing around a programmatic change; true iff a Yjs undo manager exists. */\n stopUndoCapture: (state: EditorState) => boolean\n}\n\n/** Per-surface dependencies of a feature's factories. Created when a surface is set up; never shared between editors. */\nexport interface FeatureContext {\n /** The app context the surface belongs to (shared by all editors of the app): app-level models key on it. */\n readonly app: EditorContext\n /** The app's shared settings (see `createEditorContext`): read with `get()`, write with `update()`, observe with `subscribe()`. */\n readonly settings: Store<EditorSettings>\n readonly metadata: MetadataRegistry\n /** Chrome of the editor this context belongs to (settings, sidebar). */\n readonly ui: EditorUi\n /** Shows a notice through the surface's framework (Nuxt UI toast, sonner). */\n readonly notify: Notifier\n /** The app's UI language (`createEditorContext({ locale })`). */\n readonly locale: Locale\n /** Renders a catalog message in the app's language; every label a feature contributes goes through it. */\n readonly t: Translate\n /** The data layer of the app (`createEditorContext({ backend })`): uploads, mention lookups, themes, AI. */\n readonly backend: EditorBackend\n /** Inert public AI configuration of the app context; absent when none was supplied. */\n readonly ai: EditorAiConfig | undefined\n /** Document whose package stores uploads (media feature). */\n readonly documentId: string | undefined\n readonly collaboration: CollaborationSession | undefined\n /** The collaboration-aware position mapping of the preset's `anchorResolver` feature; null means local mapping only. */\n readonly anchorResolver: AnchorResolver | null\n /** Host options for the ability extension (`abilities` prop). */\n readonly abilities: Partial<AbilitiesOptions>\n /** The final command list: the features' commands after the host's `commands` transformer. The `/` menu lists the ones with a `slash` placement. */\n readonly commands: () => CommandDef[]\n /** Undefined while extensions are constructed; set once the editor exists. Use it in event handlers. */\n getEditor: () => Editor | undefined\n}\n\n/** A tab of the settings panel/modal, contributed by the feature that owns those settings. */\nexport interface SettingsTab<C = unknown> {\n id: string\n /** Already translated (`ctx.t(...)` in the feature's `settingsTabs` factory). */\n label: string\n icon?: string\n component: C\n /** Props handed to `component`, e.g. the configured Block types. */\n props?: Record<string, unknown>\n}\n\n/** The stages `parseBlocks` and the import/AI insertion paths run; features replace stages, defaults are identity/Markdown. */\nexport interface BlockPipeline {\n parseMarkdown: (editor: Editor, markdown: string) => JSONContent[]\n normalize: (editor: Editor, blocks: JSONContent[]) => JSONContent[]\n segment: (editor: Editor, blocks: JSONContent[]) => JSONContent[]\n structure: (editor: Editor, blocks: JSONContent[]) => JSONContent[]\n wrapImport: (editor: Editor, file: File, blocks: JSONContent[]) => JSONContent[]\n /** The loaded document as the current schema reads it. The rename of the old persisted names (`migratePersistedNames`) runs before it: `defineEditor` puts it in front of a contributed hook, so the hook sees current names only. */\n migrateContent: (content: JSONContent) => JSONContent\n}\n\n/** Pipeline hooks that allow a single contributor; `normalize` chains instead. */\nexport const SINGLETON_PIPELINE_HOOKS = ['parseMarkdown', 'segment', 'structure', 'wrapImport', 'migrateContent'] as const satisfies readonly (keyof BlockPipeline)[]\n\n/**\n * A feature's block conversions. Targets keep the inert `ConvertTarget` shapes; the provider that parses a target id\n * owns that target (labels, execution). `handlesSource` claims all conversions of source blocks it understands.\n */\nexport interface ConversionProvider {\n /** Source blocks this provider converts to any target it can; the first provider claiming a node executes. */\n handlesSource?: (node: PMNode) => boolean\n /** Targets offered for `node` in menus (excluding its current type). */\n targets: (editor: Editor, node: PMNode) => ConvertTarget[]\n /** The target of `id` when this provider owns it, else null. */\n parseTarget: (id: string) => ConvertTarget | null\n /** Menu label (in the language of `t`) and icon of a target this provider owns. */\n label: (target: ConvertTarget, t: Translate) => { label: string, icon: string } | null\n /** The conversion of the block after `start` into `target` (absolute range replaced and the converted blocks), or null. */\n convert: (state: EditorState, start: ResolvedPos, target: ConvertTarget) => { from: number, to: number, blocks: PMNode[] } | null\n}\n\n/**\n * Inert public data AI reads about the editor's document model. A Block type's `fields` are its Property definitions: they carry\n * what the model needs to write the properties (`type`, and the choices of a `select`).\n */\nexport interface AiContextBlockType {\n id: string\n label: string\n fields: readonly PropertyDefinition[]\n /** The Block type's `ai.purpose`, when configured. */\n purpose?: string\n}\n\n/** A host block as AI learns it: what it is for, its Markdown form and one example. `id` is the node type name and the `convert` target id. */\nexport interface AiBlock {\n id: string\n label: string\n /** One or two German sentences: purpose and what it may contain. */\n description: string\n /** The Markdown form, placeholders in angle brackets, e.g. `!!! <info|warning|success>\\n<Inhalt>`. */\n syntax: string\n /** One complete Markdown example of the block. */\n example: string\n}\n\nexport interface AiContext {\n blockTypes?: readonly AiContextBlockType[]\n blocks?: readonly AiBlock[]\n structure?: 'flat' | 'structured'\n}\n\n/** One piece of material a feature fetched for a block before the model fills it (a host's examples, a record). */\nexport interface AiBlockDatum { label: string, text: string }\nexport interface AiBlockDataRequest { editor: Editor, node: PMNode, pos: number, signal: AbortSignal }\n/** Material for one block; `signal` aborts when the editor is destroyed or the run is cancelled. */\nexport type AiBlockDataProvider = (request: AiBlockDataRequest) => Promise<readonly AiBlockDatum[]> | readonly AiBlockDatum[]\n\n/**\n * The axis a feature belongs to: `content` (nodes, marks and structure rules the document stores: the server schema comes\n * from here), `interaction` (editing UX, backend-bound UI such as comments and collaboration) or `ai`. A feature\n * belongs to the dimension without which it makes no sense.\n */\nexport type Dimension = 'content' | 'interaction' | 'ai'\n\n/** One named contribution to an editor (blocks, toolbar entries, menus, settings, AI knowledge). Every member is optional but `dimension`; identity and ordering come from the feature list. */\nexport interface EditorFeature<C = unknown> {\n id: string\n /** The feature's primary dimension. */\n dimension: Dimension\n /**\n * The Vue-free schema-bearing extensions of this feature (no node views, no UI), collected by `schemaExtensionsOf` for\n * the server schema. Present on every feature whose nodes or marks the stored document can contain.\n */\n schemaExtensions?: () => AnyExtension[]\n /** Ids of features that must also be installed (`defineEditor` does not install them). */\n requires?: readonly string[]\n /** Backend capabilities the feature cannot work without; a surface session over a backend lacking one throws. Optional capabilities (users and tags for mentions) are not listed. */\n backend?: readonly BackendCapability[]\n extensions?: (ctx: FeatureContext) => AnyExtension[]\n blockActions?: (ctx: FeatureContext) => BlockAction[]\n /**\n * Block capabilities the feature declares (`container` and `title` are built in): descriptors of what a block is, which a\n * `BlockAction.requires` names and `capabilitiesAt` answers. Ids are unique across features. A capability installs nothing:\n * schema, extensions and node views stay with the feature that owns the mechanism.\n */\n blockCapabilities?: readonly BlockCapability[]\n /**\n * Ways to make a new block or text from a block (transcription, text extraction, summary, AI fill, AI derivation, bibliography fetch):\n * one registry across all features, each method declaring the capabilities the original must have (`requires`) and its backend\n * flags (`available`). The block actions of the methods are generated from it. Ids are unique across features and every\n * `requires` id must be a declared capability; `defineEditor` throws otherwise.\n */\n deriveMethods?: readonly DeriveMethod[]\n /**\n * The Block types the feature's editor offers: data (an id and the capabilities each type lists with their config) the capability\n * registry answers from. Additive: the contributions of all features concatenate in feature order. An editor created from the preset\n * checks them against the declared capabilities (`validateBlockTypes`): an unknown capability id or an invalid config throws. Block\n * types are per editor (the composites feature builds its defaults in the surface's language).\n */\n blockTypes?: (editor: Editor) => readonly BlockTypeData[]\n /**\n * Options of the block UI (`BlockUiOptions`: which surfaces render block actions). Set by the block-ui feature; the\n * overlay components are mounted by the surface without props, so they read it from the editor entry (`EditorEntry.blockUi`).\n */\n blockUi?: Readonly<BlockUiOptions>\n /** The feature's commands, each declared once with its toolbar and `/` placements (see `CommandDef`). */\n commands?: (ctx: FeatureContext) => CommandDef<C>[]\n /** Toolbar groups the feature declares; every command's `toolbar.group` must be declared by some feature. Ids are unique across features. */\n toolbarGroups?: ToolbarGroupDef[]\n /** Rules a command's `creates` must pass at the caret besides the schema (e.g. a Typed block's accepted children). */\n insertGuards?: (ctx: FeatureContext) => InsertGuard[]\n /**\n * Refusals of whole transactions: every transaction that changes the document runs through the guards of all\n * features, in feature order; the first one answering a string refuses it and shows that string as a notice. For rules\n * about the document as a whole that no schema expresses (a locked paragraph, a required document shape).\n */\n transactionGuards?: (ctx: FeatureContext) => TransactionGuard[]\n /** Components mounted beside the editor content; they receive `{ editor }`. `C` is the component type of the framework layer that renders them. */\n overlays?: readonly C[]\n /**\n * Runs once when a surface mounts (per-app side effects, e.g. a theme runtime; dedupe inside). Returns the teardown,\n * called when the surface unmounts; it must be idempotent (React StrictMode mounts twice).\n */\n setup?: (ctx: FeatureContext) => void | (() => void)\n /** The feature's settings tabs. A factory over the app context, so labels render in the context's language. */\n settingsTabs?: (ctx: EditorContext) => readonly SettingsTab<C>[]\n /** Built-in metadata lists (`mentions`, `hashtags`, `speakers`, …) used for every list name the host does not supply; searched only when a suggestion uses them. */\n metadataDefaults?: (ctx: FeatureContext) => EditorMetadata\n blocks?: Partial<BlockPipeline>\n conversions?: readonly ConversionProvider[]\n /** At most one contributor: supplies the collaboration-aware position mapping to `DocAnchors`. */\n anchorResolver?: (ctx: FeatureContext) => AnchorResolver\n /** Additive: the contributions of all features are merged (`kinds` and `blocks` concatenated in feature order; `structure` may be set by one feature only). Reads AI's view of the document model. */\n aiContext?: (editor: Editor) => AiContext\n /** Additive: every contributor runs for the block (in parallel), their data concatenate in feature order; one rejection fails the whole fill. Read by „Block füllen (KI)“. */\n aiBlockData?: AiBlockDataProvider\n /** At most one contributor: formats an AI result's markdown before the generic pipeline. */\n formatAiResult?: (editor: Editor, markdown: string, heading?: string) => string\n}\n\n/** An immutable, validated feature list with its resolved pipeline, conversion providers and AI hooks. */\nexport interface EditorPreset<C = unknown> {\n readonly features: readonly EditorFeature<C>[]\n readonly pipeline: BlockPipeline\n readonly conversions: readonly ConversionProvider[]\n /** The built-in and the features' block capabilities; each editor answers over them per node (`capabilitiesAt`). */\n readonly capabilities: CapabilityRegistry\n /** The features' derive methods, merged (`deriveMethodsAt`, `blockActionsOf`). */\n readonly deriveMethods: DeriveRegistry\n /** All `blockTypes` contributions merged (`capabilityIndexOf` answers from them). */\n readonly blockTypes?: (editor: Editor) => readonly BlockTypeData[]\n /** All `aiContext` contributions merged (`aiContextOf`). */\n readonly aiContext?: EditorFeature['aiContext']\n /** All `aiBlockData` contributions merged (`aiBlockDataOf`). */\n readonly aiBlockData?: AiBlockDataProvider\n /** The single `formatAiResult` contributor, if any. */\n readonly formatAiResult?: EditorFeature['formatAiResult']\n}\n"],"mappings":";;AA0HA,MAAa,2BAA2B;CAAC;CAAiB;CAAW;CAAa;CAAc;AAAgB"}
|
package/dist/core/fences.js
CHANGED
package/dist/core/fences.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fences.js","names":[],"sources":["../../src/core/fences.ts"],"sourcesContent":["import type { JSONContent } from '@tiptap/core'\n\n// The `::: kind #id {meta}` … `:::` fence grammar of Markdown documents, shared by the composite feature (registered kinds\n// become composites) and the Markdown entry (every other kind stays an `opaqueFence`). `#id` (optional, Pandoc-like) is\n// the block id of the fenced composite; `{meta}` is a JSON object. Nested fences close with the\n// same bare `:::`, so a closer always ends the innermost open fence. Lines inside ``` / ~~~ code fences are never fence\n// syntax.\n\n/** A well-formed fence: its kind, optional block id (`#id` after the kind), JSON meta, inner text and the exact source text, opener line through closer line. */\nexport interface CompositeFence { kind: string, id?: string, meta: Record<string, unknown>, inner: string, raw: string }\nexport type FenceSegment = { markdown: string } | CompositeFence\n\n/** A fence-like construct that did not become a fence: `invalid-fence-meta` (the `{…}` after the kind is no JSON object) or `unclosed-fence` (no matching `:::`). `line` is 1-based. */\nexport interface FenceProblem { code: 'invalid-fence-meta' | 'unclosed-fence', line: number, kind: string }\n\nconst OPENER = /^\\s*:::[ \\t]*([\\p{L}\\p{N}_-]+)(?:[ \\t]+#([0-9a-f-]{36}))?[ \\t]*(\\{.*\\})?[ \\t]*$/u\nconst CLOSER = /^\\s*:::\\s*$/\nconst CODE_FENCE = /^ {0,3}(`{3,}|~{3,})/\n\nfunction parseMeta(json: string | undefined): Record<string, unknown> | null {\n if (!json) return {}\n try {\n const value: unknown = JSON.parse(json)\n return value && typeof value === 'object' && !Array.isArray(value) ? value as Record<string, unknown> : null\n }\n catch {\n return null\n }\n}\n\n/** For every line whether it is part of a ``` / ~~~ code fence (the fence lines included). */\nfunction codeLines(lines: readonly string[]): boolean[] {\n const inside: boolean[] = []\n let open: { char: string, length: number } | null = null\n for (const line of lines) {\n const match = CODE_FENCE.exec(line)\n if (!open) {\n if (match) open = { char: match[1]![0]!, length: match[1]!.length }\n inside.push(open !== null)\n continue\n }\n inside.push(true)\n const closing = /^ {0,3}(`{3,}|~{3,})\\s*$/.exec(line)\n if (closing && closing[1]![0] === open.char && closing[1]!.length >= open.length) open = null\n }\n return inside\n}\n\n/** Splits `::: kind {json}` … `:::` fences (nestable) into segments; text outside fences stays markdown. `problems` lists the opener lines that stayed plain text. */\nexport function splitFences(markdown: string): { segments: FenceSegment[], problems: FenceProblem[] } {\n const lines = markdown.split('\\n')\n const code = codeLines(lines)\n const segments: FenceSegment[] = []\n const problems: FenceProblem[] = []\n let plain: string[] = []\n const flush = () => {\n if (plain.join('').trim()) segments.push({ markdown: plain.join('\\n') })\n plain = []\n }\n let i = 0\n while (i < lines.length) {\n const line = lines[i]!\n const match = code[i] ? null : OPENER.exec(line)\n const meta = match ? parseMeta(match[3]) : null\n if (!match || !meta) {\n if (match) problems.push({ code: 'invalid-fence-meta', line: i + 1, kind: match[1]! })\n plain.push(line)\n i++\n continue\n }\n // Find the matching closer, counting nested openers; none → the opener line stays plain text.\n let depth = 1\n let end = i + 1\n for (; end < lines.length; end++) {\n if (code[end]) continue\n if (OPENER.test(lines[end]!)) depth++\n else if (CLOSER.test(lines[end]!) && --depth === 0) break\n }\n if (depth) {\n problems.push({ code: 'unclosed-fence', line: i + 1, kind: match[1]! })\n plain.push(line)\n i++\n continue\n }\n flush()\n segments.push({ kind: match[1]!, ...(match[2] && { id: match[2] }), meta, inner: lines.slice(i + 1, end).join('\\n'), raw: lines.slice(i, end + 1).join('\\n') })\n i = end + 1\n }\n flush()\n return { segments, problems }\n}\n\n/** The fences of `markdown` (see `splitFences`) without the problem report. */\nexport const splitCompositeFences = (markdown: string): FenceSegment[] => splitFences(markdown).segments\n\n/** An opaque fence node: `raw` is the fence's source text, written back verbatim by the Markdown serializer. */\nexport const opaqueFenceJSON = (fence: CompositeFence): JSONContent => ({ type: 'opaqueFence', attrs: {
|
|
1
|
+
{"version":3,"file":"fences.js","names":[],"sources":["../../src/core/fences.ts"],"sourcesContent":["import type { JSONContent } from '@tiptap/core'\n\n// The `::: kind #id {meta}` … `:::` fence grammar of Markdown documents, shared by the composite feature (registered kinds\n// become composites) and the Markdown entry (every other kind stays an `opaqueFence`). `#id` (optional, Pandoc-like) is\n// the block id of the fenced composite; `{meta}` is a JSON object. Nested fences close with the\n// same bare `:::`, so a closer always ends the innermost open fence. Lines inside ``` / ~~~ code fences are never fence\n// syntax.\n\n/** A well-formed fence: its kind, optional block id (`#id` after the kind), JSON meta, inner text and the exact source text, opener line through closer line. */\nexport interface CompositeFence { kind: string, id?: string, meta: Record<string, unknown>, inner: string, raw: string }\nexport type FenceSegment = { markdown: string } | CompositeFence\n\n/** A fence-like construct that did not become a fence: `invalid-fence-meta` (the `{…}` after the kind is no JSON object) or `unclosed-fence` (no matching `:::`). `line` is 1-based. */\nexport interface FenceProblem { code: 'invalid-fence-meta' | 'unclosed-fence', line: number, kind: string }\n\nconst OPENER = /^\\s*:::[ \\t]*([\\p{L}\\p{N}_-]+)(?:[ \\t]+#([0-9a-f-]{36}))?[ \\t]*(\\{.*\\})?[ \\t]*$/u\nconst CLOSER = /^\\s*:::\\s*$/\nconst CODE_FENCE = /^ {0,3}(`{3,}|~{3,})/\n\nfunction parseMeta(json: string | undefined): Record<string, unknown> | null {\n if (!json) return {}\n try {\n const value: unknown = JSON.parse(json)\n return value && typeof value === 'object' && !Array.isArray(value) ? value as Record<string, unknown> : null\n }\n catch {\n return null\n }\n}\n\n/** For every line whether it is part of a ``` / ~~~ code fence (the fence lines included). */\nfunction codeLines(lines: readonly string[]): boolean[] {\n const inside: boolean[] = []\n let open: { char: string, length: number } | null = null\n for (const line of lines) {\n const match = CODE_FENCE.exec(line)\n if (!open) {\n if (match) open = { char: match[1]![0]!, length: match[1]!.length }\n inside.push(open !== null)\n continue\n }\n inside.push(true)\n const closing = /^ {0,3}(`{3,}|~{3,})\\s*$/.exec(line)\n if (closing && closing[1]![0] === open.char && closing[1]!.length >= open.length) open = null\n }\n return inside\n}\n\n/** Splits `::: kind {json}` … `:::` fences (nestable) into segments; text outside fences stays markdown. `problems` lists the opener lines that stayed plain text. */\nexport function splitFences(markdown: string): { segments: FenceSegment[], problems: FenceProblem[] } {\n const lines = markdown.split('\\n')\n const code = codeLines(lines)\n const segments: FenceSegment[] = []\n const problems: FenceProblem[] = []\n let plain: string[] = []\n const flush = () => {\n if (plain.join('').trim()) segments.push({ markdown: plain.join('\\n') })\n plain = []\n }\n let i = 0\n while (i < lines.length) {\n const line = lines[i]!\n const match = code[i] ? null : OPENER.exec(line)\n const meta = match ? parseMeta(match[3]) : null\n if (!match || !meta) {\n if (match) problems.push({ code: 'invalid-fence-meta', line: i + 1, kind: match[1]! })\n plain.push(line)\n i++\n continue\n }\n // Find the matching closer, counting nested openers; none → the opener line stays plain text.\n let depth = 1\n let end = i + 1\n for (; end < lines.length; end++) {\n if (code[end]) continue\n if (OPENER.test(lines[end]!)) depth++\n else if (CLOSER.test(lines[end]!) && --depth === 0) break\n }\n if (depth) {\n problems.push({ code: 'unclosed-fence', line: i + 1, kind: match[1]! })\n plain.push(line)\n i++\n continue\n }\n flush()\n segments.push({ kind: match[1]!, ...(match[2] && { id: match[2] }), meta, inner: lines.slice(i + 1, end).join('\\n'), raw: lines.slice(i, end + 1).join('\\n') })\n i = end + 1\n }\n flush()\n return { segments, problems }\n}\n\n/** The fences of `markdown` (see `splitFences`) without the problem report. */\nexport const splitCompositeFences = (markdown: string): FenceSegment[] => splitFences(markdown).segments\n\n/** An opaque fence node: `raw` is the fence's source text, written back verbatim by the Markdown serializer. */\nexport const opaqueFenceJSON = (fence: CompositeFence): JSONContent => ({ type: 'opaqueFence', attrs: { blockType: fence.kind, raw: fence.raw } })\n"],"mappings":";AAeA,MAAM,SAAS;AACf,MAAM,SAAS;AACf,MAAM,aAAa;AAEnB,SAAS,UAAU,MAA0D;CAC3E,IAAI,CAAC,MAAM,OAAO,CAAC;CACnB,IAAI;EACF,MAAM,QAAiB,KAAK,MAAM,IAAI;EACtC,OAAO,SAAS,OAAO,UAAU,YAAY,CAAC,MAAM,QAAQ,KAAK,IAAI,QAAmC;CAC1G,QACM;EACJ,OAAO;CACT;AACF;;AAGA,SAAS,UAAU,OAAqC;CACtD,MAAM,SAAoB,CAAC;CAC3B,IAAI,OAAgD;CACpD,KAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,QAAQ,WAAW,KAAK,IAAI;EAClC,IAAI,CAAC,MAAM;GACT,IAAI,OAAO,OAAO;IAAE,MAAM,MAAM,EAAE,CAAE;IAAK,QAAQ,MAAM,EAAE,CAAE;GAAO;GAClE,OAAO,KAAK,SAAS,IAAI;GACzB;EACF;EACA,OAAO,KAAK,IAAI;EAChB,MAAM,UAAU,2BAA2B,KAAK,IAAI;EACpD,IAAI,WAAW,QAAQ,EAAE,CAAE,OAAO,KAAK,QAAQ,QAAQ,EAAE,CAAE,UAAU,KAAK,QAAQ,OAAO;CAC3F;CACA,OAAO;AACT;;AAGA,SAAgB,YAAY,UAA0E;CACpG,MAAM,QAAQ,SAAS,MAAM,IAAI;CACjC,MAAM,OAAO,UAAU,KAAK;CAC5B,MAAM,WAA2B,CAAC;CAClC,MAAM,WAA2B,CAAC;CAClC,IAAI,QAAkB,CAAC;CACvB,MAAM,cAAc;EAClB,IAAI,MAAM,KAAK,EAAE,CAAC,CAAC,KAAK,GAAG,SAAS,KAAK,EAAE,UAAU,MAAM,KAAK,IAAI,EAAE,CAAC;EACvE,QAAQ,CAAC;CACX;CACA,IAAI,IAAI;CACR,OAAO,IAAI,MAAM,QAAQ;EACvB,MAAM,OAAO,MAAM;EACnB,MAAM,QAAQ,KAAK,KAAK,OAAO,OAAO,KAAK,IAAI;EAC/C,MAAM,OAAO,QAAQ,UAAU,MAAM,EAAE,IAAI;EAC3C,IAAI,CAAC,SAAS,CAAC,MAAM;GACnB,IAAI,OAAO,SAAS,KAAK;IAAE,MAAM;IAAsB,MAAM,IAAI;IAAG,MAAM,MAAM;GAAI,CAAC;GACrF,MAAM,KAAK,IAAI;GACf;GACA;EACF;EAEA,IAAI,QAAQ;EACZ,IAAI,MAAM,IAAI;EACd,OAAO,MAAM,MAAM,QAAQ,OAAO;GAChC,IAAI,KAAK,MAAM;GACf,IAAI,OAAO,KAAK,MAAM,IAAK,GAAG;QACzB,IAAI,OAAO,KAAK,MAAM,IAAK,KAAK,EAAE,UAAU,GAAG;EACtD;EACA,IAAI,OAAO;GACT,SAAS,KAAK;IAAE,MAAM;IAAkB,MAAM,IAAI;IAAG,MAAM,MAAM;GAAI,CAAC;GACtE,MAAM,KAAK,IAAI;GACf;GACA;EACF;EACA,MAAM;EACN,SAAS,KAAK;GAAE,MAAM,MAAM;GAAK,GAAI,MAAM,MAAM,EAAE,IAAI,MAAM,GAAG;GAAI;GAAM,OAAO,MAAM,MAAM,IAAI,GAAG,GAAG,CAAC,CAAC,KAAK,IAAI;GAAG,KAAK,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI;EAAE,CAAC;EAC9J,IAAI,MAAM;CACZ;CACA,MAAM;CACN,OAAO;EAAE;EAAU;CAAS;AAC9B;;AAGA,MAAa,wBAAwB,aAAqC,YAAY,QAAQ,CAAC,CAAC;;AAGhG,MAAa,mBAAmB,WAAwC;CAAE,MAAM;CAAe,OAAO;EAAE,WAAW,MAAM;EAAM,KAAK,MAAM;CAAI;AAAE"}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -8,9 +8,13 @@ import { CORE_TARGET_IDS, ConvertTarget, Converter, ForeignBlocks, TextblockSpec
|
|
|
8
8
|
import { CommandBase, CommandDef, CommandState, Creates, InsertGuard, MenuItem, PlacedToolbarGroup, ToolbarGroupDef, TransactionGuard } from "./command-types.js";
|
|
9
9
|
import { AbilitiesOptions, BlockAction, BlockActionContext, BlockActionSurface, BlockTarget, BlockUiOptions } from "./extension-points.js";
|
|
10
10
|
import { EditorEntry, EditorUi, editorEntryOf, notifierOf, registerEditor } from "./editor-ui.js";
|
|
11
|
+
import { BUILT_IN_BLOCK_CAPABILITIES, BlockCapability, BlockTypeCapability, BlockTypeData, CapabilityContext, CapabilityIndex, CapabilityIssue, CapabilityRegistry, blockTypeConfigOf, blockTypeIdOf, capabilitiesAt, capabilitiesOf, capabilityConfigOf, capabilityDataOf, capabilityIndexOf, capabilityIssues, createCapabilityIndex, createCapabilityRegistry, listsCapability, validateBlockTypes } from "./capabilities.js";
|
|
12
|
+
import { DeriveContext, DeriveMethod, DeriveRegistry, createDeriveRegistry, deriveActionsOf, deriveMethodsAt } from "./derive.js";
|
|
11
13
|
import { EditorMetadata, METADATA_LIST, MetadataItem, MetadataQuery, MetadataSource } from "./metadata-types.js";
|
|
12
14
|
import { Metadata, MetadataRegistry, createMetadataRegistry, filterMetadataItems, metadataOf } from "./metadata.js";
|
|
13
|
-
import {
|
|
15
|
+
import { PROPERTY_TYPES, PropertyDefinition } from "./properties.js";
|
|
16
|
+
import { AiBlock, AiBlockDataProvider, AiBlockDataRequest, AiBlockDatum, AiContext, AiContextBlockType, AnchorResolver, AuthorIdentity, BlockPipeline, CollaborationSession, ConversionProvider, Dimension, EditorFeature, EditorPreset, FeatureContext, SINGLETON_PIPELINE_HOOKS, SettingsTab } from "./feature.js";
|
|
17
|
+
import { AssetBlock, DERIVATION_KEY, Derivation, DerivationIndex, DerivationMethod, DerivationOrigin, DerivationSource, DerivationState, DerivedEntry, assetRefOf, derivationIndexOf, derivationOf, derivationOriginOf, derivationState, derivedChildrenOf, derivedOf, isForeignSource } from "./derivation.js";
|
|
14
18
|
import { Abilities, AbilitiesStorage, DEFAULT_ABILITY_RULES, abilitiesAt, abilitiesAtSelection, hasAbility } from "./abilities.js";
|
|
15
19
|
import { BlockConvert, blockConversion, conversionLabel, conversionTargetGroups, convertMenuItems, coreConversions, parseConversionTarget, targetOwner } from "./block-convert.js";
|
|
16
20
|
import { startBlockDrag } from "./block-drag.js";
|
|
@@ -33,4 +37,4 @@ import { selectionRange } from "./selection-range.js";
|
|
|
33
37
|
import { SlashCommand, SlashCommandOptions, SlashCommandPluginKey } from "./slash.js";
|
|
34
38
|
import { SuggestionDisplay, SuggestionListProps, SuggestionPopup, SuggestionPopupHandle, SuggestionPopupRenderer, createSuggestionRender, suggestionPopupOf } from "./suggestion-popup.js";
|
|
35
39
|
import { CORE_TOOLBAR_GROUPS, coreCommands } from "./toolbar-items.js";
|
|
36
|
-
export { Abilities, type AbilitiesOptions, type AbilitiesStorage, type AiBlock, type AiBlockDataProvider, type AiBlockDataRequest, type AiBlockDatum, type AiContext, type
|
|
40
|
+
export { Abilities, type AbilitiesOptions, type AbilitiesStorage, type AiBlock, type AiBlockDataProvider, type AiBlockDataRequest, type AiBlockDatum, type AiContext, type AiContextBlockType, type AiStreamEvent, type AnchorResolver, type AssetBlock, type AuthorIdentity, BLOCK_MIME, BUILT_IN_BLOCK_CAPABILITIES, type BackendCapability, type BackendCommentsOptions, BackendError, type BlockAction, type BlockActionContext, type BlockActionSurface, type BlockCapability, BlockConvert, BlockFlash, type BlockPipeline, type BlockTarget, type BlockTransfer, BlockTransferStorage, type BlockTransferStorageData, type BlockTypeCapability, type BlockTypeData, type BlockUiOptions, CATALOGS, CORE_TARGET_IDS, CORE_TOOLBAR_GROUPS, type CapabilityContext, type CapabilityIndex, type CapabilityIssue, type CapabilityRegistry, type CollaborationSession, type CollaborationToken, type CommandBase, type CommandDef, type CommandState, type ConversionProvider, type ConvertTarget, type Converter, type CoreContentOptions, type CoreUi, type Creates, DEFAULT_ABILITY_RULES, DEFAULT_BLOCK_PIPELINE, DEFAULT_LOCALE, DERIVATION_KEY, type Derivation, type DerivationIndex, type DerivationMethod, type DerivationOrigin, type DerivationSource, type DerivationState, type DeriveContext, type DeriveMethod, type DeriveRegistry, type DerivedEntry, type Dimension, type DocAnchor, DocAnchors, type DocAnchorsMeta, type DocAnchorsOptions, DocumentMarkdown, type EditorAiConfig, type EditorBackend, type EditorContext, type EditorContextOptions, type EditorEntry, type EditorFeature, type EditorMetadata, type EditorPreset, type EditorUi, type FeatureContext, type FeatureContextOptions, type ForeignBlocks, type InsertGuard, LOCALES, type Locale, METADATA_LIST, type MenuItem, type MessageKey, type MessageParams, type Messages, Metadata, type MetadataItem, type MetadataQuery, type MetadataRegistry, type MetadataSource, type Notice, type Notifier, PALETTE_OTHER_GROUP, PROPERTY_TYPES, type PaletteEntry, type PaletteGroup, type PlacedToolbarGroup, type PresetStorage, type PropertyDefinition, type ReadonlyStore, SINGLETON_PIPELINE_HOOKS, type SettingsTab, SlashCommand, type SlashCommandOptions, SlashCommandPluginKey, type Store, type SuggestionDisplay, type SuggestionListProps, SuggestionPopup, type SuggestionPopupHandle, type SuggestionPopupRenderer, type TextblockSpec, type ToolbarGroupDef, type TransactionGuard, TransactionGuards, type TransactionGuardsOptions, type Translate, abilitiesAt, abilitiesAtSelection, aiBlockDataOf, aiContextOf, anchorResolverOf, assetRefOf, blockActionsOf, blockConversion, blockTransferOf, blockTypeConfigOf, blockTypeIdOf, canCreateAt, capabilitiesAt, capabilitiesOf, capabilityConfigOf, capabilityDataOf, capabilityIndexOf, capabilityIssues, captureRange, childrenOf, command, commandState, commandsOf, contributions, conversionLabel, conversionTargetGroups, conversionsOf, convertCoreBlocks, convertMenuItems, convertTargetId, coreBlockActions, coreCommands, coreContentFeature, coreConversionTargets, coreConversions, coreUiFeature, createCapabilityIndex, createCapabilityRegistry, createConverter, createDeriveRegistry, createEditorContext, createFeatureContext, createMetadataRegistry, createStore, createSuggestionRender, createTranslator, defineEditor, derivationIndexOf, derivationOf, derivationOriginOf, derivationState, deriveActionsOf, deriveMethodsAt, derived, derivedChildrenOf, derivedOf, docAnchorsKey, downloadText, editorEntryOf, fetchErrorMessage, filterMetadataItems, filterPalette, finishConversion, formatAiResultOf, guardsAccept, hasAbility, isCoreSource, isCoreTarget, isCurrentTarget, isForeignSource, isListNode, isLocale, isQuoteNode, isTextblockNode, isWrapperBlock, listsCapability, metadataOf, notifierOf, paletteGroupsOf, parseBlocks, parseConversionTarget, parseCoreTarget, pipelineOf, presetExtension, readBlockTransfer, registerEditor, releaseRanges, resolveRange, selectionRange, settingsTabsOf, sha256Hex, silentNotifier, startBlockDrag, structureBlocks, suggestionPopupOf, targetOwner, textblockSpecOf, toolbarOf, transactionGuardExtensions, validateBlockTypes, wrapImportBlocks, writeBlockTransfer };
|
package/dist/core/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { BackendError } from "./backend.js";
|
|
2
2
|
import { Abilities, DEFAULT_ABILITY_RULES, abilitiesAt, abilitiesAtSelection, hasAbility } from "./abilities.js";
|
|
3
|
+
import { BUILT_IN_BLOCK_CAPABILITIES, blockTypeConfigOf, blockTypeIdOf, capabilitiesAt, capabilitiesOf, capabilityConfigOf, capabilityDataOf, capabilityIndexOf, capabilityIssues, createCapabilityIndex, createCapabilityRegistry, listsCapability, validateBlockTypes } from "./capabilities.js";
|
|
4
|
+
import { createDeriveRegistry, deriveActionsOf, deriveMethodsAt } from "./derive.js";
|
|
3
5
|
import { SINGLETON_PIPELINE_HOOKS } from "./feature.js";
|
|
4
6
|
import { DEFAULT_BLOCK_PIPELINE, aiBlockDataOf, aiContextOf, conversionsOf, formatAiResultOf, parseBlocks, pipelineOf, presetExtension, structureBlocks, wrapImportBlocks } from "./pipeline.js";
|
|
5
7
|
import { contributions, defineEditor, settingsTabsOf } from "./define-editor.js";
|
|
@@ -8,6 +10,8 @@ import { editorEntryOf, notifierOf, registerEditor } from "./editor-ui.js";
|
|
|
8
10
|
import { canCreateAt, command, commandState, commandsOf, guardsAccept, toolbarOf } from "./commands.js";
|
|
9
11
|
import { CORE_TARGET_IDS, childrenOf, convertCoreBlocks, convertTargetId, coreConversionTargets, createConverter, finishConversion, isCoreSource, isCoreTarget, isCurrentTarget, isListNode, isQuoteNode, isTextblockNode, isWrapperBlock, parseCoreTarget, textblockSpecOf } from "./convert.js";
|
|
10
12
|
import { BlockConvert, blockConversion, conversionLabel, conversionTargetGroups, convertMenuItems, coreConversions, parseConversionTarget, targetOwner } from "./block-convert.js";
|
|
13
|
+
import { DERIVATION_KEY, assetRefOf, derivationIndexOf, derivationOf, derivationOriginOf, derivationState, derivedChildrenOf, derivedOf, isForeignSource } from "./derivation.js";
|
|
14
|
+
import { PROPERTY_TYPES } from "./properties.js";
|
|
11
15
|
import { BLOCK_MIME, BlockTransferStorage, blockTransferOf, readBlockTransfer, writeBlockTransfer } from "./block-transfer.js";
|
|
12
16
|
import { startBlockDrag } from "./block-drag.js";
|
|
13
17
|
import { BlockFlash } from "./block-flash.js";
|
|
@@ -29,4 +33,4 @@ import { sha256Hex } from "./hash.js";
|
|
|
29
33
|
import { METADATA_LIST } from "./metadata-types.js";
|
|
30
34
|
import { PALETTE_OTHER_GROUP, filterPalette, paletteGroupsOf } from "./palette.js";
|
|
31
35
|
import { selectionRange } from "./selection-range.js";
|
|
32
|
-
export { Abilities, BLOCK_MIME, BackendError, BlockConvert, BlockFlash, BlockTransferStorage, CATALOGS, CORE_TARGET_IDS, CORE_TOOLBAR_GROUPS, DEFAULT_ABILITY_RULES, DEFAULT_BLOCK_PIPELINE, DEFAULT_LOCALE, DocAnchors, DocumentMarkdown, LOCALES, METADATA_LIST, Metadata, PALETTE_OTHER_GROUP, SINGLETON_PIPELINE_HOOKS, SlashCommand, SlashCommandPluginKey, SuggestionPopup, TransactionGuards, abilitiesAt, abilitiesAtSelection, aiBlockDataOf, aiContextOf, anchorResolverOf, blockActionsOf, blockConversion, blockTransferOf, canCreateAt, captureRange, childrenOf, command, commandState, commandsOf, contributions, conversionLabel, conversionTargetGroups, conversionsOf, convertCoreBlocks, convertMenuItems, convertTargetId, coreBlockActions, coreCommands, coreContentFeature, coreConversionTargets, coreConversions, coreUiFeature, createConverter, createEditorContext, createFeatureContext, createMetadataRegistry, createStore, createSuggestionRender, createTranslator, defineEditor, derived, docAnchorsKey, downloadText, editorEntryOf, fetchErrorMessage, filterMetadataItems, filterPalette, finishConversion, formatAiResultOf, guardsAccept, hasAbility, isCoreSource, isCoreTarget, isCurrentTarget, isListNode, isLocale, isQuoteNode, isTextblockNode, isWrapperBlock, metadataOf, notifierOf, paletteGroupsOf, parseBlocks, parseConversionTarget, parseCoreTarget, pipelineOf, presetExtension, readBlockTransfer, registerEditor, releaseRanges, resolveRange, selectionRange, settingsTabsOf, sha256Hex, silentNotifier, startBlockDrag, structureBlocks, suggestionPopupOf, targetOwner, textblockSpecOf, toolbarOf, transactionGuardExtensions, wrapImportBlocks, writeBlockTransfer };
|
|
36
|
+
export { Abilities, BLOCK_MIME, BUILT_IN_BLOCK_CAPABILITIES, BackendError, BlockConvert, BlockFlash, BlockTransferStorage, CATALOGS, CORE_TARGET_IDS, CORE_TOOLBAR_GROUPS, DEFAULT_ABILITY_RULES, DEFAULT_BLOCK_PIPELINE, DEFAULT_LOCALE, DERIVATION_KEY, DocAnchors, DocumentMarkdown, LOCALES, METADATA_LIST, Metadata, PALETTE_OTHER_GROUP, PROPERTY_TYPES, SINGLETON_PIPELINE_HOOKS, SlashCommand, SlashCommandPluginKey, SuggestionPopup, TransactionGuards, abilitiesAt, abilitiesAtSelection, aiBlockDataOf, aiContextOf, anchorResolverOf, assetRefOf, blockActionsOf, blockConversion, blockTransferOf, blockTypeConfigOf, blockTypeIdOf, canCreateAt, capabilitiesAt, capabilitiesOf, capabilityConfigOf, capabilityDataOf, capabilityIndexOf, capabilityIssues, captureRange, childrenOf, command, commandState, commandsOf, contributions, conversionLabel, conversionTargetGroups, conversionsOf, convertCoreBlocks, convertMenuItems, convertTargetId, coreBlockActions, coreCommands, coreContentFeature, coreConversionTargets, coreConversions, coreUiFeature, createCapabilityIndex, createCapabilityRegistry, createConverter, createDeriveRegistry, createEditorContext, createFeatureContext, createMetadataRegistry, createStore, createSuggestionRender, createTranslator, defineEditor, derivationIndexOf, derivationOf, derivationOriginOf, derivationState, deriveActionsOf, deriveMethodsAt, derived, derivedChildrenOf, derivedOf, docAnchorsKey, downloadText, editorEntryOf, fetchErrorMessage, filterMetadataItems, filterPalette, finishConversion, formatAiResultOf, guardsAccept, hasAbility, isCoreSource, isCoreTarget, isCurrentTarget, isForeignSource, isListNode, isLocale, isQuoteNode, isTextblockNode, isWrapperBlock, listsCapability, metadataOf, notifierOf, paletteGroupsOf, parseBlocks, parseConversionTarget, parseCoreTarget, pipelineOf, presetExtension, readBlockTransfer, registerEditor, releaseRanges, resolveRange, selectionRange, settingsTabsOf, sha256Hex, silentNotifier, startBlockDrag, structureBlocks, suggestionPopupOf, targetOwner, textblockSpecOf, toolbarOf, transactionGuardExtensions, validateBlockTypes, wrapImportBlocks, writeBlockTransfer };
|
package/dist/core/pipeline.d.ts
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
|
+
import { BlockTypeData, CapabilityRegistry } from "./capabilities.js";
|
|
2
|
+
import { DeriveRegistry } from "./derive.js";
|
|
1
3
|
import { AiBlockDataProvider, AiContext, BlockPipeline, ConversionProvider, EditorFeature, EditorPreset } from "./feature.js";
|
|
2
4
|
import { Editor, Extension, JSONContent } from "@tiptap/core";
|
|
3
5
|
//#region src/core/pipeline.d.ts
|
|
4
6
|
/**
|
|
5
7
|
* Tiptap Markdown parsing and identity transforms: what an editor without contributing features does. Every
|
|
6
|
-
* `:::
|
|
7
|
-
* parses those first); an editor without that node parses the fences as text.
|
|
8
|
+
* `::: <block type id>` … `:::` fence becomes an `opaqueFence` that keeps its text verbatim (a feature that knows Block types,
|
|
9
|
+
* typed blocks, parses those first); an editor without that node parses the fences as text. Loaded JSON still goes through
|
|
10
|
+
* the persisted-name migration (an `opaqueFence` stored with `kind`).
|
|
8
11
|
*/
|
|
9
12
|
export declare const DEFAULT_BLOCK_PIPELINE: BlockPipeline;
|
|
10
13
|
export interface PresetStorage {
|
|
11
14
|
pipeline: BlockPipeline;
|
|
12
15
|
conversions: readonly ConversionProvider[];
|
|
16
|
+
capabilities: CapabilityRegistry;
|
|
17
|
+
deriveMethods: DeriveRegistry;
|
|
18
|
+
blockTypes?: (editor: Editor) => readonly BlockTypeData[];
|
|
13
19
|
aiContext?: EditorFeature['aiContext'];
|
|
14
20
|
aiBlockData?: AiBlockDataProvider;
|
|
15
21
|
formatAiResult?: EditorFeature['formatAiResult'];
|
|
@@ -19,15 +25,18 @@ declare module '@tiptap/core' {
|
|
|
19
25
|
editorPreset: PresetStorage;
|
|
20
26
|
}
|
|
21
27
|
}
|
|
22
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* Makes the preset's resolved pipeline, conversion providers, block capabilities and AI hooks reachable from the editor instance (`pipelineOf`, `conversionsOf`, `aiContextOf`).
|
|
30
|
+
* Creating the editor also checks the Features' Block types against the declared capabilities (`validateBlockTypes`), so an unknown capability id throws from the editor's constructor.
|
|
31
|
+
*/
|
|
23
32
|
export declare function presetExtension(preset: EditorPreset): Extension;
|
|
24
33
|
/** The pipeline `editor` was created with (the defaults for an editor without a preset). */
|
|
25
34
|
export declare const pipelineOf: (editor: Editor) => BlockPipeline;
|
|
26
35
|
/** The conversion providers of the preset `editor` was created with, in feature order. */
|
|
27
36
|
export declare const conversionsOf: (editor: Editor) => readonly ConversionProvider[];
|
|
28
|
-
/** What AI knows about `editor`'s document model: the merged `aiContext` of the preset's features, else no
|
|
37
|
+
/** What AI knows about `editor`'s document model: the merged `aiContext` of the preset's features, else no Block types, no blocks and a flat structure. */
|
|
29
38
|
export declare function aiContextOf(editor: Editor): {
|
|
30
|
-
|
|
39
|
+
blockTypes: NonNullable<AiContext['blockTypes']>;
|
|
31
40
|
blocks: NonNullable<AiContext['blocks']>;
|
|
32
41
|
structure: NonNullable<AiContext['structure']>;
|
|
33
42
|
};
|
package/dist/core/pipeline.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import { validateBlockTypes } from "./capabilities.js";
|
|
1
2
|
import { opaqueFenceJSON, splitCompositeFences } from "./fences.js";
|
|
3
|
+
import { migratePersistedNames } from "./schema/persisted-names.js";
|
|
2
4
|
import { Extension } from "@tiptap/core";
|
|
3
5
|
//#region src/core/pipeline.ts
|
|
4
6
|
/**
|
|
5
7
|
* Tiptap Markdown parsing and identity transforms: what an editor without contributing features does. Every
|
|
6
|
-
* `:::
|
|
7
|
-
* parses those first); an editor without that node parses the fences as text.
|
|
8
|
+
* `::: <block type id>` … `:::` fence becomes an `opaqueFence` that keeps its text verbatim (a feature that knows Block types,
|
|
9
|
+
* typed blocks, parses those first); an editor without that node parses the fences as text. Loaded JSON still goes through
|
|
10
|
+
* the persisted-name migration (an `opaqueFence` stored with `kind`).
|
|
8
11
|
*/
|
|
9
12
|
const DEFAULT_BLOCK_PIPELINE = {
|
|
10
13
|
parseMarkdown: (editor, markdown) => {
|
|
@@ -17,30 +20,39 @@ const DEFAULT_BLOCK_PIPELINE = {
|
|
|
17
20
|
segment: (_editor, blocks) => blocks,
|
|
18
21
|
structure: (_editor, blocks) => blocks,
|
|
19
22
|
wrapImport: (_editor, _file, blocks) => blocks,
|
|
20
|
-
migrateContent:
|
|
23
|
+
migrateContent: migratePersistedNames
|
|
21
24
|
};
|
|
22
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Makes the preset's resolved pipeline, conversion providers, block capabilities and AI hooks reachable from the editor instance (`pipelineOf`, `conversionsOf`, `aiContextOf`).
|
|
27
|
+
* Creating the editor also checks the Features' Block types against the declared capabilities (`validateBlockTypes`), so an unknown capability id throws from the editor's constructor.
|
|
28
|
+
*/
|
|
23
29
|
function presetExtension(preset) {
|
|
24
30
|
return Extension.create({
|
|
25
31
|
name: "editorPreset",
|
|
26
32
|
addStorage: () => ({
|
|
27
33
|
pipeline: preset.pipeline,
|
|
28
34
|
conversions: preset.conversions,
|
|
35
|
+
capabilities: preset.capabilities,
|
|
36
|
+
deriveMethods: preset.deriveMethods,
|
|
37
|
+
...preset.blockTypes && { blockTypes: preset.blockTypes },
|
|
29
38
|
...preset.aiContext && { aiContext: preset.aiContext },
|
|
30
39
|
...preset.aiBlockData && { aiBlockData: preset.aiBlockData },
|
|
31
40
|
...preset.formatAiResult && { formatAiResult: preset.formatAiResult }
|
|
32
|
-
})
|
|
41
|
+
}),
|
|
42
|
+
onBeforeCreate() {
|
|
43
|
+
if (preset.blockTypes) validateBlockTypes(preset.capabilities, preset.blockTypes(this.editor));
|
|
44
|
+
}
|
|
33
45
|
});
|
|
34
46
|
}
|
|
35
47
|
/** The pipeline `editor` was created with (the defaults for an editor without a preset). */
|
|
36
48
|
const pipelineOf = (editor) => editor.storage.editorPreset?.pipeline ?? DEFAULT_BLOCK_PIPELINE;
|
|
37
49
|
/** The conversion providers of the preset `editor` was created with, in feature order. */
|
|
38
50
|
const conversionsOf = (editor) => editor.storage.editorPreset?.conversions ?? [];
|
|
39
|
-
/** What AI knows about `editor`'s document model: the merged `aiContext` of the preset's features, else no
|
|
51
|
+
/** What AI knows about `editor`'s document model: the merged `aiContext` of the preset's features, else no Block types, no blocks and a flat structure. */
|
|
40
52
|
function aiContextOf(editor) {
|
|
41
53
|
const context = editor.storage.editorPreset?.aiContext?.(editor);
|
|
42
54
|
return {
|
|
43
|
-
|
|
55
|
+
blockTypes: context?.blockTypes ?? [],
|
|
44
56
|
blocks: context?.blocks ?? [],
|
|
45
57
|
structure: context?.structure ?? "flat"
|
|
46
58
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pipeline.js","names":[],"sources":["../../src/core/pipeline.ts"],"sourcesContent":["import { type Editor, Extension, type JSONContent } from '@tiptap/core'\nimport { opaqueFenceJSON, splitCompositeFences } from './fences'\nimport type { AiBlockDataProvider, AiContext, BlockPipeline, ConversionProvider, EditorFeature, EditorPreset } from './feature'\n\n/**\n * Tiptap Markdown parsing and identity transforms: what an editor without contributing features does. Every\n * `:::
|
|
1
|
+
{"version":3,"file":"pipeline.js","names":[],"sources":["../../src/core/pipeline.ts"],"sourcesContent":["import { type Editor, Extension, type JSONContent } from '@tiptap/core'\nimport { type BlockTypeData, type CapabilityRegistry, validateBlockTypes } from './capabilities'\nimport type { DeriveRegistry } from './derive'\nimport { opaqueFenceJSON, splitCompositeFences } from './fences'\nimport type { AiBlockDataProvider, AiContext, BlockPipeline, ConversionProvider, EditorFeature, EditorPreset } from './feature'\nimport { migratePersistedNames } from './schema/persisted-names'\n\n/**\n * Tiptap Markdown parsing and identity transforms: what an editor without contributing features does. Every\n * `::: <block type id>` … `:::` fence becomes an `opaqueFence` that keeps its text verbatim (a feature that knows Block types,\n * typed blocks, parses those first); an editor without that node parses the fences as text. Loaded JSON still goes through\n * the persisted-name migration (an `opaqueFence` stored with `kind`).\n */\nexport const DEFAULT_BLOCK_PIPELINE: BlockPipeline = {\n parseMarkdown: (editor, markdown) => {\n const parse = (text: string) => editor.markdown?.parse(text).content ?? []\n const segments = editor.schema.nodes.opaqueFence ? splitCompositeFences(markdown) : []\n if (!segments.some(segment => 'inner' in segment)) return parse(markdown)\n return segments.flatMap(segment => 'inner' in segment ? [opaqueFenceJSON(segment)] : parse(segment.markdown))\n },\n normalize: (_editor, blocks) => blocks,\n segment: (_editor, blocks) => blocks,\n structure: (_editor, blocks) => blocks,\n wrapImport: (_editor, _file, blocks) => blocks,\n migrateContent: migratePersistedNames,\n}\n\nexport interface PresetStorage {\n pipeline: BlockPipeline\n conversions: readonly ConversionProvider[]\n capabilities: CapabilityRegistry\n deriveMethods: DeriveRegistry\n blockTypes?: (editor: Editor) => readonly BlockTypeData[]\n aiContext?: EditorFeature['aiContext']\n aiBlockData?: AiBlockDataProvider\n formatAiResult?: EditorFeature['formatAiResult']\n}\n\ndeclare module '@tiptap/core' {\n interface Storage { editorPreset: PresetStorage }\n}\n\n/**\n * Makes the preset's resolved pipeline, conversion providers, block capabilities and AI hooks reachable from the editor instance (`pipelineOf`, `conversionsOf`, `aiContextOf`).\n * Creating the editor also checks the Features' Block types against the declared capabilities (`validateBlockTypes`), so an unknown capability id throws from the editor's constructor.\n */\nexport function presetExtension(preset: EditorPreset): Extension {\n return Extension.create({\n name: 'editorPreset',\n addStorage: (): PresetStorage => ({\n pipeline: preset.pipeline,\n conversions: preset.conversions,\n capabilities: preset.capabilities,\n deriveMethods: preset.deriveMethods,\n ...(preset.blockTypes && { blockTypes: preset.blockTypes }),\n ...(preset.aiContext && { aiContext: preset.aiContext }),\n ...(preset.aiBlockData && { aiBlockData: preset.aiBlockData }),\n ...(preset.formatAiResult && { formatAiResult: preset.formatAiResult }),\n }),\n onBeforeCreate() {\n if (preset.blockTypes) validateBlockTypes(preset.capabilities, preset.blockTypes(this.editor))\n },\n })\n}\n\n/** The pipeline `editor` was created with (the defaults for an editor without a preset). */\nexport const pipelineOf = (editor: Editor): BlockPipeline => editor.storage.editorPreset?.pipeline ?? DEFAULT_BLOCK_PIPELINE\n\n/** The conversion providers of the preset `editor` was created with, in feature order. */\nexport const conversionsOf = (editor: Editor): readonly ConversionProvider[] => editor.storage.editorPreset?.conversions ?? []\n\n/** What AI knows about `editor`'s document model: the merged `aiContext` of the preset's features, else no Block types, no blocks and a flat structure. */\nexport function aiContextOf(editor: Editor): { blockTypes: NonNullable<AiContext['blockTypes']>, blocks: NonNullable<AiContext['blocks']>, structure: NonNullable<AiContext['structure']> } {\n const context = editor.storage.editorPreset?.aiContext?.(editor)\n return { blockTypes: context?.blockTypes ?? [], blocks: context?.blocks ?? [], structure: context?.structure ?? 'flat' }\n}\n\n/** The preset's `formatAiResult` hook, or null when no feature contributes one. */\nexport const formatAiResultOf = (editor: Editor): ((markdown: string, heading?: string) => string) | null => {\n const format = editor.storage.editorPreset?.formatAiResult\n return format ? (markdown, heading) => format(editor, markdown, heading) : null\n}\n\n/** The merged `aiBlockData` of the preset's features; without contributors it resolves to no data. */\nexport const aiBlockDataOf = (editor: Editor): AiBlockDataProvider => editor.storage.editorPreset?.aiBlockData ?? (() => [])\n\n/**\n * `markdown` as document JSON (`parsed`: parse, then normalize) and as the blocks to insert (`blocks`: `parsed` after\n * the segment stage). `parsed` is never changed by segmenting. Inline replacements use `parsed`, block insertion and\n * file import use `blocks`.\n */\nexport function parseBlocks(editor: Editor, markdown: string): { parsed: JSONContent, blocks: JSONContent[] } {\n const pipeline = pipelineOf(editor)\n const content = pipeline.normalize(editor, pipeline.parseMarkdown(editor, markdown))\n return { parsed: { type: 'doc', content }, blocks: pipeline.segment(editor, [...content]) }\n}\n\n/** Applies the structure stage to blocks about to be inserted (AI block insertion, file import). */\nexport const structureBlocks = (editor: Editor, blocks: JSONContent[]): JSONContent[] => pipelineOf(editor).structure(editor, blocks)\n\n/** Applies the file-wrapping stage to the blocks of an imported file. */\nexport const wrapImportBlocks = (editor: Editor, file: File, blocks: JSONContent[]): JSONContent[] => pipelineOf(editor).wrapImport(editor, file, blocks)\n"],"mappings":";;;;;;;;;;;AAaA,MAAa,yBAAwC;CACnD,gBAAgB,QAAQ,aAAa;EACnC,MAAM,SAAS,SAAiB,OAAO,UAAU,MAAM,IAAI,CAAC,CAAC,WAAW,CAAC;EACzE,MAAM,WAAW,OAAO,OAAO,MAAM,cAAc,qBAAqB,QAAQ,IAAI,CAAC;EACrF,IAAI,CAAC,SAAS,MAAK,YAAW,WAAW,OAAO,GAAG,OAAO,MAAM,QAAQ;EACxE,OAAO,SAAS,SAAQ,YAAW,WAAW,UAAU,CAAC,gBAAgB,OAAO,CAAC,IAAI,MAAM,QAAQ,QAAQ,CAAC;CAC9G;CACA,YAAY,SAAS,WAAW;CAChC,UAAU,SAAS,WAAW;CAC9B,YAAY,SAAS,WAAW;CAChC,aAAa,SAAS,OAAO,WAAW;CACxC,gBAAgB;AAClB;;;;;AAqBA,SAAgB,gBAAgB,QAAiC;CAC/D,OAAO,UAAU,OAAO;EACtB,MAAM;EACN,mBAAkC;GAChC,UAAU,OAAO;GACjB,aAAa,OAAO;GACpB,cAAc,OAAO;GACrB,eAAe,OAAO;GACtB,GAAI,OAAO,cAAc,EAAE,YAAY,OAAO,WAAW;GACzD,GAAI,OAAO,aAAa,EAAE,WAAW,OAAO,UAAU;GACtD,GAAI,OAAO,eAAe,EAAE,aAAa,OAAO,YAAY;GAC5D,GAAI,OAAO,kBAAkB,EAAE,gBAAgB,OAAO,eAAe;EACvE;EACA,iBAAiB;GACf,IAAI,OAAO,YAAY,mBAAmB,OAAO,cAAc,OAAO,WAAW,KAAK,MAAM,CAAC;EAC/F;CACF,CAAC;AACH;;AAGA,MAAa,cAAc,WAAkC,OAAO,QAAQ,cAAc,YAAY;;AAGtG,MAAa,iBAAiB,WAAkD,OAAO,QAAQ,cAAc,eAAe,CAAC;;AAG7H,SAAgB,YAAY,QAAgK;CAC1L,MAAM,UAAU,OAAO,QAAQ,cAAc,YAAY,MAAM;CAC/D,OAAO;EAAE,YAAY,SAAS,cAAc,CAAC;EAAG,QAAQ,SAAS,UAAU,CAAC;EAAG,WAAW,SAAS,aAAa;CAAO;AACzH;;AAGA,MAAa,oBAAoB,WAA4E;CAC3G,MAAM,SAAS,OAAO,QAAQ,cAAc;CAC5C,OAAO,UAAU,UAAU,YAAY,OAAO,QAAQ,UAAU,OAAO,IAAI;AAC7E;;AAGA,MAAa,iBAAiB,WAAwC,OAAO,QAAQ,cAAc,sBAAsB,CAAC;;;;;;AAO1H,SAAgB,YAAY,QAAgB,UAAkE;CAC5G,MAAM,WAAW,WAAW,MAAM;CAClC,MAAM,UAAU,SAAS,UAAU,QAAQ,SAAS,cAAc,QAAQ,QAAQ,CAAC;CACnF,OAAO;EAAE,QAAQ;GAAE,MAAM;GAAO;EAAQ;EAAG,QAAQ,SAAS,QAAQ,QAAQ,CAAC,GAAG,OAAO,CAAC;CAAE;AAC5F;;AAGA,MAAa,mBAAmB,QAAgB,WAAyC,WAAW,MAAM,CAAC,CAAC,UAAU,QAAQ,MAAM;;AAGpI,MAAa,oBAAoB,QAAgB,MAAY,WAAyC,WAAW,MAAM,CAAC,CAAC,WAAW,QAAQ,MAAM,MAAM"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/core/properties.d.ts
|
|
2
|
+
/** The value types of a Block property. */
|
|
3
|
+
export declare const PROPERTY_TYPES: readonly ["text", "textarea", "date", "number", "select", "multiselect", "reference", "bibliography", "derivation"];
|
|
4
|
+
/** One Property definition: a Block property stored under `key` in the block's `meta` attribute. */
|
|
5
|
+
export interface PropertyDefinition {
|
|
6
|
+
key: string;
|
|
7
|
+
label: string;
|
|
8
|
+
/**
|
|
9
|
+
* `bibliography`: CSL-JSON item under `meta.bib`; `derivation`: read-only Derivation of a Derived block; `reference`: block id of another Typed block;
|
|
10
|
+
* `multiselect`: several of `options`, stored as `string[]` (the key is removed when none is chosen).
|
|
11
|
+
*/
|
|
12
|
+
type: typeof PROPERTY_TYPES[number];
|
|
13
|
+
/** Choices of a `select` or `multiselect` property (required for `multiselect`). */
|
|
14
|
+
options?: {
|
|
15
|
+
value: string;
|
|
16
|
+
label: string;
|
|
17
|
+
}[];
|
|
18
|
+
/** `reference`: Block type ids the property may point to; absent = any Typed block. */
|
|
19
|
+
targets?: readonly string[];
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
//# sourceMappingURL=properties.d.ts.map
|