f7cloud_client/apps/text/js/MenuBar-aZwqxDEv.chunk.mjs
2026-03-05 13:40:40 +00:00

3 lines
52 KiB
JavaScript

import{f as O,r as E,c as x,p as q,e as Mt,w as wt,i as St,V as Et,k as V}from"./vue.runtime.esm-CLeelJur.chunk.mjs";import{f as F,K as C,L as M,O as At,U as Ot,Q as $t,S as Nt,Y as Tt,T as It,h as K,V as Pt,W as Ft,g as B,X as j,y as st,u as ot,Z as Bt,_ as at,$ as Rt,z as Ht,a0 as Dt,a1 as Wt,a2 as J,s as R,a3 as Lt,a4 as Ut,a5 as X,a6 as Vt,a7 as Kt,a8 as jt,a9 as zt,aa as qt,ab as Jt,ac as Xt,m as $,E as Yt,b as Qt,ad as rt,k as Zt,ae as Gt,af as te,ag as ee,ah as ne,ai as ie,aj as se,ak as oe,al as ae,am as re,an as le,ao as D,ap as de,aq as ce}from"./EditorOutline-DrybdBHq.chunk.mjs";import{n as lt,G as dt,t as S,c as N,k as Y}from"./NcLoadingIcon-ZJnsd-es.chunk.mjs";import{u as ct,c as ue,S as he,d as pe,e as me,b as ge,f as fe}from"./MediaHandler.provider-CTjO6aKX.chunk.mjs";import{n as k}from"./_plugin-vue2_normalizer-wd1ZAbRr.chunk.mjs";import{g as w,b as ve}from"./index-DxwFe63_.chunk.mjs";import{g as ye}from"./emoji-picker-MDCGxHB0.chunk.mjs";import{N as _e,j as be,u as ut,e as ke,b as ht,s as A}from"./NcNoteCard-Dz5-u2BY-S2qe9Sjm.chunk.mjs";import{s as pt,e as mt,a as xe,u as Ce}from"./index-CRQM6PVi.chunk.mjs";import{l as T}from"./logger-CoS2pszN.chunk.mjs";import{u as Me}from"./NcCheckboxRadioSwitch-DAPHFb0L-BMVa4UgQ.chunk.mjs";import{l as we}from"./index-Dl858C8_.chunk.mjs";const Se=e=>C.getState(e)?.undoManager?.undo()!=null,Ee=e=>C.getState(e)?.undoManager?.redo()!=null,Ae=new Set(["paragraph"]),Oe=(e,n)=>!(e instanceof $t)||!(e.content instanceof Nt)||!(e.content.type instanceof Tt||e.content.type instanceof It&&n.has(e.content.type.nodeName))||e.content.type._length===0,$e=({protectedNodes:e=Ae,trackedOrigins:n=[],undoManager:i=null}={})=>new F({key:C,state:{init:(s,o)=>{const a=M.getState(o),r=i||new Ot(a.type,{trackedOrigins:new Set([M].concat(n)),deleteFilter:l=>Oe(l,e),captureTransaction:l=>l.meta.get("addToHistory")!==!1});return{undoManager:r,prevSel:null,hasUndoOps:r.undoStack.length>0,hasRedoOps:r.redoStack.length>0}},apply:(s,o,a,r)=>{const l=M.getState(r).binding,p=o.undoManager,u=p.undoStack.length>0,h=p.redoStack.length>0;return l?{undoManager:p,prevSel:At(l,a),hasUndoOps:u,hasRedoOps:h}:u!==o.hasUndoOps||h!==o.hasRedoOps?Object.assign({},o,{hasUndoOps:p.undoStack.length>0,hasRedoOps:p.redoStack.length>0}):o}},view:s=>{const o=M.getState(s.state),a=C.getState(s.state).undoManager;return a.on("stack-item-added",({stackItem:r})=>{const l=o.binding;l&&r.meta.set(l,C.getState(s.state).prevSel)}),a.on("stack-item-popped",({stackItem:r})=>{const l=o.binding;l&&(l.beforeTransactionSelection=r.meta.get(l)||l.beforeTransactionSelection)}),{destroy:()=>{a.destroy()}}}}),Ti=K.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null}},addStorage(){return{isDisabled:!1}},onCreate(){this.editor.extensionManager.extensions.find(e=>e.name==="history")&&console.warn('[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-history".')},addCommands(){return{undo:()=>({tr:e,state:n,dispatch:i})=>(e.setMeta("preventDispatch",!0),C.getState(n).undoManager.undoStack.length===0?!1:i?Se(n):!0),redo:()=>({tr:e,state:n,dispatch:i})=>(e.setMeta("preventDispatch",!0),C.getState(n).undoManager.redoStack.length===0?!1:i?Ee(n):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){var e;const n=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),i=$e(this.options.yUndoOptions),s=i.spec.view;i.spec.view=r=>{const{undoManager:l}=C.getState(r.state);l.restore&&(l.restore(),l.restore=()=>{});const p=s?s(r):void 0;return{destroy:()=>{const u=l.trackedOrigins.has(l),h=l._observers;l.restore=()=>{u&&l.trackedOrigins.add(l),l.doc.on("afterTransaction",l.afterTransactionHandler),l._observers=h},p?.destroy&&p.destroy()}}};const o={...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender},a=Pt(n,o);return this.editor.options.enableContentCheck&&((e=n.doc)===null||e===void 0||e.on("beforeTransaction",()=>{try{const r=Ft(n);if(r.content.length===0)return;this.editor.schema.nodeFromJSON(r).check()}catch(r){return this.editor.emit("contentError",{error:r,editor:this.editor,disableCollaboration:()=>{var l;(l=n.doc)===null||l===void 0||l.destroy(),this.storage.isDisabled=!0}}),!1}})),[a,i,this.editor.options.enableContentCheck&&new F({key:new B("filterInvalidContent"),filterTransaction:()=>{var r;return this.storage.isDisabled&&((r=n.doc)===null||r===void 0||r.destroy()),!0}})].filter(Boolean)}});function Ne(e){return!!e.getMeta(M)}const Te=O({name:"NcDialog",components:{NcDialogButton:be,NcModal:_e},props:{name:{type:String,required:!0},message:{type:String,default:""},additionalTrapElements:{type:Array,validator:e=>Array.isArray(e)&&e.every(n=>typeof n=="string"||n instanceof HTMLElement),default:()=>[]},container:{type:String,required:!1,default:"body"},open:{type:Boolean,default:!0},size:{type:String,required:!1,default:"small",validator:e=>typeof e=="string"&&["small","normal","large","full"].includes(e)},buttons:{type:Array,required:!1,default:()=>[],validator:e=>Array.isArray(e)&&e.every(n=>typeof n=="object")},noClose:{type:Boolean,default:!1},canClose:{type:Boolean,default:!0},closeOnClickOutside:{type:Boolean,default:!1},isForm:{type:Boolean,default:!1},outTransition:{type:Boolean,default:!1},navigationClasses:{type:[String,Array,Object],required:!1,default:""},navigationAriaLabel:{type:String,required:!1,default:""},navigationAriaLabelledby:{type:String,required:!1,default:""},contentClasses:{type:[String,Array,Object],required:!1,default:""},dialogClasses:{type:[String,Array,Object],required:!1,default:""}},emits:["closing","update:open","submit"],setup(e,{emit:n,slots:i}){const s=E(),{width:o}=ut(s,{width:900}),a=x(()=>o.value<876),r=x(()=>i?.navigation!==void 0),l=dt(),p=x(()=>e.navigationAriaLabel||void 0),u=x(()=>{if(!e.navigationAriaLabel)return e.navigationAriaLabelledby||l}),h=E(),d=x(()=>e.isForm&&!r.value?"form":"div"),c=x(()=>d.value==="form"?{submit(_){_.preventDefault(),n("submit",_)},reset(_){_.preventDefault(),n("reset",_)}}:{}),y=E(!0);function f(_,Ct){(_.type==="submit"||_.nativeType==="submit")&&d.value==="form"&&!h.value.reportValidity()||(g(Ct),window.setTimeout(()=>v(),300))}function g(_){y.value=!1,n("closing",_)}function v(){y.value=!0,n("update:open",!1)}const m=x(()=>({noClose:e.noClose||!e.canClose,container:e.container===void 0?"body":e.container,labelId:l,size:e.size,show:e.open&&y.value,outTransition:e.outTransition,closeOnClickOutside:e.closeOnClickOutside,additionalTrapElements:e.additionalTrapElements}));return{dialogElement:h,dialogListeners:c,dialogTagName:d,handleButtonClose:f,handleClosing:g,handleClosed:v,hasNavigation:r,navigationId:l,navigationAriaLabelAttr:p,navigationAriaLabelledbyAttr:u,isNavigationCollapsed:a,modalProps:m,wrapper:s}}});var Ie=function(){var e=this,n=e._self._c;return e._self._setupProxy,e.open?n("NcModal",e._b({staticClass:"dialog__modal",attrs:{"enable-slideshow":!1,"enable-swipe":!1},on:{close:e.handleClosed,"update:show":function(i){return e.handleClosing()}}},"NcModal",e.modalProps,!1),[n("h2",{staticClass:"dialog__name",attrs:{id:e.navigationId},domProps:{textContent:e._s(e.name)}}),n(e.dialogTagName,e._g({ref:"dialogElement",tag:"component",staticClass:"dialog",class:e.dialogClasses},e.dialogListeners),[n("div",{ref:"wrapper",staticClass:"dialog__wrapper",class:{"dialog__wrapper--collapsed":e.isNavigationCollapsed}},[e.hasNavigation?n("nav",{staticClass:"dialog__navigation",class:e.navigationClasses,attrs:{"aria-label":e.navigationAriaLabelAttr,"aria-labelledby":e.navigationAriaLabelledbyAttr}},[e._t("navigation",null,{isCollapsed:e.isNavigationCollapsed})],2):e._e(),n("div",{staticClass:"dialog__content",class:e.contentClasses},[e._t("default",function(){return[n("p",{staticClass:"dialog__text"},[e._v(" "+e._s(e.message)+" ")])]})],2)]),n("div",{staticClass:"dialog__actions"},[e._t("actions",function(){return e._l(e.buttons,function(i,s){return n("NcDialogButton",e._b({key:s,on:{click:(o,a)=>e.handleButtonClose(i,a)}},"NcDialogButton",i,!1))})})],2)])],1):e._e()},Pe=[],Fe=lt(Te,Ie,Pe,!1,null,"66c29e13");const Be=Fe.exports,Re={name:"NcActionButton",components:{NextcloudVueNcActionButton:st},extends:j,mounted(){this.editor?.on("transaction",()=>this.updateState())},methods:{runAction(){const{actionEntry:e}=this;e.click?e.click(this):e.action(this.editor?.chain().focus(),this.editor)?.run(),this.$nextTick(()=>{this.$emit("trigged",{...e})})}}};var He=function(){var e=this,n=e._self._c;return n("NextcloudVueNcActionButton",e._g({staticClass:"entry-single-action entry-action entry-action-item",class:e.state.class,attrs:{title:e.listItemTooltip||void 0,disabled:e.state.disabled,"aria-keyshortcuts":e.keyshortcuts||void 0,"data-text-action-entry":e.actionEntry.key,type:e.state.type,"model-value":e.state.type!=="button"?e.state.active:void 0,"close-after-click":""},on:{click:e.runAction},scopedSlots:e._u([{key:"icon",fn:function(){return[n(e.icon,{tag:"component"})]},proxy:!0}])},e.$listeners),[e._v(" "+e._s(e.label)+" ")])},De=[],We=k(Re,He,De,!1,null,null);const Le=We.exports,Ue={name:"ActionList",components:{NcActions:ke,NcActionSeparator:at,ActionListItem:Le},extends:j,mixins:[ot,Bt],props:{forceEnabled:{type:Boolean,default:!1}},data:()=>({visible:!1,hasEnabledChild:!0}),computed:{currentChild(){const{state:e,editor:n,actionEntry:{children:i}}=this;return e.active?i.find(s=>Dt(s,n)):null},icon(){return this.currentChild?this.currentChild.icon:this.actionEntry.icon},iconKey(){return`${this.actionEntry.key}/${this.activeKey}`},activeKey(){return this.currentChild?.key},children(){return this.actionEntry.children.filter(({visible:e})=>e===void 0?!0:typeof e=="function"?e(this):e)},labelWithSelected(){return this.currentChild?S("text",'{menuItemName}, "{selectedSubMenuItemName}" is selected',{menuItemName:this.actionEntry.label,selectedSubMenuItemName:this.currentChild.label}):this.actionEntry.label},isEnabled(){return this.forceEnabled||this.hasEnabledChild}},mounted(){this.$_updateState=Ht(this.checkStateOfChildren.bind(this),50),this.editor?.on("update",this.$_updateState),this.editor?.on("selectionUpdate",this.$_updateState)},beforeDestroy(){this.editor?.off("update",this.$_updateState),this.editor?.off("selectionUpdate",this.$_updateState)},methods:{onOpenChange(e){this.visible=e},runAction(){},onTrigger(e){e?.click||(this.editor?.chain().focus().run(),this.$emit("trigged",e))},checkStateOfChildren(){this.hasEnabledChild=this.children.some(e=>this.isChildEnabled(e))},isChildEnabled(e){return!e.isSeparator&&!Rt(e,this.editor).disabled}}};var Ve=function(){var e=this,n=e._self._c;return n("NcActions",e._b({staticClass:"entry-list-action entry-action",attrs:{title:e.tooltip,container:e.menuIDSelector,"aria-label":e.labelWithSelected,type:e.state.active?"primary":"tertiary","force-menu":!0,"data-text-action-entry":e.actionEntry.key,"data-text-action-active":e.activeKey,disabled:!e.isEnabled},on:{"update:open":e.onOpenChange},scopedSlots:e._u([{key:"icon",fn:function(){return[n(e.icon,{key:e.iconKey,tag:"component"})]},proxy:!0}])},"NcActions",e.state,!1),[e._l(e.children,function(i){return[i.isSeparator?n("NcActionSeparator",{key:`child-${i.key}`}):n("ActionListItem",e._g({key:`child-${i.key}`,attrs:{active:e.currentChild?.key===i.key,"is-item":"","action-entry":i},on:{trigged:e.onTrigger}},e.$listeners))]}),e._t("lastAction",null,null,{visible:e.visible})],2)},Ke=[],je=k(Ue,Ve,Ke,!1,null,null);const gt=je.exports,ze={name:"ActionSingle",components:{NcButton:ht},extends:j,props:{isItem:{type:Boolean,default:!1}},mounted(){this.editor?.on("transaction",()=>this.updateState())},methods:{runAction(){const{actionEntry:e}=this;e.click?e.click(this):e.action(this.editor?.chain().focus(),this.editor)?.run(),this.$nextTick(()=>{this.$emit("trigged",{...e})})}}};var qe=function(){var e=this,n=e._self._c;return n("NcButton",e._g({staticClass:"entry-single-action entry-action",class:e.state.class,attrs:{disabled:e.state.disabled,"aria-keyshortcuts":e.keyshortcuts||void 0,"data-text-action-entry":e.actionEntry.key,"aria-label":e.label,title:e.tooltip,type:"tertiary",pressed:e.state.type!=="button"?e.state.active:void 0},on:{click:e.runAction},scopedSlots:e._u([{key:"icon",fn:function(){return[n(e.icon,{tag:"component"})]},proxy:!0},e.actionEntry.forceLabel?{key:"default",fn:function(){return[e._v(" "+e._s(e.label)+" ")]},proxy:!0}:null],null,!0)},e.$listeners))},Je=[],Xe=k(ze,qe,Je,!1,null,null);const ft=Xe.exports,vt=O({data(){return{activeMenuEntry:0,entries:[]}},computed:{visibleEntries(){return this.entries}},watch:{visibleEntries(){this.$nextTick(()=>{(this.activeMenuEntry>this.visibleEntries.length||this.visibleEntries[this.activeMenuEntry]?.disabled)&&this.setNextMenuEntry()})}},methods:{disableMenuEntry(e,n){const i=this.visibleEntries.findIndex(({key:s})=>s===e);this.visibleEntries[i].disabled=n,n===!1&&this.activeMenuEntry===i&&this.$nextTick(()=>this.setNextMenuEntry())},setNextMenuEntry(){const e=this.visibleEntries.length+(this.$refs.remainingEntries?1:0);do this.activeMenuEntry=(this.activeMenuEntry+1)%e;while(this.activeMenuEntry<this.visibleEntries.length&&this.visibleEntries[this.activeMenuEntry].disabled)},setPreviousMenuEntry(){const e=this.visibleEntries.length+(this.$refs.remainingEntries?1:0);do{const n=this.activeMenuEntry-1;this.activeMenuEntry=(n%e+e)%e}while(this.activeMenuEntry<this.visibleEntries.length&&this.visibleEntries[this.activeMenuEntry].disabled)},handleToolbarNavigation(e){e.key==="ArrowRight"?this.setNextMenuEntry():e.key==="ArrowLeft"&&this.setPreviousMenuEntry(),this.activeMenuEntry===this.visibleEntries.length?this.$refs.remainingEntries?.focusButton?.():[...this.$refs.menuEntries].sort((n,i)=>this.visibleEntries.findIndex(({key:s})=>s===n.$vnode.data.key)-this.visibleEntries.findIndex(({key:s})=>s===i.$vnode.data.key))[this.activeMenuEntry].focusButton()}}}),Ye=O({name:"ReadonlyBar",components:{ActionList:gt,ActionSingle:ft},extends:vt,mixins:[ct],props:{isHidden:{type:Boolean,default:!1},openReadOnly:{type:Boolean,default:!1}},emits:["update:loaded"],setup(){const{isRichWorkspace:e}=R();return{isRichWorkspace:e}},data(){return{entries:this.openReadOnly?[...Wt,...J]:[...J],isReady:!1}},mounted(){this.$nextTick(()=>{this.isReady=!0,this.$emit("update:loaded",!0)})},methods:{t:S}});var Qe=function(){var e=this,n=e._self._c;return e._self._setupProxy,n("div",{staticClass:"text-readonly-bar",class:{"text-readonly-bar--ready":e.isReady,"text-readonly-bar--is-workspace":e.isRichWorkspace,"text-readonly-bar--hide":e.isHidden,"is-mobile":e.$isMobile},attrs:{"data-text-el":"readonly-bar"}},[n("div",{ref:"menubar",staticClass:"text-readonly-bar__entries",attrs:{role:"toolbar","aria-label":e.t("text","Editor actions")}},e._l(e.visibleEntries,function(i,s){return n(i.component?i.component:i.children?"ActionList":"ActionSingle",{key:i.key,ref:"menuEntries",refInFor:!0,tag:"component",attrs:{"action-entry":i,"can-be-focussed":e.activeMenuEntry===s},on:{disabled:function(o){return e.disableMenuEntry(i.key,o)}}})}),1),n("div",{staticClass:"text-readonly-bar__slot"},[e._t("default")],2)])},Ze=[],Ge=k(Ye,Qe,Ze,!1,null,"988a9965");const Ii=Ge.exports;let Q=we("text","is_full_width_editor",!1);const U=Symbol("text:editor:width");function tn(){const e=getComputedStyle(document.body).getPropertyValue("--text-editor-max-width"),n=document.documentElement.style.getPropertyValue("--text-editor-max-width");return!!e&&e!==n}const Pi=()=>{if(tn())return q(U,null),{applyEditorWidth:()=>{}};const e=E(Q);q(U,Mt(e)),pt("text:editor:full-width",({value:s})=>{Q=s,e.value=s});const n=x(()=>e.value?"100%":"80ch"),i=()=>{document.documentElement.style.setProperty("--text-editor-max-width",n.value)};return wt(n,i),{applyEditorWidth:i}},yt=()=>{const e=St(U);return e===null?{canToggleWidth:!1}:{canToggleWidth:!0,isFullWidth:e,setFullWidth:n=>{N.post(w("/apps/text/settings"),{key:"is_full_width_editor",value:n?"1":"0"}),mt("text:editor:full-width",{value:n})}}},en={name:"NcActionCheckbox",mixins:[Lt],inject:{isInSemanticMenu:{from:"NcActions:isSemanticMenu",default:!1}},model:{prop:"modelValue",event:"update:modelValue"},props:{id:{type:String,default:()=>"action-"+dt(),validator:e=>e.trim()!==""},checked:{type:Boolean,default:void 0},modelValue:{type:Boolean,default:!1},value:{type:[String,Number],default:""},disabled:{type:Boolean,default:!1}},emits:["change","check","uncheck","update:checked","update:modelValue","update:model-value"],setup(){return{model:Me("checked","update:checked")}},computed:{isFocusable(){return!this.disabled},ariaChecked(){if(this.isInSemanticMenu)return this.model?"true":"false"}},methods:{checkInput(){this.$refs.label.click()},onChange(e){this.model=this.$refs.checkbox.checked,this.$emit("change",e),this.$refs.checkbox.checked?this.$emit("check"):this.$emit("uncheck")}}};var nn=function(){var e=this,n=e._self._c;return n("li",{staticClass:"action",class:{"action--disabled":e.disabled},attrs:{role:e.isInSemanticMenu&&"presentation"}},[n("span",{staticClass:"action-checkbox",attrs:{role:e.isInSemanticMenu&&"menuitemcheckbox","aria-checked":e.ariaChecked}},[n("input",{ref:"checkbox",staticClass:"checkbox action-checkbox__checkbox",class:{focusable:e.isFocusable},attrs:{id:e.id,disabled:e.disabled,type:"checkbox"},domProps:{checked:e.model,value:e.value},on:{keydown:function(i){return!i.type.indexOf("key")&&e._k(i.keyCode,"enter",13,i.key,"Enter")||i.ctrlKey||i.shiftKey||i.altKey||i.metaKey?null:(i.preventDefault(),e.checkInput.apply(null,arguments))},change:e.onChange}}),n("label",{ref:"label",staticClass:"action-checkbox__label",attrs:{for:e.id}},[e._v(e._s(e.text))]),e._e()],2)])},sn=[],on=lt(en,nn,sn,!1,null,"73edcb0b");const an=on.exports;var W={exports:{}},Z;function rn(){return Z||(Z=1,function(e,n){Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;function i(h){"@babel/helpers - typeof";return i=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(d){return typeof d}:function(d){return d&&typeof Symbol=="function"&&d.constructor===Symbol&&d!==Symbol.prototype?"symbol":typeof d},i(h)}var s=47,o=46,a=function(h){var d=i(h);if(d!=="string")throw new TypeError("Expected a string, got a ".concat(d))},r=function(h,d){for(var c="",y=0,f=-1,g=0,v,m=0;m<=h.length;++m){if(m<h.length)v=h.charCodeAt(m);else{if(v===s)break;v=s}if(v===s){if(!(f===m-1||g===1))if(f!==m-1&&g===2){if(c.length<2||y!==2||c.charCodeAt(c.length-1)!==o||c.charCodeAt(c.length-2)!==o){if(c.length>2){var _=c.lastIndexOf("/");if(_!==c.length-1){_===-1?(c="",y=0):(c=c.slice(0,_),y=c.length-1-c.lastIndexOf("/")),f=m,g=0;continue}}else if(c.length===2||c.length===1){c="",y=0,f=m,g=0;continue}}d&&(c.length>0?c+="/..":c="..",y=2)}else c.length>0?c+="/"+h.slice(f+1,m):c=h.slice(f+1,m),y=m-f-1;f=m,g=0}else v===o&&g!==-1?++g:g=-1}return c},l=function(h){try{return decodeURIComponent(h)}catch{return h}},p=function(h){a(h);var d=h;if(d.length===0)return".";var c=d.charCodeAt(0)===s,y=d.charCodeAt(d.length-1)===s;return d=l(d),d=r(d,!c),d.length===0&&!c&&(d="."),d.length>0&&y&&(d+="/"),c?"/"+d:d},u=p;n.default=u,e.exports=n.default}(W,W.exports)),W.exports}var ln=rn();const dn=ye(ln);class Fi{#t;#e;#n;#i;#s;#o;#a=[];constructor({session:n,user:i,shareToken:s,currentDirectory:o,fileId:a}){this.#t=n,this.#e=i,this.#n=s,this.#i=o,this.#s=a??n.documentId,this.#o=this.#r()}async#r(){const n=await N.post(w("/apps/text/attachments"),{documentId:this.#t?.documentId??this.#s,sessionId:this.#t?.id,sessionToken:this.#t?.token,shareToken:this.#n});this.#a=n.data}#l(n){return this.#a.find(i=>i.name===n)}async resolve(n,i=!0){let s;const o=/^\.attachments\.\d+\//;if(n.match(o)){const a=decodeURIComponent(n.replace(o,"").split("?")[0]);if(await this.#o,s=this.#l(a),i&&!s&&(await this.#r(),s=this.#l(a)),s)return s}return cn(n)?{isImage:!0,name:this.#d(n),previewUrl:n,fullUrl:n}:{isImage:!0,name:this.#d(n),previewUrl:this.#c(n),fullUrl:this.#c(n)}}#d(n){return n.split("/").pop()}#c(n){if(this.#e){const a=this.#e.uid,r=this.#u(n).split("/").map(encodeURIComponent).join("/");return ve(`dav/files/${a}${r}`)}const i=this.#u(n).split("/"),s=i.pop(),o=i.join("/");return w("/s/{token}/download?path={dirname}&files={basename}",{token:this.#n,basename:s,dirname:o})}#h(n){return decodeURI(n.split("?")[0])}#u(n){const i=[this.#i,this.#h(n)].join("/");return dn(i)}}function cn(e){return e.startsWith("http://")||e.startsWith("https://")||e.startsWith("data:")}function G(e){if(!e.length)return X.empty;const n=[],i=e[0].$from.node(0);return e.forEach(s=>{const o=s.$from.pos,a=s.$from.nodeAfter;a&&n.push(Vt.node(o,o+a.nodeSize,{class:"ProseMirror-selectednoderange"}))}),X.create(i,n)}function H(e,n,i){const s=[],o=e.node(0);i=typeof i=="number"&&i>=0?i:e.sameParent(n)?Math.max(0,e.sharedDepth(n.pos)-1):e.sharedDepth(n.pos);const a=new Kt(e,n,i),r=a.depth===0?0:o.resolve(a.start).posAtIndex(0);return a.parent.forEach((l,p)=>{const u=r+p,h=u+l.nodeSize;if(u<a.start||u>=a.end)return;const d=new jt(o.resolve(u),o.resolve(h));s.push(d)}),s}class z{constructor(n,i){this.anchor=n,this.head=i}map(n){return new z(n.map(this.anchor),n.map(this.head))}resolve(n){const i=n.resolve(this.anchor),s=n.resolve(this.head);return new b(i,s)}}class b extends Ut{constructor(n,i,s,o=1){const{doc:a}=n,r=n===i,l=n.pos===a.content.size&&i.pos===a.content.size,p=r&&!l?a.resolve(i.pos+(o>0?1:-1)):i,u=r&&l?a.resolve(n.pos-(o>0?1:-1)):n,h=H(u.min(p),u.max(p),s),d=p.pos>=n.pos?h[0].$from:h[h.length-1].$to,c=p.pos>=n.pos?h[h.length-1].$to:h[0].$from;super(d,c,h),this.depth=s}get $to(){return this.ranges[this.ranges.length-1].$to}eq(n){return n instanceof b&&n.$from.pos===this.$from.pos&&n.$to.pos===this.$to.pos}map(n,i){const s=n.resolve(i.map(this.anchor)),o=n.resolve(i.map(this.head));return new b(s,o)}toJSON(){return{type:"nodeRange",anchor:this.anchor,head:this.head}}get isForwards(){return this.head>=this.anchor}get isBackwards(){return!this.isForwards}extendBackwards(){const{doc:n}=this.$from;if(this.isForwards&&this.ranges.length>1){const o=this.ranges.slice(0,-1),a=o[0].$from,r=o[o.length-1].$to;return new b(a,r,this.depth)}const i=this.ranges[0],s=n.resolve(Math.max(0,i.$from.pos-1));return new b(this.$anchor,s,this.depth)}extendForwards(){const{doc:n}=this.$from;if(this.isBackwards&&this.ranges.length>1){const o=this.ranges.slice(1),a=o[0].$from,r=o[o.length-1].$to;return new b(r,a,this.depth)}const i=this.ranges[this.ranges.length-1],s=n.resolve(Math.min(n.content.size,i.$to.pos+1));return new b(this.$anchor,s,this.depth)}static fromJSON(n,i){return new b(n.resolve(i.anchor),n.resolve(i.head))}static create(n,i,s,o,a=1){return new this(n.resolve(i),n.resolve(s),o,a)}getBookmark(){return new z(this.anchor,this.head)}}b.prototype.visible=!1;function I(e){return e instanceof b}K.create({name:"nodeRange",addOptions(){return{depth:void 0,key:"Mod"}},addKeyboardShortcuts(){return{"Shift-ArrowUp":({editor:e})=>{const{depth:n}=this.options,{view:i,state:s}=e,{doc:o,selection:a,tr:r}=s,{anchor:l,head:p}=a;if(!I(a)){const h=b.create(o,l,p,n,-1);return r.setSelection(h),i.dispatch(r),!0}const u=a.extendBackwards();return r.setSelection(u),i.dispatch(r),!0},"Shift-ArrowDown":({editor:e})=>{const{depth:n}=this.options,{view:i,state:s}=e,{doc:o,selection:a,tr:r}=s,{anchor:l,head:p}=a;if(!I(a)){const h=b.create(o,l,p,n);return r.setSelection(h),i.dispatch(r),!0}const u=a.extendForwards();return r.setSelection(u),i.dispatch(r),!0},"Mod-a":({editor:e})=>{const{depth:n}=this.options,{view:i,state:s}=e,{doc:o,tr:a}=s,r=b.create(o,0,o.content.size,n);return a.setSelection(r),i.dispatch(a),!0}}},onSelectionUpdate(){const{selection:e}=this.editor.state;I(e)&&this.editor.view.dom.classList.add("ProseMirror-noderangeselection")},addProseMirrorPlugins(){let e=!1,n=!1;return[new F({key:new B("nodeRange"),props:{attributes:()=>e?{class:"ProseMirror-noderangeselection"}:{class:""},handleDOMEvents:{mousedown:(i,s)=>{const{key:o}=this.options,a=/Mac/.test(navigator.platform),r=!!s.shiftKey,l=!!s.ctrlKey,p=!!s.altKey,u=!!s.metaKey,h=a?u:l;return(o==null||o==="Shift"&&r||o==="Control"&&l||o==="Alt"&&p||o==="Meta"&&u||o==="Mod"&&h)&&(n=!0),n&&document.addEventListener("mouseup",()=>{n=!1;const{state:d}=i,{doc:c,selection:y,tr:f}=d,{$anchor:g,$head:v}=y;if(g.sameParent(v))return;const m=b.create(c,g.pos,v.pos,this.options.depth);f.setSelection(m),i.dispatch(f)},{once:!0}),!1}},decorations:i=>{const{selection:s}=i,o=I(s);if(e=!1,!n)return o?(e=!0,G(s.ranges)):null;const{$from:a,$to:r}=s;if(!o&&a.sameParent(r))return null;const l=H(a,r,this.options.depth);return l.length?(e=!0,G(l)):null}}})]}});function un(e){let n="";const i=getComputedStyle(e);for(let s=0;s<i.length;s+=1)n+=`${i[s]}:${i.getPropertyValue(i[s])};`;return n}function hn(e){const n=e.cloneNode(!0),i=[e,...Array.from(e.getElementsByTagName("*"))],s=[n,...Array.from(n.getElementsByTagName("*"))];return i.forEach((o,a)=>{s[a].style.cssText=un(o)}),n}const _t=e=>{const{x:n,y:i,direction:s,editor:o}=e;let a=null,r=null,l=null,p=n;for(;r===null&&p<window.innerWidth&&p>0;){const u=document.elementsFromPoint(p,i),h=u.findIndex(c=>c.classList.contains("ProseMirror")),d=u.slice(0,h);if(d.length>0){const c=d[0];if(a=c,l=o.view.posAtDOM(c,0),l>=0){r=o.state.doc.nodeAt(Math.max(l-1,0)),r?.isText&&(r=o.state.doc.nodeAt(Math.max(l-1,0))),r||(r=o.state.doc.nodeAt(Math.max(l,0)));break}}s==="left"?p-=1:p+=1}return{resultElement:a,resultNode:r,pos:l??null}};function P(e,n){return window.getComputedStyle(e)[n]}function pn(e=0,n=0,i=0){return Math.min(Math.max(e,n),i)}function mn(e,n,i){const s=parseInt(P(e.dom,"paddingLeft"),10),o=parseInt(P(e.dom,"paddingRight"),10),a=parseInt(P(e.dom,"borderLeftWidth"),10),r=parseInt(P(e.dom,"borderLeftWidth"),10),l=e.dom.getBoundingClientRect();return{left:pn(n,l.left+s+a,l.right-o-r),top:i}}function bt(e){var n;(n=e.parentNode)===null||n===void 0||n.removeChild(e)}function gn(e,n){const{doc:i}=n.view.state,s=_t({editor:n,x:e.clientX,y:e.clientY,direction:"right"});if(!s.resultNode||s.pos===null)return[];const o=e.clientX,a=mn(n.view,o,e.clientY),r=n.view.posAtCoords(a);if(!r)return[];const{pos:l}=r;if(!i.resolve(l).parent)return[];const p=i.resolve(s.pos),u=i.resolve(s.pos+1);return H(p,u,0)}function fn(e,n){const{view:i}=n;if(!e.dataTransfer)return;const{empty:s,$from:o,$to:a}=i.state.selection,r=gn(e,n),l=H(o,a,0),p=l.some(v=>r.find(m=>m.$from===v.$from&&m.$to===v.$to)),u=s||!p?r:l;if(!u.length)return;const{tr:h}=i.state,d=document.createElement("div"),c=u[0].$from.pos,y=u[u.length-1].$to.pos,f=b.create(i.state.doc,c,y),g=f.content();u.forEach(v=>{const m=i.nodeDOM(v.$from.pos),_=hn(m);d.append(_)}),d.style.position="absolute",d.style.top="-10000px",document.body.append(d),e.dataTransfer.clearData(),e.dataTransfer.setDragImage(d,0,0),i.dragging={slice:g,move:!0},h.setSelection(f),i.dispatch(h),document.addEventListener("drop",()=>bt(d),{once:!0})}const tt=(e,n)=>{const i=e.resolve(n),{depth:s}=i;return s===0?n:i.pos-i.parentOffset-1},et=(e,n)=>{const i=e.nodeAt(n),s=e.resolve(n);let{depth:o}=s,a=i;for(;o>0;){const r=s.node(o);o-=1,o===0&&(a=r)}return a},L=(e,n)=>{const i=M.getState(e);return i?qt(n,i.type,i.binding.mapping):null},vn=(e,n)=>{const i=M.getState(e);return i?Jt(i.doc,i.type,n,i.binding.mapping)||0:-1},nt=(e,n)=>{let i=n;for(;i&&i.parentNode&&i.parentNode!==e.dom;)i=i.parentNode;return i},kt=new B("dragHandle"),xt=({pluginKey:e=kt,element:n,editor:i,tippyOptions:s,onNodeChange:o})=>{const a=document.createElement("div");let r=null,l=!1,p=null,u=-1,h;return n.addEventListener("dragstart",d=>{fn(d,i),setTimeout(()=>{n&&(n.style.pointerEvents="none")},0)}),n.addEventListener("dragend",()=>{n&&(n.style.pointerEvents="auto")}),new F({key:typeof e=="string"?new B(e):e,state:{init(){return{locked:!1}},apply(d,c,y,f){const g=d.getMeta("lockDragHandle"),v=d.getMeta("hideDragHandle");if(g!==void 0&&(l=g),v&&r)return r.hide(),l=!1,p=null,u=-1,o?.({editor:i,node:null,pos:-1}),c;if(d.docChanged&&u!==-1&&n&&r)if(Ne(d)){const m=vn(f,h);m!==u&&(u=m)}else{const m=d.mapping.map(u);m!==u&&(u=m,h=L(f,u))}return c}},view:d=>{var c;return n.draggable=!0,n.style.pointerEvents="auto",(c=i.view.dom.parentElement)===null||c===void 0||c.appendChild(a),a.appendChild(n),a.style.pointerEvents="none",a.style.position="absolute",a.style.top="0",a.style.left="0",{update(y,f){if(!n)return;if(!i.isEditable){r?.destroy(),r=null;return}if(r||(r=zt(d.dom,{getReferenceClientRect:null,interactive:!0,trigger:"manual",placement:"left-start",hideOnClick:!1,duration:100,popperOptions:{modifiers:[{name:"flip",enabled:!1},{name:"preventOverflow",options:{rootBoundary:"document",mainAxis:!1}}]},...s,appendTo:a,content:n})),l?n.draggable=!1:n.draggable=!0,d.state.doc.eq(f.doc)||u===-1)return;let g=d.nodeDOM(u);if(g=nt(d,g),g===d.dom||g?.nodeType!==1)return;const v=d.posAtDOM(g,0),m=et(i.state.doc,v),_=tt(i.state.doc,v);p=m,u=_,h=L(d.state,u),o?.({editor:i,node:p,pos:u}),r.setProps({getReferenceClientRect:()=>g.getBoundingClientRect()})},destroy(){r?.destroy(),n&&bt(a)}}},props:{handleDOMEvents:{keydown(d){return r&&r.state.isVisible&&d.hasFocus()&&r.hide(),!1},mouseleave(d,c){return l||c.target&&!a.contains(c.relatedTarget)&&(r?.hide(),p=null,u=-1,o?.({editor:i,node:null,pos:-1})),!1},mousemove(d,c){if(!n||!r||l)return!1;const y=_t({x:c.clientX,y:c.clientY,direction:"right",editor:i});if(!y.resultElement)return!1;let f=y.resultElement;if(f=nt(d,f),f===d.dom||f?.nodeType!==1)return!1;const g=d.posAtDOM(f,0),v=et(i.state.doc,g);if(v!==p){const m=tt(i.state.doc,g);p=v,u=m,h=L(d.state,u),o?.({editor:i,node:p,pos:u}),r.setProps({getReferenceClientRect:()=>f.getBoundingClientRect()}),r.show()}return!1}}}})};K.create({name:"dragHandle",addOptions(){return{render(){const e=document.createElement("div");return e.classList.add("drag-handle"),e},tippyOptions:{},locked:!1,onNodeChange:()=>null}},addCommands(){return{lockDragHandle:()=>({editor:e})=>(this.options.locked=!0,e.commands.setMeta("lockDragHandle",this.options.locked)),unlockDragHandle:()=>({editor:e})=>(this.options.locked=!1,e.commands.setMeta("lockDragHandle",this.options.locked)),toggleDragHandle:()=>({editor:e})=>(this.options.locked=!this.options.locked,e.commands.setMeta("lockDragHandle",this.options.locked))}},addProseMirrorPlugins(){const e=this.options.render();return[xt({tippyOptions:this.options.tippyOptions,element:e,editor:this.editor,onNodeChange:this.options.onNodeChange})]}});const yn=Et.extend({name:"DragHandleVue",props:{pluginKey:{type:[String,Object],default:()=>kt},editor:{type:Object,required:!0},tippyOptions:{type:Object,default:()=>({})},onNodeChange:{type:Function,default:null},class:{type:String,default:"drag-handle"}},mounted(){const{editor:e,pluginKey:n,onNodeChange:i,tippyOptions:s}=this.$props;e.registerPlugin(xt({editor:e,element:this.$el,pluginKey:n,tippyOptions:s,onNodeChange:i}))},beforeDestroy(){const{pluginKey:e,editor:n}=this.$props;n.unregisterPlugin(e)},render(e){return e("div",{class:this.class},this.$slots.default)}}),_n={name:"DragVerticalIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}};var bn=function(){var e=this,n=e._self._c;return n("span",e._b({staticClass:"material-design-icon drag-vertical-icon",attrs:{"aria-hidden":e.title?null:"true","aria-label":e.title,role:"img"},on:{click:function(i){return e.$emit("click",i)}}},"span",e.$attrs,!1),[n("svg",{staticClass:"material-design-icon__svg",attrs:{fill:e.fillColor,width:e.size,height:e.size,viewBox:"0 0 24 24"}},[n("path",{attrs:{d:"M9,3H11V5H9V3M13,3H15V5H13V3M9,7H11V9H9V7M13,7H15V9H13V7M9,11H11V13H9V11M13,11H15V13H13V11M9,15H11V17H9V15M13,15H15V17H13V15M9,19H11V21H9V19M13,19H15V21H13V19Z"}},[e.title?n("title",[e._v(e._s(e.title))]):e._e()])])])},kn=[],xn=k(_n,bn,kn,!1,null,null);const Cn=xn.exports,Mn={name:"FloatingButtons",components:{DragHandle:yn,DragVerticalIcon:Cn,NcButton:ht,PlusIcon:Xt},setup(){const{editor:e}=$();return{editor:e}},data(){return{node:null,pos:-1}},computed:{isHeadingNode(){return this.node?.type===this.editor.schema.nodes.heading}},methods:{onNodeChange({node:e,pos:n}){this.node=e,this.pos=n},onOpenSmartPicker(){if(!this.node||this.pos===-1)return;const{schema:e}=this.editor,n=this.node.textContent.trim()===""&&(this.node.children.length===0||this.node.children.every(i=>i.type===e.nodes.text))?this.pos+1:this.pos+this.node.nodeSize;this.editor.chain().insertContentAt(n,"/").focus().run()},t:S}};var wn=function(){var e=this,n=e._self._c;return n("DragHandle",{staticClass:"floating-buttons",class:{heading:e.isHeadingNode},attrs:{editor:e.editor,"on-node-change":e.onNodeChange}},[n("NcButton",{attrs:{type:"tertiary-no-background",size:"small",title:e.t("text","Insert below")},on:{click:e.onOpenSmartPicker},scopedSlots:e._u([{key:"icon",fn:function(){return[n("PlusIcon",{attrs:{size:16}})]},proxy:!0}])}),n("NcButton",{staticClass:"drag-button",attrs:{type:"tertiary-no-background",size:"small",title:e.t("text","Click for options, hold to drag")},scopedSlots:e._u([{key:"icon",fn:function(){return[n("DragVerticalIcon",{attrs:{size:16}})]},proxy:!0}])})],1)},Sn=[],En=k(Mn,wn,Sn,!1,null,"4282c04c");const An=En.exports,On={name:"ContentContainer",components:{EditorContent:Qt,EditorOutline:Yt,FloatingButtons:An},mixins:[ot],props:{readOnly:{type:Boolean,required:!0}},setup(){const e=rt(),{editor:n}=$(),{isRichEditor:i,isRichWorkspace:s}=R(),{isFullWidth:o}=yt();return{editor:n,isMobile:e,isFullWidth:o,isRichEditor:i,isRichWorkspace:s}},computed:{showOutline(){return this.$outlineState.visible},showFloatingButtons(){return!this.readOnly&&!this.isMobile&&!this.isFullWidth&&this.isRichEditor&&!this.isRichWorkspace}}};var $n=function(){var e=this,n=e._self._c;return n("div",{staticClass:"content-wrapper text-editor__content-wrapper",class:{"--show-outline":e.showOutline},attrs:{"data-text-el":"editor-content-wrapper"}},[e.showOutline?n("div",{staticClass:"text-editor__content-wrapper__left"},[n("EditorOutline")],1):e._e(),e._t("default"),e.showFloatingButtons?n("FloatingButtons"):e._e(),n("EditorContent",{staticClass:"editor__content text-editor__content",attrs:{role:"document",editor:e.editor}}),n("div",{staticClass:"text-editor__content-wrapper__right"})],2)},Nn=[],Tn=k(On,$n,Nn,!1,null,"86ce242a");const Bi=Tn.exports;function In(e,n){const{documentId:i,sessionId:s,sessionToken:o,shareToken:a}=V(e),r=new FormData;r.append("file",n);const l=w("apps/text/attachment/upload?");return N.post(l,r,{headers:{"Content-Type":"multipart/form-data"},params:{documentId:i,sessionId:s,sessionToken:o,token:a}})}function Pn(e,n){const{documentId:i,sessionId:s,sessionToken:o}=V(e),a=w("apps/text/attachment/create");return N.post(a,{documentId:i,sessionId:s,sessionToken:o,fileName:`${n.app}${n.extension}`})}function Fn(e,n){const{documentId:i,sessionId:s,sessionToken:o}=V(e),a=w("apps/text/attachment/filepath");return N.post(a,{documentId:i,sessionId:s,sessionToken:o,filePath:n})}const it=e=>e.split("/").slice(0,-1).join("/"),Bn={name:"MediaHandler",mixins:[ue],provide(){const e={};return Object.defineProperties(e,{[ge]:{get:()=>this.showAttachmentPrompt},[me]:{get:()=>this.chooseLocalFile},[pe]:{get:()=>this.createAttachment},[he]:{get:()=>this.state}}),e},setup(){const{connection:e}=Zt(),n=rt(),{editor:i}=$();return{connection:e,editor:i,isMobile:n}},data(){return{lastFilePath:null,draggedOver:!1,state:{isUploadingAttachments:!1}}},computed:{initialFilePath(){return this.lastFilePath??it(this.$file?.relativePath??"/")}},methods:{setDraggedOver(e,n){n.dataTransfer.types.includes("Files")&&(this.draggedOver=e)},onPaste(e){this.uploadAttachmentFiles(e.detail.files)},onEditorDrop(e){this.uploadAttachmentFiles(e.detail.files,e.detail.position)},onAttachmentUploadFilePicked(e){this.uploadAttachmentFiles(e.target.files),e.target.value=""},chooseLocalFile(){this.$refs.attachmentFileInput.click()},async uploadAttachmentFiles(e,n=null){if(!e)return;this.state.isUploadingAttachments=!0;const i=[...e].map(s=>this.uploadAttachmentFile(s,n));return Promise.all(i).catch(s=>{T.error("Uploading multiple attachments failed",{error:s}),A(t("text","Uploading multiple attachments failed."))}).then(()=>{this.state.isUploadingAttachments=!1})},async uploadAttachmentFile(e,n=null){return this.state.isUploadingAttachments=!0,In(this.connection,e).then(i=>{this.insertAttachment(i.data?.name,i.data?.id,e.type,n,i.data?.dirname)}).catch(i=>{T.error("Uploading attachment failed",{error:i}),i.response?.data.error?A(t("text","Uploading attachment failed: {error}",{error:i.response.data.error})):A(t("text","Uploading attachment failed."))}).then(()=>{this.state.isUploadingAttachments=!1})},showAttachmentPrompt(){xe()&&OC.dialogs.filepicker(t("text","Insert an attachment"),e=>{this.insertFromPath(e)},!1,[],!0,void 0,this.initialFilePath)},insertFromPath(e){return this.lastFilePath=it(e),this.state.isUploadingAttachments=!0,Fn(this.connection,e).then(n=>{this.insertAttachment(n.data?.name,n.data?.id,n.data?.mimetype,null,n.data?.dirname)}).catch(n=>{T.error("Failed to insert from Files",{error:n}),A(t("text","Failed to insert from Files"))}).then(()=>{this.state.isUploadingAttachments=!1})},createAttachment(e){return this.state.isUploadingAttachments=!0,Pn(this.connection,e).then(n=>{this.insertAttachmentPreview(n.data?.id)}).catch(n=>{T.error("Failed to create attachment",{error:n}),A(t("text","Failed to create attachment"))}).then(()=>{this.state.isUploadingAttachments=!1})},insertAttachmentPreview(e){const n=new URL(w(`/f/${e}`),window.origin).href.replaceAll(" ","%20");this.editor.chain().focus().insertPreview(n).run()},insertAttachment(e,n,i,s=null,o=""){const a=o+"/"+encodeURIComponent(e).replace(/[!'()*]/g,p=>"%"+p.charCodeAt(0).toString(16).toUpperCase()),r=e.replaceAll(/[[\]]/g,"");(s?this.editor.chain().focus(s):this.editor.chain()).setImage({src:a,alt:r}).run();const l=this.editor.view.state.selection;l.empty||this.editor.commands.focus(l.to),this.editor.commands.scrollIntoView(),this.editor.commands.setMeta("insertedAttachmentSrc",{src:a}),mt("text:image-node:add",null)}}};var Rn=function(){var e=this,n=e._self._c;return n("div",{staticClass:"editor editor-media-handler",class:{draggedOver:e.draggedOver,"is-mobile":e.isMobile},attrs:{"data-text-el":"editor-media-handler"},on:{"image-paste":e.onPaste,dragover:function(i){return i.preventDefault(),i.stopPropagation(),e.setDraggedOver(!0,i)},dragleave:function(i){return i.preventDefault(),i.stopPropagation(),e.setDraggedOver(!1,i)},drop:function(i){return i.preventDefault(),i.stopPropagation(),e.setDraggedOver(!1,i)},"file-drop":e.onEditorDrop}},[n("input",{directives:[{name:"show",rawName:"v-show",value:!1,expression:"false"}],ref:"attachmentFileInput",attrs:{"data-text-el":"attachment-file-input",type:"file",accept:"*/*",multiple:""},on:{change:e.onAttachmentUploadFilePicked}}),e._t("default")],2)},Hn=[],Dn=k(Bn,Rn,Hn,!1,null,null);const Wn=Dn.exports,Ln={name:"MainContainer",components:{MediaHandler:Wn},mixins:[fe]};var Un=function(){var e=this,n=e._self._c;return n("div",{staticClass:"editor"},[e.$editorUpload?n("MediaHandler",{staticClass:"text-editor__main"},[e._t("default")],2):e._t("default")],2)},Vn=[],Kn=k(Ln,Un,Vn,!1,null,"e0c9a19c");const Ri=Kn.exports,jn={name:"Wrapper",provide(){const e={};return Object.defineProperties(e,{[ee]:{get:()=>this.outline},[te]:{get:()=>({toggle:this.outlineToggle})},[Gt]:{get:()=>({toggle:this.readOnlyToggle})}}),e},props:{isResolvingConflict:{type:Boolean,default:!1},hasConnectionIssue:{type:Boolean,default:!1},contentLoaded:{type:Boolean,default:!0},showOutlineOutside:{type:Boolean,default:!1}},setup(){const{isRichEditor:e,isRichWorkspace:n}=R();return{isRichEditor:e,isRichWorkspace:n}},data:()=>({outline:{visible:!1,enable:!1}}),computed:{showOutline(){return this.isAbleToShowOutline?this.outline.visible:!1},isAbleToShowOutline(){return!this.isRichWorkspace}},watch:{showOutlineOutside(){this.outline.visible=this.showOutlineOutside}},mounted(){pt("text:keyboard:outline",this.outlineToggle),this.outline.enable=this.isAbleToShowOutline,this.$watch(()=>this.isAbleToShowOutline,e=>{Object.assign(this.outline,{enable:e})})},beforeDestroy(){Ce("text:keyboard:outline",this.outlineToggle)},methods:{outlineToggle(){this.outline.visible=!this.outline.visible,this.$emit("outline-toggled",this.outline.visible)},readOnlyToggle(){this.$emit("read-only-toggled")}}};var zn=function(){var e=this,n=e._self._c;return n("div",{staticClass:"text-editor__wrapper",class:{"has-conflicts":e.isResolvingConflict,"is-rich-workspace":e.isRichWorkspace,"is-rich-editor":e.isRichEditor}},[e._t("default")],2)},qn=[],Jn=k(jn,zn,qn,!1,null,"ae654636");const Hi=Jn.exports;function Xn(){return navigator?.userAgentData?.mobile!==void 0?navigator.userAgentData.mobile:[/Android/i,/webOS/i,/iPhone/i,/iPad/i,/iPod/i,/playbook/i,/silk/i,/BlackBerry/i,/Windows Phone/i].some(e=>navigator.userAgent.match(e))}const Yn={name:"HelpModal",components:{NcDialog:Be},data(){return{formatted:{bold:!0,italic:!0,strikethrough:!0,heading1:!0,heading6:!0,unorderdList:!0,orderedList:!0,checkList:!0,blockQuote:!0,codeBlock:!0},ctrlOrModKey:ne[ie.Mod]}},computed:{isFormatted(){return e=>this.formatted[e]},isMobileCached(){return this.isMobilePlatform()}},methods:{t:S,toggleFormatted(e){this.formatted[e]=!this.formatted[e]},isMobilePlatform:Xn}};var Qn=function(){var e=this,n=e._self._c;return n("NcDialog",{attrs:{size:"large","data-text-el":"formatting-help",name:e.t("text","Formatting and shortcuts"),"close-on-click-outside":!0},on:{closing:function(i){return e.$emit("close")}}},[n("h2",[e._v(e._s(e.t("text","Formatting and shortcuts")))]),n("p",[e._v(e._s(e.t("text","Speed up your writing with simple shortcuts.")))]),e.isMobileCached?n("p",[e._v(" "+e._s(e.t("text","Just type the Markdown syntax from below."))+" ")]):n("p",[e._v(" "+e._s(e.t("text","Just type the Markdown syntax or use keyboard shortcuts from below."))+" ")]),n("table",[n("thead",[n("tr",[n("th",[e._v(e._s(e.t("text","Style")))]),n("th",[e._v(e._s(e.t("text","Syntax")))]),e.isMobileCached?e._e():n("th",[e._v(" "+e._s(e.t("text","Keyboard shortcuts"))+" ")])])]),n("tbody",[n("tr",[n("td",[e._v(e._s(e.t("text","New paragraph")))]),n("td",[n("kbd",[e._v(e._s(e.t("text","Enter")))])]),e.isMobileCached?e._e():n("td")]),n("tr",[n("td",[e._v(e._s(e.t("text","Hard line break")))]),n("td",[n("kbd",[e._v(e._s(e.t("text","Enter")))]),e._v(" "+e._s(e.t("text","followed by"))+" "),n("kbd",[e._v(e._s(e.t("text","Backspace")))])]),e.isMobileCached?e._e():n("td",[n("kbd",[e._v(e._s(e.t("text","Shift")))]),e._v(" + "),n("kbd",[e._v(e._s(e.t("text","Enter")))])])]),n("tr",[n("td",[e._v(e._s(e.t("text","Bold")))]),n("td",[n("code",[e._v("**"+e._s(e.t("text","Bold text"))+"**")])]),e.isMobileCached?e._e():n("td",[n("kbd",[e._v(e._s(e.ctrlOrModKey))]),e._v(" + "),n("kbd",[e._v("B")])])]),n("tr",[n("td",[e._v(e._s(e.t("text","Italic")))]),n("td",[n("code",[e._v("*"+e._s(e.t("text","Italicized text"))+"*")])]),e.isMobileCached?e._e():n("td",[n("kbd",[e._v(e._s(e.ctrlOrModKey))]),e._v(" + "),n("kbd",[e._v("I")])])]),n("tr",[n("td",[e._v(e._s(e.t("text","Strikethrough")))]),n("td",[n("code",[e._v("~~"+e._s(e.t("text","Mistaken text"))+"~~")])]),e.isMobileCached?e._e():n("td",[n("kbd",[e._v(e._s(e.ctrlOrModKey))]),e._v(" + "),n("kbd",[e._v(e._s(e.t("text","Shift")))]),e._v(" + "),n("kbd",[e._v("S")])])]),n("tr",[n("td",[e._v(e._s(e.t("text","Underline")))]),n("td",[n("code",[e._v("__"+e._s(e.t("text","Underlined text"))+"__")])]),e.isMobileCached?e._e():n("td",[n("kbd",[e._v(e._s(e.ctrlOrModKey))]),e._v(" + "),n("kbd",[e._v("U")])])]),n("tr",[n("td",{staticClass:"ellipsis_top"},[e._v(" "+e._s(e.t("text","Heading 1"))+" ")]),n("td",{staticClass:"ellipsis_top"},[n("code",[e._v("# "+e._s(e.t("text","Heading level 1")))])]),e.isMobileCached?e._e():n("td",{staticClass:"ellipsis_top"},[n("kbd",[e._v(e._s(e.ctrlOrModKey))]),e._v(" + "),n("kbd",[e._v(e._s(e.t("text","Shift")))]),e._v(" + "),n("kbd",[e._v("1")])])]),n("tr",[n("td",{staticClass:"noborder ellipsis"},[e._v("…")]),n("td",{staticClass:"noborder ellipsis"},[e._v("…")]),e.isMobileCached?e._e():n("td",{staticClass:"ellipsis noborder"},[e._v("…")])]),n("tr",[n("td",{staticClass:"noborder ellipsis_bottom"},[e._v(" "+e._s(e.t("text","Heading 6"))+" ")]),n("td",{staticClass:"noborder ellipsis_bottom"},[n("code",[e._v("###### "+e._s(e.t("text","Heading level 6")))])]),e.isMobileCached?e._e():n("td",{staticClass:"noborder ellipsis_bottom"},[n("kbd",[e._v(e._s(e.ctrlOrModKey))]),e._v(" + "),n("kbd",[e._v(e._s(e.t("text","Shift")))]),e._v(" + "),n("kbd",[e._v("6")])])]),n("tr",[n("td",[e._v(e._s(e.t("text","Unordered list")))]),n("td",[n("code",[e._v("* "+e._s(e.t("text","An item")))])]),e.isMobileCached?e._e():n("td",[n("kbd",[e._v(e._s(e.ctrlOrModKey))]),e._v(" + "),n("kbd",[e._v(e._s(e.t("text","Shift")))]),e._v(" + "),n("kbd",[e._v("8")])])]),n("tr",[n("td",[e._v(e._s(e.t("text","Ordered list")))]),n("td",[n("code",[e._v("1. "+e._s(e.t("text","First item")))])]),e.isMobileCached?e._e():n("td",[n("kbd",[e._v(e._s(e.ctrlOrModKey))]),e._v(" + "),n("kbd",[e._v(e._s(e.t("text","Shift")))]),e._v(" + "),n("kbd",[e._v("7")])])]),n("tr",[n("td",[e._v(e._s(e.t("text","Checklist")))]),n("td",[n("code",[e._v("* [] "+e._s(e.t("text","To-Do item")))])]),e.isMobileCached?e._e():n("td",[n("kbd",[e._v(e._s(e.ctrlOrModKey))]),e._v(" + "),n("kbd",[e._v(e._s(e.t("text","Shift")))]),e._v(" + "),n("kbd",[e._v("9")])])]),n("tr",[n("td",[e._v(e._s(e.t("text","Blockquote")))]),n("td",[n("code",[e._v("> "+e._s(e.t("text","Quoted text")))])]),e.isMobileCached?e._e():n("td",[n("kbd",[e._v(e._s(e.ctrlOrModKey))]),e._v(" + "),n("kbd",[e._v(">")])])]),n("tr",[n("td",[e._v(e._s(e.t("text","Code block")))]),n("td",[n("code",[e._v("``` "+e._s(e.t("text","Some code")))])]),e.isMobileCached?e._e():n("td")]),n("tr",[n("td",[e._v(e._s(e.t("text","Link")))]),n("td",[n("code",[e._v("[Title](https://example.org)")])]),e.isMobileCached?e._e():n("td",[n("kbd",[e._v(e._s(e.ctrlOrModKey))]),e._v(" + "),n("kbd",[e._v("K")])])]),n("tr",[n("td",[e._v(e._s(e.t("text","Insert emoji")))]),n("td",[n("code",[e._v(":"+e._s(e.t("text","emoji")))])]),e.isMobileCached?e._e():n("td")]),n("tr",[n("td",[e._v(e._s(e.t("text","Mention someone")))]),n("td",[n("code",[e._v("@"+e._s(e.t("text","name")))])]),e.isMobileCached?e._e():n("td")]),n("tr",[n("td",[e._v(e._s(e.t("text","Smart picker")))]),n("td",[n("code",[e._v("/"+e._s(e.t("text","something")))])]),e.isMobileCached?e._e():n("td")])])]),n("table",{attrs:{vif:"!isMobileCached"}},[n("thead",[n("tr",[n("th",[e._v(e._s(e.t("text","Action")))]),n("th",[e._v(e._s(e.t("text","Keyboard shortcuts")))])])]),n("tbody",[n("tr",[n("td",[e._v(e._s(e.t("text","Undo")))]),n("td",[n("kbd",[e._v(e._s(e.ctrlOrModKey))]),e._v(" + "),n("kbd",[e._v("Z")])])]),n("tr",[n("td",[e._v(e._s(e.t("text","Redo")))]),n("td",[n("kbd",[e._v(e._s(e.ctrlOrModKey))]),e._v(" + "),n("kbd",[e._v("Y")])])]),n("tr",[n("td",[e._v(e._s(e.t("text","Toggle outline")))]),n("td",[n("kbd",[e._v(e._s(e.ctrlOrModKey))]),e._v(" + "),n("kbd",[e._v(e._s(e.t("text","Alt")))]),e._v(" + "),n("kbd",[e._v("H")])])])])])])},Zn=[],Gn=k(Yn,Qn,Zn,!1,null,"5bb25ea4");const ti=Gn.exports,ei=O({name:"NcActionButton",components:{NextcloudVueNcActionButton:st,Help:se},methods:{t:S}});var ni=function(){var e=this,n=e._self._c;return e._self._setupProxy,n("NextcloudVueNcActionButton",e._g({attrs:{"close-after-click":"","data-text-action-entry":"formatting-help"},scopedSlots:e._u([{key:"icon",fn:function(){return[n("Help")]},proxy:!0}])},e.$listeners),[e._v(" "+e._s(e.t("text","Formatting help"))+" ")])},ii=[],si=k(ei,ni,ii,!1,null,null);const oi=si.exports,ai=O({name:"CharacterCount",components:{AlphabeticalVariant:ae,NcActionText:oe},props:{visible:Boolean},setup(){const{editor:e}=$(),n=E("");return{countString:n,refresh:()=>{const{storage:i,state:s}=e,o=i.characterCount.words({node:s.doc}),a=i.characterCount.characters({node:s.doc}),r=Y("text","%n word","%n words",o),l=Y("text","%n char","%n chars",a);n.value=[r,l].join(", "),console.debug({wordCount:o,charCount:a,countString:n.value})}}},watch:{visible:"refresh"},created(){this.refresh()}});var ri=function(){var e=this,n=e._self._c;return e._self._setupProxy,n("NcActionText",{attrs:{"data-text-action-entry":"character-count",name:e.countString},scopedSlots:e._u([{key:"icon",fn:function(){return[n("AlphabeticalVariant")]},proxy:!0}])})},li=[],di=k(ai,ri,li,!1,null,null);const ci=di.exports,ui={__name:"WidthToggle",setup(e){const{canToggleWidth:n,isFullWidth:i,setFullWidth:s}=yt();return{__sfc:!0,canToggleWidth:n,isFullWidth:i,setFullWidth:s,t:S,NcActionCheckbox:an}}};var hi=function(){var e=this,n=e._self._c,i=e._self._setupProxy;return i.canToggleWidth?n(i.NcActionCheckbox,{attrs:{checked:i.isFullWidth},on:{"update:checked":i.setFullWidth}},[e._v(" "+e._s(i.t("text","Full width editor"))+" ")]):e._e()},pi=[],mi=k(ui,hi,pi,!1,null,null);const gi=mi.exports,fi={name:"MenuBar",components:{ActionFormattingHelp:oi,ActionList:gt,ActionSingle:ft,HelpModal:ti,NcActionSeparator:at,CharacterCount:ci,WidthToggle:gi},extends:vt,mixins:[ct],provide(){const e={};return Object.defineProperties(e,{[ce]:{get:()=>this.randomID}}),e},props:{isHidden:{type:Boolean,default:!1},openReadOnly:{type:Boolean,default:!1}},setup(){const e=$(),{isPublic:n,isRichEditor:i,isRichWorkspace:s}=R(),o=E(),{width:a}=ut(o);return{editor:e,isPublic:n,isRichEditor:i,isRichWorkspace:s,menubar:o,width:a}},data(){return{entries:(this.openReadOnly?[...le,...D]:this.isPublic||this.isRichWorkSpace?[...D]:[...D,...de]).filter(e=>!!e),randomID:`menu-bar-${Math.ceil(Math.random()*1e4+500).toString(16)}`,displayHelp:!1,isReady:!1,resize:null}},computed:{visibleEntryKeys(){return this.entries.toSorted((e,n)=>(e.priority??0)-(n.priority??0)).map(e=>e.key).slice(0,this.iconsLimit)},visibleEntries(){return this.entries.filter(e=>this.visibleEntryKeys.includes(e.key))},hiddenEntries(){const e=this.entries.filter(i=>!this.visibleEntryKeys.includes(i.key)),n=e.reduce((i,s,o)=>{const a=s.children??[s];if(a.length>1){const r=i.length&&!i.at(-1).isSeparator?[{key:`separator-before-${s.id}`,isSeparator:!0}]:[],l=o!==e.length-1?[{key:`separator-after-${s.id}`,isSeparator:!0}]:[];return[...i,...r,...a,...l]}return[...i,...a]},[]);return{key:"remain",label:this.t("text","Remaining actions"),icon:re,children:n}},iconWidth(){const e=(this.menubar&&getComputedStyle(this.menubar))?.getPropertyValue("--default-clickable-area");return parseInt(e)||34},iconsLimit(){const e=this.width-4,n=this.$isMobile?this.iconWidth:this.iconWidth+2;return Math.floor(e/n)-1}},mounted(){this.$nextTick(()=>{this.isReady=!0,this.$emit("update:loaded",!0)})},methods:{showHelp(){this.displayHelp=!0},hideHelp(){this.displayHelp=!1},t:S}};var vi=function(){var e=this,n=e._self._c;return n("div",{staticClass:"text-menubar",class:{"text-menubar--ready":e.isReady,"text-menubar--hide":e.isHidden,"text-menubar--is-workspace":e.isRichWorkspace,"is-mobile":e.$isMobile},attrs:{id:e.randomID,"data-text-el":"menubar",role:"region","aria-label":e.t("text","Editor actions")}},[e.displayHelp?n("HelpModal",{on:{close:e.hideHelp}}):e._e(),e.isRichEditor?n("div",{ref:"menubar",staticClass:"text-menubar__entries",attrs:{role:"toolbar","aria-label":e.t("text","Formatting menu bar")},on:{keyup:[function(i){return!i.type.indexOf("key")&&e._k(i.keyCode,"left",37,i.key,["Left","ArrowLeft"])||"button"in i&&i.button!==0?null:(i.stopPropagation(),e.handleToolbarNavigation.apply(null,arguments))},function(i){return!i.type.indexOf("key")&&e._k(i.keyCode,"right",39,i.key,["Right","ArrowRight"])||"button"in i&&i.button!==2?null:(i.stopPropagation(),e.handleToolbarNavigation.apply(null,arguments))}]}},[e._l(e.visibleEntries,function(i,s){return n(i.component?i.component:i.children?"ActionList":"ActionSingle",{key:i.key,ref:"menuEntries",refInFor:!0,tag:"component",attrs:{"action-entry":i,"can-be-focussed":e.activeMenuEntry===s},on:{disabled:function(o){return e.disableMenuEntry(i.key,o)},click:function(o){e.activeMenuEntry=s}}})}),n("ActionList",{ref:"remainingEntries",attrs:{"action-entry":e.hiddenEntries,"can-be-focussed":e.activeMenuEntry===e.visibleEntries.length,"force-enabled":!0},on:{click:function(i){e.activeMenuEntry="remain"}},scopedSlots:e._u([{key:"lastAction",fn:function({visible:i}){return[n("WidthToggle"),n("ActionFormattingHelp",{on:{click:e.showHelp}}),n("NcActionSeparator"),n("CharacterCount",e._b({},"CharacterCount",{visible:i},!1))]}}],null,!1,4216951189)})],2):e._e(),n("div",{staticClass:"text-menubar__slot"},[e._t("default")],2)],1)},yi=[],_i=k(fi,vi,yi,!1,null,"6704c502");const Di=_i.exports;export{Fi as A,Bi as C,Ri as M,Be as N,Ii as R,Hi as W,Di as a,Ti as b,Pi as p};
//# sourceMappingURL=MenuBar-aZwqxDEv.chunk.mjs.map