@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.
- package/README.md +37 -13
- package/dist/adapters/shared.cjs +1 -1
- package/dist/adapters/shared.js +11 -11
- package/dist/aeriz-wysiwyg-adapter.js +1 -1
- package/dist/aeriz-wysiwyg-adapter.min.js +1 -1
- package/dist/aeriz-wysiwyg-jquery.js +1 -1
- package/dist/aeriz-wysiwyg-jquery.min.js +1 -1
- package/dist/aeriz-wysiwyg-wc.js +1 -1
- package/dist/aeriz-wysiwyg-wc.min.js +1 -1
- package/dist/aeriz-wysiwyg.cjs +3773 -1926
- package/dist/aeriz-wysiwyg.css +554 -38
- package/dist/aeriz-wysiwyg.esm.js +3773 -1926
- package/dist/aeriz-wysiwyg.esm.min.js +4271 -2658
- package/dist/aeriz-wysiwyg.js +3773 -1926
- package/dist/aeriz-wysiwyg.min.cjs +36 -34
- package/dist/aeriz-wysiwyg.min.css +1 -1
- package/dist/aeriz-wysiwyg.min.js +40 -38
- package/dist/server.cjs +24 -22
- package/dist/server.js +444 -312
- package/dist-types/adapters/shared.d.ts.map +1 -1
- package/dist-types/cjs/core/AerizEditor.d.cts +180 -7
- package/dist-types/cjs/core/block-meta.d.cts +66 -0
- package/dist-types/cjs/core/block-policy.d.cts +43 -0
- package/dist-types/cjs/core/blocks.d.cts +47 -4
- package/dist-types/cjs/core/history.d.cts +86 -0
- package/dist-types/cjs/core/i18n.d.cts +12 -0
- package/dist-types/cjs/core/import-html.d.cts +1 -0
- package/dist-types/cjs/core/import-markdown.d.cts +0 -4
- package/dist-types/cjs/core/input-rules.d.cts +46 -0
- package/dist-types/cjs/core/selection.d.cts +46 -0
- package/dist-types/cjs/core/table-ops.d.cts +30 -0
- package/dist-types/cjs/index.d.cts +2 -0
- package/dist-types/core/AerizEditor.d.ts +180 -7
- package/dist-types/core/AerizEditor.d.ts.map +1 -1
- package/dist-types/core/block-meta.d.ts +66 -0
- package/dist-types/core/block-meta.d.ts.map +1 -1
- package/dist-types/core/block-policy.d.ts +43 -0
- package/dist-types/core/block-policy.d.ts.map +1 -0
- package/dist-types/core/blocks.d.ts +47 -4
- package/dist-types/core/blocks.d.ts.map +1 -1
- package/dist-types/core/history.d.ts +86 -0
- package/dist-types/core/history.d.ts.map +1 -0
- package/dist-types/core/i18n.d.ts +12 -0
- package/dist-types/core/i18n.d.ts.map +1 -1
- package/dist-types/core/import-html.d.ts +1 -0
- package/dist-types/core/import-html.d.ts.map +1 -1
- package/dist-types/core/import-markdown.d.ts +0 -4
- package/dist-types/core/import-markdown.d.ts.map +1 -1
- package/dist-types/core/input-rules.d.ts +46 -0
- package/dist-types/core/input-rules.d.ts.map +1 -0
- package/dist-types/core/plain-text.d.ts.map +1 -1
- package/dist-types/core/render-string.d.ts.map +1 -1
- package/dist-types/core/selection.d.ts +46 -0
- package/dist-types/core/selection.d.ts.map +1 -0
- package/dist-types/core/snapshot.d.ts.map +1 -1
- package/dist-types/core/table-ops.d.ts +30 -0
- package/dist-types/core/table-ops.d.ts.map +1 -0
- package/dist-types/index.d.ts +2 -0
- package/dist-types/index.d.ts.map +1 -1
- package/dist-types/ui/Toolbar.d.ts.map +1 -1
- package/dist-types/ui/dialogs.d.ts.map +1 -1
- package/dist-types/ui/icons.d.ts.map +1 -1
- package/dist-types/ui/popovers.d.ts.map +1 -1
- 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
|
|
2
|
-
`;continue}
|
|
3
|
-
`;continue}const r=
|
|
4
|
-
`)&&(
|
|
5
|
-
`),
|
|
6
|
-
`)&&(
|
|
7
|
-
`)}return
|
|
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,"&").replace(/</g,"<").replace(/>/g,">")}function f(e){return g(e).replace(/"/g,""")}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
|
|
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(
|
|
14
|
-
`):""}case"codeBlock":{const
|
|
15
|
-
${
|
|
16
|
-
${
|
|
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=`})`,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
|
-
${
|
|
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
|
-
${
|
|
21
|
-
`)}function
|
|
22
|
-
`)}function
|
|
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();
|
|
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+=`})`);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=
|
|
27
|
-
`);case"
|
|
28
|
-
`)}function
|
|
29
|
-
`)
|
|
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
|
|
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;
|