Skip to content

Instantly share code, notes, and snippets.

@basyura
Created May 24, 2020 04:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save basyura/71b17f9ff1c0852699465fd474ec5368 to your computer and use it in GitHub Desktop.
Save basyura/71b17f9ff1c0852699465fd474ec5368 to your computer and use it in GitHub Desktop.
inkdrop.commands.add(document.body, "mycmd:toggle-distraction-free", () => {
const sidebar = document.querySelector(".sidebar-layout");
const notelist = document.querySelector(".note-list-bar-layout");
// toggle to min header
if (sidebar != null || notelist != null) {
if (sidebar != null) {
inkdrop.commands.dispatch(document.body, "view:toggle-distraction-free");
} else if (notelist != null) {
inkdrop.commands.dispatch(document.body, "view:toggle-distraction-free");
inkdrop.commands.dispatch(document.body, "view:toggle-distraction-free");
}
document.querySelector(".editor-meta-layout").style.display = "none";
document.querySelector(".editor-title-input").style.paddingLeft = "70px";
// to drug
const header = document.querySelector(".editor-header-layout");
header.style.minHeight = "5px";
for (const el of Array.from(header.children)) {
el.style.display = "none";
}
return;
}
// toggle to normal header
inkdrop.commands.dispatch(document.body, "view:toggle-distraction-free");
restoreHeader();
});
inkdrop.commands.add(document.body, "mycmd:toggle-sidebar", () => {
inkdrop.commands.dispatch(document.body, "view:toggle-sidebar");
const notelist = document.querySelector(".note-list-bar-layout");
// toggle to normal header
if (notelist != null) {
restoreHeader();
}
});
function restoreHeader() {
document.querySelector(".editor-meta-layout").style.display = "";
document.querySelector(".editor-title-input").style.paddingLeft = "";
const header = document.querySelector(".editor-header-layout");
header.style.minHeight = "40px";
for (const el of Array.from(header.children)) {
el.style.display = "";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment