@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
@@ -1,4 +1,4 @@
1
- import { createEditorController as l, createViewerController as r } from "./shared.js";
1
+ import { createEditorController as l, createViewerController as n } from "./shared.js";
2
2
  function o(e, t) {
3
3
  e.$watch(
4
4
  () => ({ ...e.$props }),
@@ -18,10 +18,14 @@ const a = {
18
18
  locale: { type: String, default: void 0 },
19
19
  /** `getHTML()` · `onChange` 출력 전략. 기본 `'inline'`. */
20
20
  htmlStyles: { type: String, default: void 0 },
21
- onImageUpload: { type: Function, default: void 0 },
22
- imageUploadUrl: { type: String, default: void 0 },
23
- onFileUpload: { type: Function, default: void 0 },
24
- fileUploadUrl: { type: String, default: void 0 }
21
+ statusBar: { type: Boolean, default: void 0 },
22
+ ariaLabel: { type: String, default: void 0 },
23
+ readOnly: { type: Boolean, default: void 0 },
24
+ height: { type: [Number, String], default: void 0 },
25
+ upload: { type: Object, default: void 0 },
26
+ fonts: { type: Array, default: void 0 },
27
+ highlighter: { type: Object, default: void 0 },
28
+ fontSizes: { type: Array, default: void 0 }
25
29
  },
26
30
  data() {
27
31
  return { aerizController: null };
@@ -29,13 +33,16 @@ const a = {
29
33
  methods: {
30
34
  aerizProps() {
31
35
  const e = this.$props, t = {
32
- onChange: (i) => {
33
- this.$emit("input", i), this.$emit("change", i);
36
+ onChange: (r) => {
37
+ this.$emit("input", r), this.$emit("change", r);
34
38
  },
35
- onStateChange: (i) => this.$emit("state-change", i),
36
- onReady: (i) => this.$emit("ready", i)
39
+ onStateChange: (r) => this.$emit("state-change", r),
40
+ onReady: (r) => this.$emit("ready", r),
41
+ onError: (r, i) => this.$emit("error", r, i)
37
42
  };
38
- return e.value !== void 0 && (t.value = e.value), e.initialHTML !== void 0 && (t.initialHTML = e.initialHTML), e.placeholder !== void 0 && (t.placeholder = e.placeholder), e.toolbar !== void 0 && (t.toolbar = e.toolbar), e.theme !== void 0 && (t.theme = e.theme), e.locale !== void 0 && (t.locale = e.locale), e.htmlStyles !== void 0 && (t.htmlStyles = e.htmlStyles), e.onImageUpload !== void 0 && (t.onImageUpload = e.onImageUpload), e.imageUploadUrl !== void 0 && (t.imageUploadUrl = e.imageUploadUrl), e.onFileUpload !== void 0 && (t.onFileUpload = e.onFileUpload), e.fileUploadUrl !== void 0 && (t.fileUploadUrl = e.fileUploadUrl), t;
43
+ for (const [r, i] of Object.entries(e))
44
+ i !== void 0 && (t[r] = i);
45
+ return t;
39
46
  },
40
47
  /** 코어 인스턴스. `this.$refs.editor.getEditor()` 로 접근한다. */
41
48
  getEditor() {
@@ -68,7 +75,7 @@ const a = {
68
75
  render(e) {
69
76
  return e("div");
70
77
  }
71
- }, d = {
78
+ }, s = {
72
79
  name: "AerizViewer",
73
80
  props: {
74
81
  blocks: { type: Array, default: void 0 },
@@ -83,7 +90,7 @@ const a = {
83
90
  methods: {
84
91
  aerizProps() {
85
92
  const e = this.$props, t = {
86
- onReady: (i) => this.$emit("ready", i)
93
+ onReady: (r) => this.$emit("ready", r)
87
94
  };
88
95
  return e.blocks !== void 0 && (t.blocks = e.blocks), e.html !== void 0 && (t.html = e.html), e.theme !== void 0 && (t.theme = e.theme), e.htmlStyles !== void 0 && (t.htmlStyles = e.htmlStyles), t;
89
96
  },
@@ -93,7 +100,7 @@ const a = {
93
100
  }
94
101
  },
95
102
  mounted() {
96
- this.aerizController = r(this.$el, this.aerizProps()), o(this, () => {
103
+ this.aerizController = n(this.$el, this.aerizProps()), o(this, () => {
97
104
  var e;
98
105
  return (e = this.aerizController) == null ? void 0 : e.update(this.aerizProps());
99
106
  });
@@ -105,13 +112,13 @@ const a = {
105
112
  render(e) {
106
113
  return e("div");
107
114
  }
108
- }, s = {
115
+ }, h = {
109
116
  install(e) {
110
- e.component("AerizEditor", a), e.component("AerizViewer", d);
117
+ e.component("AerizEditor", a), e.component("AerizViewer", s);
111
118
  }
112
119
  };
113
120
  export {
114
121
  a as AerizEditor,
115
- d as AerizViewer,
116
- s as AerizWysiwygPlugin
122
+ s as AerizViewer,
123
+ h as AerizWysiwygPlugin
117
124
  };
@@ -1 +1 @@
1
- "use strict";var b=Object.defineProperty;var v=(e,l,t)=>l in e?b(e,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[l]=t;var r=(e,l,t)=>v(e,typeof l!="symbol"?l+"":l,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./shared.cjs"),y=["light","dark"],E=["en","ko","ja","zh"];function f(e){return e!==null&&y.includes(e)?e:void 0}function A(e){return e!==null&&E.includes(e)?e:void 0}function V(e){if(e===null)return;const l=e.trim();if(l==="")return;if(l==="false"||l==="none")return!1;if(l.startsWith("{")){try{const i=JSON.parse(l);if(i&&typeof i=="object"&&Array.isArray(i.items))return i}catch{}return}const t=l.split(/[\s,]+/).filter(i=>i.length>0);return t.length>0?{items:t}:void 0}function k(e){const l=e.attachInternals;if(typeof l!="function")return null;try{const t=l.call(e);return typeof t=="object"&&t!==null&&typeof t.setFormValue=="function"?t:null}catch{return null}}class a extends HTMLElement{constructor(){super();r(this,"onImageUpload");r(this,"onFileUpload");r(this,"controller",null);r(this,"internals",null);r(this,"pendingValue");r(this,"currentHTML","");this.internals=k(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(t){this.pendingValue=t,this.applyProps()}get editor(){var t;return((t=this.controller)==null?void 0:t.editor)??null}getBlocks(){var t;return((t=this.controller)==null?void 0:t.editor.serialize())??[]}focus(){var t;(t=this.controller)==null||t.editor.focus()}connectedCallback(){if(!this.controller){if(this.pendingValue===void 0){const t=this.getAttribute("value");t!==null&&(this.pendingValue=t)}this.controller=p.createEditorController(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 t;(t=this.controller)==null||t.destroy(),this.controller=null}attributeChangedCallback(t,i,n){t==="value"&&(this.pendingValue=n??""),this.applyProps()}applyProps(){this.controller&&(this.controller.update(this.buildProps()),this.pendingValue=void 0)}buildProps(){const t={onChange:s=>{this.pendingValue=void 0,this.syncFormValue(s),this.dispatchEvent(new CustomEvent("input",{detail:{html:s},bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{html:s},bubbles:!0}))}};this.pendingValue!==void 0&&(t.value=this.pendingValue);const i=this.getAttribute("placeholder");i!==null&&(t.placeholder=i);const n=f(this.getAttribute("theme"));n!==void 0&&(t.theme=n);const u=A(this.getAttribute("locale"));u!==void 0&&(t.locale=u);const c=V(this.getAttribute("toolbar"));c!==void 0&&(t.toolbar=c);const o=this.getAttribute("html-styles");(o==="class"||o==="inline")&&(t.htmlStyles=o);const d=this.getAttribute("image-upload-url");d!==null&&(t.imageUploadUrl=d);const h=this.getAttribute("file-upload-url");return h!==null&&(t.fileUploadUrl=h),this.onImageUpload&&(t.onImageUpload=this.onImageUpload),this.onFileUpload&&(t.onFileUpload=this.onFileUpload),t}syncFormValue(t){var i;this.currentHTML=t,(i=this.internals)==null||i.setFormValue(t)}}r(a,"formAssociated",!0);class g extends HTMLElement{constructor(){super(...arguments);r(this,"controller",null);r(this,"pendingBlocks")}static get observedAttributes(){return["html","theme"]}get blocks(){var t;return((t=this.controller)==null?void 0:t.viewer.getBlocks())??this.pendingBlocks??[]}set blocks(t){var i;this.pendingBlocks=t,(i=this.controller)==null||i.update(this.buildProps())}get viewer(){var t;return((t=this.controller)==null?void 0:t.viewer)??null}connectedCallback(){this.controller||(this.controller=p.createViewerController(this,this.buildProps()),this.dispatchEvent(new CustomEvent("aeriz-ready",{detail:{viewer:this.controller.viewer},bubbles:!1})))}disconnectedCallback(){var t;(t=this.controller)==null||t.destroy(),this.controller=null}attributeChangedCallback(){var t;(t=this.controller)==null||t.update(this.buildProps())}buildProps(){const t={};this.pendingBlocks!==void 0&&(t.blocks=this.pendingBlocks);const i=this.getAttribute("html");i!==null&&(t.html=i);const n=f(this.getAttribute("theme"));return n!==void 0&&(t.theme=n),t}}function m(e="aeriz"){if(typeof customElements>"u")return;const l=`${e}-editor`,t=`${e}-viewer`;customElements.get(l)||customElements.define(l,a),customElements.get(t)||customElements.define(t,g)}m();exports.AerizEditorElement=a;exports.AerizViewerElement=g;exports.defineAerizElements=m;
1
+ "use strict";var V=Object.defineProperty;var y=(e,i,t)=>i in e?V(e,i,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[i]=t;var s=(e,i,t)=>y(e,typeof i!="symbol"?i+"":i,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("./shared.cjs"),E=["light","dark"],A=["en","ko","ja","zh"];function g(e){return e!==null&&E.includes(e)?e:void 0}function k(e){return e!==null&&A.includes(e)?e:void 0}function z(e){if(e===null)return;const i=e.trim();if(i==="")return;if(i==="false"||i==="none")return!1;if(i.startsWith("{")){try{const l=JSON.parse(i);if(l&&typeof l=="object"&&Array.isArray(l.items))return l}catch{}return}const t=i.split(/[\s,]+/).filter(l=>l.length>0);return t.length>0?{items:t}:void 0}function C(e){const i=e.attachInternals;if(typeof i!="function")return null;try{const t=i.call(e);return typeof t=="object"&&t!==null&&typeof t.setFormValue=="function"?t:null}catch{return null}}class a extends HTMLElement{constructor(){super();s(this,"uploadValue");s(this,"fontsValue");s(this,"highlighterValue");s(this,"fontSizesValue");s(this,"controller",null);s(this,"internals",null);s(this,"pendingValue");s(this,"currentHTML","");this.internals=C(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(t){this.uploadValue=t,this.applyProps()}get highlighter(){return this.highlighterValue}set highlighter(t){this.highlighterValue=t,this.applyProps()}get fonts(){return this.fontsValue}set fonts(t){this.fontsValue=t,this.applyProps()}get fontSizes(){return this.fontSizesValue}set fontSizes(t){this.fontSizesValue=t,this.applyProps()}get value(){return this.controller?this.controller.editor.getHTML():this.pendingValue??this.currentHTML}set value(t){this.pendingValue=t,this.applyProps()}get editor(){var t;return((t=this.controller)==null?void 0:t.editor)??null}getBlocks(){var t;return((t=this.controller)==null?void 0:t.editor.getBlocks())??[]}focus(){var t;(t=this.controller)==null||t.editor.focus()}connectedCallback(){if(!this.controller){if(this.pendingValue===void 0){const t=this.getAttribute("value");t!==null&&(this.pendingValue=t)}this.controller=f.createEditorController(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 t;(t=this.controller)==null||t.destroy(),this.controller=null}attributeChangedCallback(t,l,r){t==="value"&&(this.pendingValue=r??""),this.applyProps()}applyProps(){this.controller&&(this.controller.update(this.buildProps()),this.pendingValue=void 0)}buildProps(){const t={onChange:n=>{this.pendingValue=void 0,this.syncFormValue(n),this.dispatchEvent(new CustomEvent("input",{detail:{html:n},bubbles:!0})),this.dispatchEvent(new CustomEvent("change",{detail:{html:n},bubbles:!0}))},onError:(n,v)=>{this.dispatchEvent(new CustomEvent("error",{detail:{error:n,code:v.code},bubbles:!0}))}};this.pendingValue!==void 0&&(t.value=this.pendingValue);const l=this.getAttribute("placeholder");l!==null&&(t.placeholder=l);const r=g(this.getAttribute("theme"));r!==void 0&&(t.theme=r);const h=k(this.getAttribute("locale"));h!==void 0&&(t.locale=h);const c=z(this.getAttribute("toolbar"));c!==void 0&&(t.toolbar=c);const u=this.getAttribute("html-styles");(u==="class"||u==="inline")&&(t.htmlStyles=u),this.hasAttribute("read-only")&&(t.readOnly=!0),this.getAttribute("status-bar")==="false"&&(t.statusBar=!1);const o=this.getAttribute("height");o&&(t.height=/^\d+$/.test(o)?Number(o):o);const d=this.getAttribute("aria-label");d&&(t.ariaLabel=d);const p=this.getAttribute("upload-url");return this.uploadValue?t.upload=this.uploadValue:p&&(t.upload={url:p}),this.fontsValue&&(t.fonts=this.fontsValue),this.highlighterValue&&(t.highlighter=this.highlighterValue),this.fontSizesValue&&(t.fontSizes=this.fontSizesValue),t}syncFormValue(t){var l;this.currentHTML=t,(l=this.internals)==null||l.setFormValue(t)}}s(a,"formAssociated",!0);class b extends HTMLElement{constructor(){super(...arguments);s(this,"controller",null);s(this,"pendingBlocks")}static get observedAttributes(){return["html","theme"]}get blocks(){var t;return((t=this.controller)==null?void 0:t.viewer.getBlocks())??this.pendingBlocks??[]}set blocks(t){var l;this.pendingBlocks=t,(l=this.controller)==null||l.update(this.buildProps())}get viewer(){var t;return((t=this.controller)==null?void 0:t.viewer)??null}connectedCallback(){this.controller||(this.controller=f.createViewerController(this,this.buildProps()),this.dispatchEvent(new CustomEvent("aeriz-ready",{detail:{viewer:this.controller.viewer},bubbles:!1})))}disconnectedCallback(){var t;(t=this.controller)==null||t.destroy(),this.controller=null}attributeChangedCallback(){var t;(t=this.controller)==null||t.update(this.buildProps())}buildProps(){const t={};this.pendingBlocks!==void 0&&(t.blocks=this.pendingBlocks);const l=this.getAttribute("html");l!==null&&(t.html=l);const r=g(this.getAttribute("theme"));return r!==void 0&&(t.theme=r),t}}function m(e="aeriz"){if(typeof customElements>"u")return;const i=`${e}-editor`,t=`${e}-viewer`;customElements.get(i)||customElements.define(i,a),customElements.get(t)||customElements.define(t,b)}m();exports.AerizEditorElement=a;exports.AerizViewerElement=b;exports.defineAerizElements=m;
@@ -1,49 +1,51 @@
1
- var f = Object.defineProperty;
2
- var g = (e, l, t) => l in e ? f(e, l, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[l] = t;
3
- var r = (e, l, t) => g(e, typeof l != "symbol" ? l + "" : l, t);
4
- import { createEditorController as m, createViewerController as b } from "./shared.js";
5
- const v = ["light", "dark"], y = ["en", "ko", "ja", "zh"];
6
- function h(e) {
7
- return e !== null && v.includes(e) ? e : void 0;
8
- }
9
- function E(e) {
1
+ var b = Object.defineProperty;
2
+ var m = (e, i, t) => i in e ? b(e, i, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[i] = t;
3
+ var s = (e, i, t) => m(e, typeof i != "symbol" ? i + "" : i, t);
4
+ import { createEditorController as v, createViewerController as V } from "./shared.js";
5
+ const y = ["light", "dark"], E = ["en", "ko", "ja", "zh"];
6
+ function p(e) {
10
7
  return e !== null && y.includes(e) ? e : void 0;
11
8
  }
9
+ function A(e) {
10
+ return e !== null && E.includes(e) ? e : void 0;
11
+ }
12
12
  function k(e) {
13
13
  if (e === null) return;
14
- const l = e.trim();
15
- if (l === "") return;
16
- if (l === "false" || l === "none") return !1;
17
- if (l.startsWith("{")) {
14
+ const i = e.trim();
15
+ if (i === "") return;
16
+ if (i === "false" || i === "none") return !1;
17
+ if (i.startsWith("{")) {
18
18
  try {
19
- const i = JSON.parse(l);
20
- if (i && typeof i == "object" && Array.isArray(i.items))
21
- return i;
19
+ const l = JSON.parse(i);
20
+ if (l && typeof l == "object" && Array.isArray(l.items))
21
+ return l;
22
22
  } catch {
23
23
  }
24
24
  return;
25
25
  }
26
- const t = l.split(/[\s,]+/).filter((i) => i.length > 0);
26
+ const t = i.split(/[\s,]+/).filter((l) => l.length > 0);
27
27
  return t.length > 0 ? { items: t } : void 0;
28
28
  }
29
- function A(e) {
30
- const l = e.attachInternals;
31
- if (typeof l != "function") return null;
29
+ function C(e) {
30
+ const i = e.attachInternals;
31
+ if (typeof i != "function") return null;
32
32
  try {
33
- const t = l.call(e);
33
+ const t = i.call(e);
34
34
  return typeof t == "object" && t !== null && typeof t.setFormValue == "function" ? t : null;
35
35
  } catch {
36
36
  return null;
37
37
  }
38
38
  }
39
- class p extends HTMLElement {
39
+ class f extends HTMLElement {
40
40
  constructor() {
41
41
  super();
42
- /** 프로퍼티로 설정된 업로드 핸들러. 속성으로는 표현할 수 없다. */
43
- r(this, "onImageUpload");
44
- r(this, "onFileUpload");
45
- r(this, "controller", null);
46
- r(this, "internals", null);
42
+ // 속성(문자열) 으로 나타낼 수 없는 옵션은 프로퍼티로 준다. 바꾸면 바로 반영된다.
43
+ s(this, "uploadValue");
44
+ s(this, "fontsValue");
45
+ s(this, "highlighterValue");
46
+ s(this, "fontSizesValue");
47
+ s(this, "controller", null);
48
+ s(this, "internals", null);
47
49
  /**
48
50
  * 아직 에디터에 반영되지 않은 **외부에서 지정한** 값.
49
51
  *
@@ -51,10 +53,10 @@ class p extends HTMLElement {
51
53
  * 바뀔 때마다 낡은 값이 `setHTML()` 로 다시 밀려들어가, 모든 블록 id 가
52
54
  * 재발급되고 입력 중이던 캐럿이 문서 맨 앞으로 튄다.
53
55
  */
54
- r(this, "pendingValue");
56
+ s(this, "pendingValue");
55
57
  /** 에디터가 마지막으로 보고한 본문. 폼 값과 마운트 해제 후 `value` 의 근거. */
56
- r(this, "currentHTML", "");
57
- this.internals = A(this);
58
+ s(this, "currentHTML", "");
59
+ this.internals = C(this);
58
60
  }
59
61
  static get observedAttributes() {
60
62
  return [
@@ -64,10 +66,39 @@ class p extends HTMLElement {
64
66
  "locale",
65
67
  "toolbar",
66
68
  "html-styles",
67
- "image-upload-url",
68
- "file-upload-url"
69
+ "read-only",
70
+ "height",
71
+ "status-bar",
72
+ "upload-url",
73
+ "aria-label"
69
74
  ];
70
75
  }
76
+ /** 올리기 설정. `upload-url` 속성보다 우선한다 (헤더 · 직접 올리기가 필요할 때). */
77
+ get upload() {
78
+ return this.uploadValue;
79
+ }
80
+ set upload(t) {
81
+ this.uploadValue = t, this.applyProps();
82
+ }
83
+ /** 코드 블록 색칠기 (`@aeriz/wysiwyg/highlight` 의 `highlighter`). */
84
+ get highlighter() {
85
+ return this.highlighterValue;
86
+ }
87
+ set highlighter(t) {
88
+ this.highlighterValue = t, this.applyProps();
89
+ }
90
+ get fonts() {
91
+ return this.fontsValue;
92
+ }
93
+ set fonts(t) {
94
+ this.fontsValue = t, this.applyProps();
95
+ }
96
+ get fontSizes() {
97
+ return this.fontSizesValue;
98
+ }
99
+ set fontSizes(t) {
100
+ this.fontSizesValue = t, this.applyProps();
101
+ }
71
102
  /** 현재 본문 HTML. 설정하면 본문을 교체한다. */
72
103
  get value() {
73
104
  return this.controller ? this.controller.editor.getHTML() : this.pendingValue ?? this.currentHTML;
@@ -83,7 +114,7 @@ class p extends HTMLElement {
83
114
  /** 블록 상태 스냅샷. */
84
115
  getBlocks() {
85
116
  var t;
86
- return ((t = this.controller) == null ? void 0 : t.editor.serialize()) ?? [];
117
+ return ((t = this.controller) == null ? void 0 : t.editor.getBlocks()) ?? [];
87
118
  }
88
119
  /** 본문에 캐럿을 둔다. `HTMLElement.focus()` 를 본문 쪽으로 위임한다. */
89
120
  focus() {
@@ -96,7 +127,7 @@ class p extends HTMLElement {
96
127
  const t = this.getAttribute("value");
97
128
  t !== null && (this.pendingValue = t);
98
129
  }
99
- this.controller = m(this, this.buildProps()), this.pendingValue = void 0, this.syncFormValue(this.controller.editor.getHTML()), this.dispatchEvent(
130
+ this.controller = v(this, this.buildProps()), this.pendingValue = void 0, this.syncFormValue(this.controller.editor.getHTML()), this.dispatchEvent(
100
131
  new CustomEvent("aeriz-ready", {
101
132
  detail: { editor: this.controller.editor },
102
133
  bubbles: !1
@@ -108,8 +139,8 @@ class p extends HTMLElement {
108
139
  var t;
109
140
  (t = this.controller) == null || t.destroy(), this.controller = null;
110
141
  }
111
- attributeChangedCallback(t, i, o) {
112
- t === "value" && (this.pendingValue = o ?? ""), this.applyProps();
142
+ attributeChangedCallback(t, l, r) {
143
+ t === "value" && (this.pendingValue = r ?? ""), this.applyProps();
113
144
  }
114
145
  /**
115
146
  * 현재 속성·프로퍼티 상태를 컨트롤러에 반영한다.
@@ -120,38 +151,43 @@ class p extends HTMLElement {
120
151
  }
121
152
  buildProps() {
122
153
  const t = {
123
- onChange: (s) => {
124
- this.pendingValue = void 0, this.syncFormValue(s), this.dispatchEvent(new CustomEvent("input", { detail: { html: s }, bubbles: !0 })), this.dispatchEvent(new CustomEvent("change", { detail: { html: s }, bubbles: !0 }));
154
+ onChange: (o) => {
155
+ this.pendingValue = void 0, this.syncFormValue(o), this.dispatchEvent(new CustomEvent("input", { detail: { html: o }, bubbles: !0 })), this.dispatchEvent(new CustomEvent("change", { detail: { html: o }, bubbles: !0 }));
156
+ },
157
+ onError: (o, g) => {
158
+ this.dispatchEvent(new CustomEvent("error", { detail: { error: o, code: g.code }, bubbles: !0 }));
125
159
  }
126
160
  };
127
161
  this.pendingValue !== void 0 && (t.value = this.pendingValue);
128
- const i = this.getAttribute("placeholder");
129
- i !== null && (t.placeholder = i);
130
- const o = h(this.getAttribute("theme"));
131
- o !== void 0 && (t.theme = o);
132
- const u = E(this.getAttribute("locale"));
133
- u !== void 0 && (t.locale = u);
134
- const a = k(this.getAttribute("toolbar"));
135
- a !== void 0 && (t.toolbar = a);
136
- const n = this.getAttribute("html-styles");
137
- (n === "class" || n === "inline") && (t.htmlStyles = n);
138
- const c = this.getAttribute("image-upload-url");
139
- c !== null && (t.imageUploadUrl = c);
140
- const d = this.getAttribute("file-upload-url");
141
- return d !== null && (t.fileUploadUrl = d), this.onImageUpload && (t.onImageUpload = this.onImageUpload), this.onFileUpload && (t.onFileUpload = this.onFileUpload), t;
162
+ const l = this.getAttribute("placeholder");
163
+ l !== null && (t.placeholder = l);
164
+ const r = p(this.getAttribute("theme"));
165
+ r !== void 0 && (t.theme = r);
166
+ const a = A(this.getAttribute("locale"));
167
+ a !== void 0 && (t.locale = a);
168
+ const h = k(this.getAttribute("toolbar"));
169
+ h !== void 0 && (t.toolbar = h);
170
+ const u = this.getAttribute("html-styles");
171
+ (u === "class" || u === "inline") && (t.htmlStyles = u), this.hasAttribute("read-only") && (t.readOnly = !0), this.getAttribute("status-bar") === "false" && (t.statusBar = !1);
172
+ const n = this.getAttribute("height");
173
+ n && (t.height = /^\d+$/.test(n) ? Number(n) : n);
174
+ const c = this.getAttribute("aria-label");
175
+ c && (t.ariaLabel = c);
176
+ const d = this.getAttribute("upload-url");
177
+ return this.uploadValue ? t.upload = this.uploadValue : d && (t.upload = { url: d }), this.fontsValue && (t.fonts = this.fontsValue), this.highlighterValue && (t.highlighter = this.highlighterValue), this.fontSizesValue && (t.fontSizes = this.fontSizesValue), t;
142
178
  }
143
179
  syncFormValue(t) {
144
- var i;
145
- this.currentHTML = t, (i = this.internals) == null || i.setFormValue(t);
180
+ var l;
181
+ this.currentHTML = t, (l = this.internals) == null || l.setFormValue(t);
146
182
  }
147
183
  }
148
184
  /** 폼 연동 대상임을 선언. 미지원 브라우저는 이 필드를 무시한다. */
149
- r(p, "formAssociated", !0);
150
- class V extends HTMLElement {
185
+ s(f, "formAssociated", !0);
186
+ class z extends HTMLElement {
151
187
  constructor() {
152
188
  super(...arguments);
153
- r(this, "controller", null);
154
- r(this, "pendingBlocks");
189
+ s(this, "controller", null);
190
+ s(this, "pendingBlocks");
155
191
  }
156
192
  static get observedAttributes() {
157
193
  return ["html", "theme"];
@@ -162,15 +198,15 @@ class V extends HTMLElement {
162
198
  return ((t = this.controller) == null ? void 0 : t.viewer.getBlocks()) ?? this.pendingBlocks ?? [];
163
199
  }
164
200
  set blocks(t) {
165
- var i;
166
- this.pendingBlocks = t, (i = this.controller) == null || i.update(this.buildProps());
201
+ var l;
202
+ this.pendingBlocks = t, (l = this.controller) == null || l.update(this.buildProps());
167
203
  }
168
204
  get viewer() {
169
205
  var t;
170
206
  return ((t = this.controller) == null ? void 0 : t.viewer) ?? null;
171
207
  }
172
208
  connectedCallback() {
173
- this.controller || (this.controller = b(this, this.buildProps()), this.dispatchEvent(
209
+ this.controller || (this.controller = V(this, this.buildProps()), this.dispatchEvent(
174
210
  new CustomEvent("aeriz-ready", {
175
211
  detail: { viewer: this.controller.viewer },
176
212
  bubbles: !1
@@ -188,20 +224,20 @@ class V extends HTMLElement {
188
224
  buildProps() {
189
225
  const t = {};
190
226
  this.pendingBlocks !== void 0 && (t.blocks = this.pendingBlocks);
191
- const i = this.getAttribute("html");
192
- i !== null && (t.html = i);
193
- const o = h(this.getAttribute("theme"));
194
- return o !== void 0 && (t.theme = o), t;
227
+ const l = this.getAttribute("html");
228
+ l !== null && (t.html = l);
229
+ const r = p(this.getAttribute("theme"));
230
+ return r !== void 0 && (t.theme = r), t;
195
231
  }
196
232
  }
197
- function C(e = "aeriz") {
233
+ function P(e = "aeriz") {
198
234
  if (typeof customElements > "u") return;
199
- const l = `${e}-editor`, t = `${e}-viewer`;
200
- customElements.get(l) || customElements.define(l, p), customElements.get(t) || customElements.define(t, V);
235
+ const i = `${e}-editor`, t = `${e}-viewer`;
236
+ customElements.get(i) || customElements.define(i, f), customElements.get(t) || customElements.define(t, z);
201
237
  }
202
- C();
238
+ P();
203
239
  export {
204
- p as AerizEditorElement,
205
- V as AerizViewerElement,
206
- C as defineAerizElements
240
+ f as AerizEditorElement,
241
+ z as AerizViewerElement,
242
+ P as defineAerizElements
207
243
  };
@@ -1,28 +1,23 @@
1
1
  var AerizWysiwygAdapter = 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 AerizWysiwygAdapter = 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 AerizWysiwygAdapter = 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 AerizWysiwygAdapter = 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 AerizWysiwygAdapter = 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 AerizWysiwygAdapter = 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() {
@@ -163,7 +156,6 @@ var AerizWysiwygAdapter = function(exports, wysiwyg) {
163
156
  }
164
157
  exports.createEditorController = createEditorController;
165
158
  exports.createViewerController = createViewerController;
166
- exports.htmlToBlocks = htmlToBlocks;
167
159
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
168
160
  return exports;
169
161
  }({}, AerizWysiwyg);
@@ -1 +1 @@
1
- var AerizWysiwygAdapter=function(m,s){"use strict";function v(a){const e=document.createElement("div");e.innerHTML=a,s.normalizeContent(e,{writableTail:!1});const t=new s.BlockIdRegistry;return s.assignMissingIds(e,t),s.serializeBlocks(s.listBlocks(e,o=>t.ensure(o)))}function k(a,e,t){const o={element:a,onChange:t},n=e.value??e.initialHTML;return n!==void 0&&(o.initialHTML=n),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 T(a,e){return a===e?!0:a===!1||e===!1||a===void 0||e===void 0||a.sticky!==e.sticky||a.items.length!==e.items.length?!1:a.items.every((t,o)=>t===e.items[o])}function M(a,e){let t=e,o="",n=!1,d=!1;const h=l=>{var c;o=l,!n&&((c=t.onChange)==null||c.call(t,l))};let i,f=null,r;const H=l=>{l.onImageUpload===void 0?delete r.onImageUpload:r.onImageUpload=l.onImageUpload,l.imageUploadUrl===void 0?delete r.imageUploadUrl:r.imageUploadUrl=l.imageUploadUrl,l.onFileUpload===void 0?delete r.onFileUpload:r.onFileUpload=l.onFileUpload,l.fileUploadUrl===void 0?delete r.fileUploadUrl:r.fileUploadUrl=l.fileUploadUrl,l.htmlStyles===void 0?delete r.htmlStyles:r.htmlStyles=l.htmlStyles},U=(l,c)=>{var y;const u=c!==void 0?{...l,value:c}:l;r=k(a,u,h),i=new s.AerizEditor(r),o=i.getHTML(),f=i.onStateChange(I=>{var S;return(S=t.onStateChange)==null?void 0:S.call(t,I)}),(y=t.onReady)==null||y.call(t,i)},g=()=>{var l;(l=t.onDestroy)==null||l.call(t,i),f==null||f(),f=null,i.destroy()};return U(t),{get editor(){return i},update(l){if(d)return;const c=t;if(t=l,l.locale!==c.locale||!T(l.toolbar,c.toolbar)){const u=l.value??i.getHTML();g(),U(l,u);return}if(H(l),l.theme!==c.theme&&l.theme!==void 0&&i.setTheme(l.theme),l.placeholder!==c.placeholder&&(l.placeholder===void 0?delete i.content.dataset.placeholder:i.content.dataset.placeholder=l.placeholder),l.value!==void 0&&l.value!==o&&l.value!==i.getHTML()){n=!0;try{i.setHTML(l.value)}finally{n=!1}o=l.value}},destroy(){d||(d=!0,g())}}}function L(a,e){const t={element:a},o=e.blocks??(e.html!==void 0?v(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 C(a,e){var h;let t=e,o=!1;const n=L(a,e),d=new s.AerizViewer(n);return(h=t.onReady)==null||h.call(t,d),{viewer:d,update(i){if(o)return;const f=t;t=i,i.theme!==f.theme&&i.theme!==void 0&&d.setTheme(i.theme),i.htmlStyles===void 0?delete n.htmlStyles:n.htmlStyles=i.htmlStyles,i.blocks!==void 0?i.blocks!==f.blocks&&d.setBlocks(i.blocks):i.html!==void 0&&i.html!==f.html&&i.html!==d.getHTML()&&d.setBlocks(v(i.html))},destroy(){var i;o||(o=!0,(i=t.onDestroy)==null||i.call(t,d),d.destroy())}}}return m.createEditorController=M,m.createViewerController=C,m.htmlToBlocks=v,Object.defineProperty(m,Symbol.toStringTag,{value:"Module"}),m}({},AerizWysiwyg);
1
+ var AerizWysiwygAdapter=function(u,y){"use strict";const S=new Set(["value","onChange","onStateChange","onReady","onDestroy"]);function T(o,i,e){const n={element:o,onChange:e};for(const[r,c]of Object.entries(i))c===void 0||S.has(r)||(n[r]=c);const d=i.value??i.initialHTML;return d!==void 0&&(n.initialHTML=d),n}const L=["upload","htmlStyles","onError"],k=["locale","statusBar","height","ariaLabel","fonts","fontSizes","highlighter"];function C(o,i){return o===i?!0:typeof o!="object"||typeof i!="object"||!o||!i?!1:JSON.stringify(o)===JSON.stringify(i)}function M(o,i){return o===i?!0:o===!1||i===!1||o===void 0||i===void 0||o.sticky!==i.sticky||o.items.length!==i.items.length?!1:o.items.every((e,n)=>e===i.items[n])}function H(o,i){let e=i,n="",d=!1,r=!1;const c=l=>{var a;n=l,!d&&((a=e.onChange)==null||a.call(e,l))};let t,f=null,h;const R=l=>{const a=h;for(const s of L)l[s]===void 0?delete a[s]:a[s]=l[s]},v=(l,a)=>{var g;const s=a!==void 0?{...l,value:a}:l;h=T(o,s,c),t=new y.AerizEditor(h),n=t.getHTML(),f=t.onStateChange(B=>{var O;return(O=e.onStateChange)==null?void 0:O.call(e,B)}),(g=e.onReady)==null||g.call(e,t)},m=()=>{var l;(l=e.onDestroy)==null||l.call(e,t),f==null||f(),f=null,t.destroy()};return v(e),{get editor(){return t},update(l){if(r)return;const a=e;if(e=l,!M(l.toolbar,a.toolbar)||k.some(s=>!C(l[s],a[s]))){const s=l.value??t.getHTML();m(),v(l,s);return}if(R(l),l.theme!==a.theme&&l.theme!==void 0&&t.setTheme(l.theme),!!l.readOnly!=!!a.readOnly&&t.setReadOnly(!!l.readOnly),l.placeholder!==a.placeholder&&(l.placeholder===void 0?delete t.content.dataset.placeholder:t.content.dataset.placeholder=l.placeholder),l.value!==void 0&&l.value!==n&&l.value!==t.getHTML()){d=!0;try{t.setHTML(l.value)}finally{d=!1}n=l.value}},destroy(){r||(r=!0,m())}}}function w(o,i){const e={element:o};return i.blocks!==void 0?e.initialBlocks=i.blocks:i.html!==void 0&&(e.initialHTML=i.html),i.theme!==void 0&&(e.theme=i.theme),i.htmlStyles!==void 0&&(e.htmlStyles=i.htmlStyles),e}function E(o,i){var c;let e=i,n=!1;const d=w(o,i),r=new y.AerizViewer(d);return(c=e.onReady)==null||c.call(e,r),{viewer:r,update(t){if(n)return;const f=e;e=t,t.theme!==f.theme&&t.theme!==void 0&&r.setTheme(t.theme),t.htmlStyles===void 0?delete d.htmlStyles:d.htmlStyles=t.htmlStyles,t.blocks!==void 0?t.blocks!==f.blocks&&r.setBlocks(t.blocks):t.html!==void 0&&t.html!==f.html&&t.html!==r.getHTML()&&r.setHTML(t.html)},destroy(){var t;n||(n=!0,(t=e.onDestroy)==null||t.call(e,r),r.destroy())}}}return u.createEditorController=H,u.createViewerController=E,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"}),u}({},AerizWysiwyg);