Page 1 of 1

Non-modifying custom actions

Posted: Mon Nov 02, 2015 9:47 am
by Patrik
Hi,

I have non-modifying AuthorOperations. To avoid the document being marked as modified after performing the actions I'm setting the it as unmodified explicitly. Since the PseudoClassOperations should have the same problem I'm wondering if there's already a better solution!?

Thanks and regards,

Patrik

Re: Non-modifying custom actions

Posted: Mon Nov 02, 2015 10:19 am
by Radu
Hi Patrik,

We have an undoable edit manager and most of modifications you make to the document are marked as edits and registered in the edit manager in order to have undo/redo support.
The pseudo class change operations are the only operations which do not register edits in the undo manager (as we did not want undo/redo to reset the pseudo class back to the original).
So if your operations perform other changes, you will need to explicitly set the document as modified (if it was not modified before the operation). There is no other way.

Regards,
Radu

Re: Non-modifying custom actions

Posted: Mon Nov 02, 2015 10:42 am
by Patrik
Hi Radu,

I checked again and indeed: opening another file did neither mark the document as modified nor did it add an entry to the undo list. So that's fine.

But calling AuthorDocumentController.refreshNodeReferences() marks the document as modified. And you can undo this operation as well. You might consider this operation not to register edits in the undo manager as well. But it's a minor issue...

Regards,
Patrik

Re: Non-modifying custom actions

Posted: Mon Nov 02, 2015 10:55 am
by Radu
Hi Patrik,

Making the refresh nodes not register undo events in the document is quite hard to do using our current internal architecture.
The entire Author content is a single sequence of characters corresponding to the text nodes. And the hierarchy of Author nodes points in the sequence of characters using the getStartOffset and getEndOffset methods.
Most of the undoable edits remember precise offsets in the content where they need to be re-done or undone. When you refresh the nodes the Author content changes. If that would not be registered as an edit and it would not be undone, when the edit which was done before the nodes refresh would be undone, it would be possible that the offset it remembers in the content as the offset where it needs to be undone would be the wrong one.

Regards,
Radu

Re: Non-modifying custom actions

Posted: Mon Nov 02, 2015 10:59 am
by Patrik
Hi Radu,

I understand, thanks for the explanation.

Patrik