@savvycal/mjml-editor 0.6.0 → 0.7.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.
@@ -1 +1 @@
1
- {"version":3,"file":"SourceEditor.d.ts","sourceRoot":"","sources":["../../../src/components/editor/SourceEditor.tsx"],"names":[],"mappings":"AA2DA,wBAAgB,YAAY,4CA4H3B"}
1
+ {"version":3,"file":"SourceEditor.d.ts","sourceRoot":"","sources":["../../../src/components/editor/SourceEditor.tsx"],"names":[],"mappings":"AA0DA,wBAAgB,YAAY,4CAkH3B"}
@@ -1,116 +1,111 @@
1
- import { jsxs as n, jsx as t } from "react/jsx-runtime";
2
- import { useState as f, useRef as g, useEffect as p, useCallback as b, useMemo as N } from "react";
3
- import { AlertTriangle as y } from "lucide-react";
1
+ import { jsxs as m, jsx as n } from "react/jsx-runtime";
2
+ import { useState as f, useRef as g, useEffect as p, useCallback as v, useMemo as y } from "react";
4
3
  import k from "@uiw/react-codemirror";
5
- import { EditorState as M } from "@codemirror/state";
6
- import { indentUnit as E, bracketMatching as j, syntaxHighlighting as w, HighlightStyle as C } from "@codemirror/language";
7
- import { lineNumbers as L, highlightActiveLineGutter as D, highlightActiveLine as W, EditorView as R, keymap as A } from "@codemirror/view";
8
- import { history as T, indentWithTab as z, defaultKeymap as H, historyKeymap as J } from "@codemirror/commands";
9
- import { highlightSelectionMatches as K, searchKeymap as U } from "@codemirror/search";
10
- import { xml as V } from "@codemirror/lang-xml";
11
- import { tags as r } from "@lezer/highlight";
12
- import { useEditor as _ } from "../../context/EditorContext.js";
13
- import { serializeMjml as x, parseMjml as B } from "../../lib/mjml/parser.js";
14
- import { ResizableSplitPane as I } from "../ui/resizable-split-pane.js";
4
+ import { EditorState as N } from "@codemirror/state";
5
+ import { indentUnit as M, bracketMatching as E, syntaxHighlighting as j, HighlightStyle as C } from "@codemirror/language";
6
+ import { lineNumbers as w, highlightActiveLineGutter as L, highlightActiveLine as D, EditorView as W, keymap as R } from "@codemirror/view";
7
+ import { history as z, indentWithTab as A, defaultKeymap as H, historyKeymap as K } from "@codemirror/commands";
8
+ import { highlightSelectionMatches as T, searchKeymap as U } from "@codemirror/search";
9
+ import { xml as _ } from "@codemirror/lang-xml";
10
+ import { tags as t } from "@lezer/highlight";
11
+ import { useEditor as B } from "../../context/EditorContext.js";
12
+ import { serializeMjml as b, parseMjml as I } from "../../lib/mjml/parser.js";
13
+ import { ResizableSplitPane as J } from "../ui/resizable-split-pane.js";
15
14
  import { SourcePreview as O } from "./SourcePreview.js";
