Fix hj shortcuts activating in textarea.
This commit is contained in:
		@ -2,6 +2,7 @@
 | 
				
			|||||||
  <textarea
 | 
					  <textarea
 | 
				
			||||||
    @keyup.enter="addNote"
 | 
					    @keyup.enter="addNote"
 | 
				
			||||||
    v-model="content"
 | 
					    v-model="content"
 | 
				
			||||||
 | 
					    ref="content"
 | 
				
			||||||
    rows="10"
 | 
					    rows="10"
 | 
				
			||||||
    placeholder="Start typing something…"
 | 
					    placeholder="Start typing something…"
 | 
				
			||||||
    autofocus
 | 
					    autofocus
 | 
				
			||||||
@ -38,9 +39,12 @@ export default {
 | 
				
			|||||||
  computed: {},
 | 
					  computed: {},
 | 
				
			||||||
  mounted() {
 | 
					  mounted() {
 | 
				
			||||||
    document.addEventListener('keyup', e => {
 | 
					    document.addEventListener('keyup', e => {
 | 
				
			||||||
      console.log(e.code)
 | 
					 | 
				
			||||||
      switch (e.code) {
 | 
					      switch (e.code) {
 | 
				
			||||||
        case 'KeyJ':
 | 
					        case 'KeyJ':
 | 
				
			||||||
 | 
					          // only if not in textarea
 | 
				
			||||||
 | 
					          if (e.target.type === 'textarea') {
 | 
				
			||||||
 | 
					            return
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
          // go down in the list, unless it's the last item
 | 
					          // go down in the list, unless it's the last item
 | 
				
			||||||
          this.current =
 | 
					          this.current =
 | 
				
			||||||
            this.current === null
 | 
					            this.current === null
 | 
				
			||||||
@ -50,6 +54,10 @@ export default {
 | 
				
			|||||||
              : this.current + 1
 | 
					              : this.current + 1
 | 
				
			||||||
          break
 | 
					          break
 | 
				
			||||||
        case 'KeyK':
 | 
					        case 'KeyK':
 | 
				
			||||||
 | 
					          // only if not in textarea
 | 
				
			||||||
 | 
					          if (e.target.type === 'textarea') {
 | 
				
			||||||
 | 
					            return
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
          // go up in the list, unless it's the first item
 | 
					          // go up in the list, unless it's the first item
 | 
				
			||||||
          this.current =
 | 
					          this.current =
 | 
				
			||||||
            this.current === null
 | 
					            this.current === null
 | 
				
			||||||
@ -58,7 +66,14 @@ export default {
 | 
				
			|||||||
              ? this.current
 | 
					              ? this.current
 | 
				
			||||||
              : this.current - 1
 | 
					              : this.current - 1
 | 
				
			||||||
          break
 | 
					          break
 | 
				
			||||||
 | 
					        case 'KeyC':
 | 
				
			||||||
 | 
					          this.$refs.content.focus()
 | 
				
			||||||
 | 
					          break
 | 
				
			||||||
        case 'Delete':
 | 
					        case 'Delete':
 | 
				
			||||||
 | 
					          // only if not in textarea
 | 
				
			||||||
 | 
					          if (e.target.type === 'textarea') {
 | 
				
			||||||
 | 
					            return
 | 
				
			||||||
 | 
					          }
 | 
				
			||||||
          alert(`Delete note #${this.current}?`)
 | 
					          alert(`Delete note #${this.current}?`)
 | 
				
			||||||
          break
 | 
					          break
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user