Change the default for inserting elements.

Are you missing a feature? Request its implementation here.
aujunior
Posts: 28
Joined: Thu Feb 16, 2023 11:00 pm

Change the default for inserting elements.

Post by aujunior »

Good afternoon!

Is there a way to capture which element the user has selected and change how it is inserted into the document?

We have elements that will receive information from a webservice and they will have to come from a dialog developed by us. We can create an action for this, however, the elements will still be available in the completion wizard. Would it be possible to add a filter to call a method depending on the selected element?
image.png
image.png (9.46 KiB) Viewed 1762 times
Radu
Posts: 9054
Joined: Fri Jul 09, 2004 5:18 pm

Re: Change the default for inserting elements.

Post by Radu »

Hi,
You can replace items in the content completion window with your own Author actions.
And a custom Author action can call a custom Author operation which you can implement in Java.
Maybe this blog post will help:
https://blog.oxygenxml.com/topics/custo ... etion.html
Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
aujunior
Posts: 28
Joined: Thu Feb 16, 2023 11:00 pm

Re: Change the default for inserting elements.

Post by aujunior »

Thank you very much Radu for your answer. It helped me a lot in understanding what I need to do.

I'm using framework_script.exf and registered some <toolbar> actions. Using javascript I registered the actions of the toolbar in "workspace.listen()".

With your post I saw that I can use the "Content Completion Assistant" to change the behavior of an element coming from the schema, this is exactly what I need.

Is there a way to invoke an Action registered via javascript from the Completion Assistant?

Here's my code:
image.png
image.png (49.89 KiB) Viewed 1742 times
image.png
image.png (17.1 KiB) Viewed 1742 times
image.png
image.png (20.91 KiB) Viewed 1742 times
mihaela
Posts: 490
Joined: Wed May 20, 2009 2:40 pm

Re: Change the default for inserting elements.

Post by mihaela »

Hello,

Your code does exactly what you need: it replaces the element 'table' from the content completion with the 'insert.table' action.
This should work. Can you please give us more details about the problem you encounter using this code?

Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
aujunior
Posts: 28
Joined: Thu Feb 16, 2023 11:00 pm

Re: Change the default for inserting elements.

Post by aujunior »

Discover my mistake...

Missed creating an action on stub tab in the .framework file.

Now it is working correctly.

Thanks a lot for the help and answers.

I will study how to do the same thing when editing attributes.

Would you have an example of how to use the JavaScript sync.actions.AttributeEditingActionsProvider API?
Bogdan Dumitru
Site Admin
Posts: 142
Joined: Tue Mar 20, 2018 5:28 pm

Re: Change the default for inserting elements.

Post by Bogdan Dumitru »

Hi,

See the web-author-custom-attribute-editing-action-plugin that exemplifies the use of sync.actions.AttributeEditingActionsProvider JS API.
Also, you might find it useful to take a look at the other example plugins from the web-author-sample-plugins.
Bogdan Dumitru
http://www.oxygenxml.com
aujunior
Posts: 28
Joined: Thu Feb 16, 2023 11:00 pm

Re: Change the default for inserting elements.

Post by aujunior »

Great!
Thanks Bogdan Dumitru for the example.

I have just 3 more questions on the subject.

1) Is there any way to lock the input text for manual editing when we create an action for the attribute?
I'd like to just let the button be active and the code control the attribute's value.
image.png
image.png (8.92 KiB) Viewed 1566 times

2) Is there a way to call "actionPerformed(currentValue, done)" at the same time as selecting a specific attribute?

3) I used the cc_config.xml file to propose some values ​​for attributes, however, when using "editable=false" Web Author presented an error. Did I use the property in the wrong way?
image.png
image.png (12.77 KiB) Viewed 1566 times
image.png
image.png (26.47 KiB) Viewed 1566 times
Bogdan Dumitru
Site Admin
Posts: 142
Joined: Tue Mar 20, 2018 5:28 pm

Re: Change the default for inserting elements.

Post by Bogdan Dumitru »

Hello,

Regarding #1 and #2, unfortunately, with the currently existing API, you cannot lock the input field when specifying an action and you cannot listen when an attribute value is selected/chosen in the side-view.
Regarding #3, we have an issue on our internal issue tracker for this, WA-6288. How important is this issue for your customization / use-case?

By the way, if you feel the need to heavily customize the built-in attributes side-view notice that you might be able to create a custom Attributes side-view and hide the built-in one. Let us know if you're interested in doing so and we'll guide you to the useful APIs from the Oxygen SDK.
Bogdan Dumitru
http://www.oxygenxml.com
aujunior
Posts: 28
Joined: Thu Feb 16, 2023 11:00 pm

Re: Change the default for inserting elements.

Post by aujunior »

I would like to have the same behavior as Oxygen Desktop.

I create a "valueProposal", the field is disabled for user editing, however it is possible to modify it through "actions".
image.png
image.png (2.02 KiB) Viewed 1409 times
image.png
image.png (1.41 KiB) Viewed 1409 times
image.png
image.png (1.66 KiB) Viewed 1409 times
image.png
image.png (4.54 KiB) Viewed 1409 times

We will see the best way to solve the problem.

Thank you very much.
mihaela
Posts: 490
Joined: Wed May 20, 2009 2:40 pm

Re: Change the default for inserting elements.

Post by mihaela »

Hello,

Thank you for the details, we will update this thread when the fix will be available.

Best Regards,
Mihaela
Mihaela Calotescu
http://www.oxygenxml.com
aujunior
Posts: 28
Joined: Thu Feb 16, 2023 11:00 pm

Re: Change the default for inserting elements.

Post by aujunior »

Hello again!

We decided to create our own sync.view.ViewRenderer.

We created the html fields and realized that we need to put CSS in them.

We already made the CSS to customize the internal XML and pointed it in the classpath, however, this css didn't work for a class created for our customized VIEWRENDERER.

Is there any way to link a css to the custom viewrenderer?
Bogdan Dumitru
Site Admin
Posts: 142
Joined: Tue Mar 20, 2018 5:28 pm

Re: Change the default for inserting elements.

Post by Bogdan Dumitru »

Hello,

The CSS that you've added in the framework applies just to the XML document.
Try using inline CSS styles to customize the rendering for your custom sync.view.ViewRenderer.
Bogdan Dumitru
http://www.oxygenxml.com
Post Reply