@bikdotai/bik-component-library 0.0.788-beta.3 → 0.0.788-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-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
+ "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"),l=require("./BikEditor.utils.js"),r=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 a=(a,u)=>{var c;const{initialContent:m,sections:g,features:v,disabled:h,maxCharacters:f,shortcuts:C,sendShortcut:S,mentions:k,slashCommands:p,link:x,onPaste:b,onChange:B,onSend:H,onFocus:y,onBlur:j,onSelectionChange:z,minHeight:A,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((e=>Object.assign(Object.assign({},e),{content:l.normalizeHtml(e.content)})))):l.normalizeHtml(null!=m?m:""),O=t.useEditor({extensions:r.buildExtensions({features:v,placeholder:a.placeholder,maxCharacters:f,hasSections:(null!==(c=null==g?void 0:g.length)&&void 0!==c?c:0)>0,mentions:{agents:null==k?void 0:k.agents,teams:null==k?void 0:k.teams},slashCommands:null==p?void 0:p.items,onPaste:b,onSend:H,sendShortcut:S,shortcuts:C,onMentionSelected:null==k?void 0:k.onSelect,onSlashCommandSelected:null==p?void 0:p.onSelect,renderMentionItem:null==k?void 0:k.renderItem,renderMentionDropdown:null==k?void 0:k.renderDropdown,renderSlashCommandItem:null==p?void 0:p.renderItem,renderSlashCommandDropdown:null==p?void 0:p.renderDropdown}),content:q,editable:!h,immediatelyRender:!1,editorProps:{attributes:Object.assign(Object.assign({},I?{class:I}:{}),M?{style:d(M)}:{})},onUpdate:e=>{let{editor:n}=e;return null==B?void 0:B(l.extractContent(n))},onSelectionUpdate:e=>{let{editor:n}=e;return null==z?void 0:z(l.extractActiveFormats(n))},onFocus:()=>null==y?void 0:y(),onBlur:()=>null==j?void 0:j()});return o.useImperativeHandle(u,(()=>({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:e=>null==O?void 0:O.commands.setContent(l.normalizeHtml(e),{emitUpdate:!0}),insertContent:e=>null==O?void 0:O.commands.insertContent(l.normalizeHtml(e)),insertAtStart:e=>{O&&O.commands.insertContentAt(1,l.normalizeHtml(e))},insertAtEnd:e=>{O&&O.commands.insertContentAt(O.state.doc.content.size,l.normalizeHtml(e))},appendContent:e=>{O&&O.commands.insertContentAt(O.state.doc.content.size-1,l.normalizeHtml(e))},getContent:()=>l.extractContent(O),getCursorPosition:()=>{const{from:e,to:n}=O.state.selection;return{from:e,to:n}},insertAtPosition:(e,n)=>{O&&O.commands.insertContentAt(e,n)},getSelectedText:()=>{const{state:e}=O,{from:t,to:o,empty:i}=e.selection;if(!i)return e.doc.textBetween(t,o," ");const l=e.schema.marks.link;if(l){const o=n.getMarkRange(e.doc.resolve(t),l);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==O?void 0:O.storage.characterCount)||void 0===e?void 0:e.characters)||void 0===n?void 0:n.call(e))&&void 0!==t?t:null==O?void 0:O.getText().length)&&void 0!==o?o:0,limit:null!=f?f:null}},getSectionContent:e=>l.extractSectionContent(O,e),setSectionContent:(e,n)=>{O&&l.setSectionContentInEditor(O,e,l.normalizeHtml(n))},focusSection:e=>{if(!O)return;if("body"===e)return void O.chain().focus().setTextSelection(1).run();let n=-1;O.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&&O.chain().focus().setTextSelection(n).run()},clearSection:e=>{O&&l.setSectionContentInEditor(O,e,"<p></p>")},getBodyContent:()=>l.extractBodyContent(O),setBodyContent:e=>{O&&l.setSectionContentInEditor(O,"body",l.normalizeHtml(e))},appendBodyContent:e=>{if(!O)return;const n=l.normalizeHtml(e),t=l.findSectionEndPos(O,"body");O.commands.insertContentAt(t-1,n)},insertAtSectionStart:(e,n)=>{if(!O)return;const t=l.findSectionStartPos(O,e);-1!==t&&O.commands.insertContentAt(t,l.normalizeHtml(n))},insertAtSectionEnd:(e,n)=>{if(!O)return;const t=l.findSectionEndPos(O,e);O.commands.insertContentAt(t,l.normalizeHtml(n))},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:e=>null==O?void 0:O.chain().focus().setTextAlign(e).run(),setFontFamily:e=>null==O?void 0:O.chain().focus().setFontFamily(e).run(),setFontSize:e=>null==O?void 0:O.chain().focus().setFontSize(e).run(),setColor:e=>null==O?void 0:O.chain().focus().setColor(e).run(),setHighlight:e=>null==O?void 0:O.chain().focus().toggleHighlight({color:e}).run(),unsetColor:()=>null==O?void 0:O.chain().focus().unsetColor().run(),unsetHighlight:()=>null==O?void 0:O.chain().focus().unsetHighlight().run(),setLink:(e,n)=>{O&&(void 0!==n?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(n,[s.create({href:e})])),!0)})).run():O.chain().focus().extendMarkRange("link").setLink({href:e}).run())},updateLink:e=>null==O?void 0:O.chain().focus().extendMarkRange("link").setLink({href:e}).run(),removeLink:()=>null==O?void 0:O.chain().focus().extendMarkRange("link").unsetLink().run(),insertEmoji:e=>null==O?void 0:O.chain().focus().insertContent(e).run(),insertVariable:e=>null==O?void 0:O.chain().focus().insertContent(`{{${e}}}`).run(),insertHtml:e=>null==O?void 0:O.commands.insertContent(e),undo:()=>null==O?void 0:O.chain().focus().undo().run(),redo:()=>null==O?void 0:O.chain().focus().redo().run(),canUndo:()=>{var e;return null!==(e=null==O?void 0:O.can().undo())&&void 0!==e&&e},canRedo:()=>{var e;return null!==(e=null==O?void 0:O.can().redo())&&void 0!==e&&e}}})),[O]),O?e.jsxs(i.BikEditorShell,Object.assign({minHeight:A,maxHeight:E,style:L,className:F},{children:[e.jsx(t.EditorContent,{editor:O}),e.jsx(s.LinkBubbleMenu,{editor:O,renderLinkTooltip:null==x?void 0:x.renderTooltip})]})):null},u=o.forwardRef(a);u.displayName="BikEditor",exports.BikEditor=u;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t=t=>`<div data-section-divider="${t}" style="display:none;height:0;line-height:0;overflow:hidden;"></div>`;function e(e,n){let i=e;for(const e of n)i+=t(e.id)+e.content;return i}function n(t){return i(t.getHTML())}function i(t){const e=new Map,n=/<div[^>]*data-section-divider="([^"]*)[^>]*>\s*<\/div>/g,i=[];let o;for(;null!==(o=n.exec(t));)i.push({id:o[1],index:o.index,endIndex:o.index+o[0].length});if(0===i.length)return e.set("body",t),e;e.set("body",t.slice(0,i[0].index));for(let n=0;n<i.length;n++){const o=i[n].endIndex,r=n+1<i.length?i[n+1].index:t.length;e.set(i[n].id,t.slice(o,r))}return e}function o(t,e){var i;return function(t){var e;const n="undefined"!=typeof document?document.createElement("div"):null;n&&(n.innerHTML=t);const i=null!==(e=null==n?void 0:n.textContent)&&void 0!==e?e:"";return{html:t,text:i,isEmpty:!i.trim(),characterCount:i.length}}(null!==(i=n(t).get(e))&&void 0!==i?i:"")}exports.SECTION_DIVIDER_HTML=t,exports.buildSectionedContent=e,exports.extractActiveFormats=function(t){var e,n,i,o,r;return{bold:t.isActive("bold"),italic:t.isActive("italic"),underline:t.isActive("underline"),strike:t.isActive("strike"),bulletList:t.isActive("bulletList"),orderedList:t.isActive("orderedList"),blockquote:t.isActive("blockquote"),codeBlock:t.isActive("codeBlock"),link:t.isActive("link")?{href:null!==(e=t.getAttributes("link").href)&&void 0!==e?e:""}:null,textAlign:t.isActive({textAlign:"center"})?"center":t.isActive({textAlign:"right"})?"right":t.isActive({textAlign:"justify"})?"justify":"left",fontFamily:null!==(n=t.getAttributes("textStyle").fontFamily)&&void 0!==n?n:null,fontSize:null!==(i=t.getAttributes("textStyle").fontSize)&&void 0!==i?i:null,color:null!==(o=t.getAttributes("textStyle").color)&&void 0!==o?o:null,highlight:t.isActive("highlight")?null!==(r=t.getAttributes("highlight").color)&&void 0!==r?r:"default":null}},exports.extractAllSections=n,exports.extractAllSectionsFromHtml=i,exports.extractBodyContent=function(t){return o(t,"body")},exports.extractContent=function(t){var e,n,i;return{html:t.getHTML(),text:t.getText(),isEmpty:t.isEmpty,characterCount:null!==(i=null===(n=null===(e=t.storage.characterCount)||void 0===e?void 0:e.characters)||void 0===n?void 0:n.call(e))&&void 0!==i?i:t.getText().length}},exports.extractSectionContent=o,exports.findSectionEndPos=function(t,e){const n=t.state.doc,i=n.content.size;if("body"===e){let t=-1;return n.descendants(((e,n)=>{if(-1!==t)return!1;"sectionDivider"===e.type.name&&(t=n)})),-1!==t?t:i}let o=!1,r=-1;return n.descendants(((t,n)=>-1===r&&(o?void("sectionDivider"===t.type.name&&(r=n)):("sectionDivider"===t.type.name&&t.attrs.sectionId===e&&(o=!0),!1)))),-1!==r?r:i},exports.findSectionStartPos=function(t,e){if("body"===e)return 1;let n=-1;return t.state.doc.descendants(((t,i)=>{if(-1!==n)return!1;"sectionDivider"===t.type.name&&t.attrs.sectionId===e&&(n=i+t.nodeSize)})),n},exports.setSectionContentInEditor=function(t,i,o){var r;const l=n(t);l.set(i,o);const c=e(null!==(r=l.get("body"))&&void 0!==r?r:"",[...l.entries()].filter((t=>{let[e]=t;return"body"!==e})).map((t=>{let[e,n]=t;return{id:e,content:n}})));t.commands.setContent(c,{emitUpdate:!1})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t=t=>`<div data-section-divider="${t}" style="display:none;height:0;line-height:0;overflow:hidden;"></div>`;function e(e,n){let i=e;for(const e of n)i+=t(e.id)+e.content;return i}function n(t){return i(t.getHTML())}function i(t){const e=new Map,n=/<div[^>]*data-section-divider="([^"]*)[^>]*>\s*<\/div>/g,i=[];let o;for(;null!==(o=n.exec(t));)i.push({id:o[1],index:o.index,endIndex:o.index+o[0].length});if(0===i.length)return e.set("body",t),e;e.set("body",t.slice(0,i[0].index));for(let n=0;n<i.length;n++){const o=i[n].endIndex,r=n+1<i.length?i[n+1].index:t.length;e.set(i[n].id,t.slice(o,r))}return e}function o(t,e){var i;return function(t){var e;const n="undefined"!=typeof document?document.createElement("div"):null;n&&(n.innerHTML=t);const i=null!==(e=null==n?void 0:n.textContent)&&void 0!==e?e:"";return{html:t,text:i,isEmpty:!i.trim(),characterCount:i.length}}(null!==(i=n(t).get(e))&&void 0!==i?i:"")}exports.SECTION_DIVIDER_HTML=t,exports.buildSectionedContent=e,exports.extractActiveFormats=function(t){var e,n,i,o,r;return{bold:t.isActive("bold"),italic:t.isActive("italic"),underline:t.isActive("underline"),strike:t.isActive("strike"),bulletList:t.isActive("bulletList"),orderedList:t.isActive("orderedList"),blockquote:t.isActive("blockquote"),codeBlock:t.isActive("codeBlock"),link:t.isActive("link")?{href:null!==(e=t.getAttributes("link").href)&&void 0!==e?e:""}:null,textAlign:t.isActive({textAlign:"center"})?"center":t.isActive({textAlign:"right"})?"right":t.isActive({textAlign:"justify"})?"justify":"left",fontFamily:null!==(n=t.getAttributes("textStyle").fontFamily)&&void 0!==n?n:null,fontSize:null!==(i=t.getAttributes("textStyle").fontSize)&&void 0!==i?i:null,color:null!==(o=t.getAttributes("textStyle").color)&&void 0!==o?o:null,highlight:t.isActive("highlight")?null!==(r=t.getAttributes("highlight").color)&&void 0!==r?r:"default":null}},exports.extractAllSections=n,exports.extractAllSectionsFromHtml=i,exports.extractBodyContent=function(t){return o(t,"body")},exports.extractContent=function(t){var e,n,i;return{html:t.getHTML(),text:t.getText(),isEmpty:t.isEmpty,characterCount:null!==(i=null===(n=null===(e=t.storage.characterCount)||void 0===e?void 0:e.characters)||void 0===n?void 0:n.call(e))&&void 0!==i?i:t.getText().length}},exports.extractSectionContent=o,exports.findSectionEndPos=function(t,e){const n=t.state.doc,i=n.content.size;if("body"===e){let t=-1;return n.descendants(((e,n)=>{if(-1!==t)return!1;"sectionDivider"===e.type.name&&(t=n)})),-1!==t?t:i}let o=!1,r=-1;return n.descendants(((t,n)=>-1===r&&(o?void("sectionDivider"===t.type.name&&(r=n)):("sectionDivider"===t.type.name&&t.attrs.sectionId===e&&(o=!0),!1)))),-1!==r?r:i},exports.findSectionStartPos=function(t,e){if("body"===e)return 1;let n=-1;return t.state.doc.descendants(((t,i)=>{if(-1!==n)return!1;"sectionDivider"===t.type.name&&t.attrs.sectionId===e&&(n=i+t.nodeSize)})),n},exports.normalizeHtml=function(t){return t.replace(/<p>\s*<br\s*\/?>\s*<\/p>/gi,"<p></p>")},exports.setSectionContentInEditor=function(t,i,o){var r;const l=n(t);l.set(i,o);const s=e(null!==(r=l.get("body"))&&void 0!==r?r:"",[...l.entries()].filter((t=>{let[e]=t;return"body"!==e})).map((t=>{let[e,n]=t;return{id:e,content:n}})));t.commands.setContent(s,{emitUpdate:!1})};
@@ -1,5 +1,20 @@
1
1
  import { Editor } from '@tiptap/core';
