Page 1 of 1

Create a new HTML resource and insert a reference to it

Posted: Tue Mar 29, 2022 6:03 pm
by NicoAMP
Hello,

I manage a HTML table of content and I would like to implement an action that permit to create a new file and insert a reference on it in the TOC content.
I saw that following dialog exist, but I don't know how to invoke it in javascript in my framework and get the result URL.
It's a similar behavior than when you click on "Create a new DITA resource and insert a reference to it" in DITA toolbar.
image.png
image.png (84.32 KiB) Viewed 1842 times
Thanks for any help.

Regards,
Nicolas

Re: Create a new HTML resource and insert a reference to it

Posted: Thu Mar 31, 2022 12:15 pm
by mihaela
Hello,

The dialog displayed when the "Create a new DITA resource and insert a reference to it" action is invoked is not API but you can create your own dialog. You can use the "Template Chooser" component that is provided in template-chooser.html resource. For example, you can see it on our demo server here (you can also find it on your server at the similar location):
https://www.oxygenxml.com/oxygen-xml-we ... ooser.html

In your dialog you can insert the Template Chooser in an iframe, and then listen to the CustomEvent (of 'templateChooserEvent' type) that is triggered when the user selects a template. This event will provide you details about the selected template and its content request URL.

The dialog should also contain the field for file name. When the dialog is closed you can invoke an operation that inserts a fragment in the document.
ro.sync.ecss.extensions.commons.operations.InsertFragmentOperation
To invoke the operation you can use the following API:
https://www.oxygenxml.com/maven/com/oxy ... on__anchor

Best Regards,
Mihaela

Re: Create a new HTML resource and insert a reference to it

Posted: Mon Apr 04, 2022 12:58 pm
by NicoAMP
Hello Mihaela,

Thanks a lot for your answer.

Now I understand well how to insert a template chooser, get the URL and insert a reference.
What I don't understand is how create the new file in my CCMS?

Thanks.
Regards,
Nicolas

Re: Create a new HTML resource and insert a reference to it

Posted: Tue Apr 05, 2022 5:14 pm
by cristi_talau
Hello,

Once you have the URL of the file to be created and the content of the template, you can invoke a Java AuthorOperation that creates the file.

We have a sample plugin that reads a file from the CMS [1]. This code can be adapted to write the file instead of reading it [2].

Best,
Cristian

[1] https://github.com/oxygenxml/web-author ... le-as-text
[2] https://github.com/oxygenxml/web-author ... e.java#L32

Re: Create a new HTML resource and insert a reference to it

Posted: Tue Jun 21, 2022 11:51 am
by NicoAMP
Thanks Cristian for your answer.