Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

feat: delete note using delete key (#206)

Muhammad Ali8fcc213a01ae
diff --git a/apps/web/src/components/list-item/index.js b/apps/web/src/components/list-item/index.js
index 96aab5324..3a7c14240 100644
--- a/apps/web/src/components/list-item/index.js
+++ b/apps/web/src/components/list-item/index.js
@@ -124,7 +124,11 @@ function ListItem(props) {
maxWidth: "100%",
}}
onKeyPress={(e) => {
- if (e.key === "Enter") e.target.click();
+ if (e.key === "Enter") {
+ e.target.click();
+ } else {
+ if (props.onKeyPress) props.onKeyPress(e);
+ }
}}
flexDirection={isCompact ? "row" : "column"}
justifyContent={isCompact ? "space-between" : "center"}
diff --git a/apps/web/src/components/note/index.js b/apps/web/src/components/note/index.js
index b6016fecd..abe1b591c 100644
--- a/apps/web/src/components/note/index.js
+++ b/apps/web/src/components/note/index.js
@@ -3,7 +3,7 @@ import { Button, Flex, Text } from "rebass";
import * as Icon from "../icons";
import TimeAgo from "../time-ago";
import ListItem from "../list-item";
-import { showMoveNoteDialog } from "../../common/dialog-controller";
+import { confirm, showMoveNoteDialog } from "../../common/dialog-controller";
import { store, useStore } from "../../stores/note-store";
import { useStore as useAttachmentStore } from "../../stores/attachment-store";
import { db } from "../../common/db";
@@ -44,6 +44,18 @@ function Note(props) {
body={note.headline}
id={note.id}
index={index}
+ onKeyPress={async (e) => {
+ if (e.key === "Delete") {
+ await confirm({
+ title: "Delete note?",
+ message:
+ "This item will be kept in your Trash for 7 days after which it will be permanently removed",
+ noText: "No",
+ yesText: "Yes",
+ yesAction: () => Multiselect.moveNotesToTrash([item]),
+ });
+ }
+ }}
colors={{
primary,
text: note.color ? primary : "text",