@bettercms-ai/kit 4.0.0 → 4.1.1
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/adapters/lossy.d.ts +4 -0
- package/dist/adapters/lossy.js +4 -0
- package/dist/adapters/lossy.js.map +1 -1
- package/dist/adapters/prod-types.d.ts +4 -0
- package/dist/adapters/prod-types.js +4 -1
- package/dist/adapters/prod-types.js.map +1 -1
- package/dist/adapters/schema.js +7 -0
- package/dist/adapters/schema.js.map +1 -1
- package/dist/context.d.ts +83 -0
- package/dist/context.js +58 -1
- package/dist/context.js.map +1 -1
- package/dist/controls/choice.d.ts +1 -1
- package/dist/controls/choice.js +21 -2
- package/dist/controls/choice.js.map +1 -1
- package/dist/controls/index.d.ts +1 -0
- package/dist/controls/index.js +3 -2
- package/dist/controls/index.js.map +1 -1
- package/dist/controls/link.d.ts +23 -2
- package/dist/controls/link.js +456 -4
- package/dist/controls/link.js.map +1 -1
- package/dist/controls/media-v16.d.ts +27 -0
- package/dist/controls/media-v16.js +261 -0
- package/dist/controls/media-v16.js.map +1 -0
- package/dist/controls/media.js +63 -1
- package/dist/controls/media.js.map +1 -1
- package/dist/controls/reference-services.d.ts +8 -0
- package/dist/controls/reference.js +78 -2
- package/dist/controls/reference.js.map +1 -1
- package/dist/controls/rich-text/ai-runs.d.ts +13 -0
- package/dist/controls/rich-text/ai-runs.js +71 -0
- package/dist/controls/rich-text/ai-runs.js.map +1 -0
- package/dist/controls/rich-text/block-tool.d.ts +31 -0
- package/dist/controls/rich-text/block-tool.js +62 -0
- package/dist/controls/rich-text/block-tool.js.map +1 -0
- package/dist/controls/rich-text/blocks.d.ts +6 -1
- package/dist/controls/rich-text/blocks.js +404 -24
- package/dist/controls/rich-text/blocks.js.map +1 -1
- package/dist/controls/rich-text/catalog.d.ts +21 -6
- package/dist/controls/rich-text/catalog.js +312 -23
- package/dist/controls/rich-text/catalog.js.map +1 -1
- package/dist/controls/rich-text/code-head.d.ts +30 -0
- package/dist/controls/rich-text/code-head.js +230 -0
- package/dist/controls/rich-text/code-head.js.map +1 -0
- package/dist/controls/rich-text/codec.d.ts +1 -1
- package/dist/controls/rich-text/codec.js +3 -1
- package/dist/controls/rich-text/codec.js.map +1 -1
- package/dist/controls/rich-text/dom.d.ts +27 -0
- package/dist/controls/rich-text/dom.js +69 -4
- package/dist/controls/rich-text/dom.js.map +1 -1
- package/dist/controls/rich-text/editor.js +212 -50
- package/dist/controls/rich-text/editor.js.map +1 -1
- package/dist/controls/rich-text/ops.js +1 -0
- package/dist/controls/rich-text/ops.js.map +1 -1
- package/dist/controls/rich-text/slash-preview.d.ts +8 -0
- package/dist/controls/rich-text/slash-preview.js +287 -0
- package/dist/controls/rich-text/slash-preview.js.map +1 -0
- package/dist/controls/rich-text/table-grid.d.ts +22 -0
- package/dist/controls/rich-text/table-grid.js +1052 -0
- package/dist/controls/rich-text/table-grid.js.map +1 -0
- package/dist/controls/rich-text/toolbar.js +60 -18
- package/dist/controls/rich-text/toolbar.js.map +1 -1
- package/dist/controls/text.d.ts +6 -0
- package/dist/controls/text.js +95 -5
- package/dist/controls/text.js.map +1 -1
- package/dist/core/facets.d.ts +1 -0
- package/dist/core/facets.js +1 -0
- package/dist/core/facets.js.map +1 -1
- package/dist/engine/array.d.ts +7 -0
- package/dist/engine/array.js +164 -45
- package/dist/engine/array.js.map +1 -1
- package/dist/engine/field-shell.d.ts +12 -0
- package/dist/engine/field-shell.js +217 -63
- package/dist/engine/field-shell.js.map +1 -1
- package/dist/engine/frame.js +39 -2
- package/dist/engine/frame.js.map +1 -1
- package/dist/engine/grouping.d.ts +71 -10
- package/dist/engine/grouping.js +223 -26
- package/dist/engine/grouping.js.map +1 -1
- package/dist/engine/kit-field.js +38 -4
- package/dist/engine/kit-field.js.map +1 -1
- package/dist/engine/schema-form.js +7 -2
- package/dist/engine/schema-form.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +13 -6
- package/dist/index.js.map +1 -1
- package/dist/kit.css +85 -0
- package/dist/schema/table.d.ts +2 -1
- package/dist/schema/table.js +5 -0
- package/dist/schema/table.js.map +1 -1
- package/dist/schema/types.d.ts +6 -0
- package/dist/schema/types.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/theme.css +115 -0
- package/dist/tokens.css +268 -0
- package/dist/ui/block-icon-picker.d.ts +38 -0
- package/dist/ui/block-icon-picker.js +141 -0
- package/dist/ui/block-icon-picker.js.map +1 -0
- package/dist/ui/button.js +1 -0
- package/dist/ui/button.js.map +1 -1
- package/dist/ui/code-language-menu.d.ts +24 -0
- package/dist/ui/code-language-menu.js +123 -0
- package/dist/ui/code-language-menu.js.map +1 -0
- package/dist/ui/content-fields.d.ts +47 -0
- package/dist/ui/content-fields.js +278 -0
- package/dist/ui/content-fields.js.map +1 -0
- package/dist/ui/foundations.d.ts +118 -0
- package/dist/ui/foundations.js +564 -0
- package/dist/ui/foundations.js.map +1 -0
- package/dist/ui/index.d.ts +6 -0
- package/dist/ui/index.js +7 -1
- package/dist/ui/inspector.d.ts +394 -0
- package/dist/ui/inspector.js +1173 -0
- package/dist/ui/inspector.js.map +1 -0
- package/dist/ui/overlay.d.ts +7 -2
- package/dist/ui/overlay.js +55 -20
- package/dist/ui/overlay.js.map +1 -1
- package/dist/ui/shortcut-hint.js +1 -1
- package/dist/ui/shortcut-hint.js.map +1 -1
- package/dist/ui/toast.d.ts +5 -3
- package/dist/ui/toast.js +83 -11
- package/dist/ui/toast.js.map +1 -1
- package/dist/ui/tooltip-card.d.ts +45 -0
- package/dist/ui/tooltip-card.js +135 -0
- package/dist/ui/tooltip-card.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ops.js","names":[],"sources":["../../../src/controls/rich-text/ops.ts"],"sourcesContent":["/**\n * RICH TEXT · pure DOM block operations on the editor surface (V2 HEAD controls/rich-text/ops.ts; no React, no\n * emitting). The editor wraps each one, then serializes and emits the new value.\n */\nimport { closestBlock, cloneModel, createIsland, defaultModel, esc, placeCaret, textBeforeCaret, topBlock, type IslandEl, type IslandKind, type IslandModels } from \"./dom\";\nimport type { RichTextFeature } from \"./codec\";\nimport type { BasicId } from \"./catalog\";\n\nconst emptyP = () => {\n const p = document.createElement(\"p\");\n p.innerHTML = \"<br>\";\n return p;\n};\nconst isWritable = (el: Element | null): el is HTMLElement => !!el && !el.hasAttribute(\"data-rt-island\") && el.tagName !== \"HR\";\n\n/** The writable line after a block, created when the block is last or followed by another rich block. */\nexport function ensureLineAfter(b: Element): HTMLElement {\n const next = b.nextElementSibling;\n if (isWritable(next)) return next;\n const p = emptyP();\n b.after(p);\n return p;\n}\n\nexport function duplicateBlock(b: HTMLElement): HTMLElement {\n let c: HTMLElement;\n if (b.hasAttribute(\"data-rt-island\")) {\n const k = b.getAttribute(\"data-rt-island\") as IslandKind;\n c = createIsland(k, cloneModel(k, (b as IslandEl).__rt as never));\n } else {\n c = b.cloneNode(true) as HTMLElement;\n c.removeAttribute(\"data-hint\");\n }\n b.after(c);\n return c;\n}\n\n/** Moves a block one step, keeping the caret where it was. Returns false at the edge. */\nexport function moveBlock(b: HTMLElement, dir: -1 | 1): boolean {\n const sib = dir < 0 ? b.previousElementSibling : b.nextElementSibling;\n if (!sib) return false;\n const s = window.getSelection();\n // ranges are live (a move collapses them), so keep the raw caret position\n const at = s && s.rangeCount ? { n: s.getRangeAt(0).startContainer, o: s.getRangeAt(0).startOffset } : null;\n const host = document.activeElement as HTMLElement | null;\n if (dir < 0) sib.before(b);\n else sib.after(b);\n if (at && s && b.contains(at.n)) {\n host?.focus({ preventScroll: true });\n const r = document.createRange();\n r.setStart(at.n, Math.min(at.o, at.n.nodeType === 3 ? (at.n as Text).length : at.n.childNodes.length));\n r.collapse(true);\n s.removeAllRanges();\n s.addRange(r);\n }\n return true;\n}\n\n/** Text / Heading / Quote / Code. Returns the new element, or null when nothing changed. */\nexport function turnInto(root: HTMLElement, b: HTMLElement | null, tag: string): HTMLElement | null {\n if (!b || b.parentNode !== root || b.hasAttribute(\"data-rt-island\") || b.tagName === \"HR\") return null;\n if (b.tagName.toLowerCase() === tag) return null;\n const inner =\n b.tagName === \"UL\" || b.tagName === \"OL\"\n ? Array.from(b.children).map((c) => c.innerHTML).join(\"<br>\")\n : b.tagName === \"PRE\"\n ? esc(b.textContent ?? \"\").replace(/\\n/g, \"<br>\")\n : b.innerHTML;\n const n = document.createElement(tag);\n n.innerHTML = tag === \"pre\" ? esc((b.textContent ?? \"\").replace(//g, \"\")) || \"<br>\" : inner || \"<br>\";\n b.replaceWith(n);\n root.focus({ preventScroll: true });\n placeCaret(n);\n return n;\n}\n\n/** An empty paragraph at the caret to build a block from (reuses the current one when it is empty). */\nexport function takeEmptyBlock(root: HTMLElement): HTMLElement {\n const s = window.getSelection();\n const anchor = s && s.rangeCount && root.contains(s.anchorNode) ? s.anchorNode : null;\n const li = anchor ? closestBlock(root, anchor) : null;\n let b = topBlock(root, anchor);\n if (li && li.tagName === \"LI\" && !li.textContent?.trim()) {\n const list = li.parentElement!;\n li.remove();\n if (!list.children.length) {\n const p = emptyP();\n list.replaceWith(p);\n b = p;\n } else b = list;\n }\n root.focus({ preventScroll: true });\n if (b && b.tagName === \"P\" && !b.textContent?.replace(//g, \"\").trim() && !b.querySelector(\"img\")) {\n b.innerHTML = \"<br>\";\n placeCaret(b);\n return b;\n }\n // an empty heading, quote or code line (e.g. \"/\" typed on one) is reused too, so no empty block is left behind\n if (b && /^(H[1-6]|BLOCKQUOTE|PRE)$/.test(b.tagName) && !b.textContent?.replace(//g, \"\").trim()) {\n const p = emptyP();\n b.replaceWith(p);\n placeCaret(p);\n return p;\n }\n const p = emptyP();\n if (b) b.after(p);\n else root.append(p);\n placeCaret(p);\n return p;\n}\n\nexport function insertIsland<K extends IslandKind>(root: HTMLElement, kind: K, model: IslandModels[K] = defaultModel(kind)): IslandEl {\n const target = takeEmptyBlock(root);\n const isl = createIsland(kind, model);\n // A table of contents is built from the headings: nothing in it is typed first, so the caret goes on in the\n // paragraph after it (RP-054: it sat in the title, and the next \"/pull\" was typed into \"In this article\").\n isl.__rtFocus = kind !== \"toc\";\n target.before(isl);\n // keep the document tidy: reuse the line that already follows instead of leaving an empty one\n const next = target.nextElementSibling;\n if (isWritable(next)) {\n target.remove();\n placeCaret(next, false);\n } else placeCaret(target);\n return isl;\n}\n\n/** Inserts a basic block at the caret. */\nexport function insertBasic(root: HTMLElement, id: BasicId) {\n switch (id) {\n case \"p\":\n takeEmptyBlock(root);\n return;\n case \"h1\": case \"h2\": case \"h3\": case \"h4\": case \"h5\": case \"h6\":\n turnInto(root, takeEmptyBlock(root), id);\n return;\n case \"quote\":\n turnInto(root, takeEmptyBlock(root), \"blockquote\");\n return;\n case \"code\":\n turnInto(root, takeEmptyBlock(root), \"pre\");\n return;\n case \"ul\": case \"ol\": {\n const t = takeEmptyBlock(root);\n const l = document.createElement(id);\n l.innerHTML = \"<li><br></li>\";\n t.replaceWith(l);\n placeCaret(l.firstElementChild!);\n return;\n }\n case \"hr\": {\n const t = takeEmptyBlock(root);\n t.before(document.createElement(\"hr\"));\n placeCaret(t);\n return;\n }\n case \"image\": case \"table\": case \"pullquote\": case \"takeaways\": case \"callout\": case \"toggle\": case \"video\": case \"file\":\n case \"gallery\": case \"embed\": case \"toc\": case \"columns\": case \"related\": case \"author\":\n insertIsland(root, id);\n return;\n }\n}\n\n/**\n * RT-030: the last live conversion in an editor. The conversion is a DOM swap the browser's undo knows nothing of, so\n * ⌘Z right after it kept the heading (or list, or quote). While the converted block is as the conversion left it, ⌘Z\n * puts the typed text back; the next input forgets it (`forgetLiveMarkdown`).\n */\nconst LIVE = new WeakMap<HTMLElement, { at: HTMLElement; html: string; back: () => void }>();\nexport const forgetLiveMarkdown = (root: HTMLElement) => void LIVE.delete(root);\n/** Take the last live conversion back to the text that was typed. True when it did. */\nexport function undoLiveMarkdown(root: HTMLElement): boolean {\n const live = LIVE.get(root);\n LIVE.delete(root);\n if (!live || !root.contains(live.at) || live.at.innerHTML !== live.html) return false;\n live.back();\n return true;\n}\n/** The typed marker back in a paragraph (`swap` puts it in place), before what followed it, the caret after the marker. */\nfunction typedBack(typed: string, from: HTMLElement, swap: (p: HTMLElement) => void) {\n const p = document.createElement(\"p\");\n const rest = from.textContent || from.querySelector(\"img\") ? [...from.childNodes] : [];\n // alone on its line, the marker's last space is the non-breaking one the browser types at the end of a block\n const text = document.createTextNode(rest.length ? typed : typed.replace(/ $/, \"\\u00a0\"));\n p.append(text, ...rest);\n swap(p);\n const s = window.getSelection();\n if (!s) return;\n const r = document.createRange();\n r.setStart(text, text.data.length);\n r.collapse(true);\n s.removeAllRanges();\n s.addRange(r);\n}\n\n/* ── RP-043: a code block's language ──────────────────────────────────\n * Stored as production renders it: `<pre><code class=\"language-x\">`, the token lowercase [a-z0-9-]{1,32} (the strictest\n * of the renderer, the dashboard codec and render-page). No highlighter is shipped: the class is the whole feature. */\nexport const CODE_LANGUAGE = /^[a-z0-9-]{1,32}$/;\n/** The code block's language, or null when it has none. */\nexport function codeLanguage(pre: Element): string | null {\n const code = Array.from(pre.children).find((c) => c.tagName === \"CODE\");\n const m = code?.getAttribute(\"class\")?.match(/(?:^|\\s)language-([a-z0-9-]+)/i);\n return m ? m[1].toLowerCase() : null;\n}\n/** Sets (or, with null, removes) only the `language-*` token, on the one `<code>` made to wrap the block's text. */\nexport function setCodeLanguage(pre: HTMLElement, lang: string | null): void {\n let code = Array.from(pre.children).find((c) => c.tagName === \"CODE\") as HTMLElement | undefined;\n if (code) {\n // stray text or a trailing <br> beside the <code> goes into it, in order\n const nodes = Array.from(pre.childNodes);\n const at = nodes.indexOf(code);\n code.prepend(...nodes.slice(0, at));\n code.append(...nodes.slice(at + 1));\n } else {\n code = document.createElement(\"code\");\n code.append(...Array.from(pre.childNodes));\n pre.append(code);\n }\n for (const c of Array.from(code.classList)) if (/^language-/i.test(c)) code.classList.remove(c);\n if (lang) code.classList.add(`language-${lang}`);\n if (!code.classList.length) code.removeAttribute(\"class\");\n}\n/** A language change from the block menu; ⌘Z right after it puts the previous language back (as RT-030's swaps). */\nexport function changeCodeLanguage(root: HTMLElement, pre: HTMLElement, lang: string | null): void {\n const prev = codeLanguage(pre);\n setCodeLanguage(pre, lang);\n LIVE.set(root, { at: pre, html: pre.innerHTML, back: () => setCodeLanguage(pre, prev) });\n}\n/** The typed \"```\" fence (`typed`, with its language) as a code block holding `text`; ⌘Z right after it types it back. */\nfunction fenceToCode(root: HTMLElement, blk: HTMLElement, typed: string, lang: string, text: string): HTMLElement {\n const pre = document.createElement(\"pre\");\n pre.innerHTML = esc(text) || \"<br>\";\n if (lang) setCodeLanguage(pre, lang.toLowerCase());\n blk.replaceWith(pre);\n placeCaret(pre.firstElementChild?.tagName === \"CODE\" ? pre.firstElementChild : pre, false);\n LIVE.set(root, { at: pre, html: pre.innerHTML, back: () => typedBack(typed, (pre.firstElementChild as HTMLElement | null) ?? pre, (p) => pre.replaceWith(p)) });\n return pre;\n}\nconst FENCE = /^```([a-z0-9-]{0,32})$/i;\nconst inCode = (n: Node | null) => !!(n && (n.nodeType === 1 ? (n as Element) : n.parentElement)?.closest(\"code,pre\"));\n/** Enter on a paragraph that is only \"```\" or \"```lang\" makes it a code block (where the field takes one). */\nexport function enterCodeFence(root: HTMLElement, blk: HTMLElement, allows: (f: RichTextFeature) => boolean = () => true): boolean {\n if (blk.tagName !== \"P\" || blk.parentNode !== root || !allows(\"pre\") || blk.querySelector(\"code,img\")) return false;\n const typed = (blk.textContent ?? \"\").replace(//g, \"\").replace(/ /g, \" \").trim();\n const m = typed.match(FENCE);\n if (!m) return false;\n fenceToCode(root, blk, typed, m[1], \"\");\n return true;\n}\n\n/**\n * \"# \", \"> \", \"- \", \"1. \", \"---\" and \"``` \" (RP-043; \"```ts \" with a language) at the start of a paragraph, each only\n * when the field accepts what it makes. Returns true when it converted.\n */\nexport function liveMarkdown(root: HTMLElement, data: string | null, allows: (f: RichTextFeature) => boolean = () => true): boolean {\n const s = window.getSelection();\n if (!s || !s.rangeCount || !s.isCollapsed) return false;\n const blk = topBlock(root, s.anchorNode);\n if (!blk || blk.tagName !== \"P\") return false;\n const before = textBeforeCaret(blk)?.replace(/ /g, \" \");\n if (before == null) return false;\n const fence = data === \" \" && allows(\"pre\") && !inCode(s.anchorNode) ? before.match(/^```([a-z0-9-]{0,32}) $/i) : null;\n if (fence) {\n const r = document.createRange();\n r.selectNodeContents(blk);\n r.setEnd(s.anchorNode!, s.anchorOffset);\n r.deleteContents();\n fenceToCode(root, blk, before, fence[1], (blk.textContent ?? \"\").replace(//g, \"\"));\n return true;\n }\n if (data === \"-\" && before === \"---\" && (blk.textContent ?? \"\").replace(/ /g, \" \") === \"---\") {\n if (!allows(\"hr\")) return false;\n const p = emptyP();\n const hr = document.createElement(\"hr\");\n blk.replaceWith(hr, p);\n placeCaret(p);\n LIVE.set(root, {\n at: p,\n html: p.innerHTML,\n back: () => {\n hr.remove();\n typedBack(\"---\", p, (q) => p.replaceWith(q));\n },\n });\n return true;\n }\n if (data !== \" \") return false;\n const h = before.match(/^(#{1,6}) $/);\n let tag = h ? `h${h[1].length}` : before === \"> \" ? \"blockquote\" : null;\n let list = before === \"- \" || before === \"* \" ? \"ul\" : /^1[.)] $/.test(before) ? \"ol\" : null;\n if (tag && !allows(tag as RichTextFeature)) tag = null;\n if (list && !allows(list as RichTextFeature)) list = null;\n if (!tag && !list) return false;\n const r = document.createRange();\n r.selectNodeContents(blk);\n r.setEnd(s.anchorNode!, s.anchorOffset);\n r.deleteContents();\n const html = blk.textContent || blk.querySelector(\"img\") ? blk.innerHTML : \"<br>\";\n let target: HTMLElement;\n if (tag) {\n target = document.createElement(tag);\n target.innerHTML = html;\n blk.replaceWith(target);\n } else {\n const l = document.createElement(list!);\n target = document.createElement(\"li\");\n target.innerHTML = html;\n l.append(target);\n blk.replaceWith(l);\n }\n placeCaret(target, false);\n const made = target;\n LIVE.set(root, { at: made, html: made.innerHTML, back: () => typedBack(before, made, (p) => (tag ? made : made.parentElement!).replaceWith(p)) });\n return true;\n}\n\n/** `text` typed between backticks becomes inline code. */\nexport function liveInlineCode(root?: HTMLElement): boolean {\n const s = window.getSelection();\n if (!s || !s.rangeCount || !s.isCollapsed) return false;\n const r = s.getRangeAt(0);\n if (r.startContainer.nodeType !== 3 || r.startContainer.parentElement?.closest(\"code,pre\")) return false;\n const node = r.startContainer as Text;\n const m = node.data.slice(0, r.startOffset).match(/`([^`\\n]+)`$/);\n if (!m) return false;\n wrapTypedRun(s, node, r.startOffset, m[0].length, \"code\", m[1], root);\n return true;\n}\n\n/**\n * RT-030: `**text**` becomes bold and `*text*` / `_text_` italic, run as the closing marker is typed (as\n * `liveInlineCode` is for the backtick), each only where the field accepts the mark. The first closing `*` of a\n * `**bold**` being typed is not an italic (its run starts with another `*`), and `_` inside a word (`snake_case_`)\n * stays as typed. Nothing inside code converts.\n */\nexport function liveInlineEmphasis(data: string | null, allows: (f: RichTextFeature) => boolean = () => true, root?: HTMLElement): boolean {\n if (data !== \"*\" && data !== \"_\") return false;\n const s = window.getSelection();\n if (!s || !s.rangeCount || !s.isCollapsed) return false;\n const r = s.getRangeAt(0);\n if (r.startContainer.nodeType !== 3 || r.startContainer.parentElement?.closest(\"code,pre\")) return false;\n const node = r.startContainer as Text;\n const before = node.data.slice(0, r.startOffset);\n const bold = data === \"*\" && allows(\"bold\") ? before.match(/\\*\\*([^*\\n]+)\\*\\*$/) : null;\n if (bold) {\n wrapTypedRun(s, node, r.startOffset, bold[0].length, \"strong\", bold[1], root);\n return true;\n }\n if (!allows(\"italic\")) return false;\n const italic = data === \"*\" ? before.match(/(?:^|[^*])\\*([^*\\n]+)\\*$/) : before.match(/(?:^|[^\\w_])_([^_\\n]+)_$/);\n if (!italic) return false;\n // the match may start with the character before the opening marker: only the marked run is replaced\n const run = italic[0].replace(/^[^*_]/, \"\");\n wrapTypedRun(s, node, r.startOffset, run.length, \"em\", italic[1], root);\n return true;\n}\n\n/* ── RT-028: list levels (Tab / Shift+Tab in a list item) ── */\n\n/**\n * Run `move` and put the caret back where it was. Moving a node takes the selection out of it, and a cloned Range is\n * live too (the DOM moves it to the old parent on removal), so the caret is kept as its plain node and offsets.\n */\nfunction keepingCaret(move: () => void): void {\n const s = window.getSelection();\n const at = s && s.rangeCount && s.anchorNode && s.focusNode ? [s.anchorNode, s.anchorOffset, s.focusNode, s.focusOffset] as const : null;\n move();\n if (s && at) s.setBaseAndExtent(at[0], at[1], at[2], at[3]);\n}\n\n/**\n * Tab: nest `li` one level deeper, under the item before it, in a list of the same kind (`ul` / `ol`). The\n * previous item's own nested list of that kind takes it when it has one. False (nothing moves) for the first item:\n * there is no item to nest under.\n */\nexport function indentListItem(li: HTMLElement): boolean {\n const list = li.parentElement;\n const prev = li.previousElementSibling as HTMLElement | null;\n if (!list || !/^(UL|OL)$/.test(list.tagName) || !prev || prev.tagName !== \"LI\") return false;\n keepingCaret(() => {\n const last = prev.lastElementChild;\n const nested = last && last.tagName === list.tagName ? last : prev.appendChild(document.createElement(list.tagName.toLowerCase()));\n nested.append(li);\n });\n return true;\n}\n\n/**\n * Shift+Tab: bring a nested `li` up one level, right after the item that held it. The items after it in its list stay\n * after it, nested under it, so the reading order never changes; an emptied nested list goes. False for an item\n * already at the top level.\n */\nexport function outdentListItem(li: HTMLElement): boolean {\n const list = li.parentElement;\n const parentLi = list?.parentElement;\n if (!list || !/^(UL|OL)$/.test(list.tagName) || !parentLi || parentLi.tagName !== \"LI\") return false;\n keepingCaret(() => {\n const after: Element[] = [];\n for (let n = li.nextElementSibling; n; n = n.nextElementSibling) after.push(n);\n if (after.length) {\n const own = li.lastElementChild && li.lastElementChild.tagName === list.tagName ? li.lastElementChild : li.appendChild(document.createElement(list.tagName.toLowerCase()));\n own.append(...after);\n }\n parentLi.after(li);\n if (!list.children.length) list.remove();\n });\n return true;\n}\n\n/**\n * Replace the `length` characters typed before `end` in `node` with `<tag>text</tag>`, the caret after it. With the\n * editor's `root`, the conversion is the one ⌘Z takes back first (RT-030): the typed run, markers and all, returns.\n */\nfunction wrapTypedRun(s: Selection, node: Text, end: number, length: number, tag: \"code\" | \"strong\" | \"em\", text: string, root?: HTMLElement): void {\n const typed = node.data.slice(end - length, end);\n const del = document.createRange();\n del.setStart(node, end - length);\n del.setEnd(node, end);\n del.deleteContents();\n const el = document.createElement(tag);\n el.textContent = text;\n del.insertNode(el);\n const next = el.nextSibling;\n if (next && next.nodeType === 3 && next.textContent) {\n const c = document.createRange();\n c.setStart(next, 0);\n c.collapse(true);\n s.removeAllRanges();\n s.addRange(c);\n } else {\n const after = document.createTextNode(\"\");\n el.after(after);\n placeCaret(after);\n }\n if (!root) return;\n LIVE.set(root, {\n at: el,\n html: el.innerHTML,\n back: () => {\n const back = document.createTextNode(typed);\n // the caret holder this conversion added after the mark goes with it\n const holder = el.nextSibling;\n if (holder && holder.nodeType === 3 && holder.textContent === \"\") holder.remove();\n el.replaceWith(back);\n const c = document.createRange();\n c.setStart(back, back.data.length);\n c.collapse(true);\n const sel = window.getSelection();\n sel?.removeAllRanges();\n sel?.addRange(c);\n },\n });\n}\n\n/* ── What a field accepts, applied to HTML that arrives from outside (paste, Markdown) ── */\nconst MARK_FEATURE: Record<string, RichTextFeature> = {\n STRONG: \"bold\", B: \"bold\", EM: \"italic\", I: \"italic\", U: \"underline\", S: \"strike\", STRIKE: \"strike\", DEL: \"strike\", CODE: \"code\", A: \"link\",\n};\nconst BLOCK_FEATURE: Record<string, RichTextFeature> = {\n H1: \"h1\", H2: \"h2\", H3: \"h3\", H4: \"h4\", H5: \"h5\", H6: \"h6\", BLOCKQUOTE: \"blockquote\", UL: \"ul\", OL: \"ol\", PRE: \"pre\", HR: \"hr\", FIGURE: \"image\", IMG: \"image\",\n};\nconst FEATURE_WORD: Partial<Record<RichTextFeature, string>> = {\n image: \"images\", hr: \"dividers\", pre: \"code blocks\", ul: \"bulleted lists\", ol: \"numbered lists\", blockquote: \"quotes\", link: \"links\",\n};\n\n/**\n * HTML with every element the field does not accept turned into what it does: a heading / quote / code block becomes a\n * paragraph, a list becomes one paragraph per item, a mark or link is unwrapped to its text, a divider or image is\n * removed. `dropped` names what was taken out entirely (said to the author, never silent).\n */\n/**\n * RT-016: HTML from another page as this editor takes it, before `restrictHtml` keeps it to the field. Classes, inline\n * styles and ids are the source page's look, not content: only a link's address is kept. A wrapper that is only styling\n * (a span, a font, Google Docs' `<b style=\"font-weight:normal\">` around a whole paste) is unwrapped to its contents. A\n * picture is taken out when `dropImages` (the field holds images, but a pasted address is not a media-library image);\n * otherwise it is left for `restrictHtml`, which removes it and says so. `images` counts what was taken out here.\n */\nexport function pastedHtml(html: string, dropImages: boolean): { html: string; images: number } {\n const doc = new DOMParser().parseFromString(`<body>${html}</body>`, \"text/html\");\n doc.body.querySelectorAll(\"script,style,meta,link,title,iframe,object,embed,form,input,button,textarea,select,noscript,template\").forEach((n) => n.remove());\n // the Windows clipboard wraps a paste in <!--StartFragment--> / <!--EndFragment--> comments: never content\n const walker = doc.createTreeWalker(doc.body, NodeFilter.SHOW_COMMENT);\n const comments: Node[] = [];\n while (walker.nextNode()) comments.push(walker.currentNode);\n comments.forEach((c) => c.parentNode?.removeChild(c));\n // A figure's words are content: its quote stays, its caption becomes a paragraph; only the picture can go (QA q18:\n // the quote and its caption went with the picture, unsaid).\n doc.body.querySelectorAll(\"figcaption\").forEach((c) => c.replaceWith(asParagraph(doc, c)));\n doc.body.querySelectorAll(\"figure\").forEach((f) => f.replaceWith(...Array.from(f.childNodes)));\n let images = 0;\n if (dropImages) {\n doc.body.querySelectorAll(\"picture,img\").forEach((n) => {\n if (!n.isConnected) return;\n if (n.tagName === \"IMG\" || n.querySelector(\"img\")) images++;\n n.remove();\n });\n }\n dropEmptyLinks(doc.body);\n for (const el of Array.from(doc.body.querySelectorAll(\"*\")).reverse()) {\n if (el.tagName === \"SPAN\" || el.tagName === \"FONT\" || el.tagName === \"CITE\" || ((el.tagName === \"B\" || el.tagName === \"STRONG\") && /font-weight\\s*:\\s*(normal|400)/i.test(el.getAttribute(\"style\") ?? \"\"))) {\n // RT-015: Google Docs writes bold / italic / underline / strike as a span's inline style, not a tag.\n const style = el.tagName === \"SPAN\" ? (el.getAttribute(\"style\") ?? \"\") : \"\";\n let inner: Node[] = Array.from(el.childNodes);\n const wrap = (tag: string) => {\n const w = doc.createElement(tag);\n w.append(...inner);\n inner = [w];\n };\n if (/font-weight\\s*:\\s*(bold|[6-9]00)/i.test(style)) wrap(\"strong\");\n if (/font-style\\s*:\\s*italic/i.test(style)) wrap(\"em\");\n if (/text-decoration[^;]*underline/i.test(style)) wrap(\"u\");\n if (/text-decoration[^;]*line-through/i.test(style)) wrap(\"s\");\n el.replaceWith(...inner);\n continue;\n }\n for (const a of Array.from(el.attributes)) {\n const keep = (el.tagName === \"A\" && a.name === \"href\") || (el.tagName === \"IMG\" && (a.name === \"src\" || a.name === \"alt\"));\n if (!keep) el.removeAttribute(a.name);\n }\n }\n // A page's layout boxes (a card, a grid cell, a term and its definition) have no block here: each becomes a paragraph,\n // or gives up the blocks it holds; the blocks a list item holds stay on their own lines (QA q18: a metric's three\n // lines were stored as \"3 daysMonth-end closedown from 11\").\n for (const box of Array.from(doc.body.querySelectorAll(PASTE_BOXES)).reverse()) {\n if (Array.from(box.children).some((c) => PASTE_BLOCK.test(c.tagName))) unwrapBox(doc, box);\n else if (box.textContent?.trim() || box.querySelector(\"img\")) box.replaceWith(asParagraph(doc, box));\n else box.remove();\n }\n doc.body.querySelectorAll(\"li,blockquote\").forEach((el) => joinLines(doc, el));\n return { html: doc.body.innerHTML.trim(), images };\n}\n\n/**\n * NEW-Q20-EMPTYLINK: a link with no words and no picture (it held only a picture that was left out, or the copy caught\n * the edge of one) draws nothing an author could find, and no field can store it, so it made the whole paste\n * unsaveable. It goes quietly; whatever it held stays.\n */\nfunction dropEmptyLinks(root: Element): void {\n root.querySelectorAll(\"a\").forEach((a) => {\n if (!a.textContent?.trim() && !a.querySelector(\"img\")) a.replaceWith(...Array.from(a.childNodes));\n });\n}\n\nconst PASTE_BOXES = \"div,section,article,header,footer,aside,main,nav,address,hgroup,details,summary,center,dl,dt,dd\";\nconst PASTE_BLOCK = /^(P|H[1-6]|UL|OL|BLOCKQUOTE|PRE|HR|TABLE)$/;\nconst asParagraph = (doc: Document, el: Element): HTMLParagraphElement => {\n const p = doc.createElement(\"p\");\n p.append(...Array.from(el.childNodes));\n return p;\n};\nconst blank = (n: Node | null): boolean => !!n && n.nodeType === 3 && !n.textContent?.trim();\n/** A box that holds blocks is replaced by them; the loose text and marks between them become paragraphs. */\nfunction unwrapBox(doc: Document, box: Element): void {\n const out: Node[] = [];\n let run: Node[] = [];\n const close = () => {\n if (run.some((n) => !blank(n))) {\n const p = doc.createElement(\"p\");\n p.append(...run);\n out.push(p);\n }\n run = [];\n };\n for (const n of Array.from(box.childNodes)) {\n if (n.nodeType === 1 && PASTE_BLOCK.test((n as Element).tagName)) {\n close();\n out.push(n);\n } else run.push(n);\n }\n close();\n box.replaceWith(...out);\n}\n/** A list item or quote holds one line of text per block it held, never their words run together. A nested list stays. */\nfunction joinLines(doc: Document, el: Element): void {\n const blocks = Array.from(el.children).filter((c) => /^(P|H[1-6]|BLOCKQUOTE|PRE)$/.test(c.tagName));\n if (!blocks.length) return;\n Array.from(el.childNodes).filter(blank).forEach((n) => n.remove());\n for (const b of blocks) {\n const parts: Node[] = Array.from(b.childNodes);\n if (b.previousSibling && b.previousSibling.nodeName !== \"BR\") parts.unshift(doc.createElement(\"br\"));\n if (b.nextSibling && !/^(UL|OL|BR)$/.test(b.nextSibling.nodeName)) parts.push(doc.createElement(\"br\"));\n b.replaceWith(...parts);\n }\n}\n\nexport function restrictHtml(html: string, allows: (f: RichTextFeature) => boolean): { html: string; dropped: string[] } {\n if (!html) return { html, dropped: [] };\n const doc = new DOMParser().parseFromString(`<body>${html}</body>`, \"text/html\");\n const dropped = new Set<string>();\n const walk = (el: Element) => {\n for (const ch of Array.from(el.children)) {\n walk(ch);\n const mark = MARK_FEATURE[ch.tagName];\n const block = BLOCK_FEATURE[ch.tagName];\n if (mark && !allows(mark)) ch.replaceWith(...Array.from(ch.childNodes));\n else if (block && !allows(block)) {\n if (block === \"hr\" || block === \"image\") {\n dropped.add(FEATURE_WORD[block]!);\n ch.remove();\n } else if (block === \"ul\" || block === \"ol\") {\n const ps = Array.from(ch.children).map((li) => {\n const p = doc.createElement(\"p\");\n p.innerHTML = li.innerHTML;\n return p;\n });\n ch.replaceWith(...ps);\n } else {\n const p = doc.createElement(\"p\");\n p.innerHTML = block === \"pre\" ? esc(ch.textContent ?? \"\").replace(/\\n/g, \"<br>\") : ch.innerHTML;\n ch.replaceWith(p);\n }\n }\n }\n };\n walk(doc.body);\n // a linked picture the field keeps no images for leaves its link with nothing in it\n if (dropped.has(FEATURE_WORD.image!)) dropEmptyLinks(doc.body);\n return { html: doc.body.innerHTML, dropped: [...dropped] };\n}\n"],"mappings":";;;;;;AAQA,IAAM,eAAe;CACnB,MAAM,IAAI,SAAS,cAAc,GAAG;CACpC,EAAE,YAAY;CACd,OAAO;AACT;AACA,IAAM,cAAc,OAA0C,CAAC,CAAC,MAAM,CAAC,GAAG,aAAa,gBAAgB,KAAK,GAAG,YAAY;;AAG3H,SAAgB,gBAAgB,GAAyB;CACvD,MAAM,OAAO,EAAE;CACf,IAAI,WAAW,IAAI,GAAG,OAAO;CAC7B,MAAM,IAAI,OAAO;CACjB,EAAE,MAAM,CAAC;CACT,OAAO;AACT;AAEA,SAAgB,eAAe,GAA6B;CAC1D,IAAI;CACJ,IAAI,EAAE,aAAa,gBAAgB,GAAG;EACpC,MAAM,IAAI,EAAE,aAAa,gBAAgB;EACzC,IAAI,aAAa,GAAG,WAAW,GAAI,EAAe,IAAa,CAAC;CAClE,OAAO;EACL,IAAI,EAAE,UAAU,IAAI;EACpB,EAAE,gBAAgB,WAAW;CAC/B;CACA,EAAE,MAAM,CAAC;CACT,OAAO;AACT;;AAGA,SAAgB,UAAU,GAAgB,KAAsB;CAC9D,MAAM,MAAM,MAAM,IAAI,EAAE,yBAAy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;IAClB;GACF;EACF;CACF;CACA,KAAK,IAAI,IAAI;CAEb,IAAI,QAAQ,IAAI,aAAa,KAAM,GAAG,eAAe,IAAI,IAAI;CAC7D,OAAO;EAAE,MAAM,IAAI,KAAK;EAAW,SAAS,CAAC,GAAG,OAAO;CAAE;AAC3D"}
|
|
1
|
+
{"version":3,"file":"ops.js","names":[],"sources":["../../../src/controls/rich-text/ops.ts"],"sourcesContent":["/**\n * RICH TEXT · pure DOM block operations on the editor surface (V2 HEAD controls/rich-text/ops.ts; no React, no\n * emitting). The editor wraps each one, then serializes and emits the new value.\n */\nimport { closestBlock, cloneModel, createIsland, defaultModel, esc, placeCaret, textBeforeCaret, topBlock, type IslandEl, type IslandKind, type IslandModels } from \"./dom\";\nimport type { RichTextFeature } from \"./codec\";\nimport type { BasicId } from \"./catalog\";\n\nconst emptyP = () => {\n const p = document.createElement(\"p\");\n p.innerHTML = \"<br>\";\n return p;\n};\nconst isWritable = (el: Element | null): el is HTMLElement => !!el && !el.hasAttribute(\"data-rt-island\") && el.tagName !== \"HR\";\n\n/** The writable line after a block, created when the block is last or followed by another rich block. */\nexport function ensureLineAfter(b: Element): HTMLElement {\n const next = b.nextElementSibling;\n if (isWritable(next)) return next;\n const p = emptyP();\n b.after(p);\n return p;\n}\n\nexport function duplicateBlock(b: HTMLElement): HTMLElement {\n let c: HTMLElement;\n if (b.hasAttribute(\"data-rt-island\")) {\n const k = b.getAttribute(\"data-rt-island\") as IslandKind;\n c = createIsland(k, cloneModel(k, (b as IslandEl).__rt as never));\n } else {\n c = b.cloneNode(true) as HTMLElement;\n c.removeAttribute(\"data-hint\");\n }\n b.after(c);\n return c;\n}\n\n/** Moves a block one step, keeping the caret where it was. Returns false at the edge. */\nexport function moveBlock(b: HTMLElement, dir: -1 | 1): boolean {\n const sib = dir < 0 ? b.previousElementSibling : b.nextElementSibling;\n if (!sib) return false;\n const s = window.getSelection();\n // ranges are live (a move collapses them), so keep the raw caret position\n const at = s && s.rangeCount ? { n: s.getRangeAt(0).startContainer, o: s.getRangeAt(0).startOffset } : null;\n const host = document.activeElement as HTMLElement | null;\n if (dir < 0) sib.before(b);\n else sib.after(b);\n if (at && s && b.contains(at.n)) {\n host?.focus({ preventScroll: true });\n const r = document.createRange();\n r.setStart(at.n, Math.min(at.o, at.n.nodeType === 3 ? (at.n as Text).length : at.n.childNodes.length));\n r.collapse(true);\n s.removeAllRanges();\n s.addRange(r);\n }\n return true;\n}\n\n/** Text / Heading / Quote / Code. Returns the new element, or null when nothing changed. */\nexport function turnInto(root: HTMLElement, b: HTMLElement | null, tag: string): HTMLElement | null {\n if (!b || b.parentNode !== root || b.hasAttribute(\"data-rt-island\") || b.tagName === \"HR\") return null;\n if (b.tagName.toLowerCase() === tag) return null;\n const inner =\n b.tagName === \"UL\" || b.tagName === \"OL\"\n ? Array.from(b.children).map((c) => c.innerHTML).join(\"<br>\")\n : b.tagName === \"PRE\"\n ? esc(b.textContent ?? \"\").replace(/\\n/g, \"<br>\")\n : b.innerHTML;\n const n = document.createElement(tag);\n n.innerHTML = tag === \"pre\" ? esc((b.textContent ?? \"\").replace(//g, \"\")) || \"<br>\" : inner || \"<br>\";\n b.replaceWith(n);\n root.focus({ preventScroll: true });\n placeCaret(n);\n return n;\n}\n\n/** An empty paragraph at the caret to build a block from (reuses the current one when it is empty). */\nexport function takeEmptyBlock(root: HTMLElement): HTMLElement {\n const s = window.getSelection();\n const anchor = s && s.rangeCount && root.contains(s.anchorNode) ? s.anchorNode : null;\n const li = anchor ? closestBlock(root, anchor) : null;\n let b = topBlock(root, anchor);\n if (li && li.tagName === \"LI\" && !li.textContent?.trim()) {\n const list = li.parentElement!;\n li.remove();\n if (!list.children.length) {\n const p = emptyP();\n list.replaceWith(p);\n b = p;\n } else b = list;\n }\n root.focus({ preventScroll: true });\n if (b && b.tagName === \"P\" && !b.textContent?.replace(//g, \"\").trim() && !b.querySelector(\"img\")) {\n b.innerHTML = \"<br>\";\n placeCaret(b);\n return b;\n }\n // an empty heading, quote or code line (e.g. \"/\" typed on one) is reused too, so no empty block is left behind\n if (b && /^(H[1-6]|BLOCKQUOTE|PRE)$/.test(b.tagName) && !b.textContent?.replace(//g, \"\").trim()) {\n const p = emptyP();\n b.replaceWith(p);\n placeCaret(p);\n return p;\n }\n const p = emptyP();\n if (b) b.after(p);\n else root.append(p);\n placeCaret(p);\n return p;\n}\n\nexport function insertIsland<K extends IslandKind>(root: HTMLElement, kind: K, model: IslandModels[K] = defaultModel(kind)): IslandEl {\n const target = takeEmptyBlock(root);\n const isl = createIsland(kind, model);\n // A table of contents is built from the headings: nothing in it is typed first, so the caret goes on in the\n // paragraph after it (RP-054: it sat in the title, and the next \"/pull\" was typed into \"In this article\").\n isl.__rtFocus = kind !== \"toc\";\n target.before(isl);\n // keep the document tidy: reuse the line that already follows instead of leaving an empty one\n const next = target.nextElementSibling;\n if (isWritable(next)) {\n target.remove();\n placeCaret(next, false);\n } else placeCaret(target);\n return isl;\n}\n\n/** Inserts a basic block at the caret. */\nexport function insertBasic(root: HTMLElement, id: BasicId) {\n switch (id) {\n case \"p\":\n takeEmptyBlock(root);\n return;\n case \"h1\": case \"h2\": case \"h3\": case \"h4\": case \"h5\": case \"h6\":\n turnInto(root, takeEmptyBlock(root), id);\n return;\n case \"quote\":\n turnInto(root, takeEmptyBlock(root), \"blockquote\");\n return;\n case \"code\":\n turnInto(root, takeEmptyBlock(root), \"pre\");\n return;\n case \"ul\": case \"ol\": {\n const t = takeEmptyBlock(root);\n const l = document.createElement(id);\n l.innerHTML = \"<li><br></li>\";\n t.replaceWith(l);\n placeCaret(l.firstElementChild!);\n return;\n }\n case \"hr\": {\n const t = takeEmptyBlock(root);\n t.before(document.createElement(\"hr\"));\n placeCaret(t);\n return;\n }\n case \"image\": case \"table\": case \"pullquote\": case \"takeaways\": case \"callout\": case \"toggle\": case \"video\": case \"file\":\n case \"gallery\": case \"embed\": case \"toc\": case \"columns\": case \"related\": case \"author\": case \"stats\":\n insertIsland(root, id);\n return;\n }\n}\n\n/**\n * RT-030: the last live conversion in an editor. The conversion is a DOM swap the browser's undo knows nothing of, so\n * ⌘Z right after it kept the heading (or list, or quote). While the converted block is as the conversion left it, ⌘Z\n * puts the typed text back; the next input forgets it (`forgetLiveMarkdown`).\n */\nconst LIVE = new WeakMap<HTMLElement, { at: HTMLElement; html: string; back: () => void }>();\nexport const forgetLiveMarkdown = (root: HTMLElement) => void LIVE.delete(root);\n/** Take the last live conversion back to the text that was typed. True when it did. */\nexport function undoLiveMarkdown(root: HTMLElement): boolean {\n const live = LIVE.get(root);\n LIVE.delete(root);\n if (!live || !root.contains(live.at) || live.at.innerHTML !== live.html) return false;\n live.back();\n return true;\n}\n/** The typed marker back in a paragraph (`swap` puts it in place), before what followed it, the caret after the marker. */\nfunction typedBack(typed: string, from: HTMLElement, swap: (p: HTMLElement) => void) {\n const p = document.createElement(\"p\");\n const rest = from.textContent || from.querySelector(\"img\") ? [...from.childNodes] : [];\n // alone on its line, the marker's last space is the non-breaking one the browser types at the end of a block\n const text = document.createTextNode(rest.length ? typed : typed.replace(/ $/, \"\\u00a0\"));\n p.append(text, ...rest);\n swap(p);\n const s = window.getSelection();\n if (!s) return;\n const r = document.createRange();\n r.setStart(text, text.data.length);\n r.collapse(true);\n s.removeAllRanges();\n s.addRange(r);\n}\n\n/* ── RP-043: a code block's language ──────────────────────────────────\n * Stored as production renders it: `<pre><code class=\"language-x\">`, the token lowercase [a-z0-9-]{1,32} (the strictest\n * of the renderer, the dashboard codec and render-page). No highlighter is shipped: the class is the whole feature. */\nexport const CODE_LANGUAGE = /^[a-z0-9-]{1,32}$/;\n/** The code block's language, or null when it has none. */\nexport function codeLanguage(pre: Element): string | null {\n const code = Array.from(pre.children).find((c) => c.tagName === \"CODE\");\n const m = code?.getAttribute(\"class\")?.match(/(?:^|\\s)language-([a-z0-9-]+)/i);\n return m ? m[1].toLowerCase() : null;\n}\n/** Sets (or, with null, removes) only the `language-*` token, on the one `<code>` made to wrap the block's text. */\nexport function setCodeLanguage(pre: HTMLElement, lang: string | null): void {\n let code = Array.from(pre.children).find((c) => c.tagName === \"CODE\") as HTMLElement | undefined;\n if (code) {\n // stray text or a trailing <br> beside the <code> goes into it, in order\n const nodes = Array.from(pre.childNodes);\n const at = nodes.indexOf(code);\n code.prepend(...nodes.slice(0, at));\n code.append(...nodes.slice(at + 1));\n } else {\n code = document.createElement(\"code\");\n code.append(...Array.from(pre.childNodes));\n pre.append(code);\n }\n for (const c of Array.from(code.classList)) if (/^language-/i.test(c)) code.classList.remove(c);\n if (lang) code.classList.add(`language-${lang}`);\n if (!code.classList.length) code.removeAttribute(\"class\");\n}\n/** A language change from the block menu; ⌘Z right after it puts the previous language back (as RT-030's swaps). */\nexport function changeCodeLanguage(root: HTMLElement, pre: HTMLElement, lang: string | null): void {\n const prev = codeLanguage(pre);\n setCodeLanguage(pre, lang);\n LIVE.set(root, { at: pre, html: pre.innerHTML, back: () => setCodeLanguage(pre, prev) });\n}\n/** The typed \"```\" fence (`typed`, with its language) as a code block holding `text`; ⌘Z right after it types it back. */\nfunction fenceToCode(root: HTMLElement, blk: HTMLElement, typed: string, lang: string, text: string): HTMLElement {\n const pre = document.createElement(\"pre\");\n pre.innerHTML = esc(text) || \"<br>\";\n if (lang) setCodeLanguage(pre, lang.toLowerCase());\n blk.replaceWith(pre);\n placeCaret(pre.firstElementChild?.tagName === \"CODE\" ? pre.firstElementChild : pre, false);\n LIVE.set(root, { at: pre, html: pre.innerHTML, back: () => typedBack(typed, (pre.firstElementChild as HTMLElement | null) ?? pre, (p) => pre.replaceWith(p)) });\n return pre;\n}\nconst FENCE = /^```([a-z0-9-]{0,32})$/i;\nconst inCode = (n: Node | null) => !!(n && (n.nodeType === 1 ? (n as Element) : n.parentElement)?.closest(\"code,pre\"));\n/** Enter on a paragraph that is only \"```\" or \"```lang\" makes it a code block (where the field takes one). */\nexport function enterCodeFence(root: HTMLElement, blk: HTMLElement, allows: (f: RichTextFeature) => boolean = () => true): boolean {\n if (blk.tagName !== \"P\" || blk.parentNode !== root || !allows(\"pre\") || blk.querySelector(\"code,img\")) return false;\n const typed = (blk.textContent ?? \"\").replace(//g, \"\").replace(/ /g, \" \").trim();\n const m = typed.match(FENCE);\n if (!m) return false;\n fenceToCode(root, blk, typed, m[1], \"\");\n return true;\n}\n\n/**\n * \"# \", \"> \", \"- \", \"1. \", \"---\" and \"``` \" (RP-043; \"```ts \" with a language) at the start of a paragraph, each only\n * when the field accepts what it makes. Returns true when it converted.\n */\nexport function liveMarkdown(root: HTMLElement, data: string | null, allows: (f: RichTextFeature) => boolean = () => true): boolean {\n const s = window.getSelection();\n if (!s || !s.rangeCount || !s.isCollapsed) return false;\n const blk = topBlock(root, s.anchorNode);\n if (!blk || blk.tagName !== \"P\") return false;\n const before = textBeforeCaret(blk)?.replace(/ /g, \" \");\n if (before == null) return false;\n const fence = data === \" \" && allows(\"pre\") && !inCode(s.anchorNode) ? before.match(/^```([a-z0-9-]{0,32}) $/i) : null;\n if (fence) {\n const r = document.createRange();\n r.selectNodeContents(blk);\n r.setEnd(s.anchorNode!, s.anchorOffset);\n r.deleteContents();\n fenceToCode(root, blk, before, fence[1], (blk.textContent ?? \"\").replace(//g, \"\"));\n return true;\n }\n if (data === \"-\" && before === \"---\" && (blk.textContent ?? \"\").replace(/ /g, \" \") === \"---\") {\n if (!allows(\"hr\")) return false;\n const p = emptyP();\n const hr = document.createElement(\"hr\");\n blk.replaceWith(hr, p);\n placeCaret(p);\n LIVE.set(root, {\n at: p,\n html: p.innerHTML,\n back: () => {\n hr.remove();\n typedBack(\"---\", p, (q) => p.replaceWith(q));\n },\n });\n return true;\n }\n if (data !== \" \") return false;\n const h = before.match(/^(#{1,6}) $/);\n let tag = h ? `h${h[1].length}` : before === \"> \" ? \"blockquote\" : null;\n let list = before === \"- \" || before === \"* \" ? \"ul\" : /^1[.)] $/.test(before) ? \"ol\" : null;\n if (tag && !allows(tag as RichTextFeature)) tag = null;\n if (list && !allows(list as RichTextFeature)) list = null;\n if (!tag && !list) return false;\n const r = document.createRange();\n r.selectNodeContents(blk);\n r.setEnd(s.anchorNode!, s.anchorOffset);\n r.deleteContents();\n const html = blk.textContent || blk.querySelector(\"img\") ? blk.innerHTML : \"<br>\";\n let target: HTMLElement;\n if (tag) {\n target = document.createElement(tag);\n target.innerHTML = html;\n blk.replaceWith(target);\n } else {\n const l = document.createElement(list!);\n target = document.createElement(\"li\");\n target.innerHTML = html;\n l.append(target);\n blk.replaceWith(l);\n }\n placeCaret(target, false);\n const made = target;\n LIVE.set(root, { at: made, html: made.innerHTML, back: () => typedBack(before, made, (p) => (tag ? made : made.parentElement!).replaceWith(p)) });\n return true;\n}\n\n/** `text` typed between backticks becomes inline code. */\nexport function liveInlineCode(root?: HTMLElement): boolean {\n const s = window.getSelection();\n if (!s || !s.rangeCount || !s.isCollapsed) return false;\n const r = s.getRangeAt(0);\n if (r.startContainer.nodeType !== 3 || r.startContainer.parentElement?.closest(\"code,pre\")) return false;\n const node = r.startContainer as Text;\n const m = node.data.slice(0, r.startOffset).match(/`([^`\\n]+)`$/);\n if (!m) return false;\n wrapTypedRun(s, node, r.startOffset, m[0].length, \"code\", m[1], root);\n return true;\n}\n\n/**\n * RT-030: `**text**` becomes bold and `*text*` / `_text_` italic, run as the closing marker is typed (as\n * `liveInlineCode` is for the backtick), each only where the field accepts the mark. The first closing `*` of a\n * `**bold**` being typed is not an italic (its run starts with another `*`), and `_` inside a word (`snake_case_`)\n * stays as typed. Nothing inside code converts.\n */\nexport function liveInlineEmphasis(data: string | null, allows: (f: RichTextFeature) => boolean = () => true, root?: HTMLElement): boolean {\n if (data !== \"*\" && data !== \"_\") return false;\n const s = window.getSelection();\n if (!s || !s.rangeCount || !s.isCollapsed) return false;\n const r = s.getRangeAt(0);\n if (r.startContainer.nodeType !== 3 || r.startContainer.parentElement?.closest(\"code,pre\")) return false;\n const node = r.startContainer as Text;\n const before = node.data.slice(0, r.startOffset);\n const bold = data === \"*\" && allows(\"bold\") ? before.match(/\\*\\*([^*\\n]+)\\*\\*$/) : null;\n if (bold) {\n wrapTypedRun(s, node, r.startOffset, bold[0].length, \"strong\", bold[1], root);\n return true;\n }\n if (!allows(\"italic\")) return false;\n const italic = data === \"*\" ? before.match(/(?:^|[^*])\\*([^*\\n]+)\\*$/) : before.match(/(?:^|[^\\w_])_([^_\\n]+)_$/);\n if (!italic) return false;\n // the match may start with the character before the opening marker: only the marked run is replaced\n const run = italic[0].replace(/^[^*_]/, \"\");\n wrapTypedRun(s, node, r.startOffset, run.length, \"em\", italic[1], root);\n return true;\n}\n\n/* ── RT-028: list levels (Tab / Shift+Tab in a list item) ── */\n\n/**\n * Run `move` and put the caret back where it was. Moving a node takes the selection out of it, and a cloned Range is\n * live too (the DOM moves it to the old parent on removal), so the caret is kept as its plain node and offsets.\n */\nfunction keepingCaret(move: () => void): void {\n const s = window.getSelection();\n const at = s && s.rangeCount && s.anchorNode && s.focusNode ? [s.anchorNode, s.anchorOffset, s.focusNode, s.focusOffset] as const : null;\n move();\n if (s && at) s.setBaseAndExtent(at[0], at[1], at[2], at[3]);\n}\n\n/**\n * Tab: nest `li` one level deeper, under the item before it, in a list of the same kind (`ul` / `ol`). The\n * previous item's own nested list of that kind takes it when it has one. False (nothing moves) for the first item:\n * there is no item to nest under.\n */\nexport function indentListItem(li: HTMLElement): boolean {\n const list = li.parentElement;\n const prev = li.previousElementSibling as HTMLElement | null;\n if (!list || !/^(UL|OL)$/.test(list.tagName) || !prev || prev.tagName !== \"LI\") return false;\n keepingCaret(() => {\n const last = prev.lastElementChild;\n const nested = last && last.tagName === list.tagName ? last : prev.appendChild(document.createElement(list.tagName.toLowerCase()));\n nested.append(li);\n });\n return true;\n}\n\n/**\n * Shift+Tab: bring a nested `li` up one level, right after the item that held it. The items after it in its list stay\n * after it, nested under it, so the reading order never changes; an emptied nested list goes. False for an item\n * already at the top level.\n */\nexport function outdentListItem(li: HTMLElement): boolean {\n const list = li.parentElement;\n const parentLi = list?.parentElement;\n if (!list || !/^(UL|OL)$/.test(list.tagName) || !parentLi || parentLi.tagName !== \"LI\") return false;\n keepingCaret(() => {\n const after: Element[] = [];\n for (let n = li.nextElementSibling; n; n = n.nextElementSibling) after.push(n);\n if (after.length) {\n const own = li.lastElementChild && li.lastElementChild.tagName === list.tagName ? li.lastElementChild : li.appendChild(document.createElement(list.tagName.toLowerCase()));\n own.append(...after);\n }\n parentLi.after(li);\n if (!list.children.length) list.remove();\n });\n return true;\n}\n\n/**\n * Replace the `length` characters typed before `end` in `node` with `<tag>text</tag>`, the caret after it. With the\n * editor's `root`, the conversion is the one ⌘Z takes back first (RT-030): the typed run, markers and all, returns.\n */\nfunction wrapTypedRun(s: Selection, node: Text, end: number, length: number, tag: \"code\" | \"strong\" | \"em\", text: string, root?: HTMLElement): void {\n const typed = node.data.slice(end - length, end);\n const del = document.createRange();\n del.setStart(node, end - length);\n del.setEnd(node, end);\n del.deleteContents();\n const el = document.createElement(tag);\n el.textContent = text;\n del.insertNode(el);\n const next = el.nextSibling;\n if (next && next.nodeType === 3 && next.textContent) {\n const c = document.createRange();\n c.setStart(next, 0);\n c.collapse(true);\n s.removeAllRanges();\n s.addRange(c);\n } else {\n const after = document.createTextNode(\"\");\n el.after(after);\n placeCaret(after);\n }\n if (!root) return;\n LIVE.set(root, {\n at: el,\n html: el.innerHTML,\n back: () => {\n const back = document.createTextNode(typed);\n // the caret holder this conversion added after the mark goes with it\n const holder = el.nextSibling;\n if (holder && holder.nodeType === 3 && holder.textContent === \"\") holder.remove();\n el.replaceWith(back);\n const c = document.createRange();\n c.setStart(back, back.data.length);\n c.collapse(true);\n const sel = window.getSelection();\n sel?.removeAllRanges();\n sel?.addRange(c);\n },\n });\n}\n\n/* ── What a field accepts, applied to HTML that arrives from outside (paste, Markdown) ── */\nconst MARK_FEATURE: Record<string, RichTextFeature> = {\n STRONG: \"bold\", B: \"bold\", EM: \"italic\", I: \"italic\", U: \"underline\", S: \"strike\", STRIKE: \"strike\", DEL: \"strike\", CODE: \"code\", A: \"link\",\n};\nconst BLOCK_FEATURE: Record<string, RichTextFeature> = {\n H1: \"h1\", H2: \"h2\", H3: \"h3\", H4: \"h4\", H5: \"h5\", H6: \"h6\", BLOCKQUOTE: \"blockquote\", UL: \"ul\", OL: \"ol\", PRE: \"pre\", HR: \"hr\", FIGURE: \"image\", IMG: \"image\",\n};\nconst FEATURE_WORD: Partial<Record<RichTextFeature, string>> = {\n image: \"images\", hr: \"dividers\", pre: \"code blocks\", ul: \"bulleted lists\", ol: \"numbered lists\", blockquote: \"quotes\", link: \"links\",\n};\n\n/**\n * HTML with every element the field does not accept turned into what it does: a heading / quote / code block becomes a\n * paragraph, a list becomes one paragraph per item, a mark or link is unwrapped to its text, a divider or image is\n * removed. `dropped` names what was taken out entirely (said to the author, never silent).\n */\n/**\n * RT-016: HTML from another page as this editor takes it, before `restrictHtml` keeps it to the field. Classes, inline\n * styles and ids are the source page's look, not content: only a link's address is kept. A wrapper that is only styling\n * (a span, a font, Google Docs' `<b style=\"font-weight:normal\">` around a whole paste) is unwrapped to its contents. A\n * picture is taken out when `dropImages` (the field holds images, but a pasted address is not a media-library image);\n * otherwise it is left for `restrictHtml`, which removes it and says so. `images` counts what was taken out here.\n */\nexport function pastedHtml(html: string, dropImages: boolean): { html: string; images: number } {\n const doc = new DOMParser().parseFromString(`<body>${html}</body>`, \"text/html\");\n doc.body.querySelectorAll(\"script,style,meta,link,title,iframe,object,embed,form,input,button,textarea,select,noscript,template\").forEach((n) => n.remove());\n // the Windows clipboard wraps a paste in <!--StartFragment--> / <!--EndFragment--> comments: never content\n const walker = doc.createTreeWalker(doc.body, NodeFilter.SHOW_COMMENT);\n const comments: Node[] = [];\n while (walker.nextNode()) comments.push(walker.currentNode);\n comments.forEach((c) => c.parentNode?.removeChild(c));\n // A figure's words are content: its quote stays, its caption becomes a paragraph; only the picture can go (QA q18:\n // the quote and its caption went with the picture, unsaid).\n doc.body.querySelectorAll(\"figcaption\").forEach((c) => c.replaceWith(asParagraph(doc, c)));\n doc.body.querySelectorAll(\"figure\").forEach((f) => f.replaceWith(...Array.from(f.childNodes)));\n let images = 0;\n if (dropImages) {\n doc.body.querySelectorAll(\"picture,img\").forEach((n) => {\n if (!n.isConnected) return;\n if (n.tagName === \"IMG\" || n.querySelector(\"img\")) images++;\n n.remove();\n });\n }\n dropEmptyLinks(doc.body);\n for (const el of Array.from(doc.body.querySelectorAll(\"*\")).reverse()) {\n if (el.tagName === \"SPAN\" || el.tagName === \"FONT\" || el.tagName === \"CITE\" || ((el.tagName === \"B\" || el.tagName === \"STRONG\") && /font-weight\\s*:\\s*(normal|400)/i.test(el.getAttribute(\"style\") ?? \"\"))) {\n // RT-015: Google Docs writes bold / italic / underline / strike as a span's inline style, not a tag.\n const style = el.tagName === \"SPAN\" ? (el.getAttribute(\"style\") ?? \"\") : \"\";\n let inner: Node[] = Array.from(el.childNodes);\n const wrap = (tag: string) => {\n const w = doc.createElement(tag);\n w.append(...inner);\n inner = [w];\n };\n if (/font-weight\\s*:\\s*(bold|[6-9]00)/i.test(style)) wrap(\"strong\");\n if (/font-style\\s*:\\s*italic/i.test(style)) wrap(\"em\");\n if (/text-decoration[^;]*underline/i.test(style)) wrap(\"u\");\n if (/text-decoration[^;]*line-through/i.test(style)) wrap(\"s\");\n el.replaceWith(...inner);\n continue;\n }\n for (const a of Array.from(el.attributes)) {\n const keep = (el.tagName === \"A\" && a.name === \"href\") || (el.tagName === \"IMG\" && (a.name === \"src\" || a.name === \"alt\"));\n if (!keep) el.removeAttribute(a.name);\n }\n }\n // A page's layout boxes (a card, a grid cell, a term and its definition) have no block here: each becomes a paragraph,\n // or gives up the blocks it holds; the blocks a list item holds stay on their own lines (QA q18: a metric's three\n // lines were stored as \"3 daysMonth-end closedown from 11\").\n for (const box of Array.from(doc.body.querySelectorAll(PASTE_BOXES)).reverse()) {\n if (Array.from(box.children).some((c) => PASTE_BLOCK.test(c.tagName))) unwrapBox(doc, box);\n else if (box.textContent?.trim() || box.querySelector(\"img\")) box.replaceWith(asParagraph(doc, box));\n else box.remove();\n }\n doc.body.querySelectorAll(\"li,blockquote\").forEach((el) => joinLines(doc, el));\n return { html: doc.body.innerHTML.trim(), images };\n}\n\n/**\n * NEW-Q20-EMPTYLINK: a link with no words and no picture (it held only a picture that was left out, or the copy caught\n * the edge of one) draws nothing an author could find, and no field can store it, so it made the whole paste\n * unsaveable. It goes quietly; whatever it held stays.\n */\nfunction dropEmptyLinks(root: Element): void {\n root.querySelectorAll(\"a\").forEach((a) => {\n if (!a.textContent?.trim() && !a.querySelector(\"img\")) a.replaceWith(...Array.from(a.childNodes));\n });\n}\n\nconst PASTE_BOXES = \"div,section,article,header,footer,aside,main,nav,address,hgroup,details,summary,center,dl,dt,dd\";\nconst PASTE_BLOCK = /^(P|H[1-6]|UL|OL|BLOCKQUOTE|PRE|HR|TABLE)$/;\nconst asParagraph = (doc: Document, el: Element): HTMLParagraphElement => {\n const p = doc.createElement(\"p\");\n p.append(...Array.from(el.childNodes));\n return p;\n};\nconst blank = (n: Node | null): boolean => !!n && n.nodeType === 3 && !n.textContent?.trim();\n/** A box that holds blocks is replaced by them; the loose text and marks between them become paragraphs. */\nfunction unwrapBox(doc: Document, box: Element): void {\n const out: Node[] = [];\n let run: Node[] = [];\n const close = () => {\n if (run.some((n) => !blank(n))) {\n const p = doc.createElement(\"p\");\n p.append(...run);\n out.push(p);\n }\n run = [];\n };\n for (const n of Array.from(box.childNodes)) {\n if (n.nodeType === 1 && PASTE_BLOCK.test((n as Element).tagName)) {\n close();\n out.push(n);\n } else run.push(n);\n }\n close();\n box.replaceWith(...out);\n}\n/** A list item or quote holds one line of text per block it held, never their words run together. A nested list stays. */\nfunction joinLines(doc: Document, el: Element): void {\n const blocks = Array.from(el.children).filter((c) => /^(P|H[1-6]|BLOCKQUOTE|PRE)$/.test(c.tagName));\n if (!blocks.length) return;\n Array.from(el.childNodes).filter(blank).forEach((n) => n.remove());\n for (const b of blocks) {\n const parts: Node[] = Array.from(b.childNodes);\n if (b.previousSibling && b.previousSibling.nodeName !== \"BR\") parts.unshift(doc.createElement(\"br\"));\n if (b.nextSibling && !/^(UL|OL|BR)$/.test(b.nextSibling.nodeName)) parts.push(doc.createElement(\"br\"));\n b.replaceWith(...parts);\n }\n}\n\nexport function restrictHtml(html: string, allows: (f: RichTextFeature) => boolean): { html: string; dropped: string[] } {\n if (!html) return { html, dropped: [] };\n const doc = new DOMParser().parseFromString(`<body>${html}</body>`, \"text/html\");\n const dropped = new Set<string>();\n const walk = (el: Element) => {\n for (const ch of Array.from(el.children)) {\n walk(ch);\n const mark = MARK_FEATURE[ch.tagName];\n const block = BLOCK_FEATURE[ch.tagName];\n if (mark && !allows(mark)) ch.replaceWith(...Array.from(ch.childNodes));\n else if (block && !allows(block)) {\n if (block === \"hr\" || block === \"image\") {\n dropped.add(FEATURE_WORD[block]!);\n ch.remove();\n } else if (block === \"ul\" || block === \"ol\") {\n const ps = Array.from(ch.children).map((li) => {\n const p = doc.createElement(\"p\");\n p.innerHTML = li.innerHTML;\n return p;\n });\n ch.replaceWith(...ps);\n } else {\n const p = doc.createElement(\"p\");\n p.innerHTML = block === \"pre\" ? esc(ch.textContent ?? \"\").replace(/\\n/g, \"<br>\") : ch.innerHTML;\n ch.replaceWith(p);\n }\n }\n }\n };\n walk(doc.body);\n // a linked picture the field keeps no images for leaves its link with nothing in it\n if (dropped.has(FEATURE_WORD.image!)) dropEmptyLinks(doc.body);\n return { html: doc.body.innerHTML, dropped: [...dropped] };\n}\n"],"mappings":";;;;;;AAQA,IAAM,eAAe;CACnB,MAAM,IAAI,SAAS,cAAc,GAAG;CACpC,EAAE,YAAY;CACd,OAAO;AACT;AACA,IAAM,cAAc,OAA0C,CAAC,CAAC,MAAM,CAAC,GAAG,aAAa,gBAAgB,KAAK,GAAG,YAAY;;AAG3H,SAAgB,gBAAgB,GAAyB;CACvD,MAAM,OAAO,EAAE;CACf,IAAI,WAAW,IAAI,GAAG,OAAO;CAC7B,MAAM,IAAI,OAAO;CACjB,EAAE,MAAM,CAAC;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OAAO,IAAI,UAAU,QAAQ,UAAU,MAAM;KAC3C,MAAM,KAAK,MAAM,KAAK,GAAG,QAAQ,CAAC,CAAC,KAAK,OAAO;MAC7C,MAAM,IAAI,IAAI,cAAc,GAAG;MAC/B,EAAE,YAAY,GAAG;MACjB,OAAO;KACT,CAAC;KACD,GAAG,YAAY,GAAG,EAAE;IACtB,OAAO;KACL,MAAM,IAAI,IAAI,cAAc,GAAG;KAC/B,EAAE,YAAY,UAAU,QAAQ,IAAI,GAAG,eAAe,EAAE,CAAC,CAAC,QAAQ,OAAO,MAAM,IAAI,GAAG;KACtF,GAAG,YAAY,CAAC;IAClB;GACF;EACF;CACF;CACA,KAAK,IAAI,IAAI;CAEb,IAAI,QAAQ,IAAI,aAAa,KAAM,GAAG,eAAe,IAAI,IAAI;CAC7D,OAAO;EAAE,MAAM,IAAI,KAAK;EAAW,SAAS,CAAC,GAAG,OAAO;CAAE;AAC3D"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { CatalogItem } from "./catalog";
|
|
2
|
+
/** The row a preview card is drawn for (null: none). Exported for tests. */
|
|
3
|
+
export declare function previewable(it: CatalogItem | undefined): it is CatalogItem;
|
|
4
|
+
/** The card, placed by the panel (absolute, right of the menu); `top` = the highlighted row's top - 6. */
|
|
5
|
+
export declare function SlashPreviewCard({ item, top }: {
|
|
6
|
+
item: CatalogItem | undefined;
|
|
7
|
+
top: number;
|
|
8
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { cn } from "../../lib/cn.js";
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
+
import { AnimatePresence, motion } from "framer-motion";
|
|
5
|
+
//#region src/controls/rich-text/slash-preview.tsx
|
|
6
|
+
/** The row a preview card is drawn for (null: none). Exported for tests. */
|
|
7
|
+
function previewable(it) {
|
|
8
|
+
return !!it && !it.kind?.match(/^(folder|back|ai)$/) && !it.ai && !it.disabled;
|
|
9
|
+
}
|
|
10
|
+
var BAR = "block h-1.5 rounded-[3px] bg-kit-insp-line";
|
|
11
|
+
var bar = (w, cls = "") => /* @__PURE__ */ jsx("i", {
|
|
12
|
+
className: cn(BAR, cls),
|
|
13
|
+
style: { width: w }
|
|
14
|
+
});
|
|
15
|
+
var HEAD = "h-2.5 bg-kit-insp-tip-title opacity-85";
|
|
16
|
+
var ART = {
|
|
17
|
+
p: "paragraph",
|
|
18
|
+
h1: "h1",
|
|
19
|
+
h2: "h2",
|
|
20
|
+
h3: "h3",
|
|
21
|
+
h4: "h3",
|
|
22
|
+
h5: "h3",
|
|
23
|
+
h6: "h3",
|
|
24
|
+
ul: "bullets",
|
|
25
|
+
ol: "numbers",
|
|
26
|
+
task: "checklist",
|
|
27
|
+
quote: "quote",
|
|
28
|
+
pullquote: "quote",
|
|
29
|
+
callout: "callout",
|
|
30
|
+
hr: "divider",
|
|
31
|
+
toggle: "toggle",
|
|
32
|
+
table: "table",
|
|
33
|
+
stats: "stats",
|
|
34
|
+
code: "code",
|
|
35
|
+
image: "image",
|
|
36
|
+
gallery: "image",
|
|
37
|
+
video: "video",
|
|
38
|
+
embed: "video",
|
|
39
|
+
file: "file"
|
|
40
|
+
};
|
|
41
|
+
function rows3(mark) {
|
|
42
|
+
return [
|
|
43
|
+
110,
|
|
44
|
+
130,
|
|
45
|
+
90
|
|
46
|
+
].map((w, i) => /* @__PURE__ */ jsxs("span", {
|
|
47
|
+
className: "flex items-center gap-2",
|
|
48
|
+
children: [mark(i), bar(w, "min-w-0 shrink")]
|
|
49
|
+
}, i));
|
|
50
|
+
}
|
|
51
|
+
function Wireframe({ art }) {
|
|
52
|
+
const flush = art === "table" || art === "code" || art === "image" || art === "video";
|
|
53
|
+
let body;
|
|
54
|
+
switch (art) {
|
|
55
|
+
case "paragraph":
|
|
56
|
+
body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
57
|
+
bar(150),
|
|
58
|
+
bar(140),
|
|
59
|
+
bar(96)
|
|
60
|
+
] });
|
|
61
|
+
break;
|
|
62
|
+
case "h1":
|
|
63
|
+
body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
64
|
+
bar(120, "h-3.5 bg-kit-insp-tip-title opacity-85"),
|
|
65
|
+
bar(150),
|
|
66
|
+
bar(110)
|
|
67
|
+
] });
|
|
68
|
+
break;
|
|
69
|
+
case "h2":
|
|
70
|
+
body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
71
|
+
bar(100, HEAD),
|
|
72
|
+
bar(150),
|
|
73
|
+
bar(118)
|
|
74
|
+
] });
|
|
75
|
+
break;
|
|
76
|
+
case "h3":
|
|
77
|
+
body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
78
|
+
bar(80, "h-2 bg-kit-insp-tip-title opacity-85"),
|
|
79
|
+
bar(150),
|
|
80
|
+
bar(126)
|
|
81
|
+
] });
|
|
82
|
+
break;
|
|
83
|
+
case "bullets":
|
|
84
|
+
body = rows3(() => /* @__PURE__ */ jsx("b", { className: "size-[5px] shrink-0 rounded-full bg-kit-insp-tip-title" }));
|
|
85
|
+
break;
|
|
86
|
+
case "numbers":
|
|
87
|
+
body = rows3((i) => /* @__PURE__ */ jsx("b", {
|
|
88
|
+
className: "shrink-0 text-[9px] font-normal leading-[10px] text-kit-group-sub",
|
|
89
|
+
children: i + 1
|
|
90
|
+
}));
|
|
91
|
+
break;
|
|
92
|
+
case "checklist":
|
|
93
|
+
body = rows3((i) => /* @__PURE__ */ jsx("b", { className: cn("size-[9px] shrink-0 rounded-[3px]", i ? "shadow-[inset_0_0_0_1.4px_var(--kit-insp-faint)]" : "bg-kit-insp-tip-title") }));
|
|
94
|
+
break;
|
|
95
|
+
case "quote":
|
|
96
|
+
body = /* @__PURE__ */ jsxs("span", {
|
|
97
|
+
className: "flex flex-col gap-[7px] border-l-[3px] border-kit-insp-tip-title pl-2.5",
|
|
98
|
+
children: [
|
|
99
|
+
bar(130),
|
|
100
|
+
bar(140),
|
|
101
|
+
bar(90)
|
|
102
|
+
]
|
|
103
|
+
});
|
|
104
|
+
break;
|
|
105
|
+
case "callout":
|
|
106
|
+
body = /* @__PURE__ */ jsxs("span", {
|
|
107
|
+
className: "relative flex flex-col gap-[7px] rounded-lg bg-kit-insp-callout-info py-2.5 pl-[26px] pr-2.5 shadow-[inset_0_0_0_1px_var(--kit-insp-callout-info-line)]",
|
|
108
|
+
children: [
|
|
109
|
+
/* @__PURE__ */ jsx("b", { className: "absolute left-[9px] top-[9px] size-[9px] rounded-full bg-kit-insp-callout-info-icon" }),
|
|
110
|
+
bar(110, "bg-kit-insp-callout-info-line"),
|
|
111
|
+
bar(90, "bg-kit-insp-callout-info-line")
|
|
112
|
+
]
|
|
113
|
+
});
|
|
114
|
+
break;
|
|
115
|
+
case "divider":
|
|
116
|
+
body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
117
|
+
bar(150),
|
|
118
|
+
/* @__PURE__ */ jsx("hr", { className: "-mx-3.5 my-0.5 h-[1.5px] border-0 bg-kit-insp-faint" }),
|
|
119
|
+
bar(120)
|
|
120
|
+
] });
|
|
121
|
+
break;
|
|
122
|
+
case "toggle":
|
|
123
|
+
body = /* @__PURE__ */ jsxs("span", {
|
|
124
|
+
className: "relative flex flex-col gap-[7px] pl-3.5",
|
|
125
|
+
children: [
|
|
126
|
+
/* @__PURE__ */ jsx("b", { className: "absolute left-0 top-0.5 border-y-4 border-l-[6px] border-y-transparent border-l-kit-insp-tip-title" }),
|
|
127
|
+
bar(100, HEAD),
|
|
128
|
+
/* @__PURE__ */ jsxs("span", {
|
|
129
|
+
className: "flex flex-col gap-[7px]",
|
|
130
|
+
children: [bar(120), bar(96)]
|
|
131
|
+
})
|
|
132
|
+
]
|
|
133
|
+
});
|
|
134
|
+
break;
|
|
135
|
+
case "table":
|
|
136
|
+
body = /* @__PURE__ */ jsx("span", {
|
|
137
|
+
className: "flex flex-col",
|
|
138
|
+
children: [
|
|
139
|
+
0,
|
|
140
|
+
1,
|
|
141
|
+
2
|
|
142
|
+
].map((r) => /* @__PURE__ */ jsx("span", {
|
|
143
|
+
className: cn("flex", r === 0 && "bg-kit-insp-card-focus"),
|
|
144
|
+
children: [
|
|
145
|
+
0,
|
|
146
|
+
1,
|
|
147
|
+
2
|
|
148
|
+
].map((c) => /* @__PURE__ */ jsx("i", { className: "h-[22px] flex-1 shadow-[inset_-1px_-1px_0_var(--kit-insp-line)]" }, c))
|
|
149
|
+
}, r))
|
|
150
|
+
});
|
|
151
|
+
break;
|
|
152
|
+
case "stats":
|
|
153
|
+
body = /* @__PURE__ */ jsx("span", {
|
|
154
|
+
className: "grid grid-cols-3 gap-1.5",
|
|
155
|
+
children: [
|
|
156
|
+
0,
|
|
157
|
+
1,
|
|
158
|
+
2
|
|
159
|
+
].map((x) => /* @__PURE__ */ jsxs("span", {
|
|
160
|
+
className: "flex flex-col gap-1 rounded-md p-1.5 shadow-[inset_0_0_0_1px_var(--kit-insp-divider)]",
|
|
161
|
+
children: [
|
|
162
|
+
/* @__PURE__ */ jsx("i", { className: BAR }),
|
|
163
|
+
/* @__PURE__ */ jsx("b", { className: "h-[9px] rounded-[3px] bg-kit-insp-tip-title" }),
|
|
164
|
+
/* @__PURE__ */ jsx("i", { className: BAR })
|
|
165
|
+
]
|
|
166
|
+
}, x))
|
|
167
|
+
});
|
|
168
|
+
break;
|
|
169
|
+
case "code":
|
|
170
|
+
body = /* @__PURE__ */ jsxs("span", {
|
|
171
|
+
className: "flex flex-col gap-1.5 bg-kit-insp-code-bg pb-2.5",
|
|
172
|
+
children: [/* @__PURE__ */ jsx("span", { className: "h-3.5 border-b border-kit-insp-code-menu-line" }), [
|
|
173
|
+
[60, "c"],
|
|
174
|
+
[
|
|
175
|
+
24,
|
|
176
|
+
"k",
|
|
177
|
+
70
|
|
178
|
+
],
|
|
179
|
+
[50, "s"],
|
|
180
|
+
[90]
|
|
181
|
+
].map(([w, c, w2], n) => /* @__PURE__ */ jsxs("span", {
|
|
182
|
+
className: "flex gap-1.5 px-2.5",
|
|
183
|
+
children: [/* @__PURE__ */ jsx("i", {
|
|
184
|
+
className: cn("block h-1 rounded-[3px]", c === "c" ? "bg-kit-insp-code-gutter" : c === "k" ? "bg-kit-insp-code-kw" : c === "s" ? "bg-kit-insp-code-str" : "bg-kit-insp-code-fg opacity-80"),
|
|
185
|
+
style: { width: w }
|
|
186
|
+
}), w2 ? /* @__PURE__ */ jsx("i", {
|
|
187
|
+
className: "block h-1 rounded-[3px] bg-kit-insp-code-fg opacity-80",
|
|
188
|
+
style: { width: w2 }
|
|
189
|
+
}) : null]
|
|
190
|
+
}, n))]
|
|
191
|
+
});
|
|
192
|
+
break;
|
|
193
|
+
case "image":
|
|
194
|
+
body = /* @__PURE__ */ jsxs("span", {
|
|
195
|
+
className: "relative block h-[68px] bg-kit-insp-divider",
|
|
196
|
+
children: [
|
|
197
|
+
/* @__PURE__ */ jsx("b", { className: "absolute right-[22px] top-3 size-3 rounded-full bg-kit-insp-tip-bg" }),
|
|
198
|
+
/* @__PURE__ */ jsx("b", { className: "absolute bottom-0 left-[18px] border-x-[40px] border-b-[38px] border-x-transparent border-b-kit-insp-line-strong" }),
|
|
199
|
+
/* @__PURE__ */ jsx("b", { className: "absolute bottom-0 left-[66px] border-x-[36px] border-b-[28px] border-x-transparent border-b-kit-insp-faint" })
|
|
200
|
+
]
|
|
201
|
+
});
|
|
202
|
+
break;
|
|
203
|
+
case "video":
|
|
204
|
+
body = /* @__PURE__ */ jsx("span", {
|
|
205
|
+
className: "grid h-[68px] place-items-center bg-kit-insp-code-bg",
|
|
206
|
+
children: /* @__PURE__ */ jsx("b", { className: "size-6 rounded-full bg-kit-insp-tip-bg" })
|
|
207
|
+
});
|
|
208
|
+
break;
|
|
209
|
+
case "file":
|
|
210
|
+
body = /* @__PURE__ */ jsxs("span", {
|
|
211
|
+
className: "grid grid-cols-[22px_1fr] items-center gap-x-2 gap-y-[5px]",
|
|
212
|
+
children: [
|
|
213
|
+
/* @__PURE__ */ jsx("b", { className: "row-span-2 size-[22px] rounded-[5px] bg-kit-insp-divider" }),
|
|
214
|
+
bar(70, HEAD),
|
|
215
|
+
bar(46)
|
|
216
|
+
]
|
|
217
|
+
});
|
|
218
|
+
break;
|
|
219
|
+
default: body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
220
|
+
bar(100, HEAD),
|
|
221
|
+
bar(150),
|
|
222
|
+
bar(120)
|
|
223
|
+
] });
|
|
224
|
+
}
|
|
225
|
+
return /* @__PURE__ */ jsx("div", {
|
|
226
|
+
"data-art": art ?? "block",
|
|
227
|
+
className: cn("flex w-[168px] flex-col gap-2 rounded-md bg-kit-insp-tip-bg shadow-[inset_0_0_0_1px_var(--kit-insp-divider)]", flush ? "overflow-hidden p-0" : "p-3.5"),
|
|
228
|
+
children: body
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
/** A site component's card: its own thumbnail (the row's tile) on the white mini card of the prototype's site blocks. */
|
|
232
|
+
function ComponentArt({ it }) {
|
|
233
|
+
return /* @__PURE__ */ jsx("div", {
|
|
234
|
+
className: "flex h-[88px] w-[170px] items-center justify-center overflow-hidden rounded-md bg-kit-insp-tip-bg shadow-[inset_0_0_0_1px_var(--kit-insp-divider),0_2px_6px_rgb(0_0_0/0.06)] [&_img]:max-h-full [&_img]:max-w-full [&_svg]:size-8 [&_svg]:text-kit-insp-faint",
|
|
235
|
+
children: it.icon
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
/** The card, placed by the panel (absolute, right of the menu); `top` = the highlighted row's top - 6. */
|
|
239
|
+
function SlashPreviewCard({ item, top }) {
|
|
240
|
+
const [shown, setShown] = React.useState(null);
|
|
241
|
+
const key = item?.key;
|
|
242
|
+
React.useEffect(() => {
|
|
243
|
+
setShown(null);
|
|
244
|
+
if (!previewable(item)) return;
|
|
245
|
+
const t = window.setTimeout(() => setShown(item), 250);
|
|
246
|
+
return () => window.clearTimeout(t);
|
|
247
|
+
}, [key]);
|
|
248
|
+
return /* @__PURE__ */ jsx(AnimatePresence, { children: shown ? /* @__PURE__ */ jsxs(motion.div, {
|
|
249
|
+
"data-slash-preview": "",
|
|
250
|
+
"aria-hidden": true,
|
|
251
|
+
className: "pointer-events-none absolute left-[calc(100%+6px)] top-0 w-[232px] rounded-[10px] bg-kit-insp-tip-bg px-1.5 pb-1 pt-1.5 text-[13px] leading-[19.5px] text-kit-insp-tip-title shadow-[0_0_0_1px_rgb(0_0_0/0.06),0_12px_28px_rgb(0_0_0/0.12)]",
|
|
252
|
+
style: { marginTop: top },
|
|
253
|
+
initial: {
|
|
254
|
+
opacity: 0,
|
|
255
|
+
x: -4
|
|
256
|
+
},
|
|
257
|
+
animate: {
|
|
258
|
+
opacity: 1,
|
|
259
|
+
x: 0
|
|
260
|
+
},
|
|
261
|
+
exit: { opacity: 0 },
|
|
262
|
+
transition: { duration: .16 },
|
|
263
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
264
|
+
className: "grid h-28 place-items-center rounded-md bg-kit-insp-card-focus",
|
|
265
|
+
children: shown.kind === "component" ? /* @__PURE__ */ jsx(ComponentArt, { it: shown }) : /* @__PURE__ */ jsx(Wireframe, { art: shown.id ? ART[shown.id] : void 0 })
|
|
266
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
267
|
+
className: "flex items-start gap-2 px-2 pb-1.5 pt-2",
|
|
268
|
+
children: [/* @__PURE__ */ jsxs("span", {
|
|
269
|
+
className: "flex min-w-0 flex-1 flex-col",
|
|
270
|
+
children: [/* @__PURE__ */ jsx("b", {
|
|
271
|
+
className: "truncate font-medium text-kit-insp-tip-title",
|
|
272
|
+
children: shown.label
|
|
273
|
+
}), /* @__PURE__ */ jsx("small", {
|
|
274
|
+
className: "text-[12px] leading-[18px] text-kit-group-sub",
|
|
275
|
+
children: shown.description
|
|
276
|
+
})]
|
|
277
|
+
}), shown.hint ? /* @__PURE__ */ jsx("kbd", {
|
|
278
|
+
className: "shrink-0 font-kit-sans text-[13px] text-kit-group-sub",
|
|
279
|
+
children: shown.hint
|
|
280
|
+
}) : null]
|
|
281
|
+
})]
|
|
282
|
+
}, shown.key) : null });
|
|
283
|
+
}
|
|
284
|
+
//#endregion
|
|
285
|
+
export { SlashPreviewCard, previewable };
|
|
286
|
+
|
|
287
|
+
//# sourceMappingURL=slash-preview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slash-preview.js","names":[],"sources":["../../../src/controls/rich-text/slash-preview.tsx"],"sourcesContent":["/* Slash menu hover preview card · look \"v16\" (F2107; prototype content.jsx:1238-1258 + PvArt :1309-1330, content.css:236,\n 285-292, 401-428). 250ms after a row is highlighted a 232 wide white card (ring + 12/28 shadow, radius 10, padding\n 6/6/4) opens 6px to the right of the menu, level with that row: a 112 high #FAFAFA art box with a wireframe of the\n block, then the 13/500 title, the 12 #707070 description and the key hint. Not shown for the AI view's rows, More\n components, the way back or a refused row. Fades in from x -4 over 160ms. */\nimport * as React from \"react\";\nimport { AnimatePresence, motion } from \"framer-motion\";\nimport { cn } from \"../../lib/cn\";\nimport type { BasicId, CatalogItem } from \"./catalog\";\n\n/** The row a preview card is drawn for (null: none). Exported for tests. */\nexport function previewable(it: CatalogItem | undefined): it is CatalogItem {\n return !!it && !it.kind?.match(/^(folder|back|ai)$/) && !it.ai && !it.disabled;\n}\n\nconst BAR = \"block h-1.5 rounded-[3px] bg-kit-insp-line\";\nconst bar = (w: number, cls = \"\") => <i className={cn(BAR, cls)} style={{ width: w }} />;\nconst HEAD = \"h-2.5 bg-kit-insp-tip-title opacity-85\";\n\ntype Art = \"paragraph\" | \"h1\" | \"h2\" | \"h3\" | \"bullets\" | \"numbers\" | \"checklist\" | \"quote\" | \"callout\" | \"divider\" | \"toggle\" | \"table\" | \"stats\" | \"code\" | \"image\" | \"video\" | \"file\";\nconst ART: Partial<Record<BasicId, Art>> = {\n p: \"paragraph\", h1: \"h1\", h2: \"h2\", h3: \"h3\", h4: \"h3\", h5: \"h3\", h6: \"h3\", ul: \"bullets\", ol: \"numbers\", task: \"checklist\",\n quote: \"quote\", pullquote: \"quote\", callout: \"callout\", hr: \"divider\", toggle: \"toggle\", table: \"table\", stats: \"stats\",\n code: \"code\", image: \"image\", gallery: \"image\", video: \"video\", embed: \"video\", file: \"file\",\n};\n\nfunction rows3(mark: (i: number) => React.ReactNode) {\n return [110, 130, 90].map((w, i) => (\n <span key={i} className=\"flex items-center gap-2\">\n {mark(i)}\n {bar(w, \"min-w-0 shrink\")}\n </span>\n ));\n}\n\nfunction Wireframe({ art }: { art: Art | undefined }) {\n const flush = art === \"table\" || art === \"code\" || art === \"image\" || art === \"video\";\n let body: React.ReactNode;\n switch (art) {\n case \"paragraph\": body = <>{bar(150)}{bar(140)}{bar(96)}</>; break;\n case \"h1\": body = <>{bar(120, \"h-3.5 bg-kit-insp-tip-title opacity-85\")}{bar(150)}{bar(110)}</>; break;\n case \"h2\": body = <>{bar(100, HEAD)}{bar(150)}{bar(118)}</>; break;\n case \"h3\": body = <>{bar(80, \"h-2 bg-kit-insp-tip-title opacity-85\")}{bar(150)}{bar(126)}</>; break;\n case \"bullets\": body = rows3(() => <b className=\"size-[5px] shrink-0 rounded-full bg-kit-insp-tip-title\" />); break;\n case \"numbers\": body = rows3((i) => <b className=\"shrink-0 text-[9px] font-normal leading-[10px] text-kit-group-sub\">{i + 1}</b>); break;\n case \"checklist\":\n body = rows3((i) => <b className={cn(\"size-[9px] shrink-0 rounded-[3px]\", i ? \"shadow-[inset_0_0_0_1.4px_var(--kit-insp-faint)]\" : \"bg-kit-insp-tip-title\")} />);\n break;\n case \"quote\": body = <span className=\"flex flex-col gap-[7px] border-l-[3px] border-kit-insp-tip-title pl-2.5\">{bar(130)}{bar(140)}{bar(90)}</span>; break;\n case \"callout\":\n body = (\n <span className=\"relative flex flex-col gap-[7px] rounded-lg bg-kit-insp-callout-info py-2.5 pl-[26px] pr-2.5 shadow-[inset_0_0_0_1px_var(--kit-insp-callout-info-line)]\">\n <b className=\"absolute left-[9px] top-[9px] size-[9px] rounded-full bg-kit-insp-callout-info-icon\" />\n {bar(110, \"bg-kit-insp-callout-info-line\")}\n {bar(90, \"bg-kit-insp-callout-info-line\")}\n </span>\n );\n break;\n case \"divider\": body = <>{bar(150)}<hr className=\"-mx-3.5 my-0.5 h-[1.5px] border-0 bg-kit-insp-faint\" />{bar(120)}</>; break;\n case \"toggle\":\n body = (\n <span className=\"relative flex flex-col gap-[7px] pl-3.5\">\n <b className=\"absolute left-0 top-0.5 border-y-4 border-l-[6px] border-y-transparent border-l-kit-insp-tip-title\" />\n {bar(100, HEAD)}\n <span className=\"flex flex-col gap-[7px]\">{bar(120)}{bar(96)}</span>\n </span>\n );\n break;\n case \"table\":\n body = (\n <span className=\"flex flex-col\">\n {[0, 1, 2].map((r) => (\n <span key={r} className={cn(\"flex\", r === 0 && \"bg-kit-insp-card-focus\")}>\n {[0, 1, 2].map((c) => <i key={c} className=\"h-[22px] flex-1 shadow-[inset_-1px_-1px_0_var(--kit-insp-line)]\" />)}\n </span>\n ))}\n </span>\n );\n break;\n case \"stats\":\n body = (\n <span className=\"grid grid-cols-3 gap-1.5\">\n {[0, 1, 2].map((x) => (\n <span key={x} className=\"flex flex-col gap-1 rounded-md p-1.5 shadow-[inset_0_0_0_1px_var(--kit-insp-divider)]\">\n <i className={BAR} />\n <b className=\"h-[9px] rounded-[3px] bg-kit-insp-tip-title\" />\n <i className={BAR} />\n </span>\n ))}\n </span>\n );\n break;\n case \"code\":\n body = (\n <span className=\"flex flex-col gap-1.5 bg-kit-insp-code-bg pb-2.5\">\n <span className=\"h-3.5 border-b border-kit-insp-code-menu-line\" />\n {([[60, \"c\"], [24, \"k\", 70], [50, \"s\"], [90]] as [number, string?, number?][]).map(([w, c, w2], n) => (\n <span key={n} className=\"flex gap-1.5 px-2.5\">\n <i className={cn(\"block h-1 rounded-[3px]\", c === \"c\" ? \"bg-kit-insp-code-gutter\" : c === \"k\" ? \"bg-kit-insp-code-kw\" : c === \"s\" ? \"bg-kit-insp-code-str\" : \"bg-kit-insp-code-fg opacity-80\")} style={{ width: w }} />\n {w2 ? <i className=\"block h-1 rounded-[3px] bg-kit-insp-code-fg opacity-80\" style={{ width: w2 }} /> : null}\n </span>\n ))}\n </span>\n );\n break;\n case \"image\":\n body = (\n <span className=\"relative block h-[68px] bg-kit-insp-divider\">\n <b className=\"absolute right-[22px] top-3 size-3 rounded-full bg-kit-insp-tip-bg\" />\n <b className=\"absolute bottom-0 left-[18px] border-x-[40px] border-b-[38px] border-x-transparent border-b-kit-insp-line-strong\" />\n <b className=\"absolute bottom-0 left-[66px] border-x-[36px] border-b-[28px] border-x-transparent border-b-kit-insp-faint\" />\n </span>\n );\n break;\n case \"video\":\n body = (\n <span className=\"grid h-[68px] place-items-center bg-kit-insp-code-bg\">\n <b className=\"size-6 rounded-full bg-kit-insp-tip-bg\" />\n </span>\n );\n break;\n case \"file\":\n body = (\n <span className=\"grid grid-cols-[22px_1fr] items-center gap-x-2 gap-y-[5px]\">\n <b className=\"row-span-2 size-[22px] rounded-[5px] bg-kit-insp-divider\" />\n {bar(70, HEAD)}\n {bar(46)}\n </span>\n );\n break;\n default: body = <>{bar(100, HEAD)}{bar(150)}{bar(120)}</>;\n }\n return (\n <div data-art={art ?? \"block\"} className={cn(\"flex w-[168px] flex-col gap-2 rounded-md bg-kit-insp-tip-bg shadow-[inset_0_0_0_1px_var(--kit-insp-divider)]\", flush ? \"overflow-hidden p-0\" : \"p-3.5\")}>\n {body}\n </div>\n );\n}\n\n/** A site component's card: its own thumbnail (the row's tile) on the white mini card of the prototype's site blocks. */\nfunction ComponentArt({ it }: { it: CatalogItem }) {\n return (\n <div className=\"flex h-[88px] w-[170px] items-center justify-center overflow-hidden rounded-md bg-kit-insp-tip-bg shadow-[inset_0_0_0_1px_var(--kit-insp-divider),0_2px_6px_rgb(0_0_0/0.06)] [&_img]:max-h-full [&_img]:max-w-full [&_svg]:size-8 [&_svg]:text-kit-insp-faint\">\n {it.icon}\n </div>\n );\n}\n\n/** The card, placed by the panel (absolute, right of the menu); `top` = the highlighted row's top - 6. */\nexport function SlashPreviewCard({ item, top }: { item: CatalogItem | undefined; top: number }) {\n const [shown, setShown] = React.useState<CatalogItem | null>(null);\n const key = item?.key;\n React.useEffect(() => {\n setShown(null);\n if (!previewable(item)) return;\n const t = window.setTimeout(() => setShown(item), 250);\n return () => window.clearTimeout(t);\n // the card follows the highlighted row, not a new object for the same row\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [key]);\n return (\n <AnimatePresence>\n {shown ? (\n <motion.div\n key={shown.key}\n data-slash-preview=\"\"\n aria-hidden\n className=\"pointer-events-none absolute left-[calc(100%+6px)] top-0 w-[232px] rounded-[10px] bg-kit-insp-tip-bg px-1.5 pb-1 pt-1.5 text-[13px] leading-[19.5px] text-kit-insp-tip-title shadow-[0_0_0_1px_rgb(0_0_0/0.06),0_12px_28px_rgb(0_0_0/0.12)]\"\n style={{ marginTop: top }}\n initial={{ opacity: 0, x: -4 }}\n animate={{ opacity: 1, x: 0 }}\n exit={{ opacity: 0 }}\n transition={{ duration: 0.16 }}\n >\n <div className=\"grid h-28 place-items-center rounded-md bg-kit-insp-card-focus\">\n {shown.kind === \"component\" ? <ComponentArt it={shown} /> : <Wireframe art={shown.id ? ART[shown.id] : undefined} />}\n </div>\n <div className=\"flex items-start gap-2 px-2 pb-1.5 pt-2\">\n <span className=\"flex min-w-0 flex-1 flex-col\">\n <b className=\"truncate font-medium text-kit-insp-tip-title\">{shown.label}</b>\n <small className=\"text-[12px] leading-[18px] text-kit-group-sub\">{shown.description}</small>\n </span>\n {shown.hint ? <kbd className=\"shrink-0 font-kit-sans text-[13px] text-kit-group-sub\">{shown.hint}</kbd> : null}\n </div>\n </motion.div>\n ) : null}\n </AnimatePresence>\n );\n}\n"],"mappings":";;;;;;AAWA,SAAgB,YAAY,IAAgD;CAC1E,OAAO,CAAC,CAAC,MAAM,CAAC,GAAG,MAAM,MAAM,oBAAoB,KAAK,CAAC,GAAG,MAAM,CAAC,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S,EAAE;EACnB,YAAY,EAAE,UAAU,IAAK;EAT/B,UAAA,CAWE,oBAAC,OAAD;GAAK,WAAU;GACZ,UAAA,MAAM,SAAS,cAAc,oBAAC,cAAD,EAAc,IAAI,MAAQ,CAAA,IAAI,oBAAC,WAAD,EAAW,KAAK,MAAM,KAAK,IAAI,MAAM,MAAM,KAAA,EAAY,CAAA;EAChH,CAAA,GACL,qBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,qBAAC,QAAD;IAAM,WAAU;IAAhB,UAAA,CACE,oBAAC,KAAD;KAAG,WAAU;KAAgD,UAAA,MAAM;IAAS,CAAA,GAC5E,oBAAC,SAAD;KAAO,WAAU;KAAiD,UAAA,MAAM;IAAmB,CAAA,CACvF;GACL,CAAA,GAAA,MAAM,OAAO,oBAAC,OAAD;IAAK,WAAU;IAAyD,UAAA,MAAM;GAAU,CAAA,IAAI,IACvG;EACK,CAAA,CAAA;CApBL,GAAA,MAAM,GAoBD,IACV,KACW,CAAA;AAErB"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type TableFieldOptions, type TableRow, type TableValue } from "../../schema/table";
|
|
2
|
+
import type { BlockProps } from "./blocks";
|
|
3
|
+
/** Rows as the table shows them (ungrouped, then each row group, then the totals): the grid's row order. */
|
|
4
|
+
export declare function gridRows(t: TableValue): TableRow[];
|
|
5
|
+
/** Remove footnote `key` and every cell mark that names it. */
|
|
6
|
+
export declare function gridDeleteFootnote(t: TableValue, key: string): TableValue;
|
|
7
|
+
/** Write one footnote's text. */
|
|
8
|
+
export declare const gridFootnoteText: (t: TableValue, key: string, text: string) => TableValue;
|
|
9
|
+
/** A new column at `at`; with the header row on its header says "Column" (content.jsx:1093). */
|
|
10
|
+
export declare function gridInsertColumn(t: TableValue, at: number): TableValue;
|
|
11
|
+
export declare function gridMoveColumn(t: TableValue, from: number, to: number): TableValue;
|
|
12
|
+
export declare function gridDeleteColumn(t: TableValue, at: number): TableValue;
|
|
13
|
+
/** An empty row at shown position `at`; it joins the row group (or the totals) of the row it is added next to. */
|
|
14
|
+
export declare function gridInsertRow(t: TableValue, at: number, above?: boolean): TableValue;
|
|
15
|
+
export declare function gridDeleteRow(t: TableValue, at: number): TableValue;
|
|
16
|
+
/** "Center text": every column centred, or back to each column's own default. */
|
|
17
|
+
export declare const gridCentered: (t: TableValue) => boolean;
|
|
18
|
+
export declare function gridToggleCenter(t: TableValue): TableValue;
|
|
19
|
+
/** The v16 table block. `m` is the island's table value; every edit goes through `set` (one undo history). */
|
|
20
|
+
export declare function TableGridV16({ m, set, el, ctx, autoFocus, options }: BlockProps<"table"> & {
|
|
21
|
+
options?: TableFieldOptions;
|
|
22
|
+
}): import("react/jsx-runtime").JSX.Element;
|