@bikdotai/bik-component-library 0.0.795-beta.1 → 0.0.795-beta.2
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 +7 -14
- package/dist/cjs/src/editor/BikEditor.types.d.ts +11 -2
- package/dist/esm/editor/BikEditor.js +1 -1
- package/dist/esm/editor/BikEditor.styles.js +7 -14
- package/dist/esm/src/editor/BikEditor.types.d.ts +11 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react/jsx-runtime"),e=require("../node_modules/@tiptap/core/dist/index.js"),n=require("@tiptap/react"),o=require("react"),i=require("./BikEditor.styles.js"),r=require("./BikEditor.types.js"),l=require("./BikEditor.utils.js"),s=require("./extensions/buildExtensions.js"),c=require("./floating/LinkBubbleMenu.js");function
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("react/jsx-runtime"),e=require("../node_modules/@tiptap/core/dist/index.js"),n=require("@tiptap/react"),o=require("react"),i=require("./BikEditor.styles.js"),r=require("./BikEditor.types.js"),l=require("./BikEditor.utils.js"),s=require("./extensions/buildExtensions.js"),c=require("./floating/LinkBubbleMenu.js");function a(t){return Object.entries(t).map((t=>{let[e,n]=t;return`${e.replace(/([A-Z])/g,(t=>`-${t.toLowerCase()}`))}:${n}`})).join(";")}const u=(u,d)=>{var m;const{initialContent:g,sections:v,features:h,disabled:f,maxCharacters:C,shortcuts:S,sendShortcut:p,mentions:x,slashCommands:k,link:y,onPaste:b,onReady:A,onChange:H,onSend:B,onFocus:E,onBlur:z,onSelectionChange:j,minHeight:I,maxHeight:R,style:L,className:F,editorClassName:M,editorStyle:T}=u,O=(null==v?void 0:v.length)?l.buildSectionedContent(l.normalizeHtml(null!=g?g:""),v.map((t=>Object.assign(Object.assign({},t),{content:l.normalizeHtml(t.content)})))):l.normalizeHtml(null!=g?g:""),q=o.useRef([]),w=o.useRef(!1),P=o.useRef(A);P.current=A;const U=o.useRef(H);U.current=H;const D=o.useRef(j);D.current=j;const N=o.useRef(E);N.current=E;const _=o.useRef(z);_.current=z;const $=n.useEditor({extensions:s.buildExtensions({features:h,placeholder:u.placeholder,maxCharacters:C,hasSections:(null!==(m=null==v?void 0:v.length)&&void 0!==m?m:0)>0,mentions:{agents:null==x?void 0:x.agents,teams:null==x?void 0:x.teams},slashCommands:null==k?void 0:k.items,onPaste:b,onSend:B,sendShortcut:p,shortcuts:S,onMentionSelected:null==x?void 0:x.onSelect,onSlashCommandSelected:null==k?void 0:k.onSelect,renderMentionItem:null==x?void 0:x.renderItem,renderMentionDropdown:null==x?void 0:x.renderDropdown,renderSlashCommandItem:null==k?void 0:k.renderItem,renderSlashCommandDropdown:null==k?void 0:k.renderDropdown}),content:O,editable:!f,immediatelyRender:!1,editorProps:{attributes:Object.assign(Object.assign({},M?{class:M}:{}),T?{style:a(T)}:{})},onUpdate:t=>{let{editor:e}=t;var n,o;null===(n=U.current)||void 0===n||n.call(U,l.extractContent(e)),null===(o=D.current)||void 0===o||o.call(D,l.extractActiveFormats(e))},onSelectionUpdate:t=>{let{editor:e}=t;var n;return null===(n=D.current)||void 0===n?void 0:n.call(D,l.extractActiveFormats(e))},onFocus:()=>{var t;return null===(t=N.current)||void 0===t?void 0:t.call(N)},onBlur:()=>{var t;return null===(t=_.current)||void 0===t?void 0:t.call(_)}});function J(t){$?t($):q.current.push(t)}return o.useEffect((()=>{var t;if($){if(q.current.length>0){q.current.splice(0).forEach((t=>t($)))}w.current||(w.current=!0,null===(t=P.current)||void 0===t||t.call(P))}}),[$]),o.useImperativeHandle(d,(()=>({focus:()=>J((t=>t.commands.focus())),blur:()=>J((t=>t.commands.blur())),clearContent:()=>J((t=>t.commands.clearContent(!0))),setContent:t=>{const e=l.normalizeHtml(t);J((t=>t.commands.setContent(e,{emitUpdate:!0})))},insertContent:t=>{const e=l.normalizeHtml(t);J((t=>t.commands.insertContent(e)))},insertAtStart:t=>{const e=l.normalizeHtml(t);J((t=>t.commands.insertContentAt(1,e)))},insertAtEnd:t=>{const e=l.normalizeHtml(t);J((t=>t.commands.insertContentAt(t.state.doc.content.size,e)))},appendContent:t=>{const e=l.normalizeHtml(t);J((t=>t.commands.insertContentAt(t.state.doc.content.size-1,e)))},getContent:()=>$?l.extractContent($):{html:"",text:"",isEmpty:!0,characterCount:0},getJSON:()=>{var t;return null!==(t=null==$?void 0:$.getJSON())&&void 0!==t?t:null},getMentions:()=>{const t=new Set,e=new Set;return $?($.state.doc.descendants((n=>{"mentionAgent"===n.type.name&&null!=n.attrs.id?t.add(String(n.attrs.id)):"mentionTeam"===n.type.name&&null!=n.attrs.id&&e.add(String(n.attrs.id))})),{agentIds:Array.from(t),teamIds:Array.from(e)}):{agentIds:[],teamIds:[]}},getCursorPosition:()=>{const{from:t,to:e}=$.state.selection;return{from:t,to:e}},insertAtPosition:(t,e)=>{const n=l.normalizeHtml(e);J((e=>e.commands.insertContentAt(t,n)))},getSelectedText:()=>{const{state:t}=$,{from:n,to:o,empty:i}=t.selection;if(!i)return t.doc.textBetween(n,o," ");const r=t.schema.marks.link;if(r){const o=e.getMarkRange(t.doc.resolve(n),r);if(o)return t.doc.textBetween(o.from,o.to," ")}return""},getCharacterCount:()=>{var t,e,n,o;return{count:null!==(o=null!==(n=null===(e=null===(t=null==$?void 0:$.storage.characterCount)||void 0===t?void 0:t.characters)||void 0===e?void 0:e.call(t))&&void 0!==n?n:null==$?void 0:$.getText().length)&&void 0!==o?o:0,limit:null!=C?C:null}},getSectionContent:t=>l.extractSectionContent($,t),setSectionContent:(t,e)=>{const n=l.normalizeHtml(e);J((e=>l.setSectionContentInEditor(e,t,n)))},focusSection:t=>{J((e=>{if("body"===t)return void e.chain().focus().setTextSelection(1).run();let n=-1;e.state.doc.descendants(((e,o)=>{if(-1!==n)return!1;"sectionDivider"===e.type.name&&e.attrs.sectionId===t&&(n=o+e.nodeSize+1)})),-1!==n&&e.chain().focus().setTextSelection(n).run()}))},clearSection:t=>{J((e=>l.setSectionContentInEditor(e,t,"<p></p>")))},getBodyContent:()=>l.extractBodyContent($),setBodyContent:t=>{const e=l.normalizeHtml(t);J((t=>l.setSectionContentInEditor(t,"body",e)))},setBodyAndSections:(t,e)=>{const n=l.buildSectionedContent(l.normalizeHtml(t),e.map((t=>({id:t.id,content:l.normalizeHtml(t.content)}))));J((t=>t.commands.setContent(n,{emitUpdate:!0})))},appendBodyContent:t=>{const e=l.normalizeHtml(t);J((t=>{const n=l.findSectionEndPos(t,"body");t.commands.insertContentAt(n-1,e)}))},insertAtSectionStart:(t,e)=>{const n=l.normalizeHtml(e);J((e=>{const o=l.findSectionStartPos(e,t);-1!==o&&e.commands.insertContentAt(o,n)}))},insertAtSectionEnd:(t,e)=>{const n=l.normalizeHtml(e);J((e=>{const o=l.findSectionEndPos(e,t);e.commands.insertContentAt(o,n)}))},getActiveFormats:()=>$?l.extractActiveFormats($):r.DEFAULT_FORMAT_STATE,actions:{toggleBold:()=>null==$?void 0:$.chain().focus().toggleBold().run(),toggleItalic:()=>null==$?void 0:$.chain().focus().toggleItalic().run(),toggleUnderline:()=>null==$?void 0:$.chain().focus().toggleUnderline().run(),toggleStrike:()=>null==$?void 0:$.chain().focus().toggleStrike().run(),toggleBulletList:()=>null==$?void 0:$.chain().focus().toggleBulletList().run(),toggleOrderedList:()=>null==$?void 0:$.chain().focus().toggleOrderedList().run(),toggleBlockquote:()=>null==$?void 0:$.chain().focus().toggleBlockquote().run(),toggleCodeBlock:()=>null==$?void 0:$.chain().focus().toggleCodeBlock().run(),setTextAlign:t=>null==$?void 0:$.chain().focus().setTextAlign(t).run(),setFontFamily:t=>null==$?void 0:$.chain().focus().setFontFamily(t).run(),setFontSize:t=>null==$?void 0:$.chain().focus().setFontSize(t).run(),setColor:t=>null==$?void 0:$.chain().focus().setColor(t).run(),setHighlight:t=>null==$?void 0:$.chain().focus().toggleHighlight({color:t}).run(),unsetColor:()=>null==$?void 0:$.chain().focus().unsetColor().run(),unsetHighlight:()=>null==$?void 0:$.chain().focus().unsetHighlight().run(),setLink:(t,e)=>{$&&(void 0!==e?$.chain().focus().extendMarkRange("link").command((n=>{let{tr:o,state:i}=n;const{from:r,to:l}=o.selection,s=i.schema.marks.link;return!!s&&(o.replaceWith(r,l,i.schema.text(e,[s.create({href:t})])),!0)})).run():$.chain().focus().extendMarkRange("link").setLink({href:t}).run())},updateLink:t=>null==$?void 0:$.chain().focus().extendMarkRange("link").setLink({href:t}).run(),removeLink:()=>null==$?void 0:$.chain().focus().extendMarkRange("link").unsetLink().run(),insertEmoji:t=>null==$?void 0:$.chain().focus().insertContent(t).run(),insertVariable:t=>null==$?void 0:$.chain().focus().insertContent(`{{${t}}}`).run(),insertHtml:t=>null==$?void 0:$.commands.insertContent(t),undo:()=>null==$?void 0:$.chain().focus().undo().run(),redo:()=>null==$?void 0:$.chain().focus().redo().run(),canUndo:()=>{var t;return null!==(t=null==$?void 0:$.can().undo())&&void 0!==t&&t},canRedo:()=>{var t;return null!==(t=null==$?void 0:$.can().redo())&&void 0!==t&&t},toggleSuperscript:()=>null==$?void 0:$.chain().focus().toggleSuperscript().run(),toggleSubscript:()=>null==$?void 0:$.chain().focus().toggleSubscript().run(),insertImage:t=>null==$?void 0:$.chain().focus().setImage({src:t}).run()}})),[$]),$?t.jsxs(i.BikEditorShell,Object.assign({minHeight:I,maxHeight:R,style:L,className:F},{children:[t.jsx(n.EditorContent,{editor:$}),t.jsx(c.LinkBubbleMenu,{editor:$,renderLinkTooltip:null==y?void 0:y.renderTooltip})]})):null},d=o.forwardRef(u);d.displayName="BikEditor",exports.BikEditor=d;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("styled-components"),t=require("../constants/Theme.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}const n=o(e).default.div`
|
|
2
2
|
position: relative;
|
|
3
3
|
width: 100%;
|
|
4
4
|
|
|
5
5
|
.ProseMirror {
|
|
6
|
-
min-height: ${e=>{let{minHeight:
|
|
7
|
-
max-height: ${e=>{let{maxHeight:
|
|
6
|
+
min-height: ${e=>{let{minHeight:t}=e;return null!=t?t:"80px"}};
|
|
7
|
+
max-height: ${e=>{let{maxHeight:t}=e;return null!=t?t:"none"}};
|
|
8
8
|
overflow-y: auto;
|
|
9
9
|
outline: none;
|
|
10
10
|
padding: 8px 12px;
|
|
@@ -37,22 +37,15 @@
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
.bik-mention {
|
|
40
|
-
|
|
41
|
-
color: #731DCF;
|
|
42
|
-
border-radius: 4px;
|
|
40
|
+
color: ${t.COLORS.content.brand};
|
|
43
41
|
padding: 1px 4px;
|
|
44
|
-
font-weight: 500;
|
|
45
42
|
}
|
|
46
43
|
.bik-mention--team {
|
|
47
|
-
|
|
48
|
-
color: #731DCF;
|
|
44
|
+
color: ${t.COLORS.content.brand};
|
|
49
45
|
}
|
|
50
46
|
.bik-variable {
|
|
51
|
-
|
|
52
|
-
color: #4f46e5;
|
|
53
|
-
border-radius: 3px;
|
|
47
|
+
color: ${t.COLORS.content.brand};
|
|
54
48
|
padding: 1px 3px;
|
|
55
|
-
font-family: monospace;
|
|
56
49
|
}
|
|
57
50
|
|
|
58
51
|
a,
|
|
@@ -67,4 +60,4 @@
|
|
|
67
60
|
text-decoration-color: #6366f1;
|
|
68
61
|
}
|
|
69
62
|
}
|
|
70
|
-
`;exports.BikEditorShell=
|
|
63
|
+
`;exports.BikEditorShell=n;
|
|
@@ -432,11 +432,20 @@ export interface BikEditorRef {
|
|
|
432
432
|
getContent: () => EditorSnapshot;
|
|
433
433
|
/**
|
|
434
434
|
* Returns the raw TipTap document as a plain JSON object.
|
|
435
|
-
* Useful for traversing node attributes (e.g. extracting mention IDs)
|
|
436
|
-
* without parsing the serialised HTML.
|
|
437
435
|
* Returns `null` when the editor is not yet mounted.
|
|
438
436
|
*/
|
|
439
437
|
getJSON: () => Record<string, unknown> | null;
|
|
438
|
+
/**
|
|
439
|
+
* Walks the document and returns all mention IDs currently in the editor,
|
|
440
|
+
* split by type. IDs are deduplicated and returned as arrays.
|
|
441
|
+
*
|
|
442
|
+
* @example
|
|
443
|
+
* const { agentIds, teamIds } = ref.current?.getMentions() ?? { agentIds: [], teamIds: [] };
|
|
444
|
+
*/
|
|
445
|
+
getMentions: () => {
|
|
446
|
+
agentIds: string[];
|
|
447
|
+
teamIds: string[];
|
|
448
|
+
};
|
|
440
449
|
/**
|
|
441
450
|
* Returns the current cursor / selection position as a `{ from, to }` pair.
|
|
442
451
|
* When nothing is selected, `from === to` (a collapsed cursor).
|
|
@@ -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
|
|
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 r}from"@tiptap/react";import{forwardRef as i,useRef as l,useEffect as s,useImperativeHandle as c}from"react";import{BikEditorShell as u}from"./BikEditor.styles.js";import{DEFAULT_FORMAT_STATE as a}from"./BikEditor.types.js";import{buildSectionedContent as d,normalizeHtml as m,extractContent as g,extractActiveFormats as v,extractSectionContent as h,extractBodyContent as f,setSectionContentInEditor as p,findSectionEndPos as C,findSectionStartPos as S}from"./BikEditor.utils.js";import{buildExtensions as k}from"./extensions/buildExtensions.js";import{LinkBubbleMenu as y}from"./floating/LinkBubbleMenu.js";function x(n){return Object.entries(n).map((n=>{let[t,e]=n;return`${t.replace(/([A-Z])/g,(n=>`-${n.toLowerCase()}`))}:${e}`})).join(";")}const B=i(((i,B)=>{var b;const{initialContent:A,sections:j,features:I,disabled:L,maxCharacters:E,shortcuts:O,sendShortcut:w,mentions:F,slashCommands:H,link:M,onPaste:T,onReady:R,onChange:U,onSend:N,onFocus:z,onBlur:D,onSelectionChange:P,minHeight:$,maxHeight:q,style:J,className:V,editorClassName:W,editorStyle:Z}=i,_=(null==j?void 0:j.length)?d(m(null!=A?A:""),j.map((n=>Object.assign(Object.assign({},n),{content:m(n.content)})))):m(null!=A?A:""),G=l([]),K=l(!1),Q=l(R);Q.current=R;const X=l(U);X.current=U;const Y=l(P);Y.current=P;const nn=l(z);nn.current=z;const tn=l(D);tn.current=D;const en=o({extensions:k({features:I,placeholder:i.placeholder,maxCharacters:E,hasSections:(null!==(b=null==j?void 0:j.length)&&void 0!==b?b: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:N,sendShortcut:w,shortcuts:O,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:_,editable:!L,immediatelyRender:!1,editorProps:{attributes:Object.assign(Object.assign({},W?{class:W}:{}),Z?{style:x(Z)}:{})},onUpdate:n=>{let{editor:t}=n;var e,o;null===(e=X.current)||void 0===e||e.call(X,g(t)),null===(o=Y.current)||void 0===o||o.call(Y,v(t))},onSelectionUpdate:n=>{let{editor:t}=n;var e;return null===(e=Y.current)||void 0===e?void 0:e.call(Y,v(t))},onFocus:()=>{var n;return null===(n=nn.current)||void 0===n?void 0:n.call(nn)},onBlur:()=>{var n;return null===(n=tn.current)||void 0===n?void 0:n.call(tn)}});function on(n){en?n(en):G.current.push(n)}return s((()=>{var n;if(en){if(G.current.length>0){G.current.splice(0).forEach((n=>n(en)))}K.current||(K.current=!0,null===(n=Q.current)||void 0===n||n.call(Q))}}),[en]),c(B,(()=>({focus:()=>on((n=>n.commands.focus())),blur:()=>on((n=>n.commands.blur())),clearContent:()=>on((n=>n.commands.clearContent(!0))),setContent:n=>{const t=m(n);on((n=>n.commands.setContent(t,{emitUpdate:!0})))},insertContent:n=>{const t=m(n);on((n=>n.commands.insertContent(t)))},insertAtStart:n=>{const t=m(n);on((n=>n.commands.insertContentAt(1,t)))},insertAtEnd:n=>{const t=m(n);on((n=>n.commands.insertContentAt(n.state.doc.content.size,t)))},appendContent:n=>{const t=m(n);on((n=>n.commands.insertContentAt(n.state.doc.content.size-1,t)))},getContent:()=>en?g(en):{html:"",text:"",isEmpty:!0,characterCount:0},getJSON:()=>{var n;return null!==(n=null==en?void 0:en.getJSON())&&void 0!==n?n:null},getMentions:()=>{const n=new Set,t=new Set;return en?(en.state.doc.descendants((e=>{"mentionAgent"===e.type.name&&null!=e.attrs.id?n.add(String(e.attrs.id)):"mentionTeam"===e.type.name&&null!=e.attrs.id&&t.add(String(e.attrs.id))})),{agentIds:Array.from(n),teamIds:Array.from(t)}):{agentIds:[],teamIds:[]}},getCursorPosition:()=>{const{from:n,to:t}=en.state.selection;return{from:n,to:t}},insertAtPosition:(n,t)=>{const e=m(t);on((t=>t.commands.insertContentAt(n,e)))},getSelectedText:()=>{const{state:n}=en,{from:t,to:o,empty:r}=n.selection;if(!r)return n.doc.textBetween(t,o," ");const i=n.schema.marks.link;if(i){const o=e(n.doc.resolve(t),i);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==en?void 0:en.storage.characterCount)||void 0===n?void 0:n.characters)||void 0===t?void 0:t.call(n))&&void 0!==e?e:null==en?void 0:en.getText().length)&&void 0!==o?o:0,limit:null!=E?E:null}},getSectionContent:n=>h(en,n),setSectionContent:(n,t)=>{const e=m(t);on((t=>p(t,n,e)))},focusSection:n=>{on((t=>{if("body"===n)return void t.chain().focus().setTextSelection(1).run();let e=-1;t.state.doc.descendants(((t,o)=>{if(-1!==e)return!1;"sectionDivider"===t.type.name&&t.attrs.sectionId===n&&(e=o+t.nodeSize+1)})),-1!==e&&t.chain().focus().setTextSelection(e).run()}))},clearSection:n=>{on((t=>p(t,n,"<p></p>")))},getBodyContent:()=>f(en),setBodyContent:n=>{const t=m(n);on((n=>p(n,"body",t)))},setBodyAndSections:(n,t)=>{const e=d(m(n),t.map((n=>({id:n.id,content:m(n.content)}))));on((n=>n.commands.setContent(e,{emitUpdate:!0})))},appendBodyContent:n=>{const t=m(n);on((n=>{const e=C(n,"body");n.commands.insertContentAt(e-1,t)}))},insertAtSectionStart:(n,t)=>{const e=m(t);on((t=>{const o=S(t,n);-1!==o&&t.commands.insertContentAt(o,e)}))},insertAtSectionEnd:(n,t)=>{const e=m(t);on((t=>{const o=C(t,n);t.commands.insertContentAt(o,e)}))},getActiveFormats:()=>en?v(en):a,actions:{toggleBold:()=>null==en?void 0:en.chain().focus().toggleBold().run(),toggleItalic:()=>null==en?void 0:en.chain().focus().toggleItalic().run(),toggleUnderline:()=>null==en?void 0:en.chain().focus().toggleUnderline().run(),toggleStrike:()=>null==en?void 0:en.chain().focus().toggleStrike().run(),toggleBulletList:()=>null==en?void 0:en.chain().focus().toggleBulletList().run(),toggleOrderedList:()=>null==en?void 0:en.chain().focus().toggleOrderedList().run(),toggleBlockquote:()=>null==en?void 0:en.chain().focus().toggleBlockquote().run(),toggleCodeBlock:()=>null==en?void 0:en.chain().focus().toggleCodeBlock().run(),setTextAlign:n=>null==en?void 0:en.chain().focus().setTextAlign(n).run(),setFontFamily:n=>null==en?void 0:en.chain().focus().setFontFamily(n).run(),setFontSize:n=>null==en?void 0:en.chain().focus().setFontSize(n).run(),setColor:n=>null==en?void 0:en.chain().focus().setColor(n).run(),setHighlight:n=>null==en?void 0:en.chain().focus().toggleHighlight({color:n}).run(),unsetColor:()=>null==en?void 0:en.chain().focus().unsetColor().run(),unsetHighlight:()=>null==en?void 0:en.chain().focus().unsetHighlight().run(),setLink:(n,t)=>{en&&(void 0!==t?en.chain().focus().extendMarkRange("link").command((e=>{let{tr:o,state:r}=e;const{from:i,to:l}=o.selection,s=r.schema.marks.link;return!!s&&(o.replaceWith(i,l,r.schema.text(t,[s.create({href:n})])),!0)})).run():en.chain().focus().extendMarkRange("link").setLink({href:n}).run())},updateLink:n=>null==en?void 0:en.chain().focus().extendMarkRange("link").setLink({href:n}).run(),removeLink:()=>null==en?void 0:en.chain().focus().extendMarkRange("link").unsetLink().run(),insertEmoji:n=>null==en?void 0:en.chain().focus().insertContent(n).run(),insertVariable:n=>null==en?void 0:en.chain().focus().insertContent(`{{${n}}}`).run(),insertHtml:n=>null==en?void 0:en.commands.insertContent(n),undo:()=>null==en?void 0:en.chain().focus().undo().run(),redo:()=>null==en?void 0:en.chain().focus().redo().run(),canUndo:()=>{var n;return null!==(n=null==en?void 0:en.can().undo())&&void 0!==n&&n},canRedo:()=>{var n;return null!==(n=null==en?void 0:en.can().redo())&&void 0!==n&&n},toggleSuperscript:()=>null==en?void 0:en.chain().focus().toggleSuperscript().run(),toggleSubscript:()=>null==en?void 0:en.chain().focus().toggleSubscript().run(),insertImage:n=>null==en?void 0:en.chain().focus().setImage({src:n}).run()}})),[en]),en?n(u,Object.assign({minHeight:$,maxHeight:q,style:J,className:V},{children:[t(r,{editor:en}),t(y,{editor:en,renderLinkTooltip:null==M?void 0:M.renderTooltip})]})):null}));B.displayName="BikEditor";export{B as BikEditor};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import
|
|
1
|
+
import e from"styled-components";import{COLORS as o}from"../constants/Theme.js";const t=e.div`
|
|
2
2
|
position: relative;
|
|
3
3
|
width: 100%;
|
|
4
4
|
|
|
5
5
|
.ProseMirror {
|
|
6
|
-
min-height: ${
|
|
7
|
-
max-height: ${
|
|
6
|
+
min-height: ${e=>{let{minHeight:o}=e;return null!=o?o:"80px"}};
|
|
7
|
+
max-height: ${e=>{let{maxHeight:o}=e;return null!=o?o:"none"}};
|
|
8
8
|
overflow-y: auto;
|
|
9
9
|
outline: none;
|
|
10
10
|
padding: 8px 12px;
|
|
@@ -37,22 +37,15 @@ import o from"styled-components";const e=o.div`
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
.bik-mention {
|
|
40
|
-
|
|
41
|
-
color: #731DCF;
|
|
42
|
-
border-radius: 4px;
|
|
40
|
+
color: ${o.content.brand};
|
|
43
41
|
padding: 1px 4px;
|
|
44
|
-
font-weight: 500;
|
|
45
42
|
}
|
|
46
43
|
.bik-mention--team {
|
|
47
|
-
|
|
48
|
-
color: #731DCF;
|
|
44
|
+
color: ${o.content.brand};
|
|
49
45
|
}
|
|
50
46
|
.bik-variable {
|
|
51
|
-
|
|
52
|
-
color: #4f46e5;
|
|
53
|
-
border-radius: 3px;
|
|
47
|
+
color: ${o.content.brand};
|
|
54
48
|
padding: 1px 3px;
|
|
55
|
-
font-family: monospace;
|
|
56
49
|
}
|
|
57
50
|
|
|
58
51
|
a,
|
|
@@ -67,4 +60,4 @@ import o from"styled-components";const e=o.div`
|
|
|
67
60
|
text-decoration-color: #6366f1;
|
|
68
61
|
}
|
|
69
62
|
}
|
|
70
|
-
`;export{
|
|
63
|
+
`;export{t as BikEditorShell};
|
|
@@ -432,11 +432,20 @@ export interface BikEditorRef {
|
|
|
432
432
|
getContent: () => EditorSnapshot;
|
|
433
433
|
/**
|
|
434
434
|
* Returns the raw TipTap document as a plain JSON object.
|
|
435
|
-
* Useful for traversing node attributes (e.g. extracting mention IDs)
|
|
436
|
-
* without parsing the serialised HTML.
|
|
437
435
|
* Returns `null` when the editor is not yet mounted.
|
|
438
436
|
*/
|
|
439
437
|
getJSON: () => Record<string, unknown> | null;
|
|
438
|
+
/**
|
|
439
|
+
* Walks the document and returns all mention IDs currently in the editor,
|
|
440
|
+
* split by type. IDs are deduplicated and returned as arrays.
|
|
441
|
+
*
|
|
442
|
+
* @example
|
|
443
|
+
* const { agentIds, teamIds } = ref.current?.getMentions() ?? { agentIds: [], teamIds: [] };
|
|
444
|
+
*/
|
|
445
|
+
getMentions: () => {
|
|
446
|
+
agentIds: string[];
|
|
447
|
+
teamIds: string[];
|
|
448
|
+
};
|
|
440
449
|
/**
|
|
441
450
|
* Returns the current cursor / selection position as a `{ from, to }` pair.
|
|
442
451
|
* When nothing is selected, `from === to` (a collapsed cursor).
|