Page 1 of 1

Undo operation is not giving previous changes completely

Posted: Wed Sep 07, 2022 12:16 pm
by SmitaPatil
Hi Team,
I am replacing the tag name and after that removing the attributes in one operation only, but when I am trying to undo it, I am able to get previous tag name but not the attributes of it.
I am using beginCompoundEdit() and endCompoundEdit(); to make this action as single operation.

Example :
Before changes :
image.png
After changes :
image.png
After doing Undo :
image.png
As it is getting executed as single operation it should give previous tag name with attributes.
Can you please let us know why its not undoing the operation properly.

Thanks,
Smita

Re: Undo operation is not giving previous changes completely

Posted: Wed Sep 07, 2022 12:43 pm
by mihaela
Hello,
You have to use the ro.sync.ecss.extensions.api.AuthorDocumentController.setAttribute(String, AttrValue, AuthorElement) API to set attributes for an element and to make sure that undo/redo will function properly.

You can also use AuthorDocumentController.setMultipleDistinctAttributes(int, int[], List<Map<String, AttrValue>>) or AuthorDocumentController.setMultipleAttributes(int, int[], Map<String, AttrValue>) to set multiple attributes once.

Best regards,
Mihaela

Re: Undo operation is not giving previous changes completely

Posted: Wed Sep 07, 2022 2:45 pm
by SmitaPatil
Hi Mihaela,

I have developed one custom plugin to renaming tag name and after that removing attribute, if I do undo It is just displaying previous tag name not the attribute. (Attached the screenshot last time)
I am saying about this undo
image.png
which is present in Oxygen web author.
If I click on this undo it is just giving the previous tag name not the previous attribute.
Can you please check and let me know?
Please let me know if you have any questions.


Thanks & Regards,
Smita

Re: Undo operation is not giving previous changes completely

Posted: Wed Sep 07, 2022 3:26 pm
by mihaela
Hello,

What API method do you use to remove the attribute?

Best Regards,
Mihaela

Re: Undo operation is not giving previous changes completely

Posted: Thu Sep 08, 2022 9:21 am
by mihaela
Hi,

If you used ro.sync.ecss.extensions.api.node.AuthorElement.removeAttribute(String) you have to change the code to use the ro.sync.ecss.extensions.api.AuthorDocumentController.removeAttribute(String, AuthorElement) API.
The reason is that the first method must be used only when the element is from an {@link AuthorDocumentFragment} and not from the current Author document content. All operations on nodes from the document model must be done using the AuthorDocumentController methods (and they will be subject to undo/redo).

Best Regards,
Mihaela

Re: Undo operation is not giving previous changes completely

Posted: Thu Sep 08, 2022 2:22 pm
by SmitaPatil
Hi Mihaela,
Thank you so much.

Thanks,
Smita