Page 1 of 1

AuthorEditorAccess.refresh(node) not working inside WSEditorListener.editorAboutToBeSavedVeto

Posted: Mon Jun 24, 2024 10:14 pm
by vitorhugovm
Hello!

I'm trying to perform a refresh in some specific nodes before a document is saved by extending WSEditorListener and overriding the function editorAboutToBeSavedVeto. Inside the overwritten function, some nodes are located by XPath and then an attempt to refresh their CSS is made by using AuthorEditorAccess.refresh(AuthorNode) . Unfortunately nothing happens and the node is not refreshed. Is there any blockage occurring during this process? We are using a framework instead of a plugin.

Thanks!
Vitor

Re: AuthorEditorAccess.refresh(node) not working inside WSEditorListener.editorAboutToBeSavedVeto

Posted: Tue Jun 25, 2024 11:06 am
by mihaela
Hello,

Can you please explain more about your use-case? The refresh will only change the rendering of the element and it will not affect the XML source before saving the document.

Best Regards,
Mihaela

Re: AuthorEditorAccess.refresh(node) not working inside WSEditorListener.editorAboutToBeSavedVeto

Posted: Tue Jun 25, 2024 3:52 pm
by vitorhugovm
Hello Mihaela!

The reason why I want to refresh the node before saving is so a custom renderer could be recalled through oxy_editor in CSS.
I've used the refresh function like this in another cases and it works, but when I use it inside the listener, the custom renderer class is never called.
I'm not sure if the node is really not being refreshed, but this class inside oxy_editor CSS function is definitely not running in this specific moment.

Thanks!
Vitor

Re: AuthorEditorAccess.refresh(node) not working inside WSEditorListener.editorAboutToBeSavedVeto

Posted: Thu Jun 27, 2024 11:03 am
by Bogdan Dumitru
Hello Vitor,

Document changes made within WSEditorListener.editorAboutToBeSavedVeto aren't propagated to the browser directly. The save request doesn't return to the client document updates.
As a workaround you can move your code from WSEditorListener.editorAboutToBeSavedVeto to a custom AuthorOperation and invoke the operation when document gets saved.
When document is saved the sync.api.EditingSupport.EventType.DIRTY_STATUS_CHANGED event is dispatched, so you have to add a DIRTY_STATUS_CHANGED listener and when dirty status gets clean you have to invoke your AuthorOperation.
To invoke an operation see sync.api.ActionsManager.invokeOperation.