Browse Source

cancel btn now properly displays old content value

Skylsmoi 5 years ago
parent
commit
09b99a0ccb
1 changed files with 12 additions and 2 deletions
  1. 12 2
      src/container/HtmlDocument.jsx

+ 12 - 2
src/container/HtmlDocument.jsx View File

@@ -31,6 +31,7 @@ class HtmlDocument extends React.Component {
31 31
       config: props.data ? props.data.config : debug.config,
32 32
       loggedUser: props.data ? props.data.loggedUser : debug.loggedUser,
33 33
       content: props.data ? props.data.content : debug.content,
34
+      rawContentBeforeEdit: '',
34 35
       timeline: props.data ? [] : [], // debug.timeline,
35 36
       newComment: '',
36 37
       timelineWysiwyg: false,
@@ -156,11 +157,20 @@ class HtmlDocument extends React.Component {
156 157
       })
157 158
   }
158 159
 
159
-  handleClickNewVersion = () => this.setState({ mode: MODE.EDIT })
160
+  handleClickNewVersion = () => this.setState(prev => ({
161
+    rawContentBeforeEdit: prev.content.raw_content,
162
+    mode: MODE.EDIT
163
+  }))
160 164
 
161 165
   handleCloseNewVersion = () => {
162 166
     tinymce.remove('#wysiwygNewVersion')
163
-    this.setState({ mode: MODE.VIEW })
167
+    this.setState(prev => ({
168
+      content: {
169
+        ...prev.content,
170
+        raw_content: prev.rawContentBeforeEdit
171
+      },
172
+      mode: MODE.VIEW
173
+    }))
164 174
   }
165 175
 
166 176
   handleSaveHtmlDocument = async () => {