This is not a bug with Stacks, it’s just the way it works, however Isaiah can probably give us the content without forcing the current item to finish it’s edit. @isaiah What do you think?
I think it’s do-able, but I think there are probably some really fundamental performance issues that we’re going to hit right out of the gate – which is not a really good look.
Edit/Preview have traditionally been modal. Even RW7’s live browser preview only updated on focus changes and saves.
Changing that behavior is probably no big deal for a markdown page – but even a modest Stacks page takes noticeable time to export. Adding the expectation that previews are happening while the user types seems like it would be encouraging users to expect it to be nearly immediate.
We could probably do a lot better, if we thought about the bottlenecks between RW/Stacks and tried to smooth them out a bit.
Right now preview and publish are handled with the same RW API calls. Those API calls pass a context object (params) that tells the plugin how to export images and generate links. These params can (and do) change from one call to
contentHTML to the next.
This means the content passed back to preview can’t be cached. And oh man oh man have I tried.
Stacks edit mode improves that in a bunch of ways:
- It only regenerates the content near the edit.
- Links/paths are static from one generation to the next – so can be cached.
- NSImages are passed with a NSURLProtocol callback which fetches the image data directly rather then writing out an image to disk and having the web view read it from disk immediately after.
I think in order to make user edits preview in roughly real-time we’ll need to add RW API calls that a tailored to preview mode that are more easily cache-able. or… thinking really outside the box here… really change up how preview content is updated.
instead of having the update loop look like this:
plugin: broadcast page changed
rw: request content from plugin
plugin: render content
rw: replace all content in preview
make it look more like:
plugin broadcastPluginChangedWithPreviewDOMNode:(NSString *)html
plugin: broadcast DOM node changed – with change
rw: replace just that DOM node in preview
with a fallback to do the regular stuff when necessary