Page 1 of 1

DnD DTD aware

Posted: Fri Jul 06, 2018 5:37 pm
by nhenel_sog
Hi all,
I'm trying to make a Drag And Drop component.
I have a special view with drag and dropable elements, inserting xml fragment, an AuthorDndListener working fine and DTD.
But I don't found how check if my fragment is authorizzed in my DnD in the AuthorDndListener.authorDragOver method.
Could you help me again, please ?

Sincerely,
Nhenel

Re: DnD DTD aware

Posted: Mon Jul 09, 2018 7:52 am
by Radu
Hi Nhenel,

You can use an API like this:

Code: Select all

authorAccess.getDocumentController().getAuthorSchemaManager().canInsertDocumentFragment(fragment, offset, validationMode)
https://www.oxygenxml.com/InstData/Edit ... nager.html

The alternative would be to allow the drag over for any offset but when actually inserting the dropped XML fragment to insert it schema aware:

Code: Select all

ro.sync.ecss.extensions.api.AuthorDocumentController.insertFragmentSchemaAware(int, AuthorDocumentFragment)
meaning that the fragment may not be inserted exactly at the caret position, but in a position where it is allowed.

You can create an AuthorDocumentFragment from an XML string using this API:

Code: Select all

ro.sync.ecss.extensions.api.AuthorDocumentController.createNewDocumentFragmentInContext(String, int)
Regards,
Radu