@aeriz/wysiwyg 1.0.4 → 2.0.0

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 (132) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +82 -573
  3. package/angular/README.md +10 -4
  4. package/angular/aeriz-editor.directive.ts +40 -18
  5. package/dist/adapters/jquery.cjs +1 -1
  6. package/dist/adapters/jquery.js +14 -14
  7. package/dist/adapters/shared.cjs +1 -1
  8. package/dist/adapters/shared.js +59 -56
  9. package/dist/adapters/vue.cjs +1 -1
  10. package/dist/adapters/vue.js +64 -56
  11. package/dist/adapters/vue2.cjs +1 -1
  12. package/dist/adapters/vue2.js +24 -17
  13. package/dist/adapters/wc.cjs +1 -1
  14. package/dist/adapters/wc.js +108 -72
  15. package/dist/aeriz-wysiwyg-adapter.js +24 -32
  16. package/dist/aeriz-wysiwyg-adapter.min.js +1 -1
  17. package/dist/aeriz-wysiwyg-highlight.js +964 -0
  18. package/dist/aeriz-wysiwyg-highlight.min.js +5 -0
  19. package/dist/aeriz-wysiwyg-jquery.js +25 -32
  20. package/dist/aeriz-wysiwyg-jquery.min.js +1 -1
  21. package/dist/aeriz-wysiwyg-wc.js +80 -43
  22. package/dist/aeriz-wysiwyg-wc.min.js +1 -1
  23. package/dist/aeriz-wysiwyg.cjs +3688 -1757
  24. package/dist/aeriz-wysiwyg.css +2104 -1904
  25. package/dist/aeriz-wysiwyg.esm.js +3688 -1757
  26. package/dist/aeriz-wysiwyg.esm.min.js +4904 -3538
  27. package/dist/aeriz-wysiwyg.js +3688 -1757
  28. package/dist/aeriz-wysiwyg.min.cjs +53 -40
  29. package/dist/aeriz-wysiwyg.min.css +1 -1
  30. package/dist/aeriz-wysiwyg.min.js +53 -40
  31. package/dist/highlight.cjs +5 -0
  32. package/dist/highlight.js +895 -0
  33. package/dist/server.cjs +24 -19
  34. package/dist/server.js +612 -251
  35. package/dist-types/adapters/shared.d.ts +0 -8
  36. package/dist-types/adapters/shared.d.ts.map +1 -1
  37. package/dist-types/adapters/vue.d.ts +62 -21
  38. package/dist-types/adapters/vue.d.ts.map +1 -1
  39. package/dist-types/adapters/vue2.d.ts +33 -14
  40. package/dist-types/adapters/vue2.d.ts.map +1 -1
  41. package/dist-types/adapters/wc.d.ts +15 -6
  42. package/dist-types/adapters/wc.d.ts.map +1 -1
  43. package/dist-types/cjs/adapters/shared.d.cts +0 -8
  44. package/dist-types/cjs/adapters/vue.d.cts +62 -21
  45. package/dist-types/cjs/adapters/vue2.d.cts +33 -14
  46. package/dist-types/cjs/adapters/wc.d.cts +15 -6
  47. package/dist-types/cjs/core/AerizEditor.d.cts +238 -48
  48. package/dist-types/cjs/core/AerizViewer.d.cts +7 -0
  49. package/dist-types/cjs/core/block-meta.d.cts +40 -0
  50. package/dist-types/cjs/core/block-tracker.d.cts +64 -0
  51. package/dist-types/cjs/core/blocks.d.cts +39 -4
  52. package/dist-types/cjs/core/fonts.d.cts +33 -46
  53. package/dist-types/cjs/core/highlight.d.cts +2 -0
  54. package/dist-types/cjs/core/history.d.cts +28 -10
  55. package/dist-types/cjs/core/html-to-blocks.d.cts +10 -0
  56. package/dist-types/cjs/core/i18n.d.cts +44 -0
  57. package/dist-types/cjs/core/import-html.d.cts +0 -13
  58. package/dist-types/cjs/core/insert-fragment.d.cts +21 -0
  59. package/dist-types/cjs/core/paste-clean.d.cts +36 -0
  60. package/dist-types/cjs/core/sanitize-dom.d.cts +21 -0
  61. package/dist-types/cjs/core/sanitize-html.d.cts +8 -0
  62. package/dist-types/cjs/core/sanitize-policy.d.cts +22 -0
  63. package/dist-types/cjs/core/selection.d.cts +5 -0
  64. package/dist-types/cjs/core/table-grid.d.cts +87 -0
  65. package/dist-types/cjs/core/table-ops.d.cts +2 -22
  66. package/dist-types/cjs/highlight/index.d.cts +5 -0
  67. package/dist-types/cjs/index.d.cts +19 -11
  68. package/dist-types/cjs/server/index.d.cts +4 -5
  69. package/dist-types/cjs/types/index.d.cts +63 -15
  70. package/dist-types/cjs/ui/Toolbar.d.cts +10 -0
  71. package/dist-types/cjs/ui/doc-tools.d.cts +58 -0
  72. package/dist-types/cjs/ui/popovers.d.cts +14 -25
  73. package/dist-types/core/AerizEditor.d.ts +238 -48
  74. package/dist-types/core/AerizEditor.d.ts.map +1 -1
  75. package/dist-types/core/AerizViewer.d.ts +7 -0
  76. package/dist-types/core/AerizViewer.d.ts.map +1 -1
  77. package/dist-types/core/block-meta.d.ts +40 -0
  78. package/dist-types/core/block-meta.d.ts.map +1 -1
  79. package/dist-types/core/block-policy.d.ts.map +1 -1
  80. package/dist-types/core/block-tracker.d.ts +64 -0
  81. package/dist-types/core/block-tracker.d.ts.map +1 -0
  82. package/dist-types/core/blocks.d.ts +39 -4
  83. package/dist-types/core/blocks.d.ts.map +1 -1
  84. package/dist-types/core/fonts.d.ts +33 -46
  85. package/dist-types/core/fonts.d.ts.map +1 -1
  86. package/dist-types/core/highlight.d.ts +2 -0
  87. package/dist-types/core/highlight.d.ts.map +1 -1
  88. package/dist-types/core/history.d.ts +28 -10
  89. package/dist-types/core/history.d.ts.map +1 -1
  90. package/dist-types/core/html-mini.d.ts.map +1 -1
  91. package/dist-types/core/html-to-blocks.d.ts +10 -0
  92. package/dist-types/core/html-to-blocks.d.ts.map +1 -0
  93. package/dist-types/core/i18n.d.ts +44 -0
  94. package/dist-types/core/i18n.d.ts.map +1 -1
  95. package/dist-types/core/import-html.d.ts +0 -13
  96. package/dist-types/core/import-html.d.ts.map +1 -1
  97. package/dist-types/core/import-markdown.d.ts.map +1 -1
  98. package/dist-types/core/insert-fragment.d.ts +21 -0
  99. package/dist-types/core/insert-fragment.d.ts.map +1 -0
  100. package/dist-types/core/markdown-export.d.ts.map +1 -1
  101. package/dist-types/core/paste-clean.d.ts +36 -0
  102. package/dist-types/core/paste-clean.d.ts.map +1 -0
  103. package/dist-types/core/render-string.d.ts.map +1 -1
  104. package/dist-types/core/sanitize-dom.d.ts +21 -0
  105. package/dist-types/core/sanitize-dom.d.ts.map +1 -0
  106. package/dist-types/core/sanitize-html.d.ts +8 -0
  107. package/dist-types/core/sanitize-html.d.ts.map +1 -0
  108. package/dist-types/core/sanitize-policy.d.ts +22 -0
  109. package/dist-types/core/sanitize-policy.d.ts.map +1 -0
  110. package/dist-types/core/selection.d.ts +5 -0
  111. package/dist-types/core/selection.d.ts.map +1 -1
  112. package/dist-types/core/snapshot.d.ts.map +1 -1
  113. package/dist-types/core/table-grid.d.ts +87 -0
  114. package/dist-types/core/table-grid.d.ts.map +1 -0
  115. package/dist-types/core/table-ops.d.ts +2 -22
  116. package/dist-types/core/table-ops.d.ts.map +1 -1
  117. package/dist-types/highlight/index.d.ts +5 -0
  118. package/dist-types/highlight/index.d.ts.map +1 -0
  119. package/dist-types/index.d.ts +19 -11
  120. package/dist-types/index.d.ts.map +1 -1
  121. package/dist-types/server/index.d.ts +4 -5
  122. package/dist-types/server/index.d.ts.map +1 -1
  123. package/dist-types/types/index.d.ts +63 -15
  124. package/dist-types/types/index.d.ts.map +1 -1
  125. package/dist-types/ui/Toolbar.d.ts +10 -0
  126. package/dist-types/ui/Toolbar.d.ts.map +1 -1
  127. package/dist-types/ui/doc-tools.d.ts +58 -0
  128. package/dist-types/ui/doc-tools.d.ts.map +1 -0
  129. package/dist-types/ui/icons.d.ts.map +1 -1
  130. package/dist-types/ui/popovers.d.ts +14 -25
  131. package/dist-types/ui/popovers.d.ts.map +1 -1
  132. package/package.json +70 -5
