@elementor/editor-controls 3.35.0-380 → 3.35.0-382
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 +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +15 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -24
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/inline-editor.tsx +11 -3
- package/src/controls/inline-editing-control.tsx +4 -23
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": "3.35.0-
|
|
4
|
+
"version": "3.35.0-382",
|
|
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": "3.35.0-
|
|
44
|
-
"@elementor/editor-elements": "3.35.0-
|
|
45
|
-
"@elementor/editor-props": "3.35.0-
|
|
46
|
-
"@elementor/editor-responsive": "3.35.0-
|
|
47
|
-
"@elementor/editor-ui": "3.35.0-
|
|
48
|
-
"@elementor/editor-v1-adapters": "3.35.0-
|
|
49
|
-
"@elementor/env": "3.35.0-
|
|
50
|
-
"@elementor/http-client": "3.35.0-
|
|
43
|
+
"@elementor/editor-current-user": "3.35.0-382",
|
|
44
|
+
"@elementor/editor-elements": "3.35.0-382",
|
|
45
|
+
"@elementor/editor-props": "3.35.0-382",
|
|
46
|
+
"@elementor/editor-responsive": "3.35.0-382",
|
|
47
|
+
"@elementor/editor-ui": "3.35.0-382",
|
|
48
|
+
"@elementor/editor-v1-adapters": "3.35.0-382",
|
|
49
|
+
"@elementor/env": "3.35.0-382",
|
|
50
|
+
"@elementor/http-client": "3.35.0-382",
|
|
51
51
|
"@elementor/icons": "^1.63.0",
|
|
52
|
-
"@elementor/locations": "3.35.0-
|
|
53
|
-
"@elementor/mixpanel": "3.35.0-
|
|
54
|
-
"@elementor/query": "3.35.0-
|
|
55
|
-
"@elementor/session": "3.35.0-
|
|
52
|
+
"@elementor/locations": "3.35.0-382",
|
|
53
|
+
"@elementor/mixpanel": "3.35.0-382",
|
|
54
|
+
"@elementor/query": "3.35.0-382",
|
|
55
|
+
"@elementor/session": "3.35.0-382",
|
|
56
56
|
"@elementor/ui": "1.36.17",
|
|
57
|
-
"@elementor/utils": "3.35.0-
|
|
58
|
-
"@elementor/wp-media": "3.35.0-
|
|
57
|
+
"@elementor/utils": "3.35.0-382",
|
|
58
|
+
"@elementor/wp-media": "3.35.0-382",
|
|
59
59
|
"@wordpress/i18n": "^5.13.0",
|
|
60
60
|
"@monaco-editor/react": "^4.7.0",
|
|
61
61
|
"dayjs": "^1.11.18",
|
|
@@ -31,6 +31,7 @@ type InlineEditorProps = {
|
|
|
31
31
|
value: string | null;
|
|
32
32
|
setValue: ( value: string | null ) => void;
|
|
33
33
|
attributes?: Record< string, string >;
|
|
34
|
+
elementClasses?: string;
|
|
34
35
|
sx?: SxProps< Theme >;
|
|
35
36
|
onBlur?: ( event: Event ) => void;
|
|
36
37
|
showToolbar?: boolean;
|
|
@@ -39,6 +40,8 @@ type InlineEditorProps = {
|
|
|
39
40
|
expectedTag?: string | null;
|
|
40
41
|
};
|
|
41
42
|
|
|
43
|
+
const INITIAL_STYLE = 'margin:0;padding:0;';
|
|
44
|
+
|
|
42
45
|
const useOnUpdate = ( callback: () => void, dependencies: DependencyList ): void => {
|
|
43
46
|
const hasMounted = useRef( false );
|
|
44
47
|
|
|
@@ -110,6 +113,7 @@ export const InlineEditor = forwardRef(
|
|
|
110
113
|
value,
|
|
111
114
|
setValue,
|
|
112
115
|
attributes = {},
|
|
116
|
+
elementClasses = '',
|
|
113
117
|
showToolbar = false,
|
|
114
118
|
autofocus = false,
|
|
115
119
|
sx = {},
|
|
@@ -167,20 +171,24 @@ export const InlineEditor = forwardRef(
|
|
|
167
171
|
Paragraph.extend( {
|
|
168
172
|
renderHTML( { HTMLAttributes } ) {
|
|
169
173
|
const tag = expectedTag ?? 'p';
|
|
170
|
-
return [ tag, { ...HTMLAttributes, style:
|
|
174
|
+
return [ tag, { ...HTMLAttributes, style: INITIAL_STYLE, class: elementClasses }, 0 ];
|
|
171
175
|
},
|
|
172
176
|
} ),
|
|
173
177
|
Heading.extend( {
|
|
174
178
|
renderHTML( { node, HTMLAttributes } ) {
|
|
175
179
|
if ( expectedTag ) {
|
|
176
|
-
return [
|
|
180
|
+
return [
|
|
181
|
+
expectedTag,
|
|
182
|
+
{ ...HTMLAttributes, style: INITIAL_STYLE, class: elementClasses },
|
|
183
|
+
0,
|
|
184
|
+
];
|
|
177
185
|
}
|
|
178
186
|
|
|
179
187
|
const level = this.options.levels.includes( node.attrs.level )
|
|
180
188
|
? node.attrs.level
|
|
181
189
|
: this.options.levels[ 0 ];
|
|
182
190
|
|
|
183
|
-
return [ `h${ level }`, { ...HTMLAttributes, style:
|
|
191
|
+
return [ `h${ level }`, { ...HTMLAttributes, style: INITIAL_STYLE, class: elementClasses }, 0 ];
|
|
184
192
|
},
|
|
185
193
|
} ).configure( {
|
|
186
194
|
levels: [ 1, 2, 3, 4, 5, 6 ],
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { type ComponentProps
|
|
3
|
-
import { htmlPropTypeUtil
|
|
4
|
-
import {
|
|
5
|
-
__privateListenTo as listenTo,
|
|
6
|
-
commandEndEvent,
|
|
7
|
-
type CommandEvent,
|
|
8
|
-
type ListenerEvent,
|
|
9
|
-
} from '@elementor/editor-v1-adapters';
|
|
2
|
+
import { type ComponentProps } from 'react';
|
|
3
|
+
import { htmlPropTypeUtil } from '@elementor/editor-props';
|
|
10
4
|
import { Box, type SxProps, type Theme } from '@elementor/ui';
|
|
11
5
|
|
|
12
6
|
import { useBoundProp } from '../bound-prop-context';
|
|
@@ -24,22 +18,9 @@ export const InlineEditingControl = createControl(
|
|
|
24
18
|
attributes?: Record< string, string >;
|
|
25
19
|
props?: ComponentProps< 'div' >;
|
|
26
20
|
} ) => {
|
|
27
|
-
const { value, setValue
|
|
28
|
-
const [ actualValue, setActualValue ] = useState< HtmlPropValue[ 'value' ] >( value );
|
|
21
|
+
const { value, setValue } = useBoundProp( htmlPropTypeUtil );
|
|
29
22
|
const handleChange = ( newValue: unknown ) => setValue( newValue as string );
|
|
30
23
|
|
|
31
|
-
useEffect( () => {
|
|
32
|
-
return listenTo( commandEndEvent( 'document/elements/settings' ), ( e: ListenerEvent ) => {
|
|
33
|
-
const { args, type } = e as CommandEvent< { settings: Record< string, HtmlPropValue > } >;
|
|
34
|
-
const settingValue = args?.settings?.[ bind ]?.value ?? null;
|
|
35
|
-
|
|
36
|
-
if ( type !== 'command' || settingValue !== actualValue ) {
|
|
37
|
-
setActualValue( settingValue );
|
|
38
|
-
}
|
|
39
|
-
} );
|
|
40
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
41
|
-
}, [] );
|
|
42
|
-
|
|
43
24
|
return (
|
|
44
25
|
<ControlActions>
|
|
45
26
|
<Box
|
|
@@ -74,7 +55,7 @@ export const InlineEditingControl = createControl(
|
|
|
74
55
|
{ ...attributes }
|
|
75
56
|
{ ...props }
|
|
76
57
|
>
|
|
77
|
-
<InlineEditor value={
|
|
58
|
+
<InlineEditor value={ value || '' } setValue={ handleChange } />
|
|
78
59
|
</Box>
|
|
79
60
|
</ControlActions>
|
|
80
61
|
);
|