From maxm at mxm.dk Mon Oct 1 12:35:26 2007 From: maxm at mxm.dk (Max M) Date: Mon, 01 Oct 2007 12:35:26 +0200 Subject: [kupu-dev] Avoid filtering of specific attribute In-Reply-To: References: Message-ID: Duncan Booth skrev: > includeTagAttributes('span', 'dynafield:view') > > But I'm not sure that will work or if the unexpected namespace might cause > problems. Turned out that I was close all the time: editor.xhtmlvalid.setTagAttributes(['div','span'],['dynafield:uid','dynafield:view']); editor.xhtmlvalid.setAttrFilter(['dynafield:uid']); editor.xhtmlvalid.setAttrFilter(['dynafield:view']); Det fik det til at k?re. I missed the setAttrFilter at first. I thought that would make it actually do filtering on the attribute not allow it. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science From duncan.booth at suttoncourtenay.org.uk Mon Oct 1 14:59:14 2007 From: duncan.booth at suttoncourtenay.org.uk (Duncan Booth) Date: Mon, 1 Oct 2007 12:59:14 +0000 (UTC) Subject: [kupu-dev] Avoid filtering of specific attribute References: Message-ID: Max M wrote: > Duncan Booth skrev: > >> includeTagAttributes('span', 'dynafield:view') >> > >> But I'm not sure that will work or if the unexpected namespace might >> caus > e >> problems. > > Turned out that I was close all the time: > > editor.xhtmlvalid.setTagAttributes(['div','span'],['dynafield:uid','dyn > afield:view']); editor.xhtmlvalid.setAttrFilter(['dynafield:uid']); > editor.xhtmlvalid.setAttrFilter(['dynafield:view']); > setTagAttributes overrides the permitted attributes for the tag: so you have said that div and span can *only* have your custom attributes. I think you really do need includeTagAttributes (although with the parameters you used for setTagAttributes, not the ones I suggested). > Det fik det til at k?re. I missed the setAttrFilter at first. I > thought that would make it actually do filtering on the attribute not > allow it. It does, it makes it filter the attribute instead of ignoring it. The default filter function just copies the attribute. From maxm at mxm.dk Tue Oct 2 18:51:29 2007 From: maxm at mxm.dk (Max M) Date: Tue, 02 Oct 2007 18:51:29 +0200 Subject: [kupu-dev] Avoid filtering of specific attribute In-Reply-To: References: Message-ID: Duncan Booth skrev: > Max M wrote: > >> Duncan Booth skrev: >> >>> includeTagAttributes('span', 'dynafield:view') >>> >>> But I'm not sure that will work or if the unexpected namespace might >>> caus >> e >>> problems. >> Turned out that I was close all the time: >> >> editor.xhtmlvalid.setTagAttributes(['div','span'],['dynafield:uid','dyn >> afield:view']); editor.xhtmlvalid.setAttrFilter(['dynafield:uid']); >> editor.xhtmlvalid.setAttrFilter(['dynafield:view']); >> > setTagAttributes overrides the permitted attributes for the tag: so you > have said that div and span can *only* have your custom attributes. Hmmm .... yeah well I set it in 'kupuploneinit.js' and if I use includeTagAttributes I get an error: "this.tagAttributes[tag] has no properties" Seems that the attrs are not set at the time where I try to call includeTagAttributes. >> Det fik det til at k?re. I missed the setAttrFilter at first. I >> thought that would make it actually do filtering on the attribute not >> allow it. > > It does, it makes it filter the attribute instead of ignoring it. The > default filter function just copies the attribute. It does not work when I don't do it. But setting the attrfilter like that, also just copies. I guess it probably doesn't work because I use setTagAttributes instead of includeTagAttributes. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science From wouter at netcentric.be Wed Oct 3 21:52:30 2007 From: wouter at netcentric.be (Wouter Vanden Hove) Date: Wed, 03 Oct 2007 21:52:30 +0200 Subject: [kupu-dev] Avoid filtering of specific attribute References: Message-ID: Max M wrote: > Duncan Booth skrev: > >> includeTagAttributes('span', 'dynafield:view') >> >> But I'm not sure that will work or if the unexpected namespace might >> cause problems. > > Turned out that I was close all the time: > > editor.xhtmlvalid.setTagAttributes(['div','span'] ['dynafield:uid','dynafield:view']); > editor.xhtmlvalid.setAttrFilter(['dynafield:uid']); > editor.xhtmlvalid.setAttrFilter(['dynafield:view']); This is the working solution? in kupuinit.js there is: kupu.xhtmlvalid.includeTagAttributes(['div'], ['*']); this would mean that
dynamisk
should be working out-of-the-box? But this doesn't seem to be the case. I have a very similar use-case, trying to get ZPTField working with kupu to enable tags like this: title what is the best way get disable the filtering for this? edit kupucontentfilters.js or kupuinit.js? -- Wouter Vanden Hove Netcentric.be From duncan.booth at suttoncourtenay.org.uk Wed Oct 3 22:37:38 2007 From: duncan.booth at suttoncourtenay.org.uk (Duncan Booth) Date: Wed, 3 Oct 2007 20:37:38 +0000 (UTC) Subject: [kupu-dev] Avoid filtering of specific attribute References: Message-ID: Wouter Vanden Hove wrote: > I have a very similar use-case, trying to get ZPTField working with > kupu to enable tags like this: > title > > what is the best way get disable the filtering for this? > edit kupucontentfilters.js or kupuinit.js? The best thing is to edit your initialisation javascript. Max M implied that he is using the Plone version of kupu, so in his case kupuploneinit.js is the one to edit. YMMV From maxm at mxm.dk Thu Oct 4 13:00:06 2007 From: maxm at mxm.dk (Max M) Date: Thu, 04 Oct 2007 13:00:06 +0200 Subject: [kupu-dev] Avoid filtering of specific attribute In-Reply-To: References: Message-ID: Wouter Vanden Hove skrev: > Max M wrote: > >> Duncan Booth skrev: >> >>> includeTagAttributes('span', 'dynafield:view') >>> >>> But I'm not sure that will work or if the unexpected namespace might >>> cause problems. >> Turned out that I was close all the time: >> >> editor.xhtmlvalid.setTagAttributes(['div','span'] > ['dynafield:uid','dynafield:view']); >> editor.xhtmlvalid.setAttrFilter(['dynafield:uid']); >> editor.xhtmlvalid.setAttrFilter(['dynafield:view']); > > This is the working solution? Not really. Turned out that Duncan was right. That way it only allows those two attributes in divs and spans. So something like the class would be filtered out :-s > I have a very similar use-case, trying to get ZPTField working with kupu to > enable tags like this: > title > > what is the best way get disable the filtering for this? > edit kupucontentfilters.js or kupuinit.js? I will let you know when I find out :-) -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science From maxm at mxm.dk Thu Oct 4 14:01:21 2007 From: maxm at mxm.dk (Max M) Date: Thu, 04 Oct 2007 14:01:21 +0200 Subject: [kupu-dev] Avoid filtering of specific attribute In-Reply-To: References: Message-ID: Wouter Vanden Hove skrev: > what is the best way get disable the filtering for this? > edit kupucontentfilters.js or kupuinit.js? Ok. The only solution I can think of is this: this.initialize = function(editor) { // The initialize method is called automaticaly by Kupu // This is where we add the event handler. this.editor = editor; var allowedAttrs = ['class', 'dynafield:uid','dynafield:view'] var validator = editor.xhtmlvalid; validator.setTagAttributes(['span'],allowedAttrs); validator.setAttrFilter(allowedAttrs); addEventHandler(this.button, 'change', this.execCommand, this); // make the dynafield tags valid. }; This way a span will keep the attributes in 'allowedAttrs'. I could not find another way to set it. includeTagAttributes will not work, as span and div does not have any attributes set to begin with. But on the other hand it is pretty simple to add additional attributes in that list. If this is a hack, so be it. I cannot use more time on the problem now :-s If anybody figures out a more correct approach, please let me know ... -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science From duncan.booth at suttoncourtenay.org.uk Thu Oct 4 17:24:22 2007 From: duncan.booth at suttoncourtenay.org.uk (Duncan Booth) Date: Thu, 4 Oct 2007 15:24:22 +0000 (UTC) Subject: [kupu-dev] Avoid filtering of specific attribute References: Message-ID: Max M wrote: > includeTagAttributes will not work, as span and div does not have any > attributes set to begin with. > That's news to me. They should have a load of attributes set to begin with: kupucontentfilters sets them both up with attributes id, title, style, class, lang, dir, xml:lang, plus align for div but not span. From maxm at mxm.dk Fri Oct 5 11:11:24 2007 From: maxm at mxm.dk (Max M) Date: Fri, 05 Oct 2007 11:11:24 +0200 Subject: [kupu-dev] Avoid filtering of specific attribute In-Reply-To: References: Message-ID: Duncan Booth skrev: > Max M wrote: > >> includeTagAttributes will not work, as span and div does not have any >> attributes set to begin with. >> > > That's news to me. They should have a load of attributes set to begin with: > kupucontentfilters sets them both up with attributes id, title, style, > class, lang, dir, xml:lang, plus align for div but not span. Ok. That makes sense. But if I try to write validator.includeTagAttributes(['span'],allowedAttrs); Instead of validator.setTagAttributes(['span'],allowedAttrs); I get the error this.tagAttributes[tag] has no properties And this happens in kupucontentfilters.js:: // define some new attributes for existing tags this.includeTagAttributes = function(tags, attributes) { for (var j = 0; j < tags.length; j++) { var tag = tags[j]; this.tagAttributes[tag] = this.tagAttributes[tag].concat(attributes); } } So at least when I am trying to call it in kupuploneinit.js in function initPloneKupu(), it is not possible to use includeTagAttributes. Seemably because it has no prior attributes set. -- hilsen/regards Max M, Denmark http://www.mxm.dk/ IT's Mad Science From duncan.booth at suttoncourtenay.org.uk Fri Oct 5 15:38:46 2007 From: duncan.booth at suttoncourtenay.org.uk (Duncan Booth) Date: Fri, 5 Oct 2007 13:38:46 +0000 (UTC) Subject: [kupu-dev] Avoid filtering of specific attribute References: Message-ID: Max M wrote: > So at least when I am trying to call it in kupuploneinit.js in > function initPloneKupu(), it is not possible to use > includeTagAttributes. Seemably because it has no prior attributes set. > Very strange. I just added a line: kupu.xhtmlvalid.includeTagAttributes(['span'],['random']); to kupuploneinit.js right after the line: kupu.setHTMLBody(initialtext); and it works fine for me. I stepped through the code as well, and it all executes quite happily. From robichon at esrf.fr Mon Oct 15 10:53:58 2007 From: robichon at esrf.fr (Marie Robichon) Date: Mon, 15 Oct 2007 10:53:58 +0200 Subject: [kupu-dev] style definition in table of contents Message-ID: Hi everyone, why is it that in the anchor dialog box I have the possibility to select one of my defined styles for the table of contents, but this style is not kept once I have saved my page? Even before saving when I look at the html once I have defined my table I do not see where my style is declared, I just see