erl-mathtextx-editor 0.1.9 → 0.2.0

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 (29) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/README.md +294 -109
  3. package/dist/{CellPropertiesDialogImpl-DBgs-7H9.js → CellPropertiesDialogImpl-5BptFKaE.js} +1 -1
  4. package/dist/{ContentViewer-CsFSAN_B.js → ContentViewer-RijJ5nlJ.js} +15 -14
  5. package/dist/{ImageInsertDialog-B24KHrgt.js → ImageInsertDialog-Cc7wpIjM.js} +27 -25
  6. package/dist/{InsertTableDialogImpl-B6_PRu5m.js → InsertTableDialogImpl-BJFXRnQX.js} +1 -1
  7. package/dist/{LinkDialogImpl-BTA8u_qQ.js → LinkDialogImpl-Cu032Nc7.js} +1 -1
  8. package/dist/MathTextXEditor.d.ts +1 -1
  9. package/dist/{TablePropertiesDialogImpl-CuRRWS4H.js → TablePropertiesDialogImpl-YBNdKM7k.js} +1 -1
  10. package/dist/{TableTemplatesDialogImpl-CU8seEdV.js → TableTemplatesDialogImpl-P54y5q-u.js} +2 -2
  11. package/dist/assets/erl-mathtextx-editor.css +1 -1
  12. package/dist/assets/viewer.css +1 -1
  13. package/dist/components/ErrorBoundary.d.ts +18 -0
  14. package/dist/components/ImageEditDialog.d.ts +0 -1
  15. package/dist/components/TableMenu.d.ts +4 -1
  16. package/dist/erl-mathtextx-editor.js +2 -2
  17. package/dist/erl-mathtextx-editor.umd.cjs +345 -115
  18. package/dist/index-C9scFI1r.js +16549 -0
  19. package/dist/{index-UCSefQk0.js → index-D0Rzm7Tg.js} +4338 -3839
  20. package/dist/{index-CB1g0gXh.js → index-DJrUW7HG.js} +1 -1
  21. package/dist/toolbar/MainToolbar.d.ts +2 -0
  22. package/dist/toolbar/MathToolbar.d.ts +3 -1
  23. package/dist/types/index.d.ts +3 -1
  24. package/dist/utils/docxImporter.d.ts +31 -0
  25. package/dist/utils/pasteHandler.d.ts +14 -3
  26. package/dist/{viewer-deps-CjbAqdti.js → viewer-deps-BDYoL2Ts.js} +5794 -3489
  27. package/dist/viewer.js +1 -1
  28. package/package.json +2 -1
  29. package/dist/extensions/TableAlignPlugin.d.ts +0 -7
