@drghaliasri/butex 4.0.0 → 4.1.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/README.md +1 -0
- package/dist/document.js.map +1 -1
- package/dist/document.mjs.map +1 -1
- package/dist/document2.js +120 -1
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs +120 -1
- package/dist/document2.mjs.map +1 -1
- package/dist/react-document.d.mts +1 -1
- package/dist/react-document.d.ts +1 -1
- package/dist/react-document.js +138 -1
- package/dist/react-document.js.map +1 -1
- package/dist/react-document.mjs +138 -1
- package/dist/react-document.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 +165 -1
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +165 -1
- package/dist/react-document2.mjs.map +1 -1
- package/package.json +1 -1
package/dist/react-document2.mjs
CHANGED
|
@@ -5570,7 +5570,82 @@ function createEditorRuntime(options) {
|
|
|
5570
5570
|
return api;
|
|
5571
5571
|
}
|
|
5572
5572
|
|
|
5573
|
+
// src/document/normalizeCharImport.ts
|
|
5574
|
+
var WRAPPER_SPECS = [
|
|
5575
|
+
{ prefix: "\\butexdiwanioutline", font: "diwaniOutline" },
|
|
5576
|
+
{ prefix: "\\diwanioutlineshaded", font: "diwaniOutline" },
|
|
5577
|
+
{ prefix: "\\butexdiwani", font: "diwani" },
|
|
5578
|
+
{ prefix: "\\butextakween", font: "takween" },
|
|
5579
|
+
{ prefix: "\\diwani", font: "diwani" },
|
|
5580
|
+
{ prefix: "\\takween", font: "takween" },
|
|
5581
|
+
{ prefix: "\\text" }
|
|
5582
|
+
];
|
|
5583
|
+
function readBracedArg(source, openBraceIndex) {
|
|
5584
|
+
if (source[openBraceIndex] !== "{") {
|
|
5585
|
+
return null;
|
|
5586
|
+
}
|
|
5587
|
+
let depth = 0;
|
|
5588
|
+
for (let index = openBraceIndex; index < source.length; index += 1) {
|
|
5589
|
+
const char = source[index];
|
|
5590
|
+
if (char === "{") {
|
|
5591
|
+
depth += 1;
|
|
5592
|
+
} else if (char === "}") {
|
|
5593
|
+
depth -= 1;
|
|
5594
|
+
if (depth === 0) {
|
|
5595
|
+
return { inner: source.slice(openBraceIndex + 1, index), end: index + 1 };
|
|
5596
|
+
}
|
|
5597
|
+
}
|
|
5598
|
+
}
|
|
5599
|
+
return null;
|
|
5600
|
+
}
|
|
5601
|
+
function peelWrapper(source) {
|
|
5602
|
+
for (const wrapper of WRAPPER_SPECS) {
|
|
5603
|
+
if (!source.startsWith(wrapper.prefix)) {
|
|
5604
|
+
continue;
|
|
5605
|
+
}
|
|
5606
|
+
const braced = readBracedArg(source, wrapper.prefix.length);
|
|
5607
|
+
if (!braced || braced.end !== source.length) {
|
|
5608
|
+
continue;
|
|
5609
|
+
}
|
|
5610
|
+
return { inner: braced.inner, font: wrapper.font };
|
|
5611
|
+
}
|
|
5612
|
+
return null;
|
|
5613
|
+
}
|
|
5614
|
+
function normalizeCharImportExpr(expr) {
|
|
5615
|
+
const original = expr;
|
|
5616
|
+
let current = expr;
|
|
5617
|
+
let characterFont = "default";
|
|
5618
|
+
let changed = false;
|
|
5619
|
+
while (true) {
|
|
5620
|
+
const peeled = peelWrapper(current);
|
|
5621
|
+
if (!peeled) {
|
|
5622
|
+
break;
|
|
5623
|
+
}
|
|
5624
|
+
current = peeled.inner;
|
|
5625
|
+
if (peeled.font) {
|
|
5626
|
+
characterFont = peeled.font;
|
|
5627
|
+
}
|
|
5628
|
+
changed = true;
|
|
5629
|
+
}
|
|
5630
|
+
if (!changed) {
|
|
5631
|
+
return { expr: original, characterFont: "default" };
|
|
5632
|
+
}
|
|
5633
|
+
if (current.includes("\\")) {
|
|
5634
|
+
return { expr: original, characterFont: "default" };
|
|
5635
|
+
}
|
|
5636
|
+
return { expr: current, characterFont };
|
|
5637
|
+
}
|
|
5638
|
+
|
|
5573
5639
|
// src/document/mathEditorAdapter.ts
|
|
5640
|
+
var COMMAND_FONT_MAP = {
|
|
5641
|
+
"\\text": "infer",
|
|
5642
|
+
"\\butextakween": "takween",
|
|
5643
|
+
"\\takween": "takween",
|
|
5644
|
+
"\\butexdiwani": "diwani",
|
|
5645
|
+
"\\diwani": "diwani",
|
|
5646
|
+
"\\butexdiwanioutline": "diwaniOutline",
|
|
5647
|
+
"\\diwanioutlineshaded": "diwaniOutline"
|
|
5648
|
+
};
|
|
5574
5649
|
function commandIdForTex(tex) {
|
|
5575
5650
|
for (const spec of Object.values(ATOMIC_COMMANDS)) {
|
|
5576
5651
|
const renderTex = spec.arabicRenderTex;
|
|
@@ -5682,6 +5757,42 @@ function envToEditorNode(node) {
|
|
|
5682
5757
|
const scripts = attachScripts(node, env);
|
|
5683
5758
|
return scripts ?? { editable: true, node: env };
|
|
5684
5759
|
}
|
|
5760
|
+
function charFromTextLikeCommand(node) {
|
|
5761
|
+
const commandFont = COMMAND_FONT_MAP[node.name];
|
|
5762
|
+
if (commandFont === void 0) {
|
|
5763
|
+
return null;
|
|
5764
|
+
}
|
|
5765
|
+
if (node.optionalArgs.length > 0 || node.mandatoryArgs.length !== 1) {
|
|
5766
|
+
return null;
|
|
5767
|
+
}
|
|
5768
|
+
const arg = node.mandatoryArgs[0];
|
|
5769
|
+
if (arg.chain.length !== 1) {
|
|
5770
|
+
return null;
|
|
5771
|
+
}
|
|
5772
|
+
const child = arg.chain[0];
|
|
5773
|
+
if (child instanceof CommandNode) {
|
|
5774
|
+
const nested = charFromTextLikeCommand(child);
|
|
5775
|
+
if (!nested?.editable) {
|
|
5776
|
+
return null;
|
|
5777
|
+
}
|
|
5778
|
+
if (commandFont !== "infer") {
|
|
5779
|
+
nested.node.characterFont = commandFont;
|
|
5780
|
+
}
|
|
5781
|
+
const scripts2 = attachScripts(node, nested.node);
|
|
5782
|
+
return scripts2 ?? nested;
|
|
5783
|
+
}
|
|
5784
|
+
if (!(child instanceof CharNode)) {
|
|
5785
|
+
return null;
|
|
5786
|
+
}
|
|
5787
|
+
const normalized = normalizeCharImportExpr(child.expr);
|
|
5788
|
+
const characterFont = commandFont === "infer" ? normalized.characterFont : commandFont;
|
|
5789
|
+
const editorNode = createEditorNode("char", normalized.expr);
|
|
5790
|
+
if (characterFont !== "default") {
|
|
5791
|
+
editorNode.characterFont = characterFont;
|
|
5792
|
+
}
|
|
5793
|
+
const scripts = attachScripts(node, editorNode);
|
|
5794
|
+
return scripts ?? { editable: true, node: editorNode };
|
|
5795
|
+
}
|
|
5685
5796
|
function commandToEditorNode(node) {
|
|
5686
5797
|
if (node.name === "\\frac" && node.mandatoryArgs.length >= 2) {
|
|
5687
5798
|
const frac = createFracNode();
|
|
@@ -5739,11 +5850,19 @@ function commandToEditorNode(node) {
|
|
|
5739
5850
|
}
|
|
5740
5851
|
return { editable: true, node: atomicOperator };
|
|
5741
5852
|
}
|
|
5853
|
+
const textLike = charFromTextLikeCommand(node);
|
|
5854
|
+
if (textLike) {
|
|
5855
|
+
return textLike;
|
|
5856
|
+
}
|
|
5742
5857
|
return { editable: false, reason: `\u0623\u0645\u0631 \u0631\u064A\u0627\u0636\u064A \u063A\u064A\u0631 \u0645\u062F\u0639\u0648\u0645 \u062D\u0627\u0644\u064A\u0627: ${node.name}` };
|
|
5743
5858
|
}
|
|
5744
5859
|
function astNodeToEditorNode(node) {
|
|
5745
5860
|
if (node instanceof CharNode) {
|
|
5746
|
-
const
|
|
5861
|
+
const normalized = normalizeCharImportExpr(node.expr);
|
|
5862
|
+
const editorNode = createEditorNode("char", normalized.expr);
|
|
5863
|
+
if (normalized.characterFont !== "default") {
|
|
5864
|
+
editorNode.characterFont = normalized.characterFont;
|
|
5865
|
+
}
|
|
5747
5866
|
const scripts = attachScripts(node, editorNode);
|
|
5748
5867
|
return scripts ?? { editable: true, node: editorNode };
|
|
5749
5868
|
}
|
|
@@ -10647,6 +10766,51 @@ var DOCUMENT2_WIDGET_CSS = `
|
|
|
10647
10766
|
word-break: break-word;
|
|
10648
10767
|
}
|
|
10649
10768
|
|
|
10769
|
+
.butex-document2-widget__preview h1 {
|
|
10770
|
+
font-size: 1.75rem;
|
|
10771
|
+
font-weight: 700;
|
|
10772
|
+
line-height: 1.35;
|
|
10773
|
+
margin: 0 0 14px;
|
|
10774
|
+
}
|
|
10775
|
+
|
|
10776
|
+
.butex-document2-widget__preview h2 {
|
|
10777
|
+
font-size: 1.4rem;
|
|
10778
|
+
font-weight: 600;
|
|
10779
|
+
line-height: 1.4;
|
|
10780
|
+
margin: 0 0 12px;
|
|
10781
|
+
}
|
|
10782
|
+
|
|
10783
|
+
.butex-document2-widget__preview h3 {
|
|
10784
|
+
font-size: 1.2rem;
|
|
10785
|
+
font-weight: 600;
|
|
10786
|
+
line-height: 1.45;
|
|
10787
|
+
margin: 0 0 10px;
|
|
10788
|
+
}
|
|
10789
|
+
|
|
10790
|
+
.butex-document2-widget__preview p {
|
|
10791
|
+
margin: 0 0 12px;
|
|
10792
|
+
}
|
|
10793
|
+
|
|
10794
|
+
.butex-document2-widget__preview ul,
|
|
10795
|
+
.butex-document2-widget__preview ol {
|
|
10796
|
+
margin: 0 0 12px;
|
|
10797
|
+
padding-inline-start: 24px;
|
|
10798
|
+
}
|
|
10799
|
+
|
|
10800
|
+
.butex-document2-widget__preview ul {
|
|
10801
|
+
list-style-type: disc;
|
|
10802
|
+
}
|
|
10803
|
+
|
|
10804
|
+
.butex-document2-widget__preview ol {
|
|
10805
|
+
list-style-type: decimal;
|
|
10806
|
+
}
|
|
10807
|
+
|
|
10808
|
+
.butex-document2-widget__preview img {
|
|
10809
|
+
display: block;
|
|
10810
|
+
height: auto;
|
|
10811
|
+
max-width: 100%;
|
|
10812
|
+
}
|
|
10813
|
+
|
|
10650
10814
|
.butex-document2-widget__preview table {
|
|
10651
10815
|
border-collapse: collapse;
|
|
10652
10816
|
border: 1px solid #000000;
|