[kupu-dev] kupu filtering "class" attribute from links
Duncan Booth
duncan.booth at suttoncourtenay.org.uk
Mon Feb 25 15:56:02 CET 2008
Rick Moore <rem63 at cornell.edu> wrote:
> I posted this on the plone-users web site and ttried looking at
> kupubasetools,js and kupucontentfilters.js as suggested. I am not a
> javascript programmer, so I was somewhat bewildered by what I found. It
> seems that kupubasetools.js specifically allows the "class" attribute
> for practically everything. But then the code in LinkTool seems to want
> to strip it out if it wasn't set by the one of the link buttons in the
> kupu UI.
It isn't so much that the LinkTool strips it out: when you edit a link in
kupu it sets the class explicitly to 'external-link' or 'internal-link' (at
least it does in 1.4, I can't remember what it did in earlier versions.
The class should however remain unchanged unless you actually edit it.
> I need somewhat explicit help in figuring this out. Is there anyone who
> can tell me where the class attribute gets stripped out of links and how
> I can fix it. I have no aversion to upgrading to a later rev of kupu if
> that will help. And I'd be willing to add a special link button if
> that's what it takes, just don't know how.
Upgrading to 1.4 can only be a good thing whether or not you have problems.
For external links it should be easy enough to change in kupudrawers.js,
find linkel.getAttribute('href') and somewhere round there pick up any
existing classname and strip out 'external-link' if present and save in
this.saveclass. Then when saving set the class to 'external-link
'+this.savedclass, likewise for internal links the current class could be
saved in createContent and restored later.
More information about the kupu-dev
mailing list