@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
|
@@ -2,7 +2,7 @@ import { Translate } from "../../i18n/index.js";
|
|
|
2
2
|
import { Editor } from "@tiptap/core";
|
|
3
3
|
import { Node as Node$1 } from "@tiptap/pm/model";
|
|
4
4
|
//#region src/features/composites/outline.d.ts
|
|
5
|
-
/** One
|
|
5
|
+
/** One Typed block of a document's outline. */
|
|
6
6
|
export interface OutlineNode {
|
|
7
7
|
/** Block ID, or `pos:<pos>` for a block without one yet; unique within the document. */
|
|
8
8
|
key: string;
|
|
@@ -15,7 +15,7 @@ export interface OutlineNode {
|
|
|
15
15
|
* text of its own body (`labelFromBody`), else the caller's `untitled`.
|
|
16
16
|
*/
|
|
17
17
|
title: string;
|
|
18
|
-
/** `title` is derived from the body, the
|
|
18
|
+
/** `title` is derived from the body, the Typed block itself has no title. */
|
|
19
19
|
labelFromBody: boolean;
|
|
20
20
|
/** The composite has a description (the summary). */
|
|
21
21
|
hasSummary: boolean;
|
|
@@ -23,16 +23,19 @@ export interface OutlineNode {
|
|
|
23
23
|
basket: string | null;
|
|
24
24
|
/** The title is hidden in the editor (`meta.titleHidden`). */
|
|
25
25
|
titleHidden: boolean;
|
|
26
|
+
/** The Block is a Derived block whose original was deleted (the source-missing state of its Derivation). */
|
|
27
|
+
sourceMissing: boolean;
|
|
26
28
|
children: OutlineNode[];
|
|
27
29
|
}
|
|
28
30
|
/**
|
|
29
31
|
* The composites of `doc` as a tree (title, kind, summary flag). A composite without a title is labelled by its body
|
|
30
32
|
* (`labelFromBody`: first heading, else the start of the first text; nested composites do not count) and only an empty
|
|
31
33
|
* one gets `untitled` (the caller's translated „(ohne Titel)“). Composites of a kind in `hiddenKinds` are omitted and their visible descendants
|
|
32
|
-
* take their place in the parent's list.
|
|
34
|
+
* take their place in the parent's list. With `capabilitiesOf` (the editor's block capabilities) a composite without the `basket` capability has no basket.
|
|
35
|
+
* `sourceMissing` marks a Derived block whose original is gone (`derivationOriginOf` against `documentId`, the open document).
|
|
33
36
|
*/
|
|
34
|
-
export declare function compositeOutline(doc: Node$1, hiddenKinds: ReadonlySet<string>, untitled: string): OutlineNode[];
|
|
35
|
-
/** Whether a block may move into a
|
|
37
|
+
export declare function compositeOutline(doc: Node$1, hiddenKinds: ReadonlySet<string>, untitled: string, capabilitiesOf?: (node: Node$1) => ReadonlySet<string>, documentId?: string | null): OutlineNode[];
|
|
38
|
+
/** Whether a block may move into a Typed block; `reason` is a short sentence for the UI (in the language of the `t` it was judged with) when it may not. */
|
|
36
39
|
export type MoveVerdict = {
|
|
37
40
|
ok: true;
|
|
38
41
|
} | {
|
|
@@ -40,17 +43,17 @@ export type MoveVerdict = {
|
|
|
40
43
|
reason: string;
|
|
41
44
|
};
|
|
42
45
|
/**
|
|
43
|
-
* Whether block `id` may move into the
|
|
44
|
-
* not: a block is missing, the target is no
|
|
45
|
-
* does not accept the block's
|
|
46
|
-
* unless it holds
|
|
47
|
-
* checked. Moving a block to the end of the
|
|
46
|
+
* Whether block `id` may move into the Typed block `targetId` (`null` = the end of the document), with the reason when
|
|
47
|
+
* not: a block is missing, the target is no Typed block, the target is the block itself or inside it, or the target's Block type
|
|
48
|
+
* does not accept the block's Block type (`BlockType.accepts`). A block that is no Typed block may move into any Typed block,
|
|
49
|
+
* unless it holds Typed blocks of a refused Block type; Typed blocks nested inside a moved Typed block stay with it and are not
|
|
50
|
+
* checked. Moving a block to the end of the Typed block it already sits in adds no nesting and is never refused for it.
|
|
48
51
|
*/
|
|
49
52
|
export declare function moveIntoVerdict(editor: Editor, id: string, targetId: string | null, t: Translate): MoveVerdict;
|
|
50
|
-
/** Whether block `id` can move into the
|
|
53
|
+
/** Whether block `id` can move into the Typed block `targetId` (`null` = the end of the document); see `moveIntoVerdict`. */
|
|
51
54
|
export declare function canMoveBlockInto(editor: Editor, id: string, targetId: string | null): boolean;
|
|
52
55
|
/**
|
|
53
|
-
* Moves block `id` to the end of the body of the
|
|
56
|
+
* Moves block `id` to the end of the body of the Typed block `targetId` (`null` = the end of the document) in a single
|
|
54
57
|
* transaction, i.e. one undo step. `false` when nothing moved: `moveIntoVerdict` refuses the move (or the editor
|
|
55
58
|
* refused the transaction).
|
|
56
59
|
*/
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { blockIdOf, findBlockById } from "../../core/schema/block-ids.js";
|
|
2
|
-
import {
|
|
2
|
+
import { derivationOf, derivationOriginOf } from "../../core/derivation.js";
|
|
3
|
+
import { acceptsChild } from "./block-types.js";
|
|
3
4
|
import { basketOf, titleHiddenOf } from "./baskets.js";
|
|
4
|
-
import {
|
|
5
|
+
import { blockTypesOf } from "./nodes.js";
|
|
5
6
|
import { nestingReason, outermostComposites } from "./accepted-children.js";
|
|
6
7
|
//#region src/features/composites/outline.ts
|
|
7
8
|
/** Longest label taken from a paragraph; longer text is cut and ends in an ellipsis. */
|
|
@@ -20,7 +21,7 @@ const clipLabel = (text) => {
|
|
|
20
21
|
function scanBody(parent, from, found) {
|
|
21
22
|
for (let i = from; i < parent.childCount && found.heading === null; i++) {
|
|
22
23
|
const node = parent.child(i);
|
|
23
|
-
if (node.type.name === "
|
|
24
|
+
if (node.type.name === "typedBlock") continue;
|
|
24
25
|
if (node.isTextblock) {
|
|
25
26
|
const text = node.textContent.trim();
|
|
26
27
|
if (!text) continue;
|
|
@@ -42,14 +43,15 @@ function bodyLabel(composite) {
|
|
|
42
43
|
* The composites of `doc` as a tree (title, kind, summary flag). A composite without a title is labelled by its body
|
|
43
44
|
* (`labelFromBody`: first heading, else the start of the first text; nested composites do not count) and only an empty
|
|
44
45
|
* one gets `untitled` (the caller's translated „(ohne Titel)“). Composites of a kind in `hiddenKinds` are omitted and their visible descendants
|
|
45
|
-
* take their place in the parent's list.
|
|
46
|
+
* take their place in the parent's list. With `capabilitiesOf` (the editor's block capabilities) a composite without the `basket` capability has no basket.
|
|
47
|
+
* `sourceMissing` marks a Derived block whose original is gone (`derivationOriginOf` against `documentId`, the open document).
|
|
46
48
|
*/
|
|
47
|
-
function compositeOutline(doc, hiddenKinds, untitled) {
|
|
49
|
+
function compositeOutline(doc, hiddenKinds, untitled, capabilitiesOf, documentId) {
|
|
48
50
|
function collect(parent, start, into) {
|
|
49
51
|
parent.forEach((node, offset) => {
|
|
50
52
|
const pos = start + offset;
|
|
51
|
-
if (node.type.name === "
|
|
52
|
-
const kind = String(node.attrs.
|
|
53
|
+
if (node.type.name === "typedBlock") {
|
|
54
|
+
const kind = String(node.attrs.blockType);
|
|
53
55
|
const children = [];
|
|
54
56
|
collect(node, pos + 1, children);
|
|
55
57
|
if (hiddenKinds.has(kind)) {
|
|
@@ -67,8 +69,9 @@ function compositeOutline(doc, hiddenKinds, untitled) {
|
|
|
67
69
|
title: ownTitle || derived || untitled,
|
|
68
70
|
labelFromBody: derived !== null,
|
|
69
71
|
hasSummary: (node.maybeChild(1)?.content.size ?? 0) > 0,
|
|
70
|
-
basket: basketOf(node),
|
|
72
|
+
basket: capabilitiesOf && !capabilitiesOf(node).has("basket") ? null : basketOf(node),
|
|
71
73
|
titleHidden: titleHiddenOf(node),
|
|
74
|
+
sourceMissing: derivationOf(node) !== null && derivationOriginOf(doc, pos, documentId)?.status === "missing",
|
|
72
75
|
children
|
|
73
76
|
});
|
|
74
77
|
} else if (!node.isTextblock && !node.isLeaf) collect(node, pos + 1, into);
|
|
@@ -83,11 +86,11 @@ const refused = (reason) => ({
|
|
|
83
86
|
reason
|
|
84
87
|
});
|
|
85
88
|
/**
|
|
86
|
-
* Whether block `id` may move into the
|
|
87
|
-
* not: a block is missing, the target is no
|
|
88
|
-
* does not accept the block's
|
|
89
|
-
* unless it holds
|
|
90
|
-
* checked. Moving a block to the end of the
|
|
89
|
+
* Whether block `id` may move into the Typed block `targetId` (`null` = the end of the document), with the reason when
|
|
90
|
+
* not: a block is missing, the target is no Typed block, the target is the block itself or inside it, or the target's Block type
|
|
91
|
+
* does not accept the block's Block type (`BlockType.accepts`). A block that is no Typed block may move into any Typed block,
|
|
92
|
+
* unless it holds Typed blocks of a refused Block type; Typed blocks nested inside a moved Typed block stay with it and are not
|
|
93
|
+
* checked. Moving a block to the end of the Typed block it already sits in adds no nesting and is never refused for it.
|
|
91
94
|
*/
|
|
92
95
|
function moveIntoVerdict(editor, id, targetId, t) {
|
|
93
96
|
const { doc } = editor.state;
|
|
@@ -96,32 +99,32 @@ function moveIntoVerdict(editor, id, targetId, t) {
|
|
|
96
99
|
if (targetId === null) return { ok: true };
|
|
97
100
|
const target = findBlockById(doc, targetId);
|
|
98
101
|
if (!target) return refused(t("composites.move.targetGone"));
|
|
99
|
-
if (target.node.type.name !== "
|
|
102
|
+
if (target.node.type.name !== "typedBlock") return refused(t("composites.move.targetNotBlock"));
|
|
100
103
|
if (target.pos === block.pos) return refused(t("composites.move.intoSelf"));
|
|
101
104
|
if (target.pos > block.pos && target.pos < block.pos + block.node.nodeSize) return refused(t("composites.move.intoOwn"));
|
|
102
105
|
const $block = doc.resolve(block.pos);
|
|
103
106
|
let parentPos = -1;
|
|
104
|
-
for (let depth = $block.depth; depth > 0; depth--) if ($block.node(depth).type.name === "
|
|
107
|
+
for (let depth = $block.depth; depth > 0; depth--) if ($block.node(depth).type.name === "typedBlock") {
|
|
105
108
|
parentPos = $block.before(depth);
|
|
106
109
|
break;
|
|
107
110
|
}
|
|
108
111
|
if (parentPos === target.pos) return { ok: true };
|
|
109
|
-
const kinds =
|
|
110
|
-
const targetKind = String(target.node.attrs.
|
|
112
|
+
const kinds = blockTypesOf(editor);
|
|
113
|
+
const targetKind = String(target.node.attrs.blockType);
|
|
111
114
|
for (const child of outermostComposites(block.node)) {
|
|
112
|
-
const childKind = String(child.attrs.
|
|
113
|
-
if (!
|
|
115
|
+
const childKind = String(child.attrs.blockType);
|
|
116
|
+
if (!acceptsChild(kinds, targetKind, childKind)) return refused(nestingReason(kinds, targetKind, childKind, t));
|
|
114
117
|
}
|
|
115
118
|
return { ok: true };
|
|
116
119
|
}
|
|
117
120
|
/** `canMoveBlockInto` reads only `ok`, so its verdict needs no text: the message keys stand in for the sentences. */
|
|
118
121
|
const untranslated = (key) => key;
|
|
119
|
-
/** Whether block `id` can move into the
|
|
122
|
+
/** Whether block `id` can move into the Typed block `targetId` (`null` = the end of the document); see `moveIntoVerdict`. */
|
|
120
123
|
function canMoveBlockInto(editor, id, targetId) {
|
|
121
124
|
return moveIntoVerdict(editor, id, targetId, untranslated).ok;
|
|
122
125
|
}
|
|
123
126
|
/**
|
|
124
|
-
* Moves block `id` to the end of the body of the
|
|
127
|
+
* Moves block `id` to the end of the body of the Typed block `targetId` (`null` = the end of the document) in a single
|
|
125
128
|
* transaction, i.e. one undo step. `false` when nothing moved: `moveIntoVerdict` refuses the move (or the editor
|
|
126
129
|
* refused the transaction).
|
|
127
130
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outline.js","names":[],"sources":["../../../src/features/composites/outline.ts"],"sourcesContent":["import type { Editor } from '@tiptap/core'\nimport type { Node as PMNode } from '@tiptap/pm/model'\nimport { blockIdOf, findBlockById } from '../../core/schema'\nimport type { Translate } from '../../i18n'\nimport { nestingReason, outermostComposites } from './accepted-children'\nimport { basketOf, titleHiddenOf } from './baskets'\nimport { kindAccepts } from './kinds'\nimport { compositeKindsOf } from './nodes'\n\n/** One Baustein of a document's outline. */\nexport interface OutlineNode {\n /** Block ID, or `pos:<pos>` for a block without one yet; unique within the document. */\n key: string\n id: string | null\n /** Position of the composite in the document it was read from. */\n pos: number\n kind: string\n /**\n * The title; for a composite without one, the text of the first heading of its own body, else the start of the first\n * text of its own body (`labelFromBody`), else the caller's `untitled`.\n */\n title: string\n /** `title` is derived from the body, the Baustein itself has no title. */\n labelFromBody: boolean\n /** The composite has a description (the summary). */\n hasSummary: boolean\n /** Basket id (`meta.basket`), `null` without one. */\n basket: string | null\n /** The title is hidden in the editor (`meta.titleHidden`). */\n titleHidden: boolean\n children: OutlineNode[]\n}\n\n/** Longest label taken from a paragraph; longer text is cut and ends in an ellipsis. */\nconst BODY_LABEL_CHARS = 60\n\nconst clipLabel = (text: string) => {\n if (text.length <= BODY_LABEL_CHARS) return text\n let end = BODY_LABEL_CHARS\n const last = text.charCodeAt(end - 1)\n if (last >= 0xD800 && last <= 0xDBFF) end-- // do not cut a surrogate pair\n return `${text.slice(0, end).trimEnd()}…`\n}\n\n/**\n * Walks the blocks of a composite's own body (not the ones inside a nested composite) in order. The text of the first\n * heading ends the walk; `found.text` collects the first non-empty text block as the fallback.\n */\nfunction scanBody(parent: PMNode, from: number, found: { heading: string | null, text: string | null }): void {\n for (let i = from; i < parent.childCount && found.heading === null; i++) {\n const node = parent.child(i)\n if (node.type.name === 'composite') continue\n if (node.isTextblock) {\n const text = node.textContent.trim()\n if (!text) continue\n if (node.type.name === 'heading') found.heading = text\n else found.text ??= text.replace(/\\s+/g, ' ')\n }\n else if (!node.isLeaf) scanBody(node, 0, found)\n }\n}\n\n/** The label of a composite without a title: its first heading, else the start of its first text; `null` for an empty body. */\nfunction bodyLabel(composite: PMNode): string | null {\n const found = { heading: null as string | null, text: null as string | null }\n scanBody(composite, 3, found) // title, description and tags come first\n return found.heading ?? (found.text === null ? null : clipLabel(found.text))\n}\n\n/**\n * The composites of `doc` as a tree (title, kind, summary flag). A composite without a title is labelled by its body\n * (`labelFromBody`: first heading, else the start of the first text; nested composites do not count) and only an empty\n * one gets `untitled` (the caller's translated „(ohne Titel)“). Composites of a kind in `hiddenKinds` are omitted and their visible descendants\n * take their place in the parent's list.\n */\nexport function compositeOutline(doc: PMNode, hiddenKinds: ReadonlySet<string>, untitled: string): OutlineNode[] {\n function collect(parent: PMNode, start: number, into: OutlineNode[]) {\n parent.forEach((node, offset) => {\n const pos = start + offset\n if (node.type.name === 'composite') {\n const kind = String(node.attrs.kind)\n const children: OutlineNode[] = []\n collect(node, pos + 1, children)\n if (hiddenKinds.has(kind)) {\n into.push(...children)\n return\n }\n const id = blockIdOf(node)\n const ownTitle = node.firstChild?.textContent.trim() ?? ''\n const derived = ownTitle ? null : bodyLabel(node)\n into.push({\n key: id ?? `pos:${pos}`,\n id,\n pos,\n kind,\n title: ownTitle || derived || untitled,\n labelFromBody: derived !== null,\n hasSummary: (node.maybeChild(1)?.content.size ?? 0) > 0,\n basket: basketOf(node),\n titleHidden: titleHiddenOf(node),\n children,\n })\n }\n else if (!node.isTextblock && !node.isLeaf) {\n // Composites can sit in quotes or lists as well.\n collect(node, pos + 1, into)\n }\n })\n }\n const roots: OutlineNode[] = []\n collect(doc, 0, roots)\n return roots\n}\n\n/** Whether a block may move into a Baustein; `reason` is a short sentence for the UI (in the language of the `t` it was judged with) when it may not. */\nexport type MoveVerdict = { ok: true } | { ok: false, reason: string }\n\nconst refused = (reason: string): MoveVerdict => ({ ok: false, reason })\n\n/**\n * Whether block `id` may move into the Baustein `targetId` (`null` = the end of the document), with the reason when\n * not: a block is missing, the target is no Baustein, the target is the block itself or inside it, or the target's kind\n * does not accept the block's kind (`CompositeKind.accepts`). A block that is no Baustein may move into any Baustein,\n * unless it holds Bausteine of a refused kind; Bausteine nested inside a moved Baustein stay with it and are not\n * checked. Moving a block to the end of the Baustein it already sits in adds no nesting and is never refused for it.\n */\nexport function moveIntoVerdict(editor: Editor, id: string, targetId: string | null, t: Translate): MoveVerdict {\n const { doc } = editor.state\n const block = findBlockById(doc, id)\n if (!block) return refused(t('composites.move.blockGone'))\n if (targetId === null) return { ok: true }\n const target = findBlockById(doc, targetId)\n if (!target) return refused(t('composites.move.targetGone'))\n if (target.node.type.name !== 'composite') return refused(t('composites.move.targetNotBlock'))\n if (target.pos === block.pos) return refused(t('composites.move.intoSelf'))\n if (target.pos > block.pos && target.pos < block.pos + block.node.nodeSize) return refused(t('composites.move.intoOwn'))\n\n // The nearest Baustein around the block: when it is the target, the block only moves within it.\n const $block = doc.resolve(block.pos)\n let parentPos = -1\n for (let depth = $block.depth; depth > 0; depth--) {\n if ($block.node(depth).type.name === 'composite') {\n parentPos = $block.before(depth)\n break\n }\n }\n if (parentPos === target.pos) return { ok: true }\n\n const kinds = compositeKindsOf(editor)\n const targetKind = String(target.node.attrs.kind)\n for (const child of outermostComposites(block.node)) {\n const childKind = String(child.attrs.kind)\n if (!kindAccepts(kinds, targetKind, childKind)) return refused(nestingReason(kinds, targetKind, childKind, t))\n }\n return { ok: true }\n}\n\n/** `canMoveBlockInto` reads only `ok`, so its verdict needs no text: the message keys stand in for the sentences. */\nconst untranslated: Translate = key => key\n\n/** Whether block `id` can move into the Baustein `targetId` (`null` = the end of the document); see `moveIntoVerdict`. */\nexport function canMoveBlockInto(editor: Editor, id: string, targetId: string | null): boolean {\n return moveIntoVerdict(editor, id, targetId, untranslated).ok\n}\n\n/**\n * Moves block `id` to the end of the body of the Baustein `targetId` (`null` = the end of the document) in a single\n * transaction, i.e. one undo step. `false` when nothing moved: `moveIntoVerdict` refuses the move (or the editor\n * refused the transaction).\n */\nexport function moveBlockInto(editor: Editor, id: string, targetId: string | null): boolean {\n if (!canMoveBlockInto(editor, id, targetId)) return false\n const { doc, tr } = editor.state\n const block = findBlockById(doc, id)!\n const target = targetId === null ? null : findBlockById(doc, targetId)!\n // A composite's body is its last children, so its end is just before the composite's closing token.\n const insertPos = target ? target.pos + target.node.nodeSize - 1 : doc.content.size\n tr.delete(block.pos, block.pos + block.node.nodeSize)\n tr.insert(tr.mapping.map(insertPos), block.node)\n editor.view.dispatch(tr.scrollIntoView())\n return editor.state.doc !== doc\n}\n"],"mappings":";;;;;;;AAkCA,MAAM,mBAAmB;AAEzB,MAAM,aAAa,SAAiB;CAClC,IAAI,KAAK,UAAU,kBAAkB,OAAO;CAC5C,IAAI,MAAM;CACV,MAAM,OAAO,KAAK,WAAW,MAAM,CAAC;CACpC,IAAI,QAAQ,SAAU,QAAQ,OAAQ;CACtC,OAAO,GAAG,KAAK,MAAM,GAAG,GAAG,CAAC,CAAC,QAAQ,EAAE;AACzC;;;;;AAMA,SAAS,SAAS,QAAgB,MAAc,OAA8D;CAC5G,KAAK,IAAI,IAAI,MAAM,I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B,MAAM,IAAI,GAAG;EACnD,MAAM,YAAY,OAAO,MAAM,MAAM,IAAI;EACzC,IAAI,CAAC,YAAY,OAAO,YAAY,SAAS,GAAG,OAAO,QAAQ,cAAc,OAAO,YAAY,WAAW,CAAC,CAAC;CAC/G;CACA,OAAO,EAAE,IAAI,KAAK;AACpB;;AAGA,MAAM,gBAA0B,QAAO;;AAGvC,SAAgB,iBAAiB,QAAgB,IAAY,UAAkC;CAC7F,OAAO,gBAAgB,QAAQ,IAAI,UAAU,YAAY,CAAC,CAAC;AAC7D;;;;;;AAOA,SAAgB,cAAc,QAAgB,IAAY,UAAkC;CAC1F,IAAI,CAAC,iBAAiB,QAAQ,IAAI,QAAQ,GAAG,OAAO;CACpD,MAAM,EAAE,KAAK,OAAO,OAAO;CAC3B,MAAM,QAAQ,cAAc,KAAK,EAAE;CACnC,MAAM,SAAS,aAAa,OAAO,OAAO,cAAc,KAAK,QAAQ;CAErE,MAAM,YAAY,SAAS,OAAO,MAAM,OAAO,KAAK,WAAW,IAAI,IAAI,QAAQ;CAC/E,GAAG,OAAO,MAAM,KAAK,MAAM,MAAM,MAAM,KAAK,QAAQ;CACpD,GAAG,OAAO,GAAG,QAAQ,IAAI,SAAS,GAAG,MAAM,IAAI;CAC/C,OAAO,KAAK,SAAS,GAAG,eAAe,CAAC;CACxC,OAAO,OAAO,MAAM,QAAQ;AAC9B"}
|
|
1
|
+
{"version":3,"file":"outline.js","names":[],"sources":["../../../src/features/composites/outline.ts"],"sourcesContent":["import type { Editor } from '@tiptap/core'\nimport type { Node as PMNode } from '@tiptap/pm/model'\nimport { derivationOf, derivationOriginOf } from '../../core/derivation'\nimport { blockIdOf, findBlockById } from '../../core/schema'\nimport type { Translate } from '../../i18n'\nimport { nestingReason, outermostComposites } from './accepted-children'\nimport { basketOf, titleHiddenOf } from './baskets'\nimport { acceptsChild } from './block-types'\nimport { blockTypesOf } from './nodes'\n\n/** One Typed block of a document's outline. */\nexport interface OutlineNode {\n /** Block ID, or `pos:<pos>` for a block without one yet; unique within the document. */\n key: string\n id: string | null\n /** Position of the composite in the document it was read from. */\n pos: number\n kind: string\n /**\n * The title; for a composite without one, the text of the first heading of its own body, else the start of the first\n * text of its own body (`labelFromBody`), else the caller's `untitled`.\n */\n title: string\n /** `title` is derived from the body, the Typed block itself has no title. */\n labelFromBody: boolean\n /** The composite has a description (the summary). */\n hasSummary: boolean\n /** Basket id (`meta.basket`), `null` without one. */\n basket: string | null\n /** The title is hidden in the editor (`meta.titleHidden`). */\n titleHidden: boolean\n /** The Block is a Derived block whose original was deleted (the source-missing state of its Derivation). */\n sourceMissing: boolean\n children: OutlineNode[]\n}\n\n/** Longest label taken from a paragraph; longer text is cut and ends in an ellipsis. */\nconst BODY_LABEL_CHARS = 60\n\nconst clipLabel = (text: string) => {\n if (text.length <= BODY_LABEL_CHARS) return text\n let end = BODY_LABEL_CHARS\n const last = text.charCodeAt(end - 1)\n if (last >= 0xD800 && last <= 0xDBFF) end-- // do not cut a surrogate pair\n return `${text.slice(0, end).trimEnd()}…`\n}\n\n/**\n * Walks the blocks of a composite's own body (not the ones inside a nested composite) in order. The text of the first\n * heading ends the walk; `found.text` collects the first non-empty text block as the fallback.\n */\nfunction scanBody(parent: PMNode, from: number, found: { heading: string | null, text: string | null }): void {\n for (let i = from; i < parent.childCount && found.heading === null; i++) {\n const node = parent.child(i)\n if (node.type.name === 'typedBlock') continue\n if (node.isTextblock) {\n const text = node.textContent.trim()\n if (!text) continue\n if (node.type.name === 'heading') found.heading = text\n else found.text ??= text.replace(/\\s+/g, ' ')\n }\n else if (!node.isLeaf) scanBody(node, 0, found)\n }\n}\n\n/** The label of a composite without a title: its first heading, else the start of its first text; `null` for an empty body. */\nfunction bodyLabel(composite: PMNode): string | null {\n const found = { heading: null as string | null, text: null as string | null }\n scanBody(composite, 3, found) // title, description and tags come first\n return found.heading ?? (found.text === null ? null : clipLabel(found.text))\n}\n\n/**\n * The composites of `doc` as a tree (title, kind, summary flag). A composite without a title is labelled by its body\n * (`labelFromBody`: first heading, else the start of the first text; nested composites do not count) and only an empty\n * one gets `untitled` (the caller's translated „(ohne Titel)“). Composites of a kind in `hiddenKinds` are omitted and their visible descendants\n * take their place in the parent's list. With `capabilitiesOf` (the editor's block capabilities) a composite without the `basket` capability has no basket.\n * `sourceMissing` marks a Derived block whose original is gone (`derivationOriginOf` against `documentId`, the open document).\n */\nexport function compositeOutline(doc: PMNode, hiddenKinds: ReadonlySet<string>, untitled: string, capabilitiesOf?: (node: PMNode) => ReadonlySet<string>, documentId?: string | null): OutlineNode[] {\n function collect(parent: PMNode, start: number, into: OutlineNode[]) {\n parent.forEach((node, offset) => {\n const pos = start + offset\n if (node.type.name === 'typedBlock') {\n const kind = String(node.attrs.blockType)\n const children: OutlineNode[] = []\n collect(node, pos + 1, children)\n if (hiddenKinds.has(kind)) {\n into.push(...children)\n return\n }\n const id = blockIdOf(node)\n const ownTitle = node.firstChild?.textContent.trim() ?? ''\n const derived = ownTitle ? null : bodyLabel(node)\n into.push({\n key: id ?? `pos:${pos}`,\n id,\n pos,\n kind,\n title: ownTitle || derived || untitled,\n labelFromBody: derived !== null,\n hasSummary: (node.maybeChild(1)?.content.size ?? 0) > 0,\n basket: capabilitiesOf && !capabilitiesOf(node).has('basket') ? null : basketOf(node),\n titleHidden: titleHiddenOf(node),\n sourceMissing: derivationOf(node) !== null && derivationOriginOf(doc, pos, documentId)?.status === 'missing',\n children,\n })\n }\n else if (!node.isTextblock && !node.isLeaf) {\n // Composites can sit in quotes or lists as well.\n collect(node, pos + 1, into)\n }\n })\n }\n const roots: OutlineNode[] = []\n collect(doc, 0, roots)\n return roots\n}\n\n/** Whether a block may move into a Typed block; `reason` is a short sentence for the UI (in the language of the `t` it was judged with) when it may not. */\nexport type MoveVerdict = { ok: true } | { ok: false, reason: string }\n\nconst refused = (reason: string): MoveVerdict => ({ ok: false, reason })\n\n/**\n * Whether block `id` may move into the Typed block `targetId` (`null` = the end of the document), with the reason when\n * not: a block is missing, the target is no Typed block, the target is the block itself or inside it, or the target's Block type\n * does not accept the block's Block type (`BlockType.accepts`). A block that is no Typed block may move into any Typed block,\n * unless it holds Typed blocks of a refused Block type; Typed blocks nested inside a moved Typed block stay with it and are not\n * checked. Moving a block to the end of the Typed block it already sits in adds no nesting and is never refused for it.\n */\nexport function moveIntoVerdict(editor: Editor, id: string, targetId: string | null, t: Translate): MoveVerdict {\n const { doc } = editor.state\n const block = findBlockById(doc, id)\n if (!block) return refused(t('composites.move.blockGone'))\n if (targetId === null) return { ok: true }\n const target = findBlockById(doc, targetId)\n if (!target) return refused(t('composites.move.targetGone'))\n if (target.node.type.name !== 'typedBlock') return refused(t('composites.move.targetNotBlock'))\n if (target.pos === block.pos) return refused(t('composites.move.intoSelf'))\n if (target.pos > block.pos && target.pos < block.pos + block.node.nodeSize) return refused(t('composites.move.intoOwn'))\n\n // The nearest Typed block around the block: when it is the target, the block only moves within it.\n const $block = doc.resolve(block.pos)\n let parentPos = -1\n for (let depth = $block.depth; depth > 0; depth--) {\n if ($block.node(depth).type.name === 'typedBlock') {\n parentPos = $block.before(depth)\n break\n }\n }\n if (parentPos === target.pos) return { ok: true }\n\n const kinds = blockTypesOf(editor)\n const targetKind = String(target.node.attrs.blockType)\n for (const child of outermostComposites(block.node)) {\n const childKind = String(child.attrs.blockType)\n if (!acceptsChild(kinds, targetKind, childKind)) return refused(nestingReason(kinds, targetKind, childKind, t))\n }\n return { ok: true }\n}\n\n/** `canMoveBlockInto` reads only `ok`, so its verdict needs no text: the message keys stand in for the sentences. */\nconst untranslated: Translate = key => key\n\n/** Whether block `id` can move into the Typed block `targetId` (`null` = the end of the document); see `moveIntoVerdict`. */\nexport function canMoveBlockInto(editor: Editor, id: string, targetId: string | null): boolean {\n return moveIntoVerdict(editor, id, targetId, untranslated).ok\n}\n\n/**\n * Moves block `id` to the end of the body of the Typed block `targetId` (`null` = the end of the document) in a single\n * transaction, i.e. one undo step. `false` when nothing moved: `moveIntoVerdict` refuses the move (or the editor\n * refused the transaction).\n */\nexport function moveBlockInto(editor: Editor, id: string, targetId: string | null): boolean {\n if (!canMoveBlockInto(editor, id, targetId)) return false\n const { doc, tr } = editor.state\n const block = findBlockById(doc, id)!\n const target = targetId === null ? null : findBlockById(doc, targetId)!\n // A composite's body is its last children, so its end is just before the composite's closing token.\n const insertPos = target ? target.pos + target.node.nodeSize - 1 : doc.content.size\n tr.delete(block.pos, block.pos + block.node.nodeSize)\n tr.insert(tr.mapping.map(insertPos), block.node)\n editor.view.dispatch(tr.scrollIntoView())\n return editor.state.doc !== doc\n}\n"],"mappings":";;;;;;;;AAqCA,MAAM,mBAAmB;AAEzB,MAAM,aAAa,SAAiB;CAClC,IAAI,KAAK,UAAU,kBAAkB,OAAO;CAC5C,IAAI,MAAM;CACV,MAAM,OAAO,KAAK,WAAW,MAAM,CAAC;CACpC,IAAI,QAAQ,SAAU,QAAQ,OAAQ;CACtC,OAAO,GAAG,KAAK,MAAM,GAAG,GAAG,CAAC,CAAC,QAAQ,EAAE;AACzC;;;;;AAMA,SAAS,SAAS,QAAgB,MAAc,OAA8D;CAC5G,KAAK,IAAI,IAAI,MAAM,IAAI,OAAO,cAAc,MAAM,YAAY,MAAM,KAAK;EACvE,MAAM,OAAO,OAAO,MAAM,CAAC;EAC3B,IAAI,KAAK,KAAK,SAAS,cAAc;EACrC,IAAI,KAAK,aAAa;GACpB,MAAM,OAAO,KAAK,YAAY,KAAK;GACnC,IAAI,CAAC,MAAM;GACX,IAAI,KAAK,KAAK,SAAS,WAAW,MAAM,UAAU;QAC7C,MAAM,SAAS,KAAK,QAAQ,QAAQ,GAAG;EAC9C,OACK,IAAI,CAAC,KAAK,QAAQ,SAAS,MAAM,GAAG,KAAK;CAChD;AACF;;AAGA,SAAS,UAAU,WAAkC;CACnD,MAAM,QAAQ;EAAE,SAAS;EAAuB,MAAM;CAAsB;CAC5E,SAAS,WAAW,GAAG,KAAK;CAC5B,OAAO,MAAM,YAAY,MAAM,SAAS,OAAO,OAAO,UAAU,MA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IAAY,UAAkC;CAC1F,IAAI,CAAC,iBAAiB,QAAQ,IAAI,QAAQ,GAAG,OAAO;CACpD,MAAM,EAAE,KAAK,OAAO,OAAO;CAC3B,MAAM,QAAQ,cAAc,KAAK,EAAE;CACnC,MAAM,SAAS,aAAa,OAAO,OAAO,cAAc,KAAK,QAAQ;CAErE,MAAM,YAAY,SAAS,OAAO,MAAM,OAAO,KAAK,WAAW,IAAI,IAAI,QAAQ;CAC/E,GAAG,OAAO,MAAM,KAAK,MAAM,MAAM,MAAM,KAAK,QAAQ;CACpD,GAAG,OAAO,GAAG,QAAQ,IAAI,SAAS,GAAG,MAAM,IAAI;CAC/C,OAAO,KAAK,SAAS,GAAG,eAAe,CAAC;CACxC,OAAO,OAAO,MAAM,QAAQ;AAC9B"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { PropertyDefinition } from "../../core/properties.js";
|
|
2
|
+
import { BlockType } from "./block-types.js";
|
|
3
|
+
import { Editor } from "@tiptap/core";
|
|
4
|
+
import { Node as Node$1, ResolvedPos } from "@tiptap/pm/model";
|
|
5
|
+
//#region src/features/composites/properties.d.ts
|
|
6
|
+
/** Whether the node type has the `meta` attribute, where Block properties (and the bibliography, the basket, the derivation) are stored. This is what the `properties` capability's `appliesTo` asks of a node. */
|
|
7
|
+
export declare const carriesProperties: (node: Node$1) => boolean;
|
|
8
|
+
/** A block that carries property values, with the Property definitions its Block type declares and the values it holds. */
|
|
9
|
+
export interface BlockProperties {
|
|
10
|
+
/** Block ID, or `pos:<pos>` for a block without one yet; unique within the document. */
|
|
11
|
+
key: string;
|
|
12
|
+
id: string | null;
|
|
13
|
+
/** Position of the block when it was read; the write helpers re-resolve it, so a stale value is safe for blocks with an ID. */
|
|
14
|
+
pos: number;
|
|
15
|
+
/** The values, as stored: `meta`. */
|
|
16
|
+
meta: Record<string, unknown>;
|
|
17
|
+
/** The Property definitions of the block's Block type: empty without the `properties` capability; `bibliography` definitions drop out without the `bibliography` capability. */
|
|
18
|
+
definitions: readonly PropertyDefinition[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The properties of `node` at `pos`, a node that carries property values (`carriesProperties`; its `meta` is read as the
|
|
22
|
+
* values). `capabilities` is what `capabilitiesOf` answers for the node; `blockTypes` are the editor's Block types.
|
|
23
|
+
*/
|
|
24
|
+
export declare function blockPropertiesOf(node: Node$1, pos: number, blockTypes: readonly BlockType[], capabilities: ReadonlySet<string>): BlockProperties;
|
|
25
|
+
/**
|
|
26
|
+
* The properties of the innermost block around `$pos` that carries property values (`carriesProperties`), with its node; null
|
|
27
|
+
* when none does. A block of that kind whose type lacks the `properties` capability answers with no `definitions` rather than handing
|
|
28
|
+
* the caret to an outer block. `blockTypes` are the editor's Block types.
|
|
29
|
+
*/
|
|
30
|
+
export declare function blockPropertiesAt(editor: Editor, $pos: ResolvedPos, blockTypes: readonly BlockType[]): {
|
|
31
|
+
node: Node$1;
|
|
32
|
+
properties: BlockProperties;
|
|
33
|
+
} | null;
|
|
34
|
+
/** The block `target` stands for in `doc` and that carries property values: by block ID, else (no ID yet) by its position. Positions are re-resolved on every call. */
|
|
35
|
+
export declare function propertyHostOf(doc: Node$1, target: Pick<BlockProperties, 'id' | 'pos'>): {
|
|
36
|
+
pos: number;
|
|
37
|
+
node: Node$1;
|
|
38
|
+
} | null;
|
|
39
|
+
/**
|
|
40
|
+
* `meta` with `value` stored under `definition.key`: a number property converts a numeric string, an empty value (`''`,
|
|
41
|
+
* `null`, `undefined`, `NaN`) removes the key. A `multiselect` property keeps the string entries of an array value and
|
|
42
|
+
* removes the key when none is left. Returns a new object; `meta` is not changed.
|
|
43
|
+
*/
|
|
44
|
+
export declare function metaWithProperty(meta: Record<string, unknown>, definition: Pick<PropertyDefinition, 'key' | 'type'>, value: unknown): Record<string, unknown>;
|
|
45
|
+
/**
|
|
46
|
+
* Stores `value` under the property `key` of the block `target` stands for (see `metaWithProperty`), in one transaction; a key
|
|
47
|
+
* the block's `definitions` do not define is written as text. False when the block is gone or carries no property values.
|
|
48
|
+
*/
|
|
49
|
+
export declare function setBlockProperty(editor: Editor, target: Pick<BlockProperties, 'id' | 'pos' | 'definitions'>, key: string, value: unknown): boolean;
|
|
50
|
+
//#endregion
|
|
51
|
+
//# sourceMappingURL=properties.d.ts.map
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { blockIdOf, findBlockById } from "../../core/schema/block-ids.js";
|
|
2
|
+
import { blockTypeIdOf, capabilitiesOf } from "../../core/capabilities.js";
|
|
3
|
+
import { blockTypeOf, propertiesOf } from "./block-types.js";
|
|
4
|
+
//#region src/features/composites/properties.ts
|
|
5
|
+
/** Whether the node type has the `meta` attribute, where Block properties (and the bibliography, the basket, the derivation) are stored. This is what the `properties` capability's `appliesTo` asks of a node. */
|
|
6
|
+
const carriesProperties = (node) => "meta" in (node.type.spec.attrs ?? {});
|
|
7
|
+
/**
|
|
8
|
+
* The properties of `node` at `pos`, a node that carries property values (`carriesProperties`; its `meta` is read as the
|
|
9
|
+
* values). `capabilities` is what `capabilitiesOf` answers for the node; `blockTypes` are the editor's Block types.
|
|
10
|
+
*/
|
|
11
|
+
function blockPropertiesOf(node, pos, blockTypes, capabilities) {
|
|
12
|
+
const id = blockIdOf(node);
|
|
13
|
+
const typeId = blockTypeIdOf(node);
|
|
14
|
+
const definitions = typeId !== null && capabilities.has("properties") ? propertiesOf(blockTypeOf(blockTypes, typeId)).filter((field) => field.type !== "bibliography" || capabilities.has("bibliography")) : [];
|
|
15
|
+
return {
|
|
16
|
+
key: id ?? `pos:${pos}`,
|
|
17
|
+
id,
|
|
18
|
+
pos,
|
|
19
|
+
meta: node.attrs.meta ?? {},
|
|
20
|
+
definitions
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The properties of the innermost block around `$pos` that carries property values (`carriesProperties`), with its node; null
|
|
25
|
+
* when none does. A block of that kind whose type lacks the `properties` capability answers with no `definitions` rather than handing
|
|
26
|
+
* the caret to an outer block. `blockTypes` are the editor's Block types.
|
|
27
|
+
*/
|
|
28
|
+
function blockPropertiesAt(editor, $pos, blockTypes) {
|
|
29
|
+
for (let depth = $pos.depth; depth > 0; depth--) {
|
|
30
|
+
const node = $pos.node(depth);
|
|
31
|
+
if (carriesProperties(node)) return {
|
|
32
|
+
node,
|
|
33
|
+
properties: blockPropertiesOf(node, $pos.before(depth), blockTypes, capabilitiesOf(editor, node))
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
/** The block `target` stands for in `doc` and that carries property values: by block ID, else (no ID yet) by its position. Positions are re-resolved on every call. */
|
|
39
|
+
function propertyHostOf(doc, target) {
|
|
40
|
+
const found = target.id ? findBlockById(doc, target.id) : (() => {
|
|
41
|
+
const node = doc.nodeAt(target.pos);
|
|
42
|
+
return node ? {
|
|
43
|
+
pos: target.pos,
|
|
44
|
+
node
|
|
45
|
+
} : null;
|
|
46
|
+
})();
|
|
47
|
+
return found && carriesProperties(found.node) ? found : null;
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* `meta` with `value` stored under `definition.key`: a number property converts a numeric string, an empty value (`''`,
|
|
51
|
+
* `null`, `undefined`, `NaN`) removes the key. A `multiselect` property keeps the string entries of an array value and
|
|
52
|
+
* removes the key when none is left. Returns a new object; `meta` is not changed.
|
|
53
|
+
*/
|
|
54
|
+
function metaWithProperty(meta, definition, value) {
|
|
55
|
+
const next = { ...meta };
|
|
56
|
+
if (definition.type === "multiselect") {
|
|
57
|
+
const chosen = Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
58
|
+
if (chosen.length) next[definition.key] = chosen;
|
|
59
|
+
else delete next[definition.key];
|
|
60
|
+
return next;
|
|
61
|
+
}
|
|
62
|
+
const stored = definition.type === "number" && typeof value === "string" && value !== "" ? Number(value) : value;
|
|
63
|
+
if (stored === "" || stored === null || stored === void 0 || Number.isNaN(stored)) delete next[definition.key];
|
|
64
|
+
else next[definition.key] = stored;
|
|
65
|
+
return next;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Stores `value` under the property `key` of the block `target` stands for (see `metaWithProperty`), in one transaction; a key
|
|
69
|
+
* the block's `definitions` do not define is written as text. False when the block is gone or carries no property values.
|
|
70
|
+
*/
|
|
71
|
+
function setBlockProperty(editor, target, key, value) {
|
|
72
|
+
const definition = target.definitions.find((candidate) => candidate.key === key) ?? {
|
|
73
|
+
key,
|
|
74
|
+
type: "text"
|
|
75
|
+
};
|
|
76
|
+
return editor.commands.command(({ tr }) => {
|
|
77
|
+
const found = propertyHostOf(tr.doc, target);
|
|
78
|
+
if (!found) return false;
|
|
79
|
+
tr.setNodeMarkup(found.pos, void 0, {
|
|
80
|
+
...found.node.attrs,
|
|
81
|
+
meta: metaWithProperty(found.node.attrs.meta ?? {}, definition, value)
|
|
82
|
+
});
|
|
83
|
+
return true;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
//#endregion
|
|
87
|
+
export { blockPropertiesAt, blockPropertiesOf, carriesProperties, metaWithProperty, propertyHostOf, setBlockProperty };
|
|
88
|
+
|
|
89
|
+
//# sourceMappingURL=properties.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"properties.js","names":[],"sources":["../../../src/features/composites/properties.ts"],"sourcesContent":["// Vue-free: Block properties as one mechanism. A block carries property values when its node type has the `meta` attribute; the\n// `properties` capability (`capabilities.ts`) says which of its Property definitions a block's type declares. Reading, resolving\n// and writing the values never ask for a node type name, so every node type that gains a `meta` attribute is covered.\nimport type { Editor } from '@tiptap/core'\nimport type { Node as PMNode, ResolvedPos } from '@tiptap/pm/model'\nimport { blockTypeIdOf, capabilitiesOf } from '../../core/capabilities'\nimport type { PropertyDefinition } from '../../core/properties'\nimport { blockIdOf, findBlockById } from '../../core/schema'\nimport { type BlockType, blockTypeOf, propertiesOf } from './block-types'\n\n/** Whether the node type has the `meta` attribute, where Block properties (and the bibliography, the basket, the derivation) are stored. This is what the `properties` capability's `appliesTo` asks of a node. */\nexport const carriesProperties = (node: PMNode): boolean => 'meta' in (node.type.spec.attrs ?? {})\n\n/** A block that carries property values, with the Property definitions its Block type declares and the values it holds. */\nexport interface BlockProperties {\n /** Block ID, or `pos:<pos>` for a block without one yet; unique within the document. */\n key: string\n id: string | null\n /** Position of the block when it was read; the write helpers re-resolve it, so a stale value is safe for blocks with an ID. */\n pos: number\n /** The values, as stored: `meta`. */\n meta: Record<string, unknown>\n /** The Property definitions of the block's Block type: empty without the `properties` capability; `bibliography` definitions drop out without the `bibliography` capability. */\n definitions: readonly PropertyDefinition[]\n}\n\n/**\n * The properties of `node` at `pos`, a node that carries property values (`carriesProperties`; its `meta` is read as the\n * values). `capabilities` is what `capabilitiesOf` answers for the node; `blockTypes` are the editor's Block types.\n */\nexport function blockPropertiesOf(node: PMNode, pos: number, blockTypes: readonly BlockType[], capabilities: ReadonlySet<string>): BlockProperties {\n const id = blockIdOf(node)\n const typeId = blockTypeIdOf(node)\n const definitions = typeId !== null && capabilities.has('properties')\n ? propertiesOf(blockTypeOf(blockTypes, typeId)).filter(field => field.type !== 'bibliography' || capabilities.has('bibliography'))\n : []\n return { key: id ?? `pos:${pos}`, id, pos, meta: (node.attrs.meta ?? {}) as Record<string, unknown>, definitions }\n}\n\n/**\n * The properties of the innermost block around `$pos` that carries property values (`carriesProperties`), with its node; null\n * when none does. A block of that kind whose type lacks the `properties` capability answers with no `definitions` rather than handing\n * the caret to an outer block. `blockTypes` are the editor's Block types.\n */\nexport function blockPropertiesAt(editor: Editor, $pos: ResolvedPos, blockTypes: readonly BlockType[]): { node: PMNode, properties: BlockProperties } | null {\n for (let depth = $pos.depth; depth > 0; depth--) {\n const node = $pos.node(depth)\n if (carriesProperties(node)) return { node, properties: blockPropertiesOf(node, $pos.before(depth), blockTypes, capabilitiesOf(editor, node)) }\n }\n return null\n}\n\n/** The block `target` stands for in `doc` and that carries property values: by block ID, else (no ID yet) by its position. Positions are re-resolved on every call. */\nexport function propertyHostOf(doc: PMNode, target: Pick<BlockProperties, 'id' | 'pos'>): { pos: number, node: PMNode } | null {\n const found = target.id ? findBlockById(doc, target.id) : (() => {\n const node = doc.nodeAt(target.pos)\n return node ? { pos: target.pos, node } : null\n })()\n return found && carriesProperties(found.node) ? found : null\n}\n\n/**\n * `meta` with `value` stored under `definition.key`: a number property converts a numeric string, an empty value (`''`,\n * `null`, `undefined`, `NaN`) removes the key. A `multiselect` property keeps the string entries of an array value and\n * removes the key when none is left. Returns a new object; `meta` is not changed.\n */\nexport function metaWithProperty(meta: Record<string, unknown>, definition: Pick<PropertyDefinition, 'key' | 'type'>, value: unknown): Record<string, unknown> {\n const next = { ...meta }\n if (definition.type === 'multiselect') {\n const chosen = Array.isArray(value) ? value.filter((item): item is string => typeof item === 'string') : []\n if (chosen.length) next[definition.key] = chosen\n else delete next[definition.key]\n return next\n }\n const stored = definition.type === 'number' && typeof value === 'string' && value !== '' ? Number(value) : value\n if (stored === '' || stored === null || stored === undefined || Number.isNaN(stored)) delete next[definition.key]\n else next[definition.key] = stored\n return next\n}\n\n/**\n * Stores `value` under the property `key` of the block `target` stands for (see `metaWithProperty`), in one transaction; a key\n * the block's `definitions` do not define is written as text. False when the block is gone or carries no property values.\n */\nexport function setBlockProperty(editor: Editor, target: Pick<BlockProperties, 'id' | 'pos' | 'definitions'>, key: string, value: unknown): boolean {\n const definition = target.definitions.find(candidate => candidate.key === key) ?? { key, type: 'text' as const }\n return editor.commands.command(({ tr }) => {\n const found = propertyHostOf(tr.doc, target)\n if (!found) return false\n tr.setNodeMarkup(found.pos, undefined, { ...found.node.attrs, meta: metaWithProperty(found.node.attrs.meta ?? {}, definition, value) })\n return true\n })\n}\n"],"mappings":";;;;;AAWA,MAAa,qBAAqB,SAA0B,WAAW,KAAK,KAAK,KAAK,SAAS,CAAC;;;;;AAmBhG,SAAgB,kBAAkB,MAAc,KAAa,YAAkC,cAAoD;CACjJ,MAAM,KAAK,UAAU,IAAI;CACzB,MAAM,SAAS,c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I;CAC3G,IAAI,WAAW,MAAM,WAAW,QAAQ,WAAW,KAAA,KAAa,OAAO,MAAM,MAAM,GAAG,OAAO,KAAK,WAAW;MACxG,KAAK,WAAW,OAAO;CAC5B,OAAO;AACT;;;;;AAMA,SAAgB,iBAAiB,QAAgB,QAA6D,KAAa,OAAyB;CAClJ,MAAM,aAAa,OAAO,YAAY,MAAK,cAAa,UAAU,QAAQ,GAAG,KAAK;EAAE;EAAK,MAAM;CAAgB;CAC/G,OAAO,OAAO,SAAS,SAAS,EAAE,SAAS;EACzC,MAAM,QAAQ,eAAe,GAAG,KAAK,MAAM;EAC3C,IAAI,CAAC,OAAO,OAAO;EACnB,GAAG,cAAc,MAAM,KAAK,KAAA,GAAW;GAAE,GAAG,MAAM,KAAK;GAAO,MAAM,iBAAiB,MAAM,KAAK,MAAM,QAAQ,CAAC,GAAG,YAAY,KAAK;EAAE,CAAC;EACtI,OAAO;CACT,CAAC;AACH"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { bibtexOf, cslOf, cslTypeOptions } from "../bibliography.js";
|
|
2
|
+
import { propertyHostOf, setBlockProperty } from "../properties.js";
|
|
2
3
|
import { useEditorI18n } from "../../../react/use-editor-i18n.js";
|
|
3
4
|
import { Icon } from "../../../react/Icon.js";
|
|
4
5
|
import { Button } from "../../../react/ui/button.js";
|
|
5
6
|
import { Input } from "../../../react/ui/input.js";
|
|
6
7
|
import { Textarea } from "../../../react/ui/textarea.js";
|
|
7
8
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "../../../react/ui/select.js";
|
|
8
|
-
import { compositeOfRow, setCompositeMetaField } from "../rows.js";
|
|
9
9
|
import { bibFormOf, bibItemOf } from "../bibliography-form.js";
|
|
10
10
|
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
11
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -51,7 +51,7 @@ const LINES = [
|
|
|
51
51
|
/**
|
|
52
52
|
* The structured editor of a `bibliography` field (CSL-JSON item, `meta.bib`): type, authors, year, container, volume,
|
|
53
53
|
* issue, pages, publisher, DOI, ISBN, URL and abstract. Inputs keep a local draft; every commit (blur, Enter, choosing
|
|
54
|
-
* a type, unmount, another row) writes the whole item through `
|
|
54
|
+
* a type, unmount, another row) writes the whole item through `setBlockProperty`. The title is the Typed block's and
|
|
55
55
|
* never stored.
|
|
56
56
|
*/
|
|
57
57
|
function BibliographyEditor({ editor, row, field, disabled }) {
|
|
@@ -87,7 +87,7 @@ function BibliographyEditor({ editor, row, field, disabled }) {
|
|
|
87
87
|
if (!dirty.current) return;
|
|
88
88
|
dirty.current = false;
|
|
89
89
|
const current = target.current;
|
|
90
|
-
if (!current.editor.isDestroyed)
|
|
90
|
+
if (!current.editor.isDestroyed) setBlockProperty(current.editor, current.row, current.field.key, bibItemOf(formRef.current, current.stored));
|
|
91
91
|
}, []);
|
|
92
92
|
useEffect(() => commit, [
|
|
93
93
|
commit,
|
|
@@ -114,7 +114,7 @@ function BibliographyEditor({ editor, row, field, disabled }) {
|
|
|
114
114
|
}
|
|
115
115
|
async function copyBibtex() {
|
|
116
116
|
commit();
|
|
117
|
-
const node =
|
|
117
|
+
const node = propertyHostOf(editor.state.doc, row)?.node;
|
|
118
118
|
const csl = node && cslOf(node);
|
|
119
119
|
if (!csl) return;
|
|
120
120
|
await navigator.clipboard.writeText(bibtexOf(csl));
|
|
@@ -124,7 +124,7 @@ function BibliographyEditor({ editor, row, field, disabled }) {
|
|
|
124
124
|
const hasDoi = form.doi.trim() !== "" || typeof row.meta.doi === "string" && row.meta.doi.trim() !== "";
|
|
125
125
|
function fetchByDoi() {
|
|
126
126
|
commit();
|
|
127
|
-
const found =
|
|
127
|
+
const found = propertyHostOf(editor.state.doc, row);
|
|
128
128
|
if (found) editor.commands.fetchCompositeBibliography(found.pos);
|
|
129
129
|
}
|
|
130
130
|
const typeOptions = useMemo(() => cslTypeOptions(t), [t]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BibliographyEditor.js","names":[],"sources":["../../../../src/features/composites/react/BibliographyEditor.tsx"],"sourcesContent":["import type { Editor } from '@tiptap/core'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { Icon } from '../../../react/Icon'\nimport { Button } from '../../../react/ui/button'\nimport { Input } from '../../../react/ui/input'\nimport { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../../../react/ui/select'\nimport { Textarea } from '../../../react/ui/textarea'\nimport { useEditorI18n } from '../../../react/use-editor-i18n'\nimport { bibtexOf, type CslItem, type CslType, cslOf, cslTypeOptions } from '../bibliography'\nimport { type BibForm, bibFormOf, bibItemOf } from '../bibliography-form'\nimport type { CompositeMetaField } from '../kinds'\nimport { compositeOfRow, type CompositeRow, setCompositeMetaField } from '../rows'\nimport '../bibliography-command'\n\nconst INPUT_CLASS = 'h-6 w-full px-2 text-xs md:text-xs'\nconst TEXTAREA_CLASS = 'max-h-[8.5rem] min-h-0 w-full px-2 py-1 text-xs md:text-xs'\n\nconst COUNTERS = [\n { key: 'volume', labelKey: 'composites.bib.field.volume' },\n { key: 'issue', labelKey: 'composites.bib.field.issue' },\n { key: 'page', labelKey: 'composites.bib.field.page' },\n] as const\nconst LINES = [\n { key: 'containerTitle', labelKey: 'composites.bib.field.containerTitle' },\n { key: 'publisher', labelKey: 'composites.bib.field.publisher' },\n { key: 'doi', labelKey: 'composites.bib.field.doi' },\n { key: 'isbn', labelKey: 'composites.bib.field.isbn' },\n { key: 'url', labelKey: 'composites.bib.field.url' },\n] as const\n\n/**\n * The structured editor of a `bibliography` field (CSL-JSON item, `meta.bib`): type, authors, year, container, volume,\n * issue, pages, publisher, DOI, ISBN, URL and abstract. Inputs keep a local draft; every commit (blur, Enter, choosing\n * a type, unmount, another row) writes the whole item through `setCompositeMetaField`. The title is the Baustein's and\n * never stored.\n */\nexport function BibliographyEditor({ editor, row, field, disabled }: {\n editor: Editor\n row: CompositeRow\n field: CompositeMetaField\n disabled?: boolean\n}) {\n const { t } = useEditorI18n()\n const value = row.meta[field.key] as Partial<CslItem> | null | undefined\n const stored = value && typeof value === 'object' && typeof value.type === 'string' ? value as CslItem : null\n const [form, setForm] = useState<BibForm>(() => bibFormOf(stored))\n const formRef = useRef(form)\n const dirty = useRef(false)\n const [copied, setCopied] = useState(false)\n // The latest props for the commit on unmount; updated after every render, so the cleanup of a changed `row.key` still sees the previous row.\n const target = useRef({ editor, row, field, stored })\n useEffect(() => {\n target.current = { editor, row, field, stored }\n })\n\n useEffect(() => {\n if (!dirty.current) {\n const next = bibFormOf(stored)\n formRef.current = next\n setForm(next)\n }\n }, [stored, row.key])\n\n const commit = useCallback(() => {\n if (!dirty.current) return\n dirty.current = false\n const current = target.current\n if (!current.editor.isDestroyed) setCompositeMetaField(current.editor, current.row, current.field.key, bibItemOf(formRef.current, current.stored))\n }, [])\n\n // Flush on unmount and when the editor is bound to another row.\n useEffect(() => commit, [commit, editor, row.key, field.key])\n\n useEffect(() => {\n if (!copied) return\n const timer = window.setTimeout(() => setCopied(false), 1500)\n return () => window.clearTimeout(timer)\n }, [copied])\n\n function onInput<K extends keyof BibForm>(key: K, next: BibForm[K]) {\n formRef.current = { ...formRef.current, [key]: next }\n setForm(formRef.current)\n dirty.current = true\n }\n\n function onType(next: string) {\n onInput('type', next as CslType)\n commit()\n }\n\n async function copyBibtex() {\n commit()\n const node = compositeOfRow(editor.state.doc, row)?.node\n const csl = node && cslOf(node)\n if (!csl) return\n await navigator.clipboard.writeText(bibtexOf(csl))\n setCopied(true)\n }\n\n // Registered by the AI integration (`composite-ai`); without it there is nothing to fetch with.\n const canFetch = typeof editor.commands.fetchCompositeBibliography === 'function'\n const hasDoi = form.doi.trim() !== '' || (typeof row.meta.doi === 'string' && row.meta.doi.trim() !== '')\n\n function fetchByDoi() {\n commit()\n const found = compositeOfRow(editor.state.doc, row)\n if (found) editor.commands.fetchCompositeBibliography(found.pos)\n }\n\n const typeOptions = useMemo(() => cslTypeOptions(t), [t])\n\n return (\n <div className=\"flex flex-col gap-1.5\">\n <Select value={form.type} onValueChange={onType} disabled={disabled}>\n <SelectTrigger size=\"sm\" className=\"w-full text-xs data-[size=sm]:h-6\" aria-label={t('composites.bib.field.type')}>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {typeOptions.map(option => (\n <SelectItem key={option.value} value={option.value}>{option.label}</SelectItem>\n ))}\n </SelectContent>\n </Select>\n <Textarea\n value={form.authors}\n placeholder={t('composites.bib.field.authorsHelp')}\n aria-label={t('composites.bib.field.authors')}\n disabled={disabled}\n rows={2}\n className={TEXTAREA_CLASS}\n onBlur={commit}\n onChange={event => onInput('authors', event.target.value)}\n />\n <div className=\"grid grid-cols-4 gap-1.5\">\n <Input\n value={form.year}\n type=\"number\"\n placeholder={t('composites.bib.field.year')}\n aria-label={t('composites.bib.field.year')}\n disabled={disabled}\n className={INPUT_CLASS}\n onBlur={commit}\n onKeyDown={(event) => {\n if (event.key === 'Enter') commit()\n }}\n onChange={event => onInput('year', event.target.value)}\n />\n {COUNTERS.map(input => (\n <Input\n key={input.key}\n value={form[input.key]}\n placeholder={t(input.labelKey)}\n aria-label={t(input.labelKey)}\n disabled={disabled}\n className={INPUT_CLASS}\n onBlur={commit}\n onKeyDown={(event) => {\n if (event.key === 'Enter') commit()\n }}\n onChange={event => onInput(input.key, event.target.value)}\n />\n ))}\n </div>\n {LINES.map(input => (\n <Input\n key={input.key}\n value={form[input.key]}\n placeholder={t(input.labelKey)}\n aria-label={t(input.labelKey)}\n disabled={disabled}\n className={INPUT_CLASS}\n onBlur={commit}\n onKeyDown={(event) => {\n if (event.key === 'Enter') commit()\n }}\n onChange={event => onInput(input.key, event.target.value)}\n />\n ))}\n <Textarea\n value={form.abstract}\n placeholder={t('composites.bib.field.abstract')}\n aria-label={t('composites.bib.field.abstract')}\n disabled={disabled}\n rows={2}\n className={TEXTAREA_CLASS}\n onBlur={commit}\n onChange={event => onInput('abstract', event.target.value)}\n />\n <div className=\"flex justify-end gap-1.5\">\n {canFetch && (\n <Button size=\"xs\" variant=\"ghost\" disabled={disabled || !hasDoi} onClick={fetchByDoi}>\n <Icon name=\"i-lucide-book-marked\" />\n {t('composites.bib.fetchDoi')}\n </Button>\n )}\n <Button size=\"xs\" variant=\"ghost\" disabled={!stored} onClick={() => void copyBibtex()}>\n <Icon name=\"i-lucide-copy\" />\n {copied ? t('composites.bib.copied') : t('composites.bib.copyBibtex')}\n </Button>\n </div>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;AAcA,MAAM,cAAc;AACpB,MAAM,iBAAiB;AAEvB,MAAM,WAAW;CACf;EAAE,KAAK;EAAU,UAAU;CAA8B;CACzD;EAAE,KAAK;EAAS,UAAU;CAA6B;CACvD;EAAE,KAAK;EAAQ,UAAU;CAA4B;AACvD;AACA,MAAM,QAAQ;CACZ;EAAE,KAAK;EAAkB,UAAU;CAAsC;CACzE;EAAE,KAAK;EAAa,UAAU;CAAiC;CAC/D;EAAE,KAAK;EAAO,UAAU;CAA2B;CACnD;EAAE,KAAK;EAAQ,UAAU;CAA4B;CACrD;EAAE,KAAK;EAAO,UAAU;CAA2B;AACrD;;;;;;;AAQA,SAAgB,mBAAmB,EAAE,QAAQ,KAAK,OAAO,YAKtD;CACD,MAAM,EAAE,MAAM,cAAc;CAC5B,MAAM,QAAQ,IAAI,KAAK,MAAM;CAC7B,MAAM,SAAS,SAAS,OAAO,UAAU,YAAY,OAAO,MAAM,SAAS,WAAW,QAAmB;CACzG,MAAM,CAAC,MAAM,WAAW,eAAwB,UAAU,MAAM,CAAC;CACjE,MAAM,UAAU,OAAO,IAAI;CAC3B,MAAM,QAAQ,OAAO,KAAK;CAC1B,MAAM,CAAC,QAAQ,aAAa,SAAS,KAAK;CAE1C,MAAM,SAAS,OAAO;EAAE;EAAQ;EAAK;EAAO;CAAO,CAAC;CACpD,gBAAgB;EACd,OAAO,UAAU;GAAE;GAAQ;GAAK;GAAO;EAAO;CAChD,CAAC;CAED,gBAAgB;EACd,IAAI,CAAC,MAAM,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AAO;KACpC;KACA,WAAU,UAAS,QAAQ,MAAM,KAAK,MAAM,OAAO,KAAK;IACzD,GAXM,MAAM,GAWZ,CACF,CACE;;GACJ,MAAM,KAAI,UACT,oBAAC,OAAD;IAEE,OAAO,KAAK,MAAM;IAClB,aAAa,EAAE,MAAM,QAAQ;IAC7B,cAAY,EAAE,MAAM,QAAQ;IAClB;IACV,WAAW;IACX,QAAQ;IACR,YAAY,UAAU;KACpB,IAAI,MAAM,QAAQ,SAAS,OAAO;IACpC;IACA,WAAU,UAAS,QAAQ,MAAM,KAAK,MAAM,OAAO,KAAK;GACzD,GAXM,MAAM,GAWZ,CACF;GACD,oBAAC,UAAD;IACE,OAAO,KAAK;IACZ,aAAa,EAAE,+BAA+B;IAC9C,cAAY,EAAE,+BAA+B;IACnC;IACV,MAAM;IACN,WAAW;IACX,QAAQ;IACR,WAAU,UAAS,QAAQ,YAAY,MAAM,OAAO,KAAK;GAC1D,CAAA;GACD,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACG,YACC,qBAAC,QAAD;KAAQ,MAAK;KAAK,SAAQ;KAAQ,UAAU,YAAY,CAAC;KAAQ,SAAS;KAA1E,UAAA,CACE,oBAAC,MAAD,EAAM,MAAK,uBAAwB,CAAA,GAClC,EAAE,yBAAyB,CACtB;IAEV,CAAA,GAAA,qBAAC,QAAD;KAAQ,MAAK;KAAK,SAAQ;KAAQ,UAAU,CAAC;KAAQ,eAAe,KAAK,WAAW;KAApF,UAAA,CACE,oBAAC,MAAD,EAAM,MAAK,gBAAiB,CAAA,GAC3B,SAAS,EAAE,uBAAuB,IAAI,EAAE,2BAA2B,CAC9D;IACL,CAAA,CAAA;;EACF;;AAET"}
|
|
1
|
+
{"version":3,"file":"BibliographyEditor.js","names":[],"sources":["../../../../src/features/composites/react/BibliographyEditor.tsx"],"sourcesContent":["import type { Editor } from '@tiptap/core'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { Icon } from '../../../react/Icon'\nimport { Button } from '../../../react/ui/button'\nimport { Input } from '../../../react/ui/input'\nimport { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../../../react/ui/select'\nimport { Textarea } from '../../../react/ui/textarea'\nimport { useEditorI18n } from '../../../react/use-editor-i18n'\nimport { bibtexOf, type CslItem, type CslType, cslOf, cslTypeOptions } from '../bibliography'\nimport { type BibForm, bibFormOf, bibItemOf } from '../bibliography-form'\nimport type { PropertyDefinition } from '../../../core/properties'\nimport { type BlockProperties, propertyHostOf, setBlockProperty } from '../properties'\nimport '../bibliography-command'\n\nconst INPUT_CLASS = 'h-6 w-full px-2 text-xs md:text-xs'\nconst TEXTAREA_CLASS = 'max-h-[8.5rem] min-h-0 w-full px-2 py-1 text-xs md:text-xs'\n\nconst COUNTERS = [\n { key: 'volume', labelKey: 'composites.bib.field.volume' },\n { key: 'issue', labelKey: 'composites.bib.field.issue' },\n { key: 'page', labelKey: 'composites.bib.field.page' },\n] as const\nconst LINES = [\n { key: 'containerTitle', labelKey: 'composites.bib.field.containerTitle' },\n { key: 'publisher', labelKey: 'composites.bib.field.publisher' },\n { key: 'doi', labelKey: 'composites.bib.field.doi' },\n { key: 'isbn', labelKey: 'composites.bib.field.isbn' },\n { key: 'url', labelKey: 'composites.bib.field.url' },\n] as const\n\n/**\n * The structured editor of a `bibliography` field (CSL-JSON item, `meta.bib`): type, authors, year, container, volume,\n * issue, pages, publisher, DOI, ISBN, URL and abstract. Inputs keep a local draft; every commit (blur, Enter, choosing\n * a type, unmount, another row) writes the whole item through `setBlockProperty`. The title is the Typed block's and\n * never stored.\n */\nexport function BibliographyEditor({ editor, row, field, disabled }: {\n editor: Editor\n row: BlockProperties\n field: PropertyDefinition\n disabled?: boolean\n}) {\n const { t } = useEditorI18n()\n const value = row.meta[field.key] as Partial<CslItem> | null | undefined\n const stored = value && typeof value === 'object' && typeof value.type === 'string' ? value as CslItem : null\n const [form, setForm] = useState<BibForm>(() => bibFormOf(stored))\n const formRef = useRef(form)\n const dirty = useRef(false)\n const [copied, setCopied] = useState(false)\n // The latest props for the commit on unmount; updated after every render, so the cleanup of a changed `row.key` still sees the previous row.\n const target = useRef({ editor, row, field, stored })\n useEffect(() => {\n target.current = { editor, row, field, stored }\n })\n\n useEffect(() => {\n if (!dirty.current) {\n const next = bibFormOf(stored)\n formRef.current = next\n setForm(next)\n }\n }, [stored, row.key])\n\n const commit = useCallback(() => {\n if (!dirty.current) return\n dirty.current = false\n const current = target.current\n if (!current.editor.isDestroyed) setBlockProperty(current.editor, current.row, current.field.key, bibItemOf(formRef.current, current.stored))\n }, [])\n\n // Flush on unmount and when the editor is bound to another row.\n useEffect(() => commit, [commit, editor, row.key, field.key])\n\n useEffect(() => {\n if (!copied) return\n const timer = window.setTimeout(() => setCopied(false), 1500)\n return () => window.clearTimeout(timer)\n }, [copied])\n\n function onInput<K extends keyof BibForm>(key: K, next: BibForm[K]) {\n formRef.current = { ...formRef.current, [key]: next }\n setForm(formRef.current)\n dirty.current = true\n }\n\n function onType(next: string) {\n onInput('type', next as CslType)\n commit()\n }\n\n async function copyBibtex() {\n commit()\n const node = propertyHostOf(editor.state.doc, row)?.node\n const csl = node && cslOf(node)\n if (!csl) return\n await navigator.clipboard.writeText(bibtexOf(csl))\n setCopied(true)\n }\n\n // Registered by the AI integration (`composite-ai`); without it there is nothing to fetch with.\n const canFetch = typeof editor.commands.fetchCompositeBibliography === 'function'\n const hasDoi = form.doi.trim() !== '' || (typeof row.meta.doi === 'string' && row.meta.doi.trim() !== '')\n\n function fetchByDoi() {\n commit()\n const found = propertyHostOf(editor.state.doc, row)\n if (found) editor.commands.fetchCompositeBibliography(found.pos)\n }\n\n const typeOptions = useMemo(() => cslTypeOptions(t), [t])\n\n return (\n <div className=\"flex flex-col gap-1.5\">\n <Select value={form.type} onValueChange={onType} disabled={disabled}>\n <SelectTrigger size=\"sm\" className=\"w-full text-xs data-[size=sm]:h-6\" aria-label={t('composites.bib.field.type')}>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {typeOptions.map(option => (\n <SelectItem key={option.value} value={option.value}>{option.label}</SelectItem>\n ))}\n </SelectContent>\n </Select>\n <Textarea\n value={form.authors}\n placeholder={t('composites.bib.field.authorsHelp')}\n aria-label={t('composites.bib.field.authors')}\n disabled={disabled}\n rows={2}\n className={TEXTAREA_CLASS}\n onBlur={commit}\n onChange={event => onInput('authors', event.target.value)}\n />\n <div className=\"grid grid-cols-4 gap-1.5\">\n <Input\n value={form.year}\n type=\"number\"\n placeholder={t('composites.bib.field.year')}\n aria-label={t('composites.bib.field.year')}\n disabled={disabled}\n className={INPUT_CLASS}\n onBlur={commit}\n onKeyDown={(event) => {\n if (event.key === 'Enter') commit()\n }}\n onChange={event => onInput('year', event.target.value)}\n />\n {COUNTERS.map(input => (\n <Input\n key={input.key}\n value={form[input.key]}\n placeholder={t(input.labelKey)}\n aria-label={t(input.labelKey)}\n disabled={disabled}\n className={INPUT_CLASS}\n onBlur={commit}\n onKeyDown={(event) => {\n if (event.key === 'Enter') commit()\n }}\n onChange={event => onInput(input.key, event.target.value)}\n />\n ))}\n </div>\n {LINES.map(input => (\n <Input\n key={input.key}\n value={form[input.key]}\n placeholder={t(input.labelKey)}\n aria-label={t(input.labelKey)}\n disabled={disabled}\n className={INPUT_CLASS}\n onBlur={commit}\n onKeyDown={(event) => {\n if (event.key === 'Enter') commit()\n }}\n onChange={event => onInput(input.key, event.target.value)}\n />\n ))}\n <Textarea\n value={form.abstract}\n placeholder={t('composites.bib.field.abstract')}\n aria-label={t('composites.bib.field.abstract')}\n disabled={disabled}\n rows={2}\n className={TEXTAREA_CLASS}\n onBlur={commit}\n onChange={event => onInput('abstract', event.target.value)}\n />\n <div className=\"flex justify-end gap-1.5\">\n {canFetch && (\n <Button size=\"xs\" variant=\"ghost\" disabled={disabled || !hasDoi} onClick={fetchByDoi}>\n <Icon name=\"i-lucide-book-marked\" />\n {t('composites.bib.fetchDoi')}\n </Button>\n )}\n <Button size=\"xs\" variant=\"ghost\" disabled={!stored} onClick={()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a,EAAE,MAAM,QAAQ;IAC7B,cAAY,EAAE,MAAM,QAAQ;IAClB;IACV,WAAW;IACX,QAAQ;IACR,YAAY,UAAU;KACpB,IAAI,MAAM,QAAQ,SAAS,OAAO;IACpC;IACA,WAAU,UAAS,QAAQ,MAAM,KAAK,MAAM,OAAO,KAAK;GACzD,GAXM,MAAM,GAWZ,CACF;GACD,oBAAC,UAAD;IACE,OAAO,KAAK;IACZ,aAAa,EAAE,+BAA+B;IAC9C,cAAY,EAAE,+BAA+B;IACnC;IACV,MAAM;IACN,WAAW;IACX,QAAQ;IACR,WAAU,UAAS,QAAQ,YAAY,MAAM,OAAO,KAAK;GAC1D,CAAA;GACD,qBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACG,YACC,qBAAC,QAAD;KAAQ,MAAK;KAAK,SAAQ;KAAQ,UAAU,YAAY,CAAC;KAAQ,SAAS;KAA1E,UAAA,CACE,oBAAC,MAAD,EAAM,MAAK,uBAAwB,CAAA,GAClC,EAAE,yBAAyB,CACtB;IAEV,CAAA,GAAA,qBAAC,QAAD;KAAQ,MAAK;KAAK,SAAQ;KAAQ,UAAU,CAAC;KAAQ,eAAe,KAAK,WAAW;KAApF,UAAA,CACE,oBAAC,MAAD,EAAM,MAAK,gBAAiB,CAAA,GAC3B,SAAS,EAAE,uBAAuB,IAAI,EAAE,2BAA2B,CAC9D;IACL,CAAA,CAAA;;EACF;;AAET"}
|
|
@@ -9,8 +9,8 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
9
9
|
//#region src/features/composites/react/CompositeBasketMenu.tsx
|
|
10
10
|
const OPTION = "flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm text-foreground transition-colors duration-150 hover:bg-muted focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary";
|
|
11
11
|
/**
|
|
12
|
-
* Basket choice of a
|
|
13
|
-
* and its label) and „
|
|
12
|
+
* Basket choice of a Typed block: the child (a button) opens a list of the editor's baskets (a dot in the basket's colour
|
|
13
|
+
* and its label) and a „none“ entry. The menu is a popover, not a dropdown menu: a dropdown item cannot show a dot in an
|
|
14
14
|
* arbitrary CSS colour.
|
|
15
15
|
*/
|
|
16
16
|
function CompositeBasketMenu({ editor, row, children }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompositeBasketMenu.js","names":[],"sources":["../../../../src/features/composites/react/CompositeBasketMenu.tsx"],"sourcesContent":["import type { Editor } from '@tiptap/core'\nimport { type ReactNode, useState } from 'react'\nimport { Icon } from '../../../react/Icon'\nimport { Popover, PopoverContent, PopoverTrigger } from '../../../react/ui/popover'\nimport { useEditorI18n } from '../../../react/use-editor-i18n'\nimport { basketOf } from '../baskets'\nimport { compositeBasketsOf } from '../nodes'\nimport { compositeOfRow, type CompositeRow } from '../rows'\n\nconst OPTION = 'flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm text-foreground transition-colors duration-150 hover:bg-muted focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary'\n\n/**\n * Basket choice of a
|
|
1
|
+
{"version":3,"file":"CompositeBasketMenu.js","names":[],"sources":["../../../../src/features/composites/react/CompositeBasketMenu.tsx"],"sourcesContent":["import type { Editor } from '@tiptap/core'\nimport { type ReactNode, useState } from 'react'\nimport { Icon } from '../../../react/Icon'\nimport { Popover, PopoverContent, PopoverTrigger } from '../../../react/ui/popover'\nimport { useEditorI18n } from '../../../react/use-editor-i18n'\nimport { basketOf } from '../baskets'\nimport { compositeBasketsOf } from '../nodes'\nimport { compositeOfRow, type CompositeRow } from '../rows'\n\nconst OPTION = 'flex w-full items-center gap-2 rounded-sm px-2 py-1.5 text-left text-sm text-foreground transition-colors duration-150 hover:bg-muted focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary'\n\n/**\n * Basket choice of a Typed block: the child (a button) opens a list of the editor's baskets (a dot in the basket's colour\n * and its label) and a „none“ entry. The menu is a popover, not a dropdown menu: a dropdown item cannot show a dot in an\n * arbitrary CSS colour.\n */\nexport function CompositeBasketMenu({ editor, row, children }: { editor: Editor, row: CompositeRow, children: ReactNode }) {\n const { t } = useEditorI18n()\n const [open, setOpen] = useState(false)\n\n const current = basketOf(row)\n\n function choose(next: string | null) {\n setOpen(false)\n const found = compositeOfRow(editor.state.doc, row)\n if (found) editor.commands.setCompositeBasket(next, found.pos)\n }\n\n return (\n <Popover open={open} onOpenChange={setOpen}>\n <PopoverTrigger asChild>{children}</PopoverTrigger>\n <PopoverContent\n side=\"bottom\"\n align=\"start\"\n sideOffset={4}\n className=\"w-40 gap-0 p-1\"\n onCloseAutoFocus={event => event.preventDefault()}\n >\n <div role=\"menu\" aria-label={t('composites.basket.label')}>\n {compositeBasketsOf(editor).map(candidate => (\n <button\n key={candidate.id}\n type=\"button\"\n role=\"menuitemradio\"\n aria-checked={current === candidate.id}\n className={OPTION}\n onClick={() => choose(candidate.id)}\n >\n <span className=\"size-2.5 shrink-0 rounded-full\" style={{ backgroundColor: candidate.color }} />\n <span className=\"truncate\">{candidate.label}</span>\n {current === candidate.id && <Icon name=\"i-lucide-check\" className=\"ml-auto size-3.5 shrink-0\" />}\n </button>\n ))}\n <button type=\"button\" role=\"menuitemradio\" aria-checked={current === null} className={OPTION} onClick={() => choose(null)}>\n <Icon name=\"i-lucide-circle-dashed\" className=\"size-3 shrink-0 text-muted-foreground\" />\n <span className=\"truncate\">{t('composites.basket.none')}</span>\n {current === null && <Icon name=\"i-lucide-check\" className=\"ml-auto size-3.5 shrink-0\" />}\n </button>\n </div>\n </PopoverContent>\n </Popover>\n )\n}\n"],"mappings":";;;;;;;;;AASA,MAAM,SAAS;;;;;;AAOf,SAAgB,oBAAoB,EAAE,QAAQ,KAAK,YAAwE;CACzH,MAAM,EAAE,MAAM,cAAc;CAC5B,MAAM,CAAC,MAAM,WAAW,SAAS,KAAK;CAEtC,MAAM,UAAU,SAAS,GAAG;CAE5B,SAAS,OAAO,MAAqB;EACnC,QAAQ,KAAK;EACb,MAAM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ag (with a `+` chip to add tags), and on the front the kind icon. The icon is a button that
|
|
6
6
|
* opens the details popover (kind with a confirmation before it changes, the kind's fields and the summary;
|
|
7
7
|
* `CompositeDetails`) and, in an editable editor, the composite's drag handle: dragging it moves the composite
|
|
8
|
-
* (`startBlockDrag`). With `blocks.
|
|
8
|
+
* (`startBlockDrag`). With `blocks.blockTypeIcon: 'hover'` it shows only while the composite is hovered, its popover is
|
|
9
9
|
* open or the icon has keyboard focus. Chips and popover also render in read-only editors, without edit affordances.
|
|
10
10
|
* The node view's own description and tags rows are hidden by CSS; this overlay shows and edits them.
|
|
11
11
|
*/
|