@elementor/editor-global-classes 4.1.0-720 → 4.1.0-722
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 +78 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +90 -28
- package/dist/index.mjs.map +1 -1
- package/package.json +20 -20
- package/src/components/class-manager/class-manager-panel.tsx +4 -0
- package/src/components/class-manager/start-sync-to-v3-modal.tsx +28 -2
- package/src/init.ts +5 -1
- package/src/mcp-integration/classes-resource.ts +2 -5
- package/src/mcp-integration/index.ts +13 -6
- package/src/utils/tracking.ts +48 -0
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// src/mcp-integration/classes-resource.ts
|
|
2
|
-
import { getMCPByDomain } from "@elementor/editor-mcp";
|
|
3
|
-
|
|
4
1
|
// src/global-classes-styles-provider.ts
|
|
5
2
|
import { generateId } from "@elementor/editor-styles";
|
|
6
3
|
import { createStylesProvider } from "@elementor/editor-styles-repository";
|
|
@@ -359,6 +356,41 @@ var getSanitizedData = async (payload) => {
|
|
|
359
356
|
return { ...payload, classTitle: getCssClass(payload.classId).label };
|
|
360
357
|
}
|
|
361
358
|
break;
|
|
359
|
+
case "classSyncToV3PopupShown":
|
|
360
|
+
return {
|
|
361
|
+
...payload,
|
|
362
|
+
interaction_type: "popup_shown",
|
|
363
|
+
target_type: "popup",
|
|
364
|
+
target_name: "sync_to_v3_popup",
|
|
365
|
+
interaction_result: "popup_viewed",
|
|
366
|
+
target_location: "widget_panel",
|
|
367
|
+
location_l1: "class_manager"
|
|
368
|
+
};
|
|
369
|
+
case "classSyncToV3": {
|
|
370
|
+
const classLabel = getCssClass(payload.classId).label;
|
|
371
|
+
const isSync = payload.action === "sync";
|
|
372
|
+
return {
|
|
373
|
+
...payload,
|
|
374
|
+
interaction_type: "click",
|
|
375
|
+
target_type: classLabel,
|
|
376
|
+
target_name: isSync ? "sync_to_v3" : "unsync_to_v3",
|
|
377
|
+
interaction_result: isSync ? "class_is_synced_to_V3" : "class_is_unsynced_from_V3",
|
|
378
|
+
target_location: "widget_panel",
|
|
379
|
+
location_l1: "class_manager",
|
|
380
|
+
interaction_description: isSync ? `user_synced_${classLabel}_to_v3` : `user_unsync_${classLabel}_from_v3`
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
case "classSyncToV3PopupClick": {
|
|
384
|
+
const isSyncAction = payload.action === "sync";
|
|
385
|
+
return {
|
|
386
|
+
...payload,
|
|
387
|
+
interaction_type: "click",
|
|
388
|
+
target_type: "button",
|
|
389
|
+
target_name: isSyncAction ? "sync_to_v3" : "cancel",
|
|
390
|
+
interaction_result: isSyncAction ? "class_is_synced" : "cancel",
|
|
391
|
+
target_location: "sync_to_v3_popup"
|
|
392
|
+
};
|
|
393
|
+
}
|
|
362
394
|
default:
|
|
363
395
|
return payload;
|
|
364
396
|
}
|
|
@@ -504,9 +536,7 @@ var updateLocalStorageCache = () => {
|
|
|
504
536
|
const classes = globalClassesStylesProvider.actions.all();
|
|
505
537
|
localStorage.setItem(STORAGE_KEY, JSON.stringify(classes));
|
|
506
538
|
};
|
|
507
|
-
var initClassesResource = () => {
|
|
508
|
-
const canvasMcpEntry = getMCPByDomain("canvas");
|
|
509
|
-
const classesMcpEntry = getMCPByDomain("classes");
|
|
539
|
+
var initClassesResource = (classesMcpEntry, canvasMcpEntry) => {
|
|
510
540
|
[canvasMcpEntry, classesMcpEntry].forEach((entry) => {
|
|
511
541
|
const { mcpServer, resource, waitForReady } = entry;
|
|
512
542
|
resource(
|
|
@@ -538,6 +568,7 @@ import {
|
|
|
538
568
|
injectIntoCssClassConvert,
|
|
539
569
|
registerStyleProviderToColors
|
|
540
570
|
} from "@elementor/editor-editing-panel";
|
|
571
|
+
import { getMCPByDomain } from "@elementor/editor-mcp";
|
|
541
572
|
import { __registerPanel as registerPanel } from "@elementor/editor-panels";
|
|
542
573
|
import { stylesRepository } from "@elementor/editor-styles-repository";
|
|
543
574
|
import { __registerSlice as registerSlice } from "@elementor/store";
|
|
@@ -576,7 +607,7 @@ var PrefetchCssClassUsage = () => {
|
|
|
576
607
|
|
|
577
608
|
// src/components/class-manager/class-manager-panel.tsx
|
|
578
609
|
import * as React19 from "react";
|
|
579
|
-
import { useCallback, useEffect as
|
|
610
|
+
import { useCallback, useEffect as useEffect4, useState as useState7 } from "react";
|
|
580
611
|
import { useSuppressedMessage as useSuppressedMessage2 } from "@elementor/editor-current-user";
|
|
581
612
|
import { getCurrentDocument, getV1DocumentsManager, setDocumentModifiedStatus } from "@elementor/editor-documents";
|
|
582
613
|
import {
|
|
@@ -2107,7 +2138,7 @@ function unblockPanelInteractions() {
|
|
|
2107
2138
|
|
|
2108
2139
|
// src/components/class-manager/start-sync-to-v3-modal.tsx
|
|
2109
2140
|
import * as React18 from "react";
|
|
2110
|
-
import { useState as useState6 } from "react";
|
|
2141
|
+
import { useEffect as useEffect3, useRef as useRef2, useState as useState6 } from "react";
|
|
2111
2142
|
import {
|
|
2112
2143
|
Box as Box10,
|
|
2113
2144
|
Button as Button2,
|
|
@@ -2120,12 +2151,33 @@ import {
|
|
|
2120
2151
|
} from "@elementor/ui";
|
|
2121
2152
|
import { __ as __14 } from "@wordpress/i18n";
|
|
2122
2153
|
var IMAGE_URL = "https://assets.elementor.com/packages/v1/images/class-manager-sync-modal.png";
|
|
2123
|
-
var StartSyncToV3Modal = ({
|
|
2154
|
+
var StartSyncToV3Modal = ({
|
|
2155
|
+
externalOpen,
|
|
2156
|
+
classId,
|
|
2157
|
+
onExternalClose,
|
|
2158
|
+
onConfirm
|
|
2159
|
+
} = {}) => {
|
|
2124
2160
|
const [shouldShowAgain, setShouldShowAgain] = useState6(true);
|
|
2161
|
+
const hasTrackedExposure = useRef2(false);
|
|
2162
|
+
useEffect3(() => {
|
|
2163
|
+
if (externalOpen && classId && !hasTrackedExposure.current) {
|
|
2164
|
+
hasTrackedExposure.current = true;
|
|
2165
|
+
trackGlobalClasses({ event: "classSyncToV3PopupShown", classId });
|
|
2166
|
+
}
|
|
2167
|
+
if (!externalOpen) {
|
|
2168
|
+
hasTrackedExposure.current = false;
|
|
2169
|
+
}
|
|
2170
|
+
}, [externalOpen, classId]);
|
|
2125
2171
|
const handleClose = () => {
|
|
2172
|
+
if (classId) {
|
|
2173
|
+
trackGlobalClasses({ event: "classSyncToV3PopupClick", classId, action: "cancel" });
|
|
2174
|
+
}
|
|
2126
2175
|
onExternalClose?.();
|
|
2127
2176
|
};
|
|
2128
2177
|
const handleConfirm = () => {
|
|
2178
|
+
if (classId) {
|
|
2179
|
+
trackGlobalClasses({ event: "classSyncToV3PopupClick", classId, action: "sync" });
|
|
2180
|
+
}
|
|
2129
2181
|
onConfirm?.();
|
|
2130
2182
|
onExternalClose?.();
|
|
2131
2183
|
};
|
|
@@ -2196,6 +2248,7 @@ function ClassManagerPanel() {
|
|
|
2196
2248
|
}
|
|
2197
2249
|
})
|
|
2198
2250
|
);
|
|
2251
|
+
trackGlobalClasses({ event: "classSyncToV3", classId, action: "unsync" });
|
|
2199
2252
|
setStopSyncConfirmation(null);
|
|
2200
2253
|
}, []);
|
|
2201
2254
|
const handleStartSync = useCallback((classId) => {
|
|
@@ -2207,6 +2260,7 @@ function ClassManagerPanel() {
|
|
|
2207
2260
|
}
|
|
2208
2261
|
})
|
|
2209
2262
|
);
|
|
2263
|
+
trackGlobalClasses({ event: "classSyncToV3", classId, action: "sync" });
|
|
2210
2264
|
setStartSyncConfirmation(null);
|
|
2211
2265
|
}, []);
|
|
2212
2266
|
const handleStopSyncRequest = useCallback(
|
|
@@ -2278,6 +2332,7 @@ function ClassManagerPanel() {
|
|
|
2278
2332
|
StartSyncToV3Modal,
|
|
2279
2333
|
{
|
|
2280
2334
|
externalOpen: true,
|
|
2335
|
+
classId: startSyncConfirmation,
|
|
2281
2336
|
onExternalClose: () => setStartSyncConfirmation(null),
|
|
2282
2337
|
onConfirm: () => handleStartSync(startSyncConfirmation)
|
|
2283
2338
|
}
|
|
@@ -2314,7 +2369,7 @@ var CloseButton = ({ onClose, ...props }) => /* @__PURE__ */ React19.createEleme
|
|
|
2314
2369
|
var ErrorBoundaryFallback = () => /* @__PURE__ */ React19.createElement(Box11, { role: "alert", sx: { minHeight: "100%", p: 2 } }, /* @__PURE__ */ React19.createElement(Alert2, { severity: "error", sx: { mb: 2, maxWidth: 400, textAlign: "center" } }, /* @__PURE__ */ React19.createElement("strong", null, __15("Something went wrong", "elementor"))));
|
|
2315
2370
|
var usePreventUnload = () => {
|
|
2316
2371
|
const isDirty2 = useDirtyState();
|
|
2317
|
-
|
|
2372
|
+
useEffect4(() => {
|
|
2318
2373
|
const handleBeforeUnload = (event) => {
|
|
2319
2374
|
if (isDirty2) {
|
|
2320
2375
|
event.preventDefault();
|
|
@@ -2475,11 +2530,11 @@ function createClassName(prefix) {
|
|
|
2475
2530
|
}
|
|
2476
2531
|
|
|
2477
2532
|
// src/components/global-styles-import-listener.tsx
|
|
2478
|
-
import { useEffect as
|
|
2533
|
+
import { useEffect as useEffect5 } from "react";
|
|
2479
2534
|
import { __useDispatch as useDispatch2 } from "@elementor/store";
|
|
2480
2535
|
function GlobalStylesImportListener() {
|
|
2481
2536
|
const dispatch5 = useDispatch2();
|
|
2482
|
-
|
|
2537
|
+
useEffect5(() => {
|
|
2483
2538
|
const handleGlobalStylesImported = (event) => {
|
|
2484
2539
|
const importedClasses = event.detail?.global_classes;
|
|
2485
2540
|
if (importedClasses?.items && importedClasses?.order) {
|
|
@@ -2526,15 +2581,15 @@ function GlobalStylesImportListener() {
|
|
|
2526
2581
|
}
|
|
2527
2582
|
|
|
2528
2583
|
// src/components/open-panel-from-url.tsx
|
|
2529
|
-
import { useEffect as
|
|
2584
|
+
import { useEffect as useEffect6, useRef as useRef3 } from "react";
|
|
2530
2585
|
import { __privateListenTo as listenTo, routeOpenEvent } from "@elementor/editor-v1-adapters";
|
|
2531
2586
|
var ACTIVE_PANEL_PARAM = "active-panel";
|
|
2532
2587
|
var PANEL_ID = "global-classes-manager";
|
|
2533
2588
|
var DEFAULT_PANEL_ROUTE = "panel/elements";
|
|
2534
2589
|
function OpenPanelFromUrl() {
|
|
2535
2590
|
const { open } = usePanelActions();
|
|
2536
|
-
const hasOpened =
|
|
2537
|
-
|
|
2591
|
+
const hasOpened = useRef3(false);
|
|
2592
|
+
useEffect6(() => {
|
|
2538
2593
|
const urlParams = new URLSearchParams(window.location.search);
|
|
2539
2594
|
const activePanel = urlParams.get(ACTIVE_PANEL_PARAM);
|
|
2540
2595
|
if (activePanel !== PANEL_ID) {
|
|
@@ -2555,11 +2610,11 @@ function OpenPanelFromUrl() {
|
|
|
2555
2610
|
}
|
|
2556
2611
|
|
|
2557
2612
|
// src/components/populate-store.tsx
|
|
2558
|
-
import { useEffect as
|
|
2613
|
+
import { useEffect as useEffect7 } from "react";
|
|
2559
2614
|
import { __useDispatch as useDispatch3 } from "@elementor/store";
|
|
2560
2615
|
function PopulateStore() {
|
|
2561
2616
|
const dispatch5 = useDispatch3();
|
|
2562
|
-
|
|
2617
|
+
useEffect7(() => {
|
|
2563
2618
|
Promise.all([apiClient.all("preview"), apiClient.all("frontend")]).then(
|
|
2564
2619
|
([previewRes, frontendRes]) => {
|
|
2565
2620
|
const { data: previewData } = previewRes;
|
|
@@ -2582,9 +2637,6 @@ function PopulateStore() {
|
|
|
2582
2637
|
return null;
|
|
2583
2638
|
}
|
|
2584
2639
|
|
|
2585
|
-
// src/mcp-integration/index.ts
|
|
2586
|
-
import { getMCPByDomain as getMCPByDomain2 } from "@elementor/editor-mcp";
|
|
2587
|
-
|
|
2588
2640
|
// src/mcp-integration/mcp-apply-unapply-global-classes.ts
|
|
2589
2641
|
import { doApplyClasses, doGetAppliedClasses, doUnapplyClass } from "@elementor/editor-editing-panel";
|
|
2590
2642
|
import { z } from "@elementor/schema";
|
|
@@ -3013,18 +3065,25 @@ async function attemptDelete(opts) {
|
|
|
3013
3065
|
}
|
|
3014
3066
|
|
|
3015
3067
|
// src/mcp-integration/index.ts
|
|
3016
|
-
var initMcpIntegration = () => {
|
|
3017
|
-
const
|
|
3018
|
-
|
|
3019
|
-
|
|
3068
|
+
var initMcpIntegration = (reg, canvasMcpEntry) => {
|
|
3069
|
+
const { setMCPDescription } = reg;
|
|
3070
|
+
setMCPDescription(
|
|
3071
|
+
`Everything related to V4 ( Atomic ) global classes.
|
|
3072
|
+
# Global classes
|
|
3073
|
+
- Create/update/delete global classes
|
|
3074
|
+
- Get list of global classes
|
|
3075
|
+
- Get details of a global class
|
|
3076
|
+
- Get details of a global class
|
|
3077
|
+
`
|
|
3078
|
+
);
|
|
3020
3079
|
initMcpApplyUnapplyGlobalClasses(reg);
|
|
3021
3080
|
initMcpApplyGetGlobalClassUsages(reg);
|
|
3022
3081
|
initManageGlobalClasses(reg);
|
|
3023
|
-
initClassesResource();
|
|
3082
|
+
initClassesResource(reg, canvasMcpEntry);
|
|
3024
3083
|
};
|
|
3025
3084
|
|
|
3026
3085
|
// src/sync-with-document.tsx
|
|
3027
|
-
import { useEffect as
|
|
3086
|
+
import { useEffect as useEffect8 } from "react";
|
|
3028
3087
|
import { __privateListenTo as listenTo2, v1ReadyEvent } from "@elementor/editor-v1-adapters";
|
|
3029
3088
|
|
|
3030
3089
|
// src/sync-with-document-save.ts
|
|
@@ -3089,7 +3148,7 @@ function isDirty() {
|
|
|
3089
3148
|
// src/sync-with-document.tsx
|
|
3090
3149
|
function SyncWithDocumentSave() {
|
|
3091
3150
|
const panelActions = usePanelActions();
|
|
3092
|
-
|
|
3151
|
+
useEffect8(() => {
|
|
3093
3152
|
listenTo2(v1ReadyEvent(), () => {
|
|
3094
3153
|
syncWithDocumentSave(panelActions);
|
|
3095
3154
|
});
|
|
@@ -3134,7 +3193,10 @@ function init() {
|
|
|
3134
3193
|
name: "global",
|
|
3135
3194
|
getThemeColor: (theme) => theme.palette.global.dark
|
|
3136
3195
|
});
|
|
3137
|
-
initMcpIntegration(
|
|
3196
|
+
initMcpIntegration(
|
|
3197
|
+
getMCPByDomain("classes", { instructions: "MCP server for management of Elementor global classes" }),
|
|
3198
|
+
getMCPByDomain("canvas")
|
|
3199
|
+
);
|
|
3138
3200
|
}
|
|
3139
3201
|
export {
|
|
3140
3202
|
GLOBAL_CLASSES_URI,
|