Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

## Unreleased

### Fixed

- Broken shortcut behaviour when <kbd>ctrl</kbd>/<kbd>meta</kbd> is pressed.
This was previously handled correctly for <kbd>c</kbd> but not for the others.
- Use the paste key to correctly set the window target, i.e. going to raw view
from Markdown view works.


## 3.6.1

Expand Down
35 changes: 21 additions & 14 deletions crates/wastebin_server/src/javascript/paste.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,40 @@ function copy() {
}

function onKey(e) {
if (e.keyCode == 27) {
const overlay = document.getElementById("overlay");
if (overlay && overlay.style.display == "block") {
overlay.style.display = "none";
}
return;
}

if (e.ctrlKey || e.metaKey) {
return;
}

const pasteId = document.body.dataset.pasteId;

if (e.key == 'n') {
window.location.href = "/";
}
else if (e.key == 'r') {
window.location.href = "/raw" + window.location.pathname;
else if (e.key == 'r' && pasteId) {
window.location.href = "/raw/" + pasteId;
}
else if (e.key == 'y') {
navigator.clipboard.writeText(window.location.href);
showToast("Copied URL", 1500);
}
else if (e.key == 'd') {
window.location.href = "/dl" + window.location.pathname;
else if (e.key == 'd' && pasteId) {
window.location.href = "/dl/" + pasteId;
}
else if (e.key == 'q') {
window.location.href = "/qr" + window.location.pathname;
else if (e.key == 'q' && pasteId) {
window.location.href = "/qr/" + pasteId;
}
else if (e.key == 'p') {
window.location.href = window.location.href.split("?")[0];
}
else if (e.key == 'c' && !(e.ctrlKey || e.metaKey)) {
else if (e.key == 'c') {
copy();
}
else if (e.key == 'w') {
Expand All @@ -109,13 +123,6 @@ function onKey(e) {
else if (e.key == '?') {
toggleOverlay();
}

if (e.keyCode == 27) {
const overlay = document.getElementById("overlay");
if (overlay && overlay.style.display == "block") {
overlay.style.display = "none";
}
}
}

function buildOverlay() {
Expand Down
2 changes: 1 addition & 1 deletion crates/wastebin_server/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<noscript><link rel="stylesheet" href="{{ page.assets.css.no_js.route() }}"></noscript>
{% block head %}{% endblock %}
</head>
<body>
<body{% block body_attrs %}{% endblock %}>
{% block body %}
<div id="main-container">
<header>
Expand Down
2 changes: 2 additions & 0 deletions crates/wastebin_server/templates/paste.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<script defer src="{{ page.assets.paste_js.route() }}"></script>
{% endblock %}

{% block body_attrs %} data-paste-id="{{ key }}"{% endblock %}

{% block nav_actions %}
{% if is_available %}
{% if can_delete %}
Expand Down
Loading