« Return to Thread: Question about extending the SimpleDocument to allow the addition of class attributes.

Question about extending the SimpleDocument to allow the addition of class attributes.

by Alex Bleasdale :: Rate this Message:

Reply to Author | View in Thread

Hi,

Can someone help?  I was hoping to be able to extend the (standard) Rich editor that you see with the SimpleDocument part type to allow the saving of class and id attributes.

At the moment, if you create a new SimpleDocument and click on the <> icon to the right, you're allowed to freely enter xhtml markup.  Unfortunately, if you try and add class attributes to, say, p, h[x], or a tags, these classes are all "stripped" from the body content as the document is saved.  So, in this view:

<p class="red">red</p>

becomes:

<p>red</p>

After the document has been saved and re-opened for editing.

I've looked around found this page in the docs (http://www.daisycms.org/daisydocs-2_1/374-cd/499-cd.html)

and it suggests that you can create a file called variables.xml containing something like this:
<variables>

  <variableSources>
    <variableDocument id="6-DSY"/>
  </variableSources>

  <variablesInAttributes allAttributes="false">
    <element name="a" attributes="class, id"/>
    <element name="span" attributes="class, id"/>
    <element name="p" attributes="class, id"/>
    <element name="h3" attributes="class, id"/>
  </variablesInAttributes>

</variables>

Although this still seems to strip out the class attributes once the doc (in this case "6-DSY")  is saved.

So my 2 questions are: 1. is the variables.xml approach the way to do this?  Or is there another way (from reading the docs, is sounded more like variables.xml was supposed to resolve specific values, not allow the use of extra attributes).  

2. If this is the right approach, what else might I need to do if I want to ensure class attributes aren't being deleted on save?  

Also, is there any way to apply rules for all documents in the wiki?  The example seemed to suggest that you need to apply those rules to specific documents (e.g. 6-DSY).  Would there be a way to Extend the SimpleDocument editor to allow someone to write some rich text, then go to the markup view and add some class attributes in and save them knowing they will be preserved?

Thanks in advance for any info/advice.

A

 « Return to Thread: Question about extending the SimpleDocument to allow the addition of class attributes.