refactor: issue comment context menu and buttons (#39771)

1. Support show "Quote reply" shortcut in help menu, fix the TODO
2. Help #36862 to reuse existing "issue/comment context menu"
This commit is contained in:
wxiaoguang authored and GitHub committed 2026-10-14 12:07:31 +00:00
1 parent b015cd67e2
commit ccc9b928fe
16 files changed
+205 -191

No files matched your search

+8 -8
View File
@@ -1,10 +1,10 @@
import {tryShortcutQuoteReply} from './repo-issue-edit.ts';
import {tryQuoteSelectedReply} from './repo-issue-edit.ts';
test('tryShortcutQuoteReply', () => {
test('tryQuoteSelectedReply', () => {
const container = document.createElement('div');
container.innerHTML = `
<div class="comment-container">
<button class="quote-reply">Quote reply</button>
<button data-shortcut-handler="quoteSelectedReply">Quote reply</button>
<div class="render-content markup">Comment text</div>
<div class="raw-content">Raw text</div>
</div>
@@ -20,24 +20,24 @@ test('tryShortcutQuoteReply', () => {
button.addEventListener('click', onClick);
selection.removeAllRanges();
expect(tryShortcutQuoteReply()).toBe(false);
expect(tryQuoteSelectedReply()).toBe(false);
selection.selectAllChildren(container.querySelector('.raw-content')!);
expect(tryShortcutQuoteReply()).toBe(false);
expect(tryQuoteSelectedReply()).toBe(false);
const range = document.createRange();
range.selectNodeContents(container.querySelector('.render-content')!.firstChild!);
selection.removeAllRanges();
selection.addRange(range);
selection.collapseToStart();
expect(tryShortcutQuoteReply()).toBe(false);
expect(tryQuoteSelectedReply()).toBe(false);
expect(onClick).not.toHaveBeenCalled();
selection.removeAllRanges();
selection.addRange(range);
expect(tryShortcutQuoteReply()).toBe(true);
expect(tryQuoteSelectedReply()).toBe(true);
expect(onClick).toHaveBeenCalledTimes(1);
button.remove();
expect(tryShortcutQuoteReply()).toBe(false);
expect(tryQuoteSelectedReply()).toBe(false);
});