html - 禁用自动添加 <p> 标签

标签 html aem rich-text-editor

我正在尝试删除 <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>

EDIT2 这就是我的层次结构 enter image description here

最佳答案

您可以防止 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 中的期望:

CRXDE Lite text nodes

关于html - 禁用自动添加 <p> 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17965276/

相关文章:

html - 使用 CSS 创建页面 View

javascript - 使用外部样式表将 HTML 导出到 DocX

java - jsp中如何跳过%符号?

typescript - angular2 所见即所得的 tinymce 实现和 2 向绑定(bind)

html - 如何在 Canvas 中沿自定义路径为对象设置动画?

jquery - 在 POST 之前从按钮提交的 SelectList 中选择所有选项

android - 在 Android 中创建一个简单的文本编辑器

ios - UIWebView中如何实现undo/redo

tomcat 服务器中跨 J2EE 应用程序和 CQ 的 session 管理

aem - 如何以编程方式创建新版本的 CQ5 页面?