@bikdotai/bik-component-library 0.0.804-beta.14 → 0.0.804-beta.16

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 (23) 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/extensions/buildExtensions.js +1 -1
  4. package/dist/cjs/editor/extensions/buildExtensions.js.map +1 -1
  5. package/dist/cjs/editor/extensions/mention/MentionExtension.js +1 -1
  6. package/dist/cjs/editor/extensions/mention/MentionExtension.js.map +1 -1
  7. package/dist/cjs/editor/extensions/slashCommand/SlashCommandExtension.js +1 -1
  8. package/dist/cjs/editor/extensions/slashCommand/SlashCommandExtension.js.map +1 -1
  9. package/dist/cjs/src/editor/extensions/buildExtensions.d.ts +9 -3
  10. package/dist/cjs/src/editor/extensions/mention/MentionExtension.d.ts +6 -2
  11. package/dist/cjs/src/editor/extensions/slashCommand/SlashCommandExtension.d.ts +3 -1
  12. package/dist/esm/editor/BikEditor.js +1 -1
  13. package/dist/esm/editor/BikEditor.js.map +1 -1
  14. package/dist/esm/editor/extensions/buildExtensions.js +1 -1
  15. package/dist/esm/editor/extensions/buildExtensions.js.map +1 -1
  16. package/dist/esm/editor/extensions/mention/MentionExtension.js +1 -1
  17. package/dist/esm/editor/extensions/mention/MentionExtension.js.map +1 -1
  18. package/dist/esm/editor/extensions/slashCommand/SlashCommandExtension.js +1 -1
  19. package/dist/esm/editor/extensions/slashCommand/SlashCommandExtension.js.map +1 -1
  20. package/dist/esm/src/editor/extensions/buildExtensions.d.ts +9 -3
  21. package/dist/esm/src/editor/extensions/mention/MentionExtension.d.ts +6 -2
  22. package/dist/esm/src/editor/extensions/slashCommand/SlashCommandExtension.d.ts +3 -1
  23. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react/jsx-runtime"),e=require("../node_modules/@tiptap/core/dist/index.js"),n=require("@tiptap/react"),o=require("react"),i=require("./BikEditor.styles.js"),r=require("./BikEditor.types.js"),l=require("./BikEditor.utils.js"),s=require("./extensions/buildExtensions.js"),c=require("./floating/LinkBubbleMenu.js");function a(t){return Object.entries(t).map((t=>{let[e,n]=t;return`${e.replace(/([A-Z])/g,(t=>`-${t.toLowerCase()}`))}:${n}`})).join(";")}const u=(u,d)=>{var m;const{initialContent:g,sections:v,features:h,disabled:f,maxCharacters:C,shortcuts:p,sendShortcut:S,mentions:x,slashCommands:k,link:y,onPaste:H,onReady:B,onChange:b,onSend:z,onFocus:A,onBlur:E,onSelectionChange:I,minHeight:j,maxHeight:R,style:L,className:T,editorClassName:F,editorStyle:M}=u,O=(null==v?void 0:v.length)?l.buildSectionedContent(l.normalizeHtml(null!=g?g:""),v.map((t=>Object.assign(Object.assign({},t),{content:l.normalizeHtml(t.content)})))):l.normalizeHtml(null!=g?g:""),q=o.useRef([]),w=o.useRef(!1),P=o.useRef(B);P.current=B;const D=o.useRef(b);D.current=b;const U=o.useRef(I);U.current=I;const N=o.useRef(A);N.current=A;const _=o.useRef(E);_.current=E;const $=o.useRef(z);$.current=z;const J=n.useEditor({extensions:s.buildExtensions({features:h,placeholder:u.placeholder,maxCharacters:C,hasSections:(null!==(m=null==v?void 0:v.length)&&void 0!==m?m:0)>0,mentions:{agents:null==x?void 0:x.agents,teams:null==x?void 0:x.teams},slashCommands:null==k?void 0:k.items,onPaste:H,onSend:z?t=>{var e;return null===(e=$.current)||void 0===e?void 0:e.call($,t)}:void 0,sendShortcut:S,shortcuts:p,onMentionSelected:null==x?void 0:x.onSelect,onSlashCommandSelected:null==k?void 0:k.onSelect,renderMentionItem:null==x?void 0:x.renderItem,renderMentionDropdown:null==x?void 0:x.renderDropdown,renderSlashCommandItem:null==k?void 0:k.renderItem,renderSlashCommandDropdown:null==k?void 0:k.renderDropdown}),content:O,editable:!f,immediatelyRender:!1,editorProps:{attributes:Object.assign(Object.assign({},F?{class:F}:{}),M?{style:a(M)}:{})},onUpdate:t=>{let{editor:e}=t;var n;null===(n=D.current)||void 0===n||n.call(D,l.extractContent(e))},onTransaction:t=>{let{editor:e}=t;var n;null===(n=U.current)||void 0===n||n.call(U,l.extractActiveFormats(e))},onFocus:()=>{var t;return null===(t=N.current)||void 0===t?void 0:t.call(N)},onBlur:()=>{var t;return null===(t=_.current)||void 0===t?void 0:t.call(_)}});function V(t){J?t(J):q.current.push(t)}return o.useEffect((()=>{var t;if(J){if(q.current.length>0){q.current.splice(0).forEach((t=>t(J)))}w.current||(w.current=!0,null===(t=P.current)||void 0===t||t.call(P))}}),[J]),o.useImperativeHandle(d,(()=>({focus:t=>V((e=>e.commands.focus(t))),blur:()=>V((t=>t.commands.blur())),clearContent:()=>V((t=>t.commands.clearContent(!0))),setContent:t=>{const e=l.normalizeHtml(t);V((t=>t.commands.setContent(e,{emitUpdate:!0})))},insertContent:t=>{const e=l.normalizeHtml(t);V((t=>t.commands.insertContent(e)))},insertInlineContent:t=>{V((e=>l.insertInlineHtml(e,t)))},insertAtStart:t=>{const e=l.normalizeHtml(t);V((t=>t.commands.insertContentAt(1,e)))},insertBlock:t=>{const e=l.normalizeHtml(t);V((t=>t.commands.insertContentAt(t.state.doc.content.size,e)))},appendInline:t=>{const e=l.normalizeHtml(t);V((t=>t.commands.insertContentAt(t.state.doc.content.size-1,e)))},insertAtEnd(t){this.insertBlock(t)},appendContent(t){this.appendInline(t)},getContent:()=>J?l.extractContent(J):{html:"",text:"",isEmpty:!0,characterCount:0},getJSON:()=>{var t;return null!==(t=null==J?void 0:J.getJSON())&&void 0!==t?t:null},getMentions:()=>{const t=new Set,e=new Set;return J?(J.state.doc.descendants((n=>{"mentionAgent"===n.type.name&&null!=n.attrs.id?t.add(String(n.attrs.id)):"mentionTeam"===n.type.name&&null!=n.attrs.id&&e.add(String(n.attrs.id))})),{agentIds:Array.from(t),teamIds:Array.from(e)}):{agentIds:[],teamIds:[]}},getCursorPosition:()=>{if(!J)return{from:0,to:0};const{from:t,to:e}=J.state.selection;return{from:t,to:e}},insertAtPosition:(t,e)=>{const n=l.normalizeHtml(e);V((e=>e.commands.insertContentAt(t,n)))},getSelectedText:()=>{if(!J)return"";const{state:t}=J,{from:n,to:o,empty:i}=t.selection;if(!i)return t.doc.textBetween(n,o," ");const r=t.schema.marks.link;if(r){const o=e.getMarkRange(t.doc.resolve(n),r);if(o)return t.doc.textBetween(o.from,o.to," ")}return""},getCharacterCount:()=>{var t,e,n,o;return{count:null!==(o=null!==(n=null===(e=null===(t=null==J?void 0:J.storage.characterCount)||void 0===t?void 0:t.characters)||void 0===e?void 0:e.call(t))&&void 0!==n?n:null==J?void 0:J.getText().length)&&void 0!==o?o:0,limit:null!=C?C:null}},getSectionContent:t=>J?l.extractSectionContent(J,t):{html:"",text:"",isEmpty:!0,characterCount:0},setSectionContent:(t,e)=>{const n=l.normalizeHtml(e);V((e=>l.setSectionContentInEditor(e,t,n)))},focusSection:t=>{V((e=>{if("body"===t){let t=e.state.doc.content.size-1;return e.state.doc.descendants(((n,o)=>("sectionDivider"===n.type.name&&t===e.state.doc.content.size-1&&(t=o-1),t===e.state.doc.content.size-1))),t<1&&(t=1),void e.chain().focus().setTextSelection(t).run()}let n=-1;e.state.doc.descendants(((e,o)=>{if(-1!==n)return!1;"sectionDivider"===e.type.name&&e.attrs.sectionId===t&&(n=o+e.nodeSize+1)})),-1!==n&&e.chain().focus().setTextSelection(n).run()}))},clearSection:t=>{V((e=>l.setSectionContentInEditor(e,t,"<p></p>")))},getBodyContent:()=>J?l.extractBodyContent(J):{html:"",text:"",isEmpty:!0,characterCount:0},setBodyContent:t=>{const e=l.normalizeHtml(t);V((t=>l.setSectionContentInEditor(t,"body",e)))},setBodyAndSections:(t,e)=>{const n=l.buildSectionedContent(l.normalizeHtml(t),e.map((t=>({id:t.id,content:l.normalizeHtml(t.content)}))));V((t=>t.commands.setContent(n,{emitUpdate:!0})))},appendBodyContent:t=>{const e=l.normalizeHtml(t);V((t=>{const n=l.findSectionEndPos(t,"body");t.commands.insertContentAt(n-1,e)}))},insertAtSectionStart:(t,e)=>{const n=l.normalizeHtml(e);V((e=>{const o=l.findSectionStartPos(e,t);-1!==o&&e.commands.insertContentAt(o,n)}))},insertAtSectionEnd:(t,e)=>{const n=l.normalizeHtml(e);V((e=>{const o=l.findSectionEndPos(e,t);e.commands.insertContentAt(o,n)}))},getActiveFormats:()=>J?l.extractActiveFormats(J):r.DEFAULT_FORMAT_STATE,actions:{toggleBold:()=>null==J?void 0:J.chain().focus().toggleBold().run(),toggleItalic:()=>null==J?void 0:J.chain().focus().toggleItalic().run(),toggleUnderline:()=>null==J?void 0:J.chain().focus().toggleUnderline().run(),toggleStrike:()=>null==J?void 0:J.chain().focus().toggleStrike().run(),toggleBulletList:()=>null==J?void 0:J.chain().focus().toggleBulletList().run(),toggleOrderedList:()=>null==J?void 0:J.chain().focus().toggleOrderedList().run(),toggleBlockquote:()=>null==J?void 0:J.chain().focus().toggleBlockquote().run(),toggleCodeBlock:()=>null==J?void 0:J.chain().focus().toggleCodeBlock().run(),setTextAlign:t=>null==J?void 0:J.chain().focus().setTextAlign(t).run(),setFontFamily:t=>null==J?void 0:J.chain().focus().setFontFamily(t).run(),setFontSize:t=>null==J?void 0:J.chain().focus().setFontSize(t).run(),setColor:t=>null==J?void 0:J.chain().focus().setColor(t).run(),setHighlight:t=>null==J?void 0:J.chain().focus().toggleHighlight({color:t}).run(),unsetColor:()=>null==J?void 0:J.chain().focus().unsetColor().run(),unsetHighlight:()=>null==J?void 0:J.chain().focus().unsetHighlight().run(),setLink:(t,e)=>{J&&(void 0!==e?J.chain().focus().extendMarkRange("link").command((n=>{let{tr:o,state:i}=n;const{from:r,to:l}=o.selection,s=i.schema.marks.link;if(!s)return!1;const c=i.schema.text(e,[s.create({href:t})]),a=i.schema.text(" ");return o.replaceWith(r,l,[c,a]),!0})).run():J.chain().focus().extendMarkRange("link").setLink({href:t}).insertContent(" ").run())},updateLink:t=>null==J?void 0:J.chain().focus().extendMarkRange("link").setLink({href:t}).run(),removeLink:()=>null==J?void 0:J.chain().focus().extendMarkRange("link").unsetLink().run(),insertEmoji:t=>null==J?void 0:J.chain().focus().insertContent(t).run(),insertVariable:t=>null==J?void 0:J.chain().focus().insertContent(`{{${t}}}`).run(),insertHtml:t=>null==J?void 0:J.commands.insertContent(l.normalizeHtml(t)),undo:()=>null==J?void 0:J.chain().focus().undo().run(),redo:()=>null==J?void 0:J.chain().focus().redo().run(),canUndo:()=>{var t;return null!==(t=null==J?void 0:J.can().undo())&&void 0!==t&&t},canRedo:()=>{var t;return null!==(t=null==J?void 0:J.can().redo())&&void 0!==t&&t},toggleSuperscript:()=>null==J?void 0:J.chain().focus().toggleSuperscript().run(),toggleSubscript:()=>null==J?void 0:J.chain().focus().toggleSubscript().run(),insertImage:t=>null==J?void 0:J.chain().focus().setImage({src:t}).run()}})),[J]),J?t.jsxs(i.BikEditorShell,Object.assign({minHeight:j,maxHeight:R,style:L,className:T},{children:[t.jsx(n.EditorContent,{editor:J}),t.jsx(c.LinkBubbleMenu,{editor:J,renderLinkTooltip:null==y?void 0:y.renderTooltip})]})):null},d=o.forwardRef(u);d.displayName="BikEditor",exports.BikEditor=d;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react/jsx-runtime"),e=require("../node_modules/@tiptap/core/dist/index.js"),n=require("@tiptap/react"),o=require("react"),i=require("./BikEditor.styles.js"),r=require("./BikEditor.types.js"),l=require("./BikEditor.utils.js"),s=require("./extensions/buildExtensions.js"),c=require("./floating/LinkBubbleMenu.js");function u(t){return Object.entries(t).map((t=>{let[e,n]=t;return`${e.replace(/([A-Z])/g,(t=>`-${t.toLowerCase()}`))}:${n}`})).join(";")}const a=(a,d)=>{var m,v,g,h,f,C,p;const{initialContent:S,sections:x,features:k,disabled:y,maxCharacters:H,shortcuts:B,sendShortcut:b,mentions:z,slashCommands:A,link:E,onPaste:I,onReady:R,onChange:j,onSend:L,onFocus:T,onBlur:F,onSelectionChange:M,minHeight:O,maxHeight:q,style:w,className:P,editorClassName:D,editorStyle:U}=a,N=(null==x?void 0:x.length)?l.buildSectionedContent(l.normalizeHtml(null!=S?S:""),x.map((t=>Object.assign(Object.assign({},t),{content:l.normalizeHtml(t.content)})))):l.normalizeHtml(null!=S?S:""),_=o.useRef([]),$=o.useRef(!1),J=o.useRef(R);J.current=R;const V=o.useRef(j);V.current=j;const W=o.useRef(M);W.current=M;const Z=o.useRef(T);Z.current=T;const G=o.useRef(F);G.current=F;const K=o.useRef(L);K.current=L;const Q=o.useRef(null!==(m=null==z?void 0:z.agents)&&void 0!==m?m:[]);Q.current=null!==(v=null==z?void 0:z.agents)&&void 0!==v?v:[];const X=o.useRef(null!==(g=null==z?void 0:z.teams)&&void 0!==g?g:[]);X.current=null!==(h=null==z?void 0:z.teams)&&void 0!==h?h:[];const Y=o.useRef(null!==(f=null==A?void 0:A.items)&&void 0!==f?f:[]);Y.current=null!==(C=null==A?void 0:A.items)&&void 0!==C?C:[];const tt=n.useEditor({extensions:s.buildExtensions({features:k,placeholder:a.placeholder,maxCharacters:H,hasSections:(null!==(p=null==x?void 0:x.length)&&void 0!==p?p:0)>0,mentions:{agents:(null==z?void 0:z.agents)?Q:void 0,teams:(null==z?void 0:z.teams)?X:void 0},slashCommands:(null==A?void 0:A.items)?Y:void 0,onPaste:I,onSend:L?t=>{var e;return null===(e=K.current)||void 0===e?void 0:e.call(K,t)}:void 0,sendShortcut:b,shortcuts:B,onMentionSelected:null==z?void 0:z.onSelect,onSlashCommandSelected:null==A?void 0:A.onSelect,renderMentionItem:null==z?void 0:z.renderItem,renderMentionDropdown:null==z?void 0:z.renderDropdown,renderSlashCommandItem:null==A?void 0:A.renderItem,renderSlashCommandDropdown:null==A?void 0:A.renderDropdown}),content:N,editable:!y,immediatelyRender:!1,editorProps:{attributes:Object.assign(Object.assign({},D?{class:D}:{}),U?{style:u(U)}:{})},onUpdate:t=>{let{editor:e}=t;var n;null===(n=V.current)||void 0===n||n.call(V,l.extractContent(e))},onTransaction:t=>{let{editor:e}=t;var n;null===(n=W.current)||void 0===n||n.call(W,l.extractActiveFormats(e))},onFocus:()=>{var t;return null===(t=Z.current)||void 0===t?void 0:t.call(Z)},onBlur:()=>{var t;return null===(t=G.current)||void 0===t?void 0:t.call(G)}});function et(t){tt?t(tt):_.current.push(t)}return o.useEffect((()=>{var t;if(tt){if(_.current.length>0){_.current.splice(0).forEach((t=>t(tt)))}$.current||($.current=!0,null===(t=J.current)||void 0===t||t.call(J))}}),[tt]),o.useImperativeHandle(d,(()=>({focus:t=>et((e=>e.commands.focus(t))),blur:()=>et((t=>t.commands.blur())),clearContent:()=>et((t=>t.commands.clearContent(!0))),setContent:t=>{const e=l.normalizeHtml(t);et((t=>t.commands.setContent(e,{emitUpdate:!0})))},insertContent:t=>{const e=l.normalizeHtml(t);et((t=>t.commands.insertContent(e)))},insertInlineContent:t=>{et((e=>l.insertInlineHtml(e,t)))},insertAtStart:t=>{const e=l.normalizeHtml(t);et((t=>t.commands.insertContentAt(1,e)))},insertBlock:t=>{const e=l.normalizeHtml(t);et((t=>t.commands.insertContentAt(t.state.doc.content.size,e)))},appendInline:t=>{const e=l.normalizeHtml(t);et((t=>t.commands.insertContentAt(t.state.doc.content.size-1,e)))},insertAtEnd(t){this.insertBlock(t)},appendContent(t){this.appendInline(t)},getContent:()=>tt?l.extractContent(tt):{html:"",text:"",isEmpty:!0,characterCount:0},getJSON:()=>{var t;return null!==(t=null==tt?void 0:tt.getJSON())&&void 0!==t?t:null},getMentions:()=>{const t=new Set,e=new Set;return tt?(tt.state.doc.descendants((n=>{"mentionAgent"===n.type.name&&null!=n.attrs.id?t.add(String(n.attrs.id)):"mentionTeam"===n.type.name&&null!=n.attrs.id&&e.add(String(n.attrs.id))})),{agentIds:Array.from(t),teamIds:Array.from(e)}):{agentIds:[],teamIds:[]}},getCursorPosition:()=>{if(!tt)return{from:0,to:0};const{from:t,to:e}=tt.state.selection;return{from:t,to:e}},insertAtPosition:(t,e)=>{const n=l.normalizeHtml(e);et((e=>e.commands.insertContentAt(t,n)))},getSelectedText:()=>{if(!tt)return"";const{state:t}=tt,{from:n,to:o,empty:i}=t.selection;if(!i)return t.doc.textBetween(n,o," ");const r=t.schema.marks.link;if(r){const o=e.getMarkRange(t.doc.resolve(n),r);if(o)return t.doc.textBetween(o.from,o.to," ")}return""},getCharacterCount:()=>{var t,e,n,o;return{count:null!==(o=null!==(n=null===(e=null===(t=null==tt?void 0:tt.storage.characterCount)||void 0===t?void 0:t.characters)||void 0===e?void 0:e.call(t))&&void 0!==n?n:null==tt?void 0:tt.getText().length)&&void 0!==o?o:0,limit:null!=H?H:null}},getSectionContent:t=>tt?l.extractSectionContent(tt,t):{html:"",text:"",isEmpty:!0,characterCount:0},setSectionContent:(t,e)=>{const n=l.normalizeHtml(e);et((e=>l.setSectionContentInEditor(e,t,n)))},focusSection:t=>{et((e=>{if("body"===t){let t=e.state.doc.content.size-1;return e.state.doc.descendants(((n,o)=>("sectionDivider"===n.type.name&&t===e.state.doc.content.size-1&&(t=o-1),t===e.state.doc.content.size-1))),t<1&&(t=1),void e.chain().focus().setTextSelection(t).run()}let n=-1;e.state.doc.descendants(((e,o)=>{if(-1!==n)return!1;"sectionDivider"===e.type.name&&e.attrs.sectionId===t&&(n=o+e.nodeSize+1)})),-1!==n&&e.chain().focus().setTextSelection(n).run()}))},clearSection:t=>{et((e=>l.setSectionContentInEditor(e,t,"<p></p>")))},getBodyContent:()=>tt?l.extractBodyContent(tt):{html:"",text:"",isEmpty:!0,characterCount:0},setBodyContent:t=>{const e=l.normalizeHtml(t);et((t=>l.setSectionContentInEditor(t,"body",e)))},setBodyAndSections:(t,e)=>{const n=l.buildSectionedContent(l.normalizeHtml(t),e.map((t=>({id:t.id,content:l.normalizeHtml(t.content)}))));et((t=>t.commands.setContent(n,{emitUpdate:!0})))},appendBodyContent:t=>{const e=l.normalizeHtml(t);et((t=>{const n=l.findSectionEndPos(t,"body");t.commands.insertContentAt(n-1,e)}))},insertAtSectionStart:(t,e)=>{const n=l.normalizeHtml(e);et((e=>{const o=l.findSectionStartPos(e,t);-1!==o&&e.commands.insertContentAt(o,n)}))},insertAtSectionEnd:(t,e)=>{const n=l.normalizeHtml(e);et((e=>{const o=l.findSectionEndPos(e,t);e.commands.insertContentAt(o,n)}))},getActiveFormats:()=>tt?l.extractActiveFormats(tt):r.DEFAULT_FORMAT_STATE,actions:{toggleBold:()=>null==tt?void 0:tt.chain().focus().toggleBold().run(),toggleItalic:()=>null==tt?void 0:tt.chain().focus().toggleItalic().run(),toggleUnderline:()=>null==tt?void 0:tt.chain().focus().toggleUnderline().run(),toggleStrike:()=>null==tt?void 0:tt.chain().focus().toggleStrike().run(),toggleBulletList:()=>null==tt?void 0:tt.chain().focus().toggleBulletList().run(),toggleOrderedList:()=>null==tt?void 0:tt.chain().focus().toggleOrderedList().run(),toggleBlockquote:()=>null==tt?void 0:tt.chain().focus().toggleBlockquote().run(),toggleCodeBlock:()=>null==tt?void 0:tt.chain().focus().toggleCodeBlock().run(),setTextAlign:t=>null==tt?void 0:tt.chain().focus().setTextAlign(t).run(),setFontFamily:t=>null==tt?void 0:tt.chain().focus().setFontFamily(t).run(),setFontSize:t=>null==tt?void 0:tt.chain().focus().setFontSize(t).run(),setColor:t=>null==tt?void 0:tt.chain().focus().setColor(t).run(),setHighlight:t=>null==tt?void 0:tt.chain().focus().toggleHighlight({color:t}).run(),unsetColor:()=>null==tt?void 0:tt.chain().focus().unsetColor().run(),unsetHighlight:()=>null==tt?void 0:tt.chain().focus().unsetHighlight().run(),setLink:(t,e)=>{tt&&(void 0!==e?tt.chain().focus().extendMarkRange("link").command((n=>{let{tr:o,state:i}=n;const{from:r,to:l}=o.selection,s=i.schema.marks.link;if(!s)return!1;const c=i.schema.text(e,[s.create({href:t})]),u=i.schema.text(" ");return o.replaceWith(r,l,[c,u]),!0})).run():tt.chain().focus().extendMarkRange("link").setLink({href:t}).insertContent(" ").run())},updateLink:t=>null==tt?void 0:tt.chain().focus().extendMarkRange("link").setLink({href:t}).run(),removeLink:()=>null==tt?void 0:tt.chain().focus().extendMarkRange("link").unsetLink().run(),insertEmoji:t=>null==tt?void 0:tt.chain().focus().insertContent(t).run(),insertVariable:t=>null==tt?void 0:tt.chain().focus().insertContent(`{{${t}}}`).run(),insertHtml:t=>null==tt?void 0:tt.commands.insertContent(l.normalizeHtml(t)),undo:()=>null==tt?void 0:tt.chain().focus().undo().run(),redo:()=>null==tt?void 0:tt.chain().focus().redo().run(),canUndo:()=>{var t;return null!==(t=null==tt?void 0:tt.can().undo())&&void 0!==t&&t},canRedo:()=>{var t;return null!==(t=null==tt?void 0:tt.can().redo())&&void 0!==t&&t},toggleSuperscript:()=>null==tt?void 0:tt.chain().focus().toggleSuperscript().run(),toggleSubscript:()=>null==tt?void 0:tt.chain().focus().toggleSubscript().run(),insertImage:t=>null==tt?void 0:tt.chain().focus().setImage({src:t}).run()}})),[tt]),tt?t.jsxs(i.BikEditorShell,Object.assign({minHeight:O,maxHeight:q,style:w,className:P},{children:[t.jsx(n.EditorContent,{editor:tt}),t.jsx(c.LinkBubbleMenu,{editor:tt,renderLinkTooltip:null==E?void 0:E.renderTooltip})]})):null},d=o.forwardRef(a);d.displayName="BikEditor",exports.BikEditor=d;
