Skip to content

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

web: add menu items to open, view & unpublish a monograph (fixes #4812)

Abdullah Atta05695cfcc85a
diff --git a/apps/web/src/components/icons/index.tsx b/apps/web/src/components/icons/index.tsx
index 9ec0d9bea..0656d844f 100644
--- a/apps/web/src/components/icons/index.tsx
+++ b/apps/web/src/components/icons/index.tsx
@@ -215,7 +215,8 @@ import {
mdiWindowClose,
mdiFileMusicOutline,
mdiBroom,
- mdiServerSecurity
+ mdiServerSecurity,
+ mdiOpenInNew
} from "@mdi/js";
import { useTheme } from "@emotion/react";
import { Theme } from "@notesnook/theme";
@@ -552,3 +553,4 @@ export const WindowRestore = createIcon(
);
export const WindowClose = createIcon(mdiWindowClose);
export const ClearCache = createIcon(mdiBroom);
+export const OpenInNew = createIcon(mdiOpenInNew);
diff --git a/apps/web/src/components/note/index.tsx b/apps/web/src/components/note/index.tsx
index 0e752e9c6..9a402da66 100644
--- a/apps/web/src/components/note/index.tsx
+++ b/apps/web/src/components/note/index.tsx
@@ -50,7 +50,8 @@ import {
RemoveShortcutLink,
Plus,
Copy,
- Tag as TagIcon
+ Tag as TagIcon,
+ OpenInNew
} from "../icons";
import TimeAgo from "../time-ago";
import ListItem from "../list-item";
@@ -430,17 +431,53 @@ const menuItems: (
{
type: "button",
key: "publish",
- isDisabled:
- //!isSynced ||
- !db.monographs.isPublished(note.id) && context?.locked,
+ isDisabled: !db.monographs.isPublished(note.id) && context?.locked,
icon: Publish.path,
title: "Publish",
- isChecked: db.monographs.isPublished(note.id),
- onClick: async () => {
- const isPublished = db.monographs.isPublished(note.id);
- if (isPublished) await useMonographStore.getState().unpublish(note.id);
- else await showPublishView(note, "bottom");
- }
+ menu: db.monographs.isPublished(note.id)
+ ? {
+ items: [
+ {
+ type: "button",
+ key: "open",
+ title: "Open",
+ icon: OpenInNew.path,
+ onClick: async () => {
+ const url = `https://monogr.ph/${note.id}`;
+ window.open(url, "_blank");
+ }
+ },
+ {
+ type: "button",
+ key: "copy-link",
+ title: "Copy link",
+ icon: Copy.path,
+ onClick: async () => {
+ const url = `https://monogr.ph/${note.id}`;
+ await writeToClipboard({
+ "text/plain": url,
+ "text/html": `<a href="${url}">${note.title}</a>`,
+ "text/markdown": `[${note.title}](${url})`
+ });
+ }
+ },
+ {
+ type: "separator",
+ key: "sep"
+ },
+ {
+ type: "button",
+ key: "unpublish",
+ title: "Unpublish",
+ icon: Publish.path,
+ onClick: async () => {
+ await useMonographStore.getState().unpublish(note.id);
+ }
+ }
+ ]
+ }
+ : undefined,
+ onClick: () => showPublishView(note, "bottom")
},
{
type: "button",