@savvycal/mjml-editor 0.0.1 → 0.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.
Files changed (173) hide show
  1. package/README.md +191 -0
  2. package/dist/components/editor/BlockIcon.d.ts +7 -0
  3. package/dist/components/editor/BlockIcon.d.ts.map +1 -0
  4. package/dist/components/editor/BlockInspector.d.ts +6 -0
  5. package/dist/components/editor/BlockInspector.d.ts.map +1 -0
  6. package/dist/components/editor/BlockInspector.js +380 -0
  7. package/dist/components/editor/EditorCanvas.d.ts +11 -0
  8. package/dist/components/editor/EditorCanvas.d.ts.map +1 -0
  9. package/dist/components/editor/EditorCanvas.js +116 -0
  10. package/dist/components/editor/FontEditor.d.ts +2 -0
  11. package/dist/components/editor/FontEditor.d.ts.map +1 -0
  12. package/dist/components/editor/FontEditor.js +227 -0
  13. package/dist/components/editor/GlobalStylesPanel.d.ts +7 -0
  14. package/dist/components/editor/GlobalStylesPanel.d.ts.map +1 -0
  15. package/dist/components/editor/GlobalStylesPanel.js +310 -0
  16. package/dist/components/editor/InteractivePreview.d.ts +8 -0
  17. package/dist/components/editor/InteractivePreview.d.ts.map +1 -0
  18. package/dist/components/editor/InteractivePreview.js +130 -0
  19. package/dist/components/editor/LiquidAutocomplete.d.ts +10 -0
  20. package/dist/components/editor/LiquidAutocomplete.d.ts.map +1 -0
  21. package/dist/components/editor/LiquidAutocomplete.js +70 -0
  22. package/dist/components/editor/LiquidInput.d.ts +12 -0
  23. package/dist/components/editor/LiquidInput.d.ts.map +1 -0
  24. package/dist/components/editor/LiquidInput.js +185 -0
  25. package/dist/components/editor/MjmlEditor.d.ts +22 -0
  26. package/dist/components/editor/MjmlEditor.d.ts.map +1 -0
  27. package/dist/components/editor/MjmlEditor.js +137 -0
  28. package/dist/components/editor/OutlineTree.d.ts +7 -0
  29. package/dist/components/editor/OutlineTree.d.ts.map +1 -0
  30. package/dist/components/editor/OutlineTree.js +282 -0
  31. package/dist/components/editor/SourceEditor.d.ts +2 -0
  32. package/dist/components/editor/SourceEditor.d.ts.map +1 -0
  33. package/dist/components/editor/SourceEditor.js +70 -0
  34. package/dist/components/editor/SourcePreview.d.ts +7 -0
  35. package/dist/components/editor/SourcePreview.d.ts.map +1 -0
  36. package/dist/components/editor/SourcePreview.js +69 -0
  37. package/dist/components/editor/TiptapEditor.d.ts +12 -0
  38. package/dist/components/editor/TiptapEditor.d.ts.map +1 -0
  39. package/dist/components/editor/TiptapEditor.js +330 -0
  40. package/dist/components/editor/VisualEditor.d.ts +7 -0
  41. package/dist/components/editor/VisualEditor.d.ts.map +1 -0
  42. package/dist/components/editor/VisualEditor.js +51 -0
  43. package/dist/components/editor/visual-blocks/VisualBlock.d.ts +7 -0
  44. package/dist/components/editor/visual-blocks/VisualBlock.d.ts.map +1 -0
  45. package/dist/components/editor/visual-blocks/VisualBlock.js +34 -0
  46. package/dist/components/editor/visual-blocks/VisualButton.d.ts +7 -0
  47. package/dist/components/editor/visual-blocks/VisualButton.d.ts.map +1 -0
  48. package/dist/components/editor/visual-blocks/VisualButton.js +111 -0
  49. package/dist/components/editor/visual-blocks/VisualColumn.d.ts +8 -0
  50. package/dist/components/editor/visual-blocks/VisualColumn.d.ts.map +1 -0
  51. package/dist/components/editor/visual-blocks/VisualColumn.js +44 -0
  52. package/dist/components/editor/visual-blocks/VisualDivider.d.ts +7 -0
  53. package/dist/components/editor/visual-blocks/VisualDivider.d.ts.map +1 -0
  54. package/dist/components/editor/visual-blocks/VisualDivider.js +41 -0
  55. package/dist/components/editor/visual-blocks/VisualImage.d.ts +7 -0
  56. package/dist/components/editor/visual-blocks/VisualImage.d.ts.map +1 -0
  57. package/dist/components/editor/visual-blocks/VisualImage.js +48 -0
  58. package/dist/components/editor/visual-blocks/VisualRaw.d.ts +7 -0
  59. package/dist/components/editor/visual-blocks/VisualRaw.d.ts.map +1 -0
  60. package/dist/components/editor/visual-blocks/VisualRaw.js +32 -0
  61. package/dist/components/editor/visual-blocks/VisualSection.d.ts +7 -0
  62. package/dist/components/editor/visual-blocks/VisualSection.d.ts.map +1 -0
  63. package/dist/components/editor/visual-blocks/VisualSection.js +131 -0
  64. package/dist/components/editor/visual-blocks/VisualSocial.d.ts +7 -0
  65. package/dist/components/editor/visual-blocks/VisualSocial.d.ts.map +1 -0
  66. package/dist/components/editor/visual-blocks/VisualSocial.js +62 -0
  67. package/dist/components/editor/visual-blocks/VisualSpacer.d.ts +7 -0
  68. package/dist/components/editor/visual-blocks/VisualSpacer.d.ts.map +1 -0
  69. package/dist/components/editor/visual-blocks/VisualSpacer.js +30 -0
  70. package/dist/components/editor/visual-blocks/VisualText.d.ts +7 -0
  71. package/dist/components/editor/visual-blocks/VisualText.d.ts.map +1 -0
  72. package/dist/components/editor/visual-blocks/VisualText.js +103 -0
  73. package/dist/components/editor/visual-blocks/helpers.d.ts +13 -0
  74. package/dist/components/editor/visual-blocks/helpers.d.ts.map +1 -0
  75. package/dist/components/editor/visual-blocks/helpers.js +44 -0
  76. package/dist/components/editor/visual-blocks/useResolvedAttributes.d.ts +7 -0
  77. package/dist/components/editor/visual-blocks/useResolvedAttributes.d.ts.map +1 -0
  78. package/dist/components/editor/visual-blocks/useResolvedAttributes.js +12 -0
  79. package/dist/components/ui/badge.d.ts +10 -0
  80. package/dist/components/ui/badge.d.ts.map +1 -0
  81. package/dist/components/ui/badge.js +26 -0
  82. package/dist/components/ui/button.d.ts +11 -0
  83. package/dist/components/ui/button.d.ts.map +1 -0
  84. package/dist/components/ui/button.js +54 -0
  85. package/dist/components/ui/card.d.ts +10 -0
  86. package/dist/components/ui/card.d.ts.map +1 -0
  87. package/dist/components/ui/collapsible.d.ts +6 -0
  88. package/dist/components/ui/collapsible.d.ts.map +1 -0
  89. package/dist/components/ui/collapsible.js +7 -0
  90. package/dist/components/ui/floating-panel.d.ts +12 -0
  91. package/dist/components/ui/floating-panel.d.ts.map +1 -0
  92. package/dist/components/ui/floating-panel.js +54 -0
  93. package/dist/components/ui/input.d.ts +4 -0
  94. package/dist/components/ui/input.d.ts.map +1 -0
  95. package/dist/components/ui/input.js +26 -0
  96. package/dist/components/ui/label.d.ts +5 -0
  97. package/dist/components/ui/label.d.ts.map +1 -0
  98. package/dist/components/ui/label.js +23 -0
  99. package/dist/components/ui/popover.d.ts +8 -0
  100. package/dist/components/ui/popover.d.ts.map +1 -0
  101. package/dist/components/ui/popover.js +39 -0
  102. package/dist/components/ui/resizable-split-pane.d.ts +10 -0
  103. package/dist/components/ui/resizable-split-pane.d.ts.map +1 -0
  104. package/dist/components/ui/resizable-split-pane.js +65 -0
  105. package/dist/components/ui/scroll-area.d.ts +10 -0
  106. package/dist/components/ui/scroll-area.d.ts.map +1 -0
  107. package/dist/components/ui/scroll-area.js +69 -0
  108. package/dist/components/ui/select.d.ts +16 -0
  109. package/dist/components/ui/select.d.ts.map +1 -0
  110. package/dist/components/ui/select.js +145 -0
  111. package/dist/components/ui/separator.d.ts +5 -0
  112. package/dist/components/ui/separator.d.ts.map +1 -0
  113. package/dist/components/ui/tabs.d.ts +8 -0
  114. package/dist/components/ui/tabs.d.ts.map +1 -0
  115. package/dist/components/ui/tabs.js +68 -0
  116. package/dist/components/ui/theme-toggle.d.ts +2 -0
  117. package/dist/components/ui/theme-toggle.d.ts.map +1 -0
  118. package/dist/components/ui/theme-toggle.js +58 -0
  119. package/dist/components.css +365 -0
  120. package/dist/context/EditorContext.d.ts +40 -0
  121. package/dist/context/EditorContext.d.ts.map +1 -0
  122. package/dist/context/EditorContext.js +576 -0
  123. package/dist/context/LiquidSchemaContext.d.ts +10 -0
  124. package/dist/context/LiquidSchemaContext.d.ts.map +1 -0
  125. package/dist/context/LiquidSchemaContext.js +16 -0
  126. package/dist/context/ThemeContext.d.ts +29 -0
  127. package/dist/context/ThemeContext.d.ts.map +1 -0
  128. package/dist/context/ThemeContext.js +55 -0
  129. package/dist/extensions/LiquidHighlight.d.ts +3 -0
  130. package/dist/extensions/LiquidHighlight.d.ts.map +1 -0
  131. package/dist/extensions/LiquidHighlight.js +58 -0
  132. package/dist/extensions/LiquidSuggestion.d.ts +18 -0
  133. package/dist/extensions/LiquidSuggestion.d.ts.map +1 -0
  134. package/dist/extensions/LiquidSuggestion.js +119 -0
  135. package/dist/hooks/useFontLoader.d.ts +6 -0
  136. package/dist/hooks/useFontLoader.d.ts.map +1 -0
  137. package/dist/hooks/useFontLoader.js +21 -0
  138. package/dist/hooks/useStyleLoader.d.ts +11 -0
  139. package/dist/hooks/useStyleLoader.d.ts.map +1 -0
  140. package/dist/hooks/useStyleLoader.js +26 -0
  141. package/dist/index.d.ts +6 -150
  142. package/dist/index.d.ts.map +1 -0
  143. package/dist/index.js +7 -57452
  144. package/dist/lib/html-utils.d.ts +23 -0
  145. package/dist/lib/html-utils.d.ts.map +1 -0
  146. package/dist/lib/html-utils.js +25 -0
  147. package/dist/lib/mjml/attributes.d.ts +100 -0
  148. package/dist/lib/mjml/attributes.d.ts.map +1 -0
  149. package/dist/lib/mjml/attributes.js +105 -0
  150. package/dist/lib/mjml/parser.d.ts +67 -0
  151. package/dist/lib/mjml/parser.d.ts.map +1 -0
  152. package/dist/lib/mjml/parser.js +184 -0
  153. package/dist/lib/mjml/parser.test.d.ts +2 -0
  154. package/dist/lib/mjml/parser.test.d.ts.map +1 -0
  155. package/dist/lib/mjml/renderer.d.ts +23 -0
  156. package/dist/lib/mjml/renderer.d.ts.map +1 -0
  157. package/dist/lib/mjml/renderer.js +75 -0
  158. package/dist/lib/mjml/schema.d.ts +21 -0
  159. package/dist/lib/mjml/schema.d.ts.map +1 -0
  160. package/dist/lib/mjml/schema.js +1307 -0
  161. package/dist/lib/mjml/scopeCSS.d.ts +21 -0
  162. package/dist/lib/mjml/scopeCSS.d.ts.map +1 -0
  163. package/dist/lib/mjml/scopeCSS.js +67 -0
  164. package/dist/lib/utils.d.ts +3 -0
  165. package/dist/lib/utils.d.ts.map +1 -0
  166. package/dist/lib/utils.js +8 -0
  167. package/dist/preset.css +150 -0
  168. package/dist/types/liquid.d.ts +28 -0
  169. package/dist/types/liquid.d.ts.map +1 -0
  170. package/dist/types/mjml.d.ts +101 -0
  171. package/dist/types/mjml.d.ts.map +1 -0
  172. package/package.json +14 -10
  173. package/dist/styles.css +0 -1
