Skip to content

✨ 编辑器添加编辑菜单(查找、替换、撤销等)#1303

Merged
CodFrm merged 7 commits intorelease/v1.4from
worktree-issue-1103-find-replace
Mar 21, 2026
Merged

✨ 编辑器添加编辑菜单(查找、替换、撤销等)#1303
CodFrm merged 7 commits intorelease/v1.4from
worktree-issue-1103-find-replace

Conversation

@CodFrm
Copy link
Copy Markdown
Member

@CodFrm CodFrm commented Mar 21, 2026

Summary

  • 在编辑器顶部新增"编辑"菜单,包含撤销/重做、剪切/复制/粘贴、查找/替换、全选等常用操作
  • 点击菜单项会触发 Monaco Editor 对应的 action,方便用户发现内置的编辑功能
  • 添加了 8 种语言的 i18n 翻译

Closes #1103

Test plan

  • 打开编辑器 → 确认顶部菜单栏新增"编辑"菜单
  • 点击"查找" → Monaco 查找面板弹出
  • 点击"替换" → Monaco 替换面板弹出
  • 撤销/重做/剪切/复制/粘贴/全选功能正常

@CodFrm CodFrm changed the base branch from main to release/v1.4 March 21, 2026 18:26
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没有用crowdin了,感觉可以删除这个文件

@cyfung1031
Copy link
Copy Markdown
Collaborator

@CodFrm
更新 instruction md 指导一下 AI 不要这样写

${i.toString()}

应该是

${i}

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

该 PR 旨在让用户更容易发现并使用 Monaco Editor 内置的查找/替换能力,通过在脚本编辑器顶部菜单中新增入口来触发对应的 Monaco actions,同时补齐多语言文案支持。

Changes:

  • ScriptEditor 顶部菜单新增一组编辑相关菜单项(含查找/替换、撤销/重做、剪切/复制/粘贴、全选)并实现触发 Monaco 对应 action/command。
  • 为新增菜单项补充 8 种语言的 i18n 翻译键值(find/replace/undo/redo/cut/copy/paste)。
  • 调整 ExternalWhitelist(新增 sleazyfork.org,并移除未使用的 ExternalMessage 常量)。

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/pages/options/routes/script/ScriptEditor.tsx 新增编辑菜单与查找/替换入口;引入菜单分隔线渲染逻辑
src/locales/zh-TW/translation.json 新增 find/replace/undo/redo/cut/copy/paste 翻译
src/locales/zh-CN/translation.json 新增 find/replace/undo/redo/cut/copy/paste 翻译
src/locales/vi-VN/translation.json 新增 find/replace/undo/redo/cut/copy/paste 翻译
src/locales/ru-RU/translation.json 新增 find/replace/undo/redo/cut/copy/paste 翻译
src/locales/ja-JP/translation.json 新增 find/replace/undo/redo/cut/copy/paste 翻译
src/locales/en-US/translation.json 新增 find/replace/undo/redo/cut/copy/paste 翻译
src/locales/de-DE/translation.json 新增 find/replace/undo/redo/cut/copy/paste 翻译
src/locales/ach-UG/translation.json 新增 find/replace/undo/redo/cut/copy/paste 翻译(占位/英文)
src/app/const.ts 更新 ExternalWhitelist(新增 sleazyfork.org)并移除 ExternalMessage

Comment on lines +933 to +935
<div key={`divider_${i}`} style={{ padding: "4px 0", background: "var(--color-secondary)" }}>
<div style={{ height: "1px", backgroundColor: "var(--color-neutral-4)" }} />
</div>
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里用普通的

作为 Menu 的分隔线子元素,会丢失 Menu 组件的语义结构(如 role=separator)、键盘导航一致性以及主题样式一致性。建议使用 Arco Menu 提供的分隔组件/能力(如 Menu.Divider 或 disabled 的 Menu.Item 作为分隔),避免在 Menu 内混入非 Menu 子节点。

Suggested change
<div key={`divider_${i}`} style={{ padding: "4px 0", background: "var(--color-secondary)" }}>
<div style={{ height: "1px", backgroundColor: "var(--color-neutral-4)" }} />
</div>
<Menu.Divider
key={`divider_${i}`}
style={{
margin: "4px 0",
background: "var(--color-secondary)",
borderBottomColor: "var(--color-neutral-4)",
}}
/>

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

arco没有这个组件

Comment on lines +505 to +566
{
title: t("edit"),
items: [
{
id: "undo",
title: t("undo"),
hotKeyString: "Ctrl+Z",
action(_script, e) {
e.trigger("menu", "undo", null);
},
},
{
id: "redo",
title: t("redo"),
hotKeyString: "Ctrl+Shift+Z",
action(_script, e) {
e.trigger("menu", "redo", null);
},
},
{ divider: true },
{
id: "cut",
title: t("cut"),
hotKeyString: "Ctrl+X",
action(_script, e) {
e.trigger("menu", "editor.action.clipboardCutAction", null);
},
},
{
id: "copy",
title: t("copy"),
hotKeyString: "Ctrl+C",
action(_script, e) {
e.trigger("menu", "editor.action.clipboardCopyAction", null);
},
},
{
id: "paste",
title: t("paste"),
hotKeyString: "Ctrl+V",
action(_script, e) {
e.trigger("menu", "editor.action.clipboardPasteAction", null);
},
},
{ divider: true },
{
id: "find",
title: t("find"),
hotKeyString: "Ctrl+F",
action(_script, e) {
e.getAction("actions.find")?.run();
},
},
{
id: "replace",
title: t("replace"),
hotKeyString: "Ctrl+H",
action(_script, e) {
e.getAction("editor.action.startFindReplaceAction")?.run();
},
},
{
Copy link

Copilot AI Mar 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR 描述/标题提到在「工具」菜单里增加「查找/替换」入口,但这里实际新增的是顶层「编辑」菜单,并把「查找/替换」放在其中;「工具」菜单并未包含这两个入口。建议要么把这两项移动到 tools 菜单下以符合需求/Issue,要么同步更新 PR 描述与交互文案说明为何改为新增“编辑”菜单。

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

更新了

@CodFrm CodFrm changed the title ✨ 编辑器工具菜单添加查找和替换入口 ✨ 编辑器添加编辑菜单(查找、替换、撤销等) Mar 21, 2026
@CodFrm CodFrm merged commit c59c603 into release/v1.4 Mar 21, 2026
3 of 4 checks passed
@CodFrm CodFrm deleted the worktree-issue-1103-find-replace branch March 21, 2026 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] 给编辑器增加查找和替换功能。Add search and replace functionality to the editor.

3 participants