Merge branch 'pynej-view-save-restore-cursor' into dev-v7

This commit is contained in:
Shannon
2016-03-17 11:29:29 +01:00
2 changed files with 13 additions and 1 deletions

View File

@@ -35,9 +35,18 @@ Umbraco.Sys.registerNamespace("Umbraco.Controls.CodeEditor");
this._control.val(code);
}
else {
//this is a wrapper for CodeMirror
//this is a wrapper for CodeMirror
this._editor.focus();
var codeChanged = this._editor.getValue() != code;
var cursor = this._editor.doc.getCursor();
this._editor.setValue(code);
// Restore cursor position if the server saved code matches.
if (!codeChanged)
this._editor.setCursor(cursor);
this._editor.focus();
}
},

View File

@@ -174,6 +174,9 @@
}
if (args.contents) {
UmbEditor.SetCode(args.contents);
} else if (!this.IsSimpleEditor) {
// Restore focuse to text region. SetCode also does this.
UmbEditor._editor.focus();
}
UmbClientMgr.mainTree().setActiveTreeType(this._opts.currentTreeType);