erl-mathtextx-editor 0.3.2 → 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.
Files changed (49) hide show
  1. package/CHANGELOG.md +88 -0
  2. package/README.md +14 -1
  3. package/dist/{CellPropertiesDialogImpl-CgRJUUSC.js → CellPropertiesDialogImpl-NSTfG9SA.js} +1 -1
  4. package/dist/ContentViewer-LqSkiQjT.js +161 -0
  5. package/dist/ImageInsertDialog-DDxR_Cah.js +331 -0
  6. package/dist/{InsertTableDialogImpl-CWM11lNz.js → InsertTableDialogImpl-DrW9QTDd.js} +1 -1
  7. package/dist/{LinkDialogImpl-DrEasmBM.js → LinkDialogImpl-BXjhfEiE.js} +1 -1
  8. package/dist/MathTextXEditor.d.ts +1 -1
  9. package/dist/{TablePropertiesDialogImpl-BPcKuKCT.js → TablePropertiesDialogImpl-C2eqgZMa.js} +1 -1
  10. package/dist/{TableTemplatesDialogImpl-DYrlbe5p.js → TableTemplatesDialogImpl-B2DJBmzm.js} +1 -1
  11. package/dist/assets/erl-mathtextx-editor.css +1 -1
  12. package/dist/assets/viewer.css +1 -1
  13. package/dist/erl-mathtextx-editor.js +45 -27
  14. package/dist/erl-mathtextx-editor.umd.cjs +470 -200
  15. package/dist/export-deps-Tu2DJTcR.js +14815 -0
  16. package/dist/{index-DYrjnSa6.js → index-CvLezwrJ.js} +1 -1
  17. package/dist/{index-CHqs4QOj.js → index-D1pCAIcb.js} +6260 -4294
  18. package/dist/index-D7oo0rd0.js +14235 -0
  19. package/dist/index.d.ts +9 -1
  20. package/dist/index.es-UDhZ1Ncp.js +5632 -0
  21. package/dist/jszip.min-I9rjwvpP.js +2341 -0
  22. package/dist/math/MathInputModeContext.d.ts +7 -0
  23. package/dist/math/TemplatePanel.d.ts +4 -1
  24. package/dist/math/mathFieldFontStyles.d.ts +7 -0
  25. package/dist/math/mathFieldSpaceKey.d.ts +10 -0
  26. package/dist/{tiptap-K3rU-Wjn.js → tiptap-BiWGiMFj.js} +27 -27
  27. package/dist/toolbar/MainToolbar.d.ts +3 -1
  28. package/dist/toolbar/MathToolbar.d.ts +9 -2
  29. package/dist/types/index.d.ts +18 -5
  30. package/dist/utils/docxImporter.d.ts +1 -0
  31. package/dist/utils/docxOmmlPreprocess.d.ts +12 -0
  32. package/dist/utils/imageFileValidation.d.ts +14 -0
  33. package/dist/utils/isLatexContent.d.ts +5 -0
  34. package/dist/utils/mathMlToLatex.d.ts +4 -0
  35. package/dist/utils/microsoftMathPaste.d.ts +43 -0
  36. package/dist/utils/ommlToLatex.d.ts +11 -0
  37. package/dist/utils/reuploadImagesInHTML.d.ts +9 -0
  38. package/dist/utils/sanitizeConfig.d.ts +11 -0
  39. package/dist/utils/unicodeMathToLatex.d.ts +24 -0
  40. package/dist/{viewer-deps-BDYoL2Ts.js → viewer-deps-_HnWniSt.js} +5 -0
  41. package/dist/viewer.js +1 -1
  42. package/package.json +23 -10
  43. package/dist/ContentViewer-RijJ5nlJ.js +0 -45
  44. package/dist/ImageInsertDialog-DbUscLs1.js +0 -244
  45. package/dist/components/__tests__/WordCount.test.d.ts +0 -1
  46. package/dist/core/__tests__/serializer.test.d.ts +0 -1
  47. package/dist/index-CVlS1KL8.js +0 -16549
  48. package/dist/viewer-styles.d.ts +0 -1
  49. package/dist/viewer-styles.js +0 -1