2
2
  import { EditorSnapshot, FormatState } from './BikEditor.types';
3
+ /**
4
+ * Normalise HTML before passing it to TipTap.
5
+ *
6
+ * Problem: Quill uses `<p><br></p>` as a blank-line separator. TipTap's
7
+ * HardBreak extension parses that `<br>` as a real `hard_break` node.
8
+ * ProseMirror then also appends `<br class="ProseMirror-trailingBreak">` as a
9
+ * cursor-position decoration, making the empty paragraph render at **2× line
10
+ * height** instead of 1×.
11
+ *
12
+ * Fix: replace `<p><br></p>` → `<p></p>` so TipTap stores a truly empty
13
+ * paragraph. ProseMirror adds only the trailing decoration, giving the correct
14
+ * 1× line height. The WA text output is unchanged (`\n` either way after
15
+ * surrounding-newline collapse in `toWhatsAppText`).
16
+ */
17
+ export declare function normalizeHtml(html: string): string;
3
18
  export declare const SECTION_DIVIDER_HTML: (id: string) => string;
4
19
  /**
5
20
  * Build initial HTML for an editor with one or more named sections below the body.
@@ -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-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
+ 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 u,extractContent as c,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:R,onSelectionChange:U,minHeight:z,maxHeight:D,style:P,className:N,editorClassName:$,editorStyle:q}=l,V=(null==b?void 0:b.length)?d(u(null!=B?B:""),b.map((n=>Object.assign(Object.assign({},n),{content:u(n.content)})))):u(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(c(t))},onSelectionUpdate:n=>{let{editor:t}=n;return null==U?void 0:U(a(t))},onFocus:()=>null==I?void 0:I(),onBlur:()=>null==R?void 0:R()});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(u(n),{emitUpdate:!0}),insertContent:n=>null==W?void 0:W.commands.insertContent(u(n)),insertAtStart:n=>{W&&W.commands.insertContentAt(1,u(n))},insertAtEnd:n=>{W&&W.commands.insertContentAt(W.state.doc.content.size,u(n))},appendContent:n=>{W&&W.commands.insertContentAt(W.state.doc.content.size-1,u(n))},getContent:()=>c(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,u(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",u(n))},appendBodyContent:n=>{if(!W)return;const t=u(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,u(t))},insertAtSectionEnd:(n,t)=>{if(!W)return;const e=v(W,n);W.commands.insertContentAt(e,u(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
- const t=t=>`<div data-section-divider="${t}" style="display:none;height:0;line-height:0;overflow:hidden;"></div>`;function e(e,i){let n=e;for(const e of i)n+=t(e.id)+e.content;return n}function i(t){return n(t.getHTML())}function n(t){const e=new Map,i=/<div[^>]*data-section-divider="([^"]*)[^>]*>\s*<\/div>/g,n=[];let l;for(;null!==(l=i.exec(t));)n.push({id:l[1],index:l.index,endIndex:l.index+l[0].length});if(0===n.length)return e.set("body",t),e;e.set("body",t.slice(0,n[0].index));for(let i=0;i<n.length;i++){const l=n[i].endIndex,o=i+1<n.length?n[i+1].index:t.length;e.set(n[i].id,t.slice(l,o))}return e}function l(t,e){var n;return function(t){var e;const i="undefined"!=typeof document?document.createElement("div"):null;i&&(i.innerHTML=t);const n=null!==(e=null==i?void 0:i.textContent)&&void 0!==e?e:"";return{html:t,text:n,isEmpty:!n.trim(),characterCount:n.length}}(null!==(n=i(t).get(e))&&void 0!==n?n:"")}function o(t,n,l){var o;const r=i(t);r.set(n,l);const d=e(null!==(o=r.get("body"))&&void 0!==o?o:"",[...r.entries()].filter((t=>{let[e]=t;return"body"!==e})).map((t=>{let[e,i]=t;return{id:e,content:i}})));t.commands.setContent(d,{emitUpdate:!1})}function r(t){return l(t,"body")}function d(t){var e,i,n,l,o;return{bold:t.isActive("bold"),italic:t.isActive("italic"),underline:t.isActive("underline"),strike:t.isActive("strike"),bulletList:t.isActive("bulletList"),orderedList:t.isActive("orderedList"),blockquote:t.isActive("blockquote"),codeBlock:t.isActive("codeBlock"),link:t.isActive("link")?{href:null!==(e=t.getAttributes("link").href)&&void 0!==e?e:""}:null,textAlign:t.isActive({textAlign:"center"})?"center":t.isActive({textAlign:"right"})?"right":t.isActive({textAlign:"justify"})?"justify":"left",fontFamily:null!==(i=t.getAttributes("textStyle").fontFamily)&&void 0!==i?i:null,fontSize:null!==(n=t.getAttributes("textStyle").fontSize)&&void 0!==n?n:null,color:null!==(l=t.getAttributes("textStyle").color)&&void 0!==l?l:null,highlight:t.isActive("highlight")?null!==(o=t.getAttributes("highlight").color)&&void 0!==o?o:"default":null}}function c(t){var e,i,n;return{html:t.getHTML(),text:t.getText(),isEmpty:t.isEmpty,characterCount:null!==(n=null===(i=null===(e=t.storage.characterCount)||void 0===e?void 0:e.characters)||void 0===i?void 0:i.call(e))&&void 0!==n?n:t.getText().length}}function s(t,e){if("body"===e)return 1;let i=-1;return t.state.doc.descendants(((t,n)=>{if(-1!==i)return!1;"sectionDivider"===t.type.name&&t.attrs.sectionId===e&&(i=n+t.nodeSize)})),i}function u(t,e){const i=t.state.doc,n=i.content.size;if("body"===e){let t=-1;return i.descendants(((e,i)=>{if(-1!==t)return!1;"sectionDivider"===e.type.name&&(t=i)})),-1!==t?t:n}let l=!1,o=-1;return i.descendants(((t,i)=>-1===o&&(l?void("sectionDivider"===t.type.name&&(o=i)):("sectionDivider"===t.type.name&&t.attrs.sectionId===e&&(l=!0),!1)))),-1!==o?o:n}export{t as SECTION_DIVIDER_HTML,e as buildSectionedContent,d as extractActiveFormats,i as extractAllSections,n as extractAllSectionsFromHtml,r as extractBodyContent,c as extractContent,l as extractSectionContent,u as findSectionEndPos,s as findSectionStartPos,o as setSectionContentInEditor};
1
+ function t(t){return t.replace(/<p>\s*<br\s*\/?>\s*<\/p>/gi,"<p></p>")}const e=t=>`<div data-section-divider="${t}" style="display:none;height:0;line-height:0;overflow:hidden;"></div>`;function i(t,i){let n=t;for(const t of i)n+=e(t.id)+t.content;return n}function n(t){return l(t.getHTML())}function l(t){const e=new Map,i=/<div[^>]*data-section-divider="([^"]*)[^>]*>\s*<\/div>/g,n=[];let l;for(;null!==(l=i.exec(t));)n.push({id:l[1],index:l.index,endIndex:l.index+l[0].length});if(0===n.length)return e.set("body",t),e;e.set("body",t.slice(0,n[0].index));for(let i=0;i<n.length;i++){const l=n[i].endIndex,o=i+1<n.length?n[i+1].index:t.length;e.set(n[i].id,t.slice(l,o))}return e}function o(t,e){var i;return function(t){var e;const i="undefined"!=typeof document?document.createElement("div"):null;i&&(i.innerHTML=t);const n=null!==(e=null==i?void 0:i.textContent)&&void 0!==e?e:"";return{html:t,text:n,isEmpty:!n.trim(),characterCount:n.length}}(null!==(i=n(t).get(e))&&void 0!==i?i:"")}function r(t,e,l){var o;const r=n(t);r.set(e,l);const d=i(null!==(o=r.get("body"))&&void 0!==o?o:"",[...r.entries()].filter((t=>{let[e]=t;return"body"!==e})).map((t=>{let[e,i]=t;return{id:e,content:i}})));t.commands.setContent(d,{emitUpdate:!1})}function d(t){return o(t,"body")}function c(t){var e,i,n,l,o;return{bold:t.isActive("bold"),italic:t.isActive("italic"),underline:t.isActive("underline"),strike:t.isActive("strike"),bulletList:t.isActive("bulletList"),orderedList:t.isActive("orderedList"),blockquote:t.isActive("blockquote"),codeBlock:t.isActive("codeBlock"),link:t.isActive("link")?{href:null!==(e=t.getAttributes("link").href)&&void 0!==e?e:""}:null,textAlign:t.isActive({textAlign:"center"})?"center":t.isActive({textAlign:"right"})?"right":t.isActive({textAlign:"justify"})?"justify":"left",fontFamily:null!==(i=t.getAttributes("textStyle").fontFamily)&&void 0!==i?i:null,fontSize:null!==(n=t.getAttributes("textStyle").fontSize)&&void 0!==n?n:null,color:null!==(l=t.getAttributes("textStyle").color)&&void 0!==l?l:null,highlight:t.isActive("highlight")?null!==(o=t.getAttributes("highlight").color)&&void 0!==o?o:"default":null}}function s(t){var e,i,n;return{html:t.getHTML(),text:t.getText(),isEmpty:t.isEmpty,characterCount:null!==(n=null===(i=null===(e=t.storage.characterCount)||void 0===e?void 0:e.characters)||void 0===i?void 0:i.call(e))&&void 0!==n?n:t.getText().length}}function u(t,e){if("body"===e)return 1;let i=-1;return t.state.doc.descendants(((t,n)=>{if(-1!==i)return!1;"sectionDivider"===t.type.name&&t.attrs.sectionId===e&&(i=n+t.nodeSize)})),i}function v(t,e){const i=t.state.doc,n=i.content.size;if("body"===e){let t=-1;return i.descendants(((e,i)=>{if(-1!==t)return!1;"sectionDivider"===e.type.name&&(t=i)})),-1!==t?t:n}let l=!1,o=-1;return i.descendants(((t,i)=>-1===o&&(l?void("sectionDivider"===t.type.name&&(o=i)):("sectionDivider"===t.type.name&&t.attrs.sectionId===e&&(l=!0),!1)))),-1!==o?o:n}export{e as SECTION_DIVIDER_HTML,i as buildSectionedContent,c as extractActiveFormats,n as extractAllSections,l as extractAllSectionsFromHtml,d as extractBodyContent,s as extractContent,o as extractSectionContent,v as findSectionEndPos,u as findSectionStartPos,t as normalizeHtml,r as setSectionContentInEditor};
@@ -1,5 +1,20 @@
1
1
  import { Editor } from '@tiptap/core';
2
2
  import { EditorSnapshot, FormatState } from './BikEditor.types';
3
+ /**
4
+ * Normalise HTML before passing it to TipTap.
5
+ *
6
+ * Problem: Quill uses `<p><br></p>` as a blank-line separator. TipTap's
7
+ * HardBreak extension parses that `<br>` as a real `hard_break` node.
8
+ * ProseMirror then also appends `<br class="ProseMirror-trailingBreak">` as a
9
+ * cursor-position decoration, making the empty paragraph render at **2× line
10
+ * height** instead of 1×.
11
+ *
12
+ * Fix: replace `<p><br></p>` → `<p></p>` so TipTap stores a truly empty
13
+ * paragraph. ProseMirror adds only the trailing decoration, giving the correct
14
+ * 1× line height. The WA text output is unchanged (`\n` either way after
15
+ * surrounding-newline collapse in `toWhatsAppText`).
16
+ */
17
+ export declare function normalizeHtml(html: string): string;
3
18
  export declare const SECTION_DIVIDER_HTML: (id: string) => string;
4
19
  /**
5
20
  * Build initial HTML for an editor with one or more named sections below the body.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bikdotai/bik-component-library",
3
- "version": "0.0.788-beta.3",
3
+ "version": "0.0.788-beta.4",
4
4
  "description": "Bik Component Library",
5
5
  "repository": {
6
6
  "type": "git",