@richhtmleditor/math 1.1.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.
@@ -0,0 +1,30 @@
1
+ import type { EditorPlugin } from "@richhtmleditor/core";
2
+ export type MathDisplayMode = "inline" | "block";
3
+ export type MathPluginOptions = {
4
+ /**
5
+ * Render LaTeX to an HTML string (e.g., using KaTeX or MathJax).
6
+ * If omitted the raw LaTeX is displayed inside a <code> element.
7
+ *
8
+ * @example
9
+ * // KaTeX
10
+ * renderMath: (latex, display) => katex.renderToString(latex, { displayMode: display })
11
+ */
12
+ renderMath?: (latex: string, displayMode: boolean) => string;
13
+ /** Placeholder LaTeX shown in the modal input. Default: 'x^2 + y^2 = z^2' */
14
+ placeholder?: string;
15
+ };
16
+ /**
17
+ * LaTeX equation editor plugin.
18
+ * Provides an `insertMath` toolbar button that opens a modal to write LaTeX.
19
+ * Equations are stored as `<figure class="de-math" data-latex="...">` in the HTML.
20
+ *
21
+ * Pass a `renderMath` function to enable live preview and rendered output:
22
+ * ```ts
23
+ * import katex from "katex";
24
+ * createMathPlugin({ renderMath: (latex, display) => katex.renderToString(latex, { displayMode: display }) })
25
+ * ```
26
+ */
27
+ export declare function createMathPlugin(options?: MathPluginOptions): EditorPlugin;
28
+ /** Utility: scan HTML string and re-render all math figures using the provided renderer. */
29
+ export declare function renderMathInHtml(html: string, renderMath: (latex: string, displayMode: boolean) => string): string;
30
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAkB,YAAY,EAAyB,MAAM,sBAAsB,CAAC;AAEhG,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEjD,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,KAAK,MAAM,CAAC;IAC7D,6EAA6E;IAC7E,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAiGF;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,GAAE,iBAAsB,GAAG,YAAY,CAyE9E;AAED,4FAA4F;AAC5F,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,KAAK,MAAM,GAAG,MAAM,CASlH"}
package/dist/index.js ADDED
@@ -0,0 +1,174 @@
1
+ const MATH_FIGURE_CLASS = "de-math";
2
+ const MODAL_CLASS = "de-math-modal";
3
+ function escapeHtml(s) {
4
+ return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
5
+ }
6
+ function buildPreviewHtml(latex, displayMode, renderer) {
7
+ if (!latex.trim())
8
+ return "";
9
+ if (renderer) {
10
+ try {
11
+ return renderer(latex, displayMode);
12
+ }
13
+ catch (e) {
14
+ return `<span style="color:#dc2626;font-size:.8em;">Render error: ${escapeHtml(String(e))}</span>`;
15
+ }
16
+ }
17
+ const tag = displayMode ? "div" : "span";
18
+ return `<${tag} class="de-math__fallback" style="font-family:monospace;background:#f1f5f9;padding:2px 6px;border-radius:4px;">${escapeHtml(latex)}</${tag}>`;
19
+ }
20
+ function buildFigureHtml(latex, displayMode, renderer) {
21
+ const preview = buildPreviewHtml(latex, displayMode, renderer);
22
+ const display = displayMode ? "block" : "inline";
23
+ return `<figure class="${MATH_FIGURE_CLASS} ${MATH_FIGURE_CLASS}--${display}" data-latex="${escapeHtml(latex)}" data-display="${display}" contenteditable="false">${preview}</figure>`;
24
+ }
25
+ function openMathModal(host, options, initialLatex, initialDisplay, onConfirm) {
26
+ const backdrop = document.createElement("div");
27
+ backdrop.className = `${MODAL_CLASS}__backdrop`;
28
+ backdrop.style.cssText = "position:fixed;inset:0;background:rgba(0,0,0,.4);z-index:9999;display:flex;align-items:center;justify-content:center;";
29
+ const panel = document.createElement("div");
30
+ panel.className = MODAL_CLASS;
31
+ panel.setAttribute("role", "dialog");
32
+ panel.setAttribute("aria-modal", "true");
33
+ panel.setAttribute("aria-label", "Insert equation");
34
+ panel.style.cssText = "background:var(--de-toolbar-bg,#fff);border-radius:12px;padding:20px;min-width:380px;max-width:560px;width:90vw;box-shadow:0 16px 48px rgba(0,0,0,.2);display:flex;flex-direction:column;gap:12px;";
35
+ panel.innerHTML = `
36
+ <h3 style="margin:0;font-size:1rem;font-weight:600;">Insert equation</h3>
37
+ <div style="display:flex;gap:12px;align-items:center;">
38
+ <label style="font-size:.875rem;display:flex;align-items:center;gap:6px;cursor:pointer;">
39
+ <input type="radio" name="de-math-mode" value="inline" ${initialDisplay === "inline" ? "checked" : ""}> Inline
40
+ </label>
41
+ <label style="font-size:.875rem;display:flex;align-items:center;gap:6px;cursor:pointer;">
42
+ <input type="radio" name="de-math-mode" value="block" ${initialDisplay === "block" ? "checked" : ""}> Block (display)
43
+ </label>
44
+ </div>
45
+ <textarea class="${MODAL_CLASS}__input" rows="3" placeholder="${escapeHtml(options.placeholder ?? "x^2 + y^2 = z^2")}" style="width:100%;box-sizing:border-box;padding:8px 10px;border:1px solid var(--de-border,#e2e8f0);border-radius:8px;font-family:monospace;font-size:.9rem;resize:vertical;">${escapeHtml(initialLatex)}</textarea>
46
+ <div class="${MODAL_CLASS}__preview" style="min-height:40px;padding:8px;border:1px solid var(--de-border,#e2e8f0);border-radius:8px;background:var(--de-content-bg,#fff);overflow:auto;"></div>
47
+ <div style="display:flex;justify-content:flex-end;gap:8px;">
48
+ <button type="button" class="${MODAL_CLASS}__cancel" style="padding:7px 16px;border:1px solid var(--de-border,#e2e8f0);background:none;border-radius:8px;cursor:pointer;font-size:.875rem;">Cancel</button>
49
+ <button type="button" class="${MODAL_CLASS}__confirm" style="padding:7px 16px;background:var(--de-primary,#2563eb);color:#fff;border:none;border-radius:8px;cursor:pointer;font-size:.875rem;font-weight:500;">Insert</button>
50
+ </div>
51
+ `;
52
+ backdrop.appendChild(panel);
53
+ document.body.appendChild(backdrop);
54
+ const textarea = panel.querySelector(`.${MODAL_CLASS}__input`);
55
+ const preview = panel.querySelector(`.${MODAL_CLASS}__preview`);
56
+ const cancelBtn = panel.querySelector(`.${MODAL_CLASS}__cancel`);
57
+ const confirmBtn = panel.querySelector(`.${MODAL_CLASS}__confirm`);
58
+ const getMode = () => (panel.querySelector('input[name="de-math-mode"]:checked')?.value ?? "inline");
59
+ const updatePreview = () => {
60
+ preview.innerHTML = buildPreviewHtml(textarea.value, getMode() === "block", options.renderMath);
61
+ };
62
+ textarea.addEventListener("input", updatePreview);
63
+ panel.querySelectorAll('input[name="de-math-mode"]').forEach((r) => r.addEventListener("change", updatePreview));
64
+ updatePreview();
65
+ const close = () => backdrop.remove();
66
+ cancelBtn.addEventListener("click", close);
67
+ backdrop.addEventListener("click", (e) => { if (e.target === backdrop)
68
+ close(); });
69
+ panel.addEventListener("keydown", (e) => { if (e.key === "Escape")
70
+ close(); });
71
+ confirmBtn.addEventListener("click", () => {
72
+ const latex = textarea.value.trim();
73
+ if (!latex) {
74
+ close();
75
+ return;
76
+ }
77
+ onConfirm(latex, getMode());
78
+ close();
79
+ });
80
+ setTimeout(() => textarea.focus(), 50);
81
+ }
82
+ /**
83
+ * LaTeX equation editor plugin.
84
+ * Provides an `insertMath` toolbar button that opens a modal to write LaTeX.
85
+ * Equations are stored as `<figure class="de-math" data-latex="...">` in the HTML.
86
+ *
87
+ * Pass a `renderMath` function to enable live preview and rendered output:
88
+ * ```ts
89
+ * import katex from "katex";
90
+ * createMathPlugin({ renderMath: (latex, display) => katex.renderToString(latex, { displayMode: display }) })
91
+ * ```
92
+ */
93
+ export function createMathPlugin(options = {}) {
94
+ const tool = {
95
+ id: "insertMath",
96
+ type: "button",
97
+ label: "Math",
98
+ icon: "math",
99
+ display: "icon",
100
+ tooltip: "Insert equation (LaTeX)"
101
+ };
102
+ return {
103
+ id: "richhtmleditor-math",
104
+ tools: [tool],
105
+ attach: (editor) => {
106
+ const host = editor.element;
107
+ const insertEquation = (latex, display) => {
108
+ const figHtml = buildFigureHtml(latex, display === "block", options.renderMath);
109
+ const current = editor.getHTML();
110
+ editor.setContent(`${current}<p>${figHtml}</p>`);
111
+ };
112
+ // Re-render all existing math figures when the content changes (e.g., after setContent)
113
+ const rerenderAll = () => {
114
+ if (!options.renderMath)
115
+ return;
116
+ const figures = host.querySelectorAll(`figure.${MATH_FIGURE_CLASS}`);
117
+ for (const fig of Array.from(figures)) {
118
+ const latex = fig.dataset.latex ?? "";
119
+ const displayMode = fig.dataset.display === "block";
120
+ if (latex)
121
+ fig.innerHTML = buildPreviewHtml(latex, displayMode, options.renderMath);
122
+ }
123
+ };
124
+ // Click on a figure to edit it
125
+ const onFigureClick = (e) => {
126
+ const fig = e.target.closest(`figure.${MATH_FIGURE_CLASS}`);
127
+ if (!fig)
128
+ return;
129
+ e.preventDefault();
130
+ const latex = fig.dataset.latex ?? "";
131
+ const display = fig.dataset.display === "block" ? "block" : "inline";
132
+ openMathModal(host, options, latex, display, (newLatex, newDisplay) => {
133
+ fig.outerHTML = buildFigureHtml(newLatex, newDisplay === "block", options.renderMath);
134
+ });
135
+ };
136
+ // Patch insertMath tool onClick
137
+ tool.onClick = () => {
138
+ openMathModal(host, options, "", "block", insertEquation);
139
+ };
140
+ const offChange = editor.on("change", rerenderAll);
141
+ host.addEventListener("click", onFigureClick);
142
+ // Inject CSS
143
+ const styleId = "de-math-styles";
144
+ if (!document.getElementById(styleId)) {
145
+ const style = document.createElement("style");
146
+ style.id = styleId;
147
+ style.textContent = `
148
+ figure.de-math{display:inline-block;vertical-align:middle;margin:.25em 2px;}
149
+ figure.de-math--block{display:block;text-align:center;margin:1rem auto;}
150
+ figure.de-math[contenteditable="false"]{cursor:pointer;outline:none;}
151
+ figure.de-math[contenteditable="false"]:hover{outline:2px solid var(--de-primary,#2563eb);border-radius:4px;}
152
+ `.trim();
153
+ document.head.appendChild(style);
154
+ }
155
+ return () => {
156
+ offChange();
157
+ host.removeEventListener("click", onFigureClick);
158
+ };
159
+ }
160
+ };
161
+ }
162
+ /** Utility: scan HTML string and re-render all math figures using the provided renderer. */
163
+ export function renderMathInHtml(html, renderMath) {
164
+ const template = document.createElement("template");
165
+ template.innerHTML = html;
166
+ for (const fig of Array.from(template.content.querySelectorAll(`figure.${MATH_FIGURE_CLASS}`))) {
167
+ const latex = fig.dataset.latex ?? "";
168
+ const displayMode = fig.dataset.display === "block";
169
+ if (latex)
170
+ fig.innerHTML = buildPreviewHtml(latex, displayMode, renderMath);
171
+ }
172
+ return template.innerHTML;
173
+ }
174
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAkBA,MAAM,iBAAiB,GAAG,SAAS,CAAC;AACpC,MAAM,WAAW,GAAG,eAAe,CAAC;AAEpC,SAAS,UAAU,CAAC,CAAS;IAC3B,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;AACtG,CAAC;AAED,SAAS,gBAAgB,CAAC,KAAa,EAAE,WAAoB,EAAE,QAA4C;IACzG,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE;QAAE,OAAO,EAAE,CAAC;IAC7B,IAAI,QAAQ,EAAE,CAAC;QACb,IAAI,CAAC;YAAC,OAAO,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QAAC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACtD,OAAO,6DAA6D,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACrG,CAAC;IACH,CAAC;IACD,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AAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC;AAED,4FAA4F;AAC5F,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,UAA2D;IACxG,MAAM,QAAQ,GAAG,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IACpD,QAAQ,CAAC,SAAS,GAAG,IAAI,CAAC;IAC1B,KAAK,MAAM,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,gBAAgB,CAAc,UAAU,iBAAiB,EAAE,CAAC,CAAC,EAAE,CAAC;QAC5G,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,KAAK,IAAI,EAAE,CAAC;QACtC,MAAM,WAAW,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,KAAK,OAAO,CAAC;QACpD,IAAI,KAAK;YAAE,GAAG,CAAC,SAAS,GAAG,gBAAgB,CAAC,KAAK,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC;IAC9E,CAAC;IACD,OAAO,QAAQ,CAAC,SAAS,CAAC;AAC5B,CAAC"}
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@richhtmleditor/math",
3
+ "version": "1.1.0",
4
+ "description": "LaTeX / MathML equation editor plugin for Rich HTML Editor (KaTeX / MathJax adapter).",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js",
12
+ "default": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": ["dist", "README.md"],
16
+ "scripts": {
17
+ "build": "tsc -p tsconfig.json",
18
+ "prepack": "node ../../scripts/assert-pack-ready.mjs"
19
+ },
20
+ "dependencies": {
21
+ "@richhtmleditor/core": "^1.1.0"
22
+ },
23
+ "keywords": ["richhtmleditor", "math", "latex", "katex", "mathjax", "equation"],
24
+ "license": "MIT",
25
+ "publishConfig": { "access": "public" },
26
+ "engines": { "node": ">=18" }
27
+ }