@drghaliasri/butex 5.5.0 → 5.5.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/README.md CHANGED
@@ -19,8 +19,8 @@ The intended editor model is **AST-first**:
19
19
  ## Rendering outputs and MVP scope
20
20
 
21
21
  - **CommonHTML (`chtml`)** and **SVG** are supported. Load the matching MathJax 4 bundle (`tex-chtml.js` vs `tex-svg.js`) and pass the same mode as `output` to `renderBuTeXMathIsland` / `mountBuTeXMathIsland`. `<ButexEditor />` and document math preview follow the loaded bundle when possible (`tex2chtml` vs `tex2svg`).
22
- - `\arabsqrt`: optional index + mandatory radicand (same argument shape as `\sqrt`).
23
- - Compatibility macros: `\arsqrt` aliases `\arabsqrt`; `\unit{...}` and `\idx{...}` are browser-side passthrough wrappers for imported/reference TeX.
22
+ - `\arsqrt`: canonical serialized Arabic TeX command with an optional index and mandatory radicand (same argument shape as `\sqrt`).
23
+ - Compatibility macros: MathJax accepts `\arabsqrt` as an alias of `\arsqrt`; `\unit{...}` and `\idx{...}` are browser-side passthrough wrappers for imported/reference TeX.
24
24
  - **Arabic surface parser** (`parseBuTeX`) — optional helper that maps a tiny subset of Arabic command names to MathJax-safe TeX before rendering (see below). Long-term editor state is structured AST/JSON, not this string transform alone.
25
25
 
26
26
  ## Arabic preprocessor (`parseBuTeX`)
@@ -173,6 +173,7 @@ Shipped as a separate entry so apps that do not use React never pull it in.
173
173
  - Import: `import { ButexEditor } from 'butex/react'`.
174
174
  - Peer dependencies when using this entry: `react` and `react-dom` (^18 or ^19).
175
175
  - The component wraps `Editor.createEditorRuntime` (toolbar, surface, MathJax preview strip, optional dev panels via `debug`).
176
+ - Touch devices use a textarea-backed input bridge, so tapping the structured equation surface opens the software keyboard and supports normal text, deletion, and composed/IME input without making TeX strings the editor state.
176
177
  - Load MathJax and register BuTeX **before** relying on the preview (same timing as the GUI contract above). Equation preview in `ButexEditor` uses the same `renderBuTeXMathIsland` path as document math islands (output follows the loaded bundle: SVG when `tex2svg` is available, otherwise CHTML). Optional legacy `mountBuTeXMathTypeset` (`typesetPromise`) remains exported for hosts that still rely on it.
177
178
  - Next.js App Router: put BuTeX in a **client component** (`'use client'`).
178
179
 
@@ -253,7 +254,7 @@ const latex = document2Latex(documentNode);
253
254
  const preview = document2Preview(documentNode, 'svg');
254
255
  ```
255
256
 
256
- `document2Latex(doc)` emits a **complete Arabic XeLaTeX document** by default (preamble + `\begin{document}` + body + `\end{document}`). Pass `{ wrapDocument: false }` for body-only blocks. Paragraph blocks export as `\par` followed by the inline content, so prose, citations, and math are not wrapped inside `\paragraph{...}`. Optional `digitsMapping: 'arabicdigits' | 'digits'` controls eastern vs western digit font mapping in the preamble (default `'arabicdigits'`). Pass `{ twocolumn: true }` for `\documentclass[12pt,a4paper,notitlepage,twocolumn]{article}` (title block stays in-column; figures use `\columnwidth`). See [`examples/example-latex-export.tex`](examples/example-latex-export.tex) for a full sample (regenerated by the wrap vitest). Hosts can also call `getArabicXeLatexPreamble()` alone.
257
+ `document2Latex(doc)` emits a **complete Arabic XeLaTeX document** by default (preamble + `\begin{document}` + body + `\end{document}`). Structured and editor-authored Arabic roots serialize with the canonical `\arsqrt`; the bundled preamble also accepts raw legacy `\arabsqrt` with the same optional-index signature. Pass `{ wrapDocument: false }` for body-only blocks. Paragraph blocks export as `\par` followed by the inline content, so prose, citations, and math are not wrapped inside `\paragraph{...}`. Optional `digitsMapping: 'arabicdigits' | 'digits'` controls eastern vs western digit font mapping in the preamble (default `'arabicdigits'`). Pass `{ twocolumn: true }` for `\documentclass[12pt,a4paper,notitlepage,twocolumn]{article}` (title block stays in-column; figures use `\columnwidth`). See [`examples/example-latex-export.tex`](examples/example-latex-export.tex) for a full sample (regenerated by the wrap vitest). Hosts can also call `getArabicXeLatexPreamble()` alone.
257
258
 
258
259
  Figures and tables always export as centered `figure` / `table` floats. Optional caption/label fields (checkbox-driven in the editor) emit `\caption` / `\label`. Display math stays `\[…\]` unless an equation label is enabled, then export uses `\begin{equation}…\label{…}\end{equation}`. Internal cross-refs use `\ref` / `\eqref` tokens (separate from bibliography `\cite`).
259
260
 
package/dist/document.js CHANGED
@@ -227,7 +227,7 @@ var CommandNode = class extends BaseAstNode {
227
227
  arabicLatex() {
228
228
  const sup = this.superscript !== null ? this.superscript.arabicLatex() : "";
229
229
  const sub = this.subscript !== null ? this.subscript.arabicLatex() : "";
230
- const arabicName = this.name === "\\sqrt" ? "\\arabsqrt" : this.name;
230
+ const arabicName = this.name === "\\sqrt" || this.name === "\\arabsqrt" ? "\\arsqrt" : this.name;
231
231
  const content = renderCommandCore({
232
232
  name: arabicName,
233
233
  optionalArgs: this.optionalArgs,
@@ -1898,7 +1898,7 @@ function renderNodeArabic(node, options) {
1898
1898
  return arabicScripts(node, content, options);
1899
1899
  }
1900
1900
  if (node.kind === "sqrt" && node.radicand) {
1901
- const content = `\\arabsqrt${optionalRootIndexArabic(node, options)}{${renderChainArabic(node.radicand, options)}}`;
1901
+ const content = `\\arsqrt${optionalRootIndexArabic(node, options)}{${renderChainArabic(node.radicand, options)}}`;
1902
1902
  return arabicScripts(node, content, options);
1903
1903
  }
1904
1904
  if (node.kind === "overset" && node.baseExpr) {
@@ -2431,7 +2431,8 @@ ${BUTEX_FONT_FACE_CSS}
2431
2431
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
2432
2432
  }
2433
2433
 
2434
- .surface:focus {
2434
+ .surface:focus,
2435
+ .surface.surface--typing-focus {
2435
2436
  border-color: var(--butex-focus-border, rgba(13, 148, 136, 0.45));
2436
2437
  box-shadow: 0 0 0 3px var(--butex-focus-shadow, rgba(13, 148, 136, 0.12));
2437
2438
  }