initializeToolbarConfig() {
- return Optional.ofNullable(getDefinition())
- .flatMap(ExtendedRichTextDefinition::getToolbarConfig)
- .map(RichTextToolbarConfig::getConfig)
- .orElseGet(() -> {
- LOG.info("No toolbar configuration set.");
- return Collections.emptyList();
- });
+ protected Component createFieldComponent() {
+ final ExtendedCKEditor5TextFieldConfig config = getConfig();
+
+ final ExtendedCKEditor5TextField field = new ExtendedCKEditor5TextField();
+ field.setConfig(config);
+
+ //TODO ask magnolia to expose listeners
+ field.addListener((eventName, value) -> {
+ if (eventName.equals(EVENT_GET_MAGNOLIA_LINK)) {
+ try {
+ final Gson gson = new Gson();
+ final PluginData pluginData = gson.fromJson(value, PluginData.class);
+ openLinkDialog(field, pluginData, node -> {
+ final MagnoliaLink mlink = createMagnoliaLink(node);
+ field.firePluginEvent(EVENT_SEND_MAGNOLIA_LINK, new Gson().toJson(mlink));
+ });
+ } catch (Exception e) {
+ LOG.error("openLinkDialog failed", e);
+ field.firePluginEvent(EVENT_CANCEL_LINK, i18n.translate("ui-framework-core.richtexteditorexception.opentargetappfailure"));
+ }
+ } else if (eventName.equals("chooseAsset")) {
+ chooseAsset(field, value);
+ }
+ });
+ return field;
+ }
+
+ private void chooseAsset(MagnoliaCKEditorTextFieldEvents richTextEditor, String path) {
+ openLinkDialog(richTextEditor, new PluginData(DAM_WORKSPACE, path), item ->
+ richTextEditor.firePluginEvent("assetChosen", toAssetJson((Item) item))
+ );
}
@Override
- protected MagnoliaCKEditorConfig initializeCKEditorConfig() {
- final String path = VaadinService.getCurrentRequest().getContextPath();
- @Nullable
- final String configJsFile = getDefinition().getConfigJsFile();
- getDefinition().setConfigJsFile(null); //super.initializeCKEditorConfig is not applying other configs if configJs file is present
- final MagnoliaCKEditorConfig config = super.initializeCKEditorConfig();
- if(configJsFile != null) {
- config.addExtraConfig("customConfig", "'" + path + configJsFile + "'");
+ protected MagnoliaLink createMagnoliaLink(final Object object) {
+ //TODO broken in magnolia info.magnolia.ui.field.factory.RichTextFieldFactory
+ if (object instanceof Node) {
+ return Exceptions.wrap().get(() -> {
+ final Node node = (Node) object;
+ final MagnoliaLink mlink = new MagnoliaLink();
+ mlink.identifier = node.getIdentifier();
+ mlink.repository = RepositoryConstants.WEBSITE;
+ mlink.path = node.getPath();
+ mlink.caption = node.getName();
+ return mlink;
+ });
}
+ return super.createMagnoliaLink(object);
+ }
- // by default is allowedContent = true
- config.setAllowedContentAll();
-
- getDefinition().getExtraConfig().forEach(config::addExtraConfig);
- getDefinition().getExternalPlugins().forEach(config::addExternalPlugin);
- getDefinition().getExternalPlugins().keySet().forEach(config::addToExtraPlugins);
- config.setForcePasteAsPlainText(getDefinition().isForcePasteAsPlainText());
- config.setPasteFromWordRemoveFontStyles(getDefinition().isPasteFromWordRemoveFontStyles());
- config.setPasteFromWordPromptCleanup(getDefinition().isPasteFromWordPromptCleanup());
- // set enter mode (default is ):
- getDefinition().getEnterMode().ifPresent(config::setEnterMode);
- getDefinition().getExtraAllowedContent().ifPresent(config::setExtraAllowedContent);
- getDefinition().getContentCss().ifPresent(config::setContentsCss);
- getDefinition().getBodyClass().ifPresent(config::setBodyClass);
- getDefinition().getFormatTags().ifPresent(formatTags ->
- config.addExtraConfig("format_tags", "'" + formatTags + "'")
- );
- getDefinition().getCustomStyleSet().ifPresent(customStyleSet ->
- config.setStylesSet(customStyleSet + "?uncache= " + System.currentTimeMillis())
+ private ExtendedCKEditor5TextFieldConfig getConfig() {
+ if (getDefinition().getEditorType() != null) {
+ return new ExtendedCKEditor5TextFieldConfig(ckEditor5Config.getCkeditor5License(), Collections.emptyList(), Collections.emptyList());
+ }
+ return new ExtendedCKEditor5TextFieldConfig(
+ ckEditor5Config.getCkeditor5License(),
+ getDefinition().getToolbarConfig().map(RichTextToolbarConfig::getConfig).orElseGet(Collections::emptyList),
+ getDefinition().getHeadings()
);
- getDefinition().getCustomTemplates().ifPresent(customTemplates -> {
- config.addTemplatesFiles(customTemplates + "?uncache= " + System.currentTimeMillis());
- config.setTemplatesReplaceContent(false);
- getDefinition().getTemplate().ifPresent(templates ->
- config.addExtraConfig("templates", "'" + templates + "'")
- );
- });
- return config;
+ }
+
+ @Override
+ protected MagnoliaCKEditorConfig initializeCKEditorConfig() {
+ throw new UnsupportedOperationException("ExtendedRichText only supports "+ RichTextFieldDefinition.CKEditorVersion.CKEDITOR_5);
}
@Override
diff --git a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/HeadingOption.java b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/HeadingOption.java
new file mode 100644
index 0000000..7f8901a
--- /dev/null
+++ b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/HeadingOption.java
@@ -0,0 +1,45 @@
+package com.merkle.oss.magnolia.definition.custom.richtext;
+
+import java.util.Optional;
+
+import javax.annotation.Nullable;
+
+public enum HeadingOption {
+ PARAGRAPH("paragraph", null, "Paragraph", "ck-heading_paragraph"),
+ HEADING_1("heading1", "h1", "Heading 1", "ck-heading_heading1"),
+ HEADING_2("heading2", "h2", "Heading 2", "ck-heading_heading2"),
+ HEADING_3("heading3", "h3", "Heading 3", "ck-heading_heading3"),
+ HEADING_4("heading4", "h4", "Heading 4", "ck-heading_heading4"),
+ HEADING_5("heading5", "h5", "Heading 5", "ck-heading_heading5"),
+ HEADING_6("heading6", "h6", "Heading 6", "ck-heading_heading6"),
+ ;
+
+ private final String model;
+ @Nullable
+ private final String view;
+ private final String title;
+ private final String clazz;
+
+ HeadingOption(final String model, @Nullable final String view, final String title, final String clazz) {
+ this.model = model;
+ this.view = view;
+ this.title = title;
+ this.clazz = clazz;
+ }
+
+ public String getModel() {
+ return model;
+ }
+
+ public Optional getView() {
+ return Optional.ofNullable(view);
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public String getClazz() {
+ return clazz;
+ }
+}
diff --git a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/extended-ckeditor5-text-field-connector.js b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/extended-ckeditor5-text-field-connector.js
new file mode 100644
index 0000000..1e4de2a
--- /dev/null
+++ b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/extended-ckeditor5-text-field-connector.js
@@ -0,0 +1,62 @@
+com_merkle_oss_magnolia_definition_custom_richtext_ExtendedCKEditor5TextField =
+ function () {
+ const connector = this;
+ let state = this.getState();
+ let editor;
+ let config = state.extendedConfig;
+
+ config.heading.options.forEach((option) => option.class = option.clazz);
+
+ // name of the object produced by @magnolia/ckeditor5-integration
+ let buildObject = window["ClassicEditor"];
+ if (this.getState().editorType) {
+ buildObject = CKEDITOR[this.getState().editorType];
+ config = {'licenseKey': config.licenseKey};
+ }
+
+ buildObject.create(this.getElement(), config)
+ .then(newEditor => {
+ let data = this.getState().value;
+ if (data != null) {
+ newEditor.setData(data);
+ }
+ newEditor.model.document.on('change:data', () => {
+ connector.onDataChange(editor.getData());
+ });
+ newEditor.keystrokes.set( 'Enter', ( evt, data ) => {
+ // prevent the enter key from submitting the form
+ evt.stopPropagation();
+ } );
+ newEditor.editing.view.change( writer => {
+ if (this.getState().height != null) {
+ writer.setStyle('height', this.getState().height, newEditor.editing.view.document.getRoot());
+ }
+ } );
+
+ // Handle changes from the server-side
+ this.onReceiveEventFromServer = function (name, value) {
+ // dispatch the event to the corresponding editor plugin listener
+ newEditor.fire(name, value);
+ };
+
+ // Pass user interaction to the server-side
+ newEditor.listenTo(newEditor, 'mgnlPluginButtonClicked', (evt, data) => {
+ let connectorEvent = evt.name;
+ if (evt.name.includes(':')){
+ connectorEvent = evt.name.split(':')[1];
+ }
+ connector.onReceiveEventFromClient(connectorEvent, data);
+ })
+
+ editor = newEditor;
+ })
+ .catch(error => {
+ console.error(error);
+ });
+
+ // Destroy the editor when the component is detached from UI
+ this.onUnregister = function () {
+ editor.destroy().catch(error => console.error(error));
+ }
+ };
+
diff --git a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/RichTextToolbar.java b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/RichTextToolbar.java
index 4825234..4a4c78c 100755
--- a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/RichTextToolbar.java
+++ b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/RichTextToolbar.java
@@ -2,7 +2,6 @@
import com.merkle.oss.magnolia.definition.custom.richtext.toolbarbuilder.groupbuilder.AbstractToolbarGroupBuilder;
-import info.magnolia.ui.vaadin.ckeditor.MagnoliaCKEditorConfig.ToolbarGroup;
import java.util.ArrayList;
import java.util.List;
@@ -55,12 +54,7 @@ public Builder add(final AbstractToolbarGroupBuilder> groupBuilder) {
public RichTextToolbar build() {
return new RichTextToolbar(
toolsBuilders.stream()
- .map(toolbarGroupBuilder ->
- new ToolbarGroup(
- toolbarGroupBuilder.getName(),
- toolbarGroupBuilder.getOptions().toArray(String[]::new)
- )
- )
+ .map(AbstractToolbarGroupBuilder::build)
.collect(Collectors.toList())
);
}
diff --git a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/RichTextToolbarConfig.java b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/RichTextToolbarConfig.java
index c1a4bb6..2df1843 100755
--- a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/RichTextToolbarConfig.java
+++ b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/RichTextToolbarConfig.java
@@ -1,7 +1,5 @@
package com.merkle.oss.magnolia.definition.custom.richtext.toolbarbuilder;
-import info.magnolia.ui.vaadin.ckeditor.MagnoliaCKEditorConfig.ToolbarGroup;
-
import java.util.List;
import java.util.function.UnaryOperator;
diff --git a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/ToolbarGroup.java b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/ToolbarGroup.java
new file mode 100644
index 0000000..394285a
--- /dev/null
+++ b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/ToolbarGroup.java
@@ -0,0 +1,44 @@
+package com.merkle.oss.magnolia.definition.custom.richtext.toolbarbuilder;
+
+import java.util.List;
+import java.util.Objects;
+
+public class ToolbarGroup {
+ private final String name;
+ private final List items;
+
+ public ToolbarGroup(final String name, final List items) {
+ this.name = name;
+ this.items = items;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public List getItems() {
+ return items;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ ToolbarGroup that = (ToolbarGroup) o;
+ return Objects.equals(name, that.name) && Objects.equals(items, that.items);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(name, items);
+ }
+
+ @Override
+ public String toString() {
+ return "ToolbarGroup{" +
+ "name='" + name + '\'' +
+ ", items=" + items +
+ '}';
+ }
+}
\ No newline at end of file
diff --git a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/AbstractToolbarGroupBuilder.java b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/AbstractToolbarGroupBuilder.java
index 157f51c..1b59fab 100755
--- a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/AbstractToolbarGroupBuilder.java
+++ b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/AbstractToolbarGroupBuilder.java
@@ -1,49 +1,50 @@
package com.merkle.oss.magnolia.definition.custom.richtext.toolbarbuilder.groupbuilder;
-import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
import java.util.List;
-import java.util.Objects;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import javax.annotation.Nullable;
+
+import com.merkle.oss.magnolia.definition.custom.richtext.toolbarbuilder.ToolbarGroup;
public abstract class AbstractToolbarGroupBuilder> {
- private final String name;
- private final List options = new ArrayList<>();
+ private final String label;
+ @Nullable
+ private List options;
- public AbstractToolbarGroupBuilder(final String name) {
- this.name = name;
+ public AbstractToolbarGroupBuilder(final String label) {
+ this.label = label;
}
- public String getName() {
- return name;
+ public String getLabel() {
+ return label;
}
- @SuppressWarnings("unchecked")
public T option(final String option) {
- options.add(option);
- return (T)this;
+ return options(Stream.concat(
+ Stream.ofNullable(options).flatMap(Collection::stream),
+ Stream.of(option)
+ ).collect(Collectors.toList()));
}
- public List getOptions() {
- return options;
+ public T options(final List options) {
+ this.options = options;
+ return self();
}
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- AbstractToolbarGroupBuilder> that = (AbstractToolbarGroupBuilder>) o;
- return Objects.equals(name, that.name) && Objects.equals(options, that.options);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(name, options);
+ @SuppressWarnings("unchecked")
+ protected T self() {
+ return (T) this;
}
- @Override
- public String toString() {
- return "ToolbarGroupBuilder{" +
- "name='" + name + '\'' +
- ", options=" + options +
- '}';
+ public ToolbarGroup build() {
+ return new ToolbarGroup(
+ label,
+ Optional.ofNullable(options).orElseGet(Collections::emptyList)
+ );
}
}
diff --git a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/BasicStylesGroupBuilder.java b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/BasicStylesGroupBuilder.java
deleted file mode 100755
index 0273db6..0000000
--- a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/BasicStylesGroupBuilder.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.merkle.oss.magnolia.definition.custom.richtext.toolbarbuilder.groupbuilder;
-
-public class BasicStylesGroupBuilder extends AbstractToolbarGroupBuilder {
-
- public BasicStylesGroupBuilder() {
- super("basicstyles");
- }
-
- public BasicStylesGroupBuilder bold() {
- return option("Bold");
- }
-
- public BasicStylesGroupBuilder italic() {
- return option("Italic");
- }
-
- public BasicStylesGroupBuilder underline() {
- return option("Underline");
- }
-
- public BasicStylesGroupBuilder strike() {
- return option("Strike");
- }
-
- public BasicStylesGroupBuilder subscript() {
- return option("Subscript");
- }
-
- public BasicStylesGroupBuilder superscript() {
- return option("Superscript");
- }
-
- public BasicStylesGroupBuilder removeFormat() {
- return option("RemoveFormat");
- }
-
- public BasicStylesGroupBuilder specialChar() {
- return option("SpecialChar");
- }
-}
diff --git a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/ClipboardGroupBuilder.java b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/ClipboardGroupBuilder.java
deleted file mode 100755
index 116e788..0000000
--- a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/ClipboardGroupBuilder.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.merkle.oss.magnolia.definition.custom.richtext.toolbarbuilder.groupbuilder;
-
-public class ClipboardGroupBuilder extends AbstractToolbarGroupBuilder {
-
- public ClipboardGroupBuilder() {
- super("clipboard");
- }
-
- public ClipboardGroupBuilder cut() {
- return option("Cut");
- }
-
- public ClipboardGroupBuilder copy() {
- return option("Copy");
- }
-
- public ClipboardGroupBuilder paste() {
- return option("Paste");
- }
-
- public ClipboardGroupBuilder pasteText() {
- return option("PasteText");
- }
-
- public ClipboardGroupBuilder pasteFromWord() {
- return option("PasteFromWord");
- }
-}
\ No newline at end of file
diff --git a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/FontGroupBuilder.java b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/FontGroupBuilder.java
new file mode 100755
index 0000000..6575a77
--- /dev/null
+++ b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/FontGroupBuilder.java
@@ -0,0 +1,114 @@
+package com.merkle.oss.magnolia.definition.custom.richtext.toolbarbuilder.groupbuilder;
+
+import info.magnolia.ui.vaadin.ckeditor.CKEditor5TextFieldConfig.FontColor;
+import info.magnolia.ui.vaadin.ckeditor.CKEditor5TextFieldConfig.FontFamily;
+import info.magnolia.ui.vaadin.ckeditor.CKEditor5TextFieldConfig.FontSize;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import javax.annotation.Nullable;
+
+import com.merkle.oss.magnolia.definition.custom.richtext.toolbarbuilder.ToolbarGroup;
+
+public class FontGroupBuilder extends AbstractToolbarGroupBuilder {
+ @Nullable
+ private List fonts;
+ @Nullable
+ private List fontSizes;
+ @Nullable
+ private List fontColors;
+
+ public FontGroupBuilder() {
+ super("font");
+ }
+
+ public FontGroupBuilder heading() {
+ return option("heading");
+ }
+
+ public FontGroupBuilder fontFamily(final List fonts) {
+ this.fonts = fonts;
+ return option("fontFamily");
+ }
+
+ public FontGroupBuilder fontSize(final List fontSizes) {
+ this.fontSizes = fontSizes;
+ return option("fontSize");
+ }
+
+ public FontGroupBuilder fontColor(final List fontColors) {
+ this.fontColors = fontColors;
+ return option("fontColor");
+ }
+
+ @Override
+ public ToolbarGroup build() {
+ final ToolbarGroup toolbarGroup = super.build();
+ return new FontToolbarGroup(
+ toolbarGroup,
+ Stream.ofNullable(fonts).flatMap(Collection::stream).map(font -> new FontFamily.Option(font.trim())).collect(Collectors.toList()),
+ Stream.ofNullable(fontSizes).flatMap(Collection::stream).map(font -> new FontSize.Option(font.trim())).collect(Collectors.toList()),
+ Stream.ofNullable(fontColors).flatMap(Collection::stream).map(font -> new FontColor.ColorOption("#"+font.trim())).collect(Collectors.toList())
+ );
+ }
+
+ public static class FontToolbarGroup extends ToolbarGroup {
+ private final List fonts;
+ private final List fontSizes;
+ private final List fontColors;
+
+ public FontToolbarGroup(
+ final ToolbarGroup wrapped,
+ final List fonts,
+ final List fontSizes,
+ final List fontColors
+ ) {
+ super(wrapped.getName(), wrapped.getItems());
+ this.fonts = fonts;
+ this.fontSizes = fontSizes;
+ this.fontColors = fontColors;
+ }
+
+ public List getFonts() {
+ return fonts;
+ }
+
+ public List getFontSizes() {
+ return fontSizes;
+ }
+
+ public List getFontColors() {
+ return fontColors;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ if (!super.equals(o)) {
+ return false;
+ }
+ FontToolbarGroup that = (FontToolbarGroup) o;
+ return Objects.equals(fonts, that.fonts) && Objects.equals(fontSizes, that.fontSizes) && Objects.equals(fontColors, that.fontColors);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(super.hashCode(), fonts, fontSizes, fontColors);
+ }
+
+ @Override
+ public String toString() {
+ return "FontToolbarGroup{" +
+ "fonts=" + fonts +
+ ", fontSizes=" + fontSizes +
+ ", fontColors=" + fontColors +
+ "} " + super.toString();
+ }
+ }
+}
\ No newline at end of file
diff --git a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/FormattingGroupBuilder.java b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/FormattingGroupBuilder.java
new file mode 100755
index 0000000..27dc61f
--- /dev/null
+++ b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/FormattingGroupBuilder.java
@@ -0,0 +1,40 @@
+package com.merkle.oss.magnolia.definition.custom.richtext.toolbarbuilder.groupbuilder;
+
+public class FormattingGroupBuilder extends AbstractToolbarGroupBuilder {
+
+ public FormattingGroupBuilder() {
+ super("formatting");
+ }
+
+ public FormattingGroupBuilder bold() {
+ return option("bold");
+ }
+
+ public FormattingGroupBuilder italic() {
+ return option("italic");
+ }
+
+ public FormattingGroupBuilder underline() {
+ return option("underline");
+ }
+
+ public FormattingGroupBuilder strike() {
+ return option("strikethrough");
+ }
+
+ public FormattingGroupBuilder subscript() {
+ return option("subscript");
+ }
+
+ public FormattingGroupBuilder superscript() {
+ return option("superscript");
+ }
+
+ public FormattingGroupBuilder removeFormat() {
+ return option("removeFormat");
+ }
+
+ public FormattingGroupBuilder specialChar() {
+ return option("specialCharacters");
+ }
+}
diff --git a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/ImageGroupBuilder.java b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/ImageGroupBuilder.java
new file mode 100755
index 0000000..51d2f77
--- /dev/null
+++ b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/ImageGroupBuilder.java
@@ -0,0 +1,12 @@
+package com.merkle.oss.magnolia.definition.custom.richtext.toolbarbuilder.groupbuilder;
+
+public class ImageGroupBuilder extends AbstractToolbarGroupBuilder {
+
+ public ImageGroupBuilder() {
+ super("image");
+ }
+
+ public ImageGroupBuilder image() {
+ return option("insertImage");
+ }
+}
\ No newline at end of file
diff --git a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/LinksGroupBuilder.java b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/LinksGroupBuilder.java
index 3a7a9d0..91f4509 100755
--- a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/LinksGroupBuilder.java
+++ b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/LinksGroupBuilder.java
@@ -7,18 +7,14 @@ public LinksGroupBuilder() {
}
public LinksGroupBuilder link() {
- return option("Link");
+ return option("link");
}
public LinksGroupBuilder internalLink() {
- return option("InternalLink");
+ return option("mgnlPagesLink");
}
public LinksGroupBuilder damLink() {
- return option("DamLink");
- }
-
- public LinksGroupBuilder unlink() {
- return option("Unlink");
+ return option("mgnlAssetsLink");
}
}
\ No newline at end of file
diff --git a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/ListGroupBuilder.java b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/ListGroupBuilder.java
new file mode 100644
index 0000000..0eff2a1
--- /dev/null
+++ b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/ListGroupBuilder.java
@@ -0,0 +1,20 @@
+package com.merkle.oss.magnolia.definition.custom.richtext.toolbarbuilder.groupbuilder;
+
+public class ListGroupBuilder extends AbstractToolbarGroupBuilder {
+
+ public ListGroupBuilder() {
+ super("list");
+ }
+
+ public ListGroupBuilder bulletedList() {
+ return option("bulletedList");
+ }
+
+ public ListGroupBuilder numberedList() {
+ return option("numberedList");
+ }
+
+ public ListGroupBuilder todoList() {
+ return option("todoList");
+ }
+}
\ No newline at end of file
diff --git a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/OptionsGroupBuilder.java b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/OptionsGroupBuilder.java
deleted file mode 100644
index 6d45b12..0000000
--- a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/OptionsGroupBuilder.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.merkle.oss.magnolia.definition.custom.richtext.toolbarbuilder.groupbuilder;
-
-public class OptionsGroupBuilder extends AbstractToolbarGroupBuilder {
-
- public OptionsGroupBuilder() {
- super("options");
- }
-
- public OptionsGroupBuilder showBlocks() {
- return option("ShowBlocks");
- }
-}
\ No newline at end of file
diff --git a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/ParagraphGroupBuilder.java b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/ParagraphGroupBuilder.java
deleted file mode 100755
index ab0b664..0000000
--- a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/ParagraphGroupBuilder.java
+++ /dev/null
@@ -1,40 +0,0 @@
-package com.merkle.oss.magnolia.definition.custom.richtext.toolbarbuilder.groupbuilder;
-
-public class ParagraphGroupBuilder extends AbstractToolbarGroupBuilder {
-
- public ParagraphGroupBuilder() {
- super("paragraph");
- }
-
- public ParagraphGroupBuilder numberedList() {
- return option("NumberedList");
- }
-
- public ParagraphGroupBuilder bulletedList() {
- return option("BulletedList");
- }
-
- public ParagraphGroupBuilder justifyLeft() {
- return option("JustifyLeft");
- }
-
- public ParagraphGroupBuilder justifyCenter() {
- return option("JustifyCenter");
- }
-
- public ParagraphGroupBuilder justifyRight() {
- return option("JustifyRight");
- }
-
- public ParagraphGroupBuilder justifyBlock() {
- return option("JustifyBlock");
- }
-
- public ParagraphGroupBuilder image() {
- return option("Image");
- }
-
- public ParagraphGroupBuilder table() {
- return option("Table");
- }
-}
\ No newline at end of file
diff --git a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/PositionGroupBuilder.java b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/PositionGroupBuilder.java
new file mode 100755
index 0000000..f9b2d3b
--- /dev/null
+++ b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/PositionGroupBuilder.java
@@ -0,0 +1,20 @@
+package com.merkle.oss.magnolia.definition.custom.richtext.toolbarbuilder.groupbuilder;
+
+public class PositionGroupBuilder extends AbstractToolbarGroupBuilder {
+
+ public PositionGroupBuilder() {
+ super("position");
+ }
+
+ public PositionGroupBuilder alignment() {
+ return option("alignment");
+ }
+
+ public PositionGroupBuilder outdent() {
+ return option("outdent");
+ }
+
+ public PositionGroupBuilder indent() {
+ return option("indent");
+ }
+}
diff --git a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/StylingGroupBuilder.java b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/StylingGroupBuilder.java
deleted file mode 100755
index c6f46df..0000000
--- a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/StylingGroupBuilder.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.merkle.oss.magnolia.definition.custom.richtext.toolbarbuilder.groupbuilder;
-
-public class StylingGroupBuilder extends AbstractToolbarGroupBuilder {
-
- public StylingGroupBuilder() {
- super("styling");
- }
-
- public StylingGroupBuilder format() {
- return option("Format");
- }
-
- public StylingGroupBuilder styles() {
- return option("Styles");
- }
-
- public StylingGroupBuilder templates() {
- return option("Templates");
- }
-}
\ No newline at end of file
diff --git a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/TableGroupBuilder.java b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/TableGroupBuilder.java
index 3dc092e..e495ebe 100755
--- a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/TableGroupBuilder.java
+++ b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/TableGroupBuilder.java
@@ -7,6 +7,6 @@ public TableGroupBuilder() {
}
public TableGroupBuilder table() {
- return option("Table");
+ return option("insertTable");
}
}
\ No newline at end of file
diff --git a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/ToolsGroupBuilder.java b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/ToolsGroupBuilder.java
index 31b2826..682e48e 100755
--- a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/ToolsGroupBuilder.java
+++ b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/ToolsGroupBuilder.java
@@ -7,6 +7,10 @@ public ToolsGroupBuilder() {
}
public ToolsGroupBuilder source() {
- return option("Source");
+ return option("sourceEditing");
+ }
+
+ public ToolsGroupBuilder codeBlock() {
+ return option("codeBlock");
}
}
\ No newline at end of file
diff --git a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/UndoGroupBuilder.java b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/UndoGroupBuilder.java
index 46a3332..43187e8 100755
--- a/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/UndoGroupBuilder.java
+++ b/custom-definitions/src/main/java/com/merkle/oss/magnolia/definition/custom/richtext/toolbarbuilder/groupbuilder/UndoGroupBuilder.java
@@ -7,10 +7,10 @@ public UndoGroupBuilder() {
}
public UndoGroupBuilder undo() {
- return option("Undo");
+ return option("undo");
}
public UndoGroupBuilder redo() {
- return option("Redo");
+ return option("redo");
}
}
\ No newline at end of file
diff --git a/custom-definitions/src/test/java/com/merkle/oss/magnolia/definition/custom/richtext/ExtendedRichTextDefinitionBuilderTest.java b/custom-definitions/src/test/java/com/merkle/oss/magnolia/definition/custom/richtext/ExtendedRichTextDefinitionBuilderTest.java
index 7446f76..98bab15 100644
--- a/custom-definitions/src/test/java/com/merkle/oss/magnolia/definition/custom/richtext/ExtendedRichTextDefinitionBuilderTest.java
+++ b/custom-definitions/src/test/java/com/merkle/oss/magnolia/definition/custom/richtext/ExtendedRichTextDefinitionBuilderTest.java
@@ -1,13 +1,13 @@
package com.merkle.oss.magnolia.definition.custom.richtext;
-import com.merkle.oss.magnolia.definition.custom.richtext.toolbarbuilder.RichTextToolbar;
-import org.junit.jupiter.api.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import java.util.Map;
+import java.util.List;
import java.util.Optional;
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
+import org.junit.jupiter.api.Test;
+
+import com.merkle.oss.magnolia.definition.custom.richtext.toolbarbuilder.RichTextToolbar;
class ExtendedRichTextDefinitionBuilderTest {
@@ -15,37 +15,12 @@ class ExtendedRichTextDefinitionBuilderTest {
void testBuilder() {
final RichTextToolbar richTextToolbar = RichTextToolbar.builder().build();
final ExtendedRichTextDefinition definition = new ExtendedRichTextDefinitionBuilder()
- .formatTags("formatTags")
- .customStyleSet("customStyleSet")
- .customTemplates("customTemplates")
- .template("template")
- .enterMode("enterMode")
- .contentCss("contentCss")
- .extraAllowedContent("extraAllowedContent")
- .forcePasteAsPlainText(true)
- .pasteFromWordPromptCleanup(true)
- .pasteFromWordRemoveFontStyles(true)
- .bodyClass("bodyClass")
+ .headings(List.of(HeadingOption.PARAGRAPH, HeadingOption.HEADING_1))
+ .heading(HeadingOption.HEADING_2)
.toolbarConfig(richTextToolbar)
- .externalPlugin("plugin1", "source1")
- .externalPlugin("plugin2", "source2")
- .extraConfig("config1", "value1")
- .extraConfig("config2", "value2")
.build("extendedRichText");
- assertEquals(Optional.of("formatTags"), definition.getFormatTags());
- assertEquals(Optional.of("customStyleSet"), definition.getCustomStyleSet());
- assertEquals(Optional.of("customTemplates"), definition.getCustomTemplates());
- assertEquals(Optional.of("template"), definition.getTemplate());
- assertEquals(Optional.of("enterMode"), definition.getEnterMode());
- assertEquals(Optional.of("contentCss"), definition.getContentCss());
- assertEquals(Optional.of("extraAllowedContent"), definition.getExtraAllowedContent());
- assertTrue(definition.isForcePasteAsPlainText());
- assertTrue(definition.isPasteFromWordPromptCleanup());
- assertTrue(definition.isPasteFromWordRemoveFontStyles());
- assertEquals(Optional.of("bodyClass"), definition.getBodyClass());
+ assertEquals(List.of(HeadingOption.PARAGRAPH, HeadingOption.HEADING_1, HeadingOption.HEADING_2), definition.getHeadings());
assertEquals(Optional.of(richTextToolbar), definition.getToolbarConfig());
- assertEquals(Map.of("plugin1", "source1", "plugin2", "source2"), definition.getExternalPlugins());
- assertEquals(Map.of("config1", "value1", "config2", "value2"), definition.getExtraConfig());
}
}
\ No newline at end of file
diff --git a/magnolia-builders/src/main/java/com/merkle/oss/magnolia/definition/builder/simple/AbstractRichTextFieldDefinitionBuilder.java b/magnolia-builders/src/main/java/com/merkle/oss/magnolia/definition/builder/simple/AbstractRichTextFieldDefinitionBuilder.java
index f963fe8..92445ed 100644
--- a/magnolia-builders/src/main/java/com/merkle/oss/magnolia/definition/builder/simple/AbstractRichTextFieldDefinitionBuilder.java
+++ b/magnolia-builders/src/main/java/com/merkle/oss/magnolia/definition/builder/simple/AbstractRichTextFieldDefinitionBuilder.java
@@ -37,7 +37,11 @@ public abstract class AbstractRichTextFieldDefinitionBuilder> linkFieldDefinitions;
+ @Nullable
+ private RichTextFieldDefinition.CKEditorVersion ckEditorVersion;
protected AbstractRichTextFieldDefinitionBuilder() {}
protected AbstractRichTextFieldDefinitionBuilder(final D definition) {
@@ -52,6 +56,7 @@ protected AbstractRichTextFieldDefinitionBuilder(final D definition) {
fonts(definition.getFonts());
fontSizes(definition.getFontSizes());
configJsFile(definition.getConfigJsFile());
+ editorType(definition.getEditorType());
linkFieldDefinitions(definition.getLinkFieldDefinitions());
}
@@ -100,11 +105,22 @@ public B fontSizes(final String fontSizes) {
return self();
}
+ @Deprecated
public B configJsFile(final String configJsFile) {
this.configJsFile = configJsFile;
return self();
}
+ public B editorType(final String editorType) {
+ this.editorType = editorType;
+ return self();
+ }
+
+ public B ckEditorVersion(final RichTextFieldDefinition.CKEditorVersion ckEditorVersion) {
+ this.ckEditorVersion = ckEditorVersion;
+ return self();
+ }
+
public B linkFieldDefinition(final String key, final LinkFieldDefinition> value) {
return linkFieldDefinitions(Stream.concat(
Stream.ofNullable(linkFieldDefinitions).map(Map::entrySet).flatMap(Collection::stream),
@@ -130,6 +146,8 @@ protected void populate(final D definition, final String name) {
Optional.ofNullable(fonts).ifPresent(definition::setFonts);
Optional.ofNullable(fontSizes).ifPresent(definition::setFontSizes);
Optional.ofNullable(configJsFile).ifPresent(definition::setConfigJsFile);
+ Optional.ofNullable(editorType).ifPresent(definition::setEditorType);
+ Optional.ofNullable(ckEditorVersion).ifPresent(definition::setCkEditorVersion);
Stream.ofNullable(linkFieldDefinitions).map(Map::entrySet).flatMap(Collection::stream).forEach(entry ->
definition.getLinkFieldDefinitions().put(entry.getKey(), entry.getValue())
);