AEM 6.1:在触摸屏上启用富文本编辑器(RTE)插件

田阮

对于经典UI,我们可以轻松地在rteplugins标签内添加插件,Adobe在其Geometrix-Outdoor项目上构建了一个很好的示例:

        <summary
            jcr:primaryType="cq:Widget"
            fieldLabel="Summary"
            name="./summary"
            xtype="richtext">
            <rtePlugins jcr:primaryType="nt:unstructured">
                <table
                    jcr:primaryType="nt:unstructured"
                    features="*"/>
                <format
                    jcr:primaryType="nt:unstructured"
                    features="*"/>
                <lists
                    jcr:primaryType="nt:unstructured"
                    features="*"/>
                <justify
                    jcr:primaryType="nt:unstructured"
                    features="*"/>
                <edit
                    jcr:primaryType="nt:unstructured"
                    features="[paste-wordhtml]"/>
                <findreplace
                    jcr:primaryType="nt:unstructured"
                    features="*"/>
                <paraformat
                    jcr:primaryType="nt:unstructured"
                    features="*"/>
                <subsuperscript
                    jcr:primaryType="nt:unstructured"
                    features="*"/>
                <misctools
                    jcr:primaryType="nt:unstructured"
                    features="*"/>
                <links
                    jcr:primaryType="nt:unstructured"
                    features="*"/>
                <spellcheck
                    jcr:primaryType="nt:unstructured"
                    features="*"
                    invalidStyle="background-color: #ffdddd;"/>
                <undo
                    jcr:primaryType="nt:unstructured"
                    features="*"/>
                <image
                    jcr:primaryType="nt:unstructured"
                    features="*"/>
            </rtePlugins>
        </summary>

但是,我们不能在Touch UI环境上应用相同的东西,他们还在Geometrix-Outdoor上做了一个示例,但是插件不能显示全部功能:

                            <summary
                                jcr:primaryType="nt:unstructured"
                                sling:resourceType="cq/gui/components/authoring/dialog/richtext"
                                fieldLabel="Summary"
                                name="./summary"
                                renderReadOnly="{Boolean}true"/>

无论如何,是否可以将TouchUi上的插件显示为Classic UI?

马克·霍曼

