@elementor/editor-components 4.2.0-935 → 4.2.0-936
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.d.mts +1 -13
- package/dist/index.d.ts +1 -13
- package/dist/index.js +34 -112
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -110
- package/dist/index.mjs.map +1 -1
- package/package.json +23 -24
- package/src/index.ts +0 -1
- package/src/init.ts +12 -9
- package/src/store/actions/load-components-assets.ts +5 -3
- package/src/store/actions/remove-component-styles.ts +0 -4
- package/src/store/dispatchers.ts +0 -6
- package/src/store/extensible-slice.ts +0 -8
- package/src/store/store-types.ts +1 -9
- package/src/store/store.ts +0 -16
- package/src/sync/publish-draft-components-in-page-before-save.ts +1 -1
- package/src/types.ts +0 -3
- package/src/utils/get-component-documents.ts +18 -8
- package/src/store/actions/load-components-styles.ts +0 -50
- package/src/store/components-styles-provider.ts +0 -26
package/dist/index.d.mts
CHANGED
|
@@ -4,7 +4,6 @@ import { V1ElementData, V1Element, V1ElementModelProps } from '@elementor/editor
|
|
|
4
4
|
import { HttpResponse } from '@elementor/http-client';
|
|
5
5
|
import * as _elementor_editor_props from '@elementor/editor-props';
|
|
6
6
|
import { PropValue, AnyTransformable } from '@elementor/editor-props';
|
|
7
|
-
import { StyleDefinition } from '@elementor/editor-styles';
|
|
8
7
|
import * as React from 'react';
|
|
9
8
|
import { ElementType, PropsWithChildren } from 'react';
|
|
10
9
|
import { z } from '@elementor/schema';
|
|
@@ -22,7 +21,6 @@ type ComponentFormValues = {
|
|
|
22
21
|
componentName: string;
|
|
23
22
|
};
|
|
24
23
|
type ComponentId = number;
|
|
25
|
-
type StylesDefinition = Record<ComponentId, StyleDefinition[]>;
|
|
26
24
|
type Component = PublishedComponent | UnpublishedComponent;
|
|
27
25
|
type PublishedComponent = BaseComponent & {
|
|
28
26
|
id: number;
|
|
@@ -1256,7 +1254,6 @@ type ComponentsState = {
|
|
|
1256
1254
|
data: PublishedComponent[];
|
|
1257
1255
|
unpublishedData: UnpublishedComponent[];
|
|
1258
1256
|
loadStatus: 'idle' | 'pending' | 'error';
|
|
1259
|
-
styles: StylesDefinition;
|
|
1260
1257
|
createdThisSession: Component['uid'][];
|
|
1261
1258
|
archivedThisSession: ComponentId[];
|
|
1262
1259
|
path: ComponentsPathItem[];
|
|
@@ -1284,13 +1281,6 @@ declare const baseSlice: _reduxjs_toolkit.Slice<ComponentsState, {
|
|
|
1284
1281
|
addUnpublished: (state: immer_dist_internal_js.WritableDraft<ComponentsState>, { payload }: PayloadAction<UnpublishedComponent>) => void;
|
|
1285
1282
|
removeUnpublished: (state: immer_dist_internal_js.WritableDraft<ComponentsState>, { payload }: PayloadAction<string | string[]>) => void;
|
|
1286
1283
|
resetUnpublished: (state: immer_dist_internal_js.WritableDraft<ComponentsState>) => void;
|
|
1287
|
-
removeStyles(state: immer_dist_internal_js.WritableDraft<ComponentsState>, { payload }: PayloadAction<{
|
|
1288
|
-
id: ComponentId;
|
|
1289
|
-
}>): void;
|
|
1290
|
-
addStyles: (state: immer_dist_internal_js.WritableDraft<ComponentsState>, { payload }: {
|
|
1291
|
-
payload: any;
|
|
1292
|
-
type: string;
|
|
1293
|
-
}) => void;
|
|
1294
1284
|
addCreatedThisSession: (state: immer_dist_internal_js.WritableDraft<ComponentsState>, { payload }: PayloadAction<string>) => void;
|
|
1295
1285
|
removeCreatedThisSession: (state: immer_dist_internal_js.WritableDraft<ComponentsState>, { payload }: PayloadAction<string>) => void;
|
|
1296
1286
|
archive: (state: immer_dist_internal_js.WritableDraft<ComponentsState>, { payload }: PayloadAction<number>) => void;
|
|
@@ -1337,8 +1327,6 @@ declare const componentsActions: {
|
|
|
1337
1327
|
addUnpublished(component: UnpublishedComponent): void;
|
|
1338
1328
|
removeUnpublished(uids: string | string[]): void;
|
|
1339
1329
|
resetUnpublished(): void;
|
|
1340
|
-
removeStyles(id: ComponentId): void;
|
|
1341
|
-
addStyles(styles: Record<string, unknown>): void;
|
|
1342
1330
|
addCreatedThisSession(uid: string): void;
|
|
1343
1331
|
removeCreatedThisSession(uid: string): void;
|
|
1344
1332
|
archive(componentId: ComponentId): void;
|
|
@@ -1426,4 +1414,4 @@ declare const onElementDrop: (_args: unknown, element: V1Element) => void;
|
|
|
1426
1414
|
|
|
1427
1415
|
declare const getComponentDocumentData: (id: number) => Promise<Document | null>;
|
|
1428
1416
|
|
|
1429
|
-
export { COMPONENT_WIDGET_TYPE, type Component, type ComponentFormValues, type ComponentId, type ComponentInstanceOverride, type ComponentInstanceOverrideProp, type ComponentInstanceOverridePropValue, type ComponentInstanceOverridesPropValue, type ComponentInstanceProp, type ComponentInstancePropValue, ComponentInstanceProvider, ComponentItem, type ComponentItemProps, ComponentName, type ComponentOverridableProp, type ComponentOverridablePropValue, ComponentSearch, ComponentsList, type ComponentsPathItem, type ComponentsSlice, type ComponentsState, DetachAction, type DocumentSaveStatus, EditComponentAction, EmptySearchResult, type ExtendedWindow, EmptyState as InstanceEmptyState, InstancePanelBody, InstancePanelHeader, LoadingComponents, type OriginPropFields, type OriginalElementData, type OverridableProp, OverridablePropProvider, type OverridableProps, type OverridablePropsGroup, type PublishedComponent, SLICE_NAME, type SanitizeAttributes, SearchProvider, type Source, type
|
|
1417
|
+
export { COMPONENT_WIDGET_TYPE, type Component, type ComponentFormValues, type ComponentId, type ComponentInstanceOverride, type ComponentInstanceOverrideProp, type ComponentInstanceOverridePropValue, type ComponentInstanceOverridesPropValue, type ComponentInstanceProp, type ComponentInstancePropValue, ComponentInstanceProvider, ComponentItem, type ComponentItemProps, ComponentName, type ComponentOverridableProp, type ComponentOverridablePropValue, ComponentSearch, ComponentsList, type ComponentsPathItem, type ComponentsSlice, type ComponentsState, DetachAction, type DocumentSaveStatus, EditComponentAction, EmptySearchResult, type ExtendedWindow, EmptyState as InstanceEmptyState, InstancePanelBody, InstancePanelHeader, LoadingComponents, type OriginPropFields, type OriginalElementData, type OverridableProp, OverridablePropProvider, type OverridableProps, type OverridablePropsGroup, type PublishedComponent, SLICE_NAME, type SanitizeAttributes, SearchProvider, type Source, type UnpublishedComponent, type UpdatedComponentName, apiClient, componentInstanceOverridePropTypeUtil, componentInstanceOverridesPropTypeUtil, componentInstancePropTypeUtil, componentOverridablePropTypeUtil, componentsActions, componentsSelectors, createComponentsAction, filterValidOverridableProps, getComponentDocumentData, getContainerByOriginId, getOverridableProp, getPropTypeForComponentOverride, init, isComponentInstance, loadComponentsAssets, onElementDrop, publishDraftComponentsInPageBeforeSave, registerComponentsReducer, resolveOverridePropValue, selectOverridableProps, selectPath, slice, switchToComponent, trackComponentEvent, updateOverridableProp, useComponentInstanceElement, useComponents, useComponentsPermissions, useCurrentComponent, useCurrentComponentId, useFilteredComponents, useInstancePanelData, useIsSanitizedComponent, useOverridablePropValue, useOverridableProps, useSanitizeOverridableProps };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { V1ElementData, V1Element, V1ElementModelProps } from '@elementor/editor
|
|
|
4
4
|
import { HttpResponse } from '@elementor/http-client';
|
|
5
5
|
import * as _elementor_editor_props from '@elementor/editor-props';
|
|
6
6
|
import { PropValue, AnyTransformable } from '@elementor/editor-props';
|
|
7
|
-
import { StyleDefinition } from '@elementor/editor-styles';
|
|
8
7
|
import * as React from 'react';
|
|
9
8
|
import { ElementType, PropsWithChildren } from 'react';
|
|
10
9
|
import { z } from '@elementor/schema';
|
|
@@ -22,7 +21,6 @@ type ComponentFormValues = {
|
|
|
22
21
|
componentName: string;
|
|
23
22
|
};
|
|
24
23
|
type ComponentId = number;
|
|
25
|
-
type StylesDefinition = Record<ComponentId, StyleDefinition[]>;
|
|
26
24
|
type Component = PublishedComponent | UnpublishedComponent;
|
|
27
25
|
type PublishedComponent = BaseComponent & {
|
|
28
26
|
id: number;
|
|
@@ -1256,7 +1254,6 @@ type ComponentsState = {
|
|
|
1256
1254
|
data: PublishedComponent[];
|
|
1257
1255
|
unpublishedData: UnpublishedComponent[];
|
|
1258
1256
|
loadStatus: 'idle' | 'pending' | 'error';
|
|
1259
|
-
styles: StylesDefinition;
|
|
1260
1257
|
createdThisSession: Component['uid'][];
|
|
1261
1258
|
archivedThisSession: ComponentId[];
|
|
1262
1259
|
path: ComponentsPathItem[];
|
|
@@ -1284,13 +1281,6 @@ declare const baseSlice: _reduxjs_toolkit.Slice<ComponentsState, {
|
|
|
1284
1281
|
addUnpublished: (state: immer_dist_internal_js.WritableDraft<ComponentsState>, { payload }: PayloadAction<UnpublishedComponent>) => void;
|
|
1285
1282
|
removeUnpublished: (state: immer_dist_internal_js.WritableDraft<ComponentsState>, { payload }: PayloadAction<string | string[]>) => void;
|
|
1286
1283
|
resetUnpublished: (state: immer_dist_internal_js.WritableDraft<ComponentsState>) => void;
|
|
1287
|
-
removeStyles(state: immer_dist_internal_js.WritableDraft<ComponentsState>, { payload }: PayloadAction<{
|
|
1288
|
-
id: ComponentId;
|
|
1289
|
-
}>): void;
|
|
1290
|
-
addStyles: (state: immer_dist_internal_js.WritableDraft<ComponentsState>, { payload }: {
|
|
1291
|
-
payload: any;
|
|
1292
|
-
type: string;
|
|
1293
|
-
}) => void;
|
|
1294
1284
|
addCreatedThisSession: (state: immer_dist_internal_js.WritableDraft<ComponentsState>, { payload }: PayloadAction<string>) => void;
|
|
1295
1285
|
removeCreatedThisSession: (state: immer_dist_internal_js.WritableDraft<ComponentsState>, { payload }: PayloadAction<string>) => void;
|
|
1296
1286
|
archive: (state: immer_dist_internal_js.WritableDraft<ComponentsState>, { payload }: PayloadAction<number>) => void;
|
|
@@ -1337,8 +1327,6 @@ declare const componentsActions: {
|
|
|
1337
1327
|
addUnpublished(component: UnpublishedComponent): void;
|
|
1338
1328
|
removeUnpublished(uids: string | string[]): void;
|
|
1339
1329
|
resetUnpublished(): void;
|
|
1340
|
-
removeStyles(id: ComponentId): void;
|
|
1341
|
-
addStyles(styles: Record<string, unknown>): void;
|
|
1342
1330
|
addCreatedThisSession(uid: string): void;
|
|
1343
1331
|
removeCreatedThisSession(uid: string): void;
|
|
1344
1332
|
archive(componentId: ComponentId): void;
|
|
@@ -1426,4 +1414,4 @@ declare const onElementDrop: (_args: unknown, element: V1Element) => void;
|
|
|
1426
1414
|
|
|
1427
1415
|
declare const getComponentDocumentData: (id: number) => Promise<Document | null>;
|
|
1428
1416
|
|
|
1429
|
-
export { COMPONENT_WIDGET_TYPE, type Component, type ComponentFormValues, type ComponentId, type ComponentInstanceOverride, type ComponentInstanceOverrideProp, type ComponentInstanceOverridePropValue, type ComponentInstanceOverridesPropValue, type ComponentInstanceProp, type ComponentInstancePropValue, ComponentInstanceProvider, ComponentItem, type ComponentItemProps, ComponentName, type ComponentOverridableProp, type ComponentOverridablePropValue, ComponentSearch, ComponentsList, type ComponentsPathItem, type ComponentsSlice, type ComponentsState, DetachAction, type DocumentSaveStatus, EditComponentAction, EmptySearchResult, type ExtendedWindow, EmptyState as InstanceEmptyState, InstancePanelBody, InstancePanelHeader, LoadingComponents, type OriginPropFields, type OriginalElementData, type OverridableProp, OverridablePropProvider, type OverridableProps, type OverridablePropsGroup, type PublishedComponent, SLICE_NAME, type SanitizeAttributes, SearchProvider, type Source, type
|
|
1417
|
+
export { COMPONENT_WIDGET_TYPE, type Component, type ComponentFormValues, type ComponentId, type ComponentInstanceOverride, type ComponentInstanceOverrideProp, type ComponentInstanceOverridePropValue, type ComponentInstanceOverridesPropValue, type ComponentInstanceProp, type ComponentInstancePropValue, ComponentInstanceProvider, ComponentItem, type ComponentItemProps, ComponentName, type ComponentOverridableProp, type ComponentOverridablePropValue, ComponentSearch, ComponentsList, type ComponentsPathItem, type ComponentsSlice, type ComponentsState, DetachAction, type DocumentSaveStatus, EditComponentAction, EmptySearchResult, type ExtendedWindow, EmptyState as InstanceEmptyState, InstancePanelBody, InstancePanelHeader, LoadingComponents, type OriginPropFields, type OriginalElementData, type OverridableProp, OverridablePropProvider, type OverridableProps, type OverridablePropsGroup, type PublishedComponent, SLICE_NAME, type SanitizeAttributes, SearchProvider, type Source, type UnpublishedComponent, type UpdatedComponentName, apiClient, componentInstanceOverridePropTypeUtil, componentInstanceOverridesPropTypeUtil, componentInstancePropTypeUtil, componentOverridablePropTypeUtil, componentsActions, componentsSelectors, createComponentsAction, filterValidOverridableProps, getComponentDocumentData, getContainerByOriginId, getOverridableProp, getPropTypeForComponentOverride, init, isComponentInstance, loadComponentsAssets, onElementDrop, publishDraftComponentsInPageBeforeSave, registerComponentsReducer, resolveOverridePropValue, selectOverridableProps, selectPath, slice, switchToComponent, trackComponentEvent, updateOverridableProp, useComponentInstanceElement, useComponents, useComponentsPermissions, useCurrentComponent, useCurrentComponentId, useFilteredComponents, useInstancePanelData, useIsSanitizedComponent, useOverridablePropValue, useOverridableProps, useSanitizeOverridableProps };
|
package/dist/index.js
CHANGED
|
@@ -92,9 +92,9 @@ var import_editor_canvas6 = require("@elementor/editor-canvas");
|
|
|
92
92
|
var import_editor_documents6 = require("@elementor/editor-documents");
|
|
93
93
|
var import_editor_editing_panel7 = require("@elementor/editor-editing-panel");
|
|
94
94
|
var import_editor_elements_panel = require("@elementor/editor-elements-panel");
|
|
95
|
-
var
|
|
95
|
+
var import_editor_embedded_documents_manager2 = require("@elementor/editor-embedded-documents-manager");
|
|
96
96
|
var import_editor_v1_adapters6 = require("@elementor/editor-v1-adapters");
|
|
97
|
-
var
|
|
97
|
+
var import_store28 = require("@elementor/store");
|
|
98
98
|
var import_i18n16 = require("@wordpress/i18n");
|
|
99
99
|
|
|
100
100
|
// src/component-instance-transformer.ts
|
|
@@ -109,7 +109,6 @@ var initialState = {
|
|
|
109
109
|
data: [],
|
|
110
110
|
unpublishedData: [],
|
|
111
111
|
loadStatus: "idle",
|
|
112
|
-
styles: {},
|
|
113
112
|
createdThisSession: [],
|
|
114
113
|
archivedThisSession: [],
|
|
115
114
|
path: [],
|
|
@@ -229,13 +228,6 @@ var baseSlice = (0, import_store2.__createSlice)({
|
|
|
229
228
|
resetUnpublished: (state) => {
|
|
230
229
|
state.unpublishedData = [];
|
|
231
230
|
},
|
|
232
|
-
removeStyles(state, { payload }) {
|
|
233
|
-
const { [payload.id]: _, ...rest } = state.styles;
|
|
234
|
-
state.styles = rest;
|
|
235
|
-
},
|
|
236
|
-
addStyles: (state, { payload }) => {
|
|
237
|
-
state.styles = { ...state.styles, ...payload };
|
|
238
|
-
},
|
|
239
231
|
addCreatedThisSession: (state, { payload }) => {
|
|
240
232
|
state.createdThisSession.push(payload);
|
|
241
233
|
},
|
|
@@ -330,7 +322,6 @@ var slice = {
|
|
|
330
322
|
var selectData = (state) => state[SLICE_NAME].data;
|
|
331
323
|
var selectArchivedThisSession = (state) => state[SLICE_NAME].archivedThisSession;
|
|
332
324
|
var selectLoadStatus = (state) => state[SLICE_NAME].loadStatus;
|
|
333
|
-
var selectStylesDefinitions = (state) => state[SLICE_NAME].styles ?? {};
|
|
334
325
|
var selectUnpublishedData = (state) => state[SLICE_NAME].unpublishedData;
|
|
335
326
|
var getCreatedThisSession = (state) => state[SLICE_NAME].createdThisSession;
|
|
336
327
|
var getPath = (state) => state[SLICE_NAME].path;
|
|
@@ -358,17 +349,6 @@ var selectUnpublishedComponents = (0, import_store3.__createSelector)(
|
|
|
358
349
|
);
|
|
359
350
|
var selectLoadIsPending = (0, import_store3.__createSelector)(selectLoadStatus, (status) => status === "pending");
|
|
360
351
|
var selectLoadIsError = (0, import_store3.__createSelector)(selectLoadStatus, (status) => status === "error");
|
|
361
|
-
var selectStyles = (state) => state[SLICE_NAME].styles ?? {};
|
|
362
|
-
var selectFlatStyles = (0, import_store3.__createSelector)(
|
|
363
|
-
selectStylesDefinitions,
|
|
364
|
-
(_state, excludeComponentId = null) => excludeComponentId,
|
|
365
|
-
(data, excludeComponentId) => {
|
|
366
|
-
if (excludeComponentId === null) {
|
|
367
|
-
return Object.values(data).flat();
|
|
368
|
-
}
|
|
369
|
-
return Object.entries(data).filter(([id]) => id !== String(excludeComponentId)).map(([, styles]) => styles).flat();
|
|
370
|
-
}
|
|
371
|
-
);
|
|
372
352
|
var selectCreatedThisSession = (0, import_store3.__createSelector)(
|
|
373
353
|
getCreatedThisSession,
|
|
374
354
|
(createdThisSession) => createdThisSession
|
|
@@ -1744,12 +1724,6 @@ var componentsActions = {
|
|
|
1744
1724
|
resetUnpublished() {
|
|
1745
1725
|
(0, import_store12.__dispatch)(slice.actions.resetUnpublished());
|
|
1746
1726
|
},
|
|
1747
|
-
removeStyles(id) {
|
|
1748
|
-
(0, import_store12.__dispatch)(slice.actions.removeStyles({ id }));
|
|
1749
|
-
},
|
|
1750
|
-
addStyles(styles) {
|
|
1751
|
-
(0, import_store12.__dispatch)(slice.actions.addStyles(styles));
|
|
1752
|
-
},
|
|
1753
1727
|
addCreatedThisSession(uid) {
|
|
1754
1728
|
(0, import_store12.__dispatch)(slice.actions.addCreatedThisSession(uid));
|
|
1755
1729
|
},
|
|
@@ -2573,13 +2547,18 @@ var import_editor_templates = require("@elementor/editor-templates");
|
|
|
2573
2547
|
|
|
2574
2548
|
// src/store/actions/load-components-assets.ts
|
|
2575
2549
|
var import_editor_documents2 = require("@elementor/editor-documents");
|
|
2550
|
+
var import_editor_embedded_documents_manager = require("@elementor/editor-embedded-documents-manager");
|
|
2576
2551
|
|
|
2577
2552
|
// src/utils/get-component-documents.ts
|
|
2578
|
-
async function getComponentDocuments(
|
|
2579
|
-
|
|
2553
|
+
async function getComponentDocuments({
|
|
2554
|
+
elements,
|
|
2555
|
+
cache = /* @__PURE__ */ new Map(),
|
|
2556
|
+
isRecursive = true
|
|
2557
|
+
}) {
|
|
2558
|
+
const componentIds = await getComponentIds(elements, cache, isRecursive);
|
|
2580
2559
|
return getDocumentsMap(componentIds, cache);
|
|
2581
2560
|
}
|
|
2582
|
-
async function getComponentIds(elements, cache) {
|
|
2561
|
+
async function getComponentIds(elements, cache, isRecursive) {
|
|
2583
2562
|
const results = await Promise.all(
|
|
2584
2563
|
elements.map(async ({ widgetType, elType, elements: childElements, settings }) => {
|
|
2585
2564
|
const ids = [];
|
|
@@ -2595,8 +2574,8 @@ async function getComponentIds(elements, cache) {
|
|
|
2595
2574
|
const doc = await cache.get(componentId);
|
|
2596
2575
|
childElements = doc?.elements;
|
|
2597
2576
|
}
|
|
2598
|
-
if (childElements?.length) {
|
|
2599
|
-
const childIds = await getComponentIds(childElements, cache);
|
|
2577
|
+
if (isRecursive && childElements?.length) {
|
|
2578
|
+
const childIds = await getComponentIds(childElements, cache, isRecursive);
|
|
2600
2579
|
ids.push(...childIds);
|
|
2601
2580
|
}
|
|
2602
2581
|
return ids;
|
|
@@ -2628,47 +2607,13 @@ async function loadComponentsOverridableProps(componentIds) {
|
|
|
2628
2607
|
(0, import_store21.__dispatch)(slice.actions.loadOverridableProps(data));
|
|
2629
2608
|
}
|
|
2630
2609
|
|
|
2631
|
-
// src/store/actions/load-components-styles.ts
|
|
2632
|
-
var import_editor_global_classes = require("@elementor/editor-global-classes");
|
|
2633
|
-
var import_store23 = require("@elementor/store");
|
|
2634
|
-
function loadComponentsStyles(documents) {
|
|
2635
|
-
if (!documents.size) {
|
|
2636
|
-
return;
|
|
2637
|
-
}
|
|
2638
|
-
const knownComponents = selectStyles((0, import_store23.__getState)());
|
|
2639
|
-
const unknownDocuments = new Map([...documents.entries()].filter(([id]) => !knownComponents[id]));
|
|
2640
|
-
if (!unknownDocuments.size) {
|
|
2641
|
-
return;
|
|
2642
|
-
}
|
|
2643
|
-
addStyles(unknownDocuments);
|
|
2644
|
-
}
|
|
2645
|
-
function addStyles(documents) {
|
|
2646
|
-
const styles = Object.fromEntries(
|
|
2647
|
-
[...documents.entries()].map(([id, document2]) => {
|
|
2648
|
-
(0, import_editor_global_classes.addDocumentClasses)(id);
|
|
2649
|
-
return [id, extractStylesFromDocument(document2)];
|
|
2650
|
-
})
|
|
2651
|
-
);
|
|
2652
|
-
(0, import_store23.__dispatch)(slice.actions.addStyles(styles));
|
|
2653
|
-
}
|
|
2654
|
-
function extractStylesFromDocument(document2) {
|
|
2655
|
-
if (!document2.elements?.length) {
|
|
2656
|
-
return [];
|
|
2657
|
-
}
|
|
2658
|
-
return document2.elements.flatMap(extractStylesFromElement);
|
|
2659
|
-
}
|
|
2660
|
-
function extractStylesFromElement(element) {
|
|
2661
|
-
return [
|
|
2662
|
-
...Object.values(element.styles ?? {}),
|
|
2663
|
-
...(element.elements ?? []).flatMap(extractStylesFromElement)
|
|
2664
|
-
];
|
|
2665
|
-
}
|
|
2666
|
-
|
|
2667
2610
|
// src/store/actions/load-components-assets.ts
|
|
2668
2611
|
async function loadComponentsAssets(elements) {
|
|
2669
|
-
const documents = await getComponentDocuments(elements);
|
|
2612
|
+
const documents = await getComponentDocuments({ elements, isRecursive: false });
|
|
2670
2613
|
updateDocumentState(documents);
|
|
2671
|
-
|
|
2614
|
+
documents.forEach((document2, id) => {
|
|
2615
|
+
import_editor_embedded_documents_manager.embeddedDocumentsManager.setDocument(id, document2);
|
|
2616
|
+
});
|
|
2672
2617
|
await loadComponentsOverridableProps([...documents.keys()]);
|
|
2673
2618
|
}
|
|
2674
2619
|
function updateDocumentState(documents) {
|
|
@@ -2697,7 +2642,7 @@ function LoadTemplateComponentsInternal() {
|
|
|
2697
2642
|
var import_editor_canvas5 = require("@elementor/editor-canvas");
|
|
2698
2643
|
var import_editor_documents4 = require("@elementor/editor-documents");
|
|
2699
2644
|
var import_editor_notifications2 = require("@elementor/editor-notifications");
|
|
2700
|
-
var
|
|
2645
|
+
var import_store23 = require("@elementor/store");
|
|
2701
2646
|
var import_utils5 = require("@elementor/utils");
|
|
2702
2647
|
var import_i18n13 = require("@wordpress/i18n");
|
|
2703
2648
|
|
|
@@ -3088,7 +3033,7 @@ function createComponentModel() {
|
|
|
3088
3033
|
}
|
|
3089
3034
|
const componentUid = editorSettings?.component_uid;
|
|
3090
3035
|
if (componentUid) {
|
|
3091
|
-
const component = selectComponentByUid((0,
|
|
3036
|
+
const component = selectComponentByUid((0, import_store23.__getState)(), componentUid);
|
|
3092
3037
|
if (component?.name) {
|
|
3093
3038
|
return component.name;
|
|
3094
3039
|
}
|
|
@@ -3110,10 +3055,10 @@ function createComponentModel() {
|
|
|
3110
3055
|
|
|
3111
3056
|
// src/populate-store.ts
|
|
3112
3057
|
var import_react11 = require("react");
|
|
3113
|
-
var
|
|
3058
|
+
var import_store25 = require("@elementor/store");
|
|
3114
3059
|
function PopulateStore() {
|
|
3115
3060
|
(0, import_react11.useEffect)(() => {
|
|
3116
|
-
(0,
|
|
3061
|
+
(0, import_store25.__dispatch)(loadComponents());
|
|
3117
3062
|
}, []);
|
|
3118
3063
|
return null;
|
|
3119
3064
|
}
|
|
@@ -3122,7 +3067,7 @@ function PopulateStore() {
|
|
|
3122
3067
|
var import_editor_elements9 = require("@elementor/editor-elements");
|
|
3123
3068
|
var import_editor_notifications3 = require("@elementor/editor-notifications");
|
|
3124
3069
|
var import_editor_v1_adapters4 = require("@elementor/editor-v1-adapters");
|
|
3125
|
-
var
|
|
3070
|
+
var import_store26 = require("@elementor/store");
|
|
3126
3071
|
var import_i18n14 = require("@wordpress/i18n");
|
|
3127
3072
|
var COMPONENT_TYPE = "e-component";
|
|
3128
3073
|
var COMPONENT_CIRCULAR_NESTING_ALERT = {
|
|
@@ -3148,7 +3093,7 @@ function wouldCreateCircularNesting(componentIdToAdd) {
|
|
|
3148
3093
|
if (componentIdToAdd === void 0) {
|
|
3149
3094
|
return false;
|
|
3150
3095
|
}
|
|
3151
|
-
const state = (0,
|
|
3096
|
+
const state = (0, import_store26.__getState)();
|
|
3152
3097
|
const currentComponentId = selectCurrentComponentId(state);
|
|
3153
3098
|
const path = selectPath(state);
|
|
3154
3099
|
if (currentComponentId === null) {
|
|
@@ -3246,35 +3191,9 @@ function blockCircularPaste(args) {
|
|
|
3246
3191
|
}
|
|
3247
3192
|
|
|
3248
3193
|
// src/store/actions/remove-component-styles.ts
|
|
3249
|
-
var import_store30 = require("@elementor/store");
|
|
3250
3194
|
function removeComponentStyles(id) {
|
|
3251
3195
|
apiClient.invalidateComponentConfigCache(id);
|
|
3252
|
-
|
|
3253
|
-
}
|
|
3254
|
-
|
|
3255
|
-
// src/store/components-styles-provider.ts
|
|
3256
|
-
var import_editor_elements10 = require("@elementor/editor-elements");
|
|
3257
|
-
var import_editor_styles_repository = require("@elementor/editor-styles-repository");
|
|
3258
|
-
var import_store32 = require("@elementor/store");
|
|
3259
|
-
var componentsStylesProvider = (0, import_editor_styles_repository.createStylesProvider)({
|
|
3260
|
-
key: "components-styles",
|
|
3261
|
-
priority: 100,
|
|
3262
|
-
subscribe: (cb) => (0, import_store32.__subscribeWithSelector)(
|
|
3263
|
-
(state) => state[SLICE_NAME],
|
|
3264
|
-
() => {
|
|
3265
|
-
cb();
|
|
3266
|
-
}
|
|
3267
|
-
),
|
|
3268
|
-
actions: {
|
|
3269
|
-
all: () => {
|
|
3270
|
-
const currentDocumentId = (0, import_editor_elements10.getCurrentDocumentId)();
|
|
3271
|
-
return selectFlatStyles((0, import_store32.__getState)(), currentDocumentId);
|
|
3272
|
-
},
|
|
3273
|
-
get: (id) => {
|
|
3274
|
-
return selectFlatStyles((0, import_store32.__getState)()).find((style) => style.id === id) ?? null;
|
|
3275
|
-
}
|
|
3276
|
-
}
|
|
3277
|
-
});
|
|
3196
|
+
}
|
|
3278
3197
|
|
|
3279
3198
|
// src/sync/publish-draft-components-in-page-before-save.ts
|
|
3280
3199
|
var import_editor_documents5 = require("@elementor/editor-documents");
|
|
@@ -3288,7 +3207,7 @@ async function publishDraftComponentsInPageBeforeSave({ status, elements }) {
|
|
|
3288
3207
|
if (status !== "publish") {
|
|
3289
3208
|
return;
|
|
3290
3209
|
}
|
|
3291
|
-
const documents = await getComponentDocuments(elements);
|
|
3210
|
+
const documents = await getComponentDocuments({ elements });
|
|
3292
3211
|
const draftIds = [...documents.values()].filter(import_editor_documents5.isDocumentDirty).map((document2) => document2.id);
|
|
3293
3212
|
if (draftIds.length === 0) {
|
|
3294
3213
|
return;
|
|
@@ -3351,8 +3270,7 @@ function load(result) {
|
|
|
3351
3270
|
|
|
3352
3271
|
// src/init.ts
|
|
3353
3272
|
function init() {
|
|
3354
|
-
|
|
3355
|
-
(0, import_store34.__registerSlice)(slice);
|
|
3273
|
+
(0, import_store28.__registerSlice)(slice);
|
|
3356
3274
|
(0, import_editor_canvas6.registerElementType)(
|
|
3357
3275
|
COMPONENT_WIDGET_TYPE2,
|
|
3358
3276
|
(options) => createComponentType({
|
|
@@ -3372,12 +3290,16 @@ function init() {
|
|
|
3372
3290
|
id: "components-populate-store",
|
|
3373
3291
|
component: PopulateStore
|
|
3374
3292
|
});
|
|
3375
|
-
(0, import_editor_v1_adapters6.registerDataHook)("after", "editor/documents/attach-preview",
|
|
3376
|
-
const { id, config } = (0, import_editor_documents6.getV1CurrentDocument)();
|
|
3377
|
-
if (id) {
|
|
3378
|
-
|
|
3293
|
+
(0, import_editor_v1_adapters6.registerDataHook)("after", "editor/documents/attach-preview", () => {
|
|
3294
|
+
const { id, config } = (0, import_editor_documents6.getV1CurrentDocument)() ?? {};
|
|
3295
|
+
if (!id) {
|
|
3296
|
+
return;
|
|
3379
3297
|
}
|
|
3380
|
-
|
|
3298
|
+
removeComponentStyles(id);
|
|
3299
|
+
void loadComponentsAssets(config?.elements ?? []);
|
|
3300
|
+
});
|
|
3301
|
+
import_editor_embedded_documents_manager2.embeddedDocumentsManager.onDocumentLoad((_documentId, data) => {
|
|
3302
|
+
void loadComponentsAssets(data.elements ?? []);
|
|
3381
3303
|
});
|
|
3382
3304
|
(0, import_editor.injectIntoLogic)({
|
|
3383
3305
|
id: "templates",
|