@aeriz/wysiwyg 1.0.2 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +610 -96
- package/angular/README.md +112 -0
- package/angular/aeriz-editor.directive.ts +243 -0
- package/angular/aeriz-wysiwyg.module.ts +14 -0
- package/angular/index.ts +5 -0
- package/dist/adapters/jquery.cjs +1 -0
- package/dist/adapters/jquery.js +91 -0
- package/dist/adapters/react.cjs +1 -0
- package/dist/adapters/react.js +66 -0
- package/dist/adapters/shared.cjs +1 -0
- package/dist/adapters/shared.js +87 -0
- package/dist/adapters/svelte.cjs +1 -0
- package/dist/adapters/svelte.js +29 -0
- package/dist/adapters/vue.cjs +1 -0
- package/dist/adapters/vue.js +110 -0
- package/dist/adapters/vue2.cjs +1 -0
- package/dist/adapters/vue2.js +117 -0
- package/dist/adapters/wc.cjs +1 -0
- package/dist/adapters/wc.js +207 -0
- package/dist/aeriz-wysiwyg-adapter.js +169 -0
- package/dist/aeriz-wysiwyg-adapter.min.js +1 -0
- package/dist/aeriz-wysiwyg-jquery.js +275 -0
- package/dist/aeriz-wysiwyg-jquery.min.js +1 -0
- package/dist/aeriz-wysiwyg-wc.js +401 -0
- package/dist/aeriz-wysiwyg-wc.min.js +1 -0
- package/dist/aeriz-wysiwyg.cjs +6912 -0
- package/dist/aeriz-wysiwyg.css +37 -129
- package/dist/aeriz-wysiwyg.esm.js +1170 -149
- package/dist/aeriz-wysiwyg.esm.min.js +2057 -1209
- package/dist/aeriz-wysiwyg.js +1169 -148
- package/dist/aeriz-wysiwyg.min.cjs +54 -0
- package/dist/aeriz-wysiwyg.min.css +1 -1
- package/dist/aeriz-wysiwyg.min.js +44 -13
- package/dist/server.cjs +32 -0
- package/dist/server.js +666 -0
- package/dist-types/adapters/jquery.d.ts +34 -0
- package/dist-types/adapters/jquery.d.ts.map +1 -0
- package/dist-types/adapters/react.d.ts +28 -0
- package/dist-types/adapters/react.d.ts.map +1 -0
- package/dist-types/adapters/shared.d.ts +83 -0
- package/dist-types/adapters/shared.d.ts.map +1 -0
- package/dist-types/adapters/svelte.d.ts +38 -0
- package/dist-types/adapters/svelte.d.ts.map +1 -0
- package/dist-types/adapters/vue.d.ts +189 -0
- package/dist-types/adapters/vue.d.ts.map +1 -0
- package/dist-types/adapters/vue2.d.ts +175 -0
- package/dist-types/adapters/vue2.d.ts.map +1 -0
- package/dist-types/adapters/wc.d.ts +96 -0
- package/dist-types/adapters/wc.d.ts.map +1 -0
- package/dist-types/cjs/adapters/jquery.d.cts +34 -0
- package/dist-types/cjs/adapters/react.d.cts +28 -0
- package/dist-types/cjs/adapters/shared.d.cts +83 -0
- package/dist-types/cjs/adapters/svelte.d.cts +38 -0
- package/dist-types/cjs/adapters/vue.d.cts +189 -0
- package/dist-types/cjs/adapters/vue2.d.cts +175 -0
- package/dist-types/cjs/adapters/wc.d.cts +96 -0
- package/dist-types/cjs/core/AerizEditor.d.cts +357 -0
- package/dist-types/cjs/core/AerizViewer.d.cts +61 -0
- package/dist-types/cjs/core/block-meta.d.cts +32 -0
- package/dist-types/cjs/core/blocks.d.cts +368 -0
- package/dist-types/cjs/core/fonts.d.cts +60 -0
- package/dist-types/cjs/core/highlight.d.cts +44 -0
- package/dist-types/cjs/core/html-mini.d.cts +65 -0
- package/dist-types/cjs/core/i18n.d.cts +209 -0
- package/dist-types/cjs/core/import-html.d.cts +39 -0
- package/dist-types/cjs/core/import-markdown.d.cts +37 -0
- package/dist-types/cjs/core/markdown-export.d.cts +30 -0
- package/dist-types/cjs/core/plain-text.d.cts +17 -0
- package/dist-types/cjs/core/render-string.d.cts +68 -0
- package/dist-types/cjs/core/snapshot.d.cts +51 -0
- package/dist-types/cjs/index.d.cts +20 -0
- package/dist-types/cjs/server/index.d.cts +37 -0
- package/dist-types/cjs/types/index.d.cts +61 -0
- package/dist-types/cjs/ui/Toolbar.d.cts +21 -0
- package/dist-types/cjs/ui/dialogs.d.cts +74 -0
- package/dist-types/cjs/ui/icons.d.cts +2 -0
- package/dist-types/cjs/ui/popovers.d.cts +70 -0
- package/dist-types/core/AerizEditor.d.ts +30 -10
- package/dist-types/core/AerizEditor.d.ts.map +1 -1
- package/dist-types/core/AerizViewer.d.ts +16 -4
- package/dist-types/core/AerizViewer.d.ts.map +1 -1
- package/dist-types/core/block-meta.d.ts +32 -0
- package/dist-types/core/block-meta.d.ts.map +1 -0
- package/dist-types/core/blocks.d.ts +62 -7
- package/dist-types/core/blocks.d.ts.map +1 -1
- package/dist-types/core/fonts.d.ts +11 -0
- package/dist-types/core/fonts.d.ts.map +1 -1
- package/dist-types/core/html-mini.d.ts +65 -0
- package/dist-types/core/html-mini.d.ts.map +1 -0
- package/dist-types/core/import-html.d.ts.map +1 -1
- package/dist-types/core/markdown-export.d.ts +30 -0
- package/dist-types/core/markdown-export.d.ts.map +1 -0
- package/dist-types/core/plain-text.d.ts +17 -0
- package/dist-types/core/plain-text.d.ts.map +1 -0
- package/dist-types/core/render-string.d.ts +68 -0
- package/dist-types/core/render-string.d.ts.map +1 -0
- package/dist-types/core/snapshot.d.ts +51 -0
- package/dist-types/core/snapshot.d.ts.map +1 -0
- package/dist-types/index.d.ts +19 -10
- package/dist-types/index.d.ts.map +1 -1
- package/dist-types/server/index.d.ts +37 -0
- package/dist-types/server/index.d.ts.map +1 -0
- package/dist-types/types/index.d.ts +21 -0
- package/dist-types/types/index.d.ts.map +1 -1
- package/dist-types/ui/Toolbar.d.ts +1 -1
- package/dist-types/ui/popovers.d.ts +1 -1
- package/dist-types/ui/popovers.d.ts.map +1 -1
- package/package.json +213 -58
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
var AerizWysiwygJQuery = function(exports, wysiwyg) {
|
|
2
|
+
"use strict";
|
|
3
|
+
function htmlToBlocks(html) {
|
|
4
|
+
const scratch = document.createElement("div");
|
|
5
|
+
scratch.innerHTML = html;
|
|
6
|
+
wysiwyg.normalizeContent(scratch);
|
|
7
|
+
const ids = new wysiwyg.BlockIdRegistry();
|
|
8
|
+
wysiwyg.assignMissingIds(scratch, ids);
|
|
9
|
+
return wysiwyg.serializeBlocks(wysiwyg.listBlocks(scratch, (el) => ids.ensure(el)));
|
|
10
|
+
}
|
|
11
|
+
function toEditorOptions(element, props, onChange) {
|
|
12
|
+
const options = { element, onChange };
|
|
13
|
+
const initial = props.value ?? props.initialHTML;
|
|
14
|
+
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
|
+
return options;
|
|
25
|
+
}
|
|
26
|
+
function sameToolbar(a, b) {
|
|
27
|
+
if (a === b) return true;
|
|
28
|
+
if (a === false || b === false || a === void 0 || b === void 0) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
if (a.sticky !== b.sticky) return false;
|
|
32
|
+
if (a.items.length !== b.items.length) return false;
|
|
33
|
+
return a.items.every((item, i) => item === b.items[i]);
|
|
34
|
+
}
|
|
35
|
+
function createEditorController(host, initialProps) {
|
|
36
|
+
let props = initialProps;
|
|
37
|
+
let lastHTML = "";
|
|
38
|
+
let silent = false;
|
|
39
|
+
let disposed = false;
|
|
40
|
+
const emitChange = (html) => {
|
|
41
|
+
var _a;
|
|
42
|
+
lastHTML = html;
|
|
43
|
+
if (silent) return;
|
|
44
|
+
(_a = props.onChange) == null ? void 0 : _a.call(props, html);
|
|
45
|
+
};
|
|
46
|
+
let editor;
|
|
47
|
+
let unsubscribe = null;
|
|
48
|
+
let liveOptions;
|
|
49
|
+
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;
|
|
60
|
+
};
|
|
61
|
+
const create = (from, html) => {
|
|
62
|
+
var _a;
|
|
63
|
+
const seed = html !== void 0 ? { ...from, value: html } : from;
|
|
64
|
+
liveOptions = toEditorOptions(host, seed, emitChange);
|
|
65
|
+
editor = new wysiwyg.AerizEditor(liveOptions);
|
|
66
|
+
lastHTML = editor.getHTML();
|
|
67
|
+
unsubscribe = editor.onStateChange((state) => {
|
|
68
|
+
var _a2;
|
|
69
|
+
return (_a2 = props.onStateChange) == null ? void 0 : _a2.call(props, state);
|
|
70
|
+
});
|
|
71
|
+
(_a = props.onReady) == null ? void 0 : _a.call(props, editor);
|
|
72
|
+
};
|
|
73
|
+
const teardown = () => {
|
|
74
|
+
var _a;
|
|
75
|
+
(_a = props.onDestroy) == null ? void 0 : _a.call(props, editor);
|
|
76
|
+
unsubscribe == null ? void 0 : unsubscribe();
|
|
77
|
+
unsubscribe = null;
|
|
78
|
+
editor.destroy();
|
|
79
|
+
};
|
|
80
|
+
create(props);
|
|
81
|
+
return {
|
|
82
|
+
get editor() {
|
|
83
|
+
return editor;
|
|
84
|
+
},
|
|
85
|
+
update(next) {
|
|
86
|
+
if (disposed) return;
|
|
87
|
+
const prev = props;
|
|
88
|
+
props = next;
|
|
89
|
+
if (next.locale !== prev.locale || !sameToolbar(next.toolbar, prev.toolbar)) {
|
|
90
|
+
const carried = next.value ?? editor.getHTML();
|
|
91
|
+
teardown();
|
|
92
|
+
create(next, carried);
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
syncLazyOptions(next);
|
|
96
|
+
if (next.theme !== prev.theme && next.theme !== void 0) {
|
|
97
|
+
editor.setTheme(next.theme);
|
|
98
|
+
}
|
|
99
|
+
if (next.placeholder !== prev.placeholder) {
|
|
100
|
+
if (next.placeholder === void 0) {
|
|
101
|
+
delete editor.content.dataset.placeholder;
|
|
102
|
+
} else {
|
|
103
|
+
editor.content.dataset.placeholder = next.placeholder;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
if (next.value !== void 0 && next.value !== lastHTML && next.value !== editor.getHTML()) {
|
|
107
|
+
silent = true;
|
|
108
|
+
try {
|
|
109
|
+
editor.setHTML(next.value);
|
|
110
|
+
} finally {
|
|
111
|
+
silent = false;
|
|
112
|
+
}
|
|
113
|
+
lastHTML = next.value;
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
destroy() {
|
|
117
|
+
if (disposed) return;
|
|
118
|
+
disposed = true;
|
|
119
|
+
teardown();
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
function toViewerOptions(element, props) {
|
|
124
|
+
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;
|
|
127
|
+
if (props.theme !== void 0) options.theme = props.theme;
|
|
128
|
+
if (props.htmlStyles !== void 0) options.htmlStyles = props.htmlStyles;
|
|
129
|
+
return options;
|
|
130
|
+
}
|
|
131
|
+
function createViewerController(host, initialProps) {
|
|
132
|
+
var _a;
|
|
133
|
+
let props = initialProps;
|
|
134
|
+
let disposed = false;
|
|
135
|
+
const liveOptions = toViewerOptions(host, initialProps);
|
|
136
|
+
const viewer = new wysiwyg.AerizViewer(liveOptions);
|
|
137
|
+
(_a = props.onReady) == null ? void 0 : _a.call(props, viewer);
|
|
138
|
+
return {
|
|
139
|
+
viewer,
|
|
140
|
+
update(next) {
|
|
141
|
+
if (disposed) return;
|
|
142
|
+
const prev = props;
|
|
143
|
+
props = next;
|
|
144
|
+
if (next.theme !== prev.theme && next.theme !== void 0) {
|
|
145
|
+
viewer.setTheme(next.theme);
|
|
146
|
+
}
|
|
147
|
+
if (next.htmlStyles === void 0) delete liveOptions.htmlStyles;
|
|
148
|
+
else liveOptions.htmlStyles = next.htmlStyles;
|
|
149
|
+
if (next.blocks !== void 0) {
|
|
150
|
+
if (next.blocks !== prev.blocks) viewer.setBlocks(next.blocks);
|
|
151
|
+
} else if (next.html !== void 0 && next.html !== prev.html) {
|
|
152
|
+
if (next.html !== viewer.getHTML()) viewer.setBlocks(htmlToBlocks(next.html));
|
|
153
|
+
}
|
|
154
|
+
},
|
|
155
|
+
destroy() {
|
|
156
|
+
var _a2;
|
|
157
|
+
if (disposed) return;
|
|
158
|
+
disposed = true;
|
|
159
|
+
(_a2 = props.onDestroy) == null ? void 0 : _a2.call(props, viewer);
|
|
160
|
+
viewer.destroy();
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
const editors = /* @__PURE__ */ new WeakMap();
|
|
165
|
+
const viewers = /* @__PURE__ */ new WeakMap();
|
|
166
|
+
function editorCommand(collection, command, args) {
|
|
167
|
+
const first = collection[0];
|
|
168
|
+
const controller = first ? editors.get(first) : void 0;
|
|
169
|
+
switch (command) {
|
|
170
|
+
case "getHTML":
|
|
171
|
+
return (controller == null ? void 0 : controller.editor.getHTML()) ?? "";
|
|
172
|
+
case "getBlocks":
|
|
173
|
+
return (controller == null ? void 0 : controller.editor.serialize()) ?? [];
|
|
174
|
+
case "setHTML":
|
|
175
|
+
collection.each((_i, el) => {
|
|
176
|
+
var _a;
|
|
177
|
+
(_a = editors.get(el)) == null ? void 0 : _a.editor.setHTML(String(args[0] ?? ""));
|
|
178
|
+
});
|
|
179
|
+
return collection;
|
|
180
|
+
case "update":
|
|
181
|
+
collection.each((_i, el) => {
|
|
182
|
+
var _a;
|
|
183
|
+
(_a = editors.get(el)) == null ? void 0 : _a.update(args[0] ?? {});
|
|
184
|
+
});
|
|
185
|
+
return collection;
|
|
186
|
+
case "focus":
|
|
187
|
+
controller == null ? void 0 : controller.editor.focus();
|
|
188
|
+
return collection;
|
|
189
|
+
case "instance":
|
|
190
|
+
return (controller == null ? void 0 : controller.editor) ?? null;
|
|
191
|
+
case "destroy":
|
|
192
|
+
collection.each((_i, el) => {
|
|
193
|
+
const found = editors.get(el);
|
|
194
|
+
if (!found) return;
|
|
195
|
+
found.destroy();
|
|
196
|
+
editors.delete(el);
|
|
197
|
+
});
|
|
198
|
+
return collection;
|
|
199
|
+
default:
|
|
200
|
+
throw new Error(`aerizEditor: 알 수 없는 명령 "${command}"`);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
function viewerCommand(collection, command, args) {
|
|
204
|
+
const first = collection[0];
|
|
205
|
+
const controller = first ? viewers.get(first) : void 0;
|
|
206
|
+
switch (command) {
|
|
207
|
+
case "getHTML":
|
|
208
|
+
return (controller == null ? void 0 : controller.viewer.getHTML()) ?? "";
|
|
209
|
+
case "getBlocks":
|
|
210
|
+
return (controller == null ? void 0 : controller.viewer.getBlocks()) ?? [];
|
|
211
|
+
case "update":
|
|
212
|
+
collection.each((_i, el) => {
|
|
213
|
+
var _a;
|
|
214
|
+
(_a = viewers.get(el)) == null ? void 0 : _a.update(args[0] ?? {});
|
|
215
|
+
});
|
|
216
|
+
return collection;
|
|
217
|
+
case "instance":
|
|
218
|
+
return (controller == null ? void 0 : controller.viewer) ?? null;
|
|
219
|
+
case "destroy":
|
|
220
|
+
collection.each((_i, el) => {
|
|
221
|
+
const found = viewers.get(el);
|
|
222
|
+
if (!found) return;
|
|
223
|
+
found.destroy();
|
|
224
|
+
viewers.delete(el);
|
|
225
|
+
});
|
|
226
|
+
return collection;
|
|
227
|
+
default:
|
|
228
|
+
throw new Error(`aerizViewer: 알 수 없는 명령 "${command}"`);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
function editorPlugin(optionsOrCommand, ...args) {
|
|
232
|
+
if (typeof optionsOrCommand === "string") {
|
|
233
|
+
return editorCommand(this, optionsOrCommand, args);
|
|
234
|
+
}
|
|
235
|
+
const options = optionsOrCommand ?? {};
|
|
236
|
+
this.each((_i, el) => {
|
|
237
|
+
const existing = editors.get(el);
|
|
238
|
+
if (existing) {
|
|
239
|
+
existing.update(options);
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
editors.set(el, createEditorController(el, options));
|
|
243
|
+
});
|
|
244
|
+
return this;
|
|
245
|
+
}
|
|
246
|
+
function viewerPlugin(optionsOrCommand, ...args) {
|
|
247
|
+
if (typeof optionsOrCommand === "string") {
|
|
248
|
+
return viewerCommand(this, optionsOrCommand, args);
|
|
249
|
+
}
|
|
250
|
+
const options = optionsOrCommand ?? {};
|
|
251
|
+
this.each((_i, el) => {
|
|
252
|
+
const existing = viewers.get(el);
|
|
253
|
+
if (existing) {
|
|
254
|
+
existing.update(options);
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
viewers.set(el, createViewerController(el, options));
|
|
258
|
+
});
|
|
259
|
+
return this;
|
|
260
|
+
}
|
|
261
|
+
function registerAerizJQuery($) {
|
|
262
|
+
if (!$ || typeof $.fn !== "object") {
|
|
263
|
+
throw new TypeError("registerAerizJQuery: jQuery 객체가 필요합니다.");
|
|
264
|
+
}
|
|
265
|
+
if (!$.fn.aerizEditor) $.fn.aerizEditor = editorPlugin;
|
|
266
|
+
if (!$.fn.aerizViewer) $.fn.aerizViewer = viewerPlugin;
|
|
267
|
+
}
|
|
268
|
+
const globalJQuery = globalThis.jQuery;
|
|
269
|
+
if (globalJQuery) {
|
|
270
|
+
registerAerizJQuery(globalJQuery);
|
|
271
|
+
}
|
|
272
|
+
exports.registerAerizJQuery = registerAerizJQuery;
|
|
273
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
274
|
+
return exports;
|
|
275
|
+
}({}, AerizWysiwyg);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var AerizWysiwygJQuery=function(g,c){"use strict";function U(i){const e=document.createElement("div");e.innerHTML=i,c.normalizeContent(e);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);
|
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
var AerizWysiwygWC = function(exports, wysiwyg) {
|
|
2
|
+
"use strict";var __defProp = Object.defineProperty;
|
|
3
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
4
|
+
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
|
|
6
|
+
function htmlToBlocks(html) {
|
|
7
|
+
const scratch = document.createElement("div");
|
|
8
|
+
scratch.innerHTML = html;
|
|
9
|
+
wysiwyg.normalizeContent(scratch);
|
|
10
|
+
const ids = new wysiwyg.BlockIdRegistry();
|
|
11
|
+
wysiwyg.assignMissingIds(scratch, ids);
|
|
12
|
+
return wysiwyg.serializeBlocks(wysiwyg.listBlocks(scratch, (el) => ids.ensure(el)));
|
|
13
|
+
}
|
|
14
|
+
function toEditorOptions(element, props, onChange) {
|
|
15
|
+
const options = { element, onChange };
|
|
16
|
+
const initial = props.value ?? props.initialHTML;
|
|
17
|
+
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
|
+
return options;
|
|
28
|
+
}
|
|
29
|
+
function sameToolbar(a, b) {
|
|
30
|
+
if (a === b) return true;
|
|
31
|
+
if (a === false || b === false || a === void 0 || b === void 0) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
if (a.sticky !== b.sticky) return false;
|
|
35
|
+
if (a.items.length !== b.items.length) return false;
|
|
36
|
+
return a.items.every((item, i) => item === b.items[i]);
|
|
37
|
+
}
|
|
38
|
+
function createEditorController(host, initialProps) {
|
|
39
|
+
let props = initialProps;
|
|
40
|
+
let lastHTML = "";
|
|
41
|
+
let silent = false;
|
|
42
|
+
let disposed = false;
|
|
43
|
+
const emitChange = (html) => {
|
|
44
|
+
var _a;
|
|
45
|
+
lastHTML = html;
|
|
46
|
+
if (silent) return;
|
|
47
|
+
(_a = props.onChange) == null ? void 0 : _a.call(props, html);
|
|
48
|
+
};
|
|
49
|
+
let editor;
|
|
50
|
+
let unsubscribe = null;
|
|
51
|
+
let liveOptions;
|
|
52
|
+
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;
|
|
63
|
+
};
|
|
64
|
+
const create = (from, html) => {
|
|
65
|
+
var _a;
|
|
66
|
+
const seed = html !== void 0 ? { ...from, value: html } : from;
|
|
67
|
+
liveOptions = toEditorOptions(host, seed, emitChange);
|
|
68
|
+
editor = new wysiwyg.AerizEditor(liveOptions);
|
|
69
|
+
lastHTML = editor.getHTML();
|
|
70
|
+
unsubscribe = editor.onStateChange((state) => {
|
|
71
|
+
var _a2;
|
|
72
|
+
return (_a2 = props.onStateChange) == null ? void 0 : _a2.call(props, state);
|
|
73
|
+
});
|
|
74
|
+
(_a = props.onReady) == null ? void 0 : _a.call(props, editor);
|
|
75
|
+
};
|
|
76
|
+
const teardown = () => {
|
|
77
|
+
var _a;
|
|
78
|
+
(_a = props.onDestroy) == null ? void 0 : _a.call(props, editor);
|
|
79
|
+
unsubscribe == null ? void 0 : unsubscribe();
|
|
80
|
+
unsubscribe = null;
|
|
81
|
+
editor.destroy();
|
|
82
|
+
};
|
|
83
|
+
create(props);
|
|
84
|
+
return {
|
|
85
|
+
get editor() {
|
|
86
|
+
return editor;
|
|
87
|
+
},
|
|
88
|
+
update(next) {
|
|
89
|
+
if (disposed) return;
|
|
90
|
+
const prev = props;
|
|
91
|
+
props = next;
|
|
92
|
+
if (next.locale !== prev.locale || !sameToolbar(next.toolbar, prev.toolbar)) {
|
|
93
|
+
const carried = next.value ?? editor.getHTML();
|
|
94
|
+
teardown();
|
|
95
|
+
create(next, carried);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
syncLazyOptions(next);
|
|
99
|
+
if (next.theme !== prev.theme && next.theme !== void 0) {
|
|
100
|
+
editor.setTheme(next.theme);
|
|
101
|
+
}
|
|
102
|
+
if (next.placeholder !== prev.placeholder) {
|
|
103
|
+
if (next.placeholder === void 0) {
|
|
104
|
+
delete editor.content.dataset.placeholder;
|
|
105
|
+
} else {
|
|
106
|
+
editor.content.dataset.placeholder = next.placeholder;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
if (next.value !== void 0 && next.value !== lastHTML && next.value !== editor.getHTML()) {
|
|
110
|
+
silent = true;
|
|
111
|
+
try {
|
|
112
|
+
editor.setHTML(next.value);
|
|
113
|
+
} finally {
|
|
114
|
+
silent = false;
|
|
115
|
+
}
|
|
116
|
+
lastHTML = next.value;
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
destroy() {
|
|
120
|
+
if (disposed) return;
|
|
121
|
+
disposed = true;
|
|
122
|
+
teardown();
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
function toViewerOptions(element, props) {
|
|
127
|
+
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;
|
|
130
|
+
if (props.theme !== void 0) options.theme = props.theme;
|
|
131
|
+
if (props.htmlStyles !== void 0) options.htmlStyles = props.htmlStyles;
|
|
132
|
+
return options;
|
|
133
|
+
}
|
|
134
|
+
function createViewerController(host, initialProps) {
|
|
135
|
+
var _a;
|
|
136
|
+
let props = initialProps;
|
|
137
|
+
let disposed = false;
|
|
138
|
+
const liveOptions = toViewerOptions(host, initialProps);
|
|
139
|
+
const viewer = new wysiwyg.AerizViewer(liveOptions);
|
|
140
|
+
(_a = props.onReady) == null ? void 0 : _a.call(props, viewer);
|
|
141
|
+
return {
|
|
142
|
+
viewer,
|
|
143
|
+
update(next) {
|
|
144
|
+
if (disposed) return;
|
|
145
|
+
const prev = props;
|
|
146
|
+
props = next;
|
|
147
|
+
if (next.theme !== prev.theme && next.theme !== void 0) {
|
|
148
|
+
viewer.setTheme(next.theme);
|
|
149
|
+
}
|
|
150
|
+
if (next.htmlStyles === void 0) delete liveOptions.htmlStyles;
|
|
151
|
+
else liveOptions.htmlStyles = next.htmlStyles;
|
|
152
|
+
if (next.blocks !== void 0) {
|
|
153
|
+
if (next.blocks !== prev.blocks) viewer.setBlocks(next.blocks);
|
|
154
|
+
} else if (next.html !== void 0 && next.html !== prev.html) {
|
|
155
|
+
if (next.html !== viewer.getHTML()) viewer.setBlocks(htmlToBlocks(next.html));
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
destroy() {
|
|
159
|
+
var _a2;
|
|
160
|
+
if (disposed) return;
|
|
161
|
+
disposed = true;
|
|
162
|
+
(_a2 = props.onDestroy) == null ? void 0 : _a2.call(props, viewer);
|
|
163
|
+
viewer.destroy();
|
|
164
|
+
}
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
const THEMES = ["light", "dark"];
|
|
168
|
+
const LOCALES = ["en", "ko", "ja", "zh"];
|
|
169
|
+
function parseTheme(raw) {
|
|
170
|
+
return raw !== null && THEMES.includes(raw) ? raw : void 0;
|
|
171
|
+
}
|
|
172
|
+
function parseLocale(raw) {
|
|
173
|
+
return raw !== null && LOCALES.includes(raw) ? raw : void 0;
|
|
174
|
+
}
|
|
175
|
+
function parseToolbar(raw) {
|
|
176
|
+
if (raw === null) return void 0;
|
|
177
|
+
const trimmed = raw.trim();
|
|
178
|
+
if (trimmed === "") return void 0;
|
|
179
|
+
if (trimmed === "false" || trimmed === "none") return false;
|
|
180
|
+
if (trimmed.startsWith("{")) {
|
|
181
|
+
try {
|
|
182
|
+
const parsed = JSON.parse(trimmed);
|
|
183
|
+
if (parsed && typeof parsed === "object" && Array.isArray(parsed.items)) {
|
|
184
|
+
return parsed;
|
|
185
|
+
}
|
|
186
|
+
} catch {
|
|
187
|
+
}
|
|
188
|
+
return void 0;
|
|
189
|
+
}
|
|
190
|
+
const items = trimmed.split(/[\s,]+/).filter((t) => t.length > 0);
|
|
191
|
+
return items.length > 0 ? { items } : void 0;
|
|
192
|
+
}
|
|
193
|
+
function attachFormInternals(host) {
|
|
194
|
+
const attach = host.attachInternals;
|
|
195
|
+
if (typeof attach !== "function") return null;
|
|
196
|
+
try {
|
|
197
|
+
const internals = attach.call(host);
|
|
198
|
+
const usable = typeof internals === "object" && internals !== null && typeof internals.setFormValue === "function";
|
|
199
|
+
return usable ? internals : null;
|
|
200
|
+
} catch {
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
class AerizEditorElement extends HTMLElement {
|
|
205
|
+
constructor() {
|
|
206
|
+
super();
|
|
207
|
+
/** 프로퍼티로 설정된 업로드 핸들러. 속성으로는 표현할 수 없다. */
|
|
208
|
+
__publicField(this, "onImageUpload");
|
|
209
|
+
__publicField(this, "onFileUpload");
|
|
210
|
+
__publicField(this, "controller", null);
|
|
211
|
+
__publicField(this, "internals", null);
|
|
212
|
+
/**
|
|
213
|
+
* 아직 에디터에 반영되지 않은 **외부에서 지정한** 값.
|
|
214
|
+
*
|
|
215
|
+
* 반영이 끝나면 즉시 비운다. 이 값이 남아 있으면 관계없는 속성(`theme` 등) 이
|
|
216
|
+
* 바뀔 때마다 낡은 값이 `setHTML()` 로 다시 밀려들어가, 모든 블록 id 가
|
|
217
|
+
* 재발급되고 입력 중이던 캐럿이 문서 맨 앞으로 튄다.
|
|
218
|
+
*/
|
|
219
|
+
__publicField(this, "pendingValue");
|
|
220
|
+
/** 에디터가 마지막으로 보고한 본문. 폼 값과 마운트 해제 후 `value` 의 근거. */
|
|
221
|
+
__publicField(this, "currentHTML", "");
|
|
222
|
+
this.internals = attachFormInternals(this);
|
|
223
|
+
}
|
|
224
|
+
static get observedAttributes() {
|
|
225
|
+
return [
|
|
226
|
+
"value",
|
|
227
|
+
"placeholder",
|
|
228
|
+
"theme",
|
|
229
|
+
"locale",
|
|
230
|
+
"toolbar",
|
|
231
|
+
"html-styles",
|
|
232
|
+
"image-upload-url",
|
|
233
|
+
"file-upload-url"
|
|
234
|
+
];
|
|
235
|
+
}
|
|
236
|
+
/** 현재 본문 HTML. 설정하면 본문을 교체한다. */
|
|
237
|
+
get value() {
|
|
238
|
+
if (this.controller) return this.controller.editor.getHTML();
|
|
239
|
+
return this.pendingValue ?? this.currentHTML;
|
|
240
|
+
}
|
|
241
|
+
set value(next) {
|
|
242
|
+
this.pendingValue = next;
|
|
243
|
+
this.applyProps();
|
|
244
|
+
}
|
|
245
|
+
/** 코어 인스턴스. 마운트 전에는 `null`. */
|
|
246
|
+
get editor() {
|
|
247
|
+
var _a;
|
|
248
|
+
return ((_a = this.controller) == null ? void 0 : _a.editor) ?? null;
|
|
249
|
+
}
|
|
250
|
+
/** 블록 상태 스냅샷. */
|
|
251
|
+
getBlocks() {
|
|
252
|
+
var _a;
|
|
253
|
+
return ((_a = this.controller) == null ? void 0 : _a.editor.serialize()) ?? [];
|
|
254
|
+
}
|
|
255
|
+
/** 본문에 캐럿을 둔다. `HTMLElement.focus()` 를 본문 쪽으로 위임한다. */
|
|
256
|
+
focus() {
|
|
257
|
+
var _a;
|
|
258
|
+
(_a = this.controller) == null ? void 0 : _a.editor.focus();
|
|
259
|
+
}
|
|
260
|
+
connectedCallback() {
|
|
261
|
+
if (this.controller) return;
|
|
262
|
+
if (this.pendingValue === void 0) {
|
|
263
|
+
const attr = this.getAttribute("value");
|
|
264
|
+
if (attr !== null) this.pendingValue = attr;
|
|
265
|
+
}
|
|
266
|
+
this.controller = createEditorController(this, this.buildProps());
|
|
267
|
+
this.pendingValue = void 0;
|
|
268
|
+
this.syncFormValue(this.controller.editor.getHTML());
|
|
269
|
+
this.dispatchEvent(
|
|
270
|
+
new CustomEvent("aeriz-ready", {
|
|
271
|
+
detail: { editor: this.controller.editor },
|
|
272
|
+
bubbles: false
|
|
273
|
+
})
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
disconnectedCallback() {
|
|
277
|
+
var _a;
|
|
278
|
+
(_a = this.controller) == null ? void 0 : _a.destroy();
|
|
279
|
+
this.controller = null;
|
|
280
|
+
}
|
|
281
|
+
attributeChangedCallback(name, _previous, next) {
|
|
282
|
+
if (name === "value") this.pendingValue = next ?? "";
|
|
283
|
+
this.applyProps();
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* 현재 속성·프로퍼티 상태를 컨트롤러에 반영한다.
|
|
287
|
+
* 반영 직후 pendingValue 를 비워, 다음 갱신에서 같은 값이 되살아나지 않게 한다.
|
|
288
|
+
*/
|
|
289
|
+
applyProps() {
|
|
290
|
+
if (!this.controller) return;
|
|
291
|
+
this.controller.update(this.buildProps());
|
|
292
|
+
this.pendingValue = void 0;
|
|
293
|
+
}
|
|
294
|
+
buildProps() {
|
|
295
|
+
const props = {
|
|
296
|
+
onChange: (html) => {
|
|
297
|
+
this.pendingValue = void 0;
|
|
298
|
+
this.syncFormValue(html);
|
|
299
|
+
this.dispatchEvent(new CustomEvent("input", { detail: { html }, bubbles: true }));
|
|
300
|
+
this.dispatchEvent(new CustomEvent("change", { detail: { html }, bubbles: true }));
|
|
301
|
+
}
|
|
302
|
+
};
|
|
303
|
+
if (this.pendingValue !== void 0) props.value = this.pendingValue;
|
|
304
|
+
const placeholder = this.getAttribute("placeholder");
|
|
305
|
+
if (placeholder !== null) props.placeholder = placeholder;
|
|
306
|
+
const theme = parseTheme(this.getAttribute("theme"));
|
|
307
|
+
if (theme !== void 0) props.theme = theme;
|
|
308
|
+
const locale = parseLocale(this.getAttribute("locale"));
|
|
309
|
+
if (locale !== void 0) props.locale = locale;
|
|
310
|
+
const toolbar = parseToolbar(this.getAttribute("toolbar"));
|
|
311
|
+
if (toolbar !== void 0) props.toolbar = toolbar;
|
|
312
|
+
const htmlStyles = this.getAttribute("html-styles");
|
|
313
|
+
if (htmlStyles === "class" || htmlStyles === "inline") {
|
|
314
|
+
props.htmlStyles = htmlStyles;
|
|
315
|
+
}
|
|
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;
|
|
322
|
+
return props;
|
|
323
|
+
}
|
|
324
|
+
syncFormValue(html) {
|
|
325
|
+
var _a;
|
|
326
|
+
this.currentHTML = html;
|
|
327
|
+
(_a = this.internals) == null ? void 0 : _a.setFormValue(html);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
/** 폼 연동 대상임을 선언. 미지원 브라우저는 이 필드를 무시한다. */
|
|
331
|
+
__publicField(AerizEditorElement, "formAssociated", true);
|
|
332
|
+
class AerizViewerElement extends HTMLElement {
|
|
333
|
+
constructor() {
|
|
334
|
+
super(...arguments);
|
|
335
|
+
__publicField(this, "controller", null);
|
|
336
|
+
__publicField(this, "pendingBlocks");
|
|
337
|
+
}
|
|
338
|
+
static get observedAttributes() {
|
|
339
|
+
return ["html", "theme"];
|
|
340
|
+
}
|
|
341
|
+
/** 블록 상태를 직접 넣는다. `html` 속성보다 우선한다. */
|
|
342
|
+
get blocks() {
|
|
343
|
+
var _a;
|
|
344
|
+
return ((_a = this.controller) == null ? void 0 : _a.viewer.getBlocks()) ?? this.pendingBlocks ?? [];
|
|
345
|
+
}
|
|
346
|
+
set blocks(next) {
|
|
347
|
+
var _a;
|
|
348
|
+
this.pendingBlocks = next;
|
|
349
|
+
(_a = this.controller) == null ? void 0 : _a.update(this.buildProps());
|
|
350
|
+
}
|
|
351
|
+
get viewer() {
|
|
352
|
+
var _a;
|
|
353
|
+
return ((_a = this.controller) == null ? void 0 : _a.viewer) ?? null;
|
|
354
|
+
}
|
|
355
|
+
connectedCallback() {
|
|
356
|
+
if (this.controller) return;
|
|
357
|
+
this.controller = createViewerController(this, this.buildProps());
|
|
358
|
+
this.dispatchEvent(
|
|
359
|
+
new CustomEvent("aeriz-ready", {
|
|
360
|
+
detail: { viewer: this.controller.viewer },
|
|
361
|
+
bubbles: false
|
|
362
|
+
})
|
|
363
|
+
);
|
|
364
|
+
}
|
|
365
|
+
disconnectedCallback() {
|
|
366
|
+
var _a;
|
|
367
|
+
(_a = this.controller) == null ? void 0 : _a.destroy();
|
|
368
|
+
this.controller = null;
|
|
369
|
+
}
|
|
370
|
+
attributeChangedCallback() {
|
|
371
|
+
var _a;
|
|
372
|
+
(_a = this.controller) == null ? void 0 : _a.update(this.buildProps());
|
|
373
|
+
}
|
|
374
|
+
buildProps() {
|
|
375
|
+
const props = {};
|
|
376
|
+
if (this.pendingBlocks !== void 0) props.blocks = this.pendingBlocks;
|
|
377
|
+
const html = this.getAttribute("html");
|
|
378
|
+
if (html !== null) props.html = html;
|
|
379
|
+
const theme = parseTheme(this.getAttribute("theme"));
|
|
380
|
+
if (theme !== void 0) props.theme = theme;
|
|
381
|
+
return props;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
function defineAerizElements(prefix = "aeriz") {
|
|
385
|
+
if (typeof customElements === "undefined") return;
|
|
386
|
+
const editorTag = `${prefix}-editor`;
|
|
387
|
+
const viewerTag = `${prefix}-viewer`;
|
|
388
|
+
if (!customElements.get(editorTag)) {
|
|
389
|
+
customElements.define(editorTag, AerizEditorElement);
|
|
390
|
+
}
|
|
391
|
+
if (!customElements.get(viewerTag)) {
|
|
392
|
+
customElements.define(viewerTag, AerizViewerElement);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
defineAerizElements();
|
|
396
|
+
exports.AerizEditorElement = AerizEditorElement;
|
|
397
|
+
exports.AerizViewerElement = AerizViewerElement;
|
|
398
|
+
exports.defineAerizElements = defineAerizElements;
|
|
399
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
400
|
+
return exports;
|
|
401
|
+
}({}, AerizWysiwyg);
|