@rufous/ui 0.3.12 → 0.3.15
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/main.cjs +1098 -479
- package/dist/main.css +356 -22
- package/dist/main.d.cts +108 -1
- package/dist/main.d.ts +108 -1
- package/dist/main.js +1174 -552
- package/package.json +1 -1
package/dist/main.js
CHANGED
|
@@ -1353,7 +1353,7 @@ IconButton.displayName = "IconButton";
|
|
|
1353
1353
|
|
|
1354
1354
|
// lib/Dialogs/BaseDialog.tsx
|
|
1355
1355
|
import * as React65 from "react";
|
|
1356
|
-
import { useState as useState2, useContext, useEffect as useEffect2 } from "react";
|
|
1356
|
+
import { useState as useState2, useContext, useEffect as useEffect2, useRef as useRef3, useCallback } from "react";
|
|
1357
1357
|
import ReactDOM from "react-dom";
|
|
1358
1358
|
import { X } from "lucide-react";
|
|
1359
1359
|
var DialogDepthContext = React65.createContext(0);
|
|
@@ -1390,6 +1390,43 @@ var BaseDialog = ({
|
|
|
1390
1390
|
const { themeConfig } = useRufousTheme();
|
|
1391
1391
|
const [isSubmitting, setIsSubmitting] = useState2(false);
|
|
1392
1392
|
const sxClass = useSx(sx);
|
|
1393
|
+
const containerRef = useRef3(null);
|
|
1394
|
+
const setContainerRef = useCallback((el) => {
|
|
1395
|
+
containerRef.current = el;
|
|
1396
|
+
}, []);
|
|
1397
|
+
useEffect2(() => {
|
|
1398
|
+
if (!open) return;
|
|
1399
|
+
const FOCUSABLE = [
|
|
1400
|
+
"button:not([disabled])",
|
|
1401
|
+
"input:not([disabled])",
|
|
1402
|
+
"select:not([disabled])",
|
|
1403
|
+
"textarea:not([disabled])",
|
|
1404
|
+
'[tabindex]:not([tabindex="-1"])',
|
|
1405
|
+
"[href]"
|
|
1406
|
+
].join(", ");
|
|
1407
|
+
const handleKeyDown = (e) => {
|
|
1408
|
+
if (e.key !== "Tab" || !containerRef.current) return;
|
|
1409
|
+
const els = Array.from(
|
|
1410
|
+
containerRef.current.querySelectorAll(FOCUSABLE)
|
|
1411
|
+
).filter((el) => !el.closest("[disabled]") && el.offsetParent !== null);
|
|
1412
|
+
if (!els.length) return;
|
|
1413
|
+
const first = els[0];
|
|
1414
|
+
const last = els[els.length - 1];
|
|
1415
|
+
if (e.shiftKey) {
|
|
1416
|
+
if (document.activeElement === first) {
|
|
1417
|
+
e.preventDefault();
|
|
1418
|
+
last.focus();
|
|
1419
|
+
}
|
|
1420
|
+
} else {
|
|
1421
|
+
if (document.activeElement === last) {
|
|
1422
|
+
e.preventDefault();
|
|
1423
|
+
first.focus();
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
};
|
|
1427
|
+
document.addEventListener("keydown", handleKeyDown);
|
|
1428
|
+
return () => document.removeEventListener("keydown", handleKeyDown);
|
|
1429
|
+
}, [open]);
|
|
1393
1430
|
const depth = useContext(DialogDepthContext);
|
|
1394
1431
|
const overlayZ = 2e3 + depth * 200;
|
|
1395
1432
|
const portalZ = overlayZ + 100;
|
|
@@ -1464,6 +1501,7 @@ var BaseDialog = ({
|
|
|
1464
1501
|
const dialogContent = form ? /* @__PURE__ */ React65.createElement(
|
|
1465
1502
|
"form",
|
|
1466
1503
|
{
|
|
1504
|
+
ref: setContainerRef,
|
|
1467
1505
|
className: containerClass,
|
|
1468
1506
|
style: containerStyle,
|
|
1469
1507
|
onSubmit: (e) => {
|
|
@@ -1472,7 +1510,15 @@ var BaseDialog = ({
|
|
|
1472
1510
|
}
|
|
1473
1511
|
},
|
|
1474
1512
|
dialogInner
|
|
1475
|
-
) : /* @__PURE__ */ React65.createElement(
|
|
1513
|
+
) : /* @__PURE__ */ React65.createElement(
|
|
1514
|
+
"div",
|
|
1515
|
+
{
|
|
1516
|
+
ref: setContainerRef,
|
|
1517
|
+
className: containerClass,
|
|
1518
|
+
style: containerStyle
|
|
1519
|
+
},
|
|
1520
|
+
dialogInner
|
|
1521
|
+
);
|
|
1476
1522
|
const overlayNode = (content) => /* @__PURE__ */ React65.createElement(
|
|
1477
1523
|
"div",
|
|
1478
1524
|
{
|
|
@@ -1787,24 +1833,24 @@ var TextField = forwardRef3(({
|
|
|
1787
1833
|
TextField.displayName = "TextField";
|
|
1788
1834
|
|
|
1789
1835
|
// lib/TextFields/AddressLookup.tsx
|
|
1790
|
-
import React71, { useState as useState6, useRef as
|
|
1836
|
+
import React71, { useState as useState6, useRef as useRef6, useEffect as useEffect6 } from "react";
|
|
1791
1837
|
import Axios from "axios";
|
|
1792
1838
|
import { Country, State, City } from "country-state-city";
|
|
1793
1839
|
|
|
1794
1840
|
// lib/TextFields/Autocomplete.tsx
|
|
1795
1841
|
import React70, {
|
|
1796
1842
|
useState as useState5,
|
|
1797
|
-
useRef as
|
|
1843
|
+
useRef as useRef5,
|
|
1798
1844
|
useEffect as useEffect5,
|
|
1799
|
-
useCallback as
|
|
1845
|
+
useCallback as useCallback3
|
|
1800
1846
|
} from "react";
|
|
1801
1847
|
import ReactDOM3 from "react-dom";
|
|
1802
1848
|
|
|
1803
1849
|
// lib/Tooltip/Tooltip.tsx
|
|
1804
1850
|
import React69, {
|
|
1805
|
-
useCallback,
|
|
1851
|
+
useCallback as useCallback2,
|
|
1806
1852
|
useEffect as useEffect4,
|
|
1807
|
-
useRef as
|
|
1853
|
+
useRef as useRef4,
|
|
1808
1854
|
useState as useState4
|
|
1809
1855
|
} from "react";
|
|
1810
1856
|
import ReactDOM2 from "react-dom";
|
|
@@ -1905,17 +1951,17 @@ var Tooltip = ({
|
|
|
1905
1951
|
const sxClass = useSx(sx);
|
|
1906
1952
|
const [internalOpen, setInternalOpen] = useState4(false);
|
|
1907
1953
|
const [position, setPosition] = useState4({ top: 0, left: 0 });
|
|
1908
|
-
const anchorRef =
|
|
1909
|
-
const tooltipRef =
|
|
1910
|
-
const enterTimer =
|
|
1911
|
-
const leaveTimer =
|
|
1912
|
-
const cursorPos =
|
|
1954
|
+
const anchorRef = useRef4(null);
|
|
1955
|
+
const tooltipRef = useRef4(null);
|
|
1956
|
+
const enterTimer = useRef4(null);
|
|
1957
|
+
const leaveTimer = useRef4(null);
|
|
1958
|
+
const cursorPos = useRef4({ x: 0, y: 0 });
|
|
1913
1959
|
const isOpen = controlledOpen !== void 0 ? controlledOpen : internalOpen;
|
|
1914
|
-
const clearTimers =
|
|
1960
|
+
const clearTimers = useCallback2(() => {
|
|
1915
1961
|
if (enterTimer.current) clearTimeout(enterTimer.current);
|
|
1916
1962
|
if (leaveTimer.current) clearTimeout(leaveTimer.current);
|
|
1917
1963
|
}, []);
|
|
1918
|
-
const updatePosition =
|
|
1964
|
+
const updatePosition = useCallback2(() => {
|
|
1919
1965
|
if (!anchorRef.current || !tooltipRef.current) return;
|
|
1920
1966
|
const anchorRect = anchorRef.current.getBoundingClientRect();
|
|
1921
1967
|
const tooltipRect = tooltipRef.current.getBoundingClientRect();
|
|
@@ -1943,7 +1989,7 @@ var Tooltip = ({
|
|
|
1943
1989
|
});
|
|
1944
1990
|
}
|
|
1945
1991
|
}, [isOpen, updatePosition]);
|
|
1946
|
-
const handleOpen =
|
|
1992
|
+
const handleOpen = useCallback2(() => {
|
|
1947
1993
|
clearTimers();
|
|
1948
1994
|
if (enterDelay > 0) {
|
|
1949
1995
|
enterTimer.current = setTimeout(() => {
|
|
@@ -1953,7 +1999,7 @@ var Tooltip = ({
|
|
|
1953
1999
|
setInternalOpen(true);
|
|
1954
2000
|
}
|
|
1955
2001
|
}, [enterDelay, clearTimers]);
|
|
1956
|
-
const handleClose =
|
|
2002
|
+
const handleClose = useCallback2(() => {
|
|
1957
2003
|
clearTimers();
|
|
1958
2004
|
if (leaveDelay > 0) {
|
|
1959
2005
|
leaveTimer.current = setTimeout(() => {
|
|
@@ -1963,7 +2009,7 @@ var Tooltip = ({
|
|
|
1963
2009
|
setInternalOpen(false);
|
|
1964
2010
|
}
|
|
1965
2011
|
}, [leaveDelay, clearTimers]);
|
|
1966
|
-
const handleMouseMove =
|
|
2012
|
+
const handleMouseMove = useCallback2(
|
|
1967
2013
|
(e) => {
|
|
1968
2014
|
cursorPos.current = { x: e.clientX, y: e.clientY };
|
|
1969
2015
|
if (isOpen && followCursor) {
|
|
@@ -2058,10 +2104,10 @@ function defaultIsEqual(a, b) {
|
|
|
2058
2104
|
if (!aIsObj && bIsObj) return a === b.value;
|
|
2059
2105
|
return false;
|
|
2060
2106
|
}
|
|
2061
|
-
function defaultFilter(options, inputValue,
|
|
2107
|
+
function defaultFilter(options, inputValue, getLabel2) {
|
|
2062
2108
|
if (!inputValue) return options;
|
|
2063
2109
|
const q = inputValue.toLowerCase();
|
|
2064
|
-
return options.filter((o) =>
|
|
2110
|
+
return options.filter((o) => getLabel2(o).toLowerCase().includes(q));
|
|
2065
2111
|
}
|
|
2066
2112
|
function AutocompleteInner(props, _ref) {
|
|
2067
2113
|
const {
|
|
@@ -2108,13 +2154,13 @@ function AutocompleteInner(props, _ref) {
|
|
|
2108
2154
|
const [filterQuery, setFilterQuery] = useState5("");
|
|
2109
2155
|
const [focusedIdx, setFocusedIdx] = useState5(-1);
|
|
2110
2156
|
const [popupStyle, setPopupStyle] = useState5({});
|
|
2111
|
-
const containerRef =
|
|
2112
|
-
const popupRef =
|
|
2113
|
-
const inputRef =
|
|
2114
|
-
const listRef =
|
|
2115
|
-
const inputId =
|
|
2157
|
+
const containerRef = useRef5(null);
|
|
2158
|
+
const popupRef = useRef5(null);
|
|
2159
|
+
const inputRef = useRef5(null);
|
|
2160
|
+
const listRef = useRef5(null);
|
|
2161
|
+
const inputId = useRef5(`rf-ac-${Math.random().toString(36).slice(2, 9)}`).current;
|
|
2116
2162
|
const sxClass = useSx(sx);
|
|
2117
|
-
const calcPopupStyle =
|
|
2163
|
+
const calcPopupStyle = useCallback3(() => {
|
|
2118
2164
|
if (!containerRef.current) return;
|
|
2119
2165
|
const rect = containerRef.current.getBoundingClientRect();
|
|
2120
2166
|
const POPUP_MAX_HEIGHT = 280;
|
|
@@ -2145,7 +2191,7 @@ function AutocompleteInner(props, _ref) {
|
|
|
2145
2191
|
}, []);
|
|
2146
2192
|
const activeInput = controlledInput !== void 0 ? controlledInput : inputStr;
|
|
2147
2193
|
const selectedValues = multiple ? Array.isArray(value) ? value : [] : value != null ? [value] : [];
|
|
2148
|
-
const isEqual =
|
|
2194
|
+
const isEqual = useCallback3(
|
|
2149
2195
|
(a, b) => {
|
|
2150
2196
|
if (isOptionEqualToValue) return isOptionEqualToValue(a, b);
|
|
2151
2197
|
if (getOptionSelected) return getOptionSelected(a, b);
|
|
@@ -2153,7 +2199,7 @@ function AutocompleteInner(props, _ref) {
|
|
|
2153
2199
|
},
|
|
2154
2200
|
[isOptionEqualToValue, getOptionSelected]
|
|
2155
2201
|
);
|
|
2156
|
-
const isSelected =
|
|
2202
|
+
const isSelected = useCallback3(
|
|
2157
2203
|
(opt) => selectedValues.some((v) => isEqual(opt, v)),
|
|
2158
2204
|
[selectedValues, isEqual]
|
|
2159
2205
|
);
|
|
@@ -2186,7 +2232,7 @@ function AutocompleteInner(props, _ref) {
|
|
|
2186
2232
|
filtered.forEach((opt, i) => flatEntries.push({ kind: "option", option: opt, flatIdx: i }));
|
|
2187
2233
|
}
|
|
2188
2234
|
const selectableOptions = flatEntries.filter((e) => e.kind === "option");
|
|
2189
|
-
const openPopup =
|
|
2235
|
+
const openPopup = useCallback3(() => {
|
|
2190
2236
|
if (disabled) return;
|
|
2191
2237
|
calcPopupStyle();
|
|
2192
2238
|
if (openProp === void 0) setInternalOpen(true);
|
|
@@ -2194,7 +2240,7 @@ function AutocompleteInner(props, _ref) {
|
|
|
2194
2240
|
setFilterQuery("");
|
|
2195
2241
|
onOpen?.();
|
|
2196
2242
|
}, [disabled, calcPopupStyle, onOpen, openProp]);
|
|
2197
|
-
const closePopup =
|
|
2243
|
+
const closePopup = useCallback3((justSelected = false) => {
|
|
2198
2244
|
if (openProp === void 0) setInternalOpen(false);
|
|
2199
2245
|
setFocusedIdx(-1);
|
|
2200
2246
|
onClose?.();
|
|
@@ -2213,11 +2259,19 @@ function AutocompleteInner(props, _ref) {
|
|
|
2213
2259
|
closePopup();
|
|
2214
2260
|
}
|
|
2215
2261
|
};
|
|
2262
|
+
const handleFocusOut = (e) => {
|
|
2263
|
+
const next = e.relatedTarget;
|
|
2264
|
+
if (!containerRef.current?.contains(next) && !popupRef.current?.contains(next)) {
|
|
2265
|
+
closePopup();
|
|
2266
|
+
}
|
|
2267
|
+
};
|
|
2216
2268
|
document.addEventListener("mousedown", handleOutside);
|
|
2269
|
+
document.addEventListener("focusout", handleFocusOut);
|
|
2217
2270
|
window.addEventListener("scroll", calcPopupStyle, true);
|
|
2218
2271
|
window.addEventListener("resize", calcPopupStyle);
|
|
2219
2272
|
return () => {
|
|
2220
2273
|
document.removeEventListener("mousedown", handleOutside);
|
|
2274
|
+
document.removeEventListener("focusout", handleFocusOut);
|
|
2221
2275
|
window.removeEventListener("scroll", calcPopupStyle, true);
|
|
2222
2276
|
window.removeEventListener("resize", calcPopupStyle);
|
|
2223
2277
|
};
|
|
@@ -2414,6 +2468,7 @@ function AutocompleteInner(props, _ref) {
|
|
|
2414
2468
|
e.preventDefault();
|
|
2415
2469
|
open ? closePopup() : openPopup();
|
|
2416
2470
|
},
|
|
2471
|
+
onClick: (e) => e.stopPropagation(),
|
|
2417
2472
|
tabIndex: -1,
|
|
2418
2473
|
"aria-label": open ? "Close" : "Open"
|
|
2419
2474
|
},
|
|
@@ -2498,8 +2553,8 @@ var AddressLookup = ({
|
|
|
2498
2553
|
const [suggestions, setSuggestions] = useState6([]);
|
|
2499
2554
|
const [loading, setLoading] = useState6(false);
|
|
2500
2555
|
const [showSuggestions, setShowSuggestions] = useState6(false);
|
|
2501
|
-
const debounceTimeout =
|
|
2502
|
-
const containerRef =
|
|
2556
|
+
const debounceTimeout = useRef6(null);
|
|
2557
|
+
const containerRef = useRef6(null);
|
|
2503
2558
|
const apiKey = token || "";
|
|
2504
2559
|
const countries = Country.getAllCountries();
|
|
2505
2560
|
const [states, setStates] = useState6([]);
|
|
@@ -2744,9 +2799,9 @@ var AddressLookup_default = AddressLookup;
|
|
|
2744
2799
|
// lib/TextFields/DateField.tsx
|
|
2745
2800
|
import React72, {
|
|
2746
2801
|
useState as useState7,
|
|
2747
|
-
useRef as
|
|
2802
|
+
useRef as useRef7,
|
|
2748
2803
|
useEffect as useEffect7,
|
|
2749
|
-
useCallback as
|
|
2804
|
+
useCallback as useCallback4
|
|
2750
2805
|
} from "react";
|
|
2751
2806
|
import { createPortal } from "react-dom";
|
|
2752
2807
|
var WEEKDAYS = ["SU", "MO", "TU", "WE", "TH", "FR", "SA"];
|
|
@@ -2926,9 +2981,9 @@ var ChevUp = () => /* @__PURE__ */ React72.createElement("svg", { width: "10", h
|
|
|
2926
2981
|
var ChevDown = () => /* @__PURE__ */ React72.createElement("svg", { width: "10", height: "7", viewBox: "0 0 10 7", fill: "currentColor" }, /* @__PURE__ */ React72.createElement("path", { d: "M5 7L0 0H10L5 7Z" }));
|
|
2927
2982
|
var ITEM_H = 36;
|
|
2928
2983
|
var ScrollColumn = ({ items, selected, onSelect, infinite = true }) => {
|
|
2929
|
-
const listRef =
|
|
2930
|
-
const isInternalScroll =
|
|
2931
|
-
const scrollTimeout =
|
|
2984
|
+
const listRef = useRef7(null);
|
|
2985
|
+
const isInternalScroll = useRef7(false);
|
|
2986
|
+
const scrollTimeout = useRef7(null);
|
|
2932
2987
|
const MULTIPLIER = infinite ? 100 : 1;
|
|
2933
2988
|
const virtualItems = infinite ? Array(MULTIPLIER).fill(items).flat() : items;
|
|
2934
2989
|
const centerOffset = infinite ? Math.floor(MULTIPLIER / 2) * items.length : 0;
|
|
@@ -3289,10 +3344,10 @@ var DateField = ({
|
|
|
3289
3344
|
const HOURS = Array.from({ length: 12 }, (_, i) => String(i + 1).padStart(2, "0"));
|
|
3290
3345
|
const MINUTES = Array.from({ length: 60 }, (_, i) => String(i).padStart(2, "0"));
|
|
3291
3346
|
const AMPMS = ["AM", "PM"];
|
|
3292
|
-
const containerRef =
|
|
3293
|
-
const pickerRef =
|
|
3294
|
-
const inputId =
|
|
3295
|
-
const isInternalChange =
|
|
3347
|
+
const containerRef = useRef7(null);
|
|
3348
|
+
const pickerRef = useRef7(null);
|
|
3349
|
+
const inputId = useRef7(`rf-df-${Math.random().toString(36).substring(2, 11)}`).current;
|
|
3350
|
+
const isInternalChange = useRef7(false);
|
|
3296
3351
|
useEffect7(() => {
|
|
3297
3352
|
if (value === void 0) return;
|
|
3298
3353
|
if (isInternalChange.current) {
|
|
@@ -3333,10 +3388,20 @@ var DateField = ({
|
|
|
3333
3388
|
if (pickerRef.current?.contains(target)) return;
|
|
3334
3389
|
setOpen(false);
|
|
3335
3390
|
};
|
|
3391
|
+
const handleFocusOut = (e) => {
|
|
3392
|
+
const next = e.relatedTarget;
|
|
3393
|
+
if (!containerRef.current?.contains(next) && !pickerRef.current?.contains(next)) {
|
|
3394
|
+
setOpen(false);
|
|
3395
|
+
}
|
|
3396
|
+
};
|
|
3336
3397
|
document.addEventListener("mousedown", handler);
|
|
3337
|
-
|
|
3398
|
+
document.addEventListener("focusout", handleFocusOut);
|
|
3399
|
+
return () => {
|
|
3400
|
+
document.removeEventListener("mousedown", handler);
|
|
3401
|
+
document.removeEventListener("focusout", handleFocusOut);
|
|
3402
|
+
};
|
|
3338
3403
|
}, [open]);
|
|
3339
|
-
const commitDate =
|
|
3404
|
+
const commitDate = useCallback4((d, h, m, ap) => {
|
|
3340
3405
|
setSelectedDate(d);
|
|
3341
3406
|
if (!d) {
|
|
3342
3407
|
setInputStr("");
|
|
@@ -3388,7 +3453,7 @@ var DateField = ({
|
|
|
3388
3453
|
if (type === "date") setOpen(false);
|
|
3389
3454
|
}
|
|
3390
3455
|
};
|
|
3391
|
-
const handleFinalMonthSelect =
|
|
3456
|
+
const handleFinalMonthSelect = useCallback4((month, year) => {
|
|
3392
3457
|
const d = new Date(year, month, 1);
|
|
3393
3458
|
if (isOutOfRange(d)) return;
|
|
3394
3459
|
setSelectedDate(d);
|
|
@@ -3398,7 +3463,7 @@ var DateField = ({
|
|
|
3398
3463
|
onChange?.(buildISO(d, type, hour, minute, ampm));
|
|
3399
3464
|
setOpen(false);
|
|
3400
3465
|
}, [isOutOfRange, onChange, type, hour, minute, ampm]);
|
|
3401
|
-
const handleFinalYearSelect =
|
|
3466
|
+
const handleFinalYearSelect = useCallback4((year) => {
|
|
3402
3467
|
const d = new Date(year, 0, 1);
|
|
3403
3468
|
if (isOutOfRange(d)) return;
|
|
3404
3469
|
setSelectedDate(d);
|
|
@@ -3711,7 +3776,7 @@ DateField.displayName = "DateField";
|
|
|
3711
3776
|
// lib/TextFields/DateRangeField.tsx
|
|
3712
3777
|
import React73, {
|
|
3713
3778
|
useState as useState8,
|
|
3714
|
-
useRef as
|
|
3779
|
+
useRef as useRef8,
|
|
3715
3780
|
useEffect as useEffect8
|
|
3716
3781
|
} from "react";
|
|
3717
3782
|
var WEEKDAYS2 = ["SU", "MO", "TU", "WE", "TH", "FR", "SA"];
|
|
@@ -4006,8 +4071,8 @@ var DateRangeField = ({
|
|
|
4006
4071
|
const [selecting, setSelecting] = useState8("start");
|
|
4007
4072
|
const [leftViewYear, setLeftViewYear] = useState8(() => today2.getFullYear());
|
|
4008
4073
|
const [leftViewMonth, setLeftViewMonth] = useState8(() => today2.getMonth());
|
|
4009
|
-
const containerRef =
|
|
4010
|
-
const inputId =
|
|
4074
|
+
const containerRef = useRef8(null);
|
|
4075
|
+
const inputId = useRef8(`rf-dr-${Math.random().toString(36).substr(2, 9)}`).current;
|
|
4011
4076
|
useEffect8(() => {
|
|
4012
4077
|
const s2 = value?.start ? isoToDate2(value.start) : null;
|
|
4013
4078
|
const e = value?.end ? isoToDate2(value.end) : null;
|
|
@@ -4389,7 +4454,7 @@ var RufousLogoLoader = ({ size = 80, sx, className }) => {
|
|
|
4389
4454
|
};
|
|
4390
4455
|
|
|
4391
4456
|
// lib/DataGrid/DataGrid.tsx
|
|
4392
|
-
import React75, { useState as useState9, useMemo as useMemo2, useRef as
|
|
4457
|
+
import React75, { useState as useState9, useMemo as useMemo2, useRef as useRef10, useEffect as useEffect9 } from "react";
|
|
4393
4458
|
import {
|
|
4394
4459
|
ChevronUp,
|
|
4395
4460
|
ChevronDown,
|
|
@@ -4408,6 +4473,37 @@ import {
|
|
|
4408
4473
|
Trash2,
|
|
4409
4474
|
Plus
|
|
4410
4475
|
} from "lucide-react";
|
|
4476
|
+
function FilterSelect({
|
|
4477
|
+
value,
|
|
4478
|
+
onChange,
|
|
4479
|
+
options,
|
|
4480
|
+
className,
|
|
4481
|
+
placement = "bottom"
|
|
4482
|
+
}) {
|
|
4483
|
+
const [open, setOpen] = useState9(false);
|
|
4484
|
+
const ref = useRef10(null);
|
|
4485
|
+
useEffect9(() => {
|
|
4486
|
+
const handler = (e) => {
|
|
4487
|
+
if (ref.current && !ref.current.contains(e.target)) setOpen(false);
|
|
4488
|
+
};
|
|
4489
|
+
if (open) document.addEventListener("mousedown", handler);
|
|
4490
|
+
return () => document.removeEventListener("mousedown", handler);
|
|
4491
|
+
}, [open]);
|
|
4492
|
+
const selected = options.find((o) => o.value === value);
|
|
4493
|
+
return /* @__PURE__ */ React75.createElement("div", { ref, className: `dg-fsel${className ? " " + className : ""}` }, /* @__PURE__ */ React75.createElement("button", { type: "button", className: "dg-fsel-trigger", onClick: () => setOpen((o) => !o) }, /* @__PURE__ */ React75.createElement("span", { className: "dg-fsel-label" }, selected?.label ?? value), /* @__PURE__ */ React75.createElement(ChevronDown, { size: 12, className: "dg-fsel-chevron" })), open && /* @__PURE__ */ React75.createElement("div", { className: `dg-fsel-menu${placement === "top" ? " dg-fsel-menu--top" : ""}` }, options.map((opt) => /* @__PURE__ */ React75.createElement(
|
|
4494
|
+
"button",
|
|
4495
|
+
{
|
|
4496
|
+
key: opt.value,
|
|
4497
|
+
type: "button",
|
|
4498
|
+
className: `dg-menu-item${opt.value === value ? " dg-menu-item--selected" : ""}`,
|
|
4499
|
+
onClick: () => {
|
|
4500
|
+
onChange(opt.value);
|
|
4501
|
+
setOpen(false);
|
|
4502
|
+
}
|
|
4503
|
+
},
|
|
4504
|
+
opt.label
|
|
4505
|
+
))));
|
|
4506
|
+
}
|
|
4411
4507
|
var getOperatorsForType = (type) => {
|
|
4412
4508
|
if (type === "date") return [
|
|
4413
4509
|
{ value: "is", label: "is" },
|
|
@@ -4524,7 +4620,7 @@ function DataGrid({
|
|
|
4524
4620
|
const [startWidth, setStartWidth] = useState9(0);
|
|
4525
4621
|
const [activeMenu, setActiveMenu] = useState9(null);
|
|
4526
4622
|
const [menuPosition, setMenuPosition] = useState9({ top: 0, left: 0 });
|
|
4527
|
-
const menuRef =
|
|
4623
|
+
const menuRef = useRef10(null);
|
|
4528
4624
|
const [showManageColumns, setShowManageColumns] = useState9(false);
|
|
4529
4625
|
const [showAdvancedFilter, setShowAdvancedFilter] = useState9(false);
|
|
4530
4626
|
const filterableColumnsProp = initialColumnsProp.filter((c) => c.filterable !== false);
|
|
@@ -4825,7 +4921,17 @@ function DataGrid({
|
|
|
4825
4921
|
}
|
|
4826
4922
|
return offset2;
|
|
4827
4923
|
};
|
|
4828
|
-
const hasActiveFilters = advancedFilters.some((f) => f.value);
|
|
4924
|
+
const hasActiveFilters = advancedFilters.some((f) => f.value || f.operator === "is empty" || f.operator === "is not empty");
|
|
4925
|
+
const closeFilterModal = () => {
|
|
4926
|
+
setAdvancedFilters((prev) => {
|
|
4927
|
+
const meaningful = prev.filter((f) => f.value || f.operator === "is empty" || f.operator === "is not empty");
|
|
4928
|
+
if (meaningful.length > 0) return meaningful;
|
|
4929
|
+
const firstCol = resolvedColumns.find((c) => c.filterable !== false);
|
|
4930
|
+
if (!firstCol) return prev;
|
|
4931
|
+
return [{ column: String(firstCol.field), operator: getDefaultOperator(firstCol.type), value: "", logic: "AND" }];
|
|
4932
|
+
});
|
|
4933
|
+
setShowAdvancedFilter(false);
|
|
4934
|
+
};
|
|
4829
4935
|
const activeMenuCol = activeMenu ? resolvedColumns.find((c) => String(c.field) === activeMenu) : null;
|
|
4830
4936
|
const alignClass = (align) => align === "center" ? "dg-slot--center" : align === "right" ? "dg-slot--right" : "dg-slot--left";
|
|
4831
4937
|
return /* @__PURE__ */ React75.createElement("div", { className: ["dg-root", sxClass, className].filter(Boolean).join(" ") }, /* @__PURE__ */ React75.createElement("div", { className: "dg-header" }, /* @__PURE__ */ React75.createElement("div", { className: "dg-header-info" }, /* @__PURE__ */ React75.createElement("h2", null, title), /* @__PURE__ */ React75.createElement("p", null, filteredData.length, " total records")), /* @__PURE__ */ React75.createElement("div", { className: "dg-header-actions" }, /* @__PURE__ */ React75.createElement("div", { className: "dg-search-wrap" }, /* @__PURE__ */ React75.createElement(Search, { size: 15 }), /* @__PURE__ */ React75.createElement(
|
|
@@ -4859,6 +4965,7 @@ function DataGrid({
|
|
|
4859
4965
|
const leftOffset = getLeftOffset(col, idx);
|
|
4860
4966
|
const rightOffset = getRightOffset(col, idx);
|
|
4861
4967
|
const isSorted = sortField === col.field;
|
|
4968
|
+
const isFiltered = advancedFilters.some((f) => f.column === colField && f.value);
|
|
4862
4969
|
return /* @__PURE__ */ React75.createElement(
|
|
4863
4970
|
"th",
|
|
4864
4971
|
{
|
|
@@ -4875,7 +4982,7 @@ function DataGrid({
|
|
|
4875
4982
|
col.headerName,
|
|
4876
4983
|
isSorted && sortDirection === "asc" && /* @__PURE__ */ React75.createElement(ChevronUp, { size: 12 }),
|
|
4877
4984
|
isSorted && sortDirection === "desc" && /* @__PURE__ */ React75.createElement(ChevronDown, { size: 12 })
|
|
4878
|
-
), /* @__PURE__ */ React75.createElement("div", { className: "dg-th-actions" }, !col.disableColumnMenu && /* @__PURE__ */ React75.createElement(
|
|
4985
|
+
), /* @__PURE__ */ React75.createElement("div", { className: `dg-th-actions${isFiltered ? " dg-th-actions--filtered" : ""}` }, isFiltered && /* @__PURE__ */ React75.createElement(Filter, { size: 11, style: { color: "var(--primary-color)" } }), !col.disableColumnMenu && /* @__PURE__ */ React75.createElement(
|
|
4879
4986
|
"button",
|
|
4880
4987
|
{
|
|
4881
4988
|
className: "dg-th-menu-btn",
|
|
@@ -4968,12 +5075,14 @@ function DataGrid({
|
|
|
4968
5075
|
action.icon
|
|
4969
5076
|
)))));
|
|
4970
5077
|
})()))))), paginatedData.length === 0 && /* @__PURE__ */ React75.createElement("div", { className: "dg-empty-state" }, /* @__PURE__ */ React75.createElement("svg", { className: "dg-empty-icon", viewBox: "0 0 200 160", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, /* @__PURE__ */ React75.createElement("rect", { x: "20", y: "30", width: "160", height: "100", rx: "8", fill: "var(--hover-color)", stroke: "var(--border-color)", strokeWidth: "1.5" }), /* @__PURE__ */ React75.createElement("rect", { x: "20", y: "30", width: "160", height: "28", rx: "8", fill: "var(--border-color)", opacity: "0.5" }), /* @__PURE__ */ React75.createElement("rect", { x: "20", y: "50", width: "160", height: "8", rx: "0", fill: "var(--border-color)", opacity: "0.5" }), /* @__PURE__ */ React75.createElement("line", { x1: "72", y1: "30", x2: "72", y2: "130", stroke: "var(--border-color)", strokeWidth: "1" }), /* @__PURE__ */ React75.createElement("line", { x1: "128", y1: "30", x2: "128", y2: "130", stroke: "var(--border-color)", strokeWidth: "1" }), /* @__PURE__ */ React75.createElement("line", { x1: "20", y1: "78", x2: "180", y2: "78", stroke: "var(--border-color)", strokeWidth: "1" }), /* @__PURE__ */ React75.createElement("line", { x1: "20", y1: "104", x2: "180", y2: "104", stroke: "var(--border-color)", strokeWidth: "1" }), /* @__PURE__ */ React75.createElement("rect", { x: "32", y: "87", width: "28", height: "6", rx: "3", fill: "var(--border-color)", opacity: "0.4" }), /* @__PURE__ */ React75.createElement("rect", { x: "84", y: "87", width: "28", height: "6", rx: "3", fill: "var(--border-color)", opacity: "0.4" }), /* @__PURE__ */ React75.createElement("rect", { x: "140", y: "87", width: "28", height: "6", rx: "3", fill: "var(--border-color)", opacity: "0.4" }), /* @__PURE__ */ React75.createElement("rect", { x: "32", y: "113", width: "20", height: "6", rx: "3", fill: "var(--border-color)", opacity: "0.3" }), /* @__PURE__ */ React75.createElement("rect", { x: "84", y: "113", width: "32", height: "6", rx: "3", fill: "var(--border-color)", opacity: "0.3" }), /* @__PURE__ */ React75.createElement("rect", { x: "140", y: "113", width: "20", height: "6", rx: "3", fill: "var(--border-color)", opacity: "0.3" }), /* @__PURE__ */ React75.createElement("circle", { cx: "148", cy: "108", r: "26", fill: "var(--surface-color)", stroke: "var(--border-color)", strokeWidth: "1.5" }), /* @__PURE__ */ React75.createElement("circle", { cx: "145", cy: "105", r: "10", stroke: "var(--text-secondary)", strokeWidth: "2.5", opacity: "0.5" }), /* @__PURE__ */ React75.createElement("line", { x1: "152", y1: "113", x2: "161", y2: "122", stroke: "var(--text-secondary)", strokeWidth: "2.5", strokeLinecap: "round", opacity: "0.5" }), /* @__PURE__ */ React75.createElement("line", { x1: "141", y1: "101", x2: "149", y2: "109", stroke: "var(--text-secondary)", strokeWidth: "2", strokeLinecap: "round", opacity: "0.5" }), /* @__PURE__ */ React75.createElement("line", { x1: "149", y1: "101", x2: "141", y2: "109", stroke: "var(--text-secondary)", strokeWidth: "2", strokeLinecap: "round", opacity: "0.5" })), /* @__PURE__ */ React75.createElement("p", { className: "dg-empty-title" }, "No data found"), /* @__PURE__ */ React75.createElement("p", { className: "dg-empty-subtitle" }, filterText || hasActiveFilters ? "Try adjusting your search or filters" : "No records to display"))), pagination && /* @__PURE__ */ React75.createElement("div", { className: "dg-pagination" }, /* @__PURE__ */ React75.createElement("div", { className: "dg-page-info" }, /* @__PURE__ */ React75.createElement("div", { className: "dg-per-page" }, /* @__PURE__ */ React75.createElement("span", null, "Rows per page:"), /* @__PURE__ */ React75.createElement(
|
|
4971
|
-
|
|
5078
|
+
FilterSelect,
|
|
4972
5079
|
{
|
|
4973
|
-
|
|
4974
|
-
|
|
4975
|
-
|
|
4976
|
-
|
|
5080
|
+
placement: "top",
|
|
5081
|
+
value: String(activePageSize),
|
|
5082
|
+
onChange: (val) => handlePageSizeChange(Number(val)),
|
|
5083
|
+
options: pageSizeOptions.map((o) => ({ value: String(o), label: String(o) })),
|
|
5084
|
+
className: "dg-fsel--sm dg-fsel--pagesize"
|
|
5085
|
+
}
|
|
4977
5086
|
)), /* @__PURE__ */ React75.createElement("span", null, (activePage - 1) * activePageSize + 1, "\u2013", Math.min(activePage * activePageSize, totalRows), " of ", totalRows)), /* @__PURE__ */ React75.createElement("div", { className: "dg-page-nav" }, /* @__PURE__ */ React75.createElement("button", { className: "dg-page-btn", disabled: activePage === 1, onClick: () => handlePageChange(activePage - 1) }, /* @__PURE__ */ React75.createElement(ChevronLeft, { size: 15 })), /* @__PURE__ */ React75.createElement("span", { className: "dg-page-fraction" }, activePage, " / ", totalPages), /* @__PURE__ */ React75.createElement("button", { className: "dg-page-btn", disabled: activePage === totalPages, onClick: () => handlePageChange(activePage + 1) }, /* @__PURE__ */ React75.createElement(ChevronRight, { size: 15 })))), activeMenu && /* @__PURE__ */ React75.createElement(
|
|
4978
5087
|
"div",
|
|
4979
5088
|
{
|
|
@@ -4993,6 +5102,16 @@ function DataGrid({
|
|
|
4993
5102
|
})(),
|
|
4994
5103
|
/* @__PURE__ */ React75.createElement("div", { className: "dg-menu-divider" }),
|
|
4995
5104
|
activeMenuCol?.filterable !== false && /* @__PURE__ */ React75.createElement("button", { className: "dg-menu-item", onClick: () => {
|
|
5105
|
+
if (activeMenuCol) {
|
|
5106
|
+
const colField = String(activeMenuCol.field);
|
|
5107
|
+
setAdvancedFilters((prev) => {
|
|
5108
|
+
const hasValues = prev.some((f) => f.value);
|
|
5109
|
+
if (!hasValues) {
|
|
5110
|
+
return [{ column: colField, operator: getDefaultOperator(activeMenuCol.type), value: "", logic: "AND" }];
|
|
5111
|
+
}
|
|
5112
|
+
return [...prev, { column: colField, operator: getDefaultOperator(activeMenuCol.type), value: "", logic: "AND" }];
|
|
5113
|
+
});
|
|
5114
|
+
}
|
|
4996
5115
|
setShowAdvancedFilter(true);
|
|
4997
5116
|
setActiveMenu(null);
|
|
4998
5117
|
} }, /* @__PURE__ */ React75.createElement(Filter, { size: 14 }), " Filter\u2026"),
|
|
@@ -5030,7 +5149,7 @@ function DataGrid({
|
|
|
5030
5149
|
}
|
|
5031
5150
|
});
|
|
5032
5151
|
setColumnOverrides(newOverrides);
|
|
5033
|
-
} }, "Hide All")))), showAdvancedFilter && /* @__PURE__ */ React75.createElement("div", { className: "dg-modal-overlay", onClick:
|
|
5152
|
+
} }, "Hide All")))), showAdvancedFilter && /* @__PURE__ */ React75.createElement("div", { className: "dg-modal-overlay", onClick: closeFilterModal }, /* @__PURE__ */ React75.createElement("div", { className: "dg-modal dg-modal-wide dg-filter-modal", onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ React75.createElement("div", { className: "dg-modal-header" }, /* @__PURE__ */ React75.createElement("h3", null, "Filters"), /* @__PURE__ */ React75.createElement("button", { className: "dg-icon-btn", onClick: closeFilterModal }, /* @__PURE__ */ React75.createElement(X2, { size: 18 }))), /* @__PURE__ */ React75.createElement("div", { className: "dg-modal-body" }, advancedFilters.map((f, idx) => /* @__PURE__ */ React75.createElement("div", { key: idx }, idx > 0 && /* @__PURE__ */ React75.createElement("div", { className: "dg-filter-logic" }, /* @__PURE__ */ React75.createElement(
|
|
5034
5153
|
"button",
|
|
5035
5154
|
{
|
|
5036
5155
|
className: `dg-logic-btn${f.logic === "AND" ? " active" : ""}`,
|
|
@@ -5045,48 +5164,45 @@ function DataGrid({
|
|
|
5045
5164
|
},
|
|
5046
5165
|
"OR"
|
|
5047
5166
|
)), /* @__PURE__ */ React75.createElement("div", { className: "dg-filter-row" }, advancedFilters.length > 1 && /* @__PURE__ */ React75.createElement("button", { className: "dg-icon-btn", onClick: () => setAdvancedFilters((p) => p.filter((_, i) => i !== idx)) }, /* @__PURE__ */ React75.createElement(X2, { size: 14 })), /* @__PURE__ */ React75.createElement(
|
|
5048
|
-
|
|
5167
|
+
FilterSelect,
|
|
5049
5168
|
{
|
|
5050
|
-
className: "dg-filter-select",
|
|
5051
5169
|
value: f.column,
|
|
5052
|
-
onChange: (
|
|
5053
|
-
const newColKey = e.target.value;
|
|
5170
|
+
onChange: (newColKey) => {
|
|
5054
5171
|
const newCol = resolvedColumns.find((c) => String(c.key) === newColKey);
|
|
5055
5172
|
const defaultOp = getDefaultOperator(newCol?.type);
|
|
5056
5173
|
setAdvancedFilters((p) => p.map((fi, i) => i === idx ? { ...fi, column: newColKey, operator: defaultOp, value: "" } : fi));
|
|
5057
|
-
}
|
|
5058
|
-
|
|
5059
|
-
|
|
5174
|
+
},
|
|
5175
|
+
options: resolvedColumns.filter((c) => c.filterable !== false).map((c) => ({ value: String(c.key), label: c.header }))
|
|
5176
|
+
}
|
|
5060
5177
|
), (() => {
|
|
5061
5178
|
const col = resolvedColumns.find((c) => String(c.key) === f.column);
|
|
5062
5179
|
const operators = getOperatorsForType(col?.type);
|
|
5063
5180
|
const hideValue = f.operator === "is empty" || f.operator === "is not empty";
|
|
5064
5181
|
return /* @__PURE__ */ React75.createElement(React75.Fragment, null, /* @__PURE__ */ React75.createElement(
|
|
5065
|
-
|
|
5182
|
+
FilterSelect,
|
|
5066
5183
|
{
|
|
5067
|
-
className: "dg-
|
|
5184
|
+
className: "dg-fsel--sm",
|
|
5068
5185
|
value: f.operator,
|
|
5069
|
-
onChange: (
|
|
5070
|
-
|
|
5071
|
-
|
|
5186
|
+
onChange: (val) => setAdvancedFilters((p) => p.map((fi, i) => i === idx ? { ...fi, operator: val, value: "" } : fi)),
|
|
5187
|
+
options: operators
|
|
5188
|
+
}
|
|
5072
5189
|
), !hideValue && col?.type === "date" && /* @__PURE__ */ React75.createElement("div", { className: "dg-filter-datefield" }, /* @__PURE__ */ React75.createElement(
|
|
5073
5190
|
DateField,
|
|
5074
5191
|
{
|
|
5075
5192
|
value: f.value,
|
|
5076
5193
|
onChange: (val) => setAdvancedFilters((p) => p.map((fi, i) => i === idx ? { ...fi, value: val } : fi)),
|
|
5077
|
-
variant: "compact"
|
|
5194
|
+
variant: "compact",
|
|
5195
|
+
fullWidth: true
|
|
5078
5196
|
}
|
|
5079
5197
|
)), !hideValue && col?.type === "status" && (() => {
|
|
5080
|
-
const
|
|
5198
|
+
const opts = col.statusOptions || [...new Set(data.map((item) => String(item[col.field || col.key || ""])))].filter((v) => v && v !== "undefined" && v !== "null").sort();
|
|
5081
5199
|
return /* @__PURE__ */ React75.createElement(
|
|
5082
|
-
|
|
5200
|
+
FilterSelect,
|
|
5083
5201
|
{
|
|
5084
|
-
className: "dg-filter-select",
|
|
5085
5202
|
value: f.value,
|
|
5086
|
-
onChange: (
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
options.map((opt) => /* @__PURE__ */ React75.createElement("option", { key: opt, value: opt }, opt))
|
|
5203
|
+
onChange: (val) => setAdvancedFilters((p) => p.map((fi, i) => i === idx ? { ...fi, value: val } : fi)),
|
|
5204
|
+
options: [{ value: "", label: "Select\u2026" }, ...opts.map((o) => ({ value: o, label: o }))]
|
|
5205
|
+
}
|
|
5090
5206
|
);
|
|
5091
5207
|
})(), !hideValue && col?.type !== "date" && col?.type !== "status" && /* @__PURE__ */ React75.createElement(
|
|
5092
5208
|
"input",
|
|
@@ -5095,6 +5211,7 @@ function DataGrid({
|
|
|
5095
5211
|
className: "dg-filter-input",
|
|
5096
5212
|
placeholder: "Value\u2026",
|
|
5097
5213
|
value: f.value,
|
|
5214
|
+
autoFocus: idx === advancedFilters.length - 1,
|
|
5098
5215
|
onChange: (e) => setAdvancedFilters((p) => p.map((fi, i) => i === idx ? { ...fi, value: e.target.value } : fi))
|
|
5099
5216
|
}
|
|
5100
5217
|
));
|
|
@@ -5124,15 +5241,15 @@ function DataGrid({
|
|
|
5124
5241
|
},
|
|
5125
5242
|
/* @__PURE__ */ React75.createElement(Trash2, { size: 14 }),
|
|
5126
5243
|
" Reset"
|
|
5127
|
-
), /* @__PURE__ */ React75.createElement("button", { className: "submit-btn", onClick:
|
|
5244
|
+
), /* @__PURE__ */ React75.createElement("button", { className: "submit-btn", onClick: closeFilterModal }, "Apply")))));
|
|
5128
5245
|
}
|
|
5129
5246
|
|
|
5130
5247
|
// lib/Select/Select.tsx
|
|
5131
5248
|
import React76, {
|
|
5132
5249
|
useState as useState10,
|
|
5133
|
-
useRef as
|
|
5250
|
+
useRef as useRef11,
|
|
5134
5251
|
useEffect as useEffect10,
|
|
5135
|
-
useCallback as
|
|
5252
|
+
useCallback as useCallback5
|
|
5136
5253
|
} from "react";
|
|
5137
5254
|
import ReactDOM4 from "react-dom";
|
|
5138
5255
|
var ChevronDownIcon2 = () => /* @__PURE__ */ React76.createElement("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.2", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ React76.createElement("polyline", { points: "6 9 12 15 18 9" }));
|
|
@@ -5163,12 +5280,12 @@ var Select = React76.forwardRef(function Select2(props, ref) {
|
|
|
5163
5280
|
const [open, setOpen] = useState10(false);
|
|
5164
5281
|
const [focusedIdx, setFocusedIdx] = useState10(-1);
|
|
5165
5282
|
const [popupStyle, setPopupStyle] = useState10({});
|
|
5166
|
-
const containerRef =
|
|
5167
|
-
const popupRef =
|
|
5168
|
-
const listRef =
|
|
5169
|
-
const inputId =
|
|
5283
|
+
const containerRef = useRef11(null);
|
|
5284
|
+
const popupRef = useRef11(null);
|
|
5285
|
+
const listRef = useRef11(null);
|
|
5286
|
+
const inputId = useRef11(`rf-sel-${Math.random().toString(36).slice(2, 9)}`).current;
|
|
5170
5287
|
const sxClass = useSx(sx);
|
|
5171
|
-
const calcPopupStyle =
|
|
5288
|
+
const calcPopupStyle = useCallback5(() => {
|
|
5172
5289
|
if (!containerRef.current) return;
|
|
5173
5290
|
const rect = containerRef.current.getBoundingClientRect();
|
|
5174
5291
|
setPopupStyle({
|
|
@@ -5179,24 +5296,24 @@ var Select = React76.forwardRef(function Select2(props, ref) {
|
|
|
5179
5296
|
}, []);
|
|
5180
5297
|
const options = normaliseOptions(rawOptions);
|
|
5181
5298
|
const selectedValues = multiple ? Array.isArray(value) ? value : value != null ? [value] : [] : value != null ? [value] : [];
|
|
5182
|
-
const isSelected =
|
|
5299
|
+
const isSelected = useCallback5(
|
|
5183
5300
|
(optValue) => selectedValues.includes(optValue),
|
|
5184
5301
|
[selectedValues]
|
|
5185
5302
|
);
|
|
5186
5303
|
const getSelectedLabels = () => options.filter((o) => selectedValues.includes(o.value)).map((o) => o.label);
|
|
5187
5304
|
const hasValue = selectedValues.length > 0;
|
|
5188
5305
|
const isFloating = Boolean(open || hasValue);
|
|
5189
|
-
const openPopup =
|
|
5306
|
+
const openPopup = useCallback5(() => {
|
|
5190
5307
|
if (disabled) return;
|
|
5191
5308
|
calcPopupStyle();
|
|
5192
5309
|
setOpen(true);
|
|
5193
5310
|
setFocusedIdx(-1);
|
|
5194
5311
|
}, [disabled, calcPopupStyle]);
|
|
5195
|
-
const closePopup =
|
|
5312
|
+
const closePopup = useCallback5(() => {
|
|
5196
5313
|
setOpen(false);
|
|
5197
5314
|
setFocusedIdx(-1);
|
|
5198
5315
|
}, []);
|
|
5199
|
-
const togglePopup =
|
|
5316
|
+
const togglePopup = useCallback5(() => {
|
|
5200
5317
|
if (open) closePopup();
|
|
5201
5318
|
else openPopup();
|
|
5202
5319
|
}, [open, openPopup, closePopup]);
|
|
@@ -5207,16 +5324,24 @@ var Select = React76.forwardRef(function Select2(props, ref) {
|
|
|
5207
5324
|
closePopup();
|
|
5208
5325
|
}
|
|
5209
5326
|
};
|
|
5327
|
+
const handleFocusOut = (e) => {
|
|
5328
|
+
const next = e.relatedTarget;
|
|
5329
|
+
if (!containerRef.current?.contains(next) && !popupRef.current?.contains(next)) {
|
|
5330
|
+
closePopup();
|
|
5331
|
+
}
|
|
5332
|
+
};
|
|
5210
5333
|
document.addEventListener("mousedown", handleOutside);
|
|
5334
|
+
document.addEventListener("focusout", handleFocusOut);
|
|
5211
5335
|
window.addEventListener("scroll", calcPopupStyle, true);
|
|
5212
5336
|
window.addEventListener("resize", calcPopupStyle);
|
|
5213
5337
|
return () => {
|
|
5214
5338
|
document.removeEventListener("mousedown", handleOutside);
|
|
5339
|
+
document.removeEventListener("focusout", handleFocusOut);
|
|
5215
5340
|
window.removeEventListener("scroll", calcPopupStyle, true);
|
|
5216
5341
|
window.removeEventListener("resize", calcPopupStyle);
|
|
5217
5342
|
};
|
|
5218
5343
|
}, [open, closePopup, calcPopupStyle]);
|
|
5219
|
-
const selectOption =
|
|
5344
|
+
const selectOption = useCallback5((opt, event) => {
|
|
5220
5345
|
if (opt.disabled) return;
|
|
5221
5346
|
if (multiple) {
|
|
5222
5347
|
const already = isSelected(opt.value);
|
|
@@ -5389,9 +5514,9 @@ Select.displayName = "Select";
|
|
|
5389
5514
|
// lib/Slider/Slider.tsx
|
|
5390
5515
|
import React77, {
|
|
5391
5516
|
useState as useState11,
|
|
5392
|
-
useRef as
|
|
5517
|
+
useRef as useRef12,
|
|
5393
5518
|
useEffect as useEffect11,
|
|
5394
|
-
useCallback as
|
|
5519
|
+
useCallback as useCallback6
|
|
5395
5520
|
} from "react";
|
|
5396
5521
|
function clamp(val, min, max) {
|
|
5397
5522
|
return Math.max(min, Math.min(max, val));
|
|
@@ -5422,8 +5547,8 @@ var Slider = React77.forwardRef(function Slider2(props, ref) {
|
|
|
5422
5547
|
sx
|
|
5423
5548
|
} = props;
|
|
5424
5549
|
const sxClass = useSx(sx);
|
|
5425
|
-
const trackRef =
|
|
5426
|
-
const draggingThumb =
|
|
5550
|
+
const trackRef = useRef12(null);
|
|
5551
|
+
const draggingThumb = useRef12(null);
|
|
5427
5552
|
const [dragging, setDragging] = useState11(null);
|
|
5428
5553
|
const isRange = range || Array.isArray(value);
|
|
5429
5554
|
const rawVal = value ?? (isRange ? [min, max] : min);
|
|
@@ -5435,7 +5560,7 @@ var Slider = React77.forwardRef(function Slider2(props, ref) {
|
|
|
5435
5560
|
computedMarks.push(...marks);
|
|
5436
5561
|
}
|
|
5437
5562
|
const hasLabelledMarks = computedMarks.some((m) => m.label);
|
|
5438
|
-
const getValueFromPointer =
|
|
5563
|
+
const getValueFromPointer = useCallback6((e) => {
|
|
5439
5564
|
const track = trackRef.current;
|
|
5440
5565
|
if (!track) return min;
|
|
5441
5566
|
const rect = track.getBoundingClientRect();
|
|
@@ -5598,7 +5723,7 @@ var Slider = React77.forwardRef(function Slider2(props, ref) {
|
|
|
5598
5723
|
Slider.displayName = "Slider";
|
|
5599
5724
|
|
|
5600
5725
|
// lib/Switch/Switch.tsx
|
|
5601
|
-
import React78, { useRef as
|
|
5726
|
+
import React78, { useRef as useRef13 } from "react";
|
|
5602
5727
|
var Switch = React78.forwardRef(function Switch2(props, ref) {
|
|
5603
5728
|
const {
|
|
5604
5729
|
checked = false,
|
|
@@ -5614,8 +5739,8 @@ var Switch = React78.forwardRef(function Switch2(props, ref) {
|
|
|
5614
5739
|
sx
|
|
5615
5740
|
} = props;
|
|
5616
5741
|
const sxClass = useSx(sx);
|
|
5617
|
-
const inputRef =
|
|
5618
|
-
const inputId =
|
|
5742
|
+
const inputRef = useRef13(null);
|
|
5743
|
+
const inputId = useRef13(`rf-sw-${Math.random().toString(36).slice(2, 9)}`).current;
|
|
5619
5744
|
const handleChange = (e) => {
|
|
5620
5745
|
if (!disabled) onChange?.(e, e.target.checked);
|
|
5621
5746
|
};
|
|
@@ -5659,7 +5784,7 @@ var Switch = React78.forwardRef(function Switch2(props, ref) {
|
|
|
5659
5784
|
Switch.displayName = "Switch";
|
|
5660
5785
|
|
|
5661
5786
|
// lib/RadioGroup/RadioGroup.tsx
|
|
5662
|
-
import React79, { useRef as
|
|
5787
|
+
import React79, { useRef as useRef14, createContext as createContext3, useContext as useContext3 } from "react";
|
|
5663
5788
|
var RadioGroupContext = createContext3({});
|
|
5664
5789
|
var Radio = React79.forwardRef(function Radio2(props, ref) {
|
|
5665
5790
|
const ctx = useContext3(RadioGroupContext);
|
|
@@ -5674,7 +5799,7 @@ var Radio = React79.forwardRef(function Radio2(props, ref) {
|
|
|
5674
5799
|
sx
|
|
5675
5800
|
} = props;
|
|
5676
5801
|
const sxClass = useSx(sx);
|
|
5677
|
-
const inputId =
|
|
5802
|
+
const inputId = useRef14(`rf-radio-${Math.random().toString(36).slice(2, 9)}`).current;
|
|
5678
5803
|
const isChecked = checkedProp !== void 0 ? checkedProp : ctx.value === value;
|
|
5679
5804
|
const isDisabled = disabledProp !== void 0 ? disabledProp : ctx.disabled ?? false;
|
|
5680
5805
|
const size = sizeProp ?? ctx.size ?? "medium";
|
|
@@ -5724,7 +5849,7 @@ var RadioGroup = React79.forwardRef(function RadioGroup2(props, ref) {
|
|
|
5724
5849
|
sx
|
|
5725
5850
|
} = props;
|
|
5726
5851
|
const sxClass = useSx(sx);
|
|
5727
|
-
const groupName =
|
|
5852
|
+
const groupName = useRef14(name ?? `rf-rg-${Math.random().toString(36).slice(2, 9)}`).current;
|
|
5728
5853
|
const rootClasses = [
|
|
5729
5854
|
"rf-radio-group",
|
|
5730
5855
|
row ? "rf-radio-group--row" : "",
|
|
@@ -5758,7 +5883,7 @@ RadioGroup.displayName = "RadioGroup";
|
|
|
5758
5883
|
// lib/Rating/Rating.tsx
|
|
5759
5884
|
import React80, {
|
|
5760
5885
|
useState as useState12,
|
|
5761
|
-
useRef as
|
|
5886
|
+
useRef as useRef15
|
|
5762
5887
|
} from "react";
|
|
5763
5888
|
var starSize = { small: 18, medium: 24, large: 32 };
|
|
5764
5889
|
var FilledStarIcon = ({ size }) => /* @__PURE__ */ React80.createElement(
|
|
@@ -5804,7 +5929,7 @@ var Rating = React80.forwardRef(function Rating2(props, ref) {
|
|
|
5804
5929
|
} = props;
|
|
5805
5930
|
const sxClass = useSx(sx);
|
|
5806
5931
|
const [hoverValue, setHoverValue] = useState12(null);
|
|
5807
|
-
const starsRef =
|
|
5932
|
+
const starsRef = useRef15(null);
|
|
5808
5933
|
const currentValue = value ?? 0;
|
|
5809
5934
|
const displayValue = hoverValue !== null ? hoverValue : currentValue;
|
|
5810
5935
|
const iconSize = starSize[size] ?? 24;
|
|
@@ -6996,7 +7121,7 @@ AccordionDetails.displayName = "AccordionDetails";
|
|
|
6996
7121
|
import React94, {
|
|
6997
7122
|
useEffect as useEffect12,
|
|
6998
7123
|
useLayoutEffect,
|
|
6999
|
-
useRef as
|
|
7124
|
+
useRef as useRef16,
|
|
7000
7125
|
useState as useState15,
|
|
7001
7126
|
Children as Children2,
|
|
7002
7127
|
cloneElement,
|
|
@@ -7060,8 +7185,8 @@ var Tabs = ({
|
|
|
7060
7185
|
sx
|
|
7061
7186
|
}) => {
|
|
7062
7187
|
const sxClass = useSx(sx);
|
|
7063
|
-
const tabsListRef =
|
|
7064
|
-
const tabRefs =
|
|
7188
|
+
const tabsListRef = useRef16(null);
|
|
7189
|
+
const tabRefs = useRef16(/* @__PURE__ */ new Map());
|
|
7065
7190
|
const [indicatorStyle, setIndicatorStyle] = useState15({});
|
|
7066
7191
|
const updateIndicator = () => {
|
|
7067
7192
|
if (value === void 0) return;
|
|
@@ -7447,7 +7572,7 @@ Stepper.displayName = "Stepper";
|
|
|
7447
7572
|
// lib/Menu/Menu.tsx
|
|
7448
7573
|
import React97, {
|
|
7449
7574
|
useEffect as useEffect13,
|
|
7450
|
-
useRef as
|
|
7575
|
+
useRef as useRef17,
|
|
7451
7576
|
useState as useState17
|
|
7452
7577
|
} from "react";
|
|
7453
7578
|
import ReactDOM5 from "react-dom";
|
|
@@ -7540,7 +7665,7 @@ var Menu = ({
|
|
|
7540
7665
|
children
|
|
7541
7666
|
}) => {
|
|
7542
7667
|
const sxClass = useSx(sx);
|
|
7543
|
-
const paperRef =
|
|
7668
|
+
const paperRef = useRef17(null);
|
|
7544
7669
|
const [menuStyle, setMenuStyle] = useState17({});
|
|
7545
7670
|
const [mounted, setMounted] = useState17(false);
|
|
7546
7671
|
useEffect13(() => {
|
|
@@ -7721,9 +7846,9 @@ Drawer.displayName = "Drawer";
|
|
|
7721
7846
|
|
|
7722
7847
|
// lib/Snackbar/Snackbar.tsx
|
|
7723
7848
|
import React99, {
|
|
7724
|
-
useCallback as
|
|
7849
|
+
useCallback as useCallback7,
|
|
7725
7850
|
useEffect as useEffect15,
|
|
7726
|
-
useRef as
|
|
7851
|
+
useRef as useRef18,
|
|
7727
7852
|
useState as useState19
|
|
7728
7853
|
} from "react";
|
|
7729
7854
|
import ReactDOM7 from "react-dom";
|
|
@@ -7750,13 +7875,13 @@ var Snackbar = ({
|
|
|
7750
7875
|
const sxClass = useSx(sx);
|
|
7751
7876
|
const [transitionState, setTransitionState] = useState19("exited");
|
|
7752
7877
|
const [mounted, setMounted] = useState19(false);
|
|
7753
|
-
const timerRef =
|
|
7754
|
-
const hideTimerRef =
|
|
7755
|
-
const clearTimers =
|
|
7878
|
+
const timerRef = useRef18(null);
|
|
7879
|
+
const hideTimerRef = useRef18(null);
|
|
7880
|
+
const clearTimers = useCallback7(() => {
|
|
7756
7881
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
7757
7882
|
if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
|
|
7758
7883
|
}, []);
|
|
7759
|
-
const startHideTimer =
|
|
7884
|
+
const startHideTimer = useCallback7(() => {
|
|
7760
7885
|
if (autoHideDuration == null || !onClose) return;
|
|
7761
7886
|
clearTimers();
|
|
7762
7887
|
hideTimerRef.current = setTimeout(() => {
|
|
@@ -7887,7 +8012,7 @@ Link.displayName = "Link";
|
|
|
7887
8012
|
import React101, {
|
|
7888
8013
|
useEffect as useEffect16,
|
|
7889
8014
|
useLayoutEffect as useLayoutEffect2,
|
|
7890
|
-
useRef as
|
|
8015
|
+
useRef as useRef19,
|
|
7891
8016
|
useState as useState20
|
|
7892
8017
|
} from "react";
|
|
7893
8018
|
import ReactDOM8 from "react-dom";
|
|
@@ -7968,7 +8093,7 @@ var Popper = ({
|
|
|
7968
8093
|
sx
|
|
7969
8094
|
}) => {
|
|
7970
8095
|
const sxClass = useSx(sx);
|
|
7971
|
-
const popperRef =
|
|
8096
|
+
const popperRef = useRef19(null);
|
|
7972
8097
|
const [posStyle, setPosStyle] = useState20({});
|
|
7973
8098
|
const [mounted, setMounted] = useState20(open || keepMounted);
|
|
7974
8099
|
const [fadeState, setFadeState] = useState20(
|
|
@@ -8041,7 +8166,7 @@ Popper.displayName = "Popper";
|
|
|
8041
8166
|
import React102, {
|
|
8042
8167
|
useEffect as useEffect17,
|
|
8043
8168
|
useLayoutEffect as useLayoutEffect3,
|
|
8044
|
-
useRef as
|
|
8169
|
+
useRef as useRef20,
|
|
8045
8170
|
useState as useState21
|
|
8046
8171
|
} from "react";
|
|
8047
8172
|
import ReactDOM9 from "react-dom";
|
|
@@ -8071,7 +8196,7 @@ var Popover = ({
|
|
|
8071
8196
|
}) => {
|
|
8072
8197
|
const sxClass = useSx(sx);
|
|
8073
8198
|
const paperSxClass = useSx(PaperProps?.sx);
|
|
8074
|
-
const paperRef =
|
|
8199
|
+
const paperRef = useRef20(null);
|
|
8075
8200
|
const [posStyle, setPosStyle] = useState21({});
|
|
8076
8201
|
const [mounted, setMounted] = useState21(open || keepMounted);
|
|
8077
8202
|
useEffect17(() => {
|
|
@@ -8158,7 +8283,7 @@ Popover.displayName = "Popover";
|
|
|
8158
8283
|
import React103, {
|
|
8159
8284
|
cloneElement as cloneElement3,
|
|
8160
8285
|
useEffect as useEffect18,
|
|
8161
|
-
useRef as
|
|
8286
|
+
useRef as useRef21,
|
|
8162
8287
|
useState as useState22
|
|
8163
8288
|
} from "react";
|
|
8164
8289
|
function getTimeout(timeout, phase) {
|
|
@@ -8169,8 +8294,8 @@ function getTimeout(timeout, phase) {
|
|
|
8169
8294
|
function useTransitionState(inProp, timeout, onEnter, onExited) {
|
|
8170
8295
|
const [state, setState] = useState22("exited");
|
|
8171
8296
|
const [mounted, setMounted] = useState22(false);
|
|
8172
|
-
const timerRef =
|
|
8173
|
-
const isFirstRender =
|
|
8297
|
+
const timerRef = useRef21(null);
|
|
8298
|
+
const isFirstRender = useRef21(true);
|
|
8174
8299
|
useEffect18(() => {
|
|
8175
8300
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
8176
8301
|
if (inProp) {
|
|
@@ -8314,7 +8439,7 @@ var Collapse = ({
|
|
|
8314
8439
|
onExited
|
|
8315
8440
|
}) => {
|
|
8316
8441
|
const { state, mounted } = useTransitionState(inProp, timeout, onEnter, onExited);
|
|
8317
|
-
const innerRef =
|
|
8442
|
+
const innerRef = useRef21(null);
|
|
8318
8443
|
const [size, setSize] = useState22(
|
|
8319
8444
|
inProp ? "auto" : collapsedSize
|
|
8320
8445
|
);
|
|
@@ -8392,7 +8517,7 @@ var Zoom = ({
|
|
|
8392
8517
|
Zoom.displayName = "Zoom";
|
|
8393
8518
|
|
|
8394
8519
|
// lib/ImageField/ImageField.tsx
|
|
8395
|
-
import React104, { useRef as
|
|
8520
|
+
import React104, { useRef as useRef22, useState as useState23, useCallback as useCallback8 } from "react";
|
|
8396
8521
|
function getSizeStyle2(size) {
|
|
8397
8522
|
if (size === "small") return { className: "rf-image-field--small" };
|
|
8398
8523
|
if (size === "large") return { className: "rf-image-field--large" };
|
|
@@ -8419,16 +8544,16 @@ var ImageField = React104.forwardRef(
|
|
|
8419
8544
|
sx
|
|
8420
8545
|
}, ref) => {
|
|
8421
8546
|
const sxClass = useSx(sx);
|
|
8422
|
-
const inputRef =
|
|
8547
|
+
const inputRef = useRef22(null);
|
|
8423
8548
|
const [preview, setPreview] = useState23(null);
|
|
8424
8549
|
const { className: sizeClass, style: sizeStyle } = getSizeStyle2(size);
|
|
8425
8550
|
const displaySrc = preview || src;
|
|
8426
|
-
const handleClick =
|
|
8551
|
+
const handleClick = useCallback8(() => {
|
|
8427
8552
|
if (!disabled) {
|
|
8428
8553
|
inputRef.current?.click();
|
|
8429
8554
|
}
|
|
8430
8555
|
}, [disabled]);
|
|
8431
|
-
const handleKeyDown =
|
|
8556
|
+
const handleKeyDown = useCallback8(
|
|
8432
8557
|
(e) => {
|
|
8433
8558
|
if ((e.key === "Enter" || e.key === " ") && !disabled) {
|
|
8434
8559
|
e.preventDefault();
|
|
@@ -8437,7 +8562,7 @@ var ImageField = React104.forwardRef(
|
|
|
8437
8562
|
},
|
|
8438
8563
|
[disabled]
|
|
8439
8564
|
);
|
|
8440
|
-
const handleFileChange =
|
|
8565
|
+
const handleFileChange = useCallback8(
|
|
8441
8566
|
(e) => {
|
|
8442
8567
|
const file = e.target.files?.[0];
|
|
8443
8568
|
if (!file) return;
|
|
@@ -8503,9 +8628,9 @@ ImageField.displayName = "ImageField";
|
|
|
8503
8628
|
// lib/PhoneField/PhoneField.tsx
|
|
8504
8629
|
import React105, {
|
|
8505
8630
|
useState as useState24,
|
|
8506
|
-
useRef as
|
|
8631
|
+
useRef as useRef23,
|
|
8507
8632
|
useEffect as useEffect19,
|
|
8508
|
-
useCallback as
|
|
8633
|
+
useCallback as useCallback9,
|
|
8509
8634
|
forwardRef as forwardRef10
|
|
8510
8635
|
} from "react";
|
|
8511
8636
|
import { Country as Country2 } from "country-state-city";
|
|
@@ -8556,11 +8681,11 @@ var PhoneField = forwardRef10(function PhoneField2(props, ref) {
|
|
|
8556
8681
|
sx
|
|
8557
8682
|
} = props;
|
|
8558
8683
|
const sxClass = useSx(sx);
|
|
8559
|
-
const containerRef =
|
|
8560
|
-
const inputRef =
|
|
8561
|
-
const listRef =
|
|
8562
|
-
const popupRef =
|
|
8563
|
-
const inputId =
|
|
8684
|
+
const containerRef = useRef23(null);
|
|
8685
|
+
const inputRef = useRef23(null);
|
|
8686
|
+
const listRef = useRef23(null);
|
|
8687
|
+
const popupRef = useRef23(null);
|
|
8688
|
+
const inputId = useRef23(`rf-phone-${Math.random().toString(36).slice(2, 9)}`).current;
|
|
8564
8689
|
const countries = React105.useMemo(() => {
|
|
8565
8690
|
const all = getAllCountries();
|
|
8566
8691
|
if (onlyCountries && onlyCountries.length > 0) {
|
|
@@ -8579,7 +8704,7 @@ var PhoneField = forwardRef10(function PhoneField2(props, ref) {
|
|
|
8579
8704
|
const [open, setOpen] = useState24(false);
|
|
8580
8705
|
const [focusedIdx, setFocusedIdx] = useState24(-1);
|
|
8581
8706
|
const [search, setSearch] = useState24("");
|
|
8582
|
-
const prevValueRef =
|
|
8707
|
+
const prevValueRef = useRef23(value);
|
|
8583
8708
|
useEffect19(() => {
|
|
8584
8709
|
if (value === prevValueRef.current) return;
|
|
8585
8710
|
prevValueRef.current = value;
|
|
@@ -8593,13 +8718,13 @@ var PhoneField = forwardRef10(function PhoneField2(props, ref) {
|
|
|
8593
8718
|
const dialCode = selectedCountry?.phonecode || "";
|
|
8594
8719
|
const digits = sanitizeValue(value);
|
|
8595
8720
|
const phoneNumber = digits.startsWith(dialCode) ? digits.slice(dialCode.length) : digits;
|
|
8596
|
-
const openDropdown =
|
|
8721
|
+
const openDropdown = useCallback9(() => {
|
|
8597
8722
|
if (disabled) return;
|
|
8598
8723
|
setOpen(true);
|
|
8599
8724
|
setFocusedIdx(-1);
|
|
8600
8725
|
setSearch("");
|
|
8601
8726
|
}, [disabled]);
|
|
8602
|
-
const closeDropdown =
|
|
8727
|
+
const closeDropdown = useCallback9(() => {
|
|
8603
8728
|
setOpen(false);
|
|
8604
8729
|
setFocusedIdx(-1);
|
|
8605
8730
|
setSearch("");
|
|
@@ -8650,7 +8775,7 @@ var PhoneField = forwardRef10(function PhoneField2(props, ref) {
|
|
|
8650
8775
|
window.removeEventListener("resize", updatePosition);
|
|
8651
8776
|
};
|
|
8652
8777
|
}, [open]);
|
|
8653
|
-
const selectCountry =
|
|
8778
|
+
const selectCountry = useCallback9((country) => {
|
|
8654
8779
|
setSelectedCountry(country);
|
|
8655
8780
|
closeDropdown();
|
|
8656
8781
|
const newValue = "+" + country.phonecode + phoneNumber;
|
|
@@ -8807,8 +8932,503 @@ var PhoneField = forwardRef10(function PhoneField2(props, ref) {
|
|
|
8807
8932
|
});
|
|
8808
8933
|
PhoneField.displayName = "PhoneField";
|
|
8809
8934
|
|
|
8935
|
+
// lib/TreeSelect/TreeSelect.tsx
|
|
8936
|
+
import React106, {
|
|
8937
|
+
useState as useState25,
|
|
8938
|
+
useRef as useRef24,
|
|
8939
|
+
useEffect as useEffect20,
|
|
8940
|
+
useCallback as useCallback10
|
|
8941
|
+
} from "react";
|
|
8942
|
+
import ReactDOM10 from "react-dom";
|
|
8943
|
+
import { ChevronDown as ChevronDown2, ChevronRight as ChevronRight2, X as X3, Search as Search2, Check } from "lucide-react";
|
|
8944
|
+
function collectDescendants(node) {
|
|
8945
|
+
const ids = [String(node.id)];
|
|
8946
|
+
node.children?.forEach((c) => ids.push(...collectDescendants(c)));
|
|
8947
|
+
return ids;
|
|
8948
|
+
}
|
|
8949
|
+
function findNodeById(nodes, id) {
|
|
8950
|
+
for (const node of nodes) {
|
|
8951
|
+
if (String(node.id) === id) return node;
|
|
8952
|
+
const found = findNodeById(node.children ?? [], id);
|
|
8953
|
+
if (found) return found;
|
|
8954
|
+
}
|
|
8955
|
+
return null;
|
|
8956
|
+
}
|
|
8957
|
+
function getNodeState(node, selected) {
|
|
8958
|
+
if (selected.has(String(node.id))) return "checked";
|
|
8959
|
+
if (!node.children?.length) return "unchecked";
|
|
8960
|
+
const states = node.children.map((c) => getNodeState(c, selected));
|
|
8961
|
+
if (states.every((s2) => s2 === "checked")) return "checked";
|
|
8962
|
+
if (states.some((s2) => s2 !== "unchecked")) return "partial";
|
|
8963
|
+
return "unchecked";
|
|
8964
|
+
}
|
|
8965
|
+
function getTopLevelSelected(nodes, selected) {
|
|
8966
|
+
const result = [];
|
|
8967
|
+
for (const node of nodes) {
|
|
8968
|
+
const state = getNodeState(node, selected);
|
|
8969
|
+
if (state === "checked") {
|
|
8970
|
+
result.push(node);
|
|
8971
|
+
} else if (state === "partial") {
|
|
8972
|
+
result.push(...getTopLevelSelected(node.children ?? [], selected));
|
|
8973
|
+
}
|
|
8974
|
+
}
|
|
8975
|
+
return result;
|
|
8976
|
+
}
|
|
8977
|
+
function filterTree(nodes, query) {
|
|
8978
|
+
if (!query) return nodes;
|
|
8979
|
+
const q = query.toLowerCase();
|
|
8980
|
+
return nodes.reduce((acc, node) => {
|
|
8981
|
+
const filteredChildren = filterTree(node.children ?? [], q);
|
|
8982
|
+
if (node.label.toLowerCase().includes(q) || filteredChildren.length > 0) {
|
|
8983
|
+
acc.push({ ...node, children: filteredChildren });
|
|
8984
|
+
}
|
|
8985
|
+
return acc;
|
|
8986
|
+
}, []);
|
|
8987
|
+
}
|
|
8988
|
+
function recordToSet(record) {
|
|
8989
|
+
if (!record) return /* @__PURE__ */ new Set();
|
|
8990
|
+
return new Set(Object.keys(record).filter((k) => record[k]));
|
|
8991
|
+
}
|
|
8992
|
+
function setToRecord(set) {
|
|
8993
|
+
const r = {};
|
|
8994
|
+
set.forEach((id) => {
|
|
8995
|
+
r[id] = true;
|
|
8996
|
+
});
|
|
8997
|
+
return r;
|
|
8998
|
+
}
|
|
8999
|
+
function TreeNodeItem({
|
|
9000
|
+
node,
|
|
9001
|
+
depth,
|
|
9002
|
+
selected,
|
|
9003
|
+
expanded,
|
|
9004
|
+
selectionMode,
|
|
9005
|
+
onToggleExpand,
|
|
9006
|
+
onSelect,
|
|
9007
|
+
isFiltering
|
|
9008
|
+
}) {
|
|
9009
|
+
const nodeId = String(node.id);
|
|
9010
|
+
const hasChildren = !!node.children?.length;
|
|
9011
|
+
const isExpanded = isFiltering || expanded.has(nodeId);
|
|
9012
|
+
const state = getNodeState(node, selected);
|
|
9013
|
+
return /* @__PURE__ */ React106.createElement("div", { className: "rf-tsn" }, /* @__PURE__ */ React106.createElement(
|
|
9014
|
+
"div",
|
|
9015
|
+
{
|
|
9016
|
+
className: `rf-tsn__row${state !== "unchecked" ? " rf-tsn__row--active" : ""}`,
|
|
9017
|
+
style: { paddingLeft: 8 + depth * 20 },
|
|
9018
|
+
onClick: () => onSelect(node)
|
|
9019
|
+
},
|
|
9020
|
+
hasChildren ? /* @__PURE__ */ React106.createElement(
|
|
9021
|
+
"button",
|
|
9022
|
+
{
|
|
9023
|
+
type: "button",
|
|
9024
|
+
className: "rf-tsn__expand",
|
|
9025
|
+
onClick: (e) => {
|
|
9026
|
+
e.stopPropagation();
|
|
9027
|
+
onToggleExpand(nodeId);
|
|
9028
|
+
}
|
|
9029
|
+
},
|
|
9030
|
+
isExpanded ? /* @__PURE__ */ React106.createElement(ChevronDown2, { size: 14 }) : /* @__PURE__ */ React106.createElement(ChevronRight2, { size: 14 })
|
|
9031
|
+
) : /* @__PURE__ */ React106.createElement("span", { className: "rf-tsn__expand-ph" }),
|
|
9032
|
+
selectionMode === "multiple" && /* @__PURE__ */ React106.createElement(
|
|
9033
|
+
"span",
|
|
9034
|
+
{
|
|
9035
|
+
className: `rf-tsn__cb${state === "checked" ? " rf-tsn__cb--checked" : state === "partial" ? " rf-tsn__cb--partial" : ""}`
|
|
9036
|
+
},
|
|
9037
|
+
state === "checked" && /* @__PURE__ */ React106.createElement(Check, { size: 10, strokeWidth: 3 }),
|
|
9038
|
+
state === "partial" && /* @__PURE__ */ React106.createElement("span", { className: "rf-tsn__cb-dash" })
|
|
9039
|
+
),
|
|
9040
|
+
selectionMode === "single" && /* @__PURE__ */ React106.createElement("span", { className: `rf-tsn__radio${state === "checked" ? " rf-tsn__radio--checked" : ""}` }),
|
|
9041
|
+
/* @__PURE__ */ React106.createElement("span", { className: "rf-tsn__label" }, node.label)
|
|
9042
|
+
), hasChildren && isExpanded && /* @__PURE__ */ React106.createElement("div", null, node.children.map((child) => /* @__PURE__ */ React106.createElement(
|
|
9043
|
+
TreeNodeItem,
|
|
9044
|
+
{
|
|
9045
|
+
key: child.id,
|
|
9046
|
+
node: child,
|
|
9047
|
+
depth: depth + 1,
|
|
9048
|
+
selected,
|
|
9049
|
+
expanded,
|
|
9050
|
+
selectionMode,
|
|
9051
|
+
onToggleExpand,
|
|
9052
|
+
onSelect,
|
|
9053
|
+
isFiltering
|
|
9054
|
+
}
|
|
9055
|
+
))));
|
|
9056
|
+
}
|
|
9057
|
+
function TreeSelect({
|
|
9058
|
+
options,
|
|
9059
|
+
value,
|
|
9060
|
+
onChange,
|
|
9061
|
+
onNodeSelect,
|
|
9062
|
+
onNodeUnselect,
|
|
9063
|
+
selectionMode = "single",
|
|
9064
|
+
placeholder = "Select",
|
|
9065
|
+
filter = false,
|
|
9066
|
+
filterInputAutoFocus = false,
|
|
9067
|
+
resetFilterOnHide = false,
|
|
9068
|
+
metaKeySelection: _metaKeySelection,
|
|
9069
|
+
disabled = false,
|
|
9070
|
+
label,
|
|
9071
|
+
variant = "outlined",
|
|
9072
|
+
size = "medium",
|
|
9073
|
+
error = false,
|
|
9074
|
+
helperText,
|
|
9075
|
+
fullWidth = false,
|
|
9076
|
+
clearable = true,
|
|
9077
|
+
required = false,
|
|
9078
|
+
style,
|
|
9079
|
+
className,
|
|
9080
|
+
sx
|
|
9081
|
+
}) {
|
|
9082
|
+
const sxClass = useSx(sx);
|
|
9083
|
+
const [open, setOpen] = useState25(false);
|
|
9084
|
+
const [focused, setFocused] = useState25(false);
|
|
9085
|
+
const [filterQuery, setFilterQuery] = useState25("");
|
|
9086
|
+
const [expandedKeys, setExpandedKeys] = useState25(/* @__PURE__ */ new Set());
|
|
9087
|
+
const [dropdownStyle, setDropdownStyle] = useState25({});
|
|
9088
|
+
const triggerRef = useRef24(null);
|
|
9089
|
+
const dropdownRef = useRef24(null);
|
|
9090
|
+
const filterInputRef = useRef24(null);
|
|
9091
|
+
const isMultiple = selectionMode === "multiple";
|
|
9092
|
+
const selectedSet = isMultiple ? recordToSet(value) : value != null ? /* @__PURE__ */ new Set([String(value)]) : /* @__PURE__ */ new Set();
|
|
9093
|
+
const computePosition3 = useCallback10(() => {
|
|
9094
|
+
if (!triggerRef.current) return;
|
|
9095
|
+
const rect = triggerRef.current.getBoundingClientRect();
|
|
9096
|
+
const spaceBelow = window.innerHeight - rect.bottom;
|
|
9097
|
+
const dropdownMaxH = 320;
|
|
9098
|
+
const above = spaceBelow < dropdownMaxH && rect.top > spaceBelow;
|
|
9099
|
+
setDropdownStyle({
|
|
9100
|
+
position: "fixed",
|
|
9101
|
+
left: rect.left,
|
|
9102
|
+
width: rect.width,
|
|
9103
|
+
...above ? { bottom: window.innerHeight - rect.top + 4 } : { top: rect.bottom + 4 }
|
|
9104
|
+
});
|
|
9105
|
+
}, []);
|
|
9106
|
+
const openDropdown = () => {
|
|
9107
|
+
if (disabled) return;
|
|
9108
|
+
computePosition3();
|
|
9109
|
+
setOpen(true);
|
|
9110
|
+
};
|
|
9111
|
+
const closeDropdown = useCallback10(() => {
|
|
9112
|
+
setOpen(false);
|
|
9113
|
+
if (resetFilterOnHide) setFilterQuery("");
|
|
9114
|
+
}, [resetFilterOnHide]);
|
|
9115
|
+
const mouseActivatedRef = useRef24(false);
|
|
9116
|
+
const handleTriggerMouseDown = () => {
|
|
9117
|
+
mouseActivatedRef.current = true;
|
|
9118
|
+
};
|
|
9119
|
+
const handleTriggerFocus = () => {
|
|
9120
|
+
setFocused(true);
|
|
9121
|
+
if (!mouseActivatedRef.current) {
|
|
9122
|
+
openDropdown();
|
|
9123
|
+
}
|
|
9124
|
+
mouseActivatedRef.current = false;
|
|
9125
|
+
};
|
|
9126
|
+
const handleTriggerBlur = (e) => {
|
|
9127
|
+
const next = e.relatedTarget;
|
|
9128
|
+
if (next === null) return;
|
|
9129
|
+
if (!triggerRef.current?.contains(next) && !dropdownRef.current?.contains(next)) {
|
|
9130
|
+
setFocused(false);
|
|
9131
|
+
closeDropdown();
|
|
9132
|
+
}
|
|
9133
|
+
};
|
|
9134
|
+
const handleKeyDown = (e) => {
|
|
9135
|
+
if (disabled) return;
|
|
9136
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
9137
|
+
e.preventDefault();
|
|
9138
|
+
open ? closeDropdown() : openDropdown();
|
|
9139
|
+
} else if (e.key === "Escape") {
|
|
9140
|
+
closeDropdown();
|
|
9141
|
+
}
|
|
9142
|
+
};
|
|
9143
|
+
useEffect20(() => {
|
|
9144
|
+
if (open && filter && filterInputAutoFocus) {
|
|
9145
|
+
const t = setTimeout(() => filterInputRef.current?.focus(), 40);
|
|
9146
|
+
return () => clearTimeout(t);
|
|
9147
|
+
}
|
|
9148
|
+
}, [open, filter, filterInputAutoFocus]);
|
|
9149
|
+
useEffect20(() => {
|
|
9150
|
+
if (!open) return;
|
|
9151
|
+
const handleOutside = (e) => {
|
|
9152
|
+
if (dropdownRef.current?.contains(e.target) || triggerRef.current?.contains(e.target)) return;
|
|
9153
|
+
closeDropdown();
|
|
9154
|
+
setFocused(false);
|
|
9155
|
+
};
|
|
9156
|
+
const handleFocusOut = (e) => {
|
|
9157
|
+
const next = e.relatedTarget;
|
|
9158
|
+
if (next === null) return;
|
|
9159
|
+
if (!triggerRef.current?.contains(next) && !dropdownRef.current?.contains(next)) {
|
|
9160
|
+
closeDropdown();
|
|
9161
|
+
setFocused(false);
|
|
9162
|
+
}
|
|
9163
|
+
};
|
|
9164
|
+
document.addEventListener("mousedown", handleOutside);
|
|
9165
|
+
document.addEventListener("focusout", handleFocusOut);
|
|
9166
|
+
return () => {
|
|
9167
|
+
document.removeEventListener("mousedown", handleOutside);
|
|
9168
|
+
document.removeEventListener("focusout", handleFocusOut);
|
|
9169
|
+
};
|
|
9170
|
+
}, [open, closeDropdown]);
|
|
9171
|
+
useEffect20(() => {
|
|
9172
|
+
if (!open) return;
|
|
9173
|
+
const h = () => computePosition3();
|
|
9174
|
+
window.addEventListener("scroll", h, true);
|
|
9175
|
+
window.addEventListener("resize", h);
|
|
9176
|
+
return () => {
|
|
9177
|
+
window.removeEventListener("scroll", h, true);
|
|
9178
|
+
window.removeEventListener("resize", h);
|
|
9179
|
+
};
|
|
9180
|
+
}, [open, computePosition3]);
|
|
9181
|
+
const handleSelect = (node) => {
|
|
9182
|
+
const nodeId = String(node.id);
|
|
9183
|
+
if (isMultiple) {
|
|
9184
|
+
const state = getNodeState(node, selectedSet);
|
|
9185
|
+
const descendants = collectDescendants(node);
|
|
9186
|
+
const newSet = new Set(selectedSet);
|
|
9187
|
+
if (state === "checked" || state === "partial") {
|
|
9188
|
+
descendants.forEach((id) => newSet.delete(id));
|
|
9189
|
+
onNodeUnselect?.({ node });
|
|
9190
|
+
} else {
|
|
9191
|
+
descendants.forEach((id) => newSet.add(id));
|
|
9192
|
+
onNodeSelect?.({ node });
|
|
9193
|
+
}
|
|
9194
|
+
onChange?.({ value: setToRecord(newSet) });
|
|
9195
|
+
} else {
|
|
9196
|
+
if (selectedSet.has(nodeId)) {
|
|
9197
|
+
onChange?.({ value: null });
|
|
9198
|
+
onNodeUnselect?.({ node });
|
|
9199
|
+
} else {
|
|
9200
|
+
onChange?.({ value: node.id });
|
|
9201
|
+
onNodeSelect?.({ node });
|
|
9202
|
+
closeDropdown();
|
|
9203
|
+
}
|
|
9204
|
+
}
|
|
9205
|
+
};
|
|
9206
|
+
const handleToggleExpand = (id) => {
|
|
9207
|
+
setExpandedKeys((prev) => {
|
|
9208
|
+
const next = new Set(prev);
|
|
9209
|
+
next.has(id) ? next.delete(id) : next.add(id);
|
|
9210
|
+
return next;
|
|
9211
|
+
});
|
|
9212
|
+
};
|
|
9213
|
+
const handleClear = (e) => {
|
|
9214
|
+
e.stopPropagation();
|
|
9215
|
+
onChange?.({ value: isMultiple ? {} : null });
|
|
9216
|
+
};
|
|
9217
|
+
const handleRemoveTag = (e, node) => {
|
|
9218
|
+
e.stopPropagation();
|
|
9219
|
+
const newSet = new Set(selectedSet);
|
|
9220
|
+
collectDescendants(node).forEach((id) => newSet.delete(id));
|
|
9221
|
+
onChange?.({ value: setToRecord(newSet) });
|
|
9222
|
+
onNodeUnselect?.({ node });
|
|
9223
|
+
};
|
|
9224
|
+
const filteredTree = filterTree(options, filterQuery);
|
|
9225
|
+
const tagNodes = isMultiple ? getTopLevelSelected(options, selectedSet) : value != null ? findNodeById(options, String(value)) ? [findNodeById(options, String(value))] : [] : [];
|
|
9226
|
+
const hasValue = tagNodes.length > 0;
|
|
9227
|
+
const isFloating = open || hasValue || focused;
|
|
9228
|
+
const rootClasses = [
|
|
9229
|
+
"rf-text-field",
|
|
9230
|
+
`rf-text-field--${variant}`,
|
|
9231
|
+
size === "small" ? "rf-text-field--small" : "",
|
|
9232
|
+
disabled ? "rf-text-field--disabled" : "",
|
|
9233
|
+
error ? "rf-text-field--error" : "",
|
|
9234
|
+
fullWidth ? "rf-text-field--full-width" : "",
|
|
9235
|
+
isFloating ? "rf-text-field--floating" : "",
|
|
9236
|
+
"rf-tree-select",
|
|
9237
|
+
sxClass,
|
|
9238
|
+
className
|
|
9239
|
+
].filter(Boolean).join(" ");
|
|
9240
|
+
return /* @__PURE__ */ React106.createElement("div", { className: rootClasses, style }, label && /* @__PURE__ */ React106.createElement("label", { className: "rf-text-field__label" }, label, " ", required && /* @__PURE__ */ React106.createElement("span", { className: "rf-text-field__asterisk" }, "*")), /* @__PURE__ */ React106.createElement(
|
|
9241
|
+
"div",
|
|
9242
|
+
{
|
|
9243
|
+
ref: triggerRef,
|
|
9244
|
+
className: `rf-text-field__wrapper rf-tree-select__trigger${open ? " rf-tree-select__trigger--open" : ""}`,
|
|
9245
|
+
tabIndex: disabled ? -1 : 0,
|
|
9246
|
+
onMouseDown: handleTriggerMouseDown,
|
|
9247
|
+
onClick: () => open ? closeDropdown() : openDropdown(),
|
|
9248
|
+
onFocus: handleTriggerFocus,
|
|
9249
|
+
onBlur: handleTriggerBlur,
|
|
9250
|
+
onKeyDown: handleKeyDown
|
|
9251
|
+
},
|
|
9252
|
+
isMultiple ? /* @__PURE__ */ React106.createElement("div", { className: "rf-ts__chips" }, tagNodes.length > 0 ? tagNodes.map((node) => /* @__PURE__ */ React106.createElement("span", { key: node.id, className: "rf-ts__chip" }, node.label, /* @__PURE__ */ React106.createElement(
|
|
9253
|
+
"button",
|
|
9254
|
+
{
|
|
9255
|
+
type: "button",
|
|
9256
|
+
className: "rf-ts__chip-delete",
|
|
9257
|
+
onClick: (e) => handleRemoveTag(e, node),
|
|
9258
|
+
tabIndex: -1
|
|
9259
|
+
},
|
|
9260
|
+
/* @__PURE__ */ React106.createElement(X3, { size: 10 })
|
|
9261
|
+
))) : open ? /* @__PURE__ */ React106.createElement("span", { className: "rf-ts__placeholder" }, placeholder) : null) : /* @__PURE__ */ React106.createElement("div", { className: `rf-ts__display${!hasValue ? " rf-ts__display--placeholder" : ""}` }, hasValue ? tagNodes[0]?.label : open ? placeholder : "\xA0"),
|
|
9262
|
+
/* @__PURE__ */ React106.createElement("div", { className: "rf-autocomplete__endgroup" }, clearable && hasValue && /* @__PURE__ */ React106.createElement(
|
|
9263
|
+
"button",
|
|
9264
|
+
{
|
|
9265
|
+
type: "button",
|
|
9266
|
+
className: "rf-autocomplete__icon-btn",
|
|
9267
|
+
onClick: handleClear,
|
|
9268
|
+
tabIndex: -1
|
|
9269
|
+
},
|
|
9270
|
+
/* @__PURE__ */ React106.createElement(X3, { size: 16 })
|
|
9271
|
+
), /* @__PURE__ */ React106.createElement(
|
|
9272
|
+
"button",
|
|
9273
|
+
{
|
|
9274
|
+
type: "button",
|
|
9275
|
+
className: `rf-autocomplete__icon-btn rf-autocomplete__icon-btn--popup${open ? " rf-autocomplete__icon-btn--open" : ""}`,
|
|
9276
|
+
onClick: (e) => {
|
|
9277
|
+
e.stopPropagation();
|
|
9278
|
+
open ? closeDropdown() : openDropdown();
|
|
9279
|
+
},
|
|
9280
|
+
tabIndex: -1
|
|
9281
|
+
},
|
|
9282
|
+
/* @__PURE__ */ React106.createElement(ChevronDown2, { size: 18 })
|
|
9283
|
+
)),
|
|
9284
|
+
variant === "outlined" && /* @__PURE__ */ React106.createElement("fieldset", { "aria-hidden": true, className: "rf-text-field__notch" }, /* @__PURE__ */ React106.createElement("legend", { className: "rf-text-field__legend" }, label && /* @__PURE__ */ React106.createElement("span", null, label, required ? " *" : ""))),
|
|
9285
|
+
variant === "filled" && /* @__PURE__ */ React106.createElement(React106.Fragment, null, /* @__PURE__ */ React106.createElement("div", { className: "rf-text-field__filled-bg" }), /* @__PURE__ */ React106.createElement("div", { className: "rf-text-field__underline" })),
|
|
9286
|
+
variant === "standard" && /* @__PURE__ */ React106.createElement("div", { className: "rf-text-field__underline" })
|
|
9287
|
+
), helperText && /* @__PURE__ */ React106.createElement("p", { className: `rf-text-field__helper-text${error ? " rf-text-field__helper-text--error" : ""}` }, helperText), open && ReactDOM10.createPortal(
|
|
9288
|
+
/* @__PURE__ */ React106.createElement(
|
|
9289
|
+
"div",
|
|
9290
|
+
{
|
|
9291
|
+
ref: dropdownRef,
|
|
9292
|
+
className: "rf-tree-select__popup",
|
|
9293
|
+
style: dropdownStyle
|
|
9294
|
+
},
|
|
9295
|
+
filter && /* @__PURE__ */ React106.createElement("div", { className: "rf-tree-select__filter" }, /* @__PURE__ */ React106.createElement(Search2, { size: 14, className: "rf-tree-select__filter-icon" }), /* @__PURE__ */ React106.createElement(
|
|
9296
|
+
"input",
|
|
9297
|
+
{
|
|
9298
|
+
ref: filterInputRef,
|
|
9299
|
+
className: "rf-tree-select__filter-input",
|
|
9300
|
+
placeholder: "Search\u2026",
|
|
9301
|
+
value: filterQuery,
|
|
9302
|
+
onChange: (e) => setFilterQuery(e.target.value)
|
|
9303
|
+
}
|
|
9304
|
+
), filterQuery && /* @__PURE__ */ React106.createElement(
|
|
9305
|
+
"button",
|
|
9306
|
+
{
|
|
9307
|
+
type: "button",
|
|
9308
|
+
className: "rf-autocomplete__icon-btn",
|
|
9309
|
+
onClick: () => setFilterQuery(""),
|
|
9310
|
+
tabIndex: -1
|
|
9311
|
+
},
|
|
9312
|
+
/* @__PURE__ */ React106.createElement(X3, { size: 12 })
|
|
9313
|
+
)),
|
|
9314
|
+
/* @__PURE__ */ React106.createElement("div", { className: "rf-tree-select__tree" }, filteredTree.length === 0 ? /* @__PURE__ */ React106.createElement("div", { className: "rf-tree-select__empty" }, "No results found") : filteredTree.map((node) => /* @__PURE__ */ React106.createElement(
|
|
9315
|
+
TreeNodeItem,
|
|
9316
|
+
{
|
|
9317
|
+
key: node.id,
|
|
9318
|
+
node,
|
|
9319
|
+
depth: 0,
|
|
9320
|
+
selected: selectedSet,
|
|
9321
|
+
expanded: expandedKeys,
|
|
9322
|
+
selectionMode,
|
|
9323
|
+
onToggleExpand: handleToggleExpand,
|
|
9324
|
+
onSelect: handleSelect,
|
|
9325
|
+
isFiltering: !!filterQuery
|
|
9326
|
+
}
|
|
9327
|
+
)))
|
|
9328
|
+
),
|
|
9329
|
+
document.body
|
|
9330
|
+
));
|
|
9331
|
+
}
|
|
9332
|
+
|
|
9333
|
+
// lib/UserSelectionField/UserSelectionField.tsx
|
|
9334
|
+
import React107 from "react";
|
|
9335
|
+
function getOptionId(opt) {
|
|
9336
|
+
return opt.id ?? opt._id;
|
|
9337
|
+
}
|
|
9338
|
+
function getLabel(opt) {
|
|
9339
|
+
if (!opt.userFirstName) return "";
|
|
9340
|
+
return `${opt.userFirstName} ${opt.userLastName ?? ""}`.trim();
|
|
9341
|
+
}
|
|
9342
|
+
function matchesSearch(opt, query) {
|
|
9343
|
+
const q = query.toLowerCase();
|
|
9344
|
+
return opt.userFirstName?.toLowerCase().includes(q) || opt.userLastName?.toLowerCase().includes(q) || opt.emailId?.toLowerCase().includes(q) || false;
|
|
9345
|
+
}
|
|
9346
|
+
function UserAvatar({ user }) {
|
|
9347
|
+
const initials = (user.userFirstName?.[0] ?? "").toUpperCase() + (user.userLastName?.[0] ?? "").toUpperCase();
|
|
9348
|
+
return /* @__PURE__ */ React107.createElement("span", { style: {
|
|
9349
|
+
width: 28,
|
|
9350
|
+
height: 28,
|
|
9351
|
+
borderRadius: "50%",
|
|
9352
|
+
backgroundColor: "var(--hover-color, #e0e0e0)",
|
|
9353
|
+
border: "1px solid var(--border-color, #ddd)",
|
|
9354
|
+
display: "inline-flex",
|
|
9355
|
+
alignItems: "center",
|
|
9356
|
+
justifyContent: "center",
|
|
9357
|
+
fontSize: "0.7rem",
|
|
9358
|
+
fontWeight: 600,
|
|
9359
|
+
color: "var(--text-secondary, #555)",
|
|
9360
|
+
flexShrink: 0,
|
|
9361
|
+
letterSpacing: "0.02em"
|
|
9362
|
+
} }, initials || "?");
|
|
9363
|
+
}
|
|
9364
|
+
function UserSelectionField({
|
|
9365
|
+
value,
|
|
9366
|
+
onChange,
|
|
9367
|
+
options = [],
|
|
9368
|
+
loading = false,
|
|
9369
|
+
onSearchChange,
|
|
9370
|
+
label = "Select user",
|
|
9371
|
+
multiple = false,
|
|
9372
|
+
limitTags,
|
|
9373
|
+
size = "small",
|
|
9374
|
+
variant = "outlined",
|
|
9375
|
+
disabled = false,
|
|
9376
|
+
error = false,
|
|
9377
|
+
helperText,
|
|
9378
|
+
fullWidth = true,
|
|
9379
|
+
required = false,
|
|
9380
|
+
filterOptions: filterOptionsProp,
|
|
9381
|
+
className,
|
|
9382
|
+
style,
|
|
9383
|
+
sx
|
|
9384
|
+
}) {
|
|
9385
|
+
const handleInputChange = (_, inputValue) => {
|
|
9386
|
+
if (!onSearchChange) return;
|
|
9387
|
+
if (!inputValue) {
|
|
9388
|
+
onSearchChange("");
|
|
9389
|
+
return;
|
|
9390
|
+
}
|
|
9391
|
+
const hasLocalMatch = options.some((opt) => matchesSearch(opt, inputValue));
|
|
9392
|
+
if (!hasLocalMatch) {
|
|
9393
|
+
onSearchChange(inputValue);
|
|
9394
|
+
}
|
|
9395
|
+
};
|
|
9396
|
+
return /* @__PURE__ */ React107.createElement(
|
|
9397
|
+
Autocomplete,
|
|
9398
|
+
{
|
|
9399
|
+
options,
|
|
9400
|
+
value: value ?? (multiple ? [] : null),
|
|
9401
|
+
onChange: (_, newValue) => onChange(newValue),
|
|
9402
|
+
onInputChange: handleInputChange,
|
|
9403
|
+
multiple,
|
|
9404
|
+
limitTags,
|
|
9405
|
+
loading,
|
|
9406
|
+
loadingText: /* @__PURE__ */ React107.createElement("span", { style: { display: "flex", alignItems: "center", gap: 8, padding: "4px 0" } }, /* @__PURE__ */ React107.createElement(circularProgress_default, { size: 16 }), /* @__PURE__ */ React107.createElement("span", { style: { fontSize: "0.875rem", color: "var(--text-secondary)" } }, "Loading\u2026")),
|
|
9407
|
+
getOptionLabel: getLabel,
|
|
9408
|
+
isOptionEqualToValue: (opt, val) => getOptionId(opt) === getOptionId(val),
|
|
9409
|
+
filterOptions: filterOptionsProp ? (opts, inputValue) => filterOptionsProp(opts, inputValue) : (opts, inputValue) => inputValue ? opts.filter((opt) => matchesSearch(opt, inputValue)) : opts,
|
|
9410
|
+
renderOption: (props, option) => {
|
|
9411
|
+
const { key, ...rest } = props;
|
|
9412
|
+
return /* @__PURE__ */ React107.createElement("li", { key, ...rest, style: { padding: "6px 12px", listStyle: "none" } }, /* @__PURE__ */ React107.createElement("span", { style: { display: "flex", alignItems: "center", gap: 10 } }, /* @__PURE__ */ React107.createElement(UserAvatar, { user: option }), /* @__PURE__ */ React107.createElement("span", { style: { display: "flex", flexDirection: "column", minWidth: 0 } }, /* @__PURE__ */ React107.createElement("span", { style: { fontSize: "0.85rem", color: "var(--text-color)", lineHeight: 1.3 } }, option.userFirstName, " ", option.userLastName), /* @__PURE__ */ React107.createElement("span", { style: { fontSize: "0.75rem", color: "var(--text-secondary)", lineHeight: 1.3 } }, option.emailId))));
|
|
9413
|
+
},
|
|
9414
|
+
label,
|
|
9415
|
+
placeholder: label,
|
|
9416
|
+
size,
|
|
9417
|
+
variant,
|
|
9418
|
+
disabled,
|
|
9419
|
+
error,
|
|
9420
|
+
helperText,
|
|
9421
|
+
fullWidth,
|
|
9422
|
+
required,
|
|
9423
|
+
className,
|
|
9424
|
+
style,
|
|
9425
|
+
sx
|
|
9426
|
+
}
|
|
9427
|
+
);
|
|
9428
|
+
}
|
|
9429
|
+
|
|
8810
9430
|
// lib/RufousTextEditor/RufousTextEditor.tsx
|
|
8811
|
-
import
|
|
9431
|
+
import React118, { useMemo as useMemo4, useCallback as useCallback15, useState as useState35, useRef as useRef32, useEffect as useEffect29 } from "react";
|
|
8812
9432
|
import { createPortal as createPortal8 } from "react-dom";
|
|
8813
9433
|
import { useEditor, EditorContent, EditorContext, FloatingMenu, BubbleMenu } from "@tiptap/react";
|
|
8814
9434
|
import StarterKit from "@tiptap/starter-kit";
|
|
@@ -8834,16 +9454,16 @@ import { ReactRenderer } from "@tiptap/react";
|
|
|
8834
9454
|
import tippy from "tippy.js";
|
|
8835
9455
|
|
|
8836
9456
|
// lib/RufousTextEditor/MentionList.tsx
|
|
8837
|
-
import
|
|
9457
|
+
import React108, { forwardRef as forwardRef11, useEffect as useEffect21, useImperativeHandle, useState as useState26 } from "react";
|
|
8838
9458
|
var MentionList = forwardRef11((props, ref) => {
|
|
8839
|
-
const [selectedIndex, setSelectedIndex] =
|
|
9459
|
+
const [selectedIndex, setSelectedIndex] = useState26(0);
|
|
8840
9460
|
const selectItem = (index) => {
|
|
8841
9461
|
const item = props.items[index];
|
|
8842
9462
|
if (item) {
|
|
8843
9463
|
props.command({ id: item.id, label: item.shortName || item.name });
|
|
8844
9464
|
}
|
|
8845
9465
|
};
|
|
8846
|
-
|
|
9466
|
+
useEffect21(() => setSelectedIndex(0), [props.items]);
|
|
8847
9467
|
useImperativeHandle(ref, () => ({
|
|
8848
9468
|
onKeyDown: ({ event }) => {
|
|
8849
9469
|
if (event.key === "ArrowUp") {
|
|
@@ -8862,17 +9482,17 @@ var MentionList = forwardRef11((props, ref) => {
|
|
|
8862
9482
|
}
|
|
8863
9483
|
}));
|
|
8864
9484
|
if (!props.items.length) {
|
|
8865
|
-
return /* @__PURE__ */
|
|
9485
|
+
return /* @__PURE__ */ React108.createElement("div", { className: "rf-rte-mention-dropdown" }, /* @__PURE__ */ React108.createElement("div", { className: "rf-rte-mention-item rf-rte-mention-no-result" }, "No results"));
|
|
8866
9486
|
}
|
|
8867
|
-
return /* @__PURE__ */
|
|
9487
|
+
return /* @__PURE__ */ React108.createElement("div", { className: "rf-rte-mention-dropdown" }, props.items.map((item, index) => /* @__PURE__ */ React108.createElement(
|
|
8868
9488
|
"button",
|
|
8869
9489
|
{
|
|
8870
9490
|
className: `rf-rte-mention-item ${index === selectedIndex ? "is-selected" : ""}`,
|
|
8871
9491
|
key: item.id,
|
|
8872
9492
|
onClick: () => selectItem(index)
|
|
8873
9493
|
},
|
|
8874
|
-
/* @__PURE__ */
|
|
8875
|
-
/* @__PURE__ */
|
|
9494
|
+
/* @__PURE__ */ React108.createElement("span", { className: "rf-rte-mention-avatar" }, item.avatar || item.name.charAt(0).toUpperCase()),
|
|
9495
|
+
/* @__PURE__ */ React108.createElement("span", { className: "rf-rte-mention-name" }, item.name)
|
|
8876
9496
|
)));
|
|
8877
9497
|
});
|
|
8878
9498
|
MentionList.displayName = "MentionList";
|
|
@@ -8930,21 +9550,21 @@ function createMentionSuggestion(users) {
|
|
|
8930
9550
|
}
|
|
8931
9551
|
|
|
8932
9552
|
// lib/RufousTextEditor/Toolbar.tsx
|
|
8933
|
-
import
|
|
9553
|
+
import React114, { useState as useState31, useRef as useRef28, useEffect as useEffect25, useCallback as useCallback14 } from "react";
|
|
8934
9554
|
import { createPortal as createPortal4 } from "react-dom";
|
|
8935
9555
|
|
|
8936
9556
|
// lib/RufousTextEditor/TextToSpeech.tsx
|
|
8937
|
-
import
|
|
9557
|
+
import React109, { useState as useState27, useEffect as useEffect22, useRef as useRef25, useCallback as useCallback11, forwardRef as forwardRef12, useImperativeHandle as useImperativeHandle2 } from "react";
|
|
8938
9558
|
var TextToSpeech = forwardRef12(({ editor, onTextToSpeech }, ref) => {
|
|
8939
|
-
const [speaking, setSpeaking] =
|
|
8940
|
-
const [paused, setPaused] =
|
|
8941
|
-
const [voices, setVoices] =
|
|
8942
|
-
const [selectedVoice, setSelectedVoice] =
|
|
8943
|
-
const [rate, setRate] =
|
|
8944
|
-
const [showPanel, setShowPanel] =
|
|
8945
|
-
const utteranceRef =
|
|
8946
|
-
const panelRef =
|
|
8947
|
-
|
|
9559
|
+
const [speaking, setSpeaking] = useState27(false);
|
|
9560
|
+
const [paused, setPaused] = useState27(false);
|
|
9561
|
+
const [voices, setVoices] = useState27([]);
|
|
9562
|
+
const [selectedVoice, setSelectedVoice] = useState27("");
|
|
9563
|
+
const [rate, setRate] = useState27(1);
|
|
9564
|
+
const [showPanel, setShowPanel] = useState27(false);
|
|
9565
|
+
const utteranceRef = useRef25(null);
|
|
9566
|
+
const panelRef = useRef25(null);
|
|
9567
|
+
useEffect22(() => {
|
|
8948
9568
|
const synth = window.speechSynthesis;
|
|
8949
9569
|
const loadVoices = () => {
|
|
8950
9570
|
const available = synth.getVoices();
|
|
@@ -8962,7 +9582,7 @@ var TextToSpeech = forwardRef12(({ editor, onTextToSpeech }, ref) => {
|
|
|
8962
9582
|
synth.removeEventListener("voiceschanged", loadVoices);
|
|
8963
9583
|
};
|
|
8964
9584
|
}, [selectedVoice]);
|
|
8965
|
-
|
|
9585
|
+
useEffect22(() => {
|
|
8966
9586
|
const handleClick = (e) => {
|
|
8967
9587
|
if (panelRef.current && !panelRef.current.contains(e.target)) {
|
|
8968
9588
|
setShowPanel(false);
|
|
@@ -8971,7 +9591,7 @@ var TextToSpeech = forwardRef12(({ editor, onTextToSpeech }, ref) => {
|
|
|
8971
9591
|
document.addEventListener("mousedown", handleClick);
|
|
8972
9592
|
return () => document.removeEventListener("mousedown", handleClick);
|
|
8973
9593
|
}, []);
|
|
8974
|
-
const getTextToSpeak =
|
|
9594
|
+
const getTextToSpeak = useCallback11(() => {
|
|
8975
9595
|
if (!editor) return "";
|
|
8976
9596
|
const { from, to, empty } = editor.state.selection;
|
|
8977
9597
|
if (!empty) {
|
|
@@ -8979,7 +9599,7 @@ var TextToSpeech = forwardRef12(({ editor, onTextToSpeech }, ref) => {
|
|
|
8979
9599
|
}
|
|
8980
9600
|
return editor.getText();
|
|
8981
9601
|
}, [editor]);
|
|
8982
|
-
const handleSpeak =
|
|
9602
|
+
const handleSpeak = useCallback11(async () => {
|
|
8983
9603
|
const text = getTextToSpeak();
|
|
8984
9604
|
if (!text.trim()) return;
|
|
8985
9605
|
if (onTextToSpeech) {
|
|
@@ -9021,25 +9641,25 @@ var TextToSpeech = forwardRef12(({ editor, onTextToSpeech }, ref) => {
|
|
|
9021
9641
|
setSpeaking(true);
|
|
9022
9642
|
setPaused(false);
|
|
9023
9643
|
}, [getTextToSpeak, voices, selectedVoice, rate, onTextToSpeech]);
|
|
9024
|
-
const handlePause =
|
|
9644
|
+
const handlePause = useCallback11(() => {
|
|
9025
9645
|
if (window.speechSynthesis.speaking && !window.speechSynthesis.paused) {
|
|
9026
9646
|
window.speechSynthesis.pause();
|
|
9027
9647
|
setPaused(true);
|
|
9028
9648
|
}
|
|
9029
9649
|
}, []);
|
|
9030
|
-
const handleResume =
|
|
9650
|
+
const handleResume = useCallback11(() => {
|
|
9031
9651
|
if (window.speechSynthesis.paused) {
|
|
9032
9652
|
window.speechSynthesis.resume();
|
|
9033
9653
|
setPaused(false);
|
|
9034
9654
|
}
|
|
9035
9655
|
}, []);
|
|
9036
|
-
const handleStop =
|
|
9656
|
+
const handleStop = useCallback11(() => {
|
|
9037
9657
|
window.speechSynthesis.cancel();
|
|
9038
9658
|
setSpeaking(false);
|
|
9039
9659
|
setPaused(false);
|
|
9040
9660
|
}, []);
|
|
9041
9661
|
useImperativeHandle2(ref, () => ({ stop: handleStop }), [handleStop]);
|
|
9042
|
-
return /* @__PURE__ */
|
|
9662
|
+
return /* @__PURE__ */ React109.createElement("div", { className: "tts-wrapper", ref: panelRef }, /* @__PURE__ */ React109.createElement(Tooltip, { title: "Text to Speech", placement: "top" }, /* @__PURE__ */ React109.createElement(
|
|
9043
9663
|
"button",
|
|
9044
9664
|
{
|
|
9045
9665
|
className: `toolbar-btn ${speaking ? "is-active" : ""}`,
|
|
@@ -9052,15 +9672,15 @@ var TextToSpeech = forwardRef12(({ editor, onTextToSpeech }, ref) => {
|
|
|
9052
9672
|
}
|
|
9053
9673
|
},
|
|
9054
9674
|
speaking ? "\u23F9" : "\u{1F50A}"
|
|
9055
|
-
)), showPanel && !speaking && /* @__PURE__ */
|
|
9675
|
+
)), showPanel && !speaking && /* @__PURE__ */ React109.createElement("div", { className: "tts-panel" }, /* @__PURE__ */ React109.createElement("div", { className: "tts-panel-header" }, "Text to Speech"), /* @__PURE__ */ React109.createElement("label", { className: "tts-label" }, "Voice"), /* @__PURE__ */ React109.createElement(
|
|
9056
9676
|
"select",
|
|
9057
9677
|
{
|
|
9058
9678
|
className: "tts-select",
|
|
9059
9679
|
value: selectedVoice,
|
|
9060
9680
|
onChange: (e) => setSelectedVoice(e.target.value)
|
|
9061
9681
|
},
|
|
9062
|
-
voices.map((v) => /* @__PURE__ */
|
|
9063
|
-
), /* @__PURE__ */
|
|
9682
|
+
voices.map((v) => /* @__PURE__ */ React109.createElement("option", { key: v.name, value: v.name }, v.name, " (", v.lang, ")"))
|
|
9683
|
+
), /* @__PURE__ */ React109.createElement("label", { className: "tts-label" }, "Speed: ", rate, "x"), /* @__PURE__ */ React109.createElement(
|
|
9064
9684
|
"input",
|
|
9065
9685
|
{
|
|
9066
9686
|
type: "range",
|
|
@@ -9071,26 +9691,26 @@ var TextToSpeech = forwardRef12(({ editor, onTextToSpeech }, ref) => {
|
|
|
9071
9691
|
value: rate,
|
|
9072
9692
|
onChange: (e) => setRate(Number(e.target.value))
|
|
9073
9693
|
}
|
|
9074
|
-
), /* @__PURE__ */
|
|
9694
|
+
), /* @__PURE__ */ React109.createElement("div", { className: "tts-info" }, editor && !editor.state.selection.empty ? "Will read selected text" : "Will read all editor text"), /* @__PURE__ */ React109.createElement("button", { className: "tts-speak-btn", onClick: () => {
|
|
9075
9695
|
handleSpeak();
|
|
9076
9696
|
setShowPanel(false);
|
|
9077
|
-
} }, "\u25B6 Speak")), speaking && /* @__PURE__ */
|
|
9697
|
+
} }, "\u25B6 Speak")), speaking && /* @__PURE__ */ React109.createElement("div", { className: "tts-controls" }, paused ? /* @__PURE__ */ React109.createElement(Tooltip, { title: "Resume", placement: "top" }, /* @__PURE__ */ React109.createElement("button", { className: "toolbar-btn", onClick: handleResume }, "\u25B6")) : /* @__PURE__ */ React109.createElement(Tooltip, { title: "Pause", placement: "top" }, /* @__PURE__ */ React109.createElement("button", { className: "toolbar-btn", onClick: handlePause }, "\u275A\u275A")), /* @__PURE__ */ React109.createElement(Tooltip, { title: "Stop", placement: "top" }, /* @__PURE__ */ React109.createElement("button", { className: "toolbar-btn", onClick: handleStop }, "\u25A0"))));
|
|
9078
9698
|
});
|
|
9079
9699
|
var TextToSpeech_default = TextToSpeech;
|
|
9080
9700
|
|
|
9081
9701
|
// lib/RufousTextEditor/SpeechToText.tsx
|
|
9082
|
-
import
|
|
9702
|
+
import React110, { useState as useState28, useRef as useRef26, useCallback as useCallback12, useEffect as useEffect23, forwardRef as forwardRef13, useImperativeHandle as useImperativeHandle3 } from "react";
|
|
9083
9703
|
var SpeechToText = forwardRef13(({ editor, onSpeechToText }, ref) => {
|
|
9084
|
-
const [listening, setListening] =
|
|
9085
|
-
const [showPanel, setShowPanel] =
|
|
9086
|
-
const [language, setLanguage] =
|
|
9087
|
-
const [interim, setInterim] =
|
|
9088
|
-
const recognitionRef =
|
|
9089
|
-
const panelRef =
|
|
9090
|
-
const isListeningRef =
|
|
9704
|
+
const [listening, setListening] = useState28(false);
|
|
9705
|
+
const [showPanel, setShowPanel] = useState28(false);
|
|
9706
|
+
const [language, setLanguage] = useState28("en-US");
|
|
9707
|
+
const [interim, setInterim] = useState28("");
|
|
9708
|
+
const recognitionRef = useRef26(null);
|
|
9709
|
+
const panelRef = useRef26(null);
|
|
9710
|
+
const isListeningRef = useRef26(false);
|
|
9091
9711
|
const SpeechRecognitionAPI = typeof window !== "undefined" ? window.SpeechRecognition || window.webkitSpeechRecognition : null;
|
|
9092
9712
|
const supported = !!SpeechRecognitionAPI;
|
|
9093
|
-
|
|
9713
|
+
useEffect23(() => {
|
|
9094
9714
|
const handleClick = (e) => {
|
|
9095
9715
|
if (panelRef.current && !panelRef.current.contains(e.target)) {
|
|
9096
9716
|
setShowPanel(false);
|
|
@@ -9099,7 +9719,7 @@ var SpeechToText = forwardRef13(({ editor, onSpeechToText }, ref) => {
|
|
|
9099
9719
|
document.addEventListener("mousedown", handleClick);
|
|
9100
9720
|
return () => document.removeEventListener("mousedown", handleClick);
|
|
9101
9721
|
}, []);
|
|
9102
|
-
const createRecognition =
|
|
9722
|
+
const createRecognition = useCallback12(() => {
|
|
9103
9723
|
if (!supported) return null;
|
|
9104
9724
|
const recognition = new SpeechRecognitionAPI();
|
|
9105
9725
|
recognition.lang = language;
|
|
@@ -9108,7 +9728,7 @@ var SpeechToText = forwardRef13(({ editor, onSpeechToText }, ref) => {
|
|
|
9108
9728
|
recognition.maxAlternatives = 1;
|
|
9109
9729
|
return recognition;
|
|
9110
9730
|
}, [supported, language]);
|
|
9111
|
-
const startSession =
|
|
9731
|
+
const startSession = useCallback12((recognition) => {
|
|
9112
9732
|
if (!recognition || !editor) return;
|
|
9113
9733
|
recognition.onresult = async (event) => {
|
|
9114
9734
|
let finalText = "";
|
|
@@ -9163,7 +9783,7 @@ var SpeechToText = forwardRef13(({ editor, onSpeechToText }, ref) => {
|
|
|
9163
9783
|
}
|
|
9164
9784
|
};
|
|
9165
9785
|
}, [editor, createRecognition, onSpeechToText]);
|
|
9166
|
-
const startListening =
|
|
9786
|
+
const startListening = useCallback12(() => {
|
|
9167
9787
|
if (!supported || !editor) return;
|
|
9168
9788
|
const recognition = createRecognition();
|
|
9169
9789
|
if (!recognition) return;
|
|
@@ -9179,7 +9799,7 @@ var SpeechToText = forwardRef13(({ editor, onSpeechToText }, ref) => {
|
|
|
9179
9799
|
setListening(false);
|
|
9180
9800
|
}
|
|
9181
9801
|
}, [supported, editor, createRecognition, startSession]);
|
|
9182
|
-
const stopListening =
|
|
9802
|
+
const stopListening = useCallback12(() => {
|
|
9183
9803
|
isListeningRef.current = false;
|
|
9184
9804
|
if (recognitionRef.current) {
|
|
9185
9805
|
try {
|
|
@@ -9193,7 +9813,7 @@ var SpeechToText = forwardRef13(({ editor, onSpeechToText }, ref) => {
|
|
|
9193
9813
|
}, []);
|
|
9194
9814
|
useImperativeHandle3(ref, () => ({ stop: stopListening }), [stopListening]);
|
|
9195
9815
|
if (!supported) {
|
|
9196
|
-
return /* @__PURE__ */
|
|
9816
|
+
return /* @__PURE__ */ React110.createElement(Tooltip, { title: "Speech recognition not supported in this browser", placement: "top" }, /* @__PURE__ */ React110.createElement("button", { className: "toolbar-btn", disabled: true }, "\u{1F3A4}"));
|
|
9197
9817
|
}
|
|
9198
9818
|
const LANGUAGES2 = [
|
|
9199
9819
|
{ code: "en-US", label: "English (US)" },
|
|
@@ -9215,7 +9835,7 @@ var SpeechToText = forwardRef13(({ editor, onSpeechToText }, ref) => {
|
|
|
9215
9835
|
{ code: "kn-IN", label: "Kannada" },
|
|
9216
9836
|
{ code: "ml-IN", label: "Malayalam" }
|
|
9217
9837
|
];
|
|
9218
|
-
return /* @__PURE__ */
|
|
9838
|
+
return /* @__PURE__ */ React110.createElement("div", { className: "stt-wrapper", ref: panelRef }, /* @__PURE__ */ React110.createElement(Tooltip, { title: listening ? "Stop recording" : "Speech to Text", placement: "top" }, /* @__PURE__ */ React110.createElement(
|
|
9219
9839
|
"button",
|
|
9220
9840
|
{
|
|
9221
9841
|
className: `toolbar-btn ${listening ? "is-active stt-recording" : ""}`,
|
|
@@ -9228,20 +9848,20 @@ var SpeechToText = forwardRef13(({ editor, onSpeechToText }, ref) => {
|
|
|
9228
9848
|
}
|
|
9229
9849
|
},
|
|
9230
9850
|
"\u{1F3A4}"
|
|
9231
|
-
)), showPanel && !listening && /* @__PURE__ */
|
|
9851
|
+
)), showPanel && !listening && /* @__PURE__ */ React110.createElement("div", { className: "stt-panel" }, /* @__PURE__ */ React110.createElement("div", { className: "stt-panel-header" }, "Speech to Text"), /* @__PURE__ */ React110.createElement("label", { className: "stt-label" }, "Language"), /* @__PURE__ */ React110.createElement(
|
|
9232
9852
|
"select",
|
|
9233
9853
|
{
|
|
9234
9854
|
className: "stt-select",
|
|
9235
9855
|
value: language,
|
|
9236
9856
|
onChange: (e) => setLanguage(e.target.value)
|
|
9237
9857
|
},
|
|
9238
|
-
LANGUAGES2.map((l) => /* @__PURE__ */
|
|
9239
|
-
), /* @__PURE__ */
|
|
9858
|
+
LANGUAGES2.map((l) => /* @__PURE__ */ React110.createElement("option", { key: l.code, value: l.code }, l.label))
|
|
9859
|
+
), /* @__PURE__ */ React110.createElement("div", { className: "stt-info" }, "Speak into your microphone and the text will be typed into the editor."), /* @__PURE__ */ React110.createElement("button", { className: "stt-start-btn", onClick: startListening }, "\u{1F3A4} Start Listening")), listening && interim && /* @__PURE__ */ React110.createElement("div", { className: "stt-interim" }, interim));
|
|
9240
9860
|
});
|
|
9241
9861
|
var SpeechToText_default = SpeechToText;
|
|
9242
9862
|
|
|
9243
9863
|
// lib/RufousTextEditor/AICommands.tsx
|
|
9244
|
-
import
|
|
9864
|
+
import React111, { useState as useState29, useRef as useRef27, useEffect as useEffect24, useCallback as useCallback13 } from "react";
|
|
9245
9865
|
import { createPortal as createPortal2 } from "react-dom";
|
|
9246
9866
|
var AI_COMMANDS = [
|
|
9247
9867
|
{ id: "improve", label: "Improve writing", prompt: "Improve the following text to make it clearer, more engaging, and well-structured. Return only the improved text, no explanations." },
|
|
@@ -9289,16 +9909,16 @@ var callOpenAI = async (prompt, text, previousResults = []) => {
|
|
|
9289
9909
|
return data.choices?.[0]?.message?.content?.trim() || "";
|
|
9290
9910
|
};
|
|
9291
9911
|
var AICommands = ({ editor, onAICommand }) => {
|
|
9292
|
-
const [open, setOpen] =
|
|
9293
|
-
const [showModal, setShowModal] =
|
|
9294
|
-
const [loading, setLoading] =
|
|
9295
|
-
const [promptText, setPromptText] =
|
|
9296
|
-
const [resultText, setResultText] =
|
|
9297
|
-
const [originalText, setOriginalText] =
|
|
9298
|
-
const [selectionRange, setSelectionRange] =
|
|
9299
|
-
const [previousResults, setPreviousResults] =
|
|
9300
|
-
const panelRef =
|
|
9301
|
-
|
|
9912
|
+
const [open, setOpen] = useState29(false);
|
|
9913
|
+
const [showModal, setShowModal] = useState29(false);
|
|
9914
|
+
const [loading, setLoading] = useState29(false);
|
|
9915
|
+
const [promptText, setPromptText] = useState29("");
|
|
9916
|
+
const [resultText, setResultText] = useState29("");
|
|
9917
|
+
const [originalText, setOriginalText] = useState29("");
|
|
9918
|
+
const [selectionRange, setSelectionRange] = useState29(null);
|
|
9919
|
+
const [previousResults, setPreviousResults] = useState29([]);
|
|
9920
|
+
const panelRef = useRef27(null);
|
|
9921
|
+
useEffect24(() => {
|
|
9302
9922
|
const handleClick = (e) => {
|
|
9303
9923
|
if (panelRef.current && !panelRef.current.contains(e.target)) {
|
|
9304
9924
|
setOpen(false);
|
|
@@ -9307,7 +9927,7 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9307
9927
|
document.addEventListener("mousedown", handleClick);
|
|
9308
9928
|
return () => document.removeEventListener("mousedown", handleClick);
|
|
9309
9929
|
}, []);
|
|
9310
|
-
const getSelectedText =
|
|
9930
|
+
const getSelectedText = useCallback13(() => {
|
|
9311
9931
|
if (!editor) return { text: "", range: null };
|
|
9312
9932
|
const { from, to, empty } = editor.state.selection;
|
|
9313
9933
|
if (!empty) {
|
|
@@ -9315,7 +9935,7 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9315
9935
|
}
|
|
9316
9936
|
return { text: editor.getText(), range: null };
|
|
9317
9937
|
}, [editor]);
|
|
9318
|
-
const fetchAIResult =
|
|
9938
|
+
const fetchAIResult = useCallback13(async (prompt, text, prevResults = []) => {
|
|
9319
9939
|
setLoading(true);
|
|
9320
9940
|
setResultText("");
|
|
9321
9941
|
try {
|
|
@@ -9333,7 +9953,7 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9333
9953
|
setLoading(false);
|
|
9334
9954
|
}
|
|
9335
9955
|
}, [onAICommand]);
|
|
9336
|
-
const handleCommandSelect =
|
|
9956
|
+
const handleCommandSelect = useCallback13((command) => {
|
|
9337
9957
|
const { text, range } = getSelectedText();
|
|
9338
9958
|
if (!text.trim()) return;
|
|
9339
9959
|
setOriginalText(text);
|
|
@@ -9344,7 +9964,7 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9344
9964
|
setShowModal(true);
|
|
9345
9965
|
fetchAIResult(command.prompt, text, []);
|
|
9346
9966
|
}, [getSelectedText, fetchAIResult]);
|
|
9347
|
-
const handleInsert =
|
|
9967
|
+
const handleInsert = useCallback13(() => {
|
|
9348
9968
|
if (!resultText || !editor) return;
|
|
9349
9969
|
if (selectionRange) {
|
|
9350
9970
|
editor.chain().focus().deleteRange(selectionRange).insertContentAt(selectionRange.from, resultText).run();
|
|
@@ -9354,7 +9974,7 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9354
9974
|
setShowModal(false);
|
|
9355
9975
|
setResultText("");
|
|
9356
9976
|
}, [editor, resultText, selectionRange]);
|
|
9357
|
-
const handleInsertAfter =
|
|
9977
|
+
const handleInsertAfter = useCallback13(() => {
|
|
9358
9978
|
if (!resultText || !editor) return;
|
|
9359
9979
|
if (selectionRange) {
|
|
9360
9980
|
editor.chain().focus().insertContentAt(selectionRange.to, "\n" + resultText).run();
|
|
@@ -9369,11 +9989,11 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9369
9989
|
setShowModal(false);
|
|
9370
9990
|
setResultText("");
|
|
9371
9991
|
}, [editor, resultText, selectionRange]);
|
|
9372
|
-
const handleRefresh =
|
|
9992
|
+
const handleRefresh = useCallback13(() => {
|
|
9373
9993
|
if (!originalText.trim()) return;
|
|
9374
9994
|
fetchAIResult(promptText, originalText, previousResults);
|
|
9375
9995
|
}, [originalText, promptText, previousResults, fetchAIResult]);
|
|
9376
|
-
const handleCancel =
|
|
9996
|
+
const handleCancel = useCallback13(() => {
|
|
9377
9997
|
setShowModal(false);
|
|
9378
9998
|
setResultText("");
|
|
9379
9999
|
setPromptText("");
|
|
@@ -9382,15 +10002,15 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9382
10002
|
setPreviousResults([]);
|
|
9383
10003
|
}, []);
|
|
9384
10004
|
if (!editor) return null;
|
|
9385
|
-
return /* @__PURE__ */
|
|
10005
|
+
return /* @__PURE__ */ React111.createElement(React111.Fragment, null, /* @__PURE__ */ React111.createElement("div", { className: "ai-commands-wrapper", ref: panelRef }, /* @__PURE__ */ React111.createElement(Tooltip, { title: "AI Commands", placement: "top" }, /* @__PURE__ */ React111.createElement(
|
|
9386
10006
|
"button",
|
|
9387
10007
|
{
|
|
9388
10008
|
className: `toolbar-btn ${open ? "is-active" : ""}`,
|
|
9389
10009
|
onClick: () => setOpen(!open)
|
|
9390
10010
|
},
|
|
9391
|
-
/* @__PURE__ */
|
|
9392
|
-
/* @__PURE__ */
|
|
9393
|
-
)), open && /* @__PURE__ */
|
|
10011
|
+
/* @__PURE__ */ React111.createElement("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "currentColor", stroke: "none" }, /* @__PURE__ */ React111.createElement("path", { d: "M9 2l1.5 3L14 6.5 10.5 8 9 11 7.5 8 4 6.5 7.5 5zM18 10l1 2 2 1-2 1-1 2-1-2-2-1 2-1zM5 17l1.5 3L10 21.5 6.5 23 5 26 3.5 23 0 21.5 3.5 20z" })),
|
|
10012
|
+
/* @__PURE__ */ React111.createElement("span", { className: "dropdown-arrow" }, "\u25BE")
|
|
10013
|
+
)), open && /* @__PURE__ */ React111.createElement("div", { className: "ai-commands-panel" }, /* @__PURE__ */ React111.createElement("div", { className: "ai-commands-header" }, "AI Commands"), /* @__PURE__ */ React111.createElement("div", { className: "ai-commands-list" }, AI_COMMANDS.map((cmd) => /* @__PURE__ */ React111.createElement(
|
|
9394
10014
|
"button",
|
|
9395
10015
|
{
|
|
9396
10016
|
key: cmd.id,
|
|
@@ -9398,8 +10018,8 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9398
10018
|
onClick: () => handleCommandSelect(cmd)
|
|
9399
10019
|
},
|
|
9400
10020
|
cmd.label
|
|
9401
|
-
))), /* @__PURE__ */
|
|
9402
|
-
/* @__PURE__ */
|
|
10021
|
+
))), /* @__PURE__ */ React111.createElement("div", { className: "ai-commands-hint" }, editor.state.selection.empty ? "Will apply to all text" : "Will apply to selected text"))), showModal && createPortal2(
|
|
10022
|
+
/* @__PURE__ */ React111.createElement("div", { className: "ai-modal-overlay", onMouseDown: handleCancel }, /* @__PURE__ */ React111.createElement("div", { className: "ai-modal", onMouseDown: (e) => e.stopPropagation() }, /* @__PURE__ */ React111.createElement("div", { className: "ai-modal-header" }, /* @__PURE__ */ React111.createElement("span", { className: "ai-modal-title" }, "AI Assistant"), /* @__PURE__ */ React111.createElement("button", { className: "ai-modal-close", onClick: handleCancel }, "\xD7")), /* @__PURE__ */ React111.createElement("div", { className: "ai-modal-prompt-section" }, /* @__PURE__ */ React111.createElement("label", { className: "ai-modal-label" }, "Prompt"), /* @__PURE__ */ React111.createElement("div", { className: "ai-modal-prompt-row" }, /* @__PURE__ */ React111.createElement(
|
|
9403
10023
|
"textarea",
|
|
9404
10024
|
{
|
|
9405
10025
|
className: "ai-modal-prompt",
|
|
@@ -9407,15 +10027,15 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9407
10027
|
onChange: (e) => setPromptText(e.target.value),
|
|
9408
10028
|
rows: 3
|
|
9409
10029
|
}
|
|
9410
|
-
), /* @__PURE__ */
|
|
10030
|
+
), /* @__PURE__ */ React111.createElement(Tooltip, { title: "Run with custom prompt", placement: "top" }, /* @__PURE__ */ React111.createElement(
|
|
9411
10031
|
"button",
|
|
9412
10032
|
{
|
|
9413
10033
|
className: "ai-modal-robot-btn",
|
|
9414
10034
|
onClick: () => fetchAIResult(promptText, originalText),
|
|
9415
10035
|
disabled: loading
|
|
9416
10036
|
},
|
|
9417
|
-
/* @__PURE__ */
|
|
9418
|
-
)))), /* @__PURE__ */
|
|
10037
|
+
/* @__PURE__ */ React111.createElement("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ React111.createElement("rect", { x: "3", y: "11", width: "18", height: "10", rx: "2" }), /* @__PURE__ */ React111.createElement("circle", { cx: "9", cy: "16", r: "1" }), /* @__PURE__ */ React111.createElement("circle", { cx: "15", cy: "16", r: "1" }), /* @__PURE__ */ React111.createElement("path", { d: "M12 2v4" }), /* @__PURE__ */ React111.createElement("path", { d: "M8 7h8" }))
|
|
10038
|
+
)))), /* @__PURE__ */ React111.createElement("div", { className: "ai-modal-actions" }, /* @__PURE__ */ React111.createElement(
|
|
9419
10039
|
"button",
|
|
9420
10040
|
{
|
|
9421
10041
|
className: "ai-modal-action-btn ai-modal-insert-btn",
|
|
@@ -9423,7 +10043,7 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9423
10043
|
disabled: loading || !resultText
|
|
9424
10044
|
},
|
|
9425
10045
|
"Insert"
|
|
9426
|
-
), /* @__PURE__ */
|
|
10046
|
+
), /* @__PURE__ */ React111.createElement(
|
|
9427
10047
|
"button",
|
|
9428
10048
|
{
|
|
9429
10049
|
className: "ai-modal-action-btn ai-modal-insert-after-btn ms-2",
|
|
@@ -9431,22 +10051,22 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9431
10051
|
disabled: loading || !resultText
|
|
9432
10052
|
},
|
|
9433
10053
|
"Insert After"
|
|
9434
|
-
), /* @__PURE__ */
|
|
10054
|
+
), /* @__PURE__ */ React111.createElement(Tooltip, { title: "Generate another response", placement: "top" }, /* @__PURE__ */ React111.createElement(
|
|
9435
10055
|
"button",
|
|
9436
10056
|
{
|
|
9437
10057
|
className: "ai-modal-action-btn ai-modal-refresh-btn",
|
|
9438
10058
|
onClick: handleRefresh,
|
|
9439
10059
|
disabled: loading
|
|
9440
10060
|
},
|
|
9441
|
-
/* @__PURE__ */
|
|
9442
|
-
))), /* @__PURE__ */
|
|
10061
|
+
/* @__PURE__ */ React111.createElement("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ React111.createElement("path", { d: "M21 2v6h-6" }), /* @__PURE__ */ React111.createElement("path", { d: "M3 12a9 9 0 0 1 15-6.7L21 8" }), /* @__PURE__ */ React111.createElement("path", { d: "M3 22v-6h6" }), /* @__PURE__ */ React111.createElement("path", { d: "M21 12a9 9 0 0 1-15 6.7L3 16" }))
|
|
10062
|
+
))), /* @__PURE__ */ React111.createElement("div", { className: "ai-modal-result-section" }, loading ? /* @__PURE__ */ React111.createElement("div", { className: "ai-modal-loading" }, /* @__PURE__ */ React111.createElement("span", { className: "ai-spinner" }), /* @__PURE__ */ React111.createElement("span", null, "Generating response...")) : /* @__PURE__ */ React111.createElement("div", { className: "ai-modal-result" }, resultText)), /* @__PURE__ */ React111.createElement("div", { className: "ai-modal-footer" }, /* @__PURE__ */ React111.createElement("button", { className: "ai-modal-cancel-btn", onClick: handleCancel }, "CANCEL")))),
|
|
9443
10063
|
document.body
|
|
9444
10064
|
));
|
|
9445
10065
|
};
|
|
9446
10066
|
var AICommands_default = AICommands;
|
|
9447
10067
|
|
|
9448
10068
|
// lib/RufousTextEditor/TranslateModal.tsx
|
|
9449
|
-
import
|
|
10069
|
+
import React112, { useState as useState30, useMemo as useMemo3 } from "react";
|
|
9450
10070
|
import { createPortal as createPortal3 } from "react-dom";
|
|
9451
10071
|
var LANGUAGES = [
|
|
9452
10072
|
{ code: "af", name: "Afrikaans" },
|
|
@@ -9586,12 +10206,12 @@ async function translateText(text, sourceLang, targetLang) {
|
|
|
9586
10206
|
return null;
|
|
9587
10207
|
}
|
|
9588
10208
|
var TranslateModal = ({ editor, onClose, onTranslate, initialSource, initialTarget, onLangChange }) => {
|
|
9589
|
-
const [sourceLang, setSourceLang] =
|
|
9590
|
-
const [targetLang, setTargetLang] =
|
|
9591
|
-
const [sourceFilter, setSourceFilter] =
|
|
9592
|
-
const [targetFilter, setTargetFilter] =
|
|
9593
|
-
const [translating, setTranslating] =
|
|
9594
|
-
const [error, setError] =
|
|
10209
|
+
const [sourceLang, setSourceLang] = useState30(initialSource || "en");
|
|
10210
|
+
const [targetLang, setTargetLang] = useState30(initialTarget || "hi");
|
|
10211
|
+
const [sourceFilter, setSourceFilter] = useState30("");
|
|
10212
|
+
const [targetFilter, setTargetFilter] = useState30("");
|
|
10213
|
+
const [translating, setTranslating] = useState30(false);
|
|
10214
|
+
const [error, setError] = useState30("");
|
|
9595
10215
|
const filteredSource = useMemo3(() => LANGUAGES.filter(
|
|
9596
10216
|
(l) => l.name.toLowerCase().includes(sourceFilter.toLowerCase()) || l.code.toLowerCase().includes(sourceFilter.toLowerCase())
|
|
9597
10217
|
), [sourceFilter]);
|
|
@@ -9639,7 +10259,7 @@ var TranslateModal = ({ editor, onClose, onTranslate, initialSource, initialTarg
|
|
|
9639
10259
|
}
|
|
9640
10260
|
};
|
|
9641
10261
|
return createPortal3(
|
|
9642
|
-
/* @__PURE__ */
|
|
10262
|
+
/* @__PURE__ */ React112.createElement("div", { className: "modal-overlay", onClick: onClose }, /* @__PURE__ */ React112.createElement("div", { className: "modal-content translate-modal", onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ React112.createElement("div", { className: "modal-header" }, /* @__PURE__ */ React112.createElement("h3", null, "Translate options"), /* @__PURE__ */ React112.createElement("button", { className: "modal-close", onClick: onClose }, "\xD7")), /* @__PURE__ */ React112.createElement("div", { className: "modal-body" }, /* @__PURE__ */ React112.createElement("div", { className: "translate-columns" }, /* @__PURE__ */ React112.createElement("div", { className: "translate-col" }, /* @__PURE__ */ React112.createElement("div", { className: "translate-filter" }, /* @__PURE__ */ React112.createElement(
|
|
9643
10263
|
"input",
|
|
9644
10264
|
{
|
|
9645
10265
|
type: "text",
|
|
@@ -9648,16 +10268,16 @@ var TranslateModal = ({ editor, onClose, onTranslate, initialSource, initialTarg
|
|
|
9648
10268
|
onChange: (e) => setSourceFilter(e.target.value),
|
|
9649
10269
|
className: "translate-filter-input"
|
|
9650
10270
|
}
|
|
9651
|
-
)), /* @__PURE__ */
|
|
10271
|
+
)), /* @__PURE__ */ React112.createElement("div", { className: "translate-list" }, filteredSource.map((lang) => /* @__PURE__ */ React112.createElement(
|
|
9652
10272
|
"button",
|
|
9653
10273
|
{
|
|
9654
10274
|
key: lang.code,
|
|
9655
10275
|
className: `translate-item ${sourceLang === lang.code ? "active" : ""}`,
|
|
9656
10276
|
onClick: () => setSourceLang(lang.code)
|
|
9657
10277
|
},
|
|
9658
|
-
/* @__PURE__ */
|
|
9659
|
-
/* @__PURE__ */
|
|
9660
|
-
)))), /* @__PURE__ */
|
|
10278
|
+
/* @__PURE__ */ React112.createElement("span", { className: "translate-code" }, lang.code),
|
|
10279
|
+
/* @__PURE__ */ React112.createElement("span", { className: "translate-name" }, lang.name)
|
|
10280
|
+
)))), /* @__PURE__ */ React112.createElement("div", { className: "translate-swap" }, /* @__PURE__ */ React112.createElement(Tooltip, { title: "Swap languages", placement: "top" }, /* @__PURE__ */ React112.createElement("button", { className: "translate-swap-btn", onClick: handleSwap }, "\u21C4"))), /* @__PURE__ */ React112.createElement("div", { className: "translate-col" }, /* @__PURE__ */ React112.createElement("div", { className: "translate-filter" }, /* @__PURE__ */ React112.createElement(
|
|
9661
10281
|
"input",
|
|
9662
10282
|
{
|
|
9663
10283
|
type: "text",
|
|
@@ -9666,16 +10286,16 @@ var TranslateModal = ({ editor, onClose, onTranslate, initialSource, initialTarg
|
|
|
9666
10286
|
onChange: (e) => setTargetFilter(e.target.value),
|
|
9667
10287
|
className: "translate-filter-input"
|
|
9668
10288
|
}
|
|
9669
|
-
)), /* @__PURE__ */
|
|
10289
|
+
)), /* @__PURE__ */ React112.createElement("div", { className: "translate-list" }, filteredTarget.map((lang) => /* @__PURE__ */ React112.createElement(
|
|
9670
10290
|
"button",
|
|
9671
10291
|
{
|
|
9672
10292
|
key: lang.code,
|
|
9673
10293
|
className: `translate-item ${targetLang === lang.code ? "active" : ""}`,
|
|
9674
10294
|
onClick: () => setTargetLang(lang.code)
|
|
9675
10295
|
},
|
|
9676
|
-
/* @__PURE__ */
|
|
9677
|
-
/* @__PURE__ */
|
|
9678
|
-
))))), error && /* @__PURE__ */
|
|
10296
|
+
/* @__PURE__ */ React112.createElement("span", { className: "translate-code" }, lang.code),
|
|
10297
|
+
/* @__PURE__ */ React112.createElement("span", { className: "translate-name" }, lang.name)
|
|
10298
|
+
))))), error && /* @__PURE__ */ React112.createElement("div", { className: "translate-error" }, error)), /* @__PURE__ */ React112.createElement("div", { className: "modal-footer" }, /* @__PURE__ */ React112.createElement("div", { className: "modal-footer-left" }, /* @__PURE__ */ React112.createElement("button", { className: "modal-btn-cancel", onClick: onClose }, "Cancel")), /* @__PURE__ */ React112.createElement("button", { className: "modal-btn-apply", onClick: handleSave, disabled: translating }, translating ? "Translating..." : "Save")))),
|
|
9679
10299
|
document.body
|
|
9680
10300
|
);
|
|
9681
10301
|
};
|
|
@@ -10326,38 +10946,38 @@ var CustomTaskItem = TaskItem.extend({
|
|
|
10326
10946
|
});
|
|
10327
10947
|
|
|
10328
10948
|
// lib/RufousTextEditor/icons.tsx
|
|
10329
|
-
import * as
|
|
10949
|
+
import * as React113 from "react";
|
|
10330
10950
|
var s = { width: 20, height: 20, viewBox: "0 0 24 24", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg" };
|
|
10331
|
-
var IconUndo = () => /* @__PURE__ */
|
|
10332
|
-
var IconRedo = () => /* @__PURE__ */
|
|
10333
|
-
var IconBold = () => /* @__PURE__ */
|
|
10334
|
-
var IconItalic = () => /* @__PURE__ */
|
|
10335
|
-
var IconLink = () => /* @__PURE__ */
|
|
10336
|
-
var IconStrike = () => /* @__PURE__ */
|
|
10337
|
-
var IconHeading = () => /* @__PURE__ */
|
|
10338
|
-
var IconFontSize = () => /* @__PURE__ */
|
|
10339
|
-
var IconColor = () => /* @__PURE__ */
|
|
10340
|
-
var IconFont = () => /* @__PURE__ */
|
|
10341
|
-
var IconLineHeight = () => /* @__PURE__ */
|
|
10342
|
-
var IconBulletList = () => /* @__PURE__ */
|
|
10343
|
-
var IconOrderedList = () => /* @__PURE__ */
|
|
10344
|
-
var IconAlignLeft = () => /* @__PURE__ */
|
|
10345
|
-
var IconAlignCenter = () => /* @__PURE__ */
|
|
10346
|
-
var IconAlignRight = () => /* @__PURE__ */
|
|
10347
|
-
var IconAlignJustify = () => /* @__PURE__ */
|
|
10348
|
-
var IconIndentIncrease = () => /* @__PURE__ */
|
|
10349
|
-
var IconIndentDecrease = () => /* @__PURE__ */
|
|
10350
|
-
var IconTable = () => /* @__PURE__ */
|
|
10351
|
-
var IconImage = () => /* @__PURE__ */
|
|
10352
|
-
var IconVideo = () => /* @__PURE__ */
|
|
10353
|
-
var IconCut = () => /* @__PURE__ */
|
|
10354
|
-
var IconCopy = () => /* @__PURE__ */
|
|
10355
|
-
var IconCode = () => /* @__PURE__ */
|
|
10356
|
-
var IconFullscreen = () => /* @__PURE__ */
|
|
10357
|
-
var IconTranslate = () => /* @__PURE__ */
|
|
10358
|
-
var IconTaskList = () => /* @__PURE__ */
|
|
10359
|
-
var IconCheck = () => /* @__PURE__ */
|
|
10360
|
-
var IconPaste = () => /* @__PURE__ */
|
|
10951
|
+
var IconUndo = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M12.5 8C9.85 8 7.45 9 5.6 10.6L2 7v9h9l-3.62-3.62C8.93 11.01 10.63 10.2 12.5 10.2c3.03 0 5.6 1.93 6.55 4.63l2.15-.72C19.93 10.68 16.5 8 12.5 8z" }));
|
|
10952
|
+
var IconRedo = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M18.4 10.6C16.55 9 14.15 8 11.5 8c-4 0-7.43 2.68-8.7 6.11l2.15.72c.95-2.7 3.52-4.63 6.55-4.63 1.87 0 3.57.81 5.12 2.18L13 16h9V7l-3.6 3.6z" }));
|
|
10953
|
+
var IconBold = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42zM10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3v-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5z" }));
|
|
10954
|
+
var IconItalic = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z" }));
|
|
10955
|
+
var IconLink = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z" }));
|
|
10956
|
+
var IconStrike = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M7.24 11h2.01c-.13-.42-.2-.88-.2-1.37 0-.89.32-1.58.96-2.08.64-.49 1.46-.74 2.47-.74.99 0 1.81.24 2.46.71.64.47.97 1.1.97 1.88h2.04c0-1.27-.55-2.33-1.64-3.18C15.21 5.37 13.83 4.95 12.2 4.95c-1.69 0-3.09.43-4.2 1.3C6.9 7.1 6.35 8.23 6.35 9.63c0 .47.06.92.18 1.37H3v2h18v-2H7.24zM12.2 17.05c-1.03 0-1.89-.28-2.56-.84-.67-.56-1-1.27-1-2.13h-2.1c0 1.36.58 2.5 1.75 3.44 1.16.93 2.56 1.4 4.19 1.4 1.69 0 3.09-.43 4.2-1.3 1.1-.86 1.65-1.99 1.65-3.38h-2.1c0 .85-.33 1.56-1 2.13-.66.56-1.52.84-2.56.84l-.47-.16z" }));
|
|
10957
|
+
var IconHeading = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M5 4v3h5.5v12h3V7H19V4z" }));
|
|
10958
|
+
var IconFontSize = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M9 4v3h5v12h2V7h5V4H9zm-6 8h3v7h2v-7h3v-2H3v2z" }));
|
|
10959
|
+
var IconColor = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M11 2L5.5 16h2.25l1.12-3h6.25l1.12 3h2.25L13 2h-2zm-1.38 9L12 4.67 14.38 11H9.62z" }), /* @__PURE__ */ React113.createElement("path", { d: "M3 20h18v3H3z", opacity: "0.8" }));
|
|
10960
|
+
var IconFont = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M9.93 13.5h4.14L12 7.98 9.93 13.5zM20 2H4c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-4.05 16.5l-1.14-3H9.17l-1.12 3H5.96l5.11-13h1.86l5.11 13h-2.09z" }));
|
|
10961
|
+
var IconLineHeight = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M6 7h2.5L5 3.5 1.5 7H4v10H1.5L5 20.5 8.5 17H6V7zm16-3h-8v2h8V4zm0 4h-8v2h8V8zm0 4h-8v2h8v-2zm0 4h-8v2h8v-2z" }));
|
|
10962
|
+
var IconBulletList = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5zm0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5zm0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5zM7 19h14v-2H7v2zm0-6h14v-2H7v2zm0-8v2h14V5H7z" }));
|
|
10963
|
+
var IconOrderedList = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z" }));
|
|
10964
|
+
var IconAlignLeft = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M15 15H3v2h12v-2zm0-8H3v2h12V7zM3 13h18v-2H3v2zM3 21h18v-2H3v2zM3 3v2h18V3H3z" }));
|
|
10965
|
+
var IconAlignCenter = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M7 15v2h10v-2H7zm-4 6h18v-2H3v2zm0-8h18v-2H3v2zm4-6v2h10V7H7zM3 3v2h18V3H3z" }));
|
|
10966
|
+
var IconAlignRight = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M3 21h18v-2H3v2zm6-4h12v-2H9v2zm-6-4h18v-2H3v2zm6-4h12V7H9v2zM3 3v2h18V3H3z" }));
|
|
10967
|
+
var IconAlignJustify = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M3 21h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18V7H3v2zM3 3v2h18V3H3z" }));
|
|
10968
|
+
var IconIndentIncrease = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M3 21h18v-2H3v2zM3 8v8l4-4-4-4zm8 9h10v-2H11v2zM3 3v2h18V3H3zm8 6h10V7H11v2zm0 4h10v-2H11v2z" }));
|
|
10969
|
+
var IconIndentDecrease = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M11 17h10v-2H11v2zm-8-5l4 4V8l-4 4zm0 9h18v-2H3v2zM3 3v2h18V3H3zm8 6h10V7H11v2zm0 4h10v-2H11v2z" }));
|
|
10970
|
+
var IconTable = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M20 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h15c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5 19V5h4v14H5zm6 0V5h4v14h-4zm6 0V5h3v14h-3z", fillRule: "evenodd" }));
|
|
10971
|
+
var IconImage = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z" }));
|
|
10972
|
+
var IconVideo = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M4 6.47L5.76 10H20v8H4V6.47M22 4h-4l2 4h-3l-2-4h-2l2 4h-3l-2-4H8l2 4H7L5 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V4z" }));
|
|
10973
|
+
var IconCut = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M9.64 7.64c.23-.5.36-1.05.36-1.64 0-2.21-1.79-4-4-4S2 3.79 2 6s1.79 4 4 4c.59 0 1.14-.13 1.64-.36L10 12l-2.36 2.36C7.14 14.13 6.59 14 6 14c-2.21 0-4 1.79-4 4s1.79 4 4 4 4-1.79 4-4c0-.59-.13-1.14-.36-1.64L12 14l7 7h3v-1L9.64 7.64zM6 8c-1.1 0-2-.89-2-2s.9-2 2-2 2 .89 2 2-.9 2-2 2zm0 12c-1.1 0-2-.89-2-2s.9-2 2-2 2 .89 2 2-.9 2-2 2zm6-7.5c-.28 0-.5-.22-.5-.5s.22-.5.5-.5.5.22.5.5-.22.5-.5.5zM19 3l-6 6 2 2 7-7V3h-3z" }));
|
|
10974
|
+
var IconCopy = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z" }));
|
|
10975
|
+
var IconCode = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M9.4 16.6L4.8 12l4.6-4.6L8 6l-6 6 6 6 1.4-1.4zm5.2 0l4.6-4.6-4.6-4.6L16 6l6 6-6 6-1.4-1.4z" }));
|
|
10976
|
+
var IconFullscreen = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" }));
|
|
10977
|
+
var IconTranslate = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M12.87 15.07l-2.54-2.51.03-.03A17.52 17.52 0 0014.07 6H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2.02c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7l1.62-4.33L19.12 17h-3.24z" }));
|
|
10978
|
+
var IconTaskList = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M22 8c0-.55-.45-1-1-1h-7c-.55 0-1 .45-1 1s.45 1 1 1h7c.55 0 1-.45 1-1zm0 8c0-.55-.45-1-1-1h-7c-.55 0-1 .45-1 1s.45 1 1 1h7c.55 0 1-.45 1-1zM5.54 11L2 7.46l1.41-1.41 2.12 2.12 4.24-4.24 1.41 1.41L5.54 11zm0 8L2 15.46l1.41-1.41 2.12 2.12 4.24-4.24 1.41 1.41L5.54 19z" }));
|
|
10979
|
+
var IconCheck = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" }));
|
|
10980
|
+
var IconPaste = () => /* @__PURE__ */ React113.createElement("svg", { ...s }, /* @__PURE__ */ React113.createElement("path", { d: "M19 2h-4.18C14.4.84 13.3 0 12 0c-1.3 0-2.4.84-2.82 2H5c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V4c0-1.1-.9-2-2-2zm-7 0c.55 0 1 .45 1 1s-.45 1-1 1-1-.45-1-1 .45-1 1-1zm7 18H5V4h2v3h10V4h2v16z" }));
|
|
10361
10981
|
|
|
10362
10982
|
// lib/RufousTextEditor/Toolbar.tsx
|
|
10363
10983
|
var COLOR_PALETTE = [
|
|
@@ -10495,10 +11115,10 @@ var SPECIAL_CHARS = [
|
|
|
10495
11115
|
"\xA2"
|
|
10496
11116
|
];
|
|
10497
11117
|
var Dropdown = ({ trigger, children, className = "", keepOpen = false }) => {
|
|
10498
|
-
const [open, setOpen] =
|
|
10499
|
-
const ref =
|
|
10500
|
-
const menuRef =
|
|
10501
|
-
|
|
11118
|
+
const [open, setOpen] = useState31(false);
|
|
11119
|
+
const ref = useRef28(null);
|
|
11120
|
+
const menuRef = useRef28(null);
|
|
11121
|
+
useEffect25(() => {
|
|
10502
11122
|
const handleClick = (e) => {
|
|
10503
11123
|
const target = e.target;
|
|
10504
11124
|
const inTrigger = ref.current?.contains(target);
|
|
@@ -10510,7 +11130,7 @@ var Dropdown = ({ trigger, children, className = "", keepOpen = false }) => {
|
|
|
10510
11130
|
document.addEventListener("mousedown", handleClick);
|
|
10511
11131
|
return () => document.removeEventListener("mousedown", handleClick);
|
|
10512
11132
|
}, []);
|
|
10513
|
-
|
|
11133
|
+
useEffect25(() => {
|
|
10514
11134
|
if (!open || !menuRef.current || !ref.current) return;
|
|
10515
11135
|
const menu = menuRef.current;
|
|
10516
11136
|
const trigger2 = ref.current;
|
|
@@ -10539,22 +11159,22 @@ var Dropdown = ({ trigger, children, className = "", keepOpen = false }) => {
|
|
|
10539
11159
|
};
|
|
10540
11160
|
position();
|
|
10541
11161
|
}, [open]);
|
|
10542
|
-
return /* @__PURE__ */
|
|
11162
|
+
return /* @__PURE__ */ React114.createElement("div", { className: `dropdown ${className}`, ref }, /* @__PURE__ */ React114.createElement(Tooltip, { title: trigger.title || "", placement: "top" }, /* @__PURE__ */ React114.createElement(
|
|
10543
11163
|
"button",
|
|
10544
11164
|
{
|
|
10545
11165
|
className: `toolbar-btn ${trigger.className || ""}`,
|
|
10546
11166
|
onClick: () => setOpen(!open)
|
|
10547
11167
|
},
|
|
10548
11168
|
trigger.label,
|
|
10549
|
-
/* @__PURE__ */
|
|
11169
|
+
/* @__PURE__ */ React114.createElement("span", { className: "dropdown-arrow" }, "\u25BE")
|
|
10550
11170
|
)), open && createPortal4(
|
|
10551
|
-
/* @__PURE__ */
|
|
11171
|
+
/* @__PURE__ */ React114.createElement("div", { className: "rf-rte-wrapper rf-rte-dropdown-portal" }, /* @__PURE__ */ React114.createElement("div", { ref: menuRef, className: "dropdown-menu dropdown-menu-fixed", onClick: keepOpen ? void 0 : () => setOpen(false) }, typeof children === "function" ? children(() => setOpen(false)) : children)),
|
|
10552
11172
|
document.body
|
|
10553
11173
|
));
|
|
10554
11174
|
};
|
|
10555
11175
|
var InsertPanel = ({ editor, onClose, mode = "video" }) => {
|
|
10556
|
-
const [activeTab, setActiveTab] =
|
|
10557
|
-
const [url, setUrl] =
|
|
11176
|
+
const [activeTab, setActiveTab] = useState31("link");
|
|
11177
|
+
const [url, setUrl] = useState31("");
|
|
10558
11178
|
const extractIframeSrc = (html) => {
|
|
10559
11179
|
const match = html.match(/<iframe[^>]+src=["']([^"']+)["']/);
|
|
10560
11180
|
return match ? match[1] : null;
|
|
@@ -10586,14 +11206,14 @@ var InsertPanel = ({ editor, onClose, mode = "video" }) => {
|
|
|
10586
11206
|
}
|
|
10587
11207
|
onClose();
|
|
10588
11208
|
};
|
|
10589
|
-
return /* @__PURE__ */
|
|
11209
|
+
return /* @__PURE__ */ React114.createElement("div", { className: "insert-panel", onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ React114.createElement("div", { className: "insert-panel-tabs" }, /* @__PURE__ */ React114.createElement(
|
|
10590
11210
|
"button",
|
|
10591
11211
|
{
|
|
10592
11212
|
className: `insert-tab ${activeTab === "link" ? "active" : ""}`,
|
|
10593
11213
|
onClick: () => setActiveTab("link")
|
|
10594
11214
|
},
|
|
10595
11215
|
"\u{1F517} Link"
|
|
10596
|
-
), /* @__PURE__ */
|
|
11216
|
+
), /* @__PURE__ */ React114.createElement(
|
|
10597
11217
|
"button",
|
|
10598
11218
|
{
|
|
10599
11219
|
className: `insert-tab ${activeTab === "code" ? "active" : ""}`,
|
|
@@ -10601,7 +11221,7 @@ var InsertPanel = ({ editor, onClose, mode = "video" }) => {
|
|
|
10601
11221
|
},
|
|
10602
11222
|
"</>",
|
|
10603
11223
|
" Code"
|
|
10604
|
-
)), /* @__PURE__ */
|
|
11224
|
+
)), /* @__PURE__ */ React114.createElement("label", { className: "insert-panel-label" }, activeTab === "link" ? "URL" : "Embed Code"), activeTab === "link" ? /* @__PURE__ */ React114.createElement(
|
|
10605
11225
|
"input",
|
|
10606
11226
|
{
|
|
10607
11227
|
type: "text",
|
|
@@ -10612,7 +11232,7 @@ var InsertPanel = ({ editor, onClose, mode = "video" }) => {
|
|
|
10612
11232
|
onKeyDown: (e) => e.key === "Enter" && handleInsert(),
|
|
10613
11233
|
autoFocus: true
|
|
10614
11234
|
}
|
|
10615
|
-
) : /* @__PURE__ */
|
|
11235
|
+
) : /* @__PURE__ */ React114.createElement(
|
|
10616
11236
|
"textarea",
|
|
10617
11237
|
{
|
|
10618
11238
|
className: "insert-panel-textarea",
|
|
@@ -10621,13 +11241,13 @@ var InsertPanel = ({ editor, onClose, mode = "video" }) => {
|
|
|
10621
11241
|
onChange: (e) => setUrl(e.target.value),
|
|
10622
11242
|
rows: 3
|
|
10623
11243
|
}
|
|
10624
|
-
), /* @__PURE__ */
|
|
11244
|
+
), /* @__PURE__ */ React114.createElement("button", { className: "insert-panel-btn", onClick: handleInsert }, "Insert"));
|
|
10625
11245
|
};
|
|
10626
11246
|
var ImagePanel = ({ editor, onClose, onImageUpload }) => {
|
|
10627
|
-
const [activeTab, setActiveTab] =
|
|
10628
|
-
const [url, setUrl] =
|
|
10629
|
-
const [isDragging, setIsDragging] =
|
|
10630
|
-
const fileInputRef =
|
|
11247
|
+
const [activeTab, setActiveTab] = useState31("upload");
|
|
11248
|
+
const [url, setUrl] = useState31("");
|
|
11249
|
+
const [isDragging, setIsDragging] = useState31(false);
|
|
11250
|
+
const fileInputRef = useRef28(null);
|
|
10631
11251
|
const getBase64 = (file) => {
|
|
10632
11252
|
return new Promise((resolve, reject) => {
|
|
10633
11253
|
const reader = new FileReader();
|
|
@@ -10665,21 +11285,21 @@ var ImagePanel = ({ editor, onClose, onImageUpload }) => {
|
|
|
10665
11285
|
editor.chain().focus().setImage({ src: url }).run();
|
|
10666
11286
|
onClose();
|
|
10667
11287
|
};
|
|
10668
|
-
return /* @__PURE__ */
|
|
11288
|
+
return /* @__PURE__ */ React114.createElement("div", { className: "insert-panel", onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ React114.createElement("div", { className: "insert-panel-tabs" }, /* @__PURE__ */ React114.createElement(
|
|
10669
11289
|
"button",
|
|
10670
11290
|
{
|
|
10671
11291
|
className: `insert-tab ${activeTab === "upload" ? "active" : ""}`,
|
|
10672
11292
|
onClick: () => setActiveTab("upload")
|
|
10673
11293
|
},
|
|
10674
11294
|
"\u2B06 Upload"
|
|
10675
|
-
), /* @__PURE__ */
|
|
11295
|
+
), /* @__PURE__ */ React114.createElement(
|
|
10676
11296
|
"button",
|
|
10677
11297
|
{
|
|
10678
11298
|
className: `insert-tab ${activeTab === "url" ? "active" : ""}`,
|
|
10679
11299
|
onClick: () => setActiveTab("url")
|
|
10680
11300
|
},
|
|
10681
11301
|
"\u{1F517} URL"
|
|
10682
|
-
)), activeTab === "upload" ? /* @__PURE__ */
|
|
11302
|
+
)), activeTab === "upload" ? /* @__PURE__ */ React114.createElement(React114.Fragment, null, /* @__PURE__ */ React114.createElement(
|
|
10683
11303
|
"div",
|
|
10684
11304
|
{
|
|
10685
11305
|
className: `drop-zone ${isDragging ? "dragging" : ""}`,
|
|
@@ -10691,9 +11311,9 @@ var ImagePanel = ({ editor, onClose, onImageUpload }) => {
|
|
|
10691
11311
|
onDrop: handleDrop,
|
|
10692
11312
|
onClick: () => fileInputRef.current?.click()
|
|
10693
11313
|
},
|
|
10694
|
-
/* @__PURE__ */
|
|
10695
|
-
/* @__PURE__ */
|
|
10696
|
-
), /* @__PURE__ */
|
|
11314
|
+
/* @__PURE__ */ React114.createElement("span", { className: "drop-zone-text-bold" }, "Drop image"),
|
|
11315
|
+
/* @__PURE__ */ React114.createElement("span", { className: "drop-zone-text-sub" }, "or click")
|
|
11316
|
+
), /* @__PURE__ */ React114.createElement(
|
|
10697
11317
|
"input",
|
|
10698
11318
|
{
|
|
10699
11319
|
ref: fileInputRef,
|
|
@@ -10702,7 +11322,7 @@ var ImagePanel = ({ editor, onClose, onImageUpload }) => {
|
|
|
10702
11322
|
style: { display: "none" },
|
|
10703
11323
|
onChange: handleFileSelect
|
|
10704
11324
|
}
|
|
10705
|
-
)) : /* @__PURE__ */
|
|
11325
|
+
)) : /* @__PURE__ */ React114.createElement(React114.Fragment, null, /* @__PURE__ */ React114.createElement("label", { className: "insert-panel-label" }, "URL"), /* @__PURE__ */ React114.createElement(
|
|
10706
11326
|
"input",
|
|
10707
11327
|
{
|
|
10708
11328
|
type: "text",
|
|
@@ -10713,18 +11333,18 @@ var ImagePanel = ({ editor, onClose, onImageUpload }) => {
|
|
|
10713
11333
|
onKeyDown: (e) => e.key === "Enter" && handleUrlInsert(),
|
|
10714
11334
|
autoFocus: true
|
|
10715
11335
|
}
|
|
10716
|
-
), /* @__PURE__ */
|
|
11336
|
+
), /* @__PURE__ */ React114.createElement("button", { className: "insert-panel-btn", onClick: handleUrlInsert }, "Insert")));
|
|
10717
11337
|
};
|
|
10718
11338
|
var MAX_GRID = 10;
|
|
10719
11339
|
var TableGridSelector = ({ editor, onClose }) => {
|
|
10720
|
-
const [hoverRow, setHoverRow] =
|
|
10721
|
-
const [hoverCol, setHoverCol] =
|
|
11340
|
+
const [hoverRow, setHoverRow] = useState31(0);
|
|
11341
|
+
const [hoverCol, setHoverCol] = useState31(0);
|
|
10722
11342
|
const handleInsert = () => {
|
|
10723
11343
|
if (!editor || hoverRow === 0 || hoverCol === 0) return;
|
|
10724
11344
|
editor.chain().focus().insertTable({ rows: hoverRow, cols: hoverCol, withHeaderRow: true }).run();
|
|
10725
11345
|
onClose();
|
|
10726
11346
|
};
|
|
10727
|
-
return /* @__PURE__ */
|
|
11347
|
+
return /* @__PURE__ */ React114.createElement("div", { className: "table-grid-panel", onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ React114.createElement(
|
|
10728
11348
|
"div",
|
|
10729
11349
|
{
|
|
10730
11350
|
className: "table-grid",
|
|
@@ -10733,7 +11353,7 @@ var TableGridSelector = ({ editor, onClose }) => {
|
|
|
10733
11353
|
setHoverCol(0);
|
|
10734
11354
|
}
|
|
10735
11355
|
},
|
|
10736
|
-
Array.from({ length: MAX_GRID }, (_, r) => /* @__PURE__ */
|
|
11356
|
+
Array.from({ length: MAX_GRID }, (_, r) => /* @__PURE__ */ React114.createElement("div", { key: r, className: "table-grid-row" }, Array.from({ length: MAX_GRID }, (_2, c) => /* @__PURE__ */ React114.createElement(
|
|
10737
11357
|
"div",
|
|
10738
11358
|
{
|
|
10739
11359
|
key: c,
|
|
@@ -10745,7 +11365,7 @@ var TableGridSelector = ({ editor, onClose }) => {
|
|
|
10745
11365
|
onClick: handleInsert
|
|
10746
11366
|
}
|
|
10747
11367
|
))))
|
|
10748
|
-
), /* @__PURE__ */
|
|
11368
|
+
), /* @__PURE__ */ React114.createElement("div", { className: "table-grid-footer" }, /* @__PURE__ */ React114.createElement("span", { className: "table-grid-size" }, hoverRow > 0 && hoverCol > 0 ? `${hoverRow}\xD7${hoverCol}` : "Select size"), /* @__PURE__ */ React114.createElement(
|
|
10749
11369
|
"button",
|
|
10750
11370
|
{
|
|
10751
11371
|
className: "table-grid-submit",
|
|
@@ -10756,9 +11376,9 @@ var TableGridSelector = ({ editor, onClose }) => {
|
|
|
10756
11376
|
)));
|
|
10757
11377
|
};
|
|
10758
11378
|
var ColorPickerPanel = ({ editor, onClose }) => {
|
|
10759
|
-
const [tab, setTab] =
|
|
10760
|
-
const [activeBg, setActiveBg] =
|
|
10761
|
-
const [activeText, setActiveText] =
|
|
11379
|
+
const [tab, setTab] = useState31("background");
|
|
11380
|
+
const [activeBg, setActiveBg] = useState31(() => editor.getAttributes("highlight").color || null);
|
|
11381
|
+
const [activeText, setActiveText] = useState31(() => editor.getAttributes("textStyle").color || null);
|
|
10762
11382
|
const activeColor = tab === "background" ? activeBg : activeText;
|
|
10763
11383
|
const applyColor = (color) => {
|
|
10764
11384
|
if (tab === "background") {
|
|
@@ -10779,51 +11399,51 @@ var ColorPickerPanel = ({ editor, onClose }) => {
|
|
|
10779
11399
|
}
|
|
10780
11400
|
onClose();
|
|
10781
11401
|
};
|
|
10782
|
-
return /* @__PURE__ */
|
|
11402
|
+
return /* @__PURE__ */ React114.createElement("div", { className: "color-picker-panel", onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ React114.createElement("div", { className: "color-picker-tabs" }, /* @__PURE__ */ React114.createElement(
|
|
10783
11403
|
"button",
|
|
10784
11404
|
{
|
|
10785
11405
|
className: `color-picker-tab ${tab === "background" ? "active" : ""}`,
|
|
10786
11406
|
onClick: () => setTab("background")
|
|
10787
11407
|
},
|
|
10788
11408
|
"Background"
|
|
10789
|
-
), /* @__PURE__ */
|
|
11409
|
+
), /* @__PURE__ */ React114.createElement(
|
|
10790
11410
|
"button",
|
|
10791
11411
|
{
|
|
10792
11412
|
className: `color-picker-tab ${tab === "text" ? "active" : ""}`,
|
|
10793
11413
|
onClick: () => setTab("text")
|
|
10794
11414
|
},
|
|
10795
11415
|
"Text"
|
|
10796
|
-
)), /* @__PURE__ */
|
|
11416
|
+
)), /* @__PURE__ */ React114.createElement("div", { className: "color-picker-grid" }, COLOR_PALETTE.map((color, i) => /* @__PURE__ */ React114.createElement(Tooltip, { key: i, title: color, placement: "top" }, /* @__PURE__ */ React114.createElement(
|
|
10797
11417
|
"button",
|
|
10798
11418
|
{
|
|
10799
11419
|
className: `color-picker-swatch ${color === "#ffffff" ? "white-swatch" : ""}${activeColor && activeColor.toLowerCase() === color.toLowerCase() ? " swatch-active" : ""}`,
|
|
10800
11420
|
style: { background: color },
|
|
10801
11421
|
onClick: () => applyColor(color)
|
|
10802
11422
|
}
|
|
10803
|
-
)))), /* @__PURE__ */
|
|
11423
|
+
)))), /* @__PURE__ */ React114.createElement("div", { className: "color-picker-footer" }, /* @__PURE__ */ React114.createElement("div", { className: "color-picker-preview", style: { background: activeColor || "#000" } }), /* @__PURE__ */ React114.createElement(Tooltip, { title: "Remove color", placement: "top" }, /* @__PURE__ */ React114.createElement("button", { className: "color-picker-remove", onClick: removeColor }, "\u2713"))));
|
|
10804
11424
|
};
|
|
10805
11425
|
var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTextToSpeech, onClose, onImageUpload, visibleButtons, isFullscreen, onToggleFullscreen }) => {
|
|
10806
|
-
const [, setEditorState] =
|
|
10807
|
-
const [todoEnabled, setTodoEnabled] =
|
|
10808
|
-
const ttsRef =
|
|
10809
|
-
const sttRef =
|
|
11426
|
+
const [, setEditorState] = useState31(0);
|
|
11427
|
+
const [todoEnabled, setTodoEnabled] = useState31(false);
|
|
11428
|
+
const ttsRef = useRef28(null);
|
|
11429
|
+
const sttRef = useRef28(null);
|
|
10810
11430
|
const show = (id) => !visibleButtons || visibleButtons.has(id);
|
|
10811
|
-
|
|
11431
|
+
useEffect25(() => {
|
|
10812
11432
|
if (!editor) return;
|
|
10813
11433
|
const onTransaction = () => setEditorState((n) => n + 1);
|
|
10814
11434
|
editor.on("transaction", onTransaction);
|
|
10815
11435
|
return () => editor.off("transaction", onTransaction);
|
|
10816
11436
|
}, [editor]);
|
|
10817
|
-
const insertSpecialChar =
|
|
11437
|
+
const insertSpecialChar = useCallback14((char) => {
|
|
10818
11438
|
if (!editor) return;
|
|
10819
11439
|
editor.chain().focus().insertContent(char).run();
|
|
10820
11440
|
}, [editor]);
|
|
10821
|
-
const [copySuccess, setCopySuccess] =
|
|
10822
|
-
const [translateSource, setTranslateSource] =
|
|
10823
|
-
const [translateTarget, setTranslateTarget] =
|
|
10824
|
-
const [translateStatus, setTranslateStatus] =
|
|
10825
|
-
const [showTranslateModal, setShowTranslateModal] =
|
|
10826
|
-
const handleCopy =
|
|
11441
|
+
const [copySuccess, setCopySuccess] = useState31(false);
|
|
11442
|
+
const [translateSource, setTranslateSource] = useState31("en");
|
|
11443
|
+
const [translateTarget, setTranslateTarget] = useState31("hi");
|
|
11444
|
+
const [translateStatus, setTranslateStatus] = useState31("");
|
|
11445
|
+
const [showTranslateModal, setShowTranslateModal] = useState31(false);
|
|
11446
|
+
const handleCopy = useCallback14(async () => {
|
|
10827
11447
|
if (!editor) return;
|
|
10828
11448
|
const { from, to, empty } = editor.state.selection;
|
|
10829
11449
|
if (empty) return;
|
|
@@ -10838,7 +11458,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10838
11458
|
setTimeout(() => setCopySuccess(false), 2e3);
|
|
10839
11459
|
}
|
|
10840
11460
|
}, [editor]);
|
|
10841
|
-
const handlePaste =
|
|
11461
|
+
const handlePaste = useCallback14(async () => {
|
|
10842
11462
|
if (!editor) return;
|
|
10843
11463
|
try {
|
|
10844
11464
|
const text = await navigator.clipboard.readText();
|
|
@@ -10847,7 +11467,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10847
11467
|
document.execCommand("paste");
|
|
10848
11468
|
}
|
|
10849
11469
|
}, [editor]);
|
|
10850
|
-
const handleQuickTranslate =
|
|
11470
|
+
const handleQuickTranslate = useCallback14(async () => {
|
|
10851
11471
|
if (!editor) return;
|
|
10852
11472
|
const { from, to, empty } = editor.state.selection;
|
|
10853
11473
|
if (empty) {
|
|
@@ -10881,32 +11501,32 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10881
11501
|
setTimeout(() => setTranslateStatus(""), 2e3);
|
|
10882
11502
|
}, [editor, translateSource, translateTarget, onTranslate]);
|
|
10883
11503
|
if (!editor) return null;
|
|
10884
|
-
return /* @__PURE__ */
|
|
11504
|
+
return /* @__PURE__ */ React114.createElement("div", { className: "toolbar" }, /* @__PURE__ */ React114.createElement("div", { className: `toolbar-row ${onClose ? "with-close" : ""}` }, (show("undo") || show("redo")) && /* @__PURE__ */ React114.createElement("div", { className: "toolbar-group" }, show("undo") && /* @__PURE__ */ React114.createElement(Tooltip, { title: "Undo (Ctrl+Z)", placement: "top" }, /* @__PURE__ */ React114.createElement(
|
|
10885
11505
|
"button",
|
|
10886
11506
|
{
|
|
10887
11507
|
className: "toolbar-btn",
|
|
10888
11508
|
onClick: () => editor.chain().focus().undo().run(),
|
|
10889
11509
|
disabled: !editor.can().undo()
|
|
10890
11510
|
},
|
|
10891
|
-
/* @__PURE__ */
|
|
10892
|
-
)), show("redo") && /* @__PURE__ */
|
|
11511
|
+
/* @__PURE__ */ React114.createElement(IconUndo, null)
|
|
11512
|
+
)), show("redo") && /* @__PURE__ */ React114.createElement(Tooltip, { title: "Redo (Ctrl+Y)", placement: "top" }, /* @__PURE__ */ React114.createElement(
|
|
10893
11513
|
"button",
|
|
10894
11514
|
{
|
|
10895
11515
|
className: "toolbar-btn",
|
|
10896
11516
|
onClick: () => editor.chain().focus().redo().run(),
|
|
10897
11517
|
disabled: !editor.can().redo()
|
|
10898
11518
|
},
|
|
10899
|
-
/* @__PURE__ */
|
|
10900
|
-
))), show("ai") && /* @__PURE__ */
|
|
11519
|
+
/* @__PURE__ */ React114.createElement(IconRedo, null)
|
|
11520
|
+
))), show("ai") && /* @__PURE__ */ React114.createElement("div", { className: "toolbar-group" }, /* @__PURE__ */ React114.createElement(AICommands_default, { editor, onAICommand })), /* @__PURE__ */ React114.createElement("div", { className: "toolbar-group" }, show("paragraph") && /* @__PURE__ */ React114.createElement(
|
|
10901
11521
|
Dropdown,
|
|
10902
11522
|
{
|
|
10903
11523
|
trigger: {
|
|
10904
|
-
label: /* @__PURE__ */
|
|
11524
|
+
label: /* @__PURE__ */ React114.createElement(IconHeading, null),
|
|
10905
11525
|
title: "Block type",
|
|
10906
11526
|
className: editor.isActive("heading") ? "is-active" : ""
|
|
10907
11527
|
}
|
|
10908
11528
|
},
|
|
10909
|
-
/* @__PURE__ */
|
|
11529
|
+
/* @__PURE__ */ React114.createElement(
|
|
10910
11530
|
"button",
|
|
10911
11531
|
{
|
|
10912
11532
|
className: `dropdown-item ${!editor.isActive("heading") && !editor.isActive("blockquote") && !editor.isActive("codeBlock") ? "is-active" : ""}`,
|
|
@@ -10914,7 +11534,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10914
11534
|
},
|
|
10915
11535
|
"\xB6 Paragraph"
|
|
10916
11536
|
),
|
|
10917
|
-
/* @__PURE__ */
|
|
11537
|
+
/* @__PURE__ */ React114.createElement(
|
|
10918
11538
|
"button",
|
|
10919
11539
|
{
|
|
10920
11540
|
className: `dropdown-item heading-1 ${editor.isActive("heading", { level: 1 }) ? "is-active" : ""}`,
|
|
@@ -10922,7 +11542,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10922
11542
|
},
|
|
10923
11543
|
"Heading 1"
|
|
10924
11544
|
),
|
|
10925
|
-
/* @__PURE__ */
|
|
11545
|
+
/* @__PURE__ */ React114.createElement(
|
|
10926
11546
|
"button",
|
|
10927
11547
|
{
|
|
10928
11548
|
className: `dropdown-item heading-2 ${editor.isActive("heading", { level: 2 }) ? "is-active" : ""}`,
|
|
@@ -10930,7 +11550,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10930
11550
|
},
|
|
10931
11551
|
"Heading 2"
|
|
10932
11552
|
),
|
|
10933
|
-
/* @__PURE__ */
|
|
11553
|
+
/* @__PURE__ */ React114.createElement(
|
|
10934
11554
|
"button",
|
|
10935
11555
|
{
|
|
10936
11556
|
className: `dropdown-item heading-3 ${editor.isActive("heading", { level: 3 }) ? "is-active" : ""}`,
|
|
@@ -10938,7 +11558,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10938
11558
|
},
|
|
10939
11559
|
"Heading 3"
|
|
10940
11560
|
),
|
|
10941
|
-
/* @__PURE__ */
|
|
11561
|
+
/* @__PURE__ */ React114.createElement(
|
|
10942
11562
|
"button",
|
|
10943
11563
|
{
|
|
10944
11564
|
className: `dropdown-item heading-4 ${editor.isActive("heading", { level: 4 }) ? "is-active" : ""}`,
|
|
@@ -10946,7 +11566,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10946
11566
|
},
|
|
10947
11567
|
"Heading 4"
|
|
10948
11568
|
),
|
|
10949
|
-
/* @__PURE__ */
|
|
11569
|
+
/* @__PURE__ */ React114.createElement(
|
|
10950
11570
|
"button",
|
|
10951
11571
|
{
|
|
10952
11572
|
className: `dropdown-item ${editor.isActive("blockquote") ? "is-active" : ""}`,
|
|
@@ -10954,7 +11574,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10954
11574
|
},
|
|
10955
11575
|
"\u275E Blockquote"
|
|
10956
11576
|
),
|
|
10957
|
-
/* @__PURE__ */
|
|
11577
|
+
/* @__PURE__ */ React114.createElement(
|
|
10958
11578
|
"button",
|
|
10959
11579
|
{
|
|
10960
11580
|
className: `dropdown-item ${editor.isActive("codeBlock") ? "is-active" : ""}`,
|
|
@@ -10963,19 +11583,19 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10963
11583
|
"{ }",
|
|
10964
11584
|
" Code Block"
|
|
10965
11585
|
),
|
|
10966
|
-
/* @__PURE__ */
|
|
10967
|
-
), show("fontsize") && /* @__PURE__ */
|
|
11586
|
+
/* @__PURE__ */ React114.createElement("button", { className: "dropdown-item", onClick: () => editor.chain().focus().setHorizontalRule().run() }, "\u2014 Horizontal Rule")
|
|
11587
|
+
), show("fontsize") && /* @__PURE__ */ React114.createElement(
|
|
10968
11588
|
Dropdown,
|
|
10969
11589
|
{
|
|
10970
11590
|
trigger: {
|
|
10971
|
-
label: /* @__PURE__ */
|
|
11591
|
+
label: /* @__PURE__ */ React114.createElement(IconFontSize, null),
|
|
10972
11592
|
title: "Font size"
|
|
10973
11593
|
}
|
|
10974
11594
|
},
|
|
10975
11595
|
[8, 9, 10, 11, 12, 14, 16, 18, 20, 24, 28, 32, 36, 42, 48, 56, 64, 72, 80, 96].map((size) => {
|
|
10976
11596
|
const sizeStr = `${size}px`;
|
|
10977
11597
|
const isActive = editor.getAttributes("textStyle").fontSize === sizeStr;
|
|
10978
|
-
return /* @__PURE__ */
|
|
11598
|
+
return /* @__PURE__ */ React114.createElement(
|
|
10979
11599
|
"button",
|
|
10980
11600
|
{
|
|
10981
11601
|
key: size,
|
|
@@ -10991,17 +11611,17 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10991
11611
|
sizeStr
|
|
10992
11612
|
);
|
|
10993
11613
|
})
|
|
10994
|
-
), show("font") && /* @__PURE__ */
|
|
11614
|
+
), show("font") && /* @__PURE__ */ React114.createElement(
|
|
10995
11615
|
Dropdown,
|
|
10996
11616
|
{
|
|
10997
11617
|
trigger: {
|
|
10998
|
-
label: /* @__PURE__ */
|
|
11618
|
+
label: /* @__PURE__ */ React114.createElement(IconFont, null),
|
|
10999
11619
|
title: "Font family"
|
|
11000
11620
|
}
|
|
11001
11621
|
},
|
|
11002
11622
|
FONT_FAMILIES.map((font) => {
|
|
11003
11623
|
const isActive = editor.getAttributes("textStyle").fontFamily === font;
|
|
11004
|
-
return /* @__PURE__ */
|
|
11624
|
+
return /* @__PURE__ */ React114.createElement(
|
|
11005
11625
|
"button",
|
|
11006
11626
|
{
|
|
11007
11627
|
key: font,
|
|
@@ -11018,40 +11638,40 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11018
11638
|
font
|
|
11019
11639
|
);
|
|
11020
11640
|
})
|
|
11021
|
-
), show("color") && /* @__PURE__ */
|
|
11641
|
+
), show("color") && /* @__PURE__ */ React114.createElement(
|
|
11022
11642
|
Dropdown,
|
|
11023
11643
|
{
|
|
11024
11644
|
trigger: {
|
|
11025
|
-
label: /* @__PURE__ */
|
|
11645
|
+
label: /* @__PURE__ */ React114.createElement("span", { style: { display: "flex", alignItems: "center" } }, /* @__PURE__ */ React114.createElement(IconColor, null)),
|
|
11026
11646
|
title: "Colors"
|
|
11027
11647
|
},
|
|
11028
11648
|
keepOpen: true
|
|
11029
11649
|
},
|
|
11030
|
-
(close) => /* @__PURE__ */
|
|
11031
|
-
), show("bold") && /* @__PURE__ */
|
|
11650
|
+
(close) => /* @__PURE__ */ React114.createElement(ColorPickerPanel, { editor, onClose: close })
|
|
11651
|
+
), show("bold") && /* @__PURE__ */ React114.createElement(Tooltip, { title: "Bold (Ctrl+B)", placement: "top" }, /* @__PURE__ */ React114.createElement(
|
|
11032
11652
|
"button",
|
|
11033
11653
|
{
|
|
11034
11654
|
className: `toolbar-btn ${editor.isActive("bold") ? "is-active" : ""}`,
|
|
11035
11655
|
onClick: () => editor.chain().focus().toggleBold().run()
|
|
11036
11656
|
},
|
|
11037
|
-
/* @__PURE__ */
|
|
11038
|
-
)), show("italic") && /* @__PURE__ */
|
|
11657
|
+
/* @__PURE__ */ React114.createElement(IconBold, null)
|
|
11658
|
+
)), show("italic") && /* @__PURE__ */ React114.createElement(Tooltip, { title: "Italic (Ctrl+I)", placement: "top" }, /* @__PURE__ */ React114.createElement(
|
|
11039
11659
|
"button",
|
|
11040
11660
|
{
|
|
11041
11661
|
className: `toolbar-btn ${editor.isActive("italic") ? "is-active" : ""}`,
|
|
11042
11662
|
onClick: () => editor.chain().focus().toggleItalic().run()
|
|
11043
11663
|
},
|
|
11044
|
-
/* @__PURE__ */
|
|
11045
|
-
)), show("strike") && /* @__PURE__ */
|
|
11664
|
+
/* @__PURE__ */ React114.createElement(IconItalic, null)
|
|
11665
|
+
)), show("strike") && /* @__PURE__ */ React114.createElement(
|
|
11046
11666
|
Dropdown,
|
|
11047
11667
|
{
|
|
11048
|
-
trigger: { label: /* @__PURE__ */
|
|
11668
|
+
trigger: { label: /* @__PURE__ */ React114.createElement(IconStrike, null), title: "Text decoration", className: editor.isActive("strike") ? "is-active" : "" }
|
|
11049
11669
|
},
|
|
11050
|
-
/* @__PURE__ */
|
|
11051
|
-
/* @__PURE__ */
|
|
11052
|
-
/* @__PURE__ */
|
|
11053
|
-
/* @__PURE__ */
|
|
11054
|
-
/* @__PURE__ */
|
|
11670
|
+
/* @__PURE__ */ React114.createElement("button", { className: "dropdown-item", onClick: () => editor.chain().focus().toggleStrike().run() }, /* @__PURE__ */ React114.createElement("s", null, "Strikethrough")),
|
|
11671
|
+
/* @__PURE__ */ React114.createElement("button", { className: "dropdown-item", onClick: () => editor.chain().focus().toggleUnderline().run() }, /* @__PURE__ */ React114.createElement("u", null, "Underline")),
|
|
11672
|
+
/* @__PURE__ */ React114.createElement("button", { className: "dropdown-item", onClick: () => editor.chain().focus().toggleSuperscript().run() }, "X", /* @__PURE__ */ React114.createElement("sup", null, "2"), " Superscript"),
|
|
11673
|
+
/* @__PURE__ */ React114.createElement("button", { className: "dropdown-item", onClick: () => editor.chain().focus().toggleSubscript().run() }, "X", /* @__PURE__ */ React114.createElement("sub", null, "2"), " Subscript"),
|
|
11674
|
+
/* @__PURE__ */ React114.createElement("button", { className: "dropdown-item", onMouseDown: (e) => {
|
|
11055
11675
|
e.preventDefault();
|
|
11056
11676
|
const chain = editor.chain().focus();
|
|
11057
11677
|
if (!editor.state.selection.empty) {
|
|
@@ -11067,25 +11687,25 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11067
11687
|
c.run();
|
|
11068
11688
|
}
|
|
11069
11689
|
} }, "\u2715 Clear formatting")
|
|
11070
|
-
), show("link") && /* @__PURE__ */
|
|
11690
|
+
), show("link") && /* @__PURE__ */ React114.createElement(Tooltip, { title: "Insert Link", placement: "top" }, /* @__PURE__ */ React114.createElement(
|
|
11071
11691
|
"button",
|
|
11072
11692
|
{
|
|
11073
11693
|
className: `toolbar-btn ${editor.isActive("link") ? "is-active" : ""}`,
|
|
11074
11694
|
onClick: setLink
|
|
11075
11695
|
},
|
|
11076
|
-
/* @__PURE__ */
|
|
11077
|
-
)), show("lineheight") && /* @__PURE__ */
|
|
11696
|
+
/* @__PURE__ */ React114.createElement(IconLink, null)
|
|
11697
|
+
)), show("lineheight") && /* @__PURE__ */ React114.createElement(
|
|
11078
11698
|
Dropdown,
|
|
11079
11699
|
{
|
|
11080
11700
|
trigger: {
|
|
11081
|
-
label: /* @__PURE__ */
|
|
11701
|
+
label: /* @__PURE__ */ React114.createElement(IconLineHeight, null),
|
|
11082
11702
|
title: "Line height"
|
|
11083
11703
|
}
|
|
11084
11704
|
},
|
|
11085
11705
|
["1.0", "1.1", "1.2", "1.3", "1.4", "1.5", "1.6", "1.7", "1.8", "2.0", "2.5", "3.0"].map((lh) => {
|
|
11086
11706
|
const currentLH = editor.getAttributes("paragraph").lineHeight || editor.getAttributes("heading").lineHeight;
|
|
11087
11707
|
const isActive = currentLH === lh;
|
|
11088
|
-
return /* @__PURE__ */
|
|
11708
|
+
return /* @__PURE__ */ React114.createElement(
|
|
11089
11709
|
"button",
|
|
11090
11710
|
{
|
|
11091
11711
|
key: lh,
|
|
@@ -11101,19 +11721,19 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11101
11721
|
lh
|
|
11102
11722
|
);
|
|
11103
11723
|
})
|
|
11104
|
-
)), (show("ul") || show("ol")) && /* @__PURE__ */
|
|
11724
|
+
)), (show("ul") || show("ol")) && /* @__PURE__ */ React114.createElement("div", { className: "toolbar-group" }, show("ul") && /* @__PURE__ */ React114.createElement("div", { className: "list-split-btn" }, /* @__PURE__ */ React114.createElement(Tooltip, { title: editor.isActive("bulletList") ? "Disable Bullet List" : "Enable Bullet List", placement: "top" }, /* @__PURE__ */ React114.createElement(
|
|
11105
11725
|
"button",
|
|
11106
11726
|
{
|
|
11107
11727
|
className: `toolbar-btn ${editor.isActive("bulletList") ? "is-active" : ""}`,
|
|
11108
11728
|
onClick: () => editor.chain().focus().toggleBulletList().run()
|
|
11109
11729
|
},
|
|
11110
|
-
/* @__PURE__ */
|
|
11111
|
-
)), /* @__PURE__ */
|
|
11730
|
+
/* @__PURE__ */ React114.createElement(IconBulletList, null)
|
|
11731
|
+
)), /* @__PURE__ */ React114.createElement(Dropdown, { trigger: { label: "", title: "List style", className: "list-arrow-btn" }, keepOpen: true }, [
|
|
11112
11732
|
{ label: "Default", style: null, icon: "\u2022" },
|
|
11113
11733
|
{ label: "Circle", style: "circle", icon: "\u25CB" },
|
|
11114
11734
|
{ label: "Dot", style: "disc", icon: "\u2219" },
|
|
11115
11735
|
{ label: "Square", style: "square", icon: "\u25A0" }
|
|
11116
|
-
].map((item) => /* @__PURE__ */
|
|
11736
|
+
].map((item) => /* @__PURE__ */ React114.createElement(
|
|
11117
11737
|
"button",
|
|
11118
11738
|
{
|
|
11119
11739
|
key: item.label,
|
|
@@ -11138,24 +11758,24 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11138
11758
|
}).run();
|
|
11139
11759
|
}
|
|
11140
11760
|
},
|
|
11141
|
-
/* @__PURE__ */
|
|
11761
|
+
/* @__PURE__ */ React114.createElement("span", { className: "bullet-style-icon" }, item.icon),
|
|
11142
11762
|
" ",
|
|
11143
11763
|
item.label
|
|
11144
|
-
)))), show("ol") && /* @__PURE__ */
|
|
11764
|
+
)))), show("ol") && /* @__PURE__ */ React114.createElement("div", { className: "list-split-btn" }, /* @__PURE__ */ React114.createElement(Tooltip, { title: editor.isActive("orderedList") ? "Disable Ordered List" : "Enable Ordered List", placement: "top" }, /* @__PURE__ */ React114.createElement(
|
|
11145
11765
|
"button",
|
|
11146
11766
|
{
|
|
11147
11767
|
className: `toolbar-btn ${editor.isActive("orderedList") ? "is-active" : ""}`,
|
|
11148
11768
|
onClick: () => editor.chain().focus().toggleOrderedList().run()
|
|
11149
11769
|
},
|
|
11150
|
-
/* @__PURE__ */
|
|
11151
|
-
)), /* @__PURE__ */
|
|
11770
|
+
/* @__PURE__ */ React114.createElement(IconOrderedList, null)
|
|
11771
|
+
)), /* @__PURE__ */ React114.createElement(Dropdown, { trigger: { label: "", title: "List style", className: "list-arrow-btn" }, keepOpen: true }, [
|
|
11152
11772
|
{ label: "Default", style: "decimal", icon: "1." },
|
|
11153
11773
|
{ label: "Lower Alpha", style: "lower-alpha", icon: "a." },
|
|
11154
11774
|
{ label: "Lower Greek", style: "lower-greek", icon: "\u03B1." },
|
|
11155
11775
|
{ label: "Lower Roman", style: "lower-roman", icon: "i." },
|
|
11156
11776
|
{ label: "Upper Alpha", style: "upper-alpha", icon: "A." },
|
|
11157
11777
|
{ label: "Upper Roman", style: "upper-roman", icon: "I." }
|
|
11158
|
-
].map((item) => /* @__PURE__ */
|
|
11778
|
+
].map((item) => /* @__PURE__ */ React114.createElement(
|
|
11159
11779
|
"button",
|
|
11160
11780
|
{
|
|
11161
11781
|
key: item.label,
|
|
@@ -11180,24 +11800,24 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11180
11800
|
}).run();
|
|
11181
11801
|
}
|
|
11182
11802
|
},
|
|
11183
|
-
/* @__PURE__ */
|
|
11803
|
+
/* @__PURE__ */ React114.createElement("span", { className: "bullet-style-icon" }, item.icon),
|
|
11184
11804
|
" ",
|
|
11185
11805
|
item.label
|
|
11186
|
-
))))), (show("align") || show("indent") || show("outdent")) && /* @__PURE__ */
|
|
11806
|
+
))))), (show("align") || show("indent") || show("outdent")) && /* @__PURE__ */ React114.createElement("div", { className: "toolbar-group" }, show("align") && /* @__PURE__ */ React114.createElement(
|
|
11187
11807
|
Dropdown,
|
|
11188
11808
|
{
|
|
11189
11809
|
trigger: {
|
|
11190
|
-
label: /* @__PURE__ */
|
|
11810
|
+
label: /* @__PURE__ */ React114.createElement(IconAlignLeft, null),
|
|
11191
11811
|
title: "Align",
|
|
11192
11812
|
className: editor.isActive({ textAlign: "center" }) || editor.isActive({ textAlign: "right" }) || editor.isActive({ textAlign: "justify" }) ? "is-active" : ""
|
|
11193
11813
|
}
|
|
11194
11814
|
},
|
|
11195
11815
|
[
|
|
11196
|
-
{ label: "Align Left", value: "left", icon: /* @__PURE__ */
|
|
11197
|
-
{ label: "Align Center", value: "center", icon: /* @__PURE__ */
|
|
11198
|
-
{ label: "Align Right", value: "right", icon: /* @__PURE__ */
|
|
11199
|
-
{ label: "Align Justify", value: "justify", icon: /* @__PURE__ */
|
|
11200
|
-
].map((item) => /* @__PURE__ */
|
|
11816
|
+
{ label: "Align Left", value: "left", icon: /* @__PURE__ */ React114.createElement(IconAlignLeft, null) },
|
|
11817
|
+
{ label: "Align Center", value: "center", icon: /* @__PURE__ */ React114.createElement(IconAlignCenter, null) },
|
|
11818
|
+
{ label: "Align Right", value: "right", icon: /* @__PURE__ */ React114.createElement(IconAlignRight, null) },
|
|
11819
|
+
{ label: "Align Justify", value: "justify", icon: /* @__PURE__ */ React114.createElement(IconAlignJustify, null) }
|
|
11820
|
+
].map((item) => /* @__PURE__ */ React114.createElement(
|
|
11201
11821
|
"button",
|
|
11202
11822
|
{
|
|
11203
11823
|
key: item.value,
|
|
@@ -11208,7 +11828,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11208
11828
|
" ",
|
|
11209
11829
|
item.label
|
|
11210
11830
|
))
|
|
11211
|
-
), show("indent") && /* @__PURE__ */
|
|
11831
|
+
), show("indent") && /* @__PURE__ */ React114.createElement(Tooltip, { title: "Increase Indent", placement: "top" }, /* @__PURE__ */ React114.createElement(
|
|
11212
11832
|
"button",
|
|
11213
11833
|
{
|
|
11214
11834
|
className: "toolbar-btn",
|
|
@@ -11227,8 +11847,8 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11227
11847
|
}).run();
|
|
11228
11848
|
}
|
|
11229
11849
|
},
|
|
11230
|
-
/* @__PURE__ */
|
|
11231
|
-
)), show("outdent") && /* @__PURE__ */
|
|
11850
|
+
/* @__PURE__ */ React114.createElement(IconIndentIncrease, null)
|
|
11851
|
+
)), show("outdent") && /* @__PURE__ */ React114.createElement(Tooltip, { title: "Decrease Indent", placement: "top" }, /* @__PURE__ */ React114.createElement(
|
|
11232
11852
|
"button",
|
|
11233
11853
|
{
|
|
11234
11854
|
className: "toolbar-btn",
|
|
@@ -11247,29 +11867,29 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11247
11867
|
}).run();
|
|
11248
11868
|
}
|
|
11249
11869
|
},
|
|
11250
|
-
/* @__PURE__ */
|
|
11251
|
-
))), show("table") && /* @__PURE__ */
|
|
11870
|
+
/* @__PURE__ */ React114.createElement(IconIndentDecrease, null)
|
|
11871
|
+
))), show("table") && /* @__PURE__ */ React114.createElement(Dropdown, { trigger: { label: /* @__PURE__ */ React114.createElement(IconTable, null), title: "Insert Table" }, keepOpen: true }, (close) => /* @__PURE__ */ React114.createElement(TableGridSelector, { editor, onClose: close })), show("image") && /* @__PURE__ */ React114.createElement(Dropdown, { trigger: { label: /* @__PURE__ */ React114.createElement(IconImage, null), title: "Insert Image" }, keepOpen: true }, (close) => /* @__PURE__ */ React114.createElement(ImagePanel, { editor, onClose: close, onImageUpload })), show("video") && /* @__PURE__ */ React114.createElement(Dropdown, { trigger: { label: /* @__PURE__ */ React114.createElement(IconVideo, null), title: "Insert Video" }, keepOpen: true }, (close) => /* @__PURE__ */ React114.createElement(InsertPanel, { editor, onClose: close, mode: "video" })), show("cut") && /* @__PURE__ */ React114.createElement(Tooltip, { title: "Cut (Ctrl+X)", placement: "top" }, /* @__PURE__ */ React114.createElement(
|
|
11252
11872
|
"button",
|
|
11253
11873
|
{
|
|
11254
11874
|
className: "toolbar-btn",
|
|
11255
11875
|
onClick: () => document.execCommand("cut")
|
|
11256
11876
|
},
|
|
11257
|
-
/* @__PURE__ */
|
|
11258
|
-
)), show("copy") && /* @__PURE__ */
|
|
11877
|
+
/* @__PURE__ */ React114.createElement(IconCut, null)
|
|
11878
|
+
)), show("copy") && /* @__PURE__ */ React114.createElement(Tooltip, { title: "Copy selected text", placement: "top" }, /* @__PURE__ */ React114.createElement(
|
|
11259
11879
|
"button",
|
|
11260
11880
|
{
|
|
11261
11881
|
className: "toolbar-btn",
|
|
11262
11882
|
onClick: handleCopy
|
|
11263
11883
|
},
|
|
11264
|
-
copySuccess ? /* @__PURE__ */
|
|
11265
|
-
)), show("paste") && /* @__PURE__ */
|
|
11884
|
+
copySuccess ? /* @__PURE__ */ React114.createElement(IconCheck, null) : /* @__PURE__ */ React114.createElement(IconCopy, null)
|
|
11885
|
+
)), show("paste") && /* @__PURE__ */ React114.createElement(Tooltip, { title: "Paste (Ctrl+V)", placement: "top" }, /* @__PURE__ */ React114.createElement(
|
|
11266
11886
|
"button",
|
|
11267
11887
|
{
|
|
11268
11888
|
className: "toolbar-btn",
|
|
11269
11889
|
onClick: handlePaste
|
|
11270
11890
|
},
|
|
11271
|
-
/* @__PURE__ */
|
|
11272
|
-
)), show("specialchars") && /* @__PURE__ */
|
|
11891
|
+
/* @__PURE__ */ React114.createElement(IconPaste, null)
|
|
11892
|
+
)), show("specialchars") && /* @__PURE__ */ React114.createElement(Dropdown, { trigger: { label: "\u03A9", title: "Special characters", className: "special-characters-btn" } }, /* @__PURE__ */ React114.createElement("div", { className: "char-grid" }, SPECIAL_CHARS.map((char) => /* @__PURE__ */ React114.createElement(
|
|
11273
11893
|
"button",
|
|
11274
11894
|
{
|
|
11275
11895
|
key: char,
|
|
@@ -11277,12 +11897,12 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11277
11897
|
onClick: () => insertSpecialChar(char)
|
|
11278
11898
|
},
|
|
11279
11899
|
char
|
|
11280
|
-
)))), show("code") && /* @__PURE__ */
|
|
11900
|
+
)))), show("code") && /* @__PURE__ */ React114.createElement(
|
|
11281
11901
|
Dropdown,
|
|
11282
11902
|
{
|
|
11283
|
-
trigger: { label: /* @__PURE__ */
|
|
11903
|
+
trigger: { label: /* @__PURE__ */ React114.createElement(IconCode, null), title: "Code", className: editor.isActive("code") || editor.isActive("codeBlock") ? "is-active" : "" }
|
|
11284
11904
|
},
|
|
11285
|
-
/* @__PURE__ */
|
|
11905
|
+
/* @__PURE__ */ React114.createElement("button", { className: "dropdown-item", onClick: () => {
|
|
11286
11906
|
if (editor.isActive("codeBlock")) {
|
|
11287
11907
|
const text = (() => {
|
|
11288
11908
|
const { $from } = editor.state.selection;
|
|
@@ -11300,22 +11920,22 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11300
11920
|
editor.chain().focus().toggleCode().run();
|
|
11301
11921
|
}
|
|
11302
11922
|
} }, "</>", " Inline Code"),
|
|
11303
|
-
/* @__PURE__ */
|
|
11304
|
-
), show("fullscreen") && /* @__PURE__ */
|
|
11923
|
+
/* @__PURE__ */ React114.createElement("button", { className: "dropdown-item", onClick: () => editor.chain().focus().toggleCodeBlock().run() }, "{ }", " Code Block")
|
|
11924
|
+
), show("fullscreen") && /* @__PURE__ */ React114.createElement(Tooltip, { title: "Toggle Fullscreen", placement: "top" }, /* @__PURE__ */ React114.createElement(
|
|
11305
11925
|
"button",
|
|
11306
11926
|
{
|
|
11307
11927
|
className: `toolbar-btn ${isFullscreen ? "is-active" : ""}`,
|
|
11308
11928
|
onClick: onToggleFullscreen
|
|
11309
11929
|
},
|
|
11310
|
-
/* @__PURE__ */
|
|
11311
|
-
)), show("tts") && /* @__PURE__ */
|
|
11930
|
+
/* @__PURE__ */ React114.createElement(IconFullscreen, null)
|
|
11931
|
+
)), show("tts") && /* @__PURE__ */ React114.createElement(TextToSpeech_default, { ref: ttsRef, editor, onTextToSpeech }), show("stt") && /* @__PURE__ */ React114.createElement(SpeechToText_default, { ref: sttRef, editor, onSpeechToText }), show("translate") && /* @__PURE__ */ React114.createElement("div", { className: "translate-split-btn" }, /* @__PURE__ */ React114.createElement(Tooltip, { title: "Translate selected text", placement: "top" }, /* @__PURE__ */ React114.createElement(
|
|
11312
11932
|
"button",
|
|
11313
11933
|
{
|
|
11314
11934
|
className: "toolbar-btn",
|
|
11315
11935
|
onClick: handleQuickTranslate
|
|
11316
11936
|
},
|
|
11317
|
-
/* @__PURE__ */
|
|
11318
|
-
)), /* @__PURE__ */
|
|
11937
|
+
/* @__PURE__ */ React114.createElement(IconTranslate, null)
|
|
11938
|
+
)), /* @__PURE__ */ React114.createElement(Dropdown, { trigger: { label: "", title: "Translate options", className: "translate-arrow-btn" } }, /* @__PURE__ */ React114.createElement("button", { className: "dropdown-item", onClick: () => setShowTranslateModal(true) }, "Options")), translateStatus && /* @__PURE__ */ React114.createElement("span", { className: `translate-toast-popup ${translateStatus === "Please select the text" || translateStatus === "Translation failed" ? "error" : ""}` }, translateStatus)), show("todo") && /* @__PURE__ */ React114.createElement("div", { className: "todo-split-btn" }, /* @__PURE__ */ React114.createElement(Tooltip, { title: todoEnabled ? "Disable Task List" : "Enable Task List", placement: "top" }, /* @__PURE__ */ React114.createElement(
|
|
11319
11939
|
"button",
|
|
11320
11940
|
{
|
|
11321
11941
|
className: `toolbar-btn ${todoEnabled ? "is-active" : ""}`,
|
|
@@ -11358,11 +11978,11 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11358
11978
|
}
|
|
11359
11979
|
}
|
|
11360
11980
|
},
|
|
11361
|
-
/* @__PURE__ */
|
|
11362
|
-
)), /* @__PURE__ */
|
|
11981
|
+
/* @__PURE__ */ React114.createElement(IconTaskList, null)
|
|
11982
|
+
)), /* @__PURE__ */ React114.createElement(Dropdown, { trigger: { label: "", title: "Task status", className: "todo-arrow-btn" }, keepOpen: true }, ["todo", "working", "blocked", "resolved"].map((status) => {
|
|
11363
11983
|
const images = { todo: "https://storage.googleapis.com/rufous-com-bucket-1/static/images/todo-blank.svg", working: "https://storage.googleapis.com/rufous-com-bucket-1/static/images/working.svg", blocked: "https://storage.googleapis.com/rufous-com-bucket-1/static/images/blocked.svg", resolved: "https://storage.googleapis.com/rufous-com-bucket-1/static/images/closed.svg" };
|
|
11364
11984
|
const labels = { todo: "Todo", working: "Working", blocked: "Blocked", resolved: "Resolved" };
|
|
11365
|
-
return /* @__PURE__ */
|
|
11985
|
+
return /* @__PURE__ */ React114.createElement("button", { key: status, className: "dropdown-item task-status-item", onClick: () => {
|
|
11366
11986
|
const { state } = editor;
|
|
11367
11987
|
const { schema } = state;
|
|
11368
11988
|
const taskItemType = schema.nodes.taskItem;
|
|
@@ -11395,8 +12015,8 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11395
12015
|
}
|
|
11396
12016
|
return true;
|
|
11397
12017
|
}).run();
|
|
11398
|
-
} }, /* @__PURE__ */
|
|
11399
|
-
})))), onClose && /* @__PURE__ */
|
|
12018
|
+
} }, /* @__PURE__ */ React114.createElement("span", { className: `task-icon task-${status}` }, /* @__PURE__ */ React114.createElement("img", { src: images[status], alt: status })), " ", labels[status]);
|
|
12019
|
+
})))), onClose && /* @__PURE__ */ React114.createElement("div", { className: "toolbar-row-right" }, /* @__PURE__ */ React114.createElement(Tooltip, { title: "Close", placement: "top" }, /* @__PURE__ */ React114.createElement(
|
|
11400
12020
|
"button",
|
|
11401
12021
|
{
|
|
11402
12022
|
className: "toolbar-btn btn-cross",
|
|
@@ -11412,8 +12032,8 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11412
12032
|
onClose();
|
|
11413
12033
|
}
|
|
11414
12034
|
},
|
|
11415
|
-
/* @__PURE__ */
|
|
11416
|
-
))), showTranslateModal && /* @__PURE__ */
|
|
12035
|
+
/* @__PURE__ */ React114.createElement(closeIcon_default, { color: "#a81c08" })
|
|
12036
|
+
))), showTranslateModal && /* @__PURE__ */ React114.createElement(
|
|
11417
12037
|
TranslateModal_default,
|
|
11418
12038
|
{
|
|
11419
12039
|
editor,
|
|
@@ -11431,7 +12051,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11431
12051
|
var Toolbar_default = Toolbar;
|
|
11432
12052
|
|
|
11433
12053
|
// lib/RufousTextEditor/ImageToolbar.tsx
|
|
11434
|
-
import
|
|
12054
|
+
import React115, { useState as useState32, useEffect as useEffect26, useRef as useRef29 } from "react";
|
|
11435
12055
|
import { createPortal as createPortal5 } from "react-dom";
|
|
11436
12056
|
var ALIGNMENTS = [
|
|
11437
12057
|
{ value: "left", label: "Left", icon: "\u2630" },
|
|
@@ -11439,18 +12059,18 @@ var ALIGNMENTS = [
|
|
|
11439
12059
|
{ value: "right", label: "Right", icon: "\u2263" }
|
|
11440
12060
|
];
|
|
11441
12061
|
var ImagePropertiesModal = ({ editor, node, onClose }) => {
|
|
11442
|
-
const [activeTab, setActiveTab] =
|
|
11443
|
-
const [src, setSrc] =
|
|
11444
|
-
const [title, setTitle] =
|
|
11445
|
-
const [alt, setAlt] =
|
|
11446
|
-
const [link, setLink] =
|
|
11447
|
-
const [openInNewTab, setOpenInNewTab] =
|
|
11448
|
-
const [width, setWidth] =
|
|
11449
|
-
const [height, setHeight] =
|
|
11450
|
-
const [lockRatio, setLockRatio] =
|
|
11451
|
-
const [naturalWidth, setNaturalWidth] =
|
|
11452
|
-
const [naturalHeight, setNaturalHeight] =
|
|
11453
|
-
|
|
12062
|
+
const [activeTab, setActiveTab] = useState32("image");
|
|
12063
|
+
const [src, setSrc] = useState32(node?.attrs?.src || "");
|
|
12064
|
+
const [title, setTitle] = useState32(node?.attrs?.title || "");
|
|
12065
|
+
const [alt, setAlt] = useState32(node?.attrs?.alt || "");
|
|
12066
|
+
const [link, setLink] = useState32("");
|
|
12067
|
+
const [openInNewTab, setOpenInNewTab] = useState32(false);
|
|
12068
|
+
const [width, setWidth] = useState32("");
|
|
12069
|
+
const [height, setHeight] = useState32("");
|
|
12070
|
+
const [lockRatio, setLockRatio] = useState32(true);
|
|
12071
|
+
const [naturalWidth, setNaturalWidth] = useState32(0);
|
|
12072
|
+
const [naturalHeight, setNaturalHeight] = useState32(0);
|
|
12073
|
+
useEffect26(() => {
|
|
11454
12074
|
if (src) {
|
|
11455
12075
|
const img = new window.Image();
|
|
11456
12076
|
img.onload = () => {
|
|
@@ -11489,7 +12109,7 @@ var ImagePropertiesModal = ({ editor, node, onClose }) => {
|
|
|
11489
12109
|
editor.chain().focus().deleteSelection().run();
|
|
11490
12110
|
onClose();
|
|
11491
12111
|
};
|
|
11492
|
-
return /* @__PURE__ */
|
|
12112
|
+
return /* @__PURE__ */ React115.createElement("div", { className: "modal-overlay", onClick: onClose }, /* @__PURE__ */ React115.createElement("div", { className: "modal-content", onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ React115.createElement("div", { className: "modal-header" }, /* @__PURE__ */ React115.createElement("h3", null, "Image properties"), /* @__PURE__ */ React115.createElement("button", { className: "modal-close", onClick: onClose }, "\xD7")), /* @__PURE__ */ React115.createElement("div", { className: "modal-body" }, /* @__PURE__ */ React115.createElement("div", { className: "modal-layout" }, /* @__PURE__ */ React115.createElement("div", { className: "modal-preview-col" }, src && /* @__PURE__ */ React115.createElement("div", { className: "modal-preview" }, /* @__PURE__ */ React115.createElement("img", { src, alt: alt || "Preview" })), /* @__PURE__ */ React115.createElement("div", { className: "modal-dimensions" }, /* @__PURE__ */ React115.createElement(
|
|
11493
12113
|
"input",
|
|
11494
12114
|
{
|
|
11495
12115
|
type: "number",
|
|
@@ -11497,14 +12117,14 @@ var ImagePropertiesModal = ({ editor, node, onClose }) => {
|
|
|
11497
12117
|
value: width,
|
|
11498
12118
|
onChange: (e) => handleWidthChange(e.target.value)
|
|
11499
12119
|
}
|
|
11500
|
-
), /* @__PURE__ */
|
|
12120
|
+
), /* @__PURE__ */ React115.createElement(Tooltip, { title: lockRatio ? "Unlock aspect ratio" : "Lock aspect ratio", placement: "top" }, /* @__PURE__ */ React115.createElement(
|
|
11501
12121
|
"button",
|
|
11502
12122
|
{
|
|
11503
12123
|
className: `lock-btn ${lockRatio ? "locked" : ""}`,
|
|
11504
12124
|
onClick: () => setLockRatio(!lockRatio)
|
|
11505
12125
|
},
|
|
11506
12126
|
lockRatio ? "\u{1F512}" : "\u{1F513}"
|
|
11507
|
-
)), /* @__PURE__ */
|
|
12127
|
+
)), /* @__PURE__ */ React115.createElement(
|
|
11508
12128
|
"input",
|
|
11509
12129
|
{
|
|
11510
12130
|
type: "number",
|
|
@@ -11512,21 +12132,21 @@ var ImagePropertiesModal = ({ editor, node, onClose }) => {
|
|
|
11512
12132
|
value: height,
|
|
11513
12133
|
onChange: (e) => handleHeightChange(e.target.value)
|
|
11514
12134
|
}
|
|
11515
|
-
))), /* @__PURE__ */
|
|
12135
|
+
))), /* @__PURE__ */ React115.createElement("div", { className: "modal-fields-col" }, /* @__PURE__ */ React115.createElement("div", { className: "modal-tabs" }, /* @__PURE__ */ React115.createElement(
|
|
11516
12136
|
"button",
|
|
11517
12137
|
{
|
|
11518
12138
|
className: `modal-tab ${activeTab === "image" ? "active" : ""}`,
|
|
11519
12139
|
onClick: () => setActiveTab("image")
|
|
11520
12140
|
},
|
|
11521
12141
|
"Image"
|
|
11522
|
-
), /* @__PURE__ */
|
|
12142
|
+
), /* @__PURE__ */ React115.createElement(
|
|
11523
12143
|
"button",
|
|
11524
12144
|
{
|
|
11525
12145
|
className: `modal-tab ${activeTab === "advanced" ? "active" : ""}`,
|
|
11526
12146
|
onClick: () => setActiveTab("advanced")
|
|
11527
12147
|
},
|
|
11528
12148
|
"Advanced"
|
|
11529
|
-
)), activeTab === "image" ? /* @__PURE__ */
|
|
12149
|
+
)), activeTab === "image" ? /* @__PURE__ */ React115.createElement(React115.Fragment, null, /* @__PURE__ */ React115.createElement("label", { className: "modal-label" }, "Src"), /* @__PURE__ */ React115.createElement(
|
|
11530
12150
|
"input",
|
|
11531
12151
|
{
|
|
11532
12152
|
type: "text",
|
|
@@ -11534,7 +12154,7 @@ var ImagePropertiesModal = ({ editor, node, onClose }) => {
|
|
|
11534
12154
|
value: src,
|
|
11535
12155
|
onChange: (e) => setSrc(e.target.value)
|
|
11536
12156
|
}
|
|
11537
|
-
), /* @__PURE__ */
|
|
12157
|
+
), /* @__PURE__ */ React115.createElement("label", { className: "modal-label" }, "Title"), /* @__PURE__ */ React115.createElement(
|
|
11538
12158
|
"input",
|
|
11539
12159
|
{
|
|
11540
12160
|
type: "text",
|
|
@@ -11542,7 +12162,7 @@ var ImagePropertiesModal = ({ editor, node, onClose }) => {
|
|
|
11542
12162
|
value: title,
|
|
11543
12163
|
onChange: (e) => setTitle(e.target.value)
|
|
11544
12164
|
}
|
|
11545
|
-
), /* @__PURE__ */
|
|
12165
|
+
), /* @__PURE__ */ React115.createElement("label", { className: "modal-label" }, "Alternative"), /* @__PURE__ */ React115.createElement(
|
|
11546
12166
|
"input",
|
|
11547
12167
|
{
|
|
11548
12168
|
type: "text",
|
|
@@ -11550,7 +12170,7 @@ var ImagePropertiesModal = ({ editor, node, onClose }) => {
|
|
|
11550
12170
|
value: alt,
|
|
11551
12171
|
onChange: (e) => setAlt(e.target.value)
|
|
11552
12172
|
}
|
|
11553
|
-
), /* @__PURE__ */
|
|
12173
|
+
), /* @__PURE__ */ React115.createElement("label", { className: "modal-label" }, "Link"), /* @__PURE__ */ React115.createElement(
|
|
11554
12174
|
"input",
|
|
11555
12175
|
{
|
|
11556
12176
|
type: "text",
|
|
@@ -11558,23 +12178,23 @@ var ImagePropertiesModal = ({ editor, node, onClose }) => {
|
|
|
11558
12178
|
value: link,
|
|
11559
12179
|
onChange: (e) => setLink(e.target.value)
|
|
11560
12180
|
}
|
|
11561
|
-
), /* @__PURE__ */
|
|
12181
|
+
), /* @__PURE__ */ React115.createElement("label", { className: "modal-checkbox" }, /* @__PURE__ */ React115.createElement(
|
|
11562
12182
|
"input",
|
|
11563
12183
|
{
|
|
11564
12184
|
type: "checkbox",
|
|
11565
12185
|
checked: openInNewTab,
|
|
11566
12186
|
onChange: (e) => setOpenInNewTab(e.target.checked)
|
|
11567
12187
|
}
|
|
11568
|
-
), "Open link in new tab")) : /* @__PURE__ */
|
|
12188
|
+
), "Open link in new tab")) : /* @__PURE__ */ React115.createElement(React115.Fragment, null, /* @__PURE__ */ React115.createElement("label", { className: "modal-label" }, "CSS Class"), /* @__PURE__ */ React115.createElement("input", { type: "text", className: "modal-input", placeholder: "e.g. rounded shadow" }), /* @__PURE__ */ React115.createElement("label", { className: "modal-label" }, "Inline Style"), /* @__PURE__ */ React115.createElement("input", { type: "text", className: "modal-input", placeholder: "e.g. border: 1px solid #ccc" }))))), /* @__PURE__ */ React115.createElement("div", { className: "modal-footer" }, /* @__PURE__ */ React115.createElement("div", { className: "modal-footer-left" }, /* @__PURE__ */ React115.createElement("button", { className: "modal-btn-cancel", onClick: onClose }, "Cancel"), /* @__PURE__ */ React115.createElement("button", { className: "modal-btn-delete", onClick: handleDelete }, "Delete")), /* @__PURE__ */ React115.createElement("button", { className: "modal-btn-apply", onClick: handleApply }, "Apply"))));
|
|
11569
12189
|
};
|
|
11570
12190
|
var ImageToolbar = ({ editor }) => {
|
|
11571
|
-
const [showModal, setShowModal] =
|
|
11572
|
-
const [showAlign, setShowAlign] =
|
|
11573
|
-
const [showVAlign, setShowVAlign] =
|
|
11574
|
-
const [copyStatus, setCopyStatus] =
|
|
11575
|
-
const [pos, setPos] =
|
|
11576
|
-
const toolbarRef =
|
|
11577
|
-
|
|
12191
|
+
const [showModal, setShowModal] = useState32(false);
|
|
12192
|
+
const [showAlign, setShowAlign] = useState32(false);
|
|
12193
|
+
const [showVAlign, setShowVAlign] = useState32(false);
|
|
12194
|
+
const [copyStatus, setCopyStatus] = useState32("");
|
|
12195
|
+
const [pos, setPos] = useState32(null);
|
|
12196
|
+
const toolbarRef = useRef29(null);
|
|
12197
|
+
useEffect26(() => {
|
|
11578
12198
|
if (!editor) return;
|
|
11579
12199
|
const update = () => {
|
|
11580
12200
|
const { selection } = editor.state;
|
|
@@ -11604,7 +12224,7 @@ var ImageToolbar = ({ editor }) => {
|
|
|
11604
12224
|
const node = editor?.state.selection.node;
|
|
11605
12225
|
const isImage = node && node.type.name === "image";
|
|
11606
12226
|
if (!editor || !isImage || !pos) return showModal ? createPortal5(
|
|
11607
|
-
/* @__PURE__ */
|
|
12227
|
+
/* @__PURE__ */ React115.createElement(ImagePropertiesModal, { editor, node, onClose: () => setShowModal(false) }),
|
|
11608
12228
|
document.body
|
|
11609
12229
|
) : null;
|
|
11610
12230
|
const handleDelete = () => {
|
|
@@ -11681,7 +12301,7 @@ var ImageToolbar = ({ editor }) => {
|
|
|
11681
12301
|
setShowVAlign(false);
|
|
11682
12302
|
};
|
|
11683
12303
|
return createPortal5(
|
|
11684
|
-
/* @__PURE__ */
|
|
12304
|
+
/* @__PURE__ */ React115.createElement(React115.Fragment, null, /* @__PURE__ */ React115.createElement(
|
|
11685
12305
|
"div",
|
|
11686
12306
|
{
|
|
11687
12307
|
className: "image-toolbar",
|
|
@@ -11689,14 +12309,14 @@ var ImageToolbar = ({ editor }) => {
|
|
|
11689
12309
|
style: { position: "absolute", top: pos.top, left: pos.left, zIndex: 1e3 },
|
|
11690
12310
|
onMouseDown: (e) => e.preventDefault()
|
|
11691
12311
|
},
|
|
11692
|
-
/* @__PURE__ */
|
|
11693
|
-
/* @__PURE__ */
|
|
11694
|
-
/* @__PURE__ */
|
|
11695
|
-
/* @__PURE__ */
|
|
12312
|
+
/* @__PURE__ */ React115.createElement(Tooltip, { title: "Delete", placement: "top" }, /* @__PURE__ */ React115.createElement("button", { className: "img-tool-btn", onClick: handleDelete }, "\u{1F5D1}")),
|
|
12313
|
+
/* @__PURE__ */ React115.createElement(Tooltip, { title: "Edit properties", placement: "top" }, /* @__PURE__ */ React115.createElement("button", { className: "img-tool-btn", onClick: () => setShowModal(true) }, "\u270E")),
|
|
12314
|
+
/* @__PURE__ */ React115.createElement("div", { className: "img-tool-copy-wrapper" }, /* @__PURE__ */ React115.createElement(Tooltip, { title: "Copy image", placement: "top" }, /* @__PURE__ */ React115.createElement("button", { className: "img-tool-btn", onClick: handleCopy }, copyStatus ? "\u2713" : "\u{1F4CB}")), copyStatus && /* @__PURE__ */ React115.createElement("span", { className: "img-copy-toast" }, copyStatus)),
|
|
12315
|
+
/* @__PURE__ */ React115.createElement("div", { className: "img-tool-dropdown" }, /* @__PURE__ */ React115.createElement(Tooltip, { title: "Horizontal alignment", placement: "top" }, /* @__PURE__ */ React115.createElement("button", { className: "img-tool-btn", onClick: () => {
|
|
11696
12316
|
setShowAlign(!showAlign);
|
|
11697
12317
|
setShowVAlign(false);
|
|
11698
|
-
} }, "\u2630 ", /* @__PURE__ */
|
|
11699
|
-
), showModal && /* @__PURE__ */
|
|
12318
|
+
} }, "\u2630 ", /* @__PURE__ */ React115.createElement("span", { className: "dropdown-arrow" }, "\u25BE"))), showAlign && /* @__PURE__ */ React115.createElement("div", { className: "img-tool-menu" }, ALIGNMENTS.map((a) => /* @__PURE__ */ React115.createElement("button", { key: a.value, className: "dropdown-item", onClick: () => setAlignmentVal(a.value) }, a.icon, " ", a.label))))
|
|
12319
|
+
), showModal && /* @__PURE__ */ React115.createElement(
|
|
11700
12320
|
ImagePropertiesModal,
|
|
11701
12321
|
{
|
|
11702
12322
|
editor,
|
|
@@ -11710,7 +12330,7 @@ var ImageToolbar = ({ editor }) => {
|
|
|
11710
12330
|
var ImageToolbar_default = ImageToolbar;
|
|
11711
12331
|
|
|
11712
12332
|
// lib/RufousTextEditor/VideoToolbar.tsx
|
|
11713
|
-
import
|
|
12333
|
+
import React116, { useState as useState33, useEffect as useEffect27, useRef as useRef30 } from "react";
|
|
11714
12334
|
import { createPortal as createPortal6 } from "react-dom";
|
|
11715
12335
|
var ALIGNMENTS2 = [
|
|
11716
12336
|
{ value: "left", label: "Left", icon: "\u2630" },
|
|
@@ -11719,10 +12339,10 @@ var ALIGNMENTS2 = [
|
|
|
11719
12339
|
];
|
|
11720
12340
|
var VIDEO_TYPES = ["youtube", "video"];
|
|
11721
12341
|
var VideoPropertiesModal = ({ editor, node, nodeType, onClose }) => {
|
|
11722
|
-
const [src, setSrc] =
|
|
11723
|
-
const [width, setWidth] =
|
|
11724
|
-
const [height, setHeight] =
|
|
11725
|
-
const [lockRatio, setLockRatio] =
|
|
12342
|
+
const [src, setSrc] = useState33(node?.attrs?.src || "");
|
|
12343
|
+
const [width, setWidth] = useState33(String(node?.attrs?.width || 640));
|
|
12344
|
+
const [height, setHeight] = useState33(String(node?.attrs?.height || 360));
|
|
12345
|
+
const [lockRatio, setLockRatio] = useState33(true);
|
|
11726
12346
|
const handleWidthChange = (val) => {
|
|
11727
12347
|
setWidth(val);
|
|
11728
12348
|
if (lockRatio) {
|
|
@@ -11755,7 +12375,7 @@ var VideoPropertiesModal = ({ editor, node, nodeType, onClose }) => {
|
|
|
11755
12375
|
onClose();
|
|
11756
12376
|
};
|
|
11757
12377
|
const isYoutube = nodeType === "youtube";
|
|
11758
|
-
return /* @__PURE__ */
|
|
12378
|
+
return /* @__PURE__ */ React116.createElement("div", { className: "modal-overlay", onClick: onClose }, /* @__PURE__ */ React116.createElement("div", { className: "modal-content", onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ React116.createElement("div", { className: "modal-header" }, /* @__PURE__ */ React116.createElement("h3", null, "Video properties"), /* @__PURE__ */ React116.createElement("button", { className: "modal-close", onClick: onClose }, "\xD7")), /* @__PURE__ */ React116.createElement("div", { className: "modal-body" }, /* @__PURE__ */ React116.createElement("div", { className: "modal-layout" }, /* @__PURE__ */ React116.createElement("div", { className: "modal-preview-col" }, src && /* @__PURE__ */ React116.createElement("div", { className: "modal-preview", style: { background: "#000" } }, isYoutube ? /* @__PURE__ */ React116.createElement(
|
|
11759
12379
|
"iframe",
|
|
11760
12380
|
{
|
|
11761
12381
|
src,
|
|
@@ -11763,14 +12383,14 @@ var VideoPropertiesModal = ({ editor, node, nodeType, onClose }) => {
|
|
|
11763
12383
|
style: { width: "100%", aspectRatio: "16/9", border: "none", display: "block" },
|
|
11764
12384
|
allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
|
11765
12385
|
}
|
|
11766
|
-
) : /* @__PURE__ */
|
|
12386
|
+
) : /* @__PURE__ */ React116.createElement(
|
|
11767
12387
|
"video",
|
|
11768
12388
|
{
|
|
11769
12389
|
src,
|
|
11770
12390
|
controls: true,
|
|
11771
12391
|
style: { width: "100%", aspectRatio: "16/9", display: "block" }
|
|
11772
12392
|
}
|
|
11773
|
-
)), /* @__PURE__ */
|
|
12393
|
+
)), /* @__PURE__ */ React116.createElement("div", { className: "modal-dimensions" }, /* @__PURE__ */ React116.createElement(
|
|
11774
12394
|
"input",
|
|
11775
12395
|
{
|
|
11776
12396
|
type: "number",
|
|
@@ -11778,14 +12398,14 @@ var VideoPropertiesModal = ({ editor, node, nodeType, onClose }) => {
|
|
|
11778
12398
|
value: width,
|
|
11779
12399
|
onChange: (e) => handleWidthChange(e.target.value)
|
|
11780
12400
|
}
|
|
11781
|
-
), /* @__PURE__ */
|
|
12401
|
+
), /* @__PURE__ */ React116.createElement(Tooltip, { title: lockRatio ? "Unlock aspect ratio" : "Lock aspect ratio", placement: "top" }, /* @__PURE__ */ React116.createElement(
|
|
11782
12402
|
"button",
|
|
11783
12403
|
{
|
|
11784
12404
|
className: `lock-btn ${lockRatio ? "locked" : ""}`,
|
|
11785
12405
|
onClick: () => setLockRatio(!lockRatio)
|
|
11786
12406
|
},
|
|
11787
12407
|
lockRatio ? "\u{1F512}" : "\u{1F513}"
|
|
11788
|
-
)), /* @__PURE__ */
|
|
12408
|
+
)), /* @__PURE__ */ React116.createElement(
|
|
11789
12409
|
"input",
|
|
11790
12410
|
{
|
|
11791
12411
|
type: "number",
|
|
@@ -11793,7 +12413,7 @@ var VideoPropertiesModal = ({ editor, node, nodeType, onClose }) => {
|
|
|
11793
12413
|
value: height,
|
|
11794
12414
|
onChange: (e) => handleHeightChange(e.target.value)
|
|
11795
12415
|
}
|
|
11796
|
-
))), /* @__PURE__ */
|
|
12416
|
+
))), /* @__PURE__ */ React116.createElement("div", { className: "modal-fields-col" }, /* @__PURE__ */ React116.createElement("label", { className: "modal-label" }, "Video URL"), /* @__PURE__ */ React116.createElement(
|
|
11797
12417
|
"input",
|
|
11798
12418
|
{
|
|
11799
12419
|
type: "text",
|
|
@@ -11801,7 +12421,7 @@ var VideoPropertiesModal = ({ editor, node, nodeType, onClose }) => {
|
|
|
11801
12421
|
value: src,
|
|
11802
12422
|
onChange: (e) => setSrc(e.target.value)
|
|
11803
12423
|
}
|
|
11804
|
-
), /* @__PURE__ */
|
|
12424
|
+
), /* @__PURE__ */ React116.createElement("label", { className: "modal-label" }, "Width"), /* @__PURE__ */ React116.createElement(
|
|
11805
12425
|
"input",
|
|
11806
12426
|
{
|
|
11807
12427
|
type: "number",
|
|
@@ -11809,7 +12429,7 @@ var VideoPropertiesModal = ({ editor, node, nodeType, onClose }) => {
|
|
|
11809
12429
|
value: width,
|
|
11810
12430
|
onChange: (e) => handleWidthChange(e.target.value)
|
|
11811
12431
|
}
|
|
11812
|
-
), /* @__PURE__ */
|
|
12432
|
+
), /* @__PURE__ */ React116.createElement("label", { className: "modal-label" }, "Height"), /* @__PURE__ */ React116.createElement(
|
|
11813
12433
|
"input",
|
|
11814
12434
|
{
|
|
11815
12435
|
type: "number",
|
|
@@ -11817,16 +12437,16 @@ var VideoPropertiesModal = ({ editor, node, nodeType, onClose }) => {
|
|
|
11817
12437
|
value: height,
|
|
11818
12438
|
onChange: (e) => handleHeightChange(e.target.value)
|
|
11819
12439
|
}
|
|
11820
|
-
)))), /* @__PURE__ */
|
|
12440
|
+
)))), /* @__PURE__ */ React116.createElement("div", { className: "modal-footer" }, /* @__PURE__ */ React116.createElement("div", { className: "modal-footer-left" }, /* @__PURE__ */ React116.createElement("button", { className: "modal-btn-cancel", onClick: onClose }, "Cancel"), /* @__PURE__ */ React116.createElement("button", { className: "modal-btn-delete", onClick: handleDelete }, "Delete")), /* @__PURE__ */ React116.createElement("button", { className: "modal-btn-apply", onClick: handleApply }, "Apply"))));
|
|
11821
12441
|
};
|
|
11822
12442
|
var VideoToolbar = ({ editor }) => {
|
|
11823
|
-
const [showModal, setShowModal] =
|
|
11824
|
-
const [showSize, setShowSize] =
|
|
11825
|
-
const [showAlign, setShowAlign] =
|
|
11826
|
-
const [copyStatus, setCopyStatus] =
|
|
11827
|
-
const [pos, setPos] =
|
|
11828
|
-
const toolbarRef =
|
|
11829
|
-
|
|
12443
|
+
const [showModal, setShowModal] = useState33(false);
|
|
12444
|
+
const [showSize, setShowSize] = useState33(false);
|
|
12445
|
+
const [showAlign, setShowAlign] = useState33(false);
|
|
12446
|
+
const [copyStatus, setCopyStatus] = useState33("");
|
|
12447
|
+
const [pos, setPos] = useState33(null);
|
|
12448
|
+
const toolbarRef = useRef30(null);
|
|
12449
|
+
useEffect27(() => {
|
|
11830
12450
|
if (!editor) return;
|
|
11831
12451
|
const update = () => {
|
|
11832
12452
|
const { selection } = editor.state;
|
|
@@ -11857,7 +12477,7 @@ var VideoToolbar = ({ editor }) => {
|
|
|
11857
12477
|
const isVideo = node && VIDEO_TYPES.includes(node.type.name);
|
|
11858
12478
|
const nodeType = node?.type.name;
|
|
11859
12479
|
if (!editor || !isVideo || !pos) return showModal ? createPortal6(
|
|
11860
|
-
/* @__PURE__ */
|
|
12480
|
+
/* @__PURE__ */ React116.createElement(VideoPropertiesModal, { editor, node, nodeType, onClose: () => setShowModal(false) }),
|
|
11861
12481
|
document.body
|
|
11862
12482
|
) : null;
|
|
11863
12483
|
const handleDelete = () => {
|
|
@@ -11904,7 +12524,7 @@ var VideoToolbar = ({ editor }) => {
|
|
|
11904
12524
|
);
|
|
11905
12525
|
};
|
|
11906
12526
|
return createPortal6(
|
|
11907
|
-
/* @__PURE__ */
|
|
12527
|
+
/* @__PURE__ */ React116.createElement(React116.Fragment, null, /* @__PURE__ */ React116.createElement(
|
|
11908
12528
|
"div",
|
|
11909
12529
|
{
|
|
11910
12530
|
className: "image-toolbar",
|
|
@@ -11912,30 +12532,30 @@ var VideoToolbar = ({ editor }) => {
|
|
|
11912
12532
|
style: { position: "absolute", top: pos.top, left: pos.left, zIndex: 1e3 },
|
|
11913
12533
|
onMouseDown: (e) => e.preventDefault()
|
|
11914
12534
|
},
|
|
11915
|
-
/* @__PURE__ */
|
|
11916
|
-
/* @__PURE__ */
|
|
11917
|
-
/* @__PURE__ */
|
|
11918
|
-
/* @__PURE__ */
|
|
12535
|
+
/* @__PURE__ */ React116.createElement(Tooltip, { title: "Delete", placement: "top" }, /* @__PURE__ */ React116.createElement("button", { className: "img-tool-btn", onClick: handleDelete }, "\u{1F5D1}")),
|
|
12536
|
+
/* @__PURE__ */ React116.createElement(Tooltip, { title: "Edit properties", placement: "top" }, /* @__PURE__ */ React116.createElement("button", { className: "img-tool-btn", onClick: () => setShowModal(true) }, "\u270E")),
|
|
12537
|
+
/* @__PURE__ */ React116.createElement("div", { className: "img-tool-copy-wrapper" }, /* @__PURE__ */ React116.createElement(Tooltip, { title: "Copy URL", placement: "top" }, /* @__PURE__ */ React116.createElement("button", { className: "img-tool-btn", onClick: handleCopy }, copyStatus ? "\u2713" : "\u{1F4CB}")), copyStatus && /* @__PURE__ */ React116.createElement("span", { className: "img-copy-toast" }, copyStatus)),
|
|
12538
|
+
/* @__PURE__ */ React116.createElement("div", { className: "img-tool-dropdown" }, /* @__PURE__ */ React116.createElement(Tooltip, { title: "Size presets", placement: "top" }, /* @__PURE__ */ React116.createElement("button", { className: "img-tool-btn", onClick: () => {
|
|
11919
12539
|
setShowSize(!showSize);
|
|
11920
12540
|
setShowAlign(false);
|
|
11921
|
-
} }, /* @__PURE__ */
|
|
12541
|
+
} }, /* @__PURE__ */ React116.createElement("span", { style: { fontSize: "11px" } }, node.attrs.width || 640, "x", node.attrs.height || 360), /* @__PURE__ */ React116.createElement("span", { className: "dropdown-arrow" }, "\u25BE"))), showSize && /* @__PURE__ */ React116.createElement("div", { className: "img-tool-menu" }, /* @__PURE__ */ React116.createElement("button", { className: "dropdown-item", onClick: () => {
|
|
11922
12542
|
handleResize("small");
|
|
11923
12543
|
setShowSize(false);
|
|
11924
|
-
} }, "Small (320x180)"), /* @__PURE__ */
|
|
12544
|
+
} }, "Small (320x180)"), /* @__PURE__ */ React116.createElement("button", { className: "dropdown-item", onClick: () => {
|
|
11925
12545
|
handleResize("medium");
|
|
11926
12546
|
setShowSize(false);
|
|
11927
|
-
} }, "Medium (480x270)"), /* @__PURE__ */
|
|
12547
|
+
} }, "Medium (480x270)"), /* @__PURE__ */ React116.createElement("button", { className: "dropdown-item", onClick: () => {
|
|
11928
12548
|
handleResize("large");
|
|
11929
12549
|
setShowSize(false);
|
|
11930
|
-
} }, "Large (640x360)"), /* @__PURE__ */
|
|
12550
|
+
} }, "Large (640x360)"), /* @__PURE__ */ React116.createElement("button", { className: "dropdown-item", onClick: () => {
|
|
11931
12551
|
handleResize("full");
|
|
11932
12552
|
setShowSize(false);
|
|
11933
12553
|
} }, "Full (854x480)"))),
|
|
11934
|
-
/* @__PURE__ */
|
|
12554
|
+
/* @__PURE__ */ React116.createElement("div", { className: "img-tool-dropdown" }, /* @__PURE__ */ React116.createElement(Tooltip, { title: "Horizontal alignment", placement: "top" }, /* @__PURE__ */ React116.createElement("button", { className: "img-tool-btn", onClick: () => {
|
|
11935
12555
|
setShowAlign(!showAlign);
|
|
11936
12556
|
setShowSize(false);
|
|
11937
|
-
} }, "\u2630 ", /* @__PURE__ */
|
|
11938
|
-
), showModal && /* @__PURE__ */
|
|
12557
|
+
} }, "\u2630 ", /* @__PURE__ */ React116.createElement("span", { className: "dropdown-arrow" }, "\u25BE"))), showAlign && /* @__PURE__ */ React116.createElement("div", { className: "img-tool-menu" }, ALIGNMENTS2.map((a) => /* @__PURE__ */ React116.createElement("button", { key: a.value, className: "dropdown-item", onClick: () => setAlignmentVal(a.value) }, a.icon, " ", a.label))))
|
|
12558
|
+
), showModal && /* @__PURE__ */ React116.createElement(
|
|
11939
12559
|
VideoPropertiesModal,
|
|
11940
12560
|
{
|
|
11941
12561
|
editor,
|
|
@@ -11950,22 +12570,22 @@ var VideoToolbar = ({ editor }) => {
|
|
|
11950
12570
|
var VideoToolbar_default = VideoToolbar;
|
|
11951
12571
|
|
|
11952
12572
|
// lib/RufousTextEditor/TableToolbar.tsx
|
|
11953
|
-
import
|
|
12573
|
+
import React117, { useState as useState34, useEffect as useEffect28, useRef as useRef31 } from "react";
|
|
11954
12574
|
import { createPortal as createPortal7 } from "react-dom";
|
|
11955
|
-
var IconAddRowBefore = () => /* @__PURE__ */
|
|
11956
|
-
var IconAddRowAfter = () => /* @__PURE__ */
|
|
11957
|
-
var IconAddColBefore = () => /* @__PURE__ */
|
|
11958
|
-
var IconAddColAfter = () => /* @__PURE__ */
|
|
11959
|
-
var IconDeleteRow = () => /* @__PURE__ */
|
|
11960
|
-
var IconDeleteCol = () => /* @__PURE__ */
|
|
11961
|
-
var IconDeleteTable = () => /* @__PURE__ */
|
|
11962
|
-
var IconMergeCells = () => /* @__PURE__ */
|
|
11963
|
-
var IconSplitCell = () => /* @__PURE__ */
|
|
11964
|
-
var IconToggleHeader = () => /* @__PURE__ */
|
|
12575
|
+
var IconAddRowBefore = () => /* @__PURE__ */ React117.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor" }, /* @__PURE__ */ React117.createElement("path", { d: "M20 3H4c-.55 0-1 .45-1 1v16c0 .55.45 1 1 1h16c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1zm-1 8H5V5h14v6zm0 8H5v-6h14v6z" }), /* @__PURE__ */ React117.createElement("path", { d: "M9 6h2v1.5h1.5v2H11V11H9V9.5H7.5v-2H9z" }));
|
|
12576
|
+
var IconAddRowAfter = () => /* @__PURE__ */ React117.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor" }, /* @__PURE__ */ React117.createElement("path", { d: "M20 3H4c-.55 0-1 .45-1 1v16c0 .55.45 1 1 1h16c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1zm-1 8H5V5h14v6zm0 8H5v-6h14v6z" }), /* @__PURE__ */ React117.createElement("path", { d: "M9 14h2v1.5h1.5v2H11V19H9v-1.5H7.5v-2H9z" }));
|
|
12577
|
+
var IconAddColBefore = () => /* @__PURE__ */ React117.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor" }, /* @__PURE__ */ React117.createElement("path", { d: "M20 3H4c-.55 0-1 .45-1 1v16c0 .55.45 1 1 1h16c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1zm-9 16H5V5h6v14zm8 0h-6V5h6v14z" }), /* @__PURE__ */ React117.createElement("path", { d: "M6 10h1.5v2H6v1.5H4v-2h1.5V10H4V8h2z", transform: "translate(2,1)" }));
|
|
12578
|
+
var IconAddColAfter = () => /* @__PURE__ */ React117.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor" }, /* @__PURE__ */ React117.createElement("path", { d: "M20 3H4c-.55 0-1 .45-1 1v16c0 .55.45 1 1 1h16c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1zm-9 16H5V5h6v14zm8 0h-6V5h6v14z" }), /* @__PURE__ */ React117.createElement("path", { d: "M15 9h2v1.5h1.5v2H17V14h-2v-1.5h-1.5v-2H15z" }));
|
|
12579
|
+
var IconDeleteRow = () => /* @__PURE__ */ React117.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor" }, /* @__PURE__ */ React117.createElement("path", { d: "M20 3H4c-.55 0-1 .45-1 1v16c0 .55.45 1 1 1h16c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1zm-1 8H5V5h14v6zm0 8H5v-6h14v6z" }), /* @__PURE__ */ React117.createElement("path", { d: "M8 14.5h8v2H8z" }));
|
|
12580
|
+
var IconDeleteCol = () => /* @__PURE__ */ React117.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor" }, /* @__PURE__ */ React117.createElement("path", { d: "M20 3H4c-.55 0-1 .45-1 1v16c0 .55.45 1 1 1h16c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1zm-9 16H5V5h6v14zm8 0h-6V5h6v14z" }), /* @__PURE__ */ React117.createElement("path", { d: "M14 9.5v6h2v-6z" }));
|
|
12581
|
+
var IconDeleteTable = () => /* @__PURE__ */ React117.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor" }, /* @__PURE__ */ React117.createElement("path", { d: "M20 3H4c-.55 0-1 .45-1 1v16c0 .55.45 1 1 1h16c.55 0 1-.45 1-1V4c0-.55-.45-1-1-1zm-1 16H5V5h14v14z" }), /* @__PURE__ */ React117.createElement("path", { d: "M9.17 10l-1.41 1.41L10.59 14l-2.83 2.83 1.41 1.41L12 15.41l2.83 2.83 1.41-1.41L13.41 14l2.83-2.83-1.41-1.41L12 12.59z" }));
|
|
12582
|
+
var IconMergeCells = () => /* @__PURE__ */ React117.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor" }, /* @__PURE__ */ React117.createElement("path", { d: "M3 3h18v18H3V3zm2 2v5h6V5H5zm8 0v5h6V5h-6zM5 13v6h14v-6H5z" }), /* @__PURE__ */ React117.createElement("path", { d: "M8 15h8v2H8z" }));
|
|
12583
|
+
var IconSplitCell = () => /* @__PURE__ */ React117.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor" }, /* @__PURE__ */ React117.createElement("path", { d: "M3 3h18v18H3V3zm2 2v5h6V5H5zm8 0v5h6V5h-6zM5 13v6h6v-6H5zm8 0v6h6v-6h-6z" }));
|
|
12584
|
+
var IconToggleHeader = () => /* @__PURE__ */ React117.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor" }, /* @__PURE__ */ React117.createElement("path", { d: "M3 3h18v18H3V3zm2 2v4h14V5H5zm0 6v8h14v-8H5z" }), /* @__PURE__ */ React117.createElement("rect", { x: "5", y: "5", width: "14", height: "4", opacity: "0.4" }));
|
|
11965
12585
|
var TableToolbar = ({ editor }) => {
|
|
11966
|
-
const [pos, setPos] =
|
|
11967
|
-
const toolbarRef =
|
|
11968
|
-
|
|
12586
|
+
const [pos, setPos] = useState34(null);
|
|
12587
|
+
const toolbarRef = useRef31(null);
|
|
12588
|
+
useEffect28(() => {
|
|
11969
12589
|
if (!editor) return;
|
|
11970
12590
|
const update = () => {
|
|
11971
12591
|
if (!editor.isActive("table")) {
|
|
@@ -12009,7 +12629,7 @@ var TableToolbar = ({ editor }) => {
|
|
|
12009
12629
|
const canSplit = editor.can().splitCell();
|
|
12010
12630
|
const prevent = (e) => e.preventDefault();
|
|
12011
12631
|
return createPortal7(
|
|
12012
|
-
/* @__PURE__ */
|
|
12632
|
+
/* @__PURE__ */ React117.createElement(
|
|
12013
12633
|
"div",
|
|
12014
12634
|
{
|
|
12015
12635
|
ref: toolbarRef,
|
|
@@ -12017,19 +12637,19 @@ var TableToolbar = ({ editor }) => {
|
|
|
12017
12637
|
style: { top: pos.top, left: pos.left },
|
|
12018
12638
|
onMouseDown: prevent
|
|
12019
12639
|
},
|
|
12020
|
-
/* @__PURE__ */
|
|
12021
|
-
/* @__PURE__ */
|
|
12022
|
-
/* @__PURE__ */
|
|
12023
|
-
/* @__PURE__ */
|
|
12024
|
-
/* @__PURE__ */
|
|
12025
|
-
/* @__PURE__ */
|
|
12026
|
-
/* @__PURE__ */
|
|
12027
|
-
/* @__PURE__ */
|
|
12028
|
-
/* @__PURE__ */
|
|
12029
|
-
/* @__PURE__ */
|
|
12030
|
-
/* @__PURE__ */
|
|
12031
|
-
/* @__PURE__ */
|
|
12032
|
-
/* @__PURE__ */
|
|
12640
|
+
/* @__PURE__ */ React117.createElement(Tooltip, { title: "Insert row above", placement: "top" }, /* @__PURE__ */ React117.createElement("button", { className: "rf-table-toolbar-btn", onClick: () => editor.chain().focus().addRowBefore().run() }, /* @__PURE__ */ React117.createElement(IconAddRowBefore, null))),
|
|
12641
|
+
/* @__PURE__ */ React117.createElement(Tooltip, { title: "Insert row below", placement: "top" }, /* @__PURE__ */ React117.createElement("button", { className: "rf-table-toolbar-btn", onClick: () => editor.chain().focus().addRowAfter().run() }, /* @__PURE__ */ React117.createElement(IconAddRowAfter, null))),
|
|
12642
|
+
/* @__PURE__ */ React117.createElement(Tooltip, { title: "Delete row", placement: "top" }, /* @__PURE__ */ React117.createElement("button", { className: "rf-table-toolbar-btn rf-table-toolbar-btn-danger", onClick: () => editor.chain().focus().deleteRow().run() }, /* @__PURE__ */ React117.createElement(IconDeleteRow, null))),
|
|
12643
|
+
/* @__PURE__ */ React117.createElement("span", { className: "rf-table-toolbar-sep" }),
|
|
12644
|
+
/* @__PURE__ */ React117.createElement(Tooltip, { title: "Insert column left", placement: "top" }, /* @__PURE__ */ React117.createElement("button", { className: "rf-table-toolbar-btn", onClick: () => editor.chain().focus().addColumnBefore().run() }, /* @__PURE__ */ React117.createElement(IconAddColBefore, null))),
|
|
12645
|
+
/* @__PURE__ */ React117.createElement(Tooltip, { title: "Insert column right", placement: "top" }, /* @__PURE__ */ React117.createElement("button", { className: "rf-table-toolbar-btn", onClick: () => editor.chain().focus().addColumnAfter().run() }, /* @__PURE__ */ React117.createElement(IconAddColAfter, null))),
|
|
12646
|
+
/* @__PURE__ */ React117.createElement(Tooltip, { title: "Delete column", placement: "top" }, /* @__PURE__ */ React117.createElement("button", { className: "rf-table-toolbar-btn rf-table-toolbar-btn-danger", onClick: () => editor.chain().focus().deleteColumn().run() }, /* @__PURE__ */ React117.createElement(IconDeleteCol, null))),
|
|
12647
|
+
/* @__PURE__ */ React117.createElement("span", { className: "rf-table-toolbar-sep" }),
|
|
12648
|
+
/* @__PURE__ */ React117.createElement(Tooltip, { title: "Merge cells", placement: "top" }, /* @__PURE__ */ React117.createElement("button", { className: "rf-table-toolbar-btn", onClick: () => editor.chain().focus().mergeCells().run(), disabled: !canMerge }, /* @__PURE__ */ React117.createElement(IconMergeCells, null))),
|
|
12649
|
+
/* @__PURE__ */ React117.createElement(Tooltip, { title: "Split cell", placement: "top" }, /* @__PURE__ */ React117.createElement("button", { className: "rf-table-toolbar-btn", onClick: () => editor.chain().focus().splitCell().run(), disabled: !canSplit }, /* @__PURE__ */ React117.createElement(IconSplitCell, null))),
|
|
12650
|
+
/* @__PURE__ */ React117.createElement("span", { className: "rf-table-toolbar-sep" }),
|
|
12651
|
+
/* @__PURE__ */ React117.createElement(Tooltip, { title: "Toggle header row", placement: "top" }, /* @__PURE__ */ React117.createElement("button", { className: `rf-table-toolbar-btn ${editor.isActive("tableHeader") ? "active" : ""}`, onClick: () => editor.chain().focus().toggleHeaderRow().run() }, /* @__PURE__ */ React117.createElement(IconToggleHeader, null))),
|
|
12652
|
+
/* @__PURE__ */ React117.createElement(Tooltip, { title: "Delete table", placement: "top" }, /* @__PURE__ */ React117.createElement("button", { className: "rf-table-toolbar-btn rf-table-toolbar-btn-danger", onClick: () => editor.chain().focus().deleteTable().run() }, /* @__PURE__ */ React117.createElement(IconDeleteTable, null)))
|
|
12033
12653
|
),
|
|
12034
12654
|
document.body
|
|
12035
12655
|
);
|
|
@@ -12204,12 +12824,12 @@ var RufousTextEditor = ({
|
|
|
12204
12824
|
return visible;
|
|
12205
12825
|
}, [buttons, variant, hideButtons]);
|
|
12206
12826
|
const mentionSuggestion = useMemo4(() => createMentionSuggestion(mentions), [mentions]);
|
|
12207
|
-
const onChangeRef =
|
|
12208
|
-
const onBlurRef =
|
|
12209
|
-
|
|
12827
|
+
const onChangeRef = useRef32(onChange);
|
|
12828
|
+
const onBlurRef = useRef32(onBlur);
|
|
12829
|
+
useEffect29(() => {
|
|
12210
12830
|
onChangeRef.current = onChange;
|
|
12211
12831
|
}, [onChange]);
|
|
12212
|
-
|
|
12832
|
+
useEffect29(() => {
|
|
12213
12833
|
onBlurRef.current = onBlur;
|
|
12214
12834
|
}, [onBlur]);
|
|
12215
12835
|
const isEditable = editable && !disabled;
|
|
@@ -12310,8 +12930,8 @@ var RufousTextEditor = ({
|
|
|
12310
12930
|
onChangeRef.current?.(e.getHTML(), e.getJSON());
|
|
12311
12931
|
}
|
|
12312
12932
|
});
|
|
12313
|
-
const wrapperRef =
|
|
12314
|
-
|
|
12933
|
+
const wrapperRef = useRef32(null);
|
|
12934
|
+
useEffect29(() => {
|
|
12315
12935
|
if (!editor) return;
|
|
12316
12936
|
let blurTimer = null;
|
|
12317
12937
|
const handler = ({ event }) => {
|
|
@@ -12329,15 +12949,15 @@ var RufousTextEditor = ({
|
|
|
12329
12949
|
if (blurTimer) clearTimeout(blurTimer);
|
|
12330
12950
|
};
|
|
12331
12951
|
}, [editor]);
|
|
12332
|
-
const setLinkRef =
|
|
12333
|
-
const [linkModalOpen, setLinkModalOpen] =
|
|
12334
|
-
const [linkUrl, setLinkUrl] =
|
|
12335
|
-
const [linkText, setLinkText] =
|
|
12336
|
-
const [linkClassName, setLinkClassName] =
|
|
12337
|
-
const [linkNewTab, setLinkNewTab] =
|
|
12338
|
-
const [linkNoFollow, setLinkNoFollow] =
|
|
12339
|
-
const [linkSelection, setLinkSelection] =
|
|
12340
|
-
const setLink =
|
|
12952
|
+
const setLinkRef = useRef32(null);
|
|
12953
|
+
const [linkModalOpen, setLinkModalOpen] = useState35(false);
|
|
12954
|
+
const [linkUrl, setLinkUrl] = useState35("");
|
|
12955
|
+
const [linkText, setLinkText] = useState35("");
|
|
12956
|
+
const [linkClassName, setLinkClassName] = useState35("");
|
|
12957
|
+
const [linkNewTab, setLinkNewTab] = useState35(true);
|
|
12958
|
+
const [linkNoFollow, setLinkNoFollow] = useState35(true);
|
|
12959
|
+
const [linkSelection, setLinkSelection] = useState35(null);
|
|
12960
|
+
const setLink = useCallback15(() => {
|
|
12341
12961
|
if (!editor) return;
|
|
12342
12962
|
const attrs = editor.getAttributes("link");
|
|
12343
12963
|
const previousUrl = attrs.href || "";
|
|
@@ -12374,10 +12994,10 @@ var RufousTextEditor = ({
|
|
|
12374
12994
|
setLinkSelection({ from, to });
|
|
12375
12995
|
setLinkModalOpen(true);
|
|
12376
12996
|
}, [editor]);
|
|
12377
|
-
|
|
12997
|
+
useEffect29(() => {
|
|
12378
12998
|
setLinkRef.current = setLink;
|
|
12379
12999
|
}, [setLink]);
|
|
12380
|
-
|
|
13000
|
+
useEffect29(() => {
|
|
12381
13001
|
if (!editor?.view) return;
|
|
12382
13002
|
const handleKeyDown = (event) => {
|
|
12383
13003
|
if ((event.ctrlKey || event.metaKey) && event.key === "k") {
|
|
@@ -12409,7 +13029,7 @@ var RufousTextEditor = ({
|
|
|
12409
13029
|
editor.view.dom.removeEventListener("keydown", handleKeyDown);
|
|
12410
13030
|
};
|
|
12411
13031
|
}, [editor]);
|
|
12412
|
-
const handleLinkSubmit =
|
|
13032
|
+
const handleLinkSubmit = useCallback15(() => {
|
|
12413
13033
|
if (!editor || !linkSelection) return;
|
|
12414
13034
|
editor.chain().focus().setTextSelection(linkSelection).run();
|
|
12415
13035
|
if (linkUrl === "") {
|
|
@@ -12445,7 +13065,7 @@ var RufousTextEditor = ({
|
|
|
12445
13065
|
setLinkClassName("");
|
|
12446
13066
|
setLinkSelection(null);
|
|
12447
13067
|
}, [editor, linkUrl, linkText, linkClassName, linkNewTab, linkNoFollow, linkSelection]);
|
|
12448
|
-
const handleLinkRemove =
|
|
13068
|
+
const handleLinkRemove = useCallback15(() => {
|
|
12449
13069
|
if (!editor || !linkSelection) return;
|
|
12450
13070
|
editor.chain().focus().setTextSelection(linkSelection).extendMarkRange("link").unsetLink().run();
|
|
12451
13071
|
setLinkModalOpen(false);
|
|
@@ -12454,7 +13074,7 @@ var RufousTextEditor = ({
|
|
|
12454
13074
|
setLinkClassName("");
|
|
12455
13075
|
setLinkSelection(null);
|
|
12456
13076
|
}, [editor, linkSelection]);
|
|
12457
|
-
const handleLinkCancel =
|
|
13077
|
+
const handleLinkCancel = useCallback15(() => {
|
|
12458
13078
|
setLinkModalOpen(false);
|
|
12459
13079
|
setLinkUrl("");
|
|
12460
13080
|
setLinkText("");
|
|
@@ -12462,21 +13082,21 @@ var RufousTextEditor = ({
|
|
|
12462
13082
|
setLinkSelection(null);
|
|
12463
13083
|
editor?.chain().focus().run();
|
|
12464
13084
|
}, [editor]);
|
|
12465
|
-
const [saveStatus, setSaveStatus] =
|
|
12466
|
-
const handleSave =
|
|
13085
|
+
const [saveStatus, setSaveStatus] = useState35("");
|
|
13086
|
+
const handleSave = useCallback15(() => {
|
|
12467
13087
|
if (!editor || !onSaveProp) return;
|
|
12468
13088
|
onSaveProp(editor.getHTML(), editor.getJSON());
|
|
12469
13089
|
setSaveStatus("Saved!");
|
|
12470
13090
|
setTimeout(() => setSaveStatus(""), 2e3);
|
|
12471
13091
|
}, [editor, onSaveProp]);
|
|
12472
|
-
const handleExport =
|
|
13092
|
+
const handleExport = useCallback15(() => {
|
|
12473
13093
|
if (!editor || !onExportProp) return;
|
|
12474
13094
|
onExportProp(editor.getHTML(), editor.getJSON());
|
|
12475
13095
|
}, [editor, onExportProp]);
|
|
12476
13096
|
const providerValue = useMemo4(() => ({ editor }), [editor]);
|
|
12477
|
-
const [isFullscreen, setIsFullscreen] =
|
|
12478
|
-
const toggleFullscreen =
|
|
12479
|
-
const wrapperJsx = /* @__PURE__ */
|
|
13097
|
+
const [isFullscreen, setIsFullscreen] = useState35(false);
|
|
13098
|
+
const toggleFullscreen = useCallback15(() => setIsFullscreen((prev) => !prev), []);
|
|
13099
|
+
const wrapperJsx = /* @__PURE__ */ React118.createElement(
|
|
12480
13100
|
"div",
|
|
12481
13101
|
{
|
|
12482
13102
|
ref: wrapperRef,
|
|
@@ -12487,7 +13107,7 @@ var RufousTextEditor = ({
|
|
|
12487
13107
|
...height ? { height: typeof height === "number" ? `${height}px` : height } : {}
|
|
12488
13108
|
}
|
|
12489
13109
|
},
|
|
12490
|
-
/* @__PURE__ */
|
|
13110
|
+
/* @__PURE__ */ React118.createElement(EditorContext.Provider, { value: providerValue }, /* @__PURE__ */ React118.createElement(
|
|
12491
13111
|
Toolbar_default,
|
|
12492
13112
|
{
|
|
12493
13113
|
editor,
|
|
@@ -12502,7 +13122,7 @@ var RufousTextEditor = ({
|
|
|
12502
13122
|
isFullscreen,
|
|
12503
13123
|
onToggleFullscreen: toggleFullscreen
|
|
12504
13124
|
}
|
|
12505
|
-
), /* @__PURE__ */
|
|
13125
|
+
), /* @__PURE__ */ React118.createElement(EditorContent, { editor, className: "editor-content-wrapper" }), /* @__PURE__ */ React118.createElement(ImageToolbar_default, { editor }), /* @__PURE__ */ React118.createElement(VideoToolbar_default, { editor }), /* @__PURE__ */ React118.createElement(TableToolbar_default, { editor }), editor && /* @__PURE__ */ React118.createElement(
|
|
12506
13126
|
BubbleMenu,
|
|
12507
13127
|
{
|
|
12508
13128
|
editor,
|
|
@@ -12520,31 +13140,31 @@ var RufousTextEditor = ({
|
|
|
12520
13140
|
}
|
|
12521
13141
|
}
|
|
12522
13142
|
},
|
|
12523
|
-
/* @__PURE__ */
|
|
13143
|
+
/* @__PURE__ */ React118.createElement(
|
|
12524
13144
|
"button",
|
|
12525
13145
|
{
|
|
12526
13146
|
onClick: () => editor?.chain().focus().toggleBold().run(),
|
|
12527
13147
|
className: editor?.isActive("bold") ? "is-active" : ""
|
|
12528
13148
|
},
|
|
12529
|
-
/* @__PURE__ */
|
|
13149
|
+
/* @__PURE__ */ React118.createElement("strong", null, "B")
|
|
12530
13150
|
),
|
|
12531
|
-
/* @__PURE__ */
|
|
13151
|
+
/* @__PURE__ */ React118.createElement(
|
|
12532
13152
|
"button",
|
|
12533
13153
|
{
|
|
12534
13154
|
onClick: () => editor?.chain().focus().toggleItalic().run(),
|
|
12535
13155
|
className: editor?.isActive("italic") ? "is-active" : ""
|
|
12536
13156
|
},
|
|
12537
|
-
/* @__PURE__ */
|
|
13157
|
+
/* @__PURE__ */ React118.createElement("em", null, "I")
|
|
12538
13158
|
),
|
|
12539
|
-
/* @__PURE__ */
|
|
13159
|
+
/* @__PURE__ */ React118.createElement(
|
|
12540
13160
|
"button",
|
|
12541
13161
|
{
|
|
12542
13162
|
onClick: () => editor?.chain().focus().toggleStrike().run(),
|
|
12543
13163
|
className: editor?.isActive("strike") ? "is-active" : ""
|
|
12544
13164
|
},
|
|
12545
|
-
/* @__PURE__ */
|
|
13165
|
+
/* @__PURE__ */ React118.createElement("s", null, "S")
|
|
12546
13166
|
),
|
|
12547
|
-
/* @__PURE__ */
|
|
13167
|
+
/* @__PURE__ */ React118.createElement(
|
|
12548
13168
|
"button",
|
|
12549
13169
|
{
|
|
12550
13170
|
onClick: () => editor?.chain().focus().toggleCode().run(),
|
|
@@ -12552,7 +13172,7 @@ var RufousTextEditor = ({
|
|
|
12552
13172
|
},
|
|
12553
13173
|
"</>"
|
|
12554
13174
|
),
|
|
12555
|
-
/* @__PURE__ */
|
|
13175
|
+
/* @__PURE__ */ React118.createElement(
|
|
12556
13176
|
"button",
|
|
12557
13177
|
{
|
|
12558
13178
|
onClick: setLink,
|
|
@@ -12560,7 +13180,7 @@ var RufousTextEditor = ({
|
|
|
12560
13180
|
},
|
|
12561
13181
|
"\u{1F517}"
|
|
12562
13182
|
)
|
|
12563
|
-
), editor && /* @__PURE__ */
|
|
13183
|
+
), editor && /* @__PURE__ */ React118.createElement(
|
|
12564
13184
|
FloatingMenu,
|
|
12565
13185
|
{
|
|
12566
13186
|
editor,
|
|
@@ -12575,7 +13195,7 @@ var RufousTextEditor = ({
|
|
|
12575
13195
|
}
|
|
12576
13196
|
}
|
|
12577
13197
|
},
|
|
12578
|
-
/* @__PURE__ */
|
|
13198
|
+
/* @__PURE__ */ React118.createElement(
|
|
12579
13199
|
"button",
|
|
12580
13200
|
{
|
|
12581
13201
|
onClick: () => editor?.chain().focus().toggleHeading({ level: 1 }).run(),
|
|
@@ -12583,7 +13203,7 @@ var RufousTextEditor = ({
|
|
|
12583
13203
|
},
|
|
12584
13204
|
"H1"
|
|
12585
13205
|
),
|
|
12586
|
-
/* @__PURE__ */
|
|
13206
|
+
/* @__PURE__ */ React118.createElement(
|
|
12587
13207
|
"button",
|
|
12588
13208
|
{
|
|
12589
13209
|
onClick: () => editor?.chain().focus().toggleHeading({ level: 2 }).run(),
|
|
@@ -12591,7 +13211,7 @@ var RufousTextEditor = ({
|
|
|
12591
13211
|
},
|
|
12592
13212
|
"H2"
|
|
12593
13213
|
),
|
|
12594
|
-
/* @__PURE__ */
|
|
13214
|
+
/* @__PURE__ */ React118.createElement(
|
|
12595
13215
|
"button",
|
|
12596
13216
|
{
|
|
12597
13217
|
onClick: () => editor?.chain().focus().toggleBulletList().run(),
|
|
@@ -12599,7 +13219,7 @@ var RufousTextEditor = ({
|
|
|
12599
13219
|
},
|
|
12600
13220
|
"\u2022 List"
|
|
12601
13221
|
),
|
|
12602
|
-
/* @__PURE__ */
|
|
13222
|
+
/* @__PURE__ */ React118.createElement(
|
|
12603
13223
|
"button",
|
|
12604
13224
|
{
|
|
12605
13225
|
onClick: () => editor?.chain().focus().toggleOrderedList().run(),
|
|
@@ -12607,7 +13227,7 @@ var RufousTextEditor = ({
|
|
|
12607
13227
|
},
|
|
12608
13228
|
"1. List"
|
|
12609
13229
|
),
|
|
12610
|
-
/* @__PURE__ */
|
|
13230
|
+
/* @__PURE__ */ React118.createElement(
|
|
12611
13231
|
"button",
|
|
12612
13232
|
{
|
|
12613
13233
|
onClick: () => editor?.chain().focus().toggleBlockquote().run(),
|
|
@@ -12615,8 +13235,8 @@ var RufousTextEditor = ({
|
|
|
12615
13235
|
},
|
|
12616
13236
|
"\u201C Quote"
|
|
12617
13237
|
)
|
|
12618
|
-
), /* @__PURE__ */
|
|
12619
|
-
/* @__PURE__ */
|
|
13238
|
+
), /* @__PURE__ */ React118.createElement("div", { className: "status-bar" }, /* @__PURE__ */ React118.createElement("div", { className: "status-bar-left" }, onSaveProp && /* @__PURE__ */ React118.createElement("button", { onClick: handleSave, className: "status-btn save-btn" }, "Save"), onExportProp && /* @__PURE__ */ React118.createElement("button", { onClick: handleExport, className: "status-btn export-btn" }, "Export")), /* @__PURE__ */ React118.createElement("div", { className: "status-bar-right" }, saveStatus && /* @__PURE__ */ React118.createElement("span", { className: "save-status" }, saveStatus), editor && /* @__PURE__ */ React118.createElement(React118.Fragment, null, /* @__PURE__ */ React118.createElement("span", { className: "word-count" }, "CHARS: ", editor.storage.characterCount?.characters?.() ?? editor.getText().length), /* @__PURE__ */ React118.createElement("span", { className: "word-count" }, "WORDS: ", editor.storage.characterCount?.words?.() ?? editor.getText().split(/\s+/).filter(Boolean).length)))), linkModalOpen && createPortal8(
|
|
13239
|
+
/* @__PURE__ */ React118.createElement("div", { className: "link-modal-overlay", onClick: handleLinkCancel }, /* @__PURE__ */ React118.createElement("div", { className: "link-modal", onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ React118.createElement("div", { className: "link-modal-body" }, /* @__PURE__ */ React118.createElement("div", { className: "link-modal-field" }, /* @__PURE__ */ React118.createElement("label", { className: "link-modal-label" }, "URL"), /* @__PURE__ */ React118.createElement(
|
|
12620
13240
|
"input",
|
|
12621
13241
|
{
|
|
12622
13242
|
type: "url",
|
|
@@ -12629,7 +13249,7 @@ var RufousTextEditor = ({
|
|
|
12629
13249
|
placeholder: "https://example.com",
|
|
12630
13250
|
autoFocus: true
|
|
12631
13251
|
}
|
|
12632
|
-
)), /* @__PURE__ */
|
|
13252
|
+
)), /* @__PURE__ */ React118.createElement("div", { className: "link-modal-field" }, /* @__PURE__ */ React118.createElement("label", { className: "link-modal-label" }, "Text"), /* @__PURE__ */ React118.createElement(
|
|
12633
13253
|
"input",
|
|
12634
13254
|
{
|
|
12635
13255
|
type: "text",
|
|
@@ -12641,24 +13261,24 @@ var RufousTextEditor = ({
|
|
|
12641
13261
|
},
|
|
12642
13262
|
placeholder: "Link text"
|
|
12643
13263
|
}
|
|
12644
|
-
)), /* @__PURE__ */
|
|
13264
|
+
)), /* @__PURE__ */ React118.createElement("div", { className: "link-modal-checkboxes" }, /* @__PURE__ */ React118.createElement("label", { className: "link-modal-checkbox" }, /* @__PURE__ */ React118.createElement(
|
|
12645
13265
|
"input",
|
|
12646
13266
|
{
|
|
12647
13267
|
type: "checkbox",
|
|
12648
13268
|
checked: linkNewTab,
|
|
12649
13269
|
onChange: (e) => setLinkNewTab(e.target.checked)
|
|
12650
13270
|
}
|
|
12651
|
-
), "Open in new tab"), /* @__PURE__ */
|
|
13271
|
+
), "Open in new tab"), /* @__PURE__ */ React118.createElement("label", { className: "link-modal-checkbox" }, /* @__PURE__ */ React118.createElement(
|
|
12652
13272
|
"input",
|
|
12653
13273
|
{
|
|
12654
13274
|
type: "checkbox",
|
|
12655
13275
|
checked: linkNoFollow,
|
|
12656
13276
|
onChange: (e) => setLinkNoFollow(e.target.checked)
|
|
12657
13277
|
}
|
|
12658
|
-
), "No follow"))), /* @__PURE__ */
|
|
13278
|
+
), "No follow"))), /* @__PURE__ */ React118.createElement("div", { className: "link-modal-footer" }, /* @__PURE__ */ React118.createElement("button", { className: "link-modal-btn-unlink", onClick: handleLinkRemove }, "Unlink"), /* @__PURE__ */ React118.createElement("button", { className: "link-modal-btn-apply", onClick: handleLinkSubmit }, "Update")))),
|
|
12659
13279
|
document.body
|
|
12660
13280
|
)),
|
|
12661
|
-
helperText && /* @__PURE__ */
|
|
13281
|
+
helperText && /* @__PURE__ */ React118.createElement("div", { className: `rf-rte-helper-text ${error ? "rf-rte-helper-error" : ""}` }, helperText)
|
|
12662
13282
|
);
|
|
12663
13283
|
return isFullscreen ? createPortal8(wrapperJsx, document.body) : wrapperJsx;
|
|
12664
13284
|
};
|
|
@@ -12669,7 +13289,7 @@ var RufousTextContent = ({ content, className, style, sx }) => {
|
|
|
12669
13289
|
transformedContent = transformLegacyTodos(transformedContent);
|
|
12670
13290
|
} catch {
|
|
12671
13291
|
}
|
|
12672
|
-
return /* @__PURE__ */
|
|
13292
|
+
return /* @__PURE__ */ React118.createElement(
|
|
12673
13293
|
"div",
|
|
12674
13294
|
{
|
|
12675
13295
|
className: `rf-rte-content ${sxClass} ${className || ""}`,
|
|
@@ -12807,11 +13427,13 @@ export {
|
|
|
12807
13427
|
ToggleButtonGroup,
|
|
12808
13428
|
Tooltip,
|
|
12809
13429
|
trashIcon_default as TrashIcon,
|
|
13430
|
+
TreeSelect,
|
|
12810
13431
|
Typography,
|
|
12811
13432
|
unArchivedIcon_default as UnArchivedIcon,
|
|
12812
13433
|
unsubscribeIcon_default as UnsubscribeIcon,
|
|
12813
13434
|
uploadIcon_default as UploadIcon,
|
|
12814
13435
|
userAssignIcon_default as UserAssignIcon,
|
|
13436
|
+
UserSelectionField,
|
|
12815
13437
|
viewIcon_default as ViewIcon,
|
|
12816
13438
|
workItemIcon_default as WorkItemIcon,
|
|
12817
13439
|
Zoom,
|