@@ -1,4 +1,4 @@
1
- import { g as Wt, c as F, a as za } from "./index-UCSefQk0.js";
1
+ import { g as Wt, c as F, a as za } from "./index-D0Rzm7Tg.js";
2
2
  function yf(t, e) {
3
3
  for (var n = 0; n < e.length; n++) {
4
4
  const r = e[n];
@@ -5,10 +5,12 @@ interface MainToolbarProps {
5
5
  editor: Editor | null;
6
6
  toolbarMode?: ToolbarMode;
7
7
  onInsertMath?: (tab?: string) => void;
8
+ onInsertBlockMath?: () => void;
8
9
  onInsertImage?: () => void;
9
10
  onEditImage?: () => void;
10
11
  onSetImageAlign?: (align: 'left' | 'center' | 'right' | 'full') => void;
11
12
  onResetImagePosition?: () => void;
13
+ onImportDocx?: () => void;
12
14
  }
13
15
  export declare const MainToolbar: React.NamedExoticComponent<MainToolbarProps>;
14
16
  export {};
@@ -1,7 +1,9 @@
1
+ import { ToolbarMode } from '../types';
1
2
  interface MathToolbarProps {
2
3
  onInsertLatex: (latex: string) => void;
3
4
  onToggleSymbols: () => void;
4
5
  onToggleTemplates?: () => void;
6
+ mode?: ToolbarMode;
5
7
  }
6
- export declare function MathToolbar({ onInsertLatex, onToggleSymbols, onToggleTemplates }: MathToolbarProps): import("react/jsx-runtime").JSX.Element;
8
+ export declare function MathToolbar({ onInsertLatex, onToggleSymbols, onToggleTemplates, mode }: MathToolbarProps): import("react/jsx-runtime").JSX.Element;
7
9
  export {};
@@ -8,7 +8,7 @@ export type EducationLevel = 'sd' | 'smp' | 'sma' | 'all';
8
8
  /** Output format */
9
9
  export type OutputFormat = 'html' | 'json';
10
10
  /** Toolbar density mode */
11
- export type ToolbarMode = 'basic' | 'advanced';
11
+ export type ToolbarMode = 'basic' | 'advanced' | 'olimpiade';
12
12
  /** Main editor props */
13
13
  export interface MathTextXEditorProps {
14
14
  /** Initial content (HTML string or TipTap JSON) */
@@ -41,6 +41,8 @@ export interface MathTextXEditorProps {
41
41
  autoFocus?: boolean;
42
42
  /** Image upload handler — return the URL of the uploaded image */
43
43
  onImageUpload?: (file: File) => Promise<string>;
44
+ /** Transform HTML before pasting — e.g. re-upload images in pasted content */
45
+ onBeforePasteHTML?: (html: string) => Promise<string>;
44
46
  }
45
47
  /** Toolbar button config */
46
48
  export interface ToolbarButtonConfig {
@@ -0,0 +1,31 @@
1
+ export interface DocxImportResult {
2
+ html: string;
3
+ warnings: string[];
4
+ images: Map<string, {
5
+ contentType: string;
6
+ arrayBuffer: ArrayBuffer;
7
+ }>;
8
+ }
9
+ /**
10
+ * Convert a .docx File to clean HTML via mammoth.js.
11
+ *
12
+ * Images embedded in the .docx are extracted and returned separately
13
+ * so they can be re-uploaded by the host application.
14
+ */
15
+ export declare function convertDocxToHtml(file: File, onImage?: (imageKey: string, contentType: string, buffer: ArrayBuffer) => Promise<string>): Promise<DocxImportResult>;
16
+ /**
17
+ * Import a .docx file and insert its content into the editor.
18
+ *
19
+ * @param file - The .docx file
20
+ * @param editor - TipTap editor instance
21
+ * @param uploadImage - Optional callback to upload extracted images
22
+ */
23
+ export declare function importDocxFile(file: File, editor: {
24
+ chain: () => {
25
+ focus: () => {
26
+ insertContent: (html: string) => {
27
+ run: () => void;
28
+ };
29
+ };
30
+ };
31
+ }, uploadImage?: (imageKey: string, contentType: string, buffer: ArrayBuffer) => Promise<string>): Promise<string[]>;
@@ -4,13 +4,24 @@ import { Editor } from '@tiptap/react';
4
4
  */
5
5
  export declare function cleanOfficeHTML(html: string): string;
6
6
  /**
7
- * Clean Google Docs specific HTML content
7
+ * Clean Google Docs specific HTML content.
8
+ *
9
+ * Handles:
10
+ * - Inline formatting span → strong/em/u conversion
11
+ * - Google Docs wrapper/metadata removal
12
+ * - Table normalization
13
+ * - List cleanup
14
+ * - Font-color preservation (background/text color)
8
15
  */
9
16
  export declare function cleanGoogleDocsHTML(html: string): string;
10
17
  /**
11
- * Handle paste event with smart detection
18
+ * Handle paste event with smart detection.
19
+ *
20
+ * When `transformHTML` is provided and the pasted HTML contains images,
21
+ * the callback is invoked asynchronously to transform the HTML (e.g. re-upload
22
+ * images) before inserting into the editor.
12
23
  */
13
- export declare function handlePaste(editor: Editor, event: ClipboardEvent): boolean;
24
+ export declare function handlePaste(editor: Editor, event: ClipboardEvent, transformHTML?: (html: string) => Promise<string>): boolean;
14
25
  /**
15
26
  * Handle Shift+Ctrl+V (Paste as plain text)
16
27
  */