From a19e6f26e151b159f20fd7ed86938e0baedf7f20 Mon Sep 17 00:00:00 2001 From: Frederik Date: Thu, 13 Jun 2019 14:29:14 +0200 Subject: [PATCH 1/2] Use CTRL+Enter on Linux (#121) Currently, there's only "Windows and "not Windows", which makes all non-Windows platforms behave like Mac (i.e., they have a meta key.). That's unfortunately not very true. Instead, I'd suggest use the apple meta key on platforms that are known to be Mac and support CTRL+Enter on all other platforms (Linux, Unix, etc.) --- client/js/dpaste.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/js/dpaste.js b/client/js/dpaste.js index c75d32c..560e980 100644 --- a/client/js/dpaste.js +++ b/client/js/dpaste.js @@ -3,8 +3,8 @@ // ----------------------------------------------------------------------------- // Add data-platform to the body tag to show platform related shortcuts // ----------------------------------------------------------------------------- -const isWindows = navigator.appVersion.indexOf('Win') !== -1; -document.body.dataset.platform = isWindows ? 'win' : 'mac'; +const isMac = navigator.platform.indexOf('Mac') !== -1; +document.body.dataset.platform = isMac ? 'mac' : 'win'; // ----------------------------------------------------------------------------- // Autofocus the content field on the homepage @@ -18,7 +18,7 @@ if (af !== null) { // Cmd+Enter or Ctrl+Enter submits the form // ----------------------------------------------------------------------------- document.body.onkeydown = function(e) { - const metaKey = isWindows ? e.ctrlKey : e.metaKey; + const metaKey = isMac ? e.metaKey : e.ctrlKey; const form = document.querySelector('.snippet-form'); if (form && e.keyCode === 13 && metaKey) { @@ -141,4 +141,4 @@ if (editSnippetLink && editSnippetForm) { editSnippetForm.getBoundingClientRect().y ); }; -} \ No newline at end of file +} From bb8664a1a16818419edaf1c487bab91cae7040ac Mon Sep 17 00:00:00 2001 From: Martin Mahner Date: Thu, 13 Jun 2019 14:33:44 +0200 Subject: [PATCH 2/2] Update CHANGELOG.rst --- CHANGELOG.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 906ad30..882aebc 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -5,6 +5,7 @@ Changelog ------------- - "Edit Snippet" panel is now hidden by default to remove visual noise. +- Linux/Unix browsers now use Ctrl+Enter as a shortcut to submit the form. - Added a dedicated "Copy Snippet" button to copy the content to the clipboard. - Added "View Raw" option to optionally render the 'raw' snippet content with a template rather served as plain text. This was added to hinder abuse.