@drghaliasri/butex 7.1.4 → 7.2.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 -2
- package/dist/document.d.ts +1 -2
- package/dist/document.js +55 -0
- package/dist/document.js.map +1 -1
- package/dist/document.mjs +55 -0
- package/dist/document.mjs.map +1 -1
- package/dist/document2-cli.js +297 -4
- package/dist/document2-cli.js.map +1 -1
- package/dist/document2.d.mts +1 -1
- package/dist/document2.d.ts +1 -1
- package/dist/document2.js +66 -0
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs +66 -0
- package/dist/document2.mjs.map +1 -1
- package/dist/index.d.mts +129 -2
- package/dist/index.d.ts +129 -2
- package/dist/index.global.js +98 -0
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +98 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +98 -0
- package/dist/index.mjs.map +1 -1
- package/dist/react-document.js +77 -0
- package/dist/react-document.js.map +1 -1
- package/dist/react-document.mjs +77 -0
- package/dist/react-document.mjs.map +1 -1
- package/dist/react-document2-preview.js +61 -0
- package/dist/react-document2-preview.js.map +1 -1
- package/dist/react-document2-preview.mjs +61 -0
- package/dist/react-document2-preview.mjs.map +1 -1
- package/dist/react-document2.d.mts +1 -1
- package/dist/react-document2.d.ts +1 -1
- package/dist/react-document2.js +118 -0
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +118 -0
- package/dist/react-document2.mjs.map +1 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +77 -0
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +77 -0
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react.mjs
CHANGED
|
@@ -1353,6 +1353,38 @@ function atomicOperatorCommandSpec(id) {
|
|
|
1353
1353
|
return Object.prototype.hasOwnProperty.call(ATOMIC_OPERATOR_COMMANDS, id) ? ATOMIC_OPERATOR_COMMANDS[id] : null;
|
|
1354
1354
|
}
|
|
1355
1355
|
|
|
1356
|
+
// src/editor/standardCommands.ts
|
|
1357
|
+
var STANDARD_COMMANDS = {
|
|
1358
|
+
"\\alpha": { tex: "\\alpha", label: "\u03B1", title: "alpha" },
|
|
1359
|
+
"\\beta": { tex: "\\beta", label: "\u03B2", title: "beta" },
|
|
1360
|
+
"\\gamma": { tex: "\\gamma", label: "\u03B3", title: "gamma" },
|
|
1361
|
+
"\\delta": { tex: "\\delta", label: "\u03B4", title: "delta" },
|
|
1362
|
+
"\\epsilon": { tex: "\\epsilon", label: "\u03B5", title: "epsilon" },
|
|
1363
|
+
"\\eta": { tex: "\\eta", label: "\u03B7", title: "eta" },
|
|
1364
|
+
"\\theta": { tex: "\\theta", label: "\u03B8", title: "theta" },
|
|
1365
|
+
"\\lambda": { tex: "\\lambda", label: "\u03BB", title: "lambda" },
|
|
1366
|
+
"\\mu": { tex: "\\mu", label: "\u03BC", title: "mu" },
|
|
1367
|
+
"\\rho": { tex: "\\rho", label: "\u03C1", title: "rho" },
|
|
1368
|
+
"\\sigma": { tex: "\\sigma", label: "\u03C3", title: "sigma" },
|
|
1369
|
+
"\\tau": { tex: "\\tau", label: "\u03C4", title: "tau" },
|
|
1370
|
+
"\\phi": { tex: "\\phi", label: "\u03C6", title: "phi" },
|
|
1371
|
+
"\\chi": { tex: "\\chi", label: "\u03C7", title: "chi" },
|
|
1372
|
+
"\\psi": { tex: "\\psi", label: "\u03C8", title: "psi" },
|
|
1373
|
+
"\\omega": { tex: "\\omega", label: "\u03C9", title: "omega" },
|
|
1374
|
+
"\\zeta": { tex: "\\zeta", label: "\u03B6", title: "zeta" },
|
|
1375
|
+
"\\nabla": { tex: "\\nabla", label: "\u2207", title: "nabla" },
|
|
1376
|
+
"\\Delta": { tex: "\\Delta", label: "\u0394", title: "Delta" },
|
|
1377
|
+
"\\partial": { tex: "\\partial", label: "\u2202", title: "partial derivative" },
|
|
1378
|
+
"\\Longleftrightarrow": { tex: "\\Longleftrightarrow", label: "\u27FA", title: "long equivalence arrow" },
|
|
1379
|
+
"\\backslash": { tex: "\\backslash", label: "\u2216", title: "reverse solidus" }
|
|
1380
|
+
};
|
|
1381
|
+
function standardCommandSpec(tex) {
|
|
1382
|
+
return Object.prototype.hasOwnProperty.call(STANDARD_COMMANDS, tex) ? STANDARD_COMMANDS[tex] : null;
|
|
1383
|
+
}
|
|
1384
|
+
function isStandardCommandTex(tex) {
|
|
1385
|
+
return standardCommandSpec(tex) !== null;
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1356
1388
|
// src/editor/characterFonts.ts
|
|
1357
1389
|
var CHARACTER_FONT_SPECS = [
|
|
1358
1390
|
{
|
|
@@ -1605,6 +1637,9 @@ function renderNodeEnglish(node, options) {
|
|
|
1605
1637
|
const body = atomicOperatorCommandSpec(node.expr)?.Tex ?? node.expr;
|
|
1606
1638
|
return `${body}${latinScripts(node, options)}`;
|
|
1607
1639
|
}
|
|
1640
|
+
if (node.kind === "standardCommand") {
|
|
1641
|
+
return `${node.expr}${latinScripts(node, options)}`;
|
|
1642
|
+
}
|
|
1608
1643
|
if (node.kind === "char") {
|
|
1609
1644
|
return `${renderCharContent(node, options)}${latinScripts(node, options)}`;
|
|
1610
1645
|
}
|
|
@@ -1653,6 +1688,9 @@ function renderNodeArabic(node, options) {
|
|
|
1653
1688
|
const content = spec?.mirror ? `\\butexmirror{${tex}}` : tex;
|
|
1654
1689
|
return arabicScripts(node, content, options);
|
|
1655
1690
|
}
|
|
1691
|
+
if (node.kind === "standardCommand") {
|
|
1692
|
+
return arabicScripts(node, node.expr, options);
|
|
1693
|
+
}
|
|
1656
1694
|
if (node.kind === "char") {
|
|
1657
1695
|
const expr = formatDigits(node.expr, selectedDigitForm(options));
|
|
1658
1696
|
const content = renderCharContent(node, options);
|
|
@@ -5109,6 +5147,27 @@ function buildAtomicOperatorCommandNodeBody(node, side, uiLocale = "ar") {
|
|
|
5109
5147
|
return value;
|
|
5110
5148
|
}
|
|
5111
5149
|
|
|
5150
|
+
// src/editor/display/standardCommand.ts
|
|
5151
|
+
var STANDARD_COMMAND_CSS = `
|
|
5152
|
+
.standard-command {
|
|
5153
|
+
display: inline-flex;
|
|
5154
|
+
align-items: center;
|
|
5155
|
+
justify-content: center;
|
|
5156
|
+
min-width: 0.9em;
|
|
5157
|
+
font-family: "Cambria Math", "Times New Roman", serif;
|
|
5158
|
+
font-size: 1.05em;
|
|
5159
|
+
line-height: 1;
|
|
5160
|
+
}
|
|
5161
|
+
`.trim();
|
|
5162
|
+
function buildStandardCommandNodeBody(node) {
|
|
5163
|
+
const spec = standardCommandSpec(node.expr);
|
|
5164
|
+
const value = document.createElement("span");
|
|
5165
|
+
value.className = "standard-command";
|
|
5166
|
+
value.title = spec?.title ?? node.expr;
|
|
5167
|
+
value.textContent = spec?.label ?? node.expr;
|
|
5168
|
+
return value;
|
|
5169
|
+
}
|
|
5170
|
+
|
|
5112
5171
|
// src/editor/display/scripts.ts
|
|
5113
5172
|
function buildNodeScripts(node, buildChain) {
|
|
5114
5173
|
const hasScripts = Boolean(node.superscript) || Boolean(node.subscript);
|
|
@@ -5168,6 +5227,9 @@ function buildNodeBody(node, buildChain, side, digitForm = "western", uiLocale =
|
|
|
5168
5227
|
if (node.kind === "atomicOperatorCommand") {
|
|
5169
5228
|
return buildAtomicOperatorCommandNodeBody(node, side, uiLocale);
|
|
5170
5229
|
}
|
|
5230
|
+
if (node.kind === "standardCommand") {
|
|
5231
|
+
return buildStandardCommandNodeBody(node);
|
|
5232
|
+
}
|
|
5171
5233
|
return buildBaseNodeBody(node, digitForm, side);
|
|
5172
5234
|
}
|
|
5173
5235
|
|
|
@@ -5380,6 +5442,8 @@ ${MATRIX_ENV_CSS}
|
|
|
5380
5442
|
${ATOMIC_COMMAND_CSS}
|
|
5381
5443
|
|
|
5382
5444
|
${ATOMIC_OPERATOR_COMMAND_CSS}
|
|
5445
|
+
|
|
5446
|
+
${STANDARD_COMMAND_CSS}
|
|
5383
5447
|
`.trim();
|
|
5384
5448
|
function injectBuTeXEditorStyles(doc) {
|
|
5385
5449
|
const d = doc ?? (typeof document !== "undefined" ? document : void 0);
|
|
@@ -8896,6 +8960,14 @@ function commandToEditorNode(node) {
|
|
|
8896
8960
|
}
|
|
8897
8961
|
return { editable: true, node: atomicOperator };
|
|
8898
8962
|
}
|
|
8963
|
+
if (isStandardCommandTex(node.name) && node.optionalArgs.length === 0 && node.mandatoryArgs.length === 0) {
|
|
8964
|
+
const standard = createEditorNode("standardCommand", node.name);
|
|
8965
|
+
const scripts = attachScripts(node, standard);
|
|
8966
|
+
if (scripts) {
|
|
8967
|
+
return scripts;
|
|
8968
|
+
}
|
|
8969
|
+
return { editable: true, node: standard };
|
|
8970
|
+
}
|
|
8899
8971
|
const textLike = charFromTextLikeCommand(node);
|
|
8900
8972
|
if (textLike) {
|
|
8901
8973
|
return textLike;
|
|
@@ -9156,6 +9228,11 @@ function editorNodeToAstNode(node) {
|
|
|
9156
9228
|
return { ok: false, reason: `\u0631\u0645\u0632 \u0631\u064A\u0627\u0636\u064A \u063A\u064A\u0631 \u0645\u062F\u0639\u0648\u0645 \u062D\u0627\u0644\u064A\u0627: ${node.expr}` };
|
|
9157
9229
|
}
|
|
9158
9230
|
astNode = new CommandNode(tex);
|
|
9231
|
+
} else if (node.kind === "standardCommand") {
|
|
9232
|
+
if (!isStandardCommandTex(node.expr)) {
|
|
9233
|
+
return { ok: false, reason: `\u0623\u0645\u0631 \u0631\u064A\u0627\u0636\u064A \u0642\u064A\u0627\u0633\u064A \u063A\u064A\u0631 \u0645\u062F\u0639\u0648\u0645 \u062D\u0627\u0644\u064A\u0627: ${node.expr}` };
|
|
9234
|
+
}
|
|
9235
|
+
astNode = new CommandNode(node.expr);
|
|
9159
9236
|
} else if (node.kind === "env") {
|
|
9160
9237
|
return editorEnvToAstNode(node);
|
|
9161
9238
|
} else {
|