erl-mathtextx-editor 0.2.0 → 0.2.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 +32 -0
- package/README.md +448 -453
- package/dist/{CellPropertiesDialogImpl-5BptFKaE.js → CellPropertiesDialogImpl-D-qjxrs5.js} +40 -40
- package/dist/{ImageInsertDialog-Cc7wpIjM.js → ImageInsertDialog-BUX79-_G.js} +1 -1
- package/dist/{InsertTableDialogImpl-BJFXRnQX.js → InsertTableDialogImpl-DfGvKwP4.js} +25 -25
- package/dist/{LinkDialogImpl-Cu032Nc7.js → LinkDialogImpl-BQEObyL2.js} +57 -57
- package/dist/MathTextXEditor.d.ts +1 -1
- package/dist/TablePropertiesDialogImpl-CDWcoc-Y.js +56 -0
- package/dist/TableTemplatesDialogImpl-BUSPvt83.js +64 -0
- package/dist/assets/erl-mathtextx-editor.css +1 -1
- package/dist/assets/viewer.css +1 -1
- package/dist/components/ImageEditDialog.d.ts +3 -0
- package/dist/components/useDraggable.d.ts +7 -0
- package/dist/core/serializer.d.ts +8 -0
- package/dist/erl-mathtextx-editor.js +1 -1
- package/dist/erl-mathtextx-editor.umd.cjs +178 -178
- package/dist/{index-D0Rzm7Tg.js → index-BHhpSW1p.js} +4656 -4825
- package/dist/{index-DJrUW7HG.js → index-D7JFZLgA.js} +1 -1
- package/dist/{index-C9scFI1r.js → index-DBnDkAIP.js} +1 -1
- package/dist/toolbar/toolbar-config.d.ts +22 -0
- package/dist/toolbar/toolbar-icons.d.ts +53 -0
- package/dist/toolbar/useDialogManager.d.ts +45 -0
- package/dist/useDraggable-DEoLIB5k.js +34 -0
- package/package.json +1 -1
- package/dist/TablePropertiesDialogImpl-YBNdKM7k.js +0 -56
- package/dist/TableTemplatesDialogImpl-P54y5q-u.js +0 -64
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
import { IconKey } from './toolbar-icons';
|
|
3
|
+
import { ToolbarMode } from '../types';
|
|
4
|
+
export interface ToolDef {
|
|
5
|
+
id: string;
|
|
6
|
+
icon: IconKey;
|
|
7
|
+
label: string;
|
|
8
|
+
action: (editor: Editor) => void;
|
|
9
|
+
isActive?: (editor: Editor) => boolean;
|
|
10
|
+
isDisabled?: (editor: Editor) => boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface ToolGroup {
|
|
13
|
+
id: string;
|
|
14
|
+
buttons: ToolDef[];
|
|
15
|
+
}
|
|
16
|
+
type ToolActions = Record<string, (editor: Editor) => void>;
|
|
17
|
+
export declare function createToolbarConfig(mode: ToolbarMode, actions: ToolActions): ToolGroup[];
|
|
18
|
+
export declare const fontOptions: {
|
|
19
|
+
value: string;
|
|
20
|
+
label: string;
|
|
21
|
+
}[];
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export declare const icons: {
|
|
2
|
+
bold: import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
italic: import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
underline: import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
strike: import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
h1: import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
h2: import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
h3: import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
h4: import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
paragraph: import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
bulletList: import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
orderedList: import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
taskList: import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
superscript: import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
subscript: import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
link: import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
image: import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
editImage: import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
table: import("react/jsx-runtime").JSX.Element;
|
|
20
|
+
rowAbove: import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
rowBelow: import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
columnLeft: import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
columnRight: import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
cellProperties: import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
deleteRow: import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
deleteColumn: import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
mergeCells: import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
splitCell: import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
headerRow: import("react/jsx-runtime").JSX.Element;
|
|
30
|
+
headerColumn: import("react/jsx-runtime").JSX.Element;
|
|
31
|
+
fixTable: import("react/jsx-runtime").JSX.Element;
|
|
32
|
+
graph: import("react/jsx-runtime").JSX.Element;
|
|
33
|
+
horizontalRule: import("react/jsx-runtime").JSX.Element;
|
|
34
|
+
blockquote: import("react/jsx-runtime").JSX.Element;
|
|
35
|
+
codeBlock: import("react/jsx-runtime").JSX.Element;
|
|
36
|
+
math: import("react/jsx-runtime").JSX.Element;
|
|
37
|
+
undo: import("react/jsx-runtime").JSX.Element;
|
|
38
|
+
redo: import("react/jsx-runtime").JSX.Element;
|
|
39
|
+
chemistry: import("react/jsx-runtime").JSX.Element;
|
|
40
|
+
download: import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
alignLeft: import("react/jsx-runtime").JSX.Element;
|
|
42
|
+
alignCenter: import("react/jsx-runtime").JSX.Element;
|
|
43
|
+
alignRight: import("react/jsx-runtime").JSX.Element;
|
|
44
|
+
alignJustify: import("react/jsx-runtime").JSX.Element;
|
|
45
|
+
indent: import("react/jsx-runtime").JSX.Element;
|
|
46
|
+
outdent: import("react/jsx-runtime").JSX.Element;
|
|
47
|
+
highlight: import("react/jsx-runtime").JSX.Element;
|
|
48
|
+
removeFormat: import("react/jsx-runtime").JSX.Element;
|
|
49
|
+
importDocx: import("react/jsx-runtime").JSX.Element;
|
|
50
|
+
tableDropdown: import("react/jsx-runtime").JSX.Element;
|
|
51
|
+
tableTemplates: import("react/jsx-runtime").JSX.Element;
|
|
52
|
+
};
|
|
53
|
+
export type IconKey = keyof typeof icons;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export type DialogId = 'link' | 'insertTable' | 'cellProperties' | 'tableProperties' | 'tableTemplates' | 'image' | 'imageEdit';
|
|
2
|
+
export interface CellPropertiesData {
|
|
3
|
+
width?: string;
|
|
4
|
+
backgroundColor?: string;
|
|
5
|
+
horizontalAlign?: 'left' | 'center' | 'right';
|
|
6
|
+
verticalAlign?: 'top' | 'middle' | 'bottom';
|
|
7
|
+
}
|
|
8
|
+
export interface TablePropertiesData {
|
|
9
|
+
align?: 'left' | 'center' | 'right';
|
|
10
|
+
}
|
|
11
|
+
export interface TableTemplate {
|
|
12
|
+
id: string;
|
|
13
|
+
}
|
|
14
|
+
export interface ImageEditData {
|
|
15
|
+
width: number | string;
|
|
16
|
+
height: number | string;
|
|
17
|
+
align: 'left' | 'center' | 'right' | 'full';
|
|
18
|
+
alt: string;
|
|
19
|
+
title: string;
|
|
20
|
+
maintainAspectRatio: boolean;
|
|
21
|
+
naturalWidth?: number;
|
|
22
|
+
naturalHeight?: number;
|
|
23
|
+
}
|
|
24
|
+
interface DialogState {
|
|
25
|
+
link: boolean;
|
|
26
|
+
insertTable: boolean;
|
|
27
|
+
cellProperties: boolean;
|
|
28
|
+
tableProperties: boolean;
|
|
29
|
+
tableTemplates: boolean;
|
|
30
|
+
image: boolean;
|
|
31
|
+
imageEdit: boolean;
|
|
32
|
+
}
|
|
33
|
+
export declare function useDialogManager(): {
|
|
34
|
+
open: DialogState;
|
|
35
|
+
show: (id: DialogId) => boolean;
|
|
36
|
+
openDialog: (id: DialogId) => void;
|
|
37
|
+
closeDialog: (id: DialogId) => void;
|
|
38
|
+
cellData: CellPropertiesData;
|
|
39
|
+
setCellData: import('react').Dispatch<import('react').SetStateAction<CellPropertiesData>>;
|
|
40
|
+
tableData: TablePropertiesData;
|
|
41
|
+
setTableData: import('react').Dispatch<import('react').SetStateAction<TablePropertiesData>>;
|
|
42
|
+
imageEditData: ImageEditData | null;
|
|
43
|
+
setImageEditData: import('react').Dispatch<import('react').SetStateAction<ImageEditData | null>>;
|
|
44
|
+
};
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useState as x, useRef as l, useEffect as g, useCallback as D } from "react";
|
|
2
|
+
function X(o) {
|
|
3
|
+
const [n, c] = x({ x: 0, y: 0 }), r = l({ x: 0, y: 0 }), t = l({ startX: 0, startY: 0, isDragging: !1 });
|
|
4
|
+
g(() => {
|
|
5
|
+
r.current = n;
|
|
6
|
+
}, [n]), g(() => {
|
|
7
|
+
o || c({ x: 0, y: 0 });
|
|
8
|
+
}, [o]);
|
|
9
|
+
const d = D((e) => {
|
|
10
|
+
const s = e.target;
|
|
11
|
+
if (s.closest("button") || s.closest("input") || s.closest("select") || s.closest("a"))
|
|
12
|
+
return;
|
|
13
|
+
e.preventDefault(), t.current = {
|
|
14
|
+
isDragging: !0,
|
|
15
|
+
startX: e.clientX,
|
|
16
|
+
startY: e.clientY
|
|
17
|
+
};
|
|
18
|
+
const m = r.current.x, f = r.current.y, u = (i) => {
|
|
19
|
+
if (!t.current.isDragging) return;
|
|
20
|
+
const v = i.clientX - t.current.startX, p = i.clientY - t.current.startY;
|
|
21
|
+
c({
|
|
22
|
+
x: m + v,
|
|
23
|
+
y: f + p
|
|
24
|
+
});
|
|
25
|
+
}, a = () => {
|
|
26
|
+
t.current.isDragging = !1, document.removeEventListener("mousemove", u), document.removeEventListener("mouseup", a);
|
|
27
|
+
};
|
|
28
|
+
document.addEventListener("mousemove", u), document.addEventListener("mouseup", a);
|
|
29
|
+
}, []);
|
|
30
|
+
return { position: n, handleMouseDown: d };
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
X as u
|
|
34
|
+
};
|
package/package.json
CHANGED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { jsx as t, jsxs as l } from "react/jsx-runtime";
|
|
2
|
-
import u, { useId as v, useRef as g, useState as x, useEffect as p, useCallback as d } from "react";
|
|
3
|
-
import { u as f } from "./index-D0Rzm7Tg.js";
|
|
4
|
-
const N = u.memo(({
|
|
5
|
-
isOpen: r,
|
|
6
|
-
initialData: n = {},
|
|
7
|
-
onSave: m,
|
|
8
|
-
onClose: e
|
|
9
|
-
}) => {
|
|
10
|
-
const c = v(), s = g(null), [i, a] = x(n.align || "left");
|
|
11
|
-
p(() => {
|
|
12
|
-
r && a(n.align || "left");
|
|
13
|
-
}, [n, r]), f({ isOpen: r, dialogRef: s, onClose: e });
|
|
14
|
-
const h = d((o) => {
|
|
15
|
-
o.preventDefault(), m({ align: i }), e();
|
|
16
|
-
}, [i, m, e]), b = d(() => {
|
|
17
|
-
a("left");
|
|
18
|
-
}, []);
|
|
19
|
-
return r ? /* @__PURE__ */ t("div", { className: "mtx-modal-overlay", onClick: e, children: /* @__PURE__ */ l(
|
|
20
|
-
"div",
|
|
21
|
-
{
|
|
22
|
-
ref: s,
|
|
23
|
-
className: "mtx-modal-dialog mtx-table-properties-dialog",
|
|
24
|
-
onClick: (o) => o.stopPropagation(),
|
|
25
|
-
role: "dialog",
|
|
26
|
-
"aria-modal": "true",
|
|
27
|
-
"aria-labelledby": c,
|
|
28
|
-
tabIndex: -1,
|
|
29
|
-
children: [
|
|
30
|
-
/* @__PURE__ */ l("div", { className: "mtx-modal-header", children: [
|
|
31
|
-
/* @__PURE__ */ t("h3", { className: "mtx-modal-title", id: c, children: "Table Properties" }),
|
|
32
|
-
/* @__PURE__ */ t("button", { className: "mtx-modal-close", onClick: e, 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" }) }) })
|
|
33
|
-
] }),
|
|
34
|
-
/* @__PURE__ */ l("form", { onSubmit: h, children: [
|
|
35
|
-
/* @__PURE__ */ t("div", { className: "mtx-modal-body", children: /* @__PURE__ */ l("div", { className: "mtx-form-group", children: [
|
|
36
|
-
/* @__PURE__ */ t("label", { className: "mtx-form-label", children: "Table Alignment" }),
|
|
37
|
-
/* @__PURE__ */ l("div", { className: "mtx-align-buttons", children: [
|
|
38
|
-
/* @__PURE__ */ t("button", { type: "button", className: `mtx-align-btn ${i === "left" ? "is-active" : ""}`, onClick: () => a("left"), title: "Align Left", children: /* @__PURE__ */ t("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ t("path", { d: "M2 3h12v1.5H2V3zm0 4h8v1.5H2V7zm0 4h12v1.5H2v-1.5zM2 11h6v1.5H2V11z" }) }) }),
|
|
39
|
-
/* @__PURE__ */ t("button", { type: "button", className: `mtx-align-btn ${i === "center" ? "is-active" : ""}`, onClick: () => a("center"), title: "Align Center", children: /* @__PURE__ */ t("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ t("path", { d: "M2 3h12v1.5H2V3zm3 4h6v1.5H5V7zm-3 4h12v1.5H2v-1.5zM5 11h6v1.5H5V11z" }) }) }),
|
|
40
|
-
/* @__PURE__ */ t("button", { type: "button", className: `mtx-align-btn ${i === "right" ? "is-active" : ""}`, onClick: () => a("right"), title: "Align Right", children: /* @__PURE__ */ t("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "currentColor", children: /* @__PURE__ */ t("path", { d: "M2 3h12v1.5H2V3zm6 4h6v1.5H8V7zM2 11h12v1.5H2v-1.5zm6-4h6v1.5H8V7z" }) }) })
|
|
41
|
-
] })
|
|
42
|
-
] }) }),
|
|
43
|
-
/* @__PURE__ */ l("div", { className: "mtx-modal-footer", children: [
|
|
44
|
-
/* @__PURE__ */ t("button", { type: "button", className: "mtx-btn mtx-btn-secondary", onClick: b, children: "Reset" }),
|
|
45
|
-
/* @__PURE__ */ t("button", { type: "button", className: "mtx-btn mtx-btn-secondary", onClick: e, children: "Cancel" }),
|
|
46
|
-
/* @__PURE__ */ t("button", { type: "submit", className: "mtx-btn mtx-btn-primary", children: "Apply" })
|
|
47
|
-
] })
|
|
48
|
-
] })
|
|
49
|
-
]
|
|
50
|
-
}
|
|
51
|
-
) }) : null;
|
|
52
|
-
});
|
|
53
|
-
N.displayName = "TablePropertiesDialogImpl";
|
|
54
|
-
export {
|
|
55
|
-
N as TablePropertiesDialogImpl
|
|
56
|
-
};
|
|
@@ -1,64 +0,0 @@
|
|
|
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-D0Rzm7Tg.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-table-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
|
-
};
|