@elementor/editor-canvas 4.1.0-778 → 4.1.0-779

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 CHANGED
@@ -2168,7 +2168,7 @@ function createTemplatedElementView({
2168
2168
  this.triggerMethod("render:template");
2169
2169
  }
2170
2170
  afterSettingsResolve(settings) {
2171
- return settings;
2171
+ return this._getLinkAttributes(settings);
2172
2172
  }
2173
2173
  _beforeRender() {
2174
2174
  createBeforeRender(this);
@@ -2191,6 +2191,28 @@ function createTemplatedElementView({
2191
2191
  const id = this.model.get("id");
2192
2192
  return originId ?? id;
2193
2193
  }
2194
+ _getLinkAttributes(settings) {
2195
+ const linkAttributes = Object.entries(this._handleActionLinkAttributes(settings)).map(([key, value]) => `${key}="${value}"`).join(" ");
2196
+ return {
2197
+ ...settings,
2198
+ link: linkAttributes ? {
2199
+ tag: settings?.link?.tag,
2200
+ attributes: linkAttributes
2201
+ } : null
2202
+ };
2203
+ }
2204
+ _handleActionLinkAttributes(settings) {
2205
+ const link = settings.link;
2206
+ if (!link || typeof link !== "object" || !("href" in link) || !link.href) {
2207
+ return {};
2208
+ }
2209
+ const isActionLink = "tag" in link && link.tag === "button";
2210
+ const urlAttrKey = isActionLink ? "data-action-link" : "href";
2211
+ return {
2212
+ [urlAttrKey]: link.href,
2213
+ target: ("target" in link && link.target) ?? "_self"
2214
+ };
2215
+ }
2194
2216
  };
2195
2217
  }
2196
2218
 
package/dist/index.mjs CHANGED
@@ -2134,7 +2134,7 @@ function createTemplatedElementView({
2134
2134
  this.triggerMethod("render:template");
2135
2135
  }
2136
2136
  afterSettingsResolve(settings) {
2137
- return settings;
2137
+ return this._getLinkAttributes(settings);
2138
2138
  }
2139
2139
  _beforeRender() {
2140
2140
  createBeforeRender(this);
@@ -2157,6 +2157,28 @@ function createTemplatedElementView({
2157
2157
  const id = this.model.get("id");
2158
2158
  return originId ?? id;
2159
2159
  }
2160
+ _getLinkAttributes(settings) {
2161
+ const linkAttributes = Object.entries(this._handleActionLinkAttributes(settings)).map(([key, value]) => `${key}="${value}"`).join(" ");
2162
+ return {
2163
+ ...settings,
2164
+ link: linkAttributes ? {
2165
+ tag: settings?.link?.tag,
2166
+ attributes: linkAttributes
2167
+ } : null
2168
+ };
2169
+ }
2170
+ _handleActionLinkAttributes(settings) {
2171
+ const link = settings.link;
2172
+ if (!link || typeof link !== "object" || !("href" in link) || !link.href) {
2173
+ return {};
2174
+ }
2175
+ const isActionLink = "tag" in link && link.tag === "button";
2176
+ const urlAttrKey = isActionLink ? "data-action-link" : "href";
2177
+ return {
2178
+ [urlAttrKey]: link.href,
2179
+ target: ("target" in link && link.target) ?? "_self"
2180
+ };
2181
+ }
2160
2182
  };
2161
2183
  }
2162
2184
 
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.1.0-778",
4
+ "version": "4.1.0-779",
5
5
  "private": false,
6
6
  "author": "Elementor Team",
7
7
  "homepage": "https://elementor.com/",
@@ -37,25 +37,25 @@
37
37
  "react-dom": "^18.3.1"
38
38
  },
39
39
  "dependencies": {
40
- "@elementor/editor": "4.1.0-778",
40
+ "@elementor/editor": "4.1.0-779",
41
41
  "dompurify": "^3.2.6",
42
- "@elementor/editor-controls": "4.1.0-778",
43
- "@elementor/editor-documents": "4.1.0-778",
44
- "@elementor/editor-elements": "4.1.0-778",
45
- "@elementor/editor-interactions": "4.1.0-778",
46
- "@elementor/editor-mcp": "4.1.0-778",
47
- "@elementor/editor-notifications": "4.1.0-778",
48
- "@elementor/editor-props": "4.1.0-778",
49
- "@elementor/editor-responsive": "4.1.0-778",
50
- "@elementor/editor-styles": "4.1.0-778",
51
- "@elementor/editor-styles-repository": "4.1.0-778",
52
- "@elementor/editor-ui": "4.1.0-778",
53
- "@elementor/editor-v1-adapters": "4.1.0-778",
54
- "@elementor/schema": "4.1.0-778",
55
- "@elementor/twing": "4.1.0-778",
42
+ "@elementor/editor-controls": "4.1.0-779",
43
+ "@elementor/editor-documents": "4.1.0-779",
44
+ "@elementor/editor-elements": "4.1.0-779",
45
+ "@elementor/editor-interactions": "4.1.0-779",
46
+ "@elementor/editor-mcp": "4.1.0-779",
47
+ "@elementor/editor-notifications": "4.1.0-779",
48
+ "@elementor/editor-props": "4.1.0-779",
49
+ "@elementor/editor-responsive": "4.1.0-779",
50
+ "@elementor/editor-styles": "4.1.0-779",
51
+ "@elementor/editor-styles-repository": "4.1.0-779",
52
+ "@elementor/editor-ui": "4.1.0-779",
53
+ "@elementor/editor-v1-adapters": "4.1.0-779",
54
+ "@elementor/schema": "4.1.0-779",
55
+ "@elementor/twing": "4.1.0-779",
56
56
  "@elementor/ui": "1.37.5",
57
- "@elementor/utils": "4.1.0-778",
58
- "@elementor/wp-media": "4.1.0-778",
57
+ "@elementor/utils": "4.1.0-779",
58
+ "@elementor/wp-media": "4.1.0-779",
59
59
  "@floating-ui/react": "^0.27.5",
60
60
  "@wordpress/i18n": "^5.13.0"
61
61
  },
@@ -186,7 +186,7 @@ export function createTemplatedElementView( {
186
186
  }
187
187
 
188
188
  afterSettingsResolve( settings: { [ key: string ]: unknown } ) {
189
- return settings;
189
+ return this._getLinkAttributes( settings );
190
190
  }
191
191
 
192
192
  _beforeRender() {
@@ -214,5 +214,37 @@ export function createTemplatedElementView( {
214
214
 
215
215
  return originId ?? id;
216
216
  }
217
+
218
+ _getLinkAttributes( settings: { [ key: string ]: unknown } ) {
219
+ const linkAttributes = Object.entries( this._handleActionLinkAttributes( settings ) )
220
+ .map( ( [ key, value ] ) => `${ key }="${ value }"` )
221
+ .join( ' ' );
222
+
223
+ return {
224
+ ...settings,
225
+ link: linkAttributes
226
+ ? {
227
+ tag: ( settings?.link as { tag?: string } )?.tag,
228
+ attributes: linkAttributes,
229
+ }
230
+ : null,
231
+ };
232
+ }
233
+
234
+ _handleActionLinkAttributes( settings: { [ key: string ]: unknown } ) {
235
+ const link = settings.link;
236
+
237
+ if ( ! link || typeof link !== 'object' || ! ( 'href' in link ) || ! link.href ) {
238
+ return {};
239
+ }
240
+
241
+ const isActionLink = 'tag' in link && link.tag === 'button';
242
+ const urlAttrKey = isActionLink ? 'data-action-link' : 'href';
243
+
244
+ return {
245
+ [ urlAttrKey ]: link.href,
246
+ target: ( 'target' in link && link.target ) ?? '_self',
247
+ };
248
+ }
217
249
  };
218
250
  }