Skip to content

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

web: middle click on note to open it in new tab

Abdullah Atta0a0edd481494
diff --git a/apps/web/src/components/editor/action-bar.tsx b/apps/web/src/components/editor/action-bar.tsx
index 996b1fd11..e4db2d64f 100644
--- a/apps/web/src/components/editor/action-bar.tsx
+++ b/apps/web/src/components/editor/action-bar.tsx
@@ -453,7 +453,6 @@ function Tab(props: TabProps) {
}}
onClick={(e) => {
e.stopPropagation();
- console.log(e);
onFocus();
}}
{...listeners}
diff --git a/apps/web/src/components/list-item/index.tsx b/apps/web/src/components/list-item/index.tsx
index 1f725d628..c9b45b887 100644
--- a/apps/web/src/components/list-item/index.tsx
+++ b/apps/web/src/components/list-item/index.tsx
@@ -46,6 +46,7 @@ type ListItemProps<TItem extends Item, TContext> = {
onKeyPress?: (e: React.KeyboardEvent<HTMLDivElement>) => void;
onClick?: () => void;
+ onMiddleClick?: () => void;
onSelect?: () => void;
onDragEnter?: (e: React.DragEvent<HTMLDivElement>) => void;
@@ -178,7 +179,7 @@ function ListItem<TItem extends Item, TContext>(
},
...sx
}}
- onKeyPress={(e) => {
+ onKeyUp={(e) => {
if (e.key !== "Enter") {
if (props.onKeyPress) props.onKeyPress(e);
}
@@ -188,6 +189,12 @@ function ListItem<TItem extends Item, TContext>(
props.onClick();
}
}}
+ onMouseDown={(e) => {
+ if (e.button == 1 && props.onMiddleClick) {
+ e.preventDefault();
+ props.onMiddleClick();
+ }
+ }}
data-test-id={`list-item`}
>
{!isCompact && props.header}
diff --git a/apps/web/src/components/note/index.tsx b/apps/web/src/components/note/index.tsx
index 372bdc1c6..4030f6f49 100644
--- a/apps/web/src/components/note/index.tsx
+++ b/apps/web/src/components/note/index.tsx
@@ -147,6 +147,9 @@ function Note(props: NoteProps) {
context={{ color, locked }}
menuItems={menuItems}
onClick={() => useEditorStore.getState().openSession(note)}
+ onMiddleClick={() =>
+ useEditorStore.getState().openSession(note, { newSession: true })
+ }
header={
<Flex
sx={{ alignItems: "center", flexWrap: "wrap", gap: 1, mt: "small" }}
diff --git a/apps/web/src/stores/editor-store.ts b/apps/web/src/stores/editor-store.ts
index b431692cd..94fe6c390 100644
--- a/apps/web/src/stores/editor-store.ts
+++ b/apps/web/src/stores/editor-store.ts
@@ -487,7 +487,12 @@ class EditorStore extends BaseStore<EditorStore> {
openSession = async (
noteOrId: string | Note | BaseTrashItem<Note>,
- options: { force?: boolean; activeBlockId?: string; silent?: boolean } = {}
+ options: {
+ force?: boolean;
+ activeBlockId?: string;
+ silent?: boolean;
+ newSession?: boolean;
+ } = {}
): Promise<void> => {
const { getSession, openDiffSession } = this.get();
const noteId = typeof noteOrId === "string" ? noteOrId : noteOrId.id;
@@ -508,7 +513,7 @@ class EditorStore extends BaseStore<EditorStore> {
? noteOrId
: (await db.notes.note(noteId)) || (await db.notes.trashed(noteId));
if (!note) return;
- const isPreview = session ? session.preview : true;
+ const isPreview = session ? session.preview : !options?.newSession;
const isLocked = await db.vaults.itemExists(note);
if (isLocked && note.type !== "trash") {