@maildeno/editor 0.4.4 → 0.4.5

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/dist/init.js CHANGED
@@ -1,50 +1,45 @@
1
- import { r as g, c as u, b as f, h as v, _ as S, a as h, d as E } from "./element-DyFj9kgl.js";
2
- import { e as A, g as C, f as J, i as M, j, p as I, k as R, l as x, m as N, s as P } from "./element-DyFj9kgl.js";
3
- let c = !1;
4
- function p() {
5
- if (!(c || typeof document > "u")) {
6
- c = !0;
7
- for (const e of f()) {
1
+ import { O as o, at as c, i as u, st as g } from "./vue.runtime.esm-bundler-CsdyQceJ.js";
2
+ import { a as H, c as b, d as w, f as T, h as A, i as C, l as J, m as M, n as f, p as I, r as v, s as S, u as R } from "./element-Dq6bmt2l.js";
3
+ var m = !1;
4
+ function h() {
5
+ if (!(m || typeof document > "u")) {
6
+ m = !0;
7
+ for (const e of S()) {
8
8
  if (!e) continue;
9
9
  const l = document.createElement("style");
10
10
  l.setAttribute("data-maildeno-light-dom", ""), l.textContent = e, document.head.appendChild(l);
11
11
  }
12
12
  }
13
13
  }
14
- function y(e, l) {
15
- p();
16
- const a = g({ ...l }), i = /* @__PURE__ */ new Set(), d = h(null), n = document.createElement("div");
17
- n.style.height = "100%", e.appendChild(n);
18
- const r = u({
19
- setup() {
20
- return () => v(S, {
21
- ...a,
22
- ref: d,
23
- onSave: (t) => i.forEach((s) => s(t))
24
- });
25
- }
26
- });
27
- return r.mount(n), {
28
- element: n,
29
- exposed: () => d.value ?? null,
30
- setProp: (t, s) => {
31
- a[t] = s;
14
+ function E(e, l) {
15
+ h();
16
+ const t = c({ ...l }), i = /* @__PURE__ */ new Set(), a = g(null), r = document.createElement("div");
17
+ r.style.height = "100%", e.appendChild(r);
18
+ const n = u({ setup() {
19
+ return () => o(v, {
20
+ ...t,
21
+ ref: a,
22
+ onSave: (s) => i.forEach((d) => d(s))
23
+ });
24
+ } });
25
+ return n.mount(r), {
26
+ element: r,
27
+ exposed: () => a.value ?? null,
28
+ setProp: (s, d) => {
29
+ t[s] = d;
32
30
  },
33
- addSaveHandler: (t) => i.add(t),
34
- removeSaveHandler: (t) => i.delete(t),
31
+ addSaveHandler: (s) => i.add(s),
32
+ removeSaveHandler: (s) => i.delete(s),
35
33
  destroy: () => {
36
- r.unmount(), n.remove();
34
+ n.unmount(), r.remove();
37
35
  }
38
36
  };
39
37
  }
40
- async function H(e) {
38
+ async function j(e) {
41
39
  const l = typeof e.container == "string" ? document.querySelector(e.container) : e.container;
42
- if (!l)
43
- throw new Error(
44
- `[maildeno-editor] init() couldn't find a container${typeof e.container == "string" ? ` matching "${e.container}"` : ""}.`
45
- );
40
+ if (!l) throw new Error(`[maildeno-editor] init() couldn't find a container${typeof e.container == "string" ? ` matching "${e.container}"` : ""}.`);
46
41
  if (e.shadowDom === !1) {
47
- const n = y(l, {
42
+ const a = E(l, {
48
43
  templateId: e.templateId,
49
44
  storageAdapter: e.storageAdapter,
50
45
  theme: e.theme,
@@ -55,94 +50,87 @@ async function H(e) {
55
50
  saveHandler: e.onSave,
56
51
  assistant: e.assistant
57
52
  });
58
- await new Promise((t) => setTimeout(t, 0));
59
- const r = (t, ...s) => {
60
- var m;
61
- const o = (m = n.exposed()) == null ? void 0 : m[t];
62
- return typeof o == "function" ? o(...s) : null;
53
+ await new Promise((n) => setTimeout(n, 0));
54
+ const r = (n, ...s) => {
55
+ const d = a.exposed()?.[n];
56
+ return typeof d == "function" ? d(...s) : null;
63
57
  };
64
58
  return {
65
- element: n.element,
66
- on: (t, s) => n.addSaveHandler(s),
67
- off: (t, s) => n.removeSaveHandler(s),
68
- setTheme: (t) => n.setProp("theme", t),
69
- getHtml: (t = "prune") => r("getHtml", t),
70
- getMjml: (t = "prune") => r("getMjml", t),
71
- getReactEmail: (t = "prune") => r("getReactEmail", t),
59
+ element: a.element,
60
+ on: (n, s) => a.addSaveHandler(s),
61
+ off: (n, s) => a.removeSaveHandler(s),
62
+ setTheme: (n) => a.setProp("theme", n),
63
+ getHtml: (n = "prune") => r("getHtml", n),
64
+ getMjml: (n = "prune") => r("getMjml", n),
65
+ getReactEmail: (n = "prune") => r("getReactEmail", n),
72
66
  getJson: () => r("getJson"),
73
- setJson: (t, s) => {
74
- r("setJson", t, s);
67
+ setJson: (n, s) => {
68
+ r("setJson", n, s);
75
69
  },
76
70
  getSelection: () => r("getSelection"),
77
- setSelection: (t) => r("setSelection", t) ?? !1,
78
- // Falls back to a no-op unsubscribe rather than null so callers can
79
- // always call the result — a host storing it and invoking it during
80
- // teardown shouldn't have to null-check a cleanup function.
81
- onChange: (t) => r("onChange", t) ?? (() => {
71
+ setSelection: (n) => r("setSelection", n) ?? !1,
72
+ onChange: (n) => r("onChange", n) ?? (() => {
82
73
  }),
83
- destroy: () => n.destroy()
74
+ destroy: () => a.destroy()
84
75
  };
85
76
  }
86
- E();
87
- const a = document.createElement("maildeno-editor");
88
- e.templateId !== void 0 && (a.templateId = e.templateId), e.storageAdapter && (a.storageAdapter = e.storageAdapter), e.theme && (a.theme = e.theme), e.capabilities && (a.capabilities = e.capabilities), e.onSendTestEmail && (a.onSendTestEmail = e.onSendTestEmail), e.brandName !== void 0 && (a.brandName = e.brandName), e.versions !== void 0 && (a.versions = e.versions), e.assistant && (a.assistant = e.assistant), e.onSave && (a.saveHandler = e.onSave), l.appendChild(a), await new Promise((n) => setTimeout(n, 0));
77
+ f();
78
+ const t = document.createElement("maildeno-editor");
79
+ e.templateId !== void 0 && (t.templateId = e.templateId), e.storageAdapter && (t.storageAdapter = e.storageAdapter), e.theme && (t.theme = e.theme), e.capabilities && (t.capabilities = e.capabilities), e.onSendTestEmail && (t.onSendTestEmail = e.onSendTestEmail), e.brandName !== void 0 && (t.brandName = e.brandName), e.versions !== void 0 && (t.versions = e.versions), e.assistant && (t.assistant = e.assistant), e.onSave && (t.saveHandler = e.onSave), l.appendChild(t), await new Promise((a) => setTimeout(a, 0));
89
80
  const i = /* @__PURE__ */ new WeakMap();
90
81
  return {
91
- element: a,
92
- on(n, r) {
93
- const t = ((s) => r(
94
- Array.isArray(s.detail) ? s.detail[0] : s.detail
95
- ));
96
- i.set(r, t), a.addEventListener(n, t);
82
+ element: t,
83
+ on(a, r) {
84
+ const n = ((s) => r(Array.isArray(s.detail) ? s.detail[0] : s.detail));
85
+ i.set(r, n), t.addEventListener(a, n);
97
86
  },
98
- off(n, r) {
99
- const t = i.get(r);
100
- t && (a.removeEventListener(n, t), i.delete(r));
87
+ off(a, r) {
88
+ const n = i.get(r);
89
+ n && (t.removeEventListener(a, n), i.delete(r));
101
90
  },
102
- setTheme(n) {
103
- a.theme = n;
91
+ setTheme(a) {
92
+ t.theme = a;
104
93
  },
105
- getHtml(n = "prune") {
106
- return a.getHtml ? a.getHtml(n) : null;
94
+ getHtml(a = "prune") {
95
+ return t.getHtml ? t.getHtml(a) : null;
107
96
  },
108
- getMjml(n = "prune") {
109
- return a.getMjml ? a.getMjml(n) : null;
97
+ getMjml(a = "prune") {
98
+ return t.getMjml ? t.getMjml(a) : null;
110
99
  },
111
- getReactEmail(n = "prune") {
112
- return a.getReactEmail ? a.getReactEmail(n) : null;
100
+ getReactEmail(a = "prune") {
101
+ return t.getReactEmail ? t.getReactEmail(a) : null;
113
102
  },
114
103
  getJson() {
115
- return a.getJson ? a.getJson() : null;
104
+ return t.getJson ? t.getJson() : null;
116
105
  },
117
- setJson(n, r) {
118
- var t;
119
- (t = a.setJson) == null || t.call(a, n, r);
106
+ setJson(a, r) {
107
+ t.setJson?.(a, r);
120
108
  },
121
109
  getSelection() {
122
- return a.getSelection ? a.getSelection() : null;
110
+ return t.getSelection ? t.getSelection() : null;
123
111
  },
124
- setSelection(n) {
125
- return a.setSelection ? a.setSelection(n) : !1;
112
+ setSelection(a) {
113
+ return t.setSelection ? t.setSelection(a) : !1;
126
114
  },
127
- onChange(n) {
128
- return a.onChange ? a.onChange(n) : () => {
115
+ onChange(a) {
116
+ return t.onChange ? t.onChange(a) : () => {
129
117
  };
130
118
  },
131
119
  destroy() {
132
- a.remove();
120
+ t.remove();
133
121
  }
134
122
  };
135
123
  }
136
124
  export {
137
125
  A as createLocalStorageAdapter,
138
- C as getAllBlocks,
139
- J as getBlock,
140
- M as getRegisteredCustomESPs,
141
- j as getRegisteredMergeTagIds,
142
- H as init,
143
- I as palette,
144
- R as registerBlock,
145
- x as registerESPSyntax,
146
- N as registerMergeTags,
147
- P as setEditorTheme
126
+ T as getAllBlocks,
127
+ I as getBlock,
128
+ b as getRegisteredCustomESPs,
129
+ R as getRegisteredMergeTagIds,
130
+ j as init,
131
+ C as palette,
132
+ M as registerBlock,
133
+ J as registerESPSyntax,
134
+ w as registerMergeTags,
135
+ H as setEditorTheme
148
136
  };