chore(client/ts): port highlights_list

This commit is contained in:
Elian Doran
2025-01-07 12:34:10 +02:00
parent 0713b4aec8
commit 85c225fe05
9 changed files with 133 additions and 66 deletions

View File

@@ -306,7 +306,7 @@ class NoteContext extends Component
}
async getTextEditor(callback?: GetTextEditorCallback) {
return this.timeout(new Promise(resolve => appContext.triggerCommand('executeWithTextEditor', {
return this.timeout<TextEditor>(new Promise(resolve => appContext.triggerCommand('executeWithTextEditor', {
callback,
resolve,
ntxId: this.ntxId
@@ -321,7 +321,7 @@ class NoteContext extends Component
}
async getContentElement() {
return this.timeout(new Promise(resolve => appContext.triggerCommand('executeWithContentElement', {
return this.timeout<JQuery<HTMLElement>>(new Promise(resolve => appContext.triggerCommand('executeWithContentElement', {
resolve,
ntxId: this.ntxId
})));
@@ -334,11 +334,11 @@ class NoteContext extends Component
})));
}
timeout(promise: Promise<unknown>) {
timeout<T>(promise: Promise<T | null>) {
return Promise.race([
promise,
new Promise(res => setTimeout(() => res(null), 200))
]);
]) as Promise<T>;
}
resetViewScope() {