@@ -0,0 +1,58 @@
1
+ import { Extension as u } from "@tiptap/core";
2
+ import { Plugin as g, PluginKey as h } from "@tiptap/pm/state";
3
+ import { Decoration as d, DecorationSet as m } from "@tiptap/pm/view";
4
+ const a = new h("liquidHighlight"), c = /\{\{[^{}]*\}\}/g, l = /\{%[^{}]*%\}/g;
5
+ function p(t) {
6
+ const e = [];
7
+ return t.descendants((r, n) => {
8
+ if (!r.isText || !r.text) return;
9
+ const o = r.text;
10
+ let i;
11
+ for (c.lastIndex = 0; (i = c.exec(o)) !== null; )
12
+ e.push({
13
+ from: n + i.index,
14
+ to: n + i.index + i[0].length,
15
+ type: "variable"
16
+ });
17
+ for (l.lastIndex = 0; (i = l.exec(o)) !== null; )
18
+ e.push({
19
+ from: n + i.index,
20
+ to: n + i.index + i[0].length,
21
+ type: "tag"
22
+ });
23
+ }), e;
24
+ }
25
+ function s(t) {
26
+ const r = p(t).map(
27
+ (n) => d.inline(n.from, n.to, {
28
+ class: "liquid-highlight"
29
+ })
30
+ );
31
+ return m.create(t, r);
32
+ }
33
+ const y = u.create({
34
+ name: "liquidHighlight",
35
+ addProseMirrorPlugins() {
36
+ return [
37
+ new g({
38
+ key: a,
39
+ state: {
40
+ init(t, { doc: e }) {
41
+ return s(e);
42
+ },
43
+ apply(t, e) {
44
+ return t.docChanged ? s(t.doc) : e.map(t.mapping, t.doc);
45
+ }
46
+ },
47
+ props: {
48
+ decorations(t) {
49
+ return a.getState(t);
50
+ }
51
+ }
52
+ })
53
+ ];
54
+ }
55
+ });
56
+ export {
57
+ y as LiquidHighlight
58
+ };
@@ -0,0 +1,18 @@
1
+ import { Extension } from '@tiptap/core';
2
+ export interface SuggestionProps {
3
+ query: string;
4
+ triggerType: 'variable' | 'tag';
5
+ range: {
6
+ from: number;
7
+ to: number;
8
+ };
9
+ clientRect: (() => DOMRect | null) | null;
10
+ }
11
+ export interface LiquidSuggestionOptions {
12
+ onStart: (props: SuggestionProps) => void;
13
+ onUpdate: (props: SuggestionProps) => void;
14
+ onExit: () => void;
15
+ onKeyDown: (event: KeyboardEvent) => boolean;
16
+ }
17
+ export declare const LiquidSuggestion: Extension<LiquidSuggestionOptions, any>;
18
+ //# sourceMappingURL=LiquidSuggestion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LiquidSuggestion.d.ts","sourceRoot":"","sources":["../../src/extensions/LiquidSuggestion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAIzC,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,UAAU,GAAG,KAAK,CAAC;IAChC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IACpC,UAAU,EAAE,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;CAC3C;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IAC1C,QAAQ,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IAC3C,MAAM,EAAE,MAAM,IAAI,CAAC;IACnB,SAAS,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAC;CAC9C;AAqCD,eAAO,MAAM,gBAAgB,yCA0I3B,CAAC"}
@@ -0,0 +1,119 @@
1
+ import { Extension as y } from "@tiptap/core";
2
+ import { Plugin as m, PluginKey as d } from "@tiptap/pm/state";
3
+ const f = new d("liquidSuggestion");
4
+ function l(i, r) {
5
+ return () => {
6
+ const t = i.coordsAtPos(r);
7
+ return {
8
+ x: t.left,
9
+ y: t.top,
10
+ width: 0,
11
+ height: t.bottom - t.top,
12
+ top: t.top,
13
+ left: t.left,
14
+ right: t.left,
15
+ bottom: t.bottom,
16
+ toJSON: () => ({
17
+ x: t.left,
18
+ y: t.top,
19
+ width: 0,
20
+ height: t.bottom - t.top,
21
+ top: t.top,
22
+ left: t.left,
23
+ right: t.left,
24
+ bottom: t.bottom
25
+ })
26
+ };
27
+ };
28
+ }
29
+ const v = y.create({
30
+ name: "liquidSuggestion",
31
+ addOptions() {
32
+ return {
33
+ onStart: () => {
34
+ },
35
+ onUpdate: () => {
36
+ },
37
+ onExit: () => {
38
+ },
39
+ onKeyDown: () => !1
40
+ };
41
+ },
42
+ addProseMirrorPlugins() {
43
+ const { options: i } = this;
44
+ return [
45
+ new m({
46
+ key: f,
47
+ state: {
48
+ init() {
49
+ return {
50
+ active: !1,
51
+ triggerType: null,
52
+ from: 0,
53
+ query: ""
54
+ };
55
+ },
56
+ apply(r, t, o, e) {
57
+ const { selection: s } = e, { $from: n } = s;
58
+ if (!s.empty)
59
+ return t.active ? { active: !1, triggerType: null, from: 0, query: "" } : t;
60
+ const a = n.parent.textBetween(
61
+ 0,
62
+ n.parentOffset,
63
+ void 0,
64
+ ""
65
+ ), u = a.match(/\{\{([^{}]*)$/);
66
+ if (u) {
67
+ const c = n.pos - n.parentOffset + a.lastIndexOf("{{"), g = u[1];
68
+ return {
69
+ active: !0,
70
+ triggerType: "variable",
71
+ from: c,
72
+ query: g
73
+ };
74
+ }
75
+ const p = a.match(/\{%([^{}]*)$/);
76
+ if (p) {
77
+ const c = n.pos - n.parentOffset + a.lastIndexOf("{%"), g = p[1];
78
+ return {
79
+ active: !0,
80
+ triggerType: "tag",
81
+ from: c,
82
+ query: g
83
+ };
84
+ }
85
+ return t.active ? { active: !1, triggerType: null, from: 0, query: "" } : t;
86
+ }
87
+ },
88
+ view() {
89
+ return {
90
+ update: (r, t) => {
91
+ const o = f.getState(t), e = f.getState(r.state);
92
+ if (!o || !e) return;
93
+ const s = !o.active && e.active, n = o.active && !e.active, a = o.active && e.active && (o.query !== e.query || o.from !== e.from);
94
+ n && i.onExit(), s && e.triggerType && i.onStart({
95
+ query: e.query,
96
+ triggerType: e.triggerType,
97
+ range: { from: e.from, to: r.state.selection.from },
98
+ clientRect: l(r, e.from)
99
+ }), a && e.triggerType && i.onUpdate({
100
+ query: e.query,
101
+ triggerType: e.triggerType,
102
+ range: { from: e.from, to: r.state.selection.from },
103
+ clientRect: l(r, e.from)
104
+ });
105
+ }
106
+ };
107
+ },
108
+ props: {
109
+ handleKeyDown(r, t) {
110
+ return f.getState(r.state)?.active ? i.onKeyDown(t) : !1;
111
+ }
112
+ }
113
+ })
114
+ ];
115
+ }
116
+ });
117
+ export {
118
+ v as LiquidSuggestion
119
+ };
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Hook that injects <link> tags into the document head for each mj-font.
3
+ * This enables custom fonts to render in the visual editor.
4
+ */
5
+ export declare function useFontLoader(): void;
6
+ //# sourceMappingURL=useFontLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFontLoader.d.ts","sourceRoot":"","sources":["../../src/hooks/useFontLoader.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,wBAAgB,aAAa,SA6C5B"}
@@ -0,0 +1,21 @@
1
+ import { useEffect as l } from "react";
2
+ import { useEditor as m } from "../context/EditorContext.js";
3
+ const t = "mjml-editor-font-";
4
+ function d() {
5
+ const { fonts: c } = m();
6
+ l(() => (document.querySelectorAll(`link[id^="${t}"]`).forEach((e) => {
7
+ const o = e.id.replace(t, "").replace(/-/g, " ");
8
+ c.some(
9
+ (n) => n.name === o || n.name.replace(/\s+/g, "-") === e.id.replace(t, "")
10
+ ) || e.remove();
11
+ }), c.forEach((e) => {
12
+ const o = `${t}${e.name.replace(/\s+/g, "-")}`;
13
+ let r = document.getElementById(o);
14
+ r ? r.href !== e.href && (r.href = e.href) : (r = document.createElement("link"), r.id = o, r.rel = "stylesheet", r.href = e.href, document.head.appendChild(r));
15
+ }), () => {
16
+ document.querySelectorAll(`link[id^="${t}"]`).forEach((e) => e.remove());
17
+ }), [c]);
18
+ }
19
+ export {
20
+ d as useFontLoader
21
+ };
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Scope class applied to the visual editor container.
3
+ * CSS from mj-style blocks is scoped to this class to prevent leaking.
4
+ */
5
+ export declare const VISUAL_EDITOR_SCOPE_CLASS = "mjml-visual-editor-scope";
6
+ /**
7
+ * Hook that injects a scoped <style> tag into the document head for mj-style CSS.
8
+ * This enables css-class styles to render in the visual editor.
9
+ */
10
+ export declare function useStyleLoader(): void;
11
+ //# sourceMappingURL=useStyleLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStyleLoader.d.ts","sourceRoot":"","sources":["../../src/hooks/useStyleLoader.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,eAAO,MAAM,yBAAyB,6BAA6B,CAAC;AAEpE;;;GAGG;AACH,wBAAgB,cAAc,SAkC7B"}
@@ -0,0 +1,26 @@
1
+ import { useMemo as c, useEffect as r } from "react";
2
+ import { useEditor as d } from "../context/EditorContext.js";
3
+ import { extractStyles as l } from "../lib/mjml/attributes.js";
4
+ import { scopeCSS as i } from "../lib/mjml/scopeCSS.js";
5
+ const t = "mjml-editor-styles", u = "mjml-visual-editor-scope";
6
+ function a() {
7
+ const { state: o } = d(), m = c(
8
+ () => l(o.document).join(`
9
+ `),
10
+ [o.document]
11
+ ), n = c(
12
+ () => i(m, u),
13
+ [m]
14
+ );
15
+ r(() => {
16
+ let e = document.getElementById(t);
17
+ return e || (e = document.createElement("style"), e.id = t, document.head.appendChild(e)), e.textContent = n, () => {
18
+ const s = document.getElementById(t);
19
+ s && s.remove();
20
+ };
21
+ }, [n]);
22
+ }
23
+ export {
24
+ u as VISUAL_EDITOR_SCOPE_CLASS,
25
+ a as useStyleLoader
26
+ };
package/dist/index.d.ts CHANGED
@@ -1,150 +1,6 @@
1
- import { JSX } from 'react/jsx-runtime';
2
- import { ReactNode } from 'react';
3
-
4
- export declare type ContentBlockType = 'mj-text' | 'mj-image' | 'mj-button' | 'mj-divider' | 'mj-spacer';
5
-
6
- export declare type EditorAction = {
7
- type: 'SELECT_BLOCK';
8
- payload: string | null;
9
- } | {
10
- type: 'UPDATE_ATTRIBUTES';
11
- payload: {
12
- id: string;
13
- attributes: Record<string, string>;
14
- };
15
- } | {
16
- type: 'UPDATE_CONTENT';
17
- payload: {
18
- id: string;
19
- content: string;
20
- };
21
- } | {
22
- type: 'ADD_BLOCK';
23
- payload: {
24
- parentId: string;
25
- index: number;
26
- block: MjmlNode;
27
- };
28
- } | {
29
- type: 'DELETE_BLOCK';
30
- payload: string;
31
- } | {
32
- type: 'MOVE_BLOCK';
33
- payload: {
34
- id: string;
35
- newParentId: string;
36
- newIndex: number;
37
- };
38
- } | {
39
- type: 'SET_DOCUMENT';
40
- payload: MjmlNode;
41
- } | {
42
- type: 'UNDO';
43
- } | {
44
- type: 'REDO';
45
- } | {
46
- type: 'UPDATE_MJML_ATTRIBUTE';
47
- payload: {
48
- attributeType: 'all' | 'element' | 'class';
49
- target: string | null;
50
- attributes: Record<string, string>;
51
- };
52
- } | {
53
- type: 'ADD_CLASS';
54
- payload: string;
55
- } | {
56
- type: 'REMOVE_CLASS';
57
- payload: string;
58
- } | {
59
- type: 'RENAME_CLASS';
60
- payload: {
61
- oldName: string;
62
- newName: string;
63
- };
64
- } | {
65
- type: 'ADD_FONT';
66
- payload: MjmlFont;
67
- } | {
68
- type: 'REMOVE_FONT';
69
- payload: string;
70
- } | {
71
- type: 'UPDATE_FONT';
72
- payload: MjmlFont;
73
- };
74
-
75
- export declare interface EditorState {
76
- document: MjmlNode;
77
- selectedBlockId: string | null;
78
- history: MjmlNode[];
79
- historyIndex: number;
80
- }
81
-
82
- /**
83
- * Complete Liquid schema passed to MjmlEditor
84
- */
85
- export declare interface LiquidSchema {
86
- /** Variables accessible via {{ variable_name }} syntax */
87
- variables: LiquidSchemaItem[];
88
- /** Tags accessible via {% tag_name %} syntax */
89
- tags: LiquidSchemaItem[];
90
- }
91
-
92
- /**
93
- * Schema item for Liquid variables and tags
94
- */
95
- export declare interface LiquidSchemaItem {
96
- /** The name/path of the variable or tag (e.g., "user.name" or "if") */
97
- name: string;
98
- /** Optional description shown in the autocomplete popup */
99
- description?: string;
100
- }
101
-
102
- export declare function MjmlEditor({ value, onChange, className, defaultTheme, liquidSchema, }: MjmlEditorProps): JSX.Element;
103
-
104
- declare interface MjmlEditorProps {
105
- value: string;
106
- onChange: (mjml: string) => void;
107
- className?: string;
108
- defaultTheme?: 'light' | 'dark' | 'system';
109
- liquidSchema?: LiquidSchema;
110
- }
111
-
112
- declare interface MjmlFont {
113
- name: string;
114
- href: string;
115
- }
116
-
117
- export declare interface MjmlNode {
118
- tagName: string;
119
- attributes: Record<string, string>;
120
- children?: MjmlNode[];
121
- content?: string;
122
- _id?: string;
123
- }
124
-
125
- export declare type MjmlTagName = 'mjml' | 'mj-head' | 'mj-body' | 'mj-wrapper' | 'mj-section' | 'mj-column' | 'mj-text' | 'mj-image' | 'mj-button' | 'mj-divider' | 'mj-spacer' | 'mj-title' | 'mj-preview' | 'mj-attributes' | 'mj-all' | 'mj-class' | 'mj-style' | 'mj-font';
126
-
127
- declare type ResolvedTheme = 'light' | 'dark';
128
-
129
- declare type Theme = 'light' | 'dark' | 'system';
130
-
131
- declare interface ThemeContextValue {
132
- theme: Theme;
133
- resolvedTheme: ResolvedTheme;
134
- setTheme: (theme: Theme) => void;
135
- toggleTheme: () => void;
136
- }
137
-
138
- export declare function ThemeProvider({ children, defaultTheme, storageKey, }: ThemeProviderProps): JSX.Element;
139
-
140
- declare interface ThemeProviderProps {
141
- children: ReactNode;
142
- defaultTheme?: Theme;
143
- storageKey?: string;
144
- }
145
-
146
- export declare function ThemeToggle(): JSX.Element;
147
-
148
- export declare function useTheme(): ThemeContextValue;
149
-
150
- export { }
1
+ export { MjmlEditor } from './components/editor/MjmlEditor';
2
+ export { ThemeProvider, useTheme } from './context/ThemeContext';
3
+ export { ThemeToggle } from './components/ui/theme-toggle';
4
+ export type { MjmlNode, MjmlTagName, ContentBlockType, EditorState, EditorAction, } from './types/mjml';
5
+ export type { LiquidSchema, LiquidSchemaItem } from './types/liquid';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAG5D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAG3D,YAAY,EACV,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,WAAW,EACX,YAAY,GACb,MAAM,cAAc,CAAC;AAEtB,YAAY,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC"}