mirror of
https://github.com/ankitects/anki.git
synced 2025-11-13 08:07:11 -05:00
Fix type issues
This commit is contained in:
parent
33160dcb00
commit
859a52ab15
1 changed files with 15 additions and 6 deletions
|
|
@ -8,8 +8,21 @@ let currentField: EditingArea | null = null;
|
||||||
let changeTimer: number | null = null;
|
let changeTimer: number | null = null;
|
||||||
let currentNoteId: number | null = null;
|
let currentNoteId: number | null = null;
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface String {
|
||||||
|
format(...args: string[]): string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Selection {
|
||||||
|
modify(s: string, t: string, u: string): void;
|
||||||
|
addRange(r: Range): void;
|
||||||
|
removeAllRanges(): void;
|
||||||
|
getRangeAt(n: number): Range;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* kept for compatibility with add-ons */
|
/* kept for compatibility with add-ons */
|
||||||
(String.prototype as any).format = function (...args: string[]): string {
|
String.prototype.format = function (...args: string[]): string {
|
||||||
return this.replace(/\{\d+\}/g, (m: string): void => {
|
return this.replace(/\{\d+\}/g, (m: string): void => {
|
||||||
const match = m.match(/\d+/);
|
const match = m.match(/\d+/);
|
||||||
|
|
||||||
|
|
@ -44,10 +57,6 @@ function triggerKeyTimer(): void {
|
||||||
}, 600);
|
}, 600);
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Selection {
|
|
||||||
modify(s: string, t: string, u: string): void;
|
|
||||||
}
|
|
||||||
|
|
||||||
function onKey(evt: KeyboardEvent): void {
|
function onKey(evt: KeyboardEvent): void {
|
||||||
// esc clears focus, allowing dialog to close
|
// esc clears focus, allowing dialog to close
|
||||||
if (evt.code === "Escape") {
|
if (evt.code === "Escape") {
|
||||||
|
|
@ -460,7 +469,7 @@ class EditingArea extends HTMLDivElement {
|
||||||
return this.editable.style.direction === "rtl";
|
return this.editable.style.direction === "rtl";
|
||||||
}
|
}
|
||||||
|
|
||||||
getSelection(): any {
|
getSelection(): Selection {
|
||||||
return this.shadowRoot.getSelection();
|
return this.shadowRoot.getSelection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue