- I have checked the troubleshooting
Environment
- Platform: Arch Linux
- Platform version: Kernel 5.14.18
- App Version: 5.4.3
Question
I found the post on adding a template and then got a bit carried away on wanting to change a couple of things for my end, just hit a bit of a wall on how to achieve exactly what I want.
-
I want to create a new note from a template and spawn the note on a new window regardless of where I am in the app, I got this to work exactly how I would like. However, I can’t get it to switch to editor mode, so if I’m in preview mode on the main window, the new window opens in preview mode. Not sure how to change that behavior so the new window opens in editor mode.
-
I would also like to have the main window switch to preview mode whenever I open an existing note, regardless of the mode I was in previously. In the majority of cases, when I edit a note I open it on a new window so that I can use the main window to reference other notes I have. However, not exactly sure how to achieve this or if it’s even possible.
I have the code below for the template action mentioned in point 1. I tried adding the view:toggle-preview
but that toggles the main window and not the new window.
inkdrop.commands.add(document.body, "custom:new-writeup", async () => {
const db = inkdrop.main.dataStore.getLocalDB()
const template = await db.notes.get("note:fSolNc8jV")
const note = {
...template,
_id: db.notes.createId(),
_rev: undefined,
title: "Untitled Writeup",
createdAt: +new Date(),
updatedAt: +new Date(),
pinned: false,
}
try {
await db.notes.put(note)
inkdrop.commands.dispatch(document.body, "core:open-note-in-separate-window", {
noteId: note._id,
})
inkdrop.commands.dispatch(document.body, "editor:focus-mde")
} catch (e) {
console.error(e)
}
})