我正在尝试删除 <p>
的自动添加CQ5(版本 5.6.0.20130125)中的标签。我试图将这些属性添加到 text component我正在使用但没有效果。( source )
removeSingleParagraphContainer true
singeParagraphContainerReplacement (empty string)
我也试过 this solution .同样,没有效果。
是否可以禁用自动添加 <p>
标签?
感谢任何想法
编辑 我试过this answer但 CQ 仍然添加 <p>
标记到我的代码。例如,我有这段 HTML 代码
<strong>Headquarters:</strong>
<p>MY - COMPANY a.s.<br>
Random Street 77<br>
Random City</p>
提交后,代码变为
<p><strong>Headquarters:</strong></p>
<p>MY - COMPANY a.s.<br>
Random Street 77<br>
Random City</p>
我的 RTE 看起来像这样
<text jcr:primaryType="cq:widget"
hideLabel="{Boolean}true"
name="./text"
xtype="richtext">
<htmlRules jcr:primaryType="nt:unstructured">
<docType jcr:primaryType="nt:unstructured">
...
</docType>
<blockHandling
jcr:primaryType="nt:unstructured"
removeSingleParagraphContainer="{Boolean}true"/>
</htmlRules>
</text>
最佳答案
您可以防止 RTE 用 <p>
包围您的文本通过设置 removeSingleParagraphContainer
标签属性(property)true
只要您只创建一个段落。
对于 Mac OS X 上的 Chrome(至少),按住 shift 的同时按 enter 会插入换行符而不是分段符,因此您仍然可以创建多行文本。既然你在 your last question 中说过你正在使用 misctools
插件,您可以使用源代码编辑 View 随时查看标记。
最后,设置removeSingleParagraphContainer
属性,您需要创建另一个名为 blockHandling
的子项在你的htmlRules
下对话框中的节点。你不需要弄乱 singeParagraphContainerReplacement
属性,但如果你这样做了,你会把它设置在同一个节点上:
<rtePlugins jcr:primaryType="nt:unstructured">
...
</rtePlugins>
<htmlRules jcr:primaryType="nt:unstructured">
<docType jcr:primaryType="nt:unstructured">
...
</docType>
<blockHandling
jcr:primaryType="nt:unstructured"
removeSingleParagraphContainer="{Boolean}true"/>
</htmlRules>
针对您的编辑进行编辑:使用 misctools
的源代码编辑功能插入并粘贴此确切文本可以在没有 p
的情况下保存和加载在 Mac OS X 上的 Chrome 中为我标记:
<strong>Headquarters:</strong><br>
MY - COMPANY a.s.<br>
Random Street 77<br>
Random City
您确定您的 dialog.xml 部署正确吗?也许仔细检查您的组件的对话框层次结构是否符合您在 CRXDE Lite 中的期望:
关于html - 禁用自动添加 <p> 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17965276/