@agent-native/core 0.41.0 → 0.42.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/dist/action.d.ts +13 -1
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js.map +1 -1
- package/dist/agent/production-agent.d.ts +8 -0
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +93 -0
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/cli/app-skill.d.ts +16 -0
- package/dist/cli/app-skill.d.ts.map +1 -1
- package/dist/cli/app-skill.js +33 -3
- package/dist/cli/app-skill.js.map +1 -1
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +57 -0
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/pr-visual-recap-workflow.d.ts +1 -1
- package/dist/cli/pr-visual-recap-workflow.d.ts.map +1 -1
- package/dist/cli/pr-visual-recap-workflow.js +1 -1
- package/dist/cli/pr-visual-recap-workflow.js.map +1 -1
- package/dist/cli/recap.d.ts.map +1 -1
- package/dist/cli/recap.js +14 -3
- package/dist/cli/recap.js.map +1 -1
- package/dist/cli/skills.d.ts +34 -3
- package/dist/cli/skills.d.ts.map +1 -1
- package/dist/cli/skills.js +172 -48
- package/dist/cli/skills.js.map +1 -1
- package/dist/cli/workspacify.d.ts.map +1 -1
- package/dist/cli/workspacify.js +19 -4
- package/dist/cli/workspacify.js.map +1 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +2 -2
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +172 -5
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/blocks/library/AnnotatedCodeBlock.d.ts +19 -0
- package/dist/client/blocks/library/AnnotatedCodeBlock.d.ts.map +1 -1
- package/dist/client/blocks/library/AnnotatedCodeBlock.js +5 -57
- package/dist/client/blocks/library/AnnotatedCodeBlock.js.map +1 -1
- package/dist/client/blocks/library/ApiEndpointBlock.d.ts.map +1 -1
- package/dist/client/blocks/library/ApiEndpointBlock.js +116 -7
- package/dist/client/blocks/library/ApiEndpointBlock.js.map +1 -1
- package/dist/client/blocks/library/DataModelBlock.d.ts.map +1 -1
- package/dist/client/blocks/library/DataModelBlock.js +75 -9
- package/dist/client/blocks/library/DataModelBlock.js.map +1 -1
- package/dist/client/blocks/library/DiffBlock.d.ts +1 -1
- package/dist/client/blocks/library/DiffBlock.d.ts.map +1 -1
- package/dist/client/blocks/library/DiffBlock.js +195 -34
- package/dist/client/blocks/library/DiffBlock.js.map +1 -1
- package/dist/client/blocks/library/HighlightedCode.d.ts +1 -1
- package/dist/client/blocks/library/HighlightedCode.js +1 -1
- package/dist/client/blocks/library/HighlightedCode.js.map +1 -1
- package/dist/client/blocks/library/annotation-rail.d.ts +96 -0
- package/dist/client/blocks/library/annotation-rail.d.ts.map +1 -0
- package/dist/client/blocks/library/annotation-rail.js +120 -0
- package/dist/client/blocks/library/annotation-rail.js.map +1 -0
- package/dist/client/blocks/library/api-endpoint.config.d.ts +31 -6
- package/dist/client/blocks/library/api-endpoint.config.d.ts.map +1 -1
- package/dist/client/blocks/library/api-endpoint.config.js +30 -6
- package/dist/client/blocks/library/api-endpoint.config.js.map +1 -1
- package/dist/client/blocks/library/code.d.ts.map +1 -1
- package/dist/client/blocks/library/code.js +32 -15
- package/dist/client/blocks/library/code.js.map +1 -1
- package/dist/client/blocks/library/columns.d.ts.map +1 -1
- package/dist/client/blocks/library/columns.js +56 -35
- package/dist/client/blocks/library/columns.js.map +1 -1
- package/dist/client/blocks/library/data-model.config.d.ts +17 -0
- package/dist/client/blocks/library/data-model.config.d.ts.map +1 -1
- package/dist/client/blocks/library/data-model.config.js +15 -0
- package/dist/client/blocks/library/data-model.config.js.map +1 -1
- package/dist/client/blocks/library/diff.config.d.ts +28 -6
- package/dist/client/blocks/library/diff.config.d.ts.map +1 -1
- package/dist/client/blocks/library/diff.config.js +30 -6
- package/dist/client/blocks/library/diff.config.js.map +1 -1
- package/dist/client/blocks/types.d.ts +2 -2
- package/dist/client/blocks/types.d.ts.map +1 -1
- package/dist/client/blocks/types.js.map +1 -1
- package/dist/client/rich-markdown-editor/DragHandle.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/DragHandle.js +75 -9
- package/dist/client/rich-markdown-editor/DragHandle.js.map +1 -1
- package/dist/client/rich-markdown-editor/RegistryBlockNode.d.ts +25 -1
- package/dist/client/rich-markdown-editor/RegistryBlockNode.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/RegistryBlockNode.js +29 -6
- package/dist/client/rich-markdown-editor/RegistryBlockNode.js.map +1 -1
- package/dist/client/rich-markdown-editor/SharedRichEditor.d.ts +8 -1
- package/dist/client/rich-markdown-editor/SharedRichEditor.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/SharedRichEditor.js +5 -1
- package/dist/client/rich-markdown-editor/SharedRichEditor.js.map +1 -1
- package/dist/extensions/actions.d.ts.map +1 -1
- package/dist/extensions/actions.js +159 -12
- package/dist/extensions/actions.js.map +1 -1
- package/dist/extensions/store.d.ts +21 -0
- package/dist/extensions/store.d.ts.map +1 -1
- package/dist/extensions/store.js +33 -1
- package/dist/extensions/store.js.map +1 -1
- package/dist/server/recap-image-route.d.ts.map +1 -1
- package/dist/server/recap-image-route.js +12 -3
- package/dist/server/recap-image-route.js.map +1 -1
- package/dist/templates/default/pnpm-workspace.yaml +7 -0
- package/dist/templates/workspace-core/.agents/skills/extensions/SKILL.md +30 -5
- package/dist/templates/workspace-root/package.json +0 -5
- package/dist/templates/workspace-root/pnpm-workspace.yaml +14 -0
- package/docs/content/plan-plugin.md +107 -0
- package/docs/content/skills-guide.md +8 -0
- package/docs/content/visual-plans.md +2 -0
- package/package.json +5 -1
- package/src/templates/default/pnpm-workspace.yaml +7 -0
- package/src/templates/workspace-core/.agents/skills/extensions/SKILL.md +30 -5
- package/src/templates/workspace-root/package.json +0 -5
- package/src/templates/workspace-root/pnpm-workspace.yaml +14 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/client/blocks/types.ts"],"names":[],"mappings":"AAmWA,qEAAqE;AACrE,MAAM,UAAU,WAAW,CAAQ,IAAsB;IACvD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { FC } from \"react\";\nimport type { ZodType } from \"zod\";\n\n/**\n * Block-registry contract. A `BlockSpec` describes one document block end to end:\n * its data shape (`schema`), how it round-trips to MDX source (`mdx`), how it\n * renders read-only (`Read`) and how it is edited (`Edit`, or an auto-generated\n * schema-driven editor when omitted), where it can be placed (`placement`), and\n * metadata for menus / agent schema export.\n *\n * The registry runs ALONGSIDE existing per-block code (the plan `PlanBlockView`\n * switch + `serializeBlock`/`parseBlock`). Renderers check the registry first;\n * unregistered block types fall through to the legacy code path unchanged. The\n * MDX `tag` and attribute shape for a converted block MUST match the historical\n * encoding (e.g. `<Callout tone>…body…</Callout>`) so stored `.mdx` files still\n * parse byte-compatibly.\n */\n\n/** Where a block can be placed in a document. */\nexport type BlockPlacement = \"block\" | \"inline\";\n\n/**\n * A serialized MDX/NFM attribute value before the shared `prop()` encoder runs.\n * `prop()` decides string-vs-JSON encoding; this is just the value domain.\n */\nexport type MdxAttrValue =\n | string\n | number\n | boolean\n | unknown[]\n | Record<string, unknown>;\n\n/**\n * Type-narrowed reader over the resolved MDX attributes of a parsed block node.\n * The values are already estree/JSON-resolved by the shared attribute reader\n * (the same engine `plan-mdx.ts` uses), so a spec's `fromAttrs` never touches\n * the AST directly.\n */\nexport interface BlockAttrReader {\n string(name: string): string | undefined;\n number(name: string): number | undefined;\n bool(name: string): boolean | undefined;\n array<T = unknown>(name: string): T[] | undefined;\n object<T = unknown>(name: string): T | undefined;\n raw(name: string): unknown;\n}\n\n/**\n * Maps a block's validated data to/from its MDX component representation.\n * `tag` is the JSX component name in source (e.g. \"Callout\"). It MUST match the\n * historical name in `plan-mdx.ts` `BLOCK_COMPONENTS` / stored `.mdx` files or\n * existing plans break.\n */\nexport interface BlockMdxConfig<TData> {\n /** JSX component name in MDX source. Stable contract — never rename. */\n tag: string;\n /**\n * Encode `data` → a flat attribute bag. The registry serializer runs each\n * value through the shared `prop()` encoder (string-vs-JSON heuristic) and\n * preserves insertion order, so write the keys in the exact historical order.\n * Return `undefined` for a key (or omit it) to drop the attribute. When\n * `childrenField` is set, that field is excluded from the attribute bag.\n */\n toAttrs: (data: TData) => Record<string, MdxAttrValue | undefined>;\n /**\n * Decode resolved attributes (+ optional children markdown) → data. Must\n * tolerate missing/partial attributes for backward-compat (mirror today's\n * `?? []` / `?? \"\"` defaults).\n */\n fromAttrs: (attrs: BlockAttrReader, children: string) => TData;\n /**\n * When set, this data field is a markdown string serialized as MDX *children*\n * between the open/close tags (prose-bearing blocks: rich-text, callout)\n * rather than as a prop — so the body survives as real, inline-editable MDX\n * prose in source.\n */\n childrenField?: keyof TData & string;\n /**\n * Opt-in custom children serializer for blocks whose internals are nested MDX\n * components rather than a single markdown string (e.g. wireframe → Screen/kit\n * primitives). When present it overrides `childrenField`. `serializeChildren`\n * returns the raw inner MDX; `parseChildren` receives the child MDX AST nodes.\n */\n serializeChildren?: (data: TData) => string;\n parseChildren?: (childNodes: unknown[], idContext: string) => Partial<TData>;\n}\n\n/**\n * App-injected capabilities. Core blocks stay app-agnostic by taking these\n * rather than importing app services — mirroring `createImageExtension`'s\n * `onImageUpload` injection. Provided via `BlockRegistryProvider`.\n */\nexport interface BlockRenderContext {\n /** Markdown dialect for the auto-editor's rich-text field. */\n dialect?: \"gfm\" | \"nfm\";\n /** Resolve an asset id → displayable URL. */\n resolveAssetSrc?: (assetId: string) => string | undefined;\n /** Open the shared asset picker (returns the chosen asset). */\n pickAsset?: () => Promise<{ assetId: string; url?: string } | null>;\n /** Upload a local file, returns a hosted URL. */\n uploadFile?: (file: File) => Promise<{ url: string; assetId?: string }>;\n /** Call an app action by name (for blocks that fetch live data). */\n callAction?: (name: string, args: unknown) => Promise<unknown>;\n /** Sanitizer for HTML-bearing blocks. Provided by the app/core. */\n sanitizeHtml?: (html: string, css?: string) => string;\n /**\n * Render a markdown string with the app's read-only markdown renderer. Lets a\n * core block (whose `Read` lives in core) defer prose rendering to the app's\n * markdown reader (e.g. the plan `PlanMarkdownReader`) without importing it.\n */\n renderMarkdown?: (\n markdown: string,\n options?: { className?: string },\n ) => React.ReactNode;\n /**\n * Render an inline, editable rich-markdown field. The auto-editor calls this\n * for a `markdown()`-tagged field so the app owns the editor wiring (collab,\n * autosave debounce, dialect) rather than core hardcoding it.\n */\n renderMarkdownEditor?: (props: {\n value: string;\n onChange: (next: string) => void;\n editable: boolean;\n blockId?: string;\n className?: string;\n ariaLabel?: string;\n }) => React.ReactNode;\n /**\n * Render an app-owned \"Edit with AI\" affordance for a focused/editable block\n * field. Core block editors pass the current field value and nearby companion\n * fields; the host app decides how to collect the prompt and route it to the\n * agent sidebar. This keeps reusable core blocks from importing app-specific\n * popover/composer code while still exposing a generic AI edit hook.\n */\n renderAiFieldAction?: (props: BlockAiFieldActionProps) => React.ReactNode;\n /**\n * Render a nested child block through the app's own block dispatcher. Container\n * blocks whose `Read`/`Edit` live in core (e.g. tabs) call this to render each\n * child so the recursion keeps flowing through the SAME app renderer the\n * top-level document uses — registered children render via their spec, and\n * unregistered (not-yet-converted) children still fall through the app's legacy\n * switch. This is the coexistence seam: a core container never has to know\n * about app-specific child block types. Returns `null`/`undefined` when no\n * dispatcher is wired (read-only/SSR-only contexts can omit it).\n */\n renderBlock?: (props: {\n block: NestedBlock;\n /** Commit a replacement for this child block (edit mode only). */\n onChange?: (next: NestedBlock) => void;\n /** Whether the parent container is being edited. */\n editing?: boolean;\n /** Tighten embedded visuals in dense contexts (e.g. tab panes). */\n compactVisuals?: boolean;\n }) => React.ReactNode;\n /**\n * Render a nested editable block list through the host app's document editor.\n * Container blocks such as columns call this for each editable region so slash\n * commands, nested structured blocks, and ordinary prose behave like the\n * top-level document while the container still persists its normalized runtime\n * data. Source adapters may still expose a human-friendly nested MDX form\n * (for example `<Columns><Column>markdown</Column></Columns>`) and normalize it\n * into these block arrays at runtime.\n */\n renderBlocksEditor?: (props: {\n blocks: NestedBlock[];\n onChange: (blocks: NestedBlock[]) => void;\n editable: boolean;\n containerBlockId: string;\n regionId: string;\n regionLabel?: string;\n /** Tighten embedded visuals in dense regions such as tab panes. */\n compactVisuals?: boolean;\n }) => React.ReactNode;\n /**\n * Wrap a block's edit form in an app-provided \"panel\" surface (e.g. a shadcn\n * Popover anchored to the corner edit button) for `editSurface: \"panel\"`\n * blocks. Core renders the rendered `Read` view plus a corner trigger button\n * and the form, then hands them here so the app owns the overlay primitive\n * (core stays shadcn-free, mirroring `renderMarkdownEditor`). When omitted, a\n * panel-mode block falls back to inline editing. `title` is the block label.\n */\n renderEditSurface?: (props: {\n title: string;\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n trigger: React.ReactNode;\n children: React.ReactNode;\n /** Metadata for host-provided contextual controls such as \"Edit with AI\". */\n blockId?: string;\n blockType?: string;\n blockTitle?: string;\n blockSummary?: string;\n blockData?: unknown;\n }) => React.ReactNode;\n}\n\nexport interface BlockAiFieldActionProps {\n blockId: string;\n blockType: string;\n blockTitle?: string;\n blockSummary?: string;\n fieldLabel: string;\n fieldValue: string;\n draftScope: string;\n disabled?: boolean;\n /**\n * Human-readable instructions for the host agent prompt. Mention how to patch\n * the block and which sibling fields should be preserved.\n */\n instructions: string;\n companionFields?: Array<{\n label: string;\n value: string;\n language?: string;\n }>;\n}\n\n/**\n * The minimal shape of a nested child block passed to {@link\n * BlockRenderContext.renderBlock}. It mirrors the app's block union loosely (the\n * app casts it back to its own block type) — a discriminating `type`, a stable\n * `id`, optional heading/summary, and the type-specific `data`.\n */\nexport interface NestedBlock {\n type: string;\n id: string;\n title?: string;\n summary?: string;\n data: unknown;\n [key: string]: unknown;\n}\n\nexport interface BlockContainerRegion {\n id: string;\n label?: string;\n blocks: NestedBlock[];\n}\n\nexport interface BlockContainerSpec<TData> {\n regions: (data: TData) => BlockContainerRegion[];\n updateRegion: (data: TData, regionId: string, blocks: NestedBlock[]) => TData;\n addRegion?: (data: TData, afterRegionId?: string) => TData;\n removeRegion?: (data: TData, regionId: string) => TData;\n reorderRegion?: (\n data: TData,\n fromRegionId: string,\n toRegionId: string,\n ) => TData;\n}\n\nexport type BlockDataChangeMeta = {\n containerRegion?: {\n regionId: string;\n blocks: NestedBlock[];\n };\n};\n\n/** Props passed to a block's read-only renderer. */\nexport interface BlockReadProps<TData> {\n data: TData;\n /** Stable block id (for anchors, comment targeting, source patches). */\n blockId: string;\n /** Block heading, when present. */\n title?: string;\n /** Block trailing summary, when present. */\n summary?: string;\n /** Injected app capabilities. */\n ctx: BlockRenderContext;\n}\n\n/** Props passed to a block's editor (custom or schema-generated). */\nexport interface BlockEditProps<TData> {\n data: TData;\n onChange: (next: TData, meta?: BlockDataChangeMeta) => void;\n editable: boolean;\n blockId: string;\n title?: string;\n summary?: string;\n /** Injected app capabilities. */\n ctx: BlockRenderContext;\n}\n\nexport interface BlockSpec<TData = unknown> {\n /** Discriminator. Equals the runtime block `type`. */\n type: string;\n /** Zod schema for `data`. Drives validation AND the schema-auto-editor. */\n schema: ZodType<TData>;\n /** MDX round-trip config. */\n mdx: BlockMdxConfig<TData>;\n /** Read-only renderer (replaces a `PlanBlockView` switch branch / NodeView). */\n Read: FC<BlockReadProps<TData>>;\n /**\n * Optional editor. When omitted, the registry renders the schema-driven\n * `SchemaBlockEditor` generated from `schema`. Supply for full control\n * (wireframe canvas, diagram editor).\n */\n Edit?: FC<BlockEditProps<TData>>;\n /** Allowed placements: `[\"block\"]`, `[\"inline\"]`, or both. */\n placement: BlockPlacement[];\n /**\n * When `true`, this block's data maps to a Notion-Flavored-Markdown (NFM)\n * analog and therefore round-trips into a Notion page. Apps can derive\n * registry-backed Notion allowlists with\n * {@link BlockRegistry.notionCompatibleTypes} instead of hand-maintaining\n * per-app sets. Set it on registry-atom blocks with an NFM counterpart\n * (checklist, table); leave it `false`/undefined on dev-doc blocks\n * (api-endpoint, openapi-spec, data-model, diff, file-tree, json-explorer,\n * annotated-code, mermaid, custom-html, tabs, code-tabs) and visual/plan-only\n * blocks (wireframe, diagram). Prose blocks that aren't registry atoms\n * (rich-text, callout) carry their NFM analog through the prose path, not this\n * flag.\n */\n notionCompatible?: boolean;\n /**\n * How the block is edited in a `block`-placed document:\n * - `\"inline\"` — the `Edit`/auto-form renders in place for direct\n * manipulation of authored content (prose, checklist text, table cells,\n * code bodies). Schema-ish metadata such as tone/type, tab labels,\n * language, density, or structural settings should still be tucked behind a\n * contextual edit/settings affordance inside the custom `Edit`.\n * - `\"panel\"` — the block shows its rendered `Read` view with a corner edit\n * button that opens the `Edit`/auto-form in an app-provided panel (popover).\n * Best for config-driven blocks whose render differs from their props\n * (custom HTML, charts, any user-registered block).\n * - `\"container\"` — the block renders its `Edit` in place, and that editor\n * may call `ctx.renderBlocksEditor` for nested block regions with normal\n * slash commands and nested structured blocks.\n * Defaults to `\"inline\"` when a custom `Edit` is supplied, else `\"panel\"`\n * (auto-form blocks are property forms, ideal for a panel). The app must wire\n * `ctx.renderEditSurface` for `\"panel\"` to take effect; otherwise it falls\n * back to inline.\n */\n editSurface?: \"inline\" | \"panel\" | \"container\";\n /**\n * Optional generic contract for content-bearing container blocks. Keep this\n * runtime-oriented: it describes editable regions over normalized block arrays;\n * source formats can provide readable nested MDX adapters independently.\n */\n container?: BlockContainerSpec<TData>;\n /** Human label for menus + agent schema export. */\n label: string;\n /** Tabler icon component for UI menus (never emoji/robot/sparkle). */\n icon?: FC<{ size?: number; className?: string }>;\n /** One-line description for the agent schema export. */\n description: string;\n /** Optional default `data` factory for slash-menu insertion (an empty block). */\n empty?: () => TData;\n /**\n * Optional block-specific source-patch handlers, generalizing bespoke ops\n * like `update-custom-html`. Keyed by op name; the registry dispatches a\n * matching patch op here. Generic ops (`update-block` shallow-merge) need none.\n */\n patches?: Record<string, (data: TData, op: Record<string, unknown>) => TData>;\n}\n\n/** Identity helper for authoring a spec with full type inference. */\nexport function defineBlock<TData>(spec: BlockSpec<TData>): BlockSpec<TData> {\n return spec;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/client/blocks/types.ts"],"names":[],"mappings":"AAmWA,qEAAqE;AACrE,MAAM,UAAU,WAAW,CAAQ,IAAsB;IACvD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["import type { FC } from \"react\";\nimport type { ZodType } from \"zod\";\n\n/**\n * Block-registry contract. A `BlockSpec` describes one document block end to end:\n * its data shape (`schema`), how it round-trips to MDX source (`mdx`), how it\n * renders read-only (`Read`) and how it is edited (`Edit`, or an auto-generated\n * schema-driven editor when omitted), where it can be placed (`placement`), and\n * metadata for menus / agent schema export.\n *\n * The registry runs ALONGSIDE existing per-block code (the plan `PlanBlockView`\n * switch + `serializeBlock`/`parseBlock`). Renderers check the registry first;\n * unregistered block types fall through to the legacy code path unchanged. The\n * MDX `tag` and attribute shape for a converted block MUST match the historical\n * encoding (e.g. `<Callout tone>…body…</Callout>`) so stored `.mdx` files still\n * parse byte-compatibly.\n */\n\n/** Where a block can be placed in a document. */\nexport type BlockPlacement = \"block\" | \"inline\";\n\n/**\n * A serialized MDX/NFM attribute value before the shared `prop()` encoder runs.\n * `prop()` decides string-vs-JSON encoding; this is just the value domain.\n */\nexport type MdxAttrValue =\n | string\n | number\n | boolean\n | unknown[]\n | Record<string, unknown>;\n\n/**\n * Type-narrowed reader over the resolved MDX attributes of a parsed block node.\n * The values are already estree/JSON-resolved by the shared attribute reader\n * (the same engine `plan-mdx.ts` uses), so a spec's `fromAttrs` never touches\n * the AST directly.\n */\nexport interface BlockAttrReader {\n string(name: string): string | undefined;\n number(name: string): number | undefined;\n bool(name: string): boolean | undefined;\n array<T = unknown>(name: string): T[] | undefined;\n object<T = unknown>(name: string): T | undefined;\n raw(name: string): unknown;\n}\n\n/**\n * Maps a block's validated data to/from its MDX component representation.\n * `tag` is the JSX component name in source (e.g. \"Callout\"). It MUST match the\n * historical name in `plan-mdx.ts` `BLOCK_COMPONENTS` / stored `.mdx` files or\n * existing plans break.\n */\nexport interface BlockMdxConfig<TData> {\n /** JSX component name in MDX source. Stable contract — never rename. */\n tag: string;\n /**\n * Encode `data` → a flat attribute bag. The registry serializer runs each\n * value through the shared `prop()` encoder (string-vs-JSON heuristic) and\n * preserves insertion order, so write the keys in the exact historical order.\n * Return `undefined` for a key (or omit it) to drop the attribute. When\n * `childrenField` is set, that field is excluded from the attribute bag.\n */\n toAttrs: (data: TData) => Record<string, MdxAttrValue | undefined>;\n /**\n * Decode resolved attributes (+ optional children markdown) → data. Must\n * tolerate missing/partial attributes for backward-compat (mirror today's\n * `?? []` / `?? \"\"` defaults).\n */\n fromAttrs: (attrs: BlockAttrReader, children: string) => TData;\n /**\n * When set, this data field is a markdown string serialized as MDX *children*\n * between the open/close tags (prose-bearing blocks: rich-text, callout)\n * rather than as a prop — so the body survives as real, inline-editable MDX\n * prose in source.\n */\n childrenField?: keyof TData & string;\n /**\n * Opt-in custom children serializer for blocks whose internals are nested MDX\n * components rather than a single markdown string (e.g. wireframe → Screen/kit\n * primitives). When present it overrides `childrenField`. `serializeChildren`\n * returns the raw inner MDX; `parseChildren` receives the child MDX AST nodes.\n */\n serializeChildren?: (data: TData) => string;\n parseChildren?: (childNodes: unknown[], idContext: string) => Partial<TData>;\n}\n\n/**\n * App-injected capabilities. Core blocks stay app-agnostic by taking these\n * rather than importing app services — mirroring `createImageExtension`'s\n * `onImageUpload` injection. Provided via `BlockRegistryProvider`.\n */\nexport interface BlockRenderContext {\n /** Markdown dialect for the auto-editor's rich-text field. */\n dialect?: \"gfm\" | \"nfm\";\n /** Resolve an asset id → displayable URL. */\n resolveAssetSrc?: (assetId: string) => string | undefined;\n /** Open the shared asset picker (returns the chosen asset). */\n pickAsset?: () => Promise<{ assetId: string; url?: string } | null>;\n /** Upload a local file, returns a hosted URL. */\n uploadFile?: (file: File) => Promise<{ url: string; assetId?: string }>;\n /** Call an app action by name (for blocks that fetch live data). */\n callAction?: (name: string, args: unknown) => Promise<unknown>;\n /** Sanitizer for HTML-bearing blocks. Provided by the app/core. */\n sanitizeHtml?: (html: string, css?: string) => string;\n /**\n * Render a markdown string with the app's read-only markdown renderer. Lets a\n * core block (whose `Read` lives in core) defer prose rendering to the app's\n * markdown reader (e.g. the plan `PlanMarkdownReader`) without importing it.\n */\n renderMarkdown?: (\n markdown: string,\n options?: { className?: string },\n ) => React.ReactNode;\n /**\n * Render an inline, editable rich-markdown field. The auto-editor calls this\n * for a `markdown()`-tagged field so the app owns the editor wiring (collab,\n * autosave debounce, dialect) rather than core hardcoding it.\n */\n renderMarkdownEditor?: (props: {\n value: string;\n onChange: (next: string) => void;\n editable: boolean;\n blockId?: string;\n className?: string;\n ariaLabel?: string;\n }) => React.ReactNode;\n /**\n * Render an app-owned edit-by-prompt affordance (\"Describe a change…\") for a focused/editable block\n * field. Core block editors pass the current field value and nearby companion\n * fields; the host app decides how to collect the prompt and route it to the\n * agent sidebar. This keeps reusable core blocks from importing app-specific\n * popover/composer code while still exposing a generic AI edit hook.\n */\n renderAiFieldAction?: (props: BlockAiFieldActionProps) => React.ReactNode;\n /**\n * Render a nested child block through the app's own block dispatcher. Container\n * blocks whose `Read`/`Edit` live in core (e.g. tabs) call this to render each\n * child so the recursion keeps flowing through the SAME app renderer the\n * top-level document uses — registered children render via their spec, and\n * unregistered (not-yet-converted) children still fall through the app's legacy\n * switch. This is the coexistence seam: a core container never has to know\n * about app-specific child block types. Returns `null`/`undefined` when no\n * dispatcher is wired (read-only/SSR-only contexts can omit it).\n */\n renderBlock?: (props: {\n block: NestedBlock;\n /** Commit a replacement for this child block (edit mode only). */\n onChange?: (next: NestedBlock) => void;\n /** Whether the parent container is being edited. */\n editing?: boolean;\n /** Tighten embedded visuals in dense contexts (e.g. tab panes). */\n compactVisuals?: boolean;\n }) => React.ReactNode;\n /**\n * Render a nested editable block list through the host app's document editor.\n * Container blocks such as columns call this for each editable region so slash\n * commands, nested structured blocks, and ordinary prose behave like the\n * top-level document while the container still persists its normalized runtime\n * data. Source adapters may still expose a human-friendly nested MDX form\n * (for example `<Columns><Column>markdown</Column></Columns>`) and normalize it\n * into these block arrays at runtime.\n */\n renderBlocksEditor?: (props: {\n blocks: NestedBlock[];\n onChange: (blocks: NestedBlock[]) => void;\n editable: boolean;\n containerBlockId: string;\n regionId: string;\n regionLabel?: string;\n /** Tighten embedded visuals in dense regions such as tab panes. */\n compactVisuals?: boolean;\n }) => React.ReactNode;\n /**\n * Wrap a block's edit form in an app-provided \"panel\" surface (e.g. a shadcn\n * Popover anchored to the corner edit button) for `editSurface: \"panel\"`\n * blocks. Core renders the rendered `Read` view plus a corner trigger button\n * and the form, then hands them here so the app owns the overlay primitive\n * (core stays shadcn-free, mirroring `renderMarkdownEditor`). When omitted, a\n * panel-mode block falls back to inline editing. `title` is the block label.\n */\n renderEditSurface?: (props: {\n title: string;\n open?: boolean;\n onOpenChange?: (open: boolean) => void;\n trigger: React.ReactNode;\n children: React.ReactNode;\n /** Metadata for host-provided contextual controls such as the edit-by-prompt CTA. */\n blockId?: string;\n blockType?: string;\n blockTitle?: string;\n blockSummary?: string;\n blockData?: unknown;\n }) => React.ReactNode;\n}\n\nexport interface BlockAiFieldActionProps {\n blockId: string;\n blockType: string;\n blockTitle?: string;\n blockSummary?: string;\n fieldLabel: string;\n fieldValue: string;\n draftScope: string;\n disabled?: boolean;\n /**\n * Human-readable instructions for the host agent prompt. Mention how to patch\n * the block and which sibling fields should be preserved.\n */\n instructions: string;\n companionFields?: Array<{\n label: string;\n value: string;\n language?: string;\n }>;\n}\n\n/**\n * The minimal shape of a nested child block passed to {@link\n * BlockRenderContext.renderBlock}. It mirrors the app's block union loosely (the\n * app casts it back to its own block type) — a discriminating `type`, a stable\n * `id`, optional heading/summary, and the type-specific `data`.\n */\nexport interface NestedBlock {\n type: string;\n id: string;\n title?: string;\n summary?: string;\n data: unknown;\n [key: string]: unknown;\n}\n\nexport interface BlockContainerRegion {\n id: string;\n label?: string;\n blocks: NestedBlock[];\n}\n\nexport interface BlockContainerSpec<TData> {\n regions: (data: TData) => BlockContainerRegion[];\n updateRegion: (data: TData, regionId: string, blocks: NestedBlock[]) => TData;\n addRegion?: (data: TData, afterRegionId?: string) => TData;\n removeRegion?: (data: TData, regionId: string) => TData;\n reorderRegion?: (\n data: TData,\n fromRegionId: string,\n toRegionId: string,\n ) => TData;\n}\n\nexport type BlockDataChangeMeta = {\n containerRegion?: {\n regionId: string;\n blocks: NestedBlock[];\n };\n};\n\n/** Props passed to a block's read-only renderer. */\nexport interface BlockReadProps<TData> {\n data: TData;\n /** Stable block id (for anchors, comment targeting, source patches). */\n blockId: string;\n /** Block heading, when present. */\n title?: string;\n /** Block trailing summary, when present. */\n summary?: string;\n /** Injected app capabilities. */\n ctx: BlockRenderContext;\n}\n\n/** Props passed to a block's editor (custom or schema-generated). */\nexport interface BlockEditProps<TData> {\n data: TData;\n onChange: (next: TData, meta?: BlockDataChangeMeta) => void;\n editable: boolean;\n blockId: string;\n title?: string;\n summary?: string;\n /** Injected app capabilities. */\n ctx: BlockRenderContext;\n}\n\nexport interface BlockSpec<TData = unknown> {\n /** Discriminator. Equals the runtime block `type`. */\n type: string;\n /** Zod schema for `data`. Drives validation AND the schema-auto-editor. */\n schema: ZodType<TData>;\n /** MDX round-trip config. */\n mdx: BlockMdxConfig<TData>;\n /** Read-only renderer (replaces a `PlanBlockView` switch branch / NodeView). */\n Read: FC<BlockReadProps<TData>>;\n /**\n * Optional editor. When omitted, the registry renders the schema-driven\n * `SchemaBlockEditor` generated from `schema`. Supply for full control\n * (wireframe canvas, diagram editor).\n */\n Edit?: FC<BlockEditProps<TData>>;\n /** Allowed placements: `[\"block\"]`, `[\"inline\"]`, or both. */\n placement: BlockPlacement[];\n /**\n * When `true`, this block's data maps to a Notion-Flavored-Markdown (NFM)\n * analog and therefore round-trips into a Notion page. Apps can derive\n * registry-backed Notion allowlists with\n * {@link BlockRegistry.notionCompatibleTypes} instead of hand-maintaining\n * per-app sets. Set it on registry-atom blocks with an NFM counterpart\n * (checklist, table); leave it `false`/undefined on dev-doc blocks\n * (api-endpoint, openapi-spec, data-model, diff, file-tree, json-explorer,\n * annotated-code, mermaid, custom-html, tabs, code-tabs) and visual/plan-only\n * blocks (wireframe, diagram). Prose blocks that aren't registry atoms\n * (rich-text, callout) carry their NFM analog through the prose path, not this\n * flag.\n */\n notionCompatible?: boolean;\n /**\n * How the block is edited in a `block`-placed document:\n * - `\"inline\"` — the `Edit`/auto-form renders in place for direct\n * manipulation of authored content (prose, checklist text, table cells,\n * code bodies). Schema-ish metadata such as tone/type, tab labels,\n * language, density, or structural settings should still be tucked behind a\n * contextual edit/settings affordance inside the custom `Edit`.\n * - `\"panel\"` — the block shows its rendered `Read` view with a corner edit\n * button that opens the `Edit`/auto-form in an app-provided panel (popover).\n * Best for config-driven blocks whose render differs from their props\n * (custom HTML, charts, any user-registered block).\n * - `\"container\"` — the block renders its `Edit` in place, and that editor\n * may call `ctx.renderBlocksEditor` for nested block regions with normal\n * slash commands and nested structured blocks.\n * Defaults to `\"inline\"` when a custom `Edit` is supplied, else `\"panel\"`\n * (auto-form blocks are property forms, ideal for a panel). The app must wire\n * `ctx.renderEditSurface` for `\"panel\"` to take effect; otherwise it falls\n * back to inline.\n */\n editSurface?: \"inline\" | \"panel\" | \"container\";\n /**\n * Optional generic contract for content-bearing container blocks. Keep this\n * runtime-oriented: it describes editable regions over normalized block arrays;\n * source formats can provide readable nested MDX adapters independently.\n */\n container?: BlockContainerSpec<TData>;\n /** Human label for menus + agent schema export. */\n label: string;\n /** Tabler icon component for UI menus (never emoji/robot/sparkle). */\n icon?: FC<{ size?: number; className?: string }>;\n /** One-line description for the agent schema export. */\n description: string;\n /** Optional default `data` factory for slash-menu insertion (an empty block). */\n empty?: () => TData;\n /**\n * Optional block-specific source-patch handlers, generalizing bespoke ops\n * like `update-custom-html`. Keyed by op name; the registry dispatches a\n * matching patch op here. Generic ops (`update-block` shallow-merge) need none.\n */\n patches?: Record<string, (data: TData, op: Record<string, unknown>) => TData>;\n}\n\n/** Identity helper for authoring a spec with full type inference. */\nexport function defineBlock<TData>(spec: BlockSpec<TData>): BlockSpec<TData> {\n return spec;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DragHandle.d.ts","sourceRoot":"","sources":["../../../src/client/rich-markdown-editor/DragHandle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAQzC,OAAO,KAAK,EAAE,IAAI,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;;;;;;GAQG;AACH,eAAO,MAAM,oCAAoC,2BAA2B,CAAC;AAE7E,MAAM,WAAW,iBAAiB;IAChC;;;;;;;;OAQG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,CAAC,OAAO,EAAE;QAC9B,IAAI,EAAE,UAAU,CAAC;QACjB,IAAI,EAAE,eAAe,CAAC;QACtB,GAAG,EAAE,MAAM,CAAC;KACb,KAAK,OAAO,CAAC;IACd;;;;OAIG;IACH,uBAAuB,CAAC,EAAE,CACxB,IAAI,EAAE,OAAO,EACb,OAAO,EAAE;QACP,IAAI,EAAE,UAAU,CAAC;QACjB,IAAI,EAAE,eAAe,CAAC;QACtB,GAAG,EAAE,MAAM,CAAC;QACZ,UAAU,EAAE,UAAU,CAAC;KACxB,KACE,IAAI,CAAC;IACV;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,qBAAqB,KAAK,OAAO,CAAC;CACzE;AAuBD,MAAM,MAAM,uBAAuB,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;AAE5E,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,EAAE,eAAe,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,eAAe,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,uBAAuB,CAAC;CACpC,CAAC;
|
|
1
|
+
{"version":3,"file":"DragHandle.d.ts","sourceRoot":"","sources":["../../../src/client/rich-markdown-editor/DragHandle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAQzC,OAAO,KAAK,EAAE,IAAI,IAAI,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElD;;;;;;;;GAQG;AACH,eAAO,MAAM,oCAAoC,2BAA2B,CAAC;AAE7E,MAAM,WAAW,iBAAiB;IAChC;;;;;;;;OAQG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,CAAC,OAAO,EAAE;QAC9B,IAAI,EAAE,UAAU,CAAC;QACjB,IAAI,EAAE,eAAe,CAAC;QACtB,GAAG,EAAE,MAAM,CAAC;KACb,KAAK,OAAO,CAAC;IACd;;;;OAIG;IACH,uBAAuB,CAAC,EAAE,CACxB,IAAI,EAAE,OAAO,EACb,OAAO,EAAE;QACP,IAAI,EAAE,UAAU,CAAC;QACjB,IAAI,EAAE,eAAe,CAAC;QACtB,GAAG,EAAE,MAAM,CAAC;QACZ,UAAU,EAAE,UAAU,CAAC;KACxB,KACE,IAAI,CAAC;IACV;;;;;;OAMG;IACH,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,qBAAqB,KAAK,OAAO,CAAC;CACzE;AAuBD,MAAM,MAAM,uBAAuB,GAAG,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;AAE5E,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,EAAE,UAAU,CAAC;IACjB,UAAU,EAAE,UAAU,CAAC;IACvB,UAAU,EAAE,eAAe,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,eAAe,CAAC;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,uBAAuB,CAAC;CACpC,CAAC;AAuTF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,UAAU,mCAu6BrB,CAAC"}
|
|
@@ -48,8 +48,54 @@ const updateRegisteredHover = (clientX, clientY) => {
|
|
|
48
48
|
registration.hideHover?.();
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
// Pick which editor owns the grip when several register a hover block at this
|
|
52
|
+
// point. Nested region editors (e.g. each column inside a `columns` block) tile
|
|
53
|
+
// their container's whole footprint AND extend a wide forgiving zone
|
|
54
|
+
// (HOVER_SIDE_OUTSET_REM) into its left-margin gutter, so a pure
|
|
55
|
+
// "smallest editor wins" rule lets an inner block beat the container everywhere
|
|
56
|
+
// and leaves the container itself impossible to grab. Split candidates by where
|
|
57
|
+
// the cursor sits relative to each block:
|
|
58
|
+
// - Over a block's body (clientX at/after its left edge) the innermost
|
|
59
|
+
// (smallest) editor wins, so nested blocks stay grabbable from their content.
|
|
60
|
+
// - In the shared left-margin gutter (clientX left of every candidate's
|
|
61
|
+
// content, where the grip lives) the outermost (largest) editor wins, so the
|
|
62
|
+
// container block can be picked up and reordered.
|
|
63
|
+
// Prefer the candidate whose block actually sits UNDER the cursor
|
|
64
|
+
// horizontally. Without this, a left column's forgiving side zone reaches
|
|
65
|
+
// across the inter-column gap, ties the right column's editor on area, and
|
|
66
|
+
// wins — so hovering a right-column block shows the grip for the LEFT block
|
|
67
|
+
// (and right-column blocks appear to have no grip at all). `overContent`
|
|
68
|
+
// restricts to blocks the cursor is genuinely within; `rightOfLeftEdge` keeps
|
|
69
|
+
// the gutter-grab behaviour; fully left of every block → the container wins.
|
|
70
|
+
const overContent = candidates.filter((candidate) => clientX >= candidate.block.rect.left &&
|
|
71
|
+
clientX <= candidate.block.rect.right);
|
|
72
|
+
// The grip renders in a narrow band just LEFT of each block (≈24px). A block
|
|
73
|
+
// must OWN that band so moving the cursor onto its grip keeps showing (and
|
|
74
|
+
// lets you press) that block's grip — otherwise, for a column block whose grip
|
|
75
|
+
// sits in the gutter/inter-column gap, the "gutter → largest editor" rule
|
|
76
|
+
// below would flip the hover to the columns container and the grip would
|
|
77
|
+
// vanish out from under the cursor, making inner column blocks impossible to
|
|
78
|
+
// drag. The band is narrow, so it does not collide with the neighbouring
|
|
79
|
+
// column's content (the right column's grip lives in the inter-column gap,
|
|
80
|
+
// left of its own content but right of the left column's content).
|
|
81
|
+
const GRIP_HOVER_ZONE_PX = 28;
|
|
82
|
+
const overGrip = candidates.filter((candidate) => clientX >= candidate.block.rect.left - GRIP_HOVER_ZONE_PX &&
|
|
83
|
+
clientX < candidate.block.rect.left);
|
|
84
|
+
const rightOfLeftEdge = candidates.filter((candidate) => clientX >= candidate.block.rect.left);
|
|
85
|
+
let active;
|
|
86
|
+
const innerPool = overContent.length > 0
|
|
87
|
+
? overContent
|
|
88
|
+
: overGrip.length > 0
|
|
89
|
+
? overGrip
|
|
90
|
+
: rightOfLeftEdge;
|
|
91
|
+
if (innerPool.length > 0) {
|
|
92
|
+
innerPool.sort((a, b) => editorArea(a.registration) - editorArea(b.registration));
|
|
93
|
+
active = innerPool[0];
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
candidates.sort((a, b) => editorArea(b.registration) - editorArea(a.registration));
|
|
97
|
+
active = candidates[0] ?? null;
|
|
98
|
+
}
|
|
53
99
|
for (const registration of dragHandleRegistrations) {
|
|
54
100
|
if (registration !== active?.registration)
|
|
55
101
|
registration.hideHover?.();
|
|
@@ -629,11 +675,20 @@ export const DragHandle = Extension.create({
|
|
|
629
675
|
};
|
|
630
676
|
const updateDropLine = (session, target) => {
|
|
631
677
|
const sourceEnd = session.sourcePos + session.sourceNodeSize;
|
|
678
|
+
const isSideDrop = target?.placement === "left" || target?.placement === "right";
|
|
632
679
|
if (!target ||
|
|
633
680
|
(target.view === session.view &&
|
|
634
|
-
(
|
|
635
|
-
|
|
636
|
-
|
|
681
|
+
(isSideDrop
|
|
682
|
+
? // A side drop only ever builds columns; the ProseMirror seam
|
|
683
|
+
// position is irrelevant. The only no-op is dropping a block on
|
|
684
|
+
// ITS OWN side — adjacent *different* blocks must still form
|
|
685
|
+
// columns (otherwise dropping onto an immediate neighbour's
|
|
686
|
+
// facing edge silently does nothing, which reads as "side drop
|
|
687
|
+
// works sometimes").
|
|
688
|
+
target.targetPos === session.sourcePos
|
|
689
|
+
: target.pos === session.sourcePos ||
|
|
690
|
+
target.pos === sourceEnd ||
|
|
691
|
+
(target.pos > session.sourcePos && target.pos < sourceEnd)))) {
|
|
637
692
|
session.dropTarget = null;
|
|
638
693
|
session.dropLine?.remove();
|
|
639
694
|
session.dropLine = null;
|
|
@@ -676,7 +731,13 @@ export const DragHandle = Extension.create({
|
|
|
676
731
|
el.setAttribute("aria-haspopup", "menu");
|
|
677
732
|
el.setAttribute("aria-expanded", "false");
|
|
678
733
|
el.title = "Open block menu or drag to reorder";
|
|
679
|
-
|
|
734
|
+
// The icon must not be its own hit target: a real mouse-down inside a
|
|
735
|
+
// nested editor (a column) lands on the SVG, and a container block's
|
|
736
|
+
// capture-phase block-select handler (RegistryBlockNode) only spares the
|
|
737
|
+
// grip DIV — so a press on the icon gets swallowed and the block can't be
|
|
738
|
+
// dragged out of / between columns. `pointer-events:none` makes every
|
|
739
|
+
// press in the grip area resolve to the DIV instead.
|
|
740
|
+
el.innerHTML = `<svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor" style="pointer-events:none">
|
|
680
741
|
<circle cx="5.5" cy="3" r="1.5"/><circle cx="10.5" cy="3" r="1.5"/>
|
|
681
742
|
<circle cx="5.5" cy="8" r="1.5"/><circle cx="10.5" cy="8" r="1.5"/>
|
|
682
743
|
<circle cx="5.5" cy="13" r="1.5"/><circle cx="10.5" cy="13" r="1.5"/>
|
|
@@ -748,10 +809,15 @@ export const DragHandle = Extension.create({
|
|
|
748
809
|
const sourceEnd = session.sourcePos + session.sourceNodeSize;
|
|
749
810
|
const target = session.dropTarget;
|
|
750
811
|
const dropPos = target.pos;
|
|
812
|
+
const isSideDrop = target.placement === "left" || target.placement === "right";
|
|
751
813
|
if (target.view !== session.view ||
|
|
752
|
-
(
|
|
753
|
-
|
|
754
|
-
|
|
814
|
+
(isSideDrop
|
|
815
|
+
? // Side drop (column build): proceed for any block that isn't the
|
|
816
|
+
// source itself, including the source's immediate neighbour.
|
|
817
|
+
target.targetPos !== sourceStart
|
|
818
|
+
: dropPos !== sourceStart &&
|
|
819
|
+
dropPos !== sourceEnd &&
|
|
820
|
+
!(dropPos > sourceStart && dropPos < sourceEnd))) {
|
|
755
821
|
const sourceNode = session.view.state.doc.nodeAt(sourceStart);
|
|
756
822
|
if (sourceNode) {
|
|
757
823
|
const sourceRegistration = registrationForView(session.view);
|
|
@@ -1 +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,EACL,MAAM,EACN,SAAS,EACT,aAAa,EACb,aAAa,GAEd,MAAM,kBAAkB,CAAC;AAI1B;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,wBAAwB,CAA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;wBACf,SAAS,CAAC,KAAK,EAAE,KAAK;4BACpB,qBAAqB,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;4BACpD,OAAO,KAAK,CAAC;wBACf,CAAC;wBACD,IAAI;4BACF,SAAS,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;4BAC9B,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 {\n Plugin,\n PluginKey,\n NodeSelection,\n TextSelection,\n type Transaction,\n} from \"@tiptap/pm/state\";\nimport type { Node as ProseMirrorNode } from \"@tiptap/pm/model\";\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 * Optional source-side payload for a cross-editor block move. The editor doc\n * carries ProseMirror node content, but app-owned side-map data (for example a\n * plan `diagram` block's HTML/CSS) can live outside the doc; this lets the\n * host carry that data to the receiving editor before the node is inserted.\n */\n getDragTransferData?: (context: {\n view: EditorView;\n node: ProseMirrorNode;\n pos: number;\n }) => unknown;\n /**\n * Optional target-side receiver for cross-editor transfer data. Called before\n * the node is inserted into the target editor so the target's serializer can\n * resolve app-owned data during the synchronous ProseMirror update.\n */\n receiveDragTransferData?: (\n data: unknown,\n context: {\n view: EditorView;\n node: ProseMirrorNode;\n pos: number;\n sourceView: EditorView;\n },\n ) => void;\n /**\n * Optional host-level drop handler for document-specific structure changes.\n * Returning true tells the shared drag handle that the host fully handled the\n * move and no ProseMirror insert/delete should run. This is used for\n * Notion-style side drops where dropping a block to the left/right creates or\n * inserts into a column layout rather than inserting into the target editor.\n */\n handleDrop?: (data: unknown, context: DragHandleDropContext) => boolean;\n}\n\nconst dragHandleKey = new PluginKey(\"dragHandle\");\nconst HOVER_SIDE_OUTSET_REM = 8;\nconst SIDE_DROP_ZONE_RATIO = 0.28;\nconst SIDE_DROP_ZONE_MIN_PX = 48;\nconst SIDE_DROP_ZONE_MAX_PX = 140;\nconst DRAG_HANDLE_MENU_STYLE_ID = \"an-rich-md-drag-menu-styles\";\nconst DRAG_HANDLE_MENU_WIDTH = 220;\nconst DRAG_HANDLE_MENU_GAP = 6;\nconst DRAG_HANDLE_MENU_VIEWPORT_PADDING = 8;\n\ntype DropTarget = {\n registration: DragHandleRegistration;\n view: EditorView;\n block: HTMLElement;\n placement: DragHandleDropPlacement;\n pos: number;\n targetPos: number;\n targetNodeSize: number;\n rect: DOMRect;\n};\n\nexport type DragHandleDropPlacement = \"before\" | \"after\" | \"left\" | \"right\";\n\nexport type DragHandleDropContext = {\n view: EditorView;\n sourceView: EditorView;\n sourceNode: ProseMirrorNode;\n sourcePos: number;\n sourceNodeSize: number;\n targetNode: ProseMirrorNode;\n targetPos: number;\n targetNodeSize: number;\n insertPos: number;\n placement: DragHandleDropPlacement;\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 dropTarget: DropTarget | null;\n};\n\ntype HoverBlock = {\n node: HTMLElement;\n pmPos: number;\n rect: DOMRect;\n};\n\ntype DragHandleMenuContext = {\n view: EditorView;\n sourceBlock: HTMLElement;\n sourcePos: number;\n sourceNodeSize: number;\n};\n\ntype DragHandleRegistration = {\n view: EditorView;\n wrapperSelector: string;\n getDragTransferData?: DragHandleOptions[\"getDragTransferData\"];\n receiveDragTransferData?: DragHandleOptions[\"receiveDragTransferData\"];\n handleDrop?: DragHandleOptions[\"handleDrop\"];\n canHover?: () => boolean;\n findHoverBlock?: (clientX: number, clientY: number) => HoverBlock | null;\n showHoverBlock?: (block: HoverBlock) => void;\n hideHover?: () => void;\n};\n\nconst dragHandleRegistrations = new Set<DragHandleRegistration>();\nlet dragHandleGlobalHoverListeners = 0;\nlet activeDragRegistration: DragHandleRegistration | null = null;\n\nconst clamp = (value: number, min: number, max: number) =>\n Math.min(Math.max(value, min), max);\n\nconst editorArea = (registration: DragHandleRegistration) => {\n const rect = registration.view.dom.getBoundingClientRect();\n return rect.width * rect.height;\n};\n\nconst updateRegisteredHover = (clientX: number, clientY: number) => {\n if (activeDragRegistration) {\n for (const registration of dragHandleRegistrations) {\n registration.hideHover?.();\n }\n return;\n }\n\n const candidates: Array<{\n registration: DragHandleRegistration;\n block: HoverBlock;\n }> = [];\n\n for (const registration of dragHandleRegistrations) {\n if (!registration.view.dom.isConnected || !registration.canHover?.()) {\n registration.hideHover?.();\n continue;\n }\n const block = registration.findHoverBlock?.(clientX, clientY);\n if (block) {\n candidates.push({ registration, block });\n } else {\n registration.hideHover?.();\n }\n }\n\n candidates.sort(\n (a, b) => editorArea(a.registration) - editorArea(b.registration),\n );\n const active = candidates[0] ?? null;\n\n for (const registration of dragHandleRegistrations) {\n if (registration !== active?.registration) registration.hideHover?.();\n }\n active?.registration.showHoverBlock?.(active.block);\n};\n\nconst handleGlobalHoverMove = (event: MouseEvent) => {\n updateRegisteredHover(event.clientX, event.clientY);\n};\n\nconst retainGlobalHoverListener = () => {\n dragHandleGlobalHoverListeners += 1;\n if (dragHandleGlobalHoverListeners === 1) {\n document.addEventListener(\"mousemove\", handleGlobalHoverMove);\n }\n};\n\nconst releaseGlobalHoverListener = () => {\n dragHandleGlobalHoverListeners = Math.max(\n 0,\n dragHandleGlobalHoverListeners - 1,\n );\n if (dragHandleGlobalHoverListeners === 0) {\n document.removeEventListener(\"mousemove\", handleGlobalHoverMove);\n }\n};\n\nconst ensureDragHandleMenuStyles = () => {\n if (document.getElementById(DRAG_HANDLE_MENU_STYLE_ID)) return;\n\n const style = document.createElement(\"style\");\n style.id = DRAG_HANDLE_MENU_STYLE_ID;\n style.textContent = `\n.an-rich-md-drag-menu {\n position: fixed;\n z-index: 9999;\n width: ${DRAG_HANDLE_MENU_WIDTH}px;\n padding: 4px;\n border: 1px solid hsl(var(--border, 214.3 31.8% 91.4%));\n border-radius: 7px;\n background: hsl(var(--popover, 0 0% 100%));\n color: hsl(var(--popover-foreground, var(--foreground, 222.2 84% 4.9%)));\n box-shadow:\n 0 12px 32px rgb(15 23 42 / 0.16),\n 0 2px 8px rgb(15 23 42 / 0.08);\n font-family: inherit;\n font-size: 13px;\n line-height: 1.35;\n}\n\n.an-rich-md-drag-menu__item {\n display: flex;\n width: 100%;\n align-items: center;\n gap: 9px;\n border: 0;\n border-radius: 5px;\n background: transparent;\n color: inherit;\n cursor: pointer;\n font: inherit;\n letter-spacing: 0;\n padding: 7px 8px;\n text-align: left;\n}\n\n.an-rich-md-drag-menu__item:hover,\n.an-rich-md-drag-menu__item:focus-visible {\n background: hsl(var(--accent, 210 40% 96.1%));\n color: hsl(var(--accent-foreground, var(--foreground, 222.2 84% 4.9%)));\n outline: none;\n}\n\n.an-rich-md-drag-menu__item[data-danger=\"true\"] {\n color: hsl(var(--destructive, 0 84.2% 60.2%));\n}\n\n.an-rich-md-drag-menu__item[data-danger=\"true\"]:hover,\n.an-rich-md-drag-menu__item[data-danger=\"true\"]:focus-visible {\n background: hsl(var(--destructive, 0 84.2% 60.2%) / 0.1);\n}\n\n.an-rich-md-drag-menu__icon {\n position: relative;\n flex: 0 0 auto;\n width: 18px;\n height: 18px;\n color: hsl(var(--muted-foreground, 215.4 16.3% 46.9%));\n}\n\n.an-rich-md-drag-menu__item[data-danger=\"true\"] .an-rich-md-drag-menu__icon {\n color: currentColor;\n}\n\n.an-rich-md-drag-menu__icon::before,\n.an-rich-md-drag-menu__icon::after {\n content: \"\";\n position: absolute;\n box-sizing: border-box;\n}\n\n.an-rich-md-drag-menu__icon--duplicate::before,\n.an-rich-md-drag-menu__icon--duplicate::after {\n width: 11px;\n height: 11px;\n border: 1.5px solid currentColor;\n border-radius: 2px;\n}\n\n.an-rich-md-drag-menu__icon--duplicate::before {\n left: 6px;\n top: 2px;\n opacity: 0.55;\n}\n\n.an-rich-md-drag-menu__icon--duplicate::after {\n left: 2px;\n top: 6px;\n background: hsl(var(--popover, 0 0% 100%));\n}\n\n.an-rich-md-drag-menu__icon--insert::before {\n left: 3px;\n top: 8px;\n width: 12px;\n height: 1.5px;\n border-radius: 999px;\n background: currentColor;\n}\n\n.an-rich-md-drag-menu__icon--insert::after {\n left: 8px;\n top: 3px;\n width: 1.5px;\n height: 12px;\n border-radius: 999px;\n background: currentColor;\n}\n\n.an-rich-md-drag-menu__icon--delete::before {\n left: 4px;\n top: 7px;\n width: 10px;\n height: 11px;\n border: 1.5px solid currentColor;\n border-top: 0;\n border-radius: 0 0 2px 2px;\n}\n\n.an-rich-md-drag-menu__icon--delete::after {\n left: 3px;\n top: 4px;\n width: 12px;\n height: 1.5px;\n border-radius: 999px;\n background: currentColor;\n box-shadow: 3px -2.5px 0 -0.4px currentColor;\n}\n\n.an-rich-md-drag-menu__label {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n`;\n document.head.appendChild(style);\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 * - Single-clicking the grip selects the block and opens a block action menu.\n * Dragging past a small threshold starts a reorder, showing a floating clone\n * preview (`.notion-drag-preview`) and a `.notion-drop-indicator` line.\n * `Escape` 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 getDragTransferData: undefined,\n receiveDragTransferData: undefined,\n };\n },\n\n addProseMirrorPlugins() {\n const editor = this.editor;\n const wrapperSelector = this.options.wrapperSelector;\n const getDragTransferData = this.options.getDragTransferData;\n const receiveDragTransferData = this.options.receiveDragTransferData;\n const handleDrop = this.options.handleDrop;\n let handle: HTMLElement | null = null;\n let menu: HTMLElement | null = null;\n let menuContext: DragHandleMenuContext | null = null;\n let currentBlock: HTMLElement | null = null;\n let dragStartPos: number | null = null;\n let dragSession: DragSession | null = null;\n let currentRegistration: DragHandleRegistration | 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 registrationForView = (\n editorView: EditorView,\n ): DragHandleRegistration | null => {\n for (const registration of dragHandleRegistrations) {\n if (registration.view === editorView) return registration;\n }\n return null;\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 selectBlockAt = (editorView: EditorView, pos: number) => {\n try {\n const sel = NodeSelection.create(editorView.state.doc, pos);\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 = (\n registration: DragHandleRegistration,\n ): HTMLElement | null => {\n const wrapper = registration.view.dom.closest(\n registration.wrapperSelector,\n );\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 forceHideHandle = () => {\n if (handle) {\n handle.style.display = \"none\";\n handle.setAttribute(\"aria-expanded\", \"false\");\n }\n currentBlock = null;\n dragStartPos = null;\n };\n\n const closeMenu = ({ hideGrip = false }: { hideGrip?: boolean } = {}) => {\n menu?.remove();\n menu = null;\n menuContext = null;\n handle?.setAttribute(\"aria-expanded\", \"false\");\n document.removeEventListener(\"mousedown\", handleMenuDocumentMouseDown, {\n capture: true,\n });\n document.removeEventListener(\"keydown\", handleMenuKeyDown, {\n capture: true,\n });\n window.removeEventListener(\"resize\", handleMenuViewportChange);\n window.removeEventListener(\"scroll\", handleMenuViewportChange, {\n capture: true,\n });\n if (hideGrip) forceHideHandle();\n };\n\n const resolveMenuContext = (context: DragHandleMenuContext) => {\n const latestBlock = getTopLevelBlocks(context.view).find(\n (block) => block.node === context.sourceBlock,\n );\n const sourcePos = latestBlock?.pmPos ?? context.sourcePos;\n const sourceNode = context.view.state.doc.nodeAt(sourcePos);\n if (!sourceNode) return null;\n\n return {\n ...context,\n sourcePos,\n sourceNode,\n sourceNodeSize: sourceNode.nodeSize,\n };\n };\n\n const focusSelectionNear = (\n view: EditorView,\n tr: Transaction,\n pos: number,\n bias: -1 | 1,\n ) => {\n tr.setSelection(\n TextSelection.near(\n tr.doc.resolve(clamp(pos, 0, tr.doc.content.size)),\n bias,\n ),\n );\n view.dispatch(tr.scrollIntoView());\n view.focus();\n };\n\n const duplicateBlock = (context: DragHandleMenuContext) => {\n const resolved = resolveMenuContext(context);\n if (!resolved) return;\n\n const insertPos = resolved.sourcePos + resolved.sourceNodeSize;\n const tr = resolved.view.state.tr.insert(insertPos, resolved.sourceNode);\n\n try {\n tr.setSelection(NodeSelection.create(tr.doc, insertPos));\n resolved.view.dispatch(tr.scrollIntoView());\n resolved.view.focus();\n } catch {\n focusSelectionNear(resolved.view, tr, insertPos, 1);\n }\n };\n\n const deleteBlock = (context: DragHandleMenuContext) => {\n const resolved = resolveMenuContext(context);\n if (!resolved) return;\n\n const { view, sourcePos, sourceNodeSize } = resolved;\n const paragraph = view.state.schema.nodes.paragraph;\n const sourceEnd = sourcePos + sourceNodeSize;\n\n if (view.state.doc.childCount <= 1 && paragraph) {\n const replacement = paragraph.createAndFill() ?? paragraph.create();\n const tr = view.state.tr.replaceWith(sourcePos, sourceEnd, replacement);\n focusSelectionNear(view, tr, sourcePos + 1, 1);\n return;\n }\n\n const tr = view.state.tr.delete(sourcePos, sourceEnd);\n const selectionBias = sourcePos >= tr.doc.content.size ? -1 : 1;\n focusSelectionNear(view, tr, sourcePos, selectionBias);\n };\n\n const insertParagraphBelow = (context: DragHandleMenuContext) => {\n const resolved = resolveMenuContext(context);\n const paragraph = resolved?.view.state.schema.nodes.paragraph;\n if (!resolved || !paragraph) return;\n\n const insertPos = resolved.sourcePos + resolved.sourceNodeSize;\n const paragraphNode = paragraph.createAndFill() ?? paragraph.create();\n const tr = resolved.view.state.tr.insert(insertPos, paragraphNode);\n tr.setSelection(TextSelection.create(tr.doc, insertPos + 1));\n resolved.view.dispatch(tr.scrollIntoView());\n resolved.view.focus();\n };\n\n const positionMenu = (anchorRect: DOMRect) => {\n if (!menu) return;\n\n const viewportWidth = window.visualViewport?.width ?? window.innerWidth;\n const viewportHeight =\n window.visualViewport?.height ?? window.innerHeight;\n const menuHeight = menu.offsetHeight || 118;\n const preferredLeft = anchorRect.right + DRAG_HANDLE_MENU_GAP;\n const alternateLeft =\n anchorRect.left - DRAG_HANDLE_MENU_WIDTH - DRAG_HANDLE_MENU_GAP;\n const left =\n preferredLeft +\n DRAG_HANDLE_MENU_WIDTH +\n DRAG_HANDLE_MENU_VIEWPORT_PADDING <=\n viewportWidth\n ? preferredLeft\n : alternateLeft;\n\n menu.style.left = `${clamp(\n left,\n DRAG_HANDLE_MENU_VIEWPORT_PADDING,\n viewportWidth -\n DRAG_HANDLE_MENU_WIDTH -\n DRAG_HANDLE_MENU_VIEWPORT_PADDING,\n )}px`;\n menu.style.top = `${clamp(\n anchorRect.top - 4,\n DRAG_HANDLE_MENU_VIEWPORT_PADDING,\n viewportHeight - menuHeight - DRAG_HANDLE_MENU_VIEWPORT_PADDING,\n )}px`;\n };\n\n const createMenuItem = (\n label: string,\n iconModifier: string,\n action: (context: DragHandleMenuContext) => void,\n options: { danger?: boolean } = {},\n ) => {\n const button = document.createElement(\"button\");\n button.type = \"button\";\n button.className = \"an-rich-md-drag-menu__item\";\n button.setAttribute(\"role\", \"menuitem\");\n button.setAttribute(\"data-plan-interactive\", \"true\");\n if (options.danger) button.setAttribute(\"data-danger\", \"true\");\n\n const icon = document.createElement(\"span\");\n icon.className = `an-rich-md-drag-menu__icon an-rich-md-drag-menu__icon--${iconModifier}`;\n icon.setAttribute(\"aria-hidden\", \"true\");\n\n const labelElement = document.createElement(\"span\");\n labelElement.className = \"an-rich-md-drag-menu__label\";\n labelElement.textContent = label;\n\n button.append(icon, labelElement);\n button.addEventListener(\"mousedown\", (event) => {\n event.preventDefault();\n });\n button.addEventListener(\"click\", (event) => {\n event.preventDefault();\n event.stopPropagation();\n const context = menuContext;\n if (!context) return;\n closeMenu({ hideGrip: true });\n action(context);\n });\n\n return button;\n };\n\n const openMenu = (context: DragHandleMenuContext, anchorRect: DOMRect) => {\n const resolved = resolveMenuContext(context);\n if (!resolved) return;\n\n closeMenu();\n selectBlockAt(resolved.view, resolved.sourcePos);\n ensureDragHandleMenuStyles();\n\n const el = document.createElement(\"div\");\n el.className = \"an-rich-md-drag-menu\";\n el.setAttribute(\"role\", \"menu\");\n el.setAttribute(\"aria-label\", \"Block actions\");\n el.setAttribute(\"data-plan-interactive\", \"true\");\n\n el.append(\n createMenuItem(\"Duplicate\", \"duplicate\", duplicateBlock),\n createMenuItem(\"Delete\", \"delete\", deleteBlock, { danger: true }),\n createMenuItem(\"Insert block below\", \"insert\", insertParagraphBelow),\n );\n\n menu = el;\n menuContext = {\n view: resolved.view,\n sourceBlock: resolved.sourceBlock,\n sourcePos: resolved.sourcePos,\n sourceNodeSize: resolved.sourceNodeSize,\n };\n document.body.appendChild(el);\n positionMenu(anchorRect);\n handle?.setAttribute(\"aria-expanded\", \"true\");\n document.addEventListener(\"mousedown\", handleMenuDocumentMouseDown, {\n capture: true,\n });\n document.addEventListener(\"keydown\", handleMenuKeyDown, {\n capture: true,\n });\n window.addEventListener(\"resize\", handleMenuViewportChange);\n window.addEventListener(\"scroll\", handleMenuViewportChange, {\n capture: true,\n });\n\n el.querySelector<HTMLButtonElement>(\"button\")?.focus({\n preventScroll: true,\n });\n };\n\n const findDropTarget = (\n registration: DragHandleRegistration,\n clientX: number,\n clientY: number,\n ): DropTarget | null => {\n const view = registration.view;\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 let placement: DragHandleDropPlacement;\n const withinBlockY =\n clientY >= block.rect.top && clientY <= block.rect.bottom;\n const withinSideDropBand =\n clientY >= block.rect.top + block.rect.height * 0.2 &&\n clientY <= block.rect.bottom - block.rect.height * 0.2;\n const sideZoneWidth = clamp(\n block.rect.width * SIDE_DROP_ZONE_RATIO,\n SIDE_DROP_ZONE_MIN_PX,\n SIDE_DROP_ZONE_MAX_PX,\n );\n\n if (\n registration.handleDrop &&\n withinBlockY &&\n withinSideDropBand &&\n clientX <= block.rect.left + sideZoneWidth\n ) {\n placement = \"left\";\n } else if (\n registration.handleDrop &&\n withinBlockY &&\n withinSideDropBand &&\n clientX >= block.rect.right - sideZoneWidth\n ) {\n placement = \"right\";\n } else {\n placement =\n clientY < block.rect.top ||\n (clientY <= block.rect.bottom &&\n clientY < block.rect.top + block.rect.height / 2)\n ? \"before\"\n : \"after\";\n }\n const before = placement === \"before\" || placement === \"left\";\n\n return {\n registration,\n view,\n block: block.node,\n placement,\n pos: before ? block.pmPos : block.pmPos + node.nodeSize,\n targetPos: block.pmPos,\n targetNodeSize: node.nodeSize,\n rect: block.rect,\n };\n };\n\n const findAnyDropTarget = (\n session: DragSession,\n clientX: number,\n clientY: number,\n ): DropTarget | null => {\n const candidates: DropTarget[] = [];\n\n for (const registration of dragHandleRegistrations) {\n if (!registration.view.dom.isConnected) continue;\n if (\n registration.view !== session.view &&\n session.sourceBlock.contains(registration.view.dom)\n ) {\n continue;\n }\n const target = findDropTarget(registration, clientX, clientY);\n if (target) candidates.push(target);\n }\n\n candidates.sort((a, b) => {\n const aRect = a.view.dom.getBoundingClientRect();\n const bRect = b.view.dom.getBoundingClientRect();\n return aRect.width * aRect.height - bRect.width * bRect.height;\n });\n\n return candidates[0] ?? null;\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.view === session.view &&\n (target.pos === session.sourcePos ||\n target.pos === sourceEnd ||\n (target.pos > session.sourcePos && target.pos < sourceEnd)))\n ) {\n session.dropTarget = null;\n session.dropLine?.remove();\n session.dropLine = null;\n return;\n }\n\n const wrapper = target.view.dom.closest(\n target.registration.wrapperSelector,\n );\n if (!wrapper) return;\n\n if (!session.dropLine || session.dropLine.parentElement !== wrapper) {\n session.dropLine?.remove();\n session.dropLine = createDropLine(target.registration);\n }\n if (!session.dropLine) return;\n\n const wrapperRect = wrapper.getBoundingClientRect();\n const editorRect = target.view.dom.getBoundingClientRect();\n\n session.dropTarget = target;\n if (target.placement === \"left\" || target.placement === \"right\") {\n const left =\n target.placement === \"left\" ? target.rect.left : target.rect.right;\n session.dropLine.style.left = `${left - wrapperRect.left}px`;\n session.dropLine.style.top = `${target.rect.top - wrapperRect.top}px`;\n session.dropLine.style.width = \"3px\";\n session.dropLine.style.height = `${target.rect.height}px`;\n return;\n }\n\n const top =\n target.placement === \"before\" ? target.rect.top : target.rect.bottom;\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 session.dropLine.style.height = \"3px\";\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.tabIndex = 0;\n el.setAttribute(\"role\", \"button\");\n el.setAttribute(\"aria-label\", \"Open block menu or drag to reorder\");\n el.setAttribute(\"aria-haspopup\", \"menu\");\n el.setAttribute(\"aria-expanded\", \"false\");\n el.title = \"Open block menu or drag to reorder\";\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 (menu) return;\n forceHideHandle();\n };\n\n const removeDragListeners = () => {\n document.removeEventListener(\"mousemove\", handleDocumentMouseMove);\n document.removeEventListener(\"mouseup\", handleDocumentMouseUp);\n document.removeEventListener(\"keydown\", handleDocumentKeyDown);\n };\n\n function handleMenuDocumentMouseDown(event: MouseEvent) {\n const target = event.target;\n if (!(target instanceof Node)) return;\n if (menu?.contains(target) || handle?.contains(target)) return;\n closeMenu({ hideGrip: true });\n }\n\n function handleMenuKeyDown(event: KeyboardEvent) {\n if (!menu) return;\n\n if (event.key === \"Escape\") {\n event.preventDefault();\n closeMenu({ hideGrip: true });\n return;\n }\n\n if (\n event.key !== \"ArrowDown\" &&\n event.key !== \"ArrowUp\" &&\n event.key !== \"Home\" &&\n event.key !== \"End\"\n ) {\n return;\n }\n\n const buttons = Array.from(\n menu.querySelectorAll<HTMLButtonElement>(\"button\"),\n );\n if (buttons.length === 0) return;\n\n event.preventDefault();\n const activeIndex = buttons.indexOf(\n document.activeElement as HTMLButtonElement,\n );\n let nextIndex = activeIndex < 0 ? 0 : activeIndex;\n\n if (event.key === \"ArrowDown\") {\n nextIndex = (nextIndex + 1) % buttons.length;\n } else if (event.key === \"ArrowUp\") {\n nextIndex = (nextIndex - 1 + buttons.length) % buttons.length;\n } else if (event.key === \"Home\") {\n nextIndex = 0;\n } else if (event.key === \"End\") {\n nextIndex = buttons.length - 1;\n }\n\n buttons[nextIndex]?.focus({ preventScroll: true });\n }\n\n function handleMenuViewportChange() {\n closeMenu({ hideGrip: true });\n }\n\n const finishDragSession = (commit: boolean, event?: MouseEvent) => {\n const session = dragSession;\n if (!session) return;\n\n removeDragListeners();\n\n if (commit && session.dragging && session.dropTarget) {\n const sourceStart = session.sourcePos;\n const sourceEnd = session.sourcePos + session.sourceNodeSize;\n const target = session.dropTarget;\n const dropPos = target.pos;\n\n if (\n target.view !== session.view ||\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 sourceRegistration = registrationForView(session.view);\n const transferData = sourceRegistration?.getDragTransferData?.({\n view: session.view,\n node: sourceNode,\n pos: sourceStart,\n });\n const targetNode = target.view.state.doc.nodeAt(target.targetPos);\n const handled =\n !!targetNode &&\n (target.registration.handleDrop?.(transferData, {\n view: target.view,\n sourceView: session.view,\n sourceNode,\n sourcePos: sourceStart,\n sourceNodeSize: sourceNode.nodeSize,\n targetNode,\n targetPos: target.targetPos,\n targetNodeSize: target.targetNodeSize,\n insertPos: dropPos,\n placement: target.placement,\n }) ??\n false);\n\n if (handled) {\n target.view.focus();\n } else if (target.view === session.view) {\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 } else {\n try {\n const targetNode = target.view.state.schema.nodeFromJSON(\n sourceNode.toJSON(),\n );\n target.registration.receiveDragTransferData?.(transferData, {\n view: target.view,\n node: targetNode,\n pos: dropPos,\n sourceView: session.view,\n });\n const insertTr = target.view.state.tr.insert(\n dropPos,\n targetNode,\n );\n insertTr.setSelection(\n NodeSelection.create(insertTr.doc, dropPos),\n );\n target.view.dispatch(insertTr.scrollIntoView());\n\n const deleteTr = session.view.state.tr.delete(\n sourceStart,\n sourceEnd,\n );\n session.view.dispatch(deleteTr);\n target.view.focus();\n } catch {\n // If the target schema cannot accept this node, leave the\n // source document untouched.\n }\n }\n }\n }\n } else if (commit && !session.dragging && event) {\n openMenu(\n {\n view: session.view,\n sourceBlock: session.sourceBlock,\n sourcePos: session.sourcePos,\n sourceNodeSize: session.sourceNodeSize,\n },\n handle?.getBoundingClientRect() ??\n session.sourceBlock.getBoundingClientRect(),\n );\n }\n\n cleanupDragVisuals();\n dragSession = null;\n if (activeDragRegistration === currentRegistration) {\n activeDragRegistration = null;\n }\n if (session.dragging || !commit) 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 findAnyDropTarget(session, 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 findAnyDropTarget(dragSession, event.clientX, event.clientY),\n );\n }\n\n function handleDocumentMouseUp(event: MouseEvent) {\n event.preventDefault();\n finishDragSession(true, event);\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 const registration: DragHandleRegistration = {\n view: editorView,\n wrapperSelector,\n getDragTransferData,\n receiveDragTransferData,\n handleDrop,\n canHover: () =>\n !!handle && !menu && !dragSession && editor.isEditable,\n findHoverBlock: (clientX, clientY) =>\n findForgivingBlock(editorView, clientX, clientY),\n showHoverBlock: (block) => showHandleForBlock(editorView, block),\n hideHover: () => hideHandle(),\n };\n currentRegistration = registration;\n dragHandleRegistrations.add(registration);\n retainGlobalHoverListener();\n handle = createHandle();\n const wrapper = editorView.dom.closest(wrapperSelector);\n if (wrapper) {\n (wrapper as HTMLElement).style.position = \"relative\";\n wrapper.appendChild(handle);\n }\n\n handle.addEventListener(\"mousedown\", (e) => {\n e.stopPropagation();\n if (e.button !== 0) return;\n closeMenu();\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 dropTarget: null,\n };\n activeDragRegistration = registration;\n\n document.addEventListener(\"mousemove\", handleDocumentMouseMove);\n document.addEventListener(\"mouseup\", handleDocumentMouseUp);\n document.addEventListener(\"keydown\", handleDocumentKeyDown);\n });\n\n handle.addEventListener(\"keydown\", (e) => {\n if (e.key !== \"Enter\" && e.key !== \" \") return;\n e.preventDefault();\n e.stopPropagation();\n closeMenu();\n if (!editor.isEditable || !currentBlock || dragStartPos === null) {\n return;\n }\n\n const sourceNode = editorView.state.doc.nodeAt(dragStartPos);\n if (!sourceNode) return;\n\n openMenu(\n {\n view: editorView,\n sourceBlock: currentBlock,\n sourcePos: dragStartPos,\n sourceNodeSize: sourceNode.nodeSize,\n },\n handle?.getBoundingClientRect() ??\n currentBlock.getBoundingClientRect(),\n );\n });\n\n return {\n destroy() {\n closeMenu({ hideGrip: true });\n finishDragSession(false);\n releaseGlobalHoverListener();\n dragHandleRegistrations.delete(registration);\n if (activeDragRegistration === registration) {\n activeDragRegistration = null;\n }\n handle?.remove();\n handle = null;\n currentRegistration = null;\n },\n };\n },\n props: {\n handleDOMEvents: {\n mousemove(_view, event) {\n updateRegisteredHover(event.clientX, event.clientY);\n return false;\n },\n drop() {\n closeMenu({ hideGrip: true });\n finishDragSession(false);\n hideHandle();\n return false;\n },\n },\n },\n }),\n ];\n },\n});\n"]}
|
|
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,EACL,MAAM,EACN,SAAS,EACT,aAAa,EACb,aAAa,GAEd,MAAM,kBAAkB,CAAC;AAI1B;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,oCAAoC,GAAG,wBAAwB,CAAC;AAgD7E,MAAM,aAAa,GAAG,IAAI,SAAS,CAAC,YAAY,CAAC,CAAC;AAClD,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAChC,MAAM,oBAAoB,GAAG,IAAI,CAAC;AAClC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AACjC,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAClC,MAAM,yBAAyB,GAAG,6BAA6B,CAAC;AAChE,MAAM,sBAAsB,GAAG,GAAG,CAAC;AACnC,MAAM,oBAAoB,GAAG,CAAC,CAAC;AAC/B,MAAM,iCAAiC,GAAG,CAAC,CAAC;AAkE5C,MAAM,uBAAuB,GAAG,IAAI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SAAS,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;4BAC9B,iBAAiB,CAAC,KAAK,CAAC,CAAC;4BACzB,0BAA0B,EAAE,CAAC;4BAC7B,uBAAuB,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;4BAC7C,IAAI,sBAAsB,KAAK,YAAY,EAAE,CAAC;gCAC5C,sBAAsB,GAAG,IAAI,CAAC;4BAChC,CAAC;4BACD,MAAM,EAAE,MAAM,EAAE,CAAC;4BACjB,MAAM,GAAG,IAAI,CAAC;4BACd,mBAAmB,GAAG,IAAI,CAAC;wBAC7B,CAAC;qBACF,CAAC;gBACJ,CAAC;gBACD,KAAK,EAAE;oBACL,eAAe,EAAE;wBACf,SAAS,CAAC,KAAK,EAAE,KAAK;4BACpB,qBAAqB,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;4BACpD,OAAO,KAAK,CAAC;wBACf,CAAC;wBACD,IAAI;4BACF,SAAS,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;4BAC9B,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 {\n Plugin,\n PluginKey,\n NodeSelection,\n TextSelection,\n type Transaction,\n} from \"@tiptap/pm/state\";\nimport type { Node as ProseMirrorNode } from \"@tiptap/pm/model\";\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 * Optional source-side payload for a cross-editor block move. The editor doc\n * carries ProseMirror node content, but app-owned side-map data (for example a\n * plan `diagram` block's HTML/CSS) can live outside the doc; this lets the\n * host carry that data to the receiving editor before the node is inserted.\n */\n getDragTransferData?: (context: {\n view: EditorView;\n node: ProseMirrorNode;\n pos: number;\n }) => unknown;\n /**\n * Optional target-side receiver for cross-editor transfer data. Called before\n * the node is inserted into the target editor so the target's serializer can\n * resolve app-owned data during the synchronous ProseMirror update.\n */\n receiveDragTransferData?: (\n data: unknown,\n context: {\n view: EditorView;\n node: ProseMirrorNode;\n pos: number;\n sourceView: EditorView;\n },\n ) => void;\n /**\n * Optional host-level drop handler for document-specific structure changes.\n * Returning true tells the shared drag handle that the host fully handled the\n * move and no ProseMirror insert/delete should run. This is used for\n * Notion-style side drops where dropping a block to the left/right creates or\n * inserts into a column layout rather than inserting into the target editor.\n */\n handleDrop?: (data: unknown, context: DragHandleDropContext) => boolean;\n}\n\nconst dragHandleKey = new PluginKey(\"dragHandle\");\nconst HOVER_SIDE_OUTSET_REM = 8;\nconst SIDE_DROP_ZONE_RATIO = 0.28;\nconst SIDE_DROP_ZONE_MIN_PX = 48;\nconst SIDE_DROP_ZONE_MAX_PX = 140;\nconst DRAG_HANDLE_MENU_STYLE_ID = \"an-rich-md-drag-menu-styles\";\nconst DRAG_HANDLE_MENU_WIDTH = 220;\nconst DRAG_HANDLE_MENU_GAP = 6;\nconst DRAG_HANDLE_MENU_VIEWPORT_PADDING = 8;\n\ntype DropTarget = {\n registration: DragHandleRegistration;\n view: EditorView;\n block: HTMLElement;\n placement: DragHandleDropPlacement;\n pos: number;\n targetPos: number;\n targetNodeSize: number;\n rect: DOMRect;\n};\n\nexport type DragHandleDropPlacement = \"before\" | \"after\" | \"left\" | \"right\";\n\nexport type DragHandleDropContext = {\n view: EditorView;\n sourceView: EditorView;\n sourceNode: ProseMirrorNode;\n sourcePos: number;\n sourceNodeSize: number;\n targetNode: ProseMirrorNode;\n targetPos: number;\n targetNodeSize: number;\n insertPos: number;\n placement: DragHandleDropPlacement;\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 dropTarget: DropTarget | null;\n};\n\ntype HoverBlock = {\n node: HTMLElement;\n pmPos: number;\n rect: DOMRect;\n};\n\ntype DragHandleMenuContext = {\n view: EditorView;\n sourceBlock: HTMLElement;\n sourcePos: number;\n sourceNodeSize: number;\n};\n\ntype DragHandleRegistration = {\n view: EditorView;\n wrapperSelector: string;\n getDragTransferData?: DragHandleOptions[\"getDragTransferData\"];\n receiveDragTransferData?: DragHandleOptions[\"receiveDragTransferData\"];\n handleDrop?: DragHandleOptions[\"handleDrop\"];\n canHover?: () => boolean;\n findHoverBlock?: (clientX: number, clientY: number) => HoverBlock | null;\n showHoverBlock?: (block: HoverBlock) => void;\n hideHover?: () => void;\n};\n\nconst dragHandleRegistrations = new Set<DragHandleRegistration>();\nlet dragHandleGlobalHoverListeners = 0;\nlet activeDragRegistration: DragHandleRegistration | null = null;\n\nconst clamp = (value: number, min: number, max: number) =>\n Math.min(Math.max(value, min), max);\n\nconst editorArea = (registration: DragHandleRegistration) => {\n const rect = registration.view.dom.getBoundingClientRect();\n return rect.width * rect.height;\n};\n\nconst updateRegisteredHover = (clientX: number, clientY: number) => {\n if (activeDragRegistration) {\n for (const registration of dragHandleRegistrations) {\n registration.hideHover?.();\n }\n return;\n }\n\n const candidates: Array<{\n registration: DragHandleRegistration;\n block: HoverBlock;\n }> = [];\n\n for (const registration of dragHandleRegistrations) {\n if (!registration.view.dom.isConnected || !registration.canHover?.()) {\n registration.hideHover?.();\n continue;\n }\n const block = registration.findHoverBlock?.(clientX, clientY);\n if (block) {\n candidates.push({ registration, block });\n } else {\n registration.hideHover?.();\n }\n }\n\n // Pick which editor owns the grip when several register a hover block at this\n // point. Nested region editors (e.g. each column inside a `columns` block) tile\n // their container's whole footprint AND extend a wide forgiving zone\n // (HOVER_SIDE_OUTSET_REM) into its left-margin gutter, so a pure\n // \"smallest editor wins\" rule lets an inner block beat the container everywhere\n // and leaves the container itself impossible to grab. Split candidates by where\n // the cursor sits relative to each block:\n // - Over a block's body (clientX at/after its left edge) the innermost\n // (smallest) editor wins, so nested blocks stay grabbable from their content.\n // - In the shared left-margin gutter (clientX left of every candidate's\n // content, where the grip lives) the outermost (largest) editor wins, so the\n // container block can be picked up and reordered.\n // Prefer the candidate whose block actually sits UNDER the cursor\n // horizontally. Without this, a left column's forgiving side zone reaches\n // across the inter-column gap, ties the right column's editor on area, and\n // wins — so hovering a right-column block shows the grip for the LEFT block\n // (and right-column blocks appear to have no grip at all). `overContent`\n // restricts to blocks the cursor is genuinely within; `rightOfLeftEdge` keeps\n // the gutter-grab behaviour; fully left of every block → the container wins.\n const overContent = candidates.filter(\n (candidate) =>\n clientX >= candidate.block.rect.left &&\n clientX <= candidate.block.rect.right,\n );\n // The grip renders in a narrow band just LEFT of each block (≈24px). A block\n // must OWN that band so moving the cursor onto its grip keeps showing (and\n // lets you press) that block's grip — otherwise, for a column block whose grip\n // sits in the gutter/inter-column gap, the \"gutter → largest editor\" rule\n // below would flip the hover to the columns container and the grip would\n // vanish out from under the cursor, making inner column blocks impossible to\n // drag. The band is narrow, so it does not collide with the neighbouring\n // column's content (the right column's grip lives in the inter-column gap,\n // left of its own content but right of the left column's content).\n const GRIP_HOVER_ZONE_PX = 28;\n const overGrip = candidates.filter(\n (candidate) =>\n clientX >= candidate.block.rect.left - GRIP_HOVER_ZONE_PX &&\n clientX < candidate.block.rect.left,\n );\n const rightOfLeftEdge = candidates.filter(\n (candidate) => clientX >= candidate.block.rect.left,\n );\n let active: {\n registration: DragHandleRegistration;\n block: HoverBlock;\n } | null;\n const innerPool =\n overContent.length > 0\n ? overContent\n : overGrip.length > 0\n ? overGrip\n : rightOfLeftEdge;\n if (innerPool.length > 0) {\n innerPool.sort(\n (a, b) => editorArea(a.registration) - editorArea(b.registration),\n );\n active = innerPool[0];\n } else {\n candidates.sort(\n (a, b) => editorArea(b.registration) - editorArea(a.registration),\n );\n active = candidates[0] ?? null;\n }\n\n for (const registration of dragHandleRegistrations) {\n if (registration !== active?.registration) registration.hideHover?.();\n }\n active?.registration.showHoverBlock?.(active.block);\n};\n\nconst handleGlobalHoverMove = (event: MouseEvent) => {\n updateRegisteredHover(event.clientX, event.clientY);\n};\n\nconst retainGlobalHoverListener = () => {\n dragHandleGlobalHoverListeners += 1;\n if (dragHandleGlobalHoverListeners === 1) {\n document.addEventListener(\"mousemove\", handleGlobalHoverMove);\n }\n};\n\nconst releaseGlobalHoverListener = () => {\n dragHandleGlobalHoverListeners = Math.max(\n 0,\n dragHandleGlobalHoverListeners - 1,\n );\n if (dragHandleGlobalHoverListeners === 0) {\n document.removeEventListener(\"mousemove\", handleGlobalHoverMove);\n }\n};\n\nconst ensureDragHandleMenuStyles = () => {\n if (document.getElementById(DRAG_HANDLE_MENU_STYLE_ID)) return;\n\n const style = document.createElement(\"style\");\n style.id = DRAG_HANDLE_MENU_STYLE_ID;\n style.textContent = `\n.an-rich-md-drag-menu {\n position: fixed;\n z-index: 9999;\n width: ${DRAG_HANDLE_MENU_WIDTH}px;\n padding: 4px;\n border: 1px solid hsl(var(--border, 214.3 31.8% 91.4%));\n border-radius: 7px;\n background: hsl(var(--popover, 0 0% 100%));\n color: hsl(var(--popover-foreground, var(--foreground, 222.2 84% 4.9%)));\n box-shadow:\n 0 12px 32px rgb(15 23 42 / 0.16),\n 0 2px 8px rgb(15 23 42 / 0.08);\n font-family: inherit;\n font-size: 13px;\n line-height: 1.35;\n}\n\n.an-rich-md-drag-menu__item {\n display: flex;\n width: 100%;\n align-items: center;\n gap: 9px;\n border: 0;\n border-radius: 5px;\n background: transparent;\n color: inherit;\n cursor: pointer;\n font: inherit;\n letter-spacing: 0;\n padding: 7px 8px;\n text-align: left;\n}\n\n.an-rich-md-drag-menu__item:hover,\n.an-rich-md-drag-menu__item:focus-visible {\n background: hsl(var(--accent, 210 40% 96.1%));\n color: hsl(var(--accent-foreground, var(--foreground, 222.2 84% 4.9%)));\n outline: none;\n}\n\n.an-rich-md-drag-menu__item[data-danger=\"true\"] {\n color: hsl(var(--destructive, 0 84.2% 60.2%));\n}\n\n.an-rich-md-drag-menu__item[data-danger=\"true\"]:hover,\n.an-rich-md-drag-menu__item[data-danger=\"true\"]:focus-visible {\n background: hsl(var(--destructive, 0 84.2% 60.2%) / 0.1);\n}\n\n.an-rich-md-drag-menu__icon {\n position: relative;\n flex: 0 0 auto;\n width: 18px;\n height: 18px;\n color: hsl(var(--muted-foreground, 215.4 16.3% 46.9%));\n}\n\n.an-rich-md-drag-menu__item[data-danger=\"true\"] .an-rich-md-drag-menu__icon {\n color: currentColor;\n}\n\n.an-rich-md-drag-menu__icon::before,\n.an-rich-md-drag-menu__icon::after {\n content: \"\";\n position: absolute;\n box-sizing: border-box;\n}\n\n.an-rich-md-drag-menu__icon--duplicate::before,\n.an-rich-md-drag-menu__icon--duplicate::after {\n width: 11px;\n height: 11px;\n border: 1.5px solid currentColor;\n border-radius: 2px;\n}\n\n.an-rich-md-drag-menu__icon--duplicate::before {\n left: 6px;\n top: 2px;\n opacity: 0.55;\n}\n\n.an-rich-md-drag-menu__icon--duplicate::after {\n left: 2px;\n top: 6px;\n background: hsl(var(--popover, 0 0% 100%));\n}\n\n.an-rich-md-drag-menu__icon--insert::before {\n left: 3px;\n top: 8px;\n width: 12px;\n height: 1.5px;\n border-radius: 999px;\n background: currentColor;\n}\n\n.an-rich-md-drag-menu__icon--insert::after {\n left: 8px;\n top: 3px;\n width: 1.5px;\n height: 12px;\n border-radius: 999px;\n background: currentColor;\n}\n\n.an-rich-md-drag-menu__icon--delete::before {\n left: 4px;\n top: 7px;\n width: 10px;\n height: 11px;\n border: 1.5px solid currentColor;\n border-top: 0;\n border-radius: 0 0 2px 2px;\n}\n\n.an-rich-md-drag-menu__icon--delete::after {\n left: 3px;\n top: 4px;\n width: 12px;\n height: 1.5px;\n border-radius: 999px;\n background: currentColor;\n box-shadow: 3px -2.5px 0 -0.4px currentColor;\n}\n\n.an-rich-md-drag-menu__label {\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n`;\n document.head.appendChild(style);\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 * - Single-clicking the grip selects the block and opens a block action menu.\n * Dragging past a small threshold starts a reorder, showing a floating clone\n * preview (`.notion-drag-preview`) and a `.notion-drop-indicator` line.\n * `Escape` 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 getDragTransferData: undefined,\n receiveDragTransferData: undefined,\n };\n },\n\n addProseMirrorPlugins() {\n const editor = this.editor;\n const wrapperSelector = this.options.wrapperSelector;\n const getDragTransferData = this.options.getDragTransferData;\n const receiveDragTransferData = this.options.receiveDragTransferData;\n const handleDrop = this.options.handleDrop;\n let handle: HTMLElement | null = null;\n let menu: HTMLElement | null = null;\n let menuContext: DragHandleMenuContext | null = null;\n let currentBlock: HTMLElement | null = null;\n let dragStartPos: number | null = null;\n let dragSession: DragSession | null = null;\n let currentRegistration: DragHandleRegistration | 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 registrationForView = (\n editorView: EditorView,\n ): DragHandleRegistration | null => {\n for (const registration of dragHandleRegistrations) {\n if (registration.view === editorView) return registration;\n }\n return null;\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 selectBlockAt = (editorView: EditorView, pos: number) => {\n try {\n const sel = NodeSelection.create(editorView.state.doc, pos);\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 = (\n registration: DragHandleRegistration,\n ): HTMLElement | null => {\n const wrapper = registration.view.dom.closest(\n registration.wrapperSelector,\n );\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 forceHideHandle = () => {\n if (handle) {\n handle.style.display = \"none\";\n handle.setAttribute(\"aria-expanded\", \"false\");\n }\n currentBlock = null;\n dragStartPos = null;\n };\n\n const closeMenu = ({ hideGrip = false }: { hideGrip?: boolean } = {}) => {\n menu?.remove();\n menu = null;\n menuContext = null;\n handle?.setAttribute(\"aria-expanded\", \"false\");\n document.removeEventListener(\"mousedown\", handleMenuDocumentMouseDown, {\n capture: true,\n });\n document.removeEventListener(\"keydown\", handleMenuKeyDown, {\n capture: true,\n });\n window.removeEventListener(\"resize\", handleMenuViewportChange);\n window.removeEventListener(\"scroll\", handleMenuViewportChange, {\n capture: true,\n });\n if (hideGrip) forceHideHandle();\n };\n\n const resolveMenuContext = (context: DragHandleMenuContext) => {\n const latestBlock = getTopLevelBlocks(context.view).find(\n (block) => block.node === context.sourceBlock,\n );\n const sourcePos = latestBlock?.pmPos ?? context.sourcePos;\n const sourceNode = context.view.state.doc.nodeAt(sourcePos);\n if (!sourceNode) return null;\n\n return {\n ...context,\n sourcePos,\n sourceNode,\n sourceNodeSize: sourceNode.nodeSize,\n };\n };\n\n const focusSelectionNear = (\n view: EditorView,\n tr: Transaction,\n pos: number,\n bias: -1 | 1,\n ) => {\n tr.setSelection(\n TextSelection.near(\n tr.doc.resolve(clamp(pos, 0, tr.doc.content.size)),\n bias,\n ),\n );\n view.dispatch(tr.scrollIntoView());\n view.focus();\n };\n\n const duplicateBlock = (context: DragHandleMenuContext) => {\n const resolved = resolveMenuContext(context);\n if (!resolved) return;\n\n const insertPos = resolved.sourcePos + resolved.sourceNodeSize;\n const tr = resolved.view.state.tr.insert(insertPos, resolved.sourceNode);\n\n try {\n tr.setSelection(NodeSelection.create(tr.doc, insertPos));\n resolved.view.dispatch(tr.scrollIntoView());\n resolved.view.focus();\n } catch {\n focusSelectionNear(resolved.view, tr, insertPos, 1);\n }\n };\n\n const deleteBlock = (context: DragHandleMenuContext) => {\n const resolved = resolveMenuContext(context);\n if (!resolved) return;\n\n const { view, sourcePos, sourceNodeSize } = resolved;\n const paragraph = view.state.schema.nodes.paragraph;\n const sourceEnd = sourcePos + sourceNodeSize;\n\n if (view.state.doc.childCount <= 1 && paragraph) {\n const replacement = paragraph.createAndFill() ?? paragraph.create();\n const tr = view.state.tr.replaceWith(sourcePos, sourceEnd, replacement);\n focusSelectionNear(view, tr, sourcePos + 1, 1);\n return;\n }\n\n const tr = view.state.tr.delete(sourcePos, sourceEnd);\n const selectionBias = sourcePos >= tr.doc.content.size ? -1 : 1;\n focusSelectionNear(view, tr, sourcePos, selectionBias);\n };\n\n const insertParagraphBelow = (context: DragHandleMenuContext) => {\n const resolved = resolveMenuContext(context);\n const paragraph = resolved?.view.state.schema.nodes.paragraph;\n if (!resolved || !paragraph) return;\n\n const insertPos = resolved.sourcePos + resolved.sourceNodeSize;\n const paragraphNode = paragraph.createAndFill() ?? paragraph.create();\n const tr = resolved.view.state.tr.insert(insertPos, paragraphNode);\n tr.setSelection(TextSelection.create(tr.doc, insertPos + 1));\n resolved.view.dispatch(tr.scrollIntoView());\n resolved.view.focus();\n };\n\n const positionMenu = (anchorRect: DOMRect) => {\n if (!menu) return;\n\n const viewportWidth = window.visualViewport?.width ?? window.innerWidth;\n const viewportHeight =\n window.visualViewport?.height ?? window.innerHeight;\n const menuHeight = menu.offsetHeight || 118;\n const preferredLeft = anchorRect.right + DRAG_HANDLE_MENU_GAP;\n const alternateLeft =\n anchorRect.left - DRAG_HANDLE_MENU_WIDTH - DRAG_HANDLE_MENU_GAP;\n const left =\n preferredLeft +\n DRAG_HANDLE_MENU_WIDTH +\n DRAG_HANDLE_MENU_VIEWPORT_PADDING <=\n viewportWidth\n ? preferredLeft\n : alternateLeft;\n\n menu.style.left = `${clamp(\n left,\n DRAG_HANDLE_MENU_VIEWPORT_PADDING,\n viewportWidth -\n DRAG_HANDLE_MENU_WIDTH -\n DRAG_HANDLE_MENU_VIEWPORT_PADDING,\n )}px`;\n menu.style.top = `${clamp(\n anchorRect.top - 4,\n DRAG_HANDLE_MENU_VIEWPORT_PADDING,\n viewportHeight - menuHeight - DRAG_HANDLE_MENU_VIEWPORT_PADDING,\n )}px`;\n };\n\n const createMenuItem = (\n label: string,\n iconModifier: string,\n action: (context: DragHandleMenuContext) => void,\n options: { danger?: boolean } = {},\n ) => {\n const button = document.createElement(\"button\");\n button.type = \"button\";\n button.className = \"an-rich-md-drag-menu__item\";\n button.setAttribute(\"role\", \"menuitem\");\n button.setAttribute(\"data-plan-interactive\", \"true\");\n if (options.danger) button.setAttribute(\"data-danger\", \"true\");\n\n const icon = document.createElement(\"span\");\n icon.className = `an-rich-md-drag-menu__icon an-rich-md-drag-menu__icon--${iconModifier}`;\n icon.setAttribute(\"aria-hidden\", \"true\");\n\n const labelElement = document.createElement(\"span\");\n labelElement.className = \"an-rich-md-drag-menu__label\";\n labelElement.textContent = label;\n\n button.append(icon, labelElement);\n button.addEventListener(\"mousedown\", (event) => {\n event.preventDefault();\n });\n button.addEventListener(\"click\", (event) => {\n event.preventDefault();\n event.stopPropagation();\n const context = menuContext;\n if (!context) return;\n closeMenu({ hideGrip: true });\n action(context);\n });\n\n return button;\n };\n\n const openMenu = (context: DragHandleMenuContext, anchorRect: DOMRect) => {\n const resolved = resolveMenuContext(context);\n if (!resolved) return;\n\n closeMenu();\n selectBlockAt(resolved.view, resolved.sourcePos);\n ensureDragHandleMenuStyles();\n\n const el = document.createElement(\"div\");\n el.className = \"an-rich-md-drag-menu\";\n el.setAttribute(\"role\", \"menu\");\n el.setAttribute(\"aria-label\", \"Block actions\");\n el.setAttribute(\"data-plan-interactive\", \"true\");\n\n el.append(\n createMenuItem(\"Duplicate\", \"duplicate\", duplicateBlock),\n createMenuItem(\"Delete\", \"delete\", deleteBlock, { danger: true }),\n createMenuItem(\"Insert block below\", \"insert\", insertParagraphBelow),\n );\n\n menu = el;\n menuContext = {\n view: resolved.view,\n sourceBlock: resolved.sourceBlock,\n sourcePos: resolved.sourcePos,\n sourceNodeSize: resolved.sourceNodeSize,\n };\n document.body.appendChild(el);\n positionMenu(anchorRect);\n handle?.setAttribute(\"aria-expanded\", \"true\");\n document.addEventListener(\"mousedown\", handleMenuDocumentMouseDown, {\n capture: true,\n });\n document.addEventListener(\"keydown\", handleMenuKeyDown, {\n capture: true,\n });\n window.addEventListener(\"resize\", handleMenuViewportChange);\n window.addEventListener(\"scroll\", handleMenuViewportChange, {\n capture: true,\n });\n\n el.querySelector<HTMLButtonElement>(\"button\")?.focus({\n preventScroll: true,\n });\n };\n\n const findDropTarget = (\n registration: DragHandleRegistration,\n clientX: number,\n clientY: number,\n ): DropTarget | null => {\n const view = registration.view;\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 let placement: DragHandleDropPlacement;\n const withinBlockY =\n clientY >= block.rect.top && clientY <= block.rect.bottom;\n const withinSideDropBand =\n clientY >= block.rect.top + block.rect.height * 0.2 &&\n clientY <= block.rect.bottom - block.rect.height * 0.2;\n const sideZoneWidth = clamp(\n block.rect.width * SIDE_DROP_ZONE_RATIO,\n SIDE_DROP_ZONE_MIN_PX,\n SIDE_DROP_ZONE_MAX_PX,\n );\n\n if (\n registration.handleDrop &&\n withinBlockY &&\n withinSideDropBand &&\n clientX <= block.rect.left + sideZoneWidth\n ) {\n placement = \"left\";\n } else if (\n registration.handleDrop &&\n withinBlockY &&\n withinSideDropBand &&\n clientX >= block.rect.right - sideZoneWidth\n ) {\n placement = \"right\";\n } else {\n placement =\n clientY < block.rect.top ||\n (clientY <= block.rect.bottom &&\n clientY < block.rect.top + block.rect.height / 2)\n ? \"before\"\n : \"after\";\n }\n const before = placement === \"before\" || placement === \"left\";\n\n return {\n registration,\n view,\n block: block.node,\n placement,\n pos: before ? block.pmPos : block.pmPos + node.nodeSize,\n targetPos: block.pmPos,\n targetNodeSize: node.nodeSize,\n rect: block.rect,\n };\n };\n\n const findAnyDropTarget = (\n session: DragSession,\n clientX: number,\n clientY: number,\n ): DropTarget | null => {\n const candidates: DropTarget[] = [];\n\n for (const registration of dragHandleRegistrations) {\n if (!registration.view.dom.isConnected) continue;\n if (\n registration.view !== session.view &&\n session.sourceBlock.contains(registration.view.dom)\n ) {\n continue;\n }\n const target = findDropTarget(registration, clientX, clientY);\n if (target) candidates.push(target);\n }\n\n candidates.sort((a, b) => {\n const aRect = a.view.dom.getBoundingClientRect();\n const bRect = b.view.dom.getBoundingClientRect();\n return aRect.width * aRect.height - bRect.width * bRect.height;\n });\n\n return candidates[0] ?? null;\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 const isSideDrop =\n target?.placement === \"left\" || target?.placement === \"right\";\n if (\n !target ||\n (target.view === session.view &&\n (isSideDrop\n ? // A side drop only ever builds columns; the ProseMirror seam\n // position is irrelevant. The only no-op is dropping a block on\n // ITS OWN side — adjacent *different* blocks must still form\n // columns (otherwise dropping onto an immediate neighbour's\n // facing edge silently does nothing, which reads as \"side drop\n // works sometimes\").\n target.targetPos === session.sourcePos\n : target.pos === session.sourcePos ||\n target.pos === sourceEnd ||\n (target.pos > session.sourcePos && target.pos < sourceEnd)))\n ) {\n session.dropTarget = null;\n session.dropLine?.remove();\n session.dropLine = null;\n return;\n }\n\n const wrapper = target.view.dom.closest(\n target.registration.wrapperSelector,\n );\n if (!wrapper) return;\n\n if (!session.dropLine || session.dropLine.parentElement !== wrapper) {\n session.dropLine?.remove();\n session.dropLine = createDropLine(target.registration);\n }\n if (!session.dropLine) return;\n\n const wrapperRect = wrapper.getBoundingClientRect();\n const editorRect = target.view.dom.getBoundingClientRect();\n\n session.dropTarget = target;\n if (target.placement === \"left\" || target.placement === \"right\") {\n const left =\n target.placement === \"left\" ? target.rect.left : target.rect.right;\n session.dropLine.style.left = `${left - wrapperRect.left}px`;\n session.dropLine.style.top = `${target.rect.top - wrapperRect.top}px`;\n session.dropLine.style.width = \"3px\";\n session.dropLine.style.height = `${target.rect.height}px`;\n return;\n }\n\n const top =\n target.placement === \"before\" ? target.rect.top : target.rect.bottom;\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 session.dropLine.style.height = \"3px\";\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.tabIndex = 0;\n el.setAttribute(\"role\", \"button\");\n el.setAttribute(\"aria-label\", \"Open block menu or drag to reorder\");\n el.setAttribute(\"aria-haspopup\", \"menu\");\n el.setAttribute(\"aria-expanded\", \"false\");\n el.title = \"Open block menu or drag to reorder\";\n // The icon must not be its own hit target: a real mouse-down inside a\n // nested editor (a column) lands on the SVG, and a container block's\n // capture-phase block-select handler (RegistryBlockNode) only spares the\n // grip DIV — so a press on the icon gets swallowed and the block can't be\n // dragged out of / between columns. `pointer-events:none` makes every\n // press in the grip area resolve to the DIV instead.\n el.innerHTML = `<svg width=\"14\" height=\"14\" viewBox=\"0 0 16 16\" fill=\"currentColor\" style=\"pointer-events:none\">\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 (menu) return;\n forceHideHandle();\n };\n\n const removeDragListeners = () => {\n document.removeEventListener(\"mousemove\", handleDocumentMouseMove);\n document.removeEventListener(\"mouseup\", handleDocumentMouseUp);\n document.removeEventListener(\"keydown\", handleDocumentKeyDown);\n };\n\n function handleMenuDocumentMouseDown(event: MouseEvent) {\n const target = event.target;\n if (!(target instanceof Node)) return;\n if (menu?.contains(target) || handle?.contains(target)) return;\n closeMenu({ hideGrip: true });\n }\n\n function handleMenuKeyDown(event: KeyboardEvent) {\n if (!menu) return;\n\n if (event.key === \"Escape\") {\n event.preventDefault();\n closeMenu({ hideGrip: true });\n return;\n }\n\n if (\n event.key !== \"ArrowDown\" &&\n event.key !== \"ArrowUp\" &&\n event.key !== \"Home\" &&\n event.key !== \"End\"\n ) {\n return;\n }\n\n const buttons = Array.from(\n menu.querySelectorAll<HTMLButtonElement>(\"button\"),\n );\n if (buttons.length === 0) return;\n\n event.preventDefault();\n const activeIndex = buttons.indexOf(\n document.activeElement as HTMLButtonElement,\n );\n let nextIndex = activeIndex < 0 ? 0 : activeIndex;\n\n if (event.key === \"ArrowDown\") {\n nextIndex = (nextIndex + 1) % buttons.length;\n } else if (event.key === \"ArrowUp\") {\n nextIndex = (nextIndex - 1 + buttons.length) % buttons.length;\n } else if (event.key === \"Home\") {\n nextIndex = 0;\n } else if (event.key === \"End\") {\n nextIndex = buttons.length - 1;\n }\n\n buttons[nextIndex]?.focus({ preventScroll: true });\n }\n\n function handleMenuViewportChange() {\n closeMenu({ hideGrip: true });\n }\n\n const finishDragSession = (commit: boolean, event?: MouseEvent) => {\n const session = dragSession;\n if (!session) return;\n\n removeDragListeners();\n\n if (commit && session.dragging && session.dropTarget) {\n const sourceStart = session.sourcePos;\n const sourceEnd = session.sourcePos + session.sourceNodeSize;\n const target = session.dropTarget;\n const dropPos = target.pos;\n const isSideDrop =\n target.placement === \"left\" || target.placement === \"right\";\n\n if (\n target.view !== session.view ||\n (isSideDrop\n ? // Side drop (column build): proceed for any block that isn't the\n // source itself, including the source's immediate neighbour.\n target.targetPos !== sourceStart\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 sourceRegistration = registrationForView(session.view);\n const transferData = sourceRegistration?.getDragTransferData?.({\n view: session.view,\n node: sourceNode,\n pos: sourceStart,\n });\n const targetNode = target.view.state.doc.nodeAt(target.targetPos);\n const handled =\n !!targetNode &&\n (target.registration.handleDrop?.(transferData, {\n view: target.view,\n sourceView: session.view,\n sourceNode,\n sourcePos: sourceStart,\n sourceNodeSize: sourceNode.nodeSize,\n targetNode,\n targetPos: target.targetPos,\n targetNodeSize: target.targetNodeSize,\n insertPos: dropPos,\n placement: target.placement,\n }) ??\n false);\n\n if (handled) {\n target.view.focus();\n } else if (target.view === session.view) {\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 } else {\n try {\n const targetNode = target.view.state.schema.nodeFromJSON(\n sourceNode.toJSON(),\n );\n target.registration.receiveDragTransferData?.(transferData, {\n view: target.view,\n node: targetNode,\n pos: dropPos,\n sourceView: session.view,\n });\n const insertTr = target.view.state.tr.insert(\n dropPos,\n targetNode,\n );\n insertTr.setSelection(\n NodeSelection.create(insertTr.doc, dropPos),\n );\n target.view.dispatch(insertTr.scrollIntoView());\n\n const deleteTr = session.view.state.tr.delete(\n sourceStart,\n sourceEnd,\n );\n session.view.dispatch(deleteTr);\n target.view.focus();\n } catch {\n // If the target schema cannot accept this node, leave the\n // source document untouched.\n }\n }\n }\n }\n } else if (commit && !session.dragging && event) {\n openMenu(\n {\n view: session.view,\n sourceBlock: session.sourceBlock,\n sourcePos: session.sourcePos,\n sourceNodeSize: session.sourceNodeSize,\n },\n handle?.getBoundingClientRect() ??\n session.sourceBlock.getBoundingClientRect(),\n );\n }\n\n cleanupDragVisuals();\n dragSession = null;\n if (activeDragRegistration === currentRegistration) {\n activeDragRegistration = null;\n }\n if (session.dragging || !commit) 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 findAnyDropTarget(session, 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 findAnyDropTarget(dragSession, event.clientX, event.clientY),\n );\n }\n\n function handleDocumentMouseUp(event: MouseEvent) {\n event.preventDefault();\n finishDragSession(true, event);\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 const registration: DragHandleRegistration = {\n view: editorView,\n wrapperSelector,\n getDragTransferData,\n receiveDragTransferData,\n handleDrop,\n canHover: () =>\n !!handle && !menu && !dragSession && editor.isEditable,\n findHoverBlock: (clientX, clientY) =>\n findForgivingBlock(editorView, clientX, clientY),\n showHoverBlock: (block) => showHandleForBlock(editorView, block),\n hideHover: () => hideHandle(),\n };\n currentRegistration = registration;\n dragHandleRegistrations.add(registration);\n retainGlobalHoverListener();\n handle = createHandle();\n const wrapper = editorView.dom.closest(wrapperSelector);\n if (wrapper) {\n (wrapper as HTMLElement).style.position = \"relative\";\n wrapper.appendChild(handle);\n }\n\n handle.addEventListener(\"mousedown\", (e) => {\n e.stopPropagation();\n if (e.button !== 0) return;\n closeMenu();\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 dropTarget: null,\n };\n activeDragRegistration = registration;\n\n document.addEventListener(\"mousemove\", handleDocumentMouseMove);\n document.addEventListener(\"mouseup\", handleDocumentMouseUp);\n document.addEventListener(\"keydown\", handleDocumentKeyDown);\n });\n\n handle.addEventListener(\"keydown\", (e) => {\n if (e.key !== \"Enter\" && e.key !== \" \") return;\n e.preventDefault();\n e.stopPropagation();\n closeMenu();\n if (!editor.isEditable || !currentBlock || dragStartPos === null) {\n return;\n }\n\n const sourceNode = editorView.state.doc.nodeAt(dragStartPos);\n if (!sourceNode) return;\n\n openMenu(\n {\n view: editorView,\n sourceBlock: currentBlock,\n sourcePos: dragStartPos,\n sourceNodeSize: sourceNode.nodeSize,\n },\n handle?.getBoundingClientRect() ??\n currentBlock.getBoundingClientRect(),\n );\n });\n\n return {\n destroy() {\n closeMenu({ hideGrip: true });\n finishDragSession(false);\n releaseGlobalHoverListener();\n dragHandleRegistrations.delete(registration);\n if (activeDragRegistration === registration) {\n activeDragRegistration = null;\n }\n handle?.remove();\n handle = null;\n currentRegistration = null;\n },\n };\n },\n props: {\n handleDOMEvents: {\n mousemove(_view, event) {\n updateRegisteredHover(event.clientX, event.clientY);\n return false;\n },\n drop() {\n closeMenu({ hideGrip: true });\n finishDragSession(false);\n hideHandle();\n return false;\n },\n },\n },\n }),\n ];\n },\n});\n"]}
|