Blog editor removes HTML del tagBlog editor removes HTML del taghttps://liferay.dev/en/c/message_boards/find_thread?p_l_id=119785333&threadId=845110822024-03-28T15:03:34Z2024-03-28T15:03:34ZRE: Blog editor removes HTML del tagCody Burlesonhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=859206312017-02-12T03:37:47Z2017-02-12T03:37:47Z<html><head></head><body>So, thanks to your help, I do seem to have gotten something working. For the record, I created a new OSGI module using the "service" template in the Eclipse IDE with Liferay plugins. I'm deploying directly to my local dev server using publish from within the IDE (I haven't learned how to build the module and deploy it on a production server yet). But anyway, the code that did the trick follows. Basically, I modified the existing allowedContent config attribute to allow adding CSS classes to the HTML code tag (this allows you to use highlight.js for source code formatting in your blog, for example). I also added the HTML5 del attribute because...it's a standard HTML attribute; I don't think it should be missing.<br><br><pre><code>package com.base22.liferay.service;
import java.util.Map;
import org.osgi.service.component.annotations.Component;
import com.liferay.portal.kernel.editor.configuration.BaseEditorConfigContributor;
import com.liferay.portal.kernel.editor.configuration.EditorConfigContributor;
import com.liferay.portal.kernel.json.JSONObject;
import com.liferay.portal.kernel.portlet.RequestBackedPortletURLFactory;
import com.liferay.portal.kernel.theme.ThemeDisplay;
/**
* Reference Resources:
* https://web.liferay.com/community/forums/-/message_boards/view_message/85868160
* https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/modifying-an-editors-configuration
* http://docs.ckeditor.com/#!/guide/dev_allowed_content_rules
*
* Using GitHub search is useful (that's how I found the appropriate editor.config.key
* and the javax.portlet.name. For example...
* https://github.com/liferay/liferay-portal/search?utf8=%E2%9C%93&amp;q=allowedContent&amp;type=Code
*
* @author Cody Burleson
*
*/
@Component(
immediate = true,
property = {
"editor.config.key=contentEditor",
"javax.portlet.name=com_liferay_blogs_web_portlet_BlogsAdminPortlet",
"editor.name=alloyeditor",
"editor.name=ckeditor", "service.ranking:Integer=100"
},
service = EditorConfigContributor.class
)
public class EditorConfigService extends BaseEditorConfigContributor implements EditorConfigContributor {
@Override
public void populateConfigJSONObject(JSONObject jsonObject, Map<string, object> inputEditorTaglibAttributes,
ThemeDisplay themeDisplay, RequestBackedPortletURLFactory requestBackedPortletURLFactory) {
jsonObject.put("allowedContent", "a[*](*);code[*](*); b del em h1 h2 h3 h4 h5 h6 hr i pre strong u; div(*); img[class, !src] {height, width}; li ol ul; p {text-align}; table[border, cellpadding, cellspacing] {width}; tbody td th[scope]; thead tr[scope];");
}
}</string,></code></pre></body></html>Cody Burleson2017-02-12T03:37:47ZRE: Blog editor removes HTML del tagChema Balsashttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=858681602017-02-10T08:00:22Z2017-02-10T08:00:22ZHey Cody,<br /><br />This is as originally designed. The owners of the Blogs app wanted to restrict the allowed markup to be able to generate a consistent reading experience in the app (this is very similar to what every other blog platform does).<br /><br />This is achieved using the <a href="http://docs.ckeditor.com/#!/guide/dev_advanced_content_filter">Advanced Content Filter</a> feature of CKEditor, by configuring the <a href="http://docs.ckeditor.com/#!/guide/dev_allowed_content_rules">allowedContent</a> property.<br /><br />The good news is that in Liferay DXP, you can target and modify any editor configuration, so you can <a href="https://dev.liferay.com/develop/tutorials/-/knowledge_base/7-0/modifying-an-editors-configuration">create your own EditorConfigContributor</a> to set the allowedContent property to whatever you want. You can see <a href="https://github.com/liferay/liferay-portal/search?utf8=%E2%9C%93&q=allowedContent">several instances</a> of this throughout our own applications.<br /><br />Hope this helps.Chema Balsas2017-02-10T08:00:22ZRE: Blog editor removes HTML del tagCody Burlesonhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=857482272017-02-07T22:30:26Z2017-02-07T22:30:26ZIt also removes class attributes from a code element.Cody Burleson2017-02-07T22:30:26ZBlog editor removes HTML del tagCody Burlesonhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=845110812017-01-07T21:28:27Z2017-01-07T21:28:27ZIt seems that the editor in the blog form on v7 removes the HTML del tag. Does anybody