f7cloud_client/apps/text/js/Wrapper-CwuUv6cL.chunk.mjs
root 8b6a0139db f7cloud_client
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-17 22:59:26 +00:00

3 lines
25 KiB
JavaScript

import{i as A,Q as k,S as b,T as et,U as nt,V as ot,W as st,Y as it,X as rt,k as H,Z as at,_ as dt,j as _,$ as lt,a0 as V,a1 as ct,a2 as ht,a3 as pt,a4 as ut,a5 as mt,a6 as gt,a7 as ft,o as R,b as vt,f as yt,g as wt,a8 as X,w as q,l as kt,a9 as bt,aa as xt,ab as Ot}from"./EditorOutline-CZg3-0Pd.chunk.mjs";import{c as F,t as St}from"./NcLoadingIcon-zQCGdPwE.chunk.mjs";import{s as Y,e as J,a as Mt,u as Ct}from"./index-CYtgifWR.chunk.mjs";import{l as $t}from"./index-D3wiQe9-.chunk.mjs";import{g as S}from"./index-DxwFe63_.chunk.mjs";import{r as At,p as U,e as _t,c as Ft,w as Pt,i as Dt,V as Et,j as I}from"./vue.runtime.esm-fahCO3eG.chunk.mjs";import{b as Tt,s as O}from"./NcNoteCard-CwNXZ4vV-dRcgmGN6.chunk.mjs";import{n as x}from"./_plugin-vue2_normalizer-wd1ZAbRr.chunk.mjs";import{u as Ht,S as Rt,c as It,d as Nt,b as Vt,e as Ut}from"./MediaHandler.provider-BQ5p2YTP.chunk.mjs";import{l as M}from"./logger-DEhDull1.chunk.mjs";const Bt=e=>k.getState(e)?.undoManager?.undo()!=null,Wt=e=>k.getState(e)?.undoManager?.redo()!=null,zt=new Set(["paragraph"]),Lt=(e,n)=>!(e instanceof ot)||!(e.content instanceof st)||!(e.content.type instanceof it||e.content.type instanceof rt&&n.has(e.content.type.nodeName))||e.content.type._length===0,Kt=({protectedNodes:e=zt,trackedOrigins:n=[],undoManager:o=null}={})=>new A({key:k,state:{init:(s,r)=>{const a=b.getState(r),i=o||new nt(a.type,{trackedOrigins:new Set([b].concat(n)),deleteFilter:d=>Lt(d,e),captureTransaction:d=>d.meta.get("addToHistory")!==!1});return{undoManager:i,prevSel:null,hasUndoOps:i.undoStack.length>0,hasRedoOps:i.redoStack.length>0}},apply:(s,r,a,i)=>{const d=b.getState(i).binding,c=r.undoManager,l=c.undoStack.length>0,p=c.redoStack.length>0;return d?{undoManager:c,prevSel:et(d,a),hasUndoOps:l,hasRedoOps:p}:l!==r.hasUndoOps||p!==r.hasRedoOps?Object.assign({},r,{hasUndoOps:c.undoStack.length>0,hasRedoOps:c.redoStack.length>0}):r}},view:s=>{const r=b.getState(s.state),a=k.getState(s.state).undoManager;return a.on("stack-item-added",({stackItem:i})=>{const d=r.binding;d&&i.meta.set(d,k.getState(s.state).prevSel)}),a.on("stack-item-popped",({stackItem:i})=>{const d=r.binding;d&&(d.beforeTransactionSelection=i.meta.get(d)||d.beforeTransactionSelection)}),{destroy:()=>{a.destroy()}}}}),ze=H.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:o})=>(e.setMeta("preventDispatch",!0),k.getState(n).undoManager.undoStack.length===0?!1:o?Bt(n):!0),redo:()=>({tr:e,state:n,dispatch:o})=>(e.setMeta("preventDispatch",!0),k.getState(n).undoManager.redoStack.length===0?!1:o?Wt(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),o=Kt(this.options.yUndoOptions),s=o.spec.view;o.spec.view=i=>{const{undoManager:d}=k.getState(i.state);d.restore&&(d.restore(),d.restore=()=>{});const c=s?s(i):void 0;return{destroy:()=>{const l=d.trackedOrigins.has(d),p=d._observers;d.restore=()=>{l&&d.trackedOrigins.add(d),d.doc.on("afterTransaction",d.afterTransactionHandler),d._observers=p},c?.destroy&&c.destroy()}}};const r={...this.options.ySyncOptions,onFirstRender:this.options.onFirstRender},a=at(n,r);return this.editor.options.enableContentCheck&&((e=n.doc)===null||e===void 0||e.on("beforeTransaction",()=>{try{const i=dt(n);if(i.content.length===0)return;this.editor.schema.nodeFromJSON(i).check()}catch(i){return this.editor.emit("contentError",{error:i,editor:this.editor,disableCollaboration:()=>{var d;(d=n.doc)===null||d===void 0||d.destroy(),this.storage.isDisabled=!0}}),!1}})),[a,o,this.editor.options.enableContentCheck&&new A({key:new _("filterInvalidContent"),filterTransaction:()=>{var i;return this.storage.isDisabled&&((i=n.doc)===null||i===void 0||i.destroy()),!0}})].filter(Boolean)}});function jt(e){return!!e.getMeta(b)}let B=$t("text","is_full_width_editor",!1);const T=Symbol("text:editor:width");function Xt(){const e=getComputedStyle(document.body).getPropertyValue("--text-editor-max-width"),n=document.documentElement.style.getPropertyValue("--text-editor-max-width");return!!e&&e!==n}const Le=()=>{if(Xt())return U(T,null),{applyEditorWidth:()=>{}};const e=At(B);U(T,_t(e)),Y("text:editor:full-width",({value:s})=>{B=s,e.value=s});const n=Ft(()=>e.value?"100%":"80ch"),o=()=>{document.documentElement.style.setProperty("--text-editor-max-width",n.value)};return Pt(n,o),{applyEditorWidth:o}},qt=()=>{const e=Dt(T);return e===null?{canToggleWidth:!1}:{canToggleWidth:!0,isFullWidth:e,setFullWidth:n=>{F.post(S("/apps/text/settings"),{key:"is_full_width_editor",value:n?"1":"0"}),J("text:editor:full-width",{value:n})}}};function W(e){if(!e.length)return V.empty;const n=[],o=e[0].$from.node(0);return e.forEach(s=>{const r=s.$from.pos,a=s.$from.nodeAfter;a&&n.push(ct.node(r,r+a.nodeSize,{class:"ProseMirror-selectednoderange"}))}),V.create(o,n)}function P(e,n,o){const s=[],r=e.node(0);o=typeof o=="number"&&o>=0?o:e.sameParent(n)?Math.max(0,e.sharedDepth(n.pos)-1):e.sharedDepth(n.pos);const a=new ht(e,n,o),i=a.depth===0?0:r.resolve(a.start).posAtIndex(0);return a.parent.forEach((d,c)=>{const l=i+c,p=l+d.nodeSize;if(l<a.start||l>=a.end)return;const h=new pt(r.resolve(l),r.resolve(p));s.push(h)}),s}class N{constructor(n,o){this.anchor=n,this.head=o}map(n){return new N(n.map(this.anchor),n.map(this.head))}resolve(n){const o=n.resolve(this.anchor),s=n.resolve(this.head);return new v(o,s)}}class v extends lt{constructor(n,o,s,r=1){const{doc:a}=n,i=n===o,d=n.pos===a.content.size&&o.pos===a.content.size,c=i&&!d?a.resolve(o.pos+(r>0?1:-1)):o,l=i&&d?a.resolve(n.pos-(r>0?1:-1)):n,p=P(l.min(c),l.max(c),s),h=c.pos>=n.pos?p[0].$from:p[p.length-1].$to,u=c.pos>=n.pos?p[p.length-1].$to:p[0].$from;super(h,u,p),this.depth=s}get $to(){return this.ranges[this.ranges.length-1].$to}eq(n){return n instanceof v&&n.$from.pos===this.$from.pos&&n.$to.pos===this.$to.pos}map(n,o){const s=n.resolve(o.map(this.anchor)),r=n.resolve(o.map(this.head));return new v(s,r)}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 r=this.ranges.slice(0,-1),a=r[0].$from,i=r[r.length-1].$to;return new v(a,i,this.depth)}const o=this.ranges[0],s=n.resolve(Math.max(0,o.$from.pos-1));return new v(this.$anchor,s,this.depth)}extendForwards(){const{doc:n}=this.$from;if(this.isBackwards&&this.ranges.length>1){const r=this.ranges.slice(1),a=r[0].$from,i=r[r.length-1].$to;return new v(i,a,this.depth)}const o=this.ranges[this.ranges.length-1],s=n.resolve(Math.min(n.content.size,o.$to.pos+1));return new v(this.$anchor,s,this.depth)}static fromJSON(n,o){return new v(n.resolve(o.anchor),n.resolve(o.head))}static create(n,o,s,r,a=1){return new this(n.resolve(o),n.resolve(s),r,a)}getBookmark(){return new N(this.anchor,this.head)}}v.prototype.visible=!1;function C(e){return e instanceof v}H.create({name:"nodeRange",addOptions(){return{depth:void 0,key:"Mod"}},addKeyboardShortcuts(){return{"Shift-ArrowUp":({editor:e})=>{const{depth:n}=this.options,{view:o,state:s}=e,{doc:r,selection:a,tr:i}=s,{anchor:d,head:c}=a;if(!C(a)){const p=v.create(r,d,c,n,-1);return i.setSelection(p),o.dispatch(i),!0}const l=a.extendBackwards();return i.setSelection(l),o.dispatch(i),!0},"Shift-ArrowDown":({editor:e})=>{const{depth:n}=this.options,{view:o,state:s}=e,{doc:r,selection:a,tr:i}=s,{anchor:d,head:c}=a;if(!C(a)){const p=v.create(r,d,c,n);return i.setSelection(p),o.dispatch(i),!0}const l=a.extendForwards();return i.setSelection(l),o.dispatch(i),!0},"Mod-a":({editor:e})=>{const{depth:n}=this.options,{view:o,state:s}=e,{doc:r,tr:a}=s,i=v.create(r,0,r.content.size,n);return a.setSelection(i),o.dispatch(a),!0}}},onSelectionUpdate(){const{selection:e}=this.editor.state;C(e)&&this.editor.view.dom.classList.add("ProseMirror-noderangeselection")},addProseMirrorPlugins(){let e=!1,n=!1;return[new A({key:new _("nodeRange"),props:{attributes:()=>e?{class:"ProseMirror-noderangeselection"}:{class:""},handleDOMEvents:{mousedown:(o,s)=>{const{key:r}=this.options,a=/Mac/.test(navigator.platform),i=!!s.shiftKey,d=!!s.ctrlKey,c=!!s.altKey,l=!!s.metaKey,p=a?l:d;return(r==null||r==="Shift"&&i||r==="Control"&&d||r==="Alt"&&c||r==="Meta"&&l||r==="Mod"&&p)&&(n=!0),n&&document.addEventListener("mouseup",()=>{n=!1;const{state:h}=o,{doc:u,selection:w,tr:m}=h,{$anchor:g,$head:y}=w;if(g.sameParent(y))return;const f=v.create(u,g.pos,y.pos,this.options.depth);m.setSelection(f),o.dispatch(m)},{once:!0}),!1}},decorations:o=>{const{selection:s}=o,r=C(s);if(e=!1,!n)return r?(e=!0,W(s.ranges)):null;const{$from:a,$to:i}=s;if(!r&&a.sameParent(i))return null;const d=P(a,i,this.options.depth);return d.length?(e=!0,W(d)):null}}})]}});function Yt(e){let n="";const o=getComputedStyle(e);for(let s=0;s<o.length;s+=1)n+=`${o[s]}:${o.getPropertyValue(o[s])};`;return n}function Jt(e){const n=e.cloneNode(!0),o=[e,...Array.from(e.getElementsByTagName("*"))],s=[n,...Array.from(n.getElementsByTagName("*"))];return o.forEach((r,a)=>{s[a].style.cssText=Yt(r)}),n}const Z=e=>{const{x:n,y:o,direction:s,editor:r}=e;let a=null,i=null,d=null,c=n;for(;i===null&&c<window.innerWidth&&c>0;){const l=document.elementsFromPoint(c,o),p=l.findIndex(u=>u.classList.contains("ProseMirror")),h=l.slice(0,p);if(h.length>0){const u=h[0];if(a=u,d=r.view.posAtDOM(u,0),d>=0){i=r.state.doc.nodeAt(Math.max(d-1,0)),i?.isText&&(i=r.state.doc.nodeAt(Math.max(d-1,0))),i||(i=r.state.doc.nodeAt(Math.max(d,0)));break}}s==="left"?c-=1:c+=1}return{resultElement:a,resultNode:i,pos:d??null}};function $(e,n){return window.getComputedStyle(e)[n]}function Zt(e=0,n=0,o=0){return Math.min(Math.max(e,n),o)}function Qt(e,n,o){const s=parseInt($(e.dom,"paddingLeft"),10),r=parseInt($(e.dom,"paddingRight"),10),a=parseInt($(e.dom,"borderLeftWidth"),10),i=parseInt($(e.dom,"borderLeftWidth"),10),d=e.dom.getBoundingClientRect();return{left:Zt(n,d.left+s+a,d.right-r-i),top:o}}function Q(e){var n;(n=e.parentNode)===null||n===void 0||n.removeChild(e)}function Gt(e,n){const{doc:o}=n.view.state,s=Z({editor:n,x:e.clientX,y:e.clientY,direction:"right"});if(!s.resultNode||s.pos===null)return[];const r=e.clientX,a=Qt(n.view,r,e.clientY),i=n.view.posAtCoords(a);if(!i)return[];const{pos:d}=i;if(!o.resolve(d).parent)return[];const c=o.resolve(s.pos),l=o.resolve(s.pos+1);return P(c,l,0)}function te(e,n){const{view:o}=n;if(!e.dataTransfer)return;const{empty:s,$from:r,$to:a}=o.state.selection,i=Gt(e,n),d=P(r,a,0),c=d.some(y=>i.find(f=>f.$from===y.$from&&f.$to===y.$to)),l=s||!c?i:d;if(!l.length)return;const{tr:p}=o.state,h=document.createElement("div"),u=l[0].$from.pos,w=l[l.length-1].$to.pos,m=v.create(o.state.doc,u,w),g=m.content();l.forEach(y=>{const f=o.nodeDOM(y.$from.pos),D=Jt(f);h.append(D)}),h.style.position="absolute",h.style.top="-10000px",document.body.append(h),e.dataTransfer.clearData(),e.dataTransfer.setDragImage(h,0,0),o.dragging={slice:g,move:!0},p.setSelection(m),o.dispatch(p),document.addEventListener("drop",()=>Q(h),{once:!0})}const z=(e,n)=>{const o=e.resolve(n),{depth:s}=o;return s===0?n:o.pos-o.parentOffset-1},L=(e,n)=>{const o=e.nodeAt(n),s=e.resolve(n);let{depth:r}=s,a=o;for(;r>0;){const i=s.node(r);r-=1,r===0&&(a=i)}return a},E=(e,n)=>{const o=b.getState(e);return o?mt(n,o.type,o.binding.mapping):null},ee=(e,n)=>{const o=b.getState(e);return o?gt(o.doc,o.type,n,o.binding.mapping)||0:-1},K=(e,n)=>{let o=n;for(;o&&o.parentNode&&o.parentNode!==e.dom;)o=o.parentNode;return o},G=new _("dragHandle"),tt=({pluginKey:e=G,element:n,editor:o,tippyOptions:s,onNodeChange:r})=>{const a=document.createElement("div");let i=null,d=!1,c=null,l=-1,p;return n.addEventListener("dragstart",h=>{te(h,o),setTimeout(()=>{n&&(n.style.pointerEvents="none")},0)}),n.addEventListener("dragend",()=>{n&&(n.style.pointerEvents="auto")}),new A({key:typeof e=="string"?new _(e):e,state:{init(){return{locked:!1}},apply(h,u,w,m){const g=h.getMeta("lockDragHandle"),y=h.getMeta("hideDragHandle");if(g!==void 0&&(d=g),y&&i)return i.hide(),d=!1,c=null,l=-1,r?.({editor:o,node:null,pos:-1}),u;if(h.docChanged&&l!==-1&&n&&i)if(jt(h)){const f=ee(m,p);f!==l&&(l=f)}else{const f=h.mapping.map(l);f!==l&&(l=f,p=E(m,l))}return u}},view:h=>{var u;return n.draggable=!0,n.style.pointerEvents="auto",(u=o.view.dom.parentElement)===null||u===void 0||u.appendChild(a),a.appendChild(n),a.style.pointerEvents="none",a.style.position="absolute",a.style.top="0",a.style.left="0",{update(w,m){if(!n)return;if(!o.isEditable){i?.destroy(),i=null;return}if(i||(i=ut(h.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})),d?n.draggable=!1:n.draggable=!0,h.state.doc.eq(m.doc)||l===-1)return;let g=h.nodeDOM(l);if(g=K(h,g),g===h.dom||g?.nodeType!==1)return;const y=h.posAtDOM(g,0),f=L(o.state.doc,y),D=z(o.state.doc,y);c=f,l=D,p=E(h.state,l),r?.({editor:o,node:c,pos:l}),i.setProps({getReferenceClientRect:()=>g.getBoundingClientRect()})},destroy(){i?.destroy(),n&&Q(a)}}},props:{handleDOMEvents:{keydown(h){return i&&i.state.isVisible&&h.hasFocus()&&i.hide(),!1},mouseleave(h,u){return d||u.target&&!a.contains(u.relatedTarget)&&(i?.hide(),c=null,l=-1,r?.({editor:o,node:null,pos:-1})),!1},mousemove(h,u){if(!n||!i||d)return!1;const w=Z({x:u.clientX,y:u.clientY,direction:"right",editor:o});if(!w.resultElement)return!1;let m=w.resultElement;if(m=K(h,m),m===h.dom||m?.nodeType!==1)return!1;const g=h.posAtDOM(m,0),y=L(o.state.doc,g);if(y!==c){const f=z(o.state.doc,g);c=y,l=f,p=E(h.state,l),r?.({editor:o,node:c,pos:l}),i.setProps({getReferenceClientRect:()=>m.getBoundingClientRect()}),i.show()}return!1}}}})};H.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[tt({tippyOptions:this.options.tippyOptions,element:e,editor:this.editor,onNodeChange:this.options.onNodeChange})]}});const ne=Et.extend({name:"DragHandleVue",props:{pluginKey:{type:[String,Object],default:()=>G},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:o,tippyOptions:s}=this.$props;e.registerPlugin(tt({editor:e,element:this.$el,pluginKey:n,tippyOptions:s,onNodeChange:o}))},beforeDestroy(){const{pluginKey:e,editor:n}=this.$props;n.unregisterPlugin(e)},render(e){return e("div",{class:this.class},this.$slots.default)}}),oe={name:"DragVerticalIcon",emits:["click"],props:{title:{type:String},fillColor:{type:String,default:"currentColor"},size:{type:Number,default:24}}};var se=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(o){return e.$emit("click",o)}}},"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()])])])},ie=[],re=x(oe,se,ie,!1,null,null);const ae=re.exports,de={name:"FloatingButtons",components:{DragHandle:ne,DragVerticalIcon:ae,NcButton:Tt,PlusIcon:ft},setup(){const{editor:e}=R();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(o=>o.type===e.nodes.text))?this.pos+1:this.pos+this.node.nodeSize;this.editor.chain().insertContentAt(n,"/").focus().run()},t:St}};var le=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"),"aria-label":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"),"aria-label":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)},ce=[],he=x(de,le,ce,!1,null,"df42177f");const pe=he.exports,ue={name:"ContentContainer",components:{EditorContent:wt,EditorOutline:yt,FloatingButtons:pe},mixins:[vt],props:{readOnly:{type:Boolean,required:!0}},setup(){const e=X(),{editor:n}=R(),{isRichEditor:o,isRichWorkspace:s}=q(),{isFullWidth:r}=qt();return{editor:n,isMobile:e,isFullWidth:r,isRichEditor:o,isRichWorkspace:s}},computed:{showOutline(){return this.$outlineState.visible},showFloatingButtons(){return!this.readOnly&&!this.isMobile&&!this.isFullWidth&&this.isRichEditor&&!this.isRichWorkspace}}};var me=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)},ge=[],fe=x(ue,me,ge,!1,null,"86ce242a");const Ke=fe.exports;function ve(e,n){const{documentId:o,sessionId:s,sessionToken:r,shareToken:a}=I(e),i=new FormData;i.append("file",n);const d=S("apps/text/attachment/upload?");return F.post(d,i,{headers:{"Content-Type":"multipart/form-data"},params:{documentId:o,sessionId:s,sessionToken:r,token:a}})}function ye(e,n){const{documentId:o,sessionId:s,sessionToken:r}=I(e),a=S("apps/text/attachment/create");return F.post(a,{documentId:o,sessionId:s,sessionToken:r,fileName:`${n.app}${n.extension}`})}function we(e,n){const{documentId:o,sessionId:s,sessionToken:r}=I(e),a=S("apps/text/attachment/filepath");return F.post(a,{documentId:o,sessionId:s,sessionToken:r,filePath:n})}const j=e=>e.split("/").slice(0,-1).join("/"),ke={name:"MediaHandler",mixins:[Ht],provide(){const e={};return Object.defineProperties(e,{[Vt]:{get:()=>this.showAttachmentPrompt},[Nt]:{get:()=>this.chooseLocalFile},[It]:{get:()=>this.createAttachment},[Rt]:{get:()=>this.state}}),e},setup(){const{connection:e}=kt(),n=X(),{editor:o}=R();return{connection:e,editor:o,isMobile:n}},data(){return{lastFilePath:null,draggedOver:!1,state:{isUploadingAttachments:!1}}},computed:{initialFilePath(){return this.lastFilePath??j(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 o=[...e].map(s=>this.uploadAttachmentFile(s,n));return Promise.all(o).catch(s=>{M.error("Uploading multiple attachments failed",{error:s}),O(t("text","Uploading multiple attachments failed."))}).then(()=>{this.state.isUploadingAttachments=!1})},async uploadAttachmentFile(e,n=null){return this.state.isUploadingAttachments=!0,ve(this.connection,e).then(o=>{this.insertAttachment(o.data?.name,o.data?.id,e.type,n,o.data?.dirname)}).catch(o=>{M.error("Uploading attachment failed",{error:o}),o.response?.data.error?O(t("text","Uploading attachment failed: {error}",{error:o.response.data.error})):O(t("text","Uploading attachment failed."))}).then(()=>{this.state.isUploadingAttachments=!1})},showAttachmentPrompt(){Mt()&&OC.dialogs.filepicker(t("text","Insert an attachment"),e=>{this.insertFromPath(e)},!1,[],!0,void 0,this.initialFilePath)},insertFromPath(e){return this.lastFilePath=j(e),this.state.isUploadingAttachments=!0,we(this.connection,e).then(n=>{this.insertAttachment(n.data?.name,n.data?.id,n.data?.mimetype,null,n.data?.dirname)}).catch(n=>{M.error("Failed to insert from Files",{error:n}),O(t("text","Failed to insert from Files"))}).then(()=>{this.state.isUploadingAttachments=!1})},createAttachment(e){return this.state.isUploadingAttachments=!0,ye(this.connection,e).then(n=>{this.insertAttachmentPreview(n.data?.id)}).catch(n=>{M.error("Failed to create attachment",{error:n}),O(t("text","Failed to create attachment"))}).then(()=>{this.state.isUploadingAttachments=!1})},insertAttachmentPreview(e){const n=new URL(S(`/f/${e}`),window.origin).href.replaceAll(" ","%20");this.editor.chain().focus().insertPreview(n).run()},insertAttachment(e,n,o,s=null,r=""){const a=r+"/"+encodeURIComponent(e).replace(/[!'()*]/g,c=>"%"+c.charCodeAt(0).toString(16).toUpperCase()),i=e.replaceAll(/[[\]]/g,"");(s?this.editor.chain().focus(s):this.editor.chain()).setImage({src:a,alt:i}).run();const d=this.editor.view.state.selection;d.empty||this.editor.commands.focus(d.to),this.editor.commands.scrollIntoView(),this.editor.commands.setMeta("insertedAttachmentSrc",{src:a}),J("text:image-node:add",null)}}};var be=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(o){return o.preventDefault(),o.stopPropagation(),e.setDraggedOver(!0,o)},dragleave:function(o){return o.preventDefault(),o.stopPropagation(),e.setDraggedOver(!1,o)},drop:function(o){return o.preventDefault(),o.stopPropagation(),e.setDraggedOver(!1,o)},"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)},xe=[],Oe=x(ke,be,xe,!1,null,null);const Se=Oe.exports,Me={name:"MainContainer",components:{MediaHandler:Se},mixins:[Ut]};var Ce=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)},$e=[],Ae=x(Me,Ce,$e,!1,null,"e0c9a19c");const je=Ae.exports,_e={name:"Wrapper",provide(){const e={};return Object.defineProperties(e,{[Ot]:{get:()=>this.outline},[xt]:{get:()=>({toggle:this.outlineToggle})},[bt]:{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}=q();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(){Y("text:keyboard:outline",this.outlineToggle),this.outline.enable=this.isAbleToShowOutline,this.$watch(()=>this.isAbleToShowOutline,e=>{Object.assign(this.outline,{enable:e})})},beforeDestroy(){Ct("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 Fe=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)},Pe=[],De=x(_e,Fe,Pe,!1,null,"ae654636");const Xe=De.exports;export{Ke as C,je as M,Xe as W,ze as a,Le as p,qt as u};
//# sourceMappingURL=Wrapper-CwuUv6cL.chunk.mjs.map