TinyMCE in ListProperty - No styles

Vote:
 

Hello

I have an editor.css and the custom styles works in all other XhtmlProperties, it's just in the ListProperty they doesn't show up, does anyone have any idea of how to fix this?

We have a ListProperty looking like this: 

[Display(Order = 20)]
    [EditorDescriptor(EditorDescriptorType = typeof(CollectionEditorDescriptor))]
    public virtual IList Items { get; set; }



public class FaqModel {
    [UIHint(UIHint.Textarea)]
    public virtual string Question { get; set; }
		
    public virtual XhtmlString Answer { get; set; }
}

When clicking the add button the editor pops up like this
First image

But there are no styles in the list

Image 2



#147596
Apr 19, 2016 16:49
Vote:
 

Have this been solved? 

Does other settings to the editor apply like adding tinymcesettings from code? Could you also post the code for the editordescriptor? Strange error neverless could it have something with the fact it is not an actuall content class? Have you tried changed it to be a blockdata and us it lie property on the pagetype but hidden for editors with availableeditmode=false?

#147688
Apr 21, 2016 11:22
Vote:
 

No this hasn't been solved, I've tried to report a bug to EPI but I don't have access(I should have though, im registered with my company email and we are partners...).

You mean that I should change my FaqModel so that it inherits from BlockData? The editordescriptor is not my code, it's Episerver code :)

#147702
Apr 21, 2016 15:53
Vote:
 

Hi,

If I understand your problem correctly, hope the following helps

If you are using custom css for some of the xhtml string but not for all xhtml string then you need to set some custom css to be default like this

http://imgur.com/qmRWxe7

 

#147888
Edited, Apr 27, 2016 11:42
Vote:
 

Otherwise you can specify the default css using uiEditorCssPaths attribute like this

<applicationSettings httpCacheability="Public" pageValidateTemplate="false" uiShowGlobalizationUserInterface="true" uiUrl="~/EPiServer/CMS/" urlRebaseKind="ToRootRelative" uiEditorCssPaths="/Resources/Shared/texteditors/editor.css" />
#147897
Edited, Apr 27, 2016 12:41
Vote:
 

I am having this exact same issue. Does anyone have a solution? This is the only post I found about the issue anywhere.

What is happening is that TinyMCE has the proper style settings when I am editing a block directly. I have a few styles in the dropdown. Then when the modal pops up, there are no styles in that TinyMCE dropdown. This seems like a bug, not a feature.

Here is my model:

[CultureSpecific]
[Required]
[Display(Order = 400, Name = "Full Description")]
public virtual XhtmlString Description { get; set; }

[CultureSpecific]
[Required]
[Display(Order = 500, Name = "Technical Specifications Title")]
public virtual String TechnicalSpecificationsTitle { get; set; }

[CultureSpecific]
[Required]
[Display(Order = 600, Name = "Technical Specifications")]
[EditorDescriptor(EditorDescriptorType = typeof(CollectionEditorDescriptor<TechnicalSpecification>))]
public virtual IEnumerable<TechnicalSpecification> TechnicalSpecifications { get; set; }

So I am able to edit the Description successfully, with the TinyMCE editor and the styles dropdown. But then when the modal pops up to edit a single TechnicalSpecification, the styles dropdown is empty.

#174903
Feb 07, 2017 15:16
Vote:
 

It's been a while since this topic started but I also have this problem, did anyone find a solution for it now?

#180912
Aug 02, 2017 10:35
Vote:
 

I have finally found a solution for the problem! I decided not to use `uiEditorCssPaths` setting in web.config and I removed styles definitions from css file. Instead I have overriden a default `XhtmlStringEditorDescriptor` and I put styles definitions there. This way it works in all XhtmlString tiny mce editors! Here's the code:

using EPiServer.Cms.Shell.UI.ObjectEditing.EditorDescriptors;
using EPiServer.Core;
using EPiServer.Shell.ObjectEditing;
using EPiServer.Shell.ObjectEditing.EditorDescriptors;
using System;
using System.Collections.Generic;
using System.Linq;

namespace Properties
{
    [EditorDescriptorRegistration(TargetType = typeof (XhtmlString), EditorDescriptorBehavior = EditorDescriptorBehavior.OverrideDefault)]
    public class OverridenXhtmlStringEditorDescriptor : XhtmlStringEditorDescriptor
    {
        private const string TinyMceSettingsKey = "settings";
        private const string CssPathEntryKey = "content_css";
        private const string StyleFormatsKey = "style_formats";
        private const string TinyMceCssPath = "/Static/css/cms/tinymce-styles.min.css";

        public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
        {
            base.ModifyMetadata(metadata, attributes);

            KeyValuePair<string, object> tinyMceSettings = GetTinyMceSettings(metadata);
            var tinyMceSettingsDictionary = tinyMceSettings.Value as Dictionary<string, object>;

            if (tinyMceSettingsDictionary == null)
            {
                return;
            }

            List<object> styleFormats = GetTinyMceStyleFormats();

            ReplaceDictionaryKey(tinyMceSettingsDictionary, CssPathEntryKey, TinyMceCssPath);
            ReplaceDictionaryKey(tinyMceSettingsDictionary, StyleFormatsKey, styleFormats);
        }

        private KeyValuePair<string, object> GetTinyMceSettings(ExtendedMetadata metadata)
        {
            return metadata.EditorConfiguration
                .FirstOrDefault(x => x.Key == TinyMceSettingsKey);
        }

        private void ReplaceDictionaryKey(Dictionary<string, object> dictionary, string entryKey, object entryValue)
        {
            dictionary.Remove(entryKey);
            dictionary.Add(entryKey, entryValue);
        }

        private List<object> GetTinyMceStyleFormats()
        {
            return new List<object>
            {
                new { title = "Paragraph", block = "p" },
                new { title = "Some class", selector = "p", classes = "some-class" }
            };
        }
    }
}
#181047
Aug 07, 2017 15:50
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.