Products.TinyMCE 1.3 and RichText fields in custom templates

classic Classic list List threaded Threaded
10 messages Options
Gaudenz Steinlin Gaudenz Steinlin
Reply | Threaded
Open this post in threaded view
|

Products.TinyMCE 1.3 and RichText fields in custom templates


Hi

I discovered a problem with the new Products.TinyMCE beta. If you have a
RichText field in a custom template (like Ploneboard does), then you
don't get TinyMCE if the context does not also have a RichText field.
This is because ConfigurationViewlet.show returns False in this case.

I could override the configuration viewlet in Ploneboard for this case,
but this seems wrong. What's the best way to have TinyMCE in a RichText
field if the context does not provide such a field?

To reproduce install Ploneboard and Products.TinyMCE 1.3-beta2 and
create a new conversation. The comment text field does not have TinyMCE
because this is not a default AT "add view" but a custom template to add
a PloneboardConversation and a PloneboardComment in one go.

Gaudenz

--
Ever tried. Ever failed. No matter.
Try again. Fail again. Fail better.
~ Samuel Beckett ~

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Plone-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-developers
Tom Gross Tom Gross
Reply | Threaded
Open this post in threaded view
|

Re: Products.TinyMCE 1.3 and RichText fields in custom templates

Hi Gaudenz

overriding the ConfigurationViewlet does not sound to wrong for me.
Maybe a matter of personal preference ...

Can you please file a Plone ticket at https://dev.plone.org/ for this.
I'll look into it.

Thanks,
:Tom

Am 30.08.2012 08:39, schrieb Gaudenz Steinlin:

>
> Hi
>
> I discovered a problem with the new Products.TinyMCE beta. If you have a
> RichText field in a custom template (like Ploneboard does), then you
> don't get TinyMCE if the context does not also have a RichText field.
> This is because ConfigurationViewlet.show returns False in this case.
>
> I could override the configuration viewlet in Ploneboard for this case,
> but this seems wrong. What's the best way to have TinyMCE in a RichText
> field if the context does not provide such a field?
>
> To reproduce install Ploneboard and Products.TinyMCE 1.3-beta2 and
> create a new conversation. The comment text field does not have TinyMCE
> because this is not a default AT "add view" but a custom template to add
> a PloneboardConversation and a PloneboardComment in one go.
>
> Gaudenz
>



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Plone-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-developers
Malthe Borch-2 Malthe Borch-2
Reply | Threaded
Open this post in threaded view
|

Re: Products.TinyMCE 1.3 and RichText fields in custom templates

In reply to this post by Gaudenz Steinlin
On 30 August 2012 08:39, Gaudenz Steinlin <[hidden email]> wrote:
> I discovered a problem with the new Products.TinyMCE beta. If you have a
> RichText field in a custom template (like Ploneboard does), then you
> don't get TinyMCE if the context does not also have a RichText field.
> This is because ConfigurationViewlet.show returns False in this case.

I think this is actually what this patch tries to address:

   https://github.com/plone/Products.TinyMCE/pull/28

\malthe

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Plone-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-developers
Gaudenz Steinlin Gaudenz Steinlin
Reply | Threaded
Open this post in threaded view
|

Re: Products.TinyMCE 1.3 and RichText fields in custom templates

In reply to this post by Tom Gross

Hi

Tom Gross <[hidden email]> writes:

> Hi Gaudenz
>
> overriding the ConfigurationViewlet does not sound to wrong for me.
> Maybe a matter of personal preference ...

It does not sound wrong in general if you really want to customize the
configuration. But at least to me it sound wrong to force everyone who
want's to include a RichText editor in their custom template to force to
overrride this viewlet.

>
> Can you please file a Plone ticket at https://dev.plone.org/ for this.
> I'll look into it.

https://dev.plone.org/ticket/13157

I took the liberty to assign it to you. Feel free to change that if you
don't agree.

Gaudenz

