@drghaliasri/butex 5.3.1 → 5.3.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/document2.d.mts +96 -51
- package/dist/document2.d.ts +96 -51
- package/dist/document2.js +119 -10
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs +109 -10
- package/dist/document2.mjs.map +1 -1
- package/dist/react-document2.d.mts +72 -52
- package/dist/react-document2.d.ts +72 -52
- package/dist/react-document2.js +809 -279
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +764 -234
- package/dist/react-document2.mjs.map +1 -1
- package/package.json +1 -1
package/dist/document2.js
CHANGED
|
@@ -27,9 +27,11 @@ __export(document2_exports, {
|
|
|
27
27
|
BUTEX_CLOSING_HAMDALA: () => BUTEX_CLOSING_HAMDALA,
|
|
28
28
|
DEFAULT_DOCUMENT2_HISTORY_MAX_DEPTH: () => DEFAULT_DOCUMENT2_HISTORY_MAX_DEPTH,
|
|
29
29
|
DEFAULT_HIJRI_DATE: () => DEFAULT_HIJRI_DATE,
|
|
30
|
+
DEFAULT_REFERENCE_FIELD_SEPARATOR: () => DEFAULT_REFERENCE_FIELD_SEPARATOR,
|
|
30
31
|
HIJRI_MONTH_IDS: () => HIJRI_MONTH_IDS,
|
|
31
32
|
HIJRI_YEAR_MAX: () => HIJRI_YEAR_MAX,
|
|
32
33
|
HIJRI_YEAR_MIN: () => HIJRI_YEAR_MIN,
|
|
34
|
+
absoluteHttpHref: () => absoluteHttpHref,
|
|
33
35
|
addDocument2ImageBlock: () => addDocument2ImageBlock,
|
|
34
36
|
addDocument2ListBlock: () => addDocument2ListBlock,
|
|
35
37
|
addDocument2ListItem: () => addDocument2ListItem,
|
|
@@ -40,6 +42,7 @@ __export(document2_exports, {
|
|
|
40
42
|
arabicXeLatexPreambleCmd: () => arabicXeLatexPreambleCmd,
|
|
41
43
|
arabicXeLatexPreambleFont: () => arabicXeLatexPreambleFont,
|
|
42
44
|
arabicXeLatexPreamblePkg: () => arabicXeLatexPreamblePkg,
|
|
45
|
+
bibliographyEntryBody: () => bibliographyEntryBody,
|
|
43
46
|
bibliographyEntryLatex: () => bibliographyEntryLatex,
|
|
44
47
|
butexBasmalaDisplayLatex: () => butexBasmalaDisplayLatex,
|
|
45
48
|
butexBasmalaDisplayTex: () => butexBasmalaDisplayTex,
|
|
@@ -65,6 +68,7 @@ __export(document2_exports, {
|
|
|
65
68
|
document2HasTitleStack: () => document2HasTitleStack,
|
|
66
69
|
document2HistoryCanRedo: () => document2HistoryCanRedo,
|
|
67
70
|
document2HistoryCanUndo: () => document2HistoryCanUndo,
|
|
71
|
+
document2KeyError: () => document2KeyError,
|
|
68
72
|
document2Latex: () => document2Latex,
|
|
69
73
|
document2Preview: () => document2Preview,
|
|
70
74
|
emptyBlockSelection: () => emptyBlockSelection,
|
|
@@ -75,6 +79,8 @@ __export(document2_exports, {
|
|
|
75
79
|
findFirstInlineField: () => findFirstInlineField,
|
|
76
80
|
formatBibliographyNumber: () => formatBibliographyNumber,
|
|
77
81
|
formatCiteLabel: () => formatCiteLabel,
|
|
82
|
+
formatFloatCaptionPreview: () => formatFloatCaptionPreview,
|
|
83
|
+
formatFloatCaptionTitle: () => formatFloatCaptionTitle,
|
|
78
84
|
formatHijriDate: () => formatHijriDate,
|
|
79
85
|
formatRefLabel: () => formatRefLabel,
|
|
80
86
|
fromDocumentJson2: () => fromDocumentJson2,
|
|
@@ -86,6 +92,8 @@ __export(document2_exports, {
|
|
|
86
92
|
insertMathToken: () => insertMathToken,
|
|
87
93
|
insertMathTokenAtCaret: () => insertMathTokenAtCaret,
|
|
88
94
|
insertRefTokenAtCaret: () => insertRefTokenAtCaret,
|
|
95
|
+
isDuplicateDocument2Key: () => isDuplicateDocument2Key,
|
|
96
|
+
isValidDocument2Key: () => isValidDocument2Key,
|
|
89
97
|
labelNumberMap: () => labelNumberMap,
|
|
90
98
|
mathNodeFromArabicSession: () => mathNodeFromArabicSession,
|
|
91
99
|
mathNodeFromSession: () => mathNodeFromSession,
|
|
@@ -100,7 +108,9 @@ __export(document2_exports, {
|
|
|
100
108
|
moveDocument2Reference: () => moveDocument2Reference,
|
|
101
109
|
normalizeBlockSelection: () => normalizeBlockSelection,
|
|
102
110
|
normalizeDocument2HijriDate: () => normalizeDocument2HijriDate,
|
|
111
|
+
normalizeDocument2Key: () => normalizeDocument2Key,
|
|
103
112
|
normalizeDocument2Meta: () => normalizeDocument2Meta,
|
|
113
|
+
normalizeReferenceFieldSeparator: () => normalizeReferenceFieldSeparator,
|
|
104
114
|
parseCiteKeys: () => parseCiteKeys,
|
|
105
115
|
parseFloatMetaFromJson: () => parseFloatMetaFromJson,
|
|
106
116
|
parseRefKeys: () => parseRefKeys,
|
|
@@ -406,6 +416,10 @@ function cloneDocument2Meta(meta) {
|
|
|
406
416
|
}
|
|
407
417
|
|
|
408
418
|
// src/document2/citations.ts
|
|
419
|
+
var DEFAULT_REFERENCE_FIELD_SEPARATOR = "\u060C";
|
|
420
|
+
function normalizeReferenceFieldSeparator(value) {
|
|
421
|
+
return value === "," ? "," : DEFAULT_REFERENCE_FIELD_SEPARATOR;
|
|
422
|
+
}
|
|
409
423
|
function referenceNumberMap(references) {
|
|
410
424
|
const map = /* @__PURE__ */ new Map();
|
|
411
425
|
references.forEach((reference, index) => {
|
|
@@ -451,7 +465,8 @@ function referenceFromJson(json) {
|
|
|
451
465
|
title: typeof json.title === "string" ? json.title : "",
|
|
452
466
|
year: typeof json.year === "string" ? json.year : "",
|
|
453
467
|
url: typeof json.url === "string" ? json.url : "",
|
|
454
|
-
venue: typeof json.venue === "string" ? json.venue : ""
|
|
468
|
+
venue: typeof json.venue === "string" ? json.venue : "",
|
|
469
|
+
fieldSeparator: normalizeReferenceFieldSeparator(json.field_separator)
|
|
455
470
|
};
|
|
456
471
|
}
|
|
457
472
|
function createEmptyReference2(partial = {}) {
|
|
@@ -461,15 +476,33 @@ function createEmptyReference2(partial = {}) {
|
|
|
461
476
|
title: partial.title,
|
|
462
477
|
year: partial.year,
|
|
463
478
|
url: partial.url,
|
|
464
|
-
venue: partial.venue
|
|
479
|
+
venue: partial.venue,
|
|
480
|
+
field_separator: partial.field_separator
|
|
465
481
|
});
|
|
466
482
|
}
|
|
483
|
+
function bibliographyEntryBody(reference, separator = reference.fieldSeparator, options = {}) {
|
|
484
|
+
const year = options.digitForm !== void 0 ? formatDigits(reference.year, options.digitForm) : reference.year;
|
|
485
|
+
const parts = [reference.authors, reference.title, reference.venue, year].filter((part) => part.trim().length > 0);
|
|
486
|
+
return parts.join(`${separator} `);
|
|
487
|
+
}
|
|
467
488
|
function bibliographyEntryLatex(reference) {
|
|
468
|
-
const
|
|
469
|
-
const body = parts.join(", ");
|
|
489
|
+
const body = bibliographyEntryBody(reference);
|
|
470
490
|
const url = reference.url.trim().length > 0 ? ` \\url{${reference.url}}` : "";
|
|
471
491
|
return `\\bibitem{${reference.key}} ${body}${url}`.trim();
|
|
472
492
|
}
|
|
493
|
+
function absoluteHttpHref(url) {
|
|
494
|
+
const trimmed = url.trim();
|
|
495
|
+
if (trimmed.length === 0) {
|
|
496
|
+
return "";
|
|
497
|
+
}
|
|
498
|
+
if (/^[a-zA-Z][a-zA-Z0-9+.-]*:/.test(trimmed)) {
|
|
499
|
+
return trimmed;
|
|
500
|
+
}
|
|
501
|
+
if (trimmed.startsWith("//")) {
|
|
502
|
+
return `https:${trimmed}`;
|
|
503
|
+
}
|
|
504
|
+
return `https://${trimmed}`;
|
|
505
|
+
}
|
|
473
506
|
|
|
474
507
|
// src/ast/commands/index.ts
|
|
475
508
|
function renderCommandCore(context) {
|
|
@@ -954,6 +987,23 @@ function labelNumberMap(document2) {
|
|
|
954
987
|
}
|
|
955
988
|
return map;
|
|
956
989
|
}
|
|
990
|
+
function formatFloatCaptionTitle(kind, number, options = {}) {
|
|
991
|
+
const locale = options.uiLocale ?? "ar";
|
|
992
|
+
const kindWord = kind === "fig" ? locale === "ar" ? "\u0627\u0644\u0634\u0643\u0644" : "Figure" : kind === "tab" ? locale === "ar" ? "\u0627\u0644\u062C\u062F\u0648\u0644" : "Table" : locale === "ar" ? "\u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629" : "Equation";
|
|
993
|
+
const digits = formatBibliographyNumber(number, {
|
|
994
|
+
documentDirection: options.documentDirection ?? (locale === "ar" ? "rtl" : "ltr"),
|
|
995
|
+
digitForm: options.digitForm ?? (locale === "ar" ? "arabicIndic" : "western")
|
|
996
|
+
});
|
|
997
|
+
return `${kindWord} ${digits}`;
|
|
998
|
+
}
|
|
999
|
+
function formatFloatCaptionPreview(title, caption, uiLocale = "ar") {
|
|
1000
|
+
const trimmed = caption?.trim() ?? "";
|
|
1001
|
+
if (trimmed.length === 0) {
|
|
1002
|
+
return title;
|
|
1003
|
+
}
|
|
1004
|
+
const separator = uiLocale === "ar" ? ": " : ". ";
|
|
1005
|
+
return `${title}${separator}${trimmed}`;
|
|
1006
|
+
}
|
|
957
1007
|
function formatRefLabel(keys, document2, refCommand, options = {}) {
|
|
958
1008
|
const documentDirection = options.documentDirection ?? "rtl";
|
|
959
1009
|
const digitForm = options.digitForm ?? (documentDirection === "rtl" ? "arabicIndic" : "western");
|
|
@@ -1224,7 +1274,8 @@ function parseReferences(json) {
|
|
|
1224
1274
|
title: typeof entry.title === "string" ? entry.title : void 0,
|
|
1225
1275
|
year: typeof entry.year === "string" ? entry.year : void 0,
|
|
1226
1276
|
url: typeof entry.url === "string" ? entry.url : void 0,
|
|
1227
|
-
venue: typeof entry.venue === "string" ? entry.venue : void 0
|
|
1277
|
+
venue: typeof entry.venue === "string" ? entry.venue : void 0,
|
|
1278
|
+
field_separator: entry.field_separator === "," || entry.field_separator === "\u060C" ? entry.field_separator : void 0
|
|
1228
1279
|
})
|
|
1229
1280
|
);
|
|
1230
1281
|
}
|
|
@@ -4406,6 +4457,9 @@ function updateDocument2Reference(document2, referenceId, patch) {
|
|
|
4406
4457
|
if (typeof patch.venue === "string") {
|
|
4407
4458
|
reference.venue = patch.venue;
|
|
4408
4459
|
}
|
|
4460
|
+
if (patch.field_separator === "," || patch.field_separator === "\u060C") {
|
|
4461
|
+
reference.fieldSeparator = patch.field_separator;
|
|
4462
|
+
}
|
|
4409
4463
|
return next;
|
|
4410
4464
|
}
|
|
4411
4465
|
function removeDocument2Reference(document2, referenceId) {
|
|
@@ -4444,6 +4498,52 @@ function updateDocument2Meta(document2, patch) {
|
|
|
4444
4498
|
return next;
|
|
4445
4499
|
}
|
|
4446
4500
|
|
|
4501
|
+
// src/document2/keys.ts
|
|
4502
|
+
var DOCUMENT2_KEY_PATTERN = /^[\p{L}\p{M}0-9:._-]+$/u;
|
|
4503
|
+
function normalizeDocument2Key(key) {
|
|
4504
|
+
return key.normalize("NFC").trim();
|
|
4505
|
+
}
|
|
4506
|
+
function isValidDocument2Key(key) {
|
|
4507
|
+
const normalized = normalizeDocument2Key(key);
|
|
4508
|
+
return normalized.length > 0 && DOCUMENT2_KEY_PATTERN.test(normalized);
|
|
4509
|
+
}
|
|
4510
|
+
function isDuplicateDocument2Key(key, namespace) {
|
|
4511
|
+
const normalized = normalizeDocument2Key(key);
|
|
4512
|
+
if (normalized.length === 0) {
|
|
4513
|
+
return false;
|
|
4514
|
+
}
|
|
4515
|
+
for (const reference of namespace.references ?? []) {
|
|
4516
|
+
if (namespace.excludeReferenceId && reference.id === namespace.excludeReferenceId) {
|
|
4517
|
+
continue;
|
|
4518
|
+
}
|
|
4519
|
+
if (normalizeDocument2Key(reference.key) === normalized) {
|
|
4520
|
+
return true;
|
|
4521
|
+
}
|
|
4522
|
+
}
|
|
4523
|
+
for (const label of namespace.labels ?? []) {
|
|
4524
|
+
if (namespace.excludeOwnerId && label.ownerId === namespace.excludeOwnerId) {
|
|
4525
|
+
continue;
|
|
4526
|
+
}
|
|
4527
|
+
if (normalizeDocument2Key(label.key) === normalized) {
|
|
4528
|
+
return true;
|
|
4529
|
+
}
|
|
4530
|
+
}
|
|
4531
|
+
return false;
|
|
4532
|
+
}
|
|
4533
|
+
function document2KeyError(key, namespace = {}) {
|
|
4534
|
+
const normalized = normalizeDocument2Key(key);
|
|
4535
|
+
if (normalized.length === 0) {
|
|
4536
|
+
return "empty";
|
|
4537
|
+
}
|
|
4538
|
+
if (!DOCUMENT2_KEY_PATTERN.test(normalized)) {
|
|
4539
|
+
return "invalid";
|
|
4540
|
+
}
|
|
4541
|
+
if (isDuplicateDocument2Key(normalized, namespace)) {
|
|
4542
|
+
return "duplicate";
|
|
4543
|
+
}
|
|
4544
|
+
return null;
|
|
4545
|
+
}
|
|
4546
|
+
|
|
4447
4547
|
// src/document2/arabicPreamble.ts
|
|
4448
4548
|
function arabicXeLatexPreamblePkg(twocolumn = false) {
|
|
4449
4549
|
const classOptions = twocolumn ? "12pt,a4paper,notitlepage,twocolumn" : "12pt,a4paper,notitlepage";
|
|
@@ -4994,13 +5094,11 @@ function floatNumberLabel(document2, key, previewOptions) {
|
|
|
4994
5094
|
if (!hit || hit.kind !== "fig" && hit.kind !== "tab") {
|
|
4995
5095
|
return void 0;
|
|
4996
5096
|
}
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
const digits = formatBibliographyNumber(hit.number, {
|
|
5097
|
+
return formatFloatCaptionTitle(hit.kind, hit.number, {
|
|
5098
|
+
uiLocale: previewOptions.uiLocale ?? "ar",
|
|
5000
5099
|
documentDirection: previewOptions.documentDirection,
|
|
5001
5100
|
digitForm: previewOptions.digitForm
|
|
5002
5101
|
});
|
|
5003
|
-
return `${kindWord} ${digits}`;
|
|
5004
5102
|
}
|
|
5005
5103
|
function blockPreview(block, islands, output, equationSide, document2, previewOptions) {
|
|
5006
5104
|
if (block.kind === "textBlock") {
|
|
@@ -5055,7 +5153,8 @@ function blockPreview(block, islands, output, equationSide, document2, previewOp
|
|
|
5055
5153
|
title: reference.title,
|
|
5056
5154
|
year: reference.year,
|
|
5057
5155
|
url: reference.url,
|
|
5058
|
-
venue: reference.venue
|
|
5156
|
+
venue: reference.venue,
|
|
5157
|
+
fieldSeparator: reference.fieldSeparator
|
|
5059
5158
|
}))
|
|
5060
5159
|
};
|
|
5061
5160
|
}
|
|
@@ -5109,9 +5208,11 @@ function document2Preview(document2, output = "svg", equationSide = "arabic", pr
|
|
|
5109
5208
|
BUTEX_CLOSING_HAMDALA,
|
|
5110
5209
|
DEFAULT_DOCUMENT2_HISTORY_MAX_DEPTH,
|
|
5111
5210
|
DEFAULT_HIJRI_DATE,
|
|
5211
|
+
DEFAULT_REFERENCE_FIELD_SEPARATOR,
|
|
5112
5212
|
HIJRI_MONTH_IDS,
|
|
5113
5213
|
HIJRI_YEAR_MAX,
|
|
5114
5214
|
HIJRI_YEAR_MIN,
|
|
5215
|
+
absoluteHttpHref,
|
|
5115
5216
|
addDocument2ImageBlock,
|
|
5116
5217
|
addDocument2ListBlock,
|
|
5117
5218
|
addDocument2ListItem,
|
|
@@ -5122,6 +5223,7 @@ function document2Preview(document2, output = "svg", equationSide = "arabic", pr
|
|
|
5122
5223
|
arabicXeLatexPreambleCmd,
|
|
5123
5224
|
arabicXeLatexPreambleFont,
|
|
5124
5225
|
arabicXeLatexPreamblePkg,
|
|
5226
|
+
bibliographyEntryBody,
|
|
5125
5227
|
bibliographyEntryLatex,
|
|
5126
5228
|
butexBasmalaDisplayLatex,
|
|
5127
5229
|
butexBasmalaDisplayTex,
|
|
@@ -5147,6 +5249,7 @@ function document2Preview(document2, output = "svg", equationSide = "arabic", pr
|
|
|
5147
5249
|
document2HasTitleStack,
|
|
5148
5250
|
document2HistoryCanRedo,
|
|
5149
5251
|
document2HistoryCanUndo,
|
|
5252
|
+
document2KeyError,
|
|
5150
5253
|
document2Latex,
|
|
5151
5254
|
document2Preview,
|
|
5152
5255
|
emptyBlockSelection,
|
|
@@ -5157,6 +5260,8 @@ function document2Preview(document2, output = "svg", equationSide = "arabic", pr
|
|
|
5157
5260
|
findFirstInlineField,
|
|
5158
5261
|
formatBibliographyNumber,
|
|
5159
5262
|
formatCiteLabel,
|
|
5263
|
+
formatFloatCaptionPreview,
|
|
5264
|
+
formatFloatCaptionTitle,
|
|
5160
5265
|
formatHijriDate,
|
|
5161
5266
|
formatRefLabel,
|
|
5162
5267
|
fromDocumentJson2,
|
|
@@ -5168,6 +5273,8 @@ function document2Preview(document2, output = "svg", equationSide = "arabic", pr
|
|
|
5168
5273
|
insertMathToken,
|
|
5169
5274
|
insertMathTokenAtCaret,
|
|
5170
5275
|
insertRefTokenAtCaret,
|
|
5276
|
+
isDuplicateDocument2Key,
|
|
5277
|
+
isValidDocument2Key,
|
|
5171
5278
|
labelNumberMap,
|
|
5172
5279
|
mathNodeFromArabicSession,
|
|
5173
5280
|
mathNodeFromSession,
|
|
@@ -5182,7 +5289,9 @@ function document2Preview(document2, output = "svg", equationSide = "arabic", pr
|
|
|
5182
5289
|
moveDocument2Reference,
|
|
5183
5290
|
normalizeBlockSelection,
|
|
5184
5291
|
normalizeDocument2HijriDate,
|
|
5292
|
+
normalizeDocument2Key,
|
|
5185
5293
|
normalizeDocument2Meta,
|
|
5294
|
+
normalizeReferenceFieldSeparator,
|
|
5186
5295
|
parseCiteKeys,
|
|
5187
5296
|
parseFloatMetaFromJson,
|
|
5188
5297
|
parseRefKeys,
|