@pixerate/editor 0.26.0 → 0.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -2
- package/dist/agent/index.cjs +59 -9
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +6 -4
- package/dist/agent/index.d.ts +6 -4
- package/dist/agent/index.js +52 -2
- package/dist/agent/index.js.map +1 -1
- package/dist/{builtins-Chj6zv_O.d.ts → builtins-haN82vjT.d.ts} +33 -3
- package/dist/{builtins-CdPcLwwF.d.cts → builtins-nMXh9sT3.d.cts} +33 -3
- package/dist/canvas/index.cjs +372 -8
- package/dist/canvas/index.cjs.map +1 -1
- package/dist/canvas/index.d.cts +72 -4
- package/dist/canvas/index.d.ts +72 -4
- package/dist/canvas/index.js +368 -4
- package/dist/canvas/index.js.map +1 -1
- package/dist/{chunk-UBCFIABU.js → chunk-5H2OPMXZ.js} +183 -6
- package/dist/chunk-5H2OPMXZ.js.map +1 -0
- package/dist/{chunk-NFVBT3UZ.cjs → chunk-66IMF6OD.cjs} +108 -25
- package/dist/chunk-66IMF6OD.cjs.map +1 -0
- package/dist/{chunk-Q2OHWD2A.js → chunk-6IO7WUSU.js} +19 -5
- package/dist/chunk-6IO7WUSU.js.map +1 -0
- package/dist/{chunk-YOMYSFJU.cjs → chunk-AGR7EVRW.cjs} +49 -35
- package/dist/chunk-AGR7EVRW.cjs.map +1 -0
- package/dist/{chunk-RRREAOVM.cjs → chunk-HNDSPZ5T.cjs} +4 -4
- package/dist/{chunk-RRREAOVM.cjs.map → chunk-HNDSPZ5T.cjs.map} +1 -1
- package/dist/chunk-HXDMZQTD.cjs +497 -0
- package/dist/chunk-HXDMZQTD.cjs.map +1 -0
- package/dist/chunk-IB3ZHQAX.js +497 -0
- package/dist/chunk-IB3ZHQAX.js.map +1 -0
- package/dist/{chunk-X7HXL2SB.js → chunk-JT7AXQTE.js} +336 -10
- package/dist/chunk-JT7AXQTE.js.map +1 -0
- package/dist/{chunk-HDYMLS3X.cjs → chunk-MC2LQN5S.cjs} +196 -19
- package/dist/chunk-MC2LQN5S.cjs.map +1 -0
- package/dist/{chunk-JOIREKL7.js → chunk-UKI64KUD.js} +85 -2
- package/dist/chunk-UKI64KUD.js.map +1 -0
- package/dist/{chunk-MHEPLBFB.js → chunk-WON34HKM.js} +2 -2
- package/dist/{chunk-NQF32I6Z.cjs → chunk-YK5TATOF.cjs} +461 -135
- package/dist/chunk-YK5TATOF.cjs.map +1 -0
- package/dist/commands/index.cjs +30 -410
- package/dist/commands/index.cjs.map +1 -1
- package/dist/commands/index.d.cts +1 -1
- package/dist/commands/index.d.ts +1 -1
- package/dist/commands/index.js +17 -397
- package/dist/commands/index.js.map +1 -1
- package/dist/{controller-CxXGOEmy.d.cts → controller-w6eRTjF8.d.cts} +67 -2
- package/dist/{controller-CxXGOEmy.d.ts → controller-w6eRTjF8.d.ts} +67 -2
- package/dist/extensions/index.cjs +23 -5
- package/dist/extensions/index.cjs.map +1 -1
- package/dist/extensions/index.d.cts +1 -1
- package/dist/extensions/index.d.ts +1 -1
- package/dist/extensions/index.js +23 -5
- package/dist/{index-jcJwmBYt.d.cts → index-C6gaQRH0.d.cts} +53 -4
- package/dist/{index-B273Zllk.d.ts → index-DXAv_R08.d.ts} +53 -4
- package/dist/index.cjs +66 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -6
- package/dist/index.d.ts +8 -6
- package/dist/index.js +46 -6
- package/dist/index.js.map +1 -1
- package/dist/serializers/index.cjs +5 -3
- package/dist/serializers/index.cjs.map +1 -1
- package/dist/serializers/index.d.cts +13 -3
- package/dist/serializers/index.d.ts +13 -3
- package/dist/serializers/index.js +4 -2
- package/dist/spreadsheet/index.cjs +22 -2
- package/dist/spreadsheet/index.cjs.map +1 -1
- package/dist/spreadsheet/index.d.cts +76 -3
- package/dist/spreadsheet/index.d.ts +76 -3
- package/dist/spreadsheet/index.js +21 -1
- package/package.json +1 -1
- package/dist/chunk-HDYMLS3X.cjs.map +0 -1
- package/dist/chunk-JOIREKL7.js.map +0 -1
- package/dist/chunk-NFVBT3UZ.cjs.map +0 -1
- package/dist/chunk-NQF32I6Z.cjs.map +0 -1
- package/dist/chunk-Q2OHWD2A.js.map +0 -1
- package/dist/chunk-UBCFIABU.js.map +0 -1
- package/dist/chunk-X7HXL2SB.js.map +0 -1
- package/dist/chunk-YOMYSFJU.cjs.map +0 -1
- /package/dist/{chunk-MHEPLBFB.js.map → chunk-WON34HKM.js.map} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/editor/editor/packages/core/dist/chunk-66IMF6OD.cjs","../src/serializers/plain-text.ts","../src/serializers/html-scan.ts","../src/serializers/mentions.ts","../src/serializers/markdown.ts"],"names":["match"],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACZA,yCAAqF;ADcrF;AACA;AEcO,SAAS,YAAA,CACd,IAAA,EACA,GAAA,EACA,QAAA,EACA,YAAA,EACW;AACX,EAAA,MAAM,QAAA,EAAU,OAAO,SAAA,IAAa,WAAA,EAAa,SAAA,EAAW,CAAC,KAAA,EAAA,GAAkB,QAAA,CAAS,IAAA,CAAK,KAAK,CAAA;AAClG,EAAA,MAAM,MAAA,EAAmB,CAAC,CAAA;AAC1B,EAAA,MAAM,QAAA,EAAU,IAAI,MAAA,CAAO,CAAA,CAAA,EAAI,GAAG,CAAA,GAAA,CAAA,EAAO,IAAI,CAAA;AAC7C,EAAA,MAAM,SAAA,EAAW,IAAI,MAAA,CAAO,CAAA,EAAA,EAAK,GAAG,CAAA,CAAA,CAAA,EAAK,IAAI,CAAA;AAC7C,EAAA,MAAM,YAAA,EAAc,GAAA,CAAI,OAAA,EAAS,CAAA;AACjC,EAAA,IAAI,OAAA,EAAS,CAAA,CAAA;AACb,EAAA,IAAI,UAAA,EAAY,CAAA,CAAA;AACh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AA;AACpB,EAAA;AAC2B,EAAA;AAC7B;AAE6B;AACD;AACV;AAIA;AAgBF;AACO,EAAA;AACN,EAAA;AACb,IAAA;AACmB,IAAA;AACD,MAAA;AACE,MAAA;AACG,MAAA;AAGF,MAAA;AACrB,IAAA;AACF,EAAA;AACF;AAgCgB;AAIQ,EAAA;AACR,EAAA;AACD,EAAA;AACD,IAAA;AACZ,EAAA;AAEW,EAAA;AAIW,IAAA;AACI,MAAA;AACxB,IAAA;AACU,IAAA;AACZ,EAAA;AAC0B,EAAA;AAC5B;AASkC;AACZ,EAAA;AACI,EAAA;AACH,EAAA;AACA,IAAA;AACD,IAAA;AACC,MAAA;AACK,MAAA;AACxB,IAAA;AACgB,IAAA;AAClB,EAAA;AACqB,EAAA;AACvB;AJylB6B;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/editor/editor/packages/core/dist/chunk-66IMF6OD.cjs","sourcesContent":[null,"import { DOMSerializer, Slice, Fragment, Node as ProsemirrorNode, type Schema } from \"@tiptap/pm/model\";\nimport {\n BLOCK_CHANGE_ATTRIBUTE,\n MOVE_ID_ATTRIBUTE,\n resolveTrackedChanges,\n type TrackedChangesView,\n} from \"../extensions/track-changes\";\nimport { findTagSpans, replaceTagSpans, stripTags } from \"./html-scan\";\n\nexport interface PlainTextOptions {\n /**\n * How tracked changes (`TrackChanges` extension) appear in the text.\n * Defaults to `\"accepted\"`: deleted text is dropped and inserted text kept,\n * so suggested deletions never leak into exported text. `\"original\"` drops\n * insertions and keeps deletions; `\"all\"` keeps both.\n */\n trackedChanges?: TrackedChangesView;\n}\n\n/**\n * Match tracked deletion / insertion elements. They never nest within\n * themselves, so a lazy match is enough.\n */\nconst TRACKED_DELETION_ATTRIBUTE = /\\bdata-change-type=[\"']deletion[\"']/i;\nconst TRACKED_INSERTION_ATTRIBUTE = /\\bdata-change-type=[\"']insertion[\"']/i;\n\nfunction stripTrackedChanges(html: string, view: TrackedChangesView): string {\n if (view === \"all\" || !html.includes(\"data-change-type\")) return html;\n return view === \"accepted\"\n ? replaceTagSpans(html, \"del\", TRACKED_DELETION_ATTRIBUTE, () => \"\")\n : replaceTagSpans(html, \"ins\", TRACKED_INSERTION_ATTRIBUTE, () => \"\");\n}\n\n/**\n * Escapes characters that have syntactic meaning in HTML text.\n */\nexport function escapeHtml(text: string): string {\n if (!text) return \"\";\n return text\n .replace(/&/g, \"&\")\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/\"/g, \""\")\n .replace(/'/g, \"'\");\n}\n\n/**\n * Matches strings that are already TipTap paragraph HTML (start with `<p>` and\n * end with `</p>`), as opposed to plain text that merely mentions a `<p>` tag.\n */\nconst PARAGRAPH_HTML_REGEX = /^\\s*<p[\\s>][\\s\\S]*<\\/p>\\s*$/i;\n\n/**\n * Converts a plain-text string with newlines into HTML paragraphs suitable\n * for TipTap initial content or setContent, preserving line breaks.\n * Input that is already paragraph HTML (`<p>…</p>`) is passed through as-is.\n */\nexport function plainTextToTipTapHtml(text: string): string {\n if (!text) return \"<p></p>\";\n if (PARAGRAPH_HTML_REGEX.test(text)) {\n return text;\n }\n return text\n .replace(/\\r\\n/g, \"\\n\")\n .replace(/\\r/g, \"\\n\")\n .split(\"\\n\")\n .map((line) => `<p>${escapeHtml(line)}</p>`)\n .join(\"\");\n}\n\n/**\n * Builds an open ProseMirror slice with one paragraph per line, so inserting it\n * splits the surrounding paragraph like typing Enter would. Use it for\n * plain-text paste handling (`clipboardTextParser`) and literal text insertion.\n */\nexport function plainTextToSlice(text: string, schema: Schema): Slice {\n const nodes: ProsemirrorNode[] = [];\n text\n .replace(/\\r\\n?/g, \"\\n\")\n .split(\"\\n\")\n .forEach((line) => {\n const nodeJson: any = { type: \"paragraph\" };\n if (line.length > 0) {\n nodeJson.content = [{ type: \"text\", text: line }];\n }\n try {\n nodes.push(ProsemirrorNode.fromJSON(schema, nodeJson));\n } catch {\n // Ignore invalid node\n }\n });\n return Slice.maxOpen(Fragment.fromArray(nodes));\n}\n\n/**\n * Block-level elements that start a new line in plain-text output.\n */\nconst BLOCK_TAGS = new Set([\n \"P\", \"DIV\", \"LI\", \"UL\", \"OL\", \"PRE\", \"BLOCKQUOTE\", \"TABLE\", \"TR\",\n \"H1\", \"H2\", \"H3\", \"H4\", \"H5\", \"H6\", \"HR\",\n]);\n\nconst MENTION_TYPE_ATTRIBUTE = /\\bdata-type=[\"']mention[\"']/i;\n\nfunction getHtmlAttribute(attrs: string, name: string): string | undefined {\n const match = new RegExp(`\\\\b${name}=(?:\"([^\"]*)\"|'([^']*)')`, \"i\").exec(\n attrs,\n );\n return match ? (match[1] ?? match[2]) : undefined;\n}\n\n/**\n * Parses HTML into an inert fragment. Content of a `<template>` element is not\n * rendered, so `<img onerror>` and similar handlers never run.\n */\nfunction parseHtmlFragment(html: string): DocumentFragment {\n const template = document.createElement(\"template\");\n template.innerHTML = html;\n return template.content;\n}\n\nfunction decodeHtmlEntities(text: string): string {\n return text\n .replace(/</g, \"<\")\n .replace(/>/g, \">\")\n .replace(/"/g, '\"')\n .replace(/�*39;/g, \"'\")\n .replace(/ /g, \"\\u00a0\")\n .replace(/&/g, \"&\");\n}\n\nconst CELL_TAGS = new Set([\"TD\", \"TH\"]);\n\n/**\n * Walks DOM nodes and emits one line per *innermost* block, so nested blocks\n * (e.g. TipTap's `<li><p>…</p></li>`) are not repeated. A table row is one\n * line of tab-separated cells: a cell's paragraphs are joined with spaces and\n * a cell spanning several columns is followed by empty cells.\n */\nfunction blockLines(nodes: readonly ChildNode[]): string[] {\n const lines: string[] = [];\n let current: string | null = null;\n const flush = () => {\n if (current !== null) {\n lines.push(current);\n current = null;\n }\n };\n const visit = (node: Node) => {\n if (node.nodeType === 3) {\n const value = node.nodeValue ?? \"\";\n // Skip formatting whitespace between blocks.\n if (current === null && value.trim() === \"\") return;\n current = (current ?? \"\") + value;\n return;\n }\n if (node.nodeType !== 1) return;\n const element = node as Element;\n const tag = element.tagName.toUpperCase();\n if (tag === \"BR\") {\n current = (current ?? \"\") + \"\\n\";\n return;\n }\n if (tag === \"TR\") {\n flush();\n const cells: string[] = [];\n element.childNodes.forEach((child) => {\n if (child.nodeType !== 1 || !CELL_TAGS.has((child as Element).tagName.toUpperCase())) return;\n const cell = child as Element;\n cells.push(\n blockLines(Array.from(cell.childNodes))\n .filter((line) => line !== \"\")\n .join(\" \")\n .replace(/[\\t\\n]+/g, \" \"),\n );\n const span = parseInt(cell.getAttribute(\"colspan\") ?? \"1\", 10);\n for (let i = 1; i < Math.min(Number.isFinite(span) ? span : 1, 1000); i++) cells.push(\"\");\n });\n lines.push(cells.join(\"\\t\"));\n return;\n }\n if (!BLOCK_TAGS.has(tag)) {\n node.childNodes.forEach(visit);\n return;\n }\n flush();\n const linesBefore = lines.length;\n node.childNodes.forEach(visit);\n flush();\n // An empty block (e.g. <p></p>) is an empty line.\n if (lines.length === linesBefore && tag !== \"HR\" && tag !== \"TABLE\") {\n lines.push(\"\");\n }\n };\n nodes.forEach(visit);\n flush();\n return lines;\n}\n\n/**\n * Extracts plain text from an HTML string or TipTap HTML, preserving newlines\n * between block tags. Table rows become lines of tab-separated cells.\n */\nexport function htmlToPlainText(html: string, options: PlainTextOptions = {}): string {\n if (!html) return \"\";\n\n // Normalize mentions so data-label is preserved as @label even if textContent is empty\n const trackedResolved = stripTrackedChanges(\n html,\n options.trackedChanges ?? \"accepted\",\n );\n const mentionNormalized = replaceTagSpans(trackedResolved, \"span\", MENTION_TYPE_ATTRIBUTE, (match, attrs) => {\n const label =\n getHtmlAttribute(attrs, \"data-label\") || getHtmlAttribute(attrs, \"data-id\");\n const role = getHtmlAttribute(attrs, \"data-role\");\n // A role is written as `@label:role`, the text syntax `extractMentions` reads.\n const validRole = role && /^[A-Za-z](?:[A-Za-z0-9_-]*[A-Za-z0-9])?$/.test(role) ? role : \"\";\n return label ? `@${label}${validRole ? `:${validRole}` : \"\"}` : match;\n });\n\n if (typeof document !== \"undefined\") {\n const fragment = parseHtmlFragment(mentionNormalized);\n fragment\n .querySelectorAll(\"br.ProseMirror-trailingBreak\")\n .forEach((br) => br.remove());\n\n return blockLines(Array.from(fragment.childNodes)).join(\"\\n\");\n }\n\n // Node.js fallback regex. Table cells are tab-separated and rows end lines\n // (a cell's own closing paragraph is dropped first so it does not end the line).\n const text = mentionNormalized\n .replace(/<\\/p>\\s*<\\/t([dh])>/gi, \"</t$1>\")\n .replace(/<\\/t[dh]>\\s*(?=<t[dh][\\s>])/gi, \"\\t\")\n .replace(/<\\/tr>/gi, \"\\n\")\n .replace(/<br\\s*\\/?>/gi, \"\\n\")\n // A closing block, plus any closing wrappers right after it, ends one line.\n .replace(\n /<\\/(?:p|div|li|pre|blockquote|h[1-6])>(?:\\s*<\\/(?:li|ul|ol|blockquote|div)>)*/gi,\n \"\\n\",\n );\n return decodeHtmlEntities(stripTags(text)).replace(/\\n$/, \"\");\n}\n\n/**\n * Whole-block insertions/deletions (`blockChange.operation`, from document\n * comparison) have no `<ins>`/`<del>` elements to strip, and resolving a\n * moved paragraph removes its whole block, so documents with either are\n * resolved first and serialized from the resolved document.\n */\nfunction resolvedBlockOperationsHtml(editor: any, view: TrackedChangesView): string | null {\n const doc: ProsemirrorNode | undefined = editor?.state?.doc;\n if (!doc || view === \"all\" || typeof document === \"undefined\") return null;\n let found = false;\n doc.descendants((node) => {\n if (found) return false;\n if (node.isTextblock) {\n if (node.attrs?.[BLOCK_CHANGE_ATTRIBUTE]?.operation) found = true;\n else node.forEach((child) => {\n if (child.marks.some((mark) => mark.attrs?.[MOVE_ID_ATTRIBUTE])) found = true;\n });\n return false;\n }\n return true;\n });\n if (!found) return null;\n const resolved = resolveTrackedChanges(doc, view);\n const container = document.createElement(\"div\");\n container.appendChild(DOMSerializer.fromSchema(doc.type.schema).serializeFragment(resolved.content));\n return container.innerHTML;\n}\n\n/**\n * Extracts plain text from a TipTap editor instance, preserving newline separators\n * between block nodes and converting mention nodes to @label. Tracked changes\n * are rendered as accepted unless `options.trackedChanges` says otherwise.\n */\nexport function getEditorText(editor: any, options: PlainTextOptions = {}): string {\n if (!editor) return \"\";\n const html =\n resolvedBlockOperationsHtml(editor, options.trackedChanges ?? \"accepted\") ??\n (typeof editor.getHTML === \"function\" ? editor.getHTML() : \"\");\n if (html) {\n return htmlToPlainText(html, options);\n }\n if (typeof editor.getText === \"function\") {\n try {\n return editor.getText({ blockSeparator: \"\\n\" });\n } catch {\n return editor.getText();\n }\n }\n return \"\";\n}\n\nexport interface ExtractedMention {\n id: string;\n label: string;\n type?: string;\n /** Asset role (`data-role`), when set. */\n role?: string;\n avatarUrl?: string;\n color?: string;\n [key: string]: any;\n}\n\nimport { extractMentions } from \"./mentions\";\n\n/**\n * Traverses an editor instance, ProseMirror document, JSONContent, or HTML string\n * and extracts all mention attributes without needing regex.\n */\nexport function extractMentionsFromDoc(docOrEditor: any): ExtractedMention[] {\n if (!docOrEditor) return [];\n const mentions: ExtractedMention[] = [];\n\n // TipTap editor or ProseMirror Node with .descendants()\n const doc =\n docOrEditor?.state?.doc ||\n (typeof docOrEditor?.descendants === \"function\" ? docOrEditor : null);\n\n if (doc && typeof doc.descendants === \"function\") {\n doc.descendants((node: any) => {\n if (node.type?.name === \"mention\" && node.attrs) {\n mentions.push({\n id: node.attrs.id || \"\",\n label: node.attrs.label || \"\",\n type: node.attrs.type,\n avatarUrl: node.attrs.avatarUrl,\n color: node.attrs.color,\n ...node.attrs,\n ...(node.attrs.assetRole ? { role: node.attrs.assetRole } : {}),\n });\n }\n });\n return mentions;\n }\n\n // JSONContent tree\n if (typeof docOrEditor === \"object\" && docOrEditor.content) {\n const walk = (nodes: any[]) => {\n for (const node of nodes) {\n if (node.type === \"mention\" && node.attrs) {\n mentions.push({\n id: node.attrs.id || \"\",\n label: node.attrs.label || \"\",\n type: node.attrs.type,\n avatarUrl: node.attrs.avatarUrl,\n color: node.attrs.color,\n ...node.attrs,\n ...(node.attrs.assetRole ? { role: node.attrs.assetRole } : {}),\n });\n }\n if (Array.isArray(node.content)) {\n walk(node.content);\n }\n }\n };\n walk(docOrEditor.content);\n return mentions;\n }\n\n // HTML String\n if (typeof docOrEditor === \"string\") {\n if (typeof document !== \"undefined\") {\n parseHtmlFragment(docOrEditor).querySelectorAll('span[data-type=\"mention\"]').forEach((el) => {\n mentions.push({\n id: el.getAttribute(\"data-id\") || \"\",\n label: el.getAttribute(\"data-label\") || \"\",\n type: el.getAttribute(\"data-type-name\") || undefined,\n avatarUrl: el.getAttribute(\"data-avatar-url\") || undefined,\n color: el.getAttribute(\"data-color\") || undefined,\n ...(el.getAttribute(\"data-role\") ? { role: el.getAttribute(\"data-role\")! } : {}),\n });\n });\n } else {\n for (const span of findTagSpans(docOrEditor, \"span\", MENTION_TYPE_ATTRIBUTE, false)) {\n const attrStr = span.attrs;\n const getAttr = (name: string) => {\n const m = new RegExp(`${name}=[\"']([^\"']*)[\"']`, \"i\").exec(attrStr);\n return m ? m[1] : undefined;\n };\n mentions.push({\n id: getAttr(\"data-id\") || \"\",\n label: getAttr(\"data-label\") || \"\",\n type: getAttr(\"data-type-name\") || getAttr(\"data-entity-type\"),\n avatarUrl: getAttr(\"data-avatar-url\"),\n color: getAttr(\"data-color\"),\n ...(getAttr(\"data-role\") ? { role: getAttr(\"data-role\") } : {}),\n });\n }\n }\n\n // Fallback: If no HTML mention tags were found, extract raw @mentions from text or markdown\n if (mentions.length === 0) {\n const rawHandles = extractMentions(docOrEditor);\n for (const handle of rawHandles) {\n mentions.push({\n id: handle,\n label: handle,\n type: \"user\",\n });\n }\n }\n }\n\n return mentions;\n}\n","/**\n * Linear-time scanners for the HTML-ish strings the serializers handle.\n *\n * Regexes like `/<span\\b[^>]*…[^>]*>/`, `/<[^>]+>/g` or `/<pre[\\s\\S]*?<\\/pre>/g` are\n * quadratic (or worse) on malformed input: every opener without its closer\n * rescans to the end of the string. These helpers find each closer once and\n * reuse it, so untrusted input can't stall the main thread (see GOTCHAS).\n */\n\nexport interface TagSpan {\n /** Index of the opening `<tag`. */\n start: number;\n /** Index just past the opening tag's `>`. */\n openEnd: number;\n /** Index just past the close tag (or `openEnd` when the close tag isn't required). */\n end: number;\n /** Attribute text between `<span` and `>`. */\n attrs: string;\n}\n\n/**\n * Finds `<tag …attrs…>…</tag>` elements whose attributes match `attrTest`, in\n * one linear pass. A regex such as `/<span\\b(?=[^>]*…)([^>]*)>[\\s\\S]*?<\\/span>/g`\n * rescans to the end of the input from every `<span` when a `>` or `</span>` is\n * missing, which is quadratic on malformed input. Here the next `>` and the next\n * close tag are found once and reused until the scan passes them, and the scan\n * stops as soon as either no longer exists further on. The first close tag after\n * the opening tag ends the element (no nesting), as with a lazy regex.\n */\nexport function findTagSpans(\n html: string,\n tag: string,\n attrTest: RegExp | ((attrs: string) => boolean),\n requireClose: boolean,\n): TagSpan[] {\n const matches = typeof attrTest === \"function\" ? attrTest : (attrs: string) => attrTest.test(attrs);\n const spans: TagSpan[] = [];\n const openTag = new RegExp(`<${tag}\\\\b`, \"gi\");\n const closeTag = new RegExp(`</${tag}>`, \"gi\");\n const closeLength = tag.length + 3;\n let nextGt = -1;\n let nextClose = -1;\n let from = 0;\n for (;;) {\n openTag.lastIndex = from;\n const open = openTag.exec(html);\n if (!open) break;\n const start = open.index;\n const attrsStart = start + open[0].length;\n if (nextGt < attrsStart) {\n nextGt = html.indexOf(\">\", attrsStart);\n if (nextGt === -1) break;\n }\n const attrs = html.slice(attrsStart, nextGt);\n const openEnd = nextGt + 1;\n if (!matches(attrs)) {\n from = attrsStart;\n continue;\n }\n if (!requireClose) {\n spans.push({ start, openEnd, end: openEnd, attrs });\n from = openEnd;\n continue;\n }\n if (nextClose < openEnd) {\n closeTag.lastIndex = openEnd;\n const close = closeTag.exec(html);\n if (!close) break;\n nextClose = close.index;\n }\n const end = nextClose + closeLength;\n spans.push({ start, openEnd, end, attrs });\n from = end;\n }\n return spans;\n}\n\n/** Replaces each matching element (opening tag through close tag) using `replace`. */\nexport function replaceTagSpans(\n html: string,\n tag: string,\n attrTest: RegExp | ((attrs: string) => boolean),\n replace: (match: string, attrs: string) => string,\n): string {\n const spans = findTagSpans(html, tag, attrTest, true);\n if (spans.length === 0) return html;\n let out = \"\";\n let last = 0;\n for (const span of spans) {\n out += html.slice(last, span.start) + replace(html.slice(span.start, span.end), span.attrs);\n last = span.end;\n }\n return out + html.slice(last);\n}\n\n/**\n * Replaces `<…>` tags in one pass. Same result as `.replace(/<[^>]+>/g, replacement)`,\n * which is quadratic when many `<` have no closing `>`: each one rescans to the\n * end. Once no `>` is left, the rest of the input is plain text.\n */\nexport function stripTags(html: string, replacement = \"\"): string {\n let out = \"\";\n let from = 0;\n for (;;) {\n const lt = html.indexOf(\"<\", from);\n if (lt === -1) break;\n const gt = html.indexOf(\">\", lt + 1);\n if (gt === -1) break;\n if (gt === lt + 1) {\n // \"<>\" is not a tag (the regex needs at least one character).\n out += html.slice(from, gt + 1);\n } else {\n out += html.slice(from, lt) + replacement;\n }\n from = gt + 1;\n }\n return out + html.slice(from);\n}\n\n/**\n * Removes (or replaces) regions that start with a match of `open` and end at the\n * next `close`, in one pass. Equivalent to `.replace(/<open>[\\s\\S]*?<close>/g, …)`\n * but linear: such a lazy regex rescans to the end of the input from every\n * unclosed opener. The next close position is cached until the scan passes it,\n * and scanning stops once no close is left. `open` must have the `g` flag.\n */\nexport function replaceDelimited(\n text: string,\n open: RegExp,\n close: string,\n replace: (match: string) => string = () => \"\",\n caseInsensitiveClose = false,\n): string {\n const haystack = caseInsensitiveClose ? asciiLower(text) : text;\n const needle = caseInsensitiveClose ? close.toLowerCase() : close;\n let out = \"\";\n let last = 0;\n let from = 0;\n let nextClose = -1;\n for (;;) {\n open.lastIndex = from;\n const opened = open.exec(text);\n if (!opened) break;\n const afterOpen = opened.index + Math.max(opened[0].length, 1);\n if (nextClose < afterOpen) {\n nextClose = haystack.indexOf(needle, afterOpen);\n if (nextClose === -1) break;\n }\n const end = nextClose + close.length;\n out += text.slice(last, opened.index) + replace(text.slice(opened.index, end));\n last = from = end;\n }\n return out + text.slice(last);\n}\n\n/** Lower-cases ASCII letters only, so indices match the original string. */\nexport function asciiLower(text: string): string {\n return text.replace(/[A-Z]+/g, (m) => m.toLowerCase());\n}\n","import { escapeHtml } from \"./plain-text\";\nimport {\n MENTION_REGEX,\n NODE_ROLE_MARK,\n formatMentionHandle,\n readRoleSuffix,\n type MentionRoleSyntax,\n} from \"./mention-text\";\n\nexport {\n MENTION_REGEX,\n findTextMentions,\n formatMentionText,\n setMentionRoleInText,\n type MentionRoleSyntax,\n type TextMention,\n} from \"./mention-text\";\nimport { asciiLower, findTagSpans, replaceDelimited, stripTags } from \"./html-scan\";\nimport type { MentionEntity } from \"../extensions/mention\";\n\n\n/**\n * Split regex identifying markdown code blocks, inline code, URLs, and existing HTML tags:\n * the regions preprocessMarkdownMentions leaves untouched. Kept as the reference definition;\n * preprocessMarkdownMentions uses {@link splitMarkdownMentionParts}, because this regex is\n * quadratic (lazy closers) and cubic (mention spans) on malformed input.\n */\nexport const MARKDOWN_MENTION_SPLIT_REGEX =\n /(```[\\s\\S]*?```|~~~[\\s\\S]*?~~~|<pre[\\s\\S]*?<\\/pre>|<code[\\s\\S]*?<\\/code>|`[^`\\n]+`|<span\\b[^>]*\\b(?:data-type=[\"']mention[\"']|class=[\"'][^\"']*pixerate-mention-node[^\"']*[\"']|data-mention=[\"'][^\"']*[\"'])[^>]*>[\\s\\S]*?<\\/span>|<[^>]+>|\\]\\([^)]+\\)|(?:https?|file|vscode|cursor|mailto):\\/\\/[^\\s<)]+)/gi;\n\n// The mention-span attribute test. Unlike the regex above, quoted values can't run past\n// the tag's `>`: a tag ends at its first `>` here, which keeps the scan linear.\nconst MENTION_SPAN_ATTRIBUTE =\n /\\b(?:data-type=[\"']mention[\"']|class=[\"'][^\"'>]*pixerate-mention-node[^\"'>]*[\"']|data-mention=[\"'][^\"'>]*[\"'])/gi;\nconst URL_SCHEMES = [\"https://\", \"http://\", \"file://\", \"vscode://\", \"cursor://\", \"mailto://\"];\nconst URL_STOP = /[\\s<)]/;\n\n/**\n * `text.split(MARKDOWN_MENTION_SPLIT_REGEX)` in linear time: alternating plain text and\n * protected parts (code fences, `<pre>` / `<code>`, inline code, mention spans, HTML tags,\n * markdown link targets, URLs), starting and ending with text (possibly empty). Each\n * closer is found through a cached \"next occurrence\" that only moves forward, so\n * unclosed fences or tags cost O(1) per position instead of a scan to the end.\n */\nexport function splitMarkdownMentionParts(text: string): string[] {\n const lower = asciiLower(text);\n const n = text.length;\n const cache = new Map<string, { from: number; at: number }>();\n /** First index ≥ from of needle in the lower-cased text, or -1. */\n const next = (needle: string, from: number) => {\n const cached = cache.get(needle);\n if (cached && cached.from <= from && (cached.at === -1 || cached.at >= from)) return cached.at;\n const at = lower.indexOf(needle, from);\n cache.set(needle, { from, at });\n return at;\n };\n let attrFrom = -1;\n let attrAt = -1;\n /** Start of the first mention attribute at or after from, or -1. */\n const nextAttribute = (from: number) => {\n if (attrFrom !== -1 && (attrAt === -1 || attrAt >= from) && attrFrom <= from) return attrAt;\n MENTION_SPAN_ATTRIBUTE.lastIndex = from;\n attrAt = MENTION_SPAN_ATTRIBUTE.exec(text)?.index ?? -1;\n attrFrom = from;\n return attrAt;\n };\n /** End (exclusive) of a protected part starting at i, or -1. */\n const matchAt = (i: number): number => {\n const c = text[i];\n if (c === \"`\" || c === \"~\") {\n const fence = c.repeat(3);\n if (text.startsWith(fence, i)) {\n const close = next(fence, i + 3);\n if (close !== -1) return close + 3;\n }\n if (c === \"`\") {\n const tick = next(\"`\", i + 1);\n const newline = next(\"\\n\", i + 1);\n if (tick > i + 1 && (newline === -1 || tick < newline)) return tick + 1;\n }\n return -1;\n }\n if (c === \"<\") {\n for (const tag of [\"pre\", \"code\"]) {\n if (lower.startsWith(`<${tag}`, i)) {\n const close = next(`</${tag}>`, i + tag.length + 1);\n if (close !== -1) return close + tag.length + 3;\n }\n }\n const gt = next(\">\", i + 1);\n if (lower.startsWith(\"<span\", i) && !/\\w/.test(text[i + 5] ?? \"\") && gt !== -1) {\n const attr = nextAttribute(i + 5);\n if (attr !== -1 && attr < gt) {\n const close = next(\"</span>\", gt + 1);\n if (close !== -1) return close + 7;\n }\n }\n return gt > i + 1 ? gt + 1 : -1;\n }\n if (c === \"]\") {\n if (text[i + 1] !== \"(\") return -1;\n const close = next(\")\", i + 2);\n return close > i + 2 ? close + 1 : -1;\n }\n for (const scheme of URL_SCHEMES) {\n if (!lower.startsWith(scheme, i)) continue;\n let end = i + scheme.length;\n while (end < n && !URL_STOP.test(text[end])) end++;\n return end > i + scheme.length ? end : -1;\n }\n return -1;\n };\n const parts: string[] = [];\n let last = 0;\n for (let i = 0; i < n; ) {\n const end = matchAt(i);\n if (end === -1) {\n i++;\n continue;\n }\n parts.push(text.slice(last, i), text.slice(i, end));\n last = i = end;\n }\n parts.push(text.slice(last));\n return parts;\n}\n\nexport interface MentionSegment {\n type: \"text\" | \"mention\";\n value: string;\n handle?: string;\n /** Role written after the handle (`@fox:style`), when role syntax is enabled. */\n role?: string;\n}\n\n\n/** A mention with its role (asset mentions: `@fox:style`, or `data-role` on a mention node). */\nexport interface MentionDetail {\n handle: string;\n role?: string;\n}\n\nexport interface ExtractMentionsOptions {\n /** Return `{ handle, role }` objects instead of handles. */\n details?: boolean;\n /** Read `@handle:role` suffixes in text (see {@link MentionRoleSyntax}). Mention nodes' `data-role` is always read in `details` mode. */\n roles?: MentionRoleSyntax;\n}\n\nexport interface PreprocessMarkdownMentionsOptions {\n /**\n * Known pool of mentionable entities (users, agents, teams, etc.).\n */\n mentionables?: MentionEntity[];\n /**\n * Default entity type assigned when a handle does not match any entry in mentionables.\n * Defaults to 'user'.\n */\n defaultType?: string;\n /**\n * Custom resolver callback to derive entity metadata for unmatched handles.\n */\n resolveMention?: (handle: string) => Partial<MentionEntity> | null | undefined;\n /**\n * Read `@handle:role` and emit the role as `data-role` (the `:role` text is\n * consumed). Off by default. See {@link MentionRoleSyntax}.\n */\n roles?: MentionRoleSyntax;\n}\n\n/**\n * Strips code blocks and inline code from markdown or HTML content:\n * - Fenced code blocks: ```...``` and ~~~...~~~\n * - Inline backtick code: `...`\n * - HTML code/pre tags: <pre>...</pre>, <code>...</code>\n * Used to avoid false-positive mention parsing and keyword analysis within code snippets, terminal logs, or stack traces.\n */\nexport function stripMarkdownCode(content: string): string {\n if (!content || typeof content !== \"string\") return \"\";\n // Linear scans instead of lazy `[\\s\\S]*?` regexes, which rescan to the end of the\n // input from every unclosed opener (see html-scan.ts).\n let text = replaceDelimited(content, /```/g, \"```\");\n text = replaceDelimited(text, /~~~/g, \"~~~\");\n text = replaceDelimited(text, /<pre/gi, \"</pre>\", undefined, true);\n text = replaceDelimited(text, /<code/gi, \"</code>\", undefined, true);\n return text.replace(/`[^`\\n]*`/g, \"\");\n}\n\n/** True for the attributes of a mention node: `data-type=\"mention\"` or the `pixerate-mention-node` class. */\nfunction isMentionNodeAttributes(attrs: string): boolean {\n if (/\\bdata-type=[\"']mention[\"']/i.test(attrs)) return true;\n const classAttr = /\\bclass=([\"'])/i.exec(attrs);\n if (!classAttr) return false;\n const valueStart = classAttr.index + classAttr[0].length;\n const valueEnd = attrs.indexOf(classAttr[1], valueStart);\n return valueEnd !== -1 && attrs.slice(valueStart, valueEnd).includes(\"pixerate-mention-node\");\n}\n\n/**\n * Extracts unique mention handles from a text, markdown, or HTML string,\n * ignoring trailing punctuation, code blocks, URLs, and pre-existing HTML mention attributes.\n *\n * With `{ details: true }` it returns `{ handle, role }` objects, unique per\n * handle and role: roles come from mention nodes' `data-role` and, when\n * `roles` is set, from `@handle:role` text. Without options the result is\n * unchanged.\n */\nexport function extractMentions(content: string, options?: ExtractMentionsOptions & { details?: false }): string[];\nexport function extractMentions(content: string, options: ExtractMentionsOptions & { details: true }): MentionDetail[];\nexport function extractMentions(content: string, options?: ExtractMentionsOptions): string[] | MentionDetail[];\nexport function extractMentions(content: string, options: ExtractMentionsOptions = {}): string[] | MentionDetail[] {\n if (!content || typeof content !== \"string\") return [];\n const details = options.details === true;\n\n // Normalize existing HTML mention nodes (e.g. from TipTap or rich text serializers)\n // so data-mention-suggestion-char=\"@\" does not trigger spurious quoted matches against attributes,\n // and ensure the actual mentioned label or ID is preserved cleanly.\n // A linear scan: the equivalent regex (`<span\\b[^>]*\\b(?:…)[^>]*>`) backtracks\n // cubically on malformed input without a `>` (see html-scan.ts).\n let normalizedMentionNodes = \"\";\n let last = 0;\n for (const span of findTagSpans(content, \"span\", isMentionNodeAttributes, true)) {\n const labelMatch = /\\bdata-label=[\"']([^\"']+)[\"']/i.exec(span.attrs);\n const idMatch = labelMatch ? null : /\\bdata-id=[\"']([^\"']+)[\"']/i.exec(span.attrs);\n const inner = content.slice(span.openEnd, span.end - \"</span>\".length);\n let replacement = labelMatch ? ` @${labelMatch[1]} ` : idMatch ? ` @${idMatch[1]} ` : ` ${inner} `;\n if (details && (labelMatch || idMatch)) {\n const roleMatch = /\\bdata-role=[\"']([^\"']+)[\"']/i.exec(span.attrs);\n const role = roleMatch && /^[A-Za-z](?:[A-Za-z0-9_-]*[A-Za-z0-9])?$/.test(roleMatch[1]) ? roleMatch[1] : null;\n const label = (labelMatch ?? idMatch)![1];\n replacement = ` ${formatMentionHandle(label)}${role ? NODE_ROLE_MARK + role : \"\"} `;\n }\n normalizedMentionNodes += content.slice(last, span.start) + replacement;\n last = span.end;\n }\n normalizedMentionNodes += content.slice(last);\n\n const cleanContent = stripMarkdownCode(normalizedMentionNodes);\n // Strip URLs and markdown link destinations so @package or @handles in URLs are not extracted as mentions\n const withoutUrls = cleanContent\n .replace(/(?:https?|ftp|file|vscode|cursor|mailto):\\/\\/[^\\s<>()]+/gi, \"\");\n // Markdown link destinations: `](…)` → `]` (linear; `/\\]\\([^)]*\\)/g` is quadratic\n // when many `](` have no `)`).\n const withoutLinks = replaceDelimited(withoutUrls, /\\]\\(/g, \")\", () => \"]\");\n // Strip remaining HTML tags so attributes containing '@' or '>' aren't treated as mention triggers\n const textOnly = stripTags(withoutLinks, \" \");\n\n const mentions: string[] = [];\n const detailed: MentionDetail[] = [];\n const seen = new Set<string>();\n\n const regex = new RegExp(MENTION_REGEX.source, \"g\");\n let match: RegExpExecArray | null;\n\n while ((match = regex.exec(textOnly)) !== null) {\n const handle = (match[1] ?? match[2] ?? match[3] ?? \"\").trim();\n if (details) {\n const suffix = readRoleSuffix(textOnly, regex.lastIndex, options.roles);\n if (suffix) regex.lastIndex = suffix.end;\n const key = `${handle}\\u0000${suffix?.role ?? \"\"}`;\n if (handle && !seen.has(key)) {\n seen.add(key);\n detailed.push(suffix ? { handle, role: suffix.role } : { handle });\n }\n continue;\n }\n if (handle && !seen.has(handle)) {\n seen.add(handle);\n mentions.push(handle);\n }\n }\n\n return details ? detailed : mentions;\n}\n\n/**\n * Segments a text string into plain text parts and mention tokens.\n * Correctly leaves trailing punctuation (like \".\") as part of the following text segment.\n */\nexport function parseMentionSegments(\n content: string,\n options: { roles?: MentionRoleSyntax } = {},\n): MentionSegment[] {\n if (!content) return [];\n\n const segments: MentionSegment[] = [];\n const regex = new RegExp(MENTION_REGEX.source, \"g\");\n let lastIndex = 0;\n let match: RegExpExecArray | null;\n\n while ((match = regex.exec(content)) !== null) {\n const fullMatch = match[0];\n const atIndex = fullMatch.indexOf(\"@\");\n const prefix = atIndex > 0 ? fullMatch.slice(0, atIndex) : \"\";\n let mentionToken = fullMatch.slice(atIndex);\n const handle = match[1] ?? match[2] ?? match[3];\n const matchStart = match.index + prefix.length;\n const suffix =\n options.roles && content.charAt(regex.lastIndex) === \":\"\n ? readRoleSuffix(content, regex.lastIndex, options.roles)\n : null;\n if (suffix) {\n mentionToken = content.slice(matchStart, suffix.end);\n regex.lastIndex = suffix.end;\n }\n\n if (matchStart > lastIndex) {\n segments.push({\n type: \"text\",\n value: content.slice(lastIndex, matchStart),\n });\n }\n\n segments.push({\n type: \"mention\",\n value: mentionToken,\n handle,\n ...(suffix ? { role: suffix.role } : {}),\n });\n\n lastIndex = matchStart + mentionToken.length;\n }\n\n if (lastIndex < content.length) {\n segments.push({\n type: \"text\",\n value: content.slice(lastIndex),\n });\n }\n\n return segments;\n}\n\n/**\n * Preprocesses markdown text by turning raw @mention handles into TipTap-compatible\n * mention HTML spans (<span class=\"pixerate-mention-node\" data-type=\"mention\" ...>),\n * ensuring code blocks, inline code, existing mention nodes, and URLs remain immune.\n */\nexport function preprocessMarkdownMentions(\n content: string,\n optionsOrMentionables: MentionEntity[] | PreprocessMarkdownMentionsOptions = []\n): string {\n if (!content || typeof content !== \"string\") return \"\";\n\n const options: PreprocessMarkdownMentionsOptions = Array.isArray(optionsOrMentionables)\n ? { mentionables: optionsOrMentionables }\n : optionsOrMentionables;\n\n const allMentionables = options.mentionables || [];\n const defaultType = options.defaultType || \"user\";\n const resolveMention = options.resolveMention;\n\n const parts = splitMarkdownMentionParts(content);\n\n return parts\n .map((part) => {\n if (!part) return \"\";\n\n // Preserve code fences, code tags, inline backticks, existing mention spans,\n // HTML tags, markdown link targets, and raw URLs untouched.\n if (\n part.startsWith(\"```\") ||\n part.startsWith(\"~~~\") ||\n part.startsWith(\"`\") ||\n part.startsWith(\"](\") ||\n /^(?:https?|file|vscode|cursor|mailto):\\/\\//i.test(part) ||\n /^<pre[\\s>]/i.test(part) ||\n /^<code[\\s>]/i.test(part) ||\n /^<[^>]+>$/i.test(part) ||\n /^<span\\b[^>]*\\b(?:data-type=[\"']mention[\"']|class=[\"'][^\"']*pixerate-mention-node[^\"']*[\"']|data-mention=[\"'][^\"']*[\"'])/i.test(\n part\n )\n ) {\n return part;\n }\n\n const regex = new RegExp(MENTION_REGEX.source, \"g\");\n const render = (\n match: string,\n quotedHandle: string | undefined,\n escapedQuotedHandle: string | undefined,\n standardHandle: string | undefined,\n role?: string,\n ): string => {\n const atIndex = match.indexOf(\"@\");\n const prefix = atIndex > 0 ? match.slice(0, atIndex) : \"\";\n const rawHandle = (quotedHandle || escapedQuotedHandle || standardHandle || \"\").trim();\n if (!rawHandle) return match;\n\n const lowerHandle = rawHandle.toLowerCase();\n const entity = allMentionables.find((e) => {\n if (e.label?.toLowerCase() === lowerHandle) return true;\n if (e.handle?.toLowerCase() === lowerHandle) return true;\n if (e.name?.toLowerCase() === lowerHandle) return true;\n if (e.id?.toLowerCase() === lowerHandle) return true;\n if (e.type === \"agent\" && `agent${(e.handle || e.label || \"\").toLowerCase()}` === lowerHandle) return true;\n if (\n e.aliases?.some(\n (a: string) =>\n a.toLowerCase() === lowerHandle ||\n (e.type === \"agent\" && `agent${a.toLowerCase()}` === lowerHandle)\n )\n ) {\n return true;\n }\n return false;\n });\n\n let id = entity?.id;\n let label = entity?.label || entity?.handle || rawHandle;\n let type = entity?.type;\n let avatarUrl = entity?.avatarUrl;\n let color = entity?.color || entity?.hexColor;\n\n if (!entity) {\n const customResolved = resolveMention?.(rawHandle);\n if (customResolved) {\n id = customResolved.id ?? id;\n label = customResolved.label ?? customResolved.handle ?? label;\n type = customResolved.type ?? type;\n avatarUrl = customResolved.avatarUrl ?? avatarUrl;\n color = customResolved.color ?? customResolved.hexColor ?? color;\n } else {\n const stripped = lowerHandle.replace(/^agent[\\s\\-_]*/i, \"\");\n if (\n [\"supervisor\", \"coordinator\", \"planner\", \"validator\", \"executor\"].includes(stripped)\n ) {\n type = \"agent\";\n id = stripped;\n label = stripped;\n } else if (lowerHandle === \"agents\") {\n type = \"team\";\n id = \"agents\";\n label = \"agents\";\n } else {\n type = defaultType;\n id = rawHandle;\n label = rawHandle;\n }\n }\n }\n\n const avatarAttr = avatarUrl ? ` data-avatar-url=\"${escapeHtml(avatarUrl)}\"` : \"\";\n const colorAttr = color ? ` data-color=\"${escapeHtml(color)}\"` : \"\";\n\n return `${prefix}<span class=\"pixerate-mention-node\" data-type=\"mention\" data-id=\"${escapeHtml(\n id || label\n )}\" data-label=\"${escapeHtml(label)}\" data-mention-suggestion-char=\"@\" data-type-name=\"${escapeHtml(\n type || defaultType\n )}\"${avatarAttr}${colorAttr}${role ? ` data-role=\"${escapeHtml(role)}\"` : \"\"}>@${escapeHtml(label)}</span>`;\n };\n if (!options.roles) {\n return part.replace(regex, (match, quotedHandle, escapedQuotedHandle, standardHandle) =>\n render(match, quotedHandle, escapedQuotedHandle, standardHandle),\n );\n }\n // Role syntax: consume a `:role` suffix after each mention.\n let out = \"\";\n let last = 0;\n let match: RegExpExecArray | null;\n while ((match = regex.exec(part)) !== null) {\n const suffix = readRoleSuffix(part, regex.lastIndex, options.roles);\n const rendered = render(match[0], match[1], match[2], match[3], suffix?.role);\n if (suffix && rendered !== match[0]) regex.lastIndex = suffix.end;\n out += part.slice(last, match.index) + rendered;\n last = regex.lastIndex;\n }\n return out + part.slice(last);\n })\n .join(\"\");\n}\n","import MarkdownIt from \"markdown-it\";\nimport taskLists from \"markdown-it-task-lists\";\nimport { escapeHtml, getEditorText, type PlainTextOptions } from \"./plain-text\";\nimport { resolveTrackedChanges } from \"../extensions/track-changes\";\n\nconst md = new MarkdownIt({\n html: true,\n linkify: true,\n breaks: true,\n}).use(taskLists);\n\nconst defaultValidateLink = md.validateLink;\nmd.validateLink = (url: string) => {\n if (\n url.startsWith(\"file://\") ||\n url.startsWith(\"vscode://\") ||\n url.startsWith(\"cursor://\")\n ) {\n return true;\n }\n return defaultValidateLink.call(md, url);\n};\n\n/**\n * Tags allowed through from raw HTML embedded in markdown (e.g. mention spans\n * and file links that tiptap-markdown serializes as HTML). Anything else is\n * rendered as escaped text. `input` is limited to checkboxes, which\n * markdown-it-task-lists emits as raw HTML.\n */\nconst ALLOWED_HTML_TAGS = new Set([\n \"a\", \"abbr\", \"b\", \"blockquote\", \"br\", \"code\", \"col\", \"colgroup\", \"del\", \"details\", \"div\", \"em\",\n \"h1\", \"h2\", \"h3\", \"h4\", \"h5\", \"h6\", \"hr\", \"i\", \"img\", \"input\", \"ins\", \"kbd\", \"li\", \"mark\",\n \"ol\", \"p\", \"pre\", \"s\", \"span\", \"strong\", \"sub\", \"summary\", \"sup\", \"table\",\n \"tbody\", \"td\", \"tfoot\", \"th\", \"thead\", \"tr\", \"u\", \"ul\",\n]);\n\nconst ALLOWED_HTML_ATTRS = new Set([\n \"alt\", \"align\", \"checked\", \"class\", \"colspan\", \"colwidth\", \"disabled\", \"height\", \"href\",\n \"rel\", \"rowspan\", \"src\", \"start\", \"target\", \"title\", \"type\", \"width\",\n]);\n\nconst HTML_TAG_REGEX =\n /<(\\/?)([a-zA-Z][a-zA-Z0-9-]*)((?:\\s+[^\\s\"'>\\/=]+(?:\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^\\s\"'=<>`]+))?)*)\\s*\\/?>/g;\nconst HTML_ATTR_REGEX =\n /([^\\s\"'>\\/=]+)(?:\\s*=\\s*(?:\"([^\"]*)\"|'([^']*)'|([^\\s\"'=<>`]+)))?/g;\n\nfunction sanitizeTag(\n tagText: string,\n isClosing: string,\n rawTagName: string,\n rawAttrs: string,\n stripDisallowed: boolean,\n): string {\n const tagName = rawTagName.toLowerCase();\n const reject = () => (stripDisallowed ? \"\" : escapeHtml(tagText));\n if (!ALLOWED_HTML_TAGS.has(tagName)) return reject();\n if (isClosing) return `</${tagName}>`;\n if (tagName === \"input\" && !/\\stype\\s*=\\s*[\"']?checkbox[\"']?[\\s>/]/i.test(tagText)) {\n return reject();\n }\n\n let attrs = \"\";\n let attrMatch: RegExpExecArray | null;\n HTML_ATTR_REGEX.lastIndex = 0;\n while ((attrMatch = HTML_ATTR_REGEX.exec(rawAttrs)) !== null) {\n const name = attrMatch[1].toLowerCase();\n if (!ALLOWED_HTML_ATTRS.has(name) && !/^data-[a-z0-9_.-]+$/.test(name)) {\n continue;\n }\n const rawValue = attrMatch[2] ?? attrMatch[3] ?? attrMatch[4];\n if (rawValue === undefined) {\n attrs += ` ${name}`;\n continue;\n }\n const value = md.utils.unescapeAll(rawValue);\n if (\n (name === \"href\" || name === \"src\") &&\n // Browsers ignore control characters and whitespace inside schemes.\n !md.validateLink(value.replace(/[\\u0000-\\u0020\\u007f]/g, \"\"))\n ) {\n continue;\n }\n attrs += ` ${name}=\"${escapeHtml(value)}\"`;\n }\n return `<${tagName}${attrs}>`;\n}\n\nexport interface SanitizeHtmlOptions {\n /**\n * What to do with tags outside the allowlist: `escape` (default) renders\n * them as literal text, `strip` removes the tag but keeps its text content.\n */\n disallowedTags?: \"escape\" | \"strip\";\n}\n\n/**\n * Sanitizes raw HTML with the same allowlist the markdown renderer applies to\n * embedded HTML: event handlers, `style` and unsafe URL schemes are dropped,\n * and disallowed tags are escaped (or removed with `disallowedTags: \"strip\"`).\n * It is string-based, so it works without a DOM and never runs handlers.\n */\nexport function sanitizeHtml(html: string, options: SanitizeHtmlOptions = {}): string {\n return sanitizeEmbeddedHtml(html, options.disallowedTags === \"strip\");\n}\n\nfunction sanitizeEmbeddedHtml(html: string, stripDisallowed = false): string {\n let result = \"\";\n let lastIndex = 0;\n let match: RegExpExecArray | null;\n HTML_TAG_REGEX.lastIndex = 0;\n while ((match = HTML_TAG_REGEX.exec(html)) !== null) {\n result += html.slice(lastIndex, match.index).replace(/</g, \"<\");\n result += sanitizeTag(match[0], match[1], match[2], match[3], stripDisallowed);\n lastIndex = match.index + match[0].length;\n }\n return result + html.slice(lastIndex).replace(/</g, \"<\");\n}\n\nconst defaultHtmlInline = md.renderer.rules.html_inline;\nconst defaultHtmlBlock = md.renderer.rules.html_block;\nmd.renderer.rules.html_inline = (tokens, idx, options, env, self) =>\n env?.allowUnsafeHtml\n ? defaultHtmlInline!(tokens, idx, options, env, self)\n : sanitizeEmbeddedHtml(tokens[idx].content);\nmd.renderer.rules.html_block = (tokens, idx, options, env, self) =>\n env?.allowUnsafeHtml\n ? defaultHtmlBlock!(tokens, idx, options, env, self)\n : sanitizeEmbeddedHtml(tokens[idx].content);\n\nimport {\n preprocessMarkdownMentions,\n type PreprocessMarkdownMentionsOptions,\n} from \"./mentions\";\nimport type { MentionEntity } from \"../extensions/mention\";\n\n/**\n * Preprocesses file-protocol and editor-protocol links in markdown content:\n * converts [label](file://...), vscode://, and cursor:// links into anchor tags\n * annotated with data-file-link=\"true\", preserving code backticks in labels.\n */\nexport function preprocessMarkdownFileLinks(content: string): string {\n if (!content) return \"\";\n return content.replace(\n /\\[([^\\]]+)\\]\\(((?:file|vscode|cursor):\\/\\/[^)]+)\\)/g,\n (_match, rawLabel, href) => {\n const trimmed = rawLabel.trim();\n const codeMatch = trimmed.match(/^`([^`]+)`$/);\n const labelContent = codeMatch\n ? `<code>${escapeHtml(codeMatch[1])}</code>`\n : escapeHtml(trimmed);\n return `<a href=\"${escapeHtml(href)}\" data-file-link=\"true\" title=\"Click to copy file path\">${labelContent}</a>`;\n }\n );\n}\n\nexport interface MarkdownToHtmlOptions {\n /**\n * Preprocess file, vscode, and cursor links into clickable data-file-link tags.\n */\n preprocessFileLinks?: boolean;\n /**\n * Whether to preprocess @mentions into TipTap mention node HTML spans.\n */\n preprocessMentions?: boolean;\n /**\n * Pool of mentionables to pass to preprocessMarkdownMentions.\n */\n mentionables?: MentionEntity[];\n /**\n * Full options for preprocessMarkdownMentions.\n */\n preprocessOptions?: PreprocessMarkdownMentionsOptions;\n /**\n * Render raw HTML embedded in the markdown without sanitizing it. By default,\n * embedded HTML is restricted to an allowlist of tags and attributes (event\n * handlers, `style` and unsafe URL schemes are removed). Only enable this for\n * fully trusted input.\n */\n allowUnsafeHtml?: boolean;\n}\n\n/**\n * Converts a markdown string into HTML suitable for TipTap initial content or setContent.\n * Raw HTML embedded in the markdown is sanitized unless `allowUnsafeHtml` is set.\n */\nexport function markdownToTipTapHtml(\n markdown: string,\n options?: MarkdownToHtmlOptions\n): string {\n if (!markdown) return \"<p></p>\";\n let content = markdown;\n if (options?.preprocessFileLinks) {\n content = preprocessMarkdownFileLinks(content);\n }\n if (\n options?.preprocessMentions ||\n options?.mentionables ||\n options?.preprocessOptions\n ) {\n const mentionOpts = options.preprocessOptions || {\n mentionables: options.mentionables,\n };\n content = preprocessMarkdownMentions(content, mentionOpts);\n }\n return md.render(content, { allowUnsafeHtml: options?.allowUnsafeHtml });\n}\n\n/**\n * Extracts clean markdown from a TipTap editor instance.\n * If the editor has the Markdown extension configured, it uses editor.storage.markdown.getMarkdown().\n * Otherwise, it falls back to getEditorText(editor).\n * Tracked changes are exported as accepted unless `options.trackedChanges`\n * says otherwise (`\"all\"` renders deletions as `~~strikethrough~~`).\n */\nexport function getEditorMarkdown(editor: any, options: PlainTextOptions = {}): string {\n if (!editor) return \"\";\n const markdown = editor.storage?.markdown;\n if (typeof markdown?.getMarkdown === \"function\") {\n const doc = editor.state?.doc;\n if (doc && typeof markdown.serializer?.serialize === \"function\") {\n const resolved = resolveTrackedChanges(doc, options.trackedChanges ?? \"accepted\");\n if (resolved !== doc) return markdown.serializer.serialize(resolved);\n }\n return markdown.getMarkdown();\n }\n return getEditorText(editor, options);\n}\n"]}
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
rtfToPlainText,
|
|
24
24
|
sanitizeImportedHtml,
|
|
25
25
|
serializeRichClipboardPayload
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-WON34HKM.js";
|
|
27
27
|
import {
|
|
28
28
|
MAX_TABLE_COLUMNS,
|
|
29
29
|
MAX_TABLE_ROWS,
|
|
@@ -31,14 +31,18 @@ import {
|
|
|
31
31
|
createTableExtensions,
|
|
32
32
|
getTableActionState,
|
|
33
33
|
getTableState,
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
handleTablePasteWithoutNesting,
|
|
35
|
+
insertSliceAfterTable,
|
|
36
|
+
outermostTableDepth,
|
|
37
|
+
runTableAction,
|
|
38
|
+
sliceContainsTable
|
|
39
|
+
} from "./chunk-5H2OPMXZ.js";
|
|
36
40
|
import {
|
|
37
41
|
escapeHtml,
|
|
38
42
|
htmlToPlainText,
|
|
39
43
|
markdownToTipTapHtml,
|
|
40
44
|
plainTextToSlice
|
|
41
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-UKI64KUD.js";
|
|
42
46
|
import {
|
|
43
47
|
CommentStore,
|
|
44
48
|
TRACK_CHANGES_SKIP_META,
|
|
@@ -3574,6 +3578,15 @@ function insertImportedDocument(target, content, options = {}) {
|
|
|
3574
3578
|
if (!htmlSlice && from === to && !state.doc.resolve(from).parent.inlineContent) {
|
|
3575
3579
|
from = to = Selection.near(state.doc.resolve(from)).from;
|
|
3576
3580
|
}
|
|
3581
|
+
if (htmlSlice && sliceContainsTable(htmlSlice) && outermostTableDepth(state.doc.resolve(from)) >= 0) {
|
|
3582
|
+
const tr2 = state.tr;
|
|
3583
|
+
const end2 = insertSliceAfterTable(tr2, from, to, htmlSlice);
|
|
3584
|
+
if (end2 !== null) {
|
|
3585
|
+
if (options.at === void 0) tr2.setSelection(Selection.near(tr2.doc.resolve(end2), -1));
|
|
3586
|
+
view.dispatch(tr2.scrollIntoView().setMeta("uiEvent", "drop"));
|
|
3587
|
+
return end2;
|
|
3588
|
+
}
|
|
3589
|
+
}
|
|
3577
3590
|
const tr = htmlSlice ? state.tr.replaceRange(from, to, htmlSlice) : state.tr.replace(from, to, plainTextToSlice(content.text, state.schema));
|
|
3578
3591
|
const end = tr.mapping.map(to, 1);
|
|
3579
3592
|
view.dispatch(tr.scrollIntoView().setMeta("uiEvent", "drop"));
|
|
@@ -3744,6 +3757,7 @@ var RichClipboard = Extension9.create({
|
|
|
3744
3757
|
const slice = readRichClipboard(event, view.state.schema, mimeType);
|
|
3745
3758
|
if (!slice) return false;
|
|
3746
3759
|
event.preventDefault();
|
|
3760
|
+
if (handleTablePasteWithoutNesting(view, event, slice)) return true;
|
|
3747
3761
|
view.dispatch(
|
|
3748
3762
|
view.state.tr.replaceSelection(slice).scrollIntoView().setMeta("paste", true).setMeta("uiEvent", "paste")
|
|
3749
3763
|
);
|
|
@@ -7637,4 +7651,4 @@ export {
|
|
|
7637
7651
|
validateFindPattern,
|
|
7638
7652
|
createTableCommands
|
|
7639
7653
|
};
|
|
7640
|
-
//# sourceMappingURL=chunk-
|
|
7654
|
+
//# sourceMappingURL=chunk-6IO7WUSU.js.map
|