ソースを参照

fix: setting and getting value of textarea when enable codemirror

wangweimin 4 年 前
コミット
af5aa956a6
1 ファイル変更7 行追加0 行削除
  1. 7 0
      webiojs/src/models/input/textarea.ts

+ 7 - 0
webiojs/src/models/input/textarea.ts

@@ -69,11 +69,18 @@ export class Textarea extends InputItem {
 
     update_input(spec: any) {
         let attributes = spec.attributes;
+        if (this.code_mirror && 'value' in attributes) {
+            this.code_mirror.setValue(attributes['value']);
+            delete attributes['value'];
+        }
 
         this.update_input_helper.call(this, -1, attributes);
     };
 
     get_value() {
+        if (this.code_mirror)
+            return this.code_mirror.getValue();
+
         return this.element.find('textarea').val();
     };