@aeriz/wysiwyg 1.0.3 → 1.0.4

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.
Files changed (64) hide show
  1. package/README.md +37 -13
  2. package/dist/adapters/shared.cjs +1 -1
  3. package/dist/adapters/shared.js +11 -11
  4. package/dist/aeriz-wysiwyg-adapter.js +1 -1
  5. package/dist/aeriz-wysiwyg-adapter.min.js +1 -1
  6. package/dist/aeriz-wysiwyg-jquery.js +1 -1
  7. package/dist/aeriz-wysiwyg-jquery.min.js +1 -1
  8. package/dist/aeriz-wysiwyg-wc.js +1 -1
  9. package/dist/aeriz-wysiwyg-wc.min.js +1 -1
  10. package/dist/aeriz-wysiwyg.cjs +3773 -1926
  11. package/dist/aeriz-wysiwyg.css +554 -38
  12. package/dist/aeriz-wysiwyg.esm.js +3773 -1926
  13. package/dist/aeriz-wysiwyg.esm.min.js +4271 -2658
  14. package/dist/aeriz-wysiwyg.js +3773 -1926
  15. package/dist/aeriz-wysiwyg.min.cjs +36 -34
  16. package/dist/aeriz-wysiwyg.min.css +1 -1
  17. package/dist/aeriz-wysiwyg.min.js +40 -38
  18. package/dist/server.cjs +24 -22
  19. package/dist/server.js +444 -312
  20. package/dist-types/adapters/shared.d.ts.map +1 -1
  21. package/dist-types/cjs/core/AerizEditor.d.cts +180 -7
  22. package/dist-types/cjs/core/block-meta.d.cts +66 -0
  23. package/dist-types/cjs/core/block-policy.d.cts +43 -0
  24. package/dist-types/cjs/core/blocks.d.cts +47 -4
  25. package/dist-types/cjs/core/history.d.cts +86 -0
  26. package/dist-types/cjs/core/i18n.d.cts +12 -0
  27. package/dist-types/cjs/core/import-html.d.cts +1 -0
  28. package/dist-types/cjs/core/import-markdown.d.cts +0 -4
  29. package/dist-types/cjs/core/input-rules.d.cts +46 -0
  30. package/dist-types/cjs/core/selection.d.cts +46 -0
  31. package/dist-types/cjs/core/table-ops.d.cts +30 -0
  32. package/dist-types/cjs/index.d.cts +2 -0
  33. package/dist-types/core/AerizEditor.d.ts +180 -7
  34. package/dist-types/core/AerizEditor.d.ts.map +1 -1
  35. package/dist-types/core/block-meta.d.ts +66 -0
  36. package/dist-types/core/block-meta.d.ts.map +1 -1
  37. package/dist-types/core/block-policy.d.ts +43 -0
  38. package/dist-types/core/block-policy.d.ts.map +1 -0
  39. package/dist-types/core/blocks.d.ts +47 -4
  40. package/dist-types/core/blocks.d.ts.map +1 -1
  41. package/dist-types/core/history.d.ts +86 -0
  42. package/dist-types/core/history.d.ts.map +1 -0
  43. package/dist-types/core/i18n.d.ts +12 -0
  44. package/dist-types/core/i18n.d.ts.map +1 -1
  45. package/dist-types/core/import-html.d.ts +1 -0
  46. package/dist-types/core/import-html.d.ts.map +1 -1
  47. package/dist-types/core/import-markdown.d.ts +0 -4
  48. package/dist-types/core/import-markdown.d.ts.map +1 -1
  49. package/dist-types/core/input-rules.d.ts +46 -0
  50. package/dist-types/core/input-rules.d.ts.map +1 -0
  51. package/dist-types/core/plain-text.d.ts.map +1 -1
  52. package/dist-types/core/render-string.d.ts.map +1 -1
  53. package/dist-types/core/selection.d.ts +46 -0
  54. package/dist-types/core/selection.d.ts.map +1 -0
  55. package/dist-types/core/snapshot.d.ts.map +1 -1
  56. package/dist-types/core/table-ops.d.ts +30 -0
  57. package/dist-types/core/table-ops.d.ts.map +1 -0
  58. package/dist-types/index.d.ts +2 -0
  59. package/dist-types/index.d.ts.map +1 -1
  60. package/dist-types/ui/Toolbar.d.ts.map +1 -1
  61. package/dist-types/ui/dialogs.d.ts.map +1 -1
  62. package/dist-types/ui/icons.d.ts.map +1 -1
  63. package/dist-types/ui/popovers.d.ts.map +1 -1
  64. package/package.json +1 -1
