UNPKG

jodit-pro

Version:

PRO Version of Jodit Editor

2 lines (1 loc) 1.42 kB
var p=Object.defineProperty;var c=(f,o)=>p(f,"name",{value:o,configurable:!0});import{isAllowedSubdomain as u,validateLicense as m}from"./helpers/helpers.js";import{IS_TEST as h}from"jodit/esm/core/constants.js";import{Dom as l}from"jodit/esm/core/dom/dom.js";import{isBoolean as v}from"jodit/esm/core/helpers/checker/is-boolean.js";import{isString as j}from"jodit/esm/core/helpers/checker/is-string.js";import{Plugin as y}from"jodit/esm/core/plugin/plugin.js";import{JoditPro as R}from"../../jodit-pro.js";const a=class a extends y{static make(o){return new a(o)}afterInit(o){this.j.e.on("checkReserve",async i=>{const e=this.j.o.license;if(u(i))return"normal";if(!e)return"";const r=i;if(!j(e))return"";let t=m(e,r);return!t&&e[12]>"A"&&!h&&(t=await this.validateLicenseRemote(e,r)),t?"normal":""})}beforeDestruct(o){}async validateLicenseRemote(o,i){const e="validateJoditLicenseRemote",r=this.j.storage.get(e);if(r&&m(r,i))return!0;const t=document.createElement("script");return t.src=`https://xdsoft.net/jodit/pro/api/licenses/validate/?code=${encodeURIComponent(o)}&host=${encodeURIComponent(i)}`,document.body.appendChild(t),this.j.async.promise(s=>{window.onJoditResolveKeyCode=n=>{try{if(v(n))return s(n);m(n,i)?(this.j.storage.set(e,n),s(!0)):s(!1)}finally{l.safeRemove(t)}},this.j.async.setTimeout(()=>{s(!1),l.safeRemove(t)},3e3)})}};c(a,"license");let d=a;R.plugins.add("license",d);export{d as license};