@elementor/editor-controls 3.33.0-294 → 3.33.0-296

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/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-294",
4
+ "version": "3.33.0-296",
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.33.0-294",
44
- "@elementor/editor-elements": "3.33.0-294",
45
- "@elementor/editor-props": "3.33.0-294",
46
- "@elementor/editor-responsive": "3.33.0-294",
47
- "@elementor/editor-ui": "3.33.0-294",
48
- "@elementor/editor-v1-adapters": "3.33.0-294",
49
- "@elementor/env": "3.33.0-294",
50
- "@elementor/http-client": "3.33.0-294",
43
+ "@elementor/editor-current-user": "3.33.0-296",
44
+ "@elementor/editor-elements": "3.33.0-296",
45
+ "@elementor/editor-props": "3.33.0-296",
46
+ "@elementor/editor-responsive": "3.33.0-296",
47
+ "@elementor/editor-ui": "3.33.0-296",
48
+ "@elementor/editor-v1-adapters": "3.33.0-296",
49
+ "@elementor/env": "3.33.0-296",
50
+ "@elementor/http-client": "3.33.0-296",
51
51
  "@elementor/icons": "^1.61.0",
52
- "@elementor/locations": "3.33.0-294",
53
- "@elementor/mixpanel": "3.33.0-294",
54
- "@elementor/query": "3.33.0-294",
55
- "@elementor/session": "3.33.0-294",
52
+ "@elementor/locations": "3.33.0-296",
53
+ "@elementor/mixpanel": "3.33.0-296",
54
+ "@elementor/query": "3.33.0-296",
55
+ "@elementor/session": "3.33.0-296",
56
56
  "@elementor/ui": "1.36.17",
57
- "@elementor/utils": "3.33.0-294",
58
- "@elementor/wp-media": "3.33.0-294",
57
+ "@elementor/utils": "3.33.0-296",
58
+ "@elementor/wp-media": "3.33.0-296",
59
59
  "@wordpress/i18n": "^5.13.0",
60
60
  "@monaco-editor/react": "^4.7.0",
61
61
  "dayjs": "^1.11.18",
@@ -1,5 +1,5 @@
1
1
  import * as React from 'react';
2
- import { type ForwardedRef } from 'react';
2
+ import { type DependencyList, type ForwardedRef, useEffect, useRef } from 'react';
3
3
  import { Box, type SxProps, type Theme } from '@elementor/ui';
4
4
  import Bold from '@tiptap/extension-bold';
5
5
  import Document from '@tiptap/extension-document';
@@ -17,6 +17,19 @@ type InlineEditorProps = {
17
17
  sx?: SxProps< Theme >;
18
18
  };
19
19
 
20
+ const useOnUpdate = ( callback: () => void, dependencies: DependencyList ): void => {
21
+ const hasMounted = useRef( false );
22
+
23
+ useEffect( () => {
24
+ if ( hasMounted.current ) {
25
+ callback();
26
+ } else {
27
+ hasMounted.current = true;
28
+ }
29
+ // eslint-disable-next-line react-hooks/exhaustive-deps
30
+ }, dependencies );
31
+ };
32
+
20
33
  export const InlineEditor = React.forwardRef(
21
34
  ( { value, setValue, attributes = {}, sx }: InlineEditorProps, ref: ForwardedRef< HTMLDivElement > ) => {
22
35
  const editor = useEditor( {
@@ -41,6 +54,18 @@ export const InlineEditor = React.forwardRef(
41
54
  onUpdate: ( { editor: updatedEditor } ) => setValue( updatedEditor.getHTML() ),
42
55
  } );
43
56
 
57
+ useOnUpdate( () => {
58
+ if ( ! editor ) {
59
+ return;
60
+ }
61
+
62
+ const currentContent = editor.getHTML();
63
+
64
+ if ( currentContent !== value ) {
65
+ editor.commands.setContent( value, { emitUpdate: false } );
66
+ }
67
+ }, [ editor, value ] );
68
+
44
69
  return (
45
70
  <Box
46
71
  ref={ ref }