[Author mode] Insert an element in a textfield

<oXygen/> general issues.
Jorge Fins
Posts: 3

[Author mode] Insert an element in a textfield

Tue Nov 22, 2016 12:51 pm

Hello,

I am trying to find a way to insert easily an <br/> element in a textfield.

I succeeded to add a custom button with an insertfragmentoperation that permits to insert a <br/> in the code.
However, the behaviour really doesn't correspond to what I expect :

- any text already written in this textfield disappears in the author mode (but it remains in the XML file).

- I would like to be able to insert the <br/> element between words, like with the bold button here, for instance https://www.oxygenxml.com/webapp-demo-aws/app/oxygen.html?url=webdav-https%3A%2F%2Fwww.oxygenxml.com%2Fwebapp-demo-aws%2Fplugins-dispatcher%2Fwebdav-server%2Ftei%2FTEI-P5.xml&showSave=true&author=John%20Doe, but it seems I can't insert it on the caret position, even if I have no Xpath expression declared on the Action Menu of the document type association : it is inserted as first or as last child.


Many thanks for any help.
Last edited by Jorge Fins on Tue Nov 22, 2016 4:22 pm, edited 1 time in total.
cristi_talau
Posts: 160

Re: [Author mode] Insert an element in a textfield form

Tue Nov 22, 2016 3:25 pm

Hello,

Let me make sure I understand your use-case:

1. What type of document type are you editing? I would assume XHTML since <br/> is an element specific to XHTML. However, the link that you included in your post points to an TEI document.
2. Are you using a button form control [1] to insert the <br/> element? I would assume yes.
3. You are trying to insert a <br/> element as a child of an <input type="text" /> element. Is that what you call a "textfield"?

If I understood correctly, there are two possible causes for the expected behavior:
1. The XHTML schema does not allow a <br/> to be a child of an <input /> element.
2. The button form control has an "actionContext" property that you need to set to "caret" in order to insert the <br/> at the caret position.

Best,
Critian

[1] https://www.oxygenxml.com/doc/versions/ ... ditor.html
Jorge Fins
Posts: 3

Re: [Author mode] Insert an element in a textfield form

Tue Nov 22, 2016 4:20 pm

1. This is an XML file. The link was just an ex&mple found on the forums of what kind of behaviour I was trying to reproduce.
2. Yes.
3. I am trying to insert a a <br/> to be a child of an <author> XML element (specific to the project) for which I have declared in the linked CSS an oxy_textfield property.


About the causes :
1. I have tried with a DTD that permits this insertion, and also without, with a "false" value to the schemaAware argument. Both methods didn't work.
2. Do you know where this would be and what is the exact value ? The tooltips on the Action Menu of the document type association mention that it should already be on the caret position by default.


Best,
Jorge
cristi_talau
Posts: 160

Re: [Author mode] Insert an element in a textfield

Tue Nov 22, 2016 4:57 pm

Hello,

The default value for "actionContext" [1] is "element". You should specify it explicitely as "caret" in order to insert elements at caret position.

Regarding the text disappearing in Author mode, this is a limitation of the "textfield" form-control. It only renders the first text node in the parent element. You have two alternatives:
1. Use a textArea form control with the "edit" property set to "#content" [2].
2. Use the normal oXygen rendering. You can simulate a textfield by adding a border to the "author" element.

If you can describe more precisely the UI you want to achieve, maybe we can provide better alternatives.

Best,
Cristian

[1] https://www.oxygenxml.com/doc/versions/ ... ditor.html
[2] https://www.oxygenxml.com/doc/versions/ ... ntrol.html
Jorge Fins
Posts: 3

Re: [Author mode] Insert an element in a textfield

Tue Nov 22, 2016 7:35 pm

The textarea solution with a value "<br/>$caret" instead of "<br/>" for the fragment argument is good enough to solve my problem.

Thank you !

Return to “Other Issues”

Who is online

Users browsing this forum: No registered users and 0 guests