erl-mathtextx-editor 0.1.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.
Files changed (62) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +251 -0
  3. package/dist/CellPropertiesDialogImpl-CgWcr4bD.js +101 -0
  4. package/dist/ContentViewer-DcvxXP9t.js +43 -0
  5. package/dist/ImageInsertDialog-Di0MXcC2.js +222 -0
  6. package/dist/InsertTableDialogImpl-CKirXRqE.js +100 -0
  7. package/dist/LinkDialogImpl-BSz0F-xG.js +136 -0
  8. package/dist/MathTextXEditor.d.ts +8 -0
  9. package/dist/TableTemplatesDialogImpl-DrdqLQLH.js +64 -0
  10. package/dist/TemplatePanel-BE_UfzYM.js +710 -0
  11. package/dist/assets/erl-mathtextx-editor.css +1 -0
  12. package/dist/assets/viewer.css +1 -0
  13. package/dist/components/CellPropertiesDialog.d.ts +4 -0
  14. package/dist/components/CellPropertiesDialogImpl.d.ts +14 -0
  15. package/dist/components/GraphComponent.d.ts +3 -0
  16. package/dist/components/ImageContextMenu.d.ts +18 -0
  17. package/dist/components/ImageEditDialog.d.ts +25 -0
  18. package/dist/components/ImageInsertDialog.d.ts +14 -0
  19. package/dist/components/ImageNodeView.d.ts +3 -0
  20. package/dist/components/InsertTableDialog.d.ts +4 -0
  21. package/dist/components/InsertTableDialogImpl.d.ts +7 -0
  22. package/dist/components/LinkDialog.d.ts +4 -0
  23. package/dist/components/LinkDialogImpl.d.ts +18 -0
  24. package/dist/components/TableMenu.d.ts +21 -0
  25. package/dist/components/TableTemplatesDialog.d.ts +4 -0
  26. package/dist/components/TableTemplatesDialogImpl.d.ts +15 -0
  27. package/dist/components/WordCount.d.ts +6 -0
  28. package/dist/components/__tests__/WordCount.test.d.ts +1 -0
  29. package/dist/components/tableTemplateStyles.d.ts +2 -0
  30. package/dist/components/useDialogA11y.d.ts +6 -0
  31. package/dist/components/wordCountUtils.d.ts +3 -0
  32. package/dist/core/__tests__/serializer.test.d.ts +1 -0
  33. package/dist/core/extensions.d.ts +9 -0
  34. package/dist/core/serializer.d.ts +24 -0
  35. package/dist/erl-mathtextx-editor.js +30 -0
  36. package/dist/erl-mathtextx-editor.umd.cjs +3508 -0
  37. package/dist/extensions/GraphExtension.d.ts +9 -0
  38. package/dist/index-CLGg8QXp.js +8700 -0
  39. package/dist/index-DYxMVo98.js +4599 -0
  40. package/dist/index.d.ts +33 -0
  41. package/dist/math/MathNodes.d.ts +11 -0
  42. package/dist/math/MathTypeDialog.d.ts +8 -0
  43. package/dist/math/MatrixGridSelector.d.ts +5 -0
  44. package/dist/math/SymbolPalette.d.ts +5 -0
  45. package/dist/math/TemplatePanel.d.ts +5 -0
  46. package/dist/mathlive-BwNIIOwE.js +14488 -0
  47. package/dist/templates/index.d.ts +17 -0
  48. package/dist/tiptap-BhJ7Fu9S.js +17927 -0
  49. package/dist/toolbar/MainToolbar.d.ts +14 -0
  50. package/dist/toolbar/MathToolbar.d.ts +7 -0
  51. package/dist/types/index.d.ts +73 -0
  52. package/dist/utils/exportUtils.d.ts +19 -0
  53. package/dist/utils/pasteHandler.d.ts +17 -0
  54. package/dist/viewer/ContentViewer.d.ts +29 -0
  55. package/dist/viewer/index.d.ts +2 -0
  56. package/dist/viewer/styles.d.ts +0 -0
  57. package/dist/viewer-deps-xNPNdmbe.js +12141 -0
  58. package/dist/viewer-styles.d.ts +1 -0
  59. package/dist/viewer-styles.js +1 -0
  60. package/dist/viewer.d.ts +2 -0
  61. package/dist/viewer.js +4 -0
  62. package/package.json +132 -0
