@bikdotai/bik-component-library 0.0.804-beta.17 → 0.0.804-beta.2

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.
Files changed (65) hide show
  1. package/dist/cjs/editor/BikEditor.js +1 -1
  2. package/dist/cjs/editor/BikEditor.js.map +1 -1
  3. package/dist/cjs/editor/BikEditor.types.js.map +1 -1
  4. package/dist/cjs/editor/BikEditor.utils.js +1 -1
  5. package/dist/cjs/editor/BikEditor.utils.js.map +1 -1
  6. package/dist/cjs/editor/extensions/buildExtensions.js +1 -1
  7. package/dist/cjs/editor/extensions/buildExtensions.js.map +1 -1
  8. package/dist/cjs/editor/extensions/mention/MentionDropdown.js +1 -1
  9. package/dist/cjs/editor/extensions/mention/MentionDropdown.js.map +1 -1
  10. package/dist/cjs/editor/extensions/mention/MentionExtension.js +1 -1
  11. package/dist/cjs/editor/extensions/mention/MentionExtension.js.map +1 -1
  12. package/dist/cjs/editor/extensions/sendShortcut/SendShortcutExtension.js +1 -1
  13. package/dist/cjs/editor/extensions/sendShortcut/SendShortcutExtension.js.map +1 -1
  14. package/dist/cjs/editor/extensions/slashCommand/SlashCommandExtension.js +1 -1
  15. package/dist/cjs/editor/extensions/slashCommand/SlashCommandExtension.js.map +1 -1
  16. package/dist/cjs/editor/extensions/slashCommand/SlashCommandMenu.js +1 -1
  17. package/dist/cjs/editor/extensions/slashCommand/SlashCommandMenu.js.map +1 -1
  18. package/dist/cjs/editor/floating/LinkBubbleMenu.js +1 -1
  19. package/dist/cjs/editor/floating/LinkBubbleMenu.js.map +1 -1
  20. package/dist/cjs/editor/toolbar/BikEditorToolbar.js +1 -1
  21. package/dist/cjs/editor/toolbar/BikEditorToolbar.js.map +1 -1
  22. package/dist/cjs/src/components/bik-layout/MockMenus.d.ts +0 -1
  23. package/dist/cjs/src/editor/BikEditor.types.d.ts +12 -25
  24. package/dist/cjs/src/editor/BikEditor.utils.d.ts +0 -11
  25. package/dist/cjs/src/editor/extensions/buildExtensions.d.ts +4 -13
  26. package/dist/cjs/src/editor/extensions/mention/MentionExtension.d.ts +2 -6
  27. package/dist/cjs/src/editor/extensions/slashCommand/SlashCommandExtension.d.ts +1 -3
  28. package/dist/esm/editor/BikEditor.js +1 -1
  29. package/dist/esm/editor/BikEditor.js.map +1 -1
  30. package/dist/esm/editor/BikEditor.types.js.map +1 -1
  31. package/dist/esm/editor/BikEditor.utils.js +1 -1
  32. package/dist/esm/editor/BikEditor.utils.js.map +1 -1
  33. package/dist/esm/editor/extensions/buildExtensions.js +1 -1
  34. package/dist/esm/editor/extensions/buildExtensions.js.map +1 -1
  35. package/dist/esm/editor/extensions/mention/MentionDropdown.js +1 -1
  36. package/dist/esm/editor/extensions/mention/MentionDropdown.js.map +1 -1
  37. package/dist/esm/editor/extensions/mention/MentionExtension.js +1 -1
  38. package/dist/esm/editor/extensions/mention/MentionExtension.js.map +1 -1
  39. package/dist/esm/editor/extensions/sendShortcut/SendShortcutExtension.js +1 -1
  40. package/dist/esm/editor/extensions/sendShortcut/SendShortcutExtension.js.map +1 -1
  41. package/dist/esm/editor/extensions/slashCommand/SlashCommandExtension.js +1 -1
  42. package/dist/esm/editor/extensions/slashCommand/SlashCommandExtension.js.map +1 -1
  43. package/dist/esm/editor/extensions/slashCommand/SlashCommandMenu.js +1 -1
  44. package/dist/esm/editor/extensions/slashCommand/SlashCommandMenu.js.map +1 -1
  45. package/dist/esm/editor/floating/LinkBubbleMenu.js +1 -1
  46. package/dist/esm/editor/floating/LinkBubbleMenu.js.map +1 -1
  47. package/dist/esm/editor/toolbar/BikEditorToolbar.js +1 -1
  48. package/dist/esm/editor/toolbar/BikEditorToolbar.js.map +1 -1
  49. package/dist/esm/src/components/bik-layout/MockMenus.d.ts +0 -1
  50. package/dist/esm/src/editor/BikEditor.types.d.ts +12 -25
  51. package/dist/esm/src/editor/BikEditor.utils.d.ts +0 -11
  52. package/dist/esm/src/editor/extensions/buildExtensions.d.ts +4 -13
  53. package/dist/esm/src/editor/extensions/mention/MentionExtension.d.ts +2 -6
  54. package/dist/esm/src/editor/extensions/slashCommand/SlashCommandExtension.d.ts +1 -3
  55. package/package.json +2 -1
  56. package/dist/cjs/editor/extensions/suggestionPopup.js +0 -2
  57. package/dist/cjs/editor/extensions/suggestionPopup.js.map +0 -1
  58. package/dist/cjs/node_modules/prosemirror-model/dist/index.js +0 -2
  59. package/dist/cjs/node_modules/prosemirror-model/dist/index.js.map +0 -1
  60. package/dist/cjs/src/editor/extensions/suggestionPopup.d.ts +0 -13
  61. package/dist/esm/editor/extensions/suggestionPopup.js +0 -2
  62. package/dist/esm/editor/extensions/suggestionPopup.js.map +0 -1
  63. package/dist/esm/node_modules/prosemirror-model/dist/index.js +0 -2
  64. package/dist/esm/node_modules/prosemirror-model/dist/index.js.map +0 -1
  65. package/dist/esm/src/editor/extensions/suggestionPopup.d.ts +0 -13
