@elementor/editor-controls 4.0.0-573 → 4.0.0-597
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 +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +16 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +16 -18
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/size/unstable-size-field.tsx +7 -12
- package/src/controls/inline-editing-control.tsx +5 -5
- package/src/hooks/use-size-value.ts +9 -4
- package/src/index.ts +1 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@elementor/editor-controls",
|
|
3
3
|
"description": "This package contains the controls model and utils for the Elementor editor",
|
|
4
|
-
"version": "4.0.0-
|
|
4
|
+
"version": "4.0.0-597",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -40,22 +40,22 @@
|
|
|
40
40
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@elementor/editor-current-user": "4.0.0-
|
|
44
|
-
"@elementor/editor-elements": "4.0.0-
|
|
45
|
-
"@elementor/editor-props": "4.0.0-
|
|
46
|
-
"@elementor/editor-responsive": "4.0.0-
|
|
47
|
-
"@elementor/editor-ui": "4.0.0-
|
|
48
|
-
"@elementor/editor-v1-adapters": "4.0.0-
|
|
49
|
-
"@elementor/env": "4.0.0-
|
|
50
|
-
"@elementor/http-client": "4.0.0-
|
|
43
|
+
"@elementor/editor-current-user": "4.0.0-597",
|
|
44
|
+
"@elementor/editor-elements": "4.0.0-597",
|
|
45
|
+
"@elementor/editor-props": "4.0.0-597",
|
|
46
|
+
"@elementor/editor-responsive": "4.0.0-597",
|
|
47
|
+
"@elementor/editor-ui": "4.0.0-597",
|
|
48
|
+
"@elementor/editor-v1-adapters": "4.0.0-597",
|
|
49
|
+
"@elementor/env": "4.0.0-597",
|
|
50
|
+
"@elementor/http-client": "4.0.0-597",
|
|
51
51
|
"@elementor/icons": "^1.63.0",
|
|
52
|
-
"@elementor/locations": "4.0.0-
|
|
53
|
-
"@elementor/events": "4.0.0-
|
|
54
|
-
"@elementor/query": "4.0.0-
|
|
55
|
-
"@elementor/session": "4.0.0-
|
|
52
|
+
"@elementor/locations": "4.0.0-597",
|
|
53
|
+
"@elementor/events": "4.0.0-597",
|
|
54
|
+
"@elementor/query": "4.0.0-597",
|
|
55
|
+
"@elementor/session": "4.0.0-597",
|
|
56
56
|
"@elementor/ui": "1.36.17",
|
|
57
|
-
"@elementor/utils": "4.0.0-
|
|
58
|
-
"@elementor/wp-media": "4.0.0-
|
|
57
|
+
"@elementor/utils": "4.0.0-597",
|
|
58
|
+
"@elementor/wp-media": "4.0.0-597",
|
|
59
59
|
"@wordpress/i18n": "^5.13.0",
|
|
60
60
|
"@monaco-editor/react": "^4.7.0",
|
|
61
61
|
"dayjs": "^1.11.18",
|
|
@@ -8,32 +8,26 @@ import { UnitSelect } from './unit-select';
|
|
|
8
8
|
import { UnstableSizeInput } from './unstable-size-input';
|
|
9
9
|
|
|
10
10
|
type Props< TValue > = {
|
|
11
|
-
units: Unit[];
|
|
12
11
|
value: TValue;
|
|
13
|
-
|
|
12
|
+
units: Unit[];
|
|
13
|
+
defaultUnit?: Unit;
|
|
14
14
|
onChange: ( value: TValue ) => void;
|
|
15
15
|
onBlur?: ( event: React.FocusEvent< HTMLInputElement > ) => void;
|
|
16
16
|
disabled?: boolean;
|
|
17
17
|
InputProps?: TextFieldProps[ 'InputProps' ];
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const DEFAULT_VALUE: SizePropValue[ 'value' ] = {
|
|
21
|
-
unit: 'px',
|
|
22
|
-
size: 0,
|
|
18
|
+
startIcon?: React.ReactNode;
|
|
23
19
|
};
|
|
24
20
|
|
|
25
21
|
export const UnstableSizeField = < T extends SizePropValue[ 'value' ] >( {
|
|
26
22
|
value,
|
|
27
23
|
InputProps,
|
|
28
|
-
defaultValue,
|
|
29
24
|
onChange,
|
|
30
25
|
onBlur,
|
|
31
26
|
units,
|
|
27
|
+
defaultUnit,
|
|
28
|
+
startIcon,
|
|
32
29
|
}: Props< T > ) => {
|
|
33
|
-
const { size, unit, setSize, setUnit } = useSizeValue< T >( value, onChange,
|
|
34
|
-
...DEFAULT_VALUE,
|
|
35
|
-
...defaultValue,
|
|
36
|
-
} as T );
|
|
30
|
+
const { size, unit, setSize, setUnit } = useSizeValue< T >( value, onChange, defaultUnit );
|
|
37
31
|
|
|
38
32
|
const shouldHighlightUnit = () => {
|
|
39
33
|
return hasValue( size );
|
|
@@ -47,6 +41,7 @@ export const UnstableSizeField = < T extends SizePropValue[ 'value' ] >( {
|
|
|
47
41
|
onChange={ ( event ) => setSize( event.target.value ) }
|
|
48
42
|
InputProps={ {
|
|
49
43
|
...InputProps,
|
|
44
|
+
startAdornment: startIcon && <InputAdornment position="start">{ startIcon }</InputAdornment>,
|
|
50
45
|
endAdornment: (
|
|
51
46
|
<InputAdornment position="end">
|
|
52
47
|
<UnitSelect
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { type ComponentProps, useCallback, useEffect, useMemo } from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { htmlV3PropTypeUtil, parseHtmlChildren, stringPropTypeUtil } from '@elementor/editor-props';
|
|
4
4
|
import { Box, type SxProps, type Theme } from '@elementor/ui';
|
|
5
5
|
import { debounce } from '@elementor/utils';
|
|
6
6
|
|
|
@@ -21,8 +21,8 @@ export const InlineEditingControl = createControl(
|
|
|
21
21
|
attributes?: Record< string, string >;
|
|
22
22
|
props?: ComponentProps< 'div' >;
|
|
23
23
|
} ) => {
|
|
24
|
-
const { value, setValue } = useBoundProp(
|
|
25
|
-
const content = value?.content ?? '';
|
|
24
|
+
const { value, setValue } = useBoundProp( htmlV3PropTypeUtil );
|
|
25
|
+
const content = stringPropTypeUtil.extract( value?.content ?? null ) ?? '';
|
|
26
26
|
|
|
27
27
|
const debouncedParse = useMemo(
|
|
28
28
|
() =>
|
|
@@ -30,7 +30,7 @@ export const InlineEditingControl = createControl(
|
|
|
30
30
|
const parsed = parseHtmlChildren( html );
|
|
31
31
|
|
|
32
32
|
setValue( {
|
|
33
|
-
content: parsed.content
|
|
33
|
+
content: parsed.content ? stringPropTypeUtil.create( parsed.content ) : null,
|
|
34
34
|
children: parsed.children,
|
|
35
35
|
} );
|
|
36
36
|
}, CHILDREN_PARSE_DEBOUNCE_MS ),
|
|
@@ -42,7 +42,7 @@ export const InlineEditingControl = createControl(
|
|
|
42
42
|
const html = ( newValue ?? '' ) as string;
|
|
43
43
|
|
|
44
44
|
setValue( {
|
|
45
|
-
content: html
|
|
45
|
+
content: html ? stringPropTypeUtil.create( html ) : null,
|
|
46
46
|
children: value?.children ?? [],
|
|
47
47
|
} );
|
|
48
48
|
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
+
import type { Unit } from '@elementor/editor-controls';
|
|
1
2
|
import { type SizePropValue } from '@elementor/editor-props';
|
|
2
3
|
|
|
3
4
|
import { useSyncExternalState } from '../hooks/use-sync-external-state';
|
|
4
5
|
|
|
6
|
+
const DEFAULT_UNIT = 'px';
|
|
7
|
+
|
|
8
|
+
const DEFAULT_SIZE = '';
|
|
9
|
+
|
|
5
10
|
export const useSizeValue = < T extends SizePropValue[ 'value' ] >(
|
|
6
11
|
externalValue: T,
|
|
7
12
|
onChange: ( value: T ) => void,
|
|
8
|
-
|
|
13
|
+
defaultUnit?: Unit
|
|
9
14
|
) => {
|
|
10
15
|
const [ sizeValue, setSizeValue ] = useSyncExternalState< T >( {
|
|
11
16
|
external: externalValue,
|
|
@@ -15,7 +20,7 @@ export const useSizeValue = < T extends SizePropValue[ 'value' ] >(
|
|
|
15
20
|
}
|
|
16
21
|
},
|
|
17
22
|
persistWhen: ( newState ) => differsFromExternal( newState as T, externalValue ),
|
|
18
|
-
fallback: () =>
|
|
23
|
+
fallback: () => ( { size: DEFAULT_SIZE, unit: defaultUnit ?? DEFAULT_UNIT } ) as unknown as T,
|
|
19
24
|
} );
|
|
20
25
|
|
|
21
26
|
const setSize = ( value: string ) => {
|
|
@@ -44,6 +49,6 @@ export const useSizeValue = < T extends SizePropValue[ 'value' ] >(
|
|
|
44
49
|
};
|
|
45
50
|
};
|
|
46
51
|
|
|
47
|
-
const differsFromExternal = ( newState
|
|
48
|
-
return newState
|
|
52
|
+
const differsFromExternal = ( newState?: SizePropValue[ 'value' ], externalState?: SizePropValue[ 'value' ] ) => {
|
|
53
|
+
return newState?.size !== externalState?.size || newState?.unit !== externalState?.unit;
|
|
49
54
|
};
|
package/src/index.ts
CHANGED
|
@@ -56,6 +56,7 @@ export { PopoverGridContainer } from './components/popover-grid-container';
|
|
|
56
56
|
export { InlineEditor } from './components/inline-editor';
|
|
57
57
|
export { InlineEditorToolbar } from './components/inline-editor-toolbar';
|
|
58
58
|
export { UnstableSizeField } from './components/size/unstable-size-field';
|
|
59
|
+
export { NumberInput } from './components/number-input';
|
|
59
60
|
|
|
60
61
|
// types
|
|
61
62
|
export type { ControlComponent } from './create-control';
|