Package com.jalios.jcms.policy
Interface WysiwygPolicyFilter
- All Superinterfaces:
Comparable,PluginComponent,PolicyFilter
- All Known Implementing Classes:
BasicWysiwygPolicyFilter
This class provides hooks for wysiwyg rendering.
- Since:
- jcms-5.7.0
-
Method Summary
Modifier and TypeMethodDescriptionThis method is called after cleaning process of a HTML input received from the user.afterRendering(String text, Locale userLocale) This method is called after wysiwyg renderingvoidbeforeClean(String unsafeStr, Map<String, Object> contextMap) This method is called before cleaning process of a HTML input received from the user.beforeRendering(String text, Locale userLocale) This method is called before wysiwyg renderingorg.jsoup.nodes.DocumentprocessJHTML(org.jsoup.nodes.Document document, Locale userLocale, WysiwygRenderingHints hints) This method is called during JHTML processingupdateWysiwygConfiguration(String configId) Returns the list of updates to perform to the wysiwyg configuration defined by the given id.Methods inherited from interface java.lang.Comparable
compareToMethods inherited from interface com.jalios.jcms.plugin.PluginComponent
init
-
Method Details
-
beforeClean
This method is called before cleaning process of a HTML input received from the user.In current implementation, the following informations can be retrieved or modified from the context map :
-
Data instance on which cleaning is performed (can be null) :
Data data = (Data) contextMap.get(WysiwygManager.CLEANHTML_CTXT_DATA) -
Data's field name on which cleaning is performed, as described in type xml, eg "myWysiwygField" (can be null) :
String fieldName = (String) contextMap.get(WysiwygManager.CLEANHTML_CTXT_FIELDNAME) -
TypeFieldEntry of field for which HTML cleanup is being performed. (can be null) :
TypeFieldEntry tfe = (com.jalios.jcms.TypeFieldEntry) contextMap.get(WysiwygManager.CLEANHTML_CTXT_TYPEFIELDENTRY); -
The JSoup Safelist that will be used for the cleaning process :
Safelist safelist = (org.jsoup.safety.Safelist) contextMap.get(WysiwygManager.CLEANHTML_CTXT_SAFELIST)
Your WysiwygPolicyFilter implementation can set a custom Safelist for this key if you want to apply a stricter or relaxed policy in some circumstances.
Set tonullto cancel the cleaning process (ie HTML parsing and cleaning), in such case, methodafterClean(String, String, Map)will still be invoked.
- Parameters:
unsafeStr- the input received from the usercontextMap- the map providing information on cleaning context, NEVER null- Since:
- JCMS-3751+jcms-9.0
-
Data instance on which cleaning is performed (can be null) :
-
afterClean
This method is called after cleaning process of a HTML input received from the user.In current implementation, the following informations can be retrieved or modified from the context map :
-
Data instance on which cleaning is performed (can be null) :
Data data = (Data) contextMap.get(WysiwygManager.CLEANHTML_CTXT_DATA); -
Data's field name on which cleaning is performed, as described in type xml, eg "myWysiwygField" (can be null) :
String fieldName = (String) contextMap.get(WysiwygManager.CLEANHTML_CTXT_FIELDNAME); -
TypeFieldEntry of field for which HTML cleanup is being performed. (can be null) :
TypeFieldEntry tfe = (com.jalios.jcms.TypeFieldEntry) contextMap.get(WysiwygManager.CLEANHTML_CTXT_TYPEFIELDENTRY); -
The JSoup Safelist that was used for the cleaning process :
Safelist safelist = (org.jsoup.safety.Safelist) contextMap.get(WysiwygManager.CLEANHTML_CTXT_SAFELIST);
Can be null if a custom WysiwygPolicyFilter has cancelled the cleaning process. -
The JSoup Document instance that was created by parsing input :
Document dirtyDoc = (org.jsoup.nodes.Document) contextMap.get(WysiwygManager.CLEANHTML_CTXT_DIRTYDOC);
Can be null if a custom WysiwygPolicyFilter has cancelled the cleaning process. -
The JSoup Document instance that was created by cleaned the dirty document :
Document cleanDoc = (org.jsoup.nodes.Document) contextMap.get(WysiwygManager.CLEANHTML_CTXT_CLEANDOC);
Can be null if a custom WysiwygPolicyFilter has cancelled the cleaning process.
- Parameters:
unsafeStr- the input received from the usersafeStr- the input cleaned by JCMS (unless it was cancelled inbeforeClean(String, Map))contextMap- the map providing information on cleaning context, NEVER null- Returns:
- the cleaned HTML
- Since:
- JCMS-3751+jcms-9.0
-
Data instance on which cleaning is performed (can be null) :
-
beforeRendering
This method is called before wysiwyg rendering- Parameters:
text- the text to be rendered.userLocale- an optionalLocaleof the user for which the text will be generated- Returns:
- the text.
- Since:
- jcms-5.7.0
-
afterRendering
This method is called after wysiwyg rendering- Parameters:
text- the text after the rendering.userLocale- an optionalLocaleof the user for which the text will be generated- Returns:
- the text.
- Since:
- jcms-5.7.0
-
processJHTML
org.jsoup.nodes.Document processJHTML(org.jsoup.nodes.Document document, Locale userLocale, WysiwygRenderingHints hints) This method is called during JHTML processing- Parameters:
document- the JSoup document of the HTML to be rendered.userLocale- an optionalLocaleof the user for which the text will be generatedhints- the rendering options to use.- Returns:
- the document.
- Since:
- jcms-10.0.0
-
updateWysiwygConfiguration
Returns the list of updates to perform to the wysiwyg configuration defined by the given id.- Parameters:
configId- configuration id- Returns:
- List of
WysiwygConfigurationUpdate
-