node-red/packages/node_modules/@node-red/nodes/core/core/90-comment.html

75 lines
2.8 KiB
HTML

<script type="text/x-red" data-template-name="comment">
<div class="form-row">
<label for="node-input-name"><i class="fa fa-comment"></i> <span data-i18n="comment.label.title"></span></label>
<input type="text" id="node-input-name">
</div>
<div class="form-row" style="margin-bottom: 0px;">
<label for="node-input-info" style="width: 100% !important;"><i class="fa fa-comments"></i> <span data-i18n="comment.label.body"></span></label>
<input type="hidden" id="node-input-info" autofocus="autofocus">
</div>
<div class="form-row node-text-editor-row">
<div style="height: 250px; min-height:150px;" class="node-text-editor" id="node-input-info-editor"></div>
</div>
<div class="form-tips" data-i18n="[html]comment.tip"></div>
</script>
<script type="text/x-red" data-help-name="comment">
<p>A node you can use to add comments to your flows.</p>
<h3>Details</h3>
<p>The edit panel will accept Markdown syntax. The text will be rendered into
this information side panel.</p>
</script>
<script type="text/javascript">
RED.nodes.registerType('comment',{
category: 'function',
color:"#ffffff",
defaults: {
name: {value:""},
info: {value:""}
},
inputs:0,
outputs:0,
icon: "comment.png",
label: function() {
return this.name||this._("comment.comment");
},
labelStyle: function() {
return this.name?"node_label_italic":"";
},
info: function() {
return (this.name?"# "+this.name+"\n":"")+(this.info||"");
},
oneditprepare: function() {
var that = this;
this.editor = RED.editor.createEditor({
id: 'node-input-info-editor',
mode: 'ace/mode/markdown',
value: $("#node-input-info").val()
});
this.editor.focus();
},
oneditsave: function() {
$("#node-input-info").val(this.editor.getValue());
this.editor.destroy();
delete this.editor;
},
oneditcancel: function() {
this.editor.destroy();
delete this.editor;
},
oneditresize: function(size) {
var rows = $("#dialog-form>div:not(.node-text-editor-row)");
var height = $("#dialog-form").height();
for (var i=0; i<rows.size(); i++) {
height -= $(rows[i]).outerHeight(true);
}
var editorRow = $("#dialog-form>div.node-text-editor-row");
height -= (parseInt(editorRow.css("marginTop"))+parseInt(editorRow.css("marginBottom")));
$(".node-text-editor").css("height",height+"px");
this.editor.resize();
}
});
</script>