@bikdotai/bik-component-library 0.0.787-beta.2 → 0.0.787-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),n=require("../node_modules/@tiptap/core/dist/index.js"),t=require("@tiptap/react"),o=require("react"),i=require("./BikEditor.styles.js"),r=require("./BikEditor.utils.js"),l=require("./extensions/buildExtensions.js"),s=require("./floating/LinkBubbleMenu.js");function d(e){return Object.entries(e).map((e=>{let[n,t]=e;return`${n.replace(/([A-Z])/g,(e=>`-${e.toLowerCase()}`))}:${t}`})).join(";")}const u=(u,c)=>{var a;const{initialContent:m,sections:g,features:v,disabled:h,maxCharacters:f,shortcuts:C,sendShortcut:S,mentions:k,slashCommands:x,link:p,onPaste:B,onChange:b,onSend:y,onFocus:A,onBlur:E,onSelectionChange:j,minHeight:L,maxHeight:F,style:I,className:M,editorClassName:q,editorStyle:H}=u,P=(null==g?void 0:g.length)?r.buildSectionedContent(null!=m?m:"",g):null!=m?m:"",w=t.useEditor({extensions:l.buildExtensions({features:v,placeholder:u.placeholder,maxCharacters:f,hasSections:(null!==(a=null==g?void 0:g.length)&&void 0!==a?a:0)>0,mentions:{agents:null==k?void 0:k.agents,teams:null==k?void 0:k.teams},slashCommands:null==x?void 0:x.items,onPaste:B,onSend:y,sendShortcut:S,shortcuts:C,onMentionSelected:null==k?void 0:k.onSelect,onSlashCommandSelected:null==x?void 0:x.onSelect,renderMentionItem:null==k?void 0:k.renderItem,renderMentionDropdown:null==k?void 0:k.renderDropdown,renderSlashCommandItem:null==x?void 0:x.renderItem,renderSlashCommandDropdown:null==x?void 0:x.renderDropdown}),content:P,editable:!h,immediatelyRender:!1,editorProps:{attributes:Object.assign(Object.assign({},q?{class:q}:{}),H?{style:d(H)}:{})},onUpdate:e=>{let{editor:n}=e;return null==b?void 0:b(r.extractContent(n))},onSelectionUpdate:e=>{let{editor:n}=e;return null==j?void 0:j(r.extractActiveFormats(n))},onFocus:()=>null==A?void 0:A(),onBlur:()=>null==E?void 0:E()});return o.useImperativeHandle(c,(()=>({focus:()=>null==w?void 0:w.commands.focus(),blur:()=>null==w?void 0:w.commands.blur(),clearContent:()=>null==w?void 0:w.commands.clearContent(!0),setContent:e=>null==w?void 0:w.commands.setContent(e,{emitUpdate:!0}),insertContent:e=>null==w?void 0:w.commands.insertContent(e),insertAtStart:e=>{w&&w.commands.insertContentAt(1,e)},insertAtEnd:e=>{w&&w.commands.insertContentAt(w.state.doc.content.size,e)},appendContent:e=>{w&&w.commands.insertContentAt(w.state.doc.content.size,e)},getContent:()=>r.extractContent(w),getCursorPosition:()=>{const{from:e,to:n}=w.state.selection;return{from:e,to:n}},insertAtPosition:(e,n)=>{w&&w.commands.insertContentAt(e,n)},getSelectedText:()=>{const{state:e}=w,{from:t,to:o,empty:i}=e.selection;if(!i)return e.doc.textBetween(t,o," ");const r=e.schema.marks.link;if(r){const o=n.getMarkRange(e.doc.resolve(t),r);if(o)return e.doc.textBetween(o.from,o.to," ")}return""},getCharacterCount:()=>{var e,n,t,o;return{count:null!==(o=null!==(t=null===(n=null===(e=null==w?void 0:w.storage.characterCount)||void 0===e?void 0:e.characters)||void 0===n?void 0:n.call(e))&&void 0!==t?t:null==w?void 0:w.getText().length)&&void 0!==o?o:0,limit:null!=f?f:null}},getSectionContent:e=>r.extractSectionContent(w,e),setSectionContent:(e,n)=>{w&&r.setSectionContentInEditor(w,e,n)},focusSection:e=>{if(!w)return;if("body"===e)return void w.chain().focus().setTextSelection(1).run();let n=-1;w.state.doc.descendants(((t,o)=>{if(-1!==n)return!1;"sectionDivider"===t.type.name&&t.attrs.sectionId===e&&(n=o+t.nodeSize+1)})),-1!==n&&w.chain().focus().setTextSelection(n).run()},clearSection:e=>{w&&r.setSectionContentInEditor(w,e,"<p></p>")},getBodyContent:()=>r.extractBodyContent(w),setBodyContent:e=>{w&&r.setSectionContentInEditor(w,"body",e)},appendBodyContent:e=>{if(!w)return;const n=r.findSectionEndPos(w,"body");w.commands.insertContentAt(n,e)},insertAtSectionStart:(e,n)=>{if(!w)return;const t=r.findSectionStartPos(w,e);-1!==t&&w.commands.insertContentAt(t,n)},insertAtSectionEnd:(e,n)=>{if(!w)return;const t=r.findSectionEndPos(w,e);w.commands.insertContentAt(t,n)},getActiveFormats:()=>r.extractActiveFormats(w),actions:{toggleBold:()=>null==w?void 0:w.chain().focus().toggleBold().run(),toggleItalic:()=>null==w?void 0:w.chain().focus().toggleItalic().run(),toggleUnderline:()=>null==w?void 0:w.chain().focus().toggleUnderline().run(),toggleStrike:()=>null==w?void 0:w.chain().focus().toggleStrike().run(),toggleBulletList:()=>null==w?void 0:w.chain().focus().toggleBulletList().run(),toggleOrderedList:()=>null==w?void 0:w.chain().focus().toggleOrderedList().run(),toggleBlockquote:()=>null==w?void 0:w.chain().focus().toggleBlockquote().run(),toggleCodeBlock:()=>null==w?void 0:w.chain().focus().toggleCodeBlock().run(),setTextAlign:e=>null==w?void 0:w.chain().focus().setTextAlign(e).run(),setFontFamily:e=>null==w?void 0:w.chain().focus().setFontFamily(e).run(),setFontSize:e=>null==w?void 0:w.chain().focus().setFontSize(e).run(),setColor:e=>null==w?void 0:w.chain().focus().setColor(e).run(),setHighlight:e=>null==w?void 0:w.chain().focus().toggleHighlight({color:e}).run(),unsetColor:()=>null==w?void 0:w.chain().focus().unsetColor().run(),unsetHighlight:()=>null==w?void 0:w.chain().focus().unsetHighlight().run(),setLink:(e,n)=>{w&&(void 0!==n?w.chain().focus().extendMarkRange("link").command((t=>{let{tr:o,state:i}=t;const{from:r,to:l}=o.selection,s=i.schema.marks.link;return!!s&&(o.replaceWith(r,l,i.schema.text(n,[s.create({href:e})])),!0)})).run():w.chain().focus().extendMarkRange("link").setLink({href:e}).run())},updateLink:e=>null==w?void 0:w.chain().focus().extendMarkRange("link").setLink({href:e}).run(),removeLink:()=>null==w?void 0:w.chain().focus().extendMarkRange("link").unsetLink().run(),insertEmoji:e=>null==w?void 0:w.chain().focus().insertContent(e).run(),insertVariable:e=>null==w?void 0:w.chain().focus().insertContent(`{{${e}}}`).run(),insertHtml:e=>null==w?void 0:w.commands.insertContent(e),undo:()=>null==w?void 0:w.chain().focus().undo().run(),redo:()=>null==w?void 0:w.chain().focus().redo().run(),canUndo:()=>{var e;return null!==(e=null==w?void 0:w.can().undo())&&void 0!==e&&e},canRedo:()=>{var e;return null!==(e=null==w?void 0:w.can().redo())&&void 0!==e&&e}}})),[w]),w?e.jsxs(i.BikEditorShell,Object.assign({minHeight:L,maxHeight:F,style:I,className:M},{children:[e.jsx(t.EditorContent,{editor:w}),e.jsx(s.LinkBubbleMenu,{editor:w,renderLinkTooltip:null==p?void 0:p.renderTooltip})]})):null},c=o.forwardRef(u);c.displayName="BikEditor",exports.BikEditor=c;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),n=require("../node_modules/@tiptap/core/dist/index.js"),t=require("@tiptap/react"),o=require("react"),i=require("./BikEditor.styles.js"),r=require("./BikEditor.utils.js"),l=require("./extensions/buildExtensions.js"),s=require("./floating/LinkBubbleMenu.js");function d(e){return Object.entries(e).map((e=>{let[n,t]=e;return`${n.replace(/([A-Z])/g,(e=>`-${e.toLowerCase()}`))}:${t}`})).join(";")}const u=(u,c)=>{var a;const{initialContent:m,sections:g,features:v,disabled:h,maxCharacters:f,shortcuts:C,sendShortcut:S,mentions:k,slashCommands:x,link:p,onPaste:B,onChange:b,onSend:y,onFocus:A,onBlur:E,onSelectionChange:j,minHeight:L,maxHeight:F,style:I,className:M,editorClassName:q,editorStyle:H}=u,P=(null==g?void 0:g.length)?r.buildSectionedContent(null!=m?m:"",g):null!=m?m:"",w=t.useEditor({extensions:l.buildExtensions({features:v,placeholder:u.placeholder,maxCharacters:f,hasSections:(null!==(a=null==g?void 0:g.length)&&void 0!==a?a:0)>0,mentions:{agents:null==k?void 0:k.agents,teams:null==k?void 0:k.teams},slashCommands:null==x?void 0:x.items,onPaste:B,onSend:y,sendShortcut:S,shortcuts:C,onMentionSelected:null==k?void 0:k.onSelect,onSlashCommandSelected:null==x?void 0:x.onSelect,renderMentionItem:null==k?void 0:k.renderItem,renderMentionDropdown:null==k?void 0:k.renderDropdown,renderSlashCommandItem:null==x?void 0:x.renderItem,renderSlashCommandDropdown:null==x?void 0:x.renderDropdown}),content:P,editable:!h,immediatelyRender:!1,editorProps:{attributes:Object.assign(Object.assign({},q?{class:q}:{}),H?{style:d(H)}:{})},onUpdate:e=>{let{editor:n}=e;return null==b?void 0:b(r.extractContent(n))},onSelectionUpdate:e=>{let{editor:n}=e;return null==j?void 0:j(r.extractActiveFormats(n))},onFocus:()=>null==A?void 0:A(),onBlur:()=>null==E?void 0:E()});return o.useImperativeHandle(c,(()=>({focus:()=>null==w?void 0:w.commands.focus(),blur:()=>null==w?void 0:w.commands.blur(),clearContent:()=>null==w?void 0:w.commands.clearContent(!0),setContent:e=>null==w?void 0:w.commands.setContent(e,{emitUpdate:!0}),insertContent:e=>null==w?void 0:w.commands.insertContent(e),insertAtStart:e=>{w&&w.commands.insertContentAt(1,e)},insertAtEnd:e=>{w&&w.commands.insertContentAt(w.state.doc.content.size,e)},appendContent:e=>{w&&w.commands.insertContentAt(w.state.doc.content.size-1,e)},getContent:()=>r.extractContent(w),getCursorPosition:()=>{const{from:e,to:n}=w.state.selection;return{from:e,to:n}},insertAtPosition:(e,n)=>{w&&w.commands.insertContentAt(e,n)},getSelectedText:()=>{const{state:e}=w,{from:t,to:o,empty:i}=e.selection;if(!i)return e.doc.textBetween(t,o," ");const r=e.schema.marks.link;if(r){const o=n.getMarkRange(e.doc.resolve(t),r);if(o)return e.doc.textBetween(o.from,o.to," ")}return""},getCharacterCount:()=>{var e,n,t,o;return{count:null!==(o=null!==(t=null===(n=null===(e=null==w?void 0:w.storage.characterCount)||void 0===e?void 0:e.characters)||void 0===n?void 0:n.call(e))&&void 0!==t?t:null==w?void 0:w.getText().length)&&void 0!==o?o:0,limit:null!=f?f:null}},getSectionContent:e=>r.extractSectionContent(w,e),setSectionContent:(e,n)=>{w&&r.setSectionContentInEditor(w,e,n)},focusSection:e=>{if(!w)return;if("body"===e)return void w.chain().focus().setTextSelection(1).run();let n=-1;w.state.doc.descendants(((t,o)=>{if(-1!==n)return!1;"sectionDivider"===t.type.name&&t.attrs.sectionId===e&&(n=o+t.nodeSize+1)})),-1!==n&&w.chain().focus().setTextSelection(n).run()},clearSection:e=>{w&&r.setSectionContentInEditor(w,e,"<p></p>")},getBodyContent:()=>r.extractBodyContent(w),setBodyContent:e=>{w&&r.setSectionContentInEditor(w,"body",e)},appendBodyContent:e=>{if(!w)return;const n=r.findSectionEndPos(w,"body");w.commands.insertContentAt(n-1,e)},insertAtSectionStart:(e,n)=>{if(!w)return;const t=r.findSectionStartPos(w,e);-1!==t&&w.commands.insertContentAt(t,n)},insertAtSectionEnd:(e,n)=>{if(!w)return;const t=r.findSectionEndPos(w,e);w.commands.insertContentAt(t,n)},getActiveFormats:()=>r.extractActiveFormats(w),actions:{toggleBold:()=>null==w?void 0:w.chain().focus().toggleBold().run(),toggleItalic:()=>null==w?void 0:w.chain().focus().toggleItalic().run(),toggleUnderline:()=>null==w?void 0:w.chain().focus().toggleUnderline().run(),toggleStrike:()=>null==w?void 0:w.chain().focus().toggleStrike().run(),toggleBulletList:()=>null==w?void 0:w.chain().focus().toggleBulletList().run(),toggleOrderedList:()=>null==w?void 0:w.chain().focus().toggleOrderedList().run(),toggleBlockquote:()=>null==w?void 0:w.chain().focus().toggleBlockquote().run(),toggleCodeBlock:()=>null==w?void 0:w.chain().focus().toggleCodeBlock().run(),setTextAlign:e=>null==w?void 0:w.chain().focus().setTextAlign(e).run(),setFontFamily:e=>null==w?void 0:w.chain().focus().setFontFamily(e).run(),setFontSize:e=>null==w?void 0:w.chain().focus().setFontSize(e).run(),setColor:e=>null==w?void 0:w.chain().focus().setColor(e).run(),setHighlight:e=>null==w?void 0:w.chain().focus().toggleHighlight({color:e}).run(),unsetColor:()=>null==w?void 0:w.chain().focus().unsetColor().run(),unsetHighlight:()=>null==w?void 0:w.chain().focus().unsetHighlight().run(),setLink:(e,n)=>{w&&(void 0!==n?w.chain().focus().extendMarkRange("link").command((t=>{let{tr:o,state:i}=t;const{from:r,to:l}=o.selection,s=i.schema.marks.link;return!!s&&(o.replaceWith(r,l,i.schema.text(n,[s.create({href:e})])),!0)})).run():w.chain().focus().extendMarkRange("link").setLink({href:e}).run())},updateLink:e=>null==w?void 0:w.chain().focus().extendMarkRange("link").setLink({href:e}).run(),removeLink:()=>null==w?void 0:w.chain().focus().extendMarkRange("link").unsetLink().run(),insertEmoji:e=>null==w?void 0:w.chain().focus().insertContent(e).run(),insertVariable:e=>null==w?void 0:w.chain().focus().insertContent(`{{${e}}}`).run(),insertHtml:e=>null==w?void 0:w.commands.insertContent(e),undo:()=>null==w?void 0:w.chain().focus().undo().run(),redo:()=>null==w?void 0:w.chain().focus().redo().run(),canUndo:()=>{var e;return null!==(e=null==w?void 0:w.can().undo())&&void 0!==e&&e},canRedo:()=>{var e;return null!==(e=null==w?void 0:w.can().redo())&&void 0!==e&&e}}})),[w]),w?e.jsxs(i.BikEditorShell,Object.assign({minHeight:L,maxHeight:F,style:I,className:M},{children:[e.jsx(t.EditorContent,{editor:w}),e.jsx(s.LinkBubbleMenu,{editor:w,renderLinkTooltip:null==p?void 0:p.renderTooltip})]})):null},c=o.forwardRef(u);c.displayName="BikEditor",exports.BikEditor=c;
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export declare const Menus: ({
2
3
  displayName: string;
3
4
  key: number;
@@ -1 +1 @@
1
- import{jsxs as n,jsx as t}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 l,useImperativeHandle as r}from"react";import{BikEditorShell as s}from"./BikEditor.styles.js";import{buildSectionedContent as d,extractContent as u,extractActiveFormats as c,extractSectionContent as a,setSectionContentInEditor as m,extractBodyContent as g,findSectionEndPos as h,findSectionStartPos as v}from"./BikEditor.utils.js";import{buildExtensions as f}from"./extensions/buildExtensions.js";import{LinkBubbleMenu as C}from"./floating/LinkBubbleMenu.js";function p(n){return Object.entries(n).map((n=>{let[t,e]=n;return`${t.replace(/([A-Z])/g,(n=>`-${n.toLowerCase()}`))}:${e}`})).join(";")}const S=l(((l,S)=>{var k;const{initialContent:x,sections:B,features:y,disabled:b,maxCharacters:A,shortcuts:L,sendShortcut:j,mentions:F,slashCommands:H,link:M,onPaste:T,onChange:w,onSend:E,onFocus:I,onBlur:O,onSelectionChange:R,minHeight:U,maxHeight:z,style:D,className:P,editorClassName:N,editorStyle:$}=l,q=(null==B?void 0:B.length)?d(null!=x?x:"",B):null!=x?x:"",V=o({extensions:f({features:y,placeholder:l.placeholder,maxCharacters:A,hasSections:(null!==(k=null==B?void 0:B.length)&&void 0!==k?k: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:T,onSend:E,sendShortcut:j,shortcuts:L,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:q,editable:!b,immediatelyRender:!1,editorProps:{attributes:Object.assign(Object.assign({},N?{class:N}:{}),$?{style:p($)}:{})},onUpdate:n=>{let{editor:t}=n;return null==w?void 0:w(u(t))},onSelectionUpdate:n=>{let{editor:t}=n;return null==R?void 0:R(c(t))},onFocus:()=>null==I?void 0:I(),onBlur:()=>null==O?void 0:O()});return r(S,(()=>({focus:()=>null==V?void 0:V.commands.focus(),blur:()=>null==V?void 0:V.commands.blur(),clearContent:()=>null==V?void 0:V.commands.clearContent(!0),setContent:n=>null==V?void 0:V.commands.setContent(n,{emitUpdate:!0}),insertContent:n=>null==V?void 0:V.commands.insertContent(n),insertAtStart:n=>{V&&V.commands.insertContentAt(1,n)},insertAtEnd:n=>{V&&V.commands.insertContentAt(V.state.doc.content.size,n)},appendContent:n=>{V&&V.commands.insertContentAt(V.state.doc.content.size,n)},getContent:()=>u(V),getCursorPosition:()=>{const{from:n,to:t}=V.state.selection;return{from:n,to:t}},insertAtPosition:(n,t)=>{V&&V.commands.insertContentAt(n,t)},getSelectedText:()=>{const{state:n}=V,{from:t,to:o,empty:i}=n.selection;if(!i)return n.doc.textBetween(t,o," ");const l=n.schema.marks.link;if(l){const o=e(n.doc.resolve(t),l);if(o)return n.doc.textBetween(o.from,o.to," ")}return""},getCharacterCount:()=>{var n,t,e,o;return{count:null!==(o=null!==(e=null===(t=null===(n=null==V?void 0:V.storage.characterCount)||void 0===n?void 0:n.characters)||void 0===t?void 0:t.call(n))&&void 0!==e?e:null==V?void 0:V.getText().length)&&void 0!==o?o:0,limit:null!=A?A:null}},getSectionContent:n=>a(V,n),setSectionContent:(n,t)=>{V&&m(V,n,t)},focusSection:n=>{if(!V)return;if("body"===n)return void V.chain().focus().setTextSelection(1).run();let t=-1;V.state.doc.descendants(((e,o)=>{if(-1!==t)return!1;"sectionDivider"===e.type.name&&e.attrs.sectionId===n&&(t=o+e.nodeSize+1)})),-1!==t&&V.chain().focus().setTextSelection(t).run()},clearSection:n=>{V&&m(V,n,"<p></p>")},getBodyContent:()=>g(V),setBodyContent:n=>{V&&m(V,"body",n)},appendBodyContent:n=>{if(!V)return;const t=h(V,"body");V.commands.insertContentAt(t,n)},insertAtSectionStart:(n,t)=>{if(!V)return;const e=v(V,n);-1!==e&&V.commands.insertContentAt(e,t)},insertAtSectionEnd:(n,t)=>{if(!V)return;const e=h(V,n);V.commands.insertContentAt(e,t)},getActiveFormats:()=>c(V),actions:{toggleBold:()=>null==V?void 0:V.chain().focus().toggleBold().run(),toggleItalic:()=>null==V?void 0:V.chain().focus().toggleItalic().run(),toggleUnderline:()=>null==V?void 0:V.chain().focus().toggleUnderline().run(),toggleStrike:()=>null==V?void 0:V.chain().focus().toggleStrike().run(),toggleBulletList:()=>null==V?void 0:V.chain().focus().toggleBulletList().run(),toggleOrderedList:()=>null==V?void 0:V.chain().focus().toggleOrderedList().run(),toggleBlockquote:()=>null==V?void 0:V.chain().focus().toggleBlockquote().run(),toggleCodeBlock:()=>null==V?void 0:V.chain().focus().toggleCodeBlock().run(),setTextAlign:n=>null==V?void 0:V.chain().focus().setTextAlign(n).run(),setFontFamily:n=>null==V?void 0:V.chain().focus().setFontFamily(n).run(),setFontSize:n=>null==V?void 0:V.chain().focus().setFontSize(n).run(),setColor:n=>null==V?void 0:V.chain().focus().setColor(n).run(),setHighlight:n=>null==V?void 0:V.chain().focus().toggleHighlight({color:n}).run(),unsetColor:()=>null==V?void 0:V.chain().focus().unsetColor().run(),unsetHighlight:()=>null==V?void 0:V.chain().focus().unsetHighlight().run(),setLink:(n,t)=>{V&&(void 0!==t?V.chain().focus().extendMarkRange("link").command((e=>{let{tr:o,state:i}=e;const{from:l,to:r}=o.selection,s=i.schema.marks.link;return!!s&&(o.replaceWith(l,r,i.schema.text(t,[s.create({href:n})])),!0)})).run():V.chain().focus().extendMarkRange("link").setLink({href:n}).run())},updateLink:n=>null==V?void 0:V.chain().focus().extendMarkRange("link").setLink({href:n}).run(),removeLink:()=>null==V?void 0:V.chain().focus().extendMarkRange("link").unsetLink().run(),insertEmoji:n=>null==V?void 0:V.chain().focus().insertContent(n).run(),insertVariable:n=>null==V?void 0:V.chain().focus().insertContent(`{{${n}}}`).run(),insertHtml:n=>null==V?void 0:V.commands.insertContent(n),undo:()=>null==V?void 0:V.chain().focus().undo().run(),redo:()=>null==V?void 0:V.chain().focus().redo().run(),canUndo:()=>{var n;return null!==(n=null==V?void 0:V.can().undo())&&void 0!==n&&n},canRedo:()=>{var n;return null!==(n=null==V?void 0:V.can().redo())&&void 0!==n&&n}}})),[V]),V?n(s,Object.assign({minHeight:U,maxHeight:z,style:D,className:P},{children:[t(i,{editor:V}),t(C,{editor:V,renderLinkTooltip:null==M?void 0:M.renderTooltip})]})):null}));S.displayName="BikEditor";export{S as BikEditor};
1
+ import{jsxs as n,jsx as t}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 l,useImperativeHandle as r}from"react";import{BikEditorShell as s}from"./BikEditor.styles.js";import{buildSectionedContent as d,extractContent as u,extractActiveFormats as c,extractSectionContent as a,setSectionContentInEditor as m,extractBodyContent as g,findSectionEndPos as h,findSectionStartPos as v}from"./BikEditor.utils.js";import{buildExtensions as f}from"./extensions/buildExtensions.js";import{LinkBubbleMenu as C}from"./floating/LinkBubbleMenu.js";function p(n){return Object.entries(n).map((n=>{let[t,e]=n;return`${t.replace(/([A-Z])/g,(n=>`-${n.toLowerCase()}`))}:${e}`})).join(";")}const S=l(((l,S)=>{var k;const{initialContent:x,sections:B,features:y,disabled:b,maxCharacters:A,shortcuts:L,sendShortcut:j,mentions:F,slashCommands:H,link:M,onPaste:T,onChange:w,onSend:E,onFocus:I,onBlur:O,onSelectionChange:R,minHeight:U,maxHeight:z,style:D,className:P,editorClassName:N,editorStyle:$}=l,q=(null==B?void 0:B.length)?d(null!=x?x:"",B):null!=x?x:"",V=o({extensions:f({features:y,placeholder:l.placeholder,maxCharacters:A,hasSections:(null!==(k=null==B?void 0:B.length)&&void 0!==k?k: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:T,onSend:E,sendShortcut:j,shortcuts:L,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:q,editable:!b,immediatelyRender:!1,editorProps:{attributes:Object.assign(Object.assign({},N?{class:N}:{}),$?{style:p($)}:{})},onUpdate:n=>{let{editor:t}=n;return null==w?void 0:w(u(t))},onSelectionUpdate:n=>{let{editor:t}=n;return null==R?void 0:R(c(t))},onFocus:()=>null==I?void 0:I(),onBlur:()=>null==O?void 0:O()});return r(S,(()=>({focus:()=>null==V?void 0:V.commands.focus(),blur:()=>null==V?void 0:V.commands.blur(),clearContent:()=>null==V?void 0:V.commands.clearContent(!0),setContent:n=>null==V?void 0:V.commands.setContent(n,{emitUpdate:!0}),insertContent:n=>null==V?void 0:V.commands.insertContent(n),insertAtStart:n=>{V&&V.commands.insertContentAt(1,n)},insertAtEnd:n=>{V&&V.commands.insertContentAt(V.state.doc.content.size,n)},appendContent:n=>{V&&V.commands.insertContentAt(V.state.doc.content.size-1,n)},getContent:()=>u(V),getCursorPosition:()=>{const{from:n,to:t}=V.state.selection;return{from:n,to:t}},insertAtPosition:(n,t)=>{V&&V.commands.insertContentAt(n,t)},getSelectedText:()=>{const{state:n}=V,{from:t,to:o,empty:i}=n.selection;if(!i)return n.doc.textBetween(t,o," ");const l=n.schema.marks.link;if(l){const o=e(n.doc.resolve(t),l);if(o)return n.doc.textBetween(o.from,o.to," ")}return""},getCharacterCount:()=>{var n,t,e,o;return{count:null!==(o=null!==(e=null===(t=null===(n=null==V?void 0:V.storage.characterCount)||void 0===n?void 0:n.characters)||void 0===t?void 0:t.call(n))&&void 0!==e?e:null==V?void 0:V.getText().length)&&void 0!==o?o:0,limit:null!=A?A:null}},getSectionContent:n=>a(V,n),setSectionContent:(n,t)=>{V&&m(V,n,t)},focusSection:n=>{if(!V)return;if("body"===n)return void V.chain().focus().setTextSelection(1).run();let t=-1;V.state.doc.descendants(((e,o)=>{if(-1!==t)return!1;"sectionDivider"===e.type.name&&e.attrs.sectionId===n&&(t=o+e.nodeSize+1)})),-1!==t&&V.chain().focus().setTextSelection(t).run()},clearSection:n=>{V&&m(V,n,"<p></p>")},getBodyContent:()=>g(V),setBodyContent:n=>{V&&m(V,"body",n)},appendBodyContent:n=>{if(!V)return;const t=h(V,"body");V.commands.insertContentAt(t-1,n)},insertAtSectionStart:(n,t)=>{if(!V)return;const e=v(V,n);-1!==e&&V.commands.insertContentAt(e,t)},insertAtSectionEnd:(n,t)=>{if(!V)return;const e=h(V,n);V.commands.insertContentAt(e,t)},getActiveFormats:()=>c(V),actions:{toggleBold:()=>null==V?void 0:V.chain().focus().toggleBold().run(),toggleItalic:()=>null==V?void 0:V.chain().focus().toggleItalic().run(),toggleUnderline:()=>null==V?void 0:V.chain().focus().toggleUnderline().run(),toggleStrike:()=>null==V?void 0:V.chain().focus().toggleStrike().run(),toggleBulletList:()=>null==V?void 0:V.chain().focus().toggleBulletList().run(),toggleOrderedList:()=>null==V?void 0:V.chain().focus().toggleOrderedList().run(),toggleBlockquote:()=>null==V?void 0:V.chain().focus().toggleBlockquote().run(),toggleCodeBlock:()=>null==V?void 0:V.chain().focus().toggleCodeBlock().run(),setTextAlign:n=>null==V?void 0:V.chain().focus().setTextAlign(n).run(),setFontFamily:n=>null==V?void 0:V.chain().focus().setFontFamily(n).run(),setFontSize:n=>null==V?void 0:V.chain().focus().setFontSize(n).run(),setColor:n=>null==V?void 0:V.chain().focus().setColor(n).run(),setHighlight:n=>null==V?void 0:V.chain().focus().toggleHighlight({color:n}).run(),unsetColor:()=>null==V?void 0:V.chain().focus().unsetColor().run(),unsetHighlight:()=>null==V?void 0:V.chain().focus().unsetHighlight().run(),setLink:(n,t)=>{V&&(void 0!==t?V.chain().focus().extendMarkRange("link").command((e=>{let{tr:o,state:i}=e;const{from:l,to:r}=o.selection,s=i.schema.marks.link;return!!s&&(o.replaceWith(l,r,i.schema.text(t,[s.create({href:n})])),!0)})).run():V.chain().focus().extendMarkRange("link").setLink({href:n}).run())},updateLink:n=>null==V?void 0:V.chain().focus().extendMarkRange("link").setLink({href:n}).run(),removeLink:()=>null==V?void 0:V.chain().focus().extendMarkRange("link").unsetLink().run(),insertEmoji:n=>null==V?void 0:V.chain().focus().insertContent(n).run(),insertVariable:n=>null==V?void 0:V.chain().focus().insertContent(`{{${n}}}`).run(),insertHtml:n=>null==V?void 0:V.commands.insertContent(n),undo:()=>null==V?void 0:V.chain().focus().undo().run(),redo:()=>null==V?void 0:V.chain().focus().redo().run(),canUndo:()=>{var n;return null!==(n=null==V?void 0:V.can().undo())&&void 0!==n&&n},canRedo:()=>{var n;return null!==(n=null==V?void 0:V.can().redo())&&void 0!==n&&n}}})),[V]),V?n(s,Object.assign({minHeight:U,maxHeight:z,style:D,className:P},{children:[t(i,{editor:V}),t(C,{editor:V,renderLinkTooltip:null==M?void 0:M.renderTooltip})]})):null}));S.displayName="BikEditor";export{S as BikEditor};
@@ -1,3 +1,4 @@
1
+ /// <reference types="react" />
1
2
  export declare const Menus: ({
2
3
  displayName: string;
3
4
  key: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.787-beta.2",
3
+ "version": "0.0.787-beta.4",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",