import{r as g}from"./request-CEvu378m.js";import{k as A}from"./shortcutKey-3uH2JNiu.js";import{r,ax as C,c as S,j as B,X as P,B as v,z as y,D as x,W as c,H as j}from"./vue-BJk78QHK.js";import{_ as E}from"./index-M_JNBppB.js";import"./element-3_pOinej.js";import"./utils-YI6ye1sf.js";import"./threejs-BafxXW5-.js";import"./vxe-Dx3zSILm.js";const I=["contenteditable","innerHTML"],O={key:1,class:"v-text preview"},R=["innerHTML"],F=Object.assign({name:"VText"},{__name:"VText",props:{propValue:{type:String,required:!0,default:""},request:{type:Object,default:()=>({})},element:{type:Object,default:()=>({})},linkage:{type:Object,default:()=>({})}},emits:["input"],setup(n,{emit:b}){const t=n,d=b,l=r(!1),f=r(17),u=r(!1),i=r(null),m=r(null),s=C(),h=S(()=>s.state.editMode);B(()=>{var e,a;t.request&&(i.value=g(t.request,t.element,"propValue","string")),((a=(e=t.request)==null?void 0:e.global)==null?void 0:a.length)>0&&s.watch(()=>s.state.globalKey,()=>{const o=[];t.request.global.forEach(z=>{const p=s.state.globalKey.findIndex(D=>D.globalKey===z);o.push([s.state.globalKey[p].globalKey,s.state.globalKey[p].globalValue])});const L=t.request.data.concat(o);t.request.data=L,i.value(),i.value=g(t.request,t.element,"propValue","string")},{deep:!0})}),P(()=>{t.request&&i.value&&i.value()});function k(e){d("input",t.element,e.target.innerHTML)}function M(e){l.value&&e.stopPropagation(),e.keyCode==f.value?u.value=!0:(u.value&&l.value&&A.includes(e.keyCode)||e.keyCode==46)&&e.stopPropagation()}function T(e){l.value&&e.stopPropagation(),e.keyCode==f.value&&(u.value=!1)}function V(e){l.value&&e.stopPropagation()}function q(e){e.preventDefault();const o=e.clipboardData.getData("text/plain")||"";o!==""&&document.execCommand("insertText",!1,o),d("input",t.element,e.target.innerHTML)}function K(e){t.element.propValue=e.target.innerHTML||"",e.target.innerHTML!==""?t.element.propValue=e.target.innerHTML:t.element.propValue="",l.value=!1}function w(){t.element.isLock||(l.value?l.value=!1:(l.value=!0,H(m.value)))}function H(e){const a=window.getSelection(),o=document.createRange();o.selectNodeContents(e),a.removeAllRanges(),a.addRange(o)}return(e,a)=>h.value=="edit"?(y(),v("div",{key:0,style:c({verticalAlign:n.element.style.verticalAlign,"font-zise":n.element.style.fontSize}),class:"v-text",onKeydown:M,onKeyup:T},[x("div",{ref_key:"text",ref:m,contenteditable:l.value,class:j({"can-edit":l.value}),tabindex:"0",style:c({verticalAlign:n.element.style.verticalAlign,"font-zise":n.element.style.fontSize,"font-family":n.element.style.fontFamily}),onDblclick:w,onPaste:q,onMousedown:V,onBlur:K,onInput:k,innerHTML:n.element.propValue},null,46,I)],36)):(y(),v("div",O,[x("div",{style:c([{verticalAlign:n.element.style.verticalAlign,"font-zise":n.element.style.fontSize},{"font-family":"AlimamaDongFangDaKai"}]),innerHTML:n.element.propValue},null,12,R)]))}}),Z=E(F,[["__scopeId","data-v-0cceed1d"]]);export{Z as default};