>
> Thanks,
> :Tom
>
> Am 30.08.2012 08:39, schrieb Gaudenz Steinlin:
>>
>> Hi
>>
>> I discovered a problem with the new Products.TinyMCE beta. If you have a
>> RichText field in a custom template (like Ploneboard does), then you
>> don't get TinyMCE if the context does not also have a RichText field.
>> This is because ConfigurationViewlet.show returns False in this case.
>>
>> I could override the configuration viewlet in Ploneboard for this case,
>> but this seems wrong. What's the best way to have TinyMCE in a RichText
>> field if the context does not provide such a field?
>>
>> To reproduce install Ploneboard and Products.TinyMCE 1.3-beta2 and
>> create a new conversation. The comment text field does not have TinyMCE
>> because this is not a default AT "add view" but a custom template to add
>> a PloneboardConversation and a PloneboardComment in one go.
>>
>> Gaudenz
>>
>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Plone-developers mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/plone-developers

--
Ever tried. Ever failed. No matter.
Try again. Fail again. Fail better.
~ Samuel Beckett ~

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Plone-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-developers
Domen Kožar Domen Kožar
Reply | Threaded
Open this post in threaded view
|

Re: Products.TinyMCE 1.3 and RichText fields in custom templates

JSON configuration for TinyMCE is context/field dependent and needs to be generated for each request. Since response time of the page increase can be noticed without benchmarking, it's impossible to expect it should happen on every page.

Implementing interface marker for request is an easy task, I agree it should be the way to go.

On Mon, Sep 3, 2012 at 11:27 AM, Gaudenz Steinlin <[hidden email]> wrote:

Hi

Tom Gross <[hidden email]> writes:

> Hi Gaudenz
>
> overriding the ConfigurationViewlet does not sound to wrong for me.
> Maybe a matter of personal preference ...

It does not sound wrong in general if you really want to customize the
configuration. But at least to me it sound wrong to force everyone who
want's to include a RichText editor in their custom template to force to
overrride this viewlet.

>
> Can you please file a Plone ticket at https://dev.plone.org/ for this.
> I'll look into it.

https://dev.plone.org/ticket/13157

I took the liberty to assign it to you. Feel free to change that if you
don't agree.

Gaudenz

>
> Thanks,
> :Tom
>
> Am 30.08.2012 08:39, schrieb Gaudenz Steinlin:
>>
>> Hi
>>
>> I discovered a problem with the new Products.TinyMCE beta. If you have a
>> RichText field in a custom template (like Ploneboard does), then you
>> don't get TinyMCE if the context does not also have a RichText field.
>> This is because ConfigurationViewlet.show returns False in this case.
>>
>> I could override the configuration viewlet in Ploneboard for this case,
>> but this seems wrong. What's the best way to have TinyMCE in a RichText
>> field if the context does not provide such a field?
>>
>> To reproduce install Ploneboard and Products.TinyMCE 1.3-beta2 and
>> create a new conversation. The comment text field does not have TinyMCE
>> because this is not a default AT "add view" but a custom template to add
>> a PloneboardConversation and a PloneboardComment in one go.
>>
>> Gaudenz
>>
>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Plone-developers mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/plone-developers

--
Ever tried. Ever failed. No matter.
Try again. Fail again. Fail better.
~ Samuel Beckett ~

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Plone-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-developers


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Plone-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-developers
David Glick (Plone) David Glick (Plone)
Reply | Threaded
Open this post in threaded view
|

Re: Products.TinyMCE 1.3 and RichText fields in custom templates

On 9/3/12 2:33 AM, Domen Kožar wrote:
> JSON configuration for TinyMCE is context/field dependent and needs to
> be generated for each request. Since response time of the page
> increase can be noticed without benchmarking, it's impossible to
> expect it should happen on every page.
>
> Implementing interface marker for request is an easy task, I agree it
> should be the way to go.
>
I doubt that will work, unless the javascript is inserted at the bottom
of the page. (Otherwise the request marker will be getting set by rich
text widgets getting rendered after the head of the page was already
rendered.)

Here is another idea: Always include a small snippet of javascript which
detects whether any tinymce widgets are present, and then dynamically
adds a script tag to load the rest of the (cooked) tinymce js if necessary.

David

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Plone-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-developers
Malthe Borch-2 Malthe Borch-2
Reply | Threaded
Open this post in threaded view
|

Re: Products.TinyMCE 1.3 and RichText fields in custom templates

