@ecsplico/editor 2.1.1 → 3.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 +74 -1
- package/README.md +39 -156
- package/dist/adapters/comments/drizzle.d.ts +1 -1
- package/dist/adapters/comments/{client.js → rest-model.js} +3 -3
- package/dist/adapters/comments/rest-model.js.map +1 -0
- package/dist/adapters/comments/types.d.ts +2 -2
- package/dist/adapters/document-state.d.ts +23 -0
- package/dist/adapters/document-state.js +66 -0
- package/dist/adapters/document-state.js.map +1 -0
- package/dist/adapters/documents.js +14 -11
- package/dist/adapters/documents.js.map +1 -1
- package/dist/adapters/drizzle.d.ts +2 -2
- package/dist/adapters/drizzle.js +97 -88
- package/dist/adapters/drizzle.js.map +1 -1
- package/dist/adapters/forge.d.ts +12 -7
- package/dist/adapters/forge.js +38 -45
- package/dist/adapters/forge.js.map +1 -1
- package/dist/adapters/http.d.ts +20 -0
- package/dist/adapters/http.js +68 -0
- package/dist/adapters/http.js.map +1 -0
- package/dist/adapters/index.d.ts +5 -5
- package/dist/adapters/json.d.ts +3 -3
- package/dist/adapters/json.js +58 -49
- package/dist/adapters/json.js.map +1 -1
- package/dist/adapters/memory.d.ts +21 -0
- package/dist/adapters/memory.js +53 -0
- package/dist/adapters/memory.js.map +1 -0
- package/dist/adapters/nitro.d.ts +23 -20
- package/dist/adapters/nitro.js +58 -163
- package/dist/adapters/nitro.js.map +1 -1
- package/dist/adapters/react.d.ts +55 -0
- package/dist/adapters/react.js +209 -0
- package/dist/adapters/react.js.map +1 -0
- package/dist/adapters/shared.d.ts +15 -21
- package/dist/adapters/shared.js +10 -8
- package/dist/adapters/shared.js.map +1 -1
- package/dist/adapters/vue.d.ts +15 -30
- package/dist/adapters/vue.js +36 -87
- package/dist/adapters/vue.js.map +1 -1
- package/dist/code/CodeSurface.vue.d.ts +3 -3
- package/dist/config/index.d.ts +105 -0
- package/dist/config/index.js +95 -0
- package/dist/config/index.js.map +1 -0
- package/dist/core/abilities.js +1 -0
- package/dist/core/abilities.js.map +1 -1
- package/dist/{adapters/routes.js → core/api-routes.js} +5 -3
- package/dist/core/api-routes.js.map +1 -0
- package/dist/core/backend-capability.d.ts +7 -0
- package/dist/core/backend-capability.js +17 -0
- package/dist/core/backend-capability.js.map +1 -0
- package/dist/core/backend-types.d.ts +245 -0
- package/dist/core/backend-types.js +17 -0
- package/dist/core/backend-types.js.map +1 -0
- package/dist/core/backend.d.ts +108 -0
- package/dist/core/backend.js +14 -0
- package/dist/core/backend.js.map +1 -0
- package/dist/core/block-convert.d.ts +7 -5
- package/dist/core/block-convert.js +28 -5
- package/dist/core/block-convert.js.map +1 -1
- package/dist/core/command-types.d.ts +89 -0
- package/dist/core/commands.d.ts +40 -0
- package/dist/core/commands.js +151 -0
- package/dist/core/commands.js.map +1 -0
- package/dist/core/context.d.ts +17 -20
- package/dist/core/context.js +24 -21
- package/dist/core/context.js.map +1 -1
- package/dist/core/core-feature.d.ts +22 -7
- package/dist/core/core-feature.js +51 -18
- package/dist/core/core-feature.js.map +1 -1
- package/dist/core/define-editor.d.ts +4 -3
- package/dist/core/define-editor.js +14 -7
- package/dist/core/define-editor.js.map +1 -1
- package/dist/core/document-markdown.js +12 -3
- package/dist/core/document-markdown.js.map +1 -1
- package/dist/core/editor-ui.d.ts +8 -1
- package/dist/core/editor-ui.js +9 -8
- package/dist/core/editor-ui.js.map +1 -1
- package/dist/core/extension-points.d.ts +3 -15
- package/dist/core/feature-context.d.ts +8 -7
- package/dist/core/feature-context.js +12 -11
- package/dist/core/feature-context.js.map +1 -1
- package/dist/core/feature.d.ts +35 -19
- package/dist/core/feature.js.map +1 -1
- package/dist/core/fences.d.ts +2 -1
- package/dist/core/fences.js +3 -2
- package/dist/core/fences.js.map +1 -1
- package/dist/core/fetch-error.d.ts +1 -1
- package/dist/core/fetch-error.js +3 -1
- package/dist/core/fetch-error.js.map +1 -1
- package/dist/core/hash.d.ts +5 -0
- package/dist/core/hash.js +11 -0
- package/dist/core/hash.js.map +1 -0
- package/dist/core/http-backend.d.ts +11 -0
- package/dist/core/http-backend.js +195 -0
- package/dist/core/http-backend.js.map +1 -0
- package/dist/core/index.d.ts +14 -9
- package/dist/core/index.js +12 -9
- package/dist/core/palette.d.ts +48 -0
- package/dist/core/palette.js +95 -0
- package/dist/core/palette.js.map +1 -0
- package/dist/core/schema/abilities.d.ts +2 -1
- package/dist/core/schema/abilities.js +5 -1
- package/dist/core/schema/abilities.js.map +1 -1
- package/dist/core/schema/index.d.ts +11 -5
- package/dist/core/schema/index.js +13 -8
- package/dist/core/schema/index.js.map +1 -1
- package/dist/core/schema/mark-flags.d.ts +8 -1
- package/dist/core/schema/of-features.d.ts +13 -0
- package/dist/core/schema/of-features.js +14 -0
- package/dist/core/schema/of-features.js.map +1 -0
- package/dist/core/slash.d.ts +8 -6
- package/dist/core/slash.js +24 -16
- package/dist/core/slash.js.map +1 -1
- package/dist/core/surface-session.js +13 -5
- package/dist/core/surface-session.js.map +1 -1
- package/dist/core/toolbar-items.d.ts +10 -4
- package/dist/core/toolbar-items.js +269 -195
- package/dist/core/toolbar-items.js.map +1 -1
- package/dist/core/util.js +11 -0
- package/dist/core/util.js.map +1 -0
- package/dist/document/DocumentSurface.d.ts +1 -1
- package/dist/document/DocumentSurface.vue.d.ts +3 -3
- package/dist/features/ai/agent-op-review.d.ts +1 -1
- package/dist/features/ai/agent-op-review.js +1 -1
- package/dist/features/ai/agent-ops.js +1 -1
- package/dist/features/ai/ai-apply.d.ts +2 -2
- package/dist/features/ai/ai-apply.js +1 -1
- package/dist/features/ai/ai-review.js +1 -1
- package/dist/features/ai/ai-sse.d.ts +6 -6
- package/dist/features/ai/ai-sse.js +20 -63
- package/dist/features/ai/ai-sse.js.map +1 -1
- package/dist/features/ai/assistant.d.ts +8 -7
- package/dist/features/ai/assistant.js +3 -3
- package/dist/features/ai/assistant.js.map +1 -1
- package/dist/features/ai/block-actions.d.ts +3 -2
- package/dist/features/ai/block-actions.js +3 -2
- package/dist/features/ai/block-actions.js.map +1 -1
- package/dist/features/ai/components/AiSelectionMenu.js +1 -1
- package/dist/features/ai/components/DocumentChatAnswer.js +1 -1
- package/dist/features/ai/components/DocumentChatOps.vue.d.ts +1 -1
- package/dist/features/ai/components/SettingsModelProfiles.js +8 -8
- package/dist/features/ai/components/SettingsModelProfiles.js.map +1 -1
- package/dist/features/ai/document-chat-model.d.ts +8 -7
- 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 +1 -1
- package/dist/features/ai/feature.js +27 -14
- package/dist/features/ai/feature.js.map +1 -1
- package/dist/features/ai/ghost-autocomplete.d.ts +7 -6
- package/dist/features/ai/ghost-autocomplete.js +6 -9
- package/dist/features/ai/ghost-autocomplete.js.map +1 -1
- package/dist/features/ai/index.d.ts +4 -3
- package/dist/features/ai/index.js +10 -10
- package/dist/features/ai/model-profiles.d.ts +5 -4
- package/dist/features/ai/model-profiles.js +2 -2
- package/dist/features/ai/model-profiles.js.map +1 -1
- package/dist/features/ai/protocol/block-lines.js +1 -1
- package/dist/features/ai/protocol/block-lines.js.map +1 -1
- package/dist/features/ai/protocol/chat.js +4 -1
- package/dist/features/ai/protocol/chat.js.map +1 -1
- package/dist/features/ai/protocol/index.d.ts +3 -2
- package/dist/features/ai/protocol/models.d.ts +2 -16
- package/dist/features/ai/protocol/models.js.map +1 -1
- package/dist/features/ai/rate-limit.d.ts +1 -1
- package/dist/features/ai/rate-limit.js +3 -1
- package/dist/features/ai/rate-limit.js.map +1 -1
- package/dist/features/ai/react/AiSelectionMenu.js +2 -2
- package/dist/features/ai/react/AiSidebar.js +4 -4
- package/dist/features/ai/react/DocumentChatAnswer.js +1 -1
- package/dist/features/ai/react/DocumentChatOps.d.ts +1 -1
- package/dist/features/ai/react/DocumentChatOps.js +1 -1
- package/dist/features/ai/react/SettingsModelProfiles.js +8 -10
- 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 +3 -3
- package/dist/features/ai/react/use-ai-assistant.js.map +1 -1
- package/dist/features/ai/react/use-document-chat.js +2 -2
- package/dist/features/ai/react/use-document-chat.js.map +1 -1
- package/dist/features/ai/react/use-model-profiles.d.ts +2 -1
- package/dist/features/ai/selection-flow.d.ts +1 -1
- package/dist/features/ai/selection-flow.js +1 -1
- package/dist/features/ai/sidebar-flow.d.ts +1 -1
- package/dist/features/ai/sidebar-flow.js +1 -1
- package/dist/features/ai/use-ai-assistant.d.ts +1 -1
- package/dist/features/ai/use-ai-assistant.js +3 -3
- package/dist/features/ai/use-ai-assistant.js.map +1 -1
- package/dist/features/ai/use-document-chat.js +2 -2
- package/dist/features/ai/use-document-chat.js.map +1 -1
- package/dist/features/ai/use-model-profiles.d.ts +2 -1
- package/dist/features/authors/attribution.d.ts +1 -1
- package/dist/features/authors/feature.js +12 -11
- package/dist/features/authors/feature.js.map +1 -1
- package/dist/features/block-ui/block-actions.d.ts +22 -1
- package/dist/features/block-ui/block-actions.js +26 -2
- package/dist/features/block-ui/block-actions.js.map +1 -1
- package/dist/features/block-ui/components/BlockActionsOverlay.js +33 -4
- package/dist/features/block-ui/components/BlockActionsOverlay.js.map +1 -1
- package/dist/features/block-ui/components/BlockActionsOverlay.vue.d.ts +4 -0
- package/dist/features/block-ui/components/BlockUi.js +1 -1
- package/dist/features/block-ui/feature.js +1 -0
- package/dist/features/block-ui/feature.js.map +1 -1
- package/dist/features/block-ui/index.d.ts +2 -2
- package/dist/features/block-ui/index.js +2 -2
- package/dist/features/block-ui/react/BlockActionsOverlay.d.ts +4 -0
- package/dist/features/block-ui/react/BlockActionsOverlay.js +38 -12
- package/dist/features/block-ui/react/BlockActionsOverlay.js.map +1 -1
- package/dist/features/block-ui/react/BlockUi.js +1 -1
- package/dist/features/collab/anchor-resolver.js +1 -1
- package/dist/features/collab/feature.js +2 -0
- package/dist/features/collab/feature.js.map +1 -1
- package/dist/features/comments/components/CommentThreadView.vue.d.ts +2 -1
- package/dist/features/comments/feature.js +12 -11
- package/dist/features/comments/feature.js.map +1 -1
- package/dist/features/comments/index.d.ts +3 -2
- package/dist/features/comments/index.js +1 -1
- package/dist/features/comments/margin-layout.d.ts +3 -2
- package/dist/features/comments/model.d.ts +3 -67
- package/dist/features/comments/model.js +2 -2
- package/dist/features/comments/model.js.map +1 -1
- package/dist/features/comments/react/CommentThreadView.d.ts +3 -2
- package/dist/features/comments/react/use-comments.d.ts +2 -1
- package/dist/features/comments/react.d.ts +1 -1
- package/dist/features/comments/schema.d.ts +2 -52
- package/dist/features/comments/schema.js.map +1 -1
- package/dist/features/comments/snapshot-equality.js.map +1 -1
- package/dist/features/comments/use-comments.d.ts +3 -2
- package/dist/features/comments/vue.d.ts +1 -1
- package/dist/features/composites/accepted-children.d.ts +1 -0
- package/dist/features/composites/accepted-children.js +16 -1
- package/dist/features/composites/accepted-children.js.map +1 -1
- package/dist/features/composites/ai-brief.js +31 -0
- package/dist/features/composites/ai-brief.js.map +1 -1
- package/dist/features/composites/bibliography-command.d.ts +11 -0
- package/dist/features/composites/bibliography-form.js +90 -0
- package/dist/features/composites/bibliography-form.js.map +1 -0
- package/dist/features/composites/bibliography.d.ts +33 -0
- package/dist/features/composites/bibliography.js +120 -0
- package/dist/features/composites/bibliography.js.map +1 -0
- package/dist/features/composites/components/BibliographyEditor.js +261 -0
- package/dist/features/composites/components/BibliographyEditor.js.map +1 -0
- package/dist/features/composites/components/CompositeChrome.js +75 -26
- package/dist/features/composites/components/CompositeChrome.js.map +1 -1
- package/dist/features/composites/components/CompositeDetails.js +46 -11
- package/dist/features/composites/components/CompositeDetails.js.map +1 -1
- package/dist/features/composites/components/CompositeDetails.vue.d.ts +2 -1
- package/dist/features/composites/components/CompositeFieldEditor.js +37 -4
- package/dist/features/composites/components/CompositeFieldEditor.js.map +1 -1
- package/dist/features/composites/components/CompositeInspector.js +17 -5
- package/dist/features/composites/components/CompositeInspector.js.map +1 -1
- package/dist/features/composites/components/CompositeTable.js +13 -4
- package/dist/features/composites/components/CompositeTable.js.map +1 -1
- package/dist/features/composites/components/CompositeTagsEditor.js +1 -1
- package/dist/features/composites/components/CompositeView.js +11 -1
- package/dist/features/composites/components/CompositeView.js.map +1 -1
- package/dist/features/composites/components/DerivationBadge.js +103 -0
- package/dist/features/composites/components/DerivationBadge.js.map +1 -0
- package/dist/features/composites/components/ReferenceFieldSelect.js +60 -0
- package/dist/features/composites/components/ReferenceFieldSelect.js.map +1 -0
- package/dist/features/composites/components/ReferenceView.js +122 -0
- package/dist/features/composites/components/ReferenceView.js.map +1 -0
- package/dist/features/composites/components/ReferenceView.vue.d.ts +96 -0
- package/dist/features/composites/components/SettingsEditingTab.js +1 -1
- package/dist/features/composites/convert.js +2 -2
- package/dist/features/composites/convert.js.map +1 -1
- package/dist/features/composites/derivation.d.ts +61 -0
- package/dist/features/composites/derivation.js +98 -0
- package/dist/features/composites/derivation.js.map +1 -0
- package/dist/features/composites/derived-chrome.js +69 -0
- package/dist/features/composites/derived-chrome.js.map +1 -0
- package/dist/features/composites/feature.js +159 -109
- package/dist/features/composites/feature.js.map +1 -1
- package/dist/features/composites/fences.d.ts +4 -3
- package/dist/features/composites/fences.js +51 -7
- package/dist/features/composites/fences.js.map +1 -1
- package/dist/features/composites/index.d.ts +12 -3
- package/dist/features/composites/index.js +15 -6
- package/dist/features/composites/inspector-model.d.ts +4 -1
- package/dist/features/composites/inspector-model.js +8 -4
- package/dist/features/composites/inspector-model.js.map +1 -1
- package/dist/features/composites/kinds.d.ts +8 -1
- package/dist/features/composites/kinds.js +145 -6
- package/dist/features/composites/kinds.js.map +1 -1
- package/dist/features/composites/legacy.d.ts +4 -1
- package/dist/features/composites/legacy.js +56 -1
- package/dist/features/composites/legacy.js.map +1 -1
- package/dist/features/composites/meta-display.js +40 -1
- package/dist/features/composites/meta-display.js.map +1 -1
- package/dist/features/composites/meta-keys.d.ts +7 -0
- package/dist/features/composites/meta-keys.js +21 -0
- package/dist/features/composites/meta-keys.js.map +1 -0
- package/dist/features/composites/node-views.d.ts +6 -3
- package/dist/features/composites/node-views.js +7 -3
- package/dist/features/composites/node-views.js.map +1 -1
- package/dist/features/composites/nodes.d.ts +6 -1
- package/dist/features/composites/nodes.js +33 -7
- package/dist/features/composites/nodes.js.map +1 -1
- package/dist/features/composites/react/BibliographyEditor.js +229 -0
- package/dist/features/composites/react/BibliographyEditor.js.map +1 -0
- package/dist/features/composites/react/CompositeChrome.js +65 -17
- package/dist/features/composites/react/CompositeChrome.js.map +1 -1
- package/dist/features/composites/react/CompositeDetails.d.ts +2 -1
- package/dist/features/composites/react/CompositeDetails.js +45 -6
- package/dist/features/composites/react/CompositeDetails.js.map +1 -1
- package/dist/features/composites/react/CompositeFieldEditor.d.ts +1 -1
- package/dist/features/composites/react/CompositeFieldEditor.js +24 -1
- package/dist/features/composites/react/CompositeFieldEditor.js.map +1 -1
- package/dist/features/composites/react/CompositeInspector.js +11 -5
- package/dist/features/composites/react/CompositeInspector.js.map +1 -1
- package/dist/features/composites/react/CompositeStatusMenu.js +1 -1
- package/dist/features/composites/react/CompositeSummaryEditor.js +1 -1
- package/dist/features/composites/react/CompositeTable.js +16 -2
- package/dist/features/composites/react/CompositeTable.js.map +1 -1
- package/dist/features/composites/react/CompositeTagsEditor.js +2 -2
- package/dist/features/composites/react/CompositeView.js +6 -1
- package/dist/features/composites/react/CompositeView.js.map +1 -1
- package/dist/features/composites/react/DerivationBadge.js +116 -0
- package/dist/features/composites/react/DerivationBadge.js.map +1 -0
- package/dist/features/composites/react/ReferenceFieldSelect.js +52 -0
- package/dist/features/composites/react/ReferenceFieldSelect.js.map +1 -0
- package/dist/features/composites/react/ReferenceView.d.ts +11 -0
- package/dist/features/composites/react/ReferenceView.js +115 -0
- package/dist/features/composites/react/ReferenceView.js.map +1 -0
- package/dist/features/composites/react/SettingsEditingTab.js +2 -2
- package/dist/features/composites/react.d.ts +2 -1
- package/dist/features/composites/react.js +7 -3
- package/dist/features/composites/react.js.map +1 -1
- package/dist/features/composites/reference-ai.js +16 -0
- package/dist/features/composites/reference-ai.js.map +1 -0
- package/dist/features/composites/reference-label.d.ts +19 -0
- package/dist/features/composites/reference-label.js +58 -0
- package/dist/features/composites/reference-label.js.map +1 -0
- package/dist/features/composites/reference-suggestion.d.ts +10 -0
- package/dist/features/composites/reference-suggestion.js +41 -0
- package/dist/features/composites/reference-suggestion.js.map +1 -0
- package/dist/features/composites/reference-text.d.ts +18 -0
- package/dist/features/composites/reference-text.js +89 -0
- package/dist/features/composites/reference-text.js.map +1 -0
- package/dist/features/composites/reference.d.ts +44 -0
- package/dist/features/composites/reference.js +148 -0
- package/dist/features/composites/reference.js.map +1 -0
- package/dist/features/composites/reveal-source.d.ts +32 -0
- package/dist/features/composites/reveal-source.js +89 -0
- package/dist/features/composites/reveal-source.js.map +1 -0
- package/dist/features/composites/rows.d.ts +21 -2
- package/dist/features/composites/rows.js +63 -9
- package/dist/features/composites/rows.js.map +1 -1
- package/dist/features/composites/schema.d.ts +9 -3
- package/dist/features/composites/schema.js +11 -4
- package/dist/features/composites/schema.js.map +1 -1
- package/dist/features/composites/table-model.js +12 -21
- package/dist/features/composites/table-model.js.map +1 -1
- package/dist/features/composites/vue.d.ts +3 -2
- package/dist/features/composites/vue.js +8 -4
- package/dist/features/composites/vue.js.map +1 -1
- package/dist/features/media/assets.d.ts +2 -0
- package/dist/features/media/assets.js +3 -2
- package/dist/features/media/assets.js.map +1 -1
- package/dist/features/media/components/FileView.js +13 -4
- package/dist/features/media/components/FileView.js.map +1 -1
- package/dist/features/media/feature.d.ts +3 -3
- package/dist/features/media/feature.js +21 -28
- package/dist/features/media/feature.js.map +1 -1
- package/dist/features/media/file-import.js +2 -2
- package/dist/features/media/file-import.js.map +1 -1
- package/dist/features/media/index.d.ts +2 -2
- package/dist/features/media/index.js +2 -2
- package/dist/features/media/react/FileView.js +19 -2
- package/dist/features/media/react/FileView.js.map +1 -1
- package/dist/features/media/schema.d.ts +8 -0
- package/dist/features/media/schema.js +126 -11
- package/dist/features/media/schema.js.map +1 -1
- package/dist/features/media/upload.d.ts +16 -14
- package/dist/features/media/upload.js +13 -19
- package/dist/features/media/upload.js.map +1 -1
- package/dist/features/mentions/index.d.ts +4 -3
- package/dist/features/mentions/index.js +4 -1
- package/dist/features/mentions/index.js.map +1 -1
- package/dist/features/mentions/mention-text.d.ts +1 -1
- package/dist/features/mentions/mention-text.js.map +1 -1
- package/dist/features/mentions/mention.d.ts +0 -6
- package/dist/features/mentions/mention.js.map +1 -1
- package/dist/features/mentions/metadata-defaults.d.ts +2 -2
- package/dist/features/mentions/metadata-defaults.js +3 -9
- package/dist/features/mentions/metadata-defaults.js.map +1 -1
- package/dist/features/mentions/schema.d.ts +2 -1
- package/dist/features/mentions/schema.js.map +1 -1
- package/dist/features/tables/feature.d.ts +2 -1
- package/dist/features/tables/feature.js +90 -70
- package/dist/features/tables/feature.js.map +1 -1
- package/dist/features/themes/components/SettingsAppearanceTab.js +6 -9
- package/dist/features/themes/components/SettingsAppearanceTab.js.map +1 -1
- package/dist/features/themes/feature.js +2 -0
- package/dist/features/themes/feature.js.map +1 -1
- package/dist/features/themes/index.d.ts +2 -1
- package/dist/features/themes/react/SettingsAppearanceTab.js +7 -10
- package/dist/features/themes/react/SettingsAppearanceTab.js.map +1 -1
- package/dist/features/themes/schema.d.ts +2 -6
- package/dist/features/themes/schema.js.map +1 -1
- package/dist/features/themes/theme-runtime.d.ts +1 -1
- package/dist/features/themes/theme-runtime.js +4 -2
- package/dist/features/themes/theme-runtime.js.map +1 -1
- package/dist/features/transcript/TranscriptSegmentView.js +48 -28
- package/dist/features/transcript/TranscriptSegmentView.js.map +1 -1
- package/dist/features/transcript/feature.js +21 -19
- package/dist/features/transcript/feature.js.map +1 -1
- package/dist/features/transcript/react/TranscriptSegmentView.js +55 -36
- package/dist/features/transcript/react/TranscriptSegmentView.js.map +1 -1
- package/dist/features/transcript/segment-node.d.ts +2 -0
- package/dist/features/transcript/segment-node.js +35 -7
- package/dist/features/transcript/segment-node.js.map +1 -1
- package/dist/i18n/de/composites.js +91 -1
- package/dist/i18n/de/composites.js.map +1 -1
- package/dist/i18n/de/integrations.js +49 -8
- package/dist/i18n/de/integrations.js.map +1 -1
- package/dist/i18n/de/media.js +0 -1
- package/dist/i18n/de/media.js.map +1 -1
- package/dist/i18n/de/palette.js +22 -0
- package/dist/i18n/de/palette.js.map +1 -0
- package/dist/i18n/de/tables.js +0 -1
- package/dist/i18n/de/tables.js.map +1 -1
- package/dist/i18n/de/transcript.js +2 -1
- package/dist/i18n/de/transcript.js.map +1 -1
- package/dist/i18n/de/tree.js +3 -0
- package/dist/i18n/de/tree.js.map +1 -1
- package/dist/i18n/de.d.ts +157 -11
- package/dist/i18n/de.js +3 -1
- package/dist/i18n/de.js.map +1 -1
- package/dist/i18n/en/composites.js +89 -1
- package/dist/i18n/en/composites.js.map +1 -1
- package/dist/i18n/en/integrations.js +49 -8
- package/dist/i18n/en/integrations.js.map +1 -1
- package/dist/i18n/en/media.js +0 -1
- package/dist/i18n/en/media.js.map +1 -1
- package/dist/i18n/en/palette.js +22 -0
- package/dist/i18n/en/palette.js.map +1 -0
- package/dist/i18n/en/tables.js +0 -1
- package/dist/i18n/en/tables.js.map +1 -1
- package/dist/i18n/en/transcript.js +2 -1
- package/dist/i18n/en/transcript.js.map +1 -1
- package/dist/i18n/en/tree.js +3 -0
- package/dist/i18n/en/tree.js.map +1 -1
- package/dist/i18n/en.js +3 -1
- package/dist/i18n/en.js.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/integrations/composite-ai/bibliography-fetch.d.ts +31 -0
- package/dist/integrations/composite-ai/bibliography-fetch.js +159 -0
- package/dist/integrations/composite-ai/bibliography-fetch.js.map +1 -0
- package/dist/integrations/composite-ai/composite-fill.d.ts +30 -8
- package/dist/integrations/composite-ai/composite-fill.js +97 -56
- package/dist/integrations/composite-ai/composite-fill.js.map +1 -1
- package/dist/integrations/composite-ai/composite-summary.d.ts +4 -12
- package/dist/integrations/composite-ai/composite-summary.js +7 -26
- package/dist/integrations/composite-ai/composite-summary.js.map +1 -1
- package/dist/integrations/composite-ai/derive.d.ts +29 -0
- package/dist/integrations/composite-ai/derive.js +173 -0
- package/dist/integrations/composite-ai/derive.js.map +1 -0
- package/dist/integrations/composite-ai/index.d.ts +11 -7
- package/dist/integrations/composite-ai/index.js +72 -14
- package/dist/integrations/composite-ai/index.js.map +1 -1
- package/dist/integrations/composite-ai/rendition.d.ts +45 -0
- package/dist/integrations/composite-ai/rendition.js +314 -0
- package/dist/integrations/composite-ai/rendition.js.map +1 -0
- package/dist/integrations/composite-media/index.d.ts +7 -5
- package/dist/integrations/composite-media/index.js +86 -13
- package/dist/integrations/composite-media/index.js.map +1 -1
- package/dist/integrations/transcript-ai/index.d.ts +1 -1
- package/dist/integrations/transcript-ai/index.js +5 -2
- package/dist/integrations/transcript-ai/index.js.map +1 -1
- package/dist/integrations/transcript-ai/protocol.d.ts +2 -12
- package/dist/integrations/transcript-ai/protocol.js +0 -2
- package/dist/integrations/transcript-ai/protocol.js.map +1 -1
- package/dist/integrations/transcript-ai/transcript-cleanup.d.ts +5 -5
- package/dist/integrations/transcript-ai/transcript-cleanup.js +7 -10
- package/dist/integrations/transcript-ai/transcript-cleanup.js.map +1 -1
- package/dist/markdown/MarkdownSurface.vue.d.ts +10 -9
- package/dist/markdown/MarkdownSurface2.js +3 -6
- package/dist/markdown/MarkdownSurface2.js.map +1 -1
- package/dist/markdown/document.js +1 -1
- package/dist/markdown/source-mode.d.ts +1 -1
- package/dist/nuxt/module.d.ts +1402 -54
- package/dist/nuxt/module.js +6 -49
- package/dist/nuxt/module.js.map +1 -1
- package/dist/nuxt/runtime/install-context.d.ts +7 -3
- package/dist/nuxt/runtime/install-context.js +14 -8
- package/dist/nuxt/runtime/install-context.js.map +1 -1
- package/dist/nuxt/runtime/plugins/editor-context-nuxt-ui.client.ts +2 -2
- package/dist/nuxt/runtime/server/plugins/editor-server.js +20 -12
- package/dist/nuxt/runtime/server/plugins/editor-server.js.map +1 -1
- package/dist/presets/compose.d.ts +94 -0
- package/dist/presets/compose.js +164 -0
- package/dist/presets/compose.js.map +1 -0
- package/dist/react/AdvancedEditor.d.ts +15 -15
- package/dist/react/AdvancedEditor.js +15 -13
- package/dist/react/AdvancedEditor.js.map +1 -1
- package/dist/react/EditorCommandPalette.d.ts +13 -0
- package/dist/react/EditorCommandPalette.js +118 -0
- package/dist/react/EditorCommandPalette.js.map +1 -0
- package/dist/react/EditorSettingsModal.d.ts +5 -5
- package/dist/react/EditorSettingsModal.js +7 -4
- package/dist/react/EditorSettingsModal.js.map +1 -1
- package/dist/react/EditorSettingsPanel.d.ts +7 -7
- package/dist/react/EditorSettingsPanel.js +8 -5
- package/dist/react/EditorSettingsPanel.js.map +1 -1
- package/dist/react/EditorSurface.d.ts +7 -7
- package/dist/react/EditorSurface.js +10 -6
- package/dist/react/EditorSurface.js.map +1 -1
- package/dist/react/EditorToolbar.d.ts +4 -6
- package/dist/react/EditorToolbar.js +29 -37
- package/dist/react/EditorToolbar.js.map +1 -1
- package/dist/react/SimpleEditor.d.ts +22 -23
- package/dist/react/SimpleEditor.js +21 -7
- package/dist/react/SimpleEditor.js.map +1 -1
- package/dist/react/advanced.d.ts +4 -3
- package/dist/react/advanced.js +2 -2
- package/dist/react/compose.d.ts +20 -0
- package/dist/react/compose.js +49 -0
- package/dist/react/compose.js.map +1 -0
- package/dist/react/composed-surface.d.ts +39 -0
- package/dist/react/composed-surface.js +71 -0
- package/dist/react/composed-surface.js.map +1 -0
- package/dist/react/context.js +6 -2
- package/dist/react/context.js.map +1 -1
- package/dist/react/index.d.ts +2 -1
- package/dist/react/index.js +2 -1
- package/dist/react/key-labels.js +15 -0
- package/dist/react/key-labels.js.map +1 -0
- package/dist/react/settings.d.ts +1 -1
- package/dist/react/simple.d.ts +2 -2
- package/dist/react/ui/command.js +36 -1
- package/dist/react/ui/command.js.map +1 -1
- package/dist/schema/advanced.d.ts +6 -6
- package/dist/schema/advanced.js +26 -29
- package/dist/schema/advanced.js.map +1 -1
- package/dist/server/ai.d.ts +5 -16
- package/dist/server/ai.js.map +1 -1
- package/dist/server/auth.d.ts +9 -0
- package/dist/server/collab-state.d.ts +1 -1
- package/dist/server/collab-state.js.map +1 -1
- package/dist/server/collab.d.ts +13 -13
- package/dist/server/collab.js +34 -18
- package/dist/server/collab.js.map +1 -1
- package/dist/server/crossref.js +78 -0
- package/dist/server/crossref.js.map +1 -0
- package/dist/server/errors.d.ts +1 -1
- package/dist/server/errors.js +1 -1
- package/dist/server/errors.js.map +1 -1
- package/dist/server/extract.js +308 -0
- package/dist/server/extract.js.map +1 -0
- package/dist/{nuxt/runtime/server/utils/editor-route.js → server/h3.js} +8 -16
- package/dist/server/h3.js.map +1 -0
- package/dist/server/handlers/ai.d.ts +30 -9
- package/dist/server/handlers/ai.js +170 -36
- package/dist/server/handlers/ai.js.map +1 -1
- package/dist/server/handlers/context.d.ts +12 -5
- package/dist/server/handlers/context.js +10 -4
- package/dist/server/handlers/context.js.map +1 -1
- package/dist/server/handlers/editor.d.ts +19 -13
- package/dist/server/handlers/editor.js +49 -38
- package/dist/server/handlers/editor.js.map +1 -1
- package/dist/server/handlers/index.d.ts +4 -4
- package/dist/server/handlers/index.js +4 -4
- package/dist/server/host.d.ts +16 -25
- package/dist/server/host.js +58 -41
- package/dist/server/host.js.map +1 -1
- package/dist/server/index.d.ts +6 -4
- package/dist/server/index.js +3 -2
- package/dist/server/pdf.js +97 -0
- package/dist/server/pdf.js.map +1 -0
- package/dist/server/{adapter.d.ts → ports.d.ts} +81 -30
- package/dist/server/ports.js +29 -0
- package/dist/server/ports.js.map +1 -0
- package/dist/server/routes.js +144 -0
- package/dist/server/routes.js.map +1 -0
- package/dist/settings/index.d.ts +1 -1
- package/dist/settings/index.js.map +1 -1
- package/dist/styles/composites.css +25 -0
- package/dist/tree/DocumentTree.js +56 -29
- package/dist/tree/DocumentTree.js.map +1 -1
- package/dist/tree/react/DocumentTree.js +23 -0
- package/dist/tree/react/DocumentTree.js.map +1 -1
- package/dist/tree/tree-host.js +1 -1
- package/dist/vue/AdvancedEditor.js +30 -9
- package/dist/vue/AdvancedEditor.js.map +1 -1
- package/dist/vue/AdvancedEditor.vue.d.ts +32 -12
- package/dist/vue/SimpleEditor.js +62 -16
- package/dist/vue/SimpleEditor.js.map +1 -1
- package/dist/vue/SimpleEditor.vue.d.ts +37 -7
- package/dist/vue/advanced.d.ts +3 -2
- package/dist/vue/advanced.js +2 -2
- package/dist/vue/components/EditorCommandPalette.js +91 -0
- package/dist/vue/components/EditorCommandPalette.js.map +1 -0
- package/dist/vue/components/EditorCommandPalette.vue.d.ts +15 -0
- package/dist/vue/components/EditorSettingsModal.js +10 -6
- package/dist/vue/components/EditorSettingsModal.js.map +1 -1
- package/dist/vue/components/EditorSettingsModal.vue.d.ts +4 -4
- package/dist/vue/components/EditorSettingsPanel.js +10 -6
- package/dist/vue/components/EditorSettingsPanel.js.map +1 -1
- package/dist/vue/components/EditorSettingsPanel.vue.d.ts +6 -6
- package/dist/vue/components/EditorSurface.js +11 -6
- package/dist/vue/components/EditorSurface.js.map +1 -1
- package/dist/vue/components/EditorSurface.vue.d.ts +11 -11
- package/dist/vue/components/EditorToolbar.js +41 -49
- package/dist/vue/components/EditorToolbar.js.map +1 -1
- package/dist/vue/components/EditorToolbar.vue.d.ts +2 -4
- package/dist/vue/compose.d.ts +17 -0
- package/dist/vue/compose.js +51 -0
- package/dist/vue/compose.js.map +1 -0
- package/dist/vue/context-key.d.ts +6 -0
- package/dist/vue/context-key.js +6 -0
- package/dist/vue/context-key.js.map +1 -0
- package/dist/vue/context.d.ts +8 -6
- package/dist/vue/context.js +6 -5
- package/dist/vue/context.js.map +1 -1
- package/dist/vue/index.d.ts +10 -8
- package/dist/vue/index.js +10 -8
- package/dist/vue/kit/index.d.ts +2 -2
- package/dist/vue/kit/nuxt-ui.js +23 -0
- package/dist/vue/kit/nuxt-ui.js.map +1 -1
- package/dist/vue/kit/types.d.ts +40 -1
- package/package.json +30 -16
- package/dist/adapters/comments/client.d.ts +0 -64
- package/dist/adapters/comments/client.js.map +0 -1
- package/dist/adapters/routes.js.map +0 -1
- package/dist/core/toolbar.d.ts +0 -74
- package/dist/core/toolbar.js +0 -45
- package/dist/core/toolbar.js.map +0 -1
- package/dist/integrations/composite-ai/document-transcribe.d.ts +0 -14
- package/dist/integrations/composite-ai/document-transcribe.js +0 -89
- package/dist/integrations/composite-ai/document-transcribe.js.map +0 -1
- package/dist/nuxt/runtime/server/api/ai/chat.post.d.ts +0 -5
- package/dist/nuxt/runtime/server/api/ai/chat.post.js +0 -8
- package/dist/nuxt/runtime/server/api/ai/chat.post.js.map +0 -1
- package/dist/nuxt/runtime/server/api/ai/complete.post.d.ts +0 -5
- package/dist/nuxt/runtime/server/api/ai/complete.post.js +0 -8
- package/dist/nuxt/runtime/server/api/ai/complete.post.js.map +0 -1
- package/dist/nuxt/runtime/server/api/ai/generate.post.d.ts +0 -5
- package/dist/nuxt/runtime/server/api/ai/generate.post.js +0 -8
- package/dist/nuxt/runtime/server/api/ai/generate.post.js.map +0 -1
- package/dist/nuxt/runtime/server/api/ai/models.get.d.ts +0 -5
- package/dist/nuxt/runtime/server/api/ai/models.get.js +0 -8
- package/dist/nuxt/runtime/server/api/ai/models.get.js.map +0 -1
- package/dist/nuxt/runtime/server/api/ai/transcribe.post.d.ts +0 -5
- package/dist/nuxt/runtime/server/api/ai/transcribe.post.js +0 -8
- package/dist/nuxt/runtime/server/api/ai/transcribe.post.js.map +0 -1
- package/dist/nuxt/runtime/server/api/ai/transcript-cleanup.post.d.ts +0 -5
- package/dist/nuxt/runtime/server/api/ai/transcript-cleanup.post.js +0 -8
- package/dist/nuxt/runtime/server/api/ai/transcript-cleanup.post.js.map +0 -1
- package/dist/nuxt/runtime/server/api/editor/assets/[id]/[name].get.d.ts +0 -5
- package/dist/nuxt/runtime/server/api/editor/assets/[id]/[name].get.js +0 -8
- package/dist/nuxt/runtime/server/api/editor/assets/[id]/[name].get.js.map +0 -1
- package/dist/nuxt/runtime/server/api/editor/assets/[id].post.d.ts +0 -5
- package/dist/nuxt/runtime/server/api/editor/assets/[id].post.js +0 -8
- package/dist/nuxt/runtime/server/api/editor/assets/[id].post.js.map +0 -1
- package/dist/nuxt/runtime/server/api/editor/settings.get.d.ts +0 -5
- package/dist/nuxt/runtime/server/api/editor/settings.get.js +0 -8
- package/dist/nuxt/runtime/server/api/editor/settings.get.js.map +0 -1
- package/dist/nuxt/runtime/server/api/editor/settings.put.d.ts +0 -5
- package/dist/nuxt/runtime/server/api/editor/settings.put.js +0 -8
- package/dist/nuxt/runtime/server/api/editor/settings.put.js.map +0 -1
- package/dist/nuxt/runtime/server/api/editor/tags.get.d.ts +0 -5
- package/dist/nuxt/runtime/server/api/editor/tags.get.js +0 -8
- package/dist/nuxt/runtime/server/api/editor/tags.get.js.map +0 -1
- package/dist/nuxt/runtime/server/api/editor/themes/[id].delete.d.ts +0 -5
- package/dist/nuxt/runtime/server/api/editor/themes/[id].delete.js +0 -8
- package/dist/nuxt/runtime/server/api/editor/themes/[id].delete.js.map +0 -1
- package/dist/nuxt/runtime/server/api/editor/themes/[id].get.d.ts +0 -5
- package/dist/nuxt/runtime/server/api/editor/themes/[id].get.js +0 -8
- package/dist/nuxt/runtime/server/api/editor/themes/[id].get.js.map +0 -1
- package/dist/nuxt/runtime/server/api/editor/themes/index.get.d.ts +0 -5
- package/dist/nuxt/runtime/server/api/editor/themes/index.get.js +0 -8
- package/dist/nuxt/runtime/server/api/editor/themes/index.get.js.map +0 -1
- package/dist/nuxt/runtime/server/api/editor/themes/index.post.d.ts +0 -5
- package/dist/nuxt/runtime/server/api/editor/themes/index.post.js +0 -8
- package/dist/nuxt/runtime/server/api/editor/themes/index.post.js.map +0 -1
- package/dist/nuxt/runtime/server/api/editor/users.get.d.ts +0 -5
- package/dist/nuxt/runtime/server/api/editor/users.get.js +0 -8
- package/dist/nuxt/runtime/server/api/editor/users.get.js.map +0 -1
- package/dist/nuxt/runtime/server/plugins/collab.d.ts +0 -5
- package/dist/nuxt/runtime/server/plugins/collab.js +0 -10
- package/dist/nuxt/runtime/server/plugins/collab.js.map +0 -1
- package/dist/nuxt/runtime/server/routes/collab/[id].d.ts +0 -5
- package/dist/nuxt/runtime/server/routes/collab/[id].js +0 -35
- package/dist/nuxt/runtime/server/routes/collab/[id].js.map +0 -1
- package/dist/nuxt/runtime/server/utils/editor-route.d.ts +0 -11
- package/dist/nuxt/runtime/server/utils/editor-route.js.map +0 -1
- package/dist/presets/advanced.d.ts +0 -33
- package/dist/presets/advanced.js +0 -50
- package/dist/presets/advanced.js.map +0 -1
- package/dist/presets/simple.d.ts +0 -9
- package/dist/presets/simple.js +0 -12
- package/dist/presets/simple.js.map +0 -1
- package/dist/react/advanced-preset.d.ts +0 -11
- package/dist/react/advanced-preset.js +0 -31
- package/dist/react/advanced-preset.js.map +0 -1
- package/dist/vue/advanced-preset.d.ts +0 -13
- package/dist/vue/advanced-preset.js +0 -33
- package/dist/vue/advanced-preset.js.map +0 -1
- package/docs/extending.md +0 -538
- package/docs/integration.md +0 -630
- package/docs/llms.md +0 -383
- package/docs/usage.md +0 -1076
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { EDITOR_API } from "../../core/api-routes.js";
|
|
2
|
+
import { compositeKind } from "./kinds.js";
|
|
3
|
+
import { DERIVATION_KEY } from "./meta-keys.js";
|
|
4
|
+
import "./nodes.js";
|
|
5
|
+
//#region src/features/composites/derivation.ts
|
|
6
|
+
/** The derivation of a composite (`meta.derivation` with a `from` object and a `method`); null when it has none. */
|
|
7
|
+
function derivationOf(node) {
|
|
8
|
+
const meta = node.attrs.meta;
|
|
9
|
+
const value = meta && typeof meta === "object" ? meta[DERIVATION_KEY] : void 0;
|
|
10
|
+
if (!value || typeof value !== "object") return null;
|
|
11
|
+
const { from, method } = value;
|
|
12
|
+
if (!from || typeof from !== "object" || typeof method !== "string") return null;
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
const ASSET_URL_PREFIX = `${EDITOR_API}/assets/`;
|
|
16
|
+
const ASSET_NAME = /^[0-9a-f-]{36}\.[a-z0-9]{1,8}$/;
|
|
17
|
+
const ASSET_DOCUMENT_ID = /^[A-Za-z0-9_-]{1,64}$/;
|
|
18
|
+
/** The stored asset behind an `/api/editor/assets/<documentId>/<name>` URL; null for any other `src`. */
|
|
19
|
+
function assetRefOf(src) {
|
|
20
|
+
if (!src.startsWith(ASSET_URL_PREFIX)) return null;
|
|
21
|
+
const [documentId, name, ...rest] = src.slice(ASSET_URL_PREFIX.length).split("/");
|
|
22
|
+
if (rest.length || !documentId || !name || !ASSET_DOCUMENT_ID.test(documentId) || !ASSET_NAME.test(name)) return null;
|
|
23
|
+
return {
|
|
24
|
+
documentId,
|
|
25
|
+
name
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
/** The media block a source-holding kind keeps its original in: first body child of a type in `kind.source`. */
|
|
29
|
+
function sourceOf(composite, kinds) {
|
|
30
|
+
if (composite.type.name !== "composite") return null;
|
|
31
|
+
const types = compositeKind(kinds, String(composite.attrs.kind)).source;
|
|
32
|
+
if (!types) return null;
|
|
33
|
+
for (let index = 3; index < composite.childCount; index++) {
|
|
34
|
+
const node = composite.child(index);
|
|
35
|
+
if (!types.includes(node.type.name)) continue;
|
|
36
|
+
const hash = node.attrs.hash;
|
|
37
|
+
return {
|
|
38
|
+
node,
|
|
39
|
+
index,
|
|
40
|
+
asset: assetRefOf(String(node.attrs.src ?? "")),
|
|
41
|
+
hash: typeof hash === "string" && hash ? hash : null
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
/** The body children of `composite` that are derived Bausteine, with their child index. */
|
|
47
|
+
function renditionsOf(composite) {
|
|
48
|
+
const found = [];
|
|
49
|
+
composite.forEach((node, _offset, index) => {
|
|
50
|
+
if (index < 3 || node.type.name !== "composite") return;
|
|
51
|
+
const derivation = derivationOf(node);
|
|
52
|
+
if (derivation) found.push({
|
|
53
|
+
node,
|
|
54
|
+
index,
|
|
55
|
+
derivation
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
return found;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Whether `derived` (a Baustein with a derivation, a child of `composite`) is out of date or was edited since it was made.
|
|
62
|
+
* `stale`: for an asset source, the block `sourceOf(composite, kinds)` finds has a `hash` that differs from `inputHash`; null
|
|
63
|
+
* when either is unknown. A block source is null here: callers with the document compare the hash of the source block's
|
|
64
|
+
* Markdown. `edited`: the body's
|
|
65
|
+
* hash (computed lazily, it serialises the whole body) differs from `outputHash`; null when `outputHash` is unknown.
|
|
66
|
+
*/
|
|
67
|
+
function derivationState(composite, derived, bodyHash, kinds) {
|
|
68
|
+
const derivation = derivationOf(derived);
|
|
69
|
+
if (!derivation) return {
|
|
70
|
+
stale: null,
|
|
71
|
+
edited: null
|
|
72
|
+
};
|
|
73
|
+
let stale = null;
|
|
74
|
+
if ("asset" in derivation.from) {
|
|
75
|
+
const hash = sourceOf(composite, kinds)?.hash;
|
|
76
|
+
stale = hash && derivation.inputHash ? hash !== derivation.inputHash : null;
|
|
77
|
+
}
|
|
78
|
+
const edited = derivation.outputHash ? bodyHash() !== derivation.outputHash : null;
|
|
79
|
+
return {
|
|
80
|
+
stale,
|
|
81
|
+
edited
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
/** Markdown of the body of `composite` (everything after title, description and tags). */
|
|
85
|
+
function bodyMarkdown(editor, composite) {
|
|
86
|
+
const content = [];
|
|
87
|
+
composite.forEach((child, _offset, index) => {
|
|
88
|
+
if (index >= 3) content.push(child.toJSON());
|
|
89
|
+
});
|
|
90
|
+
return editor.markdown.serialize({
|
|
91
|
+
type: "doc",
|
|
92
|
+
content
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
//#endregion
|
|
96
|
+
export { DERIVATION_KEY, assetRefOf, bodyMarkdown, derivationOf, derivationState, renditionsOf, sourceOf };
|
|
97
|
+
|
|
98
|
+
//# sourceMappingURL=derivation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derivation.js","names":[],"sources":["../../../src/features/composites/derivation.ts"],"sourcesContent":["// Vue-free and server-importable: where a Baustein's content comes from. A source-holding Baustein (`recording`, `paper`,\n// `book`, `figure`, `document`) carries its original as an `image|audio|video|file` block in the body; a derived\n// Baustein (transcript, full text, description, AI result) records in `meta.derivation` what it was made from.\nimport type { Editor, JSONContent } from '@tiptap/core'\n// Types only: brings in the `editor.markdown` augmentation of `@tiptap/markdown` for contexts that do not otherwise load it.\nimport type {} from '@tiptap/markdown'\nimport type { Node as PMNode } from '@tiptap/pm/model'\nimport { EDITOR_API } from '../../core/api-routes'\nimport { type CompositeKind, compositeKind } from './kinds'\nimport { COMPOSITE_CHROME_COUNT } from './nodes'\nimport { DERIVATION_KEY } from './meta-keys'\n\n/** How a derived Baustein was made; `ai:<kindId>` for a block derived from another block by the model. */\nexport type DerivationMethod = 'transcription' | 'pdf-text' | 'ocr' | 'description' | 'bibliography' | (string & {})\n\n/** What a derived Baustein was made from: an uploaded asset (by asset name) or another block (by block id). */\nexport type DerivationSource = { asset: string } | { block: string }\n\n/** `meta.derivation` of a derived Baustein. */\nexport interface Derivation {\n from: DerivationSource\n method: DerivationMethod\n model?: string\n /** ISO timestamp. */\n createdAt: string\n /** SHA-256 hex of the asset bytes / of the source block's Markdown; `''` when unknown. */\n inputHash: string\n /** SHA-256 hex of the produced body's Markdown; `''` when unknown. */\n outputHash: string\n /** Asset name of the stored raw output (text/markdown). */\n output?: string\n}\n\nexport { DERIVATION_KEY }\n\n/** The derivation of a composite (`meta.derivation` with a `from` object and a `method`); null when it has none. */\nexport function derivationOf(node: PMNode): Derivation | null {\n const meta: unknown = node.attrs.meta\n const value = meta && typeof meta === 'object' ? (meta as Record<string, unknown>)[DERIVATION_KEY] : undefined\n if (!value || typeof value !== 'object') return null\n const { from, method } = value as Record<string, unknown>\n if (!from || typeof from !== 'object' || typeof method !== 'string') return null\n return value as Derivation\n}\n\nconst ASSET_URL_PREFIX = `${EDITOR_API}/assets/`\n// Same patterns as `features/media/assets.ts`; copied because composites must not import media.\nconst ASSET_NAME = /^[0-9a-f-]{36}\\.[a-z0-9]{1,8}$/\nconst ASSET_DOCUMENT_ID = /^[A-Za-z0-9_-]{1,64}$/\n\n/** The stored asset behind an `/api/editor/assets/<documentId>/<name>` URL; null for any other `src`. */\nexport function assetRefOf(src: string): { documentId: string, name: string } | null {\n if (!src.startsWith(ASSET_URL_PREFIX)) return null\n const [documentId, name, ...rest] = src.slice(ASSET_URL_PREFIX.length).split('/')\n if (rest.length || !documentId || !name || !ASSET_DOCUMENT_ID.test(documentId) || !ASSET_NAME.test(name)) return null\n return { documentId, name }\n}\n\n/** The media block a source-holding kind keeps its original in: first body child of a type in `kind.source`. */\nexport function sourceOf(\n composite: PMNode,\n kinds: readonly CompositeKind[],\n): { node: PMNode, index: number, asset: { documentId: string, name: string } | null, hash: string | null } | null {\n if (composite.type.name !== 'composite') return null\n const types = compositeKind(kinds, String(composite.attrs.kind)).source\n if (!types) return null\n for (let index = COMPOSITE_CHROME_COUNT; index < composite.childCount; index++) {\n const node = composite.child(index)\n if (!(types as readonly string[]).includes(node.type.name)) continue\n const hash: unknown = node.attrs.hash\n return { node, index, asset: assetRefOf(String(node.attrs.src ?? '')), hash: typeof hash === 'string' && hash ? hash : null }\n }\n return null\n}\n\n/** The body children of `composite` that are derived Bausteine, with their child index. */\nexport function renditionsOf(composite: PMNode): { node: PMNode, index: number, derivation: Derivation }[] {\n const found: { node: PMNode, index: number, derivation: Derivation }[] = []\n composite.forEach((node, _offset, index) => {\n if (index < COMPOSITE_CHROME_COUNT || node.type.name !== 'composite') return\n const derivation = derivationOf(node)\n if (derivation) found.push({ node, index, derivation })\n })\n return found\n}\n\n/**\n * Whether `derived` (a Baustein with a derivation, a child of `composite`) is out of date or was edited since it was made.\n * `stale`: for an asset source, the block `sourceOf(composite, kinds)` finds has a `hash` that differs from `inputHash`; null\n * when either is unknown. A block source is null here: callers with the document compare the hash of the source block's\n * Markdown. `edited`: the body's\n * hash (computed lazily, it serialises the whole body) differs from `outputHash`; null when `outputHash` is unknown.\n */\nexport function derivationState(\n composite: PMNode,\n derived: PMNode,\n bodyHash: () => string,\n kinds: readonly CompositeKind[],\n): { stale: boolean | null, edited: boolean | null } {\n const derivation = derivationOf(derived)\n if (!derivation) return { stale: null, edited: null }\n let stale: boolean | null = null\n if ('asset' in derivation.from) {\n const hash = sourceOf(composite, kinds)?.hash\n stale = hash && derivation.inputHash ? hash !== derivation.inputHash : null\n }\n const edited = derivation.outputHash ? bodyHash() !== derivation.outputHash : null\n return { stale, edited }\n}\n\n/** Markdown of the body of `composite` (everything after title, description and tags). */\nexport function bodyMarkdown(editor: Editor, composite: PMNode): string {\n const content: JSONContent[] = []\n composite.forEach((child, _offset, index) => {\n if (index >= COMPOSITE_CHROME_COUNT) content.push(child.toJSON() as JSONContent)\n })\n return editor.markdown!.serialize({ type: 'doc', content })\n}\n"],"mappings":";;;;;;AAoCA,SAAgB,aAAa,MAAiC;CAC5D,MAAM,OAAgB,KAAK,MAAM;CACjC,MAAM,QAAQ,QAAQ,OAAO,SAAS,WAAY,KAAiC,kBAAkB,KAAA;CACrG,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU,OAAO;CAChD,MAAM,EAAE,MAAM,WAAW;CACzB,IAAI,CAAC,QAAQ,OAAO,SAAS,YAAY,OAAO,WAAW,UAAU,OAAO;CAC5E,OAAO;AACT;AAEA,MAAM,mBAAmB,GAAG,WAAW;AAEvC,MAAM,aAAa;AACnB,MAAM,oBAAoB;;AAG1B,SAAgB,WAAW,KAA0D;CACnF,IAAI,CAAC,IAAI,WAAW,gBAAgB,GAAG,OAAO;CAC9C,MAAM,CAAC,YAAY,MAAM,GAAG,QAAQ,IAAI,MAAM,iBAAiB,MAAM,CAAC,CAAC,MAAM,GAAG;CAChF,IAAI,KAAK,UAAU,CAAC,cAAc,CAAC,QAAQ,CAAC,kBAAkB,KAAK,UAAU,KAAK,CAAC,WAAW,KAAK,IAAI,GAAG,OAAO;CACjH,OAAO;EAAE;EAAY;CAAK;AAC5B;;AAGA,SAAgB,SACd,WACA,OACiH;CACjH,IAAI,UAAU,KAAK,SAAS,aAAa,OAAO;CAChD,MAAM,QAAQ,cAAc,OAAO,OAAO,UAAU,MAAM,IAAI,CAAC,CAAC,CAAC;CACjE,IAAI,CAAC,OAAO,OAAO;CACnB,KAAK,IAAI,QAAA,GAAgC,QAAQ,UAAU,YAAY,SAAS;EAC9E,MAAM,OAAO,UAAU,MAAM,KAAK;EAClC,IAAI,CAAE,MAA4B,SAAS,KAAK,KAAK,IAAI,GAAG;EAC5D,MAAM,OAAgB,KAAK,MAAM;EACjC,OAAO;GAAE;GAAM;GAAO,OAAO,WAAW,OAAO,KAAK,MAAM,OAAO,EAAE,CAAC;GAAG,MAAM,OAAO,SAAS,YAAY,OAAO,OAAO;EAAK;CAC9H;CACA,OAAO;AACT;;AAGA,SAAgB,aAAa,WAA8E;CACzG,MAAM,QAAmE,CAAC;CAC1E,UAAU,SAAS,MAAM,SAAS,UAAU;EAC1C,IAAI,QAAA,KAAkC,KAAK,KAAK,SAAS,aAAa;EACtE,MAAM,aAAa,aAAa,IAAI;EACpC,IAAI,YAAY,MAAM,KAAK;GAAE;GAAM;GAAO;EAAW,CAAC;CACxD,CAAC;CACD,OAAO;AACT;;;;;;;;AASA,SAAgB,gBACd,WACA,SACA,UACA,OACmD;CACnD,MAAM,aAAa,aAAa,OAAO;CACvC,IAAI,CAAC,YAAY,OAAO;EAAE,OAAO;EAAM,QAAQ;CAAK;CACpD,IAAI,QAAwB;CAC5B,IAAI,WAAW,WAAW,MAAM;EAC9B,MAAM,OAAO,SAAS,WAAW,KAAK,CAAC,EAAE;EACzC,QAAQ,QAAQ,WAAW,YAAY,SAAS,WAAW,YAAY;CACzE;CACA,MAAM,SAAS,WAAW,aAAa,SAAS,MAAM,WAAW,aAAa;CAC9E,OAAO;EAAE;EAAO;CAAO;AACzB;;AAGA,SAAgB,aAAa,QAAgB,WAA2B;CACtE,MAAM,UAAyB,CAAC;CAChC,UAAU,SAAS,OAAO,SAAS,UAAU;EAC3C,IAAI,SAAA,GAAiC,QAAQ,KAAK,MAAM,OAAO,CAAgB;CACjF,CAAC;CACD,OAAO,OAAO,SAAU,UAAU;EAAE,MAAM;EAAO;CAAQ,CAAC;AAC5D"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { findBlockById } from "../../core/schema/block-ids.js";
|
|
2
|
+
import { EDITOR_API } from "../../core/api-routes.js";
|
|
3
|
+
import { sha256Hex } from "../../core/hash.js";
|
|
4
|
+
import { bodyMarkdown, derivationOf, derivationState, sourceOf } from "./derivation.js";
|
|
5
|
+
import { compositeKindsOf } from "./nodes.js";
|
|
6
|
+
import { compositeOfRow } from "./rows.js";
|
|
7
|
+
//#region src/features/composites/derived-chrome.ts
|
|
8
|
+
/**
|
|
9
|
+
* The chrome state of the row's Baustein when it is derived (null when it is not): `stale` when its asset source has
|
|
10
|
+
* changed since it was made, i.e. the enclosing Baustein's source block hash differs from the stored `inputHash`.
|
|
11
|
+
* Cheap on purpose (no body hashing): the chrome runs it for every row on every refresh. „bearbeitet“ and the staleness
|
|
12
|
+
* of a block-derived Baustein hash Markdown, so only the details card computes them (`derivationDetailsOf`).
|
|
13
|
+
*/
|
|
14
|
+
function derivedChromeOf(editor, row) {
|
|
15
|
+
const { doc } = editor.state;
|
|
16
|
+
const at = doc.nodeAt(row.pos);
|
|
17
|
+
const found = at?.type.name === "composite" && (at.attrs.id ?? null) === row.id ? {
|
|
18
|
+
pos: row.pos,
|
|
19
|
+
node: at
|
|
20
|
+
} : compositeOfRow(doc, row);
|
|
21
|
+
if (!found || !derivationOf(found.node)) return null;
|
|
22
|
+
const parent = doc.resolve(found.pos).parent;
|
|
23
|
+
return { stale: parent.type.name === "composite" && derivationState(parent, found.node, () => "", compositeKindsOf(editor)).stale === true };
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Details of the derived Baustein `node` of `editor`'s document (null when it is not derived). Serialises and hashes
|
|
27
|
+
* the body (and for a block source the source block), so call it for one Baustein at a time, not for every row.
|
|
28
|
+
*/
|
|
29
|
+
function derivationDetailsOf(editor, node) {
|
|
30
|
+
const derivation = derivationOf(node);
|
|
31
|
+
if (!derivation) return null;
|
|
32
|
+
const { doc } = editor.state;
|
|
33
|
+
const kinds = compositeKindsOf(editor);
|
|
34
|
+
const id = node.attrs.id;
|
|
35
|
+
const found = typeof id === "string" && id ? findBlockById(doc, id) : null;
|
|
36
|
+
const parent = found ? doc.resolve(found.pos).parent : null;
|
|
37
|
+
const holder = parent?.type.name === "composite" ? parent : null;
|
|
38
|
+
let bodyHash;
|
|
39
|
+
const state = derivationState(holder ?? node, node, () => bodyHash ??= sha256Hex(bodyMarkdown(editor, node)), kinds);
|
|
40
|
+
let stale = state.stale;
|
|
41
|
+
if ("block" in derivation.from) {
|
|
42
|
+
const source = findBlockById(doc, derivation.from.block);
|
|
43
|
+
stale = source && derivation.inputHash ? sha256Hex(bodyMarkdown(editor, source.node)) !== derivation.inputHash : null;
|
|
44
|
+
}
|
|
45
|
+
const documentId = holder ? sourceOf(holder, kinds)?.asset?.documentId : void 0;
|
|
46
|
+
const outputUrl = derivation.output && documentId ? `${EDITOR_API}/assets/${documentId}/${derivation.output}` : null;
|
|
47
|
+
return {
|
|
48
|
+
derivation,
|
|
49
|
+
stale,
|
|
50
|
+
edited: state.edited,
|
|
51
|
+
outputUrl
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
const KNOWN_METHODS = [
|
|
55
|
+
"transcription",
|
|
56
|
+
"pdf-text",
|
|
57
|
+
"ocr",
|
|
58
|
+
"description",
|
|
59
|
+
"bibliography"
|
|
60
|
+
];
|
|
61
|
+
/** The words for a derivation method: the known ones translated, `ai:<kind>` as „KI-Ableitung“, anything else as stored. */
|
|
62
|
+
function derivationMethodLabel(t, method) {
|
|
63
|
+
if (method.startsWith("ai:")) return t("composites.derivation.method.ai");
|
|
64
|
+
return KNOWN_METHODS.includes(method) ? t(`composites.derivation.method.${method}`) : method;
|
|
65
|
+
}
|
|
66
|
+
//#endregion
|
|
67
|
+
export { derivationDetailsOf, derivationMethodLabel, derivedChromeOf };
|
|
68
|
+
|
|
69
|
+
//# sourceMappingURL=derived-chrome.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derived-chrome.js","names":[],"sources":["../../../src/features/composites/derived-chrome.ts"],"sourcesContent":["// Vue-free: what the composite chrome and the details card show for a derived Baustein (one with a `meta.derivation`).\nimport type { Editor } from '@tiptap/core'\nimport type { Node as PMNode } from '@tiptap/pm/model'\nimport { EDITOR_API } from '../../core/api-routes'\nimport { sha256Hex } from '../../core/hash'\nimport { findBlockById } from '../../core/schema/block-ids'\nimport type { MessageKey, Translate } from '../../i18n'\nimport { type Derivation, bodyMarkdown, derivationOf, derivationState, sourceOf } from './derivation'\nimport { compositeKindsOf } from './nodes'\nimport { type CompositeRow, compositeOfRow } from './rows'\n\n/**\n * The chrome state of the row's Baustein when it is derived (null when it is not): `stale` when its asset source has\n * changed since it was made, i.e. the enclosing Baustein's source block hash differs from the stored `inputHash`.\n * Cheap on purpose (no body hashing): the chrome runs it for every row on every refresh. „bearbeitet“ and the staleness\n * of a block-derived Baustein hash Markdown, so only the details card computes them (`derivationDetailsOf`).\n */\nexport function derivedChromeOf(editor: Editor, row: Pick<CompositeRow, 'id' | 'pos'>): { stale: boolean } | null {\n const { doc } = editor.state\n // The row's position may be stale for a moment after an edit; take it only when it still holds the same Baustein.\n const at = doc.nodeAt(row.pos)\n const found = at?.type.name === 'composite' && (at.attrs.id ?? null) === row.id ? { pos: row.pos, node: at } : compositeOfRow(doc, row)\n if (!found || !derivationOf(found.node)) return null\n const parent = doc.resolve(found.pos).parent\n const stale = parent.type.name === 'composite' && derivationState(parent, found.node, () => '', compositeKindsOf(editor)).stale === true\n return { stale }\n}\n\n/** Everything the details card shows about the derivation of `node`; `stale`/`edited` are null when they cannot be told. */\nexport interface DerivationDetails {\n derivation: Derivation\n /** The source changed since `node` was made: asset hash for an asset source, Markdown hash of the source block for a block source. */\n stale: boolean | null\n /** The body differs from what was generated. */\n edited: boolean | null\n /** URL of the stored raw output, when there is one and its document is known. */\n outputUrl: string | null\n}\n\n/**\n * Details of the derived Baustein `node` of `editor`'s document (null when it is not derived). Serialises and hashes\n * the body (and for a block source the source block), so call it for one Baustein at a time, not for every row.\n */\nexport function derivationDetailsOf(editor: Editor, node: PMNode): DerivationDetails | null {\n const derivation = derivationOf(node)\n if (!derivation) return null\n const { doc } = editor.state\n const kinds = compositeKindsOf(editor)\n const id: unknown = node.attrs.id\n const found = typeof id === 'string' && id ? findBlockById(doc, id) : null\n const parent = found ? doc.resolve(found.pos).parent : null\n const holder = parent?.type.name === 'composite' ? parent : null\n\n let bodyHash: string | undefined\n const state = derivationState(holder ?? node, node, () => (bodyHash ??= sha256Hex(bodyMarkdown(editor, node))), kinds)\n let stale = state.stale\n if ('block' in derivation.from) {\n const source = findBlockById(doc, derivation.from.block)\n stale = source && derivation.inputHash ? sha256Hex(bodyMarkdown(editor, source.node)) !== derivation.inputHash : null\n }\n\n const documentId = holder ? sourceOf(holder, kinds)?.asset?.documentId : undefined\n const outputUrl = derivation.output && documentId ? `${EDITOR_API}/assets/${documentId}/${derivation.output}` : null\n return { derivation, stale, edited: state.edited, outputUrl }\n}\n\nconst KNOWN_METHODS: readonly string[] = ['transcription', 'pdf-text', 'ocr', 'description', 'bibliography']\n\n/** The words for a derivation method: the known ones translated, `ai:<kind>` as „KI-Ableitung“, anything else as stored. */\nexport function derivationMethodLabel(t: Translate, method: string): string {\n if (method.startsWith('ai:')) return t('composites.derivation.method.ai')\n return KNOWN_METHODS.includes(method) ? t(`composites.derivation.method.${method}` as MessageKey) : method\n}\n"],"mappings":";;;;;;;;;;;;;AAiBA,SAAgB,gBAAgB,QAAgB,KAAkE;CAChH,MAAM,EAAE,QAAQ,OAAO;CAEvB,MAAM,KAAK,IAAI,OAAO,IAAI,GAAG;CAC7B,MAAM,QAAQ,IAAI,KAAK,SAAS,gBAAgB,GAAG,MAAM,MAAM,UAAU,IAAI,KAAK;EAAE,KAAK,IAAI;EAAK,MAAM;CAAG,IAAI,eAAe,KAAK,GAAG;CACtI,IAAI,CAAC,SAAS,CAAC,aAAa,MAAM,IAAI,GAAG,OAAO;CAChD,MAAM,SAAS,IAAI,QAAQ,MAAM,GAAG,CAAC,CAAC;CAEtC,OAAO,EAAE,OADK,OAAO,KAAK,SAAS,eAAe,gBAAgB,QAAQ,MAAM,YAAY,IAAI,iBAAiB,MAAM,CAAC,CAAC,CAAC,UAAU,KACrH;AACjB;;;;;AAiBA,SAAgB,oBAAoB,QAAgB,MAAwC;CAC1F,MAAM,aAAa,aAAa,IAAI;CACpC,IAAI,CAAC,YAAY,OAAO;CACxB,MAAM,EAAE,QAAQ,OAAO;CACvB,MAAM,QAAQ,iBAAiB,MAAM;CACrC,MAAM,KAAc,KAAK,MAAM;CAC/B,MAAM,QAAQ,OAAO,OAAO,YAAY,KAAK,cAAc,KAAK,EAAE,IAAI;CACtE,MAAM,SAAS,QAAQ,IAAI,QAAQ,MAAM,GAAG,CAAC,CAAC,SAAS;CACvD,MAAM,SAAS,QAAQ,KAAK,SAAS,cAAc,SAAS;CAE5D,IAAI;CACJ,MAAM,QAAQ,gBAAgB,UAAU,MAAM,YAAa,aAAa,UAAU,aAAa,QAAQ,IAAI,CAAC,GAAI,KAAK;CACrH,IAAI,QAAQ,MAAM;CAClB,IAAI,WAAW,WAAW,MAAM;EAC9B,MAAM,SAAS,cAAc,KAAK,WAAW,KAAK,KAAK;EACvD,QAAQ,UAAU,WAAW,YAAY,UAAU,aAAa,QAAQ,OAAO,IAAI,CAAC,MAAM,WAAW,YAAY;CACnH;CAEA,MAAM,aAAa,SAAS,SAAS,QAAQ,KAAK,CAAC,EAAE,OAAO,aAAa,KAAA;CACzE,MAAM,YAAY,WAAW,UAAU,aAAa,GAAG,WAAW,UAAU,WAAW,GAAG,WAAW,WAAW;CAChH,OAAO;EAAE;EAAY;EAAO,QAAQ,MAAM;EAAQ;CAAU;AAC9D;AAEA,MAAM,gBAAmC;CAAC;CAAiB;CAAY;CAAO;CAAe;AAAc;;AAG3G,SAAgB,sBAAsB,GAAc,QAAwB;CAC1E,IAAI,OAAO,WAAW,KAAK,GAAG,OAAO,EAAE,iCAAiC;CACxE,OAAO,cAAc,SAAS,MAAM,IAAI,EAAE,gCAAgC,QAAsB,IAAI;AACtG"}
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
import { ABILITY } from "../../core/schema/abilities.js";
|
|
2
2
|
import { abilitiesAtSelection } from "../../core/abilities.js";
|
|
3
3
|
import { settingsTabsOf } from "../../core/define-editor.js";
|
|
4
|
-
import { downloadText } from "../../core/download.js";
|
|
5
4
|
import { editorEntryOf } from "../../core/editor-ui.js";
|
|
5
|
+
import { findBlockById } from "../../core/schema/block-ids.js";
|
|
6
|
+
import { downloadText } from "../../core/download.js";
|
|
6
7
|
import { compositeKind, defaultCompositeKinds } from "./kinds.js";
|
|
7
8
|
import { blocksFromMarkdown } from "./fences.js";
|
|
9
|
+
import { bodyMarkdown, derivationOf } from "./derivation.js";
|
|
8
10
|
import { structureBlocks } from "./heading-composites.js";
|
|
9
11
|
import { CompositeDescriptionNode, CompositeTitleNode, compositeKindsOf } from "./nodes.js";
|
|
12
|
+
import { bibOf, bibtexOf, cslOf } from "./bibliography.js";
|
|
10
13
|
import { compositeConversions } from "./convert.js";
|
|
11
14
|
import { migrateLegacyContent } from "./legacy.js";
|
|
12
|
-
import {
|
|
15
|
+
import { compositeIdsOf, normalizeReferences } from "./reference-text.js";
|
|
16
|
+
import { compositeSchemaExtensions } from "./schema.js";
|
|
17
|
+
import { AcceptedChildren, compositeInsertGuard } from "./accepted-children.js";
|
|
13
18
|
import { documentCompositeMarkdown, markdownFileName } from "./markdown-export.js";
|
|
14
19
|
import { compositeNodes } from "./node-views.js";
|
|
20
|
+
import { REFERENCE_AI_BLOCK } from "./reference-ai.js";
|
|
21
|
+
import { referenceSuggestion } from "./reference-suggestion.js";
|
|
22
|
+
import { SourceReveal } from "./reveal-source.js";
|
|
15
23
|
import { Structure, structureOf } from "./structure.js";
|
|
16
24
|
import { STRUCTURE_MODE_KEYS } from "./structure-mode.js";
|
|
17
25
|
//#region src/features/composites/feature.ts
|
|
@@ -28,9 +36,11 @@ const STRUCTURE_STAGE_LEVEL = 2;
|
|
|
28
36
|
*/
|
|
29
37
|
function compositeFeatureCore(ui, options = {}) {
|
|
30
38
|
const kindsOf = (ctx) => options.kinds ?? defaultCompositeKinds(ctx.t);
|
|
31
|
-
const { Composite, CompositeTags } = compositeNodes(ui.nodeViews);
|
|
39
|
+
const { Composite, CompositeTags, Reference } = compositeNodes(ui.nodeViews);
|
|
32
40
|
return {
|
|
33
41
|
id: "composites",
|
|
42
|
+
dimension: "content",
|
|
43
|
+
schemaExtensions: () => compositeSchemaExtensions(options.kinds ? { kinds: options.kinds } : {}),
|
|
34
44
|
extensions: (ctx) => [
|
|
35
45
|
Composite.configure({ kinds: kindsOf(ctx) }),
|
|
36
46
|
CompositeTitleNode,
|
|
@@ -40,14 +50,13 @@ function compositeFeatureCore(ui, options = {}) {
|
|
|
40
50
|
AcceptedChildren.configure({
|
|
41
51
|
notify: ctx.notify,
|
|
42
52
|
t: ctx.t
|
|
43
|
-
})
|
|
53
|
+
}),
|
|
54
|
+
SourceReveal,
|
|
55
|
+
Reference.configure({ suggestion: referenceSuggestion(ctx.t) })
|
|
44
56
|
],
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
items: compositeToolbarItems(ctx, kindsOf(ctx))
|
|
49
|
-
}],
|
|
50
|
-
slashCommands: (ctx) => compositeSlashCommands(ctx, kindsOf(ctx)),
|
|
57
|
+
toolbarGroups: COMPOSITE_TOOLBAR_GROUPS,
|
|
58
|
+
commands: (ctx) => compositeCommands(ctx, kindsOf(ctx)),
|
|
59
|
+
insertGuards: () => [compositeInsertGuard],
|
|
51
60
|
blockActions: (ctx) => [{
|
|
52
61
|
id: "document-export",
|
|
53
62
|
label: ctx.t("composites.blockAction.export"),
|
|
@@ -56,6 +65,14 @@ function compositeFeatureCore(ui, options = {}) {
|
|
|
56
65
|
order: 400,
|
|
57
66
|
isVisible: ({ node }) => node.attrs.kind === "document",
|
|
58
67
|
run: ({ editor, node }) => downloadText(markdownFileName(node), documentCompositeMarkdown(editor, node))
|
|
68
|
+
}, {
|
|
69
|
+
id: "bibliography-export",
|
|
70
|
+
label: ctx.t("composites.blockAction.bibtex"),
|
|
71
|
+
icon: "i-lucide-book-marked",
|
|
72
|
+
ability: ABILITY.compositeExport,
|
|
73
|
+
order: 410,
|
|
74
|
+
isVisible: ({ node }) => bibOf(node) !== null,
|
|
75
|
+
run: ({ node }) => downloadText(`${markdownFileName(node).replace(/\.md$/, "")}.bib`, bibtexOf(cslOf(node)), "text/x-bibtex;charset=utf-8")
|
|
59
76
|
}],
|
|
60
77
|
overlays: [ui.chrome],
|
|
61
78
|
settingsTabs: (ctx) => [{
|
|
@@ -71,7 +88,8 @@ function compositeFeatureCore(ui, options = {}) {
|
|
|
71
88
|
const { schema } = editor;
|
|
72
89
|
return structureBlocks(schema, blocks.map((block) => schema.nodeFromJSON(block)), structureOf(editor), STRUCTURE_STAGE_LEVEL, compositeKindsOf(editor)).map((node) => node.toJSON());
|
|
73
90
|
},
|
|
74
|
-
migrateContent: migrateLegacyContent
|
|
91
|
+
migrateContent: migrateLegacyContent,
|
|
92
|
+
normalize: (editor, blocks) => normalizeReferences(blocks, compositeIdsOf(editor.state.doc))
|
|
75
93
|
},
|
|
76
94
|
conversions: compositeConversions(options.kinds),
|
|
77
95
|
aiContext: (editor) => ({
|
|
@@ -81,87 +99,57 @@ function compositeFeatureCore(ui, options = {}) {
|
|
|
81
99
|
fields,
|
|
82
100
|
...ai?.purpose && { purpose: ai.purpose }
|
|
83
101
|
})),
|
|
84
|
-
structure: structureOf(editor)
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
scope: editing.headingConversionScope,
|
|
95
|
-
kind: blocks.defaultKind
|
|
96
|
-
});
|
|
97
|
-
};
|
|
98
|
-
const flatten = (recursive) => (editor) => editor.commands.convertCompositesToHeadings({
|
|
99
|
-
recursive,
|
|
100
|
-
scope: settings.get().editing.headingConversionScope
|
|
101
|
-
});
|
|
102
|
-
return [
|
|
103
|
-
{
|
|
104
|
-
id: "abschnitt",
|
|
105
|
-
label: t("composites.slash.section"),
|
|
106
|
-
icon: "i-lucide-layers",
|
|
107
|
-
ability: ABILITY.composite,
|
|
108
|
-
run: insert("section")
|
|
109
|
-
},
|
|
110
|
-
...kinds.filter((kind) => kind.id !== "section").map((kind) => ({
|
|
111
|
-
id: kind.id,
|
|
112
|
-
label: kind.label,
|
|
113
|
-
icon: kind.icon,
|
|
114
|
-
ability: ABILITY.composite,
|
|
115
|
-
run: insert(kind.id)
|
|
116
|
-
})),
|
|
117
|
-
{
|
|
118
|
-
id: "gliedern",
|
|
119
|
-
label: t("composites.slash.group"),
|
|
120
|
-
icon: "i-lucide-layers",
|
|
121
|
-
ability: ABILITY.composite,
|
|
122
|
-
run: group(false)
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
id: "gliedern-alle",
|
|
126
|
-
label: t("composites.slash.groupAll"),
|
|
127
|
-
icon: "i-lucide-list-tree",
|
|
128
|
-
ability: ABILITY.composite,
|
|
129
|
-
run: group(true)
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
id: "aufloesen",
|
|
133
|
-
label: t("composites.slash.flatten"),
|
|
134
|
-
icon: "i-lucide-heading",
|
|
135
|
-
ability: ABILITY.headings,
|
|
136
|
-
run: flatten(false)
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
id: "aufloesen-alle",
|
|
140
|
-
label: t("composites.slash.flattenAll"),
|
|
141
|
-
icon: "i-lucide-align-left",
|
|
142
|
-
ability: ABILITY.headings,
|
|
143
|
-
run: flatten(true)
|
|
102
|
+
structure: structureOf(editor),
|
|
103
|
+
blocks: [REFERENCE_AI_BLOCK]
|
|
104
|
+
}),
|
|
105
|
+
aiBlockData: ({ editor, node }) => {
|
|
106
|
+
const from = derivationOf(node)?.from;
|
|
107
|
+
const source = from && "block" in from ? findBlockById(editor.state.doc, from.block)?.node : void 0;
|
|
108
|
+
return source?.type.name === "composite" ? [{
|
|
109
|
+
label: `Quelle: ${source.child(0).textContent.trim()}`,
|
|
110
|
+
text: bodyMarkdown(editor, source)
|
|
111
|
+
}] : [];
|
|
144
112
|
}
|
|
145
|
-
|
|
113
|
+
};
|
|
146
114
|
}
|
|
115
|
+
const COMPOSITE_TOOLBAR_GROUPS = [{
|
|
116
|
+
id: "composites",
|
|
117
|
+
order: 60,
|
|
118
|
+
labelKey: "palette.group.composites"
|
|
119
|
+
}];
|
|
147
120
|
/**
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
121
|
+
* Converting headings to Bausteine and back: the checks and actions the toolbar's „Gliederung umwandeln“ menu and the
|
|
122
|
+
* `/gliedern*` and `/aufloesen*` commands share, so both placements gate and act identically. They read the scope and
|
|
123
|
+
* default kind from the settings at call time.
|
|
151
124
|
*/
|
|
152
|
-
function
|
|
153
|
-
const
|
|
154
|
-
const insert = (chain) => chain.insertComposite(defaultKind().id);
|
|
155
|
-
const scope = () => settings.get().editing.headingConversionScope;
|
|
156
|
-
const canGroup = (editor, recursive) => editor.can().convertHeadingsToComposites({
|
|
125
|
+
function structureActions({ settings }) {
|
|
126
|
+
const groupOptions = (recursive) => ({
|
|
157
127
|
recursive,
|
|
158
|
-
scope:
|
|
128
|
+
scope: settings.get().editing.headingConversionScope,
|
|
159
129
|
kind: settings.get().blocks.defaultKind
|
|
160
130
|
});
|
|
161
|
-
const
|
|
131
|
+
const flattenOptions = (recursive) => ({
|
|
162
132
|
recursive,
|
|
163
|
-
scope:
|
|
133
|
+
scope: settings.get().editing.headingConversionScope
|
|
164
134
|
});
|
|
135
|
+
return {
|
|
136
|
+
canGroup: (editor, recursive) => editor.can().convertHeadingsToComposites(groupOptions(recursive)),
|
|
137
|
+
canFlatten: (editor, recursive) => editor.can().convertCompositesToHeadings(flattenOptions(recursive)),
|
|
138
|
+
group: (editor, recursive) => void editor.chain().focus().convertHeadingsToComposites(groupOptions(recursive)).run(),
|
|
139
|
+
flatten: (editor, recursive) => void editor.chain().focus().convertCompositesToHeadings(flattenOptions(recursive)).run()
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The commands of the composites feature, each declared once. Toolbar group beside the inserts: the default kind's
|
|
144
|
+
* insert button (it follows the setting, so label/icon/shortcut/`creates` are getters read at render time), „In
|
|
145
|
+
* Baustein umwandeln“ (one entry per kind for the caret's block) and „Gliederung umwandeln“ (headings <-> composites in
|
|
146
|
+
* both directions, the preferred structure's direction first). `/` menu: one command per kind (`creates` that kind, so
|
|
147
|
+
* the insert guard hides kinds the surrounding Baustein does not accept) and the four heading conversions.
|
|
148
|
+
*/
|
|
149
|
+
function compositeCommands(ctx, kinds) {
|
|
150
|
+
const { settings, t } = ctx;
|
|
151
|
+
const defaultKind = () => compositeKind(kinds, settings.get().blocks.defaultKind);
|
|
152
|
+
const { canGroup, canFlatten, group, flatten } = structureActions(ctx);
|
|
165
153
|
function kindItems(editor) {
|
|
166
154
|
return [{
|
|
167
155
|
type: "label",
|
|
@@ -184,7 +172,6 @@ function compositeToolbarItems({ settings, t }, kinds) {
|
|
|
184
172
|
const abilities = abilitiesAtSelection(editor);
|
|
185
173
|
const composite = abilities.has(ABILITY.composite);
|
|
186
174
|
const headings = abilities.has(ABILITY.headings);
|
|
187
|
-
const run = (command) => () => void command();
|
|
188
175
|
const sep = { type: "separator" };
|
|
189
176
|
const toComposites = [
|
|
190
177
|
{
|
|
@@ -196,22 +183,14 @@ function compositeToolbarItems({ settings, t }, kinds) {
|
|
|
196
183
|
description: t("composites.menu.toComposites.top.description"),
|
|
197
184
|
icon: "i-lucide-layers",
|
|
198
185
|
disabled: !composite || !canGroup(editor, false),
|
|
199
|
-
onSelect:
|
|
200
|
-
recursive: false,
|
|
201
|
-
scope: scope(),
|
|
202
|
-
kind: settings.get().blocks.defaultKind
|
|
203
|
-
}).run())
|
|
186
|
+
onSelect: () => group(editor, false)
|
|
204
187
|
},
|
|
205
188
|
{
|
|
206
189
|
label: t("composites.menu.toComposites.all"),
|
|
207
190
|
description: t("composites.menu.toComposites.all.description"),
|
|
208
191
|
icon: "i-lucide-list-tree",
|
|
209
192
|
disabled: !composite || !canGroup(editor, true),
|
|
210
|
-
onSelect:
|
|
211
|
-
recursive: true,
|
|
212
|
-
scope: scope(),
|
|
213
|
-
kind: settings.get().blocks.defaultKind
|
|
214
|
-
}).run())
|
|
193
|
+
onSelect: () => group(editor, true)
|
|
215
194
|
}
|
|
216
195
|
];
|
|
217
196
|
const toHeadings = [
|
|
@@ -224,20 +203,14 @@ function compositeToolbarItems({ settings, t }, kinds) {
|
|
|
224
203
|
description: t("composites.menu.toHeadings.top.description"),
|
|
225
204
|
icon: "i-lucide-heading",
|
|
226
205
|
disabled: !headings || !canFlatten(editor, false),
|
|
227
|
-
onSelect:
|
|
228
|
-
recursive: false,
|
|
229
|
-
scope: scope()
|
|
230
|
-
}).run())
|
|
206
|
+
onSelect: () => flatten(editor, false)
|
|
231
207
|
},
|
|
232
208
|
{
|
|
233
209
|
label: t("composites.menu.toHeadings.all"),
|
|
234
210
|
description: t("composites.menu.toHeadings.all.description"),
|
|
235
211
|
icon: "i-lucide-align-left",
|
|
236
212
|
disabled: !headings || !canFlatten(editor, true),
|
|
237
|
-
onSelect:
|
|
238
|
-
recursive: true,
|
|
239
|
-
scope: scope()
|
|
240
|
-
}).run())
|
|
213
|
+
onSelect: () => flatten(editor, true)
|
|
241
214
|
}
|
|
242
215
|
];
|
|
243
216
|
const entry = editorEntryOf(editor);
|
|
@@ -263,10 +236,27 @@ function compositeToolbarItems({ settings, t }, kinds) {
|
|
|
263
236
|
...settingsEntry
|
|
264
237
|
];
|
|
265
238
|
}
|
|
239
|
+
const insertKind = (kind, slashId, label, icon) => ({
|
|
240
|
+
id: `composite.${kind}`,
|
|
241
|
+
slash: { id: slashId },
|
|
242
|
+
creates: {
|
|
243
|
+
type: "composite",
|
|
244
|
+
attrs: { kind }
|
|
245
|
+
},
|
|
246
|
+
icon,
|
|
247
|
+
label,
|
|
248
|
+
ability: ABILITY.composite,
|
|
249
|
+
run: (editor) => {
|
|
250
|
+
editor.chain().focus().insertComposite(kind).run();
|
|
251
|
+
}
|
|
252
|
+
});
|
|
266
253
|
return [
|
|
267
254
|
{
|
|
268
255
|
id: "insert",
|
|
269
|
-
|
|
256
|
+
toolbar: {
|
|
257
|
+
group: "composites",
|
|
258
|
+
order: 10
|
|
259
|
+
},
|
|
270
260
|
get icon() {
|
|
271
261
|
return defaultKind().icon;
|
|
272
262
|
},
|
|
@@ -280,28 +270,88 @@ function compositeToolbarItems({ settings, t }, kinds) {
|
|
|
280
270
|
"a"
|
|
281
271
|
] : void 0;
|
|
282
272
|
},
|
|
273
|
+
get creates() {
|
|
274
|
+
return {
|
|
275
|
+
type: "composite",
|
|
276
|
+
attrs: { kind: defaultKind().id }
|
|
277
|
+
};
|
|
278
|
+
},
|
|
283
279
|
ability: ABILITY.composite,
|
|
284
|
-
|
|
280
|
+
can: (editor) => editor.can().insertComposite(defaultKind().id),
|
|
285
281
|
run: (editor) => {
|
|
286
|
-
|
|
282
|
+
editor.chain().focus().insertComposite(defaultKind().id).run();
|
|
287
283
|
}
|
|
288
284
|
},
|
|
289
285
|
{
|
|
290
286
|
id: "to-kind",
|
|
291
|
-
|
|
287
|
+
toolbar: {
|
|
288
|
+
group: "composites",
|
|
289
|
+
order: 20
|
|
290
|
+
},
|
|
292
291
|
icon: "i-lucide-replace",
|
|
293
292
|
label: t("composites.toolbar.toKind"),
|
|
294
293
|
ability: ABILITY.composite,
|
|
295
|
-
|
|
294
|
+
can: (editor) => kindItems(editor).some((item) => item.type !== "label" && !item.disabled),
|
|
296
295
|
menu: kindItems
|
|
297
296
|
},
|
|
298
297
|
{
|
|
299
298
|
id: "structure",
|
|
300
|
-
|
|
299
|
+
toolbar: {
|
|
300
|
+
group: "composites",
|
|
301
|
+
order: 30
|
|
302
|
+
},
|
|
301
303
|
icon: "i-lucide-list-tree",
|
|
302
304
|
label: t("composites.toolbar.structure"),
|
|
303
|
-
|
|
305
|
+
can: (editor) => canGroup(editor, true) || canFlatten(editor, true),
|
|
304
306
|
menu: structureItems
|
|
307
|
+
},
|
|
308
|
+
insertKind("section", "abschnitt", t("composites.slash.section"), "i-lucide-layers"),
|
|
309
|
+
...kinds.filter((kind) => kind.id !== "section").map((kind) => insertKind(kind.id, kind.id, kind.label, kind.icon)),
|
|
310
|
+
{
|
|
311
|
+
id: "gliedern",
|
|
312
|
+
slash: {},
|
|
313
|
+
label: t("composites.slash.group"),
|
|
314
|
+
icon: "i-lucide-layers",
|
|
315
|
+
ability: ABILITY.composite,
|
|
316
|
+
can: (editor) => canGroup(editor, false),
|
|
317
|
+
run: (editor) => group(editor, false)
|
|
318
|
+
},
|
|
319
|
+
{
|
|
320
|
+
id: "gliedern-alle",
|
|
321
|
+
slash: {},
|
|
322
|
+
label: t("composites.slash.groupAll"),
|
|
323
|
+
icon: "i-lucide-list-tree",
|
|
324
|
+
ability: ABILITY.composite,
|
|
325
|
+
can: (editor) => canGroup(editor, true),
|
|
326
|
+
run: (editor) => group(editor, true)
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
id: "aufloesen",
|
|
330
|
+
slash: {},
|
|
331
|
+
label: t("composites.slash.flatten"),
|
|
332
|
+
icon: "i-lucide-heading",
|
|
333
|
+
ability: ABILITY.headings,
|
|
334
|
+
can: (editor) => canFlatten(editor, false),
|
|
335
|
+
run: (editor) => flatten(editor, false)
|
|
336
|
+
},
|
|
337
|
+
{
|
|
338
|
+
id: "aufloesen-alle",
|
|
339
|
+
slash: {},
|
|
340
|
+
label: t("composites.slash.flattenAll"),
|
|
341
|
+
icon: "i-lucide-align-left",
|
|
342
|
+
ability: ABILITY.headings,
|
|
343
|
+
can: (editor) => canFlatten(editor, true),
|
|
344
|
+
run: (editor) => flatten(editor, true)
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
id: "verweis",
|
|
348
|
+
slash: {},
|
|
349
|
+
label: t("composites.reference.insert"),
|
|
350
|
+
icon: "i-lucide-link-2",
|
|
351
|
+
ability: ABILITY.reference,
|
|
352
|
+
run: (editor) => {
|
|
353
|
+
editor.chain().focus().insertContent("[@").run();
|
|
354
|
+
}
|
|
305
355
|
}
|
|
306
356
|
];
|
|
307
357
|
}
|