2
2
  //# sourceMappingURL=BikEditor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BikEditor.js","sources":["../../../src/editor/BikEditor.tsx"],"sourcesContent":["'use client';\n\n/**\n * IMPLEMENTATION LAYER — TipTap-specific.\n * If the underlying editor is swapped, this file changes; BikEditor.types.ts and\n * src/editor/index.ts (the consumer contract) do NOT change.\n */\nimport { Editor, getMarkRange } from '@tiptap/core';\nimport { EditorContent, useEditor } from '@tiptap/react';\nimport React, {\n\tforwardRef,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseRef,\n} from 'react';\nimport { BikEditorShell } from './BikEditor.styles';\nimport {\n\tBikEditorProps,\n\tBikEditorRef,\n\tDEFAULT_FORMAT_STATE,\n} from './BikEditor.types';\nimport {\n\tbuildSectionedContent,\n\textractActiveFormats,\n\textractBodyContent,\n\textractContent,\n\textractSectionContent,\n\tfindSectionEndPos,\n\tfindSectionStartPos,\n\tinsertInlineHtml,\n\tnormalizeHtml,\n\tsetSectionContentInEditor,\n} from './BikEditor.utils';\nimport { buildExtensions } from './extensions/buildExtensions';\nimport { LinkBubbleMenu } from './floating/LinkBubbleMenu';\n\n/** Convert React.CSSProperties to an inline CSS string for editorProps.attributes. */\nfunction cssToString(style: React.CSSProperties): string {\n\treturn Object.entries(style)\n\t\t.map(\n\t\t\t([k, v]) => `${k.replace(/([A-Z])/g, (c) => `-${c.toLowerCase()}`)}:${v}`,\n\t\t)\n\t\t.join(';');\n}\n\nconst BikEditorInner = (\n\tprops: BikEditorProps,\n\tref: React.Ref<BikEditorRef>,\n) => {\n\tconst {\n\t\tinitialContent,\n\t\tsections,\n\t\tfeatures,\n\t\tdisabled,\n\t\tmaxCharacters,\n\t\tshortcuts,\n\t\tsendShortcut,\n\t\tmentions,\n\t\tslashCommands,\n\t\tlink,\n\t\tonPaste,\n\t\tonReady,\n\t\tonChange,\n\t\tonSend,\n\t\tonFocus,\n\t\tonBlur,\n\t\tonSelectionChange,\n\t\tminHeight,\n\t\tmaxHeight,\n\t\tstyle,\n\t\tclassName,\n\t\teditorClassName,\n\t\teditorStyle,\n\t} = props;\n\n\tconst initialEditorContent = sections?.length\n\t\t? buildSectionedContent(\n\t\t\t\tnormalizeHtml(initialContent ?? ''),\n\t\t\t\tsections.map((s) => ({ ...s, content: normalizeHtml(s.content) })),\n\t\t )\n\t\t: normalizeHtml(initialContent ?? '');\n\n\t// ── Command queue ─────────────────────────────────────────────────────────\n\t// TipTap's useEditor initializes asynchronously; the editor instance is null\n\t// until the first commit. Any imperative method called before the editor is\n\t// ready is enqueued here and flushed automatically once it becomes non-null.\n\t// Consumers never need setTimeout or readiness guards.\n\tconst pendingQueue = useRef<Array<(e: Editor) => void>>([]);\n\tconst hasCalledOnReady = useRef(false);\n\t// Keep stable refs to all callbacks so useEditor receives the same function\n\t// identity on every render — prevents TipTap from re-registering event\n\t// handlers every time the parent re-renders with new inline function props.\n\tconst onReadyRef = useRef(onReady);\n\tonReadyRef.current = onReady;\n\tconst onChangeRef = useRef(onChange);\n\tonChangeRef.current = onChange;\n\tconst onSelectionChangeRef = useRef(onSelectionChange);\n\tonSelectionChangeRef.current = onSelectionChange;\n\tconst onFocusRef = useRef(onFocus);\n\tonFocusRef.current = onFocus;\n\tconst onBlurRef = useRef(onBlur);\n\tonBlurRef.current = onBlur;\n\tconst onSendRef = useRef(onSend);\n\tonSendRef.current = onSend;\n\n\tconst editor = useEditor({\n\t\textensions: buildExtensions({\n\t\t\tfeatures,\n\t\t\tplaceholder: props.placeholder,\n\t\t\tmaxCharacters,\n\t\t\thasSections: (sections?.length ?? 0) > 0,\n\t\t\tmentions: {\n\t\t\t\tagents: mentions?.agents,\n\t\t\t\tteams: mentions?.teams,\n\t\t\t},\n\t\t\tslashCommands: slashCommands?.items,\n\t\t\tonPaste,\n\t\t\tonSend: onSend ? (snapshot) => onSendRef.current?.(snapshot) : undefined,\n\t\t\tsendShortcut,\n\t\t\tshortcuts,\n\t\t\tonMentionSelected: mentions?.onSelect,\n\t\t\tonSlashCommandSelected: slashCommands?.onSelect,\n\t\t\trenderMentionItem: mentions?.renderItem,\n\t\t\trenderMentionDropdown: mentions?.renderDropdown,\n\t\t\trenderSlashCommandItem: slashCommands?.renderItem,\n\t\t\trenderSlashCommandDropdown: slashCommands?.renderDropdown,\n\t\t}),\n\t\tcontent: initialEditorContent,\n\t\teditable: !disabled,\n\t\timmediatelyRender: false, // SSR-safe — NEVER remove this\n\t\teditorProps: {\n\t\t\tattributes: {\n\t\t\t\t...(editorClassName ? { class: editorClassName } : {}),\n\t\t\t\t...(editorStyle ? { style: cssToString(editorStyle) } : {}),\n\t\t\t},\n\t\t},\n\t\tonUpdate: ({ editor: e }) => {\n\t\t\tonChangeRef.current?.(extractContent(e));\n\t\t},\n\t\tonTransaction: ({ editor: e }) => {\n\t\t\tonSelectionChangeRef.current?.(extractActiveFormats(e));\n\t\t},\n\t\tonFocus: () => onFocusRef.current?.(),\n\t\tonBlur: () => onBlurRef.current?.(),\n\t});\n\n\t// ── enqueue ───────────────────────────────────────────────────────────────\n\t// Run immediately if the editor is ready; otherwise defer to the queue.\n\t// Closures passed to enqueue MUST capture all parameters explicitly —\n\t// they must NOT close over `editor` (which would be null at enqueue time).\n\tfunction enqueue(op: (e: Editor) => void): void {\n\t\tif (editor) {\n\t\t\top(editor);\n\t\t} else {\n\t\t\tpendingQueue.current.push(op);\n\t\t}\n\t}\n\n\t// Flush the pending queue and fire onReady when editor transitions null → ready.\n\tuseEffect(() => {\n\t\tif (!editor) return;\n\t\tif (pendingQueue.current.length > 0) {\n\t\t\tconst queue = pendingQueue.current.splice(0);\n\t\t\tqueue.forEach((op) => op(editor));\n\t\t}\n\t\tif (!hasCalledOnReady.current) {\n\t\t\thasCalledOnReady.current = true;\n\t\t\tonReadyRef.current?.();\n\t\t}\n\t}, [editor]);\n\n\tuseImperativeHandle(\n\t\tref,\n\t\t() => ({\n\t\t\t// ── Focus ────────────────────────────────────────────────────────\n\t\t\tfocus: (position) => enqueue((e) => e.commands.focus(position)),\n\t\t\tblur: () => enqueue((e) => e.commands.blur()),\n\n\t\t\t// ── Content ──────────────────────────────────────────────────────\n\t\t\tclearContent: () => enqueue((e) => e.commands.clearContent(true)),\n\t\t\tsetContent: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => e.commands.setContent(normalised, { emitUpdate: true }));\n\t\t\t},\n\t\t\tinsertContent: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => e.commands.insertContent(normalised));\n\t\t\t},\n\t\t\tinsertInlineContent: (html) => {\n\t\t\t\tenqueue((e) => insertInlineHtml(e, html));\n\t\t\t},\n\t\t\tinsertAtStart: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => e.commands.insertContentAt(1, normalised));\n\t\t\t},\n\t\t\tinsertBlock: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) =>\n\t\t\t\t\te.commands.insertContentAt(e.state.doc.content.size, normalised),\n\t\t\t\t);\n\t\t\t},\n\t\t\tappendInline: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\t// doc.content.size is after the last </p> (block boundary).\n\t\t\t\t// Subtract 1 to land inside the last paragraph so text appends\n\t\t\t\t// inline rather than being wrapped in a new paragraph each call.\n\t\t\t\tenqueue((e) =>\n\t\t\t\t\te.commands.insertContentAt(e.state.doc.content.size - 1, normalised),\n\t\t\t\t);\n\t\t\t},\n\t\t\t// Backwards-compatible aliases\n\t\t\tinsertAtEnd(html) {\n\t\t\t\tthis.insertBlock(html);\n\t\t\t},\n\t\t\tappendContent(html) {\n\t\t\t\tthis.appendInline(html);\n\t\t\t},\n\t\t\tgetContent: () =>\n\t\t\t\teditor\n\t\t\t\t\t? extractContent(editor)\n\t\t\t\t\t: { html: '', text: '', isEmpty: true, characterCount: 0 },\n\t\t\tgetJSON: () => editor?.getJSON() ?? null,\n\t\t\tgetMentions: () => {\n\t\t\t\tconst agentIds = new Set<string>();\n\t\t\t\tconst teamIds = new Set<string>();\n\t\t\t\tif (!editor) return { agentIds: [], teamIds: [] };\n\t\t\t\teditor.state.doc.descendants((node) => {\n\t\t\t\t\tif (node.type.name === 'mentionAgent' && node.attrs['id'] != null) {\n\t\t\t\t\t\tagentIds.add(String(node.attrs['id']));\n\t\t\t\t\t} else if (\n\t\t\t\t\t\tnode.type.name === 'mentionTeam' &&\n\t\t\t\t\t\tnode.attrs['id'] != null\n\t\t\t\t\t) {\n\t\t\t\t\t\tteamIds.add(String(node.attrs['id']));\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\treturn { agentIds: Array.from(agentIds), teamIds: Array.from(teamIds) };\n\t\t\t},\n\n\t\t\t// ── Selection ────────────────────────────────────────────────────\n\t\t\tgetCursorPosition: () => {\n\t\t\t\tif (!editor) return { from: 0, to: 0 };\n\t\t\t\tconst { from, to } = editor.state.selection;\n\t\t\t\treturn { from, to };\n\t\t\t},\n\t\t\tinsertAtPosition: (pos, html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => e.commands.insertContentAt(pos, normalised));\n\t\t\t},\n\t\t\tgetSelectedText: () => {\n\t\t\t\tif (!editor) return '';\n\t\t\t\tconst { state } = editor;\n\t\t\t\tconst { from, to, empty } = state.selection;\n\t\t\t\tif (!empty) {\n\t\t\t\t\treturn state.doc.textBetween(from, to, ' ');\n\t\t\t\t}\n\t\t\t\t// When the cursor is inside a link with nothing selected, return the\n\t\t\t\t// full link text — useful for pre-filling a link modal's text field.\n\t\t\t\tconst linkMarkType = state.schema.marks['link'];\n\t\t\t\tif (linkMarkType) {\n\t\t\t\t\tconst range = getMarkRange(state.doc.resolve(from), linkMarkType);\n\t\t\t\t\tif (range) {\n\t\t\t\t\t\treturn state.doc.textBetween(range.from, range.to, ' ');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn '';\n\t\t\t},\n\n\t\t\t// ── Character count ───────────────────────────────────────────────\n\t\t\tgetCharacterCount: () => ({\n\t\t\t\tcount:\n\t\t\t\t\teditor?.storage.characterCount?.characters?.() ??\n\t\t\t\t\teditor?.getText().length ??\n\t\t\t\t\t0,\n\t\t\t\tlimit: maxCharacters ?? null,\n\t\t\t}),\n\n\t\t\t// ── Sections ─────────────────────────────────────────────────────\n\t\t\tgetSectionContent: (sectionId) =>\n\t\t\t\teditor\n\t\t\t\t\t? extractSectionContent(editor, sectionId)\n\t\t\t\t\t: { html: '', text: '', isEmpty: true, characterCount: 0 },\n\n\t\t\tsetSectionContent: (sectionId, html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => setSectionContentInEditor(e, sectionId, normalised));\n\t\t\t},\n\n\t\t\tfocusSection: (sectionId) => {\n\t\t\t\tenqueue((e) => {\n\t\t\t\t\tif (sectionId === 'body') {\n\t\t\t\t\t\tlet endOfBody = e.state.doc.content.size - 1;\n\t\t\t\t\t\te.state.doc.descendants((node, pos) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tnode.type.name === 'sectionDivider' &&\n\t\t\t\t\t\t\t\tendOfBody === e.state.doc.content.size - 1\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tendOfBody = pos - 1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn endOfBody === e.state.doc.content.size - 1;\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (endOfBody < 1) endOfBody = 1;\n\t\t\t\t\t\te.chain().focus().setTextSelection(endOfBody).run();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tlet targetPos = -1;\n\t\t\t\t\te.state.doc.descendants((node, pos) => {\n\t\t\t\t\t\tif (targetPos !== -1) return false;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tnode.type.name === 'sectionDivider' &&\n\t\t\t\t\t\t\tnode.attrs['sectionId'] === sectionId\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// pos + nodeSize lands right after the divider;\n\t\t\t\t\t\t\t// +1 more puts us inside the first paragraph of that section.\n\t\t\t\t\t\t\ttargetPos = pos + node.nodeSize + 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\tif (targetPos !== -1) {\n\t\t\t\t\t\te.chain().focus().setTextSelection(targetPos).run();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t},\n\n\t\t\tclearSection: (sectionId) => {\n\t\t\t\tenqueue((e) => setSectionContentInEditor(e, sectionId, '<p></p>'));\n\t\t\t},\n\n\t\t\t// ── Convenience body shorthands ───────────────────────────────────\n\t\t\tgetBodyContent: () =>\n\t\t\t\teditor\n\t\t\t\t\t? extractBodyContent(editor)\n\t\t\t\t\t: { html: '', text: '', isEmpty: true, characterCount: 0 },\n\t\t\tsetBodyContent: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => setSectionContentInEditor(e, 'body', normalised));\n\t\t\t},\n\t\t\tsetBodyAndSections: (body, sections) => {\n\t\t\t\tconst html = buildSectionedContent(\n\t\t\t\t\tnormalizeHtml(body),\n\t\t\t\t\tsections.map((s) => ({\n\t\t\t\t\t\tid: s.id,\n\t\t\t\t\t\tcontent: normalizeHtml(s.content),\n\t\t\t\t\t})),\n\t\t\t\t);\n\t\t\t\tenqueue((e) => e.commands.setContent(html, { emitUpdate: true }));\n\t\t\t},\n\t\t\tappendBodyContent: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\t// findSectionEndPos returns the position of the first divider (or\n\t\t\t\t// doc.content.size), which is the block boundary after the last </p>.\n\t\t\t\t// Subtract 1 to stay inside the last paragraph so successive calls\n\t\t\t\t// append inline text rather than creating a new paragraph each time.\n\t\t\t\tenqueue((e) => {\n\t\t\t\t\tconst boundaryPos = findSectionEndPos(e, 'body');\n\t\t\t\t\te.commands.insertContentAt(boundaryPos - 1, normalised);\n\t\t\t\t});\n\t\t\t},\n\t\t\tinsertAtSectionStart: (sectionId, html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => {\n\t\t\t\t\tconst pos = findSectionStartPos(e, sectionId);\n\t\t\t\t\tif (pos !== -1) e.commands.insertContentAt(pos, normalised);\n\t\t\t\t});\n\t\t\t},\n\t\t\tinsertAtSectionEnd: (sectionId, html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => {\n\t\t\t\t\tconst pos = findSectionEndPos(e, sectionId);\n\t\t\t\t\te.commands.insertContentAt(pos, normalised);\n\t\t\t\t});\n\t\t\t},\n\t\t\t// ── Formats & actions ─────────────────────────────────────────────\n\t\t\tgetActiveFormats: () =>\n\t\t\t\teditor ? extractActiveFormats(editor) : DEFAULT_FORMAT_STATE,\n\t\t\tactions: {\n\t\t\t\ttoggleBold: () => editor?.chain().focus().toggleBold().run(),\n\t\t\t\ttoggleItalic: () => editor?.chain().focus().toggleItalic().run(),\n\t\t\t\ttoggleUnderline: () => editor?.chain().focus().toggleUnderline().run(),\n\t\t\t\ttoggleStrike: () => editor?.chain().focus().toggleStrike().run(),\n\t\t\t\ttoggleBulletList: () =>\n\t\t\t\t\teditor?.chain().focus().toggleBulletList().run(),\n\t\t\t\ttoggleOrderedList: () =>\n\t\t\t\t\teditor?.chain().focus().toggleOrderedList().run(),\n\t\t\t\ttoggleBlockquote: () =>\n\t\t\t\t\teditor?.chain().focus().toggleBlockquote().run(),\n\t\t\t\ttoggleCodeBlock: () => editor?.chain().focus().toggleCodeBlock().run(),\n\t\t\t\tsetTextAlign: (align) =>\n\t\t\t\t\teditor?.chain().focus().setTextAlign(align).run(),\n\t\t\t\tsetFontFamily: (font) =>\n\t\t\t\t\teditor?.chain().focus().setFontFamily(font).run(),\n\t\t\t\tsetFontSize: (size) => editor?.chain().focus().setFontSize(size).run(),\n\t\t\t\tsetColor: (color) => editor?.chain().focus().setColor(color).run(),\n\t\t\t\tsetHighlight: (color) =>\n\t\t\t\t\teditor?.chain().focus().toggleHighlight({ color }).run(),\n\t\t\t\tunsetColor: () => editor?.chain().focus().unsetColor().run(),\n\t\t\t\tunsetHighlight: () => editor?.chain().focus().unsetHighlight().run(),\n\t\t\t\tsetLink: (href, text) => {\n\t\t\t\t\tif (!editor) return;\n\t\t\t\t\tif (text !== undefined) {\n\t\t\t\t\t\teditor\n\t\t\t\t\t\t\t.chain()\n\t\t\t\t\t\t\t.focus()\n\t\t\t\t\t\t\t.extendMarkRange('link')\n\t\t\t\t\t\t\t.command(({ tr, state }) => {\n\t\t\t\t\t\t\t\tconst { from, to } = tr.selection;\n\t\t\t\t\t\t\t\tconst linkMarkType = state.schema.marks['link'];\n\t\t\t\t\t\t\t\tif (!linkMarkType) return false;\n\t\t\t\t\t\t\t\tconst linkNode = state.schema.text(text, [\n\t\t\t\t\t\t\t\t\tlinkMarkType.create({ href }),\n\t\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t\t\tconst space = state.schema.text(' ');\n\t\t\t\t\t\t\t\ttr.replaceWith(from, to, [linkNode, space]);\n\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.run();\n\t\t\t\t\t} else {\n\t\t\t\t\t\teditor\n\t\t\t\t\t\t\t.chain()\n\t\t\t\t\t\t\t.focus()\n\t\t\t\t\t\t\t.extendMarkRange('link')\n\t\t\t\t\t\t\t.setLink({ href })\n\t\t\t\t\t\t\t.insertContent(' ')\n\t\t\t\t\t\t\t.run();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tupdateLink: (href) =>\n\t\t\t\t\teditor\n\t\t\t\t\t\t?.chain()\n\t\t\t\t\t\t.focus()\n\t\t\t\t\t\t.extendMarkRange('link')\n\t\t\t\t\t\t.setLink({ href })\n\t\t\t\t\t\t.run(),\n\t\t\t\tremoveLink: () =>\n\t\t\t\t\teditor?.chain().focus().extendMarkRange('link').unsetLink().run(),\n\t\t\t\tinsertEmoji: (emoji) =>\n\t\t\t\t\teditor?.chain().focus().insertContent(emoji).run(),\n\t\t\t\tinsertVariable: (variableName) =>\n\t\t\t\t\teditor?.chain().focus().insertContent(`{{${variableName}}}`).run(),\n\t\t\t\tinsertHtml: (html) =>\n\t\t\t\t\teditor?.commands.insertContent(normalizeHtml(html)),\n\t\t\t\tundo: () => editor?.chain().focus().undo().run(),\n\t\t\t\tredo: () => editor?.chain().focus().redo().run(),\n\t\t\t\tcanUndo: () => editor?.can().undo() ?? false,\n\t\t\t\tcanRedo: () => editor?.can().redo() ?? false,\n\t\t\t\ttoggleSuperscript: () =>\n\t\t\t\t\teditor?.chain().focus().toggleSuperscript().run(),\n\t\t\t\ttoggleSubscript: () => editor?.chain().focus().toggleSubscript().run(),\n\t\t\t\tinsertImage: (src) => editor?.chain().focus().setImage({ src }).run(),\n\t\t\t},\n\t\t}),\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[editor],\n\t);\n\n\tif (!editor) return null;\n\n\treturn (\n\t\t<BikEditorShell\n\t\t\tminHeight={minHeight}\n\t\t\tmaxHeight={maxHeight}\n\t\t\tstyle={style}\n\t\t\tclassName={className}\n\t\t>\n\t\t\t<EditorContent editor={editor} />\n\t\t\t<LinkBubbleMenu editor={editor} renderLinkTooltip={link?.renderTooltip} />\n\t\t</BikEditorShell>\n\t);\n};\n\nexport const BikEditor = forwardRef<BikEditorRef, BikEditorProps>(\n\tBikEditorInner,\n);\nBikEditor.displayName = 'BikEditor';\n"],"names":["cssToString","style","Object","entries","map","_ref","k","v","replace","c","toLowerCase","join","BikEditorInner","props","ref","initialContent","sections","features","disabled","maxCharacters","shortcuts","sendShortcut","mentions","slashCommands","link","onPaste","onReady","onChange","onSend","onFocus","onBlur","onSelectionChange","minHeight","maxHeight","className","editorClassName","editorStyle","initialEditorContent","length","buildSectionedContent","normalizeHtml","s","assign","content","pendingQueue","useRef","hasCalledOnReady","onReadyRef","current","onChangeRef","onSelectionChangeRef","onFocusRef","onBlurRef","onSendRef","editor","useEditor","extensions","buildExtensions","placeholder","hasSections","_a","agents","teams","items","snapshot","call","undefined","onMentionSelected","onSelect","onSlashCommandSelected","renderMentionItem","renderItem","renderMentionDropdown","renderDropdown","renderSlashCommandItem","renderSlashCommandDropdown","editable","immediatelyRender","editorProps","attributes","class","onUpdate","_ref2","e","extractContent","onTransaction","_ref3","extractActiveFormats","enqueue","op","push","useEffect","splice","forEach","useImperativeHandle","focus","position","commands","blur","clearContent","setContent","html","normalised","emitUpdate","insertContent","insertInlineContent","insertInlineHtml","insertAtStart","insertContentAt","insertBlock","state","doc","size","appendInline","insertAtEnd","this","appendContent","getContent","text","isEmpty","characterCount","getJSON","getMentions","agentIds","Set","teamIds","descendants","node","type","name","attrs","add","String","Array","from","getCursorPosition","to","selection","insertAtPosition","pos","getSelectedText","empty","textBetween","linkMarkType","schema","marks","range","getMarkRange","resolve","getCharacterCount","count","_d","_c","_b","storage","characters","getText","limit","getSectionContent","sectionId","extractSectionContent","setSectionContent","setSectionContentInEditor","focusSection","endOfBody","chain","setTextSelection","run","targetPos","nodeSize","clearSection","getBodyContent","extractBodyContent","setBodyContent","setBodyAndSections","body","id","appendBodyContent","boundaryPos","findSectionEndPos","insertAtSectionStart","findSectionStartPos","insertAtSectionEnd","getActiveFormats","DEFAULT_FORMAT_STATE","actions","toggleBold","toggleItalic","toggleUnderline","toggleStrike","toggleBulletList","toggleOrderedList","toggleBlockquote","toggleCodeBlock","setTextAlign","align","setFontFamily","font","setFontSize","setColor","color","setHighlight","toggleHighlight","unsetColor","unsetHighlight","setLink","href","extendMarkRange","command","_ref4","tr","linkNode","create","space","replaceWith","updateLink","removeLink","unsetLink","insertEmoji","emoji","insertVariable","variableName","insertHtml","undo","redo","canUndo","can","canRedo","toggleSuperscript","toggleSubscript","insertImage","src","setImage","_jsxs","BikEditorShell","children","_jsx","jsx","EditorContent","LinkBubbleMenu","renderLinkTooltip","renderTooltip","BikEditor","forwardRef","displayName"],"mappings":"2YAqCA,SAASA,EAAYC,GACpB,OAAOC,OAAOC,QAAQF,GACpBG,KACAC,IAAA,IAAEC,EAAGC,GAAEF,EAAA,MAAK,GAAGC,EAAEE,QAAQ,YAAaC,OAAUA,EAAEC,qBAAoBH,GAAG,IAEzEI,KAAK,IACR,CAEA,MAAMC,EAAiBA,CACtBC,EACAC,WAEA,MAAMC,eACLA,EAAcC,SACdA,EAAQC,SACRA,EAAQC,SACRA,EAAQC,cACRA,EAAaC,UACbA,EAASC,aACTA,EAAYC,SACZA,EAAQC,cACRA,EAAaC,KACbA,EAAIC,QACJA,EAAOC,QACPA,EAAOC,SACPA,EAAQC,OACRA,EAAMC,QACNA,EAAOC,OACPA,EAAMC,kBACNA,EAAiBC,UACjBA,EAASC,UACTA,EAAShC,MACTA,EAAKiC,UAC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yI,SAAS,CAAED,QAAOhE,UAIlE,CAACjH,IAGGA,EAGJmL,OAACC,EAAAA,eAAcxO,OAAAwC,OAAA,CACdV,UAAWA,EACXC,UAAWA,EACXhC,MAAOA,EACPiC,UAAWA,GAEX,CAAAyM,SAAA,CAAAC,EAAAC,IAACC,gBAAa,CAACxL,OAAQA,IACvBsL,EAAAC,IAACE,iBAAe,CAAAzL,OAAQA,EAAQ0L,kBAAmBxN,aAAA,EAAAA,EAAMyN,oBAVvC,IAWF,EAINC,EAAYC,EAAUA,WAClCvO,GAEDsO,EAAUE,YAAc"}
