@bikdotai/bik-component-library 0.0.788-beta.7 → 0.0.788-beta.9

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 n=require("react/jsx-runtime"),e=require("../node_modules/@tiptap/core/dist/index.js"),t=require("@tiptap/react"),o=require("react"),i=require("./BikEditor.styles.js"),l=require("./BikEditor.utils.js"),r=require("./extensions/buildExtensions.js"),s=require("./floating/LinkBubbleMenu.js");function d(n){return Object.entries(n).map((n=>{let[e,t]=n;return`${e.replace(/([A-Z])/g,(n=>`-${n.toLowerCase()}`))}:${t}`})).join(";")}const a=(a,c)=>{var u;const{initialContent:m,sections:g,features:v,disabled:h,maxCharacters:f,shortcuts:C,sendShortcut:S,mentions:p,slashCommands:k,link:x,onPaste:H,onChange:b,onSend:B,onFocus:y,onBlur:z,onSelectionChange:A,minHeight:j,maxHeight:E,style:L,className:F,editorClassName:I,editorStyle:M}=a,q=(null==g?void 0:g.length)?l.buildSectionedContent(l.normalizeHtml(null!=m?m:""),g.map((n=>Object.assign(Object.assign({},n),{content:l.normalizeHtml(n.content)})))):l.normalizeHtml(null!=m?m:""),O=t.useEditor({extensions:r.buildExtensions({features:v,placeholder:a.placeholder,maxCharacters:f,hasSections:(null!==(u=null==g?void 0:g.length)&&void 0!==u?u:0)>0,mentions:{agents:null==p?void 0:p.agents,teams:null==p?void 0:p.teams},slashCommands:null==k?void 0:k.items,onPaste:H,onSend:B,sendShortcut:S,shortcuts:C,onMentionSelected:null==p?void 0:p.onSelect,onSlashCommandSelected:null==k?void 0:k.onSelect,renderMentionItem:null==p?void 0:p.renderItem,renderMentionDropdown:null==p?void 0:p.renderDropdown,renderSlashCommandItem:null==k?void 0:k.renderItem,renderSlashCommandDropdown:null==k?void 0:k.renderDropdown}),content:q,editable:!h,immediatelyRender:!1,editorProps:{attributes:Object.assign(Object.assign({},I?{class:I}:{}),M?{style:d(M)}:{})},onUpdate:n=>{let{editor:e}=n;return null==b?void 0:b(l.extractContent(e))},onSelectionUpdate:n=>{let{editor:e}=n;return null==A?void 0:A(l.extractActiveFormats(e))},onFocus:()=>null==y?void 0:y(),onBlur:()=>null==z?void 0:z()});return o.useImperativeHandle(c,(()=>({focus:()=>null==O?void 0:O.commands.focus(),blur:()=>null==O?void 0:O.commands.blur(),clearContent:()=>null==O?void 0:O.commands.clearContent(!0),setContent:n=>null==O?void 0:O.commands.setContent(l.normalizeHtml(n),{emitUpdate:!0}),insertContent:n=>null==O?void 0:O.commands.insertContent(l.normalizeHtml(n)),insertAtStart:n=>{O&&O.commands.insertContentAt(1,l.normalizeHtml(n))},insertAtEnd:n=>{O&&O.commands.insertContentAt(O.state.doc.content.size,l.normalizeHtml(n))},appendContent:n=>{O&&O.commands.insertContentAt(O.state.doc.content.size-1,l.normalizeHtml(n))},getContent:()=>l.extractContent(O),getCursorPosition:()=>{const{from:n,to:e}=O.state.selection;return{from:n,to:e}},insertAtPosition:(n,e)=>{O&&O.commands.insertContentAt(n,e)},getSelectedText:()=>{const{state:n}=O,{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.getMarkRange(n.doc.resolve(t),l);if(o)return n.doc.textBetween(o.from,o.to," ")}return""},getCharacterCount:()=>{var n,e,t,o;return{count:null!==(o=null!==(t=null===(e=null===(n=null==O?void 0:O.storage.characterCount)||void 0===n?void 0:n.characters)||void 0===e?void 0:e.call(n))&&void 0!==t?t:null==O?void 0:O.getText().length)&&void 0!==o?o:0,limit:null!=f?f:null}},getSectionContent:n=>l.extractSectionContent(O,n),setSectionContent:(n,e)=>{O&&l.setSectionContentInEditor(O,n,l.normalizeHtml(e))},focusSection:n=>{if(!O)return;if("body"===n)return void O.chain().focus().setTextSelection(1).run();let e=-1;O.state.doc.descendants(((t,o)=>{if(-1!==e)return!1;"sectionDivider"===t.type.name&&t.attrs.sectionId===n&&(e=o+t.nodeSize+1)})),-1!==e&&O.chain().focus().setTextSelection(e).run()},clearSection:n=>{O&&l.setSectionContentInEditor(O,n,"<p></p>")},getBodyContent:()=>l.extractBodyContent(O),setBodyContent:n=>{O&&l.setSectionContentInEditor(O,"body",l.normalizeHtml(n))},setBodyAndSections:(n,e)=>{if(!O)return;const t=l.buildSectionedContent(l.normalizeHtml(n),e.map((n=>({id:n.id,content:l.normalizeHtml(n.content)}))));O.commands.setContent(t,{emitUpdate:!1})},appendBodyContent:n=>{if(!O)return;const e=l.normalizeHtml(n),t=l.findSectionEndPos(O,"body");O.commands.insertContentAt(t-1,e)},insertAtSectionStart:(n,e)=>{if(!O)return;const t=l.findSectionStartPos(O,n);-1!==t&&O.commands.insertContentAt(t,l.normalizeHtml(e))},insertAtSectionEnd:(n,e)=>{if(!O)return;const t=l.findSectionEndPos(O,n);O.commands.insertContentAt(t,l.normalizeHtml(e))},getActiveFormats:()=>l.extractActiveFormats(O),actions:{toggleBold:()=>null==O?void 0:O.chain().focus().toggleBold().run(),toggleItalic:()=>null==O?void 0:O.chain().focus().toggleItalic().run(),toggleUnderline:()=>null==O?void 0:O.chain().focus().toggleUnderline().run(),toggleStrike:()=>null==O?void 0:O.chain().focus().toggleStrike().run(),toggleBulletList:()=>null==O?void 0:O.chain().focus().toggleBulletList().run(),toggleOrderedList:()=>null==O?void 0:O.chain().focus().toggleOrderedList().run(),toggleBlockquote:()=>null==O?void 0:O.chain().focus().toggleBlockquote().run(),toggleCodeBlock:()=>null==O?void 0:O.chain().focus().toggleCodeBlock().run(),setTextAlign:n=>null==O?void 0:O.chain().focus().setTextAlign(n).run(),setFontFamily:n=>null==O?void 0:O.chain().focus().setFontFamily(n).run(),setFontSize:n=>null==O?void 0:O.chain().focus().setFontSize(n).run(),setColor:n=>null==O?void 0:O.chain().focus().setColor(n).run(),setHighlight:n=>null==O?void 0:O.chain().focus().toggleHighlight({color:n}).run(),unsetColor:()=>null==O?void 0:O.chain().focus().unsetColor().run(),unsetHighlight:()=>null==O?void 0:O.chain().focus().unsetHighlight().run(),setLink:(n,e)=>{O&&(void 0!==e?O.chain().focus().extendMarkRange("link").command((t=>{let{tr:o,state:i}=t;const{from:l,to:r}=o.selection,s=i.schema.marks.link;return!!s&&(o.replaceWith(l,r,i.schema.text(e,[s.create({href:n})])),!0)})).run():O.chain().focus().extendMarkRange("link").setLink({href:n}).run())},updateLink:n=>null==O?void 0:O.chain().focus().extendMarkRange("link").setLink({href:n}).run(),removeLink:()=>null==O?void 0:O.chain().focus().extendMarkRange("link").unsetLink().run(),insertEmoji:n=>null==O?void 0:O.chain().focus().insertContent(n).run(),insertVariable:n=>null==O?void 0:O.chain().focus().insertContent(`{{${n}}}`).run(),insertHtml:n=>null==O?void 0:O.commands.insertContent(n),undo:()=>null==O?void 0:O.chain().focus().undo().run(),redo:()=>null==O?void 0:O.chain().focus().redo().run(),canUndo:()=>{var n;return null!==(n=null==O?void 0:O.can().undo())&&void 0!==n&&n},canRedo:()=>{var n;return null!==(n=null==O?void 0:O.can().redo())&&void 0!==n&&n}}})),[O]),O?n.jsxs(i.BikEditorShell,Object.assign({minHeight:j,maxHeight:E,style:L,className:F},{children:[n.jsx(t.EditorContent,{editor:O}),n.jsx(s.LinkBubbleMenu,{editor:O,renderLinkTooltip:null==x?void 0:x.renderTooltip})]})):null},c=o.forwardRef(a);c.displayName="BikEditor",exports.BikEditor=c;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("react/jsx-runtime"),e=require("../node_modules/@tiptap/core/dist/index.js"),t=require("@tiptap/react"),o=require("react"),i=require("./BikEditor.styles.js"),l=require("./BikEditor.utils.js"),r=require("./extensions/buildExtensions.js"),s=require("./floating/LinkBubbleMenu.js");function d(n){return Object.entries(n).map((n=>{let[e,t]=n;return`${e.replace(/([A-Z])/g,(n=>`-${n.toLowerCase()}`))}:${t}`})).join(";")}const a=(a,c)=>{var u;const{initialContent:m,sections:g,features:v,disabled:h,maxCharacters:f,shortcuts:C,sendShortcut:S,mentions:p,slashCommands:k,link:x,onPaste:H,onChange:b,onSend:B,onFocus:y,onBlur:z,onSelectionChange:A,minHeight:j,maxHeight:E,style:L,className:F,editorClassName:I,editorStyle:M}=a,q=(null==g?void 0:g.length)?l.buildSectionedContent(l.normalizeHtml(null!=m?m:""),g.map((n=>Object.assign(Object.assign({},n),{content:l.normalizeHtml(n.content)})))):l.normalizeHtml(null!=m?m:""),O=t.useEditor({extensions:r.buildExtensions({features:v,placeholder:a.placeholder,maxCharacters:f,hasSections:(null!==(u=null==g?void 0:g.length)&&void 0!==u?u:0)>0,mentions:{agents:null==p?void 0:p.agents,teams:null==p?void 0:p.teams},slashCommands:null==k?void 0:k.items,onPaste:H,onSend:B,sendShortcut:S,shortcuts:C,onMentionSelected:null==p?void 0:p.onSelect,onSlashCommandSelected:null==k?void 0:k.onSelect,renderMentionItem:null==p?void 0:p.renderItem,renderMentionDropdown:null==p?void 0:p.renderDropdown,renderSlashCommandItem:null==k?void 0:k.renderItem,renderSlashCommandDropdown:null==k?void 0:k.renderDropdown}),content:q,editable:!h,immediatelyRender:!1,editorProps:{attributes:Object.assign(Object.assign({},I?{class:I}:{}),M?{style:d(M)}:{})},onUpdate:n=>{let{editor:e}=n;return null==b?void 0:b(l.extractContent(e))},onSelectionUpdate:n=>{let{editor:e}=n;return null==A?void 0:A(l.extractActiveFormats(e))},onFocus:()=>null==y?void 0:y(),onBlur:()=>null==z?void 0:z()});return o.useImperativeHandle(c,(()=>({focus:()=>null==O?void 0:O.commands.focus(),blur:()=>null==O?void 0:O.commands.blur(),clearContent:()=>null==O?void 0:O.commands.clearContent(!0),setContent:n=>null==O?void 0:O.commands.setContent(l.normalizeHtml(n),{emitUpdate:!0}),insertContent:n=>null==O?void 0:O.commands.insertContent(l.normalizeHtml(n)),insertAtStart:n=>{O&&O.commands.insertContentAt(1,l.normalizeHtml(n))},insertAtEnd:n=>{O&&O.commands.insertContentAt(O.state.doc.content.size,l.normalizeHtml(n))},appendContent:n=>{O&&O.commands.insertContentAt(O.state.doc.content.size-1,l.normalizeHtml(n))},getContent:()=>l.extractContent(O),getCursorPosition:()=>{const{from:n,to:e}=O.state.selection;return{from:n,to:e}},insertAtPosition:(n,e)=>{O&&O.commands.insertContentAt(n,e)},getSelectedText:()=>{const{state:n}=O,{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.getMarkRange(n.doc.resolve(t),l);if(o)return n.doc.textBetween(o.from,o.to," ")}return""},getCharacterCount:()=>{var n,e,t,o;return{count:null!==(o=null!==(t=null===(e=null===(n=null==O?void 0:O.storage.characterCount)||void 0===n?void 0:n.characters)||void 0===e?void 0:e.call(n))&&void 0!==t?t:null==O?void 0:O.getText().length)&&void 0!==o?o:0,limit:null!=f?f:null}},getSectionContent:n=>l.extractSectionContent(O,n),setSectionContent:(n,e)=>{O&&l.setSectionContentInEditor(O,n,l.normalizeHtml(e))},focusSection:n=>{if(!O)return;if("body"===n)return void O.chain().focus().setTextSelection(1).run();let e=-1;O.state.doc.descendants(((t,o)=>{if(-1!==e)return!1;"sectionDivider"===t.type.name&&t.attrs.sectionId===n&&(e=o+t.nodeSize+1)})),-1!==e&&O.chain().focus().setTextSelection(e).run()},clearSection:n=>{O&&l.setSectionContentInEditor(O,n,"<p></p>")},getBodyContent:()=>l.extractBodyContent(O),setBodyContent:n=>{O&&l.setSectionContentInEditor(O,"body",l.normalizeHtml(n))},setBodyAndSections:(n,e)=>{if(!O)return;const t=l.buildSectionedContent(l.normalizeHtml(n),e.map((n=>({id:n.id,content:l.normalizeHtml(n.content)}))));O.commands.setContent(t,{emitUpdate:!0})},appendBodyContent:n=>{if(!O)return;const e=l.normalizeHtml(n),t=l.findSectionEndPos(O,"body");O.commands.insertContentAt(t-1,e)},insertAtSectionStart:(n,e)=>{if(!O)return;const t=l.findSectionStartPos(O,n);-1!==t&&O.commands.insertContentAt(t,l.normalizeHtml(e))},insertAtSectionEnd:(n,e)=>{if(!O)return;const t=l.findSectionEndPos(O,n);O.commands.insertContentAt(t,l.normalizeHtml(e))},getActiveFormats:()=>l.extractActiveFormats(O),actions:{toggleBold:()=>null==O?void 0:O.chain().focus().toggleBold().run(),toggleItalic:()=>null==O?void 0:O.chain().focus().toggleItalic().run(),toggleUnderline:()=>null==O?void 0:O.chain().focus().toggleUnderline().run(),toggleStrike:()=>null==O?void 0:O.chain().focus().toggleStrike().run(),toggleBulletList:()=>null==O?void 0:O.chain().focus().toggleBulletList().run(),toggleOrderedList:()=>null==O?void 0:O.chain().focus().toggleOrderedList().run(),toggleBlockquote:()=>null==O?void 0:O.chain().focus().toggleBlockquote().run(),toggleCodeBlock:()=>null==O?void 0:O.chain().focus().toggleCodeBlock().run(),setTextAlign:n=>null==O?void 0:O.chain().focus().setTextAlign(n).run(),setFontFamily:n=>null==O?void 0:O.chain().focus().setFontFamily(n).run(),setFontSize:n=>null==O?void 0:O.chain().focus().setFontSize(n).run(),setColor:n=>null==O?void 0:O.chain().focus().setColor(n).run(),setHighlight:n=>null==O?void 0:O.chain().focus().toggleHighlight({color:n}).run(),unsetColor:()=>null==O?void 0:O.chain().focus().unsetColor().run(),unsetHighlight:()=>null==O?void 0:O.chain().focus().unsetHighlight().run(),setLink:(n,e)=>{O&&(void 0!==e?O.chain().focus().extendMarkRange("link").command((t=>{let{tr:o,state:i}=t;const{from:l,to:r}=o.selection,s=i.schema.marks.link;return!!s&&(o.replaceWith(l,r,i.schema.text(e,[s.create({href:n})])),!0)})).run():O.chain().focus().extendMarkRange("link").setLink({href:n}).run())},updateLink:n=>null==O?void 0:O.chain().focus().extendMarkRange("link").setLink({href:n}).run(),removeLink:()=>null==O?void 0:O.chain().focus().extendMarkRange("link").unsetLink().run(),insertEmoji:n=>null==O?void 0:O.chain().focus().insertContent(n).run(),insertVariable:n=>null==O?void 0:O.chain().focus().insertContent(`{{${n}}}`).run(),insertHtml:n=>null==O?void 0:O.commands.insertContent(n),undo:()=>null==O?void 0:O.chain().focus().undo().run(),redo:()=>null==O?void 0:O.chain().focus().redo().run(),canUndo:()=>{var n;return null!==(n=null==O?void 0:O.can().undo())&&void 0!==n&&n},canRedo:()=>{var n;return null!==(n=null==O?void 0:O.can().redo())&&void 0!==n&&n}}})),[O]),O?n.jsxs(i.BikEditorShell,Object.assign({minHeight:j,maxHeight:E,style:L,className:F},{children:[n.jsx(t.EditorContent,{editor:O}),n.jsx(s.LinkBubbleMenu,{editor:O,renderLinkTooltip:null==x?void 0:x.renderTooltip})]})):null},c=o.forwardRef(a);c.displayName="BikEditor",exports.BikEditor=c;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../node_modules/@tiptap/core/dist/index.js");const t=e.Node.create({name:"sectionDivider",group:"block",atom:!0,selectable:!1,draggable:!1,addAttributes:()=>({sectionId:{default:null}}),parseHTML:()=>[{tag:"div[data-section-divider]",getAttrs:e=>({sectionId:e.getAttribute("data-section-divider")})},{tag:"div[data-signature-divider]",getAttrs:()=>({sectionId:"signature"})},{tag:"div[data-forwarded-divider]",getAttrs:()=>({sectionId:"forwarded"})}],renderHTML(t){let{node:d,HTMLAttributes:i}=t;return["div",e.mergeAttributes(i,{"data-section-divider":d.attrs.sectionId,style:"display:none;height:0;line-height:0;overflow:hidden;"})]}});exports.SectionDividerNode=t;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../node_modules/@tiptap/core/dist/index.js");const t=e.Node.create({name:"sectionDivider",group:"block",atom:!0,selectable:!1,draggable:!1,addAttributes:()=>({sectionId:{default:null,rendered:!1}}),parseHTML:()=>[{tag:"div[data-section-divider]",getAttrs:e=>({sectionId:e.getAttribute("data-section-divider")})},{tag:"div[data-signature-divider]",getAttrs:()=>({sectionId:"signature"})},{tag:"div[data-forwarded-divider]",getAttrs:()=>({sectionId:"forwarded"})}],renderHTML(t){let{node:d,HTMLAttributes:i}=t;return["div",e.mergeAttributes(i,{"data-section-divider":d.attrs.sectionId,style:"display:none;height:0;line-height:0;overflow:hidden;"})]}});exports.SectionDividerNode=t;
@@ -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,normalizeHtml as c,extractContent as u,extractActiveFormats as a,extractSectionContent as m,setSectionContentInEditor as g,extractBodyContent as h,findSectionEndPos as v,findSectionStartPos as f}from"./BikEditor.utils.js";import{buildExtensions as C}from"./extensions/buildExtensions.js";import{LinkBubbleMenu as p}from"./floating/LinkBubbleMenu.js";function S(n){return Object.entries(n).map((n=>{let[t,e]=n;return`${t.replace(/([A-Z])/g,(n=>`-${n.toLowerCase()}`))}:${e}`})).join(";")}const k=l(((l,k)=>{var x;const{initialContent:B,sections:b,features:y,disabled:A,maxCharacters:j,shortcuts:L,sendShortcut:F,mentions:H,slashCommands:M,link:O,onPaste:T,onChange:w,onSend:E,onFocus:I,onBlur:U,onSelectionChange:R,minHeight:z,maxHeight:D,style:P,className:N,editorClassName:$,editorStyle:q}=l,V=(null==b?void 0:b.length)?d(c(null!=B?B:""),b.map((n=>Object.assign(Object.assign({},n),{content:c(n.content)})))):c(null!=B?B:""),W=o({extensions:C({features:y,placeholder:l.placeholder,maxCharacters:j,hasSections:(null!==(x=null==b?void 0:b.length)&&void 0!==x?x:0)>0,mentions:{agents:null==H?void 0:H.agents,teams:null==H?void 0:H.teams},slashCommands:null==M?void 0:M.items,onPaste:T,onSend:E,sendShortcut:F,shortcuts:L,onMentionSelected:null==H?void 0:H.onSelect,onSlashCommandSelected:null==M?void 0:M.onSelect,renderMentionItem:null==H?void 0:H.renderItem,renderMentionDropdown:null==H?void 0:H.renderDropdown,renderSlashCommandItem:null==M?void 0:M.renderItem,renderSlashCommandDropdown:null==M?void 0:M.renderDropdown}),content:V,editable:!A,immediatelyRender:!1,editorProps:{attributes:Object.assign(Object.assign({},$?{class:$}:{}),q?{style:S(q)}:{})},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(a(t))},onFocus:()=>null==I?void 0:I(),onBlur:()=>null==U?void 0:U()});return r(k,(()=>({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:n=>null==W?void 0:W.commands.setContent(c(n),{emitUpdate:!0}),insertContent:n=>null==W?void 0:W.commands.insertContent(c(n)),insertAtStart:n=>{W&&W.commands.insertContentAt(1,c(n))},insertAtEnd:n=>{W&&W.commands.insertContentAt(W.state.doc.content.size,c(n))},appendContent:n=>{W&&W.commands.insertContentAt(W.state.doc.content.size-1,c(n))},getContent:()=>u(W),getCursorPosition:()=>{const{from:n,to:t}=W.state.selection;return{from:n,to:t}},insertAtPosition:(n,t)=>{W&&W.commands.insertContentAt(n,t)},getSelectedText:()=>{const{state:n}=W,{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==W?void 0:W.storage.characterCount)||void 0===n?void 0:n.characters)||void 0===t?void 0:t.call(n))&&void 0!==e?e:null==W?void 0:W.getText().length)&&void 0!==o?o:0,limit:null!=j?j:null}},getSectionContent:n=>m(W,n),setSectionContent:(n,t)=>{W&&g(W,n,c(t))},focusSection:n=>{if(!W)return;if("body"===n)return void W.chain().focus().setTextSelection(1).run();let t=-1;W.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&&W.chain().focus().setTextSelection(t).run()},clearSection:n=>{W&&g(W,n,"<p></p>")},getBodyContent:()=>h(W),setBodyContent:n=>{W&&g(W,"body",c(n))},setBodyAndSections:(n,t)=>{if(!W)return;const e=d(c(n),t.map((n=>({id:n.id,content:c(n.content)}))));W.commands.setContent(e,{emitUpdate:!1})},appendBodyContent:n=>{if(!W)return;const t=c(n),e=v(W,"body");W.commands.insertContentAt(e-1,t)},insertAtSectionStart:(n,t)=>{if(!W)return;const e=f(W,n);-1!==e&&W.commands.insertContentAt(e,c(t))},insertAtSectionEnd:(n,t)=>{if(!W)return;const e=v(W,n);W.commands.insertContentAt(e,c(t))},getActiveFormats:()=>a(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:n=>null==W?void 0:W.chain().focus().setTextAlign(n).run(),setFontFamily:n=>null==W?void 0:W.chain().focus().setFontFamily(n).run(),setFontSize:n=>null==W?void 0:W.chain().focus().setFontSize(n).run(),setColor:n=>null==W?void 0:W.chain().focus().setColor(n).run(),setHighlight:n=>null==W?void 0:W.chain().focus().toggleHighlight({color:n}).run(),unsetColor:()=>null==W?void 0:W.chain().focus().unsetColor().run(),unsetHighlight:()=>null==W?void 0:W.chain().focus().unsetHighlight().run(),setLink:(n,t)=>{W&&(void 0!==t?W.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():W.chain().focus().extendMarkRange("link").setLink({href:n}).run())},updateLink:n=>null==W?void 0:W.chain().focus().extendMarkRange("link").setLink({href:n}).run(),removeLink:()=>null==W?void 0:W.chain().focus().extendMarkRange("link").unsetLink().run(),insertEmoji:n=>null==W?void 0:W.chain().focus().insertContent(n).run(),insertVariable:n=>null==W?void 0:W.chain().focus().insertContent(`{{${n}}}`).run(),insertHtml:n=>null==W?void 0:W.commands.insertContent(n),undo:()=>null==W?void 0:W.chain().focus().undo().run(),redo:()=>null==W?void 0:W.chain().focus().redo().run(),canUndo:()=>{var n;return null!==(n=null==W?void 0:W.can().undo())&&void 0!==n&&n},canRedo:()=>{var n;return null!==(n=null==W?void 0:W.can().redo())&&void 0!==n&&n}}})),[W]),W?n(s,Object.assign({minHeight:z,maxHeight:D,style:P,className:N},{children:[t(i,{editor:W}),t(p,{editor:W,renderLinkTooltip:null==O?void 0:O.renderTooltip})]})):null}));k.displayName="BikEditor";export{k 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,normalizeHtml as c,extractContent as u,extractActiveFormats as a,extractSectionContent as m,setSectionContentInEditor as g,extractBodyContent as h,findSectionEndPos as v,findSectionStartPos as f}from"./BikEditor.utils.js";import{buildExtensions as C}from"./extensions/buildExtensions.js";import{LinkBubbleMenu as p}from"./floating/LinkBubbleMenu.js";function S(n){return Object.entries(n).map((n=>{let[t,e]=n;return`${t.replace(/([A-Z])/g,(n=>`-${n.toLowerCase()}`))}:${e}`})).join(";")}const k=l(((l,k)=>{var x;const{initialContent:B,sections:b,features:y,disabled:A,maxCharacters:j,shortcuts:L,sendShortcut:F,mentions:H,slashCommands:M,link:O,onPaste:T,onChange:w,onSend:E,onFocus:I,onBlur:U,onSelectionChange:R,minHeight:z,maxHeight:D,style:P,className:N,editorClassName:$,editorStyle:q}=l,V=(null==b?void 0:b.length)?d(c(null!=B?B:""),b.map((n=>Object.assign(Object.assign({},n),{content:c(n.content)})))):c(null!=B?B:""),W=o({extensions:C({features:y,placeholder:l.placeholder,maxCharacters:j,hasSections:(null!==(x=null==b?void 0:b.length)&&void 0!==x?x:0)>0,mentions:{agents:null==H?void 0:H.agents,teams:null==H?void 0:H.teams},slashCommands:null==M?void 0:M.items,onPaste:T,onSend:E,sendShortcut:F,shortcuts:L,onMentionSelected:null==H?void 0:H.onSelect,onSlashCommandSelected:null==M?void 0:M.onSelect,renderMentionItem:null==H?void 0:H.renderItem,renderMentionDropdown:null==H?void 0:H.renderDropdown,renderSlashCommandItem:null==M?void 0:M.renderItem,renderSlashCommandDropdown:null==M?void 0:M.renderDropdown}),content:V,editable:!A,immediatelyRender:!1,editorProps:{attributes:Object.assign(Object.assign({},$?{class:$}:{}),q?{style:S(q)}:{})},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(a(t))},onFocus:()=>null==I?void 0:I(),onBlur:()=>null==U?void 0:U()});return r(k,(()=>({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:n=>null==W?void 0:W.commands.setContent(c(n),{emitUpdate:!0}),insertContent:n=>null==W?void 0:W.commands.insertContent(c(n)),insertAtStart:n=>{W&&W.commands.insertContentAt(1,c(n))},insertAtEnd:n=>{W&&W.commands.insertContentAt(W.state.doc.content.size,c(n))},appendContent:n=>{W&&W.commands.insertContentAt(W.state.doc.content.size-1,c(n))},getContent:()=>u(W),getCursorPosition:()=>{const{from:n,to:t}=W.state.selection;return{from:n,to:t}},insertAtPosition:(n,t)=>{W&&W.commands.insertContentAt(n,t)},getSelectedText:()=>{const{state:n}=W,{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==W?void 0:W.storage.characterCount)||void 0===n?void 0:n.characters)||void 0===t?void 0:t.call(n))&&void 0!==e?e:null==W?void 0:W.getText().length)&&void 0!==o?o:0,limit:null!=j?j:null}},getSectionContent:n=>m(W,n),setSectionContent:(n,t)=>{W&&g(W,n,c(t))},focusSection:n=>{if(!W)return;if("body"===n)return void W.chain().focus().setTextSelection(1).run();let t=-1;W.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&&W.chain().focus().setTextSelection(t).run()},clearSection:n=>{W&&g(W,n,"<p></p>")},getBodyContent:()=>h(W),setBodyContent:n=>{W&&g(W,"body",c(n))},setBodyAndSections:(n,t)=>{if(!W)return;const e=d(c(n),t.map((n=>({id:n.id,content:c(n.content)}))));W.commands.setContent(e,{emitUpdate:!0})},appendBodyContent:n=>{if(!W)return;const t=c(n),e=v(W,"body");W.commands.insertContentAt(e-1,t)},insertAtSectionStart:(n,t)=>{if(!W)return;const e=f(W,n);-1!==e&&W.commands.insertContentAt(e,c(t))},insertAtSectionEnd:(n,t)=>{if(!W)return;const e=v(W,n);W.commands.insertContentAt(e,c(t))},getActiveFormats:()=>a(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:n=>null==W?void 0:W.chain().focus().setTextAlign(n).run(),setFontFamily:n=>null==W?void 0:W.chain().focus().setFontFamily(n).run(),setFontSize:n=>null==W?void 0:W.chain().focus().setFontSize(n).run(),setColor:n=>null==W?void 0:W.chain().focus().setColor(n).run(),setHighlight:n=>null==W?void 0:W.chain().focus().toggleHighlight({color:n}).run(),unsetColor:()=>null==W?void 0:W.chain().focus().unsetColor().run(),unsetHighlight:()=>null==W?void 0:W.chain().focus().unsetHighlight().run(),setLink:(n,t)=>{W&&(void 0!==t?W.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():W.chain().focus().extendMarkRange("link").setLink({href:n}).run())},updateLink:n=>null==W?void 0:W.chain().focus().extendMarkRange("link").setLink({href:n}).run(),removeLink:()=>null==W?void 0:W.chain().focus().extendMarkRange("link").unsetLink().run(),insertEmoji:n=>null==W?void 0:W.chain().focus().insertContent(n).run(),insertVariable:n=>null==W?void 0:W.chain().focus().insertContent(`{{${n}}}`).run(),insertHtml:n=>null==W?void 0:W.commands.insertContent(n),undo:()=>null==W?void 0:W.chain().focus().undo().run(),redo:()=>null==W?void 0:W.chain().focus().redo().run(),canUndo:()=>{var n;return null!==(n=null==W?void 0:W.can().undo())&&void 0!==n&&n},canRedo:()=>{var n;return null!==(n=null==W?void 0:W.can().redo())&&void 0!==n&&n}}})),[W]),W?n(s,Object.assign({minHeight:z,maxHeight:D,style:P,className:N},{children:[t(i,{editor:W}),t(p,{editor:W,renderLinkTooltip:null==O?void 0:O.renderTooltip})]})):null}));k.displayName="BikEditor";export{k as BikEditor};
@@ -1 +1 @@
1
- import{Node as t,mergeAttributes as e}from"../../../node_modules/@tiptap/core/dist/index.js";const d=t.create({name:"sectionDivider",group:"block",atom:!0,selectable:!1,draggable:!1,addAttributes:()=>({sectionId:{default:null}}),parseHTML:()=>[{tag:"div[data-section-divider]",getAttrs:t=>({sectionId:t.getAttribute("data-section-divider")})},{tag:"div[data-signature-divider]",getAttrs:()=>({sectionId:"signature"})},{tag:"div[data-forwarded-divider]",getAttrs:()=>({sectionId:"forwarded"})}],renderHTML(t){let{node:d,HTMLAttributes:i}=t;return["div",e(i,{"data-section-divider":d.attrs.sectionId,style:"display:none;height:0;line-height:0;overflow:hidden;"})]}});export{d as SectionDividerNode};
1
+ import{Node as e,mergeAttributes as t}from"../../../node_modules/@tiptap/core/dist/index.js";const d=e.create({name:"sectionDivider",group:"block",atom:!0,selectable:!1,draggable:!1,addAttributes:()=>({sectionId:{default:null,rendered:!1}}),parseHTML:()=>[{tag:"div[data-section-divider]",getAttrs:e=>({sectionId:e.getAttribute("data-section-divider")})},{tag:"div[data-signature-divider]",getAttrs:()=>({sectionId:"signature"})},{tag:"div[data-forwarded-divider]",getAttrs:()=>({sectionId:"forwarded"})}],renderHTML(e){let{node:d,HTMLAttributes:i}=e;return["div",t(i,{"data-section-divider":d.attrs.sectionId,style:"display:none;height:0;line-height:0;overflow:hidden;"})]}});export{d as SectionDividerNode};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.788-beta.7",
3
+ "version": "0.0.788-beta.9",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",