@drghaliasri/butex 7.4.2 → 8.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.
Files changed (43) hide show
  1. package/README.md +49 -553
  2. package/dist/{document2-cli.js → document-cli.js} +332 -302
  3. package/dist/document-cli.js.map +1 -0
  4. package/dist/document.d.mts +1022 -186
  5. package/dist/document.d.ts +1022 -186
  6. package/dist/document.js +6068 -658
  7. package/dist/document.js.map +1 -1
  8. package/dist/document.mjs +5928 -618
  9. package/dist/document.mjs.map +1 -1
  10. package/dist/react-document-preview.d.mts +338 -0
  11. package/dist/react-document-preview.d.ts +338 -0
  12. package/dist/{react-document2-preview.js → react-document-preview.js} +783 -783
  13. package/dist/react-document-preview.js.map +1 -0
  14. package/dist/{react-document2-preview.mjs → react-document-preview.mjs} +776 -776
  15. package/dist/react-document-preview.mjs.map +1 -0
  16. package/dist/react-document.d.mts +634 -35
  17. package/dist/react-document.d.ts +634 -35
  18. package/dist/react-document.js +13259 -4282
  19. package/dist/react-document.js.map +1 -1
  20. package/dist/react-document.mjs +12617 -3648
  21. package/dist/react-document.mjs.map +1 -1
  22. package/dist/react.js +4 -4
  23. package/dist/react.js.map +1 -1
  24. package/dist/react.mjs +4 -4
  25. package/dist/react.mjs.map +1 -1
  26. package/package.json +7 -17
  27. package/dist/document2-cli.js.map +0 -1
  28. package/dist/document2.d.mts +0 -1156
  29. package/dist/document2.d.ts +0 -1156
  30. package/dist/document2.js +0 -9137
  31. package/dist/document2.js.map +0 -1
  32. package/dist/document2.mjs +0 -8972
  33. package/dist/document2.mjs.map +0 -1
  34. package/dist/react-document2-preview.d.mts +0 -338
  35. package/dist/react-document2-preview.d.ts +0 -338
  36. package/dist/react-document2-preview.js.map +0 -1
  37. package/dist/react-document2-preview.mjs.map +0 -1
  38. package/dist/react-document2.d.mts +0 -754
  39. package/dist/react-document2.d.ts +0 -754
  40. package/dist/react-document2.js +0 -23011
  41. package/dist/react-document2.js.map +0 -1
  42. package/dist/react-document2.mjs +0 -22981
  43. package/dist/react-document2.mjs.map +0 -1
