@bikdotai/bik-component-library 0.0.804-beta.3 → 0.0.804-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"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
+ {"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\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?.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":"orCAiEM,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{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};
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};
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| 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
+ {"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"}
@@ -619,13 +619,21 @@ export interface BikEditorProps {
619
619
  * `'mod'` maps to Cmd on macOS and Ctrl on Windows/Linux.
620
620
  *
621
621
  * @example
622
- * // Cmd+Enter / Ctrl+Enter to send
622
+ * // Single shortcut
623
623
  * sendShortcut={{ key: 'Enter', modifiers: ['mod'] }}
624
+ * // Multiple shortcuts
625
+ * sendShortcut={[
626
+ * { key: 'Enter', modifiers: ['mod'] },
627
+ * { key: 's', modifiers: ['mod'] },
628
+ * ]}
624
629
  */
625
630
  sendShortcut?: {
626
631
  key: string;
627
632
  modifiers?: Array<'mod' | 'ctrl' | 'shift' | 'alt'>;
628
- };
633
+ } | Array<{
634
+ key: string;
635
+ modifiers?: Array<'mod' | 'ctrl' | 'shift' | 'alt'>;
636
+ }>;
629
637
  /**
630
638
  * Enables `@` (agent) and `#` (team) mention dropdowns.
631
639
  * Bundle all mention-related config in one object so it's easy to find.
@@ -15,7 +15,10 @@ interface ExtensionConfig {
15
15
  sendShortcut?: {
16
16
  key: string;
17
17
  modifiers?: Array<'mod' | 'ctrl' | 'shift' | 'alt'>;
18
- };
18
+ } | Array<{
19
+ key: string;
20
+ modifiers?: Array<'mod' | 'ctrl' | 'shift' | 'alt'>;
21
+ }>;
19
22
  shortcuts?: KeyboardShortcut[];
20
23
  onMentionSelected?: (item: MentionItem, char: '@' | '#') => void;
21
24
  onSlashCommandSelected?: (command: SlashCommandItem) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.804-beta.3",
3
+ "version": "0.0.804-beta.5",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",