Add 'Copy as link' option to menu
closes OLN-141
This commit is contained in:
@@ -50,6 +50,7 @@ import {
|
|||||||
newDocumentPath,
|
newDocumentPath,
|
||||||
searchPath,
|
searchPath,
|
||||||
documentPath,
|
documentPath,
|
||||||
|
urlify,
|
||||||
} from "~/utils/routeHelpers";
|
} from "~/utils/routeHelpers";
|
||||||
|
|
||||||
export const openDocument = createAction({
|
export const openDocument = createAction({
|
||||||
@@ -114,23 +115,6 @@ export const createDocumentFromTemplate = createAction({
|
|||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const copyDocumentAsMarkdown = createAction({
|
|
||||||
name: ({ t }) => t("Copy as Markdown"),
|
|
||||||
section: DocumentSection,
|
|
||||||
icon: <CopyIcon />,
|
|
||||||
keywords: "clipboard",
|
|
||||||
visible: ({ activeDocumentId }) => !!activeDocumentId,
|
|
||||||
perform: ({ stores, activeDocumentId, t }) => {
|
|
||||||
const document = activeDocumentId
|
|
||||||
? stores.documents.get(activeDocumentId)
|
|
||||||
: undefined;
|
|
||||||
if (document) {
|
|
||||||
copy(MarkdownHelper.toMarkdown(document));
|
|
||||||
toast.success(t("Markdown copied to clipboard"));
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
export const createNestedDocument = createAction({
|
export const createNestedDocument = createAction({
|
||||||
name: ({ t }) => t("New nested document"),
|
name: ({ t }) => t("New nested document"),
|
||||||
analyticsName: "New document",
|
analyticsName: "New document",
|
||||||
@@ -452,6 +436,47 @@ export const downloadDocument = createAction({
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const copyDocumentAsMarkdown = createAction({
|
||||||
|
name: ({ t }) => t("Copy as Markdown"),
|
||||||
|
section: DocumentSection,
|
||||||
|
keywords: "clipboard",
|
||||||
|
visible: ({ activeDocumentId }) => !!activeDocumentId,
|
||||||
|
perform: ({ stores, activeDocumentId, t }) => {
|
||||||
|
const document = activeDocumentId
|
||||||
|
? stores.documents.get(activeDocumentId)
|
||||||
|
: undefined;
|
||||||
|
if (document) {
|
||||||
|
copy(MarkdownHelper.toMarkdown(document));
|
||||||
|
toast.success(t("Markdown copied to clipboard"));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const copyDocumentLink = createAction({
|
||||||
|
name: ({ t }) => t("Copy link"),
|
||||||
|
section: DocumentSection,
|
||||||
|
keywords: "clipboard",
|
||||||
|
visible: ({ activeDocumentId }) => !!activeDocumentId,
|
||||||
|
perform: ({ stores, activeDocumentId, t }) => {
|
||||||
|
const document = activeDocumentId
|
||||||
|
? stores.documents.get(activeDocumentId)
|
||||||
|
: undefined;
|
||||||
|
if (document) {
|
||||||
|
copy(urlify(documentPath(document)));
|
||||||
|
toast.success(t("Link copied to clipboard"));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export const copyDocument = createAction({
|
||||||
|
name: ({ t }) => t("Copy"),
|
||||||
|
analyticsName: "Copy document",
|
||||||
|
section: DocumentSection,
|
||||||
|
icon: <CopyIcon />,
|
||||||
|
keywords: "clipboard",
|
||||||
|
children: [copyDocumentLink, copyDocumentAsMarkdown],
|
||||||
|
});
|
||||||
|
|
||||||
export const duplicateDocument = createAction({
|
export const duplicateDocument = createAction({
|
||||||
name: ({ t, isContextMenu }) =>
|
name: ({ t, isContextMenu }) =>
|
||||||
isContextMenu ? t("Duplicate") : t("Duplicate document"),
|
isContextMenu ? t("Duplicate") : t("Duplicate document"),
|
||||||
@@ -909,6 +934,7 @@ export const rootDocumentActions = [
|
|||||||
deleteDocument,
|
deleteDocument,
|
||||||
importDocument,
|
importDocument,
|
||||||
downloadDocument,
|
downloadDocument,
|
||||||
|
copyDocumentLink,
|
||||||
copyDocumentAsMarkdown,
|
copyDocumentAsMarkdown,
|
||||||
starDocument,
|
starDocument,
|
||||||
unstarDocument,
|
unstarDocument,
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ import {
|
|||||||
createDocumentFromTemplate,
|
createDocumentFromTemplate,
|
||||||
createNestedDocument,
|
createNestedDocument,
|
||||||
shareDocument,
|
shareDocument,
|
||||||
|
copyDocument,
|
||||||
} from "~/actions/definitions/documents";
|
} from "~/actions/definitions/documents";
|
||||||
import useActionContext from "~/hooks/useActionContext";
|
import useActionContext from "~/hooks/useActionContext";
|
||||||
import useCurrentUser from "~/hooks/useCurrentUser";
|
import useCurrentUser from "~/hooks/useCurrentUser";
|
||||||
@@ -293,6 +294,7 @@ function DocumentMenu({
|
|||||||
actionToMenuItem(openDocumentHistory, context),
|
actionToMenuItem(openDocumentHistory, context),
|
||||||
actionToMenuItem(openDocumentInsights, context),
|
actionToMenuItem(openDocumentInsights, context),
|
||||||
actionToMenuItem(downloadDocument, context),
|
actionToMenuItem(downloadDocument, context),
|
||||||
|
actionToMenuItem(copyDocument, context),
|
||||||
actionToMenuItem(printDocument, context),
|
actionToMenuItem(printDocument, context),
|
||||||
{
|
{
|
||||||
type: "separator",
|
type: "separator",
|
||||||
|
|||||||
@@ -20,8 +20,6 @@
|
|||||||
"Open document": "Open document",
|
"Open document": "Open document",
|
||||||
"New document": "New document",
|
"New document": "New document",
|
||||||
"New from template": "New from template",
|
"New from template": "New from template",
|
||||||
"Copy as Markdown": "Copy as Markdown",
|
|
||||||
"Markdown copied to clipboard": "Markdown copied to clipboard",
|
|
||||||
"New nested document": "New nested document",
|
"New nested document": "New nested document",
|
||||||
"Publish": "Publish",
|
"Publish": "Publish",
|
||||||
"Published {{ documentName }}": "Published {{ documentName }}",
|
"Published {{ documentName }}": "Published {{ documentName }}",
|
||||||
@@ -40,6 +38,11 @@
|
|||||||
"Markdown": "Markdown",
|
"Markdown": "Markdown",
|
||||||
"Download": "Download",
|
"Download": "Download",
|
||||||
"Download document": "Download document",
|
"Download document": "Download document",
|
||||||
|
"Copy as Markdown": "Copy as Markdown",
|
||||||
|
"Markdown copied to clipboard": "Markdown copied to clipboard",
|
||||||
|
"Copy link": "Copy link",
|
||||||
|
"Link copied to clipboard": "Link copied to clipboard",
|
||||||
|
"Copy": "Copy",
|
||||||
"Duplicate": "Duplicate",
|
"Duplicate": "Duplicate",
|
||||||
"Duplicate document": "Duplicate document",
|
"Duplicate document": "Duplicate document",
|
||||||
"Copy document": "Copy document",
|
"Copy document": "Copy document",
|
||||||
@@ -84,7 +87,6 @@
|
|||||||
"Log out": "Log out",
|
"Log out": "Log out",
|
||||||
"Mark notifications as read": "Mark notifications as read",
|
"Mark notifications as read": "Mark notifications as read",
|
||||||
"Restore revision": "Restore revision",
|
"Restore revision": "Restore revision",
|
||||||
"Copy link": "Copy link",
|
|
||||||
"Link copied": "Link copied",
|
"Link copied": "Link copied",
|
||||||
"Dark": "Dark",
|
"Dark": "Dark",
|
||||||
"Light": "Light",
|
"Light": "Light",
|
||||||
@@ -297,7 +299,6 @@
|
|||||||
"Copied to clipboard": "Copied to clipboard",
|
"Copied to clipboard": "Copied to clipboard",
|
||||||
"Code": "Code",
|
"Code": "Code",
|
||||||
"Comment": "Comment",
|
"Comment": "Comment",
|
||||||
"Copy": "Copy",
|
|
||||||
"Create link": "Create link",
|
"Create link": "Create link",
|
||||||
"Sorry, an error occurred creating the link": "Sorry, an error occurred creating the link",
|
"Sorry, an error occurred creating the link": "Sorry, an error occurred creating the link",
|
||||||
"Create a new doc": "Create a new doc",
|
"Create a new doc": "Create a new doc",
|
||||||
@@ -322,7 +323,6 @@
|
|||||||
"Info": "Info",
|
"Info": "Info",
|
||||||
"Info notice": "Info notice",
|
"Info notice": "Info notice",
|
||||||
"Link": "Link",
|
"Link": "Link",
|
||||||
"Link copied to clipboard": "Link copied to clipboard",
|
|
||||||
"Highlight": "Highlight",
|
"Highlight": "Highlight",
|
||||||
"Type '/' to insert": "Type '/' to insert",
|
"Type '/' to insert": "Type '/' to insert",
|
||||||
"Keep typing to filter": "Keep typing to filter",
|
"Keep typing to filter": "Keep typing to filter",
|
||||||
|
|||||||
Reference in New Issue
Block a user