How to create new Inkdrop owned browser window

Unlike in V5.6β : How to use an external browser with the open method I’d like to create a new Inkdrop owned browser window so I can transform the content of the current note and render it into this new window. I can’t seem to figure out a way to do this using the electron API but maybe I’m missing something?

For context see Create “render current document”

After a bit more searching, I found that inkdrop.remote exists and can be used to create a new window and display content.

Note: you cannot interact directly with the DOM of this new window and must tell it which URL to navigate to. Luckily you can set data in the url as in the following example:

ink = require('inkdrop')
const win = new ink.remote.BrowserWindow()
win.loadURL("data:text/html;charset=utf-8,<body><h1>hello</h1></body>")

There should also be ways to do this using IPC calls, but I am not familiar with them - if anyone has experience with these, please reply with more information.

Hi John,

Yeah, you can use @electron/remote via inkdrop.remote. It sounds scary to allow plugins to create BrowserWindow though :grimacing:
Maybe I should prohibit remote entirely for security reasons.
Or, it’d be nice to have a permission mechanism for plugins so users can notice those sensitive actions in the future.
Currently, it is fully relied on your goodwill :slight_smile:

Hi Yakuya,

Yes I share your viewpoint on that - a permission model for plugins might be worth it in the long run.

I think this use case warrants it, but I would be interested in hearing your thoughts on it (see link in first message)

1 Like

For what it’s worth, I have a working prototype of this. I’m trying to communicate with users on what functionality they need.

Here’s a link to my implementation

1 Like

Looks neat! :star_struck:
I guess you can call webContents.savePage to save the HTML to disk?

window.webContents.savePage('OUTPUT_PATH', 'HTMLComplete')

also printToPDF and print are available in the webContents class.