Update RTE component to use Block Quotes in AEM - aem

I'm currently using Rich Text Editor (RTE) in my AEM 6.2 project. I would like to configure RTE to use blockquote tag. How can achieve this?
<blockquote>
Component code:
<paraformat jcr:primaryType="nt:unstructured" features="*">
<formats jcr:primaryType="cq:WidgetCollection">
<p jcr:primaryType="nt:unstructured" description="Paragraph" tag="p"/>
<h1 jcr:primaryType="nt:unstructured" description="Heading 1" tag="h1"/>
<h2 jcr:primaryType="nt:unstructured" description="Heading 2" tag="h2"/>
<h3 jcr:primaryType="nt:unstructured" description="Heading 3" tag="h3"/>
<h4 jcr:primaryType="nt:unstructured" description="Heading 4" tag="h4"/>
<h5 jcr:primaryType="nt:unstructured" description="Heading 5" tag="h5"/>
<blockquote jcr:primaryType="nt:unstructured" description="Block Quote" tag="blockquote"/>
</formats>
</paraformat>
Reference:
RTE in JCR
Dialog View
Thanks.

You can add a new block element by following the instructions at official documents:
Adding custom paragraph formats to RTE
Basically, you overlay the RTE and extend the paraformat plugin by introducing the new elements. Summary steps are:
Overlay your RTE
Create cq:EditConfig/inplaceEditing/paraformat/format node under your RTE control.
Create a node for your style, name it blockquote and give it the following properties -> Description: Block Quote & Tag: blockquote
Make sure you add all other default formats like p, H1, H2 etc.
That's it. You should see your new paragraph style available in the paragraph styles dropdown.
This is a summary as all the pictures will make this post too long but a detailed post can be found at: http://www.aemcq5tutorials.com/tutorials/configure-rte-plugin-in-touch-ui/
Optionally, you will need to check if blockquote element is allowed by inspecting your /libs/cq/xssprotection/config.xml file. The file is self explanatory with lots of comments but in general you should check under <tag-rules> to ensure that your tag is supported. OOTB AEM 6.2 allows blockquote element but some upgrades might have lost it.

Related

cq:showOnCreate not working with RTE on Page properties

We are using an RTE field in the page properties. The issue here is, this field doesn't render in the page properties when author is creating the page. Is this a known issue with AEM? Is there any workaround for this?
<bannerText
cq:showOnCreate="{Boolean}true"
jcr:primaryType="nt:unstructured"
sling:resourceType="cq/gui/components/authoring/dialog/richtext"
fieldLabel="Banner text"
fieldDescription="This text describes the banner message."
required="true"
name="./bannerText"
useFixedInlineToolbar="{Boolean}true">
<rtePlugins jcr:primaryType="nt:unstructured">
<format
....
<bannerText?>
PS: We are using AEM 6.5
Thanks in advance!

Fetch Text and Values both from Touch UI Dropdown in AEM

I have a static list of drop down,but i want to fetch both value and Text from the drop down in AEM touch UI.
<articleType
jcr:primaryType="nt:unstructured"
sling:resourceType="granite/ui/components/foundation/form/select"
fieldLabel="Article Type"
name="./articleType">
<items jcr:primaryType="nt:unstructured">
<select
jcr:primaryType="nt:unstructured"
text="Select Icon"
value=""/>
<article
jcr:primaryType="nt:unstructured"
text="Article"
value="article"/>
<video
jcr:primaryType="nt:unstructured"
text="Video"
value="video"/>
<infographic
jcr:primaryType="nt:unstructured"
text="Infographic"
value="graph"/>
</items>
</articleType>
Now I want to fetch it like <i class="article-icon icon" />. I can fetch "icon class" from "value" but i need to always have some test conditions to fetch the text.
So i want a solution for this.
I have used data sources for this kind of requirements. In the example listed below, a jsp file is used. You can very well create WCMUsePojo class and call it in a HTML to refer the dynamic text and value pairs.
Please check:
https://helpx.adobe.com/experience-manager/using/creating-granite-datasource.html

How to wrap 2 components in a div from the template content.xml file?

I have two components that should be configured in a cq template, in the content.xml file (in the jcr:content node).
I don't have a page component for my template, so I cannot do something like this:
<div class="wrapper_div">
<cq:include resourceType="/my/first/component"/>
<cq:include resourceType="/my/second/component"/>
</div>
Is there a way to define a div container from within content.xml?
There can be one trick, you can add below to your content.xml file of your template.
<jcr:content
jcr:primaryType="cq:PageContent"
sling:resourceType="path/of/page/page-component">
<par
jcr:primaryType="nt:unstructured"
sling:resourceType="foundation/components/parsys">
<simple
jcr:lastModified="{Date}2015-05-05T12:16:19.895+05:30"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
sling:resourceType="path/components/content/component1"/>
<simple1
jcr:lastModified="{Date}2015-05-05T12:16:19.895+05:30"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
sling:resourceType="path/components/content/component2"/>
</par>
</jcr:content>
</jcr:root>
This will create the content nodes for the page using this template, but to make this work you must have parsys included in your rendering page component path/of/page/page-component e.g. <cq:include path="par" resourceType="foundation/components/parsys" />
Also there are some other ways like to add node of cq:template under your page component to pre populate the components.
Hope this will help.

CQ5-How to add rte plugin in custom widget

I have added richtext in the custom widget but i dont know how to add aditinal plugins for richtext.
Please help how we can achieve the same.
I am trying to add superscript/subscript in the richtext but not able to achieve the same.
Here is a code snippet that I've used to add this functionality to a richtext field.
<text
jcr:primaryType="cq:Widget"
hideLabel="{Boolean}true"
name="./text"
xtype="richtext">
<rtePlugins jcr:primaryType="nt:unstructured">
<subsuperscript
jcr:primaryType="nt:unstructured"
features="*"/>
</rtePlugins>
</text>
This snippet belongs in the dialog.xml of your custom component.
please have a look at the documentation for configuring the rich text editor for more information.

How to realize the "undo" functionality in CQ5 Rich Text Editor with a button?

Using CQ Rich Text Editor, I can undo the editing with strg + z. How to connect this functionality with a button? In other words where to find the javascript which is responsible for undo functionality?
In your RTE plugins (in the xml file), use:
<table
jcr:primaryType="nt:unstructured"
features="*"/>
<undo
jcr:primaryType="nt:unstructured"
features="*"/>
Hope this solves your problem.
For more info check here