From 4b03b18a934ab889bfd00f8b85b811f15e764732 Mon Sep 17 00:00:00 2001 From: Shivam Agarwal <47965724+im-shiv@users.noreply.github.com> Date: Tue, 19 Mar 2024 08:55:59 +0530 Subject: [PATCH 1/4] Revert "Revert "Rich text support (#1077)" (#1129)" This reverts commit a249f93b96a5a02c61b947f70468d6afea906914. --- .../core/components/models/form/Label.java | 26 +- .../models/form/OptionsConstraint.java | 13 + .../components/models/form/TextContent.java | 51 ++++ .../components/models/form/package-info.java | 2 +- .../util/AbstractOptionsFieldImpl.java | 32 +++ .../models/v1/form/CheckBoxGroupImplTest.java | 45 ++++ .../models/v1/form/CheckBoxImplTest.java | 16 +- .../models/v1/form/DropDownImplTest.java | 47 ++++ .../models/v1/form/RadioButtonImplTest.java | 43 ++- .../exporter-checkboxgroup-datalayer.json | 8 +- .../checkboxgroup/exporter-checkboxgroup.json | 12 +- .../form/dropdown/exporter-dropdown-1.json | 12 +- .../dropdown/exporter-dropdown-datalayer.json | 8 +- .../form/dropdown/exporter-dropdown.json | 12 +- .../exporter-multiselect-dropdown.json | 12 +- .../exporter-radiobutton-customized.json | 10 +- .../exporter-radiobutton-datalayer.json | 8 +- .../radiobutton/exporter-radiobutton.json | 10 +- .../form/radiobutton/test-content.json | 10 +- .../switch/exporter-switch-customized.json | 8 +- .../form/switch/exporter-switch.json | 8 +- ...exporter-termsandconditionsNoWrapData.json | 14 +- .../_jcr_content/dictionary/de.xml | 15 ++ .../_jcr_content/dictionary/es.xml | 15 ++ .../_jcr_content/dictionary/fr.xml | 15 ++ .../_jcr_content/dictionary/hi.xml | 15 ++ .../_jcr_content/dictionary/it.xml | 15 ++ .../_jcr_content/dictionary/ja.xml | 15 ++ .../_jcr_content/dictionary/ko-kr.xml | 15 ++ .../_jcr_content/dictionary/pt-br.xml | 15 ++ .../_jcr_content/dictionary/ru-ru.xml | 15 ++ .../_jcr_content/dictionary/zh-cn.xml | 15 ++ .../_jcr_content/dictionary/zh-tw.xml | 15 ++ .../samples/af2-form-translation/.content.xml | 25 +- .../samples/checkboxgroup/basic/.content.xml | 22 ++ .../termsandconditions/basic/.content.xml | 2 +- .../af-commons/v1/fieldTemplates/label.html | 4 +- .../v1/accordion/_cq_dialog/.content.xml | 8 + .../accordion/v1/accordion/accordion.html | 4 +- .../form/base/v1/base/_cq_dialog/.content.xml | 253 +++++++++++++++++- .../form/base/v1/base/_cq_editConfig.xml | 122 ++++++++- .../v1/base/clientlibs/editor/css/base.less | 2 +- .../base/clientlibs/editor/js/editDialog.js | 158 ++++++++++- .../button/v1/button/_cq_dialog/.content.xml | 7 +- .../form/button/v1/button/_cq_editConfig.xml | 122 ++++++++- .../form/button/v1/button/button.html | 2 +- .../form/checkbox/v1/checkbox/checkbox.html | 2 +- .../v1/checkboxgroup/checkboxgroup.html | 2 +- .../v1/checkboxgroup/widget.html | 2 +- .../v2/container/clientlibs/editorhook/js.txt | 1 + .../editorhook/js/toolbaractionhook.js | 55 ++++ .../datepicker/v1/datepicker/datepicker.html | 2 +- .../v1/dropdown/_cq_dialog/.content.xml | 51 +++- .../form/dropdown/v1/dropdown/dropdown.html | 8 +- .../emailinput/v1/emailinput/emailinput.html | 2 +- .../fileinput/v1/fileinput/fileinput.html | 2 +- .../image/v1/image/_cq_dialog/.content.xml | 6 + .../v1/numberinput/numberinput.html | 2 +- .../v1/panelcontainer/_cq_dialog/.content.xml | 8 + .../v1/panelcontainer/responsiveGrid.html | 2 +- .../v1/panelcontainer/simple.html | 2 +- .../v1/radiobutton/radiobutton.html | 4 +- .../v1/tabsontop/_cq_dialog/.content.xml | 8 + .../tabsontop/v1/tabsontop/tabsontop.html | 4 +- .../v1/telephoneinput/telephoneinput.html | 2 +- .../_cq_dialog/.content.xml | 16 +- .../fd/components/form/text/v1/text/text.html | 3 +- .../textinput/v1/textinput/textinput.html | 2 +- .../v1/toggleablelink/widget.html | 2 +- .../v1/verticaltabs/_cq_dialog/.content.xml | 8 + .../v1/verticaltabs/verticaltabs.html | 4 +- .../form/wizard/v1/wizard/wizard.html | 4 +- .../form/wizard/v2/wizard/wizard.html | 4 +- .../libs/commons/localeDataSets.js | 78 ++++-- ui.tests/test-module/specs/LocaleTest.spec.js | 2 +- .../specs/button/button.authoring.spec.js | 26 +- .../checkboxgroup.authoring.spec.js | 74 ++++- .../checkboxgroup.runtime.spec.js | 8 + .../specs/image/image.authoring.spec.js | 15 +- .../panelcontainer.authoring.spec.js | 15 +- .../radiobutton/radiobutton.authoring.spec.js | 20 ++ .../termsandconditions/tnc.authoring.spec.js | 2 + .../textinput/textinput.authoring.spec.js | 35 ++- 83 files changed, 1614 insertions(+), 172 deletions(-) create mode 100644 bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/TextContent.java create mode 100644 ui.af.apps/src/main/content/jcr_root/apps/core/fd/components/form/container/v2/container/clientlibs/editorhook/js/toolbaractionhook.js diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/Label.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/Label.java index a7106b9f97..f1358b939c 100644 --- a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/Label.java +++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/Label.java @@ -21,21 +21,10 @@ /** * Interface for a label * - * @since com.adobe.cq.forms.core.components.models.form 0.0.1 + * @since com.adobe.cq.forms.core.components.models.form 5.4.0 */ @ConsumerType -public interface Label { - - /** - * Returns {@code true} if label is rich text, otherwise {@code false}. - * - * @return {@code true} if label is rich text, otherwise {@code false} - * @since com.adobe.cq.forms.core.components.models.form 0.0.1 - */ - @Nullable - default Boolean isRichText() { - return null; - } +public interface Label extends TextContent { /** * Returns {@code true} if label should be visible, otherwise {@code false}. @@ -48,15 +37,4 @@ default Boolean isVisible() { return null; } - /** - * Returns the value of this label. - * - * @return the value of this label - * @since com.adobe.cq.forms.core.components.models.form 0.0.1 - */ - @Nullable - default String getValue() { - return null; - } - } diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/OptionsConstraint.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/OptionsConstraint.java index 2b949352d7..da35adad08 100644 --- a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/OptionsConstraint.java +++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/OptionsConstraint.java @@ -17,6 +17,7 @@ import org.osgi.annotation.versioning.ProviderType; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; /** @@ -57,5 +58,17 @@ default boolean isEnforceEnum() { * @return the list of enum names * @since com.adobe.cq.forms.core.components.models.form 0.0.1 */ + @Deprecated + @JsonIgnore String[] getEnumNames(); + + /** + * Returns a list of RichText to be displayed to the end user. + * The length of enum and enumNames array must match + * + * @return the list of enum names + * @since com.adobe.cq.forms.core.components.models.form 5.4.0 + */ + @JsonProperty("enumNames") + TextContent[] getEnumNamesAsTextContent(); } diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/TextContent.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/TextContent.java new file mode 100644 index 0000000000..248c78b9eb --- /dev/null +++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/TextContent.java @@ -0,0 +1,51 @@ +/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ Copyright 2023 Adobe + ~ + ~ Licensed under the Apache License, Version 2.0 (the "License"); + ~ you may not use this file except in compliance with the License. + ~ You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +package com.adobe.cq.forms.core.components.models.form; + +import org.jetbrains.annotations.Nullable; +import org.osgi.annotation.versioning.ProviderType; + +/** + * Interface to represent text as rich content + * + * @since com.adobe.cq.forms.core.components.models.form 5.4.0 + */ +@ProviderType +public interface TextContent { + + /** + * Returns {@code true} if text is rich, otherwise {@code false}. + * + * @return {@code true} if text is rich, otherwise {@code false} + * @since com.adobe.cq.forms.core.components.models.form 5.4.0 + */ + @Nullable + default Boolean isRichText() { + return null; + } + + /** + * Returns a user friendly text to display for the possible options to be shown to the end user. + * + * @return the content of this text + * @since com.adobe.cq.forms.core.components.models.form 5.4.0 + */ + @Nullable + default String getValue() { + return null; + } + +} diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/package-info.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/package-info.java index 1ed91396cf..e68a93b679 100644 --- a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/package-info.java +++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/models/form/package-info.java @@ -34,7 +34,7 @@ * version, is bound to this proxy component resource type. *
*/ -@Version("5.3.0") // aligning this with release/650 since af2-rest-api is compiled with 5.2.0 in release/650 +@Version("5.4.0") // aligning this with release/650 since af2-rest-api is compiled with 5.2.0 in release/650 package com.adobe.cq.forms.core.components.models.form; import org.osgi.annotation.versioning.Version; diff --git a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractOptionsFieldImpl.java b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractOptionsFieldImpl.java index 90fe5ba473..10dabbbd46 100644 --- a/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractOptionsFieldImpl.java +++ b/bundles/af-core/src/main/java/com/adobe/cq/forms/core/components/util/AbstractOptionsFieldImpl.java @@ -29,6 +29,9 @@ import com.adobe.cq.forms.core.components.models.form.Field; import com.adobe.cq.forms.core.components.models.form.OptionsConstraint; +import com.adobe.cq.forms.core.components.models.form.TextContent; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; /** * Abstract class which can be used as base class for options {@link Field} implementations. @@ -49,6 +52,10 @@ public abstract class AbstractOptionsFieldImpl extends AbstractFieldImpl impleme @Nullable protected String[] enumNames; + @ValueMapValue(injectionStrategy = InjectionStrategy.OPTIONAL, name = "areOptionsRichText") + @Nullable + private Boolean areOptionsRichText; + @Override public boolean isEnforceEnum() { return enforceEnum; @@ -95,6 +102,8 @@ public Object[] getEnums() { } @Override + @Deprecated + @JsonIgnore public String[] getEnumNames() { if (enumNames != null) { Map