@@ -0,0 +1,5 @@
1
+ var AerizWysiwygHighlight=function(m){"use strict";const h={lineComment:"//",blockComment:{start:"/*",end:"*/"},stringDelims:['"',"'"]},g=new Set(["abstract","arguments","async","await","break","case","catch","class","const","continue","debugger","default","delete","do","else","enum","export","extends","finally","for","from","function","get","if","implements","import","in","instanceof","interface","let","new","null","of","package","private","protected","public","return","set","static","super","switch","this","throw","true","false","try","typeof","undefined","var","void","while","with","yield"]),S=new Set([...g,"any","as","asserts","boolean","declare","infer","is","keyof","module","namespace","never","number","object","override","readonly","require","satisfies","string","symbol","type","unique","unknown"]),v=new Set(["False","None","True","and","as","assert","async","await","break","class","continue","def","del","elif","else","except","finally","for","from","global","if","import","in","is","lambda","nonlocal","not","or","pass","raise","return","try","while","with","yield"]),x=new Set(["abs","all","any","bool","dict","enumerate","filter","float","int","isinstance","len","list","map","max","min","open","print","range","set","sorted","str","sum","tuple","type","zip","self","cls"]),y=new Set(["auto","break","case","char","const","continue","default","do","double","else","enum","extern","float","for","goto","if","int","long","register","return","short","signed","sizeof","static","struct","switch","typedef","union","unsigned","void","volatile","while","inline","restrict","_Bool","NULL"]),_=new Set([...y,"class","new","delete","try","catch","throw","template","typename","namespace","using","public","private","protected","virtual","override","this","nullptr","true","false","bool","explicit","friend","mutable","operator","reinterpret_cast","static_cast","dynamic_cast","const_cast","constexpr","decltype","noexcept","final","auto"]),$=new Set(["abstract","async","await","base","bool","break","byte","case","catch","char","checked","class","const","continue","decimal","default","delegate","do","double","else","enum","event","explicit","extern","false","finally","fixed","float","for","foreach","goto","if","implicit","in","int","interface","internal","is","lock","long","namespace","new","null","object","operator","out","override","params","private","protected","public","readonly","ref","return","sbyte","sealed","short","sizeof","stackalloc","static","string","struct","switch","this","throw","true","try","typeof","uint","ulong","unchecked","unsafe","ushort","using","var","virtual","void","volatile","while","yield","record","init","nameof","when"]),O=new Set(["abstract","assert","boolean","break","byte","case","catch","char","class","const","continue","default","do","double","else","enum","extends","final","finally","float","for","goto","if","implements","import","instanceof","int","interface","long","native","new","null","package","private","protected","public","return","short","static","strictfp","super","switch","synchronized","this","throw","throws","transient","true","false","try","void","volatile","while","var","yield","record","sealed","permits","non-sealed"]),A=new Set(["abstract","actual","annotation","as","break","by","catch","class","companion","const","constructor","continue","crossinline","data","do","dynamic","else","enum","expect","external","false","final","finally","for","fun","get","if","import","in","init","inline","inner","interface","internal","is","it","lateinit","null","object","open","operator","out","override","package","private","protected","public","reified","return","sealed","set","super","suspend","tailrec","this","throw","true","try","typealias","typeof","val","var","vararg","when","where","while"]),C=new Set(["break","case","chan","const","continue","default","defer","else","fallthrough","for","func","go","goto","if","import","interface","map","package","range","return","select","struct","switch","type","var","true","false","nil","iota"]),D=new Set(["as","async","await","break","const","continue","crate","dyn","else","enum","extern","false","fn","for","if","impl","in","let","loop","match","mod","move","mut","pub","ref","return","self","Self","static","struct","super","trait","true","type","unsafe","use","where","while","box","do","final","macro","override","priv","typeof","unsized","virtual","yield"]),W=new Set(["if","then","else","elif","fi","case","esac","for","while","until","do","done","function","return","select","break","continue","in","echo","export","local","readonly","declare","typeset","unset","eval","exec","source","true","false"]),E=new Set(["select","from","where","insert","update","delete","into","values","set","create","table","drop","alter","index","view","join","inner","left","right","outer","full","cross","on","group","by","order","having","limit","offset","union","all","distinct","as","and","or","not","null","true","false","is","in","between","like","exists","primary","key","foreign","references","unique","default","check","constraint","database","schema","with","case","when","then","else","end","cast","count","sum","avg","min","max","asc","desc"]),R=new Set(["true","false","null"]),b=[{id:"plaintext",label:"Plain Text",keywords:new Set},{id:"javascript",label:"JavaScript",keywords:g,...h,stringDelims:['"',"'","`"]},{id:"typescript",label:"TypeScript",keywords:S,...h,stringDelims:['"',"'","`"]},{id:"python",label:"Python",keywords:v,builtins:x,lineComment:"#",stringDelims:['"',"'"]},{id:"json",label:"JSON",keywords:R,stringDelims:['"']},{id:"html",label:"HTML",keywords:new Set,custom:e=>L(e)},{id:"css",label:"CSS",keywords:new Set,custom:e=>N(e)},{id:"bash",label:"Bash",keywords:W,lineComment:"#",stringDelims:['"',"'"]},{id:"sql",label:"SQL",keywords:E,caseInsensitiveKeywords:!0,lineComment:"--",blockComment:{start:"/*",end:"*/"},stringDelims:['"',"'"]},{id:"markdown",label:"Markdown",keywords:new Set,custom:e=>P(e)},{id:"c",label:"C",keywords:y,...h},{id:"cpp",label:"C++",keywords:_,...h},{id:"csharp",label:"C#",keywords:$,...h},{id:"java",label:"Java",keywords:O,...h},{id:"kotlin",label:"Kotlin",keywords:A,...h},{id:"go",label:"Go",keywords:C,...h},{id:"rust",label:"Rust",keywords:D,...h}],z=(()=>{const e=new Map;for(const t of b)e.set(t.id,t);return e})(),K="plaintext";function Y(e,t){if(!t||t===K)return s(e);const n=z.get(t);return n?n.custom?n.custom(e):T(e,n):s(e)}function T(e,t){var c,a;const n=!!t.caseInsensitiveKeywords;let o="",i=0;const l=e.length;for(;i<l;){if(t.lineComment&&e.startsWith(t.lineComment,i)){const r=e.indexOf(`
2
+ `,i),p=r===-1?l:r;o+=`<span class="hl-comment">${s(e.slice(i,p))}</span>`,i=p;continue}if(t.blockComment&&e.startsWith(t.blockComment.start,i)){const r=e.indexOf(t.blockComment.end,i+t.blockComment.start.length),p=r===-1?l:r+t.blockComment.end.length;o+=`<span class="hl-comment">${s(e.slice(i,p))}</span>`,i=p;continue}const u=(c=t.stringDelims)==null?void 0:c.find(r=>e.startsWith(r,i));if(u){let r=i+u.length;for(;r<l;){const p=e[r]??"";if(p==="\\"){r+=2;continue}if(e.startsWith(u,r)){r+=u.length;break}if(p===`
3
+ `&&u!=="`")break;r++}o+=`<span class="hl-string">${s(e.slice(i,r))}</span>`,i=r;continue}const f=e[i]??"";if(/[0-9]/.test(f)){const r=j.exec(e.slice(i));if(r){o+=`<span class="hl-number">${s(r[0])}</span>`,i+=r[0].length;continue}}if(/[a-zA-Z_$]/.test(f)){let r=i+1;for(;r<l&&/[a-zA-Z0-9_$]/.test(e[r]??"");)r++;const p=e.slice(i,r),k=n?p.toLowerCase():p;if(t.keywords.has(k))o+=`<span class="hl-keyword">${s(p)}</span>`;else if((a=t.builtins)!=null&&a.has(k))o+=`<span class="hl-builtin">${s(p)}</span>`;else{let d=r;for(;d<l&&(e[d]===" "||e[d]===" ");)d++;e[d]==="("?o+=`<span class="hl-fn">${s(p)}</span>`:o+=s(p)}i=r;continue}o+=s(f),i++}return o}const j=/^(0[xX][0-9a-fA-F_]+|0[bB][01_]+|0[oO][0-7_]+|[0-9][0-9_]*(?:\.[0-9_]+)?(?:[eE][-+]?[0-9_]+)?)[a-zA-Z]*/;function L(e){let t="",n=0;const o=e.length;for(;n<o;){if(e.startsWith("<!--",n)){const i=e.indexOf("-->",n+4),l=i===-1?o:i+3;t+=`<span class="hl-comment">${s(e.slice(n,l))}</span>`,n=l;continue}if(e[n]==="<"){const i=e.indexOf(">",n);if(i===-1){t+=s(e.slice(n));break}const l=e.slice(n,i+1);t+=M(l),n=i+1;continue}t+=s(e[n]??""),n++}return t}function M(e){const t=e.slice(1,-1);let n='<span class="hl-punct">&lt;</span>';const o=/^\/?[a-zA-Z][a-zA-Z0-9-]*/.exec(t);if(o){n+=`<span class="hl-tag">${s(o[0])}</span>`;let i=t.slice(o[0].length);const l=/\s+([a-zA-Z_:][a-zA-Z0-9_:.-]*)(\s*=\s*("([^"]*)"|'([^']*)'|([^\s>]+)))?/g;let c=0,a;for(;a=l.exec(i);){n+=s(i.slice(c,a.index)),n+=s(i.slice(a.index,a.index+a[0].indexOf(a[1]??""))),n+=`<span class="hl-attr">${s(a[1]??"")}</span>`;const u=i.slice(a.index+(a[0].indexOf(a[1]??"")+(a[1]??"").length),a.index+a[0].length);if(u.includes("=")){const f=u.indexOf("=");n+=s(u.slice(0,f+1));const r=u.slice(f+1);n+=`<span class="hl-string">${s(r)}</span>`}c=a.index+a[0].length}n+=s(i.slice(c))}else n+=s(t);return n+='<span class="hl-punct">&gt;</span>',n}function N(e){let t="",n=0;const o=e.length;let i=!1;for(;n<o;){if(e.startsWith("/*",n)){const c=e.indexOf("*/",n+2),a=c===-1?o:c+2;t+=`<span class="hl-comment">${s(e.slice(n,a))}</span>`,n=a;continue}const l=e[n]??"";if(l==="{"){i=!0,t+=s(l),n++;continue}if(l==="}"){i=!1,t+=s(l),n++;continue}if(l==='"'||l==="'"){const c=l;let a=n+1;for(;a<o&&e[a]!==c;)e[a]==="\\"?a+=2:a++;a=Math.min(a+1,o),t+=`<span class="hl-string">${s(e.slice(n,a))}</span>`,n=a;continue}if(/[a-zA-Z_-]/.test(l)||l==="@"||l==="#"||l==="."||l===":"){let c=n+1;for(;c<o&&/[a-zA-Z0-9_-]/.test(e[c]??"");)c++;const a=e.slice(n,c);if(l==="@")t+=`<span class="hl-keyword">${s(a)}</span>`;else if(i&&/^[a-zA-Z-]+$/.test(a)){let u=c;for(;u<o&&(e[u]===" "||e[u]===" ");)u++;e[u]===":"?t+=`<span class="hl-prop">${s(a)}</span>`:t+=s(a)}else t+=`<span class="hl-tag">${s(a)}</span>`;n=c;continue}if(/[0-9]/.test(l)){const c=/^[0-9.]+(px|em|rem|%|vh|vw|s|ms|deg|fr)?/.exec(e.slice(n));if(c){t+=`<span class="hl-number">${s(c[0])}</span>`,n+=c[0].length;continue}}t+=s(l),n++}return t}function P(e){return e.split(`
4
+ `).map(Z).join(`
5
+ `)}function Z(e){const t=/^(#{1,6})\s+(.*)$/.exec(e);if(t)return`<span class="hl-keyword">${s(t[1]??"")}</span> <span class="hl-tag">${w(t[2]??"")}</span>`;if(e.startsWith(">"))return`<span class="hl-comment">${s(e)}</span>`;if(e.startsWith("```"))return`<span class="hl-keyword">${s(e)}</span>`;const n=/^(\s*)([-*+]|\d+\.)\s+(.*)$/.exec(e);return n?`${n[1]??""}<span class="hl-keyword">${s(n[2]??"")}</span> ${w(n[3]??"")}`:w(e)}function w(e){let t=s(e);return t=t.replace(/\*\*([^*]+)\*\*/g,'<span class="hl-keyword">**$1**</span>'),t=t.replace(new RegExp("(?<!\\*)\\*([^*]+)\\*(?!\\*)","g"),'<span class="hl-string">*$1*</span>'),t=t.replace(/`([^`]+)`/g,'<span class="hl-builtin">`$1`</span>'),t=t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,'<span class="hl-tag">[$1]</span><span class="hl-string">($2)</span>'),t}function s(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const B={languages:b.map(({id:e,label:t})=>({id:e,label:t})),highlight:Y};return m.highlighter=B,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"}),m}({});
@@ -1,28 +1,23 @@
1
1
  var AerizWysiwygJQuery = function(exports, wysiwyg) {
2
2
  "use strict";
3
- function htmlToBlocks(html) {
4
- const scratch = document.createElement("div");
5
- scratch.innerHTML = html;
6
- wysiwyg.normalizeContent(scratch, { writableTail: false });
7
- const ids = new wysiwyg.BlockIdRegistry();
8
- wysiwyg.assignMissingIds(scratch, ids);
9
- return wysiwyg.serializeBlocks(wysiwyg.listBlocks(scratch, (el) => ids.ensure(el)));
10
- }
3
+ const CONTROLLER_PROPS = /* @__PURE__ */ new Set(["value", "onChange", "onStateChange", "onReady", "onDestroy"]);
11
4
  function toEditorOptions(element, props, onChange) {
12
5
  const options = { element, onChange };
6
+ for (const [key, value] of Object.entries(props)) {
7
+ if (value === void 0 || CONTROLLER_PROPS.has(key)) continue;
8
+ options[key] = value;
9
+ }
13
10
  const initial = props.value ?? props.initialHTML;
14
11
  if (initial !== void 0) options.initialHTML = initial;
15
- if (props.placeholder !== void 0) options.placeholder = props.placeholder;
16
- if (props.toolbar !== void 0) options.toolbar = props.toolbar;
17
- if (props.theme !== void 0) options.theme = props.theme;
18
- if (props.locale !== void 0) options.locale = props.locale;
19
- if (props.htmlStyles !== void 0) options.htmlStyles = props.htmlStyles;
20
- if (props.onImageUpload !== void 0) options.onImageUpload = props.onImageUpload;
21
- if (props.imageUploadUrl !== void 0) options.imageUploadUrl = props.imageUploadUrl;
22
- if (props.onFileUpload !== void 0) options.onFileUpload = props.onFileUpload;
23
- if (props.fileUploadUrl !== void 0) options.fileUploadUrl = props.fileUploadUrl;
24
12
  return options;
25
13
  }
14
+ const LIVE_OPTIONS = ["upload", "htmlStyles", "onError"];
15
+ const REBUILD_OPTIONS = ["locale", "statusBar", "height", "ariaLabel", "fonts", "fontSizes", "highlighter"];
16
+ function sameValue(a, b) {
17
+ if (a === b) return true;
18
+ if (typeof a !== "object" || typeof b !== "object" || !a || !b) return false;
19
+ return JSON.stringify(a) === JSON.stringify(b);
20
+ }
26
21
  function sameToolbar(a, b) {
27
22
  if (a === b) return true;
28
23
  if (a === false || b === false || a === void 0 || b === void 0) {
@@ -47,16 +42,11 @@ var AerizWysiwygJQuery = function(exports, wysiwyg) {
47
42
  let unsubscribe = null;
48
43
  let liveOptions;
49
44
  const syncLazyOptions = (next) => {
50
- if (next.onImageUpload === void 0) delete liveOptions.onImageUpload;
51
- else liveOptions.onImageUpload = next.onImageUpload;
52
- if (next.imageUploadUrl === void 0) delete liveOptions.imageUploadUrl;
53
- else liveOptions.imageUploadUrl = next.imageUploadUrl;
54
- if (next.onFileUpload === void 0) delete liveOptions.onFileUpload;
55
- else liveOptions.onFileUpload = next.onFileUpload;
56
- if (next.fileUploadUrl === void 0) delete liveOptions.fileUploadUrl;
57
- else liveOptions.fileUploadUrl = next.fileUploadUrl;
58
- if (next.htmlStyles === void 0) delete liveOptions.htmlStyles;
59
- else liveOptions.htmlStyles = next.htmlStyles;
45
+ const live = liveOptions;
46
+ for (const key of LIVE_OPTIONS) {
47
+ if (next[key] === void 0) delete live[key];
48
+ else live[key] = next[key];
49
+ }
60
50
  };
61
51
  const create = (from, html) => {
62
52
  var _a;
@@ -86,7 +76,7 @@ var AerizWysiwygJQuery = function(exports, wysiwyg) {
86
76
  if (disposed) return;
87
77
  const prev = props;
88
78
  props = next;
89
- if (next.locale !== prev.locale || !sameToolbar(next.toolbar, prev.toolbar)) {
79
+ if (!sameToolbar(next.toolbar, prev.toolbar) || REBUILD_OPTIONS.some((key) => !sameValue(next[key], prev[key]))) {
90
80
  const carried = next.value ?? editor.getHTML();
91
81
  teardown();
92
82
  create(next, carried);
@@ -96,6 +86,9 @@ var AerizWysiwygJQuery = function(exports, wysiwyg) {
96
86
  if (next.theme !== prev.theme && next.theme !== void 0) {
97
87
  editor.setTheme(next.theme);
98
88
  }
89
+ if (Boolean(next.readOnly) !== Boolean(prev.readOnly)) {
90
+ editor.setReadOnly(Boolean(next.readOnly));
91
+ }
99
92
  if (next.placeholder !== prev.placeholder) {
100
93
  if (next.placeholder === void 0) {
101
94
  delete editor.content.dataset.placeholder;
@@ -122,8 +115,8 @@ var AerizWysiwygJQuery = function(exports, wysiwyg) {
122
115
  }
123
116
  function toViewerOptions(element, props) {
124
117
  const options = { element };
125
- const blocks = props.blocks ?? (props.html !== void 0 ? htmlToBlocks(props.html) : void 0);
126
- if (blocks !== void 0) options.initialBlocks = blocks;
118
+ if (props.blocks !== void 0) options.initialBlocks = props.blocks;
119
+ else if (props.html !== void 0) options.initialHTML = props.html;
127
120
  if (props.theme !== void 0) options.theme = props.theme;
128
121
  if (props.htmlStyles !== void 0) options.htmlStyles = props.htmlStyles;
129
122
  return options;
@@ -149,7 +142,7 @@ var AerizWysiwygJQuery = function(exports, wysiwyg) {
149
142
  if (next.blocks !== void 0) {
150
143
  if (next.blocks !== prev.blocks) viewer.setBlocks(next.blocks);
151
144
  } else if (next.html !== void 0 && next.html !== prev.html) {
152
- if (next.html !== viewer.getHTML()) viewer.setBlocks(htmlToBlocks(next.html));
145
+ if (next.html !== viewer.getHTML()) viewer.setHTML(next.html);
153
146
  }
154
147
  },
155
148
  destroy() {
@@ -170,7 +163,7 @@ var AerizWysiwygJQuery = function(exports, wysiwyg) {
170
163
  case "getHTML":
171
164
  return (controller == null ? void 0 : controller.editor.getHTML()) ?? "";
172
165
  case "getBlocks":
173
- return (controller == null ? void 0 : controller.editor.serialize()) ?? [];
166
+ return (controller == null ? void 0 : controller.editor.getBlocks()) ?? [];
174
167
  case "setHTML":
175
168
  collection.each((_i, el) => {
176
169
  var _a;
@@ -1 +1 @@
1
- var AerizWysiwygJQuery=function(g,c){"use strict";function U(i){const e=document.createElement("div");e.innerHTML=i,c.normalizeContent(e,{writableTail:!1});const t=new c.BlockIdRegistry;return c.assignMissingIds(e,t),c.serializeBlocks(c.listBlocks(e,o=>t.ensure(o)))}function z(i,e,t){const o={element:i,onChange:t},r=e.value??e.initialHTML;return r!==void 0&&(o.initialHTML=r),e.placeholder!==void 0&&(o.placeholder=e.placeholder),e.toolbar!==void 0&&(o.toolbar=e.toolbar),e.theme!==void 0&&(o.theme=e.theme),e.locale!==void 0&&(o.locale=e.locale),e.htmlStyles!==void 0&&(o.htmlStyles=e.htmlStyles),e.onImageUpload!==void 0&&(o.onImageUpload=e.onImageUpload),e.imageUploadUrl!==void 0&&(o.imageUploadUrl=e.imageUploadUrl),e.onFileUpload!==void 0&&(o.onFileUpload=e.onFileUpload),e.fileUploadUrl!==void 0&&(o.fileUploadUrl=e.fileUploadUrl),o}function L(i,e){return i===e?!0:i===!1||e===!1||i===void 0||e===void 0||i.sticky!==e.sticky||i.items.length!==e.items.length?!1:i.items.every((t,o)=>t===e.items[o])}function H(i,e){let t=e,o="",r=!1,d=!1;const s=a=>{var f;o=a,!r&&((f=t.onChange)==null||f.call(t,a))};let l,u=null,n;const Q=a=>{a.onImageUpload===void 0?delete n.onImageUpload:n.onImageUpload=a.onImageUpload,a.imageUploadUrl===void 0?delete n.imageUploadUrl:n.imageUploadUrl=a.imageUploadUrl,a.onFileUpload===void 0?delete n.onFileUpload:n.onFileUpload=a.onFileUpload,a.fileUploadUrl===void 0?delete n.fileUploadUrl:n.fileUploadUrl=a.fileUploadUrl,a.htmlStyles===void 0?delete n.htmlStyles:n.htmlStyles=a.htmlStyles},k=(a,f)=>{var S;const m=f!==void 0?{...a,value:f}:a;n=z(i,m,s),l=new c.AerizEditor(n),o=l.getHTML(),u=l.onStateChange(_=>{var w;return(w=t.onStateChange)==null?void 0:w.call(t,_)}),(S=t.onReady)==null||S.call(t,l)},M=()=>{var a;(a=t.onDestroy)==null||a.call(t,l),u==null||u(),u=null,l.destroy()};return k(t),{get editor(){return l},update(a){if(d)return;const f=t;if(t=a,a.locale!==f.locale||!L(a.toolbar,f.toolbar)){const m=a.value??l.getHTML();M(),k(a,m);return}if(Q(a),a.theme!==f.theme&&a.theme!==void 0&&l.setTheme(a.theme),a.placeholder!==f.placeholder&&(a.placeholder===void 0?delete l.content.dataset.placeholder:l.content.dataset.placeholder=a.placeholder),a.value!==void 0&&a.value!==o&&a.value!==l.getHTML()){r=!0;try{l.setHTML(a.value)}finally{r=!1}o=a.value}},destroy(){d||(d=!0,M())}}}function b(i,e){const t={element:i},o=e.blocks??(e.html!==void 0?U(e.html):void 0);return o!==void 0&&(t.initialBlocks=o),e.theme!==void 0&&(t.theme=e.theme),e.htmlStyles!==void 0&&(t.htmlStyles=e.htmlStyles),t}function B(i,e){var s;let t=e,o=!1;const r=b(i,e),d=new c.AerizViewer(r);return(s=t.onReady)==null||s.call(t,d),{viewer:d,update(l){if(o)return;const u=t;t=l,l.theme!==u.theme&&l.theme!==void 0&&d.setTheme(l.theme),l.htmlStyles===void 0?delete r.htmlStyles:r.htmlStyles=l.htmlStyles,l.blocks!==void 0?l.blocks!==u.blocks&&d.setBlocks(l.blocks):l.html!==void 0&&l.html!==u.html&&l.html!==d.getHTML()&&d.setBlocks(U(l.html))},destroy(){var l;o||(o=!0,(l=t.onDestroy)==null||l.call(t,d),d.destroy())}}}const h=new WeakMap,v=new WeakMap;function E(i,e,t){const o=i[0],r=o?h.get(o):void 0;switch(e){case"getHTML":return(r==null?void 0:r.editor.getHTML())??"";case"getBlocks":return(r==null?void 0:r.editor.serialize())??[];case"setHTML":return i.each((d,s)=>{var l;(l=h.get(s))==null||l.editor.setHTML(String(t[0]??""))}),i;case"update":return i.each((d,s)=>{var l;(l=h.get(s))==null||l.update(t[0]??{})}),i;case"focus":return r==null||r.editor.focus(),i;case"instance":return(r==null?void 0:r.editor)??null;case"destroy":return i.each((d,s)=>{const l=h.get(s);l&&(l.destroy(),h.delete(s))}),i;default:throw new Error(`aerizEditor: 알 수 없는 명령 "${e}"`)}}function I(i,e,t){const o=i[0],r=o?v.get(o):void 0;switch(e){case"getHTML":return(r==null?void 0:r.viewer.getHTML())??"";case"getBlocks":return(r==null?void 0:r.viewer.getBlocks())??[];case"update":return i.each((d,s)=>{var l;(l=v.get(s))==null||l.update(t[0]??{})}),i;case"instance":return(r==null?void 0:r.viewer)??null;case"destroy":return i.each((d,s)=>{const l=v.get(s);l&&(l.destroy(),v.delete(s))}),i;default:throw new Error(`aerizViewer: 알 수 없는 명령 "${e}"`)}}function A(i,...e){if(typeof i=="string")return E(this,i,e);const t=i??{};return this.each((o,r)=>{const d=h.get(r);if(d){d.update(t);return}h.set(r,H(r,t))}),this}function F(i,...e){if(typeof i=="string")return I(this,i,e);const t=i??{};return this.each((o,r)=>{const d=v.get(r);if(d){d.update(t);return}v.set(r,B(r,t))}),this}function y(i){if(!i||typeof i.fn!="object")throw new TypeError("registerAerizJQuery: jQuery 객체가 필요합니다.");i.fn.aerizEditor||(i.fn.aerizEditor=A),i.fn.aerizViewer||(i.fn.aerizViewer=F)}const T=globalThis.jQuery;return T&&y(T),g.registerAerizJQuery=y,Object.defineProperty(g,Symbol.toStringTag,{value:"Module"}),g}({},AerizWysiwyg);
1
+ var AerizWysiwygJQuery=function(y,v){"use strict";const k=new Set(["value","onChange","onStateChange","onReady","onDestroy"]);function H(e,s,i){const a={element:e,onChange:i};for(const[o,u]of Object.entries(s))u===void 0||k.has(o)||(a[o]=u);const r=s.value??s.initialHTML;return r!==void 0&&(a.initialHTML=r),a}const O=["upload","htmlStyles","onError"],z=["locale","statusBar","height","ariaLabel","fonts","fontSizes","highlighter"];function E(e,s){return e===s?!0:typeof e!="object"||typeof s!="object"||!e||!s?!1:JSON.stringify(e)===JSON.stringify(s)}function B(e,s){return e===s?!0:e===!1||s===!1||e===void 0||s===void 0||e.sticky!==s.sticky||e.items.length!==s.items.length?!1:e.items.every((i,a)=>i===s.items[a])}function _(e,s){let i=s,a="",r=!1,o=!1;const u=n=>{var f;a=n,!r&&((f=i.onChange)==null||f.call(i,n))};let t,d=null,g;const J=n=>{const f=g;for(const l of O)n[l]===void 0?delete f[l]:f[l]=n[l]},T=(n,f)=>{var S;const l=f!==void 0?{...n,value:f}:n;g=H(e,l,u),t=new v.AerizEditor(g),a=t.getHTML(),d=t.onStateChange(Q=>{var M;return(M=i.onStateChange)==null?void 0:M.call(i,Q)}),(S=i.onReady)==null||S.call(i,t)},L=()=>{var n;(n=i.onDestroy)==null||n.call(i,t),d==null||d(),d=null,t.destroy()};return T(i),{get editor(){return t},update(n){if(o)return;const f=i;if(i=n,!B(n.toolbar,f.toolbar)||z.some(l=>!E(n[l],f[l]))){const l=n.value??t.getHTML();L(),T(n,l);return}if(J(n),n.theme!==f.theme&&n.theme!==void 0&&t.setTheme(n.theme),!!n.readOnly!=!!f.readOnly&&t.setReadOnly(!!n.readOnly),n.placeholder!==f.placeholder&&(n.placeholder===void 0?delete t.content.dataset.placeholder:t.content.dataset.placeholder=n.placeholder),n.value!==void 0&&n.value!==a&&n.value!==t.getHTML()){r=!0;try{t.setHTML(n.value)}finally{r=!1}a=n.value}},destroy(){o||(o=!0,L())}}}function b(e,s){const i={element:e};return s.blocks!==void 0?i.initialBlocks=s.blocks:s.html!==void 0&&(i.initialHTML=s.html),s.theme!==void 0&&(i.theme=s.theme),s.htmlStyles!==void 0&&(i.htmlStyles=s.htmlStyles),i}function R(e,s){var u;let i=s,a=!1;const r=b(e,s),o=new v.AerizViewer(r);return(u=i.onReady)==null||u.call(i,o),{viewer:o,update(t){if(a)return;const d=i;i=t,t.theme!==d.theme&&t.theme!==void 0&&o.setTheme(t.theme),t.htmlStyles===void 0?delete r.htmlStyles:r.htmlStyles=t.htmlStyles,t.blocks!==void 0?t.blocks!==d.blocks&&o.setBlocks(t.blocks):t.html!==void 0&&t.html!==d.html&&t.html!==o.getHTML()&&o.setHTML(t.html)},destroy(){var t;a||(a=!0,(t=i.onDestroy)==null||t.call(i,o),o.destroy())}}}const c=new WeakMap,h=new WeakMap;function V(e,s,i){const a=e[0],r=a?c.get(a):void 0;switch(s){case"getHTML":return(r==null?void 0:r.editor.getHTML())??"";case"getBlocks":return(r==null?void 0:r.editor.getBlocks())??[];case"setHTML":return e.each((o,u)=>{var t;(t=c.get(u))==null||t.editor.setHTML(String(i[0]??""))}),e;case"update":return e.each((o,u)=>{var t;(t=c.get(u))==null||t.update(i[0]??{})}),e;case"focus":return r==null||r.editor.focus(),e;case"instance":return(r==null?void 0:r.editor)??null;case"destroy":return e.each((o,u)=>{const t=c.get(u);t&&(t.destroy(),c.delete(u))}),e;default:throw new Error(`aerizEditor: 알 수 없는 명령 "${s}"`)}}function j(e,s,i){const a=e[0],r=a?h.get(a):void 0;switch(s){case"getHTML":return(r==null?void 0:r.viewer.getHTML())??"";case"getBlocks":return(r==null?void 0:r.viewer.getBlocks())??[];case"update":return e.each((o,u)=>{var t;(t=h.get(u))==null||t.update(i[0]??{})}),e;case"instance":return(r==null?void 0:r.viewer)??null;case"destroy":return e.each((o,u)=>{const t=h.get(u);t&&(t.destroy(),h.delete(u))}),e;default:throw new Error(`aerizViewer: 알 수 없는 명령 "${s}"`)}}function A(e,...s){if(typeof e=="string")return V(this,e,s);const i=e??{};return this.each((a,r)=>{const o=c.get(r);if(o){o.update(i);return}c.set(r,_(r,i))}),this}function C(e,...s){if(typeof e=="string")return j(this,e,s);const i=e??{};return this.each((a,r)=>{const o=h.get(r);if(o){o.update(i);return}h.set(r,R(r,i))}),this}function w(e){if(!e||typeof e.fn!="object")throw new TypeError("registerAerizJQuery: jQuery 객체가 필요합니다.");e.fn.aerizEditor||(e.fn.aerizEditor=A),e.fn.aerizViewer||(e.fn.aerizViewer=C)}const m=globalThis.jQuery;return m&&w(m),y.registerAerizJQuery=w,Object.defineProperty(y,Symbol.toStringTag,{value:"Module"}),y}({},AerizWysiwyg);
@@ -3,29 +3,24 @@ var AerizWysiwygWC = function(exports, wysiwyg) {
3
3
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
4
4
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
5
 
6
- function htmlToBlocks(html) {
7
- const scratch = document.createElement("div");
8
- scratch.innerHTML = html;
9
- wysiwyg.normalizeContent(scratch, { writableTail: false });
10
- const ids = new wysiwyg.BlockIdRegistry();
11
- wysiwyg.assignMissingIds(scratch, ids);
12
- return wysiwyg.serializeBlocks(wysiwyg.listBlocks(scratch, (el) => ids.ensure(el)));
13
- }
6
+ const CONTROLLER_PROPS = /* @__PURE__ */ new Set(["value", "onChange", "onStateChange", "onReady", "onDestroy"]);
14
7
  function toEditorOptions(element, props, onChange) {
15
8
  const options = { element, onChange };
9
+ for (const [key, value] of Object.entries(props)) {
10
+ if (value === void 0 || CONTROLLER_PROPS.has(key)) continue;
11
+ options[key] = value;
12
+ }
16
13
  const initial = props.value ?? props.initialHTML;
17
14
  if (initial !== void 0) options.initialHTML = initial;
18
- if (props.placeholder !== void 0) options.placeholder = props.placeholder;
19
- if (props.toolbar !== void 0) options.toolbar = props.toolbar;
20
- if (props.theme !== void 0) options.theme = props.theme;
21
- if (props.locale !== void 0) options.locale = props.locale;
22
- if (props.htmlStyles !== void 0) options.htmlStyles = props.htmlStyles;
23
- if (props.onImageUpload !== void 0) options.onImageUpload = props.onImageUpload;
24
- if (props.imageUploadUrl !== void 0) options.imageUploadUrl = props.imageUploadUrl;
25
- if (props.onFileUpload !== void 0) options.onFileUpload = props.onFileUpload;
26
- if (props.fileUploadUrl !== void 0) options.fileUploadUrl = props.fileUploadUrl;
27
15
  return options;
28
16
  }
17
+ const LIVE_OPTIONS = ["upload", "htmlStyles", "onError"];
18
+ const REBUILD_OPTIONS = ["locale", "statusBar", "height", "ariaLabel", "fonts", "fontSizes", "highlighter"];
19
+ function sameValue(a, b) {
20
+ if (a === b) return true;
21
+ if (typeof a !== "object" || typeof b !== "object" || !a || !b) return false;
22
+ return JSON.stringify(a) === JSON.stringify(b);
23
+ }
29
24
  function sameToolbar(a, b) {
30
25
  if (a === b) return true;
31
26
  if (a === false || b === false || a === void 0 || b === void 0) {
@@ -50,16 +45,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
50
45
  let unsubscribe = null;
51
46
  let liveOptions;
52
47
  const syncLazyOptions = (next) => {
53
- if (next.onImageUpload === void 0) delete liveOptions.onImageUpload;
54
- else liveOptions.onImageUpload = next.onImageUpload;
55
- if (next.imageUploadUrl === void 0) delete liveOptions.imageUploadUrl;
56
- else liveOptions.imageUploadUrl = next.imageUploadUrl;
57
- if (next.onFileUpload === void 0) delete liveOptions.onFileUpload;
58
- else liveOptions.onFileUpload = next.onFileUpload;
59
- if (next.fileUploadUrl === void 0) delete liveOptions.fileUploadUrl;
60
- else liveOptions.fileUploadUrl = next.fileUploadUrl;
61
- if (next.htmlStyles === void 0) delete liveOptions.htmlStyles;
62
- else liveOptions.htmlStyles = next.htmlStyles;
48
+ const live = liveOptions;
49
+ for (const key of LIVE_OPTIONS) {
50
+ if (next[key] === void 0) delete live[key];
51
+ else live[key] = next[key];
52
+ }
63
53
  };
64
54
  const create = (from, html) => {
65
55
  var _a;
@@ -89,7 +79,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
89
79
  if (disposed) return;
90
80
  const prev = props;
91
81
  props = next;
92
- if (next.locale !== prev.locale || !sameToolbar(next.toolbar, prev.toolbar)) {
82
+ if (!sameToolbar(next.toolbar, prev.toolbar) || REBUILD_OPTIONS.some((key) => !sameValue(next[key], prev[key]))) {
93
83
  const carried = next.value ?? editor.getHTML();
94
84
  teardown();
95
85
  create(next, carried);
@@ -99,6 +89,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
99
89
  if (next.theme !== prev.theme && next.theme !== void 0) {
100
90
  editor.setTheme(next.theme);
101
91
  }
92
+ if (Boolean(next.readOnly) !== Boolean(prev.readOnly)) {
93
+ editor.setReadOnly(Boolean(next.readOnly));
94
+ }
102
95
  if (next.placeholder !== prev.placeholder) {
103
96
  if (next.placeholder === void 0) {
104
97
  delete editor.content.dataset.placeholder;
@@ -125,8 +118,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
125
118
  }
126
119
  function toViewerOptions(element, props) {
127
120
  const options = { element };
128
- const blocks = props.blocks ?? (props.html !== void 0 ? htmlToBlocks(props.html) : void 0);
129
- if (blocks !== void 0) options.initialBlocks = blocks;
121
+ if (props.blocks !== void 0) options.initialBlocks = props.blocks;
122
+ else if (props.html !== void 0) options.initialHTML = props.html;
130
123
  if (props.theme !== void 0) options.theme = props.theme;
131
124
  if (props.htmlStyles !== void 0) options.htmlStyles = props.htmlStyles;
132
125
  return options;
@@ -152,7 +145,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
152
145
  if (next.blocks !== void 0) {
153
146
  if (next.blocks !== prev.blocks) viewer.setBlocks(next.blocks);
154
147
  } else if (next.html !== void 0 && next.html !== prev.html) {
155
- if (next.html !== viewer.getHTML()) viewer.setBlocks(htmlToBlocks(next.html));
148
+ if (next.html !== viewer.getHTML()) viewer.setHTML(next.html);
156
149
  }
157
150
  },
158
151
  destroy() {
@@ -204,9 +197,11 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
204
197
  class AerizEditorElement extends HTMLElement {
205
198
  constructor() {
206
199
  super();
207
- /** 프로퍼티로 설정된 업로드 핸들러. 속성으로는 표현할 수 없다. */
208
- __publicField(this, "onImageUpload");
209
- __publicField(this, "onFileUpload");
200
+ // 속성(문자열) 으로 나타낼 수 없는 옵션은 프로퍼티로 준다. 바꾸면 바로 반영된다.
201
+ __publicField(this, "uploadValue");
202
+ __publicField(this, "fontsValue");
203
+ __publicField(this, "highlighterValue");
204
+ __publicField(this, "fontSizesValue");
210
205
  __publicField(this, "controller", null);
211
206
  __publicField(this, "internals", null);
212
207
  /**
@@ -229,10 +224,43 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
229
224
  "locale",
230
225
  "toolbar",
231
226
  "html-styles",
232
- "image-upload-url",
233
- "file-upload-url"
227
+ "read-only",
228
+ "height",
229
+ "status-bar",
230
+ "upload-url",
231
+ "aria-label"
234
232
  ];
235
233
  }
234
+ /** 올리기 설정. `upload-url` 속성보다 우선한다 (헤더 · 직접 올리기가 필요할 때). */
235
+ get upload() {
236
+ return this.uploadValue;
237
+ }
238
+ set upload(value) {
239
+ this.uploadValue = value;
240
+ this.applyProps();
241
+ }
242
+ /** 코드 블록 색칠기 (`@aeriz/wysiwyg/highlight` 의 `highlighter`). */
243
+ get highlighter() {
244
+ return this.highlighterValue;
245
+ }
246
+ set highlighter(value) {
247
+ this.highlighterValue = value;
248
+ this.applyProps();
249
+ }
250
+ get fonts() {
251
+ return this.fontsValue;
252
+ }
253
+ set fonts(value) {
254
+ this.fontsValue = value;
255
+ this.applyProps();
256
+ }
257
+ get fontSizes() {
258
+ return this.fontSizesValue;
259
+ }
260
+ set fontSizes(value) {
261
+ this.fontSizesValue = value;
262
+ this.applyProps();
263
+ }
236
264
  /** 현재 본문 HTML. 설정하면 본문을 교체한다. */
237
265
  get value() {
238
266
  if (this.controller) return this.controller.editor.getHTML();
@@ -250,7 +278,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
250
278
  /** 블록 상태 스냅샷. */
251
279
  getBlocks() {
252
280
  var _a;
253
- return ((_a = this.controller) == null ? void 0 : _a.editor.serialize()) ?? [];
281
+ return ((_a = this.controller) == null ? void 0 : _a.editor.getBlocks()) ?? [];
254
282
  }
255
283
  /** 본문에 캐럿을 둔다. `HTMLElement.focus()` 를 본문 쪽으로 위임한다. */
256
284
  focus() {
@@ -298,6 +326,9 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
298
326
  this.syncFormValue(html);
299
327
  this.dispatchEvent(new CustomEvent("input", { detail: { html }, bubbles: true }));
300
328
  this.dispatchEvent(new CustomEvent("change", { detail: { html }, bubbles: true }));
329
+ },
330
+ onError: (error, context) => {
331
+ this.dispatchEvent(new CustomEvent("error", { detail: { error, code: context.code }, bubbles: true }));
301
332
  }
302
333
  };
303
334
  if (this.pendingValue !== void 0) props.value = this.pendingValue;
@@ -313,12 +344,18 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
313
344
  if (htmlStyles === "class" || htmlStyles === "inline") {
314
345
  props.htmlStyles = htmlStyles;
315
346
  }
316
- const imageUrl = this.getAttribute("image-upload-url");
317
- if (imageUrl !== null) props.imageUploadUrl = imageUrl;
318
- const fileUrl = this.getAttribute("file-upload-url");
319
- if (fileUrl !== null) props.fileUploadUrl = fileUrl;
320
- if (this.onImageUpload) props.onImageUpload = this.onImageUpload;
321
- if (this.onFileUpload) props.onFileUpload = this.onFileUpload;
347
+ if (this.hasAttribute("read-only")) props.readOnly = true;
348
+ if (this.getAttribute("status-bar") === "false") props.statusBar = false;
349
+ const height = this.getAttribute("height");
350
+ if (height) props.height = /^\d+$/.test(height) ? Number(height) : height;
351
+ const label = this.getAttribute("aria-label");
352
+ if (label) props.ariaLabel = label;
353
+ const uploadUrl = this.getAttribute("upload-url");
354
+ if (this.uploadValue) props.upload = this.uploadValue;
355
+ else if (uploadUrl) props.upload = { url: uploadUrl };
356
+ if (this.fontsValue) props.fonts = this.fontsValue;
357
+ if (this.highlighterValue) props.highlighter = this.highlighterValue;
358
+ if (this.fontSizesValue) props.fontSizes = this.fontSizesValue;
322
359
  return props;
323
360
  }
324
361
  syncFormValue(html) {
@@ -1 +1 @@
1
- var AerizWysiwygWC=function(u,s){"use strict";var w=Object.defineProperty;var j=(u,s,m)=>s in u?w(u,s,{enumerable:!0,configurable:!0,writable:!0,value:m}):u[s]=m;var f=(u,s,m)=>j(u,typeof s!="symbol"?s+"":s,m);function m(o){const t=document.createElement("div");t.innerHTML=o,s.normalizeContent(t,{writableTail:!1});const e=new s.BlockIdRegistry;return s.assignMissingIds(t,e),s.serializeBlocks(s.listBlocks(t,l=>e.ensure(l)))}function C(o,t,e){const l={element:o,onChange:e},r=t.value??t.initialHTML;return r!==void 0&&(l.initialHTML=r),t.placeholder!==void 0&&(l.placeholder=t.placeholder),t.toolbar!==void 0&&(l.toolbar=t.toolbar),t.theme!==void 0&&(l.theme=t.theme),t.locale!==void 0&&(l.locale=t.locale),t.htmlStyles!==void 0&&(l.htmlStyles=t.htmlStyles),t.onImageUpload!==void 0&&(l.onImageUpload=t.onImageUpload),t.imageUploadUrl!==void 0&&(l.imageUploadUrl=t.imageUploadUrl),t.onFileUpload!==void 0&&(l.onFileUpload=t.onFileUpload),t.fileUploadUrl!==void 0&&(l.fileUploadUrl=t.fileUploadUrl),l}function V(o,t){return o===t?!0:o===!1||t===!1||o===void 0||t===void 0||o.sticky!==t.sticky||o.items.length!==t.items.length?!1:o.items.every((e,l)=>e===t.items[l])}function L(o,t){let e=t,l="",r=!1,a=!1;const v=i=>{var h;l=i,!r&&((h=e.onChange)==null||h.call(e,i))};let n,c=null,d;const g=i=>{i.onImageUpload===void 0?delete d.onImageUpload:d.onImageUpload=i.onImageUpload,i.imageUploadUrl===void 0?delete d.imageUploadUrl:d.imageUploadUrl=i.imageUploadUrl,i.onFileUpload===void 0?delete d.onFileUpload:d.onFileUpload=i.onFileUpload,i.fileUploadUrl===void 0?delete d.fileUploadUrl:d.fileUploadUrl=i.fileUploadUrl,i.htmlStyles===void 0?delete d.htmlStyles:d.htmlStyles=i.htmlStyles},E=(i,h)=>{var A;const U=h!==void 0?{...i,value:h}:i;d=C(o,U,v),n=new s.AerizEditor(d),l=n.getHTML(),c=n.onStateChange(O=>{var S;return(S=e.onStateChange)==null?void 0:S.call(e,O)}),(A=e.onReady)==null||A.call(e,n)},T=()=>{var i;(i=e.onDestroy)==null||i.call(e,n),c==null||c(),c=null,n.destroy()};return E(e),{get editor(){return n},update(i){if(a)return;const h=e;if(e=i,i.locale!==h.locale||!V(i.toolbar,h.toolbar)){const U=i.value??n.getHTML();T(),E(i,U);return}if(g(i),i.theme!==h.theme&&i.theme!==void 0&&n.setTheme(i.theme),i.placeholder!==h.placeholder&&(i.placeholder===void 0?delete n.content.dataset.placeholder:n.content.dataset.placeholder=i.placeholder),i.value!==void 0&&i.value!==l&&i.value!==n.getHTML()){r=!0;try{n.setHTML(i.value)}finally{r=!1}l=i.value}},destroy(){a||(a=!0,T())}}}function M(o,t){const e={element:o},l=t.blocks??(t.html!==void 0?m(t.html):void 0);return l!==void 0&&(e.initialBlocks=l),t.theme!==void 0&&(e.theme=t.theme),t.htmlStyles!==void 0&&(e.htmlStyles=t.htmlStyles),e}function z(o,t){var v;let e=t,l=!1;const r=M(o,t),a=new s.AerizViewer(r);return(v=e.onReady)==null||v.call(e,a),{viewer:a,update(n){if(l)return;const c=e;e=n,n.theme!==c.theme&&n.theme!==void 0&&a.setTheme(n.theme),n.htmlStyles===void 0?delete r.htmlStyles:r.htmlStyles=n.htmlStyles,n.blocks!==void 0?n.blocks!==c.blocks&&a.setBlocks(n.blocks):n.html!==void 0&&n.html!==c.html&&n.html!==a.getHTML()&&a.setBlocks(m(n.html))},destroy(){var n;l||(l=!0,(n=e.onDestroy)==null||n.call(e,a),a.destroy())}}}const F=["light","dark"],H=["en","ko","ja","zh"];function p(o){return o!==null&&F.includes(o)?o:void 0}function I(o){return o!==null&&H.includes(o)?o:void 0}function B(o){if(o===null)return;const t=o.trim();if(t==="")return;if(t==="false"||t==="none")return!1;if(t.startsWith("{")){try{const l=JSON.parse(t);if(l&&typeof l=="object"&&Array.isArray(l.items))return l}catch{}return}const e=t.split(/[\s,]+/).filter(l=>l.length>0);return e.length>0?{items:e}:void 0}function P(o){const t=o.attachInternals;if(typeof t!="function")return null;try{const e=t.call(o);return typeof e=="object"&&e!==null&&typeof e.setFormValue=="function"?e:null}catch{return null}}class b extends HTMLElement{constructor(){super();f(this,"onImageUpload");f(this,"onFileUpload");f(this,"controller",null);f(this,"internals",null);f(this,"pendingValue");f(this,"currentHTML","");this.internals=P(this)}static get observedAttributes(){return["value","placeholder","theme","locale","toolbar","html-styles","image-upload-url","file-upload-url"]}get value(){return this.controller?this.controller.editor.getHTML():this.pendingValue??this.currentHTML}set value(e){this.pendingValue=e,this.applyProps()}get editor(){var e;return((e=this.controller)==null?void 0:e.editor)??null}getBlocks(){var e;return((e=this.controller)==null?void 0:e.editor.serialize())??[]}focus(){var e;(e=this.controller)==null||e.editor.focus()}connectedCallback(){if(!this.controller){if(this.pendingValue===void 0){const e=this.getAttribute("value");e!==null&&(this.pendingValue=e)}this.controller=L(this,this.buildProps()),this.pendingValue=void 0,this.syncFormValue(this.controller.editor.getHTML()),this.dispatchEvent(new CustomEvent("aeriz-ready",{detail:{editor:this.controller.editor},bubbles:!1}))}}disconnectedCallback(){var e;(e=this.controller)==null||e.destroy(),this.controller=null}attributeChangedCallback(e,l,r){e==="value"&&(this.pendingValue=r??""),this.applyProps()}applyProps(){this.controller&&(this.controller.update(this.buildProps()),this.pendingValue=void 0)}buildProps(){const e={onChange:g=>{this.pendingValue=void 0,this.syncFormValue(g),this.dispatchEvent(new CustomEvent("input",{detail:{html:g},bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{html:g},bubbles:!0}))}};this.pendingValue!==void 0&&(e.value=this.pendingValue);const l=this.getAttribute("placeholder");l!==null&&(e.placeholder=l);const r=p(this.getAttribute("theme"));r!==void 0&&(e.theme=r);const a=I(this.getAttribute("locale"));a!==void 0&&(e.locale=a);const v=B(this.getAttribute("toolbar"));v!==void 0&&(e.toolbar=v);const n=this.getAttribute("html-styles");(n==="class"||n==="inline")&&(e.htmlStyles=n);const c=this.getAttribute("image-upload-url");c!==null&&(e.imageUploadUrl=c);const d=this.getAttribute("file-upload-url");return d!==null&&(e.fileUploadUrl=d),this.onImageUpload&&(e.onImageUpload=this.onImageUpload),this.onFileUpload&&(e.onFileUpload=this.onFileUpload),e}syncFormValue(e){var l;this.currentHTML=e,(l=this.internals)==null||l.setFormValue(e)}}f(b,"formAssociated",!0);class y extends HTMLElement{constructor(){super(...arguments);f(this,"controller",null);f(this,"pendingBlocks")}static get observedAttributes(){return["html","theme"]}get blocks(){var e;return((e=this.controller)==null?void 0:e.viewer.getBlocks())??this.pendingBlocks??[]}set blocks(e){var l;this.pendingBlocks=e,(l=this.controller)==null||l.update(this.buildProps())}get viewer(){var e;return((e=this.controller)==null?void 0:e.viewer)??null}connectedCallback(){this.controller||(this.controller=z(this,this.buildProps()),this.dispatchEvent(new CustomEvent("aeriz-ready",{detail:{viewer:this.controller.viewer},bubbles:!1})))}disconnectedCallback(){var e;(e=this.controller)==null||e.destroy(),this.controller=null}attributeChangedCallback(){var e;(e=this.controller)==null||e.update(this.buildProps())}buildProps(){const e={};this.pendingBlocks!==void 0&&(e.blocks=this.pendingBlocks);const l=this.getAttribute("html");l!==null&&(e.html=l);const r=p(this.getAttribute("theme"));return r!==void 0&&(e.theme=r),e}}function k(o="aeriz"){if(typeof customElements>"u")return;const t=`${o}-editor`,e=`${o}-viewer`;customElements.get(t)||customElements.define(t,b),customElements.get(e)||customElements.define(e,y)}return k(),u.AerizEditorElement=b,u.AerizViewerElement=y,u.defineAerizElements=k,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}),u}({},AerizWysiwyg);
1
+ var AerizWysiwygWC=function(c,f){"use strict";var D=Object.defineProperty;var W=(c,f,v)=>f in c?D(c,f,{enumerable:!0,configurable:!0,writable:!0,value:v}):c[f]=v;var h=(c,f,v)=>W(c,typeof f!="symbol"?f+"":f,v);const v=new Set(["value","onChange","onStateChange","onReady","onDestroy"]);function L(i,t,e){const l={element:i,onChange:e};for(const[n,g]of Object.entries(t))g===void 0||v.has(n)||(l[n]=g);const r=t.value??t.initialHTML;return r!==void 0&&(l.initialHTML=r),l}const C=["upload","htmlStyles","onError"],z=["locale","statusBar","height","ariaLabel","fonts","fontSizes","highlighter"];function O(i,t){return i===t?!0:typeof i!="object"||typeof t!="object"||!i||!t?!1:JSON.stringify(i)===JSON.stringify(t)}function M(i,t){return i===t?!0:i===!1||t===!1||i===void 0||t===void 0||i.sticky!==t.sticky||i.items.length!==t.items.length?!1:i.items.every((e,l)=>e===t.items[l])}function H(i,t){let e=t,l="",r=!1,n=!1;const g=o=>{var u;l=o,!r&&((u=e.onChange)==null||u.call(e,o))};let s,a=null,b;const y=o=>{const u=b;for(const d of C)o[d]===void 0?delete u[d]:u[d]=o[d]},m=(o,u)=>{var T;const d=u!==void 0?{...o,value:u}:o;b=L(i,d,g),s=new f.AerizEditor(b),l=s.getHTML(),a=s.onStateChange(I=>{var A;return(A=e.onStateChange)==null?void 0:A.call(e,I)}),(T=e.onReady)==null||T.call(e,s)},p=()=>{var o;(o=e.onDestroy)==null||o.call(e,s),a==null||a(),a=null,s.destroy()};return m(e),{get editor(){return s},update(o){if(n)return;const u=e;if(e=o,!M(o.toolbar,u.toolbar)||z.some(d=>!O(o[d],u[d]))){const d=o.value??s.getHTML();p(),m(o,d);return}if(y(o),o.theme!==u.theme&&o.theme!==void 0&&s.setTheme(o.theme),!!o.readOnly!=!!u.readOnly&&s.setReadOnly(!!o.readOnly),o.placeholder!==u.placeholder&&(o.placeholder===void 0?delete s.content.dataset.placeholder:s.content.dataset.placeholder=o.placeholder),o.value!==void 0&&o.value!==l&&o.value!==s.getHTML()){r=!0;try{s.setHTML(o.value)}finally{r=!1}l=o.value}},destroy(){n||(n=!0,p())}}}function P(i,t){const e={element:i};return t.blocks!==void 0?e.initialBlocks=t.blocks:t.html!==void 0&&(e.initialHTML=t.html),t.theme!==void 0&&(e.theme=t.theme),t.htmlStyles!==void 0&&(e.htmlStyles=t.htmlStyles),e}function w(i,t){var g;let e=t,l=!1;const r=P(i,t),n=new f.AerizViewer(r);return(g=e.onReady)==null||g.call(e,n),{viewer:n,update(s){if(l)return;const a=e;e=s,s.theme!==a.theme&&s.theme!==void 0&&n.setTheme(s.theme),s.htmlStyles===void 0?delete r.htmlStyles:r.htmlStyles=s.htmlStyles,s.blocks!==void 0?s.blocks!==a.blocks&&n.setBlocks(s.blocks):s.html!==void 0&&s.html!==a.html&&s.html!==n.getHTML()&&n.setHTML(s.html)},destroy(){var s;l||(l=!0,(s=e.onDestroy)==null||s.call(e,n),n.destroy())}}}const B=["light","dark"],R=["en","ko","ja","zh"];function E(i){return i!==null&&B.includes(i)?i:void 0}function j(i){return i!==null&&R.includes(i)?i:void 0}function N(i){if(i===null)return;const t=i.trim();if(t==="")return;if(t==="false"||t==="none")return!1;if(t.startsWith("{")){try{const l=JSON.parse(t);if(l&&typeof l=="object"&&Array.isArray(l.items))return l}catch{}return}const e=t.split(/[\s,]+/).filter(l=>l.length>0);return e.length>0?{items:e}:void 0}function F(i){const t=i.attachInternals;if(typeof t!="function")return null;try{const e=t.call(i);return typeof e=="object"&&e!==null&&typeof e.setFormValue=="function"?e:null}catch{return null}}class V extends HTMLElement{constructor(){super();h(this,"uploadValue");h(this,"fontsValue");h(this,"highlighterValue");h(this,"fontSizesValue");h(this,"controller",null);h(this,"internals",null);h(this,"pendingValue");h(this,"currentHTML","");this.internals=F(this)}static get observedAttributes(){return["value","placeholder","theme","locale","toolbar","html-styles","read-only","height","status-bar","upload-url","aria-label"]}get upload(){return this.uploadValue}set upload(e){this.uploadValue=e,this.applyProps()}get highlighter(){return this.highlighterValue}set highlighter(e){this.highlighterValue=e,this.applyProps()}get fonts(){return this.fontsValue}set fonts(e){this.fontsValue=e,this.applyProps()}get fontSizes(){return this.fontSizesValue}set fontSizes(e){this.fontSizesValue=e,this.applyProps()}get value(){return this.controller?this.controller.editor.getHTML():this.pendingValue??this.currentHTML}set value(e){this.pendingValue=e,this.applyProps()}get editor(){var e;return((e=this.controller)==null?void 0:e.editor)??null}getBlocks(){var e;return((e=this.controller)==null?void 0:e.editor.getBlocks())??[]}focus(){var e;(e=this.controller)==null||e.editor.focus()}connectedCallback(){if(!this.controller){if(this.pendingValue===void 0){const e=this.getAttribute("value");e!==null&&(this.pendingValue=e)}this.controller=H(this,this.buildProps()),this.pendingValue=void 0,this.syncFormValue(this.controller.editor.getHTML()),this.dispatchEvent(new CustomEvent("aeriz-ready",{detail:{editor:this.controller.editor},bubbles:!1}))}}disconnectedCallback(){var e;(e=this.controller)==null||e.destroy(),this.controller=null}attributeChangedCallback(e,l,r){e==="value"&&(this.pendingValue=r??""),this.applyProps()}applyProps(){this.controller&&(this.controller.update(this.buildProps()),this.pendingValue=void 0)}buildProps(){const e={onChange:m=>{this.pendingValue=void 0,this.syncFormValue(m),this.dispatchEvent(new CustomEvent("input",{detail:{html:m},bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{html:m},bubbles:!0}))},onError:(m,p)=>{this.dispatchEvent(new CustomEvent("error",{detail:{error:m,code:p.code},bubbles:!0}))}};this.pendingValue!==void 0&&(e.value=this.pendingValue);const l=this.getAttribute("placeholder");l!==null&&(e.placeholder=l);const r=E(this.getAttribute("theme"));r!==void 0&&(e.theme=r);const n=j(this.getAttribute("locale"));n!==void 0&&(e.locale=n);const g=N(this.getAttribute("toolbar"));g!==void 0&&(e.toolbar=g);const s=this.getAttribute("html-styles");(s==="class"||s==="inline")&&(e.htmlStyles=s),this.hasAttribute("read-only")&&(e.readOnly=!0),this.getAttribute("status-bar")==="false"&&(e.statusBar=!1);const a=this.getAttribute("height");a&&(e.height=/^\d+$/.test(a)?Number(a):a);const b=this.getAttribute("aria-label");b&&(e.ariaLabel=b);const y=this.getAttribute("upload-url");return this.uploadValue?e.upload=this.uploadValue:y&&(e.upload={url:y}),this.fontsValue&&(e.fonts=this.fontsValue),this.highlighterValue&&(e.highlighter=this.highlighterValue),this.fontSizesValue&&(e.fontSizes=this.fontSizesValue),e}syncFormValue(e){var l;this.currentHTML=e,(l=this.internals)==null||l.setFormValue(e)}}h(V,"formAssociated",!0);class S extends HTMLElement{constructor(){super(...arguments);h(this,"controller",null);h(this,"pendingBlocks")}static get observedAttributes(){return["html","theme"]}get blocks(){var e;return((e=this.controller)==null?void 0:e.viewer.getBlocks())??this.pendingBlocks??[]}set blocks(e){var l;this.pendingBlocks=e,(l=this.controller)==null||l.update(this.buildProps())}get viewer(){var e;return((e=this.controller)==null?void 0:e.viewer)??null}connectedCallback(){this.controller||(this.controller=w(this,this.buildProps()),this.dispatchEvent(new CustomEvent("aeriz-ready",{detail:{viewer:this.controller.viewer},bubbles:!1})))}disconnectedCallback(){var e;(e=this.controller)==null||e.destroy(),this.controller=null}attributeChangedCallback(){var e;(e=this.controller)==null||e.update(this.buildProps())}buildProps(){const e={};this.pendingBlocks!==void 0&&(e.blocks=this.pendingBlocks);const l=this.getAttribute("html");l!==null&&(e.html=l);const r=E(this.getAttribute("theme"));return r!==void 0&&(e.theme=r),e}}function k(i="aeriz"){if(typeof customElements>"u")return;const t=`${i}-editor`,e=`${i}-viewer`;customElements.get(t)||customElements.define(t,V),customElements.get(e)||customElements.define(e,S)}return k(),c.AerizEditorElement=V,c.AerizViewerElement=S,c.defineAerizElements=k,Object.defineProperty(c,Symbol.toStringTag,{value:"Module"}),c}({},AerizWysiwyg);