browser-extension-settings 0.0.6 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/settings.ts +9 -17
- package/package.json +1 -1
package/lib/settings.ts
CHANGED
|
@@ -103,8 +103,8 @@ const closeModal = () => {
|
|
|
103
103
|
settingsContainer.style.display = "none"
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
removeEventListener(document, "click", onDocumentClick)
|
|
107
|
-
removeEventListener(document, "keydown", onDocumentKeyDown)
|
|
106
|
+
removeEventListener(document, "click", onDocumentClick, true)
|
|
107
|
+
removeEventListener(document, "keydown", onDocumentKeyDown, true)
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
const onDocumentClick = (event: Event) => {
|
|
@@ -121,20 +121,12 @@ const onDocumentKeyDown = (event: KeyboardEvent) => {
|
|
|
121
121
|
return // 如果事件已经在进行中,则不做任何事。
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
default: {
|
|
132
|
-
return
|
|
133
|
-
} // 什么都没按就退出吧。
|
|
124
|
+
if (event.key === "Escape") {
|
|
125
|
+
// 按“ESC”键时要做的事。
|
|
126
|
+
closeModal()
|
|
127
|
+
// 取消默认动作,从而避免处理两次。
|
|
128
|
+
event.preventDefault()
|
|
134
129
|
}
|
|
135
|
-
|
|
136
|
-
// 取消默认动作,从而避免处理两次。
|
|
137
|
-
event.preventDefault()
|
|
138
130
|
}
|
|
139
131
|
|
|
140
132
|
async function updateOptions() {
|
|
@@ -369,8 +361,8 @@ export async function showSettings() {
|
|
|
369
361
|
await updateOptions()
|
|
370
362
|
settingsContainer.style.display = "block"
|
|
371
363
|
|
|
372
|
-
addEventListener(document, "click", onDocumentClick)
|
|
373
|
-
addEventListener(document, "keydown", onDocumentKeyDown)
|
|
364
|
+
addEventListener(document, "click", onDocumentClick, true)
|
|
365
|
+
addEventListener(document, "keydown", onDocumentKeyDown, true)
|
|
374
366
|
activeExtension(settingsOptions.id)
|
|
375
367
|
deactiveExtensionList()
|
|
376
368
|
}
|