Using a customConverter to remove font formatting from rich text


<xp:inputRichText id="inputRichText1" value="#{doc.body}" readonly="true">
	<xp:this.converter>
		<xp:customConverter>
			<xp:this.getAsObject><![CDATA[#{javascript:value}]]></xp:this.getAsObject>
			<xp:this.getAsString><![CDATA[#{javascript:
				try{
					var html=value.toString();
					html=html.replace(/<(FONT|font)([ ]([a-zA-Z]+)=(\"|')[^\"\\']+(\"|'))*[^>]+>/g,"")
					html=html.replace(/(<\/FONT>|<\/font>)/g,"")
				       return html;
				}catch(e){
				       print (e);
				}}]]>
			</xp:this.getAsString>
		</xp:customConverter>
	</xp:this.converter>
</xp:inputRichText>
All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.
No comments yetLogin first to comment...