TinyMCE customization depending on page context

Vote:
 

Let's say that I have two page content types PageA and PageB. Both of them are having property defined like that:

[EditorDescriptor(EditorDescriptorType = typeof(CollectionEditorDescriptor<OfferDetailsItem>))]
public override IList<OfferDetailsItem> OfferDetailsItems { get; set; }

with OfferDetailsItem defined like that:

public class OfferDetailsItem
{
   [Display(Order = 1)]
   public string Label { get; set; }

   [Display(Order = 2)]
   public XhtmlString Value { get; set; }

   [Display(Order = 3)]
   public bool Large { get; set; }
}

[PropertyDefinitionTypePlugIn]
public class OfferDetailsItemPropertyList : PropertyList<OfferDetailsItem>
{
}

I would like to customize TinyMCE editor for Value property of OfferDetailsItem class. I would like to do this depending on page context so there is different toolbar config when its used on PageA and different when its used on PageB.

I tried to use CustomEditorDescriptor for XhtmlString TargetType and override:

public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)

but in this case metadata.Parent is null so I can't reach content page context. For properties that are not collections this is possible.

Do you know if there is any other way to deal with this?

#261824
Edited, Sep 07, 2021 19:45
Vote:
 

Did you inherit from EPiServer.Cms.TinyMce.Core.XhtmlStringEditorDescriptor ?

Does 

var content = metadata.FindOwnerContent();

also returns null?

#262157
Sep 13, 2021 10:42
Michał Szkołut - Sep 13, 2021 11:30
I inherit from EditorDescriptor.
There is no method FindOwnerContent() available on metadata.
Bartosz Sekula - Sep 14, 2021 9:13
Yes there is. It's an extension method.
EPiServer.Cms.Shell.Extensions.ExtendedMetadataExtensions.FindOwnerContent
Michał Szkołut - Sep 14, 2021 12:03
Its still null.
Bartosz Sekula - Sep 14, 2021 12:40
Yes, you're right. Hypothetically, if there was a bugfix for that. Would you be willing to upgrade?
What's your current CMS version?
Michał Szkołut - Sep 14, 2021 12:52
Current version that w are using is 11.13.1.
Upgrading is always delicate process that we have to plan. If there will be only this bugfix there then it will be easier. But if we had to upgrade to version 12 or something with more braking changes and or dependencies to other packages then it may not be so fast.
Vote:
 

Hi Michał,

I have no answer direct to you question, but it is a recommendation try using ContentArea and block type instead of the generic PropertyList as your current implementation, see https://world.optimizely.com/documentation/developer-guides/CMS/Content/Properties/generic-propertylist/

Regards,

#262158
Sep 13, 2021 10:55
Michał Szkołut - Sep 13, 2021 19:29
Problem is that when I have ContentArea I don't know anything about page context. Firstly I create ContentArea items (no idea about the context), then I place them in that content area. I need to know context during item creation.
Vote:
 

OK, I managed to fix this.
Solution would be available in CMS UI 11.36.2
Stay tuned!

Available here: https://nuget.optimizely.com/package/?id=EPiServer.CMS.UI&v=12.0.2

#263162
Edited, Sep 15, 2021 11:10
* 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.