@ecsplico/editor 2.1.2 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +78 -1
- package/README.md +39 -156
- package/dist/adapters/comments/drizzle.d.ts +1 -1
- package/dist/adapters/comments/record.d.ts +15 -0
- 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/server.d.ts +2 -1
- package/dist/adapters/comments/server.js +2 -1
- package/dist/adapters/comments/server.js.map +1 -1
- 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 +27 -20
- package/dist/adapters/nitro.js +59 -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 +2 -2
- 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 +96 -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 +41 -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 +15 -9
- package/dist/core/index.js +13 -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 +15 -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/transaction-guards.d.ts +21 -0
- package/dist/core/transaction-guards.js +49 -0
- package/dist/core/transaction-guards.js.map +1 -0
- 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 +2 -2
- 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 +6 -2
- 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 +1 -1
- package/dist/features/block-ui/block-actions.js +1 -1
- package/dist/features/block-ui/block-actions.js.map +1 -1
- 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/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 +39 -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 +78 -29
- 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 +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 +64 -5
- package/dist/features/composites/components/CompositeFieldEditor.js.map +1 -1
- package/dist/features/composites/components/CompositeInspector.js +20 -7
- 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 +16 -2
- 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 +45 -2
- 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 +67 -19
- 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 +43 -1
- package/dist/features/composites/react/CompositeFieldEditor.js.map +1 -1
- package/dist/features/composites/react/CompositeInspector.js +12 -6
- 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 +25 -3
- package/dist/features/composites/rows.js +72 -10
- 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 +3 -3
- package/dist/features/media/react/AudioRecorderModal.js +1 -1
- package/dist/features/media/react/FileView.js +19 -2
- package/dist/features/media/react/FileView.js.map +1 -1
- package/dist/features/media/react.js +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 +12 -11
- 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/server/h3.d.ts +8 -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 +32 -10
- package/dist/server/handlers/ai.js +172 -37
- 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.d.ts +22 -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 +2 -2
- package/dist/tree/tree-items.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 +39 -9
- 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 -632
- package/docs/llms.md +0 -383
- package/docs/usage.md +0 -1076
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { forwardRef, useState } from "react";
|
|
1
|
+
import { ComposedSurface } from "./composed-surface.js";
|
|
2
|
+
import { forwardRef } from "react";
|
|
4
3
|
import { jsx } from "react/jsx-runtime";
|
|
5
4
|
//#region src/react/AdvancedEditor.tsx
|
|
6
5
|
/**
|
|
7
|
-
* The advanced editor on the React surface: `
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
6
|
+
* The advanced editor on the React surface: `composeEditor({ content: 'rich', interaction: 'full', ai: true })` mounted
|
|
7
|
+
* through `EditorSurface`; every dimension is overridable by its prop, and the backend (default: the editor context's)
|
|
8
|
+
* prunes what it cannot serve. The ref's `preset` is the composed preset (`omitted` lists the dropped features). The
|
|
9
|
+
* composition is fixed at mount like the kinds it is built from; hosts remount (`key`) to change it. Place
|
|
10
|
+
* `EditorToolbar` and, with `settingsUi: 'external'`, `EditorSettingsModal`/`EditorSettingsPanel` beside it and give
|
|
11
|
+
* them the editor from `onReady`; `useEditorUi(editor)` reaches the chrome of a ready editor. Collaboration is active
|
|
12
|
+
* only when a `collaboration` session is passed; mount `Toaster` once for notices.
|
|
12
13
|
*/
|
|
13
|
-
const AdvancedEditor = forwardRef(function AdvancedEditor({
|
|
14
|
-
|
|
15
|
-
return /* @__PURE__ */ jsx(EditorSurface, {
|
|
14
|
+
const AdvancedEditor = forwardRef(function AdvancedEditor({ content = "rich", interaction = "full", ai = true, ...rest }, ref) {
|
|
15
|
+
return /* @__PURE__ */ jsx(ComposedSurface, {
|
|
16
16
|
ref,
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
content,
|
|
18
|
+
interaction,
|
|
19
|
+
ai,
|
|
20
|
+
...rest
|
|
19
21
|
});
|
|
20
22
|
});
|
|
21
23
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdvancedEditor.js","names":[],"sources":["../../src/react/AdvancedEditor.tsx"],"sourcesContent":["import { forwardRef
|
|
1
|
+
{"version":3,"file":"AdvancedEditor.js","names":[],"sources":["../../src/react/AdvancedEditor.tsx"],"sourcesContent":["import { forwardRef } from 'react'\nimport { ComposedSurface, type ComposedEditorHandle, type ComposedEditorProps } from './composed-surface'\n\nexport type { ComposedEditorHandle as AdvancedEditorHandle }\n\n/**\n * Props of the advanced editor: the surface's own (collaboration session or standalone `value`/`onChange`, metadata,\n * abilities, extensions, block actions, commands, `documentId`, `editable`, `settingsUi`, the open state of the sidebar\n * and comments margin, `onReady` and the other callbacks) except the preset, plus the composition: `content`,\n * `interaction`, `ai`, `add`, `remove`, `backend` and the composite kinds. The defaults are the advanced editor's:\n * `content: 'rich'`, `interaction: 'full'`, `ai: true`.\n */\nexport type AdvancedEditorProps = ComposedEditorProps\n\n/**\n * The advanced editor on the React surface: `composeEditor({ content: 'rich', interaction: 'full', ai: true })` mounted\n * through `EditorSurface`; every dimension is overridable by its prop, and the backend (default: the editor context's)\n * prunes what it cannot serve. The ref's `preset` is the composed preset (`omitted` lists the dropped features). The\n * composition is fixed at mount like the kinds it is built from; hosts remount (`key`) to change it. Place\n * `EditorToolbar` and, with `settingsUi: 'external'`, `EditorSettingsModal`/`EditorSettingsPanel` beside it and give\n * them the editor from `onReady`; `useEditorUi(editor)` reaches the chrome of a ready editor. Collaboration is active\n * only when a `collaboration` session is passed; mount `Toaster` once for notices.\n */\nexport const AdvancedEditor = forwardRef<ComposedEditorHandle, AdvancedEditorProps>(function AdvancedEditor({ content = 'rich', interaction = 'full', ai = true, ...rest }, ref) {\n return <ComposedSurface ref={ref} content={content} interaction={interaction} ai={ai} {...rest} />\n})\n"],"mappings":";;;;;;;;;;;;;AAuBA,MAAa,iBAAiB,WAAsD,SAAS,eAAe,EAAE,UAAU,QAAQ,cAAc,QAAQ,KAAK,MAAM,GAAG,QAAQ,KAAK;CAC/K,OAAO,oBAAC,iBAAD;EAAsB;EAAc;EAAsB;EAAiB;EAAI,GAAI;CAAO,CAAA;AACnG,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Editor } from "@tiptap/core";
|
|
2
|
+
//#region src/react/EditorCommandPalette.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* „Befehle“ (⌘K): the commands of the surface's editor (features' and host's, `palette !== false`) in a command dialog,
|
|
5
|
+
* grouped like the toolbar, disabled where `commandState` disables them; a menu command opens its rows as a second
|
|
6
|
+
* level (Backspace in the empty search goes back). Mounted by `core-ui` as an overlay of the surface; the surface's
|
|
7
|
+
* `ui.paletteOpen` is its open state.
|
|
8
|
+
*/
|
|
9
|
+
export declare function EditorCommandPalette({ editor }: {
|
|
10
|
+
editor: Editor;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
12
|
+
//#endregion
|
|
13
|
+
//# sourceMappingURL=EditorCommandPalette.d.ts.map
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { editorEntryOf } from "../core/editor-ui.js";
|
|
2
|
+
import { filterPalette, paletteGroupsOf } from "../core/palette.js";
|
|
3
|
+
import { useEditorI18n } from "./use-editor-i18n.js";
|
|
4
|
+
import { Icon } from "./Icon.js";
|
|
5
|
+
import { useEditorUi } from "./editor-ui.js";
|
|
6
|
+
import { Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandShortcut } from "./ui/command.js";
|
|
7
|
+
import { shortcutLabel } from "./key-labels.js";
|
|
8
|
+
import { useEffect, useMemo, useState } from "react";
|
|
9
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
//#region src/react/EditorCommandPalette.tsx
|
|
11
|
+
function Row({ entry, onPick }) {
|
|
12
|
+
return /* @__PURE__ */ jsxs(CommandItem, {
|
|
13
|
+
value: entry.id,
|
|
14
|
+
disabled: entry.disabled,
|
|
15
|
+
onSelect: () => onPick(entry),
|
|
16
|
+
children: [
|
|
17
|
+
entry.icon && /* @__PURE__ */ jsx(Icon, { name: entry.icon }),
|
|
18
|
+
/* @__PURE__ */ jsxs("span", {
|
|
19
|
+
className: "flex min-w-0 flex-col",
|
|
20
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
21
|
+
className: "truncate",
|
|
22
|
+
children: entry.label
|
|
23
|
+
}), entry.description && /* @__PURE__ */ jsx("span", {
|
|
24
|
+
className: "truncate text-xs text-muted-foreground",
|
|
25
|
+
children: entry.description
|
|
26
|
+
})]
|
|
27
|
+
}),
|
|
28
|
+
entry.children ? /* @__PURE__ */ jsx(Icon, {
|
|
29
|
+
name: "i-lucide-chevron-right",
|
|
30
|
+
className: "ml-auto"
|
|
31
|
+
}) : entry.kbds && entry.kbds.length > 0 && /* @__PURE__ */ jsx(CommandShortcut, { children: shortcutLabel(entry.kbds) })
|
|
32
|
+
]
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* „Befehle“ (⌘K): the commands of the surface's editor (features' and host's, `palette !== false`) in a command dialog,
|
|
37
|
+
* grouped like the toolbar, disabled where `commandState` disables them; a menu command opens its rows as a second
|
|
38
|
+
* level (Backspace in the empty search goes back). Mounted by `core-ui` as an overlay of the surface; the surface's
|
|
39
|
+
* `ui.paletteOpen` is its open state.
|
|
40
|
+
*/
|
|
41
|
+
function EditorCommandPalette({ editor }) {
|
|
42
|
+
const ui = useEditorUi();
|
|
43
|
+
const { t } = useEditorI18n();
|
|
44
|
+
const open = ui?.paletteOpen ?? false;
|
|
45
|
+
const [query, setQuery] = useState("");
|
|
46
|
+
const [parent, setParent] = useState(null);
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (!open) {
|
|
49
|
+
setQuery("");
|
|
50
|
+
setParent(null);
|
|
51
|
+
}
|
|
52
|
+
}, [open]);
|
|
53
|
+
const groups = useMemo(() => {
|
|
54
|
+
const entry = open ? editorEntryOf(editor) : void 0;
|
|
55
|
+
return entry ? paletteGroupsOf(editor, entry) : [];
|
|
56
|
+
}, [open, editor]);
|
|
57
|
+
const shown = useMemo(() => filterPalette(parent ? [{
|
|
58
|
+
id: parent.id,
|
|
59
|
+
label: parent.label,
|
|
60
|
+
entries: parent.children ?? []
|
|
61
|
+
}] : groups, query), [
|
|
62
|
+
groups,
|
|
63
|
+
parent,
|
|
64
|
+
query
|
|
65
|
+
]);
|
|
66
|
+
function pick(entry) {
|
|
67
|
+
if (entry.children) {
|
|
68
|
+
setParent(entry);
|
|
69
|
+
setQuery("");
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (ui?.paletteOpen) ui.togglePalette();
|
|
73
|
+
entry.run?.();
|
|
74
|
+
}
|
|
75
|
+
return /* @__PURE__ */ jsx(CommandDialog, {
|
|
76
|
+
open,
|
|
77
|
+
onOpenChange: (next) => {
|
|
78
|
+
if (next !== open) ui?.togglePalette();
|
|
79
|
+
},
|
|
80
|
+
title: t("palette.title"),
|
|
81
|
+
description: t("palette.description"),
|
|
82
|
+
children: /* @__PURE__ */ jsxs(Command, {
|
|
83
|
+
shouldFilter: false,
|
|
84
|
+
onKeyDown: (event) => {
|
|
85
|
+
if (event.key === "Backspace" && !query && parent) {
|
|
86
|
+
event.preventDefault();
|
|
87
|
+
setParent(null);
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
children: [/* @__PURE__ */ jsx(CommandInput, {
|
|
91
|
+
value: query,
|
|
92
|
+
onValueChange: setQuery,
|
|
93
|
+
placeholder: parent ? parent.label : t("palette.placeholder")
|
|
94
|
+
}), /* @__PURE__ */ jsxs(CommandList, { children: [
|
|
95
|
+
/* @__PURE__ */ jsx(CommandEmpty, { children: t("palette.empty") }),
|
|
96
|
+
parent && /* @__PURE__ */ jsx(CommandGroup, { children: /* @__PURE__ */ jsxs(CommandItem, {
|
|
97
|
+
value: "palette:back",
|
|
98
|
+
onSelect: () => {
|
|
99
|
+
setParent(null);
|
|
100
|
+
setQuery("");
|
|
101
|
+
},
|
|
102
|
+
children: [/* @__PURE__ */ jsx(Icon, { name: "i-lucide-arrow-left" }), t("palette.back")]
|
|
103
|
+
}) }),
|
|
104
|
+
shown.map((group) => /* @__PURE__ */ jsx(CommandGroup, {
|
|
105
|
+
heading: group.label,
|
|
106
|
+
children: group.entries.map((entry) => /* @__PURE__ */ jsx(Row, {
|
|
107
|
+
entry,
|
|
108
|
+
onPick: pick
|
|
109
|
+
}, entry.id))
|
|
110
|
+
}, group.id))
|
|
111
|
+
] })]
|
|
112
|
+
})
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
//#endregion
|
|
116
|
+
export { EditorCommandPalette };
|
|
117
|
+
|
|
118
|
+
//# sourceMappingURL=EditorCommandPalette.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EditorCommandPalette.js","names":[],"sources":["../../src/react/EditorCommandPalette.tsx"],"sourcesContent":["import type { Editor } from '@tiptap/core'\nimport { useEffect, useMemo, useState } from 'react'\nimport { editorEntryOf } from '../core/editor-ui'\nimport { filterPalette, type PaletteEntry, type PaletteGroup, paletteGroupsOf } from '../core/palette'\nimport { Icon } from './Icon'\nimport { Command, CommandDialog, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandShortcut } from './ui/command'\nimport { useEditorUi } from './editor-ui'\nimport { shortcutLabel } from './key-labels'\nimport { useEditorI18n } from './use-editor-i18n'\n\nfunction Row({ entry, onPick }: { entry: PaletteEntry, onPick: (entry: PaletteEntry) => void }) {\n return (\n <CommandItem value={entry.id} disabled={entry.disabled} onSelect={() => onPick(entry)}>\n {entry.icon && <Icon name={entry.icon} />}\n <span className=\"flex min-w-0 flex-col\">\n <span className=\"truncate\">{entry.label}</span>\n {entry.description && <span className=\"truncate text-xs text-muted-foreground\">{entry.description}</span>}\n </span>\n {entry.children\n ? <Icon name=\"i-lucide-chevron-right\" className=\"ml-auto\" />\n : entry.kbds && entry.kbds.length > 0 && <CommandShortcut>{shortcutLabel(entry.kbds)}</CommandShortcut>}\n </CommandItem>\n )\n}\n\n/**\n * „Befehle“ (⌘K): the commands of the surface's editor (features' and host's, `palette !== false`) in a command dialog,\n * grouped like the toolbar, disabled where `commandState` disables them; a menu command opens its rows as a second\n * level (Backspace in the empty search goes back). Mounted by `core-ui` as an overlay of the surface; the surface's\n * `ui.paletteOpen` is its open state.\n */\nexport function EditorCommandPalette({ editor }: { editor: Editor }) {\n const ui = useEditorUi()\n const { t } = useEditorI18n()\n const open = ui?.paletteOpen ?? false\n const [query, setQuery] = useState('')\n const [parent, setParent] = useState<PaletteEntry | null>(null)\n\n useEffect(() => {\n if (!open) {\n setQuery('')\n setParent(null)\n }\n }, [open])\n\n // The state of every command is read when the palette opens, not while it is closed.\n const groups = useMemo<PaletteGroup[]>(() => {\n const entry = open ? editorEntryOf(editor) : undefined\n return entry ? paletteGroupsOf(editor, entry) : []\n }, [open, editor])\n\n const shown = useMemo(\n () => filterPalette(parent ? [{ id: parent.id, label: parent.label, entries: parent.children ?? [] }] : groups, query),\n [groups, parent, query],\n )\n\n function pick(entry: PaletteEntry) {\n if (entry.children) {\n setParent(entry)\n setQuery('')\n return\n }\n if (ui?.paletteOpen) ui.togglePalette()\n entry.run?.()\n }\n\n return (\n <CommandDialog\n open={open}\n onOpenChange={(next) => {\n if (next !== open) ui?.togglePalette()\n }}\n title={t('palette.title')}\n description={t('palette.description')}\n >\n <Command\n shouldFilter={false}\n onKeyDown={(event) => {\n if (event.key === 'Backspace' && !query && parent) {\n event.preventDefault()\n setParent(null)\n }\n }}\n >\n <CommandInput value={query} onValueChange={setQuery} placeholder={parent ? parent.label : t('palette.placeholder')} />\n <CommandList>\n <CommandEmpty>{t('palette.empty')}</CommandEmpty>\n {parent && (\n <CommandGroup>\n <CommandItem value=\"palette:back\" onSelect={() => { setParent(null); setQuery('') }}>\n <Icon name=\"i-lucide-arrow-left\" />\n {t('palette.back')}\n </CommandItem>\n </CommandGroup>\n )}\n {shown.map(group => (\n <CommandGroup key={group.id} heading={group.label}>\n {group.entries.map(entry => <Row key={entry.id} entry={entry} onPick={pick} />)}\n </CommandGroup>\n ))}\n </CommandList>\n </Command>\n </CommandDialog>\n )\n}\n"],"mappings":";;;;;;;;;;AAUA,SAAS,IAAI,EAAE,OAAO,UAA0E;CAC9F,OACE,qBAAC,aAAD;EAAa,OAAO,MAAM;EAAI,UAAU,MAAM;EAAU,gBAAgB,OAAO,KAAK;EAApF,UAAA;GACG,MAAM,QAAQ,oBAAC,MAAD,EAAM,MAAM,MAAM,KAAO,CAAA;GACxC,qBAAC,QAAD;IAAM,WAAU;IAAhB,UAAA,CACE,oBAAC,QAAD;KAAM,WAAU;KAAY,UAAA,MAAM;IAAY,CAAA,GAC7C,MAAM,eAAe,oBAAC,QAAD;KAAM,WAA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AAU;IACpB,IAAI,MAAM,QAAQ,eAAe,CAAC,SAAS,QAAQ;KACjD,MAAM,eAAe;KACrB,UAAU,IAAI;IAChB;GACF;GAPF,UAAA,CASE,oBAAC,cAAD;IAAc,OAAO;IAAO,eAAe;IAAU,aAAa,SAAS,OAAO,QAAQ,EAAE,qBAAqB;GAAI,CAAA,GACrH,qBAAC,aAAD,EAAA,UAAA;IACE,oBAAC,cAAD,EAAA,UAAe,EAAE,eAAe,EAAgB,CAAA;IAC/C,UACC,oBAAC,cAAD,EAAA,UACE,qBAAC,aAAD;KAAa,OAAM;KAAe,gBAAgB;MAAE,UAAU,IAAI;MAAG,SAAS,EAAE;KAAE;KAAlF,UAAA,CACE,oBAAC,MAAD,EAAM,MAAK,sBAAuB,CAAA,GACjC,EAAE,cAAc,CACN;IACD,CAAA,EAAA,CAAA;IAEf,MAAM,KAAI,UACT,oBAAC,cAAD;KAA6B,SAAS,MAAM;KACzC,UAAA,MAAM,QAAQ,KAAI,UAAS,oBAAC,KAAD;MAA2B;MAAO,QAAQ;KAAO,GAAvC,MAAM,EAAiC,CAAC;IAClE,GAFK,MAAM,EAEX,CACf;GACU,EAAA,CAAA,CACN;;CACI,CAAA;AAEnB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Editor } from "@tiptap/core";
|
|
2
2
|
//#region src/react/EditorSettingsModal.d.ts
|
|
3
|
-
/** „Einstellungen“: `EditorSettingsPanel` in a modal. Renders nothing when
|
|
4
|
-
export declare function EditorSettingsModal({
|
|
5
|
-
/** The
|
|
6
|
-
|
|
3
|
+
/** „Einstellungen“: `EditorSettingsPanel` in a modal. Renders nothing without an editor or when its preset contributes no settings tab. */
|
|
4
|
+
export declare function EditorSettingsModal({ editor, open, onOpenChange, tab, onTabChange }: {
|
|
5
|
+
/** The editor whose preset (registered by its surface, from its `onReady`) contributes the tabs. */
|
|
6
|
+
editor?: Editor;
|
|
7
7
|
open: boolean;
|
|
8
8
|
onOpenChange: (open: boolean) => void;
|
|
9
9
|
/** Shown tab id (see `EditorSettingsPanel`). */
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { settingsTabsOf } from "../core/define-editor.js";
|
|
2
|
+
import { editorEntryOf } from "../core/editor-ui.js";
|
|
2
3
|
import { useEditorContext } from "./context.js";
|
|
3
4
|
import { useEditorI18n } from "./use-editor-i18n.js";
|
|
4
5
|
import { EditorSettingsPanel } from "./EditorSettingsPanel.js";
|
|
@@ -7,11 +8,13 @@ import { Button } from "./ui/button.js";
|
|
|
7
8
|
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "./ui/dialog.js";
|
|
8
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
10
|
//#region src/react/EditorSettingsModal.tsx
|
|
10
|
-
/** „Einstellungen“: `EditorSettingsPanel` in a modal. Renders nothing when
|
|
11
|
-
function EditorSettingsModal({
|
|
11
|
+
/** „Einstellungen“: `EditorSettingsPanel` in a modal. Renders nothing without an editor or when its preset contributes no settings tab. */
|
|
12
|
+
function EditorSettingsModal({ editor, open, onOpenChange, tab, onTabChange }) {
|
|
12
13
|
const { synced } = useEditorSettings();
|
|
13
14
|
const { t } = useEditorI18n();
|
|
14
|
-
|
|
15
|
+
const app = useEditorContext();
|
|
16
|
+
const preset = editorEntryOf(editor?.isDestroyed ? void 0 : editor)?.preset;
|
|
17
|
+
if (!preset || !settingsTabsOf(preset, app).length) return null;
|
|
15
18
|
return /* @__PURE__ */ jsx(Dialog, {
|
|
16
19
|
open,
|
|
17
20
|
onOpenChange,
|
|
@@ -20,7 +23,7 @@ function EditorSettingsModal({ preset, open, onOpenChange, tab, onTabChange }) {
|
|
|
20
23
|
children: [
|
|
21
24
|
/* @__PURE__ */ jsxs(DialogHeader, { children: [/* @__PURE__ */ jsx(DialogTitle, { children: t("settings.title") }), /* @__PURE__ */ jsx(DialogDescription, { children: t(synced ? "settings.scope.account" : "settings.scope.browser") })] }),
|
|
22
25
|
/* @__PURE__ */ jsx(EditorSettingsPanel, {
|
|
23
|
-
|
|
26
|
+
...editor && { editor },
|
|
24
27
|
...tab !== void 0 && { tab },
|
|
25
28
|
...onTabChange && { onTabChange },
|
|
26
29
|
contentClassName: "h-[32rem] overflow-y-auto pt-4 pr-2"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorSettingsModal.js","names":[],"sources":["../../src/react/EditorSettingsModal.tsx"],"sourcesContent":["import { settingsTabsOf } from '../core/define-editor'\nimport {
|
|
1
|
+
{"version":3,"file":"EditorSettingsModal.js","names":[],"sources":["../../src/react/EditorSettingsModal.tsx"],"sourcesContent":["import type { Editor } from '@tiptap/core'\nimport { settingsTabsOf } from '../core/define-editor'\nimport { editorEntryOf } from '../core/editor-ui'\nimport { EditorSettingsPanel } from './EditorSettingsPanel'\nimport { useEditorContext } from './context'\nimport { useEditorSettings } from './settings'\nimport { useEditorI18n } from './use-editor-i18n'\nimport { Button } from './ui/button'\nimport { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from './ui/dialog'\n\n/** „Einstellungen“: `EditorSettingsPanel` in a modal. Renders nothing without an editor or when its preset contributes no settings tab. */\nexport function EditorSettingsModal({ editor, open, onOpenChange, tab, onTabChange }: {\n /** The editor whose preset (registered by its surface, from its `onReady`) contributes the tabs. */\n editor?: Editor\n open: boolean\n onOpenChange: (open: boolean) => void\n /** Shown tab id (see `EditorSettingsPanel`). */\n tab?: string\n onTabChange?: (tab: string) => void\n}) {\n const { synced } = useEditorSettings()\n const { t } = useEditorI18n()\n const app = useEditorContext()\n const preset = editorEntryOf(editor?.isDestroyed ? undefined : editor)?.preset\n if (!preset || !settingsTabsOf(preset, app).length) return null\n return (\n <Dialog open={open} onOpenChange={onOpenChange}>\n <DialogContent className=\"sm:w-[42rem] sm:max-w-[42rem]\">\n <DialogHeader>\n <DialogTitle>{t('settings.title')}</DialogTitle>\n <DialogDescription>{t(synced ? 'settings.scope.account' : 'settings.scope.browser')}</DialogDescription>\n </DialogHeader>\n <EditorSettingsPanel\n {...(editor && { editor })}\n {...(tab !== undefined && { tab })}\n {...(onTabChange && { onTabChange })}\n contentClassName=\"h-[32rem] overflow-y-auto pt-4 pr-2\"\n />\n <DialogFooter>\n <Button variant=\"ghost\" onClick={() => onOpenChange(false)}>{t('common.close')}</Button>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n )\n}\n"],"mappings":";;;;;;;;;;;AAWA,SAAgB,oBAAoB,EAAE,QAAQ,MAAM,cAAc,KAAK,eAQpE;CACD,MAAM,EAAE,WAAW,kBAAkB;CACrC,MAAM,EAAE,MAAM,cAAc;CAC5B,MAAM,MAAM,iBAAiB;CAC7B,MAAM,SAAS,cAAc,QAAQ,cAAc,KAAA,IAAY,MAAM,CAAC,EAAE;CACxE,IAAI,CAAC,UAAU,CAAC,eAAe,QAAQ,GAAG,CAAC,CAAC,QAAQ,OAAO;CAC3D,OACE,oBAAC,QAAD;EAAc;EAAoB;EAChC,UAAA,qBAAC,eAAD;GAAe,WAAU;GAAzB,UAAA;IACE,qBAAC,cAAD,EAAA,UAAA,CACE,oBAAC,aAAD,EAAA,UAAc,EAAE,gBAAgB,EAAe,CAAA,GAC/C,oBAAC,mBAAD,EAAA,UAAoB,EAAE,SAAS,2BAA2B,wBAAwB,EAAqB,CAAA,CAC3F,EAAA,CAAA;IACd,oBAAC,qBAAD;KACE,GAAK,UAAU,EAAE,OAAO;KACxB,GAAK,QAAQ,KAAA,KAAa,EAAE,IAAI;KAChC,GAAK,eAAe,EAAE,YAAY;KAClC,kBAAiB;IAClB,CAAA;IACD,oBAAC,cAAD,EAAA,UACE,oBAAC,QAAD;KAAQ,SAAQ;KAAQ,eAAe,aAAa,KAAK;KAAI,UAAA,EAAE,cAAc;IAAU,CAAA,EAC3E,CAAA;GACD;;CACT,CAAA;AAEZ"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Editor } from "@tiptap/core";
|
|
2
2
|
//#region src/react/EditorSettingsPanel.d.ts
|
|
3
3
|
/**
|
|
4
|
-
* The settings of an editor: one tab per settings tab the preset
|
|
5
|
-
* nothing when the preset contributes no tab. The values live in the app's shared settings
|
|
6
|
-
* panels of several editors edit the same preferences.
|
|
4
|
+
* The settings of an editor: one tab per settings tab the features of its preset contribute. Place it anywhere; it
|
|
5
|
+
* renders nothing without an editor or when the preset contributes no tab. The values live in the app's shared settings
|
|
6
|
+
* (`useEditorSettings`), so panels of several editors edit the same preferences.
|
|
7
7
|
*/
|
|
8
|
-
export declare function EditorSettingsPanel({
|
|
9
|
-
/** The
|
|
10
|
-
|
|
8
|
+
export declare function EditorSettingsPanel({ editor, tab, onTabChange, contentClassName }: {
|
|
9
|
+
/** The editor whose preset (registered by its surface, from its `onReady`) contributes the tabs. */
|
|
10
|
+
editor?: Editor;
|
|
11
11
|
/** Shown tab id; a missing or removed id shows the first contributed tab. */
|
|
12
12
|
tab?: string;
|
|
13
13
|
onTabChange?: (tab: string) => void;
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import { settingsTabsOf } from "../core/define-editor.js";
|
|
2
|
+
import { editorEntryOf } from "../core/editor-ui.js";
|
|
2
3
|
import { useEditorContext } from "./context.js";
|
|
3
4
|
import { Icon } from "./Icon.js";
|
|
4
5
|
import { Tabs, TabsList, TabsTrigger } from "./ui/tabs.js";
|
|
5
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
6
7
|
//#region src/react/EditorSettingsPanel.tsx
|
|
7
8
|
/**
|
|
8
|
-
* The settings of an editor: one tab per settings tab the preset
|
|
9
|
-
* nothing when the preset contributes no tab. The values live in the app's shared settings
|
|
10
|
-
* panels of several editors edit the same preferences.
|
|
9
|
+
* The settings of an editor: one tab per settings tab the features of its preset contribute. Place it anywhere; it
|
|
10
|
+
* renders nothing without an editor or when the preset contributes no tab. The values live in the app's shared settings
|
|
11
|
+
* (`useEditorSettings`), so panels of several editors edit the same preferences.
|
|
11
12
|
*/
|
|
12
|
-
function EditorSettingsPanel({
|
|
13
|
-
const
|
|
13
|
+
function EditorSettingsPanel({ editor, tab, onTabChange, contentClassName = "pt-4" }) {
|
|
14
|
+
const app = useEditorContext();
|
|
15
|
+
const preset = editorEntryOf(editor?.isDestroyed ? void 0 : editor)?.preset;
|
|
16
|
+
const tabs = preset ? settingsTabsOf(preset, app) : [];
|
|
14
17
|
const active = tabs.find((candidate) => candidate.id === tab) ?? tabs[0];
|
|
15
18
|
if (!active) return null;
|
|
16
19
|
const Active = active.component;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorSettingsPanel.js","names":[],"sources":["../../src/react/EditorSettingsPanel.tsx"],"sourcesContent":["import type { ComponentType } from 'react'\nimport { settingsTabsOf } from '../core/define-editor'\nimport
|
|
1
|
+
{"version":3,"file":"EditorSettingsPanel.js","names":[],"sources":["../../src/react/EditorSettingsPanel.tsx"],"sourcesContent":["import type { Editor } from '@tiptap/core'\nimport type { ComponentType } from 'react'\nimport { settingsTabsOf } from '../core/define-editor'\nimport { editorEntryOf } from '../core/editor-ui'\nimport { useEditorContext } from './context'\nimport { Icon } from './Icon'\nimport { Tabs, TabsList, TabsTrigger } from './ui/tabs'\n\n/**\n * The settings of an editor: one tab per settings tab the features of its preset contribute. Place it anywhere; it\n * renders nothing without an editor or when the preset contributes no tab. The values live in the app's shared settings\n * (`useEditorSettings`), so panels of several editors edit the same preferences.\n */\nexport function EditorSettingsPanel({ editor, tab, onTabChange, contentClassName = 'pt-4' }: {\n /** The editor whose preset (registered by its surface, from its `onReady`) contributes the tabs. */\n editor?: Editor\n /** Shown tab id; a missing or removed id shows the first contributed tab. */\n tab?: string\n onTabChange?: (tab: string) => void\n /** Classes of the tab content area, e.g. a fixed height with scrolling. */\n contentClassName?: string\n}) {\n const app = useEditorContext()\n const preset = editorEntryOf(editor?.isDestroyed ? undefined : editor)?.preset\n const tabs = preset ? settingsTabsOf(preset, app) : []\n const active = tabs.find(candidate => candidate.id === tab) ?? tabs[0]\n if (!active) return null\n // The preset's component type is the toolbar/overlay one; a settings tab receives only its `props`.\n const Active = active.component as ComponentType<Record<string, unknown>>\n return (\n <div className=\"flex w-full flex-col\">\n <Tabs value={active.id} onValueChange={value => onTabChange?.(value)} className=\"w-full\">\n <TabsList variant=\"line\">\n {tabs.map(({ id, label, icon }) => (\n <TabsTrigger key={id} value={id}>\n {icon && <Icon name={icon} />}\n {label}\n </TabsTrigger>\n ))}\n </TabsList>\n </Tabs>\n <div className={contentClassName} data-settings-panel-content>\n <Active key={active.id} {...active.props} />\n </div>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;AAaA,SAAgB,oBAAoB,EAAE,QAAQ,KAAK,aAAa,mBAAmB,UAQhF;CACD,MAAM,MAAM,iBAAiB;CAC7B,MAAM,SAAS,cAAc,QAAQ,cAAc,KAAA,IAAY,MAAM,CAAC,EAAE;CACxE,MAAM,OAAO,SAAS,eAAe,QAAQ,GAAG,IAAI,CAAC;CACrD,MAAM,SAAS,KAAK,MAAK,cAAa,UAAU,OAAO,GAAG,KAAK,KAAK;CACpE,IAAI,CAAC,QAAQ,OAAO;CAEpB,MAAM,SAAS,OAAO;CACtB,OACE,qBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,oBAAC,MAAD;GAAM,OAAO,OAAO;GAAI,gBAAe,UAAS,cAAc,KAAK;GAAG,WAAU;GAC9E,UAAA,oBAAC,UAAD;IAAU,SAAQ;IACf,UAAA,KAAK,KAAK,EAAE,IAAI,OAAO,WACtB,qBAAC,aAAD;KAAsB,OAAO;KAA7B,UAAA,CACG,QAAQ,oBAAC,MAAD,EAAM,MAAM,KAAO,CAAA,GAC3B,KACU;IAHK,GAAA,EAGL,CACd;GACO,CAAA;EACN,CAAA,GACN,oBAAC,OAAD;GAAK,WAAW;GAAkB,+BAAA;GAChC,UAAA,oBAAC,QAAD,EAAwB,GAAI,OAAO,MAAQ,GAA9B,OAAO,EAAuB;EACxC,CAAA,CACF;;AAET"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CommandDef } from "../core/command-types.js";
|
|
2
|
+
import { AbilitiesOptions, BlockAction } from "../core/extension-points.js";
|
|
2
3
|
import { EditorMetadata, MetadataItem } from "../core/metadata-types.js";
|
|
3
|
-
import { CollaborationSession, EditorFeature, EditorPreset
|
|
4
|
+
import { CollaborationSession, EditorFeature, EditorPreset } from "../core/feature.js";
|
|
5
|
+
import "../core/commands.js";
|
|
4
6
|
import { AnyExtension, Editor, JSONContent } from "@tiptap/core";
|
|
5
7
|
import { ComponentType } from "react";
|
|
6
8
|
//#region src/react/EditorSurface.d.ts
|
|
@@ -26,12 +28,10 @@ export interface EditorSurfaceProps {
|
|
|
26
28
|
extensions?: AnyExtension[];
|
|
27
29
|
/** Hover actions shown after the features' own; shown by an installed block-UI feature. */
|
|
28
30
|
blockActions?: BlockAction[];
|
|
29
|
-
/** Builds the `/` menu from the features' commands; absent = the features' commands. Read once at mount. */
|
|
30
|
-
|
|
31
|
-
/** Document whose package stores uploads (media feature). Read once at mount. */
|
|
31
|
+
/** Builds the final commands (and with them the `/` menu) from the features' commands; absent = the features' commands. Read once at mount. */
|
|
32
|
+
commands?: (defaults: CommandDef[]) => CommandDef[];
|
|
33
|
+
/** Document whose package stores uploads (`backend.assets`, media feature). Read once at mount. */
|
|
32
34
|
documentId?: string;
|
|
33
|
-
/** Stores an uploaded file and returns its URL (media feature). Read once at mount. */
|
|
34
|
-
upload?: UploadFn;
|
|
35
35
|
editable?: boolean;
|
|
36
36
|
/** `internal`: the surface owns its settings UI; `external`: it calls `onSettingsOpen` and the host shows the panel. */
|
|
37
37
|
settingsUi?: 'internal' | 'external';
|
|
@@ -41,17 +41,20 @@ function useOpenState(value, onChange) {
|
|
|
41
41
|
* check, setup lifecycle); callbacks are read from the surface's latest props.
|
|
42
42
|
*/
|
|
43
43
|
function createSurface(props, app, parts) {
|
|
44
|
-
const { preset, collaboration, value, editable, metadata, documentId,
|
|
44
|
+
const { preset, collaboration, value, editable, metadata, documentId, abilities, commands, extensions, blockActions } = props.current;
|
|
45
45
|
const ui = {
|
|
46
46
|
openSettings: parts.openSettings,
|
|
47
47
|
toggleSidebar: () => parts.sidebar.set(!parts.sidebar.latest.current.open),
|
|
48
48
|
toggleComments: () => parts.comments.set(!parts.comments.latest.current.open),
|
|
49
49
|
get commentsOpen() {
|
|
50
50
|
return parts.comments.latest.current.open;
|
|
51
|
+
},
|
|
52
|
+
togglePalette: () => parts.palette.set(!parts.palette.latest.current.open),
|
|
53
|
+
get paletteOpen() {
|
|
54
|
+
return parts.palette.latest.current.open;
|
|
51
55
|
}
|
|
52
56
|
};
|
|
53
57
|
return {
|
|
54
|
-
preset,
|
|
55
58
|
ui,
|
|
56
59
|
session: createSurfaceSession({
|
|
57
60
|
app,
|
|
@@ -65,9 +68,8 @@ function createSurface(props, app, parts) {
|
|
|
65
68
|
editable,
|
|
66
69
|
metadata,
|
|
67
70
|
documentId,
|
|
68
|
-
upload,
|
|
69
71
|
abilities,
|
|
70
|
-
|
|
72
|
+
commands,
|
|
71
73
|
extensions,
|
|
72
74
|
blockActions,
|
|
73
75
|
onChange: (content) => props.current.onChange?.(content),
|
|
@@ -85,6 +87,7 @@ const EditorSurface = forwardRef(function EditorSurface(props, ref) {
|
|
|
85
87
|
const editorRef = useRef(null);
|
|
86
88
|
const sidebar = useOpenState(props.sidebarOpen, props.onSidebarOpenChange);
|
|
87
89
|
const comments = useOpenState(props.commentsOpen, props.onCommentsOpenChange);
|
|
90
|
+
const palette = useOpenState(void 0, void 0);
|
|
88
91
|
const [settingsState, setSettingsState] = useState({
|
|
89
92
|
open: false,
|
|
90
93
|
tab: void 0
|
|
@@ -100,10 +103,11 @@ const EditorSurface = forwardRef(function EditorSurface(props, ref) {
|
|
|
100
103
|
tab: tab ?? state.tab
|
|
101
104
|
}));
|
|
102
105
|
}, []);
|
|
103
|
-
const [{
|
|
106
|
+
const [{ ui, session }] = useState(() => createSurface(latest, app, {
|
|
104
107
|
editor: editorRef,
|
|
105
108
|
sidebar,
|
|
106
109
|
comments,
|
|
110
|
+
palette,
|
|
107
111
|
openSettings
|
|
108
112
|
}));
|
|
109
113
|
const editor = useEditor({
|
|
@@ -150,7 +154,7 @@ const EditorSurface = forwardRef(function EditorSurface(props, ref) {
|
|
|
150
154
|
}),
|
|
151
155
|
session.overlays.map((Overlay, index) => /* @__PURE__ */ jsx(Overlay, { editor }, index)),
|
|
152
156
|
(props.settingsUi ?? "internal") === "internal" && /* @__PURE__ */ jsx(EditorSettingsModal, {
|
|
153
|
-
|
|
157
|
+
...editor && { editor },
|
|
154
158
|
open: settingsState.open,
|
|
155
159
|
onOpenChange: (open) => setSettingsState((state) => ({
|
|
156
160
|
...state,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorSurface.js","names":[],"sources":["../../src/react/EditorSurface.tsx"],"sourcesContent":["import type { AnyExtension, Editor, JSONContent } from '@tiptap/core'\nimport { EditorContent, useEditor } from '@tiptap/react'\nimport { type ComponentType, forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react'\nimport type { EditorContext } from '../core/context'\nimport { settingsTabsOf } from '../core/define-editor'\nimport type { EditorUi } from '../core/editor-ui'\nimport type { AbilitiesOptions, BlockAction, SlashCommandItem } from '../core/extension-points'\nimport type { CollaborationSession, EditorFeature, EditorPreset, UploadFn } from '../core/feature'\nimport type { EditorMetadata, MetadataItem } from '../core/metadata-types'\nimport { createSurfaceSession } from '../core/surface-session'\nimport { useEditorContext } from './context'\nimport { EditorSettingsModal } from './EditorSettingsModal'\nimport { EditorUiContext } from './editor-ui'\nimport { reactNotifier } from './notify'\nimport { reactSuggestionRenderer } from './suggestion-renderer'\n\nexport type ReactFeature = EditorFeature<ComponentType<{ editor: Editor }>>\nexport type ReactPreset = EditorPreset<ComponentType<{ editor: Editor }>>\n\nexport interface EditorSurfaceProps {\n /** The features this editor is made of (`defineEditor(...)`); fixed at mount, remount (`key`) to change it. */\n preset: ReactPreset\n /** Collaborative mode: the Y.Doc is the document. Needs a preset with the collaboration feature; fixed at mount. */\n collaboration?: CollaborationSession\n /** Standalone mode (without `collaboration`): TipTap JSON, with `onChange`; the editor keeps its own undo history. */\n value?: JSONContent\n onChange?: (content: JSONContent) => void\n /** Host lists (`mentions`, `hashtags`, `speakers`, custom) features' suggestions search. */\n metadata?: EditorMetadata\n /** Deep-merged into the `Abilities` defaults; read once at mount. */\n abilities?: Partial<AbilitiesOptions>\n /** Added after the features' extensions; read once at mount. */\n extensions?: AnyExtension[]\n /** Hover actions shown after the features' own; shown by an installed block-UI feature. */\n blockActions?: BlockAction[]\n /** Builds the `/` menu from the features' commands; absent = the features' commands. Read once at mount. */\n slashCommands?: (defaults: SlashCommandItem[]) => SlashCommandItem[]\n /** Document whose package stores uploads (media feature). Read once at mount. */\n documentId?: string\n /** Stores an uploaded file and returns its URL (media feature). Read once at mount. */\n upload?: UploadFn\n editable?: boolean\n /** `internal`: the surface owns its settings UI; `external`: it calls `onSettingsOpen` and the host shows the panel. */\n settingsUi?: 'internal' | 'external'\n /** The editor exists and its chrome is registered (`useEditorUi(editor)`, a host toolbar). */\n onReady?: (editor: Editor) => void\n onMetadataCreate?: (list: string, item: MetadataItem) => void\n /** The JSON handed in (initially or later) does not fit this editor's schema; the last valid document stays. */\n onContentError?: (error: Error) => void\n /** `settingsUi: 'external'`: the editor asks the host to open its settings (on `tab` when given). */\n onSettingsOpen?: (tab?: string) => void\n /** Whether this editor's AI sidebar is open (`toggleSidebar`): controlled when given. */\n sidebarOpen?: boolean\n onSidebarOpenChange?: (open: boolean) => void\n /**\n * Whether this editor's comments margin is open (`toggleComments`): controlled when given. The AI sidebar and the\n * margin exclude each other: whichever opens last closes the other.\n */\n commentsOpen?: boolean\n onCommentsOpenChange?: (open: boolean) => void\n}\n\nexport interface EditorSurfaceHandle {\n editor: Editor | null\n openSettings(tab?: string): void\n}\n\n/** A boolean that is the host's (`value` given) or the component's own (`value` undefined); the setter is stable. */\nfunction useOpenState(value: boolean | undefined, onChange: ((open: boolean) => void) | undefined) {\n const [internal, setInternal] = useState(false)\n const controlled = value !== undefined\n const open = value ?? internal\n const latest = useRef({ open, controlled, onChange })\n latest.current = { open, controlled, onChange }\n const set = useCallback((next: boolean) => {\n const current = latest.current\n if (next === current.open) return\n current.open = next\n if (!current.controlled) setInternal(next)\n current.onChange?.(next)\n }, [])\n return { open, set, latest }\n}\n\n/**\n * Everything fixed at mount: the chrome handle and the framework-free session (preset, context, extensions, content\n * check, setup lifecycle); callbacks are read from the surface's latest props.\n */\nfunction createSurface(props: { current: EditorSurfaceProps }, app: EditorContext, parts: {\n editor: { current: Editor | null }\n sidebar: { set: (open: boolean) => void, latest: { current: { open: boolean } } }\n comments: { set: (open: boolean) => void, latest: { current: { open: boolean } } }\n openSettings: (tab?: string) => void\n}) {\n const { preset, collaboration, value, editable, metadata, documentId, upload, abilities, slashCommands, extensions, blockActions } = props.current\n\n const ui: EditorUi = {\n openSettings: parts.openSettings,\n toggleSidebar: () => parts.sidebar.set(!parts.sidebar.latest.current.open),\n toggleComments: () => parts.comments.set(!parts.comments.latest.current.open),\n get commentsOpen() {\n return parts.comments.latest.current.open\n },\n }\n\n // The mode is fixed at mount; hosts switch it by remounting (`key`).\n const session = createSurfaceSession({\n app,\n preset,\n ui,\n notify: reactNotifier,\n suggestionRenderer: reactSuggestionRenderer,\n getEditor: () => parts.editor.current ?? undefined,\n collaboration,\n value,\n editable,\n metadata,\n documentId,\n upload,\n abilities,\n slashCommands,\n extensions,\n blockActions,\n onChange: content => props.current.onChange?.(content),\n onMetadataCreate: (list, item) => props.current.onMetadataCreate?.(list, item),\n onContentError: error => props.current.onContentError?.(error),\n onReady: editor => props.current.onReady?.(editor),\n })\n return { preset, ui, session }\n}\n\nexport const EditorSurface = forwardRef<EditorSurfaceHandle, EditorSurfaceProps>(function EditorSurface(props, ref) {\n const { value, editable = true, metadata } = props\n const latest = useRef(props)\n latest.current = props\n\n const app = useEditorContext()\n const editorRef = useRef<Editor | null>(null)\n const sidebar = useOpenState(props.sidebarOpen, props.onSidebarOpenChange)\n const comments = useOpenState(props.commentsOpen, props.onCommentsOpenChange)\n // `settingsUi: 'internal'`: the surface's own settings modal (`openSettings` opens it).\n const [settingsState, setSettingsState] = useState<{ open: boolean, tab: string | undefined }>({ open: false, tab: undefined })\n\n const openSettings = useCallback((tab?: string) => {\n // Nothing to open without a contributed tab.\n if (!settingsTabsOf(latest.current.preset, app).length) return\n if ((latest.current.settingsUi ?? 'internal') === 'external') {\n latest.current.onSettingsOpen?.(tab)\n return\n }\n setSettingsState(state => ({ open: true, tab: tab ?? state.tab }))\n }, [])\n\n const [{ preset, ui, session }] = useState(() => createSurface(latest, app, { editor: editorRef, sidebar, comments, openSettings }))\n\n const editor = useEditor({\n ...session.editorOptions,\n immediatelyRender: true,\n shouldRerenderOnTransaction: false,\n })\n editorRef.current = editor\n\n // Per-mount side effects of features (`setup`). Activation and deactivation are paired, so StrictMode's mount,\n // cleanup, mount leaves exactly one active setup, and unmounting tears it down.\n useEffect(() => {\n session.activate()\n return () => session.deactivate()\n }, [session])\n\n // The editor exists from the first render; its chrome is registered before the session announces it through\n // `onReady`, so a host toolbar that receives it finds the chrome.\n useEffect(() => session.register(editor), [editor, session])\n\n // External replacement of the standalone document (the host loaded or reset it); not an edit, so no update event.\n useEffect(() => session.setValue(value), [value, editor, session])\n\n useEffect(() => session.setEditable(editable), [editable, editor, session])\n\n useEffect(() => session.setMetadata(metadata), [metadata, session])\n\n // The AI sidebar and the comments margin exclude each other: whichever opens last closes the other.\n useEffect(() => {\n if (sidebar.open) comments.set(false)\n }, [sidebar.open, comments.set])\n useEffect(() => {\n if (comments.open) sidebar.set(false)\n }, [comments.open, sidebar.set])\n\n useImperativeHandle(ref, () => ({ editor, openSettings }), [editor, openSettings])\n\n return (\n <EditorUiContext.Provider value={ui}>\n <div className=\"relative\">\n <EditorContent editor={editor} className=\"relative\" />\n </div>\n {session.overlays.map((Overlay, index) => <Overlay key={index} editor={editor} />)}\n {(props.settingsUi ?? 'internal') === 'internal' && (\n <EditorSettingsModal\n preset={preset}\n open={settingsState.open}\n onOpenChange={open => setSettingsState(state => ({ ...state, open }))}\n {...(settingsState.tab !== undefined && { tab: settingsState.tab })}\n onTabChange={tab => setSettingsState(state => ({ ...state, tab }))}\n />\n )}\n </EditorUiContext.Provider>\n )\n})\n"],"mappings":";;;;;;;;;;;;AAoEA,SAAS,aAAa,OAA4B,UAAiD;CACjG,MAAM,CAAC,UAAU,eAAe,SAAS,KAAK;CAC9C,MAAM,aAAa,UAAU,KAAA;CAC7B,MAAM,OAAO,SAAS;CACtB,MAAM,SAAS,OAAO;EAAE;EAAM;EAAY;CAAS,CAAC;CACpD,OAAO,UAAU;EAAE;EAAM;EAAY;CAAS;CAQ9C,OAAO;EAAE;EAAM,KAPH,aAAa,SAAkB;GACzC,MAAM,UAAU,OAAO;GACvB,IAAI,SAAS,QAAQ,MAAM;GAC3B,QAAQ,OAAO;GACf,IAAI,CAAC,QAAQ,YAAY,YAAY,IAAI;GACzC,QAAQ,WAAW,IAAI;EACzB,GAAG,CAAC,CACa;EAAG;CAAO;AAC7B;;;;;AAMA,SAAS,cAAc,OAAwC,KAAoB,OAKhF;CACD,MAAM,EAAE,QAAQ,eAAe,OAAO,UAAU,UAAU,YAAY,QAAQ,WAAW,eAAe,YAAY,iBAAiB,MAAM;CAE3I,MAAM,KAAe;EACnB,cAAc,MAAM;EACpB,qBAAqB,MAAM,QAAQ,IAAI,CAAC,MAAM,QAAQ,OAAO,QAAQ,IAAI;EACzE,sBAAsB,MAAM,SAAS,IAAI,CAAC,MAAM,SAAS,OAAO,QAAQ,IAAI;EAC5E,IAAI,eAAe;GACjB,OAAO,MAAM,SAAS,OAAO,QAAQ;EACvC;CACF;CAyBA,OAAO;EAAE;EAAQ;EAAI,SAtBL,qBAAqB;GACnC;GACA;GACA;GACA,QAAQ;GACR,oBAAoB;GACpB,iBAAiB,MAAM,OAAO,WAAW,KAAA;GACzC;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/core'\nimport { EditorContent, useEditor } from '@tiptap/react'\nimport { type ComponentType, forwardRef, useCallback, useEffect, useImperativeHandle, useRef, useState } from 'react'\nimport type { EditorContext } from '../core/context'\nimport { settingsTabsOf } from '../core/define-editor'\nimport type { EditorUi } from '../core/editor-ui'\nimport type { CommandDef } from '../core/commands'\nimport type { AbilitiesOptions, BlockAction } from '../core/extension-points'\nimport type { CollaborationSession, EditorFeature, EditorPreset } from '../core/feature'\nimport type { EditorMetadata, MetadataItem } from '../core/metadata-types'\nimport { createSurfaceSession } from '../core/surface-session'\nimport { useEditorContext } from './context'\nimport { EditorSettingsModal } from './EditorSettingsModal'\nimport { EditorUiContext } from './editor-ui'\nimport { reactNotifier } from './notify'\nimport { reactSuggestionRenderer } from './suggestion-renderer'\n\nexport type ReactFeature = EditorFeature<ComponentType<{ editor: Editor }>>\nexport type ReactPreset = EditorPreset<ComponentType<{ editor: Editor }>>\n\nexport interface EditorSurfaceProps {\n /** The features this editor is made of (`defineEditor(...)`); fixed at mount, remount (`key`) to change it. */\n preset: ReactPreset\n /** Collaborative mode: the Y.Doc is the document. Needs a preset with the collaboration feature; fixed at mount. */\n collaboration?: CollaborationSession\n /** Standalone mode (without `collaboration`): TipTap JSON, with `onChange`; the editor keeps its own undo history. */\n value?: JSONContent\n onChange?: (content: JSONContent) => void\n /** Host lists (`mentions`, `hashtags`, `speakers`, custom) features' suggestions search. */\n metadata?: EditorMetadata\n /** Deep-merged into the `Abilities` defaults; read once at mount. */\n abilities?: Partial<AbilitiesOptions>\n /** Added after the features' extensions; read once at mount. */\n extensions?: AnyExtension[]\n /** Hover actions shown after the features' own; shown by an installed block-UI feature. */\n blockActions?: BlockAction[]\n /** Builds the final commands (and with them the `/` menu) from the features' commands; absent = the features' commands. Read once at mount. */\n commands?: (defaults: CommandDef[]) => CommandDef[]\n /** Document whose package stores uploads (`backend.assets`, media feature). Read once at mount. */\n documentId?: string\n editable?: boolean\n /** `internal`: the surface owns its settings UI; `external`: it calls `onSettingsOpen` and the host shows the panel. */\n settingsUi?: 'internal' | 'external'\n /** The editor exists and its chrome is registered (`useEditorUi(editor)`, a host toolbar). */\n onReady?: (editor: Editor) => void\n onMetadataCreate?: (list: string, item: MetadataItem) => void\n /** The JSON handed in (initially or later) does not fit this editor's schema; the last valid document stays. */\n onContentError?: (error: Error) => void\n /** `settingsUi: 'external'`: the editor asks the host to open its settings (on `tab` when given). */\n onSettingsOpen?: (tab?: string) => void\n /** Whether this editor's AI sidebar is open (`toggleSidebar`): controlled when given. */\n sidebarOpen?: boolean\n onSidebarOpenChange?: (open: boolean) => void\n /**\n * Whether this editor's comments margin is open (`toggleComments`): controlled when given. The AI sidebar and the\n * margin exclude each other: whichever opens last closes the other.\n */\n commentsOpen?: boolean\n onCommentsOpenChange?: (open: boolean) => void\n}\n\nexport interface EditorSurfaceHandle {\n editor: Editor | null\n openSettings(tab?: string): void\n}\n\n/** A boolean that is the host's (`value` given) or the component's own (`value` undefined); the setter is stable. */\nfunction useOpenState(value: boolean | undefined, onChange: ((open: boolean) => void) | undefined) {\n const [internal, setInternal] = useState(false)\n const controlled = value !== undefined\n const open = value ?? internal\n const latest = useRef({ open, controlled, onChange })\n latest.current = { open, controlled, onChange }\n const set = useCallback((next: boolean) => {\n const current = latest.current\n if (next === current.open) return\n current.open = next\n if (!current.controlled) setInternal(next)\n current.onChange?.(next)\n }, [])\n return { open, set, latest }\n}\n\n/**\n * Everything fixed at mount: the chrome handle and the framework-free session (preset, context, extensions, content\n * check, setup lifecycle); callbacks are read from the surface's latest props.\n */\nfunction createSurface(props: { current: EditorSurfaceProps }, app: EditorContext, parts: {\n editor: { current: Editor | null }\n sidebar: { set: (open: boolean) => void, latest: { current: { open: boolean } } }\n comments: { set: (open: boolean) => void, latest: { current: { open: boolean } } }\n palette: { set: (open: boolean) => void, latest: { current: { open: boolean } } }\n openSettings: (tab?: string) => void\n}) {\n const { preset, collaboration, value, editable, metadata, documentId, abilities, commands, extensions, blockActions } = props.current\n\n const ui: EditorUi = {\n openSettings: parts.openSettings,\n toggleSidebar: () => parts.sidebar.set(!parts.sidebar.latest.current.open),\n toggleComments: () => parts.comments.set(!parts.comments.latest.current.open),\n get commentsOpen() {\n return parts.comments.latest.current.open\n },\n togglePalette: () => parts.palette.set(!parts.palette.latest.current.open),\n get paletteOpen() {\n return parts.palette.latest.current.open\n },\n }\n\n // The mode is fixed at mount; hosts switch it by remounting (`key`).\n const session = createSurfaceSession({\n app,\n preset,\n ui,\n notify: reactNotifier,\n suggestionRenderer: reactSuggestionRenderer,\n getEditor: () => parts.editor.current ?? undefined,\n collaboration,\n value,\n editable,\n metadata,\n documentId,\n abilities,\n commands,\n extensions,\n blockActions,\n onChange: content => props.current.onChange?.(content),\n onMetadataCreate: (list, item) => props.current.onMetadataCreate?.(list, item),\n onContentError: error => props.current.onContentError?.(error),\n onReady: editor => props.current.onReady?.(editor),\n })\n return { ui, session }\n}\n\nexport const EditorSurface = forwardRef<EditorSurfaceHandle, EditorSurfaceProps>(function EditorSurface(props, ref) {\n const { value, editable = true, metadata } = props\n const latest = useRef(props)\n latest.current = props\n\n const app = useEditorContext()\n const editorRef = useRef<Editor | null>(null)\n const sidebar = useOpenState(props.sidebarOpen, props.onSidebarOpenChange)\n const comments = useOpenState(props.commentsOpen, props.onCommentsOpenChange)\n // The ⌘K palette (the `core-ui` overlay, when the preset has one): the surface's own state.\n const palette = useOpenState(undefined, undefined)\n // `settingsUi: 'internal'`: the surface's own settings modal (`openSettings` opens it).\n const [settingsState, setSettingsState] = useState<{ open: boolean, tab: string | undefined }>({ open: false, tab: undefined })\n\n const openSettings = useCallback((tab?: string) => {\n // Nothing to open without a contributed tab.\n if (!settingsTabsOf(latest.current.preset, app).length) return\n if ((latest.current.settingsUi ?? 'internal') === 'external') {\n latest.current.onSettingsOpen?.(tab)\n return\n }\n setSettingsState(state => ({ open: true, tab: tab ?? state.tab }))\n }, [])\n\n const [{ ui, session }] = useState(() => createSurface(latest, app, { editor: editorRef, sidebar, comments, palette, openSettings }))\n\n const editor = useEditor({\n ...session.editorOptions,\n immediatelyRender: true,\n shouldRerenderOnTransaction: false,\n })\n editorRef.current = editor\n\n // Per-mount side effects of features (`setup`). Activation and deactivation are paired, so StrictMode's mount,\n // cleanup, mount leaves exactly one active setup, and unmounting tears it down.\n useEffect(() => {\n session.activate()\n return () => session.deactivate()\n }, [session])\n\n // The editor exists from the first render; its chrome is registered before the session announces it through\n // `onReady`, so a host toolbar that receives it finds the chrome.\n useEffect(() => session.register(editor), [editor, session])\n\n // External replacement of the standalone document (the host loaded or reset it); not an edit, so no update event.\n useEffect(() => session.setValue(value), [value, editor, session])\n\n useEffect(() => session.setEditable(editable), [editable, editor, session])\n\n useEffect(() => session.setMetadata(metadata), [metadata, session])\n\n // The AI sidebar and the comments margin exclude each other: whichever opens last closes the other.\n useEffect(() => {\n if (sidebar.open) comments.set(false)\n }, [sidebar.open, comments.set])\n useEffect(() => {\n if (comments.open) sidebar.set(false)\n }, [comments.open, sidebar.set])\n\n useImperativeHandle(ref, () => ({ editor, openSettings }), [editor, openSettings])\n\n return (\n <EditorUiContext.Provider value={ui}>\n <div className=\"relative\">\n <EditorContent editor={editor} className=\"relative\" />\n </div>\n {session.overlays.map((Overlay, index) => <Overlay key={index} editor={editor} />)}\n {(props.settingsUi ?? 'internal') === 'internal' && (\n <EditorSettingsModal\n {...(editor && { editor })}\n open={settingsState.open}\n onOpenChange={open => setSettingsState(state => ({ ...state, open }))}\n {...(settingsState.tab !== undefined && { tab: settingsState.tab })}\n onTabChange={tab => setSettingsState(state => ({ ...state, tab }))}\n />\n )}\n </EditorUiContext.Provider>\n )\n})\n"],"mappings":";;;;;;;;;;;;AAmEA,SAAS,aAAa,OAA4B,UAAiD;CACjG,MAAM,CAAC,UAAU,eAAe,SAAS,KAAK;CAC9C,MAAM,aAAa,UAAU,KAAA;CAC7B,MAAM,OAAO,SAAS;CACtB,MAAM,SAAS,OAAO;EAAE;EAAM;EAAY;CAAS,CAAC;CACpD,OAAO,UAA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CAGlE,gBAAgB;EACd,IAAI,QAAQ,MAAM,SAAS,IAAI,KAAK;CACtC,GAAG,CAAC,QAAQ,MAAM,SAAS,GAAG,CAAC;CAC/B,gBAAgB;EACd,IAAI,SAAS,MAAM,QAAQ,IAAI,KAAK;CACtC,GAAG,CAAC,SAAS,MAAM,QAAQ,GAAG,CAAC;CAE/B,oBAAoB,YAAY;EAAE;EAAQ;CAAa,IAAI,CAAC,QAAQ,YAAY,CAAC;CAEjF,OACE,qBAAC,gBAAgB,UAAjB;EAA0B,OAAO;EAAjC,UAAA;GACE,oBAAC,OAAD;IAAK,WAAU;IACb,UAAA,oBAAC,eAAD;KAAuB;KAAQ,WAAU;IAAY,CAAA;GAClD,CAAA;GACJ,QAAQ,SAAS,KAAK,SAAS,UAAU,oBAAC,SAAD,EAA6B,OAAS,GAAxB,KAAwB,CAAC;IAC/E,MAAM,cAAc,gBAAgB,cACpC,oBAAC,qBAAD;IACE,GAAK,UAAU,EAAE,OAAO;IACxB,MAAM,cAAc;IACpB,eAAc,SAAQ,kBAAiB,WAAU;KAAE,GAAG;KAAO;IAAK,EAAE;IACpE,GAAK,cAAc,QAAQ,KAAA,KAAa,EAAE,KAAK,cAAc,IAAI;IACjE,cAAa,QAAO,kBAAiB,WAAU;KAAE,GAAG;KAAO;IAAI,EAAE;GAClE,CAAA;EAEqB;;AAE9B,CAAC"}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
import { ReactPreset } from "./EditorSurface.js";
|
|
2
1
|
import { Editor } from "@tiptap/core";
|
|
3
2
|
//#region src/react/EditorToolbar.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* The toolbar of an editor, placed anywhere on the page. `editor` is the instance it works on (from the surface's
|
|
6
|
-
* `onReady`); the preset registered for that instance supplies the groups
|
|
7
|
-
*
|
|
8
|
-
* which its keyed surface remounts. Never reads a global active editor.
|
|
5
|
+
* `onReady`); the preset registered for that instance (`editorEntryOf`) supplies the groups. Without an editor (not
|
|
6
|
+
* mounted yet, or read-only by the host's choice) it renders no groups. A destroyed editor counts as none: a host still
|
|
7
|
+
* holds the old instance for the render in which its keyed surface remounts. Never reads a global active editor.
|
|
9
8
|
*/
|
|
10
|
-
export declare function EditorToolbar({ editor: given
|
|
9
|
+
export declare function EditorToolbar({ editor: given }: {
|
|
11
10
|
editor?: Editor;
|
|
12
|
-
preset?: ReactPreset;
|
|
13
11
|
}): import("react").JSX.Element;
|
|
14
12
|
//#endregion
|
|
15
13
|
//# sourceMappingURL=EditorToolbar.d.ts.map
|