Forum OpenACS Q&A: Re: xowiki Folder Object

Collapse
10: Re: xowiki Folder Object (response to 9)
Posted by Gustaf Neumann on
here is an example to define the toolbar:
http://alice.wu-wien.ac.at:8000/xowiki-doc/#js

just tried it, and everthings seems ok to me...

Collapse
12: Re: xowiki Folder Object (response to 10)
Posted by Richard Hamilton on
Gustaf,

Yes, I know that in the instance widgetspec parameter it will work just fine (I have studied that section of your docs, and that is my fallback).

I was trying to include a spec in a specific formField specification - in the form constraints of an ::xowiki:Form

It is in that context that the issue with the '[', the ']', and the ',' crops up!

:-)

Thanks for the reply.

Regards
Richard

Collapse
14: Re: xowiki Folder Object (response to 12)
Posted by Gustaf Neumann on
I see, you want to configure xinha for a certain form_field via the form constraints. Since in the form-constraints the fields are separated via comma, these have to be coded as __COMMA__. The following should work:

{_text:richtext,editor=xinha,javascript=
xinha_config.toolbar = [
['popupeditor'__COMMA__ 'bold'__COMMA__'italic'__COMMA__'createlink'__COMMA__'insertimage'__COMMA__'separator']__COMMA__
['killword'__COMMA__'removeformat']
];
}

Collapse
Posted by Richard Hamilton on
I have spent ages tryting to do this and have so far failed. It must be me, but I cannot for the life of me see where the problem lies.

Here is my instance parameter spec:

*,text {richtext(richtext),nospell,optional
  {label Content}
  {html {style {width: 100%}}}
  {options {editor xinha plugins {Stylist OacsFs} height 350px javascript {

  xinha_config.toolbar = [
    ['popupeditor', 'bold','italic','createlink','insertimage','separator'],
    ['killword','removeformat']
  ];

  xinha_config.stylistLoadStylesheet('/resources/xowiki/examples/xinha-mc-styles.css',
  {'p.angabe' : 'Aufgabenstellung',
  'p.loesungshinweis' : 'Lösungshinweis',
  'li.correct_choice' : 'Richtige Antwort',
  'li.incorrect_choice' : 'Falsche Antwort'});
  }}}}

Here is my ::form::Field spec:

{main_page_content:richtext,label=Other Content}

Here is the rendered page source:

  <script type="text/javascript" src="/resources/acs-templating/xinha-nightly/XinhaCore.js"></script>

  <script type="text/javascript">
        xinha_editors = null;
        xinha_init = null;
        xinha_config = null;
        xinha_plugins = null;
        xinha_init = xinha_init ? xinha_init : function() {
            xinha_plugins = xinha_plugins ? xinha_plugins :
              ['GetHtml', 'CharacterMap', 'ContextMenu', 'ListType', 'TableOperations', 'EditTag', 'LangMarks', 'Abbreviation'];

Regards
Richard

Collapse
15: Re: xowiki Folder Object (response to 14)
Posted by Richard Hamilton on
Gustaf,

Thank you for the reply. The __COMMA__ substitution is extremely helpful thankyou.

For the sake of completeness I wanted to let you know that the above proposed notation (i.e. with square brackets) does not in fact work because the '[' and ']' fail the form validation checks in xowiki.

However, this notation works:

{main_page_content:richtext,editor=xinha,label=Content,plugins=Stylist OacsFs,javascript=xinha_config.toolbar=new Array(new Array('popupeditor')__COMMA__new Array('separator'__COMMA__'textindicator'));}

This is exactly what I wanted to achieve, however it still pains me that I cannot work out why the more general widgetspec parameter specification method doesn't work for me.

Regards
Richard

Collapse
16: Re: xowiki Folder Object (response to 15)
Posted by Gustaf Neumann on
glad, that this works. The form constraints are obviously not the best way to pass javascript. On the longer range, we should find a better way of providing these. The formfields contain already a "slim" configuration for xinha, and the way should be to extend this further.

Concerning square brackets for javascript arrays: i have tested the example above (14) before posting, and it works nicely.

Collapse
17: Re: xowiki Folder Object (response to 16)
Posted by Richard Hamilton on
Gustaf,

That is strange. I have just tried this again by creating a test form with a single field on it. I have copied your code from the forum post and I receive this error:

Error in field Form Constraints: Form constraint contains invalid characters

Could it be that the form validation on my setup is different for some reason? Is your form validation set to the default?

Content:  @test_var@

Form:  <form>@test_var@</form>

Form Constraints:  {test_var:richtext,editor=xinha,javascript=
xinha_config.toolbar = [
    ['popupeditor'__COMMA__ 'bold'__COMMA__'italic'__COMMA__'createlink'__COMMA__'insertimage'__COMMA__'separator']__COMMA__
    ['killword'__COMMA__'removeformat']
  ];
}

Regards
Richard

Collapse
18: Re: xowiki Folder Object (response to 17)
Posted by Gustaf Neumann on
you are right, it should complain, but does not on my local machine... i have always a lot of experimental code hanging around, so there must be somewhere a bad interaction...
-gustaf
Collapse
19: Re: xowiki Folder Object (response to 16)
Posted by Richard Hamilton on
I was just today re-visiting my confusion on this issue. I think I finally understand that the Xowiki instance 'Xinha WidgetSpec' parameter only configures Xinha for the forms used to create or edit xowiki objects.

I now finally understand that adding a xinha config to a formfield spec is the only way currently to configure the editor for Xowiki.Form fields.

In my current experiment, where I have several textarea fields that all need xinha activated with the same configuration, this is very verbose and repetitive.

It would be great to have the ability to set a default spec for xinha for use when filling-out/ creating instances of Xowiki.Forms.

regards
Richard

Collapse
20: Re: xowiki Folder Object (response to 19)
Posted by Richard Hamilton on