@drghaliasri/butex 8.1.0 → 8.1.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/book.d.mts +362 -0
- package/dist/book.d.ts +362 -0
- package/dist/book.js +3270 -0
- package/dist/book.js.map +1 -0
- package/dist/book.mjs +3235 -0
- package/dist/book.mjs.map +1 -0
- package/dist/document-cli.js +625 -38
- package/dist/document-cli.js.map +1 -1
- package/dist/document.d.mts +47 -4
- package/dist/document.d.ts +47 -4
- package/dist/document.js +204 -36
- package/dist/document.js.map +1 -1
- package/dist/document.mjs +198 -36
- package/dist/document.mjs.map +1 -1
- package/dist/react-book.d.mts +527 -0
- package/dist/react-book.d.ts +527 -0
- package/dist/react-book.js +23652 -0
- package/dist/react-book.js.map +1 -0
- package/dist/react-book.mjs +23633 -0
- package/dist/react-book.mjs.map +1 -0
- package/dist/react-document-preview.d.mts +28 -5
- package/dist/react-document-preview.d.ts +28 -5
- package/dist/react-document-preview.js +55 -10
- package/dist/react-document-preview.js.map +1 -1
- package/dist/react-document-preview.mjs +55 -10
- package/dist/react-document-preview.mjs.map +1 -1
- package/dist/react-document.d.mts +32 -3
- package/dist/react-document.d.ts +32 -3
- package/dist/react-document.js +282 -83
- package/dist/react-document.js.map +1 -1
- package/dist/react-document.mjs +282 -83
- package/dist/react-document.mjs.map +1 -1
- package/package.json +11 -1
package/dist/document.d.mts
CHANGED
|
@@ -321,6 +321,8 @@ type TextBlock2 = {
|
|
|
321
321
|
kind: 'textBlock';
|
|
322
322
|
command: '\\section' | '\\subsection' | '\\subsubsection' | '\\paragraph';
|
|
323
323
|
field: InlineField2;
|
|
324
|
+
/** Optional imported or authored label for a section heading. */
|
|
325
|
+
label?: string;
|
|
324
326
|
metadata?: DocumentBlockMetadata;
|
|
325
327
|
/** When true on \\paragraph, center in preview and LaTeX export. */
|
|
326
328
|
centered?: boolean;
|
|
@@ -590,8 +592,8 @@ declare function parseRefKeys(source: string): {
|
|
|
590
592
|
refCommand: 'ref' | 'eqref';
|
|
591
593
|
};
|
|
592
594
|
declare function refTokenLatex(keys: string[], refCommand: 'ref' | 'eqref'): string;
|
|
593
|
-
/** Deterministic, reversible, TeX-safe reference key from a persisted target ID. */
|
|
594
595
|
declare function implicitReferenceKey(kind: DocumentLabelKind, ownerId: string, unitId?: string): string;
|
|
596
|
+
declare function implicitHeadingReferenceKey(kind: 'section' | 'subsection' | 'subsubsection', ownerId: string, unitId: string): string;
|
|
595
597
|
/** Explicit numbering wins; legacy labeled/equation-environment math stays numbered. */
|
|
596
598
|
declare function isNumberedEquation(token: MathToken2): boolean;
|
|
597
599
|
declare function isNumberedFloat(block: ImageBlock2 | TableBlock2): boolean;
|
|
@@ -699,6 +701,8 @@ declare function insertMathToken(document: DocumentNode, fieldId: string, insert
|
|
|
699
701
|
declare function replaceMathTokenFromSession(document: DocumentNode, tokenId: string, session: EditorSession, opening?: string, closing?: string, side?: EditorSide): DocumentNode;
|
|
700
702
|
declare function addDocumentTextBlock(document: DocumentNode, command?: '\\section' | '\\subsection' | '\\subsubsection' | '\\paragraph', afterBlockId?: string | null): DocumentNode;
|
|
701
703
|
declare function updateDocumentTextBlockCentered(document: DocumentNode, blockId: string, centered: boolean): DocumentNode;
|
|
704
|
+
/** Edit optional heading labels without altering the heading's stable ID or text. */
|
|
705
|
+
declare function updateDocumentHeadingLabel(document: DocumentNode, blockId: string, label: string): DocumentNode;
|
|
702
706
|
declare function removeDocumentBlockById(document: DocumentNode, blockId: string): DocumentNode;
|
|
703
707
|
declare function addDocumentListBlock(document: DocumentNode, ordered: boolean, afterBlockId?: string | null): DocumentNode;
|
|
704
708
|
declare function addDocumentTableBlock(document: DocumentNode, columns?: string, rowCount?: number, colCount?: number, afterBlockId?: string | null): DocumentNode;
|
|
@@ -788,6 +792,10 @@ type DocumentCommand = ({
|
|
|
788
792
|
op: 'replace_text_block';
|
|
789
793
|
block_id: string;
|
|
790
794
|
text: string;
|
|
795
|
+
} | {
|
|
796
|
+
op: 'set_heading_label';
|
|
797
|
+
block_id: string;
|
|
798
|
+
label: string | null;
|
|
791
799
|
} | {
|
|
792
800
|
op: 'remove_block';
|
|
793
801
|
block_id: string;
|
|
@@ -1073,6 +1081,34 @@ declare function arabicXeLatexPreambleFont(digitsMapping?: ArabicDigitsMapping):
|
|
|
1073
1081
|
declare function arabicXeLatexPreambleCmd(): string;
|
|
1074
1082
|
declare function getArabicXeLatexPreamble(digitsMappingOrOptions?: ArabicDigitsMapping | ArabicXeLatexPreambleOptions): string;
|
|
1075
1083
|
|
|
1084
|
+
/** Read-only, host-supplied projection. Never copy these catalogs into a unit DocumentJson. */
|
|
1085
|
+
type DocumentBookTarget = {
|
|
1086
|
+
unitId: string;
|
|
1087
|
+
ownerId: string;
|
|
1088
|
+
key: string;
|
|
1089
|
+
kind: DocumentLabelKind | 'section' | 'subsection' | 'subsubsection' | 'chapter' | 'appendix';
|
|
1090
|
+
caption?: string;
|
|
1091
|
+
displayLabel?: string;
|
|
1092
|
+
manualKey?: string;
|
|
1093
|
+
};
|
|
1094
|
+
type DocumentBookContext = {
|
|
1095
|
+
unitId: string;
|
|
1096
|
+
references?: Reference2Json[];
|
|
1097
|
+
targets?: DocumentBookTarget[];
|
|
1098
|
+
};
|
|
1099
|
+
type DocumentEditorMode = 'article' | 'book-content';
|
|
1100
|
+
type DocumentPickerBookTarget = (DocumentReferenceTarget & {
|
|
1101
|
+
displayLabel?: string;
|
|
1102
|
+
}) | (DocumentBookTarget & {
|
|
1103
|
+
number: number | null;
|
|
1104
|
+
caption: string;
|
|
1105
|
+
});
|
|
1106
|
+
declare function bookContextReferences(context?: DocumentBookContext): Reference2[];
|
|
1107
|
+
/** A local target's book alias is scoped by the immutable unit ID, not its displayed ordinal. */
|
|
1108
|
+
declare function bookContentTargets(document: DocumentNode, context: DocumentBookContext): DocumentPickerBookTarget[];
|
|
1109
|
+
/** Supplied book display strings have priority; local article numbering is only a fallback. */
|
|
1110
|
+
declare function formatBookReferenceLabel(keys: string[], document: DocumentNode, command: 'ref' | 'eqref', context: DocumentBookContext, options?: FormatCiteLabelOptions): string;
|
|
1111
|
+
|
|
1076
1112
|
type DocumentLatexOptions = {
|
|
1077
1113
|
/**
|
|
1078
1114
|
* When true (default), emit a complete Arabic XeLaTeX file:
|
|
@@ -1092,7 +1128,7 @@ declare function inlineFieldLatex(field: InlineField2): string;
|
|
|
1092
1128
|
/** Convert the live editor AST to the canonical JSON wire format. */
|
|
1093
1129
|
declare function toDocumentJson(document: DocumentNode): DocumentJson;
|
|
1094
1130
|
|
|
1095
|
-
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';
|
|
1131
|
+
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' | 'book_local_bibliography' | 'book_context_required';
|
|
1096
1132
|
type DocumentValidationIssue = {
|
|
1097
1133
|
code: DocumentValidationIssueCode;
|
|
1098
1134
|
path: string;
|
|
@@ -1109,7 +1145,10 @@ declare function hasXeLatexUnsupportedEmoji(value: string): boolean;
|
|
|
1109
1145
|
* Validate a Document draft without mutating it. Detailed issues are kept in
|
|
1110
1146
|
* BuTeX so React can identify the field while hosts only need the boolean API.
|
|
1111
1147
|
*/
|
|
1112
|
-
declare function validateDocument(document: DocumentJson | DocumentNode
|
|
1148
|
+
declare function validateDocument(document: DocumentJson | DocumentNode, options?: {
|
|
1149
|
+
mode?: DocumentEditorMode;
|
|
1150
|
+
bookContext?: DocumentBookContext;
|
|
1151
|
+
}): DocumentValidationResult;
|
|
1113
1152
|
/** Public host contract: drafts may be saved, but only valid documents may compile. */
|
|
1114
1153
|
declare function isDocumentValid(document: DocumentJson | DocumentNode): boolean;
|
|
1115
1154
|
/** Error thrown when LaTeX export is attempted for an invalid Document draft. */
|
|
@@ -1174,6 +1213,8 @@ declare function mathNodeFromArabicSession(session: EditorSession, opening?: str
|
|
|
1174
1213
|
declare function mathTokenSourceForSide(token: MathToken2, side: EditorSide, digitForm?: DigitFormId, presentation?: boolean): string;
|
|
1175
1214
|
|
|
1176
1215
|
type DocumentPreviewOptions = {
|
|
1216
|
+
mode?: DocumentEditorMode;
|
|
1217
|
+
bookContext?: DocumentBookContext;
|
|
1177
1218
|
documentDirection?: DocumentDirection;
|
|
1178
1219
|
digitForm?: DigitFormId;
|
|
1179
1220
|
uiLocale?: ButexUiLocale;
|
|
@@ -1185,5 +1226,7 @@ declare function documentPreview(document: DocumentNode, output?: DocumentMathOu
|
|
|
1185
1226
|
* but compilation must not silently receive unsafe or unreliable LaTeX.
|
|
1186
1227
|
*/
|
|
1187
1228
|
declare function documentLatex(document: DocumentNode, options?: DocumentLatexOptions): string;
|
|
1229
|
+
/** Content-only unit export, with book-scoped reference validation. */
|
|
1230
|
+
declare function documentContentLatex(document: DocumentNode, context?: DocumentBookContext): string;
|
|
1188
1231
|
|
|
1189
|
-
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 DocumentReferenceTarget, 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, collectDocumentKeyLabels, collectDocumentLabels, collectDocumentReferenceTargets, 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, implicitReferenceKey, inlineFieldLatex, insertCiteTokenAtCaret, insertDocumentBlockAfter, insertMathToken, insertMathTokenAtCaret, insertRefTokenAtCaret, isDocumentValid, isDuplicateDocumentKey, isNumberedEquation, isNumberedFloat, 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 };
|
|
1232
|
+
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 DocumentBookContext, type DocumentBookTarget, type DocumentCitationIndexEntry, type DocumentCommand, DocumentCommandError, type DocumentCommandErrorCode, type DocumentCrossReferenceIndexEntry, type DocumentDiagnostic, type DocumentDiff, type DocumentDiffChunk, type DocumentDiffChunkKind, type DocumentDirection, type DocumentEditorMode, 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 DocumentPickerBookTarget, type DocumentPreview, type DocumentPreviewOptions, type DocumentReferenceAnchor, type DocumentReferenceIndex, type DocumentReferenceTarget, 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, bookContentTargets, bookContextReferences, butexBasmalaDisplayLatex, butexBasmalaDisplayTex, butexBasmalaTitlingPreamble, butexDiwaniDisplayLatex, butexDiwaniDisplayTex, butexInColumnMaketitleHook, butexMaghribiDisplayLatex, butexMaghribiDisplayTex, citeTokenLatex, clearDocumentImageAsset, cloneDocumentMeta, cloneDocumentNode, collectDocumentKeyLabels, collectDocumentLabels, collectDocumentReferenceTargets, createDocumentHistory, createEmptyArabicEquationSession, createEmptyDocument, createEmptyEquationSession, createEmptyReference, createInlineField, defaultFloatMeta, detectInlineSpans, detectMathSpans, diffDocument, documentContentLatex, documentHasAbstract, documentHasMaketitle, documentHasTitleStack, documentHistoryCanRedo, documentHistoryCanUndo, documentKeyError, documentLatex, documentOutline, documentPreview, emptyBlockSelection, emptyDocumentMeta, ensureDocumentBibliographyBlock, extendBlockSelectionFromAnchor, fillDocumentMetaGaps, findFirstInlineField, formatBibliographyNumber, formatBookReferenceLabel, formatCiteLabel, formatFloatCaptionPreview, formatFloatCaptionTitle, formatHijriDate, formatRefLabel, fromDocumentJson, getArabicXeLatexPreamble, getDocumentReferenceIndex, getDocumentReferences, hasXeLatexUnsupportedEmoji, hijriMonthLabel, implicitHeadingReferenceKey, implicitReferenceKey, inlineFieldLatex, insertCiteTokenAtCaret, insertDocumentBlockAfter, insertMathToken, insertMathTokenAtCaret, insertRefTokenAtCaret, isDocumentValid, isDuplicateDocumentKey, isNumberedEquation, isNumberedFloat, 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, updateDocumentHeadingLabel, updateDocumentImageAsset, updateDocumentImageMeta, updateDocumentImageValue, updateDocumentMeta, updateDocumentReference, updateDocumentTableMeta, updateDocumentTextBlockCentered, updateMathTokenLabel, updateRefTokenKeys, updateTextToken, validateDocument };
|
package/dist/document.d.ts
CHANGED
|
@@ -321,6 +321,8 @@ type TextBlock2 = {
|
|
|
321
321
|
kind: 'textBlock';
|
|
322
322
|
command: '\\section' | '\\subsection' | '\\subsubsection' | '\\paragraph';
|
|
323
323
|
field: InlineField2;
|
|
324
|
+
/** Optional imported or authored label for a section heading. */
|
|
325
|
+
label?: string;
|
|
324
326
|
metadata?: DocumentBlockMetadata;
|
|
325
327
|
/** When true on \\paragraph, center in preview and LaTeX export. */
|
|
326
328
|
centered?: boolean;
|
|
@@ -590,8 +592,8 @@ declare function parseRefKeys(source: string): {
|
|
|
590
592
|
refCommand: 'ref' | 'eqref';
|
|
591
593
|
};
|
|
592
594
|
declare function refTokenLatex(keys: string[], refCommand: 'ref' | 'eqref'): string;
|
|
593
|
-
/** Deterministic, reversible, TeX-safe reference key from a persisted target ID. */
|
|
594
595
|
declare function implicitReferenceKey(kind: DocumentLabelKind, ownerId: string, unitId?: string): string;
|
|
596
|
+
declare function implicitHeadingReferenceKey(kind: 'section' | 'subsection' | 'subsubsection', ownerId: string, unitId: string): string;
|
|
595
597
|
/** Explicit numbering wins; legacy labeled/equation-environment math stays numbered. */
|
|
596
598
|
declare function isNumberedEquation(token: MathToken2): boolean;
|
|
597
599
|
declare function isNumberedFloat(block: ImageBlock2 | TableBlock2): boolean;
|
|
@@ -699,6 +701,8 @@ declare function insertMathToken(document: DocumentNode, fieldId: string, insert
|
|
|
699
701
|
declare function replaceMathTokenFromSession(document: DocumentNode, tokenId: string, session: EditorSession, opening?: string, closing?: string, side?: EditorSide): DocumentNode;
|
|
700
702
|
declare function addDocumentTextBlock(document: DocumentNode, command?: '\\section' | '\\subsection' | '\\subsubsection' | '\\paragraph', afterBlockId?: string | null): DocumentNode;
|
|
701
703
|
declare function updateDocumentTextBlockCentered(document: DocumentNode, blockId: string, centered: boolean): DocumentNode;
|
|
704
|
+
/** Edit optional heading labels without altering the heading's stable ID or text. */
|
|
705
|
+
declare function updateDocumentHeadingLabel(document: DocumentNode, blockId: string, label: string): DocumentNode;
|
|
702
706
|
declare function removeDocumentBlockById(document: DocumentNode, blockId: string): DocumentNode;
|
|
703
707
|
declare function addDocumentListBlock(document: DocumentNode, ordered: boolean, afterBlockId?: string | null): DocumentNode;
|
|
704
708
|
declare function addDocumentTableBlock(document: DocumentNode, columns?: string, rowCount?: number, colCount?: number, afterBlockId?: string | null): DocumentNode;
|
|
@@ -788,6 +792,10 @@ type DocumentCommand = ({
|
|
|
788
792
|
op: 'replace_text_block';
|
|
789
793
|
block_id: string;
|
|
790
794
|
text: string;
|
|
795
|
+
} | {
|
|
796
|
+
op: 'set_heading_label';
|
|
797
|
+
block_id: string;
|
|
798
|
+
label: string | null;
|
|
791
799
|
} | {
|
|
792
800
|
op: 'remove_block';
|
|
793
801
|
block_id: string;
|
|
@@ -1073,6 +1081,34 @@ declare function arabicXeLatexPreambleFont(digitsMapping?: ArabicDigitsMapping):
|
|
|
1073
1081
|
declare function arabicXeLatexPreambleCmd(): string;
|
|
1074
1082
|
declare function getArabicXeLatexPreamble(digitsMappingOrOptions?: ArabicDigitsMapping | ArabicXeLatexPreambleOptions): string;
|
|
1075
1083
|
|
|
1084
|
+
/** Read-only, host-supplied projection. Never copy these catalogs into a unit DocumentJson. */
|
|
1085
|
+
type DocumentBookTarget = {
|
|
1086
|
+
unitId: string;
|
|
1087
|
+
ownerId: string;
|
|
1088
|
+
key: string;
|
|
1089
|
+
kind: DocumentLabelKind | 'section' | 'subsection' | 'subsubsection' | 'chapter' | 'appendix';
|
|
1090
|
+
caption?: string;
|
|
1091
|
+
displayLabel?: string;
|
|
1092
|
+
manualKey?: string;
|
|
1093
|
+
};
|
|
1094
|
+
type DocumentBookContext = {
|
|
1095
|
+
unitId: string;
|
|
1096
|
+
references?: Reference2Json[];
|
|
1097
|
+
targets?: DocumentBookTarget[];
|
|
1098
|
+
};
|
|
1099
|
+
type DocumentEditorMode = 'article' | 'book-content';
|
|
1100
|
+
type DocumentPickerBookTarget = (DocumentReferenceTarget & {
|
|
1101
|
+
displayLabel?: string;
|
|
1102
|
+
}) | (DocumentBookTarget & {
|
|
1103
|
+
number: number | null;
|
|
1104
|
+
caption: string;
|
|
1105
|
+
});
|
|
1106
|
+
declare function bookContextReferences(context?: DocumentBookContext): Reference2[];
|
|
1107
|
+
/** A local target's book alias is scoped by the immutable unit ID, not its displayed ordinal. */
|
|
1108
|
+
declare function bookContentTargets(document: DocumentNode, context: DocumentBookContext): DocumentPickerBookTarget[];
|
|
1109
|
+
/** Supplied book display strings have priority; local article numbering is only a fallback. */
|
|
1110
|
+
declare function formatBookReferenceLabel(keys: string[], document: DocumentNode, command: 'ref' | 'eqref', context: DocumentBookContext, options?: FormatCiteLabelOptions): string;
|
|
1111
|
+
|
|
1076
1112
|
type DocumentLatexOptions = {
|
|
1077
1113
|
/**
|
|
1078
1114
|
* When true (default), emit a complete Arabic XeLaTeX file:
|
|
@@ -1092,7 +1128,7 @@ declare function inlineFieldLatex(field: InlineField2): string;
|
|
|
1092
1128
|
/** Convert the live editor AST to the canonical JSON wire format. */
|
|
1093
1129
|
declare function toDocumentJson(document: DocumentNode): DocumentJson;
|
|
1094
1130
|
|
|
1095
|
-
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';
|
|
1131
|
+
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' | 'book_local_bibliography' | 'book_context_required';
|
|
1096
1132
|
type DocumentValidationIssue = {
|
|
1097
1133
|
code: DocumentValidationIssueCode;
|
|
1098
1134
|
path: string;
|
|
@@ -1109,7 +1145,10 @@ declare function hasXeLatexUnsupportedEmoji(value: string): boolean;
|
|
|
1109
1145
|
* Validate a Document draft without mutating it. Detailed issues are kept in
|
|
1110
1146
|
* BuTeX so React can identify the field while hosts only need the boolean API.
|
|
1111
1147
|
*/
|
|
1112
|
-
declare function validateDocument(document: DocumentJson | DocumentNode
|
|
1148
|
+
declare function validateDocument(document: DocumentJson | DocumentNode, options?: {
|
|
1149
|
+
mode?: DocumentEditorMode;
|
|
1150
|
+
bookContext?: DocumentBookContext;
|
|
1151
|
+
}): DocumentValidationResult;
|
|
1113
1152
|
/** Public host contract: drafts may be saved, but only valid documents may compile. */
|
|
1114
1153
|
declare function isDocumentValid(document: DocumentJson | DocumentNode): boolean;
|
|
1115
1154
|
/** Error thrown when LaTeX export is attempted for an invalid Document draft. */
|
|
@@ -1174,6 +1213,8 @@ declare function mathNodeFromArabicSession(session: EditorSession, opening?: str
|
|
|
1174
1213
|
declare function mathTokenSourceForSide(token: MathToken2, side: EditorSide, digitForm?: DigitFormId, presentation?: boolean): string;
|
|
1175
1214
|
|
|
1176
1215
|
type DocumentPreviewOptions = {
|
|
1216
|
+
mode?: DocumentEditorMode;
|
|
1217
|
+
bookContext?: DocumentBookContext;
|
|
1177
1218
|
documentDirection?: DocumentDirection;
|
|
1178
1219
|
digitForm?: DigitFormId;
|
|
1179
1220
|
uiLocale?: ButexUiLocale;
|
|
@@ -1185,5 +1226,7 @@ declare function documentPreview(document: DocumentNode, output?: DocumentMathOu
|
|
|
1185
1226
|
* but compilation must not silently receive unsafe or unreliable LaTeX.
|
|
1186
1227
|
*/
|
|
1187
1228
|
declare function documentLatex(document: DocumentNode, options?: DocumentLatexOptions): string;
|
|
1229
|
+
/** Content-only unit export, with book-scoped reference validation. */
|
|
1230
|
+
declare function documentContentLatex(document: DocumentNode, context?: DocumentBookContext): string;
|
|
1188
1231
|
|
|
1189
|
-
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 DocumentReferenceTarget, 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, collectDocumentKeyLabels, collectDocumentLabels, collectDocumentReferenceTargets, 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, implicitReferenceKey, inlineFieldLatex, insertCiteTokenAtCaret, insertDocumentBlockAfter, insertMathToken, insertMathTokenAtCaret, insertRefTokenAtCaret, isDocumentValid, isDuplicateDocumentKey, isNumberedEquation, isNumberedFloat, 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 };
|
|
1232
|
+
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 DocumentBookContext, type DocumentBookTarget, type DocumentCitationIndexEntry, type DocumentCommand, DocumentCommandError, type DocumentCommandErrorCode, type DocumentCrossReferenceIndexEntry, type DocumentDiagnostic, type DocumentDiff, type DocumentDiffChunk, type DocumentDiffChunkKind, type DocumentDirection, type DocumentEditorMode, 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 DocumentPickerBookTarget, type DocumentPreview, type DocumentPreviewOptions, type DocumentReferenceAnchor, type DocumentReferenceIndex, type DocumentReferenceTarget, 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, bookContentTargets, bookContextReferences, butexBasmalaDisplayLatex, butexBasmalaDisplayTex, butexBasmalaTitlingPreamble, butexDiwaniDisplayLatex, butexDiwaniDisplayTex, butexInColumnMaketitleHook, butexMaghribiDisplayLatex, butexMaghribiDisplayTex, citeTokenLatex, clearDocumentImageAsset, cloneDocumentMeta, cloneDocumentNode, collectDocumentKeyLabels, collectDocumentLabels, collectDocumentReferenceTargets, createDocumentHistory, createEmptyArabicEquationSession, createEmptyDocument, createEmptyEquationSession, createEmptyReference, createInlineField, defaultFloatMeta, detectInlineSpans, detectMathSpans, diffDocument, documentContentLatex, documentHasAbstract, documentHasMaketitle, documentHasTitleStack, documentHistoryCanRedo, documentHistoryCanUndo, documentKeyError, documentLatex, documentOutline, documentPreview, emptyBlockSelection, emptyDocumentMeta, ensureDocumentBibliographyBlock, extendBlockSelectionFromAnchor, fillDocumentMetaGaps, findFirstInlineField, formatBibliographyNumber, formatBookReferenceLabel, formatCiteLabel, formatFloatCaptionPreview, formatFloatCaptionTitle, formatHijriDate, formatRefLabel, fromDocumentJson, getArabicXeLatexPreamble, getDocumentReferenceIndex, getDocumentReferences, hasXeLatexUnsupportedEmoji, hijriMonthLabel, implicitHeadingReferenceKey, implicitReferenceKey, inlineFieldLatex, insertCiteTokenAtCaret, insertDocumentBlockAfter, insertMathToken, insertMathTokenAtCaret, insertRefTokenAtCaret, isDocumentValid, isDuplicateDocumentKey, isNumberedEquation, isNumberedFloat, 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, updateDocumentHeadingLabel, updateDocumentImageAsset, updateDocumentImageMeta, updateDocumentImageValue, updateDocumentMeta, updateDocumentReference, updateDocumentTableMeta, updateDocumentTextBlockCentered, updateMathTokenLabel, updateRefTokenKeys, updateTextToken, validateDocument };
|