Unify modals
This commit is contained in:
@@ -1,10 +1,3 @@
|
||||
function newPage() {
|
||||
const name = prompt('New page name:');
|
||||
if (!name || !name.trim()) return;
|
||||
const slug = name.trim().replace(/\s+/g, '-');
|
||||
window.location.href = window.location.pathname + slug + '/?edit';
|
||||
}
|
||||
|
||||
(function () {
|
||||
document.addEventListener('keydown', function (e) {
|
||||
if (!e.altKey || !e.shiftKey) return;
|
||||
@@ -12,11 +5,15 @@ function newPage() {
|
||||
case 'E':
|
||||
e.preventDefault();
|
||||
window.location.href = window.location.pathname + '?edit';
|
||||
break;
|
||||
break;
|
||||
case 'N':
|
||||
e.preventDefault();
|
||||
newPage();
|
||||
break;
|
||||
e.preventDefault();
|
||||
if (typeof newPage === 'function') newPage();
|
||||
break;
|
||||
case 'M':
|
||||
e.preventDefault();
|
||||
if (window.location.pathname !== '/' && typeof movePage === 'function') movePage();
|
||||
break;
|
||||
}
|
||||
});
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user