@elementor/editor-global-classes 4.2.0-870 → 4.2.0-872

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.mjs CHANGED
@@ -263,6 +263,20 @@ var slice = createSlice({
263
263
  state.classLabels[id2] = previewClassData.label;
264
264
  }
265
265
  });
266
+ },
267
+ setOrderWithoutHistory(state, { payload }) {
268
+ state.data.order = payload;
269
+ },
270
+ updateAfterTemplateImport(state, {
271
+ payload
272
+ }) {
273
+ state.initialData.frontend.items = { ...state.initialData.frontend.items, ...payload.addedItems };
274
+ state.initialData.frontend.order = [...state.initialData.frontend.order, ...payload.addedIdsOrder];
275
+ state.initialData.preview.items = { ...state.initialData.preview.items, ...payload.addedItems };
276
+ state.initialData.preview.order = [...state.initialData.preview.order, ...payload.addedIdsOrder];
277
+ state.data.items = { ...state.data.items, ...payload.addedItems };
278
+ state.data.order = [...state.data.order, ...payload.addedIdsOrder];
279
+ state.classLabels = { ...state.classLabels, ...payload.addedClassLabels };
266
280
  }
267
281
  }
268
282
  });
@@ -2062,8 +2076,9 @@ var useFilteredCssClasses = () => {
2062
2076
  [cssClasses]
2063
2077
  );
