feat(pastes): allow form submission using Ctrl/Cmd + S

Signed-off-by: SphericalKat <amolele@gmail.com>
This commit is contained in:
Amogh Lele 2021-10-07 06:08:25 +05:30
parent 8f4672b516
commit 1d0b8cc4d5
No known key found for this signature in database
GPG Key ID: F0EA64BC1B44A7F3

View File

@ -1,4 +1,12 @@
<%= form_for @changeset, @action, [class: "flex flex-col w-full h-full relative"], fn f -> %>
<%= form_for @changeset, @action, [class: "flex flex-col w-full h-full relative", id: "page_form"], fn f -> %>
<script>
document.addEventListener("keydown", function(e) {
if ((window.navigator.platform.match("Mac") ? e.metaKey : e.ctrlKey) && e.keyCode == 83) {
e.preventDefault();
document.getElementById("page_form").submit()
}
}, false);
</script>
<%= if @changeset.action do %>
<div class="w-full text-center bg-amber">
<p>Oops, something went wrong!</p>