Actions at the top of the content completion list

Having trouble deploying Oxygen XML Web Author? Got a bug to report? Post it all here.
Johann
Posts: 199
Joined: Wed Jun 17, 2015 12:46 pm

Actions at the top of the content completion list

Post by Johann »

Hello,

We are using Author web 25.1 version.

We add some actions in the contentCompletion menu with this configuration in the framework file:

Code: Select all

<field name="contextualItems">
	<contextProvider>
		<field name="items">
			<contextItem-array>
				<contextItem>
					<field name="targets">
						<list>
							<Integer>0</Integer>
						</list>
					</field>
					<field name="actionID">
						<String>my.action</String>
					</field>
					<field name="alias">
						<String>My alias</String>
					</field>
					<field name="replacementFor">
						<null/>
					</field>
					<field name="replacedElementNs">
						<String/>
					</field>
					<field name="displayOnlyWhenElementAllowed">
						<Boolean>false</Boolean>
					</field>
					<field name="useReplaceElementName">
						<Boolean>false</Boolean>
					</field>
				</contextItem>
			</contextItem-array>
		</field>
		<field name="removeItems">
			<null/>
		</field>
	</contextProvider>
</field>
It works but is it possible to get some actions always at the top of the content completion list?

Thanks for your help,

Johann
cristi_talau
Posts: 496
Joined: Thu Sep 04, 2014 4:22 pm

Re: Actions at the top of the content completion list

Post by cristi_talau »

Hello,

You can customize the order of the elements presented by the Content Completion Assistant by increasing their priority values. To do this, you should implement the methods exposed in the ContentCompletionSortPriorityAssigner API: https://www.oxygenxml.com/InstData/Edit ... igner.html .

Best,
Cristian
Johann
Posts: 199
Joined: Wed Jun 17, 2015 12:46 pm

Re: Actions at the top of the content completion list

Post by Johann »

Hello Cristian,

Thanks for you reply.

I do not see where to declare the implementation of the ContentCompletionSortPriorityAssigner class.
Can you give me an example?

Regards,

Johann
Bogdan Dumitru
Site Admin
Posts: 142
Joined: Tue Mar 20, 2018 5:28 pm

Re: Actions at the top of the content completion list

Post by Bogdan Dumitru »

Hello Johann,

The ContentCompletionSortPriorityAssigner instance can be returned from a WebappExtensionsProvider implementation, by implementing the WebappExtensionsProvider.getSortPriorityAssigner method.
The WebappExtensionsProvider instance can be returned from an ExtensionsBundle implementation, by implementing the ExtensionsBundle.getWebappExtensionsProvier method.

For the ExtensionsBundle implementation, you might find useful this sample project
Bogdan Dumitru
http://www.oxygenxml.com
Johann
Posts: 199
Joined: Wed Jun 17, 2015 12:46 pm

Re: Actions at the top of the content completion list

Post by Johann »

Hello,

I managed to implement the needed classes.

But, when I log all the CCItemProxy ccItems in the getImposedSortPriority method, it never displays my action.
However, I do see it well in the contentCompletion menu.
Is it due to the way my action is created?

It is both present on the framework side:

Code: Select all

<field name="actionDescriptors">
                                <action-array>
                                    <action>
                                        <field name="id">
                                            <String>angular-media-insert.action</String>
                                        </field>
                                        <field name="name">
                                            <String>Insert media</String>
                                        </field>
                                        <field name="description">
                                            <String>Open a modal</String>
                                        </field>
                                        <field name="largeIconPath">
                                            <String>${framework}/images/Image24.png</String>
                                        </field>
                                        <field name="smallIconPath">
                                            <String>${framework}/images/Image16.png</String>
                                        </field>
                                        <field name="accessKey">
                                            <String/>
                                        </field>
                                        <field name="accelerator">
                                            <null/>
                                        </field>
                                        <field name="actionModes">
                                            <actionMode-array>
                                                <actionMode>
                                                    <field name="xpathCondition">
                                                        <String>oxy:allows-global-element()</String>
                                                    </field>
                                                    <field name="argValues">
                                                        <serializableOrderedMap/>
                                                    </field>
                                                    <field name="operationID">
                                                        <String/>
                                                    </field>
                                                </actionMode>
                                            </actionMode-array>
                                        </field>
                                        <field name="enabledInReadOnlyContext">
                                            <Boolean>false</Boolean>
                                        </field>
                                    </action>
                                </action-array>
                            </field>

Code: Select all

<field name="contextualItems">
                                <contextProvider>
                                    <field name="items">
                                        <contextItem-array>
                                            <contextItem>
                                                <field name="targets">
                                                    <list>
                                                        <Integer>0</Integer>
                                                    </list>
                                                </field>
                                                <field name="actionID">
                                                    <String>angular-media-insert.action</String>
                                                </field>
                                                <field name="alias">
                                                    <null/>
                                                </field>
                                                <field name="replacementFor">
                                                    <null/>
                                                </field>
                                                <field name="replacedElementNs">
                                                    <String/>
                                                </field>
                                                <field name="displayOnlyWhenElementAllowed">
                                                    <Boolean>false</Boolean>
                                                </field>
                                                <field name="useReplaceElementName">
                                                    <Boolean>false</Boolean>
                                                </field>
                                            </contextItem>
                                        </contextItem-array>
                                    </field>
                                    <field name="removeItems">
                                        <null/>
                                    </field>
                                </contextProvider>
                            </field>
But also defined on the js side:

Code: Select all

goog.events.listen(workspace, sync.api.Workspace.EventType.EDITOR_LOADED, function (e) {
  let currentEditor = e.editor;
  let actionId = 'angular-media-insert.action';
  currentEditor.getActionsManager().registerAction(actionId, new IllusListingAction(currentEditor));
});
Thank you,

Johann
Bogdan Dumitru
Site Admin
Posts: 142
Joined: Tue Mar 20, 2018 5:28 pm

Re: Actions at the top of the content completion list

Post by Bogdan Dumitru »

Hello Johann,

The ContentCompletionSortPriorityAssigner API works only for elements, see the JavaDoc: "Extension that can be used to assign sorting priorities for elements". Unfortunately, actions like yours that do not replace elements from content completion aren't affected by this API. Try replacing an element from content completion with this action.
Bogdan Dumitru
http://www.oxygenxml.com
Post Reply