@elementor/editor-canvas 4.4.0-1118 → 4.4.0-1120
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
CHANGED
|
@@ -242,7 +242,7 @@ type CreateTemplatedElementTypeOptions = {
|
|
|
242
242
|
renderer: DomRenderer;
|
|
243
243
|
element: TemplatedElementConfig;
|
|
244
244
|
};
|
|
245
|
-
type TemplatedElementConfig = Required<Pick<V1ElementConfig, 'twig_templates' | 'twig_main_template' | 'atomic_props_schema' | 'base_styles_dictionary'>> & Pick<V1ElementConfig, 'default_html_tag' | 'html_tag_follows_link'>;
|
|
245
|
+
type TemplatedElementConfig = Required<Pick<V1ElementConfig, 'twig_templates' | 'twig_main_template' | 'atomic_props_schema' | 'base_styles_dictionary'>> & Pick<V1ElementConfig, 'default_html_tag' | 'html_tag_follows_link' | 'template_context'>;
|
|
246
246
|
declare function createTemplatedElementView({ type, renderer, element, }: CreateTemplatedElementTypeOptions): typeof TemplatedElementView;
|
|
247
247
|
|
|
248
248
|
type NestedTemplatedElementConfig = TemplatedElementConfig & {
|
package/dist/index.d.ts
CHANGED
|
@@ -242,7 +242,7 @@ type CreateTemplatedElementTypeOptions = {
|
|
|
242
242
|
renderer: DomRenderer;
|
|
243
243
|
element: TemplatedElementConfig;
|
|
244
244
|
};
|
|
245
|
-
type TemplatedElementConfig = Required<Pick<V1ElementConfig, 'twig_templates' | 'twig_main_template' | 'atomic_props_schema' | 'base_styles_dictionary'>> & Pick<V1ElementConfig, 'default_html_tag' | 'html_tag_follows_link'>;
|
|
245
|
+
type TemplatedElementConfig = Required<Pick<V1ElementConfig, 'twig_templates' | 'twig_main_template' | 'atomic_props_schema' | 'base_styles_dictionary'>> & Pick<V1ElementConfig, 'default_html_tag' | 'html_tag_follows_link' | 'template_context'>;
|
|
246
246
|
declare function createTemplatedElementView({ type, renderer, element, }: CreateTemplatedElementTypeOptions): typeof TemplatedElementView;
|
|
247
247
|
|
|
248
248
|
type NestedTemplatedElementConfig = TemplatedElementConfig & {
|
package/dist/index.js
CHANGED
|
@@ -3006,6 +3006,7 @@ function createTemplatedElementView({
|
|
|
3006
3006
|
this._domUpdateWasSkipped = false;
|
|
3007
3007
|
this._lastResolvedSettingsHash = settingsHash;
|
|
3008
3008
|
const context = {
|
|
3009
|
+
...element.template_context ?? {},
|
|
3009
3010
|
id: this.model.get("id"),
|
|
3010
3011
|
interaction_id: this.getInteractionId(),
|
|
3011
3012
|
type,
|
package/dist/index.mjs
CHANGED
|
@@ -2969,6 +2969,7 @@ function createTemplatedElementView({
|
|
|
2969
2969
|
this._domUpdateWasSkipped = false;
|
|
2970
2970
|
this._lastResolvedSettingsHash = settingsHash;
|
|
2971
2971
|
const context = {
|
|
2972
|
+
...element.template_context ?? {},
|
|
2972
2973
|
id: this.model.get("id"),
|
|
2973
2974
|
interaction_id: this.getInteractionId(),
|
|
2974
2975
|
type,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-canvas",
|
|
3
3
|
"description": "Elementor Editor Canvas",
|
|
4
|
-
"version": "4.4.0-
|
|
4
|
+
"version": "4.4.0-1120",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -37,26 +37,26 @@
|
|
|
37
37
|
"react-dom": "^18.3.1"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@elementor/editor": "4.4.0-
|
|
41
|
-
"@elementor/editor-controls": "4.4.0-
|
|
42
|
-
"@elementor/editor-documents": "4.4.0-
|
|
43
|
-
"@elementor/editor-elements": "4.4.0-
|
|
44
|
-
"@elementor/editor-interactions": "4.4.0-
|
|
45
|
-
"@elementor/editor-mcp": "4.4.0-
|
|
46
|
-
"@elementor/editor-notifications": "4.4.0-
|
|
47
|
-
"@elementor/editor-props": "4.4.0-
|
|
48
|
-
"@elementor/editor-responsive": "4.4.0-
|
|
49
|
-
"@elementor/editor-styles": "4.4.0-
|
|
50
|
-
"@elementor/editor-styles-repository": "4.4.0-
|
|
51
|
-
"@elementor/editor-ui": "4.4.0-
|
|
52
|
-
"@elementor/editor-v1-adapters": "4.4.0-
|
|
53
|
-
"@elementor/events": "4.4.0-
|
|
54
|
-
"@elementor/http-client": "4.4.0-
|
|
55
|
-
"@elementor/schema": "4.4.0-
|
|
56
|
-
"@elementor/twing": "4.4.0-
|
|
40
|
+
"@elementor/editor": "4.4.0-1120",
|
|
41
|
+
"@elementor/editor-controls": "4.4.0-1120",
|
|
42
|
+
"@elementor/editor-documents": "4.4.0-1120",
|
|
43
|
+
"@elementor/editor-elements": "4.4.0-1120",
|
|
44
|
+
"@elementor/editor-interactions": "4.4.0-1120",
|
|
45
|
+
"@elementor/editor-mcp": "4.4.0-1120",
|
|
46
|
+
"@elementor/editor-notifications": "4.4.0-1120",
|
|
47
|
+
"@elementor/editor-props": "4.4.0-1120",
|
|
48
|
+
"@elementor/editor-responsive": "4.4.0-1120",
|
|
49
|
+
"@elementor/editor-styles": "4.4.0-1120",
|
|
50
|
+
"@elementor/editor-styles-repository": "4.4.0-1120",
|
|
51
|
+
"@elementor/editor-ui": "4.4.0-1120",
|
|
52
|
+
"@elementor/editor-v1-adapters": "4.4.0-1120",
|
|
53
|
+
"@elementor/events": "4.4.0-1120",
|
|
54
|
+
"@elementor/http-client": "4.4.0-1120",
|
|
55
|
+
"@elementor/schema": "4.4.0-1120",
|
|
56
|
+
"@elementor/twing": "4.4.0-1120",
|
|
57
57
|
"@elementor/ui": "1.37.5",
|
|
58
|
-
"@elementor/utils": "4.4.0-
|
|
59
|
-
"@elementor/wp-media": "4.4.0-
|
|
58
|
+
"@elementor/utils": "4.4.0-1120",
|
|
59
|
+
"@elementor/wp-media": "4.4.0-1120",
|
|
60
60
|
"@floating-ui/react": "^0.27.5",
|
|
61
61
|
"@wordpress/i18n": "^5.13.0",
|
|
62
62
|
"dompurify": "^3.2.6"
|
|
@@ -121,20 +121,7 @@ describe( 'createTemplatedElementView', () => {
|
|
|
121
121
|
} );
|
|
122
122
|
|
|
123
123
|
describe( 'render context', () => {
|
|
124
|
-
|
|
125
|
-
// Arrange
|
|
126
|
-
const utils = createMockRenderer();
|
|
127
|
-
const ViewClass = createTemplatedElementView( {
|
|
128
|
-
type: MOCK_ELEMENT_TYPE,
|
|
129
|
-
renderer: utils,
|
|
130
|
-
element: {
|
|
131
|
-
...createMockElementConfig(),
|
|
132
|
-
twig_templates: {
|
|
133
|
-
main: '<{{ tag | e("html_tag") }}></{{ tag | e("html_tag") }}>',
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
} );
|
|
137
|
-
|
|
124
|
+
const createRenderableView = ( ViewClass: ReturnType< typeof createTemplatedElementView > ) => {
|
|
138
125
|
const view = new ViewClass() as unknown as ElementView & {
|
|
139
126
|
_abortController: AbortController;
|
|
140
127
|
};
|
|
@@ -159,12 +146,61 @@ describe( 'createTemplatedElementView', () => {
|
|
|
159
146
|
view._ensureViewIsIntact = jest.fn();
|
|
160
147
|
view.resetChildViewContainer = jest.fn();
|
|
161
148
|
|
|
149
|
+
return view;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
it( 'should inject computed tag into the twig render context', async () => {
|
|
153
|
+
// Arrange
|
|
154
|
+
const utils = createMockRenderer();
|
|
155
|
+
const ViewClass = createTemplatedElementView( {
|
|
156
|
+
type: MOCK_ELEMENT_TYPE,
|
|
157
|
+
renderer: utils,
|
|
158
|
+
element: {
|
|
159
|
+
...createMockElementConfig(),
|
|
160
|
+
twig_templates: {
|
|
161
|
+
main: '<{{ tag | e("html_tag") }}></{{ tag | e("html_tag") }}>',
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
} );
|
|
165
|
+
|
|
166
|
+
const view = createRenderableView( ViewClass );
|
|
167
|
+
|
|
162
168
|
// Act
|
|
163
169
|
await view._renderTemplate();
|
|
164
170
|
|
|
165
171
|
// Assert
|
|
166
172
|
expect( utils.render ).toHaveBeenCalledWith( 'main', expect.objectContaining( { tag: 'div' } ) );
|
|
167
173
|
} );
|
|
174
|
+
|
|
175
|
+
it( 'should merge element template_context into the twig render context without overriding core keys', async () => {
|
|
176
|
+
// Arrange
|
|
177
|
+
const utils = createMockRenderer();
|
|
178
|
+
const ViewClass = createTemplatedElementView( {
|
|
179
|
+
type: MOCK_ELEMENT_TYPE,
|
|
180
|
+
renderer: utils,
|
|
181
|
+
element: {
|
|
182
|
+
...createMockElementConfig(),
|
|
183
|
+
template_context: {
|
|
184
|
+
provider: { key: 'google', api_key: 'test-key' },
|
|
185
|
+
id: 'should-not-override',
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
} );
|
|
189
|
+
|
|
190
|
+
const view = createRenderableView( ViewClass );
|
|
191
|
+
|
|
192
|
+
// Act
|
|
193
|
+
await view._renderTemplate();
|
|
194
|
+
|
|
195
|
+
// Assert
|
|
196
|
+
expect( utils.render ).toHaveBeenCalledWith(
|
|
197
|
+
'main',
|
|
198
|
+
expect.objectContaining( {
|
|
199
|
+
id: 'test-id',
|
|
200
|
+
provider: { key: 'google', api_key: 'test-key' },
|
|
201
|
+
} )
|
|
202
|
+
);
|
|
203
|
+
} );
|
|
168
204
|
} );
|
|
169
205
|
} );
|
|
170
206
|
|
|
@@ -29,7 +29,7 @@ export type CreateTemplatedElementTypeOptions = {
|
|
|
29
29
|
export type TemplatedElementConfig = Required<
|
|
30
30
|
Pick< V1ElementConfig, 'twig_templates' | 'twig_main_template' | 'atomic_props_schema' | 'base_styles_dictionary' >
|
|
31
31
|
> &
|
|
32
|
-
Pick< V1ElementConfig, 'default_html_tag' | 'html_tag_follows_link' >;
|
|
32
|
+
Pick< V1ElementConfig, 'default_html_tag' | 'html_tag_follows_link' | 'template_context' >;
|
|
33
33
|
|
|
34
34
|
export function createTemplatedElementType( {
|
|
35
35
|
type,
|
|
@@ -163,6 +163,7 @@ export function createTemplatedElementView( {
|
|
|
163
163
|
this._lastResolvedSettingsHash = settingsHash;
|
|
164
164
|
|
|
165
165
|
const context = {
|
|
166
|
+
...( element.template_context ?? {} ),
|
|
166
167
|
id: this.model.get( 'id' ),
|
|
167
168
|
interaction_id: this.getInteractionId(),
|
|
168
169
|
type,
|