@drghaliasri/butex 4.4.0 → 5.0.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.
- package/README.md +3 -1
- package/dist/document2.d.mts +191 -80
- package/dist/document2.d.ts +191 -80
- package/dist/document2.js +683 -101
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs +660 -101
- package/dist/document2.mjs.map +1 -1
- package/dist/react-document2.d.mts +160 -83
- package/dist/react-document2.d.ts +160 -83
- package/dist/react-document2.js +2039 -686
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +2002 -649
- package/dist/react-document2.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -253,6 +253,8 @@ const latex = document2Latex(documentNode);
|
|
|
253
253
|
const preview = document2Preview(documentNode, 'svg');
|
|
254
254
|
```
|
|
255
255
|
|
|
256
|
+
`document2Latex(doc)` emits a **complete Arabic XeLaTeX document** by default (preamble + `\begin{document}` + body + `\end{document}`). Pass `{ wrapDocument: false }` for body-only blocks. Optional `digitsMapping: 'arabicdigits' | 'digits'` controls eastern vs western digit font mapping in the preamble (default `'arabicdigits'`). 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
|
+
|
|
256
258
|
V2 exports Arabic TeX by default for equations saved from the embedded editor. Imported raw-only math is preserved as raw source and marked non-editable until a structured equation object is attached.
|
|
257
259
|
|
|
258
260
|
### Document JSON contract (`value` + `math_objects`)
|
|
@@ -332,7 +334,7 @@ export default function Page() {
|
|
|
332
334
|
}
|
|
333
335
|
```
|
|
334
336
|
|
|
335
|
-
Host apps still register BuTeX with MathJax before preview rendering. `uiLocale` selects Arabic (`"ar"`, the default) or English (`"en"`) document-editor chrome and is passed to the embedded equation editor. `documentDirection` independently controls prose inputs and preview flow without creating a second document tree. `equationSide` independently controls whether structured equations open, render, and save from the `"english"` or `"arabic"` side. Set `editableEquations={false}` to show math islands without equation insertion, deletion, or editor access. Set `previewOnly={true}` to render only the read-only document preview with no toolbar, editor panel, or equation drawer. Raw-only equations keep their original source because the browser does not parse raw LaTeX into equation ASTs. Document editor v2 defaults to **`tex-svg.js`**; use `tex-chtml.js` only if you pass `mathOutput="chtml"`.
|
|
337
|
+
Host apps still register BuTeX with MathJax before preview rendering. `uiLocale` selects Arabic (`"ar"`, the default) or English (`"en"`) document-editor chrome and is passed to the embedded equation editor. `documentDirection` independently controls prose inputs and preview flow without creating a second document tree. `equationSide` independently controls whether structured equations open, render, and save from the `"english"` or `"arabic"` side. Set `editableEquations={false}` to show math islands without equation insertion, deletion, or editor access. Set `previewOnly={true}` to render only the read-only document preview with no toolbar, editor panel, or equation drawer. Optional `\includegraphics` `asset_id` is preserved on import; pass `resolveImageUrl={({ assetId, value }) => …})` so preview can load S3/CDN/local assets while plain `value` URLs keep working without a resolver. Document JSON may include a root `references` catalog (`key`, `authors`, `title`, `year`, `url`, `venue`) and `\cite{key1,key2}` spans in text values; the editor shows numeric cite chips and a bibliography block. RTL preview/chips render reversed labels such as `[٣،٢،١]` (Arabic comma); LTR stays `[1, 2, 3]`. Pass `digitForm` (`western` / `arabicIndic` / `persianIndic`, defaulting from `documentDirection`) or use the toolbar digit control. LaTeX export keeps logical `\cite{…}` key order for XeLaTeX; digit shaping and bidi display in PDF belong in the host preamble (`bidi`/polyglossia + font `Mapping`, see `references/commands.py`). Range compression (`[3–7]`) is not implemented yet. Raw-only equations keep their original source because the browser does not parse raw LaTeX into equation ASTs. Document editor v2 defaults to **`tex-svg.js`**; use `tex-chtml.js` only if you pass `mathOutput="chtml"`.
|
|
336
338
|
|
|
337
339
|
### Styling/theming contract
|
|
338
340
|
|
package/dist/document2.d.mts
CHANGED
|
@@ -46,6 +46,82 @@ declare class ChainNode {
|
|
|
46
46
|
toArabicLatex(): string;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
+
type EditorSide = 'english' | 'arabic';
|
|
50
|
+
type EditorNodeKind = 'char' | 'number' | 'operator' | 'delimiter' | 'frac' | 'sqrt' | 'env' | 'atomicCommand' | 'atomicOperatorCommand';
|
|
51
|
+
type MatrixEnvStyle = 'matrix' | 'pmatrix' | 'bmatrix' | 'Bmatrix' | 'vmatrix' | 'Vmatrix';
|
|
52
|
+
type GridEnvName = MatrixEnvStyle | 'array' | 'aligned';
|
|
53
|
+
type EnvColumnAlignment = 'l' | 'c' | 'r';
|
|
54
|
+
type CharacterFontId = 'default' | 'takween' | 'diwani' | 'diwaniOutline';
|
|
55
|
+
type DigitFormId = 'western' | 'arabicIndic' | 'persianIndic';
|
|
56
|
+
type EditorSyncState = 'synced' | 'diverged';
|
|
57
|
+
type EditorChain = {
|
|
58
|
+
id: string;
|
|
59
|
+
nodes: EditorNode[];
|
|
60
|
+
};
|
|
61
|
+
type EditorNode = {
|
|
62
|
+
id: string;
|
|
63
|
+
kind: EditorNodeKind;
|
|
64
|
+
expr: string;
|
|
65
|
+
characterFont?: CharacterFontId;
|
|
66
|
+
superscript: EditorChain | null;
|
|
67
|
+
subscript: EditorChain | null;
|
|
68
|
+
leftDelimExpr: string;
|
|
69
|
+
rightDelimExpr: string;
|
|
70
|
+
innerExpr: EditorChain | null;
|
|
71
|
+
numerator: EditorChain | null;
|
|
72
|
+
denominator: EditorChain | null;
|
|
73
|
+
radicand: EditorChain | null;
|
|
74
|
+
rootIndex: EditorChain | null;
|
|
75
|
+
envName: GridEnvName | null;
|
|
76
|
+
matrixStyle: MatrixEnvStyle | null;
|
|
77
|
+
matrixRows: EditorChain[][] | null;
|
|
78
|
+
columnAlignments: EnvColumnAlignment[] | null;
|
|
79
|
+
};
|
|
80
|
+
type EditorCaret = {
|
|
81
|
+
chainId: string;
|
|
82
|
+
index: number;
|
|
83
|
+
};
|
|
84
|
+
type EditorSelectionRange = {
|
|
85
|
+
chainId: string;
|
|
86
|
+
anchorIndex: number;
|
|
87
|
+
focusIndex: number;
|
|
88
|
+
};
|
|
89
|
+
type EditorSyncMap = Record<string, {
|
|
90
|
+
expr: EditorSyncState;
|
|
91
|
+
}>;
|
|
92
|
+
type EditorDebugEntry = {
|
|
93
|
+
timestamp: string;
|
|
94
|
+
command: string;
|
|
95
|
+
activeSide: EditorSide;
|
|
96
|
+
englishLatex: string;
|
|
97
|
+
arabicLatex: string;
|
|
98
|
+
renderOk: boolean;
|
|
99
|
+
renderError: string | null;
|
|
100
|
+
note: string;
|
|
101
|
+
};
|
|
102
|
+
type EditorSession = {
|
|
103
|
+
englishTree: EditorChain;
|
|
104
|
+
arabicTree: EditorChain;
|
|
105
|
+
activeSide: EditorSide;
|
|
106
|
+
/** When true, each typed letter/digit inserts a new char/number leaf; when false, merge into adjacent same-kind leaves. */
|
|
107
|
+
splitLeafTyping: boolean;
|
|
108
|
+
/** One-shot: when true, the next insertChar/insertNumber bypasses leaf-merge (used by Space in merge mode). */
|
|
109
|
+
forceSplitNextLeaf: boolean;
|
|
110
|
+
/** When true and active side is Arabic, merged number typing prepends digits (RTL-style); still mirrored on EN/AR. */
|
|
111
|
+
arabicReverseNumberTyping: boolean;
|
|
112
|
+
/** Font applied to newly typed char nodes. */
|
|
113
|
+
currentCharacterFont: CharacterFontId;
|
|
114
|
+
/** Digit glyph form used for editor display and LaTeX preview output. */
|
|
115
|
+
currentDigitForm: DigitFormId;
|
|
116
|
+
caret: EditorCaret;
|
|
117
|
+
/** Whole-node range selection inside a single chain (anchor==focus means no selection). */
|
|
118
|
+
selection: EditorSelectionRange | null;
|
|
119
|
+
selectedNodeId: string | null;
|
|
120
|
+
selectedStructureNodeId: string | null;
|
|
121
|
+
sync: EditorSyncMap;
|
|
122
|
+
debugLog: EditorDebugEntry[];
|
|
123
|
+
};
|
|
124
|
+
|
|
49
125
|
type MathNode = {
|
|
50
126
|
nodeType: 'MathObject';
|
|
51
127
|
mathMode: string;
|
|
@@ -55,19 +131,31 @@ type MathNode = {
|
|
|
55
131
|
|
|
56
132
|
type Document2ParseMode = 'english' | 'arabic';
|
|
57
133
|
type Document2MathOutput = 'svg' | 'chtml';
|
|
134
|
+
type Document2Direction = 'rtl' | 'ltr';
|
|
58
135
|
type MathObject2Json = {
|
|
59
136
|
node_type: 'MathObject';
|
|
60
137
|
math_mode: string;
|
|
61
138
|
lines: ChainJson[];
|
|
62
139
|
closing: string;
|
|
63
140
|
};
|
|
141
|
+
type Reference2Json = {
|
|
142
|
+
key: string;
|
|
143
|
+
authors?: string;
|
|
144
|
+
title?: string;
|
|
145
|
+
year?: string;
|
|
146
|
+
url?: string;
|
|
147
|
+
venue?: string;
|
|
148
|
+
};
|
|
64
149
|
type Document2Json = {
|
|
65
150
|
node_type: 'DocumentObject';
|
|
151
|
+
references?: Reference2Json[];
|
|
66
152
|
blocks: Document2BlockJson[];
|
|
67
153
|
};
|
|
68
154
|
type Document2BlockJson = {
|
|
69
155
|
command: string;
|
|
70
156
|
value?: string;
|
|
157
|
+
/** Stable host asset identity (e.g. S3 key / UUID); optional for \\includegraphics. */
|
|
158
|
+
asset_id?: string;
|
|
71
159
|
math_objects?: MathObject2Json[];
|
|
72
160
|
options?: Record<string, string>;
|
|
73
161
|
closing?: string;
|
|
@@ -85,6 +173,15 @@ type Document2Diagnostic = {
|
|
|
85
173
|
message: string;
|
|
86
174
|
path: string;
|
|
87
175
|
};
|
|
176
|
+
type Reference2 = {
|
|
177
|
+
id: string;
|
|
178
|
+
key: string;
|
|
179
|
+
authors: string;
|
|
180
|
+
title: string;
|
|
181
|
+
year: string;
|
|
182
|
+
url: string;
|
|
183
|
+
venue: string;
|
|
184
|
+
};
|
|
88
185
|
type TextToken2 = {
|
|
89
186
|
id: string;
|
|
90
187
|
kind: 'text';
|
|
@@ -103,7 +200,12 @@ type MathToken2 = {
|
|
|
103
200
|
reason?: string;
|
|
104
201
|
sourceOwner: 'imported-structured' | 'raw' | 'editor';
|
|
105
202
|
};
|
|
106
|
-
type
|
|
203
|
+
type CiteToken2 = {
|
|
204
|
+
id: string;
|
|
205
|
+
kind: 'cite';
|
|
206
|
+
keys: string[];
|
|
207
|
+
};
|
|
208
|
+
type InlineToken2 = TextToken2 | MathToken2 | CiteToken2;
|
|
107
209
|
type InlineField2 = {
|
|
108
210
|
id: string;
|
|
109
211
|
tokens: InlineToken2[];
|
|
@@ -139,17 +241,26 @@ type ImageBlock2 = {
|
|
|
139
241
|
kind: 'image';
|
|
140
242
|
command: '\\includegraphics';
|
|
141
243
|
value: string;
|
|
244
|
+
/** Host asset identity from wire `asset_id`; preserved across value edits. */
|
|
245
|
+
assetId?: string;
|
|
142
246
|
options: Record<string, string>;
|
|
143
247
|
};
|
|
248
|
+
type BibliographyBlock2 = {
|
|
249
|
+
id: string;
|
|
250
|
+
kind: 'bibliography';
|
|
251
|
+
command: '\\begin{thebibliography}';
|
|
252
|
+
closing: '\\end{thebibliography}';
|
|
253
|
+
};
|
|
144
254
|
type RawBlock2 = {
|
|
145
255
|
id: string;
|
|
146
256
|
kind: 'raw';
|
|
147
257
|
command: '\\raw';
|
|
148
258
|
value: string;
|
|
149
259
|
};
|
|
150
|
-
type Document2Block = TextBlock2 | ListBlock2 | TableBlock2 | ImageBlock2 | RawBlock2;
|
|
260
|
+
type Document2Block = TextBlock2 | ListBlock2 | TableBlock2 | ImageBlock2 | BibliographyBlock2 | RawBlock2;
|
|
151
261
|
type Document2Node = {
|
|
152
262
|
nodeType: 'DocumentObject';
|
|
263
|
+
references: Reference2[];
|
|
153
264
|
blocks: Document2Block[];
|
|
154
265
|
diagnostics: Document2Diagnostic[];
|
|
155
266
|
};
|
|
@@ -165,6 +276,16 @@ type DetectedMathSpan2 = {
|
|
|
165
276
|
closing: string;
|
|
166
277
|
display: boolean;
|
|
167
278
|
};
|
|
279
|
+
type DetectedCiteSpan2 = {
|
|
280
|
+
kind: 'cite';
|
|
281
|
+
start: number;
|
|
282
|
+
end: number;
|
|
283
|
+
source: string;
|
|
284
|
+
keys: string[];
|
|
285
|
+
};
|
|
286
|
+
type DetectedInlineSpan2 = ({
|
|
287
|
+
kind: 'math';
|
|
288
|
+
} & DetectedMathSpan2) | DetectedCiteSpan2;
|
|
168
289
|
type PreviewInline2 = {
|
|
169
290
|
kind: 'text';
|
|
170
291
|
text: string;
|
|
@@ -175,6 +296,11 @@ type PreviewInline2 = {
|
|
|
175
296
|
display: boolean;
|
|
176
297
|
output: Document2MathOutput;
|
|
177
298
|
editable: boolean;
|
|
299
|
+
} | {
|
|
300
|
+
kind: 'cite';
|
|
301
|
+
id: string;
|
|
302
|
+
keys: string[];
|
|
303
|
+
label: string;
|
|
178
304
|
};
|
|
179
305
|
type PreviewBlock2 = {
|
|
180
306
|
kind: 'heading';
|
|
@@ -202,7 +328,21 @@ type PreviewBlock2 = {
|
|
|
202
328
|
kind: 'image';
|
|
203
329
|
id: string;
|
|
204
330
|
src: string;
|
|
331
|
+
assetId?: string;
|
|
205
332
|
options: Record<string, string>;
|
|
333
|
+
} | {
|
|
334
|
+
kind: 'bibliography';
|
|
335
|
+
id: string;
|
|
336
|
+
items: Array<{
|
|
337
|
+
id: string;
|
|
338
|
+
numberLabel: string;
|
|
339
|
+
key: string;
|
|
340
|
+
authors: string;
|
|
341
|
+
title: string;
|
|
342
|
+
year: string;
|
|
343
|
+
url: string;
|
|
344
|
+
venue: string;
|
|
345
|
+
}>;
|
|
206
346
|
}
|
|
207
347
|
/** Preview-only: raw / unknown blocks are omitted from preview until we add proper rendering. */
|
|
208
348
|
| {
|
|
@@ -220,81 +360,9 @@ type Document2Preview = {
|
|
|
220
360
|
blocks: PreviewBlock2[];
|
|
221
361
|
mathIslands: MathIsland2[];
|
|
222
362
|
};
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
type MatrixEnvStyle = 'matrix' | 'pmatrix' | 'bmatrix' | 'Bmatrix' | 'vmatrix' | 'Vmatrix';
|
|
227
|
-
type GridEnvName = MatrixEnvStyle | 'array' | 'aligned';
|
|
228
|
-
type EnvColumnAlignment = 'l' | 'c' | 'r';
|
|
229
|
-
type CharacterFontId = 'default' | 'takween' | 'diwani' | 'diwaniOutline';
|
|
230
|
-
type DigitFormId = 'western' | 'arabicIndic' | 'persianIndic';
|
|
231
|
-
type EditorSyncState = 'synced' | 'diverged';
|
|
232
|
-
type EditorChain = {
|
|
233
|
-
id: string;
|
|
234
|
-
nodes: EditorNode[];
|
|
235
|
-
};
|
|
236
|
-
type EditorNode = {
|
|
237
|
-
id: string;
|
|
238
|
-
kind: EditorNodeKind;
|
|
239
|
-
expr: string;
|
|
240
|
-
characterFont?: CharacterFontId;
|
|
241
|
-
superscript: EditorChain | null;
|
|
242
|
-
subscript: EditorChain | null;
|
|
243
|
-
leftDelimExpr: string;
|
|
244
|
-
rightDelimExpr: string;
|
|
245
|
-
innerExpr: EditorChain | null;
|
|
246
|
-
numerator: EditorChain | null;
|
|
247
|
-
denominator: EditorChain | null;
|
|
248
|
-
radicand: EditorChain | null;
|
|
249
|
-
rootIndex: EditorChain | null;
|
|
250
|
-
envName: GridEnvName | null;
|
|
251
|
-
matrixStyle: MatrixEnvStyle | null;
|
|
252
|
-
matrixRows: EditorChain[][] | null;
|
|
253
|
-
columnAlignments: EnvColumnAlignment[] | null;
|
|
254
|
-
};
|
|
255
|
-
type EditorCaret = {
|
|
256
|
-
chainId: string;
|
|
257
|
-
index: number;
|
|
258
|
-
};
|
|
259
|
-
type EditorSelectionRange = {
|
|
260
|
-
chainId: string;
|
|
261
|
-
anchorIndex: number;
|
|
262
|
-
focusIndex: number;
|
|
263
|
-
};
|
|
264
|
-
type EditorSyncMap = Record<string, {
|
|
265
|
-
expr: EditorSyncState;
|
|
266
|
-
}>;
|
|
267
|
-
type EditorDebugEntry = {
|
|
268
|
-
timestamp: string;
|
|
269
|
-
command: string;
|
|
270
|
-
activeSide: EditorSide;
|
|
271
|
-
englishLatex: string;
|
|
272
|
-
arabicLatex: string;
|
|
273
|
-
renderOk: boolean;
|
|
274
|
-
renderError: string | null;
|
|
275
|
-
note: string;
|
|
276
|
-
};
|
|
277
|
-
type EditorSession = {
|
|
278
|
-
englishTree: EditorChain;
|
|
279
|
-
arabicTree: EditorChain;
|
|
280
|
-
activeSide: EditorSide;
|
|
281
|
-
/** When true, each typed letter/digit inserts a new char/number leaf; when false, merge into adjacent same-kind leaves. */
|
|
282
|
-
splitLeafTyping: boolean;
|
|
283
|
-
/** One-shot: when true, the next insertChar/insertNumber bypasses leaf-merge (used by Space in merge mode). */
|
|
284
|
-
forceSplitNextLeaf: boolean;
|
|
285
|
-
/** When true and active side is Arabic, merged number typing prepends digits (RTL-style); still mirrored on EN/AR. */
|
|
286
|
-
arabicReverseNumberTyping: boolean;
|
|
287
|
-
/** Font applied to newly typed char nodes. */
|
|
288
|
-
currentCharacterFont: CharacterFontId;
|
|
289
|
-
/** Digit glyph form used for editor display and LaTeX preview output. */
|
|
290
|
-
currentDigitForm: DigitFormId;
|
|
291
|
-
caret: EditorCaret;
|
|
292
|
-
/** Whole-node range selection inside a single chain (anchor==focus means no selection). */
|
|
293
|
-
selection: EditorSelectionRange | null;
|
|
294
|
-
selectedNodeId: string | null;
|
|
295
|
-
selectedStructureNodeId: string | null;
|
|
296
|
-
sync: EditorSyncMap;
|
|
297
|
-
debugLog: EditorDebugEntry[];
|
|
363
|
+
type FormatCiteLabelOptions = {
|
|
364
|
+
documentDirection?: Document2Direction;
|
|
365
|
+
digitForm?: DigitFormId;
|
|
298
366
|
};
|
|
299
367
|
|
|
300
368
|
declare function findFirstInlineField(document: Document2Node): InlineField2 | null;
|
|
@@ -314,9 +382,45 @@ declare function addDocument2ImageBlock(document: Document2Node, src?: string, a
|
|
|
314
382
|
declare function updateDocument2ImageValue(document: Document2Node, blockId: string, value: string): Document2Node;
|
|
315
383
|
declare function addDocument2ListItem(document: Document2Node, listBlockId: string): Document2Node;
|
|
316
384
|
declare function removeDocument2ListItem(document: Document2Node, listBlockId: string, itemId: string): Document2Node;
|
|
385
|
+
declare function insertCiteTokenAtCaret(document: Document2Node, fieldId: string, textTokenId: string | null, caretOffset: number, keys: string[]): Document2Node;
|
|
386
|
+
declare function updateCiteTokenKeys(document: Document2Node, tokenId: string, keys: string[]): Document2Node;
|
|
387
|
+
declare function removeCiteTokenById(document: Document2Node, tokenId: string): Document2Node;
|
|
388
|
+
declare function ensureDocument2BibliographyBlock(document: Document2Node, afterBlockId?: string | null): Document2Node;
|
|
389
|
+
declare function addDocument2Reference(document: Document2Node, partial?: Partial<Reference2Json>): Document2Node;
|
|
390
|
+
declare function updateDocument2Reference(document: Document2Node, referenceId: string, patch: Partial<Reference2Json>): Document2Node;
|
|
391
|
+
declare function removeDocument2Reference(document: Document2Node, referenceId: string): Document2Node;
|
|
392
|
+
declare function moveDocument2Reference(document: Document2Node, referenceId: string, direction: -1 | 1): Document2Node;
|
|
393
|
+
declare function setDocument2References(document: Document2Node, references: Reference2[]): Document2Node;
|
|
394
|
+
|
|
395
|
+
declare function referenceNumberMap(references: Array<Pick<Reference2, 'key'>>): Map<string, number>;
|
|
396
|
+
declare function resolveCiteNumbers(keys: string[], references: Array<Pick<Reference2, 'key'>>): Array<number | null>;
|
|
397
|
+
declare function formatCiteLabel(keys: string[], references: Array<Pick<Reference2, 'key'>>, options?: FormatCiteLabelOptions): string;
|
|
398
|
+
declare function formatBibliographyNumber(index: number, options?: FormatCiteLabelOptions): string;
|
|
399
|
+
declare function parseCiteKeys(source: string): string[];
|
|
400
|
+
declare function citeTokenLatex(keys: string[]): string;
|
|
401
|
+
declare function referenceFromJson(json: Reference2Json): Reference2;
|
|
402
|
+
declare function createEmptyReference2(partial?: Partial<Reference2Json>): Reference2;
|
|
403
|
+
declare function bibliographyEntryLatex(reference: Reference2): string;
|
|
317
404
|
|
|
405
|
+
/** Arabic XeLaTeX preamble fragments for full-document export. */
|
|
406
|
+
type ArabicDigitsMapping = 'arabicdigits' | 'digits';
|
|
407
|
+
declare function arabicXeLatexPreamblePkg(): string;
|
|
408
|
+
declare function arabicXeLatexPreambleFont(digitsMapping?: ArabicDigitsMapping): string;
|
|
409
|
+
declare function arabicXeLatexPreambleCmd(): string;
|
|
410
|
+
declare function getArabicXeLatexPreamble(digitsMapping?: ArabicDigitsMapping): string;
|
|
411
|
+
|
|
412
|
+
type Document2LatexOptions = {
|
|
413
|
+
/**
|
|
414
|
+
* When true (default), emit a complete Arabic XeLaTeX file:
|
|
415
|
+
* preamble + \\begin{document} + body + \\end{document}.
|
|
416
|
+
* Pass false for body-only blocks.
|
|
417
|
+
*/
|
|
418
|
+
wrapDocument?: boolean;
|
|
419
|
+
/** Font digit Mapping when wrapping. Default 'arabicdigits'. */
|
|
420
|
+
digitsMapping?: ArabicDigitsMapping;
|
|
421
|
+
};
|
|
318
422
|
declare function inlineFieldLatex(field: InlineField2): string;
|
|
319
|
-
declare function document2Latex(document: Document2Node): string;
|
|
423
|
+
declare function document2Latex(document: Document2Node, options?: Document2LatexOptions): string;
|
|
320
424
|
|
|
321
425
|
declare const DEFAULT_DOCUMENT2_HISTORY_MAX_DEPTH = 100;
|
|
322
426
|
type Document2HistoryStacks = {
|
|
@@ -335,7 +439,10 @@ declare function createInlineField2(value?: string, mathObjects?: MathObject2Jso
|
|
|
335
439
|
declare function fromDocumentJson2(json: unknown, options?: ImportDocument2Options): Document2Node;
|
|
336
440
|
declare function createEmptyDocument2(): Document2Node;
|
|
337
441
|
|
|
442
|
+
/** Math-only spans (used for math_objects alignment counts). */
|
|
338
443
|
declare function detectMathSpans2(value: string): DetectedMathSpan2[];
|
|
444
|
+
/** Left-to-right math + \\cite spans without overlap. */
|
|
445
|
+
declare function detectInlineSpans2(value: string): DetectedInlineSpan2[];
|
|
339
446
|
|
|
340
447
|
type Document2MathBridgeResult = {
|
|
341
448
|
editable: true;
|
|
@@ -354,6 +461,10 @@ declare function mathNodeFromSession(session: EditorSession, opening?: string, c
|
|
|
354
461
|
declare function mathNodeFromArabicSession(session: EditorSession, opening?: string, closing?: string): MathNode;
|
|
355
462
|
declare function mathTokenSourceForSide(token: MathToken2, side: EditorSide): string;
|
|
356
463
|
|
|
357
|
-
|
|
464
|
+
type Document2PreviewOptions = {
|
|
465
|
+
documentDirection?: Document2Direction;
|
|
466
|
+
digitForm?: DigitFormId;
|
|
467
|
+
};
|
|
468
|
+
declare function document2Preview(document: Document2Node, output?: Document2MathOutput, equationSide?: EditorSide, previewOptions?: Document2PreviewOptions): Document2Preview;
|
|
358
469
|
|
|
359
|
-
export { DEFAULT_DOCUMENT2_HISTORY_MAX_DEPTH, type Document2Block, type Document2BlockJson, type Document2Diagnostic, type Document2HistoryStacks, type Document2Json, type Document2MathOutput, type Document2Node, type ImageBlock2, type ImportDocument2Options, type InlineField2, type InlineToken2, type ListBlock2, type MathIsland2, type MathObject2Json, type MathToken2, type PreviewBlock2, type PreviewInline2, type RawBlock2, type TableBlock2, type TextBlock2, type TextToken2, addDocument2ImageBlock, addDocument2ListBlock, addDocument2ListItem, addDocument2TableBlock, addDocument2TextBlock, cloneDocument2Node, createDocument2History, createEmptyArabicEquationSession, createEmptyDocument2, createEmptyEquationSession, createInlineField2, detectMathSpans2, document2HistoryCanRedo, document2HistoryCanUndo, document2Latex, document2Preview, findFirstInlineField, fromDocumentJson2, inlineFieldLatex, insertDocument2BlockAfter, insertMathToken, insertMathTokenAtCaret, mathNodeFromArabicSession, mathNodeFromSession, mathSourceFromArabicSession, mathSourceFromSession, mathTokenSourceForSide, mathTokenToArabicEditorSession, mathTokenToEditorSession, moveDocument2BlockById, pushDocument2Snapshot, removeDocument2BlockById, removeDocument2ListItem, removeMathTokenById, replaceMathTokenFromSession, restoreDocument2Redo, restoreDocument2Undo, updateDocument2ImageValue, updateTextToken };
|
|
470
|
+
export { type ArabicDigitsMapping, type BibliographyBlock2, type CiteToken2, DEFAULT_DOCUMENT2_HISTORY_MAX_DEPTH, type Document2Block, type Document2BlockJson, type Document2Diagnostic, type Document2Direction, type Document2HistoryStacks, type Document2Json, type Document2LatexOptions, type Document2MathOutput, type Document2Node, type Document2PreviewOptions, type FormatCiteLabelOptions, type ImageBlock2, type ImportDocument2Options, type InlineField2, type InlineToken2, type ListBlock2, type MathIsland2, type MathObject2Json, type MathToken2, type PreviewBlock2, type PreviewInline2, type RawBlock2, type Reference2, type Reference2Json, type TableBlock2, type TextBlock2, type TextToken2, addDocument2ImageBlock, addDocument2ListBlock, addDocument2ListItem, addDocument2Reference, addDocument2TableBlock, addDocument2TextBlock, arabicXeLatexPreambleCmd, arabicXeLatexPreambleFont, arabicXeLatexPreamblePkg, bibliographyEntryLatex, citeTokenLatex, cloneDocument2Node, createDocument2History, createEmptyArabicEquationSession, createEmptyDocument2, createEmptyEquationSession, createEmptyReference2, createInlineField2, detectInlineSpans2, detectMathSpans2, document2HistoryCanRedo, document2HistoryCanUndo, document2Latex, document2Preview, ensureDocument2BibliographyBlock, findFirstInlineField, formatBibliographyNumber, formatCiteLabel, fromDocumentJson2, getArabicXeLatexPreamble, inlineFieldLatex, insertCiteTokenAtCaret, insertDocument2BlockAfter, insertMathToken, insertMathTokenAtCaret, mathNodeFromArabicSession, mathNodeFromSession, mathSourceFromArabicSession, mathSourceFromSession, mathTokenSourceForSide, mathTokenToArabicEditorSession, mathTokenToEditorSession, moveDocument2BlockById, moveDocument2Reference, parseCiteKeys, pushDocument2Snapshot, referenceFromJson, referenceNumberMap, removeCiteTokenById, removeDocument2BlockById, removeDocument2ListItem, removeDocument2Reference, removeMathTokenById, replaceMathTokenFromSession, resolveCiteNumbers, restoreDocument2Redo, restoreDocument2Undo, setDocument2References, updateCiteTokenKeys, updateDocument2ImageValue, updateDocument2Reference, updateTextToken };
|