erl-mathtextx-editor 0.2.4 → 0.3.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.
@@ -1,4 +1,4 @@
1
- import { g as jl, c as fe } from "./index-ABpo9sfg.js";
1
+ import { g as jl, c as fe } from "./index-7QYcLP1s.js";
2
2
  function Xl(e, n) {
3
3
  for (var t = 0; t < n.length; t++) {
4
4
  const i = n[t];
@@ -1,4 +1,4 @@
1
- import { g as Wt, c as F, a as za } from "./index-ABpo9sfg.js";
1
+ import { g as Wt, c as F, a as za } from "./index-7QYcLP1s.js";
2
2
  function yf(t, e) {
3
3
  for (var n = 0; n < e.length; n++) {
4
4
  const r = e[n];
@@ -43,6 +43,8 @@ export interface MathTextXEditorProps {
43
43
  onImageUpload?: (file: File) => Promise<string>;
44
44
  /** Transform HTML before pasting — e.g. re-upload images in pasted content */
45
45
  onBeforePasteHTML?: (html: string) => Promise<string>;
46
+ /** Table styling mode: 'custom' uses mtx-table CSS themes, 'native' uses plain TipTap/ProseMirror table */
47
+ tableStyle?: 'custom' | 'native';
46
48
  }
47
49
  /** Toolbar button config */
48
50
  export interface ToolbarButtonConfig {
@@ -1,8 +1,30 @@
1
1
  import { Editor } from '@tiptap/react';
2
2
  /**
3
- * Clean Microsoft Office specific HTML content
3
+ * Clean Microsoft Office specific HTML content.
4
+ *
5
+ * Runs AFTER `cleanGeneralHTML` so document wrappers, comments, <style>,
6
+ * <meta>, <link>, <script>, and <html>/<head>/<body> are already gone.
7
+ *
8
+ * Handles:
9
+ * - XML namespace attributes (xmlns:w, xmlns:m, xmlns:o, xmlns:v, bare xmlns)
10
+ * - Office namespace tags (<o:…>, <w:…>, <v:…>, <m:…>)
11
+ * - Mso-* classes (comprehensive)
12
+ * - Mso-* inline style properties (in double AND single quotes)
13
+ * - mso-spacerun:yes empty spacer spans
14
+ * - lang="EN-US" / lang=EN-US
15
+ * - href/src with file:/// temp paths
16
+ * - Office numbered list styles
17
+ * - Empty paragraphs from Word
4
18
  */
5
19
  export declare function cleanOfficeHTML(html: string): string;
20
+ /**
21
+ * Clean general / unspecified HTML content — applies to pastes from
22
+ * regular websites and any other source that isn't Office or Google Docs.
23
+ *
24
+ * Strips document-level metadata, empty wrappers, and comments so the
25
+ * remaining content is as clean as possible before DOMPurify sanitization.
26
+ */
27
+ export declare function cleanGeneralHTML(html: string): string;
6
28
  /**
7
29
  * Clean Google Docs specific HTML content.
8
30
  *
@@ -15,11 +37,17 @@ export declare function cleanOfficeHTML(html: string): string;
15
37
  */
16
38
  export declare function cleanGoogleDocsHTML(html: string): string;
17
39
  /**
18
- * Handle paste event with smart detection.
40
+ * Handle paste event intercepts ALL HTML pastes for consistent cleaning,
41
+ * source-specific processing (Office / Google Docs), image re-upload, and
42
+ * XSS sanitization.
43
+ *
44
+ * Pipeline for every paste:
45
+ * 1. `cleanGeneralHTML` — strip wrappers, metadata, scripts, comments
46
+ * 2. Source-specific cleaning (Office or Google Docs)
47
+ * 3. `transformHTML` callback — e.g. re-upload base64/external images
48
+ * 4. DOMPurify sanitization (XSS prevention)
19
49
  *
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.
50
+ * Plain text paste (no HTML) is left to ProseMirror's default handler.
23
51
  */
24
52
  export declare function handlePaste(editor: Editor, event: ClipboardEvent, transformHTML?: (html: string) => Promise<string>): boolean;
25
53
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "erl-mathtextx-editor",
3
- "version": "0.2.4",
3
+ "version": "0.3.0",
4
4
  "description": "Visual math editor component for solutest.id — CKEditor replacement with zero-LaTeX approach",
5
5
  "type": "module",
6
6
  "main": "./dist/erl-mathtextx-editor.umd.cjs",