package/dist/server.cjs CHANGED
@@ -1,32 +1,34 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function D(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${(e/1024/1024/1024).toFixed(1)} GB`}function U(e,n){if(e){const t=e.lastIndexOf(".");if(t>0&&t<e.length-1)return e.slice(t+1).toUpperCase()}return n?(n.split("/").pop()??"").toUpperCase():""}function z(e){try{return new URL(e).hostname}catch{return""}}function V(e){const n=z(e);return n?`https://www.google.com/s2/favicons?domain=${encodeURIComponent(n)}&sz=64`:""}const G='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/><path d="M14 3v6h6"/></svg>',K='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',Y="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",R="https://www.youtube-nocookie.com/embed/",Z="파일",X="data-block-id",F=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),J=new Set(["script","style"]),Q=new Map([["li",new Set(["li"])],["p",new Set(["p","div","ul","ol","blockquote","pre","table","h1","h2","h3","h4","h5","h6"])],["td",new Set(["td","th","tr"])],["th",new Set(["td","th","tr"])],["tr",new Set(["tr"])],["option",new Set(["option"])]]),ee={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" ",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",hellip:"…",mdash:"—",ndash:"–",lsquo:"‘",rsquo:"’",ldquo:"“",rdquo:"”",middot:"·",bull:"•",copy:"©",reg:"®",trade:"™",deg:"°",plusmn:"±",times:"×",divide:"÷",laquo:"«",raquo:"»"};function k(e){return e.includes("&")?e.replace(/&(#[Xx][0-9A-Fa-f]+|#\d+|[A-Za-z][A-Za-z0-9]{1,31});/g,(n,t)=>{if(t.charCodeAt(0)===35){const i=t[1]==="x"||t[1]==="X",o=i?t.slice(2):t.slice(1),a=Number.parseInt(o,i?16:10);if(!Number.isFinite(a)||a<0||a>1114111||a>=55296&&a<=57343)return n;try{return String.fromCodePoint(a)}catch{return n}}return ee[t.toLowerCase()]??n}):e}function m(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function f(e){return m(e).replace(/"/g,"&quot;")}function te(e){const n={},t=/([^\s/=>"']+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g;let r;for(;(r=t.exec(e))!==null;){const i=r[1];if(!i)continue;const o=r[2]??r[3]??r[4]??"";n[i.toLowerCase()]=k(o)}return n}function y(e){const n=[],t=[],r=()=>{const c=t[t.length-1];return c?c.children:n},i=c=>{if(c.length===0)return;const d=r(),u=d[d.length-1];u&&u.type==="text"?u.value+=c:d.push({type:"text",value:c})},o=c=>{var d;for(let u=t.length-1;u>=0;u--)if(((d=t[u])==null?void 0:d.tag)===c){t.length=u;return}};let a=0;for(;a<e.length;){const c=e.indexOf("<",a);if(c<0){i(k(e.slice(a)));break}if(c>a&&i(k(e.slice(a,c))),e.startsWith("<!--",c)){const $=e.indexOf("-->",c+4);a=$<0?e.length:$+3;continue}if(e.startsWith("<!",c)||e.startsWith("<?",c)){const $=e.indexOf(">",c+2);a=$<0?e.length:$+1;continue}const d=e.indexOf(">",c+1);if(d<0){i(k(e.slice(c)));break}const u=e.slice(c+1,d);if(a=d+1,u.startsWith("/")){const $=u.slice(1).trim().toLowerCase();$&&o($);continue}const s=/^([A-Za-z][^\s/>]*)/.exec(u);if(!s||!s[1]){i(k(e.slice(c,a)));continue}const l=s[1].toLowerCase(),p=u.slice(s[1].length),g=/\/\s*$/.test(p),x=te(g?p.replace(/\/\s*$/,""):p);if(J.has(l)){const $=new RegExp(`</${l}\\s*>`,"i"),W=e.slice(a),I=$.exec(W);a=I?a+I.index+I[0].length:e.length;continue}const B=t[t.length-1];if(B){const $=Q.get(B.tag);$!=null&&$.has(l)&&t.pop()}const _={type:"element",tag:l,attrs:x,children:[]};r().push(_),!g&&!F.has(l)&&t.push(_)}return n}function C(e){let n="";for(const t of e){if(t.type==="text"){n+=m(t.value);continue}const r=Object.entries(t.attrs).map(([i,o])=>o===""?` ${i}`:` ${i}="${f(o)}"`).join("");if(F.has(t.tag)){n+=`<${t.tag}${r}>`;continue}n+=`<${t.tag}${r}>${C(t.children)}</${t.tag}>`}return n}function L(e){let n="";for(const t of e){if(t.type==="text"){n+=t.value;continue}if(t.tag==="br"){n+=`
2
- `;continue}n+=L(t.children)}return n}const ne=new Set(["address","article","aside","blockquote","div","dd","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hr","li","main","nav","ol","p","pre","section","table","tbody","td","tfoot","th","thead","tr","ul"]);function v(e){let n="";for(const t of e){if(t.type==="text"){n+=t.value;continue}if(t.tag==="br"){n+=`
3
- `;continue}const r=ne.has(t.tag);r&&n!==""&&!n.endsWith(`
4
- `)&&(n+=`
5
- `),n+=v(t.children),r&&!n.endsWith(`
6
- `)&&(n+=`
7
- `)}return n}function A(e,n){return e.filter(t=>t.type==="element"&&t.tag===n)}const re=1;function H(e){const n=e.version;return typeof n=="number"&&Number.isFinite(n)&&n>0?n:1}const ie=new Set(["paragraph","heading","bulletList","orderedList","blockquote","codeBlock","image","table","hr","linkCard","youtube","file","importedHtml","unknown"]);function E(e){return e.map(n=>N(n))}function N(e){const n=ie.has(e.kind)?e.kind:"unknown",t=Math.max(H(e),1);return{...e,kind:n,version:t,html:typeof e.html=="string"?e.html:""}}function oe(e,n={}){const t=n.blockIds!==!1,r=E(e).map(o=>q(o,{blockIds:t})).join("");return n.wrapper!=="content"?r:`<div class="aeriz-wysiwyg aeriz-wysiwyg-viewer"${n.theme?` data-theme="${n.theme}"`:""}><div class="aw-content-wrap"><div class="aw-content">${r}</div></div></div>`}function ce(e,n={}){return q(N(e),n)}function q(e,n={}){const t=n.blockIds===!1?"":` ${X}="${f(e.id)}"`,r=e.html,i=e.style?` style="${f(e.style)}"`:"";switch(e.kind){case"paragraph":return`<p${t}${i}>${r||"<br>"}</p>`;case"unknown":return`<div${t}${i}>${r||"<br>"}</div>`;case"heading":{const o=ae(e.attrs.level);return`<h${o}${t}${i}>${r||"<br>"}</h${o}>`}case"bulletList":return`<ul${t}${i}>${r||"<li><br></li>"}</ul>`;case"orderedList":return`<ol${t}${i}>${r||"<li><br></li>"}</ol>`;case"blockquote":return`<blockquote${t}${i}>${r||"<p><br></p>"}</blockquote>`;case"codeBlock":{if(r)return`<pre${t}${i}>${r}</pre>`;const o=e.attrs.language,a=o?` data-language="${f(o)}"`:"";return`<pre${t}${i}><code${a}></code></pre>`}case"table":return`<table${t}${i}>${r||se(e.attrs.rows,e.attrs.cols)}</table>`;case"hr":return`<hr${t}${i}>`;case"image":return r?`<figure${t}${i}>${T(r)}</figure>`:le(e.attrs,t,i);case"youtube":{if(!r)return ue(e.attrs,t,i);const o=e.attrs.videoId;return`<div class="aw-youtube-embed"${o?` data-youtube-id="${f(o)}"`:""}${t}${i}>${T(r)}</div>`}case"linkCard":return de(e.attrs,t,i,r);case"file":return fe(e.attrs,t,i,r);case"importedHtml":{const o=e.attrs.importedStyle,a=e.attrs.importedClass,c=e.style?i:o?` style="${f(o)}"`:"";return`<div data-imported-html="true"${a?` class="${f(a)}"`:""}${c}${t}>${r}</div>`}default:return""}}const O=/aw-block-align-controls|aw-resize-handle/;function T(e){if(!O.test(e))return e;const n=y(e).filter(t=>!(t.type==="element"&&O.test(t.attrs.class??"")));return C(n)}function ae(e){return e===void 0||e<1?1:e>6?6:e}function se(e,n){const t=Math.max(1,Number.isFinite(e)?e:1),r=Math.max(1,Number.isFinite(n)?n:1);return`<tbody>${`<tr>${"<td><br></td>".repeat(r)}</tr>`.repeat(t)}</tbody>`}function le(e,n,t){const r=t||(e.wrapperStyle?` style="${f(e.wrapperStyle)}"`:""),i=e.src?` src="${f(e.src)}"`:"",o=` alt="${f(e.alt??"")}"`;return`<figure${n}${r}><img${i}${o}></figure>`}function ue(e,n,t){const r=e.videoId??"",i=t||(e.wrapperStyle?` style="${f(e.wrapperStyle)}"`:""),o=r?` data-youtube-id="${f(r)}"`:"",a=r?` src="${f(`${R}${r}`)}"`:"";return`<div class="aw-youtube-embed"${o}${n}${i}><iframe${a} allow="${f(Y)}" allowfullscreen frameborder="0" referrerpolicy="strict-origin-when-cross-origin"></iframe></div>`}function de(e,n,t,r){const i=e.href??"#",o=e.text&&e.text.length>0?e.text:z(i)||i,a=e.description??"",c=e.image??"",d=e.favicon??V(i),s=`<a class="${c?"aw-link-card aw-link-card-with-image":"aw-link-card"}" href="${f(i)}" target="_blank" rel="noopener"${n}${t}>`;if(r)return`${s}${T(r)}</a>`;let l=s;return c&&(l+=`<img class="aw-link-card-image" src="${f(c)}" alt="" loading="lazy">`),l+='<span class="aw-link-card-body">',l+=`<span class="aw-link-card-title">${m(o)}</span>`,a&&(l+=`<span class="aw-link-card-desc">${m(a)}</span>`),l+='<span class="aw-link-card-url">',d&&(l+=`<img class="aw-link-card-favicon" src="${f(d)}" alt="" loading="lazy">`),l+=`<span class="aw-link-card-url-text">${m(i)}</span>`,l+="</span></span></a>",l}function fe(e,n,t,r){const i=e.fileSrc?` href="${f(e.fileSrc)}"`:"",o=e.fileName?` data-file-name="${f(e.fileName)}"`:"",a=e.fileSize!==void 0?` data-file-size="${f(String(e.fileSize))}"`:"",c=e.fileType?` data-file-type="${f(e.fileType)}"`:"",d=` download="${f(e.fileName??"")}"`,u=[],s=U(e.fileName,e.fileType);s&&u.push(s),e.fileSize!==void 0&&u.push(D(e.fileSize));const l=`<a class="aw-file-attachment" target="_blank" rel="noopener"${i}${d}${o}${a}${c}${n}${t}>`;if(r)return`${l}${T(r)}</a>`;let p=l;return p+=`<span class="aw-file-icon" aria-hidden="true">${G}</span>`,p+='<span class="aw-file-meta">',p+=`<span class="aw-file-name">${m(e.fileName??Z)}</span>`,u.length>0&&(p+=`<span class="aw-file-info">${m(u.join(" · "))}</span>`),p+="</span>",p+=`<span class="aw-file-action" aria-hidden="true">${K}</span>`,p+="</a>",p}const pe=/([\\`*_[\]<])/g,$e=/^([#>|+-]|\d+\.)/;function ge(e,n={}){const t=n.bullet??"-",r=n.gfmTables!==!1,i=[];for(const o of E(e)){const a=me(o,t,r);a!==""&&i.push(a)}return i.length>0?`${i.join(`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function X(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/1024/1024).toFixed(1)} MB`:`${(e/1024/1024/1024).toFixed(1)} GB`}function J(e,t){if(e){const n=e.lastIndexOf(".");if(n>0&&n<e.length-1)return e.slice(n+1).toUpperCase()}return t?(t.split("/").pop()??"").toUpperCase():""}function U(e){try{return new URL(e).hostname}catch{return""}}function Q(e){const t=U(e);return t?`https://www.google.com/s2/favicons?domain=${encodeURIComponent(t)}&sz=64`:""}const ee='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"/><path d="M14 3v6h6"/></svg>',te='<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"/><polyline points="7 10 12 15 17 10"/><line x1="12" y1="15" x2="12" y2="3"/></svg>',ne="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",R="https://www.youtube-nocookie.com/embed/",re="파일",ie="data-block-id",oe=/[​-‍]/g,ce=["id","class","dir","lang","title"],se=new Set(["div","section","article","aside","header","footer","main","nav","details","summary","figure","figcaption","address","fieldset","dl","dt","dd","small","span"]);function ae(e){if(!e)return"div";const t=e.toLowerCase();return se.has(t)?t:"div"}function le(...e){const t=new Set;for(const n of e)if(n)for(const r of n.split(/\s+/))r&&t.add(r);return[...t].join(" ")}const ue="aw-task-list",de="data-checked",fe=new Set(["http:","https:","mailto:","tel:","ftp:","sms:"]),pe=new Set(["http:","https:","blob:"]),$e=/^data:image\/[a-z0-9.+-]+[,;]/i;function W(e){return e.replace(me,"")}const me=new RegExp("[\\u0000-\\u0020\\u007f]","g");function q(e){const t=/^([a-z][a-z0-9+.-]*):/i.exec(e);return t&&t[1]?`${t[1].toLowerCase()}:`:null}function I(e){if(!e)return"";const t=e.trim();if(!t)return"";const n=q(W(t));return n===null||fe.has(n)?t:""}function v(e){if(!e)return"";const t=e.trim();if(!t)return"";const n=W(t),r=q(n);return r===null?t:r==="data:"?$e.test(n)?t:"":pe.has(r)?t:""}function D(e){return e&&/^[A-Za-z0-9_-]{6,20}$/.test(e)?e:""}const P=new Set(["area","base","br","col","embed","hr","img","input","link","meta","param","source","track","wbr"]),ge=new Set(["script","style"]),he=new Map([["li",new Set(["li"])],["p",new Set(["p","div","ul","ol","blockquote","pre","table","h1","h2","h3","h4","h5","h6"])],["td",new Set(["td","th","tr"])],["th",new Set(["td","th","tr"])],["tr",new Set(["tr"])],["option",new Set(["option"])]]),be={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" ",ensp:" ",emsp:" ",thinsp:" ",zwnj:"‌",zwj:"‍",hellip:"…",mdash:"—",ndash:"–",lsquo:"‘",rsquo:"’",ldquo:"“",rdquo:"”",middot:"·",bull:"•",copy:"©",reg:"®",trade:"™",deg:"°",plusmn:"±",times:"×",divide:"÷",laquo:"«",raquo:"»"};function k(e){return e.includes("&")?e.replace(/&(#[Xx][0-9A-Fa-f]+|#\d+|[A-Za-z][A-Za-z0-9]{1,31});/g,(t,n)=>{if(n.charCodeAt(0)===35){const i=n[1]==="x"||n[1]==="X",o=i?n.slice(2):n.slice(1),c=Number.parseInt(o,i?16:10);if(!Number.isFinite(c)||c<0||c>1114111||c>=55296&&c<=57343)return t;try{return String.fromCodePoint(c)}catch{return t}}return be[n.toLowerCase()]??t}):e}function g(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function f(e){return g(e).replace(/"/g,"&quot;")}function ke(e){const t={},n=/([^\s/=>"']+)(?:\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g;let r;for(;(r=n.exec(e))!==null;){const i=r[1];if(!i)continue;const o=r[2]??r[3]??r[4]??"";t[i.toLowerCase()]=k(o)}return t}function S(e){const t=[],n=[],r=()=>{const a=n[n.length-1];return a?a.children:t},i=a=>{if(a.length===0)return;const s=r(),u=s[s.length-1];u&&u.type==="text"?u.value+=a:s.push({type:"text",value:a})},o=a=>{var s;for(let u=n.length-1;u>=0;u--)if(((s=n[u])==null?void 0:s.tag)===a){n.length=u;return}};let c=0;for(;c<e.length;){const a=e.indexOf("<",c);if(a<0){i(k(e.slice(c)));break}if(a>c&&i(k(e.slice(c,a))),e.startsWith("<!--",a)){const m=e.indexOf("-->",a+4);c=m<0?e.length:m+3;continue}if(e.startsWith("<!",a)||e.startsWith("<?",a)){const m=e.indexOf(">",a+2);c=m<0?e.length:m+1;continue}const s=e.indexOf(">",a+1);if(s<0){i(k(e.slice(a)));break}const u=e.slice(a+1,s);if(c=s+1,u.startsWith("/")){const m=u.slice(1).trim().toLowerCase();m&&o(m);continue}const d=/^([A-Za-z][^\s/>]*)/.exec(u);if(!d||!d[1]){i(k(e.slice(a,c)));continue}const l=d[1].toLowerCase(),$=u.slice(d[1].length),h=/\/\s*$/.test($),p=ke(h?$.replace(/\/\s*$/,""):$);if(ge.has(l)){const m=new RegExp(`</${l}\\s*>`,"i"),Z=e.slice(c),O=m.exec(Z);c=O?c+O.index+O[0].length:e.length;continue}const A=n[n.length-1];if(A){const m=he.get(A.tag);m!=null&&m.has(l)&&n.pop()}const z={type:"element",tag:l,attrs:p,children:[]};r().push(z),!h&&!P.has(l)&&n.push(z)}return t}function C(e){let t="";for(const n of e){if(n.type==="text"){t+=g(n.value);continue}const r=Object.entries(n.attrs).map(([i,o])=>o===""?` ${i}`:` ${i}="${f(o)}"`).join("");if(P.has(n.tag)){t+=`<${n.tag}${r}>`;continue}t+=`<${n.tag}${r}>${C(n.children)}</${n.tag}>`}return t}function N(e){let t="";for(const n of e){if(n.type==="text"){t+=n.value;continue}if(n.tag==="br"){t+=`
2
+ `;continue}t+=N(n.children)}return t}const we=new Set(["address","article","aside","blockquote","div","dd","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hr","li","main","nav","ol","p","pre","section","table","tbody","td","tfoot","th","thead","tr","ul"]);function E(e){let t="";for(const n of e){if(n.type==="text"){t+=n.value;continue}if(n.tag==="br"){t+=`
3
+ `;continue}const r=we.has(n.tag);r&&t!==""&&!t.endsWith(`
4
+ `)&&(t+=`
5
+ `),t+=E(n.children),r&&!t.endsWith(`
6
+ `)&&(t+=`
7
+ `)}return t}function L(e,t){return e.filter(n=>n.type==="element"&&n.tag===t)}const Se=1;function K(e){const t=e.version;return typeof t=="number"&&Number.isFinite(t)&&t>0?t:1}const ye=new Set(["paragraph","heading","bulletList","orderedList","taskList","blockquote","codeBlock","image","table","hr","linkCard","youtube","file","importedHtml","unknown"]);function M(e){return e.map(t=>B(t))}function B(e){const t=ye.has(e.kind)?e.kind:"unknown",n=Math.max(K(e),1);return{...e,kind:t,version:n,html:typeof e.html=="string"?e.html:""}}function Ae(e,t={}){const n=t.blockIds!==!1,r=M(e).map(o=>V(o,{blockIds:n})).join("");return t.wrapper!=="content"?r:`<div class="aeriz-wysiwyg aeriz-wysiwyg-viewer"${t.theme?` data-theme="${t.theme}"`:""}><div class="aw-content-wrap"><div class="aw-content">${r}</div></div></div>`}function Te(e,t={}){return V(B(e),t)}function V(e,t={}){const n=t.blockIds===!1?"":` ${ie}="${f(e.id)}"`,r=Ee(e.html),i=(e.style?` style="${f(e.style)}"`:"")+ve(e.attributes),o=c=>{var s;const a=le(c,(s=e.attributes)==null?void 0:s.class);return a?` class="${f(a)}"`:""};switch(e.kind){case"paragraph":return`<p${n}${i}>${r||"<br>"}</p>`;case"unknown":{const c=ae(e.attrs.tag);return`<${c}${n}${i}>${r||"<br>"}</${c}>`}case"heading":{const c=_e(e.attrs.level);return`<h${c}${n}${i}>${r||"<br>"}</h${c}>`}case"bulletList":return`<ul${n}${i}>${r||"<li><br></li>"}</ul>`;case"orderedList":return`<ol${n}${i}>${r||"<li><br></li>"}</ol>`;case"taskList":return`<ul${o(ue)}${n}${i}>${r||"<li><br></li>"}</ul>`;case"blockquote":return`<blockquote${n}${i}>${r||"<p><br></p>"}</blockquote>`;case"codeBlock":{if(r)return`<pre${n}${i}>${r}</pre>`;const c=e.attrs.language,a=c?` data-language="${f(c)}"`:"";return`<pre${n}${i}><code${a}></code></pre>`}case"table":return`<table${n}${i}>${r||Ie(e.attrs.rows,e.attrs.cols)}</table>`;case"hr":return`<hr${n}${i}>`;case"image":return r?`<figure${n}${i}>${_(r)}</figure>`:Ce(e.attrs,n,i);case"youtube":{if(!r)return Ne(e.attrs,n,i,o);const c=D(e.attrs.videoId),a=c?` data-youtube-id="${f(c)}"`:"";return`<div${o("aw-youtube-embed")}${a}${n}${i}>${_(r)}</div>`}case"linkCard":return Me(e.attrs,n,i,r,o);case"file":return Oe(e.attrs,n,i,r,o);case"importedHtml":{const c=e.attrs.importedStyle,a=e.style?i:c?` style="${f(c)}"`:"";return`<div data-imported-html="true"${o(e.attrs.importedClass)}${a}${n}>${r}</div>`}default:return""}}function ve(e){if(!e)return"";let t="";for(const n of ce){if(n==="class")continue;const r=e[n];r===void 0||r===""||(t+=` ${n}="${f(r)}"`)}return t}const j=/\s(href|src)\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/gi;function Ee(e){return!e||!Le(e)&&!xe.test(e)?e:C(S(e).map(G))}const xe=/<iframe[\s>]/i;function Le(e){j.lastIndex=0;let t;for(;(t=j.exec(e))!==null;){const n=(t[1]??"").toLowerCase(),r=k(t[2]??t[3]??t[4]??"");if(!(n==="href"?I(r):v(r)))return!0}return!1}function G(e){if(e.type!=="element")return e;const t=e.tag==="iframe",n={};for(const[r,i]of Object.entries(e.attrs))r==="href"&&!I(i)||r==="src"&&!(t?i.startsWith(R):v(i))||(n[r]=i);return{...e,attrs:n,children:e.children.map(G)}}const H=/aw-block-align-controls|aw-resize-handle/;function _(e){if(!H.test(e))return e;const t=S(e).filter(n=>!(n.type==="element"&&H.test(n.attrs.class??"")));return C(t)}function _e(e){return e===void 0||e<1?1:e>6?6:e}function Ie(e,t){const n=Math.max(1,Number.isFinite(e)?e:1),r=Math.max(1,Number.isFinite(t)?t:1);return`<tbody>${`<tr>${"<td><br></td>".repeat(r)}</tr>`.repeat(n)}</tbody>`}function Ce(e,t,n){const r=n||(e.wrapperStyle?` style="${f(e.wrapperStyle)}"`:""),i=v(e.src),o=i?` src="${f(i)}"`:"",c=` alt="${f(e.alt??"")}"`,a=e.caption?`<figcaption>${g(e.caption)}</figcaption>`:"";return`<figure${t}${r}><img${o}${c}>${a}</figure>`}function Ne(e,t,n,r){const i=D(e.videoId),o=n||(e.wrapperStyle?` style="${f(e.wrapperStyle)}"`:""),c=i?` data-youtube-id="${f(i)}"`:"",a=i?` src="${f(`${R}${i}`)}"`:"";return`<div${r("aw-youtube-embed")}${c}${t}${o}><iframe${a} allow="${f(ne)}" allowfullscreen frameborder="0" referrerpolicy="strict-origin-when-cross-origin"></iframe></div>`}function Me(e,t,n,r,i){const o=I(e.href)||"#",c=e.text&&e.text.length>0?e.text:U(o)||o,a=e.description??"",s=v(e.image),u=e.favicon?v(e.favicon):Q(o),l=`<a${i(s?"aw-link-card aw-link-card-with-image":"aw-link-card")} href="${f(o)}" target="_blank" rel="noopener"${t}${n}>`;if(r)return`${l}${_(r)}</a>`;let $=l;return s&&($+=`<img class="aw-link-card-image" src="${f(s)}" alt="" loading="lazy">`),$+='<span class="aw-link-card-body">',$+=`<span class="aw-link-card-title">${g(c)}</span>`,a&&($+=`<span class="aw-link-card-desc">${g(a)}</span>`),$+='<span class="aw-link-card-url">',u&&($+=`<img class="aw-link-card-favicon" src="${f(u)}" alt="" loading="lazy">`),$+=`<span class="aw-link-card-url-text">${g(o)}</span>`,$+="</span></span></a>",$}function Oe(e,t,n,r,i){const o=I(e.fileSrc),c=o?` href="${f(o)}"`:"",a=e.fileName?` data-file-name="${f(e.fileName)}"`:"",s=e.fileSize!==void 0?` data-file-size="${f(String(e.fileSize))}"`:"",u=e.fileType?` data-file-type="${f(e.fileType)}"`:"",d=` download="${f(e.fileName??"")}"`,l=[],$=J(e.fileName,e.fileType);$&&l.push($),e.fileSize!==void 0&&l.push(X(e.fileSize));const h=`<a${i("aw-file-attachment")} target="_blank" rel="noopener"${c}${d}${a}${s}${u}${t}${n}>`;if(r)return`${h}${_(r)}</a>`;let p=h;return p+=`<span class="aw-file-icon" aria-hidden="true">${ee}</span>`,p+='<span class="aw-file-meta">',p+=`<span class="aw-file-name">${g(e.fileName??re)}</span>`,l.length>0&&(p+=`<span class="aw-file-info">${g(l.join(" · "))}</span>`),p+="</span>",p+=`<span class="aw-file-action" aria-hidden="true">${te}</span>`,p+="</a>",p}const Re=/([\\`*_[\]<])/g,Be=/^([#>|+-]|\d+\.)/;function ze(e,t={}){const n=t.bullet??"-",r=t.gfmTables!==!1,i=[];for(const o of M(e)){const c=je(o,n,r);c!==""&&i.push(c)}return i.length>0?`${i.join(`
8
8
 
9
9
  `)}
10
- `:""}function me(e,n,t){var i,o,a;const r=y(e.html);switch(e.kind){case"paragraph":case"unknown":{const c=h(r).trim();return c===""?"":j(c)}case"heading":{const c=Math.min(6,Math.max(1,e.attrs.level??1)),d=h(r).trim();return d===""?"":`${"#".repeat(c)} ${d}`}case"bulletList":return M(r,{ordered:!1,bullet:n,depth:0});case"orderedList":return M(r,{ordered:!0,bullet:n,depth:0});case"blockquote":{const c=A(r,"p"),u=(c.length>0?c.map(s=>h(s.children).trim()):[h(r).trim()]).filter(s=>s!=="").join(`
10
+ `:""}function je(e,t,n){var i,o,c,a;const r=S(e.html);switch(e.kind){case"paragraph":case"unknown":{const s=w(r).trim();return s===""?"":F(s)}case"heading":{const s=Math.min(6,Math.max(1,e.attrs.level??1)),u=w(r).trim();return u===""?"":`${"#".repeat(s)} ${u}`}case"bulletList":return x(r,{ordered:!1,bullet:t,depth:0});case"orderedList":return x(r,{ordered:!0,bullet:t,depth:0});case"taskList":return x(r,{ordered:!1,bullet:t,depth:0,task:!0});case"blockquote":{const s=L(r,"p"),d=(s.length>0?s.map(l=>w(l.children).trim()):[w(r).trim()]).filter(l=>l!=="").join(`
11
11
 
12
12
  `).split(`
13
- `).map(s=>s===""?">":`> ${s}`);return u.length>0&&u[0]!==void 0?u.join(`
14
- `):""}case"codeBlock":{const c=A(r,"code")[0],d=L(c?c.children:r).replace(/\n$/,""),u=e.attrs.language??(c==null?void 0:c.attrs["data-language"])??"",s="`".repeat(Math.max(3,P(d)+1));return`${s}${u}
15
- ${d}
16
- ${s}`}case"image":{const c=e.attrs.src??"";return c===""?"":`![${w(e.attrs.alt??"")}](${S(c)})`}case"table":return t?he(r):`<table>${e.html}</table>`;case"hr":return"---";case"linkCard":{const c=e.attrs.href??"";if(c==="")return"";const d=((i=e.attrs.text)==null?void 0:i.trim())||c,u=`[${w(d)}](${S(c)})`,s=(o=e.attrs.description)==null?void 0:o.trim();return s?`${u}
13
+ `).map(l=>l===""?">":`> ${l}`);return d.length>0&&d[0]!==void 0?d.join(`
14
+ `):""}case"codeBlock":{const s=L(r,"code")[0],u=N(s?s.children:r).replace(/\n$/,""),d=e.attrs.language??(s==null?void 0:s.attrs["data-language"])??"",l="`".repeat(Math.max(3,Y(u)+1));return`${l}${d}
15
+ ${u}
16
+ ${l}`}case"image":{const s=e.attrs.src??"";if(s==="")return"";const u=`![${b(e.attrs.alt??"")}](${T(s)})`,d=(i=e.attrs.caption)==null?void 0:i.trim();return d?`${u}
17
+ *${b(d)}*`:u}case"table":return n?He(r):`<table>${e.html}</table>`;case"hr":return"---";case"linkCard":{const s=e.attrs.href??"";if(s==="")return"";const u=((o=e.attrs.text)==null?void 0:o.trim())||s,d=`[${b(u)}](${T(s)})`,l=(c=e.attrs.description)==null?void 0:c.trim();return l?`${d}
17
18
 
18
- ${j(w(s))}`:u}case"youtube":{const c=e.attrs.videoId;return c?`[YouTube](${R}${encodeURIComponent(c)})`:""}case"file":{const c=e.attrs.fileSrc??"";if(c==="")return"";const d=((a=e.attrs.fileName)==null?void 0:a.trim())||c;return`[${w(d)}](${S(c)})`}case"importedHtml":return e.html.trim();default:return""}}function M(e,n){const t=A(e,"li");if(t.length===0)return"";const r=" ".repeat(n.depth),i=[];return t.forEach((o,a)=>{const c=[],d=[];for(const g of o.children)g.type==="element"&&(g.tag==="ul"||g.tag==="ol")?d.push(g):c.push(g);const u=n.ordered?`${a+1}.`:n.bullet,s=h(c).trim(),l=`${r}${" ".repeat(u.length+1)}`,p=s.split(`
19
+ ${F(b(l))}`:d}case"youtube":{const s=e.attrs.videoId;return s?`[YouTube](${R}${encodeURIComponent(s)})`:""}case"file":{const s=e.attrs.fileSrc??"";if(s==="")return"";const u=((a=e.attrs.fileName)==null?void 0:a.trim())||s;return`[${b(u)}](${T(s)})`}case"importedHtml":return e.html.trim();default:return""}}function x(e,t){const n=L(e,"li");if(n.length===0)return"";const r=" ".repeat(t.depth),i=[];return n.forEach((o,c)=>{const a=[],s=[];for(const p of o.children)p.type==="element"&&(p.tag==="ul"||p.tag==="ol")?s.push(p):a.push(p);const u=t.ordered?`${c+1}.`:t.bullet,d=t.task?`${u} ${o.attrs[de]==="true"?"[x]":"[ ]"}`:u,l=w(a).trim(),$=`${r}${" ".repeat(d.length+1)}`,h=l.split(`
19
20
  `).join(`
20
- ${l}`);i.push(`${r}${u} ${p}`);for(const g of d){const x=M(g.children,{ordered:g.tag==="ol",bullet:n.bullet,depth:n.depth+1});x!==""&&i.push(x)}}),i.join(`
21
- `)}function he(e){const n=[],t=s=>{for(const l of s)if(l.type==="element"){if(l.tag==="tr"){n.push(l);continue}(l.tag==="tbody"||l.tag==="thead"||l.tag==="tfoot")&&t(l.children)}};if(t(e),n.length===0)return"";const r=n.map(s=>s.children.filter(l=>l.type==="element"&&(l.tag==="td"||l.tag==="th")).map(l=>be(l.children))),i=r.reduce((s,l)=>Math.max(s,l.length),0);if(i===0)return"";const o=s=>s.length===i?s:[...s,...Array(i-s.length).fill("")],[a,...c]=r.map(o);return[`| ${(a??Array(i).fill("")).join(" | ")} |`,`| ${Array(i).fill("---").join(" | ")} |`,...c.map(s=>`| ${s.join(" | ")} |`)].join(`
22
- `)}function be(e){return h(e,{inTableCell:!0}).replace(/\n+/g,"<br>").replace(/\|/g,"\\|").trim()}function h(e,n={}){let t="";for(const r of e){if(r.type==="text"){t+=w(r.value);continue}const i=()=>h(r.children,n);switch(r.tag){case"br":t+=n.inTableCell?`
21
+ ${$}`);i.push(`${r}${d} ${h}`);for(const p of s){const A=x(p.children,{ordered:p.tag==="ol",bullet:t.bullet,depth:t.depth+1});A!==""&&i.push(A)}}),i.join(`
22
+ `)}function He(e){const t=[],n=d=>{for(const l of d)if(l.type==="element"){if(l.tag==="tr"){t.push(l);continue}(l.tag==="tbody"||l.tag==="thead"||l.tag==="tfoot")&&n(l.children)}};if(n(e),t.length===0)return"";const r=t.map(d=>d.children.filter(l=>l.type==="element"&&(l.tag==="td"||l.tag==="th")).map(l=>Fe(l.children))),i=r.reduce((d,l)=>Math.max(d,l.length),0);if(i===0)return"";const o=d=>d.length===i?d:[...d,...Array(i-d.length).fill("")],[c,...a]=r.map(o);return[`| ${(c??Array(i).fill("")).join(" | ")} |`,`| ${Array(i).fill("---").join(" | ")} |`,...a.map(d=>`| ${d.join(" | ")} |`)].join(`
23
+ `)}function Fe(e){return w(e,{inTableCell:!0}).replace(/\n+/g,"<br>").replace(/\|/g,"\\|").trim()}function w(e,t={}){let n="";for(const r of e){if(r.type==="text"){n+=b(r.value);continue}const i=()=>w(r.children,t);switch(r.tag){case"br":n+=t.inTableCell?`
23
24
  `:`
24
- `;break;case"b":case"strong":{const o=i();t+=o.trim()===""?o:`**${o}**`;break}case"i":case"em":{const o=i();t+=o.trim()===""?o:`*${o}*`;break}case"s":case"del":case"strike":{const o=i();t+=o.trim()===""?o:`~~${o}~~`;break}case"code":{const o=L(r.children),a="`".repeat(P(o)+1),c=o.startsWith("`")||o.endsWith("`")?" ":"";t+=`${a}${c}${o}${c}${a}`;break}case"a":{const o=r.attrs.href,a=i();t+=o?`[${a}](${S(o)})`:a;break}case"img":{const o=r.attrs.src;o&&(t+=`![${w(r.attrs.alt??"")}](${S(o)})`);break}case"u":case"sub":case"sup":case"mark":t+=`<${r.tag}>${i()}</${r.tag}>`;break;default:t+=i();break}}return t}function w(e){return e.replace(pe,"\\$1")}function j(e){return e.replace($e,"\\$1")}function P(e){let n=0,t=0;for(const r of e)r==="`"?(t+=1,t>n&&(n=t)):t=0;return n}function S(e){const n=e.trim();return/[\s()]/.test(n)?`<${n.replace(/[<>]/g,"")}>`:n}function ke(e,n={}){const t=n.blockSeparator??`
25
+ `;break;case"b":case"strong":{const o=i();n+=o.trim()===""?o:`**${o}**`;break}case"i":case"em":{const o=i();n+=o.trim()===""?o:`*${o}*`;break}case"s":case"del":case"strike":{const o=i();n+=o.trim()===""?o:`~~${o}~~`;break}case"code":{const o=N(r.children),c="`".repeat(Y(o)+1),a=o.startsWith("`")||o.endsWith("`")?" ":"";n+=`${c}${a}${o}${a}${c}`;break}case"a":{const o=r.attrs.href,c=i();n+=o?`[${c}](${T(o)})`:c;break}case"img":{const o=r.attrs.src;o&&(n+=`![${b(r.attrs.alt??"")}](${T(o)})`);break}case"u":case"sub":case"sup":case"mark":n+=`<${r.tag}>${i()}</${r.tag}>`;break;default:n+=i();break}}return n}function b(e){return e.replace(Re,"\\$1")}function F(e){return e.replace(Be,"\\$1")}function Y(e){let t=0,n=0;for(const r of e)r==="`"?(n+=1,n>t&&(t=n)):n=0;return t}function T(e){const t=e.trim();return/[\s()]/.test(t)?`<${t.replace(/[<>]/g,"")}>`:t}function Ue(e,t={}){const n=t.blockSeparator??`
25
26
 
26
- `,r=n.cellSeparator??" ",i=[];for(const o of E(e)){const a=we(o,r);a!==""&&i.push(a)}return i.join(t)}function we(e,n){switch(e.kind){case"hr":case"youtube":return"";case"image":return b(e.attrs.alt??"");case"linkCard":return b(e.attrs.text??e.attrs.href??"");case"file":return b(e.attrs.fileName??"");case"bulletList":case"orderedList":return A(y(e.html),"li").map(r=>b(v(r.children))).filter(r=>r!=="").join(`
27
- `);case"table":return ye(y(e.html),n);default:return b(v(y(e.html)))}}function ye(e,n){const t=[],r=i=>{for(const o of i)o.type==="element"&&(o.tag==="tr"?t.push(o):["tbody","thead","tfoot"].includes(o.tag)&&r(o.children))};return r(e),t.map(i=>i.children.filter(o=>o.type==="element"&&(o.tag==="td"||o.tag==="th")).map(o=>b(v(o.children)).replace(/\n+/g," ")).join(n)).filter(i=>i.replace(new RegExp(Se(n),"g"),"").trim()!=="").join(`
28
- `)}function b(e){return e.replace(/[​-‍]/g,"").split(`
29
- `).map(n=>n.replace(/[^\S\n]+/g," ").trim()).join(`
27
+ `,r=t.cellSeparator??" ",i=[];for(const o of M(e)){const c=We(o,r);c!==""&&i.push(c)}return i.join(n)}function We(e,t){switch(e.kind){case"hr":case"youtube":return"";case"image":return y([e.attrs.alt,e.attrs.caption].filter(Boolean).join(`
28
+ `));case"linkCard":return y(e.attrs.text??e.attrs.href??"");case"file":return y(e.attrs.fileName??"");case"bulletList":case"orderedList":case"taskList":return L(S(e.html),"li").map(r=>y(E(r.children))).filter(r=>r!=="").join(`
29
+ `);case"table":return qe(S(e.html),t);default:return y(E(S(e.html)))}}function qe(e,t){const n=[],r=i=>{for(const o of i)o.type==="element"&&(o.tag==="tr"?n.push(o):["tbody","thead","tfoot"].includes(o.tag)&&r(o.children))};return r(e),n.map(i=>i.children.filter(o=>o.type==="element"&&(o.tag==="td"||o.tag==="th")).map(o=>y(E(o.children)).replace(/\n+/g," ")).join(t)).filter(i=>i.replace(new RegExp(De(t),"g"),"").trim()!=="").join(`
30
+ `)}function y(e){return e.replace(oe,"").split(`
31
+ `).map(t=>t.replace(/[^\S\n]+/g," ").trim()).join(`
30
32
  `).replace(/\n{3,}/g,`
31
33
 
32
- `).trim()}function Se(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}exports.SNAPSHOT_VERSION=re;exports.blocksToMarkdown=ge;exports.blocksToPlainText=ke;exports.decodeEntities=k;exports.escapeAttr=f;exports.escapeHtml=m;exports.parseHtmlFragment=y;exports.renderBlockToHTML=ce;exports.renderBlocksToHTML=oe;exports.serializeNodes=C;exports.snapshotVersionOf=H;exports.textOf=L;exports.textWithBlockBreaks=v;exports.upgradeSnapshot=N;exports.upgradeSnapshots=E;
34
+ `).trim()}function De(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}exports.SNAPSHOT_VERSION=Se;exports.blocksToMarkdown=ze;exports.blocksToPlainText=Ue;exports.decodeEntities=k;exports.escapeAttr=f;exports.escapeHtml=g;exports.parseHtmlFragment=S;exports.renderBlockToHTML=Te;exports.renderBlocksToHTML=Ae;exports.serializeNodes=C;exports.snapshotVersionOf=K;exports.textOf=N;exports.textWithBlockBreaks=E;exports.upgradeSnapshot=B;exports.upgradeSnapshots=M;