@@ -1 +1 @@
1
- {"version":3,"file":"buildExtensions.js","sources":["../../../../src/editor/extensions/buildExtensions.ts"],"sourcesContent":["import CharacterCount from '@tiptap/extension-character-count';\nimport Color from '@tiptap/extension-color';\nimport FontFamily from '@tiptap/extension-font-family';\nimport Highlight from '@tiptap/extension-highlight';\nimport Image from '@tiptap/extension-image';\nimport Link from '@tiptap/extension-link';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport Subscript from '@tiptap/extension-subscript';\nimport Superscript from '@tiptap/extension-superscript';\nimport TextAlign from '@tiptap/extension-text-align';\nimport { TextStyle } from '@tiptap/extension-text-style';\nimport Underline from '@tiptap/extension-underline';\nimport StarterKit from '@tiptap/starter-kit';\nimport type { ReactNode } from 'react';\nimport type {\n\tEditorFeatures,\n\tEditorSnapshot,\n\tKeyboardShortcut,\n\tMentionDropdownRenderProps,\n\tMentionItem,\n\tPasteData,\n\tSlashCommandDropdownRenderProps,\n\tSlashCommandItem,\n} from '../BikEditor.types';\nimport { FontSizeExtension } from './FontSizeExtension';\nimport {\n\tbuildAgentMentionExtension,\n\tbuildTeamMentionExtension,\n} from './mention/MentionExtension';\nimport { PasteExtension } from './paste/PasteExtension';\nimport { PlainClipboardExtension } from './plainClipboard/PlainClipboardExtension';\nimport { SectionDividerNode } from './sectionDivider/SectionDividerNode';\nimport { SendShortcutExtension } from './sendShortcut/SendShortcutExtension';\nimport { buildSlashCommandExtension } from './slashCommand/SlashCommandExtension';\nimport { VariableDecorationExtension } from './variable/VariableDecorationExtension';\n\ninterface ExtensionConfig {\n\tfeatures?: EditorFeatures;\n\tplaceholder?: string;\n\tmaxCharacters?: number;\n\thasSections?: boolean;\n\tmentions?: {\n\t\tagents?: { current: MentionItem[] };\n\t\tteams?: { current: MentionItem[] };\n\t};\n\tslashCommands?: { current: SlashCommandItem[] };\n\tonPaste?: (data: PasteData) => boolean | void;\n\tonSend?: (content: EditorSnapshot) => void;\n\tsendShortcut?:\n\t\t| { key: string; modifiers?: Array<'mod' | 'ctrl' | 'shift' | 'alt'> }\n\t\t| Array<{\n\t\t\t\tkey: string;\n\t\t\t\tmodifiers?: Array<'mod' | 'ctrl' | 'shift' | 'alt'>;\n\t\t }>;\n\tshortcuts?: KeyboardShortcut[];\n\tonMentionSelected?: (item: MentionItem, char: '@' | '#') => void;\n\tonSlashCommandSelected?: (command: SlashCommandItem) => void;\n\trenderMentionItem?: (item: MentionItem, isActive: boolean) => ReactNode;\n\trenderMentionDropdown?: (props: MentionDropdownRenderProps) => ReactNode;\n\trenderSlashCommandItem?: (\n\t\titem: SlashCommandItem,\n\t\tisActive: boolean,\n\t) => ReactNode;\n\trenderSlashCommandDropdown?: (\n\t\tprops: SlashCommandDropdownRenderProps,\n\t) => ReactNode;\n}\n\nexport function buildExtensions(config: ExtensionConfig) {\n\tconst hasRichPaste = config.features?.richPaste ?? false;\n\tconst hasRichTypography = config.features?.richTypography ?? false;\n\n\t// When allowedMarks is specified only those marks are registered in the schema.\n\t// This disables rendering, keyboard shortcuts AND paste-preservation for the\n\t// excluded marks — all three come for free when the extension is absent.\n\tconst allowedMarks = config.features?.allowedMarks;\n\tconst isMark = (m: 'bold' | 'italic' | 'strike' | 'underline' | 'code') =>\n\t\t!allowedMarks || allowedMarks.includes(m);\n\n\tconst base = [\n\t\t// Exclude Link and Underline from StarterKit — TipTap v3 bundles both.\n\t\t// Without this, two copies of each are registered and the StarterKit copy's\n\t\t// click handler calls window.open even when openOnClick: false is set.\n\t\tStarterKit.configure({\n\t\t\tlink: false,\n\t\t\tunderline: false,\n\t\t\tbold: isMark('bold') ? {} : false,\n\t\t\titalic: isMark('italic') ? {} : false,\n\t\t\tstrike: isMark('strike') ? {} : false,\n\t\t\tcode: isMark('code') ? {} : false,\n\t\t}),\n\t\t...(isMark('underline') ? [Underline] : []),\n\t\t// Extend Link to strip addPasteRules() and addInputRules() so pasting a\n\t\t// URL never creates a hyperlink regardless of autolink/linkOnPaste values.\n\t\tLink.extend({\n\t\t\taddPasteRules: () => [],\n\t\t\taddInputRules: () => [],\n\t\t}).configure({\n\t\t\topenOnClick: false,\n\t\t\tautolink: false,\n\t\t\tlinkOnPaste: false,\n\t\t\tHTMLAttributes: {\n\t\t\t\trel: 'noopener noreferrer',\n\t\t\t\tclass: 'bik-link',\n\t\t\t},\n\t\t}),\n\t\tTextStyle,\n\t\tPlaceholder.configure({\n\t\t\tplaceholder: config.placeholder ?? 'Type a message...',\n\t\t}),\n\t\t// Consumer paste callback runs first. If it returns true the event is\n\t\t// consumed and neither PlainClipboardExtension nor the editor's default\n\t\t// paste handling will run for that event.\n\t\t...(config.onPaste\n\t\t\t? [PasteExtension.configure({ onPaste: config.onPaste })]\n\t\t\t: []),\n\t\t// Strip HTML on paste for non-rich modes so plain text is inserted.\n\t\t...(!hasRichPaste ? [PlainClipboardExtension] : []),\n\t\tSendShortcutExtension.configure({\n\t\t\tonSend: config.onSend,\n\t\t\tsendShortcut: config.sendShortcut,\n\t\t\textraShortcuts: config.shortcuts ?? [],\n\t\t}),\n\t\tVariableDecorationExtension,\n\t\t...(config.maxCharacters\n\t\t\t? [CharacterCount.configure({ limit: config.maxCharacters })]\n\t\t\t: []),\n\t\t// Always register SectionDividerNode so the custom <div data-section-divider>\n\t\t// node is part of the schema in every editor instance. This means imperative\n\t\t// callers (setBodyAndSections / setSectionContent) work even when no\n\t\t// `sections` prop was provided at mount time.\n\t\tSectionDividerNode,\n\t];\n\n\tconst mentionExtensions = [\n\t\t...(config.mentions?.agents\n\t\t\t? [\n\t\t\t\t\tbuildAgentMentionExtension(\n\t\t\t\t\t\tconfig.mentions.agents,\n\t\t\t\t\t\tconfig.onMentionSelected,\n\t\t\t\t\t\tconfig.renderMentionItem,\n\t\t\t\t\t\tconfig.renderMentionDropdown,\n\t\t\t\t\t),\n\t\t\t ]\n\t\t\t: []),\n\t\t...(config.mentions?.teams\n\t\t\t? [\n\t\t\t\t\tbuildTeamMentionExtension(\n\t\t\t\t\t\tconfig.mentions.teams,\n\t\t\t\t\t\tconfig.onMentionSelected,\n\t\t\t\t\t\tconfig.renderMentionItem,\n\t\t\t\t\t\tconfig.renderMentionDropdown,\n\t\t\t\t\t),\n\t\t\t ]\n\t\t\t: []),\n\t\t...(config.slashCommands\n\t\t\t? [\n\t\t\t\t\tbuildSlashCommandExtension(\n\t\t\t\t\t\tconfig.slashCommands,\n\t\t\t\t\t\tconfig.onSlashCommandSelected,\n\t\t\t\t\t\tconfig.renderSlashCommandItem,\n\t\t\t\t\t\tconfig.renderSlashCommandDropdown,\n\t\t\t\t\t),\n\t\t\t ]\n\t\t\t: []),\n\t];\n\n\tconst richExtensions = hasRichTypography\n\t\t? [\n\t\t\t\tColor,\n\t\t\t\tHighlight.configure({ multicolor: true }),\n\t\t\t\tFontFamily,\n\t\t\t\tFontSizeExtension,\n\t\t\t\tTextAlign.configure({ types: ['heading', 'paragraph'] }),\n\t\t\t\tSubscript,\n\t\t\t\tSuperscript,\n\t\t\t\tImage,\n\t\t ]\n\t\t: [Color];\n\n\treturn [...base, ...mentionExtensions, ...richExtensions];\n}\n"],"names":["buildExtensions","config","hasRichPaste","_b","_a","features","richPaste","hasRichTypography","_d","_c","richTypography","allowedMarks","_e","isMark","m","includes","StarterKit","configure","link","underline","bold","italic","strike","code","Underline","Link","extend","addPasteRules","addInputRules","openOnClick","autolink","linkOnPaste","HTMLAttributes","rel","class","TextStyle","Placeholder","placeholder","_f","onPaste","PasteExtension","PlainClipboardExtension","SendShortcutExtension","onSend","sendShortcut","extraShortcuts","_g","shortcuts","VariableDecorationExtension","maxCharacters","CharacterCount","limit","SectionDividerNode","_h","mentions","agents","buildAgentMentionExtension","onMentionSelected","renderMentionItem","renderMentionDropdown","_j","teams","buildTeamMentionExtension","slashCommands","buildSlashCommandExtension","onSlashCommandSelected","renderSlashCommandItem","renderSlashCommandDropdown","Color","Highlight","multicolor","FontFamily","FontSizeExtension","TextAlign","types","Subscript","Superscript","Image"],"mappings":"orCAoEM,SAAUA,EAAgBC,yBAC/B,MAAMC,EAA6C,QAA9BC,EAAiB,QAAjBC,EAAAH,EAAOI,gBAAU,IAAAD,OAAA,EAAAA,EAAAE,iBAAa,IAAAH,GAAAA,EAC7CI,EAAuD,QAAnCC,EAAiB,QAAjBC,EAAAR,EAAOI,gBAAU,IAAAI,OAAA,EAAAA,EAAAC,sBAAkB,IAAAF,GAAAA,EAKvDG,EAA8B,QAAfC,EAAAX,EAAOI,gBAAQ,IAAAO,OAAA,EAAAA,EAAED,aAChCE,EAAUC,IACdH,GAAgBA,EAAaI,SAASD,GAuGxC,MAAO,IArGM,CAIZE,EAAWC,UAAU,CACpBC,MAAM,EACNC,WAAW,EACXC,OAAMP,EAAO,SAAU,CAAE,EACzBQ,SAAQR,EAAO,WAAY,CAAE,EAC7BS,SAAQT,EAAO,WAAY,CAAE,EAC7BU,OAAMV,EAAO,SAAU,CAAE,OAEtBA,EAAO,aAAe,CAACW,GAAa,GAGxCC,EAAKC,OAAO,CACXC,cAAeA,IAAM,GACrBC,cAAeA,IAAM,KACnBX,UAAU,CACZY,aAAa,EACbC,UAAU,EACVC,aAAa,EACbC,eAAgB,CACfC,IAAK,sBACLC,MAAO,cAGTC,EACAC,EAAYnB,UAAU,CACrBoB,oBAAaC,EAAArC,EAAOoC,2BAAe,yBAKhCpC,EAAOsC,QACR,CAACC,EAAevB,UAAU,CAAEsB,QAAStC,EAAOsC,WAC5C,MAEErC,EAA2C,GAA5B,CAACuC,GACrBC,EAAsBzB,UAAU,CAC/B0B,OAAQ1C,EAAO0C,OACfC,aAAc3C,EAAO2C,aACrBC,uBAAgBC,EAAA7C,EAAO8C,yBAAa,KAErCC,KACI/C,EAAOgD,cACR,CAACC,EAAejC,UAAU,CAAEkC,MAAOlD,EAAOgD,iBAC1C,GAKHG,MAGyB,aACrBC,EAAApD,EAAOqD,+BAAUC,QAClB,CACAC,EACCvD,EAAOqD,SAASC,OAChBtD,EAAOwD,kBACPxD,EAAOyD,kBACPzD,EAAO0D,wBAGR,eACCC,EAAA3D,EAAOqD,+BAAUO,OAClB,CACAC,EACC7D,EAAOqD,SAASO,MAChB5D,EAAOwD,kBACPxD,EAAOyD,kBACPzD,EAAO0D,wBAGR,MACC1D,EAAO8D,cACR,CACAC,EACC/D,EAAO8D,cACP9D,EAAOgE,uBACPhE,EAAOiE,uBACPjE,EAAOkE,6BAGR,OAGmB5D,EACpB,CACA6D,EACAC,EAAUpD,UAAU,CAAEqD,YAAY,IAClCC,EACAC,EACAC,EAAUxD,UAAU,CAAEyD,MAAO,CAAC,UAAW,eACzCC,EACAC,EACAC,GAEA,CAACT,GAGL"}
1
+ {"version":3,"file":"buildExtensions.js","sources":["../../../../src/editor/extensions/buildExtensions.ts"],"sourcesContent":["import CharacterCount from '@tiptap/extension-character-count';\nimport Color from '@tiptap/extension-color';\nimport FontFamily from '@tiptap/extension-font-family';\nimport Highlight from '@tiptap/extension-highlight';\nimport Image from '@tiptap/extension-image';\nimport Link from '@tiptap/extension-link';\nimport Placeholder from '@tiptap/extension-placeholder';\nimport Subscript from '@tiptap/extension-subscript';\nimport Superscript from '@tiptap/extension-superscript';\nimport TextAlign from '@tiptap/extension-text-align';\nimport { TextStyle } from '@tiptap/extension-text-style';\nimport Underline from '@tiptap/extension-underline';\nimport StarterKit from '@tiptap/starter-kit';\nimport type { ReactNode } from 'react';\nimport type {\n\tEditorFeatures,\n\tEditorSnapshot,\n\tKeyboardShortcut,\n\tMentionDropdownRenderProps,\n\tMentionItem,\n\tPasteData,\n\tSlashCommandDropdownRenderProps,\n\tSlashCommandItem,\n} from '../BikEditor.types';\nimport { FontSizeExtension } from './FontSizeExtension';\nimport {\n\tbuildAgentMentionExtension,\n\tbuildTeamMentionExtension,\n} from './mention/MentionExtension';\nimport { PasteExtension } from './paste/PasteExtension';\nimport { PlainClipboardExtension } from './plainClipboard/PlainClipboardExtension';\nimport { SectionDividerNode } from './sectionDivider/SectionDividerNode';\nimport { SendShortcutExtension } from './sendShortcut/SendShortcutExtension';\nimport { buildSlashCommandExtension } from './slashCommand/SlashCommandExtension';\nimport { VariableDecorationExtension } from './variable/VariableDecorationExtension';\n\ninterface ExtensionConfig {\n\tfeatures?: EditorFeatures;\n\tplaceholder?: string;\n\tmaxCharacters?: number;\n\thasSections?: boolean;\n\tmentions?: { agents?: MentionItem[]; teams?: MentionItem[] };\n\tslashCommands?: SlashCommandItem[];\n\tonPaste?: (data: PasteData) => boolean | void;\n\tonSend?: (content: EditorSnapshot) => void;\n\tsendShortcut?: {\n\t\tkey: string;\n\t\tmodifiers?: Array<'mod' | 'ctrl' | 'shift' | 'alt'>;\n\t};\n\tshortcuts?: KeyboardShortcut[];\n\tonMentionSelected?: (item: MentionItem, char: '@' | '#') => void;\n\tonSlashCommandSelected?: (command: SlashCommandItem) => void;\n\trenderMentionItem?: (item: MentionItem, isActive: boolean) => ReactNode;\n\trenderMentionDropdown?: (props: MentionDropdownRenderProps) => ReactNode;\n\trenderSlashCommandItem?: (\n\t\titem: SlashCommandItem,\n\t\tisActive: boolean,\n\t) => ReactNode;\n\trenderSlashCommandDropdown?: (\n\t\tprops: SlashCommandDropdownRenderProps,\n\t) => ReactNode;\n}\n\nexport function buildExtensions(config: ExtensionConfig) {\n\tconst hasRichPaste = config.features?.richPaste ?? false;\n\tconst hasRichTypography = config.features?.richTypography ?? false;\n\n\t// When allowedMarks is specified only those marks are registered in the schema.\n\t// This disables rendering, keyboard shortcuts AND paste-preservation for the\n\t// excluded marks — all three come for free when the extension is absent.\n\tconst allowedMarks = config.features?.allowedMarks;\n\tconst isMark = (m: 'bold' | 'italic' | 'strike' | 'underline' | 'code') =>\n\t\t!allowedMarks || allowedMarks.includes(m);\n\n\tconst base = [\n\t\t// Exclude Link and Underline from StarterKit — TipTap v3 bundles both.\n\t\t// Without this, two copies of each are registered and the StarterKit copy's\n\t\t// click handler calls window.open even when openOnClick: false is set.\n\t\tStarterKit.configure({\n\t\t\tlink: false,\n\t\t\tunderline: false,\n\t\t\tbold: isMark('bold') ? {} : false,\n\t\t\titalic: isMark('italic') ? {} : false,\n\t\t\tstrike: isMark('strike') ? {} : false,\n\t\t\tcode: isMark('code') ? {} : false,\n\t\t}),\n\t\t...(isMark('underline') ? [Underline] : []),\n\t\t// Extend Link to strip addPasteRules() and addInputRules() so pasting a\n\t\t// URL never creates a hyperlink regardless of autolink/linkOnPaste values.\n\t\tLink.extend({\n\t\t\taddPasteRules: () => [],\n\t\t\taddInputRules: () => [],\n\t\t}).configure({\n\t\t\topenOnClick: false,\n\t\t\tautolink: false,\n\t\t\tlinkOnPaste: false,\n\t\t\tHTMLAttributes: {\n\t\t\t\trel: 'noopener noreferrer',\n\t\t\t\tclass: 'bik-link',\n\t\t\t},\n\t\t}),\n\t\tTextStyle,\n\t\tPlaceholder.configure({\n\t\t\tplaceholder: config.placeholder ?? 'Type a message...',\n\t\t}),\n\t\t// Consumer paste callback runs first. If it returns true the event is\n\t\t// consumed and neither PlainClipboardExtension nor the editor's default\n\t\t// paste handling will run for that event.\n\t\t...(config.onPaste\n\t\t\t? [PasteExtension.configure({ onPaste: config.onPaste })]\n\t\t\t: []),\n\t\t// Strip HTML on paste for non-rich modes so plain text is inserted.\n\t\t...(!hasRichPaste ? [PlainClipboardExtension] : []),\n\t\tSendShortcutExtension.configure({\n\t\t\tonSend: config.onSend,\n\t\t\tsendShortcut: config.sendShortcut,\n\t\t\textraShortcuts: config.shortcuts ?? [],\n\t\t}),\n\t\tVariableDecorationExtension,\n\t\t...(config.maxCharacters\n\t\t\t? [CharacterCount.configure({ limit: config.maxCharacters })]\n\t\t\t: []),\n\t\t// Always register SectionDividerNode so the custom <div data-section-divider>\n\t\t// node is part of the schema in every editor instance. This means imperative\n\t\t// callers (setBodyAndSections / setSectionContent) work even when no\n\t\t// `sections` prop was provided at mount time.\n\t\tSectionDividerNode,\n\t];\n\n\tconst mentionExtensions = [\n\t\t...(config.mentions?.agents?.length\n\t\t\t? [\n\t\t\t\t\tbuildAgentMentionExtension(\n\t\t\t\t\t\tconfig.mentions.agents,\n\t\t\t\t\t\tconfig.onMentionSelected,\n\t\t\t\t\t\tconfig.renderMentionItem,\n\t\t\t\t\t\tconfig.renderMentionDropdown,\n\t\t\t\t\t),\n\t\t\t ]\n\t\t\t: []),\n\t\t...(config.mentions?.teams?.length\n\t\t\t? [\n\t\t\t\t\tbuildTeamMentionExtension(\n\t\t\t\t\t\tconfig.mentions.teams,\n\t\t\t\t\t\tconfig.onMentionSelected,\n\t\t\t\t\t\tconfig.renderMentionItem,\n\t\t\t\t\t\tconfig.renderMentionDropdown,\n\t\t\t\t\t),\n\t\t\t ]\n\t\t\t: []),\n\t\t...(config.slashCommands?.length\n\t\t\t? [\n\t\t\t\t\tbuildSlashCommandExtension(\n\t\t\t\t\t\tconfig.slashCommands,\n\t\t\t\t\t\tconfig.onSlashCommandSelected,\n\t\t\t\t\t\tconfig.renderSlashCommandItem,\n\t\t\t\t\t\tconfig.renderSlashCommandDropdown,\n\t\t\t\t\t),\n\t\t\t ]\n\t\t\t: []),\n\t];\n\n\tconst richExtensions = hasRichTypography\n\t\t? [\n\t\t\t\tColor,\n\t\t\t\tHighlight.configure({ multicolor: true }),\n\t\t\t\tFontFamily,\n\t\t\t\tFontSizeExtension,\n\t\t\t\tTextAlign.configure({ types: ['heading', 'paragraph'] }),\n\t\t\t\tSubscript,\n\t\t\t\tSuperscript,\n\t\t\t\tImage,\n\t\t ]\n\t\t: [Color];\n\n\treturn [...base, ...mentionExtensions, ...richExtensions];\n}\n"],"names":["buildExtensions","config","hasRichPaste","_b","_a","features","richPaste","hasRichTypography","_d","_c","richTypography","allowedMarks","_e","isMark","m","includes","StarterKit","configure","link","underline","bold","italic","strike","code","Underline","Link","extend","addPasteRules","addInputRules","openOnClick","autolink","linkOnPaste","HTMLAttributes","rel","class","TextStyle","Placeholder","placeholder","_f","onPaste","PasteExtension","PlainClipboardExtension","SendShortcutExtension","onSend","sendShortcut","extraShortcuts","_g","shortcuts","VariableDecorationExtension","maxCharacters","CharacterCount","limit","SectionDividerNode","_j","_h","mentions","agents","length","buildAgentMentionExtension","onMentionSelected","renderMentionItem","renderMentionDropdown","_l","_k","teams","buildTeamMentionExtension","_m","slashCommands","buildSlashCommandExtension","onSlashCommandSelected","renderSlashCommandItem","renderSlashCommandDropdown","Color","Highlight","multicolor","FontFamily","FontSizeExtension","TextAlign","types","Subscript","Superscript","Image"],"mappings":"orCA+DM,SAAUA,EAAgBC,+BAC/B,MAAMC,EAA6C,QAA9BC,EAAiB,QAAjBC,EAAAH,EAAOI,gBAAU,IAAAD,OAAA,EAAAA,EAAAE,iBAAa,IAAAH,GAAAA,EAC7CI,EAAuD,QAAnCC,EAAiB,QAAjBC,EAAAR,EAAOI,gBAAU,IAAAI,OAAA,EAAAA,EAAAC,sBAAkB,IAAAF,GAAAA,EAKvDG,EAA8B,QAAfC,EAAAX,EAAOI,gBAAQ,IAAAO,OAAA,EAAAA,EAAED,aAChCE,EAAUC,IACdH,GAAgBA,EAAaI,SAASD,GAuGxC,MAAO,IArGM,CAIZE,EAAWC,UAAU,CACpBC,MAAM,EACNC,WAAW,EACXC,OAAMP,EAAO,SAAU,CAAE,EACzBQ,SAAQR,EAAO,WAAY,CAAE,EAC7BS,SAAQT,EAAO,WAAY,CAAE,EAC7BU,OAAMV,EAAO,SAAU,CAAE,OAEtBA,EAAO,aAAe,CAACW,GAAa,GAGxCC,EAAKC,OAAO,CACXC,cAAeA,IAAM,GACrBC,cAAeA,IAAM,KACnBX,UAAU,CACZY,aAAa,EACbC,UAAU,EACVC,aAAa,EACbC,eAAgB,CACfC,IAAK,sBACLC,MAAO,cAGTC,EACAC,EAAYnB,UAAU,CACrBoB,oBAAaC,EAAArC,EAAOoC,2BAAe,yBAKhCpC,EAAOsC,QACR,CAACC,EAAevB,UAAU,CAAEsB,QAAStC,EAAOsC,WAC5C,MAEErC,EAA2C,GAA5B,CAACuC,GACrBC,EAAsBzB,UAAU,CAC/B0B,OAAQ1C,EAAO0C,OACfC,aAAc3C,EAAO2C,aACrBC,uBAAgBC,EAAA7C,EAAO8C,yBAAa,KAErCC,KACI/C,EAAOgD,cACR,CAACC,EAAejC,UAAU,CAAEkC,MAAOlD,EAAOgD,iBAC1C,GAKHG,MAGyB,KACE,QAAvBC,EAAe,QAAfC,EAAArD,EAAOsD,gBAAQ,IAAAD,OAAA,EAAAA,EAAEE,cAAM,IAAAH,OAAA,EAAAA,EAAEI,QAC1B,CACAC,EACCzD,EAAOsD,SAASC,OAChBvD,EAAO0D,kBACP1D,EAAO2D,kBACP3D,EAAO4D,wBAGR,OACuB,QAAtBC,EAAe,QAAfC,EAAA9D,EAAOsD,gBAAQ,IAAAQ,OAAA,EAAAA,EAAEC,aAAK,IAAAF,OAAA,EAAAA,EAAEL,QACzB,CACAQ,EACChE,EAAOsD,SAASS,MAChB/D,EAAO0D,kBACP1D,EAAO2D,kBACP3D,EAAO4D,wBAGR,eACCK,EAAAjE,EAAOkE,oCAAeV,QACvB,CACAW,EACCnE,EAAOkE,cACPlE,EAAOoE,uBACPpE,EAAOqE,uBACPrE,EAAOsE,6BAGR,OAGmBhE,EACpB,CACAiE,EACAC,EAAUxD,UAAU,CAAEyD,YAAY,IAClCC,EACAC,EACAC,EAAU5D,UAAU,CAAE6D,MAAO,CAAC,UAAW,eACzCC,EACAC,EACAC,GAEA,CAACT,GAGL"}
@@ -1,2 +1,2 @@
1
- import{jsx as e,Fragment as n,jsxs as r}from"react/jsx-runtime";import{forwardRef as t,useState as l,useRef as o,useCallback as i,useImperativeHandle as c,useEffect as s}from"react";import{DropdownContainer as a,DropdownItem as d,MentionAvatar as m,MentionAvatarFallback as h,MentionLabel as u,MentionPresenceDot as p}from"../editorDropdown.styles.js";const w=t(((t,w)=>{let{items:y,query:g,command:v,renderItem:b,renderDropdown:f}=t;const[k,D]=l(0),j=o(null),A=i((e=>{const n=j.current;if(!n)return;const r=n.children[e];null==r||r.scrollIntoView({block:"nearest"})}),[]),O=e=>{y[e]&&v(y[e])};return c(w,(()=>({onKeyDown:e=>{let{event:n}=e;return!!y.length&&("ArrowUp"===n.key?(D((e=>{const n=(e+y.length-1)%y.length;return A(n),n})),!0):"ArrowDown"===n.key?(D((e=>{const n=(e+1)%y.length;return A(n),n})),!0):"Enter"===n.key&&(O(k),!0))}}))),s((()=>D(0)),[y]),y.length?f?e(n,{children:f({items:y,query:g,activeIndex:k,onSelect:e=>v(e)})}):e(a,Object.assign({ref:j},{children:y.map(((t,l)=>e(d,Object.assign({$isActive:l===k,onMouseEnter:()=>D(l),onClick:()=>O(l)},{children:b?b(t,l===k):r(n,{children:[t.avatarUrl?e(m,{src:t.avatarUrl,alt:""}):e(h,{children:t.label.charAt(0).toUpperCase()}),e(u,{children:t.label}),void 0!==t.isOnline&&e(p,{$online:t.isOnline})]})}),t.id)))})):null}));w.displayName="MentionDropdown";export{w as MentionDropdown};
1
+ import{jsx as e,Fragment as n,jsxs as r}from"react/jsx-runtime";import{forwardRef as t,useState as o,useRef as l,useCallback as i,useImperativeHandle as c,useEffect as s}from"react";import{DropdownContainer as a,DropdownItem as d,MentionAvatar as m,MentionAvatarFallback as u,MentionLabel as h,MentionPresenceDot as p}from"../editorDropdown.styles.js";const w=t(((t,w)=>{let{items:y,query:g,command:v,renderItem:b,renderDropdown:f}=t;const[k,D]=o(0),j=l(null),A=i((e=>{const n=j.current;if(!n)return;const r=n.children[e];null==r||r.scrollIntoView({block:"nearest"})}),[]),O=e=>{y[e]&&v(y[e])};return c(w,(()=>({onKeyDown:e=>{let{event:n}=e;return"ArrowUp"===n.key?(D((e=>{const n=(e+y.length-1)%y.length;return A(n),n})),!0):"ArrowDown"===n.key?(D((e=>{const n=(e+1)%y.length;return A(n),n})),!0):"Enter"===n.key&&(O(k),!0)}}))),s((()=>D(0)),[y]),y.length?f?e(n,{children:f({items:y,query:g,activeIndex:k,onSelect:e=>v(e)})}):e(a,Object.assign({ref:j},{children:y.map(((t,o)=>e(d,Object.assign({$isActive:o===k,onMouseEnter:()=>D(o),onClick:()=>O(o)},{children:b?b(t,o===k):r(n,{children:[t.avatarUrl?e(m,{src:t.avatarUrl,alt:""}):e(u,{children:t.label.charAt(0).toUpperCase()}),e(h,{children:t.label}),void 0!==t.isOnline&&e(p,{$online:t.isOnline})]})}),t.id)))})):null}));w.displayName="MentionDropdown";export{w as MentionDropdown};
2
2
  //# sourceMappingURL=MentionDropdown.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MentionDropdown.js","sources":["../../../../../src/editor/extensions/mention/MentionDropdown.tsx"],"sourcesContent":["import React, {\n\tforwardRef,\n\tuseCallback,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseRef,\n\tuseState,\n} from 'react';\nimport type {\n\tMentionDropdownRenderProps,\n\tMentionItem,\n} from '../../BikEditor.types';\nimport {\n\tDropdownContainer,\n\tDropdownItem,\n\tMentionAvatar,\n\tMentionAvatarFallback,\n\tMentionLabel,\n\tMentionPresenceDot,\n} from '../editorDropdown.styles';\n\ninterface Props {\n\titems: MentionItem[];\n\tquery: string;\n\tcommand: (item: MentionItem) => void;\n\t/** Custom per-row renderer. Receives the item and whether it is the active row. */\n\trenderItem?: (item: MentionItem, isActive: boolean) => React.ReactNode;\n\t/**\n\t * Full custom dropdown renderer. Takes priority over renderItem.\n\t * The editor passes activeIndex and onSelect — you handle all the visual rendering.\n\t */\n\trenderDropdown?: (props: MentionDropdownRenderProps) => React.ReactNode;\n}\n\nexport const MentionDropdown = forwardRef<any, Props>(\n\t({ items, query, command, renderItem, renderDropdown }, ref) => {\n\t\tconst [selectedIndex, setSelectedIndex] = useState(0);\n\t\tconst containerRef = useRef<HTMLDivElement>(null);\n\n\t\tconst scrollToIndex = useCallback((index: number) => {\n\t\t\tconst container = containerRef.current;\n\t\t\tif (!container) return;\n\t\t\tconst item = container.children[index] as HTMLElement | undefined;\n\t\t\titem?.scrollIntoView({ block: 'nearest' });\n\t\t}, []);\n\n\t\tconst select = (i: number) => {\n\t\t\tif (items[i]) command(items[i]);\n\t\t};\n\n\t\tuseImperativeHandle(ref, () => ({\n\t\t\tonKeyDown: ({ event }: { event: KeyboardEvent }) => {\n\t\t\t\tif (!items.length) return false;\n\t\t\t\tif (event.key === 'ArrowUp') {\n\t\t\t\t\tsetSelectedIndex((prev) => {\n\t\t\t\t\t\tconst next = (prev + items.length - 1) % items.length;\n\t\t\t\t\t\tscrollToIndex(next);\n\t\t\t\t\t\treturn next;\n\t\t\t\t\t});\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif (event.key === 'ArrowDown') {\n\t\t\t\t\tsetSelectedIndex((prev) => {\n\t\t\t\t\t\tconst next = (prev + 1) % items.length;\n\t\t\t\t\t\tscrollToIndex(next);\n\t\t\t\t\t\treturn next;\n\t\t\t\t\t});\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif (event.key === 'Enter') {\n\t\t\t\t\tselect(selectedIndex);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t},\n\t\t}));\n\n\t\tuseEffect(() => setSelectedIndex(0), [items]);\n\n\t\tif (!items.length) return null;\n\n\t\t// Full custom dropdown — editor still manages keyboard nav via selectedIndex\n\t\tif (renderDropdown) {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t{renderDropdown({\n\t\t\t\t\t\titems,\n\t\t\t\t\t\tquery,\n\t\t\t\t\t\tactiveIndex: selectedIndex,\n\t\t\t\t\t\tonSelect: (item) => command(item),\n\t\t\t\t\t})}\n\t\t\t\t</>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<DropdownContainer ref={containerRef}>\n\t\t\t\t{items.map((item, i) => (\n\t\t\t\t\t<DropdownItem\n\t\t\t\t\t\tkey={item.id}\n\t\t\t\t\t\t$isActive={i === selectedIndex}\n\t\t\t\t\t\tonMouseEnter={() => setSelectedIndex(i)}\n\t\t\t\t\t\tonClick={() => select(i)}\n\t\t\t\t\t>\n\t\t\t\t\t\t{renderItem ? (\n\t\t\t\t\t\t\trenderItem(item, i === selectedIndex)\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{item.avatarUrl ? (\n\t\t\t\t\t\t\t\t\t<MentionAvatar src={item.avatarUrl} alt=\"\" />\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t<MentionAvatarFallback>\n\t\t\t\t\t\t\t\t\t\t{item.label.charAt(0).toUpperCase()}\n\t\t\t\t\t\t\t\t\t</MentionAvatarFallback>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t<MentionLabel>{item.label}</MentionLabel>\n\t\t\t\t\t\t\t\t{item.isOnline !== undefined && (\n\t\t\t\t\t\t\t\t\t<MentionPresenceDot $online={item.isOnline} />\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</DropdownItem>\n\t\t\t\t))}\n\t\t\t</DropdownContainer>\n\t\t);\n\t},\n);\nMentionDropdown.displayName = 'MentionDropdown';\n"],"names":["MentionDropdown","forwardRef","_ref","ref","items","query","command","renderItem","renderDropdown","selectedIndex","setSelectedIndex","useState","containerRef","useRef","scrollToIndex","useCallback","index","container","current","item","children","scrollIntoView","block","select","i","useImperativeHandle","onKeyDown","_ref2","event","length","key","prev","next","useEffect","_jsx","_Fragment","activeIndex","onSelect","DropdownContainer","Object","assign","map","DropdownItem","onMouseEnter","onClick","_jsxs","avatarUrl","MentionAvatar","src","alt","MentionAvatarFallback","label","charAt","toUpperCase","MentionLabel","undefined","isOnline","MentionPresenceDot","$online","id","displayName"],"mappings":"gWAkCO,MAAMA,EAAkBC,GAC9B,CAAAC,EAAwDC,KAAO,IAA9DC,MAAEA,EAAKC,MAAEA,EAAKC,QAAEA,EAAOC,WAAEA,EAAUC,eAAEA,GAAgBN,EACrD,MAAOO,EAAeC,GAAoBC,EAAS,GAC7CC,EAAeC,EAAuB,MAEtCC,EAAgBC,GAAaC,IAClC,MAAMC,EAAYL,EAAaM,QAC/B,IAAKD,EAAW,OAChB,MAAME,EAAOF,EAAUG,SAASJ,GAChCG,SAAAA,EAAME,eAAe,CAAEC,MAAO,WAAY,GACxC,IAEGC,EAAUC,IACXpB,EAAMoB,IAAIlB,EAAQF,EAAMoB,GAAG,EAgChC,OA7BAC,EAAoBtB,GAAK,KAAO,CAC/BuB,UAAWC,IAAwC,IAAvCC,MAAEA,GAAiCD,EAC9C,QAAKvB,EAAMyB,SACO,YAAdD,EAAME,KACTpB,GAAkBqB,IACjB,MAAMC,GAAQD,EAAO3B,EAAMyB,OAAS,GAAKzB,EAAMyB,OAE/C,OADAf,EAAckB,GACPA,CAAI,KAEL,GAEU,cAAdJ,EAAME,KACTpB,GAAkBqB,IACjB,MAAMC,GAAQD,EAAO,GAAK3B,EAAMyB,OAEhC,OADAf,EAAckB,GACPA,CAAI,KAEL,GAEU,UAAdJ,EAAME,MACTP,EAAOd,IACA,GAEI,MAIdwB,GAAU,IAAMvB,EAAiB,IAAI,CAACN,IAEjCA,EAAMyB,OAGPrB,EAEF0B,EACEC,EAAA,CAAAf,SAAAZ,EAAe,CACfJ,QACAC,QACA+B,YAAa3B,EACb4B,SAAWlB,GAASb,EAAQa,OAO/Be,EAACI,EAAiBC,OAAAC,OAAA,CAACrC,IAAKS,GACtB,CAAAQ,SAAAhB,EAAMqC,KAAI,CAACtB,EAAMK,IACjBU,EAACQ,2BAEWlB,IAAMf,EACjBkC,aAAcA,IAAMjC,EAAiBc,GACrCoB,QAASA,IAAMrB,EAAOC,IAAE,CAAAJ,SAEvBb,EACAA,EAAWY,EAAMK,IAAMf,GAEvBoC,EAAAV,EAAA,CAAAf,SAAA,CACED,EAAK2B,UACLZ,EAACa,EAAc,CAAAC,IAAK7B,EAAK2B,UAAWG,IAAI,KAExCf,EAACgB,EACC,CAAA9B,SAAAD,EAAKgC,MAAMC,OAAO,GAAGC,gBAGxBnB,EAACoB,EAAY,CAAAlC,SAAED,EAAKgC,aACDI,IAAlBpC,EAAKqC,UACLtB,EAACuB,EAA4B,CAAAC,QAAAvC,EAAKqC,gBAlBhCrC,EAAKwC,SApBY,IA4CL,IAIvB3D,EAAgB4D,YAAc"}
