@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.js
CHANGED
|
@@ -1280,6 +1280,7 @@ var React17 = __toESM(require("react"));
|
|
|
1280
1280
|
var import_react8 = require("react");
|
|
1281
1281
|
var import_store18 = require("@elementor/store");
|
|
1282
1282
|
var import_ui14 = require("@elementor/ui");
|
|
1283
|
+
var import_react_virtual = require("@tanstack/react-virtual");
|
|
1283
1284
|
var import_i18n13 = require("@wordpress/i18n");
|
|
1284
1285
|
|
|
1285
1286
|
// src/hooks/use-ordered-classes.ts
|
|
@@ -1592,9 +1593,17 @@ var useDeleteConfirmation = () => {
|
|
|
1592
1593
|
var React14 = __toESM(require("react"));
|
|
1593
1594
|
var import_icons8 = require("@elementor/icons");
|
|
1594
1595
|
var import_ui11 = require("@elementor/ui");
|
|
1595
|
-
var SortableProvider = (props) => /* @__PURE__ */ React14.createElement(
|
|
1596
|
+
var SortableProvider = (props) => /* @__PURE__ */ React14.createElement(
|
|
1597
|
+
import_ui11.UnstableSortableProvider,
|
|
1598
|
+
{
|
|
1599
|
+
restrictAxis: true,
|
|
1600
|
+
variant: "static",
|
|
1601
|
+
dragPlaceholderStyle: { visibility: "hidden" },
|
|
1602
|
+
...props
|
|
1603
|
+
}
|
|
1604
|
+
);
|
|
1596
1605
|
var SortableTrigger = (props) => /* @__PURE__ */ React14.createElement(StyledSortableTrigger, { ...props, role: "button", className: "class-item-sortable-trigger", "aria-label": "sort" }, /* @__PURE__ */ React14.createElement(import_icons8.GripVerticalIcon, { fontSize: "tiny" }));
|
|
1597
|
-
var SortableItem = ({ children, id: id2, ...props }) => {
|
|
1606
|
+
var SortableItem = ({ children, id: id2, style, ...props }) => {
|
|
1598
1607
|
return /* @__PURE__ */ React14.createElement(
|
|
1599
1608
|
import_ui11.UnstableSortableItem,
|
|
1600
1609
|
{
|
|
@@ -1615,7 +1624,7 @@ var SortableItem = ({ children, id: id2, ...props }) => {
|
|
|
1615
1624
|
import_ui11.Box,
|
|
1616
1625
|
{
|
|
1617
1626
|
...itemProps,
|
|
1618
|
-
style: itemStyle,
|
|
1627
|
+
style: { ...itemStyle, ...!isDragOverlay ? style : null },
|
|
1619
1628
|
component: "li",
|
|
1620
1629
|
role: "listitem",
|
|
1621
1630
|
sx: {
|
|
@@ -1938,7 +1947,14 @@ var NotFoundLayout = ({ onClear, searchValue, mainText, sceneryText, icon }) =>
|
|
|
1938
1947
|
);
|
|
1939
1948
|
|
|
1940
1949
|
// src/components/class-manager/global-classes-list.tsx
|
|
1941
|
-
var
|
|
1950
|
+
var ROW_HEIGHT = 40;
|
|
1951
|
+
var OVERSCAN = 6;
|
|
1952
|
+
var GlobalClassesList = ({
|
|
1953
|
+
disabled,
|
|
1954
|
+
scrollElement,
|
|
1955
|
+
onStopSyncRequest,
|
|
1956
|
+
onStartSyncRequest
|
|
1957
|
+
}) => {
|
|
1942
1958
|
const {
|
|
1943
1959
|
search: { debouncedValue: searchValue }
|
|
1944
1960
|
} = useSearchAndFilters();
|
|
@@ -1949,6 +1965,26 @@ var GlobalClassesList = ({ disabled, onStopSyncRequest, onStartSyncRequest }) =>
|
|
|
1949
1965
|
const draggedItemLabel = cssClasses.find((cssClass) => cssClass.id === draggedItemId)?.label ?? "";
|
|
1950
1966
|
const [classesOrder, reorderClasses] = useReorder(draggedItemId, setDraggedItemId, draggedItemLabel ?? "");
|
|
1951
1967
|
const filteredCssClasses = useFilteredCssClasses();
|
|
1968
|
+
const virtualizer = (0, import_react_virtual.useVirtualizer)({
|
|
1969
|
+
count: filteredCssClasses.length,
|
|
1970
|
+
getScrollElement: () => scrollElement ?? null,
|
|
1971
|
+
estimateSize: () => ROW_HEIGHT,
|
|
1972
|
+
overscan: OVERSCAN,
|
|
1973
|
+
getItemKey: (index) => filteredCssClasses[index].id,
|
|
1974
|
+
// Keep the actively dragged row mounted even when scrolled out of view.
|
|
1975
|
+
// SortableItem unregisters its render on unmount, which would make the
|
|
1976
|
+
// DragOverlay clone disappear mid-drag.
|
|
1977
|
+
rangeExtractor: (range) => {
|
|
1978
|
+
const indices = new Set((0, import_react_virtual.defaultRangeExtractor)(range));
|
|
1979
|
+
if (draggedItemId) {
|
|
1980
|
+
const draggedItemIndex = filteredCssClasses.findIndex((cssClass) => cssClass.id === draggedItemId);
|
|
1981
|
+
if (draggedItemIndex >= 0) {
|
|
1982
|
+
indices.add(draggedItemIndex);
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
return [...indices].sort((a, b) => a - b);
|
|
1986
|
+
}
|
|
1987
|
+
});
|
|
1952
1988
|
(0, import_react8.useEffect)(() => {
|
|
1953
1989
|
const handler2 = (event) => {
|
|
1954
1990
|
if (event.key === "z" && (event.ctrlKey || event.metaKey)) {
|
|
@@ -1975,67 +2011,92 @@ var GlobalClassesList = ({ disabled, onStopSyncRequest, onStartSyncRequest }) =>
|
|
|
1975
2011
|
}
|
|
1976
2012
|
const isFiltersApplied = filters?.length || searchValue;
|
|
1977
2013
|
const allowSorting = filteredCssClasses.length > 1 && !isFiltersApplied;
|
|
1978
|
-
return /* @__PURE__ */ React17.createElement(DeleteConfirmationProvider, null, /* @__PURE__ */ React17.createElement(
|
|
1979
|
-
|
|
2014
|
+
return /* @__PURE__ */ React17.createElement(DeleteConfirmationProvider, null, /* @__PURE__ */ React17.createElement(
|
|
2015
|
+
import_ui14.List,
|
|
1980
2016
|
{
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
if (isDragged && !draggedItemId) {
|
|
1987
|
-
setDraggedItemId(cssClass.id);
|
|
2017
|
+
sx: {
|
|
2018
|
+
position: "relative",
|
|
2019
|
+
display: "block",
|
|
2020
|
+
height: virtualizer.getTotalSize(),
|
|
2021
|
+
padding: 0
|
|
1988
2022
|
}
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
sortableTriggerProps: {
|
|
2014
|
-
...triggerProps,
|
|
2015
|
-
style: triggerStyle
|
|
2023
|
+
},
|
|
2024
|
+
/* @__PURE__ */ React17.createElement(
|
|
2025
|
+
SortableProvider,
|
|
2026
|
+
{
|
|
2027
|
+
value: classesOrder,
|
|
2028
|
+
onChange: reorderClasses,
|
|
2029
|
+
onDragStart: (event) => setDraggedItemId(event.active.id),
|
|
2030
|
+
onDragEnd: () => setDraggedItemId(null),
|
|
2031
|
+
onDragCancel: () => setDraggedItemId(null),
|
|
2032
|
+
disableDragOverlay: !allowSorting
|
|
2033
|
+
},
|
|
2034
|
+
virtualizer.getVirtualItems().map((virtualRow) => {
|
|
2035
|
+
const cssClass = filteredCssClasses[virtualRow.index];
|
|
2036
|
+
return /* @__PURE__ */ React17.createElement(
|
|
2037
|
+
SortableItem,
|
|
2038
|
+
{
|
|
2039
|
+
key: virtualRow.key,
|
|
2040
|
+
id: cssClass.id,
|
|
2041
|
+
style: {
|
|
2042
|
+
position: "absolute",
|
|
2043
|
+
top: virtualRow.start,
|
|
2044
|
+
left: 0,
|
|
2045
|
+
width: "100%"
|
|
2046
|
+
}
|
|
2016
2047
|
},
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2048
|
+
({ isDragged, isDragPlaceholder, triggerProps, triggerStyle }) => /* @__PURE__ */ React17.createElement(
|
|
2049
|
+
ClassItem,
|
|
2050
|
+
{
|
|
2051
|
+
id: cssClass.id,
|
|
2052
|
+
label: cssClass.label,
|
|
2053
|
+
renameClass: (newLabel) => {
|
|
2054
|
+
trackGlobalClasses({
|
|
2055
|
+
event: "classRenamed",
|
|
2056
|
+
classId: cssClass.id,
|
|
2057
|
+
oldValue: cssClass.label,
|
|
2058
|
+
newValue: newLabel,
|
|
2059
|
+
source: "class-manager"
|
|
2060
|
+
});
|
|
2061
|
+
dispatch5(
|
|
2062
|
+
slice.actions.update({
|
|
2063
|
+
style: {
|
|
2064
|
+
id: cssClass.id,
|
|
2065
|
+
label: newLabel
|
|
2066
|
+
}
|
|
2067
|
+
})
|
|
2068
|
+
);
|
|
2069
|
+
},
|
|
2070
|
+
selected: isDragged,
|
|
2071
|
+
disabled: disabled || isDragPlaceholder,
|
|
2072
|
+
sortableTriggerProps: {
|
|
2073
|
+
...triggerProps,
|
|
2074
|
+
style: triggerStyle
|
|
2075
|
+
},
|
|
2076
|
+
showSortIndicator: allowSorting,
|
|
2077
|
+
syncToV3: cssClass.sync_to_v3,
|
|
2078
|
+
onToggleSync: (id2, newValue) => {
|
|
2079
|
+
if (!newValue && onStopSyncRequest) {
|
|
2080
|
+
onStopSyncRequest(id2);
|
|
2081
|
+
} else if (newValue && onStartSyncRequest) {
|
|
2082
|
+
onStartSyncRequest(id2);
|
|
2083
|
+
} else {
|
|
2084
|
+
dispatch5(
|
|
2085
|
+
slice.actions.update({
|
|
2086
|
+
style: {
|
|
2087
|
+
id: id2,
|
|
2088
|
+
sync_to_v3: newValue
|
|
2089
|
+
}
|
|
2090
|
+
})
|
|
2091
|
+
);
|
|
2092
|
+
}
|
|
2093
|
+
}
|
|
2033
2094
|
}
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
)
|
|
2037
|
-
|
|
2038
|
-
))
|
|
2095
|
+
)
|
|
2096
|
+
);
|
|
2097
|
+
})
|
|
2098
|
+
)
|
|
2099
|
+
));
|
|
2039
2100
|
};
|
|
2040
2101
|
var EmptyState = () => /* @__PURE__ */ React17.createElement(import_ui14.Stack, { 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" }, (0, import_i18n13.__)("There are no global classes yet.", "elementor")), /* @__PURE__ */ React17.createElement(import_ui14.Typography, { align: "center", variant: "caption", color: "text.secondary" }, (0, import_i18n13.__)(
|
|
2041
2102
|
"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.",
|
|
@@ -2156,16 +2217,6 @@ var StartSyncToV3Modal = ({
|
|
|
2156
2217
|
// src/components/class-manager/class-manager-panel.tsx
|
|
2157
2218
|
var STOP_SYNC_MESSAGE_KEY = "stop-sync-class";
|
|
2158
2219
|
var id = "global-classes-manager";
|
|
2159
|
-
var reloadDocument = () => {
|
|
2160
|
-
const currentDocument = (0, import_editor_documents3.getCurrentDocument)();
|
|
2161
|
-
const documentsManager = (0, import_editor_documents3.getV1DocumentsManager)();
|
|
2162
|
-
documentsManager.invalidateCache();
|
|
2163
|
-
return (0, import_editor_v1_adapters2.__privateRunCommand)("editor/documents/switch", {
|
|
2164
|
-
id: currentDocument?.id,
|
|
2165
|
-
shouldScroll: false,
|
|
2166
|
-
shouldNavigateToDefaultRoute: false
|
|
2167
|
-
});
|
|
2168
|
-
};
|
|
2169
2220
|
var { panel, usePanelActions } = (0, import_editor_panels.__createPanel)({
|
|
2170
2221
|
id,
|
|
2171
2222
|
component: ClassManagerPanel,
|
|
@@ -2176,7 +2227,7 @@ var { panel, usePanelActions } = (0, import_editor_panels.__createPanel)({
|
|
|
2176
2227
|
},
|
|
2177
2228
|
onClose: async () => {
|
|
2178
2229
|
(0, import_editor_v1_adapters2.changeEditMode)("edit");
|
|
2179
|
-
await
|
|
2230
|
+
await (0, import_editor_documents3.reloadCurrentDocument)();
|
|
2180
2231
|
unblockPanelInteractions();
|
|
2181
2232
|
},
|
|
2182
2233
|
isOpenPreviousElement: true
|
|
@@ -2188,6 +2239,7 @@ function ClassManagerPanel() {
|
|
|
2188
2239
|
const [stopSyncConfirmation, setStopSyncConfirmation] = (0, import_react10.useState)(null);
|
|
2189
2240
|
const [startSyncConfirmation, setStartSyncConfirmation] = (0, import_react10.useState)(null);
|
|
2190
2241
|
const [isStopSyncSuppressed] = (0, import_editor_current_user2.useSuppressedMessage)(STOP_SYNC_MESSAGE_KEY);
|
|
2242
|
+
const [scrollElement, setScrollElement] = (0, import_react10.useState)(null);
|
|
2191
2243
|
const { mutateAsync: publish, isPending: isPublishing } = usePublish();
|
|
2192
2244
|
const resetAndClosePanel = () => {
|
|
2193
2245
|
(0, import_store20.__dispatch)(slice.actions.resetToInitialState({ context: "frontend" }));
|
|
@@ -2255,6 +2307,7 @@ function ClassManagerPanel() {
|
|
|
2255
2307
|
/* @__PURE__ */ React19.createElement(
|
|
2256
2308
|
import_ui16.Box,
|
|
2257
2309
|
{
|
|
2310
|
+
ref: setScrollElement,
|
|
2258
2311
|
px: 2,
|
|
2259
2312
|
sx: {
|
|
2260
2313
|
flexGrow: 1,
|
|
@@ -2265,6 +2318,7 @@ function ClassManagerPanel() {
|
|
|
2265
2318
|
GlobalClassesList,
|
|
2266
2319
|
{
|
|
2267
2320
|
disabled: isPublishing,
|
|
2321
|
+
scrollElement,
|
|
2268
2322
|
onStopSyncRequest: handleStopSyncRequest,
|
|
2269
2323
|
onStartSyncRequest: (classId) => setStartSyncConfirmation(classId)
|
|
2270
2324
|
}
|
|
@@ -2485,6 +2539,7 @@ function createClassName(prefix) {
|
|
|
2485
2539
|
|
|
2486
2540
|
// src/components/global-styles-import-listener.tsx
|
|
2487
2541
|
var import_react11 = require("react");
|
|
2542
|
+
var import_editor_canvas = require("@elementor/editor-canvas");
|
|
2488
2543
|
var import_store22 = require("@elementor/store");
|
|
2489
2544
|
function GlobalStylesImportListener() {
|
|
2490
2545
|
const dispatch5 = (0, import_store22.__useDispatch)();
|
|
@@ -2523,12 +2578,9 @@ function GlobalStylesImportListener() {
|
|
|
2523
2578
|
}).catch(() => {
|
|
2524
2579
|
});
|
|
2525
2580
|
};
|
|
2526
|
-
window.addEventListener(
|
|
2581
|
+
window.addEventListener(import_editor_canvas.GLOBAL_STYLES_IMPORTED_EVENT, handleGlobalStylesImported);
|
|
2527
2582
|
return () => {
|
|
2528
|
-
window.removeEventListener(
|
|
2529
|
-
"elementor/global-styles/imported",
|
|
2530
|
-
handleGlobalStylesImported
|
|
2531
|
-
);
|
|
2583
|
+
window.removeEventListener(import_editor_canvas.GLOBAL_STYLES_IMPORTED_EVENT, handleGlobalStylesImported);
|
|
2532
2584
|
};
|
|
2533
2585
|
}, [dispatch5]);
|
|
2534
2586
|
return null;
|
|
@@ -2755,7 +2807,7 @@ function initMcpApplyGetGlobalClassUsages(reg) {
|
|
|
2755
2807
|
}
|
|
2756
2808
|
|
|
2757
2809
|
// src/mcp-integration/mcp-manage-global-classes.ts
|
|
2758
|
-
var
|
|
2810
|
+
var import_editor_canvas2 = require("@elementor/editor-canvas");
|
|
2759
2811
|
var import_editor_props = require("@elementor/editor-props");
|
|
2760
2812
|
var import_editor_styles3 = require("@elementor/editor-styles");
|
|
2761
2813
|
var import_schema3 = require("@elementor/schema");
|
|
@@ -2915,8 +2967,8 @@ var initManageGlobalClasses = (reg) => {
|
|
|
2915
2967
|
name: "manage-global-classes",
|
|
2916
2968
|
requiredResources: [
|
|
2917
2969
|
{ uri: GLOBAL_CLASSES_URI, description: "Global classes list" },
|
|
2918
|
-
{ uri:
|
|
2919
|
-
{ uri:
|
|
2970
|
+
{ uri: import_editor_canvas2.STYLE_SCHEMA_URI, description: "Style schema resources" },
|
|
2971
|
+
{ uri: import_editor_canvas2.BREAKPOINTS_SCHEMA_URI, description: "Breakpoints list" }
|
|
2920
2972
|
],
|
|
2921
2973
|
modelPreferences: {
|
|
2922
2974
|
intelligencePriority: 0.85,
|