From 0c4197bae37bd3719a5990fa2642364f0dadcee5 Mon Sep 17 00:00:00 2001 From: antianqi <75944423+antianqi@users.noreply.github.com> Date: Thu, 26 Nov 2026 15:12:17 +0800 Subject: [PATCH] =?UTF-8?q?feat(ai-node-canvas):=20=E6=B2=89=E6=B5=B8?= =?UTF-8?q?=E6=A8=A1=E5=BC=8F=EF=BC=9A=E5=B7=A5=E5=85=B7=E6=A0=8F=E6=94=B6?= =?UTF-8?q?=E8=B5=B7=EF=BC=8C=E7=94=BB=E5=B8=83=E9=93=BA=E6=BB=A1=EF=BC=88?= =?UTF-8?q?F11=20/=20Ctrl+Shift+F=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在画布上要干活的时候,工具栏和那一排按钮都是碍事的。新增一个沉浸模式: 工具栏整个收起,画布铺满整个窗口,右上角只留一个「退出沉浸(Esc)」。 快捷键的读法收在一个纯函数里(miniapp/client/immersive.mjs):F11 和 Ctrl+Shift+F 是同一个动作;Esc 先关别的浮层,都关完了才退出沉浸。 宿主允许把窗口交给页面时,模式再叠一层真的全屏;不允许时页面内的沉浸 照常工作,工具栏该收还是收。 单测全量 336 条通过(此前 335 条,新增一条顶层测试:快捷键只有一处读法)。 变异自检三处都变红:F11 改掉、第二组键丢掉 Shift、Escape 不看当前状态。 真机用无头 Chrome 点过一遍:F11 进、Esc 出、Ctrl+Shift+F 进、Esc 出,四步都对。 没有发生成请求。 --- .../.minimax-plugin/plugin.json | 2 +- plugins/antianqi/ai-node-canvas/README.md | 10 ++- .../antianqi/ai-node-canvas/README.zh-CN.md | 9 ++- .../ai-node-canvas/miniapp/client/app.js | 67 +++++++++++++++++++ .../miniapp/client/immersive.mjs | 32 +++++++++ .../ai-node-canvas/miniapp/client/index.html | 7 +- .../ai-node-canvas/miniapp/client/styles.css | 31 +++++++++ .../ai-node-canvas/miniapp/node/server.mjs | 1 + plugins/antianqi/ai-node-canvas/package.json | 2 +- .../ai-node-canvas/tests/smoke.test.mjs | 18 +++++ 10 files changed, 172 insertions(+), 7 deletions(-) create mode 100644 plugins/antianqi/ai-node-canvas/miniapp/client/immersive.mjs diff --git a/plugins/antianqi/ai-node-canvas/.minimax-plugin/plugin.json b/plugins/antianqi/ai-node-canvas/.minimax-plugin/plugin.json index c6222a7a..3343fa77 100644 --- a/plugins/antianqi/ai-node-canvas/.minimax-plugin/plugin.json +++ b/plugins/antianqi/ai-node-canvas/.minimax-plugin/plugin.json @@ -2,7 +2,7 @@ "schemaVersion": 1, "name": "ai-node-canvas", "displayName": "节点画布", - "version": "1.22.10", + "version": "1.22.11", "description": "无限画布节点编排:把 MiniMax 模型生成的文本、图片、视频串成工作流,连线即数据流,上游产物可直接被下游引用。", "author": "antianqi", "icon": "icon.png", diff --git a/plugins/antianqi/ai-node-canvas/README.md b/plugins/antianqi/ai-node-canvas/README.md index 732577d0..dc764ded 100644 --- a/plugins/antianqi/ai-node-canvas/README.md +++ b/plugins/antianqi/ai-node-canvas/README.md @@ -5,7 +5,7 @@ English | [简体中文](README.zh-CN.md) An infinite-canvas node graph for MiniMax Code, modelled on the canvas of `work.batvid.com`. -Author: [antianqi](https://github.com/antianqi) · Version: `1.22.10` +Author: [antianqi](https://github.com/antianqi) · Version: `1.22.11`  @@ -709,6 +709,11 @@ Agent to open "节点画布" — or open it from the plugin list. 5. Drag the circle on the right edge of a node onto another node to connect them. +**Immersive mode**: `F11` or `Ctrl+Shift+F` folds the toolbar away and lets +the canvas take the whole surface, with one `Exit immersive (Esc)` chip in the +corner. When the Host hands the window to the page the mode is a real +fullscreen; when it refuses, the page mode still works. + ### Keyboard | Keys | Action | @@ -718,7 +723,8 @@ Agent to open "节点画布" — or open it from the plugin list. | `Delete` / `Backspace` | Delete the selection | | `Shift`+drag | Marquee select | | `Shift`+click | Toggle one node in the selection | -| `Escape` | Close mention menu → panel → menu → deselect | +| `F11` / `Ctrl+Shift+F` | Immersive mode: the toolbar folds away, the canvas takes the surface | +| `Escape` | Close mention menu → panel → menu → leave immersive → deselect | ## Tested environment diff --git a/plugins/antianqi/ai-node-canvas/README.zh-CN.md b/plugins/antianqi/ai-node-canvas/README.zh-CN.md index 9a5d3fa8..ee580e01 100644 --- a/plugins/antianqi/ai-node-canvas/README.zh-CN.md +++ b/plugins/antianqi/ai-node-canvas/README.zh-CN.md @@ -5,7 +5,7 @@ MiniMax Code 里的无限画布节点图。每个节点是一次模型运行,每条连线是一条数据通路—— 把文本节点连到图片节点,上游文本会自动注入下游提示词。 -作者:[antianqi](https://github.com/antianqi) · 版本:`1.22.10` +作者:[antianqi](https://github.com/antianqi) · 版本:`1.22.11`  @@ -434,6 +434,10 @@ provider 有**几种不同的请求**把素材变成视频,不是同一个请 5. 点「生成」,上游产物自动流进下游提示词,结果落到出图的那张卡上。 6. Agent 需要工具权限时,在节点上回应审批卡。 +**沉浸模式**:`F11` 或 `Ctrl+Shift+F` 让工具栏收起、画布铺满整个窗口,右上角 +只留一个「退出沉浸(Esc)」。宿主允许把窗口交给页面时,它就是真的全屏;宿主 +不允许时,页面内的沉浸照常工作。 + ### 快捷键 | 按键 | 作用 | @@ -443,7 +447,8 @@ provider 有**几种不同的请求**把素材变成视频,不是同一个请 | `Delete` / `Backspace` | 删除选中 | | `Shift`+拖拽 | 框选 | | `Shift`+点击 | 增减单个节点选择 | -| `Escape` | 依次关闭:引用菜单 → 面板 → 菜单 → 节点面板 → 取消选择 | +| `F11` / `Ctrl+Shift+F` | 沉浸模式:工具栏收起,画布铺满 | +| `Escape` | 依次关闭:引用菜单 → 面板 → 菜单 → 节点面板 → 退出沉浸 → 取消选择 | ## Test 环境 diff --git a/plugins/antianqi/ai-node-canvas/miniapp/client/app.js b/plugins/antianqi/ai-node-canvas/miniapp/client/app.js index 651a54c0..4e61022f 100644 --- a/plugins/antianqi/ai-node-canvas/miniapp/client/app.js +++ b/plugins/antianqi/ai-node-canvas/miniapp/client/app.js @@ -19,6 +19,7 @@ import { wirePlayhead } from './clip-playhead.mjs'; import { frameStops, paintFilmstrip, paintWaveform, redrawStrips } from './strip.mjs'; import { isBusyRefusal, panelClosed, panelIsShown, panelTasks, runIsGone, taskIsExpired, theRunThatIsGoing, theRunToWaitFor, waitForTheRun, withDeadline } from './run-watch.mjs'; import { panelTitleRow } from './task-panel.mjs'; +import { immersiveAction } from './immersive.mjs'; import { applyAction, applyModel, canvasTitleAfterTemplate, inheritedTextFor, legacyProductNodes, lineKind, linesDroppedByMode, materializeResults, outputForRun, pendingAncestors as pendingAncestorsIn, planIncoming, planPort, promptTemplateFor, readTemplateFile, runSpecFor, syncMentions, templateFile, templateFromCanvas } from './actions.mjs'; (() => { @@ -129,6 +130,8 @@ import { applyAction, applyModel, canvasTitleAfterTemplate, inheritedTextFor, le tool: null, // { nodeId, tool, params } picker: null, // the node picker that opens on an empty drop suppressClick: false, + // The immersive mode: the chrome goes away and the canvas takes the surface. + immersive: false, }; const dom = {}; @@ -4441,6 +4444,12 @@ import { applyAction, applyModel, canvasTitleAfterTemplate, inheritedTextFor, le dom.deleteButton.disabled = !state.canvas.id; dom.gridButton.textContent = state.canvas.backgroundMode === 'dots' ? '网格:圆点' : '网格:线条'; dom.themeButton.textContent = `主题:${THEME_LABEL[state.theme] ?? THEME_LABEL.system}`; + // The button says which way the mode goes, so the user never has to + // remember whether it is on. + dom.immersiveButton.textContent = state.immersive ? '退出沉浸' : '沉浸'; + dom.immersiveButton.title = state.immersive + ? '退出沉浸模式(Esc)' + : '沉浸模式:工具栏收起,画布铺满(F11 / Ctrl+Shift+F)'; updateHistoryBtns(); } @@ -6594,6 +6603,15 @@ import { applyAction, applyModel, canvasTitleAfterTemplate, inheritedTextFor, le }); window.addEventListener('keydown', (event) => { + // The immersive mode is a mode and not an overlay, so its key works + // whatever else is open. One rule reads the key; the page does what + // the rule means. + const immersive = immersiveAction(event, state); + if (immersive === 'toggle') { + event.preventDefault(); + setImmersive(!state.immersive); + return; + } if (event.key === 'Escape') { // The question the page asks is closed by Escape, like any other. if (dom.confirmDialog && !dom.confirmDialog.hidden) { @@ -6630,6 +6648,11 @@ import { applyAction, applyModel, canvasTitleAfterTemplate, inheritedTextFor, le render(); return; } + // Nothing else was open: what is left to close is the mode itself. + if (immersive === 'exit') { + setImmersive(false); + return; + } selectNode(null, false); return; } @@ -6670,6 +6693,12 @@ import { applyAction, applyModel, canvasTitleAfterTemplate, inheritedTextFor, le } }); + // The user may leave the fullscreen with the key the browser takes, and + // the mode has to follow it out. + document.addEventListener('fullscreenchange', () => { + if (!document.fullscreenElement && state.immersive) setImmersive(false); + }); + // A native drag would swallow the pointermove stream the canvas relies on. // The blocker lives on the document so it also covers media that is // rendered outside the viewport subtree. @@ -7282,6 +7311,41 @@ import { applyAction, applyModel, canvasTitleAfterTemplate, inheritedTextFor, le }); }); } + dom.immersiveButton.addEventListener('click', () => setImmersive(!state.immersive)); + // The way out stands on the canvas: in the mode the toolbar is gone, so + // the button that leaves it cannot live there. + dom.immersiveExit.addEventListener('click', () => setImmersive(false)); + } + + // ---------------------------------------------------------------- immersive + + /** + * The immersive mode: the chrome goes out of the way and the canvas takes + * the whole surface. + * + * The host may hand the window to the page as well, so the mode asks for + * the real fullscreen — and keeps the page mode whether the host says yes + * or no. A refusal is not an error the user has to read. + */ + function setImmersive(on) { + if (state.immersive === on) return; + state.immersive = on; + dom.app.classList.toggle('nxc-app--immersive', on); + dom.immersiveExit.hidden = !on; + // The surface grew or shrank, so the canvas has to be told again where + // there is room for it. + applyViewport(); + renderToolbar(); + void syncFullscreen(on); + } + + async function syncFullscreen(on) { + try { + if (on) await document.documentElement.requestFullscreen?.(); + else await document.exitFullscreen?.(); + } catch { + // The host says no. The canvas is still immersive without it. + } } // ---------------------------------------------------------------- bootstrap @@ -7325,6 +7389,9 @@ import { applyAction, applyModel, canvasTitleAfterTemplate, inheritedTextFor, le dom.gridButton = $('btn-grid'); dom.themeButton = $('btn-theme'); dom.popoutButton = $('btn-popout'); + dom.immersiveButton = $('btn-immersive'); + dom.immersiveExit = $('immersive-exit'); + dom.app = $('nxc-app'); bindInteractions(); bindToolbar(); diff --git a/plugins/antianqi/ai-node-canvas/miniapp/client/immersive.mjs b/plugins/antianqi/ai-node-canvas/miniapp/client/immersive.mjs new file mode 100644 index 00000000..112426bf --- /dev/null +++ b/plugins/antianqi/ai-node-canvas/miniapp/client/immersive.mjs @@ -0,0 +1,32 @@ +// The immersive mode: the chrome gets out of the way and the canvas takes +// the whole surface. +// +// One rule, one reader: the keyboard says what a key means, and the page +// does what that meaning is. If the page read the keys itself, the key on +// the keyboard and the key in the README would drift apart. + +/** + * What a key means for the immersive mode. + * + * `toggle` asks for the mode or leaves it, `exit` leaves it, and an empty + * answer means the key is none of this mode's business. + * + * The mode is a mode and not an overlay, so its own key works whatever else + * is open. Escape is the other way round: it closes whatever is open first, + * and only then does it leave the mode. + * + * @param {{ key?: string, ctrlKey?: boolean, metaKey?: boolean, shiftKey?: boolean }} event + * @param {{ immersive?: boolean }} state + * @returns {'toggle' | 'exit' | ''} + */ +export function immersiveAction(event, state = {}) { + if (!event) return ''; + const key = event.key ?? ''; + if (key === 'F11') return 'toggle'; + // The host may take F11 for itself, so the same verb has a second key. + if ((event.ctrlKey || event.metaKey) && event.shiftKey && (key === 'f' || key === 'F')) { + return 'toggle'; + } + if (key === 'Escape' && state.immersive) return 'exit'; + return ''; +} diff --git a/plugins/antianqi/ai-node-canvas/miniapp/client/index.html b/plugins/antianqi/ai-node-canvas/miniapp/client/index.html index 363b29fe..7d30adfe 100644 --- a/plugins/antianqi/ai-node-canvas/miniapp/client/index.html +++ b/plugins/antianqi/ai-node-canvas/miniapp/client/index.html @@ -7,7 +7,7 @@
-