Просмотр исходного кода

GC-363: (Editor) コメント送信時、テキストをリセット

Yuki Takei 7 лет назад
Родитель
Сommit
0094494d2d

+ 2 - 0
resource/js/components/PageComment/CommentForm.js

@@ -87,6 +87,8 @@ export default class CommentForm extends React.Component {
           html: '',
           key: 1,
         });
+        // reset value
+        this.refs.editor.setValue('');
       });
   }
 

+ 6 - 0
resource/js/components/PageEditor/AbstractEditor.js

@@ -21,6 +21,12 @@ export default class AbstractEditor extends React.Component {
   forceToFocus() {
   }
 
+  /**
+   * set new value
+   */
+  setValue(newValue) {
+  }
+
   /**
    * set caret position of codemirror
    * @param {string} number

+ 8 - 0
resource/js/components/PageEditor/CodeMirrorEditor.js

@@ -129,6 +129,14 @@ export default class CodeMirrorEditor extends AbstractEditor {
     }, 100);
   }
 
+  /**
+   * @inheritDoc
+   */
+  setValue(newValue) {
+    this.setState({ value: newValue });
+    this.getCodeMirror().getDoc().setValue(newValue);
+  }
+
   /**
    * @inheritDoc
    */

+ 7 - 0
resource/js/components/PageEditor/Editor.js

@@ -50,6 +50,13 @@ export default class Editor extends AbstractEditor {
     this.getEditorSubstance().forceToFocus();
   }
 
+  /**
+   * @inheritDoc
+   */
+  setValue(newValue) {
+    this.getEditorSubstance().setValue(newValue);
+  }
+
   /**
    * @inheritDoc
    */

+ 8 - 0
resource/js/components/PageEditor/TextAreaEditor.js

@@ -57,6 +57,14 @@ export default class TextAreaEditor extends AbstractEditor {
     }, 150);
   }
 
+  /**
+   * @inheritDoc
+   */
+  setValue(newValue) {
+    this.setState({ value: newValue });
+    this.textarea.value = newValue;
+  }
+
   /**
    * @inheritDoc
    */