erl-mathtextx-editor 0.3.0 → 0.3.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/CHANGELOG.md +20 -0
- package/README.md +542 -542
- package/dist/{CellPropertiesDialogImpl-DroCD-qw.js → CellPropertiesDialogImpl-CgRJUUSC.js} +1 -1
- package/dist/{ImageInsertDialog-BprAxxIR.js → ImageInsertDialog-DbUscLs1.js} +104 -100
- package/dist/{InsertTableDialogImpl-U7g8UMBM.js → InsertTableDialogImpl-CWM11lNz.js} +1 -1
- package/dist/{LinkDialogImpl-Cs1v0Vgd.js → LinkDialogImpl-DrEasmBM.js} +1 -1
- package/dist/{TablePropertiesDialogImpl-BmdThHz3.js → TablePropertiesDialogImpl-BPcKuKCT.js} +1 -1
- package/dist/{TableTemplatesDialogImpl-CglXYCPV.js → TableTemplatesDialogImpl-DYrlbe5p.js} +1 -1
- package/dist/assets/erl-mathtextx-editor.css +1 -1
- package/dist/assets/viewer.css +1 -1
- package/dist/components/UploadErrorDebugPanel.d.ts +6 -0
- package/dist/erl-mathtextx-editor.js +28 -24
- package/dist/erl-mathtextx-editor.umd.cjs +3748 -0
- package/dist/{index-7QYcLP1s.js → index-CHqs4QOj.js} +2413 -2348
- package/dist/{index-Cv7EVaSA.js → index-CVlS1KL8.js} +1 -1
- package/dist/{index-DLjIKZ3J.js → index-DYrjnSa6.js} +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/utils/uploadError.d.ts +8 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as t, jsxs as l } from "react/jsx-runtime";
|
|
2
2
|
import V, { useId as B, useRef as M, useCallback as b, useState as d, useEffect as A } from "react";
|
|
3
|
-
import { u as $ } from "./index-
|
|
3
|
+
import { u as $ } from "./index-CHqs4QOj.js";
|
|
4
4
|
import { u as I } from "./useDraggable-DEoLIB5k.js";
|
|
5
5
|
const P = V.memo(({
|
|
6
6
|
isOpen: o,
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useId as
|
|
3
|
-
import { u as
|
|
4
|
-
function
|
|
5
|
-
isOpen:
|
|
6
|
-
onClose:
|
|
1
|
+
import { jsxs as l, Fragment as q, jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useId as H, useRef as w, useState as d, useCallback as o } from "react";
|
|
3
|
+
import { u as Q, l as X, U as Y } from "./index-CHqs4QOj.js";
|
|
4
|
+
function ia({
|
|
5
|
+
isOpen: N,
|
|
6
|
+
onClose: R,
|
|
7
7
|
onInsert: u,
|
|
8
|
-
onImageUpload:
|
|
8
|
+
onImageUpload: f
|
|
9
9
|
}) {
|
|
10
|
-
const
|
|
11
|
-
m.current && (URL.revokeObjectURL(m.current), m.current = null),
|
|
12
|
-
}, []),
|
|
13
|
-
|
|
14
|
-
}, [
|
|
15
|
-
|
|
16
|
-
const
|
|
10
|
+
const D = H(), L = w(null), [p, P] = d(f ? "upload" : "url"), [t, C] = d(""), [g, F] = d(""), [T, b] = d(!1), [A, y] = d(!1), [_, c] = d(null), [j, r] = d(""), [G, v] = d(null), E = w(null), m = w(null), S = o(() => {
|
|
11
|
+
m.current && (URL.revokeObjectURL(m.current), m.current = null), C(""), F(""), c(null), r(""), v(null), y(!1), b(!1);
|
|
12
|
+
}, []), n = o(() => {
|
|
13
|
+
S(), R();
|
|
14
|
+
}, [R, S]);
|
|
15
|
+
Q({ isOpen: N, dialogRef: L, onClose: n });
|
|
16
|
+
const I = async (a) => {
|
|
17
17
|
if (!["image/png", "image/jpeg", "image/jpg", "image/gif", "image/webp"].includes(a.type))
|
|
18
18
|
return { valid: !1, error: "File harus berupa gambar (JPG, PNG, GIF, WebP)" };
|
|
19
19
|
if (a.size > 10 * 1024 * 1024)
|
|
20
20
|
return { valid: !1, error: "Ukuran file maksimal 10MB" };
|
|
21
|
-
const
|
|
21
|
+
const x = {
|
|
22
22
|
"image/png": [[137, 80, 78, 71]],
|
|
23
23
|
"image/jpeg": [[255, 216, 255]],
|
|
24
24
|
"image/jpg": [[255, 216, 255]],
|
|
@@ -26,106 +26,107 @@ function Z({
|
|
|
26
26
|
"image/webp": [[82, 73, 70, 70]]
|
|
27
27
|
};
|
|
28
28
|
try {
|
|
29
|
-
const
|
|
30
|
-
if (!
|
|
29
|
+
const i = await a.slice(0, 8).arrayBuffer(), h = new Uint8Array(i), U = x[a.type];
|
|
30
|
+
if (!U)
|
|
31
31
|
return { valid: !1, error: "Format gambar tidak dikenali" };
|
|
32
|
-
if (!
|
|
33
|
-
(
|
|
32
|
+
if (!U.some(
|
|
33
|
+
(z) => z.every((J, V) => h[V] === J)
|
|
34
34
|
))
|
|
35
35
|
return { valid: !1, error: "File signature tidak valid. Kemungkinan file rusak atau mencurigakan." };
|
|
36
36
|
} catch {
|
|
37
37
|
return { valid: !1, error: "Gagal memvalidasi file" };
|
|
38
38
|
}
|
|
39
39
|
return { valid: !0 };
|
|
40
|
-
},
|
|
40
|
+
}, k = o(
|
|
41
41
|
async (a) => {
|
|
42
|
-
const
|
|
43
|
-
if (!
|
|
44
|
-
|
|
42
|
+
const s = await I(a);
|
|
43
|
+
if (!s.valid) {
|
|
44
|
+
r(s.error);
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
if (m.current =
|
|
50
|
-
|
|
47
|
+
r(""), v(null), m.current && URL.revokeObjectURL(m.current);
|
|
48
|
+
const x = URL.createObjectURL(a);
|
|
49
|
+
if (m.current = x, c(x), f) {
|
|
50
|
+
y(!0);
|
|
51
51
|
try {
|
|
52
|
-
const
|
|
53
|
-
if (!
|
|
52
|
+
const i = await f(a);
|
|
53
|
+
if (!i)
|
|
54
54
|
throw new Error("Upload gagal: URL tidak valid");
|
|
55
|
-
u(
|
|
56
|
-
} catch {
|
|
57
|
-
|
|
55
|
+
u(i, g || a.name), n();
|
|
56
|
+
} catch (i) {
|
|
57
|
+
const h = i instanceof Error ? i.message : "Upload gagal", U = X("Image insert upload failed", i);
|
|
58
|
+
r(`Upload gagal: ${h}`), v(U), c(null);
|
|
58
59
|
} finally {
|
|
59
|
-
|
|
60
|
+
y(!1);
|
|
60
61
|
}
|
|
61
62
|
} else {
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
u(
|
|
66
|
-
},
|
|
63
|
+
const i = new FileReader();
|
|
64
|
+
i.onload = () => {
|
|
65
|
+
const h = i.result;
|
|
66
|
+
u(h, g || a.name), n();
|
|
67
|
+
}, i.readAsDataURL(a);
|
|
67
68
|
}
|
|
68
69
|
},
|
|
69
|
-
[
|
|
70
|
-
), M =
|
|
70
|
+
[f, u, g, n]
|
|
71
|
+
), M = o(
|
|
71
72
|
(a) => {
|
|
72
|
-
const
|
|
73
|
-
|
|
73
|
+
const s = a.target.files?.[0];
|
|
74
|
+
s && k(s);
|
|
74
75
|
},
|
|
75
|
-
[
|
|
76
|
-
),
|
|
77
|
-
a.preventDefault(), a.stopPropagation(),
|
|
78
|
-
}, []),
|
|
79
|
-
a.preventDefault(), a.stopPropagation(),
|
|
80
|
-
}, []),
|
|
76
|
+
[k]
|
|
77
|
+
), O = o((a) => {
|
|
78
|
+
a.preventDefault(), a.stopPropagation(), b(!0);
|
|
79
|
+
}, []), $ = o((a) => {
|
|
80
|
+
a.preventDefault(), a.stopPropagation(), b(!1);
|
|
81
|
+
}, []), K = o(
|
|
81
82
|
(a) => {
|
|
82
|
-
a.preventDefault(), a.stopPropagation(),
|
|
83
|
-
const
|
|
84
|
-
|
|
83
|
+
a.preventDefault(), a.stopPropagation(), b(!1);
|
|
84
|
+
const s = a.dataTransfer.files?.[0];
|
|
85
|
+
s && k(s);
|
|
85
86
|
},
|
|
86
|
-
[
|
|
87
|
-
),
|
|
88
|
-
if (!
|
|
89
|
-
|
|
87
|
+
[k]
|
|
88
|
+
), B = o(() => {
|
|
89
|
+
if (!t.trim()) {
|
|
90
|
+
r("Masukkan URL gambar");
|
|
90
91
|
return;
|
|
91
92
|
}
|
|
92
93
|
try {
|
|
93
|
-
new URL(
|
|
94
|
+
new URL(t);
|
|
94
95
|
} catch {
|
|
95
|
-
|
|
96
|
+
r("URL tidak valid");
|
|
96
97
|
return;
|
|
97
98
|
}
|
|
98
|
-
u(
|
|
99
|
-
}, [
|
|
100
|
-
if (
|
|
99
|
+
u(t.trim(), g || void 0), n();
|
|
100
|
+
}, [t, g, u, n]), W = o(() => {
|
|
101
|
+
if (t.trim())
|
|
101
102
|
try {
|
|
102
|
-
new URL(
|
|
103
|
+
new URL(t), c(t.trim()), r("");
|
|
103
104
|
} catch {
|
|
104
|
-
|
|
105
|
+
r("URL tidak valid");
|
|
105
106
|
}
|
|
106
|
-
}, [
|
|
107
|
-
return
|
|
108
|
-
/* @__PURE__ */ e("div", { className: "mtx-dialog-overlay", onClick:
|
|
109
|
-
/* @__PURE__ */
|
|
110
|
-
/* @__PURE__ */
|
|
111
|
-
/* @__PURE__ */ e("h3", { id:
|
|
107
|
+
}, [t]);
|
|
108
|
+
return N ? /* @__PURE__ */ l(q, { children: [
|
|
109
|
+
/* @__PURE__ */ e("div", { className: "mtx-dialog-overlay", onClick: n }),
|
|
110
|
+
/* @__PURE__ */ l("div", { className: "mtx-image-dialog", ref: L, role: "dialog", "aria-modal": "true", "aria-labelledby": D, tabIndex: -1, children: [
|
|
111
|
+
/* @__PURE__ */ l("div", { className: "mtx-image-dialog__header", children: [
|
|
112
|
+
/* @__PURE__ */ e("h3", { id: D, children: "Sisipkan Gambar" }),
|
|
112
113
|
/* @__PURE__ */ e(
|
|
113
114
|
"button",
|
|
114
115
|
{
|
|
115
116
|
className: "mtx-image-dialog__close",
|
|
116
|
-
onClick:
|
|
117
|
+
onClick: n,
|
|
117
118
|
"aria-label": "Tutup",
|
|
118
119
|
children: "✕"
|
|
119
120
|
}
|
|
120
121
|
)
|
|
121
122
|
] }),
|
|
122
|
-
/* @__PURE__ */
|
|
123
|
+
/* @__PURE__ */ l("div", { className: "mtx-image-dialog__tabs", children: [
|
|
123
124
|
/* @__PURE__ */ e(
|
|
124
125
|
"button",
|
|
125
126
|
{
|
|
126
127
|
className: `mtx-image-dialog__tab ${p === "upload" ? "is-active" : ""}`,
|
|
127
128
|
onClick: () => {
|
|
128
|
-
|
|
129
|
+
P("upload"), r(""), v(null), c(null);
|
|
129
130
|
},
|
|
130
131
|
children: "📁 Upload File"
|
|
131
132
|
}
|
|
@@ -135,42 +136,42 @@ function Z({
|
|
|
135
136
|
{
|
|
136
137
|
className: `mtx-image-dialog__tab ${p === "url" ? "is-active" : ""}`,
|
|
137
138
|
onClick: () => {
|
|
138
|
-
|
|
139
|
+
P("url"), r(""), v(null), c(null);
|
|
139
140
|
},
|
|
140
141
|
children: "🔗 URL"
|
|
141
142
|
}
|
|
142
143
|
)
|
|
143
144
|
] }),
|
|
144
|
-
/* @__PURE__ */
|
|
145
|
-
p === "upload" && /* @__PURE__ */
|
|
145
|
+
/* @__PURE__ */ l("div", { className: "mtx-image-dialog__body", children: [
|
|
146
|
+
p === "upload" && /* @__PURE__ */ l(
|
|
146
147
|
"div",
|
|
147
148
|
{
|
|
148
|
-
className: `mtx-image-dialog__dropzone ${
|
|
149
|
-
onDragOver:
|
|
150
|
-
onDragLeave:
|
|
151
|
-
onDrop:
|
|
152
|
-
onClick: () =>
|
|
149
|
+
className: `mtx-image-dialog__dropzone ${T ? "is-dragging" : ""}`,
|
|
150
|
+
onDragOver: O,
|
|
151
|
+
onDragLeave: $,
|
|
152
|
+
onDrop: K,
|
|
153
|
+
onClick: () => E.current?.click(),
|
|
153
154
|
children: [
|
|
154
155
|
/* @__PURE__ */ e(
|
|
155
156
|
"input",
|
|
156
157
|
{
|
|
157
|
-
ref:
|
|
158
|
+
ref: E,
|
|
158
159
|
type: "file",
|
|
159
160
|
accept: "image/*",
|
|
160
161
|
onChange: M,
|
|
161
162
|
style: { display: "none" }
|
|
162
163
|
}
|
|
163
164
|
),
|
|
164
|
-
|
|
165
|
+
A ? /* @__PURE__ */ l("div", { className: "mtx-image-dialog__uploading", children: [
|
|
165
166
|
/* @__PURE__ */ e("div", { className: "mtx-spinner" }),
|
|
166
167
|
/* @__PURE__ */ e("p", { children: "Mengupload gambar..." })
|
|
167
|
-
] }) :
|
|
168
|
-
/* @__PURE__ */
|
|
168
|
+
] }) : _ ? /* @__PURE__ */ e("div", { className: "mtx-image-dialog__preview", children: /* @__PURE__ */ e("img", { src: _, alt: "Preview" }) }) : /* @__PURE__ */ l("div", { className: "mtx-image-dialog__placeholder", children: [
|
|
169
|
+
/* @__PURE__ */ l("svg", { width: "48", height: "48", viewBox: "0 0 48 48", fill: "none", stroke: "currentColor", strokeWidth: "1.5", children: [
|
|
169
170
|
/* @__PURE__ */ e("rect", { x: "4", y: "8", width: "40", height: "32", rx: "4" }),
|
|
170
171
|
/* @__PURE__ */ e("circle", { cx: "16", cy: "20", r: "4" }),
|
|
171
172
|
/* @__PURE__ */ e("path", { d: "M4 36l10-10 6 6 8-10 16 14" })
|
|
172
173
|
] }),
|
|
173
|
-
/* @__PURE__ */
|
|
174
|
+
/* @__PURE__ */ l("p", { children: [
|
|
174
175
|
/* @__PURE__ */ e("strong", { children: "Klik untuk pilih file" }),
|
|
175
176
|
" atau drag & drop ke sini"
|
|
176
177
|
] }),
|
|
@@ -179,55 +180,58 @@ function Z({
|
|
|
179
180
|
]
|
|
180
181
|
}
|
|
181
182
|
),
|
|
182
|
-
p === "url" && /* @__PURE__ */
|
|
183
|
+
p === "url" && /* @__PURE__ */ l("div", { className: "mtx-image-dialog__url-form", children: [
|
|
183
184
|
/* @__PURE__ */ e("label", { children: "URL Gambar" }),
|
|
184
185
|
/* @__PURE__ */ e("div", { className: "mtx-image-dialog__url-row", children: /* @__PURE__ */ e(
|
|
185
186
|
"input",
|
|
186
187
|
{
|
|
187
188
|
type: "url",
|
|
188
|
-
value:
|
|
189
|
-
onChange: (a) =>
|
|
189
|
+
value: t,
|
|
190
|
+
onChange: (a) => C(a.target.value),
|
|
190
191
|
placeholder: "https://example.com/gambar.jpg",
|
|
191
192
|
onKeyDown: (a) => {
|
|
192
|
-
a.key === "Enter" &&
|
|
193
|
+
a.key === "Enter" && B();
|
|
193
194
|
},
|
|
194
|
-
onBlur:
|
|
195
|
+
onBlur: W,
|
|
195
196
|
autoFocus: !0
|
|
196
197
|
}
|
|
197
198
|
) }),
|
|
198
|
-
|
|
199
|
+
_ && /* @__PURE__ */ e("div", { className: "mtx-image-dialog__url-preview", children: /* @__PURE__ */ e(
|
|
199
200
|
"img",
|
|
200
201
|
{
|
|
201
|
-
src:
|
|
202
|
+
src: _,
|
|
202
203
|
alt: "Preview",
|
|
203
204
|
onError: () => {
|
|
204
|
-
c(null),
|
|
205
|
+
c(null), r("Gambar tidak dapat dimuat dari URL ini");
|
|
205
206
|
}
|
|
206
207
|
}
|
|
207
208
|
) })
|
|
208
209
|
] }),
|
|
209
|
-
/* @__PURE__ */
|
|
210
|
+
/* @__PURE__ */ l("div", { className: "mtx-image-dialog__alt", children: [
|
|
210
211
|
/* @__PURE__ */ e("label", { children: "Teks Alternatif (opsional)" }),
|
|
211
212
|
/* @__PURE__ */ e(
|
|
212
213
|
"input",
|
|
213
214
|
{
|
|
214
215
|
type: "text",
|
|
215
216
|
value: g,
|
|
216
|
-
onChange: (a) =>
|
|
217
|
+
onChange: (a) => F(a.target.value),
|
|
217
218
|
placeholder: "Deskripsi gambar untuk aksesibilitas"
|
|
218
219
|
}
|
|
219
220
|
)
|
|
220
221
|
] }),
|
|
221
|
-
|
|
222
|
+
j && /* @__PURE__ */ l("div", { className: "mtx-image-dialog__error", children: [
|
|
223
|
+
/* @__PURE__ */ e("div", { children: j }),
|
|
224
|
+
G && /* @__PURE__ */ e(Y, { debug: G })
|
|
225
|
+
] })
|
|
222
226
|
] }),
|
|
223
|
-
/* @__PURE__ */
|
|
224
|
-
/* @__PURE__ */ e("button", { className: "mtx-image-dialog__btn mtx-image-dialog__btn--cancel", onClick:
|
|
227
|
+
/* @__PURE__ */ l("div", { className: "mtx-image-dialog__footer", children: [
|
|
228
|
+
/* @__PURE__ */ e("button", { className: "mtx-image-dialog__btn mtx-image-dialog__btn--cancel", onClick: n, children: "Batal" }),
|
|
225
229
|
p === "url" && /* @__PURE__ */ e(
|
|
226
230
|
"button",
|
|
227
231
|
{
|
|
228
232
|
className: "mtx-image-dialog__btn mtx-image-dialog__btn--insert",
|
|
229
|
-
onClick:
|
|
230
|
-
disabled: !
|
|
233
|
+
onClick: B,
|
|
234
|
+
disabled: !t.trim(),
|
|
231
235
|
children: "Sisipkan"
|
|
232
236
|
}
|
|
233
237
|
)
|
|
@@ -236,5 +240,5 @@ function Z({
|
|
|
236
240
|
] }) : null;
|
|
237
241
|
}
|
|
238
242
|
export {
|
|
239
|
-
|
|
243
|
+
ia as ImageInsertDialog
|
|
240
244
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
2
|
import v, { useId as g, useRef as y, useState as c, useEffect as k, useCallback as w } from "react";
|
|
3
|
-
import { u as C } from "./index-
|
|
3
|
+
import { u as C } from "./index-CHqs4QOj.js";
|
|
4
4
|
import { u as M } from "./useDraggable-DEoLIB5k.js";
|
|
5
5
|
const I = v.memo(({ isOpen: i, onInsert: d, onClose: m }) => {
|
|
6
6
|
const u = g(), b = y(null), [l, n] = c(3), [a, s] = c(3), [o, h] = c(!0), { position: p, handleMouseDown: N } = M(i);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as a, jsxs as e } from "react/jsx-runtime";
|
|
2
2
|
import S, { useId as T, useRef as _, useState as r, useEffect as w, useCallback as c } from "react";
|
|
3
|
-
import { u as F } from "./index-
|
|
3
|
+
import { u as F } from "./index-CHqs4QOj.js";
|
|
4
4
|
const I = S.memo(({
|
|
5
5
|
isOpen: s,
|
|
6
6
|
currentUrl: o = "",
|
package/dist/{TablePropertiesDialogImpl-BmdThHz3.js → TablePropertiesDialogImpl-BPcKuKCT.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as t, jsxs as l } from "react/jsx-runtime";
|
|
2
2
|
import g, { useId as x, useRef as p, useState as f, useEffect as y, useCallback as h } from "react";
|
|
3
|
-
import { u as N } from "./index-
|
|
3
|
+
import { u as N } from "./index-CHqs4QOj.js";
|
|
4
4
|
import { u as k } from "./useDraggable-DEoLIB5k.js";
|
|
5
5
|
const z = g.memo(({
|
|
6
6
|
isOpen: a,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as e, jsxs as l } from "react/jsx-runtime";
|
|
2
2
|
import c, { useId as p, useRef as h, useCallback as x } from "react";
|
|
3
|
-
import { u as b } from "./index-
|
|
3
|
+
import { u as b } from "./index-CHqs4QOj.js";
|
|
4
4
|
import { u } from "./useDraggable-DEoLIB5k.js";
|
|
5
5
|
const g = [
|
|
6
6
|
{ id: "plain", name: "Polos", description: "Tabel sederhana tanpa gaya tambahan", headerStyle: "none", borderStyle: "all", stripeRows: !1 },
|