@maildeno/editor 0.4.2 → 0.4.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/CHANGELOG.md +46 -0
- package/dist/RowPreviewLegacyComponent-BFvLnPiK.js +439 -0
- package/dist/RowPreviewLegacyComponent-CXsY4P-R.js +439 -0
- package/dist/RowPreviewRow-CeowK6Q_.js +107 -0
- package/dist/RowPreviewRow-D-6koDUR.js +107 -0
- package/dist/editor.css +1832 -1831
- package/dist/element-95RHug4F.js +68388 -0
- package/dist/element-scoped-styles.css +1832 -1831
- package/dist/element.js +2 -5
- package/dist/estree-B67dfAo1.js +7989 -0
- package/dist/html-D6UnSE1C.js +7353 -0
- package/dist/index.js +68394 -16
- package/dist/init.js +148 -166
- package/dist/standalone-Bd2oQFm3.js +3639 -0
- package/dist/typescript-C_Ru9PRN.js +23184 -0
- package/dist/vue.runtime.esm-bundler-BaHqghYy.js +9097 -0
- package/package.json +1 -1
- package/dist/RowPreviewChildren-DT0y0lKC.js +0 -4
- package/dist/RowPreviewChildren-OsbF7_vu.js +0 -4
- package/dist/RowPreviewLegacyComponent-BV4b5bHQ.js +0 -487
- package/dist/RowPreviewLegacyComponent-C08MGJVT.js +0 -487
- package/dist/RowPreviewRow-ByxeBYV8.js +0 -112
- package/dist/RowPreviewRow-N-hh5l_H.js +0 -112
- package/dist/element-C2ZH0Z_i.js +0 -86561
- package/dist/estree-DBJlF9un.js +0 -4876
- package/dist/html-3PMDtB0V.js +0 -3123
- package/dist/index-DhFg3uKs.js +0 -75864
- package/dist/standalone-DKWMQftY.js +0 -2391
- package/dist/typescript-l6-4tT8s.js +0 -13240
package/dist/init.js
CHANGED
|
@@ -1,174 +1,156 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { O as h, at as reactive, i as createApp, st as ref } from "./vue.runtime.esm-bundler-BaHqghYy.js";
|
|
2
|
+
import { a as setEditorTheme, c as getRegisteredCustomESPs, d as registerMergeTags, f as getAllBlocks, h as createLocalStorageAdapter, i as palette, l as registerESPSyntax, m as registerBlock, n as registerMaildenoEditorElement, p as getBlock, r as EmailEditor_default, s as buildShadowStyles, u as getRegisteredMergeTagIds } from "./element-95RHug4F.js";
|
|
3
|
+
//#region src/lightDom.ts
|
|
4
|
+
var stylesInjected = false;
|
|
5
|
+
/**
|
|
6
|
+
* The shadow path hands these strings to defineCustomElement, which turns
|
|
7
|
+
* them into <style> tags inside the shadow root. Here they go to
|
|
8
|
+
* document.head instead — same content, different destination. Guarded so
|
|
9
|
+
* multiple editors on one page inject once.
|
|
10
|
+
*/
|
|
4
11
|
function injectStylesIntoHead() {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
if (stylesInjected || typeof document === "undefined") return;
|
|
13
|
+
stylesInjected = true;
|
|
14
|
+
for (const css of buildShadowStyles()) {
|
|
15
|
+
if (!css) continue;
|
|
16
|
+
const style = document.createElement("style");
|
|
17
|
+
style.setAttribute("data-maildeno-light-dom", "");
|
|
18
|
+
style.textContent = css;
|
|
19
|
+
document.head.appendChild(style);
|
|
20
|
+
}
|
|
14
21
|
}
|
|
15
22
|
function mountLightDom(container, initialProps) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
};
|
|
23
|
+
injectStylesIntoHead();
|
|
24
|
+
const props = reactive({ ...initialProps });
|
|
25
|
+
const saveHandlers = /* @__PURE__ */ new Set();
|
|
26
|
+
const editorRef = ref(null);
|
|
27
|
+
const mountEl = document.createElement("div");
|
|
28
|
+
mountEl.style.height = "100%";
|
|
29
|
+
container.appendChild(mountEl);
|
|
30
|
+
const app = createApp({ setup() {
|
|
31
|
+
return () => h(EmailEditor_default, {
|
|
32
|
+
...props,
|
|
33
|
+
ref: editorRef,
|
|
34
|
+
onSave: (payload) => saveHandlers.forEach((fn) => fn(payload))
|
|
35
|
+
});
|
|
36
|
+
} });
|
|
37
|
+
app.mount(mountEl);
|
|
38
|
+
return {
|
|
39
|
+
element: mountEl,
|
|
40
|
+
exposed: () => editorRef.value ?? null,
|
|
41
|
+
setProp: (key, value) => {
|
|
42
|
+
props[key] = value;
|
|
43
|
+
},
|
|
44
|
+
addSaveHandler: (fn) => saveHandlers.add(fn),
|
|
45
|
+
removeSaveHandler: (fn) => saveHandlers.delete(fn),
|
|
46
|
+
destroy: () => {
|
|
47
|
+
app.unmount();
|
|
48
|
+
mountEl.remove();
|
|
49
|
+
}
|
|
50
|
+
};
|
|
46
51
|
}
|
|
52
|
+
//#endregion
|
|
53
|
+
//#region src/init.ts
|
|
47
54
|
function toDomEventName(event) {
|
|
48
|
-
|
|
55
|
+
return event;
|
|
49
56
|
}
|
|
50
57
|
async function init(options) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
return el.getSelection ? el.getSelection() : null;
|
|
148
|
-
},
|
|
149
|
-
setSelection(id) {
|
|
150
|
-
return el.setSelection ? el.setSelection(id) : false;
|
|
151
|
-
},
|
|
152
|
-
onChange(cb) {
|
|
153
|
-
return el.onChange ? el.onChange(cb) : () => {
|
|
154
|
-
};
|
|
155
|
-
},
|
|
156
|
-
destroy() {
|
|
157
|
-
el.remove();
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
return handle;
|
|
58
|
+
const container = typeof options.container === "string" ? document.querySelector(options.container) : options.container;
|
|
59
|
+
if (!container) throw new Error(`[maildeno-editor] init() couldn't find a container${typeof options.container === "string" ? ` matching "${options.container}"` : ""}.`);
|
|
60
|
+
if (options.shadowDom === false) {
|
|
61
|
+
const mount = mountLightDom(container, {
|
|
62
|
+
templateId: options.templateId,
|
|
63
|
+
storageAdapter: options.storageAdapter,
|
|
64
|
+
theme: options.theme,
|
|
65
|
+
capabilities: options.capabilities,
|
|
66
|
+
onSendTestEmail: options.onSendTestEmail,
|
|
67
|
+
brandName: options.brandName,
|
|
68
|
+
versions: options.versions,
|
|
69
|
+
saveHandler: options.onSave,
|
|
70
|
+
assistant: options.assistant
|
|
71
|
+
});
|
|
72
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
73
|
+
const call = (name, ...args) => {
|
|
74
|
+
const fn = mount.exposed()?.[name];
|
|
75
|
+
return typeof fn === "function" ? fn(...args) : null;
|
|
76
|
+
};
|
|
77
|
+
return {
|
|
78
|
+
element: mount.element,
|
|
79
|
+
on: (_event, handler) => mount.addSaveHandler(handler),
|
|
80
|
+
off: (_event, handler) => mount.removeSaveHandler(handler),
|
|
81
|
+
setTheme: (theme) => mount.setProp("theme", theme),
|
|
82
|
+
getHtml: (mode = "prune") => call("getHtml", mode),
|
|
83
|
+
getMjml: (mode = "prune") => call("getMjml", mode),
|
|
84
|
+
getReactEmail: (mode = "prune") => call("getReactEmail", mode),
|
|
85
|
+
getJson: () => call("getJson"),
|
|
86
|
+
setJson: (data, opts) => {
|
|
87
|
+
call("setJson", data, opts);
|
|
88
|
+
},
|
|
89
|
+
getSelection: () => call("getSelection"),
|
|
90
|
+
setSelection: (id) => call("setSelection", id) ?? false,
|
|
91
|
+
onChange: (cb) => call("onChange", cb) ?? (() => {}),
|
|
92
|
+
destroy: () => mount.destroy()
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
registerMaildenoEditorElement();
|
|
96
|
+
const el = document.createElement("maildeno-editor");
|
|
97
|
+
if (options.templateId !== void 0) el.templateId = options.templateId;
|
|
98
|
+
if (options.storageAdapter) el.storageAdapter = options.storageAdapter;
|
|
99
|
+
if (options.theme) el.theme = options.theme;
|
|
100
|
+
if (options.capabilities) el.capabilities = options.capabilities;
|
|
101
|
+
if (options.onSendTestEmail) el.onSendTestEmail = options.onSendTestEmail;
|
|
102
|
+
if (options.brandName !== void 0) el.brandName = options.brandName;
|
|
103
|
+
if (options.versions !== void 0) el.versions = options.versions;
|
|
104
|
+
if (options.assistant) el.assistant = options.assistant;
|
|
105
|
+
if (options.onSave) el.saveHandler = options.onSave;
|
|
106
|
+
container.appendChild(el);
|
|
107
|
+
await new Promise((resolve) => setTimeout(resolve, 0));
|
|
108
|
+
const listenerWrappers = /* @__PURE__ */ new WeakMap();
|
|
109
|
+
return {
|
|
110
|
+
element: el,
|
|
111
|
+
on(event, handler) {
|
|
112
|
+
const wrapped = ((e) => handler(Array.isArray(e.detail) ? e.detail[0] : e.detail));
|
|
113
|
+
listenerWrappers.set(handler, wrapped);
|
|
114
|
+
el.addEventListener(toDomEventName(event), wrapped);
|
|
115
|
+
},
|
|
116
|
+
off(event, handler) {
|
|
117
|
+
const wrapped = listenerWrappers.get(handler);
|
|
118
|
+
if (wrapped) {
|
|
119
|
+
el.removeEventListener(toDomEventName(event), wrapped);
|
|
120
|
+
listenerWrappers.delete(handler);
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
setTheme(theme) {
|
|
124
|
+
el.theme = theme;
|
|
125
|
+
},
|
|
126
|
+
getHtml(mode = "prune") {
|
|
127
|
+
return el.getHtml ? el.getHtml(mode) : null;
|
|
128
|
+
},
|
|
129
|
+
getMjml(mode = "prune") {
|
|
130
|
+
return el.getMjml ? el.getMjml(mode) : null;
|
|
131
|
+
},
|
|
132
|
+
getReactEmail(mode = "prune") {
|
|
133
|
+
return el.getReactEmail ? el.getReactEmail(mode) : null;
|
|
134
|
+
},
|
|
135
|
+
getJson() {
|
|
136
|
+
return el.getJson ? el.getJson() : null;
|
|
137
|
+
},
|
|
138
|
+
setJson(data, opts) {
|
|
139
|
+
el.setJson?.(data, opts);
|
|
140
|
+
},
|
|
141
|
+
getSelection() {
|
|
142
|
+
return el.getSelection ? el.getSelection() : null;
|
|
143
|
+
},
|
|
144
|
+
setSelection(id) {
|
|
145
|
+
return el.setSelection ? el.setSelection(id) : false;
|
|
146
|
+
},
|
|
147
|
+
onChange(cb) {
|
|
148
|
+
return el.onChange ? el.onChange(cb) : () => {};
|
|
149
|
+
},
|
|
150
|
+
destroy() {
|
|
151
|
+
el.remove();
|
|
152
|
+
}
|
|
153
|
+
};
|
|
161
154
|
}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
g as getAllBlocks,
|
|
165
|
-
f as getBlock,
|
|
166
|
-
i as getRegisteredCustomESPs,
|
|
167
|
-
j as getRegisteredMergeTagIds,
|
|
168
|
-
init,
|
|
169
|
-
p as palette,
|
|
170
|
-
k as registerBlock,
|
|
171
|
-
l as registerESPSyntax,
|
|
172
|
-
m as registerMergeTags,
|
|
173
|
-
s as setEditorTheme
|
|
174
|
-
};
|
|
155
|
+
//#endregion
|
|
156
|
+
export { createLocalStorageAdapter, getAllBlocks, getBlock, getRegisteredCustomESPs, getRegisteredMergeTagIds, init, palette, registerBlock, registerESPSyntax, registerMergeTags, setEditorTheme };
|