v2.2.1
AI 辅助弹窗升级为独立 OS 窗口:现在 AI 助手面板是一个可拖出主界面的独立操作系统窗口,支持跨屏使用。对话框 B 区高度由 JS 内容动态驱动,并实现了窗口自动贴合功能,以补偿 Tauri
setSize方法在计算外尺寸时的偏移。此外,新增了光标位置可视化功能与多窗口生命周期管理。
The AI assistant pane is now a separate OS window that can be dragged outside the main interface, supporting cross-screen use. The height of dialog B-zone is dynamically driven by JS content, and the window automatically fits to compensate for the outer-size offset in Tauri'ssetSizemethod. Additionally, cursor-position visualization and multi-window lifecycle management have been added.
新增 / Features
- AI 辅助弹窗升级为独立 OS 窗口:选中文字或光标处按 ⌘J(或右键)即可弹出独立的 AI 辅助窗口。该窗口可被拖出 MDeX 主窗口至桌面或第二屏幕,不再受主窗口边框限制。窗口内的所有功能(改写 / diff / 应用 / 多轮对话)均完整保留;执行
apply操作后,窗口将保持开启状态(编辑区会自动清空)。AI pane is now a separate OS window — Invoked by ⌘J / right-click, it can be dragged outside the main MDeX window onto the desktop or second screen, free from the main-window border. All functionalities (rewrite / diff / apply / multi-turn chat) are fully preserved; the window remains open afterapply(with the edit area cleared). - 光标位置可视化:在无选区时按 ⌘J,主窗口编辑器会在光标位置显示一条闪烁的蓝色竖线;有选区时则高亮显示选区。此功能旨在解决独立窗口获取焦点后主编辑器原生光标消失的问题,帮助用户清晰定位 AI 将要改写或插入内容的位置。Cursor-position visualization: Pressing ⌘J at the cursor (without selection) displays a blinking blue caret line in the main editor; with a selection, the selection is highlighted. This compensates for the disappearance of the native cursor in the main editor when the separate window gains focus, helping users clearly identify where the AI will edit.
- 关闭主窗口即退出程序:现在关闭主窗口会自动关闭所有 AI、文件及 mermaid 子窗口,并退出整个程序(Tauri 默认行为是需关闭所有窗口才会退出)。Closing the main window now quits the app — It automatically closes all AI, file, and mermaid child windows, exiting the application (Tauri's default behavior requires all windows to be closed to exit).
重构 / Refactor
- AI 窗口 B 区高度改为 JS 内容驱动 + 窗口自动贴合:A 区与 B2(输入行)采用
flex:none,其高度由内容决定且互不影响;B 区(对话框)使用flex:1占据窗口剩余空间,B1(聊天区)同样使用flex:1占据对话框剩余空间。窗口通过 JS 的maybeFitWindow方法实现自动贴合,该方法的逻辑是:窗口始终会根据内容撑大,但仅在未手动调整大小时才会自动缩小。补偿 Tauri setSize 外尺寸偏移(标题栏高度约 32px;由于outerSize/innerSize在 webview 中测量不准确,需通过经验值进行补偿)。拖动 A-B 分隔条改变 A 区高度时,窗口会随之调整,而 B 区高度保持不变;拖动窗口下缘时,窗口会在 B2 区域仅剩一行时停止缩小(通过set_min_size实现)。当聊天区 B1 为空时,其高度为 0;B2 区域增加行数时,窗口会相应撑大;B1 区域进行流式输出时,窗口会随之增大(通过rAF紧跟内容变化,最多显示 10 行后出现滚动条)。Rebuilt B-zone with JS content-driven sizing + auto window-fit: A and B2 zones useflex:none(independent, content-sized); the dialog (B) usesflex:1; the chat (B1) also usesflex:1. The window auto-fits viamaybeFitWindow, which always expands with content but only shrinks if not manually resized. This compensates for the TaurisetSizeouter-size offset (approximately 32px for the titlebar, asouterSize/innerSizeare unreliable in webview and require empirical compensation). Dragging the A-B separator resizes A and the window (B remains constant); dragging the window bottom stops resizing when B2 is reduced to one line (viaset_min_size). When B1 is empty, its height is 0; B2 growth expands the window; B1 streaming output causes the window to grow (tracked byrAF, capped at 10 lines before scrolling appears).
修复 / Fixes
- B2 输入区显示行数受限:旧 CSS 规则
#ai-input{max-height:120px}限制了 JS 设置的高度,现已移除该上限。B2 input was capped at ~7 lines due to a stalemax-height:120pxrule that truncated the JS-set height. - B2 空输入显示异常:空 textarea 的
scrollHeight不包含一行的高度,导致自动调整大小时出现问题。现已通过在 JS 调整大小时添加max(1行)兜底,并结合 CSSmin-height属性解决。B2 collapsed to a sliver when empty because thescrollHeightof an empty textarea excludes one line of height; this is fixed by adding amax(1 line)fallback in JS resizing and using CSSmin-height. - AI 窗口关闭后选区标记残留:子窗口关闭时会发出通知,主窗口据此清除
#editor-hl标记。Selection mark lingered after the AI window closed — The child window now emits a notification on close, allowing the main window to clear the#editor-hlmark. - 选区首尾空白导致行内格式失效:
wrapSelection函数(用于 Ctrl+I 斜体、Ctrl+B 加粗、删除线、行内代码)原先将标记放置在选区的最边缘。当选区首尾包含空格或换行符时,会生成* 文本 *这样的格式,而 Markdown 行内标记要求必须紧贴文字,因此斜体/加粗无法正确渲染。现已修改逻辑,将首尾空白移至标记外侧(如*text*),确保空白留在标记之外。Inline-format markers weren't adjacent to text when the selection had surrounding whitespace/newlines, producing* text *which Markdown doesn't render; the markers now hug the text with whitespace kept outside. This affects Ctrl+I / Ctrl+B / strike / inline-code (all share thewrapSelectionfunction). - 版本号升至 2.2.1。Version bumped to 2.2.1.