@rufous/ui 0.3.11 → 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 +1191 -533
- package/dist/main.css +363 -22
- package/dist/main.d.cts +77 -1
- package/dist/main.d.ts +77 -1
- package/dist/main.js +1266 -604
- package/package.json +2 -2
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;
|
|
@@ -3040,6 +3095,24 @@ var SpinnerPanel = ({
|
|
|
3040
3095
|
},
|
|
3041
3096
|
"PM"
|
|
3042
3097
|
)));
|
|
3098
|
+
var formatViewsDisplay = (d, views) => {
|
|
3099
|
+
if (!views.includes("day") && !views.includes("month")) return String(d.getFullYear());
|
|
3100
|
+
if (!views.includes("day")) return `${MONTHS_SHORT[d.getMonth()]} ${d.getFullYear()}`;
|
|
3101
|
+
return "";
|
|
3102
|
+
};
|
|
3103
|
+
var parseYearDisplay = (str) => {
|
|
3104
|
+
const y = parseInt(str.trim(), 10);
|
|
3105
|
+
if (isNaN(y) || y < 1e3 || y > 9999) return null;
|
|
3106
|
+
return new Date(y, 0, 1);
|
|
3107
|
+
};
|
|
3108
|
+
var parseMonthYearDisplay = (str) => {
|
|
3109
|
+
const parts = str.trim().split(/\s+/);
|
|
3110
|
+
if (parts.length < 2) return null;
|
|
3111
|
+
const mm = parseMonthName(parts[0]);
|
|
3112
|
+
const yyyy = parseInt(parts[parts.length - 1], 10);
|
|
3113
|
+
if (mm < 0 || isNaN(yyyy) || yyyy < 1e3) return null;
|
|
3114
|
+
return new Date(yyyy, mm, 1);
|
|
3115
|
+
};
|
|
3043
3116
|
var CalendarBody = ({
|
|
3044
3117
|
viewMonth,
|
|
3045
3118
|
viewYear,
|
|
@@ -3052,18 +3125,48 @@ var CalendarBody = ({
|
|
|
3052
3125
|
onMonthSelect,
|
|
3053
3126
|
onYearSelect,
|
|
3054
3127
|
minDate,
|
|
3055
|
-
maxDate
|
|
3128
|
+
maxDate,
|
|
3129
|
+
views,
|
|
3130
|
+
onFinalMonthSelect,
|
|
3131
|
+
onFinalYearSelect
|
|
3056
3132
|
}) => {
|
|
3057
|
-
const
|
|
3058
|
-
const
|
|
3059
|
-
const
|
|
3133
|
+
const hasDayView = views.includes("day");
|
|
3134
|
+
const hasMonthView = views.includes("month");
|
|
3135
|
+
const hasYearView = views.includes("year");
|
|
3136
|
+
const [pickerView, setPickerView] = useState7(() => {
|
|
3137
|
+
if (!hasDayView && !hasMonthView) return "year";
|
|
3138
|
+
if (!hasDayView) return "month";
|
|
3139
|
+
return "calendar";
|
|
3140
|
+
});
|
|
3141
|
+
const handleMonthClick = () => {
|
|
3142
|
+
if (!hasMonthView || !hasDayView) return;
|
|
3143
|
+
setPickerView((v) => v === "month" ? "calendar" : "month");
|
|
3144
|
+
};
|
|
3145
|
+
const handleYearClick = () => {
|
|
3146
|
+
if (!hasYearView) return;
|
|
3147
|
+
if (pickerView === "year") {
|
|
3148
|
+
setPickerView(hasDayView ? "calendar" : "month");
|
|
3149
|
+
} else {
|
|
3150
|
+
setPickerView("year");
|
|
3151
|
+
}
|
|
3152
|
+
};
|
|
3060
3153
|
const handleMonthPick = (month) => {
|
|
3061
3154
|
onMonthSelect(month);
|
|
3062
|
-
|
|
3155
|
+
if (hasDayView) {
|
|
3156
|
+
setPickerView("calendar");
|
|
3157
|
+
} else {
|
|
3158
|
+
onFinalMonthSelect?.(month, viewYear);
|
|
3159
|
+
}
|
|
3063
3160
|
};
|
|
3064
3161
|
const handleYearPick = (year) => {
|
|
3065
3162
|
onYearSelect(year);
|
|
3066
|
-
|
|
3163
|
+
if (!hasDayView && !hasMonthView) {
|
|
3164
|
+
onFinalYearSelect?.(year);
|
|
3165
|
+
} else if (hasMonthView) {
|
|
3166
|
+
setPickerView("month");
|
|
3167
|
+
} else {
|
|
3168
|
+
setPickerView("calendar");
|
|
3169
|
+
}
|
|
3067
3170
|
};
|
|
3068
3171
|
const currentYear = todayDate.getFullYear();
|
|
3069
3172
|
const yearStart = viewYear - 6;
|
|
@@ -3087,18 +3190,35 @@ var CalendarBody = ({
|
|
|
3087
3190
|
return /* @__PURE__ */ React72.createElement(React72.Fragment, null, /* @__PURE__ */ React72.createElement("div", { className: "rf-date-picker__header" }, /* @__PURE__ */ React72.createElement("div", { className: "rf-date-picker__header-labels" }, /* @__PURE__ */ React72.createElement(
|
|
3088
3191
|
"span",
|
|
3089
3192
|
{
|
|
3090
|
-
className:
|
|
3193
|
+
className: [
|
|
3194
|
+
"rf-date-picker__month-label",
|
|
3195
|
+
pickerView === "month" ? "rf-date-picker__month-label--active" : "",
|
|
3196
|
+
!hasMonthView || !hasDayView ? "rf-date-picker__label--static" : ""
|
|
3197
|
+
].filter(Boolean).join(" "),
|
|
3091
3198
|
onClick: handleMonthClick
|
|
3092
3199
|
},
|
|
3093
3200
|
MONTHS[viewMonth]
|
|
3094
3201
|
), /* @__PURE__ */ React72.createElement(
|
|
3095
3202
|
"span",
|
|
3096
3203
|
{
|
|
3097
|
-
className:
|
|
3204
|
+
className: [
|
|
3205
|
+
"rf-date-picker__year-label",
|
|
3206
|
+
pickerView === "year" ? "rf-date-picker__year-label--active" : "",
|
|
3207
|
+
!hasYearView ? "rf-date-picker__label--static" : ""
|
|
3208
|
+
].filter(Boolean).join(" "),
|
|
3098
3209
|
onClick: handleYearClick
|
|
3099
3210
|
},
|
|
3100
3211
|
viewYear
|
|
3101
|
-
)), /* @__PURE__ */ React72.createElement("div", { className: "rf-date-picker__nav" }, pickerView === "year" ?
|
|
3212
|
+
)), /* @__PURE__ */ React72.createElement("div", { className: "rf-date-picker__nav" }, pickerView === "year" ? (
|
|
3213
|
+
// Year page navigation
|
|
3214
|
+
/* @__PURE__ */ React72.createElement(React72.Fragment, null, /* @__PURE__ */ React72.createElement("button", { type: "button", className: "rf-date-picker__nav-btn", onClick: () => onYearSelect(viewYear - 16), "aria-label": "Previous years" }, "\u2039"), /* @__PURE__ */ React72.createElement("button", { type: "button", className: "rf-date-picker__nav-btn", onClick: () => onYearSelect(viewYear + 16), "aria-label": "Next years" }, "\u203A"))
|
|
3215
|
+
) : pickerView === "month" && !hasDayView ? (
|
|
3216
|
+
// Month-only or month+year mode: ‹ › change year
|
|
3217
|
+
/* @__PURE__ */ React72.createElement(React72.Fragment, null, /* @__PURE__ */ React72.createElement("button", { type: "button", className: "rf-date-picker__nav-btn", onClick: () => onYearSelect(viewYear - 1), "aria-label": "Previous year" }, "\u2039"), /* @__PURE__ */ React72.createElement("button", { type: "button", className: "rf-date-picker__nav-btn", onClick: () => onYearSelect(viewYear + 1), "aria-label": "Next year" }, "\u203A"))
|
|
3218
|
+
) : (
|
|
3219
|
+
// Normal month navigation
|
|
3220
|
+
/* @__PURE__ */ React72.createElement(React72.Fragment, null, /* @__PURE__ */ React72.createElement("button", { type: "button", className: "rf-date-picker__nav-btn", onClick: onPrev, disabled: isPrevDisabled, "aria-label": "Previous month" }, "\u2039"), /* @__PURE__ */ React72.createElement("button", { type: "button", className: "rf-date-picker__nav-btn", onClick: onNext, disabled: isNextDisabled, "aria-label": "Next month" }, "\u203A"))
|
|
3221
|
+
))), pickerView === "month" && /* @__PURE__ */ React72.createElement("div", { className: "rf-date-picker__month-grid" }, MONTHS_SHORT.map((m, idx) => {
|
|
3102
3222
|
const monthDisabled = isMonthDisabled(idx);
|
|
3103
3223
|
return /* @__PURE__ */ React72.createElement(
|
|
3104
3224
|
"button",
|
|
@@ -3134,7 +3254,7 @@ var CalendarBody = ({
|
|
|
3134
3254
|
},
|
|
3135
3255
|
y
|
|
3136
3256
|
);
|
|
3137
|
-
})), pickerView === "calendar" && /* @__PURE__ */ React72.createElement(React72.Fragment, null, /* @__PURE__ */ React72.createElement("div", { className: "rf-date-picker__weekdays" }, WEEKDAYS.map((w) => /* @__PURE__ */ React72.createElement("div", { key: w, className: "rf-date-picker__weekday" }, w))), /* @__PURE__ */ React72.createElement("div", { className: "rf-date-picker__grid" }, dayCells.map((day, idx) => {
|
|
3257
|
+
})), pickerView === "calendar" && hasDayView && /* @__PURE__ */ React72.createElement(React72.Fragment, null, /* @__PURE__ */ React72.createElement("div", { className: "rf-date-picker__weekdays" }, WEEKDAYS.map((w) => /* @__PURE__ */ React72.createElement("div", { key: w, className: "rf-date-picker__weekday" }, w))), /* @__PURE__ */ React72.createElement("div", { className: "rf-date-picker__grid" }, dayCells.map((day, idx) => {
|
|
3138
3258
|
if (day === null) return /* @__PURE__ */ React72.createElement("div", { key: `e-${idx}`, className: "rf-date-picker__day rf-date-picker__day--empty" });
|
|
3139
3259
|
const cellDate = new Date(viewYear, viewMonth, day);
|
|
3140
3260
|
const isSelected = selectedDate ? isSameDay(cellDate, selectedDate) : false;
|
|
@@ -3177,8 +3297,12 @@ var DateField = ({
|
|
|
3177
3297
|
placeholder,
|
|
3178
3298
|
className = "",
|
|
3179
3299
|
style,
|
|
3180
|
-
sx
|
|
3300
|
+
sx,
|
|
3301
|
+
views: viewsProp
|
|
3181
3302
|
}) => {
|
|
3303
|
+
const views = viewsProp ?? ["day", "month", "year"];
|
|
3304
|
+
const hasDayView = views.includes("day");
|
|
3305
|
+
const hasMonthView = views.includes("month");
|
|
3182
3306
|
const minDate = normaliseBoundary(minDateProp);
|
|
3183
3307
|
const maxDate = normaliseBoundary(maxDateProp);
|
|
3184
3308
|
const sxClass = useSx(sx);
|
|
@@ -3208,6 +3332,8 @@ var DateField = ({
|
|
|
3208
3332
|
if (!value) return "";
|
|
3209
3333
|
const d = isoToDate(value);
|
|
3210
3334
|
if (!d) return "";
|
|
3335
|
+
const viewsStr = formatViewsDisplay(d, views);
|
|
3336
|
+
if (viewsStr) return viewsStr;
|
|
3211
3337
|
let str = formatDisplay(d, dateFormat);
|
|
3212
3338
|
if (isDatetimeType(type)) {
|
|
3213
3339
|
const t = parseTimeFromISO(value);
|
|
@@ -3218,10 +3344,10 @@ var DateField = ({
|
|
|
3218
3344
|
const HOURS = Array.from({ length: 12 }, (_, i) => String(i + 1).padStart(2, "0"));
|
|
3219
3345
|
const MINUTES = Array.from({ length: 60 }, (_, i) => String(i).padStart(2, "0"));
|
|
3220
3346
|
const AMPMS = ["AM", "PM"];
|
|
3221
|
-
const containerRef =
|
|
3222
|
-
const pickerRef =
|
|
3223
|
-
const inputId =
|
|
3224
|
-
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);
|
|
3225
3351
|
useEffect7(() => {
|
|
3226
3352
|
if (value === void 0) return;
|
|
3227
3353
|
if (isInternalChange.current) {
|
|
@@ -3238,15 +3364,20 @@ var DateField = ({
|
|
|
3238
3364
|
if (d) {
|
|
3239
3365
|
setViewYear(d.getFullYear());
|
|
3240
3366
|
setViewMonth(d.getMonth());
|
|
3241
|
-
|
|
3242
|
-
if (
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3367
|
+
const viewsStr = formatViewsDisplay(d, views);
|
|
3368
|
+
if (viewsStr) {
|
|
3369
|
+
setInputStr(viewsStr);
|
|
3370
|
+
} else {
|
|
3371
|
+
let str = formatDisplay(d, dateFormat);
|
|
3372
|
+
if (isDatetimeType(type)) {
|
|
3373
|
+
const t = parseTimeFromISO(value);
|
|
3374
|
+
setHour(t.h);
|
|
3375
|
+
setMinute(t.m);
|
|
3376
|
+
setAmpm(t.ampm);
|
|
3377
|
+
str += " " + formatTimeDisplay(t.h, t.m, t.ampm);
|
|
3378
|
+
}
|
|
3379
|
+
setInputStr(str);
|
|
3248
3380
|
}
|
|
3249
|
-
setInputStr(str);
|
|
3250
3381
|
}
|
|
3251
3382
|
}, [value, type]);
|
|
3252
3383
|
useEffect7(() => {
|
|
@@ -3257,21 +3388,37 @@ var DateField = ({
|
|
|
3257
3388
|
if (pickerRef.current?.contains(target)) return;
|
|
3258
3389
|
setOpen(false);
|
|
3259
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
|
+
};
|
|
3260
3397
|
document.addEventListener("mousedown", handler);
|
|
3261
|
-
|
|
3398
|
+
document.addEventListener("focusout", handleFocusOut);
|
|
3399
|
+
return () => {
|
|
3400
|
+
document.removeEventListener("mousedown", handler);
|
|
3401
|
+
document.removeEventListener("focusout", handleFocusOut);
|
|
3402
|
+
};
|
|
3262
3403
|
}, [open]);
|
|
3263
|
-
const commitDate =
|
|
3404
|
+
const commitDate = useCallback4((d, h, m, ap) => {
|
|
3264
3405
|
setSelectedDate(d);
|
|
3265
3406
|
if (!d) {
|
|
3266
3407
|
setInputStr("");
|
|
3267
3408
|
onChange?.("");
|
|
3268
3409
|
return;
|
|
3269
3410
|
}
|
|
3270
|
-
|
|
3271
|
-
|
|
3411
|
+
const viewsStr = formatViewsDisplay(d, views);
|
|
3412
|
+
let str;
|
|
3413
|
+
if (viewsStr) {
|
|
3414
|
+
str = viewsStr;
|
|
3415
|
+
} else {
|
|
3416
|
+
str = formatDisplay(d, dateFormat);
|
|
3417
|
+
if (isDatetimeType(type)) str += " " + formatTimeDisplay(h, m, ap);
|
|
3418
|
+
}
|
|
3272
3419
|
setInputStr(str);
|
|
3273
3420
|
onChange?.(buildISO(d, type, h, m, ap));
|
|
3274
|
-
}, [type, onChange, dateFormat]);
|
|
3421
|
+
}, [type, onChange, dateFormat, views]);
|
|
3275
3422
|
const isOutOfRange = (d) => (minDate ? isBeforeDay(d, minDate) : false) || (maxDate ? isAfterDay(d, maxDate) : false);
|
|
3276
3423
|
const handleDayClick = (day) => {
|
|
3277
3424
|
const d = new Date(viewYear, viewMonth, day);
|
|
@@ -3285,49 +3432,102 @@ var DateField = ({
|
|
|
3285
3432
|
};
|
|
3286
3433
|
const handleToday = () => {
|
|
3287
3434
|
const t = today();
|
|
3288
|
-
if (
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3435
|
+
if (!hasDayView && !hasMonthView) {
|
|
3436
|
+
const d = new Date(t.getFullYear(), 0, 1);
|
|
3437
|
+
if (isOutOfRange(d)) return;
|
|
3438
|
+
setViewYear(t.getFullYear());
|
|
3439
|
+
commitDate(d, hour, minute, ampm);
|
|
3440
|
+
setOpen(false);
|
|
3441
|
+
} else if (!hasDayView) {
|
|
3442
|
+
const d = new Date(t.getFullYear(), t.getMonth(), 1);
|
|
3443
|
+
if (isOutOfRange(d)) return;
|
|
3444
|
+
setViewYear(t.getFullYear());
|
|
3445
|
+
setViewMonth(t.getMonth());
|
|
3446
|
+
commitDate(d, hour, minute, ampm);
|
|
3447
|
+
setOpen(false);
|
|
3448
|
+
} else {
|
|
3449
|
+
if (isOutOfRange(t)) return;
|
|
3450
|
+
setViewYear(t.getFullYear());
|
|
3451
|
+
setViewMonth(t.getMonth());
|
|
3452
|
+
commitDate(t, hour, minute, ampm);
|
|
3453
|
+
if (type === "date") setOpen(false);
|
|
3454
|
+
}
|
|
3293
3455
|
};
|
|
3456
|
+
const handleFinalMonthSelect = useCallback4((month, year) => {
|
|
3457
|
+
const d = new Date(year, month, 1);
|
|
3458
|
+
if (isOutOfRange(d)) return;
|
|
3459
|
+
setSelectedDate(d);
|
|
3460
|
+
setViewYear(year);
|
|
3461
|
+
setViewMonth(month);
|
|
3462
|
+
setInputStr(`${MONTHS_SHORT[month]} ${year}`);
|
|
3463
|
+
onChange?.(buildISO(d, type, hour, minute, ampm));
|
|
3464
|
+
setOpen(false);
|
|
3465
|
+
}, [isOutOfRange, onChange, type, hour, minute, ampm]);
|
|
3466
|
+
const handleFinalYearSelect = useCallback4((year) => {
|
|
3467
|
+
const d = new Date(year, 0, 1);
|
|
3468
|
+
if (isOutOfRange(d)) return;
|
|
3469
|
+
setSelectedDate(d);
|
|
3470
|
+
setViewYear(year);
|
|
3471
|
+
setInputStr(String(year));
|
|
3472
|
+
onChange?.(buildISO(d, type, hour, minute, ampm));
|
|
3473
|
+
setOpen(false);
|
|
3474
|
+
}, [isOutOfRange, onChange, type, hour, minute, ampm]);
|
|
3294
3475
|
const handleClear = () => commitDate(null, hour, minute, ampm);
|
|
3295
3476
|
const handleInputChange = (e) => {
|
|
3296
3477
|
const raw = e.target.value;
|
|
3297
3478
|
setInputStr(raw);
|
|
3298
|
-
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3306
|
-
|
|
3307
|
-
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3317
|
-
|
|
3479
|
+
let parsed = null;
|
|
3480
|
+
if (!hasDayView && !hasMonthView) {
|
|
3481
|
+
parsed = parseYearDisplay(raw);
|
|
3482
|
+
} else if (!hasDayView) {
|
|
3483
|
+
parsed = parseMonthYearDisplay(raw);
|
|
3484
|
+
} else {
|
|
3485
|
+
const dateWordCount = getDateWordCount(dateFormat);
|
|
3486
|
+
const words = raw.split(" ");
|
|
3487
|
+
const datePart = words.slice(0, dateWordCount).join(" ");
|
|
3488
|
+
const timeParts = words.slice(dateWordCount);
|
|
3489
|
+
parsed = parseDisplay(datePart, dateFormat);
|
|
3490
|
+
if (parsed && !isOutOfRange(parsed)) {
|
|
3491
|
+
setSelectedDate(parsed);
|
|
3492
|
+
setViewYear(parsed.getFullYear());
|
|
3493
|
+
setViewMonth(parsed.getMonth());
|
|
3494
|
+
let h = hour, m = minute, ap = ampm;
|
|
3495
|
+
if (isDatetimeType(type) && timeParts.length >= 2) {
|
|
3496
|
+
const timePart = timeParts[0];
|
|
3497
|
+
const periodPart = timeParts[1]?.toUpperCase();
|
|
3498
|
+
if (timePart?.includes(":")) {
|
|
3499
|
+
const [hStr, mStr] = timePart.split(":");
|
|
3500
|
+
const parsedH = parseInt(hStr, 10);
|
|
3501
|
+
const parsedM = parseInt(mStr, 10);
|
|
3502
|
+
if (!isNaN(parsedH) && parsedH >= 1 && parsedH <= 12) {
|
|
3503
|
+
h = parsedH;
|
|
3504
|
+
setHour(h);
|
|
3505
|
+
}
|
|
3506
|
+
if (!isNaN(parsedM) && parsedM >= 0 && parsedM <= 59) {
|
|
3507
|
+
m = parsedM;
|
|
3508
|
+
setMinute(m);
|
|
3509
|
+
}
|
|
3318
3510
|
}
|
|
3319
|
-
if (
|
|
3320
|
-
|
|
3321
|
-
|
|
3511
|
+
if (periodPart === "AM" || periodPart === "PM") {
|
|
3512
|
+
ap = periodPart;
|
|
3513
|
+
setAmpm(ap);
|
|
3322
3514
|
}
|
|
3323
3515
|
}
|
|
3324
|
-
|
|
3325
|
-
|
|
3326
|
-
|
|
3327
|
-
|
|
3516
|
+
isInternalChange.current = true;
|
|
3517
|
+
onChange?.(buildISO(parsed, type, h, m, ap));
|
|
3518
|
+
} else if (!raw) {
|
|
3519
|
+
setSelectedDate(null);
|
|
3520
|
+
isInternalChange.current = true;
|
|
3521
|
+
onChange?.("");
|
|
3328
3522
|
}
|
|
3523
|
+
return;
|
|
3524
|
+
}
|
|
3525
|
+
if (parsed && !isOutOfRange(parsed)) {
|
|
3526
|
+
setSelectedDate(parsed);
|
|
3527
|
+
setViewYear(parsed.getFullYear());
|
|
3528
|
+
setViewMonth(parsed.getMonth());
|
|
3329
3529
|
isInternalChange.current = true;
|
|
3330
|
-
onChange?.(buildISO(parsed, type,
|
|
3530
|
+
onChange?.(buildISO(parsed, type, hour, minute, ampm));
|
|
3331
3531
|
} else if (!raw) {
|
|
3332
3532
|
setSelectedDate(null);
|
|
3333
3533
|
isInternalChange.current = true;
|
|
@@ -3513,7 +3713,10 @@ var DateField = ({
|
|
|
3513
3713
|
onMonthSelect: setViewMonth,
|
|
3514
3714
|
onYearSelect: setViewYear,
|
|
3515
3715
|
minDate,
|
|
3516
|
-
maxDate
|
|
3716
|
+
maxDate,
|
|
3717
|
+
views,
|
|
3718
|
+
onFinalMonthSelect: handleFinalMonthSelect,
|
|
3719
|
+
onFinalYearSelect: handleFinalYearSelect
|
|
3517
3720
|
}
|
|
3518
3721
|
), type === "datetime" && /* @__PURE__ */ React72.createElement("div", { className: "rf-date-picker__time-section" }, /* @__PURE__ */ React72.createElement("div", { className: "rf-date-picker__time-label" }, "Time"), /* @__PURE__ */ React72.createElement(
|
|
3519
3722
|
SpinnerPanel,
|
|
@@ -3573,7 +3776,7 @@ DateField.displayName = "DateField";
|
|
|
3573
3776
|
// lib/TextFields/DateRangeField.tsx
|
|
3574
3777
|
import React73, {
|
|
3575
3778
|
useState as useState8,
|
|
3576
|
-
useRef as
|
|
3779
|
+
useRef as useRef8,
|
|
3577
3780
|
useEffect as useEffect8
|
|
3578
3781
|
} from "react";
|
|
3579
3782
|
var WEEKDAYS2 = ["SU", "MO", "TU", "WE", "TH", "FR", "SA"];
|
|
@@ -3868,8 +4071,8 @@ var DateRangeField = ({
|
|
|
3868
4071
|
const [selecting, setSelecting] = useState8("start");
|
|
3869
4072
|
const [leftViewYear, setLeftViewYear] = useState8(() => today2.getFullYear());
|
|
3870
4073
|
const [leftViewMonth, setLeftViewMonth] = useState8(() => today2.getMonth());
|
|
3871
|
-
const containerRef =
|
|
3872
|
-
const inputId =
|
|
4074
|
+
const containerRef = useRef8(null);
|
|
4075
|
+
const inputId = useRef8(`rf-dr-${Math.random().toString(36).substr(2, 9)}`).current;
|
|
3873
4076
|
useEffect8(() => {
|
|
3874
4077
|
const s2 = value?.start ? isoToDate2(value.start) : null;
|
|
3875
4078
|
const e = value?.end ? isoToDate2(value.end) : null;
|
|
@@ -4251,7 +4454,7 @@ var RufousLogoLoader = ({ size = 80, sx, className }) => {
|
|
|
4251
4454
|
};
|
|
4252
4455
|
|
|
4253
4456
|
// lib/DataGrid/DataGrid.tsx
|
|
4254
|
-
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";
|
|
4255
4458
|
import {
|
|
4256
4459
|
ChevronUp,
|
|
4257
4460
|
ChevronDown,
|
|
@@ -4270,6 +4473,37 @@ import {
|
|
|
4270
4473
|
Trash2,
|
|
4271
4474
|
Plus
|
|
4272
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
|
+
}
|
|
4273
4507
|
var getOperatorsForType = (type) => {
|
|
4274
4508
|
if (type === "date") return [
|
|
4275
4509
|
{ value: "is", label: "is" },
|
|
@@ -4386,7 +4620,7 @@ function DataGrid({
|
|
|
4386
4620
|
const [startWidth, setStartWidth] = useState9(0);
|
|
4387
4621
|
const [activeMenu, setActiveMenu] = useState9(null);
|
|
4388
4622
|
const [menuPosition, setMenuPosition] = useState9({ top: 0, left: 0 });
|
|
4389
|
-
const menuRef =
|
|
4623
|
+
const menuRef = useRef10(null);
|
|
4390
4624
|
const [showManageColumns, setShowManageColumns] = useState9(false);
|
|
4391
4625
|
const [showAdvancedFilter, setShowAdvancedFilter] = useState9(false);
|
|
4392
4626
|
const filterableColumnsProp = initialColumnsProp.filter((c) => c.filterable !== false);
|
|
@@ -4687,7 +4921,17 @@ function DataGrid({
|
|
|
4687
4921
|
}
|
|
4688
4922
|
return offset2;
|
|
4689
4923
|
};
|
|
4690
|
-
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
|
+
};
|
|
4691
4935
|
const activeMenuCol = activeMenu ? resolvedColumns.find((c) => String(c.field) === activeMenu) : null;
|
|
4692
4936
|
const alignClass = (align) => align === "center" ? "dg-slot--center" : align === "right" ? "dg-slot--right" : "dg-slot--left";
|
|
4693
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(
|
|
@@ -4721,6 +4965,7 @@ function DataGrid({
|
|
|
4721
4965
|
const leftOffset = getLeftOffset(col, idx);
|
|
4722
4966
|
const rightOffset = getRightOffset(col, idx);
|
|
4723
4967
|
const isSorted = sortField === col.field;
|
|
4968
|
+
const isFiltered = advancedFilters.some((f) => f.column === colField && f.value);
|
|
4724
4969
|
return /* @__PURE__ */ React75.createElement(
|
|
4725
4970
|
"th",
|
|
4726
4971
|
{
|
|
@@ -4737,7 +4982,7 @@ function DataGrid({
|
|
|
4737
4982
|
col.headerName,
|
|
4738
4983
|
isSorted && sortDirection === "asc" && /* @__PURE__ */ React75.createElement(ChevronUp, { size: 12 }),
|
|
4739
4984
|
isSorted && sortDirection === "desc" && /* @__PURE__ */ React75.createElement(ChevronDown, { size: 12 })
|
|
4740
|
-
), /* @__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(
|
|
4741
4986
|
"button",
|
|
4742
4987
|
{
|
|
4743
4988
|
className: "dg-th-menu-btn",
|
|
@@ -4830,12 +5075,14 @@ function DataGrid({
|
|
|
4830
5075
|
action.icon
|
|
4831
5076
|
)))));
|
|
4832
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(
|
|
4833
|
-
|
|
5078
|
+
FilterSelect,
|
|
4834
5079
|
{
|
|
4835
|
-
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
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
|
+
}
|
|
4839
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(
|
|
4840
5087
|
"div",
|
|
4841
5088
|
{
|
|
@@ -4855,6 +5102,16 @@ function DataGrid({
|
|
|
4855
5102
|
})(),
|
|
4856
5103
|
/* @__PURE__ */ React75.createElement("div", { className: "dg-menu-divider" }),
|
|
4857
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
|
+
}
|
|
4858
5115
|
setShowAdvancedFilter(true);
|
|
4859
5116
|
setActiveMenu(null);
|
|
4860
5117
|
} }, /* @__PURE__ */ React75.createElement(Filter, { size: 14 }), " Filter\u2026"),
|
|
@@ -4892,7 +5149,7 @@ function DataGrid({
|
|
|
4892
5149
|
}
|
|
4893
5150
|
});
|
|
4894
5151
|
setColumnOverrides(newOverrides);
|
|
4895
|
-
} }, "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(
|
|
4896
5153
|
"button",
|
|
4897
5154
|
{
|
|
4898
5155
|
className: `dg-logic-btn${f.logic === "AND" ? " active" : ""}`,
|
|
@@ -4907,48 +5164,45 @@ function DataGrid({
|
|
|
4907
5164
|
},
|
|
4908
5165
|
"OR"
|
|
4909
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(
|
|
4910
|
-
|
|
5167
|
+
FilterSelect,
|
|
4911
5168
|
{
|
|
4912
|
-
className: "dg-filter-select",
|
|
4913
5169
|
value: f.column,
|
|
4914
|
-
onChange: (
|
|
4915
|
-
const newColKey = e.target.value;
|
|
5170
|
+
onChange: (newColKey) => {
|
|
4916
5171
|
const newCol = resolvedColumns.find((c) => String(c.key) === newColKey);
|
|
4917
5172
|
const defaultOp = getDefaultOperator(newCol?.type);
|
|
4918
5173
|
setAdvancedFilters((p) => p.map((fi, i) => i === idx ? { ...fi, column: newColKey, operator: defaultOp, value: "" } : fi));
|
|
4919
|
-
}
|
|
4920
|
-
|
|
4921
|
-
|
|
5174
|
+
},
|
|
5175
|
+
options: resolvedColumns.filter((c) => c.filterable !== false).map((c) => ({ value: String(c.key), label: c.header }))
|
|
5176
|
+
}
|
|
4922
5177
|
), (() => {
|
|
4923
5178
|
const col = resolvedColumns.find((c) => String(c.key) === f.column);
|
|
4924
5179
|
const operators = getOperatorsForType(col?.type);
|
|
4925
5180
|
const hideValue = f.operator === "is empty" || f.operator === "is not empty";
|
|
4926
5181
|
return /* @__PURE__ */ React75.createElement(React75.Fragment, null, /* @__PURE__ */ React75.createElement(
|
|
4927
|
-
|
|
5182
|
+
FilterSelect,
|
|
4928
5183
|
{
|
|
4929
|
-
className: "dg-
|
|
5184
|
+
className: "dg-fsel--sm",
|
|
4930
5185
|
value: f.operator,
|
|
4931
|
-
onChange: (
|
|
4932
|
-
|
|
4933
|
-
|
|
5186
|
+
onChange: (val) => setAdvancedFilters((p) => p.map((fi, i) => i === idx ? { ...fi, operator: val, value: "" } : fi)),
|
|
5187
|
+
options: operators
|
|
5188
|
+
}
|
|
4934
5189
|
), !hideValue && col?.type === "date" && /* @__PURE__ */ React75.createElement("div", { className: "dg-filter-datefield" }, /* @__PURE__ */ React75.createElement(
|
|
4935
5190
|
DateField,
|
|
4936
5191
|
{
|
|
4937
5192
|
value: f.value,
|
|
4938
5193
|
onChange: (val) => setAdvancedFilters((p) => p.map((fi, i) => i === idx ? { ...fi, value: val } : fi)),
|
|
4939
|
-
variant: "compact"
|
|
5194
|
+
variant: "compact",
|
|
5195
|
+
fullWidth: true
|
|
4940
5196
|
}
|
|
4941
5197
|
)), !hideValue && col?.type === "status" && (() => {
|
|
4942
|
-
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();
|
|
4943
5199
|
return /* @__PURE__ */ React75.createElement(
|
|
4944
|
-
|
|
5200
|
+
FilterSelect,
|
|
4945
5201
|
{
|
|
4946
|
-
className: "dg-filter-select",
|
|
4947
5202
|
value: f.value,
|
|
4948
|
-
onChange: (
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
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
|
+
}
|
|
4952
5206
|
);
|
|
4953
5207
|
})(), !hideValue && col?.type !== "date" && col?.type !== "status" && /* @__PURE__ */ React75.createElement(
|
|
4954
5208
|
"input",
|
|
@@ -4957,6 +5211,7 @@ function DataGrid({
|
|
|
4957
5211
|
className: "dg-filter-input",
|
|
4958
5212
|
placeholder: "Value\u2026",
|
|
4959
5213
|
value: f.value,
|
|
5214
|
+
autoFocus: idx === advancedFilters.length - 1,
|
|
4960
5215
|
onChange: (e) => setAdvancedFilters((p) => p.map((fi, i) => i === idx ? { ...fi, value: e.target.value } : fi))
|
|
4961
5216
|
}
|
|
4962
5217
|
));
|
|
@@ -4986,15 +5241,15 @@ function DataGrid({
|
|
|
4986
5241
|
},
|
|
4987
5242
|
/* @__PURE__ */ React75.createElement(Trash2, { size: 14 }),
|
|
4988
5243
|
" Reset"
|
|
4989
|
-
), /* @__PURE__ */ React75.createElement("button", { className: "submit-btn", onClick:
|
|
5244
|
+
), /* @__PURE__ */ React75.createElement("button", { className: "submit-btn", onClick: closeFilterModal }, "Apply")))));
|
|
4990
5245
|
}
|
|
4991
5246
|
|
|
4992
5247
|
// lib/Select/Select.tsx
|
|
4993
5248
|
import React76, {
|
|
4994
5249
|
useState as useState10,
|
|
4995
|
-
useRef as
|
|
5250
|
+
useRef as useRef11,
|
|
4996
5251
|
useEffect as useEffect10,
|
|
4997
|
-
useCallback as
|
|
5252
|
+
useCallback as useCallback5
|
|
4998
5253
|
} from "react";
|
|
4999
5254
|
import ReactDOM4 from "react-dom";
|
|
5000
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" }));
|
|
@@ -5025,12 +5280,12 @@ var Select = React76.forwardRef(function Select2(props, ref) {
|
|
|
5025
5280
|
const [open, setOpen] = useState10(false);
|
|
5026
5281
|
const [focusedIdx, setFocusedIdx] = useState10(-1);
|
|
5027
5282
|
const [popupStyle, setPopupStyle] = useState10({});
|
|
5028
|
-
const containerRef =
|
|
5029
|
-
const popupRef =
|
|
5030
|
-
const listRef =
|
|
5031
|
-
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;
|
|
5032
5287
|
const sxClass = useSx(sx);
|
|
5033
|
-
const calcPopupStyle =
|
|
5288
|
+
const calcPopupStyle = useCallback5(() => {
|
|
5034
5289
|
if (!containerRef.current) return;
|
|
5035
5290
|
const rect = containerRef.current.getBoundingClientRect();
|
|
5036
5291
|
setPopupStyle({
|
|
@@ -5041,24 +5296,24 @@ var Select = React76.forwardRef(function Select2(props, ref) {
|
|
|
5041
5296
|
}, []);
|
|
5042
5297
|
const options = normaliseOptions(rawOptions);
|
|
5043
5298
|
const selectedValues = multiple ? Array.isArray(value) ? value : value != null ? [value] : [] : value != null ? [value] : [];
|
|
5044
|
-
const isSelected =
|
|
5299
|
+
const isSelected = useCallback5(
|
|
5045
5300
|
(optValue) => selectedValues.includes(optValue),
|
|
5046
5301
|
[selectedValues]
|
|
5047
5302
|
);
|
|
5048
5303
|
const getSelectedLabels = () => options.filter((o) => selectedValues.includes(o.value)).map((o) => o.label);
|
|
5049
5304
|
const hasValue = selectedValues.length > 0;
|
|
5050
5305
|
const isFloating = Boolean(open || hasValue);
|
|
5051
|
-
const openPopup =
|
|
5306
|
+
const openPopup = useCallback5(() => {
|
|
5052
5307
|
if (disabled) return;
|
|
5053
5308
|
calcPopupStyle();
|
|
5054
5309
|
setOpen(true);
|
|
5055
5310
|
setFocusedIdx(-1);
|
|
5056
5311
|
}, [disabled, calcPopupStyle]);
|
|
5057
|
-
const closePopup =
|
|
5312
|
+
const closePopup = useCallback5(() => {
|
|
5058
5313
|
setOpen(false);
|
|
5059
5314
|
setFocusedIdx(-1);
|
|
5060
5315
|
}, []);
|
|
5061
|
-
const togglePopup =
|
|
5316
|
+
const togglePopup = useCallback5(() => {
|
|
5062
5317
|
if (open) closePopup();
|
|
5063
5318
|
else openPopup();
|
|
5064
5319
|
}, [open, openPopup, closePopup]);
|
|
@@ -5069,16 +5324,24 @@ var Select = React76.forwardRef(function Select2(props, ref) {
|
|
|
5069
5324
|
closePopup();
|
|
5070
5325
|
}
|
|
5071
5326
|
};
|
|
5327
|
+
const handleFocusOut = (e) => {
|
|
5328
|
+
const next = e.relatedTarget;
|
|
5329
|
+
if (!containerRef.current?.contains(next) && !popupRef.current?.contains(next)) {
|
|
5330
|
+
closePopup();
|
|
5331
|
+
}
|
|
5332
|
+
};
|
|
5072
5333
|
document.addEventListener("mousedown", handleOutside);
|
|
5334
|
+
document.addEventListener("focusout", handleFocusOut);
|
|
5073
5335
|
window.addEventListener("scroll", calcPopupStyle, true);
|
|
5074
5336
|
window.addEventListener("resize", calcPopupStyle);
|
|
5075
5337
|
return () => {
|
|
5076
5338
|
document.removeEventListener("mousedown", handleOutside);
|
|
5339
|
+
document.removeEventListener("focusout", handleFocusOut);
|
|
5077
5340
|
window.removeEventListener("scroll", calcPopupStyle, true);
|
|
5078
5341
|
window.removeEventListener("resize", calcPopupStyle);
|
|
5079
5342
|
};
|
|
5080
5343
|
}, [open, closePopup, calcPopupStyle]);
|
|
5081
|
-
const selectOption =
|
|
5344
|
+
const selectOption = useCallback5((opt, event) => {
|
|
5082
5345
|
if (opt.disabled) return;
|
|
5083
5346
|
if (multiple) {
|
|
5084
5347
|
const already = isSelected(opt.value);
|
|
@@ -5251,9 +5514,9 @@ Select.displayName = "Select";
|
|
|
5251
5514
|
// lib/Slider/Slider.tsx
|
|
5252
5515
|
import React77, {
|
|
5253
5516
|
useState as useState11,
|
|
5254
|
-
useRef as
|
|
5517
|
+
useRef as useRef12,
|
|
5255
5518
|
useEffect as useEffect11,
|
|
5256
|
-
useCallback as
|
|
5519
|
+
useCallback as useCallback6
|
|
5257
5520
|
} from "react";
|
|
5258
5521
|
function clamp(val, min, max) {
|
|
5259
5522
|
return Math.max(min, Math.min(max, val));
|
|
@@ -5284,8 +5547,8 @@ var Slider = React77.forwardRef(function Slider2(props, ref) {
|
|
|
5284
5547
|
sx
|
|
5285
5548
|
} = props;
|
|
5286
5549
|
const sxClass = useSx(sx);
|
|
5287
|
-
const trackRef =
|
|
5288
|
-
const draggingThumb =
|
|
5550
|
+
const trackRef = useRef12(null);
|
|
5551
|
+
const draggingThumb = useRef12(null);
|
|
5289
5552
|
const [dragging, setDragging] = useState11(null);
|
|
5290
5553
|
const isRange = range || Array.isArray(value);
|
|
5291
5554
|
const rawVal = value ?? (isRange ? [min, max] : min);
|
|
@@ -5297,7 +5560,7 @@ var Slider = React77.forwardRef(function Slider2(props, ref) {
|
|
|
5297
5560
|
computedMarks.push(...marks);
|
|
5298
5561
|
}
|
|
5299
5562
|
const hasLabelledMarks = computedMarks.some((m) => m.label);
|
|
5300
|
-
const getValueFromPointer =
|
|
5563
|
+
const getValueFromPointer = useCallback6((e) => {
|
|
5301
5564
|
const track = trackRef.current;
|
|
5302
5565
|
if (!track) return min;
|
|
5303
5566
|
const rect = track.getBoundingClientRect();
|
|
@@ -5460,7 +5723,7 @@ var Slider = React77.forwardRef(function Slider2(props, ref) {
|
|
|
5460
5723
|
Slider.displayName = "Slider";
|
|
5461
5724
|
|
|
5462
5725
|
// lib/Switch/Switch.tsx
|
|
5463
|
-
import React78, { useRef as
|
|
5726
|
+
import React78, { useRef as useRef13 } from "react";
|
|
5464
5727
|
var Switch = React78.forwardRef(function Switch2(props, ref) {
|
|
5465
5728
|
const {
|
|
5466
5729
|
checked = false,
|
|
@@ -5476,8 +5739,8 @@ var Switch = React78.forwardRef(function Switch2(props, ref) {
|
|
|
5476
5739
|
sx
|
|
5477
5740
|
} = props;
|
|
5478
5741
|
const sxClass = useSx(sx);
|
|
5479
|
-
const inputRef =
|
|
5480
|
-
const inputId =
|
|
5742
|
+
const inputRef = useRef13(null);
|
|
5743
|
+
const inputId = useRef13(`rf-sw-${Math.random().toString(36).slice(2, 9)}`).current;
|
|
5481
5744
|
const handleChange = (e) => {
|
|
5482
5745
|
if (!disabled) onChange?.(e, e.target.checked);
|
|
5483
5746
|
};
|
|
@@ -5521,7 +5784,7 @@ var Switch = React78.forwardRef(function Switch2(props, ref) {
|
|
|
5521
5784
|
Switch.displayName = "Switch";
|
|
5522
5785
|
|
|
5523
5786
|
// lib/RadioGroup/RadioGroup.tsx
|
|
5524
|
-
import React79, { useRef as
|
|
5787
|
+
import React79, { useRef as useRef14, createContext as createContext3, useContext as useContext3 } from "react";
|
|
5525
5788
|
var RadioGroupContext = createContext3({});
|
|
5526
5789
|
var Radio = React79.forwardRef(function Radio2(props, ref) {
|
|
5527
5790
|
const ctx = useContext3(RadioGroupContext);
|
|
@@ -5536,7 +5799,7 @@ var Radio = React79.forwardRef(function Radio2(props, ref) {
|
|
|
5536
5799
|
sx
|
|
5537
5800
|
} = props;
|
|
5538
5801
|
const sxClass = useSx(sx);
|
|
5539
|
-
const inputId =
|
|
5802
|
+
const inputId = useRef14(`rf-radio-${Math.random().toString(36).slice(2, 9)}`).current;
|
|
5540
5803
|
const isChecked = checkedProp !== void 0 ? checkedProp : ctx.value === value;
|
|
5541
5804
|
const isDisabled = disabledProp !== void 0 ? disabledProp : ctx.disabled ?? false;
|
|
5542
5805
|
const size = sizeProp ?? ctx.size ?? "medium";
|
|
@@ -5586,7 +5849,7 @@ var RadioGroup = React79.forwardRef(function RadioGroup2(props, ref) {
|
|
|
5586
5849
|
sx
|
|
5587
5850
|
} = props;
|
|
5588
5851
|
const sxClass = useSx(sx);
|
|
5589
|
-
const groupName =
|
|
5852
|
+
const groupName = useRef14(name ?? `rf-rg-${Math.random().toString(36).slice(2, 9)}`).current;
|
|
5590
5853
|
const rootClasses = [
|
|
5591
5854
|
"rf-radio-group",
|
|
5592
5855
|
row ? "rf-radio-group--row" : "",
|
|
@@ -5620,7 +5883,7 @@ RadioGroup.displayName = "RadioGroup";
|
|
|
5620
5883
|
// lib/Rating/Rating.tsx
|
|
5621
5884
|
import React80, {
|
|
5622
5885
|
useState as useState12,
|
|
5623
|
-
useRef as
|
|
5886
|
+
useRef as useRef15
|
|
5624
5887
|
} from "react";
|
|
5625
5888
|
var starSize = { small: 18, medium: 24, large: 32 };
|
|
5626
5889
|
var FilledStarIcon = ({ size }) => /* @__PURE__ */ React80.createElement(
|
|
@@ -5666,7 +5929,7 @@ var Rating = React80.forwardRef(function Rating2(props, ref) {
|
|
|
5666
5929
|
} = props;
|
|
5667
5930
|
const sxClass = useSx(sx);
|
|
5668
5931
|
const [hoverValue, setHoverValue] = useState12(null);
|
|
5669
|
-
const starsRef =
|
|
5932
|
+
const starsRef = useRef15(null);
|
|
5670
5933
|
const currentValue = value ?? 0;
|
|
5671
5934
|
const displayValue = hoverValue !== null ? hoverValue : currentValue;
|
|
5672
5935
|
const iconSize = starSize[size] ?? 24;
|
|
@@ -6858,7 +7121,7 @@ AccordionDetails.displayName = "AccordionDetails";
|
|
|
6858
7121
|
import React94, {
|
|
6859
7122
|
useEffect as useEffect12,
|
|
6860
7123
|
useLayoutEffect,
|
|
6861
|
-
useRef as
|
|
7124
|
+
useRef as useRef16,
|
|
6862
7125
|
useState as useState15,
|
|
6863
7126
|
Children as Children2,
|
|
6864
7127
|
cloneElement,
|
|
@@ -6922,8 +7185,8 @@ var Tabs = ({
|
|
|
6922
7185
|
sx
|
|
6923
7186
|
}) => {
|
|
6924
7187
|
const sxClass = useSx(sx);
|
|
6925
|
-
const tabsListRef =
|
|
6926
|
-
const tabRefs =
|
|
7188
|
+
const tabsListRef = useRef16(null);
|
|
7189
|
+
const tabRefs = useRef16(/* @__PURE__ */ new Map());
|
|
6927
7190
|
const [indicatorStyle, setIndicatorStyle] = useState15({});
|
|
6928
7191
|
const updateIndicator = () => {
|
|
6929
7192
|
if (value === void 0) return;
|
|
@@ -7309,7 +7572,7 @@ Stepper.displayName = "Stepper";
|
|
|
7309
7572
|
// lib/Menu/Menu.tsx
|
|
7310
7573
|
import React97, {
|
|
7311
7574
|
useEffect as useEffect13,
|
|
7312
|
-
useRef as
|
|
7575
|
+
useRef as useRef17,
|
|
7313
7576
|
useState as useState17
|
|
7314
7577
|
} from "react";
|
|
7315
7578
|
import ReactDOM5 from "react-dom";
|
|
@@ -7402,7 +7665,7 @@ var Menu = ({
|
|
|
7402
7665
|
children
|
|
7403
7666
|
}) => {
|
|
7404
7667
|
const sxClass = useSx(sx);
|
|
7405
|
-
const paperRef =
|
|
7668
|
+
const paperRef = useRef17(null);
|
|
7406
7669
|
const [menuStyle, setMenuStyle] = useState17({});
|
|
7407
7670
|
const [mounted, setMounted] = useState17(false);
|
|
7408
7671
|
useEffect13(() => {
|
|
@@ -7583,9 +7846,9 @@ Drawer.displayName = "Drawer";
|
|
|
7583
7846
|
|
|
7584
7847
|
// lib/Snackbar/Snackbar.tsx
|
|
7585
7848
|
import React99, {
|
|
7586
|
-
useCallback as
|
|
7849
|
+
useCallback as useCallback7,
|
|
7587
7850
|
useEffect as useEffect15,
|
|
7588
|
-
useRef as
|
|
7851
|
+
useRef as useRef18,
|
|
7589
7852
|
useState as useState19
|
|
7590
7853
|
} from "react";
|
|
7591
7854
|
import ReactDOM7 from "react-dom";
|
|
@@ -7612,13 +7875,13 @@ var Snackbar = ({
|
|
|
7612
7875
|
const sxClass = useSx(sx);
|
|
7613
7876
|
const [transitionState, setTransitionState] = useState19("exited");
|
|
7614
7877
|
const [mounted, setMounted] = useState19(false);
|
|
7615
|
-
const timerRef =
|
|
7616
|
-
const hideTimerRef =
|
|
7617
|
-
const clearTimers =
|
|
7878
|
+
const timerRef = useRef18(null);
|
|
7879
|
+
const hideTimerRef = useRef18(null);
|
|
7880
|
+
const clearTimers = useCallback7(() => {
|
|
7618
7881
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
7619
7882
|
if (hideTimerRef.current) clearTimeout(hideTimerRef.current);
|
|
7620
7883
|
}, []);
|
|
7621
|
-
const startHideTimer =
|
|
7884
|
+
const startHideTimer = useCallback7(() => {
|
|
7622
7885
|
if (autoHideDuration == null || !onClose) return;
|
|
7623
7886
|
clearTimers();
|
|
7624
7887
|
hideTimerRef.current = setTimeout(() => {
|
|
@@ -7749,7 +8012,7 @@ Link.displayName = "Link";
|
|
|
7749
8012
|
import React101, {
|
|
7750
8013
|
useEffect as useEffect16,
|
|
7751
8014
|
useLayoutEffect as useLayoutEffect2,
|
|
7752
|
-
useRef as
|
|
8015
|
+
useRef as useRef19,
|
|
7753
8016
|
useState as useState20
|
|
7754
8017
|
} from "react";
|
|
7755
8018
|
import ReactDOM8 from "react-dom";
|
|
@@ -7830,7 +8093,7 @@ var Popper = ({
|
|
|
7830
8093
|
sx
|
|
7831
8094
|
}) => {
|
|
7832
8095
|
const sxClass = useSx(sx);
|
|
7833
|
-
const popperRef =
|
|
8096
|
+
const popperRef = useRef19(null);
|
|
7834
8097
|
const [posStyle, setPosStyle] = useState20({});
|
|
7835
8098
|
const [mounted, setMounted] = useState20(open || keepMounted);
|
|
7836
8099
|
const [fadeState, setFadeState] = useState20(
|
|
@@ -7903,7 +8166,7 @@ Popper.displayName = "Popper";
|
|
|
7903
8166
|
import React102, {
|
|
7904
8167
|
useEffect as useEffect17,
|
|
7905
8168
|
useLayoutEffect as useLayoutEffect3,
|
|
7906
|
-
useRef as
|
|
8169
|
+
useRef as useRef20,
|
|
7907
8170
|
useState as useState21
|
|
7908
8171
|
} from "react";
|
|
7909
8172
|
import ReactDOM9 from "react-dom";
|
|
@@ -7933,7 +8196,7 @@ var Popover = ({
|
|
|
7933
8196
|
}) => {
|
|
7934
8197
|
const sxClass = useSx(sx);
|
|
7935
8198
|
const paperSxClass = useSx(PaperProps?.sx);
|
|
7936
|
-
const paperRef =
|
|
8199
|
+
const paperRef = useRef20(null);
|
|
7937
8200
|
const [posStyle, setPosStyle] = useState21({});
|
|
7938
8201
|
const [mounted, setMounted] = useState21(open || keepMounted);
|
|
7939
8202
|
useEffect17(() => {
|
|
@@ -8020,7 +8283,7 @@ Popover.displayName = "Popover";
|
|
|
8020
8283
|
import React103, {
|
|
8021
8284
|
cloneElement as cloneElement3,
|
|
8022
8285
|
useEffect as useEffect18,
|
|
8023
|
-
useRef as
|
|
8286
|
+
useRef as useRef21,
|
|
8024
8287
|
useState as useState22
|
|
8025
8288
|
} from "react";
|
|
8026
8289
|
function getTimeout(timeout, phase) {
|
|
@@ -8031,8 +8294,8 @@ function getTimeout(timeout, phase) {
|
|
|
8031
8294
|
function useTransitionState(inProp, timeout, onEnter, onExited) {
|
|
8032
8295
|
const [state, setState] = useState22("exited");
|
|
8033
8296
|
const [mounted, setMounted] = useState22(false);
|
|
8034
|
-
const timerRef =
|
|
8035
|
-
const isFirstRender =
|
|
8297
|
+
const timerRef = useRef21(null);
|
|
8298
|
+
const isFirstRender = useRef21(true);
|
|
8036
8299
|
useEffect18(() => {
|
|
8037
8300
|
if (timerRef.current) clearTimeout(timerRef.current);
|
|
8038
8301
|
if (inProp) {
|
|
@@ -8176,7 +8439,7 @@ var Collapse = ({
|
|
|
8176
8439
|
onExited
|
|
8177
8440
|
}) => {
|
|
8178
8441
|
const { state, mounted } = useTransitionState(inProp, timeout, onEnter, onExited);
|
|
8179
|
-
const innerRef =
|
|
8442
|
+
const innerRef = useRef21(null);
|
|
8180
8443
|
const [size, setSize] = useState22(
|
|
8181
8444
|
inProp ? "auto" : collapsedSize
|
|
8182
8445
|
);
|
|
@@ -8254,7 +8517,7 @@ var Zoom = ({
|
|
|
8254
8517
|
Zoom.displayName = "Zoom";
|
|
8255
8518
|
|
|
8256
8519
|
// lib/ImageField/ImageField.tsx
|
|
8257
|
-
import React104, { useRef as
|
|
8520
|
+
import React104, { useRef as useRef22, useState as useState23, useCallback as useCallback8 } from "react";
|
|
8258
8521
|
function getSizeStyle2(size) {
|
|
8259
8522
|
if (size === "small") return { className: "rf-image-field--small" };
|
|
8260
8523
|
if (size === "large") return { className: "rf-image-field--large" };
|
|
@@ -8281,16 +8544,16 @@ var ImageField = React104.forwardRef(
|
|
|
8281
8544
|
sx
|
|
8282
8545
|
}, ref) => {
|
|
8283
8546
|
const sxClass = useSx(sx);
|
|
8284
|
-
const inputRef =
|
|
8547
|
+
const inputRef = useRef22(null);
|
|
8285
8548
|
const [preview, setPreview] = useState23(null);
|
|
8286
8549
|
const { className: sizeClass, style: sizeStyle } = getSizeStyle2(size);
|
|
8287
8550
|
const displaySrc = preview || src;
|
|
8288
|
-
const handleClick =
|
|
8551
|
+
const handleClick = useCallback8(() => {
|
|
8289
8552
|
if (!disabled) {
|
|
8290
8553
|
inputRef.current?.click();
|
|
8291
8554
|
}
|
|
8292
8555
|
}, [disabled]);
|
|
8293
|
-
const handleKeyDown =
|
|
8556
|
+
const handleKeyDown = useCallback8(
|
|
8294
8557
|
(e) => {
|
|
8295
8558
|
if ((e.key === "Enter" || e.key === " ") && !disabled) {
|
|
8296
8559
|
e.preventDefault();
|
|
@@ -8299,7 +8562,7 @@ var ImageField = React104.forwardRef(
|
|
|
8299
8562
|
},
|
|
8300
8563
|
[disabled]
|
|
8301
8564
|
);
|
|
8302
|
-
const handleFileChange =
|
|
8565
|
+
const handleFileChange = useCallback8(
|
|
8303
8566
|
(e) => {
|
|
8304
8567
|
const file = e.target.files?.[0];
|
|
8305
8568
|
if (!file) return;
|
|
@@ -8365,9 +8628,9 @@ ImageField.displayName = "ImageField";
|
|
|
8365
8628
|
// lib/PhoneField/PhoneField.tsx
|
|
8366
8629
|
import React105, {
|
|
8367
8630
|
useState as useState24,
|
|
8368
|
-
useRef as
|
|
8631
|
+
useRef as useRef23,
|
|
8369
8632
|
useEffect as useEffect19,
|
|
8370
|
-
useCallback as
|
|
8633
|
+
useCallback as useCallback9,
|
|
8371
8634
|
forwardRef as forwardRef10
|
|
8372
8635
|
} from "react";
|
|
8373
8636
|
import { Country as Country2 } from "country-state-city";
|
|
@@ -8418,11 +8681,11 @@ var PhoneField = forwardRef10(function PhoneField2(props, ref) {
|
|
|
8418
8681
|
sx
|
|
8419
8682
|
} = props;
|
|
8420
8683
|
const sxClass = useSx(sx);
|
|
8421
|
-
const containerRef =
|
|
8422
|
-
const inputRef =
|
|
8423
|
-
const listRef =
|
|
8424
|
-
const popupRef =
|
|
8425
|
-
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;
|
|
8426
8689
|
const countries = React105.useMemo(() => {
|
|
8427
8690
|
const all = getAllCountries();
|
|
8428
8691
|
if (onlyCountries && onlyCountries.length > 0) {
|
|
@@ -8441,7 +8704,7 @@ var PhoneField = forwardRef10(function PhoneField2(props, ref) {
|
|
|
8441
8704
|
const [open, setOpen] = useState24(false);
|
|
8442
8705
|
const [focusedIdx, setFocusedIdx] = useState24(-1);
|
|
8443
8706
|
const [search, setSearch] = useState24("");
|
|
8444
|
-
const prevValueRef =
|
|
8707
|
+
const prevValueRef = useRef23(value);
|
|
8445
8708
|
useEffect19(() => {
|
|
8446
8709
|
if (value === prevValueRef.current) return;
|
|
8447
8710
|
prevValueRef.current = value;
|
|
@@ -8455,13 +8718,13 @@ var PhoneField = forwardRef10(function PhoneField2(props, ref) {
|
|
|
8455
8718
|
const dialCode = selectedCountry?.phonecode || "";
|
|
8456
8719
|
const digits = sanitizeValue(value);
|
|
8457
8720
|
const phoneNumber = digits.startsWith(dialCode) ? digits.slice(dialCode.length) : digits;
|
|
8458
|
-
const openDropdown =
|
|
8721
|
+
const openDropdown = useCallback9(() => {
|
|
8459
8722
|
if (disabled) return;
|
|
8460
8723
|
setOpen(true);
|
|
8461
8724
|
setFocusedIdx(-1);
|
|
8462
8725
|
setSearch("");
|
|
8463
8726
|
}, [disabled]);
|
|
8464
|
-
const closeDropdown =
|
|
8727
|
+
const closeDropdown = useCallback9(() => {
|
|
8465
8728
|
setOpen(false);
|
|
8466
8729
|
setFocusedIdx(-1);
|
|
8467
8730
|
setSearch("");
|
|
@@ -8512,7 +8775,7 @@ var PhoneField = forwardRef10(function PhoneField2(props, ref) {
|
|
|
8512
8775
|
window.removeEventListener("resize", updatePosition);
|
|
8513
8776
|
};
|
|
8514
8777
|
}, [open]);
|
|
8515
|
-
const selectCountry =
|
|
8778
|
+
const selectCountry = useCallback9((country) => {
|
|
8516
8779
|
setSelectedCountry(country);
|
|
8517
8780
|
closeDropdown();
|
|
8518
8781
|
const newValue = "+" + country.phonecode + phoneNumber;
|
|
@@ -8669,8 +8932,406 @@ var PhoneField = forwardRef10(function PhoneField2(props, ref) {
|
|
|
8669
8932
|
});
|
|
8670
8933
|
PhoneField.displayName = "PhoneField";
|
|
8671
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
|
+
|
|
8672
9333
|
// lib/RufousTextEditor/RufousTextEditor.tsx
|
|
8673
|
-
import
|
|
9334
|
+
import React117, { useMemo as useMemo4, useCallback as useCallback15, useState as useState35, useRef as useRef32, useEffect as useEffect29 } from "react";
|
|
8674
9335
|
import { createPortal as createPortal8 } from "react-dom";
|
|
8675
9336
|
import { useEditor, EditorContent, EditorContext, FloatingMenu, BubbleMenu } from "@tiptap/react";
|
|
8676
9337
|
import StarterKit from "@tiptap/starter-kit";
|
|
@@ -8696,16 +9357,16 @@ import { ReactRenderer } from "@tiptap/react";
|
|
|
8696
9357
|
import tippy from "tippy.js";
|
|
8697
9358
|
|
|
8698
9359
|
// lib/RufousTextEditor/MentionList.tsx
|
|
8699
|
-
import
|
|
9360
|
+
import React107, { forwardRef as forwardRef11, useEffect as useEffect21, useImperativeHandle, useState as useState26 } from "react";
|
|
8700
9361
|
var MentionList = forwardRef11((props, ref) => {
|
|
8701
|
-
const [selectedIndex, setSelectedIndex] =
|
|
9362
|
+
const [selectedIndex, setSelectedIndex] = useState26(0);
|
|
8702
9363
|
const selectItem = (index) => {
|
|
8703
9364
|
const item = props.items[index];
|
|
8704
9365
|
if (item) {
|
|
8705
9366
|
props.command({ id: item.id, label: item.shortName || item.name });
|
|
8706
9367
|
}
|
|
8707
9368
|
};
|
|
8708
|
-
|
|
9369
|
+
useEffect21(() => setSelectedIndex(0), [props.items]);
|
|
8709
9370
|
useImperativeHandle(ref, () => ({
|
|
8710
9371
|
onKeyDown: ({ event }) => {
|
|
8711
9372
|
if (event.key === "ArrowUp") {
|
|
@@ -8724,17 +9385,17 @@ var MentionList = forwardRef11((props, ref) => {
|
|
|
8724
9385
|
}
|
|
8725
9386
|
}));
|
|
8726
9387
|
if (!props.items.length) {
|
|
8727
|
-
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"));
|
|
8728
9389
|
}
|
|
8729
|
-
return /* @__PURE__ */
|
|
9390
|
+
return /* @__PURE__ */ React107.createElement("div", { className: "rf-rte-mention-dropdown" }, props.items.map((item, index) => /* @__PURE__ */ React107.createElement(
|
|
8730
9391
|
"button",
|
|
8731
9392
|
{
|
|
8732
9393
|
className: `rf-rte-mention-item ${index === selectedIndex ? "is-selected" : ""}`,
|
|
8733
9394
|
key: item.id,
|
|
8734
9395
|
onClick: () => selectItem(index)
|
|
8735
9396
|
},
|
|
8736
|
-
/* @__PURE__ */
|
|
8737
|
-
/* @__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)
|
|
8738
9399
|
)));
|
|
8739
9400
|
});
|
|
8740
9401
|
MentionList.displayName = "MentionList";
|
|
@@ -8792,21 +9453,21 @@ function createMentionSuggestion(users) {
|
|
|
8792
9453
|
}
|
|
8793
9454
|
|
|
8794
9455
|
// lib/RufousTextEditor/Toolbar.tsx
|
|
8795
|
-
import
|
|
9456
|
+
import React113, { useState as useState31, useRef as useRef28, useEffect as useEffect25, useCallback as useCallback14 } from "react";
|
|
8796
9457
|
import { createPortal as createPortal4 } from "react-dom";
|
|
8797
9458
|
|
|
8798
9459
|
// lib/RufousTextEditor/TextToSpeech.tsx
|
|
8799
|
-
import
|
|
9460
|
+
import React108, { useState as useState27, useEffect as useEffect22, useRef as useRef25, useCallback as useCallback11, forwardRef as forwardRef12, useImperativeHandle as useImperativeHandle2 } from "react";
|
|
8800
9461
|
var TextToSpeech = forwardRef12(({ editor, onTextToSpeech }, ref) => {
|
|
8801
|
-
const [speaking, setSpeaking] =
|
|
8802
|
-
const [paused, setPaused] =
|
|
8803
|
-
const [voices, setVoices] =
|
|
8804
|
-
const [selectedVoice, setSelectedVoice] =
|
|
8805
|
-
const [rate, setRate] =
|
|
8806
|
-
const [showPanel, setShowPanel] =
|
|
8807
|
-
const utteranceRef =
|
|
8808
|
-
const panelRef =
|
|
8809
|
-
|
|
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(() => {
|
|
8810
9471
|
const synth = window.speechSynthesis;
|
|
8811
9472
|
const loadVoices = () => {
|
|
8812
9473
|
const available = synth.getVoices();
|
|
@@ -8824,7 +9485,7 @@ var TextToSpeech = forwardRef12(({ editor, onTextToSpeech }, ref) => {
|
|
|
8824
9485
|
synth.removeEventListener("voiceschanged", loadVoices);
|
|
8825
9486
|
};
|
|
8826
9487
|
}, [selectedVoice]);
|
|
8827
|
-
|
|
9488
|
+
useEffect22(() => {
|
|
8828
9489
|
const handleClick = (e) => {
|
|
8829
9490
|
if (panelRef.current && !panelRef.current.contains(e.target)) {
|
|
8830
9491
|
setShowPanel(false);
|
|
@@ -8833,7 +9494,7 @@ var TextToSpeech = forwardRef12(({ editor, onTextToSpeech }, ref) => {
|
|
|
8833
9494
|
document.addEventListener("mousedown", handleClick);
|
|
8834
9495
|
return () => document.removeEventListener("mousedown", handleClick);
|
|
8835
9496
|
}, []);
|
|
8836
|
-
const getTextToSpeak =
|
|
9497
|
+
const getTextToSpeak = useCallback11(() => {
|
|
8837
9498
|
if (!editor) return "";
|
|
8838
9499
|
const { from, to, empty } = editor.state.selection;
|
|
8839
9500
|
if (!empty) {
|
|
@@ -8841,7 +9502,7 @@ var TextToSpeech = forwardRef12(({ editor, onTextToSpeech }, ref) => {
|
|
|
8841
9502
|
}
|
|
8842
9503
|
return editor.getText();
|
|
8843
9504
|
}, [editor]);
|
|
8844
|
-
const handleSpeak =
|
|
9505
|
+
const handleSpeak = useCallback11(async () => {
|
|
8845
9506
|
const text = getTextToSpeak();
|
|
8846
9507
|
if (!text.trim()) return;
|
|
8847
9508
|
if (onTextToSpeech) {
|
|
@@ -8883,25 +9544,25 @@ var TextToSpeech = forwardRef12(({ editor, onTextToSpeech }, ref) => {
|
|
|
8883
9544
|
setSpeaking(true);
|
|
8884
9545
|
setPaused(false);
|
|
8885
9546
|
}, [getTextToSpeak, voices, selectedVoice, rate, onTextToSpeech]);
|
|
8886
|
-
const handlePause =
|
|
9547
|
+
const handlePause = useCallback11(() => {
|
|
8887
9548
|
if (window.speechSynthesis.speaking && !window.speechSynthesis.paused) {
|
|
8888
9549
|
window.speechSynthesis.pause();
|
|
8889
9550
|
setPaused(true);
|
|
8890
9551
|
}
|
|
8891
9552
|
}, []);
|
|
8892
|
-
const handleResume =
|
|
9553
|
+
const handleResume = useCallback11(() => {
|
|
8893
9554
|
if (window.speechSynthesis.paused) {
|
|
8894
9555
|
window.speechSynthesis.resume();
|
|
8895
9556
|
setPaused(false);
|
|
8896
9557
|
}
|
|
8897
9558
|
}, []);
|
|
8898
|
-
const handleStop =
|
|
9559
|
+
const handleStop = useCallback11(() => {
|
|
8899
9560
|
window.speechSynthesis.cancel();
|
|
8900
9561
|
setSpeaking(false);
|
|
8901
9562
|
setPaused(false);
|
|
8902
9563
|
}, []);
|
|
8903
9564
|
useImperativeHandle2(ref, () => ({ stop: handleStop }), [handleStop]);
|
|
8904
|
-
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(
|
|
8905
9566
|
"button",
|
|
8906
9567
|
{
|
|
8907
9568
|
className: `toolbar-btn ${speaking ? "is-active" : ""}`,
|
|
@@ -8914,15 +9575,15 @@ var TextToSpeech = forwardRef12(({ editor, onTextToSpeech }, ref) => {
|
|
|
8914
9575
|
}
|
|
8915
9576
|
},
|
|
8916
9577
|
speaking ? "\u23F9" : "\u{1F50A}"
|
|
8917
|
-
)), 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(
|
|
8918
9579
|
"select",
|
|
8919
9580
|
{
|
|
8920
9581
|
className: "tts-select",
|
|
8921
9582
|
value: selectedVoice,
|
|
8922
9583
|
onChange: (e) => setSelectedVoice(e.target.value)
|
|
8923
9584
|
},
|
|
8924
|
-
voices.map((v) => /* @__PURE__ */
|
|
8925
|
-
), /* @__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(
|
|
8926
9587
|
"input",
|
|
8927
9588
|
{
|
|
8928
9589
|
type: "range",
|
|
@@ -8933,26 +9594,26 @@ var TextToSpeech = forwardRef12(({ editor, onTextToSpeech }, ref) => {
|
|
|
8933
9594
|
value: rate,
|
|
8934
9595
|
onChange: (e) => setRate(Number(e.target.value))
|
|
8935
9596
|
}
|
|
8936
|
-
), /* @__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: () => {
|
|
8937
9598
|
handleSpeak();
|
|
8938
9599
|
setShowPanel(false);
|
|
8939
|
-
} }, "\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"))));
|
|
8940
9601
|
});
|
|
8941
9602
|
var TextToSpeech_default = TextToSpeech;
|
|
8942
9603
|
|
|
8943
9604
|
// lib/RufousTextEditor/SpeechToText.tsx
|
|
8944
|
-
import
|
|
9605
|
+
import React109, { useState as useState28, useRef as useRef26, useCallback as useCallback12, useEffect as useEffect23, forwardRef as forwardRef13, useImperativeHandle as useImperativeHandle3 } from "react";
|
|
8945
9606
|
var SpeechToText = forwardRef13(({ editor, onSpeechToText }, ref) => {
|
|
8946
|
-
const [listening, setListening] =
|
|
8947
|
-
const [showPanel, setShowPanel] =
|
|
8948
|
-
const [language, setLanguage] =
|
|
8949
|
-
const [interim, setInterim] =
|
|
8950
|
-
const recognitionRef =
|
|
8951
|
-
const panelRef =
|
|
8952
|
-
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);
|
|
8953
9614
|
const SpeechRecognitionAPI = typeof window !== "undefined" ? window.SpeechRecognition || window.webkitSpeechRecognition : null;
|
|
8954
9615
|
const supported = !!SpeechRecognitionAPI;
|
|
8955
|
-
|
|
9616
|
+
useEffect23(() => {
|
|
8956
9617
|
const handleClick = (e) => {
|
|
8957
9618
|
if (panelRef.current && !panelRef.current.contains(e.target)) {
|
|
8958
9619
|
setShowPanel(false);
|
|
@@ -8961,7 +9622,7 @@ var SpeechToText = forwardRef13(({ editor, onSpeechToText }, ref) => {
|
|
|
8961
9622
|
document.addEventListener("mousedown", handleClick);
|
|
8962
9623
|
return () => document.removeEventListener("mousedown", handleClick);
|
|
8963
9624
|
}, []);
|
|
8964
|
-
const createRecognition =
|
|
9625
|
+
const createRecognition = useCallback12(() => {
|
|
8965
9626
|
if (!supported) return null;
|
|
8966
9627
|
const recognition = new SpeechRecognitionAPI();
|
|
8967
9628
|
recognition.lang = language;
|
|
@@ -8970,7 +9631,7 @@ var SpeechToText = forwardRef13(({ editor, onSpeechToText }, ref) => {
|
|
|
8970
9631
|
recognition.maxAlternatives = 1;
|
|
8971
9632
|
return recognition;
|
|
8972
9633
|
}, [supported, language]);
|
|
8973
|
-
const startSession =
|
|
9634
|
+
const startSession = useCallback12((recognition) => {
|
|
8974
9635
|
if (!recognition || !editor) return;
|
|
8975
9636
|
recognition.onresult = async (event) => {
|
|
8976
9637
|
let finalText = "";
|
|
@@ -9025,7 +9686,7 @@ var SpeechToText = forwardRef13(({ editor, onSpeechToText }, ref) => {
|
|
|
9025
9686
|
}
|
|
9026
9687
|
};
|
|
9027
9688
|
}, [editor, createRecognition, onSpeechToText]);
|
|
9028
|
-
const startListening =
|
|
9689
|
+
const startListening = useCallback12(() => {
|
|
9029
9690
|
if (!supported || !editor) return;
|
|
9030
9691
|
const recognition = createRecognition();
|
|
9031
9692
|
if (!recognition) return;
|
|
@@ -9041,7 +9702,7 @@ var SpeechToText = forwardRef13(({ editor, onSpeechToText }, ref) => {
|
|
|
9041
9702
|
setListening(false);
|
|
9042
9703
|
}
|
|
9043
9704
|
}, [supported, editor, createRecognition, startSession]);
|
|
9044
|
-
const stopListening =
|
|
9705
|
+
const stopListening = useCallback12(() => {
|
|
9045
9706
|
isListeningRef.current = false;
|
|
9046
9707
|
if (recognitionRef.current) {
|
|
9047
9708
|
try {
|
|
@@ -9055,7 +9716,7 @@ var SpeechToText = forwardRef13(({ editor, onSpeechToText }, ref) => {
|
|
|
9055
9716
|
}, []);
|
|
9056
9717
|
useImperativeHandle3(ref, () => ({ stop: stopListening }), [stopListening]);
|
|
9057
9718
|
if (!supported) {
|
|
9058
|
-
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}"));
|
|
9059
9720
|
}
|
|
9060
9721
|
const LANGUAGES2 = [
|
|
9061
9722
|
{ code: "en-US", label: "English (US)" },
|
|
@@ -9077,7 +9738,7 @@ var SpeechToText = forwardRef13(({ editor, onSpeechToText }, ref) => {
|
|
|
9077
9738
|
{ code: "kn-IN", label: "Kannada" },
|
|
9078
9739
|
{ code: "ml-IN", label: "Malayalam" }
|
|
9079
9740
|
];
|
|
9080
|
-
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(
|
|
9081
9742
|
"button",
|
|
9082
9743
|
{
|
|
9083
9744
|
className: `toolbar-btn ${listening ? "is-active stt-recording" : ""}`,
|
|
@@ -9090,20 +9751,20 @@ var SpeechToText = forwardRef13(({ editor, onSpeechToText }, ref) => {
|
|
|
9090
9751
|
}
|
|
9091
9752
|
},
|
|
9092
9753
|
"\u{1F3A4}"
|
|
9093
|
-
)), 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(
|
|
9094
9755
|
"select",
|
|
9095
9756
|
{
|
|
9096
9757
|
className: "stt-select",
|
|
9097
9758
|
value: language,
|
|
9098
9759
|
onChange: (e) => setLanguage(e.target.value)
|
|
9099
9760
|
},
|
|
9100
|
-
LANGUAGES2.map((l) => /* @__PURE__ */
|
|
9101
|
-
), /* @__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));
|
|
9102
9763
|
});
|
|
9103
9764
|
var SpeechToText_default = SpeechToText;
|
|
9104
9765
|
|
|
9105
9766
|
// lib/RufousTextEditor/AICommands.tsx
|
|
9106
|
-
import
|
|
9767
|
+
import React110, { useState as useState29, useRef as useRef27, useEffect as useEffect24, useCallback as useCallback13 } from "react";
|
|
9107
9768
|
import { createPortal as createPortal2 } from "react-dom";
|
|
9108
9769
|
var AI_COMMANDS = [
|
|
9109
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." },
|
|
@@ -9151,16 +9812,16 @@ var callOpenAI = async (prompt, text, previousResults = []) => {
|
|
|
9151
9812
|
return data.choices?.[0]?.message?.content?.trim() || "";
|
|
9152
9813
|
};
|
|
9153
9814
|
var AICommands = ({ editor, onAICommand }) => {
|
|
9154
|
-
const [open, setOpen] =
|
|
9155
|
-
const [showModal, setShowModal] =
|
|
9156
|
-
const [loading, setLoading] =
|
|
9157
|
-
const [promptText, setPromptText] =
|
|
9158
|
-
const [resultText, setResultText] =
|
|
9159
|
-
const [originalText, setOriginalText] =
|
|
9160
|
-
const [selectionRange, setSelectionRange] =
|
|
9161
|
-
const [previousResults, setPreviousResults] =
|
|
9162
|
-
const panelRef =
|
|
9163
|
-
|
|
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(() => {
|
|
9164
9825
|
const handleClick = (e) => {
|
|
9165
9826
|
if (panelRef.current && !panelRef.current.contains(e.target)) {
|
|
9166
9827
|
setOpen(false);
|
|
@@ -9169,7 +9830,7 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9169
9830
|
document.addEventListener("mousedown", handleClick);
|
|
9170
9831
|
return () => document.removeEventListener("mousedown", handleClick);
|
|
9171
9832
|
}, []);
|
|
9172
|
-
const getSelectedText =
|
|
9833
|
+
const getSelectedText = useCallback13(() => {
|
|
9173
9834
|
if (!editor) return { text: "", range: null };
|
|
9174
9835
|
const { from, to, empty } = editor.state.selection;
|
|
9175
9836
|
if (!empty) {
|
|
@@ -9177,7 +9838,7 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9177
9838
|
}
|
|
9178
9839
|
return { text: editor.getText(), range: null };
|
|
9179
9840
|
}, [editor]);
|
|
9180
|
-
const fetchAIResult =
|
|
9841
|
+
const fetchAIResult = useCallback13(async (prompt, text, prevResults = []) => {
|
|
9181
9842
|
setLoading(true);
|
|
9182
9843
|
setResultText("");
|
|
9183
9844
|
try {
|
|
@@ -9195,7 +9856,7 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9195
9856
|
setLoading(false);
|
|
9196
9857
|
}
|
|
9197
9858
|
}, [onAICommand]);
|
|
9198
|
-
const handleCommandSelect =
|
|
9859
|
+
const handleCommandSelect = useCallback13((command) => {
|
|
9199
9860
|
const { text, range } = getSelectedText();
|
|
9200
9861
|
if (!text.trim()) return;
|
|
9201
9862
|
setOriginalText(text);
|
|
@@ -9206,7 +9867,7 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9206
9867
|
setShowModal(true);
|
|
9207
9868
|
fetchAIResult(command.prompt, text, []);
|
|
9208
9869
|
}, [getSelectedText, fetchAIResult]);
|
|
9209
|
-
const handleInsert =
|
|
9870
|
+
const handleInsert = useCallback13(() => {
|
|
9210
9871
|
if (!resultText || !editor) return;
|
|
9211
9872
|
if (selectionRange) {
|
|
9212
9873
|
editor.chain().focus().deleteRange(selectionRange).insertContentAt(selectionRange.from, resultText).run();
|
|
@@ -9216,7 +9877,7 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9216
9877
|
setShowModal(false);
|
|
9217
9878
|
setResultText("");
|
|
9218
9879
|
}, [editor, resultText, selectionRange]);
|
|
9219
|
-
const handleInsertAfter =
|
|
9880
|
+
const handleInsertAfter = useCallback13(() => {
|
|
9220
9881
|
if (!resultText || !editor) return;
|
|
9221
9882
|
if (selectionRange) {
|
|
9222
9883
|
editor.chain().focus().insertContentAt(selectionRange.to, "\n" + resultText).run();
|
|
@@ -9231,11 +9892,11 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9231
9892
|
setShowModal(false);
|
|
9232
9893
|
setResultText("");
|
|
9233
9894
|
}, [editor, resultText, selectionRange]);
|
|
9234
|
-
const handleRefresh =
|
|
9895
|
+
const handleRefresh = useCallback13(() => {
|
|
9235
9896
|
if (!originalText.trim()) return;
|
|
9236
9897
|
fetchAIResult(promptText, originalText, previousResults);
|
|
9237
9898
|
}, [originalText, promptText, previousResults, fetchAIResult]);
|
|
9238
|
-
const handleCancel =
|
|
9899
|
+
const handleCancel = useCallback13(() => {
|
|
9239
9900
|
setShowModal(false);
|
|
9240
9901
|
setResultText("");
|
|
9241
9902
|
setPromptText("");
|
|
@@ -9244,15 +9905,15 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9244
9905
|
setPreviousResults([]);
|
|
9245
9906
|
}, []);
|
|
9246
9907
|
if (!editor) return null;
|
|
9247
|
-
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(
|
|
9248
9909
|
"button",
|
|
9249
9910
|
{
|
|
9250
9911
|
className: `toolbar-btn ${open ? "is-active" : ""}`,
|
|
9251
9912
|
onClick: () => setOpen(!open)
|
|
9252
9913
|
},
|
|
9253
|
-
/* @__PURE__ */
|
|
9254
|
-
/* @__PURE__ */
|
|
9255
|
-
)), 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(
|
|
9256
9917
|
"button",
|
|
9257
9918
|
{
|
|
9258
9919
|
key: cmd.id,
|
|
@@ -9260,8 +9921,8 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9260
9921
|
onClick: () => handleCommandSelect(cmd)
|
|
9261
9922
|
},
|
|
9262
9923
|
cmd.label
|
|
9263
|
-
))), /* @__PURE__ */
|
|
9264
|
-
/* @__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(
|
|
9265
9926
|
"textarea",
|
|
9266
9927
|
{
|
|
9267
9928
|
className: "ai-modal-prompt",
|
|
@@ -9269,15 +9930,15 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9269
9930
|
onChange: (e) => setPromptText(e.target.value),
|
|
9270
9931
|
rows: 3
|
|
9271
9932
|
}
|
|
9272
|
-
), /* @__PURE__ */
|
|
9933
|
+
), /* @__PURE__ */ React110.createElement(Tooltip, { title: "Run with custom prompt", placement: "top" }, /* @__PURE__ */ React110.createElement(
|
|
9273
9934
|
"button",
|
|
9274
9935
|
{
|
|
9275
9936
|
className: "ai-modal-robot-btn",
|
|
9276
9937
|
onClick: () => fetchAIResult(promptText, originalText),
|
|
9277
9938
|
disabled: loading
|
|
9278
9939
|
},
|
|
9279
|
-
/* @__PURE__ */
|
|
9280
|
-
)))), /* @__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(
|
|
9281
9942
|
"button",
|
|
9282
9943
|
{
|
|
9283
9944
|
className: "ai-modal-action-btn ai-modal-insert-btn",
|
|
@@ -9285,7 +9946,7 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9285
9946
|
disabled: loading || !resultText
|
|
9286
9947
|
},
|
|
9287
9948
|
"Insert"
|
|
9288
|
-
), /* @__PURE__ */
|
|
9949
|
+
), /* @__PURE__ */ React110.createElement(
|
|
9289
9950
|
"button",
|
|
9290
9951
|
{
|
|
9291
9952
|
className: "ai-modal-action-btn ai-modal-insert-after-btn ms-2",
|
|
@@ -9293,22 +9954,22 @@ var AICommands = ({ editor, onAICommand }) => {
|
|
|
9293
9954
|
disabled: loading || !resultText
|
|
9294
9955
|
},
|
|
9295
9956
|
"Insert After"
|
|
9296
|
-
), /* @__PURE__ */
|
|
9957
|
+
), /* @__PURE__ */ React110.createElement(Tooltip, { title: "Generate another response", placement: "top" }, /* @__PURE__ */ React110.createElement(
|
|
9297
9958
|
"button",
|
|
9298
9959
|
{
|
|
9299
9960
|
className: "ai-modal-action-btn ai-modal-refresh-btn",
|
|
9300
9961
|
onClick: handleRefresh,
|
|
9301
9962
|
disabled: loading
|
|
9302
9963
|
},
|
|
9303
|
-
/* @__PURE__ */
|
|
9304
|
-
))), /* @__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")))),
|
|
9305
9966
|
document.body
|
|
9306
9967
|
));
|
|
9307
9968
|
};
|
|
9308
9969
|
var AICommands_default = AICommands;
|
|
9309
9970
|
|
|
9310
9971
|
// lib/RufousTextEditor/TranslateModal.tsx
|
|
9311
|
-
import
|
|
9972
|
+
import React111, { useState as useState30, useMemo as useMemo3 } from "react";
|
|
9312
9973
|
import { createPortal as createPortal3 } from "react-dom";
|
|
9313
9974
|
var LANGUAGES = [
|
|
9314
9975
|
{ code: "af", name: "Afrikaans" },
|
|
@@ -9448,12 +10109,12 @@ async function translateText(text, sourceLang, targetLang) {
|
|
|
9448
10109
|
return null;
|
|
9449
10110
|
}
|
|
9450
10111
|
var TranslateModal = ({ editor, onClose, onTranslate, initialSource, initialTarget, onLangChange }) => {
|
|
9451
|
-
const [sourceLang, setSourceLang] =
|
|
9452
|
-
const [targetLang, setTargetLang] =
|
|
9453
|
-
const [sourceFilter, setSourceFilter] =
|
|
9454
|
-
const [targetFilter, setTargetFilter] =
|
|
9455
|
-
const [translating, setTranslating] =
|
|
9456
|
-
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("");
|
|
9457
10118
|
const filteredSource = useMemo3(() => LANGUAGES.filter(
|
|
9458
10119
|
(l) => l.name.toLowerCase().includes(sourceFilter.toLowerCase()) || l.code.toLowerCase().includes(sourceFilter.toLowerCase())
|
|
9459
10120
|
), [sourceFilter]);
|
|
@@ -9501,7 +10162,7 @@ var TranslateModal = ({ editor, onClose, onTranslate, initialSource, initialTarg
|
|
|
9501
10162
|
}
|
|
9502
10163
|
};
|
|
9503
10164
|
return createPortal3(
|
|
9504
|
-
/* @__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(
|
|
9505
10166
|
"input",
|
|
9506
10167
|
{
|
|
9507
10168
|
type: "text",
|
|
@@ -9510,16 +10171,16 @@ var TranslateModal = ({ editor, onClose, onTranslate, initialSource, initialTarg
|
|
|
9510
10171
|
onChange: (e) => setSourceFilter(e.target.value),
|
|
9511
10172
|
className: "translate-filter-input"
|
|
9512
10173
|
}
|
|
9513
|
-
)), /* @__PURE__ */
|
|
10174
|
+
)), /* @__PURE__ */ React111.createElement("div", { className: "translate-list" }, filteredSource.map((lang) => /* @__PURE__ */ React111.createElement(
|
|
9514
10175
|
"button",
|
|
9515
10176
|
{
|
|
9516
10177
|
key: lang.code,
|
|
9517
10178
|
className: `translate-item ${sourceLang === lang.code ? "active" : ""}`,
|
|
9518
10179
|
onClick: () => setSourceLang(lang.code)
|
|
9519
10180
|
},
|
|
9520
|
-
/* @__PURE__ */
|
|
9521
|
-
/* @__PURE__ */
|
|
9522
|
-
)))), /* @__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(
|
|
9523
10184
|
"input",
|
|
9524
10185
|
{
|
|
9525
10186
|
type: "text",
|
|
@@ -9528,16 +10189,16 @@ var TranslateModal = ({ editor, onClose, onTranslate, initialSource, initialTarg
|
|
|
9528
10189
|
onChange: (e) => setTargetFilter(e.target.value),
|
|
9529
10190
|
className: "translate-filter-input"
|
|
9530
10191
|
}
|
|
9531
|
-
)), /* @__PURE__ */
|
|
10192
|
+
)), /* @__PURE__ */ React111.createElement("div", { className: "translate-list" }, filteredTarget.map((lang) => /* @__PURE__ */ React111.createElement(
|
|
9532
10193
|
"button",
|
|
9533
10194
|
{
|
|
9534
10195
|
key: lang.code,
|
|
9535
10196
|
className: `translate-item ${targetLang === lang.code ? "active" : ""}`,
|
|
9536
10197
|
onClick: () => setTargetLang(lang.code)
|
|
9537
10198
|
},
|
|
9538
|
-
/* @__PURE__ */
|
|
9539
|
-
/* @__PURE__ */
|
|
9540
|
-
))))), 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")))),
|
|
9541
10202
|
document.body
|
|
9542
10203
|
);
|
|
9543
10204
|
};
|
|
@@ -10188,38 +10849,38 @@ var CustomTaskItem = TaskItem.extend({
|
|
|
10188
10849
|
});
|
|
10189
10850
|
|
|
10190
10851
|
// lib/RufousTextEditor/icons.tsx
|
|
10191
|
-
import * as
|
|
10852
|
+
import * as React112 from "react";
|
|
10192
10853
|
var s = { width: 20, height: 20, viewBox: "0 0 24 24", fill: "currentColor", xmlns: "http://www.w3.org/2000/svg" };
|
|
10193
|
-
var IconUndo = () => /* @__PURE__ */
|
|
10194
|
-
var IconRedo = () => /* @__PURE__ */
|
|
10195
|
-
var IconBold = () => /* @__PURE__ */
|
|
10196
|
-
var IconItalic = () => /* @__PURE__ */
|
|
10197
|
-
var IconLink = () => /* @__PURE__ */
|
|
10198
|
-
var IconStrike = () => /* @__PURE__ */
|
|
10199
|
-
var IconHeading = () => /* @__PURE__ */
|
|
10200
|
-
var IconFontSize = () => /* @__PURE__ */
|
|
10201
|
-
var IconColor = () => /* @__PURE__ */
|
|
10202
|
-
var IconFont = () => /* @__PURE__ */
|
|
10203
|
-
var IconLineHeight = () => /* @__PURE__ */
|
|
10204
|
-
var IconBulletList = () => /* @__PURE__ */
|
|
10205
|
-
var IconOrderedList = () => /* @__PURE__ */
|
|
10206
|
-
var IconAlignLeft = () => /* @__PURE__ */
|
|
10207
|
-
var IconAlignCenter = () => /* @__PURE__ */
|
|
10208
|
-
var IconAlignRight = () => /* @__PURE__ */
|
|
10209
|
-
var IconAlignJustify = () => /* @__PURE__ */
|
|
10210
|
-
var IconIndentIncrease = () => /* @__PURE__ */
|
|
10211
|
-
var IconIndentDecrease = () => /* @__PURE__ */
|
|
10212
|
-
var IconTable = () => /* @__PURE__ */
|
|
10213
|
-
var IconImage = () => /* @__PURE__ */
|
|
10214
|
-
var IconVideo = () => /* @__PURE__ */
|
|
10215
|
-
var IconCut = () => /* @__PURE__ */
|
|
10216
|
-
var IconCopy = () => /* @__PURE__ */
|
|
10217
|
-
var IconCode = () => /* @__PURE__ */
|
|
10218
|
-
var IconFullscreen = () => /* @__PURE__ */
|
|
10219
|
-
var IconTranslate = () => /* @__PURE__ */
|
|
10220
|
-
var IconTaskList = () => /* @__PURE__ */
|
|
10221
|
-
var IconCheck = () => /* @__PURE__ */
|
|
10222
|
-
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" }));
|
|
10223
10884
|
|
|
10224
10885
|
// lib/RufousTextEditor/Toolbar.tsx
|
|
10225
10886
|
var COLOR_PALETTE = [
|
|
@@ -10357,10 +11018,10 @@ var SPECIAL_CHARS = [
|
|
|
10357
11018
|
"\xA2"
|
|
10358
11019
|
];
|
|
10359
11020
|
var Dropdown = ({ trigger, children, className = "", keepOpen = false }) => {
|
|
10360
|
-
const [open, setOpen] =
|
|
10361
|
-
const ref =
|
|
10362
|
-
const menuRef =
|
|
10363
|
-
|
|
11021
|
+
const [open, setOpen] = useState31(false);
|
|
11022
|
+
const ref = useRef28(null);
|
|
11023
|
+
const menuRef = useRef28(null);
|
|
11024
|
+
useEffect25(() => {
|
|
10364
11025
|
const handleClick = (e) => {
|
|
10365
11026
|
const target = e.target;
|
|
10366
11027
|
const inTrigger = ref.current?.contains(target);
|
|
@@ -10372,7 +11033,7 @@ var Dropdown = ({ trigger, children, className = "", keepOpen = false }) => {
|
|
|
10372
11033
|
document.addEventListener("mousedown", handleClick);
|
|
10373
11034
|
return () => document.removeEventListener("mousedown", handleClick);
|
|
10374
11035
|
}, []);
|
|
10375
|
-
|
|
11036
|
+
useEffect25(() => {
|
|
10376
11037
|
if (!open || !menuRef.current || !ref.current) return;
|
|
10377
11038
|
const menu = menuRef.current;
|
|
10378
11039
|
const trigger2 = ref.current;
|
|
@@ -10401,22 +11062,22 @@ var Dropdown = ({ trigger, children, className = "", keepOpen = false }) => {
|
|
|
10401
11062
|
};
|
|
10402
11063
|
position();
|
|
10403
11064
|
}, [open]);
|
|
10404
|
-
return /* @__PURE__ */
|
|
11065
|
+
return /* @__PURE__ */ React113.createElement("div", { className: `dropdown ${className}`, ref }, /* @__PURE__ */ React113.createElement(Tooltip, { title: trigger.title || "", placement: "top" }, /* @__PURE__ */ React113.createElement(
|
|
10405
11066
|
"button",
|
|
10406
11067
|
{
|
|
10407
11068
|
className: `toolbar-btn ${trigger.className || ""}`,
|
|
10408
11069
|
onClick: () => setOpen(!open)
|
|
10409
11070
|
},
|
|
10410
11071
|
trigger.label,
|
|
10411
|
-
/* @__PURE__ */
|
|
11072
|
+
/* @__PURE__ */ React113.createElement("span", { className: "dropdown-arrow" }, "\u25BE")
|
|
10412
11073
|
)), open && createPortal4(
|
|
10413
|
-
/* @__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)),
|
|
10414
11075
|
document.body
|
|
10415
11076
|
));
|
|
10416
11077
|
};
|
|
10417
11078
|
var InsertPanel = ({ editor, onClose, mode = "video" }) => {
|
|
10418
|
-
const [activeTab, setActiveTab] =
|
|
10419
|
-
const [url, setUrl] =
|
|
11079
|
+
const [activeTab, setActiveTab] = useState31("link");
|
|
11080
|
+
const [url, setUrl] = useState31("");
|
|
10420
11081
|
const extractIframeSrc = (html) => {
|
|
10421
11082
|
const match = html.match(/<iframe[^>]+src=["']([^"']+)["']/);
|
|
10422
11083
|
return match ? match[1] : null;
|
|
@@ -10448,14 +11109,14 @@ var InsertPanel = ({ editor, onClose, mode = "video" }) => {
|
|
|
10448
11109
|
}
|
|
10449
11110
|
onClose();
|
|
10450
11111
|
};
|
|
10451
|
-
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(
|
|
10452
11113
|
"button",
|
|
10453
11114
|
{
|
|
10454
11115
|
className: `insert-tab ${activeTab === "link" ? "active" : ""}`,
|
|
10455
11116
|
onClick: () => setActiveTab("link")
|
|
10456
11117
|
},
|
|
10457
11118
|
"\u{1F517} Link"
|
|
10458
|
-
), /* @__PURE__ */
|
|
11119
|
+
), /* @__PURE__ */ React113.createElement(
|
|
10459
11120
|
"button",
|
|
10460
11121
|
{
|
|
10461
11122
|
className: `insert-tab ${activeTab === "code" ? "active" : ""}`,
|
|
@@ -10463,7 +11124,7 @@ var InsertPanel = ({ editor, onClose, mode = "video" }) => {
|
|
|
10463
11124
|
},
|
|
10464
11125
|
"</>",
|
|
10465
11126
|
" Code"
|
|
10466
|
-
)), /* @__PURE__ */
|
|
11127
|
+
)), /* @__PURE__ */ React113.createElement("label", { className: "insert-panel-label" }, activeTab === "link" ? "URL" : "Embed Code"), activeTab === "link" ? /* @__PURE__ */ React113.createElement(
|
|
10467
11128
|
"input",
|
|
10468
11129
|
{
|
|
10469
11130
|
type: "text",
|
|
@@ -10474,7 +11135,7 @@ var InsertPanel = ({ editor, onClose, mode = "video" }) => {
|
|
|
10474
11135
|
onKeyDown: (e) => e.key === "Enter" && handleInsert(),
|
|
10475
11136
|
autoFocus: true
|
|
10476
11137
|
}
|
|
10477
|
-
) : /* @__PURE__ */
|
|
11138
|
+
) : /* @__PURE__ */ React113.createElement(
|
|
10478
11139
|
"textarea",
|
|
10479
11140
|
{
|
|
10480
11141
|
className: "insert-panel-textarea",
|
|
@@ -10483,13 +11144,13 @@ var InsertPanel = ({ editor, onClose, mode = "video" }) => {
|
|
|
10483
11144
|
onChange: (e) => setUrl(e.target.value),
|
|
10484
11145
|
rows: 3
|
|
10485
11146
|
}
|
|
10486
|
-
), /* @__PURE__ */
|
|
11147
|
+
), /* @__PURE__ */ React113.createElement("button", { className: "insert-panel-btn", onClick: handleInsert }, "Insert"));
|
|
10487
11148
|
};
|
|
10488
11149
|
var ImagePanel = ({ editor, onClose, onImageUpload }) => {
|
|
10489
|
-
const [activeTab, setActiveTab] =
|
|
10490
|
-
const [url, setUrl] =
|
|
10491
|
-
const [isDragging, setIsDragging] =
|
|
10492
|
-
const fileInputRef =
|
|
11150
|
+
const [activeTab, setActiveTab] = useState31("upload");
|
|
11151
|
+
const [url, setUrl] = useState31("");
|
|
11152
|
+
const [isDragging, setIsDragging] = useState31(false);
|
|
11153
|
+
const fileInputRef = useRef28(null);
|
|
10493
11154
|
const getBase64 = (file) => {
|
|
10494
11155
|
return new Promise((resolve, reject) => {
|
|
10495
11156
|
const reader = new FileReader();
|
|
@@ -10527,21 +11188,21 @@ var ImagePanel = ({ editor, onClose, onImageUpload }) => {
|
|
|
10527
11188
|
editor.chain().focus().setImage({ src: url }).run();
|
|
10528
11189
|
onClose();
|
|
10529
11190
|
};
|
|
10530
|
-
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(
|
|
10531
11192
|
"button",
|
|
10532
11193
|
{
|
|
10533
11194
|
className: `insert-tab ${activeTab === "upload" ? "active" : ""}`,
|
|
10534
11195
|
onClick: () => setActiveTab("upload")
|
|
10535
11196
|
},
|
|
10536
11197
|
"\u2B06 Upload"
|
|
10537
|
-
), /* @__PURE__ */
|
|
11198
|
+
), /* @__PURE__ */ React113.createElement(
|
|
10538
11199
|
"button",
|
|
10539
11200
|
{
|
|
10540
11201
|
className: `insert-tab ${activeTab === "url" ? "active" : ""}`,
|
|
10541
11202
|
onClick: () => setActiveTab("url")
|
|
10542
11203
|
},
|
|
10543
11204
|
"\u{1F517} URL"
|
|
10544
|
-
)), activeTab === "upload" ? /* @__PURE__ */
|
|
11205
|
+
)), activeTab === "upload" ? /* @__PURE__ */ React113.createElement(React113.Fragment, null, /* @__PURE__ */ React113.createElement(
|
|
10545
11206
|
"div",
|
|
10546
11207
|
{
|
|
10547
11208
|
className: `drop-zone ${isDragging ? "dragging" : ""}`,
|
|
@@ -10553,9 +11214,9 @@ var ImagePanel = ({ editor, onClose, onImageUpload }) => {
|
|
|
10553
11214
|
onDrop: handleDrop,
|
|
10554
11215
|
onClick: () => fileInputRef.current?.click()
|
|
10555
11216
|
},
|
|
10556
|
-
/* @__PURE__ */
|
|
10557
|
-
/* @__PURE__ */
|
|
10558
|
-
), /* @__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(
|
|
10559
11220
|
"input",
|
|
10560
11221
|
{
|
|
10561
11222
|
ref: fileInputRef,
|
|
@@ -10564,7 +11225,7 @@ var ImagePanel = ({ editor, onClose, onImageUpload }) => {
|
|
|
10564
11225
|
style: { display: "none" },
|
|
10565
11226
|
onChange: handleFileSelect
|
|
10566
11227
|
}
|
|
10567
|
-
)) : /* @__PURE__ */
|
|
11228
|
+
)) : /* @__PURE__ */ React113.createElement(React113.Fragment, null, /* @__PURE__ */ React113.createElement("label", { className: "insert-panel-label" }, "URL"), /* @__PURE__ */ React113.createElement(
|
|
10568
11229
|
"input",
|
|
10569
11230
|
{
|
|
10570
11231
|
type: "text",
|
|
@@ -10575,18 +11236,18 @@ var ImagePanel = ({ editor, onClose, onImageUpload }) => {
|
|
|
10575
11236
|
onKeyDown: (e) => e.key === "Enter" && handleUrlInsert(),
|
|
10576
11237
|
autoFocus: true
|
|
10577
11238
|
}
|
|
10578
|
-
), /* @__PURE__ */
|
|
11239
|
+
), /* @__PURE__ */ React113.createElement("button", { className: "insert-panel-btn", onClick: handleUrlInsert }, "Insert")));
|
|
10579
11240
|
};
|
|
10580
11241
|
var MAX_GRID = 10;
|
|
10581
11242
|
var TableGridSelector = ({ editor, onClose }) => {
|
|
10582
|
-
const [hoverRow, setHoverRow] =
|
|
10583
|
-
const [hoverCol, setHoverCol] =
|
|
11243
|
+
const [hoverRow, setHoverRow] = useState31(0);
|
|
11244
|
+
const [hoverCol, setHoverCol] = useState31(0);
|
|
10584
11245
|
const handleInsert = () => {
|
|
10585
11246
|
if (!editor || hoverRow === 0 || hoverCol === 0) return;
|
|
10586
11247
|
editor.chain().focus().insertTable({ rows: hoverRow, cols: hoverCol, withHeaderRow: true }).run();
|
|
10587
11248
|
onClose();
|
|
10588
11249
|
};
|
|
10589
|
-
return /* @__PURE__ */
|
|
11250
|
+
return /* @__PURE__ */ React113.createElement("div", { className: "table-grid-panel", onClick: (e) => e.stopPropagation() }, /* @__PURE__ */ React113.createElement(
|
|
10590
11251
|
"div",
|
|
10591
11252
|
{
|
|
10592
11253
|
className: "table-grid",
|
|
@@ -10595,7 +11256,7 @@ var TableGridSelector = ({ editor, onClose }) => {
|
|
|
10595
11256
|
setHoverCol(0);
|
|
10596
11257
|
}
|
|
10597
11258
|
},
|
|
10598
|
-
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(
|
|
10599
11260
|
"div",
|
|
10600
11261
|
{
|
|
10601
11262
|
key: c,
|
|
@@ -10607,7 +11268,7 @@ var TableGridSelector = ({ editor, onClose }) => {
|
|
|
10607
11268
|
onClick: handleInsert
|
|
10608
11269
|
}
|
|
10609
11270
|
))))
|
|
10610
|
-
), /* @__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(
|
|
10611
11272
|
"button",
|
|
10612
11273
|
{
|
|
10613
11274
|
className: "table-grid-submit",
|
|
@@ -10618,9 +11279,9 @@ var TableGridSelector = ({ editor, onClose }) => {
|
|
|
10618
11279
|
)));
|
|
10619
11280
|
};
|
|
10620
11281
|
var ColorPickerPanel = ({ editor, onClose }) => {
|
|
10621
|
-
const [tab, setTab] =
|
|
10622
|
-
const [activeBg, setActiveBg] =
|
|
10623
|
-
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);
|
|
10624
11285
|
const activeColor = tab === "background" ? activeBg : activeText;
|
|
10625
11286
|
const applyColor = (color) => {
|
|
10626
11287
|
if (tab === "background") {
|
|
@@ -10641,51 +11302,51 @@ var ColorPickerPanel = ({ editor, onClose }) => {
|
|
|
10641
11302
|
}
|
|
10642
11303
|
onClose();
|
|
10643
11304
|
};
|
|
10644
|
-
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(
|
|
10645
11306
|
"button",
|
|
10646
11307
|
{
|
|
10647
11308
|
className: `color-picker-tab ${tab === "background" ? "active" : ""}`,
|
|
10648
11309
|
onClick: () => setTab("background")
|
|
10649
11310
|
},
|
|
10650
11311
|
"Background"
|
|
10651
|
-
), /* @__PURE__ */
|
|
11312
|
+
), /* @__PURE__ */ React113.createElement(
|
|
10652
11313
|
"button",
|
|
10653
11314
|
{
|
|
10654
11315
|
className: `color-picker-tab ${tab === "text" ? "active" : ""}`,
|
|
10655
11316
|
onClick: () => setTab("text")
|
|
10656
11317
|
},
|
|
10657
11318
|
"Text"
|
|
10658
|
-
)), /* @__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(
|
|
10659
11320
|
"button",
|
|
10660
11321
|
{
|
|
10661
11322
|
className: `color-picker-swatch ${color === "#ffffff" ? "white-swatch" : ""}${activeColor && activeColor.toLowerCase() === color.toLowerCase() ? " swatch-active" : ""}`,
|
|
10662
11323
|
style: { background: color },
|
|
10663
11324
|
onClick: () => applyColor(color)
|
|
10664
11325
|
}
|
|
10665
|
-
)))), /* @__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"))));
|
|
10666
11327
|
};
|
|
10667
11328
|
var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTextToSpeech, onClose, onImageUpload, visibleButtons, isFullscreen, onToggleFullscreen }) => {
|
|
10668
|
-
const [, setEditorState] =
|
|
10669
|
-
const [todoEnabled, setTodoEnabled] =
|
|
10670
|
-
const ttsRef =
|
|
10671
|
-
const sttRef =
|
|
11329
|
+
const [, setEditorState] = useState31(0);
|
|
11330
|
+
const [todoEnabled, setTodoEnabled] = useState31(false);
|
|
11331
|
+
const ttsRef = useRef28(null);
|
|
11332
|
+
const sttRef = useRef28(null);
|
|
10672
11333
|
const show = (id) => !visibleButtons || visibleButtons.has(id);
|
|
10673
|
-
|
|
11334
|
+
useEffect25(() => {
|
|
10674
11335
|
if (!editor) return;
|
|
10675
11336
|
const onTransaction = () => setEditorState((n) => n + 1);
|
|
10676
11337
|
editor.on("transaction", onTransaction);
|
|
10677
11338
|
return () => editor.off("transaction", onTransaction);
|
|
10678
11339
|
}, [editor]);
|
|
10679
|
-
const insertSpecialChar =
|
|
11340
|
+
const insertSpecialChar = useCallback14((char) => {
|
|
10680
11341
|
if (!editor) return;
|
|
10681
11342
|
editor.chain().focus().insertContent(char).run();
|
|
10682
11343
|
}, [editor]);
|
|
10683
|
-
const [copySuccess, setCopySuccess] =
|
|
10684
|
-
const [translateSource, setTranslateSource] =
|
|
10685
|
-
const [translateTarget, setTranslateTarget] =
|
|
10686
|
-
const [translateStatus, setTranslateStatus] =
|
|
10687
|
-
const [showTranslateModal, setShowTranslateModal] =
|
|
10688
|
-
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 () => {
|
|
10689
11350
|
if (!editor) return;
|
|
10690
11351
|
const { from, to, empty } = editor.state.selection;
|
|
10691
11352
|
if (empty) return;
|
|
@@ -10700,7 +11361,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10700
11361
|
setTimeout(() => setCopySuccess(false), 2e3);
|
|
10701
11362
|
}
|
|
10702
11363
|
}, [editor]);
|
|
10703
|
-
const handlePaste =
|
|
11364
|
+
const handlePaste = useCallback14(async () => {
|
|
10704
11365
|
if (!editor) return;
|
|
10705
11366
|
try {
|
|
10706
11367
|
const text = await navigator.clipboard.readText();
|
|
@@ -10709,7 +11370,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10709
11370
|
document.execCommand("paste");
|
|
10710
11371
|
}
|
|
10711
11372
|
}, [editor]);
|
|
10712
|
-
const handleQuickTranslate =
|
|
11373
|
+
const handleQuickTranslate = useCallback14(async () => {
|
|
10713
11374
|
if (!editor) return;
|
|
10714
11375
|
const { from, to, empty } = editor.state.selection;
|
|
10715
11376
|
if (empty) {
|
|
@@ -10743,32 +11404,32 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10743
11404
|
setTimeout(() => setTranslateStatus(""), 2e3);
|
|
10744
11405
|
}, [editor, translateSource, translateTarget, onTranslate]);
|
|
10745
11406
|
if (!editor) return null;
|
|
10746
|
-
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(
|
|
10747
11408
|
"button",
|
|
10748
11409
|
{
|
|
10749
11410
|
className: "toolbar-btn",
|
|
10750
11411
|
onClick: () => editor.chain().focus().undo().run(),
|
|
10751
11412
|
disabled: !editor.can().undo()
|
|
10752
11413
|
},
|
|
10753
|
-
/* @__PURE__ */
|
|
10754
|
-
)), 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(
|
|
10755
11416
|
"button",
|
|
10756
11417
|
{
|
|
10757
11418
|
className: "toolbar-btn",
|
|
10758
11419
|
onClick: () => editor.chain().focus().redo().run(),
|
|
10759
11420
|
disabled: !editor.can().redo()
|
|
10760
11421
|
},
|
|
10761
|
-
/* @__PURE__ */
|
|
10762
|
-
))), 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(
|
|
10763
11424
|
Dropdown,
|
|
10764
11425
|
{
|
|
10765
11426
|
trigger: {
|
|
10766
|
-
label: /* @__PURE__ */
|
|
11427
|
+
label: /* @__PURE__ */ React113.createElement(IconHeading, null),
|
|
10767
11428
|
title: "Block type",
|
|
10768
11429
|
className: editor.isActive("heading") ? "is-active" : ""
|
|
10769
11430
|
}
|
|
10770
11431
|
},
|
|
10771
|
-
/* @__PURE__ */
|
|
11432
|
+
/* @__PURE__ */ React113.createElement(
|
|
10772
11433
|
"button",
|
|
10773
11434
|
{
|
|
10774
11435
|
className: `dropdown-item ${!editor.isActive("heading") && !editor.isActive("blockquote") && !editor.isActive("codeBlock") ? "is-active" : ""}`,
|
|
@@ -10776,7 +11437,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10776
11437
|
},
|
|
10777
11438
|
"\xB6 Paragraph"
|
|
10778
11439
|
),
|
|
10779
|
-
/* @__PURE__ */
|
|
11440
|
+
/* @__PURE__ */ React113.createElement(
|
|
10780
11441
|
"button",
|
|
10781
11442
|
{
|
|
10782
11443
|
className: `dropdown-item heading-1 ${editor.isActive("heading", { level: 1 }) ? "is-active" : ""}`,
|
|
@@ -10784,7 +11445,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10784
11445
|
},
|
|
10785
11446
|
"Heading 1"
|
|
10786
11447
|
),
|
|
10787
|
-
/* @__PURE__ */
|
|
11448
|
+
/* @__PURE__ */ React113.createElement(
|
|
10788
11449
|
"button",
|
|
10789
11450
|
{
|
|
10790
11451
|
className: `dropdown-item heading-2 ${editor.isActive("heading", { level: 2 }) ? "is-active" : ""}`,
|
|
@@ -10792,7 +11453,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10792
11453
|
},
|
|
10793
11454
|
"Heading 2"
|
|
10794
11455
|
),
|
|
10795
|
-
/* @__PURE__ */
|
|
11456
|
+
/* @__PURE__ */ React113.createElement(
|
|
10796
11457
|
"button",
|
|
10797
11458
|
{
|
|
10798
11459
|
className: `dropdown-item heading-3 ${editor.isActive("heading", { level: 3 }) ? "is-active" : ""}`,
|
|
@@ -10800,7 +11461,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10800
11461
|
},
|
|
10801
11462
|
"Heading 3"
|
|
10802
11463
|
),
|
|
10803
|
-
/* @__PURE__ */
|
|
11464
|
+
/* @__PURE__ */ React113.createElement(
|
|
10804
11465
|
"button",
|
|
10805
11466
|
{
|
|
10806
11467
|
className: `dropdown-item heading-4 ${editor.isActive("heading", { level: 4 }) ? "is-active" : ""}`,
|
|
@@ -10808,7 +11469,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10808
11469
|
},
|
|
10809
11470
|
"Heading 4"
|
|
10810
11471
|
),
|
|
10811
|
-
/* @__PURE__ */
|
|
11472
|
+
/* @__PURE__ */ React113.createElement(
|
|
10812
11473
|
"button",
|
|
10813
11474
|
{
|
|
10814
11475
|
className: `dropdown-item ${editor.isActive("blockquote") ? "is-active" : ""}`,
|
|
@@ -10816,7 +11477,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10816
11477
|
},
|
|
10817
11478
|
"\u275E Blockquote"
|
|
10818
11479
|
),
|
|
10819
|
-
/* @__PURE__ */
|
|
11480
|
+
/* @__PURE__ */ React113.createElement(
|
|
10820
11481
|
"button",
|
|
10821
11482
|
{
|
|
10822
11483
|
className: `dropdown-item ${editor.isActive("codeBlock") ? "is-active" : ""}`,
|
|
@@ -10825,19 +11486,19 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10825
11486
|
"{ }",
|
|
10826
11487
|
" Code Block"
|
|
10827
11488
|
),
|
|
10828
|
-
/* @__PURE__ */
|
|
10829
|
-
), 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(
|
|
10830
11491
|
Dropdown,
|
|
10831
11492
|
{
|
|
10832
11493
|
trigger: {
|
|
10833
|
-
label: /* @__PURE__ */
|
|
11494
|
+
label: /* @__PURE__ */ React113.createElement(IconFontSize, null),
|
|
10834
11495
|
title: "Font size"
|
|
10835
11496
|
}
|
|
10836
11497
|
},
|
|
10837
11498
|
[8, 9, 10, 11, 12, 14, 16, 18, 20, 24, 28, 32, 36, 42, 48, 56, 64, 72, 80, 96].map((size) => {
|
|
10838
11499
|
const sizeStr = `${size}px`;
|
|
10839
11500
|
const isActive = editor.getAttributes("textStyle").fontSize === sizeStr;
|
|
10840
|
-
return /* @__PURE__ */
|
|
11501
|
+
return /* @__PURE__ */ React113.createElement(
|
|
10841
11502
|
"button",
|
|
10842
11503
|
{
|
|
10843
11504
|
key: size,
|
|
@@ -10853,17 +11514,17 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10853
11514
|
sizeStr
|
|
10854
11515
|
);
|
|
10855
11516
|
})
|
|
10856
|
-
), show("font") && /* @__PURE__ */
|
|
11517
|
+
), show("font") && /* @__PURE__ */ React113.createElement(
|
|
10857
11518
|
Dropdown,
|
|
10858
11519
|
{
|
|
10859
11520
|
trigger: {
|
|
10860
|
-
label: /* @__PURE__ */
|
|
11521
|
+
label: /* @__PURE__ */ React113.createElement(IconFont, null),
|
|
10861
11522
|
title: "Font family"
|
|
10862
11523
|
}
|
|
10863
11524
|
},
|
|
10864
11525
|
FONT_FAMILIES.map((font) => {
|
|
10865
11526
|
const isActive = editor.getAttributes("textStyle").fontFamily === font;
|
|
10866
|
-
return /* @__PURE__ */
|
|
11527
|
+
return /* @__PURE__ */ React113.createElement(
|
|
10867
11528
|
"button",
|
|
10868
11529
|
{
|
|
10869
11530
|
key: font,
|
|
@@ -10880,40 +11541,40 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10880
11541
|
font
|
|
10881
11542
|
);
|
|
10882
11543
|
})
|
|
10883
|
-
), show("color") && /* @__PURE__ */
|
|
11544
|
+
), show("color") && /* @__PURE__ */ React113.createElement(
|
|
10884
11545
|
Dropdown,
|
|
10885
11546
|
{
|
|
10886
11547
|
trigger: {
|
|
10887
|
-
label: /* @__PURE__ */
|
|
11548
|
+
label: /* @__PURE__ */ React113.createElement("span", { style: { display: "flex", alignItems: "center" } }, /* @__PURE__ */ React113.createElement(IconColor, null)),
|
|
10888
11549
|
title: "Colors"
|
|
10889
11550
|
},
|
|
10890
11551
|
keepOpen: true
|
|
10891
11552
|
},
|
|
10892
|
-
(close) => /* @__PURE__ */
|
|
10893
|
-
), 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(
|
|
10894
11555
|
"button",
|
|
10895
11556
|
{
|
|
10896
11557
|
className: `toolbar-btn ${editor.isActive("bold") ? "is-active" : ""}`,
|
|
10897
11558
|
onClick: () => editor.chain().focus().toggleBold().run()
|
|
10898
11559
|
},
|
|
10899
|
-
/* @__PURE__ */
|
|
10900
|
-
)), 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(
|
|
10901
11562
|
"button",
|
|
10902
11563
|
{
|
|
10903
11564
|
className: `toolbar-btn ${editor.isActive("italic") ? "is-active" : ""}`,
|
|
10904
11565
|
onClick: () => editor.chain().focus().toggleItalic().run()
|
|
10905
11566
|
},
|
|
10906
|
-
/* @__PURE__ */
|
|
10907
|
-
)), show("strike") && /* @__PURE__ */
|
|
11567
|
+
/* @__PURE__ */ React113.createElement(IconItalic, null)
|
|
11568
|
+
)), show("strike") && /* @__PURE__ */ React113.createElement(
|
|
10908
11569
|
Dropdown,
|
|
10909
11570
|
{
|
|
10910
|
-
trigger: { label: /* @__PURE__ */
|
|
11571
|
+
trigger: { label: /* @__PURE__ */ React113.createElement(IconStrike, null), title: "Text decoration", className: editor.isActive("strike") ? "is-active" : "" }
|
|
10911
11572
|
},
|
|
10912
|
-
/* @__PURE__ */
|
|
10913
|
-
/* @__PURE__ */
|
|
10914
|
-
/* @__PURE__ */
|
|
10915
|
-
/* @__PURE__ */
|
|
10916
|
-
/* @__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) => {
|
|
10917
11578
|
e.preventDefault();
|
|
10918
11579
|
const chain = editor.chain().focus();
|
|
10919
11580
|
if (!editor.state.selection.empty) {
|
|
@@ -10929,25 +11590,25 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10929
11590
|
c.run();
|
|
10930
11591
|
}
|
|
10931
11592
|
} }, "\u2715 Clear formatting")
|
|
10932
|
-
), show("link") && /* @__PURE__ */
|
|
11593
|
+
), show("link") && /* @__PURE__ */ React113.createElement(Tooltip, { title: "Insert Link", placement: "top" }, /* @__PURE__ */ React113.createElement(
|
|
10933
11594
|
"button",
|
|
10934
11595
|
{
|
|
10935
11596
|
className: `toolbar-btn ${editor.isActive("link") ? "is-active" : ""}`,
|
|
10936
11597
|
onClick: setLink
|
|
10937
11598
|
},
|
|
10938
|
-
/* @__PURE__ */
|
|
10939
|
-
)), show("lineheight") && /* @__PURE__ */
|
|
11599
|
+
/* @__PURE__ */ React113.createElement(IconLink, null)
|
|
11600
|
+
)), show("lineheight") && /* @__PURE__ */ React113.createElement(
|
|
10940
11601
|
Dropdown,
|
|
10941
11602
|
{
|
|
10942
11603
|
trigger: {
|
|
10943
|
-
label: /* @__PURE__ */
|
|
11604
|
+
label: /* @__PURE__ */ React113.createElement(IconLineHeight, null),
|
|
10944
11605
|
title: "Line height"
|
|
10945
11606
|
}
|
|
10946
11607
|
},
|
|
10947
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) => {
|
|
10948
11609
|
const currentLH = editor.getAttributes("paragraph").lineHeight || editor.getAttributes("heading").lineHeight;
|
|
10949
11610
|
const isActive = currentLH === lh;
|
|
10950
|
-
return /* @__PURE__ */
|
|
11611
|
+
return /* @__PURE__ */ React113.createElement(
|
|
10951
11612
|
"button",
|
|
10952
11613
|
{
|
|
10953
11614
|
key: lh,
|
|
@@ -10963,19 +11624,19 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
10963
11624
|
lh
|
|
10964
11625
|
);
|
|
10965
11626
|
})
|
|
10966
|
-
)), (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(
|
|
10967
11628
|
"button",
|
|
10968
11629
|
{
|
|
10969
11630
|
className: `toolbar-btn ${editor.isActive("bulletList") ? "is-active" : ""}`,
|
|
10970
11631
|
onClick: () => editor.chain().focus().toggleBulletList().run()
|
|
10971
11632
|
},
|
|
10972
|
-
/* @__PURE__ */
|
|
10973
|
-
)), /* @__PURE__ */
|
|
11633
|
+
/* @__PURE__ */ React113.createElement(IconBulletList, null)
|
|
11634
|
+
)), /* @__PURE__ */ React113.createElement(Dropdown, { trigger: { label: "", title: "List style", className: "list-arrow-btn" }, keepOpen: true }, [
|
|
10974
11635
|
{ label: "Default", style: null, icon: "\u2022" },
|
|
10975
11636
|
{ label: "Circle", style: "circle", icon: "\u25CB" },
|
|
10976
11637
|
{ label: "Dot", style: "disc", icon: "\u2219" },
|
|
10977
11638
|
{ label: "Square", style: "square", icon: "\u25A0" }
|
|
10978
|
-
].map((item) => /* @__PURE__ */
|
|
11639
|
+
].map((item) => /* @__PURE__ */ React113.createElement(
|
|
10979
11640
|
"button",
|
|
10980
11641
|
{
|
|
10981
11642
|
key: item.label,
|
|
@@ -11000,24 +11661,24 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11000
11661
|
}).run();
|
|
11001
11662
|
}
|
|
11002
11663
|
},
|
|
11003
|
-
/* @__PURE__ */
|
|
11664
|
+
/* @__PURE__ */ React113.createElement("span", { className: "bullet-style-icon" }, item.icon),
|
|
11004
11665
|
" ",
|
|
11005
11666
|
item.label
|
|
11006
|
-
)))), 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(
|
|
11007
11668
|
"button",
|
|
11008
11669
|
{
|
|
11009
11670
|
className: `toolbar-btn ${editor.isActive("orderedList") ? "is-active" : ""}`,
|
|
11010
11671
|
onClick: () => editor.chain().focus().toggleOrderedList().run()
|
|
11011
11672
|
},
|
|
11012
|
-
/* @__PURE__ */
|
|
11013
|
-
)), /* @__PURE__ */
|
|
11673
|
+
/* @__PURE__ */ React113.createElement(IconOrderedList, null)
|
|
11674
|
+
)), /* @__PURE__ */ React113.createElement(Dropdown, { trigger: { label: "", title: "List style", className: "list-arrow-btn" }, keepOpen: true }, [
|
|
11014
11675
|
{ label: "Default", style: "decimal", icon: "1." },
|
|
11015
11676
|
{ label: "Lower Alpha", style: "lower-alpha", icon: "a." },
|
|
11016
11677
|
{ label: "Lower Greek", style: "lower-greek", icon: "\u03B1." },
|
|
11017
11678
|
{ label: "Lower Roman", style: "lower-roman", icon: "i." },
|
|
11018
11679
|
{ label: "Upper Alpha", style: "upper-alpha", icon: "A." },
|
|
11019
11680
|
{ label: "Upper Roman", style: "upper-roman", icon: "I." }
|
|
11020
|
-
].map((item) => /* @__PURE__ */
|
|
11681
|
+
].map((item) => /* @__PURE__ */ React113.createElement(
|
|
11021
11682
|
"button",
|
|
11022
11683
|
{
|
|
11023
11684
|
key: item.label,
|
|
@@ -11042,24 +11703,24 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11042
11703
|
}).run();
|
|
11043
11704
|
}
|
|
11044
11705
|
},
|
|
11045
|
-
/* @__PURE__ */
|
|
11706
|
+
/* @__PURE__ */ React113.createElement("span", { className: "bullet-style-icon" }, item.icon),
|
|
11046
11707
|
" ",
|
|
11047
11708
|
item.label
|
|
11048
|
-
))))), (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(
|
|
11049
11710
|
Dropdown,
|
|
11050
11711
|
{
|
|
11051
11712
|
trigger: {
|
|
11052
|
-
label: /* @__PURE__ */
|
|
11713
|
+
label: /* @__PURE__ */ React113.createElement(IconAlignLeft, null),
|
|
11053
11714
|
title: "Align",
|
|
11054
11715
|
className: editor.isActive({ textAlign: "center" }) || editor.isActive({ textAlign: "right" }) || editor.isActive({ textAlign: "justify" }) ? "is-active" : ""
|
|
11055
11716
|
}
|
|
11056
11717
|
},
|
|
11057
11718
|
[
|
|
11058
|
-
{ label: "Align Left", value: "left", icon: /* @__PURE__ */
|
|
11059
|
-
{ label: "Align Center", value: "center", icon: /* @__PURE__ */
|
|
11060
|
-
{ label: "Align Right", value: "right", icon: /* @__PURE__ */
|
|
11061
|
-
{ label: "Align Justify", value: "justify", icon: /* @__PURE__ */
|
|
11062
|
-
].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(
|
|
11063
11724
|
"button",
|
|
11064
11725
|
{
|
|
11065
11726
|
key: item.value,
|
|
@@ -11070,7 +11731,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11070
11731
|
" ",
|
|
11071
11732
|
item.label
|
|
11072
11733
|
))
|
|
11073
|
-
), show("indent") && /* @__PURE__ */
|
|
11734
|
+
), show("indent") && /* @__PURE__ */ React113.createElement(Tooltip, { title: "Increase Indent", placement: "top" }, /* @__PURE__ */ React113.createElement(
|
|
11074
11735
|
"button",
|
|
11075
11736
|
{
|
|
11076
11737
|
className: "toolbar-btn",
|
|
@@ -11089,8 +11750,8 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11089
11750
|
}).run();
|
|
11090
11751
|
}
|
|
11091
11752
|
},
|
|
11092
|
-
/* @__PURE__ */
|
|
11093
|
-
)), show("outdent") && /* @__PURE__ */
|
|
11753
|
+
/* @__PURE__ */ React113.createElement(IconIndentIncrease, null)
|
|
11754
|
+
)), show("outdent") && /* @__PURE__ */ React113.createElement(Tooltip, { title: "Decrease Indent", placement: "top" }, /* @__PURE__ */ React113.createElement(
|
|
11094
11755
|
"button",
|
|
11095
11756
|
{
|
|
11096
11757
|
className: "toolbar-btn",
|
|
@@ -11109,29 +11770,29 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11109
11770
|
}).run();
|
|
11110
11771
|
}
|
|
11111
11772
|
},
|
|
11112
|
-
/* @__PURE__ */
|
|
11113
|
-
))), 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(
|
|
11114
11775
|
"button",
|
|
11115
11776
|
{
|
|
11116
11777
|
className: "toolbar-btn",
|
|
11117
11778
|
onClick: () => document.execCommand("cut")
|
|
11118
11779
|
},
|
|
11119
|
-
/* @__PURE__ */
|
|
11120
|
-
)), 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(
|
|
11121
11782
|
"button",
|
|
11122
11783
|
{
|
|
11123
11784
|
className: "toolbar-btn",
|
|
11124
11785
|
onClick: handleCopy
|
|
11125
11786
|
},
|
|
11126
|
-
copySuccess ? /* @__PURE__ */
|
|
11127
|
-
)), 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(
|
|
11128
11789
|
"button",
|
|
11129
11790
|
{
|
|
11130
11791
|
className: "toolbar-btn",
|
|
11131
11792
|
onClick: handlePaste
|
|
11132
11793
|
},
|
|
11133
|
-
/* @__PURE__ */
|
|
11134
|
-
)), 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(
|
|
11135
11796
|
"button",
|
|
11136
11797
|
{
|
|
11137
11798
|
key: char,
|
|
@@ -11139,12 +11800,12 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11139
11800
|
onClick: () => insertSpecialChar(char)
|
|
11140
11801
|
},
|
|
11141
11802
|
char
|
|
11142
|
-
)))), show("code") && /* @__PURE__ */
|
|
11803
|
+
)))), show("code") && /* @__PURE__ */ React113.createElement(
|
|
11143
11804
|
Dropdown,
|
|
11144
11805
|
{
|
|
11145
|
-
trigger: { label: /* @__PURE__ */
|
|
11806
|
+
trigger: { label: /* @__PURE__ */ React113.createElement(IconCode, null), title: "Code", className: editor.isActive("code") || editor.isActive("codeBlock") ? "is-active" : "" }
|
|
11146
11807
|
},
|
|
11147
|
-
/* @__PURE__ */
|
|
11808
|
+
/* @__PURE__ */ React113.createElement("button", { className: "dropdown-item", onClick: () => {
|
|
11148
11809
|
if (editor.isActive("codeBlock")) {
|
|
11149
11810
|
const text = (() => {
|
|
11150
11811
|
const { $from } = editor.state.selection;
|
|
@@ -11162,22 +11823,22 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11162
11823
|
editor.chain().focus().toggleCode().run();
|
|
11163
11824
|
}
|
|
11164
11825
|
} }, "</>", " Inline Code"),
|
|
11165
|
-
/* @__PURE__ */
|
|
11166
|
-
), 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(
|
|
11167
11828
|
"button",
|
|
11168
11829
|
{
|
|
11169
11830
|
className: `toolbar-btn ${isFullscreen ? "is-active" : ""}`,
|
|
11170
11831
|
onClick: onToggleFullscreen
|
|
11171
11832
|
},
|
|
11172
|
-
/* @__PURE__ */
|
|
11173
|
-
)), 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(
|
|
11174
11835
|
"button",
|
|
11175
11836
|
{
|
|
11176
11837
|
className: "toolbar-btn",
|
|
11177
11838
|
onClick: handleQuickTranslate
|
|
11178
11839
|
},
|
|
11179
|
-
/* @__PURE__ */
|
|
11180
|
-
)), /* @__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(
|
|
11181
11842
|
"button",
|
|
11182
11843
|
{
|
|
11183
11844
|
className: `toolbar-btn ${todoEnabled ? "is-active" : ""}`,
|
|
@@ -11220,11 +11881,11 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11220
11881
|
}
|
|
11221
11882
|
}
|
|
11222
11883
|
},
|
|
11223
|
-
/* @__PURE__ */
|
|
11224
|
-
)), /* @__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) => {
|
|
11225
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" };
|
|
11226
11887
|
const labels = { todo: "Todo", working: "Working", blocked: "Blocked", resolved: "Resolved" };
|
|
11227
|
-
return /* @__PURE__ */
|
|
11888
|
+
return /* @__PURE__ */ React113.createElement("button", { key: status, className: "dropdown-item task-status-item", onClick: () => {
|
|
11228
11889
|
const { state } = editor;
|
|
11229
11890
|
const { schema } = state;
|
|
11230
11891
|
const taskItemType = schema.nodes.taskItem;
|
|
@@ -11257,8 +11918,8 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11257
11918
|
}
|
|
11258
11919
|
return true;
|
|
11259
11920
|
}).run();
|
|
11260
|
-
} }, /* @__PURE__ */
|
|
11261
|
-
})))), 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(
|
|
11262
11923
|
"button",
|
|
11263
11924
|
{
|
|
11264
11925
|
className: "toolbar-btn btn-cross",
|
|
@@ -11274,8 +11935,8 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11274
11935
|
onClose();
|
|
11275
11936
|
}
|
|
11276
11937
|
},
|
|
11277
|
-
/* @__PURE__ */
|
|
11278
|
-
))), showTranslateModal && /* @__PURE__ */
|
|
11938
|
+
/* @__PURE__ */ React113.createElement(closeIcon_default, { color: "#a81c08" })
|
|
11939
|
+
))), showTranslateModal && /* @__PURE__ */ React113.createElement(
|
|
11279
11940
|
TranslateModal_default,
|
|
11280
11941
|
{
|
|
11281
11942
|
editor,
|
|
@@ -11293,7 +11954,7 @@ var Toolbar = ({ editor, setLink, onAICommand, onTranslate, onSpeechToText, onTe
|
|
|
11293
11954
|
var Toolbar_default = Toolbar;
|
|
11294
11955
|
|
|
11295
11956
|
// lib/RufousTextEditor/ImageToolbar.tsx
|
|
11296
|
-
import
|
|
11957
|
+
import React114, { useState as useState32, useEffect as useEffect26, useRef as useRef29 } from "react";
|
|
11297
11958
|
import { createPortal as createPortal5 } from "react-dom";
|
|
11298
11959
|
var ALIGNMENTS = [
|
|
11299
11960
|
{ value: "left", label: "Left", icon: "\u2630" },
|
|
@@ -11301,18 +11962,18 @@ var ALIGNMENTS = [
|
|
|
11301
11962
|
{ value: "right", label: "Right", icon: "\u2263" }
|
|
11302
11963
|
];
|
|
11303
11964
|
var ImagePropertiesModal = ({ editor, node, onClose }) => {
|
|
11304
|
-
const [activeTab, setActiveTab] =
|
|
11305
|
-
const [src, setSrc] =
|
|
11306
|
-
const [title, setTitle] =
|
|
11307
|
-
const [alt, setAlt] =
|
|
11308
|
-
const [link, setLink] =
|
|
11309
|
-
const [openInNewTab, setOpenInNewTab] =
|
|
11310
|
-
const [width, setWidth] =
|
|
11311
|
-
const [height, setHeight] =
|
|
11312
|
-
const [lockRatio, setLockRatio] =
|
|
11313
|
-
const [naturalWidth, setNaturalWidth] =
|
|
11314
|
-
const [naturalHeight, setNaturalHeight] =
|
|
11315
|
-
|
|
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(() => {
|
|
11316
11977
|
if (src) {
|
|
11317
11978
|
const img = new window.Image();
|
|
11318
11979
|
img.onload = () => {
|
|
@@ -11351,7 +12012,7 @@ var ImagePropertiesModal = ({ editor, node, onClose }) => {
|
|
|
11351
12012
|
editor.chain().focus().deleteSelection().run();
|
|
11352
12013
|
onClose();
|
|
11353
12014
|
};
|
|
11354
|
-
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(
|
|
11355
12016
|
"input",
|
|
11356
12017
|
{
|
|
11357
12018
|
type: "number",
|
|
@@ -11359,14 +12020,14 @@ var ImagePropertiesModal = ({ editor, node, onClose }) => {
|
|
|
11359
12020
|
value: width,
|
|
11360
12021
|
onChange: (e) => handleWidthChange(e.target.value)
|
|
11361
12022
|
}
|
|
11362
|
-
), /* @__PURE__ */
|
|
12023
|
+
), /* @__PURE__ */ React114.createElement(Tooltip, { title: lockRatio ? "Unlock aspect ratio" : "Lock aspect ratio", placement: "top" }, /* @__PURE__ */ React114.createElement(
|
|
11363
12024
|
"button",
|
|
11364
12025
|
{
|
|
11365
12026
|
className: `lock-btn ${lockRatio ? "locked" : ""}`,
|
|
11366
12027
|
onClick: () => setLockRatio(!lockRatio)
|
|
11367
12028
|
},
|
|
11368
12029
|
lockRatio ? "\u{1F512}" : "\u{1F513}"
|
|
11369
|
-
)), /* @__PURE__ */
|
|
12030
|
+
)), /* @__PURE__ */ React114.createElement(
|
|
11370
12031
|
"input",
|
|
11371
12032
|
{
|
|
11372
12033
|
type: "number",
|
|
@@ -11374,21 +12035,21 @@ var ImagePropertiesModal = ({ editor, node, onClose }) => {
|
|
|
11374
12035
|
value: height,
|
|
11375
12036
|
onChange: (e) => handleHeightChange(e.target.value)
|
|
11376
12037
|
}
|
|
11377
|
-
))), /* @__PURE__ */
|
|
12038
|
+
))), /* @__PURE__ */ React114.createElement("div", { className: "modal-fields-col" }, /* @__PURE__ */ React114.createElement("div", { className: "modal-tabs" }, /* @__PURE__ */ React114.createElement(
|
|
11378
12039
|
"button",
|
|
11379
12040
|
{
|
|
11380
12041
|
className: `modal-tab ${activeTab === "image" ? "active" : ""}`,
|
|
11381
12042
|
onClick: () => setActiveTab("image")
|
|
11382
12043
|
},
|
|
11383
12044
|
"Image"
|
|
11384
|
-
), /* @__PURE__ */
|
|
12045
|
+
), /* @__PURE__ */ React114.createElement(
|
|
11385
12046
|
"button",
|
|
11386
12047
|
{
|
|
11387
12048
|
className: `modal-tab ${activeTab === "advanced" ? "active" : ""}`,
|
|
11388
12049
|
onClick: () => setActiveTab("advanced")
|
|
11389
12050
|
},
|
|
11390
12051
|
"Advanced"
|
|
11391
|
-
)), activeTab === "image" ? /* @__PURE__ */
|
|
12052
|
+
)), activeTab === "image" ? /* @__PURE__ */ React114.createElement(React114.Fragment, null, /* @__PURE__ */ React114.createElement("label", { className: "modal-label" }, "Src"), /* @__PURE__ */ React114.createElement(
|
|
11392
12053
|
"input",
|
|
11393
12054
|
{
|
|
11394
12055
|
type: "text",
|
|
@@ -11396,7 +12057,7 @@ var ImagePropertiesModal = ({ editor, node, onClose }) => {
|
|
|
11396
12057
|
value: src,
|
|
11397
12058
|
onChange: (e) => setSrc(e.target.value)
|
|
11398
12059
|
}
|
|
11399
|
-
), /* @__PURE__ */
|
|
12060
|
+
), /* @__PURE__ */ React114.createElement("label", { className: "modal-label" }, "Title"), /* @__PURE__ */ React114.createElement(
|
|
11400
12061
|
"input",
|
|
11401
12062
|
{
|
|
11402
12063
|
type: "text",
|
|
@@ -11404,7 +12065,7 @@ var ImagePropertiesModal = ({ editor, node, onClose }) => {
|
|
|
11404
12065
|
value: title,
|
|
11405
12066
|
onChange: (e) => setTitle(e.target.value)
|
|
11406
12067
|
}
|
|
11407
|
-
), /* @__PURE__ */
|
|
12068
|
+
), /* @__PURE__ */ React114.createElement("label", { className: "modal-label" }, "Alternative"), /* @__PURE__ */ React114.createElement(
|
|
11408
12069
|
"input",
|
|
11409
12070
|
{
|
|
11410
12071
|
type: "text",
|
|
@@ -11412,7 +12073,7 @@ var ImagePropertiesModal = ({ editor, node, onClose }) => {
|
|
|
11412
12073
|
value: alt,
|
|
11413
12074
|
onChange: (e) => setAlt(e.target.value)
|
|
11414
12075
|
}
|
|
11415
|
-
), /* @__PURE__ */
|
|
12076
|
+
), /* @__PURE__ */ React114.createElement("label", { className: "modal-label" }, "Link"), /* @__PURE__ */ React114.createElement(
|
|
11416
12077
|
"input",
|
|
11417
12078
|
{
|
|
11418
12079
|
type: "text",
|
|
@@ -11420,23 +12081,23 @@ var ImagePropertiesModal = ({ editor, node, onClose }) => {
|
|
|
11420
12081
|
value: link,
|
|
11421
12082
|
onChange: (e) => setLink(e.target.value)
|
|
11422
12083
|
}
|
|
11423
|
-
), /* @__PURE__ */
|
|
12084
|
+
), /* @__PURE__ */ React114.createElement("label", { className: "modal-checkbox" }, /* @__PURE__ */ React114.createElement(
|
|
11424
12085
|
"input",
|
|
11425
12086
|
{
|
|
11426
12087
|
type: "checkbox",
|
|
11427
12088
|
checked: openInNewTab,
|
|
11428
12089
|
onChange: (e) => setOpenInNewTab(e.target.checked)
|
|
11429
12090
|
}
|
|
11430
|
-
), "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"))));
|
|
11431
12092
|
};
|
|
11432
12093
|
var ImageToolbar = ({ editor }) => {
|
|
11433
|
-
const [showModal, setShowModal] =
|
|
11434
|
-
const [showAlign, setShowAlign] =
|
|
11435
|
-
const [showVAlign, setShowVAlign] =
|
|
11436
|
-
const [copyStatus, setCopyStatus] =
|
|
11437
|
-
const [pos, setPos] =
|
|
11438
|
-
const toolbarRef =
|
|
11439
|
-
|
|
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(() => {
|
|
11440
12101
|
if (!editor) return;
|
|
11441
12102
|
const update = () => {
|
|
11442
12103
|
const { selection } = editor.state;
|
|
@@ -11466,7 +12127,7 @@ var ImageToolbar = ({ editor }) => {
|
|
|
11466
12127
|
const node = editor?.state.selection.node;
|
|
11467
12128
|
const isImage = node && node.type.name === "image";
|
|
11468
12129
|
if (!editor || !isImage || !pos) return showModal ? createPortal5(
|
|
11469
|
-
/* @__PURE__ */
|
|
12130
|
+
/* @__PURE__ */ React114.createElement(ImagePropertiesModal, { editor, node, onClose: () => setShowModal(false) }),
|
|
11470
12131
|
document.body
|
|
11471
12132
|
) : null;
|
|
11472
12133
|
const handleDelete = () => {
|
|
@@ -11543,7 +12204,7 @@ var ImageToolbar = ({ editor }) => {
|
|
|
11543
12204
|
setShowVAlign(false);
|
|
11544
12205
|
};
|
|
11545
12206
|
return createPortal5(
|
|
11546
|
-
/* @__PURE__ */
|
|
12207
|
+
/* @__PURE__ */ React114.createElement(React114.Fragment, null, /* @__PURE__ */ React114.createElement(
|
|
11547
12208
|
"div",
|
|
11548
12209
|
{
|
|
11549
12210
|
className: "image-toolbar",
|
|
@@ -11551,14 +12212,14 @@ var ImageToolbar = ({ editor }) => {
|
|
|
11551
12212
|
style: { position: "absolute", top: pos.top, left: pos.left, zIndex: 1e3 },
|
|
11552
12213
|
onMouseDown: (e) => e.preventDefault()
|
|
11553
12214
|
},
|
|
11554
|
-
/* @__PURE__ */
|
|
11555
|
-
/* @__PURE__ */
|
|
11556
|
-
/* @__PURE__ */
|
|
11557
|
-
/* @__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: () => {
|
|
11558
12219
|
setShowAlign(!showAlign);
|
|
11559
12220
|
setShowVAlign(false);
|
|
11560
|
-
} }, "\u2630 ", /* @__PURE__ */
|
|
11561
|
-
), 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(
|
|
11562
12223
|
ImagePropertiesModal,
|
|
11563
12224
|
{
|
|
11564
12225
|
editor,
|
|
@@ -11572,7 +12233,7 @@ var ImageToolbar = ({ editor }) => {
|
|
|
11572
12233
|
var ImageToolbar_default = ImageToolbar;
|
|
11573
12234
|
|
|
11574
12235
|
// lib/RufousTextEditor/VideoToolbar.tsx
|
|
11575
|
-
import
|
|
12236
|
+
import React115, { useState as useState33, useEffect as useEffect27, useRef as useRef30 } from "react";
|
|
11576
12237
|
import { createPortal as createPortal6 } from "react-dom";
|
|
11577
12238
|
var ALIGNMENTS2 = [
|
|
11578
12239
|
{ value: "left", label: "Left", icon: "\u2630" },
|
|
@@ -11581,10 +12242,10 @@ var ALIGNMENTS2 = [
|
|
|
11581
12242
|
];
|
|
11582
12243
|
var VIDEO_TYPES = ["youtube", "video"];
|
|
11583
12244
|
var VideoPropertiesModal = ({ editor, node, nodeType, onClose }) => {
|
|
11584
|
-
const [src, setSrc] =
|
|
11585
|
-
const [width, setWidth] =
|
|
11586
|
-
const [height, setHeight] =
|
|
11587
|
-
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);
|
|
11588
12249
|
const handleWidthChange = (val) => {
|
|
11589
12250
|
setWidth(val);
|
|
11590
12251
|
if (lockRatio) {
|
|
@@ -11617,7 +12278,7 @@ var VideoPropertiesModal = ({ editor, node, nodeType, onClose }) => {
|
|
|
11617
12278
|
onClose();
|
|
11618
12279
|
};
|
|
11619
12280
|
const isYoutube = nodeType === "youtube";
|
|
11620
|
-
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(
|
|
11621
12282
|
"iframe",
|
|
11622
12283
|
{
|
|
11623
12284
|
src,
|
|
@@ -11625,14 +12286,14 @@ var VideoPropertiesModal = ({ editor, node, nodeType, onClose }) => {
|
|
|
11625
12286
|
style: { width: "100%", aspectRatio: "16/9", border: "none", display: "block" },
|
|
11626
12287
|
allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
|
11627
12288
|
}
|
|
11628
|
-
) : /* @__PURE__ */
|
|
12289
|
+
) : /* @__PURE__ */ React115.createElement(
|
|
11629
12290
|
"video",
|
|
11630
12291
|
{
|
|
11631
12292
|
src,
|
|
11632
12293
|
controls: true,
|
|
11633
12294
|
style: { width: "100%", aspectRatio: "16/9", display: "block" }
|
|
11634
12295
|
}
|
|
11635
|
-
)), /* @__PURE__ */
|
|
12296
|
+
)), /* @__PURE__ */ React115.createElement("div", { className: "modal-dimensions" }, /* @__PURE__ */ React115.createElement(
|
|
11636
12297
|
"input",
|
|
11637
12298
|
{
|
|
11638
12299
|
type: "number",
|
|
@@ -11640,14 +12301,14 @@ var VideoPropertiesModal = ({ editor, node, nodeType, onClose }) => {
|
|
|
11640
12301
|
value: width,
|
|
11641
12302
|
onChange: (e) => handleWidthChange(e.target.value)
|
|
11642
12303
|
}
|
|
11643
|
-
), /* @__PURE__ */
|
|
12304
|
+
), /* @__PURE__ */ React115.createElement(Tooltip, { title: lockRatio ? "Unlock aspect ratio" : "Lock aspect ratio", placement: "top" }, /* @__PURE__ */ React115.createElement(
|
|
11644
12305
|
"button",
|
|
11645
12306
|
{
|
|
11646
12307
|
className: `lock-btn ${lockRatio ? "locked" : ""}`,
|
|
11647
12308
|
onClick: () => setLockRatio(!lockRatio)
|
|
11648
12309
|
},
|
|
11649
12310
|
lockRatio ? "\u{1F512}" : "\u{1F513}"
|
|
11650
|
-
)), /* @__PURE__ */
|
|
12311
|
+
)), /* @__PURE__ */ React115.createElement(
|
|
11651
12312
|
"input",
|
|
11652
12313
|
{
|
|
11653
12314
|
type: "number",
|
|
@@ -11655,7 +12316,7 @@ var VideoPropertiesModal = ({ editor, node, nodeType, onClose }) => {
|
|
|
11655
12316
|
value: height,
|
|
11656
12317
|
onChange: (e) => handleHeightChange(e.target.value)
|
|
11657
12318
|
}
|
|
11658
|
-
))), /* @__PURE__ */
|
|
12319
|
+
))), /* @__PURE__ */ React115.createElement("div", { className: "modal-fields-col" }, /* @__PURE__ */ React115.createElement("label", { className: "modal-label" }, "Video URL"), /* @__PURE__ */ React115.createElement(
|
|
11659
12320
|
"input",
|
|
11660
12321
|
{
|
|
11661
12322
|
type: "text",
|
|
@@ -11663,7 +12324,7 @@ var VideoPropertiesModal = ({ editor, node, nodeType, onClose }) => {
|
|
|
11663
12324
|
value: src,
|
|
11664
12325
|
onChange: (e) => setSrc(e.target.value)
|
|
11665
12326
|
}
|
|
11666
|
-
), /* @__PURE__ */
|
|
12327
|
+
), /* @__PURE__ */ React115.createElement("label", { className: "modal-label" }, "Width"), /* @__PURE__ */ React115.createElement(
|
|
11667
12328
|
"input",
|
|
11668
12329
|
{
|
|
11669
12330
|
type: "number",
|
|
@@ -11671,7 +12332,7 @@ var VideoPropertiesModal = ({ editor, node, nodeType, onClose }) => {
|
|
|
11671
12332
|
value: width,
|
|
11672
12333
|
onChange: (e) => handleWidthChange(e.target.value)
|
|
11673
12334
|
}
|
|
11674
|
-
), /* @__PURE__ */
|
|
12335
|
+
), /* @__PURE__ */ React115.createElement("label", { className: "modal-label" }, "Height"), /* @__PURE__ */ React115.createElement(
|
|
11675
12336
|
"input",
|
|
11676
12337
|
{
|
|
11677
12338
|
type: "number",
|
|
@@ -11679,16 +12340,16 @@ var VideoPropertiesModal = ({ editor, node, nodeType, onClose }) => {
|
|
|
11679
12340
|
value: height,
|
|
11680
12341
|
onChange: (e) => handleHeightChange(e.target.value)
|
|
11681
12342
|
}
|
|
11682
|
-
)))), /* @__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"))));
|
|
11683
12344
|
};
|
|
11684
12345
|
var VideoToolbar = ({ editor }) => {
|
|
11685
|
-
const [showModal, setShowModal] =
|
|
11686
|
-
const [showSize, setShowSize] =
|
|
11687
|
-
const [showAlign, setShowAlign] =
|
|
11688
|
-
const [copyStatus, setCopyStatus] =
|
|
11689
|
-
const [pos, setPos] =
|
|
11690
|
-
const toolbarRef =
|
|
11691
|
-
|
|
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(() => {
|
|
11692
12353
|
if (!editor) return;
|
|
11693
12354
|
const update = () => {
|
|
11694
12355
|
const { selection } = editor.state;
|
|
@@ -11719,7 +12380,7 @@ var VideoToolbar = ({ editor }) => {
|
|
|
11719
12380
|
const isVideo = node && VIDEO_TYPES.includes(node.type.name);
|
|
11720
12381
|
const nodeType = node?.type.name;
|
|
11721
12382
|
if (!editor || !isVideo || !pos) return showModal ? createPortal6(
|
|
11722
|
-
/* @__PURE__ */
|
|
12383
|
+
/* @__PURE__ */ React115.createElement(VideoPropertiesModal, { editor, node, nodeType, onClose: () => setShowModal(false) }),
|
|
11723
12384
|
document.body
|
|
11724
12385
|
) : null;
|
|
11725
12386
|
const handleDelete = () => {
|
|
@@ -11766,7 +12427,7 @@ var VideoToolbar = ({ editor }) => {
|
|
|
11766
12427
|
);
|
|
11767
12428
|
};
|
|
11768
12429
|
return createPortal6(
|
|
11769
|
-
/* @__PURE__ */
|
|
12430
|
+
/* @__PURE__ */ React115.createElement(React115.Fragment, null, /* @__PURE__ */ React115.createElement(
|
|
11770
12431
|
"div",
|
|
11771
12432
|
{
|
|
11772
12433
|
className: "image-toolbar",
|
|
@@ -11774,30 +12435,30 @@ var VideoToolbar = ({ editor }) => {
|
|
|
11774
12435
|
style: { position: "absolute", top: pos.top, left: pos.left, zIndex: 1e3 },
|
|
11775
12436
|
onMouseDown: (e) => e.preventDefault()
|
|
11776
12437
|
},
|
|
11777
|
-
/* @__PURE__ */
|
|
11778
|
-
/* @__PURE__ */
|
|
11779
|
-
/* @__PURE__ */
|
|
11780
|
-
/* @__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: () => {
|
|
11781
12442
|
setShowSize(!showSize);
|
|
11782
12443
|
setShowAlign(false);
|
|
11783
|
-
} }, /* @__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: () => {
|
|
11784
12445
|
handleResize("small");
|
|
11785
12446
|
setShowSize(false);
|
|
11786
|
-
} }, "Small (320x180)"), /* @__PURE__ */
|
|
12447
|
+
} }, "Small (320x180)"), /* @__PURE__ */ React115.createElement("button", { className: "dropdown-item", onClick: () => {
|
|
11787
12448
|
handleResize("medium");
|
|
11788
12449
|
setShowSize(false);
|
|
11789
|
-
} }, "Medium (480x270)"), /* @__PURE__ */
|
|
12450
|
+
} }, "Medium (480x270)"), /* @__PURE__ */ React115.createElement("button", { className: "dropdown-item", onClick: () => {
|
|
11790
12451
|
handleResize("large");
|
|
11791
12452
|
setShowSize(false);
|
|
11792
|
-
} }, "Large (640x360)"), /* @__PURE__ */
|
|
12453
|
+
} }, "Large (640x360)"), /* @__PURE__ */ React115.createElement("button", { className: "dropdown-item", onClick: () => {
|
|
11793
12454
|
handleResize("full");
|
|
11794
12455
|
setShowSize(false);
|
|
11795
12456
|
} }, "Full (854x480)"))),
|
|
11796
|
-
/* @__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: () => {
|
|
11797
12458
|
setShowAlign(!showAlign);
|
|
11798
12459
|
setShowSize(false);
|
|
11799
|
-
} }, "\u2630 ", /* @__PURE__ */
|
|
11800
|
-
), 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(
|
|
11801
12462
|
VideoPropertiesModal,
|
|
11802
12463
|
{
|
|
11803
12464
|
editor,
|
|
@@ -11812,22 +12473,22 @@ var VideoToolbar = ({ editor }) => {
|
|
|
11812
12473
|
var VideoToolbar_default = VideoToolbar;
|
|
11813
12474
|
|
|
11814
12475
|
// lib/RufousTextEditor/TableToolbar.tsx
|
|
11815
|
-
import
|
|
12476
|
+
import React116, { useState as useState34, useEffect as useEffect28, useRef as useRef31 } from "react";
|
|
11816
12477
|
import { createPortal as createPortal7 } from "react-dom";
|
|
11817
|
-
var IconAddRowBefore = () => /* @__PURE__ */
|
|
11818
|
-
var IconAddRowAfter = () => /* @__PURE__ */
|
|
11819
|
-
var IconAddColBefore = () => /* @__PURE__ */
|
|
11820
|
-
var IconAddColAfter = () => /* @__PURE__ */
|
|
11821
|
-
var IconDeleteRow = () => /* @__PURE__ */
|
|
11822
|
-
var IconDeleteCol = () => /* @__PURE__ */
|
|
11823
|
-
var IconDeleteTable = () => /* @__PURE__ */
|
|
11824
|
-
var IconMergeCells = () => /* @__PURE__ */
|
|
11825
|
-
var IconSplitCell = () => /* @__PURE__ */
|
|
11826
|
-
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" }));
|
|
11827
12488
|
var TableToolbar = ({ editor }) => {
|
|
11828
|
-
const [pos, setPos] =
|
|
11829
|
-
const toolbarRef =
|
|
11830
|
-
|
|
12489
|
+
const [pos, setPos] = useState34(null);
|
|
12490
|
+
const toolbarRef = useRef31(null);
|
|
12491
|
+
useEffect28(() => {
|
|
11831
12492
|
if (!editor) return;
|
|
11832
12493
|
const update = () => {
|
|
11833
12494
|
if (!editor.isActive("table")) {
|
|
@@ -11871,7 +12532,7 @@ var TableToolbar = ({ editor }) => {
|
|
|
11871
12532
|
const canSplit = editor.can().splitCell();
|
|
11872
12533
|
const prevent = (e) => e.preventDefault();
|
|
11873
12534
|
return createPortal7(
|
|
11874
|
-
/* @__PURE__ */
|
|
12535
|
+
/* @__PURE__ */ React116.createElement(
|
|
11875
12536
|
"div",
|
|
11876
12537
|
{
|
|
11877
12538
|
ref: toolbarRef,
|
|
@@ -11879,19 +12540,19 @@ var TableToolbar = ({ editor }) => {
|
|
|
11879
12540
|
style: { top: pos.top, left: pos.left },
|
|
11880
12541
|
onMouseDown: prevent
|
|
11881
12542
|
},
|
|
11882
|
-
/* @__PURE__ */
|
|
11883
|
-
/* @__PURE__ */
|
|
11884
|
-
/* @__PURE__ */
|
|
11885
|
-
/* @__PURE__ */
|
|
11886
|
-
/* @__PURE__ */
|
|
11887
|
-
/* @__PURE__ */
|
|
11888
|
-
/* @__PURE__ */
|
|
11889
|
-
/* @__PURE__ */
|
|
11890
|
-
/* @__PURE__ */
|
|
11891
|
-
/* @__PURE__ */
|
|
11892
|
-
/* @__PURE__ */
|
|
11893
|
-
/* @__PURE__ */
|
|
11894
|
-
/* @__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)))
|
|
11895
12556
|
),
|
|
11896
12557
|
document.body
|
|
11897
12558
|
);
|
|
@@ -12066,12 +12727,12 @@ var RufousTextEditor = ({
|
|
|
12066
12727
|
return visible;
|
|
12067
12728
|
}, [buttons, variant, hideButtons]);
|
|
12068
12729
|
const mentionSuggestion = useMemo4(() => createMentionSuggestion(mentions), [mentions]);
|
|
12069
|
-
const onChangeRef =
|
|
12070
|
-
const onBlurRef =
|
|
12071
|
-
|
|
12730
|
+
const onChangeRef = useRef32(onChange);
|
|
12731
|
+
const onBlurRef = useRef32(onBlur);
|
|
12732
|
+
useEffect29(() => {
|
|
12072
12733
|
onChangeRef.current = onChange;
|
|
12073
12734
|
}, [onChange]);
|
|
12074
|
-
|
|
12735
|
+
useEffect29(() => {
|
|
12075
12736
|
onBlurRef.current = onBlur;
|
|
12076
12737
|
}, [onBlur]);
|
|
12077
12738
|
const isEditable = editable && !disabled;
|
|
@@ -12172,8 +12833,8 @@ var RufousTextEditor = ({
|
|
|
12172
12833
|
onChangeRef.current?.(e.getHTML(), e.getJSON());
|
|
12173
12834
|
}
|
|
12174
12835
|
});
|
|
12175
|
-
const wrapperRef =
|
|
12176
|
-
|
|
12836
|
+
const wrapperRef = useRef32(null);
|
|
12837
|
+
useEffect29(() => {
|
|
12177
12838
|
if (!editor) return;
|
|
12178
12839
|
let blurTimer = null;
|
|
12179
12840
|
const handler = ({ event }) => {
|
|
@@ -12191,15 +12852,15 @@ var RufousTextEditor = ({
|
|
|
12191
12852
|
if (blurTimer) clearTimeout(blurTimer);
|
|
12192
12853
|
};
|
|
12193
12854
|
}, [editor]);
|
|
12194
|
-
const setLinkRef =
|
|
12195
|
-
const [linkModalOpen, setLinkModalOpen] =
|
|
12196
|
-
const [linkUrl, setLinkUrl] =
|
|
12197
|
-
const [linkText, setLinkText] =
|
|
12198
|
-
const [linkClassName, setLinkClassName] =
|
|
12199
|
-
const [linkNewTab, setLinkNewTab] =
|
|
12200
|
-
const [linkNoFollow, setLinkNoFollow] =
|
|
12201
|
-
const [linkSelection, setLinkSelection] =
|
|
12202
|
-
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(() => {
|
|
12203
12864
|
if (!editor) return;
|
|
12204
12865
|
const attrs = editor.getAttributes("link");
|
|
12205
12866
|
const previousUrl = attrs.href || "";
|
|
@@ -12236,10 +12897,10 @@ var RufousTextEditor = ({
|
|
|
12236
12897
|
setLinkSelection({ from, to });
|
|
12237
12898
|
setLinkModalOpen(true);
|
|
12238
12899
|
}, [editor]);
|
|
12239
|
-
|
|
12900
|
+
useEffect29(() => {
|
|
12240
12901
|
setLinkRef.current = setLink;
|
|
12241
12902
|
}, [setLink]);
|
|
12242
|
-
|
|
12903
|
+
useEffect29(() => {
|
|
12243
12904
|
if (!editor?.view) return;
|
|
12244
12905
|
const handleKeyDown = (event) => {
|
|
12245
12906
|
if ((event.ctrlKey || event.metaKey) && event.key === "k") {
|
|
@@ -12271,7 +12932,7 @@ var RufousTextEditor = ({
|
|
|
12271
12932
|
editor.view.dom.removeEventListener("keydown", handleKeyDown);
|
|
12272
12933
|
};
|
|
12273
12934
|
}, [editor]);
|
|
12274
|
-
const handleLinkSubmit =
|
|
12935
|
+
const handleLinkSubmit = useCallback15(() => {
|
|
12275
12936
|
if (!editor || !linkSelection) return;
|
|
12276
12937
|
editor.chain().focus().setTextSelection(linkSelection).run();
|
|
12277
12938
|
if (linkUrl === "") {
|
|
@@ -12307,7 +12968,7 @@ var RufousTextEditor = ({
|
|
|
12307
12968
|
setLinkClassName("");
|
|
12308
12969
|
setLinkSelection(null);
|
|
12309
12970
|
}, [editor, linkUrl, linkText, linkClassName, linkNewTab, linkNoFollow, linkSelection]);
|
|
12310
|
-
const handleLinkRemove =
|
|
12971
|
+
const handleLinkRemove = useCallback15(() => {
|
|
12311
12972
|
if (!editor || !linkSelection) return;
|
|
12312
12973
|
editor.chain().focus().setTextSelection(linkSelection).extendMarkRange("link").unsetLink().run();
|
|
12313
12974
|
setLinkModalOpen(false);
|
|
@@ -12316,7 +12977,7 @@ var RufousTextEditor = ({
|
|
|
12316
12977
|
setLinkClassName("");
|
|
12317
12978
|
setLinkSelection(null);
|
|
12318
12979
|
}, [editor, linkSelection]);
|
|
12319
|
-
const handleLinkCancel =
|
|
12980
|
+
const handleLinkCancel = useCallback15(() => {
|
|
12320
12981
|
setLinkModalOpen(false);
|
|
12321
12982
|
setLinkUrl("");
|
|
12322
12983
|
setLinkText("");
|
|
@@ -12324,21 +12985,21 @@ var RufousTextEditor = ({
|
|
|
12324
12985
|
setLinkSelection(null);
|
|
12325
12986
|
editor?.chain().focus().run();
|
|
12326
12987
|
}, [editor]);
|
|
12327
|
-
const [saveStatus, setSaveStatus] =
|
|
12328
|
-
const handleSave =
|
|
12988
|
+
const [saveStatus, setSaveStatus] = useState35("");
|
|
12989
|
+
const handleSave = useCallback15(() => {
|
|
12329
12990
|
if (!editor || !onSaveProp) return;
|
|
12330
12991
|
onSaveProp(editor.getHTML(), editor.getJSON());
|
|
12331
12992
|
setSaveStatus("Saved!");
|
|
12332
12993
|
setTimeout(() => setSaveStatus(""), 2e3);
|
|
12333
12994
|
}, [editor, onSaveProp]);
|
|
12334
|
-
const handleExport =
|
|
12995
|
+
const handleExport = useCallback15(() => {
|
|
12335
12996
|
if (!editor || !onExportProp) return;
|
|
12336
12997
|
onExportProp(editor.getHTML(), editor.getJSON());
|
|
12337
12998
|
}, [editor, onExportProp]);
|
|
12338
12999
|
const providerValue = useMemo4(() => ({ editor }), [editor]);
|
|
12339
|
-
const [isFullscreen, setIsFullscreen] =
|
|
12340
|
-
const toggleFullscreen =
|
|
12341
|
-
const wrapperJsx = /* @__PURE__ */
|
|
13000
|
+
const [isFullscreen, setIsFullscreen] = useState35(false);
|
|
13001
|
+
const toggleFullscreen = useCallback15(() => setIsFullscreen((prev) => !prev), []);
|
|
13002
|
+
const wrapperJsx = /* @__PURE__ */ React117.createElement(
|
|
12342
13003
|
"div",
|
|
12343
13004
|
{
|
|
12344
13005
|
ref: wrapperRef,
|
|
@@ -12349,7 +13010,7 @@ var RufousTextEditor = ({
|
|
|
12349
13010
|
...height ? { height: typeof height === "number" ? `${height}px` : height } : {}
|
|
12350
13011
|
}
|
|
12351
13012
|
},
|
|
12352
|
-
/* @__PURE__ */
|
|
13013
|
+
/* @__PURE__ */ React117.createElement(EditorContext.Provider, { value: providerValue }, /* @__PURE__ */ React117.createElement(
|
|
12353
13014
|
Toolbar_default,
|
|
12354
13015
|
{
|
|
12355
13016
|
editor,
|
|
@@ -12364,7 +13025,7 @@ var RufousTextEditor = ({
|
|
|
12364
13025
|
isFullscreen,
|
|
12365
13026
|
onToggleFullscreen: toggleFullscreen
|
|
12366
13027
|
}
|
|
12367
|
-
), /* @__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(
|
|
12368
13029
|
BubbleMenu,
|
|
12369
13030
|
{
|
|
12370
13031
|
editor,
|
|
@@ -12382,31 +13043,31 @@ var RufousTextEditor = ({
|
|
|
12382
13043
|
}
|
|
12383
13044
|
}
|
|
12384
13045
|
},
|
|
12385
|
-
/* @__PURE__ */
|
|
13046
|
+
/* @__PURE__ */ React117.createElement(
|
|
12386
13047
|
"button",
|
|
12387
13048
|
{
|
|
12388
13049
|
onClick: () => editor?.chain().focus().toggleBold().run(),
|
|
12389
13050
|
className: editor?.isActive("bold") ? "is-active" : ""
|
|
12390
13051
|
},
|
|
12391
|
-
/* @__PURE__ */
|
|
13052
|
+
/* @__PURE__ */ React117.createElement("strong", null, "B")
|
|
12392
13053
|
),
|
|
12393
|
-
/* @__PURE__ */
|
|
13054
|
+
/* @__PURE__ */ React117.createElement(
|
|
12394
13055
|
"button",
|
|
12395
13056
|
{
|
|
12396
13057
|
onClick: () => editor?.chain().focus().toggleItalic().run(),
|
|
12397
13058
|
className: editor?.isActive("italic") ? "is-active" : ""
|
|
12398
13059
|
},
|
|
12399
|
-
/* @__PURE__ */
|
|
13060
|
+
/* @__PURE__ */ React117.createElement("em", null, "I")
|
|
12400
13061
|
),
|
|
12401
|
-
/* @__PURE__ */
|
|
13062
|
+
/* @__PURE__ */ React117.createElement(
|
|
12402
13063
|
"button",
|
|
12403
13064
|
{
|
|
12404
13065
|
onClick: () => editor?.chain().focus().toggleStrike().run(),
|
|
12405
13066
|
className: editor?.isActive("strike") ? "is-active" : ""
|
|
12406
13067
|
},
|
|
12407
|
-
/* @__PURE__ */
|
|
13068
|
+
/* @__PURE__ */ React117.createElement("s", null, "S")
|
|
12408
13069
|
),
|
|
12409
|
-
/* @__PURE__ */
|
|
13070
|
+
/* @__PURE__ */ React117.createElement(
|
|
12410
13071
|
"button",
|
|
12411
13072
|
{
|
|
12412
13073
|
onClick: () => editor?.chain().focus().toggleCode().run(),
|
|
@@ -12414,7 +13075,7 @@ var RufousTextEditor = ({
|
|
|
12414
13075
|
},
|
|
12415
13076
|
"</>"
|
|
12416
13077
|
),
|
|
12417
|
-
/* @__PURE__ */
|
|
13078
|
+
/* @__PURE__ */ React117.createElement(
|
|
12418
13079
|
"button",
|
|
12419
13080
|
{
|
|
12420
13081
|
onClick: setLink,
|
|
@@ -12422,7 +13083,7 @@ var RufousTextEditor = ({
|
|
|
12422
13083
|
},
|
|
12423
13084
|
"\u{1F517}"
|
|
12424
13085
|
)
|
|
12425
|
-
), editor && /* @__PURE__ */
|
|
13086
|
+
), editor && /* @__PURE__ */ React117.createElement(
|
|
12426
13087
|
FloatingMenu,
|
|
12427
13088
|
{
|
|
12428
13089
|
editor,
|
|
@@ -12437,7 +13098,7 @@ var RufousTextEditor = ({
|
|
|
12437
13098
|
}
|
|
12438
13099
|
}
|
|
12439
13100
|
},
|
|
12440
|
-
/* @__PURE__ */
|
|
13101
|
+
/* @__PURE__ */ React117.createElement(
|
|
12441
13102
|
"button",
|
|
12442
13103
|
{
|
|
12443
13104
|
onClick: () => editor?.chain().focus().toggleHeading({ level: 1 }).run(),
|
|
@@ -12445,7 +13106,7 @@ var RufousTextEditor = ({
|
|
|
12445
13106
|
},
|
|
12446
13107
|
"H1"
|
|
12447
13108
|
),
|
|
12448
|
-
/* @__PURE__ */
|
|
13109
|
+
/* @__PURE__ */ React117.createElement(
|
|
12449
13110
|
"button",
|
|
12450
13111
|
{
|
|
12451
13112
|
onClick: () => editor?.chain().focus().toggleHeading({ level: 2 }).run(),
|
|
@@ -12453,7 +13114,7 @@ var RufousTextEditor = ({
|
|
|
12453
13114
|
},
|
|
12454
13115
|
"H2"
|
|
12455
13116
|
),
|
|
12456
|
-
/* @__PURE__ */
|
|
13117
|
+
/* @__PURE__ */ React117.createElement(
|
|
12457
13118
|
"button",
|
|
12458
13119
|
{
|
|
12459
13120
|
onClick: () => editor?.chain().focus().toggleBulletList().run(),
|
|
@@ -12461,7 +13122,7 @@ var RufousTextEditor = ({
|
|
|
12461
13122
|
},
|
|
12462
13123
|
"\u2022 List"
|
|
12463
13124
|
),
|
|
12464
|
-
/* @__PURE__ */
|
|
13125
|
+
/* @__PURE__ */ React117.createElement(
|
|
12465
13126
|
"button",
|
|
12466
13127
|
{
|
|
12467
13128
|
onClick: () => editor?.chain().focus().toggleOrderedList().run(),
|
|
@@ -12469,7 +13130,7 @@ var RufousTextEditor = ({
|
|
|
12469
13130
|
},
|
|
12470
13131
|
"1. List"
|
|
12471
13132
|
),
|
|
12472
|
-
/* @__PURE__ */
|
|
13133
|
+
/* @__PURE__ */ React117.createElement(
|
|
12473
13134
|
"button",
|
|
12474
13135
|
{
|
|
12475
13136
|
onClick: () => editor?.chain().focus().toggleBlockquote().run(),
|
|
@@ -12477,8 +13138,8 @@ var RufousTextEditor = ({
|
|
|
12477
13138
|
},
|
|
12478
13139
|
"\u201C Quote"
|
|
12479
13140
|
)
|
|
12480
|
-
), /* @__PURE__ */
|
|
12481
|
-
/* @__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(
|
|
12482
13143
|
"input",
|
|
12483
13144
|
{
|
|
12484
13145
|
type: "url",
|
|
@@ -12491,7 +13152,7 @@ var RufousTextEditor = ({
|
|
|
12491
13152
|
placeholder: "https://example.com",
|
|
12492
13153
|
autoFocus: true
|
|
12493
13154
|
}
|
|
12494
|
-
)), /* @__PURE__ */
|
|
13155
|
+
)), /* @__PURE__ */ React117.createElement("div", { className: "link-modal-field" }, /* @__PURE__ */ React117.createElement("label", { className: "link-modal-label" }, "Text"), /* @__PURE__ */ React117.createElement(
|
|
12495
13156
|
"input",
|
|
12496
13157
|
{
|
|
12497
13158
|
type: "text",
|
|
@@ -12503,24 +13164,24 @@ var RufousTextEditor = ({
|
|
|
12503
13164
|
},
|
|
12504
13165
|
placeholder: "Link text"
|
|
12505
13166
|
}
|
|
12506
|
-
)), /* @__PURE__ */
|
|
13167
|
+
)), /* @__PURE__ */ React117.createElement("div", { className: "link-modal-checkboxes" }, /* @__PURE__ */ React117.createElement("label", { className: "link-modal-checkbox" }, /* @__PURE__ */ React117.createElement(
|
|
12507
13168
|
"input",
|
|
12508
13169
|
{
|
|
12509
13170
|
type: "checkbox",
|
|
12510
13171
|
checked: linkNewTab,
|
|
12511
13172
|
onChange: (e) => setLinkNewTab(e.target.checked)
|
|
12512
13173
|
}
|
|
12513
|
-
), "Open in new tab"), /* @__PURE__ */
|
|
13174
|
+
), "Open in new tab"), /* @__PURE__ */ React117.createElement("label", { className: "link-modal-checkbox" }, /* @__PURE__ */ React117.createElement(
|
|
12514
13175
|
"input",
|
|
12515
13176
|
{
|
|
12516
13177
|
type: "checkbox",
|
|
12517
13178
|
checked: linkNoFollow,
|
|
12518
13179
|
onChange: (e) => setLinkNoFollow(e.target.checked)
|
|
12519
13180
|
}
|
|
12520
|
-
), "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")))),
|
|
12521
13182
|
document.body
|
|
12522
13183
|
)),
|
|
12523
|
-
helperText && /* @__PURE__ */
|
|
13184
|
+
helperText && /* @__PURE__ */ React117.createElement("div", { className: `rf-rte-helper-text ${error ? "rf-rte-helper-error" : ""}` }, helperText)
|
|
12524
13185
|
);
|
|
12525
13186
|
return isFullscreen ? createPortal8(wrapperJsx, document.body) : wrapperJsx;
|
|
12526
13187
|
};
|
|
@@ -12531,7 +13192,7 @@ var RufousTextContent = ({ content, className, style, sx }) => {
|
|
|
12531
13192
|
transformedContent = transformLegacyTodos(transformedContent);
|
|
12532
13193
|
} catch {
|
|
12533
13194
|
}
|
|
12534
|
-
return /* @__PURE__ */
|
|
13195
|
+
return /* @__PURE__ */ React117.createElement(
|
|
12535
13196
|
"div",
|
|
12536
13197
|
{
|
|
12537
13198
|
className: `rf-rte-content ${sxClass} ${className || ""}`,
|
|
@@ -12669,6 +13330,7 @@ export {
|
|
|
12669
13330
|
ToggleButtonGroup,
|
|
12670
13331
|
Tooltip,
|
|
12671
13332
|
trashIcon_default as TrashIcon,
|
|
13333
|
+
TreeSelect,
|
|
12672
13334
|
Typography,
|
|
12673
13335
|
unArchivedIcon_default as UnArchivedIcon,
|
|
12674
13336
|
unsubscribeIcon_default as UnsubscribeIcon,
|