@@ -8,7 +8,7 @@ import { TaskList } from "@tiptap/extension-task-list";
88import { TextStyle } from "@tiptap/extension-text-style" ;
99import { EditorContent , useEditor } from "@tiptap/react" ;
1010import { StarterKit } from "@tiptap/starter-kit" ;
11- import { forwardRef , ReactElement , useImperativeHandle , useMemo } from "react" ;
11+ import { forwardRef , ReactElement , useEffect , useImperativeHandle , useMemo } from "react" ;
1212import { executeAction } from "@mendix/widget-plugin-platform/framework/execute-action" ;
1313import { EditorContextProvider , useCurrentEditor } from "./EditorContext" ;
1414import { HighlightedCodeEditor } from "./HighlightedCodeEditor" ;
@@ -275,6 +275,18 @@ const Editor = forwardRef<EditorHandle, EditorProps>((props, ref) => {
275275 getEditor : ( ) => editor
276276 } ) ) ;
277277
278+ // update quills content on value change.
279+ useEffect ( ( ) => {
280+ // if there is an update comes from external element (default value sudden change)
281+ // only do update if editor not focused, otherwise it will override the user input.
282+ if ( ! editor . isFocused ) {
283+ const newContent = editor . getHTML ( ) ;
284+ if ( newContent && newContent !== defaultValue ) {
285+ editor . commands . setContent ( defaultValue || "" ) ;
286+ }
287+ }
288+ } , [ editor , defaultValue ] ) ;
289+
278290 if ( ! editor ) {
279291 return null ;
280292 }
0 commit comments