Explorar o código

improve reseting unsaved warning

Yuki Takei %!s(int64=3) %!d(string=hai) anos
pai
achega
28709dbdbc
Modificáronse 1 ficheiros con 8 adicións e 0 borrados
  1. 8 0
      packages/app/src/components/PageEditor.tsx

+ 8 - 0
packages/app/src/components/PageEditor.tsx

@@ -324,6 +324,14 @@ const PageEditor = React.memo((props: Props): JSX.Element => {
   const scrollEditorByPreviewScrollWithThrottle = useMemo(() => throttle(20, scrollEditorByPreviewScroll), [scrollEditorByPreviewScroll]);
 
 
+  // initialize
+  useEffect(() => {
+    if (initialValue != null) {
+      setMarkdown(initialValue);
+      mutateIsEnabledUnsavedWarning(false);
+    }
+  }, [initialValue, mutateIsEnabledUnsavedWarning]);
+
   // initial caret line
   useEffect(() => {
     if (editorRef.current != null) {