@drghaliasri/butex 6.1.4 → 7.0.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 +41 -12
- package/dist/document.js +21 -4
- package/dist/document.js.map +1 -1
- package/dist/document.mjs +21 -4
- package/dist/document.mjs.map +1 -1
- package/dist/document2-cli.js +21 -4
- package/dist/document2-cli.js.map +1 -1
- package/dist/document2.d.mts +34 -2
- package/dist/document2.d.ts +34 -2
- package/dist/document2.js +343 -20
- package/dist/document2.js.map +1 -1
- package/dist/document2.mjs +334 -15
- package/dist/document2.mjs.map +1 -1
- package/dist/index.global.js +104 -6
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +104 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +104 -6
- package/dist/index.mjs.map +1 -1
- package/dist/react-document.js +2066 -599
- package/dist/react-document.js.map +1 -1
- package/dist/react-document.mjs +2064 -596
- package/dist/react-document.mjs.map +1 -1
- package/dist/react-document2.d.mts +22 -7
- package/dist/react-document2.d.ts +22 -7
- package/dist/react-document2.js +4019 -1088
- package/dist/react-document2.js.map +1 -1
- package/dist/react-document2.mjs +4000 -1068
- package/dist/react-document2.mjs.map +1 -1
- package/dist/react.d.mts +9 -2
- package/dist/react.d.ts +9 -2
- package/dist/react.js +1954 -507
- package/dist/react.js.map +1 -1
- package/dist/react.mjs +1955 -507
- package/dist/react.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1805,7 +1805,22 @@ var EQUATION_EDITOR_MESSAGES = {
|
|
|
1805
1805
|
matrixBrackets: "\u0645\u0635\u0641\u0648\u0641\u0629 \u0628\u064A\u0646 \u0645\u0639\u0642\u0648\u0641\u064A\u0646",
|
|
1806
1806
|
matrixBraces: "\u0645\u0635\u0641\u0648\u0641\u0629 \u0628\u064A\u0646 \u062D\u0627\u0635\u0631\u062A\u064A\u0646",
|
|
1807
1807
|
matrixBars: "\u0645\u0635\u0641\u0648\u0641\u0629 \u0628\u064A\u0646 \u062E\u0637\u064A\u0646",
|
|
1808
|
-
matrixDoubleBars: "\u0645\u0635\u0641\u0648\u0641\u0629 \u0628\u064A\u0646 \u062E\u0637\u064A\u0646 \u0645\u0632\u062F\u0648\u062C\u064A\u0646"
|
|
1808
|
+
matrixDoubleBars: "\u0645\u0635\u0641\u0648\u0641\u0629 \u0628\u064A\u0646 \u062E\u0637\u064A\u0646 \u0645\u0632\u062F\u0648\u062C\u064A\u0646",
|
|
1809
|
+
compactToolbar: "\u0634\u0631\u064A\u0637 \u0623\u0648\u0627\u0645\u0631 \u0627\u0644\u0645\u0639\u0627\u062F\u0644\u0629",
|
|
1810
|
+
moreActions: "\u0627\u0644\u0645\u0632\u064A\u062F",
|
|
1811
|
+
commandCategories: "\u0641\u0626\u0627\u062A \u0627\u0644\u0623\u0648\u0627\u0645\u0631",
|
|
1812
|
+
back: "\u0631\u062C\u0648\u0639",
|
|
1813
|
+
closeActions: "\u0625\u063A\u0644\u0627\u0642 \u0627\u0644\u0623\u0648\u0627\u0645\u0631",
|
|
1814
|
+
matrices: "\u0627\u0644\u0645\u0635\u0641\u0648\u0641\u0627\u062A",
|
|
1815
|
+
typography: "\u0627\u0644\u062E\u0637 \u0648\u0627\u0644\u0625\u062F\u062E\u0627\u0644",
|
|
1816
|
+
digitForms: "\u0623\u0634\u0643\u0627\u0644 \u0627\u0644\u0623\u0631\u0642\u0627\u0645",
|
|
1817
|
+
commonMatrixSizes: "\u0623\u062D\u062C\u0627\u0645 \u0634\u0627\u0626\u0639\u0629",
|
|
1818
|
+
decreaseRows: "\u062A\u0642\u0644\u064A\u0644 \u0627\u0644\u0635\u0641\u0648\u0641",
|
|
1819
|
+
increaseRows: "\u0632\u064A\u0627\u062F\u0629 \u0627\u0644\u0635\u0641\u0648\u0641",
|
|
1820
|
+
decreaseColumns: "\u062A\u0642\u0644\u064A\u0644 \u0627\u0644\u0623\u0639\u0645\u062F\u0629",
|
|
1821
|
+
increaseColumns: "\u0632\u064A\u0627\u062F\u0629 \u0627\u0644\u0623\u0639\u0645\u062F\u0629",
|
|
1822
|
+
showPreview: "\u0625\u0638\u0647\u0627\u0631 \u0627\u0644\u0645\u0639\u0627\u064A\u0646\u0629",
|
|
1823
|
+
hidePreview: "\u0625\u062E\u0641\u0627\u0621 \u0627\u0644\u0645\u0639\u0627\u064A\u0646\u0629"
|
|
1809
1824
|
},
|
|
1810
1825
|
en: {
|
|
1811
1826
|
undoRedo: "Undo and redo",
|
|
@@ -1917,7 +1932,22 @@ var EQUATION_EDITOR_MESSAGES = {
|
|
|
1917
1932
|
matrixBrackets: "Matrix in brackets",
|
|
1918
1933
|
matrixBraces: "Matrix in braces",
|
|
1919
1934
|
matrixBars: "Matrix between bars",
|
|
1920
|
-
matrixDoubleBars: "Matrix between double bars"
|
|
1935
|
+
matrixDoubleBars: "Matrix between double bars",
|
|
1936
|
+
compactToolbar: "Equation command toolbar",
|
|
1937
|
+
moreActions: "More",
|
|
1938
|
+
commandCategories: "Command categories",
|
|
1939
|
+
back: "Back",
|
|
1940
|
+
closeActions: "Close actions",
|
|
1941
|
+
matrices: "Matrices",
|
|
1942
|
+
typography: "Typography and input",
|
|
1943
|
+
digitForms: "Digit forms",
|
|
1944
|
+
commonMatrixSizes: "Common sizes",
|
|
1945
|
+
decreaseRows: "Decrease rows",
|
|
1946
|
+
increaseRows: "Increase rows",
|
|
1947
|
+
decreaseColumns: "Decrease columns",
|
|
1948
|
+
increaseColumns: "Increase columns",
|
|
1949
|
+
showPreview: "Show preview",
|
|
1950
|
+
hidePreview: "Hide preview"
|
|
1921
1951
|
}
|
|
1922
1952
|
};
|
|
1923
1953
|
function equationEditorMessages(locale) {
|
|
@@ -2729,14 +2759,20 @@ var BUTEX_EDITOR_CSS = `
|
|
|
2729
2759
|
${BUTEX_FONT_FACE_CSS}
|
|
2730
2760
|
|
|
2731
2761
|
.surface {
|
|
2762
|
+
background: var(--butex-surface-bg, linear-gradient(180deg, #ffffff 0%, #fafbfc 100%));
|
|
2732
2763
|
border: 1px solid var(--butex-border, #e2e8f0);
|
|
2733
2764
|
border-radius: 12px;
|
|
2734
|
-
min-height: 100px;
|
|
2735
|
-
padding: 8px 10px;
|
|
2736
|
-
background: var(--butex-surface-bg, linear-gradient(180deg, #ffffff 0%, #fafbfc 100%));
|
|
2737
2765
|
color: var(--butex-surface-fg, #0f172a);
|
|
2738
|
-
outline: none;
|
|
2739
2766
|
cursor: text;
|
|
2767
|
+
max-width: 100%;
|
|
2768
|
+
min-height: 100px;
|
|
2769
|
+
min-width: 0;
|
|
2770
|
+
outline: none;
|
|
2771
|
+
overflow-x: auto;
|
|
2772
|
+
overflow-y: hidden;
|
|
2773
|
+
overscroll-behavior-inline: contain;
|
|
2774
|
+
padding: 8px 10px;
|
|
2775
|
+
touch-action: pan-x pan-y;
|
|
2740
2776
|
transition: box-shadow 0.15s ease, border-color 0.15s ease;
|
|
2741
2777
|
}
|
|
2742
2778
|
|
|
@@ -2801,6 +2837,17 @@ ${CHARACTER_FONT_CSS}
|
|
|
2801
2837
|
50% { opacity: 0; }
|
|
2802
2838
|
}
|
|
2803
2839
|
|
|
2840
|
+
@media (prefers-reduced-motion: reduce) {
|
|
2841
|
+
.surface {
|
|
2842
|
+
scroll-behavior: auto;
|
|
2843
|
+
transition: none;
|
|
2844
|
+
}
|
|
2845
|
+
|
|
2846
|
+
.caret {
|
|
2847
|
+
animation: none;
|
|
2848
|
+
}
|
|
2849
|
+
}
|
|
2850
|
+
|
|
2804
2851
|
.node {
|
|
2805
2852
|
display: inline-flex;
|
|
2806
2853
|
align-items: stretch;
|
|
@@ -5876,6 +5923,42 @@ function buildNodeBody(node, buildChain, side, digitForm = "western", uiLocale =
|
|
|
5876
5923
|
}
|
|
5877
5924
|
|
|
5878
5925
|
// src/editor/runtime.ts
|
|
5926
|
+
var CARET_REVEAL_GUTTER_PX = 8;
|
|
5927
|
+
function revealCaretInSurface(surfaceEl, caretEl) {
|
|
5928
|
+
const activeTarget = caretEl ?? surfaceEl.querySelector(".caret") ?? surfaceEl.querySelector(".node.selected");
|
|
5929
|
+
if (!activeTarget) {
|
|
5930
|
+
return;
|
|
5931
|
+
}
|
|
5932
|
+
const surfaceRect = surfaceEl.getBoundingClientRect();
|
|
5933
|
+
const targetRect = activeTarget.getBoundingClientRect();
|
|
5934
|
+
if (surfaceRect.width <= 0) {
|
|
5935
|
+
return;
|
|
5936
|
+
}
|
|
5937
|
+
const gutter = Math.min(CARET_REVEAL_GUTTER_PX, surfaceRect.width / 4);
|
|
5938
|
+
const visibleLeft = surfaceRect.left + gutter;
|
|
5939
|
+
const visibleRight = surfaceRect.right - gutter;
|
|
5940
|
+
const visibleWidth = visibleRight - visibleLeft;
|
|
5941
|
+
let delta = 0;
|
|
5942
|
+
if (targetRect.width > visibleWidth) {
|
|
5943
|
+
if (targetRect.right < visibleLeft) {
|
|
5944
|
+
delta = targetRect.right - visibleLeft;
|
|
5945
|
+
} else if (targetRect.left > visibleRight) {
|
|
5946
|
+
delta = targetRect.left - visibleRight;
|
|
5947
|
+
}
|
|
5948
|
+
} else if (targetRect.left < visibleLeft) {
|
|
5949
|
+
delta = targetRect.left - visibleLeft;
|
|
5950
|
+
} else if (targetRect.right > visibleRight) {
|
|
5951
|
+
delta = targetRect.right - visibleRight;
|
|
5952
|
+
}
|
|
5953
|
+
if (delta === 0) {
|
|
5954
|
+
return;
|
|
5955
|
+
}
|
|
5956
|
+
if (typeof surfaceEl.scrollBy === "function") {
|
|
5957
|
+
surfaceEl.scrollBy({ left: delta, behavior: "auto" });
|
|
5958
|
+
} else {
|
|
5959
|
+
surfaceEl.scrollLeft += delta;
|
|
5960
|
+
}
|
|
5961
|
+
}
|
|
5879
5962
|
function createEditorRuntime(options) {
|
|
5880
5963
|
const { surfaceEl, inputEl } = options;
|
|
5881
5964
|
const buttonElements = options.buttonElements ?? {};
|
|
@@ -5893,6 +5976,16 @@ function createEditorRuntime(options) {
|
|
|
5893
5976
|
let dragChanged = false;
|
|
5894
5977
|
let composingInput = false;
|
|
5895
5978
|
let pendingCompositionText = null;
|
|
5979
|
+
let caretRevealFrame = null;
|
|
5980
|
+
function scheduleCaretReveal() {
|
|
5981
|
+
if (caretRevealFrame !== null) {
|
|
5982
|
+
cancelAnimationFrame(caretRevealFrame);
|
|
5983
|
+
}
|
|
5984
|
+
caretRevealFrame = requestAnimationFrame(() => {
|
|
5985
|
+
caretRevealFrame = null;
|
|
5986
|
+
revealCaretInSurface(surfaceEl);
|
|
5987
|
+
});
|
|
5988
|
+
}
|
|
5896
5989
|
function resetInputElement() {
|
|
5897
5990
|
if (!inputEl) {
|
|
5898
5991
|
return;
|
|
@@ -6259,6 +6352,7 @@ function createEditorRuntime(options) {
|
|
|
6259
6352
|
surfaceEl.innerHTML = "";
|
|
6260
6353
|
const activeTree = session[activeTreeKey(session.activeSide)];
|
|
6261
6354
|
surfaceEl.appendChild(buildChain(activeTree));
|
|
6355
|
+
scheduleCaretReveal();
|
|
6262
6356
|
if (initialKeyboardFocusPending) {
|
|
6263
6357
|
requestAnimationFrame(focusInput);
|
|
6264
6358
|
initialKeyboardFocusPending = false;
|
|
@@ -6574,6 +6668,10 @@ function createEditorRuntime(options) {
|
|
|
6574
6668
|
const api = {
|
|
6575
6669
|
render,
|
|
6576
6670
|
destroy: () => {
|
|
6671
|
+
if (caretRevealFrame !== null) {
|
|
6672
|
+
cancelAnimationFrame(caretRevealFrame);
|
|
6673
|
+
caretRevealFrame = null;
|
|
6674
|
+
}
|
|
6577
6675
|
surfaceEl.removeEventListener("keydown", onKeyDown);
|
|
6578
6676
|
inputEl?.removeEventListener("keydown", onKeyDown);
|
|
6579
6677
|
inputEl?.removeEventListener("beforeinput", onBeforeInput);
|