mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
Add RED.editor.createEditor utility function
This commit is contained in:
@@ -100,32 +100,23 @@
|
||||
$( "#dialog" ).off("dialogresize",functionDialogResize);
|
||||
});
|
||||
|
||||
ace.require("ace/ext/language_tools");
|
||||
that.editor = ace.edit('node-input-func-editor');
|
||||
that.editor.setText = that.editor.setValue; // alias to make library work :-)
|
||||
that.editor.getText = that.editor.getValue; // alias to make library work
|
||||
//that.editor.setTheme("ace/theme/solarized_light");
|
||||
//that.editor.setTheme("ace/theme/crimson_editor");
|
||||
//that.editor.setTheme("ace/theme/chrome");
|
||||
that.editor.setTheme("ace/theme/tomorrow");
|
||||
that.editor.getSession().setMode("ace/mode/javascript");
|
||||
that.editor.getSession().setFoldStyle("markbeginend");
|
||||
that.editor.setOptions({enableBasicAutocompletion:true, enableSnippets:true});
|
||||
that.editor.$blockScrolling = Infinity;
|
||||
that.editor.setValue($("#node-input-func").val());
|
||||
that.editor.gotoLine(1,1);
|
||||
document.getElementById('node-input-func-editor').style.fontSize='17px';
|
||||
this.editor = RED.editor.createEditor({
|
||||
id: 'node-input-func-editor',
|
||||
mode: 'ace/mode/javascript'
|
||||
});
|
||||
this.editor.setValue($("#node-input-func").val(),-1);
|
||||
|
||||
RED.library.create({
|
||||
url:"functions", // where to get the data from
|
||||
type:"function", // the type of object the library is for
|
||||
editor:that.editor, // the field name the main text body goes to
|
||||
editor:this.editor, // the field name the main text body goes to
|
||||
mode:"ace/mode/javascript",
|
||||
fields:['name','outputs']
|
||||
});
|
||||
$("#node-input-name").focus();
|
||||
this.editor.focus();
|
||||
},
|
||||
oneditsave: function() {
|
||||
var annot = this.editor.getSession().getAnnotations();
|
||||
console.log(this);
|
||||
this.valid = true;
|
||||
for (var k=0; k < annot.length; k++) {
|
||||
//console.log(annot[k].type,":",annot[k].text, "on line", annot[k].row);
|
||||
|
@@ -22,7 +22,7 @@
|
||||
<div class="form-row" style="margin-bottom: 0px;">
|
||||
<label for="node-input-template"><i class="fa fa-file-code-o"></i> Template</label>
|
||||
<input type="hidden" id="node-input-template" autofocus="autofocus">
|
||||
<select id="node-input-mark" style="width:110px; float:right;">
|
||||
<select id="node-input-format" style=" font-size: 0.8em; margin-bottom: 3px; width:110px; float:right;">
|
||||
<option value="handlebars">mustache</option>
|
||||
<option value="html">HTML</option>
|
||||
<option value="json">JSON</option>
|
||||
@@ -61,7 +61,7 @@
|
||||
defaults: {
|
||||
name: {value:""},
|
||||
field: {value:"payload"},
|
||||
mark: {value:"handlebars"},
|
||||
format: {value:"handlebars"},
|
||||
template: {value:"This is the payload: {{payload}} !"},
|
||||
},
|
||||
inputs:1,
|
||||
@@ -96,30 +96,21 @@
|
||||
var height = $( "#dialog" ).dialog('option','height');
|
||||
$( "#dialog" ).off("dialogresize",templateDialogResize);
|
||||
});
|
||||
ace.require("ace/ext/language_tools");
|
||||
that.editor = ace.edit('node-input-template-editor');
|
||||
that.editor.setText = that.editor.setValue; // alias to make library work :-)
|
||||
that.editor.getText = that.editor.getValue; // alias to make library work
|
||||
//that.editor.setTheme("ace/theme/solarized_light");
|
||||
//that.editor.setTheme("ace/theme/crimson_editor");
|
||||
//that.editor.setTheme("ace/theme/chrome");
|
||||
that.editor.setTheme("ace/theme/tomorrow");
|
||||
that.editor.getSession().setMode("ace/mode/html");
|
||||
that.editor.getSession().setFoldStyle("markbeginend");
|
||||
that.editor.setOptions({enableBasicAutocompletion:true, enableSnippets:true});
|
||||
that.editor.$blockScrolling = Infinity;
|
||||
that.editor.setValue($("#node-input-template").val());
|
||||
that.editor.gotoLine(1);
|
||||
document.getElementById('node-input-template-editor').style.fontSize='17px';
|
||||
this.editor = RED.editor.createEditor({
|
||||
id: 'node-input-template-editor',
|
||||
mode: 'ace/mode/html'
|
||||
});
|
||||
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
|
||||
editor:that.editor, // the field name the main text body goes to
|
||||
fields:['name','outputs']
|
||||
});
|
||||
$("#node-input-name").focus();
|
||||
$("#node-input-mark").change(function() {
|
||||
var mod = "ace/mode/"+$("#node-input-mark").val();
|
||||
this.editor.focus();
|
||||
|
||||
$("#node-input-format").change(function() {
|
||||
var mod = "ace/mode/"+$("#node-input-format").val();
|
||||
that.editor.getSession().setMode({
|
||||
path: mod,
|
||||
v: Date.now()
|
||||
|
@@ -84,16 +84,12 @@
|
||||
var height = $( "#dialog" ).dialog('option','height');
|
||||
$( "#dialog" ).off("dialogresize",functionDialogResize);
|
||||
});
|
||||
ace.require("ace/ext/language_tools");
|
||||
that.editor = ace.edit('node-input-info-editor');
|
||||
that.editor.setTheme("ace/theme/chrome");
|
||||
that.editor.getSession().setMode("ace/mode/markdown");
|
||||
that.editor.getSession().setFoldStyle("markbeginend");
|
||||
that.editor.setOptions({enableBasicAutocompletion:true, enableSnippets:true});
|
||||
that.editor.$blockScrolling = Infinity;
|
||||
that.editor.setValue($("#node-input-info").val());
|
||||
that.editor.gotoLine(1);
|
||||
document.getElementById('node-input-info-editor').style.fontSize='17px';
|
||||
this.editor = RED.editor.createEditor({
|
||||
id: 'node-input-info-editor',
|
||||
mode: 'ace/mode/markdown'
|
||||
});
|
||||
this.editor.setValue($("#node-input-info").val(),-1);
|
||||
this.editor.focus();
|
||||
},
|
||||
oneditsave: function() {
|
||||
$("#node-input-info").val(this.editor.getValue());
|
||||
|
Reference in New Issue
Block a user