在 AEM 富文本编辑器中向锚点添加属性 Link

Add attribute to anchor in AEM Rich text editor Link

我正在努力使我客户的一个 AEM 网站易于访问。 For the same, I want "aria-label" attribute should be added(value can be provided in authoring dialogue) to the anchor tag, when the target selected is "New tab". 周围找不到太多,按照link的介绍我们可以自定义rtePlugin/linkPicker。但无法弄清楚我的问题。任意 help/guidance

http://experience-aem.blogspot.com/2017/06/aem-63-touch-ui-rte-rich-text-editor-color-picker-plugin-inplace-dialog-edit.html

选项 1) 重新使用来自 otb 锚 link 的 Alt Text/标题。无需自定义对话框。当创作 Alt Text 时,otb 将像这样填充标题 <a title="Google" href="htttps://www.google.com">Google Link</a>

然后您需要编写 Link Transformer to copy title into aria-label. The rewriter will look for anchor tags; if title is present, copy into a new attribute aria-label and rewrite the anchor. If link rewriter is difficult, you can also rewrite the rte text from a sling model while saving the RTE text. Use a Jsoup parser 来解析 HTML,通过将标题复制到 aria-label 并写回 JCR 来重写。

选项 2) 将 aria-label 的新文本框添加到对话框。可以参考这个blog post。但是只有当 Alt text 不同于 aria-label 时才需要这个选项,我想知道为什么。通常 aria-label 和标题相同,上面的选项 1 就足够了。

所以终于能够通过一些故障排除来添加 aria-label 属性。此外,上述 link 中的步骤是相同的​​。想要添加我遇到问题的其他详细信息

  1. 添加新字段
    按照 blog
  2. 中提到的步骤进行操作
  3. 添加博客中提到的字段后,新添加的属性将被 AEM 过滤。您将在 error.log 文件

    中看到以下错误

    错误:“26.09.2017 12:40:42.804 INFO [0:0:0:0:0: 0:0:1 [1506447642680] GET /content/we-retail/language-masters/en.html HTTP/1.1] org.apache.sling.xss.impl.HtmlToHtmlContentContext AntiSamy 警告:a 标签包含我们无法处理的属性。rel属性的值为 "bookmark"。出于安全原因,无法接受此值。我们已选择从标记中删除此属性,并保留其他所有内容,以便我们可以处理输入。”

    解决方法:在CRXDE Light的AntiSamy配置文件中声明属性。 注意 : 在/apps/cq/xssprotection/config.xml中进行以下更改(覆盖/libs/cq/xssprotection/config.xml),因为Sightly/HTL其/libs/sling/xss/config.xml

  4. 复制/libs/cq/xssprotection/config.xml到/apps/cq/xssprotection/config.xml.

  5. 打开 /apps/cq/xssprotection/config.xml。 在公共属性部分,添加以下目标属性声明。

    <attribute name="aria-label> <regexp-list> <regexp value="[a-zA-Z0-9-_$]+" /> </regexp-list> </attribute>

  6. 通过搜索术语 <tag name="a" 找到标签声明。

  7. 在属性列表中添加以下行:

    <attribute name="aria-label" />

保存文件。现在,如果选择该选项,link 将在新的 window 中打开。