Ensure ace edit history is reset after initialisation

This commit is contained in:
Nick O'Leary 2015-05-07 21:12:46 +01:00
parent cf25b2866e
commit ce5c9da107
4 changed files with 13 additions and 9 deletions

View File

@ -916,13 +916,14 @@ RED.editor = (function() {
createEditor: function(options) { createEditor: function(options) {
var editor = ace.edit(options.id); var editor = ace.edit(options.id);
editor.setTheme("ace/theme/tomorrow"); editor.setTheme("ace/theme/tomorrow");
var session = editor.getSession();
if (options.mode) { if (options.mode) {
editor.getSession().setMode(options.mode); session.setMode(options.mode);
} }
if (options.foldStyle) { if (options.foldStyle) {
editor.getSession().setFoldStyle(options.foldStyle); session.setFoldStyle(options.foldStyle);
} else { } else {
editor.getSession().setFoldStyle('markbeginend'); session.setFoldStyle('markbeginend');
} }
if (options.options) { if (options.options) {
editor.setOptions(options.options); editor.setOptions(options.options);
@ -933,6 +934,9 @@ RED.editor = (function() {
}); });
} }
editor.$blockScrolling = Infinity; editor.$blockScrolling = Infinity;
if (options.value) {
session.setValue(options.value,-1);
}
return editor; return editor;
} }
} }

View File

@ -115,9 +115,9 @@
this.editor = RED.editor.createEditor({ this.editor = RED.editor.createEditor({
id: 'node-input-func-editor', id: 'node-input-func-editor',
mode: 'ace/mode/javascript' mode: 'ace/mode/javascript',
value: $("#node-input-func").val()
}); });
this.editor.setValue($("#node-input-func").val(),-1);
RED.library.create({ RED.library.create({
url:"functions", // where to get the data from url:"functions", // where to get the data from

View File

@ -98,9 +98,9 @@
}); });
this.editor = RED.editor.createEditor({ this.editor = RED.editor.createEditor({
id: 'node-input-template-editor', id: 'node-input-template-editor',
mode: 'ace/mode/html' mode: 'ace/mode/html',
value: $("#node-input-template").val()
}); });
this.editor.setValue($("#node-input-template").val(),-1);
RED.library.create({ RED.library.create({
url:"functions", // where to get the data from url:"functions", // where to get the data from
type:"function", // the type of object the library is for type:"function", // the type of object the library is for

View File

@ -86,9 +86,9 @@
}); });
this.editor = RED.editor.createEditor({ this.editor = RED.editor.createEditor({
id: 'node-input-info-editor', id: 'node-input-info-editor',
mode: 'ace/mode/markdown' mode: 'ace/mode/markdown',
value: $("#node-input-info").val()
}); });
this.editor.setValue($("#node-input-info").val(),-1);
this.editor.focus(); this.editor.focus();
}, },
oneditsave: function() { oneditsave: function() {