mirror of
https://github.com/outline/outline.git
synced 2025-04-13 15:43:14 +00:00
Add 'Copy as link' option to menu
closes OLN-141
This commit is contained in:
@ -50,6 +50,7 @@ import {
|
||||
newDocumentPath,
|
||||
searchPath,
|
||||
documentPath,
|
||||
urlify,
|
||||
} from "~/utils/routeHelpers";
|
||||
|
||||
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({
|
||||
name: ({ t }) => t("New nested 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({
|
||||
name: ({ t, isContextMenu }) =>
|
||||
isContextMenu ? t("Duplicate") : t("Duplicate document"),
|
||||
@ -909,6 +934,7 @@ export const rootDocumentActions = [
|
||||
deleteDocument,
|
||||
importDocument,
|
||||
downloadDocument,
|
||||
copyDocumentLink,
|
||||
copyDocumentAsMarkdown,
|
||||
starDocument,
|
||||
unstarDocument,
|
||||
|
@ -43,6 +43,7 @@ import {
|
||||
createDocumentFromTemplate,
|
||||
createNestedDocument,
|
||||
shareDocument,
|
||||
copyDocument,
|
||||
} from "~/actions/definitions/documents";
|
||||
import useActionContext from "~/hooks/useActionContext";
|
||||
import useCurrentUser from "~/hooks/useCurrentUser";
|
||||
@ -293,6 +294,7 @@ function DocumentMenu({
|
||||
actionToMenuItem(openDocumentHistory, context),
|
||||
actionToMenuItem(openDocumentInsights, context),
|
||||
actionToMenuItem(downloadDocument, context),
|
||||
actionToMenuItem(copyDocument, context),
|
||||
actionToMenuItem(printDocument, context),
|
||||
{
|
||||
type: "separator",
|
||||
|
@ -20,8 +20,6 @@
|
||||
"Open document": "Open document",
|
||||
"New document": "New document",
|
||||
"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",
|
||||
"Publish": "Publish",
|
||||
"Published {{ documentName }}": "Published {{ documentName }}",
|
||||
@ -40,6 +38,11 @@
|
||||
"Markdown": "Markdown",
|
||||
"Download": "Download",
|
||||
"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 document": "Duplicate document",
|
||||
"Copy document": "Copy document",
|
||||
@ -84,7 +87,6 @@
|
||||
"Log out": "Log out",
|
||||
"Mark notifications as read": "Mark notifications as read",
|
||||
"Restore revision": "Restore revision",
|
||||
"Copy link": "Copy link",
|
||||
"Link copied": "Link copied",
|
||||
"Dark": "Dark",
|
||||
"Light": "Light",
|
||||
@ -297,7 +299,6 @@
|
||||
"Copied to clipboard": "Copied to clipboard",
|
||||
"Code": "Code",
|
||||
"Comment": "Comment",
|
||||
"Copy": "Copy",
|
||||
"Create link": "Create link",
|
||||
"Sorry, an error occurred creating the link": "Sorry, an error occurred creating the link",
|
||||
"Create a new doc": "Create a new doc",
|
||||
@ -322,7 +323,6 @@
|
||||
"Info": "Info",
|
||||
"Info notice": "Info notice",
|
||||
"Link": "Link",
|
||||
"Link copied to clipboard": "Link copied to clipboard",
|
||||
"Highlight": "Highlight",
|
||||
"Type '/' to insert": "Type '/' to insert",
|
||||
"Keep typing to filter": "Keep typing to filter",
|
||||
|
Reference in New Issue
Block a user