Page 1 of 1
Prevent Pasting
Posted: Wed Sep 26, 2012 11:45 am
by neon096
I'm trying to prevent a user pasting over a mandatory heading. I've tried using the AuthorDocumentFilter.insertFragment but this is too late in the call hierarchy. So I'm now using AuthorSchemaAwareEditingHandlerAdapter.handlePaste however the API suggests the selection removal has already been removed before the method call. The question I have is how do I put the selection back?
Re: Prevent Pasting
Posted: Wed Sep 26, 2012 12:25 pm
by neon096
Please note that the following doesn't seem to work.
Code: Select all
access.getDocumentController().getUndoManager().undo();
Re: Prevent Pasting
Posted: Wed Sep 26, 2012 3:13 pm
by Radu
Hi Neil,
Your
AuthorSchemaAwareEditingHandlerAdapter.handlePaste() code gets called while a compound edit is still opened (in order to have the Undo action undo all changes, both delete and insert).
Please try to use this API method to cancel the edit:
Code: Select all
ro.sync.ecss.extensions.api.AuthorDocumentController.cancelCompoundEdit()
The method should also undo the deletion of the selection.
Regards,
Radu