Skip to content

Commit

Permalink
Fix richtext dam asset filebrowser
Browse files Browse the repository at this point in the history
  • Loading branch information
eschleb committed Apr 30, 2024
1 parent b6571f7 commit f67539a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
package com.merkle.oss.magnolia.definition.custom.richtext;

import com.merkle.oss.magnolia.definition.custom.richtext.toolbarbuilder.RichTextToolbarConfig;
import info.magnolia.ui.field.RichTextFieldDefinition;
import info.magnolia.dam.app.field.DamRichTextFieldDefinition;

import javax.annotation.Nullable;
import java.util.Collections;
import java.util.Map;
import java.util.Optional;

public class ExtendedRichTextDefinition extends RichTextFieldDefinition {
import javax.annotation.Nullable;

import com.merkle.oss.magnolia.definition.custom.richtext.toolbarbuilder.RichTextToolbarConfig;

public class ExtendedRichTextDefinition extends DamRichTextFieldDefinition {
@Nullable
private String formatTags;
@Nullable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
package com.merkle.oss.magnolia.definition.custom.richtext;

import com.merkle.oss.magnolia.definition.custom.richtext.toolbarbuilder.RichTextToolbarConfig;
import com.vaadin.server.VaadinService;
import info.magnolia.dam.api.AssetProviderRegistry;
import info.magnolia.dam.app.field.factory.DamRichTextFieldFactory;
import info.magnolia.i18nsystem.I18nizer;
import info.magnolia.i18nsystem.SimpleTranslator;
import info.magnolia.ui.dialog.DialogDefinitionRegistry;
import info.magnolia.ui.field.factory.RichTextFieldFactory;
import info.magnolia.ui.framework.ioc.UiComponentProvider;
import info.magnolia.ui.vaadin.ckeditor.MagnoliaCKEditorConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Nullable;
import javax.inject.Inject;
import java.util.Collections;
import java.util.List;
import java.util.Optional;

public class ExtendedRichTextFactory extends RichTextFieldFactory {
import javax.annotation.Nullable;
import javax.inject.Inject;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.merkle.oss.magnolia.definition.custom.richtext.toolbarbuilder.RichTextToolbarConfig;
import com.vaadin.server.VaadinService;

public class ExtendedRichTextFactory extends DamRichTextFieldFactory {
private static final Logger LOG = LoggerFactory.getLogger(ExtendedRichTextFactory.class);

@Inject
Expand All @@ -26,9 +30,10 @@ public ExtendedRichTextFactory(
final UiComponentProvider componentProvider,
final SimpleTranslator i18n,
final DialogDefinitionRegistry dialogDefinitionRegistry,
final I18nizer i18nizer
final I18nizer i18nizer,
final AssetProviderRegistry assetProviderRegistry
) {
super(definition, componentProvider, i18n, dialogDefinitionRegistry, i18nizer);
super(definition, componentProvider, i18n, dialogDefinitionRegistry, i18nizer, assetProviderRegistry);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
package com.merkle.oss.magnolia.definition.builder.simple;

import info.magnolia.dam.app.field.DamRichTextFieldDefinition;
import info.magnolia.ui.field.RichTextFieldDefinition;

/**
* builds a {@link RichTextFieldDefinition}
* @see <a href="https://docs.magnolia-cms.com/product-docs/6.2/Developing/Templating/Dialog-definition/Field-definition/List-of-fields/Rich-text-field.html">magnolia Docs - Rich text field </a>
* @author Merkle DACH
*/
public class RichTextFieldDefinitionBuilder extends AbstractRichTextFieldDefinitionBuilder<RichTextFieldDefinition, RichTextFieldDefinitionBuilder> {
public class RichTextFieldDefinitionBuilder extends AbstractRichTextFieldDefinitionBuilder<DamRichTextFieldDefinition, RichTextFieldDefinitionBuilder> {

public RichTextFieldDefinition build(final String name) {
final RichTextFieldDefinition definition = new RichTextFieldDefinition();
public DamRichTextFieldDefinition build(final String name) {
final DamRichTextFieldDefinition definition = new DamRichTextFieldDefinition();
super.populate(definition, name);
return definition;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,20 @@
package com.merkle.oss.magnolia.definition.builder.simple;

import com.merkle.oss.magnolia.definition.builder.AbstractFieldDefinitionBuilderTestCase;
import static org.junit.jupiter.api.Assertions.*;

import info.magnolia.dam.app.field.DamRichTextFieldDefinition;
import info.magnolia.dam.app.field.factory.DamRichTextFieldFactory;
import info.magnolia.repository.RepositoryConstants;
import info.magnolia.ui.datasource.BaseDatasourceDefinition;
import info.magnolia.ui.datasource.DatasourceDefinition;
import info.magnolia.ui.field.ComboBoxFieldDefinition;
import info.magnolia.ui.field.LinkFieldDefinition;
import info.magnolia.ui.field.RichTextFieldDefinition;
import info.magnolia.ui.field.SafeHtmlValidatorDefinition;
import info.magnolia.ui.field.factory.ComboBoxFieldFactory;
import info.magnolia.ui.field.factory.RichTextFieldFactory;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import java.util.HashMap;
import java.util.Map;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;
import com.merkle.oss.magnolia.definition.builder.AbstractFieldDefinitionBuilderTestCase;

class RichTextFieldDefinitionBuilderTest extends AbstractFieldDefinitionBuilderTestCase {

@Test
void testBuilder() {
final RichTextFieldDefinition definition = super.assertField(new RichTextFieldDefinitionBuilder(), (name, builder) -> builder.build(name))
final DamRichTextFieldDefinition definition = super.assertField(new RichTextFieldDefinitionBuilder(), (name, builder) -> builder.build(name))
.alignment(true)
.images(true)
.lists(false)
Expand All @@ -46,11 +38,11 @@ void testBuilder() {
assertEquals("someFontSizes", definition.getFontSizes());
assertEquals("someConfigJsFile", definition.getConfigJsFile());

final RichTextFieldDefinition emptyDefinition = new RichTextFieldDefinitionBuilder().build("richText");
final DamRichTextFieldDefinition emptyDefinition = new RichTextFieldDefinitionBuilder().build("richText");
assertEquals(String.class, emptyDefinition.getType());
assertEquals(RichTextFieldFactory.class, emptyDefinition.getFactoryClass());
assertEquals(DamRichTextFieldFactory.class, emptyDefinition.getFactoryClass());
assertEquals(0, emptyDefinition.getValidators().size());
assertEquals(1, emptyDefinition.getLinkFieldDefinitions().size());
assertEquals(2, emptyDefinition.getLinkFieldDefinitions().size());
assertNotNull(emptyDefinition.getLinkFieldDefinitions().get(RepositoryConstants.WEBSITE));
}
}

0 comments on commit f67539a

Please sign in to comment.