@@ -0,0 +1,100 @@
1
+ import { jsx as e, jsxs as t } from "react/jsx-runtime";
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";
4
+ const k = N.memo(({ isOpen: i, onInsert: d, onClose: m }) => {
5
+ const b = v(), u = f(null), [l, n] = c(3), [a, s] = c(3), [o, h] = c(!0);
6
+ g(() => {
7
+ i && (n(3), s(3), h(!0));
8
+ }, [i]), y({ isOpen: i, dialogRef: u, onClose: m });
9
+ const x = w((r) => {
10
+ r.preventDefault(), d(l, a, o), m();
11
+ }, [l, a, o, d, m]);
12
+ return i ? /* @__PURE__ */ e("div", { className: "mtx-modal-overlay", onClick: m, children: /* @__PURE__ */ t(
13
+ "div",
14
+ {
15
+ ref: u,
16
+ className: "mtx-modal-dialog mtx-insert-table-dialog",
17
+ onClick: (r) => r.stopPropagation(),
18
+ role: "dialog",
19
+ "aria-modal": "true",
20
+ "aria-labelledby": b,
21
+ tabIndex: -1,
22
+ children: [
23
+ /* @__PURE__ */ t("div", { className: "mtx-modal-header", children: [
24
+ /* @__PURE__ */ e("h3", { className: "mtx-modal-title", id: b, children: "Insert Table" }),
25
+ /* @__PURE__ */ e("button", { className: "mtx-modal-close", onClick: m, title: "Close", "aria-label": "Close dialog", children: /* @__PURE__ */ e("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ e("path", { d: "M4 4l8 8m0-8l-8 8", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }) }) })
26
+ ] }),
27
+ /* @__PURE__ */ t("form", { onSubmit: x, children: [
28
+ /* @__PURE__ */ t("div", { className: "mtx-modal-body", children: [
29
+ /* @__PURE__ */ t("div", { className: "mtx-form-group", children: [
30
+ /* @__PURE__ */ t("label", { className: "mtx-form-label", htmlFor: "table-rows", children: [
31
+ "Rows",
32
+ /* @__PURE__ */ e("span", { className: "mtx-form-hint", children: "(1-10)" })
33
+ ] }),
34
+ /* @__PURE__ */ t("div", { className: "mtx-number-input-wrapper", children: [
35
+ /* @__PURE__ */ e("button", { type: "button", className: "mtx-number-btn", onClick: () => n(Math.max(1, l - 1)), disabled: l <= 1, children: "−" }),
36
+ /* @__PURE__ */ e(
37
+ "input",
38
+ {
39
+ id: "table-rows",
40
+ type: "number",
41
+ className: "mtx-form-input mtx-number-input",
42
+ value: l,
43
+ onChange: (r) => n(Math.min(10, Math.max(1, parseInt(r.target.value) || 1))),
44
+ min: "1",
45
+ max: "10",
46
+ autoFocus: !0
47
+ }
48
+ ),
49
+ /* @__PURE__ */ e("button", { type: "button", className: "mtx-number-btn", onClick: () => n(Math.min(10, l + 1)), disabled: l >= 10, children: "+" })
50
+ ] })
51
+ ] }),
52
+ /* @__PURE__ */ t("div", { className: "mtx-form-group", children: [
53
+ /* @__PURE__ */ t("label", { className: "mtx-form-label", htmlFor: "table-cols", children: [
54
+ "Columns",
55
+ /* @__PURE__ */ e("span", { className: "mtx-form-hint", children: "(1-10)" })
56
+ ] }),
57
+ /* @__PURE__ */ t("div", { className: "mtx-number-input-wrapper", children: [
58
+ /* @__PURE__ */ e("button", { type: "button", className: "mtx-number-btn", onClick: () => s(Math.max(1, a - 1)), disabled: a <= 1, children: "−" }),
59
+ /* @__PURE__ */ e(
60
+ "input",
61
+ {
62
+ id: "table-cols",
63
+ type: "number",
64
+ className: "mtx-form-input mtx-number-input",
65
+ value: a,
66
+ onChange: (r) => s(Math.min(10, Math.max(1, parseInt(r.target.value) || 1))),
67
+ min: "1",
68
+ max: "10"
69
+ }
70
+ ),
71
+ /* @__PURE__ */ e("button", { type: "button", className: "mtx-number-btn", onClick: () => s(Math.min(10, a + 1)), disabled: a >= 10, children: "+" })
72
+ ] })
73
+ ] }),
74
+ /* @__PURE__ */ e("div", { className: "mtx-form-group mtx-form-checkbox", children: /* @__PURE__ */ t("label", { className: "mtx-checkbox-label", children: [
75
+ /* @__PURE__ */ e("input", { type: "checkbox", checked: o, onChange: (r) => h(r.target.checked) }),
76
+ /* @__PURE__ */ e("span", { children: "Include header row" })
77
+ ] }) }),
78
+ /* @__PURE__ */ t("div", { className: "mtx-table-preview", children: [
79
+ /* @__PURE__ */ t("div", { className: "mtx-table-preview-label", children: [
80
+ "Preview: ",
81
+ l,
82
+ "x",
83
+ a
84
+ ] }),
85
+ /* @__PURE__ */ e("div", { className: "mtx-table-preview-grid", style: { display: "grid", gridTemplateColumns: `repeat(${a}, 1fr)`, gridTemplateRows: `repeat(${l}, 1fr)` }, children: Array.from({ length: l * a }).map((r, p) => /* @__PURE__ */ e("div", { className: `mtx-preview-cell${o && p < a ? " mtx-preview-header" : ""}` }, p)) })
86
+ ] })
87
+ ] }),
88
+ /* @__PURE__ */ t("div", { className: "mtx-modal-footer", children: [
89
+ /* @__PURE__ */ e("button", { type: "button", className: "mtx-btn mtx-btn-secondary", onClick: m, children: "Cancel" }),
90
+ /* @__PURE__ */ e("button", { type: "submit", className: "mtx-btn mtx-btn-primary", children: "Insert Table" })
91
+ ] })
92
+ ] })
93
+ ]
94
+ }
95
+ ) }) : null;
96
+ });
97
+ k.displayName = "InsertTableDialogImpl";
98
+ export {
99
+ k as InsertTableDialogImpl
100
+ };
@@ -0,0 +1,136 @@
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(({
5
+ isOpen: m,
6
+ currentUrl: i = "",
7
+ currentText: c = "",
8
+ currentTitle: u = "",
9
+ currentTarget: p = "_blank",
10
+ onInsert: g,
11
+ onRemove: r,
12
+ onClose: o
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) => {
19
+ const l = e.trim();
20
+ return l.startsWith("http://") || l.startsWith("https://") || l.startsWith("mailto:") || l.startsWith("#") ? l : `https://${l}`;
21
+ }, []), _ = h((e) => {
22
+ e.preventDefault();
23
+ const l = W(x);
24
+ D(l) && g({
25
+ url: l,
26
+ text: k.trim() || void 0,
27
+ title: f.trim() || void 0,
28
+ target: b || void 0
29
+ });
30
+ }, [x, k, f, b, D, W, g]), w = h(() => {
31
+ r == null || r(), o();
32
+ }, [r, o]);
33
+ return m ? /* @__PURE__ */ t("div", { className: "mtx-modal-overlay", onClick: o, children: /* @__PURE__ */ a(
34
+ "div",
35
+ {
36
+ ref: v,
37
+ className: "mtx-modal-dialog mtx-link-dialog",
38
+ onClick: (e) => e.stopPropagation(),
39
+ role: "dialog",
40
+ "aria-modal": "true",
41
+ "aria-labelledby": N,
42
+ tabIndex: -1,
43
+ children: [
44
+ /* @__PURE__ */ a("div", { className: "mtx-modal-header", children: [
45
+ /* @__PURE__ */ t("h3", { className: "mtx-modal-title", id: N, children: i ? "Edit Link" : "Insert Link" }),
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
+ ] }),
48
+ /* @__PURE__ */ a("form", { onSubmit: _, children: [
49
+ /* @__PURE__ */ a("div", { className: "mtx-modal-body", children: [
50
+ /* @__PURE__ */ a("div", { className: "mtx-form-group", children: [
51
+ /* @__PURE__ */ a("label", { className: "mtx-form-label", htmlFor: "link-url", children: [
52
+ "URL ",
53
+ /* @__PURE__ */ t("span", { className: "mtx-required", children: "*" })
54
+ ] }),
55
+ /* @__PURE__ */ t(
56
+ "input",
57
+ {
58
+ id: "link-url",
59
+ type: "text",
60
+ className: `mtx-form-input ${d ? "mtx-input-error" : ""}`,
61
+ value: x,
62
+ onChange: (e) => {
63
+ y(e.target.value), d && n("");
64
+ },
65
+ placeholder: "https://example.com",
66
+ autoFocus: !0,
67
+ autoComplete: "url"
68
+ }
69
+ ),
70
+ d && /* @__PURE__ */ t("div", { className: "mtx-form-error", children: d })
71
+ ] }),
72
+ /* @__PURE__ */ a("div", { className: "mtx-form-group", children: [
73
+ /* @__PURE__ */ a("label", { className: "mtx-form-label", htmlFor: "link-text", children: [
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)" })
76
+ ] }),
77
+ /* @__PURE__ */ t(
78
+ "input",
79
+ {
80
+ id: "link-text",
81
+ type: "text",
82
+ className: "mtx-form-input",
83
+ value: k,
84
+ onChange: (e) => C(e.target.value),
85
+ placeholder: "Click here",
86
+ autoComplete: "off"
87
+ }
88
+ )
89
+ ] }),
90
+ /* @__PURE__ */ a("div", { className: "mtx-form-group", children: [
91
+ /* @__PURE__ */ a("label", { className: "mtx-form-label", htmlFor: "link-title", children: [
92
+ "Title (Tooltip)",
93
+ /* @__PURE__ */ t("span", { className: "mtx-form-hint", children: "Teks yang muncul saat hover" })
94
+ ] }),
95
+ /* @__PURE__ */ t(
96
+ "input",
97
+ {
98
+ id: "link-title",
99
+ type: "text",
100
+ className: "mtx-form-input",
101
+ value: f,
102
+ onChange: (e) => L(e.target.value),
103
+ placeholder: "Visit our website",
104
+ autoComplete: "off"
105
+ }
106
+ )
107
+ ] }),
108
+ /* @__PURE__ */ t("div", { className: "mtx-form-group mtx-form-checkbox", children: /* @__PURE__ */ a("label", { className: "mtx-checkbox-label", children: [
109
+ /* @__PURE__ */ t(
110
+ "input",
111
+ {
112
+ type: "checkbox",
113
+ checked: b === "_blank",
114
+ onChange: (e) => I(e.target.checked ? "_blank" : "_self")
115
+ }
116
+ ),
117
+ /* @__PURE__ */ t("span", { children: "Open in new tab" })
118
+ ] }) })
119
+ ] }),
120
+ /* @__PURE__ */ a("div", { className: "mtx-modal-footer", children: [
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" }),
123
+ /* @__PURE__ */ a("button", { type: "submit", className: "mtx-btn mtx-btn-primary", children: [
124
+ i ? "Update" : "Insert",
125
+ " Link"
126
+ ] })
127
+ ] })
128
+ ] })
129
+ ]
130
+ }
131
+ ) }) : null;
132
+ });
133
+ R.displayName = "LinkDialogImpl";
134
+ export {
135
+ R as LinkDialogImpl
136
+ };
@@ -0,0 +1,8 @@
1
+ import { MathTextXEditorProps } from './types';
2
+ /**
3
+ * MathTextX Editor — Visual math editor React component.
4
+ *
5
+ * Drop-in replacement for CKEditor in solutest.id.
6
+ * Supports rich text formatting and visual math input without LaTeX.
7
+ */
8
+ export declare function MathTextXEditor({ content, onChange, onSave, editable, placeholder, toolbarMode, className, minHeight, maxHeight, autoFocus, onImageUpload, }: MathTextXEditorProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,64 @@
1
+ import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
+ import o, { useId as c, useRef as n, useCallback as p } from "react";
3
+ import { u as h } from "./index-DYxMVo98.js";
4
+ const x = [
5
+ { id: "plain", name: "Plain", description: "Simple table without styling", headerStyle: "none", borderStyle: "all", stripeRows: !1 },
6
+ { id: "light", name: "Light", description: "Light gray header", headerStyle: "light", borderStyle: "all", stripeRows: !1 },
7
+ { id: "dark", name: "Dark", description: "Dark header with white text", headerStyle: "dark", borderStyle: "horizontal", stripeRows: !1 },
8
+ { id: "blue", name: "Blue Theme", description: "Blue header with striped rows", headerStyle: "blue", borderStyle: "horizontal", stripeRows: !0 },
9
+ { id: "striped", name: "Striped", description: "Alternating row colors", headerStyle: "light", borderStyle: "none", stripeRows: !0 },
10
+ { id: "minimal", name: "Minimal", description: "Only horizontal borders", headerStyle: "none", borderStyle: "horizontal", stripeRows: !1 }
11
+ ], b = o.memo(({ isOpen: i, onSelect: m, onClose: a }) => {
12
+ const r = c(), d = n(null), s = p((l) => {
13
+ m(l), a();
14
+ }, [m, a]);
15
+ return h({ isOpen: i, dialogRef: d, onClose: a }), i ? /* @__PURE__ */ e("div", { className: "mtx-modal-overlay", onClick: a, children: /* @__PURE__ */ t(
16
+ "div",
17
+ {
18
+ ref: d,
19
+ className: "mtx-modal-dialog mtx-table-templates-dialog",
20
+ onClick: (l) => l.stopPropagation(),
21
+ role: "dialog",
22
+ "aria-modal": "true",
23
+ "aria-labelledby": r,
24
+ tabIndex: -1,
25
+ children: [
26
+ /* @__PURE__ */ t("div", { className: "mtx-modal-header", children: [
27
+ /* @__PURE__ */ e("h3", { className: "mtx-modal-title", id: r, children: "Table Templates" }),
28
+ /* @__PURE__ */ e("button", { className: "mtx-modal-close", onClick: a, title: "Close", "aria-label": "Close dialog", children: /* @__PURE__ */ e("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ e("path", { d: "M4 4l8 8m0-8l-8 8", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }) }) })
29
+ ] }),
30
+ /* @__PURE__ */ t("div", { className: "mtx-modal-body", children: [
31
+ /* @__PURE__ */ e("p", { className: "mtx-template-dialog-hint", children: "Pilih template untuk diterapkan ke tabel yang sedang dipilih." }),
32
+ /* @__PURE__ */ e("div", { className: "mtx-templates-grid", children: x.map((l) => /* @__PURE__ */ t("button", { type: "button", className: "mtx-template-card", onClick: () => s(l), children: [
33
+ /* @__PURE__ */ e("div", { className: "mtx-template-preview", children: /* @__PURE__ */ t("div", { className: `mtx-template-table mtx-template-${l.id}`, children: [
34
+ /* @__PURE__ */ t("div", { className: "mtx-template-row", children: [
35
+ /* @__PURE__ */ e("div", { className: "mtx-template-cell mtx-template-header" }),
36
+ /* @__PURE__ */ e("div", { className: "mtx-template-cell mtx-template-header" }),
37
+ /* @__PURE__ */ e("div", { className: "mtx-template-cell mtx-template-header" })
38
+ ] }),
39
+ /* @__PURE__ */ t("div", { className: "mtx-template-row", children: [
40
+ /* @__PURE__ */ e("div", { className: "mtx-template-cell" }),
41
+ /* @__PURE__ */ e("div", { className: "mtx-template-cell" }),
42
+ /* @__PURE__ */ e("div", { className: "mtx-template-cell" })
43
+ ] }),
44
+ /* @__PURE__ */ t("div", { className: "mtx-template-row", children: [
45
+ /* @__PURE__ */ e("div", { className: "mtx-template-cell" }),
46
+ /* @__PURE__ */ e("div", { className: "mtx-template-cell" }),
47
+ /* @__PURE__ */ e("div", { className: "mtx-template-cell" })
48
+ ] })
49
+ ] }) }),
50
+ /* @__PURE__ */ t("div", { className: "mtx-template-info", children: [
51
+ /* @__PURE__ */ e("h4", { className: "mtx-template-name", children: l.name }),
52
+ /* @__PURE__ */ e("p", { className: "mtx-template-description", children: l.description })
53
+ ] })
54
+ ] }, l.id)) })
55
+ ] }),
56
+ /* @__PURE__ */ e("div", { className: "mtx-modal-footer", children: /* @__PURE__ */ e("button", { type: "button", className: "mtx-btn mtx-btn-secondary", onClick: a, children: "Cancel" }) })
57
+ ]
58
+ }
59
+ ) }) : null;
60
+ });
61
+ b.displayName = "TableTemplatesDialogImpl";
62
+ export {
63
+ b as TableTemplatesDialogImpl
64
+ };