I implemented an object to embed websites into visual canvas files in the notes app I'm building. image The website objects are live, meaning that if the user double-clicks on an object, they can scroll, zoom, select text, and click links - just as they would in a real browser. I need to show the actual website inside the minimap in the bottom-left corner. Currently, it just shows a dark box with a Safari logo. #dev #Swift #SwiftUI #AppKit #macOS

Replies (3)

Regarding the website objects in the minimap, I haven’t decided how I want to implement it yet. Of course, I could just embed another `WKWebView` in the minimap, but then I would be duplicating the same twice, which seems unnecessarily resource intensive… Therefore, I’m considering a different approach where the app should take a snapshot of the website and then show that in the minimap. The minimap is so small that it does not really matter anyways. When user clicks the web object, then deselect it again, the app should take a new snapshot. I think that’s the way to go. The question is if we have five web objects in the canvas, that would be five different `WKWebView`’s which might also be resource intensive. So perhaps I should also replace the web objects in the canvas with a snapshot when user is not interacting with the object. This means, when user clicks a web object or maybe hovers it, the snapshot is replaced with the real webview. But this approach is only good if it is super quick, so that it feels natural. Otherwise it just leads to a bad UX if it takes too long for the snapshot to be replaced with the webview… will need to experiment with this.
I want the infinite canvas to be the perfect tool I envision for brainstorming ideas.
At some point, I’ll need to work on folders. Think it would be nice to have the ability to group objects into a folder.