feat(sidebar): add dialogue selection and copying (#238)

This commit is contained in:
2026-09-07 14:03:54 -07:00
committed by GitHub
parent c14c690875
commit 1e5d7747b4
24 changed files with 624 additions and 3 deletions
+23
View File
@@ -1863,6 +1863,29 @@ test('keyboard mode: popup hidden after mode off clears stale selected token hig
}
});
test('Yomitan popup dismissal and subtitle updates preserve selection outside the overlay subtitle', async () => {
const { ctx, handlers, testGlobals } = createKeyboardHandlerHarness();
let cleared = false;
try {
Object.defineProperty(window, 'getSelection', {
configurable: true,
value: () => ({
anchorNode: {},
removeAllRanges: () => {
cleared = true;
},
}),
});
Object.assign(ctx.dom.subtitleRoot, { contains: () => false });
await handlers.setupMpvInputForwarding();
testGlobals.dispatchWindowEvent(YOMITAN_POPUP_HIDDEN_EVENT);
handlers.syncKeyboardTokenSelection();
assert.equal(cleared, false);
} finally {
testGlobals.restore();
}
});
test('keyboard mode: closing lookup keeps controller selection but clears native text selection', async () => {
const { ctx, handlers, testGlobals } = createKeyboardHandlerHarness();
+4 -1
View File
@@ -436,7 +436,10 @@ export function createKeyboardHandlers(
}
function clearNativeSubtitleSelection(): void {
window.getSelection()?.removeAllRanges();
const selection = window.getSelection();
if (!selection?.anchorNode || ctx.dom.subtitleRoot.contains(selection.anchorNode)) {
selection?.removeAllRanges();
}
ctx.dom.subtitleRoot.classList.remove('has-selection');
}