@drghaliasri/butex 7.0.4 → 7.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/document2-cli.js +117 -0
- package/dist/document2-cli.js.map +1 -1
- package/dist/document2.d.mts +21 -1
- package/dist/document2.d.ts +21 -1
- package/dist/document2.js +100 -0
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs +99 -0
- package/dist/document2.mjs.map +1 -1
- package/dist/react-document2.js +3 -0
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +3 -0
- package/dist/react-document2.mjs.map +1 -1
- package/package.json +4 -2
package/dist/document2.d.mts
CHANGED
|
@@ -905,6 +905,26 @@ declare class Document2CommandError extends Error {
|
|
|
905
905
|
/** Apply one validated command to canonical JSON without mutating caller input. */
|
|
906
906
|
declare function applyDocument2Command(json: Document2Json, commandInput: Document2Command): Document2Json;
|
|
907
907
|
|
|
908
|
+
type Document2DiffChunkKind = 'added' | 'removed' | 'context';
|
|
909
|
+
type Document2DiffChunk = {
|
|
910
|
+
kind: Document2DiffChunkKind;
|
|
911
|
+
text: string;
|
|
912
|
+
};
|
|
913
|
+
type Document2Diff = {
|
|
914
|
+
version: 1;
|
|
915
|
+
changed: boolean;
|
|
916
|
+
truncated: boolean;
|
|
917
|
+
chunks: Document2DiffChunk[];
|
|
918
|
+
};
|
|
919
|
+
/**
|
|
920
|
+
* Compare two persisted Document2 documents using canonical Document2 import/export
|
|
921
|
+
* semantics and jsdiff's maintained JSON diff implementation.
|
|
922
|
+
*
|
|
923
|
+
* Generated editor identity sidecars are intentionally excluded so equivalent
|
|
924
|
+
* legacy documents do not differ merely because normalization assigned new IDs.
|
|
925
|
+
*/
|
|
926
|
+
declare function diffDocument2(before: Document2Json, after: Document2Json): Document2Diff;
|
|
927
|
+
|
|
908
928
|
type Document2OutlineKind = 'section' | 'subsection' | 'subsubsection' | 'paragraph' | 'list' | 'table' | 'figure' | 'bibliography' | 'raw';
|
|
909
929
|
type Document2OutlineEntry = {
|
|
910
930
|
id: string;
|
|
@@ -1123,4 +1143,4 @@ declare function document2Preview(document: Document2Node, output?: Document2Mat
|
|
|
1123
1143
|
*/
|
|
1124
1144
|
declare function document2Latex(document: Document2Node, options?: Document2LatexOptions): string;
|
|
1125
1145
|
|
|
1126
|
-
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 Document2Anchor, type Document2Block, type Document2BlockJson, type Document2BlockMetadata, type Document2CitationIndexEntry, type Document2Command, Document2CommandError, type Document2CommandErrorCode, type Document2CrossReferenceIndexEntry, type Document2Diagnostic, type Document2Direction, type Document2HijriDate, type Document2HistoryStacks, type Document2ImageAssetRef, type Document2IndexedLabel, type Document2InlineAnchor, type Document2InlineIdsJson, type Document2InlineTokenIdJson, type Document2InlineTokenInput, type Document2Json, type Document2KeyError, type Document2KeyNamespace, type Document2LabelEntry, type Document2LabelKind, type Document2LatexOptions, type Document2ListItemAnchor, type Document2MathObjectJson, type Document2MathOutput, type Document2Meta, type Document2MetaProp, type Document2Node, type Document2OutlineEntry, type Document2OutlineKind, type Document2Preview, type Document2PreviewOptions, type Document2ReferenceAnchor, type Document2ReferenceIndex, type Document2TextBlockKind, Document2ValidationError, type Document2ValidationIssue, type Document2ValidationIssueCode, type Document2ValidationResult, 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 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, addDocument2ImageBlock, addDocument2ListBlock, addDocument2ListItem, addDocument2Reference, addDocument2TableBlock, addDocument2TextBlock, applyDocument2Command, applyFloatMetaPatch, arabicXeLatexPreambleCmd, arabicXeLatexPreambleFont, arabicXeLatexPreamblePkg, bibliographyEntryBody, bibliographyEntryLatex, butexBasmalaDisplayLatex, butexBasmalaDisplayTex, butexBasmalaTitlingPreamble, butexDiwaniDisplayLatex, butexDiwaniDisplayTex, butexInColumnMaketitleHook, butexMaghribiDisplayLatex, butexMaghribiDisplayTex, citeTokenLatex, clearDocument2ImageAsset, cloneDocument2Meta, cloneDocument2Node, collectDocument2Labels, createDocument2History, createEmptyArabicEquationSession, createEmptyDocument2, createEmptyEquationSession, createEmptyReference2, createInlineField2, defaultFloatMeta, detectInlineSpans2, detectMathSpans2, document2HasAbstract, document2HasMaketitle, document2HasTitleStack, document2HistoryCanRedo, document2HistoryCanUndo, document2KeyError, document2Latex, document2Outline, document2Preview, emptyBlockSelection, emptyDocument2Meta, ensureDocument2BibliographyBlock, extendBlockSelectionFromAnchor, fillDocument2MetaGaps, findFirstInlineField, formatBibliographyNumber, formatCiteLabel, formatFloatCaptionPreview, formatFloatCaptionTitle, formatHijriDate, formatRefLabel, fromDocumentJson2, getArabicXeLatexPreamble, getDocument2ReferenceIndex, getDocument2References, hasXeLatexUnsupportedEmoji, hijriMonthLabel, inlineFieldLatex, insertCiteTokenAtCaret, insertDocument2BlockAfter, insertMathToken, insertMathTokenAtCaret, insertRefTokenAtCaret, isDocument2Valid, 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, toDocumentJson2, toggleBlockInSelection, toggleTextTokenStyle, updateCiteTokenKeys, updateDocument2ImageAsset, updateDocument2ImageMeta, updateDocument2ImageValue, updateDocument2Meta, updateDocument2Reference, updateDocument2TableMeta, updateDocument2TextBlockCentered, updateMathTokenLabel, updateRefTokenKeys, updateTextToken, validateDocument2 };
|
|
1146
|
+
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 Document2Anchor, type Document2Block, type Document2BlockJson, type Document2BlockMetadata, type Document2CitationIndexEntry, type Document2Command, Document2CommandError, type Document2CommandErrorCode, type Document2CrossReferenceIndexEntry, type Document2Diagnostic, type Document2Diff, type Document2DiffChunk, type Document2DiffChunkKind, type Document2Direction, type Document2HijriDate, type Document2HistoryStacks, type Document2ImageAssetRef, type Document2IndexedLabel, type Document2InlineAnchor, type Document2InlineIdsJson, type Document2InlineTokenIdJson, type Document2InlineTokenInput, type Document2Json, type Document2KeyError, type Document2KeyNamespace, type Document2LabelEntry, type Document2LabelKind, type Document2LatexOptions, type Document2ListItemAnchor, type Document2MathObjectJson, type Document2MathOutput, type Document2Meta, type Document2MetaProp, type Document2Node, type Document2OutlineEntry, type Document2OutlineKind, type Document2Preview, type Document2PreviewOptions, type Document2ReferenceAnchor, type Document2ReferenceIndex, type Document2TextBlockKind, Document2ValidationError, type Document2ValidationIssue, type Document2ValidationIssueCode, type Document2ValidationResult, 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 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, addDocument2ImageBlock, addDocument2ListBlock, addDocument2ListItem, addDocument2Reference, addDocument2TableBlock, addDocument2TextBlock, applyDocument2Command, applyFloatMetaPatch, arabicXeLatexPreambleCmd, arabicXeLatexPreambleFont, arabicXeLatexPreamblePkg, bibliographyEntryBody, bibliographyEntryLatex, butexBasmalaDisplayLatex, butexBasmalaDisplayTex, butexBasmalaTitlingPreamble, butexDiwaniDisplayLatex, butexDiwaniDisplayTex, butexInColumnMaketitleHook, butexMaghribiDisplayLatex, butexMaghribiDisplayTex, citeTokenLatex, clearDocument2ImageAsset, cloneDocument2Meta, cloneDocument2Node, collectDocument2Labels, createDocument2History, createEmptyArabicEquationSession, createEmptyDocument2, createEmptyEquationSession, createEmptyReference2, createInlineField2, defaultFloatMeta, detectInlineSpans2, detectMathSpans2, diffDocument2, document2HasAbstract, document2HasMaketitle, document2HasTitleStack, document2HistoryCanRedo, document2HistoryCanUndo, document2KeyError, document2Latex, document2Outline, document2Preview, emptyBlockSelection, emptyDocument2Meta, ensureDocument2BibliographyBlock, extendBlockSelectionFromAnchor, fillDocument2MetaGaps, findFirstInlineField, formatBibliographyNumber, formatCiteLabel, formatFloatCaptionPreview, formatFloatCaptionTitle, formatHijriDate, formatRefLabel, fromDocumentJson2, getArabicXeLatexPreamble, getDocument2ReferenceIndex, getDocument2References, hasXeLatexUnsupportedEmoji, hijriMonthLabel, inlineFieldLatex, insertCiteTokenAtCaret, insertDocument2BlockAfter, insertMathToken, insertMathTokenAtCaret, insertRefTokenAtCaret, isDocument2Valid, 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, toDocumentJson2, toggleBlockInSelection, toggleTextTokenStyle, updateCiteTokenKeys, updateDocument2ImageAsset, updateDocument2ImageMeta, updateDocument2ImageValue, updateDocument2Meta, updateDocument2Reference, updateDocument2TableMeta, updateDocument2TextBlockCentered, updateMathTokenLabel, updateRefTokenKeys, updateTextToken, validateDocument2 };
|
package/dist/document2.d.ts
CHANGED
|
@@ -905,6 +905,26 @@ declare class Document2CommandError extends Error {
|
|
|
905
905
|
/** Apply one validated command to canonical JSON without mutating caller input. */
|
|
906
906
|
declare function applyDocument2Command(json: Document2Json, commandInput: Document2Command): Document2Json;
|
|
907
907
|
|
|
908
|
+
type Document2DiffChunkKind = 'added' | 'removed' | 'context';
|
|
909
|
+
type Document2DiffChunk = {
|
|
910
|
+
kind: Document2DiffChunkKind;
|
|
911
|
+
text: string;
|
|
912
|
+
};
|
|
913
|
+
type Document2Diff = {
|
|
914
|
+
version: 1;
|
|
915
|
+
changed: boolean;
|
|
916
|
+
truncated: boolean;
|
|
917
|
+
chunks: Document2DiffChunk[];
|
|
918
|
+
};
|
|
919
|
+
/**
|
|
920
|
+
* Compare two persisted Document2 documents using canonical Document2 import/export
|
|
921
|
+
* semantics and jsdiff's maintained JSON diff implementation.
|
|
922
|
+
*
|
|
923
|
+
* Generated editor identity sidecars are intentionally excluded so equivalent
|
|
924
|
+
* legacy documents do not differ merely because normalization assigned new IDs.
|
|
925
|
+
*/
|
|
926
|
+
declare function diffDocument2(before: Document2Json, after: Document2Json): Document2Diff;
|
|
927
|
+
|
|
908
928
|
type Document2OutlineKind = 'section' | 'subsection' | 'subsubsection' | 'paragraph' | 'list' | 'table' | 'figure' | 'bibliography' | 'raw';
|
|
909
929
|
type Document2OutlineEntry = {
|
|
910
930
|
id: string;
|
|
@@ -1123,4 +1143,4 @@ declare function document2Preview(document: Document2Node, output?: Document2Mat
|
|
|
1123
1143
|
*/
|
|
1124
1144
|
declare function document2Latex(document: Document2Node, options?: Document2LatexOptions): string;
|
|
1125
1145
|
|
|
1126
|
-
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 Document2Anchor, type Document2Block, type Document2BlockJson, type Document2BlockMetadata, type Document2CitationIndexEntry, type Document2Command, Document2CommandError, type Document2CommandErrorCode, type Document2CrossReferenceIndexEntry, type Document2Diagnostic, type Document2Direction, type Document2HijriDate, type Document2HistoryStacks, type Document2ImageAssetRef, type Document2IndexedLabel, type Document2InlineAnchor, type Document2InlineIdsJson, type Document2InlineTokenIdJson, type Document2InlineTokenInput, type Document2Json, type Document2KeyError, type Document2KeyNamespace, type Document2LabelEntry, type Document2LabelKind, type Document2LatexOptions, type Document2ListItemAnchor, type Document2MathObjectJson, type Document2MathOutput, type Document2Meta, type Document2MetaProp, type Document2Node, type Document2OutlineEntry, type Document2OutlineKind, type Document2Preview, type Document2PreviewOptions, type Document2ReferenceAnchor, type Document2ReferenceIndex, type Document2TextBlockKind, Document2ValidationError, type Document2ValidationIssue, type Document2ValidationIssueCode, type Document2ValidationResult, 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 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, addDocument2ImageBlock, addDocument2ListBlock, addDocument2ListItem, addDocument2Reference, addDocument2TableBlock, addDocument2TextBlock, applyDocument2Command, applyFloatMetaPatch, arabicXeLatexPreambleCmd, arabicXeLatexPreambleFont, arabicXeLatexPreamblePkg, bibliographyEntryBody, bibliographyEntryLatex, butexBasmalaDisplayLatex, butexBasmalaDisplayTex, butexBasmalaTitlingPreamble, butexDiwaniDisplayLatex, butexDiwaniDisplayTex, butexInColumnMaketitleHook, butexMaghribiDisplayLatex, butexMaghribiDisplayTex, citeTokenLatex, clearDocument2ImageAsset, cloneDocument2Meta, cloneDocument2Node, collectDocument2Labels, createDocument2History, createEmptyArabicEquationSession, createEmptyDocument2, createEmptyEquationSession, createEmptyReference2, createInlineField2, defaultFloatMeta, detectInlineSpans2, detectMathSpans2, document2HasAbstract, document2HasMaketitle, document2HasTitleStack, document2HistoryCanRedo, document2HistoryCanUndo, document2KeyError, document2Latex, document2Outline, document2Preview, emptyBlockSelection, emptyDocument2Meta, ensureDocument2BibliographyBlock, extendBlockSelectionFromAnchor, fillDocument2MetaGaps, findFirstInlineField, formatBibliographyNumber, formatCiteLabel, formatFloatCaptionPreview, formatFloatCaptionTitle, formatHijriDate, formatRefLabel, fromDocumentJson2, getArabicXeLatexPreamble, getDocument2ReferenceIndex, getDocument2References, hasXeLatexUnsupportedEmoji, hijriMonthLabel, inlineFieldLatex, insertCiteTokenAtCaret, insertDocument2BlockAfter, insertMathToken, insertMathTokenAtCaret, insertRefTokenAtCaret, isDocument2Valid, 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, toDocumentJson2, toggleBlockInSelection, toggleTextTokenStyle, updateCiteTokenKeys, updateDocument2ImageAsset, updateDocument2ImageMeta, updateDocument2ImageValue, updateDocument2Meta, updateDocument2Reference, updateDocument2TableMeta, updateDocument2TextBlockCentered, updateMathTokenLabel, updateRefTokenKeys, updateTextToken, validateDocument2 };
|
|
1146
|
+
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 Document2Anchor, type Document2Block, type Document2BlockJson, type Document2BlockMetadata, type Document2CitationIndexEntry, type Document2Command, Document2CommandError, type Document2CommandErrorCode, type Document2CrossReferenceIndexEntry, type Document2Diagnostic, type Document2Diff, type Document2DiffChunk, type Document2DiffChunkKind, type Document2Direction, type Document2HijriDate, type Document2HistoryStacks, type Document2ImageAssetRef, type Document2IndexedLabel, type Document2InlineAnchor, type Document2InlineIdsJson, type Document2InlineTokenIdJson, type Document2InlineTokenInput, type Document2Json, type Document2KeyError, type Document2KeyNamespace, type Document2LabelEntry, type Document2LabelKind, type Document2LatexOptions, type Document2ListItemAnchor, type Document2MathObjectJson, type Document2MathOutput, type Document2Meta, type Document2MetaProp, type Document2Node, type Document2OutlineEntry, type Document2OutlineKind, type Document2Preview, type Document2PreviewOptions, type Document2ReferenceAnchor, type Document2ReferenceIndex, type Document2TextBlockKind, Document2ValidationError, type Document2ValidationIssue, type Document2ValidationIssueCode, type Document2ValidationResult, 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 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, addDocument2ImageBlock, addDocument2ListBlock, addDocument2ListItem, addDocument2Reference, addDocument2TableBlock, addDocument2TextBlock, applyDocument2Command, applyFloatMetaPatch, arabicXeLatexPreambleCmd, arabicXeLatexPreambleFont, arabicXeLatexPreamblePkg, bibliographyEntryBody, bibliographyEntryLatex, butexBasmalaDisplayLatex, butexBasmalaDisplayTex, butexBasmalaTitlingPreamble, butexDiwaniDisplayLatex, butexDiwaniDisplayTex, butexInColumnMaketitleHook, butexMaghribiDisplayLatex, butexMaghribiDisplayTex, citeTokenLatex, clearDocument2ImageAsset, cloneDocument2Meta, cloneDocument2Node, collectDocument2Labels, createDocument2History, createEmptyArabicEquationSession, createEmptyDocument2, createEmptyEquationSession, createEmptyReference2, createInlineField2, defaultFloatMeta, detectInlineSpans2, detectMathSpans2, diffDocument2, document2HasAbstract, document2HasMaketitle, document2HasTitleStack, document2HistoryCanRedo, document2HistoryCanUndo, document2KeyError, document2Latex, document2Outline, document2Preview, emptyBlockSelection, emptyDocument2Meta, ensureDocument2BibliographyBlock, extendBlockSelectionFromAnchor, fillDocument2MetaGaps, findFirstInlineField, formatBibliographyNumber, formatCiteLabel, formatFloatCaptionPreview, formatFloatCaptionTitle, formatHijriDate, formatRefLabel, fromDocumentJson2, getArabicXeLatexPreamble, getDocument2ReferenceIndex, getDocument2References, hasXeLatexUnsupportedEmoji, hijriMonthLabel, inlineFieldLatex, insertCiteTokenAtCaret, insertDocument2BlockAfter, insertMathToken, insertMathTokenAtCaret, insertRefTokenAtCaret, isDocument2Valid, 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, toDocumentJson2, toggleBlockInSelection, toggleTextTokenStyle, updateCiteTokenKeys, updateDocument2ImageAsset, updateDocument2ImageMeta, updateDocument2ImageValue, updateDocument2Meta, updateDocument2Reference, updateDocument2TableMeta, updateDocument2TextBlockCentered, updateMathTokenLabel, updateRefTokenKeys, updateTextToken, validateDocument2 };
|
package/dist/document2.js
CHANGED
|
@@ -69,6 +69,7 @@ __export(public_exports, {
|
|
|
69
69
|
defaultFloatMeta: () => defaultFloatMeta,
|
|
70
70
|
detectInlineSpans2: () => detectInlineSpans2,
|
|
71
71
|
detectMathSpans2: () => detectMathSpans2,
|
|
72
|
+
diffDocument2: () => diffDocument2,
|
|
72
73
|
document2HasAbstract: () => document2HasAbstract,
|
|
73
74
|
document2HasMaketitle: () => document2HasMaketitle,
|
|
74
75
|
document2HasTitleStack: () => document2HasTitleStack,
|
|
@@ -7236,6 +7237,104 @@ function applyDocument2Command(json, commandInput) {
|
|
|
7236
7237
|
return toDocumentJson2(document2);
|
|
7237
7238
|
}
|
|
7238
7239
|
|
|
7240
|
+
// src/document2/diff.ts
|
|
7241
|
+
var import_diff = require("diff");
|
|
7242
|
+
var MAX_TOTAL_TEXT_CHARS = 16e3;
|
|
7243
|
+
var MAX_CHANGED_CHUNK_CHARS = 4e3;
|
|
7244
|
+
var MAX_CONTEXT_CHUNK_CHARS = 600;
|
|
7245
|
+
var TRUNCATION_MARKER = "\n\u2026\n";
|
|
7246
|
+
var IDENTITY_KEYS = /* @__PURE__ */ new Set(["id", "inline_ids", "caption_inline_ids", "cell_inline_ids"]);
|
|
7247
|
+
function comparisonValue(value, key) {
|
|
7248
|
+
if (key && IDENTITY_KEYS.has(key)) {
|
|
7249
|
+
return void 0;
|
|
7250
|
+
}
|
|
7251
|
+
if (Array.isArray(value)) {
|
|
7252
|
+
return value.map((entry) => comparisonValue(entry));
|
|
7253
|
+
}
|
|
7254
|
+
if (value && typeof value === "object") {
|
|
7255
|
+
const result = {};
|
|
7256
|
+
for (const childKey of Object.keys(value).sort()) {
|
|
7257
|
+
const child = comparisonValue(value[childKey], childKey);
|
|
7258
|
+
if (child !== void 0) {
|
|
7259
|
+
result[childKey] = child;
|
|
7260
|
+
}
|
|
7261
|
+
}
|
|
7262
|
+
return result;
|
|
7263
|
+
}
|
|
7264
|
+
return value;
|
|
7265
|
+
}
|
|
7266
|
+
function normalizedComparisonDocument(document2) {
|
|
7267
|
+
return comparisonValue(toDocumentJson2(fromDocumentJson2(document2)));
|
|
7268
|
+
}
|
|
7269
|
+
function withoutFinalNewline(value) {
|
|
7270
|
+
return value.endsWith("\n") ? value.slice(0, -1) : value;
|
|
7271
|
+
}
|
|
7272
|
+
function shorten(text, limit, mode) {
|
|
7273
|
+
if (text.length <= limit) {
|
|
7274
|
+
return { text, truncated: false };
|
|
7275
|
+
}
|
|
7276
|
+
if (limit <= TRUNCATION_MARKER.length) {
|
|
7277
|
+
return { text: text.slice(0, Math.max(0, limit)), truncated: true };
|
|
7278
|
+
}
|
|
7279
|
+
const available = limit - TRUNCATION_MARKER.length;
|
|
7280
|
+
if (mode === "head") {
|
|
7281
|
+
return { text: `${text.slice(0, available)}${TRUNCATION_MARKER}`, truncated: true };
|
|
7282
|
+
}
|
|
7283
|
+
if (mode === "tail") {
|
|
7284
|
+
return { text: `${TRUNCATION_MARKER}${text.slice(text.length - available)}`, truncated: true };
|
|
7285
|
+
}
|
|
7286
|
+
const head = Math.ceil(available / 2);
|
|
7287
|
+
const tail = available - head;
|
|
7288
|
+
return {
|
|
7289
|
+
text: `${text.slice(0, head)}${TRUNCATION_MARKER}${text.slice(text.length - tail)}`,
|
|
7290
|
+
truncated: true
|
|
7291
|
+
};
|
|
7292
|
+
}
|
|
7293
|
+
function diffDocument2(before, after) {
|
|
7294
|
+
const beforeComparable = normalizedComparisonDocument(before);
|
|
7295
|
+
const afterComparable = normalizedComparisonDocument(after);
|
|
7296
|
+
const parts = (0, import_diff.diffJson)(beforeComparable, afterComparable);
|
|
7297
|
+
const changed = parts.some((part) => part.added === true || part.removed === true);
|
|
7298
|
+
if (!changed) {
|
|
7299
|
+
return { version: 1, changed: false, truncated: false, chunks: [] };
|
|
7300
|
+
}
|
|
7301
|
+
const chunks = [];
|
|
7302
|
+
let truncated = false;
|
|
7303
|
+
let totalTextChars = 0;
|
|
7304
|
+
const append = (kind, rawText, limit, mode) => {
|
|
7305
|
+
const cleaned = withoutFinalNewline(rawText);
|
|
7306
|
+
if (cleaned.length === 0) return;
|
|
7307
|
+
const perChunk = shorten(cleaned, limit, mode);
|
|
7308
|
+
truncated ||= perChunk.truncated;
|
|
7309
|
+
const remaining = MAX_TOTAL_TEXT_CHARS - totalTextChars;
|
|
7310
|
+
if (remaining <= 0) {
|
|
7311
|
+
truncated = true;
|
|
7312
|
+
return;
|
|
7313
|
+
}
|
|
7314
|
+
const withinBudget = shorten(perChunk.text, remaining, mode);
|
|
7315
|
+
truncated ||= withinBudget.truncated;
|
|
7316
|
+
if (withinBudget.text.length === 0) return;
|
|
7317
|
+
chunks.push({ kind, text: withinBudget.text });
|
|
7318
|
+
totalTextChars += withinBudget.text.length;
|
|
7319
|
+
};
|
|
7320
|
+
parts.forEach((part, index) => {
|
|
7321
|
+
if (part.added) {
|
|
7322
|
+
append("added", part.value, MAX_CHANGED_CHUNK_CHARS, "both");
|
|
7323
|
+
return;
|
|
7324
|
+
}
|
|
7325
|
+
if (part.removed) {
|
|
7326
|
+
append("removed", part.value, MAX_CHANGED_CHUNK_CHARS, "both");
|
|
7327
|
+
return;
|
|
7328
|
+
}
|
|
7329
|
+
const previousChanged = index > 0 && (parts[index - 1]?.added === true || parts[index - 1]?.removed === true);
|
|
7330
|
+
const nextChanged = index + 1 < parts.length && (parts[index + 1]?.added === true || parts[index + 1]?.removed === true);
|
|
7331
|
+
if (!previousChanged && !nextChanged) return;
|
|
7332
|
+
const mode = previousChanged && nextChanged ? "both" : previousChanged ? "head" : "tail";
|
|
7333
|
+
append("context", part.value, MAX_CONTEXT_CHUNK_CHARS, mode);
|
|
7334
|
+
});
|
|
7335
|
+
return { version: 1, changed: true, truncated, chunks };
|
|
7336
|
+
}
|
|
7337
|
+
|
|
7239
7338
|
// src/document2/outline.ts
|
|
7240
7339
|
var EXCERPT_LIMIT = 160;
|
|
7241
7340
|
function normalizeExcerpt(value) {
|
|
@@ -8568,6 +8667,7 @@ function document2Latex2(document2, options = {}) {
|
|
|
8568
8667
|
defaultFloatMeta,
|
|
8569
8668
|
detectInlineSpans2,
|
|
8570
8669
|
detectMathSpans2,
|
|
8670
|
+
diffDocument2,
|
|
8571
8671
|
document2HasAbstract,
|
|
8572
8672
|
document2HasMaketitle,
|
|
8573
8673
|
document2HasTitleStack,
|