@agent-native/core 0.37.3 → 0.39.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/README.md +19 -6
- package/dist/action.d.ts +60 -2
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js +6 -2
- package/dist/action.js.map +1 -1
- package/dist/agent/production-agent.d.ts +12 -6
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +161 -11
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/types.d.ts +2 -0
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/catalog.json +2 -2
- package/dist/cli/connect.d.ts.map +1 -1
- package/dist/cli/connect.js +15 -0
- package/dist/cli/connect.js.map +1 -1
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +8 -1
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/index.js +10 -6
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/plan-publish-store.d.ts +52 -0
- package/dist/cli/plan-publish-store.d.ts.map +1 -0
- package/dist/cli/plan-publish-store.js +103 -0
- package/dist/cli/plan-publish-store.js.map +1 -0
- package/dist/cli/skills.d.ts +30 -4
- package/dist/cli/skills.d.ts.map +1 -1
- package/dist/cli/skills.js +1240 -339
- package/dist/cli/skills.js.map +1 -1
- package/dist/cli/templates-meta.js +12 -12
- package/dist/cli/templates-meta.js.map +1 -1
- package/dist/client/AssistantChat.d.ts +3 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +65 -15
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/client/MultiTabAssistantChat.js +20 -2
- package/dist/client/MultiTabAssistantChat.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +12 -0
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/agent-engine-key.d.ts +24 -0
- package/dist/client/agent-engine-key.d.ts.map +1 -0
- package/dist/client/agent-engine-key.js +49 -0
- package/dist/client/agent-engine-key.js.map +1 -0
- package/dist/client/analytics.d.ts.map +1 -1
- package/dist/client/analytics.js +34 -0
- package/dist/client/analytics.js.map +1 -1
- package/dist/client/blocks/BlockView.d.ts +35 -0
- package/dist/client/blocks/BlockView.d.ts.map +1 -0
- package/dist/client/blocks/BlockView.js +45 -0
- package/dist/client/blocks/BlockView.js.map +1 -0
- package/dist/client/blocks/SchemaBlockEditor.d.ts +25 -0
- package/dist/client/blocks/SchemaBlockEditor.d.ts.map +1 -0
- package/dist/client/blocks/SchemaBlockEditor.js +165 -0
- package/dist/client/blocks/SchemaBlockEditor.js.map +1 -0
- package/dist/client/blocks/agent.d.ts +30 -0
- package/dist/client/blocks/agent.d.ts.map +1 -0
- package/dist/client/blocks/agent.js +61 -0
- package/dist/client/blocks/agent.js.map +1 -0
- package/dist/client/blocks/index.d.ts +51 -0
- package/dist/client/blocks/index.d.ts.map +1 -0
- package/dist/client/blocks/index.js +67 -0
- package/dist/client/blocks/index.js.map +1 -0
- package/dist/client/blocks/library/AnnotatedCodeBlock.d.ts +6 -0
- package/dist/client/blocks/library/AnnotatedCodeBlock.d.ts.map +1 -0
- package/dist/client/blocks/library/AnnotatedCodeBlock.js +135 -0
- package/dist/client/blocks/library/AnnotatedCodeBlock.js.map +1 -0
- package/dist/client/blocks/library/ApiEndpointBlock.d.ts +20 -0
- package/dist/client/blocks/library/ApiEndpointBlock.d.ts.map +1 -0
- package/dist/client/blocks/library/ApiEndpointBlock.js +131 -0
- package/dist/client/blocks/library/ApiEndpointBlock.js.map +1 -0
- package/dist/client/blocks/library/DataModelBlock.d.ts +28 -0
- package/dist/client/blocks/library/DataModelBlock.d.ts.map +1 -0
- package/dist/client/blocks/library/DataModelBlock.js +222 -0
- package/dist/client/blocks/library/DataModelBlock.js.map +1 -0
- package/dist/client/blocks/library/DiffBlock.d.ts +6 -0
- package/dist/client/blocks/library/DiffBlock.d.ts.map +1 -0
- package/dist/client/blocks/library/DiffBlock.js +293 -0
- package/dist/client/blocks/library/DiffBlock.js.map +1 -0
- package/dist/client/blocks/library/FileTreeBlock.d.ts +23 -0
- package/dist/client/blocks/library/FileTreeBlock.d.ts.map +1 -0
- package/dist/client/blocks/library/FileTreeBlock.js +225 -0
- package/dist/client/blocks/library/FileTreeBlock.js.map +1 -0
- package/dist/client/blocks/library/JsonExplorerBlock.d.ts +19 -0
- package/dist/client/blocks/library/JsonExplorerBlock.d.ts.map +1 -0
- package/dist/client/blocks/library/JsonExplorerBlock.js +171 -0
- package/dist/client/blocks/library/JsonExplorerBlock.js.map +1 -0
- package/dist/client/blocks/library/MermaidBlock.d.ts +17 -0
- package/dist/client/blocks/library/MermaidBlock.d.ts.map +1 -0
- package/dist/client/blocks/library/MermaidBlock.js +131 -0
- package/dist/client/blocks/library/MermaidBlock.js.map +1 -0
- package/dist/client/blocks/library/OpenApiSpecBlock.d.ts +19 -0
- package/dist/client/blocks/library/OpenApiSpecBlock.d.ts.map +1 -0
- package/dist/client/blocks/library/OpenApiSpecBlock.js +494 -0
- package/dist/client/blocks/library/OpenApiSpecBlock.js.map +1 -0
- package/dist/client/blocks/library/annotated-code.config.d.ts +58 -0
- package/dist/client/blocks/library/annotated-code.config.d.ts.map +1 -0
- package/dist/client/blocks/library/annotated-code.config.js +53 -0
- package/dist/client/blocks/library/annotated-code.config.js.map +1 -0
- package/dist/client/blocks/library/api-endpoint.config.d.ts +71 -0
- package/dist/client/blocks/library/api-endpoint.config.d.ts.map +1 -0
- package/dist/client/blocks/library/api-endpoint.config.js +91 -0
- package/dist/client/blocks/library/api-endpoint.config.js.map +1 -0
- package/dist/client/blocks/library/checklist.config.d.ts +36 -0
- package/dist/client/blocks/library/checklist.config.d.ts.map +1 -0
- package/dist/client/blocks/library/checklist.config.js +25 -0
- package/dist/client/blocks/library/checklist.config.js.map +1 -0
- package/dist/client/blocks/library/checklist.d.ts +26 -0
- package/dist/client/blocks/library/checklist.d.ts.map +1 -0
- package/dist/client/blocks/library/checklist.js +78 -0
- package/dist/client/blocks/library/checklist.js.map +1 -0
- package/dist/client/blocks/library/code-tabs.config.d.ts +36 -0
- package/dist/client/blocks/library/code-tabs.config.d.ts.map +1 -0
- package/dist/client/blocks/library/code-tabs.config.js +30 -0
- package/dist/client/blocks/library/code-tabs.config.js.map +1 -0
- package/dist/client/blocks/library/code-tabs.d.ts +3 -0
- package/dist/client/blocks/library/code-tabs.d.ts.map +1 -0
- package/dist/client/blocks/library/code-tabs.js +165 -0
- package/dist/client/blocks/library/code-tabs.js.map +1 -0
- package/dist/client/blocks/library/data-model.config.d.ts +72 -0
- package/dist/client/blocks/library/data-model.config.d.ts.map +1 -0
- package/dist/client/blocks/library/data-model.config.js +59 -0
- package/dist/client/blocks/library/data-model.config.js.map +1 -0
- package/dist/client/blocks/library/dev-doc-ui.d.ts +49 -0
- package/dist/client/blocks/library/dev-doc-ui.d.ts.map +1 -0
- package/dist/client/blocks/library/dev-doc-ui.js +50 -0
- package/dist/client/blocks/library/dev-doc-ui.js.map +1 -0
- package/dist/client/blocks/library/diff.config.d.ts +41 -0
- package/dist/client/blocks/library/diff.config.d.ts.map +1 -0
- package/dist/client/blocks/library/diff.config.js +34 -0
- package/dist/client/blocks/library/diff.config.js.map +1 -0
- package/dist/client/blocks/library/file-tree.config.d.ts +59 -0
- package/dist/client/blocks/library/file-tree.config.d.ts.map +1 -0
- package/dist/client/blocks/library/file-tree.config.js +45 -0
- package/dist/client/blocks/library/file-tree.config.js.map +1 -0
- package/dist/client/blocks/library/html.config.d.ts +37 -0
- package/dist/client/blocks/library/html.config.d.ts.map +1 -0
- package/dist/client/blocks/library/html.config.js +46 -0
- package/dist/client/blocks/library/html.config.js.map +1 -0
- package/dist/client/blocks/library/html.d.ts +21 -0
- package/dist/client/blocks/library/html.d.ts.map +1 -0
- package/dist/client/blocks/library/html.js +72 -0
- package/dist/client/blocks/library/html.js.map +1 -0
- package/dist/client/blocks/library/json-explorer.config.d.ts +46 -0
- package/dist/client/blocks/library/json-explorer.config.d.ts.map +1 -0
- package/dist/client/blocks/library/json-explorer.config.js +28 -0
- package/dist/client/blocks/library/json-explorer.config.js.map +1 -0
- package/dist/client/blocks/library/mermaid.config.d.ts +32 -0
- package/dist/client/blocks/library/mermaid.config.d.ts.map +1 -0
- package/dist/client/blocks/library/mermaid.config.js +24 -0
- package/dist/client/blocks/library/mermaid.config.js.map +1 -0
- package/dist/client/blocks/library/openapi-spec.config.d.ts +49 -0
- package/dist/client/blocks/library/openapi-spec.config.d.ts.map +1 -0
- package/dist/client/blocks/library/openapi-spec.config.js +24 -0
- package/dist/client/blocks/library/openapi-spec.config.js.map +1 -0
- package/dist/client/blocks/library/server-specs.d.ts +35 -0
- package/dist/client/blocks/library/server-specs.d.ts.map +1 -0
- package/dist/client/blocks/library/server-specs.js +171 -0
- package/dist/client/blocks/library/server-specs.js.map +1 -0
- package/dist/client/blocks/library/specs.d.ts +29 -0
- package/dist/client/blocks/library/specs.d.ts.map +1 -0
- package/dist/client/blocks/library/specs.js +229 -0
- package/dist/client/blocks/library/specs.js.map +1 -0
- package/dist/client/blocks/library/table.config.d.ts +30 -0
- package/dist/client/blocks/library/table.config.d.ts.map +1 -0
- package/dist/client/blocks/library/table.config.js +22 -0
- package/dist/client/blocks/library/table.config.js.map +1 -0
- package/dist/client/blocks/library/table.d.ts +8 -0
- package/dist/client/blocks/library/table.d.ts.map +1 -0
- package/dist/client/blocks/library/table.js +109 -0
- package/dist/client/blocks/library/table.js.map +1 -0
- package/dist/client/blocks/library/tabs.config.d.ts +56 -0
- package/dist/client/blocks/library/tabs.config.d.ts.map +1 -0
- package/dist/client/blocks/library/tabs.config.js +36 -0
- package/dist/client/blocks/library/tabs.config.js.map +1 -0
- package/dist/client/blocks/library/tabs.d.ts +20 -0
- package/dist/client/blocks/library/tabs.d.ts.map +1 -0
- package/dist/client/blocks/library/tabs.js +123 -0
- package/dist/client/blocks/library/tabs.js.map +1 -0
- package/dist/client/blocks/mdx.d.ts +74 -0
- package/dist/client/blocks/mdx.d.ts.map +1 -0
- package/dist/client/blocks/mdx.js +205 -0
- package/dist/client/blocks/mdx.js.map +1 -0
- package/dist/client/blocks/provider.d.ts +25 -0
- package/dist/client/blocks/provider.d.ts.map +1 -0
- package/dist/client/blocks/provider.js +19 -0
- package/dist/client/blocks/provider.js.map +1 -0
- package/dist/client/blocks/registry.d.ts +32 -0
- package/dist/client/blocks/registry.d.ts.map +1 -0
- package/dist/client/blocks/registry.js +65 -0
- package/dist/client/blocks/registry.js.map +1 -0
- package/dist/client/blocks/schema-form/introspect.d.ts +31 -0
- package/dist/client/blocks/schema-form/introspect.d.ts.map +1 -0
- package/dist/client/blocks/schema-form/introspect.js +164 -0
- package/dist/client/blocks/schema-form/introspect.js.map +1 -0
- package/dist/client/blocks/server.d.ts +31 -0
- package/dist/client/blocks/server.d.ts.map +1 -0
- package/dist/client/blocks/server.js +41 -0
- package/dist/client/blocks/server.js.map +1 -0
- package/dist/client/blocks/types.d.ts +252 -0
- package/dist/client/blocks/types.d.ts.map +1 -0
- package/dist/client/blocks/types.js +5 -0
- package/dist/client/blocks/types.js.map +1 -0
- package/dist/client/composer/ComposerPlusMenu.js +10 -1
- package/dist/client/composer/ComposerPlusMenu.js.map +1 -1
- package/dist/client/guided-questions.d.ts +68 -0
- package/dist/client/guided-questions.d.ts.map +1 -1
- package/dist/client/guided-questions.js +158 -3
- package/dist/client/guided-questions.js.map +1 -1
- package/dist/client/index.d.ts +6 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +24 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/rich-markdown-editor/BubbleToolbar.d.ts +37 -0
- package/dist/client/rich-markdown-editor/BubbleToolbar.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/BubbleToolbar.js +161 -0
- package/dist/client/rich-markdown-editor/BubbleToolbar.js.map +1 -0
- package/dist/client/rich-markdown-editor/DragHandle.d.ts +52 -0
- package/dist/client/rich-markdown-editor/DragHandle.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/DragHandle.js +403 -0
- package/dist/client/rich-markdown-editor/DragHandle.js.map +1 -0
- package/dist/client/rich-markdown-editor/ImageExtension.d.ts +63 -0
- package/dist/client/rich-markdown-editor/ImageExtension.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/ImageExtension.js +242 -0
- package/dist/client/rich-markdown-editor/ImageExtension.js.map +1 -0
- package/dist/client/rich-markdown-editor/RegistryBlockNode.d.ts +97 -0
- package/dist/client/rich-markdown-editor/RegistryBlockNode.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/RegistryBlockNode.js +214 -0
- package/dist/client/rich-markdown-editor/RegistryBlockNode.js.map +1 -0
- package/dist/client/rich-markdown-editor/RichMarkdownEditor.d.ts +51 -0
- package/dist/client/rich-markdown-editor/RichMarkdownEditor.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/RichMarkdownEditor.js +37 -0
- package/dist/client/rich-markdown-editor/RichMarkdownEditor.js.map +1 -0
- package/dist/client/rich-markdown-editor/RunId.d.ts +28 -0
- package/dist/client/rich-markdown-editor/RunId.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/RunId.js +60 -0
- package/dist/client/rich-markdown-editor/RunId.js.map +1 -0
- package/dist/client/rich-markdown-editor/SharedRichEditor.d.ts +85 -0
- package/dist/client/rich-markdown-editor/SharedRichEditor.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/SharedRichEditor.js +130 -0
- package/dist/client/rich-markdown-editor/SharedRichEditor.js.map +1 -0
- package/dist/client/rich-markdown-editor/SlashCommandMenu.d.ts +36 -0
- package/dist/client/rich-markdown-editor/SlashCommandMenu.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/SlashCommandMenu.js +193 -0
- package/dist/client/rich-markdown-editor/SlashCommandMenu.js.map +1 -0
- package/dist/client/rich-markdown-editor/extensions.d.ts +166 -0
- package/dist/client/rich-markdown-editor/extensions.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/extensions.js +222 -0
- package/dist/client/rich-markdown-editor/extensions.js.map +1 -0
- package/dist/client/rich-markdown-editor/gfmDoc.d.ts +24 -0
- package/dist/client/rich-markdown-editor/gfmDoc.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/gfmDoc.js +83 -0
- package/dist/client/rich-markdown-editor/gfmDoc.js.map +1 -0
- package/dist/client/rich-markdown-editor/index.d.ts +14 -0
- package/dist/client/rich-markdown-editor/index.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/index.js +14 -0
- package/dist/client/rich-markdown-editor/index.js.map +1 -0
- package/dist/client/rich-markdown-editor/registrySlashCommands.d.ts +46 -0
- package/dist/client/rich-markdown-editor/registrySlashCommands.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/registrySlashCommands.js +13 -0
- package/dist/client/rich-markdown-editor/registrySlashCommands.js.map +1 -0
- package/dist/client/rich-markdown-editor/uploadEditorImage.d.ts +18 -0
- package/dist/client/rich-markdown-editor/uploadEditorImage.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/uploadEditorImage.js +57 -0
- package/dist/client/rich-markdown-editor/uploadEditorImage.js.map +1 -0
- package/dist/client/rich-markdown-editor/useCollabReconcile.d.ts +91 -0
- package/dist/client/rich-markdown-editor/useCollabReconcile.d.ts.map +1 -0
- package/dist/client/rich-markdown-editor/useCollabReconcile.js +375 -0
- package/dist/client/rich-markdown-editor/useCollabReconcile.js.map +1 -0
- package/dist/client/track.d.ts +25 -0
- package/dist/client/track.d.ts.map +1 -0
- package/dist/client/track.js +53 -0
- package/dist/client/track.js.map +1 -0
- package/dist/client/use-action.d.ts.map +1 -1
- package/dist/client/use-action.js +6 -0
- package/dist/client/use-action.js.map +1 -1
- package/dist/client/use-session.d.ts +3 -2
- package/dist/client/use-session.d.ts.map +1 -1
- package/dist/client/use-session.js +3 -2
- package/dist/client/use-session.js.map +1 -1
- package/dist/deploy/build.d.ts +5 -0
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +67 -1
- package/dist/deploy/build.js.map +1 -1
- package/dist/extensions/schema.d.ts +1 -1
- package/dist/mcp/build-server.d.ts.map +1 -1
- package/dist/mcp/build-server.js +9 -2
- package/dist/mcp/build-server.js.map +1 -1
- package/dist/mcp/server.d.ts +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +35 -2
- package/dist/mcp/server.js.map +1 -1
- package/dist/provider-api/index.d.ts +1 -1
- package/dist/provider-api/index.d.ts.map +1 -1
- package/dist/scripts/docs/search.d.ts.map +1 -1
- package/dist/scripts/docs/search.js +5 -2
- package/dist/scripts/docs/search.js.map +1 -1
- package/dist/scripts/runner.d.ts.map +1 -1
- package/dist/scripts/runner.js +16 -3
- package/dist/scripts/runner.js.map +1 -1
- package/dist/server/action-discovery.d.ts.map +1 -1
- package/dist/server/action-discovery.js +2 -0
- package/dist/server/action-discovery.js.map +1 -1
- package/dist/server/action-routes.d.ts.map +1 -1
- package/dist/server/action-routes.js +30 -4
- package/dist/server/action-routes.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +65 -19
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agent-teams.d.ts.map +1 -1
- package/dist/server/agent-teams.js +8 -1
- package/dist/server/agent-teams.js.map +1 -1
- package/dist/server/agents-bundle.d.ts +27 -1
- package/dist/server/agents-bundle.d.ts.map +1 -1
- package/dist/server/agents-bundle.js +41 -3
- package/dist/server/agents-bundle.js.map +1 -1
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +76 -3
- package/dist/server/auth.js.map +1 -1
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +60 -0
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/onboarding-html.d.ts.map +1 -1
- package/dist/server/onboarding-html.js +160 -22
- package/dist/server/onboarding-html.js.map +1 -1
- package/dist/server/sentry.d.ts.map +1 -1
- package/dist/server/sentry.js +6 -0
- package/dist/server/sentry.js.map +1 -1
- package/dist/server/social-og-image.d.ts +2 -1
- package/dist/server/social-og-image.d.ts.map +1 -1
- package/dist/server/social-og-image.js +24 -4
- package/dist/server/social-og-image.js.map +1 -1
- package/dist/sharing/schema.d.ts +1 -1
- package/dist/styles/agent-native.css +1 -0
- package/dist/styles/rich-markdown-editor.css +439 -0
- package/dist/templates/default/.agents/skills/actions/SKILL.md +4 -1
- package/dist/templates/default/.agents/skills/security/SKILL.md +13 -4
- package/dist/templates/default/.agents/skills/storing-data/SKILL.md +15 -3
- package/dist/templates/default/AGENTS.md +1 -0
- package/dist/templates/default/DEVELOPING.md +2 -0
- package/dist/templates/workspace-core/.agents/skills/a2a-protocol/SKILL.md +10 -3
- package/dist/templates/workspace-core/.agents/skills/actions/SKILL.md +98 -10
- package/dist/templates/workspace-core/.agents/skills/adding-a-feature/SKILL.md +45 -3
- package/dist/templates/workspace-core/.agents/skills/address-feedback/SKILL.md +2 -0
- package/dist/templates/workspace-core/.agents/skills/authentication/SKILL.md +37 -4
- package/dist/templates/workspace-core/.agents/skills/automations/SKILL.md +9 -4
- package/dist/templates/workspace-core/.agents/skills/capture-learnings/SKILL.md +2 -0
- package/dist/templates/workspace-core/.agents/skills/client-methods/SKILL.md +106 -0
- package/dist/templates/workspace-core/.agents/skills/client-methods/references/legacy-client-fetch-audit-2026-06-03.md +53 -0
- package/dist/templates/workspace-core/.agents/skills/client-side-routing/SKILL.md +2 -0
- package/dist/templates/workspace-core/.agents/skills/context-awareness/SKILL.md +62 -61
- package/dist/templates/workspace-core/.agents/skills/context-xray/SKILL.md +47 -0
- package/dist/templates/workspace-core/.agents/skills/create-skill/SKILL.md +28 -0
- package/dist/templates/workspace-core/.agents/skills/delegate-to-agent/SKILL.md +52 -1
- package/dist/templates/workspace-core/.agents/skills/extension-points/SKILL.md +2 -0
- package/dist/templates/workspace-core/.agents/skills/extensions/SKILL.md +95 -433
- package/dist/templates/workspace-core/.agents/skills/extensions/references/api.md +285 -0
- package/dist/templates/workspace-core/.agents/skills/extensions/references/examples.md +259 -0
- package/dist/templates/workspace-core/.agents/skills/external-agents/SKILL.md +398 -0
- package/dist/templates/workspace-core/.agents/skills/external-agents/references/mcp-apps-embedding.md +157 -0
- package/dist/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +17 -0
- package/dist/templates/workspace-core/.agents/skills/integration-webhooks/SKILL.md +13 -2
- package/dist/templates/workspace-core/.agents/skills/mvp-followup/SKILL.md +51 -0
- package/dist/templates/workspace-core/.agents/skills/observability/SKILL.md +14 -4
- package/dist/templates/workspace-core/.agents/skills/onboarding/SKILL.md +13 -1
- package/dist/templates/workspace-core/.agents/skills/portability/SKILL.md +27 -5
- package/dist/templates/workspace-core/.agents/skills/qa/SKILL.md +24 -8
- package/dist/templates/workspace-core/.agents/skills/real-time-collab/SKILL.md +53 -7
- package/dist/templates/workspace-core/.agents/skills/real-time-sync/SKILL.md +43 -10
- package/dist/templates/workspace-core/.agents/skills/recurring-jobs/SKILL.md +2 -0
- package/dist/templates/workspace-core/.agents/skills/secrets/SKILL.md +43 -14
- package/dist/templates/workspace-core/.agents/skills/security/SKILL.md +50 -1
- package/dist/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +4 -2
- package/dist/templates/workspace-core/.agents/skills/server-plugins/SKILL.md +11 -1
- package/dist/templates/workspace-core/.agents/skills/shadcn-ui/SKILL.md +15 -0
- package/dist/templates/workspace-core/.agents/skills/sharing/SKILL.md +5 -1
- package/dist/templates/workspace-core/.agents/skills/storing-data/SKILL.md +48 -19
- package/dist/templates/workspace-core/.agents/skills/tracking/SKILL.md +7 -3
- package/dist/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +13 -6
- package/dist/templates/workspace-core/.agents/skills/writing-agent-instructions/SKILL.md +236 -0
- package/dist/templates/workspace-core/AGENTS.md +5 -1
- package/dist/templates/workspace-root/AGENTS.md +5 -2
- package/dist/tracking/route.d.ts +43 -0
- package/dist/tracking/route.d.ts.map +1 -0
- package/dist/tracking/route.js +85 -0
- package/dist/tracking/route.js.map +1 -0
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +15 -0
- package/dist/vite/client.js.map +1 -1
- package/docs/content/a2a-protocol.md +18 -4
- package/docs/content/actions.md +87 -0
- package/docs/content/agent-mentions.md +2 -1
- package/docs/content/authentication.md +2 -1
- package/docs/content/client.md +64 -13
- package/docs/content/cloneable-saas.md +1 -1
- package/docs/content/code-agents-ui.md +17 -11
- package/docs/content/context-awareness.md +23 -28
- package/docs/content/creating-templates.md +1 -1
- package/docs/content/drop-in-agent.md +2 -0
- package/docs/content/getting-started.md +2 -2
- package/docs/content/key-concepts.md +2 -2
- package/docs/content/messaging.md +57 -15
- package/docs/content/migration-workbench.md +1 -1
- package/docs/content/multi-app-workspace.md +1 -1
- package/docs/content/multi-tenancy.md +17 -15
- package/docs/content/real-time-collaboration.md +1 -1
- package/docs/content/recurring-jobs.md +1 -1
- package/docs/content/security.md +2 -2
- package/docs/content/server.md +4 -4
- package/docs/content/skills-guide.md +30 -0
- package/docs/content/template-analytics.md +2 -2
- package/docs/content/template-assets.md +17 -1
- package/docs/content/template-brain.md +2 -2
- package/docs/content/template-calendar.md +1 -1
- package/docs/content/template-clips.md +3 -3
- package/docs/content/template-content.md +2 -2
- package/docs/content/template-design.md +2 -2
- package/docs/content/template-dispatch.md +3 -3
- package/docs/content/template-forms.md +14 -2
- package/docs/content/template-mail.md +1 -3
- package/docs/content/template-plan.md +133 -0
- package/docs/content/template-slides.md +5 -4
- package/docs/content/template-starter.md +4 -4
- package/docs/content/template-videos.md +6 -11
- package/docs/content/tracking.md +21 -1
- package/docs/content/visual-plans.md +74 -0
- package/docs/content/workspace.md +9 -9
- package/package.json +26 -11
- package/src/templates/default/.agents/skills/actions/SKILL.md +4 -1
- package/src/templates/default/.agents/skills/security/SKILL.md +13 -4
- package/src/templates/default/.agents/skills/storing-data/SKILL.md +15 -3
- package/src/templates/default/AGENTS.md +1 -0
- package/src/templates/default/DEVELOPING.md +2 -0
- package/src/templates/workspace-core/.agents/skills/a2a-protocol/SKILL.md +10 -3
- package/src/templates/workspace-core/.agents/skills/actions/SKILL.md +98 -10
- package/src/templates/workspace-core/.agents/skills/adding-a-feature/SKILL.md +45 -3
- package/src/templates/workspace-core/.agents/skills/address-feedback/SKILL.md +2 -0
- package/src/templates/workspace-core/.agents/skills/authentication/SKILL.md +37 -4
- package/src/templates/workspace-core/.agents/skills/automations/SKILL.md +9 -4
- package/src/templates/workspace-core/.agents/skills/capture-learnings/SKILL.md +2 -0
- package/src/templates/workspace-core/.agents/skills/client-methods/SKILL.md +106 -0
- package/src/templates/workspace-core/.agents/skills/client-methods/references/legacy-client-fetch-audit-2026-06-03.md +53 -0
- package/src/templates/workspace-core/.agents/skills/client-side-routing/SKILL.md +2 -0
- package/src/templates/workspace-core/.agents/skills/context-awareness/SKILL.md +62 -61
- package/src/templates/workspace-core/.agents/skills/context-xray/SKILL.md +47 -0
- package/src/templates/workspace-core/.agents/skills/create-skill/SKILL.md +28 -0
- package/src/templates/workspace-core/.agents/skills/delegate-to-agent/SKILL.md +52 -1
- package/src/templates/workspace-core/.agents/skills/extension-points/SKILL.md +2 -0
- package/src/templates/workspace-core/.agents/skills/extensions/SKILL.md +95 -433
- package/src/templates/workspace-core/.agents/skills/extensions/references/api.md +285 -0
- package/src/templates/workspace-core/.agents/skills/extensions/references/examples.md +259 -0
- package/src/templates/workspace-core/.agents/skills/external-agents/SKILL.md +398 -0
- package/src/templates/workspace-core/.agents/skills/external-agents/references/mcp-apps-embedding.md +157 -0
- package/src/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +17 -0
- package/src/templates/workspace-core/.agents/skills/integration-webhooks/SKILL.md +13 -2
- package/src/templates/workspace-core/.agents/skills/mvp-followup/SKILL.md +51 -0
- package/src/templates/workspace-core/.agents/skills/observability/SKILL.md +14 -4
- package/src/templates/workspace-core/.agents/skills/onboarding/SKILL.md +13 -1
- package/src/templates/workspace-core/.agents/skills/portability/SKILL.md +27 -5
- package/src/templates/workspace-core/.agents/skills/qa/SKILL.md +24 -8
- package/src/templates/workspace-core/.agents/skills/real-time-collab/SKILL.md +53 -7
- package/src/templates/workspace-core/.agents/skills/real-time-sync/SKILL.md +43 -10
- package/src/templates/workspace-core/.agents/skills/recurring-jobs/SKILL.md +2 -0
- package/src/templates/workspace-core/.agents/skills/secrets/SKILL.md +43 -14
- package/src/templates/workspace-core/.agents/skills/security/SKILL.md +50 -1
- package/src/templates/workspace-core/.agents/skills/self-modifying-code/SKILL.md +4 -2
- package/src/templates/workspace-core/.agents/skills/server-plugins/SKILL.md +11 -1
- package/src/templates/workspace-core/.agents/skills/shadcn-ui/SKILL.md +15 -0
- package/src/templates/workspace-core/.agents/skills/sharing/SKILL.md +5 -1
- package/src/templates/workspace-core/.agents/skills/storing-data/SKILL.md +48 -19
- package/src/templates/workspace-core/.agents/skills/tracking/SKILL.md +7 -3
- package/src/templates/workspace-core/.agents/skills/voice-transcription/SKILL.md +13 -6
- package/src/templates/workspace-core/.agents/skills/writing-agent-instructions/SKILL.md +236 -0
- package/src/templates/workspace-core/AGENTS.md +5 -1
- package/src/templates/workspace-root/AGENTS.md +5 -2
|
@@ -0,0 +1,403 @@
|
|
|
1
|
+
import { Extension } from "@tiptap/core";
|
|
2
|
+
import { Plugin, PluginKey, NodeSelection } from "@tiptap/pm/state";
|
|
3
|
+
/**
|
|
4
|
+
* Default editor-wrapper CSS selector the drag handle scopes itself to.
|
|
5
|
+
*
|
|
6
|
+
* The handle, the drop indicator, and the `position: relative` anchor are all
|
|
7
|
+
* appended to / measured against the closest ancestor matching this selector.
|
|
8
|
+
* Content's editor wraps its ProseMirror DOM in a `.visual-editor-wrapper`
|
|
9
|
+
* element, so that is the historical default. Other apps (e.g. the plan editor)
|
|
10
|
+
* pass their own wrapper selector via {@link DragHandleOptions.wrapperSelector}.
|
|
11
|
+
*/
|
|
12
|
+
export const DEFAULT_DRAG_HANDLE_WRAPPER_SELECTOR = ".visual-editor-wrapper";
|
|
13
|
+
const dragHandleKey = new PluginKey("dragHandle");
|
|
14
|
+
const HOVER_SIDE_OUTSET_REM = 8;
|
|
15
|
+
/**
|
|
16
|
+
* App-agnostic Tiptap extension providing a Notion-style left-margin drag grip
|
|
17
|
+
* (the `::` handle), block selection, and drag-to-reorder over top-level block
|
|
18
|
+
* nodes.
|
|
19
|
+
*
|
|
20
|
+
* Behavior:
|
|
21
|
+
* - On hover over any top-level block, a `.drag-handle` grip appears in the left
|
|
22
|
+
* margin (forgiving hit zone extends {@link HOVER_SIDE_OUTSET_REM}rem to the
|
|
23
|
+
* sides and into the gap above/between blocks).
|
|
24
|
+
* - `mousedown` on the grip selects the block as a `NodeSelection`; dragging past
|
|
25
|
+
* a small threshold starts a reorder, showing a floating clone preview
|
|
26
|
+
* (`.notion-drag-preview`) and a `.notion-drop-indicator` line. `Escape`
|
|
27
|
+
* cancels.
|
|
28
|
+
* - While dragging, the source block carries `.notion-block--dragging` and the
|
|
29
|
+
* document element carries `.notion-editor-is-dragging` so apps can style the
|
|
30
|
+
* in-flight state. Apps own all of these CSS class names.
|
|
31
|
+
* - Works for ANY top-level node ProseMirror renders as a direct child of the
|
|
32
|
+
* editor — including `group: "block"`, `draggable: true` atoms such as the
|
|
33
|
+
* plan editor's `planBlock`.
|
|
34
|
+
*
|
|
35
|
+
* The only app-specific coupling — the editor wrapper element the handle and
|
|
36
|
+
* drop indicator are anchored to — is configurable via
|
|
37
|
+
* {@link DragHandleOptions.wrapperSelector}, defaulting to
|
|
38
|
+
* {@link DEFAULT_DRAG_HANDLE_WRAPPER_SELECTOR} (`.visual-editor-wrapper`) so the
|
|
39
|
+
* Content editor keeps working byte-identically. The plan editor passes its own
|
|
40
|
+
* wrapper selector via `DragHandle.configure({ wrapperSelector })`.
|
|
41
|
+
*/
|
|
42
|
+
export const DragHandle = Extension.create({
|
|
43
|
+
name: "dragHandle",
|
|
44
|
+
addOptions() {
|
|
45
|
+
return {
|
|
46
|
+
wrapperSelector: DEFAULT_DRAG_HANDLE_WRAPPER_SELECTOR,
|
|
47
|
+
};
|
|
48
|
+
},
|
|
49
|
+
addProseMirrorPlugins() {
|
|
50
|
+
const editor = this.editor;
|
|
51
|
+
const wrapperSelector = this.options.wrapperSelector;
|
|
52
|
+
let handle = null;
|
|
53
|
+
let currentBlock = null;
|
|
54
|
+
let dragStartPos = null;
|
|
55
|
+
let dragSession = null;
|
|
56
|
+
const getHoverSideOutset = () => {
|
|
57
|
+
const rootFontSize = Number.parseFloat(getComputedStyle(document.documentElement).fontSize);
|
|
58
|
+
return ((Number.isFinite(rootFontSize) ? rootFontSize : 16) *
|
|
59
|
+
HOVER_SIDE_OUTSET_REM);
|
|
60
|
+
};
|
|
61
|
+
const getTopLevelBlocks = (editorView) => {
|
|
62
|
+
const blocks = [];
|
|
63
|
+
editorView.state.doc.forEach((_node, offset) => {
|
|
64
|
+
const dom = editorView.nodeDOM(offset);
|
|
65
|
+
if (!(dom instanceof HTMLElement))
|
|
66
|
+
return;
|
|
67
|
+
blocks.push({
|
|
68
|
+
node: dom,
|
|
69
|
+
pmPos: offset,
|
|
70
|
+
rect: dom.getBoundingClientRect(),
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
return blocks;
|
|
74
|
+
};
|
|
75
|
+
const findForgivingBlock = (editorView, clientX, clientY) => {
|
|
76
|
+
const blocks = getTopLevelBlocks(editorView);
|
|
77
|
+
if (blocks.length === 0)
|
|
78
|
+
return null;
|
|
79
|
+
const sideOutset = getHoverSideOutset();
|
|
80
|
+
const pageLeft = 0;
|
|
81
|
+
const pageRight = window.visualViewport?.width ?? window.innerWidth;
|
|
82
|
+
for (let index = 0; index < blocks.length; index++) {
|
|
83
|
+
const block = blocks[index];
|
|
84
|
+
const nextBlock = blocks[index + 1];
|
|
85
|
+
const blockBottomGap = nextBlock
|
|
86
|
+
? Math.max(0, nextBlock.rect.top - block.rect.bottom)
|
|
87
|
+
: 0;
|
|
88
|
+
const zoneLeft = Math.max(pageLeft, block.rect.left - sideOutset);
|
|
89
|
+
const zoneRight = Math.min(pageRight, block.rect.right + sideOutset);
|
|
90
|
+
const zoneTop = index === 0
|
|
91
|
+
? Math.max(0, block.rect.top - blockBottomGap)
|
|
92
|
+
: block.rect.top;
|
|
93
|
+
const zoneBottom = nextBlock ? nextBlock.rect.top : block.rect.bottom;
|
|
94
|
+
if (clientX >= zoneLeft &&
|
|
95
|
+
clientX <= zoneRight &&
|
|
96
|
+
clientY >= zoneTop &&
|
|
97
|
+
clientY < zoneBottom) {
|
|
98
|
+
return block;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
};
|
|
103
|
+
const showHandleForBlock = (editorView, block) => {
|
|
104
|
+
if (!handle)
|
|
105
|
+
return;
|
|
106
|
+
currentBlock = block.node;
|
|
107
|
+
dragStartPos = block.pmPos;
|
|
108
|
+
const wrapper = editorView.dom.closest(wrapperSelector);
|
|
109
|
+
if (!wrapper)
|
|
110
|
+
return;
|
|
111
|
+
// Lazily (re)attach the grip the first time a wrapper is actually
|
|
112
|
+
// available. At plugin `view()` init the editor DOM may not yet be mounted
|
|
113
|
+
// inside the wrapper (React mounts `EditorContent` after the EditorView is
|
|
114
|
+
// constructed), so the init-time append can silently no-op and leave the
|
|
115
|
+
// grip orphaned. Re-home it here once the wrapper exists.
|
|
116
|
+
if (handle.parentElement !== wrapper) {
|
|
117
|
+
wrapper.style.position = "relative";
|
|
118
|
+
wrapper.appendChild(handle);
|
|
119
|
+
}
|
|
120
|
+
const wrapperRect = wrapper.getBoundingClientRect();
|
|
121
|
+
handle.style.display = "flex";
|
|
122
|
+
handle.style.top = `${block.rect.top - wrapperRect.top + 2}px`;
|
|
123
|
+
handle.style.left = "-24px";
|
|
124
|
+
};
|
|
125
|
+
const selectCurrentBlock = (editorView) => {
|
|
126
|
+
if (dragStartPos === null)
|
|
127
|
+
return null;
|
|
128
|
+
try {
|
|
129
|
+
const sel = NodeSelection.create(editorView.state.doc, dragStartPos);
|
|
130
|
+
editorView.dispatch(editorView.state.tr.setSelection(sel));
|
|
131
|
+
editorView.focus();
|
|
132
|
+
return sel;
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
const cleanupDragVisuals = () => {
|
|
139
|
+
dragSession?.preview?.remove();
|
|
140
|
+
dragSession?.dropLine?.remove();
|
|
141
|
+
dragSession?.sourceBlock.classList.remove("notion-block--dragging");
|
|
142
|
+
document.documentElement.classList.remove("notion-editor-is-dragging");
|
|
143
|
+
};
|
|
144
|
+
const createDragPreview = (block) => {
|
|
145
|
+
const blockRect = block.getBoundingClientRect();
|
|
146
|
+
const preview = document.createElement("div");
|
|
147
|
+
const clone = block.cloneNode(true);
|
|
148
|
+
clone.classList.remove("ProseMirror-selectednode", "notion-block--dragging");
|
|
149
|
+
clone.removeAttribute("contenteditable");
|
|
150
|
+
clone.style.background = "transparent";
|
|
151
|
+
clone.style.backgroundColor = "transparent";
|
|
152
|
+
clone.querySelectorAll("[contenteditable]").forEach((node) => {
|
|
153
|
+
node.removeAttribute("contenteditable");
|
|
154
|
+
});
|
|
155
|
+
clone.querySelectorAll("*").forEach((node) => {
|
|
156
|
+
node.style.background = "transparent";
|
|
157
|
+
node.style.backgroundColor = "transparent";
|
|
158
|
+
});
|
|
159
|
+
preview.className = "notion-drag-preview";
|
|
160
|
+
preview.style.width = `${blockRect.width}px`;
|
|
161
|
+
preview.appendChild(clone);
|
|
162
|
+
document.body.appendChild(preview);
|
|
163
|
+
return preview;
|
|
164
|
+
};
|
|
165
|
+
const createDropLine = (view) => {
|
|
166
|
+
const wrapper = view.dom.closest(wrapperSelector);
|
|
167
|
+
if (!wrapper)
|
|
168
|
+
return null;
|
|
169
|
+
const line = document.createElement("div");
|
|
170
|
+
line.className = "notion-drop-indicator";
|
|
171
|
+
wrapper.appendChild(line);
|
|
172
|
+
return line;
|
|
173
|
+
};
|
|
174
|
+
const findDropTarget = (view, clientX, clientY) => {
|
|
175
|
+
const block = findForgivingBlock(view, clientX, clientY);
|
|
176
|
+
if (!block)
|
|
177
|
+
return null;
|
|
178
|
+
const node = view.state.doc.nodeAt(block.pmPos);
|
|
179
|
+
if (!node)
|
|
180
|
+
return null;
|
|
181
|
+
const dropBefore = clientY < block.rect.top ||
|
|
182
|
+
(clientY <= block.rect.bottom &&
|
|
183
|
+
clientY < block.rect.top + block.rect.height / 2);
|
|
184
|
+
return {
|
|
185
|
+
block: block.node,
|
|
186
|
+
before: dropBefore,
|
|
187
|
+
pos: dropBefore ? block.pmPos : block.pmPos + node.nodeSize,
|
|
188
|
+
rect: block.rect,
|
|
189
|
+
};
|
|
190
|
+
};
|
|
191
|
+
const positionDragPreview = (session, clientX, clientY) => {
|
|
192
|
+
if (!session.preview)
|
|
193
|
+
return;
|
|
194
|
+
session.preview.style.transform = `translate3d(${clientX + 12}px, ${clientY + 10}px, 0)`;
|
|
195
|
+
};
|
|
196
|
+
const updateDropLine = (session, target) => {
|
|
197
|
+
const sourceEnd = session.sourcePos + session.sourceNodeSize;
|
|
198
|
+
if (!target ||
|
|
199
|
+
target.pos === session.sourcePos ||
|
|
200
|
+
target.pos === sourceEnd ||
|
|
201
|
+
(target.pos > session.sourcePos && target.pos < sourceEnd)) {
|
|
202
|
+
session.dropPos = null;
|
|
203
|
+
session.dropLine?.remove();
|
|
204
|
+
session.dropLine = null;
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (!session.dropLine)
|
|
208
|
+
session.dropLine = createDropLine(session.view);
|
|
209
|
+
if (!session.dropLine)
|
|
210
|
+
return;
|
|
211
|
+
const wrapper = session.view.dom.closest(wrapperSelector);
|
|
212
|
+
if (!wrapper)
|
|
213
|
+
return;
|
|
214
|
+
const wrapperRect = wrapper.getBoundingClientRect();
|
|
215
|
+
const editorRect = session.view.dom.getBoundingClientRect();
|
|
216
|
+
const top = target.before ? target.rect.top : target.rect.bottom;
|
|
217
|
+
session.dropPos = target.pos;
|
|
218
|
+
session.dropLine.style.left = `${editorRect.left - wrapperRect.left}px`;
|
|
219
|
+
session.dropLine.style.top = `${top - wrapperRect.top}px`;
|
|
220
|
+
session.dropLine.style.width = `${editorRect.width}px`;
|
|
221
|
+
};
|
|
222
|
+
const createHandle = () => {
|
|
223
|
+
const el = document.createElement("div");
|
|
224
|
+
el.className = "drag-handle";
|
|
225
|
+
el.contentEditable = "false";
|
|
226
|
+
el.draggable = false;
|
|
227
|
+
el.innerHTML = `<svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor">
|
|
228
|
+
<circle cx="5.5" cy="3" r="1.5"/><circle cx="10.5" cy="3" r="1.5"/>
|
|
229
|
+
<circle cx="5.5" cy="8" r="1.5"/><circle cx="10.5" cy="8" r="1.5"/>
|
|
230
|
+
<circle cx="5.5" cy="13" r="1.5"/><circle cx="10.5" cy="13" r="1.5"/>
|
|
231
|
+
</svg>`;
|
|
232
|
+
return el;
|
|
233
|
+
};
|
|
234
|
+
const hideHandle = () => {
|
|
235
|
+
if (handle)
|
|
236
|
+
handle.style.display = "none";
|
|
237
|
+
currentBlock = null;
|
|
238
|
+
};
|
|
239
|
+
const removeDragListeners = () => {
|
|
240
|
+
document.removeEventListener("mousemove", handleDocumentMouseMove);
|
|
241
|
+
document.removeEventListener("mouseup", handleDocumentMouseUp);
|
|
242
|
+
document.removeEventListener("keydown", handleDocumentKeyDown);
|
|
243
|
+
};
|
|
244
|
+
const createDocumentHoverMove = (editorView) => {
|
|
245
|
+
return (event) => {
|
|
246
|
+
if (!handle || dragSession)
|
|
247
|
+
return;
|
|
248
|
+
if (!editor.isEditable) {
|
|
249
|
+
hideHandle();
|
|
250
|
+
return;
|
|
251
|
+
}
|
|
252
|
+
const block = findForgivingBlock(editorView, event.clientX, event.clientY);
|
|
253
|
+
if (!block) {
|
|
254
|
+
hideHandle();
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
showHandleForBlock(editorView, block);
|
|
258
|
+
};
|
|
259
|
+
};
|
|
260
|
+
const finishDragSession = (commit) => {
|
|
261
|
+
const session = dragSession;
|
|
262
|
+
if (!session)
|
|
263
|
+
return;
|
|
264
|
+
removeDragListeners();
|
|
265
|
+
if (commit && session.dragging && session.dropPos !== null) {
|
|
266
|
+
const sourceStart = session.sourcePos;
|
|
267
|
+
const sourceEnd = session.sourcePos + session.sourceNodeSize;
|
|
268
|
+
const dropPos = session.dropPos;
|
|
269
|
+
if (dropPos !== sourceStart &&
|
|
270
|
+
dropPos !== sourceEnd &&
|
|
271
|
+
!(dropPos > sourceStart && dropPos < sourceEnd)) {
|
|
272
|
+
const sourceNode = session.view.state.doc.nodeAt(sourceStart);
|
|
273
|
+
if (sourceNode) {
|
|
274
|
+
const insertPos = dropPos > sourceStart ? dropPos - sourceNode.nodeSize : dropPos;
|
|
275
|
+
const tr = session.view.state.tr
|
|
276
|
+
.delete(sourceStart, sourceEnd)
|
|
277
|
+
.insert(insertPos, sourceNode);
|
|
278
|
+
tr.setSelection(NodeSelection.create(tr.doc, insertPos));
|
|
279
|
+
session.view.dispatch(tr.scrollIntoView());
|
|
280
|
+
session.view.focus();
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
else if (!session.dragging) {
|
|
285
|
+
selectCurrentBlock(session.view);
|
|
286
|
+
}
|
|
287
|
+
cleanupDragVisuals();
|
|
288
|
+
dragSession = null;
|
|
289
|
+
hideHandle();
|
|
290
|
+
};
|
|
291
|
+
const beginDragSession = (session, event) => {
|
|
292
|
+
session.dragging = true;
|
|
293
|
+
session.preview = createDragPreview(session.sourceBlock);
|
|
294
|
+
session.sourceBlock.classList.add("notion-block--dragging");
|
|
295
|
+
document.documentElement.classList.add("notion-editor-is-dragging");
|
|
296
|
+
positionDragPreview(session, event.clientX, event.clientY);
|
|
297
|
+
updateDropLine(session, findDropTarget(session.view, event.clientX, event.clientY));
|
|
298
|
+
};
|
|
299
|
+
function handleDocumentMouseMove(event) {
|
|
300
|
+
if (!dragSession)
|
|
301
|
+
return;
|
|
302
|
+
event.preventDefault();
|
|
303
|
+
const movedEnough = Math.hypot(event.clientX - dragSession.startX, event.clientY - dragSession.startY) > 4;
|
|
304
|
+
if (!dragSession.dragging && movedEnough) {
|
|
305
|
+
beginDragSession(dragSession, event);
|
|
306
|
+
}
|
|
307
|
+
if (!dragSession.dragging)
|
|
308
|
+
return;
|
|
309
|
+
positionDragPreview(dragSession, event.clientX, event.clientY);
|
|
310
|
+
updateDropLine(dragSession, findDropTarget(dragSession.view, event.clientX, event.clientY));
|
|
311
|
+
}
|
|
312
|
+
function handleDocumentMouseUp(event) {
|
|
313
|
+
event.preventDefault();
|
|
314
|
+
finishDragSession(true);
|
|
315
|
+
}
|
|
316
|
+
function handleDocumentKeyDown(event) {
|
|
317
|
+
if (event.key !== "Escape")
|
|
318
|
+
return;
|
|
319
|
+
event.preventDefault();
|
|
320
|
+
finishDragSession(false);
|
|
321
|
+
}
|
|
322
|
+
return [
|
|
323
|
+
new Plugin({
|
|
324
|
+
key: dragHandleKey,
|
|
325
|
+
view(editorView) {
|
|
326
|
+
handle = createHandle();
|
|
327
|
+
const handleDocumentHoverMove = createDocumentHoverMove(editorView);
|
|
328
|
+
const wrapper = editorView.dom.closest(wrapperSelector);
|
|
329
|
+
if (wrapper) {
|
|
330
|
+
wrapper.style.position = "relative";
|
|
331
|
+
wrapper.appendChild(handle);
|
|
332
|
+
}
|
|
333
|
+
document.addEventListener("mousemove", handleDocumentHoverMove);
|
|
334
|
+
handle.addEventListener("mousedown", (e) => {
|
|
335
|
+
e.stopPropagation();
|
|
336
|
+
if (!editor.isEditable) {
|
|
337
|
+
e.preventDefault();
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
if (!currentBlock || dragStartPos === null)
|
|
341
|
+
return;
|
|
342
|
+
const sourceNode = editorView.state.doc.nodeAt(dragStartPos);
|
|
343
|
+
if (!sourceNode)
|
|
344
|
+
return;
|
|
345
|
+
e.preventDefault();
|
|
346
|
+
dragSession = {
|
|
347
|
+
view: editorView,
|
|
348
|
+
sourceBlock: currentBlock,
|
|
349
|
+
sourcePos: dragStartPos,
|
|
350
|
+
sourceNodeSize: sourceNode.nodeSize,
|
|
351
|
+
startX: e.clientX,
|
|
352
|
+
startY: e.clientY,
|
|
353
|
+
dragging: false,
|
|
354
|
+
preview: null,
|
|
355
|
+
dropLine: null,
|
|
356
|
+
dropPos: null,
|
|
357
|
+
};
|
|
358
|
+
document.addEventListener("mousemove", handleDocumentMouseMove);
|
|
359
|
+
document.addEventListener("mouseup", handleDocumentMouseUp);
|
|
360
|
+
document.addEventListener("keydown", handleDocumentKeyDown);
|
|
361
|
+
});
|
|
362
|
+
return {
|
|
363
|
+
destroy() {
|
|
364
|
+
document.removeEventListener("mousemove", handleDocumentHoverMove);
|
|
365
|
+
finishDragSession(false);
|
|
366
|
+
handle?.remove();
|
|
367
|
+
handle = null;
|
|
368
|
+
},
|
|
369
|
+
};
|
|
370
|
+
},
|
|
371
|
+
props: {
|
|
372
|
+
handleDOMEvents: {
|
|
373
|
+
mousemove(view, event) {
|
|
374
|
+
if (!handle)
|
|
375
|
+
return false;
|
|
376
|
+
if (!editor.isEditable) {
|
|
377
|
+
hideHandle();
|
|
378
|
+
return false;
|
|
379
|
+
}
|
|
380
|
+
if (dragSession)
|
|
381
|
+
return false;
|
|
382
|
+
const block = findForgivingBlock(view, event.clientX, event.clientY);
|
|
383
|
+
if (!block) {
|
|
384
|
+
hideHandle();
|
|
385
|
+
return false;
|
|
386
|
+
}
|
|
387
|
+
if (block.node === currentBlock)
|
|
388
|
+
return false;
|
|
389
|
+
showHandleForBlock(view, block);
|
|
390
|
+
return false;
|
|
391
|
+
},
|
|
392
|
+
drop() {
|
|
393
|
+
finishDragSession(false);
|
|
394
|
+
hideHandle();
|
|
395
|
+
return false;
|
|
396
|
+
},
|
|
397
|
+
},
|
|
398
|
+
},
|
|
399
|
+
}),
|
|
400
|
+
];
|
|
401
|
+
},
|
|
402
|
+
});
|
|
403
|
+
//# sourceMappingURL=DragHandle.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DragHandle.js","sourceRoot":"","sources":["../../../src/client/rich-markdown-editor/DragHandle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAGpE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,wBAAwB,CAAC;AAe7E,MAAM,aAAa,GAAG,IAAI,SAAS,CAAC,YAAY,CAAC,CAAC;AAClD,MAAM,qBAAqB,GAAG,CAAC,CAAC;AA4BhC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC,MAAM,CAAoB;IAC5D,IAAI,EAAE,YAAY;IAElB,UAAU;QACR,OAAO;YACL,eAAe,EAAE,oCAAoC;SACtD,CAAC;IACJ,CAAC;IAED,qBAAqB;QACnB,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,MAAM,eAAe,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC;QACrD,IAAI,MAAM,GAAuB,IAAI,CAAC;QACtC,IAAI,YAAY,GAAuB,IAAI,CAAC;QAC5C,IAAI,YAAY,GAAkB,IAAI,CAAC;QACvC,IAAI,WAAW,GAAuB,IAAI,CAAC;QAE3C,MAAM,kBAAkB,GAAG,GAAG,EAAE;YAC9B,MAAM,YAAY,GAAG,MAAM,CAAC,UAAU,CACpC,gBAAgB,CAAC,QAAQ,CAAC,eAAe,CAAC,CAAC,QAAQ,CACpD,CAAC;YACF,OAAO,CACL,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE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AAgB,CAAC,SAAS,EAAE,qBAAqB,CAAC,CAAC;oBAC9D,CAAC,CAAC,CAAC;oBAEH,OAAO;wBACL,OAAO;4BACL,QAAQ,CAAC,mBAAmB,CAC1B,WAAW,EACX,uBAAuB,CACxB,CAAC;4BACF,iBAAiB,CAAC,KAAK,CAAC,CAAC;4BACzB,MAAM,EAAE,MAAM,EAAE,CAAC;4BACjB,MAAM,GAAG,IAAI,CAAC;wBAChB,CAAC;qBACF,CAAC;gBACJ,CAAC;gBACD,KAAK,EAAE;oBACL,eAAe,EAAE;wBACf,SAAS,CAAC,IAAI,EAAE,KAAK;4BACnB,IAAI,CAAC,MAAM;gCAAE,OAAO,KAAK,CAAC;4BAC1B,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;gCACvB,UAAU,EAAE,CAAC;gCACb,OAAO,KAAK,CAAC;4BACf,CAAC;4BACD,IAAI,WAAW;gCAAE,OAAO,KAAK,CAAC;4BAE9B,MAAM,KAAK,GAAG,kBAAkB,CAC9B,IAAI,EACJ,KAAK,CAAC,OAAO,EACb,KAAK,CAAC,OAAO,CACd,CAAC;4BACF,IAAI,CAAC,KAAK,EAAE,CAAC;gCACX,UAAU,EAAE,CAAC;gCACb,OAAO,KAAK,CAAC;4BACf,CAAC;4BAED,IAAI,KAAK,CAAC,IAAI,KAAK,YAAY;gCAAE,OAAO,KAAK,CAAC;4BAC9C,kBAAkB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;4BAEhC,OAAO,KAAK,CAAC;wBACf,CAAC;wBACD,IAAI;4BACF,iBAAiB,CAAC,KAAK,CAAC,CAAC;4BACzB,UAAU,EAAE,CAAC;4BACb,OAAO,KAAK,CAAC;wBACf,CAAC;qBACF;iBACF;aACF,CAAC;SACH,CAAC;IACJ,CAAC;CACF,CAAC,CAAC","sourcesContent":["import { Extension } from \"@tiptap/core\";\nimport { Plugin, PluginKey, NodeSelection } from \"@tiptap/pm/state\";\nimport { type EditorView } from \"@tiptap/pm/view\";\n\n/**\n * Default editor-wrapper CSS selector the drag handle scopes itself to.\n *\n * The handle, the drop indicator, and the `position: relative` anchor are all\n * appended to / measured against the closest ancestor matching this selector.\n * Content's editor wraps its ProseMirror DOM in a `.visual-editor-wrapper`\n * element, so that is the historical default. Other apps (e.g. the plan editor)\n * pass their own wrapper selector via {@link DragHandleOptions.wrapperSelector}.\n */\nexport const DEFAULT_DRAG_HANDLE_WRAPPER_SELECTOR = \".visual-editor-wrapper\";\n\nexport interface DragHandleOptions {\n /**\n * CSS selector for the editor wrapper element the handle is anchored to.\n *\n * Must match an ancestor of the ProseMirror editor DOM. The wrapper gets\n * `position: relative` so the absolutely-positioned grip and drop indicator\n * can be placed relative to it. Defaults to\n * {@link DEFAULT_DRAG_HANDLE_WRAPPER_SELECTOR} so Content keeps working\n * unchanged.\n */\n wrapperSelector: string;\n}\n\nconst dragHandleKey = new PluginKey(\"dragHandle\");\nconst HOVER_SIDE_OUTSET_REM = 8;\n\ntype DropTarget = {\n block: HTMLElement;\n before: boolean;\n pos: number;\n rect: DOMRect;\n};\n\ntype DragSession = {\n view: EditorView;\n sourceBlock: HTMLElement;\n sourcePos: number;\n sourceNodeSize: number;\n startX: number;\n startY: number;\n dragging: boolean;\n preview: HTMLElement | null;\n dropLine: HTMLElement | null;\n dropPos: number | null;\n};\n\ntype HoverBlock = {\n node: HTMLElement;\n pmPos: number;\n rect: DOMRect;\n};\n\n/**\n * App-agnostic Tiptap extension providing a Notion-style left-margin drag grip\n * (the `::` handle), block selection, and drag-to-reorder over top-level block\n * nodes.\n *\n * Behavior:\n * - On hover over any top-level block, a `.drag-handle` grip appears in the left\n * margin (forgiving hit zone extends {@link HOVER_SIDE_OUTSET_REM}rem to the\n * sides and into the gap above/between blocks).\n * - `mousedown` on the grip selects the block as a `NodeSelection`; dragging past\n * a small threshold starts a reorder, showing a floating clone preview\n * (`.notion-drag-preview`) and a `.notion-drop-indicator` line. `Escape`\n * cancels.\n * - While dragging, the source block carries `.notion-block--dragging` and the\n * document element carries `.notion-editor-is-dragging` so apps can style the\n * in-flight state. Apps own all of these CSS class names.\n * - Works for ANY top-level node ProseMirror renders as a direct child of the\n * editor — including `group: \"block\"`, `draggable: true` atoms such as the\n * plan editor's `planBlock`.\n *\n * The only app-specific coupling — the editor wrapper element the handle and\n * drop indicator are anchored to — is configurable via\n * {@link DragHandleOptions.wrapperSelector}, defaulting to\n * {@link DEFAULT_DRAG_HANDLE_WRAPPER_SELECTOR} (`.visual-editor-wrapper`) so the\n * Content editor keeps working byte-identically. The plan editor passes its own\n * wrapper selector via `DragHandle.configure({ wrapperSelector })`.\n */\nexport const DragHandle = Extension.create<DragHandleOptions>({\n name: \"dragHandle\",\n\n addOptions() {\n return {\n wrapperSelector: DEFAULT_DRAG_HANDLE_WRAPPER_SELECTOR,\n };\n },\n\n addProseMirrorPlugins() {\n const editor = this.editor;\n const wrapperSelector = this.options.wrapperSelector;\n let handle: HTMLElement | null = null;\n let currentBlock: HTMLElement | null = null;\n let dragStartPos: number | null = null;\n let dragSession: DragSession | null = null;\n\n const getHoverSideOutset = () => {\n const rootFontSize = Number.parseFloat(\n getComputedStyle(document.documentElement).fontSize,\n );\n return (\n (Number.isFinite(rootFontSize) ? rootFontSize : 16) *\n HOVER_SIDE_OUTSET_REM\n );\n };\n\n const getTopLevelBlocks = (editorView: EditorView): HoverBlock[] => {\n const blocks: HoverBlock[] = [];\n\n editorView.state.doc.forEach((_node, offset) => {\n const dom = editorView.nodeDOM(offset);\n if (!(dom instanceof HTMLElement)) return;\n\n blocks.push({\n node: dom,\n pmPos: offset,\n rect: dom.getBoundingClientRect(),\n });\n });\n\n return blocks;\n };\n\n const findForgivingBlock = (\n editorView: EditorView,\n clientX: number,\n clientY: number,\n ): HoverBlock | null => {\n const blocks = getTopLevelBlocks(editorView);\n if (blocks.length === 0) return null;\n\n const sideOutset = getHoverSideOutset();\n const pageLeft = 0;\n const pageRight = window.visualViewport?.width ?? window.innerWidth;\n\n for (let index = 0; index < blocks.length; index++) {\n const block = blocks[index];\n const nextBlock = blocks[index + 1];\n const blockBottomGap = nextBlock\n ? Math.max(0, nextBlock.rect.top - block.rect.bottom)\n : 0;\n const zoneLeft = Math.max(pageLeft, block.rect.left - sideOutset);\n const zoneRight = Math.min(pageRight, block.rect.right + sideOutset);\n const zoneTop =\n index === 0\n ? Math.max(0, block.rect.top - blockBottomGap)\n : block.rect.top;\n const zoneBottom = nextBlock ? nextBlock.rect.top : block.rect.bottom;\n\n if (\n clientX >= zoneLeft &&\n clientX <= zoneRight &&\n clientY >= zoneTop &&\n clientY < zoneBottom\n ) {\n return block;\n }\n }\n\n return null;\n };\n\n const showHandleForBlock = (editorView: EditorView, block: HoverBlock) => {\n if (!handle) return;\n currentBlock = block.node;\n dragStartPos = block.pmPos;\n\n const wrapper = editorView.dom.closest(wrapperSelector);\n if (!wrapper) return;\n\n // Lazily (re)attach the grip the first time a wrapper is actually\n // available. At plugin `view()` init the editor DOM may not yet be mounted\n // inside the wrapper (React mounts `EditorContent` after the EditorView is\n // constructed), so the init-time append can silently no-op and leave the\n // grip orphaned. Re-home it here once the wrapper exists.\n if (handle.parentElement !== wrapper) {\n (wrapper as HTMLElement).style.position = \"relative\";\n wrapper.appendChild(handle);\n }\n\n const wrapperRect = wrapper.getBoundingClientRect();\n\n handle.style.display = \"flex\";\n handle.style.top = `${block.rect.top - wrapperRect.top + 2}px`;\n handle.style.left = \"-24px\";\n };\n\n const selectCurrentBlock = (editorView: EditorView) => {\n if (dragStartPos === null) return null;\n\n try {\n const sel = NodeSelection.create(editorView.state.doc, dragStartPos);\n editorView.dispatch(editorView.state.tr.setSelection(sel));\n editorView.focus();\n return sel;\n } catch {\n return null;\n }\n };\n\n const cleanupDragVisuals = () => {\n dragSession?.preview?.remove();\n dragSession?.dropLine?.remove();\n dragSession?.sourceBlock.classList.remove(\"notion-block--dragging\");\n document.documentElement.classList.remove(\"notion-editor-is-dragging\");\n };\n\n const createDragPreview = (block: HTMLElement): HTMLElement => {\n const blockRect = block.getBoundingClientRect();\n const preview = document.createElement(\"div\");\n const clone = block.cloneNode(true) as HTMLElement;\n\n clone.classList.remove(\n \"ProseMirror-selectednode\",\n \"notion-block--dragging\",\n );\n clone.removeAttribute(\"contenteditable\");\n clone.style.background = \"transparent\";\n clone.style.backgroundColor = \"transparent\";\n clone.querySelectorAll(\"[contenteditable]\").forEach((node) => {\n node.removeAttribute(\"contenteditable\");\n });\n clone.querySelectorAll<HTMLElement>(\"*\").forEach((node) => {\n node.style.background = \"transparent\";\n node.style.backgroundColor = \"transparent\";\n });\n\n preview.className = \"notion-drag-preview\";\n preview.style.width = `${blockRect.width}px`;\n preview.appendChild(clone);\n document.body.appendChild(preview);\n\n return preview;\n };\n\n const createDropLine = (view: EditorView): HTMLElement | null => {\n const wrapper = view.dom.closest(wrapperSelector);\n if (!wrapper) return null;\n\n const line = document.createElement(\"div\");\n line.className = \"notion-drop-indicator\";\n wrapper.appendChild(line);\n return line;\n };\n\n const findDropTarget = (\n view: EditorView,\n clientX: number,\n clientY: number,\n ): DropTarget | null => {\n const block = findForgivingBlock(view, clientX, clientY);\n if (!block) return null;\n\n const node = view.state.doc.nodeAt(block.pmPos);\n if (!node) return null;\n\n const dropBefore =\n clientY < block.rect.top ||\n (clientY <= block.rect.bottom &&\n clientY < block.rect.top + block.rect.height / 2);\n\n return {\n block: block.node,\n before: dropBefore,\n pos: dropBefore ? block.pmPos : block.pmPos + node.nodeSize,\n rect: block.rect,\n };\n };\n\n const positionDragPreview = (\n session: DragSession,\n clientX: number,\n clientY: number,\n ) => {\n if (!session.preview) return;\n\n session.preview.style.transform = `translate3d(${clientX + 12}px, ${clientY + 10}px, 0)`;\n };\n\n const updateDropLine = (\n session: DragSession,\n target: DropTarget | null,\n ) => {\n const sourceEnd = session.sourcePos + session.sourceNodeSize;\n if (\n !target ||\n target.pos === session.sourcePos ||\n target.pos === sourceEnd ||\n (target.pos > session.sourcePos && target.pos < sourceEnd)\n ) {\n session.dropPos = null;\n session.dropLine?.remove();\n session.dropLine = null;\n return;\n }\n\n if (!session.dropLine) session.dropLine = createDropLine(session.view);\n if (!session.dropLine) return;\n\n const wrapper = session.view.dom.closest(wrapperSelector);\n if (!wrapper) return;\n\n const wrapperRect = wrapper.getBoundingClientRect();\n const editorRect = session.view.dom.getBoundingClientRect();\n const top = target.before ? target.rect.top : target.rect.bottom;\n\n session.dropPos = target.pos;\n session.dropLine.style.left = `${editorRect.left - wrapperRect.left}px`;\n session.dropLine.style.top = `${top - wrapperRect.top}px`;\n session.dropLine.style.width = `${editorRect.width}px`;\n };\n\n const createHandle = () => {\n const el = document.createElement(\"div\");\n el.className = \"drag-handle\";\n el.contentEditable = \"false\";\n el.draggable = false;\n el.innerHTML = `<svg width=\"14\" height=\"14\" viewBox=\"0 0 16 16\" fill=\"currentColor\">\n <circle cx=\"5.5\" cy=\"3\" r=\"1.5\"/><circle cx=\"10.5\" cy=\"3\" r=\"1.5\"/>\n <circle cx=\"5.5\" cy=\"8\" r=\"1.5\"/><circle cx=\"10.5\" cy=\"8\" r=\"1.5\"/>\n <circle cx=\"5.5\" cy=\"13\" r=\"1.5\"/><circle cx=\"10.5\" cy=\"13\" r=\"1.5\"/>\n </svg>`;\n return el;\n };\n\n const hideHandle = () => {\n if (handle) handle.style.display = \"none\";\n currentBlock = null;\n };\n\n const removeDragListeners = () => {\n document.removeEventListener(\"mousemove\", handleDocumentMouseMove);\n document.removeEventListener(\"mouseup\", handleDocumentMouseUp);\n document.removeEventListener(\"keydown\", handleDocumentKeyDown);\n };\n\n const createDocumentHoverMove = (editorView: EditorView) => {\n return (event: MouseEvent) => {\n if (!handle || dragSession) return;\n if (!editor.isEditable) {\n hideHandle();\n return;\n }\n\n const block = findForgivingBlock(\n editorView,\n event.clientX,\n event.clientY,\n );\n\n if (!block) {\n hideHandle();\n return;\n }\n\n showHandleForBlock(editorView, block);\n };\n };\n\n const finishDragSession = (commit: boolean) => {\n const session = dragSession;\n if (!session) return;\n\n removeDragListeners();\n\n if (commit && session.dragging && session.dropPos !== null) {\n const sourceStart = session.sourcePos;\n const sourceEnd = session.sourcePos + session.sourceNodeSize;\n const dropPos = session.dropPos;\n\n if (\n dropPos !== sourceStart &&\n dropPos !== sourceEnd &&\n !(dropPos > sourceStart && dropPos < sourceEnd)\n ) {\n const sourceNode = session.view.state.doc.nodeAt(sourceStart);\n if (sourceNode) {\n const insertPos =\n dropPos > sourceStart ? dropPos - sourceNode.nodeSize : dropPos;\n const tr = session.view.state.tr\n .delete(sourceStart, sourceEnd)\n .insert(insertPos, sourceNode);\n\n tr.setSelection(NodeSelection.create(tr.doc, insertPos));\n\n session.view.dispatch(tr.scrollIntoView());\n session.view.focus();\n }\n }\n } else if (!session.dragging) {\n selectCurrentBlock(session.view);\n }\n\n cleanupDragVisuals();\n dragSession = null;\n hideHandle();\n };\n\n const beginDragSession = (session: DragSession, event: MouseEvent) => {\n session.dragging = true;\n session.preview = createDragPreview(session.sourceBlock);\n session.sourceBlock.classList.add(\"notion-block--dragging\");\n document.documentElement.classList.add(\"notion-editor-is-dragging\");\n positionDragPreview(session, event.clientX, event.clientY);\n updateDropLine(\n session,\n findDropTarget(session.view, event.clientX, event.clientY),\n );\n };\n\n function handleDocumentMouseMove(event: MouseEvent) {\n if (!dragSession) return;\n event.preventDefault();\n\n const movedEnough =\n Math.hypot(\n event.clientX - dragSession.startX,\n event.clientY - dragSession.startY,\n ) > 4;\n\n if (!dragSession.dragging && movedEnough) {\n beginDragSession(dragSession, event);\n }\n\n if (!dragSession.dragging) return;\n\n positionDragPreview(dragSession, event.clientX, event.clientY);\n updateDropLine(\n dragSession,\n findDropTarget(dragSession.view, event.clientX, event.clientY),\n );\n }\n\n function handleDocumentMouseUp(event: MouseEvent) {\n event.preventDefault();\n finishDragSession(true);\n }\n\n function handleDocumentKeyDown(event: KeyboardEvent) {\n if (event.key !== \"Escape\") return;\n event.preventDefault();\n finishDragSession(false);\n }\n\n return [\n new Plugin({\n key: dragHandleKey,\n view(editorView) {\n handle = createHandle();\n const handleDocumentHoverMove = createDocumentHoverMove(editorView);\n const wrapper = editorView.dom.closest(wrapperSelector);\n if (wrapper) {\n (wrapper as HTMLElement).style.position = \"relative\";\n wrapper.appendChild(handle);\n }\n\n document.addEventListener(\"mousemove\", handleDocumentHoverMove);\n\n handle.addEventListener(\"mousedown\", (e) => {\n e.stopPropagation();\n if (!editor.isEditable) {\n e.preventDefault();\n return;\n }\n\n if (!currentBlock || dragStartPos === null) return;\n\n const sourceNode = editorView.state.doc.nodeAt(dragStartPos);\n if (!sourceNode) return;\n\n e.preventDefault();\n dragSession = {\n view: editorView,\n sourceBlock: currentBlock,\n sourcePos: dragStartPos,\n sourceNodeSize: sourceNode.nodeSize,\n startX: e.clientX,\n startY: e.clientY,\n dragging: false,\n preview: null,\n dropLine: null,\n dropPos: null,\n };\n\n document.addEventListener(\"mousemove\", handleDocumentMouseMove);\n document.addEventListener(\"mouseup\", handleDocumentMouseUp);\n document.addEventListener(\"keydown\", handleDocumentKeyDown);\n });\n\n return {\n destroy() {\n document.removeEventListener(\n \"mousemove\",\n handleDocumentHoverMove,\n );\n finishDragSession(false);\n handle?.remove();\n handle = null;\n },\n };\n },\n props: {\n handleDOMEvents: {\n mousemove(view, event) {\n if (!handle) return false;\n if (!editor.isEditable) {\n hideHandle();\n return false;\n }\n if (dragSession) return false;\n\n const block = findForgivingBlock(\n view,\n event.clientX,\n event.clientY,\n );\n if (!block) {\n hideHandle();\n return false;\n }\n\n if (block.node === currentBlock) return false;\n showHandleForBlock(view, block);\n\n return false;\n },\n drop() {\n finishDragSession(false);\n hideHandle();\n return false;\n },\n },\n },\n }),\n ];\n },\n});\n"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { type ImageOptions } from "@tiptap/extension-image";
|
|
2
|
+
import type { EditorView } from "@tiptap/pm/view";
|
|
3
|
+
/**
|
|
4
|
+
* The injectable async upload contract for the shared image block.
|
|
5
|
+
*
|
|
6
|
+
* An app provides this to turn a picked / pasted / dropped {@link File} into a
|
|
7
|
+
* hosted image. It returns the final `src` (a hosted URL) plus an optional
|
|
8
|
+
* `alt`. Plans wire it to the framework `upload-image` action; Content keeps its
|
|
9
|
+
* own richer image block and does not use this contract.
|
|
10
|
+
*
|
|
11
|
+
* When NO upload function is supplied, the shared block still renders images and
|
|
12
|
+
* round-trips `` markdown — it just cannot ingest local files (paste
|
|
13
|
+
* of an image URL / markdown still works via the base node's input rules).
|
|
14
|
+
*/
|
|
15
|
+
export type ImageUploadFn = (file: File) => Promise<{
|
|
16
|
+
src: string;
|
|
17
|
+
alt?: string;
|
|
18
|
+
}>;
|
|
19
|
+
export interface SharedImageOptions extends ImageOptions {
|
|
20
|
+
/**
|
|
21
|
+
* App-injected uploader. When present, the shared block accepts pasted /
|
|
22
|
+
* dropped image files and the `/image` slash command, uploading each file
|
|
23
|
+
* through this function and patching the node's `src` on resolve.
|
|
24
|
+
*/
|
|
25
|
+
onImageUpload?: ImageUploadFn | null;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* The SHARED block-level image node. Built on `@tiptap/extension-image` (a
|
|
29
|
+
* node named `image`), so:
|
|
30
|
+
*
|
|
31
|
+
* - **GFM serialization** emits pure `` markdown via a block-aware
|
|
32
|
+
* `addStorage().markdown.serialize` (it calls `closeBlock` so a block image
|
|
33
|
+
* keeps its blank-line separator, byte-stable). It emits NO `<img width>`
|
|
34
|
+
* HTML, so plans stay source-syncable under the GFM `html:false` contract.
|
|
35
|
+
* - **Paste / drop** of local image files is handled by a self-contained
|
|
36
|
+
* ProseMirror plugin that calls the injected {@link ImageUploadFn}. Pasting
|
|
37
|
+
* an image URL or `` markdown works through the base node's input
|
|
38
|
+
* rules even when no uploader is supplied.
|
|
39
|
+
*
|
|
40
|
+
* The node adds one transient `uploadId` attribute (never parsed/rendered to
|
|
41
|
+
* HTML, never serialized to markdown) used to track an in-flight upload.
|
|
42
|
+
*
|
|
43
|
+
* Content keeps its own richer `ImageNode` (Assets picker, AI alt-text, resize,
|
|
44
|
+
* NFM `{color}` serialization) and does NOT use this shared node — both nodes
|
|
45
|
+
* are named `image` but never coexist in the same editor because Content leaves
|
|
46
|
+
* `features.image` off and injects its own via `extraExtensions`.
|
|
47
|
+
*/
|
|
48
|
+
export declare const SharedImage: import("@tiptap/core").Node<SharedImageOptions, any>;
|
|
49
|
+
/**
|
|
50
|
+
* Build the shared image extension, optionally wired with an app uploader.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* createImageExtension({ onImageUpload: uploadEditorImage })
|
|
54
|
+
*/
|
|
55
|
+
export declare function createImageExtension(options?: {
|
|
56
|
+
onImageUpload?: ImageUploadFn | null;
|
|
57
|
+
}): import("@tiptap/core").Node<SharedImageOptions, any>;
|
|
58
|
+
/**
|
|
59
|
+
* Open a native file picker, then upload + insert the chosen image(s) through
|
|
60
|
+
* the same flow as paste/drop. Used by the `/image` slash command.
|
|
61
|
+
*/
|
|
62
|
+
export declare function pickAndInsertImage(view: EditorView, upload: ImageUploadFn): void;
|
|
63
|
+
//# sourceMappingURL=ImageExtension.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ImageExtension.d.ts","sourceRoot":"","sources":["../../../src/client/rich-markdown-editor/ImageExtension.ts"],"names":[],"mappings":"AAAA,OAAc,EAAE,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAEnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;;;;;;;;;GAWG;AACH,MAAM,MAAM,aAAa,GAAG,CAC1B,IAAI,EAAE,IAAI,KACP,OAAO,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC;AAE5C,MAAM,WAAW,kBAAmB,SAAQ,YAAY;IACtD;;;;OAIG;IACH,aAAa,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;CACtC;AAoHD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,WAAW,sDAoGtB,CAAC;AAEH;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,GAAE;IAAE,aAAa,CAAC,EAAE,aAAa,GAAG,IAAI,CAAA;CAAO,wDAMvD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,aAAa,GACpB,IAAI,CAgBN"}
|