@bikdotai/bik-component-library 0.0.809-beta.26 → 0.0.809-beta.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/editor/extensions/buildExtensions.js +1 -1
- package/dist/cjs/editor/extensions/buildExtensions.js.map +1 -1
- package/dist/cjs/src/editor/extensions/buildExtensions.d.ts +2 -1
- package/dist/esm/editor/extensions/buildExtensions.js +1 -1
- package/dist/esm/editor/extensions/buildExtensions.js.map +1 -1
- package/dist/esm/src/editor/extensions/buildExtensions.d.ts +2 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/@tiptap/core/dist/index.js"),t=require("@tiptap/extension-character-count"),n=require("@tiptap/extension-color"),i=require("@tiptap/extension-font-family"),r=require("@tiptap/extension-highlight"),o=require("@tiptap/extension-image"),a=require("@tiptap/extension-link"),s=require("../../node_modules/@tiptap/extension-paragraph/dist/index.js"),d=require("@tiptap/extension-placeholder"),l=require("@tiptap/extension-subscript"),u=require("@tiptap/extension-superscript"),p=require("@tiptap/extension-text-align"),c=require("@tiptap/extension-text-style"),x=require("@tiptap/extension-underline"),m=require("@tiptap/starter-kit"),f=require("./FontSizeExtension.js"),h=require("./mention/MentionExtension.js"),g=require("./paste/PasteExtension.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../node_modules/@tiptap/core/dist/index.js"),t=require("@tiptap/extension-character-count"),n=require("@tiptap/extension-color"),i=require("@tiptap/extension-font-family"),r=require("@tiptap/extension-highlight"),o=require("@tiptap/extension-image"),a=require("@tiptap/extension-link"),s=require("../../node_modules/@tiptap/extension-paragraph/dist/index.js"),d=require("@tiptap/extension-placeholder"),l=require("@tiptap/extension-subscript"),u=require("@tiptap/extension-superscript"),p=require("@tiptap/extension-text-align"),c=require("@tiptap/extension-text-style"),x=require("@tiptap/extension-underline"),m=require("@tiptap/starter-kit"),f=require("./FontSizeExtension.js"),h=require("./mention/MentionExtension.js"),g=require("./paste/PasteExtension.js"),S=require("./plainClipboard/PasteNormalizationExtension.js"),q=require("./sectionDivider/SectionDividerNode.js"),v=require("./sendShortcut/SendShortcutExtension.js"),E=require("./slashCommand/SlashCommandExtension.js"),b=require("./variable/VariableDecorationExtension.js");function M(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var k=M(t),j=M(n),C=M(i),P=M(r),y=M(o),D=M(a),T=M(d),w=M(l),z=M(u),A=M(p),I=M(x),N=M(m);exports.buildExtensions=function(t){var n,i,r,o,a,d,l,u,p;const x=null!==(i=null===(n=t.features)||void 0===n?void 0:n.richPaste)&&void 0!==i&&i,m=null!==(o=null===(r=t.features)||void 0===r?void 0:r.richTypography)&&void 0!==o&&o,M=null===(a=t.features)||void 0===a?void 0:a.allowedMarks,_=e=>!M||M.includes(e),H=s.default.extend({renderHTML(t){let{HTMLAttributes:n}=t;return["p",e.mergeAttributes(n,{style:"margin: 0px; padding: 0px;"}),0]}});return[...[N.default.configure({link:!1,underline:!1,paragraph:!x&&{},hardBreak:!1,bold:!!_("bold")&&{},italic:!!_("italic")&&{},strike:!!_("strike")&&{},code:!!_("code")&&{}}),e.Extension.create({name:"shiftEnterParagraph",addKeyboardShortcuts:()=>({"Shift-Enter":e=>{let{editor:t}=e;return t.commands.splitBlock()}})}),...x?[H]:[],..._("underline")?[I.default]:[],D.default.extend({addPasteRules:()=>[],addInputRules:()=>[]}).configure({openOnClick:!1,autolink:!1,linkOnPaste:!1,HTMLAttributes:{rel:"noopener noreferrer",class:"bik-link"}}),c.TextStyle,T.default.configure({placeholder:null!==(d=t.placeholder)&&void 0!==d?d:"Type a message..."}),...t.onPaste?[g.PasteExtension.configure({onPaste:t.onPaste})]:[],S.PasteNormalizationExtension.configure({preserveMarks:x}),v.SendShortcutExtension.configure({onSend:t.onSend,sendShortcut:t.sendShortcut,extraShortcuts:null!==(l=t.shortcuts)&&void 0!==l?l:[]}),b.VariableDecorationExtension,...t.maxCharacters?[k.default.configure({limit:t.maxCharacters})]:[],q.SectionDividerNode],...[...(null===(u=t.mentions)||void 0===u?void 0:u.agents)?[h.buildAgentMentionExtension(t.mentions.agents,t.onMentionSelected,t.renderMentionItem,t.renderMentionDropdown)]:[],...(null===(p=t.mentions)||void 0===p?void 0:p.teams)?[h.buildTeamMentionExtension(t.mentions.teams,t.onMentionSelected,t.renderMentionItem,t.renderMentionDropdown)]:[],...t.slashCommands?[E.buildSlashCommandExtension(t.slashCommands,t.onSlashCommandSelected,t.renderSlashCommandItem,t.renderSlashCommandDropdown)]:[]],...m?[j.default,P.default.configure({multicolor:!0}),C.default,f.FontSizeExtension,A.default.configure({types:["heading","paragraph"]}),w.default,z.default,y.default]:[j.default]]};
|
|
2
2
|
//# sourceMappingURL=buildExtensions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildExtensions.js","sources":["../../../../src/editor/extensions/buildExtensions.ts"],"sourcesContent":["import { mergeAttributes } from '@tiptap/core';\nimport 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 Paragraph from '@tiptap/extension-paragraph';\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 { PasteNormalizationExtension } from './plainClipboard/PasteNormalizationExtension';\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 emailParagraph = Paragraph.extend({\n\t\trenderHTML({ HTMLAttributes }) {\n\t\t\treturn [\n\t\t\t\t'p',\n\t\t\t\tmergeAttributes(HTMLAttributes, {\n\t\t\t\t\tstyle: 'margin: 0px; padding: 0px;',\n\t\t\t\t}),\n\t\t\t\t0,\n\t\t\t];\n\t\t},\n\t});\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\tparagraph: hasRichPaste ? 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...(hasRichPaste ? [emailParagraph] : []),\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\tPasteNormalizationExtension.configure({\n\t\t\tpreserveMarks: hasRichPaste,\n\t\t}),\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":["config","hasRichPaste","_b","_a","features","richPaste","hasRichTypography","_d","_c","richTypography","allowedMarks","_e","isMark","m","includes","emailParagraph","Paragraph","extend","renderHTML","_ref","HTMLAttributes","mergeAttributes","style","StarterKit","configure","link","underline","paragraph","bold","italic","strike","code","Underline","Link","addPasteRules","addInputRules","openOnClick","autolink","linkOnPaste","rel","class","TextStyle","Placeholder","placeholder","_f","onPaste","PasteExtension","PasteNormalizationExtension","preserveMarks","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":"2xCAsEM,SAA0BA,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,SAAS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OAClB,CACAC,EAAyBA,0BACxBrE,EAAO6D,SAASO,MAChBpE,EAAOgE,kBACPhE,EAAOiE,kBACPjE,EAAOkE,wBAGR,MACClE,EAAOsE,cACR,CACAC,EAAAA,2BACCvE,EAAOsE,cACPtE,EAAOwE,uBACPxE,EAAOyE,uBACPzE,EAAO0E,6BAGR,OAGmBpE,EACpB,CACAqE,EAAAA,QACAC,EAAAA,QAAUpD,UAAU,CAAEqD,YAAY,IAClCC,EAAU,QACVC,oBACAC,EAAAA,QAAUxD,UAAU,CAAEyD,MAAO,CAAC,UAAW,eACzCC,EAAS,QACTC,EAAW,QACXC,EAAK,SAEL,CAACT,EAAK,SAGV"}
|
|
1
|
+
{"version":3,"file":"buildExtensions.js","sources":["../../../../src/editor/extensions/buildExtensions.ts"],"sourcesContent":["import { Extension, mergeAttributes } from '@tiptap/core';\nimport 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 Paragraph from '@tiptap/extension-paragraph';\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 { PasteNormalizationExtension } from './plainClipboard/PasteNormalizationExtension';\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 emailParagraph = Paragraph.extend({\n\t\trenderHTML({ HTMLAttributes }) {\n\t\t\treturn [\n\t\t\t\t'p',\n\t\t\t\tmergeAttributes(HTMLAttributes, {\n\t\t\t\t\tstyle: 'margin: 0px; padding: 0px;',\n\t\t\t\t}),\n\t\t\t\t0,\n\t\t\t];\n\t\t},\n\t});\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\tparagraph: hasRichPaste ? false : {},\n\t\t\thardBreak: 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\tExtension.create({\n\t\t\tname: 'shiftEnterParagraph',\n\t\t\taddKeyboardShortcuts() {\n\t\t\t\treturn {\n\t\t\t\t\t'Shift-Enter': ({ editor }) => editor.commands.splitBlock(),\n\t\t\t\t};\n\t\t\t},\n\t\t}),\n\t\t...(hasRichPaste ? [emailParagraph] : []),\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\tPasteNormalizationExtension.configure({\n\t\t\tpreserveMarks: hasRichPaste,\n\t\t}),\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":["config","hasRichPaste","_b","_a","features","richPaste","hasRichTypography","_d","_c","richTypography","allowedMarks","_e","isMark","m","includes","emailParagraph","Paragraph","extend","renderHTML","_ref","HTMLAttributes","mergeAttributes","style","StarterKit","configure","link","underline","paragraph","hardBreak","bold","italic","strike","code","Extension","create","name","addKeyboardShortcuts","_ref2","editor","commands","splitBlock","Underline","Link","addPasteRules","addInputRules","openOnClick","autolink","linkOnPaste","rel","class","TextStyle","Placeholder","placeholder","_f","onPaste","PasteExtension","PasteNormalizationExtension","preserveMarks","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":"2xCAsEM,SAA0BA,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,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BhE,EAAOiE,cACR,CAACC,EAAc,QAAC1C,UAAU,CAAE2C,MAAOnE,EAAOiE,iBAC1C,GAKHG,EAAAA,uBAGyB,aACrBC,EAAArE,EAAOsE,+BAAUC,QAClB,CACAC,6BACCxE,EAAOsE,SAASC,OAChBvE,EAAOyE,kBACPzE,EAAO0E,kBACP1E,EAAO2E,wBAGR,eACCC,EAAA5E,EAAOsE,+BAAUO,OAClB,CACAC,EAAyBA,0BACxB9E,EAAOsE,SAASO,MAChB7E,EAAOyE,kBACPzE,EAAO0E,kBACP1E,EAAO2E,wBAGR,MACC3E,EAAO+E,cACR,CACAC,EAAAA,2BACChF,EAAO+E,cACP/E,EAAOiF,uBACPjF,EAAOkF,uBACPlF,EAAOmF,6BAGR,OAGmB7E,EACpB,CACA8E,EAAAA,QACAC,EAAAA,QAAU7D,UAAU,CAAE8D,YAAY,IAClCC,EAAU,QACVC,oBACAC,EAAAA,QAAUjE,UAAU,CAAEkE,MAAO,CAAC,UAAW,eACzCC,EAAS,QACTC,EAAW,QACXC,EAAK,SAEL,CAACT,EAAK,SAGV"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
1
2
|
import type { ReactNode } from 'react';
|
|
2
3
|
import type { EditorFeatures, EditorSnapshot, KeyboardShortcut, MentionDropdownRenderProps, MentionItem, PasteData, SlashCommandDropdownRenderProps, SlashCommandItem } from '../BikEditor.types';
|
|
3
4
|
interface ExtensionConfig {
|
|
@@ -33,5 +34,5 @@ interface ExtensionConfig {
|
|
|
33
34
|
renderSlashCommandItem?: (item: SlashCommandItem, isActive: boolean) => ReactNode;
|
|
34
35
|
renderSlashCommandDropdown?: (props: SlashCommandDropdownRenderProps) => ReactNode;
|
|
35
36
|
}
|
|
36
|
-
export declare function buildExtensions(config: ExtensionConfig): (import("@tiptap/core").Node<import("@tiptap/extension-paragraph").ParagraphOptions, any> |
|
|
37
|
+
export declare function buildExtensions(config: ExtensionConfig): (import("@tiptap/core").Node<import("@tiptap/extension-paragraph").ParagraphOptions, any> | Extension<import("@tiptap/starter-kit").StarterKitOptions, any> | Extension<any, any> | import("@tiptap/core").Mark<import("@tiptap/extension-underline").UnderlineOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-link").LinkOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-text-style").TextStyleOptions, any> | Extension<import("@tiptap/extensions").PlaceholderOptions, any> | Extension<import("@tiptap/extensions").CharacterCountOptions, import("@tiptap/extensions").CharacterCountStorage> | import("@tiptap/core").Node<any, any> | import("@tiptap/core").Node<import("@tiptap/extension-mention").MentionOptions<any, import("@tiptap/extension-mention").MentionNodeAttrs>, any> | Extension<import("@tiptap/extension-text-style").ColorOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-highlight").HighlightOptions, any> | Extension<import("@tiptap/extension-text-align").TextAlignOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-image").ImageOptions, any>)[];
|
|
37
38
|
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{mergeAttributes as e}from"../../node_modules/@tiptap/core/dist/index.js";import
|
|
1
|
+
import{mergeAttributes as e,Extension as t}from"../../node_modules/@tiptap/core/dist/index.js";import o from"@tiptap/extension-character-count";import n from"@tiptap/extension-color";import i from"@tiptap/extension-font-family";import r from"@tiptap/extension-highlight";import a from"@tiptap/extension-image";import s from"@tiptap/extension-link";import p from"../../node_modules/@tiptap/extension-paragraph/dist/index.js";import m from"@tiptap/extension-placeholder";import d from"@tiptap/extension-subscript";import l from"@tiptap/extension-superscript";import c from"@tiptap/extension-text-align";import{TextStyle as u}from"@tiptap/extension-text-style";import f from"@tiptap/extension-underline";import h from"@tiptap/starter-kit";import{FontSizeExtension as x}from"./FontSizeExtension.js";import{buildAgentMentionExtension as g,buildTeamMentionExtension as v}from"./mention/MentionExtension.js";import{PasteExtension as S}from"./paste/PasteExtension.js";import{PasteNormalizationExtension as k}from"./plainClipboard/PasteNormalizationExtension.js";import{SectionDividerNode as M}from"./sectionDivider/SectionDividerNode.js";import{SendShortcutExtension as C}from"./sendShortcut/SendShortcutExtension.js";import{buildSlashCommandExtension as b}from"./slashCommand/SlashCommandExtension.js";import{VariableDecorationExtension as j}from"./variable/VariableDecorationExtension.js";function E(E){var P,y,D,T,w,I,H,L,z;const A=null!==(y=null===(P=E.features)||void 0===P?void 0:P.richPaste)&&void 0!==y&&y,B=null!==(T=null===(D=E.features)||void 0===D?void 0:D.richTypography)&&void 0!==T&&T,N=null===(w=E.features)||void 0===w?void 0:w.allowedMarks,O=e=>!N||N.includes(e),R=p.extend({renderHTML(t){let{HTMLAttributes:o}=t;return["p",e(o,{style:"margin: 0px; padding: 0px;"}),0]}});return[...[h.configure({link:!1,underline:!1,paragraph:!A&&{},hardBreak:!1,bold:!!O("bold")&&{},italic:!!O("italic")&&{},strike:!!O("strike")&&{},code:!!O("code")&&{}}),t.create({name:"shiftEnterParagraph",addKeyboardShortcuts:()=>({"Shift-Enter":e=>{let{editor:t}=e;return t.commands.splitBlock()}})}),...A?[R]:[],...O("underline")?[f]:[],s.extend({addPasteRules:()=>[],addInputRules:()=>[]}).configure({openOnClick:!1,autolink:!1,linkOnPaste:!1,HTMLAttributes:{rel:"noopener noreferrer",class:"bik-link"}}),u,m.configure({placeholder:null!==(I=E.placeholder)&&void 0!==I?I:"Type a message..."}),...E.onPaste?[S.configure({onPaste:E.onPaste})]:[],k.configure({preserveMarks:A}),C.configure({onSend:E.onSend,sendShortcut:E.sendShortcut,extraShortcuts:null!==(H=E.shortcuts)&&void 0!==H?H:[]}),j,...E.maxCharacters?[o.configure({limit:E.maxCharacters})]:[],M],...[...(null===(L=E.mentions)||void 0===L?void 0:L.agents)?[g(E.mentions.agents,E.onMentionSelected,E.renderMentionItem,E.renderMentionDropdown)]:[],...(null===(z=E.mentions)||void 0===z?void 0:z.teams)?[v(E.mentions.teams,E.onMentionSelected,E.renderMentionItem,E.renderMentionDropdown)]:[],...E.slashCommands?[b(E.slashCommands,E.onSlashCommandSelected,E.renderSlashCommandItem,E.renderSlashCommandDropdown)]:[]],...B?[n,r.configure({multicolor:!0}),i,x,c.configure({types:["heading","paragraph"]}),d,l,a]:[n]]}export{E as buildExtensions};
|
|
2
2
|
//# sourceMappingURL=buildExtensions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildExtensions.js","sources":["../../../../src/editor/extensions/buildExtensions.ts"],"sourcesContent":["import { mergeAttributes } from '@tiptap/core';\nimport 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 Paragraph from '@tiptap/extension-paragraph';\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 { PasteNormalizationExtension } from './plainClipboard/PasteNormalizationExtension';\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 emailParagraph = Paragraph.extend({\n\t\trenderHTML({ HTMLAttributes }) {\n\t\t\treturn [\n\t\t\t\t'p',\n\t\t\t\tmergeAttributes(HTMLAttributes, {\n\t\t\t\t\tstyle: 'margin: 0px; padding: 0px;',\n\t\t\t\t}),\n\t\t\t\t0,\n\t\t\t];\n\t\t},\n\t});\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\tparagraph: hasRichPaste ? 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...(hasRichPaste ? [emailParagraph] : []),\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\tPasteNormalizationExtension.configure({\n\t\t\tpreserveMarks: hasRichPaste,\n\t\t}),\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","emailParagraph","Paragraph","extend","renderHTML","_ref","HTMLAttributes","mergeAttributes","style","StarterKit","configure","link","underline","paragraph","bold","italic","strike","code","Underline","Link","addPasteRules","addInputRules","openOnClick","autolink","linkOnPaste","rel","class","TextStyle","Placeholder","placeholder","_f","onPaste","PasteExtension","PasteNormalizationExtension","preserveMarks","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":"w1CAsEM,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,GAElCE,EAAiBC,EAAUC,OAAO,CACvCC,WAAUC,GAAmB,IAAlBC,eAAEA,GAAgBD,EAC5B,MAAO,CACN,IACAE,EAAgBD,EAAgB,CAC/BE,MAAO,+BAER,EAEF,IA2GD,MAAO,IAxGM,CAIZC,EAAWC,UAAU,CACpBC,MAAM,EACNC,WAAW,EACXC,WAAW1B,GAAuB,CAAE,EACpC2B,OAAMhB,EAAO,SAAU,CAAE,EACzBiB,SAAQjB,EAAO,WAAY,CAAE,EAC7BkB,SAAQlB,EAAO,WAAY,CAAE,EAC7BmB,OAAMnB,EAAO,SAAU,CAAE,OAEtBX,EAAe,CAACc,GAAkB,MAClCH,EAAO,aAAe,CAACoB,GAAa,GAGxCC,EAAKhB,OAAO,CACXiB,cAAeA,IAAM,GACrBC,cAAeA,IAAM,KACnBX,UAAU,CACZY,aAAa,EACbC,UAAU,EACVC,aAAa,EACblB,eAAgB,CACfmB,IAAK,sBACLC,MAAO,cAGTC,EACAC,EAAYlB,UAAU,CACrBmB,oBAAaC,EAAA5C,EAAO2C,2BAAe,yBAKhC3C,EAAO6C,QACR,CAACC,EAAetB,UAAU,CAAEqB,QAAS7C,EAAO6C,WAC5C,GACHE,EAA4BvB,UAAU,CACrCwB,cAAe/C,IAEhBgD,EAAsBzB,UAAU,CAC/B0B,OAAQlD,EAAOkD,OACfC,aAAcnD,EAAOmD,aACrBC,uBAAgBC,EAAArD,EAAOsD,yBAAa,KAErCC,KACIvD,EAAOwD,cACR,CAACC,EAAejC,UAAU,CAAEkC,MAAO1D,EAAOwD,iBAC1C,GAKHG,MAGyB,aACrBC,EAAA5D,EAAO6D,+BAAUC,QAClB,CACAC,EACC/D,EAAO6D,SAASC,OAChB9D,EAAOgE,kBACPhE,EAAOiE,kBACPjE,EAAOkE,wBAGR,eACCC,EAAAnE,EAAO6D,+BAAUO,OAClB,CACAC,EACCrE,EAAO6D,SAASO,MAChBpE,EAAOgE,kBACPhE,EAAOiE,kBACPjE,EAAOkE,wBAGR,MACClE,EAAOsE,cACR,CACAC,EACCvE,EAAOsE,cACPtE,EAAOwE,uBACPxE,EAAOyE,uBACPzE,EAAO0E,6BAGR,OAGmBpE,EACpB,CACAqE,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 { Extension, mergeAttributes } from '@tiptap/core';\nimport 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 Paragraph from '@tiptap/extension-paragraph';\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 { PasteNormalizationExtension } from './plainClipboard/PasteNormalizationExtension';\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 emailParagraph = Paragraph.extend({\n\t\trenderHTML({ HTMLAttributes }) {\n\t\t\treturn [\n\t\t\t\t'p',\n\t\t\t\tmergeAttributes(HTMLAttributes, {\n\t\t\t\t\tstyle: 'margin: 0px; padding: 0px;',\n\t\t\t\t}),\n\t\t\t\t0,\n\t\t\t];\n\t\t},\n\t});\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\tparagraph: hasRichPaste ? false : {},\n\t\t\thardBreak: 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\tExtension.create({\n\t\t\tname: 'shiftEnterParagraph',\n\t\t\taddKeyboardShortcuts() {\n\t\t\t\treturn {\n\t\t\t\t\t'Shift-Enter': ({ editor }) => editor.commands.splitBlock(),\n\t\t\t\t};\n\t\t\t},\n\t\t}),\n\t\t...(hasRichPaste ? [emailParagraph] : []),\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\tPasteNormalizationExtension.configure({\n\t\t\tpreserveMarks: hasRichPaste,\n\t\t}),\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","emailParagraph","Paragraph","extend","renderHTML","_ref","HTMLAttributes","mergeAttributes","style","StarterKit","configure","link","underline","paragraph","hardBreak","bold","italic","strike","code","Extension","create","name","addKeyboardShortcuts","_ref2","editor","commands","splitBlock","Underline","Link","addPasteRules","addInputRules","openOnClick","autolink","linkOnPaste","rel","class","TextStyle","Placeholder","placeholder","_f","onPaste","PasteExtension","PasteNormalizationExtension","preserveMarks","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":"u2CAsEM,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,GAElCE,EAAiBC,EAAUC,OAAO,CACvCC,WAAUC,GAAmB,IAAlBC,eAAEA,GAAgBD,EAC5B,MAAO,CACN,IACAE,EAAgBD,EAAgB,CAC/BE,MAAO,+BAER,EAEF,IAoHD,MAAO,IAjHM,CAIZC,EAAWC,UAAU,CACpBC,MAAM,EACNC,WAAW,EACXC,WAAW1B,GAAuB,CAAE,EACpC2B,WAAW,EACXC,OAAMjB,EAAO,SAAU,CAAE,EACzBkB,SAAQlB,EAAO,WAAY,CAAE,EAC7BmB,SAAQnB,EAAO,WAAY,CAAE,EAC7BoB,OAAMpB,EAAO,SAAU,CAAE,IAE1Bq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}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Extension } from '@tiptap/core';
|
|
1
2
|
import type { ReactNode } from 'react';
|
|
2
3
|
import type { EditorFeatures, EditorSnapshot, KeyboardShortcut, MentionDropdownRenderProps, MentionItem, PasteData, SlashCommandDropdownRenderProps, SlashCommandItem } from '../BikEditor.types';
|
|
3
4
|
interface ExtensionConfig {
|
|
@@ -33,5 +34,5 @@ interface ExtensionConfig {
|
|
|
33
34
|
renderSlashCommandItem?: (item: SlashCommandItem, isActive: boolean) => ReactNode;
|
|
34
35
|
renderSlashCommandDropdown?: (props: SlashCommandDropdownRenderProps) => ReactNode;
|
|
35
36
|
}
|
|
36
|
-
export declare function buildExtensions(config: ExtensionConfig): (import("@tiptap/core").Node<import("@tiptap/extension-paragraph").ParagraphOptions, any> |
|
|
37
|
+
export declare function buildExtensions(config: ExtensionConfig): (import("@tiptap/core").Node<import("@tiptap/extension-paragraph").ParagraphOptions, any> | Extension<import("@tiptap/starter-kit").StarterKitOptions, any> | Extension<any, any> | import("@tiptap/core").Mark<import("@tiptap/extension-underline").UnderlineOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-link").LinkOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-text-style").TextStyleOptions, any> | Extension<import("@tiptap/extensions").PlaceholderOptions, any> | Extension<import("@tiptap/extensions").CharacterCountOptions, import("@tiptap/extensions").CharacterCountStorage> | import("@tiptap/core").Node<any, any> | import("@tiptap/core").Node<import("@tiptap/extension-mention").MentionOptions<any, import("@tiptap/extension-mention").MentionNodeAttrs>, any> | Extension<import("@tiptap/extension-text-style").ColorOptions, any> | import("@tiptap/core").Mark<import("@tiptap/extension-highlight").HighlightOptions, any> | Extension<import("@tiptap/extension-text-align").TextAlignOptions, any> | import("@tiptap/core").Node<import("@tiptap/extension-image").ImageOptions, any>)[];
|
|
37
38
|
export {};
|