aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazuki Yamaguchi <k@rhe.jp>2016-03-03 14:57:10 +0900
committerKazuki Yamaguchi <k@rhe.jp>2016-03-03 14:57:52 +0900
commitd907e2a69ec49c09083f57ff296bf92d84422ff0 (patch)
treedc0d082c75d285a477109574842eb0a85672c098
parentc0d976b8c852848be32209d9585f3d3a98405d23 (diff)
downloadpoe-d907e2a69ec49c09083f57ff296bf92d84422ff0.tar.gz
don't use CodeMirror.fromTextArea
-rw-r--r--frontend/app/editor.component.ts20
-rw-r--r--frontend/app/snippet-detail.component.ts2
2 files changed, 10 insertions, 12 deletions
diff --git a/frontend/app/editor.component.ts b/frontend/app/editor.component.ts
index 162c1dc..09a5c96 100644
--- a/frontend/app/editor.component.ts
+++ b/frontend/app/editor.component.ts
@@ -13,9 +13,7 @@ import "codemirror/addon/edit/matchbrackets";
@Component({
selector: "editor",
- template: `
- <textarea></textarea>
- `,
+ template: "",
})
export class EditorComponent implements OnInit {
private _mode: string;
@@ -37,16 +35,16 @@ export class EditorComponent implements OnInit {
@Output() valueChange = new EventEmitter();
@Output() onSubmit = new EventEmitter();
- private cm: CodeMirror.EditorFromTextArea;
+ private cm: CodeMirror.Editor;
constructor(
- private elementRef: ElementRef) { }
+ private elementRef: ElementRef) {
+ }
ngOnInit() {
if (!this.cm) {
const elm = this.elementRef.nativeElement;
- const origTextarea = <HTMLTextAreaElement>elm.querySelector("textarea");
- this.cm = CodeMirror.fromTextArea(origTextarea, {
+ this.cm = CodeMirror(elm, {
mode: this._mode,
lineNumbers: true,
value: this._value,
@@ -55,10 +53,10 @@ export class EditorComponent implements OnInit {
}
});
this.cm.on("change", cm => {
- this.cm.save();
- if (this._value !== origTextarea.value) {
- this._value = origTextarea.value;
- this.valueChange.emit(this._value);
+ const val = cm.getDoc().getValue();
+ if (this._value !== val) {
+ this._value = val;
+ this.valueChange.emit(val);
}
});
}
diff --git a/frontend/app/snippet-detail.component.ts b/frontend/app/snippet-detail.component.ts
index 70e0308..60b5694 100644
--- a/frontend/app/snippet-detail.component.ts
+++ b/frontend/app/snippet-detail.component.ts
@@ -39,7 +39,7 @@ export class SnippetDetailComponent implements OnInit {
// Result に移動したいんだけどどうすればいいんだろ
formatted_output(r: Result): string {
if (this.isRunning(r)) return "Running...";
- if (r._) return r._;
+ if (r._) return r._; // うーーーーーーーーーーん💩
let haveNewLine = false;
let str = r.output.reduce((str, pair) => {
let fd = pair[0];