November Happy Hour will be moved to Thursday December 5th.

Configure TinyMCE on FormContainerBlock submission email

Vote:
 

I would like to enable the source code editor in TinyMCE for just the message field of the FormContainerBlock submission email. I don't see a way to do this since you can only configure interfaces of IContentData. I think the data type I'm trying to configure is the Body field of the EmailTemplateActorModel.

Below is a snippet from my TinyMCE configuration.

config.For<EmailTemplateActorModel>(t => t.Body)
  .AddPlugin("code")
  .Toolbar(new[] { defaultToolbarTop, "code" });

The error I get is: There is no implicit reference conversion from 'EPiServer.Forms.Implementation.Actors.EmailTemplateActorModel' to 'EPiServer.Core.IContentData'.    CapCom.Epi.Cms

Is there any way to accomplish this other than enabling the HTML souce code option for all editor fields?

#300446
Edited, Apr 20, 2023 21:24
Vote:
 

Hi,

The fastest way to overwrite the RTF settings for this specific field can be done using the EditroDescriptor:

    [EditorDescriptorRegistration(TargetType = typeof(XhtmlString))]
    public class EmailTemplateActorCollectionEditorDescriptor : EditorDescriptor
    {
        public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
        {
            base.ModifyMetadata(metadata, attributes);

            if (metadata.ContainerType == typeof(EmailTemplateActorModel))
            {
                var settings = (TinyMceSettings)metadata.EditorConfiguration["settings"];
                settings.Toolbar("code");
                //add any other settings
            }            
        }
    }

Since EmailTemplateActorModel doesn't inherit from IContentData, you need to override the behavior on the metadata. This is how it should look:

You can also be more specific and manipulate directly the EditorDescriptor that configures the EmailTemplateActorModel which is this: 

[EditorDescriptorRegistration(TargetType = typeof(IEnumerable<EmailTemplateActorModel>), UIHint = "EmailTemplateActorEditor")]
public class EmailTemplateActorCollectionEditorDescriptor : CollectionEditorDescriptor<EmailTemplateActorModel>

Hope it helps

Santiago. 

#300842
Apr 27, 2023 17:05
Vote:
 

Hi Santiago,

Thank you so much. Your code snippet works for modifying the editor descriptor for XhtmlString. When I adapt that to use the more specific selector for IEnumerable<EmailTemplateActorModel> I get errors when calling the base.ModifyMetadata(metadata, attributes) (adding duplicate key) and when accessing the metadata.EditorConfiguration["settings"] property (does not exist). Could you provide please the complete implementation for that specific registration?

Thanks,

Rich

#300897
Apr 28, 2023 14:49
Vote:
 

After working with Optimizely support I had to tweak the attribute a bit to make this work.

[EditorDescriptorRegistration(TargetType = typeof(XhtmlString), EditorDescriptorBehavior = EditorDescriptorBehavior.PlaceLast)]

Once I deployed to the INTE environment I was seeing errors that I did not have locally and this solved that issue.

Also, I had to re-apply the TinyMCE configuration to include my default settings.

#303828
Jun 20, 2023 14:02
Vote:
 

Hi Rich,

I don't suppose a blog post would be out of the question? to help share the knowledge and your experiences upon this.

Something brief that explains the situtation you where up against, what issues / errors you experienced along the way.

Who helped along the way.

Paul

#303885
Jun 21, 2023 10:26
* 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.