这是一个示例dialog.xml(对于AEM6.1中的RTE,您需要dialog和_cq_dialog)

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="cq:Dialog"
helpPath="en/cq/current/wcm/default_components.html#Text"
title="Text"
xtype="tabpanel">
<items jcr:primaryType="cq:WidgetCollection">
    <tab1
        jcr:primaryType="cq:Widget"
        anchor="100%"
        title="Text"
        xtype="panel">
        <items jcr:primaryType="cq:WidgetCollection">
            <text
                jcr:primaryType="cq:Widget"
                hideLabel="{Boolean}true"
                name="./text"
                useFixedInlineToolbar="{Boolean}true"
                xtype="richtext">
                <rtePlugins jcr:primaryType="nt:unstructured">
                    <subsuperscript
                        jcr:primaryType="nt:unstructured"
                        features="*"/>
                    <paraformat
                        jcr:primaryType="nt:unstructured"
                        features="*">
                        <formats jcr:primaryType="cq:WidgetCollection">
                            <p
                                jcr:primaryType="nt:unstructured"
                                description="Paragraph"
                                tag="p"/>
                            <h2
                                jcr:primaryType="nt:unstructured"
                                description="Header 2"
                                tag="h2"/>
                            <h3
                                jcr:primaryType="nt:unstructured"
                                description="Header 3"
                                tag="h3"/>
                            <h4
                                jcr:primaryType="nt:unstructured"
                                description="Header 4"
                                tag="h4"/>
                        </formats>
                    </paraformat>
                    <misctools
                        jcr:primaryType="nt:unstructured"
                        features="specialchars">
                        <specialCharsConfig jcr:primaryType="nt:unstructured">
                            <chars jcr:primaryType="nt:unstructured">
                                <copyright
                                    jcr:primaryType="nt:unstructured"
                                    entity="©"/>
                                <trademark
                                    jcr:primaryType="nt:unstructured"
                                    entity="™"/>
                                <registered
                                    jcr:primaryType="nt:unstructured"
                                    entity="®"/>
                                <emDash
                                    jcr:primaryType="nt:unstructured"
                                    entity="—"/>
                                <pound
                                    jcr:primaryType="nt:unstructured"
                                    entity="£"/>
                                <nbsp
                                    jcr:primaryType="nt:unstructured"
                                    entity=" "/>
                            </chars>
                        </specialCharsConfig>
                    </misctools>
                    <links jcr:primaryType="nt:unstructured">
                        <linkDialogConfig
                            jcr:primaryType="nt:unstructured"
                            height="{Long}316">
                            <linkAttributes jcr:primaryType="cq:WidgetCollection">
                                <linkAdvanced
                                    jcr:primaryType="cq:Widget"
                                    collapsed="{Boolean}true"
                                    collapsible="{Boolean}true"
                                    inputValue="advanced"
                                    name="./linkdialog/cq:adhocLinkTrackingTab"
                                    title="Link tracking"
                                    xtype="dialogfieldset">
                                    <items jcr:primaryType="cq:WidgetCollection">
                                        <enable
                                            jcr:primaryType="nt:unstructured"
                                            attribute="enabletracking"
                                            fieldDescription="override analytics framework settings"
                                            fieldLabel="Custom link tracking"
                                            name="./linkdialog/cq:adhocLinkTrackingEnableTracking"
                                            xtype="checkbox">
                                            <listeners
                                                jcr:primaryType="nt:unstructured"
                                                check="function(component){var dlg=component.findParentByType('rtelinkdialog');dlg.enableSCFields(component.checked);}"/>
                                        </enable>
                                        <events
                                            jcr:primaryType="nt:unstructured"
                                            attribute="adhocevents"
                                            fieldDescription="e.g.: event2, event7"
                                            fieldLabel="Include SiteCatalyst events"
                                            name="./linkdialog/cq:adhocLinkTrackingEvents"
                                            xtype="textfield"/>
                                        <evars
                                            jcr:primaryType="nt:unstructured"
                                            attribute="adhocevars"
                                            fieldDescription="e.g.: eVar1: pagedata.url, prop4: 'const'"
                                            fieldLabel="Include SiteCatalyst variables"
                                            name="./linkdialog/cq:adhocLinkTrackingEvars"
                                            xtype="textfield"/>
                                    </items>
                                </linkAdvanced>
                            </linkAttributes>
                        </linkDialogConfig>
                    </links>
                    <edit
                        jcr:primaryType="nt:unstructured"
                        defaultPasteMode="plaintext"
                        features="[cut,copy,paste-plaintext]"
                        stripHtmlTags="{Boolean}true"/>
                    <spellcheck
                        jcr:primaryType="nt:unstructured"
                        features="*"/>
                    <findreplace
                        jcr:primaryType="nt:unstructured"
                        features="*"/>
                    <undo
                        jcr:primaryType="nt:unstructured"
                        features="*"/>
                    <format
                        jcr:primaryType="nt:unstructured"
                        features="[bold,italic]"/>
                    <lists
                        jcr:primaryType="nt:unstructured"
                        features="*"/>
                    <justify
                        jcr:primaryType="nt:unstructured"
                        features="*"/>
                    <styles
                        jcr:primaryType="nt:unstructured"
                        features="*">
                        <styles jcr:primaryType="cq:WidgetCollection">
                            <disclaimer
                                jcr:primaryType="nt:unstructured"
                                cssName="wysiwyg--disclaimer"
                                text="Disclaimer"/>
                            <quote
                                jcr:primaryType="nt:unstructured"
                                cssName="pull-quote component"
                                text="Quote"/>
                        </styles>
                    </styles>
                </rtePlugins>
                <uiSettings jcr:primaryType="nt:unstructured">
                    <cui jcr:primaryType="nt:unstructured">
                        <inline
                            jcr:primaryType="nt:unstructured"
                            toolbar="[links#modifylink,links#unlink,format#bold,format#italic,justify#justifyleft,justify#justifycenter,justify#justifyright,lists#unordered,lists#ordered,lists#outdent,lists#indent,fullscreen#start,control#close,control#save]"/>
                        <fullscreen
                            jcr:primaryType="nt:unstructured"
                            toolbar="[links#modifylink,links#unlink,links#anchor,format#bold,format#italic,format#underline,subsuperscript#subscript,subsuperscript#superscript,edit#cut,edit#copy,edit#paste-plaintext,findreplace#find,findreplace#replace,undo#undo,undo#redo,justify#justifyleft,justify#justifycenter,justify#justifyright,lists#unordered,lists#ordered,lists#outdent,lists#indent,spellcheck#checktext,misctools#specialchars,#styles,#paraformat,fullscreen#start,control#close,control#save]">
                            <popovers jcr:primaryType="nt:unstructured">
                                <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>
                        </fullscreen>
                    </cui>
                </uiSettings>
            </text>
            <isRichTextFlag
                jcr:primaryType="cq:Widget"
                ignoreData="{Boolean}true"
                name="./textIsRich"
                value="true"
                xtype="hidden"/>
        </items>
    </tab1>
