Hello,
In training materials it's shown a possibility to extend the editor:
https://community.telligent.com/community/11/w/developer-training/65057/extending-the-content-editor
I'm trying to do the same (at least to repeat the sample) without any success. Could you help to identify missings?
Extensions/Controllers/TextEditor.cs
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Telligent.DynamicConfiguration.Components;
using Telligent.Evolution.Extensibility.EmbeddableContent.Version1;
using Telligent.Evolution.Extensibility.Version1;
namespace Test.Extensions.Controllers
{
public class TextEditor : IEmbeddableContentFragmentType, ITranslatablePlugin, IPlugin
{
readonly Guid _fragmentTypeId = new Guid("6c33babb0c0e45e8b691294b8b6569e5");
ITranslatablePluginController _translation;
#region IEmbeddableContentFragmentType Members
public string ContentFragmentName
{
get { return _translation.GetLanguageResourceValue("fragment_name"); }
}
public string ContentFragmentDescription
{
get { return _translation.GetLanguageResourceValue("fragment_description"); }
}
public Guid EmbeddedContentFragmentTypeId
{
get { return _fragmentTypeId; }
}
public bool CanEmbed(Guid contentTypeId, int userId)
{
return true;
}
PropertyGroup[] IEmbeddableContentFragmentType.EmbedConfiguration
{
get
{
var group = new PropertyGroup("options", _translation.GetLanguageResourceValue("configuration_group"), 1);
group.Properties.Add(new Property("color", _translation.GetLanguageResourceValue("configuration_color"), PropertyType.Color, 1, ""));
return new PropertyGroup[] { group };
}
}
void IEmbeddableContentFragmentType.AddUpdateContentFragments(Guid contentId, Guid contentTypeId, IEnumerable<IEmbeddableContentFragment> embeddedFragments)
{
}
public string PreviewImageUrl
{
get { return null; }
}
string IEmbeddableContentFragmentType.Render(IEmbeddableContentFragment embeddedFragment, string target)
{
if (System.Diagnostics.Debugger.Launch()) System.Diagnostics.Debugger.Break();
var color = embeddedFragment.GetString("color");
if (String.IsNullOrEmpty(color))
return String.Empty;
return String.Format("<div style='height: 300px; width: 300px; background-color: {0};'> </div>", color);
}
EmbeddableContentFragmentValidationState IEmbeddableContentFragmentType.Validate(IEmbeddableContentFragment embeddedFragment)
{
if (System.Diagnostics.Debugger.Launch()) System.Diagnostics.Debugger.Break();
var color = embeddedFragment.GetString("color");
if (string.IsNullOrEmpty(color))
return new EmbeddableContentFragmentValidationState(false) { Message = _translation.GetLanguageResourceValue("configuration_colorinvalid") };
return new EmbeddableContentFragmentValidationState(true);
}
#endregion
#region IPlugin Members
string IPlugin.Description
{
get { return "Displays a box with configurable height."; }
}
void IPlugin.Initialize()
{
}
string IPlugin.Name
{
get { return "Sample Embeddable"; }
}
#endregion
#region ITranslatablePlugin Members
Translation[] ITranslatablePlugin.DefaultTranslations
{
get
{
var translation = new Translation("en-us");
translation.Set("fragment_name", "Embeddable Box");
translation.Set("fragment_description", "Displays a box with configurable height.");
translation.Set("configuration_group", "Options");
translation.Set("configuration_color", "Background Color");
translation.Set("configuration_colorinvalid", "A Background Color must be provided.");
return new Translation[] { translation };
}
}
void ITranslatablePlugin.SetController(ITranslatablePluginController controller)
{
_translation = controller;
}
#endregion
}
}
public class TextEditorExtension : IScriptedContentFragmentExtension { public string ExtensionName => "test_v1_text_editor"; public string Name => "Text Editor"; public string Description => "Text Editor"; public object Extension => new TextEditor(); public void Initialize() { } }
Changed class name
[edited by: Viachaslau at 2:47 PM (GMT 0) on Mon, Jul 27 2020]