@elementor/editor-global-classes 4.1.0-beta1 → 4.1.0-beta2

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();
@@ -3370,7 +3410,7 @@ var initMcpIntegration = (reg, canvasMcpEntry) => {
3370
3410
  };
3371
3411
 
3372
3412
  // src/sync-with-document.tsx
3373
- import { useEffect as useEffect8 } from "react";
3413
+ import { useEffect as useEffect9 } from "react";
3374
3414
  import { __privateListenTo as listenTo2, isExperimentActive as isExperimentActive3, v1ReadyEvent } from "@elementor/editor-v1-adapters";
3375
3415
 
3376
3416
  // src/sync-with-document-save.ts
@@ -3435,7 +3475,7 @@ function isDirty() {
3435
3475
  // src/sync-with-document.tsx
3436
3476
  function SyncWithDocumentSave() {
3437
3477
  const { open: openClassPanel } = usePanelActions();
3438
- useEffect8(() => {
3478
+ useEffect9(() => {
3439
3479
  const unsubscribe = listenTo2(v1ReadyEvent(), () => {
3440
3480
  const open = isExperimentActive3("e_editor_design_system_panel") ? () => {
3441
3481
  window.dispatchEvent(new CustomEvent("elementor/open-global-classes-manager"));
@@ -3475,6 +3515,10 @@ function init() {
3475
3515
  id: "global-classes-open-panel-from-url",
3476
3516
  component: OpenPanelFromUrl
3477
3517
  });
3518
+ injectIntoLogic({
3519
+ id: "global-classes-open-panel-from-event",
3520
+ component: OpenPanelFromEvent
3521
+ });
3478
3522
  }
3479
3523
  injectIntoCssClassConvert({
3480
3524
  id: "global-classes-convert-from-local-class",