aboutsummaryrefslogtreecommitdiff
path: root/editor/editor.ts
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2021-07-31 21:57:04 +0700
committerShulhan <ms@kilabit.info>2021-07-31 21:57:04 +0700
commit32b16bbcb4d4edc872df1ac579bee3a34ebe70d5 (patch)
treebea0835f7c6e2d1e83264abde70b4e7032380ee5 /editor/editor.ts
parent064b08c44cc4f88667b6c960927e352e7661311c (diff)
downloadpakakeh.ts-32b16bbcb4d4edc872df1ac579bee3a34ebe70d5.tar.xz
editor: pressing escape key will clear the selection
Diffstat (limited to 'editor/editor.ts')
-rw-r--r--editor/editor.ts15
1 files changed, 14 insertions, 1 deletions
diff --git a/editor/editor.ts b/editor/editor.ts
index de52c98..4076474 100644
--- a/editor/editor.ts
+++ b/editor/editor.ts
@@ -82,6 +82,15 @@ export class Editor implements IEditor {
return res
}
+ clearSelection() {
+ if (!this.el) {
+ return
+ }
+ for (let x = 0; x < this.el.children.length; x++) {
+ this.el.children[x].setAttribute("style", "")
+ }
+ }
+
initStyle() {
let style = document.createElement("style")
style.type = "text/css"
@@ -214,7 +223,6 @@ export class Editor implements IEditor {
case "ContextMenu":
case "Delete":
case "End":
- case "Escape":
case "Home":
case "Insert":
case "OS":
@@ -395,6 +403,11 @@ export class Editor implements IEditor {
this.insertNewline(x + 1, textAfter)
break
+ case "Escape":
+ ev.preventDefault()
+ this.clearSelection()
+ break
+
case "r":
if (this.isKeyControl) {
ev.preventDefault()