16
- const P = 350, Y = C.define([
15
+ const P = 350, V = C.define([
17
16
  {
18
- tag: r.tagName,
17
+ tag: t.tagName,
19
18
  color: "var(--cm-tag, oklch(0.74 0.1 158))",
20
19
  fontWeight: "600"
21
20
  },
22
21
  {
23
- tag: r.attributeName,
22
+ tag: t.attributeName,
24
23
  color: "var(--cm-attribute-name, oklch(0.76 0.09 80))"
25
24
  },
26
25
  {
27
- tag: [r.attributeValue, r.string],
26
+ tag: [t.attributeValue, t.string],
28
27
  color: "var(--cm-attribute-value, oklch(0.77 0.1 255))"
29
28
  },
30
29
  {
31
- tag: [r.angleBracket, r.bracket],
30
+ tag: [t.angleBracket, t.bracket],
32
31
  color: "var(--cm-punctuation, oklch(0.7 0.02 250))"
33
32
  },
34
- { tag: r.comment, color: "var(--cm-comment, oklch(0.63 0.01 250))" },
33
+ { tag: t.comment, color: "var(--cm-comment, oklch(0.63 0.01 250))" },
35
34
  {
36
- tag: r.invalid,
35
+ tag: t.invalid,
37
36
  color: "var(--cm-invalid, oklch(0.7 0.16 25))",
38
37
  textDecoration: "underline"
39
38
  }
40
39
  ]);
41
- function le() {
42
- const { state: s, setDocument: u } = _(), [a, d] = f(""), [c, i] = f(null), l = g(!1), m = g("");
40
+ function ae() {
41
+ const { state: s, setDocument: u } = B(), [o, d] = f(""), [a, i] = f(null), c = g(!1), l = g("");
43
42
  p(() => {
44
- if (l.current) {
45
- l.current = !1;
43
+ if (c.current) {
44
+ c.current = !1;
46
45
  return;
47
46
  }
48
- const e = x(s.document);
49
- m.current = e, d(e), i(null);
47
+ const e = b(s.document);
48
+ l.current = e, d(e), i(null);
50
49
  }, [s.document]);
51
- const h = b(
50
+ const h = v(
52
51
  (e) => {
53
52
  try {
54
- const o = B(e);
55
- if (o.tagName !== "mjml") {
53
+ const r = I(e);
54
+ if (r.tagName !== "mjml") {
56
55
  i("Invalid MJML: Document must have an <mjml> root element");
57
56
  return;
58
57
  }
59
- m.current = x(o), l.current = !0, u(o), i(null);
60
- } catch (o) {
61
- i(o instanceof Error ? o.message : "Failed to parse MJML");
58
+ l.current = b(r), c.current = !0, u(r), i(null);
59
+ } catch (r) {
60
+ i(r instanceof Error ? r.message : "Failed to parse MJML");
62
61
  }
63
62
  },
64
63
  [u]
65
- ), v = N(
64
+ ), x = y(
66
65
  () => [
66
+ w(),
67
67
  L(),
68
68
  D(),
69
- W(),
69
+ z(),
70
+ N.tabSize.of(2),
71
+ M.of(" "),
72
+ E(),
70
73
  T(),
71
- M.tabSize.of(2),
72
- E.of(" "),
73
- j(),
74
- K(),
75
- w(Y),
76
- R.lineWrapping,
77
- A.of([
78
- z,
74
+ j(V),
75
+ W.lineWrapping,
76
+ R.of([
77
+ A,
79
78
  ...H,
80
- ...J,
79
+ ...K,
81
80
  ...U
82
81
  ]),
83
- V()
82
+ _()
84
83
  ],
85
84
  []
86
- ), S = b((e) => {
85
+ ), S = v((e) => {
87
86
  d(e), i(null);
88
87
  }, []);
89
88
  return p(() => {
90
- if (a === m.current)
89
+ if (o === l.current)
91
90
  return;
92
91
  const e = window.setTimeout(() => {
93
- h(a);
92
+ h(o);
94
93
  }, P);
95
94
  return () => window.clearTimeout(e);
96
- }, [a, h]), /* @__PURE__ */ n(
97
- I,
95
+ }, [o, h]), /* @__PURE__ */ m(
96
+ J,
98
97
  {
99
98
  defaultLeftWidth: 50,
100
99
  minLeftWidth: 30,
101
100
  maxLeftWidth: 70,
102
101
  children: [
103
- /* @__PURE__ */ n("div", { className: "flex flex-col h-full bg-background", children: [
104
- /* @__PURE__ */ t("div", { className: "px-4 pt-4", children: /* @__PURE__ */ n("div", { className: "flex items-start gap-3 p-3 rounded-md bg-amber-50 border border-amber-200 text-amber-800", children: [
105
- /* @__PURE__ */ t(y, { className: "h-4 w-4 mt-0.5 flex-shrink-0" }),
106
- /* @__PURE__ */ t("p", { className: "text-sm", children: "You are editing raw MJML source. Valid changes sync to the visual editor automatically." })
107
- ] }) }),
108
- /* @__PURE__ */ t("div", { className: "flex-1 min-h-0 p-4", children: /* @__PURE__ */ t(
102
+ /* @__PURE__ */ m("div", { className: "flex flex-col h-full bg-background", children: [
103
+ /* @__PURE__ */ n("div", { className: "flex-1 min-h-0 p-4", children: /* @__PURE__ */ n(
109
104
  k,
110
105
  {
111
- value: a,
106
+ value: o,
112
107
  onChange: S,
113
- extensions: v,
108
+ extensions: x,
114
109
  basicSetup: !1,
115
110
  theme: "none",
116
111
  className: "source-editor h-full overflow-hidden rounded-md border border-border bg-muted text-foreground",
@@ -118,16 +113,16 @@ function le() {
118
113
  spellCheck: !1
119
114
  }
120
115
  ) }),
121
- /* @__PURE__ */ n("div", { className: "px-4 pb-4 flex items-center gap-3", children: [
122
- !c && /* @__PURE__ */ t("span", { className: "text-sm text-foreground-muted", children: "Changes sync automatically" }),
123
- c && /* @__PURE__ */ t("span", { className: "text-sm text-destructive", children: c })
116
+ /* @__PURE__ */ m("div", { className: "px-4 pb-4 flex items-center gap-3", children: [
117
+ !a && /* @__PURE__ */ n("span", { className: "text-sm text-foreground-muted", children: "Changes sync automatically" }),
118
+ a && /* @__PURE__ */ n("span", { className: "text-sm text-destructive", children: a })
124
119
  ] })
125
120
  ] }),
126
- /* @__PURE__ */ t(O, { mjmlSource: a, debounceMs: 300 })
121
+ /* @__PURE__ */ n(O, { mjmlSource: o, debounceMs: 300 })
127
122
  ]
128
123
  }
129
124
  );
130
125
  }
131
126
  export {
132
- le as SourceEditor
127
+ ae as SourceEditor
133
128
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@savvycal/mjml-editor",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {