12 |
- "use strict";(self.webpackChunknextcloud=self.webpackChunknextcloud||[]).push([[6318],{46318:function(t,e,i){i.r(e),i.d(e,{NcAutoCompleteResult:function(){return b},NcMentionBubble:function(){return n.N},default:function(){return C}}),i(55849);var n=i(22663),l=i(79753),s=i(76311),a=i(23248),o=(i(79845),i(93911)),r=i(2343),u=(i(93664),i(86514),i(61537),i(25751),i(20435),i(49368),i(89115),i(57274),i(59110),i(69183),i(32219),i(82675),i(65507)),c=i(20296),p=i(36683),d=i(73045),h=i(25108);const m={name:"NcAutoCompleteResult",props:{title:{type:String,required:!0},subline:{type:String,default:null},id:{type:String,default:null},icon:{type:String,required:!0},iconUrl:{type:String,default:null},source:{type:String,required:!0},status:{type:[Object,Array],default:()=>({})}},computed:{avatarUrl(){return this.iconUrl?this.iconUrl:this.id&&"users"===this.source?this.getAvatarUrl(this.id,44):null},haveStatus(){var t,e,i;return(null==(t=this.status)?void 0:t.icon)||(null==(e=this.status)?void 0:e.status)&&"offline"!==(null==(i=this.status)?void 0:i.status)}},methods:{getAvatarUrl(t,e){return(0,l.generateUrl)("/avatar/{user}/{size}",{user:t,size:e})}}};var f=function(){var t=this,e=t._self._c;return e("div",{staticClass:"autocomplete-result"},[e("div",{staticClass:"autocomplete-result__icon",class:[t.icon,"autocomplete-result__icon--"+(t.avatarUrl?"with-avatar":"")],style:t.avatarUrl?{backgroundImage:`url(${t.avatarUrl})`}:null},[t.haveStatus?e("div",{staticClass:"autocomplete-result__status",class:[`autocomplete-result__status--${t.status&&t.status.icon?"icon":t.status.status}`]},[t._v(" "+t._s(t.status&&t.status.icon||"")+" ")]):t._e()]),e("span",{staticClass:"autocomplete-result__content"},[e("span",{staticClass:"autocomplete-result__title",attrs:{title:t.title}},[t._v(" "+t._s(t.title)+" ")]),t.subline?e("span",{staticClass:"autocomplete-result__subline"},[t._v(" "+t._s(t.subline)+" ")]):t._e()])])},g=[];const b=(0,s.n)(m,f,g,!1,null,"25cf09d8",null,null).exports,v={name:"NcRichContenteditable",directives:{tooltip:d.VTooltip},mixins:[n.r],props:{value:{type:String,default:"",required:!0},placeholder:{type:String,default:(0,a.t)("Write a message …")},autoComplete:{type:Function,default:()=>[]},menuContainer:{type:Element,default:()=>document.body},multiline:{type:Boolean,default:!1},contenteditable:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},maxlength:{type:Number,default:null},emojiAutocomplete:{type:Boolean,default:!0},linkAutocomplete:{type:Boolean,default:!0}},emits:["submit","paste","update:value"],data(){return{textSmiles:[],tribute:null,autocompleteOptions:{allowSpaces:!0,fillAttr:"id",lookup:t=>`${t.id} ${t.title}`,menuContainer:this.menuContainer,menuItemTemplate:t=>this.renderComponentHtml(t.original,b),noMatchTemplate:()=>'<span class="hidden"></span>',selectTemplate:t=>{var e;return this.genSelectTemplate(null==(e=null==t?void 0:t.original)?void 0:e.id)},values:this.debouncedAutoComplete},emojiOptions:{trigger:":",lookup:(t,e)=>e,menuContainer:this.menuContainer,menuItemTemplate:t=>this.textSmiles.includes(t.original)?t.original:`<span class="tribute-container-emoji__item__emoji">${t.original.native}</span> :${t.original.short_name}`,noMatchTemplate:()=>(0,a.t)("No emoji found"),selectTemplate:t=>this.textSmiles.includes(t.original)?t.original:((0,o.R)(t.original),t.original.native),values:(t,e)=>{const i=(0,o.K)(t);this.textSmiles.includes(":"+t)&&i.unshift(":"+t),e(i)},containerClass:"tribute-container-emoji",itemClass:"tribute-container-emoji__item"},linkOptions:{trigger:"/",lookup:(t,e)=>e,menuContainer:this.menuContainer,menuItemTemplate:t=>`<img class="tribute-container-link__item__icon" src="${t.original.icon_url}"> <span class="tribute-container-link__item__title">${t.original.title}</span>`,noMatchTemplate:()=>(0,a.t)("No link provider found"),selectTemplate:this.getLink,values:(t,e)=>e((0,r.n)(t)),containerClass:"tribute-container-link",itemClass:"tribute-container-link__item"},localValue:this.value,isComposing:!1}},computed:{isEmptyValue(){return!this.localValue||this.localValue&&""===this.localValue.trim()},isFF(){return!!navigator.userAgent.match(/firefox/i)},isOverMaxlength(){return!(this.isEmptyValue||!this.maxlength)&&(0,p.default)(this.localValue)>this.maxlength},tooltipString(){return this.isOverMaxlength?{content:(0,a.t)("Message limit of {count} characters reached",{count:this.maxlength}),shown:!0,trigger:"manual"}:null},canEdit(){return this.contenteditable&&!this.disabled},listeners(){const t={...this.$listeners};return delete t.paste,t}},watch:{value(){const t=this.$refs.contenteditable.innerHTML;this.value.trim()!==this.parseContent(t).trim()&&this.updateContent(this.value)}},mounted(){this.textSmiles=[],["d","D","p","P","s","S","x","X",")","(","|","/"].forEach((t=>{this.textSmiles.push(":"+t),this.textSmiles.push(":-"+t)})),this.autocompleteTribute=new u.default(this.autocompleteOptions),this.autocompleteTribute.attach(this.$el),this.emojiAutocomplete&&(this.emojiTribute=new u.default(this.emojiOptions),this.emojiTribute.attach(this.$el)),this.linkAutocomplete&&(this.linkTribute=new u.default(this.linkOptions),this.linkTribute.attach(this.$el)),this.updateContent(this.value),this.$refs.contenteditable.contentEditable=this.canEdit},beforeDestroy(){this.autocompleteTribute&&this.autocompleteTribute.detach(this.$el),this.emojiTribute&&this.emojiTribute.detach(this.$el),this.linkTribute&&this.linkTribute.detach(this.$el)},methods:{focus(){this.$refs.contenteditable.focus()},getLink(t){return(0,r.j)(t.original.id).then((t=>{const e=document.getElementById("tmp-link-result-node"),i=document.createTextNode(t);e.replaceWith(i),this.setCursorAfter(i),this.updateValue(this.$refs.contenteditable.innerHTML)})).catch((t=>{h.debug("Smart picker promise rejected:",t);const e=document.getElementById("tmp-link-result-node");this.setCursorAfter(e),e.remove()})),'<span id="tmp-link-result-node"></span>'},setCursorAfter(t){const e=document.createRange();e.setEndAfter(t),e.collapse();const i=window.getSelection();i.removeAllRanges(),i.addRange(e)},onInput(t){this.updateValue(t.target.innerHTML)},onPaste(t){if(!this.canEdit)return;t.preventDefault();const e=t.clipboardData;if(this.$emit("paste",t),0!==e.files.length||!Object.values(e.items).find((t=>null==t?void 0:t.type.startsWith("text"))))return;const i=e.getData("text"),n=window.getSelection();if(!n.rangeCount)return void this.updateValue(i);const l=n.getRangeAt(0);n.deleteFromDocument(),l.insertNode(document.createTextNode(i));const s=document.createRange();s.setStart(t.target,l.endOffset),s.collapse(!0),n.removeAllRanges(),n.addRange(s),this.updateValue(this.$refs.contenteditable.innerHTML)},updateValue(t){const e=this.parseContent(t);this.localValue=e,this.$emit("update:value",e)},updateContent(t){const e=this.renderContent(t);this.$refs.contenteditable.innerHTML=e,this.localValue=t},onDelete(t){if(!this.isFF||!window.getSelection||!this.canEdit)return;const e=window.getSelection(),i=t.target;if(!e.isCollapsed||!e.rangeCount)return;const n=e.getRangeAt(e.rangeCount-1);if(3===n.commonAncestorContainer.nodeType&&n.startOffset>0)return;const l=document.createRange();if(e.anchorNode!==i)l.selectNodeContents(i),l.setEndBefore(e.anchorNode);else{if(!(e.anchorOffset>0))return;l.setEnd(i,e.anchorOffset)}l.setStart(i,l.endOffset-1);const s=l.cloneContents().lastChild;s&&"false"===s.contentEditable&&(l.deleteContents(),t.preventDefault())},onEnter(t){this.multiline||this.isOverMaxlength||this.autocompleteTribute.isActive||this.emojiTribute.isActive||this.linkTribute.isActive||this.isComposing||(t.preventDefault(),t.stopPropagation(),this.$emit("submit",t))},onCtrlEnter(t){this.isOverMaxlength||this.$emit("submit",t)},debouncedAutoComplete:c((async function(t,e){this.autoComplete(t,e)}),100),onKeyUp(t){t.stopImmediatePropagation()}}};var y=function(){var t=this;return(0,t._self._c)("div",t._g({directives:[{name:"tooltip",rawName:"v-tooltip",value:t.tooltipString,expression:"tooltipString"}],ref:"contenteditable",staticClass:"rich-contenteditable__input",class:{"rich-contenteditable__input--empty":t.isEmptyValue,"rich-contenteditable__input--multiline":t.multiline,"rich-contenteditable__input--overflow":t.isOverMaxlength,"rich-contenteditable__input--disabled":t.disabled},attrs:{contenteditable:t.canEdit,placeholder:t.placeholder,"aria-placeholder":t.placeholder,"aria-multiline":"true",role:"textbox"},on:{input:t.onInput,compositionstart:function(e){t.isComposing=!0},compositionend:function(e){t.isComposing=!1},keydown:[function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"delete",[8,46],e.key,["Backspace","Delete","Del"])?null:t.onDelete.apply(null,arguments)},function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"enter",13,e.key,"Enter")||e.ctrlKey||e.shiftKey||e.altKey||e.metaKey?null:t.onEnter.apply(null,arguments)},function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"enter",13,e.key,"Enter")||!e.ctrlKey||e.shiftKey||e.altKey||e.metaKey?null:(e.stopPropagation(),e.preventDefault(),t.onCtrlEnter.apply(null,arguments))}],paste:t.onPaste,"!keyup":function(e){return e.stopPropagation(),e.preventDefault(),t.onKeyUp.apply(null,arguments)}}},t.listeners))},_=[];const C=(0,s.n)(v,y,_,!1,null,"b7f5e546",null,null).exports}}]);
- //# sourceMappingURL=6318-6318.js.map?v=a59ab0e92c526b05f790
|