@dialpad/dialtone 9.161.0 → 9.162.0
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/tokens/doc.json +102311 -102311
- package/dist/vue3/lib/rich-text-editor/rich-text-editor.cjs +10 -10
- package/dist/vue3/lib/rich-text-editor/rich-text-editor.cjs.map +1 -1
- package/dist/vue3/lib/rich-text-editor/rich-text-editor.js +2351 -830
- package/dist/vue3/lib/rich-text-editor/rich-text-editor.js.map +1 -1
- package/dist/vue3/node_modules/@tiptap/vue-3.cjs +1 -1
- package/dist/vue3/node_modules/@tiptap/vue-3.cjs.map +1 -1
- package/dist/vue3/node_modules/@tiptap/vue-3.js +233 -209
- package/dist/vue3/node_modules/@tiptap/vue-3.js.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/channels/suggestion.d.ts +1 -6
- package/dist/vue3/types/components/rich_text_editor/extensions/channels/suggestion.d.ts.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/emoji/suggestion.d.ts +1 -6
- package/dist/vue3/types/components/rich_text_editor/extensions/emoji/suggestion.d.ts.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/mentions/suggestion.d.ts +1 -6
- package/dist/vue3/types/components/rich_text_editor/extensions/mentions/suggestion.d.ts.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/slash_command/suggestion.d.ts +1 -6
- package/dist/vue3/types/components/rich_text_editor/extensions/slash_command/suggestion.d.ts.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/utils/suggestion_utils.d.ts +29 -0
- package/dist/vue3/types/components/rich_text_editor/extensions/utils/suggestion_utils.d.ts.map +1 -0
- package/package.json +31 -37
- package/dist/vue3/types/components/rich_text_editor/extensions/tippy_plugins/hide_on_esc.d.ts +0 -12
- package/dist/vue3/types/components/rich_text_editor/extensions/tippy_plugins/hide_on_esc.d.ts.map +0 -1
- package/dist/vue3/types/components/rich_text_editor/rich_text_editor.vue.d.ts +0 -768
- package/dist/vue3/types/components/rich_text_editor/rich_text_editor.vue.d.ts.map +0 -1
- package/dist/vue3/types/recipes/conversation_view/editor/editor.vue.d.ts +0 -4072
- package/dist/vue3/types/recipes/conversation_view/editor/editor.vue.d.ts.map +0 -1
- package/dist/vue3/types/recipes/conversation_view/message_input/message_input.vue.d.ts +0 -8005
- package/dist/vue3/types/recipes/conversation_view/message_input/message_input.vue.d.ts.map +0 -1
|
@@ -1,21 +1,21 @@
|
|
|
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"),q=require("@tiptap/extension-code"),j=require("@tiptap/extension-document"),H=require("@tiptap/extension-gapcursor"),K=require("@tiptap/extension-hard-break"),R=require("@tiptap/extension-paragraph"),W=require("@tiptap/extension-placeholder"),F=require("@tiptap/extension-bold"),U=require("@tiptap/extension-bullet-list"),z=require("@tiptap/extension-italic"),X=require("@tiptap/extension-link"),G=require("@tiptap/extension-list-item"),J=require("@tiptap/extension-ordered-list"),Y=require("@tiptap/extension-strike"),Q=require("@tiptap/extension-underline"),Z=require("@tiptap/extension-text"),ee=require("@tiptap/extension-text-align"),te=require("@tiptap/extension-history"),ne=require("@tiptap/extension-table"),oe=require("@tiptap/extension-table-cell"),re=require("@tiptap/extension-table-header"),se=require("@tiptap/extension-table-row"),ie=require("@tiptap/extension-text-style"),ae=require("@tiptap/extension-color"),ce=require("@tiptap/extension-font-family"),k=require("@tiptap/pm/state"),le=require("@tiptap/suggestion"),I=require("regex-combined-emojis"),o=require("vue"),h=require("../../_plugin-vue_export-helper-BRilXfQE.cjs"),D=require("../emoji/emoji.cjs"),g=require("../../common/emoji/index.cjs"),de=require("../list-item/list-item.cjs"),y=require("../stack/stack.cjs"),T=require("tippy.js"),C=require("../../common/utils/index.cjs"),ue=require("@tiptap/extension-image"),S=require("@tiptap/extension-mention"),$=require("../link/link.cjs"),me=require("@dialpad/dialtone-icons/vue3"),A=require("../../localization/index.cjs"),he=require("../input/input.cjs"),pe=require("../popover/popover.cjs"),V=require("../button/button.cjs"),fe=require("../badge/badge.cjs"),x=require("./rich-text-editor-constants.cjs"),ge=require("../avatar/avatar.cjs"),_e=require("@dialpad/dialtone-icons/vue3/hash"),ke=require("@dialpad/dialtone-icons/vue3/lock"),we=require("deep-equal"),Ce={compatConfig:{MODE:3},name:"EmojiComponent",components:{NodeViewWrapper:d.NodeViewWrapper,DtEmoji:D.default},props:d.nodeViewProps};function ye(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 be=h._(Ce,[["render",ye]]),xe={compatConfig:{MODE:3},name:"SuggestionList",components:{DtListItem:de.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}}}},Te={class:"d-popover__dialog d-suggestion-list__container"},Ee={ref:"suggestionList",class:"d-suggestion-list"};function ve(e,t,r,n,s,i){const a=o.resolveComponent("dt-list-item");return o.openBlock(),o.createElementBlock("div",Te,[o.withDirectives(o.createElementVNode("ul",Ee,[(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 E=h._(xe,[["render",ve]]),Le={compatConfig:{MODE:3},name:"EmojiSuggestion",components:{DtEmoji:D.default,DtStack:y.default},props:{item:{type:Object,required:!0}}};function Se(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 Ne=h._(Le,[["render",Se]]),v={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)}}}},Be=20,Re=(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)},Ie={items:({query:e})=>{if(e.length<2)return[];const t=Object.values(g.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,Be).sort((n,s)=>Re(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(E,{props:{itemComponent:o.markRaw(Ne),itemType:"emoji",...n},editor:n.editor}),n.clientRect&&(t=T("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:[v]}),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}}}},De=/(:\w+:)$/,$e=new RegExp(I.emojiPattern+"$"),Ae=e=>{if(e&&g.codeToEmojiData(e[0]))return{text:e[2]||e[0]}},Ve=e=>[...e.matchAll(g.emojiShortCodeRegex)].filter(r=>g.codeToEmojiData(r[0])).map(r=>({index:r.index,text:r[0],match:r})),Me=u.Node.create({name:"emoji",addOptions(){return{HTMLAttributes:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addNodeView(){return d.VueNodeViewRenderer(be)},addAttributes(){return{code:{default:null}}},parseHTML(){return[{tag:"emoji-component"}]},renderText({node:e}){return g.stringToUnicode(g.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(De)||e.match($e);if(t)return Ae(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:Ve,type:this.type,getAttributes(e){return{code:e[0]}}}),u.nodePasteRule({find:g.emojiRegex,type:this.type,getAttributes(e){return{code:e[0]}}})]},addProseMirrorPlugins(){return[le({char:":",pluginKey:new k.PluginKey("emoji"),editor:this.editor,...this.options.suggestion,...Ie})]},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 Oe(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 Pe(e,t){return!["#","@"].includes(e.charAt(t.index))&&!["#","@"].includes(e.charAt(t.index-1))}function qe(e){const t=new RegExp("(?:"+[`[!?.,:;'"]`,"(?:&|&)(?:lt|gt|quot|apos|raquo|laquo|rsaquo|lsaquo);)+$"].join("|"),"g");return e.replace(t,"")}function je(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 L(e,t,r,n){const s=je(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:L(e,i,r,n)}function He(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=C.getPhoneNumberRegex(1,15);function B(e,t,r,n,s,i){if(!e)return;let a=r-t-1;a=a<0?0:a;const c=n-t,l=L(e,a,"left",N),m=L(e,c,"right",N),p=e.slice(l.from,m.to);Oe(p,C.linkRegex,Pe).forEach(_=>{const w=qe(_[0]),b=t+l.from+_.index+1,M=b+w.length;s.addMark(b,M,i.create())})}function Ke(e){let t=!1;return new k.Plugin({key:new k.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||B(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:f})=>{He(f,s.doc,a,e.type),u.findChildrenInRange(s.doc,f,w=>w.isTextblock).forEach(({node:w,pos:b})=>{B(w.textContent,b,p.from,f.to,a,e.type)})}),a}})}const We={class:"d-link d-c-text d-d-inline-block d-wb-break-all",rel:"noopener noreferrer nofollow"},Fe=u.Mark.create({name:"CustomLink",renderHTML({HTMLAttributes:e}){return["a",u.mergeAttributes(this.options.HTMLAttributes,e,We)]},renderText({node:e}){return e.attrs.text},addProseMirrorPlugins(){return[Ke({type:this.type})]}}),Ue=ue.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}),ze=R.extend({parseHTML(){return[{tag:"div"}]},renderHTML({HTMLAttributes:e}){return["div",u.mergeAttributes(this.options.HTMLAttributes,e),0]}}),Xe={compatConfig:{MODE:3},name:"MentionComponent",components:{NodeViewWrapper:d.NodeViewWrapper,DtLink:$.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 Ge(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 Je=h._(Xe,[["render",Ge]]),Ye=S.extend({addNodeView(){return d.VueNodeViewRenderer(Je)},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 k.PluginKey("mentionSuggestion")}}),Qe={compatConfig:{MODE:3},name:"ChannelComponent",components:{NodeViewWrapper:d.NodeViewWrapper,DtLink:$.default,DtIconLock:me.DtIconLock,DtStack:y.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 Ze(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 et=h._(Qe,[["render",Ze]]),tt=S.extend({name:"channel",addNodeView(){return d.VueNodeViewRenderer(et)},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 k.PluginKey("channelSuggestion")}}),nt={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 ot(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 rt=h._(nt,[["render",ot]]),st=(e,t)=>[...e.matchAll(t)].map(n=>{let s=n[2];return s.endsWith(" ")||(s+=" "),{index:n.index,text:s,match:n}}),it=S.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(rt)},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=>st(n,t),type:this.type,getAttributes(n){return{command:n[0].trim()}}})]}}).configure({suggestion:{char:"/",pluginKey:new k.PluginKey("slashCommandSuggestion")}}),at=100,ct={name:"VariableComponent",components:{DtBadge:fe.default,DtButton:V.default,DtPopover:pe.default,DtInput:he.default,NodeViewWrapper:d.NodeViewWrapper},props:d.nodeViewProps,data(){return{i18n:new A.DialtoneLocalization,MAX_VARIABLE_ALT_LENGTH:at}},computed:{altText:{get(){var e,t;return((t=(e=this.node)==null?void 0:e.attrs)==null?void 0:t.altText)||""},set(e){this.updateAttributes({altText:e})}},variableId(){var e,t;return(t=(e=this.node)==null?void 0:e.attrs)==null?void 0:t.id},placeholder(){var e;return((e=this.variableData)==null?void 0:e.placeholder)||""},variableItems(){var e,t;return((t=(e=this.extension)==null?void 0:e.options)==null?void 0:t.variableItems)||[]},variableData(){return this.variableItems.find(e=>e.id===this.variableId)},badgeLabel(){return`{} ${this.placeholder}`},placeholderText(){return`Replaces ${this.placeholder}`}}};function lt(e,t,r,n,s,i){const a=o.resolveComponent("dt-badge"),c=o.resolveComponent("dt-button"),l=o.resolveComponent("dt-input"),m=o.resolveComponent("dt-popover"),p=o.resolveComponent("node-view-wrapper");return o.openBlock(),o.createBlock(p,{class:"d-d-inline-block"},{default:o.withCtx(()=>[o.createVNode(m,{padding:"small","navigation-type":"arrow-keys",placement:"top-start",modal:!1},{anchor:o.withCtx(({attrs:f})=>[o.createVNode(c,o.mergeProps(f,{kind:"unstyled"}),{default:o.withCtx(()=>[o.createVNode(a,{text:i.badgeLabel,contenteditable:"false"},null,8,["text"])]),_:1},16)]),content:o.withCtx(({close:f})=>[o.createVNode(l,{modelValue:i.altText,"onUpdate:modelValue":t[0]||(t[0]=_=>i.altText=_),"root-class":"d-p8 d-w332",label:s.i18n.$t("DIALTONE_EDITOR_VARIABLE_LABEL"),placeholder:i.placeholderText,validate:{length:{description:s.i18n.$t("DIALTONE_EDITOR_VARIABLE_VALIDATE_DESCRIPTION"),message:s.i18n.$t("DIALTONE_EDITOR_VARIABLE_VALIDATE_MESSAGE"),max:s.MAX_VARIABLE_ALT_LENGTH,warn:s.MAX_VARIABLE_ALT_LENGTH,limitMaxLength:!0}},onKeyup:o.withKeys(_=>f(),["enter"])},null,8,["modelValue","label","placeholder","validate","onKeyup"])]),_:1})]),_:1})}const dt=h._(ct,[["render",lt]]),ut=u.Node.create({name:"variable",group:"inline",inline:!0,selectable:!0,atom:!0,addOptions(){return{HTMLAttributes:{},variableItems:[]}},addNodeView(){return d.VueNodeViewRenderer(dt)},addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute("data-variable-id"),renderHTML:e=>e.id?{"data-variable-id":e.id}:{}},altText:{default:"",parseHTML:e=>e.getAttribute("data-alt-text"),renderHTML:e=>e.altText?{"data-alt-text":e.altText}:{}}}},parseHTML(){return[{tag:"variable"}]},renderText({node:e}){return e.attrs.altText},renderHTML({node:e,HTMLAttributes:t}){return["variable",u.mergeAttributes(this.options.HTMLAttributes,t,{"data-variable-id":e.attrs.id,"data-alt-text":e.attrs.altText})]},addCommands(){return{insertVariable:(e={})=>({commands:t})=>t.insertContent({type:this.name,attrs:{id:e.id||null,altText:e.altText||""}})}}}),mt={compatConfig:{MODE:3},name:"MentionSuggestion",components:{DtAvatar:ge.default,DtStack:y.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}}},ht={class:"d-mention-suggestion__name"},pt={key:1,class:"d-mention-suggestion__divider"},ft={key:2,class:"d-mention-suggestion__status"};function gt(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",ht,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",pt," • ")):o.createCommentVNode("",!0),i.status?(o.openBlock(),o.createElementBlock("div",ft,o.toDisplayString(i.status),1)):o.createCommentVNode("",!0)]),_:1})):o.createCommentVNode("",!0)]),_:1})]),_:1})}const _t=h._(mt,[["render",gt]]),kt={allowSpaces:!0,render:()=>{let e,t,r=!1;return{onStart:n=>{e=new d.VueRenderer(E,{props:{itemComponent:o.markRaw(_t),itemType:"mention",...n},editor:n.editor}),n.clientRect&&(t=T("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:[v]}),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}}}},wt={compatConfig:{MODE:3},name:"ChannelSuggestion",components:{DtStack:y.default,DtIconHash:_e,DtIconLock:ke},props:{item:{type:Object,required:!0}},computed:{name(){return this.item.name}}};function Ct(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 yt=h._(wt,[["render",Ct]]),bt={allowSpaces:!0,render:()=>{let e,t,r=!1;return{onStart:n=>{e=new d.VueRenderer(E,{props:{itemComponent:o.markRaw(yt),itemType:"channel",...n},editor:n.editor}),n.clientRect&&(t=T("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:[v]}),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}}}},xt={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}}},Tt={class:"d-body--md-compact"},Et={key:0},vt={class:"d-body--sm d-fc-tertiary"};function Lt(e,t,r,n,s,i){return o.openBlock(),o.createElementBlock("div",null,[o.createElementVNode("div",Tt,[o.createElementVNode("span",null,"/"+o.toDisplayString(i.command),1),i.parametersExample?(o.openBlock(),o.createElementBlock("span",Et,o.toDisplayString(i.parametersExample),1)):o.createCommentVNode("",!0)]),o.createElementVNode("div",vt,o.toDisplayString(i.description),1)])}const St=h._(xt,[["render",Lt]]),Nt={allowSpaces:!0,startOfLine:!0,render:()=>{let e,t,r=!1;return{onStart:n=>{e=new d.VueRenderer(E,{parent:void 0,props:{itemComponent:o.markRaw(St),itemType:"slash-command",...n},editor:n.editor}),n.clientRect&&(t=T("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:[v]}),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}}}},Bt={compatConfig:{MODE:3},name:"DtRichTextEditor",components:{EditorContent:d.EditorContent,BubbleMenu:d.BubbleMenu,DtButton:V.default,DtStack:y.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},allowVariable:{type:Boolean,default:!1},variableItems:{type:Array,default:()=>[]},additionalExtensions:{type:Array,default:()=>[]},hideLinkBubbleMenu:{type:Boolean,default:!1},useDivTags:{type:Boolean,default:!1},allowTables:{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=C.returnFirstEl(this.$refs.editor.$el).getRootNode())==null?void 0:e.querySelector("body")},placement:"top-start"},i18n:new A.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),variable:n=>this.processVariableNode(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 S=require("../../node_modules/@tiptap/vue-3.cjs"),T=require("@tiptap/core"),j=require("@tiptap/pm/state"),_t=require("@tiptap/pm/tables"),a=require("vue"),Tt=require("@tiptap/extension-blockquote"),kt=require("@tiptap/extension-code-block"),Ct=require("@tiptap/extension-code"),Et=require("@tiptap/extension-document"),be=require("@tiptap/extensions"),Ot=require("@tiptap/extension-hard-break"),Ye=require("@tiptap/extension-paragraph"),St=require("@tiptap/extension-bold"),ve=require("@tiptap/extension-list"),Lt=require("@tiptap/extension-italic"),Dt=require("@tiptap/extension-link"),It=require("@tiptap/extension-strike"),Rt=require("@tiptap/extension-underline"),At=require("@tiptap/extension-text"),Bt=require("@tiptap/extension-text-align"),ce=require("@tiptap/extension-table"),Nt=require("@tiptap/extension-text-style"),Mt=require("@tiptap/suggestion"),Ge=require("regex-combined-emojis"),F=require("../../_plugin-vue_export-helper-BRilXfQE.cjs"),Je=require("../emoji/emoji.cjs"),ee=require("../../common/emoji/index.cjs"),Ht=require("../list-item/list-item.cjs"),ae=require("../stack/stack.cjs"),se=require("../../common/utils/index.cjs"),Vt=require("@tiptap/extension-image"),ke=require("@tiptap/extension-mention"),Ze=require("../link/link.cjs"),$t=require("@dialpad/dialtone-icons/vue3"),Qe=require("../../localization/index.cjs"),Pt=require("../input/input.cjs"),Ut=require("../popover/popover.cjs"),et=require("../button/button.cjs"),jt=require("../badge/badge.cjs"),de=require("./rich-text-editor-constants.cjs"),qt=require("../avatar/avatar.cjs"),zt=require("@dialpad/dialtone-icons/vue3/hash"),Ft=require("@dialpad/dialtone-icons/vue3/lock"),Kt=require("deep-equal"),tt=["top","right","bottom","left"],Be=["start","end"],Ne=tt.reduce((e,t)=>e.concat(t,t+"-"+Be[0],t+"-"+Be[1]),[]),X=Math.min,R=Math.max,ue=Math.round,W=e=>({x:e,y:e}),Wt={left:"right",right:"left",bottom:"top",top:"bottom"},Xt={start:"end",end:"start"};function _e(e,t,o){return R(e,X(t,o))}function G(e,t){return typeof e=="function"?e(t):e}function $(e){return e.split("-")[0]}function U(e){return e.split("-")[1]}function nt(e){return e==="x"?"y":"x"}function Ce(e){return e==="y"?"height":"width"}const Yt=new Set(["top","bottom"]);function K(e){return Yt.has($(e))?"y":"x"}function Ee(e){return nt(K(e))}function ot(e,t,o){o===void 0&&(o=!1);const n=U(e),i=Ee(e),s=Ce(i);let r=i==="x"?n===(o?"end":"start")?"right":"left":n==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(r=fe(r)),[r,fe(r)]}function Gt(e){const t=fe(e);return[he(e),t,he(t)]}function he(e){return e.replace(/start|end/g,t=>Xt[t])}const Me=["left","right"],He=["right","left"],Jt=["top","bottom"],Zt=["bottom","top"];function Qt(e,t,o){switch(e){case"top":case"bottom":return o?t?He:Me:t?Me:He;case"left":case"right":return t?Jt:Zt;default:return[]}}function en(e,t,o,n){const i=U(e);let s=Qt($(e),o==="start",n);return i&&(s=s.map(r=>r+"-"+i),t&&(s=s.concat(s.map(he)))),s}function fe(e){return e.replace(/left|right|bottom|top/g,t=>Wt[t])}function tn(e){return{top:0,right:0,bottom:0,left:0,...e}}function Oe(e){return typeof e!="number"?tn(e):{top:e,right:e,bottom:e,left:e}}function ne(e){const{x:t,y:o,width:n,height:i}=e;return{width:n,height:i,top:o,left:t,right:t+n,bottom:o+i,x:t,y:o}}function Ve(e,t,o){let{reference:n,floating:i}=e;const s=K(t),r=Ee(t),l=Ce(r),c=$(t),h=s==="y",u=n.x+n.width/2-i.width/2,d=n.y+n.height/2-i.height/2,f=n[l]/2-i[l]/2;let p;switch(c){case"top":p={x:u,y:n.y-i.height};break;case"bottom":p={x:u,y:n.y+n.height};break;case"right":p={x:n.x+n.width,y:d};break;case"left":p={x:n.x-i.width,y:d};break;default:p={x:n.x,y:n.y}}switch(U(t)){case"start":p[r]-=f*(o&&h?-1:1);break;case"end":p[r]+=f*(o&&h?-1:1);break}return p}async function nn(e,t){var o;t===void 0&&(t={});const{x:n,y:i,platform:s,rects:r,elements:l,strategy:c}=e,{boundary:h="clippingAncestors",rootBoundary:u="viewport",elementContext:d="floating",altBoundary:f=!1,padding:p=0}=G(t,e),m=Oe(p),w=l[f?d==="floating"?"reference":"floating":d],y=ne(await s.getClippingRect({element:(o=await(s.isElement==null?void 0:s.isElement(w)))==null||o?w:w.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:h,rootBoundary:u,strategy:c})),v=d==="floating"?{x:n,y:i,width:r.floating.width,height:r.floating.height}:r.reference,x=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),_=await(s.isElement==null?void 0:s.isElement(x))?await(s.getScale==null?void 0:s.getScale(x))||{x:1,y:1}:{x:1,y:1},C=ne(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:v,offsetParent:x,strategy:c}):v);return{top:(y.top-C.top+m.top)/_.y,bottom:(C.bottom-y.bottom+m.bottom)/_.y,left:(y.left-C.left+m.left)/_.x,right:(C.right-y.right+m.right)/_.x}}const on=async(e,t,o)=>{const{placement:n="bottom",strategy:i="absolute",middleware:s=[],platform:r}=o,l=s.filter(Boolean),c=await(r.isRTL==null?void 0:r.isRTL(t));let h=await r.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=Ve(h,n,c),f=n,p={},m=0;for(let w=0;w<l.length;w++){var g;const{name:y,fn:v}=l[w],{x,y:_,data:C,reset:k}=await v({x:u,y:d,initialPlacement:n,placement:f,strategy:i,middlewareData:p,rects:h,platform:{...r,detectOverflow:(g=r.detectOverflow)!=null?g:nn},elements:{reference:e,floating:t}});u=x??u,d=_??d,p={...p,[y]:{...p[y],...C}},k&&m<=50&&(m++,typeof k=="object"&&(k.placement&&(f=k.placement),k.rects&&(h=k.rects===!0?await r.getElementRects({reference:e,floating:t,strategy:i}):k.rects),{x:u,y:d}=Ve(h,f,c)),w=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:p}},sn=e=>({name:"arrow",options:e,async fn(t){const{x:o,y:n,placement:i,rects:s,platform:r,elements:l,middlewareData:c}=t,{element:h,padding:u=0}=G(e,t)||{};if(h==null)return{};const d=Oe(u),f={x:o,y:n},p=Ee(i),m=Ce(p),g=await r.getDimensions(h),w=p==="y",y=w?"top":"left",v=w?"bottom":"right",x=w?"clientHeight":"clientWidth",_=s.reference[m]+s.reference[p]-f[p]-s.floating[m],C=f[p]-s.reference[p],k=await(r.getOffsetParent==null?void 0:r.getOffsetParent(h));let L=k?k[x]:0;(!L||!await(r.isElement==null?void 0:r.isElement(k)))&&(L=l.floating[x]||s.floating[m]);const H=_/2-C/2,D=L/2-g[m]/2-1,b=X(d[y],D),E=X(d[v],D),I=b,A=L-g[m]-E,O=L/2-g[m]/2+H,P=_e(I,O,A),V=!c.arrow&&U(i)!=null&&O!==P&&s.reference[m]/2-(O<I?b:E)-g[m]/2<0,B=V?O<I?O-I:O-A:0;return{[p]:f[p]+B,data:{[p]:P,centerOffset:O-P-B,...V&&{alignmentOffset:B}},reset:V}}});function rn(e,t,o){return(e?[...o.filter(i=>U(i)===e),...o.filter(i=>U(i)!==e)]:o.filter(i=>$(i)===i)).filter(i=>e?U(i)===e||(t?he(i)!==i:!1):!0)}const an=function(e){return e===void 0&&(e={}),{name:"autoPlacement",options:e,async fn(t){var o,n,i;const{rects:s,middlewareData:r,placement:l,platform:c,elements:h}=t,{crossAxis:u=!1,alignment:d,allowedPlacements:f=Ne,autoAlignment:p=!0,...m}=G(e,t),g=d!==void 0||f===Ne?rn(d||null,p,f):f,w=await c.detectOverflow(t,m),y=((o=r.autoPlacement)==null?void 0:o.index)||0,v=g[y];if(v==null)return{};const x=ot(v,s,await(c.isRTL==null?void 0:c.isRTL(h.floating)));if(l!==v)return{reset:{placement:g[0]}};const _=[w[$(v)],w[x[0]],w[x[1]]],C=[...((n=r.autoPlacement)==null?void 0:n.overflows)||[],{placement:v,overflows:_}],k=g[y+1];if(k)return{data:{index:y+1,overflows:C},reset:{placement:k}};const L=C.map(b=>{const E=U(b.placement);return[b.placement,E&&u?b.overflows.slice(0,2).reduce((I,A)=>I+A,0):b.overflows[0],b.overflows]}).sort((b,E)=>b[1]-E[1]),D=((i=L.filter(b=>b[2].slice(0,U(b[0])?2:3).every(E=>E<=0))[0])==null?void 0:i[0])||L[0][0];return D!==l?{data:{index:y+1,overflows:C},reset:{placement:D}}:{}}}},ln=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var o,n;const{placement:i,middlewareData:s,rects:r,initialPlacement:l,platform:c,elements:h}=t,{mainAxis:u=!0,crossAxis:d=!0,fallbackPlacements:f,fallbackStrategy:p="bestFit",fallbackAxisSideDirection:m="none",flipAlignment:g=!0,...w}=G(e,t);if((o=s.arrow)!=null&&o.alignmentOffset)return{};const y=$(i),v=K(l),x=$(l)===l,_=await(c.isRTL==null?void 0:c.isRTL(h.floating)),C=f||(x||!g?[fe(l)]:Gt(l)),k=m!=="none";!f&&k&&C.push(...en(l,g,m,_));const L=[l,...C],H=await c.detectOverflow(t,w),D=[];let b=((n=s.flip)==null?void 0:n.overflows)||[];if(u&&D.push(H[y]),d){const O=ot(i,r,_);D.push(H[O[0]],H[O[1]])}if(b=[...b,{placement:i,overflows:D}],!D.every(O=>O<=0)){var E,I;const O=(((E=s.flip)==null?void 0:E.index)||0)+1,P=L[O];if(P&&(!(d==="alignment"?v!==K(P):!1)||b.every(N=>K(N.placement)===v?N.overflows[0]>0:!0)))return{data:{index:O,overflows:b},reset:{placement:P}};let V=(I=b.filter(B=>B.overflows[0]<=0).sort((B,N)=>B.overflows[1]-N.overflows[1])[0])==null?void 0:I.placement;if(!V)switch(p){case"bestFit":{var A;const B=(A=b.filter(N=>{if(k){const Z=K(N.placement);return Z===v||Z==="y"}return!0}).map(N=>[N.placement,N.overflows.filter(Z=>Z>0).reduce((Z,xt)=>Z+xt,0)]).sort((N,Z)=>N[1]-Z[1])[0])==null?void 0:A[0];B&&(V=B);break}case"initialPlacement":V=l;break}if(i!==V)return{reset:{placement:V}}}return{}}}};function $e(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Pe(e){return tt.some(t=>e[t]>=0)}const cn=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:o,platform:n}=t,{strategy:i="referenceHidden",...s}=G(e,t);switch(i){case"referenceHidden":{const r=await n.detectOverflow(t,{...s,elementContext:"reference"}),l=$e(r,o.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:Pe(l)}}}case"escaped":{const r=await n.detectOverflow(t,{...s,altBoundary:!0}),l=$e(r,o.floating);return{data:{escapedOffsets:l,escaped:Pe(l)}}}default:return{}}}}};function it(e){const t=X(...e.map(s=>s.left)),o=X(...e.map(s=>s.top)),n=R(...e.map(s=>s.right)),i=R(...e.map(s=>s.bottom));return{x:t,y:o,width:n-t,height:i-o}}function dn(e){const t=e.slice().sort((i,s)=>i.y-s.y),o=[];let n=null;for(let i=0;i<t.length;i++){const s=t[i];!n||s.y-n.y>n.height/2?o.push([s]):o[o.length-1].push(s),n=s}return o.map(i=>ne(it(i)))}const un=function(e){return e===void 0&&(e={}),{name:"inline",options:e,async fn(t){const{placement:o,elements:n,rects:i,platform:s,strategy:r}=t,{padding:l=2,x:c,y:h}=G(e,t),u=Array.from(await(s.getClientRects==null?void 0:s.getClientRects(n.reference))||[]),d=dn(u),f=ne(it(u)),p=Oe(l);function m(){if(d.length===2&&d[0].left>d[1].right&&c!=null&&h!=null)return d.find(w=>c>w.left-p.left&&c<w.right+p.right&&h>w.top-p.top&&h<w.bottom+p.bottom)||f;if(d.length>=2){if(K(o)==="y"){const b=d[0],E=d[d.length-1],I=$(o)==="top",A=b.top,O=E.bottom,P=I?b.left:E.left,V=I?b.right:E.right,B=V-P,N=O-A;return{top:A,bottom:O,left:P,right:V,width:B,height:N,x:P,y:A}}const w=$(o)==="left",y=R(...d.map(b=>b.right)),v=X(...d.map(b=>b.left)),x=d.filter(b=>w?b.left===v:b.right===y),_=x[0].top,C=x[x.length-1].bottom,k=v,L=y,H=L-k,D=C-_;return{top:_,bottom:C,left:k,right:L,width:H,height:D,x:k,y:_}}return f}const g=await s.getElementRects({reference:{getBoundingClientRect:m},floating:n.floating,strategy:r});return i.reference.x!==g.reference.x||i.reference.y!==g.reference.y||i.reference.width!==g.reference.width||i.reference.height!==g.reference.height?{reset:{rects:g}}:{}}}},hn=new Set(["left","top"]);async function fn(e,t){const{placement:o,platform:n,elements:i}=e,s=await(n.isRTL==null?void 0:n.isRTL(i.floating)),r=$(o),l=U(o),c=K(o)==="y",h=hn.has(r)?-1:1,u=s&&c?-1:1,d=G(t,e);let{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d=="number"?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return l&&typeof m=="number"&&(p=l==="end"?m*-1:m),c?{x:p*u,y:f*h}:{x:f*h,y:p*u}}const pn=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var o,n;const{x:i,y:s,placement:r,middlewareData:l}=t,c=await fn(t,e);return r===((o=l.offset)==null?void 0:o.placement)&&(n=l.arrow)!=null&&n.alignmentOffset?{}:{x:i+c.x,y:s+c.y,data:{...c,placement:r}}}}},mn=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:o,y:n,placement:i,platform:s}=t,{mainAxis:r=!0,crossAxis:l=!1,limiter:c={fn:y=>{let{x:v,y:x}=y;return{x:v,y:x}}},...h}=G(e,t),u={x:o,y:n},d=await s.detectOverflow(t,h),f=K($(i)),p=nt(f);let m=u[p],g=u[f];if(r){const y=p==="y"?"top":"left",v=p==="y"?"bottom":"right",x=m+d[y],_=m-d[v];m=_e(x,m,_)}if(l){const y=f==="y"?"top":"left",v=f==="y"?"bottom":"right",x=g+d[y],_=g-d[v];g=_e(x,g,_)}const w=c.fn({...t,[p]:m,[f]:g});return{...w,data:{x:w.x-o,y:w.y-n,enabled:{[p]:r,[f]:l}}}}}},gn=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var o,n;const{placement:i,rects:s,platform:r,elements:l}=t,{apply:c=()=>{},...h}=G(e,t),u=await r.detectOverflow(t,h),d=$(i),f=U(i),p=K(i)==="y",{width:m,height:g}=s.floating;let w,y;d==="top"||d==="bottom"?(w=d,y=f===(await(r.isRTL==null?void 0:r.isRTL(l.floating))?"start":"end")?"left":"right"):(y=d,w=f==="end"?"top":"bottom");const v=g-u.top-u.bottom,x=m-u.left-u.right,_=X(g-u[w],v),C=X(m-u[y],x),k=!t.middlewareData.shift;let L=_,H=C;if((o=t.middlewareData.shift)!=null&&o.enabled.x&&(H=x),(n=t.middlewareData.shift)!=null&&n.enabled.y&&(L=v),k&&!f){const b=R(u.left,0),E=R(u.right,0),I=R(u.top,0),A=R(u.bottom,0);p?H=m-2*(b!==0||E!==0?b+E:R(u.left,u.right)):L=g-2*(I!==0||A!==0?I+A:R(u.top,u.bottom))}await c({...t,availableWidth:H,availableHeight:L});const D=await r.getDimensions(l.floating);return m!==D.width||g!==D.height?{reset:{rects:!0}}:{}}}};function pe(){return typeof window<"u"}function ie(e){return st(e)?(e.nodeName||"").toLowerCase():"#document"}function M(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function J(e){var t;return(t=(st(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function st(e){return pe()?e instanceof Node||e instanceof M(e).Node:!1}function q(e){return pe()?e instanceof Element||e instanceof M(e).Element:!1}function Y(e){return pe()?e instanceof HTMLElement||e instanceof M(e).HTMLElement:!1}function Ue(e){return!pe()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof M(e).ShadowRoot}const wn=new Set(["inline","contents"]);function le(e){const{overflow:t,overflowX:o,overflowY:n,display:i}=z(e);return/auto|scroll|overlay|hidden|clip/.test(t+n+o)&&!wn.has(i)}const yn=new Set(["table","td","th"]);function bn(e){return yn.has(ie(e))}const vn=[":popover-open",":modal"];function me(e){return vn.some(t=>{try{return e.matches(t)}catch{return!1}})}const xn=["transform","translate","scale","rotate","perspective"],_n=["transform","translate","scale","rotate","perspective","filter"],Tn=["paint","layout","strict","content"];function Se(e){const t=Le(),o=q(e)?z(e):e;return xn.some(n=>o[n]?o[n]!=="none":!1)||(o.containerType?o.containerType!=="normal":!1)||!t&&(o.backdropFilter?o.backdropFilter!=="none":!1)||!t&&(o.filter?o.filter!=="none":!1)||_n.some(n=>(o.willChange||"").includes(n))||Tn.some(n=>(o.contain||"").includes(n))}function kn(e){let t=Q(e);for(;Y(t)&&!oe(t);){if(Se(t))return t;if(me(t))return null;t=Q(t)}return null}function Le(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Cn=new Set(["html","body","#document"]);function oe(e){return Cn.has(ie(e))}function z(e){return M(e).getComputedStyle(e)}function ge(e){return q(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Q(e){if(ie(e)==="html")return e;const t=e.assignedSlot||e.parentNode||Ue(e)&&e.host||J(e);return Ue(t)?t.host:t}function rt(e){const t=Q(e);return oe(t)?e.ownerDocument?e.ownerDocument.body:e.body:Y(t)&&le(t)?t:rt(t)}function at(e,t,o){var n;t===void 0&&(t=[]);const i=rt(e),s=i===((n=e.ownerDocument)==null?void 0:n.body),r=M(i);return s?t.concat(r,r.visualViewport||[],le(i)?i:[],[]):t.concat(i,at(i,[]))}function je(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function lt(e){const t=z(e);let o=parseFloat(t.width)||0,n=parseFloat(t.height)||0;const i=Y(e),s=i?e.offsetWidth:o,r=i?e.offsetHeight:n,l=ue(o)!==s||ue(n)!==r;return l&&(o=s,n=r),{width:o,height:n,$:l}}function ct(e){return q(e)?e:e.contextElement}function te(e){const t=ct(e);if(!Y(t))return W(1);const o=t.getBoundingClientRect(),{width:n,height:i,$:s}=lt(t);let r=(s?ue(o.width):o.width)/n,l=(s?ue(o.height):o.height)/i;return(!r||!Number.isFinite(r))&&(r=1),(!l||!Number.isFinite(l))&&(l=1),{x:r,y:l}}const En=W(0);function dt(e){const t=M(e);return!Le()||!t.visualViewport?En:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function On(e,t,o){return t===void 0&&(t=!1),!o||t&&o!==M(e)?!1:t}function re(e,t,o,n){t===void 0&&(t=!1),o===void 0&&(o=!1);const i=e.getBoundingClientRect(),s=ct(e);let r=W(1);t&&(n?q(n)&&(r=te(n)):r=te(e));const l=On(s,o,n)?dt(s):W(0);let c=(i.left+l.x)/r.x,h=(i.top+l.y)/r.y,u=i.width/r.x,d=i.height/r.y;if(s){const f=M(s),p=n&&q(n)?M(n):n;let m=f,g=je(m);for(;g&&n&&p!==m;){const w=te(g),y=g.getBoundingClientRect(),v=z(g),x=y.left+(g.clientLeft+parseFloat(v.paddingLeft))*w.x,_=y.top+(g.clientTop+parseFloat(v.paddingTop))*w.y;c*=w.x,h*=w.y,u*=w.x,d*=w.y,c+=x,h+=_,m=M(g),g=je(m)}}return ne({width:u,height:d,x:c,y:h})}function we(e,t){const o=ge(e).scrollLeft;return t?t.left+o:re(J(e)).left+o}function ut(e,t){const o=e.getBoundingClientRect(),n=o.left+t.scrollLeft-we(e,o),i=o.top+t.scrollTop;return{x:n,y:i}}function Sn(e){let{elements:t,rect:o,offsetParent:n,strategy:i}=e;const s=i==="fixed",r=J(n),l=t?me(t.floating):!1;if(n===r||l&&s)return o;let c={scrollLeft:0,scrollTop:0},h=W(1);const u=W(0),d=Y(n);if((d||!d&&!s)&&((ie(n)!=="body"||le(r))&&(c=ge(n)),Y(n))){const p=re(n);h=te(n),u.x=p.x+n.clientLeft,u.y=p.y+n.clientTop}const f=r&&!d&&!s?ut(r,c):W(0);return{width:o.width*h.x,height:o.height*h.y,x:o.x*h.x-c.scrollLeft*h.x+u.x+f.x,y:o.y*h.y-c.scrollTop*h.y+u.y+f.y}}function Ln(e){return Array.from(e.getClientRects())}function Dn(e){const t=J(e),o=ge(e),n=e.ownerDocument.body,i=R(t.scrollWidth,t.clientWidth,n.scrollWidth,n.clientWidth),s=R(t.scrollHeight,t.clientHeight,n.scrollHeight,n.clientHeight);let r=-o.scrollLeft+we(e);const l=-o.scrollTop;return z(n).direction==="rtl"&&(r+=R(t.clientWidth,n.clientWidth)-i),{width:i,height:s,x:r,y:l}}const qe=25;function In(e,t){const o=M(e),n=J(e),i=o.visualViewport;let s=n.clientWidth,r=n.clientHeight,l=0,c=0;if(i){s=i.width,r=i.height;const u=Le();(!u||u&&t==="fixed")&&(l=i.offsetLeft,c=i.offsetTop)}const h=we(n);if(h<=0){const u=n.ownerDocument,d=u.body,f=getComputedStyle(d),p=u.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,m=Math.abs(n.clientWidth-d.clientWidth-p);m<=qe&&(s-=m)}else h<=qe&&(s+=h);return{width:s,height:r,x:l,y:c}}const Rn=new Set(["absolute","fixed"]);function An(e,t){const o=re(e,!0,t==="fixed"),n=o.top+e.clientTop,i=o.left+e.clientLeft,s=Y(e)?te(e):W(1),r=e.clientWidth*s.x,l=e.clientHeight*s.y,c=i*s.x,h=n*s.y;return{width:r,height:l,x:c,y:h}}function ze(e,t,o){let n;if(t==="viewport")n=In(e,o);else if(t==="document")n=Dn(J(e));else if(q(t))n=An(t,o);else{const i=dt(e);n={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return ne(n)}function ht(e,t){const o=Q(e);return o===t||!q(o)||oe(o)?!1:z(o).position==="fixed"||ht(o,t)}function Bn(e,t){const o=t.get(e);if(o)return o;let n=at(e,[]).filter(l=>q(l)&&ie(l)!=="body"),i=null;const s=z(e).position==="fixed";let r=s?Q(e):e;for(;q(r)&&!oe(r);){const l=z(r),c=Se(r);!c&&l.position==="fixed"&&(i=null),(s?!c&&!i:!c&&l.position==="static"&&!!i&&Rn.has(i.position)||le(r)&&!c&&ht(e,r))?n=n.filter(u=>u!==r):i=l,r=Q(r)}return t.set(e,n),n}function Nn(e){let{element:t,boundary:o,rootBoundary:n,strategy:i}=e;const r=[...o==="clippingAncestors"?me(t)?[]:Bn(t,this._c):[].concat(o),n],l=r[0],c=r.reduce((h,u)=>{const d=ze(t,u,i);return h.top=R(d.top,h.top),h.right=X(d.right,h.right),h.bottom=X(d.bottom,h.bottom),h.left=R(d.left,h.left),h},ze(t,l,i));return{width:c.right-c.left,height:c.bottom-c.top,x:c.left,y:c.top}}function Mn(e){const{width:t,height:o}=lt(e);return{width:t,height:o}}function Hn(e,t,o){const n=Y(t),i=J(t),s=o==="fixed",r=re(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const c=W(0);function h(){c.x=we(i)}if(n||!n&&!s)if((ie(t)!=="body"||le(i))&&(l=ge(t)),n){const p=re(t,!0,s,t);c.x=p.x+t.clientLeft,c.y=p.y+t.clientTop}else i&&h();s&&!n&&i&&h();const u=i&&!n&&!s?ut(i,l):W(0),d=r.left+l.scrollLeft-c.x-u.x,f=r.top+l.scrollTop-c.y-u.y;return{x:d,y:f,width:r.width,height:r.height}}function xe(e){return z(e).position==="static"}function Fe(e,t){if(!Y(e)||z(e).position==="fixed")return null;if(t)return t(e);let o=e.offsetParent;return J(e)===o&&(o=o.ownerDocument.body),o}function ft(e,t){const o=M(e);if(me(e))return o;if(!Y(e)){let i=Q(e);for(;i&&!oe(i);){if(q(i)&&!xe(i))return i;i=Q(i)}return o}let n=Fe(e,t);for(;n&&bn(n)&&xe(n);)n=Fe(n,t);return n&&oe(n)&&xe(n)&&!Se(n)?o:n||kn(e)||o}const Vn=async function(e){const t=this.getOffsetParent||ft,o=this.getDimensions,n=await o(e.floating);return{reference:Hn(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:n.width,height:n.height}}};function $n(e){return z(e).direction==="rtl"}const Pn={convertOffsetParentRelativeRectToViewportRelativeRect:Sn,getDocumentElement:J,getClippingRect:Nn,getOffsetParent:ft,getElementRects:Vn,getClientRects:Ln,getDimensions:Mn,getScale:te,isElement:q,isRTL:$n},De=pn,pt=an,Ie=mn,Re=ln,mt=gn,gt=cn,wt=sn,yt=un,Ae=(e,t,o)=>{const n=new Map,i={platform:Pn,...o},s={...i.platform,_c:n};return on(e,t,{...i,platform:s})};function Un(e,t){const o=Math.min(e.top,t.top),n=Math.max(e.bottom,t.bottom),i=Math.min(e.left,t.left),r=Math.max(e.right,t.right)-i,l=n-o,c=i,h=o;return new DOMRect(c,h,r,l)}var jn=class{constructor({editor:e,element:t,view:o,updateDelay:n=250,resizeDelay:i=60,shouldShow:s,appendTo:r,getReferencedVirtualElement:l,options:c}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.floatingUIOptions={strategy:"absolute",placement:"top",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1,onShow:void 0,onHide:void 0,onUpdate:void 0,onDestroy:void 0},this.shouldShow=({view:u,state:d,from:f,to:p})=>{const{doc:m,selection:g}=d,{empty:w}=g,y=!m.textBetween(f,p).length&&T.isTextSelection(d.selection),v=this.element.contains(document.activeElement);return!(!(u.hasFocus()||v)||w||y||!this.editor.isEditable)},this.mousedownHandler=()=>{this.preventHide=!0},this.dragstartHandler=()=>{this.hide()},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:u})=>{var d;if(this.editor.isDestroyed){this.destroy();return}if(this.preventHide){this.preventHide=!1;return}u!=null&&u.relatedTarget&&((d=this.element.parentNode)!=null&&d.contains(u.relatedTarget))||(u==null?void 0:u.relatedTarget)!==this.editor.view.dom&&this.hide()},this.handleDebouncedUpdate=(u,d)=>{const f=!(d!=null&&d.selection.eq(u.state.selection)),p=!(d!=null&&d.doc.eq(u.state.doc));!f&&!p||(this.updateDebounceTimer&&clearTimeout(this.updateDebounceTimer),this.updateDebounceTimer=window.setTimeout(()=>{this.updateHandler(u,f,p,d)},this.updateDelay))},this.updateHandler=(u,d,f,p)=>{const{composing:m}=u;if(m||!d&&!f)return;if(!this.getShouldShow(p)){this.hide();return}this.updatePosition(),this.show()},this.transactionHandler=({transaction:u})=>{const d=u.getMeta("bubbleMenu");d==="updatePosition"?this.updatePosition():d&&typeof d=="object"&&d.type==="updateOptions"&&this.updateOptions(d.options)};var h;this.editor=e,this.element=t,this.view=o,this.updateDelay=n,this.resizeDelay=i,this.appendTo=r,this.scrollTarget=(h=c==null?void 0:c.scrollTarget)!=null?h:window,this.getReferencedVirtualElement=l,this.floatingUIOptions={...this.floatingUIOptions,...c},this.element.tabIndex=0,s&&(this.shouldShow=s),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.addEventListener("dragstart",this.dragstartHandler),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(o,o.state),this.getShouldShow()&&(this.show(),this.updatePosition())}get middlewares(){const e=[];return this.floatingUIOptions.flip&&e.push(Re(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&e.push(Ie(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&e.push(De(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&e.push(wt(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(mt(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&e.push(pt(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&e.push(gt(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&e.push(yt(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),e}get virtualElement(){var e,t,o;const{selection:n}=this.editor.state,i=(e=this.getReferencedVirtualElement)==null?void 0:e.call(this);if(i)return i;if(!((o=(t=this.view)==null?void 0:t.dom)!=null&&o.parentNode))return;const s=T.posToDOMRect(this.view,n.from,n.to);let r={getBoundingClientRect:()=>s,getClientRects:()=>[s]};if(n instanceof j.NodeSelection){let l=this.view.nodeDOM(n.from);const c=l.dataset.nodeViewWrapper?l:l.querySelector("[data-node-view-wrapper]");c&&(l=c),l&&(r={getBoundingClientRect:()=>l.getBoundingClientRect(),getClientRects:()=>[l.getBoundingClientRect()]})}if(n instanceof _t.CellSelection){const{$anchorCell:l,$headCell:c}=n,h=l?l.pos:c.pos,u=c?c.pos:l.pos,d=this.view.nodeDOM(h),f=this.view.nodeDOM(u);if(!d||!f)return;const p=d===f?d.getBoundingClientRect():Un(d.getBoundingClientRect(),f.getBoundingClientRect());r={getBoundingClientRect:()=>p,getClientRects:()=>[p]}}return r}updatePosition(){const e=this.virtualElement;e&&Ae(e,this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:t,y:o,strategy:n,middlewareData:i})=>{var s,r;if((s=i.hide)!=null&&s.referenceHidden||(r=i.hide)!=null&&r.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=n,this.element.style.left=`${t}px`,this.element.style.top=`${o}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){const{state:o}=e,n=o.selection.from!==o.selection.to;if(this.updateDelay>0&&n){this.handleDebouncedUpdate(e,t);return}const i=!(t!=null&&t.selection.eq(e.state.selection)),s=!(t!=null&&t.doc.eq(e.state.doc));this.updateHandler(e,i,s,t)}getShouldShow(e){var t;const{state:o}=this.view,{selection:n}=o,{ranges:i}=n,s=Math.min(...i.map(c=>c.$from.pos)),r=Math.max(...i.map(c=>c.$to.pos));return((t=this.shouldShow)==null?void 0:t.call(this,{editor:this.editor,element:this.element,view:this.view,state:o,oldState:e,from:s,to:r}))||!1}show(){var e;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const t=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(e=t??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}updateOptions(e){var t;if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.getReferencedVirtualElement!==void 0&&(this.getReferencedVirtualElement=e.getReferencedVirtualElement),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){const o=(t=e.options.scrollTarget)!=null?t:window;o!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=o,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.view.dom.removeEventListener("dragstart",this.dragstartHandler),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},qn=e=>new j.Plugin({key:typeof e.pluginKey=="string"?new j.PluginKey(e.pluginKey):e.pluginKey,view:t=>new jn({view:t,...e})}),zn=a.defineComponent({name:"BubbleMenu",inheritAttrs:!1,props:{pluginKey:{type:[String,Object],default:"bubbleMenu"},editor:{type:Object,required:!0},updateDelay:{type:Number,default:void 0},resizeDelay:{type:Number,default:void 0},options:{type:Object,default:()=>({})},appendTo:{type:[Object,Function],default:void 0},shouldShow:{type:Function,default:null},getReferencedVirtualElement:{type:Function,default:void 0}},setup(e,{slots:t,attrs:o}){const n=a.ref(null);return a.onMounted(()=>{const{editor:i,options:s,pluginKey:r,resizeDelay:l,appendTo:c,shouldShow:h,getReferencedVirtualElement:u,updateDelay:d}=e,f=n.value;f&&(f.style.visibility="hidden",f.style.position="absolute",f.remove(),a.nextTick(()=>{i.registerPlugin(qn({editor:i,element:f,options:s,pluginKey:r,resizeDelay:l,appendTo:c,shouldShow:h,getReferencedVirtualElement:u,updateDelay:d}))}))}),a.onBeforeUnmount(()=>{const{pluginKey:i,editor:s}=e;s.unregisterPlugin(i)}),()=>{var i;return a.h("div",{ref:n,...o},(i=t.default)==null?void 0:i.call(t))}}}),Fn=class{constructor({editor:e,element:t,view:o,updateDelay:n=250,resizeDelay:i=60,options:s,appendTo:r,shouldShow:l}){this.preventHide=!1,this.isVisible=!1,this.scrollTarget=window,this.shouldShow=({view:h,state:u})=>{const{selection:d}=u,{$anchor:f,empty:p}=d,m=f.depth===1,g=f.parent.isTextblock&&!f.parent.type.spec.code&&!f.parent.textContent&&f.parent.childCount===0&&!this.getTextContent(f.parent);return!(!h.hasFocus()||!p||!m||!g||!this.editor.isEditable)},this.floatingUIOptions={strategy:"absolute",placement:"right",offset:8,flip:{},shift:{},arrow:!1,size:!1,autoPlacement:!1,hide:!1,inline:!1},this.updateHandler=(h,u,d,f)=>{const{composing:p}=h;if(p||!u&&!d)return;if(!this.getShouldShow(f)){this.hide();return}this.updatePosition(),this.show()},this.mousedownHandler=()=>{this.preventHide=!0},this.focusHandler=()=>{setTimeout(()=>this.update(this.editor.view))},this.blurHandler=({event:h})=>{var u;if(this.preventHide){this.preventHide=!1;return}h!=null&&h.relatedTarget&&((u=this.element.parentNode)!=null&&u.contains(h.relatedTarget))||(h==null?void 0:h.relatedTarget)!==this.editor.view.dom&&this.hide()},this.transactionHandler=({transaction:h})=>{const u=h.getMeta("floatingMenu");u==="updatePosition"?this.updatePosition():u&&typeof u=="object"&&u.type==="updateOptions"&&this.updateOptions(u.options)},this.resizeHandler=()=>{this.resizeDebounceTimer&&clearTimeout(this.resizeDebounceTimer),this.resizeDebounceTimer=window.setTimeout(()=>{this.updatePosition()},this.resizeDelay)};var c;this.editor=e,this.element=t,this.view=o,this.updateDelay=n,this.resizeDelay=i,this.appendTo=r,this.scrollTarget=(c=s==null?void 0:s.scrollTarget)!=null?c:window,this.floatingUIOptions={...this.floatingUIOptions,...s},this.element.tabIndex=0,l&&(this.shouldShow=l),this.element.addEventListener("mousedown",this.mousedownHandler,{capture:!0}),this.editor.on("focus",this.focusHandler),this.editor.on("blur",this.blurHandler),this.editor.on("transaction",this.transactionHandler),window.addEventListener("resize",this.resizeHandler),this.scrollTarget.addEventListener("scroll",this.resizeHandler),this.update(o,o.state),this.getShouldShow()&&(this.show(),this.updatePosition())}getTextContent(e){return T.getText(e,{textSerializers:T.getTextSerializersFromSchema(this.editor.schema)})}get middlewares(){const e=[];return this.floatingUIOptions.flip&&e.push(Re(typeof this.floatingUIOptions.flip!="boolean"?this.floatingUIOptions.flip:void 0)),this.floatingUIOptions.shift&&e.push(Ie(typeof this.floatingUIOptions.shift!="boolean"?this.floatingUIOptions.shift:void 0)),this.floatingUIOptions.offset&&e.push(De(typeof this.floatingUIOptions.offset!="boolean"?this.floatingUIOptions.offset:void 0)),this.floatingUIOptions.arrow&&e.push(wt(this.floatingUIOptions.arrow)),this.floatingUIOptions.size&&e.push(mt(typeof this.floatingUIOptions.size!="boolean"?this.floatingUIOptions.size:void 0)),this.floatingUIOptions.autoPlacement&&e.push(pt(typeof this.floatingUIOptions.autoPlacement!="boolean"?this.floatingUIOptions.autoPlacement:void 0)),this.floatingUIOptions.hide&&e.push(gt(typeof this.floatingUIOptions.hide!="boolean"?this.floatingUIOptions.hide:void 0)),this.floatingUIOptions.inline&&e.push(yt(typeof this.floatingUIOptions.inline!="boolean"?this.floatingUIOptions.inline:void 0)),e}getShouldShow(e){var t;const{state:o}=this.view,{selection:n}=o,{ranges:i}=n,s=Math.min(...i.map(c=>c.$from.pos)),r=Math.max(...i.map(c=>c.$to.pos));return(t=this.shouldShow)==null?void 0:t.call(this,{editor:this.editor,view:this.view,state:o,oldState:e,from:s,to:r})}updateOptions(e){var t;if(e.updateDelay!==void 0&&(this.updateDelay=e.updateDelay),e.resizeDelay!==void 0&&(this.resizeDelay=e.resizeDelay),e.appendTo!==void 0&&(this.appendTo=e.appendTo),e.shouldShow!==void 0&&e.shouldShow&&(this.shouldShow=e.shouldShow),e.options!==void 0){const o=(t=e.options.scrollTarget)!=null?t:window;o!==this.scrollTarget&&(this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.scrollTarget=o,this.scrollTarget.addEventListener("scroll",this.resizeHandler)),this.floatingUIOptions={...this.floatingUIOptions,...e.options}}}updatePosition(){const{selection:e}=this.editor.state,t=T.posToDOMRect(this.view,e.from,e.to);Ae({getBoundingClientRect:()=>t,getClientRects:()=>[t]},this.element,{placement:this.floatingUIOptions.placement,strategy:this.floatingUIOptions.strategy,middleware:this.middlewares}).then(({x:n,y:i,strategy:s,middlewareData:r})=>{var l,c;if((l=r.hide)!=null&&l.referenceHidden||(c=r.hide)!=null&&c.escaped){this.element.style.visibility="hidden";return}this.element.style.visibility="visible",this.element.style.width="max-content",this.element.style.position=s,this.element.style.left=`${n}px`,this.element.style.top=`${i}px`,this.isVisible&&this.floatingUIOptions.onUpdate&&this.floatingUIOptions.onUpdate()})}update(e,t){const o=!(t!=null&&t.selection.eq(e.state.selection)),n=!(t!=null&&t.doc.eq(e.state.doc));this.updateHandler(e,o,n,t)}show(){var e;if(this.isVisible)return;this.element.style.visibility="visible",this.element.style.opacity="1";const t=typeof this.appendTo=="function"?this.appendTo():this.appendTo;(e=t??this.view.dom.parentElement)==null||e.appendChild(this.element),this.floatingUIOptions.onShow&&this.floatingUIOptions.onShow(),this.isVisible=!0}hide(){this.isVisible&&(this.element.style.visibility="hidden",this.element.style.opacity="0",this.element.remove(),this.floatingUIOptions.onHide&&this.floatingUIOptions.onHide(),this.isVisible=!1)}destroy(){this.hide(),this.element.removeEventListener("mousedown",this.mousedownHandler,{capture:!0}),window.removeEventListener("resize",this.resizeHandler),this.scrollTarget.removeEventListener("scroll",this.resizeHandler),this.editor.off("focus",this.focusHandler),this.editor.off("blur",this.blurHandler),this.editor.off("transaction",this.transactionHandler),this.floatingUIOptions.onDestroy&&this.floatingUIOptions.onDestroy()}},Kn=e=>new j.Plugin({key:typeof e.pluginKey=="string"?new j.PluginKey(e.pluginKey):e.pluginKey,view:t=>new Fn({view:t,...e})});a.defineComponent({name:"FloatingMenu",inheritAttrs:!1,props:{pluginKey:{type:null,default:"floatingMenu"},editor:{type:Object,required:!0},updateDelay:{type:Number,default:void 0},resizeDelay:{type:Number,default:void 0},options:{type:Object,default:()=>({})},appendTo:{type:[Object,Function],default:void 0},shouldShow:{type:Function,default:null}},setup(e,{slots:t,attrs:o}){const n=a.ref(null);return a.onMounted(()=>{const{pluginKey:i,editor:s,updateDelay:r,resizeDelay:l,options:c,appendTo:h,shouldShow:u}=e,d=n.value;d&&(d.style.visibility="hidden",d.style.position="absolute",d.remove(),s.registerPlugin(Kn({pluginKey:i,editor:s,element:d,updateDelay:r,resizeDelay:l,options:c,appendTo:h,shouldShow:u})))}),a.onBeforeUnmount(()=>{const{pluginKey:i,editor:s}=e;s.unregisterPlugin(i)}),()=>{var i;return a.h("div",{ref:n,...o},(i=t.default)==null?void 0:i.call(t))}}});const Wn={compatConfig:{MODE:3},name:"EmojiComponent",components:{NodeViewWrapper:S.NodeViewWrapper,DtEmoji:Je.default},props:S.nodeViewProps};function Xn(e,t,o,n,i,s){const r=a.resolveComponent("dt-emoji"),l=a.resolveComponent("node-view-wrapper");return a.openBlock(),a.createBlock(l,{class:"d-d-inline-block d-va-bottom d-lh0"},{default:a.withCtx(()=>[a.createVNode(r,{size:"500",code:e.node.attrs.code},null,8,["code"])]),_:1})}const Yn=F._(Wn,[["render",Xn]]),Gn={compatConfig:{MODE:3},name:"SuggestionList",components:{DtListItem:Ht.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}}}},Jn={class:"d-popover__dialog d-suggestion-list__container"},Zn={ref:"suggestionList",class:"d-suggestion-list"};function Qn(e,t,o,n,i,s){const r=a.resolveComponent("dt-list-item");return a.openBlock(),a.createElementBlock("div",Jn,[a.withDirectives(a.createElementVNode("ul",Zn,[(a.openBlock(!0),a.createElementBlock(a.Fragment,null,a.renderList(o.items,(l,c)=>(a.openBlock(),a.createBlock(r,{key:l.id,class:a.normalizeClass(["d-suggestion-list__item",{"d-list-item--highlighted":c===i.selectedIndex}]),"navigation-type":"arrow-keys",onClick:h=>s.selectItem(c),onKeydown:a.withModifiers(s.onKeyDown,["prevent"])},{default:a.withCtx(()=>[(a.openBlock(),a.createBlock(a.resolveDynamicComponent(o.itemComponent),{item:l},null,8,["item"]))]),_:2},1032,["class","onClick","onKeydown"]))),128))],512),[[a.vShow,o.items.length]])])}const eo=F._(Gn,[["render",Qn]]),bt="top-start",vt="650";function to(){return{getBoundingClientRect:()=>({width:0,height:0,x:0,y:0,top:0,left:0,right:0,bottom:0})}}function Ke(e){return{getBoundingClientRect:e}}async function no(e,t,o={}){if(!e||!(t!=null&&t.getBoundingClientRect))return;const{placement:n=bt,middleware:i=[De(0),Re(),Ie({padding:8})]}=o,{x:s,y:r}=await Ae(t,e,{placement:n,middleware:i});Object.assign(e.style,{left:`${s}px`,top:`${r}px`})}function oo(e,t={}){const{zIndex:o=vt}=t;e.style.position="absolute",e.style.zIndex=o,e.style.display="none"}function io(e){e&&(e.style.display="block")}function so(e){e&&(e.style.display="none")}function ro(e,t){return o=>{o.key==="Escape"&&t()&&e()}}function ao(e){document.addEventListener("keydown",e)}function lo(e){document.removeEventListener("keydown",e)}function co(e,t,o,n){return new S.VueRenderer(e,{props:{itemComponent:a.markRaw(t),itemType:o,...n},editor:n.editor})}function uo(e){var t,o;e.escHandler&&lo(e.escHandler),(t=e.floatingEl)==null||t.remove(),(o=e.component)==null||o.destroy()}function ye(e,t,o={}){const{listComponent:n=eo,placement:i=bt,zIndex:s=vt}=o;return()=>{let r=null,l=null,c=!1,h=to(),u=null;function d(){no(l,h,{placement:i})}function f(){l&&(io(l),c=!0,d())}function p(){l&&(so(l),c=!1)}return{onStart:m=>{r=co(n,e,t,m),m.clientRect&&(l=r.element,oo(l,{zIndex:s}),document.body.appendChild(l),h=Ke(m.clientRect),u=ro(p,()=>c),ao(u),m.items.length>0&&f())},onUpdate(m){r==null||r.updateProps(m),m.items.length>0?f():p(),m.clientRect&&(h=Ke(m.clientRect),d())},onKeyDown(m){var g;if(c)return(g=r==null?void 0:r.ref)==null?void 0:g.onKeyDown(m)},onExit(){uo({escHandler:u,floatingEl:l,component:r}),u=null,l=null,r=null}}}}const ho={compatConfig:{MODE:3},name:"EmojiSuggestion",components:{DtEmoji:Je.default,DtStack:ae.default},props:{item:{type:Object,required:!0}}};function fo(e,t,o,n,i,s){const r=a.resolveComponent("dt-emoji"),l=a.resolveComponent("dt-stack");return a.openBlock(),a.createBlock(l,{direction:"row",gap:"400"},{default:a.withCtx(()=>[a.createVNode(r,{size:"200",code:o.item.code},null,8,["code"]),a.createTextVNode(" "+a.toDisplayString(o.item.code),1)]),_:1})}const po=F._(ho,[["render",fo]]),mo=20,go=(e,t,o)=>{var l,c;const n=(l=e.shortname)==null?void 0:l.replaceAll(":",""),i=(c=t.shortname)==null?void 0:c.replaceAll(":",""),s=n.startsWith(o),r=i.startsWith(o);return s&&!r?-1:!s&&r?1:n.localeCompare(i)},wo={items:({query:e})=>{if(e.length<2)return[];const t=Object.values(ee.getEmojiData());return e=e.toLowerCase(),t.filter(n=>{var i;return[n.name,(i=n.shortname)==null?void 0:i.replaceAll(":",""),...n.keywords||[]].some(s=>s&&s.startsWith(e))}).splice(0,mo).sort((n,i)=>go(n,i,e)).map(n=>({code:n.shortname}))},command:({editor:e,range:t,props:o})=>{var s,r;const n=e.view.state.selection.$to.nodeAfter;((s=n==null?void 0:n.text)==null?void 0:s.startsWith(" "))&&(t.to+=1),e.chain().focus().insertContentAt(t,[{type:"emoji",attrs:o}]).run(),(r=window.getSelection())==null||r.collapseToEnd()},render:ye(po,"emoji")},yo=/(:\w+:)$/,bo=new RegExp(Ge.emojiPattern+"$"),vo=e=>{if(e&&ee.codeToEmojiData(e[0]))return{text:e[2]||e[0]}},xo=e=>[...e.matchAll(ee.emojiShortCodeRegex)].filter(o=>ee.codeToEmojiData(o[0])).map(o=>({index:o.index,text:o[0],match:o})),_o=T.Node.create({name:"emoji",addOptions(){return{HTMLAttributes:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addNodeView(){return S.VueNodeViewRenderer(Yn)},addAttributes(){return{code:{default:null}}},parseHTML(){return[{tag:"emoji-component"}]},renderText({node:e}){return ee.stringToUnicode(ee.codeToEmojiData(e.attrs.code).unicode_output)},renderHTML({HTMLAttributes:e}){return["emoji-component",T.mergeAttributes(this.options.HTMLAttributes,e)]},addInputRules(){return[new T.InputRule({find:e=>{const t=e.match(yo)||e.match(bo);if(t)return vo(t)},handler:({state:e,range:t,match:o})=>{const{tr:n}=e,i=t.from,s=t.to;n.replaceWith(i,s,this.type.create({code:o[0]}))}})]},addPasteRules(){return[T.nodePasteRule({find:xo,type:this.type,getAttributes(e){return{code:e[0]}}}),T.nodePasteRule({find:ee.emojiRegex,type:this.type,getAttributes(e){return{code:e[0]}}})]},addProseMirrorPlugins(){return[Mt({char:":",pluginKey:new j.PluginKey("emoji"),editor:this.editor,...this.options.suggestion,...wo})]},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:e,state:t})=>{let o=!1;const{selection:n}=t,{empty:i,anchor:s}=n;return i?(t.doc.nodesBetween(s-1,s,(r,l)=>{if(r.type.name===this.name)return o=!0,e.insertText("",l,l+r.nodeSize),!1}),o):!1})}}});function To(e,t,o=()=>!0){const n=[];t.lastIndex=0;let i;for(;i=t.exec(e);)o(e,i)&&n.push(i);return n}function ko(e,t){return!["#","@"].includes(e.charAt(t.index))&&!["#","@"].includes(e.charAt(t.index-1))}function Co(e){const t=new RegExp("(?:"+[`[!?.,:;'"]`,"(?:&|&)(?:lt|gt|quot|apos|raquo|laquo|rsaquo|lsaquo);)+$"].join("|"),"g");return e.replace(t,"")}function Eo(e,t){const o=e.slice(0,t+1).search(/\S+\s*$/),n=e.slice(t).search(/\s/);if(n<0){const i=e.slice(o);return{text:i,from:o,to:o+i.length}}return{text:e.slice(o,n+t),from:o,to:n+t}}function Te(e,t,o,n){const i=Eo(e,t);if(n.lastIndex=0,!n.test(i.text))return i;const s=o==="left"?i.from-1:i.to+1;return s<=0||s>=e.length||s===t?i:Te(e,s,o,n)}function Oo(e,t,o,n){const i=Math.max(e.from-1,0),s=Math.min(e.to+1,t.content.size),r=T.getMarksBetween(i,s,t);for(const l of r)l.mark.type===n&&o.removeMark(l.from,l.to,n)}const We=se.getPhoneNumberRegex(1,15);function Xe(e,t,o,n,i,s){if(!e)return;let r=o-t-1;r=r<0?0:r;const l=n-t,c=Te(e,r,"left",We),h=Te(e,l,"right",We),u=e.slice(c.from,h.to);To(u,se.linkRegex,ko).forEach(f=>{const p=Co(f[0]),m=t+c.from+f.index+1,g=m+p.length;i.addMark(m,g,s.create())})}function So(e){let t=!1;return new j.Plugin({key:new j.PluginKey("autolink"),appendTransaction:(o,n,i)=>{const s=o.some(u=>u.docChanged)&&!n.doc.eq(i.doc);if(t&&!s)return;const{tr:r}=i,{textContent:l}=i.doc;t||Xe(l,0,0,l.length,r,e.type),t=!0;const c=T.combineTransactionSteps(n.doc,[...o]);return T.getChangedRanges(c).forEach(({oldRange:u,newRange:d})=>{Oo(d,i.doc,r,e.type),T.findChildrenInRange(i.doc,d,p=>p.isTextblock).forEach(({node:p,pos:m})=>{Xe(p.textContent,m,u.from,d.to,r,e.type)})}),r}})}const Lo={class:"d-link d-c-text d-d-inline-block d-wb-break-all",rel:"noopener noreferrer nofollow"},Do=T.Mark.create({name:"CustomLink",renderHTML({HTMLAttributes:e}){return["a",T.mergeAttributes(this.options.HTMLAttributes,e,Lo)]},renderText({node:e}){return e.attrs.text},addProseMirrorPlugins(){return[So({type:this.type})]}}),Io=Vt.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}),Ro=Ye.extend({parseHTML(){return[{tag:"div"}]},renderHTML({HTMLAttributes:e}){return["div",T.mergeAttributes(this.options.HTMLAttributes,e),0]}}),Ao={compatConfig:{MODE:3},name:"MentionComponent",components:{NodeViewWrapper:S.NodeViewWrapper,DtLink:Ze.default},props:S.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 Bo(e,t,o,n,i,s){const r=a.resolveComponent("dt-link"),l=a.resolveComponent("node-view-wrapper");return a.openBlock(),a.createBlock(l,{class:"d-d-inline-block"},{default:a.withCtx(()=>[a.createVNode(r,{kind:"mention",onClick:a.withModifiers(s.handleClick,["prevent"])},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(s.text),1)]),_:1},8,["onClick"])]),_:1})}const No=F._(Ao,[["render",Bo]]),Mo=ke.extend({addNodeView(){return S.VueNodeViewRenderer(No)},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",T.mergeAttributes(this.options.HTMLAttributes,e)]}}).configure({suggestion:{char:"@",pluginKey:new j.PluginKey("mentionSuggestion")}}),Ho={compatConfig:{MODE:3},name:"ChannelComponent",components:{NodeViewWrapper:S.NodeViewWrapper,DtLink:Ze.default,DtIconLock:$t.DtIconLock,DtStack:ae.default},props:S.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 Vo(e,t,o,n,i,s){const r=a.resolveComponent("dt-icon-lock"),l=a.resolveComponent("dt-stack"),c=a.resolveComponent("dt-link"),h=a.resolveComponent("node-view-wrapper");return a.openBlock(),a.createBlock(h,{class:"d-d-inline-block"},{default:a.withCtx(()=>[a.createVNode(c,{kind:"mention",onClick:a.withModifiers(s.handleClick,["prevent"])},{default:a.withCtx(()=>[a.createVNode(l,{direction:"row",gap:"0"},{default:a.withCtx(()=>[e.$props.node.attrs.locked?(a.openBlock(),a.createBlock(r,{key:0,size:"200"})):a.createCommentVNode("",!0),a.createElementVNode("span",null,a.toDisplayString(s.text),1)]),_:1})]),_:1},8,["onClick"])]),_:1})}const $o=F._(Ho,[["render",Vo]]),Po=ke.extend({name:"channel",addNodeView(){return S.VueNodeViewRenderer($o)},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",T.mergeAttributes(this.options.HTMLAttributes,e)]}}).configure({suggestion:{char:"#",pluginKey:new j.PluginKey("channelSuggestion")}}),Uo={compatConfig:{MODE:3},name:"SlashCommandsComponent",components:{NodeViewWrapper:S.NodeViewWrapper},props:{...S.nodeViewProps},emits:["selected-command"],computed:{text(){return"/"+this.$props.node.attrs.command}},created(){var o,n,i;const e=this.$props.node.attrs.command;this.$emit("selected-command",e);const t=(i=(n=(o=this.editor)==null?void 0:o.storage)==null?void 0:n["slash-commands"])==null?void 0:i.onSelectedCommand;t&&typeof t=="function"&&t(e)}};function jo(e,t,o,n,i,s){const r=a.resolveComponent("node-view-wrapper");return a.openBlock(),a.createBlock(r,{class:"d-d-inline-block"},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(s.text),1)]),_:1})}const qo=F._(Uo,[["render",jo]]),zo=(e,t)=>[...e.matchAll(t)].map(n=>{let i=n[2];return i.endsWith(" ")||(i+=" "),{index:n.index,text:i,match:n}}),Fo=ke.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 S.VueNodeViewRenderer(qo)},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",T.mergeAttributes(this.options.HTMLAttributes,e)]},addInputRules(){var o;const e=(o=this.options.suggestion)==null?void 0:o.items({query:""}).map(n=>n.command),t=new RegExp(`^((?:\\/)(${e.join("|")})) $`);return[T.nodeInputRule({find:t,type:this.type,getAttributes(n){return{command:n[2]}}})]},addPasteRules(){var o;const e=(o=this.options.suggestion)==null?void 0:o.items({query:""}).map(n=>n.command),t=new RegExp(`^((?:\\/)(${e.join("|")})) ?$`,"g");return[T.nodePasteRule({find:n=>zo(n,t),type:this.type,getAttributes(n){return{command:n[0].trim()}}})]}}).configure({suggestion:{char:"/",pluginKey:new j.PluginKey("slashCommandSuggestion")}}),Ko=100,Wo={name:"VariableComponent",components:{DtBadge:jt.default,DtButton:et.default,DtPopover:Ut.default,DtInput:Pt.default,NodeViewWrapper:S.NodeViewWrapper},props:S.nodeViewProps,data(){return{i18n:new Qe.DialtoneLocalization,MAX_VARIABLE_ALT_LENGTH:Ko}},computed:{altText:{get(){var e,t;return((t=(e=this.node)==null?void 0:e.attrs)==null?void 0:t.altText)||""},set(e){this.updateAttributes({altText:e})}},variableId(){var e,t;return(t=(e=this.node)==null?void 0:e.attrs)==null?void 0:t.id},placeholder(){var e;return((e=this.variableData)==null?void 0:e.placeholder)||""},variableItems(){var e,t;return((t=(e=this.extension)==null?void 0:e.options)==null?void 0:t.variableItems)||[]},variableData(){return this.variableItems.find(e=>e.id===this.variableId)},badgeLabel(){return`{} ${this.placeholder}`},placeholderText(){return`Replaces ${this.placeholder}`}}};function Xo(e,t,o,n,i,s){const r=a.resolveComponent("dt-badge"),l=a.resolveComponent("dt-button"),c=a.resolveComponent("dt-input"),h=a.resolveComponent("dt-popover"),u=a.resolveComponent("node-view-wrapper");return a.openBlock(),a.createBlock(u,{class:"d-d-inline-block"},{default:a.withCtx(()=>[a.createVNode(h,{padding:"small","navigation-type":"arrow-keys",placement:"top-start",modal:!1},{anchor:a.withCtx(({attrs:d})=>[a.createVNode(l,a.mergeProps(d,{kind:"unstyled"}),{default:a.withCtx(()=>[a.createVNode(r,{text:s.badgeLabel,contenteditable:"false"},null,8,["text"])]),_:1},16)]),content:a.withCtx(({close:d})=>[a.createVNode(c,{modelValue:s.altText,"onUpdate:modelValue":t[0]||(t[0]=f=>s.altText=f),"root-class":"d-p8 d-w332",label:i.i18n.$t("DIALTONE_EDITOR_VARIABLE_LABEL"),placeholder:s.placeholderText,validate:{length:{description:i.i18n.$t("DIALTONE_EDITOR_VARIABLE_VALIDATE_DESCRIPTION"),message:i.i18n.$t("DIALTONE_EDITOR_VARIABLE_VALIDATE_MESSAGE"),max:i.MAX_VARIABLE_ALT_LENGTH,warn:i.MAX_VARIABLE_ALT_LENGTH,limitMaxLength:!0}},onKeyup:a.withKeys(f=>d(),["enter"])},null,8,["modelValue","label","placeholder","validate","onKeyup"])]),_:1})]),_:1})}const Yo=F._(Wo,[["render",Xo]]),Go=T.Node.create({name:"variable",group:"inline",inline:!0,selectable:!0,atom:!0,addOptions(){return{HTMLAttributes:{},variableItems:[]}},addNodeView(){return S.VueNodeViewRenderer(Yo)},addAttributes(){return{id:{default:null,parseHTML:e=>e.getAttribute("data-variable-id"),renderHTML:e=>e.id?{"data-variable-id":e.id}:{}},altText:{default:"",parseHTML:e=>e.getAttribute("data-alt-text"),renderHTML:e=>e.altText?{"data-alt-text":e.altText}:{}}}},parseHTML(){return[{tag:"variable"}]},renderText({node:e}){return e.attrs.altText},renderHTML({node:e,HTMLAttributes:t}){return["variable",T.mergeAttributes(this.options.HTMLAttributes,t,{"data-variable-id":e.attrs.id,"data-alt-text":e.attrs.altText})]},addCommands(){return{insertVariable:(e={})=>({commands:t})=>t.insertContent({type:this.name,attrs:{id:e.id||null,altText:e.altText||""}})}}}),Jo={compatConfig:{MODE:3},name:"MentionSuggestion",components:{DtAvatar:qt.default,DtStack:ae.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}}},Zo={class:"d-mention-suggestion__name"},Qo={key:1,class:"d-mention-suggestion__divider"},ei={key:2,class:"d-mention-suggestion__status"};function ti(e,t,o,n,i,s){const r=a.resolveComponent("dt-avatar"),l=a.resolveComponent("dt-stack");return a.openBlock(),a.createBlock(l,{direction:"row",class:"d-mention-suggestion__container",gap:"400"},{default:a.withCtx(()=>[a.createVNode(r,{"full-name":s.name,"image-src":s.avatarSrc,"image-alt":s.name,"show-presence":s.showDetails,presence:s.presence,size:"sm"},null,8,["full-name","image-src","image-alt","show-presence","presence"]),a.createVNode(l,{class:"d-mention-suggestion__details-container",gap:"100"},{default:a.withCtx(()=>[a.createElementVNode("span",Zo,a.toDisplayString(s.name),1),s.showDetails?(a.openBlock(),a.createBlock(l,{key:0,direction:"row",gap:"300",class:"d-label--sm-plain"},{default:a.withCtx(()=>[s.presenceText?(a.openBlock(),a.createElementBlock("span",{key:0,class:a.normalizeClass(["d-mention-suggestion__presence",[s.presenceFontColorClass]])},a.toDisplayString(s.presenceText),3)):a.createCommentVNode("",!0),s.status&&s.presenceText?(a.openBlock(),a.createElementBlock("div",Qo," • ")):a.createCommentVNode("",!0),s.status?(a.openBlock(),a.createElementBlock("div",ei,a.toDisplayString(s.status),1)):a.createCommentVNode("",!0)]),_:1})):a.createCommentVNode("",!0)]),_:1})]),_:1})}const ni=F._(Jo,[["render",ti]]),oi={allowSpaces:!0,render:ye(ni,"mention")},ii={compatConfig:{MODE:3},name:"ChannelSuggestion",components:{DtStack:ae.default,DtIconHash:zt,DtIconLock:Ft},props:{item:{type:Object,required:!0}},computed:{name(){return this.item.name}}};function si(e,t,o,n,i,s){const r=a.resolveComponent("dt-icon-hash"),l=a.resolveComponent("dt-icon-lock"),c=a.resolveComponent("dt-stack");return a.openBlock(),a.createBlock(c,{direction:"row",gap:"400"},{default:a.withCtx(()=>[o.item.locked?(a.openBlock(),a.createBlock(l,{key:1,size:"300"})):(a.openBlock(),a.createBlock(r,{key:0,size:"300"})),a.createElementVNode("span",null,a.toDisplayString(s.name),1)]),_:1})}const ri=F._(ii,[["render",si]]),ai={allowSpaces:!0,render:ye(ri,"channel")},li={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}}},ci={class:"d-body--md-compact"},di={key:0},ui={class:"d-body--sm d-fc-tertiary"};function hi(e,t,o,n,i,s){return a.openBlock(),a.createElementBlock("div",null,[a.createElementVNode("div",ci,[a.createElementVNode("span",null,"/"+a.toDisplayString(s.command),1),s.parametersExample?(a.openBlock(),a.createElementBlock("span",di,a.toDisplayString(s.parametersExample),1)):a.createCommentVNode("",!0)]),a.createElementVNode("div",ui,a.toDisplayString(s.description),1)])}const fi=F._(li,[["render",hi]]),pi={allowSpaces:!0,startOfLine:!0,render:ye(fi,"slash-command")},mi={compatConfig:{MODE:3},name:"DtRichTextEditor",components:{EditorContent:S.EditorContent,BubbleMenu:zn,DtButton:et.default,DtStack:ae.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"?de.RICH_TEXT_EDITOR_AUTOFOCUS_TYPES.includes(e):!0}},outputFormat:{type:String,default:"html",validator(e){return de.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},allowVariable:{type:Boolean,default:!1},variableItems:{type:Array,default:()=>[]},additionalExtensions:{type:Array,default:()=>[]},hideLinkBubbleMenu:{type:Boolean,default:!1},useDivTags:{type:Boolean,default:!1},allowTables:{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,appendTo:()=>{var e;return(e=se.returnFirstEl(this.$refs.editor.$el).getRootNode())==null?void 0:e.querySelector("body")},floatingOptions:{placement:"top-start"},i18n:new Qe.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 o={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),variable:n=>this.processVariableNode(n)}[e.type];return o?o(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(`
|
|
5
|
-
`).map(
|
|
5
|
+
`).map(o=>o?`> ${o}`:">").join(`
|
|
6
6
|
`)+`
|
|
7
|
-
`},processBulletListNode(e){return this.processNodeContent(e)},processOrderedListNode(e){return e.content?e.content.map((t,
|
|
7
|
+
`},processBulletListNode(e){return this.processNodeContent(e)},processOrderedListNode(e){return e.content?e.content.map((t,o)=>this.processNode(t).replace(/^- /,`${o+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,
|
|
10
|
+
\`\`\``},processMentionNode(e){var i,s,r;const t=((i=e.attrs)==null?void 0:i.name)||"",o=((s=e.attrs)==null?void 0:s.id)||"",n=((r=e.attrs)==null?void 0:r.contactKey)||"";return`<!-- @mention: {"id": "${o}", "contactKey": "${n}", "name": "${t}"} -->`},processChannelNode(e){var s,r,l,c;const t=((s=e.attrs)==null?void 0:s.name)||"",o=((r=e.attrs)==null?void 0:r.id)||"",n=((l=e.attrs)==null?void 0:l.locked.toString())||"",i=((c=e.attrs)==null?void 0:c.channelKey)||"";return`<!-- @channel: {"id": "${o}", "channelKey": "${i}", "name": "${t}", "locked": "${n}"} -->`},processSlashCommandsNode(e){var n,i;const t=((n=e.attrs)==null?void 0:n.command)||"",o=((i=e.attrs)==null?void 0:i.parameters)||"";return`/${t}${o?` ${o}`:""}`},processEmojiNode(e){var t;return((t=e.attrs)==null?void 0:t.code)||""},processVariableNode(e){var n,i;const t=((n=e.attrs)==null?void 0:n.id)||"",o=((i=e.attrs)==null?void 0:i.altText)||"";return`{{${t}=${o}}}`},processUnknownNode(e){return this.processNodeContent(e)},applyMarks(e,t){let o=e;return[...t].sort((i,s)=>{const r={link:0,bold:1,italic:2,strike:3,code:4};return(r[i.type]||5)-(r[s.type]||5)}).forEach(i=>{var s;switch(i.type){case"bold":o=`**${o}**`;break;case"italic":o=`*${o}*`;break;case"strike":o=`~~${o}~~`;break;case"code":o=`\`${o}\``;break;case"link":{const r=((s=i.attrs)==null?void 0:s.href)||"";o=`[${o}](${r})`;break}}}),o}}}},computed:{attrs(){return{...this.$attrs,onInput:()=>{},onFocus:()=>{},onBlur:()=>{}}},extensions(){const e=[Et,At,be.UndoRedo,Ot];e.push(this.useDivTags?Ro:Ye),this.allowBold&&e.push(St),this.allowBlockquote&&e.push(Tt),this.allowBulletList&&(e.push(ve.BulletList),e.push(ve.ListItem.extend({renderText({node:n}){return n.textContent}})),e.push(ve.OrderedList)),this.allowItalic&&e.push(Lt),this.allowStrike&&e.push(It),this.allowUnderline&&e.push(Rt),this.placeholder&&e.push(be.Placeholder.configure({placeholder:this.placeholder}));const t=this,o=T.Extension.create({addKeyboardShortcuts(){return{"Shift-Enter":({editor:n})=>t.allowLineBreaks?!1:(n.commands.first(({commands:i})=>[()=>i.newlineInCode(),()=>t.allowBulletList&&i.splitListItem("listItem"),()=>i.createParagraphNear(),()=>i.liftEmptyBlock(),()=>i.splitBlock()]),!0),Enter:()=>t.allowLineBreaks?!1:(t.$emit("enter"),!0)}}});if(e.push(o),this.link&&e.push(Dt.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:de.RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS})),this.customLink&&e.push(this.getExtension(Do,this.customLink)),this.mentionSuggestion){const n={...this.mentionSuggestion,...oi};e.push(Mo.configure({suggestion:n}))}if(this.channelSuggestion){const n={...this.channelSuggestion,...ai};e.push(Po.configure({suggestion:n}))}if(this.slashCommandSuggestion){const n={...this.slashCommandSuggestion,...pi};e.push(Fo.configure({suggestion:n,onSelectedCommand:i=>{this.$emit("selected-command",i)}}))}return this.allowVariable&&e.push(Go.configure({variableItems:this.variableItems})),e.push(_o),e.push(Bt.configure({types:["paragraph"]})),this.allowCode&&e.push(Ct),this.allowCodeblock&&e.push(kt.extend({renderText({node:n}){return`\`\`\`
|
|
11
11
|
${n.textContent}
|
|
12
|
-
\`\`\``}}).configure({HTMLAttributes:{class:"d-rich-text-editor__code-block"}})),this.allowInlineImages&&e.push(
|
|
12
|
+
\`\`\``}}).configure({HTMLAttributes:{class:"d-rich-text-editor__code-block"}})),this.allowInlineImages&&e.push(Io),(this.allowFontFamily||this.allowFontColor)&&e.push(Nt.TextStyleKit.configure({color:this.allowFontColor,backgroundColor:!1,fontFamily:this.allowFontFamily,fontSize:!1,lineHeight:!1})),this.additionalExtensions.length&&e.push(...this.additionalExtensions),this.allowTables&&e.push(ce.Table.configure({resizable:!0}),ce.TableRow,ce.TableHeader,ce.TableCell,be.Gapcursor),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(){se.warnIfUnmounted(se.returnFirstEl(this.$el),this.$options.name),this.processValue(this.modelValue,!1)},methods:{createEditor(){this.editor=new S.Editor({autofocus:this.autoFocus,content:this.modelValue,editable:this.editable,extensions:this.extensions,shouldRerenderOnTransaction:!1,parseOptions:{preserveWhitespace:"full"},editorProps:{attributes:{...this.inputAttrs,class:this.inputClass},handleKeyDown:(e,t)=>{if(!this.preventTyping)return!1;const o=["Backspace"];return!this.allowLineBreaks&&!t.shiftKey&&o.push("Enter"),!o.includes(t.key)},handlePaste:(e,t)=>{const o=t.clipboardData||window.clipboardData,n=o.getData("text/plain"),i=o.getData("text/html");return this.processPasteData(e,n,i)},transformPastedHTML(e){return e.replace(/(<\/\w+>)((<br \/>)+)/g,"$2$3$1")}}}),this.addEditorListeners()},bubbleMenuShouldShow({editor:e}){return e.isActive("link")},getSelectedLinkText(e){var l,c,h;const{view:t,state:o}=e,{from:n,to:i}=t.state.selection,s=o.doc.textBetween(n,i,""),r=this.editor.state.doc.nodeAt(n);return r&&((h=(c=(l=r.marks)==null?void 0:l.at(0))==null?void 0:c.type)==null?void 0:h.name)==="link"?r.textContent:s},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,o,n;(n=(o=(t=(e=this.editor)==null?void 0:e.chain())==null?void 0:t.focus())==null?void 0:o.unsetLink())==null||n.run()},openLink(){var t,o;(o=(t=this.editor)==null?void 0:t.chain())==null||o.focus();const e=this.editor.getAttributes("link").href;window.open(e,"_blank")},setLink(e,t,o,n=de.RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS,i){var l,c,h;if(!e){this.removeLink();return}n.find(u=>u.test(e))||(e=`${i}${e}`),this.editor.chain().focus().extendMarkRange("link").run();const r=(h=(c=(l=this.editor)==null?void 0:l.view)==null?void 0:c.state)==null?void 0:h.selection;this.editor.chain().focus().insertContent(t).setTextSelection({from:r.from,to:r.from+t.length}).setLink({href:e,class:o.class}).run()},processValue(e,t=!0){if(!this.editor)return;const o=this.getOutput();if(!(t&&Kt(e,o))){if(typeof e=="string"&&this.outputFormat==="text"){const n=new RegExp(`(${Ge.emojiPattern})`,"g");e=e==null?void 0:e.replace(n,'<emoji-component code="$1"></emoji-component>')}this.editor.commands.setContent(e,{emitUpdate:!1,parseOptions:{preserveWhitespace:"full"}})}},destroyEditor(){this.editor.destroy()},insertPlainTextWithHardBreaks(e,t){const i=(this.pasteRichText?t:t.replace(/\r\n/g,`
|
|
13
13
|
`).replace(/\n\n/g,`
|
|
14
|
-
`)).replace(/[\r\n]+$/,"").split(/\r?\n/),
|
|
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
|
|
14
|
+
`)).replace(/[\r\n]+$/,"").split(/\r?\n/),s=[];for(let r=0;r<i.length;r++)r>0&&s.push({type:"hardBreak"}),i[r]&&s.push({type:"text",text:i[r]});this.editor.chain().focus().insertContent(s).run()},shouldPreserveLineBreaks(e,t){return this.pasteRichText?!t&&e&&this.hasBlankLines(e):!!e},processPasteData(e,t,o){if(this.shouldPreserveLineBreaks(t,o))return this.insertPlainTextWithHardBreaks(e,t),!0;if(this.shouldHandlePreformattedHTML(o)){const n=this.extractPreformattedText(o);if(n&&n.includes(`
|
|
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 o=t.querySelectorAll("*");for(const n of o)if(this.hasPreWhitespace(n)&&this.hasLineBreaks(n))return!0;return!1},hasPreWhitespace(e){const t=e.getAttribute("style")||"",o=e.style.whiteSpace||"",n=o==="pre"||o==="pre-wrap",i=t.includes("white-space: pre");return n||i},hasLineBreaks(e){return e.textContent&&e.textContent.includes(`
|
|
16
16
|
`)},hasBlankLines(e){return e.includes(`
|
|
17
17
|
|
|
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
|
|
19
|
-
`});this.$emit("text-input",n);const
|
|
20
|
-
`})}},getExtension(e,t){var
|
|
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 o of e.childNodes)t+=this.walkAndExtractText(o);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 o=this.editor.getHTML();this.$emit("html-input",o);const n=this.editor.getText({blockSeparator:`
|
|
19
|
+
`});this.$emit("text-input",n);const i=this.jsonToMarkdownConverter.convertToMarkdown(t);this.$emit("markdown-input",i)},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 o;return typeof t=="boolean"?e:(o=e.configure)==null?void 0:o.call(e,t)},updateEditorAttributes(e){this.editor.setOptions({editorProps:{attributes:{...this.inputAttrs,class:this.inputClass,...e}}})},focusEditor(){this.editor.commands.focus()}}},gi={class:"d-popover__dialog"};function wi(e,t,o,n,i,s){const r=a.resolveComponent("dt-button"),l=a.resolveComponent("dt-stack"),c=a.resolveComponent("bubble-menu"),h=a.resolveComponent("editor-content");return a.openBlock(),a.createElementBlock("div",null,[i.editor&&o.link&&!o.hideLinkBubbleMenu?(a.openBlock(),a.createBlock(c,{key:0,editor:i.editor,"should-show":s.bubbleMenuShouldShow,options:i.floatingOptions,"append-to":i.appendTo,style:{visibility:"visible"}},{default:a.withCtx(()=>[a.createElementVNode("div",gi,[a.createVNode(l,{direction:"row",class:"d-rich-text-editor-bubble-menu__button-stack",gap:"0"},{default:a.withCtx(()=>[a.createVNode(r,{kind:"muted",importance:"clear",onClick:s.editLink},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(i.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_EDIT_BUTTON_LABEL")),1)]),_:1},8,["onClick"]),a.createVNode(r,{kind:"muted",importance:"clear",onClick:s.openLink},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(i.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_OPEN_LINK_BUTTON_LABEL")),1)]),_:1},8,["onClick"]),a.createVNode(r,{kind:"danger",importance:"clear",onClick:s.removeLink},{default:a.withCtx(()=>[a.createTextVNode(a.toDisplayString(i.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_REMOVE_BUTTON_LABEL")),1)]),_:1},8,["onClick"])]),_:1})])]),_:1},8,["editor","should-show","options","append-to"])):a.createCommentVNode("",!0),a.createVNode(h,a.mergeProps({ref:"editor",editor:i.editor,class:"d-rich-text-editor","data-qa":"dt-rich-text-editor"},s.attrs),null,16,["editor"])])}const yi=F._(mi,[["render",wi]]);exports.default=yi;
|
|
21
21
|
//# sourceMappingURL=rich-text-editor.cjs.map
|