@elementor/editor-canvas 4.3.0-1061 → 4.3.0-1062
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 +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +47 -0
- package/dist/index.mjs +47 -0
- package/package.json +20 -20
- package/src/init.tsx +2 -0
- package/src/legacy/__tests__/list-type.test.ts +89 -0
- package/src/legacy/list-type.ts +63 -0
- package/src/legacy/types.ts +4 -0
package/dist/index.d.mts
CHANGED
|
@@ -151,6 +151,8 @@ declare class ElementView {
|
|
|
151
151
|
}): void;
|
|
152
152
|
once: (event: string, callback: () => void) => void;
|
|
153
153
|
getContainer(): V1Element;
|
|
154
|
+
initialize?(...args: unknown[]): void;
|
|
155
|
+
listenTo(target: unknown, event: string, callback: () => void): void;
|
|
154
156
|
}
|
|
155
157
|
declare class TemplatedElementView extends ElementView {
|
|
156
158
|
_doAfterRender(callback: () => void): void;
|
package/dist/index.d.ts
CHANGED
|
@@ -151,6 +151,8 @@ declare class ElementView {
|
|
|
151
151
|
}): void;
|
|
152
152
|
once: (event: string, callback: () => void) => void;
|
|
153
153
|
getContainer(): V1Element;
|
|
154
|
+
initialize?(...args: unknown[]): void;
|
|
155
|
+
listenTo(target: unknown, event: string, callback: () => void): void;
|
|
154
156
|
}
|
|
155
157
|
declare class TemplatedElementView extends ElementView {
|
|
156
158
|
_doAfterRender(callback: () => void): void;
|
package/dist/index.js
CHANGED
|
@@ -4089,6 +4089,52 @@ function createNestedTemplatedType(type, renderer, element) {
|
|
|
4089
4089
|
});
|
|
4090
4090
|
}
|
|
4091
4091
|
|
|
4092
|
+
// src/legacy/list-type.ts
|
|
4093
|
+
var LIST_TYPE = "e-list";
|
|
4094
|
+
function initListType() {
|
|
4095
|
+
registerElementType(
|
|
4096
|
+
LIST_TYPE,
|
|
4097
|
+
(options) => createListType(options)
|
|
4098
|
+
);
|
|
4099
|
+
}
|
|
4100
|
+
function createListType(options) {
|
|
4101
|
+
const BaseType = createNestedTemplatedElementType(options);
|
|
4102
|
+
let ListView = null;
|
|
4103
|
+
return class extends BaseType {
|
|
4104
|
+
getView() {
|
|
4105
|
+
if (!ListView) {
|
|
4106
|
+
ListView = createListView(options);
|
|
4107
|
+
}
|
|
4108
|
+
return ListView;
|
|
4109
|
+
}
|
|
4110
|
+
};
|
|
4111
|
+
}
|
|
4112
|
+
function createListView(options) {
|
|
4113
|
+
const BaseView = createNestedTemplatedElementView(options);
|
|
4114
|
+
return BaseView.extend({
|
|
4115
|
+
getRenderContext() {
|
|
4116
|
+
const parentContext = this._parent?.getRenderContext?.();
|
|
4117
|
+
const settings = this.model.get("settings");
|
|
4118
|
+
const showMarkersProp = settings?.get?.("show_markers");
|
|
4119
|
+
const showMarkers = showMarkersProp?.value ?? showMarkersProp ?? true;
|
|
4120
|
+
return {
|
|
4121
|
+
...parentContext,
|
|
4122
|
+
show_markers: showMarkers
|
|
4123
|
+
};
|
|
4124
|
+
},
|
|
4125
|
+
getResolverRenderContext() {
|
|
4126
|
+
const parentContext = this._parent?.getResolverRenderContext?.();
|
|
4127
|
+
const settings = this.model.get("settings");
|
|
4128
|
+
const showMarkersProp = settings?.get?.("show_markers");
|
|
4129
|
+
const showMarkers = showMarkersProp?.value ?? showMarkersProp ?? true;
|
|
4130
|
+
return {
|
|
4131
|
+
...parentContext,
|
|
4132
|
+
show_markers: showMarkers
|
|
4133
|
+
};
|
|
4134
|
+
}
|
|
4135
|
+
});
|
|
4136
|
+
}
|
|
4137
|
+
|
|
4092
4138
|
// src/legacy/tabs-model-extensions.ts
|
|
4093
4139
|
var import_editor_props5 = require("@elementor/editor-props");
|
|
4094
4140
|
var tabModelExtensions = {
|
|
@@ -5746,6 +5792,7 @@ function init() {
|
|
|
5746
5792
|
})
|
|
5747
5793
|
);
|
|
5748
5794
|
initTabsModelExtensions();
|
|
5795
|
+
initListType();
|
|
5749
5796
|
}
|
|
5750
5797
|
|
|
5751
5798
|
// src/sync/drag-element-from-panel.ts
|
package/dist/index.mjs
CHANGED
|
@@ -4054,6 +4054,52 @@ function createNestedTemplatedType(type, renderer, element) {
|
|
|
4054
4054
|
});
|
|
4055
4055
|
}
|
|
4056
4056
|
|
|
4057
|
+
// src/legacy/list-type.ts
|
|
4058
|
+
var LIST_TYPE = "e-list";
|
|
4059
|
+
function initListType() {
|
|
4060
|
+
registerElementType(
|
|
4061
|
+
LIST_TYPE,
|
|
4062
|
+
(options) => createListType(options)
|
|
4063
|
+
);
|
|
4064
|
+
}
|
|
4065
|
+
function createListType(options) {
|
|
4066
|
+
const BaseType = createNestedTemplatedElementType(options);
|
|
4067
|
+
let ListView = null;
|
|
4068
|
+
return class extends BaseType {
|
|
4069
|
+
getView() {
|
|
4070
|
+
if (!ListView) {
|
|
4071
|
+
ListView = createListView(options);
|
|
4072
|
+
}
|
|
4073
|
+
return ListView;
|
|
4074
|
+
}
|
|
4075
|
+
};
|
|
4076
|
+
}
|
|
4077
|
+
function createListView(options) {
|
|
4078
|
+
const BaseView = createNestedTemplatedElementView(options);
|
|
4079
|
+
return BaseView.extend({
|
|
4080
|
+
getRenderContext() {
|
|
4081
|
+
const parentContext = this._parent?.getRenderContext?.();
|
|
4082
|
+
const settings = this.model.get("settings");
|
|
4083
|
+
const showMarkersProp = settings?.get?.("show_markers");
|
|
4084
|
+
const showMarkers = showMarkersProp?.value ?? showMarkersProp ?? true;
|
|
4085
|
+
return {
|
|
4086
|
+
...parentContext,
|
|
4087
|
+
show_markers: showMarkers
|
|
4088
|
+
};
|
|
4089
|
+
},
|
|
4090
|
+
getResolverRenderContext() {
|
|
4091
|
+
const parentContext = this._parent?.getResolverRenderContext?.();
|
|
4092
|
+
const settings = this.model.get("settings");
|
|
4093
|
+
const showMarkersProp = settings?.get?.("show_markers");
|
|
4094
|
+
const showMarkers = showMarkersProp?.value ?? showMarkersProp ?? true;
|
|
4095
|
+
return {
|
|
4096
|
+
...parentContext,
|
|
4097
|
+
show_markers: showMarkers
|
|
4098
|
+
};
|
|
4099
|
+
}
|
|
4100
|
+
});
|
|
4101
|
+
}
|
|
4102
|
+
|
|
4057
4103
|
// src/legacy/tabs-model-extensions.ts
|
|
4058
4104
|
import { escapedHtmlPropTypeUtil as escapedHtmlPropTypeUtil3 } from "@elementor/editor-props";
|
|
4059
4105
|
var tabModelExtensions = {
|
|
@@ -5739,6 +5785,7 @@ function init() {
|
|
|
5739
5785
|
})
|
|
5740
5786
|
);
|
|
5741
5787
|
initTabsModelExtensions();
|
|
5788
|
+
initListType();
|
|
5742
5789
|
}
|
|
5743
5790
|
|
|
5744
5791
|
// src/sync/drag-element-from-panel.ts
|
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.3.0-
|
|
4
|
+
"version": "4.3.0-1062",
|
|
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.3.0-
|
|
41
|
-
"@elementor/editor-controls": "4.3.0-
|
|
42
|
-
"@elementor/editor-documents": "4.3.0-
|
|
43
|
-
"@elementor/editor-elements": "4.3.0-
|
|
44
|
-
"@elementor/editor-interactions": "4.3.0-
|
|
45
|
-
"@elementor/editor-mcp": "4.3.0-
|
|
46
|
-
"@elementor/editor-notifications": "4.3.0-
|
|
47
|
-
"@elementor/editor-props": "4.3.0-
|
|
48
|
-
"@elementor/editor-responsive": "4.3.0-
|
|
49
|
-
"@elementor/editor-styles": "4.3.0-
|
|
50
|
-
"@elementor/editor-styles-repository": "4.3.0-
|
|
51
|
-
"@elementor/editor-ui": "4.3.0-
|
|
52
|
-
"@elementor/editor-v1-adapters": "4.3.0-
|
|
53
|
-
"@elementor/events": "4.3.0-
|
|
54
|
-
"@elementor/http-client": "4.3.0-
|
|
55
|
-
"@elementor/schema": "4.3.0-
|
|
56
|
-
"@elementor/twing": "4.3.0-
|
|
40
|
+
"@elementor/editor": "4.3.0-1062",
|
|
41
|
+
"@elementor/editor-controls": "4.3.0-1062",
|
|
42
|
+
"@elementor/editor-documents": "4.3.0-1062",
|
|
43
|
+
"@elementor/editor-elements": "4.3.0-1062",
|
|
44
|
+
"@elementor/editor-interactions": "4.3.0-1062",
|
|
45
|
+
"@elementor/editor-mcp": "4.3.0-1062",
|
|
46
|
+
"@elementor/editor-notifications": "4.3.0-1062",
|
|
47
|
+
"@elementor/editor-props": "4.3.0-1062",
|
|
48
|
+
"@elementor/editor-responsive": "4.3.0-1062",
|
|
49
|
+
"@elementor/editor-styles": "4.3.0-1062",
|
|
50
|
+
"@elementor/editor-styles-repository": "4.3.0-1062",
|
|
51
|
+
"@elementor/editor-ui": "4.3.0-1062",
|
|
52
|
+
"@elementor/editor-v1-adapters": "4.3.0-1062",
|
|
53
|
+
"@elementor/events": "4.3.0-1062",
|
|
54
|
+
"@elementor/http-client": "4.3.0-1062",
|
|
55
|
+
"@elementor/schema": "4.3.0-1062",
|
|
56
|
+
"@elementor/twing": "4.3.0-1062",
|
|
57
57
|
"@elementor/ui": "1.37.5",
|
|
58
|
-
"@elementor/utils": "4.3.0-
|
|
59
|
-
"@elementor/wp-media": "4.3.0-
|
|
58
|
+
"@elementor/utils": "4.3.0-1062",
|
|
59
|
+
"@elementor/wp-media": "4.3.0-1062",
|
|
60
60
|
"@floating-ui/react": "^0.27.5",
|
|
61
61
|
"@wordpress/i18n": "^5.13.0",
|
|
62
62
|
"dompurify": "^3.2.6"
|
package/src/init.tsx
CHANGED
|
@@ -10,6 +10,7 @@ import { initFormNestingPrevention } from './form-structure/prevent-form-nesting
|
|
|
10
10
|
import { initSettingsTransformers } from './init-settings-transformers';
|
|
11
11
|
import { initStyleTransformers } from './init-style-transformers';
|
|
12
12
|
import { initLegacyViews } from './legacy/init-legacy-views';
|
|
13
|
+
import { initListType } from './legacy/list-type';
|
|
13
14
|
import { initViewReplacements } from './legacy/replacements/manager';
|
|
14
15
|
import { initTabsModelExtensions } from './legacy/tabs-model-extensions';
|
|
15
16
|
import { initCanvasMcp } from './mcp/canvas-mcp';
|
|
@@ -63,4 +64,5 @@ export function init() {
|
|
|
63
64
|
);
|
|
64
65
|
|
|
65
66
|
initTabsModelExtensions();
|
|
67
|
+
initListType();
|
|
66
68
|
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createNestedTemplatedElementType,
|
|
3
|
+
createNestedTemplatedElementView,
|
|
4
|
+
} from '../create-nested-templated-element-type';
|
|
5
|
+
import { elementsLegacyTypes } from '../init-legacy-views';
|
|
6
|
+
import { initListType } from '../list-type';
|
|
7
|
+
import type { ElementType, NestedTemplatedElementViewClass } from '../types';
|
|
8
|
+
|
|
9
|
+
jest.mock( '../create-nested-templated-element-type', () => ( {
|
|
10
|
+
createNestedTemplatedElementType: jest.fn(),
|
|
11
|
+
createNestedTemplatedElementView: jest.fn(),
|
|
12
|
+
} ) );
|
|
13
|
+
|
|
14
|
+
const LIST_TYPE = 'e-list';
|
|
15
|
+
const resetListType = () => Reflect.deleteProperty( elementsLegacyTypes, LIST_TYPE );
|
|
16
|
+
|
|
17
|
+
const createMockBaseType = (): typeof ElementType => {
|
|
18
|
+
const MockBaseType = function MockBaseType() {};
|
|
19
|
+
|
|
20
|
+
MockBaseType.prototype.getType = () => LIST_TYPE;
|
|
21
|
+
MockBaseType.prototype.getView = () => function MockBaseView() {};
|
|
22
|
+
|
|
23
|
+
return MockBaseType as unknown as typeof ElementType;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const createMockBaseView = ( generatedViewIdRef: { current: number } ): NestedTemplatedElementViewClass => {
|
|
27
|
+
const MockBaseView = Object.assign( function BaseViewMock() {}, {
|
|
28
|
+
extend() {
|
|
29
|
+
return Object.assign( function ExtendedViewMock() {}, {
|
|
30
|
+
viewId: ++generatedViewIdRef.current,
|
|
31
|
+
} );
|
|
32
|
+
},
|
|
33
|
+
} );
|
|
34
|
+
|
|
35
|
+
return MockBaseView as unknown as NestedTemplatedElementViewClass;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const createMockOptions = () => ( {
|
|
39
|
+
type: LIST_TYPE,
|
|
40
|
+
renderer: {
|
|
41
|
+
register: jest.fn(),
|
|
42
|
+
render: jest.fn(),
|
|
43
|
+
},
|
|
44
|
+
element: {
|
|
45
|
+
twig_templates: {},
|
|
46
|
+
twig_main_template: 'main',
|
|
47
|
+
atomic_props_schema: {},
|
|
48
|
+
base_styles_dictionary: {},
|
|
49
|
+
default_html_tag: 'ul',
|
|
50
|
+
html_tag_follows_link: false,
|
|
51
|
+
support_nesting: true,
|
|
52
|
+
},
|
|
53
|
+
} );
|
|
54
|
+
|
|
55
|
+
describe( 'initListType', () => {
|
|
56
|
+
beforeEach( () => {
|
|
57
|
+
const generatedViewIdRef = { current: 0 };
|
|
58
|
+
|
|
59
|
+
jest.clearAllMocks();
|
|
60
|
+
resetListType();
|
|
61
|
+
|
|
62
|
+
jest.mocked( createNestedTemplatedElementType ).mockImplementation( () => createMockBaseType() );
|
|
63
|
+
|
|
64
|
+
jest.mocked( createNestedTemplatedElementView ).mockImplementation( () =>
|
|
65
|
+
createMockBaseView( generatedViewIdRef )
|
|
66
|
+
);
|
|
67
|
+
} );
|
|
68
|
+
|
|
69
|
+
afterEach( () => {
|
|
70
|
+
resetListType();
|
|
71
|
+
} );
|
|
72
|
+
|
|
73
|
+
it( 'should reuse the same view class for multiple list type instances', () => {
|
|
74
|
+
// Arrange
|
|
75
|
+
initListType();
|
|
76
|
+
const createListType = elementsLegacyTypes[ LIST_TYPE ];
|
|
77
|
+
const ElementType = createListType( createMockOptions() );
|
|
78
|
+
|
|
79
|
+
// Act
|
|
80
|
+
const typeInstance1 = new ElementType();
|
|
81
|
+
const typeInstance2 = new ElementType();
|
|
82
|
+
const viewClass1 = typeInstance1.getView();
|
|
83
|
+
const viewClass2 = typeInstance2.getView();
|
|
84
|
+
|
|
85
|
+
// Assert
|
|
86
|
+
expect( viewClass1 ).toBe( viewClass2 );
|
|
87
|
+
expect( createNestedTemplatedElementView ).toHaveBeenCalledTimes( 1 );
|
|
88
|
+
} );
|
|
89
|
+
} );
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createNestedTemplatedElementType,
|
|
3
|
+
type CreateNestedTemplatedElementTypeOptions,
|
|
4
|
+
createNestedTemplatedElementView,
|
|
5
|
+
} from './create-nested-templated-element-type';
|
|
6
|
+
import { registerElementType } from './init-legacy-views';
|
|
7
|
+
import type { ElementType, RenderContext } from './types';
|
|
8
|
+
|
|
9
|
+
const LIST_TYPE = 'e-list';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Initialize the e-list element type with custom render context.
|
|
13
|
+
*/
|
|
14
|
+
export function initListType() {
|
|
15
|
+
registerElementType( LIST_TYPE, ( options ) =>
|
|
16
|
+
createListType( options as CreateNestedTemplatedElementTypeOptions )
|
|
17
|
+
);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function createListType( options: CreateNestedTemplatedElementTypeOptions ): typeof ElementType {
|
|
21
|
+
const BaseType = createNestedTemplatedElementType( options );
|
|
22
|
+
let ListView: ReturnType< typeof createListView > | null = null;
|
|
23
|
+
|
|
24
|
+
return class extends BaseType {
|
|
25
|
+
getView() {
|
|
26
|
+
if ( ! ListView ) {
|
|
27
|
+
ListView = createListView( options );
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return ListView;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function createListView( options: CreateNestedTemplatedElementTypeOptions ) {
|
|
36
|
+
const BaseView = createNestedTemplatedElementView( options );
|
|
37
|
+
|
|
38
|
+
return BaseView.extend( {
|
|
39
|
+
getRenderContext(): RenderContext | undefined {
|
|
40
|
+
const parentContext = this._parent?.getRenderContext?.();
|
|
41
|
+
const settings = this.model.get( 'settings' );
|
|
42
|
+
const showMarkersProp = settings?.get?.( 'show_markers' ) as unknown;
|
|
43
|
+
const showMarkers = ( showMarkersProp as { value?: boolean } )?.value ?? showMarkersProp ?? true;
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
...parentContext,
|
|
47
|
+
show_markers: showMarkers,
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
getResolverRenderContext(): RenderContext | undefined {
|
|
52
|
+
const parentContext = this._parent?.getResolverRenderContext?.();
|
|
53
|
+
const settings = this.model.get( 'settings' );
|
|
54
|
+
const showMarkersProp = settings?.get?.( 'show_markers' ) as unknown;
|
|
55
|
+
const showMarkers = ( showMarkersProp as { value?: boolean } )?.value ?? showMarkersProp ?? true;
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
...parentContext,
|
|
59
|
+
show_markers: showMarkers,
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
} );
|
|
63
|
+
}
|
package/src/legacy/types.ts
CHANGED
|
@@ -174,6 +174,10 @@ export declare class ElementView {
|
|
|
174
174
|
once: ( event: string, callback: () => void ) => void;
|
|
175
175
|
|
|
176
176
|
getContainer(): V1Element;
|
|
177
|
+
|
|
178
|
+
initialize?( ...args: unknown[] ): void;
|
|
179
|
+
|
|
180
|
+
listenTo( target: unknown, event: string, callback: () => void ): void;
|
|
177
181
|
}
|
|
178
182
|
|
|
179
183
|
export declare class TemplatedElementView extends ElementView {
|