1
+ {"version":3,"file":"MentionDropdown.js","sources":["../../../../../src/editor/extensions/mention/MentionDropdown.tsx"],"sourcesContent":["import React, {\n\tforwardRef,\n\tuseCallback,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseRef,\n\tuseState,\n} from 'react';\nimport type {\n\tMentionDropdownRenderProps,\n\tMentionItem,\n} from '../../BikEditor.types';\nimport {\n\tDropdownContainer,\n\tDropdownItem,\n\tMentionAvatar,\n\tMentionAvatarFallback,\n\tMentionLabel,\n\tMentionPresenceDot,\n} from '../editorDropdown.styles';\n\ninterface Props {\n\titems: MentionItem[];\n\tquery: string;\n\tcommand: (item: MentionItem) => void;\n\t/** Custom per-row renderer. Receives the item and whether it is the active row. */\n\trenderItem?: (item: MentionItem, isActive: boolean) => React.ReactNode;\n\t/**\n\t * Full custom dropdown renderer. Takes priority over renderItem.\n\t * The editor passes activeIndex and onSelect — you handle all the visual rendering.\n\t */\n\trenderDropdown?: (props: MentionDropdownRenderProps) => React.ReactNode;\n}\n\nexport const MentionDropdown = forwardRef<any, Props>(\n\t({ items, query, command, renderItem, renderDropdown }, ref) => {\n\t\tconst [selectedIndex, setSelectedIndex] = useState(0);\n\t\tconst containerRef = useRef<HTMLDivElement>(null);\n\n\t\tconst scrollToIndex = useCallback((index: number) => {\n\t\t\tconst container = containerRef.current;\n\t\t\tif (!container) return;\n\t\t\tconst item = container.children[index] as HTMLElement | undefined;\n\t\t\titem?.scrollIntoView({ block: 'nearest' });\n\t\t}, []);\n\n\t\tconst select = (i: number) => {\n\t\t\tif (items[i]) command(items[i]);\n\t\t};\n\n\t\tuseImperativeHandle(ref, () => ({\n\t\t\tonKeyDown: ({ event }: { event: KeyboardEvent }) => {\n\t\t\t\tif (event.key === 'ArrowUp') {\n\t\t\t\t\tsetSelectedIndex((prev) => {\n\t\t\t\t\t\tconst next = (prev + items.length - 1) % items.length;\n\t\t\t\t\t\tscrollToIndex(next);\n\t\t\t\t\t\treturn next;\n\t\t\t\t\t});\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif (event.key === 'ArrowDown') {\n\t\t\t\t\tsetSelectedIndex((prev) => {\n\t\t\t\t\t\tconst next = (prev + 1) % items.length;\n\t\t\t\t\t\tscrollToIndex(next);\n\t\t\t\t\t\treturn next;\n\t\t\t\t\t});\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif (event.key === 'Enter') {\n\t\t\t\t\tselect(selectedIndex);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t},\n\t\t}));\n\n\t\tuseEffect(() => setSelectedIndex(0), [items]);\n\n\t\tif (!items.length) return null;\n\n\t\t// Full custom dropdown — editor still manages keyboard nav via selectedIndex\n\t\tif (renderDropdown) {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t{renderDropdown({\n\t\t\t\t\t\titems,\n\t\t\t\t\t\tquery,\n\t\t\t\t\t\tactiveIndex: selectedIndex,\n\t\t\t\t\t\tonSelect: (item) => command(item),\n\t\t\t\t\t})}\n\t\t\t\t</>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<DropdownContainer ref={containerRef}>\n\t\t\t\t{items.map((item, i) => (\n\t\t\t\t\t<DropdownItem\n\t\t\t\t\t\tkey={item.id}\n\t\t\t\t\t\t$isActive={i === selectedIndex}\n\t\t\t\t\t\tonMouseEnter={() => setSelectedIndex(i)}\n\t\t\t\t\t\tonClick={() => select(i)}\n\t\t\t\t\t>\n\t\t\t\t\t\t{renderItem ? (\n\t\t\t\t\t\t\trenderItem(item, i === selectedIndex)\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t{item.avatarUrl ? (\n\t\t\t\t\t\t\t\t\t<MentionAvatar src={item.avatarUrl} alt=\"\" />\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t<MentionAvatarFallback>\n\t\t\t\t\t\t\t\t\t\t{item.label.charAt(0).toUpperCase()}\n\t\t\t\t\t\t\t\t\t</MentionAvatarFallback>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t<MentionLabel>{item.label}</MentionLabel>\n\t\t\t\t\t\t\t\t{item.isOnline !== undefined && (\n\t\t\t\t\t\t\t\t\t<MentionPresenceDot $online={item.isOnline} />\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</DropdownItem>\n\t\t\t\t))}\n\t\t\t</DropdownContainer>\n\t\t);\n\t},\n);\nMentionDropdown.displayName = 'MentionDropdown';\n"],"names":["MentionDropdown","forwardRef","_ref","ref","items","query","command","renderItem","renderDropdown","selectedIndex","setSelectedIndex","useState","containerRef","useRef","scrollToIndex","useCallback","index","container","current","item","children","scrollIntoView","block","select","i","useImperativeHandle","onKeyDown","_ref2","event","key","prev","next","length","useEffect","_jsx","_Fragment","activeIndex","onSelect","DropdownContainer","Object","assign","map","DropdownItem","onMouseEnter","onClick","_jsxs","avatarUrl","MentionAvatar","src","alt","MentionAvatarFallback","label","charAt","toUpperCase","MentionLabel","undefined","isOnline","MentionPresenceDot","$online","id","displayName"],"mappings":"gWAkCO,MAAMA,EAAkBC,GAC9B,CAAAC,EAAwDC,KAAO,IAA9DC,MAAEA,EAAKC,MAAEA,EAAKC,QAAEA,EAAOC,WAAEA,EAAUC,eAAEA,GAAgBN,EACrD,MAAOO,EAAeC,GAAoBC,EAAS,GAC7CC,EAAeC,EAAuB,MAEtCC,EAAgBC,GAAaC,IAClC,MAAMC,EAAYL,EAAaM,QAC/B,IAAKD,EAAW,OAChB,MAAME,EAAOF,EAAUG,SAASJ,GAChCG,SAAAA,EAAME,eAAe,CAAEC,MAAO,WAAY,GACxC,IAEGC,EAAUC,IACXpB,EAAMoB,IAAIlB,EAAQF,EAAMoB,GAAG,EA+BhC,OA5BAC,EAAoBtB,GAAK,KAAO,CAC/BuB,UAAWC,IAAwC,IAAvCC,MAAEA,GAAiCD,EAC9C,MAAkB,YAAdC,EAAMC,KACTnB,GAAkBoB,IACjB,MAAMC,GAAQD,EAAO1B,EAAM4B,OAAS,GAAK5B,EAAM4B,OAE/C,OADAlB,EAAciB,GACPA,CAAI,KAEL,GAEU,cAAdH,EAAMC,KACTnB,GAAkBoB,IACjB,MAAMC,GAAQD,EAAO,GAAK1B,EAAM4B,OAEhC,OADAlB,EAAciB,GACPA,CAAI,KAEL,GAEU,UAAdH,EAAMC,MACTN,EAAOd,IACA,EAEI,MAIdwB,GAAU,IAAMvB,EAAiB,IAAI,CAACN,IAEjCA,EAAM4B,OAGPxB,EAEF0B,EACEC,EAAA,CAAAf,SAAAZ,EAAe,CACfJ,QACAC,QACA+B,YAAa3B,EACb4B,SAAWlB,GAASb,EAAQa,OAO/Be,EAACI,EAAiBC,OAAAC,OAAA,CAACrC,IAAKS,GACtB,CAAAQ,SAAAhB,EAAMqC,KAAI,CAACtB,EAAMK,IACjBU,EAACQ,2BAEWlB,IAAMf,EACjBkC,aAAcA,IAAMjC,EAAiBc,GACrCoB,QAASA,IAAMrB,EAAOC,IAAE,CAAAJ,SAEvBb,EACAA,EAAWY,EAAMK,IAAMf,GAEvBoC,EAAAV,EAAA,CAAAf,SAAA,CACED,EAAK2B,UACLZ,EAACa,EAAc,CAAAC,IAAK7B,EAAK2B,UAAWG,IAAI,KAExCf,EAACgB,EACC,CAAA9B,SAAAD,EAAKgC,MAAMC,OAAO,GAAGC,gBAGxBnB,EAACoB,EAAY,CAAAlC,SAAED,EAAKgC,aACDI,IAAlBpC,EAAKqC,UACLtB,EAACuB,EAA4B,CAAAC,QAAAvC,EAAKqC,gBAlBhCrC,EAAKwC,SApBY,IA4CL,IAIvB3D,EAAgB4D,YAAc"}
@@ -1,2 +1,2 @@
1
- import{mergeAttributes as e}from"../../../node_modules/@tiptap/core/dist/index.js";import t from"@tiptap/extension-mention";import{ReactRenderer as n}from"@tiptap/react";import{createSuggestionPopup as r}from"../suggestionPopup.js";import{MentionDropdown as o}from"./MentionDropdown.js";function i(e){let t=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;return()=>{let e,s;return{onStart:a=>{e=new n(o,{props:Object.assign(Object.assign({},a),{renderItem:t,renderDropdown:i}),editor:a.editor}),s=r(e.element,a.clientRect)},onUpdate:n=>{var r;e.updateProps(Object.assign(Object.assign({},n),{renderItem:t,renderDropdown:i})),(null===(r=n.items)||void 0===r?void 0:r.length)?(s.show(),s.updatePosition(n.clientRect)):s.hide()},onKeyDown:t=>{var n,r;return"Escape"===t.event.key?(s.hide(),!0):null!==(r=null===(n=e.ref)||void 0===n?void 0:n.onKeyDown(t))&&void 0!==r&&r},onExit:()=>{s.destroy(),e.destroy()}}}}function s(n,r,o,s){return t.extend({name:"mentionAgent"}).configure({HTMLAttributes:{class:"bik-mention bik-mention--agent"},renderText:e=>{let{options:t,node:n}=e;return`${t.suggestion.char}${n.attrs.label}`},renderHTML:t=>{let{options:n,node:r}=t;return["span",e(n.HTMLAttributes),`${n.suggestion.char}${r.attrs.label}`]},suggestion:{char:"@",items:e=>{let{query:t}=e;return n.current.filter((e=>e.label.toLowerCase().includes(t.toLowerCase())))},command:e=>{let{editor:t,range:n,props:o}=e;t.chain().focus().deleteRange(n).insertContent({type:"mentionAgent",attrs:{id:o.id,label:o.label}}).run(),null==r||r(o,"@")},render:i(r,"@",o,s)}})}function a(n,r,o,s){return t.extend({name:"mentionTeam"}).configure({HTMLAttributes:{class:"bik-mention bik-mention--team"},renderText:e=>{let{options:t,node:n}=e;return`${t.suggestion.char}${n.attrs.label}`},renderHTML:t=>{let{options:n,node:r}=t;return["span",e(n.HTMLAttributes),`${n.suggestion.char}${r.attrs.label}`]},suggestion:{char:"#",items:e=>{let{query:t}=e;return n.current.filter((e=>e.label.toLowerCase().includes(t.toLowerCase())))},command:e=>{let{editor:t,range:n,props:o}=e;t.chain().focus().deleteRange(n).insertContent({type:"mentionTeam",attrs:{id:o.id,label:o.label}}).run(),null==r||r(o,"#")},render:i(r,"#",o,s)}})}export{s as buildAgentMentionExtension,a as buildTeamMentionExtension};
1
+ import{mergeAttributes as e}from"../../../node_modules/@tiptap/core/dist/index.js";import t from"@tiptap/extension-mention";import{ReactRenderer as n}from"@tiptap/react";import r from"tippy.js";import{MentionDropdown as o}from"./MentionDropdown.js";function i(e){let t=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;return()=>{let e,s;return{onStart:a=>{e=new n(o,{props:Object.assign(Object.assign({},a),{renderItem:t,renderDropdown:i}),editor:a.editor}),s=r(document.body,{getReferenceClientRect:a.clientRect,appendTo:()=>document.body,content:e.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start",zIndex:9999,arrow:!1,onMount:e=>{const t=e.popper.querySelector(".tippy-box");t&&(t.style.cssText="background:none;box-shadow:none;border:none;padding:0;border-radius:0;")}})},onUpdate:n=>{var r,o,a;e.updateProps(Object.assign(Object.assign({},n),{renderItem:t,renderDropdown:i})),(null===(r=n.items)||void 0===r?void 0:r.length)?null===(a=s[0])||void 0===a||a.setProps({getReferenceClientRect:n.clientRect}):null===(o=s[0])||void 0===o||o.hide()},onKeyDown:t=>{var n,r,o;return"Escape"===t.event.key?(null===(n=s[0])||void 0===n||n.hide(),!0):null!==(o=null===(r=e.ref)||void 0===r?void 0:r.onKeyDown(t))&&void 0!==o&&o},onExit:()=>{var t;null===(t=s[0])||void 0===t||t.destroy(),e.destroy()}}}}function s(n,r,o,s){return t.extend({name:"mentionAgent"}).configure({HTMLAttributes:{class:"bik-mention bik-mention--agent"},renderText:e=>{let{options:t,node:n}=e;return`${t.suggestion.char}${n.attrs.label}`},renderHTML:t=>{let{options:n,node:r}=t;return["span",e(n.HTMLAttributes),`${n.suggestion.char}${r.attrs.label}`]},suggestion:{char:"@",items:e=>{let{query:t}=e;return n.filter((e=>e.label.toLowerCase().includes(t.toLowerCase())))},command:e=>{let{editor:t,range:n,props:o}=e;t.chain().focus().deleteRange(n).insertContent({type:"mentionAgent",attrs:{id:o.id,label:o.label}}).run(),null==r||r(o,"@")},render:i(r,"@",o,s)}})}function a(n,r,o,s){return t.extend({name:"mentionTeam"}).configure({HTMLAttributes:{class:"bik-mention bik-mention--team"},renderText:e=>{let{options:t,node:n}=e;return`${t.suggestion.char}${n.attrs.label}`},renderHTML:t=>{let{options:n,node:r}=t;return["span",e(n.HTMLAttributes),`${n.suggestion.char}${r.attrs.label}`]},suggestion:{char:"#",items:e=>{let{query:t}=e;return n.filter((e=>e.label.toLowerCase().includes(t.toLowerCase())))},command:e=>{let{editor:t,range:n,props:o}=e;t.chain().focus().deleteRange(n).insertContent({type:"mentionTeam",attrs:{id:o.id,label:o.label}}).run(),null==r||r(o,"#")},render:i(r,"#",o,s)}})}export{s as buildAgentMentionExtension,a as buildTeamMentionExtension};
2
2
  //# sourceMappingURL=MentionExtension.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MentionExtension.js","sources":["../../../../../src/editor/extensions/mention/MentionExtension.ts"],"sourcesContent":["import { mergeAttributes } from '@tiptap/core';\nimport Mention from '@tiptap/extension-mention';\nimport { ReactRenderer } from '@tiptap/react';\nimport type { ReactNode } from 'react';\nimport type {\n\tMentionDropdownRenderProps,\n\tMentionItem,\n} from '../../BikEditor.types';\nimport {\n\tcreateSuggestionPopup,\n\ttype SuggestionPopup,\n} from '../suggestionPopup';\nimport { MentionDropdown } from './MentionDropdown';\n\nfunction buildRender(\n\tonSelect?: (item: MentionItem, char: '@' | '#') => void,\n\tchar: '@' | '#' = '@',\n\trenderItem?: (item: MentionItem, isActive: boolean) => ReactNode,\n\trenderDropdown?: (props: MentionDropdownRenderProps) => ReactNode,\n) {\n\treturn () => {\n\t\tlet component: ReactRenderer;\n\t\tlet popup: SuggestionPopup;\n\n\t\treturn {\n\t\t\tonStart: (props: any) => {\n\t\t\t\tcomponent = new ReactRenderer(MentionDropdown, {\n\t\t\t\t\tprops: { ...props, renderItem, renderDropdown },\n\t\t\t\t\teditor: props.editor,\n\t\t\t\t});\n\t\t\t\tpopup = createSuggestionPopup(component.element, props.clientRect);\n\t\t\t},\n\t\t\tonUpdate: (props: any) => {\n\t\t\t\tcomponent.updateProps({ ...props, renderItem, renderDropdown });\n\t\t\t\tif (!props.items?.length) {\n\t\t\t\t\tpopup.hide();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tpopup.show();\n\t\t\t\tpopup.updatePosition(props.clientRect);\n\t\t\t},\n\t\t\tonKeyDown: (props: any) => {\n\t\t\t\tif (props.event.key === 'Escape') {\n\t\t\t\t\tpopup.hide();\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn (component.ref as any)?.onKeyDown(props) ?? false;\n\t\t\t},\n\t\t\tonExit: () => {\n\t\t\t\tpopup.destroy();\n\t\t\t\tcomponent.destroy();\n\t\t\t},\n\t\t};\n\t};\n}\n\nexport function buildAgentMentionExtension(\n\tagentsRef: { current: MentionItem[] },\n\tonSelect?: (item: MentionItem, char: '@' | '#') => void,\n\trenderItem?: (item: MentionItem, isActive: boolean) => ReactNode,\n\trenderDropdown?: (props: MentionDropdownRenderProps) => ReactNode,\n) {\n\treturn Mention.extend({ name: 'mentionAgent' }).configure({\n\t\tHTMLAttributes: { class: 'bik-mention bik-mention--agent' },\n\t\trenderText: ({ options, node }) =>\n\t\t\t`${options.suggestion.char}${node.attrs['label']}`,\n\t\trenderHTML: ({ options, node }) => [\n\t\t\t'span',\n\t\t\tmergeAttributes(options.HTMLAttributes),\n\t\t\t`${options.suggestion.char}${node.attrs['label']}`,\n\t\t],\n\t\tsuggestion: {\n\t\t\tchar: '@',\n\t\t\titems: ({ query }: { query: string }) =>\n\t\t\t\tagentsRef.current.filter((a) =>\n\t\t\t\t\ta.label.toLowerCase().includes(query.toLowerCase()),\n\t\t\t\t),\n\t\t\tcommand: ({ editor, range, props }: any) => {\n\t\t\t\teditor\n\t\t\t\t\t.chain()\n\t\t\t\t\t.focus()\n\t\t\t\t\t.deleteRange(range)\n\t\t\t\t\t.insertContent({\n\t\t\t\t\t\ttype: 'mentionAgent',\n\t\t\t\t\t\tattrs: { id: props.id, label: props.label },\n\t\t\t\t\t})\n\t\t\t\t\t.run();\n\t\t\t\tonSelect?.(props, '@');\n\t\t\t},\n\t\t\trender: buildRender(onSelect, '@', renderItem, renderDropdown),\n\t\t},\n\t});\n}\n\nexport function buildTeamMentionExtension(\n\tteamsRef: { current: MentionItem[] },\n\tonSelect?: (item: MentionItem, char: '@' | '#') => void,\n\trenderItem?: (item: MentionItem, isActive: boolean) => ReactNode,\n\trenderDropdown?: (props: MentionDropdownRenderProps) => ReactNode,\n) {\n\treturn Mention.extend({ name: 'mentionTeam' }).configure({\n\t\tHTMLAttributes: { class: 'bik-mention bik-mention--team' },\n\t\trenderText: ({ options, node }) =>\n\t\t\t`${options.suggestion.char}${node.attrs['label']}`,\n\t\trenderHTML: ({ options, node }) => [\n\t\t\t'span',\n\t\t\tmergeAttributes(options.HTMLAttributes),\n\t\t\t`${options.suggestion.char}${node.attrs['label']}`,\n\t\t],\n\t\tsuggestion: {\n\t\t\tchar: '#',\n\t\t\titems: ({ query }: { query: string }) =>\n\t\t\t\tteamsRef.current.filter((t) =>\n\t\t\t\t\tt.label.toLowerCase().includes(query.toLowerCase()),\n\t\t\t\t),\n\t\t\tcommand: ({ editor, range, props }: any) => {\n\t\t\t\teditor\n\t\t\t\t\t.chain()\n\t\t\t\t\t.focus()\n\t\t\t\t\t.deleteRange(range)\n\t\t\t\t\t.insertContent({\n\t\t\t\t\t\ttype: 'mentionTeam',\n\t\t\t\t\t\tattrs: { id: props.id, label: props.label },\n\t\t\t\t\t})\n\t\t\t\t\t.run();\n\t\t\t\tonSelect?.(props, '#');\n\t\t\t},\n\t\t\trender: buildRender(onSelect, '#', renderItem, renderDropdown),\n\t\t},\n\t});\n}\n"],"names":["buildRender","onSelect","renderItem","arguments","length","undefined","renderDropdown","component","popup","onStart","props","ReactRenderer","MentionDropdown","editor","createSuggestionPopup","element","clientRect","onUpdate","updateProps","Object","assign","_a","items","show","updatePosition","hide","onKeyDown","event","key","_b","ref","onExit","destroy","buildAgentMentionExtension","agentsRef","Mention","extend","name","configure","HTMLAttributes","class","renderText","_ref","options","node","suggestion","char","attrs","renderHTML","_ref2","mergeAttributes","_ref3","query","current","filter","a","label","toLowerCase","includes","command","_ref4","range","chain","focus","deleteRange","insertContent","type","id","run","render","buildTeamMentionExtension","teamsRef","_ref5","_ref6","_ref7","t","_ref8"],"mappings":"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"}
1
+ {"version":3,"file":"MentionExtension.js","sources":["../../../../../src/editor/extensions/mention/MentionExtension.ts"],"sourcesContent":["import { mergeAttributes } from '@tiptap/core';\nimport Mention from '@tiptap/extension-mention';\nimport { ReactRenderer } from '@tiptap/react';\nimport type { ReactNode } from 'react';\nimport tippy from 'tippy.js';\nimport type {\n\tMentionDropdownRenderProps,\n\tMentionItem,\n} from '../../BikEditor.types';\nimport { MentionDropdown } from './MentionDropdown';\n\nfunction buildRender(\n\tonSelect?: (item: MentionItem, char: '@' | '#') => void,\n\tchar: '@' | '#' = '@',\n\trenderItem?: (item: MentionItem, isActive: boolean) => ReactNode,\n\trenderDropdown?: (props: MentionDropdownRenderProps) => ReactNode,\n) {\n\treturn () => {\n\t\tlet component: ReactRenderer;\n\t\tlet popup: any;\n\n\t\treturn {\n\t\t\tonStart: (props: any) => {\n\t\t\t\tcomponent = new ReactRenderer(MentionDropdown, {\n\t\t\t\t\tprops: { ...props, renderItem, renderDropdown },\n\t\t\t\t\teditor: props.editor,\n\t\t\t\t});\n\t\t\t\tpopup = tippy(document.body, {\n\t\t\t\t\tgetReferenceClientRect: props.clientRect,\n\t\t\t\t\tappendTo: () => document.body,\n\t\t\t\t\tcontent: component.element,\n\t\t\t\t\tshowOnCreate: true,\n\t\t\t\t\tinteractive: true,\n\t\t\t\t\ttrigger: 'manual',\n\t\t\t\t\tplacement: 'bottom-start',\n\t\t\t\t\tzIndex: 9999,\n\t\t\t\t\tarrow: false,\n\t\t\t\t\t// tippy's default dark theme adds a visible box even when content\n\t\t\t\t\t// is empty. Strip it so our dropdown handles all visual styling.\n\t\t\t\t\tonMount: (instance) => {\n\t\t\t\t\t\tconst box =\n\t\t\t\t\t\t\tinstance.popper.querySelector<HTMLElement>('.tippy-box');\n\t\t\t\t\t\tif (box)\n\t\t\t\t\t\t\tbox.style.cssText =\n\t\t\t\t\t\t\t\t'background:none;box-shadow:none;border:none;padding:0;border-radius:0;';\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t},\n\t\t\tonUpdate: (props: any) => {\n\t\t\t\tcomponent.updateProps({ ...props, renderItem, renderDropdown });\n\t\t\t\tif (!props.items?.length) {\n\t\t\t\t\tpopup[0]?.hide();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tpopup[0]?.setProps({ getReferenceClientRect: props.clientRect });\n\t\t\t},\n\t\t\tonKeyDown: (props: any) => {\n\t\t\t\tif (props.event.key === 'Escape') {\n\t\t\t\t\tpopup[0]?.hide();\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn (component.ref as any)?.onKeyDown(props) ?? false;\n\t\t\t},\n\t\t\tonExit: () => {\n\t\t\t\tpopup[0]?.destroy();\n\t\t\t\tcomponent.destroy();\n\t\t\t},\n\t\t};\n\t};\n}\n\nexport function buildAgentMentionExtension(\n\tagents: MentionItem[],\n\tonSelect?: (item: MentionItem, char: '@' | '#') => void,\n\trenderItem?: (item: MentionItem, isActive: boolean) => ReactNode,\n\trenderDropdown?: (props: MentionDropdownRenderProps) => ReactNode,\n) {\n\treturn Mention.extend({ name: 'mentionAgent' }).configure({\n\t\tHTMLAttributes: { class: 'bik-mention bik-mention--agent' },\n\t\trenderText: ({ options, node }) =>\n\t\t\t`${options.suggestion.char}${node.attrs['label']}`,\n\t\trenderHTML: ({ options, node }) => [\n\t\t\t'span',\n\t\t\tmergeAttributes(options.HTMLAttributes),\n\t\t\t`${options.suggestion.char}${node.attrs['label']}`,\n\t\t],\n\t\tsuggestion: {\n\t\t\tchar: '@',\n\t\t\titems: ({ query }: { query: string }) =>\n\t\t\t\tagents.filter((a) =>\n\t\t\t\t\ta.label.toLowerCase().includes(query.toLowerCase()),\n\t\t\t\t),\n\t\t\tcommand: ({ editor, range, props }: any) => {\n\t\t\t\teditor\n\t\t\t\t\t.chain()\n\t\t\t\t\t.focus()\n\t\t\t\t\t.deleteRange(range)\n\t\t\t\t\t.insertContent({\n\t\t\t\t\t\ttype: 'mentionAgent',\n\t\t\t\t\t\tattrs: { id: props.id, label: props.label },\n\t\t\t\t\t})\n\t\t\t\t\t.run();\n\t\t\t\tonSelect?.(props, '@');\n\t\t\t},\n\t\t\trender: buildRender(onSelect, '@', renderItem, renderDropdown),\n\t\t},\n\t});\n}\n\nexport function buildTeamMentionExtension(\n\tteams: MentionItem[],\n\tonSelect?: (item: MentionItem, char: '@' | '#') => void,\n\trenderItem?: (item: MentionItem, isActive: boolean) => ReactNode,\n\trenderDropdown?: (props: MentionDropdownRenderProps) => ReactNode,\n) {\n\treturn Mention.extend({ name: 'mentionTeam' }).configure({\n\t\tHTMLAttributes: { class: 'bik-mention bik-mention--team' },\n\t\trenderText: ({ options, node }) =>\n\t\t\t`${options.suggestion.char}${node.attrs['label']}`,\n\t\trenderHTML: ({ options, node }) => [\n\t\t\t'span',\n\t\t\tmergeAttributes(options.HTMLAttributes),\n\t\t\t`${options.suggestion.char}${node.attrs['label']}`,\n\t\t],\n\t\tsuggestion: {\n\t\t\tchar: '#',\n\t\t\titems: ({ query }: { query: string }) =>\n\t\t\t\tteams.filter((t) =>\n\t\t\t\t\tt.label.toLowerCase().includes(query.toLowerCase()),\n\t\t\t\t),\n\t\t\tcommand: ({ editor, range, props }: any) => {\n\t\t\t\teditor\n\t\t\t\t\t.chain()\n\t\t\t\t\t.focus()\n\t\t\t\t\t.deleteRange(range)\n\t\t\t\t\t.insertContent({\n\t\t\t\t\t\ttype: 'mentionTeam',\n\t\t\t\t\t\tattrs: { id: props.id, label: props.label },\n\t\t\t\t\t})\n\t\t\t\t\t.run();\n\t\t\t\tonSelect?.(props, '#');\n\t\t\t},\n\t\t\trender: buildRender(onSelect, '#', renderItem, renderDropdown),\n\t\t},\n\t});\n}\n"],"names":["buildRender","onSelect","renderItem","arguments","length","undefined","renderDropdown","component","popup","onStart","props","ReactRenderer","MentionDropdown","editor","tippy","document","body","getReferenceClientRect","clientRect","appendTo","content","element","showOnCreate","interactive","trigger","placement","zIndex","arrow","onMount","instance","box","popper","querySelector","style","cssText","onUpdate","updateProps","Object","assign","_a","items","_c","setProps","_b","hide","onKeyDown","event","key","ref","onExit","destroy","buildAgentMentionExtension","agents","Mention","extend","name","configure","HTMLAttributes","class","renderText","_ref","options","node","suggestion","char","attrs","renderHTML","_ref2","mergeAttributes","_ref3","query","filter","a","label","toLowerCase","includes","command","_ref4","range","chain","focus","deleteRange","insertContent","type","id","run","render","buildTeamMentionExtension","teams","_ref5","_ref6","_ref7","t","_ref8"],"mappings":"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"}
@@ -1,2 +1,2 @@
1
- import{Extension as t}from"../../../node_modules/@tiptap/core/dist/index.js";const o=t.create({name:"sendShortcut",addOptions:()=>({onSend:void 0,sendShortcut:void 0,extraShortcuts:[]}),addKeyboardShortcuts(){var t,o;const i={};if(this.options.onSend&&this.options.sendShortcut){const o=Array.isArray(this.options.sendShortcut)?this.options.sendShortcut:[this.options.sendShortcut],e=()=>{var t,o,i;return this.options.onSend({html:this.editor.getHTML(),text:this.editor.getText(),isEmpty:this.editor.isEmpty,characterCount:null!==(i=null===(o=null===(t=this.editor.storage.characterCount)||void 0===t?void 0:t.characters)||void 0===o?void 0:o.call(t))&&void 0!==i?i:this.editor.getText().length}),!0};for(const r of o){i[[...(null!==(t=r.modifiers)&&void 0!==t?t:[]).map((t=>"mod"===t?"Mod":t.charAt(0).toUpperCase()+t.slice(1))),r.key].join("-")]=e}}for(const t of this.options.extraShortcuts){i[[...(null!==(o=t.modifiers)&&void 0!==o?o:[]).map((t=>"mod"===t?"Mod":t.charAt(0).toUpperCase()+t.slice(1))),t.key].join("-")]=()=>(t.handler(),!0)}return i}});export{o as SendShortcutExtension};
1
+ import{Extension as t}from"../../../node_modules/@tiptap/core/dist/index.js";const o=t.create({name:"sendShortcut",addOptions:()=>({onSend:void 0,sendShortcut:void 0,extraShortcuts:[]}),addKeyboardShortcuts(){var t,o;const e={};if(this.options.onSend&&this.options.sendShortcut){const o=this.options.sendShortcut;e[[...(null!==(t=o.modifiers)&&void 0!==t?t:[]).map((t=>"mod"===t?"Mod":t.charAt(0).toUpperCase()+t.slice(1))),o.key].join("-")]=()=>{var t,o,e;return this.options.onSend({html:this.editor.getHTML(),text:this.editor.getText(),isEmpty:this.editor.isEmpty,characterCount:null!==(e=null===(o=null===(t=this.editor.storage.characterCount)||void 0===t?void 0:t.characters)||void 0===o?void 0:o.call(t))&&void 0!==e?e:this.editor.getText().length}),!0}}for(const t of this.options.extraShortcuts){e[[...(null!==(o=t.modifiers)&&void 0!==o?o:[]).map((t=>"mod"===t?"Mod":t.charAt(0).toUpperCase()+t.slice(1))),t.key].join("-")]=()=>(t.handler(),!0)}return e}});export{o as SendShortcutExtension};
2
2
  //# sourceMappingURL=SendShortcutExtension.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SendShortcutExtension.js","sources":["../../../../../src/editor/extensions/sendShortcut/SendShortcutExtension.ts"],"sourcesContent":["import { Extension } from '@tiptap/core';\nimport type { EditorSnapshot, KeyboardShortcut } from '../../BikEditor.types';\n\nexport const SendShortcutExtension = Extension.create({\n\tname: 'sendShortcut',\n\taddOptions() {\n\t\treturn {\n\t\t\tonSend: undefined as ((c: EditorSnapshot) => void) | undefined,\n\t\t\tsendShortcut: undefined as\n\t\t\t\t| { key: string; modifiers?: Array<'mod' | 'ctrl' | 'shift' | 'alt'> }\n\t\t\t\t| Array<{\n\t\t\t\t\t\tkey: string;\n\t\t\t\t\t\tmodifiers?: Array<'mod' | 'ctrl' | 'shift' | 'alt'>;\n\t\t\t\t }>\n\t\t\t\t| undefined,\n\t\t\textraShortcuts: [] as KeyboardShortcut[],\n\t\t};\n\t},\n\taddKeyboardShortcuts() {\n\t\tconst map: Record<string, () => boolean> = {};\n\n\t\t// onSend shortcut(s) — only registered when sendShortcut is explicitly configured\n\t\tif (this.options.onSend && this.options.sendShortcut) {\n\t\t\tconst shortcuts = Array.isArray(this.options.sendShortcut)\n\t\t\t\t? this.options.sendShortcut\n\t\t\t\t: [this.options.sendShortcut];\n\t\t\tconst handler = () => {\n\t\t\t\tthis.options.onSend!({\n\t\t\t\t\thtml: this.editor.getHTML(),\n\t\t\t\t\ttext: this.editor.getText(),\n\t\t\t\t\tisEmpty: this.editor.isEmpty,\n\t\t\t\t\tcharacterCount:\n\t\t\t\t\t\tthis.editor.storage.characterCount?.characters?.() ??\n\t\t\t\t\t\tthis.editor.getText().length,\n\t\t\t\t});\n\t\t\t\treturn true;\n\t\t\t};\n\t\t\tfor (const sc of shortcuts) {\n\t\t\t\tconst modParts = (sc.modifiers ?? []).map((m) =>\n\t\t\t\t\tm === 'mod' ? 'Mod' : m.charAt(0).toUpperCase() + m.slice(1),\n\t\t\t\t);\n\t\t\t\tconst combo = [...modParts, sc.key].join('-');\n\t\t\t\tmap[combo] = handler;\n\t\t\t}\n\t\t}\n\n\t\t// Consumer-defined shortcuts\n\t\tfor (const shortcut of this.options.extraShortcuts) {\n\t\t\tconst modParts = (shortcut.modifiers ?? []).map((m) =>\n\t\t\t\tm === 'mod' ? 'Mod' : m.charAt(0).toUpperCase() + m.slice(1),\n\t\t\t);\n\t\t\tconst combo = [...modParts, shortcut.key].join('-');\n\t\t\tmap[combo] = () => {\n\t\t\t\tshortcut.handler();\n\t\t\t\treturn true;\n\t\t\t};\n\t\t}\n\n\t\treturn map;\n\t},\n});\n"],"names":["SendShortcutExtension","Extension","create","name","addOptions","onSend","undefined","sendShortcut","extraShortcuts","addKeyboardShortcuts","map","this","options","shortcuts","Array","isArray","handler","html","editor","getHTML","text","getText","isEmpty","characterCount","_b","_a","storage","characters","call","length","sc","modifiers","m","charAt","toUpperCase","slice","key","join","shortcut"],"mappings":"mFAGaA,EAAwBC,EAAUC,OAAO,CACrDC,KAAM,eACNC,WAAUA,KACF,CACNC,YAAQC,EACRC,kBAAcD,EAOdE,eAAgB,KAGlBC,+BACC,MAAMC,EAAqC,CAAA,EAG3C,GAAIC,KAAKC,QAAQP,QAAUM,KAAKC,QAAQL,aAAc,CACrD,MAAMM,EAAYC,MAAMC,QAAQJ,KAAKC,QAAQL,cAC1CI,KAAKC,QAAQL,aACb,CAACI,KAAKC,QAAQL,cACXS,EAAUA,eASf,OARAL,KAAKC,QAAQP,OAAQ,CACpBY,KAAMN,KAAKO,OAAOC,UAClBC,KAAMT,KAAKO,OAAOG,UAClBC,QAASX,KAAKO,OAAOI,QACrBC,yBAC+C,QAA9CC,UAAAC,EAAAd,KAAKO,OAAOQ,QAAQH,qCAAgBI,kBAAU,IAAAH,OAAA,EAAAA,EAAAI,KAAAH,kBAC9Cd,KAAKO,OAAOG,UAAUQ,UAEjB,CAAI,EAEZ,IAAK,MAAMC,KAAMjB,EAAW,CAK3BH,EADc,aAHIe,EAAAK,EAAGC,yBAAa,IAAIrB,KAAKsB,GACpC,QAANA,EAAc,MAAQA,EAAEC,OAAO,GAAGC,cAAgBF,EAAEG,MAAM,KAE/BL,EAAGM,KAAKC,KAAK,MAC5BrB,CACb,CACD,CAGD,IAAK,MAAMsB,KAAY3B,KAAKC,QAAQJ,eAAgB,CAKnDE,EADc,aAHIc,EAAAc,EAASP,yBAAa,IAAIrB,KAAKsB,GAC1C,QAANA,EAAc,MAAQA,EAAEC,OAAO,GAAGC,cAAgBF,EAAEG,MAAM,KAE/BG,EAASF,KAAKC,KAAK,MAClC,KACZC,EAAStB,WACF,EAER,CAED,OAAON,CACR"}
1
+ {"version":3,"file":"SendShortcutExtension.js","sources":["../../../../../src/editor/extensions/sendShortcut/SendShortcutExtension.ts"],"sourcesContent":["import { Extension } from '@tiptap/core';\nimport type { EditorSnapshot, KeyboardShortcut } from '../../BikEditor.types';\n\nexport const SendShortcutExtension = Extension.create({\n\tname: 'sendShortcut',\n\taddOptions() {\n\t\treturn {\n\t\t\tonSend: undefined as ((c: EditorSnapshot) => void) | undefined,\n\t\t\tsendShortcut: undefined as\n\t\t\t\t| { key: string; modifiers?: Array<'mod' | 'ctrl' | 'shift' | 'alt'> }\n\t\t\t\t| undefined,\n\t\t\textraShortcuts: [] as KeyboardShortcut[],\n\t\t};\n\t},\n\taddKeyboardShortcuts() {\n\t\tconst map: Record<string, () => boolean> = {};\n\n\t\t// onSend shortcut — only registered when sendShortcut is explicitly configured\n\t\tif (this.options.onSend && this.options.sendShortcut) {\n\t\t\tconst sc = this.options.sendShortcut;\n\t\t\tconst modParts = (sc.modifiers ?? []).map((m) =>\n\t\t\t\tm === 'mod' ? 'Mod' : m.charAt(0).toUpperCase() + m.slice(1),\n\t\t\t);\n\t\t\tconst combo = [...modParts, sc.key].join('-');\n\t\t\tmap[combo] = () => {\n\t\t\t\tthis.options.onSend!({\n\t\t\t\t\thtml: this.editor.getHTML(),\n\t\t\t\t\ttext: this.editor.getText(),\n\t\t\t\t\tisEmpty: this.editor.isEmpty,\n\t\t\t\t\tcharacterCount:\n\t\t\t\t\t\tthis.editor.storage.characterCount?.characters?.() ??\n\t\t\t\t\t\tthis.editor.getText().length,\n\t\t\t\t});\n\t\t\t\treturn true;\n\t\t\t};\n\t\t}\n\n\t\t// Consumer-defined shortcuts\n\t\tfor (const shortcut of this.options.extraShortcuts) {\n\t\t\tconst modParts = (shortcut.modifiers ?? []).map((m) =>\n\t\t\t\tm === 'mod' ? 'Mod' : m.charAt(0).toUpperCase() + m.slice(1),\n\t\t\t);\n\t\t\tconst combo = [...modParts, shortcut.key].join('-');\n\t\t\tmap[combo] = () => {\n\t\t\t\tshortcut.handler();\n\t\t\t\treturn true;\n\t\t\t};\n\t\t}\n\n\t\treturn map;\n\t},\n});\n"],"names":["SendShortcutExtension","Extension","create","name","addOptions","onSend","undefined","sendShortcut","extraShortcuts","addKeyboardShortcuts","map","this","options","sc","_a","modifiers","m","charAt","toUpperCase","slice","key","join","html","editor","getHTML","text","getText","isEmpty","characterCount","_b","storage","characters","call","length","shortcut","handler"],"mappings":"mFAGaA,EAAwBC,EAAUC,OAAO,CACrDC,KAAM,eACNC,WAAUA,KACF,CACNC,YAAQC,EACRC,kBAAcD,EAGdE,eAAgB,KAGlBC,+BACC,MAAMC,EAAqC,CAAA,EAG3C,GAAIC,KAAKC,QAAQP,QAAUM,KAAKC,QAAQL,aAAc,CACrD,MAAMM,EAAKF,KAAKC,QAAQL,aAKxBG,EADc,aAHII,EAAAD,EAAGE,yBAAa,IAAIL,KAAKM,GACpC,QAANA,EAAc,MAAQA,EAAEC,OAAO,GAAGC,cAAgBF,EAAEG,MAAM,KAE/BN,EAAGO,KAAKC,KAAK,MAC5B,eASZ,OARAV,KAAKC,QAAQP,OAAQ,CACpBiB,KAAMX,KAAKY,OAAOC,UAClBC,KAAMd,KAAKY,OAAOG,UAClBC,QAAShB,KAAKY,OAAOI,QACrBC,yBAC+C,QAA9CC,UAAAf,EAAAH,KAAKY,OAAOO,QAAQF,qCAAgBG,kBAAU,IAAAF,OAAA,EAAAA,EAAAG,KAAAlB,kBAC9CH,KAAKY,OAAOG,UAAUO,UAEjB,CAAI,CAEZ,CAGD,IAAK,MAAMC,KAAYvB,KAAKC,QAAQJ,eAAgB,CAKnDE,EADc,aAHImB,EAAAK,EAASnB,yBAAa,IAAIL,KAAKM,GAC1C,QAANA,EAAc,MAAQA,EAAEC,OAAO,GAAGC,cAAgBF,EAAEG,MAAM,KAE/Be,EAASd,KAAKC,KAAK,MAClC,KACZa,EAASC,WACF,EAER,CAED,OAAOzB,CACR"}
@@ -1,2 +1,2 @@
1
- import{Extension as e}from"../../../node_modules/@tiptap/core/dist/index.js";import{ReactRenderer as r}from"@tiptap/react";import t from"@tiptap/suggestion";import{createSuggestionPopup as o}from"../suggestionPopup.js";import{SlashCommandMenu as n}from"./SlashCommandMenu.js";function i(i,s,d,a){return e.create({name:"slashCommand",addProseMirrorPlugins(){return[t({editor:this.editor,char:"/",items:e=>{let{query:r}=e;return i.current.filter((e=>e.label.toLowerCase().includes(r.toLowerCase()))).slice(0,20)},command:e=>{let{editor:r,range:t,props:o}=e;r.chain().focus().deleteRange(t).run(),null==s||s(o)},render:()=>{let e,t;return{onStart:i=>{e=new r(n,{props:Object.assign(Object.assign({},i),{renderItem:d,renderDropdown:a}),editor:i.editor}),t=o(e.element,i.clientRect)},onUpdate:r=>{var o;e.updateProps(Object.assign(Object.assign({},r),{renderItem:d,renderDropdown:a})),(null===(o=r.items)||void 0===o?void 0:o.length)?(t.show(),t.updatePosition(r.clientRect)):t.hide()},onKeyDown:r=>{var o,n;return"Escape"===r.event.key?(t.hide(),!0):null!==(n=null===(o=e.ref)||void 0===o?void 0:o.onKeyDown(r))&&void 0!==n&&n},onExit:()=>{t.destroy(),e.destroy()}}}})]}})}export{i as buildSlashCommandExtension};
1
+ import{Extension as e}from"../../../node_modules/@tiptap/core/dist/index.js";import{ReactRenderer as t}from"@tiptap/react";import o from"@tiptap/suggestion";import r from"tippy.js";import{SlashCommandMenu as n}from"./SlashCommandMenu.js";function i(i,d,s,a){return e.create({name:"slashCommand",addProseMirrorPlugins(){return[o({editor:this.editor,char:"/",items:e=>{let{query:t}=e;return i.filter((e=>e.label.toLowerCase().includes(t.toLowerCase()))).slice(0,20)},command:e=>{let{editor:t,range:o,props:r}=e;t.chain().focus().deleteRange(o).run(),null==d||d(r)},render:()=>{let e,o;return{onStart:i=>{e=new t(n,{props:Object.assign(Object.assign({},i),{renderItem:s,renderDropdown:a}),editor:i.editor}),o=r(document.body,{getReferenceClientRect:i.clientRect,appendTo:()=>document.body,content:e.element,showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start",zIndex:9999,arrow:!1,onMount:e=>{const t=e.popper.querySelector(".tippy-box");t&&(t.style.cssText="background:none;box-shadow:none;border:none;padding:0;border-radius:0;")}})},onUpdate:t=>{var r,n,i;e.updateProps(Object.assign(Object.assign({},t),{renderItem:s,renderDropdown:a})),(null===(r=t.items)||void 0===r?void 0:r.length)?null===(i=o[0])||void 0===i||i.setProps({getReferenceClientRect:t.clientRect}):null===(n=o[0])||void 0===n||n.hide()},onKeyDown:t=>{var r,n,i;return"Escape"===t.event.key?(null===(r=o[0])||void 0===r||r.hide(),!0):null!==(i=null===(n=e.ref)||void 0===n?void 0:n.onKeyDown(t))&&void 0!==i&&i},onExit:()=>{var t;null===(t=o[0])||void 0===t||t.destroy(),e.destroy()}}}})]}})}export{i as buildSlashCommandExtension};
2
2
  //# sourceMappingURL=SlashCommandExtension.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SlashCommandExtension.js","sources":["../../../../../src/editor/extensions/slashCommand/SlashCommandExtension.ts"],"sourcesContent":["import { Extension } from '@tiptap/core';\nimport { ReactRenderer } from '@tiptap/react';\nimport Suggestion from '@tiptap/suggestion';\nimport type { ReactNode } from 'react';\nimport type {\n\tSlashCommandDropdownRenderProps,\n\tSlashCommandItem,\n} from '../../BikEditor.types';\nimport {\n\tcreateSuggestionPopup,\n\ttype SuggestionPopup,\n} from '../suggestionPopup';\nimport { SlashCommandMenu } from './SlashCommandMenu';\n\nexport function buildSlashCommandExtension(\n\tcommandsRef: { current: SlashCommandItem[] },\n\tonSelect?: (command: SlashCommandItem) => void,\n\trenderItem?: (item: SlashCommandItem, isActive: boolean) => ReactNode,\n\trenderDropdown?: (props: SlashCommandDropdownRenderProps) => ReactNode,\n) {\n\treturn Extension.create({\n\t\tname: 'slashCommand',\n\t\taddProseMirrorPlugins() {\n\t\t\treturn [\n\t\t\t\tSuggestion({\n\t\t\t\t\teditor: this.editor,\n\t\t\t\t\tchar: '/',\n\t\t\t\t\titems: ({ query }: any) =>\n\t\t\t\t\t\tcommandsRef.current\n\t\t\t\t\t\t\t.filter((c) =>\n\t\t\t\t\t\t\t\tc.label.toLowerCase().includes(query.toLowerCase()),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.slice(0, 20),\n\t\t\t\t\tcommand: ({ editor, range, props }: any) => {\n\t\t\t\t\t\teditor.chain().focus().deleteRange(range).run();\n\t\t\t\t\t\tonSelect?.(props);\n\t\t\t\t\t},\n\t\t\t\t\trender: () => {\n\t\t\t\t\t\tlet component: ReactRenderer;\n\t\t\t\t\t\tlet popup: SuggestionPopup;\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tonStart: (props: any) => {\n\t\t\t\t\t\t\t\tcomponent = new ReactRenderer(SlashCommandMenu, {\n\t\t\t\t\t\t\t\t\tprops: { ...props, renderItem, renderDropdown },\n\t\t\t\t\t\t\t\t\teditor: props.editor,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tpopup = createSuggestionPopup(\n\t\t\t\t\t\t\t\t\tcomponent.element,\n\t\t\t\t\t\t\t\t\tprops.clientRect,\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tonUpdate: (props: any) => {\n\t\t\t\t\t\t\t\tcomponent.updateProps({ ...props, renderItem, renderDropdown });\n\t\t\t\t\t\t\t\tif (!props.items?.length) {\n\t\t\t\t\t\t\t\t\tpopup.hide();\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tpopup.show();\n\t\t\t\t\t\t\t\tpopup.updatePosition(props.clientRect);\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tonKeyDown: (props: any) => {\n\t\t\t\t\t\t\t\tif (props.event.key === 'Escape') {\n\t\t\t\t\t\t\t\t\tpopup.hide();\n\t\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn (component.ref as any)?.onKeyDown(props) ?? false;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tonExit: () => {\n\t\t\t\t\t\t\t\tpopup.destroy();\n\t\t\t\t\t\t\t\tcomponent.destroy();\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t];\n\t\t},\n\t});\n}\n"],"names":["buildSlashCommandExtension","commandsRef","onSelect","renderItem","renderDropdown","Extension","create","name","addProseMirrorPlugins","Suggestion","editor","this","char","items","_ref","query","current","filter","c","label","toLowerCase","includes","slice","command","_ref2","range","props","chain","focus","deleteRange","run","render","component","popup","onStart","ReactRenderer","SlashCommandMenu","createSuggestionPopup","element","clientRect","onUpdate","updateProps","Object","assign","_a","length","show","updatePosition","hide","onKeyDown","event","key","_b","ref","onExit","destroy"],"mappings":"oRAcM,SAAUA,EACfC,EACAC,EACAC,EACAC,GAEA,OAAOC,EAAUC,OAAO,CACvBC,KAAM,eACNC,wBACC,MAAO,CACNC,EAAW,CACVC,OAAQC,KAAKD,OACbE,KAAM,IACNC,MAAOC,IAAA,IAACC,MAAEA,GAAYD,EAAA,OACrBb,EAAYe,QACVC,QAAQC,GACRA,EAAEC,MAAMC,cAAcC,SAASN,EAAMK,iBAErCE,MAAM,EAAG,GAAG,EACfC,QAASC,IAAkC,IAAjCd,OAAEA,EAAMe,MAAEA,EAAKC,MAAEA,GAAYF,EACtCd,EAAOiB,QAAQC,QAAQC,YAAYJ,GAAOK,MAC1C5B,SAAAA,EAAWwB,EAAM,EAElBK,OAAQA,KACP,IAAIC,EACAC,EAEJ,MAAO,CACNC,QAAUR,IACTM,EAAY,IAAIG,EAAcC,EAAkB,CAC/CV,qCAAYA,GAAK,CAAEvB,aAAYC,mBAC/BM,OAAQgB,EAAMhB,SAEfuB,EAAQI,EACPL,EAAUM,QACVZ,EAAMa,WACN,EAEFC,SAAWd,UACVM,EAAUS,YAAiBC,OAAAC,OAAAD,OAAAC,OAAA,CAAA,EAAAjB,IAAOvB,aAAYC,qBAC9B,QAAXwC,EAAAlB,EAAMb,aAAK,IAAA+B,OAAA,EAAAA,EAAEC,SAIlBZ,EAAMa,OACNb,EAAMc,eAAerB,EAAMa,aAJ1BN,EAAMe,MAI+B,EAEvCC,UAAYvB,YACX,MAAwB,WAApBA,EAAMwB,MAAMC,KACflB,EAAMe,QACC,GAE2C,QAA5CI,EAAsB,QAAtBR,EAACZ,EAAUqB,WAAW,IAAAT,OAAA,EAAAA,EAAEK,UAAUvB,UAAU,IAAA0B,GAAAA,CAAK,EAEzDE,OAAQA,KACPrB,EAAMsB,UACNvB,EAAUuB,SAAS,EAEpB,IAIL,GAEF"}
1
+ {"version":3,"file":"SlashCommandExtension.js","sources":["../../../../../src/editor/extensions/slashCommand/SlashCommandExtension.ts"],"sourcesContent":["import { Extension } from '@tiptap/core';\nimport { ReactRenderer } from '@tiptap/react';\nimport Suggestion from '@tiptap/suggestion';\nimport type { ReactNode } from 'react';\nimport tippy from 'tippy.js';\nimport type {\n\tSlashCommandDropdownRenderProps,\n\tSlashCommandItem,\n} from '../../BikEditor.types';\nimport { SlashCommandMenu } from './SlashCommandMenu';\n\nexport function buildSlashCommandExtension(\n\tcommands: SlashCommandItem[],\n\tonSelect?: (command: SlashCommandItem) => void,\n\trenderItem?: (item: SlashCommandItem, isActive: boolean) => ReactNode,\n\trenderDropdown?: (props: SlashCommandDropdownRenderProps) => ReactNode,\n) {\n\treturn Extension.create({\n\t\tname: 'slashCommand',\n\t\taddProseMirrorPlugins() {\n\t\t\treturn [\n\t\t\t\tSuggestion({\n\t\t\t\t\teditor: this.editor,\n\t\t\t\t\tchar: '/',\n\t\t\t\t\titems: ({ query }: any) =>\n\t\t\t\t\t\tcommands\n\t\t\t\t\t\t\t.filter((c) =>\n\t\t\t\t\t\t\t\tc.label.toLowerCase().includes(query.toLowerCase()),\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t.slice(0, 20),\n\t\t\t\t\tcommand: ({ editor, range, props }: any) => {\n\t\t\t\t\t\teditor.chain().focus().deleteRange(range).run();\n\t\t\t\t\t\tonSelect?.(props);\n\t\t\t\t\t},\n\t\t\t\t\trender: () => {\n\t\t\t\t\t\tlet component: ReactRenderer;\n\t\t\t\t\t\tlet popup: any;\n\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tonStart: (props: any) => {\n\t\t\t\t\t\t\t\tcomponent = new ReactRenderer(SlashCommandMenu, {\n\t\t\t\t\t\t\t\t\tprops: { ...props, renderItem, renderDropdown },\n\t\t\t\t\t\t\t\t\teditor: props.editor,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\tpopup = tippy(document.body, {\n\t\t\t\t\t\t\t\t\tgetReferenceClientRect: props.clientRect,\n\t\t\t\t\t\t\t\t\tappendTo: () => document.body,\n\t\t\t\t\t\t\t\t\tcontent: component.element,\n\t\t\t\t\t\t\t\t\tshowOnCreate: true,\n\t\t\t\t\t\t\t\t\tinteractive: true,\n\t\t\t\t\t\t\t\t\ttrigger: 'manual',\n\t\t\t\t\t\t\t\t\tplacement: 'bottom-start',\n\t\t\t\t\t\t\t\t\tzIndex: 9999,\n\t\t\t\t\t\t\t\t\tarrow: false,\n\t\t\t\t\t\t\t\t\t// tippy's default dark theme adds a visible box even when content\n\t\t\t\t\t\t\t\t\t// is empty. Strip it so our dropdown handles all visual styling.\n\t\t\t\t\t\t\t\t\tonMount: (instance) => {\n\t\t\t\t\t\t\t\t\t\tconst box =\n\t\t\t\t\t\t\t\t\t\t\tinstance.popper.querySelector<HTMLElement>('.tippy-box');\n\t\t\t\t\t\t\t\t\t\tif (box)\n\t\t\t\t\t\t\t\t\t\t\tbox.style.cssText =\n\t\t\t\t\t\t\t\t\t\t\t\t'background:none;box-shadow:none;border:none;padding:0;border-radius:0;';\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tonUpdate: (props: any) => {\n\t\t\t\t\t\t\t\tcomponent.updateProps({ ...props, renderItem, renderDropdown });\n\t\t\t\t\t\t\t\tif (!props.items?.length) {\n\t\t\t\t\t\t\t\t\tpopup[0]?.hide();\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tpopup[0]?.setProps({\n\t\t\t\t\t\t\t\t\tgetReferenceClientRect: props.clientRect,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tonKeyDown: (props: any) => {\n\t\t\t\t\t\t\t\tif (props.event.key === 'Escape') {\n\t\t\t\t\t\t\t\t\tpopup[0]?.hide();\n\t\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn (component.ref as any)?.onKeyDown(props) ?? false;\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tonExit: () => {\n\t\t\t\t\t\t\t\tpopup[0]?.destroy();\n\t\t\t\t\t\t\t\tcomponent.destroy();\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t};\n\t\t\t\t\t},\n\t\t\t\t}),\n\t\t\t];\n\t\t},\n\t});\n}\n"],"names":["buildSlashCommandExtension","commands","onSelect","renderItem","renderDropdown","Extension","create","name","addProseMirrorPlugins","Suggestion","editor","this","char","items","_ref","query","filter","c","label","toLowerCase","includes","slice","command","_ref2","range","props","chain","focus","deleteRange","run","render","component","popup","onStart","ReactRenderer","SlashCommandMenu","tippy","document","body","getReferenceClientRect","clientRect","appendTo","content","element","showOnCreate","interactive","trigger","placement","zIndex","arrow","onMount","instance","box","popper","querySelector","style","cssText","onUpdate","updateProps","Object","assign","_a","length","_c","setProps","_b","hide","onKeyDown","event","key","ref","onExit","destroy"],"mappings":"8OAWM,SAAUA,EACfC,EACAC,EACAC,EACAC,GAEA,OAAOC,EAAUC,OAAO,CACvBC,KAAM,eACNC,wBACC,MAAO,CACNC,EAAW,CACVC,OAAQC,KAAKD,OACbE,KAAM,IACNC,MAAOC,IAAA,IAACC,MAAEA,GAAYD,EAAA,OACrBb,EACEe,QAAQC,GACRA,EAAEC,MAAMC,cAAcC,SAASL,EAAMI,iBAErCE,MAAM,EAAG,GAAG,EACfC,QAASC,IAAkC,IAAjCb,OAAEA,EAAMc,MAAEA,EAAKC,MAAEA,GAAYF,EACtCb,EAAOgB,QAAQC,QAAQC,YAAYJ,GAAOK,MAC1C3B,SAAAA,EAAWuB,EAAM,EAElBK,OAAQA,KACP,IAAIC,EACAC,EAEJ,MAAO,CACNC,QAAUR,IACTM,EAAY,IAAIG,EAAcC,EAAkB,CAC/CV,qCAAYA,GAAK,CAAEtB,aAAYC,mBAC/BM,OAAQe,EAAMf,SAEfsB,EAAQI,EAAMC,SAASC,KAAM,CAC5BC,uBAAwBd,EAAMe,WAC9BC,SAAUA,IAAMJ,SAASC,KACzBI,QAASX,EAAUY,QACnBC,cAAc,EACdC,aAAa,EACbC,QAAS,SACTC,UAAW,eACXC,OAAQ,KACRC,OAAO,EAGPC,QAAUC,IACT,MAAMC,EACLD,EAASE,OAAOC,cAA2B,cACxCF,IACHA,EAAIG,MAAMC,QACT,yEAAwE,GAE1E,EAEHC,SAAWhC,cACVM,EAAU2B,YAAiBC,OAAAC,OAAAD,OAAAC,OAAA,CAAA,EAAAnC,IAAOtB,aAAYC,qBAC9B,QAAXyD,EAAApC,EAAMZ,aAAK,IAAAgD,OAAA,EAAAA,EAAEC,QAIV,QAARC,EAAA/B,EAAM,UAAE,IAAA+B,GAAAA,EAAEC,SAAS,CAClBzB,uBAAwBd,EAAMe,aAJpB,QAAVyB,EAAAjC,EAAM,UAAI,IAAAiC,GAAAA,EAAAC,MAKT,EAEHC,UAAY1C,cACX,MAAwB,WAApBA,EAAM2C,MAAMC,KACL,QAAVR,EAAA7B,EAAM,UAAI,IAAA6B,GAAAA,EAAAK,QACH,GAE2C,QAA5CH,EAAsB,QAAtBE,EAAClC,EAAUuC,WAAW,IAAAL,OAAA,EAAAA,EAAEE,UAAU1C,UAAU,IAAAsC,GAAAA,CAAK,EAEzDQ,OAAQA,WACG,QAAVV,EAAA7B,EAAM,UAAI,IAAA6B,GAAAA,EAAAW,UACVzC,EAAUyC,SAAS,EAEpB,IAIL,GAEF"}
@@ -1,2 +1,2 @@
1
- import{jsx as e,Fragment as n,jsxs as r}from"react/jsx-runtime";import{forwardRef as t,useState as o,useRef as l,useCallback as i,useImperativeHandle as c,useEffect as s}from"react";import{DropdownContainer as d,DropdownItem as m,SlashLabel as u,SlashDescription as a}from"../editorDropdown.styles.js";const h=t(((t,h)=>{let{items:p,query:y,command:g,renderItem:w,renderDropdown:f}=t;const[k,b]=o(0),j=l(null),D=i((e=>{const n=j.current;if(!n)return;const r=n.children[e];null==r||r.scrollIntoView({block:"nearest"})}),[]),v=e=>{p[e]&&g(p[e])};return c(h,(()=>({onKeyDown:e=>{let{event:n}=e;return!!p.length&&("ArrowUp"===n.key?(b((e=>{const n=(e+p.length-1)%p.length;return D(n),n})),!0):"ArrowDown"===n.key?(b((e=>{const n=(e+1)%p.length;return D(n),n})),!0):"Enter"===n.key&&(v(k),!0))}}))),s((()=>b(0)),[p]),p.length?f?e(n,{children:f({items:p,query:y,activeIndex:k,onSelect:e=>g(e)})}):e(d,Object.assign({ref:j},{children:p.map(((t,o)=>e(m,Object.assign({$isActive:o===k,onMouseEnter:()=>b(o),onClick:()=>v(o)},{children:w?w(t,o===k):r(n,{children:[e(u,{children:t.label}),t.description&&e(a,{children:t.description})]})}),t.id)))})):null}));h.displayName="SlashCommandMenu";export{h as SlashCommandMenu};
1
+ import{jsx as e,Fragment as n,jsxs as r}from"react/jsx-runtime";import{forwardRef as t,useState as o,useRef as l,useCallback as i,useImperativeHandle as c,useEffect as s}from"react";import{DropdownContainer as d,DropdownItem as m,SlashLabel as u,SlashDescription as a}from"../editorDropdown.styles.js";const h=t(((t,h)=>{let{items:p,query:y,command:w,renderItem:g,renderDropdown:f}=t;const[k,b]=o(0),j=l(null),D=i((e=>{const n=j.current;if(!n)return;const r=n.children[e];null==r||r.scrollIntoView({block:"nearest"})}),[]),v=e=>{p[e]&&w(p[e])};return c(h,(()=>({onKeyDown:e=>{let{event:n}=e;return"ArrowUp"===n.key?(b((e=>{const n=(e+p.length-1)%p.length;return D(n),n})),!0):"ArrowDown"===n.key?(b((e=>{const n=(e+1)%p.length;return D(n),n})),!0):"Enter"===n.key&&(v(k),!0)}}))),s((()=>b(0)),[p]),p.length?f?e(n,{children:f({items:p,query:y,activeIndex:k,onSelect:e=>w(e)})}):e(d,Object.assign({ref:j},{children:p.map(((t,o)=>e(m,Object.assign({$isActive:o===k,onMouseEnter:()=>b(o),onClick:()=>v(o)},{children:g?g(t,o===k):r(n,{children:[e(u,{children:t.label}),t.description&&e(a,{children:t.description})]})}),t.id)))})):null}));h.displayName="SlashCommandMenu";export{h as SlashCommandMenu};
2
2
  //# sourceMappingURL=SlashCommandMenu.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SlashCommandMenu.js","sources":["../../../../../src/editor/extensions/slashCommand/SlashCommandMenu.tsx"],"sourcesContent":["import React, {\n\tforwardRef,\n\tuseCallback,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseRef,\n\tuseState,\n} from 'react';\nimport type {\n\tSlashCommandDropdownRenderProps,\n\tSlashCommandItem,\n} from '../../BikEditor.types';\nimport {\n\tDropdownContainer,\n\tDropdownItem,\n\tSlashDescription,\n\tSlashLabel,\n} from '../editorDropdown.styles';\n\ninterface Props {\n\titems: SlashCommandItem[];\n\tquery: string;\n\tcommand: (item: SlashCommandItem) => void;\n\t/** Custom per-row renderer. Receives the item and whether it is the active row. */\n\trenderItem?: (item: SlashCommandItem, isActive: boolean) => React.ReactNode;\n\t/**\n\t * Full custom dropdown renderer. Takes priority over renderItem.\n\t * The editor passes activeIndex and onSelect — you handle all the visual rendering.\n\t */\n\trenderDropdown?: (props: SlashCommandDropdownRenderProps) => React.ReactNode;\n}\n\nexport const SlashCommandMenu = forwardRef<any, Props>(\n\t({ items, query, command, renderItem, renderDropdown }, ref) => {\n\t\tconst [selectedIndex, setSelectedIndex] = useState(0);\n\t\tconst containerRef = useRef<HTMLDivElement>(null);\n\n\t\tconst scrollToIndex = useCallback((index: number) => {\n\t\t\tconst container = containerRef.current;\n\t\t\tif (!container) return;\n\t\t\tconst item = container.children[index] as HTMLElement | undefined;\n\t\t\titem?.scrollIntoView({ block: 'nearest' });\n\t\t}, []);\n\n\t\tconst select = (i: number) => {\n\t\t\tif (items[i]) command(items[i]);\n\t\t};\n\n\t\tuseImperativeHandle(ref, () => ({\n\t\t\tonKeyDown: ({ event }: { event: KeyboardEvent }) => {\n\t\t\t\tif (!items.length) return false;\n\t\t\t\tif (event.key === 'ArrowUp') {\n\t\t\t\t\tsetSelectedIndex((prev) => {\n\t\t\t\t\t\tconst next = (prev + items.length - 1) % items.length;\n\t\t\t\t\t\tscrollToIndex(next);\n\t\t\t\t\t\treturn next;\n\t\t\t\t\t});\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif (event.key === 'ArrowDown') {\n\t\t\t\t\tsetSelectedIndex((prev) => {\n\t\t\t\t\t\tconst next = (prev + 1) % items.length;\n\t\t\t\t\t\tscrollToIndex(next);\n\t\t\t\t\t\treturn next;\n\t\t\t\t\t});\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif (event.key === 'Enter') {\n\t\t\t\t\tselect(selectedIndex);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t},\n\t\t}));\n\n\t\tuseEffect(() => setSelectedIndex(0), [items]);\n\n\t\tif (!items.length) return null;\n\n\t\t// Full custom dropdown — editor still manages keyboard nav via selectedIndex\n\t\tif (renderDropdown) {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t{renderDropdown({\n\t\t\t\t\t\titems,\n\t\t\t\t\t\tquery,\n\t\t\t\t\t\tactiveIndex: selectedIndex,\n\t\t\t\t\t\tonSelect: (item) => command(item),\n\t\t\t\t\t})}\n\t\t\t\t</>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<DropdownContainer ref={containerRef}>\n\t\t\t\t{items.map((item, i) => (\n\t\t\t\t\t<DropdownItem\n\t\t\t\t\t\tkey={item.id}\n\t\t\t\t\t\t$isActive={i === selectedIndex}\n\t\t\t\t\t\tonMouseEnter={() => setSelectedIndex(i)}\n\t\t\t\t\t\tonClick={() => select(i)}\n\t\t\t\t\t>\n\t\t\t\t\t\t{renderItem ? (\n\t\t\t\t\t\t\trenderItem(item, i === selectedIndex)\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<SlashLabel>{item.label}</SlashLabel>\n\t\t\t\t\t\t\t\t{item.description && (\n\t\t\t\t\t\t\t\t\t<SlashDescription>{item.description}</SlashDescription>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</DropdownItem>\n\t\t\t\t))}\n\t\t\t</DropdownContainer>\n\t\t);\n\t},\n);\nSlashCommandMenu.displayName = 'SlashCommandMenu';\n"],"names":["SlashCommandMenu","forwardRef","_ref","ref","items","query","command","renderItem","renderDropdown","selectedIndex","setSelectedIndex","useState","containerRef","useRef","scrollToIndex","useCallback","index","container","current","item","children","scrollIntoView","block","select","i","useImperativeHandle","onKeyDown","_ref2","event","length","key","prev","next","useEffect","_jsx","_Fragment","activeIndex","onSelect","DropdownContainer","Object","assign","map","DropdownItem","$isActive","onMouseEnter","onClick","_jsxs","SlashLabel","label","description","SlashDescription","id","displayName"],"mappings":"8SAgCO,MAAMA,EAAmBC,GAC/B,CAAAC,EAAwDC,KAAO,IAA9DC,MAAEA,EAAKC,MAAEA,EAAKC,QAAEA,EAAOC,WAAEA,EAAUC,eAAEA,GAAgBN,EACrD,MAAOO,EAAeC,GAAoBC,EAAS,GAC7CC,EAAeC,EAAuB,MAEtCC,EAAgBC,GAAaC,IAClC,MAAMC,EAAYL,EAAaM,QAC/B,IAAKD,EAAW,OAChB,MAAME,EAAOF,EAAUG,SAASJ,GAChCG,SAAAA,EAAME,eAAe,CAAEC,MAAO,WAAY,GACxC,IAEGC,EAAUC,IACXpB,EAAMoB,IAAIlB,EAAQF,EAAMoB,GAAG,EAgChC,OA7BAC,EAAoBtB,GAAK,KAAO,CAC/BuB,UAAWC,IAAwC,IAAvCC,MAAEA,GAAiCD,EAC9C,QAAKvB,EAAMyB,SACO,YAAdD,EAAME,KACTpB,GAAkBqB,IACjB,MAAMC,GAAQD,EAAO3B,EAAMyB,OAAS,GAAKzB,EAAMyB,OAE/C,OADAf,EAAckB,GACPA,CAAI,KAEL,GAEU,cAAdJ,EAAME,KACTpB,GAAkBqB,IACjB,MAAMC,GAAQD,EAAO,GAAK3B,EAAMyB,OAEhC,OADAf,EAAckB,GACPA,CAAI,KAEL,GAEU,UAAdJ,EAAME,MACTP,EAAOd,IACA,GAEI,MAIdwB,GAAU,IAAMvB,EAAiB,IAAI,CAACN,IAEjCA,EAAMyB,OAGPrB,EAEF0B,EACEC,EAAA,CAAAf,SAAAZ,EAAe,CACfJ,QACAC,QACA+B,YAAa3B,EACb4B,SAAWlB,GAASb,EAAQa,OAO/Be,EAACI,EAAiBC,OAAAC,OAAA,CAACrC,IAAKS,aACtBR,EAAMqC,KAAI,CAACtB,EAAMK,IACjBU,EAACQ,EAAYH,OAAAC,OAAA,CAAAG,UAEDnB,IAAMf,EACjBmC,aAAcA,IAAMlC,EAAiBc,GACrCqB,QAASA,IAAMtB,EAAOC,IAAE,CAAAJ,SAEvBb,EACAA,EAAWY,EAAMK,IAAMf,GAEvBqC,EACCX,EAAA,CAAAf,SAAA,CAAAc,EAACa,EAAY,CAAA3B,SAAAD,EAAK6B,QACjB7B,EAAK8B,aACLf,EAACgB,EAAkB,CAAA9B,SAAAD,EAAK8B,mBAXtB9B,EAAKgC,SApBY,IAqCL,IAIvBnD,EAAiBoD,YAAc"}
1
+ {"version":3,"file":"SlashCommandMenu.js","sources":["../../../../../src/editor/extensions/slashCommand/SlashCommandMenu.tsx"],"sourcesContent":["import React, {\n\tforwardRef,\n\tuseCallback,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseRef,\n\tuseState,\n} from 'react';\nimport type {\n\tSlashCommandDropdownRenderProps,\n\tSlashCommandItem,\n} from '../../BikEditor.types';\nimport {\n\tDropdownContainer,\n\tDropdownItem,\n\tSlashDescription,\n\tSlashLabel,\n} from '../editorDropdown.styles';\n\ninterface Props {\n\titems: SlashCommandItem[];\n\tquery: string;\n\tcommand: (item: SlashCommandItem) => void;\n\t/** Custom per-row renderer. Receives the item and whether it is the active row. */\n\trenderItem?: (item: SlashCommandItem, isActive: boolean) => React.ReactNode;\n\t/**\n\t * Full custom dropdown renderer. Takes priority over renderItem.\n\t * The editor passes activeIndex and onSelect — you handle all the visual rendering.\n\t */\n\trenderDropdown?: (props: SlashCommandDropdownRenderProps) => React.ReactNode;\n}\n\nexport const SlashCommandMenu = forwardRef<any, Props>(\n\t({ items, query, command, renderItem, renderDropdown }, ref) => {\n\t\tconst [selectedIndex, setSelectedIndex] = useState(0);\n\t\tconst containerRef = useRef<HTMLDivElement>(null);\n\n\t\tconst scrollToIndex = useCallback((index: number) => {\n\t\t\tconst container = containerRef.current;\n\t\t\tif (!container) return;\n\t\t\tconst item = container.children[index] as HTMLElement | undefined;\n\t\t\titem?.scrollIntoView({ block: 'nearest' });\n\t\t}, []);\n\n\t\tconst select = (i: number) => {\n\t\t\tif (items[i]) command(items[i]);\n\t\t};\n\n\t\tuseImperativeHandle(ref, () => ({\n\t\t\tonKeyDown: ({ event }: { event: KeyboardEvent }) => {\n\t\t\t\tif (event.key === 'ArrowUp') {\n\t\t\t\t\tsetSelectedIndex((prev) => {\n\t\t\t\t\t\tconst next = (prev + items.length - 1) % items.length;\n\t\t\t\t\t\tscrollToIndex(next);\n\t\t\t\t\t\treturn next;\n\t\t\t\t\t});\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif (event.key === 'ArrowDown') {\n\t\t\t\t\tsetSelectedIndex((prev) => {\n\t\t\t\t\t\tconst next = (prev + 1) % items.length;\n\t\t\t\t\t\tscrollToIndex(next);\n\t\t\t\t\t\treturn next;\n\t\t\t\t\t});\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\tif (event.key === 'Enter') {\n\t\t\t\t\tselect(selectedIndex);\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t},\n\t\t}));\n\n\t\tuseEffect(() => setSelectedIndex(0), [items]);\n\n\t\tif (!items.length) return null;\n\n\t\t// Full custom dropdown — editor still manages keyboard nav via selectedIndex\n\t\tif (renderDropdown) {\n\t\t\treturn (\n\t\t\t\t<>\n\t\t\t\t\t{renderDropdown({\n\t\t\t\t\t\titems,\n\t\t\t\t\t\tquery,\n\t\t\t\t\t\tactiveIndex: selectedIndex,\n\t\t\t\t\t\tonSelect: (item) => command(item),\n\t\t\t\t\t})}\n\t\t\t\t</>\n\t\t\t);\n\t\t}\n\n\t\treturn (\n\t\t\t<DropdownContainer ref={containerRef}>\n\t\t\t\t{items.map((item, i) => (\n\t\t\t\t\t<DropdownItem\n\t\t\t\t\t\tkey={item.id}\n\t\t\t\t\t\t$isActive={i === selectedIndex}\n\t\t\t\t\t\tonMouseEnter={() => setSelectedIndex(i)}\n\t\t\t\t\t\tonClick={() => select(i)}\n\t\t\t\t\t>\n\t\t\t\t\t\t{renderItem ? (\n\t\t\t\t\t\t\trenderItem(item, i === selectedIndex)\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t<SlashLabel>{item.label}</SlashLabel>\n\t\t\t\t\t\t\t\t{item.description && (\n\t\t\t\t\t\t\t\t\t<SlashDescription>{item.description}</SlashDescription>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</DropdownItem>\n\t\t\t\t))}\n\t\t\t</DropdownContainer>\n\t\t);\n\t},\n);\nSlashCommandMenu.displayName = 'SlashCommandMenu';\n"],"names":["SlashCommandMenu","forwardRef","_ref","ref","items","query","command","renderItem","renderDropdown","selectedIndex","setSelectedIndex","useState","containerRef","useRef","scrollToIndex","useCallback","index","container","current","item","children","scrollIntoView","block","select","i","useImperativeHandle","onKeyDown","_ref2","event","key","prev","next","length","useEffect","_jsx","_Fragment","activeIndex","onSelect","DropdownContainer","Object","assign","map","DropdownItem","$isActive","onMouseEnter","onClick","_jsxs","SlashLabel","label","description","SlashDescription","id","displayName"],"mappings":"8SAgCO,MAAMA,EAAmBC,GAC/B,CAAAC,EAAwDC,KAAO,IAA9DC,MAAEA,EAAKC,MAAEA,EAAKC,QAAEA,EAAOC,WAAEA,EAAUC,eAAEA,GAAgBN,EACrD,MAAOO,EAAeC,GAAoBC,EAAS,GAC7CC,EAAeC,EAAuB,MAEtCC,EAAgBC,GAAaC,IAClC,MAAMC,EAAYL,EAAaM,QAC/B,IAAKD,EAAW,OAChB,MAAME,EAAOF,EAAUG,SAASJ,GAChCG,SAAAA,EAAME,eAAe,CAAEC,MAAO,WAAY,GACxC,IAEGC,EAAUC,IACXpB,EAAMoB,IAAIlB,EAAQF,EAAMoB,GAAG,EA+BhC,OA5BAC,EAAoBtB,GAAK,KAAO,CAC/BuB,UAAWC,IAAwC,IAAvCC,MAAEA,GAAiCD,EAC9C,MAAkB,YAAdC,EAAMC,KACTnB,GAAkBoB,IACjB,MAAMC,GAAQD,EAAO1B,EAAM4B,OAAS,GAAK5B,EAAM4B,OAE/C,OADAlB,EAAciB,GACPA,CAAI,KAEL,GAEU,cAAdH,EAAMC,KACTnB,GAAkBoB,IACjB,MAAMC,GAAQD,EAAO,GAAK1B,EAAM4B,OAEhC,OADAlB,EAAciB,GACPA,CAAI,KAEL,GAEU,UAAdH,EAAMC,MACTN,EAAOd,IACA,EAEI,MAIdwB,GAAU,IAAMvB,EAAiB,IAAI,CAACN,IAEjCA,EAAM4B,OAGPxB,EAEF0B,EACEC,EAAA,CAAAf,SAAAZ,EAAe,CACfJ,QACAC,QACA+B,YAAa3B,EACb4B,SAAWlB,GAASb,EAAQa,OAO/Be,EAACI,EAAiBC,OAAAC,OAAA,CAACrC,IAAKS,aACtBR,EAAMqC,KAAI,CAACtB,EAAMK,IACjBU,EAACQ,EAAYH,OAAAC,OAAA,CAAAG,UAEDnB,IAAMf,EACjBmC,aAAcA,IAAMlC,EAAiBc,GACrCqB,QAASA,IAAMtB,EAAOC,IAAE,CAAAJ,SAEvBb,EACAA,EAAWY,EAAMK,IAAMf,GAEvBqC,EACCX,EAAA,CAAAf,SAAA,CAAAc,EAACa,EAAY,CAAA3B,SAAAD,EAAK6B,QACjB7B,EAAK8B,aACLf,EAACgB,EAAkB,CAAA9B,SAAAD,EAAK8B,mBAXtB9B,EAAKgC,SApBY,IAqCL,IAIvBnD,EAAiBoD,YAAc"}
@@ -1,2 +1,2 @@
1
- import{jsx as e,jsxs as n}from"react/jsx-runtime";import{useState as t,useRef as o,useCallback as r,useEffect as i}from"react";const l=l=>{let{editor:d,renderLinkTooltip:a}=l;const[s,c]=t(null),p=o(null),u=r((()=>c(null)),[]);if(i((()=>{const e=d.view.dom,n=n=>{var t,o,r;if(!e.contains(n.target))return;const i=n.target,l=i instanceof Element?i:i.parentElement,d=null!==(t=null==l?void 0:l.closest("a"))&&void 0!==t?t:null;d?(n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation(),c({href:null!==(o=d.getAttribute("href"))&&void 0!==o?o:"",text:null!==(r=d.textContent)&&void 0!==r?r:"",rect:d.getBoundingClientRect()})):u()},t=n=>{var t;const o=n.target;e.contains(o)||(null===(t=p.current)||void 0===t?void 0:t.contains(o))||u()},o=()=>u();return document.addEventListener("click",n,{capture:!0}),document.addEventListener("mousedown",t),e.addEventListener("keydown",o),()=>{document.removeEventListener("click",n,{capture:!0}),document.removeEventListener("mousedown",t),e.removeEventListener("keydown",o)}}),[d,u]),!s)return null;const{href:f,text:g,rect:v}=s,m=()=>window.open(f,"_blank","noopener,noreferrer"),b=()=>{d.chain().focus().extendMarkRange("link").unsetLink().run(),u()};return e("div",Object.assign({ref:p},{children:a?a({href:f,text:g,rect:v,onOpen:m,onRemove:b,onHide:u}):n("div",Object.assign({className:"bik-link-bubble",style:{position:"fixed",top:v.bottom+8,left:v.left,zIndex:9999,background:"#fff",border:"1px solid #dee2e6",borderRadius:6,boxShadow:"0 4px 12px rgba(0,0,0,0.15)",padding:"6px 10px",display:"flex",alignItems:"center",gap:8,fontSize:13}},{children:[n("span",Object.assign({style:{display:"inline-flex",alignItems:"center",gap:4,color:"#4f46e5",maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:[n("svg",Object.assign({width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2"},{children:[e("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),e("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})),f.length>40?f.slice(0,40)+"…":f]})),e("button",Object.assign({onMouseDown:e=>{e.preventDefault(),m()},style:{background:"none",border:"none",cursor:"pointer",padding:"2px 4px",fontSize:12,color:"#495057"}},{children:"Open ↗"})),e("span",Object.assign({style:{color:"#dee2e6"}},{children:"|"})),e("button",Object.assign({onMouseDown:e=>{e.preventDefault(),b()},style:{background:"none",border:"none",cursor:"pointer",padding:"2px 4px",fontSize:12,color:"#dc3545"}},{children:"Remove"}))]}))}))};export{l as LinkBubbleMenu};
1
+ import{jsx as e,jsxs as n}from"react/jsx-runtime";import{useState as t,useRef as o,useCallback as r,useEffect as i}from"react";const l=l=>{let{editor:d,renderLinkTooltip:s}=l;const[a,c]=t(null),p=o(null),u=r((()=>c(null)),[]);if(i((()=>{const e=d.view.dom,n=n=>{var t,o;if(!e.contains(n.target))return;const r=n.target.closest("a");r?(n.preventDefault(),n.stopPropagation(),n.stopImmediatePropagation(),c({href:null!==(t=r.getAttribute("href"))&&void 0!==t?t:"",text:null!==(o=r.textContent)&&void 0!==o?o:"",rect:r.getBoundingClientRect()})):u()},t=n=>{var t;const o=n.target;e.contains(o)||(null===(t=p.current)||void 0===t?void 0:t.contains(o))||u()},o=()=>u();return document.addEventListener("click",n,{capture:!0}),document.addEventListener("mousedown",t),e.addEventListener("keydown",o),()=>{document.removeEventListener("click",n,{capture:!0}),document.removeEventListener("mousedown",t),e.removeEventListener("keydown",o)}}),[d,u]),!a)return null;const{href:g,text:f,rect:v}=a,b=()=>window.open(g,"_blank","noopener,noreferrer"),m=()=>{d.chain().focus().extendMarkRange("link").unsetLink().run(),u()};return e("div",Object.assign({ref:p},{children:s?s({href:g,text:f,rect:v,onOpen:b,onRemove:m,onHide:u}):n("div",Object.assign({className:"bik-link-bubble",style:{position:"fixed",top:v.bottom+8,left:v.left,zIndex:9999,background:"#fff",border:"1px solid #dee2e6",borderRadius:6,boxShadow:"0 4px 12px rgba(0,0,0,0.15)",padding:"6px 10px",display:"flex",alignItems:"center",gap:8,fontSize:13}},{children:[n("span",Object.assign({style:{display:"inline-flex",alignItems:"center",gap:4,color:"#4f46e5",maxWidth:220,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},{children:[n("svg",Object.assign({width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2"},{children:[e("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),e("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})),g.length>40?g.slice(0,40)+"…":g]})),e("button",Object.assign({onMouseDown:e=>{e.preventDefault(),b()},style:{background:"none",border:"none",cursor:"pointer",padding:"2px 4px",fontSize:12,color:"#495057"}},{children:"Open ↗"})),e("span",Object.assign({style:{color:"#dee2e6"}},{children:"|"})),e("button",Object.assign({onMouseDown:e=>{e.preventDefault(),m()},style:{background:"none",border:"none",cursor:"pointer",padding:"2px 4px",fontSize:12,color:"#dc3545"}},{children:"Remove"}))]}))}))};export{l as LinkBubbleMenu};
2
2
  //# sourceMappingURL=LinkBubbleMenu.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"LinkBubbleMenu.js","sources":["../../../../src/editor/floating/LinkBubbleMenu.tsx"],"sourcesContent":["import { Editor } from '@tiptap/core';\nimport React, { useCallback, useEffect, useRef, useState } from 'react';\nimport type { LinkTooltipProps } from '../BikEditor.types';\n\ninterface Props {\n\teditor: Editor;\n\trenderLinkTooltip?: (props: LinkTooltipProps) => React.ReactNode;\n}\n\ninterface LinkState {\n\thref: string;\n\ttext: string;\n\trect: DOMRect;\n}\n\n/**\n * Shows a tooltip when the user **clicks** a hyperlink inside the editor.\n * Hides on click outside the editor/bubble or on any keypress.\n * Does NOT trigger on cursor movement or keyboard navigation.\n */\nexport const LinkBubbleMenu: React.FC<Props> = ({\n\teditor,\n\trenderLinkTooltip,\n}) => {\n\tconst [link, setLink] = useState<LinkState | null>(null);\n\tconst bubbleRef = useRef<HTMLDivElement>(null);\n\n\tconst hide = useCallback(() => setLink(null), []);\n\n\tuseEffect(() => {\n\t\tconst dom = editor.view.dom;\n\n\t\t// Use document-level capture so we fire before ANY other listener on the\n\t\t// page — ProseMirror, browser defaults, and Storybook iframes included.\n\t\tconst handleCaptureClick = (e: MouseEvent) => {\n\t\t\t// Only act on clicks that land inside the editor\n\t\t\tif (!dom.contains(e.target as Node)) return;\n\n\t\t\tconst target = e.target as Node;\n\t\t\tconst el = target instanceof Element ? target : target.parentElement;\n\t\t\tconst linkEl = el?.closest('a') ?? null;\n\t\t\tif (!linkEl) {\n\t\t\t\thide();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Prevent browser href navigation\n\t\t\te.preventDefault();\n\t\t\t// Prevent the event reaching ProseMirror's bubble-phase handlers\n\t\t\te.stopPropagation();\n\t\t\te.stopImmediatePropagation();\n\n\t\t\tsetLink({\n\t\t\t\thref: linkEl.getAttribute('href') ?? '',\n\t\t\t\ttext: linkEl.textContent ?? '',\n\t\t\t\trect: linkEl.getBoundingClientRect(),\n\t\t\t});\n\t\t};\n\n\t\t// Hide when clicking outside both the editor and the bubble\n\t\tconst handleDocumentMousedown = (e: MouseEvent) => {\n\t\t\tconst target = e.target as Node;\n\t\t\tif (!dom.contains(target) && !bubbleRef.current?.contains(target)) {\n\t\t\t\thide();\n\t\t\t}\n\t\t};\n\n\t\t// Hide on any keypress — user is typing or navigating away\n\t\tconst handleKeyDown = () => hide();\n\n\t\t// { capture: true } on document — fires before every other listener\n\t\tdocument.addEventListener('click', handleCaptureClick, { capture: true });\n\t\tdocument.addEventListener('mousedown', handleDocumentMousedown);\n\t\tdom.addEventListener('keydown', handleKeyDown);\n\n\t\treturn () => {\n\t\t\tdocument.removeEventListener('click', handleCaptureClick, {\n\t\t\t\tcapture: true,\n\t\t\t});\n\t\t\tdocument.removeEventListener('mousedown', handleDocumentMousedown);\n\t\t\tdom.removeEventListener('keydown', handleKeyDown);\n\t\t};\n\t}, [editor, hide]);\n\n\tif (!link) return null;\n\n\tconst { href, text, rect } = link;\n\n\tconst onOpen = () => window.open(href, '_blank', 'noopener,noreferrer');\n\tconst onRemove = () => {\n\t\teditor.chain().focus().extendMarkRange('link').unsetLink().run();\n\t\thide();\n\t};\n\n\t// The <div ref={bubbleRef}> wrapper is what we check for outside-click detection.\n\t// Consumer tooltips use position:fixed internally but remain DOM descendants of\n\t// this wrapper, so bubbleRef.contains() correctly identifies clicks inside them.\n\treturn (\n\t\t<div ref={bubbleRef}>\n\t\t\t{renderLinkTooltip ? (\n\t\t\t\trenderLinkTooltip({ href, text, rect, onOpen, onRemove, onHide: hide })\n\t\t\t) : (\n\t\t\t\t// Built-in fallback: shows href + Open + Remove.\n\t\t\t\t// Use renderLinkTooltip to add an Edit button or custom styling.\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"bik-link-bubble\"\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tposition: 'fixed',\n\t\t\t\t\t\ttop: rect.bottom + 8,\n\t\t\t\t\t\tleft: rect.left,\n\t\t\t\t\t\tzIndex: 9999,\n\t\t\t\t\t\tbackground: '#fff',\n\t\t\t\t\t\tborder: '1px solid #dee2e6',\n\t\t\t\t\t\tborderRadius: 6,\n\t\t\t\t\t\tboxShadow: '0 4px 12px rgba(0,0,0,0.15)',\n\t\t\t\t\t\tpadding: '6px 10px',\n\t\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\t\talignItems: 'center',\n\t\t\t\t\t\tgap: 8,\n\t\t\t\t\t\tfontSize: 13,\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<span\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tdisplay: 'inline-flex',\n\t\t\t\t\t\t\talignItems: 'center',\n\t\t\t\t\t\t\tgap: 4,\n\t\t\t\t\t\t\tcolor: '#4f46e5',\n\t\t\t\t\t\t\tmaxWidth: 220,\n\t\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t\t\ttextOverflow: 'ellipsis',\n\t\t\t\t\t\t\twhiteSpace: 'nowrap',\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\twidth=\"14\"\n\t\t\t\t\t\t\theight=\"14\"\n\t\t\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\t\t\tfill=\"none\"\n\t\t\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\t\t\tstrokeWidth=\"2\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<path d=\"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71\" />\n\t\t\t\t\t\t\t<path d=\"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71\" />\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t{href.length > 40 ? href.slice(0, 40) + '…' : href}\n\t\t\t\t\t</span>\n\t\t\t\t\t<button\n\t\t\t\t\t\tonMouseDown={(e) => {\n\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\tonOpen();\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tbackground: 'none',\n\t\t\t\t\t\t\tborder: 'none',\n\t\t\t\t\t\t\tcursor: 'pointer',\n\t\t\t\t\t\t\tpadding: '2px 4px',\n\t\t\t\t\t\t\tfontSize: 12,\n\t\t\t\t\t\t\tcolor: '#495057',\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\tOpen ↗\n\t\t\t\t\t</button>\n\t\t\t\t\t<span style={{ color: '#dee2e6' }}>|</span>\n\t\t\t\t\t<button\n\t\t\t\t\t\tonMouseDown={(e) => {\n\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\tonRemove();\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tbackground: 'none',\n\t\t\t\t\t\t\tborder: 'none',\n\t\t\t\t\t\t\tcursor: 'pointer',\n\t\t\t\t\t\t\tpadding: '2px 4px',\n\t\t\t\t\t\t\tfontSize: 12,\n\t\t\t\t\t\t\tcolor: '#dc3545',\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\tRemove\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n"],"names":["LinkBubbleMenu","_ref","editor","renderLinkTooltip","link","setLink","useState","bubbleRef","useRef","hide","useCallback","useEffect","dom","view","handleCaptureClick","e","contains","target","el","Element","parentElement","linkEl","_a","closest","preventDefault","stopPropagation","stopImmediatePropagation","href","getAttribute","_b","text","_c","textContent","rect","getBoundingClientRect","handleDocumentMousedown","current","handleKeyDown","document","addEventListener","capture","removeEventListener","onOpen","window","open","onRemove","chain","focus","extendMarkRange","unsetLink","run","_jsx","Object","assign","ref","children","onHide","_jsxs","className","style","position","top","bottom","left","zIndex","background","border","borderRadius","boxShadow","padding","display","alignItems","gap","fontSize","color","maxWidth","overflow","textOverflow","whiteSpace","width","height","viewBox","fill","stroke","strokeWidth","d","length","slice","onMouseDown","cursor"],"mappings":"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"}
1
+ {"version":3,"file":"LinkBubbleMenu.js","sources":["../../../../src/editor/floating/LinkBubbleMenu.tsx"],"sourcesContent":["import { Editor } from '@tiptap/core';\nimport React, { useCallback, useEffect, useRef, useState } from 'react';\nimport type { LinkTooltipProps } from '../BikEditor.types';\n\ninterface Props {\n\teditor: Editor;\n\trenderLinkTooltip?: (props: LinkTooltipProps) => React.ReactNode;\n}\n\ninterface LinkState {\n\thref: string;\n\ttext: string;\n\trect: DOMRect;\n}\n\n/**\n * Shows a tooltip when the user **clicks** a hyperlink inside the editor.\n * Hides on click outside the editor/bubble or on any keypress.\n * Does NOT trigger on cursor movement or keyboard navigation.\n */\nexport const LinkBubbleMenu: React.FC<Props> = ({\n\teditor,\n\trenderLinkTooltip,\n}) => {\n\tconst [link, setLink] = useState<LinkState | null>(null);\n\tconst bubbleRef = useRef<HTMLDivElement>(null);\n\n\tconst hide = useCallback(() => setLink(null), []);\n\n\tuseEffect(() => {\n\t\tconst dom = editor.view.dom;\n\n\t\t// Use document-level capture so we fire before ANY other listener on the\n\t\t// page — ProseMirror, browser defaults, and Storybook iframes included.\n\t\tconst handleCaptureClick = (e: MouseEvent) => {\n\t\t\t// Only act on clicks that land inside the editor\n\t\t\tif (!dom.contains(e.target as Node)) return;\n\n\t\t\tconst linkEl = (e.target as Element).closest('a');\n\t\t\tif (!linkEl) {\n\t\t\t\thide();\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Prevent browser href navigation\n\t\t\te.preventDefault();\n\t\t\t// Prevent the event reaching ProseMirror's bubble-phase handlers\n\t\t\te.stopPropagation();\n\t\t\te.stopImmediatePropagation();\n\n\t\t\tsetLink({\n\t\t\t\thref: linkEl.getAttribute('href') ?? '',\n\t\t\t\ttext: linkEl.textContent ?? '',\n\t\t\t\trect: linkEl.getBoundingClientRect(),\n\t\t\t});\n\t\t};\n\n\t\t// Hide when clicking outside both the editor and the bubble\n\t\tconst handleDocumentMousedown = (e: MouseEvent) => {\n\t\t\tconst target = e.target as Node;\n\t\t\tif (!dom.contains(target) && !bubbleRef.current?.contains(target)) {\n\t\t\t\thide();\n\t\t\t}\n\t\t};\n\n\t\t// Hide on any keypress — user is typing or navigating away\n\t\tconst handleKeyDown = () => hide();\n\n\t\t// { capture: true } on document — fires before every other listener\n\t\tdocument.addEventListener('click', handleCaptureClick, { capture: true });\n\t\tdocument.addEventListener('mousedown', handleDocumentMousedown);\n\t\tdom.addEventListener('keydown', handleKeyDown);\n\n\t\treturn () => {\n\t\t\tdocument.removeEventListener('click', handleCaptureClick, {\n\t\t\t\tcapture: true,\n\t\t\t});\n\t\t\tdocument.removeEventListener('mousedown', handleDocumentMousedown);\n\t\t\tdom.removeEventListener('keydown', handleKeyDown);\n\t\t};\n\t}, [editor, hide]);\n\n\tif (!link) return null;\n\n\tconst { href, text, rect } = link;\n\n\tconst onOpen = () => window.open(href, '_blank', 'noopener,noreferrer');\n\tconst onRemove = () => {\n\t\teditor.chain().focus().extendMarkRange('link').unsetLink().run();\n\t\thide();\n\t};\n\n\t// The <div ref={bubbleRef}> wrapper is what we check for outside-click detection.\n\t// Consumer tooltips use position:fixed internally but remain DOM descendants of\n\t// this wrapper, so bubbleRef.contains() correctly identifies clicks inside them.\n\treturn (\n\t\t<div ref={bubbleRef}>\n\t\t\t{renderLinkTooltip ? (\n\t\t\t\trenderLinkTooltip({ href, text, rect, onOpen, onRemove, onHide: hide })\n\t\t\t) : (\n\t\t\t\t// Built-in fallback: shows href + Open + Remove.\n\t\t\t\t// Use renderLinkTooltip to add an Edit button or custom styling.\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"bik-link-bubble\"\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\tposition: 'fixed',\n\t\t\t\t\t\ttop: rect.bottom + 8,\n\t\t\t\t\t\tleft: rect.left,\n\t\t\t\t\t\tzIndex: 9999,\n\t\t\t\t\t\tbackground: '#fff',\n\t\t\t\t\t\tborder: '1px solid #dee2e6',\n\t\t\t\t\t\tborderRadius: 6,\n\t\t\t\t\t\tboxShadow: '0 4px 12px rgba(0,0,0,0.15)',\n\t\t\t\t\t\tpadding: '6px 10px',\n\t\t\t\t\t\tdisplay: 'flex',\n\t\t\t\t\t\talignItems: 'center',\n\t\t\t\t\t\tgap: 8,\n\t\t\t\t\t\tfontSize: 13,\n\t\t\t\t\t}}\n\t\t\t\t>\n\t\t\t\t\t<span\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tdisplay: 'inline-flex',\n\t\t\t\t\t\t\talignItems: 'center',\n\t\t\t\t\t\t\tgap: 4,\n\t\t\t\t\t\t\tcolor: '#4f46e5',\n\t\t\t\t\t\t\tmaxWidth: 220,\n\t\t\t\t\t\t\toverflow: 'hidden',\n\t\t\t\t\t\t\ttextOverflow: 'ellipsis',\n\t\t\t\t\t\t\twhiteSpace: 'nowrap',\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t<svg\n\t\t\t\t\t\t\twidth=\"14\"\n\t\t\t\t\t\t\theight=\"14\"\n\t\t\t\t\t\t\tviewBox=\"0 0 24 24\"\n\t\t\t\t\t\t\tfill=\"none\"\n\t\t\t\t\t\t\tstroke=\"currentColor\"\n\t\t\t\t\t\t\tstrokeWidth=\"2\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<path d=\"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71\" />\n\t\t\t\t\t\t\t<path d=\"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71\" />\n\t\t\t\t\t\t</svg>\n\t\t\t\t\t\t{href.length > 40 ? href.slice(0, 40) + '…' : href}\n\t\t\t\t\t</span>\n\t\t\t\t\t<button\n\t\t\t\t\t\tonMouseDown={(e) => {\n\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\tonOpen();\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tbackground: 'none',\n\t\t\t\t\t\t\tborder: 'none',\n\t\t\t\t\t\t\tcursor: 'pointer',\n\t\t\t\t\t\t\tpadding: '2px 4px',\n\t\t\t\t\t\t\tfontSize: 12,\n\t\t\t\t\t\t\tcolor: '#495057',\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\tOpen ↗\n\t\t\t\t\t</button>\n\t\t\t\t\t<span style={{ color: '#dee2e6' }}>|</span>\n\t\t\t\t\t<button\n\t\t\t\t\t\tonMouseDown={(e) => {\n\t\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\t\tonRemove();\n\t\t\t\t\t\t}}\n\t\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\tbackground: 'none',\n\t\t\t\t\t\t\tborder: 'none',\n\t\t\t\t\t\t\tcursor: 'pointer',\n\t\t\t\t\t\t\tpadding: '2px 4px',\n\t\t\t\t\t\t\tfontSize: 12,\n\t\t\t\t\t\t\tcolor: '#dc3545',\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\tRemove\n\t\t\t\t\t</button>\n\t\t\t\t</div>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n"],"names":["LinkBubbleMenu","_ref","editor","renderLinkTooltip","link","setLink","useState","bubbleRef","useRef","hide","useCallback","useEffect","dom","view","handleCaptureClick","e","contains","target","linkEl","closest","preventDefault","stopPropagation","stopImmediatePropagation","href","getAttribute","_a","text","_b","textContent","rect","getBoundingClientRect","handleDocumentMousedown","current","handleKeyDown","document","addEventListener","capture","removeEventListener","onOpen","window","open","onRemove","chain","focus","extendMarkRange","unsetLink","run","_jsx","Object","assign","ref","children","onHide","_jsxs","className","style","position","top","bottom","left","zIndex","background","border","borderRadius","boxShadow","padding","display","alignItems","gap","fontSize","color","maxWidth","overflow","textOverflow","whiteSpace","width","height","viewBox","fill","stroke","strokeWidth","d","length","slice","onMouseDown","cursor"],"mappings":"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"}
@@ -1,2 +1,2 @@
1
- import{jsxs as e,jsx as t,Fragment as l}from"react/jsx-runtime";const i=i=>{let{editorRef:o,activeFormats:r,showBold:s=!0,showItalic:a=!0,showUnderline:c=!0,showStrike:d=!0,showLink:b=!0,showLists:g=!0,showAlignment:v=!1,showFontPicker:u=!1,onLinkButtonClick:h}=i;var k;const P=null===(k=o.current)||void 0===k?void 0:k.actions;return P?e("div",Object.assign({className:"bik-editor-toolbar"},{children:[s&&t(n,{active:r.bold,onPress:P.toggleBold,label:"Bold"}),a&&t(n,{active:r.italic,onPress:P.toggleItalic,label:"Italic"}),c&&t(n,{active:r.underline,onPress:P.toggleUnderline,label:"Underline"}),d&&t(n,{active:r.strike,onPress:P.toggleStrike,label:"Strike"}),b&&t(n,{active:!!r.link,onPress:()=>{var e,t,l,i;const n=null!==(t=null===(e=o.current)||void 0===e?void 0:e.getSelectedText())&&void 0!==t?t:"",s=null!==(i=null===(l=r.link)||void 0===l?void 0:l.href)&&void 0!==i?i:null;null==h||h(n,s)},label:"Link"}),g&&e(l,{children:[t(n,{active:r.bulletList,onPress:P.toggleBulletList,label:"Bullet"}),t(n,{active:r.orderedList,onPress:P.toggleOrderedList,label:"Ordered"})]}),v&&e(l,{children:[t(n,{active:"left"===r.textAlign,onPress:()=>P.setTextAlign("left"),label:"Left"}),t(n,{active:"center"===r.textAlign,onPress:()=>P.setTextAlign("center"),label:"Center"}),t(n,{active:"right"===r.textAlign,onPress:()=>P.setTextAlign("right"),label:"Right"})]})]})):null},n=e=>{let{active:l,onPress:i,label:n}=e;return t("button",Object.assign({type:"button",title:n,className:"bik-toolbar-btn"+(l?" bik-toolbar-btn--active":""),onMouseDown:e=>{e.preventDefault(),i()}},{children:n}))};export{i as BikEditorToolbar};
1
+ import{jsxs as e,jsx as t,Fragment as l}from"react/jsx-runtime";const i=i=>{let{editorRef:o,activeFormats:r,showBold:s=!0,showItalic:a=!0,showUnderline:c=!0,showStrike:d=!0,showLink:b=!0,showLists:g=!0,showAlignment:v=!1,showFontPicker:u=!1,onLinkButtonClick:h}=i;var k;const P=null===(k=o.current)||void 0===k?void 0:k.actions;return P?e("div",Object.assign({className:"bik-editor-toolbar"},{children:[s&&t(n,{active:r.bold,onPress:P.toggleBold,label:"Bold"}),a&&t(n,{active:r.italic,onPress:P.toggleItalic,label:"Italic"}),c&&t(n,{active:r.underline,onPress:P.toggleUnderline,label:"Underline"}),d&&t(n,{active:r.strike,onPress:P.toggleStrike,label:"Strike"}),b&&t(n,{active:!!r.link,onPress:()=>{var e,t,l,i;const n=null!==(t=null===(e=o.current)||void 0===e?void 0:e.getSelectedText())&&void 0!==t?t:"",s=null!==(i=null===(l=r.link)||void 0===l?void 0:l.href)&&void 0!==i?i:null;null==h||h(n,s)},label:"Link"}),g&&e(l,{children:[t(n,{active:r.bulletList,onPress:P.toggleBulletList,label:"Bullet"}),t(n,{active:r.orderedList,onPress:P.toggleOrderedList,label:"Ordered"})]}),v&&e(l,{children:[t(n,{active:"left"===r.textAlign,onPress:()=>P.setTextAlign("left"),label:"Left"}),t(n,{active:"center"===r.textAlign,onPress:()=>P.setTextAlign("center"),label:"Center"}),t(n,{active:"right"===r.textAlign,onPress:()=>P.setTextAlign("right"),label:"Right"})]})]})):null},n=e=>{let{active:l,onPress:i,label:n}=e;return t("button",Object.assign({type:"button",title:n,className:"bik-toolbar-btn"+(l?" bik-toolbar-btn--active":""),onMouseDown:e=>{e.preventDefault(),i()}},{children:n}))};export{i as BikEditorToolbar};
2
2
  //# sourceMappingURL=BikEditorToolbar.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BikEditorToolbar.js","sources":["../../../../src/editor/toolbar/BikEditorToolbar.tsx"],"sourcesContent":["import React from 'react';\nimport type { BikEditorRef, FormatState } from '../BikEditor.types';\n\n/**\n * Props for `<BikEditorToolbar />`.\n *\n * All `show*` props default to `true` except `showAlignment`, `showFontPicker`,\n * and `showColorPicker` which default to `false`.\n */\ninterface Props {\n\t/** The same ref you passed to `<BikEditor ref={...} />`. Required. */\n\teditorRef: React.RefObject<BikEditorRef>;\n\t/**\n\t * Active format snapshot. Keep this in state, updated via `onSelectionChange`.\n\t *\n\t * @example\n\t * const [formats, setFormats] = useState(DEFAULT_ACTIVE_FORMATS);\n\t * <BikEditor onSelectionChange={setFormats} ... />\n\t * <BikEditorToolbar activeFormats={formats} ... />\n\t */\n\tactiveFormats: FormatState;\n\t/** Show the Bold button. Default `true`. */\n\tshowBold?: boolean;\n\t/** Show the Italic button. Default `true`. */\n\tshowItalic?: boolean;\n\t/** Show the Underline button. Default `true`. */\n\tshowUnderline?: boolean;\n\t/** Show the Strikethrough button. Default `true`. */\n\tshowStrike?: boolean;\n\t/** Show the Link button. Default `true`. */\n\tshowLink?: boolean;\n\t/** Show Bullet and Ordered list buttons. Default `true`. */\n\tshowLists?: boolean;\n\t/** Show Left / Center / Right alignment buttons. Default `false`. */\n\tshowAlignment?: boolean;\n\t/** Reserved — renders nothing yet. Default `false`. */\n\tshowFontPicker?: boolean;\n\t/** Reserved — renders nothing yet. Default `false`. */\n\tshowColorPicker?: boolean;\n\t/**\n\t * Called when the user clicks the Link button.\n\t *\n\t * - `selectedText` — the selected text, or the full text of the link the cursor\n\t * is already inside (useful for pre-filling the \"Text\" field of your modal).\n\t * - `currentHref` — non-null when the cursor is inside an existing link\n\t * (useful for pre-filling the \"URL\" field).\n\t *\n\t * After the user saves, call `editorRef.current?.actions.setLink(href, text)`.\n\t */\n\tonLinkButtonClick?: (\n\t\tselectedText: string,\n\t\tcurrentHref: string | null,\n\t) => void;\n}\n\nexport const BikEditorToolbar: React.FC<Props> = ({\n\teditorRef,\n\tactiveFormats,\n\tshowBold = true,\n\tshowItalic = true,\n\tshowUnderline = true,\n\tshowStrike = true,\n\tshowLink = true,\n\tshowLists = true,\n\tshowAlignment = false,\n\tshowFontPicker = false,\n\tonLinkButtonClick,\n}) => {\n\tconst act = editorRef.current?.actions;\n\tif (!act) return null;\n\n\treturn (\n\t\t<div className=\"bik-editor-toolbar\">\n\t\t\t{showBold && (\n\t\t\t\t<Btn\n\t\t\t\t\tactive={activeFormats.bold}\n\t\t\t\t\tonPress={act.toggleBold}\n\t\t\t\t\tlabel=\"Bold\"\n\t\t\t\t/>\n\t\t\t)}\n\t\t\t{showItalic && (\n\t\t\t\t<Btn\n\t\t\t\t\tactive={activeFormats.italic}\n\t\t\t\t\tonPress={act.toggleItalic}\n\t\t\t\t\tlabel=\"Italic\"\n\t\t\t\t/>\n\t\t\t)}\n\t\t\t{showUnderline && (\n\t\t\t\t<Btn\n\t\t\t\t\tactive={activeFormats.underline}\n\t\t\t\t\tonPress={act.toggleUnderline}\n\t\t\t\t\tlabel=\"Underline\"\n\t\t\t\t/>\n\t\t\t)}\n\t\t\t{showStrike && (\n\t\t\t\t<Btn\n\t\t\t\t\tactive={activeFormats.strike}\n\t\t\t\t\tonPress={act.toggleStrike}\n\t\t\t\t\tlabel=\"Strike\"\n\t\t\t\t/>\n\t\t\t)}\n\t\t\t{showLink && (\n\t\t\t\t<Btn\n\t\t\t\t\tactive={!!activeFormats.link}\n\t\t\t\t\tonPress={() => {\n\t\t\t\t\t\tconst selectedText = editorRef.current?.getSelectedText() ?? '';\n\t\t\t\t\t\tconst currentHref = activeFormats.link?.href ?? null;\n\t\t\t\t\t\tonLinkButtonClick?.(selectedText, currentHref);\n\t\t\t\t\t}}\n\t\t\t\t\tlabel=\"Link\"\n\t\t\t\t/>\n\t\t\t)}\n\t\t\t{showLists && (\n\t\t\t\t<>\n\t\t\t\t\t<Btn\n\t\t\t\t\t\tactive={activeFormats.bulletList}\n\t\t\t\t\t\tonPress={act.toggleBulletList}\n\t\t\t\t\t\tlabel=\"Bullet\"\n\t\t\t\t\t/>\n\t\t\t\t\t<Btn\n\t\t\t\t\t\tactive={activeFormats.orderedList}\n\t\t\t\t\t\tonPress={act.toggleOrderedList}\n\t\t\t\t\t\tlabel=\"Ordered\"\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t)}\n\t\t\t{showAlignment && (\n\t\t\t\t<>\n\t\t\t\t\t<Btn\n\t\t\t\t\t\tactive={activeFormats.textAlign === 'left'}\n\t\t\t\t\t\tonPress={() => act.setTextAlign('left')}\n\t\t\t\t\t\tlabel=\"Left\"\n\t\t\t\t\t/>\n\t\t\t\t\t<Btn\n\t\t\t\t\t\tactive={activeFormats.textAlign === 'center'}\n\t\t\t\t\t\tonPress={() => act.setTextAlign('center')}\n\t\t\t\t\t\tlabel=\"Center\"\n\t\t\t\t\t/>\n\t\t\t\t\t<Btn\n\t\t\t\t\t\tactive={activeFormats.textAlign === 'right'}\n\t\t\t\t\t\tonPress={() => act.setTextAlign('right')}\n\t\t\t\t\t\tlabel=\"Right\"\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n\nconst Btn: React.FC<{\n\tactive: boolean;\n\tonPress: () => void;\n\tlabel: string;\n}> = ({ active, onPress, label }) => (\n\t<button\n\t\ttype=\"button\"\n\t\ttitle={label}\n\t\tclassName={`bik-toolbar-btn${active ? ' bik-toolbar-btn--active' : ''}`}\n\t\tonMouseDown={(e) => {\n\t\t\te.preventDefault();\n\t\t\tonPress();\n\t\t}}\n\t>\n\t\t{label}\n\t</button>\n);\n"],"names":["BikEditorToolbar","_ref","editorRef","activeFormats","showBold","showItalic","showUnderline","showStrike","showLink","showLists","showAlignment","showFontPicker","onLinkButtonClick","act","_a","current","actions","_jsxs","Object","assign","className","children","_jsx","Btn","active","bold","onPress","toggleBold","label","italic","toggleItalic","underline","toggleUnderline","strike","toggleStrike","link","selectedText","_b","getSelectedText","currentHref","_d","_c","href","_Fragment","bulletList","toggleBulletList","orderedList","toggleOrderedList","textAlign","setTextAlign","_ref2","type","title","onMouseDown","e","preventDefault"],"mappings":"gEAuDaA,MAAAA,EAAoCC,IAY5C,IAZ6CC,UACjDA,EAASC,cACTA,EAAaC,SACbA,GAAW,EAAIC,WACfA,GAAa,EAAIC,cACjBA,GAAgB,EAAIC,WACpBA,GAAa,EAAIC,SACjBA,GAAW,EAAIC,UACfA,GAAY,EAAIC,cAChBA,GAAgB,EAAKC,eACrBA,GAAiB,EAAKC,kBACtBA,GACAX,QACA,MAAMY,EAAuB,QAAjBC,EAAAZ,EAAUa,eAAO,IAAAD,OAAA,EAAAA,EAAEE,QAC/B,OAAKH,EAGJI,EAAK,MAAAC,OAAAC,OAAA,CAAAC,UAAU,sBACb,CAAAC,SAAA,CAAAjB,GACAkB,EAACC,EACA,CAAAC,OAAQrB,EAAcsB,KACtBC,QAASb,EAAIc,WACbC,MAAM,SAGPvB,GACAiB,EAACC,EACA,CAAAC,OAAQrB,EAAc0B,OACtBH,QAASb,EAAIiB,aACbF,MAAM,WAGPtB,GACAgB,EAACC,GACAC,OAAQrB,EAAc4B,UACtBL,QAASb,EAAImB,gBACbJ,MAAM,cAGPrB,GACAe,EAACC,EAAG,CACHC,OAAQrB,EAAc8B,OACtBP,QAASb,EAAIqB,aACbN,MAAM,WAGPpB,GACAc,EAACC,EACA,CAAAC,SAAUrB,EAAcgC,KACxBT,QAASA,iBACR,MAAMU,EAAuD,QAAxCC,EAAiB,QAAjBvB,EAAAZ,EAAUa,eAAO,IAAAD,OAAA,EAAAA,EAAEwB,yBAAqB,IAAAD,EAAAA,EAAA,GACvDE,EAA0C,QAA5BC,EAAoB,QAApBC,EAAAtC,EAAcgC,YAAM,IAAAM,OAAA,EAAAA,EAAAC,YAAQ,IAAAF,EAAAA,EAAA,KAChD5B,SAAAA,EAAoBwB,EAAcG,EAAY,EAE/CX,MAAM,SAGPnB,GACAQ,EAAA0B,EAAA,CAAAtB,SAAA,CACCC,EAACC,GACAC,OAAQrB,EAAcyC,WACtBlB,QAASb,EAAIgC,iBACbjB,MAAM,WAEPN,EAACC,EACA,CAAAC,OAAQrB,EAAc2C,YACtBpB,QAASb,EAAIkC,kBACbnB,MAAM,eAIRlB,GACAO,EAAA0B,EAAA,CAAAtB,SAAA,CACCC,EAACC,GACAC,OAAoC,SAA5BrB,EAAc6C,UACtBtB,QAASA,IAAMb,EAAIoC,aAAa,QAChCrB,MAAM,SAEPN,EAACC,GACAC,OAAoC,WAA5BrB,EAAc6C,UACtBtB,QAASA,IAAMb,EAAIoC,aAAa,UAChCrB,MAAM,WAEPN,EAACC,GACAC,OAAoC,UAA5BrB,EAAc6C,UACtBtB,QAASA,IAAMb,EAAIoC,aAAa,SAChCrB,MAAM,iBAxEM,IA4EV,EAIFL,EAID2B,IAAA,IAAC1B,OAAEA,EAAME,QAAEA,EAAOE,MAAEA,GAAOsB,EAAA,OAC/B5B,EAAA,SAAAJ,OAAAC,OAAA,CACCgC,KAAK,SACLC,MAAOxB,EACPR,UAAW,mBAAkBI,EAAS,2BAA6B,IACnE6B,YAAcC,IACbA,EAAEC,iBACF7B,GAAS,GAGT,CAAAL,SAAAO,IACO"}
1
+ {"version":3,"file":"BikEditorToolbar.js","sources":["../../../../src/editor/toolbar/BikEditorToolbar.tsx"],"sourcesContent":["import React from 'react';\nimport type { BikEditorRef, FormatState } from '../BikEditor.types';\n\n/**\n * Props for `<BikEditorToolbar />`.\n *\n * All `show*` props default to `true` except `showAlignment`, `showFontPicker`,\n * and `showColorPicker` which default to `false`.\n */\ninterface Props {\n\t/** The same ref you passed to `<BikEditor ref={...} />`. Required. */\n\teditorRef: React.RefObject<BikEditorRef>;\n\t/**\n\t * Active format snapshot. Keep this in state, updated via `onSelectionChange`.\n\t *\n\t * @example\n\t * const [formats, setFormats] = useState(DEFAULT_ACTIVE_FORMATS);\n\t * <BikEditor onSelectionChange={setFormats} ... />\n\t * <BikEditorToolbar activeFormats={formats} ... />\n\t */\n\tactiveFormats: FormatState;\n\t/** Show the Bold button. Default `true`. */\n\tshowBold?: boolean;\n\t/** Show the Italic button. Default `true`. */\n\tshowItalic?: boolean;\n\t/** Show the Underline button. Default `true`. */\n\tshowUnderline?: boolean;\n\t/** Show the Strikethrough button. Default `true`. */\n\tshowStrike?: boolean;\n\t/** Show the Link button. Default `true`. */\n\tshowLink?: boolean;\n\t/** Show Bullet and Ordered list buttons. Default `true`. */\n\tshowLists?: boolean;\n\t/** Show Left / Center / Right alignment buttons. Default `false`. */\n\tshowAlignment?: boolean;\n\t/** Reserved — renders nothing yet. Default `false`. */\n\tshowFontPicker?: boolean;\n\t/** Reserved — renders nothing yet. Default `false`. */\n\tshowColorPicker?: boolean;\n\t/**\n\t * Called when the user clicks the Link button.\n\t *\n\t * - `selectedText` — the selected text, or the full text of the link the cursor\n\t * is already inside (useful for pre-filling the \"Text\" field of your modal).\n\t * - `currentHref` — non-null when the cursor is inside an existing link\n\t * (useful for pre-filling the \"URL\" field).\n\t *\n\t * After the user saves, call `editorRef.current?.actions.setLink(href, text)`.\n\t */\n\tonLinkButtonClick?: (\n\t\tselectedText: string,\n\t\tcurrentHref: string | null,\n\t) => void;\n}\n\nexport const BikEditorToolbar: React.FC<Props> = ({\n\teditorRef,\n\tactiveFormats,\n\tshowBold = true,\n\tshowItalic = true,\n\tshowUnderline = true,\n\tshowStrike = true,\n\tshowLink = true,\n\tshowLists = true,\n\tshowAlignment = false,\n\tshowFontPicker = false,\n\tonLinkButtonClick,\n}) => {\n\tconst act = editorRef.current?.actions;\n\tif (!act) return null;\n\n\treturn (\n\t\t<div className=\"bik-editor-toolbar\">\n\t\t\t{showBold && (\n\t\t\t\t<Btn\n\t\t\t\t\tactive={activeFormats.bold}\n\t\t\t\t\tonPress={act.toggleBold}\n\t\t\t\t\tlabel=\"Bold\"\n\t\t\t\t/>\n\t\t\t)}\n\t\t\t{showItalic && (\n\t\t\t\t<Btn\n\t\t\t\t\tactive={activeFormats.italic}\n\t\t\t\t\tonPress={act.toggleItalic}\n\t\t\t\t\tlabel=\"Italic\"\n\t\t\t\t/>\n\t\t\t)}\n\t\t\t{showUnderline && (\n\t\t\t\t<Btn\n\t\t\t\t\tactive={activeFormats.underline}\n\t\t\t\t\tonPress={act.toggleUnderline}\n\t\t\t\t\tlabel=\"Underline\"\n\t\t\t\t/>\n\t\t\t)}\n\t\t\t{showStrike && (\n\t\t\t\t<Btn\n\t\t\t\t\tactive={activeFormats.strike}\n\t\t\t\t\tonPress={act.toggleStrike}\n\t\t\t\t\tlabel=\"Strike\"\n\t\t\t\t/>\n\t\t\t)}\n\t\t\t{showLink && (\n\t\t\t\t<Btn\n\t\t\t\t\tactive={!!activeFormats.link}\n\t\t\t\t\tonPress={() => {\n\t\t\t\t\t\tconst selectedText = editorRef.current?.getSelectedText() ?? '';\n\t\t\t\t\t\tconst currentHref = activeFormats.link?.href ?? null;\n\t\t\t\t\t\tonLinkButtonClick?.(selectedText, currentHref);\n\t\t\t\t\t}}\n\t\t\t\t\tlabel=\"Link ↗\"\n\t\t\t\t/>\n\t\t\t)}\n\t\t\t{showLists && (\n\t\t\t\t<>\n\t\t\t\t\t<Btn\n\t\t\t\t\t\tactive={activeFormats.bulletList}\n\t\t\t\t\t\tonPress={act.toggleBulletList}\n\t\t\t\t\t\tlabel=\"Bullet\"\n\t\t\t\t\t/>\n\t\t\t\t\t<Btn\n\t\t\t\t\t\tactive={activeFormats.orderedList}\n\t\t\t\t\t\tonPress={act.toggleOrderedList}\n\t\t\t\t\t\tlabel=\"Ordered\"\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t)}\n\t\t\t{showAlignment && (\n\t\t\t\t<>\n\t\t\t\t\t<Btn\n\t\t\t\t\t\tactive={activeFormats.textAlign === 'left'}\n\t\t\t\t\t\tonPress={() => act.setTextAlign('left')}\n\t\t\t\t\t\tlabel=\"Left\"\n\t\t\t\t\t/>\n\t\t\t\t\t<Btn\n\t\t\t\t\t\tactive={activeFormats.textAlign === 'center'}\n\t\t\t\t\t\tonPress={() => act.setTextAlign('center')}\n\t\t\t\t\t\tlabel=\"Center\"\n\t\t\t\t\t/>\n\t\t\t\t\t<Btn\n\t\t\t\t\t\tactive={activeFormats.textAlign === 'right'}\n\t\t\t\t\t\tonPress={() => act.setTextAlign('right')}\n\t\t\t\t\t\tlabel=\"Right\"\n\t\t\t\t\t/>\n\t\t\t\t</>\n\t\t\t)}\n\t\t</div>\n\t);\n};\n\nconst Btn: React.FC<{\n\tactive: boolean;\n\tonPress: () => void;\n\tlabel: string;\n}> = ({ active, onPress, label }) => (\n\t<button\n\t\ttype=\"button\"\n\t\ttitle={label}\n\t\tclassName={`bik-toolbar-btn${active ? ' bik-toolbar-btn--active' : ''}`}\n\t\tonMouseDown={(e) => {\n\t\t\te.preventDefault();\n\t\t\tonPress();\n\t\t}}\n\t>\n\t\t{label}\n\t</button>\n);\n"],"names":["BikEditorToolbar","_ref","editorRef","activeFormats","showBold","showItalic","showUnderline","showStrike","showLink","showLists","showAlignment","showFontPicker","onLinkButtonClick","act","_a","current","actions","_jsxs","Object","assign","className","children","_jsx","Btn","active","bold","onPress","toggleBold","label","italic","toggleItalic","underline","toggleUnderline","strike","toggleStrike","link","selectedText","_b","getSelectedText","currentHref","_d","_c","href","_Fragment","bulletList","toggleBulletList","orderedList","toggleOrderedList","textAlign","setTextAlign","_ref2","type","title","onMouseDown","e","preventDefault"],"mappings":"gEAuDaA,MAAAA,EAAoCC,IAY5C,IAZ6CC,UACjDA,EAASC,cACTA,EAAaC,SACbA,GAAW,EAAIC,WACfA,GAAa,EAAIC,cACjBA,GAAgB,EAAIC,WACpBA,GAAa,EAAIC,SACjBA,GAAW,EAAIC,UACfA,GAAY,EAAIC,cAChBA,GAAgB,EAAKC,eACrBA,GAAiB,EAAKC,kBACtBA,GACAX,QACA,MAAMY,EAAuB,QAAjBC,EAAAZ,EAAUa,eAAO,IAAAD,OAAA,EAAAA,EAAEE,QAC/B,OAAKH,EAGJI,EAAK,MAAAC,OAAAC,OAAA,CAAAC,UAAU,sBACb,CAAAC,SAAA,CAAAjB,GACAkB,EAACC,EACA,CAAAC,OAAQrB,EAAcsB,KACtBC,QAASb,EAAIc,WACbC,MAAM,SAGPvB,GACAiB,EAACC,EACA,CAAAC,OAAQrB,EAAc0B,OACtBH,QAASb,EAAIiB,aACbF,MAAM,WAGPtB,GACAgB,EAACC,GACAC,OAAQrB,EAAc4B,UACtBL,QAASb,EAAImB,gBACbJ,MAAM,cAGPrB,GACAe,EAACC,EAAG,CACHC,OAAQrB,EAAc8B,OACtBP,QAASb,EAAIqB,aACbN,MAAM,WAGPpB,GACAc,EAACC,EACA,CAAAC,SAAUrB,EAAcgC,KACxBT,QAASA,iBACR,MAAMU,EAAuD,QAAxCC,EAAiB,QAAjBvB,EAAAZ,EAAUa,eAAO,IAAAD,OAAA,EAAAA,EAAEwB,yBAAqB,IAAAD,EAAAA,EAAA,GACvDE,EAA0C,QAA5BC,EAAoB,QAApBC,EAAAtC,EAAcgC,YAAM,IAAAM,OAAA,EAAAA,EAAAC,YAAQ,IAAAF,EAAAA,EAAA,KAChD5B,SAAAA,EAAoBwB,EAAcG,EAAY,EAE/CX,MAAM,WAGPnB,GACAQ,EAAA0B,EAAA,CAAAtB,SAAA,CACCC,EAACC,GACAC,OAAQrB,EAAcyC,WACtBlB,QAASb,EAAIgC,iBACbjB,MAAM,WAEPN,EAACC,EACA,CAAAC,OAAQrB,EAAc2C,YACtBpB,QAASb,EAAIkC,kBACbnB,MAAM,eAIRlB,GACAO,EAAA0B,EAAA,CAAAtB,SAAA,CACCC,EAACC,GACAC,OAAoC,SAA5BrB,EAAc6C,UACtBtB,QAASA,IAAMb,EAAIoC,aAAa,QAChCrB,MAAM,SAEPN,EAACC,GACAC,OAAoC,WAA5BrB,EAAc6C,UACtBtB,QAASA,IAAMb,EAAIoC,aAAa,UAChCrB,MAAM,WAEPN,EAACC,GACAC,OAAoC,UAA5BrB,EAAc6C,UACtBtB,QAASA,IAAMb,EAAIoC,aAAa,SAChCrB,MAAM,iBAxEM,IA4EV,EAIFL,EAID2B,IAAA,IAAC1B,OAAEA,EAAME,QAAEA,EAAOE,MAAEA,GAAOsB,EAAA,OAC/B5B,EAAA,SAAAJ,OAAAC,OAAA,CACCgC,KAAK,SACLC,MAAOxB,EACPR,UAAW,mBAAkBI,EAAS,2BAA6B,IACnE6B,YAAcC,IACbA,EAAEC,iBACF7B,GAAS,GAGT,CAAAL,SAAAO,IACO"}
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  export declare const Menus: ({
3
2
  displayName: string;
4
3
  key: number;
@@ -413,25 +413,20 @@ export interface BikEditorRef {
413
413
  setContent: (html: string) => void;
414
414
  /** Inserts HTML at the current cursor position without replacing anything. */
415
415
  insertContent: (html: string) => void;
416
- /**
417
- * Inserts HTML inline at the current cursor position, unwrapping block
418
- * wrappers (e.g. `<p>`) so the content merges into the surrounding paragraph
419
- * instead of creating new blocks. Use for macros, quick replies, etc.
420
- */
421
- insertInlineContent: (html: string) => void;
422
416
  /** Inserts HTML at the very start of the document. */
423
417
  insertAtStart: (html: string) => void;
424
- /** Inserts HTML as a new block at the end of the document. */
425
- insertBlock: (html: string) => void;
418
+ /** Inserts HTML at the very end of the document. */
419
+ insertAtEnd: (html: string) => void;
426
420
  /**
427
- * Appends HTML inline inside the last paragraph of the document.
421
+ * Appends HTML to the very end of the document without moving the cursor.
428
422
  * Ideal for streaming — call repeatedly with each text chunk.
429
423
  * Use `appendBodyContent` instead if the editor has named sections.
424
+ *
425
+ * @example
426
+ * for await (const chunk of stream) {
427
+ * ref.current?.appendContent(chunk);
428
+ * }
430
429
  */
431
- appendInline: (html: string) => void;
432
- /** @deprecated Use `insertBlock` */
433
- insertAtEnd: (html: string) => void;
434
- /** @deprecated Use `appendInline` */
435
430
  appendContent: (html: string) => void;
436
431
  /** Returns the full document as `{ html, text, isEmpty, characterCount }`. */
437
432
  getContent: () => EditorSnapshot;
@@ -625,21 +620,13 @@ export interface BikEditorProps {
625
620
  * `'mod'` maps to Cmd on macOS and Ctrl on Windows/Linux.
626
621
  *
627
622
  * @example
628
- * // Single shortcut
623
+ * // Cmd+Enter / Ctrl+Enter to send
629
624
  * sendShortcut={{ key: 'Enter', modifiers: ['mod'] }}
630
- * // Multiple shortcuts
631
- * sendShortcut={[
632
- * { key: 'Enter', modifiers: ['mod'] },
633
- * { key: 's', modifiers: ['mod'] },
634
- * ]}
635
625
  */
636
626
  sendShortcut?: {
637
627
  key: string;
638
628
  modifiers?: Array<'mod' | 'ctrl' | 'shift' | 'alt'>;
639
- } | Array<{
640
- key: string;
641
- modifiers?: Array<'mod' | 'ctrl' | 'shift' | 'alt'>;
642
- }>;
629
+ };
643
630
  /**
644
631
  * Enables `@` (agent) and `#` (team) mention dropdowns.
645
632
  * Bundle all mention-related config in one object so it's easy to find.
@@ -688,8 +675,8 @@ export interface BikEditorProps {
688
675
  /** Called on every document change. */
689
676
  onChange?: (content: EditorSnapshot) => void;
690
677
  /**
691
- * Called when the user presses the key combo defined by `sendShortcut`.
692
- * Only fires when both `onSend` and `sendShortcut` are provided.
678
+ * Called when the user presses Mod+Enter (Cmd on Mac, Ctrl on Win/Linux).
679
+ * Only fires when this prop is provided.
693
680
  */
694
681
  onSend?: (content: EditorSnapshot) => void;
695
682
  /** Called when the editor gains focus. */
@@ -15,15 +15,6 @@ import { EditorSnapshot, FormatState } from './BikEditor.types';
15
15
  * surrounding-newline collapse in `toWhatsAppText`).
16
16
  */
17
17
  export declare function normalizeHtml(html: string): string;
18
- /**
19
- * Insert HTML at the current cursor position, merging the first paragraph
20
- * inline while preserving the block structure of subsequent paragraphs/lists.
21
- *
22
- * Uses `parseSlice` which returns an open-ended Slice — the first block merges
23
- * at the cursor, middle blocks stay intact, and the last block merges with any
24
- * text that follows the cursor.
25
- */
26
- export declare function insertInlineHtml(editor: Editor, html: string): void;
27
18
  export declare const SECTION_DIVIDER_HTML: (id: string) => string;
28
19
  /**
29
20
  * Build initial HTML for an editor with one or more named sections below the body.
@@ -61,8 +52,6 @@ export declare function extractAllSectionsFromHtml(html: string): Map<string, st
61
52
  export declare function extractSectionContent(editor: Editor, id: string): EditorSnapshot;
62
53
  /**
63
54
  * Replace the content of a single named section without touching others.
64
- * Uses a ProseMirror transaction to replace only the target range,
65
- * preserving undo history and other sections' state.
66
55
  * If the section doesn't exist yet, it is appended at the end of the document.
67
56
  */
68
57
  export declare function setSectionContentInEditor(editor: Editor, id: string, html: string): void;
@@ -6,25 +6,16 @@ interface ExtensionConfig {
6
6
  maxCharacters?: number;
7
7
  hasSections?: boolean;
8
8
  mentions?: {
9
- agents?: {
10
- current: MentionItem[];
11
- };
12
- teams?: {
13
- current: MentionItem[];
14
- };
15
- };
16
- slashCommands?: {
17
- current: SlashCommandItem[];
9
+ agents?: MentionItem[];
10
+ teams?: MentionItem[];
18
11
  };
12
+ slashCommands?: SlashCommandItem[];
19
13
  onPaste?: (data: PasteData) => boolean | void;
20
14
  onSend?: (content: EditorSnapshot) => void;
21
15
  sendShortcut?: {
22
16
  key: string;
23
17
  modifiers?: Array<'mod' | 'ctrl' | 'shift' | 'alt'>;
24
- } | Array<{
25
- key: string;
26
- modifiers?: Array<'mod' | 'ctrl' | 'shift' | 'alt'>;
27
- }>;
18
+ };
28
19
  shortcuts?: KeyboardShortcut[];
29
20
  onMentionSelected?: (item: MentionItem, char: '@' | '#') => void;
30
21
  onSlashCommandSelected?: (command: SlashCommandItem) => void;
@@ -1,8 +1,4 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import type { MentionDropdownRenderProps, MentionItem } from '../../BikEditor.types';
3
- export declare function buildAgentMentionExtension(agentsRef: {
4
- current: MentionItem[];
5
- }, onSelect?: (item: MentionItem, char: '@' | '#') => void, renderItem?: (item: MentionItem, isActive: boolean) => ReactNode, renderDropdown?: (props: MentionDropdownRenderProps) => ReactNode): import("@tiptap/core").Node<import("@tiptap/extension-mention").MentionOptions<any, import("@tiptap/extension-mention").MentionNodeAttrs>, any>;
6
- export declare function buildTeamMentionExtension(teamsRef: {
7
- current: MentionItem[];
8
- }, onSelect?: (item: MentionItem, char: '@' | '#') => void, renderItem?: (item: MentionItem, isActive: boolean) => ReactNode, renderDropdown?: (props: MentionDropdownRenderProps) => ReactNode): import("@tiptap/core").Node<import("@tiptap/extension-mention").MentionOptions<any, import("@tiptap/extension-mention").MentionNodeAttrs>, any>;
3
+ export declare function buildAgentMentionExtension(agents: MentionItem[], onSelect?: (item: MentionItem, char: '@' | '#') => void, renderItem?: (item: MentionItem, isActive: boolean) => ReactNode, renderDropdown?: (props: MentionDropdownRenderProps) => ReactNode): import("@tiptap/core").Node<import("@tiptap/extension-mention").MentionOptions<any, import("@tiptap/extension-mention").MentionNodeAttrs>, any>;
4
+ export declare function buildTeamMentionExtension(teams: MentionItem[], onSelect?: (item: MentionItem, char: '@' | '#') => void, renderItem?: (item: MentionItem, isActive: boolean) => ReactNode, renderDropdown?: (props: MentionDropdownRenderProps) => ReactNode): import("@tiptap/core").Node<import("@tiptap/extension-mention").MentionOptions<any, import("@tiptap/extension-mention").MentionNodeAttrs>, any>;