@elementor/editor-controls 3.35.0-375 → 3.35.0-377
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 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +27 -14
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +37 -16
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -15
- package/src/components/inline-editor.tsx +23 -13
- package/src/controls/inline-editing-control.tsx +24 -4
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-377",
|
|
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-377",
|
|
44
|
+
"@elementor/editor-elements": "3.35.0-377",
|
|
45
|
+
"@elementor/editor-props": "3.35.0-377",
|
|
46
|
+
"@elementor/editor-responsive": "3.35.0-377",
|
|
47
|
+
"@elementor/editor-ui": "3.35.0-377",
|
|
48
|
+
"@elementor/editor-v1-adapters": "3.35.0-377",
|
|
49
|
+
"@elementor/env": "3.35.0-377",
|
|
50
|
+
"@elementor/http-client": "3.35.0-377",
|
|
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-377",
|
|
53
|
+
"@elementor/mixpanel": "3.35.0-377",
|
|
54
|
+
"@elementor/query": "3.35.0-377",
|
|
55
|
+
"@elementor/session": "3.35.0-377",
|
|
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-377",
|
|
58
|
+
"@elementor/wp-media": "3.35.0-377",
|
|
59
59
|
"@wordpress/i18n": "^5.13.0",
|
|
60
60
|
"@monaco-editor/react": "^4.7.0",
|
|
61
61
|
"dayjs": "^1.11.18",
|
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
type DependencyList,
|
|
4
|
+
forwardRef,
|
|
5
|
+
type PropsWithChildren,
|
|
6
|
+
type RefObject,
|
|
7
|
+
useEffect,
|
|
8
|
+
useRef,
|
|
9
|
+
useState,
|
|
10
|
+
} from 'react';
|
|
3
11
|
import { bindPopover, Box, ClickAwayListener, Popover, type SxProps, type Theme, usePopupState } from '@elementor/ui';
|
|
4
12
|
import Bold from '@tiptap/extension-bold';
|
|
5
13
|
import Document from '@tiptap/extension-document';
|
|
@@ -14,7 +22,7 @@ import Superscript from '@tiptap/extension-superscript';
|
|
|
14
22
|
import Text from '@tiptap/extension-text';
|
|
15
23
|
import Underline from '@tiptap/extension-underline';
|
|
16
24
|
import { type EditorView } from '@tiptap/pm/view';
|
|
17
|
-
import { EditorContent, useEditor } from '@tiptap/react';
|
|
25
|
+
import { type Editor, EditorContent, useEditor } from '@tiptap/react';
|
|
18
26
|
|
|
19
27
|
import { isEmpty } from '../utils/inline-editing';
|
|
20
28
|
import { InlineEditorToolbar } from './inline-editor-toolbar';
|
|
@@ -62,8 +70,8 @@ const calcSelectionCenter = (
|
|
|
62
70
|
return { left, top };
|
|
63
71
|
};
|
|
64
72
|
|
|
65
|
-
type WrapperProps =
|
|
66
|
-
containerRef:
|
|
73
|
+
type WrapperProps = PropsWithChildren< {
|
|
74
|
+
containerRef: RefObject< HTMLDivElement >;
|
|
67
75
|
editor: ReturnType< typeof useEditor >;
|
|
68
76
|
sx: SxProps< Theme >;
|
|
69
77
|
onBlur?: ( event: Event ) => void;
|
|
@@ -96,7 +104,7 @@ const Wrapper = ( { children, containerRef, editor, sx, onBlur }: WrapperProps )
|
|
|
96
104
|
);
|
|
97
105
|
};
|
|
98
106
|
|
|
99
|
-
export const InlineEditor =
|
|
107
|
+
export const InlineEditor = forwardRef(
|
|
100
108
|
(
|
|
101
109
|
{
|
|
102
110
|
value,
|
|
@@ -111,11 +119,11 @@ export const InlineEditor = React.forwardRef(
|
|
|
111
119
|
}: InlineEditorProps,
|
|
112
120
|
ref
|
|
113
121
|
) => {
|
|
114
|
-
const containerRef =
|
|
122
|
+
const containerRef = useRef< HTMLDivElement >( null );
|
|
115
123
|
const popupState = usePopupState( { variant: 'popover', disableAutoFocus: true } );
|
|
116
|
-
const [ hasSelectedContent, setHasSelectedContent ] =
|
|
124
|
+
const [ hasSelectedContent, setHasSelectedContent ] = useState( false );
|
|
117
125
|
const documentContentSettings = !! expectedTag ? 'block+' : 'inline*';
|
|
118
|
-
const [ selectionRect, setSelectionRect ] =
|
|
126
|
+
const [ selectionRect, setSelectionRect ] = useState< { left: number; top: number } | null >( null );
|
|
119
127
|
|
|
120
128
|
const onSelectionEnd = ( view: EditorView ) => {
|
|
121
129
|
const hasSelection = ! view.state.selection.empty;
|
|
@@ -145,6 +153,12 @@ export const InlineEditor = React.forwardRef(
|
|
|
145
153
|
}
|
|
146
154
|
: undefined;
|
|
147
155
|
|
|
156
|
+
const onUpdate = ( { editor: updatedEditor }: { editor: Editor } ) => {
|
|
157
|
+
const newValue: string | null = updatedEditor.getHTML();
|
|
158
|
+
|
|
159
|
+
setValue( isEmpty( newValue ) ? null : newValue );
|
|
160
|
+
};
|
|
161
|
+
|
|
148
162
|
const editor = useEditor( {
|
|
149
163
|
extensions: [
|
|
150
164
|
Document.extend( {
|
|
@@ -190,11 +204,7 @@ export const InlineEditor = React.forwardRef(
|
|
|
190
204
|
} ),
|
|
191
205
|
],
|
|
192
206
|
content: value,
|
|
193
|
-
onUpdate
|
|
194
|
-
const newValue: string | null = updatedEditor.getHTML();
|
|
195
|
-
|
|
196
|
-
setValue( isEmpty( newValue ) ? null : newValue );
|
|
197
|
-
},
|
|
207
|
+
onUpdate,
|
|
198
208
|
autofocus,
|
|
199
209
|
editorProps: {
|
|
200
210
|
attributes: {
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { type ComponentProps, useEffect, useState } from 'react';
|
|
3
|
+
import { htmlPropTypeUtil, type HtmlPropValue } from '@elementor/editor-props';
|
|
4
|
+
import {
|
|
5
|
+
__privateListenTo as listenTo,
|
|
6
|
+
commandEndEvent,
|
|
7
|
+
type CommandEvent,
|
|
8
|
+
type ListenerEvent,
|
|
9
|
+
} from '@elementor/editor-v1-adapters';
|
|
3
10
|
import { Box, type SxProps, type Theme } from '@elementor/ui';
|
|
4
11
|
|
|
5
12
|
import { useBoundProp } from '../bound-prop-context';
|
|
@@ -15,11 +22,24 @@ export const InlineEditingControl = createControl(
|
|
|
15
22
|
}: {
|
|
16
23
|
sx?: SxProps< Theme >;
|
|
17
24
|
attributes?: Record< string, string >;
|
|
18
|
-
props?:
|
|
25
|
+
props?: ComponentProps< 'div' >;
|
|
19
26
|
} ) => {
|
|
20
|
-
const { value, setValue } = useBoundProp( htmlPropTypeUtil );
|
|
27
|
+
const { value, setValue, bind } = useBoundProp( htmlPropTypeUtil );
|
|
28
|
+
const [ actualValue, setActualValue ] = useState< HtmlPropValue[ 'value' ] >( value );
|
|
21
29
|
const handleChange = ( newValue: unknown ) => setValue( newValue as string );
|
|
22
30
|
|
|
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
|
+
|
|
23
43
|
return (
|
|
24
44
|
<ControlActions>
|
|
25
45
|
<Box
|
|
@@ -54,7 +74,7 @@ export const InlineEditingControl = createControl(
|
|
|
54
74
|
{ ...attributes }
|
|
55
75
|
{ ...props }
|
|
56
76
|
>
|
|
57
|
-
<InlineEditor value={
|
|
77
|
+
<InlineEditor value={ actualValue || '' } setValue={ handleChange } />
|
|
58
78
|
</Box>
|
|
59
79
|
</ControlActions>
|
|
60
80
|
);
|