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