Skip to content

Commit a415f47

Browse files
committed
Update monaco notes as per discussion
1 parent 0b8bf72 commit a415f47

File tree

1 file changed

+57
-7
lines changed

1 file changed

+57
-7
lines changed

docs/api/ui/themes/index.md

Lines changed: 57 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -126,21 +126,20 @@ Node-RED
126126
### Theming the Monaco editor
127127
128128
As well as providing custom CSS and scripts, a theme plugin can also provide custom
129-
Monaco editor options, include what theme it should use.
129+
Monaco editor options including what theme it should use.
130130
131131
#### Setting the Monaco theme by name
132132
133-
Monaco comes with a number of built-in themes available. The full list is [here](https://github.com/node-red/node-red/tree/master/packages/node_modules/%40node-red/editor-client/src/vendor/monaco/dist/theme).
133+
Monaco comes with a number of built-in themes available. The full list is [here](https://github.com/node-red/node-red/tree/master/packages/node_modules/%40node-red/editor-client/src/vendor/monaco/dist/theme). Additional settings for Monaco options can be found [here](https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.istandaloneeditorconstructionoptions.html).
134134
135135
The name of the theme can be provided in the plugin settings:
136136
137137
```javascript
138-
RED.plugins.registerPlugin("midnight-red2", {
138+
RED.plugins.registerPlugin("midnight-red", {
139139
type: "node-red-theme",
140140
css: "style.css",
141141
monacoOptions: {
142142
theme: "vs-dark", // Monaco theme name
143-
fontLigatures: true,
144143
fontSize: 14,
145144
fontLigatures: true,
146145
fontFamily: "Cascadia Code, Fira Code, Consolas, 'Courier New', monospace",
@@ -151,10 +150,12 @@ RED.plugins.registerPlugin("midnight-red2", {
151150
152151
#### Setting a custom Monaco theme
153152
154-
Rather than identify a theme by name. the `monacoOptions.theme` setting can be
155-
used to provide a custom Monaco theme object:
153+
Rather than specifying a built-in theme by name, the `monacoOptions.theme` setting can
154+
be used to provide a custom Monaco theme object:
156155
157156
```javascript
157+
RED.plugins.registerPlugin("midnight-red", {
158+
monacoOptions: {
158159
theme: {
159160
"base": "vs-dark",
160161
"inherit": true,
@@ -187,7 +188,56 @@ used to provide a custom Monaco theme object:
187188
]
188189
}
189190
}
190-
})
191+
})
192+
```
193+
194+
195+
#### Setting a custom Monaco theme from a JSON file
196+
197+
Rather than hardcode the theme settings, you can store the Monaco theme JSON in a
198+
separate file and use `require` to import it:
199+
200+
```javascript
201+
RED.plugins.registerPlugin("midnight-red", {
202+
monacoOptions: {
203+
theme: require("midnight-red-monaco-theme.json"),
204+
}
205+
})
206+
```
207+
208+
`midnight-red-monaco-theme.json` file example:
209+
```json
210+
{
211+
"base": "vs-dark",
212+
"inherit": true,
213+
"colors": {
214+
"editor.foreground": "#CCC",
215+
"editor.background": "#434954",
216+
"editor.selectionBackground": "#80000080",
217+
"editor.lineHighlightBackground": "#80000040",
218+
"editorCursor.foreground": "#7070FF",
219+
"editorWhitespace.foreground": "#BFBFBF"
220+
},
221+
"rules": [
222+
{
223+
"background": "434954",
224+
},
225+
{
226+
"foreground": "aeaeae",
227+
"fontStyle": "italic",
228+
"token": "comment"
229+
},
230+
{
231+
"foreground": "d8fa3c",
232+
"token": "string"
233+
},
234+
{
235+
"foreground": "d8fa3c",
236+
"fontStyle": "bold",
237+
"token": "constant"
238+
},
239+
]
240+
}
191241
```
192242
193243
The specific details of how to create a Monaco theme is beyond the scope of our documentation.

0 commit comments

Comments
 (0)