Skip to content

Commit

Permalink
added autofocus and keyboard shortcut for deleting with cmd+backspace
Browse files Browse the repository at this point in the history
  • Loading branch information
ecrmnn committed Dec 25, 2016
1 parent e807bcd commit dc73c0a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
@keydown="selectItem"
@keyup.enter="add"
@focus="showSelectedItemIndex"
@blur="hideSelectedItemIndex">
@blur="hideSelectedItemIndex"
ref="input">

<div class="input-group-btn">
<button type="button" class="btn btn-success" @click="add">
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"name": "minta",
"version": "1.0.0",
"version": "1.0.1",
"description": "Generate regular expressions with ease",
"main": "main.js",
"scripts": {
"start": "NODE_ENV=developement electron .",
"start-prod": "electron .",
"build": "node_modules/.bin/electron-packager . Minta --out=dist/osx --platform=darwin --arch=x64 --overwrite --icon=resources/minta_600.icns"
"build": "npm run package && npm run compress",
"package": "node_modules/.bin/electron-packager . Minta --out=dist/osx --platform=darwin --arch=x64 --overwrite --icon=resources/minta_600.icns",
"compress": "cd dist/osx/Minta-darwin-x64 && tar cvzf Minta.tar.gz Minta.app"
},
"repository": "https://github.com/ecrmnn/minta",
"author": {
Expand Down
8 changes: 6 additions & 2 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ new Vue({

created() {
new Clipboard('.copy');

this.$nextTick(() => this.$refs.input.focus());
},

computed: {
Expand Down Expand Up @@ -51,7 +53,7 @@ new Vue({
this.selectNext();
} else if (event.keyCode === 38) {
this.selectPrevious();
} else if (event.keyCode === 46) {
} else if (event.keyCode === 46 || event.metaKey && event.keyCode === 8) {
this.deleteSelected();
}
},
Expand All @@ -73,7 +75,9 @@ new Vue({
},

deleteSelected() {
this.remove(this.selectedItemIndex);
if (this.selectedItemIndex !== -1) {
this.remove(this.selectedItemIndex);
}
},

showSelectedItemIndex() {
Expand Down

0 comments on commit dc73c0a

Please sign in to comment.