@@ -1,3 +1,92 @@
1
+ type EditorSide = 'english' | 'arabic';
2
+ type EditorNodeKind = 'char' | 'number' | 'operator' | 'delimiter' | 'boxed' | 'frac' | 'sqrt' | 'overset' | 'underset' | 'accent' | 'env' | 'atomicCommand' | 'atomicOperatorCommand' | 'standardCommand';
3
+ type MatrixEnvStyle = 'matrix' | 'pmatrix' | 'bmatrix' | 'Bmatrix' | 'vmatrix' | 'Vmatrix';
4
+ type GridEnvName = MatrixEnvStyle | 'array' | 'aligned';
5
+ type EnvColumnAlignment = 'l' | 'c' | 'r';
6
+ type CharacterFontId = 'default' | 'takween' | 'diwani' | 'diwaniOutline' | 'maghribi';
7
+ type DigitFormId = 'western' | 'arabicIndic' | 'persianIndic';
8
+ type EditorSyncState = 'synced' | 'diverged';
9
+ type EditorChain = {
10
+ id: string;
11
+ nodes: EditorNode[];
12
+ /** Complete script authored as \\mathnormal{ordered,index,atoms}. */
13
+ indexSequence?: boolean;
14
+ };
15
+ type EditorNode = {
16
+ id: string;
17
+ kind: EditorNodeKind;
18
+ expr: string;
19
+ characterFont?: CharacterFontId;
20
+ /** Minimal upstream source identity used only while the node remains unchanged. */
21
+ sourceLatex?: string;
22
+ /** Existing editor node reused for wrapper commands that need editable content. */
23
+ wrapperCommand?: '\\unit' | '\\mathtt' | '\\mathbf' | '\\boldarabic';
24
+ superscript: EditorChain | null;
25
+ subscript: EditorChain | null;
26
+ leftDelimExpr: string;
27
+ rightDelimExpr: string;
28
+ innerExpr: EditorChain | null;
29
+ numerator: EditorChain | null;
30
+ denominator: EditorChain | null;
31
+ radicand: EditorChain | null;
32
+ rootIndex: EditorChain | null;
33
+ overExpr: EditorChain | null;
34
+ underExpr: EditorChain | null;
35
+ baseExpr: EditorChain | null;
36
+ envName: GridEnvName | null;
37
+ matrixStyle: MatrixEnvStyle | null;
38
+ matrixRows: EditorChain[][] | null;
39
+ columnAlignments: EnvColumnAlignment[] | null;
40
+ };
41
+ type EditorCaret = {
42
+ chainId: string;
43
+ index: number;
44
+ };
45
+ type EditorSelectionRange = {
46
+ chainId: string;
47
+ anchorIndex: number;
48
+ focusIndex: number;
49
+ };
50
+ type EditorSyncMap = Record<string, {
51
+ expr: EditorSyncState;
52
+ }>;
53
+ type EditorDebugEntry = {
54
+ timestamp: string;
55
+ command: string;
56
+ activeSide: EditorSide;
57
+ englishLatex: string;
58
+ arabicLatex: string;
59
+ renderOk: boolean;
60
+ renderError: string | null;
61
+ note: string;
62
+ };
63
+ type EditorSession = {
64
+ englishTree: EditorChain;
65
+ arabicTree: EditorChain;
66
+ activeSide: EditorSide;
67
+ /** When true, each typed letter/digit inserts a new char/number leaf; when false, merge into adjacent same-kind leaves. */
68
+ splitLeafTyping: boolean;
69
+ /** One-shot: when true, the next insertChar/insertNumber bypasses leaf-merge (used by Space in merge mode). */
70
+ forceSplitNextLeaf: boolean;
71
+ /** When true and active side is Arabic, merged number typing prepends digits (RTL-style); still mirrored on EN/AR. */
72
+ arabicReverseNumberTyping: boolean;
73
+ /** Font applied to newly typed char nodes. */
74
+ currentCharacterFont: CharacterFontId;
75
+ /** Structured command wrapper applied to newly typed chars; kept separate from fonts. */
76
+ currentCharacterWrapper: '\\boldarabic' | null;
77
+ /** Digit glyph form used for editor display and LaTeX preview output. */
78
+ currentDigitForm: DigitFormId;
79
+ caret: EditorCaret;
80
+ /** Whole-node range selection inside a single chain (anchor==focus means no selection). */
81
+ selection: EditorSelectionRange | null;
82
+ selectedNodeId: string | null;
83
+ selectedStructureNodeId: string | null;
84
+ sync: EditorSyncMap;
85
+ debugLog: EditorDebugEntry[];
86
+ };
87
+
88
+ type ButexUiLocale = 'ar' | 'en';
89
+
1
90
  type ArabicNodeJson = {
2
91
  node_type: string;
3
92
  expr?: string;
@@ -48,273 +137,1020 @@ declare class ChainNode {
48
137
  toArabicLatex(): string;
49
138
  }
50
139
 
140
+ type MathNode = {
141
+ nodeType: 'MathObject';
142
+ mathMode: string;
143
+ lines: ChainNode[];
144
+ closing: string;
145
+ };
146
+
51
147
  type DocumentParseMode = 'english' | 'arabic';
52
- type MathObjectJson = {
148
+ type DocumentMathOutput = 'svg' | 'chtml';
149
+ type DocumentDirection = 'rtl' | 'ltr';
150
+ type MathObject2Json = {
53
151
  node_type: 'MathObject';
54
152
  math_mode: string;
55
153
  lines: ChainJson[];
56
154
  closing: string;
155
+ /** Side used by the delimited source stored in the containing value/cell. */
156
+ source_side?: DocumentParseMode;
157
+ /** Preserve whether LaTeX export should prefer imported AST rendering or editor source. */
158
+ source_owner?: 'imported-structured' | 'editor';
159
+ label_enabled?: boolean;
160
+ label?: string;
161
+ };
162
+ /** Positional metadata for a raw-only span that has no structured equation AST. */
163
+ type RawMathObject2Json = {
164
+ node_type: 'RawMathObject';
165
+ label_enabled?: boolean;
166
+ label?: string;
167
+ };
168
+ type DocumentMathObjectJson = MathObject2Json | RawMathObject2Json;
169
+ type ReferenceFieldSeparator = ',' | '،';
170
+ type Reference2Json = {
171
+ key: string;
172
+ authors?: string;
173
+ title?: string;
174
+ year?: string;
175
+ url?: string;
176
+ venue?: string;
177
+ /** Bibliography field join: LTR `,` or Arabic `،`. Defaults to `،` when omitted. */
178
+ field_separator?: ReferenceFieldSeparator;
179
+ };
180
+ type HijriMonthId = 'محرم' | 'صفر' | 'ربيع الأول' | 'ربيع الآخر' | 'جمادى الأولى' | 'جمادى الآخرة' | 'رجب' | 'شعبان' | 'رمضان' | 'شوال' | 'ذو القعدة' | 'ذو الحجة';
181
+ type DocumentHijriDate = {
182
+ day: number;
183
+ month: HijriMonthId;
184
+ year: number;
185
+ };
186
+ type DocumentMeta = {
187
+ title: string;
188
+ authors: string;
189
+ date: DocumentHijriDate;
190
+ abstract: string;
57
191
  };
58
192
  type DocumentJson = {
59
193
  node_type: 'DocumentObject';
194
+ meta?: DocumentMeta;
195
+ references?: Reference2Json[];
60
196
  blocks: DocumentBlockJson[];
61
197
  };
198
+ type DocumentInlineTokenIdJson = {
199
+ id: string;
200
+ kind: InlineToken2['kind'];
201
+ start: number;
202
+ end: number;
203
+ };
204
+ type DocumentInlineIdsJson = {
205
+ field_id: string;
206
+ tokens: DocumentInlineTokenIdJson[];
207
+ };
208
+ type DocumentBlockMetadata = {
209
+ source?: 'agent' | 'user';
210
+ };
62
211
  type DocumentBlockJson = {
212
+ /** Stable identity used by headless commands. Legacy JSON may omit it. */
213
+ id?: string;
63
214
  command: string;
64
215
  value?: string;
65
- math_objects?: Array<MathObjectJson | null>;
216
+ formats?: TextFormatSpan2Json[];
217
+ inline_ids?: DocumentInlineIdsJson;
218
+ metadata?: DocumentBlockMetadata;
219
+ /** Stable host asset identity (e.g. S3 key / UUID); optional for \\includegraphics. */
220
+ asset_id?: string;
221
+ math_objects?: Array<DocumentMathObjectJson | null>;
66
222
  options?: Record<string, string>;
67
223
  closing?: string;
68
224
  items?: DocumentListItemJson[];
69
225
  rows?: string[][];
226
+ cell_formats?: TextFormatSpan2Json[][][];
227
+ cell_inline_ids?: DocumentInlineIdsJson[][];
70
228
  columns?: string;
229
+ caption?: string;
230
+ /** Optional formatting sidecar for caption text spans. */
231
+ caption_formats?: TextFormatSpan2Json[];
232
+ /** Stable caption field/token identities; omitted by legacy documents. */
233
+ caption_inline_ids?: DocumentInlineIdsJson;
234
+ /** Caption-only structured math sidecar, independent from table cell math_objects. */
235
+ caption_math_objects?: Array<DocumentMathObjectJson | null>;
236
+ label?: string;
237
+ caption_enabled?: boolean;
238
+ label_enabled?: boolean;
239
+ centered?: boolean;
71
240
  };
72
241
  type DocumentListItemJson = {
242
+ id?: string;
73
243
  value: string;
74
- math_objects?: Array<MathObjectJson | null>;
244
+ formats?: TextFormatSpan2Json[];
245
+ inline_ids?: DocumentInlineIdsJson;
246
+ math_objects?: Array<DocumentMathObjectJson | null>;
75
247
  blocks?: DocumentBlockJson[];
76
248
  };
77
- type DocumentCommand = '\\section' | '\\subsection' | '\\subsubsection' | '\\paragraph' | '\\begin{itemize}' | '\\begin{enumerate}' | '\\begin{tabular}' | '\\includegraphics' | '\\raw';
78
- type MathNode = {
79
- nodeType: 'MathObject';
80
- mathMode: string;
81
- lines: ChainNode[];
82
- closing: string;
249
+ type DocumentDiagnostic = {
250
+ code: string;
251
+ message: string;
252
+ path: string;
253
+ };
254
+ type Reference2 = {
255
+ id: string;
256
+ key: string;
257
+ authors: string;
258
+ title: string;
259
+ year: string;
260
+ url: string;
261
+ venue: string;
262
+ /** Joins authors/title/venue/year in bibliography display and export. */
263
+ fieldSeparator: ReferenceFieldSeparator;
264
+ };
265
+ type TextStyle2 = {
266
+ bold?: true;
267
+ italic?: true;
268
+ underline?: true;
269
+ };
270
+ type TextFormatSpan2Json = {
271
+ start: number;
272
+ end: number;
273
+ bold?: boolean;
274
+ italic?: boolean;
275
+ underline?: boolean;
83
276
  };
84
- type TextInline = {
277
+ type TextToken2 = {
278
+ id: string;
85
279
  kind: 'text';
86
280
  text: string;
281
+ style?: TextStyle2;
87
282
  };
88
- type MathInline = {
283
+ type MathToken2 = {
284
+ id: string;
89
285
  kind: 'math';
286
+ display: boolean;
287
+ opening: string;
288
+ closing: string;
90
289
  source: string;
290
+ sourceSide?: DocumentParseMode;
91
291
  math: MathNode | null;
292
+ editable: boolean;
293
+ reason?: string;
294
+ sourceOwner: 'imported-structured' | 'raw' | 'editor';
295
+ /** When true on display math, export as equation env with \\label. */
296
+ labelEnabled?: boolean;
297
+ label?: string;
298
+ };
299
+ type CiteToken2 = {
300
+ id: string;
301
+ kind: 'cite';
302
+ keys: string[];
92
303
  };
93
- type DocumentInline = TextInline | MathInline;
94
- type TextBlockNode = {
304
+ type RefToken2 = {
305
+ id: string;
306
+ kind: 'ref';
307
+ keys: string[];
308
+ refCommand: 'ref' | 'eqref';
309
+ };
310
+ type InlineToken2 = TextToken2 | MathToken2 | CiteToken2 | RefToken2;
311
+ type InlineField2 = {
312
+ id: string;
313
+ tokens: InlineToken2[];
314
+ };
315
+ type TextBlock2 = {
316
+ id: string;
95
317
  kind: 'textBlock';
96
318
  command: '\\section' | '\\subsection' | '\\subsubsection' | '\\paragraph';
97
- value: string;
98
- inlines: DocumentInline[];
319
+ field: InlineField2;
320
+ metadata?: DocumentBlockMetadata;
321
+ /** When true on \\paragraph, center in preview and LaTeX export. */
322
+ centered?: boolean;
99
323
  };
100
- type ListItemNode = {
101
- value: string;
102
- inlines: DocumentInline[];
103
- blocks: DocumentBlockNode[];
324
+ type ListItem2 = {
325
+ id: string;
326
+ field: InlineField2;
327
+ blocks: DocumentBlock[];
104
328
  };
105
- type ListBlockNode = {
329
+ type ListBlock2 = {
330
+ id: string;
106
331
  kind: 'list';
107
332
  command: '\\begin{itemize}' | '\\begin{enumerate}';
108
333
  closing: '\\end{itemize}' | '\\end{enumerate}';
109
- items: ListItemNode[];
334
+ items: ListItem2[];
335
+ metadata?: DocumentBlockMetadata;
110
336
  };
111
- type TableBlockNode = {
337
+ type FloatMeta2 = {
338
+ centered: boolean;
339
+ captionEnabled: boolean;
340
+ /** Compatibility source string; captionField is the structured source of truth. */
341
+ caption: string;
342
+ /** Stable inline field used by the editor, commands, preview, and persistence. */
343
+ captionField: InlineField2;
344
+ labelEnabled: boolean;
345
+ label: string;
346
+ };
347
+ type TableBlock2 = {
348
+ id: string;
112
349
  kind: 'table';
113
350
  command: '\\begin{tabular}';
114
351
  closing: '\\end{tabular}';
115
352
  columns: string;
116
- rows: DocumentInline[][][];
117
- };
118
- type ImageBlockNode = {
353
+ rows: InlineField2[][];
354
+ metadata?: DocumentBlockMetadata;
355
+ } & FloatMeta2;
356
+ type ImageBlock2 = {
357
+ id: string;
119
358
  kind: 'image';
120
359
  command: '\\includegraphics';
121
360
  value: string;
361
+ /** Host asset identity from wire `asset_id`; preserved across value edits. */
362
+ assetId?: string;
122
363
  options: Record<string, string>;
364
+ metadata?: DocumentBlockMetadata;
365
+ } & FloatMeta2;
366
+ type BibliographyBlock2 = {
367
+ id: string;
368
+ kind: 'bibliography';
369
+ command: '\\begin{thebibliography}';
370
+ closing: '\\end{thebibliography}';
371
+ metadata?: DocumentBlockMetadata;
123
372
  };
124
- type RawBlockNode = {
373
+ type RawBlock2 = {
374
+ id: string;
125
375
  kind: 'raw';
126
376
  command: '\\raw';
127
377
  value: string;
378
+ metadata?: DocumentBlockMetadata;
128
379
  };
129
- type DocumentBlockNode = TextBlockNode | ListBlockNode | TableBlockNode | ImageBlockNode | RawBlockNode;
380
+ type DocumentBlock = TextBlock2 | ListBlock2 | TableBlock2 | ImageBlock2 | BibliographyBlock2 | RawBlock2;
130
381
  type DocumentNode = {
131
382
  nodeType: 'DocumentObject';
132
- blocks: DocumentBlockNode[];
383
+ meta: DocumentMeta;
384
+ references: Reference2[];
385
+ blocks: DocumentBlock[];
386
+ diagnostics: DocumentDiagnostic[];
133
387
  };
134
- type DetectedMathSpan = {
388
+ type ImportDocumentOptions = {
389
+ strict?: boolean;
390
+ mode?: DocumentParseMode;
391
+ };
392
+ type DetectedMathSpan2 = {
135
393
  start: number;
136
394
  end: number;
137
395
  source: string;
138
- mathMode: string;
396
+ opening: string;
139
397
  closing: string;
398
+ display: boolean;
399
+ };
400
+ type DetectedCiteSpan2 = {
401
+ kind: 'cite';
402
+ start: number;
403
+ end: number;
404
+ source: string;
405
+ keys: string[];
406
+ };
407
+ type DetectedRefSpan2 = {
408
+ kind: 'ref';
409
+ start: number;
410
+ end: number;
411
+ source: string;
412
+ keys: string[];
413
+ refCommand: 'ref' | 'eqref';
414
+ };
415
+ type DetectedInlineSpan2 = ({
416
+ kind: 'math';
417
+ } & DetectedMathSpan2) | DetectedCiteSpan2 | DetectedRefSpan2;
418
+ type PreviewInline2 = {
419
+ kind: 'text';
420
+ text: string;
421
+ style?: TextStyle2;
422
+ } | {
423
+ kind: 'math';
424
+ id: string;
425
+ tex: string;
426
+ display: boolean;
427
+ output: DocumentMathOutput;
428
+ editable: boolean;
429
+ } | {
430
+ kind: 'cite';
431
+ id: string;
432
+ keys: string[];
433
+ label: string;
434
+ } | {
435
+ kind: 'ref';
436
+ id: string;
437
+ keys: string[];
438
+ refCommand: 'ref' | 'eqref';
439
+ label: string;
440
+ };
441
+ type PreviewBlock2 = {
442
+ kind: 'basmala';
443
+ id: string;
444
+ text: string;
445
+ tex: string;
446
+ } | {
447
+ kind: 'titleBlock';
448
+ id: string;
449
+ title?: string;
450
+ authors?: string;
451
+ date?: string;
452
+ } | {
453
+ kind: 'abstract';
454
+ id: string;
455
+ text: string;
456
+ } | {
457
+ kind: 'closing';
458
+ id: string;
459
+ text: string;
460
+ tex: string;
461
+ } | {
462
+ kind: 'heading';
463
+ id: string;
464
+ level: 1 | 2 | 3;
465
+ inlines: PreviewInline2[];
466
+ metadata?: DocumentBlockMetadata;
467
+ } | {
468
+ kind: 'paragraph';
469
+ id: string;
470
+ inlines: PreviewInline2[];
471
+ centered?: boolean;
472
+ metadata?: DocumentBlockMetadata;
473
+ } | {
474
+ kind: 'list';
475
+ id: string;
476
+ ordered: boolean;
477
+ items: Array<{
478
+ id: string;
479
+ inlines: PreviewInline2[];
480
+ blocks: PreviewBlock2[];
481
+ }>;
482
+ metadata?: DocumentBlockMetadata;
483
+ } | {
484
+ kind: 'table';
485
+ id: string;
486
+ rows: PreviewInline2[][][];
487
+ /** Compatibility source string for hosts that still read caption directly. */
488
+ caption?: string;
489
+ /** Structured caption rendering path, including MathIsland tokens. */
490
+ captionInlines?: PreviewInline2[];
491
+ label?: string;
492
+ numberLabel?: string;
493
+ metadata?: DocumentBlockMetadata;
494
+ } | {
495
+ kind: 'image';
496
+ id: string;
497
+ src: string;
498
+ assetId?: string;
499
+ options: Record<string, string>;
500
+ centered?: boolean;
501
+ /** Compatibility source string for alt text/legacy hosts. */
502
+ caption?: string;
503
+ /** Structured caption rendering path, including MathIsland tokens. */
504
+ captionInlines?: PreviewInline2[];
505
+ label?: string;
506
+ numberLabel?: string;
507
+ metadata?: DocumentBlockMetadata;
508
+ } | {
509
+ kind: 'bibliography';
510
+ id: string;
511
+ items: Array<{
512
+ id: string;
513
+ numberLabel: string;
514
+ key: string;
515
+ authors: string;
516
+ title: string;
517
+ year: string;
518
+ url: string;
519
+ venue: string;
520
+ fieldSeparator: ReferenceFieldSeparator;
521
+ }>;
522
+ metadata?: DocumentBlockMetadata;
523
+ }
524
+ /** Preview-only: raw / unknown blocks are omitted from preview until we add proper rendering. */
525
+ | {
526
+ kind: 'omit';
527
+ id: string;
528
+ metadata?: DocumentBlockMetadata;
140
529
  };
141
- type DocumentPreviewMathIsland = {
530
+ type MathIsland2 = {
142
531
  id: string;
143
532
  tex: string;
144
533
  display: boolean;
534
+ output: DocumentMathOutput;
535
+ editable: boolean;
145
536
  };
146
537
  type DocumentPreview = {
147
- html: string;
148
- mathIslands: DocumentPreviewMathIsland[];
538
+ blocks: PreviewBlock2[];
539
+ mathIslands: MathIsland2[];
540
+ };
541
+ type FormatCiteLabelOptions = {
542
+ documentDirection?: DocumentDirection;
543
+ digitForm?: DigitFormId;
149
544
  };
150
545
 
151
- declare function fromDocumentJson(json: unknown, mode?: DocumentParseMode): DocumentNode;
152
- declare function createEmptyDocument(): DocumentNode;
153
- declare function createTextBlock(command: TextBlockNode['command'], value?: string): TextBlockNode;
154
- declare function createRawBlock(value?: string): RawBlockNode;
155
- declare function createListBlock(command: ListBlockNode['command'], items?: string[]): ListBlockNode;
156
- declare function createTableBlock(rows?: string[][], columns?: string): TableBlockNode;
157
- declare function createImageBlock(value?: string, options?: Record<string, string>): ImageBlockNode;
158
- declare function isSupportedDocumentCommand(command: string): command is DocumentCommand;
546
+ type DocumentLabelKind = 'fig' | 'tab' | 'eq';
547
+ type DocumentLabelEntry = {
548
+ key: string;
549
+ kind: DocumentLabelKind;
550
+ caption: string;
551
+ /** Block id for fig/tab, or math token id for eq. */
552
+ ownerId: string;
553
+ number: number;
554
+ };
555
+ type FloatMetaPatch = {
556
+ centered?: boolean;
557
+ captionEnabled?: boolean;
558
+ caption?: string;
559
+ labelEnabled?: boolean;
560
+ label?: string;
561
+ };
562
+ declare function defaultFloatMeta(): {
563
+ centered: true;
564
+ captionEnabled: false;
565
+ caption: string;
566
+ captionField: InlineField2;
567
+ labelEnabled: false;
568
+ label: string;
569
+ };
570
+ declare function parseFloatMetaFromJson(json: {
571
+ caption?: string;
572
+ label?: string;
573
+ caption_enabled?: boolean;
574
+ label_enabled?: boolean;
575
+ centered?: boolean;
576
+ }): {
577
+ centered: boolean;
578
+ captionEnabled: boolean;
579
+ caption: string;
580
+ labelEnabled: boolean;
581
+ label: string;
582
+ };
583
+ declare function parseRefKeys(source: string): {
584
+ keys: string[];
585
+ refCommand: 'ref' | 'eqref';
586
+ };
587
+ declare function refTokenLatex(keys: string[], refCommand: 'ref' | 'eqref'): string;
588
+ /** Collect enabled labels in document order, numbering per kind. */
589
+ declare function collectDocumentLabels(document: DocumentNode): DocumentLabelEntry[];
590
+ declare function labelNumberMap(document: DocumentNode): Map<string, {
591
+ kind: DocumentLabelKind;
592
+ number: number;
593
+ }>;
594
+ type FormatFloatCaptionTitleOptions = {
595
+ uiLocale?: ButexUiLocale;
596
+ documentDirection?: DocumentDirection;
597
+ digitForm?: DigitFormId;
598
+ };
599
+ /** Localized numbered float/equation title: الشكل ١ / Figure 1 / المعادلة ١. */
600
+ declare function formatFloatCaptionTitle(kind: DocumentLabelKind, number: number, options?: FormatFloatCaptionTitleOptions): string;
601
+ /** Caption line as shown in document preview: الشكل ١: نص / Figure 1. text. */
602
+ declare function formatFloatCaptionPreview(title: string, caption: string | undefined, uiLocale?: ButexUiLocale): string;
603
+ declare function formatRefLabel(keys: string[], document: DocumentNode, refCommand: 'ref' | 'eqref', options?: FormatCiteLabelOptions): string;
604
+ declare function stripDisplayMathDelimiters(source: string): string;
605
+ declare function applyFloatMetaPatch<T extends ImageBlock2 | TableBlock2>(block: T, patch: FloatMetaPatch): void;
159
606
 
160
- declare function fromMathObjectJson(json: unknown, mode?: DocumentParseMode): MathNode;
161
- declare function toMathObjectJson(math: MathNode): MathObjectJson;
162
- declare function renderMathNodeLatex(math: MathNode): string;
163
- declare function isDisplayMathNode(math: MathNode): boolean;
607
+ declare const BUTEX_BASMALA_LINE1 = "\u0628\u0650\u0633\u0652\u0645\u0650 \u0671\u0644\u0644\u064E\u0651\u0670\u0647\u0650 \u0671\u0644\u0631\u064E\u0651\u062D\u0652\u0645\u064E\u0670\u0646\u0650 \u0671\u0644\u0631\u064E\u0651\u062D\u0650\u064A\u0645\u0650";
608
+ declare const BUTEX_BASMALA_LINE2 = "\u0648\u064E\u0671\u0644\u0635\u064E\u0651\u0644\u064E\u0627\u0629\u064F \u0648\u064E\u0671\u0644\u0633\u064E\u0651\u0644\u064E\u0627\u0645\u064F \u0639\u064E\u0644\u064E\u0649\u0670 \u0631\u064E\u0633\u064F\u0648\u0644\u0650 \u0671\u0644\u0644\u064E\u0651\u0670\u0647\u0650";
609
+ declare const BUTEX_BASMALA_SALAWAT = "\u0635\u064E\u0644\u064E\u0651\u0649 \u0671\u0644\u0644\u064E\u0651\u0647\u064F \u0639\u064E\u0644\u064E\u064A\u0652\u0647\u0650 \u0648\u064E\u0633\u064E\u0644\u064E\u0651\u0645\u064E";
610
+ /** Three-line basmala joined for UI / plain-text matchers. */
611
+ declare const BUTEX_BASMALA = "\u0628\u0650\u0633\u0652\u0645\u0650 \u0671\u0644\u0644\u064E\u0651\u0670\u0647\u0650 \u0671\u0644\u0631\u064E\u0651\u062D\u0652\u0645\u064E\u0670\u0646\u0650 \u0671\u0644\u0631\u064E\u0651\u062D\u0650\u064A\u0645\u0650\n\u0648\u064E\u0671\u0644\u0635\u064E\u0651\u0644\u064E\u0627\u0629\u064F \u0648\u064E\u0671\u0644\u0633\u064E\u0651\u0644\u064E\u0627\u0645\u064F \u0639\u064E\u0644\u064E\u0649\u0670 \u0631\u064E\u0633\u064F\u0648\u0644\u0650 \u0671\u0644\u0644\u064E\u0651\u0670\u0647\u0650\n\u0635\u064E\u0644\u064E\u0651\u0649 \u0671\u0644\u0644\u064E\u0651\u0647\u064F \u0639\u064E\u0644\u064E\u064A\u0652\u0647\u0650 \u0648\u064E\u0633\u064E\u0644\u064E\u0651\u0645\u064E";
612
+ declare const BUTEX_CLOSING_HAMDALA = "\u0627\u0644\u0652\u062D\u064E\u0645\u0652\u062F\u064F \u0644\u0650\u0644\u064E\u0651\u0647\u0650 \u0646\u064E\u0641\u064E\u0639\u064E\u0646\u064E\u0627 \u0628\u0650\u0639\u0650\u0644\u0652\u0645\u0650\u0647\u0650";
613
+ /** Display-math body using BuTeX Diwani (for MathJax preview islands). */
614
+ declare function butexDiwaniDisplayTex(text: string): string;
615
+ /** Full display equation for XeLaTeX export. */
616
+ declare function butexDiwaniDisplayLatex(text: string): string;
617
+ /** Display-math body using BuTeX Maghribi (for document chrome). */
618
+ declare function butexMaghribiDisplayTex(text: string): string;
619
+ /** Full display equation using BuTeX Maghribi for XeLaTeX export. */
620
+ declare function butexMaghribiDisplayLatex(text: string): string;
621
+ /** Three-line Maghribi body for MathJax basmala islands. */
622
+ declare function butexBasmalaDisplayTex(): string;
623
+ /** Standalone display equation when there is no \\maketitle (title-less docs). */
624
+ declare function butexBasmalaDisplayLatex(): string;
625
+ /**
626
+ * Keep \\maketitle inside the current column when twocolumn is on.
627
+ * Standard article otherwise does \\twocolumn[\\@maketitle] and spans both columns.
628
+ * Call after titling so \\@maketitle still includes \\pretitle hooks.
629
+ */
630
+ declare function butexInColumnMaketitleHook(): string;
631
+ /** Titling hooks so the basmala stays attached to the visible title. */
632
+ declare function butexBasmalaTitlingPreamble(options?: {
633
+ twocolumn?: boolean;
634
+ }): string;
635
+ declare const HIJRI_YEAR_MIN = 1400;
636
+ declare const HIJRI_YEAR_MAX = 1500;
637
+ declare const HIJRI_MONTH_IDS: HijriMonthId[];
638
+ declare const DEFAULT_HIJRI_DATE: DocumentHijriDate;
639
+ declare function hijriMonthLabel(month: HijriMonthId, locale?: ButexUiLocale): string;
640
+ declare function emptyDocumentMeta(): DocumentMeta;
641
+ declare function normalizeDocumentHijriDate(value: unknown): DocumentHijriDate;
642
+ declare function normalizeDocumentMeta(value: unknown): DocumentMeta;
643
+ type DocumentMetaProp = Partial<Omit<DocumentMeta, 'date'>> & {
644
+ date?: Partial<DocumentHijriDate>;
645
+ };
646
+ /** Prop fills gaps; JSON wins only when the key is present on the JSON object. */
647
+ declare function mergeDocumentMeta(fromJson: unknown, fromProp?: DocumentMetaProp): DocumentMeta;
648
+ /** For live DocumentNode meta: prop fills empty title/authors/abstract; date patch merges. */
649
+ declare function fillDocumentMetaGaps(current: DocumentMeta, fromProp?: DocumentMetaProp): DocumentMeta;
650
+ declare function documentHasMaketitle(meta: DocumentMeta): boolean;
651
+ declare function documentHasAbstract(meta: DocumentMeta): boolean;
652
+ declare function documentHasTitleStack(meta: DocumentMeta): boolean;
653
+ type FormatHijriDateOptions = {
654
+ locale?: ButexUiLocale;
655
+ digitForm?: DigitFormId;
656
+ };
657
+ declare function formatHijriDate(date: DocumentHijriDate, options?: FormatHijriDateOptions | ButexUiLocale): string;
658
+ declare function cloneDocumentMeta(meta: DocumentMeta): DocumentMeta;
164
659
 
165
- type EditorSide = 'english' | 'arabic';
166
- type EditorNodeKind = 'char' | 'number' | 'operator' | 'delimiter' | 'boxed' | 'frac' | 'sqrt' | 'overset' | 'underset' | 'accent' | 'env' | 'atomicCommand' | 'atomicOperatorCommand' | 'standardCommand';
167
- type MatrixEnvStyle = 'matrix' | 'pmatrix' | 'bmatrix' | 'Bmatrix' | 'vmatrix' | 'Vmatrix';
168
- type GridEnvName = MatrixEnvStyle | 'array' | 'aligned';
169
- type EnvColumnAlignment = 'l' | 'c' | 'r';
170
- type CharacterFontId = 'default' | 'takween' | 'diwani' | 'diwaniOutline' | 'maghribi';
171
- type DigitFormId = 'western' | 'arabicIndic' | 'persianIndic';
172
- type EditorSyncState = 'synced' | 'diverged';
173
- type EditorChain = {
174
- id: string;
175
- nodes: EditorNode[];
176
- /** Complete script authored as \\mathnormal{ordered,index,atoms}. */
177
- indexSequence?: boolean;
660
+ type DocumentImageAssetRef = {
661
+ assetId: string;
662
+ value?: string;
178
663
  };
179
- type EditorNode = {
180
- id: string;
181
- kind: EditorNodeKind;
182
- expr: string;
183
- characterFont?: CharacterFontId;
184
- /** Minimal upstream source identity used only while the node remains unchanged. */
185
- sourceLatex?: string;
186
- /** Existing editor node reused for wrapper commands that need editable content. */
187
- wrapperCommand?: '\\unit' | '\\mathtt' | '\\mathbf' | '\\boldarabic';
188
- superscript: EditorChain | null;
189
- subscript: EditorChain | null;
190
- leftDelimExpr: string;
191
- rightDelimExpr: string;
192
- innerExpr: EditorChain | null;
193
- numerator: EditorChain | null;
194
- denominator: EditorChain | null;
195
- radicand: EditorChain | null;
196
- rootIndex: EditorChain | null;
197
- overExpr: EditorChain | null;
198
- underExpr: EditorChain | null;
199
- baseExpr: EditorChain | null;
200
- envName: GridEnvName | null;
201
- matrixStyle: MatrixEnvStyle | null;
202
- matrixRows: EditorChain[][] | null;
203
- columnAlignments: EnvColumnAlignment[] | null;
664
+ type DocumentImageInput = string | DocumentImageAssetRef | undefined;
665
+ declare function findFirstInlineField(document: DocumentNode): InlineField2 | null;
666
+ declare function updateTextToken(document: DocumentNode, fieldId: string, tokenId: string, text: string): DocumentNode;
667
+ declare function cloneDocumentNode(document: DocumentNode): DocumentNode;
668
+ declare function insertDocumentBlockAfter(document: DocumentNode, afterBlockId: string | null | undefined, block: DocumentBlock): DocumentNode;
669
+ declare function moveDocumentBlockById(document: DocumentNode, blockId: string, direction: -1 | 1): DocumentNode;
670
+ declare function moveDocumentBlockRange(document: DocumentNode, from: number, to: number, direction: -1 | 1): DocumentNode;
671
+ declare function removeDocumentBlockRange(document: DocumentNode, from: number, to: number): DocumentNode;
672
+ declare function toggleTextTokenStyle(document: DocumentNode, fieldId: string, tokenId: string, selectionStart: number, selectionEnd: number, styleName: keyof TextStyle2): DocumentNode;
673
+ declare function removeMathTokenById(document: DocumentNode, tokenId: string): DocumentNode;
674
+ declare function insertMathTokenAtCaret(document: DocumentNode, fieldId: string, textTokenId: string | null, caretOffset: number, session: EditorSession, opening?: string, closing?: string, side?: EditorSide): DocumentNode;
675
+ declare function insertMathToken(document: DocumentNode, fieldId: string, insertIndex: number, session: EditorSession, opening?: string, closing?: string, side?: EditorSide): DocumentNode;
676
+ declare function replaceMathTokenFromSession(document: DocumentNode, tokenId: string, session: EditorSession, opening?: string, closing?: string, side?: EditorSide): DocumentNode;
677
+ declare function addDocumentTextBlock(document: DocumentNode, command?: '\\section' | '\\subsection' | '\\subsubsection' | '\\paragraph', afterBlockId?: string | null): DocumentNode;
678
+ declare function updateDocumentTextBlockCentered(document: DocumentNode, blockId: string, centered: boolean): DocumentNode;
679
+ declare function removeDocumentBlockById(document: DocumentNode, blockId: string): DocumentNode;
680
+ declare function addDocumentListBlock(document: DocumentNode, ordered: boolean, afterBlockId?: string | null): DocumentNode;
681
+ declare function addDocumentTableBlock(document: DocumentNode, columns?: string, rowCount?: number, colCount?: number, afterBlockId?: string | null): DocumentNode;
682
+ declare function addDocumentImageBlock(document: DocumentNode, srcOrAsset?: DocumentImageInput, afterBlockId?: string | null): DocumentNode;
683
+ declare function updateDocumentImageValue(document: DocumentNode, blockId: string, value: string): DocumentNode;
684
+ declare function updateDocumentImageAsset(document: DocumentNode, blockId: string, asset: DocumentImageAssetRef): DocumentNode;
685
+ declare function clearDocumentImageAsset(document: DocumentNode, blockId: string): DocumentNode;
686
+ declare function updateDocumentImageMeta(document: DocumentNode, blockId: string, patch: FloatMetaPatch): DocumentNode;
687
+ declare function updateDocumentTableMeta(document: DocumentNode, blockId: string, patch: FloatMetaPatch): DocumentNode;
688
+ declare function updateMathTokenLabel(document: DocumentNode, tokenId: string, patch: {
689
+ labelEnabled?: boolean;
690
+ label?: string;
691
+ }): DocumentNode;
692
+ declare function insertRefTokenAtCaret(document: DocumentNode, fieldId: string, textTokenId: string | null, caretOffset: number, keys: string[], refCommand?: 'ref' | 'eqref'): DocumentNode;
693
+ declare function updateRefTokenKeys(document: DocumentNode, tokenId: string, keys: string[], refCommand?: 'ref' | 'eqref'): DocumentNode;
694
+ declare function removeRefTokenById(document: DocumentNode, tokenId: string): DocumentNode;
695
+ declare function addDocumentListItem(document: DocumentNode, listBlockId: string): DocumentNode;
696
+ declare function removeDocumentListItem(document: DocumentNode, listBlockId: string, itemId: string): DocumentNode;
697
+ declare function insertCiteTokenAtCaret(document: DocumentNode, fieldId: string, textTokenId: string | null, caretOffset: number, keys: string[]): DocumentNode;
698
+ declare function updateCiteTokenKeys(document: DocumentNode, tokenId: string, keys: string[]): DocumentNode;
699
+ declare function removeCiteTokenById(document: DocumentNode, tokenId: string): DocumentNode;
700
+ declare function ensureDocumentBibliographyBlock(document: DocumentNode, afterBlockId?: string | null): DocumentNode;
701
+ declare function addDocumentReference(document: DocumentNode, partial?: Partial<Reference2Json>): DocumentNode;
702
+ declare function updateDocumentReference(document: DocumentNode, referenceId: string, patch: Partial<Reference2Json>): DocumentNode;
703
+ declare function removeDocumentReference(document: DocumentNode, referenceId: string): DocumentNode;
704
+ declare function moveDocumentReference(document: DocumentNode, referenceId: string, direction: -1 | 1): DocumentNode;
705
+ declare function setDocumentReferences(document: DocumentNode, references: Reference2[]): DocumentNode;
706
+ declare function updateDocumentMeta(document: DocumentNode, patch: DocumentMetaProp): DocumentNode;
707
+
708
+ type DocumentTextBlockKind = 'section' | 'subsection' | 'subsubsection' | 'paragraph';
709
+ type DocumentAnchor = {
710
+ before_block_id: string;
711
+ } | {
712
+ after_block_id: string;
713
+ } | {
714
+ end: true;
204
715
  };
205
- type EditorCaret = {
206
- chainId: string;
716
+ type DocumentInlineAnchor = {
717
+ before_token_id: string;
718
+ } | {
719
+ after_token_id: string;
720
+ } | {
721
+ start: true;
722
+ } | {
723
+ end: true;
724
+ };
725
+ type DocumentListItemAnchor = {
726
+ before_item_id: string;
727
+ } | {
728
+ after_item_id: string;
729
+ } | {
730
+ end: true;
731
+ };
732
+ type DocumentReferenceAnchor = {
733
+ before_reference_key: string;
734
+ } | {
735
+ after_reference_key: string;
736
+ } | {
737
+ end: true;
738
+ };
739
+ type DocumentInlineTokenInput = {
740
+ kind: 'text';
741
+ text: string;
742
+ style?: TextStyle2;
743
+ } | {
744
+ kind: 'math';
745
+ source: string;
746
+ math_object: MathObject2Json;
747
+ } | {
748
+ kind: 'cite';
749
+ keys: string[];
750
+ } | {
751
+ kind: 'ref';
752
+ keys: string[];
753
+ ref_command: 'ref' | 'eqref';
754
+ };
755
+ type BlockInsertion = {
756
+ anchor: DocumentAnchor;
757
+ metadata?: DocumentBlockMetadata;
758
+ };
759
+ type DocumentCommand = ({
760
+ op: 'insert_text_block';
761
+ kind: DocumentTextBlockKind;
762
+ text: string;
763
+ } & BlockInsertion) | {
764
+ op: 'replace_text_block';
765
+ block_id: string;
766
+ text: string;
767
+ } | {
768
+ op: 'remove_block';
769
+ block_id: string;
770
+ } | {
771
+ op: 'move_block';
772
+ block_id: string;
773
+ anchor: DocumentAnchor;
774
+ } | ({
775
+ op: 'insert_figure';
776
+ asset_id: string;
777
+ value?: string;
778
+ caption?: string;
779
+ label?: string;
780
+ } & BlockInsertion) | {
781
+ op: 'update_figure';
782
+ block_id: string;
783
+ asset_id?: string | null;
784
+ value?: string;
785
+ } | {
786
+ op: 'update_float_meta';
787
+ block_id: string;
788
+ centered?: boolean;
789
+ caption_enabled?: boolean;
790
+ caption?: string;
791
+ label_enabled?: boolean;
792
+ label?: string;
793
+ } | ({
794
+ op: 'insert_bibliography';
795
+ } & BlockInsertion) | {
796
+ op: 'update_document_meta';
797
+ title?: string;
798
+ authors?: string;
799
+ abstract?: string;
800
+ date?: Partial<DocumentHijriDate>;
801
+ } | ({
802
+ op: 'insert_reference';
803
+ key: string;
804
+ authors?: string;
805
+ title?: string;
806
+ year?: string;
807
+ venue?: string;
808
+ url?: string;
809
+ field_separator?: ReferenceFieldSeparator;
810
+ anchor: DocumentReferenceAnchor;
811
+ }) | {
812
+ op: 'update_reference';
813
+ reference_key: string;
814
+ key?: string;
815
+ authors?: string;
816
+ title?: string;
817
+ year?: string;
818
+ venue?: string;
819
+ url?: string;
820
+ field_separator?: ReferenceFieldSeparator;
821
+ } | {
822
+ op: 'remove_reference';
823
+ reference_key: string;
824
+ } | {
825
+ op: 'move_reference';
826
+ reference_key: string;
827
+ anchor: DocumentReferenceAnchor;
828
+ } | {
829
+ op: 'insert_inline_token';
830
+ field_id: string;
831
+ token: DocumentInlineTokenInput;
832
+ anchor: DocumentInlineAnchor;
833
+ } | {
834
+ op: 'replace_inline_token';
835
+ field_id: string;
836
+ token_id: string;
837
+ token: DocumentInlineTokenInput;
838
+ } | {
839
+ op: 'remove_inline_token';
840
+ field_id: string;
841
+ token_id: string;
842
+ } | ({
843
+ op: 'insert_list';
844
+ ordered: boolean;
845
+ items: string[];
846
+ } & BlockInsertion) | {
847
+ op: 'insert_list_item';
848
+ list_id: string;
849
+ text: string;
850
+ anchor: DocumentListItemAnchor;
851
+ } | {
852
+ op: 'replace_list_item';
853
+ list_id: string;
854
+ item_id: string;
855
+ text: string;
856
+ } | {
857
+ op: 'remove_list_item';
858
+ list_id: string;
859
+ item_id: string;
860
+ } | {
861
+ op: 'move_list_item';
862
+ list_id: string;
863
+ item_id: string;
864
+ anchor: DocumentListItemAnchor;
865
+ } | ({
866
+ op: 'insert_table';
867
+ rows: string[][];
868
+ columns: string;
869
+ caption?: string;
870
+ label?: string;
871
+ } & BlockInsertion) | {
872
+ op: 'replace_table_cell';
873
+ table_id: string;
874
+ row_index: number;
875
+ column_index: number;
876
+ text: string;
877
+ } | {
878
+ op: 'insert_table_row';
879
+ table_id: string;
880
+ index: number;
881
+ values: string[];
882
+ } | {
883
+ op: 'remove_table_row';
884
+ table_id: string;
207
885
  index: number;
886
+ } | {
887
+ op: 'move_table_row';
888
+ table_id: string;
889
+ from_index: number;
890
+ to_index: number;
891
+ } | {
892
+ op: 'insert_table_column';
893
+ table_id: string;
894
+ index: number;
895
+ values: string[];
896
+ columns: string;
897
+ } | {
898
+ op: 'remove_table_column';
899
+ table_id: string;
900
+ index: number;
901
+ columns: string;
902
+ } | {
903
+ op: 'move_table_column';
904
+ table_id: string;
905
+ from_index: number;
906
+ to_index: number;
907
+ columns: string;
208
908
  };
209
- type EditorSelectionRange = {
210
- chainId: string;
211
- anchorIndex: number;
212
- focusIndex: number;
909
+ type DocumentCommandErrorCode = 'invalid_document' | 'invalid_command' | 'missing_block_id' | 'duplicate_block_id' | 'invalid_anchor' | 'anchor_not_found' | 'block_not_found' | 'block_kind_mismatch' | 'field_not_found' | 'token_not_found' | 'list_not_found' | 'item_not_found' | 'table_not_found' | 'invalid_table_shape' | 'index_out_of_range' | 'minimum_structure' | 'invalid_inline_token' | 'math_object_mismatch' | 'unsupported_inline_content' | 'reference_not_found' | 'invalid_key' | 'duplicate_key' | 'bibliography_exists';
910
+ declare class DocumentCommandError extends Error {
911
+ readonly code: DocumentCommandErrorCode;
912
+ constructor(code: DocumentCommandErrorCode, message: string);
913
+ }
914
+
915
+ /** Apply one validated command to canonical JSON without mutating caller input. */
916
+ declare function applyDocumentCommand(json: DocumentJson, commandInput: DocumentCommand): DocumentJson;
917
+
918
+ type DocumentDiffChunkKind = 'added' | 'removed' | 'context';
919
+ type DocumentDiffChunk = {
920
+ kind: DocumentDiffChunkKind;
921
+ text: string;
213
922
  };
214
- type EditorSyncMap = Record<string, {
215
- expr: EditorSyncState;
216
- }>;
217
- type EditorDebugEntry = {
218
- timestamp: string;
923
+ type DocumentDiff = {
924
+ version: 1;
925
+ changed: boolean;
926
+ truncated: boolean;
927
+ chunks: DocumentDiffChunk[];
928
+ };
929
+ /**
930
+ * Compare two persisted Document documents using canonical Document import/export
931
+ * semantics and jsdiff's maintained JSON diff implementation.
932
+ *
933
+ * Generated editor identity sidecars are intentionally excluded so equivalent
934
+ * legacy documents do not differ merely because normalization assigned new IDs.
935
+ */
936
+ declare function diffDocument(before: DocumentJson, after: DocumentJson): DocumentDiff;
937
+
938
+ type DocumentOutlineKind = 'section' | 'subsection' | 'subsubsection' | 'paragraph' | 'list' | 'table' | 'figure' | 'bibliography' | 'raw';
939
+ type DocumentOutlineEntry = {
940
+ id: string;
941
+ kind: DocumentOutlineKind;
219
942
  command: string;
220
- activeSide: EditorSide;
221
- englishLatex: string;
222
- arabicLatex: string;
223
- renderOk: boolean;
224
- renderError: string | null;
225
- note: string;
943
+ excerpt: string;
226
944
  };
227
- type EditorSession = {
228
- englishTree: EditorChain;
229
- arabicTree: EditorChain;
230
- activeSide: EditorSide;
231
- /** When true, each typed letter/digit inserts a new char/number leaf; when false, merge into adjacent same-kind leaves. */
232
- splitLeafTyping: boolean;
233
- /** One-shot: when true, the next insertChar/insertNumber bypasses leaf-merge (used by Space in merge mode). */
234
- forceSplitNextLeaf: boolean;
235
- /** When true and active side is Arabic, merged number typing prepends digits (RTL-style); still mirrored on EN/AR. */
236
- arabicReverseNumberTyping: boolean;
237
- /** Font applied to newly typed char nodes. */
238
- currentCharacterFont: CharacterFontId;
239
- /** Structured command wrapper applied to newly typed chars; kept separate from fonts. */
240
- currentCharacterWrapper: '\\boldarabic' | null;
241
- /** Digit glyph form used for editor display and LaTeX preview output. */
242
- currentDigitForm: DigitFormId;
243
- caret: EditorCaret;
244
- /** Whole-node range selection inside a single chain (anchor==focus means no selection). */
245
- selection: EditorSelectionRange | null;
246
- selectedNodeId: string | null;
247
- selectedStructureNodeId: string | null;
248
- sync: EditorSyncMap;
249
- debugLog: EditorDebugEntry[];
945
+ /** Return a compact top-level outline for a canonical document. */
946
+ declare function documentOutline(json: DocumentJson): DocumentOutlineEntry[];
947
+
948
+ type DocumentCitationIndexEntry = {
949
+ kind: 'cite';
950
+ block_id: string;
951
+ field_id: string;
952
+ token_id: string;
953
+ keys: string[];
954
+ unresolved_keys: string[];
955
+ };
956
+ type DocumentCrossReferenceIndexEntry = {
957
+ kind: 'ref';
958
+ ref_command: 'ref' | 'eqref';
959
+ block_id: string;
960
+ field_id: string;
961
+ token_id: string;
962
+ keys: string[];
963
+ unresolved_keys: string[];
964
+ };
965
+ type DocumentIndexedLabel = {
966
+ key: string;
967
+ kind: DocumentLabelKind;
968
+ caption: string;
969
+ number: number;
970
+ block_id?: string;
971
+ field_id?: string;
972
+ token_id?: string;
973
+ };
974
+ type DocumentReferenceIndex = {
975
+ citations: DocumentCitationIndexEntry[];
976
+ cross_references: DocumentCrossReferenceIndexEntry[];
977
+ labels: DocumentIndexedLabel[];
978
+ unresolved: {
979
+ citation_keys: string[];
980
+ cross_reference_keys: string[];
981
+ };
982
+ };
983
+ /** Return a detached, read-only view of the registered bibliography catalog. */
984
+ declare function getDocumentReferences(document: DocumentNode): Reference2Json[];
985
+ /**
986
+ * Return semantic citation, cross-reference, and label relationships without
987
+ * changing the document. Entries follow document/token order and preserve the
988
+ * stable IDs already present in the live Document node.
989
+ */
990
+ declare function getDocumentReferenceIndex(document: DocumentNode): DocumentReferenceIndex;
991
+
992
+ type DocumentKeyError = 'empty' | 'invalid' | 'duplicate';
993
+ /** NFC-normalize and trim a document key (label or bibliography). */
994
+ declare function normalizeDocumentKey(key: string): string;
995
+ /** True when key matches Unicode letters/marks, decimal digits, and :._- with no spaces. */
996
+ declare function isValidDocumentKey(key: string): boolean;
997
+ type DocumentKeyNamespace = {
998
+ references?: Array<Pick<Reference2, 'id' | 'key'>>;
999
+ labels?: Array<Pick<DocumentLabelEntry, 'ownerId' | 'key'>>;
1000
+ /** Skip this reference id when checking (editing that entry). */
1001
+ excludeReferenceId?: string;
1002
+ /** Skip this label owner id when checking (editing that float/eq). */
1003
+ excludeOwnerId?: string;
1004
+ };
1005
+ /** Returns true if another reference or label already uses this key (NFC match). */
1006
+ declare function isDuplicateDocumentKey(key: string, namespace: DocumentKeyNamespace): boolean;
1007
+ /** Classify a key for UI messaging: empty, invalid charset, or duplicate. */
1008
+ declare function documentKeyError(key: string, namespace?: DocumentKeyNamespace): DocumentKeyError | null;
1009
+
1010
+ declare const DEFAULT_REFERENCE_FIELD_SEPARATOR: ReferenceFieldSeparator;
1011
+ declare function normalizeReferenceFieldSeparator(value: unknown): ReferenceFieldSeparator;
1012
+ declare function referenceNumberMap(references: Array<Pick<Reference2, 'key'>>): Map<string, number>;
1013
+ declare function resolveCiteNumbers(keys: string[], references: Array<Pick<Reference2, 'key'>>): Array<number | null>;
1014
+ declare function formatCiteLabel(keys: string[], references: Array<Pick<Reference2, 'key'>>, options?: FormatCiteLabelOptions): string;
1015
+ declare function formatBibliographyNumber(index: number, options?: FormatCiteLabelOptions): string;
1016
+ declare function parseCiteKeys(source: string): string[];
1017
+ declare function citeTokenLatex(keys: string[]): string;
1018
+ declare function referenceFromJson(json: Reference2Json): Reference2;
1019
+ declare function createEmptyReference(partial?: Partial<Reference2Json>): Reference2;
1020
+ /** Joined authors/title/venue/year for preview and export (no \\bibitem wrapper). */
1021
+ declare function bibliographyEntryBody(reference: Pick<Reference2, 'authors' | 'title' | 'venue' | 'year' | 'fieldSeparator'>, separator?: ReferenceFieldSeparator, options?: {
1022
+ digitForm?: DigitFormId;
1023
+ }): string;
1024
+ declare function bibliographyEntryLatex(reference: Reference2): string;
1025
+ /**
1026
+ * Build an href for a bibliography URL. Values without a scheme become https://…
1027
+ * so the browser does not resolve them against the editor origin (e.g. localhost).
1028
+ * Leaves http(s)/mailto/ftp and other schemed URLs unchanged. Empty → ''.
1029
+ */
1030
+ declare function absoluteHttpHref(url: string): string;
1031
+
1032
+ type ArabicDigitsMapping = 'arabicdigits' | 'farsidigits' | 'digits';
1033
+ type ArabicXeLatexPreambleOptions = {
1034
+ digitsMapping?: ArabicDigitsMapping;
1035
+ /** When true, add the article class twocolumn option. Default false. */
1036
+ twocolumn?: boolean;
1037
+ };
1038
+ declare function arabicXeLatexPreamblePkg(twocolumn?: boolean): string;
1039
+ declare function arabicXeLatexPreambleFont(digitsMapping?: ArabicDigitsMapping): string;
1040
+ declare function arabicXeLatexPreambleCmd(): string;
1041
+ declare function getArabicXeLatexPreamble(digitsMappingOrOptions?: ArabicDigitsMapping | ArabicXeLatexPreambleOptions): string;
1042
+
1043
+ type DocumentLatexOptions = {
1044
+ /**
1045
+ * When true (default), emit a complete Arabic XeLaTeX file:
1046
+ * preamble + \\begin{document} + body + \\end{document}.
1047
+ * Pass false for body-only blocks.
1048
+ */
1049
+ wrapDocument?: boolean;
1050
+ /** Font digit Mapping when wrapping. Default 'arabicdigits'. */
1051
+ digitsMapping?: ArabicDigitsMapping;
1052
+ /** Document-level digit form for XeLaTeX font Mapping. Ignored when digitsMapping is set. */
1053
+ digitForm?: DigitFormId;
1054
+ /** When true, use article class option twocolumn. Default false. */
1055
+ twocolumn?: boolean;
250
1056
  };
1057
+ declare function inlineFieldLatex(field: InlineField2): string;
1058
+
1059
+ /** Convert the live editor AST to the canonical JSON wire format. */
1060
+ declare function toDocumentJson(document: DocumentNode): DocumentJson;
251
1061
 
252
- type MathNodeFromEditorResult = {
253
- ok: true;
254
- math: MathNode;
1062
+ type DocumentValidationIssueCode = 'malformed_document' | 'parser_diagnostic' | 'empty_image' | 'unsupported_emoji' | 'key_empty' | 'key_invalid' | 'key_duplicate' | 'empty_citation' | 'missing_citation' | 'empty_reference' | 'missing_reference' | 'reference_kind_mismatch' | 'invalid_equation_label' | 'invalid_table';
1063
+ type DocumentValidationIssue = {
1064
+ code: DocumentValidationIssueCode;
1065
+ path: string;
1066
+ blockId?: string;
1067
+ tokenId?: string;
1068
+ };
1069
+ type DocumentValidationResult = {
1070
+ valid: boolean;
1071
+ issues: DocumentValidationIssue[];
1072
+ };
1073
+ /** True when the current XeLaTeX text profile cannot render the value reliably. */
1074
+ declare function hasXeLatexUnsupportedEmoji(value: string): boolean;
1075
+ /**
1076
+ * Validate a Document draft without mutating it. Detailed issues are kept in
1077
+ * BuTeX so React can identify the field while hosts only need the boolean API.
1078
+ */
1079
+ declare function validateDocument(document: DocumentJson | DocumentNode): DocumentValidationResult;
1080
+ /** Public host contract: drafts may be saved, but only valid documents may compile. */
1081
+ declare function isDocumentValid(document: DocumentJson | DocumentNode): boolean;
1082
+ /** Error thrown when LaTeX export is attempted for an invalid Document draft. */
1083
+ declare class DocumentValidationError extends Error {
1084
+ readonly issues: DocumentValidationIssue[];
1085
+ constructor(issues: DocumentValidationIssue[]);
1086
+ }
1087
+
1088
+ declare const DEFAULT_DOCUMENT_HISTORY_MAX_DEPTH = 100;
1089
+ type DocumentHistoryStacks = {
1090
+ past: DocumentNode[];
1091
+ future: DocumentNode[];
1092
+ maxDepth: number;
1093
+ };
1094
+ declare function createDocumentHistory(maxDepth?: number): DocumentHistoryStacks;
1095
+ declare function pushDocumentSnapshot(stacks: DocumentHistoryStacks, documentBeforeEdit: DocumentNode): void;
1096
+ declare function restoreDocumentUndo(stacks: DocumentHistoryStacks, documentNow: DocumentNode): DocumentNode | null;
1097
+ declare function restoreDocumentRedo(stacks: DocumentHistoryStacks, documentNow: DocumentNode): DocumentNode | null;
1098
+ declare function documentHistoryCanUndo(stacks: DocumentHistoryStacks): boolean;
1099
+ declare function documentHistoryCanRedo(stacks: DocumentHistoryStacks): boolean;
1100
+
1101
+ type BlockSelectionRange = {
1102
+ from: number;
1103
+ to: number;
1104
+ };
1105
+ type BlockSelectionState = {
1106
+ selection: BlockSelectionRange | null;
1107
+ anchor: number | null;
1108
+ };
1109
+ declare function emptyBlockSelection(): BlockSelectionState;
1110
+ declare function normalizeBlockSelection(selection: BlockSelectionRange | null, blockCount: number): BlockSelectionRange | null;
1111
+ /** Checkbox click without Shift */
1112
+ declare function toggleBlockInSelection(state: BlockSelectionState, index: number, blockCount: number): BlockSelectionState;
1113
+ /** Shift+click on checkbox or header label */
1114
+ declare function extendBlockSelectionFromAnchor(state: BlockSelectionState, index: number, blockCount: number): BlockSelectionState;
1115
+ declare function remapSelectionAfterRangeMove(selection: BlockSelectionRange, direction: -1 | 1): BlockSelectionRange;
1116
+
1117
+ declare function createInlineField(value?: string, mathObjects?: Array<DocumentMathObjectJson | null>, options?: ImportDocumentOptions, path?: string, diagnostics?: DocumentDiagnostic[], formats?: TextFormatSpan2Json[]): InlineField2;
1118
+ declare function fromDocumentJson(json: unknown, options?: ImportDocumentOptions): DocumentNode;
1119
+ declare function createEmptyDocument(): DocumentNode;
1120
+
1121
+ /** Math-only spans (used for math_objects alignment counts). */
1122
+ declare function detectMathSpans(value: string): DetectedMathSpan2[];
1123
+ /** Left-to-right math + \\cite + \\ref/\\eqref spans without overlap. */
1124
+ declare function detectInlineSpans(value: string): DetectedInlineSpan2[];
1125
+
1126
+ type DocumentMathBridgeResult = {
1127
+ editable: true;
1128
+ session: EditorSession;
255
1129
  } | {
256
- ok: false;
1130
+ editable: false;
257
1131
  reason: string;
258
1132
  };
259
- declare function mathNodeFromEditorSession(session: EditorSession, mathMode?: string, closing?: string): MathNodeFromEditorResult;
260
- declare function mathSourceFromEditorSession(session: EditorSession, mathMode?: string, closing?: string): string;
1133
+ declare function createEmptyEquationSession(side?: EditorSide): EditorSession;
1134
+ declare function createEmptyArabicEquationSession(): EditorSession;
1135
+ declare function mathTokenToEditorSession(math: MathNode | null, side?: EditorSide): DocumentMathBridgeResult;
1136
+ declare function mathTokenToArabicEditorSession(math: MathNode | null): DocumentMathBridgeResult;
1137
+ declare function mathSourceFromSession(session: EditorSession, side: EditorSide, opening?: string, closing?: string): string;
1138
+ declare function mathSourceFromArabicSession(session: EditorSession, opening?: string, closing?: string): string;
1139
+ declare function mathNodeFromSession(session: EditorSession, opening?: string, closing?: string): MathNode;
1140
+ declare function mathNodeFromArabicSession(session: EditorSession, opening?: string, closing?: string): MathNode;
1141
+ declare function mathTokenSourceForSide(token: MathToken2, side: EditorSide, digitForm?: DigitFormId): string;
261
1142
 
262
- declare function detectMathSpans(value: string): DetectedMathSpan[];
263
- declare function buildInlines(value: string, mathObjects?: Array<MathObjectJson | null>, mode?: DocumentParseMode): DocumentInline[];
264
-
265
- declare function renderDocumentLatex(document: DocumentNode): string;
266
- declare function buildDocumentPreview(document: DocumentNode): DocumentPreview;
1143
+ type DocumentPreviewOptions = {
1144
+ documentDirection?: DocumentDirection;
1145
+ digitForm?: DigitFormId;
1146
+ uiLocale?: ButexUiLocale;
1147
+ };
1148
+ declare function documentPreview(document: DocumentNode, output?: DocumentMathOutput, equationSide?: EditorSide, previewOptions?: DocumentPreviewOptions): DocumentPreview;
267
1149
 
268
- type NewDocumentBlockKind = 'section' | 'subsection' | 'subsubsection' | 'paragraph' | 'itemize' | 'enumerate' | 'table' | 'image' | 'raw';
269
- type DocumentMathTarget = {
270
- scope: 'block';
271
- blockIndex: number;
272
- spanIndex: number;
273
- } | {
274
- scope: 'listItem';
275
- blockIndex: number;
276
- itemIndex: number;
277
- spanIndex: number;
278
- } | {
279
- scope: 'tableCell';
280
- blockIndex: number;
281
- rowIndex: number;
282
- columnIndex: number;
283
- spanIndex: number;
284
- };
285
- type DocumentInlineTarget = {
286
- scope: 'block';
287
- blockIndex: number;
288
- } | {
289
- scope: 'listItem';
290
- blockIndex: number;
291
- itemIndex: number;
292
- } | {
293
- scope: 'tableCell';
294
- blockIndex: number;
295
- rowIndex: number;
296
- columnIndex: number;
297
- };
298
- declare function createDocumentBlock(kind: NewDocumentBlockKind): DocumentBlockNode;
299
- declare function addDocumentBlock(document: DocumentNode, kind: NewDocumentBlockKind): DocumentNode;
300
- declare function removeDocumentBlock(document: DocumentNode, blockIndex: number): DocumentNode;
301
- declare function moveDocumentBlock(document: DocumentNode, blockIndex: number, direction: -1 | 1): DocumentNode;
302
- declare function updateTextBlockValue(document: DocumentNode, blockIndex: number, value: string): DocumentNode;
303
- declare function updateRawBlockValue(document: DocumentNode, blockIndex: number, value: string): DocumentNode;
304
- declare function updateImageBlock(document: DocumentNode, blockIndex: number, value: string, options: Record<string, string>): DocumentNode;
305
- declare function updateListItemValue(document: DocumentNode, blockIndex: number, itemIndex: number, value: string): DocumentNode;
306
- declare function addListItem(document: DocumentNode, blockIndex: number): DocumentNode;
307
- declare function removeListItem(document: DocumentNode, blockIndex: number, itemIndex: number): DocumentNode;
308
- declare function addNestedListBlock(document: DocumentNode, blockIndex: number, itemIndex: number, kind: 'itemize' | 'enumerate'): DocumentNode;
309
- declare function updateTableCell(document: DocumentNode, blockIndex: number, rowIndex: number, columnIndex: number, value: string): DocumentNode;
310
- declare function updateTableColumns(document: DocumentNode, blockIndex: number, columns: string): DocumentNode;
311
- declare function addTableRow(document: DocumentNode, blockIndex: number): DocumentNode;
312
- declare function removeTableRow(document: DocumentNode, blockIndex: number): DocumentNode;
313
- declare function addTableColumn(document: DocumentNode, blockIndex: number): DocumentNode;
314
- declare function removeTableColumn(document: DocumentNode, blockIndex: number): DocumentNode;
315
- declare function replaceMathSpanSource(document: DocumentNode, target: DocumentMathTarget, source: string): DocumentNode;
316
- declare function replaceMathSpanFromEditor(document: DocumentNode, target: DocumentMathTarget, math: MathNode, source?: string): DocumentNode;
317
- declare function insertMathSpanFromEditor(document: DocumentNode, target: DocumentInlineTarget, insertAt: number, math: MathNode, source?: string): DocumentNode;
318
- declare function documentInlineText(inlines: DocumentInline[]): string;
1150
+ /**
1151
+ * Export a validated Document runtime node. Invalid drafts remain saveable,
1152
+ * but compilation must not silently receive unsafe or unreliable LaTeX.
1153
+ */
1154
+ declare function documentLatex(document: DocumentNode, options?: DocumentLatexOptions): string;
319
1155
 
320
- export { type DetectedMathSpan, type DocumentBlockJson, type DocumentBlockNode, type DocumentCommand, type DocumentInline, type DocumentInlineTarget, type DocumentJson, type DocumentListItemJson, type DocumentMathTarget, type DocumentNode, type DocumentParseMode, type DocumentPreview, type DocumentPreviewMathIsland, type ImageBlockNode, type ListBlockNode, type ListItemNode, type MathInline, type MathNode, type MathObjectJson, type NewDocumentBlockKind, type RawBlockNode, type TableBlockNode, type TextBlockNode, type TextInline, addDocumentBlock, addListItem, addNestedListBlock, addTableColumn, addTableRow, buildDocumentPreview, buildInlines, createDocumentBlock, createEmptyDocument, createImageBlock, createListBlock, createRawBlock, createTableBlock, createTextBlock, detectMathSpans, documentInlineText, fromDocumentJson, fromMathObjectJson, insertMathSpanFromEditor, isDisplayMathNode, isSupportedDocumentCommand, mathNodeFromEditorSession, mathSourceFromEditorSession, moveDocumentBlock, removeDocumentBlock, removeListItem, removeTableColumn, removeTableRow, renderDocumentLatex, renderMathNodeLatex, replaceMathSpanFromEditor, replaceMathSpanSource, toMathObjectJson, updateImageBlock, updateListItemValue, updateRawBlockValue, updateTableCell, updateTableColumns, updateTextBlockValue };
1156
+ export { type ArabicDigitsMapping, type ArabicXeLatexPreambleOptions, BUTEX_BASMALA, BUTEX_BASMALA_LINE1, BUTEX_BASMALA_LINE2, BUTEX_BASMALA_SALAWAT, BUTEX_CLOSING_HAMDALA, type BibliographyBlock2, type BlockSelectionRange, type BlockSelectionState, type CiteToken2, DEFAULT_DOCUMENT_HISTORY_MAX_DEPTH, DEFAULT_HIJRI_DATE, DEFAULT_REFERENCE_FIELD_SEPARATOR, type DocumentAnchor, type DocumentBlock, type DocumentBlockJson, type DocumentBlockMetadata, type DocumentCitationIndexEntry, type DocumentCommand, DocumentCommandError, type DocumentCommandErrorCode, type DocumentCrossReferenceIndexEntry, type DocumentDiagnostic, type DocumentDiff, type DocumentDiffChunk, type DocumentDiffChunkKind, type DocumentDirection, type DocumentHijriDate, type DocumentHistoryStacks, type DocumentImageAssetRef, type DocumentIndexedLabel, type DocumentInlineAnchor, type DocumentInlineIdsJson, type DocumentInlineTokenIdJson, type DocumentInlineTokenInput, type DocumentJson, type DocumentKeyError, type DocumentKeyNamespace, type DocumentLabelEntry, type DocumentLabelKind, type DocumentLatexOptions, type DocumentListItemAnchor, type DocumentMathObjectJson, type DocumentMathOutput, type DocumentMeta, type DocumentMetaProp, type DocumentNode, type DocumentOutlineEntry, type DocumentOutlineKind, type DocumentPreview, type DocumentPreviewOptions, type DocumentReferenceAnchor, type DocumentReferenceIndex, type DocumentTextBlockKind, DocumentValidationError, type DocumentValidationIssue, type DocumentValidationIssueCode, type DocumentValidationResult, type FloatMeta2, type FloatMetaPatch, type FormatCiteLabelOptions, type FormatFloatCaptionTitleOptions, HIJRI_MONTH_IDS, HIJRI_YEAR_MAX, HIJRI_YEAR_MIN, type HijriMonthId, type ImageBlock2, type ImportDocumentOptions, type InlineField2, type InlineToken2, type ListBlock2, type ListItem2, type MathIsland2, type MathObject2Json, type MathToken2, type PreviewBlock2, type PreviewInline2, type RawBlock2, type RawMathObject2Json, type RefToken2, type Reference2, type Reference2Json, type ReferenceFieldSeparator, type TableBlock2, type TextBlock2, type TextFormatSpan2Json, type TextStyle2, type TextToken2, absoluteHttpHref, addDocumentImageBlock, addDocumentListBlock, addDocumentListItem, addDocumentReference, addDocumentTableBlock, addDocumentTextBlock, applyDocumentCommand, applyFloatMetaPatch, arabicXeLatexPreambleCmd, arabicXeLatexPreambleFont, arabicXeLatexPreamblePkg, bibliographyEntryBody, bibliographyEntryLatex, butexBasmalaDisplayLatex, butexBasmalaDisplayTex, butexBasmalaTitlingPreamble, butexDiwaniDisplayLatex, butexDiwaniDisplayTex, butexInColumnMaketitleHook, butexMaghribiDisplayLatex, butexMaghribiDisplayTex, citeTokenLatex, clearDocumentImageAsset, cloneDocumentMeta, cloneDocumentNode, collectDocumentLabels, createDocumentHistory, createEmptyArabicEquationSession, createEmptyDocument, createEmptyEquationSession, createEmptyReference, createInlineField, defaultFloatMeta, detectInlineSpans, detectMathSpans, diffDocument, documentHasAbstract, documentHasMaketitle, documentHasTitleStack, documentHistoryCanRedo, documentHistoryCanUndo, documentKeyError, documentLatex, documentOutline, documentPreview, emptyBlockSelection, emptyDocumentMeta, ensureDocumentBibliographyBlock, extendBlockSelectionFromAnchor, fillDocumentMetaGaps, findFirstInlineField, formatBibliographyNumber, formatCiteLabel, formatFloatCaptionPreview, formatFloatCaptionTitle, formatHijriDate, formatRefLabel, fromDocumentJson, getArabicXeLatexPreamble, getDocumentReferenceIndex, getDocumentReferences, hasXeLatexUnsupportedEmoji, hijriMonthLabel, inlineFieldLatex, insertCiteTokenAtCaret, insertDocumentBlockAfter, insertMathToken, insertMathTokenAtCaret, insertRefTokenAtCaret, isDocumentValid, isDuplicateDocumentKey, isValidDocumentKey, labelNumberMap, mathNodeFromArabicSession, mathNodeFromSession, mathSourceFromArabicSession, mathSourceFromSession, mathTokenSourceForSide, mathTokenToArabicEditorSession, mathTokenToEditorSession, mergeDocumentMeta, moveDocumentBlockById, moveDocumentBlockRange, moveDocumentReference, normalizeBlockSelection, normalizeDocumentHijriDate, normalizeDocumentKey, normalizeDocumentMeta, normalizeReferenceFieldSeparator, parseCiteKeys, parseFloatMetaFromJson, parseRefKeys, pushDocumentSnapshot, refTokenLatex, referenceFromJson, referenceNumberMap, remapSelectionAfterRangeMove, removeCiteTokenById, removeDocumentBlockById, removeDocumentBlockRange, removeDocumentListItem, removeDocumentReference, removeMathTokenById, removeRefTokenById, replaceMathTokenFromSession, resolveCiteNumbers, restoreDocumentRedo, restoreDocumentUndo, setDocumentReferences, stripDisplayMathDelimiters, toDocumentJson, toggleBlockInSelection, toggleTextTokenStyle, updateCiteTokenKeys, updateDocumentImageAsset, updateDocumentImageMeta, updateDocumentImageValue, updateDocumentMeta, updateDocumentReference, updateDocumentTableMeta, updateDocumentTextBlockCentered, updateMathTokenLabel, updateRefTokenKeys, updateTextToken, validateDocument };