Edit JSON node settings in a dialog from a one-line preview

A free setting typed json and a declared object or array setting (a Switch
node's rules, HTTP headers) show one line of their value; clicking opens a
Monaco JSON editor in a dialog that saves only once the text parses.
Declared object settings were not shown at all before. Escape in a dialog
opened from a side panel no longer closes the panel too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013GAeg4Jo6xjZzjwy9QDWMQ
This commit is contained in:
2026-10-05 23:49:42 +02:00
co-authored by Claude Opus 5.5
parent 5b67dab415
commit 2c1ad395de
6 changed files with 192 additions and 14 deletions
+15 -4
View File
@@ -1,15 +1,18 @@
/**
* Monaco, self-hosted and themed from the design tokens.
*
* Only the base editor and the Python grammar are pulled in; the other seventy
* languages would triple the chunk for nothing. This module is imported by
* NodeEditor alone, which the panel loads lazily.
* Only the base editor, the Python grammar and JSON (for settings holding JSON)
* are pulled in; the other seventy languages would triple the chunk for
* nothing. This module is imported by NodeEditor alone, which the panel loads
* lazily.
*/
import { loader } from "@monaco-editor/react"
import * as monaco from "monaco-editor/editor/editor.api"
// Only Python registers itself; `basic-languages` would pull in all seventy.
import "monaco-editor/languages/definitions/python/register"
import "monaco-editor/languages/features/json/register"
import editorWorker from "monaco-editor/editor/editor.worker?worker"
import jsonWorker from "monaco-editor/languages/features/json/json.worker?worker"
let configured = false
@@ -36,6 +39,11 @@ function defineThemes() {
{ token: "string", foreground: success.slice(1) },
{ token: "comment", foreground: muted.slice(1), fontStyle: "italic" },
{ token: "number", foreground: foreground.slice(1) },
// JSON names its tokens more specifically, so the base theme's
// colours would win over the generic ones above.
{ token: "string.key.json", foreground: foreground.slice(1) },
{ token: "string.value.json", foreground: success.slice(1) },
{ token: "keyword.json", foreground: primary.slice(1) },
],
colors: {
"editor.background": background,
@@ -58,7 +66,10 @@ export function setupMonaco(): typeof monaco {
configured = true
// Self-hosted: no CDN fetch, so the editor works on a LAN install.
self.MonacoEnvironment = { getWorker: () => new editorWorker() }
self.MonacoEnvironment = {
getWorker: (_, label) =>
label === "json" ? new jsonWorker() : new editorWorker(),
}
loader.config({ monaco })
defineThemes()
return monaco