11import { If } from "@mendix/widget-plugin-component-kit/If" ;
2+ import { useDebounceWithStatus } from "@mendix/widget-plugin-hooks/useDebounceWithStatus" ;
23import { executeAction } from "@mendix/widget-plugin-platform/framework/execute-action" ;
3- import { debounce } from "@mendix/widget-plugin-platform/utils/debounce" ;
44import classNames from "classnames" ;
55import Quill , { Range } from "quill" ;
66import "quill/dist/quill.core.css" ;
@@ -12,7 +12,6 @@ import {
1212 useCallback ,
1313 useContext ,
1414 useEffect ,
15- useMemo ,
1615 useRef ,
1716 useState
1817} from "react" ;
@@ -70,17 +69,17 @@ function EditorWrapperInner(props: EditorWrapperProps): ReactElement {
7069
7170 const { isFullscreen } = globalState ;
7271
73- const [ setAttributeValueDebounce ] = useMemo (
74- ( ) =>
75- debounce ( string => {
76- if ( stringAttribute . value !== string ) {
77- stringAttribute . setValue ( string ) ;
78- if ( onChangeType === "onDataChange" ) {
79- executeAction ( onChange ) ;
80- }
72+ const [ setAttributeValueDebounce ] = useDebounceWithStatus (
73+ ( string ?: string ) => {
74+ if ( stringAttribute . value !== string ) {
75+ stringAttribute . setValue ( string ) ;
76+ if ( onChangeType === "onDataChange" ) {
77+ executeAction ( onChange ) ;
8178 }
82- } , 200 ) ,
83- [ stringAttribute , onChange , onChangeType ]
79+ }
80+ } ,
81+ 200 ,
82+ onChange ?. isExecuting ?? false
8483 ) ;
8584
8685 const calculateCounts = useCallback (
@@ -128,15 +127,15 @@ function EditorWrapperInner(props: EditorWrapperProps): ReactElement {
128127 }
129128 }
130129 // eslint-disable-next-line react-hooks/exhaustive-deps
131- } , [ quillRef . current ] ) ;
130+ } , [ quillRef . current , onChange ?. isExecuting ] ) ;
132131
133132 const onTextChange = useCallback ( ( ) => {
134133 if ( stringAttribute . value !== quillRef ?. current ?. getSemanticHTML ( ) ) {
135134 setAttributeValueDebounce ( quillRef ?. current ?. getSemanticHTML ( ) ) ;
136135 }
137136 calculateCounts ( quillRef . current ) ;
138137 // eslint-disable-next-line react-hooks/exhaustive-deps
139- } , [ quillRef . current , stringAttribute , calculateCounts ] ) ;
138+ } , [ quillRef . current , stringAttribute , calculateCounts , onChange ?. isExecuting ] ) ;
140139
141140 const onSelectionChange = useCallback (
142141 ( range : Range ) => {
0 commit comments