Rich text editor empty check

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Rich text editor empty check

dennis.vis
Good day,

I'm trying to check if a 'webrichtlijnen' rich text editor is empty, but it never is. I noticed that when a user empties the editor a <p>&nbsp;</p> remeains. I have read this blog post and this issue on the subject. Therefore I have adjusted my jsp like so:

<hst:html hippohtml="${document.html}" var="intro" />
 <c:if test="${not empty intro}">
   <div class="intro"><hst:html hippohtml="${document.html}"/></div>
 </c:if>

However, this does not work. The intro div is still shown. How should I go about fixing this?

Kind regards,

Dennis Vis
Consultant | Incentro Rotterdam

Fascinatio Boulevard 562-4
Capelle aan den IJssel, The Netherlands, 2909 VA


E: [hidden email]
T: +31102020544
M: +31640801868
W: www.incentro.com
Logo Incentro

_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: Rich text editor empty check

Laurens Leeuwis

We encountered this problem during several projects as well. Wat we did is create a new tag function:

 

 /**
     * Checks if a HippoHTML field is empty.
     * e.g.:
     *   <hst:html hippohtml="${document.html}" var="intro" />
     *      <c:if test="${not myTag:isEmpty(intro)}">
     *
     * @param hippohtml the parsed hippo html field
     * @return true if empty, false otherwise
     */
    public static Boolean isEmpty(String hippohtml){
        // parse the html field, and check if text or images are present
        Document doc = Jsoup.parse(hippohtml);
        String htmlText = doc.body().text();
        boolean noText = (htmlText == null || htmlText.replaceAll("<a href="file://\\p{Zs}&quot;,&quot;&quot;).isEmpty">\\p{Zs}","").isEmpty());
        boolean noImages = doc.body().getElementsByTag("img").isEmpty();

        return noText && noImages;
    }

 

 

it is quite an expensive method I guess; and it needs Jsoup as a dependency

 


Van: [hidden email] [[hidden email]] namens Dennis Vis [[hidden email]]
Verzonden: vrijdag 18 januari 2013 11:13
To: Hippo CMS 7 implementation list
Onderwerp: [Hippo-cms7-user] Rich text editor empty check

Good day,

I'm trying to check if a 'webrichtlijnen' rich text editor is empty, but it never is. I noticed that when a user empties the editor a <p>&nbsp;</p> remeains. I have read this blog post and this issue on the subject. Therefore I have adjusted my jsp like so:

<hst:html hippohtml="${document.html}" var="intro" />
 <c:if test="${not empty intro}">
   <div class="intro"><hst:html hippohtml="${document.html}"/></div>
 </c:if>

However, this does not work. The intro div is still shown. How should I go about fixing this?

Kind regards,

Dennis Vis
Consultant | Incentro Rotterdam

Fascinatio Boulevard 562-4
Capelle aan den IJssel, The Netherlands, 2909 VA


E: [hidden email]
T: +31102020544
M: +31640801868
W: www.incentro.com
Logo Incentro

This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: Rich text editor empty check

Frank van Lankvelt
wouldn't it make more sense to store this information in the hippostd:html node?  E.g. as a separate property, derived when the content is saved.  It should be straightforward to make this part of the RichTextModel in the CMS.

cheers, Frank


On Fri, Jan 18, 2013 at 11:24 AM, Leeuwis, Laurens <[hidden email]> wrote:

We encountered this problem during several projects as well. Wat we did is create a new tag function:

 

 /**
     * Checks if a HippoHTML field is empty.
     * e.g.:
     *   <hst:html hippohtml="${document.html}" var="intro" />
     *      <c:if test="${not myTag:isEmpty(intro)}">
     *
     * @param hippohtml the parsed hippo html field
     * @return true if empty, false otherwise
     */
    public static Boolean isEmpty(String hippohtml){
        // parse the html field, and check if text or images are present
        Document doc = Jsoup.parse(hippohtml);
        String htmlText = doc.body().text();
        boolean noText = (htmlText == null || htmlText.replaceAll("\\p{Zs}","").isEmpty());
        boolean noImages = doc.body().getElementsByTag("img").isEmpty();

        return noText && noImages;
    }

 

 

it is quite an expensive method I guess; and it needs Jsoup as a dependency

 


Van: [hidden email] [[hidden email]] namens Dennis Vis [[hidden email]]
Verzonden: vrijdag 18 januari 2013 11:13
To: Hippo CMS 7 implementation list
Onderwerp: [Hippo-cms7-user] Rich text editor empty check

Good day,

I'm trying to check if a 'webrichtlijnen' rich text editor is empty, but it never is. I noticed that when a user empties the editor a <p>&nbsp;</p> remeains. I have read this blog post and this issue on the subject. Therefore I have adjusted my jsp like so:

<hst:html hippohtml="${document.html}" var="intro" />
 <c:if test="${not empty intro}">
   <div class="intro"><hst:html hippohtml="${document.html}"/></div>
 </c:if>

However, this does not work. The intro div is still shown. How should I go about fixing this?

Kind regards,

Dennis Vis
Consultant | Incentro Rotterdam

Fascinatio Boulevard 562-4
Capelle aan den IJssel, The Netherlands, 2909 VA


E: [hidden email]
T: <a href="tel:%2B31102020544" value="+31102020544" target="_blank">+31102020544
M: <a href="tel:%2B31640801868" value="+31640801868" target="_blank">+31640801868
W: www.incentro.com
Logo Incentro

This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html



--
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com

_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: Rich text editor empty check

Mathijs den Burger
This is indeed a known issue that's currently being worked on.


Mathijs



On Fri, Jan 18, 2013 at 11:33 AM, Frank van Lankvelt <[hidden email]> wrote:
wouldn't it make more sense to store this information in the hippostd:html node?  E.g. as a separate property, derived when the content is saved.  It should be straightforward to make this part of the RichTextModel in the CMS.

cheers, Frank


On Fri, Jan 18, 2013 at 11:24 AM, Leeuwis, Laurens <[hidden email]> wrote:

We encountered this problem during several projects as well. Wat we did is create a new tag function:

 

 /**
     * Checks if a HippoHTML field is empty.
     * e.g.:
     *   <hst:html hippohtml="${document.html}" var="intro" />
     *      <c:if test="${not myTag:isEmpty(intro)}">
     *
     * @param hippohtml the parsed hippo html field
     * @return true if empty, false otherwise
     */
    public static Boolean isEmpty(String hippohtml){
        // parse the html field, and check if text or images are present
        Document doc = Jsoup.parse(hippohtml);
        String htmlText = doc.body().text();
        boolean noText = (htmlText == null || htmlText.replaceAll("\\p{Zs}","").isEmpty());
        boolean noImages = doc.body().getElementsByTag("img").isEmpty();

        return noText && noImages;
    }

 

 

it is quite an expensive method I guess; and it needs Jsoup as a dependency

 


Van: [hidden email] [[hidden email]] namens Dennis Vis [[hidden email]]
Verzonden: vrijdag 18 januari 2013 11:13
To: Hippo CMS 7 implementation list
Onderwerp: [Hippo-cms7-user] Rich text editor empty check

Good day,

I'm trying to check if a 'webrichtlijnen' rich text editor is empty, but it never is. I noticed that when a user empties the editor a <p>&nbsp;</p> remeains. I have read this blog post and this issue on the subject. Therefore I have adjusted my jsp like so:

<hst:html hippohtml="${document.html}" var="intro" />
 <c:if test="${not empty intro}">
   <div class="intro"><hst:html hippohtml="${document.html}"/></div>
 </c:if>

However, this does not work. The intro div is still shown. How should I go about fixing this?

Kind regards,

Dennis Vis
Consultant | Incentro Rotterdam

Fascinatio Boulevard 562-4
Capelle aan den IJssel, The Netherlands, 2909 VA


E: [hidden email]
T: <a href="tel:%2B31102020544" value="+31102020544" target="_blank">+31102020544
M: <a href="tel:%2B31640801868" value="+31640801868" target="_blank">+31640801868
W: www.incentro.com
Logo Incentro

This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html



--
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

US <a href="tel:%2B1%20877%20414%204776" value="+18774144776" target="_blank">+1 877 414 4776 (toll free)
Europe <a href="tel:%2B31%280%2920%20522%204466" value="+31205224466" target="_blank">+31(0)20 522 4466
www.onehippo.com

_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: Rich text editor empty check

dennis.vis
Thanks guys,

Good to know it's being worked on. For now I'm going to implement a variety of Laurens' code snippet.
Thanks again for the help!


Kind regards,

Dennis Vis
Consultant | Incentro Rotterdam

Fascinatio Boulevard 562-4
Capelle aan den IJssel, The Netherlands, 2909 VA


E: [hidden email]
T: +31102020544
M: +31640801868
W: www.incentro.com
Logo Incentro


2013/1/18 Mathijs den Burger <[hidden email]>
This is indeed a known issue that's currently being worked on.


Mathijs



On Fri, Jan 18, 2013 at 11:33 AM, Frank van Lankvelt <[hidden email]> wrote:
wouldn't it make more sense to store this information in the hippostd:html node?  E.g. as a separate property, derived when the content is saved.  It should be straightforward to make this part of the RichTextModel in the CMS.

cheers, Frank


On Fri, Jan 18, 2013 at 11:24 AM, Leeuwis, Laurens <[hidden email]> wrote:

We encountered this problem during several projects as well. Wat we did is create a new tag function:

 

 /**
     * Checks if a HippoHTML field is empty.
     * e.g.:
     *   <hst:html hippohtml="${document.html}" var="intro" />
     *      <c:if test="${not myTag:isEmpty(intro)}">
     *
     * @param hippohtml the parsed hippo html field
     * @return true if empty, false otherwise
     */
    public static Boolean isEmpty(String hippohtml){
        // parse the html field, and check if text or images are present
        Document doc = Jsoup.parse(hippohtml);
        String htmlText = doc.body().text();
        boolean noText = (htmlText == null || htmlText.replaceAll("\\p{Zs}","").isEmpty());
        boolean noImages = doc.body().getElementsByTag("img").isEmpty();

        return noText && noImages;
    }

 

 

it is quite an expensive method I guess; and it needs Jsoup as a dependency

 


Van: [hidden email] [[hidden email]] namens Dennis Vis [[hidden email]]
Verzonden: vrijdag 18 januari 2013 11:13
To: Hippo CMS 7 implementation list
Onderwerp: [Hippo-cms7-user] Rich text editor empty check

Good day,

I'm trying to check if a 'webrichtlijnen' rich text editor is empty, but it never is. I noticed that when a user empties the editor a <p>&nbsp;</p> remeains. I have read this blog post and this issue on the subject. Therefore I have adjusted my jsp like so:

<hst:html hippohtml="${document.html}" var="intro" />
 <c:if test="${not empty intro}">
   <div class="intro"><hst:html hippohtml="${document.html}"/></div>
 </c:if>

However, this does not work. The intro div is still shown. How should I go about fixing this?

Kind regards,

Dennis Vis
Consultant | Incentro Rotterdam

Fascinatio Boulevard 562-4
Capelle aan den IJssel, The Netherlands, 2909 VA


E: [hidden email]
T: <a href="tel:%2B31102020544" value="+31102020544" target="_blank">+31102020544
M: <a href="tel:%2B31640801868" value="+31640801868" target="_blank">+31640801868
W: www.incentro.com
Logo Incentro

This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html



--
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

US <a href="tel:%2B1%20877%20414%204776" value="+18774144776" target="_blank">+1 877 414 4776 (toll free)
Europe <a href="tel:%2B31%280%2920%20522%204466" value="+31205224466" target="_blank">+31(0)20 522 4466
www.onehippo.com

_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html
Reply | Threaded
Open this post in threaded view
|

Re: Rich text editor empty check

Wouter Danes-2

Go for the derived data option, else this is quite a performance hit on your servers.

 

From: [hidden email] [mailto:[hidden email]] On Behalf Of Dennis Vis
Sent: vrijdag 18 januari 2013 11:50
To: Hippo CMS 7 implementation list
Subject: Re: [Hippo-cms7-user] Rich text editor empty check

 

Thanks guys,

 

Good to know it's being worked on. For now I'm going to implement a variety of Laurens' code snippet.

Thanks again for the help!

 


Kind regards,

Dennis Vis
Consultant | Incentro Rotterdam

Fascinatio Boulevard 562-4
Capelle aan den IJssel, The Netherlands, 2909 VA


E: [hidden email]
T: +31102020544
M: +31640801868
W: www.incentro.com
Logo Incentro

 

2013/1/18 Mathijs den Burger <[hidden email]>

This is indeed a known issue that's currently being worked on.

 

 

Mathijs

 

 

On Fri, Jan 18, 2013 at 11:33 AM, Frank van Lankvelt <[hidden email]> wrote:

wouldn't it make more sense to store this information in the hippostd:html node?  E.g. as a separate property, derived when the content is saved.  It should be straightforward to make this part of the RichTextModel in the CMS.

 

cheers, Frank

 

On Fri, Jan 18, 2013 at 11:24 AM, Leeuwis, Laurens <[hidden email]> wrote:

We encountered this problem during several projects as well. Wat we did is create a new tag function:

 

 /**
     * Checks if a HippoHTML field is empty.
     * e.g.:
     *   <hst:html hippohtml="${document.html}" var="intro" />
     *      <c:if test="${not myTag:isEmpty(intro)}">
     *
     * @param hippohtml the parsed hippo html field
     * @return true if empty, false otherwise
     */
    public static Boolean isEmpty(String hippohtml){
        // parse the html field, and check if text or images are present
        Document doc = Jsoup.parse(hippohtml);
        String htmlText = doc.body().text();
        boolean noText = (htmlText == null || htmlText.replaceAll("<a href="file:///\\p%7bZs%7d">\\p{Zs}","").isEmpty());
        boolean noImages = doc.body().getElementsByTag("img").isEmpty();

        return noText && noImages;
    }

 

 

it is quite an expensive method I guess; and it needs Jsoup as a dependency

 


Van: [hidden email] [[hidden email]] namens Dennis Vis [[hidden email]]
Verzonden: vrijdag 18 januari 2013 11:13
To: Hippo CMS 7 implementation list
Onderwerp: [Hippo-cms7-user] Rich text editor empty check

Good day,

 

I'm trying to check if a 'webrichtlijnen' rich text editor is empty, but it never is. I noticed that when a user empties the editor a <p>&nbsp;</p> remeains. I have read this blog post and this issue on the subject. Therefore I have adjusted my jsp like so:

<hst:html hippohtml="${document.html}" var="intro" />

 <c:if test="${not empty intro}">

   <div class="intro"><hst:html hippohtml="${document.html}"/></div>

 </c:if>

 

However, this does not work. The intro div is still shown. How should I go about fixing this?


Kind regards,

Dennis Vis
Consultant | Incentro Rotterdam

Fascinatio Boulevard 562-4
Capelle aan den IJssel, The Netherlands, 2909 VA


E: [hidden email]
T: <a href="tel:%2B31102020544" target="_blank">+31102020544
M: <a href="tel:%2B31640801868" target="_blank">+31640801868
W: www.incentro.com

This message contains information that may be privileged or confidential and is the property of the Capgemini Group. It is intended only for the person to whom it is addressed. If you are not the intended recipient, you are not authorized to read, print, retain, copy, disseminate, distribute, or use this message or any part thereof. If you receive this message in error, please notify the sender immediately and delete all copies of this message.

 

_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html



 

--
Amsterdam - Oosteinde 11, 1017 WT Amsterdam
Boston - 1 Broadway, Cambridge, MA 02142

US +1 877 414 4776 (toll free)
Europe +31(0)20 522 4466
www.onehippo.com


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html

 


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html

 


_______________________________________________
Hippo-cms7-user mailing list and forums
http://www.onehippo.org/cms7/support/forums.html