首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >AEM锚链接css类

AEM锚链接css类
EN

Stack Overflow用户
提问于 2021-10-09 07:11:35
回答 1查看 493关注 0票数 0

我设法在RTE中显示了用于创作的文本组件的锚链接选项。因为在我们的网站上,我们有一个固定的标题,它是抵消锚链接。我可以用CSS解决这个问题,但支持我需要锚链接上的CSS类。有人能建议如何在AEM中的锚链接中添加一个“链接锚”类吗?

代码语言:javascript
运行
复制
<links jcr:primaryType="nt:unstructured" features="[modifylink,unlink,anchor]" />

<uiSettings jcr:primaryType="nt:unstructured">
    <cui jcr:primaryType="nt:unstructured">
      <inline jcr:primaryType="nt:unstructured" toolbar="[undo#undo,undo#redo,#paraformat,#styles,-,#format,experience-aem#colorPicker,-,#justify,-,#lists,-,subsuperscript#subscript,subsuperscript#superscript,links#modifylink,links#unlink,links#anchor,edit#cut,edit#copy,edit#paste-plaintext,edit#paste-wordhtml,misctools#specialchars,misctools#sourceedit,-,table#table]">
          <popovers jcr:primaryType="nt:unstructured">
              <format
                  jcr:primaryType="nt:unstructured"
                  items="[format#bold,format#italic,format#underline]"
                  ref="format"/>
              <justify
                  jcr:primaryType="nt:unstructured"
                  items="[justify#justifyleft,justify#justifycenter,justify#justifyright]"
                  ref="justify"/>
              <lists
                  jcr:primaryType="nt:unstructured"
                  items="[lists#unordered,lists#ordered,lists#outdent,lists#indent]"
                  ref="lists"/>
              <styles
                  jcr:primaryType="nt:unstructured"
                  items="styles:getStyles:styles-pulldown"
                  ref="styles"/>
              <paraformat
                  jcr:primaryType="nt:unstructured"
                  items="paraformat:getFormats:paraformat-pulldown"
                  ref="paraformat"/>
          </popovers>
        </inline>
      <dialogFullScreen jcr:primaryType="nt:unstructured" toolbar="[undo#undo,undo#redo,#paraformat,-,#format,experience-aem#colorPicker,-,#justify,-,#lists,-,subsuperscript#subscript,subsuperscript#superscript,links#modifylink,links#unlink,links#anchor,edit#cut,edit#copy,edit#paste-plaintext,edit#paste-wordhtml,misctools#specialchars,misctools#sourceedit,-,table#table]">
        <popovers jcr:primaryType="nt:unstructured">
            <format
                jcr:primaryType="nt:unstructured"
                items="[format#bold,format#italic,format#underline]"
                ref="format"/>
            <justify
                jcr:primaryType="nt:unstructured"
                items="[justify#justifyleft,justify#justifycenter,justify#justifyright]"
                ref="justify"/>
            <lists
                jcr:primaryType="nt:unstructured"
                items="[lists#unordered,lists#ordered,lists#outdent,lists#indent]"
                ref="lists"/>
            <styles
                jcr:primaryType="nt:unstructured"
                items="styles:getStyles:styles-pulldown"
                ref="styles"/>
            <paraformat
                jcr:primaryType="nt:unstructured"
                items="paraformat:getFormats:paraformat-pulldown"
                ref="paraformat"/>
        </popovers>
      </dialogFullScreen>
      <tableEditOptions
          jcr:primaryType="nt:unstructured"
          toolbar="[table#insertcolumn-before,table#insertcolumn-after,table#removecolumn,-,table#insertrow-before,table#insertrow-after,table#removerow,-,table#mergecells-right,table#mergecells-down,table#mergecells,table#splitcell-horizontal,table#splitcell-vertical,-,table#selectrow,table#selectcolumn,-,table#ensureparagraph,-,table#modifytableandcell,table#removetable,-,undo#undo,undo#redo,-,table#exitTableEditing,-]"/>
    </cui>
</uiSettings>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-10-15 23:36:43

您的usecase是这个用例的简化版本- http://experience-aem.blogspot.com/2017/09/aem-63-touch-ui-extend-rich-text-link-dialog-add-rel-select.html。您只需要在保存过程中硬编码类名,而不是添加下拉和双向映射。这对我起了作用:

/apps/myproj/clientlibs/authoring

  • Add

  • 创建一个clientlib - cq.authoring.dialog

  • Add目录,一个新的js文件作为rte-link-class.js。在rte-link-class.js

中添加js.txt

  • 中的任何名称和相同的名称

代码语言:javascript
运行
复制
(function ($) {
  "use strict";

  var _ = window._,
    Class = window.Class,
    CUI = window.CUI,
    RTE_LINK_DIALOG = "rtelinkdialog";

  if (CUI.rte.ui.cui.CuiDialogHelper.eaemExtended) {
    return;
  }

  var EAEMLinkBaseDialog = new Class({
    extend: CUI.rte.ui.cui.CQLinkBaseDialog,

    toString: "EAEMLinkBaseDialog",

    initialize: function (config) {
      this.superClass.initialize.call(this, config);
    },

    dlgToModel: function () {
      this.superClass.dlgToModel.call(this);
      this.objToEdit.attributes["class"] = "custom-anchor-link";
    },

    dlgFromModel: function () {
      this.superClass.dlgFromModel.call(this);
    },
  });

  CUI.rte.ui.cui.CuiDialogHelper = new Class({
    extend: CUI.rte.ui.cui.CuiDialogHelper,

    toString: "EAEMCuiDialogHelper",

    instantiateDialog: function (dialogConfig) {
      var type = dialogConfig.type;

      if (type !== RTE_LINK_DIALOG) {
        this.superClass.instantiateDialog.call(this, dialogConfig);
        return;
      }

      var $editable = $(this.editorKernel.getEditContext().root),
        $container = CUI.rte.UIUtils.getUIContainer($editable),
        dialog = new EAEMLinkBaseDialog();

      dialog.attach(dialogConfig, $container, this.editorKernel);

      return dialog;
    },
  });

  CUI.rte.ui.cui.CuiDialogHelper.eaemExtended = true;
})(jQuery);

在从RTE中添加链接后,它将被保存在jcr中,如下所示

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69504528

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档