From d7de671645a7ae77c04dd9334611dabe8065e06d Mon Sep 17 00:00:00 2001 From: Nikhil Thorat Date: Tue, 13 Feb 2024 18:44:22 -0500 Subject: [PATCH] Change link to selection => copy link to selection. --- .../datasetView/ItemMediaTextContent.svelte | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/web/blueprint/src/lib/components/datasetView/ItemMediaTextContent.svelte b/web/blueprint/src/lib/components/datasetView/ItemMediaTextContent.svelte index 1bca8238..d5cbce44 100644 --- a/web/blueprint/src/lib/components/datasetView/ItemMediaTextContent.svelte +++ b/web/blueprint/src/lib/components/datasetView/ItemMediaTextContent.svelte @@ -605,12 +605,19 @@ if (editor.getAction(idLinkSelection) == null) { editor.addAction({ id: idLinkSelection, - label: '🔗 Link to selection', + label: '🔗 Copy link to selection', contextMenuGroupId: 'navigation_links', // We use ctrl/cmd + K to create a link, which is standard for hyperlinks. keybindings: [monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyK], run: () => { - if (datasetViewStore == null || path == null || field == null || editor == null) return; + if ( + datasetViewStore == null || + path == null || + field == null || + editor == null || + model == null + ) + return; const selection = editor.getSelection(); if (selection == null) return; @@ -621,6 +628,12 @@ startCol: selection.startColumn, endCol: selection.endColumn }); + + // Copy the URL to the clipboard after the store is updated. + navigator.clipboard.writeText(location.href).then(null, () => { + throw Error('Error copying URL to clipboard.'); + }); + editor.setSelection(selection); } });