@elementor/editor-controls 3.33.0-113 → 3.33.0-115
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 +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.js +122 -84
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +118 -81
- package/dist/index.mjs.map +1 -1
- package/package.json +14 -14
- package/src/components/css-code-editor/css-editor.styles.ts +1 -0
- package/src/components/css-code-editor/css-editor.tsx +66 -34
- package/src/components/icon-buttons/clear-icon-button.tsx +23 -0
- 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": "3.33.0-
|
|
4
|
+
"version": "3.33.0-115",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Elementor Team",
|
|
7
7
|
"homepage": "https://elementor.com/",
|
|
@@ -40,21 +40,21 @@
|
|
|
40
40
|
"dev": "tsup --config=../../tsup.dev.ts"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@elementor/editor-current-user": "3.33.0-
|
|
44
|
-
"@elementor/editor-elements": "3.33.0-
|
|
45
|
-
"@elementor/editor-props": "3.33.0-
|
|
46
|
-
"@elementor/editor-responsive": "3.33.0-
|
|
47
|
-
"@elementor/editor-ui": "3.33.0-
|
|
48
|
-
"@elementor/editor-v1-adapters": "3.33.0-
|
|
49
|
-
"@elementor/env": "3.33.0-
|
|
50
|
-
"@elementor/http-client": "3.33.0-
|
|
43
|
+
"@elementor/editor-current-user": "3.33.0-115",
|
|
44
|
+
"@elementor/editor-elements": "3.33.0-115",
|
|
45
|
+
"@elementor/editor-props": "3.33.0-115",
|
|
46
|
+
"@elementor/editor-responsive": "3.33.0-115",
|
|
47
|
+
"@elementor/editor-ui": "3.33.0-115",
|
|
48
|
+
"@elementor/editor-v1-adapters": "3.33.0-115",
|
|
49
|
+
"@elementor/env": "3.33.0-115",
|
|
50
|
+
"@elementor/http-client": "3.33.0-115",
|
|
51
51
|
"@elementor/icons": "^1.51.1",
|
|
52
|
-
"@elementor/locations": "3.33.0-
|
|
53
|
-
"@elementor/query": "3.33.0-
|
|
54
|
-
"@elementor/session": "3.33.0-
|
|
52
|
+
"@elementor/locations": "3.33.0-115",
|
|
53
|
+
"@elementor/query": "3.33.0-115",
|
|
54
|
+
"@elementor/session": "3.33.0-115",
|
|
55
55
|
"@elementor/ui": "1.36.12",
|
|
56
|
-
"@elementor/utils": "3.33.0-
|
|
57
|
-
"@elementor/wp-media": "3.33.0-
|
|
56
|
+
"@elementor/utils": "3.33.0-115",
|
|
57
|
+
"@elementor/wp-media": "3.33.0-115",
|
|
58
58
|
"@wordpress/i18n": "^5.13.0",
|
|
59
59
|
"@monaco-editor/react": "^4.7.0"
|
|
60
60
|
},
|
|
@@ -3,7 +3,10 @@ import type { editor, MonacoEditor } from 'monaco-types';
|
|
|
3
3
|
import { useActiveBreakpoint } from '@elementor/editor-responsive';
|
|
4
4
|
import { useTheme } from '@elementor/ui';
|
|
5
5
|
import { Editor } from '@monaco-editor/react';
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
6
7
|
|
|
8
|
+
import { FloatingActionsBar } from '../floating-bar';
|
|
9
|
+
import { ClearIconButton } from '../icon-buttons/clear-icon-button';
|
|
7
10
|
import { EditorWrapper } from './css-editor.styles';
|
|
8
11
|
import { clearMarkersFromVisualContent, setCustomSyntaxRules, validate } from './css-validation';
|
|
9
12
|
import { ResizeHandleComponent } from './resize-handle';
|
|
@@ -32,7 +35,8 @@ const getActual = ( value: string ): string => {
|
|
|
32
35
|
|
|
33
36
|
const createEditorDidMountHandler = (
|
|
34
37
|
editorRef: React.MutableRefObject< editor.IStandaloneCodeEditor | null >,
|
|
35
|
-
monacoRef: React.MutableRefObject< MonacoEditor | null
|
|
38
|
+
monacoRef: React.MutableRefObject< MonacoEditor | null >,
|
|
39
|
+
onUserContentChange: ( value: string ) => void
|
|
36
40
|
) => {
|
|
37
41
|
return ( editor: editor.IStandaloneCodeEditor, monaco: MonacoEditor ) => {
|
|
38
42
|
editorRef.current = editor;
|
|
@@ -42,6 +46,11 @@ const createEditorDidMountHandler = (
|
|
|
42
46
|
|
|
43
47
|
setCustomSyntaxRules( editor, monaco );
|
|
44
48
|
|
|
49
|
+
const initialCode = editor.getModel()?.getValue() ?? '';
|
|
50
|
+
const initialUserContent = getActual( initialCode );
|
|
51
|
+
|
|
52
|
+
onUserContentChange( initialUserContent );
|
|
53
|
+
|
|
45
54
|
monaco.editor.onDidChangeMarkers( () => {
|
|
46
55
|
setTimeout( () => clearMarkersFromVisualContent( editor, monaco ), 0 );
|
|
47
56
|
} );
|
|
@@ -57,6 +66,11 @@ export const CssEditor = ( { value, onChange }: CssEditorProps ) => {
|
|
|
57
66
|
const monacoRef = React.useRef< MonacoEditor | null >( null );
|
|
58
67
|
const debounceTimer = React.useRef< NodeJS.Timeout | null >( null );
|
|
59
68
|
const activeBreakpoint = useActiveBreakpoint();
|
|
69
|
+
const [ hasContent, setHasContent ] = React.useState( value.trim() !== '' );
|
|
70
|
+
|
|
71
|
+
const handleUserContentChange = React.useCallback( ( newValue: string ) => {
|
|
72
|
+
setHasContent( newValue.trim() !== '' );
|
|
73
|
+
}, [] );
|
|
60
74
|
|
|
61
75
|
const handleResize = React.useCallback( () => {
|
|
62
76
|
editorRef.current?.layout();
|
|
@@ -76,6 +90,8 @@ export const CssEditor = ( { value, onChange }: CssEditorProps ) => {
|
|
|
76
90
|
const code = editorRef.current?.getModel()?.getValue() ?? '';
|
|
77
91
|
const userContent = getActual( code );
|
|
78
92
|
|
|
93
|
+
setHasContent( userContent.trim() !== '' );
|
|
94
|
+
|
|
79
95
|
setCustomSyntaxRules( editorRef?.current, monacoRef.current );
|
|
80
96
|
|
|
81
97
|
const currentTimer = debounceTimer.current;
|
|
@@ -96,7 +112,9 @@ export const CssEditor = ( { value, onChange }: CssEditorProps ) => {
|
|
|
96
112
|
debounceTimer.current = newTimer;
|
|
97
113
|
};
|
|
98
114
|
|
|
99
|
-
const handleEditorDidMount = createEditorDidMountHandler( editorRef, monacoRef );
|
|
115
|
+
const handleEditorDidMount = createEditorDidMountHandler( editorRef, monacoRef, handleUserContentChange );
|
|
116
|
+
|
|
117
|
+
const handleReset = () => editorRef.current?.getModel()?.setValue( setVisualContent( '' ) );
|
|
100
118
|
|
|
101
119
|
React.useEffect( () => {
|
|
102
120
|
const timerRef = debounceTimer;
|
|
@@ -109,37 +127,51 @@ export const CssEditor = ( { value, onChange }: CssEditorProps ) => {
|
|
|
109
127
|
}, [] );
|
|
110
128
|
|
|
111
129
|
return (
|
|
112
|
-
<
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
130
|
+
<FloatingActionsBar
|
|
131
|
+
actions={
|
|
132
|
+
hasContent
|
|
133
|
+
? [
|
|
134
|
+
<ClearIconButton
|
|
135
|
+
key="clear"
|
|
136
|
+
tooltipText={ __( 'Clear', 'elementor' ) }
|
|
137
|
+
onClick={ handleReset }
|
|
138
|
+
/>,
|
|
139
|
+
]
|
|
140
|
+
: []
|
|
141
|
+
}
|
|
142
|
+
>
|
|
143
|
+
<EditorWrapper ref={ containerRef }>
|
|
144
|
+
<Editor
|
|
145
|
+
key={ activeBreakpoint }
|
|
146
|
+
height="100%"
|
|
147
|
+
language="css"
|
|
148
|
+
theme={ theme.palette.mode === 'dark' ? 'vs-dark' : 'vs' }
|
|
149
|
+
value={ setVisualContent( value ) }
|
|
150
|
+
onMount={ handleEditorDidMount }
|
|
151
|
+
onChange={ handleEditorChange }
|
|
152
|
+
options={ {
|
|
153
|
+
lineNumbers: 'on',
|
|
154
|
+
folding: true,
|
|
155
|
+
minimap: { enabled: false },
|
|
156
|
+
fontFamily: 'Roboto, Arial, Helvetica, Verdana, sans-serif',
|
|
157
|
+
fontSize: 12,
|
|
158
|
+
renderLineHighlight: 'none',
|
|
159
|
+
hideCursorInOverviewRuler: true,
|
|
160
|
+
fixedOverflowWidgets: true,
|
|
161
|
+
suggestFontSize: 10,
|
|
162
|
+
suggestLineHeight: 14,
|
|
163
|
+
stickyScroll: {
|
|
164
|
+
enabled: false,
|
|
165
|
+
},
|
|
166
|
+
lineDecorationsWidth: 2,
|
|
167
|
+
} }
|
|
168
|
+
/>
|
|
169
|
+
<ResizeHandleComponent
|
|
170
|
+
onResize={ handleResize }
|
|
171
|
+
containerRef={ containerRef }
|
|
172
|
+
onHeightChange={ handleHeightChange }
|
|
173
|
+
/>
|
|
174
|
+
</EditorWrapper>
|
|
175
|
+
</FloatingActionsBar>
|
|
144
176
|
);
|
|
145
177
|
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { BrushBigIcon } from '@elementor/icons';
|
|
3
|
+
import { IconButton, styled, Tooltip } from '@elementor/ui';
|
|
4
|
+
|
|
5
|
+
type ClearIconButtonProps = {
|
|
6
|
+
onClick?: () => void;
|
|
7
|
+
tooltipText: React.ReactNode;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
size?: 'tiny' | 'small' | 'medium' | 'large';
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const CustomIconButton = styled( IconButton )( ( { theme } ) => ( {
|
|
13
|
+
width: theme.spacing( 2.5 ),
|
|
14
|
+
height: theme.spacing( 2.5 ),
|
|
15
|
+
} ) );
|
|
16
|
+
|
|
17
|
+
export const ClearIconButton = ( { tooltipText, onClick, disabled, size = 'tiny' }: ClearIconButtonProps ) => (
|
|
18
|
+
<Tooltip title={ tooltipText } placement="top" disableInteractive>
|
|
19
|
+
<CustomIconButton aria-label={ tooltipText } size={ size } onClick={ onClick } disabled={ disabled }>
|
|
20
|
+
<BrushBigIcon fontSize={ size } />
|
|
21
|
+
</CustomIconButton>
|
|
22
|
+
</Tooltip>
|
|
23
|
+
);
|
package/src/index.ts
CHANGED
|
@@ -35,6 +35,7 @@ export { transitionProperties, transitionsItemsList } from './controls/transitio
|
|
|
35
35
|
export { ControlFormLabel } from './components/control-form-label';
|
|
36
36
|
export { ControlToggleButtonGroup } from './components/control-toggle-button-group';
|
|
37
37
|
export { CssEditor } from './components/css-code-editor/css-editor';
|
|
38
|
+
export { ClearIconButton } from './components/icon-buttons/clear-icon-button';
|
|
38
39
|
export { Repeater } from './components/repeater';
|
|
39
40
|
|
|
40
41
|
// types
|