mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-04-05 21:01:35 +08:00

* Adds the ability to create links based on orchard contents, calculating href during the display process using tokens # Conflicts: # src/Orchard.Web/Modules/TinyMce/Scripts/orchard-tinymce.js * Adds Contentmanager.Get Tokens Adds Content Links plugin to TinyMCE * Adds settings for TextField and BodyPart in order to specify which content types or part to show in the list * Settings for Html editors built on BodyParts, TextFields, LayoutParts * Adds minified version of the plugin.js * Tests if dependencies are enabled before activating the content links settings * new .png for TinyMce * Renamed the token as suggested during last meeting
35 lines
1.4 KiB
C#
35 lines
1.4 KiB
C#
using Orchard.Layouts.Elements;
|
|
using Orchard.Layouts.Framework.Display;
|
|
using Orchard.Layouts.Framework.Drivers;
|
|
using Orchard.Layouts.Helpers;
|
|
using Orchard.Layouts.Services;
|
|
using Orchard.Layouts.ViewModels;
|
|
|
|
namespace Orchard.Layouts.Drivers {
|
|
public class HtmlElementDriver : ElementDriver<Html> {
|
|
private readonly IElementFilterProcessor _processor;
|
|
|
|
public HtmlElementDriver(IElementFilterProcessor processor) {
|
|
_processor = processor;
|
|
}
|
|
|
|
protected override EditorResult OnBuildEditor(Html element, ElementEditorContext context) {
|
|
var viewModel = new HtmlEditorViewModel {
|
|
Text = element.Content,
|
|
Part = ((dynamic)context.Content.ContentItem).LayoutPart
|
|
};
|
|
var editor = context.ShapeFactory.EditorTemplate(TemplateName: "Elements.Html", Model: viewModel);
|
|
|
|
if (context.Updater != null) {
|
|
context.Updater.TryUpdateModel(viewModel, context.Prefix, null, null);
|
|
element.Content = viewModel.Text;
|
|
}
|
|
|
|
return Editor(context, editor);
|
|
}
|
|
|
|
protected override void OnDisplaying(Html element, ElementDisplayingContext context) {
|
|
context.ElementShape.ProcessedContent = _processor.ProcessContent(element.Content, "html", context.GetTokenData());
|
|
}
|
|
}
|
|
} |