@dialpad/dialtone 9.139.1 → 9.140.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 +59256 -59256
- package/dist/vue2/component-documentation.json +1 -1
- package/dist/vue2/lib/emoji-picker/emoji-picker.cjs.map +1 -1
- package/dist/vue2/lib/emoji-picker/emoji-picker.js.map +1 -1
- package/dist/vue2/lib/message-input/message-input.cjs +1 -1
- package/dist/vue2/lib/message-input/message-input.cjs.map +1 -1
- package/dist/vue2/lib/message-input/message-input.js +26 -18
- package/dist/vue2/lib/message-input/message-input.js.map +1 -1
- package/dist/vue2/lib/rich-text-editor/channel-suggestion.cjs.map +1 -1
- package/dist/vue2/lib/rich-text-editor/channel-suggestion.js.map +1 -1
- package/dist/vue2/lib/rich-text-editor/rich-text-editor-constants.cjs +1 -1
- package/dist/vue2/lib/rich-text-editor/rich-text-editor-constants.cjs.map +1 -1
- package/dist/vue2/lib/rich-text-editor/rich-text-editor-constants.js +2 -1
- package/dist/vue2/lib/rich-text-editor/rich-text-editor-constants.js.map +1 -1
- package/dist/vue2/lib/rich-text-editor/rich-text-editor.cjs +13 -4
- package/dist/vue2/lib/rich-text-editor/rich-text-editor.cjs.map +1 -1
- package/dist/vue2/lib/rich-text-editor/rich-text-editor.js +356 -225
- package/dist/vue2/lib/rich-text-editor/rich-text-editor.js.map +1 -1
- package/dist/vue2/types/components/rich_text_editor/extensions/mentions/mention.d.ts.map +1 -1
- package/dist/vue2/types/components/rich_text_editor/rich_text_editor.vue.d.ts +21 -1
- package/dist/vue2/types/components/rich_text_editor/rich_text_editor.vue.d.ts.map +1 -1
- package/dist/vue2/types/components/rich_text_editor/rich_text_editor_constants.d.ts.map +1 -1
- package/dist/vue2/types/recipes/conversation_view/message_input/message_input.vue.d.ts +2 -1
- package/dist/vue2/types/recipes/conversation_view/message_input/message_input.vue.d.ts.map +1 -1
- package/dist/vue3/component-documentation.json +1 -1
- package/dist/vue3/lib/emoji-picker/emoji-picker.cjs.map +1 -1
- package/dist/vue3/lib/emoji-picker/emoji-picker.js.map +1 -1
- package/dist/vue3/lib/message-input/message-input.cjs +1 -1
- package/dist/vue3/lib/message-input/message-input.cjs.map +1 -1
- package/dist/vue3/lib/message-input/message-input.js +37 -28
- package/dist/vue3/lib/message-input/message-input.js.map +1 -1
- package/dist/vue3/lib/rich-text-editor/channel-suggestion.cjs.map +1 -1
- package/dist/vue3/lib/rich-text-editor/channel-suggestion.js.map +1 -1
- package/dist/vue3/lib/rich-text-editor/rich-text-editor-constants.cjs +1 -1
- package/dist/vue3/lib/rich-text-editor/rich-text-editor-constants.cjs.map +1 -1
- package/dist/vue3/lib/rich-text-editor/rich-text-editor-constants.js +2 -1
- package/dist/vue3/lib/rich-text-editor/rich-text-editor-constants.js.map +1 -1
- package/dist/vue3/lib/rich-text-editor/rich-text-editor.cjs +15 -6
- 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 +421 -278
- package/dist/vue3/lib/rich-text-editor/rich-text-editor.js.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/channels/ChannelComponent.vue.d.ts +1 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/channels/ChannelComponent.vue.d.ts.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/extensions/mentions/mention.d.ts.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/rich_text_editor.vue.d.ts +22 -1
- package/dist/vue3/types/components/rich_text_editor/rich_text_editor.vue.d.ts.map +1 -1
- package/dist/vue3/types/components/rich_text_editor/rich_text_editor_constants.d.ts.map +1 -1
- package/dist/vue3/types/recipes/conversation_view/message_input/message_input.vue.d.ts +3 -1
- package/dist/vue3/types/recipes/conversation_view/message_input/message_input.vue.d.ts.map +1 -1
- package/package.json +4 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rich-text-editor-constants.js","sources":["../../../components/rich_text_editor/rich_text_editor_constants.js"],"sourcesContent":["export const RICH_TEXT_EDITOR_OUTPUT_FORMATS = [\n 'text',\n 'json',\n 'html',\n];\n\nexport const RICH_TEXT_EDITOR_AUTOFOCUS_TYPES = [\n 'start',\n 'end',\n 'all',\n];\n\nexport const RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS = [\n 'https',\n 'http',\n 'ftp',\n 'ftps',\n 'sftp',\n 'mailto',\n];\n\nexport default {\n RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS,\n RICH_TEXT_EDITOR_OUTPUT_FORMATS,\n RICH_TEXT_EDITOR_AUTOFOCUS_TYPES,\n};\n"],"names":["RICH_TEXT_EDITOR_OUTPUT_FORMATS","RICH_TEXT_EDITOR_AUTOFOCUS_TYPES","RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS","rich_text_editor_constants"],"mappings":"AAAY,MAACA,IAAkC;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AACF,GAEaC,IAAmC;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AACF,GAEaC,IAA4C;AAAA,EACvD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAEAC,IAAe;AAAA,EACb,2CAAAD;AAAA,EACA,iCAAAF;AAAA,EACA,kCAAAC;AACF;"}
|
|
1
|
+
{"version":3,"file":"rich-text-editor-constants.js","sources":["../../../components/rich_text_editor/rich_text_editor_constants.js"],"sourcesContent":["export const RICH_TEXT_EDITOR_OUTPUT_FORMATS = [\n 'text',\n 'json',\n 'html',\n 'markdown',\n];\n\nexport const RICH_TEXT_EDITOR_AUTOFOCUS_TYPES = [\n 'start',\n 'end',\n 'all',\n];\n\nexport const RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS = [\n 'https',\n 'http',\n 'ftp',\n 'ftps',\n 'sftp',\n 'mailto',\n];\n\nexport default {\n RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS,\n RICH_TEXT_EDITOR_OUTPUT_FORMATS,\n RICH_TEXT_EDITOR_AUTOFOCUS_TYPES,\n};\n"],"names":["RICH_TEXT_EDITOR_OUTPUT_FORMATS","RICH_TEXT_EDITOR_AUTOFOCUS_TYPES","RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS","rich_text_editor_constants"],"mappings":"AAAY,MAACA,IAAkC;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAEaC,IAAmC;AAAA,EAC9C;AAAA,EACA;AAAA,EACA;AACF,GAEaC,IAA4C;AAAA,EACvD;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,GAEAC,IAAe;AAAA,EACb,2CAAAD;AAAA,EACA,iCAAAF;AAAA,EACA,kCAAAC;AACF;"}
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("../../node_modules/@tiptap/vue-2.cjs"),l=require("@tiptap/core"),D=require("@tiptap/extension-blockquote"),B=require("@tiptap/extension-code-block"),q=require("@tiptap/extension-code"),j=require("@tiptap/extension-document"),$=require("@tiptap/extension-paragraph"),M=require("@tiptap/extension-placeholder"),H=require("@tiptap/extension-hard-break"),N=require("@tiptap/extension-bold"),V=require("@tiptap/extension-bullet-list"),F=require("@tiptap/extension-italic"),K=require("@tiptap/extension-link"),W=require("@tiptap/extension-list-item"),U=require("@tiptap/extension-ordered-list"),z=require("@tiptap/extension-strike"),X=require("@tiptap/extension-underline"),J=require("@tiptap/extension-text"),Y=require("@tiptap/extension-text-align"),G=require("@tiptap/extension-history"),Q=require("@tiptap/extension-text-style"),Z=require("@tiptap/extension-color"),ee=require("@tiptap/extension-font-family"),p=require("@tiptap/pm/state"),te=require("@tiptap/suggestion"),I=require("regex-combined-emojis"),u=require("../../_plugin-vue2_normalizer-e_CkxkSV.cjs"),P=require("../emoji/emoji.cjs"),f=require("../../common/emoji/index.cjs"),ne=require("../list-item/list-item.cjs"),b=require("../stack/stack.cjs"),v=require("tippy.js"),E=require("../../common/utils/index.cjs"),re=require("@tiptap/extension-image"),S=require("@tiptap/extension-mention"),A=require("../link/link.cjs"),w=require("./rich-text-editor-constants.cjs"),se=require("../avatar/avatar.cjs"),ie=require("@dialpad/dialtone-icons/vue2/hash"),oe=require("@dialpad/dialtone-icons/vue2/lock"),ae=require("deep-equal"),ce=require("../../localization/index.cjs"),le=require("../button/button.cjs"),de={name:"EmojiComponent",components:{NodeViewWrapper:c.NodeViewWrapper,DtEmoji:P.default},props:c.nodeViewProps};var ue=function(){var t=this,n=t._self._c;return n("node-view-wrapper",{staticClass:"d-d-inline-block d-va-bottom d-lh0"},[n("dt-emoji",{attrs:{size:"500",code:t.node.attrs.code}})],1)},me=[],he=u.n(de,ue,me);const fe=he.exports,pe={name:"SuggestionList",components:{DtListItem:ne.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});break;case"channel":this.command({name:t.name,id:t.id});break;case"slash-command":this.command({command:t.command});break}}}};var ge=function(){var t=this,n=t._self._c;return n("div",{staticClass:"d-popover__dialog d-suggestion-list__container"},[n("ul",{directives:[{name:"show",rawName:"v-show",value:t.items.length,expression:"items.length"}],ref:"suggestionList",staticClass:"d-suggestion-list"},t._l(t.items,function(r,s){return n("dt-list-item",{key:r.id,class:["d-suggestion-list__item",{"d-list-item--highlighted":s===t.selectedIndex}],attrs:{"navigation-type":"arrow-keys"},on:{click:function(i){return t.selectItem(s)},keydown:function(i){return i.preventDefault(),t.onKeyDown.apply(null,arguments)}}},[n(t.itemComponent,{tag:"component",attrs:{item:r}})],1)}),1)])},_e=[],ye=u.n(pe,ge,_e);const x=ye.exports,we={name:"EmojiSuggestion",components:{DtEmoji:P.default,DtStack:b.default},props:{item:{type:Object,required:!0}}};var be=function(){var t=this,n=t._self._c;return n("dt-stack",{attrs:{direction:"row",gap:"400"}},[n("dt-emoji",{attrs:{size:"200",code:t.item.code}}),t._v(" "+t._s(t.item.code)+" ")],1)},ve=[],xe=u.n(we,be,ve);const ke=xe.exports,k={name:"hideOnEsc",defaultValue:!0,fn({hide:e}){function t(n){n.keyCode===27&&e()}return{onShow(){document.addEventListener("keydown",t)},onHide(){document.removeEventListener("keydown",t)}}}},Te=20,Ce=(e,t,n)=>{var a,d;const r=(a=e.shortname)==null?void 0:a.replaceAll(":",""),s=(d=t.shortname)==null?void 0:d.replaceAll(":",""),i=r.startsWith(n),o=s.startsWith(n);return i&&!o?-1:!i&&o?1:r.localeCompare(s)},Ee={items:({query:e})=>{if(e.length<2)return[];const t=Object.values(f.getEmojiData());return e=e.toLowerCase(),t.filter(r=>{var s;return[r.name,(s=r.shortname)==null?void 0:s.replaceAll(":",""),...r.keywords||[]].some(i=>i&&i.startsWith(e))}).splice(0,Te).sort((r,s)=>Ce(r,s,e)).map(r=>({code:r.shortname}))},command:({editor:e,range:t,props:n})=>{var i,o;const r=e.view.state.selection.$to.nodeAfter;((i=r==null?void 0:r.text)==null?void 0:i.startsWith(" "))&&(t.to+=1),e.chain().focus().insertContentAt(t,[{type:"emoji",attrs:n}]).run(),(o=window.getSelection())==null||o.collapseToEnd()},render:()=>{let e,t,n=!1;return{onStart:r=>{e=new c.VueRenderer(x,{parent:void 0,propsData:{itemComponent:ke,itemType:"emoji",...r},editor:r.editor}),r.clientRect&&(t=v("body",{getReferenceClientRect:r.clientRect,appendTo:()=>document.body,content:e.element,showOnCreate:!1,onShow:()=>{n=!0},onHidden:()=>{n=!1},interactive:!0,trigger:"manual",placement:"top-start",zIndex:650,plugins:[k]}),r.items.length>0&&(t==null||t[0].show()))},onUpdate(r){e==null||e.updateProps(r),r.items.length>0?t==null||t[0].show():t==null||t[0].hide(),t==null||t[0].setProps({getReferenceClientRect:r.clientRect})},onKeyDown(r){var s;if(n)return(s=e==null?void 0:e.ref)==null?void 0:s.onKeyDown(r)},onExit(){t==null||t[0].destroy(),t=null,e==null||e.destroy(),e=null}}}},Se=/(:\w+:)$/,Re=new RegExp(I.emojiPattern+"$"),Le=e=>{if(e&&f.codeToEmojiData(e[0]))return{text:e[2]||e[0]}},$e=e=>[...e.matchAll(f.emojiShortCodeRegex)].filter(n=>f.codeToEmojiData(n[0])).map(n=>({index:n.index,text:n[0],match:n})),Ie=l.Node.create({name:"emoji",addOptions(){return{HTMLAttributes:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addNodeView(){return c.VueNodeViewRenderer(fe)},addAttributes(){return{code:{default:null},image:{default:null},name:{default:null}}},parseHTML(){return[{tag:"emoji-component"}]},renderText({node:e}){return f.stringToUnicode(f.codeToEmojiData(e.attrs.code).unicode_output)},renderHTML({HTMLAttributes:e}){return["emoji-component",l.mergeAttributes(this.options.HTMLAttributes,e)]},addInputRules(){return[new l.InputRule({find:e=>{const t=e.match(Se)||e.match(Re);if(t)return Le(t)},handler:({state:e,range:t,match:n})=>{const{tr:r}=e,s=t.from,i=t.to;r.replaceWith(s,i,this.type.create({code:n[0]}))}})]},addPasteRules(){return[l.nodePasteRule({find:$e,type:this.type,getAttributes(e){return{code:e[0],image:e[1],name:e[2]}}}),l.nodePasteRule({find:f.emojiRegex,type:this.type,getAttributes(e){return{code:e[0],image:e[1],name:e[2]}}})]},addProseMirrorPlugins(){return[te({char:":",pluginKey:new p.PluginKey("emoji"),editor:this.editor,...this.options.suggestion,...Ee})]},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:e,state:t})=>{let n=!1;const{selection:r}=t,{empty:s,anchor:i}=r;return s?(t.doc.nodesBetween(i-1,i,(o,a)=>{if(o.type.name===this.name)return n=!0,e.insertText("",a,a+o.nodeSize),!1}),n):!1})}}});function Pe(e,t,n=()=>!0){const r=[];t.lastIndex=0;let s;for(;s=t.exec(e);)n(e,s)&&r.push(s);return r}function Ae(e,t){return!["#","@"].includes(e.charAt(t.index))&&!["#","@"].includes(e.charAt(t.index-1))}function Oe(e){const t=new RegExp("(?:"+[`[!?.,:;'"]`,"(?:&|&)(?:lt|gt|quot|apos|raquo|laquo|rsaquo|lsaquo);)+$"].join("|"),"g");return e.replace(t,"")}function De(e,t){const n=e.slice(0,t+1).search(/\S+\s*$/),r=e.slice(t).search(/\s/);if(r<0){const s=e.slice(n);return{text:s,from:n,to:n+s.length}}return{text:e.slice(n,r+t),from:n,to:r+t}}function C(e,t,n,r){const s=De(e,t);if(r.lastIndex=0,!r.test(s.text))return s;const i=n==="left"?s.from-1:s.to+1;return i<=0||i>=e.length||i===t?s:C(e,i,n,r)}function Be(e,t,n,r){const s=Math.max(e.from-1,0),i=Math.min(e.to+1,t.content.size),o=l.getMarksBetween(s,i,t);for(const a of o)a.mark.type===r&&n.removeMark(a.from,a.to,r)}const R=E.getPhoneNumberRegex(1,15);function L(e,t,n,r,s,i){if(!e)return;let o=n-t-1;o=o<0?0:o;const a=r-t,d=C(e,o,"left",R),m=C(e,a,"right",R),h=e.slice(d.from,m.to);Pe(h,E.linkRegex,Ae).forEach(T=>{const g=Oe(T[0]),y=t+d.from+T.index+1,O=y+g.length;s.addMark(y,O,i.create())})}function qe(e){let t=!1;return new p.Plugin({key:new p.PluginKey("autolink"),appendTransaction:(n,r,s)=>{const i=n.some(h=>h.docChanged)&&!r.doc.eq(s.doc);if(t&&!i)return;const{tr:o}=s,{textContent:a}=s.doc;t||L(a,0,0,a.length,o,e.type),t=!0;const d=l.combineTransactionSteps(r.doc,[...n]);return l.getChangedRanges(d).forEach(({oldRange:h,newRange:_})=>{Be(_,s.doc,o,e.type),l.findChildrenInRange(s.doc,_,g=>g.isTextblock).forEach(({node:g,pos:y})=>{L(g.textContent,y,h.from,_.to,o,e.type)})}),o}})}const je={class:"d-link d-c-text d-d-inline-block d-wb-break-all",rel:"noopener noreferrer nofollow"},Me=l.Mark.create({name:"CustomLink",renderHTML({HTMLAttributes:e}){return["a",l.mergeAttributes(this.options.HTMLAttributes,e,je)]},renderText({node:e}){return e.attrs.text},addProseMirrorPlugins(){return[qe({type:this.type})]}}),He=re.extend({name:"ConfigurableImage",addAttributes(){return{src:{default:""},alt:{default:void 0},title:{default:void 0},width:{default:void 0},height:{default:void 0},style:{default:void 0}}}}).configure({inline:!0,allowBase64:!0}),Ne=$.extend({parseHTML(){return[{tag:"div"}]},renderHTML({HTMLAttributes:e}){return["div",l.mergeAttributes(this.options.HTMLAttributes,e),0]}}),Ve={name:"MentionComponent",components:{NodeViewWrapper:c.NodeViewWrapper,DtLink:A.default},props:c.nodeViewProps,computed:{text(){return"@"+this.$props.node.attrs.name}}};var Fe=function(){var t=this,n=t._self._c;return n("node-view-wrapper",{staticClass:"d-d-inline-block"},[n("dt-link",{attrs:{kind:"mention"}},[t._v(" "+t._s(t.text)+" ")])],1)},Ke=[],We=u.n(Ve,Fe,Ke);const Ue=We.exports,ze=S.extend({addNodeView(){return c.VueNodeViewRenderer(Ue)},parseHTML(){return[{tag:"mention-component"}]},addAttributes(){return{name:{default:""},avatarSrc:{default:""},id:{default:""}}},renderText({node:e}){return`@${e.attrs.id}`},renderHTML({HTMLAttributes:e}){return["mention-component",l.mergeAttributes(this.options.HTMLAttributes,e)]}}).configure({suggestion:{char:"@",pluginKey:new p.PluginKey("mentionSuggestion")}}),Xe={name:"ChannelComponent",components:{NodeViewWrapper:c.NodeViewWrapper,DtLink:A.default},props:c.nodeViewProps,computed:{text(){return"#"+this.$props.node.attrs.name}}};var Je=function(){var t=this,n=t._self._c;return n("node-view-wrapper",{staticClass:"d-d-inline-block"},[n("dt-link",{attrs:{kind:"mention"}},[t._v(" "+t._s(t.text)+" ")])],1)},Ye=[],Ge=u.n(Xe,Je,Ye);const Qe=Ge.exports,Ze=S.extend({name:"channel",addNodeView(){return c.VueNodeViewRenderer(Qe)},parseHTML(){return[{tag:"channel-component"}]},addAttributes(){return{name:{default:""},id:{default:""},locked:{default:!1}}},renderText({node:e}){return`#${e.attrs.id}`},renderHTML({HTMLAttributes:e}){return["channel-component",l.mergeAttributes(this.options.HTMLAttributes,e)]}}).configure({suggestion:{char:"#",pluginKey:new p.PluginKey("channelSuggestion")}}),et={name:"SlashCommandsComponent",components:{NodeViewWrapper:c.NodeViewWrapper},props:{...c.nodeViewProps},emits:["selected-command"],computed:{text(){return"/"+this.$props.node.attrs.command}},created(){var n,r,s;const e=this.$props.node.attrs.command;this.$emit("selected-command",e);const t=(s=(r=(n=this.editor)==null?void 0:n.storage)==null?void 0:r["slash-commands"])==null?void 0:s.onSelectedCommand;t&&typeof t=="function"&&t(e)}};var tt=function(){var t=this,n=t._self._c;return n("node-view-wrapper",{staticClass:"d-d-inline-block"},[t._v(" "+t._s(t.text)+" ")])},nt=[],rt=u.n(et,tt,nt);const st=rt.exports,it=(e,t)=>[...e.matchAll(t)].map(r=>{let s=r[2];return s.endsWith(" ")||(s+=" "),{index:r.index,text:s,match:r}}),ot=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 c.VueNodeViewRenderer(st)},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",l.mergeAttributes(this.options.HTMLAttributes,e)]},addInputRules(){var n;const e=(n=this.options.suggestion)==null?void 0:n.items({query:""}).map(r=>r.command),t=new RegExp(`^((?:\\/)(${e.join("|")})) $`);return[l.nodeInputRule({find:t,type:this.type,getAttributes(r){return{command:r[2]}}})]},addPasteRules(){var n;const e=(n=this.options.suggestion)==null?void 0:n.items({query:""}).map(r=>r.command),t=new RegExp(`^((?:\\/)(${e.join("|")})) ?$`,"g");return[l.nodePasteRule({find:r=>it(r,t),type:this.type,getAttributes(r){return{command:r[0].trim()}}})]}}).configure({suggestion:{char:"/",pluginKey:new p.PluginKey("slashCommandSuggestion")}}),at={name:"MentionSuggestion",components:{DtAvatar:se.default,DtStack:b.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}}};var ct=function(){var t=this,n=t._self._c;return n("dt-stack",{staticClass:"d-mention-suggestion__container",attrs:{direction:"row",gap:"400"}},[n("dt-avatar",{attrs:{"full-name":t.name,"image-src":t.avatarSrc,"image-alt":t.name,"show-presence":t.showDetails,presence:t.presence,size:"sm"}}),n("dt-stack",{staticClass:"d-mention-suggestion__details-container",attrs:{gap:"100"}},[n("span",{staticClass:"d-mention-suggestion__name"},[t._v(" "+t._s(t.name)+" ")]),t.showDetails?n("dt-stack",{staticClass:"d-label--sm-plain",attrs:{direction:"row",gap:"300"}},[t.presenceText?n("span",{staticClass:"d-mention-suggestion__presence",class:[t.presenceFontColorClass]},[t._v(" "+t._s(t.presenceText)+" ")]):t._e(),t.status&&t.presenceText?n("div",{staticClass:"d-mention-suggestion__divider"},[t._v(" • ")]):t._e(),t.status?n("div",{staticClass:"d-mention-suggestion__status"},[t._v(" "+t._s(t.status)+" ")]):t._e()]):t._e()],1)],1)},lt=[],dt=u.n(at,ct,lt);const ut=dt.exports,mt={allowSpaces:!0,render:()=>{let e,t,n=!1;return{onStart:r=>{e=new c.VueRenderer(x,{parent:void 0,propsData:{itemComponent:ut,itemType:"mention",...r},editor:r.editor}),r.clientRect&&(t=v("body",{getReferenceClientRect:r.clientRect,appendTo:()=>document.body,content:e.element,showOnCreate:!1,onShow:()=>{n=!0},onHidden:()=>{n=!1},interactive:!0,trigger:"manual",placement:"top-start",zIndex:650,plugins:[k]}),r.items.length>0&&(t==null||t[0].show()))},onUpdate(r){e==null||e.updateProps(r),r.items.length>0?t==null||t[0].show():t==null||t[0].hide(),r.clientRect&&(t==null||t[0].setProps({getReferenceClientRect:r.clientRect}))},onKeyDown(r){var s;if(n)return(s=e==null?void 0:e.ref)==null?void 0:s.onKeyDown(r)},onExit(){t==null||t[0].destroy(),t=null,e==null||e.destroy(),e=null}}}},ht={name:"ChannelSuggestion",components:{DtStack:b.default,DtIconHash:ie,DtIconLock:oe},props:{item:{type:Object,required:!0}},computed:{name(){return this.item.name}}};var ft=function(){var t=this,n=t._self._c;return n("dt-stack",{attrs:{direction:"row",gap:"400"}},[t.item.locked?n("dt-icon-lock",{attrs:{size:"300"}}):n("dt-icon-hash",{attrs:{size:"300"}}),n("span",[t._v(t._s(t.name))])],1)},pt=[],gt=u.n(ht,ft,pt);const _t=gt.exports,yt={allowSpaces:!0,render:()=>{let e,t,n=!1;return{onStart:r=>{e=new c.VueRenderer(x,{parent:void 0,propsData:{itemComponent:_t,itemType:"channel",...r},editor:r.editor}),r.clientRect&&(t=v("body",{getReferenceClientRect:r.clientRect,appendTo:()=>document.body,content:e.element,showOnCreate:!1,onShow:()=>{n=!0},onHidden:()=>{n=!1},interactive:!0,trigger:"manual",placement:"top-start",zIndex:650,plugins:[k]}),r.items.length>0&&(t==null||t[0].show()))},onUpdate(r){e==null||e.updateProps(r),r.items.length>0?t==null||t[0].show():t==null||t[0].hide(),r.clientRect&&(t==null||t[0].setProps({getReferenceClientRect:r.clientRect}))},onKeyDown(r){var s;if(n)return(s=e==null?void 0:e.ref)==null?void 0:s.onKeyDown(r)},onExit(){t==null||t[0].destroy(),t=null,e==null||e.destroy(),e=null}}}},wt={name:"SlashCommandSuggestion",props:{item:{type:Object,required:!0}},computed:{command(){return this.item.command},description(){return this.item.description},parametersExample(){return this.item.parametersExample}}};var bt=function(){var t=this,n=t._self._c;return n("div",[n("div",{staticClass:"d-body--md-compact"},[n("span",[t._v("/"+t._s(t.command))]),t.parametersExample?n("span",[t._v(" "+t._s(t.parametersExample))]):t._e()]),n("div",{staticClass:"d-body--sm d-fc-tertiary"},[t._v(" "+t._s(t.description)+" ")])])},vt=[],xt=u.n(wt,bt,vt);const kt=xt.exports,Tt={allowSpaces:!0,startOfLine:!0,render:()=>{let e,t,n=!1;return{onStart:r=>{e=new c.VueRenderer(x,{parent:void 0,propsData:{itemComponent:kt,itemType:"slash-command",...r},editor:r.editor}),r.clientRect&&(t=v("body",{getReferenceClientRect:r.clientRect,appendTo:()=>document.body,content:e.element,showOnCreate:!1,onShow:()=>{n=!0},onHidden:()=>{n=!1},interactive:!0,trigger:"manual",placement:"top-start",zIndex:650,plugins:[k]}),r.items.length>0&&(t==null||t[0].show()))},onUpdate(r){e==null||e.updateProps(r),r.items.length>0?t==null||t[0].show():t==null||t[0].hide(),r.clientRect&&(t==null||t[0].setProps({getReferenceClientRect:r.clientRect}))},onKeyDown(r){var s;if(n)return(s=e==null?void 0:e.ref)==null?void 0:s.onKeyDown(r)},onExit(){t==null||t[0].destroy(),t=null,e==null||e.destroy(),e=null}}}},Ct={name:"DtRichTextEditor",components:{EditorContent:c.EditorContent,BubbleMenu:c.BubbleMenu,DtButton:le.default,DtStack:b.default},props:{value:{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"?w.RICH_TEXT_EDITOR_AUTOFOCUS_TYPES.includes(e):!0}},outputFormat:{type:String,default:"html",validator(e){return w.RICH_TEXT_EDITOR_OUTPUT_FORMATS.includes(e)}},placeholder:{type:String,default:""},link:{type:[Boolean,Object],default:!1},customLink:{type:[Boolean,Object],default:!1},mentionSuggestion:{type:Object,default:null},channelSuggestion:{type:Object,default:null},slashCommandSuggestion:{type:Object,default:null},allowBlockquote:{type:Boolean,default:!0},allowBold:{type:Boolean,default:!0},allowBulletList:{type:Boolean,default:!0},allowItalic:{type:Boolean,default:!0},allowStrike:{type:Boolean,default:!0},allowUnderline:{type:Boolean,default:!0},allowCode:{type:Boolean,default:!0},allowCodeblock:{type:Boolean,default:!0},allowInlineImages:{type:Boolean,default:!1},allowFontColor:{type:Boolean,default:!1},allowFontFamily:{type:Boolean,default:!1},additionalExtensions:{type:Array,default:()=>[]},hideLinkBubbleMenu:{type:Boolean,default:!1},useDivTags:{type:Boolean,default:!1}},emits:["input","json-input","html-input","text-input","update:value","blur","focus","enter","edit-link","selected","selected-command"],data(){return{editor:null,tippyOptions:{appendTo:()=>{var e;return(e=this.$refs.editor.$el.getRootNode())==null?void 0:e.querySelector("body")},placement:"top-start"},i18n:new ce.DialtoneLocalization}},computed:{editorListeners(){return{...this.$listeners,input:()=>{},focus:()=>{},blur:()=>{}}},extensions(){const e=[j,J,G,H];e.push(this.useDivTags?Ne:$),this.allowBold&&e.push(N),this.allowBlockquote&&e.push(D),this.allowBulletList&&(e.push(V),e.push(W.extend({renderText({node:r}){return r.textContent}})),e.push(U)),this.allowItalic&&e.push(F),this.allowStrike&&e.push(z),this.allowUnderline&&e.push(X),this.placeholder&&e.push(M.configure({placeholder:this.placeholder}));const t=this,n=l.Extension.create({addKeyboardShortcuts(){return{"Shift-Enter":({editor:r})=>t.allowLineBreaks?!1:(r.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>t.allowBulletList&&s.splitListItem("listItem"),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),!0),Enter:()=>t.allowLineBreaks?!1:(t.$emit("enter"),!0)}}});if(e.push(n),this.link&&e.push(K.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:w.RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS})),this.customLink&&e.push(this.getExtension(Me,this.customLink)),this.mentionSuggestion){const r={...this.mentionSuggestion,...mt};e.push(ze.configure({suggestion:r}))}if(this.channelSuggestion){const r={...this.channelSuggestion,...yt};e.push(Ze.configure({suggestion:r}))}if(this.slashCommandSuggestion){const r={...this.slashCommandSuggestion,...Tt};e.push(ot.configure({suggestion:r,onSelectedCommand:s=>{this.$emit("selected-command",s)}}))}return e.push(Ie),e.push(Y.configure({types:["paragraph"]})),this.allowCode&&e.push(q),this.allowCodeblock&&e.push(B.extend({renderText({node:r}){return`\`\`\`
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const c=require("../../node_modules/@tiptap/vue-2.cjs"),d=require("@tiptap/core"),M=require("@tiptap/extension-blockquote"),O=require("@tiptap/extension-code-block"),A=require("@tiptap/extension-code"),D=require("@tiptap/extension-document"),$=require("@tiptap/extension-paragraph"),j=require("@tiptap/extension-placeholder"),q=require("@tiptap/extension-hard-break"),H=require("@tiptap/extension-bold"),V=require("@tiptap/extension-bullet-list"),F=require("@tiptap/extension-italic"),K=require("@tiptap/extension-link"),W=require("@tiptap/extension-list-item"),U=require("@tiptap/extension-ordered-list"),z=require("@tiptap/extension-strike"),X=require("@tiptap/extension-underline"),J=require("@tiptap/extension-text"),Y=require("@tiptap/extension-text-align"),G=require("@tiptap/extension-history"),Q=require("@tiptap/extension-text-style"),Z=require("@tiptap/extension-color"),ee=require("@tiptap/extension-font-family"),f=require("@tiptap/pm/state"),te=require("@tiptap/suggestion"),I=require("regex-combined-emojis"),u=require("../../_plugin-vue2_normalizer-e_CkxkSV.cjs"),N=require("../emoji/emoji.cjs"),p=require("../../common/emoji/index.cjs"),ne=require("../list-item/list-item.cjs"),_=require("../stack/stack.cjs"),b=require("tippy.js"),E=require("../../common/utils/index.cjs"),re=require("@tiptap/extension-image"),S=require("@tiptap/extension-mention"),P=require("../link/link.cjs"),se=require("@dialpad/dialtone-icons/vue2"),y=require("./rich-text-editor-constants.cjs"),oe=require("../avatar/avatar.cjs"),ie=require("@dialpad/dialtone-icons/vue2/hash"),ae=require("@dialpad/dialtone-icons/vue2/lock"),ce=require("deep-equal"),de=require("../../localization/index.cjs"),le=require("../button/button.cjs"),ue={name:"EmojiComponent",components:{NodeViewWrapper:c.NodeViewWrapper,DtEmoji:N.default},props:c.nodeViewProps};var me=function(){var t=this,n=t._self._c;return n("node-view-wrapper",{staticClass:"d-d-inline-block d-va-bottom d-lh0"},[n("dt-emoji",{attrs:{size:"500",code:t.node.attrs.code}})],1)},he=[],pe=u.n(ue,me,he);const fe=pe.exports,ge={name:"SuggestionList",components:{DtListItem:ne.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});break;case"channel":this.command({name:t.name,id:t.id,locked:t.locked});break;case"slash-command":this.command({command:t.command});break}}}};var _e=function(){var t=this,n=t._self._c;return n("div",{staticClass:"d-popover__dialog d-suggestion-list__container"},[n("ul",{directives:[{name:"show",rawName:"v-show",value:t.items.length,expression:"items.length"}],ref:"suggestionList",staticClass:"d-suggestion-list"},t._l(t.items,function(r,s){return n("dt-list-item",{key:r.id,class:["d-suggestion-list__item",{"d-list-item--highlighted":s===t.selectedIndex}],attrs:{"navigation-type":"arrow-keys"},on:{click:function(o){return t.selectItem(s)},keydown:function(o){return o.preventDefault(),t.onKeyDown.apply(null,arguments)}}},[n(t.itemComponent,{tag:"component",attrs:{item:r}})],1)}),1)])},ke=[],we=u.n(ge,_e,ke);const C=we.exports,ye={name:"EmojiSuggestion",components:{DtEmoji:N.default,DtStack:_.default},props:{item:{type:Object,required:!0}}};var be=function(){var t=this,n=t._self._c;return n("dt-stack",{attrs:{direction:"row",gap:"400"}},[n("dt-emoji",{attrs:{size:"200",code:t.item.code}}),t._v(" "+t._s(t.item.code)+" ")],1)},Ce=[],ve=u.n(ye,be,Ce);const xe=ve.exports,v={name:"hideOnEsc",defaultValue:!0,fn({hide:e}){function t(n){n.keyCode===27&&e()}return{onShow(){document.addEventListener("keydown",t)},onHide(){document.removeEventListener("keydown",t)}}}},Te=20,Ee=(e,t,n)=>{var a,l;const r=(a=e.shortname)==null?void 0:a.replaceAll(":",""),s=(l=t.shortname)==null?void 0:l.replaceAll(":",""),o=r.startsWith(n),i=s.startsWith(n);return o&&!i?-1:!o&&i?1:r.localeCompare(s)},Se={items:({query:e})=>{if(e.length<2)return[];const t=Object.values(p.getEmojiData());return e=e.toLowerCase(),t.filter(r=>{var s;return[r.name,(s=r.shortname)==null?void 0:s.replaceAll(":",""),...r.keywords||[]].some(o=>o&&o.startsWith(e))}).splice(0,Te).sort((r,s)=>Ee(r,s,e)).map(r=>({code:r.shortname}))},command:({editor:e,range:t,props:n})=>{var o,i;const r=e.view.state.selection.$to.nodeAfter;((o=r==null?void 0:r.text)==null?void 0:o.startsWith(" "))&&(t.to+=1),e.chain().focus().insertContentAt(t,[{type:"emoji",attrs:n}]).run(),(i=window.getSelection())==null||i.collapseToEnd()},render:()=>{let e,t,n=!1;return{onStart:r=>{e=new c.VueRenderer(C,{parent:void 0,propsData:{itemComponent:xe,itemType:"emoji",...r},editor:r.editor}),r.clientRect&&(t=b("body",{getReferenceClientRect:r.clientRect,appendTo:()=>document.body,content:e.element,showOnCreate:!1,onShow:()=>{n=!0},onHidden:()=>{n=!1},interactive:!0,trigger:"manual",placement:"top-start",zIndex:650,plugins:[v]}),r.items.length>0&&(t==null||t[0].show()))},onUpdate(r){e==null||e.updateProps(r),r.items.length>0?t==null||t[0].show():t==null||t[0].hide(),t==null||t[0].setProps({getReferenceClientRect:r.clientRect})},onKeyDown(r){var s;if(n)return(s=e==null?void 0:e.ref)==null?void 0:s.onKeyDown(r)},onExit(){t==null||t[0].destroy(),t=null,e==null||e.destroy(),e=null}}}},Le=/(:\w+:)$/,Re=new RegExp(I.emojiPattern+"$"),$e=e=>{if(e&&p.codeToEmojiData(e[0]))return{text:e[2]||e[0]}},Ie=e=>[...e.matchAll(p.emojiShortCodeRegex)].filter(n=>p.codeToEmojiData(n[0])).map(n=>({index:n.index,text:n[0],match:n})),Ne=d.Node.create({name:"emoji",addOptions(){return{HTMLAttributes:{}}},group:"inline",inline:!0,selectable:!1,atom:!0,addNodeView(){return c.VueNodeViewRenderer(fe)},addAttributes(){return{code:{default:null},image:{default:null},name:{default:null}}},parseHTML(){return[{tag:"emoji-component"}]},renderText({node:e}){return p.stringToUnicode(p.codeToEmojiData(e.attrs.code).unicode_output)},renderHTML({HTMLAttributes:e}){return["emoji-component",d.mergeAttributes(this.options.HTMLAttributes,e)]},addInputRules(){return[new d.InputRule({find:e=>{const t=e.match(Le)||e.match(Re);if(t)return $e(t)},handler:({state:e,range:t,match:n})=>{const{tr:r}=e,s=t.from,o=t.to;r.replaceWith(s,o,this.type.create({code:n[0]}))}})]},addPasteRules(){return[d.nodePasteRule({find:Ie,type:this.type,getAttributes(e){return{code:e[0],image:e[1],name:e[2]}}}),d.nodePasteRule({find:p.emojiRegex,type:this.type,getAttributes(e){return{code:e[0],image:e[1],name:e[2]}}})]},addProseMirrorPlugins(){return[te({char:":",pluginKey:new f.PluginKey("emoji"),editor:this.editor,...this.options.suggestion,...Se})]},addKeyboardShortcuts(){return{Backspace:()=>this.editor.commands.command(({tr:e,state:t})=>{let n=!1;const{selection:r}=t,{empty:s,anchor:o}=r;return s?(t.doc.nodesBetween(o-1,o,(i,a)=>{if(i.type.name===this.name)return n=!0,e.insertText("",a,a+i.nodeSize),!1}),n):!1})}}});function Pe(e,t,n=()=>!0){const r=[];t.lastIndex=0;let s;for(;s=t.exec(e);)n(e,s)&&r.push(s);return r}function Be(e,t){return!["#","@"].includes(e.charAt(t.index))&&!["#","@"].includes(e.charAt(t.index-1))}function Me(e){const t=new RegExp("(?:"+[`[!?.,:;'"]`,"(?:&|&)(?:lt|gt|quot|apos|raquo|laquo|rsaquo|lsaquo);)+$"].join("|"),"g");return e.replace(t,"")}function Oe(e,t){const n=e.slice(0,t+1).search(/\S+\s*$/),r=e.slice(t).search(/\s/);if(r<0){const s=e.slice(n);return{text:s,from:n,to:n+s.length}}return{text:e.slice(n,r+t),from:n,to:r+t}}function T(e,t,n,r){const s=Oe(e,t);if(r.lastIndex=0,!r.test(s.text))return s;const o=n==="left"?s.from-1:s.to+1;return o<=0||o>=e.length||o===t?s:T(e,o,n,r)}function Ae(e,t,n,r){const s=Math.max(e.from-1,0),o=Math.min(e.to+1,t.content.size),i=d.getMarksBetween(s,o,t);for(const a of i)a.mark.type===r&&n.removeMark(a.from,a.to,r)}const L=E.getPhoneNumberRegex(1,15);function R(e,t,n,r,s,o){if(!e)return;let i=n-t-1;i=i<0?0:i;const a=r-t,l=T(e,i,"left",L),m=T(e,a,"right",L),h=e.slice(l.from,m.to);Pe(h,E.linkRegex,Be).forEach(x=>{const g=Me(x[0]),w=t+l.from+x.index+1,B=w+g.length;s.addMark(w,B,o.create())})}function De(e){let t=!1;return new f.Plugin({key:new f.PluginKey("autolink"),appendTransaction:(n,r,s)=>{const o=n.some(h=>h.docChanged)&&!r.doc.eq(s.doc);if(t&&!o)return;const{tr:i}=s,{textContent:a}=s.doc;t||R(a,0,0,a.length,i,e.type),t=!0;const l=d.combineTransactionSteps(r.doc,[...n]);return d.getChangedRanges(l).forEach(({oldRange:h,newRange:k})=>{Ae(k,s.doc,i,e.type),d.findChildrenInRange(s.doc,k,g=>g.isTextblock).forEach(({node:g,pos:w})=>{R(g.textContent,w,h.from,k.to,i,e.type)})}),i}})}const je={class:"d-link d-c-text d-d-inline-block d-wb-break-all",rel:"noopener noreferrer nofollow"},qe=d.Mark.create({name:"CustomLink",renderHTML({HTMLAttributes:e}){return["a",d.mergeAttributes(this.options.HTMLAttributes,e,je)]},renderText({node:e}){return e.attrs.text},addProseMirrorPlugins(){return[De({type:this.type})]}}),He=re.extend({name:"ConfigurableImage",addAttributes(){return{src:{default:""},alt:{default:void 0},title:{default:void 0},width:{default:void 0},height:{default:void 0},style:{default:void 0}}}}).configure({inline:!0,allowBase64:!0}),Ve=$.extend({parseHTML(){return[{tag:"div"}]},renderHTML({HTMLAttributes:e}){return["div",d.mergeAttributes(this.options.HTMLAttributes,e),0]}}),Fe={name:"MentionComponent",components:{NodeViewWrapper:c.NodeViewWrapper,DtLink:P.default},props:c.nodeViewProps,computed:{text(){return"@"+this.$props.node.attrs.name}}};var Ke=function(){var t=this,n=t._self._c;return n("node-view-wrapper",{staticClass:"d-d-inline-block"},[n("dt-link",{attrs:{kind:"mention"}},[t._v(" "+t._s(t.text)+" ")])],1)},We=[],Ue=u.n(Fe,Ke,We);const ze=Ue.exports,Xe=S.extend({addNodeView(){return c.VueNodeViewRenderer(ze)},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",d.mergeAttributes(this.options.HTMLAttributes,e)]}}).configure({suggestion:{char:"@",pluginKey:new f.PluginKey("mentionSuggestion")}}),Je={name:"ChannelComponent",components:{NodeViewWrapper:c.NodeViewWrapper,DtLink:P.default,DtIconLock:se.DtIconLock,DtStack:_.default},props:c.nodeViewProps,computed:{text(){return this.$props.node.attrs.locked?this.$props.node.attrs.name:"#"+this.$props.node.attrs.name}}};var Ye=function(){var t=this,n=t._self._c;return n("node-view-wrapper",{staticClass:"d-d-inline-block"},[n("dt-link",{attrs:{kind:"mention"}},[n("dt-stack",{attrs:{direction:"row",gap:"0"}},[t.$props.node.attrs.locked?n("dt-icon-lock",{attrs:{size:"200"}}):t._e(),n("span",[t._v(t._s(t.text))])],1)],1)],1)},Ge=[],Qe=u.n(Je,Ye,Ge);const Ze=Qe.exports,et=S.extend({name:"channel",addNodeView(){return c.VueNodeViewRenderer(Ze)},parseHTML(){return[{tag:"channel-component"}]},addAttributes(){return{name:{default:""},id:{default:""},locked:{default:!1}}},renderText({node:e}){return`#${e.attrs.id}`},renderHTML({HTMLAttributes:e}){return["channel-component",d.mergeAttributes(this.options.HTMLAttributes,e)]}}).configure({suggestion:{char:"#",pluginKey:new f.PluginKey("channelSuggestion")}}),tt={name:"SlashCommandsComponent",components:{NodeViewWrapper:c.NodeViewWrapper},props:{...c.nodeViewProps},emits:["selected-command"],computed:{text(){return"/"+this.$props.node.attrs.command}},created(){var n,r,s;const e=this.$props.node.attrs.command;this.$emit("selected-command",e);const t=(s=(r=(n=this.editor)==null?void 0:n.storage)==null?void 0:r["slash-commands"])==null?void 0:s.onSelectedCommand;t&&typeof t=="function"&&t(e)}};var nt=function(){var t=this,n=t._self._c;return n("node-view-wrapper",{staticClass:"d-d-inline-block"},[t._v(" "+t._s(t.text)+" ")])},rt=[],st=u.n(tt,nt,rt);const ot=st.exports,it=(e,t)=>[...e.matchAll(t)].map(r=>{let s=r[2];return s.endsWith(" ")||(s+=" "),{index:r.index,text:s,match:r}}),at=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 c.VueNodeViewRenderer(ot)},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",d.mergeAttributes(this.options.HTMLAttributes,e)]},addInputRules(){var n;const e=(n=this.options.suggestion)==null?void 0:n.items({query:""}).map(r=>r.command),t=new RegExp(`^((?:\\/)(${e.join("|")})) $`);return[d.nodeInputRule({find:t,type:this.type,getAttributes(r){return{command:r[2]}}})]},addPasteRules(){var n;const e=(n=this.options.suggestion)==null?void 0:n.items({query:""}).map(r=>r.command),t=new RegExp(`^((?:\\/)(${e.join("|")})) ?$`,"g");return[d.nodePasteRule({find:r=>it(r,t),type:this.type,getAttributes(r){return{command:r[0].trim()}}})]}}).configure({suggestion:{char:"/",pluginKey:new f.PluginKey("slashCommandSuggestion")}}),ct={name:"MentionSuggestion",components:{DtAvatar:oe.default,DtStack:_.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}}};var dt=function(){var t=this,n=t._self._c;return n("dt-stack",{staticClass:"d-mention-suggestion__container",attrs:{direction:"row",gap:"400"}},[n("dt-avatar",{attrs:{"full-name":t.name,"image-src":t.avatarSrc,"image-alt":t.name,"show-presence":t.showDetails,presence:t.presence,size:"sm"}}),n("dt-stack",{staticClass:"d-mention-suggestion__details-container",attrs:{gap:"100"}},[n("span",{staticClass:"d-mention-suggestion__name"},[t._v(" "+t._s(t.name)+" ")]),t.showDetails?n("dt-stack",{staticClass:"d-label--sm-plain",attrs:{direction:"row",gap:"300"}},[t.presenceText?n("span",{staticClass:"d-mention-suggestion__presence",class:[t.presenceFontColorClass]},[t._v(" "+t._s(t.presenceText)+" ")]):t._e(),t.status&&t.presenceText?n("div",{staticClass:"d-mention-suggestion__divider"},[t._v(" • ")]):t._e(),t.status?n("div",{staticClass:"d-mention-suggestion__status"},[t._v(" "+t._s(t.status)+" ")]):t._e()]):t._e()],1)],1)},lt=[],ut=u.n(ct,dt,lt);const mt=ut.exports,ht={allowSpaces:!0,render:()=>{let e,t,n=!1;return{onStart:r=>{e=new c.VueRenderer(C,{parent:void 0,propsData:{itemComponent:mt,itemType:"mention",...r},editor:r.editor}),r.clientRect&&(t=b("body",{getReferenceClientRect:r.clientRect,appendTo:()=>document.body,content:e.element,showOnCreate:!1,onShow:()=>{n=!0},onHidden:()=>{n=!1},interactive:!0,trigger:"manual",placement:"top-start",zIndex:650,plugins:[v]}),r.items.length>0&&(t==null||t[0].show()))},onUpdate(r){e==null||e.updateProps(r),r.items.length>0?t==null||t[0].show():t==null||t[0].hide(),r.clientRect&&(t==null||t[0].setProps({getReferenceClientRect:r.clientRect}))},onKeyDown(r){var s;if(n)return(s=e==null?void 0:e.ref)==null?void 0:s.onKeyDown(r)},onExit(){t==null||t[0].destroy(),t=null,e==null||e.destroy(),e=null}}}},pt={name:"ChannelSuggestion",components:{DtStack:_.default,DtIconHash:ie,DtIconLock:ae},props:{item:{type:Object,required:!0}},computed:{name(){return this.item.name}}};var ft=function(){var t=this,n=t._self._c;return n("dt-stack",{attrs:{direction:"row",gap:"400"}},[t.item.locked?n("dt-icon-lock",{attrs:{size:"300"}}):n("dt-icon-hash",{attrs:{size:"300"}}),n("span",[t._v(t._s(t.name))])],1)},gt=[],_t=u.n(pt,ft,gt);const kt=_t.exports,wt={allowSpaces:!0,render:()=>{let e,t,n=!1;return{onStart:r=>{e=new c.VueRenderer(C,{parent:void 0,propsData:{itemComponent:kt,itemType:"channel",...r},editor:r.editor}),r.clientRect&&(t=b("body",{getReferenceClientRect:r.clientRect,appendTo:()=>document.body,content:e.element,showOnCreate:!1,onShow:()=>{n=!0},onHidden:()=>{n=!1},interactive:!0,trigger:"manual",placement:"top-start",zIndex:650,plugins:[v]}),r.items.length>0&&(t==null||t[0].show()))},onUpdate(r){e==null||e.updateProps(r),r.items.length>0?t==null||t[0].show():t==null||t[0].hide(),r.clientRect&&(t==null||t[0].setProps({getReferenceClientRect:r.clientRect}))},onKeyDown(r){var s;if(n)return(s=e==null?void 0:e.ref)==null?void 0:s.onKeyDown(r)},onExit(){t==null||t[0].destroy(),t=null,e==null||e.destroy(),e=null}}}},yt={name:"SlashCommandSuggestion",props:{item:{type:Object,required:!0}},computed:{command(){return this.item.command},description(){return this.item.description},parametersExample(){return this.item.parametersExample}}};var bt=function(){var t=this,n=t._self._c;return n("div",[n("div",{staticClass:"d-body--md-compact"},[n("span",[t._v("/"+t._s(t.command))]),t.parametersExample?n("span",[t._v(" "+t._s(t.parametersExample))]):t._e()]),n("div",{staticClass:"d-body--sm d-fc-tertiary"},[t._v(" "+t._s(t.description)+" ")])])},Ct=[],vt=u.n(yt,bt,Ct);const xt=vt.exports,Tt={allowSpaces:!0,startOfLine:!0,render:()=>{let e,t,n=!1;return{onStart:r=>{e=new c.VueRenderer(C,{parent:void 0,propsData:{itemComponent:xt,itemType:"slash-command",...r},editor:r.editor}),r.clientRect&&(t=b("body",{getReferenceClientRect:r.clientRect,appendTo:()=>document.body,content:e.element,showOnCreate:!1,onShow:()=>{n=!0},onHidden:()=>{n=!1},interactive:!0,trigger:"manual",placement:"top-start",zIndex:650,plugins:[v]}),r.items.length>0&&(t==null||t[0].show()))},onUpdate(r){e==null||e.updateProps(r),r.items.length>0?t==null||t[0].show():t==null||t[0].hide(),r.clientRect&&(t==null||t[0].setProps({getReferenceClientRect:r.clientRect}))},onKeyDown(r){var s;if(n)return(s=e==null?void 0:e.ref)==null?void 0:s.onKeyDown(r)},onExit(){t==null||t[0].destroy(),t=null,e==null||e.destroy(),e=null}}}},Et={name:"DtRichTextEditor",components:{EditorContent:c.EditorContent,BubbleMenu:c.BubbleMenu,DtButton:le.default,DtStack:_.default},props:{value:{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"?y.RICH_TEXT_EDITOR_AUTOFOCUS_TYPES.includes(e):!0}},outputFormat:{type:String,default:"html",validator(e){return y.RICH_TEXT_EDITOR_OUTPUT_FORMATS.includes(e)}},placeholder:{type:String,default:""},link:{type:[Boolean,Object],default:!1},customLink:{type:[Boolean,Object],default:!1},mentionSuggestion:{type:Object,default:null},channelSuggestion:{type:Object,default:null},slashCommandSuggestion:{type:Object,default:null},allowBlockquote:{type:Boolean,default:!0},allowBold:{type:Boolean,default:!0},allowBulletList:{type:Boolean,default:!0},allowItalic:{type:Boolean,default:!0},allowStrike:{type:Boolean,default:!0},allowUnderline:{type:Boolean,default:!0},allowCode:{type:Boolean,default:!0},allowCodeblock:{type:Boolean,default:!0},allowInlineImages:{type:Boolean,default:!1},allowFontColor:{type:Boolean,default:!1},allowFontFamily:{type:Boolean,default:!1},additionalExtensions:{type:Array,default:()=>[]},hideLinkBubbleMenu:{type:Boolean,default:!1},useDivTags:{type:Boolean,default:!1}},emits:["input","json-input","html-input","text-input","markdown-input","update:value","blur","focus","enter","edit-link","selected","selected-command"],data(){return{editor:null,tippyOptions:{appendTo:()=>{var e;return(e=this.$refs.editor.$el.getRootNode())==null?void 0:e.querySelector("body")},placement:"top-start"},i18n:new de.DialtoneLocalization,jsonToMarkdownConverter:{convertToMarkdown(e){return this.processNode(e)},processNodeContent(e){return e.content?e.content.map(t=>this.processNode(t)).join(""):""},processNode(e){if(!e)return"";const n={doc:r=>this.processDocNode(r),paragraph:r=>this.processParagraphNode(r),text:r=>this.processTextNode(r),hardBreak:()=>this.processHardBreakNode(),blockquote:r=>this.processBlockquoteNode(r),bulletList:r=>this.processBulletListNode(r),orderedList:r=>this.processOrderedListNode(r),listItem:r=>this.processListItemNode(r),codeBlock:r=>this.processCodeBlockNode(r),mention:r=>this.processMentionNode(r),channel:r=>this.processChannelNode(r),"slash-commands":r=>this.processSlashCommandsNode(r),emoji:r=>this.processEmojiNode(r)}[e.type];return n?n(e):this.processUnknownNode(e)},processDocNode(e){return this.processNodeContent(e)},processParagraphNode(e){const t=this.processNodeContent(e);return t?t+`
|
|
2
|
+
`:`
|
|
3
|
+
`},processTextNode(e){let t=e.text||"";return e.marks&&(t=this.applyMarks(t,e.marks)),t},processHardBreakNode(){return`
|
|
4
|
+
`},processBlockquoteNode(e){return this.processNodeContent(e).split(`
|
|
5
|
+
`).map(n=>n?`> ${n}`:">").join(`
|
|
6
|
+
`)+`
|
|
7
|
+
`},processBulletListNode(e){return this.processNodeContent(e)},processOrderedListNode(e){return e.content?e.content.map((t,n)=>this.processNode(t).replace(/^- /,`${n+1}. `)).join(""):""},processListItemNode(e){const t=this.processNodeContent(e);return t?`- ${t.replace(/\n$/,"")}
|
|
8
|
+
`:""},processCodeBlockNode(e){return`\`\`\`
|
|
9
|
+
${this.processNodeContent(e)}
|
|
10
|
+
\`\`\``},processMentionNode(e){var s,o,i;const t=((s=e.attrs)==null?void 0:s.name)||"",n=((o=e.attrs)==null?void 0:o.id)||"",r=((i=e.attrs)==null?void 0:i.contactKey)||"";return`<!-- @mention: {"id": "${n}", "contactKey": "${r}", "name": "${t}"} -->`},processChannelNode(e){var s,o,i;const t=((s=e.attrs)==null?void 0:s.name)||"",n=((o=e.attrs)==null?void 0:o.id)||"",r=((i=e.attrs)==null?void 0:i.locked.toString())||"";return`<!-- @channel: {"id": "${n}", "name": "${t}", "locked": "${r}"} -->`},processSlashCommandsNode(e){var r,s;const t=((r=e.attrs)==null?void 0:r.command)||"",n=((s=e.attrs)==null?void 0:s.parameters)||"";return`/${t}${n?` ${n}`:""}`},processEmojiNode(e){var t;return((t=e.attrs)==null?void 0:t.code)||""},processUnknownNode(e){return this.processNodeContent(e)},applyMarks(e,t){let n=e;return[...t].sort((s,o)=>{const i={link:0,bold:1,italic:2,strike:3,code:4};return(i[s.type]||5)-(i[o.type]||5)}).forEach(s=>{var o;switch(s.type){case"bold":n=`**${n}**`;break;case"italic":n=`*${n}*`;break;case"strike":n=`~~${n}~~`;break;case"code":n=`\`${n}\``;break;case"link":{const i=((o=s.attrs)==null?void 0:o.href)||"";n=`[${n}](${i})`;break}}}),n}}}},computed:{editorListeners(){return{...this.$listeners,input:()=>{},focus:()=>{},blur:()=>{}}},extensions(){const e=[D,J,G,q];e.push(this.useDivTags?Ve:$),this.allowBold&&e.push(H),this.allowBlockquote&&e.push(M),this.allowBulletList&&(e.push(V),e.push(W.extend({renderText({node:r}){return r.textContent}})),e.push(U)),this.allowItalic&&e.push(F),this.allowStrike&&e.push(z),this.allowUnderline&&e.push(X),this.placeholder&&e.push(j.configure({placeholder:this.placeholder}));const t=this,n=d.Extension.create({addKeyboardShortcuts(){return{"Shift-Enter":({editor:r})=>t.allowLineBreaks?!1:(r.commands.first(({commands:s})=>[()=>s.newlineInCode(),()=>t.allowBulletList&&s.splitListItem("listItem"),()=>s.createParagraphNear(),()=>s.liftEmptyBlock(),()=>s.splitBlock()]),!0),Enter:()=>t.allowLineBreaks?!1:(t.$emit("enter"),!0)}}});if(e.push(n),this.link&&e.push(K.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:y.RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS})),this.customLink&&e.push(this.getExtension(qe,this.customLink)),this.mentionSuggestion){const r={...this.mentionSuggestion,...ht};e.push(Xe.configure({suggestion:r}))}if(this.channelSuggestion){const r={...this.channelSuggestion,...wt};e.push(et.configure({suggestion:r}))}if(this.slashCommandSuggestion){const r={...this.slashCommandSuggestion,...Tt};e.push(at.configure({suggestion:r,onSelectedCommand:s=>{this.$emit("selected-command",s)}}))}return e.push(Ne),e.push(Y.configure({types:["paragraph"]})),this.allowCode&&e.push(A),this.allowCodeblock&&e.push(O.extend({renderText({node:r}){return`\`\`\`
|
|
2
11
|
${r.textContent}
|
|
3
|
-
\`\`\``}}).configure({HTMLAttributes:{class:"d-rich-text-editor__code-block"}})),this.allowInlineImages&&e.push(He),(this.allowFontFamily||this.allowFontColor)&&(e.push(Q),this.allowFontColor&&e.push(Z),this.allowFontFamily&&e.push(ee)),this.additionalExtensions.length&&e.push(...this.additionalExtensions),e},inputAttrs(){const e={"aria-label":this.inputAriaLabel,"aria-multiline":!0,role:"textbox"};return this.editable||(e["aria-readonly"]=!0),e}},watch:{editable(e){this.editor.setEditable(e),this.updateEditorAttributes({"aria-readonly":!e})},inputClass(e){this.updateEditorAttributes({class:e})},inputAriaLabel(e){this.updateEditorAttributes({"aria-label":e})},extensions(){this.destroyEditor(),this.createEditor()},value(e){this.processValue(e)}},created(){this.createEditor()},beforeDestroy(){this.destroyEditor()},mounted(){E.warnIfUnmounted(this.$el,this.$options.name),this.processValue(this.value,!1)},methods:{createEditor(){this.editor=new c.Editor({autofocus:this.autoFocus,content:this.value,editable:this.editable,extensions:this.extensions,parseOptions:{preserveWhitespace:"full"},editorProps:{attributes:{...this.inputAttrs,class:this.inputClass},handleKeyDown:(e,t)=>{if(!this.preventTyping)return!1;const n=["Backspace"];return!this.allowLineBreaks&&!t.shiftKey&&n.push("Enter"),!n.includes(t.key)},handlePaste:(e,t)=>{const n=t.clipboardData||window.clipboardData,r=n.getData("text/plain"),s=n.getData("text/html");return this.processPasteData(e,r,s)},transformPastedHTML(e){return e.replace(/(<\/\w+>)((<br \/>)+)/g,"$2$3$1")}}}),this.addEditorListeners()},bubbleMenuShouldShow({editor:e}){return e.isActive("link")},getSelectedLinkText(e){var a,
|
|
12
|
+
\`\`\``}}).configure({HTMLAttributes:{class:"d-rich-text-editor__code-block"}})),this.allowInlineImages&&e.push(He),(this.allowFontFamily||this.allowFontColor)&&(e.push(Q),this.allowFontColor&&e.push(Z),this.allowFontFamily&&e.push(ee)),this.additionalExtensions.length&&e.push(...this.additionalExtensions),e},inputAttrs(){const e={"aria-label":this.inputAriaLabel,"aria-multiline":!0,role:"textbox"};return this.editable||(e["aria-readonly"]=!0),e}},watch:{editable(e){this.editor.setEditable(e),this.updateEditorAttributes({"aria-readonly":!e})},inputClass(e){this.updateEditorAttributes({class:e})},inputAriaLabel(e){this.updateEditorAttributes({"aria-label":e})},extensions(){this.destroyEditor(),this.createEditor()},value(e){this.processValue(e)}},created(){this.createEditor()},beforeDestroy(){this.destroyEditor()},mounted(){E.warnIfUnmounted(this.$el,this.$options.name),this.processValue(this.value,!1)},methods:{createEditor(){this.editor=new c.Editor({autofocus:this.autoFocus,content:this.value,editable:this.editable,extensions:this.extensions,parseOptions:{preserveWhitespace:"full"},editorProps:{attributes:{...this.inputAttrs,class:this.inputClass},handleKeyDown:(e,t)=>{if(!this.preventTyping)return!1;const n=["Backspace"];return!this.allowLineBreaks&&!t.shiftKey&&n.push("Enter"),!n.includes(t.key)},handlePaste:(e,t)=>{const n=t.clipboardData||window.clipboardData,r=n.getData("text/plain"),s=n.getData("text/html");return this.processPasteData(e,r,s)},transformPastedHTML(e){return e.replace(/(<\/\w+>)((<br \/>)+)/g,"$2$3$1")}}}),this.addEditorListeners()},bubbleMenuShouldShow({editor:e}){return e.isActive("link")},getSelectedLinkText(e){var a,l,m;const{view:t,state:n}=e,{from:r,to:s}=t.state.selection,o=n.doc.textBetween(r,s,""),i=this.editor.state.doc.nodeAt(r);return i&&((m=(l=(a=i.marks)==null?void 0:a.at(0))==null?void 0:l.type)==null?void 0:m.name)==="link"?i.textContent:o},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,n,r;(r=(n=(t=(e=this.editor)==null?void 0:e.chain())==null?void 0:t.focus())==null?void 0:n.unsetLink())==null||r.run()},openLink(){var t,n;(n=(t=this.editor)==null?void 0:t.chain())==null||n.focus();const e=this.editor.getAttributes("link").href;window.open(e,"_blank")},setLink(e,t,n,r=y.RICH_TEXT_EDITOR_SUPPORTED_LINK_PROTOCOLS,s){var a,l,m;if(!e){this.removeLink();return}r.find(h=>h.test(e))||(e=`${s}${e}`),this.editor.chain().focus().extendMarkRange("link").run();const i=(m=(l=(a=this.editor)==null?void 0:a.view)==null?void 0:l.state)==null?void 0:m.selection;this.editor.chain().focus().insertContent(t).setTextSelection({from:i.from,to:i.from+t.length}).setLink({href:e,class:n.class}).run()},processValue(e,t=!0){const n=this.getOutput();if(!(t&&ce(e,n))){if(typeof e=="string"&&this.outputFormat==="text"){const r=new RegExp(`(${I.emojiPattern})`,"g");e=e==null?void 0:e.replace(r,'<emoji-component code="$1"></emoji-component>')}this.editor.commands.setContent(e,!1,{preserveWhitespace:"full"})}},destroyEditor(){this.editor.destroy()},insertPlainTextWithHardBreaks(e,t){const{tr:n}=e.state,{from:r,to:s}=e.state.selection;n.deleteRange(r,s);const o=t.split(/\r?\n/);let i=r;for(let a=0;a<o.length;a++)a>0&&(n.insert(i,e.state.schema.nodes.hardBreak.create()),i++),n.insertText(o[a],i),i+=o[a].length;e.dispatch(n)},shouldPreserveLineBreaks(e,t){return this.pasteRichText?!t&&e&&this.hasBlankLines(e):!!e},processPasteData(e,t,n){if(this.shouldPreserveLineBreaks(t,n))return this.insertPlainTextWithHardBreaks(e,t),!0;if(this.shouldHandlePreformattedHTML(n)){const r=this.extractPreformattedText(n);if(r&&r.includes(`
|
|
4
13
|
`))return this.insertPlainTextWithHardBreaks(e,r),!0}return!1},shouldHandlePreformattedHTML(e){return this.pasteRichText&&e&&this.containsPreformattedContent(e)},containsPreformattedContent(e){const t=document.createElement("div");t.innerHTML=e;const n=t.querySelectorAll("*");for(const r of n)if(this.hasPreWhitespace(r)&&this.hasLineBreaks(r))return!0;return!1},hasPreWhitespace(e){const t=e.getAttribute("style")||"",n=e.style.whiteSpace||"",r=n==="pre"||n==="pre-wrap",s=t.includes("white-space: pre");return r||s},hasLineBreaks(e){return e.textContent&&e.textContent.includes(`
|
|
5
14
|
`)},hasBlankLines(e){return e.includes(`
|
|
6
15
|
|
|
7
16
|
`)||/\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 n of e.childNodes)t+=this.walkAndExtractText(n);return t},triggerInputChangeEvents(){const e=this.getOutput();this.$emit("input",e),this.$emit("update:value",e);const t=this.editor.getJSON();this.$emit("json-input",t);const n=this.editor.getHTML();this.$emit("html-input",n);const r=this.editor.getText({blockSeparator:`
|
|
8
|
-
`});this.$emit("text-input",r)},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)})},getOutput(){switch(this.outputFormat){case"json":return this.editor.getJSON();case"html":return this.editor.getHTML();case"text":default:return this.editor.getText({blockSeparator:`
|
|
9
|
-
`})}},getExtension(e,t){var n;return typeof t=="boolean"?e:(n=e.configure)==null?void 0:n.call(e,t)},updateEditorAttributes(e){this.editor.setOptions({editorProps:{attributes:{...this.inputAttrs,class:this.inputClass,...e}}})},focusEditor(){this.editor.commands.focus()}}};var
|
|
17
|
+
`});this.$emit("text-input",r);const s=this.jsonToMarkdownConverter.convertToMarkdown(t);this.$emit("markdown-input",s)},addEditorListeners(){this.editor.on("create",()=>{this.triggerInputChangeEvents()}),this.editor.on("update",()=>{this.triggerInputChangeEvents()}),this.editor.on("selectionUpdate",({editor:e})=>{this.$emit("selected",this.getSelectedLinkText(e))}),this.editor.on("focus",({event:e})=>{this.$emit("focus",e)}),this.editor.on("blur",({event:e})=>{this.$emit("blur",e)})},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:`
|
|
18
|
+
`})}},getExtension(e,t){var n;return typeof t=="boolean"?e:(n=e.configure)==null?void 0:n.call(e,t)},updateEditorAttributes(e){this.editor.setOptions({editorProps:{attributes:{...this.inputAttrs,class:this.inputClass,...e}}})},focusEditor(){this.editor.commands.focus()}}};var St=function(){var t=this,n=t._self._c;return n("div",[t.editor&&t.link&&!t.hideLinkBubbleMenu?n("bubble-menu",{staticStyle:{visibility:"visible"},attrs:{editor:t.editor,"should-show":t.bubbleMenuShouldShow,"tippy-options":t.tippyOptions}},[n("div",{staticClass:"d-popover__dialog"},[n("dt-stack",{staticClass:"d-rich-text-editor-bubble-menu__button-stack",attrs:{direction:"row",gap:"0"}},[n("dt-button",{attrs:{kind:"muted",importance:"clear"},on:{click:t.editLink}},[t._v(" "+t._s(t.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_EDIT_BUTTON_LABEL"))+" ")]),n("dt-button",{attrs:{kind:"muted",importance:"clear"},on:{click:t.openLink}},[t._v(" "+t._s(t.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_OPEN_LINK_BUTTON_LABEL"))+" ")]),n("dt-button",{attrs:{kind:"danger",importance:"clear"},on:{click:t.removeLink}},[t._v(" "+t._s(t.i18n.$t("DIALTONE_RICH_TEXT_EDITOR_REMOVE_BUTTON_LABEL"))+" ")])],1)],1)]):t._e(),n("editor-content",t._g({ref:"editor",staticClass:"d-rich-text-editor",attrs:{editor:t.editor,"data-qa":"dt-rich-text-editor"}},t.editorListeners))],1)},Lt=[],Rt=u.n(Et,St,Lt);const $t=Rt.exports;exports.default=$t;
|
|
10
19
|
//# sourceMappingURL=rich-text-editor.cjs.map
|