@dialpad/dialtone 9.155.0 → 9.155.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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a={items({query:e}){const t=[{id:"dialpad",name:"dialpad"},{id:"dialtone",name:"dialtone"},{id:"dialtone-vue",name:"dialtone-vue"},{id:"dialtone-internal",name:"dialtone-internal",locked:!0}];return e.length===0?t:t.filter(n=>n.name.toLowerCase().startsWith(e.toLowerCase()))}};exports.default=a;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const a={items({query:e}){const n=[{id:"dialpad",name:"dialpad",channelKey:"ch-001"},{id:"dialtone",name:"dialtone",channelKey:"ch-002"},{id:"dialtone-vue",name:"dialtone-vue",channelKey:"ch-003"},{id:"dialtone-internal",name:"dialtone-internal",locked:!0,channelKey:"ch-004"}];return e.length===0?n:n.filter(t=>t.name.toLowerCase().startsWith(e.toLowerCase()))}};exports.default=a;
2
2
  //# sourceMappingURL=channel-suggestion.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"channel-suggestion.cjs","sources":["../../../components/rich_text_editor/channel_suggestion.js"],"sourcesContent":["\nexport default {\n items ({ query }) {\n const CHANNEL_LIST = [\n {\n id: 'dialpad',\n name: 'dialpad',\n },\n {\n id: 'dialtone',\n name: 'dialtone',\n },\n {\n id: 'dialtone-vue',\n name: 'dialtone-vue',\n },\n {\n id: 'dialtone-internal',\n name: 'dialtone-internal',\n locked: true,\n },\n ];\n\n if (query.length === 0) return CHANNEL_LIST;\n\n return CHANNEL_LIST.filter((channel) => { return channel.name.toLowerCase().startsWith(query.toLowerCase()); });\n },\n};\n"],"names":["channel_suggestion","query","CHANNEL_LIST","channel"],"mappings":"4GACA,MAAAA,EAAe,CACb,MAAO,CAAE,MAAAC,GAAS,CAChB,MAAMC,EAAe,CACnB,CACE,GAAI,UACJ,KAAM,SACd,EACM,CACE,GAAI,WACJ,KAAM,UACd,EACM,CACE,GAAI,eACJ,KAAM,cACd,EACM,CACE,GAAI,oBACJ,KAAM,oBACN,OAAQ,EAChB,CACA,EAEI,OAAID,EAAM,SAAW,EAAUC,EAExBA,EAAa,OAAQC,GAAqBA,EAAQ,KAAK,YAAW,EAAG,WAAWF,EAAM,YAAW,CAAE,CAAI,CAChH,CACF"}
