@drghaliasri/butex 5.3.1 → 5.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/document2.d.mts +96 -51
- package/dist/document2.d.ts +96 -51
- package/dist/document2.js +119 -10
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs +109 -10
- package/dist/document2.mjs.map +1 -1
- package/dist/react-document2.d.mts +72 -52
- package/dist/react-document2.d.ts +72 -52
- package/dist/react-document2.js +809 -279
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +764 -234
- package/dist/react-document2.mjs.map +1 -1
- package/package.json +1 -1
package/dist/document2.d.mts
CHANGED
|
@@ -1,51 +1,3 @@
|
|
|
1
|
-
type ArabicNodeJson = {
|
|
2
|
-
node_type: string;
|
|
3
|
-
expr?: string;
|
|
4
|
-
name?: string;
|
|
5
|
-
superscript?: ChainJson | null;
|
|
6
|
-
subscript?: ChainJson | null;
|
|
7
|
-
left_delim_expr?: string;
|
|
8
|
-
right_delim_expr?: string;
|
|
9
|
-
inner_expr?: ChainJson;
|
|
10
|
-
optional_args?: ChainJson[];
|
|
11
|
-
mandatory_args?: ChainJson[];
|
|
12
|
-
opening?: string;
|
|
13
|
-
closing?: string;
|
|
14
|
-
lines?: ChainJson[];
|
|
15
|
-
};
|
|
16
|
-
type ChainJson = {
|
|
17
|
-
node_type: 'ChainClass';
|
|
18
|
-
chain: ArabicNodeJson[];
|
|
19
|
-
};
|
|
20
|
-
declare class State {
|
|
21
|
-
}
|
|
22
|
-
declare class BaseAstNode {
|
|
23
|
-
state: State;
|
|
24
|
-
superscript: ChainNode | null;
|
|
25
|
-
subscript: ChainNode | null;
|
|
26
|
-
nodeType: string;
|
|
27
|
-
constructor(state?: State | null);
|
|
28
|
-
latex(): string;
|
|
29
|
-
arabicLatex(): string;
|
|
30
|
-
toArabicLatex(): string;
|
|
31
|
-
/** Latin-style scripts: `^{...}` and `_{...}` for english_json rendering. */
|
|
32
|
-
latexScripts(): string;
|
|
33
|
-
/**
|
|
34
|
-
* Arabic scripts use \\prescript{sup}{sub}{content} (matches reference Python output).
|
|
35
|
-
* Call with rendered strings for sup/sub chains (may be empty strings).
|
|
36
|
-
*/
|
|
37
|
-
arabicLatexScripts(sup: string, sub: string, content: string): string;
|
|
38
|
-
}
|
|
39
|
-
declare class ChainNode {
|
|
40
|
-
chain: BaseAstNode[];
|
|
41
|
-
constructor(chain?: BaseAstNode[]);
|
|
42
|
-
latex(): string;
|
|
43
|
-
toEnglishLatex(): string;
|
|
44
|
-
/** RTL: reverse order relative to Latin chain (see test/ref_tests.txt). */
|
|
45
|
-
arabicLatex(): string;
|
|
46
|
-
toArabicLatex(): string;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
1
|
type EditorSide = 'english' | 'arabic';
|
|
50
2
|
type EditorNodeKind = 'char' | 'number' | 'operator' | 'delimiter' | 'frac' | 'sqrt' | 'env' | 'atomicCommand' | 'atomicOperatorCommand';
|
|
51
3
|
type MatrixEnvStyle = 'matrix' | 'pmatrix' | 'bmatrix' | 'Bmatrix' | 'vmatrix' | 'Vmatrix';
|
|
@@ -122,6 +74,56 @@ type EditorSession = {
|
|
|
122
74
|
debugLog: EditorDebugEntry[];
|
|
123
75
|
};
|
|
124
76
|
|
|
77
|
+
type ButexUiLocale = 'ar' | 'en';
|
|
78
|
+
|
|
79
|
+
type ArabicNodeJson = {
|
|
80
|
+
node_type: string;
|
|
81
|
+
expr?: string;
|
|
82
|
+
name?: string;
|
|
83
|
+
superscript?: ChainJson | null;
|
|
84
|
+
subscript?: ChainJson | null;
|
|
85
|
+
left_delim_expr?: string;
|
|
86
|
+
right_delim_expr?: string;
|
|
87
|
+
inner_expr?: ChainJson;
|
|
88
|
+
optional_args?: ChainJson[];
|
|
89
|
+
mandatory_args?: ChainJson[];
|
|
90
|
+
opening?: string;
|
|
91
|
+
closing?: string;
|
|
92
|
+
lines?: ChainJson[];
|
|
93
|
+
};
|
|
94
|
+
type ChainJson = {
|
|
95
|
+
node_type: 'ChainClass';
|
|
96
|
+
chain: ArabicNodeJson[];
|
|
97
|
+
};
|
|
98
|
+
declare class State {
|
|
99
|
+
}
|
|
100
|
+
declare class BaseAstNode {
|
|
101
|
+
state: State;
|
|
102
|
+
superscript: ChainNode | null;
|
|
103
|
+
subscript: ChainNode | null;
|
|
104
|
+
nodeType: string;
|
|
105
|
+
constructor(state?: State | null);
|
|
106
|
+
latex(): string;
|
|
107
|
+
arabicLatex(): string;
|
|
108
|
+
toArabicLatex(): string;
|
|
109
|
+
/** Latin-style scripts: `^{...}` and `_{...}` for english_json rendering. */
|
|
110
|
+
latexScripts(): string;
|
|
111
|
+
/**
|
|
112
|
+
* Arabic scripts use \\prescript{sup}{sub}{content} (matches reference Python output).
|
|
113
|
+
* Call with rendered strings for sup/sub chains (may be empty strings).
|
|
114
|
+
*/
|
|
115
|
+
arabicLatexScripts(sup: string, sub: string, content: string): string;
|
|
116
|
+
}
|
|
117
|
+
declare class ChainNode {
|
|
118
|
+
chain: BaseAstNode[];
|
|
119
|
+
constructor(chain?: BaseAstNode[]);
|
|
120
|
+
latex(): string;
|
|
121
|
+
toEnglishLatex(): string;
|
|
122
|
+
/** RTL: reverse order relative to Latin chain (see test/ref_tests.txt). */
|
|
123
|
+
arabicLatex(): string;
|
|
124
|
+
toArabicLatex(): string;
|
|
125
|
+
}
|
|
126
|
+
|
|
125
127
|
type MathNode = {
|
|
126
128
|
nodeType: 'MathObject';
|
|
127
129
|
mathMode: string;
|
|
@@ -138,6 +140,7 @@ type MathObject2Json = {
|
|
|
138
140
|
lines: ChainJson[];
|
|
139
141
|
closing: string;
|
|
140
142
|
};
|
|
143
|
+
type ReferenceFieldSeparator = ',' | '،';
|
|
141
144
|
type Reference2Json = {
|
|
142
145
|
key: string;
|
|
143
146
|
authors?: string;
|
|
@@ -145,6 +148,8 @@ type Reference2Json = {
|
|
|
145
148
|
year?: string;
|
|
146
149
|
url?: string;
|
|
147
150
|
venue?: string;
|
|
151
|
+
/** Bibliography field join: LTR `,` or Arabic `،`. Defaults to `،` when omitted. */
|
|
152
|
+
field_separator?: ReferenceFieldSeparator;
|
|
148
153
|
};
|
|
149
154
|
type HijriMonthId = 'محرم' | 'صفر' | 'ربيع الأول' | 'ربيع الآخر' | 'جمادى الأولى' | 'جمادى الآخرة' | 'رجب' | 'شعبان' | 'رمضان' | 'شوال' | 'ذو القعدة' | 'ذو الحجة';
|
|
150
155
|
type Document2HijriDate = {
|
|
@@ -199,6 +204,8 @@ type Reference2 = {
|
|
|
199
204
|
year: string;
|
|
200
205
|
url: string;
|
|
201
206
|
venue: string;
|
|
207
|
+
/** Joins authors/title/venue/year in bibliography display and export. */
|
|
208
|
+
fieldSeparator: ReferenceFieldSeparator;
|
|
202
209
|
};
|
|
203
210
|
type TextToken2 = {
|
|
204
211
|
id: string;
|
|
@@ -420,6 +427,7 @@ type PreviewBlock2 = {
|
|
|
420
427
|
year: string;
|
|
421
428
|
url: string;
|
|
422
429
|
venue: string;
|
|
430
|
+
fieldSeparator: ReferenceFieldSeparator;
|
|
423
431
|
}>;
|
|
424
432
|
}
|
|
425
433
|
/** Preview-only: raw / unknown blocks are omitted from preview until we add proper rendering. */
|
|
@@ -490,12 +498,19 @@ declare function labelNumberMap(document: Document2Node): Map<string, {
|
|
|
490
498
|
kind: Document2LabelKind;
|
|
491
499
|
number: number;
|
|
492
500
|
}>;
|
|
501
|
+
type FormatFloatCaptionTitleOptions = {
|
|
502
|
+
uiLocale?: ButexUiLocale;
|
|
503
|
+
documentDirection?: Document2Direction;
|
|
504
|
+
digitForm?: DigitFormId;
|
|
505
|
+
};
|
|
506
|
+
/** Localized numbered float/equation title: الشكل ١ / Figure 1 / المعادلة ١. */
|
|
507
|
+
declare function formatFloatCaptionTitle(kind: Document2LabelKind, number: number, options?: FormatFloatCaptionTitleOptions): string;
|
|
508
|
+
/** Caption line as shown in document preview: الشكل ١: نص / Figure 1. text. */
|
|
509
|
+
declare function formatFloatCaptionPreview(title: string, caption: string | undefined, uiLocale?: ButexUiLocale): string;
|
|
493
510
|
declare function formatRefLabel(keys: string[], document: Document2Node, refCommand: 'ref' | 'eqref', options?: FormatCiteLabelOptions): string;
|
|
494
511
|
declare function stripDisplayMathDelimiters(source: string): string;
|
|
495
512
|
declare function applyFloatMetaPatch<T extends ImageBlock2 | TableBlock2>(block: T, patch: FloatMetaPatch): void;
|
|
496
513
|
|
|
497
|
-
type ButexUiLocale = 'ar' | 'en';
|
|
498
|
-
|
|
499
514
|
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";
|
|
500
515
|
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";
|
|
501
516
|
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";
|
|
@@ -585,6 +600,26 @@ declare function moveDocument2Reference(document: Document2Node, referenceId: st
|
|
|
585
600
|
declare function setDocument2References(document: Document2Node, references: Reference2[]): Document2Node;
|
|
586
601
|
declare function updateDocument2Meta(document: Document2Node, patch: Document2MetaProp): Document2Node;
|
|
587
602
|
|
|
603
|
+
type Document2KeyError = 'empty' | 'invalid' | 'duplicate';
|
|
604
|
+
/** NFC-normalize and trim a document key (label or bibliography). */
|
|
605
|
+
declare function normalizeDocument2Key(key: string): string;
|
|
606
|
+
/** True when key matches Unicode letters/marks, ASCII digits, and :._- with no spaces. */
|
|
607
|
+
declare function isValidDocument2Key(key: string): boolean;
|
|
608
|
+
type Document2KeyNamespace = {
|
|
609
|
+
references?: Array<Pick<Reference2, 'id' | 'key'>>;
|
|
610
|
+
labels?: Array<Pick<Document2LabelEntry, 'ownerId' | 'key'>>;
|
|
611
|
+
/** Skip this reference id when checking (editing that entry). */
|
|
612
|
+
excludeReferenceId?: string;
|
|
613
|
+
/** Skip this label owner id when checking (editing that float/eq). */
|
|
614
|
+
excludeOwnerId?: string;
|
|
615
|
+
};
|
|
616
|
+
/** Returns true if another reference or label already uses this key (NFC match). */
|
|
617
|
+
declare function isDuplicateDocument2Key(key: string, namespace: Document2KeyNamespace): boolean;
|
|
618
|
+
/** Classify a key for UI messaging: empty, invalid charset, or duplicate. */
|
|
619
|
+
declare function document2KeyError(key: string, namespace?: Document2KeyNamespace): Document2KeyError | null;
|
|
620
|
+
|
|
621
|
+
declare const DEFAULT_REFERENCE_FIELD_SEPARATOR: ReferenceFieldSeparator;
|
|
622
|
+
declare function normalizeReferenceFieldSeparator(value: unknown): ReferenceFieldSeparator;
|
|
588
623
|
declare function referenceNumberMap(references: Array<Pick<Reference2, 'key'>>): Map<string, number>;
|
|
589
624
|
declare function resolveCiteNumbers(keys: string[], references: Array<Pick<Reference2, 'key'>>): Array<number | null>;
|
|
590
625
|
declare function formatCiteLabel(keys: string[], references: Array<Pick<Reference2, 'key'>>, options?: FormatCiteLabelOptions): string;
|
|
@@ -593,7 +628,17 @@ declare function parseCiteKeys(source: string): string[];
|
|
|
593
628
|
declare function citeTokenLatex(keys: string[]): string;
|
|
594
629
|
declare function referenceFromJson(json: Reference2Json): Reference2;
|
|
595
630
|
declare function createEmptyReference2(partial?: Partial<Reference2Json>): Reference2;
|
|
631
|
+
/** Joined authors/title/venue/year for preview and export (no \\bibitem wrapper). */
|
|
632
|
+
declare function bibliographyEntryBody(reference: Pick<Reference2, 'authors' | 'title' | 'venue' | 'year' | 'fieldSeparator'>, separator?: ReferenceFieldSeparator, options?: {
|
|
633
|
+
digitForm?: DigitFormId;
|
|
634
|
+
}): string;
|
|
596
635
|
declare function bibliographyEntryLatex(reference: Reference2): string;
|
|
636
|
+
/**
|
|
637
|
+
* Build an href for a bibliography URL. Values without a scheme become https://…
|
|
638
|
+
* so the browser does not resolve them against the editor origin (e.g. localhost).
|
|
639
|
+
* Leaves http(s)/mailto/ftp and other schemed URLs unchanged. Empty → ''.
|
|
640
|
+
*/
|
|
641
|
+
declare function absoluteHttpHref(url: string): string;
|
|
597
642
|
|
|
598
643
|
/** Arabic XeLaTeX preamble fragments for full-document export. */
|
|
599
644
|
type ArabicDigitsMapping = 'arabicdigits' | 'digits';
|
|
@@ -684,4 +729,4 @@ type Document2PreviewOptions = {
|
|
|
684
729
|
};
|
|
685
730
|
declare function document2Preview(document: Document2Node, output?: Document2MathOutput, equationSide?: EditorSide, previewOptions?: Document2PreviewOptions): Document2Preview;
|
|
686
731
|
|
|
687
|
-
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_DOCUMENT2_HISTORY_MAX_DEPTH, DEFAULT_HIJRI_DATE, type Document2Block, type Document2BlockJson, type Document2Diagnostic, type Document2Direction, type Document2HijriDate, type Document2HistoryStacks, type Document2Json, type Document2LabelEntry, type Document2LabelKind, type Document2LatexOptions, type Document2MathOutput, type Document2Meta, type Document2MetaProp, type Document2Node, type Document2Preview, type Document2PreviewOptions, type FloatMeta2, type FloatMetaPatch, type FormatCiteLabelOptions, HIJRI_MONTH_IDS, HIJRI_YEAR_MAX, HIJRI_YEAR_MIN, type HijriMonthId, type ImageBlock2, type ImportDocument2Options, type InlineField2, type InlineToken2, type ListBlock2, type MathIsland2, type MathObject2Json, type MathToken2, type PreviewBlock2, type PreviewInline2, type RawBlock2, type RefToken2, type Reference2, type Reference2Json, type TableBlock2, type TextBlock2, type TextToken2, addDocument2ImageBlock, addDocument2ListBlock, addDocument2ListItem, addDocument2Reference, addDocument2TableBlock, addDocument2TextBlock, applyFloatMetaPatch, arabicXeLatexPreambleCmd, arabicXeLatexPreambleFont, arabicXeLatexPreamblePkg, bibliographyEntryLatex, butexBasmalaDisplayLatex, butexBasmalaDisplayTex, butexBasmalaTitlingPreamble, butexDiwaniDisplayLatex, butexDiwaniDisplayTex, butexInColumnMaketitleHook, citeTokenLatex, cloneDocument2Meta, cloneDocument2Node, collectDocument2Labels, createDocument2History, createEmptyArabicEquationSession, createEmptyDocument2, createEmptyEquationSession, createEmptyReference2, createInlineField2, defaultFloatMeta, detectInlineSpans2, detectMathSpans2, document2HasAbstract, document2HasMaketitle, document2HasTitleStack, document2HistoryCanRedo, document2HistoryCanUndo, document2Latex, document2Preview, emptyBlockSelection, emptyDocument2Meta, ensureDocument2BibliographyBlock, extendBlockSelectionFromAnchor, fillDocument2MetaGaps, findFirstInlineField, formatBibliographyNumber, formatCiteLabel, formatHijriDate, formatRefLabel, fromDocumentJson2, getArabicXeLatexPreamble, hijriMonthLabel, inlineFieldLatex, insertCiteTokenAtCaret, insertDocument2BlockAfter, insertMathToken, insertMathTokenAtCaret, insertRefTokenAtCaret, labelNumberMap, mathNodeFromArabicSession, mathNodeFromSession, mathSourceFromArabicSession, mathSourceFromSession, mathTokenSourceForSide, mathTokenToArabicEditorSession, mathTokenToEditorSession, mergeDocument2Meta, moveDocument2BlockById, moveDocument2BlockRange, moveDocument2Reference, normalizeBlockSelection, normalizeDocument2HijriDate, normalizeDocument2Meta, parseCiteKeys, parseFloatMetaFromJson, parseRefKeys, pushDocument2Snapshot, refTokenLatex, referenceFromJson, referenceNumberMap, remapSelectionAfterRangeMove, removeCiteTokenById, removeDocument2BlockById, removeDocument2BlockRange, removeDocument2ListItem, removeDocument2Reference, removeMathTokenById, removeRefTokenById, replaceMathTokenFromSession, resolveCiteNumbers, restoreDocument2Redo, restoreDocument2Undo, setDocument2References, stripDisplayMathDelimiters, toggleBlockInSelection, updateCiteTokenKeys, updateDocument2ImageMeta, updateDocument2ImageValue, updateDocument2Meta, updateDocument2Reference, updateDocument2TableMeta, updateDocument2TextBlockCentered, updateMathTokenLabel, updateRefTokenKeys, updateTextToken };
|
|
732
|
+
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_DOCUMENT2_HISTORY_MAX_DEPTH, DEFAULT_HIJRI_DATE, DEFAULT_REFERENCE_FIELD_SEPARATOR, type Document2Block, type Document2BlockJson, type Document2Diagnostic, type Document2Direction, type Document2HijriDate, type Document2HistoryStacks, type Document2Json, type Document2KeyError, type Document2KeyNamespace, type Document2LabelEntry, type Document2LabelKind, type Document2LatexOptions, type Document2MathOutput, type Document2Meta, type Document2MetaProp, type Document2Node, type Document2Preview, type Document2PreviewOptions, type FloatMeta2, type FloatMetaPatch, type FormatCiteLabelOptions, type FormatFloatCaptionTitleOptions, HIJRI_MONTH_IDS, HIJRI_YEAR_MAX, HIJRI_YEAR_MIN, type HijriMonthId, type ImageBlock2, type ImportDocument2Options, type InlineField2, type InlineToken2, type ListBlock2, type MathIsland2, type MathObject2Json, type MathToken2, type PreviewBlock2, type PreviewInline2, type RawBlock2, type RefToken2, type Reference2, type Reference2Json, type ReferenceFieldSeparator, type TableBlock2, type TextBlock2, type TextToken2, absoluteHttpHref, addDocument2ImageBlock, addDocument2ListBlock, addDocument2ListItem, addDocument2Reference, addDocument2TableBlock, addDocument2TextBlock, applyFloatMetaPatch, arabicXeLatexPreambleCmd, arabicXeLatexPreambleFont, arabicXeLatexPreamblePkg, bibliographyEntryBody, bibliographyEntryLatex, butexBasmalaDisplayLatex, butexBasmalaDisplayTex, butexBasmalaTitlingPreamble, butexDiwaniDisplayLatex, butexDiwaniDisplayTex, butexInColumnMaketitleHook, citeTokenLatex, cloneDocument2Meta, cloneDocument2Node, collectDocument2Labels, createDocument2History, createEmptyArabicEquationSession, createEmptyDocument2, createEmptyEquationSession, createEmptyReference2, createInlineField2, defaultFloatMeta, detectInlineSpans2, detectMathSpans2, document2HasAbstract, document2HasMaketitle, document2HasTitleStack, document2HistoryCanRedo, document2HistoryCanUndo, document2KeyError, document2Latex, document2Preview, emptyBlockSelection, emptyDocument2Meta, ensureDocument2BibliographyBlock, extendBlockSelectionFromAnchor, fillDocument2MetaGaps, findFirstInlineField, formatBibliographyNumber, formatCiteLabel, formatFloatCaptionPreview, formatFloatCaptionTitle, formatHijriDate, formatRefLabel, fromDocumentJson2, getArabicXeLatexPreamble, hijriMonthLabel, inlineFieldLatex, insertCiteTokenAtCaret, insertDocument2BlockAfter, insertMathToken, insertMathTokenAtCaret, insertRefTokenAtCaret, isDuplicateDocument2Key, isValidDocument2Key, labelNumberMap, mathNodeFromArabicSession, mathNodeFromSession, mathSourceFromArabicSession, mathSourceFromSession, mathTokenSourceForSide, mathTokenToArabicEditorSession, mathTokenToEditorSession, mergeDocument2Meta, moveDocument2BlockById, moveDocument2BlockRange, moveDocument2Reference, normalizeBlockSelection, normalizeDocument2HijriDate, normalizeDocument2Key, normalizeDocument2Meta, normalizeReferenceFieldSeparator, parseCiteKeys, parseFloatMetaFromJson, parseRefKeys, pushDocument2Snapshot, refTokenLatex, referenceFromJson, referenceNumberMap, remapSelectionAfterRangeMove, removeCiteTokenById, removeDocument2BlockById, removeDocument2BlockRange, removeDocument2ListItem, removeDocument2Reference, removeMathTokenById, removeRefTokenById, replaceMathTokenFromSession, resolveCiteNumbers, restoreDocument2Redo, restoreDocument2Undo, setDocument2References, stripDisplayMathDelimiters, toggleBlockInSelection, updateCiteTokenKeys, updateDocument2ImageMeta, updateDocument2ImageValue, updateDocument2Meta, updateDocument2Reference, updateDocument2TableMeta, updateDocument2TextBlockCentered, updateMathTokenLabel, updateRefTokenKeys, updateTextToken };
|
package/dist/document2.d.ts
CHANGED
|
@@ -1,51 +1,3 @@
|
|
|
1
|
-
type ArabicNodeJson = {
|
|
2
|
-
node_type: string;
|
|
3
|
-
expr?: string;
|
|
4
|
-
name?: string;
|
|
5
|
-
superscript?: ChainJson | null;
|
|
6
|
-
subscript?: ChainJson | null;
|
|
7
|
-
left_delim_expr?: string;
|
|
8
|
-
right_delim_expr?: string;
|
|
9
|
-
inner_expr?: ChainJson;
|
|
10
|
-
optional_args?: ChainJson[];
|
|
11
|
-
mandatory_args?: ChainJson[];
|
|
12
|
-
opening?: string;
|
|
13
|
-
closing?: string;
|
|
14
|
-
lines?: ChainJson[];
|
|
15
|
-
};
|
|
16
|
-
type ChainJson = {
|
|
17
|
-
node_type: 'ChainClass';
|
|
18
|
-
chain: ArabicNodeJson[];
|
|
19
|
-
};
|
|
20
|
-
declare class State {
|
|
21
|
-
}
|
|
22
|
-
declare class BaseAstNode {
|
|
23
|
-
state: State;
|
|
24
|
-
superscript: ChainNode | null;
|
|
25
|
-
subscript: ChainNode | null;
|
|
26
|
-
nodeType: string;
|
|
27
|
-
constructor(state?: State | null);
|
|
28
|
-
latex(): string;
|
|
29
|
-
arabicLatex(): string;
|
|
30
|
-
toArabicLatex(): string;
|
|
31
|
-
/** Latin-style scripts: `^{...}` and `_{...}` for english_json rendering. */
|
|
32
|
-
latexScripts(): string;
|
|
33
|
-
/**
|
|
34
|
-
* Arabic scripts use \\prescript{sup}{sub}{content} (matches reference Python output).
|
|
35
|
-
* Call with rendered strings for sup/sub chains (may be empty strings).
|
|
36
|
-
*/
|
|
37
|
-
arabicLatexScripts(sup: string, sub: string, content: string): string;
|
|
38
|
-
}
|
|
39
|
-
declare class ChainNode {
|
|
40
|
-
chain: BaseAstNode[];
|
|
41
|
-
constructor(chain?: BaseAstNode[]);
|
|
42
|
-
latex(): string;
|
|
43
|
-
toEnglishLatex(): string;
|
|
44
|
-
/** RTL: reverse order relative to Latin chain (see test/ref_tests.txt). */
|
|
45
|
-
arabicLatex(): string;
|
|
46
|
-
toArabicLatex(): string;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
1
|
type EditorSide = 'english' | 'arabic';
|
|
50
2
|
type EditorNodeKind = 'char' | 'number' | 'operator' | 'delimiter' | 'frac' | 'sqrt' | 'env' | 'atomicCommand' | 'atomicOperatorCommand';
|
|
51
3
|
type MatrixEnvStyle = 'matrix' | 'pmatrix' | 'bmatrix' | 'Bmatrix' | 'vmatrix' | 'Vmatrix';
|
|
@@ -122,6 +74,56 @@ type EditorSession = {
|
|
|
122
74
|
debugLog: EditorDebugEntry[];
|
|
123
75
|
};
|
|
124
76
|
|
|
77
|
+
type ButexUiLocale = 'ar' | 'en';
|
|
78
|
+
|
|
79
|
+
type ArabicNodeJson = {
|
|
80
|
+
node_type: string;
|
|
81
|
+
expr?: string;
|
|
82
|
+
name?: string;
|
|
83
|
+
superscript?: ChainJson | null;
|
|
84
|
+
subscript?: ChainJson | null;
|
|
85
|
+
left_delim_expr?: string;
|
|
86
|
+
right_delim_expr?: string;
|
|
87
|
+
inner_expr?: ChainJson;
|
|
88
|
+
optional_args?: ChainJson[];
|
|
89
|
+
mandatory_args?: ChainJson[];
|
|
90
|
+
opening?: string;
|
|
91
|
+
closing?: string;
|
|
92
|
+
lines?: ChainJson[];
|
|
93
|
+
};
|
|
94
|
+
type ChainJson = {
|
|
95
|
+
node_type: 'ChainClass';
|
|
96
|
+
chain: ArabicNodeJson[];
|
|
97
|
+
};
|
|
98
|
+
declare class State {
|
|
99
|
+
}
|
|
100
|
+
declare class BaseAstNode {
|
|
101
|
+
state: State;
|
|
102
|
+
superscript: ChainNode | null;
|
|
103
|
+
subscript: ChainNode | null;
|
|
104
|
+
nodeType: string;
|
|
105
|
+
constructor(state?: State | null);
|
|
106
|
+
latex(): string;
|
|
107
|
+
arabicLatex(): string;
|
|
108
|
+
toArabicLatex(): string;
|
|
109
|
+
/** Latin-style scripts: `^{...}` and `_{...}` for english_json rendering. */
|
|
110
|
+
latexScripts(): string;
|
|
111
|
+
/**
|
|
112
|
+
* Arabic scripts use \\prescript{sup}{sub}{content} (matches reference Python output).
|
|
113
|
+
* Call with rendered strings for sup/sub chains (may be empty strings).
|
|
114
|
+
*/
|
|
115
|
+
arabicLatexScripts(sup: string, sub: string, content: string): string;
|
|
116
|
+
}
|
|
117
|
+
declare class ChainNode {
|
|
118
|
+
chain: BaseAstNode[];
|
|
119
|
+
constructor(chain?: BaseAstNode[]);
|
|
120
|
+
latex(): string;
|
|
121
|
+
toEnglishLatex(): string;
|
|
122
|
+
/** RTL: reverse order relative to Latin chain (see test/ref_tests.txt). */
|
|
123
|
+
arabicLatex(): string;
|
|
124
|
+
toArabicLatex(): string;
|
|
125
|
+
}
|
|
126
|
+
|
|
125
127
|
type MathNode = {
|
|
126
128
|
nodeType: 'MathObject';
|
|
127
129
|
mathMode: string;
|
|
@@ -138,6 +140,7 @@ type MathObject2Json = {
|
|
|
138
140
|
lines: ChainJson[];
|
|
139
141
|
closing: string;
|
|
140
142
|
};
|
|
143
|
+
type ReferenceFieldSeparator = ',' | '،';
|
|
141
144
|
type Reference2Json = {
|
|
142
145
|
key: string;
|
|
143
146
|
authors?: string;
|
|
@@ -145,6 +148,8 @@ type Reference2Json = {
|
|
|
145
148
|
year?: string;
|
|
146
149
|
url?: string;
|
|
147
150
|
venue?: string;
|
|
151
|
+
/** Bibliography field join: LTR `,` or Arabic `،`. Defaults to `،` when omitted. */
|
|
152
|
+
field_separator?: ReferenceFieldSeparator;
|
|
148
153
|
};
|
|
149
154
|
type HijriMonthId = 'محرم' | 'صفر' | 'ربيع الأول' | 'ربيع الآخر' | 'جمادى الأولى' | 'جمادى الآخرة' | 'رجب' | 'شعبان' | 'رمضان' | 'شوال' | 'ذو القعدة' | 'ذو الحجة';
|
|
150
155
|
type Document2HijriDate = {
|
|
@@ -199,6 +204,8 @@ type Reference2 = {
|
|
|
199
204
|
year: string;
|
|
200
205
|
url: string;
|
|
201
206
|
venue: string;
|
|
207
|
+
/** Joins authors/title/venue/year in bibliography display and export. */
|
|
208
|
+
fieldSeparator: ReferenceFieldSeparator;
|
|
202
209
|
};
|
|
203
210
|
type TextToken2 = {
|
|
204
211
|
id: string;
|
|
@@ -420,6 +427,7 @@ type PreviewBlock2 = {
|
|
|
420
427
|
year: string;
|
|
421
428
|
url: string;
|
|
422
429
|
venue: string;
|
|
430
|
+
fieldSeparator: ReferenceFieldSeparator;
|
|
423
431
|
}>;
|
|
424
432
|
}
|
|
425
433
|
/** Preview-only: raw / unknown blocks are omitted from preview until we add proper rendering. */
|
|
@@ -490,12 +498,19 @@ declare function labelNumberMap(document: Document2Node): Map<string, {
|
|
|
490
498
|
kind: Document2LabelKind;
|
|
491
499
|
number: number;
|
|
492
500
|
}>;
|
|
501
|
+
type FormatFloatCaptionTitleOptions = {
|
|
502
|
+
uiLocale?: ButexUiLocale;
|
|
503
|
+
documentDirection?: Document2Direction;
|
|
504
|
+
digitForm?: DigitFormId;
|
|
505
|
+
};
|
|
506
|
+
/** Localized numbered float/equation title: الشكل ١ / Figure 1 / المعادلة ١. */
|
|
507
|
+
declare function formatFloatCaptionTitle(kind: Document2LabelKind, number: number, options?: FormatFloatCaptionTitleOptions): string;
|
|
508
|
+
/** Caption line as shown in document preview: الشكل ١: نص / Figure 1. text. */
|
|
509
|
+
declare function formatFloatCaptionPreview(title: string, caption: string | undefined, uiLocale?: ButexUiLocale): string;
|
|
493
510
|
declare function formatRefLabel(keys: string[], document: Document2Node, refCommand: 'ref' | 'eqref', options?: FormatCiteLabelOptions): string;
|
|
494
511
|
declare function stripDisplayMathDelimiters(source: string): string;
|
|
495
512
|
declare function applyFloatMetaPatch<T extends ImageBlock2 | TableBlock2>(block: T, patch: FloatMetaPatch): void;
|
|
496
513
|
|
|
497
|
-
type ButexUiLocale = 'ar' | 'en';
|
|
498
|
-
|
|
499
514
|
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";
|
|
500
515
|
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";
|
|
501
516
|
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";
|
|
@@ -585,6 +600,26 @@ declare function moveDocument2Reference(document: Document2Node, referenceId: st
|
|
|
585
600
|
declare function setDocument2References(document: Document2Node, references: Reference2[]): Document2Node;
|
|
586
601
|
declare function updateDocument2Meta(document: Document2Node, patch: Document2MetaProp): Document2Node;
|
|
587
602
|
|
|
603
|
+
type Document2KeyError = 'empty' | 'invalid' | 'duplicate';
|
|
604
|
+
/** NFC-normalize and trim a document key (label or bibliography). */
|
|
605
|
+
declare function normalizeDocument2Key(key: string): string;
|
|
606
|
+
/** True when key matches Unicode letters/marks, ASCII digits, and :._- with no spaces. */
|
|
607
|
+
declare function isValidDocument2Key(key: string): boolean;
|
|
608
|
+
type Document2KeyNamespace = {
|
|
609
|
+
references?: Array<Pick<Reference2, 'id' | 'key'>>;
|
|
610
|
+
labels?: Array<Pick<Document2LabelEntry, 'ownerId' | 'key'>>;
|
|
611
|
+
/** Skip this reference id when checking (editing that entry). */
|
|
612
|
+
excludeReferenceId?: string;
|
|
613
|
+
/** Skip this label owner id when checking (editing that float/eq). */
|
|
614
|
+
excludeOwnerId?: string;
|
|
615
|
+
};
|
|
616
|
+
/** Returns true if another reference or label already uses this key (NFC match). */
|
|
617
|
+
declare function isDuplicateDocument2Key(key: string, namespace: Document2KeyNamespace): boolean;
|
|
618
|
+
/** Classify a key for UI messaging: empty, invalid charset, or duplicate. */
|
|
619
|
+
declare function document2KeyError(key: string, namespace?: Document2KeyNamespace): Document2KeyError | null;
|
|
620
|
+
|
|
621
|
+
declare const DEFAULT_REFERENCE_FIELD_SEPARATOR: ReferenceFieldSeparator;
|
|
622
|
+
declare function normalizeReferenceFieldSeparator(value: unknown): ReferenceFieldSeparator;
|
|
588
623
|
declare function referenceNumberMap(references: Array<Pick<Reference2, 'key'>>): Map<string, number>;
|
|
589
624
|
declare function resolveCiteNumbers(keys: string[], references: Array<Pick<Reference2, 'key'>>): Array<number | null>;
|
|
590
625
|
declare function formatCiteLabel(keys: string[], references: Array<Pick<Reference2, 'key'>>, options?: FormatCiteLabelOptions): string;
|
|
@@ -593,7 +628,17 @@ declare function parseCiteKeys(source: string): string[];
|
|
|
593
628
|
declare function citeTokenLatex(keys: string[]): string;
|
|
594
629
|
declare function referenceFromJson(json: Reference2Json): Reference2;
|
|
595
630
|
declare function createEmptyReference2(partial?: Partial<Reference2Json>): Reference2;
|
|
631
|
+
/** Joined authors/title/venue/year for preview and export (no \\bibitem wrapper). */
|
|
632
|
+
declare function bibliographyEntryBody(reference: Pick<Reference2, 'authors' | 'title' | 'venue' | 'year' | 'fieldSeparator'>, separator?: ReferenceFieldSeparator, options?: {
|
|
633
|
+
digitForm?: DigitFormId;
|
|
634
|
+
}): string;
|
|
596
635
|
declare function bibliographyEntryLatex(reference: Reference2): string;
|
|
636
|
+
/**
|
|
637
|
+
* Build an href for a bibliography URL. Values without a scheme become https://…
|
|
638
|
+
* so the browser does not resolve them against the editor origin (e.g. localhost).
|
|
639
|
+
* Leaves http(s)/mailto/ftp and other schemed URLs unchanged. Empty → ''.
|
|
640
|
+
*/
|
|
641
|
+
declare function absoluteHttpHref(url: string): string;
|
|
597
642
|
|
|
598
643
|
/** Arabic XeLaTeX preamble fragments for full-document export. */
|
|
599
644
|
type ArabicDigitsMapping = 'arabicdigits' | 'digits';
|
|
@@ -684,4 +729,4 @@ type Document2PreviewOptions = {
|
|
|
684
729
|
};
|
|
685
730
|
declare function document2Preview(document: Document2Node, output?: Document2MathOutput, equationSide?: EditorSide, previewOptions?: Document2PreviewOptions): Document2Preview;
|
|
686
731
|
|
|
687
|
-
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_DOCUMENT2_HISTORY_MAX_DEPTH, DEFAULT_HIJRI_DATE, type Document2Block, type Document2BlockJson, type Document2Diagnostic, type Document2Direction, type Document2HijriDate, type Document2HistoryStacks, type Document2Json, type Document2LabelEntry, type Document2LabelKind, type Document2LatexOptions, type Document2MathOutput, type Document2Meta, type Document2MetaProp, type Document2Node, type Document2Preview, type Document2PreviewOptions, type FloatMeta2, type FloatMetaPatch, type FormatCiteLabelOptions, HIJRI_MONTH_IDS, HIJRI_YEAR_MAX, HIJRI_YEAR_MIN, type HijriMonthId, type ImageBlock2, type ImportDocument2Options, type InlineField2, type InlineToken2, type ListBlock2, type MathIsland2, type MathObject2Json, type MathToken2, type PreviewBlock2, type PreviewInline2, type RawBlock2, type RefToken2, type Reference2, type Reference2Json, type TableBlock2, type TextBlock2, type TextToken2, addDocument2ImageBlock, addDocument2ListBlock, addDocument2ListItem, addDocument2Reference, addDocument2TableBlock, addDocument2TextBlock, applyFloatMetaPatch, arabicXeLatexPreambleCmd, arabicXeLatexPreambleFont, arabicXeLatexPreamblePkg, bibliographyEntryLatex, butexBasmalaDisplayLatex, butexBasmalaDisplayTex, butexBasmalaTitlingPreamble, butexDiwaniDisplayLatex, butexDiwaniDisplayTex, butexInColumnMaketitleHook, citeTokenLatex, cloneDocument2Meta, cloneDocument2Node, collectDocument2Labels, createDocument2History, createEmptyArabicEquationSession, createEmptyDocument2, createEmptyEquationSession, createEmptyReference2, createInlineField2, defaultFloatMeta, detectInlineSpans2, detectMathSpans2, document2HasAbstract, document2HasMaketitle, document2HasTitleStack, document2HistoryCanRedo, document2HistoryCanUndo, document2Latex, document2Preview, emptyBlockSelection, emptyDocument2Meta, ensureDocument2BibliographyBlock, extendBlockSelectionFromAnchor, fillDocument2MetaGaps, findFirstInlineField, formatBibliographyNumber, formatCiteLabel, formatHijriDate, formatRefLabel, fromDocumentJson2, getArabicXeLatexPreamble, hijriMonthLabel, inlineFieldLatex, insertCiteTokenAtCaret, insertDocument2BlockAfter, insertMathToken, insertMathTokenAtCaret, insertRefTokenAtCaret, labelNumberMap, mathNodeFromArabicSession, mathNodeFromSession, mathSourceFromArabicSession, mathSourceFromSession, mathTokenSourceForSide, mathTokenToArabicEditorSession, mathTokenToEditorSession, mergeDocument2Meta, moveDocument2BlockById, moveDocument2BlockRange, moveDocument2Reference, normalizeBlockSelection, normalizeDocument2HijriDate, normalizeDocument2Meta, parseCiteKeys, parseFloatMetaFromJson, parseRefKeys, pushDocument2Snapshot, refTokenLatex, referenceFromJson, referenceNumberMap, remapSelectionAfterRangeMove, removeCiteTokenById, removeDocument2BlockById, removeDocument2BlockRange, removeDocument2ListItem, removeDocument2Reference, removeMathTokenById, removeRefTokenById, replaceMathTokenFromSession, resolveCiteNumbers, restoreDocument2Redo, restoreDocument2Undo, setDocument2References, stripDisplayMathDelimiters, toggleBlockInSelection, updateCiteTokenKeys, updateDocument2ImageMeta, updateDocument2ImageValue, updateDocument2Meta, updateDocument2Reference, updateDocument2TableMeta, updateDocument2TextBlockCentered, updateMathTokenLabel, updateRefTokenKeys, updateTextToken };
|
|
732
|
+
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_DOCUMENT2_HISTORY_MAX_DEPTH, DEFAULT_HIJRI_DATE, DEFAULT_REFERENCE_FIELD_SEPARATOR, type Document2Block, type Document2BlockJson, type Document2Diagnostic, type Document2Direction, type Document2HijriDate, type Document2HistoryStacks, type Document2Json, type Document2KeyError, type Document2KeyNamespace, type Document2LabelEntry, type Document2LabelKind, type Document2LatexOptions, type Document2MathOutput, type Document2Meta, type Document2MetaProp, type Document2Node, type Document2Preview, type Document2PreviewOptions, type FloatMeta2, type FloatMetaPatch, type FormatCiteLabelOptions, type FormatFloatCaptionTitleOptions, HIJRI_MONTH_IDS, HIJRI_YEAR_MAX, HIJRI_YEAR_MIN, type HijriMonthId, type ImageBlock2, type ImportDocument2Options, type InlineField2, type InlineToken2, type ListBlock2, type MathIsland2, type MathObject2Json, type MathToken2, type PreviewBlock2, type PreviewInline2, type RawBlock2, type RefToken2, type Reference2, type Reference2Json, type ReferenceFieldSeparator, type TableBlock2, type TextBlock2, type TextToken2, absoluteHttpHref, addDocument2ImageBlock, addDocument2ListBlock, addDocument2ListItem, addDocument2Reference, addDocument2TableBlock, addDocument2TextBlock, applyFloatMetaPatch, arabicXeLatexPreambleCmd, arabicXeLatexPreambleFont, arabicXeLatexPreamblePkg, bibliographyEntryBody, bibliographyEntryLatex, butexBasmalaDisplayLatex, butexBasmalaDisplayTex, butexBasmalaTitlingPreamble, butexDiwaniDisplayLatex, butexDiwaniDisplayTex, butexInColumnMaketitleHook, citeTokenLatex, cloneDocument2Meta, cloneDocument2Node, collectDocument2Labels, createDocument2History, createEmptyArabicEquationSession, createEmptyDocument2, createEmptyEquationSession, createEmptyReference2, createInlineField2, defaultFloatMeta, detectInlineSpans2, detectMathSpans2, document2HasAbstract, document2HasMaketitle, document2HasTitleStack, document2HistoryCanRedo, document2HistoryCanUndo, document2KeyError, document2Latex, document2Preview, emptyBlockSelection, emptyDocument2Meta, ensureDocument2BibliographyBlock, extendBlockSelectionFromAnchor, fillDocument2MetaGaps, findFirstInlineField, formatBibliographyNumber, formatCiteLabel, formatFloatCaptionPreview, formatFloatCaptionTitle, formatHijriDate, formatRefLabel, fromDocumentJson2, getArabicXeLatexPreamble, hijriMonthLabel, inlineFieldLatex, insertCiteTokenAtCaret, insertDocument2BlockAfter, insertMathToken, insertMathTokenAtCaret, insertRefTokenAtCaret, isDuplicateDocument2Key, isValidDocument2Key, labelNumberMap, mathNodeFromArabicSession, mathNodeFromSession, mathSourceFromArabicSession, mathSourceFromSession, mathTokenSourceForSide, mathTokenToArabicEditorSession, mathTokenToEditorSession, mergeDocument2Meta, moveDocument2BlockById, moveDocument2BlockRange, moveDocument2Reference, normalizeBlockSelection, normalizeDocument2HijriDate, normalizeDocument2Key, normalizeDocument2Meta, normalizeReferenceFieldSeparator, parseCiteKeys, parseFloatMetaFromJson, parseRefKeys, pushDocument2Snapshot, refTokenLatex, referenceFromJson, referenceNumberMap, remapSelectionAfterRangeMove, removeCiteTokenById, removeDocument2BlockById, removeDocument2BlockRange, removeDocument2ListItem, removeDocument2Reference, removeMathTokenById, removeRefTokenById, replaceMathTokenFromSession, resolveCiteNumbers, restoreDocument2Redo, restoreDocument2Undo, setDocument2References, stripDisplayMathDelimiters, toggleBlockInSelection, updateCiteTokenKeys, updateDocument2ImageMeta, updateDocument2ImageValue, updateDocument2Meta, updateDocument2Reference, updateDocument2TableMeta, updateDocument2TextBlockCentered, updateMathTokenLabel, updateRefTokenKeys, updateTextToken };
|