@drghaliasri/butex 5.5.3 → 5.5.4
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 +7 -3
- package/dist/document.d.mts +1 -1
- package/dist/document.d.ts +1 -1
- package/dist/document.js +109 -24
- package/dist/document.js.map +1 -1
- package/dist/document.mjs +109 -24
- package/dist/document.mjs.map +1 -1
- package/dist/document2.d.mts +1 -2
- package/dist/document2.d.ts +1 -2
- package/dist/document2.js +109 -45
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs +109 -45
- package/dist/document2.mjs.map +1 -1
- package/dist/index.d.mts +32 -2
- package/dist/index.d.ts +32 -2
- package/dist/index.global.js +142 -89
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +142 -89
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +142 -89
- package/dist/index.mjs.map +1 -1
- package/dist/react-document.js +113 -55
- package/dist/react-document.js.map +1 -1
- package/dist/react-document.mjs +113 -55
- package/dist/react-document.mjs.map +1 -1
- package/dist/react-document2.d.mts +1 -1
- package/dist/react-document2.d.ts +1 -1
- package/dist/react-document2.js +118 -61
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +118 -61
- package/dist/react-document2.mjs.map +1 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +99 -35
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +99 -35
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -61,7 +61,7 @@ Peer dependency: `mathjax` ^4.x (aligned with MathJax 4 components). If you use
|
|
|
61
61
|
2. Load BuTeX’s IIFE bundle (`dist/index.global.js` exposes global `BuTeX`).
|
|
62
62
|
3. In `MathJax.startup.ready`, call `BuTeX.registerBuTeX(MathJax)` before `MathJax.startup.defaultReady()`.
|
|
63
63
|
4. Inject styles once: `BuTeX.injectBuTeXStyles()` (or embed `BuTeX.BUTEX_CHROME_CSS` yourself).
|
|
64
|
-
5. When using **SVG** (`tex-svg.js`), call `BuTeX.registerBuTeXSvgTextWrapper(MathJax)` **after** `defaultReady()` so Takween/Diwani text, `\ad`, and Arabic atomic commands (`\arsin`, etc.) render in the preview with the correct fonts. CommonHTML (`tex-chtml.js`) uses the injected CSS classes instead.
|
|
64
|
+
5. When using **SVG** (`tex-svg.js`), call `BuTeX.registerBuTeXSvgTextWrapper(MathJax)` **after** `defaultReady()` so Takween/Diwani/Maghribi text, `\ad`, and Arabic atomic commands (`\arsin`, etc.) render in the preview with the correct fonts. CommonHTML (`tex-chtml.js`) uses the injected CSS classes instead.
|
|
65
65
|
6. Render math with `renderBuTeXMathIsland(tex, options?)` or mount into a host element via `mountBuTeXMathIsland(host, tex, options?)`. Pass `output: 'svg'` when the host loads `tex-svg.js`, or `output: 'chtml'` with `tex-chtml.js`. For raw Arabic TeX that did not come from the editor AST, pass `mirrorOperators: true` to wrap directional operators according to BuTeX's shared operator table. `ButexEditor` picks SVG vs CHTML automatically from the loaded MathJax bundle (`tex2svg` vs `tex2chtml`).
|
|
66
66
|
|
|
67
67
|
Ensure TeX `packages` includes `butex-arabic-math` (use `BUTEX_TEX_PACKAGE` in config when using `{ '[+]': [...] }`).
|
|
@@ -152,7 +152,7 @@ Use this when you want the same editor UX as the demo:
|
|
|
152
152
|
- Optionally pass `buttonElements` (undo/redo/copy/cut/split toggle) for auto button state refresh.
|
|
153
153
|
- Wire your toolbar/actions to runtime methods (`toggleSide`, `insertDelimiterByKind`, `addSup`, `addSub`, `removeSup`, `removeSub`, `deleteStructure`, `performUndo`, `performRedo`, `performCopy`, `performCut`, `performPaste`).
|
|
154
154
|
- Use `onSessionChange(session)` to render external previews (e.g., MathJax pane, status labels).
|
|
155
|
-
- **Imported `MathObject` / `CharObject` for the editor:** document LaTeX preview treats `CharObject.expr` as already-rendered Arabic TeX (e.g. `\text{م}`). When opening an imported equation in `<ButexEditor />` via `mathObjectToEditorSession`, BuTeX unwraps supported LaTeX text/font wrappers into plain glyph `expr` plus editor `characterFont`. Supported patterns: `\text{…}`, `\takween{…}`, `\diwani{…}`, `\butextakween{…}`, `\butexdiwani{…}`, `\butexdiwanioutline{…}`, and nested forms such as `\text{\takween{…}}`. On save, default-font chars stay plain `CharObject` nodes; non-default fonts are stored as font `CommandObject` wrappers so editor round-trip preserves `characterFont`. Upstream converters may still emit wrapped `expr` on import.
|
|
155
|
+
- **Imported `MathObject` / `CharObject` for the editor:** document LaTeX preview treats `CharObject.expr` as already-rendered Arabic TeX (e.g. `\text{م}`). When opening an imported equation in `<ButexEditor />` via `mathObjectToEditorSession`, BuTeX unwraps supported LaTeX text/font wrappers into plain glyph `expr` plus editor `characterFont`. Supported patterns: `\text{…}`, `\takween{…}`, `\diwani{…}`, `\butextakween{…}`, `\butexdiwani{…}`, `\butexdiwanioutline{…}`, `\butexmaghribi{…}`, and nested forms such as `\text{\takween{…}}`. On save, default-font chars stay plain `CharObject` nodes; non-default fonts are stored as font `CommandObject` wrappers so editor round-trip preserves `characterFont`. Upstream converters may still emit wrapped `expr` on import.
|
|
156
156
|
|
|
157
157
|
Minimal browser example:
|
|
158
158
|
|
|
@@ -254,7 +254,11 @@ const latex = document2Latex(documentNode);
|
|
|
254
254
|
const preview = document2Preview(documentNode, 'svg');
|
|
255
255
|
```
|
|
256
256
|
|
|
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
|
+
`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. It defines BuTeX font wrappers (`\butextakween`, `\butexdiwani`, `\butexdiwanioutline`, `\butexmaghribi`) and the MathJax-compatible `\butexmirror` bridge. 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.
|
|
258
|
+
|
|
259
|
+
For XeLaTeX compiler images, install `src/fonts/Almaghribi-Warsh-Quran.otf` as a system font and refresh fontconfig (`fc-cache -f -v`). Verify with `fc-match "Almaghribi Warsh Quran"`; the preamble uses that installed family name.
|
|
260
|
+
|
|
261
|
+
To add another character font, add its metadata to `src/editor/characterFonts.ts` and its browser `@font-face` asset to `src/diwani-font.ts`.
|
|
258
262
|
|
|
259
263
|
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`).
|
|
260
264
|
|
package/dist/document.d.mts
CHANGED
|
@@ -165,7 +165,7 @@ type EditorNodeKind = 'char' | 'number' | 'operator' | 'delimiter' | 'frac' | 's
|
|
|
165
165
|
type MatrixEnvStyle = 'matrix' | 'pmatrix' | 'bmatrix' | 'Bmatrix' | 'vmatrix' | 'Vmatrix';
|
|
166
166
|
type GridEnvName = MatrixEnvStyle | 'array' | 'aligned';
|
|
167
167
|
type EnvColumnAlignment = 'l' | 'c' | 'r';
|
|
168
|
-
type CharacterFontId = 'default' | 'takween' | 'diwani' | 'diwaniOutline';
|
|
168
|
+
type CharacterFontId = 'default' | 'takween' | 'diwani' | 'diwaniOutline' | 'maghribi';
|
|
169
169
|
type DigitFormId = 'western' | 'arabicIndic' | 'persianIndic';
|
|
170
170
|
type EditorSyncState = 'synced' | 'diverged';
|
|
171
171
|
type EditorChain = {
|
package/dist/document.d.ts
CHANGED
|
@@ -165,7 +165,7 @@ type EditorNodeKind = 'char' | 'number' | 'operator' | 'delimiter' | 'frac' | 's
|
|
|
165
165
|
type MatrixEnvStyle = 'matrix' | 'pmatrix' | 'bmatrix' | 'Bmatrix' | 'vmatrix' | 'Vmatrix';
|
|
166
166
|
type GridEnvName = MatrixEnvStyle | 'array' | 'aligned';
|
|
167
167
|
type EnvColumnAlignment = 'l' | 'c' | 'r';
|
|
168
|
-
type CharacterFontId = 'default' | 'takween' | 'diwani' | 'diwaniOutline';
|
|
168
|
+
type CharacterFontId = 'default' | 'takween' | 'diwani' | 'diwaniOutline' | 'maghribi';
|
|
169
169
|
type DigitFormId = 'western' | 'arabicIndic' | 'persianIndic';
|
|
170
170
|
type EditorSyncState = 'synced' | 'diverged';
|
|
171
171
|
type EditorChain = {
|