@drghaliasri/butex 8.1.2 → 8.1.5

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.
@@ -531,6 +531,7 @@ type DocumentBookTarget = {
531
531
  kind: DocumentLabelKind | 'section' | 'subsection' | 'subsubsection' | 'chapter' | 'appendix';
532
532
  caption?: string;
533
533
  displayLabel?: string;
534
+ ordinal?: string;
534
535
  manualKey?: string;
535
536
  };
536
537
  type DocumentBookContext = {
@@ -531,6 +531,7 @@ type DocumentBookTarget = {
531
531
  kind: DocumentLabelKind | 'section' | 'subsection' | 'subsubsection' | 'chapter' | 'appendix';
532
532
  caption?: string;
533
533
  displayLabel?: string;
534
+ ordinal?: string;
534
535
  manualKey?: string;
535
536
  };
536
537
  type DocumentBookContext = {
@@ -11224,6 +11224,11 @@ function remapSelectionAfterRangeMove(selection, direction) {
11224
11224
  function mathTex(token, equationSide, digitForm) {
11225
11225
  return mathTokenSourceForSide(token, equationSide, digitForm, true);
11226
11226
  }
11227
+ function projectedBookTarget(options, ownerId, kind) {
11228
+ if (options.mode !== "book-content") return void 0;
11229
+ const book = options.bookContext;
11230
+ return book?.targets?.find((target) => target.unitId === book.unitId && target.ownerId === ownerId && target.kind === kind);
11231
+ }
11227
11232
  function previewInlines(field, islands, output, equationSide, document2, previewOptions) {
11228
11233
  return field.tokens.map((token) => {
11229
11234
  if (token.kind === "text") {
@@ -11255,7 +11260,8 @@ function previewInlines(field, islands, output, equationSide, document2, preview
11255
11260
  })
11256
11261
  };
11257
11262
  }
11258
- const number = collectDocumentReferenceTargets(document2).find((target) => target.kind === "eq" && target.ownerId === token.id)?.number;
11263
+ const projected = projectedBookTarget(previewOptions, token.id, "eq");
11264
+ const number = projected ? void 0 : collectDocumentReferenceTargets(document2).find((target) => target.kind === "eq" && target.ownerId === token.id)?.number;
11259
11265
  const island = {
11260
11266
  id: token.id,
11261
11267
  tex: mathTex(token, equationSide, previewOptions.digitForm),
@@ -11263,7 +11269,7 @@ function previewInlines(field, islands, output, equationSide, document2, preview
11263
11269
  output,
11264
11270
  editable: token.editable
11265
11271
  };
11266
- const numberLabel = number == null ? void 0 : formatBibliographyNumber(number, {
11272
+ const numberLabel = projected ? projected.ordinal : number == null ? void 0 : formatBibliographyNumber(number, {
11267
11273
  documentDirection: previewOptions.documentDirection,
11268
11274
  digitForm: previewOptions.digitForm
11269
11275
  });
@@ -11292,6 +11298,8 @@ function textBlockPreview(block, islands, output, equationSide, document2, previ
11292
11298
  };
11293
11299
  }
11294
11300
  function floatNumberLabel(document2, ownerId, previewOptions) {
11301
+ const projected = projectedBookTarget(previewOptions, ownerId, "fig") ?? projectedBookTarget(previewOptions, ownerId, "tab");
11302
+ if (projected) return projected.displayLabel;
11295
11303
  const hit = collectDocumentReferenceTargets(document2).find((target) => target.ownerId === ownerId);
11296
11304
  if (!hit || hit.number === null || hit.kind !== "fig" && hit.kind !== "tab") {
11297
11305
  return void 0;