@elementor/editor-canvas 0.17.0 → 0.18.0
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/.turbo/turbo-build.log +10 -10
- package/CHANGELOG.md +23 -0
- package/dist/index.d.mts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +10 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -13
- package/dist/index.mjs.map +1 -1
- package/package.json +7 -7
- package/src/components/style-renderer.tsx +5 -7
- package/src/hooks/__tests__/use-style-items.test.ts +29 -32
- package/src/hooks/use-floating-on-element.ts +2 -2
- package/src/hooks/use-style-items.ts +2 -2
- package/src/index.ts +1 -3
- package/src/style-commands/__tests__/paste-style.test.ts +5 -5
- package/src/style-commands/__tests__/reset-style.test.ts +2 -2
- package/src/style-commands/undoable-actions/paste-element-style.ts +3 -3
- package/src/style-commands/undoable-actions/reset-element-style.ts +2 -2
|
@@ -7,6 +7,7 @@ import { useStyleItems } from '../use-style-items';
|
|
|
7
7
|
import { useStyleRenderer } from '../use-style-renderer';
|
|
8
8
|
|
|
9
9
|
jest.mock( '@elementor/editor-styles-repository', () => ( {
|
|
10
|
+
...jest.requireActual( '@elementor/editor-styles-repository' ),
|
|
10
11
|
stylesRepository: {
|
|
11
12
|
getProviders: jest.fn(),
|
|
12
13
|
},
|
|
@@ -36,23 +37,21 @@ describe( 'useStyleItems', () => {
|
|
|
36
37
|
|
|
37
38
|
it( 'should return style items from providers when subscribed', async () => {
|
|
38
39
|
// Arrange.
|
|
39
|
-
const mockProvider1 = createMockStylesProvider(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
} );
|
|
40
|
+
const mockProvider1 = createMockStylesProvider(
|
|
41
|
+
{
|
|
42
|
+
key: 'provider1',
|
|
43
|
+
priority: 2,
|
|
44
|
+
},
|
|
45
|
+
[ createMockStyleDefinition( { id: 'style1' } ), createMockStyleDefinition( { id: 'style2' } ) ]
|
|
46
|
+
);
|
|
47
47
|
|
|
48
|
-
const mockProvider2 = createMockStylesProvider(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
} );
|
|
48
|
+
const mockProvider2 = createMockStylesProvider(
|
|
49
|
+
{
|
|
50
|
+
key: 'provider2',
|
|
51
|
+
priority: 1,
|
|
52
|
+
},
|
|
53
|
+
[ createMockStyleDefinition( { id: 'style3' } ), createMockStyleDefinition( { id: 'style4' } ) ]
|
|
54
|
+
);
|
|
56
55
|
|
|
57
56
|
jest.mocked( stylesRepository ).getProviders.mockReturnValue( [ mockProvider1, mockProvider2 ] );
|
|
58
57
|
|
|
@@ -89,23 +88,21 @@ describe( 'useStyleItems', () => {
|
|
|
89
88
|
|
|
90
89
|
it( 'should return style items when attach-preview command is triggered', async () => {
|
|
91
90
|
// Arrange.
|
|
92
|
-
const mockProvider1 = createMockStylesProvider(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
} );
|
|
91
|
+
const mockProvider1 = createMockStylesProvider(
|
|
92
|
+
{
|
|
93
|
+
key: 'provider1',
|
|
94
|
+
priority: 2,
|
|
95
|
+
},
|
|
96
|
+
[ createMockStyleDefinition( { id: 'style1' } ), createMockStyleDefinition( { id: 'style2' } ) ]
|
|
97
|
+
);
|
|
100
98
|
|
|
101
|
-
const mockProvider2 = createMockStylesProvider(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
} );
|
|
99
|
+
const mockProvider2 = createMockStylesProvider(
|
|
100
|
+
{
|
|
101
|
+
key: 'provider2',
|
|
102
|
+
priority: 1,
|
|
103
|
+
},
|
|
104
|
+
[ createMockStyleDefinition( { id: 'style3' } ), createMockStyleDefinition( { id: 'style4' } ) ]
|
|
105
|
+
);
|
|
109
106
|
|
|
110
107
|
jest.mocked( stylesRepository ).getProviders.mockReturnValue( [ mockProvider1, mockProvider2 ] );
|
|
111
108
|
|
|
@@ -21,8 +21,8 @@ export function useFloatingOnElement( { element, isSelected }: Options ) {
|
|
|
21
21
|
size( {
|
|
22
22
|
apply( { elements, rects } ) {
|
|
23
23
|
Object.assign( elements.floating.style, {
|
|
24
|
-
width: `${ rects.reference.width }px`,
|
|
25
|
-
height: `${ rects.reference.height }px`,
|
|
24
|
+
width: `${ rects.reference.width + 2 }px`,
|
|
25
|
+
height: `${ rects.reference.height + 2 }px`,
|
|
26
26
|
} );
|
|
27
27
|
},
|
|
28
28
|
} ),
|
|
@@ -66,11 +66,11 @@ type CreateProviderSubscriberArgs = {
|
|
|
66
66
|
function createProviderSubscriber( { provider, renderStyles, setStyleItems }: CreateProviderSubscriberArgs ) {
|
|
67
67
|
return abortPreviousRuns( ( abortController ) =>
|
|
68
68
|
signalizedProcess( abortController.signal )
|
|
69
|
-
.then( ( _, signal ) => renderStyles( { styles: provider.actions.
|
|
69
|
+
.then( ( _, signal ) => renderStyles( { styles: provider.actions.all(), signal } ) )
|
|
70
70
|
.then( ( items ) => {
|
|
71
71
|
setStyleItems( ( prev ) => ( {
|
|
72
72
|
...prev,
|
|
73
|
-
[ provider.
|
|
73
|
+
[ provider.getKey() ]: { provider, items },
|
|
74
74
|
} ) );
|
|
75
75
|
} )
|
|
76
76
|
.execute()
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
export { init } from './init';
|
|
2
2
|
|
|
3
3
|
export { styleTransformersRegistry } from './style-transformers-registry';
|
|
4
4
|
export { settingsTransformersRegistry } from './settings-transformers-registry';
|
|
5
5
|
export { createTransformer } from './transformers/create-transformer';
|
|
6
|
-
|
|
7
|
-
init();
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
updateElementStyle,
|
|
12
12
|
} from '@elementor/editor-elements';
|
|
13
13
|
import { type StyleDefinition } from '@elementor/editor-styles';
|
|
14
|
-
import {
|
|
14
|
+
import { ELEMENTS_STYLES_RESERVED_LABEL } from '@elementor/editor-styles-repository';
|
|
15
15
|
|
|
16
16
|
import { initPasteStyleCommand } from '../paste-style';
|
|
17
17
|
import { getClassesProp, getClipboardElements, isAtomicWidget } from '../utils';
|
|
@@ -132,7 +132,7 @@ describe( 'pasteStyles', () => {
|
|
|
132
132
|
expect( createElementStyle ).toHaveBeenCalledWith( {
|
|
133
133
|
elementId: 'test-container',
|
|
134
134
|
styleId: 's-1',
|
|
135
|
-
label:
|
|
135
|
+
label: ELEMENTS_STYLES_RESERVED_LABEL,
|
|
136
136
|
classesProp: 'classes',
|
|
137
137
|
meta: {
|
|
138
138
|
breakpoint: null,
|
|
@@ -195,7 +195,7 @@ describe( 'pasteStyles', () => {
|
|
|
195
195
|
// Assert.
|
|
196
196
|
expect( createElementStyle ).toHaveBeenCalledWith( {
|
|
197
197
|
elementId: 'test-container',
|
|
198
|
-
label:
|
|
198
|
+
label: ELEMENTS_STYLES_RESERVED_LABEL,
|
|
199
199
|
classesProp: 'classes',
|
|
200
200
|
meta: {
|
|
201
201
|
breakpoint: null,
|
|
@@ -461,7 +461,7 @@ describe( 'pasteStyles', () => {
|
|
|
461
461
|
// Assert.
|
|
462
462
|
expect( createElementStyle ).toHaveBeenCalledWith( {
|
|
463
463
|
elementId: 'test-container-1',
|
|
464
|
-
label:
|
|
464
|
+
label: ELEMENTS_STYLES_RESERVED_LABEL,
|
|
465
465
|
classesProp: 'classes',
|
|
466
466
|
meta: {
|
|
467
467
|
breakpoint: null,
|
|
@@ -522,7 +522,7 @@ describe( 'pasteStyles', () => {
|
|
|
522
522
|
|
|
523
523
|
expect( createElementStyle ).toHaveBeenCalledWith( {
|
|
524
524
|
elementId: 'test-container-2',
|
|
525
|
-
label:
|
|
525
|
+
label: ELEMENTS_STYLES_RESERVED_LABEL,
|
|
526
526
|
classesProp: 'classes',
|
|
527
527
|
styleId: 's-1',
|
|
528
528
|
meta: {
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
mockHistoryManager,
|
|
6
6
|
} from 'test-utils';
|
|
7
7
|
import { createElementStyle, deleteElementStyle, getElementStyles } from '@elementor/editor-elements';
|
|
8
|
-
import {
|
|
8
|
+
import { ELEMENTS_STYLES_RESERVED_LABEL } from '@elementor/editor-styles-repository';
|
|
9
9
|
|
|
10
10
|
import { initResetStyleCommand } from '../reset-style';
|
|
11
11
|
import { getClassesProp, hasAtomicWidgets, isAtomicWidget } from '../utils';
|
|
@@ -80,7 +80,7 @@ describe( 'resetStyles', () => {
|
|
|
80
80
|
// Assert.
|
|
81
81
|
expect( createElementStyle ).toHaveBeenCalledWith( {
|
|
82
82
|
elementId: 'test-container',
|
|
83
|
-
label:
|
|
83
|
+
label: ELEMENTS_STYLES_RESERVED_LABEL,
|
|
84
84
|
classesProp: 'classes',
|
|
85
85
|
meta: {
|
|
86
86
|
breakpoint: null,
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
type V1Element,
|
|
7
7
|
} from '@elementor/editor-elements';
|
|
8
8
|
import { type StyleDefinition } from '@elementor/editor-styles';
|
|
9
|
-
import {
|
|
9
|
+
import { ELEMENTS_STYLES_RESERVED_LABEL } from '@elementor/editor-styles-repository';
|
|
10
10
|
import { undoable } from '@elementor/editor-v1-adapters';
|
|
11
11
|
import { __ } from '@wordpress/i18n';
|
|
12
12
|
|
|
@@ -55,7 +55,7 @@ export const undoablePasteElementStyle = () =>
|
|
|
55
55
|
revertData.styleId = createElementStyle( {
|
|
56
56
|
elementId,
|
|
57
57
|
classesProp,
|
|
58
|
-
label:
|
|
58
|
+
label: ELEMENTS_STYLES_RESERVED_LABEL,
|
|
59
59
|
...firstVariant,
|
|
60
60
|
additionalVariants,
|
|
61
61
|
} );
|
|
@@ -92,7 +92,7 @@ export const undoablePasteElementStyle = () =>
|
|
|
92
92
|
createElementStyle( {
|
|
93
93
|
elementId: container.id,
|
|
94
94
|
classesProp,
|
|
95
|
-
label:
|
|
95
|
+
label: ELEMENTS_STYLES_RESERVED_LABEL,
|
|
96
96
|
styleId: revertData.styleId,
|
|
97
97
|
...firstVariant,
|
|
98
98
|
additionalVariants,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createElementStyle, deleteElementStyle, getElementStyles, type V1Element } from '@elementor/editor-elements';
|
|
2
|
-
import {
|
|
2
|
+
import { ELEMENTS_STYLES_RESERVED_LABEL } from '@elementor/editor-styles-repository';
|
|
3
3
|
import { undoable } from '@elementor/editor-v1-adapters';
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
|
|
@@ -45,7 +45,7 @@ export const undoableResetElementStyle = () =>
|
|
|
45
45
|
elementId,
|
|
46
46
|
classesProp,
|
|
47
47
|
styleId,
|
|
48
|
-
label:
|
|
48
|
+
label: ELEMENTS_STYLES_RESERVED_LABEL,
|
|
49
49
|
...firstVariant,
|
|
50
50
|
additionalVariants,
|
|
51
51
|
} );
|