@pixerate/editor 0.2.3 → 0.3.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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/extensions/gradient-text.ts","../../src/grammar/tokens.ts","../../src/extensions/slash-commands.ts","../../src/extensions/template-suggestions.ts","../../src/extensions/loading-node.ts","../../src/extensions/SmilieReplacer.ts","../../src/extensions/ColorHighlighter.ts","../../src/extensions/FontSize.ts","../../src/extensions/rich-text-preset.ts"],"sourcesContent":["import { Mark } from \"@tiptap/core\";\nimport { Plugin } from \"@tiptap/pm/state\";\nimport { Decoration, DecorationSet } from \"@tiptap/pm/view\";\nimport type { Node as ProsemirrorNode } from \"@tiptap/pm/model\";\nimport type { EditorState } from \"@tiptap/pm/state\";\nimport { TEMPLATE_REGEX, VARIABLE_REGEX, INSTRUCTION_REGEX, ColorGradient } from \"../grammar/tokens\";\n\nexport interface GradientTextOptions {\n templateColorMap: Map<string, ColorGradient>;\n speed?: number;\n jsonVariables?: string[] | Set<string>;\n onTemplateClick?: (templateName: string, event: MouseEvent) => void;\n}\n\nconst createGradientDecorations = (\n doc: ProsemirrorNode,\n options: GradientTextOptions,\n): Decoration[] => {\n const decorations: Decoration[] = [];\n const speed = options.speed ?? 1;\n const jsonVarSet = options.jsonVariables\n ? options.jsonVariables instanceof Set\n ? options.jsonVariables\n : new Set(options.jsonVariables)\n : null;\n\n doc.descendants((node, pos) => {\n if (node.isText) {\n const text = node.text || \"\";\n let match: RegExpExecArray | null;\n\n // 1. Template: {{templateName}}\n const tmplRegex = new RegExp(TEMPLATE_REGEX.source, TEMPLATE_REGEX.flags);\n while ((match = tmplRegex.exec(text)) !== null) {\n const templateName = match[1].trim();\n const colors = options.templateColorMap?.get(templateName);\n\n if (colors) {\n const start = pos + match.index;\n const end = start + match[0].length;\n const { from: colorFrom, to: colorTo } = colors;\n\n const style = `--bg-size: ${\n speed * 300\n }%; --color-from: ${colorFrom}; --color-to: ${colorTo}; caret-color: #111 !important;`;\n\n decorations.push(\n Decoration.inline(start, end, {\n class:\n \"inline animate-gradient bg-gradient-to-r from-[var(--color-from)] via-[var(--color-to)] to-[var(--color-from)] bg-[length:var(--bg-size)_100%] bg-clip-text text-transparent border border-(--color-to)/20 px-1 py-0.5 rounded-sm cursor-pointer\",\n style,\n \"data-template\": templateName,\n }),\n );\n }\n }\n\n // 2. Instruction: __text__\n const instRegex = new RegExp(\n INSTRUCTION_REGEX.source,\n INSTRUCTION_REGEX.flags,\n );\n while ((match = instRegex.exec(text)) !== null) {\n const content = match[1].trim();\n const colors = options.templateColorMap?.get(content) || {\n from: \"#ffaa40\",\n to: \"#9c40ff\",\n };\n\n const start = pos + match.index;\n const end = start + match[0].length;\n const { from: colorFrom, to: colorTo } = colors;\n\n const style = `--bg-size: ${\n speed * 300\n }%; --color-from: ${colorFrom}; --color-to: ${colorTo}; caret-color: #111 !important;`;\n\n decorations.push(\n Decoration.inline(start, end, {\n class:\n \"italic animate-gradient bg-gradient-to-r from-rose-400 from-50% to-violet-500 to-50% bg-size-[200%_100%] bg-clip-text text-transparent inline-flex items-baseline gap-0.5\",\n style,\n }),\n );\n }\n\n // 3. Variable: {variableName}\n const varRegex = new RegExp(\n VARIABLE_REGEX.source,\n VARIABLE_REGEX.flags,\n );\n while ((match = varRegex.exec(text)) !== null) {\n const variableName = match[1].trim();\n const start = pos + match.index;\n const end = start + match[0].length;\n const isJsonVar = jsonVarSet?.has(variableName);\n\n decorations.push(\n Decoration.inline(start, end, {\n class: isJsonVar\n ? \"bg-violet-400/40 border-b-4 border-rose-300 dark:border-rose-800 inline-flex items-baseline px-1 py-0 text-foreground/80 gap-0.5 rounded-xs\"\n : \"bg-rose-400/40 border-b-4 border-violet-300 dark:border-violet-800 inline-flex items-baseline px-1 py-0 text-foreground/80 gap-0.5 rounded-xs\",\n \"data-variable\": variableName,\n }),\n );\n }\n }\n });\n\n return decorations;\n};\n\nexport const GradientText = Mark.create<GradientTextOptions>({\n name: \"gradientText\",\n\n addOptions() {\n return {\n templateColorMap: new Map(),\n speed: 1,\n jsonVariables: undefined,\n onTemplateClick: undefined,\n };\n },\n\n renderHTML({ HTMLAttributes }) {\n const defaultColors = {\n from: \"#ffaa40\",\n to: \"#9c40ff\",\n };\n const speed = this.options.speed ?? 1;\n const style = `--bg-size: ${speed * 300}%; --color-from: ${\n defaultColors.from\n }; --color-to: ${defaultColors.to}; caret-color: #111 !important;`;\n\n return [\n \"span\",\n {\n class:\n \"inline animate-gradient bg-gradient-to-r from-[var(--color-from)] via-[var(--color-to)] to-[var(--color-from)] bg-[length:var(--bg-size)_100%] bg-clip-text text-transparent\",\n style,\n ...HTMLAttributes,\n },\n 0,\n ];\n },\n\n parseHTML() {\n return [\n {\n tag: \"span\",\n getAttrs: (node) =>\n (node as HTMLElement).classList.contains(\"animate-gradient\") &&\n (node as HTMLElement).classList.contains(\"bg-clip-text\") &&\n null,\n },\n ];\n },\n\n addProseMirrorPlugins() {\n const markOptions = this.options;\n\n return [\n new Plugin({\n state: {\n init(_, { doc }) {\n return DecorationSet.create(\n doc,\n createGradientDecorations(doc, markOptions),\n );\n },\n apply(tr, value: DecorationSet) {\n const newDoc = tr.doc;\n if (tr.docChanged) {\n return DecorationSet.create(\n newDoc,\n createGradientDecorations(newDoc, markOptions),\n );\n }\n return value.map(tr.mapping, newDoc);\n },\n },\n props: {\n decorations(state: EditorState) {\n return (this as any).getState(state) as DecorationSet;\n },\n handleClickOn(view, pos, _node, _nodePos, event) {\n const decorationSet = (this as any).getState(\n view.state,\n ) as DecorationSet;\n const decorations = decorationSet.find(pos, pos + 1);\n\n for (const decoration of decorations) {\n const decorationWithAttrs = decoration as any;\n const templateName =\n decorationWithAttrs.type?.attrs?.[\"data-template\"];\n if (templateName) {\n if (markOptions.onTemplateClick) {\n markOptions.onTemplateClick(templateName, event as MouseEvent);\n }\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(\n new CustomEvent(\"show-gradient-popover\", {\n detail: {\n templateName,\n target: event.target,\n },\n }),\n );\n }\n return true;\n }\n }\n return false;\n },\n },\n }),\n ];\n },\n});\n","/**\n * Canonical regex patterns for prompt editing tokens.\n */\nexport const TEMPLATE_REGEX = /{{\\s*([^}]+?)\\s*}}/g;\nexport const VARIABLE_REGEX = /(?<!\\{)\\{([^{}]+)\\}(?!\\})/g;\nexport const INSTRUCTION_REGEX = /__(.+?)__/g;\n\n// Backward-compatible camelCase aliases\nexport const templateRegex = TEMPLATE_REGEX;\nexport const variableRegex = VARIABLE_REGEX;\nexport const instructionRegex = INSTRUCTION_REGEX;\n\nexport type TokenType = \"template\" | \"variable\" | \"instruction\" | \"text\";\n\nexport interface Token {\n type: TokenType;\n raw: string;\n value: string;\n start: number;\n end: number;\n}\n\nexport interface TemplateVersion {\n id: string;\n version: string | number;\n body: string;\n createdAt?: any;\n [key: string]: any;\n}\n\nexport interface Template {\n id?: string;\n name: string;\n body?: string;\n latestVersion?: string | number;\n versions?: TemplateVersion[];\n color?: string;\n [key: string]: any;\n}\n\nexport interface ColorGradient {\n from: string;\n to: string;\n}\n","import { Extension } from \"@tiptap/core\";\nimport { Plugin } from \"@tiptap/pm/state\";\n\nexport interface SlashCommandMatchData {\n match: RegExpMatchArray;\n query: string;\n from: number;\n to: number;\n coords: { top: number; left: number; bottom: number; right: number };\n}\n\nexport interface SlashCommandsOptions {\n trigger?: string;\n onMatch?: (data: SlashCommandMatchData) => void;\n onClear?: () => void;\n containerId?: string;\n}\n\nexport const SlashCommands = Extension.create<SlashCommandsOptions>({\n name: \"slashCommands\",\n\n addOptions() {\n return {\n trigger: \"/\",\n onMatch: undefined,\n onClear: undefined,\n containerId: undefined,\n };\n },\n\n addProseMirrorPlugins() {\n const opts = this.options;\n\n return [\n new Plugin({\n view() {\n return {\n update(view) {\n const { state } = view;\n const { selection } = state;\n const { $from } = selection;\n\n if (!$from.parent.isTextblock) {\n opts.onClear?.();\n return;\n }\n\n const textBeforeCursor = $from.parent.textBetween(\n 0,\n $from.parentOffset,\n );\n\n const slashMatch = textBeforeCursor.match(\n /(?:^|\\s)\\/([a-zA-Z0-9_-]*)$/,\n );\n\n if (slashMatch) {\n const matchIndex = slashMatch.index ?? 0;\n const offsetInParent =\n matchIndex + (slashMatch[0].startsWith(\" \") ? 1 : 0);\n const matchFrom = $from.start() + offsetInParent;\n const matchTo = $from.pos;\n const coords = view.coordsAtPos($from.pos);\n\n let relativeCoords = {\n top: coords.top,\n left: coords.left,\n bottom: coords.bottom,\n right: coords.right,\n };\n\n if (opts.containerId && typeof document !== \"undefined\") {\n const container = document.getElementById(opts.containerId);\n if (container) {\n const rect = container.getBoundingClientRect();\n relativeCoords = {\n top: coords.bottom - rect.top + 5,\n left: coords.left - rect.left,\n bottom: coords.bottom - rect.top,\n right: coords.right - rect.left,\n };\n }\n }\n\n opts.onMatch?.({\n match: slashMatch,\n query: slashMatch[1] || \"\",\n from: matchFrom,\n to: matchTo,\n coords: relativeCoords,\n });\n } else {\n opts.onClear?.();\n }\n },\n };\n },\n }),\n ];\n },\n});\n","import { Extension } from \"@tiptap/core\";\nimport Suggestion, { SuggestionOptions } from \"@tiptap/suggestion\";\nimport { Template } from \"../grammar/tokens\";\n\nexport interface TemplateSuggestionsOptions {\n templates: Template[];\n char?: string;\n onSuggestion?: (props: {\n query: string;\n range: { from: number; to: number };\n clientRect?: (() => DOMRect | null) | null;\n items: Template[];\n command: (props: { name: string }) => void;\n }) => void;\n}\n\nexport const TemplateSuggestions = Extension.create<TemplateSuggestionsOptions>({\n name: \"templateSuggestions\",\n\n addOptions() {\n return {\n templates: [],\n char: \"{{\",\n onSuggestion: undefined,\n };\n },\n\n addProseMirrorPlugins() {\n const opts = this.options;\n\n const suggestionConfig: Omit<SuggestionOptions<Template>, \"editor\"> = {\n char: opts.char || \"{{\",\n items: ({ query }) => {\n const lower = query.toLowerCase();\n return (opts.templates || []).filter((t) =>\n t.name.toLowerCase().includes(lower),\n );\n },\n command: ({ editor, range, props }) => {\n editor\n .chain()\n .focus()\n .deleteRange(range)\n .insertContent(`{{${props.name}}}`)\n .run();\n },\n render: () => {\n return {\n onStart: (props) => {\n opts.onSuggestion?.(props as any);\n },\n onUpdate: (props) => {\n opts.onSuggestion?.(props as any);\n },\n onExit: () => {\n opts.onSuggestion?.({\n query: \"\",\n range: { from: 0, to: 0 },\n items: [],\n command: () => {},\n });\n },\n };\n },\n };\n\n const SuggestionFn =\n typeof Suggestion === \"function\"\n ? Suggestion\n : (Suggestion as any)?.default || (Suggestion as any)?.Suggestion;\n\n return [\n SuggestionFn({\n editor: this.editor,\n ...suggestionConfig,\n }),\n ];\n },\n});\n","import { Node, mergeAttributes } from \"@tiptap/core\";\n\nexport const LoadingNode = Node.create({\n name: \"loadingNode\",\n group: \"inline\",\n inline: true,\n selectable: true,\n atom: true,\n\n addAttributes() {\n return {\n id: {\n default: null,\n parseHTML: (element) => element.getAttribute(\"data-id\"),\n renderHTML: (attributes) => {\n if (!attributes.id) return {};\n return { \"data-id\": attributes.id };\n },\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: 'span[data-type=\"loading\"]',\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\n \"span\",\n mergeAttributes(HTMLAttributes, {\n \"data-type\": \"loading\",\n class: \"inline-flex items-center px-1.5 py-0.5 text-xs text-muted-foreground animate-pulse\",\n }),\n \"⏳\",\n ];\n },\n});\n","import { Extension, textInputRule } from \"@tiptap/core\";\n\nexport const SmilieReplacer = Extension.create({\n name: \"smilieReplacer\",\n\n addInputRules() {\n return [\n textInputRule({ find: /-___- $/, replace: \"😑 \" }),\n textInputRule({ find: /:'-\\) $/, replace: \"😂 \" }),\n textInputRule({ find: /':-\\) $/, replace: \"😅 \" }),\n textInputRule({ find: /':-D $/, replace: \"😅 \" }),\n textInputRule({ find: />:-\\) $/, replace: \"😆 \" }),\n textInputRule({ find: /-__- $/, replace: \"😑 \" }),\n textInputRule({ find: /':-\\( $/, replace: \"😓 \" }),\n textInputRule({ find: /:'-\\( $/, replace: \"😢 \" }),\n textInputRule({ find: />:-\\( $/, replace: \"😠 \" }),\n textInputRule({ find: /O:-\\) $/, replace: \"😇 \" }),\n textInputRule({ find: /:'\\) $/, replace: \"😂 \" }),\n textInputRule({ find: /:-D $/, replace: \"😃 \" }),\n textInputRule({ find: /':\\) $/, replace: \"😅 \" }),\n textInputRule({ find: /;-\\) $/, replace: \"😉 \" }),\n textInputRule({ find: /B-\\) $/, replace: \"😎 \" }),\n textInputRule({ find: /:-\\* $/, replace: \"😘 \" }),\n textInputRule({ find: /:-\\) $/, replace: \"🙂 \" }),\n textInputRule({ find: /-_- $/, replace: \"😑 \" }),\n textInputRule({ find: /:-O $/, replace: \"😮 \" }),\n textInputRule({ find: /:-P $/, replace: \"😛 \" }),\n textInputRule({ find: /:-p $/, replace: \"😛 \" }),\n textInputRule({ find: /:-\\/ $/, replace: \"😕 \" }),\n textInputRule({ find: /:-\\( $/, replace: \"😞 \" }),\n textInputRule({ find: /:'\\( $/, replace: \"😢 \" }),\n textInputRule({ find: /:D $/, replace: \"😃 \" }),\n textInputRule({ find: /=D $/, replace: \"😃 \" }),\n textInputRule({ find: /;\\) $/, replace: \"😉 \" }),\n textInputRule({ find: /B\\) $/, replace: \"😎 \" }),\n textInputRule({ find: /:\\) $/, replace: \"🙂 \" }),\n textInputRule({ find: /=\\) $/, replace: \"🙂 \" }),\n textInputRule({ find: /:O $/, replace: \"😮 \" }),\n textInputRule({ find: /:P $/, replace: \"😛 \" }),\n textInputRule({ find: /:p $/, replace: \"😛 \" }),\n textInputRule({ find: /:\\/ $/, replace: \"😕 \" }),\n textInputRule({ find: /:\\( $/, replace: \"😞 \" }),\n textInputRule({ find: /<3 $/, replace: \"❤️ \" }),\n textInputRule({ find: /<\\/3 $/, replace: \"💔 \" }),\n textInputRule({ find: /\\/shrug $/, replace: \"¯\\\\_(ツ)_/¯ \" }),\n ];\n },\n});\n","import { Extension } from \"@tiptap/core\";\nimport { Plugin } from \"@tiptap/pm/state\";\nimport { Decoration, DecorationSet } from \"@tiptap/pm/view\";\nimport type { Node as ProsemirrorNode } from \"@tiptap/pm/model\";\n\nexport function findHexColors(doc: ProsemirrorNode): DecorationSet {\n const hexColorRegex = /(#[0-9a-fA-F]{3,8})\\b/g;\n const decorations: Decoration[] = [];\n\n doc.descendants((node, position) => {\n if (!node.text) return;\n\n let match: RegExpExecArray | null;\n while ((match = hexColorRegex.exec(node.text)) !== null) {\n const color = match[0];\n const from = position + match.index;\n const to = from + color.length;\n\n decorations.push(\n Decoration.inline(from, to, {\n class: \"color-highlight px-1 py-0.5 rounded text-xs font-mono border\",\n style: `--color: ${color}; background-color: ${color}20; border-color: ${color}; color: ${color};`,\n }),\n );\n }\n });\n\n return DecorationSet.create(doc, decorations);\n}\n\nexport const ColorHighlighter = Extension.create({\n name: \"colorHighlighter\",\n\n addProseMirrorPlugins() {\n return [\n new Plugin({\n state: {\n init(_, { doc }) {\n return findHexColors(doc);\n },\n apply(transaction, oldState) {\n return transaction.docChanged ? findHexColors(transaction.doc) : oldState;\n },\n },\n props: {\n decorations(state) {\n return (this as any).getState(state);\n },\n },\n }),\n ];\n },\n});\n","import { Extension } from \"@tiptap/core\";\nimport \"@tiptap/extension-text-style\";\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n fontSize: {\n setFontSize: (size: string) => ReturnType;\n unsetFontSize: () => ReturnType;\n };\n }\n}\n\nexport const FontSize = Extension.create({\n name: \"fontSize\",\n\n addOptions() {\n return {\n types: [\"textStyle\"],\n };\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n fontSize: {\n default: null,\n parseHTML: (element) =>\n element.style.fontSize.replace(/['\"]+/g, \"\"),\n renderHTML: (attributes) => {\n if (!attributes.fontSize) {\n return {};\n }\n return {\n style: `font-size: ${attributes.fontSize}`,\n };\n },\n },\n },\n },\n ];\n },\n\n addCommands() {\n return {\n setFontSize:\n (fontSize: string) =>\n ({ chain }) =>\n chain().setMark(\"textStyle\", { fontSize }).run(),\n unsetFontSize:\n () =>\n ({ chain }) =>\n chain()\n .setMark(\"textStyle\", { fontSize: null })\n .removeEmptyTextStyle()\n .run(),\n };\n },\n});\n\nexport default FontSize;\n","import type { Extensions } from \"@tiptap/core\";\nimport StarterKit from \"@tiptap/starter-kit\";\nimport Color from \"@tiptap/extension-color\";\nimport Highlight from \"@tiptap/extension-highlight\";\nimport Link from \"@tiptap/extension-link\";\nimport TaskList from \"@tiptap/extension-task-list\";\nimport TaskItem from \"@tiptap/extension-task-item\";\nimport TextAlign from \"@tiptap/extension-text-align\";\nimport * as _TextStyle from \"@tiptap/extension-text-style\";\nconst TextStyle = (_TextStyle as any).TextStyle || (_TextStyle as any).default || _TextStyle;\nimport Typography from \"@tiptap/extension-typography\";\nimport Underline from \"@tiptap/extension-underline\";\nimport Placeholder from \"@tiptap/extension-placeholder\";\nimport CharacterCount from \"@tiptap/extension-character-count\";\n\nimport { SmilieReplacer } from \"./SmilieReplacer\";\nimport { ColorHighlighter } from \"./ColorHighlighter\";\nimport { FontSize } from \"./FontSize\";\n\nexport interface RichTextPresetOptions {\n placeholder?: string | ((props: { node: any }) => string);\n characterLimit?: number;\n openLinksOnClick?: boolean;\n enableSmilies?: boolean;\n enableColorHighlighter?: boolean;\n headingLevels?: (1 | 2 | 3 | 4 | 5 | 6)[];\n}\n\n/**\n * Creates a standard rich-text extensions bundle with full formatting support.\n */\nexport function createRichTextPreset(\n options: RichTextPresetOptions = {},\n): Extensions {\n const {\n placeholder = \"Start typing...\",\n characterLimit,\n openLinksOnClick = false,\n enableSmilies = true,\n enableColorHighlighter = true,\n headingLevels = [1, 2, 3, 4],\n } = options;\n\n const extensions: Extensions = [\n StarterKit.configure({\n orderedList: {\n HTMLAttributes: {\n class: \"list-decimal pl-4\",\n },\n },\n bulletList: {\n HTMLAttributes: {\n class: \"list-disc pl-4\",\n },\n },\n heading: {\n levels: headingLevels,\n HTMLAttributes: {\n class: \"font-bold tracking-tight\",\n },\n },\n }),\n TextStyle,\n Color,\n Highlight.configure({ multicolor: true }),\n Underline,\n Typography,\n TextAlign.configure({\n types: [\"heading\", \"paragraph\"],\n }),\n Link.configure({\n openOnClick: openLinksOnClick,\n autolink: true,\n defaultProtocol: \"https\",\n HTMLAttributes: {\n target: \"_blank\",\n rel: \"noopener noreferrer\",\n class: \"text-blue-500 underline underline-offset-2\",\n },\n }),\n TaskList,\n TaskItem.configure({\n nested: true,\n }),\n FontSize,\n Placeholder.configure({\n emptyEditorClass: \"is-empty\",\n placeholder:\n typeof placeholder === \"function\"\n ? placeholder\n : () => placeholder,\n }),\n ];\n\n if (characterLimit) {\n extensions.push(\n CharacterCount.configure({\n limit: characterLimit,\n }),\n );\n }\n\n if (enableSmilies) {\n extensions.push(SmilieReplacer);\n }\n\n if (enableColorHighlighter) {\n extensions.push(ColorHighlighter);\n }\n\n return extensions;\n}\n"],"mappings":";AAAA,SAAS,YAAY;AACrB,SAAS,cAAc;AACvB,SAAS,YAAY,qBAAqB;;;ACCnC,IAAM,iBAAiB;AACvB,IAAM,iBAAiB;AACvB,IAAM,oBAAoB;;;ADSjC,IAAM,4BAA4B,CAChC,KACA,YACiB;AACjB,QAAM,cAA4B,CAAC;AACnC,QAAM,QAAQ,QAAQ,SAAS;AAC/B,QAAM,aAAa,QAAQ,gBACvB,QAAQ,yBAAyB,MAC/B,QAAQ,gBACR,IAAI,IAAI,QAAQ,aAAa,IAC/B;AAEJ,MAAI,YAAY,CAAC,MAAM,QAAQ;AAC7B,QAAI,KAAK,QAAQ;AACf,YAAM,OAAO,KAAK,QAAQ;AAC1B,UAAI;AAGJ,YAAM,YAAY,IAAI,OAAO,eAAe,QAAQ,eAAe,KAAK;AACxE,cAAQ,QAAQ,UAAU,KAAK,IAAI,OAAO,MAAM;AAC9C,cAAM,eAAe,MAAM,CAAC,EAAE,KAAK;AACnC,cAAM,SAAS,QAAQ,kBAAkB,IAAI,YAAY;AAEzD,YAAI,QAAQ;AACV,gBAAM,QAAQ,MAAM,M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ACE,OAAO,gBAAgB,aACnB,cACA,MAAM;AAAA,IACd,CAAC;AAAA,EACH;AAEA,MAAI,gBAAgB;AAClB,eAAW;AAAA,MACT,eAAe,UAAU;AAAA,QACvB,OAAO;AAAA,MACT,CAAC;AAAA,IACH;AAAA,EACF;AAEA,MAAI,eAAe;AACjB,eAAW,KAAK,cAAc;AAAA,EAChC;AAEA,MAAI,wBAAwB;AAC1B,eAAW,KAAK,gBAAgB;AAAA,EAClC;AAEA,SAAO;AACT;","names":["Plugin","Extension","Extension","Extension","Plugin","Decoration","DecorationSet","Extension","TextStyle"]}
1
+ {"version":3,"sources":["../../src/extensions/gradient-text.ts","../../src/grammar/tokens.ts","../../src/extensions/slash-commands.ts","../../src/extensions/template-suggestions.ts","../../src/extensions/loading-node.ts","../../src/extensions/SmilieReplacer.ts","../../src/extensions/ColorHighlighter.ts","../../src/extensions/FontSize.ts","../../src/extensions/rich-text-preset.ts","../../src/extensions/mention.ts"],"sourcesContent":["import { Mark } from \"@tiptap/core\";\nimport { Plugin } from \"@tiptap/pm/state\";\nimport { Decoration, DecorationSet } from \"@tiptap/pm/view\";\nimport type { Node as ProsemirrorNode } from \"@tiptap/pm/model\";\nimport type { EditorState } from \"@tiptap/pm/state\";\nimport { TEMPLATE_REGEX, VARIABLE_REGEX, INSTRUCTION_REGEX, ColorGradient } from \"../grammar/tokens\";\n\nexport interface GradientTextOptions {\n templateColorMap: Map<string, ColorGradient>;\n speed?: number;\n jsonVariables?: string[] | Set<string>;\n onTemplateClick?: (templateName: string, event: MouseEvent) => void;\n}\n\nconst createGradientDecorations = (\n doc: ProsemirrorNode,\n options: GradientTextOptions,\n): Decoration[] => {\n const decorations: Decoration[] = [];\n const speed = options.speed ?? 1;\n const jsonVarSet = options.jsonVariables\n ? options.jsonVariables instanceof Set\n ? options.jsonVariables\n : new Set(options.jsonVariables)\n : null;\n\n doc.descendants((node, pos) => {\n if (node.isText) {\n const text = node.text || \"\";\n let match: RegExpExecArray | null;\n\n // 1. Template: {{templateName}}\n const tmplRegex = new RegExp(TEMPLATE_REGEX.source, TEMPLATE_REGEX.flags);\n while ((match = tmplRegex.exec(text)) !== null) {\n const templateName = match[1].trim();\n const colors = options.templateColorMap?.get(templateName);\n\n if (colors) {\n const start = pos + match.index;\n const end = start + match[0].length;\n const { from: colorFrom, to: colorTo } = colors;\n\n const style = `--bg-size: ${\n speed * 300\n }%; --color-from: ${colorFrom}; --color-to: ${colorTo}; caret-color: #111 !important;`;\n\n decorations.push(\n Decoration.inline(start, end, {\n class:\n \"inline animate-gradient bg-gradient-to-r from-[var(--color-from)] via-[var(--color-to)] to-[var(--color-from)] bg-[length:var(--bg-size)_100%] bg-clip-text text-transparent border border-(--color-to)/20 px-1 py-0.5 rounded-sm cursor-pointer\",\n style,\n \"data-template\": templateName,\n }),\n );\n }\n }\n\n // 2. Instruction: __text__\n const instRegex = new RegExp(\n INSTRUCTION_REGEX.source,\n INSTRUCTION_REGEX.flags,\n );\n while ((match = instRegex.exec(text)) !== null) {\n const content = match[1].trim();\n const colors = options.templateColorMap?.get(content) || {\n from: \"#ffaa40\",\n to: \"#9c40ff\",\n };\n\n const start = pos + match.index;\n const end = start + match[0].length;\n const { from: colorFrom, to: colorTo } = colors;\n\n const style = `--bg-size: ${\n speed * 300\n }%; --color-from: ${colorFrom}; --color-to: ${colorTo}; caret-color: #111 !important;`;\n\n decorations.push(\n Decoration.inline(start, end, {\n class:\n \"italic animate-gradient bg-gradient-to-r from-rose-400 from-50% to-violet-500 to-50% bg-size-[200%_100%] bg-clip-text text-transparent inline-flex items-baseline gap-0.5\",\n style,\n }),\n );\n }\n\n // 3. Variable: {variableName}\n const varRegex = new RegExp(\n VARIABLE_REGEX.source,\n VARIABLE_REGEX.flags,\n );\n while ((match = varRegex.exec(text)) !== null) {\n const variableName = match[1].trim();\n const start = pos + match.index;\n const end = start + match[0].length;\n const isJsonVar = jsonVarSet?.has(variableName);\n\n decorations.push(\n Decoration.inline(start, end, {\n class: isJsonVar\n ? \"bg-violet-400/40 border-b-4 border-rose-300 dark:border-rose-800 inline-flex items-baseline px-1 py-0 text-foreground/80 gap-0.5 rounded-xs\"\n : \"bg-rose-400/40 border-b-4 border-violet-300 dark:border-violet-800 inline-flex items-baseline px-1 py-0 text-foreground/80 gap-0.5 rounded-xs\",\n \"data-variable\": variableName,\n }),\n );\n }\n }\n });\n\n return decorations;\n};\n\nexport const GradientText = Mark.create<GradientTextOptions>({\n name: \"gradientText\",\n\n addOptions() {\n return {\n templateColorMap: new Map(),\n speed: 1,\n jsonVariables: undefined,\n onTemplateClick: undefined,\n };\n },\n\n renderHTML({ HTMLAttributes }) {\n const defaultColors = {\n from: \"#ffaa40\",\n to: \"#9c40ff\",\n };\n const speed = this.options.speed ?? 1;\n const style = `--bg-size: ${speed * 300}%; --color-from: ${\n defaultColors.from\n }; --color-to: ${defaultColors.to}; caret-color: #111 !important;`;\n\n return [\n \"span\",\n {\n class:\n \"inline animate-gradient bg-gradient-to-r from-[var(--color-from)] via-[var(--color-to)] to-[var(--color-from)] bg-[length:var(--bg-size)_100%] bg-clip-text text-transparent\",\n style,\n ...HTMLAttributes,\n },\n 0,\n ];\n },\n\n parseHTML() {\n return [\n {\n tag: \"span\",\n getAttrs: (node) =>\n (node as HTMLElement).classList.contains(\"animate-gradient\") &&\n (node as HTMLElement).classList.contains(\"bg-clip-text\") &&\n null,\n },\n ];\n },\n\n addProseMirrorPlugins() {\n const markOptions = this.options;\n\n return [\n new Plugin({\n state: {\n init(_, { doc }) {\n return DecorationSet.create(\n doc,\n createGradientDecorations(doc, markOptions),\n );\n },\n apply(tr, value: DecorationSet) {\n const newDoc = tr.doc;\n if (tr.docChanged) {\n return DecorationSet.create(\n newDoc,\n createGradientDecorations(newDoc, markOptions),\n );\n }\n return value.map(tr.mapping, newDoc);\n },\n },\n props: {\n decorations(state: EditorState) {\n return (this as any).getState(state) as DecorationSet;\n },\n handleClickOn(view, pos, _node, _nodePos, event) {\n const decorationSet = (this as any).getState(\n view.state,\n ) as DecorationSet;\n const decorations = decorationSet.find(pos, pos + 1);\n\n for (const decoration of decorations) {\n const decorationWithAttrs = decoration as any;\n const templateName =\n decorationWithAttrs.type?.attrs?.[\"data-template\"];\n if (templateName) {\n if (markOptions.onTemplateClick) {\n markOptions.onTemplateClick(templateName, event as MouseEvent);\n }\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(\n new CustomEvent(\"show-gradient-popover\", {\n detail: {\n templateName,\n target: event.target,\n },\n }),\n );\n }\n return true;\n }\n }\n return false;\n },\n },\n }),\n ];\n },\n});\n","/**\n * Canonical regex patterns for prompt editing tokens.\n */\nexport const TEMPLATE_REGEX = /{{\\s*([^}]+?)\\s*}}/g;\nexport const VARIABLE_REGEX = /(?<!\\{)\\{([^{}]+)\\}(?!\\})/g;\nexport const INSTRUCTION_REGEX = /__(.+?)__/g;\n\n// Backward-compatible camelCase aliases\nexport const templateRegex = TEMPLATE_REGEX;\nexport const variableRegex = VARIABLE_REGEX;\nexport const instructionRegex = INSTRUCTION_REGEX;\n\nexport type TokenType = \"template\" | \"variable\" | \"instruction\" | \"text\";\n\nexport interface Token {\n type: TokenType;\n raw: string;\n value: string;\n start: number;\n end: number;\n}\n\nexport interface TemplateVersion {\n id: string;\n version: string | number;\n body: string;\n createdAt?: any;\n [key: string]: any;\n}\n\nexport interface Template {\n id?: string;\n name: string;\n body?: string;\n latestVersion?: string | number;\n versions?: TemplateVersion[];\n color?: string;\n [key: string]: any;\n}\n\nexport interface ColorGradient {\n from: string;\n to: string;\n}\n","import { Extension } from \"@tiptap/core\";\nimport { Plugin } from \"@tiptap/pm/state\";\n\nexport interface SlashCommandMatchData {\n match: RegExpMatchArray;\n query: string;\n from: number;\n to: number;\n coords: { top: number; left: number; bottom: number; right: number };\n}\n\nexport interface SlashCommandsOptions {\n trigger?: string;\n onMatch?: (data: SlashCommandMatchData) => void;\n onClear?: () => void;\n containerId?: string;\n}\n\nexport const SlashCommands = Extension.create<SlashCommandsOptions>({\n name: \"slashCommands\",\n\n addOptions() {\n return {\n trigger: \"/\",\n onMatch: undefined,\n onClear: undefined,\n containerId: undefined,\n };\n },\n\n addProseMirrorPlugins() {\n const opts = this.options;\n\n return [\n new Plugin({\n view() {\n return {\n update(view) {\n const { state } = view;\n const { selection } = state;\n const { $from } = selection;\n\n if (!$from.parent.isTextblock) {\n opts.onClear?.();\n return;\n }\n\n const textBeforeCursor = $from.parent.textBetween(\n 0,\n $from.parentOffset,\n );\n\n const slashMatch = textBeforeCursor.match(\n /(?:^|\\s)\\/([a-zA-Z0-9_-]*)$/,\n );\n\n if (slashMatch) {\n const matchIndex = slashMatch.index ?? 0;\n const offsetInParent =\n matchIndex + (slashMatch[0].startsWith(\" \") ? 1 : 0);\n const matchFrom = $from.start() + offsetInParent;\n const matchTo = $from.pos;\n const coords = view.coordsAtPos($from.pos);\n\n let relativeCoords = {\n top: coords.top,\n left: coords.left,\n bottom: coords.bottom,\n right: coords.right,\n };\n\n if (opts.containerId && typeof document !== \"undefined\") {\n const container = document.getElementById(opts.containerId);\n if (container) {\n const rect = container.getBoundingClientRect();\n relativeCoords = {\n top: coords.bottom - rect.top + 5,\n left: coords.left - rect.left,\n bottom: coords.bottom - rect.top,\n right: coords.right - rect.left,\n };\n }\n }\n\n opts.onMatch?.({\n match: slashMatch,\n query: slashMatch[1] || \"\",\n from: matchFrom,\n to: matchTo,\n coords: relativeCoords,\n });\n } else {\n opts.onClear?.();\n }\n },\n };\n },\n }),\n ];\n },\n});\n","import { Extension } from \"@tiptap/core\";\nimport Suggestion, { SuggestionOptions } from \"@tiptap/suggestion\";\nimport { Template } from \"../grammar/tokens\";\n\nexport interface TemplateSuggestionsOptions {\n templates: Template[];\n char?: string;\n onSuggestion?: (props: {\n query: string;\n range: { from: number; to: number };\n clientRect?: (() => DOMRect | null) | null;\n items: Template[];\n command: (props: { name: string }) => void;\n }) => void;\n}\n\nexport const TemplateSuggestions = Extension.create<TemplateSuggestionsOptions>({\n name: \"templateSuggestions\",\n\n addOptions() {\n return {\n templates: [],\n char: \"{{\",\n onSuggestion: undefined,\n };\n },\n\n addProseMirrorPlugins() {\n const opts = this.options;\n\n const suggestionConfig: Omit<SuggestionOptions<Template>, \"editor\"> = {\n char: opts.char || \"{{\",\n items: ({ query }) => {\n const lower = query.toLowerCase();\n return (opts.templates || []).filter((t) =>\n t.name.toLowerCase().includes(lower),\n );\n },\n command: ({ editor, range, props }) => {\n editor\n .chain()\n .focus()\n .deleteRange(range)\n .insertContent(`{{${props.name}}}`)\n .run();\n },\n render: () => {\n return {\n onStart: (props) => {\n opts.onSuggestion?.(props as any);\n },\n onUpdate: (props) => {\n opts.onSuggestion?.(props as any);\n },\n onExit: () => {\n opts.onSuggestion?.({\n query: \"\",\n range: { from: 0, to: 0 },\n items: [],\n command: () => {},\n });\n },\n };\n },\n };\n\n const SuggestionFn =\n typeof Suggestion === \"function\"\n ? Suggestion\n : (Suggestion as any)?.default || (Suggestion as any)?.Suggestion;\n\n return [\n SuggestionFn({\n editor: this.editor,\n ...suggestionConfig,\n }),\n ];\n },\n});\n","import { Node, mergeAttributes } from \"@tiptap/core\";\n\nexport const LoadingNode = Node.create({\n name: \"loadingNode\",\n group: \"inline\",\n inline: true,\n selectable: true,\n atom: true,\n\n addAttributes() {\n return {\n id: {\n default: null,\n parseHTML: (element) => element.getAttribute(\"data-id\"),\n renderHTML: (attributes) => {\n if (!attributes.id) return {};\n return { \"data-id\": attributes.id };\n },\n },\n };\n },\n\n parseHTML() {\n return [\n {\n tag: 'span[data-type=\"loading\"]',\n },\n ];\n },\n\n renderHTML({ HTMLAttributes }) {\n return [\n \"span\",\n mergeAttributes(HTMLAttributes, {\n \"data-type\": \"loading\",\n class: \"inline-flex items-center px-1.5 py-0.5 text-xs text-muted-foreground animate-pulse\",\n }),\n \"⏳\",\n ];\n },\n});\n","import { Extension, textInputRule } from \"@tiptap/core\";\n\nexport const SmilieReplacer = Extension.create({\n name: \"smilieReplacer\",\n\n addInputRules() {\n return [\n textInputRule({ find: /-___- $/, replace: \"😑 \" }),\n textInputRule({ find: /:'-\\) $/, replace: \"😂 \" }),\n textInputRule({ find: /':-\\) $/, replace: \"😅 \" }),\n textInputRule({ find: /':-D $/, replace: \"😅 \" }),\n textInputRule({ find: />:-\\) $/, replace: \"😆 \" }),\n textInputRule({ find: /-__- $/, replace: \"😑 \" }),\n textInputRule({ find: /':-\\( $/, replace: \"😓 \" }),\n textInputRule({ find: /:'-\\( $/, replace: \"😢 \" }),\n textInputRule({ find: />:-\\( $/, replace: \"😠 \" }),\n textInputRule({ find: /O:-\\) $/, replace: \"😇 \" }),\n textInputRule({ find: /:'\\) $/, replace: \"😂 \" }),\n textInputRule({ find: /:-D $/, replace: \"😃 \" }),\n textInputRule({ find: /':\\) $/, replace: \"😅 \" }),\n textInputRule({ find: /;-\\) $/, replace: \"😉 \" }),\n textInputRule({ find: /B-\\) $/, replace: \"😎 \" }),\n textInputRule({ find: /:-\\* $/, replace: \"😘 \" }),\n textInputRule({ find: /:-\\) $/, replace: \"🙂 \" }),\n textInputRule({ find: /-_- $/, replace: \"😑 \" }),\n textInputRule({ find: /:-O $/, replace: \"😮 \" }),\n textInputRule({ find: /:-P $/, replace: \"😛 \" }),\n textInputRule({ find: /:-p $/, replace: \"😛 \" }),\n textInputRule({ find: /:-\\/ $/, replace: \"😕 \" }),\n textInputRule({ find: /:-\\( $/, replace: \"😞 \" }),\n textInputRule({ find: /:'\\( $/, replace: \"😢 \" }),\n textInputRule({ find: /:D $/, replace: \"😃 \" }),\n textInputRule({ find: /=D $/, replace: \"😃 \" }),\n textInputRule({ find: /;\\) $/, replace: \"😉 \" }),\n textInputRule({ find: /B\\) $/, replace: \"😎 \" }),\n textInputRule({ find: /:\\) $/, replace: \"🙂 \" }),\n textInputRule({ find: /=\\) $/, replace: \"🙂 \" }),\n textInputRule({ find: /:O $/, replace: \"😮 \" }),\n textInputRule({ find: /:P $/, replace: \"😛 \" }),\n textInputRule({ find: /:p $/, replace: \"😛 \" }),\n textInputRule({ find: /:\\/ $/, replace: \"😕 \" }),\n textInputRule({ find: /:\\( $/, replace: \"😞 \" }),\n textInputRule({ find: /<3 $/, replace: \"❤️ \" }),\n textInputRule({ find: /<\\/3 $/, replace: \"💔 \" }),\n textInputRule({ find: /\\/shrug $/, replace: \"¯\\\\_(ツ)_/¯ \" }),\n ];\n },\n});\n","import { Extension } from \"@tiptap/core\";\nimport { Plugin } from \"@tiptap/pm/state\";\nimport { Decoration, DecorationSet } from \"@tiptap/pm/view\";\nimport type { Node as ProsemirrorNode } from \"@tiptap/pm/model\";\n\nexport function findHexColors(doc: ProsemirrorNode): DecorationSet {\n const hexColorRegex = /(#[0-9a-fA-F]{3,8})\\b/g;\n const decorations: Decoration[] = [];\n\n doc.descendants((node, position) => {\n if (!node.text) return;\n\n let match: RegExpExecArray | null;\n while ((match = hexColorRegex.exec(node.text)) !== null) {\n const color = match[0];\n const from = position + match.index;\n const to = from + color.length;\n\n decorations.push(\n Decoration.inline(from, to, {\n class: \"color-highlight px-1 py-0.5 rounded text-xs font-mono border\",\n style: `--color: ${color}; background-color: ${color}20; border-color: ${color}; color: ${color};`,\n }),\n );\n }\n });\n\n return DecorationSet.create(doc, decorations);\n}\n\nexport const ColorHighlighter = Extension.create({\n name: \"colorHighlighter\",\n\n addProseMirrorPlugins() {\n return [\n new Plugin({\n state: {\n init(_, { doc }) {\n return findHexColors(doc);\n },\n apply(transaction, oldState) {\n return transaction.docChanged ? findHexColors(transaction.doc) : oldState;\n },\n },\n props: {\n decorations(state) {\n return (this as any).getState(state);\n },\n },\n }),\n ];\n },\n});\n","import { Extension } from \"@tiptap/core\";\nimport \"@tiptap/extension-text-style\";\n\ndeclare module \"@tiptap/core\" {\n interface Commands<ReturnType> {\n fontSize: {\n setFontSize: (size: string) => ReturnType;\n unsetFontSize: () => ReturnType;\n };\n }\n}\n\nexport const FontSize = Extension.create({\n name: \"fontSize\",\n\n addOptions() {\n return {\n types: [\"textStyle\"],\n };\n },\n\n addGlobalAttributes() {\n return [\n {\n types: this.options.types,\n attributes: {\n fontSize: {\n default: null,\n parseHTML: (element) =>\n element.style.fontSize.replace(/['\"]+/g, \"\"),\n renderHTML: (attributes) => {\n if (!attributes.fontSize) {\n return {};\n }\n return {\n style: `font-size: ${attributes.fontSize}`,\n };\n },\n },\n },\n },\n ];\n },\n\n addCommands() {\n return {\n setFontSize:\n (fontSize: string) =>\n ({ chain }) =>\n chain().setMark(\"textStyle\", { fontSize }).run(),\n unsetFontSize:\n () =>\n ({ chain }) =>\n chain()\n .setMark(\"textStyle\", { fontSize: null })\n .removeEmptyTextStyle()\n .run(),\n };\n },\n});\n\nexport default FontSize;\n","import { wrappingInputRule, markInputRule, type Extensions } from \"@tiptap/core\";\nimport StarterKit from \"@tiptap/starter-kit\";\nimport Color from \"@tiptap/extension-color\";\nimport Highlight from \"@tiptap/extension-highlight\";\nimport Link from \"@tiptap/extension-link\";\nimport TaskList from \"@tiptap/extension-task-list\";\nimport TaskItem from \"@tiptap/extension-task-item\";\nimport TextAlign from \"@tiptap/extension-text-align\";\nimport * as _TextStyle from \"@tiptap/extension-text-style\";\nconst TextStyle = (_TextStyle as any).TextStyle || (_TextStyle as any).default || _TextStyle;\nimport Typography from \"@tiptap/extension-typography\";\nimport Underline from \"@tiptap/extension-underline\";\nimport Placeholder from \"@tiptap/extension-placeholder\";\nimport CharacterCount from \"@tiptap/extension-character-count\";\n\nimport { SmilieReplacer } from \"./SmilieReplacer\";\nimport { ColorHighlighter } from \"./ColorHighlighter\";\nimport { FontSize } from \"./FontSize\";\nimport { Mention, type MentionOptions } from \"./mention\";\n\nexport interface RichTextPresetOptions {\n placeholder?: string | ((props: { node: any }) => string);\n characterLimit?: number;\n openLinksOnClick?: boolean;\n enableSmilies?: boolean;\n enableColorHighlighter?: boolean;\n headingLevels?: (1 | 2 | 3 | 4 | 5 | 6)[];\n mention?: MentionOptions | boolean;\n}\n\n/**\n * Creates a standard rich-text extensions bundle with full formatting support.\n */\nexport function createRichTextPreset(\n options: RichTextPresetOptions = {},\n): Extensions {\n const {\n placeholder = \"Start typing...\",\n characterLimit,\n openLinksOnClick = false,\n enableSmilies = true,\n enableColorHighlighter = true,\n headingLevels = [1, 2, 3, 4],\n } = options;\n\n const extensions: Extensions = [\n StarterKit.configure({\n orderedList: {\n HTMLAttributes: {\n class: \"list-decimal pl-4\",\n },\n },\n bulletList: {\n HTMLAttributes: {\n class: \"list-disc pl-4\",\n },\n },\n heading: {\n levels: headingLevels,\n HTMLAttributes: {\n class: \"font-bold tracking-tight\",\n },\n },\n }),\n TextStyle,\n Color,\n Highlight.configure({ multicolor: true }),\n Underline,\n Typography,\n TextAlign.configure({\n types: [\"heading\", \"paragraph\"],\n }),\n Link.extend({\n addInputRules() {\n return [\n markInputRule({\n find: /(?:^|\\s)\\[([^\\]]+)\\]\\(([^)]+)\\)$/,\n type: this.type,\n getAttributes: (match) => ({\n href: match[2],\n }),\n }),\n ];\n },\n }).configure({\n openOnClick: openLinksOnClick,\n autolink: true,\n defaultProtocol: \"https\",\n HTMLAttributes: {\n target: \"_blank\",\n rel: \"noopener noreferrer\",\n class: \"text-blue-500 underline underline-offset-2\",\n },\n }),\n TaskList,\n TaskItem.extend({\n addInputRules() {\n return [\n wrappingInputRule({\n find: /^\\s*(\\[([ |x])?\\])\\s$/i,\n type: this.type,\n getAttributes: (match) => ({\n checked: match[2]?.toLowerCase() === \"x\",\n }),\n }),\n ];\n },\n }).configure({\n nested: true,\n }),\n FontSize,\n Placeholder.configure({\n emptyEditorClass: \"is-empty\",\n placeholder:\n typeof placeholder === \"function\"\n ? placeholder\n : () => placeholder,\n }),\n ];\n\n if (characterLimit) {\n extensions.push(\n CharacterCount.configure({\n limit: characterLimit,\n }),\n );\n }\n\n if (enableSmilies) {\n extensions.push(SmilieReplacer);\n }\n\n if (enableColorHighlighter) {\n extensions.push(ColorHighlighter);\n }\n\n if (options.mention) {\n const mentionConfig = typeof options.mention === \"object\" ? options.mention : {};\n extensions.push(\n Mention.configure({\n HTMLAttributes: {\n class: \"pixerate-mention-node\",\n ...(mentionConfig.HTMLAttributes || {}),\n },\n ...mentionConfig,\n }),\n );\n }\n\n return extensions;\n}\n","import MentionExtension, {\n type MentionOptions as TipTapMentionOptions,\n} from \"@tiptap/extension-mention\";\nimport type { SuggestionOptions } from \"@tiptap/suggestion\";\n\nexport interface MentionEntity {\n id: string;\n label: string;\n type?: string;\n avatarUrl?: string;\n color?: string;\n [key: string]: any;\n}\n\nexport interface MentionOptions extends Partial<TipTapMentionOptions> {\n HTMLAttributes?: Record<string, any>;\n suggestion?: Partial<SuggestionOptions<MentionEntity>>;\n}\n\n/**\n * First-class native Mention extension for @pixerate/editor.\n * Creates atomic inline <span data-type=\"mention\"> nodes with full suggestion support.\n */\nexport const Mention = MentionExtension.extend({\n addAttributes() {\n return {\n ...this.parent?.(),\n type: {\n default: null,\n parseHTML: (element: HTMLElement) =>\n element.getAttribute(\"data-type-name\") ||\n element.getAttribute(\"data-entity-type\"),\n renderHTML: (attributes: Record<string, any>) => {\n if (!attributes.type) return {};\n return { \"data-type-name\": attributes.type };\n },\n },\n avatarUrl: {\n default: null,\n parseHTML: (element: HTMLElement) => element.getAttribute(\"data-avatar-url\"),\n renderHTML: (attributes: Record<string, any>) => {\n if (!attributes.avatarUrl) return {};\n return { \"data-avatar-url\": attributes.avatarUrl };\n },\n },\n color: {\n default: null,\n parseHTML: (element: HTMLElement) => element.getAttribute(\"data-color\"),\n renderHTML: (attributes: Record<string, any>) => {\n if (!attributes.color) return {};\n return { \"data-color\": attributes.color };\n },\n },\n };\n },\n});\n\n/**\n * Helper to configure the Mention extension with preset defaults.\n */\nexport function createMentionExtension(options: Partial<MentionOptions> = {}) {\n const { HTMLAttributes = {}, ...rest } = options;\n return Mention.configure({\n HTMLAttributes: {\n class: \"pixerate-mention-node\",\n ...HTMLAttributes,\n },\n ...rest,\n });\n}\n"],"mappings":";AAAA,SAAS,YAAY;AACrB,SAAS,cAAc;AACvB,SAAS,YAAY,qBAAqB;;;ACCnC,IAAM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;AAEA,MAAI,QAAQ,SAAS;AACnB,UAAM,gBAAgB,OAAO,QAAQ,YAAY,WAAW,QAAQ,UAAU,CAAC;AAC/E,eAAW;AAAA,MACT,QAAQ,UAAU;AAAA,QAChB,gBAAgB;AAAA,UACd,OAAO;AAAA,UACP,GAAI,cAAc,kBAAkB,CAAC;AAAA,QACvC;AAAA,QACA,GAAG;AAAA,MACL,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;","names":["Plugin","Extension","Extension","Extension","Plugin","Decoration","DecorationSet","Extension","TextStyle"]}
package/dist/index.cjs CHANGED
@@ -36,15 +36,18 @@ __export(src_exports, {
36
36
  GradientText: () => GradientText,
37
37
  INSTRUCTION_REGEX: () => INSTRUCTION_REGEX,
38
38
  LoadingNode: () => LoadingNode,
39
+ Mention: () => Mention,
39
40
  SlashCommands: () => SlashCommands,
40
41
  SmilieReplacer: () => SmilieReplacer,
41
42
  TEMPLATE_REGEX: () => TEMPLATE_REGEX,
42
43
  TemplateSuggestions: () => TemplateSuggestions,
43
44
  VARIABLE_REGEX: () => VARIABLE_REGEX,
44
45
  createEditor: () => createEditor,
46
+ createMentionExtension: () => createMentionExtension,
45
47
  createRichTextPreset: () => createRichTextPreset,
46
48
  escapeHtml: () => escapeHtml,
47
49
  extractInstructionNames: () => extractInstructionNames,
50
+ extractMentionsFromDoc: () => extractMentionsFromDoc,
48
51
  extractTemplateNames: () => extractTemplateNames,
49
52
  extractVariableNames: () => extractVariableNames,
50
53
  findHexColors: () => findHexColors,
@@ -875,6 +878,7 @@ var FontSize = import_core7.Extension.create({
875
878
  });
876
879
 
877
880
  // src/extensions/rich-text-preset.ts
881
+ var import_core8 = require("@tiptap/core");
878
882
  var import_starter_kit = __toESM(require("@tiptap/starter-kit"), 1);
879
883
  var import_extension_color = __toESM(require("@tiptap/extension-color"), 1);
880
884
  var import_extension_highlight = __toESM(require("@tiptap/extension-highlight"), 1);
@@ -887,6 +891,52 @@ var import_extension_typography = __toESM(require("@tiptap/extension-typography"
887
891
  var import_extension_underline = __toESM(require("@tiptap/extension-underline"), 1);
888
892
  var import_extension_placeholder = __toESM(require("@tiptap/extension-placeholder"), 1);
889
893
  var import_extension_character_count = __toESM(require("@tiptap/extension-character-count"), 1);
894
+
895
+ // src/extensions/mention.ts
896
+ var import_extension_mention = __toESM(require("@tiptap/extension-mention"), 1);
897
+ var Mention = import_extension_mention.default.extend({
898
+ addAttributes() {
899
+ return {
900
+ ...this.parent?.(),
901
+ type: {
902
+ default: null,
903
+ parseHTML: (element) => element.getAttribute("data-type-name") || element.getAttribute("data-entity-type"),
904
+ renderHTML: (attributes) => {
905
+ if (!attributes.type) return {};
906
+ return { "data-type-name": attributes.type };
907
+ }
908
+ },
909
+ avatarUrl: {
910
+ default: null,
911
+ parseHTML: (element) => element.getAttribute("data-avatar-url"),
912
+ renderHTML: (attributes) => {
913
+ if (!attributes.avatarUrl) return {};
914
+ return { "data-avatar-url": attributes.avatarUrl };
915
+ }
916
+ },
917
+ color: {
918
+ default: null,
919
+ parseHTML: (element) => element.getAttribute("data-color"),
920
+ renderHTML: (attributes) => {
921
+ if (!attributes.color) return {};
922
+ return { "data-color": attributes.color };
923
+ }
924
+ }
925
+ };
926
+ }
927
+ });
928
+ function createMentionExtension(options = {}) {
929
+ const { HTMLAttributes = {}, ...rest } = options;
930
+ return Mention.configure({
931
+ HTMLAttributes: {
932
+ class: "pixerate-mention-node",
933
+ ...HTMLAttributes
934
+ },
935
+ ...rest
936
+ });
937
+ }
938
+
939
+ // src/extensions/rich-text-preset.ts
890
940
  var TextStyle2 = _TextStyle.TextStyle || _TextStyle.default || _TextStyle;
891
941
  function createRichTextPreset(options = {}) {
892
942
  const {
@@ -924,7 +974,19 @@ function createRichTextPreset(options = {}) {
924
974
  import_extension_text_align.default.configure({
925
975
  types: ["heading", "paragraph"]
926
976
  }),
927
- import_extension_link.default.configure({
977
+ import_extension_link.default.extend({
978
+ addInputRules() {
979
+ return [
980
+ (0, import_core8.markInputRule)({
981
+ find: /(?:^|\s)\[([^\]]+)\]\(([^)]+)\)$/,
982
+ type: this.type,
983
+ getAttributes: (match) => ({
984
+ href: match[2]
985
+ })
986
+ })
987
+ ];
988
+ }
989
+ }).configure({
928
990
  openOnClick: openLinksOnClick,
929
991
  autolink: true,
930
992
  defaultProtocol: "https",
@@ -935,7 +997,19 @@ function createRichTextPreset(options = {}) {
935
997
  }
936
998
  }),
937
999
  import_extension_task_list.default,
938
- import_extension_task_item.default.configure({
1000
+ import_extension_task_item.default.extend({
1001
+ addInputRules() {
1002
+ return [
1003
+ (0, import_core8.wrappingInputRule)({
1004
+ find: /^\s*(\[([ |x])?\])\s$/i,
1005
+ type: this.type,
1006
+ getAttributes: (match) => ({
1007
+ checked: match[2]?.toLowerCase() === "x"
1008
+ })
1009
+ })
1010
+ ];
1011
+ }
1012
+ }).configure({
939
1013
  nested: true
940
1014
  }),
941
1015
  FontSize,
@@ -957,6 +1031,18 @@ function createRichTextPreset(options = {}) {
957
1031
  if (enableColorHighlighter) {
958
1032
  extensions.push(ColorHighlighter);
959
1033
  }
1034
+ if (options.mention) {
1035
+ const mentionConfig = typeof options.mention === "object" ? options.mention : {};
1036
+ extensions.push(
1037
+ Mention.configure({
1038
+ HTMLAttributes: {
1039
+ class: "pixerate-mention-node",
1040
+ ...mentionConfig.HTMLAttributes || {}
1041
+ },
1042
+ ...mentionConfig
1043
+ })
1044
+ );
1045
+ }
960
1046
  return extensions;
961
1047
  }
962
1048
 
@@ -974,9 +1060,16 @@ function plainTextToTipTapHtml(text) {
974
1060
  }
975
1061
  function htmlToPlainText(html) {
976
1062
  if (!html) return "";
1063
+ const mentionNormalized = html.replace(
1064
+ /<span[^>]*data-type=["']mention["'][^>]*data-label=["']([^"']+)["'][^>]*>.*?<\/span>/gi,
1065
+ "@$1"
1066
+ ).replace(
1067
+ /<span[^>]*data-type=["']mention["'][^>]*data-id=["']([^"']+)["'][^>]*>.*?<\/span>/gi,
1068
+ "@$1"
1069
+ );
977
1070
  if (typeof document !== "undefined") {
978
1071
  const tempDiv = document.createElement("div");
979
- tempDiv.innerHTML = html;
1072
+ tempDiv.innerHTML = mentionNormalized;
980
1073
  tempDiv.querySelectorAll("br.ProseMirror-trailingBreak").forEach((br) => br.remove());
981
1074
  tempDiv.querySelectorAll("br").forEach((br) => br.replaceWith("\n"));
982
1075
  const paragraphs = tempDiv.querySelectorAll("p, div, li, h1, h2, h3, h4, h5, h6");
@@ -989,7 +1082,7 @@ function htmlToPlainText(html) {
989
1082
  }
990
1083
  return tempDiv.textContent || "";
991
1084
  }
992
- return html.replace(/<br\s*\/?>/gi, "\n").replace(/<\/p>/gi, "\n").replace(/<\/div>/gi, "\n").replace(/<\/li>/gi, "\n").replace(/<[^>]+>/g, "").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#039;/g, "'").trim();
1085
+ return mentionNormalized.replace(/<br\s*\/?>/gi, "\n").replace(/<\/p>/gi, "\n").replace(/<\/div>/gi, "\n").replace(/<\/li>/gi, "\n").replace(/<[^>]+>/g, "").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#039;/g, "'").trim();
993
1086
  }
994
1087
  function getEditorText(editor) {
995
1088
  if (!editor) return "";
@@ -1006,9 +1099,83 @@ function getEditorText(editor) {
1006
1099
  }
1007
1100
  return "";
1008
1101
  }
1102
+ function extractMentionsFromDoc(docOrEditor) {
1103
+ if (!docOrEditor) return [];
1104
+ const mentions = [];
1105
+ const doc = docOrEditor?.state?.doc || (typeof docOrEditor?.descendants === "function" ? docOrEditor : null);
1106
+ if (doc && typeof doc.descendants === "function") {
1107
+ doc.descendants((node) => {
1108
+ if (node.type?.name === "mention" && node.attrs) {
1109
+ mentions.push({
1110
+ id: node.attrs.id || "",
1111
+ label: node.attrs.label || "",
1112
+ type: node.attrs.type,
1113
+ avatarUrl: node.attrs.avatarUrl,
1114
+ color: node.attrs.color,
1115
+ ...node.attrs
1116
+ });
1117
+ }
1118
+ });
1119
+ return mentions;
1120
+ }
1121
+ if (typeof docOrEditor === "object" && docOrEditor.content) {
1122
+ const walk = (nodes) => {
1123
+ for (const node of nodes) {
1124
+ if (node.type === "mention" && node.attrs) {
1125
+ mentions.push({
1126
+ id: node.attrs.id || "",
1127
+ label: node.attrs.label || "",
1128
+ type: node.attrs.type,
1129
+ avatarUrl: node.attrs.avatarUrl,
1130
+ color: node.attrs.color,
1131
+ ...node.attrs
1132
+ });
1133
+ }
1134
+ if (Array.isArray(node.content)) {
1135
+ walk(node.content);
1136
+ }
1137
+ }
1138
+ };
1139
+ walk(docOrEditor.content);
1140
+ return mentions;
1141
+ }
1142
+ if (typeof docOrEditor === "string") {
1143
+ if (typeof document !== "undefined") {
1144
+ const div = document.createElement("div");
1145
+ div.innerHTML = docOrEditor;
1146
+ div.querySelectorAll('span[data-type="mention"]').forEach((el) => {
1147
+ mentions.push({
1148
+ id: el.getAttribute("data-id") || "",
1149
+ label: el.getAttribute("data-label") || "",
1150
+ type: el.getAttribute("data-type-name") || void 0,
1151
+ avatarUrl: el.getAttribute("data-avatar-url") || void 0,
1152
+ color: el.getAttribute("data-color") || void 0
1153
+ });
1154
+ });
1155
+ } else {
1156
+ const spanRegex = /<span([^>]*data-type=["']mention["'][^>]*)>/gi;
1157
+ let match;
1158
+ while ((match = spanRegex.exec(docOrEditor)) !== null) {
1159
+ const attrStr = match[1];
1160
+ const getAttr = (name) => {
1161
+ const m = new RegExp(`${name}=["']([^"']*)["']`, "i").exec(attrStr);
1162
+ return m ? m[1] : void 0;
1163
+ };
1164
+ mentions.push({
1165
+ id: getAttr("data-id") || "",
1166
+ label: getAttr("data-label") || "",
1167
+ type: getAttr("data-type-name") || getAttr("data-entity-type"),
1168
+ avatarUrl: getAttr("data-avatar-url"),
1169
+ color: getAttr("data-color")
1170
+ });
1171
+ }
1172
+ }
1173
+ }
1174
+ return mentions;
1175
+ }
1009
1176
 
1010
1177
  // src/controller.ts
1011
- var import_core8 = require("@tiptap/core");
1178
+ var import_core9 = require("@tiptap/core");
1012
1179
  var import_model = require("@tiptap/pm/model");
1013
1180
  var EditorController = class {
1014
1181
  editor;
@@ -1032,7 +1199,7 @@ var EditorController = class {
1032
1199
  this.onTokensChange = onTokensChange;
1033
1200
  this.onSelectionChange = onSelectionChange;
1034
1201
  const initialContent = plainTextMode && typeof content === "string" ? plainTextToTipTapHtml(content) : content;
1035
- this.editor = new import_core8.Editor({
1202
+ this.editor = new import_core9.Editor({
1036
1203
  element: element || void 0,
1037
1204
  content: initialContent,
1038
1205
  extensions,
@@ -1122,15 +1289,18 @@ function createEditor(options = {}) {
1122
1289
  GradientText,
1123
1290
  INSTRUCTION_REGEX,
1124
1291
  LoadingNode,
1292
+ Mention,
1125
1293
  SlashCommands,
1126
1294
  SmilieReplacer,
1127
1295
  TEMPLATE_REGEX,
1128
1296
  TemplateSuggestions,
1129
1297
  VARIABLE_REGEX,
1130
1298
  createEditor,
1299
+ createMentionExtension,
1131
1300
  createRichTextPreset,
1132
1301
  escapeHtml,
1133
1302
  extractInstructionNames,
1303
+ extractMentionsFromDoc,
1134
1304
  extractTemplateNames,
1135
1305
  extractVariableNames,
1136
1306
  findHexColors,