UNPKG

jodit-pro

Version:

PRO Version of Jodit Editor

2 lines (1 loc) 1.51 kB
var $=Object.defineProperty;var u=(t,n)=>$(t,"name",{value:n,configurable:!0});import{IS_PROD as d}from"jodit/esm/core/constants.js";import{isBoolean as l}from"jodit/esm/core/helpers/checker/is-boolean.js";import{trim as w}from"jodit/esm/core/helpers/string/trim.js";function b(t,n=()=>!0,s=!0,i){switch(!0){case t.isComment:case t.isText:{if(!n(t))return"";const{nodeValue:e}=t.attributes;return t.isComment?`<!--${e}-->`:e}case t.isElement:{const{attributes:e}=t,r=j(t,n,s,i);if(!t.attributes["jd-safe"]&&s&&r.replace(/[\n\t]/g,"").length===0&&!t.isSingle)return"";const c=Object.keys(e).map(o=>o==="style"||e[o]==null||/^jd-/.test(o)?"":`${o}="${p(e[o])}"`).filter(Boolean),{str:g}=t.style,f=p(g(o=>a(o,i)));if(f&&c.push(`style="${f}"`),s&&c.length===0&&["span","a"].includes(t.name))return r;const h=c.length?" "+c.join(" "):"";return n(t)?t.isSingle?`<${t.name}${h}/>`:`<${t.name}${h}>${r}</${t.name}>`:r}default:if(!d)throw Error("Need implementation for this type")}return""}u(b,"html");function a(t,n){var s;if(!n)return!0;if(a.cache.has(n)){const r=(s=a.cache.get(n))===null||s===void 0?void 0:s.get(t);if(l(r))return r}const i=n.some(r=>new RegExp(r).test(t)),e=a.cache.get(n)||new Map;return e.set(t,i),a.cache.set(n,e),i}u(a,"keyInList"),a.cache=new WeakMap;function j(t,n=()=>!0,s=!0,i){let e=t.map(r=>b(r,n,s,i)).join("");return t.name==="p"&&w(e).length===0&&(e="&nbsp;"),e}u(j,"innerHTML");function p(t){return t.toString().replace(/"/g,"&quot;")}u(p,"htmlEntity");export{b as html,j as innerHTML};