From fdf7a2d3d3118809c223b291c52353d7bdaaf5e6 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 29 Jul 2023 16:24:25 +0200 Subject: [PATCH 1/6] Fix clipboard copy on insecure origin --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 87288565bc943..8ef6ffca808a7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "add-asset-webpack-plugin": "2.0.1", "ansi_up": "5.2.1", "asciinema-player": "3.5.0", - "clippie": "4.0.1", + "clippie": "4.0.2", "css-loader": "6.8.1", "dropzone": "6.0.0-beta.2", "easymde": "2.18.0", @@ -3118,9 +3118,9 @@ } }, "node_modules/clippie": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/clippie/-/clippie-4.0.1.tgz", - "integrity": "sha512-glbCTIRm5gL/vOZ02Dvxa2DXNYrwn8tylBHP3Bz77O1rQ4GMzbzm2Vzv8NYBv1kQYQsHXaUxHBRof8c/f2NXrg==" + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/clippie/-/clippie-4.0.2.tgz", + "integrity": "sha512-kUdELlS2oWum8fNgDgj1Wa2oKKEy+ho+mq3lM5RPIsCnXs3nBMNO9I/FyS1GhFCYYVpX1k3+/2BR4onpiAVbgA==" }, "node_modules/cliui": { "version": "7.0.4", diff --git a/package.json b/package.json index 571de3acf526b..91edc54d6d954 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "add-asset-webpack-plugin": "2.0.1", "ansi_up": "5.2.1", "asciinema-player": "3.5.0", - "clippie": "4.0.1", + "clippie": "4.0.2", "css-loader": "6.8.1", "dropzone": "6.0.0-beta.2", "easymde": "2.18.0", From 2643716099b8e648c27d16f4221a5ef3cae04275 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 29 Jul 2023 16:33:00 +0200 Subject: [PATCH 2/6] update once more --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8ef6ffca808a7..2c55ad4dbca61 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "add-asset-webpack-plugin": "2.0.1", "ansi_up": "5.2.1", "asciinema-player": "3.5.0", - "clippie": "4.0.2", + "clippie": "4.0.3", "css-loader": "6.8.1", "dropzone": "6.0.0-beta.2", "easymde": "2.18.0", @@ -3118,9 +3118,9 @@ } }, "node_modules/clippie": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/clippie/-/clippie-4.0.2.tgz", - "integrity": "sha512-kUdELlS2oWum8fNgDgj1Wa2oKKEy+ho+mq3lM5RPIsCnXs3nBMNO9I/FyS1GhFCYYVpX1k3+/2BR4onpiAVbgA==" + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/clippie/-/clippie-4.0.3.tgz", + "integrity": "sha512-iHMiEFCKL11Tnh2RdjHafok9KMreBNKhOSM683XapFCNzIxMIuBX0NJpBemdEabAPEYpn5Iveaw4O5+k/y9H+w==" }, "node_modules/cliui": { "version": "7.0.4", diff --git a/package.json b/package.json index 91edc54d6d954..0ccd020d86b3a 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "add-asset-webpack-plugin": "2.0.1", "ansi_up": "5.2.1", "asciinema-player": "3.5.0", - "clippie": "4.0.2", + "clippie": "4.0.3", "css-loader": "6.8.1", "dropzone": "6.0.0-beta.2", "easymde": "2.18.0", From 5c2d1bc46d998be94e121d01a6ad02df2a11f0ce Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 29 Jul 2023 16:44:58 +0200 Subject: [PATCH 3/6] actually use clippie in attachment link copy --- web_src/js/features/common-global.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/web_src/js/features/common-global.js b/web_src/js/features/common-global.js index 474993045b2b7..6adcf0bd9a285 100644 --- a/web_src/js/features/common-global.js +++ b/web_src/js/features/common-global.js @@ -1,5 +1,6 @@ import $ from 'jquery'; import 'jquery.are-you-sure'; +import {clippie} from 'clippie'; import {createDropzone} from './dropzone.js'; import {initCompColorPicker} from './comp/ColorPicker.js'; import {showGlobalErrorMessage} from '../bootstrap.js'; @@ -7,11 +8,12 @@ import {handleGlobalEnterQuickSubmit} from './comp/QuickSubmit.js'; import {svg} from '../svg.js'; import {hideElem, showElem, toggleElem} from '../utils/dom.js'; import {htmlEscape} from 'escape-goat'; -import {createTippy} from '../modules/tippy.js'; +import {createTippy, showTemporaryTooltip} from '../modules/tippy.js'; import {confirmModal} from './comp/ConfirmModal.js'; import {showErrorToast} from '../modules/toast.js'; const {appUrl, appSubUrl, csrfToken, i18n} = window.config; +const {copy_success, copy_error} = i18n; export function initGlobalFormDirtyLeaveConfirm() { // Warn users that try to leave a page after entering data into a form. @@ -240,7 +242,7 @@ export function initGlobalDropzone() { copyLinkElement.className = 'gt-text-center'; // The a element has a hardcoded cursor: pointer because the default is overridden by .dropzone copyLinkElement.innerHTML = `${svg('octicon-copy', 14, 'copy link')} Copy link`; - copyLinkElement.addEventListener('click', (e) => { + copyLinkElement.addEventListener('click', async (e) => { e.preventDefault(); let fileMarkdown = `[${file.name}](/attachments/${file.uuid})`; if (file.type.startsWith('image/')) { @@ -248,7 +250,8 @@ export function initGlobalDropzone() { } else if (file.type.startsWith('video/')) { fileMarkdown = ``; } - navigator.clipboard.writeText(fileMarkdown); + const success = await clippie(fileMarkdown); + showTemporaryTooltip(e.target, success ? copy_success : copy_error); }); file.previewTemplate.append(copyLinkElement); }); From e71310bcb2763c8ab370bff17ee0811f1286e9a0 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 29 Jul 2023 17:02:27 +0200 Subject: [PATCH 4/6] update once more --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2c55ad4dbca61..89ee2bb684376 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "add-asset-webpack-plugin": "2.0.1", "ansi_up": "5.2.1", "asciinema-player": "3.5.0", - "clippie": "4.0.3", + "clippie": "4.0.4", "css-loader": "6.8.1", "dropzone": "6.0.0-beta.2", "easymde": "2.18.0", @@ -3118,9 +3118,9 @@ } }, "node_modules/clippie": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/clippie/-/clippie-4.0.3.tgz", - "integrity": "sha512-iHMiEFCKL11Tnh2RdjHafok9KMreBNKhOSM683XapFCNzIxMIuBX0NJpBemdEabAPEYpn5Iveaw4O5+k/y9H+w==" + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/clippie/-/clippie-4.0.4.tgz", + "integrity": "sha512-sQs1/5+qqKhCYdrUR201+/A4rYz5+WDitk2HOaRwlYVtnbQ38fvAnTUzWiL3yp4c4WECkSANWZfmg5xvkYU2sQ==" }, "node_modules/cliui": { "version": "7.0.4", diff --git a/package.json b/package.json index 0ccd020d86b3a..d9c52a773fa92 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "add-asset-webpack-plugin": "2.0.1", "ansi_up": "5.2.1", "asciinema-player": "3.5.0", - "clippie": "4.0.3", + "clippie": "4.0.4", "css-loader": "6.8.1", "dropzone": "6.0.0-beta.2", "easymde": "2.18.0", From b55da50439187eb2ceab45ca84cfd1c3c383edcd Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 29 Jul 2023 17:04:07 +0200 Subject: [PATCH 5/6] revert clippie bump so changeset is focused --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 89ee2bb684376..87288565bc943 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "add-asset-webpack-plugin": "2.0.1", "ansi_up": "5.2.1", "asciinema-player": "3.5.0", - "clippie": "4.0.4", + "clippie": "4.0.1", "css-loader": "6.8.1", "dropzone": "6.0.0-beta.2", "easymde": "2.18.0", @@ -3118,9 +3118,9 @@ } }, "node_modules/clippie": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/clippie/-/clippie-4.0.4.tgz", - "integrity": "sha512-sQs1/5+qqKhCYdrUR201+/A4rYz5+WDitk2HOaRwlYVtnbQ38fvAnTUzWiL3yp4c4WECkSANWZfmg5xvkYU2sQ==" + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/clippie/-/clippie-4.0.1.tgz", + "integrity": "sha512-glbCTIRm5gL/vOZ02Dvxa2DXNYrwn8tylBHP3Bz77O1rQ4GMzbzm2Vzv8NYBv1kQYQsHXaUxHBRof8c/f2NXrg==" }, "node_modules/cliui": { "version": "7.0.4", diff --git a/package.json b/package.json index d9c52a773fa92..571de3acf526b 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "add-asset-webpack-plugin": "2.0.1", "ansi_up": "5.2.1", "asciinema-player": "3.5.0", - "clippie": "4.0.4", + "clippie": "4.0.1", "css-loader": "6.8.1", "dropzone": "6.0.0-beta.2", "easymde": "2.18.0", From 084926470606f91474a4f92cbecb7412bd001db9 Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 29 Jul 2023 17:16:55 +0200 Subject: [PATCH 6/6] fix lint --- web_src/js/features/common-global.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/web_src/js/features/common-global.js b/web_src/js/features/common-global.js index 6adcf0bd9a285..be337ee903650 100644 --- a/web_src/js/features/common-global.js +++ b/web_src/js/features/common-global.js @@ -13,7 +13,6 @@ import {confirmModal} from './comp/ConfirmModal.js'; import {showErrorToast} from '../modules/toast.js'; const {appUrl, appSubUrl, csrfToken, i18n} = window.config; -const {copy_success, copy_error} = i18n; export function initGlobalFormDirtyLeaveConfirm() { // Warn users that try to leave a page after entering data into a form. @@ -251,7 +250,7 @@ export function initGlobalDropzone() { fileMarkdown = ``; } const success = await clippie(fileMarkdown); - showTemporaryTooltip(e.target, success ? copy_success : copy_error); + showTemporaryTooltip(e.target, success ? i18n.copy_success : i18n.copy_error); }); file.previewTemplate.append(copyLinkElement); });