@@ -0,0 +1,1210 @@
+package org.sakaiproject.site.util;%0A%0Aimport org.sakaiproject.util.FormattedText;%0Aimport org.sakaiproject.util.StringUtil;%0A%0Apublic class SiteTextEditUtil %7B%0A%09/**%0A%09 * @param formattedText %0A%09          The formatted text to convert to plain text and then to trim%0A%09 * @param maxNumOfChars%0A%09          The maximum number of characters for the trimmed text.%0A%09 * @return Ellipse %0A%09           A String to represent the ending pattern of the trimmed text%0A%09 */%0A%09public String doPlainTextAndLimit(String formattedText, int maxNumOfChars, String ellipse)%0A%09%7B%0A%09%09formattedText = StringUtil.trimToNull(formattedText);%0A%09%09if(formattedText == null %7C%7C formattedText.equalsIgnoreCase(%22%3Cbr/%3E%22) %7C%7C formattedText.equalsIgnoreCase(%22%3Cbr%3E%22)%7C%7C%0A%09%09%09%09formattedText.equals(%22&nbsp;%22) %7C%7C FormattedText.escapeHtml(formattedText,false).equals(%22&lt;br type=&quot;_moz&quot; /&gt;%22))%7B%0A%09%09%09%0A%09%09%09return %22%22;%0A%09%09%7D%0A%0A%09%09StringBuilder sb = new StringBuilder();%0A%09%09String text = FormattedText.convertFormattedTextToPlaintext(formattedText);%09%09%09%09%0A%09%09if(maxNumOfChars%3Etext.length())%7B%0A%09%09%09maxNumOfChars=text.length();%0A%09%09%7D%0A%09%09String trimmedText=text.substring(0, maxNumOfChars);%0A%09%09sb.setLength(0);%0A%09%09sb.append(trimmedText).append(ellipse);%0A%09%09return sb.toString();%09%09%09%09%0A%09%7D%0A%7D

Fix to SAK-15868 and doPlainTextAndTrim has been moved into a utility class SiteTextEditUtil