@chenyomi/leafer-htmltext-edit 2.1.6 → 2.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';var editor=require('@leafer-in/editor'),leaferUi=require('leafer-ui'),core=require('@leafer-ui/core'),m=require('quill');require('quill/dist/quill.core.css');var font=require('quill/formats/font'),html=require('@leafer-in/html');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var m__default=/*#__PURE__*/_interopDefault(m);var f=async(t,e,n)=>{let{scaleX:i,scaleY:l}=t.worldTransform,s=Math.max(Math.abs(i),Math.abs(l)),a=document.querySelector("#textInnerEditor");if(a&&t.data.textData?.fontSize&&(a.style.fontSize=`${t.data.textData.fontSize*s}px`),a&&t.data.textData?.lineHeight&&(a.style.lineHeight=t.data.textData.lineHeight),a&&t.data.textData?.letterSpacing&&(a.style.letterSpacing=`${t.data.textData.letterSpacing}px`),a&&t.data.textData?.textShadow?a.style.textShadow=t.data.textData.textShadow:a.style.textShadow="none",a&&t.data.textData?.alignContent){let d=a.querySelector(".ql-editor");d.style.alignContent=t.data.textData.alignContent;}let r=c.getQuill().getSemanticHTML();if(r==="<p></p>"){t.text.includes("<style>@font-face")?t.text=t.text.split("</style>")[0]+"</style>":t.text="";return}if(t.text.includes("<style>@font-face")){let d=t.text.split("</style>")[0];if(n&&!d.includes(n)){let u=`@font-face {font-family: ${n.split(",")[0]};src: url(${e}) format('woff2') }</style>`;t.text=d+u+T(t,r,t.data.textData.fontSize,t.data.textData.lineHeight,t.data.textData.letterSpacing,t.data.textData.textShadow,t.data.textData?.alignContent);}else t.text=d+"</style>"+T(t,r,t.data.textData.fontSize,t.data.textData.lineHeight,t.data.textData.letterSpacing,t.data.textData.textShadow,t.data.textData?.alignContent);}else if(e&&n){let d=`<style>@font-face {font-family: ${n.split(",")[0]};src: url(${e}) format('woff2') }</style>`;t.text=d+T(t,r,t.data.textData.fontSize,t.data.textData.lineHeight,t.data.textData.letterSpacing,t.data.textData.textShadow,t.data.textData?.alignContent);}else t.text=T(t,r,t.data.textData.fontSize,t.data.textData.lineHeight,t.data.textData.letterSpacing,t.data.textData.textShadow,t.data.textData?.alignContent);},T=(t,e,n=20.67,i=1.5,l=0,s="none",a="start")=>{let{scaleX:o,scaleY:r}=t.worldTransform,d=Math.max(Math.abs(o),Math.abs(r)),u=document.createElement("div");u.innerHTML=e;let v={fontSize:`${n}px`,lineHeight:i,letterSpacing:`${l}px`,textShadow:s};u.querySelectorAll("p,ol,ul").forEach(z=>{Object.assign(z.style,v);});let h=u.innerHTML;/<p\b[^>]*><\/p>/.test(h)&&(h=h.replace(/<p\b([^>]*)><\/p>/g,"<p$1>&nbsp;</p>")),/&quot;/.test(h)&&(h=h.replace(/&quot;/g,""));let p;document.querySelector("#textInnerEditor");let C=c.getQuill(),S=Number((C.scroll.domNode.scrollHeight/d).toFixed(0));Number((C.scroll.domNode.scrollWidth/d).toFixed(0));["center","end"].includes(t.data.textData.alignContent)?t.parent.height<S?p=(S||t.__layout.boxBounds.height)+"px":p=`${t.parent.height}px`:t.parent.height<S?p=(S||t.__layout.boxBounds.height)+"px":p=`${t.parent.height}px`;let w="<style>p{margin:0;}sub,sup{font-size:63%;}.ql-ui{position:absolute}ol,ul{counter-reset:list-0;padding-left:1.5em;margin:0}ol>li,ul>li{counter-increment:list-0;list-style-type:none;position:relative;padding-left:0;margin:0}ol>li::before{content:counter(list-0,decimal) '. ';position:absolute;left:-1.5em;width:1.2em;text-align:right}ul>li::before{content:'\u2022';position:absolute;left:-1.5em;width:1.2em;text-align:right}li[data-list]{counter-set:list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9}.ql-align-center{text-align:center}.ql-align-right{text-align:right}.ql-align-left{text-align:left}.ql-align-justify{text-align:justify}</style>",g="";return t.parent.children[0].tag.includes("Shape")?g=w+`<div style="width: ${t.parent.width}px;height: ${t.parent.height}px;overflow-wrap:break-word;word-break:break-all;align-content:center;">${h}</div>`:t.data.canChangeBox?g=w+`<div style="width: ${t.parent.width}px;height:${p};overflow-wrap:break-word;word-break:break-all;align-content:${a};">${h}</div>`:t.data.textData.italic?g=w+h:g=w+`<div style="overflow-wrap:break-word;word-break:break-all;">${h}</div>`,console.log(g,"\u6700\u7EC8\u7684html\u5185\u5BB9"),g},gt=(t,e,n)=>{let i=c.getQuill(),{editor:l,canvas:s}=c.getCanvas();if(!i)return;let a=i.selection.savedRange;c.dateEdit(async o=>{if(t==="font")l.innerEditing?(a&&a.length?i.formatText(a.index,a.length,t,e):i.formatText(0,i.getLength()-1,t,e),o.data.textData.fontFamily=e,f(o,n??null,e??null)):(c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),i.formatText(0,i.getLength()-1,t,e),o.data.textData.fontFamily=e,f(o,n??null,e??null));else if(t==="fontSize")o.data.textData[t]=e,c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),f(o,n??null);else if(t==="textCase"){if(l.innerEditing){let r=i.getText(a.index,a.length),d=i.getFormat(a.index,a.length);i.deleteText(a.index,a.length);let u;r===r.toUpperCase()&&/[A-Z]/.test(r)?u=r.toLowerCase():(r===r.toLowerCase()&&/[a-z]/.test(r),u=r.toUpperCase()),i.insertText(a.index,u,d),a&&l.innerEditing&&i.setSelection(a.index,a.length);}}else if(t==="script"){let r="sub";e==="super"&&(r="sup"),l.innerEditing?a&&a.length?i.formatText(a.index,a.length,t,i.getFormat(a).script===e?false:r):i.formatText(0,i.getLength()-1,t,i.getFormat().script===e?false:r):(c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),i.formatText(0,i.getLength()-1,t,i.getFormat().script===e?false:r),f(o));}else if(t==="align")c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),l.innerEditing?i.format(t,e):i.formatLine(0,i.getLength(),t,e),f(o);else if(t==="alignContent")c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),o.data.textData[t]=e,f(o);else if(t==="lineHeight"||t==="letterSpacing")c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),o.data.textData[t]=e,f(o);else if(t==="color")c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),a&&a.length?i.formatText(a.index,a.length,t,e):i.formatText(0,i.getLength()-1,t,e),o.tag==="HTMLText"?f(o):o.parent.findOne("HTMLText")&&f(o.parent.findOne("HTMLText"));else if(t==="textShadow")c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),o.data.textData[t]=e,f(o);else if(t==="list"){if(c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),l.innerEditing){let[r]=i.getLine(a?.index||0);r.formats().list?i.format(t,false):i.format(t,e);}else {let[r]=i.getLine(a?.index||0);r.formats().list?i.formatLine(0,i.getLength(),t,false):i.formatLine(0,i.getLength(),t,e);}f(o);}else l.innerEditing?a&&a.length?i.formatText(a.index,a.length,t,e===void 0?!i.getFormat(a)[t]:e):i.formatText(0,i.getLength()-1,t,e===void 0?!i.getFormat()[t]:e):(c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),i.formatText(0,i.getLength()-1,t,e===void 0?!i.getFormat()[t]:e),f(o));},1);};var A=(t,e,n,i)=>{for(var l=e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(l=(a(l))||l);return l},B=class extends editor.EditTool{constructor(t){super(t),this.quill=null,this.isUpdatingPoints=false,this.curveAmount=0,this.eventIds=[],this.updateBoxDebounced=this.debounce(e=>{f(e);},300);}get tag(){return "TextEditTool"}debounce(t,e){let n=null;return((...i)=>{n!==null&&window.clearTimeout(n),n=window.setTimeout(()=>t.apply(this,i),e);})}addEvent(){let{editor:t}=c.getCanvas(),e=t._target.findOne("HTMLText"),{scaleX:n,scaleY:i}=e.worldTransform,l=Math.max(Math.abs(n),Math.abs(i)),s=document.querySelector("#textInnerEditor"),{style:a}=s;this.eventIds=[t.on_(editor.EditorScaleEvent.SCALE,o=>{e.data.canChangeBox||(e.data.canChangeBox=true),e.data.canChangeBox&&(a.width=e.parent.width*l+"px",a.height="auto");let r=1;e.parent.tag==="HtmlText"&&e.parent.lockRatio&&e.data?.baseSize?.width&&(r=e.parent.width/e.data?.baseSize.width,e.data.textData.fontSize=e.data.textData.fontSize*r),e.data?.baseSize?.width&&(e.data.baseSize.width=e.parent.width),this.updateBoxDebounced(e);}),t.on_(leaferUi.PointerEvent.DOUBLE_TAP,()=>{e.parent.locked||t.openInnerEditor(e,true);})];}onLoad(){let{editor:t}=c.getCanvas();console.log(t._target,123);let e=t._target.findOne("HTMLText"),{scaleX:n,scaleY:i}=e.worldTransform,l=Math.max(Math.abs(n),Math.abs(i));this.addEvent(),this.quill=c.getQuill(),this.quill.clipboard.dangerouslyPasteHTML(e.text);let s=document.querySelector("#textInnerEditor"),{style:a}=s;e.data.canChangeBox?(a.width=e.parent.width*l+"px",a.height=e.parent.height*l+"px"):(a.width="auto",a.height="auto");}updateChangeBoxBound(t){t&&t.set({width:t.__layout.boxBounds.width,height:t.__layout.boxBounds.height});}onUpdate(){let {editor:t}=c.getCanvas(),e=t._target.findOne("HTMLText");t._target;console.log("\u6587\u672Cbound\u66F4\u65B0"),this.curveAmount!=e.curveAmount&&this.isUpdatingPoints;}onUnload(){let{editor:t}=c.getCanvas();t.off_(this.eventIds);}onDestroy(){}};B=A([editor.registerEditTool()],B);var K=(t,e,n,i)=>{for(var l=e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(l=(a(l))||l);return l},H=class extends editor.InnerEditor{constructor(){super(...arguments),this.config={selectAll:false},this.eventIds=[],this.selectText=void 0,this.inBody=void 0,this.isHTMLText=void 0,this._keyEvent=void 0,this.quill=null,this.isComposing=false,this.onInput=async()=>{let{editDom:t}=this;f(this.editTarget);},this.isUpdatingPoints=false;}get tag(){return "TextEditor"}onLoad(){let{editor:t}=this,{config:e}=t.app,n=this.editTarget,{scaleX:i,scaleY:l}=n.worldTransform,s=Math.max(Math.abs(i),Math.abs(l));this.isHTMLText=!(n instanceof Text),this._keyEvent=e.keyEvent,e.keyEvent=false;let a=this.editDom=document.querySelector("#textInnerEditor"),{style:o}=a;if(o.visibility="visible",n.data.canChangeBox?(o.width=n.parent.width*s+"px",o.height=n.parent.height*s+"px"):(o.width="auto",o.height="auto"),o.outline="solid #8499EF",n.data.textData.fontSize&&(a.style.fontSize=`${n.data.textData.fontSize*s}px`),n.data.textData.lineHeight&&(a.style.lineHeight=n.data.textData.lineHeight),n.data.textData.letterSpacing&&(a.style.letterSpacing=`${n.data.textData.letterSpacing}px`),n.data.textData.textShadow?a.style.textShadow=`${n.data.textData.textShadow}`:a.style.textShadow="none",n.data.textData.alignContent){let r=a.querySelector(".ql-editor");r.style.alignContent=`${n.data.textData.alignContent}`;}this.quill=c.getQuill(),this.quill.clipboard.dangerouslyPasteHTML(n.text),n.parent.children[0].tag.includes("Shape")?(o.width=n.parent.width*s+"px",o.left="0px",this.quill.formatLine(0,this.quill.getLength(),"align","center")):this.quill.setSelection(0,this.quill.getLength()-1),this.quill.on("text-change",this.onInput),this.eventIds=[t.app.on_(core.PointerEvent.DOWN,r=>{let{target:d}=r.origin,u=false;for(;d;)d===a&&(u=true),d=d.parentElement;u||(t.closeInnerEditor(),t.cancel());})];}onUpdate(){let{editTarget:t}=this,{scaleX:e,scaleY:n}=t.worldTransform,i=Math.max(Math.abs(e),Math.abs(n)),{width:l,height:s}=t.parent.__local;l*=i,s*=i;let{x:a,y:o}=this.inBody?t.app.clientBounds:t.app.tree.clientBounds,{a:r,b:d,c:u,d:v,e:h,f:p}=new core.Matrix(t.worldTransform).scale(1/i).translateInner(0,0),{style:y}=this.editDom;y.transform=`matrix(${r},${d},${u},${v},${h},${p})`,y.left=a+"px",y.top=o+"px",t.set({visible:false});}onUnload(){let{editTarget:t,editor:e,editDom:n}=this;t&&(this.onInput(),e.app&&(e.app.config.keyEvent=this._keyEvent),e.off_(this.eventIds),this.editDom.style.visibility="hidden",this.eventIds=[]),t.parent&&t.parent.name=="Text"&&t.parent.children.some(i=>i.tag==="Box")?(t.parent.findOne("Box").opacity=1,t.visible=false):t.set({visible:true}),this.quill.getLength()===1&&t.parent.name==="Text"&&t.parent.remove(),this.quill.off("text-change",this.onInput);}};H=K([editor.registerInnerEditor()],H);function E(t,{insertAt:e}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",e==="top"&&n.firstChild?n.insertBefore(i,n.firstChild):n.appendChild(i),i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t));}E(`.ql-editor{padding:0!important;line-height:unset!important;overflow:unset!important;outline:0}.ql-container{font-family:unset!important}.ql-editor p{margin:0!important}.ql-editor sub,.ql-editor sup{font-size:63%}.ql-editor sup{top:-.58em}.ql-editor sub{bottom:-.38em}.ql-editor ol{padding-left:0!important}
2
- `);var _="LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUFxaUFnU1hWM3dMKzh2YkZ2OVkwQwpEN1dBUjhPa2I4bjlmTWxpQjF3enZodTBrdVdZUWEvMUxvVDhHWVh6WWlRQVFBRk9zTTA0MGp2dlNRT2hRSWpiCjRaYXZ1NHUvWVA5bElPYjFKYnZnYkFoYVVOQnphL0l2UmFnaFlKYTJBc1cyRVhnZkVrdmMyUENNMS9zbVlFNnoKNjZiUmx1dnREK3FJZkpLVCtUUXJRRmp5TnNTZ0c2Z2R4MThrZTRMSStBejFPcklMbUsyMHlBU2tlRXpYT1BTVAplM3RNYThleHpZdmUzV0wyNHRHUHg5WHNvN1JyUEl1elZlajh0NDYrZ0c1Y0pQaVh0N1lqa0V2NEJOUUt5eUpoCkltOVRJdVZ6clFpa2NJNE14dExNSGdUMHpLcU9ZZ1NzcmEvTHNDd2ZOdzdtYWxITkU2c21YZWYyQ2E5RGhZODQKS1FJREFRQUIKLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg==";function k(t){let e=t.replace(/-----BEGIN PUBLIC KEY-----/,"").replace(/-----END PUBLIC KEY-----/,"").replace(/\s/g,"");return F(e)}function F(t){let e=atob(t),n=new Uint8Array(e.length);for(let i=0;i<e.length;i++)n[i]=e.charCodeAt(i);return n.buffer}async function G(){let t=atob(_),e=k(t);return await crypto.subtle.importKey("spki",e,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},false,["verify"])}async function U(t,e){try{let n=await G(),i=new TextEncoder().encode(t),l=F(e);return await crypto.subtle.verify("RSASSA-PKCS1-v1_5",n,l,i)}catch(n){return console.error("[RSA] Signature verification failed:",n),false}}async function tt(t){try{let e=atob(t),n=JSON.parse(e);if(!n.data||!n.signature)return console.error("[License] Invalid license format"),null;if(!await U(n.data,n.signature))return console.error("[License] Invalid signature - License may be tampered or forged"),null;let l=JSON.parse(n.data);return console.log("[License] Signature verified successfully"),l}catch(e){return console.error("[License] Failed to parse license:",e),null}}function et(t){if(!t||t.length===0)return true;let e=window.location.hostname;if(e==="localhost"||e==="127.0.0.1")return console.log("[License] Local development environment detected"),true;let n=t.some(i=>{if(i.startsWith("*.")){let l=i.slice(2);return e.endsWith(l)}return e===i});return n||(console.error(`[License] Domain not authorized: ${e}`),console.error("[License] Allowed domains:",t)),n}function it(t){if(!t)return true;try{let e=new Date(t),n=new Date;if(n>=e)return console.error(`[License] License has expired on ${t}`),!1;let i=Math.ceil((e.getTime()-n.getTime())/(1e3*60*60*24));return i<=7&&console.warn(`[License] License will expire in ${i} days`),!0}catch{return console.error("[License] Invalid expire date format:",t),false}}function nt(t){if(!t)return true;try{return new Date(t)>new Date?(console.error("[License] License issue date is in the future"),!1):!0}catch{return true}}async function D(t){try{let e=await tt(t);return e?nt(e.issueDate)?et(e.domains)?it(e.expireDate)?(console.log("[License] All validations passed"),console.log("[License] License info:",{key:e.key,domains:e.domains,expireDate:e.expireDate,features:e.features}),{valid:!0,data:e}):{valid:!1,error:"License has expired",data:e}:{valid:!1,error:`License not valid for domain: ${window.location.hostname}`,data:e}:{valid:!1,error:"Invalid license issue date",data:e}:{valid:!1,error:"Invalid license key or signature verification failed"}}catch(e){return console.error("[License] Validation error:",e),{valid:false,error:"License validation failed"}}}var L=null,b=null,x=false;async function at(t){console.log("[License] Activating license...");let e=await D(t);return e.valid&&e.data?(L=t,b=e.data,x=true,console.log("[License] \u2705 License activated successfully"),console.log(`[License] Valid until: ${e.data.expireDate||"unlimited"}`),true):(L=null,b=null,x=false,console.error("[License] \u274C License activation failed:",e.error),false)}async function M(){if(!L)return console.warn("[License] No license key provided"),false;if(!x)return console.warn("[License] License is not valid"),false;let t=await D(L);return x=t.valid,x||(console.error("[License] License validation failed:",t.error),b=null),x}function lt(){return b}var q=class t{constructor(){this.quill=null,this.app_=null;}static getInstance(){return t.instance||(t.instance=new t),t.instance}async init(e){if(!await M())throw new Error("[HtmlTextManage] \u6388\u6743\u5931\u8D25\u8BF7\u8054\u7CFB\u4F5C\u8005\u83B7\u53D6\u6388\u6743 \u90AE\u7BB1 : 408550179@qq.com \u5FAE\u4FE1 : cym5640");if(this.app_=e,this.quill)return this.quill;let i=document.getElementById("textInnerEditor");if(i)this.quill=this.app_.editor.quill;else return i=document.createElement("div"),i.id="textInnerEditor",i.style.position="fixed",i.style.transformOrigin="left top",i.style.overflowWrap="break-word",i.style.wordBreak="break-all",i.style.visibility="hidden",document.body.appendChild(i),this.quill=new m__default.default("#textInnerEditor",{theme:void 0,modules:{toolbar:false,keyboard:{bindings:{enter:{key:"Enter",handler:l=>{let[s]=this.quill.getLine(l.index),a=m__default.default.import("blots/block");if(!a?.bubbleFormats)return true;let o=a.bubbleFormats(s),r=new m.Delta().retain(l.index).delete(l.length).insert(`
3
- `,o);return this.quill.updateContents(r,m__default.default.sources.USER),this.quill.setSelection(l.index+1,m__default.default.sources.SILENT),false}}}}}}),this.app_.editor.quill=this.quill,this.registerFonts(),this.quill}getQuill(){if(!this.quill)throw new Error("Quill editor not initialized. Call init() first.");return this.quill}getCanvas(){if(!this.app_)throw new Error("app_ editor not initialized. Call init() first.");return this.app_}getSelection(){return console.log(this.quill?.selection.savedRange,"this.quill?.selection.savedRange"),this.quill?.selection.savedRange}registerFonts(){font.FontStyle.whitelist=void 0,m__default.default.register("formats/font",font.FontStyle,true);}isMultiSelect(){return this.app_.editor?this.app_.editor.multiple===true:false}dateEdit(e,n=0,i){let{editor:l}=this.app_,s=i||l.leafList.list,a=o=>{n&&(o.tag==="Box"||o.name==="Text")?e(o.children?.[0]||o):e(o);};s.length&&(Array.isArray(s)&&s.length>1?(this.app_.lockLayout(),s.forEach(a),this.app_.unlockLayout(),l.updateEditBox()):a(s[0]));}},c=q.getInstance();var ct=(t,e,n,i)=>{for(var l=e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(l=(a(l))||l);return l};exports.HtmlText=class P extends core.Box{get __tag(){return "HtmlText"}constructor(t){let{text:e,fontSize:n,fontFamily:i,lineHeight:l,letterSpacing:s,textShadow:a,alignContent:o,...r}=t||{};super({editOuter:"TextEditTool",name:"HtmlText",x:0,y:0,editable:true,draggable:true,overflow:"show",...r}),t&&this.createTextElement(t);}createTextElement(t){let{text:e,fontSize:n,fontFamily:i,lineHeight:l,letterSpacing:s,textShadow:a,alignContent:o}=t,r="<style>p{margin:0;}sub,sup{font-size:63%;}.ql-ui{position:absolute}ol,ul{counter-reset:list-0;padding-left:1.5em;margin:0}ol>li,ul>li{counter-increment:list-0;list-style-type:none;position:relative;padding-left:0;margin:0}ol>li::before{content:counter(list-0,decimal) '. ';position:absolute;left:-1.5em;width:1.2em;text-align:right}ul>li::before{content:'\u2022';position:absolute;left:-1.5em;width:1.2em;text-align:right}li[data-list]{counter-set:list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9}.ql-align-center{text-align:center}.ql-align-right{text-align:right}.ql-align-left{text-align:left}.ql-align-justify{text-align:justify}</style>",d=`<div style="ove
4
- rflow-wrap:break-word;word-break:break-all;"><p style="font-size: ${n}px; line-height: ${l}; letter-spacing: ${s}px; text-shadow: ${a};"><strong>Hello World</strong></p></div>`,u=new html.HTMLText({name:"Text",text:r+(e||d),x:0,y:0,data:{canChangeBox:false,textData:{fontFamily:i,fontSize:n,lineHeight:l,letterSpacing:s||0,textShadow:a,alignContent:o}},editConfig:{selectedStyle:{strokeWidth:0}}});this.add(u);}};exports.HtmlText=ct([core.registerUI()],exports.HtmlText);exports.checkLicense=M;exports.getLicenseInfo=lt;exports.htmlTextManage=c;exports.setHTMLText=gt;exports.setLicense=at;exports.updataHtmlText=f;
1
+ 'use strict';var editor=require('@leafer-in/editor'),leaferUi=require('leafer-ui'),core=require('@leafer-ui/core'),y=require('quill');require('quill/dist/quill.core.css');var font=require('quill/formats/font'),x=require('crypto-js'),html=require('@leafer-in/html');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var y__default=/*#__PURE__*/_interopDefault(y);var x__default=/*#__PURE__*/_interopDefault(x);var f=async(t,e,n)=>{let{scaleX:i,scaleY:r}=t.worldTransform,l=Math.max(Math.abs(i),Math.abs(r)),a=document.querySelector("#textInnerEditor");if(a&&t.data.textData?.fontSize&&(a.style.fontSize=`${t.data.textData.fontSize*l}px`),a&&t.data.textData?.lineHeight&&(a.style.lineHeight=t.data.textData.lineHeight),a&&t.data.textData?.letterSpacing&&(a.style.letterSpacing=`${t.data.textData.letterSpacing}px`),a&&t.data.textData?.textShadow?a.style.textShadow=t.data.textData.textShadow:a.style.textShadow="none",a&&t.data.textData?.alignContent){let d=a.querySelector(".ql-editor");d.style.alignContent=t.data.textData.alignContent;}let s=c.getQuill().getSemanticHTML();if(s==="<p></p>"){t.text.includes("<style>@font-face")?t.text=t.text.split("</style>")[0]+"</style>":t.text="";return}if(t.text.includes("<style>@font-face")){let d=t.text.split("</style>")[0];if(n&&!d.includes(n)){let u=`@font-face {font-family: ${n.split(",")[0]};src: url(${e}) format('woff2') }</style>`;t.text=d+u+T(t,s,t.data.textData.fontSize,t.data.textData.lineHeight,t.data.textData.letterSpacing,t.data.textData.textShadow,t.data.textData?.alignContent);}else t.text=d+"</style>"+T(t,s,t.data.textData.fontSize,t.data.textData.lineHeight,t.data.textData.letterSpacing,t.data.textData.textShadow,t.data.textData?.alignContent);}else if(e&&n){let d=`<style>@font-face {font-family: ${n.split(",")[0]};src: url(${e}) format('woff2') }</style>`;t.text=d+T(t,s,t.data.textData.fontSize,t.data.textData.lineHeight,t.data.textData.letterSpacing,t.data.textData.textShadow,t.data.textData?.alignContent);}else t.text=T(t,s,t.data.textData.fontSize,t.data.textData.lineHeight,t.data.textData.letterSpacing,t.data.textData.textShadow,t.data.textData?.alignContent);},T=(t,e,n=20.67,i=1.5,r=0,l="none",a="start")=>{let{scaleX:o,scaleY:s}=t.worldTransform,d=Math.max(Math.abs(o),Math.abs(s)),u=document.createElement("div");u.innerHTML=e;let L={fontSize:`${n}px`,lineHeight:i,letterSpacing:`${r}px`,textShadow:l};u.querySelectorAll("p,ol,ul").forEach(N=>{Object.assign(N.style,L);});let p=u.innerHTML;/<p\b[^>]*><\/p>/.test(p)&&(p=p.replace(/<p\b([^>]*)><\/p>/g,"<p$1>&nbsp;</p>")),/&quot;/.test(p)&&(p=p.replace(/&quot;/g,""));let h;document.querySelector("#textInnerEditor");let B=c.getQuill(),w=Number((B.scroll.domNode.scrollHeight/d).toFixed(0));Number((B.scroll.domNode.scrollWidth/d).toFixed(0));["center","end"].includes(t.data.textData.alignContent)?t.parent.height<w?h=(w||t.__layout.boxBounds.height)+"px":h=`${t.parent.height}px`:t.parent.height<w?h=(w||t.__layout.boxBounds.height)+"px":h=`${t.parent.height}px`;let b="<style>p{margin:0;}sub,sup{font-size:63%;}.ql-ui{position:absolute}ol,ul{counter-reset:list-0;padding-left:1.5em;margin:0}ol>li,ul>li{counter-increment:list-0;list-style-type:none;position:relative;padding-left:0;margin:0}ol>li::before{content:counter(list-0,decimal) '. ';position:absolute;left:-1.5em;width:1.2em;text-align:right}ul>li::before{content:'\u2022';position:absolute;left:-1.5em;width:1.2em;text-align:right}li[data-list]{counter-set:list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9}.ql-align-center{text-align:center}.ql-align-right{text-align:right}.ql-align-left{text-align:left}.ql-align-justify{text-align:justify}</style>",g="";return t.parent.children[0].tag.includes("Shape")?g=b+`<div style="width: ${t.parent.width}px;height: ${t.parent.height}px;overflow-wrap:break-word;word-break:break-all;align-content:center;">${p}</div>`:t.data.canChangeBox?g=b+`<div style="width: ${t.parent.width}px;height:${h};overflow-wrap:break-word;word-break:break-all;align-content:${a};">${p}</div>`:t.data.textData.italic?g=b+p:g=b+`<div style="overflow-wrap:break-word;word-break:break-all;">${p}</div>`,console.log(g,"\u6700\u7EC8\u7684html\u5185\u5BB9"),g},St=(t,e,n)=>{let i=c.getQuill(),{editor:r,canvas:l}=c.getCanvas();if(!i)return;let a=i.selection.savedRange;c.dateEdit(async o=>{if(t==="font")r.innerEditing?(a&&a.length?i.formatText(a.index,a.length,t,e):i.formatText(0,i.getLength()-1,t,e),o.data.textData.fontFamily=e,f(o,n??null,e??null)):(c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),i.formatText(0,i.getLength()-1,t,e),o.data.textData.fontFamily=e,f(o,n??null,e??null));else if(t==="fontSize")o.data.textData[t]=e,c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),f(o,n??null);else if(t==="textCase"){if(r.innerEditing){let s=i.getText(a.index,a.length),d=i.getFormat(a.index,a.length);i.deleteText(a.index,a.length);let u;s===s.toUpperCase()&&/[A-Z]/.test(s)?u=s.toLowerCase():(s===s.toLowerCase()&&/[a-z]/.test(s),u=s.toUpperCase()),i.insertText(a.index,u,d),a&&r.innerEditing&&i.setSelection(a.index,a.length);}}else if(t==="script"){let s="sub";e==="super"&&(s="sup"),r.innerEditing?a&&a.length?i.formatText(a.index,a.length,t,i.getFormat(a).script===e?false:s):i.formatText(0,i.getLength()-1,t,i.getFormat().script===e?false:s):(c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),i.formatText(0,i.getLength()-1,t,i.getFormat().script===e?false:s),f(o));}else if(t==="align")c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),r.innerEditing?i.format(t,e):i.formatLine(0,i.getLength(),t,e),f(o);else if(t==="alignContent")c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),o.data.textData[t]=e,f(o);else if(t==="lineHeight"||t==="letterSpacing")c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),o.data.textData[t]=e,f(o);else if(t==="color")c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),a&&a.length?i.formatText(a.index,a.length,t,e):i.formatText(0,i.getLength()-1,t,e),o.tag==="HTMLText"?f(o):o.parent.findOne("HTMLText")&&f(o.parent.findOne("HTMLText"));else if(t==="textShadow")c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),o.data.textData[t]=e,f(o);else if(t==="list"){if(c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),r.innerEditing){let[s]=i.getLine(a?.index||0);s.formats().list?i.format(t,false):i.format(t,e);}else {let[s]=i.getLine(a?.index||0);s.formats().list?i.formatLine(0,i.getLength(),t,false):i.formatLine(0,i.getLength(),t,e);}f(o);}else r.innerEditing?a&&a.length?i.formatText(a.index,a.length,t,e===void 0?!i.getFormat(a)[t]:e):i.formatText(0,i.getLength()-1,t,e===void 0?!i.getFormat()[t]:e):(c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),i.formatText(0,i.getLength()-1,t,e===void 0?!i.getFormat()[t]:e),f(o));},1);};var Y=(t,e,n,i)=>{for(var r=e,l=t.length-1,a;l>=0;l--)(a=t[l])&&(r=(a(r))||r);return r},H=class extends editor.EditTool{constructor(t){super(t),this.quill=null,this.isUpdatingPoints=false,this.curveAmount=0,this.eventIds=[],this.updateBoxDebounced=this.debounce(e=>{f(e);},300);}get tag(){return "TextEditTool"}debounce(t,e){let n=null;return((...i)=>{n!==null&&window.clearTimeout(n),n=window.setTimeout(()=>t.apply(this,i),e);})}addEvent(){let{editor:t}=c.getCanvas(),e=t._target.findOne("HTMLText"),{scaleX:n,scaleY:i}=e.worldTransform,r=Math.max(Math.abs(n),Math.abs(i)),l=document.querySelector("#textInnerEditor"),{style:a}=l;this.eventIds=[t.on_(editor.EditorScaleEvent.SCALE,o=>{e.data.canChangeBox||(e.data.canChangeBox=true),e.data.canChangeBox&&(a.width=e.parent.width*r+"px",a.height="auto");let s=1;e.parent.tag==="HtmlText"&&e.parent.lockRatio&&e.data?.baseSize?.width&&(s=e.parent.width/e.data?.baseSize.width,e.data.textData.fontSize=e.data.textData.fontSize*s),e.data?.baseSize?.width&&(e.data.baseSize.width=e.parent.width),this.updateBoxDebounced(e);}),t.on_(leaferUi.PointerEvent.DOUBLE_TAP,()=>{e.parent.locked||t.openInnerEditor(e,true);})];}onLoad(){let{editor:t}=c.getCanvas();console.log(t._target,123);let e=t._target.findOne("HTMLText"),{scaleX:n,scaleY:i}=e.worldTransform,r=Math.max(Math.abs(n),Math.abs(i));this.addEvent(),this.quill=c.getQuill(),this.quill.clipboard.dangerouslyPasteHTML(e.text);let l=document.querySelector("#textInnerEditor"),{style:a}=l;e.data.canChangeBox?(a.width=e.parent.width*r+"px",a.height=e.parent.height*r+"px"):(a.width="auto",a.height="auto");}updateChangeBoxBound(t){t&&t.set({width:t.__layout.boxBounds.width,height:t.__layout.boxBounds.height});}onUpdate(){let {editor:t}=c.getCanvas(),e=t._target.findOne("HTMLText");t._target;console.log("\u6587\u672Cbound\u66F4\u65B0"),this.curveAmount!=e.curveAmount&&this.isUpdatingPoints;}onUnload(){let{editor:t}=c.getCanvas();t.off_(this.eventIds);}onDestroy(){}};H=Y([editor.registerEditTool()],H);var k=(t,e,n,i)=>{for(var r=e,l=t.length-1,a;l>=0;l--)(a=t[l])&&(r=(a(r))||r);return r},_=class extends editor.InnerEditor{constructor(){super(...arguments),this.config={selectAll:false},this.eventIds=[],this.selectText=void 0,this.inBody=void 0,this.isHTMLText=void 0,this._keyEvent=void 0,this.quill=null,this.isComposing=false,this.onInput=async()=>{let{editDom:t}=this;f(this.editTarget);},this.isUpdatingPoints=false;}get tag(){return "TextEditor"}onLoad(){let{editor:t}=this,{config:e}=t.app,n=this.editTarget,{scaleX:i,scaleY:r}=n.worldTransform,l=Math.max(Math.abs(i),Math.abs(r));this.isHTMLText=!(n instanceof Text),this._keyEvent=e.keyEvent,e.keyEvent=false;let a=this.editDom=document.querySelector("#textInnerEditor"),{style:o}=a;if(o.visibility="visible",n.data.canChangeBox?(o.width=n.parent.width*l+"px",o.height=n.parent.height*l+"px"):(o.width="auto",o.height="auto"),o.outline="solid #8499EF",n.data.textData.fontSize&&(a.style.fontSize=`${n.data.textData.fontSize*l}px`),n.data.textData.lineHeight&&(a.style.lineHeight=n.data.textData.lineHeight),n.data.textData.letterSpacing&&(a.style.letterSpacing=`${n.data.textData.letterSpacing}px`),n.data.textData.textShadow?a.style.textShadow=`${n.data.textData.textShadow}`:a.style.textShadow="none",n.data.textData.alignContent){let s=a.querySelector(".ql-editor");s.style.alignContent=`${n.data.textData.alignContent}`;}this.quill=c.getQuill(),this.quill.clipboard.dangerouslyPasteHTML(n.text),n.parent.children[0].tag.includes("Shape")?(o.width=n.parent.width*l+"px",o.left="0px",this.quill.formatLine(0,this.quill.getLength(),"align","center")):this.quill.setSelection(0,this.quill.getLength()-1),this.quill.on("text-change",this.onInput),this.eventIds=[t.app.on_(core.PointerEvent.DOWN,s=>{let{target:d}=s.origin,u=false;for(;d;)d===a&&(u=true),d=d.parentElement;u||(t.closeInnerEditor(),t.cancel());})];}onUpdate(){let{editTarget:t}=this,{scaleX:e,scaleY:n}=t.worldTransform,i=Math.max(Math.abs(e),Math.abs(n)),{width:r,height:l}=t.parent.__local;r*=i,l*=i;let{x:a,y:o}=this.inBody?t.app.clientBounds:t.app.tree.clientBounds,{a:s,b:d,c:u,d:L,e:p,f:h}=new core.Matrix(t.worldTransform).scale(1/i).translateInner(0,0),{style:S}=this.editDom;S.transform=`matrix(${s},${d},${u},${L},${p},${h})`,S.left=a+"px",S.top=o+"px",t.set({visible:false});}onUnload(){let{editTarget:t,editor:e,editDom:n}=this;t&&(this.onInput(),e.app&&(e.app.config.keyEvent=this._keyEvent),e.off_(this.eventIds),this.editDom.style.visibility="hidden",this.eventIds=[]),t.parent&&t.parent.name=="Text"&&t.parent.children.some(i=>i.tag==="Box")?(t.parent.findOne("Box").opacity=1,t.visible=false):t.set({visible:true}),this.quill.getLength()===1&&t.parent.name==="Text"&&t.parent.remove(),this.quill.off("text-change",this.onInput);}};_=k([editor.registerInnerEditor()],_);function D(t,{insertAt:e}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",e==="top"&&n.firstChild?n.insertBefore(i,n.firstChild):n.appendChild(i),i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t));}D(`.ql-editor{padding:0!important;line-height:unset!important;overflow:unset!important;outline:0}.ql-container{font-family:unset!important}.ql-editor p{margin:0!important}.ql-editor sub,.ql-editor sup{font-size:63%}.ql-editor sup{top:-.58em}.ql-editor sub{bottom:-.38em}.ql-editor ol{padding-left:0!important}
2
+ `);var U="LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUFxaUFnU1hWM3dMKzh2YkZ2OVkwQwpEN1dBUjhPa2I4bjlmTWxpQjF3enZodTBrdVdZUWEvMUxvVDhHWVh6WWlRQVFBRk9zTTA0MGp2dlNRT2hRSWpiCjRaYXZ1NHUvWVA5bElPYjFKYnZnYkFoYVVOQnphL0l2UmFnaFlKYTJBc1cyRVhnZkVrdmMyUENNMS9zbVlFNnoKNjZiUmx1dnREK3FJZkpLVCtUUXJRRmp5TnNTZ0c2Z2R4MThrZTRMSStBejFPcklMbUsyMHlBU2tlRXpYT1BTVAplM3RNYThleHpZdmUzV0wyNHRHUHg5WHNvN1JyUEl1elZlajh0NDYrZ0c1Y0pQaVh0N1lqa0V2NEJOUUt5eUpoCkltOVRJdVZ6clFpa2NJNE14dExNSGdUMHpLcU9ZZ1NzcmEvTHNDd2ZOdzdtYWxITkU2c21YZWYyQ2E5RGhZODQKS1FJREFRQUIKLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg==";function it(t){let e=t.replace(/-----BEGIN PUBLIC KEY-----/,"").replace(/-----END PUBLIC KEY-----/,"").replace(/\s/g,"");return F(e)}function F(t){let e=atob(t),n=new Uint8Array(e.length);for(let i=0;i<e.length;i++)n[i]=e.charCodeAt(i);return n.buffer}async function nt(){let t=atob(U),e=it(t);return await crypto.subtle.importKey("spki",e,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},false,["verify"])}async function A(t,e){try{let n=await nt(),i=new TextEncoder().encode(t),r=F(e);return await crypto.subtle.verify("RSASSA-PKCS1-v1_5",n,r,i)}catch(n){return console.error("[RSA] Signature verification failed:",n),false}}var P="c19496eb17719960b6c3cebab0ef5eddfce5d0315ab8c5af86a52fbda434fea9",I="ce1e3e8974f1392b3c5803b34ecf659f";function z(t){try{let e=x__default.default.enc.Hex.parse(P),n=x__default.default.enc.Hex.parse(I),r=x__default.default.AES.decrypt(t,e,{iv:n,mode:x__default.default.mode.CBC,padding:x__default.default.pad.Pkcs7}).toString(x__default.default.enc.Utf8);if(!r)throw new Error("Decryption resulted in empty string - invalid ciphertext or wrong key");return r}catch(e){throw console.error("[AES] Decryption failed:",e),e}}async function at(t){try{let e=atob(t),n=JSON.parse(e);if(!n.data||!n.signature||!await A(n.data,n.signature))return null;let r=n.data;if(n.encrypted)try{r=z(n.data);}catch{return null}return JSON.parse(r)}catch{return null}}function rt(t){if(!t||t.length===0)return true;let e=window.location.hostname;if(e==="localhost"||e==="127.0.0.1")return console.log("[License] Local development environment detected"),true;let n=t.some(i=>{if(i.startsWith("*.")){let r=i.slice(2);return e.endsWith(r)}return e===i});return n||(console.error(`[License] Domain not authorized: ${e}`),console.error("[License] Allowed domains:",t)),n}function ot(t){if(!t)return true;try{let e=new Date(t),n=new Date;if(n>=e)return console.error(`[License] License has expired on ${t}`),!1;let i=Math.ceil((e.getTime()-n.getTime())/(1e3*60*60*24));return i<=7&&console.warn(`[License] License will expire in ${i} days`),!0}catch{return console.error("[License] Invalid expire date format:",t),false}}function lt(t){if(!t)return true;try{return new Date(t)>new Date?(console.error("[License] License issue date is in the future"),!1):!0}catch{return true}}async function C(t){try{let e=await at(t);return e?lt(e.issueDate)?rt(e.domains)?ot(e.expireDate)?(console.log("[License] License info:",{key:e.key,domains:e.domains,expireDate:e.expireDate,features:e.features}),{valid:!0,data:e}):{valid:!1,error:"License has expired",data:e}:{valid:!1,error:`License not valid for domain: ${window.location.hostname}`,data:e}:{valid:!1,error:"Invalid license issue date",data:e}:{valid:!1,error:"Invalid license key or signature verification failed"}}catch(e){return console.error("[License] Validation error:",e),{valid:false,error:"License validation failed"}}}var E=null,v=null,m=false;async function st(t){console.log("[License] Activating license...");let e=await C(t);return e.valid&&e.data?(E=t,v=e.data,m=true,console.log("[License] \u2705 License activated successfully"),console.log(`[License] Valid until: ${e.data.expireDate||"unlimited"}`),true):(E=null,v=null,m=false,console.error("[License] \u274C License activation failed:",e.error),false)}async function M(){if(!E)return console.warn("[License] No license key provided"),false;if(!m)return console.warn("[License] License is not valid"),false;let t=await C(E);return m=t.valid,m||(console.error("[License] License validation failed:",t.error),v=null),m}function ct(){return v}var q=class t{constructor(){this.quill=null,this.app_=null;}static getInstance(){return t.instance||(t.instance=new t),t.instance}async init(e){if(!await M())throw new Error("[HtmlTextManage] \u6388\u6743\u5931\u8D25\u8BF7\u8054\u7CFB\u4F5C\u8005\u83B7\u53D6\u6388\u6743 \u90AE\u7BB1 : 408550179@qq.com \u5FAE\u4FE1 : cym5640");if(this.app_=e,this.quill)return this.quill;let i=document.getElementById("textInnerEditor");if(i)this.quill=this.app_.editor.quill;else return i=document.createElement("div"),i.id="textInnerEditor",i.style.position="fixed",i.style.transformOrigin="left top",i.style.overflowWrap="break-word",i.style.wordBreak="break-all",i.style.visibility="hidden",document.body.appendChild(i),this.quill=new y__default.default("#textInnerEditor",{theme:void 0,modules:{toolbar:false,keyboard:{bindings:{enter:{key:"Enter",handler:r=>{let[l]=this.quill.getLine(r.index),a=y__default.default.import("blots/block");if(!a?.bubbleFormats)return true;let o=a.bubbleFormats(l),s=new y.Delta().retain(r.index).delete(r.length).insert(`
3
+ `,o);return this.quill.updateContents(s,y__default.default.sources.USER),this.quill.setSelection(r.index+1,y__default.default.sources.SILENT),false}}}}}}),this.app_.editor.quill=this.quill,this.registerFonts(),this.quill}getQuill(){if(!this.quill)throw new Error("Quill editor not initialized. Call init() first.");return this.quill}getCanvas(){if(!this.app_)throw new Error("app_ editor not initialized. Call init() first.");return this.app_}getSelection(){return console.log(this.quill?.selection.savedRange,"this.quill?.selection.savedRange"),this.quill?.selection.savedRange}registerFonts(){font.FontStyle.whitelist=void 0,y__default.default.register("formats/font",font.FontStyle,true);}isMultiSelect(){return this.app_.editor?this.app_.editor.multiple===true:false}dateEdit(e,n=0,i){let{editor:r}=this.app_,l=i||r.leafList.list,a=o=>{n&&(o.tag==="Box"||o.name==="Text")?e(o.children?.[0]||o):e(o);};l.length&&(Array.isArray(l)&&l.length>1?(this.app_.lockLayout(),l.forEach(a),this.app_.unlockLayout(),r.updateEditBox()):a(l[0]));}},c=q.getInstance();var pt=(t,e,n,i)=>{for(var r=e,l=t.length-1,a;l>=0;l--)(a=t[l])&&(r=(a(r))||r);return r};exports.HtmlText=class R extends core.Box{get __tag(){return "HtmlText"}constructor(t){let{text:e,fontSize:n,fontFamily:i,lineHeight:r,letterSpacing:l,textShadow:a,alignContent:o,...s}=t||{};super({editOuter:"TextEditTool",name:"HtmlText",x:0,y:0,editable:true,draggable:true,overflow:"show",...s}),t&&this.createTextElement(t);}createTextElement(t){let{text:e,fontSize:n,fontFamily:i,lineHeight:r,letterSpacing:l,textShadow:a,alignContent:o}=t,s="<style>p{margin:0;}sub,sup{font-size:63%;}.ql-ui{position:absolute}ol,ul{counter-reset:list-0;padding-left:1.5em;margin:0}ol>li,ul>li{counter-increment:list-0;list-style-type:none;position:relative;padding-left:0;margin:0}ol>li::before{content:counter(list-0,decimal) '. ';position:absolute;left:-1.5em;width:1.2em;text-align:right}ul>li::before{content:'\u2022';position:absolute;left:-1.5em;width:1.2em;text-align:right}li[data-list]{counter-set:list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9}.ql-align-center{text-align:center}.ql-align-right{text-align:right}.ql-align-left{text-align:left}.ql-align-justify{text-align:justify}</style>",d=`<div style="ove
4
+ rflow-wrap:break-word;word-break:break-all;"><p style="font-size: ${n}px; line-height: ${r}; letter-spacing: ${l}px; text-shadow: ${a};"><strong>Hello World</strong></p></div>`;if(t.children?.length>0)return;let u=new html.HTMLText({name:"Text",text:s+(e||d),x:0,y:0,data:{canChangeBox:false,textData:{fontFamily:i,fontSize:n,lineHeight:r,letterSpacing:l||0,textShadow:a,alignContent:o}},editConfig:{selectedStyle:{strokeWidth:0}}});this.add(u);}};exports.HtmlText=pt([core.registerUI()],exports.HtmlText);exports.checkLicense=M;exports.getLicenseInfo=ct;exports.htmlTextManage=c;exports.setHTMLText=St;exports.setLicense=st;exports.updataHtmlText=f;
package/dist/index.d.mts CHANGED
@@ -39,12 +39,13 @@ declare class HtmlText extends Box {
39
39
  }
40
40
 
41
41
  /**
42
- * License 验证器 V2 (RSA 签名版本)
42
+ * License 验证器 V3 (RSA 签名 + AES 加密双重验证版本)
43
43
  *
44
44
  * 主要改进:
45
- * 1. 使用 RSA 签名防止 License 伪造
46
- * 2. 保留原有的域名和过期时间验证
47
- * 3. 向后兼容旧版 License
45
+ * 1. 使用 AES-256-CBC 加密 License 数据
46
+ * 2. 使用 RSA 签名防止 License 伪造
47
+ * 3. 保留原有的域名和过期时间验证
48
+ * 4. 向后兼容旧版 License (仅 RSA 签名)
48
49
  */
49
50
  interface LicenseData {
50
51
  key: string;
package/dist/index.d.ts CHANGED
@@ -39,12 +39,13 @@ declare class HtmlText extends Box {
39
39
  }
40
40
 
41
41
  /**
42
- * License 验证器 V2 (RSA 签名版本)
42
+ * License 验证器 V3 (RSA 签名 + AES 加密双重验证版本)
43
43
  *
44
44
  * 主要改进:
45
- * 1. 使用 RSA 签名防止 License 伪造
46
- * 2. 保留原有的域名和过期时间验证
47
- * 3. 向后兼容旧版 License
45
+ * 1. 使用 AES-256-CBC 加密 License 数据
46
+ * 2. 使用 RSA 签名防止 License 伪造
47
+ * 3. 保留原有的域名和过期时间验证
48
+ * 4. 向后兼容旧版 License (仅 RSA 签名)
48
49
  */
49
50
  interface LicenseData {
50
51
  key: string;
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import {registerEditTool,registerInnerEditor,EditTool,EditorScaleEvent,InnerEditor}from'@leafer-in/editor';import {PointerEvent}from'leafer-ui';import {registerUI,Box,PointerEvent as PointerEvent$1,Matrix}from'@leafer-ui/core';import m,{Delta}from'quill';import'quill/dist/quill.core.css';import {FontStyle}from'quill/formats/font';import {HTMLText}from'@leafer-in/html';var f=async(t,e,n)=>{let{scaleX:i,scaleY:l}=t.worldTransform,s=Math.max(Math.abs(i),Math.abs(l)),a=document.querySelector("#textInnerEditor");if(a&&t.data.textData?.fontSize&&(a.style.fontSize=`${t.data.textData.fontSize*s}px`),a&&t.data.textData?.lineHeight&&(a.style.lineHeight=t.data.textData.lineHeight),a&&t.data.textData?.letterSpacing&&(a.style.letterSpacing=`${t.data.textData.letterSpacing}px`),a&&t.data.textData?.textShadow?a.style.textShadow=t.data.textData.textShadow:a.style.textShadow="none",a&&t.data.textData?.alignContent){let d=a.querySelector(".ql-editor");d.style.alignContent=t.data.textData.alignContent;}let r=c.getQuill().getSemanticHTML();if(r==="<p></p>"){t.text.includes("<style>@font-face")?t.text=t.text.split("</style>")[0]+"</style>":t.text="";return}if(t.text.includes("<style>@font-face")){let d=t.text.split("</style>")[0];if(n&&!d.includes(n)){let u=`@font-face {font-family: ${n.split(",")[0]};src: url(${e}) format('woff2') }</style>`;t.text=d+u+T(t,r,t.data.textData.fontSize,t.data.textData.lineHeight,t.data.textData.letterSpacing,t.data.textData.textShadow,t.data.textData?.alignContent);}else t.text=d+"</style>"+T(t,r,t.data.textData.fontSize,t.data.textData.lineHeight,t.data.textData.letterSpacing,t.data.textData.textShadow,t.data.textData?.alignContent);}else if(e&&n){let d=`<style>@font-face {font-family: ${n.split(",")[0]};src: url(${e}) format('woff2') }</style>`;t.text=d+T(t,r,t.data.textData.fontSize,t.data.textData.lineHeight,t.data.textData.letterSpacing,t.data.textData.textShadow,t.data.textData?.alignContent);}else t.text=T(t,r,t.data.textData.fontSize,t.data.textData.lineHeight,t.data.textData.letterSpacing,t.data.textData.textShadow,t.data.textData?.alignContent);},T=(t,e,n=20.67,i=1.5,l=0,s="none",a="start")=>{let{scaleX:o,scaleY:r}=t.worldTransform,d=Math.max(Math.abs(o),Math.abs(r)),u=document.createElement("div");u.innerHTML=e;let v={fontSize:`${n}px`,lineHeight:i,letterSpacing:`${l}px`,textShadow:s};u.querySelectorAll("p,ol,ul").forEach(z=>{Object.assign(z.style,v);});let h=u.innerHTML;/<p\b[^>]*><\/p>/.test(h)&&(h=h.replace(/<p\b([^>]*)><\/p>/g,"<p$1>&nbsp;</p>")),/&quot;/.test(h)&&(h=h.replace(/&quot;/g,""));let p;document.querySelector("#textInnerEditor");let C=c.getQuill(),S=Number((C.scroll.domNode.scrollHeight/d).toFixed(0));Number((C.scroll.domNode.scrollWidth/d).toFixed(0));["center","end"].includes(t.data.textData.alignContent)?t.parent.height<S?p=(S||t.__layout.boxBounds.height)+"px":p=`${t.parent.height}px`:t.parent.height<S?p=(S||t.__layout.boxBounds.height)+"px":p=`${t.parent.height}px`;let w="<style>p{margin:0;}sub,sup{font-size:63%;}.ql-ui{position:absolute}ol,ul{counter-reset:list-0;padding-left:1.5em;margin:0}ol>li,ul>li{counter-increment:list-0;list-style-type:none;position:relative;padding-left:0;margin:0}ol>li::before{content:counter(list-0,decimal) '. ';position:absolute;left:-1.5em;width:1.2em;text-align:right}ul>li::before{content:'\u2022';position:absolute;left:-1.5em;width:1.2em;text-align:right}li[data-list]{counter-set:list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9}.ql-align-center{text-align:center}.ql-align-right{text-align:right}.ql-align-left{text-align:left}.ql-align-justify{text-align:justify}</style>",g="";return t.parent.children[0].tag.includes("Shape")?g=w+`<div style="width: ${t.parent.width}px;height: ${t.parent.height}px;overflow-wrap:break-word;word-break:break-all;align-content:center;">${h}</div>`:t.data.canChangeBox?g=w+`<div style="width: ${t.parent.width}px;height:${p};overflow-wrap:break-word;word-break:break-all;align-content:${a};">${h}</div>`:t.data.textData.italic?g=w+h:g=w+`<div style="overflow-wrap:break-word;word-break:break-all;">${h}</div>`,console.log(g,"\u6700\u7EC8\u7684html\u5185\u5BB9"),g},gt=(t,e,n)=>{let i=c.getQuill(),{editor:l,canvas:s}=c.getCanvas();if(!i)return;let a=i.selection.savedRange;c.dateEdit(async o=>{if(t==="font")l.innerEditing?(a&&a.length?i.formatText(a.index,a.length,t,e):i.formatText(0,i.getLength()-1,t,e),o.data.textData.fontFamily=e,f(o,n??null,e??null)):(c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),i.formatText(0,i.getLength()-1,t,e),o.data.textData.fontFamily=e,f(o,n??null,e??null));else if(t==="fontSize")o.data.textData[t]=e,c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),f(o,n??null);else if(t==="textCase"){if(l.innerEditing){let r=i.getText(a.index,a.length),d=i.getFormat(a.index,a.length);i.deleteText(a.index,a.length);let u;r===r.toUpperCase()&&/[A-Z]/.test(r)?u=r.toLowerCase():(r===r.toLowerCase()&&/[a-z]/.test(r),u=r.toUpperCase()),i.insertText(a.index,u,d),a&&l.innerEditing&&i.setSelection(a.index,a.length);}}else if(t==="script"){let r="sub";e==="super"&&(r="sup"),l.innerEditing?a&&a.length?i.formatText(a.index,a.length,t,i.getFormat(a).script===e?false:r):i.formatText(0,i.getLength()-1,t,i.getFormat().script===e?false:r):(c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),i.formatText(0,i.getLength()-1,t,i.getFormat().script===e?false:r),f(o));}else if(t==="align")c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),l.innerEditing?i.format(t,e):i.formatLine(0,i.getLength(),t,e),f(o);else if(t==="alignContent")c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),o.data.textData[t]=e,f(o);else if(t==="lineHeight"||t==="letterSpacing")c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),o.data.textData[t]=e,f(o);else if(t==="color")c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),a&&a.length?i.formatText(a.index,a.length,t,e):i.formatText(0,i.getLength()-1,t,e),o.tag==="HTMLText"?f(o):o.parent.findOne("HTMLText")&&f(o.parent.findOne("HTMLText"));else if(t==="textShadow")c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),o.data.textData[t]=e,f(o);else if(t==="list"){if(c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),l.innerEditing){let[r]=i.getLine(a?.index||0);r.formats().list?i.format(t,false):i.format(t,e);}else {let[r]=i.getLine(a?.index||0);r.formats().list?i.formatLine(0,i.getLength(),t,false):i.formatLine(0,i.getLength(),t,e);}f(o);}else l.innerEditing?a&&a.length?i.formatText(a.index,a.length,t,e===void 0?!i.getFormat(a)[t]:e):i.formatText(0,i.getLength()-1,t,e===void 0?!i.getFormat()[t]:e):(c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),i.formatText(0,i.getLength()-1,t,e===void 0?!i.getFormat()[t]:e),f(o));},1);};var A=(t,e,n,i)=>{for(var l=e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(l=(a(l))||l);return l},B=class extends EditTool{constructor(t){super(t),this.quill=null,this.isUpdatingPoints=false,this.curveAmount=0,this.eventIds=[],this.updateBoxDebounced=this.debounce(e=>{f(e);},300);}get tag(){return "TextEditTool"}debounce(t,e){let n=null;return((...i)=>{n!==null&&window.clearTimeout(n),n=window.setTimeout(()=>t.apply(this,i),e);})}addEvent(){let{editor:t}=c.getCanvas(),e=t._target.findOne("HTMLText"),{scaleX:n,scaleY:i}=e.worldTransform,l=Math.max(Math.abs(n),Math.abs(i)),s=document.querySelector("#textInnerEditor"),{style:a}=s;this.eventIds=[t.on_(EditorScaleEvent.SCALE,o=>{e.data.canChangeBox||(e.data.canChangeBox=true),e.data.canChangeBox&&(a.width=e.parent.width*l+"px",a.height="auto");let r=1;e.parent.tag==="HtmlText"&&e.parent.lockRatio&&e.data?.baseSize?.width&&(r=e.parent.width/e.data?.baseSize.width,e.data.textData.fontSize=e.data.textData.fontSize*r),e.data?.baseSize?.width&&(e.data.baseSize.width=e.parent.width),this.updateBoxDebounced(e);}),t.on_(PointerEvent.DOUBLE_TAP,()=>{e.parent.locked||t.openInnerEditor(e,true);})];}onLoad(){let{editor:t}=c.getCanvas();console.log(t._target,123);let e=t._target.findOne("HTMLText"),{scaleX:n,scaleY:i}=e.worldTransform,l=Math.max(Math.abs(n),Math.abs(i));this.addEvent(),this.quill=c.getQuill(),this.quill.clipboard.dangerouslyPasteHTML(e.text);let s=document.querySelector("#textInnerEditor"),{style:a}=s;e.data.canChangeBox?(a.width=e.parent.width*l+"px",a.height=e.parent.height*l+"px"):(a.width="auto",a.height="auto");}updateChangeBoxBound(t){t&&t.set({width:t.__layout.boxBounds.width,height:t.__layout.boxBounds.height});}onUpdate(){let {editor:t}=c.getCanvas(),e=t._target.findOne("HTMLText");t._target;console.log("\u6587\u672Cbound\u66F4\u65B0"),this.curveAmount!=e.curveAmount&&this.isUpdatingPoints;}onUnload(){let{editor:t}=c.getCanvas();t.off_(this.eventIds);}onDestroy(){}};B=A([registerEditTool()],B);var K=(t,e,n,i)=>{for(var l=e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(l=(a(l))||l);return l},H=class extends InnerEditor{constructor(){super(...arguments),this.config={selectAll:false},this.eventIds=[],this.selectText=void 0,this.inBody=void 0,this.isHTMLText=void 0,this._keyEvent=void 0,this.quill=null,this.isComposing=false,this.onInput=async()=>{let{editDom:t}=this;f(this.editTarget);},this.isUpdatingPoints=false;}get tag(){return "TextEditor"}onLoad(){let{editor:t}=this,{config:e}=t.app,n=this.editTarget,{scaleX:i,scaleY:l}=n.worldTransform,s=Math.max(Math.abs(i),Math.abs(l));this.isHTMLText=!(n instanceof Text),this._keyEvent=e.keyEvent,e.keyEvent=false;let a=this.editDom=document.querySelector("#textInnerEditor"),{style:o}=a;if(o.visibility="visible",n.data.canChangeBox?(o.width=n.parent.width*s+"px",o.height=n.parent.height*s+"px"):(o.width="auto",o.height="auto"),o.outline="solid #8499EF",n.data.textData.fontSize&&(a.style.fontSize=`${n.data.textData.fontSize*s}px`),n.data.textData.lineHeight&&(a.style.lineHeight=n.data.textData.lineHeight),n.data.textData.letterSpacing&&(a.style.letterSpacing=`${n.data.textData.letterSpacing}px`),n.data.textData.textShadow?a.style.textShadow=`${n.data.textData.textShadow}`:a.style.textShadow="none",n.data.textData.alignContent){let r=a.querySelector(".ql-editor");r.style.alignContent=`${n.data.textData.alignContent}`;}this.quill=c.getQuill(),this.quill.clipboard.dangerouslyPasteHTML(n.text),n.parent.children[0].tag.includes("Shape")?(o.width=n.parent.width*s+"px",o.left="0px",this.quill.formatLine(0,this.quill.getLength(),"align","center")):this.quill.setSelection(0,this.quill.getLength()-1),this.quill.on("text-change",this.onInput),this.eventIds=[t.app.on_(PointerEvent$1.DOWN,r=>{let{target:d}=r.origin,u=false;for(;d;)d===a&&(u=true),d=d.parentElement;u||(t.closeInnerEditor(),t.cancel());})];}onUpdate(){let{editTarget:t}=this,{scaleX:e,scaleY:n}=t.worldTransform,i=Math.max(Math.abs(e),Math.abs(n)),{width:l,height:s}=t.parent.__local;l*=i,s*=i;let{x:a,y:o}=this.inBody?t.app.clientBounds:t.app.tree.clientBounds,{a:r,b:d,c:u,d:v,e:h,f:p}=new Matrix(t.worldTransform).scale(1/i).translateInner(0,0),{style:y}=this.editDom;y.transform=`matrix(${r},${d},${u},${v},${h},${p})`,y.left=a+"px",y.top=o+"px",t.set({visible:false});}onUnload(){let{editTarget:t,editor:e,editDom:n}=this;t&&(this.onInput(),e.app&&(e.app.config.keyEvent=this._keyEvent),e.off_(this.eventIds),this.editDom.style.visibility="hidden",this.eventIds=[]),t.parent&&t.parent.name=="Text"&&t.parent.children.some(i=>i.tag==="Box")?(t.parent.findOne("Box").opacity=1,t.visible=false):t.set({visible:true}),this.quill.getLength()===1&&t.parent.name==="Text"&&t.parent.remove(),this.quill.off("text-change",this.onInput);}};H=K([registerInnerEditor()],H);function E(t,{insertAt:e}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",e==="top"&&n.firstChild?n.insertBefore(i,n.firstChild):n.appendChild(i),i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t));}E(`.ql-editor{padding:0!important;line-height:unset!important;overflow:unset!important;outline:0}.ql-container{font-family:unset!important}.ql-editor p{margin:0!important}.ql-editor sub,.ql-editor sup{font-size:63%}.ql-editor sup{top:-.58em}.ql-editor sub{bottom:-.38em}.ql-editor ol{padding-left:0!important}
2
- `);var _="LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUFxaUFnU1hWM3dMKzh2YkZ2OVkwQwpEN1dBUjhPa2I4bjlmTWxpQjF3enZodTBrdVdZUWEvMUxvVDhHWVh6WWlRQVFBRk9zTTA0MGp2dlNRT2hRSWpiCjRaYXZ1NHUvWVA5bElPYjFKYnZnYkFoYVVOQnphL0l2UmFnaFlKYTJBc1cyRVhnZkVrdmMyUENNMS9zbVlFNnoKNjZiUmx1dnREK3FJZkpLVCtUUXJRRmp5TnNTZ0c2Z2R4MThrZTRMSStBejFPcklMbUsyMHlBU2tlRXpYT1BTVAplM3RNYThleHpZdmUzV0wyNHRHUHg5WHNvN1JyUEl1elZlajh0NDYrZ0c1Y0pQaVh0N1lqa0V2NEJOUUt5eUpoCkltOVRJdVZ6clFpa2NJNE14dExNSGdUMHpLcU9ZZ1NzcmEvTHNDd2ZOdzdtYWxITkU2c21YZWYyQ2E5RGhZODQKS1FJREFRQUIKLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg==";function k(t){let e=t.replace(/-----BEGIN PUBLIC KEY-----/,"").replace(/-----END PUBLIC KEY-----/,"").replace(/\s/g,"");return F(e)}function F(t){let e=atob(t),n=new Uint8Array(e.length);for(let i=0;i<e.length;i++)n[i]=e.charCodeAt(i);return n.buffer}async function G(){let t=atob(_),e=k(t);return await crypto.subtle.importKey("spki",e,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},false,["verify"])}async function U(t,e){try{let n=await G(),i=new TextEncoder().encode(t),l=F(e);return await crypto.subtle.verify("RSASSA-PKCS1-v1_5",n,l,i)}catch(n){return console.error("[RSA] Signature verification failed:",n),false}}async function tt(t){try{let e=atob(t),n=JSON.parse(e);if(!n.data||!n.signature)return console.error("[License] Invalid license format"),null;if(!await U(n.data,n.signature))return console.error("[License] Invalid signature - License may be tampered or forged"),null;let l=JSON.parse(n.data);return console.log("[License] Signature verified successfully"),l}catch(e){return console.error("[License] Failed to parse license:",e),null}}function et(t){if(!t||t.length===0)return true;let e=window.location.hostname;if(e==="localhost"||e==="127.0.0.1")return console.log("[License] Local development environment detected"),true;let n=t.some(i=>{if(i.startsWith("*.")){let l=i.slice(2);return e.endsWith(l)}return e===i});return n||(console.error(`[License] Domain not authorized: ${e}`),console.error("[License] Allowed domains:",t)),n}function it(t){if(!t)return true;try{let e=new Date(t),n=new Date;if(n>=e)return console.error(`[License] License has expired on ${t}`),!1;let i=Math.ceil((e.getTime()-n.getTime())/(1e3*60*60*24));return i<=7&&console.warn(`[License] License will expire in ${i} days`),!0}catch{return console.error("[License] Invalid expire date format:",t),false}}function nt(t){if(!t)return true;try{return new Date(t)>new Date?(console.error("[License] License issue date is in the future"),!1):!0}catch{return true}}async function D(t){try{let e=await tt(t);return e?nt(e.issueDate)?et(e.domains)?it(e.expireDate)?(console.log("[License] All validations passed"),console.log("[License] License info:",{key:e.key,domains:e.domains,expireDate:e.expireDate,features:e.features}),{valid:!0,data:e}):{valid:!1,error:"License has expired",data:e}:{valid:!1,error:`License not valid for domain: ${window.location.hostname}`,data:e}:{valid:!1,error:"Invalid license issue date",data:e}:{valid:!1,error:"Invalid license key or signature verification failed"}}catch(e){return console.error("[License] Validation error:",e),{valid:false,error:"License validation failed"}}}var L=null,b=null,x=false;async function at(t){console.log("[License] Activating license...");let e=await D(t);return e.valid&&e.data?(L=t,b=e.data,x=true,console.log("[License] \u2705 License activated successfully"),console.log(`[License] Valid until: ${e.data.expireDate||"unlimited"}`),true):(L=null,b=null,x=false,console.error("[License] \u274C License activation failed:",e.error),false)}async function M(){if(!L)return console.warn("[License] No license key provided"),false;if(!x)return console.warn("[License] License is not valid"),false;let t=await D(L);return x=t.valid,x||(console.error("[License] License validation failed:",t.error),b=null),x}function lt(){return b}var q=class t{constructor(){this.quill=null,this.app_=null;}static getInstance(){return t.instance||(t.instance=new t),t.instance}async init(e){if(!await M())throw new Error("[HtmlTextManage] \u6388\u6743\u5931\u8D25\u8BF7\u8054\u7CFB\u4F5C\u8005\u83B7\u53D6\u6388\u6743 \u90AE\u7BB1 : 408550179@qq.com \u5FAE\u4FE1 : cym5640");if(this.app_=e,this.quill)return this.quill;let i=document.getElementById("textInnerEditor");if(i)this.quill=this.app_.editor.quill;else return i=document.createElement("div"),i.id="textInnerEditor",i.style.position="fixed",i.style.transformOrigin="left top",i.style.overflowWrap="break-word",i.style.wordBreak="break-all",i.style.visibility="hidden",document.body.appendChild(i),this.quill=new m("#textInnerEditor",{theme:void 0,modules:{toolbar:false,keyboard:{bindings:{enter:{key:"Enter",handler:l=>{let[s]=this.quill.getLine(l.index),a=m.import("blots/block");if(!a?.bubbleFormats)return true;let o=a.bubbleFormats(s),r=new Delta().retain(l.index).delete(l.length).insert(`
3
- `,o);return this.quill.updateContents(r,m.sources.USER),this.quill.setSelection(l.index+1,m.sources.SILENT),false}}}}}}),this.app_.editor.quill=this.quill,this.registerFonts(),this.quill}getQuill(){if(!this.quill)throw new Error("Quill editor not initialized. Call init() first.");return this.quill}getCanvas(){if(!this.app_)throw new Error("app_ editor not initialized. Call init() first.");return this.app_}getSelection(){return console.log(this.quill?.selection.savedRange,"this.quill?.selection.savedRange"),this.quill?.selection.savedRange}registerFonts(){FontStyle.whitelist=void 0,m.register("formats/font",FontStyle,true);}isMultiSelect(){return this.app_.editor?this.app_.editor.multiple===true:false}dateEdit(e,n=0,i){let{editor:l}=this.app_,s=i||l.leafList.list,a=o=>{n&&(o.tag==="Box"||o.name==="Text")?e(o.children?.[0]||o):e(o);};s.length&&(Array.isArray(s)&&s.length>1?(this.app_.lockLayout(),s.forEach(a),this.app_.unlockLayout(),l.updateEditBox()):a(s[0]));}},c=q.getInstance();var ct=(t,e,n,i)=>{for(var l=e,s=t.length-1,a;s>=0;s--)(a=t[s])&&(l=(a(l))||l);return l},P=class extends Box{get __tag(){return "HtmlText"}constructor(t){let{text:e,fontSize:n,fontFamily:i,lineHeight:l,letterSpacing:s,textShadow:a,alignContent:o,...r}=t||{};super({editOuter:"TextEditTool",name:"HtmlText",x:0,y:0,editable:true,draggable:true,overflow:"show",...r}),t&&this.createTextElement(t);}createTextElement(t){let{text:e,fontSize:n,fontFamily:i,lineHeight:l,letterSpacing:s,textShadow:a,alignContent:o}=t,r="<style>p{margin:0;}sub,sup{font-size:63%;}.ql-ui{position:absolute}ol,ul{counter-reset:list-0;padding-left:1.5em;margin:0}ol>li,ul>li{counter-increment:list-0;list-style-type:none;position:relative;padding-left:0;margin:0}ol>li::before{content:counter(list-0,decimal) '. ';position:absolute;left:-1.5em;width:1.2em;text-align:right}ul>li::before{content:'\u2022';position:absolute;left:-1.5em;width:1.2em;text-align:right}li[data-list]{counter-set:list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9}.ql-align-center{text-align:center}.ql-align-right{text-align:right}.ql-align-left{text-align:left}.ql-align-justify{text-align:justify}</style>",d=`<div style="ove
4
- rflow-wrap:break-word;word-break:break-all;"><p style="font-size: ${n}px; line-height: ${l}; letter-spacing: ${s}px; text-shadow: ${a};"><strong>Hello World</strong></p></div>`,u=new HTMLText({name:"Text",text:r+(e||d),x:0,y:0,data:{canChangeBox:false,textData:{fontFamily:i,fontSize:n,lineHeight:l,letterSpacing:s||0,textShadow:a,alignContent:o}},editConfig:{selectedStyle:{strokeWidth:0}}});this.add(u);}};P=ct([registerUI()],P);export{P as HtmlText,M as checkLicense,lt as getLicenseInfo,c as htmlTextManage,gt as setHTMLText,at as setLicense,f as updataHtmlText};
1
+ import {registerEditTool,registerInnerEditor,EditTool,EditorScaleEvent,InnerEditor}from'@leafer-in/editor';import {PointerEvent}from'leafer-ui';import {registerUI,Box,PointerEvent as PointerEvent$1,Matrix}from'@leafer-ui/core';import y,{Delta}from'quill';import'quill/dist/quill.core.css';import {FontStyle}from'quill/formats/font';import x from'crypto-js';import {HTMLText}from'@leafer-in/html';var f=async(t,e,n)=>{let{scaleX:i,scaleY:r}=t.worldTransform,l=Math.max(Math.abs(i),Math.abs(r)),a=document.querySelector("#textInnerEditor");if(a&&t.data.textData?.fontSize&&(a.style.fontSize=`${t.data.textData.fontSize*l}px`),a&&t.data.textData?.lineHeight&&(a.style.lineHeight=t.data.textData.lineHeight),a&&t.data.textData?.letterSpacing&&(a.style.letterSpacing=`${t.data.textData.letterSpacing}px`),a&&t.data.textData?.textShadow?a.style.textShadow=t.data.textData.textShadow:a.style.textShadow="none",a&&t.data.textData?.alignContent){let d=a.querySelector(".ql-editor");d.style.alignContent=t.data.textData.alignContent;}let s=c.getQuill().getSemanticHTML();if(s==="<p></p>"){t.text.includes("<style>@font-face")?t.text=t.text.split("</style>")[0]+"</style>":t.text="";return}if(t.text.includes("<style>@font-face")){let d=t.text.split("</style>")[0];if(n&&!d.includes(n)){let u=`@font-face {font-family: ${n.split(",")[0]};src: url(${e}) format('woff2') }</style>`;t.text=d+u+T(t,s,t.data.textData.fontSize,t.data.textData.lineHeight,t.data.textData.letterSpacing,t.data.textData.textShadow,t.data.textData?.alignContent);}else t.text=d+"</style>"+T(t,s,t.data.textData.fontSize,t.data.textData.lineHeight,t.data.textData.letterSpacing,t.data.textData.textShadow,t.data.textData?.alignContent);}else if(e&&n){let d=`<style>@font-face {font-family: ${n.split(",")[0]};src: url(${e}) format('woff2') }</style>`;t.text=d+T(t,s,t.data.textData.fontSize,t.data.textData.lineHeight,t.data.textData.letterSpacing,t.data.textData.textShadow,t.data.textData?.alignContent);}else t.text=T(t,s,t.data.textData.fontSize,t.data.textData.lineHeight,t.data.textData.letterSpacing,t.data.textData.textShadow,t.data.textData?.alignContent);},T=(t,e,n=20.67,i=1.5,r=0,l="none",a="start")=>{let{scaleX:o,scaleY:s}=t.worldTransform,d=Math.max(Math.abs(o),Math.abs(s)),u=document.createElement("div");u.innerHTML=e;let L={fontSize:`${n}px`,lineHeight:i,letterSpacing:`${r}px`,textShadow:l};u.querySelectorAll("p,ol,ul").forEach(N=>{Object.assign(N.style,L);});let p=u.innerHTML;/<p\b[^>]*><\/p>/.test(p)&&(p=p.replace(/<p\b([^>]*)><\/p>/g,"<p$1>&nbsp;</p>")),/&quot;/.test(p)&&(p=p.replace(/&quot;/g,""));let h;document.querySelector("#textInnerEditor");let B=c.getQuill(),w=Number((B.scroll.domNode.scrollHeight/d).toFixed(0));Number((B.scroll.domNode.scrollWidth/d).toFixed(0));["center","end"].includes(t.data.textData.alignContent)?t.parent.height<w?h=(w||t.__layout.boxBounds.height)+"px":h=`${t.parent.height}px`:t.parent.height<w?h=(w||t.__layout.boxBounds.height)+"px":h=`${t.parent.height}px`;let b="<style>p{margin:0;}sub,sup{font-size:63%;}.ql-ui{position:absolute}ol,ul{counter-reset:list-0;padding-left:1.5em;margin:0}ol>li,ul>li{counter-increment:list-0;list-style-type:none;position:relative;padding-left:0;margin:0}ol>li::before{content:counter(list-0,decimal) '. ';position:absolute;left:-1.5em;width:1.2em;text-align:right}ul>li::before{content:'\u2022';position:absolute;left:-1.5em;width:1.2em;text-align:right}li[data-list]{counter-set:list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9}.ql-align-center{text-align:center}.ql-align-right{text-align:right}.ql-align-left{text-align:left}.ql-align-justify{text-align:justify}</style>",g="";return t.parent.children[0].tag.includes("Shape")?g=b+`<div style="width: ${t.parent.width}px;height: ${t.parent.height}px;overflow-wrap:break-word;word-break:break-all;align-content:center;">${p}</div>`:t.data.canChangeBox?g=b+`<div style="width: ${t.parent.width}px;height:${h};overflow-wrap:break-word;word-break:break-all;align-content:${a};">${p}</div>`:t.data.textData.italic?g=b+p:g=b+`<div style="overflow-wrap:break-word;word-break:break-all;">${p}</div>`,console.log(g,"\u6700\u7EC8\u7684html\u5185\u5BB9"),g},St=(t,e,n)=>{let i=c.getQuill(),{editor:r,canvas:l}=c.getCanvas();if(!i)return;let a=i.selection.savedRange;c.dateEdit(async o=>{if(t==="font")r.innerEditing?(a&&a.length?i.formatText(a.index,a.length,t,e):i.formatText(0,i.getLength()-1,t,e),o.data.textData.fontFamily=e,f(o,n??null,e??null)):(c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),i.formatText(0,i.getLength()-1,t,e),o.data.textData.fontFamily=e,f(o,n??null,e??null));else if(t==="fontSize")o.data.textData[t]=e,c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),f(o,n??null);else if(t==="textCase"){if(r.innerEditing){let s=i.getText(a.index,a.length),d=i.getFormat(a.index,a.length);i.deleteText(a.index,a.length);let u;s===s.toUpperCase()&&/[A-Z]/.test(s)?u=s.toLowerCase():(s===s.toLowerCase()&&/[a-z]/.test(s),u=s.toUpperCase()),i.insertText(a.index,u,d),a&&r.innerEditing&&i.setSelection(a.index,a.length);}}else if(t==="script"){let s="sub";e==="super"&&(s="sup"),r.innerEditing?a&&a.length?i.formatText(a.index,a.length,t,i.getFormat(a).script===e?false:s):i.formatText(0,i.getLength()-1,t,i.getFormat().script===e?false:s):(c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),i.formatText(0,i.getLength()-1,t,i.getFormat().script===e?false:s),f(o));}else if(t==="align")c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),r.innerEditing?i.format(t,e):i.formatLine(0,i.getLength(),t,e),f(o);else if(t==="alignContent")c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),o.data.textData[t]=e,f(o);else if(t==="lineHeight"||t==="letterSpacing")c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),o.data.textData[t]=e,f(o);else if(t==="color")c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),a&&a.length?i.formatText(a.index,a.length,t,e):i.formatText(0,i.getLength()-1,t,e),o.tag==="HTMLText"?f(o):o.parent.findOne("HTMLText")&&f(o.parent.findOne("HTMLText"));else if(t==="textShadow")c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),o.data.textData[t]=e,f(o);else if(t==="list"){if(c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),r.innerEditing){let[s]=i.getLine(a?.index||0);s.formats().list?i.format(t,false):i.format(t,e);}else {let[s]=i.getLine(a?.index||0);s.formats().list?i.formatLine(0,i.getLength(),t,false):i.formatLine(0,i.getLength(),t,e);}f(o);}else r.innerEditing?a&&a.length?i.formatText(a.index,a.length,t,e===void 0?!i.getFormat(a)[t]:e):i.formatText(0,i.getLength()-1,t,e===void 0?!i.getFormat()[t]:e):(c.isMultiSelect()&&i.clipboard.dangerouslyPasteHTML(o.text),i.formatText(0,i.getLength()-1,t,e===void 0?!i.getFormat()[t]:e),f(o));},1);};var Y=(t,e,n,i)=>{for(var r=e,l=t.length-1,a;l>=0;l--)(a=t[l])&&(r=(a(r))||r);return r},H=class extends EditTool{constructor(t){super(t),this.quill=null,this.isUpdatingPoints=false,this.curveAmount=0,this.eventIds=[],this.updateBoxDebounced=this.debounce(e=>{f(e);},300);}get tag(){return "TextEditTool"}debounce(t,e){let n=null;return((...i)=>{n!==null&&window.clearTimeout(n),n=window.setTimeout(()=>t.apply(this,i),e);})}addEvent(){let{editor:t}=c.getCanvas(),e=t._target.findOne("HTMLText"),{scaleX:n,scaleY:i}=e.worldTransform,r=Math.max(Math.abs(n),Math.abs(i)),l=document.querySelector("#textInnerEditor"),{style:a}=l;this.eventIds=[t.on_(EditorScaleEvent.SCALE,o=>{e.data.canChangeBox||(e.data.canChangeBox=true),e.data.canChangeBox&&(a.width=e.parent.width*r+"px",a.height="auto");let s=1;e.parent.tag==="HtmlText"&&e.parent.lockRatio&&e.data?.baseSize?.width&&(s=e.parent.width/e.data?.baseSize.width,e.data.textData.fontSize=e.data.textData.fontSize*s),e.data?.baseSize?.width&&(e.data.baseSize.width=e.parent.width),this.updateBoxDebounced(e);}),t.on_(PointerEvent.DOUBLE_TAP,()=>{e.parent.locked||t.openInnerEditor(e,true);})];}onLoad(){let{editor:t}=c.getCanvas();console.log(t._target,123);let e=t._target.findOne("HTMLText"),{scaleX:n,scaleY:i}=e.worldTransform,r=Math.max(Math.abs(n),Math.abs(i));this.addEvent(),this.quill=c.getQuill(),this.quill.clipboard.dangerouslyPasteHTML(e.text);let l=document.querySelector("#textInnerEditor"),{style:a}=l;e.data.canChangeBox?(a.width=e.parent.width*r+"px",a.height=e.parent.height*r+"px"):(a.width="auto",a.height="auto");}updateChangeBoxBound(t){t&&t.set({width:t.__layout.boxBounds.width,height:t.__layout.boxBounds.height});}onUpdate(){let {editor:t}=c.getCanvas(),e=t._target.findOne("HTMLText");t._target;console.log("\u6587\u672Cbound\u66F4\u65B0"),this.curveAmount!=e.curveAmount&&this.isUpdatingPoints;}onUnload(){let{editor:t}=c.getCanvas();t.off_(this.eventIds);}onDestroy(){}};H=Y([registerEditTool()],H);var k=(t,e,n,i)=>{for(var r=e,l=t.length-1,a;l>=0;l--)(a=t[l])&&(r=(a(r))||r);return r},_=class extends InnerEditor{constructor(){super(...arguments),this.config={selectAll:false},this.eventIds=[],this.selectText=void 0,this.inBody=void 0,this.isHTMLText=void 0,this._keyEvent=void 0,this.quill=null,this.isComposing=false,this.onInput=async()=>{let{editDom:t}=this;f(this.editTarget);},this.isUpdatingPoints=false;}get tag(){return "TextEditor"}onLoad(){let{editor:t}=this,{config:e}=t.app,n=this.editTarget,{scaleX:i,scaleY:r}=n.worldTransform,l=Math.max(Math.abs(i),Math.abs(r));this.isHTMLText=!(n instanceof Text),this._keyEvent=e.keyEvent,e.keyEvent=false;let a=this.editDom=document.querySelector("#textInnerEditor"),{style:o}=a;if(o.visibility="visible",n.data.canChangeBox?(o.width=n.parent.width*l+"px",o.height=n.parent.height*l+"px"):(o.width="auto",o.height="auto"),o.outline="solid #8499EF",n.data.textData.fontSize&&(a.style.fontSize=`${n.data.textData.fontSize*l}px`),n.data.textData.lineHeight&&(a.style.lineHeight=n.data.textData.lineHeight),n.data.textData.letterSpacing&&(a.style.letterSpacing=`${n.data.textData.letterSpacing}px`),n.data.textData.textShadow?a.style.textShadow=`${n.data.textData.textShadow}`:a.style.textShadow="none",n.data.textData.alignContent){let s=a.querySelector(".ql-editor");s.style.alignContent=`${n.data.textData.alignContent}`;}this.quill=c.getQuill(),this.quill.clipboard.dangerouslyPasteHTML(n.text),n.parent.children[0].tag.includes("Shape")?(o.width=n.parent.width*l+"px",o.left="0px",this.quill.formatLine(0,this.quill.getLength(),"align","center")):this.quill.setSelection(0,this.quill.getLength()-1),this.quill.on("text-change",this.onInput),this.eventIds=[t.app.on_(PointerEvent$1.DOWN,s=>{let{target:d}=s.origin,u=false;for(;d;)d===a&&(u=true),d=d.parentElement;u||(t.closeInnerEditor(),t.cancel());})];}onUpdate(){let{editTarget:t}=this,{scaleX:e,scaleY:n}=t.worldTransform,i=Math.max(Math.abs(e),Math.abs(n)),{width:r,height:l}=t.parent.__local;r*=i,l*=i;let{x:a,y:o}=this.inBody?t.app.clientBounds:t.app.tree.clientBounds,{a:s,b:d,c:u,d:L,e:p,f:h}=new Matrix(t.worldTransform).scale(1/i).translateInner(0,0),{style:S}=this.editDom;S.transform=`matrix(${s},${d},${u},${L},${p},${h})`,S.left=a+"px",S.top=o+"px",t.set({visible:false});}onUnload(){let{editTarget:t,editor:e,editDom:n}=this;t&&(this.onInput(),e.app&&(e.app.config.keyEvent=this._keyEvent),e.off_(this.eventIds),this.editDom.style.visibility="hidden",this.eventIds=[]),t.parent&&t.parent.name=="Text"&&t.parent.children.some(i=>i.tag==="Box")?(t.parent.findOne("Box").opacity=1,t.visible=false):t.set({visible:true}),this.quill.getLength()===1&&t.parent.name==="Text"&&t.parent.remove(),this.quill.off("text-change",this.onInput);}};_=k([registerInnerEditor()],_);function D(t,{insertAt:e}={}){if(typeof document>"u")return;let n=document.head||document.getElementsByTagName("head")[0],i=document.createElement("style");i.type="text/css",e==="top"&&n.firstChild?n.insertBefore(i,n.firstChild):n.appendChild(i),i.styleSheet?i.styleSheet.cssText=t:i.appendChild(document.createTextNode(t));}D(`.ql-editor{padding:0!important;line-height:unset!important;overflow:unset!important;outline:0}.ql-container{font-family:unset!important}.ql-editor p{margin:0!important}.ql-editor sub,.ql-editor sup{font-size:63%}.ql-editor sup{top:-.58em}.ql-editor sub{bottom:-.38em}.ql-editor ol{padding-left:0!important}
2
+ `);var U="LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQklqQU5CZ2txaGtpRzl3MEJBUUVGQUFPQ0FROEFNSUlCQ2dLQ0FRRUFxaUFnU1hWM3dMKzh2YkZ2OVkwQwpEN1dBUjhPa2I4bjlmTWxpQjF3enZodTBrdVdZUWEvMUxvVDhHWVh6WWlRQVFBRk9zTTA0MGp2dlNRT2hRSWpiCjRaYXZ1NHUvWVA5bElPYjFKYnZnYkFoYVVOQnphL0l2UmFnaFlKYTJBc1cyRVhnZkVrdmMyUENNMS9zbVlFNnoKNjZiUmx1dnREK3FJZkpLVCtUUXJRRmp5TnNTZ0c2Z2R4MThrZTRMSStBejFPcklMbUsyMHlBU2tlRXpYT1BTVAplM3RNYThleHpZdmUzV0wyNHRHUHg5WHNvN1JyUEl1elZlajh0NDYrZ0c1Y0pQaVh0N1lqa0V2NEJOUUt5eUpoCkltOVRJdVZ6clFpa2NJNE14dExNSGdUMHpLcU9ZZ1NzcmEvTHNDd2ZOdzdtYWxITkU2c21YZWYyQ2E5RGhZODQKS1FJREFRQUIKLS0tLS1FTkQgUFVCTElDIEtFWS0tLS0tCg==";function it(t){let e=t.replace(/-----BEGIN PUBLIC KEY-----/,"").replace(/-----END PUBLIC KEY-----/,"").replace(/\s/g,"");return F(e)}function F(t){let e=atob(t),n=new Uint8Array(e.length);for(let i=0;i<e.length;i++)n[i]=e.charCodeAt(i);return n.buffer}async function nt(){let t=atob(U),e=it(t);return await crypto.subtle.importKey("spki",e,{name:"RSASSA-PKCS1-v1_5",hash:"SHA-256"},false,["verify"])}async function A(t,e){try{let n=await nt(),i=new TextEncoder().encode(t),r=F(e);return await crypto.subtle.verify("RSASSA-PKCS1-v1_5",n,r,i)}catch(n){return console.error("[RSA] Signature verification failed:",n),false}}var P="c19496eb17719960b6c3cebab0ef5eddfce5d0315ab8c5af86a52fbda434fea9",I="ce1e3e8974f1392b3c5803b34ecf659f";function z(t){try{let e=x.enc.Hex.parse(P),n=x.enc.Hex.parse(I),r=x.AES.decrypt(t,e,{iv:n,mode:x.mode.CBC,padding:x.pad.Pkcs7}).toString(x.enc.Utf8);if(!r)throw new Error("Decryption resulted in empty string - invalid ciphertext or wrong key");return r}catch(e){throw console.error("[AES] Decryption failed:",e),e}}async function at(t){try{let e=atob(t),n=JSON.parse(e);if(!n.data||!n.signature||!await A(n.data,n.signature))return null;let r=n.data;if(n.encrypted)try{r=z(n.data);}catch{return null}return JSON.parse(r)}catch{return null}}function rt(t){if(!t||t.length===0)return true;let e=window.location.hostname;if(e==="localhost"||e==="127.0.0.1")return console.log("[License] Local development environment detected"),true;let n=t.some(i=>{if(i.startsWith("*.")){let r=i.slice(2);return e.endsWith(r)}return e===i});return n||(console.error(`[License] Domain not authorized: ${e}`),console.error("[License] Allowed domains:",t)),n}function ot(t){if(!t)return true;try{let e=new Date(t),n=new Date;if(n>=e)return console.error(`[License] License has expired on ${t}`),!1;let i=Math.ceil((e.getTime()-n.getTime())/(1e3*60*60*24));return i<=7&&console.warn(`[License] License will expire in ${i} days`),!0}catch{return console.error("[License] Invalid expire date format:",t),false}}function lt(t){if(!t)return true;try{return new Date(t)>new Date?(console.error("[License] License issue date is in the future"),!1):!0}catch{return true}}async function C(t){try{let e=await at(t);return e?lt(e.issueDate)?rt(e.domains)?ot(e.expireDate)?(console.log("[License] License info:",{key:e.key,domains:e.domains,expireDate:e.expireDate,features:e.features}),{valid:!0,data:e}):{valid:!1,error:"License has expired",data:e}:{valid:!1,error:`License not valid for domain: ${window.location.hostname}`,data:e}:{valid:!1,error:"Invalid license issue date",data:e}:{valid:!1,error:"Invalid license key or signature verification failed"}}catch(e){return console.error("[License] Validation error:",e),{valid:false,error:"License validation failed"}}}var E=null,v=null,m=false;async function st(t){console.log("[License] Activating license...");let e=await C(t);return e.valid&&e.data?(E=t,v=e.data,m=true,console.log("[License] \u2705 License activated successfully"),console.log(`[License] Valid until: ${e.data.expireDate||"unlimited"}`),true):(E=null,v=null,m=false,console.error("[License] \u274C License activation failed:",e.error),false)}async function M(){if(!E)return console.warn("[License] No license key provided"),false;if(!m)return console.warn("[License] License is not valid"),false;let t=await C(E);return m=t.valid,m||(console.error("[License] License validation failed:",t.error),v=null),m}function ct(){return v}var q=class t{constructor(){this.quill=null,this.app_=null;}static getInstance(){return t.instance||(t.instance=new t),t.instance}async init(e){if(!await M())throw new Error("[HtmlTextManage] \u6388\u6743\u5931\u8D25\u8BF7\u8054\u7CFB\u4F5C\u8005\u83B7\u53D6\u6388\u6743 \u90AE\u7BB1 : 408550179@qq.com \u5FAE\u4FE1 : cym5640");if(this.app_=e,this.quill)return this.quill;let i=document.getElementById("textInnerEditor");if(i)this.quill=this.app_.editor.quill;else return i=document.createElement("div"),i.id="textInnerEditor",i.style.position="fixed",i.style.transformOrigin="left top",i.style.overflowWrap="break-word",i.style.wordBreak="break-all",i.style.visibility="hidden",document.body.appendChild(i),this.quill=new y("#textInnerEditor",{theme:void 0,modules:{toolbar:false,keyboard:{bindings:{enter:{key:"Enter",handler:r=>{let[l]=this.quill.getLine(r.index),a=y.import("blots/block");if(!a?.bubbleFormats)return true;let o=a.bubbleFormats(l),s=new Delta().retain(r.index).delete(r.length).insert(`
3
+ `,o);return this.quill.updateContents(s,y.sources.USER),this.quill.setSelection(r.index+1,y.sources.SILENT),false}}}}}}),this.app_.editor.quill=this.quill,this.registerFonts(),this.quill}getQuill(){if(!this.quill)throw new Error("Quill editor not initialized. Call init() first.");return this.quill}getCanvas(){if(!this.app_)throw new Error("app_ editor not initialized. Call init() first.");return this.app_}getSelection(){return console.log(this.quill?.selection.savedRange,"this.quill?.selection.savedRange"),this.quill?.selection.savedRange}registerFonts(){FontStyle.whitelist=void 0,y.register("formats/font",FontStyle,true);}isMultiSelect(){return this.app_.editor?this.app_.editor.multiple===true:false}dateEdit(e,n=0,i){let{editor:r}=this.app_,l=i||r.leafList.list,a=o=>{n&&(o.tag==="Box"||o.name==="Text")?e(o.children?.[0]||o):e(o);};l.length&&(Array.isArray(l)&&l.length>1?(this.app_.lockLayout(),l.forEach(a),this.app_.unlockLayout(),r.updateEditBox()):a(l[0]));}},c=q.getInstance();var pt=(t,e,n,i)=>{for(var r=e,l=t.length-1,a;l>=0;l--)(a=t[l])&&(r=(a(r))||r);return r},R=class extends Box{get __tag(){return "HtmlText"}constructor(t){let{text:e,fontSize:n,fontFamily:i,lineHeight:r,letterSpacing:l,textShadow:a,alignContent:o,...s}=t||{};super({editOuter:"TextEditTool",name:"HtmlText",x:0,y:0,editable:true,draggable:true,overflow:"show",...s}),t&&this.createTextElement(t);}createTextElement(t){let{text:e,fontSize:n,fontFamily:i,lineHeight:r,letterSpacing:l,textShadow:a,alignContent:o}=t,s="<style>p{margin:0;}sub,sup{font-size:63%;}.ql-ui{position:absolute}ol,ul{counter-reset:list-0;padding-left:1.5em;margin:0}ol>li,ul>li{counter-increment:list-0;list-style-type:none;position:relative;padding-left:0;margin:0}ol>li::before{content:counter(list-0,decimal) '. ';position:absolute;left:-1.5em;width:1.2em;text-align:right}ul>li::before{content:'\u2022';position:absolute;left:-1.5em;width:1.2em;text-align:right}li[data-list]{counter-set:list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9}.ql-align-center{text-align:center}.ql-align-right{text-align:right}.ql-align-left{text-align:left}.ql-align-justify{text-align:justify}</style>",d=`<div style="ove
4
+ rflow-wrap:break-word;word-break:break-all;"><p style="font-size: ${n}px; line-height: ${r}; letter-spacing: ${l}px; text-shadow: ${a};"><strong>Hello World</strong></p></div>`;if(t.children?.length>0)return;let u=new HTMLText({name:"Text",text:s+(e||d),x:0,y:0,data:{canChangeBox:false,textData:{fontFamily:i,fontSize:n,lineHeight:r,letterSpacing:l||0,textShadow:a,alignContent:o}},editConfig:{selectedStyle:{strokeWidth:0}}});this.add(u);}};R=pt([registerUI()],R);export{R as HtmlText,M as checkLicense,ct as getLicenseInfo,c as htmlTextManage,St as setHTMLText,st as setLicense,f as updataHtmlText};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chenyomi/leafer-htmltext-edit",
3
- "version": "2.1.6",
3
+ "version": "2.1.8",
4
4
  "description": "A text editor plugin for Leafer UI with HTML text support",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",