@rufous/ui 0.3.12 → 0.3.14
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 +997 -477
- package/dist/main.css +356 -22
- package/dist/main.d.cts +63 -1
- package/dist/main.d.ts +63 -1
- package/dist/main.js +1074 -550
- 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) {
|
|
@@ -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,406 @@ 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
|
+
|
|
8810
9333
|
// lib/RufousTextEditor/RufousTextEditor.tsx
|
|
8811
|
-
import
|
|
9334
|
+
import React117, { useMemo as useMemo4, useCallback as useCallback15, useState as useState35, useRef as useRef32, useEffect as useEffect29 } from "react";
|
|
8812
9335
|
import { createPortal as createPortal8 } from "react-dom";
|
|
8813
9336
|
import { useEditor, EditorContent, EditorContext, FloatingMenu, BubbleMenu } from "@tiptap/react";
|
|
8814
9337
|
import StarterKit from "@tiptap/starter-kit";
|
|
@@ -8834,16 +9357,16 @@ import { ReactRenderer } from "@tiptap/react";
|
|
|
8834
9357
|
import tippy from "tippy.js";
|
|
8835
9358
|
|
|
8836
9359
|
// lib/RufousTextEditor/MentionList.tsx
|
|
8837
|
-
import
|
|
9360
|
+
import React107, { forwardRef as forwardRef11, useEffect as useEffect21, useImperativeHandle, useState as useState26 } from "react";
|
|
8838
9361
|
var MentionList = forwardRef11((props, ref) => {
|
|
8839
|
-
const [selectedIndex, setSelectedIndex] =
|
|
9362
|
+
const [selectedIndex, setSelectedIndex] = useState26(0);
|
|
8840
9363
|
const selectItem = (index) => {
|
|
8841
9364
|
const item = props.items[index];
|
|
8842
9365
|
if (item) {
|
|
8843
9366
|
props.command({ id: item.id, label: item.shortName || item.name });
|
|
8844
9367
|
}
|
|
8845
9368
|
};
|
|
8846
|
-
|
|
9369
|
+
useEffect21(() => setSelectedIndex(0), [props.items]);
|
|
8847
9370
|
useImperativeHandle(ref, () => ({
|
|
8848
9371
|
onKeyDown: ({ event }) => {
|
|
8849
9372
|
if (event.key === "ArrowUp") {
|
|
@@ -8862,17 +9385,17 @@ var MentionList = forwardRef11((props, ref) => {
|
|
|
8862
9385
|
}
|
|
8863
9386
|
}));
|
|
8864
9387
|
if (!props.items.length) {
|
|
8865
|
-
return /* @__PURE__ */
|
|
9388
|
+
return /* @__PURE__ */ React107.createElement("div", { className: "rf-rte-mention-dropdown" }, /* @__PURE__ */ React107.createElement("div", { className: "rf-rte-mention-item rf-rte-mention-no-result" }, "No results"));
|
|
8866
9389
|
}
|
|
8867
|
-
return /* @__PURE__ */
|
|
9390
|
+
return /* @__PURE__ */ React107.createElement("div", { className: "rf-rte-mention-dropdown" }, props.items.map((item, index) => /* @__PURE__ */ React107.createElement(
|
|
8868
9391
|
"button",
|
|
8869
9392
|
{
|
|
8870
9393
|
className: `rf-rte-mention-item ${index === selectedIndex ? "is-selected" : ""}`,
|
|
8871
9394
|
key: item.id,
|
|
8872
9395
|
onClick: () => selectItem(index)
|
|
8873
9396
|
},
|
|
8874
|
-
/* @__PURE__ */
|
|
8875
|
-
/* @__PURE__ */
|
|
9397
|
+
/* @__PURE__ */ React107.createElement("span", { className: "rf-rte-mention-avatar" }, item.avatar || item.name.charAt(0).toUpperCase()),
|
|
9398
|
+
/* @__PURE__ */ React107.createElement("span", { className: "rf-rte-mention-name" }, item.name)
|
|
8876
9399
|
)));
|
|
8877
9400
|
});
|
|
8878
9401
|
MentionList.displayName = "MentionList";
|
|
@@ -8930,21 +9453,21 @@ function createMentionSuggestion(users) {
|
|
|
8930
9453
|
}
|
|
8931
9454
|
|
|
8932
9455
|
// lib/RufousTextEditor/Toolbar.tsx
|
|
8933
|
-
import
|
|
9456
|
+
import React113, { useState as useState31, useRef as useRef28, useEffect as useEffect25, useCallback as useCallback14 } from "react";
|
|
8934
9457
|
import { createPortal as createPortal4 } from "react-dom";
|
|
8935
9458
|
|
|
8936
9459
|
// lib/RufousTextEditor/TextToSpeech.tsx
|
|
8937
|
-
import
|
|
9460
|
+
import React108, { useState as useState27, useEffect as useEffect22, useRef as useRef25, useCallback as useCallback11, forwardRef as forwardRef12, useImperativeHandle as useImperativeHandle2 } from "react";
|
|
8938
9461
|
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
|
-
|
|
9462
|
+
const [speaking, setSpeaking] = useState27(false);
|
|
9463
|
+
const [paused, setPaused] = useState27(false);
|
|
9464
|
+
const [voices, setVoices] = useState27([]);
|
|
9465
|
+
const [selectedVoice, setSelectedVoice] = useState27("");
|
|
9466
|
+
const [rate, setRate] = useState27(1);
|
|
9467
|
+
const [showPanel, setShowPanel] = useState27(false);
|
|
9468
|
+
const utteranceRef = useRef25(null);
|
|
9469
|
+
const panelRef = useRef25(null);
|
|
9470
|
+
useEffect22(() => {
|
|
8948
9471
|
const synth = window.speechSynthesis;
|
|
8949
9472
|
const loadVoices = () => {
|
|
8950
9473
|
const available = synth.getVoices();
|
|
@@ -8962,7 +9485,7 @@ var TextToSpeech = forwardRef12(({ editor, onTextToSpeech }, ref) => {
|
|
|
8962
9485
|
synth.removeEventListener("voiceschanged", loadVoices);
|
|
8963
9486
|
};
|
|
8964
9487
|
}, [selectedVoice]);
|
|
8965
|
-
|
|
9488
|
+
useEffect22(() => {
|
|
8966
9489
|
const handleClick = (e) => {
|
|
8967
9490
|
if (panelRef.current && !panelRef.current.contains(e.target)) {
|
|
8968
9491
|
setShowPanel(false);
|
|
@@ -8971,7 +9494,7 @@ var TextToSpeech = forwardRef12(({ editor, onTextToSpeech }, ref) => {
|
|
|
8971
9494
|
document.addEventListener("mousedown", handleClick);
|
|
8972
9495
|
return () => document.removeEventListener("mousedown", handleClick);
|
|
8973
9496
|
}, []);
|
|
8974
|
-
const getTextToSpeak =
|
|
9497
|
+
const getTextToSpeak = useCallback11(() => {
|
|
8975
9498
|
if (!editor) return "";
|
|
8976
9499
|
const { from, to, empty } = editor.state.selection;
|
|
8977
9500
|
if (!empty) {
|
|
@@ -8979,7 +9502,7 @@ var TextToSpeech = forwardRef12(({ editor, onTextToSpeech }, ref) => {
|
|
|
8979
9502
|
}
|
|
8980
9503
|
return editor.getText();
|
|
8981
9504
|
}, [editor]);
|
|
8982
|
-
const handleSpeak =
|
|
9505
|
+
const handleSpeak = useCallback11(async () => {
|
|
8983
9506
|
const text = getTextToSpeak();
|
|
8984
9507
|
if (!text.trim()) return;
|
|
8985
9508
|
if (onTextToSpeech) {
|
|
@@ -9021,25 +9544,25 @@ var TextToSpeech = forwardRef12(({ editor, onTextToSpeech }, ref) => {
|
|
|
9021
9544
|
setSpeaking(true);
|
|
9022
9545
|
setPaused(false);
|
|
9023
9546
|
}, [getTextToSpeak, voices, selectedVoice, rate, onTextToSpeech]);
|
|
9024
|
-
const handlePause =
|
|
9547
|
+
const handlePause = useCallback11(() => {
|
|
9025
9548
|
if (window.speechSynthesis.speaking && !window.speechSynthesis.paused) {
|
|
9026
9549
|
window.speechSynthesis.pause();
|
|
9027
9550
|
setPaused(true);
|
|
9028
9551
|
}
|
|
9029
9552
|
}, []);
|
|
9030
|
-
const handleResume =
|
|
9553
|
+
const handleResume = useCallback11(() => {
|
|
9031
9554
|
if (window.speechSynthesis.paused) {
|
|
9032
9555
|
window.speechSynthesis.resume();
|
|
9033
9556
|
setPaused(false);
|
|
9034
9557
|
}
|
|
9035
9558
|
}, []);
|
|
9036
|
-
const handleStop =
|
|
9559
|
+
const handleStop = useCallback11(() => {
|
|
9037
9560
|
window.speechSynthesis.cancel();
|
|
9038
9561
|
setSpeaking(false);
|
|
9039
9562
|
setPaused(false);
|
|
9040
9563
|
}, []);
|
|
9041
9564
|
useImperativeHandle2(ref, () => ({ stop: handleStop }), [handleStop]);
|
|
9042
|
-
return /* @__PURE__ */
|
|
9565
|
+
return /* @__PURE__ */ React108.createElement("div", { className: "tts-wrapper", ref: panelRef }, /* @__PURE__ */ React108.createElement(Tooltip, { title: "Text to Speech", placement: "top" }, /* @__PURE__ */ React108.createElement(
|
|
9043
9566
|
"button",
|
|
9044
9567
|
{
|
|
9045
9568
|
className: `toolbar-btn ${speaking ? "is-active" : ""}`,
|
|
@@ -9052,15 +9575,15 @@ var TextToSpeech = forwardRef12(({ editor, onTextToSpeech }, ref) => {
|
|
|
9052
9575
|
}
|
|
9053
9576
|
},
|
|
9054
9577
|
speaking ? "\u23F9" : "\u{1F50A}"
|
|
9055
|
-
)), showPanel && !speaking && /* @__PURE__ */
|
|
9578
|
+
)), showPanel && !speaking && /* @__PURE__ */ React108.createElement("div", { className: "tts-panel" }, /* @__PURE__ */ React108.createElement("div", { className: "tts-panel-header" }, "Text to Speech"), /* @__PURE__ */ React108.createElement("label", { className: "tts-label" }, "Voice"), /* @__PURE__ */ React108.createElement(
|
|
9056
9579
|
"select",
|
|
9057
9580
|
{
|
|
9058
9581
|
className: "tts-select",
|
|
9059
9582
|
value: selectedVoice,
|
|
9060
9583
|
onChange: (e) => setSelectedVoice(e.target.value)
|
|
9061
9584
|
},
|
|
9062
|
-
voices.map((v) => /* @__PURE__ */
|
|
9063
|
-
), /* @__PURE__ */
|
|
9585
|
+
voices.map((v) => /* @__PURE__ */ React108.createElement("option", { key: v.name, value: v.name }, v.name, " (", v.lang, ")"))
|
|
9586
|
+
), /* @__PURE__ */ React108.createElement("label", { className: "tts-label" }, "Speed: ", rate, "x"), /* @__PURE__ */ React108.createElement(
|
|
9064
9587
|
"input",
|
|
9065
9588
|
{
|
|
9066
9589
|
type: "range",
|
|
@@ -9071,26 +9594,26 @@ var TextToSpeech = forwardRef12(({ editor, onTextToSpeech }, ref) => {
|
|
|
9071
9594
|
value: rate,
|
|
9072
9595
|
onChange: (e) => setRate(Number(e.target.value))
|
|
9073
9596
|
}
|
|
9074
|
-
), /* @__PURE__ */
|
|
9597
|
+
), /* @__PURE__ */ React108.createElement("div", { className: "tts-info" }, editor && !editor.state.selection.empty ? "Will read selected text" : "Will read all editor text"), /* @__PURE__ */ React108.createElement("button", { className: "tts-speak-btn", onClick: () => {
|
|
9075
9598
|
handleSpeak();
|
|
9076
9599
|
setShowPanel(false);
|
|
9077
|
-
} }, "\u25B6 Speak")), speaking && /* @__PURE__ */
|
|
9600
|
+
} }, "\u25B6 Speak")), speaking && /* @__PURE__ */ React108.createElement("div", { className: "tts-controls" }, paused ? /* @__PURE__ */ React108.createElement(Tooltip, { title: "Resume", placement: "top" }, /* @__PURE__ */ React108.createElement("button", { className: "toolbar-btn", onClick: handleResume }, "\u25B6")) : /* @__PURE__ */ React108.createElement(Tooltip, { title: "Pause", placement: "top" }, /* @__PURE__ */ React108.createElement("button", { className: "toolbar-btn", onClick: handlePause }, "\u275A\u275A")), /* @__PURE__ */ React108.createElement(Tooltip, { title: "Stop", placement: "top" }, /* @__PURE__ */ React108.createElement("button", { className: "toolbar-btn", onClick: handleStop }, "\u25A0"))));
|
|
9078
9601
|
});
|
|
9079
9602
|
var TextToSpeech_default = TextToSpeech;
|
|
9080
9603
|
|
|
9081
9604
|
// lib/RufousTextEditor/SpeechToText.tsx
|
|
9082
|
-
import
|
|
9605
|
+
import React109, { useState as useState28, useRef as useRef26, useCallback as useCallback12, useEffect as useEffect23, forwardRef as forwardRef13, useImperativeHandle as useImperativeHandle3 } from "react";
|
|
9083
9606
|
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 =
|
|
9607
|
+
const [listening, setListening] = useState28(false);
|
|
9608
|
+
const [showPanel, setShowPanel] = useState28(false);
|
|
9609
|
+
const [language, setLanguage] = useState28("en-US");
|
|
9610
|
+
const [interim, setInterim] = useState28("");
|
|
9611
|
+
const recognitionRef = useRef26(null);
|
|
9612
|
+
const panelRef = useRef26(null);
|
|
9613
|
+
const isListeningRef = useRef26(false);
|
|
9091
9614
|
const SpeechRecognitionAPI = typeof window !== "undefined" ? window.SpeechRecognition || window.webkitSpeechRecognition : null;
|
|
9092
9615
|
const supported = !!SpeechRecognitionAPI;
|
|
9093
|
-
|
|
9616
|
+
useEffect23(() => {
|
|
9094
9617
|
const handleClick = (e) => {
|
|
9095
9618
|
if (panelRef.current && !panelRef.current.contains(e.target)) {
|
|
9096
9619
|
setShowPanel(false);
|
|
@@ -9099,7 +9622,7 @@ var SpeechToText = forwardRef13(({ editor, onSpeechToText }, ref) => {
|
|
|
9099
9622
|
document.addEventListener("mousedown", handleClick);
|
|
9100
9623
|
return () => document.removeEventListener("mousedown", handleClick);
|
|
9101
9624
|
}, []);
|
|
9102
|
-
const createRecognition =
|
|
9625
|
+
const createRecognition = useCallback12(() => {
|
|
9103
9626
|
if (!supported) return null;
|
|
9104
9627
|
const recognition = new SpeechRecognitionAPI();
|
|
9105
9628
|
recognition.lang = language;
|
|
@@ -9108,7 +9631,7 @@ var SpeechToText = forwardRef13(({ editor, onSpeechToText }, ref) => {
|
|
|
9108
9631
|
recognition.maxAlternatives = 1;
|
|
9109
9632
|
return recognition;
|
|
9110
9633
|
}, [supported, language]);
|
|
9111
|
-
const startSession =
|
|
9634
|
+
const startSession = useCallback12((recognition) => {
|
|
9112
9635
|
if (!recognition || !editor) return;
|
|
9113
9636
|
recognition.onresult = async (event) => {
|
|
9114
9637
|
let finalText = "";
|
|
@@ -9163,7 +9686,7 @@ var SpeechToText = forwardRef13(({ editor, onSpeechToText }, ref) => {
|
|
|
9163
9686
|
}
|
|
9164
9687
|
};
|
|
9165
9688
|
}, [editor, createRecognition, onSpeechToText]);
|
|
9166
|
-
const startListening =
|
|
9689
|
+
const startListening = useCallback12(() => {
|
|
9167
9690
|
if (!supported || !editor) return;
|
|
9168
9691
|
const recognition = createRecognition();
|
|
9169
9692
|
if (!recognition) return;
|
|
@@ -9179,7 +9702,7 @@ var SpeechToText = forwardRef13(({ editor, onSpeechToText }, ref) => {
|
|
|
9179
9702
|
setListening(false);
|
|
9180
9703
|
}
|
|
9181
9704
|
}, [supported, editor, createRecognition, startSession]);
|
|
9182
|
-
const stopListening =
|
|
9705
|
+
const stopListening = useCallback12(() => {
|
|
9183
9706
|
isListeningRef.current = false;
|
|
9184
9707
|
if (recognitionRef.current) {
|
|
9185
9708
|
try {
|
|
@@ -9193,7 +9716,7 @@ var SpeechToText = forwardRef13(({ editor, onSpeechToText }, ref) => {
|
|
|
9193
9716
|
}, []);
|
|
9194
9717
|
useImperativeHandle3(ref, () => ({ stop: stopListening }), [stopListening]);
|
|
9195
9718
|
if (!supported) {
|
|
9196
|
-
return /* @__PURE__ */
|
|
9719
|
+
return /* @__PURE__ */ React109.createElement(Tooltip, { title: "Speech recognition not supported in this browser", placement: "top" }, /* @__PURE__ */ React109.createElement("button", { className: "toolbar-btn", disabled: true }, "\u{1F3A4}"));
|
|
9197
9720
|
}
|
|
9198
9721
|
const LANGUAGES2 = [
|
|
9199
9722
|
{ code: "en-US", label: "English (US)" },
|
|
@@ -9215,7 +9738,7 @@ var SpeechToText = forwardRef13(({ editor, onSpeechToText }, ref) => {
|
|
|
9215
9738
|
{ code: "kn-IN", label: "Kannada" },
|
|
9216
9739
|
{ code: "ml-IN", label: "Malayalam" }
|
|
9217
9740
|
];
|
|
9218
|
-
return /* @__PURE__ */
|
|
9741
|
+
return /* @__PURE__ */ React109.createElement("div", { className: "stt-wrapper", ref: panelRef }, /* @__PURE__ */ React109.createElement(Tooltip, { title: listening ? "Stop recording" : "Speech to Text", placement: "top" }, /* @__PURE__ */ React109.createElement(
|
|
9219
9742
|
"button",
|
|
9220
9743
|
{
|
|
9221
9744
|
className: `toolbar-btn ${listening ? "is-active stt-recording" : ""}`,
|
|
@@ -9228,20 +9751,20 @@ var SpeechToText = forwardRef13(({ editor, onSpeechToText }, ref) => {
|
|
|
9228
9751
|
}
|
|
9229
9752
|
},
|
|
9230
9753
|
"\u{1F3A4}"
|
|
9231
|
-
)), showPanel && !listening && /* @__PURE__ */
|
|
9754
|
+
)), showPanel && !listening && /* @__PURE__ */ React109.createElement("div", { className: "stt-panel" }, /* @__PURE__ */ React109.createElement("div", { className: "stt-panel-header" }, "Speech to Text"), /* @__PURE__ */ React109.createElement("label", { className: "stt-label" }, "Language"), /* @__PURE__ */ React109.createElement(
|
|
9232
9755
|
"select",
|
|
9233
9756
|
{
|
|
9234
9757
|
className: "stt-select",
|
|
9235
9758
|
value: language,
|
|
9236
9759
|
onChange: (e) => setLanguage(e.target.value)
|
|
9237
9760
|
},
|
|
9238
|
-
LANGUAGES2.map((l) => /* @__PURE__ */
|
|
9239
|
-
), /* @__PURE__ */
|
|
9761
|
+
LANGUAGES2.map((l) => /* @__PURE__ */ React109.createElement("option", { key: l.code, value: l.code }, l.label))
|
|
9762
|
+
), /* @__PURE__ */ React109.createElement("div", { className: "stt-info" }, "Speak into your microphone and the text will be typed into the editor."), /* @__PURE__ */ React109.createElement("button", { className: "stt-start-btn", onClick: startListening }, "\u{1F3A4} Start Listening")), listening && interim && /* @__PURE__ */ React109.createElement("div", { className: "stt-interim" }, interim));
|
|
9240
9763
|
});
|
|
9241
9764
|
var SpeechToText_default = SpeechToText;
|
|
9242
9765
|
|
|
9243
9766
|
// lib/RufousTextEditor/AICommands.tsx
|
|
9244
|
-
import
|
|
9767
|
+
import React110, { useState as useState29, useRef as useRef27, useEffect as useEffect24, useCallback as useCallback13 } from "react";
|
|
9245
9768
|
import { createPortal as createPortal2 } from "react-dom";
|
|
9246
9769
|
var AI_COMMANDS = [
|
|
9247
9770
|
{ 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 +9812,16 @@ var callOpenAI = async (prompt, text, previousResults = []) => {
|
|
|
9289
9812
|
return data.choices?.[0]?.message?.content?.trim() || "";
|
|
9290
9813
|
};
|
|
9291
9814
|
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
|
-
|
|
9815
|
+
const [open, setOpen] = useState29(false);
|
|
9816
|
+
const [showModal, setShowModal] = useState29(false);
|
|
9817
|
+
const [loading, setLoading] = useState29(false);
|
|
9818
|
+
const [promptText, setPromptText] = useState29("");
|
|
9819
|
+
const [resultText, setResultText] = useState29("");
|
|
9820
|
+
const [originalText, setOriginalText] = useState29("");
|
|
9821
|
+
const [selectionRange, setSelectionRange] = useState29(null);
|
|
9822
|
+
const [previousResults, setPreviousResults] = useState29([]);
|
|
9823
|
+
const panelRef = useRef27(null);
|
|
9824
|
+
useEffect24(() => {
|
|
9302
9825
|
const handleClick = (e) => {
|
|
9303
9826
|
if (panelRef.current && !panelRef.current.contains(e.target)) {
|
|
9304
9827
|
setOpen(false);
|
|
@@ -9307,7 +9830,7 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9307
9830
|
document.addEventListener("mousedown", handleClick);
|
|
9308
9831
|
return () => document.removeEventListener("mousedown", handleClick);
|
|
9309
9832
|
}, []);
|
|
9310
|
-
const getSelectedText =
|
|
9833
|
+
const getSelectedText = useCallback13(() => {
|
|
9311
9834
|
if (!editor) return { text: "", range: null };
|
|
9312
9835
|
const { from, to, empty } = editor.state.selection;
|
|
9313
9836
|
if (!empty) {
|
|
@@ -9315,7 +9838,7 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9315
9838
|
}
|
|
9316
9839
|
return { text: editor.getText(), range: null };
|
|
9317
9840
|
}, [editor]);
|
|
9318
|
-
const fetchAIResult =
|
|
9841
|
+
const fetchAIResult = useCallback13(async (prompt, text, prevResults = []) => {
|
|
9319
9842
|
setLoading(true);
|
|
9320
9843
|
setResultText("");
|
|
9321
9844
|
try {
|
|
@@ -9333,7 +9856,7 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9333
9856
|
setLoading(false);
|
|
9334
9857
|
}
|
|
9335
9858
|
}, [onAICommand]);
|
|
9336
|
-
const handleCommandSelect =
|
|
9859
|
+
const handleCommandSelect = useCallback13((command) => {
|
|
9337
9860
|
const { text, range } = getSelectedText();
|
|
9338
9861
|
if (!text.trim()) return;
|
|
9339
9862
|
setOriginalText(text);
|
|
@@ -9344,7 +9867,7 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9344
9867
|
setShowModal(true);
|
|
9345
9868
|
fetchAIResult(command.prompt, text, []);
|
|
9346
9869
|
}, [getSelectedText, fetchAIResult]);
|
|
9347
|
-
const handleInsert =
|
|
9870
|
+
const handleInsert = useCallback13(() => {
|
|
9348
9871
|
if (!resultText || !editor) return;
|
|
9349
9872
|
if (selectionRange) {
|
|
9350
9873
|
editor.chain().focus().deleteRange(selectionRange).insertContentAt(selectionRange.from, resultText).run();
|
|
@@ -9354,7 +9877,7 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9354
9877
|
setShowModal(false);
|
|
9355
9878
|
setResultText("");
|
|
9356
9879
|
}, [editor, resultText, selectionRange]);
|
|
9357
|
-
const handleInsertAfter =
|
|
9880
|
+
const handleInsertAfter = useCallback13(() => {
|
|
9358
9881
|
if (!resultText || !editor) return;
|
|
9359
9882
|
if (selectionRange) {
|
|
9360
9883
|
editor.chain().focus().insertContentAt(selectionRange.to, "\n" + resultText).run();
|
|
@@ -9369,11 +9892,11 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9369
9892
|
setShowModal(false);
|
|
9370
9893
|
setResultText("");
|
|
9371
9894
|
}, [editor, resultText, selectionRange]);
|
|
9372
|
-
const handleRefresh =
|
|
9895
|
+
const handleRefresh = useCallback13(() => {
|
|
9373
9896
|
if (!originalText.trim()) return;
|
|
9374
9897
|
fetchAIResult(promptText, originalText, previousResults);
|
|
9375
9898
|
}, [originalText, promptText, previousResults, fetchAIResult]);
|
|
9376
|
-
const handleCancel =
|
|
9899
|
+
const handleCancel = useCallback13(() => {
|
|
9377
9900
|
setShowModal(false);
|
|
9378
9901
|
setResultText("");
|
|
9379
9902
|
setPromptText("");
|
|
@@ -9382,15 +9905,15 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9382
9905
|
setPreviousResults([]);
|
|
9383
9906
|
}, []);
|
|
9384
9907
|
if (!editor) return null;
|
|
9385
|
-
return /* @__PURE__ */
|
|
9908
|
+
return /* @__PURE__ */ React110.createElement(React110.Fragment, null, /* @__PURE__ */ React110.createElement("div", { className: "ai-commands-wrapper", ref: panelRef }, /* @__PURE__ */ React110.createElement(Tooltip, { title: "AI Commands", placement: "top" }, /* @__PURE__ */ React110.createElement(
|
|
9386
9909
|
"button",
|
|
9387
9910
|
{
|
|
9388
9911
|
className: `toolbar-btn ${open ? "is-active" : ""}`,
|
|
9389
9912
|
onClick: () => setOpen(!open)
|
|
9390
9913
|
},
|
|
9391
|
-
/* @__PURE__ */
|
|
9392
|
-
/* @__PURE__ */
|
|
9393
|
-
)), open && /* @__PURE__ */
|
|
9914
|
+
/* @__PURE__ */ React110.createElement("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "currentColor", stroke: "none" }, /* @__PURE__ */ React110.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" })),
|
|
9915
|
+
/* @__PURE__ */ React110.createElement("span", { className: "dropdown-arrow" }, "\u25BE")
|
|
9916
|
+
)), open && /* @__PURE__ */ React110.createElement("div", { className: "ai-commands-panel" }, /* @__PURE__ */ React110.createElement("div", { className: "ai-commands-header" }, "AI Commands"), /* @__PURE__ */ React110.createElement("div", { className: "ai-commands-list" }, AI_COMMANDS.map((cmd) => /* @__PURE__ */ React110.createElement(
|
|
9394
9917
|
"button",
|
|
9395
9918
|
{
|
|
9396
9919
|
key: cmd.id,
|
|
@@ -9398,8 +9921,8 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9398
9921
|
onClick: () => handleCommandSelect(cmd)
|
|
9399
9922
|
},
|
|
9400
9923
|
cmd.label
|
|
9401
|
-
))), /* @__PURE__ */
|
|
9402
|
-
/* @__PURE__ */
|
|
9924
|
+
))), /* @__PURE__ */ React110.createElement("div", { className: "ai-commands-hint" }, editor.state.selection.empty ? "Will apply to all text" : "Will apply to selected text"))), showModal && createPortal2(
|
|
9925
|
+
/* @__PURE__ */ React110.createElement("div", { className: "ai-modal-overlay", onMouseDown: handleCancel }, /* @__PURE__ */ React110.createElement("div", { className: "ai-modal", onMouseDown: (e) => e.stopPropagation() }, /* @__PURE__ */ React110.createElement("div", { className: "ai-modal-header" }, /* @__PURE__ */ React110.createElement("span", { className: "ai-modal-title" }, "AI Assistant"), /* @__PURE__ */ React110.createElement("button", { className: "ai-modal-close", onClick: handleCancel }, "\xD7")), /* @__PURE__ */ React110.createElement("div", { className: "ai-modal-prompt-section" }, /* @__PURE__ */ React110.createElement("label", { className: "ai-modal-label" }, "Prompt"), /* @__PURE__ */ React110.createElement("div", { className: "ai-modal-prompt-row" }, /* @__PURE__ */ React110.createElement(
|
|
9403
9926
|
"textarea",
|
|
9404
9927
|
{
|
|
9405
9928
|
className: "ai-modal-prompt",
|
|
@@ -9407,15 +9930,15 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9407
9930
|
onChange: (e) => setPromptText(e.target.value),
|
|
9408
9931
|
rows: 3
|
|
9409
9932
|
}
|
|
9410
|
-
), /* @__PURE__ */
|
|
9933
|
+
), /* @__PURE__ */ React110.createElement(Tooltip, { title: "Run with custom prompt", placement: "top" }, /* @__PURE__ */ React110.createElement(
|
|
9411
9934
|
"button",
|
|
9412
9935
|
{
|
|
9413
9936
|
className: "ai-modal-robot-btn",
|
|
9414
9937
|
onClick: () => fetchAIResult(promptText, originalText),
|
|
9415
9938
|
disabled: loading
|
|
9416
9939
|
},
|
|
9417
|
-
/* @__PURE__ */
|
|
9418
|
-
)))), /* @__PURE__ */
|
|
9940
|
+
/* @__PURE__ */ React110.createElement("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ React110.createElement("rect", { x: "3", y: "11", width: "18", height: "10", rx: "2" }), /* @__PURE__ */ React110.createElement("circle", { cx: "9", cy: "16", r: "1" }), /* @__PURE__ */ React110.createElement("circle", { cx: "15", cy: "16", r: "1" }), /* @__PURE__ */ React110.createElement("path", { d: "M12 2v4" }), /* @__PURE__ */ React110.createElement("path", { d: "M8 7h8" }))
|
|
9941
|
+
)))), /* @__PURE__ */ React110.createElement("div", { className: "ai-modal-actions" }, /* @__PURE__ */ React110.createElement(
|
|
9419
9942
|
"button",
|
|
9420
9943
|
{
|
|
9421
9944
|
className: "ai-modal-action-btn ai-modal-insert-btn",
|
|
@@ -9423,7 +9946,7 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9423
9946
|
disabled: loading || !resultText
|
|
9424
9947
|
},
|
|
9425
9948
|
"Insert"
|
|
9426
|
-
), /* @__PURE__ */
|
|
9949
|
+
), /* @__PURE__ */ React110.createElement(
|
|
9427
9950
|
"button",
|
|
9428
9951
|
{
|
|
9429
9952
|
className: "ai-modal-action-btn ai-modal-insert-after-btn ms-2",
|
|
@@ -9431,22 +9954,22 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9431
9954
|
disabled: loading || !resultText
|
|
9432
9955
|
},
|
|
9433
9956
|
"Insert After"
|
|
9434
|
-
), /* @__PURE__ */
|
|
9957
|
+
), /* @__PURE__ */ React110.createElement(Tooltip, { title: "Generate another response", placement: "top" }, /* @__PURE__ */ React110.createElement(
|
|
9435
9958
|
"button",
|
|
9436
9959
|
{
|
|
9437
9960
|
className: "ai-modal-action-btn ai-modal-refresh-btn",
|
|
9438
9961
|
onClick: handleRefresh,
|
|
9439
9962
|
disabled: loading
|
|
9440
9963
|
},
|
|
9441
|
-
/* @__PURE__ */
|
|
9442
|
-
))), /* @__PURE__ */
|
|
9964
|
+
/* @__PURE__ */ React110.createElement("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round" }, /* @__PURE__ */ React110.createElement("path", { d: "M21 2v6h-6" }), /* @__PURE__ */ React110.createElement("path", { d: "M3 12a9 9 0 0 1 15-6.7L21 8" }), /* @__PURE__ */ React110.createElement("path", { d: "M3 22v-6h6" }), /* @__PURE__ */ React110.createElement("path", { d: "M21 12a9 9 0 0 1-15 6.7L3 16" }))
|
|
9965
|
+
))), /* @__PURE__ */ React110.createElement("div", { className: "ai-modal-result-section" }, loading ? /* @__PURE__ */ React110.createElement("div", { className: "ai-modal-loading" }, /* @__PURE__ */ React110.createElement("span", { className: "ai-spinner" }), /* @__PURE__ */ React110.createElement("span", null, "Generating response...")) : /* @__PURE__ */ React110.createElement("div", { className: "ai-modal-result" }, resultText)), /* @__PURE__ */ React110.createElement("div", { className: "ai-modal-footer" }, /* @__PURE__ */ React110.createElement("button", { className: "ai-modal-cancel-btn", onClick: handleCancel }, "CANCEL")))),
|
|
9443
9966
|
document.body
|
|
9444
9967
|
));
|
|
9445
9968
|
};
|
|
9446
9969
|
var AICommands_default = AICommands;
|
|
9447
9970
|
|
|
9448
9971
|
// lib/RufousTextEditor/TranslateModal.tsx
|
|
9449
|
-
import
|
|
9972
|
+
import React111, { useState as useState30, useMemo as useMemo3 } from "react";
|
|
9450
9973
|
import { createPortal as createPortal3 } from "react-dom";
|
|
9451
9974
|
var LANGUAGES = [
|
|
9452
9975
|
{ code: "af", name: "Afrikaans" },
|
|
@@ -9586,12 +10109,12 @@ async function translateText(text, sourceLang, targetLang) {
|
|
|
9586
10109
|
return null;
|
|
9587
10110
|
}
|
|
9588
10111
|
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] =
|
|
10112
|
+
const [sourceLang, setSourceLang] = useState30(initialSource || "en");
|
|
10113
|
+
const [targetLang, setTargetLang] = useState30(initialTarget || "hi");
|
|
10114
|
+
const [sourceFilter, setSourceFilter] = useState30("");
|
|
10115
|
+
const [targetFilter, setTargetFilter] = useState30("");
|
|
10116
|
+
const [translating, setTranslating] = useState30(false);
|
|
10117
|
+
const [error, setError] = useState30("");
|
|
9595
10118
|
const filteredSource = useMemo3(() => LANGUAGES.filter(
|
|
9596
10119
|
(l) => l.name.toLowerCase().includes(sourceFilter.toLowerCase()) || l.code.toLowerCase().includes(sourceFilter.toLowerCase())
|
|
9597
10120
|
), [sourceFilter]);
|
|
@@ -9639,7 +10162,7 @@ var TranslateModal = ({ editor, onClose, onTranslate, initialSource, initialTarg
|
|
|
9639
10162
|
}
|
|
9640
10163
|
};
|
|
9641
10164
|
return createPortal3(
|
|
9642
|
-
/* @__PURE__ */
|
|
10165
|
+
/* @__PURE__ */ React111.createElement("div", { className: "modal-overlay", onClick: onClose }, /* @__PURE__ */ React111.createElement("div", { className: "modal-content translate-modal", onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ React111.createElement("div", { className: "modal-header" }, /* @__PURE__ */ React111.createElement("h3", null, "Translate options"), /* @__PURE__ */ React111.createElement("button", { className: "modal-close", onClick: onClose }, "\xD7")), /* @__PURE__ */ React111.createElement("div", { className: "modal-body" }, /* @__PURE__ */ React111.createElement("div", { className: "translate-columns" }, /* @__PURE__ */ React111.createElement("div", { className: "translate-col" }, /* @__PURE__ */ React111.createElement("div", { className: "translate-filter" }, /* @__PURE__ */ React111.createElement(
|
|
9643
10166
|
"input",
|
|
9644
10167
|
{
|
|
9645
10168
|
type: "text",
|
|
@@ -9648,16 +10171,16 @@ var TranslateModal = ({ editor, onClose, onTranslate, initialSource, initialTarg
|
|
|
9648
10171
|
onChange: (e) => setSourceFilter(e.target.value),
|
|
9649
10172
|
className: "translate-filter-input"
|
|
9650
10173
|
}
|
|
9651
|
-
)), /* @__PURE__ */
|
|
10174
|
+
)), /* @__PURE__ */ React111.createElement("div", { className: "translate-list" }, filteredSource.map((lang) => /* @__PURE__ */ React111.createElement(
|
|
9652
10175
|
"button",
|
|
9653
10176
|
{
|
|
9654
10177
|
key: lang.code,
|
|
9655
10178
|
className: `translate-item ${sourceLang === lang.code ? "active" : ""}`,
|
|
9656
10179
|
onClick: () => setSourceLang(lang.code)
|
|
9657
10180
|
},
|
|
9658
|
-
/* @__PURE__ */
|
|
9659
|
-
/* @__PURE__ */
|
|
9660
|
-
)))), /* @__PURE__ */
|
|
10181
|
+
/* @__PURE__ */ React111.createElement("span", { className: "translate-code" }, lang.code),
|
|
10182
|
+
/* @__PURE__ */ React111.createElement("span", { className: "translate-name" }, lang.name)
|
|
10183
|
+
)))), /* @__PURE__ */ React111.createElement("div", { className: "translate-swap" }, /* @__PURE__ */ React111.createElement(Tooltip, { title: "Swap languages", placement: "top" }, /* @__PURE__ */ React111.createElement("button", { className: "translate-swap-btn", onClick: handleSwap }, "\u21C4"))), /* @__PURE__ */ React111.createElement("div", { className: "translate-col" }, /* @__PURE__ */ React111.createElement("div", { className: "translate-filter" }, /* @__PURE__ */ React111.createElement(
|
|
9661
10184
|
"input",
|
|
9662
10185
|
{
|
|
9663
10186
|
type: "text",
|
|
@@ -9666,16 +10189,16 @@ var TranslateModal = ({ editor, onClose, onTranslate, initialSource, initialTarg
|
|
|
9666
10189
|
onChange: (e) => setTargetFilter(e.target.value),
|
|
9667
10190
|
className: "translate-filter-input"
|
|
9668
10191
|
}
|
|
9669
|
-
)), /* @__PURE__ */
|
|
10192
|
+
)), /* @__PURE__ */ React111.createElement("div", { className: "translate-list" }, filteredTarget.map((lang) => /* @__PURE__ */ React111.createElement(
|
|
9670
10193
|
"button",
|
|
9671
10194
|
{
|
|
9672
10195
|
key: lang.code,
|
|
9673
10196
|
className: `translate-item ${targetLang === lang.code ? "active" : ""}`,
|
|
9674
10197
|
onClick: () => setTargetLang(lang.code)
|
|
9675
10198
|
},
|
|
9676
|
-
/* @__PURE__ */
|
|
9677
|
-
/* @__PURE__ */
|
|
9678
|
-
))))), error && /* @__PURE__ */
|
|
10199
|
+
/* @__PURE__ */ React111.createElement("span", { className: "translate-code" }, lang.code),
|
|
10200
|
+
/* @__PURE__ */ React111.createElement("span", { className: "translate-name" }, lang.name)
|
|
10201
|
+
))))), error && /* @__PURE__ */ React111.createElement("div", { className: "translate-error" }, error)), /* @__PURE__ */ React111.createElement("div", { className: "modal-footer" }, /* @__PURE__ */ React111.createElement("div", { className: "modal-footer-left" }, /* @__PURE__ */ React111.createElement("button", { className: "modal-btn-cancel", onClick: onClose }, "Cancel")), /* @__PURE__ */ React111.createElement("button", { className: "modal-btn-apply", onClick: handleSave, disabled: translating }, translating ? "Translating..." : "Save")))),
|
|
9679
10202
|
document.body
|
|
9680
10203
|
);
|
|
9681
10204
|
};
|
|
@@ -10326,38 +10849,38 @@ var CustomTaskItem = TaskItem.extend({
|
|
|
10326
10849
|
});
|
|
10327
10850
|
|
|
10328
10851
|
// lib/RufousTextEditor/icons.tsx
|
|
10329
|
-
import * as
|
|
10852
|
+
import * as React112 from "react";
|
|
10330
10853
|
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__ */
|
|
10854
|
+
var IconUndo = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.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" }));
|
|
10855
|
+
var IconRedo = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.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" }));
|
|
10856
|
+
var IconBold = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.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" }));
|
|
10857
|
+
var IconItalic = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.createElement("path", { d: "M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z" }));
|
|
10858
|
+
var IconLink = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.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" }));
|
|
10859
|
+
var IconStrike = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.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" }));
|
|
10860
|
+
var IconHeading = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.createElement("path", { d: "M5 4v3h5.5v12h3V7H19V4z" }));
|
|
10861
|
+
var IconFontSize = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.createElement("path", { d: "M9 4v3h5v12h2V7h5V4H9zm-6 8h3v7h2v-7h3v-2H3v2z" }));
|
|
10862
|
+
var IconColor = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.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__ */ React112.createElement("path", { d: "M3 20h18v3H3z", opacity: "0.8" }));
|
|
10863
|
+
var IconFont = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.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" }));
|
|
10864
|
+
var IconLineHeight = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.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" }));
|
|
10865
|
+
var IconBulletList = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.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" }));
|
|
10866
|
+
var IconOrderedList = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.createElement("path", { d: "M2 17h2v.5H3v1h1v.5H2v1h3v-4H2v1zm1-9h1V4H2v1h1v3zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2v1zm5-6v2h14V5H7zm0 14h14v-2H7v2zm0-6h14v-2H7v2z" }));
|
|
10867
|
+
var IconAlignLeft = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.createElement("path", { d: "M15 15H3v2h12v-2zm0-8H3v2h12V7zM3 13h18v-2H3v2zM3 21h18v-2H3v2zM3 3v2h18V3H3z" }));
|
|
10868
|
+
var IconAlignCenter = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.createElement("path", { d: "M7 15v2h10v-2H7zm-4 6h18v-2H3v2zm0-8h18v-2H3v2zm4-6v2h10V7H7zM3 3v2h18V3H3z" }));
|
|
10869
|
+
var IconAlignRight = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.createElement("path", { d: "M3 21h18v-2H3v2zm6-4h12v-2H9v2zm-6-4h18v-2H3v2zm6-4h12V7H9v2zM3 3v2h18V3H3z" }));
|
|
10870
|
+
var IconAlignJustify = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.createElement("path", { d: "M3 21h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18v-2H3v2zm0-4h18V7H3v2zM3 3v2h18V3H3z" }));
|
|
10871
|
+
var IconIndentIncrease = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.createElement("path", { d: "M3 21h18v-2H3v2zM3 8v8l4-4-4-4zm8 9h10v-2H11v2zM3 3v2h18V3H3zm8 6h10V7H11v2zm0 4h10v-2H11v2z" }));
|
|
10872
|
+
var IconIndentDecrease = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.createElement("path", { d: "M11 17h10v-2H11v2zm-8-5l4 4V8l-4 4zm0 9h18v-2H3v2zM3 3v2h18V3H3zm8 6h10V7H11v2zm0 4h10v-2H11v2z" }));
|
|
10873
|
+
var IconTable = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.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" }));
|
|
10874
|
+
var IconImage = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.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" }));
|
|
10875
|
+
var IconVideo = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.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" }));
|
|
10876
|
+
var IconCut = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.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" }));
|
|
10877
|
+
var IconCopy = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.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" }));
|
|
10878
|
+
var IconCode = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.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" }));
|
|
10879
|
+
var IconFullscreen = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.createElement("path", { d: "M7 14H5v5h5v-2H7v-3zm-2-4h2V7h3V5H5v5zm12 7h-3v2h5v-5h-2v3zM14 5v2h3v3h2V5h-5z" }));
|
|
10880
|
+
var IconTranslate = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.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" }));
|
|
10881
|
+
var IconTaskList = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.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" }));
|
|
10882
|
+
var IconCheck = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.createElement("path", { d: "M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z" }));
|
|
10883
|
+
var IconPaste = () => /* @__PURE__ */ React112.createElement("svg", { ...s }, /* @__PURE__ */ React112.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
10884
|
|
|
10362
10885
|
// lib/RufousTextEditor/Toolbar.tsx
|
|
10363
10886
|
var COLOR_PALETTE = [
|
|
@@ -10495,10 +11018,10 @@ var SPECIAL_CHARS = [
|
|
|
10495
11018
|
"\xA2"
|
|
10496
11019
|
];
|
|
10497
11020
|
var Dropdown = ({ trigger, children, className = "", keepOpen = false }) => {
|
|
10498
|
-
const [open, setOpen] =
|
|
10499
|
-
const ref =
|
|
10500
|
-
const menuRef =
|
|
10501
|
-
|
|
11021
|
+
const [open, setOpen] = useState31(false);
|
|
11022
|
+
const ref = useRef28(null);
|
|
11023
|
+
const menuRef = useRef28(null);
|
|
11024
|
+
useEffect25(() => {
|
|
10502
11025
|
const handleClick = (e) => {
|
|
10503
11026
|
const target = e.target;
|
|
10504
11027
|
const inTrigger = ref.current?.contains(target);
|
|
@@ -10510,7 +11033,7 @@ var Dropdown = ({ trigger, children, className = "", keepOpen = false }) => {
|
|
|
10510
11033
|
document.addEventListener("mousedown", handleClick);
|
|
10511
11034
|
return () => document.removeEventListener("mousedown", handleClick);
|
|
10512
11035
|
}, []);
|
|
10513
|
-
|
|
11036
|
+
useEffect25(() => {
|
|
10514
11037
|
if (!open || !menuRef.current || !ref.current) return;
|
|
10515
11038
|
const menu = menuRef.current;
|
|
10516
11039
|
const trigger2 = ref.current;
|
|
@@ -10539,22 +11062,22 @@ var Dropdown = ({ trigger, children, className = "", keepOpen = false }) => {
|
|
|
10539
11062
|
};
|
|
10540
11063
|
position();
|
|
10541
11064
|
}, [open]);
|
|
10542
|
-
return /* @__PURE__ */
|
|
11065
|
+
return /* @__PURE__ */ React113.createElement("div", { className: `dropdown ${className}`, ref }, /* @__PURE__ */ React113.createElement(Tooltip, { title: trigger.title || "", placement: "top" }, /* @__PURE__ */ React113.createElement(
|
|
10543
11066
|
"button",
|
|
10544
11067
|
{
|
|
10545
11068
|
className: `toolbar-btn ${trigger.className || ""}`,
|
|
10546
11069
|
onClick: () => setOpen(!open)
|
|
10547
11070
|
},
|
|
10548
11071
|
trigger.label,
|
|
10549
|
-
/* @__PURE__ */
|
|
11072
|
+
/* @__PURE__ */ React113.createElement("span", { className: "dropdown-arrow" }, "\u25BE")
|
|
10550
11073
|
)), open && createPortal4(
|
|
10551
|
-
/* @__PURE__ */
|
|
11074
|
+
/* @__PURE__ */ React113.createElement("div", { className: "rf-rte-wrapper rf-rte-dropdown-portal" }, /* @__PURE__ */ React113.createElement("div", { ref: menuRef, className: "dropdown-menu dropdown-menu-fixed", onClick: keepOpen ? void 0 : () => setOpen(false) }, typeof children === "function" ? children(() => setOpen(false)) : children)),
|
|
10552
11075
|
document.body
|
|
10553
11076
|
));
|
|
10554
11077
|
};
|
|
10555
11078
|
var InsertPanel = ({ editor, onClose, mode = "video" }) => {
|
|
10556
|
-
const [activeTab, setActiveTab] =
|
|
10557
|
-
const [url, setUrl] =
|
|
11079
|
+
const [activeTab, setActiveTab] = useState31("link");
|
|
11080
|
+
const [url, setUrl] = useState31("");
|
|
10558
11081
|
const extractIframeSrc = (html) => {
|
|
10559
11082
|
const match = html.match(/<iframe[^>]+src=["']([^"']+)["']/);
|
|
10560
11083
|
return match ? match[1] : null;
|
|
@@ -10586,14 +11109,14 @@ var InsertPanel = ({ editor, onClose, mode = "video" }) => {
|
|
|
10586
11109
|
}
|
|
10587
11110
|
onClose();
|
|
10588
11111
|
};
|
|
10589
|
-
return /* @__PURE__ */
|
|
11112
|
+
return /* @__PURE__ */ React113.createElement("div", { className: "insert-panel", onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ React113.createElement("div", { className: "insert-panel-tabs" }, /* @__PURE__ */ React113.createElement(
|
|
10590
11113
|
"button",
|
|
10591
11114
|
{
|
|
10592
11115
|
className: `insert-tab ${activeTab === "link" ? "active" : ""}`,
|
|
10593
11116
|
onClick: () => setActiveTab("link")
|
|
10594
11117
|
},
|
|
10595
11118
|
"\u{1F517} Link"
|
|
10596
|
-
), /* @__PURE__ */
|
|
11119
|
+
), /* @__PURE__ */ React113.createElement(
|
|
10597
11120
|
"button",
|
|
10598
11121
|
{
|
|
10599
11122
|
className: `insert-tab ${activeTab === "code" ? "active" : ""}`,
|
|
@@ -10601,7 +11124,7 @@ var InsertPanel = ({ editor, onClose, mode = "video" }) => {
|
|
|
10601
11124
|
},
|
|
10602
11125
|
"</>",
|
|
10603
11126
|
" Code"
|
|
10604
|
-
)), /* @__PURE__ */
|
|
11127
|
+
)), /* @__PURE__ */ React113.createElement("label", { className: "insert-panel-label" }, activeTab === "link" ? "URL" : "Embed Code"), activeTab === "link" ? /* @__PURE__ */ React113.createElement(
|
|
10605
11128
|
"input",
|
|
10606
11129
|
{
|
|
10607
11130
|
type: "text",
|
|
@@ -10612,7 +11135,7 @@ var InsertPanel = ({ editor, onClose, mode = "video" }) => {
|
|
|
10612
11135
|
onKeyDown: (e) => e.key === "Enter" && handleInsert(),
|
|
10613
11136
|
autoFocus: true
|
|
10614
11137
|
}
|
|
10615
|
-
) : /* @__PURE__ */
|
|
11138
|
+
) : /* @__PURE__ */ React113.createElement(
|
|
10616
11139
|
"textarea",
|
|
10617
11140
|
{
|
|
10618
11141
|
className: "insert-panel-textarea",
|
|
@@ -10621,13 +11144,13 @@ var InsertPanel = ({ editor, onClose, mode = "video" }) => {
|
|
|
10621
11144
|
onChange: (e) => setUrl(e.target.value),
|
|
10622
11145
|
rows: 3
|
|
10623
11146
|
}
|
|
10624
|
-
), /* @__PURE__ */
|
|
11147
|
+
), /* @__PURE__ */ React113.createElement("button", { className: "insert-panel-btn", onClick: handleInsert }, "Insert"));
|
|
10625
11148
|
};
|
|
10626
11149
|
var ImagePanel = ({ editor, onClose, onImageUpload }) => {
|
|
10627
|
-
const [activeTab, setActiveTab] =
|
|
10628
|
-
const [url, setUrl] =
|
|
10629
|
-
const [isDragging, setIsDragging] =
|
|
10630
|
-
const fileInputRef =
|
|
11150
|
+
const [activeTab, setActiveTab] = useState31("upload");
|
|
11151
|
+
const [url, setUrl] = useState31("");
|
|
11152
|
+
const [isDragging, setIsDragging] = useState31(false);
|
|
11153
|
+
const fileInputRef = useRef28(null);
|
|
10631
11154
|
const getBase64 = (file) => {
|
|
10632
11155
|
return new Promise((resolve, reject) => {
|
|
10633
11156
|
const reader = new FileReader();
|
|
@@ -10665,21 +11188,21 @@ var ImagePanel = ({ editor, onClose, onImageUpload }) => {
|
|
|
10665
11188
|
editor.chain().focus().setImage({ src: url }).run();
|
|
10666
11189
|
onClose();
|
|
10667
11190
|
};
|
|
10668
|
-
return /* @__PURE__ */
|
|
11191
|
+
return /* @__PURE__ */ React113.createElement("div", { className: "insert-panel", onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ React113.createElement("div", { className: "insert-panel-tabs" }, /* @__PURE__ */ React113.createElement(
|
|
10669
11192
|
"button",
|
|
10670
11193
|
{
|
|
10671
11194
|
className: `insert-tab ${activeTab === "upload" ? "active" : ""}`,
|
|
10672
11195
|
onClick: () => setActiveTab("upload")
|
|
10673
11196
|
},
|
|
10674
11197
|
"\u2B06 Upload"
|
|
10675
|
-
), /* @__PURE__ */
|
|
11198
|
+
), /* @__PURE__ */ React113.createElement(
|
|
10676
11199
|
"button",
|
|
10677
11200
|
{
|
|
10678
11201
|
className: `insert-tab ${activeTab === "url" ? "active" : ""}`,
|
|
10679
11202
|
onClick: () => setActiveTab("url")
|
|
10680
11203
|
},
|
|
10681
11204
|
"\u{1F517} URL"
|
|
10682
|
-
)), activeTab === "upload" ? /* @__PURE__ */
|
|
11205
|
+
)), activeTab === "upload" ? /* @__PURE__ */ React113.createElement(React113.Fragment, null, /* @__PURE__ */ React113.createElement(
|
|
10683
11206
|
"div",
|
|
10684
11207
|
{
|
|
10685
11208
|
className: `drop-zone ${isDragging ? "dragging" : ""}`,
|
|
@@ -10691,9 +11214,9 @@ var ImagePanel = ({ editor, onClose, onImageUpload }) => {
|
|
|
10691
11214
|
onDrop: handleDrop,
|
|
10692
11215
|
onClick: () => fileInputRef.current?.click()
|
|
10693
11216
|
},
|
|
10694
|
-
/* @__PURE__ */
|
|
10695
|
-
/* @__PURE__ */
|
|
10696
|
-
), /* @__PURE__ */
|
|
11217
|
+
/* @__PURE__ */ React113.createElement("span", { className: "drop-zone-text-bold" }, "Drop image"),
|
|
11218
|
+
/* @__PURE__ */ React113.createElement("span", { className: "drop-zone-text-sub" }, "or click")
|
|
11219
|
+
), /* @__PURE__ */ React113.createElement(
|
|
10697
11220
|
"input",
|
|
10698
11221
|
{
|
|
10699
11222
|
ref: fileInputRef,
|
|
@@ -10702,7 +11225,7 @@ var ImagePanel = ({ editor, onClose, onImageUpload }) => {
|
|
|
10702
11225
|
style: { display: "none" },
|
|
10703
11226
|
onChange: handleFileSelect
|
|
10704
11227
|
}
|
|
10705
|
-
)) : /* @__PURE__ */
|
|
11228
|
+
)) : /* @__PURE__ */ React113.createElement(React113.Fragment, null, /* @__PURE__ */ React113.createElement("label", { className: "insert-panel-label" }, "URL"), /* @__PURE__ */ React113.createElement(
|
|
10706
11229
|
"input",
|
|
10707
11230
|
{
|
|
10708
11231
|
type: "text",
|
|
@@ -10713,18 +11236,18 @@ var ImagePanel = ({ editor, onClose, onImageUpload }) => {
|
|
|
10713
11236
|
onKeyDown: (e) => e.key === "Enter" && handleUrlInsert(),
|
|
10714
11237
|
autoFocus: true
|
|
10715
11238
|
}
|
|
10716
|
-
), /* @__PURE__ */
|
|
11239
|
+
), /* @__PURE__ */ React113.createElement("button", { className: "insert-panel-btn", onClick: handleUrlInsert }, "Insert")));
|
|
10717
11240
|
};
|
|
10718
11241
|
var MAX_GRID = 10;
|
|
10719
11242
|
var TableGridSelector = ({ editor, onClose }) => {
|
|
10720
|
-
const [hoverRow, setHoverRow] =
|
|
10721
|
-
const [hoverCol, setHoverCol] =
|
|
11243
|
+
const [hoverRow, setHoverRow] = useState31(0);
|
|
11244
|
+
const [hoverCol, setHoverCol] = useState31(0);
|
|
10722
11245
|
const handleInsert = () => {
|
|
10723
11246
|
if (!editor || hoverRow === 0 || hoverCol === 0) return;
|
|
10724
11247
|
editor.chain().focus().insertTable({ rows: hoverRow, cols: hoverCol, withHeaderRow: true }).run();
|
|
10725
11248
|
onClose();
|
|
10726
11249
|
};
|
|
10727
|
-
return /* @__PURE__ */
|
|
11250
|
+
return /* @__PURE__ */ React113.createElement("div", { className: "table-grid-panel", onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ React113.createElement(
|
|
10728
11251
|
"div",
|
|
10729
11252
|
{
|
|
10730
11253
|
className: "table-grid",
|
|
@@ -10733,7 +11256,7 @@ var TableGridSelector = ({ editor, onClose }) => {
|
|
|
10733
11256
|
setHoverCol(0);
|
|
10734
11257
|
}
|
|
10735
11258
|
},
|
|
10736
|
-
Array.from({ length: MAX_GRID }, (_, r) => /* @__PURE__ */
|
|
11259
|
+
Array.from({ length: MAX_GRID }, (_, r) => /* @__PURE__ */ React113.createElement("div", { key: r, className: "table-grid-row" }, Array.from({ length: MAX_GRID }, (_2, c) => /* @__PURE__ */ React113.createElement(
|
|
10737
11260
|
"div",
|
|
10738
11261
|
{
|
|
10739
11262
|
key: c,
|
|
@@ -10745,7 +11268,7 @@ var TableGridSelector = ({ editor, onClose }) => {
|
|
|
10745
11268
|
onClick: handleInsert
|
|
10746
11269
|
}
|
|
10747
11270
|
))))
|
|
10748
|
-
), /* @__PURE__ */
|
|
11271
|
+
), /* @__PURE__ */ React113.createElement("div", { className: "table-grid-footer" }, /* @__PURE__ */ React113.createElement("span", { className: "table-grid-size" }, hoverRow > 0 && hoverCol > 0 ? `${hoverRow}\xD7${hoverCol}` : "Select size"), /* @__PURE__ */ React113.createElement(
|
|
10749
11272
|
"button",
|
|
10750
11273
|
{
|
|
10751
11274
|
className: "table-grid-submit",
|
|
@@ -10756,9 +11279,9 @@ var TableGridSelector = ({ editor, onClose }) => {
|
|
|
10756
11279
|
)));
|
|
10757
11280
|
};
|
|
10758
11281
|
var ColorPickerPanel = ({ editor, onClose }) => {
|
|
10759
|
-
const [tab, setTab] =
|
|
10760
|
-
const [activeBg, setActiveBg] =
|
|
10761
|
-
const [activeText, setActiveText] =
|
|
11282
|
+
const [tab, setTab] = useState31("background");
|
|
11283
|
+
const [activeBg, setActiveBg] = useState31(() => editor.getAttributes("highlight").color || null);
|
|
11284
|
+
const [activeText, setActiveText] = useState31(() => editor.getAttributes("textStyle").color || null);
|
|
10762
11285
|
const activeColor = tab === "background" ? activeBg : activeText;
|
|
10763
11286
|
const applyColor = (color) => {
|
|
10764
11287
|
if (tab === "background") {
|
|
@@ -10779,51 +11302,51 @@ var ColorPickerPanel = ({ editor, onClose }) => {
|
|
|
10779
11302
|
}
|
|
10780
11303
|
onClose();
|
|
10781
11304
|
};
|
|
10782
|
-
return /* @__PURE__ */
|
|
11305
|
+
return /* @__PURE__ */ React113.createElement("div", { className: "color-picker-panel", onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ React113.createElement("div", { className: "color-picker-tabs" }, /* @__PURE__ */ React113.createElement(
|
|
10783
11306
|
"button",
|
|
10784
11307
|
{
|
|
10785
11308
|
className: `color-picker-tab ${tab === "background" ? "active" : ""}`,
|
|
10786
11309
|
onClick: () => setTab("background")
|
|
10787
11310
|
},
|
|
10788
11311
|
"Background"
|
|
10789
|
-
), /* @__PURE__ */
|
|
11312
|
+
), /* @__PURE__ */ React113.createElement(
|
|
10790
11313
|
"button",
|
|
10791
11314
|
{
|
|
10792
11315
|
className: `color-picker-tab ${tab === "text" ? "active" : ""}`,
|
|
10793
11316
|
onClick: () => setTab("text")
|
|
10794
11317
|
},
|
|
10795
11318
|
"Text"
|
|
10796
|
-
)), /* @__PURE__ */
|
|
11319
|
+
)), /* @__PURE__ */ React113.createElement("div", { className: "color-picker-grid" }, COLOR_PALETTE.map((color, i) => /* @__PURE__ */ React113.createElement(Tooltip, { key: i, title: color, placement: "top" }, /* @__PURE__ */ React113.createElement(
|
|
10797
11320
|
"button",
|
|
10798
11321
|
{
|
|
10799
11322
|
className: `color-picker-swatch ${color === "#ffffff" ? "white-swatch" : ""}${activeColor && activeColor.toLowerCase() === color.toLowerCase() ? " swatch-active" : ""}`,
|
|
10800
11323
|
style: { background: color },
|
|
10801
11324
|
onClick: () => applyColor(color)
|
|
10802
11325
|
}
|
|
10803
|
-
)))), /* @__PURE__ */
|
|
11326
|
+
)))), /* @__PURE__ */ React113.createElement("div", { className: "color-picker-footer" }, /* @__PURE__ */ React113.createElement("div", { className: "color-picker-preview", style: { background: activeColor || "#000" } }), /* @__PURE__ */ React113.createElement(Tooltip, { title: "Remove color", placement: "top" }, /* @__PURE__ */ React113.createElement("button", { className: "color-picker-remove", onClick: removeColor }, "\u2713"))));
|
|
10804
11327
|
};
|
|
10805
11328
|
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 =
|
|
11329
|
+
const [, setEditorState] = useState31(0);
|
|
11330
|
+
const [todoEnabled, setTodoEnabled] = useState31(false);
|
|
11331
|
+
const ttsRef = useRef28(null);
|
|
11332
|
+
const sttRef = useRef28(null);
|
|
10810
11333
|
const show = (id) => !visibleButtons || visibleButtons.has(id);
|
|
10811
|
-
|
|
11334
|
+
useEffect25(() => {
|
|
10812
11335
|
if (!editor) return;
|
|
10813
11336
|
const onTransaction = () => setEditorState((n) => n + 1);
|
|
10814
11337
|
editor.on("transaction", onTransaction);
|
|
10815
11338
|
return () => editor.off("transaction", onTransaction);
|
|
10816
11339
|
}, [editor]);
|
|
10817
|
-
const insertSpecialChar =
|
|
11340
|
+
const insertSpecialChar = useCallback14((char) => {
|
|
10818
11341
|
if (!editor) return;
|
|
10819
11342
|
editor.chain().focus().insertContent(char).run();
|
|
10820
11343
|
}, [editor]);
|
|
10821
|
-
const [copySuccess, setCopySuccess] =
|
|
10822
|
-
const [translateSource, setTranslateSource] =
|
|
10823
|
-
const [translateTarget, setTranslateTarget] =
|
|
10824
|
-
const [translateStatus, setTranslateStatus] =
|
|
10825
|
-
const [showTranslateModal, setShowTranslateModal] =
|
|
10826
|
-
const handleCopy =
|
|
11344
|
+
const [copySuccess, setCopySuccess] = useState31(false);
|
|
11345
|
+
const [translateSource, setTranslateSource] = useState31("en");
|
|
11346
|
+
const [translateTarget, setTranslateTarget] = useState31("hi");
|
|
11347
|
+
const [translateStatus, setTranslateStatus] = useState31("");
|
|
11348
|
+
const [showTranslateModal, setShowTranslateModal] = useState31(false);
|
|
11349
|
+
const handleCopy = useCallback14(async () => {
|
|
10827
11350
|
if (!editor) return;
|
|
10828
11351
|
const { from, to, empty } = editor.state.selection;
|
|
10829
11352
|
if (empty) return;
|
|
@@ -10838,7 +11361,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10838
11361
|
setTimeout(() => setCopySuccess(false), 2e3);
|
|
10839
11362
|
}
|
|
10840
11363
|
}, [editor]);
|
|
10841
|
-
const handlePaste =
|
|
11364
|
+
const handlePaste = useCallback14(async () => {
|
|
10842
11365
|
if (!editor) return;
|
|
10843
11366
|
try {
|
|
10844
11367
|
const text = await navigator.clipboard.readText();
|
|
@@ -10847,7 +11370,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10847
11370
|
document.execCommand("paste");
|
|
10848
11371
|
}
|
|
10849
11372
|
}, [editor]);
|
|
10850
|
-
const handleQuickTranslate =
|
|
11373
|
+
const handleQuickTranslate = useCallback14(async () => {
|
|
10851
11374
|
if (!editor) return;
|
|
10852
11375
|
const { from, to, empty } = editor.state.selection;
|
|
10853
11376
|
if (empty) {
|
|
@@ -10881,32 +11404,32 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10881
11404
|
setTimeout(() => setTranslateStatus(""), 2e3);
|
|
10882
11405
|
}, [editor, translateSource, translateTarget, onTranslate]);
|
|
10883
11406
|
if (!editor) return null;
|
|
10884
|
-
return /* @__PURE__ */
|
|
11407
|
+
return /* @__PURE__ */ React113.createElement("div", { className: "toolbar" }, /* @__PURE__ */ React113.createElement("div", { className: `toolbar-row ${onClose ? "with-close" : ""}` }, (show("undo") || show("redo")) && /* @__PURE__ */ React113.createElement("div", { className: "toolbar-group" }, show("undo") && /* @__PURE__ */ React113.createElement(Tooltip, { title: "Undo (Ctrl+Z)", placement: "top" }, /* @__PURE__ */ React113.createElement(
|
|
10885
11408
|
"button",
|
|
10886
11409
|
{
|
|
10887
11410
|
className: "toolbar-btn",
|
|
10888
11411
|
onClick: () => editor.chain().focus().undo().run(),
|
|
10889
11412
|
disabled: !editor.can().undo()
|
|
10890
11413
|
},
|
|
10891
|
-
/* @__PURE__ */
|
|
10892
|
-
)), show("redo") && /* @__PURE__ */
|
|
11414
|
+
/* @__PURE__ */ React113.createElement(IconUndo, null)
|
|
11415
|
+
)), show("redo") && /* @__PURE__ */ React113.createElement(Tooltip, { title: "Redo (Ctrl+Y)", placement: "top" }, /* @__PURE__ */ React113.createElement(
|
|
10893
11416
|
"button",
|
|
10894
11417
|
{
|
|
10895
11418
|
className: "toolbar-btn",
|
|
10896
11419
|
onClick: () => editor.chain().focus().redo().run(),
|
|
10897
11420
|
disabled: !editor.can().redo()
|
|
10898
11421
|
},
|
|
10899
|
-
/* @__PURE__ */
|
|
10900
|
-
))), show("ai") && /* @__PURE__ */
|
|
11422
|
+
/* @__PURE__ */ React113.createElement(IconRedo, null)
|
|
11423
|
+
))), show("ai") && /* @__PURE__ */ React113.createElement("div", { className: "toolbar-group" }, /* @__PURE__ */ React113.createElement(AICommands_default, { editor, onAICommand })), /* @__PURE__ */ React113.createElement("div", { className: "toolbar-group" }, show("paragraph") && /* @__PURE__ */ React113.createElement(
|
|
10901
11424
|
Dropdown,
|
|
10902
11425
|
{
|
|
10903
11426
|
trigger: {
|
|
10904
|
-
label: /* @__PURE__ */
|
|
11427
|
+
label: /* @__PURE__ */ React113.createElement(IconHeading, null),
|
|
10905
11428
|
title: "Block type",
|
|
10906
11429
|
className: editor.isActive("heading") ? "is-active" : ""
|
|
10907
11430
|
}
|
|
10908
11431
|
},
|
|
10909
|
-
/* @__PURE__ */
|
|
11432
|
+
/* @__PURE__ */ React113.createElement(
|
|
10910
11433
|
"button",
|
|
10911
11434
|
{
|
|
10912
11435
|
className: `dropdown-item ${!editor.isActive("heading") && !editor.isActive("blockquote") && !editor.isActive("codeBlock") ? "is-active" : ""}`,
|
|
@@ -10914,7 +11437,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10914
11437
|
},
|
|
10915
11438
|
"\xB6 Paragraph"
|
|
10916
11439
|
),
|
|
10917
|
-
/* @__PURE__ */
|
|
11440
|
+
/* @__PURE__ */ React113.createElement(
|
|
10918
11441
|
"button",
|
|
10919
11442
|
{
|
|
10920
11443
|
className: `dropdown-item heading-1 ${editor.isActive("heading", { level: 1 }) ? "is-active" : ""}`,
|
|
@@ -10922,7 +11445,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10922
11445
|
},
|
|
10923
11446
|
"Heading 1"
|
|
10924
11447
|
),
|
|
10925
|
-
/* @__PURE__ */
|
|
11448
|
+
/* @__PURE__ */ React113.createElement(
|
|
10926
11449
|
"button",
|
|
10927
11450
|
{
|
|
10928
11451
|
className: `dropdown-item heading-2 ${editor.isActive("heading", { level: 2 }) ? "is-active" : ""}`,
|
|
@@ -10930,7 +11453,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10930
11453
|
},
|
|
10931
11454
|
"Heading 2"
|
|
10932
11455
|
),
|
|
10933
|
-
/* @__PURE__ */
|
|
11456
|
+
/* @__PURE__ */ React113.createElement(
|
|
10934
11457
|
"button",
|
|
10935
11458
|
{
|
|
10936
11459
|
className: `dropdown-item heading-3 ${editor.isActive("heading", { level: 3 }) ? "is-active" : ""}`,
|
|
@@ -10938,7 +11461,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10938
11461
|
},
|
|
10939
11462
|
"Heading 3"
|
|
10940
11463
|
),
|
|
10941
|
-
/* @__PURE__ */
|
|
11464
|
+
/* @__PURE__ */ React113.createElement(
|
|
10942
11465
|
"button",
|
|
10943
11466
|
{
|
|
10944
11467
|
className: `dropdown-item heading-4 ${editor.isActive("heading", { level: 4 }) ? "is-active" : ""}`,
|
|
@@ -10946,7 +11469,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10946
11469
|
},
|
|
10947
11470
|
"Heading 4"
|
|
10948
11471
|
),
|
|
10949
|
-
/* @__PURE__ */
|
|
11472
|
+
/* @__PURE__ */ React113.createElement(
|
|
10950
11473
|
"button",
|
|
10951
11474
|
{
|
|
10952
11475
|
className: `dropdown-item ${editor.isActive("blockquote") ? "is-active" : ""}`,
|
|
@@ -10954,7 +11477,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10954
11477
|
},
|
|
10955
11478
|
"\u275E Blockquote"
|
|
10956
11479
|
),
|
|
10957
|
-
/* @__PURE__ */
|
|
11480
|
+
/* @__PURE__ */ React113.createElement(
|
|
10958
11481
|
"button",
|
|
10959
11482
|
{
|
|
10960
11483
|
className: `dropdown-item ${editor.isActive("codeBlock") ? "is-active" : ""}`,
|
|
@@ -10963,19 +11486,19 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10963
11486
|
"{ }",
|
|
10964
11487
|
" Code Block"
|
|
10965
11488
|
),
|
|
10966
|
-
/* @__PURE__ */
|
|
10967
|
-
), show("fontsize") && /* @__PURE__ */
|
|
11489
|
+
/* @__PURE__ */ React113.createElement("button", { className: "dropdown-item", onClick: () => editor.chain().focus().setHorizontalRule().run() }, "\u2014 Horizontal Rule")
|
|
11490
|
+
), show("fontsize") && /* @__PURE__ */ React113.createElement(
|
|
10968
11491
|
Dropdown,
|
|
10969
11492
|
{
|
|
10970
11493
|
trigger: {
|
|
10971
|
-
label: /* @__PURE__ */
|
|
11494
|
+
label: /* @__PURE__ */ React113.createElement(IconFontSize, null),
|
|
10972
11495
|
title: "Font size"
|
|
10973
11496
|
}
|
|
10974
11497
|
},
|
|
10975
11498
|
[8, 9, 10, 11, 12, 14, 16, 18, 20, 24, 28, 32, 36, 42, 48, 56, 64, 72, 80, 96].map((size) => {
|
|
10976
11499
|
const sizeStr = `${size}px`;
|
|
10977
11500
|
const isActive = editor.getAttributes("textStyle").fontSize === sizeStr;
|
|
10978
|
-
return /* @__PURE__ */
|
|
11501
|
+
return /* @__PURE__ */ React113.createElement(
|
|
10979
11502
|
"button",
|
|
10980
11503
|
{
|
|
10981
11504
|
key: size,
|
|
@@ -10991,17 +11514,17 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10991
11514
|
sizeStr
|
|
10992
11515
|
);
|
|
10993
11516
|
})
|
|
10994
|
-
), show("font") && /* @__PURE__ */
|
|
11517
|
+
), show("font") && /* @__PURE__ */ React113.createElement(
|
|
10995
11518
|
Dropdown,
|
|
10996
11519
|
{
|
|
10997
11520
|
trigger: {
|
|
10998
|
-
label: /* @__PURE__ */
|
|
11521
|
+
label: /* @__PURE__ */ React113.createElement(IconFont, null),
|
|
10999
11522
|
title: "Font family"
|
|
11000
11523
|
}
|
|
11001
11524
|
},
|
|
11002
11525
|
FONT_FAMILIES.map((font) => {
|
|
11003
11526
|
const isActive = editor.getAttributes("textStyle").fontFamily === font;
|
|
11004
|
-
return /* @__PURE__ */
|
|
11527
|
+
return /* @__PURE__ */ React113.createElement(
|
|
11005
11528
|
"button",
|
|
11006
11529
|
{
|
|
11007
11530
|
key: font,
|
|
@@ -11018,40 +11541,40 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11018
11541
|
font
|
|
11019
11542
|
);
|
|
11020
11543
|
})
|
|
11021
|
-
), show("color") && /* @__PURE__ */
|
|
11544
|
+
), show("color") && /* @__PURE__ */ React113.createElement(
|
|
11022
11545
|
Dropdown,
|
|
11023
11546
|
{
|
|
11024
11547
|
trigger: {
|
|
11025
|
-
label: /* @__PURE__ */
|
|
11548
|
+
label: /* @__PURE__ */ React113.createElement("span", { style: { display: "flex", alignItems: "center" } }, /* @__PURE__ */ React113.createElement(IconColor, null)),
|
|
11026
11549
|
title: "Colors"
|
|
11027
11550
|
},
|
|
11028
11551
|
keepOpen: true
|
|
11029
11552
|
},
|
|
11030
|
-
(close) => /* @__PURE__ */
|
|
11031
|
-
), show("bold") && /* @__PURE__ */
|
|
11553
|
+
(close) => /* @__PURE__ */ React113.createElement(ColorPickerPanel, { editor, onClose: close })
|
|
11554
|
+
), show("bold") && /* @__PURE__ */ React113.createElement(Tooltip, { title: "Bold (Ctrl+B)", placement: "top" }, /* @__PURE__ */ React113.createElement(
|
|
11032
11555
|
"button",
|
|
11033
11556
|
{
|
|
11034
11557
|
className: `toolbar-btn ${editor.isActive("bold") ? "is-active" : ""}`,
|
|
11035
11558
|
onClick: () => editor.chain().focus().toggleBold().run()
|
|
11036
11559
|
},
|
|
11037
|
-
/* @__PURE__ */
|
|
11038
|
-
)), show("italic") && /* @__PURE__ */
|
|
11560
|
+
/* @__PURE__ */ React113.createElement(IconBold, null)
|
|
11561
|
+
)), show("italic") && /* @__PURE__ */ React113.createElement(Tooltip, { title: "Italic (Ctrl+I)", placement: "top" }, /* @__PURE__ */ React113.createElement(
|
|
11039
11562
|
"button",
|
|
11040
11563
|
{
|
|
11041
11564
|
className: `toolbar-btn ${editor.isActive("italic") ? "is-active" : ""}`,
|
|
11042
11565
|
onClick: () => editor.chain().focus().toggleItalic().run()
|
|
11043
11566
|
},
|
|
11044
|
-
/* @__PURE__ */
|
|
11045
|
-
)), show("strike") && /* @__PURE__ */
|
|
11567
|
+
/* @__PURE__ */ React113.createElement(IconItalic, null)
|
|
11568
|
+
)), show("strike") && /* @__PURE__ */ React113.createElement(
|
|
11046
11569
|
Dropdown,
|
|
11047
11570
|
{
|
|
11048
|
-
trigger: { label: /* @__PURE__ */
|
|
11571
|
+
trigger: { label: /* @__PURE__ */ React113.createElement(IconStrike, null), title: "Text decoration", className: editor.isActive("strike") ? "is-active" : "" }
|
|
11049
11572
|
},
|
|
11050
|
-
/* @__PURE__ */
|
|
11051
|
-
/* @__PURE__ */
|
|
11052
|
-
/* @__PURE__ */
|
|
11053
|
-
/* @__PURE__ */
|
|
11054
|
-
/* @__PURE__ */
|
|
11573
|
+
/* @__PURE__ */ React113.createElement("button", { className: "dropdown-item", onClick: () => editor.chain().focus().toggleStrike().run() }, /* @__PURE__ */ React113.createElement("s", null, "Strikethrough")),
|
|
11574
|
+
/* @__PURE__ */ React113.createElement("button", { className: "dropdown-item", onClick: () => editor.chain().focus().toggleUnderline().run() }, /* @__PURE__ */ React113.createElement("u", null, "Underline")),
|
|
11575
|
+
/* @__PURE__ */ React113.createElement("button", { className: "dropdown-item", onClick: () => editor.chain().focus().toggleSuperscript().run() }, "X", /* @__PURE__ */ React113.createElement("sup", null, "2"), " Superscript"),
|
|
11576
|
+
/* @__PURE__ */ React113.createElement("button", { className: "dropdown-item", onClick: () => editor.chain().focus().toggleSubscript().run() }, "X", /* @__PURE__ */ React113.createElement("sub", null, "2"), " Subscript"),
|
|
11577
|
+
/* @__PURE__ */ React113.createElement("button", { className: "dropdown-item", onMouseDown: (e) => {
|
|
11055
11578
|
e.preventDefault();
|
|
11056
11579
|
const chain = editor.chain().focus();
|
|
11057
11580
|
if (!editor.state.selection.empty) {
|
|
@@ -11067,25 +11590,25 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11067
11590
|
c.run();
|
|
11068
11591
|
}
|
|
11069
11592
|
} }, "\u2715 Clear formatting")
|
|
11070
|
-
), show("link") && /* @__PURE__ */
|
|
11593
|
+
), show("link") && /* @__PURE__ */ React113.createElement(Tooltip, { title: "Insert Link", placement: "top" }, /* @__PURE__ */ React113.createElement(
|
|
11071
11594
|
"button",
|
|
11072
11595
|
{
|
|
11073
11596
|
className: `toolbar-btn ${editor.isActive("link") ? "is-active" : ""}`,
|
|
11074
11597
|
onClick: setLink
|
|
11075
11598
|
},
|
|
11076
|
-
/* @__PURE__ */
|
|
11077
|
-
)), show("lineheight") && /* @__PURE__ */
|
|
11599
|
+
/* @__PURE__ */ React113.createElement(IconLink, null)
|
|
11600
|
+
)), show("lineheight") && /* @__PURE__ */ React113.createElement(
|
|
11078
11601
|
Dropdown,
|
|
11079
11602
|
{
|
|
11080
11603
|
trigger: {
|
|
11081
|
-
label: /* @__PURE__ */
|
|
11604
|
+
label: /* @__PURE__ */ React113.createElement(IconLineHeight, null),
|
|
11082
11605
|
title: "Line height"
|
|
11083
11606
|
}
|
|
11084
11607
|
},
|
|
11085
11608
|
["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
11609
|
const currentLH = editor.getAttributes("paragraph").lineHeight || editor.getAttributes("heading").lineHeight;
|
|
11087
11610
|
const isActive = currentLH === lh;
|
|
11088
|
-
return /* @__PURE__ */
|
|
11611
|
+
return /* @__PURE__ */ React113.createElement(
|
|
11089
11612
|
"button",
|
|
11090
11613
|
{
|
|
11091
11614
|
key: lh,
|
|
@@ -11101,19 +11624,19 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11101
11624
|
lh
|
|
11102
11625
|
);
|
|
11103
11626
|
})
|
|
11104
|
-
)), (show("ul") || show("ol")) && /* @__PURE__ */
|
|
11627
|
+
)), (show("ul") || show("ol")) && /* @__PURE__ */ React113.createElement("div", { className: "toolbar-group" }, show("ul") && /* @__PURE__ */ React113.createElement("div", { className: "list-split-btn" }, /* @__PURE__ */ React113.createElement(Tooltip, { title: editor.isActive("bulletList") ? "Disable Bullet List" : "Enable Bullet List", placement: "top" }, /* @__PURE__ */ React113.createElement(
|
|
11105
11628
|
"button",
|
|
11106
11629
|
{
|
|
11107
11630
|
className: `toolbar-btn ${editor.isActive("bulletList") ? "is-active" : ""}`,
|
|
11108
11631
|
onClick: () => editor.chain().focus().toggleBulletList().run()
|
|
11109
11632
|
},
|
|
11110
|
-
/* @__PURE__ */
|
|
11111
|
-
)), /* @__PURE__ */
|
|
11633
|
+
/* @__PURE__ */ React113.createElement(IconBulletList, null)
|
|
11634
|
+
)), /* @__PURE__ */ React113.createElement(Dropdown, { trigger: { label: "", title: "List style", className: "list-arrow-btn" }, keepOpen: true }, [
|
|
11112
11635
|
{ label: "Default", style: null, icon: "\u2022" },
|
|
11113
11636
|
{ label: "Circle", style: "circle", icon: "\u25CB" },
|
|
11114
11637
|
{ label: "Dot", style: "disc", icon: "\u2219" },
|
|
11115
11638
|
{ label: "Square", style: "square", icon: "\u25A0" }
|
|
11116
|
-
].map((item) => /* @__PURE__ */
|
|
11639
|
+
].map((item) => /* @__PURE__ */ React113.createElement(
|
|
11117
11640
|
"button",
|
|
11118
11641
|
{
|
|
11119
11642
|
key: item.label,
|
|
@@ -11138,24 +11661,24 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11138
11661
|
}).run();
|
|
11139
11662
|
}
|
|
11140
11663
|
},
|
|
11141
|
-
/* @__PURE__ */
|
|
11664
|
+
/* @__PURE__ */ React113.createElement("span", { className: "bullet-style-icon" }, item.icon),
|
|
11142
11665
|
" ",
|
|
11143
11666
|
item.label
|
|
11144
|
-
)))), show("ol") && /* @__PURE__ */
|
|
11667
|
+
)))), show("ol") && /* @__PURE__ */ React113.createElement("div", { className: "list-split-btn" }, /* @__PURE__ */ React113.createElement(Tooltip, { title: editor.isActive("orderedList") ? "Disable Ordered List" : "Enable Ordered List", placement: "top" }, /* @__PURE__ */ React113.createElement(
|
|
11145
11668
|
"button",
|
|
11146
11669
|
{
|
|
11147
11670
|
className: `toolbar-btn ${editor.isActive("orderedList") ? "is-active" : ""}`,
|
|
11148
11671
|
onClick: () => editor.chain().focus().toggleOrderedList().run()
|
|
11149
11672
|
},
|
|
11150
|
-
/* @__PURE__ */
|
|
11151
|
-
)), /* @__PURE__ */
|
|
11673
|
+
/* @__PURE__ */ React113.createElement(IconOrderedList, null)
|
|
11674
|
+
)), /* @__PURE__ */ React113.createElement(Dropdown, { trigger: { label: "", title: "List style", className: "list-arrow-btn" }, keepOpen: true }, [
|
|
11152
11675
|
{ label: "Default", style: "decimal", icon: "1." },
|
|
11153
11676
|
{ label: "Lower Alpha", style: "lower-alpha", icon: "a." },
|
|
11154
11677
|
{ label: "Lower Greek", style: "lower-greek", icon: "\u03B1." },
|
|
11155
11678
|
{ label: "Lower Roman", style: "lower-roman", icon: "i." },
|
|
11156
11679
|
{ label: "Upper Alpha", style: "upper-alpha", icon: "A." },
|
|
11157
11680
|
{ label: "Upper Roman", style: "upper-roman", icon: "I." }
|
|
11158
|
-
].map((item) => /* @__PURE__ */
|
|
11681
|
+
].map((item) => /* @__PURE__ */ React113.createElement(
|
|
11159
11682
|
"button",
|
|
11160
11683
|
{
|
|
11161
11684
|
key: item.label,
|
|
@@ -11180,24 +11703,24 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11180
11703
|
}).run();
|
|
11181
11704
|
}
|
|
11182
11705
|
},
|
|
11183
|
-
/* @__PURE__ */
|
|
11706
|
+
/* @__PURE__ */ React113.createElement("span", { className: "bullet-style-icon" }, item.icon),
|
|
11184
11707
|
" ",
|
|
11185
11708
|
item.label
|
|
11186
|
-
))))), (show("align") || show("indent") || show("outdent")) && /* @__PURE__ */
|
|
11709
|
+
))))), (show("align") || show("indent") || show("outdent")) && /* @__PURE__ */ React113.createElement("div", { className: "toolbar-group" }, show("align") && /* @__PURE__ */ React113.createElement(
|
|
11187
11710
|
Dropdown,
|
|
11188
11711
|
{
|
|
11189
11712
|
trigger: {
|
|
11190
|
-
label: /* @__PURE__ */
|
|
11713
|
+
label: /* @__PURE__ */ React113.createElement(IconAlignLeft, null),
|
|
11191
11714
|
title: "Align",
|
|
11192
11715
|
className: editor.isActive({ textAlign: "center" }) || editor.isActive({ textAlign: "right" }) || editor.isActive({ textAlign: "justify" }) ? "is-active" : ""
|
|
11193
11716
|
}
|
|
11194
11717
|
},
|
|
11195
11718
|
[
|
|
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__ */
|
|
11719
|
+
{ label: "Align Left", value: "left", icon: /* @__PURE__ */ React113.createElement(IconAlignLeft, null) },
|
|
11720
|
+
{ label: "Align Center", value: "center", icon: /* @__PURE__ */ React113.createElement(IconAlignCenter, null) },
|
|
11721
|
+
{ label: "Align Right", value: "right", icon: /* @__PURE__ */ React113.createElement(IconAlignRight, null) },
|
|
11722
|
+
{ label: "Align Justify", value: "justify", icon: /* @__PURE__ */ React113.createElement(IconAlignJustify, null) }
|
|
11723
|
+
].map((item) => /* @__PURE__ */ React113.createElement(
|
|
11201
11724
|
"button",
|
|
11202
11725
|
{
|
|
11203
11726
|
key: item.value,
|
|
@@ -11208,7 +11731,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11208
11731
|
" ",
|
|
11209
11732
|
item.label
|
|
11210
11733
|
))
|
|
11211
|
-
), show("indent") && /* @__PURE__ */
|
|
11734
|
+
), show("indent") && /* @__PURE__ */ React113.createElement(Tooltip, { title: "Increase Indent", placement: "top" }, /* @__PURE__ */ React113.createElement(
|
|
11212
11735
|
"button",
|
|
11213
11736
|
{
|
|
11214
11737
|
className: "toolbar-btn",
|
|
@@ -11227,8 +11750,8 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11227
11750
|
}).run();
|
|
11228
11751
|
}
|
|
11229
11752
|
},
|
|
11230
|
-
/* @__PURE__ */
|
|
11231
|
-
)), show("outdent") && /* @__PURE__ */
|
|
11753
|
+
/* @__PURE__ */ React113.createElement(IconIndentIncrease, null)
|
|
11754
|
+
)), show("outdent") && /* @__PURE__ */ React113.createElement(Tooltip, { title: "Decrease Indent", placement: "top" }, /* @__PURE__ */ React113.createElement(
|
|
11232
11755
|
"button",
|
|
11233
11756
|
{
|
|
11234
11757
|
className: "toolbar-btn",
|
|
@@ -11247,29 +11770,29 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11247
11770
|
}).run();
|
|
11248
11771
|
}
|
|
11249
11772
|
},
|
|
11250
|
-
/* @__PURE__ */
|
|
11251
|
-
))), show("table") && /* @__PURE__ */
|
|
11773
|
+
/* @__PURE__ */ React113.createElement(IconIndentDecrease, null)
|
|
11774
|
+
))), show("table") && /* @__PURE__ */ React113.createElement(Dropdown, { trigger: { label: /* @__PURE__ */ React113.createElement(IconTable, null), title: "Insert Table" }, keepOpen: true }, (close) => /* @__PURE__ */ React113.createElement(TableGridSelector, { editor, onClose: close })), show("image") && /* @__PURE__ */ React113.createElement(Dropdown, { trigger: { label: /* @__PURE__ */ React113.createElement(IconImage, null), title: "Insert Image" }, keepOpen: true }, (close) => /* @__PURE__ */ React113.createElement(ImagePanel, { editor, onClose: close, onImageUpload })), show("video") && /* @__PURE__ */ React113.createElement(Dropdown, { trigger: { label: /* @__PURE__ */ React113.createElement(IconVideo, null), title: "Insert Video" }, keepOpen: true }, (close) => /* @__PURE__ */ React113.createElement(InsertPanel, { editor, onClose: close, mode: "video" })), show("cut") && /* @__PURE__ */ React113.createElement(Tooltip, { title: "Cut (Ctrl+X)", placement: "top" }, /* @__PURE__ */ React113.createElement(
|
|
11252
11775
|
"button",
|
|
11253
11776
|
{
|
|
11254
11777
|
className: "toolbar-btn",
|
|
11255
11778
|
onClick: () => document.execCommand("cut")
|
|
11256
11779
|
},
|
|
11257
|
-
/* @__PURE__ */
|
|
11258
|
-
)), show("copy") && /* @__PURE__ */
|
|
11780
|
+
/* @__PURE__ */ React113.createElement(IconCut, null)
|
|
11781
|
+
)), show("copy") && /* @__PURE__ */ React113.createElement(Tooltip, { title: "Copy selected text", placement: "top" }, /* @__PURE__ */ React113.createElement(
|
|
11259
11782
|
"button",
|
|
11260
11783
|
{
|
|
11261
11784
|
className: "toolbar-btn",
|
|
11262
11785
|
onClick: handleCopy
|
|
11263
11786
|
},
|
|
11264
|
-
copySuccess ? /* @__PURE__ */
|
|
11265
|
-
)), show("paste") && /* @__PURE__ */
|
|
11787
|
+
copySuccess ? /* @__PURE__ */ React113.createElement(IconCheck, null) : /* @__PURE__ */ React113.createElement(IconCopy, null)
|
|
11788
|
+
)), show("paste") && /* @__PURE__ */ React113.createElement(Tooltip, { title: "Paste (Ctrl+V)", placement: "top" }, /* @__PURE__ */ React113.createElement(
|
|
11266
11789
|
"button",
|
|
11267
11790
|
{
|
|
11268
11791
|
className: "toolbar-btn",
|
|
11269
11792
|
onClick: handlePaste
|
|
11270
11793
|
},
|
|
11271
|
-
/* @__PURE__ */
|
|
11272
|
-
)), show("specialchars") && /* @__PURE__ */
|
|
11794
|
+
/* @__PURE__ */ React113.createElement(IconPaste, null)
|
|
11795
|
+
)), show("specialchars") && /* @__PURE__ */ React113.createElement(Dropdown, { trigger: { label: "\u03A9", title: "Special characters", className: "special-characters-btn" } }, /* @__PURE__ */ React113.createElement("div", { className: "char-grid" }, SPECIAL_CHARS.map((char) => /* @__PURE__ */ React113.createElement(
|
|
11273
11796
|
"button",
|
|
11274
11797
|
{
|
|
11275
11798
|
key: char,
|
|
@@ -11277,12 +11800,12 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11277
11800
|
onClick: () => insertSpecialChar(char)
|
|
11278
11801
|
},
|
|
11279
11802
|
char
|
|
11280
|
-
)))), show("code") && /* @__PURE__ */
|
|
11803
|
+
)))), show("code") && /* @__PURE__ */ React113.createElement(
|
|
11281
11804
|
Dropdown,
|
|
11282
11805
|
{
|
|
11283
|
-
trigger: { label: /* @__PURE__ */
|
|
11806
|
+
trigger: { label: /* @__PURE__ */ React113.createElement(IconCode, null), title: "Code", className: editor.isActive("code") || editor.isActive("codeBlock") ? "is-active" : "" }
|
|
11284
11807
|
},
|
|
11285
|
-
/* @__PURE__ */
|
|
11808
|
+
/* @__PURE__ */ React113.createElement("button", { className: "dropdown-item", onClick: () => {
|
|
11286
11809
|
if (editor.isActive("codeBlock")) {
|
|
11287
11810
|
const text = (() => {
|
|
11288
11811
|
const { $from } = editor.state.selection;
|
|
@@ -11300,22 +11823,22 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11300
11823
|
editor.chain().focus().toggleCode().run();
|
|
11301
11824
|
}
|
|
11302
11825
|
} }, "</>", " Inline Code"),
|
|
11303
|
-
/* @__PURE__ */
|
|
11304
|
-
), show("fullscreen") && /* @__PURE__ */
|
|
11826
|
+
/* @__PURE__ */ React113.createElement("button", { className: "dropdown-item", onClick: () => editor.chain().focus().toggleCodeBlock().run() }, "{ }", " Code Block")
|
|
11827
|
+
), show("fullscreen") && /* @__PURE__ */ React113.createElement(Tooltip, { title: "Toggle Fullscreen", placement: "top" }, /* @__PURE__ */ React113.createElement(
|
|
11305
11828
|
"button",
|
|
11306
11829
|
{
|
|
11307
11830
|
className: `toolbar-btn ${isFullscreen ? "is-active" : ""}`,
|
|
11308
11831
|
onClick: onToggleFullscreen
|
|
11309
11832
|
},
|
|
11310
|
-
/* @__PURE__ */
|
|
11311
|
-
)), show("tts") && /* @__PURE__ */
|
|
11833
|
+
/* @__PURE__ */ React113.createElement(IconFullscreen, null)
|
|
11834
|
+
)), show("tts") && /* @__PURE__ */ React113.createElement(TextToSpeech_default, { ref: ttsRef, editor, onTextToSpeech }), show("stt") && /* @__PURE__ */ React113.createElement(SpeechToText_default, { ref: sttRef, editor, onSpeechToText }), show("translate") && /* @__PURE__ */ React113.createElement("div", { className: "translate-split-btn" }, /* @__PURE__ */ React113.createElement(Tooltip, { title: "Translate selected text", placement: "top" }, /* @__PURE__ */ React113.createElement(
|
|
11312
11835
|
"button",
|
|
11313
11836
|
{
|
|
11314
11837
|
className: "toolbar-btn",
|
|
11315
11838
|
onClick: handleQuickTranslate
|
|
11316
11839
|
},
|
|
11317
|
-
/* @__PURE__ */
|
|
11318
|
-
)), /* @__PURE__ */
|
|
11840
|
+
/* @__PURE__ */ React113.createElement(IconTranslate, null)
|
|
11841
|
+
)), /* @__PURE__ */ React113.createElement(Dropdown, { trigger: { label: "", title: "Translate options", className: "translate-arrow-btn" } }, /* @__PURE__ */ React113.createElement("button", { className: "dropdown-item", onClick: () => setShowTranslateModal(true) }, "Options")), translateStatus && /* @__PURE__ */ React113.createElement("span", { className: `translate-toast-popup ${translateStatus === "Please select the text" || translateStatus === "Translation failed" ? "error" : ""}` }, translateStatus)), show("todo") && /* @__PURE__ */ React113.createElement("div", { className: "todo-split-btn" }, /* @__PURE__ */ React113.createElement(Tooltip, { title: todoEnabled ? "Disable Task List" : "Enable Task List", placement: "top" }, /* @__PURE__ */ React113.createElement(
|
|
11319
11842
|
"button",
|
|
11320
11843
|
{
|
|
11321
11844
|
className: `toolbar-btn ${todoEnabled ? "is-active" : ""}`,
|
|
@@ -11358,11 +11881,11 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11358
11881
|
}
|
|
11359
11882
|
}
|
|
11360
11883
|
},
|
|
11361
|
-
/* @__PURE__ */
|
|
11362
|
-
)), /* @__PURE__ */
|
|
11884
|
+
/* @__PURE__ */ React113.createElement(IconTaskList, null)
|
|
11885
|
+
)), /* @__PURE__ */ React113.createElement(Dropdown, { trigger: { label: "", title: "Task status", className: "todo-arrow-btn" }, keepOpen: true }, ["todo", "working", "blocked", "resolved"].map((status) => {
|
|
11363
11886
|
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
11887
|
const labels = { todo: "Todo", working: "Working", blocked: "Blocked", resolved: "Resolved" };
|
|
11365
|
-
return /* @__PURE__ */
|
|
11888
|
+
return /* @__PURE__ */ React113.createElement("button", { key: status, className: "dropdown-item task-status-item", onClick: () => {
|
|
11366
11889
|
const { state } = editor;
|
|
11367
11890
|
const { schema } = state;
|
|
11368
11891
|
const taskItemType = schema.nodes.taskItem;
|
|
@@ -11395,8 +11918,8 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11395
11918
|
}
|
|
11396
11919
|
return true;
|
|
11397
11920
|
}).run();
|
|
11398
|
-
} }, /* @__PURE__ */
|
|
11399
|
-
})))), onClose && /* @__PURE__ */
|
|
11921
|
+
} }, /* @__PURE__ */ React113.createElement("span", { className: `task-icon task-${status}` }, /* @__PURE__ */ React113.createElement("img", { src: images[status], alt: status })), " ", labels[status]);
|
|
11922
|
+
})))), onClose && /* @__PURE__ */ React113.createElement("div", { className: "toolbar-row-right" }, /* @__PURE__ */ React113.createElement(Tooltip, { title: "Close", placement: "top" }, /* @__PURE__ */ React113.createElement(
|
|
11400
11923
|
"button",
|
|
11401
11924
|
{
|
|
11402
11925
|
className: "toolbar-btn btn-cross",
|
|
@@ -11412,8 +11935,8 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11412
11935
|
onClose();
|
|
11413
11936
|
}
|
|
11414
11937
|
},
|
|
11415
|
-
/* @__PURE__ */
|
|
11416
|
-
))), showTranslateModal && /* @__PURE__ */
|
|
11938
|
+
/* @__PURE__ */ React113.createElement(closeIcon_default, { color: "#a81c08" })
|
|
11939
|
+
))), showTranslateModal && /* @__PURE__ */ React113.createElement(
|
|
11417
11940
|
TranslateModal_default,
|
|
11418
11941
|
{
|
|
11419
11942
|
editor,
|
|
@@ -11431,7 +11954,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11431
11954
|
var Toolbar_default = Toolbar;
|
|
11432
11955
|
|
|
11433
11956
|
// lib/RufousTextEditor/ImageToolbar.tsx
|
|
11434
|
-
import
|
|
11957
|
+
import React114, { useState as useState32, useEffect as useEffect26, useRef as useRef29 } from "react";
|
|
11435
11958
|
import { createPortal as createPortal5 } from "react-dom";
|
|
11436
11959
|
var ALIGNMENTS = [
|
|
11437
11960
|
{ value: "left", label: "Left", icon: "\u2630" },
|
|
@@ -11439,18 +11962,18 @@ var ALIGNMENTS = [
|
|
|
11439
11962
|
{ value: "right", label: "Right", icon: "\u2263" }
|
|
11440
11963
|
];
|
|
11441
11964
|
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
|
-
|
|
11965
|
+
const [activeTab, setActiveTab] = useState32("image");
|
|
11966
|
+
const [src, setSrc] = useState32(node?.attrs?.src || "");
|
|
11967
|
+
const [title, setTitle] = useState32(node?.attrs?.title || "");
|
|
11968
|
+
const [alt, setAlt] = useState32(node?.attrs?.alt || "");
|
|
11969
|
+
const [link, setLink] = useState32("");
|
|
11970
|
+
const [openInNewTab, setOpenInNewTab] = useState32(false);
|
|
11971
|
+
const [width, setWidth] = useState32("");
|
|
11972
|
+
const [height, setHeight] = useState32("");
|
|
11973
|
+
const [lockRatio, setLockRatio] = useState32(true);
|
|
11974
|
+
const [naturalWidth, setNaturalWidth] = useState32(0);
|
|
11975
|
+
const [naturalHeight, setNaturalHeight] = useState32(0);
|
|
11976
|
+
useEffect26(() => {
|
|
11454
11977
|
if (src) {
|
|
11455
11978
|
const img = new window.Image();
|
|
11456
11979
|
img.onload = () => {
|
|
@@ -11489,7 +12012,7 @@ var ImagePropertiesModal = ({ editor, node, onClose }) => {
|
|
|
11489
12012
|
editor.chain().focus().deleteSelection().run();
|
|
11490
12013
|
onClose();
|
|
11491
12014
|
};
|
|
11492
|
-
return /* @__PURE__ */
|
|
12015
|
+
return /* @__PURE__ */ React114.createElement("div", { className: "modal-overlay", onClick: onClose }, /* @__PURE__ */ React114.createElement("div", { className: "modal-content", onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ React114.createElement("div", { className: "modal-header" }, /* @__PURE__ */ React114.createElement("h3", null, "Image properties"), /* @__PURE__ */ React114.createElement("button", { className: "modal-close", onClick: onClose }, "\xD7")), /* @__PURE__ */ React114.createElement("div", { className: "modal-body" }, /* @__PURE__ */ React114.createElement("div", { className: "modal-layout" }, /* @__PURE__ */ React114.createElement("div", { className: "modal-preview-col" }, src && /* @__PURE__ */ React114.createElement("div", { className: "modal-preview" }, /* @__PURE__ */ React114.createElement("img", { src, alt: alt || "Preview" })), /* @__PURE__ */ React114.createElement("div", { className: "modal-dimensions" }, /* @__PURE__ */ React114.createElement(
|
|
11493
12016
|
"input",
|
|
11494
12017
|
{
|
|
11495
12018
|
type: "number",
|
|
@@ -11497,14 +12020,14 @@ var ImagePropertiesModal = ({ editor, node, onClose }) => {
|
|
|
11497
12020
|
value: width,
|
|
11498
12021
|
onChange: (e) => handleWidthChange(e.target.value)
|
|
11499
12022
|
}
|
|
11500
|
-
), /* @__PURE__ */
|
|
12023
|
+
), /* @__PURE__ */ React114.createElement(Tooltip, { title: lockRatio ? "Unlock aspect ratio" : "Lock aspect ratio", placement: "top" }, /* @__PURE__ */ React114.createElement(
|
|
11501
12024
|
"button",
|
|
11502
12025
|
{
|
|
11503
12026
|
className: `lock-btn ${lockRatio ? "locked" : ""}`,
|
|
11504
12027
|
onClick: () => setLockRatio(!lockRatio)
|
|
11505
12028
|
},
|
|
11506
12029
|
lockRatio ? "\u{1F512}" : "\u{1F513}"
|
|
11507
|
-
)), /* @__PURE__ */
|
|
12030
|
+
)), /* @__PURE__ */ React114.createElement(
|
|
11508
12031
|
"input",
|
|
11509
12032
|
{
|
|
11510
12033
|
type: "number",
|
|
@@ -11512,21 +12035,21 @@ var ImagePropertiesModal = ({ editor, node, onClose }) => {
|
|
|
11512
12035
|
value: height,
|
|
11513
12036
|
onChange: (e) => handleHeightChange(e.target.value)
|
|
11514
12037
|
}
|
|
11515
|
-
))), /* @__PURE__ */
|
|
12038
|
+
))), /* @__PURE__ */ React114.createElement("div", { className: "modal-fields-col" }, /* @__PURE__ */ React114.createElement("div", { className: "modal-tabs" }, /* @__PURE__ */ React114.createElement(
|
|
11516
12039
|
"button",
|
|
11517
12040
|
{
|
|
11518
12041
|
className: `modal-tab ${activeTab === "image" ? "active" : ""}`,
|
|
11519
12042
|
onClick: () => setActiveTab("image")
|
|
11520
12043
|
},
|
|
11521
12044
|
"Image"
|
|
11522
|
-
), /* @__PURE__ */
|
|
12045
|
+
), /* @__PURE__ */ React114.createElement(
|
|
11523
12046
|
"button",
|
|
11524
12047
|
{
|
|
11525
12048
|
className: `modal-tab ${activeTab === "advanced" ? "active" : ""}`,
|
|
11526
12049
|
onClick: () => setActiveTab("advanced")
|
|
11527
12050
|
},
|
|
11528
12051
|
"Advanced"
|
|
11529
|
-
)), activeTab === "image" ? /* @__PURE__ */
|
|
12052
|
+
)), activeTab === "image" ? /* @__PURE__ */ React114.createElement(React114.Fragment, null, /* @__PURE__ */ React114.createElement("label", { className: "modal-label" }, "Src"), /* @__PURE__ */ React114.createElement(
|
|
11530
12053
|
"input",
|
|
11531
12054
|
{
|
|
11532
12055
|
type: "text",
|
|
@@ -11534,7 +12057,7 @@ var ImagePropertiesModal = ({ editor, node, onClose }) => {
|
|
|
11534
12057
|
value: src,
|
|
11535
12058
|
onChange: (e) => setSrc(e.target.value)
|
|
11536
12059
|
}
|
|
11537
|
-
), /* @__PURE__ */
|
|
12060
|
+
), /* @__PURE__ */ React114.createElement("label", { className: "modal-label" }, "Title"), /* @__PURE__ */ React114.createElement(
|
|
11538
12061
|
"input",
|
|
11539
12062
|
{
|
|
11540
12063
|
type: "text",
|
|
@@ -11542,7 +12065,7 @@ var ImagePropertiesModal = ({ editor, node, onClose }) => {
|
|
|
11542
12065
|
value: title,
|
|
11543
12066
|
onChange: (e) => setTitle(e.target.value)
|
|
11544
12067
|
}
|
|
11545
|
-
), /* @__PURE__ */
|
|
12068
|
+
), /* @__PURE__ */ React114.createElement("label", { className: "modal-label" }, "Alternative"), /* @__PURE__ */ React114.createElement(
|
|
11546
12069
|
"input",
|
|
11547
12070
|
{
|
|
11548
12071
|
type: "text",
|
|
@@ -11550,7 +12073,7 @@ var ImagePropertiesModal = ({ editor, node, onClose }) => {
|
|
|
11550
12073
|
value: alt,
|
|
11551
12074
|
onChange: (e) => setAlt(e.target.value)
|
|
11552
12075
|
}
|
|
11553
|
-
), /* @__PURE__ */
|
|
12076
|
+
), /* @__PURE__ */ React114.createElement("label", { className: "modal-label" }, "Link"), /* @__PURE__ */ React114.createElement(
|
|
11554
12077
|
"input",
|
|
11555
12078
|
{
|
|
11556
12079
|
type: "text",
|
|
@@ -11558,23 +12081,23 @@ var ImagePropertiesModal = ({ editor, node, onClose }) => {
|
|
|
11558
12081
|
value: link,
|
|
11559
12082
|
onChange: (e) => setLink(e.target.value)
|
|
11560
12083
|
}
|
|
11561
|
-
), /* @__PURE__ */
|
|
12084
|
+
), /* @__PURE__ */ React114.createElement("label", { className: "modal-checkbox" }, /* @__PURE__ */ React114.createElement(
|
|
11562
12085
|
"input",
|
|
11563
12086
|
{
|
|
11564
12087
|
type: "checkbox",
|
|
11565
12088
|
checked: openInNewTab,
|
|
11566
12089
|
onChange: (e) => setOpenInNewTab(e.target.checked)
|
|
11567
12090
|
}
|
|
11568
|
-
), "Open link in new tab")) : /* @__PURE__ */
|
|
12091
|
+
), "Open link in new tab")) : /* @__PURE__ */ React114.createElement(React114.Fragment, null, /* @__PURE__ */ React114.createElement("label", { className: "modal-label" }, "CSS Class"), /* @__PURE__ */ React114.createElement("input", { type: "text", className: "modal-input", placeholder: "e.g. rounded shadow" }), /* @__PURE__ */ React114.createElement("label", { className: "modal-label" }, "Inline Style"), /* @__PURE__ */ React114.createElement("input", { type: "text", className: "modal-input", placeholder: "e.g. border: 1px solid #ccc" }))))), /* @__PURE__ */ React114.createElement("div", { className: "modal-footer" }, /* @__PURE__ */ React114.createElement("div", { className: "modal-footer-left" }, /* @__PURE__ */ React114.createElement("button", { className: "modal-btn-cancel", onClick: onClose }, "Cancel"), /* @__PURE__ */ React114.createElement("button", { className: "modal-btn-delete", onClick: handleDelete }, "Delete")), /* @__PURE__ */ React114.createElement("button", { className: "modal-btn-apply", onClick: handleApply }, "Apply"))));
|
|
11569
12092
|
};
|
|
11570
12093
|
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
|
-
|
|
12094
|
+
const [showModal, setShowModal] = useState32(false);
|
|
12095
|
+
const [showAlign, setShowAlign] = useState32(false);
|
|
12096
|
+
const [showVAlign, setShowVAlign] = useState32(false);
|
|
12097
|
+
const [copyStatus, setCopyStatus] = useState32("");
|
|
12098
|
+
const [pos, setPos] = useState32(null);
|
|
12099
|
+
const toolbarRef = useRef29(null);
|
|
12100
|
+
useEffect26(() => {
|
|
11578
12101
|
if (!editor) return;
|
|
11579
12102
|
const update = () => {
|
|
11580
12103
|
const { selection } = editor.state;
|
|
@@ -11604,7 +12127,7 @@ var ImageToolbar = ({ editor }) => {
|
|
|
11604
12127
|
const node = editor?.state.selection.node;
|
|
11605
12128
|
const isImage = node && node.type.name === "image";
|
|
11606
12129
|
if (!editor || !isImage || !pos) return showModal ? createPortal5(
|
|
11607
|
-
/* @__PURE__ */
|
|
12130
|
+
/* @__PURE__ */ React114.createElement(ImagePropertiesModal, { editor, node, onClose: () => setShowModal(false) }),
|
|
11608
12131
|
document.body
|
|
11609
12132
|
) : null;
|
|
11610
12133
|
const handleDelete = () => {
|
|
@@ -11681,7 +12204,7 @@ var ImageToolbar = ({ editor }) => {
|
|
|
11681
12204
|
setShowVAlign(false);
|
|
11682
12205
|
};
|
|
11683
12206
|
return createPortal5(
|
|
11684
|
-
/* @__PURE__ */
|
|
12207
|
+
/* @__PURE__ */ React114.createElement(React114.Fragment, null, /* @__PURE__ */ React114.createElement(
|
|
11685
12208
|
"div",
|
|
11686
12209
|
{
|
|
11687
12210
|
className: "image-toolbar",
|
|
@@ -11689,14 +12212,14 @@ var ImageToolbar = ({ editor }) => {
|
|
|
11689
12212
|
style: { position: "absolute", top: pos.top, left: pos.left, zIndex: 1e3 },
|
|
11690
12213
|
onMouseDown: (e) => e.preventDefault()
|
|
11691
12214
|
},
|
|
11692
|
-
/* @__PURE__ */
|
|
11693
|
-
/* @__PURE__ */
|
|
11694
|
-
/* @__PURE__ */
|
|
11695
|
-
/* @__PURE__ */
|
|
12215
|
+
/* @__PURE__ */ React114.createElement(Tooltip, { title: "Delete", placement: "top" }, /* @__PURE__ */ React114.createElement("button", { className: "img-tool-btn", onClick: handleDelete }, "\u{1F5D1}")),
|
|
12216
|
+
/* @__PURE__ */ React114.createElement(Tooltip, { title: "Edit properties", placement: "top" }, /* @__PURE__ */ React114.createElement("button", { className: "img-tool-btn", onClick: () => setShowModal(true) }, "\u270E")),
|
|
12217
|
+
/* @__PURE__ */ React114.createElement("div", { className: "img-tool-copy-wrapper" }, /* @__PURE__ */ React114.createElement(Tooltip, { title: "Copy image", placement: "top" }, /* @__PURE__ */ React114.createElement("button", { className: "img-tool-btn", onClick: handleCopy }, copyStatus ? "\u2713" : "\u{1F4CB}")), copyStatus && /* @__PURE__ */ React114.createElement("span", { className: "img-copy-toast" }, copyStatus)),
|
|
12218
|
+
/* @__PURE__ */ React114.createElement("div", { className: "img-tool-dropdown" }, /* @__PURE__ */ React114.createElement(Tooltip, { title: "Horizontal alignment", placement: "top" }, /* @__PURE__ */ React114.createElement("button", { className: "img-tool-btn", onClick: () => {
|
|
11696
12219
|
setShowAlign(!showAlign);
|
|
11697
12220
|
setShowVAlign(false);
|
|
11698
|
-
} }, "\u2630 ", /* @__PURE__ */
|
|
11699
|
-
), showModal && /* @__PURE__ */
|
|
12221
|
+
} }, "\u2630 ", /* @__PURE__ */ React114.createElement("span", { className: "dropdown-arrow" }, "\u25BE"))), showAlign && /* @__PURE__ */ React114.createElement("div", { className: "img-tool-menu" }, ALIGNMENTS.map((a) => /* @__PURE__ */ React114.createElement("button", { key: a.value, className: "dropdown-item", onClick: () => setAlignmentVal(a.value) }, a.icon, " ", a.label))))
|
|
12222
|
+
), showModal && /* @__PURE__ */ React114.createElement(
|
|
11700
12223
|
ImagePropertiesModal,
|
|
11701
12224
|
{
|
|
11702
12225
|
editor,
|
|
@@ -11710,7 +12233,7 @@ var ImageToolbar = ({ editor }) => {
|
|
|
11710
12233
|
var ImageToolbar_default = ImageToolbar;
|
|
11711
12234
|
|
|
11712
12235
|
// lib/RufousTextEditor/VideoToolbar.tsx
|
|
11713
|
-
import
|
|
12236
|
+
import React115, { useState as useState33, useEffect as useEffect27, useRef as useRef30 } from "react";
|
|
11714
12237
|
import { createPortal as createPortal6 } from "react-dom";
|
|
11715
12238
|
var ALIGNMENTS2 = [
|
|
11716
12239
|
{ value: "left", label: "Left", icon: "\u2630" },
|
|
@@ -11719,10 +12242,10 @@ var ALIGNMENTS2 = [
|
|
|
11719
12242
|
];
|
|
11720
12243
|
var VIDEO_TYPES = ["youtube", "video"];
|
|
11721
12244
|
var VideoPropertiesModal = ({ editor, node, nodeType, onClose }) => {
|
|
11722
|
-
const [src, setSrc] =
|
|
11723
|
-
const [width, setWidth] =
|
|
11724
|
-
const [height, setHeight] =
|
|
11725
|
-
const [lockRatio, setLockRatio] =
|
|
12245
|
+
const [src, setSrc] = useState33(node?.attrs?.src || "");
|
|
12246
|
+
const [width, setWidth] = useState33(String(node?.attrs?.width || 640));
|
|
12247
|
+
const [height, setHeight] = useState33(String(node?.attrs?.height || 360));
|
|
12248
|
+
const [lockRatio, setLockRatio] = useState33(true);
|
|
11726
12249
|
const handleWidthChange = (val) => {
|
|
11727
12250
|
setWidth(val);
|
|
11728
12251
|
if (lockRatio) {
|
|
@@ -11755,7 +12278,7 @@ var VideoPropertiesModal = ({ editor, node, nodeType, onClose }) => {
|
|
|
11755
12278
|
onClose();
|
|
11756
12279
|
};
|
|
11757
12280
|
const isYoutube = nodeType === "youtube";
|
|
11758
|
-
return /* @__PURE__ */
|
|
12281
|
+
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, "Video 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", style: { background: "#000" } }, isYoutube ? /* @__PURE__ */ React115.createElement(
|
|
11759
12282
|
"iframe",
|
|
11760
12283
|
{
|
|
11761
12284
|
src,
|
|
@@ -11763,14 +12286,14 @@ var VideoPropertiesModal = ({ editor, node, nodeType, onClose }) => {
|
|
|
11763
12286
|
style: { width: "100%", aspectRatio: "16/9", border: "none", display: "block" },
|
|
11764
12287
|
allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
|
11765
12288
|
}
|
|
11766
|
-
) : /* @__PURE__ */
|
|
12289
|
+
) : /* @__PURE__ */ React115.createElement(
|
|
11767
12290
|
"video",
|
|
11768
12291
|
{
|
|
11769
12292
|
src,
|
|
11770
12293
|
controls: true,
|
|
11771
12294
|
style: { width: "100%", aspectRatio: "16/9", display: "block" }
|
|
11772
12295
|
}
|
|
11773
|
-
)), /* @__PURE__ */
|
|
12296
|
+
)), /* @__PURE__ */ React115.createElement("div", { className: "modal-dimensions" }, /* @__PURE__ */ React115.createElement(
|
|
11774
12297
|
"input",
|
|
11775
12298
|
{
|
|
11776
12299
|
type: "number",
|
|
@@ -11778,14 +12301,14 @@ var VideoPropertiesModal = ({ editor, node, nodeType, onClose }) => {
|
|
|
11778
12301
|
value: width,
|
|
11779
12302
|
onChange: (e) => handleWidthChange(e.target.value)
|
|
11780
12303
|
}
|
|
11781
|
-
), /* @__PURE__ */
|
|
12304
|
+
), /* @__PURE__ */ React115.createElement(Tooltip, { title: lockRatio ? "Unlock aspect ratio" : "Lock aspect ratio", placement: "top" }, /* @__PURE__ */ React115.createElement(
|
|
11782
12305
|
"button",
|
|
11783
12306
|
{
|
|
11784
12307
|
className: `lock-btn ${lockRatio ? "locked" : ""}`,
|
|
11785
12308
|
onClick: () => setLockRatio(!lockRatio)
|
|
11786
12309
|
},
|
|
11787
12310
|
lockRatio ? "\u{1F512}" : "\u{1F513}"
|
|
11788
|
-
)), /* @__PURE__ */
|
|
12311
|
+
)), /* @__PURE__ */ React115.createElement(
|
|
11789
12312
|
"input",
|
|
11790
12313
|
{
|
|
11791
12314
|
type: "number",
|
|
@@ -11793,7 +12316,7 @@ var VideoPropertiesModal = ({ editor, node, nodeType, onClose }) => {
|
|
|
11793
12316
|
value: height,
|
|
11794
12317
|
onChange: (e) => handleHeightChange(e.target.value)
|
|
11795
12318
|
}
|
|
11796
|
-
))), /* @__PURE__ */
|
|
12319
|
+
))), /* @__PURE__ */ React115.createElement("div", { className: "modal-fields-col" }, /* @__PURE__ */ React115.createElement("label", { className: "modal-label" }, "Video URL"), /* @__PURE__ */ React115.createElement(
|
|
11797
12320
|
"input",
|
|
11798
12321
|
{
|
|
11799
12322
|
type: "text",
|
|
@@ -11801,7 +12324,7 @@ var VideoPropertiesModal = ({ editor, node, nodeType, onClose }) => {
|
|
|
11801
12324
|
value: src,
|
|
11802
12325
|
onChange: (e) => setSrc(e.target.value)
|
|
11803
12326
|
}
|
|
11804
|
-
), /* @__PURE__ */
|
|
12327
|
+
), /* @__PURE__ */ React115.createElement("label", { className: "modal-label" }, "Width"), /* @__PURE__ */ React115.createElement(
|
|
11805
12328
|
"input",
|
|
11806
12329
|
{
|
|
11807
12330
|
type: "number",
|
|
@@ -11809,7 +12332,7 @@ var VideoPropertiesModal = ({ editor, node, nodeType, onClose }) => {
|
|
|
11809
12332
|
value: width,
|
|
11810
12333
|
onChange: (e) => handleWidthChange(e.target.value)
|
|
11811
12334
|
}
|
|
11812
|
-
), /* @__PURE__ */
|
|
12335
|
+
), /* @__PURE__ */ React115.createElement("label", { className: "modal-label" }, "Height"), /* @__PURE__ */ React115.createElement(
|
|
11813
12336
|
"input",
|
|
11814
12337
|
{
|
|
11815
12338
|
type: "number",
|
|
@@ -11817,16 +12340,16 @@ var VideoPropertiesModal = ({ editor, node, nodeType, onClose }) => {
|
|
|
11817
12340
|
value: height,
|
|
11818
12341
|
onChange: (e) => handleHeightChange(e.target.value)
|
|
11819
12342
|
}
|
|
11820
|
-
)))), /* @__PURE__ */
|
|
12343
|
+
)))), /* @__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"))));
|
|
11821
12344
|
};
|
|
11822
12345
|
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
|
-
|
|
12346
|
+
const [showModal, setShowModal] = useState33(false);
|
|
12347
|
+
const [showSize, setShowSize] = useState33(false);
|
|
12348
|
+
const [showAlign, setShowAlign] = useState33(false);
|
|
12349
|
+
const [copyStatus, setCopyStatus] = useState33("");
|
|
12350
|
+
const [pos, setPos] = useState33(null);
|
|
12351
|
+
const toolbarRef = useRef30(null);
|
|
12352
|
+
useEffect27(() => {
|
|
11830
12353
|
if (!editor) return;
|
|
11831
12354
|
const update = () => {
|
|
11832
12355
|
const { selection } = editor.state;
|
|
@@ -11857,7 +12380,7 @@ var VideoToolbar = ({ editor }) => {
|
|
|
11857
12380
|
const isVideo = node && VIDEO_TYPES.includes(node.type.name);
|
|
11858
12381
|
const nodeType = node?.type.name;
|
|
11859
12382
|
if (!editor || !isVideo || !pos) return showModal ? createPortal6(
|
|
11860
|
-
/* @__PURE__ */
|
|
12383
|
+
/* @__PURE__ */ React115.createElement(VideoPropertiesModal, { editor, node, nodeType, onClose: () => setShowModal(false) }),
|
|
11861
12384
|
document.body
|
|
11862
12385
|
) : null;
|
|
11863
12386
|
const handleDelete = () => {
|
|
@@ -11904,7 +12427,7 @@ var VideoToolbar = ({ editor }) => {
|
|
|
11904
12427
|
);
|
|
11905
12428
|
};
|
|
11906
12429
|
return createPortal6(
|
|
11907
|
-
/* @__PURE__ */
|
|
12430
|
+
/* @__PURE__ */ React115.createElement(React115.Fragment, null, /* @__PURE__ */ React115.createElement(
|
|
11908
12431
|
"div",
|
|
11909
12432
|
{
|
|
11910
12433
|
className: "image-toolbar",
|
|
@@ -11912,30 +12435,30 @@ var VideoToolbar = ({ editor }) => {
|
|
|
11912
12435
|
style: { position: "absolute", top: pos.top, left: pos.left, zIndex: 1e3 },
|
|
11913
12436
|
onMouseDown: (e) => e.preventDefault()
|
|
11914
12437
|
},
|
|
11915
|
-
/* @__PURE__ */
|
|
11916
|
-
/* @__PURE__ */
|
|
11917
|
-
/* @__PURE__ */
|
|
11918
|
-
/* @__PURE__ */
|
|
12438
|
+
/* @__PURE__ */ React115.createElement(Tooltip, { title: "Delete", placement: "top" }, /* @__PURE__ */ React115.createElement("button", { className: "img-tool-btn", onClick: handleDelete }, "\u{1F5D1}")),
|
|
12439
|
+
/* @__PURE__ */ React115.createElement(Tooltip, { title: "Edit properties", placement: "top" }, /* @__PURE__ */ React115.createElement("button", { className: "img-tool-btn", onClick: () => setShowModal(true) }, "\u270E")),
|
|
12440
|
+
/* @__PURE__ */ React115.createElement("div", { className: "img-tool-copy-wrapper" }, /* @__PURE__ */ React115.createElement(Tooltip, { title: "Copy URL", 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)),
|
|
12441
|
+
/* @__PURE__ */ React115.createElement("div", { className: "img-tool-dropdown" }, /* @__PURE__ */ React115.createElement(Tooltip, { title: "Size presets", placement: "top" }, /* @__PURE__ */ React115.createElement("button", { className: "img-tool-btn", onClick: () => {
|
|
11919
12442
|
setShowSize(!showSize);
|
|
11920
12443
|
setShowAlign(false);
|
|
11921
|
-
} }, /* @__PURE__ */
|
|
12444
|
+
} }, /* @__PURE__ */ React115.createElement("span", { style: { fontSize: "11px" } }, node.attrs.width || 640, "x", node.attrs.height || 360), /* @__PURE__ */ React115.createElement("span", { className: "dropdown-arrow" }, "\u25BE"))), showSize && /* @__PURE__ */ React115.createElement("div", { className: "img-tool-menu" }, /* @__PURE__ */ React115.createElement("button", { className: "dropdown-item", onClick: () => {
|
|
11922
12445
|
handleResize("small");
|
|
11923
12446
|
setShowSize(false);
|
|
11924
|
-
} }, "Small (320x180)"), /* @__PURE__ */
|
|
12447
|
+
} }, "Small (320x180)"), /* @__PURE__ */ React115.createElement("button", { className: "dropdown-item", onClick: () => {
|
|
11925
12448
|
handleResize("medium");
|
|
11926
12449
|
setShowSize(false);
|
|
11927
|
-
} }, "Medium (480x270)"), /* @__PURE__ */
|
|
12450
|
+
} }, "Medium (480x270)"), /* @__PURE__ */ React115.createElement("button", { className: "dropdown-item", onClick: () => {
|
|
11928
12451
|
handleResize("large");
|
|
11929
12452
|
setShowSize(false);
|
|
11930
|
-
} }, "Large (640x360)"), /* @__PURE__ */
|
|
12453
|
+
} }, "Large (640x360)"), /* @__PURE__ */ React115.createElement("button", { className: "dropdown-item", onClick: () => {
|
|
11931
12454
|
handleResize("full");
|
|
11932
12455
|
setShowSize(false);
|
|
11933
12456
|
} }, "Full (854x480)"))),
|
|
11934
|
-
/* @__PURE__ */
|
|
12457
|
+
/* @__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: () => {
|
|
11935
12458
|
setShowAlign(!showAlign);
|
|
11936
12459
|
setShowSize(false);
|
|
11937
|
-
} }, "\u2630 ", /* @__PURE__ */
|
|
11938
|
-
), showModal && /* @__PURE__ */
|
|
12460
|
+
} }, "\u2630 ", /* @__PURE__ */ React115.createElement("span", { className: "dropdown-arrow" }, "\u25BE"))), showAlign && /* @__PURE__ */ React115.createElement("div", { className: "img-tool-menu" }, ALIGNMENTS2.map((a) => /* @__PURE__ */ React115.createElement("button", { key: a.value, className: "dropdown-item", onClick: () => setAlignmentVal(a.value) }, a.icon, " ", a.label))))
|
|
12461
|
+
), showModal && /* @__PURE__ */ React115.createElement(
|
|
11939
12462
|
VideoPropertiesModal,
|
|
11940
12463
|
{
|
|
11941
12464
|
editor,
|
|
@@ -11950,22 +12473,22 @@ var VideoToolbar = ({ editor }) => {
|
|
|
11950
12473
|
var VideoToolbar_default = VideoToolbar;
|
|
11951
12474
|
|
|
11952
12475
|
// lib/RufousTextEditor/TableToolbar.tsx
|
|
11953
|
-
import
|
|
12476
|
+
import React116, { useState as useState34, useEffect as useEffect28, useRef as useRef31 } from "react";
|
|
11954
12477
|
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__ */
|
|
12478
|
+
var IconAddRowBefore = () => /* @__PURE__ */ React116.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor" }, /* @__PURE__ */ React116.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__ */ React116.createElement("path", { d: "M9 6h2v1.5h1.5v2H11V11H9V9.5H7.5v-2H9z" }));
|
|
12479
|
+
var IconAddRowAfter = () => /* @__PURE__ */ React116.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor" }, /* @__PURE__ */ React116.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__ */ React116.createElement("path", { d: "M9 14h2v1.5h1.5v2H11V19H9v-1.5H7.5v-2H9z" }));
|
|
12480
|
+
var IconAddColBefore = () => /* @__PURE__ */ React116.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor" }, /* @__PURE__ */ React116.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__ */ React116.createElement("path", { d: "M6 10h1.5v2H6v1.5H4v-2h1.5V10H4V8h2z", transform: "translate(2,1)" }));
|
|
12481
|
+
var IconAddColAfter = () => /* @__PURE__ */ React116.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor" }, /* @__PURE__ */ React116.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__ */ React116.createElement("path", { d: "M15 9h2v1.5h1.5v2H17V14h-2v-1.5h-1.5v-2H15z" }));
|
|
12482
|
+
var IconDeleteRow = () => /* @__PURE__ */ React116.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor" }, /* @__PURE__ */ React116.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__ */ React116.createElement("path", { d: "M8 14.5h8v2H8z" }));
|
|
12483
|
+
var IconDeleteCol = () => /* @__PURE__ */ React116.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor" }, /* @__PURE__ */ React116.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__ */ React116.createElement("path", { d: "M14 9.5v6h2v-6z" }));
|
|
12484
|
+
var IconDeleteTable = () => /* @__PURE__ */ React116.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor" }, /* @__PURE__ */ React116.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__ */ React116.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" }));
|
|
12485
|
+
var IconMergeCells = () => /* @__PURE__ */ React116.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor" }, /* @__PURE__ */ React116.createElement("path", { d: "M3 3h18v18H3V3zm2 2v5h6V5H5zm8 0v5h6V5h-6zM5 13v6h14v-6H5z" }), /* @__PURE__ */ React116.createElement("path", { d: "M8 15h8v2H8z" }));
|
|
12486
|
+
var IconSplitCell = () => /* @__PURE__ */ React116.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor" }, /* @__PURE__ */ React116.createElement("path", { d: "M3 3h18v18H3V3zm2 2v5h6V5H5zm8 0v5h6V5h-6zM5 13v6h6v-6H5zm8 0v6h6v-6h-6z" }));
|
|
12487
|
+
var IconToggleHeader = () => /* @__PURE__ */ React116.createElement("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "currentColor" }, /* @__PURE__ */ React116.createElement("path", { d: "M3 3h18v18H3V3zm2 2v4h14V5H5zm0 6v8h14v-8H5z" }), /* @__PURE__ */ React116.createElement("rect", { x: "5", y: "5", width: "14", height: "4", opacity: "0.4" }));
|
|
11965
12488
|
var TableToolbar = ({ editor }) => {
|
|
11966
|
-
const [pos, setPos] =
|
|
11967
|
-
const toolbarRef =
|
|
11968
|
-
|
|
12489
|
+
const [pos, setPos] = useState34(null);
|
|
12490
|
+
const toolbarRef = useRef31(null);
|
|
12491
|
+
useEffect28(() => {
|
|
11969
12492
|
if (!editor) return;
|
|
11970
12493
|
const update = () => {
|
|
11971
12494
|
if (!editor.isActive("table")) {
|
|
@@ -12009,7 +12532,7 @@ var TableToolbar = ({ editor }) => {
|
|
|
12009
12532
|
const canSplit = editor.can().splitCell();
|
|
12010
12533
|
const prevent = (e) => e.preventDefault();
|
|
12011
12534
|
return createPortal7(
|
|
12012
|
-
/* @__PURE__ */
|
|
12535
|
+
/* @__PURE__ */ React116.createElement(
|
|
12013
12536
|
"div",
|
|
12014
12537
|
{
|
|
12015
12538
|
ref: toolbarRef,
|
|
@@ -12017,19 +12540,19 @@ var TableToolbar = ({ editor }) => {
|
|
|
12017
12540
|
style: { top: pos.top, left: pos.left },
|
|
12018
12541
|
onMouseDown: prevent
|
|
12019
12542
|
},
|
|
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__ */
|
|
12543
|
+
/* @__PURE__ */ React116.createElement(Tooltip, { title: "Insert row above", placement: "top" }, /* @__PURE__ */ React116.createElement("button", { className: "rf-table-toolbar-btn", onClick: () => editor.chain().focus().addRowBefore().run() }, /* @__PURE__ */ React116.createElement(IconAddRowBefore, null))),
|
|
12544
|
+
/* @__PURE__ */ React116.createElement(Tooltip, { title: "Insert row below", placement: "top" }, /* @__PURE__ */ React116.createElement("button", { className: "rf-table-toolbar-btn", onClick: () => editor.chain().focus().addRowAfter().run() }, /* @__PURE__ */ React116.createElement(IconAddRowAfter, null))),
|
|
12545
|
+
/* @__PURE__ */ React116.createElement(Tooltip, { title: "Delete row", placement: "top" }, /* @__PURE__ */ React116.createElement("button", { className: "rf-table-toolbar-btn rf-table-toolbar-btn-danger", onClick: () => editor.chain().focus().deleteRow().run() }, /* @__PURE__ */ React116.createElement(IconDeleteRow, null))),
|
|
12546
|
+
/* @__PURE__ */ React116.createElement("span", { className: "rf-table-toolbar-sep" }),
|
|
12547
|
+
/* @__PURE__ */ React116.createElement(Tooltip, { title: "Insert column left", placement: "top" }, /* @__PURE__ */ React116.createElement("button", { className: "rf-table-toolbar-btn", onClick: () => editor.chain().focus().addColumnBefore().run() }, /* @__PURE__ */ React116.createElement(IconAddColBefore, null))),
|
|
12548
|
+
/* @__PURE__ */ React116.createElement(Tooltip, { title: "Insert column right", placement: "top" }, /* @__PURE__ */ React116.createElement("button", { className: "rf-table-toolbar-btn", onClick: () => editor.chain().focus().addColumnAfter().run() }, /* @__PURE__ */ React116.createElement(IconAddColAfter, null))),
|
|
12549
|
+
/* @__PURE__ */ React116.createElement(Tooltip, { title: "Delete column", placement: "top" }, /* @__PURE__ */ React116.createElement("button", { className: "rf-table-toolbar-btn rf-table-toolbar-btn-danger", onClick: () => editor.chain().focus().deleteColumn().run() }, /* @__PURE__ */ React116.createElement(IconDeleteCol, null))),
|
|
12550
|
+
/* @__PURE__ */ React116.createElement("span", { className: "rf-table-toolbar-sep" }),
|
|
12551
|
+
/* @__PURE__ */ React116.createElement(Tooltip, { title: "Merge cells", placement: "top" }, /* @__PURE__ */ React116.createElement("button", { className: "rf-table-toolbar-btn", onClick: () => editor.chain().focus().mergeCells().run(), disabled: !canMerge }, /* @__PURE__ */ React116.createElement(IconMergeCells, null))),
|
|
12552
|
+
/* @__PURE__ */ React116.createElement(Tooltip, { title: "Split cell", placement: "top" }, /* @__PURE__ */ React116.createElement("button", { className: "rf-table-toolbar-btn", onClick: () => editor.chain().focus().splitCell().run(), disabled: !canSplit }, /* @__PURE__ */ React116.createElement(IconSplitCell, null))),
|
|
12553
|
+
/* @__PURE__ */ React116.createElement("span", { className: "rf-table-toolbar-sep" }),
|
|
12554
|
+
/* @__PURE__ */ React116.createElement(Tooltip, { title: "Toggle header row", placement: "top" }, /* @__PURE__ */ React116.createElement("button", { className: `rf-table-toolbar-btn ${editor.isActive("tableHeader") ? "active" : ""}`, onClick: () => editor.chain().focus().toggleHeaderRow().run() }, /* @__PURE__ */ React116.createElement(IconToggleHeader, null))),
|
|
12555
|
+
/* @__PURE__ */ React116.createElement(Tooltip, { title: "Delete table", placement: "top" }, /* @__PURE__ */ React116.createElement("button", { className: "rf-table-toolbar-btn rf-table-toolbar-btn-danger", onClick: () => editor.chain().focus().deleteTable().run() }, /* @__PURE__ */ React116.createElement(IconDeleteTable, null)))
|
|
12033
12556
|
),
|
|
12034
12557
|
document.body
|
|
12035
12558
|
);
|
|
@@ -12204,12 +12727,12 @@ var RufousTextEditor = ({
|
|
|
12204
12727
|
return visible;
|
|
12205
12728
|
}, [buttons, variant, hideButtons]);
|
|
12206
12729
|
const mentionSuggestion = useMemo4(() => createMentionSuggestion(mentions), [mentions]);
|
|
12207
|
-
const onChangeRef =
|
|
12208
|
-
const onBlurRef =
|
|
12209
|
-
|
|
12730
|
+
const onChangeRef = useRef32(onChange);
|
|
12731
|
+
const onBlurRef = useRef32(onBlur);
|
|
12732
|
+
useEffect29(() => {
|
|
12210
12733
|
onChangeRef.current = onChange;
|
|
12211
12734
|
}, [onChange]);
|
|
12212
|
-
|
|
12735
|
+
useEffect29(() => {
|
|
12213
12736
|
onBlurRef.current = onBlur;
|
|
12214
12737
|
}, [onBlur]);
|
|
12215
12738
|
const isEditable = editable && !disabled;
|
|
@@ -12310,8 +12833,8 @@ var RufousTextEditor = ({
|
|
|
12310
12833
|
onChangeRef.current?.(e.getHTML(), e.getJSON());
|
|
12311
12834
|
}
|
|
12312
12835
|
});
|
|
12313
|
-
const wrapperRef =
|
|
12314
|
-
|
|
12836
|
+
const wrapperRef = useRef32(null);
|
|
12837
|
+
useEffect29(() => {
|
|
12315
12838
|
if (!editor) return;
|
|
12316
12839
|
let blurTimer = null;
|
|
12317
12840
|
const handler = ({ event }) => {
|
|
@@ -12329,15 +12852,15 @@ var RufousTextEditor = ({
|
|
|
12329
12852
|
if (blurTimer) clearTimeout(blurTimer);
|
|
12330
12853
|
};
|
|
12331
12854
|
}, [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 =
|
|
12855
|
+
const setLinkRef = useRef32(null);
|
|
12856
|
+
const [linkModalOpen, setLinkModalOpen] = useState35(false);
|
|
12857
|
+
const [linkUrl, setLinkUrl] = useState35("");
|
|
12858
|
+
const [linkText, setLinkText] = useState35("");
|
|
12859
|
+
const [linkClassName, setLinkClassName] = useState35("");
|
|
12860
|
+
const [linkNewTab, setLinkNewTab] = useState35(true);
|
|
12861
|
+
const [linkNoFollow, setLinkNoFollow] = useState35(true);
|
|
12862
|
+
const [linkSelection, setLinkSelection] = useState35(null);
|
|
12863
|
+
const setLink = useCallback15(() => {
|
|
12341
12864
|
if (!editor) return;
|
|
12342
12865
|
const attrs = editor.getAttributes("link");
|
|
12343
12866
|
const previousUrl = attrs.href || "";
|
|
@@ -12374,10 +12897,10 @@ var RufousTextEditor = ({
|
|
|
12374
12897
|
setLinkSelection({ from, to });
|
|
12375
12898
|
setLinkModalOpen(true);
|
|
12376
12899
|
}, [editor]);
|
|
12377
|
-
|
|
12900
|
+
useEffect29(() => {
|
|
12378
12901
|
setLinkRef.current = setLink;
|
|
12379
12902
|
}, [setLink]);
|
|
12380
|
-
|
|
12903
|
+
useEffect29(() => {
|
|
12381
12904
|
if (!editor?.view) return;
|
|
12382
12905
|
const handleKeyDown = (event) => {
|
|
12383
12906
|
if ((event.ctrlKey || event.metaKey) && event.key === "k") {
|
|
@@ -12409,7 +12932,7 @@ var RufousTextEditor = ({
|
|
|
12409
12932
|
editor.view.dom.removeEventListener("keydown", handleKeyDown);
|
|
12410
12933
|
};
|
|
12411
12934
|
}, [editor]);
|
|
12412
|
-
const handleLinkSubmit =
|
|
12935
|
+
const handleLinkSubmit = useCallback15(() => {
|
|
12413
12936
|
if (!editor || !linkSelection) return;
|
|
12414
12937
|
editor.chain().focus().setTextSelection(linkSelection).run();
|
|
12415
12938
|
if (linkUrl === "") {
|
|
@@ -12445,7 +12968,7 @@ var RufousTextEditor = ({
|
|
|
12445
12968
|
setLinkClassName("");
|
|
12446
12969
|
setLinkSelection(null);
|
|
12447
12970
|
}, [editor, linkUrl, linkText, linkClassName, linkNewTab, linkNoFollow, linkSelection]);
|
|
12448
|
-
const handleLinkRemove =
|
|
12971
|
+
const handleLinkRemove = useCallback15(() => {
|
|
12449
12972
|
if (!editor || !linkSelection) return;
|
|
12450
12973
|
editor.chain().focus().setTextSelection(linkSelection).extendMarkRange("link").unsetLink().run();
|
|
12451
12974
|
setLinkModalOpen(false);
|
|
@@ -12454,7 +12977,7 @@ var RufousTextEditor = ({
|
|
|
12454
12977
|
setLinkClassName("");
|
|
12455
12978
|
setLinkSelection(null);
|
|
12456
12979
|
}, [editor, linkSelection]);
|
|
12457
|
-
const handleLinkCancel =
|
|
12980
|
+
const handleLinkCancel = useCallback15(() => {
|
|
12458
12981
|
setLinkModalOpen(false);
|
|
12459
12982
|
setLinkUrl("");
|
|
12460
12983
|
setLinkText("");
|
|
@@ -12462,21 +12985,21 @@ var RufousTextEditor = ({
|
|
|
12462
12985
|
setLinkSelection(null);
|
|
12463
12986
|
editor?.chain().focus().run();
|
|
12464
12987
|
}, [editor]);
|
|
12465
|
-
const [saveStatus, setSaveStatus] =
|
|
12466
|
-
const handleSave =
|
|
12988
|
+
const [saveStatus, setSaveStatus] = useState35("");
|
|
12989
|
+
const handleSave = useCallback15(() => {
|
|
12467
12990
|
if (!editor || !onSaveProp) return;
|
|
12468
12991
|
onSaveProp(editor.getHTML(), editor.getJSON());
|
|
12469
12992
|
setSaveStatus("Saved!");
|
|
12470
12993
|
setTimeout(() => setSaveStatus(""), 2e3);
|
|
12471
12994
|
}, [editor, onSaveProp]);
|
|
12472
|
-
const handleExport =
|
|
12995
|
+
const handleExport = useCallback15(() => {
|
|
12473
12996
|
if (!editor || !onExportProp) return;
|
|
12474
12997
|
onExportProp(editor.getHTML(), editor.getJSON());
|
|
12475
12998
|
}, [editor, onExportProp]);
|
|
12476
12999
|
const providerValue = useMemo4(() => ({ editor }), [editor]);
|
|
12477
|
-
const [isFullscreen, setIsFullscreen] =
|
|
12478
|
-
const toggleFullscreen =
|
|
12479
|
-
const wrapperJsx = /* @__PURE__ */
|
|
13000
|
+
const [isFullscreen, setIsFullscreen] = useState35(false);
|
|
13001
|
+
const toggleFullscreen = useCallback15(() => setIsFullscreen((prev) => !prev), []);
|
|
13002
|
+
const wrapperJsx = /* @__PURE__ */ React117.createElement(
|
|
12480
13003
|
"div",
|
|
12481
13004
|
{
|
|
12482
13005
|
ref: wrapperRef,
|
|
@@ -12487,7 +13010,7 @@ var RufousTextEditor = ({
|
|
|
12487
13010
|
...height ? { height: typeof height === "number" ? `${height}px` : height } : {}
|
|
12488
13011
|
}
|
|
12489
13012
|
},
|
|
12490
|
-
/* @__PURE__ */
|
|
13013
|
+
/* @__PURE__ */ React117.createElement(EditorContext.Provider, { value: providerValue }, /* @__PURE__ */ React117.createElement(
|
|
12491
13014
|
Toolbar_default,
|
|
12492
13015
|
{
|
|
12493
13016
|
editor,
|
|
@@ -12502,7 +13025,7 @@ var RufousTextEditor = ({
|
|
|
12502
13025
|
isFullscreen,
|
|
12503
13026
|
onToggleFullscreen: toggleFullscreen
|
|
12504
13027
|
}
|
|
12505
|
-
), /* @__PURE__ */
|
|
13028
|
+
), /* @__PURE__ */ React117.createElement(EditorContent, { editor, className: "editor-content-wrapper" }), /* @__PURE__ */ React117.createElement(ImageToolbar_default, { editor }), /* @__PURE__ */ React117.createElement(VideoToolbar_default, { editor }), /* @__PURE__ */ React117.createElement(TableToolbar_default, { editor }), editor && /* @__PURE__ */ React117.createElement(
|
|
12506
13029
|
BubbleMenu,
|
|
12507
13030
|
{
|
|
12508
13031
|
editor,
|
|
@@ -12520,31 +13043,31 @@ var RufousTextEditor = ({
|
|
|
12520
13043
|
}
|
|
12521
13044
|
}
|
|
12522
13045
|
},
|
|
12523
|
-
/* @__PURE__ */
|
|
13046
|
+
/* @__PURE__ */ React117.createElement(
|
|
12524
13047
|
"button",
|
|
12525
13048
|
{
|
|
12526
13049
|
onClick: () => editor?.chain().focus().toggleBold().run(),
|
|
12527
13050
|
className: editor?.isActive("bold") ? "is-active" : ""
|
|
12528
13051
|
},
|
|
12529
|
-
/* @__PURE__ */
|
|
13052
|
+
/* @__PURE__ */ React117.createElement("strong", null, "B")
|
|
12530
13053
|
),
|
|
12531
|
-
/* @__PURE__ */
|
|
13054
|
+
/* @__PURE__ */ React117.createElement(
|
|
12532
13055
|
"button",
|
|
12533
13056
|
{
|
|
12534
13057
|
onClick: () => editor?.chain().focus().toggleItalic().run(),
|
|
12535
13058
|
className: editor?.isActive("italic") ? "is-active" : ""
|
|
12536
13059
|
},
|
|
12537
|
-
/* @__PURE__ */
|
|
13060
|
+
/* @__PURE__ */ React117.createElement("em", null, "I")
|
|
12538
13061
|
),
|
|
12539
|
-
/* @__PURE__ */
|
|
13062
|
+
/* @__PURE__ */ React117.createElement(
|
|
12540
13063
|
"button",
|
|
12541
13064
|
{
|
|
12542
13065
|
onClick: () => editor?.chain().focus().toggleStrike().run(),
|
|
12543
13066
|
className: editor?.isActive("strike") ? "is-active" : ""
|
|
12544
13067
|
},
|
|
12545
|
-
/* @__PURE__ */
|
|
13068
|
+
/* @__PURE__ */ React117.createElement("s", null, "S")
|
|
12546
13069
|
),
|
|
12547
|
-
/* @__PURE__ */
|
|
13070
|
+
/* @__PURE__ */ React117.createElement(
|
|
12548
13071
|
"button",
|
|
12549
13072
|
{
|
|
12550
13073
|
onClick: () => editor?.chain().focus().toggleCode().run(),
|
|
@@ -12552,7 +13075,7 @@ var RufousTextEditor = ({
|
|
|
12552
13075
|
},
|
|
12553
13076
|
"</>"
|
|
12554
13077
|
),
|
|
12555
|
-
/* @__PURE__ */
|
|
13078
|
+
/* @__PURE__ */ React117.createElement(
|
|
12556
13079
|
"button",
|
|
12557
13080
|
{
|
|
12558
13081
|
onClick: setLink,
|
|
@@ -12560,7 +13083,7 @@ var RufousTextEditor = ({
|
|
|
12560
13083
|
},
|
|
12561
13084
|
"\u{1F517}"
|
|
12562
13085
|
)
|
|
12563
|
-
), editor && /* @__PURE__ */
|
|
13086
|
+
), editor && /* @__PURE__ */ React117.createElement(
|
|
12564
13087
|
FloatingMenu,
|
|
12565
13088
|
{
|
|
12566
13089
|
editor,
|
|
@@ -12575,7 +13098,7 @@ var RufousTextEditor = ({
|
|
|
12575
13098
|
}
|
|
12576
13099
|
}
|
|
12577
13100
|
},
|
|
12578
|
-
/* @__PURE__ */
|
|
13101
|
+
/* @__PURE__ */ React117.createElement(
|
|
12579
13102
|
"button",
|
|
12580
13103
|
{
|
|
12581
13104
|
onClick: () => editor?.chain().focus().toggleHeading({ level: 1 }).run(),
|
|
@@ -12583,7 +13106,7 @@ var RufousTextEditor = ({
|
|
|
12583
13106
|
},
|
|
12584
13107
|
"H1"
|
|
12585
13108
|
),
|
|
12586
|
-
/* @__PURE__ */
|
|
13109
|
+
/* @__PURE__ */ React117.createElement(
|
|
12587
13110
|
"button",
|
|
12588
13111
|
{
|
|
12589
13112
|
onClick: () => editor?.chain().focus().toggleHeading({ level: 2 }).run(),
|
|
@@ -12591,7 +13114,7 @@ var RufousTextEditor = ({
|
|
|
12591
13114
|
},
|
|
12592
13115
|
"H2"
|
|
12593
13116
|
),
|
|
12594
|
-
/* @__PURE__ */
|
|
13117
|
+
/* @__PURE__ */ React117.createElement(
|
|
12595
13118
|
"button",
|
|
12596
13119
|
{
|
|
12597
13120
|
onClick: () => editor?.chain().focus().toggleBulletList().run(),
|
|
@@ -12599,7 +13122,7 @@ var RufousTextEditor = ({
|
|
|
12599
13122
|
},
|
|
12600
13123
|
"\u2022 List"
|
|
12601
13124
|
),
|
|
12602
|
-
/* @__PURE__ */
|
|
13125
|
+
/* @__PURE__ */ React117.createElement(
|
|
12603
13126
|
"button",
|
|
12604
13127
|
{
|
|
12605
13128
|
onClick: () => editor?.chain().focus().toggleOrderedList().run(),
|
|
@@ -12607,7 +13130,7 @@ var RufousTextEditor = ({
|
|
|
12607
13130
|
},
|
|
12608
13131
|
"1. List"
|
|
12609
13132
|
),
|
|
12610
|
-
/* @__PURE__ */
|
|
13133
|
+
/* @__PURE__ */ React117.createElement(
|
|
12611
13134
|
"button",
|
|
12612
13135
|
{
|
|
12613
13136
|
onClick: () => editor?.chain().focus().toggleBlockquote().run(),
|
|
@@ -12615,8 +13138,8 @@ var RufousTextEditor = ({
|
|
|
12615
13138
|
},
|
|
12616
13139
|
"\u201C Quote"
|
|
12617
13140
|
)
|
|
12618
|
-
), /* @__PURE__ */
|
|
12619
|
-
/* @__PURE__ */
|
|
13141
|
+
), /* @__PURE__ */ React117.createElement("div", { className: "status-bar" }, /* @__PURE__ */ React117.createElement("div", { className: "status-bar-left" }, onSaveProp && /* @__PURE__ */ React117.createElement("button", { onClick: handleSave, className: "status-btn save-btn" }, "Save"), onExportProp && /* @__PURE__ */ React117.createElement("button", { onClick: handleExport, className: "status-btn export-btn" }, "Export")), /* @__PURE__ */ React117.createElement("div", { className: "status-bar-right" }, saveStatus && /* @__PURE__ */ React117.createElement("span", { className: "save-status" }, saveStatus), editor && /* @__PURE__ */ React117.createElement(React117.Fragment, null, /* @__PURE__ */ React117.createElement("span", { className: "word-count" }, "CHARS: ", editor.storage.characterCount?.characters?.() ?? editor.getText().length), /* @__PURE__ */ React117.createElement("span", { className: "word-count" }, "WORDS: ", editor.storage.characterCount?.words?.() ?? editor.getText().split(/\s+/).filter(Boolean).length)))), linkModalOpen && createPortal8(
|
|
13142
|
+
/* @__PURE__ */ React117.createElement("div", { className: "link-modal-overlay", onClick: handleLinkCancel }, /* @__PURE__ */ React117.createElement("div", { className: "link-modal", onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ React117.createElement("div", { className: "link-modal-body" }, /* @__PURE__ */ React117.createElement("div", { className: "link-modal-field" }, /* @__PURE__ */ React117.createElement("label", { className: "link-modal-label" }, "URL"), /* @__PURE__ */ React117.createElement(
|
|
12620
13143
|
"input",
|
|
12621
13144
|
{
|
|
12622
13145
|
type: "url",
|
|
@@ -12629,7 +13152,7 @@ var RufousTextEditor = ({
|
|
|
12629
13152
|
placeholder: "https://example.com",
|
|
12630
13153
|
autoFocus: true
|
|
12631
13154
|
}
|
|
12632
|
-
)), /* @__PURE__ */
|
|
13155
|
+
)), /* @__PURE__ */ React117.createElement("div", { className: "link-modal-field" }, /* @__PURE__ */ React117.createElement("label", { className: "link-modal-label" }, "Text"), /* @__PURE__ */ React117.createElement(
|
|
12633
13156
|
"input",
|
|
12634
13157
|
{
|
|
12635
13158
|
type: "text",
|
|
@@ -12641,24 +13164,24 @@ var RufousTextEditor = ({
|
|
|
12641
13164
|
},
|
|
12642
13165
|
placeholder: "Link text"
|
|
12643
13166
|
}
|
|
12644
|
-
)), /* @__PURE__ */
|
|
13167
|
+
)), /* @__PURE__ */ React117.createElement("div", { className: "link-modal-checkboxes" }, /* @__PURE__ */ React117.createElement("label", { className: "link-modal-checkbox" }, /* @__PURE__ */ React117.createElement(
|
|
12645
13168
|
"input",
|
|
12646
13169
|
{
|
|
12647
13170
|
type: "checkbox",
|
|
12648
13171
|
checked: linkNewTab,
|
|
12649
13172
|
onChange: (e) => setLinkNewTab(e.target.checked)
|
|
12650
13173
|
}
|
|
12651
|
-
), "Open in new tab"), /* @__PURE__ */
|
|
13174
|
+
), "Open in new tab"), /* @__PURE__ */ React117.createElement("label", { className: "link-modal-checkbox" }, /* @__PURE__ */ React117.createElement(
|
|
12652
13175
|
"input",
|
|
12653
13176
|
{
|
|
12654
13177
|
type: "checkbox",
|
|
12655
13178
|
checked: linkNoFollow,
|
|
12656
13179
|
onChange: (e) => setLinkNoFollow(e.target.checked)
|
|
12657
13180
|
}
|
|
12658
|
-
), "No follow"))), /* @__PURE__ */
|
|
13181
|
+
), "No follow"))), /* @__PURE__ */ React117.createElement("div", { className: "link-modal-footer" }, /* @__PURE__ */ React117.createElement("button", { className: "link-modal-btn-unlink", onClick: handleLinkRemove }, "Unlink"), /* @__PURE__ */ React117.createElement("button", { className: "link-modal-btn-apply", onClick: handleLinkSubmit }, "Update")))),
|
|
12659
13182
|
document.body
|
|
12660
13183
|
)),
|
|
12661
|
-
helperText && /* @__PURE__ */
|
|
13184
|
+
helperText && /* @__PURE__ */ React117.createElement("div", { className: `rf-rte-helper-text ${error ? "rf-rte-helper-error" : ""}` }, helperText)
|
|
12662
13185
|
);
|
|
12663
13186
|
return isFullscreen ? createPortal8(wrapperJsx, document.body) : wrapperJsx;
|
|
12664
13187
|
};
|
|
@@ -12669,7 +13192,7 @@ var RufousTextContent = ({ content, className, style, sx }) => {
|
|
|
12669
13192
|
transformedContent = transformLegacyTodos(transformedContent);
|
|
12670
13193
|
} catch {
|
|
12671
13194
|
}
|
|
12672
|
-
return /* @__PURE__ */
|
|
13195
|
+
return /* @__PURE__ */ React117.createElement(
|
|
12673
13196
|
"div",
|
|
12674
13197
|
{
|
|
12675
13198
|
className: `rf-rte-content ${sxClass} ${className || ""}`,
|
|
@@ -12807,6 +13330,7 @@ export {
|
|
|
12807
13330
|
ToggleButtonGroup,
|
|
12808
13331
|
Tooltip,
|
|
12809
13332
|
trashIcon_default as TrashIcon,
|
|
13333
|
+
TreeSelect,
|
|
12810
13334
|
Typography,
|
|
12811
13335
|
unArchivedIcon_default as UnArchivedIcon,
|
|
12812
13336
|
unsubscribeIcon_default as UnsubscribeIcon,
|