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.
- package/LICENSE +21 -0
- package/README.md +251 -0
- package/dist/CellPropertiesDialogImpl-CgWcr4bD.js +101 -0
- package/dist/ContentViewer-DcvxXP9t.js +43 -0
- package/dist/ImageInsertDialog-Di0MXcC2.js +222 -0
- package/dist/InsertTableDialogImpl-CKirXRqE.js +100 -0
- package/dist/LinkDialogImpl-BSz0F-xG.js +136 -0
- package/dist/MathTextXEditor.d.ts +8 -0
- package/dist/TableTemplatesDialogImpl-DrdqLQLH.js +64 -0
- package/dist/TemplatePanel-BE_UfzYM.js +710 -0
- package/dist/assets/erl-mathtextx-editor.css +1 -0
- package/dist/assets/viewer.css +1 -0
- package/dist/components/CellPropertiesDialog.d.ts +4 -0
- package/dist/components/CellPropertiesDialogImpl.d.ts +14 -0
- package/dist/components/GraphComponent.d.ts +3 -0
- package/dist/components/ImageContextMenu.d.ts +18 -0
- package/dist/components/ImageEditDialog.d.ts +25 -0
- package/dist/components/ImageInsertDialog.d.ts +14 -0
- package/dist/components/ImageNodeView.d.ts +3 -0
- package/dist/components/InsertTableDialog.d.ts +4 -0
- package/dist/components/InsertTableDialogImpl.d.ts +7 -0
- package/dist/components/LinkDialog.d.ts +4 -0
- package/dist/components/LinkDialogImpl.d.ts +18 -0
- package/dist/components/TableMenu.d.ts +21 -0
- package/dist/components/TableTemplatesDialog.d.ts +4 -0
- package/dist/components/TableTemplatesDialogImpl.d.ts +15 -0
- package/dist/components/WordCount.d.ts +6 -0
- package/dist/components/__tests__/WordCount.test.d.ts +1 -0
- package/dist/components/tableTemplateStyles.d.ts +2 -0
- package/dist/components/useDialogA11y.d.ts +6 -0
- package/dist/components/wordCountUtils.d.ts +3 -0
- package/dist/core/__tests__/serializer.test.d.ts +1 -0
- package/dist/core/extensions.d.ts +9 -0
- package/dist/core/serializer.d.ts +24 -0
- package/dist/erl-mathtextx-editor.js +30 -0
- package/dist/erl-mathtextx-editor.umd.cjs +3508 -0
- package/dist/extensions/GraphExtension.d.ts +9 -0
- package/dist/index-CLGg8QXp.js +8700 -0
- package/dist/index-DYxMVo98.js +4599 -0
- package/dist/index.d.ts +33 -0
- package/dist/math/MathNodes.d.ts +11 -0
- package/dist/math/MathTypeDialog.d.ts +8 -0
- package/dist/math/MatrixGridSelector.d.ts +5 -0
- package/dist/math/SymbolPalette.d.ts +5 -0
- package/dist/math/TemplatePanel.d.ts +5 -0
- package/dist/mathlive-BwNIIOwE.js +14488 -0
- package/dist/templates/index.d.ts +17 -0
- package/dist/tiptap-BhJ7Fu9S.js +17927 -0
- package/dist/toolbar/MainToolbar.d.ts +14 -0
- package/dist/toolbar/MathToolbar.d.ts +7 -0
- package/dist/types/index.d.ts +73 -0
- package/dist/utils/exportUtils.d.ts +19 -0
- package/dist/utils/pasteHandler.d.ts +17 -0
- package/dist/viewer/ContentViewer.d.ts +29 -0
- package/dist/viewer/index.d.ts +2 -0
- package/dist/viewer/styles.d.ts +0 -0
- package/dist/viewer-deps-xNPNdmbe.js +12141 -0
- package/dist/viewer-styles.d.ts +1 -0
- package/dist/viewer-styles.js +1 -0
- package/dist/viewer.d.ts +2 -0
- package/dist/viewer.js +4 -0
- package/package.json +132 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { Editor } from '@tiptap/react';
|
|
3
|
+
import { ToolbarMode } from '../types';
|
|
4
|
+
interface MainToolbarProps {
|
|
5
|
+
editor: Editor | null;
|
|
6
|
+
toolbarMode?: ToolbarMode;
|
|
7
|
+
onInsertMath?: (tab?: string) => void;
|
|
8
|
+
onInsertImage?: () => void;
|
|
9
|
+
onEditImage?: () => void;
|
|
10
|
+
onSetImageAlign?: (align: 'left' | 'center' | 'right' | 'full') => void;
|
|
11
|
+
onResetImagePosition?: () => void;
|
|
12
|
+
}
|
|
13
|
+
export declare const MainToolbar: React.NamedExoticComponent<MainToolbarProps>;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
interface MathToolbarProps {
|
|
2
|
+
onInsertLatex: (latex: string) => void;
|
|
3
|
+
onToggleSymbols: () => void;
|
|
4
|
+
onToggleTemplates?: () => void;
|
|
5
|
+
}
|
|
6
|
+
export declare function MathToolbar({ onInsertLatex, onToggleSymbols, onToggleTemplates }: MathToolbarProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
/** Toolbar item identifiers */
|
|
3
|
+
export type ToolbarItem = 'bold' | 'italic' | 'underline' | 'strike' | 'heading' | 'bulletList' | 'orderedList' | 'taskList' | 'codeBlock' | 'blockquote' | 'horizontalRule' | 'link' | 'image' | 'table' | 'subscript' | 'superscript' | 'math' | 'undo' | 'redo' | 'divider';
|
|
4
|
+
/** Math toolbar item identifiers */
|
|
5
|
+
export type MathToolbarItem = 'fraction' | 'sqrt' | 'power' | 'subscriptMath' | 'sum' | 'integral' | 'limit' | 'matrix' | 'symbols' | 'templates';
|
|
6
|
+
/** Education level for formula templates */
|
|
7
|
+
export type EducationLevel = 'sd' | 'smp' | 'sma' | 'all';
|
|
8
|
+
/** Output format */
|
|
9
|
+
export type OutputFormat = 'html' | 'json';
|
|
10
|
+
/** Toolbar density mode */
|
|
11
|
+
export type ToolbarMode = 'basic' | 'advanced';
|
|
12
|
+
/** Main editor props */
|
|
13
|
+
export interface MathTextXEditorProps {
|
|
14
|
+
/** Initial content (HTML string or TipTap JSON) */
|
|
15
|
+
content?: string;
|
|
16
|
+
/** Called when content changes — returns HTML string */
|
|
17
|
+
onChange?: (html: string) => void;
|
|
18
|
+
/** Called when user triggers save (Ctrl+S) */
|
|
19
|
+
onSave?: (html: string) => void;
|
|
20
|
+
/** Is the editor editable? */
|
|
21
|
+
editable?: boolean;
|
|
22
|
+
/** Placeholder text when editor is empty */
|
|
23
|
+
placeholder?: string;
|
|
24
|
+
/** Which toolbar items to show */
|
|
25
|
+
toolbar?: ToolbarItem[];
|
|
26
|
+
/** Preset toolbar density mode */
|
|
27
|
+
toolbarMode?: ToolbarMode;
|
|
28
|
+
/** Which math toolbar items to show */
|
|
29
|
+
mathToolbar?: MathToolbarItem[];
|
|
30
|
+
/** Education level for formula templates */
|
|
31
|
+
templates?: EducationLevel;
|
|
32
|
+
/** Output format */
|
|
33
|
+
outputFormat?: OutputFormat;
|
|
34
|
+
/** Custom class name for the editor container */
|
|
35
|
+
className?: string;
|
|
36
|
+
/** Minimum height of the editor */
|
|
37
|
+
minHeight?: string;
|
|
38
|
+
/** Maximum height of the editor (enables scrolling) */
|
|
39
|
+
maxHeight?: string;
|
|
40
|
+
/** Auto-focus the editor on mount */
|
|
41
|
+
autoFocus?: boolean;
|
|
42
|
+
/** Image upload handler — return the URL of the uploaded image */
|
|
43
|
+
onImageUpload?: (file: File) => Promise<string>;
|
|
44
|
+
}
|
|
45
|
+
/** Toolbar button config */
|
|
46
|
+
export interface ToolbarButtonConfig {
|
|
47
|
+
id: ToolbarItem;
|
|
48
|
+
icon: string;
|
|
49
|
+
label: string;
|
|
50
|
+
action: (editor: Editor) => void;
|
|
51
|
+
isActive?: (editor: Editor) => boolean;
|
|
52
|
+
isDisabled?: (editor: Editor) => boolean;
|
|
53
|
+
}
|
|
54
|
+
/** Math template */
|
|
55
|
+
export interface MathTemplate {
|
|
56
|
+
id: string;
|
|
57
|
+
label: string;
|
|
58
|
+
latex: string;
|
|
59
|
+
category: string;
|
|
60
|
+
level: EducationLevel;
|
|
61
|
+
}
|
|
62
|
+
/** Symbol category */
|
|
63
|
+
export interface SymbolCategory {
|
|
64
|
+
id: string;
|
|
65
|
+
label: string;
|
|
66
|
+
symbols: SymbolItem[];
|
|
67
|
+
}
|
|
68
|
+
/** Individual symbol */
|
|
69
|
+
export interface SymbolItem {
|
|
70
|
+
char: string;
|
|
71
|
+
label: string;
|
|
72
|
+
latex: string;
|
|
73
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
/**
|
|
3
|
+
* Export the editor content as a PNG image.
|
|
4
|
+
* @param elementId The ID of the element to capture (usually the editor container).
|
|
5
|
+
* @param fileName The name of the downloaded file.
|
|
6
|
+
*/
|
|
7
|
+
export declare const exportToImage: (elementId: string, fileName?: string) => Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Export the editor content as a PDF document.
|
|
10
|
+
* @param elementId The ID of the element to capture.
|
|
11
|
+
* @param fileName The name of the downloaded file.
|
|
12
|
+
*/
|
|
13
|
+
export declare const exportToPDF: (elementId: string, fileName?: string) => Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Export the editor content as a JSON file.
|
|
16
|
+
* @param editor The Tiptap editor instance.
|
|
17
|
+
* @param fileName The name of the downloaded file.
|
|
18
|
+
*/
|
|
19
|
+
export declare const exportToJSON: (editor: Editor, fileName?: string) => void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Editor } from '@tiptap/react';
|
|
2
|
+
/**
|
|
3
|
+
* Clean Microsoft Office specific HTML content
|
|
4
|
+
*/
|
|
5
|
+
export declare function cleanOfficeHTML(html: string): string;
|
|
6
|
+
/**
|
|
7
|
+
* Clean Google Docs specific HTML content
|
|
8
|
+
*/
|
|
9
|
+
export declare function cleanGoogleDocsHTML(html: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Handle paste event with smart detection
|
|
12
|
+
*/
|
|
13
|
+
export declare function handlePaste(editor: Editor, event: ClipboardEvent): boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Handle Shift+Ctrl+V (Paste as plain text)
|
|
16
|
+
*/
|
|
17
|
+
export declare function handlePastePlainText(editor: Editor, event: ClipboardEvent): boolean;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Props for the ContentViewer component.
|
|
3
|
+
*/
|
|
4
|
+
export interface ContentViewerProps {
|
|
5
|
+
/** Raw HTML string from the editor (stored in database) */
|
|
6
|
+
content: string;
|
|
7
|
+
/** Additional CSS class name for the wrapper */
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* ContentViewer — Lightweight read-only renderer for MathTextX Editor content.
|
|
12
|
+
*
|
|
13
|
+
* This component takes raw HTML (as saved by the editor to the database)
|
|
14
|
+
* and renders it safely with:
|
|
15
|
+
* 1. XSS sanitization via DOMPurify
|
|
16
|
+
* 2. Automatic KaTeX rendering for math elements (`mtx-math-inline`, `mtx-math-block`)
|
|
17
|
+
* 3. Consistent styling via `content-style.css`
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```tsx
|
|
21
|
+
* // In your Quiz / Exam frontend:
|
|
22
|
+
* import { ContentViewer } from '@mathtextx/editor'
|
|
23
|
+
*
|
|
24
|
+
* function SoalCard({ htmlFromDB }) {
|
|
25
|
+
* return <ContentViewer content={htmlFromDB} />
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function ContentViewer({ content, className }: ContentViewerProps): import("react/jsx-runtime").JSX.Element;
|
|
File without changes
|