1
+ {"version":3,"file":"BikEditor.js","sources":["../../../src/editor/BikEditor.tsx"],"sourcesContent":["'use client';\n\n/**\n * IMPLEMENTATION LAYER — TipTap-specific.\n * If the underlying editor is swapped, this file changes; BikEditor.types.ts and\n * src/editor/index.ts (the consumer contract) do NOT change.\n */\nimport { Editor, getMarkRange } from '@tiptap/core';\nimport { EditorContent, useEditor } from '@tiptap/react';\nimport React, {\n\tforwardRef,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseRef,\n} from 'react';\nimport { BikEditorShell } from './BikEditor.styles';\nimport {\n\tBikEditorProps,\n\tBikEditorRef,\n\tDEFAULT_FORMAT_STATE,\n} from './BikEditor.types';\nimport {\n\tbuildSectionedContent,\n\textractActiveFormats,\n\textractBodyContent,\n\textractContent,\n\textractSectionContent,\n\tfindSectionEndPos,\n\tfindSectionStartPos,\n\tinsertInlineHtml,\n\tnormalizeHtml,\n\tsetSectionContentInEditor,\n} from './BikEditor.utils';\nimport { buildExtensions } from './extensions/buildExtensions';\nimport { LinkBubbleMenu } from './floating/LinkBubbleMenu';\n\n/** Convert React.CSSProperties to an inline CSS string for editorProps.attributes. */\nfunction cssToString(style: React.CSSProperties): string {\n\treturn Object.entries(style)\n\t\t.map(\n\t\t\t([k, v]) => `${k.replace(/([A-Z])/g, (c) => `-${c.toLowerCase()}`)}:${v}`,\n\t\t)\n\t\t.join(';');\n}\n\nconst BikEditorInner = (\n\tprops: BikEditorProps,\n\tref: React.Ref<BikEditorRef>,\n) => {\n\tconst {\n\t\tinitialContent,\n\t\tsections,\n\t\tfeatures,\n\t\tdisabled,\n\t\tmaxCharacters,\n\t\tshortcuts,\n\t\tsendShortcut,\n\t\tmentions,\n\t\tslashCommands,\n\t\tlink,\n\t\tonPaste,\n\t\tonReady,\n\t\tonChange,\n\t\tonSend,\n\t\tonFocus,\n\t\tonBlur,\n\t\tonSelectionChange,\n\t\tminHeight,\n\t\tmaxHeight,\n\t\tstyle,\n\t\tclassName,\n\t\teditorClassName,\n\t\teditorStyle,\n\t} = props;\n\n\tconst initialEditorContent = sections?.length\n\t\t? buildSectionedContent(\n\t\t\t\tnormalizeHtml(initialContent ?? ''),\n\t\t\t\tsections.map((s) => ({ ...s, content: normalizeHtml(s.content) })),\n\t\t )\n\t\t: normalizeHtml(initialContent ?? '');\n\n\t// ── Command queue ─────────────────────────────────────────────────────────\n\t// TipTap's useEditor initializes asynchronously; the editor instance is null\n\t// until the first commit. Any imperative method called before the editor is\n\t// ready is enqueued here and flushed automatically once it becomes non-null.\n\t// Consumers never need setTimeout or readiness guards.\n\tconst pendingQueue = useRef<Array<(e: Editor) => void>>([]);\n\tconst hasCalledOnReady = useRef(false);\n\t// Keep stable refs to all callbacks so useEditor receives the same function\n\t// identity on every render — prevents TipTap from re-registering event\n\t// handlers every time the parent re-renders with new inline function props.\n\tconst onReadyRef = useRef(onReady);\n\tonReadyRef.current = onReady;\n\tconst onChangeRef = useRef(onChange);\n\tonChangeRef.current = onChange;\n\tconst onSelectionChangeRef = useRef(onSelectionChange);\n\tonSelectionChangeRef.current = onSelectionChange;\n\tconst onFocusRef = useRef(onFocus);\n\tonFocusRef.current = onFocus;\n\tconst onBlurRef = useRef(onBlur);\n\tonBlurRef.current = onBlur;\n\tconst onSendRef = useRef(onSend);\n\tonSendRef.current = onSend;\n\tconst agentMentionsRef = useRef(mentions?.agents ?? []);\n\tagentMentionsRef.current = mentions?.agents ?? [];\n\tconst teamMentionsRef = useRef(mentions?.teams ?? []);\n\tteamMentionsRef.current = mentions?.teams ?? [];\n\tconst slashCommandsRef = useRef(slashCommands?.items ?? []);\n\tslashCommandsRef.current = slashCommands?.items ?? [];\n\n\tconst editor = useEditor({\n\t\textensions: buildExtensions({\n\t\t\tfeatures,\n\t\t\tplaceholder: props.placeholder,\n\t\t\tmaxCharacters,\n\t\t\thasSections: (sections?.length ?? 0) > 0,\n\t\t\tmentions: {\n\t\t\t\tagents: mentions?.agents ? agentMentionsRef : undefined,\n\t\t\t\tteams: mentions?.teams ? teamMentionsRef : undefined,\n\t\t\t},\n\t\t\tslashCommands: slashCommands?.items ? slashCommandsRef : undefined,\n\t\t\tonPaste,\n\t\t\tonSend: onSend ? (snapshot) => onSendRef.current?.(snapshot) : undefined,\n\t\t\tsendShortcut,\n\t\t\tshortcuts,\n\t\t\tonMentionSelected: mentions?.onSelect,\n\t\t\tonSlashCommandSelected: slashCommands?.onSelect,\n\t\t\trenderMentionItem: mentions?.renderItem,\n\t\t\trenderMentionDropdown: mentions?.renderDropdown,\n\t\t\trenderSlashCommandItem: slashCommands?.renderItem,\n\t\t\trenderSlashCommandDropdown: slashCommands?.renderDropdown,\n\t\t}),\n\t\tcontent: initialEditorContent,\n\t\teditable: !disabled,\n\t\timmediatelyRender: false, // SSR-safe — NEVER remove this\n\t\teditorProps: {\n\t\t\tattributes: {\n\t\t\t\t...(editorClassName ? { class: editorClassName } : {}),\n\t\t\t\t...(editorStyle ? { style: cssToString(editorStyle) } : {}),\n\t\t\t},\n\t\t},\n\t\tonUpdate: ({ editor: e }) => {\n\t\t\tonChangeRef.current?.(extractContent(e));\n\t\t},\n\t\tonTransaction: ({ editor: e }) => {\n\t\t\tonSelectionChangeRef.current?.(extractActiveFormats(e));\n\t\t},\n\t\tonFocus: () => onFocusRef.current?.(),\n\t\tonBlur: () => onBlurRef.current?.(),\n\t});\n\n\t// ── enqueue ───────────────────────────────────────────────────────────────\n\t// Run immediately if the editor is ready; otherwise defer to the queue.\n\t// Closures passed to enqueue MUST capture all parameters explicitly —\n\t// they must NOT close over `editor` (which would be null at enqueue time).\n\tfunction enqueue(op: (e: Editor) => void): void {\n\t\tif (editor) {\n\t\t\top(editor);\n\t\t} else {\n\t\t\tpendingQueue.current.push(op);\n\t\t}\n\t}\n\n\t// Flush the pending queue and fire onReady when editor transitions null → ready.\n\tuseEffect(() => {\n\t\tif (!editor) return;\n\t\tif (pendingQueue.current.length > 0) {\n\t\t\tconst queue = pendingQueue.current.splice(0);\n\t\t\tqueue.forEach((op) => op(editor));\n\t\t}\n\t\tif (!hasCalledOnReady.current) {\n\t\t\thasCalledOnReady.current = true;\n\t\t\tonReadyRef.current?.();\n\t\t}\n\t}, [editor]);\n\n\tuseImperativeHandle(\n\t\tref,\n\t\t() => ({\n\t\t\t// ── Focus ────────────────────────────────────────────────────────\n\t\t\tfocus: (position) => enqueue((e) => e.commands.focus(position)),\n\t\t\tblur: () => enqueue((e) => e.commands.blur()),\n\n\t\t\t// ── Content ──────────────────────────────────────────────────────\n\t\t\tclearContent: () => enqueue((e) => e.commands.clearContent(true)),\n\t\t\tsetContent: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => e.commands.setContent(normalised, { emitUpdate: true }));\n\t\t\t},\n\t\t\tinsertContent: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => e.commands.insertContent(normalised));\n\t\t\t},\n\t\t\tinsertInlineContent: (html) => {\n\t\t\t\tenqueue((e) => insertInlineHtml(e, html));\n\t\t\t},\n\t\t\tinsertAtStart: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => e.commands.insertContentAt(1, normalised));\n\t\t\t},\n\t\t\tinsertBlock: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) =>\n\t\t\t\t\te.commands.insertContentAt(e.state.doc.content.size, normalised),\n\t\t\t\t);\n\t\t\t},\n\t\t\tappendInline: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\t// doc.content.size is after the last </p> (block boundary).\n\t\t\t\t// Subtract 1 to land inside the last paragraph so text appends\n\t\t\t\t// inline rather than being wrapped in a new paragraph each call.\n\t\t\t\tenqueue((e) =>\n\t\t\t\t\te.commands.insertContentAt(e.state.doc.content.size - 1, normalised),\n\t\t\t\t);\n\t\t\t},\n\t\t\t// Backwards-compatible aliases\n\t\t\tinsertAtEnd(html) {\n\t\t\t\tthis.insertBlock(html);\n\t\t\t},\n\t\t\tappendContent(html) {\n\t\t\t\tthis.appendInline(html);\n\t\t\t},\n\t\t\tgetContent: () =>\n\t\t\t\teditor\n\t\t\t\t\t? extractContent(editor)\n\t\t\t\t\t: { html: '', text: '', isEmpty: true, characterCount: 0 },\n\t\t\tgetJSON: () => editor?.getJSON() ?? null,\n\t\t\tgetMentions: () => {\n\t\t\t\tconst agentIds = new Set<string>();\n\t\t\t\tconst teamIds = new Set<string>();\n\t\t\t\tif (!editor) return { agentIds: [], teamIds: [] };\n\t\t\t\teditor.state.doc.descendants((node) => {\n\t\t\t\t\tif (node.type.name === 'mentionAgent' && node.attrs['id'] != null) {\n\t\t\t\t\t\tagentIds.add(String(node.attrs['id']));\n\t\t\t\t\t} else if (\n\t\t\t\t\t\tnode.type.name === 'mentionTeam' &&\n\t\t\t\t\t\tnode.attrs['id'] != null\n\t\t\t\t\t) {\n\t\t\t\t\t\tteamIds.add(String(node.attrs['id']));\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\treturn { agentIds: Array.from(agentIds), teamIds: Array.from(teamIds) };\n\t\t\t},\n\n\t\t\t// ── Selection ────────────────────────────────────────────────────\n\t\t\tgetCursorPosition: () => {\n\t\t\t\tif (!editor) return { from: 0, to: 0 };\n\t\t\t\tconst { from, to } = editor.state.selection;\n\t\t\t\treturn { from, to };\n\t\t\t},\n\t\t\tinsertAtPosition: (pos, html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => e.commands.insertContentAt(pos, normalised));\n\t\t\t},\n\t\t\tgetSelectedText: () => {\n\t\t\t\tif (!editor) return '';\n\t\t\t\tconst { state } = editor;\n\t\t\t\tconst { from, to, empty } = state.selection;\n\t\t\t\tif (!empty) {\n\t\t\t\t\treturn state.doc.textBetween(from, to, ' ');\n\t\t\t\t}\n\t\t\t\t// When the cursor is inside a link with nothing selected, return the\n\t\t\t\t// full link text — useful for pre-filling a link modal's text field.\n\t\t\t\tconst linkMarkType = state.schema.marks['link'];\n\t\t\t\tif (linkMarkType) {\n\t\t\t\t\tconst range = getMarkRange(state.doc.resolve(from), linkMarkType);\n\t\t\t\t\tif (range) {\n\t\t\t\t\t\treturn state.doc.textBetween(range.from, range.to, ' ');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn '';\n\t\t\t},\n\n\t\t\t// ── Character count ───────────────────────────────────────────────\n\t\t\tgetCharacterCount: () => ({\n\t\t\t\tcount:\n\t\t\t\t\teditor?.storage.characterCount?.characters?.() ??\n\t\t\t\t\teditor?.getText().length ??\n\t\t\t\t\t0,\n\t\t\t\tlimit: maxCharacters ?? null,\n\t\t\t}),\n\n\t\t\t// ── Sections ─────────────────────────────────────────────────────\n\t\t\tgetSectionContent: (sectionId) =>\n\t\t\t\teditor\n\t\t\t\t\t? extractSectionContent(editor, sectionId)\n\t\t\t\t\t: { html: '', text: '', isEmpty: true, characterCount: 0 },\n\n\t\t\tsetSectionContent: (sectionId, html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => setSectionContentInEditor(e, sectionId, normalised));\n\t\t\t},\n\n\t\t\tfocusSection: (sectionId) => {\n\t\t\t\tenqueue((e) => {\n\t\t\t\t\tif (sectionId === 'body') {\n\t\t\t\t\t\tlet endOfBody = e.state.doc.content.size - 1;\n\t\t\t\t\t\te.state.doc.descendants((node, pos) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tnode.type.name === 'sectionDivider' &&\n\t\t\t\t\t\t\t\tendOfBody === e.state.doc.content.size - 1\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tendOfBody = pos - 1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn endOfBody === e.state.doc.content.size - 1;\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (endOfBody < 1) endOfBody = 1;\n\t\t\t\t\t\te.chain().focus().setTextSelection(endOfBody).run();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tlet targetPos = -1;\n\t\t\t\t\te.state.doc.descendants((node, pos) => {\n\t\t\t\t\t\tif (targetPos !== -1) return false;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tnode.type.name === 'sectionDivider' &&\n\t\t\t\t\t\t\tnode.attrs['sectionId'] === sectionId\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// pos + nodeSize lands right after the divider;\n\t\t\t\t\t\t\t// +1 more puts us inside the first paragraph of that section.\n\t\t\t\t\t\t\ttargetPos = pos + node.nodeSize + 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\tif (targetPos !== -1) {\n\t\t\t\t\t\te.chain().focus().setTextSelection(targetPos).run();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t},\n\n\t\t\tclearSection: (sectionId) => {\n\t\t\t\tenqueue((e) => setSectionContentInEditor(e, sectionId, '<p></p>'));\n\t\t\t},\n\n\t\t\t// ── Convenience body shorthands ───────────────────────────────────\n\t\t\tgetBodyContent: () =>\n\t\t\t\teditor\n\t\t\t\t\t? extractBodyContent(editor)\n\t\t\t\t\t: { html: '', text: '', isEmpty: true, characterCount: 0 },\n\t\t\tsetBodyContent: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => setSectionContentInEditor(e, 'body', normalised));\n\t\t\t},\n\t\t\tsetBodyAndSections: (body, sections) => {\n\t\t\t\tconst html = buildSectionedContent(\n\t\t\t\t\tnormalizeHtml(body),\n\t\t\t\t\tsections.map((s) => ({\n\t\t\t\t\t\tid: s.id,\n\t\t\t\t\t\tcontent: normalizeHtml(s.content),\n\t\t\t\t\t})),\n\t\t\t\t);\n\t\t\t\tenqueue((e) => e.commands.setContent(html, { emitUpdate: true }));\n\t\t\t},\n\t\t\tappendBodyContent: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\t// findSectionEndPos returns the position of the first divider (or\n\t\t\t\t// doc.content.size), which is the block boundary after the last </p>.\n\t\t\t\t// Subtract 1 to stay inside the last paragraph so successive calls\n\t\t\t\t// append inline text rather than creating a new paragraph each time.\n\t\t\t\tenqueue((e) => {\n\t\t\t\t\tconst boundaryPos = findSectionEndPos(e, 'body');\n\t\t\t\t\te.commands.insertContentAt(boundaryPos - 1, normalised);\n\t\t\t\t});\n\t\t\t},\n\t\t\tinsertAtSectionStart: (sectionId, html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => {\n\t\t\t\t\tconst pos = findSectionStartPos(e, sectionId);\n\t\t\t\t\tif (pos !== -1) e.commands.insertContentAt(pos, normalised);\n\t\t\t\t});\n\t\t\t},\n\t\t\tinsertAtSectionEnd: (sectionId, html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => {\n\t\t\t\t\tconst pos = findSectionEndPos(e, sectionId);\n\t\t\t\t\te.commands.insertContentAt(pos, normalised);\n\t\t\t\t});\n\t\t\t},\n\t\t\t// ── Formats & actions ─────────────────────────────────────────────\n\t\t\tgetActiveFormats: () =>\n\t\t\t\teditor ? extractActiveFormats(editor) : DEFAULT_FORMAT_STATE,\n\t\t\tactions: {\n\t\t\t\ttoggleBold: () => editor?.chain().focus().toggleBold().run(),\n\t\t\t\ttoggleItalic: () => editor?.chain().focus().toggleItalic().run(),\n\t\t\t\ttoggleUnderline: () => editor?.chain().focus().toggleUnderline().run(),\n\t\t\t\ttoggleStrike: () => editor?.chain().focus().toggleStrike().run(),\n\t\t\t\ttoggleBulletList: () =>\n\t\t\t\t\teditor?.chain().focus().toggleBulletList().run(),\n\t\t\t\ttoggleOrderedList: () =>\n\t\t\t\t\teditor?.chain().focus().toggleOrderedList().run(),\n\t\t\t\ttoggleBlockquote: () =>\n\t\t\t\t\teditor?.chain().focus().toggleBlockquote().run(),\n\t\t\t\ttoggleCodeBlock: () => editor?.chain().focus().toggleCodeBlock().run(),\n\t\t\t\tsetTextAlign: (align) =>\n\t\t\t\t\teditor?.chain().focus().setTextAlign(align).run(),\n\t\t\t\tsetFontFamily: (font) =>\n\t\t\t\t\teditor?.chain().focus().setFontFamily(font).run(),\n\t\t\t\tsetFontSize: (size) => editor?.chain().focus().setFontSize(size).run(),\n\t\t\t\tsetColor: (color) => editor?.chain().focus().setColor(color).run(),\n\t\t\t\tsetHighlight: (color) =>\n\t\t\t\t\teditor?.chain().focus().toggleHighlight({ color }).run(),\n\t\t\t\tunsetColor: () => editor?.chain().focus().unsetColor().run(),\n\t\t\t\tunsetHighlight: () => editor?.chain().focus().unsetHighlight().run(),\n\t\t\t\tsetLink: (href, text) => {\n\t\t\t\t\tif (!editor) return;\n\t\t\t\t\tif (text !== undefined) {\n\t\t\t\t\t\teditor\n\t\t\t\t\t\t\t.chain()\n\t\t\t\t\t\t\t.focus()\n\t\t\t\t\t\t\t.extendMarkRange('link')\n\t\t\t\t\t\t\t.command(({ tr, state }) => {\n\t\t\t\t\t\t\t\tconst { from, to } = tr.selection;\n\t\t\t\t\t\t\t\tconst linkMarkType = state.schema.marks['link'];\n\t\t\t\t\t\t\t\tif (!linkMarkType) return false;\n\t\t\t\t\t\t\t\tconst linkNode = state.schema.text(text, [\n\t\t\t\t\t\t\t\t\tlinkMarkType.create({ href }),\n\t\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t\t\tconst space = state.schema.text(' ');\n\t\t\t\t\t\t\t\ttr.replaceWith(from, to, [linkNode, space]);\n\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.run();\n\t\t\t\t\t} else {\n\t\t\t\t\t\teditor\n\t\t\t\t\t\t\t.chain()\n\t\t\t\t\t\t\t.focus()\n\t\t\t\t\t\t\t.extendMarkRange('link')\n\t\t\t\t\t\t\t.setLink({ href })\n\t\t\t\t\t\t\t.insertContent(' ')\n\t\t\t\t\t\t\t.run();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tupdateLink: (href) =>\n\t\t\t\t\teditor\n\t\t\t\t\t\t?.chain()\n\t\t\t\t\t\t.focus()\n\t\t\t\t\t\t.extendMarkRange('link')\n\t\t\t\t\t\t.setLink({ href })\n\t\t\t\t\t\t.run(),\n\t\t\t\tremoveLink: () =>\n\t\t\t\t\teditor?.chain().focus().extendMarkRange('link').unsetLink().run(),\n\t\t\t\tinsertEmoji: (emoji) =>\n\t\t\t\t\teditor?.chain().focus().insertContent(emoji).run(),\n\t\t\t\tinsertVariable: (variableName) =>\n\t\t\t\t\teditor?.chain().focus().insertContent(`{{${variableName}}}`).run(),\n\t\t\t\tinsertHtml: (html) =>\n\t\t\t\t\teditor?.commands.insertContent(normalizeHtml(html)),\n\t\t\t\tundo: () => editor?.chain().focus().undo().run(),\n\t\t\t\tredo: () => editor?.chain().focus().redo().run(),\n\t\t\t\tcanUndo: () => editor?.can().undo() ?? false,\n\t\t\t\tcanRedo: () => editor?.can().redo() ?? false,\n\t\t\t\ttoggleSuperscript: () =>\n\t\t\t\t\teditor?.chain().focus().toggleSuperscript().run(),\n\t\t\t\ttoggleSubscript: () => editor?.chain().focus().toggleSubscript().run(),\n\t\t\t\tinsertImage: (src) => editor?.chain().focus().setImage({ src }).run(),\n\t\t\t},\n\t\t}),\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[editor],\n\t);\n\n\tif (!editor) return null;\n\n\treturn (\n\t\t<BikEditorShell\n\t\t\tminHeight={minHeight}\n\t\t\tmaxHeight={maxHeight}\n\t\t\tstyle={style}\n\t\t\tclassName={className}\n\t\t>\n\t\t\t<EditorContent editor={editor} />\n\t\t\t<LinkBubbleMenu editor={editor} renderLinkTooltip={link?.renderTooltip} />\n\t\t</BikEditorShell>\n\t);\n};\n\nexport const BikEditor = forwardRef<BikEditorRef, BikEditorProps>(\n\tBikEditorInner,\n);\nBikEditor.displayName = 'BikEditor';\n"],"names":["cssToString","style","Object","entries","map","_ref","k","v","replace","c","toLowerCase","join","BikEditorInner","props","ref","initialContent","sections","features","disabled","maxCharacters","shortcuts","sendShortcut","mentions","slashCommands","link","onPaste","onReady","onChange","onSend","onFocus","onBlur","onSelectionChange","minHeight","maxHeight","className","editorClassName","editorStyle","initialEditorContent","length","buildSectionedContent","normalizeHtml","s","assign","content","pendingQueue","useRef","hasCalledOnReady","onReadyRef","current","onChangeRef","onSelectionChangeRef","onFocusRef","onBlurRef","onSendRef","agentMentionsRef","agents","_a","_b","teamMentionsRef","teams","_c","_d","slashCommandsRef","items","_e","_f","editor","useEditor","extensions","buildExtensions","placeholder","hasSections","_g","undefined","snapshot","call","onMentionSelected","onSelect","onSlashCommandSelected","renderMentionItem","renderItem","renderMentionDropdown","renderDropdown","renderSlashCommandItem","renderSlashCommandDropdown","editable","immediatelyRender","editorProps","attributes","class","onUpdate","_ref2","e","extractContent","onTransaction","_ref3","extractActiveFormats","enqueue","op","push","useEffect","splice","forEach","useImperativeHandle","focus","position","commands","blur","clearContent","setContent","html","normalised","emitUpdate","insertContent","insertInlineContent","insertInlineHtml","insertAtStart","insertContentAt","insertBlock","state","doc","size","appendInline","insertAtEnd","this","appendContent","getContent","text","isEmpty","characterCount","getJSON","getMentions","agentIds","Set","teamIds","descendants","node","type","name","attrs","add","String","Array","from","getCursorPosition","to","selection","insertAtPosition","pos","getSelectedText","empty","textBetween","linkMarkType","schema","marks","range","getMarkRange","resolve","getCharacterCount","count","storage","characters","getText","limit","getSectionContent","sectionId","extractSectionContent","setSectionContent","setSectionContentInEditor","focusSection","endOfBody","chain","setTextSelection","run","targetPos","nodeSize","clearSection","getBodyContent","extractBodyContent","setBodyContent","setBodyAndSections","body","id","appendBodyContent","boundaryPos","findSectionEndPos","insertAtSectionStart","findSectionStartPos","insertAtSectionEnd","getActiveFormats","DEFAULT_FORMAT_STATE","actions","toggleBold","toggleItalic","toggleUnderline","toggleStrike","toggleBulletList","toggleOrderedList","toggleBlockquote","toggleCodeBlock","setTextAlign","align","setFontFamily","font","setFontSize","setColor","color","setHighlight","toggleHighlight","unsetColor","unsetHighlight","setLink","href","extendMarkRange","command","_ref4","tr","linkNode","create","space","replaceWith","updateLink","removeLink","unsetLink","insertEmoji","emoji","insertVariable","variableName","insertHtml","undo","redo","canUndo","can","canRedo","toggleSuperscript","toggleSubscript","insertImage","src","setImage","_jsxs","BikEditorShell","children","_jsx","jsx","EditorContent","LinkBubbleMenu","renderLinkTooltip","renderTooltip","BikEditor","forwardRef","displayName"],"mappings":"2YAqCA,SAASA,EAAYC,GACpB,OAAOC,OAAOC,QAAQF,GACpBG,KACAC,IAAA,IAAEC,EAAGC,GAAEF,EAAA,MAAK,GAAGC,EAAEE,QAAQ,YAAaC,OAAUA,EAAEC,qBAAoBH,GAAG,IAEzEI,KAAK,IACR,CAEA,MAAMC,EAAiBA,CACtBC,EACAC,uBAEA,MAAMC,eACLA,EAAcC,SACdA,EAAQC,SACRA,EAAQC,SACRA,EAAQC,cACRA,EAAaC,UACbA,EAASC,aACTA,EAAYC,SACZA,EAAQC,cACRA,EAAaC,KACbA,EAAIC,QACJA,EAAOC,QACPA,EAAOC,SACPA,EAAQC,OACRA,EAAMC,QACNA,EAAOC,OACPA,EAAMC,kBACNA,EAAiBC,UACjBA,EAASC,UACTA,EAAShC,MACTA,EAAKiC,UACLA,EAASC,gBACTA,EAAeC,YACfA,GACGvB,EAEEwB,GAAuBrB,aAAQ,EAARA,EAAUsB,QACpCC,EAAqBA,sBACrBC,EAAaA,cAACzB,QAAAA,EAAkB,IAChCC,EAASZ,KAAKqC,GAAYv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OzD,MAC3C0D,QAASA,WAAM,OAAwB,QAAxB/K,EAAAU,gBAAAA,GAAQsK,MAAMH,cAAU,IAAA7K,GAAAA,CAAK,EAC5CiL,QAASA,WAAM,OAAwB,QAAxBjL,EAAAU,gBAAAA,GAAQsK,MAAMF,cAAU,IAAA9K,GAAAA,CAAK,EAC5CkL,kBAAmBA,IAClBxK,cAAM,EAANA,GAAQyG,QAAQnE,QAAQkI,oBAAoB7D,MAC7C8D,gBAAiBA,IAAMzK,cAAM,EAANA,GAAQyG,QAAQnE,QAAQmI,kBAAkB9D,MACjE+D,YAAcC,GAAQ3K,cAAA,EAAAA,GAAQyG,QAAQnE,QAAQsI,SAAS,CAAED,QAAOhE,UAIlE,CAAC3G,KAGGA,GAGJ6K,OAACC,EAAAA,eAAc9O,OAAAwC,OAAA,CACdV,UAAWA,EACXC,UAAWA,EACXhC,MAAOA,EACPiC,UAAWA,GAEX,CAAA+M,SAAA,CAAAC,EAAAC,IAACC,gBAAa,CAAClL,OAAQA,KACvBgL,EAAAC,IAACE,iBAAe,CAAAnL,OAAQA,GAAQoL,kBAAmB9N,aAAA,EAAAA,EAAM+N,oBAVvC,IAWF,EAINC,EAAYC,EAAUA,WAClC7O,GAED4O,EAAUE,YAAc"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@tiptap/extension-character-count"),n=require("@tiptap/extension-color"),t=require("@tiptap/extension-font-family"),i=require("@tiptap/extension-highlight"),o=require("@tiptap/extension-image"),r=require("@tiptap/extension-link"),a=require("@tiptap/extension-placeholder"),l=require("@tiptap/extension-subscript"),s=require("@tiptap/extension-superscript"),d=require("@tiptap/extension-text-align"),u=require("@tiptap/extension-text-style"),p=require("@tiptap/extension-underline"),c=require("@tiptap/starter-kit"),x=require("./FontSizeExtension.js"),m=require("./mention/MentionExtension.js"),f=require("./paste/PasteExtension.js"),h=require("./plainClipboard/PlainClipboardExtension.js"),v=require("./sectionDivider/SectionDividerNode.js"),S=require("./sendShortcut/SendShortcutExtension.js"),g=require("./slashCommand/SlashCommandExtension.js"),q=require("./variable/VariableDecorationExtension.js");function b(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var E=b(e),C=b(n),M=b(t),k=b(i),P=b(o),j=b(r),y=b(a),D=b(l),T=b(s),w=b(d),I=b(p),O=b(c);exports.buildExtensions=function(e){var n,t,i,o,r,a,l,s,d,p,c,b;const z=null!==(t=null===(n=e.features)||void 0===n?void 0:n.richPaste)&&void 0!==t&&t,A=null!==(o=null===(i=e.features)||void 0===i?void 0:i.richTypography)&&void 0!==o&&o,F=null===(r=e.features)||void 0===r?void 0:r.allowedMarks,N=e=>!F||F.includes(e);return[...[O.default.configure({link:!1,underline:!1,bold:!!N("bold")&&{},italic:!!N("italic")&&{},strike:!!N("strike")&&{},code:!!N("code")&&{}}),...N("underline")?[I.default]:[],j.default.extend({addPasteRules:()=>[],addInputRules:()=>[]}).configure({openOnClick:!1,autolink:!1,linkOnPaste:!1,HTMLAttributes:{rel:"noopener noreferrer",class:"bik-link"}}),u.TextStyle,y.default.configure({placeholder:null!==(a=e.placeholder)&&void 0!==a?a:"Type a message..."}),...e.onPaste?[f.PasteExtension.configure({onPaste:e.onPaste})]:[],...z?[]:[h.PlainClipboardExtension],S.SendShortcutExtension.configure({onSend:e.onSend,sendShortcut:e.sendShortcut,extraShortcuts:null!==(l=e.shortcuts)&&void 0!==l?l:[]}),q.VariableDecorationExtension,...e.maxCharacters?[E.default.configure({limit:e.maxCharacters})]:[],v.SectionDividerNode],...[...(null===(d=null===(s=e.mentions)||void 0===s?void 0:s.agents)||void 0===d?void 0:d.length)?[m.buildAgentMentionExtension(e.mentions.agents,e.onMentionSelected,e.renderMentionItem,e.renderMentionDropdown)]:[],...(null===(c=null===(p=e.mentions)||void 0===p?void 0:p.teams)||void 0===c?void 0:c.length)?[m.buildTeamMentionExtension(e.mentions.teams,e.onMentionSelected,e.renderMentionItem,e.renderMentionDropdown)]:[],...(null===(b=e.slashCommands)||void 0===b?void 0:b.length)?[g.buildSlashCommandExtension(e.slashCommands,e.onSlashCommandSelected,e.renderSlashCommandItem,e.renderSlashCommandDropdown)]:[]],...A?[C.default,k.default.configure({multicolor:!0}),M.default,x.FontSizeExtension,w.default.configure({types:["heading","paragraph"]}),D.default,T.default,P.default]:[C.default]]};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@tiptap/extension-character-count"),n=require("@tiptap/extension-color"),t=require("@tiptap/extension-font-family"),i=require("@tiptap/extension-highlight"),o=require("@tiptap/extension-image"),r=require("@tiptap/extension-link"),a=require("@tiptap/extension-placeholder"),s=require("@tiptap/extension-subscript"),l=require("@tiptap/extension-superscript"),d=require("@tiptap/extension-text-align"),u=require("@tiptap/extension-text-style"),p=require("@tiptap/extension-underline"),c=require("@tiptap/starter-kit"),x=require("./FontSizeExtension.js"),m=require("./mention/MentionExtension.js"),f=require("./paste/PasteExtension.js"),h=require("./plainClipboard/PlainClipboardExtension.js"),S=require("./sectionDivider/SectionDividerNode.js"),v=require("./sendShortcut/SendShortcutExtension.js"),q=require("./slashCommand/SlashCommandExtension.js"),g=require("./variable/VariableDecorationExtension.js");function b(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var E=b(e),C=b(n),M=b(t),k=b(i),P=b(o),j=b(r),y=b(a),D=b(s),T=b(l),w=b(d),I=b(p),O=b(c);exports.buildExtensions=function(e){var n,t,i,o,r,a,s,l,d;const p=null!==(t=null===(n=e.features)||void 0===n?void 0:n.richPaste)&&void 0!==t&&t,c=null!==(o=null===(i=e.features)||void 0===i?void 0:i.richTypography)&&void 0!==o&&o,b=null===(r=e.features)||void 0===r?void 0:r.allowedMarks,z=e=>!b||b.includes(e);return[...[O.default.configure({link:!1,underline:!1,bold:!!z("bold")&&{},italic:!!z("italic")&&{},strike:!!z("strike")&&{},code:!!z("code")&&{}}),...z("underline")?[I.default]:[],j.default.extend({addPasteRules:()=>[],addInputRules:()=>[]}).configure({openOnClick:!1,autolink:!1,linkOnPaste:!1,HTMLAttributes:{rel:"noopener noreferrer",class:"bik-link"}}),u.TextStyle,y.default.configure({placeholder:null!==(a=e.placeholder)&&void 0!==a?a:"Type a message..."}),...e.onPaste?[f.PasteExtension.configure({onPaste:e.onPaste})]:[],...p?[]:[h.PlainClipboardExtension],v.SendShortcutExtension.configure({onSend:e.onSend,sendShortcut:e.sendShortcut,extraShortcuts:null!==(s=e.shortcuts)&&void 0!==s?s:[]}),g.VariableDecorationExtension,...e.maxCharacters?[E.default.configure({limit:e.maxCharacters})]:[],S.SectionDividerNode],...[...(null===(l=e.mentions)||void 0===l?void 0:l.agents)?[m.buildAgentMentionExtension(e.mentions.agents,e.onMentionSelected,e.renderMentionItem,e.renderMentionDropdown)]:[],...(null===(d=e.mentions)||void 0===d?void 0:d.teams)?[m.buildTeamMentionExtension(e.mentions.teams,e.onMentionSelected,e.renderMentionItem,e.renderMentionDropdown)]:[],...e.slashCommands?[q.buildSlashCommandExtension(e.slashCommands,e.onSlashCommandSelected,e.renderSlashCommandItem,e.renderSlashCommandDropdown)]:[]],...c?[C.default,k.default.configure({multicolor:!0}),M.default,x.FontSizeExtension,w.default.configure({types:["heading","paragraph"]}),D.default,T.default,P.default]:[C.default]]};
2
2
  //# sourceMappingURL=buildExtensions.js.map
@@ -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\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":["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":"kpCAiEM,SAA0BA,+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,EAAAA,QAAWC,UAAU,CACpBC,MAAM,EACNC,WAAW,EACXC,OAAMP,EAAO,SAAU,CAAE,EACzBQ,SAAQR,EAAO,WAAY,CAAE,EAC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EAAOsE,6BAGR,OAGmBhE,EACpB,CACAiE,EAAAA,QACAC,EAAAA,QAAUxD,UAAU,CAAEyD,YAAY,IAClCC,EAAU,QACVC,oBACAC,EAAAA,QAAU5D,UAAU,CAAE6D,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 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":["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":"kpCAoEM,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,SAASD,GAuGxC,MAAO,IArGM,CAIZE,EAAAA,QAAWC,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,EAAAA,SAAa,GAGxCC,EAAAA,QAAKC,OAAO,CACXC,cAAeA,IAAM,GACrBC,cAAeA,IAAM,KACnBX,UAAU,CACZY,aAAa,EACbC,UAAU,EACVC,aAAa,EACbC,eAAgB,CACfC,IAAK,sBACLC,MAAO,cAGTC,EAAAA,UACAC,EAAW,QAACnB,UAAU,CACrBoB,oBAAaC,EAAArC,EAAOoC,2BAAe,yBAKhCpC,EAAOsC,QACR,CAACC,EAAAA,eAAevB,UAAU,CAAEsB,QAAStC,EAAOsC,WAC5C,MAEErC,EAA2C,GAA5B,CAACuC,EAAuBA,yBAC5CC,EAAqBA,sBAACzB,UAAU,CAC/B0B,OAAQ1C,EAAO0C,OACfC,aAAc3C,EAAO2C,aACrBC,uBAAgBC,EAAA7C,EAAO8C,yBAAa,KAErCC,EAA2BA,+BACvB/C,EAAOgD,cACR,CAACC,EAAc,QAACjC,UAAU,CAAEkC,MAAOlD,EAAOgD,iBAC1C,GAKHG,EAAAA,uBAGyB,aACrBC,EAAApD,EAAOqD,+BAAUC,QAClB,CACAC,6BACCvD,EAAOqD,SAASC,OAChBtD,EAAOwD,kBACPxD,EAAOyD,kBACPzD,EAAO0D,wBAGR,eACCC,EAAA3D,EAAOqD,+BAAUO,OAClB,CACAC,EAAyBA,0BACxB7D,EAAOqD,SAASO,MAChB5D,EAAOwD,kBACPxD,EAAOyD,kBACPzD,EAAO0D,wBAGR,MACC1D,EAAO8D,cACR,CACAC,EAAAA,2BACC/D,EAAO8D,cACP9D,EAAOgE,uBACPhE,EAAOiE,uBACPjE,EAAOkE,6BAGR,OAGmB5D,EACpB,CACA6D,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,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-mention"),n=require("@tiptap/react"),r=require("../suggestionPopup.js"),o=require("./MentionDropdown.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=i(t);function a(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.ReactRenderer(o.MentionDropdown,{props:Object.assign(Object.assign({},a),{renderItem:t,renderDropdown:i}),editor:a.editor}),s=r.createSuggestionPopup(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()}}}}exports.buildAgentMentionExtension=function(t,n,r,o){return s.default.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.mergeAttributes(n.HTMLAttributes),`${n.suggestion.char}${r.attrs.label}`]},suggestion:{char:"@",items:e=>{let{query:n}=e;return t.filter((e=>e.label.toLowerCase().includes(n.toLowerCase())))},command:e=>{let{editor:t,range:r,props:o}=e;t.chain().focus().deleteRange(r).insertContent({type:"mentionAgent",attrs:{id:o.id,label:o.label}}).run(),null==n||n(o,"@")},render:a(n,"@",r,o)}})},exports.buildTeamMentionExtension=function(t,n,r,o){return s.default.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.mergeAttributes(n.HTMLAttributes),`${n.suggestion.char}${r.attrs.label}`]},suggestion:{char:"#",items:e=>{let{query:n}=e;return t.filter((e=>e.label.toLowerCase().includes(n.toLowerCase())))},command:e=>{let{editor:t,range:r,props:o}=e;t.chain().focus().deleteRange(r).insertContent({type:"mentionTeam",attrs:{id:o.id,label:o.label}}).run(),null==n||n(o,"#")},render:a(n,"#",r,o)}})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../node_modules/@tiptap/core/dist/index.js"),t=require("@tiptap/extension-mention"),n=require("@tiptap/react"),r=require("../suggestionPopup.js"),o=require("./MentionDropdown.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=i(t);function a(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.ReactRenderer(o.MentionDropdown,{props:Object.assign(Object.assign({},a),{renderItem:t,renderDropdown:i}),editor:a.editor}),s=r.createSuggestionPopup(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()}}}}exports.buildAgentMentionExtension=function(t,n,r,o){return s.default.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.mergeAttributes(n.HTMLAttributes),`${n.suggestion.char}${r.attrs.label}`]},suggestion:{char:"@",items:e=>{let{query:n}=e;return t.current.filter((e=>e.label.toLowerCase().includes(n.toLowerCase())))},command:e=>{let{editor:t,range:r,props:o}=e;t.chain().focus().deleteRange(r).insertContent({type:"mentionAgent",attrs:{id:o.id,label:o.label}}).run(),null==n||n(o,"@")},render:a(n,"@",r,o)}})},exports.buildTeamMentionExtension=function(t,n,r,o){return s.default.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.mergeAttributes(n.HTMLAttributes),`${n.suggestion.char}${r.attrs.label}`]},suggestion:{char:"#",items:e=>{let{query:n}=e;return t.current.filter((e=>e.label.toLowerCase().includes(n.toLowerCase())))},command:e=>{let{editor:t,range:r,props:o}=e;t.chain().focus().deleteRange(r).insertContent({type:"mentionTeam",attrs:{id:o.id,label:o.label}}).run(),null==n||n(o,"#")},render:a(n,"#",r,o)}})};
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\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","createSuggestionPopup","element","clientRect","onUpdate","updateProps","Object","assign","_a","items","show","updatePosition","hide","onKeyDown","event","key","_b","ref","onExit","destroy","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","teams","_ref5","_ref6","_ref7","t","_ref8"],"mappings":"gWAcA,SAASA,EACRC,GACqB,IACrBC,EAAgEC,UAAAC,OAAAD,EAAAA,kBAAAE,EAChEC,EAAiEH,UAAAC,OAAAD,EAAAA,kBAAAE,EAEjE,MAAO,KACN,IAAIE,EACAC,EAEJ,MAAO,CACNC,QAAUC,IACTH,EAAY,IAAII,EAAaA,cAACC,kBAAiB,CAC9CF,qC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ACAC,YAAYH,GACZI,cAAc,CACdC,KAAM,eACNlB,MAAO,CAAEmB,GAAIvD,EAAMuD,GAAIX,MAAO5C,EAAM4C,SAEpCY,MACFjE,SAAAA,EAAWS,EAAO,IAAI,EAEvByD,OAAQnE,EAAYC,EAAU,IAAKC,EAAYI,KAGlD,oCAEM,SACL8D,EACAnE,EACAC,EACAI,GAEA,OAAO4B,EAAAA,QAAQC,OAAO,CAAEC,KAAM,gBAAiBC,UAAU,CACxDC,eAAgB,CAAEC,MAAO,iCACzBC,WAAY6B,IAAA,IAAC3B,QAAEA,EAAOC,KAAEA,GAAM0B,EAAA,MAC7B,GAAG3B,EAAQE,WAAWC,OAAOF,EAAKG,MAAa,OAAG,EACnDC,WAAYuB,IAAA,IAAC5B,QAAEA,EAAOC,KAAEA,GAAM2B,EAAA,MAAK,CAClC,OACArB,EAAeA,gBAACP,EAAQJ,gBACxB,GAAGI,EAAQE,WAAWC,OAAOF,EAAKG,MAAa,QAC/C,EACDF,WAAY,CACXC,KAAM,IACNvB,MAAOiD,IAAA,IAACpB,MAAEA,GAA0BoB,EAAA,OACnCH,EAAMhB,QAAQoB,GACbA,EAAElB,MAAMC,cAAcC,SAASL,EAAMI,gBACrC,EACFE,QAASgB,IAAkC,IAAjC5D,OAAEA,EAAM8C,MAAEA,EAAKjD,MAAEA,GAAY+D,EACtC5D,EACE+C,QACAC,QACAC,YAAYH,GACZI,cAAc,CACdC,KAAM,cACNlB,MAAO,CAAEmB,GAAIvD,EAAMuD,GAAIX,MAAO5C,EAAM4C,SAEpCY,MACFjE,SAAAA,EAAWS,EAAO,IAAI,EAEvByD,OAAQnE,EAAYC,EAAU,IAAKC,EAAYI,KAGlD"}
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","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","teamsRef","_ref5","_ref6","_ref7","t","_ref8"],"mappings":"gWAcA,SAASA,EACRC,GACqB,IACrBC,EAAgEC,UAAAC,OAAAD,EAAAA,kBAAAE,EAChEC,EAAiEH,UAAAC,OAAAD,EAAAA,kBAAAE,EAEjE,MAAO,KACN,IAAIE,EACAC,EAEJ,MAAO,CACNC,QAAUC,IACTH,EAAY,IAAII,EAAaA,cAACC,kBAAiB,CAC9CF,qCAAYA,GAAK,CAAER,aAAYI,mBAC/BO,OAAQH,EAAMG,SAEfL,EAAQM,EAAqBA,sBAACP,EAAUQ,QAASL,EAAMM,WAAW,EAEnEC,SAAWP,UACVH,EAAUW,YAAiBC,OAAAC,OAAAD,OAAAC,OAAA,CAAA,EAAAV,IAAOR,aAAYI,qBAC9B,QAAXe,EAAAX,EAAMY,aAAK,IAAAD,OAAA,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EAAAA,QAAQC,OAAO,CAAEC,KAAM,gBAAiBC,UAAU,CACxDC,eAAgB,CAAEC,MAAO,iCACzBC,WAAY8B,IAAA,IAAC5B,QAAEA,EAAOC,KAAEA,GAAM2B,EAAA,MAC7B,GAAG5B,EAAQE,WAAWC,OAAOF,EAAKG,MAAa,OAAG,EACnDC,WAAYwB,IAAA,IAAC7B,QAAEA,EAAOC,KAAEA,GAAM4B,EAAA,MAAK,CAClC,OACAtB,EAAeA,gBAACP,EAAQJ,gBACxB,GAAGI,EAAQE,WAAWC,OAAOF,EAAKG,MAAa,QAC/C,EACDF,WAAY,CACXC,KAAM,IACNvB,MAAOkD,IAAA,IAACrB,MAAEA,GAA0BqB,EAAA,OACnCH,EAASjB,QAAQC,QAAQoB,GACxBA,EAAElB,MAAMC,cAAcC,SAASN,EAAMK,gBACrC,EACFE,QAASgB,IAAkC,IAAjC7D,OAAEA,EAAM+C,MAAEA,EAAKlD,MAAEA,GAAYgE,EACtC7D,EACEgD,QACAC,QACAC,YAAYH,GACZI,cAAc,CACdC,KAAM,cACNnB,MAAO,CAAEoB,GAAIxD,EAAMwD,GAAIX,MAAO7C,EAAM6C,SAEpCY,MACFlE,SAAAA,EAAWS,EAAO,IAAI,EAEvB0D,OAAQpE,EAAYC,EAAU,IAAKC,EAAYI,KAGlD"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../node_modules/@tiptap/core/dist/index.js"),r=require("@tiptap/react"),t=require("@tiptap/suggestion"),n=require("../suggestionPopup.js"),o=require("./SlashCommandMenu.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=i(t);exports.buildSlashCommandExtension=function(t,i,d,a){return e.Extension.create({name:"slashCommand",addProseMirrorPlugins(){return[s.default({editor:this.editor,char:"/",items:e=>{let{query:r}=e;return t.filter((e=>e.label.toLowerCase().includes(r.toLowerCase()))).slice(0,20)},command:e=>{let{editor:r,range:t,props:n}=e;r.chain().focus().deleteRange(t).run(),null==i||i(n)},render:()=>{let e,t;return{onStart:i=>{e=new r.ReactRenderer(o.SlashCommandMenu,{props:Object.assign(Object.assign({},i),{renderItem:d,renderDropdown:a}),editor:i.editor}),t=n.createSuggestionPopup(e.element,i.clientRect)},onUpdate:r=>{var n;e.updateProps(Object.assign(Object.assign({},r),{renderItem:d,renderDropdown:a})),(null===(n=r.items)||void 0===n?void 0:n.length)?(t.show(),t.updatePosition(r.clientRect)):t.hide()},onKeyDown:r=>{var n,o;return"Escape"===r.event.key?(t.hide(),!0):null!==(o=null===(n=e.ref)||void 0===n?void 0:n.onKeyDown(r))&&void 0!==o&&o},onExit:()=>{t.destroy(),e.destroy()}}}})]}})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../node_modules/@tiptap/core/dist/index.js"),r=require("@tiptap/react"),t=require("@tiptap/suggestion"),n=require("../suggestionPopup.js"),o=require("./SlashCommandMenu.js");function i(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=i(t);exports.buildSlashCommandExtension=function(t,i,d,a){return e.Extension.create({name:"slashCommand",addProseMirrorPlugins(){return[s.default({editor:this.editor,char:"/",items:e=>{let{query:r}=e;return t.current.filter((e=>e.label.toLowerCase().includes(r.toLowerCase()))).slice(0,20)},command:e=>{let{editor:r,range:t,props:n}=e;r.chain().focus().deleteRange(t).run(),null==i||i(n)},render:()=>{let e,t;return{onStart:i=>{e=new r.ReactRenderer(o.SlashCommandMenu,{props:Object.assign(Object.assign({},i),{renderItem:d,renderDropdown:a}),editor:i.editor}),t=n.createSuggestionPopup(e.element,i.clientRect)},onUpdate:r=>{var n;e.updateProps(Object.assign(Object.assign({},r),{renderItem:d,renderDropdown:a})),(null===(n=r.items)||void 0===n?void 0:n.length)?(t.show(),t.updatePosition(r.clientRect)):t.hide()},onKeyDown:r=>{var n,o;return"Escape"===r.event.key?(t.hide(),!0):null!==(o=null===(n=e.ref)||void 0===n?void 0:n.onKeyDown(r))&&void 0!==o&&o},onExit:()=>{t.destroy(),e.destroy()}}}})]}})};
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\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: 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":["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","createSuggestionPopup","element","clientRect","onUpdate","updateProps","Object","assign","_a","length","show","updatePosition","hide","onKeyDown","event","key","_b","ref","onExit","destroy"],"mappings":"6XAcM,SACLA,EACAC,EACAC,EACAC,GAEA,OAAOC,EAAAA,UAAUC,OAAO,CACvBC,KAAM,eACNC,wBACC,MAAO,CACNC,EAAAA,QAAW,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,EAAaA,cAACC,mBAAkB,CAC/CV,qCAAYA,GAAK,CAAEtB,aAAYC,mBAC/BM,OAAQe,EAAMf,SAEfsB,EAAQI,EAAqBA,sBAC5BL,EAAUM,QACVZ,EAAMa,WACN,EAEFC,SAAWd,UACVM,EAAUS,YAAiBC,OAAAC,OAAAD,OAAAC,OAAA,CAAA,EAAAjB,IAAOtB,aAAYC,qBAC9B,QAAXuC,EAAAlB,EAAMZ,aAAK,IAAA8B,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 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":["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":"6XAcM,SACLA,EACAC,EACAC,EACAC,GAEA,OAAOC,EAAAA,UAAUC,OAAO,CACvBC,KAAM,eACNC,wBACC,MAAO,CACNC,EAAAA,QAAW,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,EAAaA,cAACC,mBAAkB,CAC/CV,qCAAYA,GAAK,CAAEvB,aAAYC,mBAC/BM,OAAQgB,EAAMhB,SAEfuB,EAAQI,EAAqBA,sBAC5BL,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"}
@@ -6,10 +6,16 @@ interface ExtensionConfig {
6
6
  maxCharacters?: number;
7
7
  hasSections?: boolean;
8
8
  mentions?: {
9
- agents?: MentionItem[];
10
- teams?: MentionItem[];
9
+ agents?: {
10
+ current: MentionItem[];
11
+ };
12
+ teams?: {
13
+ current: MentionItem[];
14
+ };
15
+ };
16
+ slashCommands?: {
17
+ current: SlashCommandItem[];
11
18
  };
12
- slashCommands?: SlashCommandItem[];
13
19
  onPaste?: (data: PasteData) => boolean | void;
14
20
  onSend?: (content: EditorSnapshot) => void;
15
21
  sendShortcut?: {
@@ -1,4 +1,8 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import type { MentionDropdownRenderProps, MentionItem } from '../../BikEditor.types';
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>;
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>;
@@ -1,4 +1,6 @@
1
1
  import { Extension } from '@tiptap/core';
2
2
  import type { ReactNode } from 'react';
3
3
  import type { SlashCommandDropdownRenderProps, SlashCommandItem } from '../../BikEditor.types';
4
- export declare function buildSlashCommandExtension(commands: SlashCommandItem[], onSelect?: (command: SlashCommandItem) => void, renderItem?: (item: SlashCommandItem, isActive: boolean) => ReactNode, renderDropdown?: (props: SlashCommandDropdownRenderProps) => ReactNode): Extension<any, any>;
4
+ export declare function buildSlashCommandExtension(commandsRef: {
5
+ current: SlashCommandItem[];
6
+ }, onSelect?: (command: SlashCommandItem) => void, renderItem?: (item: SlashCommandItem, isActive: boolean) => ReactNode, renderDropdown?: (props: SlashCommandDropdownRenderProps) => ReactNode): Extension<any, any>;
@@ -1,2 +1,2 @@
1
- import{jsxs as t,jsx as n}from"react/jsx-runtime";import{getMarkRange as e}from"../node_modules/@tiptap/core/dist/index.js";import{useEditor as o,EditorContent as r}from"@tiptap/react";import{forwardRef as i,useRef as s,useEffect as l,useImperativeHandle as c}from"react";import{BikEditorShell as a}from"./BikEditor.styles.js";import{DEFAULT_FORMAT_STATE as u}from"./BikEditor.types.js";import{buildSectionedContent as d,normalizeHtml as m,extractContent as g,extractActiveFormats as h,extractSectionContent as v,extractBodyContent as f,insertInlineHtml as p,setSectionContentInEditor as C,findSectionEndPos as S,findSectionStartPos as k}from"./BikEditor.utils.js";import{buildExtensions as y}from"./extensions/buildExtensions.js";import{LinkBubbleMenu as x}from"./floating/LinkBubbleMenu.js";function B(t){return Object.entries(t).map((t=>{let[n,e]=t;return`${n.replace(/([A-Z])/g,(t=>`-${t.toLowerCase()}`))}:${e}`})).join(";")}const b=i(((i,b)=>{var A;const{initialContent:I,sections:j,features:L,disabled:E,maxCharacters:O,shortcuts:T,sendShortcut:w,mentions:F,slashCommands:H,link:M,onPaste:z,onReady:R,onChange:D,onSend:N,onFocus:U,onBlur:P,onSelectionChange:$,minHeight:q,maxHeight:J,style:V,className:W,editorClassName:Z,editorStyle:_}=i,G=(null==j?void 0:j.length)?d(m(null!=I?I:""),j.map((t=>Object.assign(Object.assign({},t),{content:m(t.content)})))):m(null!=I?I:""),K=s([]),Q=s(!1),X=s(R);X.current=R;const Y=s(D);Y.current=D;const tt=s($);tt.current=$;const nt=s(U);nt.current=U;const et=s(P);et.current=P;const ot=s(N);ot.current=N;const rt=o({extensions:y({features:L,placeholder:i.placeholder,maxCharacters:O,hasSections:(null!==(A=null==j?void 0:j.length)&&void 0!==A?A:0)>0,mentions:{agents:null==F?void 0:F.agents,teams:null==F?void 0:F.teams},slashCommands:null==H?void 0:H.items,onPaste:z,onSend:N?t=>{var n;return null===(n=ot.current)||void 0===n?void 0:n.call(ot,t)}:void 0,sendShortcut:w,shortcuts:T,onMentionSelected:null==F?void 0:F.onSelect,onSlashCommandSelected:null==H?void 0:H.onSelect,renderMentionItem:null==F?void 0:F.renderItem,renderMentionDropdown:null==F?void 0:F.renderDropdown,renderSlashCommandItem:null==H?void 0:H.renderItem,renderSlashCommandDropdown:null==H?void 0:H.renderDropdown}),content:G,editable:!E,immediatelyRender:!1,editorProps:{attributes:Object.assign(Object.assign({},Z?{class:Z}:{}),_?{style:B(_)}:{})},onUpdate:t=>{let{editor:n}=t;var e;null===(e=Y.current)||void 0===e||e.call(Y,g(n))},onTransaction:t=>{let{editor:n}=t;var e;null===(e=tt.current)||void 0===e||e.call(tt,h(n))},onFocus:()=>{var t;return null===(t=nt.current)||void 0===t?void 0:t.call(nt)},onBlur:()=>{var t;return null===(t=et.current)||void 0===t?void 0:t.call(et)}});function it(t){rt?t(rt):K.current.push(t)}return l((()=>{var t;if(rt){if(K.current.length>0){K.current.splice(0).forEach((t=>t(rt)))}Q.current||(Q.current=!0,null===(t=X.current)||void 0===t||t.call(X))}}),[rt]),c(b,(()=>({focus:t=>it((n=>n.commands.focus(t))),blur:()=>it((t=>t.commands.blur())),clearContent:()=>it((t=>t.commands.clearContent(!0))),setContent:t=>{const n=m(t);it((t=>t.commands.setContent(n,{emitUpdate:!0})))},insertContent:t=>{const n=m(t);it((t=>t.commands.insertContent(n)))},insertInlineContent:t=>{it((n=>p(n,t)))},insertAtStart:t=>{const n=m(t);it((t=>t.commands.insertContentAt(1,n)))},insertBlock:t=>{const n=m(t);it((t=>t.commands.insertContentAt(t.state.doc.content.size,n)))},appendInline:t=>{const n=m(t);it((t=>t.commands.insertContentAt(t.state.doc.content.size-1,n)))},insertAtEnd(t){this.insertBlock(t)},appendContent(t){this.appendInline(t)},getContent:()=>rt?g(rt):{html:"",text:"",isEmpty:!0,characterCount:0},getJSON:()=>{var t;return null!==(t=null==rt?void 0:rt.getJSON())&&void 0!==t?t:null},getMentions:()=>{const t=new Set,n=new Set;return rt?(rt.state.doc.descendants((e=>{"mentionAgent"===e.type.name&&null!=e.attrs.id?t.add(String(e.attrs.id)):"mentionTeam"===e.type.name&&null!=e.attrs.id&&n.add(String(e.attrs.id))})),{agentIds:Array.from(t),teamIds:Array.from(n)}):{agentIds:[],teamIds:[]}},getCursorPosition:()=>{if(!rt)return{from:0,to:0};const{from:t,to:n}=rt.state.selection;return{from:t,to:n}},insertAtPosition:(t,n)=>{const e=m(n);it((n=>n.commands.insertContentAt(t,e)))},getSelectedText:()=>{if(!rt)return"";const{state:t}=rt,{from:n,to:o,empty:r}=t.selection;if(!r)return t.doc.textBetween(n,o," ");const i=t.schema.marks.link;if(i){const o=e(t.doc.resolve(n),i);if(o)return t.doc.textBetween(o.from,o.to," ")}return""},getCharacterCount:()=>{var t,n,e,o;return{count:null!==(o=null!==(e=null===(n=null===(t=null==rt?void 0:rt.storage.characterCount)||void 0===t?void 0:t.characters)||void 0===n?void 0:n.call(t))&&void 0!==e?e:null==rt?void 0:rt.getText().length)&&void 0!==o?o:0,limit:null!=O?O:null}},getSectionContent:t=>rt?v(rt,t):{html:"",text:"",isEmpty:!0,characterCount:0},setSectionContent:(t,n)=>{const e=m(n);it((n=>C(n,t,e)))},focusSection:t=>{it((n=>{if("body"===t){let t=n.state.doc.content.size-1;return n.state.doc.descendants(((e,o)=>("sectionDivider"===e.type.name&&t===n.state.doc.content.size-1&&(t=o-1),t===n.state.doc.content.size-1))),t<1&&(t=1),void n.chain().focus().setTextSelection(t).run()}let e=-1;n.state.doc.descendants(((n,o)=>{if(-1!==e)return!1;"sectionDivider"===n.type.name&&n.attrs.sectionId===t&&(e=o+n.nodeSize+1)})),-1!==e&&n.chain().focus().setTextSelection(e).run()}))},clearSection:t=>{it((n=>C(n,t,"<p></p>")))},getBodyContent:()=>rt?f(rt):{html:"",text:"",isEmpty:!0,characterCount:0},setBodyContent:t=>{const n=m(t);it((t=>C(t,"body",n)))},setBodyAndSections:(t,n)=>{const e=d(m(t),n.map((t=>({id:t.id,content:m(t.content)}))));it((t=>t.commands.setContent(e,{emitUpdate:!0})))},appendBodyContent:t=>{const n=m(t);it((t=>{const e=S(t,"body");t.commands.insertContentAt(e-1,n)}))},insertAtSectionStart:(t,n)=>{const e=m(n);it((n=>{const o=k(n,t);-1!==o&&n.commands.insertContentAt(o,e)}))},insertAtSectionEnd:(t,n)=>{const e=m(n);it((n=>{const o=S(n,t);n.commands.insertContentAt(o,e)}))},getActiveFormats:()=>rt?h(rt):u,actions:{toggleBold:()=>null==rt?void 0:rt.chain().focus().toggleBold().run(),toggleItalic:()=>null==rt?void 0:rt.chain().focus().toggleItalic().run(),toggleUnderline:()=>null==rt?void 0:rt.chain().focus().toggleUnderline().run(),toggleStrike:()=>null==rt?void 0:rt.chain().focus().toggleStrike().run(),toggleBulletList:()=>null==rt?void 0:rt.chain().focus().toggleBulletList().run(),toggleOrderedList:()=>null==rt?void 0:rt.chain().focus().toggleOrderedList().run(),toggleBlockquote:()=>null==rt?void 0:rt.chain().focus().toggleBlockquote().run(),toggleCodeBlock:()=>null==rt?void 0:rt.chain().focus().toggleCodeBlock().run(),setTextAlign:t=>null==rt?void 0:rt.chain().focus().setTextAlign(t).run(),setFontFamily:t=>null==rt?void 0:rt.chain().focus().setFontFamily(t).run(),setFontSize:t=>null==rt?void 0:rt.chain().focus().setFontSize(t).run(),setColor:t=>null==rt?void 0:rt.chain().focus().setColor(t).run(),setHighlight:t=>null==rt?void 0:rt.chain().focus().toggleHighlight({color:t}).run(),unsetColor:()=>null==rt?void 0:rt.chain().focus().unsetColor().run(),unsetHighlight:()=>null==rt?void 0:rt.chain().focus().unsetHighlight().run(),setLink:(t,n)=>{rt&&(void 0!==n?rt.chain().focus().extendMarkRange("link").command((e=>{let{tr:o,state:r}=e;const{from:i,to:s}=o.selection,l=r.schema.marks.link;if(!l)return!1;const c=r.schema.text(n,[l.create({href:t})]),a=r.schema.text(" ");return o.replaceWith(i,s,[c,a]),!0})).run():rt.chain().focus().extendMarkRange("link").setLink({href:t}).insertContent(" ").run())},updateLink:t=>null==rt?void 0:rt.chain().focus().extendMarkRange("link").setLink({href:t}).run(),removeLink:()=>null==rt?void 0:rt.chain().focus().extendMarkRange("link").unsetLink().run(),insertEmoji:t=>null==rt?void 0:rt.chain().focus().insertContent(t).run(),insertVariable:t=>null==rt?void 0:rt.chain().focus().insertContent(`{{${t}}}`).run(),insertHtml:t=>null==rt?void 0:rt.commands.insertContent(m(t)),undo:()=>null==rt?void 0:rt.chain().focus().undo().run(),redo:()=>null==rt?void 0:rt.chain().focus().redo().run(),canUndo:()=>{var t;return null!==(t=null==rt?void 0:rt.can().undo())&&void 0!==t&&t},canRedo:()=>{var t;return null!==(t=null==rt?void 0:rt.can().redo())&&void 0!==t&&t},toggleSuperscript:()=>null==rt?void 0:rt.chain().focus().toggleSuperscript().run(),toggleSubscript:()=>null==rt?void 0:rt.chain().focus().toggleSubscript().run(),insertImage:t=>null==rt?void 0:rt.chain().focus().setImage({src:t}).run()}})),[rt]),rt?t(a,Object.assign({minHeight:q,maxHeight:J,style:V,className:W},{children:[n(r,{editor:rt}),n(x,{editor:rt,renderLinkTooltip:null==M?void 0:M.renderTooltip})]})):null}));b.displayName="BikEditor";export{b as BikEditor};
1
+ import{jsxs as t,jsx as n}from"react/jsx-runtime";import{getMarkRange as e}from"../node_modules/@tiptap/core/dist/index.js";import{useEditor as o,EditorContent as i}from"@tiptap/react";import{forwardRef as r,useRef as l,useEffect as s,useImperativeHandle as c}from"react";import{BikEditorShell as u}from"./BikEditor.styles.js";import{DEFAULT_FORMAT_STATE as d}from"./BikEditor.types.js";import{buildSectionedContent as a,normalizeHtml as m,extractContent as g,extractActiveFormats as v,extractSectionContent as h,extractBodyContent as f,insertInlineHtml as p,setSectionContentInEditor as C,findSectionEndPos as S,findSectionStartPos as k}from"./BikEditor.utils.js";import{buildExtensions as y}from"./extensions/buildExtensions.js";import{LinkBubbleMenu as x}from"./floating/LinkBubbleMenu.js";function B(t){return Object.entries(t).map((t=>{let[n,e]=t;return`${n.replace(/([A-Z])/g,(t=>`-${t.toLowerCase()}`))}:${e}`})).join(";")}const b=r(((r,b)=>{var A,I,j,L,E,O,T;const{initialContent:w,sections:F,features:H,disabled:M,maxCharacters:z,shortcuts:R,sendShortcut:D,mentions:N,slashCommands:U,link:P,onPaste:$,onReady:q,onChange:J,onSend:V,onFocus:W,onBlur:Z,onSelectionChange:_,minHeight:G,maxHeight:K,style:Q,className:X,editorClassName:Y,editorStyle:tt}=r,nt=(null==F?void 0:F.length)?a(m(null!=w?w:""),F.map((t=>Object.assign(Object.assign({},t),{content:m(t.content)})))):m(null!=w?w:""),et=l([]),ot=l(!1),it=l(q);it.current=q;const rt=l(J);rt.current=J;const lt=l(_);lt.current=_;const st=l(W);st.current=W;const ct=l(Z);ct.current=Z;const ut=l(V);ut.current=V;const dt=l(null!==(A=null==N?void 0:N.agents)&&void 0!==A?A:[]);dt.current=null!==(I=null==N?void 0:N.agents)&&void 0!==I?I:[];const at=l(null!==(j=null==N?void 0:N.teams)&&void 0!==j?j:[]);at.current=null!==(L=null==N?void 0:N.teams)&&void 0!==L?L:[];const mt=l(null!==(E=null==U?void 0:U.items)&&void 0!==E?E:[]);mt.current=null!==(O=null==U?void 0:U.items)&&void 0!==O?O:[];const gt=o({extensions:y({features:H,placeholder:r.placeholder,maxCharacters:z,hasSections:(null!==(T=null==F?void 0:F.length)&&void 0!==T?T:0)>0,mentions:{agents:(null==N?void 0:N.agents)?dt:void 0,teams:(null==N?void 0:N.teams)?at:void 0},slashCommands:(null==U?void 0:U.items)?mt:void 0,onPaste:$,onSend:V?t=>{var n;return null===(n=ut.current)||void 0===n?void 0:n.call(ut,t)}:void 0,sendShortcut:D,shortcuts:R,onMentionSelected:null==N?void 0:N.onSelect,onSlashCommandSelected:null==U?void 0:U.onSelect,renderMentionItem:null==N?void 0:N.renderItem,renderMentionDropdown:null==N?void 0:N.renderDropdown,renderSlashCommandItem:null==U?void 0:U.renderItem,renderSlashCommandDropdown:null==U?void 0:U.renderDropdown}),content:nt,editable:!M,immediatelyRender:!1,editorProps:{attributes:Object.assign(Object.assign({},Y?{class:Y}:{}),tt?{style:B(tt)}:{})},onUpdate:t=>{let{editor:n}=t;var e;null===(e=rt.current)||void 0===e||e.call(rt,g(n))},onTransaction:t=>{let{editor:n}=t;var e;null===(e=lt.current)||void 0===e||e.call(lt,v(n))},onFocus:()=>{var t;return null===(t=st.current)||void 0===t?void 0:t.call(st)},onBlur:()=>{var t;return null===(t=ct.current)||void 0===t?void 0:t.call(ct)}});function vt(t){gt?t(gt):et.current.push(t)}return s((()=>{var t;if(gt){if(et.current.length>0){et.current.splice(0).forEach((t=>t(gt)))}ot.current||(ot.current=!0,null===(t=it.current)||void 0===t||t.call(it))}}),[gt]),c(b,(()=>({focus:t=>vt((n=>n.commands.focus(t))),blur:()=>vt((t=>t.commands.blur())),clearContent:()=>vt((t=>t.commands.clearContent(!0))),setContent:t=>{const n=m(t);vt((t=>t.commands.setContent(n,{emitUpdate:!0})))},insertContent:t=>{const n=m(t);vt((t=>t.commands.insertContent(n)))},insertInlineContent:t=>{vt((n=>p(n,t)))},insertAtStart:t=>{const n=m(t);vt((t=>t.commands.insertContentAt(1,n)))},insertBlock:t=>{const n=m(t);vt((t=>t.commands.insertContentAt(t.state.doc.content.size,n)))},appendInline:t=>{const n=m(t);vt((t=>t.commands.insertContentAt(t.state.doc.content.size-1,n)))},insertAtEnd(t){this.insertBlock(t)},appendContent(t){this.appendInline(t)},getContent:()=>gt?g(gt):{html:"",text:"",isEmpty:!0,characterCount:0},getJSON:()=>{var t;return null!==(t=null==gt?void 0:gt.getJSON())&&void 0!==t?t:null},getMentions:()=>{const t=new Set,n=new Set;return gt?(gt.state.doc.descendants((e=>{"mentionAgent"===e.type.name&&null!=e.attrs.id?t.add(String(e.attrs.id)):"mentionTeam"===e.type.name&&null!=e.attrs.id&&n.add(String(e.attrs.id))})),{agentIds:Array.from(t),teamIds:Array.from(n)}):{agentIds:[],teamIds:[]}},getCursorPosition:()=>{if(!gt)return{from:0,to:0};const{from:t,to:n}=gt.state.selection;return{from:t,to:n}},insertAtPosition:(t,n)=>{const e=m(n);vt((n=>n.commands.insertContentAt(t,e)))},getSelectedText:()=>{if(!gt)return"";const{state:t}=gt,{from:n,to:o,empty:i}=t.selection;if(!i)return t.doc.textBetween(n,o," ");const r=t.schema.marks.link;if(r){const o=e(t.doc.resolve(n),r);if(o)return t.doc.textBetween(o.from,o.to," ")}return""},getCharacterCount:()=>{var t,n,e,o;return{count:null!==(o=null!==(e=null===(n=null===(t=null==gt?void 0:gt.storage.characterCount)||void 0===t?void 0:t.characters)||void 0===n?void 0:n.call(t))&&void 0!==e?e:null==gt?void 0:gt.getText().length)&&void 0!==o?o:0,limit:null!=z?z:null}},getSectionContent:t=>gt?h(gt,t):{html:"",text:"",isEmpty:!0,characterCount:0},setSectionContent:(t,n)=>{const e=m(n);vt((n=>C(n,t,e)))},focusSection:t=>{vt((n=>{if("body"===t){let t=n.state.doc.content.size-1;return n.state.doc.descendants(((e,o)=>("sectionDivider"===e.type.name&&t===n.state.doc.content.size-1&&(t=o-1),t===n.state.doc.content.size-1))),t<1&&(t=1),void n.chain().focus().setTextSelection(t).run()}let e=-1;n.state.doc.descendants(((n,o)=>{if(-1!==e)return!1;"sectionDivider"===n.type.name&&n.attrs.sectionId===t&&(e=o+n.nodeSize+1)})),-1!==e&&n.chain().focus().setTextSelection(e).run()}))},clearSection:t=>{vt((n=>C(n,t,"<p></p>")))},getBodyContent:()=>gt?f(gt):{html:"",text:"",isEmpty:!0,characterCount:0},setBodyContent:t=>{const n=m(t);vt((t=>C(t,"body",n)))},setBodyAndSections:(t,n)=>{const e=a(m(t),n.map((t=>({id:t.id,content:m(t.content)}))));vt((t=>t.commands.setContent(e,{emitUpdate:!0})))},appendBodyContent:t=>{const n=m(t);vt((t=>{const e=S(t,"body");t.commands.insertContentAt(e-1,n)}))},insertAtSectionStart:(t,n)=>{const e=m(n);vt((n=>{const o=k(n,t);-1!==o&&n.commands.insertContentAt(o,e)}))},insertAtSectionEnd:(t,n)=>{const e=m(n);vt((n=>{const o=S(n,t);n.commands.insertContentAt(o,e)}))},getActiveFormats:()=>gt?v(gt):d,actions:{toggleBold:()=>null==gt?void 0:gt.chain().focus().toggleBold().run(),toggleItalic:()=>null==gt?void 0:gt.chain().focus().toggleItalic().run(),toggleUnderline:()=>null==gt?void 0:gt.chain().focus().toggleUnderline().run(),toggleStrike:()=>null==gt?void 0:gt.chain().focus().toggleStrike().run(),toggleBulletList:()=>null==gt?void 0:gt.chain().focus().toggleBulletList().run(),toggleOrderedList:()=>null==gt?void 0:gt.chain().focus().toggleOrderedList().run(),toggleBlockquote:()=>null==gt?void 0:gt.chain().focus().toggleBlockquote().run(),toggleCodeBlock:()=>null==gt?void 0:gt.chain().focus().toggleCodeBlock().run(),setTextAlign:t=>null==gt?void 0:gt.chain().focus().setTextAlign(t).run(),setFontFamily:t=>null==gt?void 0:gt.chain().focus().setFontFamily(t).run(),setFontSize:t=>null==gt?void 0:gt.chain().focus().setFontSize(t).run(),setColor:t=>null==gt?void 0:gt.chain().focus().setColor(t).run(),setHighlight:t=>null==gt?void 0:gt.chain().focus().toggleHighlight({color:t}).run(),unsetColor:()=>null==gt?void 0:gt.chain().focus().unsetColor().run(),unsetHighlight:()=>null==gt?void 0:gt.chain().focus().unsetHighlight().run(),setLink:(t,n)=>{gt&&(void 0!==n?gt.chain().focus().extendMarkRange("link").command((e=>{let{tr:o,state:i}=e;const{from:r,to:l}=o.selection,s=i.schema.marks.link;if(!s)return!1;const c=i.schema.text(n,[s.create({href:t})]),u=i.schema.text(" ");return o.replaceWith(r,l,[c,u]),!0})).run():gt.chain().focus().extendMarkRange("link").setLink({href:t}).insertContent(" ").run())},updateLink:t=>null==gt?void 0:gt.chain().focus().extendMarkRange("link").setLink({href:t}).run(),removeLink:()=>null==gt?void 0:gt.chain().focus().extendMarkRange("link").unsetLink().run(),insertEmoji:t=>null==gt?void 0:gt.chain().focus().insertContent(t).run(),insertVariable:t=>null==gt?void 0:gt.chain().focus().insertContent(`{{${t}}}`).run(),insertHtml:t=>null==gt?void 0:gt.commands.insertContent(m(t)),undo:()=>null==gt?void 0:gt.chain().focus().undo().run(),redo:()=>null==gt?void 0:gt.chain().focus().redo().run(),canUndo:()=>{var t;return null!==(t=null==gt?void 0:gt.can().undo())&&void 0!==t&&t},canRedo:()=>{var t;return null!==(t=null==gt?void 0:gt.can().redo())&&void 0!==t&&t},toggleSuperscript:()=>null==gt?void 0:gt.chain().focus().toggleSuperscript().run(),toggleSubscript:()=>null==gt?void 0:gt.chain().focus().toggleSubscript().run(),insertImage:t=>null==gt?void 0:gt.chain().focus().setImage({src:t}).run()}})),[gt]),gt?t(u,Object.assign({minHeight:G,maxHeight:K,style:Q,className:X},{children:[n(i,{editor:gt}),n(x,{editor:gt,renderLinkTooltip:null==P?void 0:P.renderTooltip})]})):null}));b.displayName="BikEditor";export{b as BikEditor};
2
2
  //# sourceMappingURL=BikEditor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BikEditor.js","sources":["../../../src/editor/BikEditor.tsx"],"sourcesContent":["'use client';\n\n/**\n * IMPLEMENTATION LAYER — TipTap-specific.\n * If the underlying editor is swapped, this file changes; BikEditor.types.ts and\n * src/editor/index.ts (the consumer contract) do NOT change.\n */\nimport { Editor, getMarkRange } from '@tiptap/core';\nimport { EditorContent, useEditor } from '@tiptap/react';\nimport React, {\n\tforwardRef,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseRef,\n} from 'react';\nimport { BikEditorShell } from './BikEditor.styles';\nimport {\n\tBikEditorProps,\n\tBikEditorRef,\n\tDEFAULT_FORMAT_STATE,\n} from './BikEditor.types';\nimport {\n\tbuildSectionedContent,\n\textractActiveFormats,\n\textractBodyContent,\n\textractContent,\n\textractSectionContent,\n\tfindSectionEndPos,\n\tfindSectionStartPos,\n\tinsertInlineHtml,\n\tnormalizeHtml,\n\tsetSectionContentInEditor,\n} from './BikEditor.utils';\nimport { buildExtensions } from './extensions/buildExtensions';\nimport { LinkBubbleMenu } from './floating/LinkBubbleMenu';\n\n/** Convert React.CSSProperties to an inline CSS string for editorProps.attributes. */\nfunction cssToString(style: React.CSSProperties): string {\n\treturn Object.entries(style)\n\t\t.map(\n\t\t\t([k, v]) => `${k.replace(/([A-Z])/g, (c) => `-${c.toLowerCase()}`)}:${v}`,\n\t\t)\n\t\t.join(';');\n}\n\nconst BikEditorInner = (\n\tprops: BikEditorProps,\n\tref: React.Ref<BikEditorRef>,\n) => {\n\tconst {\n\t\tinitialContent,\n\t\tsections,\n\t\tfeatures,\n\t\tdisabled,\n\t\tmaxCharacters,\n\t\tshortcuts,\n\t\tsendShortcut,\n\t\tmentions,\n\t\tslashCommands,\n\t\tlink,\n\t\tonPaste,\n\t\tonReady,\n\t\tonChange,\n\t\tonSend,\n\t\tonFocus,\n\t\tonBlur,\n\t\tonSelectionChange,\n\t\tminHeight,\n\t\tmaxHeight,\n\t\tstyle,\n\t\tclassName,\n\t\teditorClassName,\n\t\teditorStyle,\n\t} = props;\n\n\tconst initialEditorContent = sections?.length\n\t\t? buildSectionedContent(\n\t\t\t\tnormalizeHtml(initialContent ?? ''),\n\t\t\t\tsections.map((s) => ({ ...s, content: normalizeHtml(s.content) })),\n\t\t )\n\t\t: normalizeHtml(initialContent ?? '');\n\n\t// ── Command queue ─────────────────────────────────────────────────────────\n\t// TipTap's useEditor initializes asynchronously; the editor instance is null\n\t// until the first commit. Any imperative method called before the editor is\n\t// ready is enqueued here and flushed automatically once it becomes non-null.\n\t// Consumers never need setTimeout or readiness guards.\n\tconst pendingQueue = useRef<Array<(e: Editor) => void>>([]);\n\tconst hasCalledOnReady = useRef(false);\n\t// Keep stable refs to all callbacks so useEditor receives the same function\n\t// identity on every render — prevents TipTap from re-registering event\n\t// handlers every time the parent re-renders with new inline function props.\n\tconst onReadyRef = useRef(onReady);\n\tonReadyRef.current = onReady;\n\tconst onChangeRef = useRef(onChange);\n\tonChangeRef.current = onChange;\n\tconst onSelectionChangeRef = useRef(onSelectionChange);\n\tonSelectionChangeRef.current = onSelectionChange;\n\tconst onFocusRef = useRef(onFocus);\n\tonFocusRef.current = onFocus;\n\tconst onBlurRef = useRef(onBlur);\n\tonBlurRef.current = onBlur;\n\tconst onSendRef = useRef(onSend);\n\tonSendRef.current = onSend;\n\n\tconst editor = useEditor({\n\t\textensions: buildExtensions({\n\t\t\tfeatures,\n\t\t\tplaceholder: props.placeholder,\n\t\t\tmaxCharacters,\n\t\t\thasSections: (sections?.length ?? 0) > 0,\n\t\t\tmentions: {\n\t\t\t\tagents: mentions?.agents,\n\t\t\t\tteams: mentions?.teams,\n\t\t\t},\n\t\t\tslashCommands: slashCommands?.items,\n\t\t\tonPaste,\n\t\t\tonSend: onSend ? (snapshot) => onSendRef.current?.(snapshot) : undefined,\n\t\t\tsendShortcut,\n\t\t\tshortcuts,\n\t\t\tonMentionSelected: mentions?.onSelect,\n\t\t\tonSlashCommandSelected: slashCommands?.onSelect,\n\t\t\trenderMentionItem: mentions?.renderItem,\n\t\t\trenderMentionDropdown: mentions?.renderDropdown,\n\t\t\trenderSlashCommandItem: slashCommands?.renderItem,\n\t\t\trenderSlashCommandDropdown: slashCommands?.renderDropdown,\n\t\t}),\n\t\tcontent: initialEditorContent,\n\t\teditable: !disabled,\n\t\timmediatelyRender: false, // SSR-safe — NEVER remove this\n\t\teditorProps: {\n\t\t\tattributes: {\n\t\t\t\t...(editorClassName ? { class: editorClassName } : {}),\n\t\t\t\t...(editorStyle ? { style: cssToString(editorStyle) } : {}),\n\t\t\t},\n\t\t},\n\t\tonUpdate: ({ editor: e }) => {\n\t\t\tonChangeRef.current?.(extractContent(e));\n\t\t},\n\t\tonTransaction: ({ editor: e }) => {\n\t\t\tonSelectionChangeRef.current?.(extractActiveFormats(e));\n\t\t},\n\t\tonFocus: () => onFocusRef.current?.(),\n\t\tonBlur: () => onBlurRef.current?.(),\n\t});\n\n\t// ── enqueue ───────────────────────────────────────────────────────────────\n\t// Run immediately if the editor is ready; otherwise defer to the queue.\n\t// Closures passed to enqueue MUST capture all parameters explicitly —\n\t// they must NOT close over `editor` (which would be null at enqueue time).\n\tfunction enqueue(op: (e: Editor) => void): void {\n\t\tif (editor) {\n\t\t\top(editor);\n\t\t} else {\n\t\t\tpendingQueue.current.push(op);\n\t\t}\n\t}\n\n\t// Flush the pending queue and fire onReady when editor transitions null → ready.\n\tuseEffect(() => {\n\t\tif (!editor) return;\n\t\tif (pendingQueue.current.length > 0) {\n\t\t\tconst queue = pendingQueue.current.splice(0);\n\t\t\tqueue.forEach((op) => op(editor));\n\t\t}\n\t\tif (!hasCalledOnReady.current) {\n\t\t\thasCalledOnReady.current = true;\n\t\t\tonReadyRef.current?.();\n\t\t}\n\t}, [editor]);\n\n\tuseImperativeHandle(\n\t\tref,\n\t\t() => ({\n\t\t\t// ── Focus ────────────────────────────────────────────────────────\n\t\t\tfocus: (position) => enqueue((e) => e.commands.focus(position)),\n\t\t\tblur: () => enqueue((e) => e.commands.blur()),\n\n\t\t\t// ── Content ──────────────────────────────────────────────────────\n\t\t\tclearContent: () => enqueue((e) => e.commands.clearContent(true)),\n\t\t\tsetContent: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => e.commands.setContent(normalised, { emitUpdate: true }));\n\t\t\t},\n\t\t\tinsertContent: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => e.commands.insertContent(normalised));\n\t\t\t},\n\t\t\tinsertInlineContent: (html) => {\n\t\t\t\tenqueue((e) => insertInlineHtml(e, html));\n\t\t\t},\n\t\t\tinsertAtStart: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => e.commands.insertContentAt(1, normalised));\n\t\t\t},\n\t\t\tinsertBlock: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) =>\n\t\t\t\t\te.commands.insertContentAt(e.state.doc.content.size, normalised),\n\t\t\t\t);\n\t\t\t},\n\t\t\tappendInline: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\t// doc.content.size is after the last </p> (block boundary).\n\t\t\t\t// Subtract 1 to land inside the last paragraph so text appends\n\t\t\t\t// inline rather than being wrapped in a new paragraph each call.\n\t\t\t\tenqueue((e) =>\n\t\t\t\t\te.commands.insertContentAt(e.state.doc.content.size - 1, normalised),\n\t\t\t\t);\n\t\t\t},\n\t\t\t// Backwards-compatible aliases\n\t\t\tinsertAtEnd(html) {\n\t\t\t\tthis.insertBlock(html);\n\t\t\t},\n\t\t\tappendContent(html) {\n\t\t\t\tthis.appendInline(html);\n\t\t\t},\n\t\t\tgetContent: () =>\n\t\t\t\teditor\n\t\t\t\t\t? extractContent(editor)\n\t\t\t\t\t: { html: '', text: '', isEmpty: true, characterCount: 0 },\n\t\t\tgetJSON: () => editor?.getJSON() ?? null,\n\t\t\tgetMentions: () => {\n\t\t\t\tconst agentIds = new Set<string>();\n\t\t\t\tconst teamIds = new Set<string>();\n\t\t\t\tif (!editor) return { agentIds: [], teamIds: [] };\n\t\t\t\teditor.state.doc.descendants((node) => {\n\t\t\t\t\tif (node.type.name === 'mentionAgent' && node.attrs['id'] != null) {\n\t\t\t\t\t\tagentIds.add(String(node.attrs['id']));\n\t\t\t\t\t} else if (\n\t\t\t\t\t\tnode.type.name === 'mentionTeam' &&\n\t\t\t\t\t\tnode.attrs['id'] != null\n\t\t\t\t\t) {\n\t\t\t\t\t\tteamIds.add(String(node.attrs['id']));\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\treturn { agentIds: Array.from(agentIds), teamIds: Array.from(teamIds) };\n\t\t\t},\n\n\t\t\t// ── Selection ────────────────────────────────────────────────────\n\t\t\tgetCursorPosition: () => {\n\t\t\t\tif (!editor) return { from: 0, to: 0 };\n\t\t\t\tconst { from, to } = editor.state.selection;\n\t\t\t\treturn { from, to };\n\t\t\t},\n\t\t\tinsertAtPosition: (pos, html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => e.commands.insertContentAt(pos, normalised));\n\t\t\t},\n\t\t\tgetSelectedText: () => {\n\t\t\t\tif (!editor) return '';\n\t\t\t\tconst { state } = editor;\n\t\t\t\tconst { from, to, empty } = state.selection;\n\t\t\t\tif (!empty) {\n\t\t\t\t\treturn state.doc.textBetween(from, to, ' ');\n\t\t\t\t}\n\t\t\t\t// When the cursor is inside a link with nothing selected, return the\n\t\t\t\t// full link text — useful for pre-filling a link modal's text field.\n\t\t\t\tconst linkMarkType = state.schema.marks['link'];\n\t\t\t\tif (linkMarkType) {\n\t\t\t\t\tconst range = getMarkRange(state.doc.resolve(from), linkMarkType);\n\t\t\t\t\tif (range) {\n\t\t\t\t\t\treturn state.doc.textBetween(range.from, range.to, ' ');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn '';\n\t\t\t},\n\n\t\t\t// ── Character count ───────────────────────────────────────────────\n\t\t\tgetCharacterCount: () => ({\n\t\t\t\tcount:\n\t\t\t\t\teditor?.storage.characterCount?.characters?.() ??\n\t\t\t\t\teditor?.getText().length ??\n\t\t\t\t\t0,\n\t\t\t\tlimit: maxCharacters ?? null,\n\t\t\t}),\n\n\t\t\t// ── Sections ─────────────────────────────────────────────────────\n\t\t\tgetSectionContent: (sectionId) =>\n\t\t\t\teditor\n\t\t\t\t\t? extractSectionContent(editor, sectionId)\n\t\t\t\t\t: { html: '', text: '', isEmpty: true, characterCount: 0 },\n\n\t\t\tsetSectionContent: (sectionId, html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => setSectionContentInEditor(e, sectionId, normalised));\n\t\t\t},\n\n\t\t\tfocusSection: (sectionId) => {\n\t\t\t\tenqueue((e) => {\n\t\t\t\t\tif (sectionId === 'body') {\n\t\t\t\t\t\tlet endOfBody = e.state.doc.content.size - 1;\n\t\t\t\t\t\te.state.doc.descendants((node, pos) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tnode.type.name === 'sectionDivider' &&\n\t\t\t\t\t\t\t\tendOfBody === e.state.doc.content.size - 1\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tendOfBody = pos - 1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn endOfBody === e.state.doc.content.size - 1;\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (endOfBody < 1) endOfBody = 1;\n\t\t\t\t\t\te.chain().focus().setTextSelection(endOfBody).run();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tlet targetPos = -1;\n\t\t\t\t\te.state.doc.descendants((node, pos) => {\n\t\t\t\t\t\tif (targetPos !== -1) return false;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tnode.type.name === 'sectionDivider' &&\n\t\t\t\t\t\t\tnode.attrs['sectionId'] === sectionId\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// pos + nodeSize lands right after the divider;\n\t\t\t\t\t\t\t// +1 more puts us inside the first paragraph of that section.\n\t\t\t\t\t\t\ttargetPos = pos + node.nodeSize + 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\tif (targetPos !== -1) {\n\t\t\t\t\t\te.chain().focus().setTextSelection(targetPos).run();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t},\n\n\t\t\tclearSection: (sectionId) => {\n\t\t\t\tenqueue((e) => setSectionContentInEditor(e, sectionId, '<p></p>'));\n\t\t\t},\n\n\t\t\t// ── Convenience body shorthands ───────────────────────────────────\n\t\t\tgetBodyContent: () =>\n\t\t\t\teditor\n\t\t\t\t\t? extractBodyContent(editor)\n\t\t\t\t\t: { html: '', text: '', isEmpty: true, characterCount: 0 },\n\t\t\tsetBodyContent: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => setSectionContentInEditor(e, 'body', normalised));\n\t\t\t},\n\t\t\tsetBodyAndSections: (body, sections) => {\n\t\t\t\tconst html = buildSectionedContent(\n\t\t\t\t\tnormalizeHtml(body),\n\t\t\t\t\tsections.map((s) => ({\n\t\t\t\t\t\tid: s.id,\n\t\t\t\t\t\tcontent: normalizeHtml(s.content),\n\t\t\t\t\t})),\n\t\t\t\t);\n\t\t\t\tenqueue((e) => e.commands.setContent(html, { emitUpdate: true }));\n\t\t\t},\n\t\t\tappendBodyContent: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\t// findSectionEndPos returns the position of the first divider (or\n\t\t\t\t// doc.content.size), which is the block boundary after the last </p>.\n\t\t\t\t// Subtract 1 to stay inside the last paragraph so successive calls\n\t\t\t\t// append inline text rather than creating a new paragraph each time.\n\t\t\t\tenqueue((e) => {\n\t\t\t\t\tconst boundaryPos = findSectionEndPos(e, 'body');\n\t\t\t\t\te.commands.insertContentAt(boundaryPos - 1, normalised);\n\t\t\t\t});\n\t\t\t},\n\t\t\tinsertAtSectionStart: (sectionId, html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => {\n\t\t\t\t\tconst pos = findSectionStartPos(e, sectionId);\n\t\t\t\t\tif (pos !== -1) e.commands.insertContentAt(pos, normalised);\n\t\t\t\t});\n\t\t\t},\n\t\t\tinsertAtSectionEnd: (sectionId, html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => {\n\t\t\t\t\tconst pos = findSectionEndPos(e, sectionId);\n\t\t\t\t\te.commands.insertContentAt(pos, normalised);\n\t\t\t\t});\n\t\t\t},\n\t\t\t// ── Formats & actions ─────────────────────────────────────────────\n\t\t\tgetActiveFormats: () =>\n\t\t\t\teditor ? extractActiveFormats(editor) : DEFAULT_FORMAT_STATE,\n\t\t\tactions: {\n\t\t\t\ttoggleBold: () => editor?.chain().focus().toggleBold().run(),\n\t\t\t\ttoggleItalic: () => editor?.chain().focus().toggleItalic().run(),\n\t\t\t\ttoggleUnderline: () => editor?.chain().focus().toggleUnderline().run(),\n\t\t\t\ttoggleStrike: () => editor?.chain().focus().toggleStrike().run(),\n\t\t\t\ttoggleBulletList: () =>\n\t\t\t\t\teditor?.chain().focus().toggleBulletList().run(),\n\t\t\t\ttoggleOrderedList: () =>\n\t\t\t\t\teditor?.chain().focus().toggleOrderedList().run(),\n\t\t\t\ttoggleBlockquote: () =>\n\t\t\t\t\teditor?.chain().focus().toggleBlockquote().run(),\n\t\t\t\ttoggleCodeBlock: () => editor?.chain().focus().toggleCodeBlock().run(),\n\t\t\t\tsetTextAlign: (align) =>\n\t\t\t\t\teditor?.chain().focus().setTextAlign(align).run(),\n\t\t\t\tsetFontFamily: (font) =>\n\t\t\t\t\teditor?.chain().focus().setFontFamily(font).run(),\n\t\t\t\tsetFontSize: (size) => editor?.chain().focus().setFontSize(size).run(),\n\t\t\t\tsetColor: (color) => editor?.chain().focus().setColor(color).run(),\n\t\t\t\tsetHighlight: (color) =>\n\t\t\t\t\teditor?.chain().focus().toggleHighlight({ color }).run(),\n\t\t\t\tunsetColor: () => editor?.chain().focus().unsetColor().run(),\n\t\t\t\tunsetHighlight: () => editor?.chain().focus().unsetHighlight().run(),\n\t\t\t\tsetLink: (href, text) => {\n\t\t\t\t\tif (!editor) return;\n\t\t\t\t\tif (text !== undefined) {\n\t\t\t\t\t\teditor\n\t\t\t\t\t\t\t.chain()\n\t\t\t\t\t\t\t.focus()\n\t\t\t\t\t\t\t.extendMarkRange('link')\n\t\t\t\t\t\t\t.command(({ tr, state }) => {\n\t\t\t\t\t\t\t\tconst { from, to } = tr.selection;\n\t\t\t\t\t\t\t\tconst linkMarkType = state.schema.marks['link'];\n\t\t\t\t\t\t\t\tif (!linkMarkType) return false;\n\t\t\t\t\t\t\t\tconst linkNode = state.schema.text(text, [\n\t\t\t\t\t\t\t\t\tlinkMarkType.create({ href }),\n\t\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t\t\tconst space = state.schema.text(' ');\n\t\t\t\t\t\t\t\ttr.replaceWith(from, to, [linkNode, space]);\n\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.run();\n\t\t\t\t\t} else {\n\t\t\t\t\t\teditor\n\t\t\t\t\t\t\t.chain()\n\t\t\t\t\t\t\t.focus()\n\t\t\t\t\t\t\t.extendMarkRange('link')\n\t\t\t\t\t\t\t.setLink({ href })\n\t\t\t\t\t\t\t.insertContent(' ')\n\t\t\t\t\t\t\t.run();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tupdateLink: (href) =>\n\t\t\t\t\teditor\n\t\t\t\t\t\t?.chain()\n\t\t\t\t\t\t.focus()\n\t\t\t\t\t\t.extendMarkRange('link')\n\t\t\t\t\t\t.setLink({ href })\n\t\t\t\t\t\t.run(),\n\t\t\t\tremoveLink: () =>\n\t\t\t\t\teditor?.chain().focus().extendMarkRange('link').unsetLink().run(),\n\t\t\t\tinsertEmoji: (emoji) =>\n\t\t\t\t\teditor?.chain().focus().insertContent(emoji).run(),\n\t\t\t\tinsertVariable: (variableName) =>\n\t\t\t\t\teditor?.chain().focus().insertContent(`{{${variableName}}}`).run(),\n\t\t\t\tinsertHtml: (html) =>\n\t\t\t\t\teditor?.commands.insertContent(normalizeHtml(html)),\n\t\t\t\tundo: () => editor?.chain().focus().undo().run(),\n\t\t\t\tredo: () => editor?.chain().focus().redo().run(),\n\t\t\t\tcanUndo: () => editor?.can().undo() ?? false,\n\t\t\t\tcanRedo: () => editor?.can().redo() ?? false,\n\t\t\t\ttoggleSuperscript: () =>\n\t\t\t\t\teditor?.chain().focus().toggleSuperscript().run(),\n\t\t\t\ttoggleSubscript: () => editor?.chain().focus().toggleSubscript().run(),\n\t\t\t\tinsertImage: (src) => editor?.chain().focus().setImage({ src }).run(),\n\t\t\t},\n\t\t}),\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[editor],\n\t);\n\n\tif (!editor) return null;\n\n\treturn (\n\t\t<BikEditorShell\n\t\t\tminHeight={minHeight}\n\t\t\tmaxHeight={maxHeight}\n\t\t\tstyle={style}\n\t\t\tclassName={className}\n\t\t>\n\t\t\t<EditorContent editor={editor} />\n\t\t\t<LinkBubbleMenu editor={editor} renderLinkTooltip={link?.renderTooltip} />\n\t\t</BikEditorShell>\n\t);\n};\n\nexport const BikEditor = forwardRef<BikEditorRef, BikEditorProps>(\n\tBikEditorInner,\n);\nBikEditor.displayName = 'BikEditor';\n"],"names":["cssToString","style","Object","entries","map","_ref","k","v","replace","c","toLowerCase","join","BikEditor","forwardRef","BikEditorInner","props","ref","initialContent","sections","features","disabled","maxCharacters","shortcuts","sendShortcut","mentions","slashCommands","link","onPaste","onReady","onChange","onSend","onFocus","onBlur","onSelectionChange","minHeight","maxHeight","className","editorClassName","editorStyle","initialEditorContent","length","buildSectionedContent","normalizeHtml","s","assign","content","pendingQueue","useRef","hasCalledOnReady","onReadyRef","current","onChangeRef","onSelectionChangeRef","onFocusRef","onBlurRef","onSendRef","editor","useEditor","extensions","buildExtensions","placeholder","hasSections","_a","agents","teams","items","snapshot","call","undefined","onMentionSelected","onSelect","onSlashCommandSelected","renderMentionItem","renderItem","renderMentionDropdown","renderDropdown","renderSlashCommandItem","renderSlashCommandDropdown","editable","immediatelyRender","editorProps","attributes","class","onUpdate","_ref2","e","extractContent","onTransaction","_ref3","extractActiveFormats","enqueue","op","push","useEffect","splice","forEach","useImperativeHandle","focus","position","commands","blur","clearContent","setContent","html","normalised","emitUpdate","insertContent","insertInlineContent","insertInlineHtml","insertAtStart","insertContentAt","insertBlock","state","doc","size","appendInline","insertAtEnd","this","appendContent","getContent","text","isEmpty","characterCount","getJSON","getMentions","agentIds","Set","teamIds","descendants","node","type","name","attrs","add","String","Array","from","getCursorPosition","to","selection","insertAtPosition","pos","getSelectedText","empty","textBetween","linkMarkType","schema","marks","range","getMarkRange","resolve","getCharacterCount","count","_d","_c","_b","storage","characters","getText","limit","getSectionContent","sectionId","extractSectionContent","setSectionContent","setSectionContentInEditor","focusSection","endOfBody","chain","setTextSelection","run","targetPos","nodeSize","clearSection","getBodyContent","extractBodyContent","setBodyContent","setBodyAndSections","body","id","appendBodyContent","boundaryPos","findSectionEndPos","insertAtSectionStart","findSectionStartPos","insertAtSectionEnd","getActiveFormats","DEFAULT_FORMAT_STATE","actions","toggleBold","toggleItalic","toggleUnderline","toggleStrike","toggleBulletList","toggleOrderedList","toggleBlockquote","toggleCodeBlock","setTextAlign","align","setFontFamily","font","setFontSize","setColor","color","setHighlight","toggleHighlight","unsetColor","unsetHighlight","setLink","href","extendMarkRange","command","_ref4","tr","linkNode","create","space","replaceWith","updateLink","removeLink","unsetLink","insertEmoji","emoji","insertVariable","variableName","insertHtml","undo","redo","canUndo","can","canRedo","toggleSuperscript","toggleSubscript","insertImage","src","setImage","_jsxs","BikEditorShell","children","_jsx","EditorContent","LinkBubbleMenu","renderLinkTooltip","renderTooltip","displayName"],"mappings":"yxBAqCA,SAASA,EAAYC,GACpB,OAAOC,OAAOC,QAAQF,GACpBG,KACAC,IAAA,IAAEC,EAAGC,GAAEF,EAAA,MAAK,GAAGC,EAAEE,QAAQ,YAAaC,OAAUA,EAAEC,qBAAoBH,GAAG,IAEzEI,KAAK,IACR,CAEA,MAwaaC,EAAYC,GAxaFC,CACtBC,EACAC,WAEA,MAAMC,eACLA,EAAcC,SACdA,EAAQC,SACRA,EAAQC,SACRA,EAAQC,cACRA,EAAaC,UACbA,EAASC,aACTA,EAAYC,SACZA,EAAQC,cACRA,EAAaC,KACbA,EAAIC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V,UAAWA,EACXC,UAAWA,EACXlC,MAAOA,EACPmC,UAAWA,GAEX,CAAAyM,SAAA,CAAAC,EAACC,EAAa,CAACvL,OAAQA,KACvBsL,EAACE,EAAe,CAAAxL,OAAQA,GAAQyL,kBAAmBvN,aAAA,EAAAA,EAAMwN,oBAVvC,IAWF,IAOnBtO,EAAUuO,YAAc"}
1
+ {"version":3,"file":"BikEditor.js","sources":["../../../src/editor/BikEditor.tsx"],"sourcesContent":["'use client';\n\n/**\n * IMPLEMENTATION LAYER — TipTap-specific.\n * If the underlying editor is swapped, this file changes; BikEditor.types.ts and\n * src/editor/index.ts (the consumer contract) do NOT change.\n */\nimport { Editor, getMarkRange } from '@tiptap/core';\nimport { EditorContent, useEditor } from '@tiptap/react';\nimport React, {\n\tforwardRef,\n\tuseEffect,\n\tuseImperativeHandle,\n\tuseRef,\n} from 'react';\nimport { BikEditorShell } from './BikEditor.styles';\nimport {\n\tBikEditorProps,\n\tBikEditorRef,\n\tDEFAULT_FORMAT_STATE,\n} from './BikEditor.types';\nimport {\n\tbuildSectionedContent,\n\textractActiveFormats,\n\textractBodyContent,\n\textractContent,\n\textractSectionContent,\n\tfindSectionEndPos,\n\tfindSectionStartPos,\n\tinsertInlineHtml,\n\tnormalizeHtml,\n\tsetSectionContentInEditor,\n} from './BikEditor.utils';\nimport { buildExtensions } from './extensions/buildExtensions';\nimport { LinkBubbleMenu } from './floating/LinkBubbleMenu';\n\n/** Convert React.CSSProperties to an inline CSS string for editorProps.attributes. */\nfunction cssToString(style: React.CSSProperties): string {\n\treturn Object.entries(style)\n\t\t.map(\n\t\t\t([k, v]) => `${k.replace(/([A-Z])/g, (c) => `-${c.toLowerCase()}`)}:${v}`,\n\t\t)\n\t\t.join(';');\n}\n\nconst BikEditorInner = (\n\tprops: BikEditorProps,\n\tref: React.Ref<BikEditorRef>,\n) => {\n\tconst {\n\t\tinitialContent,\n\t\tsections,\n\t\tfeatures,\n\t\tdisabled,\n\t\tmaxCharacters,\n\t\tshortcuts,\n\t\tsendShortcut,\n\t\tmentions,\n\t\tslashCommands,\n\t\tlink,\n\t\tonPaste,\n\t\tonReady,\n\t\tonChange,\n\t\tonSend,\n\t\tonFocus,\n\t\tonBlur,\n\t\tonSelectionChange,\n\t\tminHeight,\n\t\tmaxHeight,\n\t\tstyle,\n\t\tclassName,\n\t\teditorClassName,\n\t\teditorStyle,\n\t} = props;\n\n\tconst initialEditorContent = sections?.length\n\t\t? buildSectionedContent(\n\t\t\t\tnormalizeHtml(initialContent ?? ''),\n\t\t\t\tsections.map((s) => ({ ...s, content: normalizeHtml(s.content) })),\n\t\t )\n\t\t: normalizeHtml(initialContent ?? '');\n\n\t// ── Command queue ─────────────────────────────────────────────────────────\n\t// TipTap's useEditor initializes asynchronously; the editor instance is null\n\t// until the first commit. Any imperative method called before the editor is\n\t// ready is enqueued here and flushed automatically once it becomes non-null.\n\t// Consumers never need setTimeout or readiness guards.\n\tconst pendingQueue = useRef<Array<(e: Editor) => void>>([]);\n\tconst hasCalledOnReady = useRef(false);\n\t// Keep stable refs to all callbacks so useEditor receives the same function\n\t// identity on every render — prevents TipTap from re-registering event\n\t// handlers every time the parent re-renders with new inline function props.\n\tconst onReadyRef = useRef(onReady);\n\tonReadyRef.current = onReady;\n\tconst onChangeRef = useRef(onChange);\n\tonChangeRef.current = onChange;\n\tconst onSelectionChangeRef = useRef(onSelectionChange);\n\tonSelectionChangeRef.current = onSelectionChange;\n\tconst onFocusRef = useRef(onFocus);\n\tonFocusRef.current = onFocus;\n\tconst onBlurRef = useRef(onBlur);\n\tonBlurRef.current = onBlur;\n\tconst onSendRef = useRef(onSend);\n\tonSendRef.current = onSend;\n\tconst agentMentionsRef = useRef(mentions?.agents ?? []);\n\tagentMentionsRef.current = mentions?.agents ?? [];\n\tconst teamMentionsRef = useRef(mentions?.teams ?? []);\n\tteamMentionsRef.current = mentions?.teams ?? [];\n\tconst slashCommandsRef = useRef(slashCommands?.items ?? []);\n\tslashCommandsRef.current = slashCommands?.items ?? [];\n\n\tconst editor = useEditor({\n\t\textensions: buildExtensions({\n\t\t\tfeatures,\n\t\t\tplaceholder: props.placeholder,\n\t\t\tmaxCharacters,\n\t\t\thasSections: (sections?.length ?? 0) > 0,\n\t\t\tmentions: {\n\t\t\t\tagents: mentions?.agents ? agentMentionsRef : undefined,\n\t\t\t\tteams: mentions?.teams ? teamMentionsRef : undefined,\n\t\t\t},\n\t\t\tslashCommands: slashCommands?.items ? slashCommandsRef : undefined,\n\t\t\tonPaste,\n\t\t\tonSend: onSend ? (snapshot) => onSendRef.current?.(snapshot) : undefined,\n\t\t\tsendShortcut,\n\t\t\tshortcuts,\n\t\t\tonMentionSelected: mentions?.onSelect,\n\t\t\tonSlashCommandSelected: slashCommands?.onSelect,\n\t\t\trenderMentionItem: mentions?.renderItem,\n\t\t\trenderMentionDropdown: mentions?.renderDropdown,\n\t\t\trenderSlashCommandItem: slashCommands?.renderItem,\n\t\t\trenderSlashCommandDropdown: slashCommands?.renderDropdown,\n\t\t}),\n\t\tcontent: initialEditorContent,\n\t\teditable: !disabled,\n\t\timmediatelyRender: false, // SSR-safe — NEVER remove this\n\t\teditorProps: {\n\t\t\tattributes: {\n\t\t\t\t...(editorClassName ? { class: editorClassName } : {}),\n\t\t\t\t...(editorStyle ? { style: cssToString(editorStyle) } : {}),\n\t\t\t},\n\t\t},\n\t\tonUpdate: ({ editor: e }) => {\n\t\t\tonChangeRef.current?.(extractContent(e));\n\t\t},\n\t\tonTransaction: ({ editor: e }) => {\n\t\t\tonSelectionChangeRef.current?.(extractActiveFormats(e));\n\t\t},\n\t\tonFocus: () => onFocusRef.current?.(),\n\t\tonBlur: () => onBlurRef.current?.(),\n\t});\n\n\t// ── enqueue ───────────────────────────────────────────────────────────────\n\t// Run immediately if the editor is ready; otherwise defer to the queue.\n\t// Closures passed to enqueue MUST capture all parameters explicitly —\n\t// they must NOT close over `editor` (which would be null at enqueue time).\n\tfunction enqueue(op: (e: Editor) => void): void {\n\t\tif (editor) {\n\t\t\top(editor);\n\t\t} else {\n\t\t\tpendingQueue.current.push(op);\n\t\t}\n\t}\n\n\t// Flush the pending queue and fire onReady when editor transitions null → ready.\n\tuseEffect(() => {\n\t\tif (!editor) return;\n\t\tif (pendingQueue.current.length > 0) {\n\t\t\tconst queue = pendingQueue.current.splice(0);\n\t\t\tqueue.forEach((op) => op(editor));\n\t\t}\n\t\tif (!hasCalledOnReady.current) {\n\t\t\thasCalledOnReady.current = true;\n\t\t\tonReadyRef.current?.();\n\t\t}\n\t}, [editor]);\n\n\tuseImperativeHandle(\n\t\tref,\n\t\t() => ({\n\t\t\t// ── Focus ────────────────────────────────────────────────────────\n\t\t\tfocus: (position) => enqueue((e) => e.commands.focus(position)),\n\t\t\tblur: () => enqueue((e) => e.commands.blur()),\n\n\t\t\t// ── Content ──────────────────────────────────────────────────────\n\t\t\tclearContent: () => enqueue((e) => e.commands.clearContent(true)),\n\t\t\tsetContent: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => e.commands.setContent(normalised, { emitUpdate: true }));\n\t\t\t},\n\t\t\tinsertContent: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => e.commands.insertContent(normalised));\n\t\t\t},\n\t\t\tinsertInlineContent: (html) => {\n\t\t\t\tenqueue((e) => insertInlineHtml(e, html));\n\t\t\t},\n\t\t\tinsertAtStart: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => e.commands.insertContentAt(1, normalised));\n\t\t\t},\n\t\t\tinsertBlock: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) =>\n\t\t\t\t\te.commands.insertContentAt(e.state.doc.content.size, normalised),\n\t\t\t\t);\n\t\t\t},\n\t\t\tappendInline: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\t// doc.content.size is after the last </p> (block boundary).\n\t\t\t\t// Subtract 1 to land inside the last paragraph so text appends\n\t\t\t\t// inline rather than being wrapped in a new paragraph each call.\n\t\t\t\tenqueue((e) =>\n\t\t\t\t\te.commands.insertContentAt(e.state.doc.content.size - 1, normalised),\n\t\t\t\t);\n\t\t\t},\n\t\t\t// Backwards-compatible aliases\n\t\t\tinsertAtEnd(html) {\n\t\t\t\tthis.insertBlock(html);\n\t\t\t},\n\t\t\tappendContent(html) {\n\t\t\t\tthis.appendInline(html);\n\t\t\t},\n\t\t\tgetContent: () =>\n\t\t\t\teditor\n\t\t\t\t\t? extractContent(editor)\n\t\t\t\t\t: { html: '', text: '', isEmpty: true, characterCount: 0 },\n\t\t\tgetJSON: () => editor?.getJSON() ?? null,\n\t\t\tgetMentions: () => {\n\t\t\t\tconst agentIds = new Set<string>();\n\t\t\t\tconst teamIds = new Set<string>();\n\t\t\t\tif (!editor) return { agentIds: [], teamIds: [] };\n\t\t\t\teditor.state.doc.descendants((node) => {\n\t\t\t\t\tif (node.type.name === 'mentionAgent' && node.attrs['id'] != null) {\n\t\t\t\t\t\tagentIds.add(String(node.attrs['id']));\n\t\t\t\t\t} else if (\n\t\t\t\t\t\tnode.type.name === 'mentionTeam' &&\n\t\t\t\t\t\tnode.attrs['id'] != null\n\t\t\t\t\t) {\n\t\t\t\t\t\tteamIds.add(String(node.attrs['id']));\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\treturn { agentIds: Array.from(agentIds), teamIds: Array.from(teamIds) };\n\t\t\t},\n\n\t\t\t// ── Selection ────────────────────────────────────────────────────\n\t\t\tgetCursorPosition: () => {\n\t\t\t\tif (!editor) return { from: 0, to: 0 };\n\t\t\t\tconst { from, to } = editor.state.selection;\n\t\t\t\treturn { from, to };\n\t\t\t},\n\t\t\tinsertAtPosition: (pos, html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => e.commands.insertContentAt(pos, normalised));\n\t\t\t},\n\t\t\tgetSelectedText: () => {\n\t\t\t\tif (!editor) return '';\n\t\t\t\tconst { state } = editor;\n\t\t\t\tconst { from, to, empty } = state.selection;\n\t\t\t\tif (!empty) {\n\t\t\t\t\treturn state.doc.textBetween(from, to, ' ');\n\t\t\t\t}\n\t\t\t\t// When the cursor is inside a link with nothing selected, return the\n\t\t\t\t// full link text — useful for pre-filling a link modal's text field.\n\t\t\t\tconst linkMarkType = state.schema.marks['link'];\n\t\t\t\tif (linkMarkType) {\n\t\t\t\t\tconst range = getMarkRange(state.doc.resolve(from), linkMarkType);\n\t\t\t\t\tif (range) {\n\t\t\t\t\t\treturn state.doc.textBetween(range.from, range.to, ' ');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn '';\n\t\t\t},\n\n\t\t\t// ── Character count ───────────────────────────────────────────────\n\t\t\tgetCharacterCount: () => ({\n\t\t\t\tcount:\n\t\t\t\t\teditor?.storage.characterCount?.characters?.() ??\n\t\t\t\t\teditor?.getText().length ??\n\t\t\t\t\t0,\n\t\t\t\tlimit: maxCharacters ?? null,\n\t\t\t}),\n\n\t\t\t// ── Sections ─────────────────────────────────────────────────────\n\t\t\tgetSectionContent: (sectionId) =>\n\t\t\t\teditor\n\t\t\t\t\t? extractSectionContent(editor, sectionId)\n\t\t\t\t\t: { html: '', text: '', isEmpty: true, characterCount: 0 },\n\n\t\t\tsetSectionContent: (sectionId, html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => setSectionContentInEditor(e, sectionId, normalised));\n\t\t\t},\n\n\t\t\tfocusSection: (sectionId) => {\n\t\t\t\tenqueue((e) => {\n\t\t\t\t\tif (sectionId === 'body') {\n\t\t\t\t\t\tlet endOfBody = e.state.doc.content.size - 1;\n\t\t\t\t\t\te.state.doc.descendants((node, pos) => {\n\t\t\t\t\t\t\tif (\n\t\t\t\t\t\t\t\tnode.type.name === 'sectionDivider' &&\n\t\t\t\t\t\t\t\tendOfBody === e.state.doc.content.size - 1\n\t\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t\tendOfBody = pos - 1;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn endOfBody === e.state.doc.content.size - 1;\n\t\t\t\t\t\t});\n\t\t\t\t\t\tif (endOfBody < 1) endOfBody = 1;\n\t\t\t\t\t\te.chain().focus().setTextSelection(endOfBody).run();\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tlet targetPos = -1;\n\t\t\t\t\te.state.doc.descendants((node, pos) => {\n\t\t\t\t\t\tif (targetPos !== -1) return false;\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tnode.type.name === 'sectionDivider' &&\n\t\t\t\t\t\t\tnode.attrs['sectionId'] === sectionId\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\t// pos + nodeSize lands right after the divider;\n\t\t\t\t\t\t\t// +1 more puts us inside the first paragraph of that section.\n\t\t\t\t\t\t\ttargetPos = pos + node.nodeSize + 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\tif (targetPos !== -1) {\n\t\t\t\t\t\te.chain().focus().setTextSelection(targetPos).run();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t},\n\n\t\t\tclearSection: (sectionId) => {\n\t\t\t\tenqueue((e) => setSectionContentInEditor(e, sectionId, '<p></p>'));\n\t\t\t},\n\n\t\t\t// ── Convenience body shorthands ───────────────────────────────────\n\t\t\tgetBodyContent: () =>\n\t\t\t\teditor\n\t\t\t\t\t? extractBodyContent(editor)\n\t\t\t\t\t: { html: '', text: '', isEmpty: true, characterCount: 0 },\n\t\t\tsetBodyContent: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => setSectionContentInEditor(e, 'body', normalised));\n\t\t\t},\n\t\t\tsetBodyAndSections: (body, sections) => {\n\t\t\t\tconst html = buildSectionedContent(\n\t\t\t\t\tnormalizeHtml(body),\n\t\t\t\t\tsections.map((s) => ({\n\t\t\t\t\t\tid: s.id,\n\t\t\t\t\t\tcontent: normalizeHtml(s.content),\n\t\t\t\t\t})),\n\t\t\t\t);\n\t\t\t\tenqueue((e) => e.commands.setContent(html, { emitUpdate: true }));\n\t\t\t},\n\t\t\tappendBodyContent: (html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\t// findSectionEndPos returns the position of the first divider (or\n\t\t\t\t// doc.content.size), which is the block boundary after the last </p>.\n\t\t\t\t// Subtract 1 to stay inside the last paragraph so successive calls\n\t\t\t\t// append inline text rather than creating a new paragraph each time.\n\t\t\t\tenqueue((e) => {\n\t\t\t\t\tconst boundaryPos = findSectionEndPos(e, 'body');\n\t\t\t\t\te.commands.insertContentAt(boundaryPos - 1, normalised);\n\t\t\t\t});\n\t\t\t},\n\t\t\tinsertAtSectionStart: (sectionId, html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => {\n\t\t\t\t\tconst pos = findSectionStartPos(e, sectionId);\n\t\t\t\t\tif (pos !== -1) e.commands.insertContentAt(pos, normalised);\n\t\t\t\t});\n\t\t\t},\n\t\t\tinsertAtSectionEnd: (sectionId, html) => {\n\t\t\t\tconst normalised = normalizeHtml(html);\n\t\t\t\tenqueue((e) => {\n\t\t\t\t\tconst pos = findSectionEndPos(e, sectionId);\n\t\t\t\t\te.commands.insertContentAt(pos, normalised);\n\t\t\t\t});\n\t\t\t},\n\t\t\t// ── Formats & actions ─────────────────────────────────────────────\n\t\t\tgetActiveFormats: () =>\n\t\t\t\teditor ? extractActiveFormats(editor) : DEFAULT_FORMAT_STATE,\n\t\t\tactions: {\n\t\t\t\ttoggleBold: () => editor?.chain().focus().toggleBold().run(),\n\t\t\t\ttoggleItalic: () => editor?.chain().focus().toggleItalic().run(),\n\t\t\t\ttoggleUnderline: () => editor?.chain().focus().toggleUnderline().run(),\n\t\t\t\ttoggleStrike: () => editor?.chain().focus().toggleStrike().run(),\n\t\t\t\ttoggleBulletList: () =>\n\t\t\t\t\teditor?.chain().focus().toggleBulletList().run(),\n\t\t\t\ttoggleOrderedList: () =>\n\t\t\t\t\teditor?.chain().focus().toggleOrderedList().run(),\n\t\t\t\ttoggleBlockquote: () =>\n\t\t\t\t\teditor?.chain().focus().toggleBlockquote().run(),\n\t\t\t\ttoggleCodeBlock: () => editor?.chain().focus().toggleCodeBlock().run(),\n\t\t\t\tsetTextAlign: (align) =>\n\t\t\t\t\teditor?.chain().focus().setTextAlign(align).run(),\n\t\t\t\tsetFontFamily: (font) =>\n\t\t\t\t\teditor?.chain().focus().setFontFamily(font).run(),\n\t\t\t\tsetFontSize: (size) => editor?.chain().focus().setFontSize(size).run(),\n\t\t\t\tsetColor: (color) => editor?.chain().focus().setColor(color).run(),\n\t\t\t\tsetHighlight: (color) =>\n\t\t\t\t\teditor?.chain().focus().toggleHighlight({ color }).run(),\n\t\t\t\tunsetColor: () => editor?.chain().focus().unsetColor().run(),\n\t\t\t\tunsetHighlight: () => editor?.chain().focus().unsetHighlight().run(),\n\t\t\t\tsetLink: (href, text) => {\n\t\t\t\t\tif (!editor) return;\n\t\t\t\t\tif (text !== undefined) {\n\t\t\t\t\t\teditor\n\t\t\t\t\t\t\t.chain()\n\t\t\t\t\t\t\t.focus()\n\t\t\t\t\t\t\t.extendMarkRange('link')\n\t\t\t\t\t\t\t.command(({ tr, state }) => {\n\t\t\t\t\t\t\t\tconst { from, to } = tr.selection;\n\t\t\t\t\t\t\t\tconst linkMarkType = state.schema.marks['link'];\n\t\t\t\t\t\t\t\tif (!linkMarkType) return false;\n\t\t\t\t\t\t\t\tconst linkNode = state.schema.text(text, [\n\t\t\t\t\t\t\t\t\tlinkMarkType.create({ href }),\n\t\t\t\t\t\t\t\t]);\n\t\t\t\t\t\t\t\tconst space = state.schema.text(' ');\n\t\t\t\t\t\t\t\ttr.replaceWith(from, to, [linkNode, space]);\n\t\t\t\t\t\t\t\treturn true;\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t.run();\n\t\t\t\t\t} else {\n\t\t\t\t\t\teditor\n\t\t\t\t\t\t\t.chain()\n\t\t\t\t\t\t\t.focus()\n\t\t\t\t\t\t\t.extendMarkRange('link')\n\t\t\t\t\t\t\t.setLink({ href })\n\t\t\t\t\t\t\t.insertContent(' ')\n\t\t\t\t\t\t\t.run();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tupdateLink: (href) =>\n\t\t\t\t\teditor\n\t\t\t\t\t\t?.chain()\n\t\t\t\t\t\t.focus()\n\t\t\t\t\t\t.extendMarkRange('link')\n\t\t\t\t\t\t.setLink({ href })\n\t\t\t\t\t\t.run(),\n\t\t\t\tremoveLink: () =>\n\t\t\t\t\teditor?.chain().focus().extendMarkRange('link').unsetLink().run(),\n\t\t\t\tinsertEmoji: (emoji) =>\n\t\t\t\t\teditor?.chain().focus().insertContent(emoji).run(),\n\t\t\t\tinsertVariable: (variableName) =>\n\t\t\t\t\teditor?.chain().focus().insertContent(`{{${variableName}}}`).run(),\n\t\t\t\tinsertHtml: (html) =>\n\t\t\t\t\teditor?.commands.insertContent(normalizeHtml(html)),\n\t\t\t\tundo: () => editor?.chain().focus().undo().run(),\n\t\t\t\tredo: () => editor?.chain().focus().redo().run(),\n\t\t\t\tcanUndo: () => editor?.can().undo() ?? false,\n\t\t\t\tcanRedo: () => editor?.can().redo() ?? false,\n\t\t\t\ttoggleSuperscript: () =>\n\t\t\t\t\teditor?.chain().focus().toggleSuperscript().run(),\n\t\t\t\ttoggleSubscript: () => editor?.chain().focus().toggleSubscript().run(),\n\t\t\t\tinsertImage: (src) => editor?.chain().focus().setImage({ src }).run(),\n\t\t\t},\n\t\t}),\n\t\t// eslint-disable-next-line react-hooks/exhaustive-deps\n\t\t[editor],\n\t);\n\n\tif (!editor) return null;\n\n\treturn (\n\t\t<BikEditorShell\n\t\t\tminHeight={minHeight}\n\t\t\tmaxHeight={maxHeight}\n\t\t\tstyle={style}\n\t\t\tclassName={className}\n\t\t>\n\t\t\t<EditorContent editor={editor} />\n\t\t\t<LinkBubbleMenu editor={editor} renderLinkTooltip={link?.renderTooltip} />\n\t\t</BikEditorShell>\n\t);\n};\n\nexport const BikEditor = forwardRef<BikEditorRef, BikEditorProps>(\n\tBikEditorInner,\n);\nBikEditor.displayName = 'BikEditor';\n"],"names":["cssToString","style","Object","entries","map","_ref","k","v","replace","c","toLowerCase","join","BikEditor","forwardRef","BikEditorInner","props","ref","initialContent","sections","features","disabled","maxCharacters","shortcuts","sendShortcut","mentions","slashCommands","link","onPaste","onReady","onChange","onSend","onFocus","onBlur","onSelectionChange","minHeight","maxHeight","className","editorClassName","editorStyle","initialEditorContent","length","buildSectionedContent","normalizeHtml","s","assign","content","pendingQueue","useRef","hasCalledOnReady","onReadyRef","current","onChangeRef","onSelectionChangeRef","onFocusRef","onBlurRef","onSendRef","agentMentionsRef","agents","_a","_b","teamMentionsRef","teams","_c","_d","slashCommandsRef","items","_e","_f","editor","useEditor","extensions","buildExtensions","placeholder","hasSections","_g","undefined","snapshot","call","onMentionSelected","onSelect","onSlashCommandSelected","renderMentionItem","renderItem","renderMentionDropdown","renderDropdown","renderSlashCommandItem","renderSlashCommandDropdown","editable","immediatelyRender","editorProps","attributes","class","onUpdate","_ref2","e","extractContent","onTransaction","_ref3","extractActiveFormats","enqueue","op","push","useEffect","splice","forEach","useImperativeHandle","focus","position","commands","blur","clearContent","setContent","html","normalised","emitUpdate","insertContent","insertInlineContent","insertInlineHtml","insertAtStart","insertContentAt","insertBlock","state","doc","size","appendInline","insertAtEnd","this","appendContent","getContent","text","isEmpty","characterCount","getJSON","getMentions","agentIds","Set","teamIds","descendants","node","type","name","attrs","add","String","Array","from","getCursorPosition","to","selection","insertAtPosition","pos","getSelectedText","empty","textBetween","linkMarkType","schema","marks","range","getMarkRange","resolve","getCharacterCount","count","storage","characters","getText","limit","getSectionContent","sectionId","extractSectionContent","setSectionContent","setSectionContentInEditor","focusSection","endOfBody","chain","setTextSelection","run","targetPos","nodeSize","clearSection","getBodyContent","extractBodyContent","setBodyContent","setBodyAndSections","body","id","appendBodyContent","boundaryPos","findSectionEndPos","insertAtSectionStart","findSectionStartPos","insertAtSectionEnd","getActiveFormats","DEFAULT_FORMAT_STATE","actions","toggleBold","toggleItalic","toggleUnderline","toggleStrike","toggleBulletList","toggleOrderedList","toggleBlockquote","toggleCodeBlock","setTextAlign","align","setFontFamily","font","setFontSize","setColor","color","setHighlight","toggleHighlight","unsetColor","unsetHighlight","setLink","href","extendMarkRange","command","_ref4","tr","linkNode","create","space","replaceWith","updateLink","removeLink","unsetLink","insertEmoji","emoji","insertVariable","variableName","insertHtml","undo","redo","canUndo","can","canRedo","toggleSuperscript","toggleSubscript","insertImage","src","setImage","_jsxs","BikEditorShell","children","_jsx","EditorContent","LinkBubbleMenu","renderLinkTooltip","renderTooltip","displayName"],"mappings":"yxBAqCA,SAASA,EAAYC,GACpB,OAAOC,OAAOC,QAAQF,GACpBG,KACAC,IAAA,IAAEC,EAAGC,GAAEF,EAAA,MAAK,GAAGC,EAAEE,QAAQ,YAAaC,OAAUA,EAAEC,qBAAoBH,GAAG,IAEzEI,KAAK,IACR,CAEA,MA8aaC,EAAYC,GA9aFC,CACtBC,EACAC,uBAEA,MAAMC,eACLA,EAAcC,SACdA,EAAQC,SACRA,EAAQC,SACRA,EAAQC,cACRA,EAAaC,UACbA,EAASC,aACTA,EAAYC,SACZA,EAAQC,cACRA,EAAaC,KACbA,EAAIC,QACJA,EAAOC,QACPA,EAAOC,SACPA,EAAQC,OACRA,EAAMC,QACNA,EAAOC,OACPA,EAAMC,kBACNA,EAAiBC,UACjBA,EAASC,UACTA,EAASlC,MACTA,EAAKmC,UACLA,EAASC,gBACTA,EAAeC,YACfA,IACGvB,EAEEwB,IAAuBrB,aAAQ,EAARA,EAAUsB,QACpCC,EACAC,EAAczB,QAAAA,EAAkB,IAChCC,EAASd,KAAKuC,GAAYzC,OAAA0C,OAAA1C,OAAA0C,OAAA,CAAA,EAAAD,IAAGE,QAASH,EAAcC,EAAEE,cAEtDH,EAAczB,QAAAA,EAAkB,IAO7B6B,GAAeC,EAAmC,IAClDC,GAAmBD,GAAO,GA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,EAAAA,GAAQyG,QAAQnE,QAAQsI,SAAS,CAAED,QAAOhE,UAIlE,CAAC3G,KAGGA,GAGJ6K,EAACC,EAAchP,OAAA0C,OAAA,CACdV,UAAWA,EACXC,UAAWA,EACXlC,MAAOA,EACPmC,UAAWA,GAEX,CAAA+M,SAAA,CAAAC,EAACC,EAAa,CAACjL,OAAQA,KACvBgL,EAACE,EAAe,CAAAlL,OAAQA,GAAQmL,kBAAmB7N,aAAA,EAAAA,EAAM8N,oBAVvC,IAWF,IAOnB5O,EAAU6O,YAAc"}
@@ -1,2 +1,2 @@
1
- import o from"@tiptap/extension-character-count";import e from"@tiptap/extension-color";import t from"@tiptap/extension-font-family";import n from"@tiptap/extension-highlight";import i from"@tiptap/extension-image";import r from"@tiptap/extension-link";import s from"@tiptap/extension-placeholder";import a from"@tiptap/extension-subscript";import l from"@tiptap/extension-superscript";import m from"@tiptap/extension-text-align";import{TextStyle as p}from"@tiptap/extension-text-style";import d from"@tiptap/extension-underline";import u from"@tiptap/starter-kit";import{FontSizeExtension as c}from"./FontSizeExtension.js";import{buildAgentMentionExtension as f,buildTeamMentionExtension as h}from"./mention/MentionExtension.js";import{PasteExtension as x}from"./paste/PasteExtension.js";import{PlainClipboardExtension as v}from"./plainClipboard/PlainClipboardExtension.js";import{SectionDividerNode as g}from"./sectionDivider/SectionDividerNode.js";import{SendShortcutExtension as S}from"./sendShortcut/SendShortcutExtension.js";import{buildSlashCommandExtension as C}from"./slashCommand/SlashCommandExtension.js";import{VariableDecorationExtension as k}from"./variable/VariableDecorationExtension.js";function b(b){var M,j,P,E,y,D,w,I,T,O,R,z;const A=null!==(j=null===(M=b.features)||void 0===M?void 0:M.richPaste)&&void 0!==j&&j,F=null!==(E=null===(P=b.features)||void 0===P?void 0:P.richTypography)&&void 0!==E&&E,H=null===(y=b.features)||void 0===y?void 0:y.allowedMarks,L=o=>!H||H.includes(o);return[...[u.configure({link:!1,underline:!1,bold:!!L("bold")&&{},italic:!!L("italic")&&{},strike:!!L("strike")&&{},code:!!L("code")&&{}}),...L("underline")?[d]:[],r.extend({addPasteRules:()=>[],addInputRules:()=>[]}).configure({openOnClick:!1,autolink:!1,linkOnPaste:!1,HTMLAttributes:{rel:"noopener noreferrer",class:"bik-link"}}),p,s.configure({placeholder:null!==(D=b.placeholder)&&void 0!==D?D:"Type a message..."}),...b.onPaste?[x.configure({onPaste:b.onPaste})]:[],...A?[]:[v],S.configure({onSend:b.onSend,sendShortcut:b.sendShortcut,extraShortcuts:null!==(w=b.shortcuts)&&void 0!==w?w:[]}),k,...b.maxCharacters?[o.configure({limit:b.maxCharacters})]:[],g],...[...(null===(T=null===(I=b.mentions)||void 0===I?void 0:I.agents)||void 0===T?void 0:T.length)?[f(b.mentions.agents,b.onMentionSelected,b.renderMentionItem,b.renderMentionDropdown)]:[],...(null===(R=null===(O=b.mentions)||void 0===O?void 0:O.teams)||void 0===R?void 0:R.length)?[h(b.mentions.teams,b.onMentionSelected,b.renderMentionItem,b.renderMentionDropdown)]:[],...(null===(z=b.slashCommands)||void 0===z?void 0:z.length)?[C(b.slashCommands,b.onSlashCommandSelected,b.renderSlashCommandItem,b.renderSlashCommandDropdown)]:[]],...F?[e,n.configure({multicolor:!0}),t,c,m.configure({types:["heading","paragraph"]}),a,l,i]:[e]]}export{b as buildExtensions};
1
+ import e from"@tiptap/extension-character-count";import o from"@tiptap/extension-color";import t from"@tiptap/extension-font-family";import n from"@tiptap/extension-highlight";import i from"@tiptap/extension-image";import r from"@tiptap/extension-link";import s from"@tiptap/extension-placeholder";import a from"@tiptap/extension-subscript";import m from"@tiptap/extension-superscript";import p from"@tiptap/extension-text-align";import{TextStyle as l}from"@tiptap/extension-text-style";import d from"@tiptap/extension-underline";import c from"@tiptap/starter-kit";import{FontSizeExtension as u}from"./FontSizeExtension.js";import{buildAgentMentionExtension as f,buildTeamMentionExtension as h}from"./mention/MentionExtension.js";import{PasteExtension as x}from"./paste/PasteExtension.js";import{PlainClipboardExtension as g}from"./plainClipboard/PlainClipboardExtension.js";import{SectionDividerNode as v}from"./sectionDivider/SectionDividerNode.js";import{SendShortcutExtension as S}from"./sendShortcut/SendShortcutExtension.js";import{buildSlashCommandExtension as C}from"./slashCommand/SlashCommandExtension.js";import{VariableDecorationExtension as k}from"./variable/VariableDecorationExtension.js";function b(b){var M,j,P,E,y,D,w,I,T;const O=null!==(j=null===(M=b.features)||void 0===M?void 0:M.richPaste)&&void 0!==j&&j,R=null!==(E=null===(P=b.features)||void 0===P?void 0:P.richTypography)&&void 0!==E&&E,z=null===(y=b.features)||void 0===y?void 0:y.allowedMarks,A=e=>!z||z.includes(e);return[...[c.configure({link:!1,underline:!1,bold:!!A("bold")&&{},italic:!!A("italic")&&{},strike:!!A("strike")&&{},code:!!A("code")&&{}}),...A("underline")?[d]:[],r.extend({addPasteRules:()=>[],addInputRules:()=>[]}).configure({openOnClick:!1,autolink:!1,linkOnPaste:!1,HTMLAttributes:{rel:"noopener noreferrer",class:"bik-link"}}),l,s.configure({placeholder:null!==(D=b.placeholder)&&void 0!==D?D:"Type a message..."}),...b.onPaste?[x.configure({onPaste:b.onPaste})]:[],...O?[]:[g],S.configure({onSend:b.onSend,sendShortcut:b.sendShortcut,extraShortcuts:null!==(w=b.shortcuts)&&void 0!==w?w:[]}),k,...b.maxCharacters?[e.configure({limit:b.maxCharacters})]:[],v],...[...(null===(I=b.mentions)||void 0===I?void 0:I.agents)?[f(b.mentions.agents,b.onMentionSelected,b.renderMentionItem,b.renderMentionDropdown)]:[],...(null===(T=b.mentions)||void 0===T?void 0:T.teams)?[h(b.mentions.teams,b.onMentionSelected,b.renderMentionItem,b.renderMentionDropdown)]:[],...b.slashCommands?[C(b.slashCommands,b.onSlashCommandSelected,b.renderSlashCommandItem,b.renderSlashCommandDropdown)]:[]],...R?[o,n.configure({multicolor:!0}),t,u,p.configure({types:["heading","paragraph"]}),a,m,i]:[o]]}export{b as buildExtensions};
2
2
  //# sourceMappingURL=buildExtensions.js.map
@@ -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\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,EA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P3D,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?: {\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,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.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};
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};
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\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","createSuggestionPopup","element","clientRect","onUpdate","updateProps","Object","assign","_a","items","show","updatePosition","hide","onKeyDown","event","key","_b","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":"+RAcA,SAASA,EACRC,GACqB,IACrBC,EAAgEC,UAAAC,OAAAD,EAAAA,kBAAAE,EAChEC,EAAiEH,UAAAC,OAAAD,EAAAA,kBAAAE,EAEjE,MAAO,KACN,IAAIE,EACAC,EAEJ,MAAO,CACNC,QAAUC,IACTH,EAAY,IAAII,EAAcC,EAAiB,CAC9CF,qCAAYA,GAAK,CAAER,aAAYI,mBAC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AAO,CAAEmB,GAAIxD,EAAMwD,GAAIX,MAAO7C,EAAM6C,SAEpCY,MACFlE,SAAAA,EAAWS,EAAO,IAAI,EAEvB0D,OAAQpE,EAAYC,EAAU,IAAKC,EAAYI,KAGlD,CAEM,SAAU+D,EACfC,EACArE,EACAC,EACAI,GAEA,OAAO6B,EAAQC,OAAO,CAAEC,KAAM,gBAAiBC,UAAU,CACxDC,eAAgB,CAAEC,MAAO,iCACzBC,WAAY8B,IAAA,IAAC5B,QAAEA,EAAOC,KAAEA,GAAM2B,EAAA,MAC7B,GAAG5B,EAAQE,WAAWC,OAAOF,EAAKG,MAAa,OAAG,EACnDC,WAAYwB,IAAA,IAAC7B,QAAEA,EAAOC,KAAEA,GAAM4B,EAAA,MAAK,CAClC,OACAtB,EAAgBP,EAAQJ,gBACxB,GAAGI,EAAQE,WAAWC,OAAOF,EAAKG,MAAa,QAC/C,EACDF,WAAY,CACXC,KAAM,IACNxB,MAAOmD,IAAA,IAACrB,MAAEA,GAA0BqB,EAAA,OACnCH,EAAMjB,QAAQqB,GACbA,EAAEnB,MAAMC,cAAcC,SAASL,EAAMI,gBACrC,EACFE,QAASiB,IAAkC,IAAjC9D,OAAEA,EAAM+C,MAAEA,EAAKlD,MAAEA,GAAYiE,EACtC9D,EACEgD,QACAC,QACAC,YAAYH,GACZI,cAAc,CACdC,KAAM,cACNlB,MAAO,CAAEmB,GAAIxD,EAAMwD,GAAIX,MAAO7C,EAAM6C,SAEpCY,MACFlE,SAAAA,EAAWS,EAAO,IAAI,EAEvB0D,OAAQpE,EAAYC,EAAU,IAAKC,EAAYI,KAGlD"}
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":"+RAcA,SAASA,EACRC,GACqB,IACrBC,EAAgEC,UAAAC,OAAAD,EAAAA,kBAAAE,EAChEC,EAAiEH,UAAAC,OAAAD,EAAAA,kBAAAE,EAEjE,MAAO,KACN,IAAIE,EACAC,EAEJ,MAAO,CACNC,QAAUC,IACTH,EAAY,IAAII,EAAcC,EAAiB,CAC9CF,qCAAYA,GAAK,CAAER,aAAYI,mBAC/BO,OAAQH,EAAMG,SAEfL,EAAQM,EAAsBP,EAAUQ,QAASL,EAAMM,WAAW,EAEnEC,SAAWP,UACVH,EAAUW,YAAiBC,OAAAC,OAAAD,OAAAC,OAAA,CAAA,EAAAV,IAAOR,aAAYI,qBAC9B,QAAXe,EAAAX,EAAMY,aAAK,IAAAD,OAAA,EAAAA,EAAEjB,SAIlBI,EAAMe,OAC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C,UAAU,CACxDC,eAAgB,CAAEC,MAAO,iCACzBC,WAAY+B,IAAA,IAAC7B,QAAEA,EAAOC,KAAEA,GAAM4B,EAAA,MAC7B,GAAG7B,EAAQE,WAAWC,OAAOF,EAAKG,MAAa,OAAG,EACnDC,WAAYyB,IAAA,IAAC9B,QAAEA,EAAOC,KAAEA,GAAM6B,EAAA,MAAK,CAClC,OACAvB,EAAgBP,EAAQJ,gBACxB,GAAGI,EAAQE,WAAWC,OAAOF,EAAKG,MAAa,QAC/C,EACDF,WAAY,CACXC,KAAM,IACNxB,MAAOoD,IAAA,IAACtB,MAAEA,GAA0BsB,EAAA,OACnCH,EAASlB,QAAQC,QAAQqB,GACxBA,EAAEnB,MAAMC,cAAcC,SAASN,EAAMK,gBACrC,EACFE,QAASiB,IAAkC,IAAjC/D,OAAEA,EAAMgD,MAAEA,EAAKnD,MAAEA,GAAYkE,EACtC/D,EACEiD,QACAC,QACAC,YAAYH,GACZI,cAAc,CACdC,KAAM,cACNnB,MAAO,CAAEoB,GAAIzD,EAAMyD,GAAIX,MAAO9C,EAAM8C,SAEpCY,MACFnE,SAAAA,EAAWS,EAAO,IAAI,EAEvB2D,OAAQrE,EAAYC,EAAU,IAAKC,EAAYI,KAGlD"}
@@ -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.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 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};
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\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: 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","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","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,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,EACPL,EAAUM,QACVZ,EAAMa,WACN,EAEFC,SAAWd,UACVM,EAAUS,YAAiBC,OAAAC,OAAAD,OAAAC,OAAA,CAAA,EAAAjB,IAAOtB,aAAYC,qBAC9B,QAAXuC,EAAAlB,EAAMZ,aAAK,IAAA8B,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 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"}
@@ -6,10 +6,16 @@ interface ExtensionConfig {
6
6
  maxCharacters?: number;
7
7
  hasSections?: boolean;
8
8
  mentions?: {
9
- agents?: MentionItem[];
10
- teams?: MentionItem[];
9
+ agents?: {
10
+ current: MentionItem[];
11
+ };
12
+ teams?: {
13
+ current: MentionItem[];
14
+ };
15
+ };
16
+ slashCommands?: {
17
+ current: SlashCommandItem[];
11
18
  };
12
- slashCommands?: SlashCommandItem[];
13
19
  onPaste?: (data: PasteData) => boolean | void;
14
20
  onSend?: (content: EditorSnapshot) => void;
15
21
  sendShortcut?: {
@@ -1,4 +1,8 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import type { MentionDropdownRenderProps, MentionItem } from '../../BikEditor.types';
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>;
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>;
@@ -1,4 +1,6 @@
1
1
  import { Extension } from '@tiptap/core';
2
2
  import type { ReactNode } from 'react';
3
3
  import type { SlashCommandDropdownRenderProps, SlashCommandItem } from '../../BikEditor.types';
4
- export declare function buildSlashCommandExtension(commands: SlashCommandItem[], onSelect?: (command: SlashCommandItem) => void, renderItem?: (item: SlashCommandItem, isActive: boolean) => ReactNode, renderDropdown?: (props: SlashCommandDropdownRenderProps) => ReactNode): Extension<any, any>;
4
+ export declare function buildSlashCommandExtension(commandsRef: {
5
+ current: SlashCommandItem[];
6
+ }, onSelect?: (command: SlashCommandItem) => void, renderItem?: (item: SlashCommandItem, isActive: boolean) => ReactNode, renderDropdown?: (props: SlashCommandDropdownRenderProps) => ReactNode): Extension<any, any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.804-beta.14",
3
+ "version": "0.0.804-beta.16",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",