@elementor/editor-components 4.0.0-564 → 4.0.0-591
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 +3801 -3744
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3813 -3761
- package/dist/index.mjs.map +1 -1
- package/package.json +23 -22
- package/src/components/components-tab/components-item.tsx +5 -4
- package/src/components/components-tab/components-list.tsx +5 -13
- package/src/components/components-tab/loading-components.tsx +2 -3
- package/src/components/instance-editing-panel/instance-editing-panel.tsx +17 -5
- package/src/components/instance-editing-panel/override-prop-control.tsx +13 -7
- package/src/components/instance-editing-panel/use-resolved-origin-value.tsx +1 -1
- package/src/components/load-template-components.tsx +14 -0
- package/src/create-component-type.ts +8 -2
- package/src/{components → extended/components}/component-panel-header/component-panel-header.tsx +4 -4
- package/src/{components → extended/components}/component-properties-panel/component-properties-panel-content.tsx +2 -2
- package/src/{components → extended/components}/component-properties-panel/properties-empty-state.tsx +1 -1
- package/src/{components → extended/components}/component-properties-panel/properties-group.tsx +1 -1
- package/src/{components → extended/components}/component-properties-panel/property-item.tsx +1 -1
- package/src/{components → extended/components}/component-properties-panel/use-current-editable-item.ts +1 -1
- package/src/{components → extended/components}/component-properties-panel/utils/generate-unique-label.ts +1 -1
- package/src/{components → extended/components}/component-properties-panel/utils/validate-group-label.ts +1 -1
- package/src/{components → extended/components}/create-component-form/create-component-form.tsx +5 -5
- package/src/{components → extended/components}/edit-component/component-modal.tsx +2 -2
- package/src/{components → extended/components}/edit-component/edit-component.tsx +3 -3
- package/src/{components → extended/components}/overridable-props/overridable-prop-control.tsx +7 -7
- package/src/{components → extended/components}/overridable-props/overridable-prop-form.tsx +1 -1
- package/src/{components → extended/components}/overridable-props/overridable-prop-indicator.tsx +7 -7
- package/src/{components → extended}/consts.ts +2 -1
- package/src/{hooks → extended/hooks}/use-navigate-back.ts +2 -2
- package/src/extended/init.ts +77 -0
- package/src/{mcp → extended/mcp}/save-as-component-tool.ts +2 -2
- package/src/{prevent-non-atomic-nesting.ts → extended/prevent-non-atomic-nesting.ts} +1 -1
- package/src/{store → extended/store}/actions/add-overridable-group.ts +3 -3
- package/src/{store → extended/store}/actions/create-unpublished-component.ts +4 -4
- package/src/{store → extended/store}/actions/delete-overridable-group.ts +2 -2
- package/src/extended/store/actions/delete-overridable-prop.ts +70 -0
- package/src/{store → extended/store}/actions/rename-overridable-group.ts +2 -2
- package/src/{store → extended/store}/actions/reorder-group-props.ts +2 -2
- package/src/{store → extended/store}/actions/reorder-overridable-groups.ts +2 -2
- package/src/{store → extended/store}/actions/reset-sanitized-components.ts +1 -1
- package/src/{store → extended/store}/actions/set-overridable-prop.ts +3 -3
- package/src/{store → extended/store}/actions/update-component-sanitized-attribute.ts +2 -2
- package/src/{store → extended/store}/actions/update-current-component.ts +2 -14
- package/src/{store → extended/store}/actions/update-overridable-prop-params.ts +2 -2
- package/src/{store → extended/store}/utils/groups-transformers.ts +6 -4
- package/src/extended/sync/before-save.ts +52 -0
- package/src/{sync → extended/sync}/cleanup-overridable-props-on-delete.ts +24 -24
- package/src/{sync → extended/sync}/create-components-before-save.ts +4 -4
- package/src/{sync → extended/sync}/handle-component-edit-mode-container.ts +1 -1
- package/src/{sync → extended/sync}/revert-overridables-on-copy-or-duplicate.ts +1 -1
- package/src/{sync → extended/sync}/set-component-overridable-props-settings-before-save.ts +2 -2
- package/src/{sync → extended/sync}/update-archived-component-before-save.ts +3 -3
- package/src/{sync → extended/sync}/update-component-title-before-save.ts +3 -3
- package/src/{utils → extended/utils}/is-editing-component.ts +1 -1
- package/src/extended/utils/replace-element-with-component.ts +11 -0
- package/src/{utils → extended/utils}/revert-overridable-settings.ts +6 -6
- package/src/hooks/use-sanitize-overridable-props.ts +9 -4
- package/src/init.ts +8 -69
- package/src/sync/before-save.ts +1 -30
- package/src/types.ts +8 -1
- package/src/utils/component-name-validation.ts +1 -1
- package/src/{components/create-component-form/utils/replace-element-with-component.ts → utils/create-component-model.ts} +2 -10
- package/src/utils/filter-valid-overridable-props.ts +18 -8
- package/src/utils/format-component-elements-id.ts +20 -0
- package/src/utils/get-container-by-origin-id.ts +46 -0
- package/src/{components/overridable-props/utils → utils}/get-overridable-prop.ts +2 -2
- package/src/utils/switch-to-component.ts +5 -2
- package/src/hooks/use-component-instance-settings.ts +0 -15
- package/src/store/actions/delete-overridable-prop.ts +0 -56
- package/src/utils/expand-navigator.ts +0 -5
- /package/src/{components/components-tab → extended/components}/component-introduction.tsx +0 -0
- /package/src/{components → extended/components}/component-panel-header/component-badge.tsx +0 -0
- /package/src/{components → extended/components}/component-properties-panel/component-properties-panel.tsx +0 -0
- /package/src/{components → extended/components}/component-properties-panel/sortable.tsx +0 -0
- /package/src/{components → extended/components}/create-component-form/hooks/use-form.ts +0 -0
- /package/src/{components → extended/components}/create-component-form/utils/component-form-schema.ts +0 -0
- /package/src/{components → extended/components}/create-component-form/utils/get-component-event-data.ts +0 -0
- /package/src/{hooks → extended/components/edit-component}/use-canvas-document.ts +0 -0
- /package/src/{hooks → extended/components/edit-component}/use-element-rect.ts +0 -0
- /package/src/{components → extended/components}/overridable-props/indicator.tsx +0 -0
- /package/src/{components → extended/components}/overridable-props/utils/validate-prop-label.ts +0 -0
- /package/src/{mcp → extended/mcp}/index.ts +0 -0
package/src/init.ts
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
import { injectIntoLogic
|
|
1
|
+
import { injectIntoLogic } from '@elementor/editor';
|
|
2
2
|
import {
|
|
3
3
|
type CreateTemplatedElementTypeOptions,
|
|
4
4
|
registerElementType,
|
|
5
5
|
settingsTransformersRegistry,
|
|
6
6
|
} from '@elementor/editor-canvas';
|
|
7
|
-
import { registerControlReplacement } from '@elementor/editor-controls';
|
|
8
7
|
import { getV1CurrentDocument } from '@elementor/editor-documents';
|
|
9
|
-
import {
|
|
10
|
-
FIELD_TYPE,
|
|
11
|
-
injectIntoPanelHeaderTop,
|
|
12
|
-
registerEditingPanelReplacement,
|
|
13
|
-
registerFieldIndicator,
|
|
14
|
-
} from '@elementor/editor-editing-panel';
|
|
8
|
+
import { registerEditingPanelReplacement } from '@elementor/editor-editing-panel';
|
|
15
9
|
import { type V1ElementData } from '@elementor/editor-elements';
|
|
16
10
|
import { injectTab } from '@elementor/editor-elements-panel';
|
|
17
|
-
import { __registerPanel as registerPanel } from '@elementor/editor-panels';
|
|
18
11
|
import { stylesRepository } from '@elementor/editor-styles-repository';
|
|
19
12
|
import { registerDataHook } from '@elementor/editor-v1-adapters';
|
|
20
13
|
import { __registerSlice as registerSlice } from '@elementor/store';
|
|
@@ -23,54 +16,31 @@ import { __ } from '@wordpress/i18n';
|
|
|
23
16
|
import { componentInstanceTransformer } from './component-instance-transformer';
|
|
24
17
|
import { componentOverridableTransformer } from './component-overridable-transformer';
|
|
25
18
|
import { componentOverrideTransformer } from './component-override-transformer';
|
|
26
|
-
import { ComponentPanelHeader } from './components/component-panel-header/component-panel-header';
|
|
27
|
-
import { panel as componentPropertiesPanel } from './components/component-properties-panel/component-properties-panel';
|
|
28
19
|
import { Components } from './components/components-tab/components';
|
|
29
|
-
import { COMPONENT_DOCUMENT_TYPE, OVERRIDABLE_PROP_REPLACEMENT_ID } from './components/consts';
|
|
30
|
-
import { CreateComponentForm } from './components/create-component-form/create-component-form';
|
|
31
|
-
import { EditComponent } from './components/edit-component/edit-component';
|
|
32
20
|
import { openEditModeDialog } from './components/in-edit-mode';
|
|
33
21
|
import { InstanceEditingPanel } from './components/instance-editing-panel/instance-editing-panel';
|
|
34
|
-
import {
|
|
35
|
-
import { OverridablePropIndicator } from './components/overridable-props/overridable-prop-indicator';
|
|
22
|
+
import { LoadTemplateComponents } from './components/load-template-components';
|
|
36
23
|
import { COMPONENT_WIDGET_TYPE, createComponentType } from './create-component-type';
|
|
37
|
-
import {
|
|
24
|
+
import { initExtended } from './extended/init';
|
|
38
25
|
import { PopulateStore } from './populate-store';
|
|
39
26
|
import { initCircularNestingPrevention } from './prevent-circular-nesting';
|
|
40
|
-
import { initNonAtomicNestingPrevention } from './prevent-non-atomic-nesting';
|
|
41
|
-
import { componentOverridablePropTypeUtil } from './prop-types/component-overridable-prop-type';
|
|
42
27
|
import { loadComponentsAssets } from './store/actions/load-components-assets';
|
|
43
28
|
import { removeComponentStyles } from './store/actions/remove-component-styles';
|
|
44
29
|
import { componentsStylesProvider } from './store/components-styles-provider';
|
|
45
30
|
import { slice } from './store/store';
|
|
46
31
|
import { beforeSave } from './sync/before-save';
|
|
47
|
-
import { initCleanupOverridablePropsOnDelete } from './sync/cleanup-overridable-props-on-delete';
|
|
48
|
-
import { initHandleComponentEditModeContainer } from './sync/handle-component-edit-mode-container';
|
|
49
32
|
import { initLoadComponentDataAfterInstanceAdded } from './sync/load-component-data-after-instance-added';
|
|
50
|
-
import { initRevertOverridablesOnCopyOrDuplicate } from './sync/revert-overridables-on-copy-or-duplicate';
|
|
51
33
|
import { type ExtendedWindow } from './types';
|
|
52
|
-
import { onElementDrop } from './utils/tracking';
|
|
53
34
|
|
|
54
35
|
export function init() {
|
|
55
36
|
stylesRepository.register( componentsStylesProvider );
|
|
56
37
|
|
|
57
38
|
registerSlice( slice );
|
|
58
|
-
registerPanel( componentPropertiesPanel );
|
|
59
39
|
|
|
60
40
|
registerElementType( COMPONENT_WIDGET_TYPE, ( options: CreateTemplatedElementTypeOptions ) =>
|
|
61
41
|
createComponentType( { ...options, showLockedByModal: openEditModeDialog } )
|
|
62
42
|
);
|
|
63
43
|
|
|
64
|
-
registerDataHook( 'dependency', 'editor/documents/close', ( args ) => {
|
|
65
|
-
const document = getV1CurrentDocument();
|
|
66
|
-
if ( document.config.type === COMPONENT_DOCUMENT_TYPE ) {
|
|
67
|
-
args.mode = 'autosave';
|
|
68
|
-
}
|
|
69
|
-
return true;
|
|
70
|
-
} );
|
|
71
|
-
|
|
72
|
-
registerDataHook( 'after', 'preview/drop', onElementDrop );
|
|
73
|
-
|
|
74
44
|
( window as unknown as ExtendedWindow ).elementorCommon.__beforeSave = beforeSave;
|
|
75
45
|
|
|
76
46
|
injectTab( {
|
|
@@ -80,26 +50,11 @@ export function init() {
|
|
|
80
50
|
position: 1,
|
|
81
51
|
} );
|
|
82
52
|
|
|
83
|
-
injectIntoTop( {
|
|
84
|
-
id: 'create-component-popup',
|
|
85
|
-
component: CreateComponentForm,
|
|
86
|
-
} );
|
|
87
|
-
|
|
88
53
|
injectIntoLogic( {
|
|
89
54
|
id: 'components-populate-store',
|
|
90
55
|
component: PopulateStore,
|
|
91
56
|
} );
|
|
92
57
|
|
|
93
|
-
injectIntoTop( {
|
|
94
|
-
id: 'edit-component',
|
|
95
|
-
component: EditComponent,
|
|
96
|
-
} );
|
|
97
|
-
|
|
98
|
-
injectIntoPanelHeaderTop( {
|
|
99
|
-
id: 'component-panel-header',
|
|
100
|
-
component: ComponentPanelHeader,
|
|
101
|
-
} );
|
|
102
|
-
|
|
103
58
|
registerDataHook( 'after', 'editor/documents/attach-preview', async () => {
|
|
104
59
|
const { id, config } = getV1CurrentDocument();
|
|
105
60
|
|
|
@@ -110,17 +65,9 @@ export function init() {
|
|
|
110
65
|
await loadComponentsAssets( ( config?.elements as V1ElementData[] ) ?? [] );
|
|
111
66
|
} );
|
|
112
67
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
priority: 1,
|
|
117
|
-
indicator: OverridablePropIndicator,
|
|
118
|
-
} );
|
|
119
|
-
|
|
120
|
-
registerControlReplacement( {
|
|
121
|
-
id: OVERRIDABLE_PROP_REPLACEMENT_ID,
|
|
122
|
-
component: OverridablePropControl,
|
|
123
|
-
condition: ( { value } ) => componentOverridablePropTypeUtil.isValid( value ),
|
|
68
|
+
injectIntoLogic( {
|
|
69
|
+
id: 'templates',
|
|
70
|
+
component: LoadTemplateComponents,
|
|
124
71
|
} );
|
|
125
72
|
|
|
126
73
|
registerEditingPanelReplacement( {
|
|
@@ -133,17 +80,9 @@ export function init() {
|
|
|
133
80
|
settingsTransformersRegistry.register( 'overridable', componentOverridableTransformer );
|
|
134
81
|
settingsTransformersRegistry.register( 'override', componentOverrideTransformer );
|
|
135
82
|
|
|
136
|
-
initCleanupOverridablePropsOnDelete();
|
|
137
|
-
|
|
138
|
-
initMcp();
|
|
139
|
-
|
|
140
83
|
initCircularNestingPrevention();
|
|
141
84
|
|
|
142
|
-
initNonAtomicNestingPrevention();
|
|
143
|
-
|
|
144
85
|
initLoadComponentDataAfterInstanceAdded();
|
|
145
86
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
initRevertOverridablesOnCopyOrDuplicate();
|
|
87
|
+
initExtended();
|
|
149
88
|
}
|
package/src/sync/before-save.ts
CHANGED
|
@@ -2,11 +2,7 @@ import { type V1Document } from '@elementor/editor-documents';
|
|
|
2
2
|
import { type V1Element, type V1ElementData } from '@elementor/editor-elements';
|
|
3
3
|
|
|
4
4
|
import { type DocumentSaveStatus } from '../types';
|
|
5
|
-
import { createComponentsBeforeSave } from './create-components-before-save';
|
|
6
5
|
import { publishDraftComponentsInPageBeforeSave } from './publish-draft-components-in-page-before-save';
|
|
7
|
-
import { setComponentOverridablePropsSettingsBeforeSave } from './set-component-overridable-props-settings-before-save';
|
|
8
|
-
import { updateArchivedComponentBeforeSave } from './update-archived-component-before-save';
|
|
9
|
-
import { updateComponentTitleBeforeSave } from './update-component-title-before-save';
|
|
10
6
|
|
|
11
7
|
type Options = {
|
|
12
8
|
container: V1Element & {
|
|
@@ -23,30 +19,5 @@ type Options = {
|
|
|
23
19
|
export const beforeSave = ( { container, status }: Options ) => {
|
|
24
20
|
const elements = container?.model.get( 'elements' ).toJSON?.() ?? [];
|
|
25
21
|
|
|
26
|
-
return
|
|
27
|
-
syncComponents( { elements, status } ),
|
|
28
|
-
setComponentOverridablePropsSettingsBeforeSave( { container } ),
|
|
29
|
-
] );
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// These operations run sequentially to prevent race conditions when multiple
|
|
33
|
-
// edits occur on the same component simultaneously.
|
|
34
|
-
// TODO: Consolidate these into a single PUT /components endpoint.
|
|
35
|
-
const syncComponents = async ( { elements, status }: { elements: V1ElementData[]; status: DocumentSaveStatus } ) => {
|
|
36
|
-
// This order is important - first update existing components, then create new components,
|
|
37
|
-
// Since new component validation depends on the existing components (preventing duplicate names).
|
|
38
|
-
await updateExistingComponentsBeforeSave( { elements, status } );
|
|
39
|
-
await createComponentsBeforeSave( { elements, status } );
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
const updateExistingComponentsBeforeSave = async ( {
|
|
43
|
-
elements,
|
|
44
|
-
status,
|
|
45
|
-
}: {
|
|
46
|
-
elements: V1ElementData[];
|
|
47
|
-
status: DocumentSaveStatus;
|
|
48
|
-
} ) => {
|
|
49
|
-
await updateComponentTitleBeforeSave( status );
|
|
50
|
-
await updateArchivedComponentBeforeSave( status );
|
|
51
|
-
await publishDraftComponentsInPageBeforeSave( { elements, status } );
|
|
22
|
+
return publishDraftComponentsInPageBeforeSave( { elements, status } );
|
|
52
23
|
};
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type RenderContext } from '@elementor/editor-canvas';
|
|
2
|
-
import { type V1ElementData } from '@elementor/editor-elements';
|
|
2
|
+
import { type V1Element, type V1ElementData } from '@elementor/editor-elements';
|
|
3
3
|
import { type PropValue, type TransformablePropValue } from '@elementor/editor-props';
|
|
4
4
|
import type { StyleDefinition } from '@elementor/editor-styles';
|
|
5
5
|
|
|
@@ -81,6 +81,13 @@ export type ExtendedWindow = Window & {
|
|
|
81
81
|
};
|
|
82
82
|
storage: ElementorStorage;
|
|
83
83
|
};
|
|
84
|
+
elementor?: {
|
|
85
|
+
getContainerByKeyValue?: ( args: {
|
|
86
|
+
key: string;
|
|
87
|
+
value: string;
|
|
88
|
+
parent?: V1Element[ 'view' ];
|
|
89
|
+
} ) => V1Element | null;
|
|
90
|
+
};
|
|
84
91
|
};
|
|
85
92
|
|
|
86
93
|
export type ComponentOverridable = {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __getState as getState } from '@elementor/store';
|
|
2
2
|
|
|
3
|
-
import { createSubmitComponentSchema } from '../components/create-component-form/utils/component-form-schema';
|
|
3
|
+
import { createSubmitComponentSchema } from '../extended/components/create-component-form/utils/component-form-schema';
|
|
4
4
|
import { selectComponents } from '../store/store';
|
|
5
5
|
|
|
6
6
|
type ValidationResult = { isValid: true; errorMessage: null } | { isValid: false; errorMessage: string };
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type V1ElementModelProps } from '@elementor/editor-elements';
|
|
2
2
|
|
|
3
|
-
type ComponentInstanceParams = {
|
|
3
|
+
export type ComponentInstanceParams = {
|
|
4
4
|
id?: number;
|
|
5
5
|
name: string;
|
|
6
6
|
uid: string;
|
|
7
7
|
};
|
|
8
8
|
|
|
9
|
-
export const replaceElementWithComponent = async ( element: V1ElementData, component: ComponentInstanceParams ) => {
|
|
10
|
-
return await replaceElement( {
|
|
11
|
-
currentElement: element,
|
|
12
|
-
newElement: createComponentModel( component ),
|
|
13
|
-
withHistory: false,
|
|
14
|
-
} );
|
|
15
|
-
};
|
|
16
|
-
|
|
17
9
|
export const createComponentModel = ( component: ComponentInstanceParams ): Omit< V1ElementModelProps, 'id' > => {
|
|
18
10
|
return {
|
|
19
11
|
elType: 'widget',
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
-
import { getElementSetting } from '@elementor/editor-elements';
|
|
2
|
-
|
|
3
|
-
import { getOverridableProp } from '../components/overridable-props/utils/get-overridable-prop';
|
|
4
1
|
import { type ComponentInstanceOverride } from '../prop-types/component-instance-overrides-prop-type';
|
|
5
2
|
import { componentInstanceOverridesPropTypeUtil } from '../prop-types/component-instance-overrides-prop-type';
|
|
6
3
|
import { componentInstancePropTypeUtil } from '../prop-types/component-instance-prop-type';
|
|
7
4
|
import { componentOverridablePropTypeUtil } from '../prop-types/component-overridable-prop-type';
|
|
8
5
|
import { type OverridableProp, type OverridableProps } from '../types';
|
|
6
|
+
import { getContainerByOriginId } from './get-container-by-origin-id';
|
|
7
|
+
import { getOverridableProp } from './get-overridable-prop';
|
|
9
8
|
import { extractInnerOverrideInfo } from './overridable-props-utils';
|
|
10
9
|
|
|
11
|
-
export function filterValidOverridableProps(
|
|
10
|
+
export function filterValidOverridableProps(
|
|
11
|
+
overridableProps: OverridableProps,
|
|
12
|
+
// instanceElementId is used to find the component inner elements,
|
|
13
|
+
// and should be passed when editing component instance (not in component edit mode)
|
|
14
|
+
instanceElementId?: string
|
|
15
|
+
): OverridableProps {
|
|
12
16
|
const validProps: Record< string, OverridableProp > = {};
|
|
13
17
|
|
|
14
18
|
for ( const [ key, prop ] of Object.entries( overridableProps.props ) ) {
|
|
15
|
-
if ( isExposedPropValid( prop ) ) {
|
|
19
|
+
if ( isExposedPropValid( prop, instanceElementId ) ) {
|
|
16
20
|
validProps[ key ] = prop;
|
|
17
21
|
}
|
|
18
22
|
}
|
|
@@ -31,13 +35,19 @@ export function filterValidOverridableProps( overridableProps: OverridableProps
|
|
|
31
35
|
return { props: validProps, groups: filteredGroups };
|
|
32
36
|
}
|
|
33
37
|
|
|
34
|
-
export function isExposedPropValid( prop: OverridableProp ): boolean {
|
|
38
|
+
export function isExposedPropValid( prop: OverridableProp, instanceElementId?: string ): boolean {
|
|
35
39
|
if ( ! prop.originPropFields ) {
|
|
36
40
|
// if no originPropFields - the prop is on the widget level itself, therefore no need to lookup for a corresponding component's overridables
|
|
37
41
|
return true;
|
|
38
42
|
}
|
|
39
43
|
|
|
40
|
-
const
|
|
44
|
+
const innerComponentInstanceElement = getContainerByOriginId( prop.elementId, instanceElementId );
|
|
45
|
+
|
|
46
|
+
if ( ! innerComponentInstanceElement ) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const setting = innerComponentInstanceElement.settings?.get( 'component_instance' ) ?? null;
|
|
41
51
|
const componentInstance = componentInstancePropTypeUtil.extract( setting );
|
|
42
52
|
|
|
43
53
|
if ( ! componentInstance?.component_id?.value ) {
|
|
@@ -59,7 +69,7 @@ export function isExposedPropValid( prop: OverridableProp ): boolean {
|
|
|
59
69
|
return false;
|
|
60
70
|
}
|
|
61
71
|
|
|
62
|
-
return isExposedPropValid( innerOverridableProp );
|
|
72
|
+
return isExposedPropValid( innerOverridableProp, innerComponentInstanceElement.id );
|
|
63
73
|
}
|
|
64
74
|
|
|
65
75
|
function findOverrideByOuterKey(
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type V1ElementData } from '@elementor/editor-elements';
|
|
2
|
+
import { hashString } from '@elementor/utils';
|
|
3
|
+
|
|
4
|
+
const ELEMENT_ID_LENGTH = 7;
|
|
5
|
+
// The purpose of this function is to solve the issue of component inner elements having the same ID
|
|
6
|
+
// when there are multiple instances of the same component on a page.
|
|
7
|
+
// We change the ID of the inner elements to a hash of the nesting path of the element and the element's originalID.
|
|
8
|
+
export function formatComponentElementsId( elements: V1ElementData[], path: string[] ): V1ElementData[] {
|
|
9
|
+
return elements.map( ( element ) => {
|
|
10
|
+
const nestingPath = [ ...path, element.id ];
|
|
11
|
+
const id = hashString( nestingPath.join( '_' ), ELEMENT_ID_LENGTH );
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
...element,
|
|
15
|
+
id,
|
|
16
|
+
originId: element.id,
|
|
17
|
+
elements: element.elements ? formatComponentElementsId( element.elements, nestingPath ) : undefined,
|
|
18
|
+
};
|
|
19
|
+
} );
|
|
20
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { getContainer, type V1Element } from '@elementor/editor-elements';
|
|
2
|
+
|
|
3
|
+
import { type ExtendedWindow } from '../types';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Resolves a container by its origin ID, with optional scoping to a component instance.
|
|
7
|
+
*
|
|
8
|
+
* When component instances are rendered, their inner elements get prefixed IDs
|
|
9
|
+
* (e.g., `{instanceId}_{originalId}`), but store data uses original IDs.
|
|
10
|
+
* This function bridges between the two by searching for elements with a matching `originId`.
|
|
11
|
+
*
|
|
12
|
+
* @param originElementId - The original (unprefixed) element ID from store data
|
|
13
|
+
* @param instanceElementId - Optional instance widget ID to scope the search
|
|
14
|
+
*
|
|
15
|
+
* @return The container with prefixed runtime ID, or null if not found
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* // Component editing mode (no prefixing)
|
|
19
|
+
* getContainerByOriginId('element-1') // returns container with id='element-1'
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* // Instance editing mode (with hash prefixing)
|
|
23
|
+
* getContainerByOriginId('element-1', 'instance-abc')
|
|
24
|
+
* // returns container with id='{hash}_element-1' and originId='element-1'
|
|
25
|
+
*/
|
|
26
|
+
export function getContainerByOriginId( originElementId: string, instanceElementId?: string ): V1Element | null {
|
|
27
|
+
if ( ! instanceElementId ) {
|
|
28
|
+
return getContainer( originElementId );
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const instanceContainer = getContainer( instanceElementId );
|
|
32
|
+
|
|
33
|
+
if ( ! instanceContainer ) {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const legacyWindow = window as unknown as ExtendedWindow;
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
legacyWindow.elementor?.getContainerByKeyValue?.( {
|
|
41
|
+
key: 'originId',
|
|
42
|
+
value: originElementId,
|
|
43
|
+
parent: instanceContainer.view,
|
|
44
|
+
} ) ?? null
|
|
45
|
+
);
|
|
46
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __getState as getState } from '@elementor/store';
|
|
2
2
|
|
|
3
|
-
import { selectOverridableProps } from '
|
|
4
|
-
import { type OverridableProp } from '
|
|
3
|
+
import { selectOverridableProps } from '../store/store';
|
|
4
|
+
import { type OverridableProp } from '../types';
|
|
5
5
|
|
|
6
6
|
export function getOverridableProp( {
|
|
7
7
|
componentId,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { invalidateDocumentData, switchToDocument } from '@elementor/editor-documents';
|
|
2
2
|
import { getCurrentDocumentContainer, selectElement } from '@elementor/editor-elements';
|
|
3
|
-
|
|
4
|
-
import { expandNavigator } from './expand-navigator';
|
|
3
|
+
import { __privateRunCommand as runCommand } from '@elementor/editor-v1-adapters';
|
|
5
4
|
|
|
6
5
|
export async function switchToComponent(
|
|
7
6
|
componentId: number,
|
|
@@ -28,6 +27,10 @@ export async function switchToComponent(
|
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
29
|
|
|
30
|
+
export async function expandNavigator() {
|
|
31
|
+
await runCommand( 'navigator/expand-all' );
|
|
32
|
+
}
|
|
33
|
+
|
|
31
34
|
function getSelector( element?: HTMLElement | null, componentInstanceId?: string | null ): string | undefined {
|
|
32
35
|
if ( element ) {
|
|
33
36
|
return buildUniqueSelector( element );
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { useElement } from '@elementor/editor-editing-panel';
|
|
2
|
-
import { useElementSetting } from '@elementor/editor-elements';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
componentInstancePropTypeUtil,
|
|
6
|
-
type ComponentInstancePropValue,
|
|
7
|
-
} from '../prop-types/component-instance-prop-type';
|
|
8
|
-
|
|
9
|
-
export function useComponentInstanceSettings() {
|
|
10
|
-
const { element } = useElement();
|
|
11
|
-
|
|
12
|
-
const settings = useElementSetting< ComponentInstancePropValue >( element.id, 'component_instance' );
|
|
13
|
-
|
|
14
|
-
return componentInstancePropTypeUtil.extract( settings );
|
|
15
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { __dispatch as dispatch, __getState as getState } from '@elementor/store';
|
|
2
|
-
|
|
3
|
-
import { type ComponentId } from '../../types';
|
|
4
|
-
import { revertElementOverridableSetting } from '../../utils/revert-overridable-settings';
|
|
5
|
-
import { type Source, trackComponentEvent } from '../../utils/tracking';
|
|
6
|
-
import { selectCurrentComponent, selectOverridableProps, slice } from '../store';
|
|
7
|
-
import { removePropFromAllGroups } from '../utils/groups-transformers';
|
|
8
|
-
|
|
9
|
-
type DeletePropParams = {
|
|
10
|
-
componentId: ComponentId;
|
|
11
|
-
propKey: string;
|
|
12
|
-
source: Source;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export function deleteOverridableProp( { componentId, propKey, source }: DeletePropParams ): void {
|
|
16
|
-
const overridableProps = selectOverridableProps( getState(), componentId );
|
|
17
|
-
|
|
18
|
-
if ( ! overridableProps ) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const prop = overridableProps.props[ propKey ];
|
|
23
|
-
|
|
24
|
-
if ( ! prop ) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
revertElementOverridableSetting( prop.elementId, prop.propKey, prop.originValue, propKey );
|
|
29
|
-
|
|
30
|
-
const { [ propKey ]: removedProp, ...remainingProps } = overridableProps.props;
|
|
31
|
-
|
|
32
|
-
const updatedGroups = removePropFromAllGroups( overridableProps.groups, propKey );
|
|
33
|
-
|
|
34
|
-
dispatch(
|
|
35
|
-
slice.actions.setOverridableProps( {
|
|
36
|
-
componentId,
|
|
37
|
-
overridableProps: {
|
|
38
|
-
...overridableProps,
|
|
39
|
-
props: remainingProps,
|
|
40
|
-
groups: updatedGroups,
|
|
41
|
-
},
|
|
42
|
-
} )
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
const currentComponent = selectCurrentComponent( getState() );
|
|
46
|
-
|
|
47
|
-
trackComponentEvent( {
|
|
48
|
-
action: 'propertyRemoved',
|
|
49
|
-
source,
|
|
50
|
-
component_uid: currentComponent?.uid,
|
|
51
|
-
property_id: removedProp.overrideKey,
|
|
52
|
-
property_path: removedProp.propKey,
|
|
53
|
-
property_name: removedProp.label,
|
|
54
|
-
element_type: removedProp.widgetType ?? removedProp.elType,
|
|
55
|
-
} );
|
|
56
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/{components → extended/components}/create-component-form/utils/component-form-schema.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/{components → extended/components}/overridable-props/utils/validate-prop-label.ts
RENAMED
|
File without changes
|
|
File without changes
|