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

Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
vitorhugovm
Posts: 31
Joined: Fri Jan 26, 2024 3:31 pm

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

Post 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
mihaela
Posts: 504
Joined: Wed May 20, 2009 2:40 pm

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

Post 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
Mihaela Calotescu
http://www.oxygenxml.com
vitorhugovm
Posts: 31
Joined: Fri Jan 26, 2024 3:31 pm

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

Post 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
Bogdan Dumitru
Site Admin
Posts: 163
Joined: Tue Mar 20, 2018 5:28 pm

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

Post 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.
Bogdan Dumitru
http://www.oxygenxml.com
Post Reply