</items>

这是_cq_dialog的示例

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="nt:unstructured"
jcr:title="Configure rich text component"
sling:resourceType="cq/gui/components/authoring/dialog"
helpPath="en/cq/current/wcm/default_components.html#Text">
    <content
    jcr:primaryType="nt:unstructured"
    sling:resourceType="granite/ui/components/foundation/container">
    <layout
        jcr:primaryType="nt:unstructured"
        sling:resourceType="granite/ui/components/foundation/layouts/fixedcolumns"
        margin="{Boolean}false"
        type="nav"/>
    <items jcr:primaryType="nt:unstructured">
        <column
            jcr:primaryType="nt:unstructured"
            sling:resourceType="granite/ui/components/foundation/container">
            <items jcr:primaryType="nt:unstructured">
                <text
                    jcr:primaryType="nt:unstructured"
                    sling:resourceType="granite/ui/components/foundation/form/textarea"
                    cols="{Long}2"
                    disabled="{Boolean}true"
                    fieldLabel="Body text"
                    name="./text"
                    rows="{Long}10"/>
            </items>
        </column>
    </items>
</content>

示例text.html

<div data-sly-test="${(wcmmode.edit || wcmInit.isTouchAuthoring) && (!properties.text)}">
<div>Please edit this component.</div>
<sub>This text will only appear in Authoring Mode</sub>
</div>
<div data-sly-test="${properties.text}" data-sly-unwrap>
<p data-sly-use.text="text.js" data-sly-unwrap="${text.context == text.CONST.CONTEXT_HTML}" class="${text.cssClass}" data-emptytext="Rich Text">${text.text @ context=text.context}</p>
</div>

和test.js

"use strict";
/**
 * Text foundation component JS backing script
 */
use(["/apps/global/components/utils/AuthoringUtils.js"], function (AuthoringUtils) {

var CONST = {
    PROP_TEXT: "text",
    PROP_RICH_FORMAT: "textIsRich",
    CONTEXT_TEXT: "text",
    CONTEXT_HTML: "html"
};

var text = {};

// The actual text content
text.text = granite.resource.properties[CONST.PROP_TEXT]
        || "";

// Wether the text contains HTML or not
text.context = granite.resource.properties[CONST.PROP_RICH_FORMAT]
        ? CONST.CONTEXT_HTML : CONST.CONTEXT_TEXT

// Set up placeholder if empty
if (!text.text) {
    text.cssClass = AuthoringUtils.isTouch
            ? "cq-placeholder"
            : "cq-text-placeholder-ipe";
    text.context = CONST.CONTEXT_TEXT;

    // only dysplay placeholder in edit mode
    if (typeof wcmmode != "undefined" && wcmmode.isEdit()) {
        text.text = AuthoringUtils.isTouch
        ? ""
        : "Edit text";
    } else {
        text.text = "";
    }
}

// Adding the constants to the exposed API
text.CONST = CONST;

return text;

});

最后是您的editConfig

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0"
jcr:primaryType="cq:EditConfig">
<cq:inplaceEditing
    jcr:primaryType="cq:InplaceEditingConfig"
    active="{Boolean}true"
    configPath="../../dialog/items/tab1/items/text"
    editorType="text"/>
<cq:listeners
    jcr:primaryType="cq:EditListenersConfig"
    afteredit="REFRESH_PAGE"
    afterinsert="REFRESH_PAGE"/>

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

在Sightly(AEM6)的parsys上设置emptyText

来自分类Dev

Umbraco富文本编辑器不会保存html标记<code>(将其转换为<p>(版本6))

