@ecsplico/editor 3.6.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +73 -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 -8
- package/dist/features/composites/merge.js +23 -22
- 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 +150 -87
- package/dist/features/image-studio/components/ImageStudioDialog.js.map +1 -1
- package/dist/features/image-studio/components/ImageStudioDialog.vue.d.ts +5 -1
- package/dist/features/image-studio/components/ImageStudioLibraryPanel.js +186 -0
- package/dist/features/image-studio/components/ImageStudioLibraryPanel.js.map +1 -0
- package/dist/features/image-studio/components/ImageStudioLibraryTile.js +134 -0
- package/dist/features/image-studio/components/ImageStudioLibraryTile.js.map +1 -0
- 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/index.d.ts +3 -2
- package/dist/features/image-studio/index.js +2 -2
- package/dist/features/image-studio/library.d.ts +35 -0
- 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 +46 -5
- package/dist/features/image-studio/react/ImageStudioDialog.js.map +1 -1
- package/dist/features/image-studio/react/ImageStudioLibraryPanel.js +141 -0
- package/dist/features/image-studio/react/ImageStudioLibraryPanel.js.map +1 -0
- package/dist/features/image-studio/react/ImageStudioLibraryTile.js +105 -0
- package/dist/features/image-studio/react/ImageStudioLibraryTile.js.map +1 -0
- 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 +8 -3
- package/dist/features/image-studio/react/store.js.map +1 -1
- package/dist/features/image-studio/react.d.ts +4 -3
- package/dist/features/image-studio/react.js +3 -3
- 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 +8 -3
- package/dist/features/image-studio/state.js +11 -3
- package/dist/features/image-studio/state.js.map +1 -1
- package/dist/features/image-studio/store.d.ts +8 -3
- package/dist/features/image-studio/vue.d.ts +4 -3
- package/dist/features/image-studio/vue.js +3 -3
- package/dist/features/image-studio/vue.js.map +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 +11 -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 +110 -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/image-studio.js +9 -0
- package/dist/i18n/en/image-studio.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 +11 -11
- 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 +48 -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 +7 -4
- 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 +1 -1
- 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 +5 -5
- 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 +1 -1
- 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 -89
- package/dist/features/composites/kinds.js +0 -285
- package/dist/features/composites/kinds.js.map +0 -1
|
@@ -1,30 +1,31 @@
|
|
|
1
|
+
import { blockIdOf, findBlockById, newBlockId } from "../../core/schema/block-ids.js";
|
|
2
|
+
import { capabilitiesOf } from "../../core/capabilities.js";
|
|
1
3
|
import { parseBlocks } from "../../core/pipeline.js";
|
|
2
4
|
import { guardsAccept } from "../../core/commands.js";
|
|
3
|
-
import {
|
|
5
|
+
import { DERIVATION_KEY, derivationOf } from "../../core/derivation.js";
|
|
4
6
|
import { sha256Hex } from "../../core/hash.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { bodyMarkdown
|
|
8
|
-
import { compositeJSON, compositeKindsOf } from "../../features/composites/nodes.js";
|
|
7
|
+
import { aiBriefOf, blockTypeOf } from "../../features/composites/block-types.js";
|
|
8
|
+
import { blockTypesOf, compositeJSON } from "../../features/composites/nodes.js";
|
|
9
|
+
import { bodyMarkdown } from "../../features/composites/source.js";
|
|
9
10
|
import { notifyAiRateLimited } from "../../features/ai/rate-limit.js";
|
|
10
11
|
import { generateCompositeBody } from "./composite-fill.js";
|
|
11
12
|
import { Fragment } from "@tiptap/pm/model";
|
|
12
13
|
//#region src/integrations/composite-ai/derive.ts
|
|
13
|
-
/**
|
|
14
|
-
const
|
|
15
|
-
/** Whether the
|
|
16
|
-
const isDerivableSource = (editor, node) => node.
|
|
17
|
-
/** Whether a
|
|
14
|
+
/** Block types a Typed block can be derived into: the ones with the `ai-brief` capability (their brief drives the generation). */
|
|
15
|
+
const derivableBlockTypesOf = (editor) => blockTypesOf(editor).filter((blockType) => aiBriefOf(blockType) !== void 0);
|
|
16
|
+
/** Whether the Typed block `node` can be the source of a derivation: a container block with a block id (the derivation points at it by id). */
|
|
17
|
+
const isDerivableSource = (editor, node) => capabilitiesOf(editor, node).has("container") && blockIdOf(node) !== null && derivableBlockTypesOf(editor).length > 0;
|
|
18
|
+
/** Whether a Typed block of `kindId` may be inserted right after the Typed block at `pos` (the same guards as creating it there). */
|
|
18
19
|
function canDeriveAfter(editor, pos, kindId) {
|
|
19
20
|
const source = editor.state.doc.nodeAt(pos);
|
|
20
21
|
if (!source) return false;
|
|
21
22
|
const $at = editor.state.doc.resolve(pos + source.nodeSize);
|
|
22
23
|
return guardsAccept(editor, $at, {
|
|
23
|
-
type: "
|
|
24
|
-
attrs: {
|
|
24
|
+
type: "typedBlock",
|
|
25
|
+
attrs: { blockType: kindId }
|
|
25
26
|
});
|
|
26
27
|
}
|
|
27
|
-
/** Drops the derived
|
|
28
|
+
/** Drops the derived Typed block `id` again, unless its body got content meanwhile (the user may have started writing in it). */
|
|
28
29
|
function discardDerived(editor, id) {
|
|
29
30
|
const found = editor.isDestroyed ? null : findBlockById(editor.state.doc, id);
|
|
30
31
|
if (!found) return;
|
|
@@ -33,12 +34,12 @@ function discardDerived(editor, id) {
|
|
|
33
34
|
}
|
|
34
35
|
/**
|
|
35
36
|
* The write-back half of every derivation: parses the streamed `markdown` through the block pipeline and replaces the
|
|
36
|
-
* body of the (still empty) derived
|
|
37
|
-
* body as `outputHash` (kept next to the `derivation` the
|
|
37
|
+
* body of the (still empty) derived Typed block `id` with it, in one transaction together with the hash of exactly that
|
|
38
|
+
* body as `outputHash` (kept next to the `derivation` the Typed block already carries, else `options.derivation`; a Typed block
|
|
38
39
|
* with neither only gets its body), so one
|
|
39
|
-
* undo step removes both. An empty result calls `options.discard` and shows the „Leeres Ergebnis“ notice; a
|
|
40
|
-
* that vanished or no longer takes the body shows „nicht mehr gefunden“; on success the
|
|
41
|
-
* `options.done` shown as success notice. The
|
|
40
|
+
* undo step removes both. An empty result calls `options.discard` and shows the „Leeres Ergebnis“ notice; a Typed block
|
|
41
|
+
* that vanished or no longer takes the body shows „nicht mehr gefunden“; on success the Typed block is revealed and
|
|
42
|
+
* `options.done` shown as success notice. The Typed block is found again by its block id, so edits while the model ran do
|
|
42
43
|
* not misplace the result. Returns whether the body was written.
|
|
43
44
|
*/
|
|
44
45
|
function writeDerivedBody(editor, id, markdown, options) {
|
|
@@ -86,20 +87,20 @@ function writeDerivedBody(editor, id, markdown, options) {
|
|
|
86
87
|
return true;
|
|
87
88
|
}
|
|
88
89
|
/**
|
|
89
|
-
* „Ableiten (KI) → <Art>“: inserts a sibling
|
|
90
|
+
* „Ableiten (KI) → <Art>“: inserts a sibling Typed block of Block type `kindId` right after the Typed block at `pos`, titled
|
|
90
91
|
* „<Art>: <Quelle>“, whose `meta.derivation` points back at the source block (`from.block`, method `ai:<kindId>`, the
|
|
91
92
|
* Markdown hash of the source's body as `inputHash`), generates its body from the source (`generateCompositeBody`; the
|
|
92
93
|
* `aiBlockData` of composites hands the model the source's Markdown) and writes the result directly into the new
|
|
93
|
-
*
|
|
94
|
-
* edit shows as „bearbeitet“ and a later edit of the source as „Quelle geändert“. The new
|
|
94
|
+
* Typed block — no review, the new Typed block is the proposal. The hash of the written body becomes `outputHash`, so a later
|
|
95
|
+
* edit shows as „bearbeitet“ and a later edit of the source as „Quelle geändert“. The new Typed block is found again by its
|
|
95
96
|
* block id after every await, so edits while the model runs do not misplace the result. When the run fails or yields
|
|
96
|
-
* nothing the still-empty
|
|
97
|
+
* nothing the still-empty Typed block is removed again. Notices go through `notify`, in the language of `t`.
|
|
97
98
|
*/
|
|
98
99
|
async function deriveComposite(editor, pos, kindId, ai, modelRef, notify, t) {
|
|
99
100
|
const source = editor.state.doc.nodeAt(pos);
|
|
100
101
|
const sourceId = source && blockIdOf(source);
|
|
101
|
-
const kind =
|
|
102
|
-
if (source?.type.name !== "
|
|
102
|
+
const kind = blockTypesOf(editor).find((candidate) => candidate.id === kindId);
|
|
103
|
+
if (source?.type.name !== "typedBlock" || !sourceId || !kind || !aiBriefOf(kind)) return;
|
|
103
104
|
if (!canDeriveAfter(editor, pos, kindId)) {
|
|
104
105
|
notify({
|
|
105
106
|
title: t("integrations.compositeDerive.notAccepted"),
|
|
@@ -107,7 +108,7 @@ async function deriveComposite(editor, pos, kindId, ai, modelRef, notify, t) {
|
|
|
107
108
|
});
|
|
108
109
|
return;
|
|
109
110
|
}
|
|
110
|
-
const sourceKind =
|
|
111
|
+
const sourceKind = blockTypeOf(blockTypesOf(editor), String(source.attrs.blockType));
|
|
111
112
|
const derivation = {
|
|
112
113
|
from: { block: sourceId },
|
|
113
114
|
method: `ai:${kindId}`,
|
|
@@ -190,6 +191,6 @@ async function deriveComposite(editor, pos, kindId, ai, modelRef, notify, t) {
|
|
|
190
191
|
}
|
|
191
192
|
}
|
|
192
193
|
//#endregion
|
|
193
|
-
export { canDeriveAfter,
|
|
194
|
+
export { canDeriveAfter, derivableBlockTypesOf, deriveComposite, discardDerived, isDerivableSource, writeDerivedBody };
|
|
194
195
|
|
|
195
196
|
//# sourceMappingURL=derive.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"derive.js","names":[],"sources":["../../../src/integrations/composite-ai/derive.ts"],"sourcesContent":["import type { Editor, JSONContent } from '@tiptap/core'\nimport { Fragment, type Node as PMNode } from '@tiptap/pm/model'\nimport type { EditorBackend } from '../../core/backend'\nimport { guardsAccept, parseBlocks, sha256Hex } from '../../core'\nimport type { Notifier } from '../../core/notify'\nimport { blockIdOf, findBlockById, newBlockId } from '../../core/schema'\nimport type { Translate } from '../../i18n'\nimport { type ModelRef, notifyAiRateLimited } from '../../features/ai'\nimport { bodyMarkdown, COMPOSITE_CHROME_COUNT, compositeJSON, compositeKind, compositeKindsOf, DERIVATION_KEY, type Derivation, derivationOf } from '../../features/composites/schema'\nimport { generateCompositeBody } from './composite-fill'\n\n/** Kinds a Baustein can be derived into: the ones with an `ai` configuration (their brief drives the generation). */\nexport const derivableKindsOf = (editor: Editor) => compositeKindsOf(editor).filter(kind => kind.ai !== undefined)\n\n/** Whether the Baustein `node` can be the source of a derivation: a composite with a block id (the derivation points at it by id). */\nexport const isDerivableSource = (editor: Editor, node: PMNode) => node.type.name === 'composite' && blockIdOf(node) !== null && derivableKindsOf(editor).length > 0\n\n/** Whether a Baustein of `kindId` may be inserted right after the Baustein at `pos` (the same guards as creating it there). */\nexport function canDeriveAfter(editor: Editor, pos: number, kindId: string): boolean {\n const source = editor.state.doc.nodeAt(pos)\n if (!source) return false\n const $at = editor.state.doc.resolve(pos + source.nodeSize)\n return guardsAccept(editor, $at, { type: 'composite', attrs: { kind: kindId } })\n}\n\n/** Drops the derived Baustein `id` again, unless its body got content meanwhile (the user may have started writing in it). */\nexport function discardDerived(editor: Editor, id: string): void {\n const found = editor.isDestroyed ? null : findBlockById(editor.state.doc, id)\n if (!found) return\n const body = Array.from({ length: found.node.childCount - COMPOSITE_CHROME_COUNT }, (_, index) => found.node.child(COMPOSITE_CHROME_COUNT + index))\n if (body.some(child => child.textContent.trim() || child.type.name !== 'paragraph')) return\n editor.view.dispatch(editor.state.tr.delete(found.pos, found.pos + found.node.nodeSize))\n}\n\n/**\n * The write-back half of every derivation: parses the streamed `markdown` through the block pipeline and replaces the\n * body of the (still empty) derived Baustein `id` with it, in one transaction together with the hash of exactly that\n * body as `outputHash` (kept next to the `derivation` the Baustein already carries, else `options.derivation`; a Baustein\n * with neither only gets its body), so one\n * undo step removes both. An empty result calls `options.discard` and shows the „Leeres Ergebnis“ notice; a Baustein\n * that vanished or no longer takes the body shows „nicht mehr gefunden“; on success the Baustein is revealed and\n * `options.done` shown as success notice. The Baustein is found again by its block id, so edits while the model ran do\n * not misplace the result. Returns whether the body was written.\n */\nexport function writeDerivedBody(editor: Editor, id: string, markdown: string, options: { derivation?: Derivation, discard: () => void, notify: Notifier, t: Translate, done: string }): boolean {\n const { derivation, discard, notify, t, done } = options\n const blocks = markdown.trim() ? parseBlocks(editor, markdown).blocks.map(block => editor.schema.nodeFromJSON(block)) : []\n if (!blocks.length) {\n discard()\n notify({ title: t('integrations.compositeDerive.empty.title'), description: t('integrations.compositeDerive.empty.description'), kind: 'error' })\n return false\n }\n const found = findBlockById(editor.state.doc, id)\n if (!found || !found.node.canReplace(COMPOSITE_CHROME_COUNT, found.node.childCount, Fragment.from(blocks))) {\n notify({ title: t('integrations.compositeDerive.gone.title'), description: t('integrations.compositeDerive.gone.description'), kind: 'error' })\n return false\n }\n\n // One transaction: body and the hash of exactly that body, so one undo step removes both.\n const chromeSize = Array.from({ length: COMPOSITE_CHROME_COUNT }, (_, index) => found.node.child(index).nodeSize).reduce((sum, size) => sum + size, 0)\n const tr = editor.state.tr.replaceWith(found.pos + 1 + chromeSize, found.pos + found.node.nodeSize - 1, blocks)\n const written = findBlockById(tr.doc, id)!\n const stored = derivationOf(written.node) ?? derivation\n if (stored) {\n tr.setNodeMarkup(written.pos, undefined, {\n ...written.node.attrs,\n meta: { ...written.node.attrs.meta, [DERIVATION_KEY]: { ...stored, outputHash: sha256Hex(bodyMarkdown(editor, written.node)) } },\n })\n }\n editor.view.dispatch(tr)\n editor.commands.revealBlock(id)\n notify({ title: done, kind: 'success', icon: 'i-lucide-git-branch' })\n return true\n}\n\n/**\n * „Ableiten (KI) → <Art>“: inserts a sibling Baustein of kind `kindId` right after the Baustein at `pos`, titled\n * „<Art>: <Quelle>“, whose `meta.derivation` points back at the source block (`from.block`, method `ai:<kindId>`, the\n * Markdown hash of the source's body as `inputHash`), generates its body from the source (`generateCompositeBody`; the\n * `aiBlockData` of composites hands the model the source's Markdown) and writes the result directly into the new\n * Baustein — no review, the new Baustein is the proposal. The hash of the written body becomes `outputHash`, so a later\n * edit shows as „bearbeitet“ and a later edit of the source as „Quelle geändert“. The new Baustein is found again by its\n * block id after every await, so edits while the model runs do not misplace the result. When the run fails or yields\n * nothing the still-empty Baustein is removed again. Notices go through `notify`, in the language of `t`.\n */\nexport async function deriveComposite(editor: Editor, pos: number, kindId: string, ai: NonNullable<EditorBackend['ai']>, modelRef: (slot: 'generate') => ModelRef, notify: Notifier, t: Translate): Promise<void> {\n const source = editor.state.doc.nodeAt(pos)\n const sourceId = source && blockIdOf(source)\n const kind = compositeKindsOf(editor).find(candidate => candidate.id === kindId)\n if (source?.type.name !== 'composite' || !sourceId || !kind?.ai) return\n if (!canDeriveAfter(editor, pos, kindId)) {\n notify({ title: t('integrations.compositeDerive.notAccepted'), kind: 'error' })\n return\n }\n\n const sourceKind = compositeKind(compositeKindsOf(editor), String(source.attrs.kind))\n const derivation: Derivation = {\n from: { block: sourceId },\n method: `ai:${kindId}`,\n createdAt: new Date().toISOString(),\n inputHash: sha256Hex(bodyMarkdown(editor, source)),\n outputHash: '',\n }\n const id = newBlockId()\n const json = compositeJSON(kindId)\n const [title, ...rest] = json.content as JSONContent[]\n const text = `${kind.label}: ${source.child(0).textContent.trim() || sourceKind.label}`\n const created: JSONContent = {\n ...json,\n attrs: { ...json.attrs, id, meta: { [DERIVATION_KEY]: derivation } },\n content: [{ ...title!, content: [{ type: 'text', text }] }, ...rest],\n }\n editor.view.dispatch(editor.state.tr.insert(pos + source.nodeSize, editor.schema.nodeFromJSON(created)))\n\n const toastId = `derive-${id}`\n const controller = new AbortController()\n const abort = () => controller.abort()\n editor.on('destroy', abort)\n notify({ id: toastId, title: t('integrations.compositeDerive.running', { kind: kind.label }), kind: 'info', icon: 'i-lucide-loader-circle', duration: 0 })\n\n const discard = () => discardDerived(editor, id)\n\n try {\n const target = findBlockById(editor.state.doc, id)\n const result = target ? await generateCompositeBody(editor, target.pos, ai, modelRef, t, controller.signal) : null\n if (!result || result.status === 'aborted' || editor.isDestroyed) {\n if (!editor.isDestroyed) discard()\n return\n }\n if (result.status === 'rate-limited') {\n discard()\n notifyAiRateLimited(notify, t)\n return\n }\n if (result.status === 'data-error') {\n discard()\n notify({ title: t('integrations.compositeFill.dataMissing'), description: result.message, kind: 'error' })\n return\n }\n if (result.status === 'error') {\n discard()\n notify({ title: t('integrations.compositeDerive.failed'), description: result.message, kind: 'error' })\n return\n }\n\n writeDerivedBody(editor, id, result.output, { derivation, discard, notify, t, done: t('integrations.compositeDerive.done', { kind: kind.label }) })\n }\n finally {\n notify.dismiss?.(toastId)\n editor.off('destroy', abort)\n }\n}\n"],"mappings":";;;;;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AC;EAAG,MAAM;EAAQ,MAAM;EAA0B,UAAU;CAAE,CAAC;CAEzJ,MAAM,gBAAgB,eAAe,QAAQ,EAAE;CAE/C,IAAI;EACF,MAAM,SAAS,cAAc,OAAO,MAAM,KAAK,EAAE;EACjD,MAAM,SAAS,SAAS,MAAM,sBAAsB,QAAQ,OAAO,KAAK,IAAI,UAAU,GAAG,WAAW,MAAM,IAAI;EAC9G,IAAI,CAAC,UAAU,OAAO,WAAW,aAAa,OAAO,aAAa;GAChE,IAAI,CAAC,OAAO,aAAa,QAAQ;GACjC;EACF;EACA,IAAI,OAAO,WAAW,gBAAgB;GACpC,QAAQ;GACR,oBAAoB,QAAQ,CAAC;GAC7B;EACF;EACA,IAAI,OAAO,WAAW,cAAc;GAClC,QAAQ;GACR,OAAO;IAAE,OAAO,EAAE,wCAAwC;IAAG,aAAa,OAAO;IAAS,MAAM;GAAQ,CAAC;GACzG;EACF;EACA,IAAI,OAAO,WAAW,SAAS;GAC7B,QAAQ;GACR,OAAO;IAAE,OAAO,EAAE,qCAAqC;IAAG,aAAa,OAAO;IAAS,MAAM;GAAQ,CAAC;GACtG;EACF;EAEA,iBAAiB,QAAQ,IAAI,OAAO,QAAQ;GAAE;GAAY;GAAS;GAAQ;GAAG,MAAM,EAAE,qCAAqC,EAAE,MAAM,KAAK,MAAM,CAAC;EAAE,CAAC;CACpJ,UACQ;EACN,OAAO,UAAU,OAAO;EACxB,OAAO,IAAI,WAAW,KAAK;CAC7B;AACF"}
|
|
1
|
+
{"version":3,"file":"derive.js","names":[],"sources":["../../../src/integrations/composite-ai/derive.ts"],"sourcesContent":["import type { Editor, JSONContent } from '@tiptap/core'\nimport { Fragment, type Node as PMNode } from '@tiptap/pm/model'\nimport type { EditorBackend } from '../../core/backend'\nimport { capabilitiesOf, DERIVATION_KEY, type Derivation, derivationOf, guardsAccept, parseBlocks, sha256Hex } from '../../core'\nimport type { Notifier } from '../../core/notify'\nimport { blockIdOf, findBlockById, newBlockId } from '../../core/schema'\nimport type { Translate } from '../../i18n'\nimport { type ModelRef, notifyAiRateLimited } from '../../features/ai'\nimport { aiBriefOf, blockTypeOf, blockTypesOf, bodyMarkdown, COMPOSITE_CHROME_COUNT, compositeJSON } from '../../features/composites/schema'\nimport { generateCompositeBody } from './composite-fill'\n\n/** Block types a Typed block can be derived into: the ones with the `ai-brief` capability (their brief drives the generation). */\nexport const derivableBlockTypesOf = (editor: Editor) => blockTypesOf(editor).filter(blockType => aiBriefOf(blockType) !== undefined)\n\n/** Whether the Typed block `node` can be the source of a derivation: a container block with a block id (the derivation points at it by id). */\nexport const isDerivableSource = (editor: Editor, node: PMNode) => capabilitiesOf(editor, node).has('container') && blockIdOf(node) !== null && derivableBlockTypesOf(editor).length > 0\n\n/** Whether a Typed block of `kindId` may be inserted right after the Typed block at `pos` (the same guards as creating it there). */\nexport function canDeriveAfter(editor: Editor, pos: number, kindId: string): boolean {\n const source = editor.state.doc.nodeAt(pos)\n if (!source) return false\n const $at = editor.state.doc.resolve(pos + source.nodeSize)\n return guardsAccept(editor, $at, { type: 'typedBlock', attrs: { blockType: kindId } })\n}\n\n/** Drops the derived Typed block `id` again, unless its body got content meanwhile (the user may have started writing in it). */\nexport function discardDerived(editor: Editor, id: string): void {\n const found = editor.isDestroyed ? null : findBlockById(editor.state.doc, id)\n if (!found) return\n const body = Array.from({ length: found.node.childCount - COMPOSITE_CHROME_COUNT }, (_, index) => found.node.child(COMPOSITE_CHROME_COUNT + index))\n if (body.some(child => child.textContent.trim() || child.type.name !== 'paragraph')) return\n editor.view.dispatch(editor.state.tr.delete(found.pos, found.pos + found.node.nodeSize))\n}\n\n/**\n * The write-back half of every derivation: parses the streamed `markdown` through the block pipeline and replaces the\n * body of the (still empty) derived Typed block `id` with it, in one transaction together with the hash of exactly that\n * body as `outputHash` (kept next to the `derivation` the Typed block already carries, else `options.derivation`; a Typed block\n * with neither only gets its body), so one\n * undo step removes both. An empty result calls `options.discard` and shows the „Leeres Ergebnis“ notice; a Typed block\n * that vanished or no longer takes the body shows „nicht mehr gefunden“; on success the Typed block is revealed and\n * `options.done` shown as success notice. The Typed block is found again by its block id, so edits while the model ran do\n * not misplace the result. Returns whether the body was written.\n */\nexport function writeDerivedBody(editor: Editor, id: string, markdown: string, options: { derivation?: Derivation, discard: () => void, notify: Notifier, t: Translate, done: string }): boolean {\n const { derivation, discard, notify, t, done } = options\n const blocks = markdown.trim() ? parseBlocks(editor, markdown).blocks.map(block => editor.schema.nodeFromJSON(block)) : []\n if (!blocks.length) {\n discard()\n notify({ title: t('integrations.compositeDerive.empty.title'), description: t('integrations.compositeDerive.empty.description'), kind: 'error' })\n return false\n }\n const found = findBlockById(editor.state.doc, id)\n if (!found || !found.node.canReplace(COMPOSITE_CHROME_COUNT, found.node.childCount, Fragment.from(blocks))) {\n notify({ title: t('integrations.compositeDerive.gone.title'), description: t('integrations.compositeDerive.gone.description'), kind: 'error' })\n return false\n }\n\n // One transaction: body and the hash of exactly that body, so one undo step removes both.\n const chromeSize = Array.from({ length: COMPOSITE_CHROME_COUNT }, (_, index) => found.node.child(index).nodeSize).reduce((sum, size) => sum + size, 0)\n const tr = editor.state.tr.replaceWith(found.pos + 1 + chromeSize, found.pos + found.node.nodeSize - 1, blocks)\n const written = findBlockById(tr.doc, id)!\n const stored = derivationOf(written.node) ?? derivation\n if (stored) {\n tr.setNodeMarkup(written.pos, undefined, {\n ...written.node.attrs,\n meta: { ...written.node.attrs.meta, [DERIVATION_KEY]: { ...stored, outputHash: sha256Hex(bodyMarkdown(editor, written.node)) } },\n })\n }\n editor.view.dispatch(tr)\n editor.commands.revealBlock(id)\n notify({ title: done, kind: 'success', icon: 'i-lucide-git-branch' })\n return true\n}\n\n/**\n * „Ableiten (KI) → <Art>“: inserts a sibling Typed block of Block type `kindId` right after the Typed block at `pos`, titled\n * „<Art>: <Quelle>“, whose `meta.derivation` points back at the source block (`from.block`, method `ai:<kindId>`, the\n * Markdown hash of the source's body as `inputHash`), generates its body from the source (`generateCompositeBody`; the\n * `aiBlockData` of composites hands the model the source's Markdown) and writes the result directly into the new\n * Typed block — no review, the new Typed block is the proposal. The hash of the written body becomes `outputHash`, so a later\n * edit shows as „bearbeitet“ and a later edit of the source as „Quelle geändert“. The new Typed block is found again by its\n * block id after every await, so edits while the model runs do not misplace the result. When the run fails or yields\n * nothing the still-empty Typed block is removed again. Notices go through `notify`, in the language of `t`.\n */\nexport async function deriveComposite(editor: Editor, pos: number, kindId: string, ai: NonNullable<EditorBackend['ai']>, modelRef: (slot: 'generate') => ModelRef, notify: Notifier, t: Translate): Promise<void> {\n const source = editor.state.doc.nodeAt(pos)\n const sourceId = source && blockIdOf(source)\n const kind = blockTypesOf(editor).find(candidate => candidate.id === kindId)\n if (source?.type.name !== 'typedBlock' || !sourceId || !kind || !aiBriefOf(kind)) return\n if (!canDeriveAfter(editor, pos, kindId)) {\n notify({ title: t('integrations.compositeDerive.notAccepted'), kind: 'error' })\n return\n }\n\n const sourceKind = blockTypeOf(blockTypesOf(editor), String(source.attrs.blockType))\n const derivation: Derivation = {\n from: { block: sourceId },\n method: `ai:${kindId}`,\n createdAt: new Date().toISOString(),\n inputHash: sha256Hex(bodyMarkdown(editor, source)),\n outputHash: '',\n }\n const id = newBlockId()\n const json = compositeJSON(kindId)\n const [title, ...rest] = json.content as JSONContent[]\n const text = `${kind.label}: ${source.child(0).textContent.trim() || sourceKind.label}`\n const created: JSONContent = {\n ...json,\n attrs: { ...json.attrs, id, meta: { [DERIVATION_KEY]: derivation } },\n content: [{ ...title!, content: [{ type: 'text', text }] }, ...rest],\n }\n editor.view.dispatch(editor.state.tr.insert(pos + source.nodeSize, editor.schema.nodeFromJSON(created)))\n\n const toastId = `derive-${id}`\n const controller = new AbortController()\n const abort = () => controller.abort()\n editor.on('destroy', abort)\n notify({ id: toastId, title: t('integrations.compositeDerive.running', { kind: kind.label }), kind: 'info', icon: 'i-lucide-loader-circle', duration: 0 })\n\n const discard = () => discardDerived(editor, id)\n\n try {\n const target = findBlockById(editor.state.doc, id)\n const result = target ? await generateCompositeBody(editor, target.pos, ai, modelRef, t, controller.signal) : null\n if (!result || result.status === 'aborted' || editor.isDestroyed) {\n if (!editor.isDestroyed) discard()\n return\n }\n if (result.status === 'rate-limited') {\n discard()\n notifyAiRateLimited(notify, t)\n return\n }\n if (result.status === 'data-error') {\n discard()\n notify({ title: t('integrations.compositeFill.dataMissing'), description: result.message, kind: 'error' })\n return\n }\n if (result.status === 'error') {\n discard()\n notify({ title: t('integrations.compositeDerive.failed'), description: result.message, kind: 'error' })\n return\n }\n\n writeDerivedBody(editor, id, result.output, { derivation, discard, notify, t, done: t('integrations.compositeDerive.done', { kind: kind.label }) })\n }\n finally {\n notify.dismiss?.(toastId)\n editor.off('destroy', abort)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAYA,MAAa,yBAAyB,WAAmB,aAAa,MAAM,CAAC,CAAC,QAAO,cAAa,UAAU,SAAS,MAAM,KAAA,CAAS;;AAGpI,MAAa,qBAAqB,QAAgB,SAAiB,eAAe,QAAQ,IAAI,CAAC,CAAC,IAAI,WAAW,KAAK,UAAU,IAAI,MAAM,QAAQ,sBAAsB,MAAM,CAAC,CAAC,SAAS;;AAGvL,SAAgB,eAAe,QAAgB,KAAa,QAAyB;CACnF,MAAM,SAAS,OAAO,MAAM,IAAI,OAAO,GAAG;CAC1C,IAAI,CAAC,QAAQ,OAAO;CACpB,MAAM,MAAM,OAAO,MAAM,IAAI,QAAQ,MAAM,OAAO,QAAQ;CAC1D,OAAO,aAAa,QAAQ,KAAK;EAAE,MAAM;EAAc,OAAO,EAAE,WAAW,OAAO;CAAE,CAAC;AACvF;;AAGA,SAAgB,eAAe,QAAgB,IAAkB;CAC/D,MAAM,QAAQ,OAAO,cAAc,OAAO,cAAc,OAAO,MAAM,KAAK,EAAE;CAC5E,IAAI,CAAC,OAAO;CAEZ,IADa,MAAM,KAAK,EAAE,QAAQ,MAAM,KAAK,aAAA,EAAoC,IAAI,GAAG,UAAU,MAAM,KAAK,MAAA,I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,iBAAiB,QAAQ,IAAI,OAAO,QAAQ;GAAE;GAAY;GAAS;GAAQ;GAAG,MAAM,EAAE,qCAAqC,EAAE,MAAM,KAAK,MAAM,CAAC;EAAE,CAAC;CACpJ,UACQ;EACN,OAAO,UAAU,OAAO;EACxB,OAAO,IAAI,WAAW,KAAK;CAC7B;AACF"}
|
|
@@ -5,27 +5,26 @@ import { bulletsTransform, summaryTransform, transferRequest } from "./transfer-
|
|
|
5
5
|
import { CompositeBodyResult, fillComposite, generateCompositeBody } from "./composite-fill.js";
|
|
6
6
|
import { COMPOSITE_BODY_START, compositeSourceText, summarizeComposite } from "./composite-summary.js";
|
|
7
7
|
import { RenditionOptions, canCreateRendition, canRegenerateRendition, createRendition, regenerateRendition } from "./rendition.js";
|
|
8
|
-
import { canDeriveAfter,
|
|
8
|
+
import { canDeriveAfter, derivableBlockTypesOf, deriveComposite, discardDerived, isDerivableSource, writeDerivedBody } from "./derive.js";
|
|
9
9
|
import { canFetchBibliography, doiOf, fetchBibliography } from "./bibliography-fetch.js";
|
|
10
10
|
import { OutlineEntry, OutlineHeading, applyOutline, collectHeadings, parseOutlineResponse, sanitizeOutline } from "./outline-sanitize.js";
|
|
11
11
|
import { bodyUnchanged, splitByInsertedHeadings, splitCompositeWithAi } from "./split.js";
|
|
12
12
|
//#region src/integrations/composite-ai/index.d.ts
|
|
13
13
|
/**
|
|
14
|
-
* AI on
|
|
15
|
-
*
|
|
16
|
-
* body), the „Zusammenfassung erzeugen“ block action (streams a
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* and the
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* repairs the heading outline of the whole document).
|
|
14
|
+
* AI on Typed blocks (requires `composites`, `ai`, `media`): the „Block füllen (KI)“ block action (on Typed blocks of Block
|
|
15
|
+
* types with the `ai-brief` capability: brief + document → task `fill-block`, the result opens the diff review over the
|
|
16
|
+
* body), the „Zusammenfassung erzeugen (KI)“ block action (streams a summary of a Typed block's body into its description),
|
|
17
|
+
* the „Create readable rendition“ / „Regenerate (replace)“ actions of Typed blocks of a Block type with a Source (`ai.extract`:
|
|
18
|
+
* a rendition child with the transcript, full text or description of the Source; a recording needs the app's public AI
|
|
19
|
+
* configuration to enable transcription), „Ableiten (KI)“ (a Derived block of another Block type), the bibliography fetch,
|
|
20
|
+
* and the formatting of AI results in `structured` structure: an AI result that has a heading is inserted as a `section`
|
|
21
|
+
* Typed block fence; otherwise, and in `flat` structure, the base AI heading is used. It is the preset's single
|
|
22
|
+
* `formatAiResult` contributor. The base AI feature and the composites feature do not know it. Framework-free: notices go
|
|
23
|
+
* through the surface's `ctx.notify`, the model through the app's `modelProfiles(ctx.app)`. Also „Mit KI in Unterblöcke teilen“ /
|
|
24
|
+
* „Mit KI in Blöcke teilen“ (block actions on Typed blocks: the model inserts headings, the body is split at them) and
|
|
25
|
+
* „Gliederung bereinigen (KI)“ (⌘K command and block action on headings: repairs the heading outline of the whole document).
|
|
27
26
|
*/
|
|
28
27
|
export declare function compositeAiFeature(): EditorFeature<never>;
|
|
29
28
|
//#endregion
|
|
30
|
-
export { COMPOSITE_BODY_START, type CompositeBodyResult, type OutlineEntry, type OutlineHeading, type RenditionOptions, applyOutline, bodyUnchanged, bulletsTransform, canCreateRendition, canDeriveAfter, canFetchBibliography, canRegenerateRendition, collectHeadings, compositeSourceText, createRendition,
|
|
29
|
+
export { COMPOSITE_BODY_START, type CompositeBodyResult, type OutlineEntry, type OutlineHeading, type RenditionOptions, applyOutline, bodyUnchanged, bulletsTransform, canCreateRendition, canDeriveAfter, canFetchBibliography, canRegenerateRendition, collectHeadings, compositeSourceText, createRendition, derivableBlockTypesOf, deriveComposite, discardDerived, doiOf, fetchBibliography, fillComposite, generateCompositeBody, isDerivableSource, parseOutlineResponse, regenerateRendition, sanitizeOutline, splitByInsertedHeadings, splitCompositeWithAi, summarizeComposite, summaryTransform, transferRequest, writeDerivedBody };
|
|
31
30
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import { withHeading } from "../../features/ai/protocol/tasks.js";
|
|
2
2
|
import { ABILITY } from "../../core/schema/abilities.js";
|
|
3
|
-
import { compositeKind } from "../../features/composites/kinds.js";
|
|
4
3
|
import { compositeFence } from "../../features/composites/fences.js";
|
|
5
|
-
import { compositeKindsOf } from "../../features/composites/nodes.js";
|
|
6
4
|
import { modelProfiles } from "../../features/ai/model-profiles.js";
|
|
7
5
|
import { structureOf } from "../../features/composites/structure.js";
|
|
8
6
|
import { fillComposite, generateCompositeBody } from "./composite-fill.js";
|
|
9
|
-
import { canDeriveAfter,
|
|
7
|
+
import { canDeriveAfter, derivableBlockTypesOf, deriveComposite, discardDerived, isDerivableSource, writeDerivedBody } from "./derive.js";
|
|
10
8
|
import { canFetchBibliography, doiOf, fetchBibliography } from "./bibliography-fetch.js";
|
|
11
9
|
import { COMPOSITE_BODY_START, compositeSourceText, summarizeComposite } from "./composite-summary.js";
|
|
12
10
|
import { canCreateRendition, canRegenerateRendition, createRendition, regenerateRendition } from "./rendition.js";
|
|
@@ -27,109 +25,132 @@ function bibliographyFetchExtensions(ctx) {
|
|
|
27
25
|
} })
|
|
28
26
|
})];
|
|
29
27
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
28
|
+
/** Runs `fn` with the AI backend; nothing to run without it (`composeEditor` omits the integration in that case, `available` hides the method). */
|
|
29
|
+
const withAi = (fn) => (ctx) => {
|
|
30
|
+
const ai = ctx.ctx.backend.ai;
|
|
31
|
+
if (ai) fn(ctx, ai);
|
|
32
|
+
};
|
|
33
|
+
const hasAi = ({ ctx }) => !!ctx.backend.ai;
|
|
34
|
+
/**
|
|
35
|
+
* The derive methods of this integration: AI fill (`ai:<type>` content for a Typed block of a Block type with a brief), summary,
|
|
36
|
+
* AI derivation into another Block type, bibliography fetch, and the rendition of a source (transcription, text extraction, description)
|
|
37
|
+
* with its regeneration. Each declares the capability the original needs; the block actions of the same ids are generated from them.
|
|
38
|
+
*/
|
|
39
|
+
function compositeAiDeriveMethods() {
|
|
33
40
|
return [
|
|
34
41
|
{
|
|
35
42
|
id: "composite-fill",
|
|
36
|
-
label: ctx.t("integrations.compositeFill.action"),
|
|
43
|
+
label: (ctx) => ctx.t("integrations.compositeFill.action"),
|
|
37
44
|
icon: "i-lucide-wand-sparkles",
|
|
38
45
|
ability: ABILITY.aiGenerate,
|
|
39
46
|
order: 25,
|
|
40
|
-
|
|
41
|
-
|
|
47
|
+
requires: ["ai-brief"],
|
|
48
|
+
available: hasAi,
|
|
49
|
+
run: withAi(({ editor, pos, ctx }, ai) => {
|
|
42
50
|
fillComposite(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t);
|
|
43
|
-
}
|
|
51
|
+
})
|
|
44
52
|
},
|
|
45
53
|
{
|
|
46
54
|
id: "composite-summarize",
|
|
47
|
-
label: ctx.t("integrations.compositeSummary.action"),
|
|
55
|
+
label: (ctx) => ctx.t("integrations.compositeSummary.action"),
|
|
48
56
|
icon: "i-lucide-text-quote",
|
|
49
57
|
ability: ABILITY.compositeSummarize,
|
|
50
58
|
order: 30,
|
|
51
|
-
|
|
52
|
-
|
|
59
|
+
requires: ["container", "title"],
|
|
60
|
+
available: (ctx) => hasAi(ctx) && compositeSourceText(ctx.node).trim().length > 0,
|
|
61
|
+
run: withAi(({ editor, pos, ctx }, ai) => {
|
|
53
62
|
summarizeComposite(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t);
|
|
54
|
-
}
|
|
63
|
+
})
|
|
55
64
|
},
|
|
56
65
|
{
|
|
57
66
|
id: "composite-derive",
|
|
58
|
-
label: ctx.t("integrations.compositeDerive.action"),
|
|
67
|
+
label: (ctx) => ctx.t("integrations.compositeDerive.action"),
|
|
59
68
|
icon: "i-lucide-git-branch",
|
|
60
69
|
ability: ABILITY.compositeDerive,
|
|
61
70
|
order: 452,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
requires: ["container", "title"],
|
|
72
|
+
available: (ctx) => hasAi(ctx) && isDerivableSource(ctx.editor, ctx.node),
|
|
73
|
+
menu: ({ editor, pos, ctx }) => {
|
|
74
|
+
const ai = ctx.backend.ai;
|
|
75
|
+
if (!ai) return [];
|
|
76
|
+
return derivableBlockTypesOf(editor).map((kind) => ({
|
|
77
|
+
label: kind.label,
|
|
78
|
+
icon: kind.icon,
|
|
79
|
+
disabled: !canDeriveAfter(editor, pos, kind.id),
|
|
80
|
+
onSelect: () => {
|
|
81
|
+
deriveComposite(editor, pos, kind.id, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t);
|
|
82
|
+
}
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
71
85
|
},
|
|
72
86
|
{
|
|
73
87
|
id: "bibliography-fetch",
|
|
74
|
-
label: ctx.t("integrations.bibliographyFetch.action"),
|
|
88
|
+
label: (ctx) => ctx.t("integrations.bibliographyFetch.action"),
|
|
75
89
|
icon: "i-lucide-book-marked",
|
|
76
90
|
ability: ABILITY.compositeDerive,
|
|
77
91
|
order: 453,
|
|
78
|
-
|
|
79
|
-
|
|
92
|
+
requires: ["bibliography"],
|
|
93
|
+
available: (ctx) => hasAi(ctx) && canFetchBibliography(ctx.editor, ctx.node),
|
|
94
|
+
run: withAi(({ editor, pos, ctx }, ai) => {
|
|
80
95
|
fetchBibliography(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t, ctx.documentId);
|
|
81
|
-
}
|
|
96
|
+
})
|
|
82
97
|
},
|
|
83
98
|
{
|
|
84
99
|
id: "rendition-create",
|
|
85
|
-
label: ctx.t("integrations.rendition.action"),
|
|
100
|
+
label: (ctx) => ctx.t("integrations.rendition.action"),
|
|
86
101
|
icon: "i-lucide-captions",
|
|
87
102
|
ability: ABILITY.compositeDerive,
|
|
88
103
|
order: 450,
|
|
89
|
-
|
|
90
|
-
|
|
104
|
+
requires: ["source"],
|
|
105
|
+
available: (ctx) => hasAi(ctx) && canCreateRendition(ctx.editor, ctx.node, !!ctx.ctx.ai?.transcription),
|
|
106
|
+
run: withAi(({ editor, pos, ctx }, ai) => {
|
|
91
107
|
createRendition(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t);
|
|
92
|
-
}
|
|
108
|
+
})
|
|
93
109
|
},
|
|
94
110
|
{
|
|
95
111
|
id: "rendition-regenerate",
|
|
96
|
-
label: ctx.t("integrations.rendition.regenerate"),
|
|
112
|
+
label: (ctx) => ctx.t("integrations.rendition.regenerate"),
|
|
97
113
|
icon: "i-lucide-refresh-cw",
|
|
98
114
|
ability: ABILITY.compositeDerive,
|
|
99
115
|
order: 451,
|
|
100
|
-
|
|
101
|
-
|
|
116
|
+
requires: ["derived"],
|
|
117
|
+
available: (ctx) => hasAi(ctx) && canRegenerateRendition(ctx.editor, ctx.node, ctx.pos, !!ctx.ctx.ai?.transcription),
|
|
118
|
+
run: withAi(({ editor, pos, ctx }, ai) => {
|
|
102
119
|
regenerateRendition(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t);
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
...["children", "siblings"].map((mode) => ({
|
|
106
|
-
id: `composite-split-ai-${mode}`,
|
|
107
|
-
label: ctx.t(`integrations.compositeSplit.ai.${mode}`),
|
|
108
|
-
icon: "i-lucide-sparkles",
|
|
109
|
-
ability: ABILITY.aiGenerate,
|
|
110
|
-
order: mode === "children" ? 454 : 455,
|
|
111
|
-
isVisible: ({ node }) => node.type.name === "composite" && compositeSourceText(node).trim().length > 0,
|
|
112
|
-
run: ({ editor, pos }) => {
|
|
113
|
-
const { blocks } = ctx.settings.get();
|
|
114
|
-
splitCompositeWithAi(editor, pos, mode, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t, {
|
|
115
|
-
targetChars: blocks.splitTargetChars,
|
|
116
|
-
defaultKind: blocks.defaultKind
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
})),
|
|
120
|
-
{
|
|
121
|
-
id: "outline-sanitize",
|
|
122
|
-
label: ctx.t("integrations.outlineSanitize.label"),
|
|
123
|
-
icon: "i-lucide-list-tree",
|
|
124
|
-
ability: ABILITY.aiGenerate,
|
|
125
|
-
order: 456,
|
|
126
|
-
isVisible: ({ node }) => node.type.name === "heading",
|
|
127
|
-
run: ({ editor }) => {
|
|
128
|
-
sanitizeOutline(editor, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t);
|
|
129
|
-
}
|
|
120
|
+
})
|
|
130
121
|
}
|
|
131
122
|
];
|
|
132
123
|
}
|
|
124
|
+
function compositeAiActions(ctx) {
|
|
125
|
+
const ai = ctx.backend.ai;
|
|
126
|
+
if (!ai) return [];
|
|
127
|
+
return [...["children", "siblings"].map((mode) => ({
|
|
128
|
+
id: `composite-split-ai-${mode}`,
|
|
129
|
+
label: ctx.t(`integrations.compositeSplit.ai.${mode}`),
|
|
130
|
+
icon: "i-lucide-sparkles",
|
|
131
|
+
ability: ABILITY.aiGenerate,
|
|
132
|
+
order: mode === "children" ? 454 : 455,
|
|
133
|
+
requires: ["container", "title"],
|
|
134
|
+
isVisible: ({ node }) => compositeSourceText(node).trim().length > 0,
|
|
135
|
+
run: ({ editor, pos }) => {
|
|
136
|
+
const { blocks } = ctx.settings.get();
|
|
137
|
+
splitCompositeWithAi(editor, pos, mode, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t, {
|
|
138
|
+
targetChars: blocks.splitTargetChars,
|
|
139
|
+
defaultBlockType: blocks.defaultBlockType
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
})), {
|
|
143
|
+
id: "outline-sanitize",
|
|
144
|
+
label: ctx.t("integrations.outlineSanitize.label"),
|
|
145
|
+
icon: "i-lucide-list-tree",
|
|
146
|
+
ability: ABILITY.aiGenerate,
|
|
147
|
+
order: 456,
|
|
148
|
+
isVisible: ({ node }) => node.type.name === "heading",
|
|
149
|
+
run: ({ editor }) => {
|
|
150
|
+
sanitizeOutline(editor, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t);
|
|
151
|
+
}
|
|
152
|
+
}];
|
|
153
|
+
}
|
|
133
154
|
/** The ⌘K entry „Gliederung bereinigen (KI)“ (no toolbar button); absent without the AI capability. */
|
|
134
155
|
function compositeAiCommands(ctx) {
|
|
135
156
|
const ai = ctx.backend.ai;
|
|
@@ -145,19 +166,18 @@ function compositeAiCommands(ctx) {
|
|
|
145
166
|
}];
|
|
146
167
|
}
|
|
147
168
|
/**
|
|
148
|
-
* AI on
|
|
149
|
-
*
|
|
150
|
-
* body), the „Zusammenfassung erzeugen“ block action (streams a
|
|
151
|
-
*
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
* and the
|
|
155
|
-
*
|
|
156
|
-
*
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
* repairs the heading outline of the whole document).
|
|
169
|
+
* AI on Typed blocks (requires `composites`, `ai`, `media`): the „Block füllen (KI)“ block action (on Typed blocks of Block
|
|
170
|
+
* types with the `ai-brief` capability: brief + document → task `fill-block`, the result opens the diff review over the
|
|
171
|
+
* body), the „Zusammenfassung erzeugen (KI)“ block action (streams a summary of a Typed block's body into its description),
|
|
172
|
+
* the „Create readable rendition“ / „Regenerate (replace)“ actions of Typed blocks of a Block type with a Source (`ai.extract`:
|
|
173
|
+
* a rendition child with the transcript, full text or description of the Source; a recording needs the app's public AI
|
|
174
|
+
* configuration to enable transcription), „Ableiten (KI)“ (a Derived block of another Block type), the bibliography fetch,
|
|
175
|
+
* and the formatting of AI results in `structured` structure: an AI result that has a heading is inserted as a `section`
|
|
176
|
+
* Typed block fence; otherwise, and in `flat` structure, the base AI heading is used. It is the preset's single
|
|
177
|
+
* `formatAiResult` contributor. The base AI feature and the composites feature do not know it. Framework-free: notices go
|
|
178
|
+
* through the surface's `ctx.notify`, the model through the app's `modelProfiles(ctx.app)`. Also „Mit KI in Unterblöcke teilen“ /
|
|
179
|
+
* „Mit KI in Blöcke teilen“ (block actions on Typed blocks: the model inserts headings, the body is split at them) and
|
|
180
|
+
* „Gliederung bereinigen (KI)“ (⌘K command and block action on headings: repairs the heading outline of the whole document).
|
|
161
181
|
*/
|
|
162
182
|
function compositeAiFeature() {
|
|
163
183
|
return {
|
|
@@ -169,16 +189,17 @@ function compositeAiFeature() {
|
|
|
169
189
|
"media"
|
|
170
190
|
],
|
|
171
191
|
blockActions: compositeAiActions,
|
|
192
|
+
deriveMethods: compositeAiDeriveMethods(),
|
|
172
193
|
extensions: bibliographyFetchExtensions,
|
|
173
194
|
commands: compositeAiCommands,
|
|
174
195
|
formatAiResult: (editor, markdown, heading) => {
|
|
175
196
|
if (!heading) return markdown;
|
|
176
197
|
const text = withHeading(heading, markdown);
|
|
177
|
-
return structureOf(editor) === "
|
|
198
|
+
return structureOf(editor) === "structured" ? compositeFence("section", {}, text) : text;
|
|
178
199
|
}
|
|
179
200
|
};
|
|
180
201
|
}
|
|
181
202
|
//#endregion
|
|
182
|
-
export { COMPOSITE_BODY_START, applyOutline, bodyUnchanged, bulletsTransform, canCreateRendition, canDeriveAfter, canFetchBibliography, canRegenerateRendition, collectHeadings, compositeAiFeature, compositeSourceText, createRendition,
|
|
203
|
+
export { COMPOSITE_BODY_START, applyOutline, bodyUnchanged, bulletsTransform, canCreateRendition, canDeriveAfter, canFetchBibliography, canRegenerateRendition, collectHeadings, compositeAiFeature, compositeSourceText, createRendition, derivableBlockTypesOf, deriveComposite, discardDerived, doiOf, fetchBibliography, fillComposite, generateCompositeBody, isDerivableSource, parseOutlineResponse, regenerateRendition, sanitizeOutline, splitByInsertedHeadings, splitCompositeWithAi, summarizeComposite, summaryTransform, transferRequest, writeDerivedBody };
|
|
183
204
|
|
|
184
205
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../../src/integrations/composite-ai/index.ts"],"sourcesContent":["import { type AnyExtension, Extension } from '@tiptap/core'\nimport type { BlockAction, CommandDef, EditorFeature, FeatureContext } from '../../core'\nimport { ABILITY } from '../../core/schema'\nimport { modelProfiles, withHeading } from '../../features/ai'\nimport { structureOf } from '../../features/composites'\nimport '../../features/composites/bibliography-command'\nimport { compositeFence, compositeKind, compositeKindsOf } from '../../features/composites/schema'\nimport { fillComposite } from './composite-fill'\nimport { canDeriveAfter, derivableKindsOf, deriveComposite, isDerivableSource } from './derive'\nimport { canFetchBibliography, fetchBibliography } from './bibliography-fetch'\nimport { compositeSourceText, summarizeComposite } from './composite-summary'\nimport { canCreateRendition, canRegenerateRendition, createRendition, regenerateRendition } from './rendition'\nimport { sanitizeOutline } from './outline-sanitize'\nimport { splitCompositeWithAi } from './split'\n\nexport { bulletsTransform, summaryTransform, transferRequest } from './transfer-transforms'\n\nexport { type CompositeBodyResult, fillComposite, generateCompositeBody } from './composite-fill'\nexport { COMPOSITE_BODY_START, compositeSourceText, summarizeComposite } from './composite-summary'\nexport { canCreateRendition, canRegenerateRendition, createRendition, regenerateRendition, type RenditionOptions } from './rendition'\nexport { canDeriveAfter, derivableKindsOf, deriveComposite, discardDerived, isDerivableSource, writeDerivedBody } from './derive'\nexport { canFetchBibliography, doiOf, fetchBibliography } from './bibliography-fetch'\nexport { applyOutline, collectHeadings, type OutlineEntry, type OutlineHeading, parseOutlineResponse, sanitizeOutline } from './outline-sanitize'\nexport { bodyUnchanged, splitByInsertedHeadings, splitCompositeWithAi } from './split'\n\n/** The editor command `fetchCompositeBibliography` (declared by composites) behind the bibliography editor's „DOI abrufen“ button; absent without the AI capability. */\nfunction bibliographyFetchExtensions(ctx: FeatureContext): AnyExtension[] {\n const ai = ctx.backend.ai\n if (!ai) return []\n return [Extension.create({\n name: 'compositeBibliographyFetch',\n addCommands: () => ({\n fetchCompositeBibliography: (pos: number) => ({ editor }) => {\n void fetchBibliography(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t, ctx.documentId)\n return true\n },\n }),\n })]\n}\n\nfunction compositeAiActions(ctx: FeatureContext): BlockAction[] {\n const ai = ctx.backend.ai\n // Without the AI capability there is nothing to run (`composeEditor` omits the integration in that case).\n if (!ai) return []\n return [\n {\n id: 'composite-fill',\n label: ctx.t('integrations.compositeFill.action'),\n icon: 'i-lucide-wand-sparkles',\n ability: ABILITY.aiGenerate,\n order: 25,\n isVisible: ({ editor, node }) => node.type.name === 'composite' && compositeKind(compositeKindsOf(editor), String(node.attrs.kind)).ai !== undefined,\n run: ({ editor, pos }) => {\n void fillComposite(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t)\n },\n },\n {\n id: 'composite-summarize',\n label: ctx.t('integrations.compositeSummary.action'),\n icon: 'i-lucide-text-quote',\n ability: ABILITY.compositeSummarize,\n order: 30,\n isVisible: ({ node }) => compositeSourceText(node).trim().length > 0,\n run: ({ editor, pos }) => {\n void summarizeComposite(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t)\n },\n },\n {\n id: 'composite-derive',\n label: ctx.t('integrations.compositeDerive.action'),\n icon: 'i-lucide-git-branch',\n ability: ABILITY.compositeDerive,\n order: 452,\n isVisible: ({ editor, node }) => isDerivableSource(editor, node),\n menu: ({ editor, pos }) => derivableKindsOf(editor).map(kind => ({\n label: kind.label,\n icon: kind.icon,\n disabled: !canDeriveAfter(editor, pos, kind.id),\n onSelect: () => {\n void deriveComposite(editor, pos, kind.id, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t)\n },\n })),\n },\n {\n id: 'bibliography-fetch',\n label: ctx.t('integrations.bibliographyFetch.action'),\n icon: 'i-lucide-book-marked',\n ability: ABILITY.compositeDerive,\n order: 453,\n isVisible: ({ editor, node }) => canFetchBibliography(editor, node),\n run: ({ editor, pos }) => {\n void fetchBibliography(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t, ctx.documentId)\n },\n },\n {\n id: 'rendition-create',\n label: ctx.t('integrations.rendition.action'),\n icon: 'i-lucide-captions',\n ability: ABILITY.compositeDerive,\n order: 450,\n isVisible: ({ editor, node }) => canCreateRendition(editor, node, !!ctx.ai?.transcription),\n run: ({ editor, pos }) => {\n void createRendition(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t)\n },\n },\n {\n id: 'rendition-regenerate',\n label: ctx.t('integrations.rendition.regenerate'),\n icon: 'i-lucide-refresh-cw',\n ability: ABILITY.compositeDerive,\n order: 451,\n isVisible: ({ editor, node, pos }) => canRegenerateRendition(editor, node, pos, !!ctx.ai?.transcription),\n run: ({ editor, pos }) => {\n regenerateRendition(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t)\n },\n },\n ...(['children', 'siblings'] as const).map((mode): BlockAction => ({\n id: `composite-split-ai-${mode}`,\n label: ctx.t(`integrations.compositeSplit.ai.${mode}`),\n icon: 'i-lucide-sparkles',\n ability: ABILITY.aiGenerate,\n order: mode === 'children' ? 454 : 455,\n isVisible: ({ node }) => node.type.name === 'composite' && compositeSourceText(node).trim().length > 0,\n run: ({ editor, pos }) => {\n const { blocks } = ctx.settings.get()\n void splitCompositeWithAi(editor, pos, mode, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t, { targetChars: blocks.splitTargetChars, defaultKind: blocks.defaultKind })\n },\n })),\n {\n id: 'outline-sanitize',\n label: ctx.t('integrations.outlineSanitize.label'),\n icon: 'i-lucide-list-tree',\n ability: ABILITY.aiGenerate,\n order: 456,\n isVisible: ({ node }) => node.type.name === 'heading',\n run: ({ editor }) => {\n void sanitizeOutline(editor, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t)\n },\n },\n ]\n}\n\n/** The ⌘K entry „Gliederung bereinigen (KI)“ (no toolbar button); absent without the AI capability. */\nfunction compositeAiCommands(ctx: FeatureContext): CommandDef<never>[] {\n const ai = ctx.backend.ai\n if (!ai) return []\n return [{\n id: 'outline-sanitize',\n label: ctx.t('integrations.outlineSanitize.label'),\n icon: 'i-lucide-list-tree',\n toolbar: false,\n run: (editor) => {\n void sanitizeOutline(editor, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t)\n },\n }]\n}\n\n/**\n * AI on composites (requires `composites`, `ai`, `media`): the „Baustein füllen (KI)“ block action (on composites of\n * kinds with an `ai` configuration: brief + document → task `fill-block`, the result opens the diff review over the\n * body), the „Zusammenfassung erzeugen“ block action (streams a\n * summary of a composite's body into its description), the „Lesefassung erzeugen“ / „Neu erzeugen (ersetzen)“\n * actions of source-holding Bausteine (`ai.extract`: a rendition child with the transcript, full text or description of\n * the source; a recording needs the app's public AI configuration to enable transcription),\n * and the composite-structure form of AI results: with `composite` structure an AI result that\n * has a heading is inserted as a `section` composite fence, otherwise (and in flat structure) the base AI heading\n * is used. It is the preset's single `formatAiResult` contributor. The base AI feature and the composites feature do\n * not know it. Framework-free: notices go through the surface's `ctx.notify`, the model through the app's\n * `modelProfiles(ctx.app)`. Also „Mit KI in (Unter-)Bausteine teilen“ (block actions on composites: the model inserts\n * headings, the body is split at them) and „Gliederung bereinigen (KI)“ (⌘K command and block action on headings:\n * repairs the heading outline of the whole document).\n */\nexport function compositeAiFeature(): EditorFeature<never> {\n return {\n id: 'composite-ai',\n dimension: 'ai',\n requires: ['composites', 'ai', 'media'],\n blockActions: compositeAiActions,\n extensions: bibliographyFetchExtensions,\n commands: compositeAiCommands,\n formatAiResult: (editor, markdown, heading) => {\n if (!heading) return markdown\n const text = withHeading(heading, markdown)\n return structureOf(editor) === 'composite' ? compositeFence('section', {}, text) : text\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA0BA,SAAS,4BAA4B,KAAqC;CACxE,MAAM,KAAK,IAAI,QAAQ;CACvB,IAAI,CAAC,IAAI,OAAO,CAAC;CACjB,OAAO,CAAC,UAAU,OAAO;EACvB,MAAM;EACN,oBAAo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cAAc,eAAe,WAAW,CAAC,GAAG,IAAI,IAAI;EACrF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../../src/integrations/composite-ai/index.ts"],"sourcesContent":["import { type AnyExtension, Extension } from '@tiptap/core'\nimport type { BlockAction, CommandDef, DeriveContext, DeriveMethod, EditorBackend, EditorFeature, FeatureContext } from '../../core'\nimport { ABILITY } from '../../core/schema'\nimport { modelProfiles, withHeading } from '../../features/ai'\nimport { structureOf } from '../../features/composites'\nimport '../../features/composites/bibliography-command'\nimport { compositeFence } from '../../features/composites/schema'\nimport { fillComposite } from './composite-fill'\nimport { canDeriveAfter, derivableBlockTypesOf, deriveComposite, isDerivableSource } from './derive'\nimport { canFetchBibliography, fetchBibliography } from './bibliography-fetch'\nimport { compositeSourceText, summarizeComposite } from './composite-summary'\nimport { canCreateRendition, canRegenerateRendition, createRendition, regenerateRendition } from './rendition'\nimport { sanitizeOutline } from './outline-sanitize'\nimport { splitCompositeWithAi } from './split'\n\nexport { bulletsTransform, summaryTransform, transferRequest } from './transfer-transforms'\n\nexport { type CompositeBodyResult, fillComposite, generateCompositeBody } from './composite-fill'\nexport { COMPOSITE_BODY_START, compositeSourceText, summarizeComposite } from './composite-summary'\nexport { canCreateRendition, canRegenerateRendition, createRendition, regenerateRendition, type RenditionOptions } from './rendition'\nexport { canDeriveAfter, derivableBlockTypesOf, deriveComposite, discardDerived, isDerivableSource, writeDerivedBody } from './derive'\nexport { canFetchBibliography, doiOf, fetchBibliography } from './bibliography-fetch'\nexport { applyOutline, collectHeadings, type OutlineEntry, type OutlineHeading, parseOutlineResponse, sanitizeOutline } from './outline-sanitize'\nexport { bodyUnchanged, splitByInsertedHeadings, splitCompositeWithAi } from './split'\n\n/** The editor command `fetchCompositeBibliography` (declared by composites) behind the bibliography editor's „DOI abrufen“ button; absent without the AI capability. */\nfunction bibliographyFetchExtensions(ctx: FeatureContext): AnyExtension[] {\n const ai = ctx.backend.ai\n if (!ai) return []\n return [Extension.create({\n name: 'compositeBibliographyFetch',\n addCommands: () => ({\n fetchCompositeBibliography: (pos: number) => ({ editor }) => {\n void fetchBibliography(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t, ctx.documentId)\n return true\n },\n }),\n })]\n}\n\n/** Runs `fn` with the AI backend; nothing to run without it (`composeEditor` omits the integration in that case, `available` hides the method). */\nconst withAi = (fn: (ctx: DeriveContext, ai: NonNullable<EditorBackend['ai']>) => void) => (ctx: DeriveContext): void => {\n const ai = ctx.ctx.backend.ai\n if (ai) fn(ctx, ai)\n}\n\nconst hasAi = ({ ctx }: DeriveContext): boolean => !!ctx.backend.ai\n\n/**\n * The derive methods of this integration: AI fill (`ai:<type>` content for a Typed block of a Block type with a brief), summary,\n * AI derivation into another Block type, bibliography fetch, and the rendition of a source (transcription, text extraction, description)\n * with its regeneration. Each declares the capability the original needs; the block actions of the same ids are generated from them.\n */\nfunction compositeAiDeriveMethods(): DeriveMethod[] {\n return [\n {\n id: 'composite-fill',\n label: ctx => ctx.t('integrations.compositeFill.action'),\n icon: 'i-lucide-wand-sparkles',\n ability: ABILITY.aiGenerate,\n order: 25,\n requires: ['ai-brief'],\n available: hasAi,\n run: withAi(({ editor, pos, ctx }, ai) => {\n void fillComposite(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t)\n }),\n },\n {\n id: 'composite-summarize',\n label: ctx => ctx.t('integrations.compositeSummary.action'),\n icon: 'i-lucide-text-quote',\n ability: ABILITY.compositeSummarize,\n order: 30,\n requires: ['container', 'title'],\n available: ctx => hasAi(ctx) && compositeSourceText(ctx.node).trim().length > 0,\n run: withAi(({ editor, pos, ctx }, ai) => {\n void summarizeComposite(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t)\n }),\n },\n {\n id: 'composite-derive',\n label: ctx => ctx.t('integrations.compositeDerive.action'),\n icon: 'i-lucide-git-branch',\n ability: ABILITY.compositeDerive,\n order: 452,\n requires: ['container', 'title'],\n available: ctx => hasAi(ctx) && isDerivableSource(ctx.editor, ctx.node),\n menu: ({ editor, pos, ctx }) => {\n const ai = ctx.backend.ai\n if (!ai) return []\n return derivableBlockTypesOf(editor).map(kind => ({\n label: kind.label,\n icon: kind.icon,\n disabled: !canDeriveAfter(editor, pos, kind.id),\n onSelect: () => {\n void deriveComposite(editor, pos, kind.id, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t)\n },\n }))\n },\n },\n {\n id: 'bibliography-fetch',\n label: ctx => ctx.t('integrations.bibliographyFetch.action'),\n icon: 'i-lucide-book-marked',\n ability: ABILITY.compositeDerive,\n order: 453,\n requires: ['bibliography'],\n available: ctx => hasAi(ctx) && canFetchBibliography(ctx.editor, ctx.node),\n run: withAi(({ editor, pos, ctx }, ai) => {\n void fetchBibliography(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t, ctx.documentId)\n }),\n },\n {\n id: 'rendition-create',\n label: ctx => ctx.t('integrations.rendition.action'),\n icon: 'i-lucide-captions',\n ability: ABILITY.compositeDerive,\n order: 450,\n requires: ['source'],\n available: ctx => hasAi(ctx) && canCreateRendition(ctx.editor, ctx.node, !!ctx.ctx.ai?.transcription),\n run: withAi(({ editor, pos, ctx }, ai) => {\n void createRendition(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t)\n }),\n },\n {\n id: 'rendition-regenerate',\n label: ctx => ctx.t('integrations.rendition.regenerate'),\n icon: 'i-lucide-refresh-cw',\n ability: ABILITY.compositeDerive,\n order: 451,\n requires: ['derived'],\n available: ctx => hasAi(ctx) && canRegenerateRendition(ctx.editor, ctx.node, ctx.pos, !!ctx.ctx.ai?.transcription),\n run: withAi(({ editor, pos, ctx }, ai) => {\n regenerateRendition(editor, pos, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t)\n }),\n },\n ]\n}\n\nfunction compositeAiActions(ctx: FeatureContext): BlockAction[] {\n const ai = ctx.backend.ai\n // Without the AI capability there is nothing to run (`composeEditor` omits the integration in that case).\n if (!ai) return []\n return [\n ...(['children', 'siblings'] as const).map((mode): BlockAction => ({\n id: `composite-split-ai-${mode}`,\n label: ctx.t(`integrations.compositeSplit.ai.${mode}`),\n icon: 'i-lucide-sparkles',\n ability: ABILITY.aiGenerate,\n order: mode === 'children' ? 454 : 455,\n requires: ['container', 'title'],\n isVisible: ({ node }) => compositeSourceText(node).trim().length > 0,\n run: ({ editor, pos }) => {\n const { blocks } = ctx.settings.get()\n void splitCompositeWithAi(editor, pos, mode, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t, { targetChars: blocks.splitTargetChars, defaultBlockType: blocks.defaultBlockType })\n },\n })),\n {\n id: 'outline-sanitize',\n label: ctx.t('integrations.outlineSanitize.label'),\n icon: 'i-lucide-list-tree',\n ability: ABILITY.aiGenerate,\n order: 456,\n isVisible: ({ node }) => node.type.name === 'heading',\n run: ({ editor }) => {\n void sanitizeOutline(editor, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t)\n },\n },\n ]\n}\n\n/** The ⌘K entry „Gliederung bereinigen (KI)“ (no toolbar button); absent without the AI capability. */\nfunction compositeAiCommands(ctx: FeatureContext): CommandDef<never>[] {\n const ai = ctx.backend.ai\n if (!ai) return []\n return [{\n id: 'outline-sanitize',\n label: ctx.t('integrations.outlineSanitize.label'),\n icon: 'i-lucide-list-tree',\n toolbar: false,\n run: (editor) => {\n void sanitizeOutline(editor, ai, modelProfiles(ctx.app).modelRef, ctx.notify, ctx.t)\n },\n }]\n}\n\n/**\n * AI on Typed blocks (requires `composites`, `ai`, `media`): the „Block füllen (KI)“ block action (on Typed blocks of Block\n * types with the `ai-brief` capability: brief + document → task `fill-block`, the result opens the diff review over the\n * body), the „Zusammenfassung erzeugen (KI)“ block action (streams a summary of a Typed block's body into its description),\n * the „Create readable rendition“ / „Regenerate (replace)“ actions of Typed blocks of a Block type with a Source (`ai.extract`:\n * a rendition child with the transcript, full text or description of the Source; a recording needs the app's public AI\n * configuration to enable transcription), „Ableiten (KI)“ (a Derived block of another Block type), the bibliography fetch,\n * and the formatting of AI results in `structured` structure: an AI result that has a heading is inserted as a `section`\n * Typed block fence; otherwise, and in `flat` structure, the base AI heading is used. It is the preset's single\n * `formatAiResult` contributor. The base AI feature and the composites feature do not know it. Framework-free: notices go\n * through the surface's `ctx.notify`, the model through the app's `modelProfiles(ctx.app)`. Also „Mit KI in Unterblöcke teilen“ /\n * „Mit KI in Blöcke teilen“ (block actions on Typed blocks: the model inserts headings, the body is split at them) and\n * „Gliederung bereinigen (KI)“ (⌘K command and block action on headings: repairs the heading outline of the whole document).\n */\nexport function compositeAiFeature(): EditorFeature<never> {\n return {\n id: 'composite-ai',\n dimension: 'ai',\n requires: ['composites', 'ai', 'media'],\n blockActions: compositeAiActions,\n deriveMethods: compositeAiDeriveMethods(),\n extensions: bibliographyFetchExtensions,\n commands: compositeAiCommands,\n formatAiResult: (editor, markdown, heading) => {\n if (!heading) return markdown\n const text = withHeading(heading, markdown)\n return structureOf(editor) === 'structured' ? compositeFence('section', {}, text) : text\n },\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA0BA,SAAS,4BAA4B,KAAqC;CACxE,MAAM,KAAK,IAAI,QAAQ;CACvB,IAAI,CAAC,IAAI,OAAO,CAAC;CACjB,OAAO,CAAC,UAAU,OAAO;EACvB,MAAM;EACN,oBAAoB,EAClB,6BAA6B,SAAiB,EAAE,aAAa;GAC3D,kBAAuB,QAAQ,KAAK,IAAI,cAAc,IAAI,GAAG,CAAC,CAAC,UAAU,IAAI,QAAQ,IAAI,GAAG,IAAI,UAAU;GAC1G,OAAO;EACT,EACF;CACF,CAAC,CAAC;AACJ;;AAGA,MAAM,UAAU,QAA4E,QAA6B;CACvH,MAAM,KAAK,IAAI,IAAI,QAAQ;CAC3B,IAAI,IAAI,GAAG,KAAK,EAAE;AACpB;AAEA,MAAM,SAAS,EAAE,UAAkC,CAAC,CAAC,IAAI,QAAQ;;;;;;AAOjE,SAAS,2B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D,OAAO;EACL,IAAI;EACJ,WAAW;EACX,UAAU;GAAC;GAAc;GAAM;EAAO;EACtC,cAAc;EACd,eAAe,yBAAyB;EACxC,YAAY;EACZ,UAAU;EACV,iBAAiB,QAAQ,UAAU,YAAY;GAC7C,IAAI,CAAC,SAAS,OAAO;GACrB,MAAM,OAAO,YAAY,SAAS,QAAQ;GAC1C,OAAO,YAAY,MAAM,MAAM,eAAe,eAAe,WAAW,CAAC,GAAG,IAAI,IAAI;EACtF;CACF;AACF"}
|
|
@@ -38,7 +38,7 @@ export declare function parseOutlineResponse(text: string, headings: readonly {
|
|
|
38
38
|
*/
|
|
39
39
|
export declare function applyOutline(tr: Transaction, headings: readonly OutlineHeading[], outline: readonly OutlineEntry[]): number;
|
|
40
40
|
/**
|
|
41
|
-
* „Gliederung bereinigen (KI)“: sends the headings of the whole document (task `outline-sanitize`, `generate`
|
|
41
|
+
* „Gliederung bereinigen (KI)“: sends the headings of the whole document (task `outline-sanitize`, `generate` Model role) and
|
|
42
42
|
* applies the model's repaired outline (levels without gaps, numbering and trailing punctuation gone, empty headings
|
|
43
43
|
* merged into the next) in one transaction. A malformed answer, or a document whose headings changed while the model
|
|
44
44
|
* ran, writes nothing and shows a notice. Notices go through `notify`, in the language of `t`.
|
|
@@ -75,7 +75,7 @@ function applyOutline(tr, headings, outline) {
|
|
|
75
75
|
return changed;
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
|
-
* „Gliederung bereinigen (KI)“: sends the headings of the whole document (task `outline-sanitize`, `generate`
|
|
78
|
+
* „Gliederung bereinigen (KI)“: sends the headings of the whole document (task `outline-sanitize`, `generate` Model role) and
|
|
79
79
|
* applies the model's repaired outline (levels without gaps, numbering and trailing punctuation gone, empty headings
|
|
80
80
|
* merged into the next) in one transaction. A malformed answer, or a document whose headings changed while the model
|
|
81
81
|
* ran, writes nothing and shows a notice. Notices go through `notify`, in the language of `t`.
|