@estiva-app/ui 0.63.0 → 0.65.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/CodeBlockColours.d.ts +11 -0
- package/dist/CodeBlockColours.d.ts.map +1 -0
- package/dist/Link.d.ts +1 -1
- package/dist/RichText.d.ts +2 -1
- package/dist/RichText.d.ts.map +1 -1
- package/dist/codeColours.d.ts +18 -0
- package/dist/codeColours.d.ts.map +1 -0
- package/dist/editor.d.ts +1 -0
- package/dist/editor.d.ts.map +1 -1
- package/dist/editor.js +21 -0
- package/dist/editor.js.map +3 -3
- package/dist/index.js +58 -31
- package/dist/index.js.map +4 -4
- package/package.json +8 -2
- package/registry.json +33 -14
- package/src/CodeBlockColours.mdx +49 -0
- package/src/CodeBlockColours.stories.tsx +37 -0
- package/src/CodeBlockColours.test.ts +36 -0
- package/src/CodeBlockColours.ts +28 -0
- package/src/Link.mdx +1 -1
- package/src/Link.stories.tsx +1 -1
- package/src/Link.test.tsx +2 -2
- package/src/Link.tsx +2 -2
- package/src/RichText.stories.tsx +24 -0
- package/src/RichText.tsx +31 -17
- package/src/codeColours.ts +41 -0
- package/src/editor.ts +1 -0
- package/src/pages.test.ts +1 -0
- package/src/registry/registry.test.ts +6 -6
- package/stories/Choosing.mdx +1 -0
- package/tailwind-preset.js +7 -0
- package/tokens.css +40 -0
package/dist/editor.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/SelectionToolbar.tsx", "../src/PastedImages.ts", "../src/suggestionPopup.tsx", "../src/EditorBlockHandle.tsx", "../src/ComposerTriggers.tsx", "../src/BlockNodes.tsx"],
|
|
4
|
-
"sourcesContent": ["import { useCallback, useEffect, useRef, useState } from 'react'\nimport type { Editor } from '@tiptap/react'\nimport { Extension } from '@tiptap/core'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\nimport { Decoration, DecorationSet } from '@tiptap/pm/view'\nimport { IconBold, IconCode, IconItalic, IconLink, IconUnderline } from '@tabler/icons-react'\nimport { Form } from './Form'\nimport { Popover } from './Popover'\nimport { TextInput } from './TextInput'\nimport { Toolbar, ToolbarButton } from './Toolbar'\nimport { shortcutLabel } from './shortcuts'\n\n/**\n * The selection, kept visible while something else has the focus \u2014 Peek's\n * `src/extensions/keptSelection.ts` (PEE-19), moved into the package with the\n * `SelectionToolbar` that needs it (UIG-31, Katerina's ruling 29 September).\n *\n * The toolbar's address field takes the focus, and with it the document's\n * one selection, so the words being linked lost their highlight the moment\n * the field opened (measured 2026-09-07). Linear keeps it, and Katerina asked\n * for the same. The editor's own selection never moved \u2014 ProseMirror keeps it\n * while unfocused \u2014 so this only *draws* it: an inline decoration over the\n * range, in `bg-selected` \u2014 the token Peek's composer paints `::selection` in,\n * mapped through edits and cleared when the field closes.\n *\n * A decoration rather than a second selection, because a document has one\n * and the field needs it. Editor-internal by design (the editor owns its own\n * drawing); nothing here floats, focuses or handles a key.\n */\n\nexport interface KeptRange {\n from: number\n to: number\n}\n\n/** The plugin's key: read what is being kept, or dispatch a change to it. */\nexport const keptSelectionKey = new PluginKey<KeptRange | null>('keptSelection')\n\n/** The extension an editor registers so a selection can stay drawn while a field has the focus. */\nexport const KeptSelection = Extension.create({\n name: 'keptSelection',\n\n addProseMirrorPlugins() {\n return [\n new Plugin<KeptRange | null>({\n key: keptSelectionKey,\n state: {\n init: () => null,\n apply(tr, previous) {\n const meta = tr.getMeta(keptSelectionKey) as KeptRange | null | undefined\n if (meta !== undefined) return meta\n if (!previous) return null\n // Follow the words through an edit, so applying the link to them\n // (or typing before them) does not leave the highlight behind.\n return { from: tr.mapping.map(previous.from), to: tr.mapping.map(previous.to) }\n },\n },\n props: {\n decorations(state) {\n const range = keptSelectionKey.getState(state)\n if (!range || range.from === range.to) return null\n return DecorationSet.create(state.doc, [\n Decoration.inline(range.from, range.to, { class: 'kept-selection bg-bg-selected' }),\n ])\n },\n },\n }),\n ]\n },\n})\n\n/** Draw the selection as it is now, until `releaseSelection`. */\nexport function keepSelection(editor: Editor) {\n const { from, to } = editor.state.selection\n editor.view.dispatch(editor.state.tr.setMeta(keptSelectionKey, { from, to }))\n}\n\n/** Stop drawing it. Nothing kept, nothing dispatched. */\nexport function releaseSelection(editor: Editor) {\n if (editor.isDestroyed || !keptSelectionKey.getState(editor.state)) return\n editor.view.dispatch(editor.state.tr.setMeta(keptSelectionKey, null))\n}\n\n/** What is being drawn, or null. */\nexport function keptSelection(editor: Editor): KeptRange | null {\n return keptSelectionKey.getState(editor.state) ?? null\n}\n\n/** A mark the strip can toggle \u2014 the suite's inline vocabulary (SPEC \u00A713.1) less link and reference. */\nexport type MarkId = 'bold' | 'italic' | 'underline' | 'code'\n\nconst MARKS: Record<MarkId, { label: string; keys: string }> = {\n bold: { label: 'Bold', keys: 'Mod-B' },\n italic: { label: 'Italic', keys: 'Mod-I' },\n underline: { label: 'Underline', keys: 'Mod-U' },\n code: { label: 'Code', keys: 'Mod-E' },\n}\n\n/**\n * Toggle one mark over the current selection. The core `toggleMark`, which\n * each mark's own `toggleBold` and the like wrap: the package names no Tiptap\n * extension, only the marks the suite's format has (SPEC \u00A713.1).\n */\nfunction toggleMark(editor: Editor, id: MarkId): boolean {\n return editor.chain().focus().toggleMark(id).run()\n}\n\n/** The address the selection sits in, or '' \u2014 what the link field opens with. */\nexport function currentLink(editor: Editor): string {\n const href: unknown = editor.getAttributes('link').href\n return typeof href === 'string' ? href : ''\n}\n\n/**\n * What somebody typed into the link field \u2192 an `href`, or null when it cannot\n * be one. A bare host (`google.com`) gets `https://`. A scheme is kept only when\n * SPEC \u00A713.1 lets a reader follow it (http, https, mailto); `javascript:` and\n * the like are refused here. `localhost:5173` is a host and a port: a scheme is\n * never followed by a digit.\n */\nexport function normalizeHref(raw: string): string | null {\n const s = raw.trim()\n if (!s || /\\s/.test(s)) return null\n if (/^(https?:|mailto:)/i.test(s)) return s\n if (/^[a-z][a-z0-9+.-]*:(?!\\d)/i.test(s)) return null\n return `https://${s}`\n}\n\n/**\n * Apply the link field to the selection. Empty removes the link; an address\n * sets it, over the whole link when the caret sits inside one. `false` means\n * the text could not be an address, and the field should stay open.\n */\nexport function applyLink(editor: Editor, raw: string): boolean {\n const chain = editor.chain().focus().extendMarkRange('link')\n // The core commands the Link extension's `setLink` and `unsetLink` wrap, with\n // the same meta; `normalizeHref` has already refused what it would refuse.\n if (!raw.trim()) return chain.unsetMark('link', { extendEmptyMarkRange: true }).setMeta('preventAutolink', true).run()\n const href = normalizeHref(raw)\n if (!href) return false\n return chain.setMark('link', { href }).setMeta('preventAutolink', true).run()\n}\n\n/**\n * Bold / italic / underline / link over selected text \u2014 Peek's\n * `SelectionToolbar` (PEE-18, PEE-19), moved into the package at Katerina's\n * word (29 September, UIG-31) when Ship's description became its second user.\n * Unchanged but for two props: `marks`, which buttons the strip has (Peek's\n * three by default; Ship adds code), and `link`, whether it has the Link button\n * and its field (Peek's editor has a link mark; an editor without one leaves it\n * off). The editor must register `KeptSelection` when `link` is on.\n *\n * The marks apply to a run you have already written, which is why they are\n * not in the `/` menu: typing `/` replaces the selection, so by definition\n * there is nothing selected to apply them to.\n *\n * **The chrome is the shared `Popover`, anchored** (P26). It was a `Menu`, and\n * it never was one: a menu gives its contents roving focus and typeahead,\n * which would fight the link field this panel exists for. An anchored\n * `Popover` is the mode built for exactly this \u2014 it takes no focus, so the\n * caret stays in the text. It is laid out as a row instead of a column\n * through `className`, which `cn` merges last. The panel still portals out of\n * the composer, so no overflow clips it, and Floating UI clamps it on screen.\n *\n * **The anchor is the selection's own point** since 0.12.2. This toolbar is\n * *centred* over the selection (her design, PEE-19, after Linear), and the\n * package's `Popover` aligns left or right only \u2014 Base UI has `center`, the\n * package does not expose it (ADOPTION **B21**). So the placement arithmetic\n * and the hand-measured `SIZE` box stay for now, and the rect handed over is\n * positioned so the panel lands on the same pixel it always has: the\n * package's own 4px gap is subtracted from this file's 8px, and the rect's\n * left edge is the panel's. When `align=\"center\"` exists, `SIZE`, `GAP` and\n * `placement` all go and the anchor becomes the selection's own rect.\n *\n * **Two faces** (PEE-19 \u2014 Katerina, 2026-09-07, after Linear). `marks` is the\n * row of four buttons. `link` is one text field for the address: it opens from\n * the Link button, and opens by itself when the settled selection sits inside\n * a link, with that link's address in it. There is no open, embed or delete\n * button, by her call: the field is the whole control.\n *\n * **What applies the field** (her rule, same day): Enter, and clicking away \u2014\n * anywhere outside the toolbar, the editor included. Enter on an empty field\n * removes the link; clicking away with an empty field changes nothing, since\n * removing is deliberate and leaving is not. Escape drops what was typed and\n * puts the caret back. Once applied, the caret lands after the link, and\n * typing goes on as plain text \u2014 the mark is not inclusive (editorKit).\n *\n * While the field has focus the editor has not, so everything below that\n * hides the toolbar on blur or on an empty editor selection stands down in\n * `link` mode. The editor keeps its selection while unfocused; `focus()` in\n * the apply command puts it back.\n *\n * **Why it waits.** Showing on every selection change put the toolbar under the\n * pointer mid-drag, and made it blink on a plain click \u2014 ProseMirror restores\n * the previous selection when the editor takes focus and collapses it a tick\n * later, so there is a real, non-empty range in between. Both go away by\n * refusing to show while the pointer is down and re-reading the selection after\n * a short settle rather than trusting the event that woke us.\n */\n\nconst ICONS: Record<MarkId, typeof IconBold> = {\n bold: IconBold,\n italic: IconItalic,\n underline: IconUnderline,\n code: IconCode,\n}\n\ntype Mode = 'marks' | 'link'\n\n/** How long a selection must stand still before the toolbar appears. */\nconst SETTLE_MS = 250\nconst GAP = 8\n/** The gap the package's `Popover` adds of its own, subtracted above so the\n * panel keeps this file's 8px. Read from `Popover.tsx`, not guessed. */\nconst POPOVER_GAP = 4\n\nexport interface SelectionToolbarProps {\n /** The editor whose selection the strip follows. `null` while it loads. */\n editor: Editor | null\n /** Which marks the strip toggles, in order. Default bold, italic, underline. */\n marks?: readonly MarkId[]\n /** The Link button and its address field. Needs a link mark in the editor and `KeptSelection`. Default off. */\n link?: boolean\n}\n\nexport function SelectionToolbar({ editor, marks = ['bold', 'italic', 'underline'], link = false }: SelectionToolbarProps) {\n /** The selection's top edge and horizontal centre; the face decides the rest. */\n const [anchor, setAnchor] = useState<{ top: number; centre: number } | null>(null)\n const [mode, setMode] = useState<Mode>('marks')\n const [url, setUrl] = useState('')\n // Re-render as marks turn on and off while the caret moves through the\n // selection, so the pressed states stay honest.\n const [, setTick] = useState(0)\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)\n const pointerDown = useRef(false)\n const field = useRef<HTMLInputElement>(null)\n /** What the field holds while it is open; null while it is closed. The\n * listeners below are bound once, so they read this rather than state. */\n const draft = useRef<string | null>(null)\n // Read by the same listeners. Kept in an effect, declared before the focus\n // effect below so the ref already says `link` when the field's focus blurs\n // the editor.\n const modeRef = useRef<Mode>('marks')\n useEffect(() => {\n modeRef.current = mode\n }, [mode])\n // Read by `settle`, which is bound once: words already a link open the field only when there is one.\n const linkOn = useRef(link)\n linkOn.current = link\n\n const hide = useCallback(() => {\n clearTimeout(timer.current)\n draft.current = null\n if (editor) releaseSelection(editor)\n setAnchor(null)\n setMode('marks')\n }, [editor])\n\n /**\n * Leaving the field applies it (Enter or a click away). An address links the\n * words and the caret moves past them; an empty field on the way out is a\n * shrug, not a removal. Idempotent: the outside click reaches this twice,\n * once from the editor press and once from the Menu's own listener.\n */\n const commit = useCallback(() => {\n const text = draft.current\n if (text === null || !editor) return\n draft.current = null\n if (text.trim() && applyLink(editor, text)) {\n editor.commands.setTextSelection(editor.state.selection.to)\n }\n hide()\n }, [editor, hide])\n\n /** Read the selection as it is *now* and place the toolbar, or hide it. */\n const settle = useCallback(() => {\n if (!editor || editor.isDestroyed) return\n // Keeping the selection drawn is itself a transaction, which schedules\n // this; by then the field has the focus, and reading `hasFocus()` here\n // would close it.\n if (modeRef.current === 'link') return\n const { state, view } = editor\n const { empty, from, to } = state.selection\n if (empty || from === to || !view.hasFocus() || pointerDown.current) {\n setAnchor(null)\n setMode('marks')\n return\n }\n const start = view.coordsAtPos(from)\n const end = view.coordsAtPos(to)\n const centre = (Math.min(start.left, end.left) + Math.max(start.right, end.right)) / 2\n // Words that are already a link open on the field, with their address in it.\n const inLink = linkOn.current && editor.isActive('link')\n const address = inLink ? currentLink(editor) : ''\n draft.current = inLink ? address : null\n // The field is about to take the focus; the words stay highlighted.\n if (inLink) keepSelection(editor)\n setMode(inLink ? 'link' : 'marks')\n setUrl(address)\n setAnchor({ top: start.top, centre })\n }, [editor])\n\n useEffect(() => {\n if (!editor) return\n\n const schedule = () => {\n // The field owns the keyboard and the focus; the editor's own events\n // stand down until it closes.\n if (modeRef.current === 'link') return\n setTick((t) => t + 1)\n clearTimeout(timer.current)\n // A collapsed selection hides at once \u2014 waiting to hide is what made the\n // click blink. Only *showing* is deferred.\n if (editor.state.selection.empty) {\n setAnchor(null)\n return\n }\n timer.current = setTimeout(settle, SETTLE_MS)\n }\n\n // The field taking focus is the one blur that must not hide us.\n const onBlur = () => {\n if (modeRef.current !== 'link') hide()\n }\n\n // Only a press *inside the editor* starts a selection. A press on the\n // toolbar itself must not hide it \u2014 doing so unmounted the button before\n // its click could land, so nothing ever applied.\n const startsSelection = (e: MouseEvent) =>\n e.target instanceof Node && editor.view.dom.contains(e.target)\n\n const onPointerDown = (e: MouseEvent) => {\n if (!startsSelection(e)) return\n // A press in the editor while the field is open is a click away: apply\n // first, before the editor moves the caret under the press.\n commit()\n pointerDown.current = true\n hide()\n }\n const onPointerUp = () => {\n if (!pointerDown.current) return\n pointerDown.current = false\n schedule()\n }\n\n editor.on('selectionUpdate', schedule)\n editor.on('transaction', schedule)\n editor.on('blur', onBlur)\n // @estiva-escape(no-hand-rolled-behaviour): watches presses in the editor to follow a text selection; the Popover it opens in has no trigger to own that (Peek's UIG-8 escape, moved here with the part, UIG-31)\n document.addEventListener('mousedown', onPointerDown, true)\n document.addEventListener('mouseup', onPointerUp, true)\n\n return () => {\n clearTimeout(timer.current)\n editor.off('selectionUpdate', schedule)\n editor.off('transaction', schedule)\n editor.off('blur', onBlur)\n document.removeEventListener('mousedown', onPointerDown, true)\n document.removeEventListener('mouseup', onPointerUp, true)\n }\n }, [editor, settle, hide, commit])\n\n // The field takes focus once it is on screen. Not `autoFocus`, and not in\n // the same frame: the Menu renders once hidden to measure itself, and a\n // hidden input cannot take focus \u2014 measured 2026-09-07, the field opened\n // unfocused on a re-selected link. An address already in it is selected\n // whole, so typing replaces it.\n useEffect(() => {\n if (mode !== 'link' || !anchor) return\n const frame = requestAnimationFrame(() => {\n field.current?.focus()\n field.current?.select()\n })\n return () => cancelAnimationFrame(frame)\n }, [mode, anchor])\n\n if (!editor || !anchor) return null\n\n const openField = () => {\n const address = currentLink(editor)\n draft.current = address\n keepSelection(editor)\n setUrl(address)\n setMode('link')\n }\n /** Enter. Unlike a click away, an empty field here means remove. */\n const submit = () => {\n if (!url.trim()) {\n applyLink(editor, '')\n hide()\n editor.commands.focus()\n return\n }\n commit()\n }\n const discard = () => {\n hide()\n editor.commands.focus()\n }\n\n /* A zero-sized rect at the selection's own top edge and centre. The panel's\n width is no longer this file's business: `align=\"center\"` puts the\n panel's middle over this point (B21, package 0.12.2), so the measured\n `SIZE` table and the placement arithmetic that stood in for it are gone.\n The top is this file's GAP less the package's own 4, so the panel keeps\n the 8px it has always had. */\n const anchorRect = new DOMRect(anchor.centre, anchor.top - (GAP - POPOVER_GAP), 0, 0)\n\n return (\n <Popover\n anchor={anchorRect}\n open\n side=\"top\"\n align=\"center\"\n onOpenChange={(next) => {\n if (!next) commit()\n }}\n ariaLabel=\"Text formatting\"\n // The panel gives up its column; the strip inside draws the row. The 4px\n // around it is `contentClassName`'s: on `className` it was added to the\n // package's 8px from 0.12.6 on, and the toolbar grew 8px a side\n // (Katerina, 2026-09-13; migration docs D68, Finding 60). This is the\n // package's own `Popover/A toolbar` story, class for class.\n className=\"w-auto min-w-0\"\n contentClassName=\"p-1\"\n >\n {mode === 'link' ? (\n /* One field, so no strip: a toolbar of one control is a toolbar in\n name only, and `ToolbarInput` cannot take the ref this field is\n focused by (ADOPTION B25). */\n // The package Form (UIG-7): Enter applies the link. `free` and `flex`: one field, which keeps its own height.\n <Form onSubmit={submit} layout=\"free\" className=\"flex\">\n <TextInput\n ref={field}\n value={url}\n onChange={(e) => {\n setUrl(e.target.value)\n draft.current = e.target.value\n }}\n onKeyDown={(e) => {\n if (e.key === 'Escape') {\n // Before the Menu's own Escape, which would apply instead.\n e.stopPropagation()\n discard()\n }\n }}\n placeholder=\"Enter link URL\"\n aria-label=\"Link URL\"\n className=\"w-[264px]\"\n />\n </Form>\n ) : (\n /* Four marks and a link button: one Tab stop, \u2190 \u2192 along them (D29). */\n <Toolbar aria-label=\"Text formatting\" surface={false}>\n {marks.map((id) => {\n const Icon = ICONS[id]\n const active = editor.isActive(id)\n return (\n <ToolbarButton\n key={id}\n aria-label={MARKS[id].label}\n pressed={active}\n tooltip={MARKS[id].label}\n tooltipShortcut={shortcutLabel(MARKS[id].keys)}\n // Keep the selection: focus must not leave the editor on press.\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => toggleMark(editor, id)}\n >\n <Icon size={16} stroke={1.5} />\n </ToolbarButton>\n )\n })}\n {link && (\n <ToolbarButton\n aria-label=\"Link\"\n tooltip=\"Link\"\n onMouseDown={(e) => e.preventDefault()}\n onClick={openField}\n >\n <IconLink size={16} stroke={1.5} />\n </ToolbarButton>\n )}\n </Toolbar>\n )}\n </Popover>\n )\n}\n", "import { Extension } from '@tiptap/core'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\n\n/** As much of a `DataTransfer` as the paste reads. */\nexport interface ClipboardSource {\n files?: ArrayLike<File> | null\n getData(format: string): string\n}\n\n/** MIME type \u2192 the extension a pasted picture is named with. */\nconst IMAGE_EXTENSIONS: Record<string, string> = {\n 'image/png': 'png',\n 'image/jpeg': 'jpg',\n 'image/gif': 'gif',\n 'image/webp': 'webp',\n 'image/heic': 'heic',\n 'image/heif': 'heif',\n 'image/svg+xml': 'svg',\n}\n\n/** Names a browser invents for a clipboard picture. A made-up one is better. */\nconst GENERIC_STEMS = new Set(['image', 'blob', 'unknown', 'untitled', 'screenshot'])\n\n/*\n An unlisted type keeps its own subtype rather than becoming `png`, so a\n picture the app does not accept is refused by the app's own message instead\n of arriving disguised as one it does.\n*/\nfunction extensionFor(contentType: string): string {\n const type = contentType.toLowerCase()\n return IMAGE_EXTENSIONS[type] ?? type.split('/')[1]?.split('+')[0] ?? 'png'\n}\n\n/** `'Screenshot 2026-09-07 14-32-05.png'`: sortable, and readable on a file card. */\nexport function pastedImageName(contentType: string, at: Date = new Date(), index = 0): string {\n const pad = (n: number) => String(n).padStart(2, '0')\n const stamp =\n `${at.getFullYear()}-${pad(at.getMonth() + 1)}-${pad(at.getDate())} ` +\n `${pad(at.getHours())}-${pad(at.getMinutes())}-${pad(at.getSeconds())}`\n const nth = index > 0 ? ` (${index + 1})` : ''\n return `Screenshot ${stamp}${nth}.${extensionFor(contentType)}`\n}\n\n/** A real filename is kept; `image.png`, `blob` and '' are not names. */\nfunction hasUsableName(name: string): boolean {\n const dot = name.lastIndexOf('.')\n if (dot <= 0 || dot === name.length - 1) return false\n return !GENERIC_STEMS.has(name.slice(0, dot).toLowerCase())\n}\n\n/**\n * The pictures on the clipboard, named \u2014 `[]` when there is nothing to attach.\n *\n * **Text wins.** A copy from a spreadsheet or a document puts a rendered\n * picture of the selection beside the text; attaching the picture instead of\n * pasting the text is wrong every time. So a clipboard holding text is left to\n * the editor, and a screenshot, which holds none, lands here. Pictures only:\n * any other file comes through the app's own file picker.\n */\nexport function pastedImages(source: ClipboardSource | null | undefined, at: Date = new Date()): File[] {\n if (!source) return []\n if (source.getData('text/plain').trim() !== '') return []\n const images = Array.from(source.files ?? []).filter((f) => f.type.toLowerCase().startsWith('image/'))\n let generated = 0\n return images.map((file) =>\n hasUsableName(file.name)\n ? file\n : new File([file], pastedImageName(file.type, at, generated++), { type: file.type, lastModified: file.lastModified }),\n )\n}\n\nexport interface PastedImagesOptions {\n /**\n * The pictures a paste carried, named. Return `true` when the app took them\n * (an upload started), `false` to let the editor paste as it would have \u2014\n * for a box that cannot upload right now.\n */\n onImages: (files: File[]) => boolean\n}\n\n/**\n * Pasting a picture attaches it: a screenshot pasted into the editor reaches\n * the app as named files, the way the app's own file picker would hand them.\n * Text on the clipboard wins (see {@link pastedImages}).\n */\nexport const PastedImages = Extension.create<PastedImagesOptions>({\n name: 'pastedImages',\n addOptions() {\n return { onImages: () => false }\n },\n addProseMirrorPlugins() {\n const options = this.options\n return [\n new Plugin({\n key: new PluginKey('pastedImages'),\n props: {\n handlePaste: (_view, event) => {\n const files = pastedImages(event.clipboardData)\n return files.length > 0 && options.onImages(files)\n },\n },\n }),\n ]\n },\n})\n", "// @estiva-escape(component-has-a-page, component-has-a-story): draws nothing of its own \u2014 it opens a SuggestionMenu from a Tiptap suggestion plugin, and SuggestionMenu's page and stories show it (UIG-31)\nimport { forwardRef, useRef, useImperativeHandle } from 'react'\nimport { ReactRenderer } from '@tiptap/react'\nimport { exitSuggestion, type SuggestionKeyDownProps, type SuggestionOptions, type SuggestionProps } from '@tiptap/suggestion'\nimport { SuggestionMenu, type SuggestionMenuHandle, type SuggestionMenuRow, type SuggestionMenuSection } from './SuggestionMenu'\n\n/*\n * Is a type-ahead list open? \u2014 Peek's counter (`mention.tsx`), moved here with\n * the lists it counts (UIG-31).\n *\n * A counter rather than a boolean: two suggestion plugins can overlap for a\n * moment while one hands over to the other (`/` choosing \"Mention\" types `@`).\n * An editor asks before it acts on Enter or Escape, so a key that chose a row\n * does not also send the message or cancel the edit.\n *\n * A list counts while it shows rows, not while its trigger listens: since a\n * space stopped closing one (f586437a), \"meet @ 5pm\" leaves `@` listening\n * behind a hidden list to the end of the line, and that Enter must still send.\n *\n * And only while its editor has focus (71a4577b): a list left by a click ends,\n * or it would stay counted and swallow Escape in the box clicked into.\n */\nlet openCount = 0\nlet lastClose = 0\n\n/**\n * Open, or closed less than 100ms ago \u2014 what an Enter handler asks. Choosing a\n * row with Enter closes the list, and that same Enter must not also send.\n */\nexport function isSuggestionActive(): boolean {\n return openCount > 0 || Date.now() - lastClose < 100\n}\n\n/**\n * Open *now*, with no grace period \u2014 what an Escape handler asks. The first\n * Escape closes the list, the second is somebody's deliberate press.\n */\nexport function isSuggestionOpen(): boolean {\n return openCount > 0\n}\n\n/** How a list looks and what fills it \u2014 everything but the editor's own wiring. */\nexport interface SuggestionPopupOptions<T> {\n /** Names the list \u2014 \"Commands\", \"People\". */\n ariaLabel: string\n /** The box's width, e.g. `w-[300px]`. */\n width: string\n /** The cap before the rows scroll, e.g. `max-h-[400px]`. */\n maxHeight: string\n /** The plugin's items, and the typed query, \u2192 the sections to draw. One unlabeled section by default. */\n sections?: (items: T[], query: string) => readonly SuggestionMenuSection<T>[]\n itemKey: (item: T) => string\n row: (item: T) => SuggestionMenuRow\n /**\n * With `refresh`: called with a listener while the list is open; the app\n * calls it when its data has changed (a search landing), and the open list is\n * drawn again for the same query. Returns the unsubscribe, run when the list\n * closes however it closes.\n */\n subscribe?: (listener: () => void) => () => void\n /** The items for a query, as the plugin's `items` answers \u2014 asked again when `subscribe` fires. */\n refresh?: (query: string) => T[]\n}\n\ntype Props<T> = SuggestionProps<T> & { options: SuggestionPopupOptions<T> }\n\n// `forwardRef`, so Tiptap's `ReactRenderer` hands its `ref` through whichever\n// way it detects a component that takes one.\nconst Popup = forwardRef<SuggestionMenuHandle, Props<unknown>>(function Popup({ options, ...props }, handle) {\n const menu = useRef<SuggestionMenuHandle>(null)\n useImperativeHandle(handle, () => ({ onKeyDown: (event) => menu.current?.onKeyDown(event) ?? false }))\n const sections = options.sections ? options.sections(props.items, props.query) : [{ items: props.items }]\n return (\n <SuggestionMenu\n handle={menu}\n rect={props.clientRect?.() ?? null}\n editorElement={props.editor.view.dom}\n ariaLabel={options.ariaLabel}\n width={options.width}\n maxHeight={options.maxHeight}\n sections={sections}\n itemKey={options.itemKey}\n row={options.row}\n onSelect={(item) => props.command(item)}\n />\n )\n})\n\n/**\n * The `render` of a Tiptap suggestion plugin, drawn as a `SuggestionMenu` \u2014\n * the popup controller Peek wrote four times (`mention.tsx`, `slashCommands.tsx`),\n * once.\n *\n * Suggestion({ editor, char: '/', items, command,\n * render: suggestionPopup({ ariaLabel: 'Commands', width: 'w-[300px]',\n * maxHeight: 'max-h-[400px]', itemKey, row, sections }) })\n *\n * It mounts the list when the query starts and removes it when it ends: the\n * plugin owns the list's life. Escape closes it and is used up; \u2191, \u2193 and Enter\n * go to the list; every other key stays the editor's. The list portals itself\n * (the package `Popover`), so the mount point is only a mount point.\n */\nexport function suggestionPopup<T>(options: SuggestionPopupOptions<T>): NonNullable<SuggestionOptions<T>['render']> {\n return () => {\n let component: ReactRenderer<SuggestionMenuHandle, Props<T>> | null = null\n let container: HTMLDivElement | null = null\n let last: SuggestionProps<T> | null = null\n let unsubscribe: (() => void) | undefined\n let counted = false\n let unlisten: (() => void) | undefined\n const count = (shown: boolean) => {\n if (shown === counted) return\n counted = shown\n openCount = shown ? openCount + 1 : Math.max(0, openCount - 1)\n }\n // The plugin's state outlives a blur \u2014 no transaction runs \u2014 so leaving the\n // box ends the query here, as Escape does: coming back finds no list, and\n // Enter sends (Miky, 2026-10-06). Leaving the window is not leaving the box,\n // and a press in the list's own panel never takes focus (SuggestionMenu).\n const listen = (props: SuggestionProps<T>) => {\n const { view } = props.editor\n const dom = view.dom\n const onBlur = () => {\n // A window that loses focus leaves its active element where it was.\n if (dom.contains(document.activeElement) || !last) return\n const from = last.range.from\n // Not a pick: no grace for the other box's Enter.\n count(false)\n for (const plugin of view.state.plugins) {\n const state = plugin.getState(view.state) as { active?: boolean; range?: { from: number } } | undefined\n if (state?.active && state.range?.from === from && plugin.spec.key) exitSuggestion(view, plugin.spec.key)\n }\n }\n dom.addEventListener('blur', onBlur)\n unlisten = () => dom.removeEventListener('blur', onBlur)\n }\n const exit = () => {\n unsubscribe?.()\n unsubscribe = undefined\n unlisten?.()\n unlisten = undefined\n last = null\n // The grace is for the Enter that picked a row and closed the list, not\n // for a keystroke that only left it with no rows.\n if (counted) lastClose = Date.now()\n count(false)\n if (!component) return\n component.destroy()\n container?.remove()\n component = null\n container = null\n }\n return {\n onStart: (props) => {\n count(props.items.length > 0)\n component = new ReactRenderer<SuggestionMenuHandle, Props<T>>(Popup as never, { props: { ...props, options }, editor: props.editor })\n container = document.createElement('div')\n document.body.appendChild(container)\n container.appendChild(component.element)\n last = props\n listen(props)\n const { subscribe, refresh } = options\n if (subscribe && refresh) {\n // The plugin asks for items only when the query changes; an answer\n // landing later draws the open list again with the same props.\n unsubscribe = subscribe(() => {\n if (!last || !component) return\n last = { ...last, items: refresh(last.query) }\n count(last.items.length > 0)\n component.updateProps({ ...last, options })\n })\n }\n },\n onUpdate: (props) => {\n last = props\n count(props.items.length > 0)\n component?.updateProps({ ...props, options })\n },\n onKeyDown: ({ event }: SuggestionKeyDownProps) => {\n if (event.key === 'Escape') {\n exit()\n return true\n }\n return component?.ref?.onKeyDown(event) ?? false\n },\n onExit: exit,\n }\n }\n}\n", "import { useMemo, type ReactNode } from 'react'\nimport type { Editor } from '@tiptap/core'\nimport type { Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport type { EditorView } from '@tiptap/pm/view'\nimport { IconCopy, IconTrash } from '@tabler/icons-react'\nimport { BlockHandle, blockAtY, type BlockHandleEditing, type HandleBlock } from './BlockHandle'\nimport { MenuItem, MenuSub } from './Menu'\n\n/** A row of the block menu's Turn into: what the block becomes. */\nexport interface BlockTurnInto {\n label: string\n /** Turns the block the caret is in. The handle puts the caret there first. */\n run: (editor: Editor) => void\n /** Whether the block already is this \u2014 drawn as the selected row. */\n active?: (node: ProseMirrorNode) => boolean\n}\n\nexport interface EditorBlockHandleProps {\n /** The editor. Not editable, or not there yet, and the handle reads: the caller's rows only. */\n editor: Editor | null\n /** Turn into's rows. Offered for a block of text \u2014 a paragraph, a heading, code. */\n turnInto?: readonly BlockTurnInto[]\n /** The caller's own rows, after the editing ones. */\n actions?: (block: HandleBlock) => ReactNode\n /** The `EditorContent`. */\n children: ReactNode\n className?: string\n}\n\n/** The editor's top-level blocks, where each starts and what it is. */\nfunction editorBlocks(view: EditorView): HandleBlock[] {\n const out: HandleBlock[] = []\n view.state.doc.forEach((node, pos) => {\n const element = view.nodeDOM(pos)\n if (element instanceof HTMLElement) out.push({ id: (node.attrs.blockId as string | null) || undefined, element, pos })\n })\n return out\n}\n\n/*\n Duplicate and Delete leave the editor focused, as Turn into and a drop do: the\n person is still in the field, so an editor that saves when they leave it saves\n these too \u2014 and one that loads someone else's edit while unfocused does not\n load it over them.\n*/\n\n/** A copy of the block straight after it, the caret in the copy. `BlockId` gives the copy a fresh id; the original keeps its own. */\nexport function duplicateBlock(editor: Editor, pos: number): boolean {\n const node = editor.state.doc.nodeAt(pos)\n if (!node) return false\n editor.view.dispatch(editor.state.tr.insert(pos + node.nodeSize, node).scrollIntoView())\n editor.commands.focus(pos + node.nodeSize + 1)\n return true\n}\n\n/** Removes the block, the caret where it was. The last block of a document becomes an empty paragraph, since a document holds at least one. */\nexport function deleteBlock(editor: Editor, pos: number): boolean {\n const { state } = editor\n const node = state.doc.nodeAt(pos)\n if (!node) return false\n const tr = state.doc.childCount === 1 ? state.tr.replaceWith(pos, pos + node.nodeSize, state.schema.nodes.paragraph.create()) : state.tr.delete(pos, pos + node.nodeSize)\n editor.view.dispatch(tr)\n editor.commands.focus(Math.min(pos + 1, editor.state.doc.content.size))\n return true\n}\n\n/**\n * Moves the block at `from` to `to` (a position between top-level blocks), the\n * caret in it: what a drop in the gutter does, where the editor has no drop of\n * its own. The node moves whole, attributes and all, so it keeps its id, as\n * ProseMirror's drop keeps it.\n */\nexport function moveBlock(editor: Editor, from: number, to: number): boolean {\n const node = editor.state.doc.nodeAt(from)\n if (!node || (to >= from && to <= from + node.nodeSize)) return false\n const tr = editor.state.tr.delete(from, from + node.nodeSize)\n const at = tr.mapping.map(to)\n editor.view.dispatch(tr.insert(at, node).scrollIntoView())\n editor.commands.focus(at + 1)\n return true\n}\n\n/**\n * Starts the browser's own drag of the block, as ProseMirror starts one of a\n * selected node: the block selected, its slice on `view.dragging` with `move`,\n * and its HTML on the transfer. ProseMirror's drop then deletes the selection\n * and inserts the slice with its attributes \u2014 so the block arrives with the\n * id it left with, and every comment anchored to it still finds it.\n */\nexport function startBlockDrag(editor: Editor, pos: number, event: Pick<globalThis.DragEvent, 'dataTransfer'>, image?: Element) {\n editor.commands.setNodeSelection(pos)\n const { view } = editor\n const slice = view.state.selection.content()\n const { dom, text } = view.serializeForClipboard(slice)\n const transfer = event.dataTransfer\n if (transfer) {\n transfer.clearData()\n transfer.setData('text/html', dom.innerHTML)\n transfer.setData('text/plain', text)\n transfer.effectAllowed = 'copyMove'\n if (image) transfer.setDragImage(image, 0, 0)\n }\n view.dragging = { slice, move: true }\n}\n\n/**\n * The drop line a dragged block shows, in the package's accent instead of the\n * editor's default (the text's colour). Give it to the editor's StarterKit:\n * `StarterKit.configure({ dropcursor: blockDropCursor })`.\n */\nexport const blockDropCursor = { color: false, class: 'bg-accent-primary' } as const\n\nconst NOTHING_YET: BlockHandleEditing = { find: () => null, rows: () => null, startDrag: () => {}, drop: () => {}, endDrag: () => {}, onChange: () => () => {} }\n\n/**\n * `BlockHandle` in an editor: drag the handle to move the block, and the menu\n * gains Turn into, Duplicate and Delete before the caller's rows.\n */\nexport function EditorBlockHandle({ editor, turnInto = [], actions, children, className }: EditorBlockHandleProps) {\n const editing = useMemo<BlockHandleEditing>(() => {\n // Before the editor exists there is no block to find \u2014 not the editor's whole element read as one.\n if (!editor) return NOTHING_YET\n // Where the block being dragged starts.\n let dragged: number | undefined\n return {\n find: (y) => blockAtY(editorBlocks(editor.view), y),\n rows: (block) => {\n const pos = block.pos\n // Not editable: the caller's rows only, and no drag.\n if (!editor.isEditable) return null\n const node = pos === undefined ? null : editor.state.doc.nodeAt(pos)\n if (pos === undefined || !node) return null\n return (\n <>\n {node.isTextblock && turnInto.length > 0 && (\n <MenuSub label=\"Turn into\">\n {turnInto.map((row) => (\n <MenuItem\n key={row.label}\n label={row.label}\n selected={row.active?.(node) ?? false}\n onClick={() => {\n // Inside the block's text, so the row's command turns this block and no other.\n editor.chain().focus().setTextSelection(pos + 1).run()\n row.run(editor)\n }}\n />\n ))}\n </MenuSub>\n )}\n <MenuItem label=\"Duplicate\" leading={<IconCopy size={16} stroke={1.5} className=\"text-text-secondary\" />} onClick={() => duplicateBlock(editor, pos)} />\n <MenuItem label=\"Delete\" destructive leading={<IconTrash size={16} stroke={1.5} className=\"text-error-default\" />} onClick={() => deleteBlock(editor, pos)} />\n </>\n )\n },\n startDrag: (block, event) => {\n dragged = block.pos\n if (block.pos !== undefined) startBlockDrag(editor, block.pos, event, block.element)\n },\n drop: (target, after) => {\n const node = target.pos === undefined ? null : editor.state.doc.nodeAt(target.pos)\n if (dragged === undefined || target.pos === undefined || !node) return\n moveBlock(editor, dragged, after ? target.pos + node.nodeSize : target.pos)\n },\n // ProseMirror clears `dragging` on its own dragend, which a drag started outside its element never reaches.\n endDrag: () => setTimeout(() => (editor.view.dragging = null), 50),\n onChange: (changed) => {\n editor.on('update', changed)\n return () => {\n editor.off('update', changed)\n }\n },\n }\n }, [editor, turnInto])\n\n return (\n <BlockHandle editing={editing} actions={actions} className={className}>\n {children}\n </BlockHandle>\n )\n}\n", "import type { ReactNode } from 'react'\nimport { Extension, type Editor } from '@tiptap/core'\nimport { PluginKey } from '@tiptap/pm/state'\nimport Mention, { type MentionOptions } from '@tiptap/extension-mention'\nimport Suggestion from '@tiptap/suggestion'\nimport { NodeViewWrapper, ReactNodeViewRenderer, type ReactNodeViewProps } from '@tiptap/react'\nimport { Avatar } from './Avatar'\nimport { EnterHint } from './Menu'\nimport { inlineChipClassName } from './InlineChip'\nimport type { SuggestionMenuRow } from './SuggestionMenu'\nimport { suggestionPopup, type SuggestionPopupOptions } from './suggestionPopup'\n\n/*\n * The four composer triggers every Estiva app shares \u2014 `@`, `!@`, `[` and `/`\n * (CON-26, Miky 2026-10-02). Peek built them first and they move here unchanged\n * (CON-27); an app passes in only its own data: its people, the things `[` can\n * reference, and the `/` rows it can perform beside the shared Format section.\n *\n * **What a pick writes is not here.** The text a chip becomes in the body and\n * the tags it earns are `@estiva-app/conversation`'s (`mentionText`,\n * `messageReference`, `urgentTagsFor`), so a client without React writes the\n * same bytes. A chip here carries what that needs: a person's `pubkey`, a\n * reference's `uri`.\n */\n\n// \u2500\u2500\u2500 @ and !@ \u2500\u2500\u2500\n\n/** A person `@` and `!@` offer. */\nexport interface MentionPerson {\n /** The app's own key for the person \u2014 the row's key and the chip's `id`. */\n id: string\n name: string\n /** The second line of the row: a role, a team. */\n description?: string\n /** Their Nostr key, when they have one \u2014 what the body is written with (SPEC \u00A713.1). */\n pubkey?: string | null\n /** The face at the row's start. Default: the package `Avatar` for the name. */\n avatar?: ReactNode\n}\n\n/** How many people the list shows. */\nexport const PEOPLE_LIMIT = 6\n\n/** The people whose name holds the query, the first {@link PEOPLE_LIMIT} of them. */\nexport function filterPeople(people: readonly MentionPerson[], query: string): MentionPerson[] {\n const q = query.toLowerCase()\n return people.filter((person) => q === '' || person.name.toLowerCase().includes(q)).slice(0, PEOPLE_LIMIT)\n}\n\n/**\n * The people list `@` and `!@` open: the face, the name, the second line, and\n * the Enter hint while highlighted \u2014 `MenuItem` at its tall size.\n */\nexport function peopleMenu(urgent: boolean): SuggestionPopupOptions<MentionPerson> {\n const section = urgent ? 'Urgent mention' : 'People'\n return {\n ariaLabel: section,\n // The people and the reference lists are the same box: 658px, capped at 360.\n width: 'w-[658px]',\n maxHeight: 'max-h-[360px]',\n sections: (people) => [{ label: section, items: people, className: 'px-3 py-1' }],\n itemKey: (person) => person.id,\n row: (person) => ({\n label: person.name,\n description: person.description,\n leading: person.avatar ?? <Avatar size={32} alt={person.name} />,\n hint: <EnterHint />,\n size: 'tall',\n }),\n }\n}\n\nexport interface PersonMentionOptions {\n /** Everyone the list can offer, asked each time the query changes. */\n people: () => readonly MentionPerson[]\n}\n\ntype Doc = { descendants: (cb: (node: { type: { name: string }; attrs: Record<string, unknown> }) => boolean | void) => void }\n\nfunction optionsOf<T>(editor: Editor, name: string): T | undefined {\n return editor.extensionManager.extensions.find((one) => one.name === name)?.options as T | undefined\n}\n\n/**\n * A list keeps listening across spaces, so a name or a title can be more than\n * one word (f586437a, Miky 2026-10-06). It stops at a new line, Escape, a pick\n * or the cursor leaving \u2014 Suggestion's own \u2014 and once the query holds `stop`:\n * `]` for `[`, so \"see [the notes] above\" ends as text. While nothing matches,\n * the list is hidden rather than closed, and comes back if the words match again.\n * A space straight after the key is prose (\"meet @ 5pm\", \"- [ ] task\"), not a\n * query: every two-word name holds a space.\n */\nconst listening = (stop: string) => ({\n allowSpaces: true,\n shouldShow: ({ query }: { query: string }) => !/^\\s/.test(query) && !query.includes(stop),\n})\n\n/** `@`'s list and pick, or `!@`'s, for the node `name` \u2014 the extension's own, so a renamed one still finds its people. */\nfunction personSuggestion(urgent: boolean, name: string) {\n return {\n ...(urgent ? { char: '!@' } : {}),\n // A second `@` starts another mention; the first one has ended.\n ...listening('@'),\n items: ({ query, editor }: { query: string; editor: Editor }) => filterPeople(optionsOf<PersonMentionOptions>(editor, name)?.people() ?? [], query),\n render: suggestionPopup(peopleMenu(urgent)),\n command: ({ editor, range, props: person }: { editor: Editor; range: { from: number; to: number }; props: MentionPerson }) => {\n editor\n .chain()\n .focus()\n .insertContentAt(range, [\n { type: name, attrs: { id: person.id, label: person.name, pubkey: person.pubkey ?? null } },\n { type: 'text', text: ' ' },\n ])\n .run()\n },\n }\n}\n\n/*\n What a chip keeps through HTML \u2014 a copy and paste, inside an editor or\n between two. The chip's own `renderHTML` writes each as a `data-*` attribute\n and these read them back. Until CON-27 none was written, so a pasted chip\n came back with every value null and was sent as `@null`. What is read is\n checked: a crafted `data-pubkey` that is not a key, or a `data-uri` that is\n not a `nostr:` reference, is dropped rather than written into the body.\n*/\nconst HEX_KEY = /^[0-9a-f]{64}$/\nconst NOSTR_URI = /^nostr:[a-z0-9]+$/i\nconst fromData = (name: string, valid?: RegExp) => ({\n parseHTML: (element: HTMLElement) => {\n const value = element.getAttribute(`data-${name}`)\n return value !== null && (!valid || valid.test(value)) ? value : null\n },\n // The node's own `renderHTML` writes it.\n renderHTML: () => ({}),\n})\n\nconst personAttributes = () => ({\n id: { default: null, ...fromData('id') },\n label: { default: null, ...fromData('label') },\n /**\n * The person's Nostr key, when they have one \u2014 SPEC \u00A713.1. `id` is the app's\n * own and means nothing to another app; this is what the body is written\n * with, so a mention survives a rename.\n */\n pubkey: { default: null, ...fromData('pubkey', HEX_KEY) },\n})\n\n/** The `data-*` a person chip is written with, so a paste reads it back. */\nfunction personData(attrs: Record<string, unknown>): Record<string, string> {\n return {\n 'data-id': String(attrs.id ?? ''),\n 'data-label': String(attrs.label ?? ''),\n ...(typeof attrs.pubkey === 'string' && attrs.pubkey ? { 'data-pubkey': attrs.pubkey } : {}),\n }\n}\n\n/**\n * `@` \u2014 a person, as a chip that writes their key (SPEC \u00A713.1).\n *\n * PersonMention.configure({ people: () => directory })\n *\n * Its `pubkey` and `label` are what `mentionText` takes.\n */\nexport const PersonMention = Mention.extend<MentionOptions<MentionPerson, MentionPerson> & PersonMentionOptions>({\n name: 'mention',\n addOptions() {\n return { ...this.parent!(), HTMLAttributes: {}, people: () => [], suggestion: personSuggestion(false, this.name) }\n },\n addAttributes: personAttributes,\n renderHTML({ node }) {\n // No node view, so this spec is what the editor draws: the one chip.\n return ['span', { 'data-mention': 'true', ...personData(node.attrs), class: inlineChipClassName('person', 'cursor-default') }, `@${node.attrs.label}`]\n },\n parseHTML() {\n return [{ tag: 'span[data-mention]' }]\n },\n})\n\n/**\n * `!@` \u2014 a person, urgently: the same chip in the urgent tone. Its text is an\n * ordinary mention; the urgency travels as a tag (`urgentTagsFor`), so hand the\n * write {@link urgentPubkeys}.\n */\nexport const UrgentPersonMention = Mention.extend<MentionOptions<MentionPerson, MentionPerson> & PersonMentionOptions>({\n name: 'urgentMention',\n addOptions() {\n return { ...this.parent!(), HTMLAttributes: {}, people: () => [], suggestion: personSuggestion(true, this.name) }\n },\n addAttributes: personAttributes,\n renderHTML({ node }) {\n return [\n 'span',\n { 'data-urgent-mention': 'true', ...personData(node.attrs), class: inlineChipClassName('urgent', 'cursor-default') },\n `@${node.attrs.label}`,\n ]\n },\n parseHTML() {\n return [{ tag: 'span[data-urgent-mention]' }]\n },\n})\n\n/**\n * The keys the document's urgent mentions name \u2014 what the write turns into\n * `[\"urgent\", <pubkey>]` tags. A chip with no key has no tag to carry; its text\n * is the old `!@Name`.\n */\nexport function urgentPubkeys(editor: { state: { doc: Doc } }): string[] | undefined {\n const urgent: string[] = []\n editor.state.doc.descendants((node) => {\n if (node.type.name === 'urgentMention' && typeof node.attrs.pubkey === 'string' && node.attrs.pubkey) urgent.push(node.attrs.pubkey)\n })\n return urgent.length > 0 ? urgent : undefined\n}\n\n// \u2500\u2500\u2500 [ \u2500\u2500\u2500\n\n/** Something `[` offers: a reference drawn as who said it and how it opens. */\nexport interface CaptionedItem {\n /** The referenced thing's id \u2014 the row's key and the chip's `id`. */\n id: string\n /** Who, as the list shows them. */\n label: string\n /** The opening words, marks stripped: the caption the row and the chip wear. */\n snippet: string\n /** `nostr:\u2026`, exactly as the body will carry it (`messageReference`). */\n uri: string\n /** What the query is matched against beside `label`. Default: `snippet`. */\n search?: string\n /** The row's second line, e.g. where the thing sits. The chip does not wear it. */\n description?: string\n /**\n * This row's own 16px icon, in place of the list's `icon`: what the thing is,\n * when the list holds several kinds \u2014 a topic, a project, a message\n * (Katerina, 7 October). Absent, the list's icon.\n */\n icon?: ReactNode\n}\n\n/** One labelled group of `[`'s rows, in the order the list draws them. */\nexport interface ReferenceSection {\n label: string\n items: readonly CaptionedItem[]\n}\n\n/** How many references the list shows. */\nexport const REFERENCE_LIMIT = 6\n\n/**\n * The references whose label or text holds the query \u2014 the last\n * {@link REFERENCE_LIMIT}, in the order given: a thread is unbounded, and a\n * list that grew with it would be a hundred rows of prose.\n */\nexport function filterReferences(items: readonly CaptionedItem[], query: string): CaptionedItem[] {\n const q = query.toLowerCase()\n const shown = q ? items.filter((item) => (item.search ?? item.snippet).toLowerCase().includes(q) || item.label.toLowerCase().includes(q)) : [...items]\n return shown.slice(-REFERENCE_LIMIT)\n}\n\nconst captionOf = (label: string, snippet: string) => (snippet ? `${label}: ${snippet}` : label)\n\nexport interface CaptionedReferenceOptions {\n /** Drawn before the caption: a 14px icon. */\n icon: ReactNode\n /**\n * The chip's 14px icon from what it points at \u2014 its `uri` \u2014 when chips name\n * several kinds of thing; `undefined` from it, or no `iconFor`, draws `icon`.\n * The same answer the list's row gave (Katerina, 7 October).\n */\n iconFor?: (uri: string | null) => ReactNode | undefined\n}\n\n/**\n * A reference mid-sentence, drawn as `label: snippet` and written as its `uri`\n * verbatim (SPEC \u00A713.1). The caption is the snapshot it was picked with \u2014 a\n * caption, never parsed. Inserted by {@link ReferenceTrigger}, a paste or a\n * draft; it opens no list of its own.\n */\nexport const CaptionedReference = Mention.extend<MentionOptions & CaptionedReferenceOptions>({\n name: 'captionedReference',\n group: 'inline',\n inline: true,\n atom: true,\n addOptions() {\n return { ...this.parent!(), HTMLAttributes: {}, icon: null, iconFor: undefined, suggestion: { char: '\\0', items: () => [] } }\n },\n addAttributes() {\n return {\n id: { default: null, ...fromData('id') },\n label: { default: null, ...fromData('label') },\n snippet: { default: '', parseHTML: (element: HTMLElement) => element.getAttribute('data-snippet') ?? '', renderHTML: () => ({}) },\n uri: { default: null, ...fromData('uri', NOSTR_URI) },\n }\n },\n renderHTML({ node }) {\n return [\n 'span',\n { [`data-${this.name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)}`]: 'true', 'data-id': String(node.attrs.id ?? ''), 'data-label': String(node.attrs.label ?? ''), 'data-snippet': String(node.attrs.snippet ?? ''), ...(node.attrs.uri ? { 'data-uri': String(node.attrs.uri) } : {}), class: inlineChipClassName('neutral', 'cursor-default') },\n captionOf(node.attrs.label, node.attrs.snippet),\n ]\n },\n parseHTML() {\n return [{ tag: `span[data-${this.name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)}]` }]\n },\n addNodeView() {\n const { icon, iconFor } = this.options\n return ReactNodeViewRenderer(\n ({ node }: ReactNodeViewProps) => (\n <NodeViewWrapper as=\"span\" className={inlineChipClassName('neutral', 'max-w-[24ch] cursor-default')}>\n <span className=\"flex items-center justify-center w-4 h-4 shrink-0 text-text-secondary\">{iconFor?.(node.attrs.uri ?? null) ?? icon}</span>\n <span className=\"truncate\">{captionOf(node.attrs.label, node.attrs.snippet)}</span>\n </NodeViewWrapper>\n ),\n { as: 'span' },\n )\n },\n})\n\nexport interface ReferenceMenuOptions {\n /** Names the list, e.g. what can be referenced. */\n ariaLabel: string\n /** The section's heading. */\n sectionLabel: string\n /** At each row's start: a 16px icon \u2014 unless the row brings its own (`CaptionedItem.icon`), or `iconFor` answers. */\n icon: ReactNode\n /**\n * A row's 16px icon from what it points at \u2014 its `uri` \u2014 when the list holds\n * several kinds of thing; `undefined` from it draws `icon`. Give the chip the\n * same answer at 14px (`CaptionedReference`'s `iconFor`), so a pick keeps it.\n */\n iconFor?: (uri: string) => ReactNode | undefined\n}\n\n/** A row as the list holds it: which section it is drawn under, when the list has several. */\ntype ListedItem = CaptionedItem & { section?: string }\n\n/**\n * The list `[` opens: `label: snippet` rows, the same box as the people list.\n * One section headed `sectionLabel`, or \u2014 when the rows say which section they\n * are in \u2014 a heading for each, in the order the rows arrive.\n */\nexport function referenceMenu({ ariaLabel, sectionLabel, icon, iconFor }: ReferenceMenuOptions): SuggestionPopupOptions<CaptionedItem> {\n return {\n ariaLabel,\n width: 'w-[658px]',\n maxHeight: 'max-h-[360px]',\n sections: (items: ListedItem[]) => {\n const groups: { label: string; items: CaptionedItem[]; className: string }[] = []\n for (const item of items) {\n const label = item.section ?? sectionLabel\n const last = groups[groups.length - 1]\n if (last?.label === label) last.items.push(item)\n else groups.push({ label, items: [item], className: 'px-2' })\n }\n return groups\n },\n itemKey: (item) => `reference-${item.id}`,\n row: (item) => ({ leading: item.icon ?? iconFor?.(item.uri) ?? icon, label: captionOf(item.label, item.snippet), description: item.description, hint: <EnterHint /> }),\n }\n}\n\nexport interface ReferenceTriggerOptions extends ReferenceMenuOptions {\n /** Everything `[` can offer, asked each time the query changes. Narrowed by {@link filterReferences}. */\n items: () => readonly CaptionedItem[]\n /**\n * In place of `items`: the sections to draw for what was typed, already\n * narrowed and ordered by the app. Empty sections are not drawn.\n */\n sections?: (query: string) => readonly ReferenceSection[]\n /**\n * Called with a listener while the list is open; the app calls it when what\n * `sections` would answer has changed \u2014 a search landing \u2014 and the open list\n * is drawn again for the same query. Returns the unsubscribe.\n */\n subscribe?: (listener: () => void) => () => void\n /** The node a pick inserts. Default `captionedReference`. */\n nodeName: string\n}\n\nconst listed = (options: ReferenceTriggerOptions, query: string): ListedItem[] =>\n options.sections\n ? options.sections(query).flatMap((section) => section.items.map((item) => ({ ...item, section: section.label })))\n : filterReferences(options.items(), query)\n\n/**\n * `[` \u2014 reference something, inserted as a {@link CaptionedReference} chip.\n *\n * Its own extension rather than the chip's suggestion, so the chip's text (its\n * `renderText`) does not change with the key that summons the list.\n */\nexport const ReferenceTrigger = Extension.create<ReferenceTriggerOptions>({\n name: 'referenceTrigger',\n addOptions() {\n return { items: () => [], nodeName: 'captionedReference', ariaLabel: 'References', sectionLabel: 'References', icon: null }\n },\n addProseMirrorPlugins() {\n const options = this.options\n return [\n Suggestion<CaptionedItem>({\n editor: this.editor,\n char: '[',\n pluginKey: new PluginKey('referenceTrigger'),\n ...listening(']'),\n // As a mention's: only where the chip may go.\n allow: ({ state, range }) => {\n const type = state.schema.nodes[options.nodeName]\n return !!type && !!state.doc.resolve(range.from).parent.type.contentMatch.matchType(type)\n },\n items: ({ query }) => listed(options, query),\n render: suggestionPopup({ ...referenceMenu(options), subscribe: options.subscribe, refresh: (query) => listed(options, query) }),\n command: ({ editor, range, props: item }) => {\n editor\n .chain()\n .focus()\n .insertContentAt(range, [\n { type: options.nodeName, attrs: { id: item.id, label: item.label, snippet: item.snippet, uri: item.uri } },\n { type: 'text', text: ' ' },\n ])\n .run()\n },\n }),\n ]\n },\n})\n\n// \u2500\u2500\u2500 / \u2500\u2500\u2500\n\n/** A row of the `/` list, and what choosing it does. */\nexport interface SlashCommand {\n key: string\n row: SuggestionMenuRow\n /** Matched beside the row's label: an id, a trigger, a description. */\n keywords?: readonly string[]\n /** Runs once the `/query` that summoned the list has been removed. */\n run: (editor: Editor) => void\n}\n\nexport interface SlashSection {\n label: string\n commands: readonly SlashCommand[]\n}\n\nexport type FormatId = 'paragraph' | 'heading' | 'subheading' | 'quote' | 'bulletList' | 'orderedList' | 'code'\n\nexport interface FormatDef {\n id: FormatId\n label: string\n /** What you type to get it \u2014 the input rule the extension registers. Blank when there is none. */\n trigger?: string\n /** The trigger when the format makes a block instead \u2014 Code's fence. Blank when it is the same. */\n blockTrigger?: string\n}\n\n/**\n * The formats `/` offers, in order. The hint is what you would type, not a key\n * chord. Bold, italic and underline are absent: they act on text already\n * written, so they are the selection toolbar's.\n */\nexport const FORMATS: readonly FormatDef[] = [\n { id: 'paragraph', label: 'Text' },\n { id: 'heading', label: 'Heading', trigger: '#' },\n { id: 'subheading', label: 'Subheading', trigger: '##' },\n { id: 'quote', label: 'Quote', trigger: '>' },\n { id: 'code', label: 'Code', trigger: '`', blockTrigger: '```' },\n { id: 'bulletList', label: 'Bulleted list', trigger: '-' },\n { id: 'orderedList', label: 'Numbered list', trigger: '1.' },\n]\n\n/** Code as a mark inside the line, or as a block of its own. */\nexport type CodeFormat = 'inline' | 'block'\n\n/**\n * Apply one format to the current block. `set*` wherever Tiptap has one:\n * choosing Heading should make a heading, not turn one off. `false` means\n * nothing changed, not that anything failed.\n */\nexport function applyFormat(editor: Editor, id: FormatId, code: CodeFormat = 'inline'): boolean {\n const chain = editor.chain().focus()\n /*\n The node's own command, called by name: StarterKit's extensions declare\n them, and this package builds without StarterKit. Its own command, rather\n than the core one it wraps, because a list's runs with the app's options\n (`keepMarks`, `itemTypeName`). An editor without that node changes nothing.\n */\n const run = (command: string, ...args: unknown[]): boolean => {\n const named = (chain as unknown as Record<string, ((...a: unknown[]) => { run: () => boolean }) | undefined>)[command]\n return named ? named(...args).run() : false\n }\n switch (id) {\n case 'paragraph':\n return run('setParagraph')\n case 'heading':\n return run('setHeading', { level: 1 })\n case 'subheading':\n return run('setHeading', { level: 2 })\n case 'quote':\n return run('toggleBlockquote')\n case 'bulletList':\n return run('toggleBulletList')\n case 'orderedList':\n return run('toggleOrderedList')\n case 'code':\n return run(code === 'block' ? 'toggleCodeBlock' : 'toggleCode')\n default:\n return false\n }\n}\n\n/** The Format section every app's `/` opens with. */\nexport function formatSection(code: CodeFormat = 'inline'): SlashSection {\n return {\n label: 'Format',\n commands: FORMATS.map((format) => ({\n key: `format-${format.id}`,\n row: { label: format.label, shortcut: (code === 'block' && format.blockTrigger) || format.trigger },\n keywords: [format.id],\n run: (editor) => {\n applyFormat(editor, format.id, code)\n },\n })),\n }\n}\n\n/** A row that types another trigger, so its own list opens \u2014 `@` from `/`. */\nexport function typeTrigger(input: string): SlashCommand['run'] {\n // Deferred a frame: the delete of the `/query` has to land first, or the\n // trigger's plugin sees the character arrive inside a range still being removed.\n return (editor) => {\n requestAnimationFrame(() => editor.commands.insertContent(input))\n }\n}\n\nfunction matches(command: SlashCommand, q: string): boolean {\n return [command.row.label, ...(command.keywords ?? [])].some((text) => text.toLowerCase().includes(q))\n}\n\n/** The sections narrowed to a query \u2014 the text typed after the `/`. Empty sections stay. */\nexport function filterSlashSections(sections: readonly SlashSection[], query: string): SlashSection[] {\n const q = query.toLowerCase()\n return sections.map((section) => ({ ...section, commands: q ? section.commands.filter((command) => matches(command, q)) : section.commands }))\n}\n\nexport interface SlashCommandsOptions {\n /** The sections, in order: {@link formatSection} first, then the app's own. */\n sections: readonly SlashSection[]\n}\n\ntype SlashRow = SlashCommand & { section: number }\n\n/**\n * `/` \u2014 format the line or insert something, at the caret, mid-sentence too.\n * A `/` inside a word (`and/or`, a path) opens nothing: the plugin wants a\n * space or the line's start before it.\n */\nexport const SlashCommands = Extension.create<SlashCommandsOptions>({\n name: 'slashCommands',\n addOptions() {\n return { sections: [formatSection()] }\n },\n addProseMirrorPlugins() {\n const sections = this.options.sections\n return [\n Suggestion<SlashRow>({\n editor: this.editor,\n char: '/',\n startOfLine: false,\n pluginKey: new PluginKey('slashCommands'),\n items: ({ query }) => filterSlashSections(sections, query).flatMap((section, at) => section.commands.map((command) => ({ ...command, section: at }))),\n command: ({ editor, range, props }) => {\n editor.chain().focus().deleteRange(range).run()\n props.run(editor)\n },\n render: suggestionPopup<SlashRow>({\n ariaLabel: 'Commands',\n width: 'w-[300px]',\n maxHeight: 'max-h-[400px]',\n sections: (rows) => sections.map((section, at) => ({ label: section.label, items: rows.filter((row) => row.section === at) })),\n itemKey: (row) => row.key,\n row: (row) => row.row,\n }),\n }),\n ]\n },\n})\n", "import type { ComponentType } from 'react'\nimport { Extension, Node } from '@tiptap/core'\nimport type { Node as ProseMirrorNode, Slice } from '@tiptap/pm/model'\nimport { Plugin, PluginKey, type Transaction } from '@tiptap/pm/state'\nimport { Mapping, ReplaceAroundStep } from '@tiptap/pm/transform'\nimport { NodeViewWrapper, ReactNodeViewRenderer, type ReactNodeViewProps } from '@tiptap/react'\n\n/*\n * The four nodes an editor of a block document needs that a stock schema does\n * not have (SPEC \u00A713.3) \u2014 moved here from Ship's `editorSchema.tsx` (RIC-14,\n * SHI-2) when Peek became the second editor of the same documents (MAN-9).\n *\n * They are one half of a pair. The other half is `@estiva-app/protocol`'s\n * `toEditorDocument` / `fromEditorDocument`, which turn a stored document into\n * the JSON these nodes read and back: the node names (`unknownBlock`,\n * `reference`, `attachment`) and the `blockId` attribute are that translation's,\n * and must not drift from it. This package does not import protocol, as\n * `RichText` does not: the translation hands over everything a view draws.\n *\n * Everything else a document can contain is already a ProseMirror node of the\n * same name \u2014 StarterKit's and TableKit's \u2014 which is why this file is short.\n */\n\n/**\n * The block types \u00A713.3 puts an id on, as the editor's node names \u2014\n * protocol's `EDITOR_BLOCK_TYPES`, less `unknownBlock`, which declares its own.\n */\nconst BLOCK_TYPES = [\n 'paragraph',\n 'heading',\n 'bulletList',\n 'orderedList',\n 'listItem',\n 'blockquote',\n 'codeBlock',\n 'horizontalRule',\n // A table and everything inside it (UIG-18): a row or a cell whose id was\n // re-minted on each save would detach any comment anchored to it.\n 'table',\n 'tableRow',\n 'tableHeader',\n 'tableCell',\n // Without this an attachment's id is re-minted on every save, and every\n // comment anchored to it stops resolving.\n 'attachment',\n]\nconst BLOCK_TYPE_SET = new Set(BLOCK_TYPES)\n\n/** protocol's `newBlockId`: six random bytes as hex. */\nfunction newBlockId(): string {\n return Array.from(crypto.getRandomValues(new Uint8Array(6)), (b) => b.toString(16).padStart(2, '0')).join('')\n}\n\n/** Whether anything typed or inserted is inside \u2014 protocol's `holdsText`. An empty paragraph is not; a lone line break is. */\nfunction holdsText(node: ProseMirrorNode): boolean {\n let found = false\n node.descendants((child) => {\n if (found) return false\n if ((child.isText && child.text !== '') || child.type.name === 'hardBreak' || child.type.name === 'reference') found = true\n return !found\n })\n return found\n}\n\ninterface Claim {\n pos: number\n node: ProseMirrorNode\n /** An unknown block: the translation hands its source back untouched, so re-minting it here would be undone on save. */\n fixed: boolean\n}\n\n/** Every block that claims an id, by id, in document order. */\nfunction claimsIn(doc: ProseMirrorNode): Map<string, Claim[]> {\n const claims = new Map<string, Claim[]>()\n doc.descendants((node, pos) => {\n const fixed = node.type.name === 'unknownBlock'\n if (!fixed && !BLOCK_TYPE_SET.has(node.type.name)) return\n const id = node.attrs.blockId\n if (typeof id !== 'string' || id === '') return\n const copies = claims.get(id)\n if (copies) copies.push({ pos, node, fixed })\n else claims.set(id, [{ pos, node, fixed }])\n })\n return claims\n}\n\n/**\n * The copy the block that was there before carried on into: where the start\n * of its content landed. Enter at the very start pushes that content into the\n * lower half; a split anywhere else leaves it in the upper; a pasted copy,\n * above or below, never moves it out of the original.\n */\nfunction carriedOn(copies: Claim[], before: Claim, mapping: Mapping): Claim | undefined {\n if (before.node.isLeaf) {\n const at = mapping.map(before.pos, 1)\n return copies.find((c) => c.pos === at)\n }\n const at = mapping.map(textStart(before), 1)\n return copies.find((c) => c.pos < at && at < c.pos + c.node.nodeSize)\n}\n\n/** The start of a block's text, inside the paragraph a list item or quote wraps it in. */\nfunction textStart({ pos, node }: { pos: number; node: ProseMirrorNode }): number {\n let start = pos + 1\n if (!node.isTextblock) {\n let found = false\n node.descendants((child, at) => {\n if (found) return false\n if (child.isTextblock) {\n start = pos + 1 + at + 1\n found = true\n }\n return !found\n })\n }\n return start\n}\n\n/**\n * Where a block claims an id another block keeps \u2014 see {@link BlockId}. An\n * unknown block always keeps its id; otherwise the copy the original carried\n * on into, and failing that protocol's rule: the first that holds text, or\n * the first.\n */\nfunction repeatedBlockIds(doc: ProseMirrorNode, before: ProseMirrorNode, mapping: Mapping): number[] {\n const claims = claimsIn(doc)\n let previous: Map<string, Claim[]> | undefined\n const losers: number[] = []\n for (const [id, copies] of claims) {\n if (copies.length < 2) continue\n previous ??= claimsIn(before)\n const original = previous.get(id)?.[0]\n const owner =\n copies.find((c) => c.fixed) ??\n (original && carriedOn(copies, original, mapping)) ??\n copies.find((c) => holdsText(c.node)) ??\n copies[0]\n for (const copy of copies) if (copy !== owner && !copy.fixed) losers.push(copy.pos)\n }\n return losers\n}\n\n/**\n * The blocks a save turns into blocks \u2014 exactly what protocol's\n * `blockFromEditor` walks \u2014 so a list, a table and its rows and cells are\n * walked into, and a list item or a quote is not: the save flattens their\n * paragraph wrappers into inline runs, so an id there would be dropped.\n */\nconst BLOCK_CONTAINERS = new Set(['bulletList', 'orderedList', 'table', 'tableRow', 'tableHeader', 'tableCell'])\n\n/** The wrappers the save flattens: their paragraphs become inline runs of theirs. */\nconst FLATTENED = new Set(['listItem', 'blockquote'])\n\nconst idOf = (node: ProseMirrorNode): string | undefined => {\n const id = node.attrs.blockId\n return typeof id === 'string' && id !== '' ? id : undefined\n}\n\n/** Every block the save turns into a block, in document order. */\nfunction addressedBlocks(doc: ProseMirrorNode): { pos: number; node: ProseMirrorNode }[] {\n const out: { pos: number; node: ProseMirrorNode }[] = []\n const visit = (node: ProseMirrorNode, pos: number) => {\n if (!BLOCK_TYPE_SET.has(node.type.name)) return\n out.push({ pos, node })\n if (BLOCK_CONTAINERS.has(node.type.name)) node.forEach((child, offset) => visit(child, pos + 1 + offset))\n }\n doc.forEach((node, offset) => visit(node, offset))\n return out\n}\n\n/** Where a block the save would give an id has none, so it would get a new one on every save. */\nfunction unnamedBlocks(doc: ProseMirrorNode): number[] {\n return addressedBlocks(doc)\n .filter((b) => idOf(b.node) === undefined)\n .map((b) => b.pos)\n}\n\n/** Where a paragraph inside a list item or a quote claims an id \u2014 which the save drops. */\nfunction hiddenIds(doc: ProseMirrorNode): number[] {\n const out: number[] = []\n doc.descendants((node, pos) => {\n if (!FLATTENED.has(node.type.name)) return\n node.forEach((child, offset) => {\n if (child.isTextblock && idOf(child) !== undefined) out.push(pos + 1 + offset)\n })\n })\n return out\n}\n\n/**\n * The id each block a wrap or a lift brought in takes over \u2014 see\n * {@link BlockId}. An id the save addressed before the change and does not\n * now goes to the innermost new block its text was carried into: the quote or\n * the list item around a paragraph, or the paragraph lifted out of one.\n * A block the change deleted hands nothing on. What it asks is whether the\n * block's own opening survived, the token left of its text, not its first\n * character: the `/` menu and a typed `> ` or `- ` delete what was typed at\n * the very start of the text in the same change as the wrap.\n */\nfunction handedOver(doc: ProseMirrorNode, before: ProseMirrorNode, mapping: Mapping, unnamed: number[]): Map<number, string> {\n const out = new Map<number, string>()\n if (unnamed.length === 0) return out\n const now = new Set(addressedBlocks(doc).map((b) => idOf(b.node)))\n // By where their text starts, and of a list and its item around the same text, the item first.\n const gone = addressedBlocks(before)\n .filter((b) => !b.node.isLeaf && idOf(b.node) !== undefined && !now.has(idOf(b.node)))\n .map((b) => ({ ...b, start: textStart(b) }))\n .sort((a, b) => a.start - b.start || b.pos - a.pos)\n for (const old of gone) {\n const id = idOf(old.node)!\n const { pos: at, deleted } = mapping.mapResult(old.start, -1)\n if (deleted) continue\n let inner: number | undefined\n for (const pos of unnamed) {\n if (out.has(pos)) continue\n if (pos < at && at < pos + doc.nodeAt(pos)!.nodeSize && (inner === undefined || pos > inner)) inner = pos\n }\n if (inner !== undefined) {\n out.set(inner, id)\n now.add(id)\n }\n }\n return out\n}\n\n/**\n * Whether a change could have made a repeat or a block without an id: only a\n * step that brings in blocks can, or one that wraps or lifts them \u2014 lifting\n * the paragraph out of a quote or a one-item list brings in nothing, yet\n * leaves a block the save addresses with the wrapper's missing id. Typing,\n * deleting and marks do neither, so most keystrokes skip the walk.\n */\nfunction bringsInBlocks(transactions: readonly Transaction[]): boolean {\n return transactions.some((tr) =>\n tr.steps.some((step) => {\n if (step instanceof ReplaceAroundStep) return true\n const slice = (step as { slice?: Slice }).slice\n let blocks = false\n slice?.content.forEach((node) => {\n if (node.isBlock) blocks = true\n })\n return blocks\n }),\n )\n}\n\n/**\n * `id` on every block, carried as the `blockId` attribute.\n *\n * A global attribute rather than one per node type, because \u00A713.3 puts an id\n * on **every** block and a type that quietly lacked one would mint a fresh id\n * on every save \u2014 detaching each anchored comment on it (RFC 0.4 \u00A76) with\n * nothing on screen to say so.\n *\n * Rendered as `data-block-id`, which is what `RichText` already emits, so the\n * reading and the editing surface address a block the same way.\n *\n * **A split gives the new half its own id, the moment it happens** (MAN-10).\n * ProseMirror copies a split node's attrs to both halves, so Enter leaves two\n * blocks claiming one id. Enter at the very start of a paragraph puts the\n * copy *above* it \u2014 and once something is typed there, nothing at save time\n * can tell which half was the original, so protocol's `fromEditorDocument`\n * gave the id, and every comment anchored to it, to the new line. Settled\n * here instead, in the same transaction, where the change itself says which\n * copy the original carried on into \u2014 so a copy pasted above a block does\n * not take its id either. The others get fresh ids. `fromEditorDocument`\n * keeps its own rule (the copy that holds text) as the backstop for an\n * editor without this extension; where the change says nothing, this falls\n * back to that rule too.\n *\n * **A block that arrives without an id gets one, the moment it arrives**\n * (MAN-11): a paste, a `/` menu insert, the empty paragraph a new editor\n * starts with and the one StarterKit keeps at the end. `fromEditorDocument`\n * mints an id for such a block on every save and the editor never sees it, so\n * each save gave it a different one \u2014 a blur with no edit published again, and\n * a comment anchored to it in between was detached. The editor's first\n * document is filled in when it is created, outside the undo history and\n * without an update, so opening a description is not an edit.\n *\n * **A wrap or a lift hands the id on** (MAN-12). Turning a paragraph into a\n * quote or a list wraps it, and ProseMirror leaves its attrs on the paragraph\n * inside \u2014 where the save flattens it and drops the id, so the quote or list\n * item was published under a new one and every comment anchored to the\n * paragraph was detached. The quote or the list item takes the paragraph's id\n * instead, and the list around it a fresh one; lifting the text back out hands\n * the id to the paragraph again. The paragraph inside keeps no id, as one\n * loaded from a stored document has none.\n */\nexport const BlockId = Extension.create({\n name: 'blockId',\n onCreate() {\n const { state, view } = this.editor\n const unnamed = unnamedBlocks(state.doc)\n if (unnamed.length === 0) return\n const tr = state.tr\n for (const pos of unnamed) tr.setNodeAttribute(pos, 'blockId', newBlockId())\n view.dispatch(tr.setMeta('addToHistory', false).setMeta('preventUpdate', true))\n },\n addProseMirrorPlugins() {\n return [\n new Plugin({\n key: new PluginKey('blockIdSplit'),\n appendTransaction: (transactions, old, state) => {\n if (!bringsInBlocks(transactions)) return null\n const mapping = new Mapping()\n for (const tr of transactions) mapping.appendMapping(tr.mapping)\n const unnamed = unnamedBlocks(state.doc)\n const handed = handedOver(state.doc, old.doc, mapping, unnamed)\n const ids = new Map<number, string | null>()\n for (const pos of repeatedBlockIds(state.doc, old.doc, mapping)) ids.set(pos, newBlockId())\n for (const pos of unnamed) ids.set(pos, handed.get(pos) ?? newBlockId())\n for (const pos of hiddenIds(state.doc)) ids.set(pos, null)\n if (ids.size === 0) return null\n const tr = state.tr\n for (const [pos, id] of ids) tr.setNodeAttribute(pos, 'blockId', id)\n return tr\n },\n }),\n ]\n },\n addGlobalAttributes() {\n return [\n {\n types: BLOCK_TYPES,\n attributes: {\n blockId: {\n default: null,\n parseHTML: (element: HTMLElement) => element.getAttribute('data-block-id'),\n renderHTML: (attributes: Record<string, unknown>) =>\n attributes.blockId ? { 'data-block-id': String(attributes.blockId) } : {},\n },\n },\n },\n ]\n },\n})\n\n/** What a reference's view is handed: the `nostr:` URI it stands for. */\nexport interface ReferenceViewProps {\n uri: string\n}\n\nexport interface ReferenceNodeOptions {\n /**\n * Draws the reference as the thing it points at \u2014 the app's own chip, which\n * knows how to resolve it. Without one, the URI is drawn as text.\n */\n view: ComponentType<ReferenceViewProps> | null\n}\n\n/**\n * A `nostr:` reference, drawn as the thing it points at \u2014 SPEC \u00A713.1.\n *\n * An **atom**: it has no editable interior, because its text is the URI and\n * nobody edits half a `naddr`. Selecting it selects the whole reference, which\n * is also how deleting one works. `marks` carries the run's other marks, so a\n * bold reference comes back bold.\n */\nexport const ReferenceNode = Node.create<ReferenceNodeOptions>({\n name: 'reference',\n group: 'inline',\n inline: true,\n atom: true,\n selectable: true,\n draggable: false,\n addOptions() {\n return { view: null }\n },\n addAttributes() {\n return {\n uri: { default: '' },\n marks: { default: [] as string[] },\n }\n },\n parseHTML() {\n return [{ tag: 'span[data-reference]' }]\n },\n renderHTML({ node }) {\n // A copy to the clipboard as HTML, and the whole drawing when no view is given.\n return ['span', { 'data-reference': String(node.attrs.uri) }, String(node.attrs.uri)]\n },\n addNodeView() {\n const View = this.options.view\n if (!View) return null\n return ReactNodeViewRenderer(({ node }: ReactNodeViewProps) => (\n <NodeViewWrapper as=\"span\" className=\"inline\">\n <View uri={String(node.attrs.uri ?? '')} />\n </NodeViewWrapper>\n ))\n },\n})\n\n/**\n * A block this editor has no design for, kept whole.\n *\n * \u00A713.3: a reader MUST render an unknown block's inline text and MUST NOT drop\n * it silently. **An editor is the dangerous case** \u2014 ProseMirror discards a\n * node its schema does not know, and the save after that would delete somebody\n * else's block with no error anywhere on the way. So the block's own JSON\n * rides in `source`, and protocol's `fromEditorDocument` hands it back\n * untouched; `text` is its inline text, worked out by `toEditorDocument`.\n *\n * Not editable, deliberately: an affordance that lets a person change\n * something they cannot see is worse than one that says the content is there\n * and belongs to another surface.\n */\nexport const UnknownBlock = Node.create({\n name: 'unknownBlock',\n group: 'block',\n atom: true,\n selectable: true,\n addAttributes() {\n return {\n blockId: { default: null },\n source: { default: null },\n text: { default: '' },\n }\n },\n parseHTML() {\n return [{ tag: 'div[data-unknown-block]' }]\n },\n renderHTML({ node }) {\n return ['div', { 'data-unknown-block': String(node.attrs.blockId ?? '') }, String(node.attrs.text ?? '')]\n },\n addNodeView() {\n return ReactNodeViewRenderer(UnknownBlockView)\n },\n})\n\nfunction UnknownBlockView({ node }: ReactNodeViewProps) {\n const source = node.attrs.source as { id?: string; type?: string } | null\n const text = String(node.attrs.text ?? '')\n return (\n <NodeViewWrapper\n data-block-id={source?.id}\n data-block-type={source?.type}\n className=\"rounded-md border border-border-default bg-bg-inset px-2 py-1 text-text-secondary\"\n >\n {text || `A ${source?.type ?? 'block'} this app cannot edit yet.`}\n </NodeViewWrapper>\n )\n}\n\n/** What an attachment's view is handed: the block's `imeta` fields. */\nexport interface AttachmentViewProps {\n attrs: Record<string, unknown>\n}\n\nexport interface AttachmentNodeOptions {\n /** Draws the file \u2014 the app's own attachment card. Without one, its name is drawn as text. */\n view: ComponentType<AttachmentViewProps> | null\n}\n\n/**\n * A file placed in a document \u2014 SPEC \u00A713.3's `attachment` block (SHI-2).\n *\n * An atom: the file is the block, there is nothing inside it to edit, and a\n * caret that could sit \"inside\" an image is a way to produce documents no\n * reader has a rule for. Selectable and deletable, so removing one is Backspace\n * like anything else.\n *\n * Its attributes are the `imeta` fields exactly, because that is what \u00A713.3\n * specifies. Each is declared, and that is not boilerplate: ProseMirror **drops\n * an attribute its schema does not name**, so an undeclared `thumb` would\n * survive the editor and vanish on save \u2014 the silent deletion `UnknownBlock`\n * exists to prevent.\n */\nexport const AttachmentNode = Node.create<AttachmentNodeOptions>({\n name: 'attachment',\n group: 'block',\n atom: true,\n selectable: true,\n draggable: false,\n addOptions() {\n return { view: null }\n },\n addAttributes() {\n return {\n url: { default: '' },\n m: { default: '' },\n x: { default: '' },\n size: { default: 0 },\n dim: { default: null },\n thumb: { default: null },\n alt: { default: null },\n filename: { default: null },\n }\n },\n parseHTML() {\n return [{ tag: 'div[data-attachment-block]' }]\n },\n renderHTML({ node }) {\n // A copy to the clipboard, and the whole drawing when no view is given.\n return ['div', { 'data-attachment-block': String(node.attrs.x ?? '') }, String(node.attrs.filename ?? 'attachment')]\n },\n addNodeView() {\n const View = this.options.view\n if (!View) return null\n return ReactNodeViewRenderer(({ node }: ReactNodeViewProps) => (\n <NodeViewWrapper className=\"my-2\">\n <View attrs={node.attrs} />\n </NodeViewWrapper>\n ))\n },\n})\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,aAAa,WAAW,QAAQ,gBAAgB;AAEzD,SAAS,iBAAiB;AAC1B,SAAS,QAAQ,iBAAiB;AAClC,SAAS,YAAY,qBAAqB;AAC1C,SAAS,UAAU,UAAU,YAAY,UAAU,qBAAqB;AACxE,SAAS,YAAY;AACrB,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAS,SAAS,qBAAqB;AACvC,SAAS,qBAAqB;AAsatB,cAqBA,YArBA;AA5YD,IAAM,mBAAmB,IAAI,UAA4B,eAAe;AAGxE,IAAM,gBAAgB,UAAU,OAAO;AAAA,EAC5C,MAAM;AAAA,EAEN,wBAAwB;AACtB,WAAO;AAAA,MACL,IAAI,OAAyB;AAAA,QAC3B,KAAK;AAAA,QACL,OAAO;AAAA,UACL,MAAM,MAAM;AAAA,UACZ,MAAM,IAAI,UAAU;AAClB,kBAAM,OAAO,GAAG,QAAQ,gBAAgB;AACxC,gBAAI,SAAS,OAAW,QAAO;AAC/B,gBAAI,CAAC,SAAU,QAAO;AAGtB,mBAAO,EAAE,MAAM,GAAG,QAAQ,IAAI,SAAS,IAAI,GAAG,IAAI,GAAG,QAAQ,IAAI,SAAS,EAAE,EAAE;AAAA,UAChF;AAAA,QACF;AAAA,QACA,OAAO;AAAA,UACL,YAAY,OAAO;AACjB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A,IAC5B;AAAA,EACF;AAAA,EACA,YAAY;AACV,WAAO,CAAC,EAAE,KAAK,6BAA6B,CAAC;AAAA,EAC/C;AAAA,EACA,WAAW,EAAE,KAAK,GAAG;AAEnB,WAAO,CAAC,OAAO,EAAE,yBAAyB,OAAO,KAAK,MAAM,KAAK,EAAE,EAAE,GAAG,OAAO,KAAK,MAAM,YAAY,YAAY,CAAC;AAAA,EACrH;AAAA,EACA,cAAc;AACZ,UAAM,OAAO,KAAK,QAAQ;AAC1B,QAAI,CAAC,KAAM,QAAO;AAClB,WAAOI,uBAAsB,CAAC,EAAE,KAAK,MACnC,gBAAAC,KAACF,kBAAA,EAAgB,WAAU,QACzB,0BAAAE,KAAC,QAAK,OAAO,KAAK,OAAO,GAC3B,CACD;AAAA,EACH;AACF,CAAC;",
|
|
3
|
+
"sources": ["../src/SelectionToolbar.tsx", "../src/PastedImages.ts", "../src/CodeBlockColours.ts", "../src/codeColours.ts", "../src/suggestionPopup.tsx", "../src/EditorBlockHandle.tsx", "../src/ComposerTriggers.tsx", "../src/BlockNodes.tsx"],
|
|
4
|
+
"sourcesContent": ["import { useCallback, useEffect, useRef, useState } from 'react'\nimport type { Editor } from '@tiptap/react'\nimport { Extension } from '@tiptap/core'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\nimport { Decoration, DecorationSet } from '@tiptap/pm/view'\nimport { IconBold, IconCode, IconItalic, IconLink, IconUnderline } from '@tabler/icons-react'\nimport { Form } from './Form'\nimport { Popover } from './Popover'\nimport { TextInput } from './TextInput'\nimport { Toolbar, ToolbarButton } from './Toolbar'\nimport { shortcutLabel } from './shortcuts'\n\n/**\n * The selection, kept visible while something else has the focus \u2014 Peek's\n * `src/extensions/keptSelection.ts` (PEE-19), moved into the package with the\n * `SelectionToolbar` that needs it (UIG-31, Katerina's ruling 29 September).\n *\n * The toolbar's address field takes the focus, and with it the document's\n * one selection, so the words being linked lost their highlight the moment\n * the field opened (measured 2026-09-07). Linear keeps it, and Katerina asked\n * for the same. The editor's own selection never moved \u2014 ProseMirror keeps it\n * while unfocused \u2014 so this only *draws* it: an inline decoration over the\n * range, in `bg-selected` \u2014 the token Peek's composer paints `::selection` in,\n * mapped through edits and cleared when the field closes.\n *\n * A decoration rather than a second selection, because a document has one\n * and the field needs it. Editor-internal by design (the editor owns its own\n * drawing); nothing here floats, focuses or handles a key.\n */\n\nexport interface KeptRange {\n from: number\n to: number\n}\n\n/** The plugin's key: read what is being kept, or dispatch a change to it. */\nexport const keptSelectionKey = new PluginKey<KeptRange | null>('keptSelection')\n\n/** The extension an editor registers so a selection can stay drawn while a field has the focus. */\nexport const KeptSelection = Extension.create({\n name: 'keptSelection',\n\n addProseMirrorPlugins() {\n return [\n new Plugin<KeptRange | null>({\n key: keptSelectionKey,\n state: {\n init: () => null,\n apply(tr, previous) {\n const meta = tr.getMeta(keptSelectionKey) as KeptRange | null | undefined\n if (meta !== undefined) return meta\n if (!previous) return null\n // Follow the words through an edit, so applying the link to them\n // (or typing before them) does not leave the highlight behind.\n return { from: tr.mapping.map(previous.from), to: tr.mapping.map(previous.to) }\n },\n },\n props: {\n decorations(state) {\n const range = keptSelectionKey.getState(state)\n if (!range || range.from === range.to) return null\n return DecorationSet.create(state.doc, [\n Decoration.inline(range.from, range.to, { class: 'kept-selection bg-bg-selected' }),\n ])\n },\n },\n }),\n ]\n },\n})\n\n/** Draw the selection as it is now, until `releaseSelection`. */\nexport function keepSelection(editor: Editor) {\n const { from, to } = editor.state.selection\n editor.view.dispatch(editor.state.tr.setMeta(keptSelectionKey, { from, to }))\n}\n\n/** Stop drawing it. Nothing kept, nothing dispatched. */\nexport function releaseSelection(editor: Editor) {\n if (editor.isDestroyed || !keptSelectionKey.getState(editor.state)) return\n editor.view.dispatch(editor.state.tr.setMeta(keptSelectionKey, null))\n}\n\n/** What is being drawn, or null. */\nexport function keptSelection(editor: Editor): KeptRange | null {\n return keptSelectionKey.getState(editor.state) ?? null\n}\n\n/** A mark the strip can toggle \u2014 the suite's inline vocabulary (SPEC \u00A713.1) less link and reference. */\nexport type MarkId = 'bold' | 'italic' | 'underline' | 'code'\n\nconst MARKS: Record<MarkId, { label: string; keys: string }> = {\n bold: { label: 'Bold', keys: 'Mod-B' },\n italic: { label: 'Italic', keys: 'Mod-I' },\n underline: { label: 'Underline', keys: 'Mod-U' },\n code: { label: 'Code', keys: 'Mod-E' },\n}\n\n/**\n * Toggle one mark over the current selection. The core `toggleMark`, which\n * each mark's own `toggleBold` and the like wrap: the package names no Tiptap\n * extension, only the marks the suite's format has (SPEC \u00A713.1).\n */\nfunction toggleMark(editor: Editor, id: MarkId): boolean {\n return editor.chain().focus().toggleMark(id).run()\n}\n\n/** The address the selection sits in, or '' \u2014 what the link field opens with. */\nexport function currentLink(editor: Editor): string {\n const href: unknown = editor.getAttributes('link').href\n return typeof href === 'string' ? href : ''\n}\n\n/**\n * What somebody typed into the link field \u2192 an `href`, or null when it cannot\n * be one. A bare host (`google.com`) gets `https://`. A scheme is kept only when\n * SPEC \u00A713.1 lets a reader follow it (http, https, mailto); `javascript:` and\n * the like are refused here. `localhost:5173` is a host and a port: a scheme is\n * never followed by a digit.\n */\nexport function normalizeHref(raw: string): string | null {\n const s = raw.trim()\n if (!s || /\\s/.test(s)) return null\n if (/^(https?:|mailto:)/i.test(s)) return s\n if (/^[a-z][a-z0-9+.-]*:(?!\\d)/i.test(s)) return null\n return `https://${s}`\n}\n\n/**\n * Apply the link field to the selection. Empty removes the link; an address\n * sets it, over the whole link when the caret sits inside one. `false` means\n * the text could not be an address, and the field should stay open.\n */\nexport function applyLink(editor: Editor, raw: string): boolean {\n const chain = editor.chain().focus().extendMarkRange('link')\n // The core commands the Link extension's `setLink` and `unsetLink` wrap, with\n // the same meta; `normalizeHref` has already refused what it would refuse.\n if (!raw.trim()) return chain.unsetMark('link', { extendEmptyMarkRange: true }).setMeta('preventAutolink', true).run()\n const href = normalizeHref(raw)\n if (!href) return false\n return chain.setMark('link', { href }).setMeta('preventAutolink', true).run()\n}\n\n/**\n * Bold / italic / underline / link over selected text \u2014 Peek's\n * `SelectionToolbar` (PEE-18, PEE-19), moved into the package at Katerina's\n * word (29 September, UIG-31) when Ship's description became its second user.\n * Unchanged but for two props: `marks`, which buttons the strip has (Peek's\n * three by default; Ship adds code), and `link`, whether it has the Link button\n * and its field (Peek's editor has a link mark; an editor without one leaves it\n * off). The editor must register `KeptSelection` when `link` is on.\n *\n * The marks apply to a run you have already written, which is why they are\n * not in the `/` menu: typing `/` replaces the selection, so by definition\n * there is nothing selected to apply them to.\n *\n * **The chrome is the shared `Popover`, anchored** (P26). It was a `Menu`, and\n * it never was one: a menu gives its contents roving focus and typeahead,\n * which would fight the link field this panel exists for. An anchored\n * `Popover` is the mode built for exactly this \u2014 it takes no focus, so the\n * caret stays in the text. It is laid out as a row instead of a column\n * through `className`, which `cn` merges last. The panel still portals out of\n * the composer, so no overflow clips it, and Floating UI clamps it on screen.\n *\n * **The anchor is the selection's own point** since 0.12.2. This toolbar is\n * *centred* over the selection (her design, PEE-19, after Linear), and the\n * package's `Popover` aligns left or right only \u2014 Base UI has `center`, the\n * package does not expose it (ADOPTION **B21**). So the placement arithmetic\n * and the hand-measured `SIZE` box stay for now, and the rect handed over is\n * positioned so the panel lands on the same pixel it always has: the\n * package's own 4px gap is subtracted from this file's 8px, and the rect's\n * left edge is the panel's. When `align=\"center\"` exists, `SIZE`, `GAP` and\n * `placement` all go and the anchor becomes the selection's own rect.\n *\n * **Two faces** (PEE-19 \u2014 Katerina, 2026-09-07, after Linear). `marks` is the\n * row of four buttons. `link` is one text field for the address: it opens from\n * the Link button, and opens by itself when the settled selection sits inside\n * a link, with that link's address in it. There is no open, embed or delete\n * button, by her call: the field is the whole control.\n *\n * **What applies the field** (her rule, same day): Enter, and clicking away \u2014\n * anywhere outside the toolbar, the editor included. Enter on an empty field\n * removes the link; clicking away with an empty field changes nothing, since\n * removing is deliberate and leaving is not. Escape drops what was typed and\n * puts the caret back. Once applied, the caret lands after the link, and\n * typing goes on as plain text \u2014 the mark is not inclusive (editorKit).\n *\n * While the field has focus the editor has not, so everything below that\n * hides the toolbar on blur or on an empty editor selection stands down in\n * `link` mode. The editor keeps its selection while unfocused; `focus()` in\n * the apply command puts it back.\n *\n * **Why it waits.** Showing on every selection change put the toolbar under the\n * pointer mid-drag, and made it blink on a plain click \u2014 ProseMirror restores\n * the previous selection when the editor takes focus and collapses it a tick\n * later, so there is a real, non-empty range in between. Both go away by\n * refusing to show while the pointer is down and re-reading the selection after\n * a short settle rather than trusting the event that woke us.\n */\n\nconst ICONS: Record<MarkId, typeof IconBold> = {\n bold: IconBold,\n italic: IconItalic,\n underline: IconUnderline,\n code: IconCode,\n}\n\ntype Mode = 'marks' | 'link'\n\n/** How long a selection must stand still before the toolbar appears. */\nconst SETTLE_MS = 250\nconst GAP = 8\n/** The gap the package's `Popover` adds of its own, subtracted above so the\n * panel keeps this file's 8px. Read from `Popover.tsx`, not guessed. */\nconst POPOVER_GAP = 4\n\nexport interface SelectionToolbarProps {\n /** The editor whose selection the strip follows. `null` while it loads. */\n editor: Editor | null\n /** Which marks the strip toggles, in order. Default bold, italic, underline. */\n marks?: readonly MarkId[]\n /** The Link button and its address field. Needs a link mark in the editor and `KeptSelection`. Default off. */\n link?: boolean\n}\n\nexport function SelectionToolbar({ editor, marks = ['bold', 'italic', 'underline'], link = false }: SelectionToolbarProps) {\n /** The selection's top edge and horizontal centre; the face decides the rest. */\n const [anchor, setAnchor] = useState<{ top: number; centre: number } | null>(null)\n const [mode, setMode] = useState<Mode>('marks')\n const [url, setUrl] = useState('')\n // Re-render as marks turn on and off while the caret moves through the\n // selection, so the pressed states stay honest.\n const [, setTick] = useState(0)\n const timer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)\n const pointerDown = useRef(false)\n const field = useRef<HTMLInputElement>(null)\n /** What the field holds while it is open; null while it is closed. The\n * listeners below are bound once, so they read this rather than state. */\n const draft = useRef<string | null>(null)\n // Read by the same listeners. Kept in an effect, declared before the focus\n // effect below so the ref already says `link` when the field's focus blurs\n // the editor.\n const modeRef = useRef<Mode>('marks')\n useEffect(() => {\n modeRef.current = mode\n }, [mode])\n // Read by `settle`, which is bound once: words already a link open the field only when there is one.\n const linkOn = useRef(link)\n linkOn.current = link\n\n const hide = useCallback(() => {\n clearTimeout(timer.current)\n draft.current = null\n if (editor) releaseSelection(editor)\n setAnchor(null)\n setMode('marks')\n }, [editor])\n\n /**\n * Leaving the field applies it (Enter or a click away). An address links the\n * words and the caret moves past them; an empty field on the way out is a\n * shrug, not a removal. Idempotent: the outside click reaches this twice,\n * once from the editor press and once from the Menu's own listener.\n */\n const commit = useCallback(() => {\n const text = draft.current\n if (text === null || !editor) return\n draft.current = null\n if (text.trim() && applyLink(editor, text)) {\n editor.commands.setTextSelection(editor.state.selection.to)\n }\n hide()\n }, [editor, hide])\n\n /** Read the selection as it is *now* and place the toolbar, or hide it. */\n const settle = useCallback(() => {\n if (!editor || editor.isDestroyed) return\n // Keeping the selection drawn is itself a transaction, which schedules\n // this; by then the field has the focus, and reading `hasFocus()` here\n // would close it.\n if (modeRef.current === 'link') return\n const { state, view } = editor\n const { empty, from, to } = state.selection\n if (empty || from === to || !view.hasFocus() || pointerDown.current) {\n setAnchor(null)\n setMode('marks')\n return\n }\n const start = view.coordsAtPos(from)\n const end = view.coordsAtPos(to)\n const centre = (Math.min(start.left, end.left) + Math.max(start.right, end.right)) / 2\n // Words that are already a link open on the field, with their address in it.\n const inLink = linkOn.current && editor.isActive('link')\n const address = inLink ? currentLink(editor) : ''\n draft.current = inLink ? address : null\n // The field is about to take the focus; the words stay highlighted.\n if (inLink) keepSelection(editor)\n setMode(inLink ? 'link' : 'marks')\n setUrl(address)\n setAnchor({ top: start.top, centre })\n }, [editor])\n\n useEffect(() => {\n if (!editor) return\n\n const schedule = () => {\n // The field owns the keyboard and the focus; the editor's own events\n // stand down until it closes.\n if (modeRef.current === 'link') return\n setTick((t) => t + 1)\n clearTimeout(timer.current)\n // A collapsed selection hides at once \u2014 waiting to hide is what made the\n // click blink. Only *showing* is deferred.\n if (editor.state.selection.empty) {\n setAnchor(null)\n return\n }\n timer.current = setTimeout(settle, SETTLE_MS)\n }\n\n // The field taking focus is the one blur that must not hide us.\n const onBlur = () => {\n if (modeRef.current !== 'link') hide()\n }\n\n // Only a press *inside the editor* starts a selection. A press on the\n // toolbar itself must not hide it \u2014 doing so unmounted the button before\n // its click could land, so nothing ever applied.\n const startsSelection = (e: MouseEvent) =>\n e.target instanceof Node && editor.view.dom.contains(e.target)\n\n const onPointerDown = (e: MouseEvent) => {\n if (!startsSelection(e)) return\n // A press in the editor while the field is open is a click away: apply\n // first, before the editor moves the caret under the press.\n commit()\n pointerDown.current = true\n hide()\n }\n const onPointerUp = () => {\n if (!pointerDown.current) return\n pointerDown.current = false\n schedule()\n }\n\n editor.on('selectionUpdate', schedule)\n editor.on('transaction', schedule)\n editor.on('blur', onBlur)\n // @estiva-escape(no-hand-rolled-behaviour): watches presses in the editor to follow a text selection; the Popover it opens in has no trigger to own that (Peek's UIG-8 escape, moved here with the part, UIG-31)\n document.addEventListener('mousedown', onPointerDown, true)\n document.addEventListener('mouseup', onPointerUp, true)\n\n return () => {\n clearTimeout(timer.current)\n editor.off('selectionUpdate', schedule)\n editor.off('transaction', schedule)\n editor.off('blur', onBlur)\n document.removeEventListener('mousedown', onPointerDown, true)\n document.removeEventListener('mouseup', onPointerUp, true)\n }\n }, [editor, settle, hide, commit])\n\n // The field takes focus once it is on screen. Not `autoFocus`, and not in\n // the same frame: the Menu renders once hidden to measure itself, and a\n // hidden input cannot take focus \u2014 measured 2026-09-07, the field opened\n // unfocused on a re-selected link. An address already in it is selected\n // whole, so typing replaces it.\n useEffect(() => {\n if (mode !== 'link' || !anchor) return\n const frame = requestAnimationFrame(() => {\n field.current?.focus()\n field.current?.select()\n })\n return () => cancelAnimationFrame(frame)\n }, [mode, anchor])\n\n if (!editor || !anchor) return null\n\n const openField = () => {\n const address = currentLink(editor)\n draft.current = address\n keepSelection(editor)\n setUrl(address)\n setMode('link')\n }\n /** Enter. Unlike a click away, an empty field here means remove. */\n const submit = () => {\n if (!url.trim()) {\n applyLink(editor, '')\n hide()\n editor.commands.focus()\n return\n }\n commit()\n }\n const discard = () => {\n hide()\n editor.commands.focus()\n }\n\n /* A zero-sized rect at the selection's own top edge and centre. The panel's\n width is no longer this file's business: `align=\"center\"` puts the\n panel's middle over this point (B21, package 0.12.2), so the measured\n `SIZE` table and the placement arithmetic that stood in for it are gone.\n The top is this file's GAP less the package's own 4, so the panel keeps\n the 8px it has always had. */\n const anchorRect = new DOMRect(anchor.centre, anchor.top - (GAP - POPOVER_GAP), 0, 0)\n\n return (\n <Popover\n anchor={anchorRect}\n open\n side=\"top\"\n align=\"center\"\n onOpenChange={(next) => {\n if (!next) commit()\n }}\n ariaLabel=\"Text formatting\"\n // The panel gives up its column; the strip inside draws the row. The 4px\n // around it is `contentClassName`'s: on `className` it was added to the\n // package's 8px from 0.12.6 on, and the toolbar grew 8px a side\n // (Katerina, 2026-09-13; migration docs D68, Finding 60). This is the\n // package's own `Popover/A toolbar` story, class for class.\n className=\"w-auto min-w-0\"\n contentClassName=\"p-1\"\n >\n {mode === 'link' ? (\n /* One field, so no strip: a toolbar of one control is a toolbar in\n name only, and `ToolbarInput` cannot take the ref this field is\n focused by (ADOPTION B25). */\n // The package Form (UIG-7): Enter applies the link. `free` and `flex`: one field, which keeps its own height.\n <Form onSubmit={submit} layout=\"free\" className=\"flex\">\n <TextInput\n ref={field}\n value={url}\n onChange={(e) => {\n setUrl(e.target.value)\n draft.current = e.target.value\n }}\n onKeyDown={(e) => {\n if (e.key === 'Escape') {\n // Before the Menu's own Escape, which would apply instead.\n e.stopPropagation()\n discard()\n }\n }}\n placeholder=\"Enter link URL\"\n aria-label=\"Link URL\"\n className=\"w-[264px]\"\n />\n </Form>\n ) : (\n /* Four marks and a link button: one Tab stop, \u2190 \u2192 along them (D29). */\n <Toolbar aria-label=\"Text formatting\" surface={false}>\n {marks.map((id) => {\n const Icon = ICONS[id]\n const active = editor.isActive(id)\n return (\n <ToolbarButton\n key={id}\n aria-label={MARKS[id].label}\n pressed={active}\n tooltip={MARKS[id].label}\n tooltipShortcut={shortcutLabel(MARKS[id].keys)}\n // Keep the selection: focus must not leave the editor on press.\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => toggleMark(editor, id)}\n >\n <Icon size={16} stroke={1.5} />\n </ToolbarButton>\n )\n })}\n {link && (\n <ToolbarButton\n aria-label=\"Link\"\n tooltip=\"Link\"\n onMouseDown={(e) => e.preventDefault()}\n onClick={openField}\n >\n <IconLink size={16} stroke={1.5} />\n </ToolbarButton>\n )}\n </Toolbar>\n )}\n </Popover>\n )\n}\n", "import { Extension } from '@tiptap/core'\nimport { Plugin, PluginKey } from '@tiptap/pm/state'\n\n/** As much of a `DataTransfer` as the paste reads. */\nexport interface ClipboardSource {\n files?: ArrayLike<File> | null\n getData(format: string): string\n}\n\n/** MIME type \u2192 the extension a pasted picture is named with. */\nconst IMAGE_EXTENSIONS: Record<string, string> = {\n 'image/png': 'png',\n 'image/jpeg': 'jpg',\n 'image/gif': 'gif',\n 'image/webp': 'webp',\n 'image/heic': 'heic',\n 'image/heif': 'heif',\n 'image/svg+xml': 'svg',\n}\n\n/** Names a browser invents for a clipboard picture. A made-up one is better. */\nconst GENERIC_STEMS = new Set(['image', 'blob', 'unknown', 'untitled', 'screenshot'])\n\n/*\n An unlisted type keeps its own subtype rather than becoming `png`, so a\n picture the app does not accept is refused by the app's own message instead\n of arriving disguised as one it does.\n*/\nfunction extensionFor(contentType: string): string {\n const type = contentType.toLowerCase()\n return IMAGE_EXTENSIONS[type] ?? type.split('/')[1]?.split('+')[0] ?? 'png'\n}\n\n/** `'Screenshot 2026-09-07 14-32-05.png'`: sortable, and readable on a file card. */\nexport function pastedImageName(contentType: string, at: Date = new Date(), index = 0): string {\n const pad = (n: number) => String(n).padStart(2, '0')\n const stamp =\n `${at.getFullYear()}-${pad(at.getMonth() + 1)}-${pad(at.getDate())} ` +\n `${pad(at.getHours())}-${pad(at.getMinutes())}-${pad(at.getSeconds())}`\n const nth = index > 0 ? ` (${index + 1})` : ''\n return `Screenshot ${stamp}${nth}.${extensionFor(contentType)}`\n}\n\n/** A real filename is kept; `image.png`, `blob` and '' are not names. */\nfunction hasUsableName(name: string): boolean {\n const dot = name.lastIndexOf('.')\n if (dot <= 0 || dot === name.length - 1) return false\n return !GENERIC_STEMS.has(name.slice(0, dot).toLowerCase())\n}\n\n/**\n * The pictures on the clipboard, named \u2014 `[]` when there is nothing to attach.\n *\n * **Text wins.** A copy from a spreadsheet or a document puts a rendered\n * picture of the selection beside the text; attaching the picture instead of\n * pasting the text is wrong every time. So a clipboard holding text is left to\n * the editor, and a screenshot, which holds none, lands here. Pictures only:\n * any other file comes through the app's own file picker.\n */\nexport function pastedImages(source: ClipboardSource | null | undefined, at: Date = new Date()): File[] {\n if (!source) return []\n if (source.getData('text/plain').trim() !== '') return []\n const images = Array.from(source.files ?? []).filter((f) => f.type.toLowerCase().startsWith('image/'))\n let generated = 0\n return images.map((file) =>\n hasUsableName(file.name)\n ? file\n : new File([file], pastedImageName(file.type, at, generated++), { type: file.type, lastModified: file.lastModified }),\n )\n}\n\nexport interface PastedImagesOptions {\n /**\n * The pictures a paste carried, named. Return `true` when the app took them\n * (an upload started), `false` to let the editor paste as it would have \u2014\n * for a box that cannot upload right now.\n */\n onImages: (files: File[]) => boolean\n}\n\n/**\n * Pasting a picture attaches it: a screenshot pasted into the editor reaches\n * the app as named files, the way the app's own file picker would hand them.\n * Text on the clipboard wins (see {@link pastedImages}).\n */\nexport const PastedImages = Extension.create<PastedImagesOptions>({\n name: 'pastedImages',\n addOptions() {\n return { onImages: () => false }\n },\n addProseMirrorPlugins() {\n const options = this.options\n return [\n new Plugin({\n key: new PluginKey('pastedImages'),\n props: {\n handlePaste: (_view, event) => {\n const files = pastedImages(event.clipboardData)\n return files.length > 0 && options.onImages(files)\n },\n },\n }),\n ]\n },\n})\n", "/** The editor's code block, coloured by language like RichText's (`@estiva-app/ui/editor`). */\nimport { CodeBlockLowlight } from '@tiptap/extension-code-block-lowlight'\nimport { lowlight } from './codeColours'\n\n/*\n The editor library guesses a language for a block that names none, or names\n one it does not know, and colours it by the guess. RichText never guesses, so\n that block was coloured while written and plain once read. A block is\n coloured only by the language it names, while written and when read\n (Katerina, 9 October: never guess).\n*/\nconst namedOnly = {\n highlight: (language: string, value: string) => lowlight().highlight(language, value),\n highlightAuto: (value: string) => ({ type: 'root' as const, children: [{ type: 'text' as const, value }], data: { language: undefined, relevance: 0 } }),\n listLanguages: () => lowlight().listLanguages(),\n registered: (language: string) => lowlight().registered(language),\n}\n\n/**\n * A code block in the editor, with the colours RichText reads it in (Katerina,\n * 9 October): the same highlight.js languages, the same classes, and the\n * editor's root wears `richTextClassName`, which colours them.\n *\n * It replaces the starter kit's code block: `StarterKit.configure({ codeBlock: false })`,\n * then add `CodeBlockColours`. The block keeps its name, `codeBlock`, and its\n * `language` attribute, so nothing already written changes.\n */\nexport const CodeBlockColours = CodeBlockLowlight.configure({ lowlight: namedOnly })\n", "import { createElement, type ReactNode } from 'react'\nimport { common, createLowlight } from 'lowlight'\n\n/**\n * Colours inside a code block, by language (Katerina, 9 October).\n *\n * highlight.js reads the code and names each word (a keyword, a string, a\n * comment); RichText's class list gives each name its colour from the theme's\n * `syntax-*` tokens. The same instance colours the editor's code block\n * (`CodeBlockColours`), so what is written looks the same as what is read.\n *\n * `common` is highlight.js's 37 everyday languages. A language outside them, or\n * none, leaves the code in one colour.\n *\n * Made the first time code is coloured, not when the package loads: a call at\n * the top of the file is kept by every app's bundler, so an app that never draws\n * code carried highlight.js too (measured: an app importing only `Link` was\n * 55 KB gzipped).\n */\nlet instance: ReturnType<typeof createLowlight> | undefined\nexport function lowlight() {\n return (instance ??= createLowlight(common))\n}\n\ninterface HastNode {\n type: string\n value?: string\n properties?: { className?: string[] }\n children?: HastNode[]\n}\n\nfunction draw(node: HastNode, key: number): ReactNode {\n if (node.type === 'text') return node.value\n return createElement('span', { key, className: node.properties?.className?.join(' ') }, (node.children ?? []).map(draw))\n}\n\n/** The code, its words wrapped in highlight.js's classes; the text as it is when the language is unknown. */\nexport function codeColours(text: string, language?: string): ReactNode {\n if (!language || !lowlight().registered(language)) return text\n return (lowlight().highlight(language, text).children as HastNode[]).map(draw)\n}\n", "// @estiva-escape(component-has-a-page, component-has-a-story): draws nothing of its own \u2014 it opens a SuggestionMenu from a Tiptap suggestion plugin, and SuggestionMenu's page and stories show it (UIG-31)\nimport { forwardRef, useRef, useImperativeHandle } from 'react'\nimport { ReactRenderer } from '@tiptap/react'\nimport { exitSuggestion, type SuggestionKeyDownProps, type SuggestionOptions, type SuggestionProps } from '@tiptap/suggestion'\nimport { SuggestionMenu, type SuggestionMenuHandle, type SuggestionMenuRow, type SuggestionMenuSection } from './SuggestionMenu'\n\n/*\n * Is a type-ahead list open? \u2014 Peek's counter (`mention.tsx`), moved here with\n * the lists it counts (UIG-31).\n *\n * A counter rather than a boolean: two suggestion plugins can overlap for a\n * moment while one hands over to the other (`/` choosing \"Mention\" types `@`).\n * An editor asks before it acts on Enter or Escape, so a key that chose a row\n * does not also send the message or cancel the edit.\n *\n * A list counts while it shows rows, not while its trigger listens: since a\n * space stopped closing one (f586437a), \"meet @ 5pm\" leaves `@` listening\n * behind a hidden list to the end of the line, and that Enter must still send.\n *\n * And only while its editor has focus (71a4577b): a list left by a click ends,\n * or it would stay counted and swallow Escape in the box clicked into.\n */\nlet openCount = 0\nlet lastClose = 0\n\n/**\n * Open, or closed less than 100ms ago \u2014 what an Enter handler asks. Choosing a\n * row with Enter closes the list, and that same Enter must not also send.\n */\nexport function isSuggestionActive(): boolean {\n return openCount > 0 || Date.now() - lastClose < 100\n}\n\n/**\n * Open *now*, with no grace period \u2014 what an Escape handler asks. The first\n * Escape closes the list, the second is somebody's deliberate press.\n */\nexport function isSuggestionOpen(): boolean {\n return openCount > 0\n}\n\n/** How a list looks and what fills it \u2014 everything but the editor's own wiring. */\nexport interface SuggestionPopupOptions<T> {\n /** Names the list \u2014 \"Commands\", \"People\". */\n ariaLabel: string\n /** The box's width, e.g. `w-[300px]`. */\n width: string\n /** The cap before the rows scroll, e.g. `max-h-[400px]`. */\n maxHeight: string\n /** The plugin's items, and the typed query, \u2192 the sections to draw. One unlabeled section by default. */\n sections?: (items: T[], query: string) => readonly SuggestionMenuSection<T>[]\n itemKey: (item: T) => string\n row: (item: T) => SuggestionMenuRow\n /**\n * With `refresh`: called with a listener while the list is open; the app\n * calls it when its data has changed (a search landing), and the open list is\n * drawn again for the same query. Returns the unsubscribe, run when the list\n * closes however it closes.\n */\n subscribe?: (listener: () => void) => () => void\n /** The items for a query, as the plugin's `items` answers \u2014 asked again when `subscribe` fires. */\n refresh?: (query: string) => T[]\n}\n\ntype Props<T> = SuggestionProps<T> & { options: SuggestionPopupOptions<T> }\n\n// `forwardRef`, so Tiptap's `ReactRenderer` hands its `ref` through whichever\n// way it detects a component that takes one.\nconst Popup = forwardRef<SuggestionMenuHandle, Props<unknown>>(function Popup({ options, ...props }, handle) {\n const menu = useRef<SuggestionMenuHandle>(null)\n useImperativeHandle(handle, () => ({ onKeyDown: (event) => menu.current?.onKeyDown(event) ?? false }))\n const sections = options.sections ? options.sections(props.items, props.query) : [{ items: props.items }]\n return (\n <SuggestionMenu\n handle={menu}\n rect={props.clientRect?.() ?? null}\n editorElement={props.editor.view.dom}\n ariaLabel={options.ariaLabel}\n width={options.width}\n maxHeight={options.maxHeight}\n sections={sections}\n itemKey={options.itemKey}\n row={options.row}\n onSelect={(item) => props.command(item)}\n />\n )\n})\n\n/**\n * The `render` of a Tiptap suggestion plugin, drawn as a `SuggestionMenu` \u2014\n * the popup controller Peek wrote four times (`mention.tsx`, `slashCommands.tsx`),\n * once.\n *\n * Suggestion({ editor, char: '/', items, command,\n * render: suggestionPopup({ ariaLabel: 'Commands', width: 'w-[300px]',\n * maxHeight: 'max-h-[400px]', itemKey, row, sections }) })\n *\n * It mounts the list when the query starts and removes it when it ends: the\n * plugin owns the list's life. Escape closes it and is used up; \u2191, \u2193 and Enter\n * go to the list; every other key stays the editor's. The list portals itself\n * (the package `Popover`), so the mount point is only a mount point.\n */\nexport function suggestionPopup<T>(options: SuggestionPopupOptions<T>): NonNullable<SuggestionOptions<T>['render']> {\n return () => {\n let component: ReactRenderer<SuggestionMenuHandle, Props<T>> | null = null\n let container: HTMLDivElement | null = null\n let last: SuggestionProps<T> | null = null\n let unsubscribe: (() => void) | undefined\n let counted = false\n let unlisten: (() => void) | undefined\n const count = (shown: boolean) => {\n if (shown === counted) return\n counted = shown\n openCount = shown ? openCount + 1 : Math.max(0, openCount - 1)\n }\n // The plugin's state outlives a blur \u2014 no transaction runs \u2014 so leaving the\n // box ends the query here, as Escape does: coming back finds no list, and\n // Enter sends (Miky, 2026-10-06). Leaving the window is not leaving the box,\n // and a press in the list's own panel never takes focus (SuggestionMenu).\n const listen = (props: SuggestionProps<T>) => {\n const { view } = props.editor\n const dom = view.dom\n const onBlur = () => {\n // A window that loses focus leaves its active element where it was.\n if (dom.contains(document.activeElement) || !last) return\n const from = last.range.from\n // Not a pick: no grace for the other box's Enter.\n count(false)\n for (const plugin of view.state.plugins) {\n const state = plugin.getState(view.state) as { active?: boolean; range?: { from: number } } | undefined\n if (state?.active && state.range?.from === from && plugin.spec.key) exitSuggestion(view, plugin.spec.key)\n }\n }\n dom.addEventListener('blur', onBlur)\n unlisten = () => dom.removeEventListener('blur', onBlur)\n }\n const exit = () => {\n unsubscribe?.()\n unsubscribe = undefined\n unlisten?.()\n unlisten = undefined\n last = null\n // The grace is for the Enter that picked a row and closed the list, not\n // for a keystroke that only left it with no rows.\n if (counted) lastClose = Date.now()\n count(false)\n if (!component) return\n component.destroy()\n container?.remove()\n component = null\n container = null\n }\n return {\n onStart: (props) => {\n count(props.items.length > 0)\n component = new ReactRenderer<SuggestionMenuHandle, Props<T>>(Popup as never, { props: { ...props, options }, editor: props.editor })\n container = document.createElement('div')\n document.body.appendChild(container)\n container.appendChild(component.element)\n last = props\n listen(props)\n const { subscribe, refresh } = options\n if (subscribe && refresh) {\n // The plugin asks for items only when the query changes; an answer\n // landing later draws the open list again with the same props.\n unsubscribe = subscribe(() => {\n if (!last || !component) return\n last = { ...last, items: refresh(last.query) }\n count(last.items.length > 0)\n component.updateProps({ ...last, options })\n })\n }\n },\n onUpdate: (props) => {\n last = props\n count(props.items.length > 0)\n component?.updateProps({ ...props, options })\n },\n onKeyDown: ({ event }: SuggestionKeyDownProps) => {\n if (event.key === 'Escape') {\n exit()\n return true\n }\n return component?.ref?.onKeyDown(event) ?? false\n },\n onExit: exit,\n }\n }\n}\n", "import { useMemo, type ReactNode } from 'react'\nimport type { Editor } from '@tiptap/core'\nimport type { Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport type { EditorView } from '@tiptap/pm/view'\nimport { IconCopy, IconTrash } from '@tabler/icons-react'\nimport { BlockHandle, blockAtY, type BlockHandleEditing, type HandleBlock } from './BlockHandle'\nimport { MenuItem, MenuSub } from './Menu'\n\n/** A row of the block menu's Turn into: what the block becomes. */\nexport interface BlockTurnInto {\n label: string\n /** Turns the block the caret is in. The handle puts the caret there first. */\n run: (editor: Editor) => void\n /** Whether the block already is this \u2014 drawn as the selected row. */\n active?: (node: ProseMirrorNode) => boolean\n}\n\nexport interface EditorBlockHandleProps {\n /** The editor. Not editable, or not there yet, and the handle reads: the caller's rows only. */\n editor: Editor | null\n /** Turn into's rows. Offered for a block of text \u2014 a paragraph, a heading, code. */\n turnInto?: readonly BlockTurnInto[]\n /** The caller's own rows, after the editing ones. */\n actions?: (block: HandleBlock) => ReactNode\n /** The `EditorContent`. */\n children: ReactNode\n className?: string\n}\n\n/** The editor's top-level blocks, where each starts and what it is. */\nfunction editorBlocks(view: EditorView): HandleBlock[] {\n const out: HandleBlock[] = []\n view.state.doc.forEach((node, pos) => {\n const element = view.nodeDOM(pos)\n if (element instanceof HTMLElement) out.push({ id: (node.attrs.blockId as string | null) || undefined, element, pos })\n })\n return out\n}\n\n/*\n Duplicate and Delete leave the editor focused, as Turn into and a drop do: the\n person is still in the field, so an editor that saves when they leave it saves\n these too \u2014 and one that loads someone else's edit while unfocused does not\n load it over them.\n*/\n\n/** A copy of the block straight after it, the caret in the copy. `BlockId` gives the copy a fresh id; the original keeps its own. */\nexport function duplicateBlock(editor: Editor, pos: number): boolean {\n const node = editor.state.doc.nodeAt(pos)\n if (!node) return false\n editor.view.dispatch(editor.state.tr.insert(pos + node.nodeSize, node).scrollIntoView())\n editor.commands.focus(pos + node.nodeSize + 1)\n return true\n}\n\n/** Removes the block, the caret where it was. The last block of a document becomes an empty paragraph, since a document holds at least one. */\nexport function deleteBlock(editor: Editor, pos: number): boolean {\n const { state } = editor\n const node = state.doc.nodeAt(pos)\n if (!node) return false\n const tr = state.doc.childCount === 1 ? state.tr.replaceWith(pos, pos + node.nodeSize, state.schema.nodes.paragraph.create()) : state.tr.delete(pos, pos + node.nodeSize)\n editor.view.dispatch(tr)\n editor.commands.focus(Math.min(pos + 1, editor.state.doc.content.size))\n return true\n}\n\n/**\n * Moves the block at `from` to `to` (a position between top-level blocks), the\n * caret in it: what a drop in the gutter does, where the editor has no drop of\n * its own. The node moves whole, attributes and all, so it keeps its id, as\n * ProseMirror's drop keeps it.\n */\nexport function moveBlock(editor: Editor, from: number, to: number): boolean {\n const node = editor.state.doc.nodeAt(from)\n if (!node || (to >= from && to <= from + node.nodeSize)) return false\n const tr = editor.state.tr.delete(from, from + node.nodeSize)\n const at = tr.mapping.map(to)\n editor.view.dispatch(tr.insert(at, node).scrollIntoView())\n editor.commands.focus(at + 1)\n return true\n}\n\n/**\n * Starts the browser's own drag of the block, as ProseMirror starts one of a\n * selected node: the block selected, its slice on `view.dragging` with `move`,\n * and its HTML on the transfer. ProseMirror's drop then deletes the selection\n * and inserts the slice with its attributes \u2014 so the block arrives with the\n * id it left with, and every comment anchored to it still finds it.\n */\nexport function startBlockDrag(editor: Editor, pos: number, event: Pick<globalThis.DragEvent, 'dataTransfer'>, image?: Element) {\n editor.commands.setNodeSelection(pos)\n const { view } = editor\n const slice = view.state.selection.content()\n const { dom, text } = view.serializeForClipboard(slice)\n const transfer = event.dataTransfer\n if (transfer) {\n transfer.clearData()\n transfer.setData('text/html', dom.innerHTML)\n transfer.setData('text/plain', text)\n transfer.effectAllowed = 'copyMove'\n if (image) transfer.setDragImage(image, 0, 0)\n }\n view.dragging = { slice, move: true }\n}\n\n/**\n * The drop line a dragged block shows, in the package's accent instead of the\n * editor's default (the text's colour). Give it to the editor's StarterKit:\n * `StarterKit.configure({ dropcursor: blockDropCursor })`.\n */\nexport const blockDropCursor = { color: false, class: 'bg-accent-primary' } as const\n\nconst NOTHING_YET: BlockHandleEditing = { find: () => null, rows: () => null, startDrag: () => {}, drop: () => {}, endDrag: () => {}, onChange: () => () => {} }\n\n/**\n * `BlockHandle` in an editor: drag the handle to move the block, and the menu\n * gains Turn into, Duplicate and Delete before the caller's rows.\n */\nexport function EditorBlockHandle({ editor, turnInto = [], actions, children, className }: EditorBlockHandleProps) {\n const editing = useMemo<BlockHandleEditing>(() => {\n // Before the editor exists there is no block to find \u2014 not the editor's whole element read as one.\n if (!editor) return NOTHING_YET\n // Where the block being dragged starts.\n let dragged: number | undefined\n return {\n find: (y) => blockAtY(editorBlocks(editor.view), y),\n rows: (block) => {\n const pos = block.pos\n // Not editable: the caller's rows only, and no drag.\n if (!editor.isEditable) return null\n const node = pos === undefined ? null : editor.state.doc.nodeAt(pos)\n if (pos === undefined || !node) return null\n return (\n <>\n {node.isTextblock && turnInto.length > 0 && (\n <MenuSub label=\"Turn into\">\n {turnInto.map((row) => (\n <MenuItem\n key={row.label}\n label={row.label}\n selected={row.active?.(node) ?? false}\n onClick={() => {\n // Inside the block's text, so the row's command turns this block and no other.\n editor.chain().focus().setTextSelection(pos + 1).run()\n row.run(editor)\n }}\n />\n ))}\n </MenuSub>\n )}\n <MenuItem label=\"Duplicate\" leading={<IconCopy size={16} stroke={1.5} className=\"text-text-secondary\" />} onClick={() => duplicateBlock(editor, pos)} />\n <MenuItem label=\"Delete\" destructive leading={<IconTrash size={16} stroke={1.5} className=\"text-error-default\" />} onClick={() => deleteBlock(editor, pos)} />\n </>\n )\n },\n startDrag: (block, event) => {\n dragged = block.pos\n if (block.pos !== undefined) startBlockDrag(editor, block.pos, event, block.element)\n },\n drop: (target, after) => {\n const node = target.pos === undefined ? null : editor.state.doc.nodeAt(target.pos)\n if (dragged === undefined || target.pos === undefined || !node) return\n moveBlock(editor, dragged, after ? target.pos + node.nodeSize : target.pos)\n },\n // ProseMirror clears `dragging` on its own dragend, which a drag started outside its element never reaches.\n endDrag: () => setTimeout(() => (editor.view.dragging = null), 50),\n onChange: (changed) => {\n editor.on('update', changed)\n return () => {\n editor.off('update', changed)\n }\n },\n }\n }, [editor, turnInto])\n\n return (\n <BlockHandle editing={editing} actions={actions} className={className}>\n {children}\n </BlockHandle>\n )\n}\n", "import type { ReactNode } from 'react'\nimport { Extension, type Editor } from '@tiptap/core'\nimport { PluginKey } from '@tiptap/pm/state'\nimport Mention, { type MentionOptions } from '@tiptap/extension-mention'\nimport Suggestion from '@tiptap/suggestion'\nimport { NodeViewWrapper, ReactNodeViewRenderer, type ReactNodeViewProps } from '@tiptap/react'\nimport { Avatar } from './Avatar'\nimport { EnterHint } from './Menu'\nimport { inlineChipClassName } from './InlineChip'\nimport type { SuggestionMenuRow } from './SuggestionMenu'\nimport { suggestionPopup, type SuggestionPopupOptions } from './suggestionPopup'\n\n/*\n * The four composer triggers every Estiva app shares \u2014 `@`, `!@`, `[` and `/`\n * (CON-26, Miky 2026-10-02). Peek built them first and they move here unchanged\n * (CON-27); an app passes in only its own data: its people, the things `[` can\n * reference, and the `/` rows it can perform beside the shared Format section.\n *\n * **What a pick writes is not here.** The text a chip becomes in the body and\n * the tags it earns are `@estiva-app/conversation`'s (`mentionText`,\n * `messageReference`, `urgentTagsFor`), so a client without React writes the\n * same bytes. A chip here carries what that needs: a person's `pubkey`, a\n * reference's `uri`.\n */\n\n// \u2500\u2500\u2500 @ and !@ \u2500\u2500\u2500\n\n/** A person `@` and `!@` offer. */\nexport interface MentionPerson {\n /** The app's own key for the person \u2014 the row's key and the chip's `id`. */\n id: string\n name: string\n /** The second line of the row: a role, a team. */\n description?: string\n /** Their Nostr key, when they have one \u2014 what the body is written with (SPEC \u00A713.1). */\n pubkey?: string | null\n /** The face at the row's start. Default: the package `Avatar` for the name. */\n avatar?: ReactNode\n}\n\n/** How many people the list shows. */\nexport const PEOPLE_LIMIT = 6\n\n/** The people whose name holds the query, the first {@link PEOPLE_LIMIT} of them. */\nexport function filterPeople(people: readonly MentionPerson[], query: string): MentionPerson[] {\n const q = query.toLowerCase()\n return people.filter((person) => q === '' || person.name.toLowerCase().includes(q)).slice(0, PEOPLE_LIMIT)\n}\n\n/**\n * The people list `@` and `!@` open: the face, the name, the second line, and\n * the Enter hint while highlighted \u2014 `MenuItem` at its tall size.\n */\nexport function peopleMenu(urgent: boolean): SuggestionPopupOptions<MentionPerson> {\n const section = urgent ? 'Urgent mention' : 'People'\n return {\n ariaLabel: section,\n // The people and the reference lists are the same box: 658px, capped at 360.\n width: 'w-[658px]',\n maxHeight: 'max-h-[360px]',\n sections: (people) => [{ label: section, items: people, className: 'px-3 py-1' }],\n itemKey: (person) => person.id,\n row: (person) => ({\n label: person.name,\n description: person.description,\n leading: person.avatar ?? <Avatar size={32} alt={person.name} />,\n hint: <EnterHint />,\n size: 'tall',\n }),\n }\n}\n\nexport interface PersonMentionOptions {\n /** Everyone the list can offer, asked each time the query changes. */\n people: () => readonly MentionPerson[]\n}\n\ntype Doc = { descendants: (cb: (node: { type: { name: string }; attrs: Record<string, unknown> }) => boolean | void) => void }\n\nfunction optionsOf<T>(editor: Editor, name: string): T | undefined {\n return editor.extensionManager.extensions.find((one) => one.name === name)?.options as T | undefined\n}\n\n/**\n * A list keeps listening across spaces, so a name or a title can be more than\n * one word (f586437a, Miky 2026-10-06). It stops at a new line, Escape, a pick\n * or the cursor leaving \u2014 Suggestion's own \u2014 and once the query holds `stop`:\n * `]` for `[`, so \"see [the notes] above\" ends as text. While nothing matches,\n * the list is hidden rather than closed, and comes back if the words match again.\n * A space straight after the key is prose (\"meet @ 5pm\", \"- [ ] task\"), not a\n * query: every two-word name holds a space.\n */\nconst listening = (stop: string) => ({\n allowSpaces: true,\n shouldShow: ({ query }: { query: string }) => !/^\\s/.test(query) && !query.includes(stop),\n})\n\n/** `@`'s list and pick, or `!@`'s, for the node `name` \u2014 the extension's own, so a renamed one still finds its people. */\nfunction personSuggestion(urgent: boolean, name: string) {\n return {\n ...(urgent ? { char: '!@' } : {}),\n // A second `@` starts another mention; the first one has ended.\n ...listening('@'),\n items: ({ query, editor }: { query: string; editor: Editor }) => filterPeople(optionsOf<PersonMentionOptions>(editor, name)?.people() ?? [], query),\n render: suggestionPopup(peopleMenu(urgent)),\n command: ({ editor, range, props: person }: { editor: Editor; range: { from: number; to: number }; props: MentionPerson }) => {\n editor\n .chain()\n .focus()\n .insertContentAt(range, [\n { type: name, attrs: { id: person.id, label: person.name, pubkey: person.pubkey ?? null } },\n { type: 'text', text: ' ' },\n ])\n .run()\n },\n }\n}\n\n/*\n What a chip keeps through HTML \u2014 a copy and paste, inside an editor or\n between two. The chip's own `renderHTML` writes each as a `data-*` attribute\n and these read them back. Until CON-27 none was written, so a pasted chip\n came back with every value null and was sent as `@null`. What is read is\n checked: a crafted `data-pubkey` that is not a key, or a `data-uri` that is\n not a `nostr:` reference, is dropped rather than written into the body.\n*/\nconst HEX_KEY = /^[0-9a-f]{64}$/\nconst NOSTR_URI = /^nostr:[a-z0-9]+$/i\nconst fromData = (name: string, valid?: RegExp) => ({\n parseHTML: (element: HTMLElement) => {\n const value = element.getAttribute(`data-${name}`)\n return value !== null && (!valid || valid.test(value)) ? value : null\n },\n // The node's own `renderHTML` writes it.\n renderHTML: () => ({}),\n})\n\nconst personAttributes = () => ({\n id: { default: null, ...fromData('id') },\n label: { default: null, ...fromData('label') },\n /**\n * The person's Nostr key, when they have one \u2014 SPEC \u00A713.1. `id` is the app's\n * own and means nothing to another app; this is what the body is written\n * with, so a mention survives a rename.\n */\n pubkey: { default: null, ...fromData('pubkey', HEX_KEY) },\n})\n\n/** The `data-*` a person chip is written with, so a paste reads it back. */\nfunction personData(attrs: Record<string, unknown>): Record<string, string> {\n return {\n 'data-id': String(attrs.id ?? ''),\n 'data-label': String(attrs.label ?? ''),\n ...(typeof attrs.pubkey === 'string' && attrs.pubkey ? { 'data-pubkey': attrs.pubkey } : {}),\n }\n}\n\n/**\n * `@` \u2014 a person, as a chip that writes their key (SPEC \u00A713.1).\n *\n * PersonMention.configure({ people: () => directory })\n *\n * Its `pubkey` and `label` are what `mentionText` takes.\n */\nexport const PersonMention = Mention.extend<MentionOptions<MentionPerson, MentionPerson> & PersonMentionOptions>({\n name: 'mention',\n addOptions() {\n return { ...this.parent!(), HTMLAttributes: {}, people: () => [], suggestion: personSuggestion(false, this.name) }\n },\n addAttributes: personAttributes,\n renderHTML({ node }) {\n // No node view, so this spec is what the editor draws: the one chip.\n return ['span', { 'data-mention': 'true', ...personData(node.attrs), class: inlineChipClassName('person', 'cursor-default') }, `@${node.attrs.label}`]\n },\n parseHTML() {\n return [{ tag: 'span[data-mention]' }]\n },\n})\n\n/**\n * `!@` \u2014 a person, urgently: the same chip in the urgent tone. Its text is an\n * ordinary mention; the urgency travels as a tag (`urgentTagsFor`), so hand the\n * write {@link urgentPubkeys}.\n */\nexport const UrgentPersonMention = Mention.extend<MentionOptions<MentionPerson, MentionPerson> & PersonMentionOptions>({\n name: 'urgentMention',\n addOptions() {\n return { ...this.parent!(), HTMLAttributes: {}, people: () => [], suggestion: personSuggestion(true, this.name) }\n },\n addAttributes: personAttributes,\n renderHTML({ node }) {\n return [\n 'span',\n { 'data-urgent-mention': 'true', ...personData(node.attrs), class: inlineChipClassName('urgent', 'cursor-default') },\n `@${node.attrs.label}`,\n ]\n },\n parseHTML() {\n return [{ tag: 'span[data-urgent-mention]' }]\n },\n})\n\n/**\n * The keys the document's urgent mentions name \u2014 what the write turns into\n * `[\"urgent\", <pubkey>]` tags. A chip with no key has no tag to carry; its text\n * is the old `!@Name`.\n */\nexport function urgentPubkeys(editor: { state: { doc: Doc } }): string[] | undefined {\n const urgent: string[] = []\n editor.state.doc.descendants((node) => {\n if (node.type.name === 'urgentMention' && typeof node.attrs.pubkey === 'string' && node.attrs.pubkey) urgent.push(node.attrs.pubkey)\n })\n return urgent.length > 0 ? urgent : undefined\n}\n\n// \u2500\u2500\u2500 [ \u2500\u2500\u2500\n\n/** Something `[` offers: a reference drawn as who said it and how it opens. */\nexport interface CaptionedItem {\n /** The referenced thing's id \u2014 the row's key and the chip's `id`. */\n id: string\n /** Who, as the list shows them. */\n label: string\n /** The opening words, marks stripped: the caption the row and the chip wear. */\n snippet: string\n /** `nostr:\u2026`, exactly as the body will carry it (`messageReference`). */\n uri: string\n /** What the query is matched against beside `label`. Default: `snippet`. */\n search?: string\n /** The row's second line, e.g. where the thing sits. The chip does not wear it. */\n description?: string\n /**\n * This row's own 16px icon, in place of the list's `icon`: what the thing is,\n * when the list holds several kinds \u2014 a topic, a project, a message\n * (Katerina, 7 October). Absent, the list's icon.\n */\n icon?: ReactNode\n}\n\n/** One labelled group of `[`'s rows, in the order the list draws them. */\nexport interface ReferenceSection {\n label: string\n items: readonly CaptionedItem[]\n}\n\n/** How many references the list shows. */\nexport const REFERENCE_LIMIT = 6\n\n/**\n * The references whose label or text holds the query \u2014 the last\n * {@link REFERENCE_LIMIT}, in the order given: a thread is unbounded, and a\n * list that grew with it would be a hundred rows of prose.\n */\nexport function filterReferences(items: readonly CaptionedItem[], query: string): CaptionedItem[] {\n const q = query.toLowerCase()\n const shown = q ? items.filter((item) => (item.search ?? item.snippet).toLowerCase().includes(q) || item.label.toLowerCase().includes(q)) : [...items]\n return shown.slice(-REFERENCE_LIMIT)\n}\n\nconst captionOf = (label: string, snippet: string) => (snippet ? `${label}: ${snippet}` : label)\n\nexport interface CaptionedReferenceOptions {\n /** Drawn before the caption: a 14px icon. */\n icon: ReactNode\n /**\n * The chip's 14px icon from what it points at \u2014 its `uri` \u2014 when chips name\n * several kinds of thing; `undefined` from it, or no `iconFor`, draws `icon`.\n * The same answer the list's row gave (Katerina, 7 October).\n */\n iconFor?: (uri: string | null) => ReactNode | undefined\n}\n\n/**\n * A reference mid-sentence, drawn as `label: snippet` and written as its `uri`\n * verbatim (SPEC \u00A713.1). The caption is the snapshot it was picked with \u2014 a\n * caption, never parsed. Inserted by {@link ReferenceTrigger}, a paste or a\n * draft; it opens no list of its own.\n */\nexport const CaptionedReference = Mention.extend<MentionOptions & CaptionedReferenceOptions>({\n name: 'captionedReference',\n group: 'inline',\n inline: true,\n atom: true,\n addOptions() {\n return { ...this.parent!(), HTMLAttributes: {}, icon: null, iconFor: undefined, suggestion: { char: '\\0', items: () => [] } }\n },\n addAttributes() {\n return {\n id: { default: null, ...fromData('id') },\n label: { default: null, ...fromData('label') },\n snippet: { default: '', parseHTML: (element: HTMLElement) => element.getAttribute('data-snippet') ?? '', renderHTML: () => ({}) },\n uri: { default: null, ...fromData('uri', NOSTR_URI) },\n }\n },\n renderHTML({ node }) {\n return [\n 'span',\n { [`data-${this.name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)}`]: 'true', 'data-id': String(node.attrs.id ?? ''), 'data-label': String(node.attrs.label ?? ''), 'data-snippet': String(node.attrs.snippet ?? ''), ...(node.attrs.uri ? { 'data-uri': String(node.attrs.uri) } : {}), class: inlineChipClassName('neutral', 'cursor-default') },\n captionOf(node.attrs.label, node.attrs.snippet),\n ]\n },\n parseHTML() {\n return [{ tag: `span[data-${this.name.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`)}]` }]\n },\n addNodeView() {\n const { icon, iconFor } = this.options\n return ReactNodeViewRenderer(\n ({ node }: ReactNodeViewProps) => (\n <NodeViewWrapper as=\"span\" className={inlineChipClassName('neutral', 'max-w-[24ch] cursor-default')}>\n <span className=\"flex items-center justify-center w-4 h-4 shrink-0 text-text-secondary\">{iconFor?.(node.attrs.uri ?? null) ?? icon}</span>\n <span className=\"truncate\">{captionOf(node.attrs.label, node.attrs.snippet)}</span>\n </NodeViewWrapper>\n ),\n { as: 'span' },\n )\n },\n})\n\nexport interface ReferenceMenuOptions {\n /** Names the list, e.g. what can be referenced. */\n ariaLabel: string\n /** The section's heading. */\n sectionLabel: string\n /** At each row's start: a 16px icon \u2014 unless the row brings its own (`CaptionedItem.icon`), or `iconFor` answers. */\n icon: ReactNode\n /**\n * A row's 16px icon from what it points at \u2014 its `uri` \u2014 when the list holds\n * several kinds of thing; `undefined` from it draws `icon`. Give the chip the\n * same answer at 14px (`CaptionedReference`'s `iconFor`), so a pick keeps it.\n */\n iconFor?: (uri: string) => ReactNode | undefined\n}\n\n/** A row as the list holds it: which section it is drawn under, when the list has several. */\ntype ListedItem = CaptionedItem & { section?: string }\n\n/**\n * The list `[` opens: `label: snippet` rows, the same box as the people list.\n * One section headed `sectionLabel`, or \u2014 when the rows say which section they\n * are in \u2014 a heading for each, in the order the rows arrive.\n */\nexport function referenceMenu({ ariaLabel, sectionLabel, icon, iconFor }: ReferenceMenuOptions): SuggestionPopupOptions<CaptionedItem> {\n return {\n ariaLabel,\n width: 'w-[658px]',\n maxHeight: 'max-h-[360px]',\n sections: (items: ListedItem[]) => {\n const groups: { label: string; items: CaptionedItem[]; className: string }[] = []\n for (const item of items) {\n const label = item.section ?? sectionLabel\n const last = groups[groups.length - 1]\n if (last?.label === label) last.items.push(item)\n else groups.push({ label, items: [item], className: 'px-2' })\n }\n return groups\n },\n itemKey: (item) => `reference-${item.id}`,\n row: (item) => ({ leading: item.icon ?? iconFor?.(item.uri) ?? icon, label: captionOf(item.label, item.snippet), description: item.description, hint: <EnterHint /> }),\n }\n}\n\nexport interface ReferenceTriggerOptions extends ReferenceMenuOptions {\n /** Everything `[` can offer, asked each time the query changes. Narrowed by {@link filterReferences}. */\n items: () => readonly CaptionedItem[]\n /**\n * In place of `items`: the sections to draw for what was typed, already\n * narrowed and ordered by the app. Empty sections are not drawn.\n */\n sections?: (query: string) => readonly ReferenceSection[]\n /**\n * Called with a listener while the list is open; the app calls it when what\n * `sections` would answer has changed \u2014 a search landing \u2014 and the open list\n * is drawn again for the same query. Returns the unsubscribe.\n */\n subscribe?: (listener: () => void) => () => void\n /** The node a pick inserts. Default `captionedReference`. */\n nodeName: string\n}\n\nconst listed = (options: ReferenceTriggerOptions, query: string): ListedItem[] =>\n options.sections\n ? options.sections(query).flatMap((section) => section.items.map((item) => ({ ...item, section: section.label })))\n : filterReferences(options.items(), query)\n\n/**\n * `[` \u2014 reference something, inserted as a {@link CaptionedReference} chip.\n *\n * Its own extension rather than the chip's suggestion, so the chip's text (its\n * `renderText`) does not change with the key that summons the list.\n */\nexport const ReferenceTrigger = Extension.create<ReferenceTriggerOptions>({\n name: 'referenceTrigger',\n addOptions() {\n return { items: () => [], nodeName: 'captionedReference', ariaLabel: 'References', sectionLabel: 'References', icon: null }\n },\n addProseMirrorPlugins() {\n const options = this.options\n return [\n Suggestion<CaptionedItem>({\n editor: this.editor,\n char: '[',\n pluginKey: new PluginKey('referenceTrigger'),\n ...listening(']'),\n // As a mention's: only where the chip may go.\n allow: ({ state, range }) => {\n const type = state.schema.nodes[options.nodeName]\n return !!type && !!state.doc.resolve(range.from).parent.type.contentMatch.matchType(type)\n },\n items: ({ query }) => listed(options, query),\n render: suggestionPopup({ ...referenceMenu(options), subscribe: options.subscribe, refresh: (query) => listed(options, query) }),\n command: ({ editor, range, props: item }) => {\n editor\n .chain()\n .focus()\n .insertContentAt(range, [\n { type: options.nodeName, attrs: { id: item.id, label: item.label, snippet: item.snippet, uri: item.uri } },\n { type: 'text', text: ' ' },\n ])\n .run()\n },\n }),\n ]\n },\n})\n\n// \u2500\u2500\u2500 / \u2500\u2500\u2500\n\n/** A row of the `/` list, and what choosing it does. */\nexport interface SlashCommand {\n key: string\n row: SuggestionMenuRow\n /** Matched beside the row's label: an id, a trigger, a description. */\n keywords?: readonly string[]\n /** Runs once the `/query` that summoned the list has been removed. */\n run: (editor: Editor) => void\n}\n\nexport interface SlashSection {\n label: string\n commands: readonly SlashCommand[]\n}\n\nexport type FormatId = 'paragraph' | 'heading' | 'subheading' | 'quote' | 'bulletList' | 'orderedList' | 'code'\n\nexport interface FormatDef {\n id: FormatId\n label: string\n /** What you type to get it \u2014 the input rule the extension registers. Blank when there is none. */\n trigger?: string\n /** The trigger when the format makes a block instead \u2014 Code's fence. Blank when it is the same. */\n blockTrigger?: string\n}\n\n/**\n * The formats `/` offers, in order. The hint is what you would type, not a key\n * chord. Bold, italic and underline are absent: they act on text already\n * written, so they are the selection toolbar's.\n */\nexport const FORMATS: readonly FormatDef[] = [\n { id: 'paragraph', label: 'Text' },\n { id: 'heading', label: 'Heading', trigger: '#' },\n { id: 'subheading', label: 'Subheading', trigger: '##' },\n { id: 'quote', label: 'Quote', trigger: '>' },\n { id: 'code', label: 'Code', trigger: '`', blockTrigger: '```' },\n { id: 'bulletList', label: 'Bulleted list', trigger: '-' },\n { id: 'orderedList', label: 'Numbered list', trigger: '1.' },\n]\n\n/** Code as a mark inside the line, or as a block of its own. */\nexport type CodeFormat = 'inline' | 'block'\n\n/**\n * Apply one format to the current block. `set*` wherever Tiptap has one:\n * choosing Heading should make a heading, not turn one off. `false` means\n * nothing changed, not that anything failed.\n */\nexport function applyFormat(editor: Editor, id: FormatId, code: CodeFormat = 'inline'): boolean {\n const chain = editor.chain().focus()\n /*\n The node's own command, called by name: StarterKit's extensions declare\n them, and this package builds without StarterKit. Its own command, rather\n than the core one it wraps, because a list's runs with the app's options\n (`keepMarks`, `itemTypeName`). An editor without that node changes nothing.\n */\n const run = (command: string, ...args: unknown[]): boolean => {\n const named = (chain as unknown as Record<string, ((...a: unknown[]) => { run: () => boolean }) | undefined>)[command]\n return named ? named(...args).run() : false\n }\n switch (id) {\n case 'paragraph':\n return run('setParagraph')\n case 'heading':\n return run('setHeading', { level: 1 })\n case 'subheading':\n return run('setHeading', { level: 2 })\n case 'quote':\n return run('toggleBlockquote')\n case 'bulletList':\n return run('toggleBulletList')\n case 'orderedList':\n return run('toggleOrderedList')\n case 'code':\n return run(code === 'block' ? 'toggleCodeBlock' : 'toggleCode')\n default:\n return false\n }\n}\n\n/** The Format section every app's `/` opens with. */\nexport function formatSection(code: CodeFormat = 'inline'): SlashSection {\n return {\n label: 'Format',\n commands: FORMATS.map((format) => ({\n key: `format-${format.id}`,\n row: { label: format.label, shortcut: (code === 'block' && format.blockTrigger) || format.trigger },\n keywords: [format.id],\n run: (editor) => {\n applyFormat(editor, format.id, code)\n },\n })),\n }\n}\n\n/** A row that types another trigger, so its own list opens \u2014 `@` from `/`. */\nexport function typeTrigger(input: string): SlashCommand['run'] {\n // Deferred a frame: the delete of the `/query` has to land first, or the\n // trigger's plugin sees the character arrive inside a range still being removed.\n return (editor) => {\n requestAnimationFrame(() => editor.commands.insertContent(input))\n }\n}\n\nfunction matches(command: SlashCommand, q: string): boolean {\n return [command.row.label, ...(command.keywords ?? [])].some((text) => text.toLowerCase().includes(q))\n}\n\n/** The sections narrowed to a query \u2014 the text typed after the `/`. Empty sections stay. */\nexport function filterSlashSections(sections: readonly SlashSection[], query: string): SlashSection[] {\n const q = query.toLowerCase()\n return sections.map((section) => ({ ...section, commands: q ? section.commands.filter((command) => matches(command, q)) : section.commands }))\n}\n\nexport interface SlashCommandsOptions {\n /** The sections, in order: {@link formatSection} first, then the app's own. */\n sections: readonly SlashSection[]\n}\n\ntype SlashRow = SlashCommand & { section: number }\n\n/**\n * `/` \u2014 format the line or insert something, at the caret, mid-sentence too.\n * A `/` inside a word (`and/or`, a path) opens nothing: the plugin wants a\n * space or the line's start before it.\n */\nexport const SlashCommands = Extension.create<SlashCommandsOptions>({\n name: 'slashCommands',\n addOptions() {\n return { sections: [formatSection()] }\n },\n addProseMirrorPlugins() {\n const sections = this.options.sections\n return [\n Suggestion<SlashRow>({\n editor: this.editor,\n char: '/',\n startOfLine: false,\n pluginKey: new PluginKey('slashCommands'),\n items: ({ query }) => filterSlashSections(sections, query).flatMap((section, at) => section.commands.map((command) => ({ ...command, section: at }))),\n command: ({ editor, range, props }) => {\n editor.chain().focus().deleteRange(range).run()\n props.run(editor)\n },\n render: suggestionPopup<SlashRow>({\n ariaLabel: 'Commands',\n width: 'w-[300px]',\n maxHeight: 'max-h-[400px]',\n sections: (rows) => sections.map((section, at) => ({ label: section.label, items: rows.filter((row) => row.section === at) })),\n itemKey: (row) => row.key,\n row: (row) => row.row,\n }),\n }),\n ]\n },\n})\n", "import type { ComponentType } from 'react'\nimport { Extension, Node } from '@tiptap/core'\nimport type { Node as ProseMirrorNode, Slice } from '@tiptap/pm/model'\nimport { Plugin, PluginKey, type Transaction } from '@tiptap/pm/state'\nimport { Mapping, ReplaceAroundStep } from '@tiptap/pm/transform'\nimport { NodeViewWrapper, ReactNodeViewRenderer, type ReactNodeViewProps } from '@tiptap/react'\n\n/*\n * The four nodes an editor of a block document needs that a stock schema does\n * not have (SPEC \u00A713.3) \u2014 moved here from Ship's `editorSchema.tsx` (RIC-14,\n * SHI-2) when Peek became the second editor of the same documents (MAN-9).\n *\n * They are one half of a pair. The other half is `@estiva-app/protocol`'s\n * `toEditorDocument` / `fromEditorDocument`, which turn a stored document into\n * the JSON these nodes read and back: the node names (`unknownBlock`,\n * `reference`, `attachment`) and the `blockId` attribute are that translation's,\n * and must not drift from it. This package does not import protocol, as\n * `RichText` does not: the translation hands over everything a view draws.\n *\n * Everything else a document can contain is already a ProseMirror node of the\n * same name \u2014 StarterKit's and TableKit's \u2014 which is why this file is short.\n */\n\n/**\n * The block types \u00A713.3 puts an id on, as the editor's node names \u2014\n * protocol's `EDITOR_BLOCK_TYPES`, less `unknownBlock`, which declares its own.\n */\nconst BLOCK_TYPES = [\n 'paragraph',\n 'heading',\n 'bulletList',\n 'orderedList',\n 'listItem',\n 'blockquote',\n 'codeBlock',\n 'horizontalRule',\n // A table and everything inside it (UIG-18): a row or a cell whose id was\n // re-minted on each save would detach any comment anchored to it.\n 'table',\n 'tableRow',\n 'tableHeader',\n 'tableCell',\n // Without this an attachment's id is re-minted on every save, and every\n // comment anchored to it stops resolving.\n 'attachment',\n]\nconst BLOCK_TYPE_SET = new Set(BLOCK_TYPES)\n\n/** protocol's `newBlockId`: six random bytes as hex. */\nfunction newBlockId(): string {\n return Array.from(crypto.getRandomValues(new Uint8Array(6)), (b) => b.toString(16).padStart(2, '0')).join('')\n}\n\n/** Whether anything typed or inserted is inside \u2014 protocol's `holdsText`. An empty paragraph is not; a lone line break is. */\nfunction holdsText(node: ProseMirrorNode): boolean {\n let found = false\n node.descendants((child) => {\n if (found) return false\n if ((child.isText && child.text !== '') || child.type.name === 'hardBreak' || child.type.name === 'reference') found = true\n return !found\n })\n return found\n}\n\ninterface Claim {\n pos: number\n node: ProseMirrorNode\n /** An unknown block: the translation hands its source back untouched, so re-minting it here would be undone on save. */\n fixed: boolean\n}\n\n/** Every block that claims an id, by id, in document order. */\nfunction claimsIn(doc: ProseMirrorNode): Map<string, Claim[]> {\n const claims = new Map<string, Claim[]>()\n doc.descendants((node, pos) => {\n const fixed = node.type.name === 'unknownBlock'\n if (!fixed && !BLOCK_TYPE_SET.has(node.type.name)) return\n const id = node.attrs.blockId\n if (typeof id !== 'string' || id === '') return\n const copies = claims.get(id)\n if (copies) copies.push({ pos, node, fixed })\n else claims.set(id, [{ pos, node, fixed }])\n })\n return claims\n}\n\n/**\n * The copy the block that was there before carried on into: where the start\n * of its content landed. Enter at the very start pushes that content into the\n * lower half; a split anywhere else leaves it in the upper; a pasted copy,\n * above or below, never moves it out of the original.\n */\nfunction carriedOn(copies: Claim[], before: Claim, mapping: Mapping): Claim | undefined {\n if (before.node.isLeaf) {\n const at = mapping.map(before.pos, 1)\n return copies.find((c) => c.pos === at)\n }\n const at = mapping.map(textStart(before), 1)\n return copies.find((c) => c.pos < at && at < c.pos + c.node.nodeSize)\n}\n\n/** The start of a block's text, inside the paragraph a list item or quote wraps it in. */\nfunction textStart({ pos, node }: { pos: number; node: ProseMirrorNode }): number {\n let start = pos + 1\n if (!node.isTextblock) {\n let found = false\n node.descendants((child, at) => {\n if (found) return false\n if (child.isTextblock) {\n start = pos + 1 + at + 1\n found = true\n }\n return !found\n })\n }\n return start\n}\n\n/**\n * Where a block claims an id another block keeps \u2014 see {@link BlockId}. An\n * unknown block always keeps its id; otherwise the copy the original carried\n * on into, and failing that protocol's rule: the first that holds text, or\n * the first.\n */\nfunction repeatedBlockIds(doc: ProseMirrorNode, before: ProseMirrorNode, mapping: Mapping): number[] {\n const claims = claimsIn(doc)\n let previous: Map<string, Claim[]> | undefined\n const losers: number[] = []\n for (const [id, copies] of claims) {\n if (copies.length < 2) continue\n previous ??= claimsIn(before)\n const original = previous.get(id)?.[0]\n const owner =\n copies.find((c) => c.fixed) ??\n (original && carriedOn(copies, original, mapping)) ??\n copies.find((c) => holdsText(c.node)) ??\n copies[0]\n for (const copy of copies) if (copy !== owner && !copy.fixed) losers.push(copy.pos)\n }\n return losers\n}\n\n/**\n * The blocks a save turns into blocks \u2014 exactly what protocol's\n * `blockFromEditor` walks \u2014 so a list, a table and its rows and cells are\n * walked into, and a list item or a quote is not: the save flattens their\n * paragraph wrappers into inline runs, so an id there would be dropped.\n */\nconst BLOCK_CONTAINERS = new Set(['bulletList', 'orderedList', 'table', 'tableRow', 'tableHeader', 'tableCell'])\n\n/** The wrappers the save flattens: their paragraphs become inline runs of theirs. */\nconst FLATTENED = new Set(['listItem', 'blockquote'])\n\nconst idOf = (node: ProseMirrorNode): string | undefined => {\n const id = node.attrs.blockId\n return typeof id === 'string' && id !== '' ? id : undefined\n}\n\n/** Every block the save turns into a block, in document order. */\nfunction addressedBlocks(doc: ProseMirrorNode): { pos: number; node: ProseMirrorNode }[] {\n const out: { pos: number; node: ProseMirrorNode }[] = []\n const visit = (node: ProseMirrorNode, pos: number) => {\n if (!BLOCK_TYPE_SET.has(node.type.name)) return\n out.push({ pos, node })\n if (BLOCK_CONTAINERS.has(node.type.name)) node.forEach((child, offset) => visit(child, pos + 1 + offset))\n }\n doc.forEach((node, offset) => visit(node, offset))\n return out\n}\n\n/** Where a block the save would give an id has none, so it would get a new one on every save. */\nfunction unnamedBlocks(doc: ProseMirrorNode): number[] {\n return addressedBlocks(doc)\n .filter((b) => idOf(b.node) === undefined)\n .map((b) => b.pos)\n}\n\n/** Where a paragraph inside a list item or a quote claims an id \u2014 which the save drops. */\nfunction hiddenIds(doc: ProseMirrorNode): number[] {\n const out: number[] = []\n doc.descendants((node, pos) => {\n if (!FLATTENED.has(node.type.name)) return\n node.forEach((child, offset) => {\n if (child.isTextblock && idOf(child) !== undefined) out.push(pos + 1 + offset)\n })\n })\n return out\n}\n\n/**\n * The id each block a wrap or a lift brought in takes over \u2014 see\n * {@link BlockId}. An id the save addressed before the change and does not\n * now goes to the innermost new block its text was carried into: the quote or\n * the list item around a paragraph, or the paragraph lifted out of one.\n * A block the change deleted hands nothing on. What it asks is whether the\n * block's own opening survived, the token left of its text, not its first\n * character: the `/` menu and a typed `> ` or `- ` delete what was typed at\n * the very start of the text in the same change as the wrap.\n */\nfunction handedOver(doc: ProseMirrorNode, before: ProseMirrorNode, mapping: Mapping, unnamed: number[]): Map<number, string> {\n const out = new Map<number, string>()\n if (unnamed.length === 0) return out\n const now = new Set(addressedBlocks(doc).map((b) => idOf(b.node)))\n // By where their text starts, and of a list and its item around the same text, the item first.\n const gone = addressedBlocks(before)\n .filter((b) => !b.node.isLeaf && idOf(b.node) !== undefined && !now.has(idOf(b.node)))\n .map((b) => ({ ...b, start: textStart(b) }))\n .sort((a, b) => a.start - b.start || b.pos - a.pos)\n for (const old of gone) {\n const id = idOf(old.node)!\n const { pos: at, deleted } = mapping.mapResult(old.start, -1)\n if (deleted) continue\n let inner: number | undefined\n for (const pos of unnamed) {\n if (out.has(pos)) continue\n if (pos < at && at < pos + doc.nodeAt(pos)!.nodeSize && (inner === undefined || pos > inner)) inner = pos\n }\n if (inner !== undefined) {\n out.set(inner, id)\n now.add(id)\n }\n }\n return out\n}\n\n/**\n * Whether a change could have made a repeat or a block without an id: only a\n * step that brings in blocks can, or one that wraps or lifts them \u2014 lifting\n * the paragraph out of a quote or a one-item list brings in nothing, yet\n * leaves a block the save addresses with the wrapper's missing id. Typing,\n * deleting and marks do neither, so most keystrokes skip the walk.\n */\nfunction bringsInBlocks(transactions: readonly Transaction[]): boolean {\n return transactions.some((tr) =>\n tr.steps.some((step) => {\n if (step instanceof ReplaceAroundStep) return true\n const slice = (step as { slice?: Slice }).slice\n let blocks = false\n slice?.content.forEach((node) => {\n if (node.isBlock) blocks = true\n })\n return blocks\n }),\n )\n}\n\n/**\n * `id` on every block, carried as the `blockId` attribute.\n *\n * A global attribute rather than one per node type, because \u00A713.3 puts an id\n * on **every** block and a type that quietly lacked one would mint a fresh id\n * on every save \u2014 detaching each anchored comment on it (RFC 0.4 \u00A76) with\n * nothing on screen to say so.\n *\n * Rendered as `data-block-id`, which is what `RichText` already emits, so the\n * reading and the editing surface address a block the same way.\n *\n * **A split gives the new half its own id, the moment it happens** (MAN-10).\n * ProseMirror copies a split node's attrs to both halves, so Enter leaves two\n * blocks claiming one id. Enter at the very start of a paragraph puts the\n * copy *above* it \u2014 and once something is typed there, nothing at save time\n * can tell which half was the original, so protocol's `fromEditorDocument`\n * gave the id, and every comment anchored to it, to the new line. Settled\n * here instead, in the same transaction, where the change itself says which\n * copy the original carried on into \u2014 so a copy pasted above a block does\n * not take its id either. The others get fresh ids. `fromEditorDocument`\n * keeps its own rule (the copy that holds text) as the backstop for an\n * editor without this extension; where the change says nothing, this falls\n * back to that rule too.\n *\n * **A block that arrives without an id gets one, the moment it arrives**\n * (MAN-11): a paste, a `/` menu insert, the empty paragraph a new editor\n * starts with and the one StarterKit keeps at the end. `fromEditorDocument`\n * mints an id for such a block on every save and the editor never sees it, so\n * each save gave it a different one \u2014 a blur with no edit published again, and\n * a comment anchored to it in between was detached. The editor's first\n * document is filled in when it is created, outside the undo history and\n * without an update, so opening a description is not an edit.\n *\n * **A wrap or a lift hands the id on** (MAN-12). Turning a paragraph into a\n * quote or a list wraps it, and ProseMirror leaves its attrs on the paragraph\n * inside \u2014 where the save flattens it and drops the id, so the quote or list\n * item was published under a new one and every comment anchored to the\n * paragraph was detached. The quote or the list item takes the paragraph's id\n * instead, and the list around it a fresh one; lifting the text back out hands\n * the id to the paragraph again. The paragraph inside keeps no id, as one\n * loaded from a stored document has none.\n */\nexport const BlockId = Extension.create({\n name: 'blockId',\n onCreate() {\n const { state, view } = this.editor\n const unnamed = unnamedBlocks(state.doc)\n if (unnamed.length === 0) return\n const tr = state.tr\n for (const pos of unnamed) tr.setNodeAttribute(pos, 'blockId', newBlockId())\n view.dispatch(tr.setMeta('addToHistory', false).setMeta('preventUpdate', true))\n },\n addProseMirrorPlugins() {\n return [\n new Plugin({\n key: new PluginKey('blockIdSplit'),\n appendTransaction: (transactions, old, state) => {\n if (!bringsInBlocks(transactions)) return null\n const mapping = new Mapping()\n for (const tr of transactions) mapping.appendMapping(tr.mapping)\n const unnamed = unnamedBlocks(state.doc)\n const handed = handedOver(state.doc, old.doc, mapping, unnamed)\n const ids = new Map<number, string | null>()\n for (const pos of repeatedBlockIds(state.doc, old.doc, mapping)) ids.set(pos, newBlockId())\n for (const pos of unnamed) ids.set(pos, handed.get(pos) ?? newBlockId())\n for (const pos of hiddenIds(state.doc)) ids.set(pos, null)\n if (ids.size === 0) return null\n const tr = state.tr\n for (const [pos, id] of ids) tr.setNodeAttribute(pos, 'blockId', id)\n return tr\n },\n }),\n ]\n },\n addGlobalAttributes() {\n return [\n {\n types: BLOCK_TYPES,\n attributes: {\n blockId: {\n default: null,\n parseHTML: (element: HTMLElement) => element.getAttribute('data-block-id'),\n renderHTML: (attributes: Record<string, unknown>) =>\n attributes.blockId ? { 'data-block-id': String(attributes.blockId) } : {},\n },\n },\n },\n ]\n },\n})\n\n/** What a reference's view is handed: the `nostr:` URI it stands for. */\nexport interface ReferenceViewProps {\n uri: string\n}\n\nexport interface ReferenceNodeOptions {\n /**\n * Draws the reference as the thing it points at \u2014 the app's own chip, which\n * knows how to resolve it. Without one, the URI is drawn as text.\n */\n view: ComponentType<ReferenceViewProps> | null\n}\n\n/**\n * A `nostr:` reference, drawn as the thing it points at \u2014 SPEC \u00A713.1.\n *\n * An **atom**: it has no editable interior, because its text is the URI and\n * nobody edits half a `naddr`. Selecting it selects the whole reference, which\n * is also how deleting one works. `marks` carries the run's other marks, so a\n * bold reference comes back bold.\n */\nexport const ReferenceNode = Node.create<ReferenceNodeOptions>({\n name: 'reference',\n group: 'inline',\n inline: true,\n atom: true,\n selectable: true,\n draggable: false,\n addOptions() {\n return { view: null }\n },\n addAttributes() {\n return {\n uri: { default: '' },\n marks: { default: [] as string[] },\n }\n },\n parseHTML() {\n return [{ tag: 'span[data-reference]' }]\n },\n renderHTML({ node }) {\n // A copy to the clipboard as HTML, and the whole drawing when no view is given.\n return ['span', { 'data-reference': String(node.attrs.uri) }, String(node.attrs.uri)]\n },\n addNodeView() {\n const View = this.options.view\n if (!View) return null\n return ReactNodeViewRenderer(({ node }: ReactNodeViewProps) => (\n <NodeViewWrapper as=\"span\" className=\"inline\">\n <View uri={String(node.attrs.uri ?? '')} />\n </NodeViewWrapper>\n ))\n },\n})\n\n/**\n * A block this editor has no design for, kept whole.\n *\n * \u00A713.3: a reader MUST render an unknown block's inline text and MUST NOT drop\n * it silently. **An editor is the dangerous case** \u2014 ProseMirror discards a\n * node its schema does not know, and the save after that would delete somebody\n * else's block with no error anywhere on the way. So the block's own JSON\n * rides in `source`, and protocol's `fromEditorDocument` hands it back\n * untouched; `text` is its inline text, worked out by `toEditorDocument`.\n *\n * Not editable, deliberately: an affordance that lets a person change\n * something they cannot see is worse than one that says the content is there\n * and belongs to another surface.\n */\nexport const UnknownBlock = Node.create({\n name: 'unknownBlock',\n group: 'block',\n atom: true,\n selectable: true,\n addAttributes() {\n return {\n blockId: { default: null },\n source: { default: null },\n text: { default: '' },\n }\n },\n parseHTML() {\n return [{ tag: 'div[data-unknown-block]' }]\n },\n renderHTML({ node }) {\n return ['div', { 'data-unknown-block': String(node.attrs.blockId ?? '') }, String(node.attrs.text ?? '')]\n },\n addNodeView() {\n return ReactNodeViewRenderer(UnknownBlockView)\n },\n})\n\nfunction UnknownBlockView({ node }: ReactNodeViewProps) {\n const source = node.attrs.source as { id?: string; type?: string } | null\n const text = String(node.attrs.text ?? '')\n return (\n <NodeViewWrapper\n data-block-id={source?.id}\n data-block-type={source?.type}\n className=\"rounded-md border border-border-default bg-bg-inset px-2 py-1 text-text-secondary\"\n >\n {text || `A ${source?.type ?? 'block'} this app cannot edit yet.`}\n </NodeViewWrapper>\n )\n}\n\n/** What an attachment's view is handed: the block's `imeta` fields. */\nexport interface AttachmentViewProps {\n attrs: Record<string, unknown>\n}\n\nexport interface AttachmentNodeOptions {\n /** Draws the file \u2014 the app's own attachment card. Without one, its name is drawn as text. */\n view: ComponentType<AttachmentViewProps> | null\n}\n\n/**\n * A file placed in a document \u2014 SPEC \u00A713.3's `attachment` block (SHI-2).\n *\n * An atom: the file is the block, there is nothing inside it to edit, and a\n * caret that could sit \"inside\" an image is a way to produce documents no\n * reader has a rule for. Selectable and deletable, so removing one is Backspace\n * like anything else.\n *\n * Its attributes are the `imeta` fields exactly, because that is what \u00A713.3\n * specifies. Each is declared, and that is not boilerplate: ProseMirror **drops\n * an attribute its schema does not name**, so an undeclared `thumb` would\n * survive the editor and vanish on save \u2014 the silent deletion `UnknownBlock`\n * exists to prevent.\n */\nexport const AttachmentNode = Node.create<AttachmentNodeOptions>({\n name: 'attachment',\n group: 'block',\n atom: true,\n selectable: true,\n draggable: false,\n addOptions() {\n return { view: null }\n },\n addAttributes() {\n return {\n url: { default: '' },\n m: { default: '' },\n x: { default: '' },\n size: { default: 0 },\n dim: { default: null },\n thumb: { default: null },\n alt: { default: null },\n filename: { default: null },\n }\n },\n parseHTML() {\n return [{ tag: 'div[data-attachment-block]' }]\n },\n renderHTML({ node }) {\n // A copy to the clipboard, and the whole drawing when no view is given.\n return ['div', { 'data-attachment-block': String(node.attrs.x ?? '') }, String(node.attrs.filename ?? 'attachment')]\n },\n addNodeView() {\n const View = this.options.view\n if (!View) return null\n return ReactNodeViewRenderer(({ node }: ReactNodeViewProps) => (\n <NodeViewWrapper className=\"my-2\">\n <View attrs={node.attrs} />\n </NodeViewWrapper>\n ))\n },\n})\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,aAAa,WAAW,QAAQ,gBAAgB;AAEzD,SAAS,iBAAiB;AAC1B,SAAS,QAAQ,iBAAiB;AAClC,SAAS,YAAY,qBAAqB;AAC1C,SAAS,UAAU,UAAU,YAAY,UAAU,qBAAqB;AACxE,SAAS,YAAY;AACrB,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAS,SAAS,qBAAqB;AACvC,SAAS,qBAAqB;AAsatB,cAqBA,YArBA;AA5YD,IAAM,mBAAmB,IAAI,UAA4B,eAAe;AAGxE,IAAM,gBAAgB,UAAU,OAAO;AAAA,EAC5C,MAAM;AAAA,EAEN,wBAAwB;AACtB,WAAO;AAAA,MACL,IAAI,OAAyB;AAAA,QAC3B,KAAK;AAAA,QACL,OAAO;AAAA,UACL,MAAM,MAAM;AAAA,UACZ,MAAM,IAAI,UAAU;AAClB,kBAAM,OAAO,GAAG,QAAQ,gBAAgB;AACxC,gBAAI,SAAS,OAAW,QAAO;AAC/B,gBAAI,CAAC,SAAU,QAAO;AAGtB,mBAAO,EAAE,MAAM,GAAG,QAAQ,IAAI,SAAS,IAAI,GAAG,IAAI,GAAG,QAAQ,IAAI,SAAS,EAAE,EAAE;AAAA,UAChF;AAAA,QACF;AAAA,QACA,OAAO;AAAA,UACL,YAAY,OAAO;AACjB,kBAAM,QAAQ,iBAAiB,SAAS,KAAK;AAC7C,gBAAI,CAAC,SAAS,MAAM,SAAS,MAAM,GAAI,QAAO;AAC9C,mBAAO,cAAc,OAAO,MAAM,KAAK;AAAA,cACrC,WAAW,OAAO,MAAM,MAAM,MAAM,IAAI,EAA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AACX,WAAO,EAAE,MAAM,KAAK;AAAA,EACtB;AAAA,EACA,gBAAgB;AACd,WAAO;AAAA,MACL,KAAK,EAAE,SAAS,GAAG;AAAA,MACnB,GAAG,EAAE,SAAS,GAAG;AAAA,MACjB,GAAG,EAAE,SAAS,GAAG;AAAA,MACjB,MAAM,EAAE,SAAS,EAAE;AAAA,MACnB,KAAK,EAAE,SAAS,KAAK;AAAA,MACrB,OAAO,EAAE,SAAS,KAAK;AAAA,MACvB,KAAK,EAAE,SAAS,KAAK;AAAA,MACrB,UAAU,EAAE,SAAS,KAAK;AAAA,IAC5B;AAAA,EACF;AAAA,EACA,YAAY;AACV,WAAO,CAAC,EAAE,KAAK,6BAA6B,CAAC;AAAA,EAC/C;AAAA,EACA,WAAW,EAAE,KAAK,GAAG;AAEnB,WAAO,CAAC,OAAO,EAAE,yBAAyB,OAAO,KAAK,MAAM,KAAK,EAAE,EAAE,GAAG,OAAO,KAAK,MAAM,YAAY,YAAY,CAAC;AAAA,EACrH;AAAA,EACA,cAAc;AACZ,UAAM,OAAO,KAAK,QAAQ;AAC1B,QAAI,CAAC,KAAM,QAAO;AAClB,WAAOI,uBAAsB,CAAC,EAAE,KAAK,MACnC,gBAAAC,KAACF,kBAAA,EAAgB,WAAU,QACzB,0BAAAE,KAAC,QAAK,OAAO,KAAK,OAAO,GAC3B,CACD;AAAA,EACH;AACF,CAAC;",
|
|
6
6
|
"names": ["Extension", "Plugin", "PluginKey", "useRef", "jsx", "Popup", "jsx", "jsxs", "Extension", "PluginKey", "jsx", "jsxs", "Extension", "PluginKey", "Extension", "Node", "Plugin", "PluginKey", "NodeViewWrapper", "ReactNodeViewRenderer", "jsx", "at", "tr"]
|
|
7
7
|
}
|