Fix type issues

This commit is contained in:
Henrik Giesel 2021-01-30 18:32:36 +01:00
parent 33160dcb00
commit 859a52ab15

View file

@ -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();
} }