Skip to content

Commit

Permalink
Reload preview window instead of changing location
Browse files Browse the repository at this point in the history
This allow to stay at the same place in the previewed page after the render refresh.
For now it is only working with Ctrl + D, not when clicking the button, as the button
is only a simple link. Later the button could be overriden with javascript to allow
the same behaviour
  • Loading branch information
n-peugnet committed May 10, 2024
1 parent d4d9f90 commit 7a0a3e1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ import shadow from 'leaflet/dist/images/marker-shadow.png';
import * as L from 'leaflet';
import { initWorkspaceForm, submitHandler } from './fn/fn';

/** @var {Window | null} */
let preview = null;

/* ________________ TAGIFY ________________ */

/** @var {HTMLInputElement} */
Expand Down Expand Up @@ -450,7 +453,11 @@ function keyboardHandler(e) {
const a = document.getElementById('display');
const href = a.getAttribute('href');
const target = a.getAttribute('target');
window.open(href, target);
try {
preview.location.reload();
} catch {
preview = window.open(href, target);
}
break;
default:
return true;
Expand Down

0 comments on commit 7a0a3e1

Please sign in to comment.