@drghaliasri/butex 8.2.1 → 8.3.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/document.d.mts +1 -0
- package/dist/document.d.ts +1 -0
- package/dist/document.js +28 -13
- package/dist/document.js.map +1 -1
- package/dist/document.mjs +28 -13
- package/dist/document.mjs.map +1 -1
- package/dist/react-book.js +38 -14
- package/dist/react-book.js.map +1 -1
- package/dist/react-book.mjs +38 -14
- package/dist/react-book.mjs.map +1 -1
- package/dist/react-document-preview.d.mts +1 -1
- package/dist/react-document-preview.d.ts +1 -1
- package/dist/react-document-preview.js +38 -14
- package/dist/react-document-preview.js.map +1 -1
- package/dist/react-document-preview.mjs +38 -14
- package/dist/react-document-preview.mjs.map +1 -1
- package/dist/react-document.d.mts +2 -1
- package/dist/react-document.d.ts +2 -1
- package/dist/react-document.js +38 -14
- package/dist/react-document.js.map +1 -1
- package/dist/react-document.mjs +38 -14
- package/dist/react-document.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react-document.mjs
CHANGED
|
@@ -11240,17 +11240,31 @@ function previewInlines(field, islands, output, equationSide, document2, preview
|
|
|
11240
11240
|
return { kind: "math", ...island, ...numberLabel ? { numberLabel } : {} };
|
|
11241
11241
|
});
|
|
11242
11242
|
}
|
|
11243
|
-
function
|
|
11243
|
+
function nextHeadingNumber(block, counters, options) {
|
|
11244
|
+
const level = block.command === "\\section" ? 1 : block.command === "\\subsection" ? 2 : 3;
|
|
11245
|
+
counters[level - 1] += 1;
|
|
11246
|
+
for (let index = level; index < counters.length; index += 1) counters[index] = 0;
|
|
11247
|
+
const kind = block.command.slice(1);
|
|
11248
|
+
const projected = options.mode === "book-content" ? options.bookContext?.targets?.find((target) => target.unitId === options.bookContext?.unitId && target.ownerId === block.id && target.kind === kind) : void 0;
|
|
11249
|
+
if (projected?.ordinal) return projected.ordinal;
|
|
11250
|
+
return counters.slice(0, level).map((number) => formatBibliographyNumber(number, {
|
|
11251
|
+
documentDirection: options.documentDirection,
|
|
11252
|
+
digitForm: options.digitForm
|
|
11253
|
+
})).join(".");
|
|
11254
|
+
}
|
|
11255
|
+
function textBlockPreview(block, islands, output, equationSide, document2, previewOptions, headingCounters) {
|
|
11244
11256
|
const inlines = previewInlines(block.field, islands, output, equationSide, document2, previewOptions);
|
|
11245
11257
|
const metadata = block.metadata ? { metadata: { ...block.metadata } } : {};
|
|
11246
|
-
if (block.command === "\\section") {
|
|
11247
|
-
|
|
11248
|
-
|
|
11249
|
-
|
|
11250
|
-
|
|
11251
|
-
|
|
11252
|
-
|
|
11253
|
-
|
|
11258
|
+
if (block.command === "\\section" || block.command === "\\subsection" || block.command === "\\subsubsection") {
|
|
11259
|
+
const level = block.command === "\\section" ? 1 : block.command === "\\subsection" ? 2 : 3;
|
|
11260
|
+
return {
|
|
11261
|
+
kind: "heading",
|
|
11262
|
+
id: block.id,
|
|
11263
|
+
level,
|
|
11264
|
+
inlines,
|
|
11265
|
+
numberLabel: nextHeadingNumber(block, headingCounters, previewOptions),
|
|
11266
|
+
...metadata
|
|
11267
|
+
};
|
|
11254
11268
|
}
|
|
11255
11269
|
return {
|
|
11256
11270
|
kind: "paragraph",
|
|
@@ -11282,9 +11296,9 @@ function captionPreview(block, islands, output, equationSide, document2, preview
|
|
|
11282
11296
|
captionInlines: previewInlines(block.captionField, islands, output, equationSide, document2, previewOptions)
|
|
11283
11297
|
};
|
|
11284
11298
|
}
|
|
11285
|
-
function blockPreview(block, islands, output, equationSide, document2, previewOptions) {
|
|
11299
|
+
function blockPreview(block, islands, output, equationSide, document2, previewOptions, headingCounters) {
|
|
11286
11300
|
if (block.kind === "textBlock") {
|
|
11287
|
-
return textBlockPreview(block, islands, output, equationSide, document2, previewOptions);
|
|
11301
|
+
return textBlockPreview(block, islands, output, equationSide, document2, previewOptions, headingCounters);
|
|
11288
11302
|
}
|
|
11289
11303
|
if (block.kind === "list") {
|
|
11290
11304
|
return {
|
|
@@ -11294,7 +11308,7 @@ function blockPreview(block, islands, output, equationSide, document2, previewOp
|
|
|
11294
11308
|
items: block.items.map((item) => ({
|
|
11295
11309
|
id: item.id,
|
|
11296
11310
|
inlines: previewInlines(item.field, islands, output, equationSide, document2, previewOptions),
|
|
11297
|
-
blocks: item.blocks.map((child) => blockPreview(child, islands, output, equationSide, document2, previewOptions))
|
|
11311
|
+
blocks: item.blocks.map((child) => blockPreview(child, islands, output, equationSide, document2, previewOptions, headingCounters))
|
|
11298
11312
|
})),
|
|
11299
11313
|
...block.metadata ? { metadata: { ...block.metadata } } : {}
|
|
11300
11314
|
};
|
|
@@ -11380,7 +11394,8 @@ function documentPreview(document2, output = "svg", equationSide = "arabic", pre
|
|
|
11380
11394
|
mode: previewOptions.mode ?? "article",
|
|
11381
11395
|
bookContext: previewOptions.bookContext
|
|
11382
11396
|
};
|
|
11383
|
-
const
|
|
11397
|
+
const headingCounters = [0, 0, 0];
|
|
11398
|
+
const body = document2.blocks.filter((block) => options.mode !== "book-content" || block.kind !== "bibliography").map((block) => blockPreview(block, mathIslands, output, equationSide, document2, options, headingCounters));
|
|
11384
11399
|
return {
|
|
11385
11400
|
blocks: [
|
|
11386
11401
|
...options.mode === "book-content" ? [] : articleChromePreview(document2, options.uiLocale ?? "ar", options),
|
|
@@ -15306,7 +15321,10 @@ function PreviewBlock({
|
|
|
15306
15321
|
}
|
|
15307
15322
|
if (block.kind === "heading") {
|
|
15308
15323
|
const Tag = block.level === 1 ? "h1" : block.level === 2 ? "h2" : "h3";
|
|
15309
|
-
return /* @__PURE__ */
|
|
15324
|
+
return /* @__PURE__ */ jsxs12(Tag, { "data-butex-block-source": source, children: [
|
|
15325
|
+
block.numberLabel ? /* @__PURE__ */ jsx13("span", { className: "butex-document-widget__preview-heading-number", dir: "auto", children: block.numberLabel }) : null,
|
|
15326
|
+
/* @__PURE__ */ jsx13(PreviewInlines, { inlines: block.inlines, output })
|
|
15327
|
+
] });
|
|
15310
15328
|
}
|
|
15311
15329
|
if (block.kind === "paragraph") {
|
|
15312
15330
|
return /* @__PURE__ */ jsx13("p", { "data-butex-block-source": source, className: block.centered ? "butex-document-widget__preview-paragraph--centered" : void 0, children: /* @__PURE__ */ jsx13(PreviewInlines, { inlines: block.inlines, output }) });
|
|
@@ -20779,6 +20797,12 @@ var DOCUMENT_WIDGET_CSS = `
|
|
|
20779
20797
|
word-break: break-word;
|
|
20780
20798
|
}
|
|
20781
20799
|
|
|
20800
|
+
.butex-document-widget__preview-heading-number {
|
|
20801
|
+
display: inline-block;
|
|
20802
|
+
margin-inline-end: 0.6em;
|
|
20803
|
+
font-variant-numeric: tabular-nums;
|
|
20804
|
+
}
|
|
20805
|
+
|
|
20782
20806
|
.butex-document-widget__preview h1 {
|
|
20783
20807
|
font-size: 1.75rem;
|
|
20784
20808
|
font-weight: 700;
|