【问题标题】:How do I prevent AEM stripping out the href from a RTE that has a default value which contains a link?如何防止 AEM 从具有包含链接的默认值的 RTE 中剥离 href?
【发布时间】:2016-05-19 11:08:06
【问题描述】:

我为 AEM 中的 RTE 设置了默认值。该值在对话框首次打开时显示正确,但是当它被保存并重新打开时,href 已从 A 标记中删除。 (这是一个外部链接)

如果然后使用 RTE 链接按钮重新添加此 href,则它可以正常工作,但我自然希望它第一次正常工作。

我是 AEM 新手,目前有以下内容(注意:对于本示例,我已更改 URL 并复制到测试版本):

<branchResultsCopy
    jcr:primaryType="cq:Widget"
    externalStyleSheets="[/etc/designs/rtg/clientlibs/author/style/source/rte.css]"
    fieldLabel="Branch results copy"
    name="./branchresultscopy"
    defaultValue="&lt;p&gt;If you'd like information about blah blah blah, visit our &lt;a target='_blank' link-checker='skip' href='https://www.testurl.com'&gt;Link text&lt;/a&gt; page.&lt;/p&gt;"
    xtype="richtext">
        <htmlRules
            jcr:primaryType="nt:unstructured">
                <links
                    jcr:primaryType="nt:unstructured"
                    protocols="[http://,https://]"/>
        </htmlRules>
        <rtePlugins
            jcr:primaryType="nt:unstructured">
                <edit
                    jcr:primaryType="nt:unstructured">
                        <htmlPasteRules
                            jcr:primaryType="nt:unstructured">
                                <allowBasics
                                    jcr:primaryType="nt:unstructured"
                                    anchor="{Boolean}true"
                                     bold="{Boolean}true"
                                />
                        </htmlPasteRules>
                </edit>
                <format
                    jcr:primaryType="nt:unstructured"
                    features="[bold,italic]"/>
                <lists
                    jcr:primaryType="nt:unstructured"
                    features="[ordered,unordered]"/>
                <links
                    jcr:primaryType="nt:unstructured"
                    features="*"/>
        </rtePlugins>
</branchResultsCopy>

【问题讨论】:

  • 您使用的链接是否有效(我假设示例是虚拟 url)?也许即使使用 link-checker='skip' (从未听说过),链接也会被链接检查器剥离。
  • 谢谢 Thomas,我检查了,我的真实代码中的 URL 将指向一个有效的链接。

标签: aem rte


【解决方案1】:

我认为您的主要问题是 defaultValue 字段中使用的语法。 我只是通过添加到文本组件的链接自己进行了测试,然后通过 CRXDE 我去获取 jcr:content 的 ./text 并将其直接复制粘贴到组件的 defaultValue 字段。

然后我将组件的新实例添加到页面中,对其进行编辑,默认值在 RTE 中,我只需单击保存,链接保持不变。

我做了一个组件包来检查 AEM 在 XML 中放了什么,至少可以说很奇怪,所有的 > 字符都保持不变,而所有的

这是我在包的 dialog.xml 中的 defaultValue:

defaultValue="&lt;p>Timeless beauty. Classic simplicity. It must be the circle! Each &lt;a href=&quot;http://google.ca&quot;>Geometrixx-brand&lt;/a> circle is handcrafted from an infinite number of very skinny isoceles triangles arrange in, well, a circle! We guarantee that our circles are not simply&lt;i> n&lt;/i>-gons, where &lt;i>n&lt;/i> is a very large number; ours are guaranteed round, no matter how closely you look. test&lt;/p>&#xa;"

注意他们使用 &quot 作为属性。

另外,一个小警告,RTEPlugin 不喜欢 link-checker="skip" 属性,它会去掉它。

如果你希望它保留链接检查器,你需要告诉它你有一个自定义属性要处理。

我知道如何做到这一点的唯一方法是通过经典对话框 这需要在 RTEPlugin 的 linkDialogConfig 中的 linkAttributes 中添加一个新节点。

类似的东西

<skipchecker
    jcr:primaryType="nt:unstructured"
    attribute="link-checker"
    fieldDescription="Skip link checker"
    fieldLabel="Skip Checker"
    name="./linkdialog/skip"
    xtype="selection">   
        <options jcr:primaryType="cq:WidgetCollection">
            <noskip
                jcr:primaryType="nt:unstructured"
                text="No Skip"
                value=""/>  
            <skip
                jcr:primaryType="nt:unstructured"
                text="Skip"
                value="skip"/>         
        </options>
</skipchecker>

不过,所有这些都是使用不美观的组件进行的测试,您没有提及您使用的是哪个版本的文本组件。 Sightly 组件的工作方式可能略有不同,但经典对话框是相同的,应该使用相同的插件。

【讨论】:

  • 感谢弗朗索瓦,位解决了我的主要问题。
猜你喜欢
  • 2017-12-09
  • 1970-01-01
  • 2016-11-19
  • 1970-01-01
  • 2016-06-06
  • 2011-04-02
  • 1970-01-01
  • 2015-11-22
  • 1970-01-01
相关资源
最近更新 更多