@ecsplico/editor 3.5.1 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +71 -0
- package/dist/adapters/direct-ai.d.ts +4 -4
- package/dist/adapters/direct-ai.js +2 -2
- package/dist/adapters/direct-ai.js.map +1 -1
- package/dist/adapters/document-state.d.ts +1 -1
- package/dist/adapters/document-state.js.map +1 -1
- package/dist/adapters/forge.d.ts +2 -2
- package/dist/adapters/forge.js.map +1 -1
- package/dist/adapters/nitro.d.ts +11 -3
- package/dist/adapters/nitro.js +3 -1
- package/dist/adapters/nitro.js.map +1 -1
- package/dist/adapters/shared.d.ts +6 -6
- package/dist/adapters/shared.js.map +1 -1
- package/dist/code/CodeSurface.vue.d.ts +3 -3
- package/dist/config/index.d.ts +14 -14
- package/dist/config/index.js +8 -8
- package/dist/config/index.js.map +1 -1
- package/dist/core/backend-types.d.ts +3 -3
- package/dist/core/backend-types.js.map +1 -1
- package/dist/core/backend.d.ts +4 -4
- package/dist/core/backend.js.map +1 -1
- package/dist/core/block-convert.d.ts +1 -1
- package/dist/core/block-convert.js +5 -5
- package/dist/core/block-convert.js.map +1 -1
- package/dist/core/block-transfer.d.ts +8 -4
- package/dist/core/block-transfer.js +23 -14
- package/dist/core/block-transfer.js.map +1 -1
- package/dist/core/capabilities.d.ts +113 -0
- package/dist/core/capabilities.js +155 -0
- package/dist/core/capabilities.js.map +1 -0
- package/dist/core/command-types.d.ts +1 -1
- package/dist/core/context.js.map +1 -1
- package/dist/core/convert.d.ts +5 -5
- package/dist/core/convert.js +5 -5
- package/dist/core/convert.js.map +1 -1
- package/dist/core/core-feature.js +1 -1
- package/dist/core/define-editor.d.ts +2 -2
- package/dist/core/define-editor.js +34 -6
- package/dist/core/define-editor.js.map +1 -1
- package/dist/core/derivation.d.ts +119 -0
- package/dist/core/derivation.js +187 -0
- package/dist/core/derivation.js.map +1 -0
- package/dist/core/derive.d.ts +61 -0
- package/dist/core/derive.js +69 -0
- package/dist/core/derive.js.map +1 -0
- package/dist/core/extension-points.d.ts +16 -0
- package/dist/core/feature-context.d.ts +5 -1
- package/dist/core/feature-context.js +10 -3
- package/dist/core/feature-context.js.map +1 -1
- package/dist/core/feature.d.ts +41 -19
- package/dist/core/feature.js.map +1 -1
- package/dist/core/fences.js +1 -1
- package/dist/core/fences.js.map +1 -1
- package/dist/core/index.d.ts +6 -2
- package/dist/core/index.js +5 -1
- package/dist/core/pipeline.d.ts +14 -5
- package/dist/core/pipeline.js +19 -7
- package/dist/core/pipeline.js.map +1 -1
- package/dist/core/properties.d.ts +22 -0
- package/dist/core/properties.js +17 -0
- package/dist/core/properties.js.map +1 -0
- package/dist/core/schema/block-ids.js +5 -5
- package/dist/core/schema/block-ids.js.map +1 -1
- package/dist/core/schema/index.d.ts +2 -1
- package/dist/core/schema/index.js +2 -1
- package/dist/core/schema/index.js.map +1 -1
- package/dist/core/schema/opaque-fence.d.ts +4 -4
- package/dist/core/schema/opaque-fence.js +7 -7
- package/dist/core/schema/opaque-fence.js.map +1 -1
- package/dist/core/schema/persisted-names.d.ts +58 -0
- package/dist/core/schema/persisted-names.js +96 -0
- package/dist/core/schema/persisted-names.js.map +1 -0
- package/dist/core/toolbar-items.js +1 -1
- package/dist/core/toolbar-items.js.map +1 -1
- package/dist/core/util.js +5 -1
- package/dist/core/util.js.map +1 -1
- package/dist/document/DocumentSurface.vue.d.ts +3 -3
- package/dist/features/ai/agent-ops.js +1 -1
- package/dist/features/ai/ai-review.js +1 -1
- package/dist/features/ai/assistant.d.ts +4 -4
- package/dist/features/ai/assistant.js +1 -1
- package/dist/features/ai/assistant.js.map +1 -1
- package/dist/features/ai/components/AiSelectionMenu.js +1 -1
- package/dist/features/ai/components/AiSelectionMenu.js.map +1 -1
- package/dist/features/ai/components/ModelQuickSwitch.js +7 -7
- package/dist/features/ai/components/ModelQuickSwitch.js.map +1 -1
- package/dist/features/ai/components/ModelQuickSwitch.vue.d.ts +4 -4
- package/dist/features/ai/components/SettingsAiTab.js +8 -8
- package/dist/features/ai/components/SettingsAiTab.js.map +1 -1
- package/dist/features/ai/components/SettingsModelProfiles.js +1 -1
- package/dist/features/ai/components/SettingsModelProfiles.js.map +1 -1
- package/dist/features/ai/document-chat-model.d.ts +2 -2
- package/dist/features/ai/document-chat-model.js +5 -5
- package/dist/features/ai/document-chat-model.js.map +1 -1
- package/dist/features/ai/document-chat.js +2 -2
- package/dist/features/ai/document-chat.js.map +1 -1
- package/dist/features/ai/feature.d.ts +2 -2
- package/dist/features/ai/feature.js +2 -2
- package/dist/features/ai/feature.js.map +1 -1
- package/dist/features/ai/ghost-autocomplete.d.ts +4 -4
- package/dist/features/ai/ghost-autocomplete.js +1 -1
- package/dist/features/ai/ghost-autocomplete.js.map +1 -1
- package/dist/features/ai/index.d.ts +3 -3
- package/dist/features/ai/index.js +2 -2
- package/dist/features/ai/model-profiles.d.ts +9 -9
- package/dist/features/ai/model-profiles.js +13 -13
- package/dist/features/ai/model-profiles.js.map +1 -1
- package/dist/features/ai/protocol/agent-ops.d.ts +2 -2
- package/dist/features/ai/protocol/agent-ops.js +1 -1
- package/dist/features/ai/protocol/agent-ops.js.map +1 -1
- package/dist/features/ai/protocol/block-lines.d.ts +7 -7
- package/dist/features/ai/protocol/block-lines.js +10 -10
- package/dist/features/ai/protocol/block-lines.js.map +1 -1
- package/dist/features/ai/protocol/chat.d.ts +5 -5
- package/dist/features/ai/protocol/chat.js +12 -12
- package/dist/features/ai/protocol/chat.js.map +1 -1
- package/dist/features/ai/protocol/generate.d.ts +1 -1
- package/dist/features/ai/protocol/generate.js +1 -1
- package/dist/features/ai/protocol/generate.js.map +1 -1
- package/dist/features/ai/protocol/index.d.ts +3 -3
- package/dist/features/ai/protocol/index.js +2 -2
- package/dist/features/ai/protocol/models.d.ts +3 -3
- package/dist/features/ai/protocol/models.js +3 -3
- package/dist/features/ai/protocol/models.js.map +1 -1
- package/dist/features/ai/protocol/schemas.d.ts +1 -1
- package/dist/features/ai/protocol/schemas.js +1 -1
- package/dist/features/ai/protocol/schemas.js.map +1 -1
- package/dist/features/ai/protocol/tasks.d.ts +5 -5
- package/dist/features/ai/protocol/tasks.js +12 -12
- package/dist/features/ai/protocol/tasks.js.map +1 -1
- package/dist/features/ai/react/AiSelectionMenu.js.map +1 -1
- package/dist/features/ai/react/ModelQuickSwitch.d.ts +4 -4
- package/dist/features/ai/react/ModelQuickSwitch.js +6 -6
- package/dist/features/ai/react/ModelQuickSwitch.js.map +1 -1
- package/dist/features/ai/react/SettingsAiTab.d.ts +1 -1
- package/dist/features/ai/react/SettingsAiTab.js +8 -8
- package/dist/features/ai/react/SettingsAiTab.js.map +1 -1
- package/dist/features/ai/react/SettingsModelProfiles.d.ts +1 -1
- package/dist/features/ai/react/SettingsModelProfiles.js +1 -1
- package/dist/features/ai/react/SettingsModelProfiles.js.map +1 -1
- package/dist/features/ai/react/use-ai-assistant.d.ts +1 -1
- package/dist/features/ai/react/use-ai-assistant.js +1 -1
- package/dist/features/ai/react/use-ai-assistant.js.map +1 -1
- package/dist/features/ai/react/use-model-profiles.d.ts +5 -5
- package/dist/features/ai/react/use-model-profiles.js +2 -2
- package/dist/features/ai/react/use-model-profiles.js.map +1 -1
- package/dist/features/ai/use-ai-assistant.d.ts +1 -1
- package/dist/features/ai/use-ai-assistant.js +1 -1
- package/dist/features/ai/use-ai-assistant.js.map +1 -1
- package/dist/features/ai/use-model-profiles.d.ts +4 -4
- package/dist/features/ai/use-model-profiles.js +2 -2
- package/dist/features/ai/use-model-profiles.js.map +1 -1
- package/dist/features/block-ui/block-actions.d.ts +8 -4
- package/dist/features/block-ui/block-actions.js +38 -22
- package/dist/features/block-ui/block-actions.js.map +1 -1
- package/dist/features/block-ui/block-target.d.ts +29 -0
- package/dist/features/block-ui/block-target.js +63 -0
- package/dist/features/block-ui/block-target.js.map +1 -0
- package/dist/features/block-ui/components/BlockHandles.js +3 -3
- package/dist/features/block-ui/components/BlockHandles.js.map +1 -1
- package/dist/features/block-ui/components/BlockUi.js +11 -23
- package/dist/features/block-ui/components/BlockUi.js.map +1 -1
- package/dist/features/block-ui/feature.d.ts +3 -2
- package/dist/features/block-ui/feature.js +3 -2
- package/dist/features/block-ui/feature.js.map +1 -1
- package/dist/features/block-ui/handle-geometry.js +12 -23
- package/dist/features/block-ui/handle-geometry.js.map +1 -1
- package/dist/features/block-ui/index.d.ts +2 -1
- package/dist/features/block-ui/index.js +2 -1
- package/dist/features/block-ui/react/BlockHandles.d.ts +1 -1
- package/dist/features/block-ui/react/BlockHandles.js +4 -4
- package/dist/features/block-ui/react/BlockHandles.js.map +1 -1
- package/dist/features/block-ui/react/BlockUi.js +13 -25
- package/dist/features/block-ui/react/BlockUi.js.map +1 -1
- package/dist/features/comments/model.js +1 -1
- package/dist/features/composites/accepted-children.d.ts +5 -4
- package/dist/features/composites/accepted-children.js +26 -26
- package/dist/features/composites/accepted-children.js.map +1 -1
- package/dist/features/composites/ai-brief.d.ts +4 -4
- package/dist/features/composites/ai-brief.js +14 -12
- package/dist/features/composites/ai-brief.js.map +1 -1
- package/dist/features/composites/anchors.d.ts +1 -1
- package/dist/features/composites/anchors.js.map +1 -1
- package/dist/features/composites/baskets.d.ts +1 -1
- package/dist/features/composites/baskets.js.map +1 -1
- package/dist/features/composites/bibliography-command.d.ts +1 -1
- package/dist/features/composites/bibliography-form.js +1 -1
- package/dist/features/composites/bibliography-form.js.map +1 -1
- package/dist/features/composites/bibliography.js.map +1 -1
- package/dist/features/composites/block-types-json.d.ts +38 -0
- package/dist/features/composites/block-types-json.js +122 -0
- package/dist/features/composites/block-types-json.js.map +1 -0
- package/dist/features/composites/block-types.d.ts +119 -0
- package/dist/features/composites/block-types.js +343 -0
- package/dist/features/composites/block-types.js.map +1 -0
- package/dist/features/composites/capabilities.js +109 -0
- package/dist/features/composites/capabilities.js.map +1 -0
- package/dist/features/composites/components/BibliographyEditor.js +5 -5
- package/dist/features/composites/components/BibliographyEditor.js.map +1 -1
- package/dist/features/composites/components/CompositeBasketMenu.js +2 -2
- package/dist/features/composites/components/CompositeBasketMenu.js.map +1 -1
- package/dist/features/composites/components/CompositeChrome.js +18 -8
- package/dist/features/composites/components/CompositeChrome.js.map +1 -1
- package/dist/features/composites/components/CompositeChrome.vue.d.ts +1 -1
- package/dist/features/composites/components/CompositeDetails.js +11 -10
- package/dist/features/composites/components/CompositeDetails.js.map +1 -1
- package/dist/features/composites/components/CompositeDetails.vue.d.ts +1 -1
- package/dist/features/composites/components/CompositeFieldEditor.js +7 -7
- package/dist/features/composites/components/CompositeFieldEditor.js.map +1 -1
- package/dist/features/composites/components/CompositeFieldEditor.vue.d.ts +5 -5
- package/dist/features/composites/components/CompositeInspector.js +136 -113
- package/dist/features/composites/components/CompositeInspector.js.map +1 -1
- package/dist/features/composites/components/CompositeInspector.vue.d.ts +3 -3
- package/dist/features/composites/components/CompositeStatusMenu.js +2 -2
- package/dist/features/composites/components/CompositeStatusMenu.js.map +1 -1
- package/dist/features/composites/components/CompositeSummaryEditor.js +1 -1
- package/dist/features/composites/components/CompositeSummaryEditor.js.map +1 -1
- package/dist/features/composites/components/CompositeSummaryEditor.vue.d.ts +1 -1
- package/dist/features/composites/components/CompositeTable.js +2 -2
- package/dist/features/composites/components/CompositeTable.js.map +1 -1
- package/dist/features/composites/components/CompositeTagsEditor.js +1 -1
- package/dist/features/composites/components/CompositeTagsEditor.js.map +1 -1
- package/dist/features/composites/components/CompositeTagsEditor.vue.d.ts +1 -1
- package/dist/features/composites/components/CompositeView.js +19 -17
- package/dist/features/composites/components/CompositeView.js.map +1 -1
- package/dist/features/composites/components/DerivationBadge.js +15 -6
- package/dist/features/composites/components/DerivationBadge.js.map +1 -1
- package/dist/features/composites/components/FocusChip.js +1 -1
- package/dist/features/composites/components/FocusChip.js.map +1 -1
- package/dist/features/composites/components/FocusChip.vue.d.ts +1 -1
- package/dist/features/composites/components/ReferenceFieldSelect.js +3 -3
- package/dist/features/composites/components/ReferenceFieldSelect.js.map +1 -1
- package/dist/features/composites/components/ReferenceView.js +1 -1
- package/dist/features/composites/components/ReferenceView.js.map +1 -1
- package/dist/features/composites/components/SettingsEditingTab.js +18 -18
- package/dist/features/composites/components/SettingsEditingTab.js.map +1 -1
- package/dist/features/composites/components/SettingsEditingTab.vue.d.ts +3 -3
- package/dist/features/composites/convert.d.ts +4 -4
- package/dist/features/composites/convert.js +27 -28
- package/dist/features/composites/convert.js.map +1 -1
- package/dist/features/composites/derived-chrome.js +34 -28
- package/dist/features/composites/derived-chrome.js.map +1 -1
- package/dist/features/composites/editing-settings-keys.js +6 -6
- package/dist/features/composites/editing-settings-keys.js.map +1 -1
- package/dist/features/composites/feature.d.ts +10 -10
- package/dist/features/composites/feature.js +58 -46
- package/dist/features/composites/feature.js.map +1 -1
- package/dist/features/composites/fences.d.ts +3 -3
- package/dist/features/composites/fences.js +18 -13
- package/dist/features/composites/fences.js.map +1 -1
- package/dist/features/composites/focus.d.ts +10 -10
- package/dist/features/composites/focus.js +11 -11
- package/dist/features/composites/focus.js.map +1 -1
- package/dist/features/composites/heading-composites.d.ts +5 -5
- package/dist/features/composites/heading-composites.js +13 -16
- package/dist/features/composites/heading-composites.js.map +1 -1
- package/dist/features/composites/index.d.ts +20 -18
- package/dist/features/composites/index.js +9 -7
- package/dist/features/composites/inspector-model.d.ts +45 -22
- package/dist/features/composites/inspector-model.js +53 -14
- package/dist/features/composites/inspector-model.js.map +1 -1
- package/dist/features/composites/legacy.d.ts +5 -4
- package/dist/features/composites/legacy.js +16 -23
- package/dist/features/composites/legacy.js.map +1 -1
- package/dist/features/composites/markdown-export.js +3 -3
- package/dist/features/composites/markdown-export.js.map +1 -1
- package/dist/features/composites/merge.d.ts +8 -7
- package/dist/features/composites/merge.js +39 -12
- package/dist/features/composites/merge.js.map +1 -1
- package/dist/features/composites/meta-display.js +5 -5
- package/dist/features/composites/meta-display.js.map +1 -1
- package/dist/features/composites/meta-keys.d.ts +5 -5
- package/dist/features/composites/meta-keys.js +8 -8
- package/dist/features/composites/meta-keys.js.map +1 -1
- package/dist/features/composites/node-views.d.ts +3 -3
- package/dist/features/composites/node-views.js +2 -2
- package/dist/features/composites/node-views.js.map +1 -1
- package/dist/features/composites/nodes.d.ts +13 -13
- package/dist/features/composites/nodes.js +100 -77
- package/dist/features/composites/nodes.js.map +1 -1
- package/dist/features/composites/outline.d.ts +15 -12
- package/dist/features/composites/outline.js +24 -21
- package/dist/features/composites/outline.js.map +1 -1
- package/dist/features/composites/properties.d.ts +51 -0
- package/dist/features/composites/properties.js +89 -0
- package/dist/features/composites/properties.js.map +1 -0
- package/dist/features/composites/react/BibliographyEditor.js +5 -5
- package/dist/features/composites/react/BibliographyEditor.js.map +1 -1
- package/dist/features/composites/react/CompositeBasketMenu.js +2 -2
- package/dist/features/composites/react/CompositeBasketMenu.js.map +1 -1
- package/dist/features/composites/react/CompositeChrome.d.ts +1 -1
- package/dist/features/composites/react/CompositeChrome.js +15 -6
- package/dist/features/composites/react/CompositeChrome.js.map +1 -1
- package/dist/features/composites/react/CompositeDetails.d.ts +1 -1
- package/dist/features/composites/react/CompositeDetails.js +11 -10
- package/dist/features/composites/react/CompositeDetails.js.map +1 -1
- package/dist/features/composites/react/CompositeFieldEditor.d.ts +5 -5
- package/dist/features/composites/react/CompositeFieldEditor.js +6 -6
- package/dist/features/composites/react/CompositeFieldEditor.js.map +1 -1
- package/dist/features/composites/react/CompositeInspector.d.ts +3 -3
- package/dist/features/composites/react/CompositeInspector.js +142 -128
- package/dist/features/composites/react/CompositeInspector.js.map +1 -1
- package/dist/features/composites/react/CompositeStatusMenu.js +2 -2
- package/dist/features/composites/react/CompositeStatusMenu.js.map +1 -1
- package/dist/features/composites/react/CompositeSummaryEditor.d.ts +1 -1
- package/dist/features/composites/react/CompositeSummaryEditor.js +1 -1
- package/dist/features/composites/react/CompositeSummaryEditor.js.map +1 -1
- package/dist/features/composites/react/CompositeTable.d.ts +1 -1
- package/dist/features/composites/react/CompositeTable.js +3 -3
- package/dist/features/composites/react/CompositeTable.js.map +1 -1
- package/dist/features/composites/react/CompositeTagsEditor.d.ts +1 -1
- package/dist/features/composites/react/CompositeTagsEditor.js +1 -1
- package/dist/features/composites/react/CompositeTagsEditor.js.map +1 -1
- package/dist/features/composites/react/CompositeView.js +17 -15
- package/dist/features/composites/react/CompositeView.js.map +1 -1
- package/dist/features/composites/react/DerivationBadge.js +13 -4
- package/dist/features/composites/react/DerivationBadge.js.map +1 -1
- package/dist/features/composites/react/FocusChip.d.ts +1 -1
- package/dist/features/composites/react/FocusChip.js +1 -1
- package/dist/features/composites/react/FocusChip.js.map +1 -1
- package/dist/features/composites/react/ReferenceFieldSelect.js +3 -3
- package/dist/features/composites/react/ReferenceFieldSelect.js.map +1 -1
- package/dist/features/composites/react/ReferenceView.d.ts +1 -1
- package/dist/features/composites/react/ReferenceView.js +1 -1
- package/dist/features/composites/react/ReferenceView.js.map +1 -1
- package/dist/features/composites/react/SettingsEditingTab.d.ts +4 -4
- package/dist/features/composites/react/SettingsEditingTab.js +20 -20
- package/dist/features/composites/react/SettingsEditingTab.js.map +1 -1
- package/dist/features/composites/react.js +1 -1
- package/dist/features/composites/react.js.map +1 -1
- package/dist/features/composites/reference-ai.js +1 -1
- package/dist/features/composites/reference-ai.js.map +1 -1
- package/dist/features/composites/reference-label.d.ts +3 -3
- package/dist/features/composites/reference-label.js +6 -6
- package/dist/features/composites/reference-label.js.map +1 -1
- package/dist/features/composites/reference-suggestion.d.ts +1 -1
- package/dist/features/composites/reference-suggestion.js +3 -3
- package/dist/features/composites/reference-suggestion.js.map +1 -1
- package/dist/features/composites/reference-text.d.ts +2 -2
- package/dist/features/composites/reference-text.js +4 -4
- package/dist/features/composites/reference-text.js.map +1 -1
- package/dist/features/composites/reference.d.ts +3 -3
- package/dist/features/composites/reference.js +1 -1
- package/dist/features/composites/reference.js.map +1 -1
- package/dist/features/composites/reveal-source.d.ts +3 -3
- package/dist/features/composites/reveal-source.js +6 -6
- package/dist/features/composites/reveal-source.js.map +1 -1
- package/dist/features/composites/rows-model.d.ts +2 -2
- package/dist/features/composites/rows-model.js +4 -3
- package/dist/features/composites/rows-model.js.map +1 -1
- package/dist/features/composites/rows.d.ts +16 -28
- package/dist/features/composites/rows.js +20 -54
- package/dist/features/composites/rows.js.map +1 -1
- package/dist/features/composites/schema.d.ts +12 -11
- package/dist/features/composites/schema.js +10 -9
- package/dist/features/composites/schema.js.map +1 -1
- package/dist/features/composites/source.d.ts +20 -0
- package/dist/features/composites/source.js +40 -0
- package/dist/features/composites/source.js.map +1 -0
- package/dist/features/composites/split.d.ts +11 -11
- package/dist/features/composites/split.js +20 -20
- package/dist/features/composites/split.js.map +1 -1
- package/dist/features/composites/structure-mode.js +3 -3
- package/dist/features/composites/structure-mode.js.map +1 -1
- package/dist/features/composites/table-model.js +2 -2
- package/dist/features/composites/table-model.js.map +1 -1
- package/dist/features/composites/use-composite-inspector.js +3 -1
- package/dist/features/composites/use-composite-inspector.js.map +1 -1
- package/dist/features/composites/use-composite-rows.d.ts +2 -2
- package/dist/features/composites/use-composite-rows.js.map +1 -1
- package/dist/features/composites/vue.js +1 -1
- package/dist/features/composites/vue.js.map +1 -1
- package/dist/features/image-studio/components/ImageStudioDialog.js +1 -1
- package/dist/features/image-studio/components/ImageStudioDialog.js.map +1 -1
- package/dist/features/image-studio/components/ImageStudioDialog.vue.d.ts +1 -1
- package/dist/features/image-studio/components/ImageStudioView.js.map +1 -1
- package/dist/features/image-studio/feature.d.ts +1 -1
- package/dist/features/image-studio/feature.js +1 -1
- package/dist/features/image-studio/feature.js.map +1 -1
- package/dist/features/image-studio/node-core.d.ts +3 -3
- package/dist/features/image-studio/node-core.js +1 -1
- package/dist/features/image-studio/node-core.js.map +1 -1
- package/dist/features/image-studio/node-store.d.ts +1 -1
- package/dist/features/image-studio/node-store.js +1 -1
- package/dist/features/image-studio/node-store.js.map +1 -1
- package/dist/features/image-studio/react/ImageStudioDialog.d.ts +1 -1
- package/dist/features/image-studio/react/ImageStudioDialog.js +1 -1
- package/dist/features/image-studio/react/ImageStudioDialog.js.map +1 -1
- package/dist/features/image-studio/react/ImageStudioView.js +1 -1
- package/dist/features/image-studio/react/ImageStudioView.js.map +1 -1
- package/dist/features/image-studio/react/store.d.ts +3 -3
- package/dist/features/image-studio/react/store.js.map +1 -1
- package/dist/features/image-studio/react.d.ts +1 -1
- package/dist/features/image-studio/react.js +1 -1
- package/dist/features/image-studio/react.js.map +1 -1
- package/dist/features/image-studio/schema.d.ts +1 -1
- package/dist/features/image-studio/schema.js +1 -1
- package/dist/features/image-studio/schema.js.map +1 -1
- package/dist/features/image-studio/state.d.ts +3 -3
- package/dist/features/image-studio/state.js +2 -2
- package/dist/features/image-studio/state.js.map +1 -1
- package/dist/features/image-studio/store.d.ts +3 -3
- package/dist/features/image-studio/vue.d.ts +1 -1
- package/dist/features/image-studio/vue.js +1 -1
- package/dist/features/image-studio/vue.js.map +1 -1
- package/dist/features/media/index.js +1 -1
- package/dist/features/media/react/AudioRecorderModal.js +1 -1
- package/dist/features/media/react.js +1 -1
- package/dist/features/mentions/tag.js +2 -1
- package/dist/features/mentions/tag.js.map +1 -1
- package/dist/features/themes/components/SettingsAppearanceTab.js +1 -1
- package/dist/features/themes/components/SettingsAppearanceTab.js.map +1 -1
- package/dist/features/themes/feature.d.ts +1 -1
- package/dist/features/themes/feature.js.map +1 -1
- package/dist/features/themes/react/SettingsAppearanceTab.d.ts +1 -1
- package/dist/features/themes/react/SettingsAppearanceTab.js +1 -1
- package/dist/features/themes/react/SettingsAppearanceTab.js.map +1 -1
- package/dist/features/themes/theme-runtime.js +1 -1
- package/dist/features/themes/theme-runtime.js.map +1 -1
- package/dist/features/transcript/TranscriptSegmentView.js +1 -1
- package/dist/features/transcript/TranscriptSegmentView.js.map +1 -1
- package/dist/features/transcript/react/TranscriptSegmentView.js +1 -1
- package/dist/features/transcript/react/TranscriptSegmentView.js.map +1 -1
- package/dist/features/transcript/segment-node.js.map +1 -1
- package/dist/features/transfer/feature.js +1 -1
- package/dist/features/transfer/feature.js.map +1 -1
- package/dist/features/transfer/transforms.d.ts +4 -4
- package/dist/features/transfer/transforms.js +12 -12
- package/dist/features/transfer/transforms.js.map +1 -1
- package/dist/i18n/de/ai.js +4 -4
- package/dist/i18n/de/ai.js.map +1 -1
- package/dist/i18n/de/authors.js +1 -1
- package/dist/i18n/de/authors.js.map +1 -1
- package/dist/i18n/de/comments.js +1 -1
- package/dist/i18n/de/comments.js.map +1 -1
- package/dist/i18n/de/composites.js +62 -59
- package/dist/i18n/de/composites.js.map +1 -1
- package/dist/i18n/de/image-studio.js +2 -2
- package/dist/i18n/de/image-studio.js.map +1 -1
- package/dist/i18n/de/integrations.js +20 -20
- package/dist/i18n/de/integrations.js.map +1 -1
- package/dist/i18n/de/markdown.js +1 -1
- package/dist/i18n/de/markdown.js.map +1 -1
- package/dist/i18n/de/palette.js +1 -1
- package/dist/i18n/de/palette.js.map +1 -1
- package/dist/i18n/de/themes.js +3 -3
- package/dist/i18n/de/themes.js.map +1 -1
- package/dist/i18n/de/transfer.js +2 -2
- package/dist/i18n/de/transfer.js.map +1 -1
- package/dist/i18n/de/tree.js +6 -6
- package/dist/i18n/de/tree.js.map +1 -1
- package/dist/i18n/de.d.ts +101 -98
- package/dist/i18n/en/ai.js +2 -2
- package/dist/i18n/en/ai.js.map +1 -1
- package/dist/i18n/en/composites.js +64 -61
- package/dist/i18n/en/composites.js.map +1 -1
- package/dist/i18n/en/integrations.js +9 -9
- package/dist/i18n/en/integrations.js.map +1 -1
- package/dist/i18n/en/markdown.js +1 -1
- package/dist/i18n/en/markdown.js.map +1 -1
- package/dist/i18n/en/palette.js +1 -1
- package/dist/i18n/en/palette.js.map +1 -1
- package/dist/i18n/en/themes.js +4 -4
- package/dist/i18n/en/themes.js.map +1 -1
- package/dist/i18n/en/tree.js +5 -5
- package/dist/i18n/en/tree.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/integrations/composite-ai/bibliography-fetch.d.ts +6 -6
- package/dist/integrations/composite-ai/bibliography-fetch.js +19 -19
- package/dist/integrations/composite-ai/bibliography-fetch.js.map +1 -1
- package/dist/integrations/composite-ai/composite-fill.d.ts +4 -4
- package/dist/integrations/composite-ai/composite-fill.js +5 -5
- package/dist/integrations/composite-ai/composite-fill.js.map +1 -1
- package/dist/integrations/composite-ai/composite-summary.d.ts +2 -2
- package/dist/integrations/composite-ai/composite-summary.js +5 -5
- package/dist/integrations/composite-ai/composite-summary.js.map +1 -1
- package/dist/integrations/composite-ai/derive.d.ts +17 -17
- package/dist/integrations/composite-ai/derive.js +27 -26
- package/dist/integrations/composite-ai/derive.js.map +1 -1
- package/dist/integrations/composite-ai/index.d.ts +14 -15
- package/dist/integrations/composite-ai/index.js +98 -77
- package/dist/integrations/composite-ai/index.js.map +1 -1
- package/dist/integrations/composite-ai/outline-sanitize.d.ts +1 -1
- package/dist/integrations/composite-ai/outline-sanitize.js +1 -1
- package/dist/integrations/composite-ai/outline-sanitize.js.map +1 -1
- package/dist/integrations/composite-ai/rendition.d.ts +9 -9
- package/dist/integrations/composite-ai/rendition.js +27 -27
- package/dist/integrations/composite-ai/rendition.js.map +1 -1
- package/dist/integrations/composite-ai/split.d.ts +8 -8
- package/dist/integrations/composite-ai/split.js +12 -12
- package/dist/integrations/composite-ai/split.js.map +1 -1
- package/dist/integrations/composite-ai/transfer-transforms.d.ts +2 -2
- package/dist/integrations/composite-ai/transfer-transforms.js +12 -12
- package/dist/integrations/composite-ai/transfer-transforms.js.map +1 -1
- package/dist/integrations/composite-media/index.d.ts +4 -3
- package/dist/integrations/composite-media/index.js +20 -14
- package/dist/integrations/composite-media/index.js.map +1 -1
- package/dist/markdown/MarkdownSurface.vue.d.ts +7 -7
- package/dist/markdown/document.js +1 -1
- package/dist/markdown/document.js.map +1 -1
- package/dist/nuxt/module.d.ts +30 -24
- package/dist/nuxt/module.js.map +1 -1
- package/dist/nuxt/runtime/server/plugins/editor-server.js +3 -2
- package/dist/nuxt/runtime/server/plugins/editor-server.js.map +1 -1
- package/dist/presets/compose.d.ts +6 -6
- package/dist/presets/compose.js +8 -5
- package/dist/presets/compose.js.map +1 -1
- package/dist/react/AdvancedEditor.d.ts +2 -2
- package/dist/react/AdvancedEditor.js +1 -1
- package/dist/react/AdvancedEditor.js.map +1 -1
- package/dist/react/compose.d.ts +1 -1
- package/dist/react/compose.js +2 -2
- package/dist/react/compose.js.map +1 -1
- package/dist/react/composed-surface.d.ts +5 -5
- package/dist/react/composed-surface.js +2 -2
- package/dist/react/composed-surface.js.map +1 -1
- package/dist/server/ai.d.ts +7 -7
- package/dist/server/ai.js +1 -1
- package/dist/server/ai.js.map +1 -1
- package/dist/server/auth.d.ts +1 -1
- package/dist/server/collab-state.d.ts +1 -1
- package/dist/server/collab-state.js.map +1 -1
- package/dist/server/collab.d.ts +4 -4
- package/dist/server/collab.js +22 -17
- package/dist/server/collab.js.map +1 -1
- package/dist/server/handlers/ai.d.ts +9 -6
- package/dist/server/handlers/ai.js +13 -17
- package/dist/server/handlers/ai.js.map +1 -1
- package/dist/server/handlers/context.d.ts +4 -0
- package/dist/server/handlers/context.js.map +1 -1
- package/dist/server/handlers/editor.d.ts +33 -32
- package/dist/server/handlers/editor.js +13 -8
- package/dist/server/handlers/editor.js.map +1 -1
- package/dist/server/handlers/images.d.ts +1 -1
- package/dist/server/handlers/images.js +1 -1
- package/dist/server/handlers/images.js.map +1 -1
- package/dist/server/host.d.ts +4 -0
- package/dist/server/host.js +10 -2
- package/dist/server/host.js.map +1 -1
- package/dist/server/index.d.ts +3 -3
- package/dist/server/ports.d.ts +8 -8
- package/dist/server/ports.js.map +1 -1
- package/dist/settings/index.d.ts +20 -19
- package/dist/settings/index.js +25 -24
- package/dist/settings/index.js.map +1 -1
- package/dist/settings/migrate.d.ts +18 -0
- package/dist/settings/migrate.js +46 -0
- package/dist/settings/migrate.js.map +1 -0
- package/dist/settings/values.d.ts +12 -12
- package/dist/settings/values.js +11 -11
- package/dist/settings/values.js.map +1 -1
- package/dist/styles/composites.css +10 -10
- package/dist/tree/DocumentTree.js +12 -5
- package/dist/tree/DocumentTree.js.map +1 -1
- package/dist/tree/drop-rules.js +5 -5
- package/dist/tree/drop-rules.js.map +1 -1
- package/dist/tree/react/DocumentTree.js +14 -5
- package/dist/tree/react/DocumentTree.js.map +1 -1
- package/dist/tree/tree-host.js +6 -6
- package/dist/tree/tree-host.js.map +1 -1
- package/dist/tree/tree-items.js +34 -28
- package/dist/tree/tree-items.js.map +1 -1
- package/dist/tree/tree-model.js +16 -16
- package/dist/tree/tree-model.js.map +1 -1
- package/dist/tree/tree-rows.js +2 -2
- package/dist/tree/tree-rows.js.map +1 -1
- package/dist/tree/tree-view-model.d.ts +2 -2
- package/dist/tree/tree-view-model.js.map +1 -1
- package/dist/vue/AdvancedEditor.js +2 -2
- package/dist/vue/AdvancedEditor.js.map +1 -1
- package/dist/vue/AdvancedEditor.vue.d.ts +10 -10
- package/dist/vue/SimpleEditor.vue.d.ts +4 -4
- package/dist/vue/components/EditorSurface.vue.d.ts +4 -4
- package/dist/vue/compose.d.ts +1 -1
- package/dist/vue/compose.js +2 -2
- package/dist/vue/compose.js.map +1 -1
- package/package.json +1 -1
- package/dist/features/composites/derivation.d.ts +0 -62
- package/dist/features/composites/derivation.js +0 -102
- package/dist/features/composites/derivation.js.map +0 -1
- package/dist/features/composites/kinds.d.ts +0 -83
- package/dist/features/composites/kinds.js +0 -285
- package/dist/features/composites/kinds.js.map +0 -1
|
@@ -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,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;AAEA,SAAS,mBAAmB,KAAoC;CAC9D,MAAM,KAAK,IAAI,QAAQ;CAEvB,IAAI,CAAC,IAAI,OAAO,CAAC;CACjB,OAAO;EACL;GACE,IAAI;GACJ,OAAO,IAAI,EAAE,mCAAmC;GAChD,MAAM;GACN,SAAS,QAAQ;GACjB,OAAO;GACP,YAAY,EAAE,QAAQ,WAAW,KAAK,KAAK,SAAS,eAAe,cAAc,iBAAiB,MAAM,GAAG,OAAO,KAAK,MAAM,IAAI,CAAC,CAAC,CAAC,OAAO,KAAA;GAC3I,MAAM,EAAE,QAAQ,UAAU;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,IAAI,cAAc,IAAI,GAAG,CAAC,CAAC,UAAU,IAAI,QAAQ,IAAI,CAAC;GACrF;EACF;CACF;AACF;;AAGA,SAAS,oBAAoB,KAA0C;CACrE,MAAM,KAAK,IAAI,QAAQ;CACvB,IAAI,CAAC,IAAI,OAAO,CAAC;CACjB,OAAO,CAAC;EACN,IAAI;EACJ,OAAO,IAAI,EAAE,oCAAoC;EACjD,MAAM;EACN,SAAS;EACT,MAAM,WAAW;GACf,gBAAqB,QAAQ,IAAI,cAAc,IAAI,GAAG,CAAC,CAAC,UAAU,IAAI,QAAQ,IAAI,CAAC;EACrF;CACF,CAAC;AACH;;;;;;;;;;;;;;;;AAiBA,SAAgB,qBAA2C;CACzD,OAAO;EACL,IAAI;EACJ,WAAW;EACX,UAAU;GAAC;GAAc;GAAM;EAAO;EACtC,cAAc;EACd,YAAY;EACZ,UAAU;EACV,iBAAiB,QAAQ,UAAU,YAAY;GAC7C,IAAI,CAAC,SAAS,OAAO;GACrB,MAAM,OAAO,YAAY,SAAS,QAAQ;GAC1C,OAAO,YAAY,MAAM,MAAM,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,2BAA2C;CAClD,OAAO;EACL;GACE,IAAI;GACJ,QAAO,QAAO,IAAI,EAAE,mCAAmC;GACvD,MAAM;GACN,SAAS,QAAQ;GACjB,OAAO;GACP,UAAU,CAAC,UAAU;GACrB,WAAW;GACX,KAAK,QAAQ,EAAE,QAAQ,KAAK,OAAO,OAAO;IACxC,cAAmB,QAAQ,KAAK,IAAI,cAAc,IAAI,GAAG,CAAC,CAAC,UAAU,IAAI,QAAQ,IAAI,CAAC;GACxF,CAAC;EACH;EACA;GACE,IAAI;GACJ,QAAO,QAAO,IAAI,EAAE,sCAAsC;GAC1D,MAAM;GACN,SAAS,QAAQ;GACjB,OAAO;GACP,UAAU,CAAC,aAAa,OAAO;GAC/B,YAAW,QAAO,MAAM,GAAG,KAAK,oBAAoB,IAAI,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,SAAS;GAC9E,KAAK,QAAQ,EAAE,Q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OAAO;IAAkB,kBAAkB,OAAO;GAAiB,CAAC;EAC1L;CACF,EAAE,GACF;EACE,IAAI;EACJ,OAAO,IAAI,EAAE,oCAAoC;EACjD,MAAM;EACN,SAAS,QAAQ;EACjB,OAAO;EACP,YAAY,EAAE,WAAW,KAAK,KAAK,SAAS;EAC5C,MAAM,EAAE,aAAa;GACnB,gBAAqB,QAAQ,IAAI,cAAc,IAAI,GAAG,CAAC,CAAC,UAAU,IAAI,QAAQ,IAAI,CAAC;EACrF;CACF,CACF;AACF;;AAGA,SAAS,oBAAoB,KAA0C;CACrE,MAAM,KAAK,IAAI,QAAQ;CACvB,IAAI,CAAC,IAAI,OAAO,CAAC;CACjB,OAAO,CAAC;EACN,IAAI;EACJ,OAAO,IAAI,EAAE,oCAAoC;EACjD,MAAM;EACN,SAAS;EACT,MAAM,WAAW;GACf,gBAAqB,QAAQ,IAAI,cAAc,IAAI,GAAG,CAAC,CAAC,UAAU,IAAI,QAAQ,IAAI,CAAC;EACrF;CACF,CAAC;AACH;;;;;;;;;;;;;;;AAgBA,SAAgB,qBAA2C;CACzD,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`.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outline-sanitize.js","names":[],"sources":["../../../src/integrations/composite-ai/outline-sanitize.ts"],"sourcesContent":["import type { Editor } from '@tiptap/core'\nimport type { Node as PMNode } from '@tiptap/pm/model'\nimport type { Transaction } from '@tiptap/pm/state'\nimport type { EditorBackend } from '../../core/backend'\nimport type { Notifier } from '../../core/notify'\nimport type { Translate } from '../../i18n'\nimport { AI_LIMITS, type ModelRef, notifyAiRateLimited, postAiSse } from '../../features/ai'\nimport { headingGroupRange } from '../../features/composites/schema'\n\n/** A heading of the document as the model sees it, plus where it is: `i` is its index in document order, `chars` the text length of the blocks under it up to the next heading of the same or a higher level. */\nexport interface OutlineHeading { i: number, level: number, text: string, chars: number, pos: number }\n\n/** The model's answer for one heading: its level and text (empty: the heading is removed). */\nexport interface OutlineEntry { i: number, level: number, text: string }\n\n/** Every `heading` node of `doc` (any depth, document order). */\nexport function collectHeadings(doc: PMNode): OutlineHeading[] {\n const headings: OutlineHeading[] = []\n doc.descendants((node, pos, parent, index) => {\n if (node.type.name !== 'heading' || !parent) return\n const { to } = headingGroupRange(parent, index)\n let chars = 0\n for (let sibling = index + 1; sibling < to; sibling++) chars += parent.child(sibling).textContent.length\n headings.push({ i: headings.length, level: node.attrs.level as number, text: node.textContent, chars, pos })\n })\n return headings\n}\n\n/**\n * The model's answer as one entry per heading, or `null` when it is not exactly that: a JSON list (a Markdown code\n * fence around it is tolerated) of the same length as `headings`, `i` equal to the position, `level` an integer 1..6,\n * `text` a string.\n */\nexport function parseOutlineResponse(text: string, headings: readonly { i: number }[]): OutlineEntry[] | null {\n let parsed: unknown\n try {\n parsed = JSON.parse(text.trim().replace(/^```(?:json)?\\s*/i, '').replace(/\\s*```$/, ''))\n }\n catch {\n return null\n }\n if (!Array.isArray(parsed) || parsed.length !== headings.length) return null\n const entries: OutlineEntry[] = []\n for (const [index, item] of parsed.entries()) {\n const { i, level, text: value } = (item ?? {}) as Partial<Record<'i' | 'level' | 'text', unknown>>\n if (i !== index || typeof level !== 'number' || !Number.isInteger(level) || level < 1 || level > 6 || typeof value !== 'string') return null\n entries.push({ i, level, text: value.trim() })\n }\n return entries\n}\n\n/**\n * Writes `outline` into `tr` for the `headings` collected from `tr.doc` (so far unchanged): an empty text removes the\n * heading, otherwise its level and, when it differs, its text (as plain text) are set. Runs from the last heading to\n * the first, so the positions of the earlier ones stay valid. Returns how many headings changed.\n */\nexport function applyOutline(tr: Transaction, headings: readonly OutlineHeading[], outline: readonly OutlineEntry[]): number {\n let changed = 0\n for (let index = headings.length - 1; index >= 0; index--) {\n const { pos } = headings[index]!\n const { level, text } = outline[index]!\n const node = tr.doc.nodeAt(pos)\n if (node?.type.name !== 'heading') continue\n if (!text) {\n tr.delete(pos, pos + node.nodeSize)\n changed++\n continue\n }\n const retext = text !== node.textContent\n if (!retext && level === node.attrs.level) continue\n if (level !== node.attrs.level) tr.setNodeMarkup(pos, undefined, { ...node.attrs, level })\n if (retext) tr.replaceWith(pos + 1, pos + 1 + node.content.size, tr.doc.type.schema.text(text))\n changed++\n }\n return changed\n}\n\n/**\n * „Gliederung bereinigen (KI)“: sends the headings of the whole document (task `outline-sanitize`, `generate`
|
|
1
|
+
{"version":3,"file":"outline-sanitize.js","names":[],"sources":["../../../src/integrations/composite-ai/outline-sanitize.ts"],"sourcesContent":["import type { Editor } from '@tiptap/core'\nimport type { Node as PMNode } from '@tiptap/pm/model'\nimport type { Transaction } from '@tiptap/pm/state'\nimport type { EditorBackend } from '../../core/backend'\nimport type { Notifier } from '../../core/notify'\nimport type { Translate } from '../../i18n'\nimport { AI_LIMITS, type ModelRef, notifyAiRateLimited, postAiSse } from '../../features/ai'\nimport { headingGroupRange } from '../../features/composites/schema'\n\n/** A heading of the document as the model sees it, plus where it is: `i` is its index in document order, `chars` the text length of the blocks under it up to the next heading of the same or a higher level. */\nexport interface OutlineHeading { i: number, level: number, text: string, chars: number, pos: number }\n\n/** The model's answer for one heading: its level and text (empty: the heading is removed). */\nexport interface OutlineEntry { i: number, level: number, text: string }\n\n/** Every `heading` node of `doc` (any depth, document order). */\nexport function collectHeadings(doc: PMNode): OutlineHeading[] {\n const headings: OutlineHeading[] = []\n doc.descendants((node, pos, parent, index) => {\n if (node.type.name !== 'heading' || !parent) return\n const { to } = headingGroupRange(parent, index)\n let chars = 0\n for (let sibling = index + 1; sibling < to; sibling++) chars += parent.child(sibling).textContent.length\n headings.push({ i: headings.length, level: node.attrs.level as number, text: node.textContent, chars, pos })\n })\n return headings\n}\n\n/**\n * The model's answer as one entry per heading, or `null` when it is not exactly that: a JSON list (a Markdown code\n * fence around it is tolerated) of the same length as `headings`, `i` equal to the position, `level` an integer 1..6,\n * `text` a string.\n */\nexport function parseOutlineResponse(text: string, headings: readonly { i: number }[]): OutlineEntry[] | null {\n let parsed: unknown\n try {\n parsed = JSON.parse(text.trim().replace(/^```(?:json)?\\s*/i, '').replace(/\\s*```$/, ''))\n }\n catch {\n return null\n }\n if (!Array.isArray(parsed) || parsed.length !== headings.length) return null\n const entries: OutlineEntry[] = []\n for (const [index, item] of parsed.entries()) {\n const { i, level, text: value } = (item ?? {}) as Partial<Record<'i' | 'level' | 'text', unknown>>\n if (i !== index || typeof level !== 'number' || !Number.isInteger(level) || level < 1 || level > 6 || typeof value !== 'string') return null\n entries.push({ i, level, text: value.trim() })\n }\n return entries\n}\n\n/**\n * Writes `outline` into `tr` for the `headings` collected from `tr.doc` (so far unchanged): an empty text removes the\n * heading, otherwise its level and, when it differs, its text (as plain text) are set. Runs from the last heading to\n * the first, so the positions of the earlier ones stay valid. Returns how many headings changed.\n */\nexport function applyOutline(tr: Transaction, headings: readonly OutlineHeading[], outline: readonly OutlineEntry[]): number {\n let changed = 0\n for (let index = headings.length - 1; index >= 0; index--) {\n const { pos } = headings[index]!\n const { level, text } = outline[index]!\n const node = tr.doc.nodeAt(pos)\n if (node?.type.name !== 'heading') continue\n if (!text) {\n tr.delete(pos, pos + node.nodeSize)\n changed++\n continue\n }\n const retext = text !== node.textContent\n if (!retext && level === node.attrs.level) continue\n if (level !== node.attrs.level) tr.setNodeMarkup(pos, undefined, { ...node.attrs, level })\n if (retext) tr.replaceWith(pos + 1, pos + 1 + node.content.size, tr.doc.type.schema.text(text))\n changed++\n }\n return changed\n}\n\n/**\n * „Gliederung bereinigen (KI)“: sends the headings of the whole document (task `outline-sanitize`, `generate` Model role) and\n * applies the model's repaired outline (levels without gaps, numbering and trailing punctuation gone, empty headings\n * merged into the next) in one transaction. A malformed answer, or a document whose headings changed while the model\n * ran, writes nothing and shows a notice. Notices go through `notify`, in the language of `t`.\n */\nexport async function sanitizeOutline(editor: Editor, ai: NonNullable<EditorBackend['ai']>, modelRef: (slot: 'generate') => ModelRef, notify: Notifier, t: Translate): Promise<void> {\n const headings = collectHeadings(editor.state.doc)\n if (!headings.length) {\n notify({ title: t('integrations.outlineSanitize.none'), kind: 'info' })\n return\n }\n const selection = JSON.stringify(headings.map(({ i, level, text, chars }) => ({ i, level, text, chars })))\n if (selection.length > AI_LIMITS.selection) {\n notify({ title: t('integrations.outlineSanitize.tooLong'), kind: 'error' })\n return\n }\n\n const toastId = 'outline-sanitize'\n const controller = new AbortController()\n const abort = () => controller.abort()\n editor.on('destroy', abort)\n notify({ id: toastId, title: t('integrations.outlineSanitize.running'), kind: 'info', icon: 'i-lucide-loader-circle', duration: 0 })\n let output = ''\n try {\n const outcome = await postAiSse(ai, 'generate', {\n task: 'outline-sanitize',\n prompt: '',\n selection,\n context: '',\n model: modelRef('generate'),\n }, { signal: controller.signal, t, onDelta: (text) => { output += text } })\n\n if (outcome.status === 'aborted' || editor.isDestroyed) return\n if (outcome.status === 'rate-limited') {\n notifyAiRateLimited(notify, t)\n return\n }\n if (outcome.status === 'error') {\n notify({ title: t('integrations.outlineSanitize.failed'), description: outcome.message, kind: 'error' })\n return\n }\n const outline = parseOutlineResponse(output, headings)\n if (!outline) {\n notify({ title: t('integrations.outlineSanitize.invalid'), kind: 'warning' })\n return\n }\n\n const current = collectHeadings(editor.state.doc)\n if (current.length !== headings.length || current.some((heading, index) => heading.pos !== headings[index]!.pos || heading.level !== headings[index]!.level || heading.text !== headings[index]!.text)) {\n notify({ title: t('integrations.outlineSanitize.gone'), kind: 'error' })\n return\n }\n const tr = editor.state.tr\n if (applyOutline(tr, current, outline)) editor.view.dispatch(tr)\n notify({ title: t('integrations.outlineSanitize.done'), kind: 'success', icon: 'i-lucide-list-tree' })\n }\n finally {\n notify.dismiss?.(toastId)\n editor.off('destroy', abort)\n }\n}\n"],"mappings":";;;;;;AAgBA,SAAgB,gBAAgB,KAA+B;CAC7D,MAAM,WAA6B,CAAC;CACpC,IAAI,aAAa,MAAM,KAAK,QAAQ,UAAU;EAC5C,IAAI,KAAK,KAAK,SAAS,aAAa,CAAC,QAAQ;EAC7C,MAAM,EAAE,OAAO,kBAAkB,QAAQ,KAAK;EAC9C,IAAI,QAAQ;EACZ,KAAK,IAAI,UAAU,QAAQ,GAAG,UAAU,IAAI,WAAW,SA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7B;EACF;EACA,IAAI,QAAQ,WAAW,SAAS;GAC9B,OAAO;IAAE,OAAO,EAAE,qCAAqC;IAAG,aAAa,QAAQ;IAAS,MAAM;GAAQ,CAAC;GACvG;EACF;EACA,MAAM,UAAU,qBAAqB,QAAQ,QAAQ;EACrD,IAAI,CAAC,SAAS;GACZ,OAAO;IAAE,OAAO,EAAE,sCAAsC;IAAG,MAAM;GAAU,CAAC;GAC5E;EACF;EAEA,MAAM,UAAU,gBAAgB,OAAO,MAAM,GAAG;EAChD,IAAI,QAAQ,WAAW,SAAS,UAAU,QAAQ,MAAM,SAAS,UAAU,QAAQ,QAAQ,SAAS,MAAM,CAAE,OAAO,QAAQ,UAAU,SAAS,MAAM,CAAE,SAAS,QAAQ,SAAS,SAAS,MAAM,CAAE,IAAI,GAAG;GACtM,OAAO;IAAE,OAAO,EAAE,mCAAmC;IAAG,MAAM;GAAQ,CAAC;GACvE;EACF;EACA,MAAM,KAAK,OAAO,MAAM;EACxB,IAAI,aAAa,IAAI,SAAS,OAAO,GAAG,OAAO,KAAK,SAAS,EAAE;EAC/D,OAAO;GAAE,OAAO,EAAE,mCAAmC;GAAG,MAAM;GAAW,MAAM;EAAqB,CAAC;CACvG,UACQ;EACN,OAAO,UAAU,OAAO;EACxB,OAAO,IAAI,WAAW,KAAK;CAC7B;AACF"}
|
|
@@ -8,7 +8,7 @@ import { Node as Node$1 } from "@tiptap/pm/model";
|
|
|
8
8
|
//#region src/integrations/composite-ai/rendition.d.ts
|
|
9
9
|
export interface RenditionOptions {
|
|
10
10
|
/**
|
|
11
|
-
* Replace the rendition at this position (a child of the source-holding
|
|
11
|
+
* Replace the rendition at this position (a child of the source-holding Typed block) in place instead of adding a new one
|
|
12
12
|
* after the source: its chrome (title, description, tags) and block id stay, body and derivation are new.
|
|
13
13
|
*/
|
|
14
14
|
replace?: {
|
|
@@ -16,26 +16,26 @@ export interface RenditionOptions {
|
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
|
-
* „
|
|
19
|
+
* the „Create readable rendition“ action: extracts the readable content of the source of the Typed block at `pos` (`ai.extract`, method
|
|
20
20
|
* `auto`: transcript with timestamps for audio/video, full text or OCR for a PDF, a description for an image) and adds
|
|
21
|
-
* it as a `rendition`
|
|
22
|
-
* the stored raw output). Bibliographic data the server found fills an empty `meta.bib` of the
|
|
23
|
-
* title an empty
|
|
24
|
-
* The
|
|
21
|
+
* it as a `rendition` Typed block right after the source block, carrying `meta.derivation` (asset, method, model, hashes,
|
|
22
|
+
* the stored raw output). Bibliographic data the server found fills an empty `meta.bib` of the Typed block, and the work's
|
|
23
|
+
* title an empty Typed block title. With `options.replace` the existing rendition is replaced in place (same block id).
|
|
24
|
+
* The Typed block is anchored through its description when the request starts and found again after it ends, so edits
|
|
25
25
|
* while it runs do not misplace the result. Notices go through `notify`, in the language of `t`; the progress notice
|
|
26
26
|
* stays until the request ends.
|
|
27
27
|
*/
|
|
28
28
|
export declare function createRendition(editor: Editor, pos: number, ai: NonNullable<EditorBackend['ai']>, modelRef: (slot: 'generate') => ModelRef, notify: Notifier, t: Translate, options?: RenditionOptions): Promise<void>;
|
|
29
29
|
/**
|
|
30
|
-
* Whether „
|
|
30
|
+
* Whether the „Create readable rendition“ action applies to `node`: a Typed block of a source-holding Block type whose source block was
|
|
31
31
|
* found. A recording needs speech-to-text (`transcription`: the app's public configuration enables it); everything else
|
|
32
32
|
* is extracted by the server.
|
|
33
33
|
*/
|
|
34
34
|
export declare function canCreateRendition(editor: Editor, node: Node$1, transcription: boolean): boolean;
|
|
35
|
-
/** Whether „Neu erzeugen (ersetzen)“ applies to the
|
|
35
|
+
/** Whether „Neu erzeugen (ersetzen)“ applies to the Typed block `node` at `pos`: an asset-derived rendition inside a Typed block that still has a source. */
|
|
36
36
|
export declare function canRegenerateRendition(editor: Editor, node: Node$1, pos: number, transcription: boolean): boolean;
|
|
37
37
|
/**
|
|
38
|
-
* „Neu erzeugen (ersetzen)“: makes the rendition at `pos` again from the source of its
|
|
38
|
+
* „Neu erzeugen (ersetzen)“: makes the rendition at `pos` again from the source of its Typed block and replaces it in place
|
|
39
39
|
* (`createRendition` with `replace`; the block id stays, so references keep resolving). A rendition whose body was
|
|
40
40
|
* edited since it was made is not replaced silently: a warning notice offers „Trotzdem ersetzen“, dismissing the notice
|
|
41
41
|
* cancels. The rendition is found again by its id when the button is pressed.
|