mirror of
https://github.com/obsqrbtz/goose-highlighter.git
synced 2026-04-08 20:19:06 +03:00
fix: do not call save() on all keypresses in textboxes
This commit is contained in:
@@ -144,9 +144,11 @@ export class PopupController {
|
|||||||
this.updateListForm();
|
this.updateListForm();
|
||||||
});
|
});
|
||||||
|
|
||||||
listName.addEventListener('input', () => {
|
listName.addEventListener('keydown', (e) => {
|
||||||
this.lists[this.currentListIndex].name = listName.value;
|
if (e.key === 'Enter') {
|
||||||
this.save();
|
this.lists[this.currentListIndex].name = listName.value;
|
||||||
|
this.save();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
listBg.addEventListener('input', () => {
|
listBg.addEventListener('input', () => {
|
||||||
@@ -237,17 +239,30 @@ export class PopupController {
|
|||||||
|
|
||||||
wordList.addEventListener('input', (e) => {
|
wordList.addEventListener('input', (e) => {
|
||||||
const target = e.target as HTMLInputElement;
|
const target = e.target as HTMLInputElement;
|
||||||
const index = +(target.dataset.wordEdit ?? target.dataset.bgEdit ?? target.dataset.fgEdit ?? -1);
|
const index = +(target.dataset.bgEdit ?? target.dataset.fgEdit ?? -1);
|
||||||
if (index === -1) return;
|
if (index === -1) return;
|
||||||
|
|
||||||
const word = this.lists[this.currentListIndex].words[index];
|
const word = this.lists[this.currentListIndex].words[index];
|
||||||
if (target.dataset.wordEdit != null) word.wordStr = target.value;
|
|
||||||
if (target.dataset.bgEdit != null) word.background = target.value;
|
if (target.dataset.bgEdit != null) word.background = target.value;
|
||||||
if (target.dataset.fgEdit != null) word.foreground = target.value;
|
if (target.dataset.fgEdit != null) word.foreground = target.value;
|
||||||
|
|
||||||
this.save();
|
this.save();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
wordList.addEventListener('keydown', (e) => {
|
||||||
|
if (e.key === 'Enter') {
|
||||||
|
const target = e.target as HTMLInputElement;
|
||||||
|
const index = +(target.dataset.wordEdit ?? -1);
|
||||||
|
if (index === -1) return;
|
||||||
|
|
||||||
|
const word = this.lists[this.currentListIndex].words[index];
|
||||||
|
if (target.dataset.wordEdit != null) {
|
||||||
|
word.wordStr = target.value;
|
||||||
|
this.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let scrollTimeout: number;
|
let scrollTimeout: number;
|
||||||
wordList.addEventListener('scroll', () => {
|
wordList.addEventListener('scroll', () => {
|
||||||
if (scrollTimeout) return;
|
if (scrollTimeout) return;
|
||||||
@@ -473,6 +488,8 @@ export class PopupController {
|
|||||||
MessageService.sendToAllTabs({ type: 'EXCEPTIONS_LIST_UPDATED' });
|
MessageService.sendToAllTabs({ type: 'EXCEPTIONS_LIST_UPDATED' });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private async updateGlobalToggleState(): Promise<void> {
|
private async updateGlobalToggleState(): Promise<void> {
|
||||||
await StorageService.update('globalHighlightEnabled', this.globalHighlightEnabled);
|
await StorageService.update('globalHighlightEnabled', this.globalHighlightEnabled);
|
||||||
MessageService.sendToAllTabs({
|
MessageService.sendToAllTabs({
|
||||||
|
|||||||
Reference in New Issue
Block a user