@drghaliasri/butex 5.4.6 → 5.5.1

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.
@@ -175,6 +175,7 @@ type Document2Json = {
175
175
  type Document2BlockJson = {
176
176
  command: string;
177
177
  value?: string;
178
+ formats?: TextFormatSpan2Json[];
178
179
  /** Stable host asset identity (e.g. S3 key / UUID); optional for \\includegraphics. */
179
180
  asset_id?: string;
180
181
  math_objects?: MathObject2Json[];
@@ -182,6 +183,7 @@ type Document2BlockJson = {
182
183
  closing?: string;
183
184
  items?: Document2ListItemJson[];
184
185
  rows?: string[][];
186
+ cell_formats?: TextFormatSpan2Json[][][];
185
187
  columns?: string;
186
188
  caption?: string;
187
189
  label?: string;
@@ -191,6 +193,7 @@ type Document2BlockJson = {
191
193
  };
192
194
  type Document2ListItemJson = {
193
195
  value: string;
196
+ formats?: TextFormatSpan2Json[];
194
197
  math_objects?: MathObject2Json[];
195
198
  blocks?: Document2BlockJson[];
196
199
  };
@@ -210,10 +213,23 @@ type Reference2 = {
210
213
  /** Joins authors/title/venue/year in bibliography display and export. */
211
214
  fieldSeparator: ReferenceFieldSeparator;
212
215
  };
216
+ type TextStyle2 = {
217
+ bold?: true;
218
+ italic?: true;
219
+ underline?: true;
220
+ };
221
+ type TextFormatSpan2Json = {
222
+ start: number;
223
+ end: number;
224
+ bold?: boolean;
225
+ italic?: boolean;
226
+ underline?: boolean;
227
+ };
213
228
  type TextToken2 = {
214
229
  id: string;
215
230
  kind: 'text';
216
231
  text: string;
232
+ style?: TextStyle2;
217
233
  };
218
234
  type MathToken2 = {
219
235
  id: string;
@@ -344,6 +360,7 @@ type DetectedInlineSpan2 = ({
344
360
  type PreviewInline2 = {
345
361
  kind: 'text';
346
362
  text: string;
363
+ style?: TextStyle2;
347
364
  } | {
348
365
  kind: 'math';
349
366
  id: string;
@@ -570,6 +587,7 @@ declare function insertDocument2BlockAfter(document: Document2Node, afterBlockId
570
587
  declare function moveDocument2BlockById(document: Document2Node, blockId: string, direction: -1 | 1): Document2Node;
571
588
  declare function moveDocument2BlockRange(document: Document2Node, from: number, to: number, direction: -1 | 1): Document2Node;
572
589
  declare function removeDocument2BlockRange(document: Document2Node, from: number, to: number): Document2Node;
590
+ declare function toggleTextTokenStyle(document: Document2Node, fieldId: string, tokenId: string, selectionStart: number, selectionEnd: number, styleName: keyof TextStyle2): Document2Node;
573
591
  declare function removeMathTokenById(document: Document2Node, tokenId: string): Document2Node;
574
592
  declare function insertMathTokenAtCaret(document: Document2Node, fieldId: string, textTokenId: string | null, caretOffset: number, session: EditorSession, opening?: string, closing?: string, side?: EditorSide): Document2Node;
575
593
  declare function insertMathToken(document: Document2Node, fieldId: string, insertIndex: number, session: EditorSession, opening?: string, closing?: string, side?: EditorSide): Document2Node;
@@ -699,7 +717,7 @@ declare function toggleBlockInSelection(state: BlockSelectionState, index: numbe
699
717
  declare function extendBlockSelectionFromAnchor(state: BlockSelectionState, index: number, blockCount: number): BlockSelectionState;
700
718
  declare function remapSelectionAfterRangeMove(selection: BlockSelectionRange, direction: -1 | 1): BlockSelectionRange;
701
719
 
702
- declare function createInlineField2(value?: string, mathObjects?: MathObject2Json[], options?: ImportDocument2Options, path?: string, diagnostics?: Document2Diagnostic[]): InlineField2;
720
+ declare function createInlineField2(value?: string, mathObjects?: MathObject2Json[], options?: ImportDocument2Options, path?: string, diagnostics?: Document2Diagnostic[], formats?: TextFormatSpan2Json[]): InlineField2;
703
721
  declare function fromDocumentJson2(json: unknown, options?: ImportDocument2Options): Document2Node;
704
722
  declare function createEmptyDocument2(): Document2Node;
705
723
 
@@ -732,4 +750,4 @@ type Document2PreviewOptions = {
732
750
  };
733
751
  declare function document2Preview(document: Document2Node, output?: Document2MathOutput, equationSide?: EditorSide, previewOptions?: Document2PreviewOptions): Document2Preview;
734
752
 
735
- 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 };
753
+ 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 TextFormatSpan2Json, type TextStyle2, 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, toggleTextTokenStyle, updateCiteTokenKeys, updateDocument2ImageMeta, updateDocument2ImageValue, updateDocument2Meta, updateDocument2Reference, updateDocument2TableMeta, updateDocument2TextBlockCentered, updateMathTokenLabel, updateRefTokenKeys, updateTextToken };
@@ -175,6 +175,7 @@ type Document2Json = {
175
175
  type Document2BlockJson = {
176
176
  command: string;
177
177
  value?: string;
178
+ formats?: TextFormatSpan2Json[];
178
179
  /** Stable host asset identity (e.g. S3 key / UUID); optional for \\includegraphics. */
179
180
  asset_id?: string;
180
181
  math_objects?: MathObject2Json[];
@@ -182,6 +183,7 @@ type Document2BlockJson = {
182
183
  closing?: string;
183
184
  items?: Document2ListItemJson[];
184
185
  rows?: string[][];
186
+ cell_formats?: TextFormatSpan2Json[][][];
185
187
  columns?: string;
186
188
  caption?: string;
187
189
  label?: string;
@@ -191,6 +193,7 @@ type Document2BlockJson = {
191
193
  };
192
194
  type Document2ListItemJson = {
193
195
  value: string;
196
+ formats?: TextFormatSpan2Json[];
194
197
  math_objects?: MathObject2Json[];
195
198
  blocks?: Document2BlockJson[];
196
199
  };
@@ -210,10 +213,23 @@ type Reference2 = {
210
213
  /** Joins authors/title/venue/year in bibliography display and export. */
211
214
  fieldSeparator: ReferenceFieldSeparator;
212
215
  };
216
+ type TextStyle2 = {
217
+ bold?: true;
218
+ italic?: true;
219
+ underline?: true;
220
+ };
221
+ type TextFormatSpan2Json = {
222
+ start: number;
223
+ end: number;
224
+ bold?: boolean;
225
+ italic?: boolean;
226
+ underline?: boolean;
227
+ };
213
228
  type TextToken2 = {
214
229
  id: string;
215
230
  kind: 'text';
216
231
  text: string;
232
+ style?: TextStyle2;
217
233
  };
218
234
  type MathToken2 = {
219
235
  id: string;
@@ -344,6 +360,7 @@ type DetectedInlineSpan2 = ({
344
360
  type PreviewInline2 = {
345
361
  kind: 'text';
346
362
  text: string;
363
+ style?: TextStyle2;
347
364
  } | {
348
365
  kind: 'math';
349
366
  id: string;
@@ -570,6 +587,7 @@ declare function insertDocument2BlockAfter(document: Document2Node, afterBlockId
570
587
  declare function moveDocument2BlockById(document: Document2Node, blockId: string, direction: -1 | 1): Document2Node;
571
588
  declare function moveDocument2BlockRange(document: Document2Node, from: number, to: number, direction: -1 | 1): Document2Node;
572
589
  declare function removeDocument2BlockRange(document: Document2Node, from: number, to: number): Document2Node;
590
+ declare function toggleTextTokenStyle(document: Document2Node, fieldId: string, tokenId: string, selectionStart: number, selectionEnd: number, styleName: keyof TextStyle2): Document2Node;
573
591
  declare function removeMathTokenById(document: Document2Node, tokenId: string): Document2Node;
574
592
  declare function insertMathTokenAtCaret(document: Document2Node, fieldId: string, textTokenId: string | null, caretOffset: number, session: EditorSession, opening?: string, closing?: string, side?: EditorSide): Document2Node;
575
593
  declare function insertMathToken(document: Document2Node, fieldId: string, insertIndex: number, session: EditorSession, opening?: string, closing?: string, side?: EditorSide): Document2Node;
@@ -699,7 +717,7 @@ declare function toggleBlockInSelection(state: BlockSelectionState, index: numbe
699
717
  declare function extendBlockSelectionFromAnchor(state: BlockSelectionState, index: number, blockCount: number): BlockSelectionState;
700
718
  declare function remapSelectionAfterRangeMove(selection: BlockSelectionRange, direction: -1 | 1): BlockSelectionRange;
701
719
 
702
- declare function createInlineField2(value?: string, mathObjects?: MathObject2Json[], options?: ImportDocument2Options, path?: string, diagnostics?: Document2Diagnostic[]): InlineField2;
720
+ declare function createInlineField2(value?: string, mathObjects?: MathObject2Json[], options?: ImportDocument2Options, path?: string, diagnostics?: Document2Diagnostic[], formats?: TextFormatSpan2Json[]): InlineField2;
703
721
  declare function fromDocumentJson2(json: unknown, options?: ImportDocument2Options): Document2Node;
704
722
  declare function createEmptyDocument2(): Document2Node;
705
723
 
@@ -732,4 +750,4 @@ type Document2PreviewOptions = {
732
750
  };
733
751
  declare function document2Preview(document: Document2Node, output?: Document2MathOutput, equationSide?: EditorSide, previewOptions?: Document2PreviewOptions): Document2Preview;
734
752
 
735
- 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 };
753
+ 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 TextFormatSpan2Json, type TextStyle2, 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, toggleTextTokenStyle, updateCiteTokenKeys, updateDocument2ImageMeta, updateDocument2ImageValue, updateDocument2Meta, updateDocument2Reference, updateDocument2TableMeta, updateDocument2TextBlockCentered, updateMathTokenLabel, updateRefTokenKeys, updateTextToken };
package/dist/document2.js CHANGED
@@ -133,6 +133,7 @@ __export(document2_exports, {
133
133
  setDocument2References: () => setDocument2References,
134
134
  stripDisplayMathDelimiters: () => stripDisplayMathDelimiters,
135
135
  toggleBlockInSelection: () => toggleBlockInSelection,
136
+ toggleTextTokenStyle: () => toggleTextTokenStyle,
136
137
  updateCiteTokenKeys: () => updateCiteTokenKeys,
137
138
  updateDocument2ImageMeta: () => updateDocument2ImageMeta,
138
139
  updateDocument2ImageValue: () => updateDocument2ImageValue,
@@ -1281,7 +1282,7 @@ function parseReferences(json) {
1281
1282
  }
1282
1283
  return references;
1283
1284
  }
1284
- function createInlineField2(value = "", mathObjects = [], options = {}, path = "$", diagnostics = []) {
1285
+ function createInlineField2(value = "", mathObjects = [], options = {}, path = "$", diagnostics = [], formats = []) {
1285
1286
  const mode = options.mode ?? "english";
1286
1287
  const spans = detectInlineSpans2(value);
1287
1288
  const mathSpans = spans.filter((span) => span.kind === "math");
@@ -1293,7 +1294,7 @@ function createInlineField2(value = "", mathObjects = [], options = {}, path = "
1293
1294
  }
1294
1295
  for (const span of spans) {
1295
1296
  if (span.start > index) {
1296
- tokens.push({ id: document2Id("text"), kind: "text", text: value.slice(index, span.start) });
1297
+ pushFormattedTextTokens(tokens, value.slice(index, span.start), index, formats);
1297
1298
  }
1298
1299
  if (span.kind === "cite") {
1299
1300
  tokens.push({
@@ -1349,9 +1350,81 @@ function createInlineField2(value = "", mathObjects = [], options = {}, path = "
1349
1350
  index = span.end;
1350
1351
  }
1351
1352
  if (index < value.length || tokens.length === 0) {
1352
- tokens.push({ id: document2Id("text"), kind: "text", text: value.slice(index) });
1353
+ pushFormattedTextTokens(tokens, value.slice(index), index, formats);
1354
+ }
1355
+ return { id: document2Id("field"), tokens: compactTextTokens(tokens) };
1356
+ }
1357
+ function styleFromFormat(format) {
1358
+ const style = {};
1359
+ if (format.bold === true) {
1360
+ style.bold = true;
1361
+ }
1362
+ if (format.italic === true) {
1363
+ style.italic = true;
1364
+ }
1365
+ if (format.underline === true) {
1366
+ style.underline = true;
1367
+ }
1368
+ return style.bold || style.italic || style.underline ? style : null;
1369
+ }
1370
+ function mergeTextStyle(base, added) {
1371
+ return {
1372
+ ...base?.bold ? { bold: true } : {},
1373
+ ...base?.italic ? { italic: true } : {},
1374
+ ...base?.underline ? { underline: true } : {},
1375
+ ...added.bold ? { bold: true } : {},
1376
+ ...added.italic ? { italic: true } : {},
1377
+ ...added.underline ? { underline: true } : {}
1378
+ };
1379
+ }
1380
+ function textStylesEqual(a, b) {
1381
+ return Boolean(a?.bold) === Boolean(b?.bold) && Boolean(a?.italic) === Boolean(b?.italic) && Boolean(a?.underline) === Boolean(b?.underline);
1382
+ }
1383
+ function compactTextTokens(tokens) {
1384
+ const compacted = [];
1385
+ for (const token of tokens) {
1386
+ const previous = compacted[compacted.length - 1];
1387
+ if (previous?.kind === "text" && token.kind === "text" && textStylesEqual(previous.style, token.style)) {
1388
+ previous.text += token.text;
1389
+ } else {
1390
+ compacted.push(token);
1391
+ }
1392
+ }
1393
+ return compacted;
1394
+ }
1395
+ function styleKey(style) {
1396
+ return `${style?.bold ? "b" : ""}${style?.italic ? "i" : ""}${style?.underline ? "u" : ""}`;
1397
+ }
1398
+ function pushFormattedTextTokens(tokens, text, sourceStart, formats) {
1399
+ if (text.length === 0) {
1400
+ tokens.push({ id: document2Id("text"), kind: "text", text });
1401
+ return;
1402
+ }
1403
+ const styles = Array.from({ length: text.length });
1404
+ for (const format of formats) {
1405
+ const style = styleFromFormat(format);
1406
+ if (!style || !Number.isFinite(format.start) || !Number.isFinite(format.end)) {
1407
+ continue;
1408
+ }
1409
+ const start = Math.max(0, Math.min(text.length, Math.trunc(format.start) - sourceStart));
1410
+ const end = Math.max(0, Math.min(text.length, Math.trunc(format.end) - sourceStart));
1411
+ if (end <= start) {
1412
+ continue;
1413
+ }
1414
+ for (let index = start; index < end; index += 1) {
1415
+ styles[index] = mergeTextStyle(styles[index], style);
1416
+ }
1417
+ }
1418
+ let chunkStart = 0;
1419
+ for (let index = 1; index <= text.length; index += 1) {
1420
+ if (index < text.length && styleKey(styles[index]) === styleKey(styles[chunkStart])) {
1421
+ continue;
1422
+ }
1423
+ const chunk = text.slice(chunkStart, index);
1424
+ const style = styles[chunkStart];
1425
+ tokens.push({ id: document2Id("text"), kind: "text", text: chunk, ...style ? { style } : {} });
1426
+ chunkStart = index;
1353
1427
  }
1354
- return { id: document2Id("field"), tokens };
1355
1428
  }
1356
1429
  function closingForList(command) {
1357
1430
  return command === "\\begin{itemize}" ? "\\end{itemize}" : "\\end{enumerate}";
@@ -1362,7 +1435,7 @@ function parseTextBlock(json, options, path, diagnostics) {
1362
1435
  id: document2Id("block"),
1363
1436
  kind: "textBlock",
1364
1437
  command: json.command,
1365
- field: createInlineField2(value, json.math_objects ?? [], options, `${path}.value`, diagnostics),
1438
+ field: createInlineField2(value, json.math_objects ?? [], options, `${path}.value`, diagnostics, json.command === "\\paragraph" ? json.formats ?? [] : []),
1366
1439
  ...json.centered === true ? { centered: true } : {}
1367
1440
  };
1368
1441
  }
@@ -1371,7 +1444,7 @@ function parseListItem(json, options, path, diagnostics) {
1371
1444
  const blocksJson = Array.isArray(json.blocks) ? json.blocks : [];
1372
1445
  return {
1373
1446
  id: document2Id("item"),
1374
- field: createInlineField2(value, json.math_objects ?? [], options, `${path}.value`, diagnostics),
1447
+ field: createInlineField2(value, json.math_objects ?? [], options, `${path}.value`, diagnostics, json.formats ?? []),
1375
1448
  blocks: blocksJson.map((block, index) => parseBlock(asBlockJson(block), options, `${path}.blocks[${String(index)}]`, diagnostics))
1376
1449
  };
1377
1450
  }
@@ -1404,7 +1477,8 @@ function parseTableBlock(json, options, path, diagnostics) {
1404
1477
  const spanCount = detectMathSpans2(value).length;
1405
1478
  const cellMathObjects = mathObjects.slice(mathObjectIndex, mathObjectIndex + spanCount);
1406
1479
  mathObjectIndex += spanCount;
1407
- return createInlineField2(value, cellMathObjects, options, `${path}.rows[${String(rowIndex)}][${String(columnIndex)}]`, diagnostics);
1480
+ const cellFormats = json.cell_formats?.[rowIndex]?.[columnIndex] ?? [];
1481
+ return createInlineField2(value, cellMathObjects, options, `${path}.rows[${String(rowIndex)}][${String(columnIndex)}]`, diagnostics, cellFormats);
1408
1482
  });
1409
1483
  });
1410
1484
  if (mathObjects.length > 0 && mathObjects.length !== mathObjectIndex) {
@@ -3429,7 +3503,8 @@ ${BUTEX_FONT_FACE_CSS}
3429
3503
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
3430
3504
  }
3431
3505
 
3432
- .surface:focus {
3506
+ .surface:focus,
3507
+ .surface.surface--typing-focus {
3433
3508
  border-color: var(--butex-focus-border, rgba(13, 148, 136, 0.45));
3434
3509
  box-shadow: 0 0 0 3px var(--butex-focus-shadow, rgba(13, 148, 136, 0.12));
3435
3510
  }
@@ -4444,6 +4519,79 @@ function normalizeFieldTokens(tokens) {
4444
4519
  }
4445
4520
  return tokens;
4446
4521
  }
4522
+ function textStylesEqual2(a, b) {
4523
+ return Boolean(a?.bold) === Boolean(b?.bold) && Boolean(a?.italic) === Boolean(b?.italic) && Boolean(a?.underline) === Boolean(b?.underline);
4524
+ }
4525
+ function compactAdjacentTextTokens(tokens) {
4526
+ const compacted = [];
4527
+ for (const token of tokens) {
4528
+ const previous = compacted[compacted.length - 1];
4529
+ if (previous?.kind === "text" && token.kind === "text" && textStylesEqual2(previous.style, token.style)) {
4530
+ previous.text += token.text;
4531
+ } else {
4532
+ compacted.push(token);
4533
+ }
4534
+ }
4535
+ return normalizeFieldTokens(compacted);
4536
+ }
4537
+ function withoutEmptyStyle(style) {
4538
+ const next = {};
4539
+ if (style.bold) {
4540
+ next.bold = true;
4541
+ }
4542
+ if (style.italic) {
4543
+ next.italic = true;
4544
+ }
4545
+ if (style.underline) {
4546
+ next.underline = true;
4547
+ }
4548
+ return next.bold || next.italic || next.underline ? next : void 0;
4549
+ }
4550
+ function textTokenPart(text, style, id = document2Id("text")) {
4551
+ return { id, kind: "text", text, ...style ? { style } : {} };
4552
+ }
4553
+ function toggleTextTokenStyle(document2, fieldId, tokenId, selectionStart, selectionEnd, styleName) {
4554
+ if (selectionEnd <= selectionStart) {
4555
+ return document2;
4556
+ }
4557
+ const next = cloneDocument(document2);
4558
+ visitFields(next.blocks, (field) => {
4559
+ if (field.id !== fieldId) {
4560
+ return false;
4561
+ }
4562
+ const tokenIndex = field.tokens.findIndex((entry) => entry.id === tokenId && entry.kind === "text");
4563
+ if (tokenIndex < 0) {
4564
+ return true;
4565
+ }
4566
+ const token = field.tokens[tokenIndex];
4567
+ const start = Math.max(0, Math.min(token.text.length, selectionStart));
4568
+ const end = Math.max(0, Math.min(token.text.length, selectionEnd));
4569
+ if (end <= start) {
4570
+ return true;
4571
+ }
4572
+ const selectedStyle = token.style ?? {};
4573
+ const enabled = selectedStyle[styleName] === true;
4574
+ const nextStyle = withoutEmptyStyle({ ...selectedStyle, [styleName]: enabled ? void 0 : true });
4575
+ const parts = [];
4576
+ const before = token.text.slice(0, start);
4577
+ const selected = token.text.slice(start, end);
4578
+ const after = token.text.slice(end);
4579
+ if (before.length > 0) {
4580
+ parts.push(textTokenPart(before, token.style, token.id));
4581
+ }
4582
+ parts.push(textTokenPart(selected, nextStyle, before.length > 0 ? document2Id("text") : token.id));
4583
+ if (after.length > 0) {
4584
+ parts.push(textTokenPart(after, token.style));
4585
+ }
4586
+ field.tokens = compactAdjacentTextTokens([
4587
+ ...field.tokens.slice(0, tokenIndex),
4588
+ ...parts,
4589
+ ...field.tokens.slice(tokenIndex + 1)
4590
+ ]);
4591
+ return true;
4592
+ });
4593
+ return next;
4594
+ }
4447
4595
  function stitchTextAroundRemovedToken(tokens, index) {
4448
4596
  const before = tokens[index - 1];
4449
4597
  const after = tokens[index + 1];
@@ -4471,8 +4619,8 @@ function removeMathTokenById(document2, tokenId) {
4471
4619
  function splitTextTokenAt(token, offset) {
4472
4620
  const safeOffset = Math.max(0, Math.min(offset, token.text.length));
4473
4621
  return [
4474
- { id: token.id, kind: "text", text: token.text.slice(0, safeOffset) },
4475
- { id: document2Id("text"), kind: "text", text: token.text.slice(safeOffset) }
4622
+ { id: token.id, kind: "text", text: token.text.slice(0, safeOffset), ...token.style ? { style: token.style } : {} },
4623
+ { id: document2Id("text"), kind: "text", text: token.text.slice(safeOffset), ...token.style ? { style: token.style } : {} }
4476
4624
  ];
4477
4625
  }
4478
4626
  function insertMathTokenAtCaret(document2, fieldId, textTokenId, caretOffset, session, opening = "$", closing = "$", side = "arabic") {
@@ -5009,7 +5157,7 @@ function arabicXeLatexPreamblePkg(twocolumn = false) {
5009
5157
  \usepackage{bidi}
5010
5158
  \usepackage{multirow}
5011
5159
  \usepackage{booktabs}
5012
- \usepackage{graphicx} % For \butexreflect
5160
+ \usepackage{graphicx} % For \reflectbox
5013
5161
  \usepackage{xcolor}
5014
5162
  \usepackage{tikz}
5015
5163
  \usepackage{tcolorbox} % For tcolorbox environment
@@ -5078,10 +5226,8 @@ function arabicXeLatexPreambleCmd() {
5078
5226
  \newcommand{\horzbar}{\rule[.5ex]{2.5ex}{0.5pt}}
5079
5227
 
5080
5228
 
5081
- \newcommand{\butexreflect}[1]{\tikz[baseline=(n.base)]{\node[inner sep=0pt,outer sep=0pt,xscale=-1](n){#1};}}
5082
-
5083
- \newcommand{\arabsqrt}[2]{\butexreflect{\(\sqrt[\butexreflect{\(#1\)}]{\butexreflect{\(#2\)}}\)}}
5084
- \newcommand{\arabvec}[1]{\butexreflect{$\vec{\butexreflect{$#1$}}$}}
5229
+ \newcommand{\arabsqrt}[2]{\reflectbox{\(\sqrt[\reflectbox{\(#1\)}]{\reflectbox{\(#2\)}}\)}}
5230
+ \newcommand{\arabvec}[1]{\reflectbox{$\vec{\reflectbox{$#1$}}$}}
5085
5231
 
5086
5232
  \newcommand{\arabexp}[1]{{}^{#1}\!\raisebox{-4.5pt}{\text{\diwani{ه}}}}
5087
5233
  \newcommand{\arablog}[2]{\left(\text{#2}\right)\!\prescript{}{\text{#1}}{\text{\diwani{لو}}}}
@@ -5129,9 +5275,9 @@ function arabicXeLatexPreambleCmd() {
5129
5275
  \newcommand{\araboddde}[2][-5pt]{\stackrel{\raisebox{#1}{$\vcenter{\hbox{$\cdot\!\cdot\!\cdot$}}$}}{\text{#2}}}
5130
5276
  \newcommand{\arabpde}[1]{\prescript{}{#1\!\!}{\nabla}} % arabic partial differential equation (PDE)
5131
5277
 
5132
- \newcommand{\arabprime}[0]{\butexreflect{$\prime$}\!} % arabic prime notation
5133
- \newcommand{\arabpprime}[0]{\butexreflect{$\prime$}\butexreflect{$\prime$}\!} % arabic prime notation
5134
- \newcommand{\arabppprime}[0]{\butexreflect{$\prime$}\butexreflect{$\prime$}\butexreflect{$\prime$}\!} % arabic prime notation
5278
+ \newcommand{\arabprime}[0]{\reflectbox{$\prime$}\!} % arabic prime notation
5279
+ \newcommand{\arabpprime}[0]{\reflectbox{$\prime$}\reflectbox{$\prime$}\!} % arabic prime notation
5280
+ \newcommand{\arabppprime}[0]{\reflectbox{$\prime$}\reflectbox{$\prime$}\reflectbox{$\prime$}\!} % arabic prime notation
5135
5281
 
5136
5282
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5137
5283
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -5151,7 +5297,7 @@ function arabicXeLatexPreambleCmd() {
5151
5297
  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5152
5298
 
5153
5299
 
5154
- \newcommand{\arsqrt}[2][]{\butexreflect{\(\sqrt[\butexreflect{\(#1\)}]{\butexreflect{\(#2\)}}\)}}
5300
+ \newcommand{\arsqrt}[2][]{\reflectbox{\(\sqrt[\reflectbox{\(#1\)}]{\reflectbox{\(#2\)}}\)}}
5155
5301
  \newcommand{\arexp}[0]{\!\raisebox{-4.5pt}{\text{\diwani{ه}}}}
5156
5302
  \newcommand{\arlog}[0]{\!\!\text{\diwani{لو}}}
5157
5303
  \newcommand{\arln}[0]{\!\!\prescript{}{\text{\diwani{ه}}}{\text{\diwani{لو}}}}
@@ -5214,9 +5360,22 @@ function mathBodyLatex(token) {
5214
5360
  const rendered = renderMathNodeLatex(token.math);
5215
5361
  return stripDisplayMathDelimiters(rendered);
5216
5362
  }
5363
+ function styledTextLatex(text, style) {
5364
+ let output = text;
5365
+ if (style?.bold) {
5366
+ output = `\\textbf{${output}}`;
5367
+ }
5368
+ if (style?.italic) {
5369
+ output = `\\textit{${output}}`;
5370
+ }
5371
+ if (style?.underline) {
5372
+ output = `\\underline{${output}}`;
5373
+ }
5374
+ return output;
5375
+ }
5217
5376
  function tokenLatex(token) {
5218
5377
  if (token.kind === "text") {
5219
- return token.text;
5378
+ return styledTextLatex(token.text, token.style);
5220
5379
  }
5221
5380
  if (token.kind === "cite") {
5222
5381
  return citeTokenLatex(token.keys);
@@ -5240,7 +5399,9 @@ function inlineFieldLatex(field) {
5240
5399
  return field.tokens.map((token) => tokenLatex(token)).join("");
5241
5400
  }
5242
5401
  function textBlockLatex(block) {
5243
- const body = `${block.command}{${inlineFieldLatex(block.field)}}`;
5402
+ const content = inlineFieldLatex(block.field);
5403
+ const body = block.command === "\\paragraph" ? `\\par
5404
+ ${content}` : `${block.command}{${content}}`;
5244
5405
  if (block.command === "\\paragraph" && block.centered) {
5245
5406
  return `\\begin{center}
5246
5407
  ${body}
@@ -5492,7 +5653,7 @@ function mathTex(token, equationSide) {
5492
5653
  function previewInlines(field, islands, output, equationSide, document2, previewOptions) {
5493
5654
  return field.tokens.map((token) => {
5494
5655
  if (token.kind === "text") {
5495
- return { kind: "text", text: token.text };
5656
+ return { kind: "text", text: token.text, ...token.style ? { style: token.style } : {} };
5496
5657
  }
5497
5658
  if (token.kind === "cite") {
5498
5659
  return {
@@ -5774,6 +5935,7 @@ function document2Preview(document2, output = "svg", equationSide = "arabic", pr
5774
5935
  setDocument2References,
5775
5936
  stripDisplayMathDelimiters,
5776
5937
  toggleBlockInSelection,
5938
+ toggleTextTokenStyle,
5777
5939
  updateCiteTokenKeys,
5778
5940
  updateDocument2ImageMeta,
5779
5941
  updateDocument2ImageValue,