erl-mathtextx-editor 0.1.8 → 0.1.10

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 (28) hide show
  1. package/CHANGELOG.md +157 -0
  2. package/README.md +262 -107
  3. package/dist/{CellPropertiesDialogImpl-DBgs-7H9.js → CellPropertiesDialogImpl-Cl0pxbeQ.js} +1 -1
  4. package/dist/{ContentViewer-CsFSAN_B.js → ContentViewer-RijJ5nlJ.js} +15 -14
  5. package/dist/{ImageInsertDialog-B24KHrgt.js → ImageInsertDialog-BVBl1y36.js} +27 -25
  6. package/dist/{InsertTableDialogImpl-B6_PRu5m.js → InsertTableDialogImpl-Cx3ShX7u.js} +1 -1
  7. package/dist/{LinkDialogImpl-BTA8u_qQ.js → LinkDialogImpl-gMjoZVma.js} +1 -1
  8. package/dist/MathTextXEditor.d.ts +1 -1
  9. package/dist/{TablePropertiesDialogImpl-CuRRWS4H.js → TablePropertiesDialogImpl-CrTTV3Zr.js} +1 -1
  10. package/dist/{TableTemplatesDialogImpl-CU8seEdV.js → TableTemplatesDialogImpl-DTcom8H5.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-UCSefQk0.js → index-CakccgVO.js} +3801 -3201
  19. package/dist/{index-CB1g0gXh.js → index-Djb9MY7m.js} +1 -1
  20. package/dist/index-QMz8TDH0.js +16549 -0
  21. package/dist/toolbar/MainToolbar.d.ts +1 -0
  22. package/dist/types/index.d.ts +2 -0
  23. package/dist/utils/docxImporter.d.ts +31 -0
  24. package/dist/utils/pasteHandler.d.ts +14 -3
  25. package/dist/{viewer-deps-CjbAqdti.js → viewer-deps-BDYoL2Ts.js} +5794 -3489
  26. package/dist/viewer.js +1 -1
  27. package/package.json +6 -2
  28. package/dist/extensions/TableAlignPlugin.d.ts +0 -7
@@ -9,6 +9,7 @@ interface MainToolbarProps {
9
9
  onEditImage?: () => void;
10
10
  onSetImageAlign?: (align: 'left' | 'center' | 'right' | 'full') => void;
11
11
  onResetImagePosition?: () => void;
12
+ onImportDocx?: () => void;
12
13
  }
13
14
  export declare const MainToolbar: React.NamedExoticComponent<MainToolbarProps>;
14
15
  export {};
@@ -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
  */