Page 1 of 1

surroundFragmentOperation with schemaaware flag set to true is not working as expected.

Posted: Fri Jul 01, 2022 1:13 pm
by shikhar_472
Hi Oxygen Team,

We found the issue with surroundFragmentOperation with schemaaware flag set to true, below is the scenario-
Valid xml as per the xsd would look like

<document>
<title>
<format>
<bold></bold>
<italic></italic>
<underline></underline>
</format>
</title>
</document>
in our example xml looks like below-
<document>
<title>
<bold></bold>
<italic></italic>
<underline></underline>
</title>
</document>

Here our user selects content/xml-elements inside <title> and invokes format operation and we are using surroundFragmentOperation to wrap selected content within the format tag.
But when users selects entire <title> tag including the tag boundaries and invokes format operation we observed the <title> tag itself being wrapped inside <format> tag,
which is not valid as per schema.
surroundFragmentOperation should be able to identify that this is not a valid operation and throw error.
Can you please help us on this scenario.

We are calling surroundFragmentOperation within a plugin like below.


this.editor.getActionsManager().invokeOperation(
'ro.sync.ecss.extensions.commons.operations.SurroundWithFragmentOperation', {
fragment: '<format xmlns="http://www.example.com/article"></format>',
schemaAware: 'true'
});

Thanks,
Shikhar.

Re: surroundFragmentOperation with schemaaware flag set to true is not working as expected.

Posted: Mon Jul 04, 2022 4:48 pm
by mihaela
Hi,

The schemaAware argument of the SurroundWithFragmentOperation applies only when there is no selection in the document (in this case the fragment is inserted at caret position).
If there is a selection in the document, the schemaAware argument is not taken into account:
https://www.oxygenxml.com/InstData/Edit ... ation.html

Best Regards,
Mihaela