@@ -1,244 +0,0 @@
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
- onInsert: u,
8
- onImageUpload: f
9
- }) {
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
- 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 x = {
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 i = await a.slice(0, 8).arrayBuffer(), h = new Uint8Array(i), U = x[a.type];
30
- if (!U)
31
- return { valid: !1, error: "Format gambar tidak dikenali" };
32
- if (!U.some(
33
- (z) => z.every((J, V) => h[V] === J)
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
- }, k = o(
41
- async (a) => {
42
- const s = await I(a);
43
- if (!s.valid) {
44
- r(s.error);
45
- return;
46
- }
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
- try {
52
- const i = await f(a);
53
- if (!i)
54
- throw new Error("Upload gagal: URL tidak valid");
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);
59
- } finally {
60
- y(!1);
61
- }
62
- } else {
63
- const i = new FileReader();
64
- i.onload = () => {
65
- const h = i.result;
66
- u(h, g || a.name), n();
67
- }, i.readAsDataURL(a);
68
- }
69
- },
70
- [f, u, g, n]
71
- ), M = o(
72
- (a) => {
73
- const s = a.target.files?.[0];
74
- s && k(s);
75
- },
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(
82
- (a) => {
83
- a.preventDefault(), a.stopPropagation(), b(!1);
84
- const s = a.dataTransfer.files?.[0];
85
- s && k(s);
86
- },
87
- [k]
88
- ), B = o(() => {
89
- if (!t.trim()) {
90
- r("Masukkan URL gambar");
91
- return;
92
- }
93
- try {
94
- new URL(t);
95
- } catch {
96
- r("URL tidak valid");
97
- return;
98
- }
99
- u(t.trim(), g || void 0), n();
100
- }, [t, g, u, n]), W = o(() => {
101
- if (t.trim())
102
- try {
103
- new URL(t), c(t.trim()), r("");
104
- } catch {
105
- r("URL tidak valid");
106
- }
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" }),
113
- /* @__PURE__ */ e(
114
- "button",
115
- {
116
- className: "mtx-image-dialog__close",
117
- onClick: n,
118
- "aria-label": "Tutup",
119
- children: "✕"
120
- }
121
- )
122
- ] }),
123
- /* @__PURE__ */ l("div", { className: "mtx-image-dialog__tabs", children: [
124
- /* @__PURE__ */ e(
125
- "button",
126
- {
127
- className: `mtx-image-dialog__tab ${p === "upload" ? "is-active" : ""}`,
128
- onClick: () => {
129
- P("upload"), r(""), v(null), c(null);
130
- },
131
- children: "📁 Upload File"
132
- }
133
- ),
134
- /* @__PURE__ */ e(
135
- "button",
136
- {
137
- className: `mtx-image-dialog__tab ${p === "url" ? "is-active" : ""}`,
138
- onClick: () => {
139
- P("url"), r(""), v(null), c(null);
140
- },
141
- children: "🔗 URL"
142
- }
143
- )
144
- ] }),
145
- /* @__PURE__ */ l("div", { className: "mtx-image-dialog__body", children: [
146
- p === "upload" && /* @__PURE__ */ l(
147
- "div",
148
- {
149
- className: `mtx-image-dialog__dropzone ${T ? "is-dragging" : ""}`,
150
- onDragOver: O,
151
- onDragLeave: $,
152
- onDrop: K,
153
- onClick: () => E.current?.click(),
154
- children: [
155
- /* @__PURE__ */ e(
156
- "input",
157
- {
158
- ref: E,
159
- type: "file",
160
- accept: "image/*",
161
- onChange: M,
162
- style: { display: "none" }
163
- }
164
- ),
165
- A ? /* @__PURE__ */ l("div", { className: "mtx-image-dialog__uploading", children: [
166
- /* @__PURE__ */ e("div", { className: "mtx-spinner" }),
167
- /* @__PURE__ */ e("p", { children: "Mengupload gambar..." })
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: [
170
- /* @__PURE__ */ e("rect", { x: "4", y: "8", width: "40", height: "32", rx: "4" }),
171
- /* @__PURE__ */ e("circle", { cx: "16", cy: "20", r: "4" }),
172
- /* @__PURE__ */ e("path", { d: "M4 36l10-10 6 6 8-10 16 14" })
173
- ] }),
174
- /* @__PURE__ */ l("p", { children: [
175
- /* @__PURE__ */ e("strong", { children: "Klik untuk pilih file" }),
176
- " atau drag & drop ke sini"
177
- ] }),
178
- /* @__PURE__ */ e("span", { children: "JPG, PNG, GIF, WebP — Maks 10MB" })
179
- ] })
180
- ]
181
- }
182
- ),
183
- p === "url" && /* @__PURE__ */ l("div", { className: "mtx-image-dialog__url-form", children: [
184
- /* @__PURE__ */ e("label", { children: "URL Gambar" }),
185
- /* @__PURE__ */ e("div", { className: "mtx-image-dialog__url-row", children: /* @__PURE__ */ e(
186
- "input",
187
- {
188
- type: "url",
189
- value: t,
190
- onChange: (a) => C(a.target.value),
191
- placeholder: "https://example.com/gambar.jpg",
192
- onKeyDown: (a) => {
193
- a.key === "Enter" && B();
194
- },
195
- onBlur: W,
196
- autoFocus: !0
197
- }
198
- ) }),
199
- _ && /* @__PURE__ */ e("div", { className: "mtx-image-dialog__url-preview", children: /* @__PURE__ */ e(
200
- "img",
201
- {
202
- src: _,
203
- alt: "Preview",
204
- onError: () => {
205
- c(null), r("Gambar tidak dapat dimuat dari URL ini");
206
- }
207
- }
208
- ) })
209
- ] }),
210
- /* @__PURE__ */ l("div", { className: "mtx-image-dialog__alt", children: [
211
- /* @__PURE__ */ e("label", { children: "Teks Alternatif (opsional)" }),
212
- /* @__PURE__ */ e(
213
- "input",
214
- {
215
- type: "text",
216
- value: g,
217
- onChange: (a) => F(a.target.value),
218
- placeholder: "Deskripsi gambar untuk aksesibilitas"
219
- }
220
- )
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
- ] })
226
- ] }),
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" }),
229
- p === "url" && /* @__PURE__ */ e(
230
- "button",
231
- {
232
- className: "mtx-image-dialog__btn mtx-image-dialog__btn--insert",
233
- onClick: B,
234
- disabled: !t.trim(),
235
- children: "Sisipkan"
236
- }
237
- )
238
- ] })
239
- ] })
240
- ] }) : null;
241
- }
242
- export {
243
- ia as ImageInsertDialog
244
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export {};