@savvycal/mjml-editor 0.0.1 → 0.0.2
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 +176 -0
- package/dist/components/editor/BlockIcon.d.ts +7 -0
- package/dist/components/editor/BlockIcon.d.ts.map +1 -0
- package/dist/components/editor/BlockInspector.d.ts +6 -0
- package/dist/components/editor/BlockInspector.d.ts.map +1 -0
- package/dist/components/editor/BlockInspector.js +380 -0
- package/dist/components/editor/EditorCanvas.d.ts +11 -0
- package/dist/components/editor/EditorCanvas.d.ts.map +1 -0
- package/dist/components/editor/EditorCanvas.js +116 -0
- package/dist/components/editor/FontEditor.d.ts +2 -0
- package/dist/components/editor/FontEditor.d.ts.map +1 -0
- package/dist/components/editor/FontEditor.js +227 -0
- package/dist/components/editor/GlobalStylesPanel.d.ts +7 -0
- package/dist/components/editor/GlobalStylesPanel.d.ts.map +1 -0
- package/dist/components/editor/GlobalStylesPanel.js +310 -0
- package/dist/components/editor/InteractivePreview.d.ts +8 -0
- package/dist/components/editor/InteractivePreview.d.ts.map +1 -0
- package/dist/components/editor/InteractivePreview.js +120 -0
- package/dist/components/editor/LiquidAutocomplete.d.ts +10 -0
- package/dist/components/editor/LiquidAutocomplete.d.ts.map +1 -0
- package/dist/components/editor/LiquidAutocomplete.js +70 -0
- package/dist/components/editor/LiquidInput.d.ts +12 -0
- package/dist/components/editor/LiquidInput.d.ts.map +1 -0
- package/dist/components/editor/LiquidInput.js +185 -0
- package/dist/components/editor/MjmlEditor.d.ts +11 -0
- package/dist/components/editor/MjmlEditor.d.ts.map +1 -0
- package/dist/components/editor/MjmlEditor.js +111 -0
- package/dist/components/editor/OutlineTree.d.ts +7 -0
- package/dist/components/editor/OutlineTree.d.ts.map +1 -0
- package/dist/components/editor/OutlineTree.js +282 -0
- package/dist/components/editor/SourceEditor.d.ts +2 -0
- package/dist/components/editor/SourceEditor.d.ts.map +1 -0
- package/dist/components/editor/SourceEditor.js +70 -0
- package/dist/components/editor/SourcePreview.d.ts +7 -0
- package/dist/components/editor/SourcePreview.d.ts.map +1 -0
- package/dist/components/editor/SourcePreview.js +55 -0
- package/dist/components/editor/TiptapEditor.d.ts +12 -0
- package/dist/components/editor/TiptapEditor.d.ts.map +1 -0
- package/dist/components/editor/TiptapEditor.js +330 -0
- package/dist/components/editor/VisualEditor.d.ts +7 -0
- package/dist/components/editor/VisualEditor.d.ts.map +1 -0
- package/dist/components/editor/VisualEditor.js +51 -0
- package/dist/components/editor/visual-blocks/VisualBlock.d.ts +7 -0
- package/dist/components/editor/visual-blocks/VisualBlock.d.ts.map +1 -0
- package/dist/components/editor/visual-blocks/VisualBlock.js +34 -0
- package/dist/components/editor/visual-blocks/VisualButton.d.ts +7 -0
- package/dist/components/editor/visual-blocks/VisualButton.d.ts.map +1 -0
- package/dist/components/editor/visual-blocks/VisualButton.js +111 -0
- package/dist/components/editor/visual-blocks/VisualColumn.d.ts +8 -0
- package/dist/components/editor/visual-blocks/VisualColumn.d.ts.map +1 -0
- package/dist/components/editor/visual-blocks/VisualColumn.js +44 -0
- package/dist/components/editor/visual-blocks/VisualDivider.d.ts +7 -0
- package/dist/components/editor/visual-blocks/VisualDivider.d.ts.map +1 -0
- package/dist/components/editor/visual-blocks/VisualDivider.js +41 -0
- package/dist/components/editor/visual-blocks/VisualImage.d.ts +7 -0
- package/dist/components/editor/visual-blocks/VisualImage.d.ts.map +1 -0
- package/dist/components/editor/visual-blocks/VisualImage.js +48 -0
- package/dist/components/editor/visual-blocks/VisualRaw.d.ts +7 -0
- package/dist/components/editor/visual-blocks/VisualRaw.d.ts.map +1 -0
- package/dist/components/editor/visual-blocks/VisualRaw.js +32 -0
- package/dist/components/editor/visual-blocks/VisualSection.d.ts +7 -0
- package/dist/components/editor/visual-blocks/VisualSection.d.ts.map +1 -0
- package/dist/components/editor/visual-blocks/VisualSection.js +131 -0
- package/dist/components/editor/visual-blocks/VisualSocial.d.ts +7 -0
- package/dist/components/editor/visual-blocks/VisualSocial.d.ts.map +1 -0
- package/dist/components/editor/visual-blocks/VisualSocial.js +62 -0
- package/dist/components/editor/visual-blocks/VisualSpacer.d.ts +7 -0
- package/dist/components/editor/visual-blocks/VisualSpacer.d.ts.map +1 -0
- package/dist/components/editor/visual-blocks/VisualSpacer.js +30 -0
- package/dist/components/editor/visual-blocks/VisualText.d.ts +7 -0
- package/dist/components/editor/visual-blocks/VisualText.d.ts.map +1 -0
- package/dist/components/editor/visual-blocks/VisualText.js +103 -0
- package/dist/components/editor/visual-blocks/helpers.d.ts +13 -0
- package/dist/components/editor/visual-blocks/helpers.d.ts.map +1 -0
- package/dist/components/editor/visual-blocks/helpers.js +44 -0
- package/dist/components/editor/visual-blocks/useResolvedAttributes.d.ts +7 -0
- package/dist/components/editor/visual-blocks/useResolvedAttributes.d.ts.map +1 -0
- package/dist/components/editor/visual-blocks/useResolvedAttributes.js +12 -0
- package/dist/components/ui/badge.d.ts +10 -0
- package/dist/components/ui/badge.d.ts.map +1 -0
- package/dist/components/ui/badge.js +26 -0
- package/dist/components/ui/button.d.ts +11 -0
- package/dist/components/ui/button.d.ts.map +1 -0
- package/dist/components/ui/button.js +54 -0
- package/dist/components/ui/card.d.ts +10 -0
- package/dist/components/ui/card.d.ts.map +1 -0
- package/dist/components/ui/collapsible.d.ts +6 -0
- package/dist/components/ui/collapsible.d.ts.map +1 -0
- package/dist/components/ui/collapsible.js +7 -0
- package/dist/components/ui/floating-panel.d.ts +12 -0
- package/dist/components/ui/floating-panel.d.ts.map +1 -0
- package/dist/components/ui/floating-panel.js +54 -0
- package/dist/components/ui/input.d.ts +4 -0
- package/dist/components/ui/input.d.ts.map +1 -0
- package/dist/components/ui/input.js +26 -0
- package/dist/components/ui/label.d.ts +5 -0
- package/dist/components/ui/label.d.ts.map +1 -0
- package/dist/components/ui/label.js +23 -0
- package/dist/components/ui/popover.d.ts +8 -0
- package/dist/components/ui/popover.d.ts.map +1 -0
- package/dist/components/ui/popover.js +39 -0
- package/dist/components/ui/resizable-split-pane.d.ts +10 -0
- package/dist/components/ui/resizable-split-pane.d.ts.map +1 -0
- package/dist/components/ui/resizable-split-pane.js +65 -0
- package/dist/components/ui/scroll-area.d.ts +10 -0
- package/dist/components/ui/scroll-area.d.ts.map +1 -0
- package/dist/components/ui/scroll-area.js +69 -0
- package/dist/components/ui/select.d.ts +16 -0
- package/dist/components/ui/select.d.ts.map +1 -0
- package/dist/components/ui/select.js +145 -0
- package/dist/components/ui/separator.d.ts +5 -0
- package/dist/components/ui/separator.d.ts.map +1 -0
- package/dist/components/ui/tabs.d.ts +8 -0
- package/dist/components/ui/tabs.d.ts.map +1 -0
- package/dist/components/ui/tabs.js +68 -0
- package/dist/components/ui/theme-toggle.d.ts +2 -0
- package/dist/components/ui/theme-toggle.d.ts.map +1 -0
- package/dist/components/ui/theme-toggle.js +58 -0
- package/dist/context/EditorContext.d.ts +40 -0
- package/dist/context/EditorContext.d.ts.map +1 -0
- package/dist/context/EditorContext.js +576 -0
- package/dist/context/LiquidSchemaContext.d.ts +10 -0
- package/dist/context/LiquidSchemaContext.d.ts.map +1 -0
- package/dist/context/LiquidSchemaContext.js +16 -0
- package/dist/context/ThemeContext.d.ts +18 -0
- package/dist/context/ThemeContext.d.ts.map +1 -0
- package/dist/context/ThemeContext.js +53 -0
- package/dist/extensions/LiquidHighlight.d.ts +3 -0
- package/dist/extensions/LiquidHighlight.d.ts.map +1 -0
- package/dist/extensions/LiquidHighlight.js +58 -0
- package/dist/extensions/LiquidSuggestion.d.ts +18 -0
- package/dist/extensions/LiquidSuggestion.d.ts.map +1 -0
- package/dist/extensions/LiquidSuggestion.js +119 -0
- package/dist/hooks/useFontLoader.d.ts +6 -0
- package/dist/hooks/useFontLoader.d.ts.map +1 -0
- package/dist/hooks/useFontLoader.js +21 -0
- package/dist/hooks/useStyleLoader.d.ts +11 -0
- package/dist/hooks/useStyleLoader.d.ts.map +1 -0
- package/dist/hooks/useStyleLoader.js +26 -0
- package/dist/index.d.ts +6 -150
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -57452
- package/dist/lib/html-utils.d.ts +23 -0
- package/dist/lib/html-utils.d.ts.map +1 -0
- package/dist/lib/html-utils.js +25 -0
- package/dist/lib/mjml/attributes.d.ts +100 -0
- package/dist/lib/mjml/attributes.d.ts.map +1 -0
- package/dist/lib/mjml/attributes.js +105 -0
- package/dist/lib/mjml/parser.d.ts +67 -0
- package/dist/lib/mjml/parser.d.ts.map +1 -0
- package/dist/lib/mjml/parser.js +184 -0
- package/dist/lib/mjml/parser.test.d.ts +2 -0
- package/dist/lib/mjml/parser.test.d.ts.map +1 -0
- package/dist/lib/mjml/renderer.d.ts +23 -0
- package/dist/lib/mjml/renderer.d.ts.map +1 -0
- package/dist/lib/mjml/renderer.js +72 -0
- package/dist/lib/mjml/schema.d.ts +21 -0
- package/dist/lib/mjml/schema.d.ts.map +1 -0
- package/dist/lib/mjml/schema.js +1307 -0
- package/dist/lib/mjml/scopeCSS.d.ts +21 -0
- package/dist/lib/mjml/scopeCSS.d.ts.map +1 -0
- package/dist/lib/mjml/scopeCSS.js +67 -0
- package/dist/lib/utils.d.ts +3 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +8 -0
- package/dist/styles.d.ts +1 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/styles.js +1 -0
- package/dist/types/liquid.d.ts +28 -0
- package/dist/types/liquid.d.ts.map +1 -0
- package/dist/types/mjml.d.ts +101 -0
- package/dist/types/mjml.d.ts.map +1 -0
- package/package.json +12 -9
|
@@ -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 @@
|
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
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"}
|