module.exports = function(RED) { var ui = require('../ui')(RED); function TemplateNode(config) { RED.nodes.createNode(this, config); var node = this; var group = RED.nodes.getNode(config.group); if (!group && config.templateScope !== 'global') { return; } var tab = null; if (config.templateScope !== 'global') { tab = RED.nodes.getNode(group.config.tab); if (!tab) { return; } if (!config.width) { config.width = group.config.width; } } var hei = Number(config.height|| 0); var previousTemplate = null var theme = ui.getTheme(); var colortheme = {}; for (var i in theme) { if (theme.hasOwnProperty(i)) { colortheme[i.replace(/-/g, "_")] = theme[i].value; } } var done = ui.add({ forwardInputMessages: config.fwdInMessages, storeFrontEndInputAsState: config.storeOutMessages, persistantFrontEndValue: config.resendOnRefresh, emitOnlyNewValues: false, node: node, tab: tab, group: group, control: { type: 'template', order: config.order, width: config.width || 6, height: hei, format: config.format, templateScope: config.templateScope, theme: colortheme, className: config.className || '', }, beforeEmit: function(msg) { var properties = Object.getOwnPropertyNames(msg).filter(function (p) { return p[0] != '_'; }); var clonedMsg = { templateScope: config.templateScope }; for (var i=0; i