From ce5c9da1075a8a82eea3238a094b2a354b603e0f Mon Sep 17 00:00:00 2001 From: Nick O'Leary Date: Thu, 7 May 2015 21:12:46 +0100 Subject: [PATCH] Ensure ace edit history is reset after initialisation --- editor/js/ui/editor.js | 10 +++++++--- nodes/core/core/80-function.html | 4 ++-- nodes/core/core/80-template.html | 4 ++-- nodes/core/core/90-comment.html | 4 ++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/editor/js/ui/editor.js b/editor/js/ui/editor.js index 38d753e7b..316cddfab 100644 --- a/editor/js/ui/editor.js +++ b/editor/js/ui/editor.js @@ -916,13 +916,14 @@ RED.editor = (function() { createEditor: function(options) { var editor = ace.edit(options.id); editor.setTheme("ace/theme/tomorrow"); + var session = editor.getSession(); if (options.mode) { - editor.getSession().setMode(options.mode); + session.setMode(options.mode); } if (options.foldStyle) { - editor.getSession().setFoldStyle(options.foldStyle); + session.setFoldStyle(options.foldStyle); } else { - editor.getSession().setFoldStyle('markbeginend'); + session.setFoldStyle('markbeginend'); } if (options.options) { editor.setOptions(options.options); @@ -933,6 +934,9 @@ RED.editor = (function() { }); } editor.$blockScrolling = Infinity; + if (options.value) { + session.setValue(options.value,-1); + } return editor; } } diff --git a/nodes/core/core/80-function.html b/nodes/core/core/80-function.html index 70c4290e8..5c1cc4df3 100644 --- a/nodes/core/core/80-function.html +++ b/nodes/core/core/80-function.html @@ -115,9 +115,9 @@ this.editor = RED.editor.createEditor({ 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({ url:"functions", // where to get the data from diff --git a/nodes/core/core/80-template.html b/nodes/core/core/80-template.html index cdf6ea495..06c817725 100644 --- a/nodes/core/core/80-template.html +++ b/nodes/core/core/80-template.html @@ -98,9 +98,9 @@ }); this.editor = RED.editor.createEditor({ 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({ url:"functions", // where to get the data from type:"function", // the type of object the library is for diff --git a/nodes/core/core/90-comment.html b/nodes/core/core/90-comment.html index 5bd3dd6df..f8c08fdd1 100644 --- a/nodes/core/core/90-comment.html +++ b/nodes/core/core/90-comment.html @@ -86,9 +86,9 @@ }); this.editor = RED.editor.createEditor({ 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(); }, oneditsave: function() {