(node: LGraphNode)
| 7282 | } |
| 7283 | |
| 7284 | showShowNodePanel(node: LGraphNode): void { |
| 7285 | this.SELECTED_NODE = node |
| 7286 | this.closePanels() |
| 7287 | const ref_window = this.getCanvasWindow() |
| 7288 | const panel = this.createPanel(node.title || "", { |
| 7289 | closable: true, |
| 7290 | window: ref_window, |
| 7291 | onOpen: () => { |
| 7292 | this.NODEPANEL_IS_OPEN = true |
| 7293 | }, |
| 7294 | onClose: () => { |
| 7295 | this.NODEPANEL_IS_OPEN = false |
| 7296 | this.node_panel = null |
| 7297 | }, |
| 7298 | }) |
| 7299 | this.node_panel = panel |
| 7300 | panel.id = "node-panel" |
| 7301 | panel.node = node |
| 7302 | panel.classList.add("settings") |
| 7303 | |
| 7304 | const inner_refresh = () => { |
| 7305 | // clear |
| 7306 | panel.content.innerHTML = "" |
| 7307 | // @ts-expect-error ctor props |
| 7308 | panel.addHTML(`<span class='node_type'>${node.type}</span><span class='node_desc'>${node.constructor.desc || ""}</span><span class='separator'></span>`) |
| 7309 | |
| 7310 | panel.addHTML("<h3>Properties</h3>") |
| 7311 | |
| 7312 | const fUpdate = (name: string, value: string | number | boolean | object | undefined) => { |
| 7313 | if (!this.graph) throw new NullGraphError() |
| 7314 | this.graph.beforeChange(node) |
| 7315 | switch (name) { |
| 7316 | case "Title": |
| 7317 | if (typeof value !== "string") throw new TypeError("Attempting to set title to non-string value.") |
| 7318 | |
| 7319 | node.title = value |
| 7320 | break |
| 7321 | case "Mode": { |
| 7322 | if (typeof value !== "string") throw new TypeError("Attempting to set mode to non-string value.") |
| 7323 | |
| 7324 | const kV = Object.values(LiteGraph.NODE_MODES).indexOf(value) |
| 7325 | if (kV !== -1 && LiteGraph.NODE_MODES[kV]) { |
| 7326 | node.changeMode(kV) |
| 7327 | } else { |
| 7328 | console.warn(`unexpected mode: ${value}`) |
| 7329 | } |
| 7330 | break |
| 7331 | } |
| 7332 | case "Color": |
| 7333 | if (typeof value !== "string") throw new TypeError("Attempting to set colour to non-string value.") |
| 7334 | |
| 7335 | if (LGraphCanvas.node_colors[value]) { |
| 7336 | node.color = LGraphCanvas.node_colors[value].color |
| 7337 | node.bgcolor = LGraphCanvas.node_colors[value].bgcolor |
| 7338 | } else { |
| 7339 | console.warn(`unexpected color: ${value}`) |
| 7340 | } |
| 7341 | break |
no test coverage detected