@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.
- package/LICENSE +201 -201
- package/README.md +82 -573
- package/angular/README.md +10 -4
- package/angular/aeriz-editor.directive.ts +40 -18
- package/dist/adapters/jquery.cjs +1 -1
- package/dist/adapters/jquery.js +14 -14
- package/dist/adapters/shared.cjs +1 -1
- package/dist/adapters/shared.js +59 -56
- package/dist/adapters/vue.cjs +1 -1
- package/dist/adapters/vue.js +64 -56
- package/dist/adapters/vue2.cjs +1 -1
- package/dist/adapters/vue2.js +24 -17
- package/dist/adapters/wc.cjs +1 -1
- package/dist/adapters/wc.js +108 -72
- package/dist/aeriz-wysiwyg-adapter.js +24 -32
- package/dist/aeriz-wysiwyg-adapter.min.js +1 -1
- package/dist/aeriz-wysiwyg-highlight.js +964 -0
- package/dist/aeriz-wysiwyg-highlight.min.js +5 -0
- package/dist/aeriz-wysiwyg-jquery.js +25 -32
- package/dist/aeriz-wysiwyg-jquery.min.js +1 -1
- package/dist/aeriz-wysiwyg-wc.js +80 -43
- package/dist/aeriz-wysiwyg-wc.min.js +1 -1
- package/dist/aeriz-wysiwyg.cjs +3688 -1757
- package/dist/aeriz-wysiwyg.css +2104 -1904
- package/dist/aeriz-wysiwyg.esm.js +3688 -1757
- package/dist/aeriz-wysiwyg.esm.min.js +4904 -3538
- package/dist/aeriz-wysiwyg.js +3688 -1757
- package/dist/aeriz-wysiwyg.min.cjs +53 -40
- package/dist/aeriz-wysiwyg.min.css +1 -1
- package/dist/aeriz-wysiwyg.min.js +53 -40
- package/dist/highlight.cjs +5 -0
- package/dist/highlight.js +895 -0
- package/dist/server.cjs +24 -19
- package/dist/server.js +612 -251
- package/dist-types/adapters/shared.d.ts +0 -8
- package/dist-types/adapters/shared.d.ts.map +1 -1
- package/dist-types/adapters/vue.d.ts +62 -21
- package/dist-types/adapters/vue.d.ts.map +1 -1
- package/dist-types/adapters/vue2.d.ts +33 -14
- package/dist-types/adapters/vue2.d.ts.map +1 -1
- package/dist-types/adapters/wc.d.ts +15 -6
- package/dist-types/adapters/wc.d.ts.map +1 -1
- package/dist-types/cjs/adapters/shared.d.cts +0 -8
- package/dist-types/cjs/adapters/vue.d.cts +62 -21
- package/dist-types/cjs/adapters/vue2.d.cts +33 -14
- package/dist-types/cjs/adapters/wc.d.cts +15 -6
- package/dist-types/cjs/core/AerizEditor.d.cts +238 -48
- package/dist-types/cjs/core/AerizViewer.d.cts +7 -0
- package/dist-types/cjs/core/block-meta.d.cts +40 -0
- package/dist-types/cjs/core/block-tracker.d.cts +64 -0
- package/dist-types/cjs/core/blocks.d.cts +39 -4
- package/dist-types/cjs/core/fonts.d.cts +33 -46
- package/dist-types/cjs/core/highlight.d.cts +2 -0
- package/dist-types/cjs/core/history.d.cts +28 -10
- package/dist-types/cjs/core/html-to-blocks.d.cts +10 -0
- package/dist-types/cjs/core/i18n.d.cts +44 -0
- package/dist-types/cjs/core/import-html.d.cts +0 -13
- package/dist-types/cjs/core/insert-fragment.d.cts +21 -0
- package/dist-types/cjs/core/paste-clean.d.cts +36 -0
- package/dist-types/cjs/core/sanitize-dom.d.cts +21 -0
- package/dist-types/cjs/core/sanitize-html.d.cts +8 -0
- package/dist-types/cjs/core/sanitize-policy.d.cts +22 -0
- package/dist-types/cjs/core/selection.d.cts +5 -0
- package/dist-types/cjs/core/table-grid.d.cts +87 -0
- package/dist-types/cjs/core/table-ops.d.cts +2 -22
- package/dist-types/cjs/highlight/index.d.cts +5 -0
- package/dist-types/cjs/index.d.cts +19 -11
- package/dist-types/cjs/server/index.d.cts +4 -5
- package/dist-types/cjs/types/index.d.cts +63 -15
- package/dist-types/cjs/ui/Toolbar.d.cts +10 -0
- package/dist-types/cjs/ui/doc-tools.d.cts +58 -0
- package/dist-types/cjs/ui/popovers.d.cts +14 -25
- package/dist-types/core/AerizEditor.d.ts +238 -48
- package/dist-types/core/AerizEditor.d.ts.map +1 -1
- package/dist-types/core/AerizViewer.d.ts +7 -0
- package/dist-types/core/AerizViewer.d.ts.map +1 -1
- package/dist-types/core/block-meta.d.ts +40 -0
- package/dist-types/core/block-meta.d.ts.map +1 -1
- package/dist-types/core/block-policy.d.ts.map +1 -1
- package/dist-types/core/block-tracker.d.ts +64 -0
- package/dist-types/core/block-tracker.d.ts.map +1 -0
- package/dist-types/core/blocks.d.ts +39 -4
- package/dist-types/core/blocks.d.ts.map +1 -1
- package/dist-types/core/fonts.d.ts +33 -46
- package/dist-types/core/fonts.d.ts.map +1 -1
- package/dist-types/core/highlight.d.ts +2 -0
- package/dist-types/core/highlight.d.ts.map +1 -1
- package/dist-types/core/history.d.ts +28 -10
- package/dist-types/core/history.d.ts.map +1 -1
- package/dist-types/core/html-mini.d.ts.map +1 -1
- package/dist-types/core/html-to-blocks.d.ts +10 -0
- package/dist-types/core/html-to-blocks.d.ts.map +1 -0
- package/dist-types/core/i18n.d.ts +44 -0
- package/dist-types/core/i18n.d.ts.map +1 -1
- package/dist-types/core/import-html.d.ts +0 -13
- package/dist-types/core/import-html.d.ts.map +1 -1
- package/dist-types/core/import-markdown.d.ts.map +1 -1
- package/dist-types/core/insert-fragment.d.ts +21 -0
- package/dist-types/core/insert-fragment.d.ts.map +1 -0
- package/dist-types/core/markdown-export.d.ts.map +1 -1
- package/dist-types/core/paste-clean.d.ts +36 -0
- package/dist-types/core/paste-clean.d.ts.map +1 -0
- package/dist-types/core/render-string.d.ts.map +1 -1
- package/dist-types/core/sanitize-dom.d.ts +21 -0
- package/dist-types/core/sanitize-dom.d.ts.map +1 -0
- package/dist-types/core/sanitize-html.d.ts +8 -0
- package/dist-types/core/sanitize-html.d.ts.map +1 -0
- package/dist-types/core/sanitize-policy.d.ts +22 -0
- package/dist-types/core/sanitize-policy.d.ts.map +1 -0
- package/dist-types/core/selection.d.ts +5 -0
- package/dist-types/core/selection.d.ts.map +1 -1
- package/dist-types/core/snapshot.d.ts.map +1 -1
- package/dist-types/core/table-grid.d.ts +87 -0
- package/dist-types/core/table-grid.d.ts.map +1 -0
- package/dist-types/core/table-ops.d.ts +2 -22
- package/dist-types/core/table-ops.d.ts.map +1 -1
- package/dist-types/highlight/index.d.ts +5 -0
- package/dist-types/highlight/index.d.ts.map +1 -0
- package/dist-types/index.d.ts +19 -11
- package/dist-types/index.d.ts.map +1 -1
- package/dist-types/server/index.d.ts +4 -5
- package/dist-types/server/index.d.ts.map +1 -1
- package/dist-types/types/index.d.ts +63 -15
- package/dist-types/types/index.d.ts.map +1 -1
- package/dist-types/ui/Toolbar.d.ts +10 -0
- package/dist-types/ui/Toolbar.d.ts.map +1 -1
- package/dist-types/ui/doc-tools.d.ts +58 -0
- package/dist-types/ui/doc-tools.d.ts.map +1 -0
- package/dist-types/ui/icons.d.ts.map +1 -1
- package/dist-types/ui/popovers.d.ts +14 -25
- package/dist-types/ui/popovers.d.ts.map +1 -1
- package/package.json +70 -5
package/dist/adapters/vue2.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createEditorController as l, createViewerController as
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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: (
|
|
33
|
-
this.$emit("input",
|
|
36
|
+
onChange: (r) => {
|
|
37
|
+
this.$emit("input", r), this.$emit("change", r);
|
|
34
38
|
},
|
|
35
|
-
onStateChange: (
|
|
36
|
-
onReady: (
|
|
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
|
-
|
|
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
|
-
},
|
|
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: (
|
|
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 =
|
|
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
|
-
},
|
|
115
|
+
}, h = {
|
|
109
116
|
install(e) {
|
|
110
|
-
e.component("AerizEditor", a), e.component("AerizViewer",
|
|
117
|
+
e.component("AerizEditor", a), e.component("AerizViewer", s);
|
|
111
118
|
}
|
|
112
119
|
};
|
|
113
120
|
export {
|
|
114
121
|
a as AerizEditor,
|
|
115
|
-
|
|
116
|
-
|
|
122
|
+
s as AerizViewer,
|
|
123
|
+
h as AerizWysiwygPlugin
|
|
117
124
|
};
|
package/dist/adapters/wc.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
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;
|
package/dist/adapters/wc.js
CHANGED
|
@@ -1,49 +1,51 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { createEditorController as
|
|
5
|
-
const
|
|
6
|
-
function
|
|
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
|
|
15
|
-
if (
|
|
16
|
-
if (
|
|
17
|
-
if (
|
|
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
|
|
20
|
-
if (
|
|
21
|
-
return
|
|
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 =
|
|
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
|
|
30
|
-
const
|
|
31
|
-
if (typeof
|
|
29
|
+
function C(e) {
|
|
30
|
+
const i = e.attachInternals;
|
|
31
|
+
if (typeof i != "function") return null;
|
|
32
32
|
try {
|
|
33
|
-
const t =
|
|
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
|
|
39
|
+
class f extends HTMLElement {
|
|
40
40
|
constructor() {
|
|
41
41
|
super();
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
56
|
+
s(this, "pendingValue");
|
|
55
57
|
/** 에디터가 마지막으로 보고한 본문. 폼 값과 마운트 해제 후 `value` 의 근거. */
|
|
56
|
-
|
|
57
|
-
this.internals =
|
|
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
|
-
"
|
|
68
|
-
"
|
|
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.
|
|
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 =
|
|
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,
|
|
112
|
-
t === "value" && (this.pendingValue =
|
|
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: (
|
|
124
|
-
this.pendingValue = void 0, this.syncFormValue(
|
|
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
|
|
129
|
-
|
|
130
|
-
const
|
|
131
|
-
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
const
|
|
137
|
-
(
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
|
|
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
|
|
145
|
-
this.currentHTML = t, (
|
|
180
|
+
var l;
|
|
181
|
+
this.currentHTML = t, (l = this.internals) == null || l.setFormValue(t);
|
|
146
182
|
}
|
|
147
183
|
}
|
|
148
184
|
/** 폼 연동 대상임을 선언. 미지원 브라우저는 이 필드를 무시한다. */
|
|
149
|
-
|
|
150
|
-
class
|
|
185
|
+
s(f, "formAssociated", !0);
|
|
186
|
+
class z extends HTMLElement {
|
|
151
187
|
constructor() {
|
|
152
188
|
super(...arguments);
|
|
153
|
-
|
|
154
|
-
|
|
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
|
|
166
|
-
this.pendingBlocks = t, (
|
|
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 =
|
|
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
|
|
192
|
-
|
|
193
|
-
const
|
|
194
|
-
return
|
|
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
|
|
233
|
+
function P(e = "aeriz") {
|
|
198
234
|
if (typeof customElements > "u") return;
|
|
199
|
-
const
|
|
200
|
-
customElements.get(
|
|
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
|
-
|
|
238
|
+
P();
|
|
203
239
|
export {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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
|
-
|
|
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
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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.
|
|
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
|
-
|
|
126
|
-
if (
|
|
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.
|
|
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(
|
|
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);
|