@ecsplico/editor 3.6.0 → 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +73 -0
- package/dist/adapters/direct-ai.d.ts +4 -4
- package/dist/adapters/direct-ai.js +2 -2
- package/dist/adapters/direct-ai.js.map +1 -1
- package/dist/adapters/document-state.d.ts +1 -1
- package/dist/adapters/document-state.js.map +1 -1
- package/dist/adapters/forge.d.ts +2 -2
- package/dist/adapters/forge.js.map +1 -1
- package/dist/adapters/nitro.d.ts +11 -3
- package/dist/adapters/nitro.js +3 -1
- package/dist/adapters/nitro.js.map +1 -1
- package/dist/adapters/shared.d.ts +6 -6
- package/dist/adapters/shared.js.map +1 -1
- package/dist/code/CodeSurface.vue.d.ts +3 -3
- package/dist/config/index.d.ts +14 -14
- package/dist/config/index.js +8 -8
- package/dist/config/index.js.map +1 -1
- package/dist/core/backend-types.d.ts +3 -3
- package/dist/core/backend-types.js.map +1 -1
- package/dist/core/backend.d.ts +4 -4
- package/dist/core/backend.js.map +1 -1
- package/dist/core/block-convert.d.ts +1 -1
- package/dist/core/block-convert.js +5 -5
- package/dist/core/block-convert.js.map +1 -1
- package/dist/core/block-transfer.d.ts +8 -4
- package/dist/core/block-transfer.js +23 -14
- package/dist/core/block-transfer.js.map +1 -1
- package/dist/core/capabilities.d.ts +113 -0
- package/dist/core/capabilities.js +155 -0
- package/dist/core/capabilities.js.map +1 -0
- package/dist/core/command-types.d.ts +1 -1
- package/dist/core/context.js.map +1 -1
- package/dist/core/convert.d.ts +5 -5
- package/dist/core/convert.js +5 -5
- package/dist/core/convert.js.map +1 -1
- package/dist/core/core-feature.js +1 -1
- package/dist/core/define-editor.d.ts +2 -2
- package/dist/core/define-editor.js +34 -6
- package/dist/core/define-editor.js.map +1 -1
- package/dist/core/derivation.d.ts +119 -0
- package/dist/core/derivation.js +187 -0
- package/dist/core/derivation.js.map +1 -0
- package/dist/core/derive.d.ts +61 -0
- package/dist/core/derive.js +69 -0
- package/dist/core/derive.js.map +1 -0
- package/dist/core/extension-points.d.ts +16 -0
- package/dist/core/feature-context.d.ts +5 -1
- package/dist/core/feature-context.js +10 -3
- package/dist/core/feature-context.js.map +1 -1
- package/dist/core/feature.d.ts +41 -19
- package/dist/core/feature.js.map +1 -1
- package/dist/core/fences.js +1 -1
- package/dist/core/fences.js.map +1 -1
- package/dist/core/index.d.ts +6 -2
- package/dist/core/index.js +5 -1
- package/dist/core/pipeline.d.ts +14 -5
- package/dist/core/pipeline.js +19 -7
- package/dist/core/pipeline.js.map +1 -1
- package/dist/core/properties.d.ts +22 -0
- package/dist/core/properties.js +17 -0
- package/dist/core/properties.js.map +1 -0
- package/dist/core/schema/block-ids.js +5 -5
- package/dist/core/schema/block-ids.js.map +1 -1
- package/dist/core/schema/index.d.ts +2 -1
- package/dist/core/schema/index.js +2 -1
- package/dist/core/schema/index.js.map +1 -1
- package/dist/core/schema/opaque-fence.d.ts +4 -4
- package/dist/core/schema/opaque-fence.js +7 -7
- package/dist/core/schema/opaque-fence.js.map +1 -1
- package/dist/core/schema/persisted-names.d.ts +58 -0
- package/dist/core/schema/persisted-names.js +96 -0
- package/dist/core/schema/persisted-names.js.map +1 -0
- package/dist/core/toolbar-items.js +1 -1
- package/dist/core/toolbar-items.js.map +1 -1
- package/dist/core/util.js +5 -1
- package/dist/core/util.js.map +1 -1
- package/dist/document/DocumentSurface.vue.d.ts +3 -3
- package/dist/features/ai/agent-ops.js +1 -1
- package/dist/features/ai/ai-review.js +1 -1
- package/dist/features/ai/assistant.d.ts +4 -4
- package/dist/features/ai/assistant.js +1 -1
- package/dist/features/ai/assistant.js.map +1 -1
- package/dist/features/ai/components/AiSelectionMenu.js +1 -1
- package/dist/features/ai/components/AiSelectionMenu.js.map +1 -1
- package/dist/features/ai/components/ModelQuickSwitch.js +7 -7
- package/dist/features/ai/components/ModelQuickSwitch.js.map +1 -1
- package/dist/features/ai/components/ModelQuickSwitch.vue.d.ts +4 -4
- package/dist/features/ai/components/SettingsAiTab.js +8 -8
- package/dist/features/ai/components/SettingsAiTab.js.map +1 -1
- package/dist/features/ai/components/SettingsModelProfiles.js +1 -1
- package/dist/features/ai/components/SettingsModelProfiles.js.map +1 -1
- package/dist/features/ai/document-chat-model.d.ts +2 -2
- package/dist/features/ai/document-chat-model.js +5 -5
- package/dist/features/ai/document-chat-model.js.map +1 -1
- package/dist/features/ai/document-chat.js +2 -2
- package/dist/features/ai/document-chat.js.map +1 -1
- package/dist/features/ai/feature.d.ts +2 -2
- package/dist/features/ai/feature.js +2 -2
- package/dist/features/ai/feature.js.map +1 -1
- package/dist/features/ai/ghost-autocomplete.d.ts +4 -4
- package/dist/features/ai/ghost-autocomplete.js +1 -1
- package/dist/features/ai/ghost-autocomplete.js.map +1 -1
- package/dist/features/ai/index.d.ts +3 -3
- package/dist/features/ai/index.js +2 -2
- package/dist/features/ai/model-profiles.d.ts +9 -9
- package/dist/features/ai/model-profiles.js +13 -13
- package/dist/features/ai/model-profiles.js.map +1 -1
- package/dist/features/ai/protocol/agent-ops.d.ts +2 -2
- package/dist/features/ai/protocol/agent-ops.js +1 -1
- package/dist/features/ai/protocol/agent-ops.js.map +1 -1
- package/dist/features/ai/protocol/block-lines.d.ts +7 -7
- package/dist/features/ai/protocol/block-lines.js +10 -10
- package/dist/features/ai/protocol/block-lines.js.map +1 -1
- package/dist/features/ai/protocol/chat.d.ts +5 -5
- package/dist/features/ai/protocol/chat.js +12 -12
- package/dist/features/ai/protocol/chat.js.map +1 -1
- package/dist/features/ai/protocol/generate.d.ts +1 -1
- package/dist/features/ai/protocol/generate.js +1 -1
- package/dist/features/ai/protocol/generate.js.map +1 -1
- package/dist/features/ai/protocol/index.d.ts +3 -3
- package/dist/features/ai/protocol/index.js +2 -2
- package/dist/features/ai/protocol/models.d.ts +3 -3
- package/dist/features/ai/protocol/models.js +3 -3
- package/dist/features/ai/protocol/models.js.map +1 -1
- package/dist/features/ai/protocol/schemas.d.ts +1 -1
- package/dist/features/ai/protocol/schemas.js +1 -1
- package/dist/features/ai/protocol/schemas.js.map +1 -1
- package/dist/features/ai/protocol/tasks.d.ts +5 -5
- package/dist/features/ai/protocol/tasks.js +12 -12
- package/dist/features/ai/protocol/tasks.js.map +1 -1
- package/dist/features/ai/react/AiSelectionMenu.js.map +1 -1
- package/dist/features/ai/react/ModelQuickSwitch.d.ts +4 -4
- package/dist/features/ai/react/ModelQuickSwitch.js +6 -6
- package/dist/features/ai/react/ModelQuickSwitch.js.map +1 -1
- package/dist/features/ai/react/SettingsAiTab.d.ts +1 -1
- package/dist/features/ai/react/SettingsAiTab.js +8 -8
- package/dist/features/ai/react/SettingsAiTab.js.map +1 -1
- package/dist/features/ai/react/SettingsModelProfiles.d.ts +1 -1
- package/dist/features/ai/react/SettingsModelProfiles.js +1 -1
- package/dist/features/ai/react/SettingsModelProfiles.js.map +1 -1
- package/dist/features/ai/react/use-ai-assistant.d.ts +1 -1
- package/dist/features/ai/react/use-ai-assistant.js +1 -1
- package/dist/features/ai/react/use-ai-assistant.js.map +1 -1
- package/dist/features/ai/react/use-model-profiles.d.ts +5 -5
- package/dist/features/ai/react/use-model-profiles.js +2 -2
- package/dist/features/ai/react/use-model-profiles.js.map +1 -1
- package/dist/features/ai/use-ai-assistant.d.ts +1 -1
- package/dist/features/ai/use-ai-assistant.js +1 -1
- package/dist/features/ai/use-ai-assistant.js.map +1 -1
- package/dist/features/ai/use-model-profiles.d.ts +4 -4
- package/dist/features/ai/use-model-profiles.js +2 -2
- package/dist/features/ai/use-model-profiles.js.map +1 -1
- package/dist/features/block-ui/block-actions.d.ts +8 -4
- package/dist/features/block-ui/block-actions.js +38 -22
- package/dist/features/block-ui/block-actions.js.map +1 -1
- package/dist/features/block-ui/block-target.d.ts +29 -0
- package/dist/features/block-ui/block-target.js +63 -0
- package/dist/features/block-ui/block-target.js.map +1 -0
- package/dist/features/block-ui/components/BlockHandles.js +3 -3
- package/dist/features/block-ui/components/BlockHandles.js.map +1 -1
- package/dist/features/block-ui/components/BlockUi.js +11 -23
- package/dist/features/block-ui/components/BlockUi.js.map +1 -1
- package/dist/features/block-ui/feature.d.ts +3 -2
- package/dist/features/block-ui/feature.js +3 -2
- package/dist/features/block-ui/feature.js.map +1 -1
- package/dist/features/block-ui/handle-geometry.js +12 -23
- package/dist/features/block-ui/handle-geometry.js.map +1 -1
- package/dist/features/block-ui/index.d.ts +2 -1
- package/dist/features/block-ui/index.js +2 -1
- package/dist/features/block-ui/react/BlockHandles.d.ts +1 -1
- package/dist/features/block-ui/react/BlockHandles.js +4 -4
- package/dist/features/block-ui/react/BlockHandles.js.map +1 -1
- package/dist/features/block-ui/react/BlockUi.js +13 -25
- package/dist/features/block-ui/react/BlockUi.js.map +1 -1
- package/dist/features/comments/model.js +1 -1
- package/dist/features/composites/accepted-children.d.ts +5 -4
- package/dist/features/composites/accepted-children.js +26 -26
- package/dist/features/composites/accepted-children.js.map +1 -1
- package/dist/features/composites/ai-brief.d.ts +4 -4
- package/dist/features/composites/ai-brief.js +14 -12
- package/dist/features/composites/ai-brief.js.map +1 -1
- package/dist/features/composites/anchors.d.ts +1 -1
- package/dist/features/composites/anchors.js.map +1 -1
- package/dist/features/composites/baskets.d.ts +1 -1
- package/dist/features/composites/baskets.js.map +1 -1
- package/dist/features/composites/bibliography-command.d.ts +1 -1
- package/dist/features/composites/bibliography-form.js +1 -1
- package/dist/features/composites/bibliography-form.js.map +1 -1
- package/dist/features/composites/bibliography.js.map +1 -1
- package/dist/features/composites/block-types-json.d.ts +38 -0
- package/dist/features/composites/block-types-json.js +122 -0
- package/dist/features/composites/block-types-json.js.map +1 -0
- package/dist/features/composites/block-types.d.ts +119 -0
- package/dist/features/composites/block-types.js +343 -0
- package/dist/features/composites/block-types.js.map +1 -0
- package/dist/features/composites/capabilities.js +109 -0
- package/dist/features/composites/capabilities.js.map +1 -0
- package/dist/features/composites/components/BibliographyEditor.js +5 -5
- package/dist/features/composites/components/BibliographyEditor.js.map +1 -1
- package/dist/features/composites/components/CompositeBasketMenu.js +2 -2
- package/dist/features/composites/components/CompositeBasketMenu.js.map +1 -1
- package/dist/features/composites/components/CompositeChrome.js +18 -8
- package/dist/features/composites/components/CompositeChrome.js.map +1 -1
- package/dist/features/composites/components/CompositeChrome.vue.d.ts +1 -1
- package/dist/features/composites/components/CompositeDetails.js +11 -10
- package/dist/features/composites/components/CompositeDetails.js.map +1 -1
- package/dist/features/composites/components/CompositeDetails.vue.d.ts +1 -1
- package/dist/features/composites/components/CompositeFieldEditor.js +7 -7
- package/dist/features/composites/components/CompositeFieldEditor.js.map +1 -1
- package/dist/features/composites/components/CompositeFieldEditor.vue.d.ts +5 -5
- package/dist/features/composites/components/CompositeInspector.js +136 -113
- package/dist/features/composites/components/CompositeInspector.js.map +1 -1
- package/dist/features/composites/components/CompositeInspector.vue.d.ts +3 -3
- package/dist/features/composites/components/CompositeStatusMenu.js +2 -2
- package/dist/features/composites/components/CompositeStatusMenu.js.map +1 -1
- package/dist/features/composites/components/CompositeSummaryEditor.js +1 -1
- package/dist/features/composites/components/CompositeSummaryEditor.js.map +1 -1
- package/dist/features/composites/components/CompositeSummaryEditor.vue.d.ts +1 -1
- package/dist/features/composites/components/CompositeTable.js +2 -2
- package/dist/features/composites/components/CompositeTable.js.map +1 -1
- package/dist/features/composites/components/CompositeTagsEditor.js +1 -1
- package/dist/features/composites/components/CompositeTagsEditor.js.map +1 -1
- package/dist/features/composites/components/CompositeTagsEditor.vue.d.ts +1 -1
- package/dist/features/composites/components/CompositeView.js +19 -17
- package/dist/features/composites/components/CompositeView.js.map +1 -1
- package/dist/features/composites/components/DerivationBadge.js +15 -6
- package/dist/features/composites/components/DerivationBadge.js.map +1 -1
- package/dist/features/composites/components/FocusChip.js +1 -1
- package/dist/features/composites/components/FocusChip.js.map +1 -1
- package/dist/features/composites/components/FocusChip.vue.d.ts +1 -1
- package/dist/features/composites/components/ReferenceFieldSelect.js +3 -3
- package/dist/features/composites/components/ReferenceFieldSelect.js.map +1 -1
- package/dist/features/composites/components/ReferenceView.js +1 -1
- package/dist/features/composites/components/ReferenceView.js.map +1 -1
- package/dist/features/composites/components/SettingsEditingTab.js +18 -18
- package/dist/features/composites/components/SettingsEditingTab.js.map +1 -1
- package/dist/features/composites/components/SettingsEditingTab.vue.d.ts +3 -3
- package/dist/features/composites/convert.d.ts +4 -4
- package/dist/features/composites/convert.js +27 -28
- package/dist/features/composites/convert.js.map +1 -1
- package/dist/features/composites/derived-chrome.js +34 -28
- package/dist/features/composites/derived-chrome.js.map +1 -1
- package/dist/features/composites/editing-settings-keys.js +6 -6
- package/dist/features/composites/editing-settings-keys.js.map +1 -1
- package/dist/features/composites/feature.d.ts +10 -10
- package/dist/features/composites/feature.js +58 -46
- package/dist/features/composites/feature.js.map +1 -1
- package/dist/features/composites/fences.d.ts +3 -3
- package/dist/features/composites/fences.js +18 -13
- package/dist/features/composites/fences.js.map +1 -1
- package/dist/features/composites/focus.d.ts +10 -10
- package/dist/features/composites/focus.js +11 -11
- package/dist/features/composites/focus.js.map +1 -1
- package/dist/features/composites/heading-composites.d.ts +5 -5
- package/dist/features/composites/heading-composites.js +13 -16
- package/dist/features/composites/heading-composites.js.map +1 -1
- package/dist/features/composites/index.d.ts +20 -18
- package/dist/features/composites/index.js +9 -7
- package/dist/features/composites/inspector-model.d.ts +45 -22
- package/dist/features/composites/inspector-model.js +53 -14
- package/dist/features/composites/inspector-model.js.map +1 -1
- package/dist/features/composites/legacy.d.ts +5 -4
- package/dist/features/composites/legacy.js +16 -23
- package/dist/features/composites/legacy.js.map +1 -1
- package/dist/features/composites/markdown-export.js +3 -3
- package/dist/features/composites/markdown-export.js.map +1 -1
- package/dist/features/composites/merge.d.ts +8 -8
- package/dist/features/composites/merge.js +23 -22
- package/dist/features/composites/merge.js.map +1 -1
- package/dist/features/composites/meta-display.js +5 -5
- package/dist/features/composites/meta-display.js.map +1 -1
- package/dist/features/composites/meta-keys.d.ts +5 -5
- package/dist/features/composites/meta-keys.js +8 -8
- package/dist/features/composites/meta-keys.js.map +1 -1
- package/dist/features/composites/node-views.d.ts +3 -3
- package/dist/features/composites/node-views.js +2 -2
- package/dist/features/composites/node-views.js.map +1 -1
- package/dist/features/composites/nodes.d.ts +13 -13
- package/dist/features/composites/nodes.js +100 -77
- package/dist/features/composites/nodes.js.map +1 -1
- package/dist/features/composites/outline.d.ts +15 -12
- package/dist/features/composites/outline.js +24 -21
- package/dist/features/composites/outline.js.map +1 -1
- package/dist/features/composites/properties.d.ts +51 -0
- package/dist/features/composites/properties.js +89 -0
- package/dist/features/composites/properties.js.map +1 -0
- package/dist/features/composites/react/BibliographyEditor.js +5 -5
- package/dist/features/composites/react/BibliographyEditor.js.map +1 -1
- package/dist/features/composites/react/CompositeBasketMenu.js +2 -2
- package/dist/features/composites/react/CompositeBasketMenu.js.map +1 -1
- package/dist/features/composites/react/CompositeChrome.d.ts +1 -1
- package/dist/features/composites/react/CompositeChrome.js +15 -6
- package/dist/features/composites/react/CompositeChrome.js.map +1 -1
- package/dist/features/composites/react/CompositeDetails.d.ts +1 -1
- package/dist/features/composites/react/CompositeDetails.js +11 -10
- package/dist/features/composites/react/CompositeDetails.js.map +1 -1
- package/dist/features/composites/react/CompositeFieldEditor.d.ts +5 -5
- package/dist/features/composites/react/CompositeFieldEditor.js +6 -6
- package/dist/features/composites/react/CompositeFieldEditor.js.map +1 -1
- package/dist/features/composites/react/CompositeInspector.d.ts +3 -3
- package/dist/features/composites/react/CompositeInspector.js +142 -128
- package/dist/features/composites/react/CompositeInspector.js.map +1 -1
- package/dist/features/composites/react/CompositeStatusMenu.js +2 -2
- package/dist/features/composites/react/CompositeStatusMenu.js.map +1 -1
- package/dist/features/composites/react/CompositeSummaryEditor.d.ts +1 -1
- package/dist/features/composites/react/CompositeSummaryEditor.js +1 -1
- package/dist/features/composites/react/CompositeSummaryEditor.js.map +1 -1
- package/dist/features/composites/react/CompositeTable.d.ts +1 -1
- package/dist/features/composites/react/CompositeTable.js +3 -3
- package/dist/features/composites/react/CompositeTable.js.map +1 -1
- package/dist/features/composites/react/CompositeTagsEditor.d.ts +1 -1
- package/dist/features/composites/react/CompositeTagsEditor.js +1 -1
- package/dist/features/composites/react/CompositeTagsEditor.js.map +1 -1
- package/dist/features/composites/react/CompositeView.js +17 -15
- package/dist/features/composites/react/CompositeView.js.map +1 -1
- package/dist/features/composites/react/DerivationBadge.js +13 -4
- package/dist/features/composites/react/DerivationBadge.js.map +1 -1
- package/dist/features/composites/react/FocusChip.d.ts +1 -1
- package/dist/features/composites/react/FocusChip.js +1 -1
- package/dist/features/composites/react/FocusChip.js.map +1 -1
- package/dist/features/composites/react/ReferenceFieldSelect.js +3 -3
- package/dist/features/composites/react/ReferenceFieldSelect.js.map +1 -1
- package/dist/features/composites/react/ReferenceView.d.ts +1 -1
- package/dist/features/composites/react/ReferenceView.js +1 -1
- package/dist/features/composites/react/ReferenceView.js.map +1 -1
- package/dist/features/composites/react/SettingsEditingTab.d.ts +4 -4
- package/dist/features/composites/react/SettingsEditingTab.js +20 -20
- package/dist/features/composites/react/SettingsEditingTab.js.map +1 -1
- package/dist/features/composites/react.js +1 -1
- package/dist/features/composites/react.js.map +1 -1
- package/dist/features/composites/reference-ai.js +1 -1
- package/dist/features/composites/reference-ai.js.map +1 -1
- package/dist/features/composites/reference-label.d.ts +3 -3
- package/dist/features/composites/reference-label.js +6 -6
- package/dist/features/composites/reference-label.js.map +1 -1
- package/dist/features/composites/reference-suggestion.d.ts +1 -1
- package/dist/features/composites/reference-suggestion.js +3 -3
- package/dist/features/composites/reference-suggestion.js.map +1 -1
- package/dist/features/composites/reference-text.d.ts +2 -2
- package/dist/features/composites/reference-text.js +4 -4
- package/dist/features/composites/reference-text.js.map +1 -1
- package/dist/features/composites/reference.d.ts +3 -3
- package/dist/features/composites/reference.js +1 -1
- package/dist/features/composites/reference.js.map +1 -1
- package/dist/features/composites/reveal-source.d.ts +3 -3
- package/dist/features/composites/reveal-source.js +6 -6
- package/dist/features/composites/reveal-source.js.map +1 -1
- package/dist/features/composites/rows-model.d.ts +2 -2
- package/dist/features/composites/rows-model.js +4 -3
- package/dist/features/composites/rows-model.js.map +1 -1
- package/dist/features/composites/rows.d.ts +16 -28
- package/dist/features/composites/rows.js +20 -54
- package/dist/features/composites/rows.js.map +1 -1
- package/dist/features/composites/schema.d.ts +12 -11
- package/dist/features/composites/schema.js +10 -9
- package/dist/features/composites/schema.js.map +1 -1
- package/dist/features/composites/source.d.ts +20 -0
- package/dist/features/composites/source.js +40 -0
- package/dist/features/composites/source.js.map +1 -0
- package/dist/features/composites/split.d.ts +11 -11
- package/dist/features/composites/split.js +20 -20
- package/dist/features/composites/split.js.map +1 -1
- package/dist/features/composites/structure-mode.js +3 -3
- package/dist/features/composites/structure-mode.js.map +1 -1
- package/dist/features/composites/table-model.js +2 -2
- package/dist/features/composites/table-model.js.map +1 -1
- package/dist/features/composites/use-composite-inspector.js +3 -1
- package/dist/features/composites/use-composite-inspector.js.map +1 -1
- package/dist/features/composites/use-composite-rows.d.ts +2 -2
- package/dist/features/composites/use-composite-rows.js.map +1 -1
- package/dist/features/composites/vue.js +1 -1
- package/dist/features/composites/vue.js.map +1 -1
- package/dist/features/image-studio/components/ImageStudioDialog.js +150 -87
- package/dist/features/image-studio/components/ImageStudioDialog.js.map +1 -1
- package/dist/features/image-studio/components/ImageStudioDialog.vue.d.ts +5 -1
- package/dist/features/image-studio/components/ImageStudioLibraryPanel.js +186 -0
- package/dist/features/image-studio/components/ImageStudioLibraryPanel.js.map +1 -0
- package/dist/features/image-studio/components/ImageStudioLibraryTile.js +134 -0
- package/dist/features/image-studio/components/ImageStudioLibraryTile.js.map +1 -0
- package/dist/features/image-studio/components/ImageStudioView.js.map +1 -1
- package/dist/features/image-studio/feature.d.ts +1 -1
- package/dist/features/image-studio/feature.js +1 -1
- package/dist/features/image-studio/feature.js.map +1 -1
- package/dist/features/image-studio/index.d.ts +3 -2
- package/dist/features/image-studio/index.js +2 -2
- package/dist/features/image-studio/library.d.ts +35 -0
- package/dist/features/image-studio/node-core.d.ts +3 -3
- package/dist/features/image-studio/node-core.js +1 -1
- package/dist/features/image-studio/node-core.js.map +1 -1
- package/dist/features/image-studio/node-store.d.ts +1 -1
- package/dist/features/image-studio/node-store.js +1 -1
- package/dist/features/image-studio/node-store.js.map +1 -1
- package/dist/features/image-studio/react/ImageStudioDialog.d.ts +1 -1
- package/dist/features/image-studio/react/ImageStudioDialog.js +46 -5
- package/dist/features/image-studio/react/ImageStudioDialog.js.map +1 -1
- package/dist/features/image-studio/react/ImageStudioLibraryPanel.js +141 -0
- package/dist/features/image-studio/react/ImageStudioLibraryPanel.js.map +1 -0
- package/dist/features/image-studio/react/ImageStudioLibraryTile.js +105 -0
- package/dist/features/image-studio/react/ImageStudioLibraryTile.js.map +1 -0
- package/dist/features/image-studio/react/ImageStudioView.js +1 -1
- package/dist/features/image-studio/react/ImageStudioView.js.map +1 -1
- package/dist/features/image-studio/react/store.d.ts +8 -3
- package/dist/features/image-studio/react/store.js.map +1 -1
- package/dist/features/image-studio/react.d.ts +4 -3
- package/dist/features/image-studio/react.js +3 -3
- package/dist/features/image-studio/react.js.map +1 -1
- package/dist/features/image-studio/schema.d.ts +1 -1
- package/dist/features/image-studio/schema.js +1 -1
- package/dist/features/image-studio/schema.js.map +1 -1
- package/dist/features/image-studio/state.d.ts +8 -3
- package/dist/features/image-studio/state.js +11 -3
- package/dist/features/image-studio/state.js.map +1 -1
- package/dist/features/image-studio/store.d.ts +8 -3
- package/dist/features/image-studio/vue.d.ts +4 -3
- package/dist/features/image-studio/vue.js +3 -3
- package/dist/features/image-studio/vue.js.map +1 -1
- package/dist/features/mentions/tag.js +2 -1
- package/dist/features/mentions/tag.js.map +1 -1
- package/dist/features/themes/components/SettingsAppearanceTab.js +1 -1
- package/dist/features/themes/components/SettingsAppearanceTab.js.map +1 -1
- package/dist/features/themes/feature.d.ts +1 -1
- package/dist/features/themes/feature.js.map +1 -1
- package/dist/features/themes/react/SettingsAppearanceTab.d.ts +1 -1
- package/dist/features/themes/react/SettingsAppearanceTab.js +1 -1
- package/dist/features/themes/react/SettingsAppearanceTab.js.map +1 -1
- package/dist/features/themes/theme-runtime.js +1 -1
- package/dist/features/themes/theme-runtime.js.map +1 -1
- package/dist/features/transcript/TranscriptSegmentView.js +1 -1
- package/dist/features/transcript/TranscriptSegmentView.js.map +1 -1
- package/dist/features/transcript/react/TranscriptSegmentView.js +1 -1
- package/dist/features/transcript/react/TranscriptSegmentView.js.map +1 -1
- package/dist/features/transcript/segment-node.js.map +1 -1
- package/dist/features/transfer/feature.js +1 -1
- package/dist/features/transfer/feature.js.map +1 -1
- package/dist/features/transfer/transforms.d.ts +4 -4
- package/dist/features/transfer/transforms.js +12 -12
- package/dist/features/transfer/transforms.js.map +1 -1
- package/dist/i18n/de/ai.js +4 -4
- package/dist/i18n/de/ai.js.map +1 -1
- package/dist/i18n/de/authors.js +1 -1
- package/dist/i18n/de/authors.js.map +1 -1
- package/dist/i18n/de/comments.js +1 -1
- package/dist/i18n/de/comments.js.map +1 -1
- package/dist/i18n/de/composites.js +62 -59
- package/dist/i18n/de/composites.js.map +1 -1
- package/dist/i18n/de/image-studio.js +11 -2
- package/dist/i18n/de/image-studio.js.map +1 -1
- package/dist/i18n/de/integrations.js +20 -20
- package/dist/i18n/de/integrations.js.map +1 -1
- package/dist/i18n/de/markdown.js +1 -1
- package/dist/i18n/de/markdown.js.map +1 -1
- package/dist/i18n/de/palette.js +1 -1
- package/dist/i18n/de/palette.js.map +1 -1
- package/dist/i18n/de/themes.js +3 -3
- package/dist/i18n/de/themes.js.map +1 -1
- package/dist/i18n/de/transfer.js +2 -2
- package/dist/i18n/de/transfer.js.map +1 -1
- package/dist/i18n/de/tree.js +6 -6
- package/dist/i18n/de/tree.js.map +1 -1
- package/dist/i18n/de.d.ts +110 -98
- package/dist/i18n/en/ai.js +2 -2
- package/dist/i18n/en/ai.js.map +1 -1
- package/dist/i18n/en/composites.js +64 -61
- package/dist/i18n/en/composites.js.map +1 -1
- package/dist/i18n/en/image-studio.js +9 -0
- package/dist/i18n/en/image-studio.js.map +1 -1
- package/dist/i18n/en/integrations.js +9 -9
- package/dist/i18n/en/integrations.js.map +1 -1
- package/dist/i18n/en/markdown.js +1 -1
- package/dist/i18n/en/markdown.js.map +1 -1
- package/dist/i18n/en/palette.js +1 -1
- package/dist/i18n/en/palette.js.map +1 -1
- package/dist/i18n/en/themes.js +4 -4
- package/dist/i18n/en/themes.js.map +1 -1
- package/dist/i18n/en/tree.js +5 -5
- package/dist/i18n/en/tree.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/integrations/composite-ai/bibliography-fetch.d.ts +6 -6
- package/dist/integrations/composite-ai/bibliography-fetch.js +19 -19
- package/dist/integrations/composite-ai/bibliography-fetch.js.map +1 -1
- package/dist/integrations/composite-ai/composite-fill.d.ts +4 -4
- package/dist/integrations/composite-ai/composite-fill.js +5 -5
- package/dist/integrations/composite-ai/composite-fill.js.map +1 -1
- package/dist/integrations/composite-ai/composite-summary.d.ts +2 -2
- package/dist/integrations/composite-ai/composite-summary.js +5 -5
- package/dist/integrations/composite-ai/composite-summary.js.map +1 -1
- package/dist/integrations/composite-ai/derive.d.ts +17 -17
- package/dist/integrations/composite-ai/derive.js +27 -26
- package/dist/integrations/composite-ai/derive.js.map +1 -1
- package/dist/integrations/composite-ai/index.d.ts +14 -15
- package/dist/integrations/composite-ai/index.js +98 -77
- package/dist/integrations/composite-ai/index.js.map +1 -1
- package/dist/integrations/composite-ai/outline-sanitize.d.ts +1 -1
- package/dist/integrations/composite-ai/outline-sanitize.js +1 -1
- package/dist/integrations/composite-ai/outline-sanitize.js.map +1 -1
- package/dist/integrations/composite-ai/rendition.d.ts +9 -9
- package/dist/integrations/composite-ai/rendition.js +27 -27
- package/dist/integrations/composite-ai/rendition.js.map +1 -1
- package/dist/integrations/composite-ai/split.d.ts +8 -8
- package/dist/integrations/composite-ai/split.js +12 -12
- package/dist/integrations/composite-ai/split.js.map +1 -1
- package/dist/integrations/composite-ai/transfer-transforms.d.ts +2 -2
- package/dist/integrations/composite-ai/transfer-transforms.js +11 -11
- package/dist/integrations/composite-ai/transfer-transforms.js.map +1 -1
- package/dist/integrations/composite-media/index.d.ts +4 -3
- package/dist/integrations/composite-media/index.js +20 -14
- package/dist/integrations/composite-media/index.js.map +1 -1
- package/dist/markdown/MarkdownSurface.vue.d.ts +7 -7
- package/dist/markdown/document.js +1 -1
- package/dist/markdown/document.js.map +1 -1
- package/dist/nuxt/module.d.ts +48 -24
- package/dist/nuxt/module.js.map +1 -1
- package/dist/nuxt/runtime/server/plugins/editor-server.js +3 -2
- package/dist/nuxt/runtime/server/plugins/editor-server.js.map +1 -1
- package/dist/presets/compose.d.ts +6 -6
- package/dist/presets/compose.js +7 -4
- package/dist/presets/compose.js.map +1 -1
- package/dist/react/AdvancedEditor.d.ts +2 -2
- package/dist/react/AdvancedEditor.js +1 -1
- package/dist/react/AdvancedEditor.js.map +1 -1
- package/dist/react/compose.d.ts +1 -1
- package/dist/react/compose.js +1 -1
- package/dist/react/compose.js.map +1 -1
- package/dist/react/composed-surface.d.ts +5 -5
- package/dist/react/composed-surface.js +2 -2
- package/dist/react/composed-surface.js.map +1 -1
- package/dist/server/ai.d.ts +7 -7
- package/dist/server/ai.js +1 -1
- package/dist/server/ai.js.map +1 -1
- package/dist/server/auth.d.ts +1 -1
- package/dist/server/collab-state.d.ts +1 -1
- package/dist/server/collab-state.js.map +1 -1
- package/dist/server/collab.d.ts +4 -4
- package/dist/server/collab.js +22 -17
- package/dist/server/collab.js.map +1 -1
- package/dist/server/handlers/ai.d.ts +9 -6
- package/dist/server/handlers/ai.js +13 -17
- package/dist/server/handlers/ai.js.map +1 -1
- package/dist/server/handlers/context.d.ts +4 -0
- package/dist/server/handlers/context.js.map +1 -1
- package/dist/server/handlers/editor.d.ts +33 -32
- package/dist/server/handlers/editor.js +13 -8
- package/dist/server/handlers/editor.js.map +1 -1
- package/dist/server/handlers/images.d.ts +1 -1
- package/dist/server/handlers/images.js +1 -1
- package/dist/server/handlers/images.js.map +1 -1
- package/dist/server/host.d.ts +4 -0
- package/dist/server/host.js +10 -2
- package/dist/server/host.js.map +1 -1
- package/dist/server/index.d.ts +3 -3
- package/dist/server/ports.d.ts +8 -8
- package/dist/server/ports.js.map +1 -1
- package/dist/settings/index.d.ts +20 -19
- package/dist/settings/index.js +25 -24
- package/dist/settings/index.js.map +1 -1
- package/dist/settings/migrate.d.ts +18 -0
- package/dist/settings/migrate.js +46 -0
- package/dist/settings/migrate.js.map +1 -0
- package/dist/settings/values.d.ts +12 -12
- package/dist/settings/values.js +11 -11
- package/dist/settings/values.js.map +1 -1
- package/dist/styles/composites.css +10 -10
- package/dist/tree/DocumentTree.js +12 -5
- package/dist/tree/DocumentTree.js.map +1 -1
- package/dist/tree/drop-rules.js +5 -5
- package/dist/tree/drop-rules.js.map +1 -1
- package/dist/tree/react/DocumentTree.js +14 -5
- package/dist/tree/react/DocumentTree.js.map +1 -1
- package/dist/tree/tree-host.js +5 -5
- package/dist/tree/tree-host.js.map +1 -1
- package/dist/tree/tree-items.js +34 -28
- package/dist/tree/tree-items.js.map +1 -1
- package/dist/tree/tree-model.js +16 -16
- package/dist/tree/tree-model.js.map +1 -1
- package/dist/tree/tree-rows.js +2 -2
- package/dist/tree/tree-rows.js.map +1 -1
- package/dist/tree/tree-view-model.d.ts +2 -2
- package/dist/tree/tree-view-model.js.map +1 -1
- package/dist/vue/AdvancedEditor.js +2 -2
- package/dist/vue/AdvancedEditor.js.map +1 -1
- package/dist/vue/AdvancedEditor.vue.d.ts +10 -10
- package/dist/vue/SimpleEditor.vue.d.ts +4 -4
- package/dist/vue/components/EditorSurface.vue.d.ts +4 -4
- package/dist/vue/compose.d.ts +1 -1
- package/dist/vue/compose.js +1 -1
- package/dist/vue/compose.js.map +1 -1
- package/package.json +1 -1
- package/dist/features/composites/derivation.d.ts +0 -62
- package/dist/features/composites/derivation.js +0 -102
- package/dist/features/composites/derivation.js.map +0 -1
- package/dist/features/composites/kinds.d.ts +0 -89
- package/dist/features/composites/kinds.js +0 -285
- package/dist/features/composites/kinds.js.map +0 -1
package/dist/tree/tree-items.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { fail } from "../core/util.js";
|
|
2
|
+
import { capabilitiesOf } from "../core/capabilities.js";
|
|
3
|
+
import { documentIdOf } from "../core/block-transfer.js";
|
|
4
|
+
import { acceptsChild, acceptsImport, blockTypeOf, defaultBlockTypes, isRootBlockType } from "../features/composites/block-types.js";
|
|
2
5
|
import { basketById } from "../features/composites/baskets.js";
|
|
3
6
|
import { headingOutline } from "../outline/heading-outline.js";
|
|
4
7
|
import { compositeOutline } from "../features/composites/outline.js";
|
|
@@ -35,16 +38,16 @@ function collectFolderPaths(folder, into) {
|
|
|
35
38
|
folder.folders.forEach((sub) => collectFolderPaths(sub, into));
|
|
36
39
|
}
|
|
37
40
|
const EMPTY_OUTLINE = {
|
|
38
|
-
structure: "
|
|
41
|
+
structure: "structured",
|
|
39
42
|
nodes: []
|
|
40
43
|
};
|
|
41
44
|
/** The outline of the editor's document: the composites in composite structure, else the headings. */
|
|
42
45
|
function readOutline(editor, structure, t) {
|
|
43
46
|
if (!editor || editor.isDestroyed) return EMPTY_OUTLINE;
|
|
44
47
|
const { doc } = editor.state;
|
|
45
|
-
return structure === "
|
|
46
|
-
structure: "
|
|
47
|
-
nodes: compositeOutline(doc, /* @__PURE__ */ new Set(), t("tree.untitled"))
|
|
48
|
+
return structure === "structured" ? {
|
|
49
|
+
structure: "structured",
|
|
50
|
+
nodes: compositeOutline(doc, /* @__PURE__ */ new Set(), t("tree.untitled"), (node) => capabilitiesOf(editor, node), documentIdOf(editor))
|
|
48
51
|
} : {
|
|
49
52
|
structure: "flat",
|
|
50
53
|
nodes: headingOutline(doc, t("tree.untitled"))
|
|
@@ -58,14 +61,15 @@ function outlineItems(nodes, kinds, select) {
|
|
|
58
61
|
key: `outline:${node.key}`,
|
|
59
62
|
label: composite ? node.title : node.text,
|
|
60
63
|
labelFromBody: composite && node.labelFromBody ? true : void 0,
|
|
61
|
-
icon: composite ?
|
|
62
|
-
type: composite ? "
|
|
64
|
+
icon: composite ? blockTypeOf(kinds, node.kind).icon : `i-lucide-heading-${node.level}`,
|
|
65
|
+
type: composite ? "typedBlock" : "heading",
|
|
63
66
|
blockId: node.id,
|
|
64
67
|
pos: node.pos,
|
|
65
68
|
kind: composite ? node.kind : void 0,
|
|
66
69
|
hasSummary: composite ? node.hasSummary : void 0,
|
|
67
|
-
tone: composite ?
|
|
70
|
+
tone: composite ? blockTypeOf(kinds, node.kind).chrome?.tone || void 0 : void 0,
|
|
68
71
|
basket: composite ? node.basket : void 0,
|
|
72
|
+
sourceMissing: composite && node.sourceMissing ? true : void 0,
|
|
69
73
|
children: node.children.length ? outlineItems(node.children, kinds, select) : void 0,
|
|
70
74
|
onSelect: () => select(item),
|
|
71
75
|
onToggle: (e) => e?.preventDefault()
|
|
@@ -138,34 +142,36 @@ function pathTo(index, key) {
|
|
|
138
142
|
}
|
|
139
143
|
/**
|
|
140
144
|
* The breadcrumb of a focus (`TreeState.focusPath`): `document` is the open document's own row (the virtual root, or the
|
|
141
|
-
* document row of the store; its label words the first crumb, which leaves focus), `crumbs` the
|
|
145
|
+
* document row of the store; its label words the first crumb, which leaves focus), `crumbs` the Typed blocks from there
|
|
142
146
|
* down to the focused one, which is last.
|
|
143
147
|
*/
|
|
144
148
|
function focusCrumbs(path) {
|
|
145
149
|
return {
|
|
146
150
|
document: path.find((item) => item.type === "document" || item.key === "vroot"),
|
|
147
|
-
crumbs: path.filter((item) => item.type === "
|
|
151
|
+
crumbs: path.filter((item) => item.type === "typedBlock")
|
|
148
152
|
};
|
|
149
153
|
}
|
|
150
154
|
const fileKindsOf = /* @__PURE__ */ new WeakMap();
|
|
151
|
-
/** The kinds a folder lists: Ordner and Dokumente (in the language of `t`; one list per translator). */
|
|
155
|
+
/** The kinds a folder lists: Ordner (the built-in Folder type) and Dokumente (the built-in Block type whose `container` config says `root: true`), the store's folder and document rows (`TreeItem.type`), shown with the presentation of those types (in the language of `t`; one list per translator). No rule reads the Block type. */
|
|
152
156
|
function fileKinds(t) {
|
|
153
157
|
let kinds = fileKindsOf.get(t);
|
|
154
158
|
if (!kinds) {
|
|
155
|
-
const builtIn =
|
|
156
|
-
|
|
159
|
+
const builtIn = defaultBlockTypes(t);
|
|
160
|
+
const document = builtIn.find(isRootBlockType);
|
|
161
|
+
if (!document) fail("the built-in Block types have none with `root: true` in its `container` config", "tree");
|
|
162
|
+
kinds = [blockTypeOf(builtIn, "folder"), document];
|
|
157
163
|
fileKindsOf.set(t, kinds);
|
|
158
164
|
}
|
|
159
165
|
return kinds;
|
|
160
166
|
}
|
|
161
|
-
/** What an item is filtered by: the
|
|
167
|
+
/** What an item is filtered by: the Block type of a Typed block, or Ordner/Dokument for the store's folders and documents. */
|
|
162
168
|
function itemKind(item) {
|
|
163
169
|
return item.kind ?? (item.type === "folder" || item.type === "document" ? item.type : void 0);
|
|
164
170
|
}
|
|
165
171
|
/** The kinds `item`'s filter can hide below it (`kinds` = those of the open editor). */
|
|
166
172
|
function filterKinds(item, env) {
|
|
167
|
-
const composite = env.structure === "
|
|
168
|
-
if (item.key === "vroot" || item.type === "
|
|
173
|
+
const composite = env.structure === "structured";
|
|
174
|
+
if (item.key === "vroot" || item.type === "typedBlock") return env.kinds;
|
|
169
175
|
if (item.type === "document") return composite && item.id === env.activeId ? env.kinds : [];
|
|
170
176
|
if (item.type === "root" || item.type === "folder") return fileKinds(env.t);
|
|
171
177
|
return [];
|
|
@@ -193,7 +199,7 @@ function applyNodeFilters(list, filters, inherited = /* @__PURE__ */ new Set())
|
|
|
193
199
|
function applyBasketFilter(list, shown, dimmed) {
|
|
194
200
|
return list.flatMap((item) => {
|
|
195
201
|
const children = item.children ? applyBasketFilter(item.children, shown, dimmed) : void 0;
|
|
196
|
-
if (item.type === "
|
|
202
|
+
if (item.type === "typedBlock") {
|
|
197
203
|
const matches = !!item.basket && shown.has(item.basket);
|
|
198
204
|
if (!matches && !children?.length) return [];
|
|
199
205
|
if (!matches) dimmed.add(item.key);
|
|
@@ -205,29 +211,29 @@ function applyBasketFilter(list, shown, dimmed) {
|
|
|
205
211
|
});
|
|
206
212
|
}
|
|
207
213
|
/**
|
|
208
|
-
* What `item` takes as new
|
|
209
|
-
* every
|
|
214
|
+
* What `item` takes as new Typed blocks of the open file: the file itself (the virtual root, or its document row) takes
|
|
215
|
+
* every Block type, a Typed block what its Block type accepts as children (`acceptsChild`; files need a Block type that lists the `import` capability, `acceptsImport`). Nothing in a flat structure or without an editor.
|
|
210
216
|
*/
|
|
211
217
|
function creatableBelow(item, env) {
|
|
212
218
|
const none = {
|
|
213
219
|
folder: false,
|
|
214
|
-
|
|
220
|
+
files: false
|
|
215
221
|
};
|
|
216
|
-
if (env.structure !== "
|
|
222
|
+
if (env.structure !== "structured" || !env.hasEditor) return none;
|
|
217
223
|
if (item.key === "vroot" || item.type === "document" && item.id === env.activeId) return {
|
|
218
224
|
folder: true,
|
|
219
|
-
|
|
225
|
+
files: true
|
|
220
226
|
};
|
|
221
|
-
if (item.type !== "
|
|
227
|
+
if (item.type !== "typedBlock" || !item.blockId || !item.kind) return none;
|
|
222
228
|
return {
|
|
223
|
-
folder:
|
|
224
|
-
|
|
229
|
+
folder: acceptsChild(env.kinds, item.kind, "folder"),
|
|
230
|
+
files: acceptsImport(env.kinds, item.kind)
|
|
225
231
|
};
|
|
226
232
|
}
|
|
227
233
|
/** What a dragged item carries: its document or folder, or in virtual mode its composite's block ID. */
|
|
228
234
|
function dragPayloadOf(item) {
|
|
229
|
-
return item.type === "
|
|
230
|
-
type: "
|
|
235
|
+
return item.type === "typedBlock" ? {
|
|
236
|
+
type: "typedBlock",
|
|
231
237
|
blockId: item.blockId
|
|
232
238
|
} : item.type === "document" ? {
|
|
233
239
|
type: "document",
|
|
@@ -240,7 +246,7 @@ function dragPayloadOf(item) {
|
|
|
240
246
|
}
|
|
241
247
|
/** Whether `item` may be dragged. Virtual mode moves composites of the open document; blocks without an ID cannot be addressed. */
|
|
242
248
|
function isDraggable(item, virtual) {
|
|
243
|
-
if (virtual) return item.type === "
|
|
249
|
+
if (virtual) return item.type === "typedBlock" && !!item.blockId;
|
|
244
250
|
return item.type === "document" || item.type === "folder";
|
|
245
251
|
}
|
|
246
252
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-items.js","names":[],"sources":["../../src/tree/tree-items.ts"],"sourcesContent":["import type { Editor } from '@tiptap/core'\nimport { type Basket, basketById, compositeKind, type CompositeKind, compositeOutline, defaultCompositeKinds, kindAccepts, type OutlineNode } from '../features/composites'\nimport type { Translate } from '../i18n'\nimport { type HeadingOutlineNode, headingOutline } from '../outline'\nimport { folderKey } from './folder-paths'\nimport type { TreeFolder } from './types'\nimport type { NodeFilters } from './tree-view-model'\n\n// What the Vue and the React `DocumentTree` share: the items of the file browser (folders and documents of the store,\n// the open document's outline), their kind filters, what can be dragged and created, and the path arithmetic. No\n// framework, no state; the drop rules are `drop-rules.ts`, the text filter and the visible rows `tree-rows.ts`.\n\n/** One row of the file browser: a store folder or document, or an entry of the open document's outline. Which fields are set depends on `type`. */\nexport interface TreeItem {\n /** Unique within the tree: `root`, `folder:<path>`, `doc:<id>`, `outline:<block key>` */\n key: string\n label: string\n /** Composite items: `label` is derived from the body (the Baustein has no title); rows show it muted and italic */\n labelFromBody?: boolean\n icon: string\n type: 'root' | 'folder' | 'document' | 'composite' | 'heading'\n /** Folder path of a root/folder item (`''` = root) */\n path?: string\n /** Document id */\n id?: string\n /** Folder path a document item lives in */\n folder?: string\n /** Outline items: block ID of the composite/heading (`null` while it has none) and its position when the outline was read */\n blockId?: string | null\n pos?: number\n /** Composite items: the composite's kind, and whether it has a summary (description) */\n kind?: string\n hasSummary?: boolean\n /** Composite items: the tone of the kind (`CompositeKind.chrome.tone`) that tints the kind icon; absent for a kind without one */\n tone?: string\n /** Composite items: the basket id (`meta.basket`), `null`/absent without one */\n basket?: string | null\n children?: TreeItem[]\n onSelect?: (e?: Event) => void\n onToggle?: (e?: Event) => void\n}\n\n/**\n * What a drag carries (serialized under `DRAG_MIME`): a document or folder of the store, or a composite of the open document.\n * `foreign-block` is a Baustein from another editor surface or document tree (it travels under `BLOCK_MIME`, not `DRAG_MIME`).\n */\nexport type DragPayload\n = | {\n type: 'document' | 'folder'\n /** Document id */\n id?: string\n /** Folder path of a folder item, or the folder a document currently lives in */\n path: string\n }\n /** Virtual mode: a composite of the open document, by block ID */\n | { type: 'composite', blockId: string }\n /** A Baustein dragged in from outside this tree; only its verdict is known until the drop reads the payload. */\n | { type: 'foreign-block' }\n\n/** Key of the virtual-mode root item (the open document). */\nexport const VIRTUAL_ROOT = 'vroot'\n\nexport const DRAG_MIME = 'application/x-tip-tree'\n\nexport const parentPath = (folder: string) => folder.slice(0, Math.max(folder.lastIndexOf('/'), 0))\nexport const joinPath = (folder: string, name: string) => (folder ? `${folder}/${name}` : name)\n\n/** Item keys from the root down to `folder`. */\nexport function ancestorKeys(folder: string): string[] {\n const keys = ['root']\n let path = ''\n for (const segment of folder.split('/').filter(Boolean)) {\n path = joinPath(path, segment)\n keys.push(folderKey(path))\n }\n return keys\n}\n\n/** The folder at `path` below (or at) `from`; undefined when there is none. */\nexport function findFolder(path: string, from: TreeFolder | null | undefined): TreeFolder | undefined {\n if (!from) return undefined\n if (from.path === path) return from\n for (const sub of from.folders) {\n const found = path === sub.path || path.startsWith(`${sub.path}/`) ? findFolder(path, sub) : undefined\n if (found) return found\n }\n return undefined\n}\n\n/** Names of the folders directly in `parent`, without the folder at path `except`. */\nexport const folderNamesIn = (tree: TreeFolder | null | undefined, parent: string, except?: string) =>\n (findFolder(parent, tree)?.folders ?? []).filter(sub => sub.path !== except).map(sub => sub.name)\n\nexport function collectFolderPaths(folder: TreeFolder, into: Set<string>) {\n into.add(folder.path)\n folder.folders.forEach(sub => collectFolderPaths(sub, into))\n}\n\n// --- outline of the open document ------------------------------------------------------------------------------\n\nexport type Outline = { structure: 'composite', nodes: OutlineNode[] } | { structure: 'flat', nodes: HeadingOutlineNode[] }\n\nexport const EMPTY_OUTLINE: Outline = { structure: 'composite', nodes: [] }\n\n/** The outline of the editor's document: the composites in composite structure, else the headings. */\nexport function readOutline(editor: Editor | undefined, structure: string, t: Translate): Outline {\n if (!editor || editor.isDestroyed) return EMPTY_OUTLINE\n const { doc } = editor.state\n return structure === 'composite'\n ? { structure: 'composite', nodes: compositeOutline(doc, new Set(), t('tree.untitled')) }\n : { structure: 'flat', nodes: headingOutline(doc, t('tree.untitled')) }\n}\n\n/** The outline entries as items; `select` runs when one is chosen. */\nexport function outlineItems(nodes: readonly (OutlineNode | HeadingOutlineNode)[], kinds: readonly CompositeKind[], select: (item: TreeItem) => void): TreeItem[] {\n return nodes.map((node) => {\n const composite = 'kind' in node\n const item: TreeItem = {\n key: `outline:${node.key}`,\n label: composite ? node.title : node.text,\n labelFromBody: composite && node.labelFromBody ? true : undefined,\n icon: composite ? compositeKind(kinds, node.kind).icon : `i-lucide-heading-${node.level}`,\n type: composite ? 'composite' : 'heading',\n blockId: node.id,\n pos: node.pos,\n kind: composite ? node.kind : undefined,\n hasSummary: composite ? node.hasSummary : undefined,\n tone: composite ? compositeKind(kinds, node.kind).chrome?.tone || undefined : undefined,\n basket: composite ? node.basket : undefined,\n children: node.children.length ? outlineItems(node.children as (OutlineNode | HeadingOutlineNode)[], kinds, select) : undefined,\n onSelect: () => select(item),\n onToggle: e => e?.preventDefault(), // the chevron toggles, a click reveals\n }\n return item\n })\n}\n\n/** The basket of a composite item among `baskets`; `undefined` without one (or when the host no longer offers it). */\nexport const itemBasket = (item: TreeItem, baskets: readonly Basket[]): Basket | undefined => basketById(baskets, item.basket)\n\n// --- items -----------------------------------------------------------------------------------------------------\n\n/** The store's folders and documents as items; the open document (`activeId`) lists `outline` below it. */\nexport function folderItem(folder: TreeFolder, activeId: string | undefined, outline: TreeItem[], select: (item: TreeItem) => void): TreeItem {\n const root = folder.path === ''\n const item: TreeItem = {\n key: root ? 'root' : folderKey(folder.path),\n label: folder.name,\n icon: root ? 'i-lucide-hard-drive' : 'i-lucide-folder',\n type: root ? 'root' : 'folder',\n path: folder.path,\n children: [\n ...folder.folders.map(sub => folderItem(sub, activeId, outline, select)),\n ...folder.documents.map((doc) => {\n const document: TreeItem = {\n key: `doc:${doc.id}`,\n label: doc.title,\n icon: 'i-lucide-file',\n type: 'document',\n id: doc.id,\n folder: doc.folder,\n // The open document lists its outline; its chevron (not a row click) opens and closes it.\n children: doc.id === activeId && outline.length ? outline : undefined,\n onSelect: () => select(document),\n onToggle: e => e?.preventDefault(),\n }\n return document\n }),\n ],\n onSelect: () => select(item),\n }\n return item\n}\n\n/** Virtual mode: the open document is the root, its `folder`/`document` composites (and all others) the tree below it. */\nexport function virtualRootItem(label: string, outline: TreeItem[], select: (item: TreeItem) => void): TreeItem {\n const item: TreeItem = {\n key: VIRTUAL_ROOT,\n label,\n icon: 'i-lucide-package',\n type: 'root',\n children: outline.length ? outline : undefined,\n onSelect: () => select(item),\n }\n return item\n}\n\n/** An item of the unfiltered tree and the key of its parent (`null` for a top-level item). */\nexport interface IndexedItem {\n item: TreeItem\n parent: string | null\n}\n\n/** Adds `list` and all items below it to `into` by key; returns `into`. */\nexport function indexItems(list: readonly TreeItem[], into: Map<string, IndexedItem>, parent: string | null = null) {\n for (const item of list) {\n into.set(item.key, { item, parent })\n if (item.children) indexItems(item.children, into, item.key)\n }\n return into\n}\n\n/** The items from the top-level one down to the item at `key` (empty when `key` is not in `index`). */\nexport function pathTo(index: ReadonlyMap<string, IndexedItem>, key: string): TreeItem[] {\n const path: TreeItem[] = []\n let entry = index.get(key)\n if (!entry) return path\n for (;;) {\n path.unshift(entry.item)\n if (entry.parent === null) return path\n entry = index.get(entry.parent)!\n }\n}\n\n/**\n * The breadcrumb of a focus (`TreeState.focusPath`): `document` is the open document's own row (the virtual root, or the\n * document row of the store; its label words the first crumb, which leaves focus), `crumbs` the Bausteine from there\n * down to the focused one, which is last.\n */\nexport function focusCrumbs(path: readonly TreeItem[]): { document: TreeItem | undefined, crumbs: TreeItem[] } {\n return {\n document: path.find(item => item.type === 'document' || item.key === VIRTUAL_ROOT),\n crumbs: path.filter(item => item.type === 'composite'),\n }\n}\n\n// --- filters ---------------------------------------------------------------------------------------------------\n\nconst fileKindsOf = new WeakMap<Translate, CompositeKind[]>()\n\n/** The kinds a folder lists: Ordner and Dokumente (in the language of `t`; one list per translator). */\nexport function fileKinds(t: Translate): CompositeKind[] {\n let kinds = fileKindsOf.get(t)\n if (!kinds) {\n const builtIn = defaultCompositeKinds(t)\n kinds = ['folder', 'document'].map(id => compositeKind(builtIn, id))\n fileKindsOf.set(t, kinds)\n }\n return kinds\n}\n\n/** What an item is filtered by: the composite's kind, or Ordner/Dokument for the store's folders and documents. */\nfunction itemKind(item: TreeItem): string | undefined {\n return item.kind ?? (item.type === 'folder' || item.type === 'document' ? item.type : undefined)\n}\n\n/** The kinds `item`'s filter can hide below it (`kinds` = those of the open editor). */\nexport function filterKinds(item: TreeItem, env: { structure: string, activeId: string | undefined, kinds: readonly CompositeKind[], t: Translate }): readonly CompositeKind[] {\n const composite = env.structure === 'composite'\n if (item.key === VIRTUAL_ROOT || item.type === 'composite') return env.kinds\n if (item.type === 'document') return composite && item.id === env.activeId ? env.kinds : []\n if (item.type === 'root' || item.type === 'folder') return fileKinds(env.t)\n return []\n}\n\n/**\n * Drops the items of kinds an ancestor's filter hides. Like the outline's own kind filter, their visible descendants\n * move up into the parent's list. A node's own filter applies to everything below it.\n */\nexport function applyNodeFilters(list: readonly TreeItem[], filters: NodeFilters, inherited: ReadonlySet<string> = new Set()): TreeItem[] {\n return list.flatMap((item) => {\n const own = filters[item.key]\n const children = item.children ? applyNodeFilters(item.children, filters, own?.length ? new Set([...inherited, ...own]) : inherited) : undefined\n const kind = itemKind(item)\n if (kind && inherited.has(kind)) return children ?? []\n return [{ ...item, children: children?.length ? children : undefined }]\n })\n}\n\n/**\n * Hides the composites that are not in a `shown` basket and have no visible descendant; ancestors that stay only\n * because of a visible descendant are collected in `dimmed`. Documents, folders, headings and the roots are never hidden.\n */\nexport function applyBasketFilter(list: readonly TreeItem[], shown: ReadonlySet<string>, dimmed: Set<string>): TreeItem[] {\n return list.flatMap((item) => {\n const children = item.children ? applyBasketFilter(item.children, shown, dimmed) : undefined\n if (item.type === 'composite') {\n const matches = !!item.basket && shown.has(item.basket)\n if (!matches && !children?.length) return []\n if (!matches) dimmed.add(item.key)\n }\n return [{ ...item, children: children?.length ? children : undefined }]\n })\n}\n\n// --- creating ----------------------------------------------------------------------------------------------------\n\n/** What can be created below an item of the open file: Ordner-Bausteine, imported Dokument-Bausteine. */\nexport interface Creatable {\n folder: boolean\n document: boolean\n}\n\n/**\n * What `item` takes as new Bausteine of the open file: the file itself (the virtual root, or its document row) takes\n * every kind, a Baustein what its kind accepts as children (`kindAccepts`). Nothing in a flat structure or without an editor.\n */\nexport function creatableBelow(item: TreeItem, env: { structure: string, hasEditor: boolean, activeId: string | undefined, kinds: readonly CompositeKind[] }): Creatable {\n const none: Creatable = { folder: false, document: false }\n if (env.structure !== 'composite' || !env.hasEditor) return none\n if (item.key === VIRTUAL_ROOT || (item.type === 'document' && item.id === env.activeId)) return { folder: true, document: true }\n if (item.type !== 'composite' || !item.blockId || !item.kind) return none\n return { folder: kindAccepts(env.kinds, item.kind, 'folder'), document: kindAccepts(env.kinds, item.kind, 'document') }\n}\n\n// --- drag & drop -----------------------------------------------------------------------------------------------\n\n/** What a dragged item carries: its document or folder, or in virtual mode its composite's block ID. */\nexport function dragPayloadOf(item: TreeItem): DragPayload {\n return item.type === 'composite'\n ? { type: 'composite', blockId: item.blockId! }\n : item.type === 'document'\n ? { type: 'document', id: item.id, path: item.folder ?? '' }\n : { type: 'folder', path: item.path! }\n}\n\n/** Whether `item` may be dragged. Virtual mode moves composites of the open document; blocks without an ID cannot be addressed. */\nexport function isDraggable(item: TreeItem, virtual: boolean): boolean {\n if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AAK,SAAS;AACnD"}
|
|
1
|
+
{"version":3,"file":"tree-items.js","names":[],"sources":["../../src/tree/tree-items.ts"],"sourcesContent":["import type { Editor } from '@tiptap/core'\nimport { documentIdOf } from '../core/block-transfer'\nimport { capabilitiesOf } from '../core/capabilities'\nimport { fail } from '../core/util'\nimport { acceptsChild, acceptsImport, type Basket, basketById, type BlockType, blockTypeOf, compositeOutline, defaultBlockTypes, isRootBlockType, type OutlineNode } from '../features/composites'\nimport type { Translate } from '../i18n'\nimport { type HeadingOutlineNode, headingOutline } from '../outline'\nimport { folderKey } from './folder-paths'\nimport type { TreeFolder } from './types'\nimport type { NodeFilters } from './tree-view-model'\n\n// What the Vue and the React `DocumentTree` share: the items of the file browser (folders and documents of the store,\n// the open document's outline), their kind filters, what can be dragged and created, and the path arithmetic. No\n// framework, no state; the drop rules are `drop-rules.ts`, the text filter and the visible rows `tree-rows.ts`.\n\n/** One row of the file browser: a store folder or document, or an entry of the open document's outline. Which fields are set depends on `type`. */\nexport interface TreeItem {\n /** Unique within the tree: `root`, `folder:<path>`, `doc:<id>`, `outline:<block key>` */\n key: string\n label: string\n /** Composite items: `label` is derived from the body (the Typed block has no title); rows show it muted and italic */\n labelFromBody?: boolean\n icon: string\n type: 'root' | 'folder' | 'document' | 'typedBlock' | 'heading'\n /** Folder path of a root/folder item (`''` = root) */\n path?: string\n /** Document id */\n id?: string\n /** Folder path a document item lives in */\n folder?: string\n /** Outline items: block ID of the composite/heading (`null` while it has none) and its position when the outline was read */\n blockId?: string | null\n pos?: number\n /** Typed block items: the Block type id, and whether it has a summary (description) */\n kind?: string\n hasSummary?: boolean\n /** Typed block items: the tone of the Block type (`BlockType.chrome.tone`) that tints its icon; absent for a Block type without one */\n tone?: string\n /** Composite items: the basket id (`meta.basket`), `null`/absent without one */\n basket?: string | null\n /** Composite items: a Derived block whose original was deleted (`OutlineNode.sourceMissing`) */\n sourceMissing?: boolean\n children?: TreeItem[]\n onSelect?: (e?: Event) => void\n onToggle?: (e?: Event) => void\n}\n\n/**\n * What a drag carries (serialized under `DRAG_MIME`): a document or folder of the store, or a composite of the open document.\n * `foreign-block` is a Typed block from another editor surface or document tree (it travels under `BLOCK_MIME`, not `DRAG_MIME`).\n */\nexport type DragPayload\n = | {\n type: 'document' | 'folder'\n /** Document id */\n id?: string\n /** Folder path of a folder item, or the folder a document currently lives in */\n path: string\n }\n /** Virtual mode: a composite of the open document, by block ID */\n | { type: 'typedBlock', blockId: string }\n /** A Typed block dragged in from outside this tree; only its verdict is known until the drop reads the payload. */\n | { type: 'foreign-block' }\n\n/** Key of the virtual-mode root item (the open document). */\nexport const VIRTUAL_ROOT = 'vroot'\n\nexport const DRAG_MIME = 'application/x-tip-tree'\n\nexport const parentPath = (folder: string) => folder.slice(0, Math.max(folder.lastIndexOf('/'), 0))\nexport const joinPath = (folder: string, name: string) => (folder ? `${folder}/${name}` : name)\n\n/** Item keys from the root down to `folder`. */\nexport function ancestorKeys(folder: string): string[] {\n const keys = ['root']\n let path = ''\n for (const segment of folder.split('/').filter(Boolean)) {\n path = joinPath(path, segment)\n keys.push(folderKey(path))\n }\n return keys\n}\n\n/** The folder at `path` below (or at) `from`; undefined when there is none. */\nexport function findFolder(path: string, from: TreeFolder | null | undefined): TreeFolder | undefined {\n if (!from) return undefined\n if (from.path === path) return from\n for (const sub of from.folders) {\n const found = path === sub.path || path.startsWith(`${sub.path}/`) ? findFolder(path, sub) : undefined\n if (found) return found\n }\n return undefined\n}\n\n/** Names of the folders directly in `parent`, without the folder at path `except`. */\nexport const folderNamesIn = (tree: TreeFolder | null | undefined, parent: string, except?: string) =>\n (findFolder(parent, tree)?.folders ?? []).filter(sub => sub.path !== except).map(sub => sub.name)\n\nexport function collectFolderPaths(folder: TreeFolder, into: Set<string>) {\n into.add(folder.path)\n folder.folders.forEach(sub => collectFolderPaths(sub, into))\n}\n\n// --- outline of the open document ------------------------------------------------------------------------------\n\nexport type Outline = { structure: 'structured', nodes: OutlineNode[] } | { structure: 'flat', nodes: HeadingOutlineNode[] }\n\nexport const EMPTY_OUTLINE: Outline = { structure: 'structured', nodes: [] }\n\n/** The outline of the editor's document: the composites in composite structure, else the headings. */\nexport function readOutline(editor: Editor | undefined, structure: string, t: Translate): Outline {\n if (!editor || editor.isDestroyed) return EMPTY_OUTLINE\n const { doc } = editor.state\n return structure === 'structured'\n ? { structure: 'structured', nodes: compositeOutline(doc, new Set(), t('tree.untitled'), node => capabilitiesOf(editor, node), documentIdOf(editor)) }\n : { structure: 'flat', nodes: headingOutline(doc, t('tree.untitled')) }\n}\n\n/** The outline entries as items; `select` runs when one is chosen. */\nexport function outlineItems(nodes: readonly (OutlineNode | HeadingOutlineNode)[], kinds: readonly BlockType[], select: (item: TreeItem) => void): TreeItem[] {\n return nodes.map((node) => {\n const composite = 'kind' in node\n const item: TreeItem = {\n key: `outline:${node.key}`,\n label: composite ? node.title : node.text,\n labelFromBody: composite && node.labelFromBody ? true : undefined,\n icon: composite ? blockTypeOf(kinds, node.kind).icon : `i-lucide-heading-${node.level}`,\n type: composite ? 'typedBlock' : 'heading',\n blockId: node.id,\n pos: node.pos,\n kind: composite ? node.kind : undefined,\n hasSummary: composite ? node.hasSummary : undefined,\n tone: composite ? blockTypeOf(kinds, node.kind).chrome?.tone || undefined : undefined,\n basket: composite ? node.basket : undefined,\n sourceMissing: composite && node.sourceMissing ? true : undefined,\n children: node.children.length ? outlineItems(node.children as (OutlineNode | HeadingOutlineNode)[], kinds, select) : undefined,\n onSelect: () => select(item),\n onToggle: e => e?.preventDefault(), // the chevron toggles, a click reveals\n }\n return item\n })\n}\n\n/** The basket of a composite item among `baskets`; `undefined` without one (or when the host no longer offers it). */\nexport const itemBasket = (item: TreeItem, baskets: readonly Basket[]): Basket | undefined => basketById(baskets, item.basket)\n\n// --- items -----------------------------------------------------------------------------------------------------\n\n/** The store's folders and documents as items; the open document (`activeId`) lists `outline` below it. */\nexport function folderItem(folder: TreeFolder, activeId: string | undefined, outline: TreeItem[], select: (item: TreeItem) => void): TreeItem {\n const root = folder.path === ''\n const item: TreeItem = {\n key: root ? 'root' : folderKey(folder.path),\n label: folder.name,\n icon: root ? 'i-lucide-hard-drive' : 'i-lucide-folder',\n type: root ? 'root' : 'folder',\n path: folder.path,\n children: [\n ...folder.folders.map(sub => folderItem(sub, activeId, outline, select)),\n ...folder.documents.map((doc) => {\n const document: TreeItem = {\n key: `doc:${doc.id}`,\n label: doc.title,\n icon: 'i-lucide-file',\n type: 'document',\n id: doc.id,\n folder: doc.folder,\n // The open document lists its outline; its chevron (not a row click) opens and closes it.\n children: doc.id === activeId && outline.length ? outline : undefined,\n onSelect: () => select(document),\n onToggle: e => e?.preventDefault(),\n }\n return document\n }),\n ],\n onSelect: () => select(item),\n }\n return item\n}\n\n/** Virtual mode: the open document is the root, its `folder`/`document` composites (and all others) the tree below it. */\nexport function virtualRootItem(label: string, outline: TreeItem[], select: (item: TreeItem) => void): TreeItem {\n const item: TreeItem = {\n key: VIRTUAL_ROOT,\n label,\n icon: 'i-lucide-package',\n type: 'root',\n children: outline.length ? outline : undefined,\n onSelect: () => select(item),\n }\n return item\n}\n\n/** An item of the unfiltered tree and the key of its parent (`null` for a top-level item). */\nexport interface IndexedItem {\n item: TreeItem\n parent: string | null\n}\n\n/** Adds `list` and all items below it to `into` by key; returns `into`. */\nexport function indexItems(list: readonly TreeItem[], into: Map<string, IndexedItem>, parent: string | null = null) {\n for (const item of list) {\n into.set(item.key, { item, parent })\n if (item.children) indexItems(item.children, into, item.key)\n }\n return into\n}\n\n/** The items from the top-level one down to the item at `key` (empty when `key` is not in `index`). */\nexport function pathTo(index: ReadonlyMap<string, IndexedItem>, key: string): TreeItem[] {\n const path: TreeItem[] = []\n let entry = index.get(key)\n if (!entry) return path\n for (;;) {\n path.unshift(entry.item)\n if (entry.parent === null) return path\n entry = index.get(entry.parent)!\n }\n}\n\n/**\n * The breadcrumb of a focus (`TreeState.focusPath`): `document` is the open document's own row (the virtual root, or the\n * document row of the store; its label words the first crumb, which leaves focus), `crumbs` the Typed blocks from there\n * down to the focused one, which is last.\n */\nexport function focusCrumbs(path: readonly TreeItem[]): { document: TreeItem | undefined, crumbs: TreeItem[] } {\n return {\n document: path.find(item => item.type === 'document' || item.key === VIRTUAL_ROOT),\n crumbs: path.filter(item => item.type === 'typedBlock'),\n }\n}\n\n// --- filters ---------------------------------------------------------------------------------------------------\n\nconst fileKindsOf = new WeakMap<Translate, BlockType[]>()\n\n/** The kinds a folder lists: Ordner (the built-in Folder type) and Dokumente (the built-in Block type whose `container` config says `root: true`), the store's folder and document rows (`TreeItem.type`), shown with the presentation of those types (in the language of `t`; one list per translator). No rule reads the Block type. */\nexport function fileKinds(t: Translate): BlockType[] {\n let kinds = fileKindsOf.get(t)\n if (!kinds) {\n const builtIn = defaultBlockTypes(t)\n const document = builtIn.find(isRootBlockType)\n if (!document) fail('the built-in Block types have none with `root: true` in its `container` config', 'tree')\n kinds = [blockTypeOf(builtIn, 'folder'), document!]\n fileKindsOf.set(t, kinds)\n }\n return kinds\n}\n\n/** What an item is filtered by: the Block type of a Typed block, or Ordner/Dokument for the store's folders and documents. */\nfunction itemKind(item: TreeItem): string | undefined {\n return item.kind ?? (item.type === 'folder' || item.type === 'document' ? item.type : undefined)\n}\n\n/** The kinds `item`'s filter can hide below it (`kinds` = those of the open editor). */\nexport function filterKinds(item: TreeItem, env: { structure: string, activeId: string | undefined, kinds: readonly BlockType[], t: Translate }): readonly BlockType[] {\n const composite = env.structure === 'structured'\n if (item.key === VIRTUAL_ROOT || item.type === 'typedBlock') return env.kinds\n if (item.type === 'document') return composite && item.id === env.activeId ? env.kinds : []\n if (item.type === 'root' || item.type === 'folder') return fileKinds(env.t)\n return []\n}\n\n/**\n * Drops the items of kinds an ancestor's filter hides. Like the outline's own kind filter, their visible descendants\n * move up into the parent's list. A node's own filter applies to everything below it.\n */\nexport function applyNodeFilters(list: readonly TreeItem[], filters: NodeFilters, inherited: ReadonlySet<string> = new Set()): TreeItem[] {\n return list.flatMap((item) => {\n const own = filters[item.key]\n const children = item.children ? applyNodeFilters(item.children, filters, own?.length ? new Set([...inherited, ...own]) : inherited) : undefined\n const kind = itemKind(item)\n if (kind && inherited.has(kind)) return children ?? []\n return [{ ...item, children: children?.length ? children : undefined }]\n })\n}\n\n/**\n * Hides the composites that are not in a `shown` basket and have no visible descendant; ancestors that stay only\n * because of a visible descendant are collected in `dimmed`. Documents, folders, headings and the roots are never hidden.\n */\nexport function applyBasketFilter(list: readonly TreeItem[], shown: ReadonlySet<string>, dimmed: Set<string>): TreeItem[] {\n return list.flatMap((item) => {\n const children = item.children ? applyBasketFilter(item.children, shown, dimmed) : undefined\n if (item.type === 'typedBlock') {\n const matches = !!item.basket && shown.has(item.basket)\n if (!matches && !children?.length) return []\n if (!matches) dimmed.add(item.key)\n }\n return [{ ...item, children: children?.length ? children : undefined }]\n })\n}\n\n// --- creating ----------------------------------------------------------------------------------------------------\n\n/** What can be created below an item of the open file: Folder blocks, and Typed blocks imported from files. */\nexport interface Creatable {\n folder: boolean\n files: boolean\n}\n\n/**\n * What `item` takes as new Typed blocks of the open file: the file itself (the virtual root, or its document row) takes\n * every Block type, a Typed block what its Block type accepts as children (`acceptsChild`; files need a Block type that lists the `import` capability, `acceptsImport`). Nothing in a flat structure or without an editor.\n */\nexport function creatableBelow(item: TreeItem, env: { structure: string, hasEditor: boolean, activeId: string | undefined, kinds: readonly BlockType[] }): Creatable {\n const none: Creatable = { folder: false, files: false }\n if (env.structure !== 'structured' || !env.hasEditor) return none\n if (item.key === VIRTUAL_ROOT || (item.type === 'document' && item.id === env.activeId)) return { folder: true, files: true }\n if (item.type !== 'typedBlock' || !item.blockId || !item.kind) return none\n return { folder: acceptsChild(env.kinds, item.kind, 'folder'), files: acceptsImport(env.kinds, item.kind) }\n}\n\n// --- drag & drop -----------------------------------------------------------------------------------------------\n\n/** What a dragged item carries: its document or folder, or in virtual mode its composite's block ID. */\nexport function dragPayloadOf(item: TreeItem): DragPayload {\n return item.type === 'typedBlock'\n ? { type: 'typedBlock', blockId: item.blockId! }\n : item.type === 'document'\n ? { type: 'document', id: item.id, path: item.folder ?? '' }\n : { type: 'folder', path: item.path! }\n}\n\n/** Whether `item` may be dragged. Virtual mode moves composites of the open document; blocks without an ID cannot be addressed. */\nexport function isDraggable(item: TreeItem, virtual: boolean): boolean {\n if (virtual) return item.type === 'typedBlock' && !!item.blockId\n return item.type === 'document' || item.type === 'folder'\n}\n\n"],"mappings":";;;;;;;;;;AAiEA,MAAa,eAAe;AAE5B,MAAa,YAAY;AAEzB,MAAa,cAAc,WAAmB,OAAO,MAAM,GAAG,KAAK,IAAI,OAAO,YAAY,GAAG,GAAG,CAAC,CAAC;AAClG,MAAa,YAAY,QAAgB,SAAkB,SAAS,GAAG,OAAO,GAAG,SAAS;;AAG1F,SAAgB,aAAa,QAA0B;CACrD,MAAM,OAAO,CAAC,MAAM;CACpB,IAAI,OAAO;CACX,KAAK,MAAM,WAAW,OAAO,MAAM,GAAG,CAAC,CAAC,OAAO,OAAO,GAAG;EACvD,OAAO,SAAS,MAAM,OAAO;EAC7B,KAAK,KAAK,UAAU,IAAI,CAAC;CAC3B;CACA,OAAO;AACT;;AAGA,SAAgB,WAAW,MAAc,MAA6D;CACpG,IAAI,CAAC,MAAM,OAAO,KAAA;CAClB,IAAI,KAAK,SAAS,MAAM,OAAO;CAC/B,KAAK,MAAM,OAAO,KAAK,SAAS;EAC9B,MAAM,QAAQ,SAAS,IAAI,QAAQ,KAAK,WAAW,GAAG,IAAI,KAAK,EAAE,IAAI,WAAW,MAAM,GAAG,IAAI,KAAA;EAC7F,IAAI,OAAO,OAAO;CACpB;AAEF;;AAGA,MAAa,iBAAiB,MAAqC,QAAgB,YAChF,WAAW,QAAQ,IAAI,CAAC,EAAE,WAAW,CAAC,EAAA,CAAG,QAAO,QAAO,IAAI,SAAS,MAAM,CAAC,CAAC,KAAI,QAAO,IAAI,IAAI;AAElG,SAAgB,mBAAmB,QAAoB,MAAmB;CACxE,KAAK,IAAI,OAAO,IAAI;C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A,SAAgB,cAAc,MAA6B;CACzD,OAAO,KAAK,SAAS,eACjB;EAAE,MAAM;EAAc,SAAS,KAAK;CAAS,IAC7C,KAAK,SAAS,aACZ;EAAE,MAAM;EAAY,IAAI,KAAK;EAAI,MAAM,KAAK,UAAU;CAAG,IACzD;EAAE,MAAM;EAAU,MAAM,KAAK;CAAM;AAC3C;;AAGA,SAAgB,YAAY,MAAgB,SAA2B;CACrE,IAAI,SAAS,OAAO,KAAK,SAAS,gBAAgB,CAAC,CAAC,KAAK;CACzD,OAAO,KAAK,SAAS,cAAc,KAAK,SAAS;AACnD"}
|
package/dist/tree/tree-model.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createStore } from "../core/store.js";
|
|
2
|
-
import {
|
|
2
|
+
import { acceptsChild } from "../features/composites/block-types.js";
|
|
3
3
|
import { basketById } from "../features/composites/baskets.js";
|
|
4
4
|
import { remapFolderPath } from "./folder-paths.js";
|
|
5
5
|
import { EMPTY_OUTLINE, VIRTUAL_ROOT, ancestorKeys, collectFolderPaths, creatableBelow, dragPayloadOf, filterKinds, folderNamesIn, isDraggable, joinPath, parentPath } from "./tree-items.js";
|
|
@@ -58,7 +58,7 @@ function createTreeModel(options) {
|
|
|
58
58
|
/** A folder move the host is running: until it is done, a selected folder at the old path follows to the new one. */
|
|
59
59
|
let pendingMove;
|
|
60
60
|
let disposed = false;
|
|
61
|
-
const isVirtual = () => treeRoot === "file" && structure === "
|
|
61
|
+
const isVirtual = () => treeRoot === "file" && structure === "structured" && !!editor;
|
|
62
62
|
let core = {
|
|
63
63
|
tree: store.tree.get(),
|
|
64
64
|
documents: store.documents.get() ?? NO_DOCUMENTS,
|
|
@@ -256,8 +256,8 @@ function createTreeModel(options) {
|
|
|
256
256
|
mirrorFocus();
|
|
257
257
|
}
|
|
258
258
|
/**
|
|
259
|
-
* The editor's focus mode changed on its own (the focus chip, a block's „Fokussieren“, the focused
|
|
260
|
-
* the tree follows without a command. A
|
|
259
|
+
* The editor's focus mode changed on its own (the focus chip, a block's „Fokussieren“, the focused Typed block vanished):
|
|
260
|
+
* the tree follows without a command. A Typed block the outline does not know yet is retried after the next outline read.
|
|
261
261
|
*/
|
|
262
262
|
function mirrorFocus() {
|
|
263
263
|
const id = editor?.focusedId() ?? null;
|
|
@@ -269,7 +269,7 @@ function createTreeModel(options) {
|
|
|
269
269
|
}
|
|
270
270
|
const key = `outline:${id}`;
|
|
271
271
|
if (core.focusKey !== key) {
|
|
272
|
-
if ((state.get().view.index.get(key)?.item)?.type !== "
|
|
272
|
+
if ((state.get().view.index.get(key)?.item)?.type !== "typedBlock") return;
|
|
273
273
|
patch({ focusKey: key });
|
|
274
274
|
}
|
|
275
275
|
seenFocus = id;
|
|
@@ -331,10 +331,10 @@ function createTreeModel(options) {
|
|
|
331
331
|
filterOverrides: filterQuery(text) ? core.filterOverrides : NO_FILTERS
|
|
332
332
|
});
|
|
333
333
|
}
|
|
334
|
-
/** Only a
|
|
334
|
+
/** Only a Typed block the editor can address (it has a block ID) can be focused. */
|
|
335
335
|
function focus(key) {
|
|
336
336
|
const item = state.get().view.index.get(key)?.item;
|
|
337
|
-
if (item?.type !== "
|
|
337
|
+
if (item?.type !== "typedBlock" || !item.blockId) return;
|
|
338
338
|
patch({ focusKey: key });
|
|
339
339
|
execute({
|
|
340
340
|
type: "focusBlock",
|
|
@@ -349,7 +349,7 @@ function createTreeModel(options) {
|
|
|
349
349
|
id: null
|
|
350
350
|
});
|
|
351
351
|
}
|
|
352
|
-
const canMerge = (item) => item.type === "
|
|
352
|
+
const canMerge = (item) => item.type === "typedBlock" && !!item.blockId && !!editor?.canMerge(item.blockId);
|
|
353
353
|
function merge(item) {
|
|
354
354
|
if (canMerge(item)) execute({
|
|
355
355
|
type: "mergeBlock",
|
|
@@ -368,14 +368,14 @@ function createTreeModel(options) {
|
|
|
368
368
|
type: "openDocument",
|
|
369
369
|
id: item.id
|
|
370
370
|
});
|
|
371
|
-
} else if (item.type === "
|
|
371
|
+
} else if (item.type === "typedBlock" || item.type === "heading") {
|
|
372
372
|
execute({
|
|
373
373
|
type: "revealBlock",
|
|
374
374
|
id: item.blockId ?? null,
|
|
375
375
|
pos: item.pos
|
|
376
376
|
});
|
|
377
|
-
const
|
|
378
|
-
if (core.virtual && item.blockId &&
|
|
377
|
+
const takesTypedBlocks = !!item.kind && core.kinds.some((kind) => acceptsChild(core.kinds, item.kind, kind.id));
|
|
378
|
+
if (core.virtual && item.blockId && takesTypedBlocks) patch({ virtualTarget: item.blockId });
|
|
379
379
|
} else setSelectedFolder(item.path ?? "");
|
|
380
380
|
}
|
|
381
381
|
function toggle(key) {
|
|
@@ -463,7 +463,7 @@ function createTreeModel(options) {
|
|
|
463
463
|
patch({ drag: null });
|
|
464
464
|
if (!drag || !dropVerdict(drag.source, item, dropEnv()).ok) return;
|
|
465
465
|
const { source } = drag;
|
|
466
|
-
if (source.type === "
|
|
466
|
+
if (source.type === "typedBlock") {
|
|
467
467
|
const targetId = item.key === "vroot" ? null : item.blockId;
|
|
468
468
|
if (await execute({
|
|
469
469
|
type: "moveBlock",
|
|
@@ -543,13 +543,13 @@ function createTreeModel(options) {
|
|
|
543
543
|
folder
|
|
544
544
|
})) expand(ancestorKeys(folder));
|
|
545
545
|
}
|
|
546
|
-
/** Runs `command` for the
|
|
546
|
+
/** Runs `command` for the Typed block of `item` (the file itself when it has none) and shows the result. */
|
|
547
547
|
async function inComposite(item, command) {
|
|
548
548
|
if (await execute(command)) expand([item.blockId ? `outline:${item.blockId}` : item.key]);
|
|
549
549
|
}
|
|
550
550
|
/**
|
|
551
551
|
* What can be created below `item`: folders of the store take documents and sub-folders, the open file (as the root or
|
|
552
|
-
* as a document row) and its
|
|
552
|
+
* as a document row) and its Typed blocks take what their Block type accepts. Other rows take nothing. Folders also list
|
|
553
553
|
* „Umbenennen“ here: renaming a document happens in the editor's title field.
|
|
554
554
|
*/
|
|
555
555
|
function addMenu(item) {
|
|
@@ -578,11 +578,11 @@ function createTreeModel(options) {
|
|
|
578
578
|
label: t("tree.menu.newCompositeFolder"),
|
|
579
579
|
icon: "i-lucide-folder-plus",
|
|
580
580
|
run: () => void inComposite(item, {
|
|
581
|
-
type: "
|
|
581
|
+
type: "createFolderBlock",
|
|
582
582
|
targetId
|
|
583
583
|
})
|
|
584
584
|
});
|
|
585
|
-
if (can.
|
|
585
|
+
if (can.files) entries.push({
|
|
586
586
|
label: t("tree.menu.importFile"),
|
|
587
587
|
icon: "i-lucide-file-up",
|
|
588
588
|
run: () => void inComposite(item, {
|