You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -16,16 +16,26 @@ The value of the property can be either a string or a function.
16
16
17
17
If the value is a string, that is used as the icon.
18
18
19
-
If the value is a function, it will get evaluated when the node is first loaded, or after it has been edited. The function is expected to return the value to use as the icon.
20
-
The function will be called both for nodes in the workspace, where `this` references a node instance, as well as
21
-
for the node's entry in the palette. In this latter case, `this` will not refer to a particular node instance and
22
-
the function *must* return a valid value.
19
+
If the value is a function, it will get evaluated when the node is first loaded,
20
+
or after it has been edited. The function is expected to return the value to use
21
+
as the icon.
22
+
23
+
The function will be called both for nodes in the workspace, where `this` references
24
+
a node instance, as well as for the node's entry in the palette. In this latter case,
25
+
`this` will not refer to a particular node instance and the function *must* return
26
+
a valid value.
27
+
28
+
{% highlight javascript %}
29
+
...
30
+
icon: "file.png",
31
+
...
32
+
{% endhighlight %}
23
33
24
-
...
25
-
icon: "file.png",
26
-
...
34
+
The icon can be either:
27
35
28
-
There are some stock icons available for use, or the node can provide its own.
36
+
- the name of a stock icon provided by Node-RED,
37
+
- the name of a custom icon provided by the module,
38
+
- a Font Awesome 4.7 icon
29
39
30
40
#### Stock icons
31
41
@@ -48,24 +58,28 @@ There are some stock icons available for use, or the node can provide its own.
To specify a FA icon, the property should take the form:
96
+
97
+
{% highlight javascript %}
98
+
...
99
+
icon: "font-awesome/fa-automobile",
100
+
...
101
+
{% endhighlight %}
102
+
103
+
#### User defined icon
84
104
85
-
The name of installed modules that contain one or more icon files or `node-red` for core nodes are shown on the left. The name of icon files in the module are shown on the right.
105
+
Individual node icons can be customised by the user within the editor on the 'appearance'
106
+
tab of the node's edit dialog.
86
107
87
-
**Note**: If a node has `icon` property by default, the node's icon cannot be overwritten (e.g. ui_button node of node-red-dashboard).
108
+
**Note**: If a node has an `icon` property in its `defaults` object, its icon
109
+
cannot be customised. For example, the `ui_button` node of `node-red-dashboard`.
88
110
89
111
### Background Colour
90
112
@@ -227,27 +249,31 @@ align: 'right',
227
249
228
250
#### Port labels
229
251
230
-
From Node-RED version **0.17** onwards nodes can optionally provide labels on their input
231
-
and output ports, that can be seen by hovering the mouse over the port.
252
+
Nodes can provide labels on their input and output ports that can be seen by
Copy file name to clipboardExpand all lines: docs/creating-nodes/first-node.md
+18-20Lines changed: 18 additions & 20 deletions
Original file line number
Diff line number
Diff line change
@@ -8,9 +8,9 @@ slug: first node
8
8
Nodes get created when a flow is deployed, they may send and receive some messages
9
9
whilst the flow is running and they get deleted when the next flow is deployed.
10
10
11
-
They typically consist of a pair of files; a JavaScript file that defines what the
12
-
node does, and an html file that defines the node's properties, edit dialog and
13
-
help text.
11
+
They consist of a pair of files:
12
+
- a JavaScript file that defines what the node does,
13
+
- an html file that defines the node's properties, edit dialog and help text.
14
14
15
15
A `package.json` file is used to package it all together as an npm module.
16
16
@@ -25,7 +25,8 @@ A `package.json` file is used to package it all together as an npm module.
25
25
This example will show how to create a node that converts message payloads to
26
26
all lower-case characters.
27
27
28
-
Ensure you have the recommended LTS version of Node.js installed on your system. As of this writing this is version **LTS 8.x** which includes npm version 5.x.
28
+
Ensure you have the current LTS version of Node.js installed on your system. At
29
+
the time of writing this is 10.x.
29
30
30
31
Create a directory where you will develop your code. Within that directory, create the following files:
31
32
@@ -152,44 +153,41 @@ For more information about the editor part of the node, see [here](node-html).
152
153
153
154
Once you have created a basic node module as described above, you can install it into your Node-RED runtime.
154
155
155
-
To test a node module locally using npm 5.x, the [`npm install <folder>`](https://docs.npmjs.com/cli/install) command can be used. This allows you
156
-
to develop the node in a local directory and have it linked into a local node-red install during development.
156
+
To test a node module locally the [`npm install <folder>`](https://docs.npmjs.com/cli/install)
157
+
command can be used. This allows you to develop the node in a local directory and
158
+
have it linked into a local node-red install during development.
157
159
158
160
In your node-red user directory, typically `~/.node-red`, run:
159
161
160
162
npm install <location of node module>
161
163
162
-
For example, on Mac OS or linux, if your node is located at `~/dev/node-red-contrib-example-lower-case` you would type the following:
164
+
For example, on Mac OS or Linux, if your node is located at `~/dev/node-red-contrib-example-lower-case` you would do the following:
This creates a symbolic link to your node module project directory in `~/.node-red/node_modules` so that Node-RED will discover the node when it starts. Any changes to the node's file can be picked up by simply restarting Node-RED. On Windows, again, using npm 5.x or greater:
This creates a symbolic link to your node module project directory in `~/.node-red/node_modules` so that Node-RED will discover the node when it starts. Any changes to the node's file can be picked up by simply restarting Node-RED. On Windows, again, using npm 5.x or greater:
181
175
182
176
<divclass="doc-callout">
183
-
<em>Note</em> : npm 5 will add your module as a dependency in the <code>package.json</code> file located in your user directory. If you want to prevent this, use the npm <code>--no-save</code> option.
177
+
<em>Note</em> : <code>npm</code> will automatically add an entry for your module in the
178
+
<code>package.json</code> file located in your user directory. If you don't want
179
+
it to do this, use the <code>--no-save</code> option to the <code>npm install</code>
180
+
command.
184
181
</div>
185
182
186
183
### Unit Testing
187
184
188
-
To support unit testing, an npm module called [`node-red-node-test-helper`](https://www.npmjs.com/package/node-red-node-test-helper) can be used. The test-helper is a framework built on the Node-RED runtime to make it easier to test nodes.
185
+
To support unit testing, an npm module called [`node-red-node-test-helper`](https://www.npmjs.com/package/node-red-node-test-helper) can be used. The test-helper is a framework
186
+
built on the Node-RED runtime to make it easier to test nodes.
189
187
190
188
Using this framework, you can create test flows, and then assert that your node properties and output is working as expected. For example, to add a unit test to the lower-case node you can add a `test` folder to your node module package containing a file called `_spec.js`
0 commit comments