Mixing surface.transaction() with document.transaction()
Closed this issue · 7 comments
We have this mixture in archivist and undo/redo behavior is not always right for this. It seems we don't consider the case that the document could have changed without a surface / selection being involved (aka document.transaction())
Try:
- open archivist-writer
- click on a subject bracket
- modify targets of a subject reference
- then undo
(e.g. there's a warning that the surface name can not be determined...)
I just ask me, why you are not using the surface's transaction?
Otherwise, in SurfaceManager you should support DocmentChanges without surface information.
https://github.com/substance/substance/blob/master/src/surface/surface_manager.js#L67
It's likely that there is no active surface. E.g. when you click on a subject bracket and select targets. I'm not sure if we should bind operations to a surface always. I see use-cases where we come up with a custom ui for the info panel that doesn't use a surface at all, but transforms properties in the document. If we consider non-surface actions in general, then the document-change handling doesn't fit into the SurfaceManager either. It's more like... documentController-ish. Would be good to have a pluggable concept though.
I don't see a great potential for a general concept.
It sounds like every application could have custom transactions... then it would be the apps task to do the change dispatching.
Feel free to take SurfaceManager's dispatcher as a start for your own dispatcher.
Ok. But just to clarify: It would be ok from your side to use document.transaction() in an app, when the manipulation is not related with text-editing?
Yes. I think that is just fine...
The surface's transaction is basically only a convenience to setup the before/after selection correctly.
But essentially it is using document.transaction().
When app level information is to be added to the transaction payload, it is not the proper place to do it in surface.
I don't if and how you would want to augment your transactions, so that you can provide a user feedback. We can do pretty much anything, only make sure that the classical editing transactions are still supported.
kk. closing this here, as it doesn't require a change to Substance.