2064
2078
  const filteredClasses = useMemo3(() => {
2065
- if (searchValue.length > 1) {
2066
- return lowercaseLabels.filter((cssClass) => cssClass.lowerLabel.includes(searchValue.toLowerCase()));
2079
+ const normalizedSearch = searchValue.replace(/[^a-zA-Z0-9_-]/g, "").toLowerCase();
2080
+ if (normalizedSearch.length > 1) {
2081
+ return lowercaseLabels.filter((cssClass) => cssClass.lowerLabel.includes(normalizedSearch));
2067
2082
  }
2068
2083
  return cssClasses;
2069
2084
  }, [searchValue, cssClasses, lowercaseLabels]);
@@ -2576,7 +2591,7 @@ async function fetchAndMergeClasses() {
2576
2591
  }
2577
2592
 
2578
2593
  // src/global-classes-styles-provider.ts
2579
- var MAX_CLASSES = 5e3;
2594
+ var MAX_CLASSES = 1e3;
2580
2595
  var GLOBAL_CLASSES_PROVIDER_KEY = "global-classes";
2581
2596
  var PREGENERATED_LINK_PATTERN = /^global-([0-9]+-)?(preview|frontend)-[a-zA-Z_-]+-css$/;
2582
2597
  var globalClassesStylesProvider = createStylesProvider({
@@ -2874,8 +2889,20 @@ import { __useDispatch as useDispatch2 } from "@elementor/store";
2874
2889
  function GlobalStylesImportListener() {
2875
2890
  const dispatch7 = useDispatch2();
2876
2891
  useEffect5(() => {
2877
- const handleGlobalStylesImported = () => {
2878
- loadCurrentDocumentClasses();
2892
+ const handleGlobalStylesImported = async (event) => {
2893
+ const customEvent = event;
2894
+ const globalClasses = customEvent.detail?.global_classes;
2895
+ if (!globalClasses?.added_items_order || !globalClasses?.added_items || globalClasses?.added_items_order?.length === 0) {
2896
+ loadCurrentDocumentClasses();
2897
+ return;
2898
+ }
2899
+ dispatch7(
2900
+ slice.actions.updateAfterTemplateImport({
2901
+ addedItems: globalClasses.added_items,
2902
+ addedIdsOrder: globalClasses.added_items_order,
2903
+ addedClassLabels: createLabelsForClasses(Object.values(globalClasses.added_items))
2904
+ })
2905
+ );
2879
2906
  };
2880
2907
  window.addEventListener(GLOBAL_STYLES_IMPORTED_EVENT, handleGlobalStylesImported);
2881
2908
  return () => {
@@ -2885,8 +2912,21 @@ function GlobalStylesImportListener() {
2885
2912
  return null;
2886
2913
  }
2887
2914
 
2915
+ // src/components/open-panel-from-event.tsx
2916
+ import { useEffect as useEffect6 } from "react";
2917
+ var EVENT_OPEN_GLOBAL_CLASSES_MANAGER = "elementor/open-global-classes-manager";
2918
+ function OpenPanelFromEvent() {
2919
+ const { open } = usePanelActions();
2920
+ useEffect6(() => {
2921
+ const handler2 = () => open();
2922
+ window.addEventListener(EVENT_OPEN_GLOBAL_CLASSES_MANAGER, handler2);
2923
+ return () => window.removeEventListener(EVENT_OPEN_GLOBAL_CLASSES_MANAGER, handler2);
2924
+ }, [open]);
2925
+ return null;
2926
+ }
2927
+
2888
2928
  // src/components/open-panel-from-url.tsx
2889
- import { useEffect as useEffect6, useRef as useRef3 } from "react";
2929
+ import { useEffect as useEffect7, useRef as useRef3 } from "react";
2890
2930
  import { __privateListenTo as listenTo, routeOpenEvent } from "@elementor/editor-v1-adapters";
2891
2931
  var ACTIVE_PANEL_PARAM = "active-panel";
2892
2932
  var PANEL_ID = "global-classes-manager";
@@ -2894,7 +2934,7 @@ var DEFAULT_PANEL_ROUTE = "panel/elements";
2894
2934
  function OpenPanelFromUrl() {
2895
2935
  const { open } = usePanelActions();
2896
2936
  const hasOpened = useRef3(false);
2897
- useEffect6(() => {
2937
+ useEffect7(() => {
2898
2938
  const urlParams = new URLSearchParams(window.location.search);
2899
2939
  const activePanel = urlParams.get(ACTIVE_PANEL_PARAM);
2900
2940
  if (activePanel !== PANEL_ID) {
@@ -2915,10 +2955,10 @@ function OpenPanelFromUrl() {
2915
2955
  }
2916
2956
 
2917
2957
  // src/components/populate-store.tsx
2918
- import { useEffect as useEffect7 } from "react";
2958
+ import { useEffect as useEffect8 } from "react";
2919
2959
  import { registerDataHook } from "@elementor/editor-v1-adapters";
2920
2960
  function PopulateStore() {
2921
- useEffect7(() => {
2961
+ useEffect8(() => {
2922
2962
  loadCurrentDocumentClasses();
2923
2963
  registerDataHook("after", "editor/documents/attach-preview", async () => {
2924
2964
  await loadCurrentDocumentClasses();
@@ -3354,7 +3394,7 @@ var initMcpIntegration = (reg, canvasMcpEntry) => {
3354
3394
  };
3355
3395
 
3356
3396
  // src/sync-with-document.tsx
3357
- import { useEffect as useEffect8 } from "react";
3397
+ import { useEffect as useEffect9 } from "react";
3358
3398
  import { __privateListenTo as listenTo2, isExperimentActive as isExperimentActive3, v1ReadyEvent } from "@elementor/editor-v1-adapters";
3359
3399
 
3360
3400
  // src/sync-with-document-save.ts
@@ -3419,7 +3459,7 @@ function isDirty() {
3419
3459
  // src/sync-with-document.tsx
3420
3460
  function SyncWithDocumentSave() {
3421
3461
  const { open: openClassPanel } = usePanelActions();
3422
- useEffect8(() => {
3462
+ useEffect9(() => {
3423
3463
  const unsubscribe = listenTo2(v1ReadyEvent(), () => {
3424
3464
  const open = isExperimentActive3("e_editor_design_system_panel") ? () => {
3425
3465
  window.dispatchEvent(new CustomEvent("elementor/open-global-classes-manager"));
@@ -3459,6 +3499,10 @@ function init() {
3459
3499
  id: "global-classes-open-panel-from-url",
3460
3500
  component: OpenPanelFromUrl
3461
3501
  });
3502
+ injectIntoLogic({
3503
+ id: "global-classes-open-panel-from-event",
3504
+ component: OpenPanelFromEvent
3505
+ });
3462
3506
  }
3463
3507
  injectIntoCssClassConvert({
3464
3508
  id: "global-classes-convert-from-local-class",