mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 22:42:25 -04:00

* Add utility functions for saving and restoring the caret location * Implement cross-browser.getSelection * Save and restore location on ContentEditable * Fix refocus by clicking on a field that had a non-collapsed selection
12 lines
448 B
TypeScript
12 lines
448 B
TypeScript
// Copyright: Ankitects Pty Ltd and contributors
|
|
// License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html
|
|
|
|
export function on<T extends EventTarget, L extends EventListener>(
|
|
target: T,
|
|
eventType: string,
|
|
listener: L,
|
|
options: AddEventListenerOptions = {},
|
|
): () => void {
|
|
target.addEventListener(eventType, listener, options);
|
|
return () => target.removeEventListener(eventType, listener, options);
|
|
}
|