@elementor/editor-global-classes 4.1.0-822 → 4.1.0-824
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/index.js +132 -80
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +131 -79
- package/dist/index.mjs.map +1 -1
- package/package.json +21 -20
- package/src/components/class-manager/class-manager-panel.tsx +6 -16
- package/src/components/class-manager/global-classes-list.tsx +62 -14
- package/src/components/class-manager/sortable.tsx +9 -3
- package/src/components/global-styles-import-listener.tsx +3 -5
package/dist/index.mjs
CHANGED
|
@@ -620,7 +620,7 @@ var PrefetchCssClassUsage = () => {
|
|
|
620
620
|
import * as React19 from "react";
|
|
621
621
|
import { useCallback, useEffect as useEffect4, useState as useState7 } from "react";
|
|
622
622
|
import { useSuppressedMessage as useSuppressedMessage2 } from "@elementor/editor-current-user";
|
|
623
|
-
import {
|
|
623
|
+
import { reloadCurrentDocument, setDocumentModifiedStatus } from "@elementor/editor-documents";
|
|
624
624
|
import {
|
|
625
625
|
__createPanel as createPanel,
|
|
626
626
|
Panel,
|
|
@@ -630,7 +630,7 @@ import {
|
|
|
630
630
|
PanelHeaderTitle
|
|
631
631
|
} from "@elementor/editor-panels";
|
|
632
632
|
import { ConfirmationDialog as ConfirmationDialog2, SaveChangesDialog, ThemeProvider, useDialog } from "@elementor/editor-ui";
|
|
633
|
-
import {
|
|
633
|
+
import { changeEditMode } from "@elementor/editor-v1-adapters";
|
|
634
634
|
import { XIcon } from "@elementor/icons";
|
|
635
635
|
import { useMutation } from "@elementor/query";
|
|
636
636
|
import { __dispatch as dispatch4 } from "@elementor/store";
|
|
@@ -1289,6 +1289,7 @@ import * as React17 from "react";
|
|
|
1289
1289
|
import { useEffect as useEffect2, useMemo as useMemo3, useState as useState5 } from "react";
|
|
1290
1290
|
import { __useDispatch as useDispatch } from "@elementor/store";
|
|
1291
1291
|
import { List, Stack as Stack8, styled as styled6, Typography as Typography8 } from "@elementor/ui";
|
|
1292
|
+
import { defaultRangeExtractor, useVirtualizer } from "@tanstack/react-virtual";
|
|
1292
1293
|
import { __ as __13 } from "@wordpress/i18n";
|
|
1293
1294
|
|
|
1294
1295
|
// src/hooks/use-ordered-classes.ts
|
|
@@ -1641,9 +1642,17 @@ import {
|
|
|
1641
1642
|
UnstableSortableItem,
|
|
1642
1643
|
UnstableSortableProvider
|
|
1643
1644
|
} from "@elementor/ui";
|
|
1644
|
-
var SortableProvider = (props) => /* @__PURE__ */ React14.createElement(
|
|
1645
|
+
var SortableProvider = (props) => /* @__PURE__ */ React14.createElement(
|
|
1646
|
+
UnstableSortableProvider,
|
|
1647
|
+
{
|
|
1648
|
+
restrictAxis: true,
|
|
1649
|
+
variant: "static",
|
|
1650
|
+
dragPlaceholderStyle: { visibility: "hidden" },
|
|
1651
|
+
...props
|
|
1652
|
+
}
|
|
1653
|
+
);
|
|
1645
1654
|
var SortableTrigger = (props) => /* @__PURE__ */ React14.createElement(StyledSortableTrigger, { ...props, role: "button", className: "class-item-sortable-trigger", "aria-label": "sort" }, /* @__PURE__ */ React14.createElement(GripVerticalIcon, { fontSize: "tiny" }));
|
|
1646
|
-
var SortableItem = ({ children, id: id2, ...props }) => {
|
|
1655
|
+
var SortableItem = ({ children, id: id2, style, ...props }) => {
|
|
1647
1656
|
return /* @__PURE__ */ React14.createElement(
|
|
1648
1657
|
UnstableSortableItem,
|
|
1649
1658
|
{
|
|
@@ -1664,7 +1673,7 @@ var SortableItem = ({ children, id: id2, ...props }) => {
|
|
|
1664
1673
|
Box7,
|
|
1665
1674
|
{
|
|
1666
1675
|
...itemProps,
|
|
1667
|
-
style: itemStyle,
|
|
1676
|
+
style: { ...itemStyle, ...!isDragOverlay ? style : null },
|
|
1668
1677
|
component: "li",
|
|
1669
1678
|
role: "listitem",
|
|
1670
1679
|
sx: {
|
|
@@ -1987,7 +1996,14 @@ var NotFoundLayout = ({ onClear, searchValue, mainText, sceneryText, icon }) =>
|
|
|
1987
1996
|
);
|
|
1988
1997
|
|
|
1989
1998
|
// src/components/class-manager/global-classes-list.tsx
|
|
1990
|
-
var
|
|
1999
|
+
var ROW_HEIGHT = 40;
|
|
2000
|
+
var OVERSCAN = 6;
|
|
2001
|
+
var GlobalClassesList = ({
|
|
2002
|
+
disabled,
|
|
2003
|
+
scrollElement,
|
|
2004
|
+
onStopSyncRequest,
|
|
2005
|
+
onStartSyncRequest
|
|
2006
|
+
}) => {
|
|
1991
2007
|
const {
|
|
1992
2008
|
search: { debouncedValue: searchValue }
|
|
1993
2009
|
} = useSearchAndFilters();
|
|
@@ -1998,6 +2014,26 @@ var GlobalClassesList = ({ disabled, onStopSyncRequest, onStartSyncRequest }) =>
|
|
|
1998
2014
|
const draggedItemLabel = cssClasses.find((cssClass) => cssClass.id === draggedItemId)?.label ?? "";
|
|
1999
2015
|
const [classesOrder, reorderClasses] = useReorder(draggedItemId, setDraggedItemId, draggedItemLabel ?? "");
|
|
2000
2016
|
const filteredCssClasses = useFilteredCssClasses();
|
|
2017
|
+
const virtualizer = useVirtualizer({
|
|
2018
|
+
count: filteredCssClasses.length,
|
|
2019
|
+
getScrollElement: () => scrollElement ?? null,
|
|
2020
|
+
estimateSize: () => ROW_HEIGHT,
|
|
2021
|
+
overscan: OVERSCAN,
|
|
2022
|
+
getItemKey: (index) => filteredCssClasses[index].id,
|
|
2023
|
+
// Keep the actively dragged row mounted even when scrolled out of view.
|
|
2024
|
+
// SortableItem unregisters its render on unmount, which would make the
|
|
2025
|
+
// DragOverlay clone disappear mid-drag.
|
|
2026
|
+
rangeExtractor: (range) => {
|
|
2027
|
+
const indices = new Set(defaultRangeExtractor(range));
|
|
2028
|
+
if (draggedItemId) {
|
|
2029
|
+
const draggedItemIndex = filteredCssClasses.findIndex((cssClass) => cssClass.id === draggedItemId);
|
|
2030
|
+
if (draggedItemIndex >= 0) {
|
|
2031
|
+
indices.add(draggedItemIndex);
|
|
2032
|
+
}
|
|
2033
|
+
}
|
|
2034
|
+
return [...indices].sort((a, b) => a - b);
|
|
2035
|
+
}
|
|
2036
|
+
});
|
|
2001
2037
|
useEffect2(() => {
|
|
2002
2038
|
const handler2 = (event) => {
|
|
2003
2039
|
if (event.key === "z" && (event.ctrlKey || event.metaKey)) {
|
|
@@ -2024,67 +2060,92 @@ var GlobalClassesList = ({ disabled, onStopSyncRequest, onStartSyncRequest }) =>
|
|
|
2024
2060
|
}
|
|
2025
2061
|
const isFiltersApplied = filters?.length || searchValue;
|
|
2026
2062
|
const allowSorting = filteredCssClasses.length > 1 && !isFiltersApplied;
|
|
2027
|
-
return /* @__PURE__ */ React17.createElement(DeleteConfirmationProvider, null, /* @__PURE__ */ React17.createElement(
|
|
2028
|
-
|
|
2063
|
+
return /* @__PURE__ */ React17.createElement(DeleteConfirmationProvider, null, /* @__PURE__ */ React17.createElement(
|
|
2064
|
+
List,
|
|
2029
2065
|
{
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
if (isDragged && !draggedItemId) {
|
|
2036
|
-
setDraggedItemId(cssClass.id);
|
|
2066
|
+
sx: {
|
|
2067
|
+
position: "relative",
|
|
2068
|
+
display: "block",
|
|
2069
|
+
height: virtualizer.getTotalSize(),
|
|
2070
|
+
padding: 0
|
|
2037
2071
|
}
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
sortableTriggerProps: {
|
|
2063
|
-
...triggerProps,
|
|
2064
|
-
style: triggerStyle
|
|
2072
|
+
},
|
|
2073
|
+
/* @__PURE__ */ React17.createElement(
|
|
2074
|
+
SortableProvider,
|
|
2075
|
+
{
|
|
2076
|
+
value: classesOrder,
|
|
2077
|
+
onChange: reorderClasses,
|
|
2078
|
+
onDragStart: (event) => setDraggedItemId(event.active.id),
|
|
2079
|
+
onDragEnd: () => setDraggedItemId(null),
|
|
2080
|
+
onDragCancel: () => setDraggedItemId(null),
|
|
2081
|
+
disableDragOverlay: !allowSorting
|
|
2082
|
+
},
|
|
2083
|
+
virtualizer.getVirtualItems().map((virtualRow) => {
|
|
2084
|
+
const cssClass = filteredCssClasses[virtualRow.index];
|
|
2085
|
+
return /* @__PURE__ */ React17.createElement(
|
|
2086
|
+
SortableItem,
|
|
2087
|
+
{
|
|
2088
|
+
key: virtualRow.key,
|
|
2089
|
+
id: cssClass.id,
|
|
2090
|
+
style: {
|
|
2091
|
+
position: "absolute",
|
|
2092
|
+
top: virtualRow.start,
|
|
2093
|
+
left: 0,
|
|
2094
|
+
width: "100%"
|
|
2095
|
+
}
|
|
2065
2096
|
},
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2097
|
+
({ isDragged, isDragPlaceholder, triggerProps, triggerStyle }) => /* @__PURE__ */ React17.createElement(
|
|
2098
|
+
ClassItem,
|
|
2099
|
+
{
|
|
2100
|
+
id: cssClass.id,
|
|
2101
|
+
label: cssClass.label,
|
|
2102
|
+
renameClass: (newLabel) => {
|
|
2103
|
+
trackGlobalClasses({
|
|
2104
|
+
event: "classRenamed",
|
|
2105
|
+
classId: cssClass.id,
|
|
2106
|
+
oldValue: cssClass.label,
|
|
2107
|
+
newValue: newLabel,
|
|
2108
|
+
source: "class-manager"
|
|
2109
|
+
});
|
|
2110
|
+
dispatch5(
|
|
2111
|
+
slice.actions.update({
|
|
2112
|
+
style: {
|
|
2113
|
+
id: cssClass.id,
|
|
2114
|
+
label: newLabel
|
|
2115
|
+
}
|
|
2116
|
+
})
|
|
2117
|
+
);
|
|
2118
|
+
},
|
|
2119
|
+
selected: isDragged,
|
|
2120
|
+
disabled: disabled || isDragPlaceholder,
|
|
2121
|
+
sortableTriggerProps: {
|
|
2122
|
+
...triggerProps,
|
|
2123
|
+
style: triggerStyle
|
|
2124
|
+
},
|
|
2125
|
+
showSortIndicator: allowSorting,
|
|
2126
|
+
syncToV3: cssClass.sync_to_v3,
|
|
2127
|
+
onToggleSync: (id2, newValue) => {
|
|
2128
|
+
if (!newValue && onStopSyncRequest) {
|
|
2129
|
+
onStopSyncRequest(id2);
|
|
2130
|
+
} else if (newValue && onStartSyncRequest) {
|
|
2131
|
+
onStartSyncRequest(id2);
|
|
2132
|
+
} else {
|
|
2133
|
+
dispatch5(
|
|
2134
|
+
slice.actions.update({
|
|
2135
|
+
style: {
|
|
2136
|
+
id: id2,
|
|
2137
|
+
sync_to_v3: newValue
|
|
2138
|
+
}
|
|
2139
|
+
})
|
|
2140
|
+
);
|
|
2141
|
+
}
|
|
2142
|
+
}
|
|
2082
2143
|
}
|
|
2083
|
-
|
|
2084
|
-
|
|
2085
|
-
)
|
|
2086
|
-
|
|
2087
|
-
))
|
|
2144
|
+
)
|
|
2145
|
+
);
|
|
2146
|
+
})
|
|
2147
|
+
)
|
|
2148
|
+
));
|
|
2088
2149
|
};
|
|
2089
2150
|
var EmptyState = () => /* @__PURE__ */ React17.createElement(Stack8, { alignItems: "center", gap: 1.5, pt: 10, px: 0.5, maxWidth: "260px", margin: "auto" }, /* @__PURE__ */ React17.createElement(FlippedColorSwatchIcon, { fontSize: "large" }), /* @__PURE__ */ React17.createElement(StyledHeader, { variant: "subtitle2", component: "h2", color: "text.secondary" }, __13("There are no global classes yet.", "elementor")), /* @__PURE__ */ React17.createElement(Typography8, { align: "center", variant: "caption", color: "text.secondary" }, __13(
|
|
2090
2151
|
"CSS classes created in the editor panel will appear here. Once they are available, you can arrange their hierarchy, rename them, or delete them as needed.",
|
|
@@ -2214,16 +2275,6 @@ var StartSyncToV3Modal = ({
|
|
|
2214
2275
|
// src/components/class-manager/class-manager-panel.tsx
|
|
2215
2276
|
var STOP_SYNC_MESSAGE_KEY = "stop-sync-class";
|
|
2216
2277
|
var id = "global-classes-manager";
|
|
2217
|
-
var reloadDocument = () => {
|
|
2218
|
-
const currentDocument = getCurrentDocument();
|
|
2219
|
-
const documentsManager = getV1DocumentsManager();
|
|
2220
|
-
documentsManager.invalidateCache();
|
|
2221
|
-
return runCommand("editor/documents/switch", {
|
|
2222
|
-
id: currentDocument?.id,
|
|
2223
|
-
shouldScroll: false,
|
|
2224
|
-
shouldNavigateToDefaultRoute: false
|
|
2225
|
-
});
|
|
2226
|
-
};
|
|
2227
2278
|
var { panel, usePanelActions } = createPanel({
|
|
2228
2279
|
id,
|
|
2229
2280
|
component: ClassManagerPanel,
|
|
@@ -2234,7 +2285,7 @@ var { panel, usePanelActions } = createPanel({
|
|
|
2234
2285
|
},
|
|
2235
2286
|
onClose: async () => {
|
|
2236
2287
|
changeEditMode("edit");
|
|
2237
|
-
await
|
|
2288
|
+
await reloadCurrentDocument();
|
|
2238
2289
|
unblockPanelInteractions();
|
|
2239
2290
|
},
|
|
2240
2291
|
isOpenPreviousElement: true
|
|
@@ -2246,6 +2297,7 @@ function ClassManagerPanel() {
|
|
|
2246
2297
|
const [stopSyncConfirmation, setStopSyncConfirmation] = useState7(null);
|
|
2247
2298
|
const [startSyncConfirmation, setStartSyncConfirmation] = useState7(null);
|
|
2248
2299
|
const [isStopSyncSuppressed] = useSuppressedMessage2(STOP_SYNC_MESSAGE_KEY);
|
|
2300
|
+
const [scrollElement, setScrollElement] = useState7(null);
|
|
2249
2301
|
const { mutateAsync: publish, isPending: isPublishing } = usePublish();
|
|
2250
2302
|
const resetAndClosePanel = () => {
|
|
2251
2303
|
dispatch4(slice.actions.resetToInitialState({ context: "frontend" }));
|
|
@@ -2313,6 +2365,7 @@ function ClassManagerPanel() {
|
|
|
2313
2365
|
/* @__PURE__ */ React19.createElement(
|
|
2314
2366
|
Box11,
|
|
2315
2367
|
{
|
|
2368
|
+
ref: setScrollElement,
|
|
2316
2369
|
px: 2,
|
|
2317
2370
|
sx: {
|
|
2318
2371
|
flexGrow: 1,
|
|
@@ -2323,6 +2376,7 @@ function ClassManagerPanel() {
|
|
|
2323
2376
|
GlobalClassesList,
|
|
2324
2377
|
{
|
|
2325
2378
|
disabled: isPublishing,
|
|
2379
|
+
scrollElement,
|
|
2326
2380
|
onStopSyncRequest: handleStopSyncRequest,
|
|
2327
2381
|
onStartSyncRequest: (classId) => setStartSyncConfirmation(classId)
|
|
2328
2382
|
}
|
|
@@ -2543,6 +2597,7 @@ function createClassName(prefix) {
|
|
|
2543
2597
|
|
|
2544
2598
|
// src/components/global-styles-import-listener.tsx
|
|
2545
2599
|
import { useEffect as useEffect5 } from "react";
|
|
2600
|
+
import { GLOBAL_STYLES_IMPORTED_EVENT } from "@elementor/editor-canvas";
|
|
2546
2601
|
import { __useDispatch as useDispatch2 } from "@elementor/store";
|
|
2547
2602
|
function GlobalStylesImportListener() {
|
|
2548
2603
|
const dispatch5 = useDispatch2();
|
|
@@ -2581,12 +2636,9 @@ function GlobalStylesImportListener() {
|
|
|
2581
2636
|
}).catch(() => {
|
|
2582
2637
|
});
|
|
2583
2638
|
};
|
|
2584
|
-
window.addEventListener(
|
|
2639
|
+
window.addEventListener(GLOBAL_STYLES_IMPORTED_EVENT, handleGlobalStylesImported);
|
|
2585
2640
|
return () => {
|
|
2586
|
-
window.removeEventListener(
|
|
2587
|
-
"elementor/global-styles/imported",
|
|
2588
|
-
handleGlobalStylesImported
|
|
2589
|
-
);
|
|
2641
|
+
window.removeEventListener(GLOBAL_STYLES_IMPORTED_EVENT, handleGlobalStylesImported);
|
|
2590
2642
|
};
|
|
2591
2643
|
}, [dispatch5]);
|
|
2592
2644
|
return null;
|