On 3 September 2012 18:29, David Glick (Plone) <[hidden email]> wrote:
> Here is another idea: Always include a small snippet of javascript which
> detects whether any tinymce widgets are present, and then dynamically
> adds a script tag to load the rest of the (cooked) tinymce js if necessary.

That's not a bad idea.

But please be aware that there's already a fix committed. I think it
will solve most people's problems. It's waiting for review but should
land in a TinyMCE package near you shortly.

\malthe

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Plone-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-developers
Gaudenz Steinlin Gaudenz Steinlin
Reply | Threaded
Open this post in threaded view
|

Re: Products.TinyMCE 1.3 and RichText fields in custom templates

Malthe Borch <[hidden email]> writes:

> On 3 September 2012 18:29, David Glick (Plone) <[hidden email]> wrote:
>> Here is another idea: Always include a small snippet of javascript which
>> detects whether any tinymce widgets are present, and then dynamically
>> adds a script tag to load the rest of the (cooked) tinymce js if necessary.
>
> That's not a bad idea.
>
> But please be aware that there's already a fix committed. I think it
> will solve most people's problems. It's waiting for review but should
> land in a TinyMCE package near you shortly.

If you are refering to https://github.com/headnet/Products.TinyMCE (aka
https://github.com/plone/Products.TinyMCE/pull/28) this does not fix the
issue in Ploneboard (tested). As far as I understand the changes they just
restructure the way how dexterity forms are detected and add support for
formlib forms. But for everything else this does not work either.

Gaudenz

--
Ever tried. Ever failed. No matter.
Try again. Fail again. Fail better.
~ Samuel Beckett ~

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Plone-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-developers
Malthe Borch-2 Malthe Borch-2
Reply | Threaded
Open this post in threaded view
|

Re: Products.TinyMCE 1.3 and RichText fields in custom templates

On 3 September 2012 23:02, Gaudenz Steinlin <[hidden email]> wrote:
> If you are refering to https://github.com/headnet/Products.TinyMCE (aka
> https://github.com/plone/Products.TinyMCE/pull/28) this does not fix the
> issue in Ploneboard (tested). As far as I understand the changes they just
> restructure the way how dexterity forms are detected and add support for
> formlib forms. But for everything else this does not work either.

It no longer checks against Dexterity, but simply z3c.form.

But maybe I don't understand what the issue is.

\malthe

--
Au revoir, et tous mes voeux pour un avenir plein de succès et de bonheur ––

Malthe Borch
[hidden email]

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Plone-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-developers
Gaudenz Steinlin Gaudenz Steinlin
Reply | Threaded
Open this post in threaded view
|

Re: Products.TinyMCE 1.3 and RichText fields in custom templates

Malthe Borch <[hidden email]> writes:

> On 3 September 2012 23:02, Gaudenz Steinlin <[hidden email]> wrote:
>> If you are refering to https://github.com/headnet/Products.TinyMCE (aka
>> https://github.com/plone/Products.TinyMCE/pull/28) this does not fix the
>> issue in Ploneboard (tested). As far as I understand the changes they just
>> restructure the way how dexterity forms are detected and add support for
>> formlib forms. But for everything else this does not work either.
>
> It no longer checks against Dexterity, but simply z3c.form.
>
> But maybe I don't understand what the issue is.

It's probably easiest to explain this by example:
Products/Ploneboard/skins/ploneboard_templates/add_conversation_form.cpt
indirectly (via a macro in add_comment_form.cpt) contains:

              <tal:editor define="inputname  string:text;
                                  formname   string:add_comment_form;
                                  inputvalue text;
                                  cooked_inputvalue string:;
                                  tabindex   nothing">
                <div metal:use-macro="context/wysiwyg_support/macros/wysiwygEditorBox">
                  The WYSIWYG code
                </div>
              </tal:editor>

This should include the WYSIWYG editor. But the usual context of this
form is a PloneboardForum object which while it is an AT content type
does not include a field with a RichText widget. Therefore the TinyMCE
JS code is not included. But this form is neither z3c.form, nor Dexterity,
nor anything else ConfigurationViewlet.show checks for. Hope this makes
the problem clear.

Gaudenz

--
Ever tried. Ever failed. No matter.
Try again. Fail again. Fail better.
~ Samuel Beckett ~

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Plone-developers mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/plone-developers