来自分类Dev

如何在AEM 6触摸对话框中创建单选按钮

来自分类Dev

AEM6-如何在没有对话框的情况下编辑组件?

来自分类Dev

AEM6中的SSL配置问题

来自分类Dev

使用AEM插件设置Eclipse

来自分类Dev

AEM如何在AEM 6中打包用户组和权限

来自分类Dev

AEM 6:如何自定义Reviews Essentials组件

来自分类Dev

如何覆盖AEM 6中的占位符图标?

来自分类Dev

How to configure Custom Health Checks in Adobe AEM 6?

来自分类Dev

AEM 6 工作流清除何时运行?

来自分类Dev

AEM Touch UI RTE通用rtePlugins配置

来自分类Dev

跳至Sublime文本编辑器中的ES6箭头功能

来自分类Dev

如何在AEM上的列表组件对话框上使用子级编辑器?

来自分类Dev

AEM中的触摸UI与经典UI

来自分类Dev

将富文本字段添加到触摸 UI 对话框 - AEM 6.2

来自分类Dev

AngularJS的富文本编辑器

来自分类Dev

如何在Adobe AEM中启用WebDAV?

来自分类Dev

启用AEM 6.0 SolR的DAM资产全文

来自分类Dev

AEM是否支持在编辑器或作者模式下进行硒自动测试?

来自分类Dev

如何在Adobe AEM 6中配置自定义运行状况检查?

来自分类Dev

如何在aem6的吊索模型中适应子节点

来自分类Dev

AEM 6清晰可见:如何从语言文件中读取变量?

来自分类Dev

AEM6(CQ)通过模板将变量通过模板传递给javascript

来自分类Dev

AEM 6对话框中的条件显示/隐藏字段

来自分类Dev

AEM6-图像组件-我无法将图像渲染为背景

来自分类Dev

aem-6-2-节点的复制问题包含无效的jcr名称

来自分类Dev

AEM 6.x:如何将 HTL 变量传递给 clientlib/JS?

来自分类Dev

触摸UI对话框中的defaultValue-AEM / CQ

Related 相关文章

  1. 1

    在Sightly(AEM6)的parsys上设置emptyText

  2. 2

    Umbraco富文本编辑器不会保存html标记<code>(将其转换为<p>(版本6))

  3. 3

    如何在AEM 6触摸对话框中创建单选按钮

  4. 4

    AEM6-如何在没有对话框的情况下编辑组件?

  5. 5

    AEM6中的SSL配置问题

  6. 6

    使用AEM插件设置Eclipse

  7. 7

    AEM如何在AEM 6中打包用户组和权限

  8. 8

    AEM 6:如何自定义Reviews Essentials组件

  9. 9

    如何覆盖AEM 6中的占位符图标?

  10. 10

    How to configure Custom Health Checks in Adobe AEM 6?

  11. 11

    AEM 6 工作流清除何时运行?

  12. 12

    AEM Touch UI RTE通用rtePlugins配置

  13. 13

    跳至Sublime文本编辑器中的ES6箭头功能

  14. 14

    如何在AEM上的列表组件对话框上使用子级编辑器?

  15. 15

    AEM中的触摸UI与经典UI

  16. 16

    将富文本字段添加到触摸 UI 对话框 - AEM 6.2

  17. 17

    AngularJS的富文本编辑器

  18. 18

    如何在Adobe AEM中启用WebDAV?

  19. 19

    启用AEM 6.0 SolR的DAM资产全文

  20. 20

    AEM是否支持在编辑器或作者模式下进行硒自动测试?

  21. 21

    如何在Adobe AEM 6中配置自定义运行状况检查?

  22. 22

    如何在aem6的吊索模型中适应子节点

  23. 23

    AEM 6清晰可见:如何从语言文件中读取变量?

  24. 24

    AEM6(CQ)通过模板将变量通过模板传递给javascript

  25. 25

    AEM 6对话框中的条件显示/隐藏字段

  26. 26

    AEM6-图像组件-我无法将图像渲染为背景

  27. 27

    aem-6-2-节点的复制问题包含无效的jcr名称

  28. 28

    AEM 6.x:如何将 HTL 变量传递给 clientlib/JS?

  29. 29

    触摸UI对话框中的defaultValue-AEM / CQ

热门标签

归档