1
+ {"version":3,"file":"channel-suggestion.cjs","sources":["../../../components/rich_text_editor/channel_suggestion.js"],"sourcesContent":["\nexport default {\n items ({ query }) {\n const CHANNEL_LIST = [\n {\n id: 'dialpad',\n name: 'dialpad',\n channelKey: 'ch-001',\n },\n {\n id: 'dialtone',\n name: 'dialtone',\n channelKey: 'ch-002',\n },\n {\n id: 'dialtone-vue',\n name: 'dialtone-vue',\n channelKey: 'ch-003',\n },\n {\n id: 'dialtone-internal',\n name: 'dialtone-internal',\n locked: true,\n channelKey: 'ch-004',\n },\n ];\n\n if (query.length === 0) return CHANNEL_LIST;\n\n return CHANNEL_LIST.filter((channel) => { return channel.name.toLowerCase().startsWith(query.toLowerCase()); });\n },\n};\n"],"names":["channel_suggestion","query","CHANNEL_LIST","channel"],"mappings":"4GACA,MAAAA,EAAe,CACb,MAAO,CAAE,MAAAC,GAAS,CAChB,MAAMC,EAAe,CACnB,CACE,GAAI,UACJ,KAAM,UACN,WAAY,QACpB,EACM,CACE,GAAI,WACJ,KAAM,WACN,WAAY,QACpB,EACM,CACE,GAAI,eACJ,KAAM,eACN,WAAY,QACpB,EACM,CACE,GAAI,oBACJ,KAAM,oBACN,OAAQ,GACR,WAAY,QACpB,CACA,EAEI,OAAID,EAAM,SAAW,EAAUC,EAExBA,EAAa,OAAQC,GAAqBA,EAAQ,KAAK,YAAW,EAAG,WAAWF,EAAM,YAAW,CAAE,CAAI,CAChH,CACF"}
@@ -1,28 +1,32 @@
1
- const a = {
1
+ const t = {
2
2
  items({ query: e }) {
3
- const t = [
3
+ const n = [
4
4
  {
5
5
  id: "dialpad",
6
- name: "dialpad"
6
+ name: "dialpad",
7
+ channelKey: "ch-001"
7
8
  },
8
9
  {
9
10
  id: "dialtone",
10
- name: "dialtone"
11
+ name: "dialtone",
12
+ channelKey: "ch-002"
11
13
  },
12
14
  {
13
15
  id: "dialtone-vue",
14
- name: "dialtone-vue"
16
+ name: "dialtone-vue",
17
+ channelKey: "ch-003"
15
18
  },
16
19
  {
17
20
  id: "dialtone-internal",
18
21
  name: "dialtone-internal",
19
- locked: !0
22
+ locked: !0,
23
+ channelKey: "ch-004"
20
24
  }
21
25
  ];
22
- return e.length === 0 ? t : t.filter((n) => n.name.toLowerCase().startsWith(e.toLowerCase()));
26
+ return e.length === 0 ? n : n.filter((a) => a.name.toLowerCase().startsWith(e.toLowerCase()));
23
27
  }
24
28
  };
25
29
  export {
26
- a as default
30
+ t as default
27
31
  };
28
32
  //# sourceMappingURL=channel-suggestion.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"channel-suggestion.js","sources":["../../../components/rich_text_editor/channel_suggestion.js"],"sourcesContent":["\nexport default {\n items ({ query }) {\n const CHANNEL_LIST = [\n {\n id: 'dialpad',\n name: 'dialpad',\n },\n {\n id: 'dialtone',\n name: 'dialtone',\n },\n {\n id: 'dialtone-vue',\n name: 'dialtone-vue',\n },\n {\n id: 'dialtone-internal',\n name: 'dialtone-internal',\n locked: true,\n },\n ];\n\n if (query.length === 0) return CHANNEL_LIST;\n\n return CHANNEL_LIST.filter((channel) => { return channel.name.toLowerCase().startsWith(query.toLowerCase()); });\n },\n};\n"],"names":["channel_suggestion","query","CHANNEL_LIST","channel"],"mappings":"AACA,MAAAA,IAAe;AAAA,EACb,MAAO,EAAE,OAAAC,KAAS;AAChB,UAAMC,IAAe;AAAA,MACnB;AAAA,QACE,IAAI;AAAA,QACJ,MAAM;AAAA,MACd;AAAA,MACM;AAAA,QACE,IAAI;AAAA,QACJ,MAAM;AAAA,MACd;AAAA,MACM;AAAA,QACE,IAAI;AAAA,QACJ,MAAM;AAAA,MACd;AAAA,MACM;AAAA,QACE,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,QAAQ;AAAA,MAChB;AAAA,IACA;AAEI,WAAID,EAAM,WAAW,IAAUC,IAExBA,EAAa,OAAO,CAACC,MAAqBA,EAAQ,KAAK,YAAW,EAAG,WAAWF,EAAM,YAAW,CAAE,CAAI;AAAA,EAChH;AACF;"}
1
+ {"version":3,"file":"channel-suggestion.js","sources":["../../../components/rich_text_editor/channel_suggestion.js"],"sourcesContent":["\nexport default {\n items ({ query }) {\n const CHANNEL_LIST = [\n {\n id: 'dialpad',\n name: 'dialpad',\n channelKey: 'ch-001',\n },\n {\n id: 'dialtone',\n name: 'dialtone',\n channelKey: 'ch-002',\n },\n {\n id: 'dialtone-vue',\n name: 'dialtone-vue',\n channelKey: 'ch-003',\n },\n {\n id: 'dialtone-internal',\n name: 'dialtone-internal',\n locked: true,\n channelKey: 'ch-004',\n },\n ];\n\n if (query.length === 0) return CHANNEL_LIST;\n\n return CHANNEL_LIST.filter((channel) => { return channel.name.toLowerCase().startsWith(query.toLowerCase()); });\n },\n};\n"],"names":["channel_suggestion","query","CHANNEL_LIST","channel"],"mappings":"AACA,MAAAA,IAAe;AAAA,EACb,MAAO,EAAE,OAAAC,KAAS;AAChB,UAAMC,IAAe;AAAA,MACnB;AAAA,QACE,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,YAAY;AAAA,MACpB;AAAA,MACM;AAAA,QACE,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,YAAY;AAAA,MACpB;AAAA,MACM;AAAA,QACE,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,YAAY;AAAA,MACpB;AAAA,MACM;AAAA,QACE,IAAI;AAAA,QACJ,MAAM;AAAA,QACN,QAAQ;AAAA,QACR,YAAY;AAAA,MACpB;AAAA,IACA;AAEI,WAAID,EAAM,WAAW,IAAUC,IAExBA,EAAa,OAAO,CAACC,MAAqBA,EAAQ,KAAK,YAAW,EAAG,WAAWF,EAAM,YAAW,CAAE,CAAI;AAAA,EAChH;AACF;"}
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("../../node_modules/@tiptap/vue-3.cjs"),u=require("@tiptap/core"),O=require("@tiptap/extension-blockquote"),P=require("@tiptap/extension-code-block"),V=require("@tiptap/extension-code"),A=require("@tiptap/extension-document"),j=require("@tiptap/extension-hard-break"),R=require("@tiptap/extension-paragraph"),q=require("@tiptap/extension-placeholder"),H=require("@tiptap/extension-bold"),K=require("@tiptap/extension-bullet-list"),W=require("@tiptap/extension-italic"),F=require("@tiptap/extension-link"),U=require("@tiptap/extension-list-item"),z=require("@tiptap/extension-ordered-list"),X=require("@tiptap/extension-strike"),J=require("@tiptap/extension-underline"),Y=require("@tiptap/extension-text"),G=require("@tiptap/extension-text-align"),Q=require("@tiptap/extension-history"),Z=require("@tiptap/extension-text-style"),ee=require("@tiptap/extension-color"),te=require("@tiptap/extension-font-family"),g=require("@tiptap/pm/state"),ne=require("@tiptap/suggestion"),$=require("regex-combined-emojis"),o=require("vue"),h=require("../../_plugin-vue_export-helper-BRilXfQE.cjs"),D=require("../emoji/emoji.cjs"),f=require("../../common/emoji/index.cjs"),oe=require("../list-item/list-item.cjs"),w=require("../stack/stack.cjs"),b=require("tippy.js"),_=require("../../common/utils/index.cjs"),re=require("@tiptap/extension-image"),B=require("@tiptap/extension-mention"),I=require("../link/link.cjs"),se=require("@dialpad/dialtone-icons/vue3"),x=require("./rich-text-editor-constants.cjs"),ie=require("../avatar/avatar.cjs"),ae=require("@dialpad/dialtone-icons/vue3/hash"),ce=require("@dialpad/dialtone-icons/vue3/lock"),le=require("deep-equal"),de=require("../../localization/index.cjs"),ue=require("../button/button.cjs"),me={compatConfig:{MODE:3},name:"EmojiComponent",components:{NodeViewWrapper:d.NodeViewWrapper,DtEmoji:D.default},props:d.nodeViewProps};function he(e,t,r,n,s,i){const a=o.resolveComponent("dt-emoji"),c=o.resolveComponent("node-view-wrapper");return o.openBlock(),o.createBlock(c,{class:"d-d-inline-block d-va-bottom d-lh0"},{default:o.withCtx(()=>[o.createVNode(a,{size:"500",code:e.node.attrs.code},null,8,["code"])]),_:1})}const pe=h._(me,[["render",he]]),fe={compatConfig:{MODE:3},name:"SuggestionList",components:{DtListItem:oe.default},props:{items:{type:Array,required:!0},command:{type:Function,required:!0},itemComponent:{type:Object,required:!0},itemType:{type:String,required:!0}},data(){return{selectedIndex:0}},watch:{items(){this.selectedIndex=0}},methods:{onKeyDown({event:e}){return e.key==="ArrowUp"?(this.upHandler(),!0):e.key==="ArrowDown"?(this.downHandler(),!0):e.key==="Enter"||e.key==="Tab"?(this.selectHandler(),!0):!1},upHandler(){this.selectedIndex=(this.selectedIndex+this.items.length-1)%this.items.length,this.scrollActiveElementIntoView()},downHandler(){this.selectedIndex=(this.selectedIndex+1)%this.items.length,this.scrollActiveElementIntoView()},async scrollActiveElementIntoView(){await this.$nextTick();const e=this.$refs.suggestionList.querySelector(".d-list-item--highlighted");e&&e.scrollIntoView({behaviour:"smooth",block:"center"})},selectHandler(){this.selectItem(this.selectedIndex)},selectItem(e){const t=this.items[e];switch(this.itemType){case"emoji":this.command(t);return;case"mention":this.command({name:t.name,id:t.id,avatarSrc:t.avatarSrc,contactKey:t.contactKey});break;case"channel":this.command({name:t.name,id:t.id,locked:t.locked});break;case"slash-command":this.command({command:t.command});break}}}},ge={class:"d-popover__dialog d-suggestion-list__container"},ke={ref:"suggestionList",class:"d-suggestion-list"};function _e(e,t,r,n,s,i){const a=o.resolveComponent("dt-list-item");return o.openBlock(),o.createElementBlock("div",ge,[o.withDirectives(o.createElementVNode("ul",ke,[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(r.items,(c,l)=>(o.openBlock(),o.createBlock(a,{key:c.id,class:o.normalizeClass(["d-suggestion-list__item",{"d-list-item--highlighted":l===s.selectedIndex}]),"navigation-type":"arrow-keys",onClick:m=>i.selectItem(l),onKeydown:o.withModifiers(i.onKeyDown,["prevent"])},{default:o.withCtx(()=>[(o.openBlock(),o.createBlock(o.resolveDynamicComponent(r.itemComponent),{item:c},null,8,["item"]))]),_:2},1032,["class","onClick","onKeydown"]))),128))],512),[[o.vShow,r.items.length]])])}const T=h._(fe,[["render",_e]]),we={compatConfig:{MODE:3},name:"EmojiSuggestion",components:{DtEmoji:D.default,DtStack:w.default},props:{item:{type:Object,required:!0}}};function Ce(e,t,r,n,s,i){const a=o.resolveComponent("dt-emoji"),c=o.resolveComponent("dt-stack");return o.openBlock(),o.createBlock(c,{direction:"row",gap:"400"},{default:o.withCtx(()=>[o.createVNode(a,{size:"200",code:r.item.code},null,8,["code"]),o.createTextVNode(" "+o.toDisplayString(r.item.code),1)]),_:1})}const ye=h._(we,[["render",Ce]]),E={name:"hideOnEsc",defaultValue:!0,fn({hide:e}){function t(r){r.keyCode===27&&e()}return{onShow(){document.addEventListener("keydown",t)},onHide(){document.removeEventListener("keydown",t)}}}},xe=20,be=(e,t,r)=>{var c,l;const n=(c=e.shortname)==null?void 0:c.replaceAll(":",""),s=(l=t.shortname)==null?void 0:l.replaceAll(":",""),i=n.startsWith(r),a=s.startsWith(r);return i&&!a?-1:!i&&a?1:n.localeCompare(s)},Te={items:({query:e})=>{if(e.length<2)return[];const t=Object.values(f.getEmojiData());return e=e.toLowerCase(),t.filter(n=>{var s;return[n.name,(s=n.shortname)==null?void 0:s.replaceAll(":",""),...n.keywords||[]].some(i=>i&&i.startsWith(e))}).splice(0,xe).sort((n,s)=>be(n,s,e)).map(n=>({code:n.shortname}))},command:({editor:e,range:t,props:r})=>{var i,a;const n=e.view.state.selection.$to.nodeAfter;((i=n==null?void 0:n.text)==null?void 0:i.startsWith(" "))&&(t.to+=1),e.chain().focus().insertContentAt(t,[{type:"emoji",attrs:r}]).run(),(a=window.getSelection())==null||a.collapseToEnd()},render:()=>{let e,t,r=!1;return{onStart:n=>{e=new d.VueRenderer(T,{props:{itemComponent:o.markRaw(ye),itemType:"emoji",...n},editor:n.editor}),n.clientRect&&(t=b("body",{getReferenceClientRect:n.clientRect,appendTo:()=>document.body,content:e.element,showOnCreate:!1,onShow:()=>{r=!0},onHidden:()=>{r=!1},interactive:!0,trigger:"manual",placement:"top-start",zIndex:650,plugins:[E]}),n.items.length>0&&(t==null||t[0].show()))},onUpdate(n){e==null||e.updateProps(n),n.items.length>0?t==null||t[0].show():t==null||t[0].hide(),t==null||t[0].setProps({getReferenceClientRect:n.clientRect})},onKeyDown(n){var s;if(r)return(s=e==null?void 0:e.ref)==null?void 0:s.onKeyDown(n)},onExit(){t==null||t[0].destroy(),t=null,e==null||e.destroy(),e=null}}}},Ee=/(:\w+:)$/,Se=new RegExp($.emojiPattern+"$"),ve=e=>{if(e&&f.codeToEmojiData(e[0]))return{text:e[2]||e[0]}},Be=e=>[...e.matchAll(f.emojiShortCodeRegex)].filter(r=>f.codeToEmojiData(r[0])).map(r=>({index:r.index,text:r[0],match:r})),Ne=u.Node.create({name:"emoji",addOptions(){return{HTMLAttributes:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addNodeView(){return d.VueNodeViewRenderer(pe)},addAttributes(){return{code:{default:null}}},parseHTML(){return[{tag:"emoji-component"}]},renderText({node:e}){return f.stringToUnicode(f.codeToEmojiData(e.attrs.code).unicode_output)},renderHTML({HTMLAttributes:e}){return["emoji-component",u.mergeAttributes(this.options.HTMLAttributes,e)]},addInputRules(){return[new u.InputRule({find:e=>{const t=e.match(Ee)||e.match(Se);if(t)return ve(t)},handler:({state:e,range:t,match:r})=>{const{tr:n}=e,s=t.from,i=t.to;n.replaceWith(s,i,this.type.create({code:r[0]}))}})]},addPasteRules(){return[u.nodePasteRule({find:Be,type:this.type,getAttributes(e){return{code:e[0]}}}),u.nodePasteRule({find:f.emojiRegex,type:this.type,getAttributes(e){return{code:e[0]}}})]},addProseMirrorPlugins(){return[ne({char:":",pluginKey:new g.PluginKey("emoji"),editor:this.editor,...this.options.suggestion,...Te})]},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:e,state:t})=>{let r=!1;const{selection:n}=t,{empty:s,anchor:i}=n;return s?(t.doc.nodesBetween(i-1,i,(a,c)=>{if(a.type.name===this.name)return r=!0,e.insertText("",c,c+a.nodeSize),!1}),r):!1})}}});function Le(e,t,r=()=>!0){const n=[];t.lastIndex=0;let s;for(;s=t.exec(e);)r(e,s)&&n.push(s);return n}function Re(e,t){return!["#","@"].includes(e.charAt(t.index))&&!["#","@"].includes(e.charAt(t.index-1))}function $e(e){const t=new RegExp("(?:"+[`[!?.,:;'"]`,"(?:&|&amp;)(?:lt|gt|quot|apos|raquo|laquo|rsaquo|lsaquo);)+$"].join("|"),"g");return e.replace(t,"")}function De(e,t){const r=e.slice(0,t+1).search(/\S+\s*$/),n=e.slice(t).search(/\s/);if(n<0){const s=e.slice(r);return{text:s,from:r,to:r+s.length}}return{text:e.slice(r,n+t),from:r,to:n+t}}function v(e,t,r,n){const s=De(e,t);if(n.lastIndex=0,!n.test(s.text))return s;const i=r==="left"?s.from-1:s.to+1;return i<=0||i>=e.length||i===t?s:v(e,i,r,n)}function Ie(e,t,r,n){const s=Math.max(e.from-1,0),i=Math.min(e.to+1,t.content.size),a=u.getMarksBetween(s,i,t);for(const c of a)c.mark.type===n&&r.removeMark(c.from,c.to,n)}const N=_.getPhoneNumberRegex(1,15);function L(e,t,r,n,s,i){if(!e)return;let a=r-t-1;a=a<0?0:a;const c=n-t,l=v(e,a,"left",N),m=v(e,c,"right",N),p=e.slice(l.from,m.to);Le(p,_.linkRegex,Re).forEach(S=>{const k=$e(S[0]),y=t+l.from+S.index+1,M=y+k.length;s.addMark(y,M,i.create())})}function Me(e){let t=!1;return new g.Plugin({key:new g.PluginKey("autolink"),appendTransaction:(r,n,s)=>{const i=r.some(p=>p.docChanged)&&!n.doc.eq(s.doc);if(t&&!i)return;const{tr:a}=s,{textContent:c}=s.doc;t||L(c,0,0,c.length,a,e.type),t=!0;const l=u.combineTransactionSteps(n.doc,[...r]);return u.getChangedRanges(l).forEach(({oldRange:p,newRange:C})=>{Ie(C,s.doc,a,e.type),u.findChildrenInRange(s.doc,C,k=>k.isTextblock).forEach(({node:k,pos:y})=>{L(k.textContent,y,p.from,C.to,a,e.type)})}),a}})}const Oe={class:"d-link d-c-text d-d-inline-block d-wb-break-all",rel:"noopener noreferrer nofollow"},Pe=u.Mark.create({name:"CustomLink",renderHTML({HTMLAttributes:e}){return["a",u.mergeAttributes(this.options.HTMLAttributes,e,Oe)]},renderText({node:e}){return e.attrs.text},addProseMirrorPlugins(){return[Me({type:this.type})]}}),Ve=re.extend({name:"ConfigurableImage",addAttributes(){return{src:{default:""},alt:{default:void 0},title:{default:void 0},width:{default:void 0},height:{default:void 0},style:{default:void 0}}}}).configure({inline:!0,allowBase64:!0}),Ae=R.extend({parseHTML(){return[{tag:"div"}]},renderHTML({HTMLAttributes:e}){return["div",u.mergeAttributes(this.options.HTMLAttributes,e),0]}}),je={compatConfig:{MODE:3},name:"MentionComponent",components:{NodeViewWrapper:d.NodeViewWrapper,DtLink:I.default},props:d.nodeViewProps,computed:{text(){return"@"+this.$props.node.attrs.name}},methods:{handleClick(){const e={name:this.$props.node.attrs.name,id:this.$props.node.attrs.id,avatarSrc:this.$props.node.attrs.avatarSrc,contactKey:this.$props.node.attrs.contactKey};this.$props.editor.emit("mention-click",e)}}};function qe(e,t,r,n,s,i){const a=o.resolveComponent("dt-link"),c=o.resolveComponent("node-view-wrapper");return o.openBlock(),o.createBlock(c,{class:"d-d-inline-block"},{default:o.withCtx(()=>[o.createVNode(a,{kind:"mention",onClick:o.withModifiers(i.handleClick,["prevent"])},{default:o.withCtx(()=>[o.createTextVNode(o.toDisplayString(i.text),1)]),_:1},8,["onClick"])]),_:1})}const He=h._(je,[["render",qe]]),Ke=B.extend({addNodeView(){return d.VueNodeViewRenderer(He)},parseHTML(){return[{tag:"mention-component"}]},addAttributes(){return{name:{default:""},avatarSrc:{default:""},id:{default:""},contactKey:{default:""}}},renderText({node:e}){return`@${e.attrs.id}`},renderHTML({HTMLAttributes:e}){return["mention-component",u.mergeAttributes(this.options.HTMLAttributes,e)]}}).configure({suggestion:{char:"@",pluginKey:new g.PluginKey("mentionSuggestion")}}),We={compatConfig:{MODE:3},name:"ChannelComponent",components:{NodeViewWrapper:d.NodeViewWrapper,DtLink:I.default,DtIconLock:se.DtIconLock,DtStack:w.default},props:d.nodeViewProps,computed:{text(){return this.$props.node.attrs.locked?this.$props.node.attrs.name:"#"+this.$props.node.attrs.name}},methods:{handleClick(){const e={name:this.$props.node.attrs.name,id:this.$props.node.attrs.id,locked:this.$props.node.attrs.locked};this.$props.editor.emit("channel-click",e)}}};function Fe(e,t,r,n,s,i){const a=o.resolveComponent("dt-icon-lock"),c=o.resolveComponent("dt-stack"),l=o.resolveComponent("dt-link"),m=o.resolveComponent("node-view-wrapper");return o.openBlock(),o.createBlock(m,{class:"d-d-inline-block"},{default:o.withCtx(()=>[o.createVNode(l,{kind:"mention",onClick:o.withModifiers(i.handleClick,["prevent"])},{default:o.withCtx(()=>[o.createVNode(c,{direction:"row",gap:"0"},{default:o.withCtx(()=>[e.$props.node.attrs.locked?(o.openBlock(),o.createBlock(a,{key:0,size:"200"})):o.createCommentVNode("",!0),o.createElementVNode("span",null,o.toDisplayString(i.text),1)]),_:1})]),_:1},8,["onClick"])]),_:1})}const Ue=h._(We,[["render",Fe]]),ze=B.extend({name:"channel",addNodeView(){return d.VueNodeViewRenderer(Ue)},parseHTML(){return[{tag:"channel-component"}]},addAttributes(){return{name:{default:""},id:{default:""},locked:{default:!1}}},renderText({node:e}){return`#${e.attrs.id}`},renderHTML({HTMLAttributes:e}){return["channel-component",u.mergeAttributes(this.options.HTMLAttributes,e)]}}).configure({suggestion:{char:"#",pluginKey:new g.PluginKey("channelSuggestion")}}),Xe={compatConfig:{MODE:3},name:"SlashCommandsComponent",components:{NodeViewWrapper:d.NodeViewWrapper},props:{...d.nodeViewProps},emits:["selected-command"],computed:{text(){return"/"+this.$props.node.attrs.command}},created(){var r,n,s;const e=this.$props.node.attrs.command;this.$emit("selected-command",e);const t=(s=(n=(r=this.editor)==null?void 0:r.storage)==null?void 0:n["slash-commands"])==null?void 0:s.onSelectedCommand;t&&typeof t=="function"&&t(e)}};function Je(e,t,r,n,s,i){const a=o.resolveComponent("node-view-wrapper");return o.openBlock(),o.createBlock(a,{class:"d-d-inline-block"},{default:o.withCtx(()=>[o.createTextVNode(o.toDisplayString(i.text),1)]),_:1})}const Ye=h._(Xe,[["render",Je]]),Ge=(e,t)=>[...e.matchAll(t)].map(n=>{let s=n[2];return s.endsWith(" ")||(s+=" "),{index:n.index,text:s,match:n}}),Qe=B.extend({name:"slash-commands",group:"inline",inline:!0,addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),onSelectedCommand:null}},addStorage(){return{onSelectedCommand:this.options.onSelectedCommand}},addNodeView(){return d.VueNodeViewRenderer(Ye)},parseHTML(){return[{tag:"command-component"}]},addAttributes(){return{command:{default:""},parametersExample:{default:""},description:{default:""}}},renderText({node:e}){return`/${e.attrs.command}`},renderHTML({HTMLAttributes:e}){return["command-component",u.mergeAttributes(this.options.HTMLAttributes,e)]},addInputRules(){var r;const e=(r=this.options.suggestion)==null?void 0:r.items({query:""}).map(n=>n.command),t=new RegExp(`^((?:\\/)(${e.join("|")})) $`);return[u.nodeInputRule({find:t,type:this.type,getAttributes(n){return{command:n[2]}}})]},addPasteRules(){var r;const e=(r=this.options.suggestion)==null?void 0:r.items({query:""}).map(n=>n.command),t=new RegExp(`^((?:\\/)(${e.join("|")})) ?$`,"g");return[u.nodePasteRule({find:n=>Ge(n,t),type:this.type,getAttributes(n){return{command:n[0].trim()}}})]}}).configure({suggestion:{char:"/",pluginKey:new g.PluginKey("slashCommandSuggestion")}}),Ze={compatConfig:{MODE:3},name:"MentionSuggestion",components:{DtAvatar:ie.default,DtStack:w.default},props:{item:{type:Object,required:!0}},computed:{name(){return this.item.name},avatarSrc(){return this.item.avatarSrc},presence(){return this.item.presence},status(){return this.item.status},presenceText(){return this.item.presenceText},presenceFontColorClass(){return{active:"d-recipe-contact-row--active",busy:"d-recipe-contact-row--busy",away:"d-recipe-contact-row--away",offline:"d-recipe-contact-row--busy"}[this.presence]},showDetails(){return this.item.showDetails}}},et={class:"d-mention-suggestion__name"},tt={key:1,class:"d-mention-suggestion__divider"},nt={key:2,class:"d-mention-suggestion__status"};function ot(e,t,r,n,s,i){const a=o.resolveComponent("dt-avatar"),c=o.resolveComponent("dt-stack");return o.openBlock(),o.createBlock(c,{direction:"row",class:"d-mention-suggestion__container",gap:"400"},{default:o.withCtx(()=>[o.createVNode(a,{"full-name":i.name,"image-src":i.avatarSrc,"image-alt":i.name,"show-presence":i.showDetails,presence:i.presence,size:"sm"},null,8,["full-name","image-src","image-alt","show-presence","presence"]),o.createVNode(c,{class:"d-mention-suggestion__details-container",gap:"100"},{default:o.withCtx(()=>[o.createElementVNode("span",et,o.toDisplayString(i.name),1),i.showDetails?(o.openBlock(),o.createBlock(c,{key:0,direction:"row",gap:"300",class:"d-label--sm-plain"},{default:o.withCtx(()=>[i.presenceText?(o.openBlock(),o.createElementBlock("span",{key:0,class:o.normalizeClass(["d-mention-suggestion__presence",[i.presenceFontColorClass]])},o.toDisplayString(i.presenceText),3)):o.createCommentVNode("",!0),i.status&&i.presenceText?(o.openBlock(),o.createElementBlock("div",tt," • ")):o.createCommentVNode("",!0),i.status?(o.openBlock(),o.createElementBlock("div",nt,o.toDisplayString(i.status),1)):o.createCommentVNode("",!0)]),_:1})):o.createCommentVNode("",!0)]),_:1})]),_:1})}const rt=h._(Ze,[["render",ot]]),st={allowSpaces:!0,render:()=>{let e,t,r=!1;return{onStart:n=>{e=new d.VueRenderer(T,{props:{itemComponent:o.markRaw(rt),itemType:"mention",...n},editor:n.editor}),n.clientRect&&(t=b("body",{getReferenceClientRect:n.clientRect,appendTo:()=>document.body,content:e.element,showOnCreate:!1,onShow:()=>{r=!0},onHidden:()=>{r=!1},interactive:!0,trigger:"manual",placement:"top-start",zIndex:650,plugins:[E]}),n.items.length>0&&(t==null||t[0].show()))},onUpdate(n){e==null||e.updateProps(n),n.items.length>0?t==null||t[0].show():t==null||t[0].hide(),n.clientRect&&(t==null||t[0].setProps({getReferenceClientRect:n.clientRect}))},onKeyDown(n){var s;if(r)return(s=e==null?void 0:e.ref)==null?void 0:s.onKeyDown(n)},onExit(){t==null||t[0].destroy(),t=null,e==null||e.destroy(),e=null}}}},it={compatConfig:{MODE:3},name:"ChannelSuggestion",components:{DtStack:w.default,DtIconHash:ae,DtIconLock:ce},props:{item:{type:Object,required:!0}},computed:{name(){return this.item.name}}};function at(e,t,r,n,s,i){const a=o.resolveComponent("dt-icon-hash"),c=o.resolveComponent("dt-icon-lock"),l=o.resolveComponent("dt-stack");return o.openBlock(),o.createBlock(l,{direction:"row",gap:"400"},{default:o.withCtx(()=>[r.item.locked?(o.openBlock(),o.createBlock(c,{key:1,size:"300"})):(o.openBlock(),o.createBlock(a,{key:0,size:"300"})),o.createElementVNode("span",null,o.toDisplayString(i.name),1)]),_:1})}const ct=h._(it,[["render",at]]),lt={allowSpaces:!0,render:()=>{let e,t,r=!1;return{onStart:n=>{e=new d.VueRenderer(T,{props:{itemComponent:o.markRaw(ct),itemType:"channel",...n},editor:n.editor}),n.clientRect&&(t=b("body",{getReferenceClientRect:n.clientRect,appendTo:()=>document.body,content:e.element,showOnCreate:!1,onShow:()=>{r=!0},onHidden:()=>{r=!1},interactive:!0,trigger:"manual",placement:"top-start",zIndex:650,plugins:[E]}),n.items.length>0&&(t==null||t[0].show()))},onUpdate(n){e==null||e.updateProps(n),n.items.length>0?t==null||t[0].show():t==null||t[0].hide(),n.clientRect&&(t==null||t[0].setProps({getReferenceClientRect:n.clientRect}))},onKeyDown(n){var s;if(r)return(s=e==null?void 0:e.ref)==null?void 0:s.onKeyDown(n)},onExit(){t==null||t[0].destroy(),t=null,e==null||e.destroy(),e=null}}}},dt={compatConfig:{MODE:3},name:"SlashCommandSuggestion",props:{item:{type:Object,required:!0}},computed:{command(){return this.item.command},description(){return this.item.description},parametersExample(){return this.item.parametersExample}}},ut={class:"d-body--md-compact"},mt={key:0},ht={class:"d-body--sm d-fc-tertiary"};function pt(e,t,r,n,s,i){return o.openBlock(),o.createElementBlock("div",null,[o.createElementVNode("div",ut,[o.createElementVNode("span",null,"/"+o.toDisplayString(i.command),1),i.parametersExample?(o.openBlock(),o.createElementBlock("span",mt,o.toDisplayString(i.parametersExample),1)):o.createCommentVNode("",!0)]),o.createElementVNode("div",ht,o.toDisplayString(i.description),1)])}const ft=h._(dt,[["render",pt]]),gt={allowSpaces:!0,startOfLine:!0,render:()=>{let e,t,r=!1;return{onStart:n=>{e=new d.VueRenderer(T,{parent:void 0,props:{itemComponent:o.markRaw(ft),itemType:"slash-command",...n},editor:n.editor}),n.clientRect&&(t=b("body",{getReferenceClientRect:n.clientRect,appendTo:()=>document.body,content:e.element,showOnCreate:!1,onShow:()=>{r=!0},onHidden:()=>{r=!1},interactive:!0,trigger:"manual",placement:"top-start",zIndex:650,plugins:[E]}),n.items.length>0&&(t==null||t[0].show()))},onUpdate(n){e==null||e.updateProps(n),n.items.length>0?t==null||t[0].show():t==null||t[0].hide(),n.clientRect&&(t==null||t[0].setProps({getReferenceClientRect:n.clientRect}))},onKeyDown(n){var s;if(r)return(s=e==null?void 0:e.ref)==null?void 0:s.onKeyDown(n)},onExit(){t==null||t[0].destroy(),t=null,e==null||e.destroy(),e=null}}}},kt={compatConfig:{MODE:3},name:"DtRichTextEditor",components:{EditorContent:d.EditorContent,BubbleMenu:d.BubbleMenu,DtButton:ue.default,DtStack:w.default},props:{modelValue:{type:[Object,String],default:""},editable:{type:Boolean,default:!0},preventTyping:{type:Boolean,default:!1},pasteRichText:{type:Boolean,default:!0},allowLineBreaks:{type:Boolean,default:!1},inputAriaLabel:{type:String,required:!0},inputClass:{type:String,default:""},autoFocus:{type:[Boolean,String,Number],default:!1,validator(e){return typeof e=="string"?x.RICH_TEXT_EDITOR_AUTOFOCUS_TYPES.includes(e):!0}},outputFormat:{type:String,default:"html",validator(e){return x.RICH_TEXT_EDITOR_OUTPUT_FORMATS.includes(e)}},placeholder:{type:String,default:""},link:{type:[Boolean,Object],default:!1},customLink:{type:[Boolean,Object],default:!1},mentionSuggestion:{type:Object,default:null},channelSuggestion:{type:Object,default:null},slashCommandSuggestion:{type:Object,default:null},allowBlockquote:{type:Boolean,default:!0},allowBold:{type:Boolean,default:!0},allowBulletList:{type:Boolean,default:!0},allowItalic:{type:Boolean,default:!0},allowStrike:{type:Boolean,default:!0},allowUnderline:{type:Boolean,default:!0},allowCode:{type:Boolean,default:!0},allowCodeblock:{type:Boolean,default:!0},allowInlineImages:{type:Boolean,default:!1},allowFontColor:{type:Boolean,default:!1},allowFontFamily:{type:Boolean,default:!1},additionalExtensions:{type:Array,default:()=>[]},hideLinkBubbleMenu:{type:Boolean,default:!1},useDivTags:{type:Boolean,default:!1}},emits:["input","json-input","html-input","text-input","markdown-input","update:modelValue","blur","focus","enter","edit-link","selected","selected-command","mention-click","channel-click"],data(){return{editor:null,tippyOptions:{appendTo:()=>{var e;return(e=_.returnFirstEl(this.$refs.editor.$el).getRootNode())==null?void 0:e.querySelector("body")},placement:"top-start"},i18n:new de.DialtoneLocalization,jsonToMarkdownConverter:{convertToMarkdown(e){return this.processNode(e)},processNodeContent(e){return e.content?e.content.map(t=>this.processNode(t)).join(""):""},processNode(e){if(!e)return"";const r={doc:n=>this.processDocNode(n),paragraph:n=>this.processParagraphNode(n),text:n=>this.processTextNode(n),hardBreak:()=>this.processHardBreakNode(),blockquote:n=>this.processBlockquoteNode(n),bulletList:n=>this.processBulletListNode(n),orderedList:n=>this.processOrderedListNode(n),listItem:n=>this.processListItemNode(n),codeBlock:n=>this.processCodeBlockNode(n),mention:n=>this.processMentionNode(n),channel:n=>this.processChannelNode(n),"slash-commands":n=>this.processSlashCommandsNode(n),emoji:n=>this.processEmojiNode(n)}[e.type];return r?r(e):this.processUnknownNode(e)},processDocNode(e){return this.processNodeContent(e)},processParagraphNode(e){const t=this.processNodeContent(e);return t?t+`
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const d=require("../../node_modules/@tiptap/vue-3.cjs"),u=require("@tiptap/core"),O=require("@tiptap/extension-blockquote"),P=require("@tiptap/extension-code-block"),V=require("@tiptap/extension-code"),A=require("@tiptap/extension-document"),j=require("@tiptap/extension-hard-break"),$=require("@tiptap/extension-paragraph"),q=require("@tiptap/extension-placeholder"),H=require("@tiptap/extension-bold"),K=require("@tiptap/extension-bullet-list"),W=require("@tiptap/extension-italic"),F=require("@tiptap/extension-link"),U=require("@tiptap/extension-list-item"),z=require("@tiptap/extension-ordered-list"),X=require("@tiptap/extension-strike"),J=require("@tiptap/extension-underline"),Y=require("@tiptap/extension-text"),G=require("@tiptap/extension-text-align"),Q=require("@tiptap/extension-history"),Z=require("@tiptap/extension-text-style"),ee=require("@tiptap/extension-color"),te=require("@tiptap/extension-font-family"),g=require("@tiptap/pm/state"),ne=require("@tiptap/suggestion"),R=require("regex-combined-emojis"),o=require("vue"),h=require("../../_plugin-vue_export-helper-BRilXfQE.cjs"),D=require("../emoji/emoji.cjs"),f=require("../../common/emoji/index.cjs"),oe=require("../list-item/list-item.cjs"),w=require("../stack/stack.cjs"),b=require("tippy.js"),_=require("../../common/utils/index.cjs"),re=require("@tiptap/extension-image"),B=require("@tiptap/extension-mention"),I=require("../link/link.cjs"),se=require("@dialpad/dialtone-icons/vue3"),x=require("./rich-text-editor-constants.cjs"),ie=require("../avatar/avatar.cjs"),ae=require("@dialpad/dialtone-icons/vue3/hash"),ce=require("@dialpad/dialtone-icons/vue3/lock"),le=require("deep-equal"),de=require("../../localization/index.cjs"),ue=require("../button/button.cjs"),me={compatConfig:{MODE:3},name:"EmojiComponent",components:{NodeViewWrapper:d.NodeViewWrapper,DtEmoji:D.default},props:d.nodeViewProps};function he(e,t,r,n,s,i){const a=o.resolveComponent("dt-emoji"),c=o.resolveComponent("node-view-wrapper");return o.openBlock(),o.createBlock(c,{class:"d-d-inline-block d-va-bottom d-lh0"},{default:o.withCtx(()=>[o.createVNode(a,{size:"500",code:e.node.attrs.code},null,8,["code"])]),_:1})}const pe=h._(me,[["render",he]]),fe={compatConfig:{MODE:3},name:"SuggestionList",components:{DtListItem:oe.default},props:{items:{type:Array,required:!0},command:{type:Function,required:!0},itemComponent:{type:Object,required:!0},itemType:{type:String,required:!0}},data(){return{selectedIndex:0}},watch:{items(){this.selectedIndex=0}},methods:{onKeyDown({event:e}){return e.key==="ArrowUp"?(this.upHandler(),!0):e.key==="ArrowDown"?(this.downHandler(),!0):e.key==="Enter"||e.key==="Tab"?(this.selectHandler(),!0):!1},upHandler(){this.selectedIndex=(this.selectedIndex+this.items.length-1)%this.items.length,this.scrollActiveElementIntoView()},downHandler(){this.selectedIndex=(this.selectedIndex+1)%this.items.length,this.scrollActiveElementIntoView()},async scrollActiveElementIntoView(){await this.$nextTick();const e=this.$refs.suggestionList.querySelector(".d-list-item--highlighted");e&&e.scrollIntoView({behaviour:"smooth",block:"center"})},selectHandler(){this.selectItem(this.selectedIndex)},selectItem(e){const t=this.items[e];switch(this.itemType){case"emoji":this.command(t);return;case"mention":this.command({name:t.name,id:t.id,avatarSrc:t.avatarSrc,contactKey:t.contactKey});break;case"channel":this.command({name:t.name,id:t.id,locked:t.locked,channelKey:t.channelKey});break;case"slash-command":this.command({command:t.command});break}}}},ge={class:"d-popover__dialog d-suggestion-list__container"},ke={ref:"suggestionList",class:"d-suggestion-list"};function _e(e,t,r,n,s,i){const a=o.resolveComponent("dt-list-item");return o.openBlock(),o.createElementBlock("div",ge,[o.withDirectives(o.createElementVNode("ul",ke,[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(r.items,(c,l)=>(o.openBlock(),o.createBlock(a,{key:c.id,class:o.normalizeClass(["d-suggestion-list__item",{"d-list-item--highlighted":l===s.selectedIndex}]),"navigation-type":"arrow-keys",onClick:m=>i.selectItem(l),onKeydown:o.withModifiers(i.onKeyDown,["prevent"])},{default:o.withCtx(()=>[(o.openBlock(),o.createBlock(o.resolveDynamicComponent(r.itemComponent),{item:c},null,8,["item"]))]),_:2},1032,["class","onClick","onKeydown"]))),128))],512),[[o.vShow,r.items.length]])])}const T=h._(fe,[["render",_e]]),we={compatConfig:{MODE:3},name:"EmojiSuggestion",components:{DtEmoji:D.default,DtStack:w.default},props:{item:{type:Object,required:!0}}};function ye(e,t,r,n,s,i){const a=o.resolveComponent("dt-emoji"),c=o.resolveComponent("dt-stack");return o.openBlock(),o.createBlock(c,{direction:"row",gap:"400"},{default:o.withCtx(()=>[o.createVNode(a,{size:"200",code:r.item.code},null,8,["code"]),o.createTextVNode(" "+o.toDisplayString(r.item.code),1)]),_:1})}const Ce=h._(we,[["render",ye]]),E={name:"hideOnEsc",defaultValue:!0,fn({hide:e}){function t(r){r.keyCode===27&&e()}return{onShow(){document.addEventListener("keydown",t)},onHide(){document.removeEventListener("keydown",t)}}}},xe=20,be=(e,t,r)=>{var c,l;const n=(c=e.shortname)==null?void 0:c.replaceAll(":",""),s=(l=t.shortname)==null?void 0:l.replaceAll(":",""),i=n.startsWith(r),a=s.startsWith(r);return i&&!a?-1:!i&&a?1:n.localeCompare(s)},Te={items:({query:e})=>{if(e.length<2)return[];const t=Object.values(f.getEmojiData());return e=e.toLowerCase(),t.filter(n=>{var s;return[n.name,(s=n.shortname)==null?void 0:s.replaceAll(":",""),...n.keywords||[]].some(i=>i&&i.startsWith(e))}).splice(0,xe).sort((n,s)=>be(n,s,e)).map(n=>({code:n.shortname}))},command:({editor:e,range:t,props:r})=>{var i,a;const n=e.view.state.selection.$to.nodeAfter;((i=n==null?void 0:n.text)==null?void 0:i.startsWith(" "))&&(t.to+=1),e.chain().focus().insertContentAt(t,[{type:"emoji",attrs:r}]).run(),(a=window.getSelection())==null||a.collapseToEnd()},render:()=>{let e,t,r=!1;return{onStart:n=>{e=new d.VueRenderer(T,{props:{itemComponent:o.markRaw(Ce),itemType:"emoji",...n},editor:n.editor}),n.clientRect&&(t=b("body",{getReferenceClientRect:n.clientRect,appendTo:()=>document.body,content:e.element,showOnCreate:!1,onShow:()=>{r=!0},onHidden:()=>{r=!1},interactive:!0,trigger:"manual",placement:"top-start",zIndex:650,plugins:[E]}),n.items.length>0&&(t==null||t[0].show()))},onUpdate(n){e==null||e.updateProps(n),n.items.length>0?t==null||t[0].show():t==null||t[0].hide(),t==null||t[0].setProps({getReferenceClientRect:n.clientRect})},onKeyDown(n){var s;if(r)return(s=e==null?void 0:e.ref)==null?void 0:s.onKeyDown(n)},onExit(){t==null||t[0].destroy(),t=null,e==null||e.destroy(),e=null}}}},Ee=/(:\w+:)$/,Se=new RegExp(R.emojiPattern+"$"),ve=e=>{if(e&&f.codeToEmojiData(e[0]))return{text:e[2]||e[0]}},Be=e=>[...e.matchAll(f.emojiShortCodeRegex)].filter(r=>f.codeToEmojiData(r[0])).map(r=>({index:r.index,text:r[0],match:r})),Ne=u.Node.create({name:"emoji",addOptions(){return{HTMLAttributes:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addNodeView(){return d.VueNodeViewRenderer(pe)},addAttributes(){return{code:{default:null}}},parseHTML(){return[{tag:"emoji-component"}]},renderText({node:e}){return f.stringToUnicode(f.codeToEmojiData(e.attrs.code).unicode_output)},renderHTML({HTMLAttributes:e}){return["emoji-component",u.mergeAttributes(this.options.HTMLAttributes,e)]},addInputRules(){return[new u.InputRule({find:e=>{const t=e.match(Ee)||e.match(Se);if(t)return ve(t)},handler:({state:e,range:t,match:r})=>{const{tr:n}=e,s=t.from,i=t.to;n.replaceWith(s,i,this.type.create({code:r[0]}))}})]},addPasteRules(){return[u.nodePasteRule({find:Be,type:this.type,getAttributes(e){return{code:e[0]}}}),u.nodePasteRule({find:f.emojiRegex,type:this.type,getAttributes(e){return{code:e[0]}}})]},addProseMirrorPlugins(){return[ne({char:":",pluginKey:new g.PluginKey("emoji"),editor:this.editor,...this.options.suggestion,...Te})]},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:e,state:t})=>{let r=!1;const{selection:n}=t,{empty:s,anchor:i}=n;return s?(t.doc.nodesBetween(i-1,i,(a,c)=>{if(a.type.name===this.name)return r=!0,e.insertText("",c,c+a.nodeSize),!1}),r):!1})}}});function Le(e,t,r=()=>!0){const n=[];t.lastIndex=0;let s;for(;s=t.exec(e);)r(e,s)&&n.push(s);return n}function $e(e,t){return!["#","@"].includes(e.charAt(t.index))&&!["#","@"].includes(e.charAt(t.index-1))}function Re(e){const t=new RegExp("(?:"+[`[!?.,:;'"]`,"(?:&|&amp;)(?:lt|gt|quot|apos|raquo|laquo|rsaquo|lsaquo);)+$"].join("|"),"g");return e.replace(t,"")}function De(e,t){const r=e.slice(0,t+1).search(/\S+\s*$/),n=e.slice(t).search(/\s/);if(n<0){const s=e.slice(r);return{text:s,from:r,to:r+s.length}}return{text:e.slice(r,n+t),from:r,to:n+t}}function v(e,t,r,n){const s=De(e,t);if(n.lastIndex=0,!n.test(s.text))return s;const i=r==="left"?s.from-1:s.to+1;return i<=0||i>=e.length||i===t?s:v(e,i,r,n)}function Ie(e,t,r,n){const s=Math.max(e.from-1,0),i=Math.min(e.to+1,t.content.size),a=u.getMarksBetween(s,i,t);for(const c of a)c.mark.type===n&&r.removeMark(c.from,c.to,n)}const N=_.getPhoneNumberRegex(1,15);function L(e,t,r,n,s,i){if(!e)return;let a=r-t-1;a=a<0?0:a;const c=n-t,l=v(e,a,"left",N),m=v(e,c,"right",N),p=e.slice(l.from,m.to);Le(p,_.linkRegex,$e).forEach(S=>{const k=Re(S[0]),C=t+l.from+S.index+1,M=C+k.length;s.addMark(C,M,i.create())})}function Me(e){let t=!1;return new g.Plugin({key:new g.PluginKey("autolink"),appendTransaction:(r,n,s)=>{const i=r.some(p=>p.docChanged)&&!n.doc.eq(s.doc);if(t&&!i)return;const{tr:a}=s,{textContent:c}=s.doc;t||L(c,0,0,c.length,a,e.type),t=!0;const l=u.combineTransactionSteps(n.doc,[...r]);return u.getChangedRanges(l).forEach(({oldRange:p,newRange:y})=>{Ie(y,s.doc,a,e.type),u.findChildrenInRange(s.doc,y,k=>k.isTextblock).forEach(({node:k,pos:C})=>{L(k.textContent,C,p.from,y.to,a,e.type)})}),a}})}const Oe={class:"d-link d-c-text d-d-inline-block d-wb-break-all",rel:"noopener noreferrer nofollow"},Pe=u.Mark.create({name:"CustomLink",renderHTML({HTMLAttributes:e}){return["a",u.mergeAttributes(this.options.HTMLAttributes,e,Oe)]},renderText({node:e}){return e.attrs.text},addProseMirrorPlugins(){return[Me({type:this.type})]}}),Ve=re.extend({name:"ConfigurableImage",addAttributes(){return{src:{default:""},alt:{default:void 0},title:{default:void 0},width:{default:void 0},height:{default:void 0},style:{default:void 0}}}}).configure({inline:!0,allowBase64:!0}),Ae=$.extend({parseHTML(){return[{tag:"div"}]},renderHTML({HTMLAttributes:e}){return["div",u.mergeAttributes(this.options.HTMLAttributes,e),0]}}),je={compatConfig:{MODE:3},name:"MentionComponent",components:{NodeViewWrapper:d.NodeViewWrapper,DtLink:I.default},props:d.nodeViewProps,computed:{text(){return"@"+this.$props.node.attrs.name}},methods:{handleClick(){const e={name:this.$props.node.attrs.name,id:this.$props.node.attrs.id,avatarSrc:this.$props.node.attrs.avatarSrc,contactKey:this.$props.node.attrs.contactKey};this.$props.editor.emit("mention-click",e)}}};function qe(e,t,r,n,s,i){const a=o.resolveComponent("dt-link"),c=o.resolveComponent("node-view-wrapper");return o.openBlock(),o.createBlock(c,{class:"d-d-inline-block"},{default:o.withCtx(()=>[o.createVNode(a,{kind:"mention",onClick:o.withModifiers(i.handleClick,["prevent"])},{default:o.withCtx(()=>[o.createTextVNode(o.toDisplayString(i.text),1)]),_:1},8,["onClick"])]),_:1})}const He=h._(je,[["render",qe]]),Ke=B.extend({addNodeView(){return d.VueNodeViewRenderer(He)},parseHTML(){return[{tag:"mention-component"}]},addAttributes(){return{name:{default:""},avatarSrc:{default:""},id:{default:""},contactKey:{default:""}}},renderText({node:e}){return`@${e.attrs.id}`},renderHTML({HTMLAttributes:e}){return["mention-component",u.mergeAttributes(this.options.HTMLAttributes,e)]}}).configure({suggestion:{char:"@",pluginKey:new g.PluginKey("mentionSuggestion")}}),We={compatConfig:{MODE:3},name:"ChannelComponent",components:{NodeViewWrapper:d.NodeViewWrapper,DtLink:I.default,DtIconLock:se.DtIconLock,DtStack:w.default},props:d.nodeViewProps,computed:{text(){return this.$props.node.attrs.locked?this.$props.node.attrs.name:"#"+this.$props.node.attrs.name}},methods:{handleClick(){const e={name:this.$props.node.attrs.name,id:this.$props.node.attrs.id,locked:this.$props.node.attrs.locked,channelKey:this.$props.node.attrs.channelKey};this.$props.editor.emit("channel-click",e)}}};function Fe(e,t,r,n,s,i){const a=o.resolveComponent("dt-icon-lock"),c=o.resolveComponent("dt-stack"),l=o.resolveComponent("dt-link"),m=o.resolveComponent("node-view-wrapper");return o.openBlock(),o.createBlock(m,{class:"d-d-inline-block"},{default:o.withCtx(()=>[o.createVNode(l,{kind:"mention",onClick:o.withModifiers(i.handleClick,["prevent"])},{default:o.withCtx(()=>[o.createVNode(c,{direction:"row",gap:"0"},{default:o.withCtx(()=>[e.$props.node.attrs.locked?(o.openBlock(),o.createBlock(a,{key:0,size:"200"})):o.createCommentVNode("",!0),o.createElementVNode("span",null,o.toDisplayString(i.text),1)]),_:1})]),_:1},8,["onClick"])]),_:1})}const Ue=h._(We,[["render",Fe]]),ze=B.extend({name:"channel",addNodeView(){return d.VueNodeViewRenderer(Ue)},parseHTML(){return[{tag:"channel-component"}]},addAttributes(){return{name:{default:""},id:{default:""},locked:{default:!1},channelKey:{default:""}}},renderText({node:e}){return`#${e.attrs.id}`},renderHTML({HTMLAttributes:e}){return["channel-component",u.mergeAttributes(this.options.HTMLAttributes,e)]}}).configure({suggestion:{char:"#",pluginKey:new g.PluginKey("channelSuggestion")}}),Xe={compatConfig:{MODE:3},name:"SlashCommandsComponent",components:{NodeViewWrapper:d.NodeViewWrapper},props:{...d.nodeViewProps},emits:["selected-command"],computed:{text(){return"/"+this.$props.node.attrs.command}},created(){var r,n,s;const e=this.$props.node.attrs.command;this.$emit("selected-command",e);const t=(s=(n=(r=this.editor)==null?void 0:r.storage)==null?void 0:n["slash-commands"])==null?void 0:s.onSelectedCommand;t&&typeof t=="function"&&t(e)}};function Je(e,t,r,n,s,i){const a=o.resolveComponent("node-view-wrapper");return o.openBlock(),o.createBlock(a,{class:"d-d-inline-block"},{default:o.withCtx(()=>[o.createTextVNode(o.toDisplayString(i.text),1)]),_:1})}const Ye=h._(Xe,[["render",Je]]),Ge=(e,t)=>[...e.matchAll(t)].map(n=>{let s=n[2];return s.endsWith(" ")||(s+=" "),{index:n.index,text:s,match:n}}),Qe=B.extend({name:"slash-commands",group:"inline",inline:!0,addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),onSelectedCommand:null}},addStorage(){return{onSelectedCommand:this.options.onSelectedCommand}},addNodeView(){return d.VueNodeViewRenderer(Ye)},parseHTML(){return[{tag:"command-component"}]},addAttributes(){return{command:{default:""},parametersExample:{default:""},description:{default:""}}},renderText({node:e}){return`/${e.attrs.command}`},renderHTML({HTMLAttributes:e}){return["command-component",u.mergeAttributes(this.options.HTMLAttributes,e)]},addInputRules(){var r;const e=(r=this.options.suggestion)==null?void 0:r.items({query:""}).map(n=>n.command),t=new RegExp(`^((?:\\/)(${e.join("|")})) $`);return[u.nodeInputRule({find:t,type:this.type,getAttributes(n){return{command:n[2]}}})]},addPasteRules(){var r;const e=(r=this.options.suggestion)==null?void 0:r.items({query:""}).map(n=>n.command),t=new RegExp(`^((?:\\/)(${e.join("|")})) ?$`,"g");return[u.nodePasteRule({find:n=>Ge(n,t),type:this.type,getAttributes(n){return{command:n[0].trim()}}})]}}).configure({suggestion:{char:"/",pluginKey:new g.PluginKey("slashCommandSuggestion")}}),Ze={compatConfig:{MODE:3},name:"MentionSuggestion",components:{DtAvatar:ie.default,DtStack:w.default},props:{item:{type:Object,required:!0}},computed:{name(){return this.item.name},avatarSrc(){return this.item.avatarSrc},presence(){return this.item.presence},status(){return this.item.status},presenceText(){return this.item.presenceText},presenceFontColorClass(){return{active:"d-recipe-contact-row--active",busy:"d-recipe-contact-row--busy",away:"d-recipe-contact-row--away",offline:"d-recipe-contact-row--busy"}[this.presence]},showDetails(){return this.item.showDetails}}},et={class:"d-mention-suggestion__name"},tt={key:1,class:"d-mention-suggestion__divider"},nt={key:2,class:"d-mention-suggestion__status"};function ot(e,t,r,n,s,i){const a=o.resolveComponent("dt-avatar"),c=o.resolveComponent("dt-stack");return o.openBlock(),o.createBlock(c,{direction:"row",class:"d-mention-suggestion__container",gap:"400"},{default:o.withCtx(()=>[o.createVNode(a,{"full-name":i.name,"image-src":i.avatarSrc,"image-alt":i.name,"show-presence":i.showDetails,presence:i.presence,size:"sm"},null,8,["full-name","image-src","image-alt","show-presence","presence"]),o.createVNode(c,{class:"d-mention-suggestion__details-container",gap:"100"},{default:o.withCtx(()=>[o.createElementVNode("span",et,o.toDisplayString(i.name),1),i.showDetails?(o.openBlock(),o.createBlock(c,{key:0,direction:"row",gap:"300",class:"d-label--sm-plain"},{default:o.withCtx(()=>[i.presenceText?(o.openBlock(),o.createElementBlock("span",{key:0,class:o.normalizeClass(["d-mention-suggestion__presence",[i.presenceFontColorClass]])},o.toDisplayString(i.presenceText),3)):o.createCommentVNode("",!0),i.status&&i.presenceText?(o.openBlock(),o.createElementBlock("div",tt," • ")):o.createCommentVNode("",!0),i.status?(o.openBlock(),o.createElementBlock("div",nt,o.toDisplayString(i.status),1)):o.createCommentVNode("",!0)]),_:1})):o.createCommentVNode("",!0)]),_:1})]),_:1})}const rt=h._(Ze,[["render",ot]]),st={allowSpaces:!0,render:()=>{let e,t,r=!1;return{onStart:n=>{e=new d.VueRenderer(T,{props:{itemComponent:o.markRaw(rt),itemType:"mention",...n},editor:n.editor}),n.clientRect&&(t=b("body",{getReferenceClientRect:n.clientRect,appendTo:()=>document.body,content:e.element,showOnCreate:!1,onShow:()=>{r=!0},onHidden:()=>{r=!1},interactive:!0,trigger:"manual",placement:"top-start",zIndex:650,plugins:[E]}),n.items.length>0&&(t==null||t[0].show()))},onUpdate(n){e==null||e.updateProps(n),n.items.length>0?t==null||t[0].show():t==null||t[0].hide(),n.clientRect&&(t==null||t[0].setProps({getReferenceClientRect:n.clientRect}))},onKeyDown(n){var s;if(r)return(s=e==null?void 0:e.ref)==null?void 0:s.onKeyDown(n)},onExit(){t==null||t[0].destroy(),t=null,e==null||e.destroy(),e=null}}}},it={compatConfig:{MODE:3},name:"ChannelSuggestion",components:{DtStack:w.default,DtIconHash:ae,DtIconLock:ce},props:{item:{type:Object,required:!0}},computed:{name(){return this.item.name}}};function at(e,t,r,n,s,i){const a=o.resolveComponent("dt-icon-hash"),c=o.resolveComponent("dt-icon-lock"),l=o.resolveComponent("dt-stack");return o.openBlock(),o.createBlock(l,{direction:"row",gap:"400"},{default:o.withCtx(()=>[r.item.locked?(o.openBlock(),o.createBlock(c,{key:1,size:"300"})):(o.openBlock(),o.createBlock(a,{key:0,size:"300"})),o.createElementVNode("span",null,o.toDisplayString(i.name),1)]),_:1})}const ct=h._(it,[["render",at]]),lt={allowSpaces:!0,render:()=>{let e,t,r=!1;return{onStart:n=>{e=new d.VueRenderer(T,{props:{itemComponent:o.markRaw(ct),itemType:"channel",...n},editor:n.editor}),n.clientRect&&(t=b("body",{getReferenceClientRect:n.clientRect,appendTo:()=>document.body,content:e.element,showOnCreate:!1,onShow:()=>{r=!0},onHidden:()=>{r=!1},interactive:!0,trigger:"manual",placement:"top-start",zIndex:650,plugins:[E]}),n.items.length>0&&(t==null||t[0].show()))},onUpdate(n){e==null||e.updateProps(n),n.items.length>0?t==null||t[0].show():t==null||t[0].hide(),n.clientRect&&(t==null||t[0].setProps({getReferenceClientRect:n.clientRect}))},onKeyDown(n){var s;if(r)return(s=e==null?void 0:e.ref)==null?void 0:s.onKeyDown(n)},onExit(){t==null||t[0].destroy(),t=null,e==null||e.destroy(),e=null}}}},dt={compatConfig:{MODE:3},name:"SlashCommandSuggestion",props:{item:{type:Object,required:!0}},computed:{command(){return this.item.command},description(){return this.item.description},parametersExample(){return this.item.parametersExample}}},ut={class:"d-body--md-compact"},mt={key:0},ht={class:"d-body--sm d-fc-tertiary"};function pt(e,t,r,n,s,i){return o.openBlock(),o.createElementBlock("div",null,[o.createElementVNode("div",ut,[o.createElementVNode("span",null,"/"+o.toDisplayString(i.command),1),i.parametersExample?(o.openBlock(),o.createElementBlock("span",mt,o.toDisplayString(i.parametersExample),1)):o.createCommentVNode("",!0)]),o.createElementVNode("div",ht,o.toDisplayString(i.description),1)])}const ft=h._(dt,[["render",pt]]),gt={allowSpaces:!0,startOfLine:!0,render:()=>{let e,t,r=!1;return{onStart:n=>{e=new d.VueRenderer(T,{parent:void 0,props:{itemComponent:o.markRaw(ft),itemType:"slash-command",...n},editor:n.editor}),n.clientRect&&(t=b("body",{getReferenceClientRect:n.clientRect,appendTo:()=>document.body,content:e.element,showOnCreate:!1,onShow:()=>{r=!0},onHidden:()=>{r=!1},interactive:!0,trigger:"manual",placement:"top-start",zIndex:650,plugins:[E]}),n.items.length>0&&(t==null||t[0].show()))},onUpdate(n){e==null||e.updateProps(n),n.items.length>0?t==null||t[0].show():t==null||t[0].hide(),n.clientRect&&(t==null||t[0].setProps({getReferenceClientRect:n.clientRect}))},onKeyDown(n){var s;if(r)return(s=e==null?void 0:e.ref)==null?void 0:s.onKeyDown(n)},onExit(){t==null||t[0].destroy(),t=null,e==null||e.destroy(),e=null}}}},kt={compatConfig:{MODE:3},name:"DtRichTextEditor",components:{EditorContent:d.EditorContent,BubbleMenu:d.BubbleMenu,DtButton:ue.default,DtStack:w.default},props:{modelValue:{type:[Object,String],default:""},editable:{type:Boolean,default:!0},preventTyping:{type:Boolean,default:!1},pasteRichText:{type:Boolean,default:!0},allowLineBreaks:{type:Boolean,default:!1},inputAriaLabel:{type:String,required:!0},inputClass:{type:String,default:""},autoFocus:{type:[Boolean,String,Number],default:!1,validator(e){return typeof e=="string"?x.RICH_TEXT_EDITOR_AUTOFOCUS_TYPES.includes(e):!0}},outputFormat:{type:String,default:"html",validator(e){return x.RICH_TEXT_EDITOR_OUTPUT_FORMATS.includes(e)}},placeholder:{type:String,default:""},link:{type:[Boolean,Object],default:!1},customLink:{type:[Boolean,Object],default:!1},mentionSuggestion:{type:Object,default:null},channelSuggestion:{type:Object,default:null},slashCommandSuggestion:{type:Object,default:null},allowBlockquote:{type:Boolean,default:!0},allowBold:{type:Boolean,default:!0},allowBulletList:{type:Boolean,default:!0},allowItalic:{type:Boolean,default:!0},allowStrike:{type:Boolean,default:!0},allowUnderline:{type:Boolean,default:!0},allowCode:{type:Boolean,default:!0},allowCodeblock:{type:Boolean,default:!0},allowInlineImages:{type:Boolean,default:!1},allowFontColor:{type:Boolean,default:!1},allowFontFamily:{type:Boolean,default:!1},additionalExtensions:{type:Array,default:()=>[]},hideLinkBubbleMenu:{type:Boolean,default:!1},useDivTags:{type:Boolean,default:!1}},emits:["input","json-input","html-input","text-input","markdown-input","update:modelValue","blur","focus","enter","edit-link","selected","selected-command","mention-click","channel-click"],data(){return{editor:null,tippyOptions:{appendTo:()=>{var e;return(e=_.returnFirstEl(this.$refs.editor.$el).getRootNode())==null?void 0:e.querySelector("body")},placement:"top-start"},i18n:new de.DialtoneLocalization,jsonToMarkdownConverter:{convertToMarkdown(e){return this.processNode(e)},processNodeContent(e){return e.content?e.content.map(t=>this.processNode(t)).join(""):""},processNode(e){if(!e)return"";const r={doc:n=>this.processDocNode(n),paragraph:n=>this.processParagraphNode(n),text:n=>this.processTextNode(n),hardBreak:()=>this.processHardBreakNode(),blockquote:n=>this.processBlockquoteNode(n),bulletList:n=>this.processBulletListNode(n),orderedList:n=>this.processOrderedListNode(n),listItem:n=>this.processListItemNode(n),codeBlock:n=>this.processCodeBlockNode(n),mention:n=>this.processMentionNode(n),channel:n=>this.processChannelNode(n),"slash-commands":n=>this.processSlashCommandsNode(n),emoji:n=>this.processEmojiNode(n)}[e.type];return r?r(e):this.processUnknownNode(e)},processDocNode(e){return this.processNodeContent(e)},processParagraphNode(e){const t=this.processNodeContent(e);return t?t+`
2
2
  `:`
3
3
  `},processTextNode(e){let t=e.text||"";return e.marks&&(t=this.applyMarks(t,e.marks)),t},processHardBreakNode(){return`
4
4
  `},processBlockquoteNode(e){return this.processNodeContent(e).split(`
@@ -7,9 +7,9 @@
7
7
  `},processBulletListNode(e){return this.processNodeContent(e)},processOrderedListNode(e){return e.content?e.content.map((t,r)=>this.processNode(t).replace(/^- /,`${r+1}. `)).join(""):""},processListItemNode(e){const t=this.processNodeContent(e);return t?`- ${t.replace(/\n$/,"")}
8
8
  `:""},processCodeBlockNode(e){return`\`\`\`
9
9
  ${this.processNodeContent(e)}
10
- \`\`\``},processMentionNode(e){var s,i,a;const t=((s=e.attrs)==null?void 0:s.name)||"",r=((i=e.attrs)==null?void 0:i.id)||"",n=((a=e.attrs)==null?void 0:a.contactKey)||"";return`<!-- @mention: {"id": "${r}", "contactKey": "${n}", "name": "${t}"} -->`},processChannelNode(e){var s,i,a;const t=((s=e.attrs)==null?void 0:s.name)||"",r=((i=e.attrs)==null?void 0:i.id)||"",n=((a=e.attrs)==null?void 0:a.locked.toString())||"";return`<!-- @channel: {"id": "${r}", "name": "${t}", "locked": "${n}"} -->`},processSlashCommandsNode(e){var n,s;const t=((n=e.attrs)==null?void 0:n.command)||"",r=((s=e.attrs)==null?void 0:s.parameters)||"";return`/${t}${r?` ${r}`:""}`},processEmojiNode(e){var t;return((t=e.attrs)==null?void 0:t.code)||""},processUnknownNode(e){return this.processNodeContent(e)},applyMarks(e,t){let r=e;return[...t].sort((s,i)=>{const a={link:0,bold:1,italic:2,strike:3,code:4};return(a[s.type]||5)-(a[i.type]||5)}).forEach(s=>{var i;switch(s.type){case"bold":r=`**${r}**`;break;case"italic":r=`*${r}*`;break;case"strike":r=`~~${r}~~`;break;case"code":r=`\`${r}\``;break;case"link":{const a=((i=s.attrs)==null?void 0:i.href)||"";r=`[${r}](${a})`;break}}}),r}}}},computed:{attrs(){return{...this.$attrs,onInput:()=>{},onFocus:()=>{},onBlur:()=>{}}},extensions(){const e=[A,Y,Q,j];e.push(this.useDivTags?Ae:R),this.allowBold&&e.push(H),this.allowBlockquote&&e.push(O),this.allowBulletList&&(e.push(K),e.push(U.extend({renderText({node:n}){return n.textContent}})),e.push(z)),this.allowItalic&&e.push(W),this.allowStrike&&e.push(X),this.allowUnderline&&e.push(J),this.placeholder&&e.push(q.configure({placeholder:this.placeholder}));const t=this,r=u.Extension.create({addKeyboardShortcuts(){return{"Shift-Enter":({editor:n})=>t.allowLineBreaks?!1:(n.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>t.allowBulletList&&s.splitListItem("listItem"),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),!0),Enter:()=>t.allowLineBreaks?!1:(t.$emit("enter"),!0)}}});if(e.push(r),this.link&&e.push(F.extend({inclusive:!1,addKeyboardShortcuts(){return{"Mod-k":()=>(t.$emit("edit-link"),!0)}}}).configure({HTMLAttributes:{class:"d-link d-wb-break-all"},openOnClick:!1,autolink:!0,protocols:x.RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS})),this.customLink&&e.push(this.getExtension(Pe,this.customLink)),this.mentionSuggestion){const n={...this.mentionSuggestion,...st};e.push(Ke.configure({suggestion:n}))}if(this.channelSuggestion){const n={...this.channelSuggestion,...lt};e.push(ze.configure({suggestion:n}))}if(this.slashCommandSuggestion){const n={...this.slashCommandSuggestion,...gt};e.push(Qe.configure({suggestion:n,onSelectedCommand:s=>{this.$emit("selected-command",s)}}))}return e.push(Ne),e.push(G.configure({types:["paragraph"]})),this.allowCode&&e.push(V),this.allowCodeblock&&e.push(P.extend({renderText({node:n}){return`\`\`\`
10
+ \`\`\``},processMentionNode(e){var s,i,a;const t=((s=e.attrs)==null?void 0:s.name)||"",r=((i=e.attrs)==null?void 0:i.id)||"",n=((a=e.attrs)==null?void 0:a.contactKey)||"";return`<!-- @mention: {"id": "${r}", "contactKey": "${n}", "name": "${t}"} -->`},processChannelNode(e){var i,a,c,l;const t=((i=e.attrs)==null?void 0:i.name)||"",r=((a=e.attrs)==null?void 0:a.id)||"",n=((c=e.attrs)==null?void 0:c.locked.toString())||"",s=((l=e.attrs)==null?void 0:l.channelKey)||"";return`<!-- @channel: {"id": "${r}", "channelKey": "${s}", "name": "${t}", "locked": "${n}"} -->`},processSlashCommandsNode(e){var n,s;const t=((n=e.attrs)==null?void 0:n.command)||"",r=((s=e.attrs)==null?void 0:s.parameters)||"";return`/${t}${r?` ${r}`:""}`},processEmojiNode(e){var t;return((t=e.attrs)==null?void 0:t.code)||""},processUnknownNode(e){return this.processNodeContent(e)},applyMarks(e,t){let r=e;return[...t].sort((s,i)=>{const a={link:0,bold:1,italic:2,strike:3,code:4};return(a[s.type]||5)-(a[i.type]||5)}).forEach(s=>{var i;switch(s.type){case"bold":r=`**${r}**`;break;case"italic":r=`*${r}*`;break;case"strike":r=`~~${r}~~`;break;case"code":r=`\`${r}\``;break;case"link":{const a=((i=s.attrs)==null?void 0:i.href)||"";r=`[${r}](${a})`;break}}}),r}}}},computed:{attrs(){return{...this.$attrs,onInput:()=>{},onFocus:()=>{},onBlur:()=>{}}},extensions(){const e=[A,Y,Q,j];e.push(this.useDivTags?Ae:$),this.allowBold&&e.push(H),this.allowBlockquote&&e.push(O),this.allowBulletList&&(e.push(K),e.push(U.extend({renderText({node:n}){return n.textContent}})),e.push(z)),this.allowItalic&&e.push(W),this.allowStrike&&e.push(X),this.allowUnderline&&e.push(J),this.placeholder&&e.push(q.configure({placeholder:this.placeholder}));const t=this,r=u.Extension.create({addKeyboardShortcuts(){return{"Shift-Enter":({editor:n})=>t.allowLineBreaks?!1:(n.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>t.allowBulletList&&s.splitListItem("listItem"),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),!0),Enter:()=>t.allowLineBreaks?!1:(t.$emit("enter"),!0)}}});if(e.push(r),this.link&&e.push(F.extend({inclusive:!1,addKeyboardShortcuts(){return{"Mod-k":()=>(t.$emit("edit-link"),!0)}}}).configure({HTMLAttributes:{class:"d-link d-wb-break-all"},openOnClick:!1,autolink:!0,protocols:x.RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS})),this.customLink&&e.push(this.getExtension(Pe,this.customLink)),this.mentionSuggestion){const n={...this.mentionSuggestion,...st};e.push(Ke.configure({suggestion:n}))}if(this.channelSuggestion){const n={...this.channelSuggestion,...lt};e.push(ze.configure({suggestion:n}))}if(this.slashCommandSuggestion){const n={...this.slashCommandSuggestion,...gt};e.push(Qe.configure({suggestion:n,onSelectedCommand:s=>{this.$emit("selected-command",s)}}))}return e.push(Ne),e.push(G.configure({types:["paragraph"]})),this.allowCode&&e.push(V),this.allowCodeblock&&e.push(P.extend({renderText({node:n}){return`\`\`\`
11
11
  ${n.textContent}
12
- \`\`\``}}).configure({HTMLAttributes:{class:"d-rich-text-editor__code-block"}})),this.allowInlineImages&&e.push(Ve),(this.allowFontFamily||this.allowFontColor)&&(e.push(Z),this.allowFontColor&&e.push(ee),this.allowFontFamily&&e.push(te)),this.additionalExtensions.length&&e.push(...this.additionalExtensions),e},inputAttrs(){const e={"aria-label":this.inputAriaLabel,"aria-multiline":!0,role:"textbox"};return this.editable||(e["aria-readonly"]=!0),e}},watch:{editable(e){this.editor.setEditable(e),this.updateEditorAttributes({"aria-readonly":!e})},inputClass(e){this.updateEditorAttributes({class:e})},inputAriaLabel(e){this.updateEditorAttributes({"aria-label":e})},extensions(){this.destroyEditor(),this.createEditor()},modelValue(e){this.processValue(e)}},created(){this.createEditor()},beforeUnmount(){this.destroyEditor()},mounted(){_.warnIfUnmounted(_.returnFirstEl(this.$el),this.$options.name),this.processValue(this.modelValue,!1)},methods:{createEditor(){this.editor=new d.Editor({autofocus:this.autoFocus,content:this.modelValue,editable:this.editable,extensions:this.extensions,parseOptions:{preserveWhitespace:"full"},editorProps:{attributes:{...this.inputAttrs,class:this.inputClass},handleKeyDown:(e,t)=>{if(!this.preventTyping)return!1;const r=["Backspace"];return!this.allowLineBreaks&&!t.shiftKey&&r.push("Enter"),!r.includes(t.key)},handlePaste:(e,t)=>{const r=t.clipboardData||window.clipboardData,n=r.getData("text/plain"),s=r.getData("text/html");return this.processPasteData(e,n,s)},transformPastedHTML(e){return e.replace(/(<\/\w+>)((<br \/>)+)/g,"$2$3$1")}}}),this.addEditorListeners()},bubbleMenuShouldShow({editor:e}){return e.isActive("link")},getSelectedLinkText(e){var c,l,m;const{view:t,state:r}=e,{from:n,to:s}=t.state.selection,i=r.doc.textBetween(n,s,""),a=this.editor.state.doc.nodeAt(n);return a&&((m=(l=(c=a.marks)==null?void 0:c.at(0))==null?void 0:l.type)==null?void 0:m.name)==="link"?a.textContent:i},editLink(){const e=this.getSelectedLinkText(this.editor),t={href:this.editor.getAttributes("link").href,text:e};this.$emit("edit-link",t)},removeLink(){var e,t,r,n;(n=(r=(t=(e=this.editor)==null?void 0:e.chain())==null?void 0:t.focus())==null?void 0:r.unsetLink())==null||n.run()},openLink(){var t,r;(r=(t=this.editor)==null?void 0:t.chain())==null||r.focus();const e=this.editor.getAttributes("link").href;window.open(e,"_blank")},setLink(e,t,r,n=x.RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS,s){var c,l,m;if(!e){this.removeLink();return}n.find(p=>p.test(e))||(e=`${s}${e}`),this.editor.chain().focus().extendMarkRange("link").run();const a=(m=(l=(c=this.editor)==null?void 0:c.view)==null?void 0:l.state)==null?void 0:m.selection;this.editor.chain().focus().insertContent(t).setTextSelection({from:a.from,to:a.from+t.length}).setLink({href:e,class:r.class}).run()},processValue(e,t=!0){const r=this.getOutput();if(!(t&&le(e,r))){if(typeof e=="string"&&this.outputFormat==="text"){const n=new RegExp(`(${$.emojiPattern})`,"g");e=e==null?void 0:e.replace(n,'<emoji-component code="$1"></emoji-component>')}this.editor.commands.setContent(e,!1,{preserveWhitespace:"full"})}},destroyEditor(){this.editor.destroy()},insertPlainTextWithHardBreaks(e,t){const s=(this.pasteRichText?t:t.replace(/\r\n/g,`
12
+ \`\`\``}}).configure({HTMLAttributes:{class:"d-rich-text-editor__code-block"}})),this.allowInlineImages&&e.push(Ve),(this.allowFontFamily||this.allowFontColor)&&(e.push(Z),this.allowFontColor&&e.push(ee),this.allowFontFamily&&e.push(te)),this.additionalExtensions.length&&e.push(...this.additionalExtensions),e},inputAttrs(){const e={"aria-label":this.inputAriaLabel,"aria-multiline":!0,role:"textbox"};return this.editable||(e["aria-readonly"]=!0),e}},watch:{editable(e){this.editor.setEditable(e),this.updateEditorAttributes({"aria-readonly":!e})},inputClass(e){this.updateEditorAttributes({class:e})},inputAriaLabel(e){this.updateEditorAttributes({"aria-label":e})},extensions(){this.destroyEditor(),this.createEditor()},modelValue(e){this.processValue(e)}},created(){this.createEditor()},beforeUnmount(){this.destroyEditor()},mounted(){_.warnIfUnmounted(_.returnFirstEl(this.$el),this.$options.name),this.processValue(this.modelValue,!1)},methods:{createEditor(){this.editor=new d.Editor({autofocus:this.autoFocus,content:this.modelValue,editable:this.editable,extensions:this.extensions,parseOptions:{preserveWhitespace:"full"},editorProps:{attributes:{...this.inputAttrs,class:this.inputClass},handleKeyDown:(e,t)=>{if(!this.preventTyping)return!1;const r=["Backspace"];return!this.allowLineBreaks&&!t.shiftKey&&r.push("Enter"),!r.includes(t.key)},handlePaste:(e,t)=>{const r=t.clipboardData||window.clipboardData,n=r.getData("text/plain"),s=r.getData("text/html");return this.processPasteData(e,n,s)},transformPastedHTML(e){return e.replace(/(<\/\w+>)((<br \/>)+)/g,"$2$3$1")}}}),this.addEditorListeners()},bubbleMenuShouldShow({editor:e}){return e.isActive("link")},getSelectedLinkText(e){var c,l,m;const{view:t,state:r}=e,{from:n,to:s}=t.state.selection,i=r.doc.textBetween(n,s,""),a=this.editor.state.doc.nodeAt(n);return a&&((m=(l=(c=a.marks)==null?void 0:c.at(0))==null?void 0:l.type)==null?void 0:m.name)==="link"?a.textContent:i},editLink(){const e=this.getSelectedLinkText(this.editor),t={href:this.editor.getAttributes("link").href,text:e};this.$emit("edit-link",t)},removeLink(){var e,t,r,n;(n=(r=(t=(e=this.editor)==null?void 0:e.chain())==null?void 0:t.focus())==null?void 0:r.unsetLink())==null||n.run()},openLink(){var t,r;(r=(t=this.editor)==null?void 0:t.chain())==null||r.focus();const e=this.editor.getAttributes("link").href;window.open(e,"_blank")},setLink(e,t,r,n=x.RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS,s){var c,l,m;if(!e){this.removeLink();return}n.find(p=>p.test(e))||(e=`${s}${e}`),this.editor.chain().focus().extendMarkRange("link").run();const a=(m=(l=(c=this.editor)==null?void 0:c.view)==null?void 0:l.state)==null?void 0:m.selection;this.editor.chain().focus().insertContent(t).setTextSelection({from:a.from,to:a.from+t.length}).setLink({href:e,class:r.class}).run()},processValue(e,t=!0){const r=this.getOutput();if(!(t&&le(e,r))){if(typeof e=="string"&&this.outputFormat==="text"){const n=new RegExp(`(${R.emojiPattern})`,"g");e=e==null?void 0:e.replace(n,'<emoji-component code="$1"></emoji-component>')}this.editor.commands.setContent(e,!1,{preserveWhitespace:"full"})}},destroyEditor(){this.editor.destroy()},insertPlainTextWithHardBreaks(e,t){const s=(this.pasteRichText?t:t.replace(/\r\n/g,`
13
13
  `).replace(/\n\n/g,`
14
14
  `)).replace(/[\r\n]+$/,"").split(/\r?\n/),i=[];for(let a=0;a<s.length;a++)a>0&&i.push({type:"hardBreak"}),s[a]&&i.push({type:"text",text:s[a]});this.editor.chain().focus().insertContent(i).run()},shouldPreserveLineBreaks(e,t){return this.pasteRichText?!t&&e&&this.hasBlankLines(e):!!e},processPasteData(e,t,r){if(this.shouldPreserveLineBreaks(t,r))return this.insertPlainTextWithHardBreaks(e,t),!0;if(this.shouldHandlePreformattedHTML(r)){const n=this.extractPreformattedText(r);if(n&&n.includes(`
15
15
  `))return this.insertPlainTextWithHardBreaks(e,n),!0}return!1},shouldHandlePreformattedHTML(e){return this.pasteRichText&&e&&this.containsPreformattedContent(e)},containsPreformattedContent(e){const t=document.createElement("div");t.innerHTML=e;const r=t.querySelectorAll("*");for(const n of r)if(this.hasPreWhitespace(n)&&this.hasLineBreaks(n))return!0;return!1},hasPreWhitespace(e){const t=e.getAttribute("style")||"",r=e.style.whiteSpace||"",n=r==="pre"||r==="pre-wrap",s=t.includes("white-space: pre");return n||s},hasLineBreaks(e){return e.textContent&&e.textContent.includes(`
@@ -17,5 +17,5 @@ ${n.textContent}
17
17
 
18
18
  `)||/\n\s*\n/.test(e)},extractPreformattedText(e){const t=document.createElement("div");return t.innerHTML=e,this.walkAndExtractText(t)},walkAndExtractText(e){let t="";if(e.nodeType===Node.TEXT_NODE)t+=e.textContent;else if(e.nodeType===Node.ELEMENT_NODE)if(this.hasPreWhitespace(e))t+=e.textContent;else for(const r of e.childNodes)t+=this.walkAndExtractText(r);return t},triggerInputChangeEvents(){const e=this.getOutput();this.$emit("input",e),this.$emit("update:modelValue",e);const t=this.editor.getJSON();this.$emit("json-input",t);const r=this.editor.getHTML();this.$emit("html-input",r);const n=this.editor.getText({blockSeparator:`
19
19
  `});this.$emit("text-input",n);const s=this.jsonToMarkdownConverter.convertToMarkdown(t);this.$emit("markdown-input",s)},addEditorListeners(){this.editor.on("create",()=>{this.triggerInputChangeEvents()}),this.editor.on("update",()=>{this.triggerInputChangeEvents()}),this.editor.on("selectionUpdate",({editor:e})=>{this.$emit("selected",this.getSelectedLinkText(e))}),this.editor.on("focus",({event:e})=>{this.$emit("focus",e)}),this.editor.on("blur",({event:e})=>{this.$emit("blur",e)}),this.editor.on("mention-click",e=>{this.$emit("mention-click",e)}),this.editor.on("channel-click",e=>{this.$emit("channel-click",e)})},getOutput(){switch(this.outputFormat){case"json":return this.editor.getJSON();case"html":return this.editor.getHTML();case"markdown":return this.jsonToMarkdownConverter.convertToMarkdown(this.editor.getJSON());case"text":default:return this.editor.getText({blockSeparator:`
20
- `})}},getExtension(e,t){var r;return typeof t=="boolean"?e:(r=e.configure)==null?void 0:r.call(e,t)},updateEditorAttributes(e){this.editor.setOptions({editorProps:{attributes:{...this.inputAttrs,class:this.inputClass,...e}}})},focusEditor(){this.editor.commands.focus()}}},_t={class:"d-popover__dialog"};function wt(e,t,r,n,s,i){const a=o.resolveComponent("dt-button"),c=o.resolveComponent("dt-stack"),l=o.resolveComponent("bubble-menu"),m=o.resolveComponent("editor-content");return o.openBlock(),o.createElementBlock("div",null,[s.editor&&r.link&&!r.hideLinkBubbleMenu?(o.openBlock(),o.createBlock(l,{key:0,editor:s.editor,"should-show":i.bubbleMenuShouldShow,"tippy-options":s.tippyOptions,style:{visibility:"visible"}},{default:o.withCtx(()=>[o.createElementVNode("div",_t,[o.createVNode(c,{direction:"row",class:"d-rich-text-editor-bubble-menu__button-stack",gap:"0"},{default:o.withCtx(()=>[o.createVNode(a,{kind:"muted",importance:"clear",onClick:i.editLink},{default:o.withCtx(()=>[o.createTextVNode(o.toDisplayString(s.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_EDIT_BUTTON_LABEL")),1)]),_:1},8,["onClick"]),o.createVNode(a,{kind:"muted",importance:"clear",onClick:i.openLink},{default:o.withCtx(()=>[o.createTextVNode(o.toDisplayString(s.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_OPEN_LINK_BUTTON_LABEL")),1)]),_:1},8,["onClick"]),o.createVNode(a,{kind:"danger",importance:"clear",onClick:i.removeLink},{default:o.withCtx(()=>[o.createTextVNode(o.toDisplayString(s.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_REMOVE_BUTTON_LABEL")),1)]),_:1},8,["onClick"])]),_:1})])]),_:1},8,["editor","should-show","tippy-options"])):o.createCommentVNode("",!0),o.createVNode(m,o.mergeProps({ref:"editor",editor:s.editor,class:"d-rich-text-editor","data-qa":"dt-rich-text-editor"},i.attrs),null,16,["editor"])])}const Ct=h._(kt,[["render",wt]]);exports.default=Ct;
20
+ `})}},getExtension(e,t){var r;return typeof t=="boolean"?e:(r=e.configure)==null?void 0:r.call(e,t)},updateEditorAttributes(e){this.editor.setOptions({editorProps:{attributes:{...this.inputAttrs,class:this.inputClass,...e}}})},focusEditor(){this.editor.commands.focus()}}},_t={class:"d-popover__dialog"};function wt(e,t,r,n,s,i){const a=o.resolveComponent("dt-button"),c=o.resolveComponent("dt-stack"),l=o.resolveComponent("bubble-menu"),m=o.resolveComponent("editor-content");return o.openBlock(),o.createElementBlock("div",null,[s.editor&&r.link&&!r.hideLinkBubbleMenu?(o.openBlock(),o.createBlock(l,{key:0,editor:s.editor,"should-show":i.bubbleMenuShouldShow,"tippy-options":s.tippyOptions,style:{visibility:"visible"}},{default:o.withCtx(()=>[o.createElementVNode("div",_t,[o.createVNode(c,{direction:"row",class:"d-rich-text-editor-bubble-menu__button-stack",gap:"0"},{default:o.withCtx(()=>[o.createVNode(a,{kind:"muted",importance:"clear",onClick:i.editLink},{default:o.withCtx(()=>[o.createTextVNode(o.toDisplayString(s.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_EDIT_BUTTON_LABEL")),1)]),_:1},8,["onClick"]),o.createVNode(a,{kind:"muted",importance:"clear",onClick:i.openLink},{default:o.withCtx(()=>[o.createTextVNode(o.toDisplayString(s.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_OPEN_LINK_BUTTON_LABEL")),1)]),_:1},8,["onClick"]),o.createVNode(a,{kind:"danger",importance:"clear",onClick:i.removeLink},{default:o.withCtx(()=>[o.createTextVNode(o.toDisplayString(s.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_REMOVE_BUTTON_LABEL")),1)]),_:1},8,["onClick"])]),_:1})])]),_:1},8,["editor","should-show","tippy-options"])):o.createCommentVNode("",!0),o.createVNode(m,o.mergeProps({ref:"editor",editor:s.editor,class:"d-rich-text-editor","data-qa":"dt-rich-text-editor"},i.attrs),null,16,["editor"])])}const yt=h._(kt,[["render",wt]]);exports.default=yt;
21
21
  //# sourceMappingURL=rich-text-editor.cjs.map