@bikdotai/bik-component-library 0.0.788-beta.0 → 0.0.788-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/editor/BikEditor.js +1 -1
- package/dist/cjs/editor/BikEditor.styles.js +11 -3
- package/dist/cjs/editor/BikEditor.utils.js +1 -1
- package/dist/cjs/editor/extensions/buildExtensions.js +1 -1
- package/dist/cjs/editor/extensions/editorDropdown.styles.js +15 -18
- package/dist/cjs/editor/extensions/mention/MentionDropdown.js +1 -1
- package/dist/cjs/editor/extensions/sectionDivider/SectionDividerNode.js +1 -1
- package/dist/cjs/editor/extensions/slashCommand/SlashCommandMenu.js +1 -1
- package/dist/cjs/editor/serializers/toLiveChatText.js +1 -1
- package/dist/cjs/editor/serializers/toWhatsAppText.js +1 -1
- package/dist/cjs/src/components/bik-layout/MockMenus.d.ts +1 -0
- package/dist/cjs/src/editor/BikEditor.types.d.ts +27 -0
- package/dist/cjs/src/editor/BikEditor.utils.d.ts +15 -0
- package/dist/esm/editor/BikEditor.js +1 -1
- package/dist/esm/editor/BikEditor.styles.js +11 -3
- package/dist/esm/editor/BikEditor.utils.js +1 -1
- package/dist/esm/editor/extensions/buildExtensions.js +1 -1
- package/dist/esm/editor/extensions/editorDropdown.styles.js +11 -14
- package/dist/esm/editor/extensions/mention/MentionDropdown.js +1 -1
- package/dist/esm/editor/extensions/sectionDivider/SectionDividerNode.js +1 -1
- package/dist/esm/editor/extensions/slashCommand/SlashCommandMenu.js +1 -1
- package/dist/esm/editor/serializers/toLiveChatText.js +1 -1
- package/dist/esm/editor/serializers/toWhatsAppText.js +1 -1
- package/dist/esm/src/components/bik-layout/MockMenus.d.ts +1 -0
- package/dist/esm/src/editor/BikEditor.types.d.ts +27 -0
- package/dist/esm/src/editor/BikEditor.utils.d.ts +15 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var n=require("react/jsx-runtime"),t=require("../node_modules/@tiptap/core/dist/index.js"),e=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[t,e]=n;return`${t.replace(/([A-Z])/g,(n=>`-${n.toLowerCase()}`))}:${e}`})).join(";")}const a=(a,c)=>{var u;const{initialContent:m,sections:g,features:v,disabled:h,maxCharacters:C,shortcuts:f,sendShortcut:S,mentions:p,slashCommands:x,link:k,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=e.useEditor({extensions:r.buildExtensions({features:v,placeholder:a.placeholder,maxCharacters:C,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==x?void 0:x.items,onPaste:H,onSend:B,sendShortcut:S,shortcuts:f,onMentionSelected:null==p?void 0:p.onSelect,onSlashCommandSelected:null==x?void 0:x.onSelect,renderMentionItem:null==p?void 0:p.renderItem,renderMentionDropdown:null==p?void 0:p.renderDropdown,renderSlashCommandItem:null==x?void 0:x.renderItem,renderSlashCommandDropdown:null==x?void 0:x.renderDropdown}),content:q,editable:!h,immediatelyRender:!1,editorProps:{attributes:Object.assign(Object.assign({},I?{class:I}:{}),M?{style:d(M)}:{})},onUpdate:n=>{let{editor:t}=n;return null==b?void 0:b(l.extractContent(t))},onSelectionUpdate:n=>{let{editor:t}=n;return null==A?void 0:A(l.extractActiveFormats(t))},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:()=>O?l.extractContent(O):{html:"",text:"",isEmpty:!0,characterCount:0},getCursorPosition:()=>{const{from:n,to:t}=O.state.selection;return{from:n,to:t}},insertAtPosition:(n,t)=>{O&&O.commands.insertContentAt(n,t)},getSelectedText:()=>{const{state:n}=O,{from:e,to:o,empty:i}=n.selection;if(!i)return n.doc.textBetween(e,o," ");const l=n.schema.marks.link;if(l){const o=t.getMarkRange(n.doc.resolve(e),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==O?void 0:O.storage.characterCount)||void 0===n?void 0:n.characters)||void 0===t?void 0:t.call(n))&&void 0!==e?e:null==O?void 0:O.getText().length)&&void 0!==o?o:0,limit:null!=C?C:null}},getSectionContent:n=>l.extractSectionContent(O,n),setSectionContent:(n,t)=>{O&&l.setSectionContentInEditor(O,n,l.normalizeHtml(t))},focusSection:n=>{if(!O)return;if("body"===n)return void O.chain().focus().setTextSelection(1).run();let t=-1;O.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&&O.chain().focus().setTextSelection(t).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,t)=>{if(!O)return;const e=l.buildSectionedContent(l.normalizeHtml(n),t.map((n=>({id:n.id,content:l.normalizeHtml(n.content)}))));O.commands.setContent(e,{emitUpdate:!0})},appendBodyContent:n=>{if(!O)return;const t=l.normalizeHtml(n),e=l.findSectionEndPos(O,"body");O.commands.insertContentAt(e-1,t)},insertAtSectionStart:(n,t)=>{if(!O)return;const e=l.findSectionStartPos(O,n);-1!==e&&O.commands.insertContentAt(e,l.normalizeHtml(t))},insertAtSectionEnd:(n,t)=>{if(!O)return;const e=l.findSectionEndPos(O,n);O.commands.insertContentAt(e,l.normalizeHtml(t))},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,t)=>{O&&(void 0!==t?O.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():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(e.EditorContent,{editor:O}),n.jsx(s.LinkBubbleMenu,{editor:O,renderLinkTooltip:null==k?void 0:k.renderTooltip})]})):null},c=o.forwardRef(a);c.displayName="BikEditor",exports.BikEditor=c;
|
|
@@ -14,12 +14,20 @@
|
|
|
14
14
|
|
|
15
15
|
p {
|
|
16
16
|
margin: 0;
|
|
17
|
+
padding: 0;
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
|
|
20
|
+
ul,
|
|
21
|
+
ol {
|
|
22
|
+
margin: 0;
|
|
23
|
+
padding-left: 1.5em;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
li + li {
|
|
27
|
+
margin-top: 2px;
|
|
20
28
|
}
|
|
21
29
|
|
|
22
|
-
|
|
30
|
+
p.is-editor-empty:first-child::before {
|
|
23
31
|
content: attr(data-placeholder);
|
|
24
32
|
float: left;
|
|
25
33
|
color: #adb5bd;
|
|
@@ -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-
|
|
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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@tiptap/extension-character-count"),n=require("@tiptap/extension-color"),t=require("@tiptap/extension-font-family"),i=require("@tiptap/extension-highlight"),o=require("@tiptap/extension-image"),r=require("@tiptap/extension-link"),a=require("@tiptap/extension-placeholder"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@tiptap/extension-character-count"),n=require("@tiptap/extension-color"),t=require("@tiptap/extension-font-family"),i=require("@tiptap/extension-highlight"),o=require("@tiptap/extension-image"),r=require("@tiptap/extension-link"),a=require("@tiptap/extension-placeholder"),l=require("@tiptap/extension-subscript"),s=require("@tiptap/extension-superscript"),d=require("@tiptap/extension-text-align"),u=require("@tiptap/extension-text-style"),p=require("@tiptap/extension-underline"),c=require("@tiptap/starter-kit"),x=require("./FontSizeExtension.js"),m=require("./mention/MentionExtension.js"),f=require("./paste/PasteExtension.js"),h=require("./plainClipboard/PlainClipboardExtension.js"),v=require("./sectionDivider/SectionDividerNode.js"),S=require("./sendShortcut/SendShortcutExtension.js"),g=require("./slashCommand/SlashCommandExtension.js"),q=require("./variable/VariableDecorationExtension.js");function b(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var E=b(e),C=b(n),M=b(t),k=b(i),P=b(o),j=b(r),y=b(a),D=b(l),T=b(s),w=b(d),I=b(p),O=b(c);exports.buildExtensions=function(e){var n,t,i,o,r,a,l,s,d,p,c,b;const z=null!==(t=null===(n=e.features)||void 0===n?void 0:n.richPaste)&&void 0!==t&&t,A=null!==(o=null===(i=e.features)||void 0===i?void 0:i.richTypography)&&void 0!==o&&o,F=null===(r=e.features)||void 0===r?void 0:r.allowedMarks,N=e=>!F||F.includes(e);return[...[O.default.configure({link:!1,underline:!1,bold:!!N("bold")&&{},italic:!!N("italic")&&{},strike:!!N("strike")&&{},code:!!N("code")&&{}}),...N("underline")?[I.default]:[],j.default.extend({addPasteRules:()=>[],addInputRules:()=>[]}).configure({openOnClick:!1,autolink:!1,linkOnPaste:!1,HTMLAttributes:{rel:"noopener noreferrer",class:"bik-link"}}),u.TextStyle,y.default.configure({placeholder:null!==(a=e.placeholder)&&void 0!==a?a:"Type a message..."}),...e.onPaste?[f.PasteExtension.configure({onPaste:e.onPaste})]:[],...z?[]:[h.PlainClipboardExtension],S.SendShortcutExtension.configure({onSend:e.onSend,sendShortcut:e.sendShortcut,extraShortcuts:null!==(l=e.shortcuts)&&void 0!==l?l:[]}),q.VariableDecorationExtension,...e.maxCharacters?[E.default.configure({limit:e.maxCharacters})]:[],v.SectionDividerNode],...[...(null===(d=null===(s=e.mentions)||void 0===s?void 0:s.agents)||void 0===d?void 0:d.length)?[m.buildAgentMentionExtension(e.mentions.agents,e.onMentionSelected,e.renderMentionItem,e.renderMentionDropdown)]:[],...(null===(c=null===(p=e.mentions)||void 0===p?void 0:p.teams)||void 0===c?void 0:c.length)?[m.buildTeamMentionExtension(e.mentions.teams,e.onMentionSelected,e.renderMentionItem,e.renderMentionDropdown)]:[],...(null===(b=e.slashCommands)||void 0===b?void 0:b.length)?[g.buildSlashCommandExtension(e.slashCommands,e.onSlashCommandSelected,e.renderSlashCommandItem,e.renderSlashCommandDropdown)]:[]],...A?[C.default,k.default.configure({multicolor:!0}),M.default,x.FontSizeExtension,w.default.configure({types:["heading","paragraph"]}),D.default,T.default,P.default]:[C.default]]};
|
|
@@ -1,27 +1,24 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("styled-components"),
|
|
2
|
-
background: ${
|
|
3
|
-
border: 1px solid ${
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("styled-components"),t=require("../../constants/Theme.js");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=r(e);const n=o.default.div`
|
|
2
|
+
background: ${t.COLORS.surface.standard};
|
|
3
|
+
border: 1px solid ${t.COLORS.stroke.primary};
|
|
4
4
|
border-radius: 8px;
|
|
5
5
|
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
|
|
6
6
|
padding: 4px;
|
|
7
|
-
min-width:
|
|
7
|
+
min-width: 330px;
|
|
8
8
|
max-height: 260px;
|
|
9
9
|
overflow-y: auto;
|
|
10
10
|
font-size: 14px;
|
|
11
|
-
color: ${
|
|
11
|
+
color: ${t.COLORS.content.primary};
|
|
12
12
|
`,a=o.default.div`
|
|
13
13
|
display: flex;
|
|
14
14
|
align-items: center;
|
|
15
15
|
gap: 8px;
|
|
16
|
-
padding:
|
|
16
|
+
padding: 12px 16px;
|
|
17
|
+
min-height: 43px;
|
|
17
18
|
border-radius: 6px;
|
|
18
19
|
cursor: pointer;
|
|
19
|
-
color: ${
|
|
20
|
-
background: ${e=>{let{$isActive:
|
|
21
|
-
|
|
22
|
-
&:hover {
|
|
23
|
-
background: ${r.COLORS.surface.hovered};
|
|
24
|
-
}
|
|
20
|
+
color: ${t.COLORS.content.primary};
|
|
21
|
+
background: ${e=>{let{$isActive:r}=e;return r?t.COLORS.surface.hovered:"transparent"}};
|
|
25
22
|
`,i=o.default.img`
|
|
26
23
|
width: 24px;
|
|
27
24
|
height: 24px;
|
|
@@ -30,19 +27,19 @@
|
|
|
30
27
|
flex-shrink: 0;
|
|
31
28
|
`,p=o.default.span`
|
|
32
29
|
font-weight: 500;
|
|
33
|
-
color: ${
|
|
30
|
+
color: ${t.COLORS.content.primary};
|
|
34
31
|
`,s=o.default.span`
|
|
35
32
|
width: 8px;
|
|
36
33
|
height: 8px;
|
|
37
34
|
border-radius: 50%;
|
|
38
|
-
background: ${e=>{let{$online:
|
|
35
|
+
background: ${e=>{let{$online:r}=e;return r?t.COLORS.content.positive:t.COLORS.content.placeholder}};
|
|
39
36
|
margin-left: auto;
|
|
40
37
|
flex-shrink: 0;
|
|
41
38
|
`,d=o.default.span`
|
|
42
39
|
font-weight: 500;
|
|
43
|
-
color: ${
|
|
44
|
-
`,
|
|
40
|
+
color: ${t.COLORS.content.primary};
|
|
41
|
+
`,l=o.default.span`
|
|
45
42
|
font-size: 12px;
|
|
46
|
-
color: ${
|
|
43
|
+
color: ${t.COLORS.content.secondary};
|
|
47
44
|
margin-left: auto;
|
|
48
|
-
`;exports.DropdownContainer=n,exports.DropdownItem=a,exports.MentionAvatar=i,exports.MentionLabel=p,exports.MentionPresenceDot=s,exports.SlashDescription=
|
|
45
|
+
`;exports.DropdownContainer=n,exports.DropdownItem=a,exports.MentionAvatar=i,exports.MentionLabel=p,exports.MentionPresenceDot=s,exports.SlashDescription=l,exports.SlashLabel=d;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),n=require("react"),r=require("../editorDropdown.styles.js");const t=n.forwardRef(((t,o)=>{let{items:i,query:s,command:l,renderItem:a,renderDropdown:d}=t;const[c,u]=n.useState(0),p=e=>{i[e]&&l(i[e])};return n.useImperativeHandle(o,(()=>({onKeyDown:e=>{let{event:n}=e;return"ArrowUp"===n.key?(u((e=>(e+i.length-1)%i.length)),!0):"ArrowDown"===n.key?(u((e=>(e+1)%i.length)),!0):"Enter"===n.key&&(p(c),!0)}}))),n.useEffect((()=>u(0)),[i]),i.length?d?e.jsx(e.Fragment,{children:d({items:i,query:s,activeIndex:c,onSelect:e=>l(e)})}):e.jsx(r.DropdownContainer,{children:i.map(((n,t)=>e.jsx(r.DropdownItem,Object.assign({$isActive:t===c,onClick:()=>p(t)},{children:a?a(n,t===c):e.jsxs(e.Fragment,{children:[n.avatarUrl&&e.jsx(r.MentionAvatar,{src:n.avatarUrl,alt:""}),e.jsx(r.MentionLabel,{children:n.label}),void 0!==n.isOnline&&e.jsx(r.MentionPresenceDot,{$online:n.isOnline})]})}),n.id)))}):null}));t.displayName="MentionDropdown",exports.MentionDropdown=t;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),n=require("react"),r=require("../editorDropdown.styles.js");const t=n.forwardRef(((t,o)=>{let{items:i,query:s,command:l,renderItem:a,renderDropdown:d}=t;const[c,u]=n.useState(0),p=e=>{i[e]&&l(i[e])};return n.useImperativeHandle(o,(()=>({onKeyDown:e=>{let{event:n}=e;return"ArrowUp"===n.key?(u((e=>(e+i.length-1)%i.length)),!0):"ArrowDown"===n.key?(u((e=>(e+1)%i.length)),!0):"Enter"===n.key&&(p(c),!0)}}))),n.useEffect((()=>u(0)),[i]),i.length?d?e.jsx(e.Fragment,{children:d({items:i,query:s,activeIndex:c,onSelect:e=>l(e)})}):e.jsx(r.DropdownContainer,{children:i.map(((n,t)=>e.jsx(r.DropdownItem,Object.assign({$isActive:t===c,onMouseEnter:()=>u(t),onClick:()=>p(t)},{children:a?a(n,t===c):e.jsxs(e.Fragment,{children:[n.avatarUrl&&e.jsx(r.MentionAvatar,{src:n.avatarUrl,alt:""}),e.jsx(r.MentionLabel,{children:n.label}),void 0!==n.isOnline&&e.jsx(r.MentionPresenceDot,{$online:n.isOnline})]})}),n.id)))}):null}));t.displayName="MentionDropdown",exports.MentionDropdown=t;
|
|
@@ -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
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),n=require("../editorDropdown.styles.js");const t=r.forwardRef(((t,s)=>{let{items:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),n=require("../editorDropdown.styles.js");const t=r.forwardRef(((t,s)=>{let{items:o,query:i,command:l,renderItem:a,renderDropdown:d}=t;const[c,u]=r.useState(0),m=e=>{o[e]&&l(o[e])};return r.useImperativeHandle(s,(()=>({onKeyDown:e=>{let{event:r}=e;return"ArrowUp"===r.key?(u((e=>(e+o.length-1)%o.length)),!0):"ArrowDown"===r.key?(u((e=>(e+1)%o.length)),!0):"Enter"===r.key&&(m(c),!0)}}))),r.useEffect((()=>u(0)),[o]),o.length?d?e.jsx(e.Fragment,{children:d({items:o,query:i,activeIndex:c,onSelect:e=>l(e)})}):e.jsx(n.DropdownContainer,{children:o.map(((r,t)=>e.jsx(n.DropdownItem,Object.assign({$isActive:t===c,onMouseEnter:()=>u(t),onClick:()=>m(t)},{children:a?a(r,t===c):e.jsxs(e.Fragment,{children:[e.jsx(n.SlashLabel,{children:r.label}),r.description&&e.jsx(n.SlashDescription,{children:r.description})]})}),r.id)))}):null}));t.displayName="SlashCommandMenu",exports.SlashCommandMenu=t;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function e(r){var a;if(r.nodeType===Node.TEXT_NODE)return null!==(a=r.textContent)&&void 0!==a?a:"";if(r.nodeType!==Node.ELEMENT_NODE)return"";const n=r,c=n.tagName.toLowerCase(),
|
|
1
|
+
"use strict";function e(r){var a;if(r.nodeType===Node.TEXT_NODE)return null!==(a=r.textContent)&&void 0!==a?a:"";if(r.nodeType!==Node.ELEMENT_NODE)return"";const n=r,c=n.tagName.toLowerCase(),t=function(r){return Array.from(r.childNodes).map(e).join("")}(n);switch(c){case"strong":case"b":return t?`*${t}*`:"";case"em":case"i":case"s":case"del":case"strike":case"code":case"pre":case"a":case"ul":case"ol":case"body":default:return t;case"br":return"\n";case"p":case"div":return t?`${t}\n`:"\n";case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return t?`*${t}*\n`:"\n";case"li":return`• ${t.trimEnd()}\n`;case"blockquote":return t+"\n"}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.toLiveChatText=function(r){if(!r)return"";if("undefined"!=typeof document){return e((new DOMParser).parseFromString(r,"text/html").body).replace(/\n{3,}/g,"\n\n").trim()}return function(e){return e.replace(/<strong[^>]*>([\s\S]*?)<\/strong>/gi,"*$1*").replace(/<b[^>]*>([\s\S]*?)<\/b>/gi,"*$1*").replace(/<em[^>]*>([\s\S]*?)<\/em>/gi,"$1").replace(/<i[^>]*>([\s\S]*?)<\/i>/gi,"$1").replace(/<s[^>]*>([\s\S]*?)<\/s>/gi,"$1").replace(/<del[^>]*>([\s\S]*?)<\/del>/gi,"$1").replace(/<a[^>]*>([\s\S]*?)<\/a>/gi,"$1").replace(/<br\s*\/?>/gi,"\n").replace(/<\/p>/gi,"\n").replace(/<\/div>/gi,"\n").replace(/<\/h[1-6]>/gi,"\n").replace(/<li[^>]*>/gi,"• ").replace(/<\/li>/gi,"\n").replace(/<[^>]+>/g,"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ").replace(/\n{3,}/g,"\n\n").trim()}(r)};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function e(r){var n,
|
|
1
|
+
"use strict";function e(r){var n,t;if(r.nodeType===Node.TEXT_NODE)return null!==(n=r.textContent)&&void 0!==n?n:"";if(r.nodeType!==Node.ELEMENT_NODE)return"";const a=r,c=a.tagName.toLowerCase(),s=function(r){return Array.from(r.childNodes).map(e).join("")}(a);switch(c){case"strong":case"b":return s?`*${s}*`:"";case"em":case"i":return s?`_${s}_`:"";case"s":case"del":case"strike":return s?`~${s}~`:"";case"code":return s?`\`${s}\``:"";case"pre":return s?`\`\`\`${s}\`\`\``:"";case"a":return(null!==(t=a.getAttribute("href"))&&void 0!==t?t:"")||s;case"br":return"\n";case"p":case"div":return s?`${s}\n`:"\n";case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return s?`*${s}*\n`:"\n";case"ul":case"ol":case"body":default:return s;case"li":return`• ${s.trimEnd()}\n`;case"blockquote":return s.split("\n").map((e=>e?`> ${e}`:"")).join("\n")+"\n"}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.toWhatsAppText=function(r){if(!r)return"";if("undefined"!=typeof document){return e((new DOMParser).parseFromString(r,"text/html").body).replace(/\n{3,}/g,"\n\n").trim()}return function(e){return e.replace(/<strong[^>]*>([\s\S]*?)<\/strong>/gi,"*$1*").replace(/<b[^>]*>([\s\S]*?)<\/b>/gi,"*$1*").replace(/<em[^>]*>([\s\S]*?)<\/em>/gi,"_$1_").replace(/<i[^>]*>([\s\S]*?)<\/i>/gi,"_$1_").replace(/<s[^>]*>([\s\S]*?)<\/s>/gi,"~$1~").replace(/<del[^>]*>([\s\S]*?)<\/del>/gi,"~$1~").replace(/<code[^>]*>([\s\S]*?)<\/code>/gi,"`$1`").replace(/<a[^>]*href="([^"]*)"[^>]*>[\s\S]*?<\/a>/gi,"$1").replace(/<br\s*\/?>/gi,"\n").replace(/<\/p>/gi,"\n").replace(/<\/div>/gi,"\n").replace(/<\/h[1-6]>/gi,"\n").replace(/<li[^>]*>/gi,"• ").replace(/<\/li>/gi,"\n").replace(/<[^>]+>/g,"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ").replace(/\n{3,}/g,"\n\n").trim()}(r)};
|
|
@@ -26,6 +26,17 @@ export interface EditorFeatures {
|
|
|
26
26
|
richPaste?: boolean;
|
|
27
27
|
/** Enable font family, font size, text alignment, highlight, subscript, superscript, and image. Default: `false`. */
|
|
28
28
|
richTypography?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Restrict which inline marks are active in the editor.
|
|
31
|
+
* When set, only the listed marks are registered — all others are disabled
|
|
32
|
+
* (no rendering, no keyboard shortcuts, no paste preservation).
|
|
33
|
+
* Omit to allow all marks (default).
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* // LiveChat: bold only, no italic / underline / strike
|
|
37
|
+
* features={{ allowedMarks: ['bold'] }}
|
|
38
|
+
*/
|
|
39
|
+
allowedMarks?: Array<'bold' | 'italic' | 'strike' | 'underline' | 'code'>;
|
|
29
40
|
}
|
|
30
41
|
/**
|
|
31
42
|
* A named content section placed below the main body, separated by an invisible divider.
|
|
@@ -478,6 +489,22 @@ export interface BikEditorRef {
|
|
|
478
489
|
getBodyContent: () => EditorSnapshot;
|
|
479
490
|
/** Shorthand for `setSectionContent('body', html)`. */
|
|
480
491
|
setBodyContent: (html: string) => void;
|
|
492
|
+
/**
|
|
493
|
+
* Atomically sets the body AND all sections in a single editor update.
|
|
494
|
+
* Sections are laid out in the exact order supplied — use this instead of
|
|
495
|
+
* multiple `setSectionContent()` calls whenever order matters (e.g. forward
|
|
496
|
+
* mail where signature must appear before the forwarded thread).
|
|
497
|
+
*
|
|
498
|
+
* @example
|
|
499
|
+
* ref.current?.setBodyAndSections('<p></p>', [
|
|
500
|
+
* { id: 'signature', content: '<p>Alice</p>' },
|
|
501
|
+
* { id: 'forwarded', content: '<p>--- Forwarded ---</p>' },
|
|
502
|
+
* ]);
|
|
503
|
+
*/
|
|
504
|
+
setBodyAndSections: (body: string, sections: Array<{
|
|
505
|
+
id: string;
|
|
506
|
+
content: string;
|
|
507
|
+
}>) => void;
|
|
481
508
|
/**
|
|
482
509
|
* Appends HTML to the end of the body section without moving the cursor.
|
|
483
510
|
* Ideal for streaming AI-generated content — call repeatedly with each chunk.
|
|
@@ -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
|
|
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:y,features:b,disabled:A,maxCharacters:j,shortcuts:L,sendShortcut:F,mentions:H,slashCommands:E,link:M,onPaste:O,onChange:T,onSend:w,onFocus:I,onBlur:U,onSelectionChange:R,minHeight:z,maxHeight:D,style:P,className:N,editorClassName:$,editorStyle:q}=l,V=(null==y?void 0:y.length)?d(c(null!=B?B:""),y.map((n=>Object.assign(Object.assign({},n),{content:c(n.content)})))):c(null!=B?B:""),W=o({extensions:C({features:b,placeholder:l.placeholder,maxCharacters:j,hasSections:(null!==(x=null==y?void 0:y.length)&&void 0!==x?x:0)>0,mentions:{agents:null==H?void 0:H.agents,teams:null==H?void 0:H.teams},slashCommands:null==E?void 0:E.items,onPaste:O,onSend:w,sendShortcut:F,shortcuts:L,onMentionSelected:null==H?void 0:H.onSelect,onSlashCommandSelected:null==E?void 0:E.onSelect,renderMentionItem:null==H?void 0:H.renderItem,renderMentionDropdown:null==H?void 0:H.renderDropdown,renderSlashCommandItem:null==E?void 0:E.renderItem,renderSlashCommandDropdown:null==E?void 0:E.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==T?void 0:T(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:()=>W?u(W):{html:"",text:"",isEmpty:!0,characterCount:0},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==M?void 0:M.renderTooltip})]})):null}));k.displayName="BikEditor";export{k as BikEditor};
|
|
@@ -14,12 +14,20 @@ import e from"styled-components";const o=e.div`
|
|
|
14
14
|
|
|
15
15
|
p {
|
|
16
16
|
margin: 0;
|
|
17
|
+
padding: 0;
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
|
|
20
|
+
ul,
|
|
21
|
+
ol {
|
|
22
|
+
margin: 0;
|
|
23
|
+
padding-left: 1.5em;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
li + li {
|
|
27
|
+
margin-top: 2px;
|
|
20
28
|
}
|
|
21
29
|
|
|
22
|
-
|
|
30
|
+
p.is-editor-empty:first-child::before {
|
|
23
31
|
content: attr(data-placeholder);
|
|
24
32
|
float: left;
|
|
25
33
|
color: #adb5bd;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
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 +1 @@
|
|
|
1
|
-
import o from"@tiptap/extension-character-count";import e from"@tiptap/extension-color";import
|
|
1
|
+
import o from"@tiptap/extension-character-count";import e from"@tiptap/extension-color";import t from"@tiptap/extension-font-family";import n from"@tiptap/extension-highlight";import i from"@tiptap/extension-image";import r from"@tiptap/extension-link";import s from"@tiptap/extension-placeholder";import a from"@tiptap/extension-subscript";import l from"@tiptap/extension-superscript";import m from"@tiptap/extension-text-align";import{TextStyle as p}from"@tiptap/extension-text-style";import d from"@tiptap/extension-underline";import u from"@tiptap/starter-kit";import{FontSizeExtension as c}from"./FontSizeExtension.js";import{buildAgentMentionExtension as f,buildTeamMentionExtension as h}from"./mention/MentionExtension.js";import{PasteExtension as x}from"./paste/PasteExtension.js";import{PlainClipboardExtension as v}from"./plainClipboard/PlainClipboardExtension.js";import{SectionDividerNode as g}from"./sectionDivider/SectionDividerNode.js";import{SendShortcutExtension as S}from"./sendShortcut/SendShortcutExtension.js";import{buildSlashCommandExtension as C}from"./slashCommand/SlashCommandExtension.js";import{VariableDecorationExtension as k}from"./variable/VariableDecorationExtension.js";function b(b){var M,j,P,E,y,D,w,I,T,O,R,z;const A=null!==(j=null===(M=b.features)||void 0===M?void 0:M.richPaste)&&void 0!==j&&j,F=null!==(E=null===(P=b.features)||void 0===P?void 0:P.richTypography)&&void 0!==E&&E,H=null===(y=b.features)||void 0===y?void 0:y.allowedMarks,L=o=>!H||H.includes(o);return[...[u.configure({link:!1,underline:!1,bold:!!L("bold")&&{},italic:!!L("italic")&&{},strike:!!L("strike")&&{},code:!!L("code")&&{}}),...L("underline")?[d]:[],r.extend({addPasteRules:()=>[],addInputRules:()=>[]}).configure({openOnClick:!1,autolink:!1,linkOnPaste:!1,HTMLAttributes:{rel:"noopener noreferrer",class:"bik-link"}}),p,s.configure({placeholder:null!==(D=b.placeholder)&&void 0!==D?D:"Type a message..."}),...b.onPaste?[x.configure({onPaste:b.onPaste})]:[],...A?[]:[v],S.configure({onSend:b.onSend,sendShortcut:b.sendShortcut,extraShortcuts:null!==(w=b.shortcuts)&&void 0!==w?w:[]}),k,...b.maxCharacters?[o.configure({limit:b.maxCharacters})]:[],g],...[...(null===(T=null===(I=b.mentions)||void 0===I?void 0:I.agents)||void 0===T?void 0:T.length)?[f(b.mentions.agents,b.onMentionSelected,b.renderMentionItem,b.renderMentionDropdown)]:[],...(null===(R=null===(O=b.mentions)||void 0===O?void 0:O.teams)||void 0===R?void 0:R.length)?[h(b.mentions.teams,b.onMentionSelected,b.renderMentionItem,b.renderMentionDropdown)]:[],...(null===(z=b.slashCommands)||void 0===z?void 0:z.length)?[C(b.slashCommands,b.onSlashCommandSelected,b.renderSlashCommandItem,b.renderSlashCommandDropdown)]:[]],...F?[e,n.configure({multicolor:!0}),t,c,m.configure({types:["heading","paragraph"]}),a,l,i]:[e]]}export{b as buildExtensions};
|
|
@@ -1,27 +1,24 @@
|
|
|
1
|
-
import r from"styled-components";import{COLORS as o}from"../../constants/Theme.js";const
|
|
1
|
+
import r from"styled-components";import{COLORS as o}from"../../constants/Theme.js";const t=r.div`
|
|
2
2
|
background: ${o.surface.standard};
|
|
3
3
|
border: 1px solid ${o.stroke.primary};
|
|
4
4
|
border-radius: 8px;
|
|
5
5
|
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
|
|
6
6
|
padding: 4px;
|
|
7
|
-
min-width:
|
|
7
|
+
min-width: 330px;
|
|
8
8
|
max-height: 260px;
|
|
9
9
|
overflow-y: auto;
|
|
10
10
|
font-size: 14px;
|
|
11
11
|
color: ${o.content.primary};
|
|
12
|
-
`,
|
|
12
|
+
`,e=r.div`
|
|
13
13
|
display: flex;
|
|
14
14
|
align-items: center;
|
|
15
15
|
gap: 8px;
|
|
16
|
-
padding:
|
|
16
|
+
padding: 12px 16px;
|
|
17
|
+
min-height: 43px;
|
|
17
18
|
border-radius: 6px;
|
|
18
19
|
cursor: pointer;
|
|
19
20
|
color: ${o.content.primary};
|
|
20
|
-
background: ${r=>{let{$isActive:
|
|
21
|
-
|
|
22
|
-
&:hover {
|
|
23
|
-
background: ${o.surface.hovered};
|
|
24
|
-
}
|
|
21
|
+
background: ${r=>{let{$isActive:t}=r;return t?o.surface.hovered:"transparent"}};
|
|
25
22
|
`,n=r.img`
|
|
26
23
|
width: 24px;
|
|
27
24
|
height: 24px;
|
|
@@ -31,18 +28,18 @@ import r from"styled-components";import{COLORS as o}from"../../constants/Theme.j
|
|
|
31
28
|
`,i=r.span`
|
|
32
29
|
font-weight: 500;
|
|
33
30
|
color: ${o.content.primary};
|
|
34
|
-
`,
|
|
31
|
+
`,p=r.span`
|
|
35
32
|
width: 8px;
|
|
36
33
|
height: 8px;
|
|
37
34
|
border-radius: 50%;
|
|
38
|
-
background: ${r=>{let{$online:
|
|
35
|
+
background: ${r=>{let{$online:t}=r;return t?o.content.positive:o.content.placeholder}};
|
|
39
36
|
margin-left: auto;
|
|
40
37
|
flex-shrink: 0;
|
|
41
|
-
`,
|
|
38
|
+
`,a=r.span`
|
|
42
39
|
font-weight: 500;
|
|
43
40
|
color: ${o.content.primary};
|
|
44
|
-
`,
|
|
41
|
+
`,s=r.span`
|
|
45
42
|
font-size: 12px;
|
|
46
43
|
color: ${o.content.secondary};
|
|
47
44
|
margin-left: auto;
|
|
48
|
-
`;export{
|
|
45
|
+
`;export{t as DropdownContainer,e as DropdownItem,n as MentionAvatar,i as MentionLabel,p as MentionPresenceDot,s as SlashDescription,a as SlashLabel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,Fragment as
|
|
1
|
+
import{jsx as e,Fragment as n,jsxs as r}from"react/jsx-runtime";import{forwardRef as t,useState as o,useImperativeHandle as i,useEffect as l}from"react";import{DropdownContainer as a,DropdownItem as c,MentionAvatar as d,MentionLabel as s,MentionPresenceDot as m}from"../editorDropdown.styles.js";const p=t(((t,p)=>{let{items:h,query:y,command:u,renderItem:w,renderDropdown:v}=t;const[g,D]=o(0),k=e=>{h[e]&&u(h[e])};return i(p,(()=>({onKeyDown:e=>{let{event:n}=e;return"ArrowUp"===n.key?(D((e=>(e+h.length-1)%h.length)),!0):"ArrowDown"===n.key?(D((e=>(e+1)%h.length)),!0):"Enter"===n.key&&(k(g),!0)}}))),l((()=>D(0)),[h]),h.length?v?e(n,{children:v({items:h,query:y,activeIndex:g,onSelect:e=>u(e)})}):e(a,{children:h.map(((t,o)=>e(c,Object.assign({$isActive:o===g,onMouseEnter:()=>D(o),onClick:()=>k(o)},{children:w?w(t,o===g):r(n,{children:[t.avatarUrl&&e(d,{src:t.avatarUrl,alt:""}),e(s,{children:t.label}),void 0!==t.isOnline&&e(m,{$online:t.isOnline})]})}),t.id)))}):null}));p.displayName="MentionDropdown";export{p as MentionDropdown};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Node as
|
|
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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,Fragment as r,jsxs as n}from"react/jsx-runtime";import{forwardRef as t,useState as o,useImperativeHandle as i,useEffect as l}from"react";import{DropdownContainer as c,DropdownItem as d,SlashLabel as m,SlashDescription as s}from"../editorDropdown.styles.js";const a=t(((t,a)=>{let{items:h,query:p,command:
|
|
1
|
+
import{jsx as e,Fragment as r,jsxs as n}from"react/jsx-runtime";import{forwardRef as t,useState as o,useImperativeHandle as i,useEffect as l}from"react";import{DropdownContainer as c,DropdownItem as d,SlashLabel as m,SlashDescription as s}from"../editorDropdown.styles.js";const a=t(((t,a)=>{let{items:h,query:p,command:u,renderItem:y,renderDropdown:w}=t;const[g,k]=o(0),D=e=>{h[e]&&u(h[e])};return i(a,(()=>({onKeyDown:e=>{let{event:r}=e;return"ArrowUp"===r.key?(k((e=>(e+h.length-1)%h.length)),!0):"ArrowDown"===r.key?(k((e=>(e+1)%h.length)),!0):"Enter"===r.key&&(D(g),!0)}}))),l((()=>k(0)),[h]),h.length?w?e(r,{children:w({items:h,query:p,activeIndex:g,onSelect:e=>u(e)})}):e(c,{children:h.map(((t,o)=>e(d,Object.assign({$isActive:o===g,onMouseEnter:()=>k(o),onClick:()=>D(o)},{children:y?y(t,o===g):n(r,{children:[e(m,{children:t.label}),t.description&&e(s,{children:t.description})]})}),t.id)))}):null}));a.displayName="SlashCommandMenu";export{a as SlashCommandMenu};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e){if(!e)return"";if("undefined"!=typeof document){return r((new DOMParser).parseFromString(e,"text/html").body).replace(/\n{3,}/g,"\n\n").trim()}return function(e){return e.replace(/<strong[^>]*>([\s\S]*?)<\/strong>/gi,"*$1*").replace(/<b[^>]*>([\s\S]*?)<\/b>/gi,"*$1*").replace(/<em[^>]*>([\s\S]*?)<\/em>/gi,"$1").replace(/<i[^>]*>([\s\S]*?)<\/i>/gi,"$1").replace(/<s[^>]*>([\s\S]*?)<\/s>/gi,"$1").replace(/<del[^>]*>([\s\S]*?)<\/del>/gi,"$1").replace(/<a[^>]*>([\s\S]*?)<\/a>/gi,"$1").replace(/<br\s*\/?>/gi,"\n").replace(/<\/p>/gi,"\n").replace(/<\/div>/gi,"\n").replace(/<\/h[1-6]>/gi,"\n").replace(/<li[^>]*>/gi,"• ").replace(/<\/li>/gi,"\n").replace(/<[^>]+>/g,"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ").replace(/\n{3,}/g,"\n\n").trim()}(e)}function r(e){var a;if(e.nodeType===Node.TEXT_NODE)return null!==(a=e.textContent)&&void 0!==a?a:"";if(e.nodeType!==Node.ELEMENT_NODE)return"";const n=e,c=n.tagName.toLowerCase(),s=function(e){return Array.from(e.childNodes).map(r).join("")}(n);switch(c){case"strong":case"b":return s?`*${s}*`:"";case"em":case"i":case"s":case"del":case"strike":case"code":case"pre":case"a":case"ul":case"ol":case"body":default:return s;case"br":return"\n";case"p":case"div":return s?`${s}\n`:"\n";case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return s?`*${s}*\n`:"\n";case"li":return`• ${s}\n`;case"blockquote":return s+"\n"}}export{e as toLiveChatText};
|
|
1
|
+
function e(e){if(!e)return"";if("undefined"!=typeof document){return r((new DOMParser).parseFromString(e,"text/html").body).replace(/\n{3,}/g,"\n\n").trim()}return function(e){return e.replace(/<strong[^>]*>([\s\S]*?)<\/strong>/gi,"*$1*").replace(/<b[^>]*>([\s\S]*?)<\/b>/gi,"*$1*").replace(/<em[^>]*>([\s\S]*?)<\/em>/gi,"$1").replace(/<i[^>]*>([\s\S]*?)<\/i>/gi,"$1").replace(/<s[^>]*>([\s\S]*?)<\/s>/gi,"$1").replace(/<del[^>]*>([\s\S]*?)<\/del>/gi,"$1").replace(/<a[^>]*>([\s\S]*?)<\/a>/gi,"$1").replace(/<br\s*\/?>/gi,"\n").replace(/<\/p>/gi,"\n").replace(/<\/div>/gi,"\n").replace(/<\/h[1-6]>/gi,"\n").replace(/<li[^>]*>/gi,"• ").replace(/<\/li>/gi,"\n").replace(/<[^>]+>/g,"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ").replace(/\n{3,}/g,"\n\n").trim()}(e)}function r(e){var a;if(e.nodeType===Node.TEXT_NODE)return null!==(a=e.textContent)&&void 0!==a?a:"";if(e.nodeType!==Node.ELEMENT_NODE)return"";const n=e,c=n.tagName.toLowerCase(),s=function(e){return Array.from(e.childNodes).map(r).join("")}(n);switch(c){case"strong":case"b":return s?`*${s}*`:"";case"em":case"i":case"s":case"del":case"strike":case"code":case"pre":case"a":case"ul":case"ol":case"body":default:return s;case"br":return"\n";case"p":case"div":return s?`${s}\n`:"\n";case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return s?`*${s}*\n`:"\n";case"li":return`• ${s.trimEnd()}\n`;case"blockquote":return s+"\n"}}export{e as toLiveChatText};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e){if(!e)return"";if("undefined"!=typeof document){return r((new DOMParser).parseFromString(e,"text/html").body).replace(/\n{3,}/g,"\n\n").trim()}return function(e){return e.replace(/<strong[^>]*>([\s\S]*?)<\/strong>/gi,"*$1*").replace(/<b[^>]*>([\s\S]*?)<\/b>/gi,"*$1*").replace(/<em[^>]*>([\s\S]*?)<\/em>/gi,"_$1_").replace(/<i[^>]*>([\s\S]*?)<\/i>/gi,"_$1_").replace(/<s[^>]*>([\s\S]*?)<\/s>/gi,"~$1~").replace(/<del[^>]*>([\s\S]*?)<\/del>/gi,"~$1~").replace(/<code[^>]*>([\s\S]*?)<\/code>/gi,"`$1`").replace(/<a[^>]*href="([^"]*)"[^>]*>[\s\S]*?<\/a>/gi,"$1").replace(/<br\s*\/?>/gi,"\n").replace(/<\/p>/gi,"\n").replace(/<\/div>/gi,"\n").replace(/<\/h[1-6]>/gi,"\n").replace(/<li[^>]*>/gi,"• ").replace(/<\/li>/gi,"\n").replace(/<[^>]+>/g,"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ").replace(/\n{3,}/g,"\n\n").trim()}(e)}function r(e){var n,a;if(e.nodeType===Node.TEXT_NODE)return null!==(n=e.textContent)&&void 0!==n?n:"";if(e.nodeType!==Node.ELEMENT_NODE)return"";const c=e,t=c.tagName.toLowerCase(),s=function(e){return Array.from(e.childNodes).map(r).join("")}(c);switch(t){case"strong":case"b":return s?`*${s}*`:"";case"em":case"i":return s?`_${s}_`:"";case"s":case"del":case"strike":return s?`~${s}~`:"";case"code":return s?`\`${s}\``:"";case"pre":return s?`\`\`\`${s}\`\`\``:"";case"a":return(null!==(a=c.getAttribute("href"))&&void 0!==a?a:"")||s;case"br":return"\n";case"p":case"div":return s?`${s}\n`:"\n";case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return s?`*${s}*\n`:"\n";case"ul":case"ol":case"body":default:return s;case"li":return`• ${s}\n`;case"blockquote":return s.split("\n").map((e=>e?`> ${e}`:"")).join("\n")+"\n"}}export{e as toWhatsAppText};
|
|
1
|
+
function e(e){if(!e)return"";if("undefined"!=typeof document){return r((new DOMParser).parseFromString(e,"text/html").body).replace(/\n{3,}/g,"\n\n").trim()}return function(e){return e.replace(/<strong[^>]*>([\s\S]*?)<\/strong>/gi,"*$1*").replace(/<b[^>]*>([\s\S]*?)<\/b>/gi,"*$1*").replace(/<em[^>]*>([\s\S]*?)<\/em>/gi,"_$1_").replace(/<i[^>]*>([\s\S]*?)<\/i>/gi,"_$1_").replace(/<s[^>]*>([\s\S]*?)<\/s>/gi,"~$1~").replace(/<del[^>]*>([\s\S]*?)<\/del>/gi,"~$1~").replace(/<code[^>]*>([\s\S]*?)<\/code>/gi,"`$1`").replace(/<a[^>]*href="([^"]*)"[^>]*>[\s\S]*?<\/a>/gi,"$1").replace(/<br\s*\/?>/gi,"\n").replace(/<\/p>/gi,"\n").replace(/<\/div>/gi,"\n").replace(/<\/h[1-6]>/gi,"\n").replace(/<li[^>]*>/gi,"• ").replace(/<\/li>/gi,"\n").replace(/<[^>]+>/g,"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/ /g," ").replace(/\n{3,}/g,"\n\n").trim()}(e)}function r(e){var n,a;if(e.nodeType===Node.TEXT_NODE)return null!==(n=e.textContent)&&void 0!==n?n:"";if(e.nodeType!==Node.ELEMENT_NODE)return"";const c=e,t=c.tagName.toLowerCase(),s=function(e){return Array.from(e.childNodes).map(r).join("")}(c);switch(t){case"strong":case"b":return s?`*${s}*`:"";case"em":case"i":return s?`_${s}_`:"";case"s":case"del":case"strike":return s?`~${s}~`:"";case"code":return s?`\`${s}\``:"";case"pre":return s?`\`\`\`${s}\`\`\``:"";case"a":return(null!==(a=c.getAttribute("href"))&&void 0!==a?a:"")||s;case"br":return"\n";case"p":case"div":return s?`${s}\n`:"\n";case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":return s?`*${s}*\n`:"\n";case"ul":case"ol":case"body":default:return s;case"li":return`• ${s.trimEnd()}\n`;case"blockquote":return s.split("\n").map((e=>e?`> ${e}`:"")).join("\n")+"\n"}}export{e as toWhatsAppText};
|
|
@@ -26,6 +26,17 @@ export interface EditorFeatures {
|
|
|
26
26
|
richPaste?: boolean;
|
|
27
27
|
/** Enable font family, font size, text alignment, highlight, subscript, superscript, and image. Default: `false`. */
|
|
28
28
|
richTypography?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Restrict which inline marks are active in the editor.
|
|
31
|
+
* When set, only the listed marks are registered — all others are disabled
|
|
32
|
+
* (no rendering, no keyboard shortcuts, no paste preservation).
|
|
33
|
+
* Omit to allow all marks (default).
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* // LiveChat: bold only, no italic / underline / strike
|
|
37
|
+
* features={{ allowedMarks: ['bold'] }}
|
|
38
|
+
*/
|
|
39
|
+
allowedMarks?: Array<'bold' | 'italic' | 'strike' | 'underline' | 'code'>;
|
|
29
40
|
}
|
|
30
41
|
/**
|
|
31
42
|
* A named content section placed below the main body, separated by an invisible divider.
|
|
@@ -478,6 +489,22 @@ export interface BikEditorRef {
|
|
|
478
489
|
getBodyContent: () => EditorSnapshot;
|
|
479
490
|
/** Shorthand for `setSectionContent('body', html)`. */
|
|
480
491
|
setBodyContent: (html: string) => void;
|
|
492
|
+
/**
|
|
493
|
+
* Atomically sets the body AND all sections in a single editor update.
|
|
494
|
+
* Sections are laid out in the exact order supplied — use this instead of
|
|
495
|
+
* multiple `setSectionContent()` calls whenever order matters (e.g. forward
|
|
496
|
+
* mail where signature must appear before the forwarded thread).
|
|
497
|
+
*
|
|
498
|
+
* @example
|
|
499
|
+
* ref.current?.setBodyAndSections('<p></p>', [
|
|
500
|
+
* { id: 'signature', content: '<p>Alice</p>' },
|
|
501
|
+
* { id: 'forwarded', content: '<p>--- Forwarded ---</p>' },
|
|
502
|
+
* ]);
|
|
503
|
+
*/
|
|
504
|
+
setBodyAndSections: (body: string, sections: Array<{
|
|
505
|
+
id: string;
|
|
506
|
+
content: string;
|
|
507
|
+
}>) => void;
|
|
481
508
|
/**
|
|
482
509
|
* Appends HTML to the end of the body section without moving the cursor.
|
|
483
510
|
* Ideal for streaming AI-generated content — call repeatedly with each chunk.
|
|
@@ -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.
|