@drghaliasri/butex 8.0.0 → 8.0.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.
- package/dist/document-cli.js +103 -62
- package/dist/document-cli.js.map +1 -1
- package/dist/document.js +103 -62
- package/dist/document.js.map +1 -1
- package/dist/document.mjs +103 -62
- package/dist/document.mjs.map +1 -1
- package/dist/index.d.mts +12 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.global.js +14 -0
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +14 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +14 -0
- package/dist/index.mjs.map +1 -1
- package/dist/react-document-preview.js +28 -8
- package/dist/react-document-preview.js.map +1 -1
- package/dist/react-document-preview.mjs +28 -8
- package/dist/react-document-preview.mjs.map +1 -1
- package/dist/react-document.js +29 -8
- package/dist/react-document.js.map +1 -1
- package/dist/react-document.mjs +29 -8
- package/dist/react-document.mjs.map +1 -1
- package/dist/react.d.mts +12 -0
- package/dist/react.d.ts +12 -0
- package/dist/react.js +29 -8
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +29 -8
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/document.js
CHANGED
|
@@ -2306,6 +2306,15 @@ var ATOMIC_COMMANDS = {
|
|
|
2306
2306
|
title: "\u0641\u0631\u0627\u063A \u0633\u0627\u0644\u0628 \u0631\u0641\u064A\u0639",
|
|
2307
2307
|
spacing: { direction: "negative", level: 1 }
|
|
2308
2308
|
},
|
|
2309
|
+
thinSpace: {
|
|
2310
|
+
id: "thinSpace",
|
|
2311
|
+
category: "spacing",
|
|
2312
|
+
englishTex: "\\,",
|
|
2313
|
+
arabicTex: "\\,",
|
|
2314
|
+
arabicLabel: "",
|
|
2315
|
+
title: "\u0641\u0631\u0627\u063A \u0631\u0641\u064A\u0639",
|
|
2316
|
+
spacing: { direction: "positive", level: 1 }
|
|
2317
|
+
},
|
|
2309
2318
|
mediumSpace: {
|
|
2310
2319
|
id: "mediumSpace",
|
|
2311
2320
|
category: "spacing",
|
|
@@ -3466,6 +3475,10 @@ function renderNodeEnglish(node, options) {
|
|
|
3466
3475
|
}
|
|
3467
3476
|
if (node.kind === "char") {
|
|
3468
3477
|
if (node.sourceLatex) {
|
|
3478
|
+
if (node.wrapperCommand === "\\boldarabic" || node.wrapperCommand === "\\mathbf") {
|
|
3479
|
+
const boldSource = node.sourceLatex.startsWith("\\mathbf{") ? node.sourceLatex : `\\mathbf{${node.sourceLatex}}`;
|
|
3480
|
+
return `${boldSource}${latinScripts(node, options)}`;
|
|
3481
|
+
}
|
|
3469
3482
|
return `${node.sourceLatex}${latinScripts(node, options)}`;
|
|
3470
3483
|
}
|
|
3471
3484
|
if (node.wrapperCommand) {
|
|
@@ -4603,20 +4616,27 @@ function editableWrapperCommand(node) {
|
|
|
4603
4616
|
return null;
|
|
4604
4617
|
}
|
|
4605
4618
|
const child = singleCommandChar(node);
|
|
4606
|
-
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
|
|
4610
|
-
|
|
4611
|
-
|
|
4612
|
-
|
|
4619
|
+
let editorNode;
|
|
4620
|
+
if (child) {
|
|
4621
|
+
const normalized = normalizeCharImportExpr(child.expr);
|
|
4622
|
+
editorNode = createEditorNode("char", normalized.expr);
|
|
4623
|
+
if (normalized.characterFont !== "default") {
|
|
4624
|
+
editorNode.characterFont = normalized.characterFont;
|
|
4625
|
+
}
|
|
4626
|
+
} else {
|
|
4627
|
+
if (node.optionalArgs.length || node.mandatoryArgs.length !== 1) return null;
|
|
4628
|
+
const nodes = node.mandatoryArgs[0]?.chain;
|
|
4629
|
+
if (!nodes || nodes.length !== 1 || !(nodes[0] instanceof CommandNode)) return null;
|
|
4630
|
+
const nested = charFromTextLikeCommand(nodes[0]);
|
|
4631
|
+
if (!nested?.editable) return null;
|
|
4632
|
+
editorNode = nested.node;
|
|
4613
4633
|
}
|
|
4614
4634
|
editorNode.wrapperCommand = node.name === "\\mathtt" ? "\\mathtt" : node.name === "\\mathbf" ? "\\mathbf" : node.name === "\\boldarabic" ? "\\boldarabic" : "\\unit";
|
|
4615
4635
|
const scripts = attachScripts(node, editorNode);
|
|
4616
4636
|
if (scripts) {
|
|
4617
4637
|
return scripts;
|
|
4618
4638
|
}
|
|
4619
|
-
if (!editorNode.sourceLatex && node.name === "\\mathsf") {
|
|
4639
|
+
if (!editorNode.sourceLatex && node.name === "\\mathsf" && child) {
|
|
4620
4640
|
editorNode.sourceLatex = `\\mathsf{${child.expr}}`;
|
|
4621
4641
|
}
|
|
4622
4642
|
return { editable: true, node: editorNode };
|
|
@@ -6021,6 +6041,52 @@ function updateDocumentMeta(document2, patch) {
|
|
|
6021
6041
|
return next;
|
|
6022
6042
|
}
|
|
6023
6043
|
|
|
6044
|
+
// src/document/keys.ts
|
|
6045
|
+
var DOCUMENT_KEY_PATTERN = /^[\p{L}\p{M}\p{Nd}:._-]+$/u;
|
|
6046
|
+
function normalizeDocumentKey(key) {
|
|
6047
|
+
return key.normalize("NFC").trim();
|
|
6048
|
+
}
|
|
6049
|
+
function isValidDocumentKey(key) {
|
|
6050
|
+
const normalized = normalizeDocumentKey(key);
|
|
6051
|
+
return normalized.length > 0 && DOCUMENT_KEY_PATTERN.test(normalized);
|
|
6052
|
+
}
|
|
6053
|
+
function isDuplicateDocumentKey(key, namespace) {
|
|
6054
|
+
const normalized = normalizeDocumentKey(key);
|
|
6055
|
+
if (normalized.length === 0) {
|
|
6056
|
+
return false;
|
|
6057
|
+
}
|
|
6058
|
+
for (const reference of namespace.references ?? []) {
|
|
6059
|
+
if (namespace.excludeReferenceId && reference.id === namespace.excludeReferenceId) {
|
|
6060
|
+
continue;
|
|
6061
|
+
}
|
|
6062
|
+
if (normalizeDocumentKey(reference.key) === normalized) {
|
|
6063
|
+
return true;
|
|
6064
|
+
}
|
|
6065
|
+
}
|
|
6066
|
+
for (const label of namespace.labels ?? []) {
|
|
6067
|
+
if (namespace.excludeOwnerId && label.ownerId === namespace.excludeOwnerId) {
|
|
6068
|
+
continue;
|
|
6069
|
+
}
|
|
6070
|
+
if (normalizeDocumentKey(label.key) === normalized) {
|
|
6071
|
+
return true;
|
|
6072
|
+
}
|
|
6073
|
+
}
|
|
6074
|
+
return false;
|
|
6075
|
+
}
|
|
6076
|
+
function documentKeyError(key, namespace = {}) {
|
|
6077
|
+
const normalized = normalizeDocumentKey(key);
|
|
6078
|
+
if (normalized.length === 0) {
|
|
6079
|
+
return "empty";
|
|
6080
|
+
}
|
|
6081
|
+
if (!DOCUMENT_KEY_PATTERN.test(normalized)) {
|
|
6082
|
+
return "invalid";
|
|
6083
|
+
}
|
|
6084
|
+
if (isDuplicateDocumentKey(normalized, namespace)) {
|
|
6085
|
+
return "duplicate";
|
|
6086
|
+
}
|
|
6087
|
+
return null;
|
|
6088
|
+
}
|
|
6089
|
+
|
|
6024
6090
|
// src/document/jsonCommandTypes.ts
|
|
6025
6091
|
var DocumentCommandError = class extends Error {
|
|
6026
6092
|
code;
|
|
@@ -6032,6 +6098,22 @@ var DocumentCommandError = class extends Error {
|
|
|
6032
6098
|
};
|
|
6033
6099
|
|
|
6034
6100
|
// src/document/jsonCommandHelpers.ts
|
|
6101
|
+
function normalizedNewFloatLabel(document2, label) {
|
|
6102
|
+
if (label === void 0) return void 0;
|
|
6103
|
+
const normalized = label.trim().length > 0 ? normalizeDocumentKey(label) : "";
|
|
6104
|
+
if (!normalized) return "";
|
|
6105
|
+
const error = documentKeyError(normalized, {
|
|
6106
|
+
references: document2.references,
|
|
6107
|
+
labels: collectDocumentLabels(document2)
|
|
6108
|
+
});
|
|
6109
|
+
if (error === "duplicate") {
|
|
6110
|
+
throw new DocumentCommandError("duplicate_key", "Float label is already in use");
|
|
6111
|
+
}
|
|
6112
|
+
if (error !== null) {
|
|
6113
|
+
throw new DocumentCommandError("invalid_key", "Float label is invalid");
|
|
6114
|
+
}
|
|
6115
|
+
return normalized;
|
|
6116
|
+
}
|
|
6035
6117
|
function isObject3(value) {
|
|
6036
6118
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
6037
6119
|
}
|
|
@@ -6280,6 +6362,9 @@ function replacePlainField(document2, field, text) {
|
|
|
6280
6362
|
"Whole-field replacement is not supported for formatted or structured inline content"
|
|
6281
6363
|
);
|
|
6282
6364
|
}
|
|
6365
|
+
if (field.tokens.map((token) => token.kind === "text" ? token.text : "").join("") === text) {
|
|
6366
|
+
return;
|
|
6367
|
+
}
|
|
6283
6368
|
const next = createCommandInlineField(document2, text);
|
|
6284
6369
|
field.tokens = next.tokens;
|
|
6285
6370
|
}
|
|
@@ -6299,52 +6384,6 @@ function compactTextTokens2(tokens, emptyTokenId = documentId("text")) {
|
|
|
6299
6384
|
return compacted.length > 0 ? compacted : [{ id: emptyTokenId, kind: "text", text: "" }];
|
|
6300
6385
|
}
|
|
6301
6386
|
|
|
6302
|
-
// src/document/keys.ts
|
|
6303
|
-
var DOCUMENT_KEY_PATTERN = /^[\p{L}\p{M}\p{Nd}:._-]+$/u;
|
|
6304
|
-
function normalizeDocumentKey(key) {
|
|
6305
|
-
return key.normalize("NFC").trim();
|
|
6306
|
-
}
|
|
6307
|
-
function isValidDocumentKey(key) {
|
|
6308
|
-
const normalized = normalizeDocumentKey(key);
|
|
6309
|
-
return normalized.length > 0 && DOCUMENT_KEY_PATTERN.test(normalized);
|
|
6310
|
-
}
|
|
6311
|
-
function isDuplicateDocumentKey(key, namespace) {
|
|
6312
|
-
const normalized = normalizeDocumentKey(key);
|
|
6313
|
-
if (normalized.length === 0) {
|
|
6314
|
-
return false;
|
|
6315
|
-
}
|
|
6316
|
-
for (const reference of namespace.references ?? []) {
|
|
6317
|
-
if (namespace.excludeReferenceId && reference.id === namespace.excludeReferenceId) {
|
|
6318
|
-
continue;
|
|
6319
|
-
}
|
|
6320
|
-
if (normalizeDocumentKey(reference.key) === normalized) {
|
|
6321
|
-
return true;
|
|
6322
|
-
}
|
|
6323
|
-
}
|
|
6324
|
-
for (const label of namespace.labels ?? []) {
|
|
6325
|
-
if (namespace.excludeOwnerId && label.ownerId === namespace.excludeOwnerId) {
|
|
6326
|
-
continue;
|
|
6327
|
-
}
|
|
6328
|
-
if (normalizeDocumentKey(label.key) === normalized) {
|
|
6329
|
-
return true;
|
|
6330
|
-
}
|
|
6331
|
-
}
|
|
6332
|
-
return false;
|
|
6333
|
-
}
|
|
6334
|
-
function documentKeyError(key, namespace = {}) {
|
|
6335
|
-
const normalized = normalizeDocumentKey(key);
|
|
6336
|
-
if (normalized.length === 0) {
|
|
6337
|
-
return "empty";
|
|
6338
|
-
}
|
|
6339
|
-
if (!DOCUMENT_KEY_PATTERN.test(normalized)) {
|
|
6340
|
-
return "invalid";
|
|
6341
|
-
}
|
|
6342
|
-
if (isDuplicateDocumentKey(normalized, namespace)) {
|
|
6343
|
-
return "duplicate";
|
|
6344
|
-
}
|
|
6345
|
-
return null;
|
|
6346
|
-
}
|
|
6347
|
-
|
|
6348
6387
|
// src/document/articleJsonCommands.ts
|
|
6349
6388
|
var REFERENCE_TEXT_FIELDS = ["authors", "title", "year", "venue", "url"];
|
|
6350
6389
|
function hasOwn(value, field) {
|
|
@@ -7028,6 +7067,7 @@ function parseTableCommand(value) {
|
|
|
7028
7067
|
throw new DocumentCommandError("invalid_command", "Unsupported table command");
|
|
7029
7068
|
}
|
|
7030
7069
|
function insertTable(document2, command) {
|
|
7070
|
+
const label = normalizedNewFloatLabel(document2, command.label);
|
|
7031
7071
|
const block = {
|
|
7032
7072
|
id: newBlockId(document2),
|
|
7033
7073
|
kind: "table",
|
|
@@ -7036,7 +7076,7 @@ function insertTable(document2, command) {
|
|
|
7036
7076
|
columns: command.columns,
|
|
7037
7077
|
rows: command.rows.map((row) => row.map((cell) => createCommandInlineField(document2, cell))),
|
|
7038
7078
|
...defaultFloatMeta(),
|
|
7039
|
-
...
|
|
7079
|
+
...label !== void 0 ? { label, labelEnabled: label.length > 0 } : {},
|
|
7040
7080
|
...command.metadata ? { metadata: { ...command.metadata } } : {}
|
|
7041
7081
|
};
|
|
7042
7082
|
if (command.caption !== void 0) {
|
|
@@ -7550,12 +7590,12 @@ function applyBasicCommand(document2, command) {
|
|
|
7550
7590
|
if (block2.kind !== "image" && block2.kind !== "table") {
|
|
7551
7591
|
throw new DocumentCommandError("block_kind_mismatch", "Target block is not a figure or table");
|
|
7552
7592
|
}
|
|
7553
|
-
let
|
|
7554
|
-
if (
|
|
7555
|
-
|
|
7593
|
+
let label2 = command.label;
|
|
7594
|
+
if (label2 !== void 0) {
|
|
7595
|
+
label2 = label2.trim().length > 0 ? normalizeDocumentKey(label2) : "";
|
|
7556
7596
|
}
|
|
7557
|
-
if (
|
|
7558
|
-
const keyError = documentKeyError(
|
|
7597
|
+
if (label2 !== void 0 && label2.length > 0) {
|
|
7598
|
+
const keyError = documentKeyError(label2, {
|
|
7559
7599
|
references: document2.references,
|
|
7560
7600
|
labels: collectDocumentLabels(document2),
|
|
7561
7601
|
excludeOwnerId: block2.id
|
|
@@ -7572,10 +7612,11 @@ function applyBasicCommand(document2, command) {
|
|
|
7572
7612
|
...command.caption_enabled !== void 0 ? { captionEnabled: command.caption_enabled } : {},
|
|
7573
7613
|
...command.caption !== void 0 ? { caption: command.caption } : {},
|
|
7574
7614
|
...command.label_enabled !== void 0 ? { labelEnabled: command.label_enabled } : {},
|
|
7575
|
-
...
|
|
7615
|
+
...label2 !== void 0 ? { label: label2 } : {}
|
|
7576
7616
|
});
|
|
7577
7617
|
return;
|
|
7578
7618
|
}
|
|
7619
|
+
const label = normalizedNewFloatLabel(document2, command.label);
|
|
7579
7620
|
const block = {
|
|
7580
7621
|
id: newBlockId(document2),
|
|
7581
7622
|
kind: "image",
|
|
@@ -7584,7 +7625,7 @@ function applyBasicCommand(document2, command) {
|
|
|
7584
7625
|
assetId: command.asset_id,
|
|
7585
7626
|
options: { width: "0.8\\columnwidth" },
|
|
7586
7627
|
...defaultFloatMeta(),
|
|
7587
|
-
...
|
|
7628
|
+
...label !== void 0 ? { label, labelEnabled: label.length > 0 } : {},
|
|
7588
7629
|
...command.metadata ? { metadata: { ...command.metadata } } : {}
|
|
7589
7630
|
};
|
|
7590
7631
|
if (command.caption !== void 0) {
|