erl-mathtextx-editor 0.3.1 → 0.3.6
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 +108 -0
- package/README.md +14 -1
- package/dist/{CellPropertiesDialogImpl-5bzEkaTt.js → CellPropertiesDialogImpl-NSTfG9SA.js} +1 -1
- package/dist/ContentViewer-LqSkiQjT.js +161 -0
- package/dist/ImageInsertDialog-DDxR_Cah.js +331 -0
- package/dist/{InsertTableDialogImpl-B2GUzYNY.js → InsertTableDialogImpl-DrW9QTDd.js} +1 -1
- package/dist/{LinkDialogImpl-CPjj0CkY.js → LinkDialogImpl-BXjhfEiE.js} +1 -1
- package/dist/MathTextXEditor.d.ts +1 -1
- package/dist/{TablePropertiesDialogImpl-BLbhyfA0.js → TablePropertiesDialogImpl-C2eqgZMa.js} +1 -1
- package/dist/{TableTemplatesDialogImpl-BQZTGw_Y.js → TableTemplatesDialogImpl-B2DJBmzm.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 +50 -28
- package/dist/erl-mathtextx-editor.umd.cjs +470 -200
- package/dist/export-deps-Tu2DJTcR.js +14815 -0
- package/dist/{index-CI4oNSUc.js → index-CvLezwrJ.js} +1 -1
- package/dist/{index-Bq8NKSwD.js → index-D1pCAIcb.js} +6239 -4221
- package/dist/index-D7oo0rd0.js +14235 -0
- package/dist/index.d.ts +11 -1
- package/dist/index.es-UDhZ1Ncp.js +5632 -0
- package/dist/jszip.min-I9rjwvpP.js +2341 -0
- package/dist/math/MathInputModeContext.d.ts +7 -0
- package/dist/math/TemplatePanel.d.ts +4 -1
- package/dist/math/mathFieldFontStyles.d.ts +7 -0
- package/dist/math/mathFieldSpaceKey.d.ts +10 -0
- package/dist/{tiptap-K3rU-Wjn.js → tiptap-BiWGiMFj.js} +27 -27
- package/dist/toolbar/MainToolbar.d.ts +3 -1
- package/dist/toolbar/MathToolbar.d.ts +9 -2
- package/dist/types/index.d.ts +18 -5
- package/dist/utils/docxImporter.d.ts +1 -0
- package/dist/utils/docxOmmlPreprocess.d.ts +12 -0
- package/dist/utils/imageFileValidation.d.ts +14 -0
- package/dist/utils/isLatexContent.d.ts +5 -0
- package/dist/utils/mathMlToLatex.d.ts +4 -0
- package/dist/utils/microsoftMathPaste.d.ts +43 -0
- package/dist/utils/ommlToLatex.d.ts +11 -0
- package/dist/utils/reuploadImagesInHTML.d.ts +9 -0
- package/dist/utils/sanitizeConfig.d.ts +11 -0
- package/dist/utils/unicodeMathToLatex.d.ts +24 -0
- package/dist/utils/uploadError.d.ts +8 -0
- package/dist/{viewer-deps-BDYoL2Ts.js → viewer-deps-_HnWniSt.js} +5 -0
- package/dist/viewer.js +1 -1
- package/package.json +23 -10
- package/dist/ContentViewer-RijJ5nlJ.js +0 -45
- package/dist/ImageInsertDialog-Dcg6kdLb.js +0 -240
- package/dist/components/__tests__/WordCount.test.d.ts +0 -1
- package/dist/core/__tests__/serializer.test.d.ts +0 -1
- package/dist/index-elIws1oE.js +0 -16549
- package/dist/viewer-styles.d.ts +0 -1
- package/dist/viewer-styles.js +0 -1
|
@@ -1,240 +0,0 @@
|
|
|
1
|
-
import { jsxs as i, Fragment as J, jsx as e } from "react/jsx-runtime";
|
|
2
|
-
import { useId as V, useRef as y, useState as d, useCallback as s } from "react";
|
|
3
|
-
import { u as q } from "./index-Bq8NKSwD.js";
|
|
4
|
-
function Z({
|
|
5
|
-
isOpen: U,
|
|
6
|
-
onClose: w,
|
|
7
|
-
onInsert: u,
|
|
8
|
-
onImageUpload: v
|
|
9
|
-
}) {
|
|
10
|
-
const N = V(), R = y(null), [p, L] = d(v ? "upload" : "url"), [r, D] = d(""), [g, C] = d(""), [B, h] = d(!1), [T, k] = d(!1), [f, c] = d(null), [P, l] = d(""), F = y(null), m = y(null), j = s(() => {
|
|
11
|
-
m.current && (URL.revokeObjectURL(m.current), m.current = null), D(""), C(""), c(null), l(""), k(!1), h(!1);
|
|
12
|
-
}, []), t = s(() => {
|
|
13
|
-
j(), w();
|
|
14
|
-
}, [w, j]);
|
|
15
|
-
q({ isOpen: U, dialogRef: R, onClose: t });
|
|
16
|
-
const A = async (a) => {
|
|
17
|
-
if (!["image/png", "image/jpeg", "image/jpg", "image/gif", "image/webp"].includes(a.type))
|
|
18
|
-
return { valid: !1, error: "File harus berupa gambar (JPG, PNG, GIF, WebP)" };
|
|
19
|
-
if (a.size > 10 * 1024 * 1024)
|
|
20
|
-
return { valid: !1, error: "Ukuran file maksimal 10MB" };
|
|
21
|
-
const _ = {
|
|
22
|
-
"image/png": [[137, 80, 78, 71]],
|
|
23
|
-
"image/jpeg": [[255, 216, 255]],
|
|
24
|
-
"image/jpg": [[255, 216, 255]],
|
|
25
|
-
"image/gif": [[71, 73, 70, 56]],
|
|
26
|
-
"image/webp": [[82, 73, 70, 70]]
|
|
27
|
-
};
|
|
28
|
-
try {
|
|
29
|
-
const o = await a.slice(0, 8).arrayBuffer(), x = new Uint8Array(o), S = _[a.type];
|
|
30
|
-
if (!S)
|
|
31
|
-
return { valid: !1, error: "Format gambar tidak dikenali" };
|
|
32
|
-
if (!S.some(
|
|
33
|
-
(W) => W.every(($, z) => x[z] === $)
|
|
34
|
-
))
|
|
35
|
-
return { valid: !1, error: "File signature tidak valid. Kemungkinan file rusak atau mencurigakan." };
|
|
36
|
-
} catch {
|
|
37
|
-
return { valid: !1, error: "Gagal memvalidasi file" };
|
|
38
|
-
}
|
|
39
|
-
return { valid: !0 };
|
|
40
|
-
}, b = s(
|
|
41
|
-
async (a) => {
|
|
42
|
-
const n = await A(a);
|
|
43
|
-
if (!n.valid) {
|
|
44
|
-
l(n.error);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
l(""), m.current && URL.revokeObjectURL(m.current);
|
|
48
|
-
const _ = URL.createObjectURL(a);
|
|
49
|
-
if (m.current = _, c(_), v) {
|
|
50
|
-
k(!0);
|
|
51
|
-
try {
|
|
52
|
-
const o = await v(a);
|
|
53
|
-
if (!o)
|
|
54
|
-
throw new Error("Upload gagal: URL tidak valid");
|
|
55
|
-
u(o, g || a.name), t();
|
|
56
|
-
} catch {
|
|
57
|
-
l("Upload gagal. Silakan coba lagi."), c(null);
|
|
58
|
-
} finally {
|
|
59
|
-
k(!1);
|
|
60
|
-
}
|
|
61
|
-
} else {
|
|
62
|
-
const o = new FileReader();
|
|
63
|
-
o.onload = () => {
|
|
64
|
-
const x = o.result;
|
|
65
|
-
u(x, g || a.name), t();
|
|
66
|
-
}, o.readAsDataURL(a);
|
|
67
|
-
}
|
|
68
|
-
},
|
|
69
|
-
[v, u, g, t]
|
|
70
|
-
), M = s(
|
|
71
|
-
(a) => {
|
|
72
|
-
const n = a.target.files?.[0];
|
|
73
|
-
n && b(n);
|
|
74
|
-
},
|
|
75
|
-
[b]
|
|
76
|
-
), I = s((a) => {
|
|
77
|
-
a.preventDefault(), a.stopPropagation(), h(!0);
|
|
78
|
-
}, []), E = s((a) => {
|
|
79
|
-
a.preventDefault(), a.stopPropagation(), h(!1);
|
|
80
|
-
}, []), O = s(
|
|
81
|
-
(a) => {
|
|
82
|
-
a.preventDefault(), a.stopPropagation(), h(!1);
|
|
83
|
-
const n = a.dataTransfer.files?.[0];
|
|
84
|
-
n && b(n);
|
|
85
|
-
},
|
|
86
|
-
[b]
|
|
87
|
-
), G = s(() => {
|
|
88
|
-
if (!r.trim()) {
|
|
89
|
-
l("Masukkan URL gambar");
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
try {
|
|
93
|
-
new URL(r);
|
|
94
|
-
} catch {
|
|
95
|
-
l("URL tidak valid");
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
u(r.trim(), g || void 0), t();
|
|
99
|
-
}, [r, g, u, t]), K = s(() => {
|
|
100
|
-
if (r.trim())
|
|
101
|
-
try {
|
|
102
|
-
new URL(r), c(r.trim()), l("");
|
|
103
|
-
} catch {
|
|
104
|
-
l("URL tidak valid");
|
|
105
|
-
}
|
|
106
|
-
}, [r]);
|
|
107
|
-
return U ? /* @__PURE__ */ i(J, { children: [
|
|
108
|
-
/* @__PURE__ */ e("div", { className: "mtx-dialog-overlay", onClick: t }),
|
|
109
|
-
/* @__PURE__ */ i("div", { className: "mtx-image-dialog", ref: R, role: "dialog", "aria-modal": "true", "aria-labelledby": N, tabIndex: -1, children: [
|
|
110
|
-
/* @__PURE__ */ i("div", { className: "mtx-image-dialog__header", children: [
|
|
111
|
-
/* @__PURE__ */ e("h3", { id: N, children: "Sisipkan Gambar" }),
|
|
112
|
-
/* @__PURE__ */ e(
|
|
113
|
-
"button",
|
|
114
|
-
{
|
|
115
|
-
className: "mtx-image-dialog__close",
|
|
116
|
-
onClick: t,
|
|
117
|
-
"aria-label": "Tutup",
|
|
118
|
-
children: "✕"
|
|
119
|
-
}
|
|
120
|
-
)
|
|
121
|
-
] }),
|
|
122
|
-
/* @__PURE__ */ i("div", { className: "mtx-image-dialog__tabs", children: [
|
|
123
|
-
/* @__PURE__ */ e(
|
|
124
|
-
"button",
|
|
125
|
-
{
|
|
126
|
-
className: `mtx-image-dialog__tab ${p === "upload" ? "is-active" : ""}`,
|
|
127
|
-
onClick: () => {
|
|
128
|
-
L("upload"), l(""), c(null);
|
|
129
|
-
},
|
|
130
|
-
children: "📁 Upload File"
|
|
131
|
-
}
|
|
132
|
-
),
|
|
133
|
-
/* @__PURE__ */ e(
|
|
134
|
-
"button",
|
|
135
|
-
{
|
|
136
|
-
className: `mtx-image-dialog__tab ${p === "url" ? "is-active" : ""}`,
|
|
137
|
-
onClick: () => {
|
|
138
|
-
L("url"), l(""), c(null);
|
|
139
|
-
},
|
|
140
|
-
children: "🔗 URL"
|
|
141
|
-
}
|
|
142
|
-
)
|
|
143
|
-
] }),
|
|
144
|
-
/* @__PURE__ */ i("div", { className: "mtx-image-dialog__body", children: [
|
|
145
|
-
p === "upload" && /* @__PURE__ */ i(
|
|
146
|
-
"div",
|
|
147
|
-
{
|
|
148
|
-
className: `mtx-image-dialog__dropzone ${B ? "is-dragging" : ""}`,
|
|
149
|
-
onDragOver: I,
|
|
150
|
-
onDragLeave: E,
|
|
151
|
-
onDrop: O,
|
|
152
|
-
onClick: () => F.current?.click(),
|
|
153
|
-
children: [
|
|
154
|
-
/* @__PURE__ */ e(
|
|
155
|
-
"input",
|
|
156
|
-
{
|
|
157
|
-
ref: F,
|
|
158
|
-
type: "file",
|
|
159
|
-
accept: "image/*",
|
|
160
|
-
onChange: M,
|
|
161
|
-
style: { display: "none" }
|
|
162
|
-
}
|
|
163
|
-
),
|
|
164
|
-
T ? /* @__PURE__ */ i("div", { className: "mtx-image-dialog__uploading", children: [
|
|
165
|
-
/* @__PURE__ */ e("div", { className: "mtx-spinner" }),
|
|
166
|
-
/* @__PURE__ */ e("p", { children: "Mengupload gambar..." })
|
|
167
|
-
] }) : f ? /* @__PURE__ */ e("div", { className: "mtx-image-dialog__preview", children: /* @__PURE__ */ e("img", { src: f, alt: "Preview" }) }) : /* @__PURE__ */ i("div", { className: "mtx-image-dialog__placeholder", children: [
|
|
168
|
-
/* @__PURE__ */ i("svg", { width: "48", height: "48", viewBox: "0 0 48 48", fill: "none", stroke: "currentColor", strokeWidth: "1.5", children: [
|
|
169
|
-
/* @__PURE__ */ e("rect", { x: "4", y: "8", width: "40", height: "32", rx: "4" }),
|
|
170
|
-
/* @__PURE__ */ e("circle", { cx: "16", cy: "20", r: "4" }),
|
|
171
|
-
/* @__PURE__ */ e("path", { d: "M4 36l10-10 6 6 8-10 16 14" })
|
|
172
|
-
] }),
|
|
173
|
-
/* @__PURE__ */ i("p", { children: [
|
|
174
|
-
/* @__PURE__ */ e("strong", { children: "Klik untuk pilih file" }),
|
|
175
|
-
" atau drag & drop ke sini"
|
|
176
|
-
] }),
|
|
177
|
-
/* @__PURE__ */ e("span", { children: "JPG, PNG, GIF, WebP — Maks 10MB" })
|
|
178
|
-
] })
|
|
179
|
-
]
|
|
180
|
-
}
|
|
181
|
-
),
|
|
182
|
-
p === "url" && /* @__PURE__ */ i("div", { className: "mtx-image-dialog__url-form", children: [
|
|
183
|
-
/* @__PURE__ */ e("label", { children: "URL Gambar" }),
|
|
184
|
-
/* @__PURE__ */ e("div", { className: "mtx-image-dialog__url-row", children: /* @__PURE__ */ e(
|
|
185
|
-
"input",
|
|
186
|
-
{
|
|
187
|
-
type: "url",
|
|
188
|
-
value: r,
|
|
189
|
-
onChange: (a) => D(a.target.value),
|
|
190
|
-
placeholder: "https://example.com/gambar.jpg",
|
|
191
|
-
onKeyDown: (a) => {
|
|
192
|
-
a.key === "Enter" && G();
|
|
193
|
-
},
|
|
194
|
-
onBlur: K,
|
|
195
|
-
autoFocus: !0
|
|
196
|
-
}
|
|
197
|
-
) }),
|
|
198
|
-
f && /* @__PURE__ */ e("div", { className: "mtx-image-dialog__url-preview", children: /* @__PURE__ */ e(
|
|
199
|
-
"img",
|
|
200
|
-
{
|
|
201
|
-
src: f,
|
|
202
|
-
alt: "Preview",
|
|
203
|
-
onError: () => {
|
|
204
|
-
c(null), l("Gambar tidak dapat dimuat dari URL ini");
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
) })
|
|
208
|
-
] }),
|
|
209
|
-
/* @__PURE__ */ i("div", { className: "mtx-image-dialog__alt", children: [
|
|
210
|
-
/* @__PURE__ */ e("label", { children: "Teks Alternatif (opsional)" }),
|
|
211
|
-
/* @__PURE__ */ e(
|
|
212
|
-
"input",
|
|
213
|
-
{
|
|
214
|
-
type: "text",
|
|
215
|
-
value: g,
|
|
216
|
-
onChange: (a) => C(a.target.value),
|
|
217
|
-
placeholder: "Deskripsi gambar untuk aksesibilitas"
|
|
218
|
-
}
|
|
219
|
-
)
|
|
220
|
-
] }),
|
|
221
|
-
P && /* @__PURE__ */ e("div", { className: "mtx-image-dialog__error", children: P })
|
|
222
|
-
] }),
|
|
223
|
-
/* @__PURE__ */ i("div", { className: "mtx-image-dialog__footer", children: [
|
|
224
|
-
/* @__PURE__ */ e("button", { className: "mtx-image-dialog__btn mtx-image-dialog__btn--cancel", onClick: t, children: "Batal" }),
|
|
225
|
-
p === "url" && /* @__PURE__ */ e(
|
|
226
|
-
"button",
|
|
227
|
-
{
|
|
228
|
-
className: "mtx-image-dialog__btn mtx-image-dialog__btn--insert",
|
|
229
|
-
onClick: G,
|
|
230
|
-
disabled: !r.trim(),
|
|
231
|
-
children: "Sisipkan"
|
|
232
|
-
}
|
|
233
|
-
)
|
|
234
|
-
] })
|
|
235
|
-
] })
|
|
236
|
-
] }) : null;
|
|
237
|
-
}
|
|
238
|
-
export {
|
|
239
|
-
Z as ImageInsertDialog
|
|
240
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|