diff --git a/packages/editor/src/toolbar/floating-menus/hover-popup/link.tsx b/packages/editor/src/toolbar/floating-menus/hover-popup/link.tsx index 6ced57d53..f357794b0 100644 --- a/packages/editor/src/toolbar/floating-menus/hover-popup/link.tsx +++ b/packages/editor/src/toolbar/floating-menus/hover-popup/link.tsx @@ -34,7 +34,7 @@ function LinkHoverPopup(props: HoverPopupProps) { return ( . */ import { + mdiApplicationCogOutline, + mdiArrowDown, + mdiArrowExpandDown, + mdiArrowExpandLeft, + mdiArrowExpandRight, + mdiArrowExpandUp, + mdiArrowLeft, + mdiArrowUp, mdiAttachment, mdiBorderHorizontal, + mdiCameraOutline, mdiCheck, + mdiCheckboxMarkedOutline, mdiChevronDown, + mdiChevronLeft, + mdiChevronRight, + mdiChevronUp, + mdiCircle, + mdiClipboardOutline, + mdiClose, mdiCodeBraces, mdiCodeTags, + mdiContentSaveOutline, + mdiDeleteOutline, mdiDotsVertical, + mdiDownloadOutline, + mdiDrag, + mdiEyeOutline, + mdiFileTreeOutline, mdiFormatAlignCenter, mdiFormatAlignJustify, mdiFormatAlignLeft, mdiFormatAlignRight, mdiFormatBold, mdiFormatClear, + mdiFormatColorFill, mdiFormatColorHighlight, mdiFormatColorText, + mdiFormatFont, + mdiFormatFontSizeIncrease, + mdiFormatHeaderPound, + mdiFormatIndentDecrease, + mdiFormatIndentIncrease, mdiFormatItalic, + mdiFormatLetterCase, + mdiFormatLetterMatches, mdiFormatListBulleted, + mdiFormatListCheckbox, mdiFormatListNumbered, mdiFormatQuoteClose, mdiFormatStrikethrough, @@ -43,78 +74,47 @@ import { mdiFormatTextdirectionLToR, mdiFormatTextdirectionRToL, mdiFormatUnderline, + mdiFullscreen, + mdiFunctionVariant, + mdiImageEditOutline, + mdiImageOutline, mdiInvertColorsOff, + mdiLink, + mdiLinkOff, mdiLinkPlus, mdiLoading, + mdiMathIntegral, + mdiMinus, + mdiMovieCogOutline, + mdiMoviePlusOutline, + mdiNewspaper, + mdiNotificationClearAll, + mdiOpenInNew, + mdiPageNextOutline, + mdiPaletteOutline, + mdiPlus, + mdiProgressAlert, + mdiProgressDownload, + mdiRegex, + mdiResizeBottomRight, + mdiSortBoolAscendingVariant, + mdiSortDescending, mdiTable, mdiTableBorder, - mdiTableRowPlusAfter, - mdiTableRowPlusBefore, - mdiTableRowRemove, + mdiTableCog, mdiTableColumnPlusAfter, mdiTableColumnPlusBefore, mdiTableColumnRemove, - mdiUploadOutline, - mdiPlus, - mdiFormatColorFill, - mdiClose, - mdiSortDescending, - mdiArrowExpandRight, - mdiArrowExpandLeft, - mdiArrowExpandDown, - mdiArrowExpandUp, - mdiTableMergeCells, - mdiTableSplitCell, - mdiDeleteOutline, - mdiDownloadOutline, - mdiFormatListCheckbox, - mdiDrag, - mdiCheckboxMarkedOutline, - mdiChevronUp, - mdiArrowUp, - mdiArrowDown, - mdiRegex, - mdiFormatLetterCase, - mdiFormatLetterMatches, - mdiMoviePlusOutline, - mdiLink, - mdiChevronRight, mdiTableColumnWidth, - mdiTableRowHeight, - mdiMinus, - mdiPaletteOutline, - mdiCircle, - mdiChevronLeft, - mdiTableCog, + mdiTableMergeCells, mdiTableOff, - mdiImageEditOutline, - mdiArrowLeft, - mdiMovieCogOutline, - mdiLinkOff, - mdiOpenInNew, - mdiCameraOutline, - mdiMathIntegral, - mdiFunctionVariant, - mdiFileTreeOutline, - mdiFormatFont, - mdiFormatFontSizeIncrease, - mdiFormatHeaderPound, - mdiFormatIndentIncrease, - mdiFormatIndentDecrease, - mdiResizeBottomRight, - mdiImageOutline, - mdiProgressDownload, - mdiProgressAlert, - mdiContentSaveOutline, - mdiClipboardOutline, - mdiNotificationClearAll, - mdiNewspaper, - mdiFullscreen, - mdiWeb, - mdiPageNextOutline, - mdiSortBoolAscendingVariant, - mdiApplicationCogOutline, - mdiEyeOutline + mdiTableRowHeight, + mdiTableRowPlusAfter, + mdiTableRowPlusBefore, + mdiTableRowRemove, + mdiTableSplitCell, + mdiUploadOutline, + mdiWeb } from "@mdi/js"; export const Icons = { @@ -144,6 +144,7 @@ export const Icons = { link: mdiLinkPlus, linkRemove: mdiLinkOff, openLink: mdiOpenInNew, + copyLink: mdiClipboardOutline, openSource: mdiWeb, webClip: mdiNewspaper, simplifyWebClip: mdiPageNextOutline, diff --git a/packages/editor/src/toolbar/tool-definitions.ts b/packages/editor/src/toolbar/tool-definitions.ts index ce0c836c3..d90c8e615 100644 --- a/packages/editor/src/toolbar/tool-definitions.ts +++ b/packages/editor/src/toolbar/tool-definitions.ts @@ -60,6 +60,11 @@ const tools: Record = { title: "Open link", conditional: true }, + copyLink: { + icon: "copyLink", + title: "Copy link", + conditional: true + }, linkSettings: { icon: "linkSettings", title: "Link settings", diff --git a/packages/editor/src/toolbar/tools/index.ts b/packages/editor/src/toolbar/tools/index.ts index 6be37cdea..a0112c0af 100644 --- a/packages/editor/src/toolbar/tools/index.ts +++ b/packages/editor/src/toolbar/tools/index.ts @@ -81,7 +81,14 @@ import { EmbedProperties, EmbedSettings } from "./embed"; -import { AddLink, EditLink, RemoveLink, LinkSettings, OpenLink } from "./link"; +import { + AddLink, + EditLink, + RemoveLink, + LinkSettings, + OpenLink, + CopyLink +} from "./link"; import { WebClipFullScreen, WebClipSettings, @@ -103,6 +110,7 @@ const tools = { addLink: AddLink, editLink: EditLink, removeLink: RemoveLink, + copyLink: CopyLink, linkSettings: LinkSettings, openLink: OpenLink, insertBlock: InsertBlock, diff --git a/packages/editor/src/toolbar/tools/link.tsx b/packages/editor/src/toolbar/tools/link.tsx index 418c86df4..cad7b3785 100644 --- a/packages/editor/src/toolbar/tools/link.tsx +++ b/packages/editor/src/toolbar/tools/link.tsx @@ -41,7 +41,7 @@ export function LinkSettings(props: ToolProps) { autoOpen autoCloseOnUnmount popupId="linkSettings" - tools={["openLink", "editLink", "removeLink"]} + tools={["openLink", "editLink", "removeLink", "copyLink"]} /> ); } @@ -247,6 +247,27 @@ export function OpenLink(props: ToolProps) { ); } +export function CopyLink(props: ToolProps) { + const { editor, selectedNode: _selectedNode } = props; + const selectedNode = useRefValue( + _selectedNode || selectionToOffset(editor.state) + ); + const { node } = selectedNode.current || {}; + const link = node ? findMark(node, "link") : null; + if (!link) return null; + const href = link?.attrs.href; + + return ( + { + editor.commands.copyToClipboard(href); + }} + /> + ); +} + export type LinkDefinition = { href?: string; text?: string;