@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-cli.js
CHANGED
|
@@ -1986,6 +1986,15 @@ var ATOMIC_COMMANDS = {
|
|
|
1986
1986
|
title: "\u0641\u0631\u0627\u063A \u0633\u0627\u0644\u0628 \u0631\u0641\u064A\u0639",
|
|
1987
1987
|
spacing: { direction: "negative", level: 1 }
|
|
1988
1988
|
},
|
|
1989
|
+
thinSpace: {
|
|
1990
|
+
id: "thinSpace",
|
|
1991
|
+
category: "spacing",
|
|
1992
|
+
englishTex: "\\,",
|
|
1993
|
+
arabicTex: "\\,",
|
|
1994
|
+
arabicLabel: "",
|
|
1995
|
+
title: "\u0641\u0631\u0627\u063A \u0631\u0641\u064A\u0639",
|
|
1996
|
+
spacing: { direction: "positive", level: 1 }
|
|
1997
|
+
},
|
|
1989
1998
|
mediumSpace: {
|
|
1990
1999
|
id: "mediumSpace",
|
|
1991
2000
|
category: "spacing",
|
|
@@ -3146,6 +3155,10 @@ function renderNodeEnglish(node, options) {
|
|
|
3146
3155
|
}
|
|
3147
3156
|
if (node.kind === "char") {
|
|
3148
3157
|
if (node.sourceLatex) {
|
|
3158
|
+
if (node.wrapperCommand === "\\boldarabic" || node.wrapperCommand === "\\mathbf") {
|
|
3159
|
+
const boldSource = node.sourceLatex.startsWith("\\mathbf{") ? node.sourceLatex : `\\mathbf{${node.sourceLatex}}`;
|
|
3160
|
+
return `${boldSource}${latinScripts(node, options)}`;
|
|
3161
|
+
}
|
|
3149
3162
|
return `${node.sourceLatex}${latinScripts(node, options)}`;
|
|
3150
3163
|
}
|
|
3151
3164
|
if (node.wrapperCommand) {
|
|
@@ -4261,20 +4274,27 @@ function editableWrapperCommand(node) {
|
|
|
4261
4274
|
return null;
|
|
4262
4275
|
}
|
|
4263
4276
|
const child = singleCommandChar(node);
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4277
|
+
let editorNode;
|
|
4278
|
+
if (child) {
|
|
4279
|
+
const normalized = normalizeCharImportExpr(child.expr);
|
|
4280
|
+
editorNode = createEditorNode("char", normalized.expr);
|
|
4281
|
+
if (normalized.characterFont !== "default") {
|
|
4282
|
+
editorNode.characterFont = normalized.characterFont;
|
|
4283
|
+
}
|
|
4284
|
+
} else {
|
|
4285
|
+
if (node.optionalArgs.length || node.mandatoryArgs.length !== 1) return null;
|
|
4286
|
+
const nodes = node.mandatoryArgs[0]?.chain;
|
|
4287
|
+
if (!nodes || nodes.length !== 1 || !(nodes[0] instanceof CommandNode)) return null;
|
|
4288
|
+
const nested = charFromTextLikeCommand(nodes[0]);
|
|
4289
|
+
if (!nested?.editable) return null;
|
|
4290
|
+
editorNode = nested.node;
|
|
4271
4291
|
}
|
|
4272
4292
|
editorNode.wrapperCommand = node.name === "\\mathtt" ? "\\mathtt" : node.name === "\\mathbf" ? "\\mathbf" : node.name === "\\boldarabic" ? "\\boldarabic" : "\\unit";
|
|
4273
4293
|
const scripts = attachScripts(node, editorNode);
|
|
4274
4294
|
if (scripts) {
|
|
4275
4295
|
return scripts;
|
|
4276
4296
|
}
|
|
4277
|
-
if (!editorNode.sourceLatex && node.name === "\\mathsf") {
|
|
4297
|
+
if (!editorNode.sourceLatex && node.name === "\\mathsf" && child) {
|
|
4278
4298
|
editorNode.sourceLatex = `\\mathsf{${child.expr}}`;
|
|
4279
4299
|
}
|
|
4280
4300
|
return { editable: true, node: editorNode };
|
|
@@ -4762,6 +4782,52 @@ function mathNodeFromEditorSession(session, mathMode = "$", closing = "$") {
|
|
|
4762
4782
|
};
|
|
4763
4783
|
}
|
|
4764
4784
|
|
|
4785
|
+
// src/document/keys.ts
|
|
4786
|
+
var DOCUMENT_KEY_PATTERN = /^[\p{L}\p{M}\p{Nd}:._-]+$/u;
|
|
4787
|
+
function normalizeDocumentKey(key) {
|
|
4788
|
+
return key.normalize("NFC").trim();
|
|
4789
|
+
}
|
|
4790
|
+
function isValidDocumentKey(key) {
|
|
4791
|
+
const normalized = normalizeDocumentKey(key);
|
|
4792
|
+
return normalized.length > 0 && DOCUMENT_KEY_PATTERN.test(normalized);
|
|
4793
|
+
}
|
|
4794
|
+
function isDuplicateDocumentKey(key, namespace) {
|
|
4795
|
+
const normalized = normalizeDocumentKey(key);
|
|
4796
|
+
if (normalized.length === 0) {
|
|
4797
|
+
return false;
|
|
4798
|
+
}
|
|
4799
|
+
for (const reference of namespace.references ?? []) {
|
|
4800
|
+
if (namespace.excludeReferenceId && reference.id === namespace.excludeReferenceId) {
|
|
4801
|
+
continue;
|
|
4802
|
+
}
|
|
4803
|
+
if (normalizeDocumentKey(reference.key) === normalized) {
|
|
4804
|
+
return true;
|
|
4805
|
+
}
|
|
4806
|
+
}
|
|
4807
|
+
for (const label of namespace.labels ?? []) {
|
|
4808
|
+
if (namespace.excludeOwnerId && label.ownerId === namespace.excludeOwnerId) {
|
|
4809
|
+
continue;
|
|
4810
|
+
}
|
|
4811
|
+
if (normalizeDocumentKey(label.key) === normalized) {
|
|
4812
|
+
return true;
|
|
4813
|
+
}
|
|
4814
|
+
}
|
|
4815
|
+
return false;
|
|
4816
|
+
}
|
|
4817
|
+
function documentKeyError(key, namespace = {}) {
|
|
4818
|
+
const normalized = normalizeDocumentKey(key);
|
|
4819
|
+
if (normalized.length === 0) {
|
|
4820
|
+
return "empty";
|
|
4821
|
+
}
|
|
4822
|
+
if (!DOCUMENT_KEY_PATTERN.test(normalized)) {
|
|
4823
|
+
return "invalid";
|
|
4824
|
+
}
|
|
4825
|
+
if (isDuplicateDocumentKey(normalized, namespace)) {
|
|
4826
|
+
return "duplicate";
|
|
4827
|
+
}
|
|
4828
|
+
return null;
|
|
4829
|
+
}
|
|
4830
|
+
|
|
4765
4831
|
// src/document/jsonCommandTypes.ts
|
|
4766
4832
|
var DocumentCommandError = class extends Error {
|
|
4767
4833
|
code;
|
|
@@ -4773,6 +4839,22 @@ var DocumentCommandError = class extends Error {
|
|
|
4773
4839
|
};
|
|
4774
4840
|
|
|
4775
4841
|
// src/document/jsonCommandHelpers.ts
|
|
4842
|
+
function normalizedNewFloatLabel(document2, label) {
|
|
4843
|
+
if (label === void 0) return void 0;
|
|
4844
|
+
const normalized = label.trim().length > 0 ? normalizeDocumentKey(label) : "";
|
|
4845
|
+
if (!normalized) return "";
|
|
4846
|
+
const error = documentKeyError(normalized, {
|
|
4847
|
+
references: document2.references,
|
|
4848
|
+
labels: collectDocumentLabels(document2)
|
|
4849
|
+
});
|
|
4850
|
+
if (error === "duplicate") {
|
|
4851
|
+
throw new DocumentCommandError("duplicate_key", "Float label is already in use");
|
|
4852
|
+
}
|
|
4853
|
+
if (error !== null) {
|
|
4854
|
+
throw new DocumentCommandError("invalid_key", "Float label is invalid");
|
|
4855
|
+
}
|
|
4856
|
+
return normalized;
|
|
4857
|
+
}
|
|
4776
4858
|
function isObject3(value) {
|
|
4777
4859
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4778
4860
|
}
|
|
@@ -5021,6 +5103,9 @@ function replacePlainField(document2, field, text) {
|
|
|
5021
5103
|
"Whole-field replacement is not supported for formatted or structured inline content"
|
|
5022
5104
|
);
|
|
5023
5105
|
}
|
|
5106
|
+
if (field.tokens.map((token) => token.kind === "text" ? token.text : "").join("") === text) {
|
|
5107
|
+
return;
|
|
5108
|
+
}
|
|
5024
5109
|
const next = createCommandInlineField(document2, text);
|
|
5025
5110
|
field.tokens = next.tokens;
|
|
5026
5111
|
}
|
|
@@ -5040,52 +5125,6 @@ function compactTextTokens2(tokens, emptyTokenId = documentId("text")) {
|
|
|
5040
5125
|
return compacted.length > 0 ? compacted : [{ id: emptyTokenId, kind: "text", text: "" }];
|
|
5041
5126
|
}
|
|
5042
5127
|
|
|
5043
|
-
// src/document/keys.ts
|
|
5044
|
-
var DOCUMENT_KEY_PATTERN = /^[\p{L}\p{M}\p{Nd}:._-]+$/u;
|
|
5045
|
-
function normalizeDocumentKey(key) {
|
|
5046
|
-
return key.normalize("NFC").trim();
|
|
5047
|
-
}
|
|
5048
|
-
function isValidDocumentKey(key) {
|
|
5049
|
-
const normalized = normalizeDocumentKey(key);
|
|
5050
|
-
return normalized.length > 0 && DOCUMENT_KEY_PATTERN.test(normalized);
|
|
5051
|
-
}
|
|
5052
|
-
function isDuplicateDocumentKey(key, namespace) {
|
|
5053
|
-
const normalized = normalizeDocumentKey(key);
|
|
5054
|
-
if (normalized.length === 0) {
|
|
5055
|
-
return false;
|
|
5056
|
-
}
|
|
5057
|
-
for (const reference of namespace.references ?? []) {
|
|
5058
|
-
if (namespace.excludeReferenceId && reference.id === namespace.excludeReferenceId) {
|
|
5059
|
-
continue;
|
|
5060
|
-
}
|
|
5061
|
-
if (normalizeDocumentKey(reference.key) === normalized) {
|
|
5062
|
-
return true;
|
|
5063
|
-
}
|
|
5064
|
-
}
|
|
5065
|
-
for (const label of namespace.labels ?? []) {
|
|
5066
|
-
if (namespace.excludeOwnerId && label.ownerId === namespace.excludeOwnerId) {
|
|
5067
|
-
continue;
|
|
5068
|
-
}
|
|
5069
|
-
if (normalizeDocumentKey(label.key) === normalized) {
|
|
5070
|
-
return true;
|
|
5071
|
-
}
|
|
5072
|
-
}
|
|
5073
|
-
return false;
|
|
5074
|
-
}
|
|
5075
|
-
function documentKeyError(key, namespace = {}) {
|
|
5076
|
-
const normalized = normalizeDocumentKey(key);
|
|
5077
|
-
if (normalized.length === 0) {
|
|
5078
|
-
return "empty";
|
|
5079
|
-
}
|
|
5080
|
-
if (!DOCUMENT_KEY_PATTERN.test(normalized)) {
|
|
5081
|
-
return "invalid";
|
|
5082
|
-
}
|
|
5083
|
-
if (isDuplicateDocumentKey(normalized, namespace)) {
|
|
5084
|
-
return "duplicate";
|
|
5085
|
-
}
|
|
5086
|
-
return null;
|
|
5087
|
-
}
|
|
5088
|
-
|
|
5089
5128
|
// src/document/articleJsonCommands.ts
|
|
5090
5129
|
var REFERENCE_TEXT_FIELDS = ["authors", "title", "year", "venue", "url"];
|
|
5091
5130
|
function hasOwn(value, field) {
|
|
@@ -5769,6 +5808,7 @@ function parseTableCommand(value) {
|
|
|
5769
5808
|
throw new DocumentCommandError("invalid_command", "Unsupported table command");
|
|
5770
5809
|
}
|
|
5771
5810
|
function insertTable(document2, command) {
|
|
5811
|
+
const label = normalizedNewFloatLabel(document2, command.label);
|
|
5772
5812
|
const block = {
|
|
5773
5813
|
id: newBlockId(document2),
|
|
5774
5814
|
kind: "table",
|
|
@@ -5777,7 +5817,7 @@ function insertTable(document2, command) {
|
|
|
5777
5817
|
columns: command.columns,
|
|
5778
5818
|
rows: command.rows.map((row) => row.map((cell) => createCommandInlineField(document2, cell))),
|
|
5779
5819
|
...defaultFloatMeta(),
|
|
5780
|
-
...
|
|
5820
|
+
...label !== void 0 ? { label, labelEnabled: label.length > 0 } : {},
|
|
5781
5821
|
...command.metadata ? { metadata: { ...command.metadata } } : {}
|
|
5782
5822
|
};
|
|
5783
5823
|
if (command.caption !== void 0) {
|
|
@@ -6291,12 +6331,12 @@ function applyBasicCommand(document2, command) {
|
|
|
6291
6331
|
if (block2.kind !== "image" && block2.kind !== "table") {
|
|
6292
6332
|
throw new DocumentCommandError("block_kind_mismatch", "Target block is not a figure or table");
|
|
6293
6333
|
}
|
|
6294
|
-
let
|
|
6295
|
-
if (
|
|
6296
|
-
|
|
6334
|
+
let label2 = command.label;
|
|
6335
|
+
if (label2 !== void 0) {
|
|
6336
|
+
label2 = label2.trim().length > 0 ? normalizeDocumentKey(label2) : "";
|
|
6297
6337
|
}
|
|
6298
|
-
if (
|
|
6299
|
-
const keyError = documentKeyError(
|
|
6338
|
+
if (label2 !== void 0 && label2.length > 0) {
|
|
6339
|
+
const keyError = documentKeyError(label2, {
|
|
6300
6340
|
references: document2.references,
|
|
6301
6341
|
labels: collectDocumentLabels(document2),
|
|
6302
6342
|
excludeOwnerId: block2.id
|
|
@@ -6313,10 +6353,11 @@ function applyBasicCommand(document2, command) {
|
|
|
6313
6353
|
...command.caption_enabled !== void 0 ? { captionEnabled: command.caption_enabled } : {},
|
|
6314
6354
|
...command.caption !== void 0 ? { caption: command.caption } : {},
|
|
6315
6355
|
...command.label_enabled !== void 0 ? { labelEnabled: command.label_enabled } : {},
|
|
6316
|
-
...
|
|
6356
|
+
...label2 !== void 0 ? { label: label2 } : {}
|
|
6317
6357
|
});
|
|
6318
6358
|
return;
|
|
6319
6359
|
}
|
|
6360
|
+
const label = normalizedNewFloatLabel(document2, command.label);
|
|
6320
6361
|
const block = {
|
|
6321
6362
|
id: newBlockId(document2),
|
|
6322
6363
|
kind: "image",
|
|
@@ -6325,7 +6366,7 @@ function applyBasicCommand(document2, command) {
|
|
|
6325
6366
|
assetId: command.asset_id,
|
|
6326
6367
|
options: { width: "0.8\\columnwidth" },
|
|
6327
6368
|
...defaultFloatMeta(),
|
|
6328
|
-
...
|
|
6369
|
+
...label !== void 0 ? { label, labelEnabled: label.length > 0 } : {},
|
|
6329
6370
|
...command.metadata ? { metadata: { ...command.metadata } } : {}
|
|
6330
6371
|
};
|
|
6331
6372
|
if (command.caption !== void 0) {
|