mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-09-09 17:16:19 -07:00
feat(sidebar): add dialogue selection and copying (#238)
This commit is contained in:
@@ -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();
|
||||
|
||||
|
||||
@@ -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');
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user