DEV Community

David Boland
David Boland

Posted on • Originally published at davidboland.site on

Changing Episerver PropertyList Modal Size

Episerver PropertyList Modal Size

Quick Summary

I have worked with Episerver's PropertyList on several occasions, and the one problem that I have consistently run into is the fact that the modal that appears in the editor view is too small for some scenarios. Specifically, when using XhtmlString properties.

Default Modal Size

Jump to implementation

This becomes an issue for editors due to the fact that there is no horizontal scroll functionality in the modal. So if editors want to center content they may need to do some workarounds such as adding white space to have the TinyMCE center around the content they wish to see.

In looking for solutions to this problem, I was able to track down some CSS updates that could be made to resolve this. However, finding it wasn't the quick Google search I have come to appreciate. So I thought I would post it here with the hope it will be easier to find for the next person.

As I said I found this solution elsewhere, so props to Minesh Shah who posted what I found on the Episerver forums.

Episerver TinyMCE 2.0 Configuration

I know with the latest updates to TinyMCE in Episerver 11 you are able to customize the size of the editor down to the content type based on your configuration. However, custom configurations can only be added to instances of IContentData. And pages that implement your custom PropertyList cannot access those XhtmlString properties to apply custom configurations. Plus I think it would be better from an editor experience to increase the size of the modal instead of decreasing the size of the rich text area.

Implementation

Creating the Property

The process for creating a PropertyList is pretty straight forward. The implementation here you can find it in my Github repo using the Alloy demo site. First, I created a custom type along with a property type definition.

public class ContentProperty{ [Display(Name = "Title Content")] public virtual string Title { get; set; } [Display(Name = "Rich Text Content")] public virtual XhtmlString MainContentArea { get; set; }}[PropertyDefinitionTypePlugIn]public class ContentPropertyListTypeDefinition : PropertyList<contentproperty> { }
Enter fullscreen mode Exit fullscreen mode

Then, I added the property to one of the Alloy page types, ProductPage.

[EditorDescriptor(EditorDescriptorType = typeof(CollectionEditorDescriptor<contentproperty>))]
[Display(
    Name = "Example Property List",
    GroupName = SystemTabNames.Content)]
public virtual IList<contentproperty> PropertyListExample { get; set; }
Enter fullscreen mode Exit fullscreen mode

And thats all you need to create the actual property.

Page Property

Adding the CSS

As you saw in the image at the start of the article, the MainContentArea property does not fit within the modal. We can resolve this by updating the following:

First, update the module.config in the root of the web project. If you do not have the module.config file, you can add it and include the following:

<?xml version="1.0" encoding="utf-8"?>
<module>
    <assemblies>
        <!-- This adds the Alloy template assembly to the "default module" -->
        <add assembly="Alloy Demo Site"></add>
    </assemblies>
    <clientresources>
        <add name="epi-cms.widgets.base" path="Styles/Styles.css" resourcetype="Style"></add>
    </clientresources>
    <dojo>
        <paths>
            <add name="alloy" path="Scripts"></add>
        </paths>
    </dojo>
</module>
Enter fullscreen mode Exit fullscreen mode

If you already have the config, add node with name epi-cms.widgets.base under the clientResources node if you don't have one already. That referenced CSS is where we will add our styling updates.

Second, update the CSS file referenced in the module.config. In this example, it will be in ~/ClientResources/Styles/Styles.css. In that CSS file, add the following:

.Sleek .epi-dialog-landscape .dijitDialogPaneContentArea {
    height: 500px !important;
}

.Sleek .epi-dialog-landscape, .Sleek .epi-dialog-portrait, .Sleek .epi-dialog--auto-height {
    width: auto !important;
    transform: translateX(-50%);
    left: 50% !important;
}
Enter fullscreen mode Exit fullscreen mode

The CSS adjusts the height and width of the modal, and centers it on the page.

Final Modal Size

Final Thoughts

The final result provides a much better editor experience. As I mentioned before this is nothing new, but hopefully you were able to find this faster than I found the solution. As always, if you have any questions or thoughts on how to improve this solution, feel free to reach out.

Top comments (0)