From 38c8c5c5199557b80cc1747fffce5cc004686325 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20=C3=85hall?= Date: Tue, 20 Jun 2023 07:59:54 +0200 Subject: [PATCH] Added keyhandler --- main.go | 2 +- static/css/main.css | 8 ++++---- static/js/node.mjs | 39 +++++++++++++++++++++++++++++---------- static/less/main.less | 1 - static/less/theme.less | 4 ++-- 5 files changed, 36 insertions(+), 18 deletions(-) diff --git a/main.go b/main.go index 50197fd..4dc9c1d 100644 --- a/main.go +++ b/main.go @@ -15,7 +15,7 @@ import ( _ "embed" ) -const VERSION = "v0.1.0"; +const VERSION = "v0.1.1"; const LISTEN_HOST = "0.0.0.0"; const DB_SCHEMA = 2 diff --git a/static/css/main.css b/static/css/main.css index e853491..c01758e 100644 --- a/static/css/main.css +++ b/static/css/main.css @@ -18,7 +18,7 @@ body { background-color: #fff; } h1 { - color: #ecbf00; + color: #abc837; } #app { display: grid; @@ -67,9 +67,9 @@ header { display: grid; grid-template-columns: 1fr min-content min-content; align-items: center; - background: #ecbf00; + background: #abc837; padding: 0px; - color: #3a2f00; + color: #333c11; } header.modified { background: #c84a37; @@ -108,7 +108,7 @@ header .menu { .crumbs .crumb:after { content: "•"; margin-left: 8px; - color: #ecbf00; + color: #abc837; } .crumbs .crumb:last-child { margin-right: 0; diff --git a/static/js/node.mjs b/static/js/node.mjs index a12c788..d273939 100644 --- a/static/js/node.mjs +++ b/static/js/node.mjs @@ -16,6 +16,7 @@ export class NodeUI extends Component { else this.goToNode(0, true) }) + window.addEventListener('keydown', evt=>this.keyHandler(evt)) }//}}} render() {//{{{ if(this.node.value === null) @@ -70,12 +71,6 @@ export class NodeUI extends Component { <${NodeContent} key=${node.ID} content=${node.Content} ref=${this.nodeContent} /> ` : html``} ` - /* -
this.retrieveTree()} style="color: #000"> -
Start
- ${treeHTML} -
- */ }//}}} componentDidMount() {//{{{ let urlParams = new URLSearchParams(window.location.search) @@ -87,6 +82,34 @@ export class NodeUI extends Component { }) }//}}} + keyHandler(evt) {//{{{ + let handled = true + switch(evt.key.toUpperCase()) { + case 'S': + if(!evt.ctrlKey) { + handled = false + break + } + this.saveNode() + break + + case 'N': + if(!evt.ctrlKey && !evt.AltKey) { + handled = false + break + } + this.createNode() + break + + default: + handled = false + } + + if(handled) { + evt.preventDefault() + evt.stopPropagation() + } + }//}}} showMenu() {//{{{ this.menu.value = true }//}}} @@ -121,10 +144,6 @@ export class NodeUI extends Component { }//}}} saveNode() {//{{{ let content = this.nodeContent.current.contentDiv.current.value - content = content - .replaceAll("\r", "") - .replaceAll("
", "") - this.props.app.request('/node/update', { NodeID: this.node.value.ID, Content: content, diff --git a/static/less/main.less b/static/less/main.less index 9896725..404ceb8 100644 --- a/static/less/main.less +++ b/static/less/main.less @@ -186,7 +186,6 @@ header { } &:invalid { - //background: #eee; border-bottom: 1px solid #eee; border-radius: 8px; } diff --git a/static/less/theme.less b/static/less/theme.less index 38feff7..2f12cfd 100644 --- a/static/less/theme.less +++ b/static/less/theme.less @@ -1,5 +1,5 @@ @fontsize: 14pt; @background: #fff; -@accent_1: #ecbf00; -@accent_2: #abc837; +@accent_1: #abc837; +@accent_2: #ecbf00; @accent_3: #c84a37;