erl-mathtextx-editor 0.1.2 → 0.1.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.
@@ -1,6 +1,6 @@
1
1
  import { jsx as t, jsxs as l } from "react/jsx-runtime";
2
2
  import z, { useId as H, useRef as A, useCallback as b, useState as d, useEffect as V } from "react";
3
- import { u as B } from "./index-DYxMVo98.js";
3
+ import { u as B } from "./index-jQUBaVKf.js";
4
4
  const M = z.memo(({
5
5
  isOpen: s,
6
6
  initialData: i = {},
@@ -1,6 +1,6 @@
1
1
  import { jsx as r } from "react/jsx-runtime";
2
2
  import { useRef as o, useMemo as i, useEffect as m } from "react";
3
- import { p as s, k as l } from "./viewer-deps-xNPNdmbe.js";
3
+ import { p as s, k as l } from "./viewer-deps-CjbAqdti.js";
4
4
  function c(t) {
5
5
  const e = t.getAttribute("data-latex") || t.getAttribute("latex");
6
6
  if (!e) return;
@@ -1,19 +1,19 @@
1
1
  import { jsxs as l, Fragment as E, jsx as e } from "react/jsx-runtime";
2
- import { useId as I, useRef as P, useState as d, useCallback as s } from "react";
3
- import { u as W } from "./index-DYxMVo98.js";
2
+ import { useId as I, useRef as P, useState as c, useCallback as n } from "react";
3
+ import { u as W } from "./index-jQUBaVKf.js";
4
4
  function O({
5
5
  isOpen: f,
6
6
  onClose: x,
7
- onInsert: g,
7
+ onInsert: m,
8
8
  onImageUpload: p
9
9
  }) {
10
- const k = I(), N = P(null), [u, y] = d(p ? "upload" : "url"), [r, U] = d(""), [m, w] = d(""), [F, h] = d(!1), [G, b] = d(!1), [v, o] = d(null), [D, i] = d(""), R = P(null), C = s(() => {
11
- U(""), w(""), o(null), i(""), b(!1), h(!1);
12
- }, []), n = s(() => {
10
+ const k = I(), N = P(null), [g, y] = c(p ? "upload" : "url"), [t, U] = c(""), [d, w] = c(""), [F, h] = c(!1), [G, b] = c(!1), [v, s] = c(null), [D, i] = c(""), R = P(null), C = n(() => {
11
+ U(""), w(""), s(null), i(""), b(!1), h(!1);
12
+ }, []), r = n(() => {
13
13
  C(), x();
14
14
  }, [x, C]);
15
- W({ isOpen: f, dialogRef: N, onClose: n });
16
- const _ = s(
15
+ W({ isOpen: f, dialogRef: N, onClose: r });
16
+ const _ = n(
17
17
  async (a) => {
18
18
  if (!a.type.startsWith("image/")) {
19
19
  i("File harus berupa gambar (jpg, png, gif, webp)");
@@ -24,67 +24,65 @@ function O({
24
24
  return;
25
25
  }
26
26
  i("");
27
- const c = URL.createObjectURL(a);
28
- if (o(c), p) {
27
+ const o = URL.createObjectURL(a);
28
+ if (s(o), p) {
29
29
  b(!0);
30
30
  try {
31
- const t = await p(a);
32
- g(t, m || a.name), n();
31
+ const u = await p(a);
32
+ m(u, d || a.name), r();
33
33
  } catch {
34
- i("Upload gagal. Silakan coba lagi."), o(null);
34
+ i("Upload gagal. Silakan coba lagi."), s(null);
35
35
  } finally {
36
36
  b(!1);
37
37
  }
38
38
  } else {
39
- const t = new FileReader();
40
- t.onload = () => {
41
- const T = t.result;
42
- g(T, m || a.name), n();
43
- }, t.readAsDataURL(a);
39
+ const u = new FileReader();
40
+ u.onload = () => {
41
+ const T = u.result;
42
+ m(T, d || a.name), r();
43
+ }, u.readAsDataURL(a);
44
44
  }
45
45
  },
46
- [p, g, m, n]
47
- ), M = s(
46
+ [p, m, d, r]
47
+ ), M = n(
48
48
  (a) => {
49
- var t;
50
- const c = (t = a.target.files) == null ? void 0 : t[0];
51
- c && _(c);
49
+ const o = a.target.files?.[0];
50
+ o && _(o);
52
51
  },
53
52
  [_]
54
- ), S = s((a) => {
53
+ ), S = n((a) => {
55
54
  a.preventDefault(), a.stopPropagation(), h(!0);
56
- }, []), j = s((a) => {
55
+ }, []), j = n((a) => {
57
56
  a.preventDefault(), a.stopPropagation(), h(!1);
58
- }, []), A = s(
57
+ }, []), A = n(
59
58
  (a) => {
60
- var t;
61
59
  a.preventDefault(), a.stopPropagation(), h(!1);
62
- const c = (t = a.dataTransfer.files) == null ? void 0 : t[0];
63
- c && _(c);
60
+ const o = a.dataTransfer.files?.[0];
61
+ o && _(o);
64
62
  },
65
63
  [_]
66
- ), L = s(() => {
67
- if (!r.trim()) {
64
+ ), L = n(() => {
65
+ if (!t.trim()) {
68
66
  i("Masukkan URL gambar");
69
67
  return;
70
68
  }
71
69
  try {
72
- new URL(r);
70
+ new URL(t);
73
71
  } catch {
74
72
  i("URL tidak valid");
75
73
  return;
76
74
  }
77
- g(r.trim(), m || void 0), n();
78
- }, [r, m, g, n]), B = s(() => {
79
- if (r.trim())
75
+ m(t.trim(), d || void 0), r();
76
+ }, [t, d, m, r]), B = n(() => {
77
+ if (t.trim())
80
78
  try {
81
- new URL(r), o(r.trim()), i("");
79
+ new URL(t), s(t.trim()), i("");
82
80
  } catch {
83
81
  i("URL tidak valid");
84
82
  }
85
- }, [r]);
83
+ }, [t]);
86
84
  return f ? /* @__PURE__ */ l(E, { children: [
87
- /* @__PURE__ */ e("div", { className: "mtx-dialog-overlay", onClick: n }),
85
+ /* @__PURE__ */ e("div", { className: "mtx-dialog-overlay", onClick: r }),
88
86
  /* @__PURE__ */ l("div", { className: "mtx-image-dialog", ref: N, role: "dialog", "aria-modal": "true", "aria-labelledby": k, tabIndex: -1, children: [
89
87
  /* @__PURE__ */ l("div", { className: "mtx-image-dialog__header", children: [
90
88
  /* @__PURE__ */ e("h3", { id: k, children: "Sisipkan Gambar" }),
@@ -92,7 +90,7 @@ function O({
92
90
  "button",
93
91
  {
94
92
  className: "mtx-image-dialog__close",
95
- onClick: n,
93
+ onClick: r,
96
94
  "aria-label": "Tutup",
97
95
  children: "✕"
98
96
  }
@@ -102,9 +100,9 @@ function O({
102
100
  /* @__PURE__ */ e(
103
101
  "button",
104
102
  {
105
- className: `mtx-image-dialog__tab ${u === "upload" ? "is-active" : ""}`,
103
+ className: `mtx-image-dialog__tab ${g === "upload" ? "is-active" : ""}`,
106
104
  onClick: () => {
107
- y("upload"), i(""), o(null);
105
+ y("upload"), i(""), s(null);
108
106
  },
109
107
  children: "📁 Upload File"
110
108
  }
@@ -112,26 +110,23 @@ function O({
112
110
  /* @__PURE__ */ e(
113
111
  "button",
114
112
  {
115
- className: `mtx-image-dialog__tab ${u === "url" ? "is-active" : ""}`,
113
+ className: `mtx-image-dialog__tab ${g === "url" ? "is-active" : ""}`,
116
114
  onClick: () => {
117
- y("url"), i(""), o(null);
115
+ y("url"), i(""), s(null);
118
116
  },
119
117
  children: "🔗 URL"
120
118
  }
121
119
  )
122
120
  ] }),
123
121
  /* @__PURE__ */ l("div", { className: "mtx-image-dialog__body", children: [
124
- u === "upload" && /* @__PURE__ */ l(
122
+ g === "upload" && /* @__PURE__ */ l(
125
123
  "div",
126
124
  {
127
125
  className: `mtx-image-dialog__dropzone ${F ? "is-dragging" : ""}`,
128
126
  onDragOver: S,
129
127
  onDragLeave: j,
130
128
  onDrop: A,
131
- onClick: () => {
132
- var a;
133
- return (a = R.current) == null ? void 0 : a.click();
134
- },
129
+ onClick: () => R.current?.click(),
135
130
  children: [
136
131
  /* @__PURE__ */ e(
137
132
  "input",
@@ -161,13 +156,13 @@ function O({
161
156
  ]
162
157
  }
163
158
  ),
164
- u === "url" && /* @__PURE__ */ l("div", { className: "mtx-image-dialog__url-form", children: [
159
+ g === "url" && /* @__PURE__ */ l("div", { className: "mtx-image-dialog__url-form", children: [
165
160
  /* @__PURE__ */ e("label", { children: "URL Gambar" }),
166
161
  /* @__PURE__ */ e("div", { className: "mtx-image-dialog__url-row", children: /* @__PURE__ */ e(
167
162
  "input",
168
163
  {
169
164
  type: "url",
170
- value: r,
165
+ value: t,
171
166
  onChange: (a) => U(a.target.value),
172
167
  placeholder: "https://example.com/gambar.jpg",
173
168
  onKeyDown: (a) => {
@@ -183,7 +178,7 @@ function O({
183
178
  src: v,
184
179
  alt: "Preview",
185
180
  onError: () => {
186
- o(null), i("Gambar tidak dapat dimuat dari URL ini");
181
+ s(null), i("Gambar tidak dapat dimuat dari URL ini");
187
182
  }
188
183
  }
189
184
  ) })
@@ -194,7 +189,7 @@ function O({
194
189
  "input",
195
190
  {
196
191
  type: "text",
197
- value: m,
192
+ value: d,
198
193
  onChange: (a) => w(a.target.value),
199
194
  placeholder: "Deskripsi gambar untuk aksesibilitas"
200
195
  }
@@ -203,13 +198,13 @@ function O({
203
198
  D && /* @__PURE__ */ e("div", { className: "mtx-image-dialog__error", children: D })
204
199
  ] }),
205
200
  /* @__PURE__ */ l("div", { className: "mtx-image-dialog__footer", children: [
206
- /* @__PURE__ */ e("button", { className: "mtx-image-dialog__btn mtx-image-dialog__btn--cancel", onClick: n, children: "Batal" }),
207
- u === "url" && /* @__PURE__ */ e(
201
+ /* @__PURE__ */ e("button", { className: "mtx-image-dialog__btn mtx-image-dialog__btn--cancel", onClick: r, children: "Batal" }),
202
+ g === "url" && /* @__PURE__ */ e(
208
203
  "button",
209
204
  {
210
205
  className: "mtx-image-dialog__btn mtx-image-dialog__btn--insert",
211
206
  onClick: L,
212
- disabled: !r.trim(),
207
+ disabled: !t.trim(),
213
208
  children: "Sisipkan"
214
209
  }
215
210
  )
@@ -1,6 +1,6 @@
1
1
  import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
2
  import N, { useId as v, useRef as f, useState as c, useEffect as g, useCallback as w } from "react";
3
- import { u as y } from "./index-DYxMVo98.js";
3
+ import { u as y } from "./index-jQUBaVKf.js";
4
4
  const k = N.memo(({ isOpen: i, onInsert: d, onClose: m }) => {
5
5
  const b = v(), u = f(null), [l, n] = c(3), [a, s] = c(3), [o, h] = c(!0);
6
6
  g(() => {
@@ -1,35 +1,35 @@
1
1
  import { jsx as t, jsxs as a } from "react/jsx-runtime";
2
- import F, { useId as U, useRef as j, useState as s, useEffect as E, useCallback as h } from "react";
3
- import { u as P } from "./index-DYxMVo98.js";
4
- const R = F.memo(({
2
+ import w, { useId as F, useRef as U, useState as r, useEffect as j, useCallback as d } from "react";
3
+ import { u as E } from "./index-jQUBaVKf.js";
4
+ const P = w.memo(({
5
5
  isOpen: m,
6
6
  currentUrl: i = "",
7
- currentText: c = "",
8
- currentTitle: u = "",
9
- currentTarget: p = "_blank",
7
+ currentText: s = "",
8
+ currentTitle: h = "",
9
+ currentTarget: u = "_blank",
10
10
  onInsert: g,
11
- onRemove: r,
11
+ onRemove: p,
12
12
  onClose: o
13
13
  }) => {
14
- const N = U(), v = j(null), [x, y] = s(i), [k, C] = s(c), [f, L] = s(u), [b, I] = s(p), [d, n] = s("");
15
- E(() => {
16
- m && (y(i), C(c), L(u), I(p || "_blank"), n(""));
17
- }, [m, i, c, u, p]), P({ isOpen: m, dialogRef: v, onClose: o });
18
- const D = h((e) => e.trim() ? /^(https?:\/\/|mailto:|#)[^\s]+$/i.test(e) ? (n(""), !0) : (n("URL harus dimulai dengan http://, https://, mailto:, atau #"), !1) : (n("URL tidak boleh kosong"), !1), []), W = h((e) => {
14
+ const N = F(), v = U(null), [x, y] = r(i), [k, C] = r(s), [f, L] = r(h), [b, R] = r(u), [c, n] = r("");
15
+ j(() => {
16
+ m && (y(i), C(s), L(h), R(u || "_blank"), n(""));
17
+ }, [m, i, s, h, u]), E({ isOpen: m, dialogRef: v, onClose: o });
18
+ const I = d((e) => e.trim() ? /^(https?:\/\/|mailto:|#)[^\s]+$/i.test(e) ? (n(""), !0) : (n("URL harus dimulai dengan http://, https://, mailto:, atau #"), !1) : (n("URL tidak boleh kosong"), !1), []), D = d((e) => {
19
19
  const l = e.trim();
20
20
  return l.startsWith("http://") || l.startsWith("https://") || l.startsWith("mailto:") || l.startsWith("#") ? l : `https://${l}`;
21
- }, []), _ = h((e) => {
21
+ }, []), W = d((e) => {
22
22
  e.preventDefault();
23
- const l = W(x);
24
- D(l) && g({
23
+ const l = D(x);
24
+ I(l) && g({
25
25
  url: l,
26
26
  text: k.trim() || void 0,
27
27
  title: f.trim() || void 0,
28
28
  target: b || void 0
29
29
  });
30
- }, [x, k, f, b, D, W, g]), w = h(() => {
31
- r == null || r(), o();
32
- }, [r, o]);
30
+ }, [x, k, f, b, I, D, g]), _ = d(() => {
31
+ p?.(), o();
32
+ }, [p, o]);
33
33
  return m ? /* @__PURE__ */ t("div", { className: "mtx-modal-overlay", onClick: o, children: /* @__PURE__ */ a(
34
34
  "div",
35
35
  {
@@ -45,7 +45,7 @@ const R = F.memo(({
45
45
  /* @__PURE__ */ t("h3", { className: "mtx-modal-title", id: N, children: i ? "Edit Link" : "Insert Link" }),
46
46
  /* @__PURE__ */ t("button", { className: "mtx-modal-close", onClick: o, title: "Close", "aria-label": "Close dialog", children: /* @__PURE__ */ t("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ t("path", { d: "M4 4l8 8m0-8l-8 8", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }) }) })
47
47
  ] }),
48
- /* @__PURE__ */ a("form", { onSubmit: _, children: [
48
+ /* @__PURE__ */ a("form", { onSubmit: W, children: [
49
49
  /* @__PURE__ */ a("div", { className: "mtx-modal-body", children: [
50
50
  /* @__PURE__ */ a("div", { className: "mtx-form-group", children: [
51
51
  /* @__PURE__ */ a("label", { className: "mtx-form-label", htmlFor: "link-url", children: [
@@ -57,22 +57,22 @@ const R = F.memo(({
57
57
  {
58
58
  id: "link-url",
59
59
  type: "text",
60
- className: `mtx-form-input ${d ? "mtx-input-error" : ""}`,
60
+ className: `mtx-form-input ${c ? "mtx-input-error" : ""}`,
61
61
  value: x,
62
62
  onChange: (e) => {
63
- y(e.target.value), d && n("");
63
+ y(e.target.value), c && n("");
64
64
  },
65
65
  placeholder: "https://example.com",
66
66
  autoFocus: !0,
67
67
  autoComplete: "url"
68
68
  }
69
69
  ),
70
- d && /* @__PURE__ */ t("div", { className: "mtx-form-error", children: d })
70
+ c && /* @__PURE__ */ t("div", { className: "mtx-form-error", children: c })
71
71
  ] }),
72
72
  /* @__PURE__ */ a("div", { className: "mtx-form-group", children: [
73
73
  /* @__PURE__ */ a("label", { className: "mtx-form-label", htmlFor: "link-text", children: [
74
74
  "Display Text",
75
- /* @__PURE__ */ t("span", { className: "mtx-form-hint", children: c ? "(kosongkan untuk tetap menggunakan text saat ini)" : "(opsional, akan menggunakan URL jika kosong)" })
75
+ /* @__PURE__ */ t("span", { className: "mtx-form-hint", children: s ? "(kosongkan untuk tetap menggunakan text saat ini)" : "(opsional, akan menggunakan URL jika kosong)" })
76
76
  ] }),
77
77
  /* @__PURE__ */ t(
78
78
  "input",
@@ -111,7 +111,7 @@ const R = F.memo(({
111
111
  {
112
112
  type: "checkbox",
113
113
  checked: b === "_blank",
114
- onChange: (e) => I(e.target.checked ? "_blank" : "_self")
114
+ onChange: (e) => R(e.target.checked ? "_blank" : "_self")
115
115
  }
116
116
  ),
117
117
  /* @__PURE__ */ t("span", { children: "Open in new tab" })
@@ -119,7 +119,7 @@ const R = F.memo(({
119
119
  ] }),
120
120
  /* @__PURE__ */ a("div", { className: "mtx-modal-footer", children: [
121
121
  /* @__PURE__ */ t("button", { type: "button", className: "mtx-btn mtx-btn-secondary", onClick: o, children: "Cancel" }),
122
- i && r && /* @__PURE__ */ t("button", { type: "button", className: "mtx-btn mtx-btn-danger", onClick: w, children: "Remove Link" }),
122
+ i && p && /* @__PURE__ */ t("button", { type: "button", className: "mtx-btn mtx-btn-danger", onClick: _, children: "Remove Link" }),
123
123
  /* @__PURE__ */ a("button", { type: "submit", className: "mtx-btn mtx-btn-primary", children: [
124
124
  i ? "Update" : "Insert",
125
125
  " Link"
@@ -130,7 +130,7 @@ const R = F.memo(({
130
130
  }
131
131
  ) }) : null;
132
132
  });
133
- R.displayName = "LinkDialogImpl";
133
+ P.displayName = "LinkDialogImpl";
134
134
  export {
135
- R as LinkDialogImpl
135
+ P as LinkDialogImpl
136
136
  };
@@ -1,6 +1,6 @@
1
1
  import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
2
  import o, { useId as c, useRef as n, useCallback as p } from "react";
3
- import { u as h } from "./index-DYxMVo98.js";
3
+ import { u as h } from "./index-jQUBaVKf.js";
4
4
  const x = [
5
5
  { id: "plain", name: "Plain", description: "Simple table without styling", headerStyle: "none", borderStyle: "all", stripeRows: !1 },
6
6
  { id: "light", name: "Light", description: "Light gray header", headerStyle: "light", borderStyle: "all", stripeRows: !1 },