Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LMBQ-276: Improving WithEditor #230

Merged
merged 12 commits into from
Dec 30, 2023
MZole marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace Lombiq.HelpfulLibraries.OrchardCore.Contents;

public static class ContentFieldEditorEnums
{
public enum TextFieldEditors
{
CodeMirror,
Color,
Email,
IconPicker,
Monaco,
PredefinedList,
Tel,
TextArea,
Url,
}

public enum HtmlEditors
{
Monaco,
Multiline,
Trumbowyg,
Wysiwyg,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ public static class ContentPartDefinitionBuilderExtensions
public static ContentPartDefinitionBuilder<TPart> AsPart<TPart>(this ContentPartDefinitionBuilder builder)
where TPart : ContentPart =>
new(builder);

/// <summary>
/// Sets the editor for a ContentField using an <see cref="Enum"/> parameter.
/// </summary>
public static ContentPartFieldDefinitionBuilder WithEditor(this ContentPartFieldDefinitionBuilder builder, Enum editor) =>
builder.MergeSettings<ContentPartFieldSettings>(x => x.Editor = editor.ToString());
}

public class ContentPartDefinitionBuilder<TPart>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using OrchardCore.ContentManagement.Metadata.Builders;
using System;

namespace OrchardCore.ContentManagement.Metadata.Settings;

public static class ContentTypePartDefinitionBuilderExtensions
{
/// <summary>
/// Sets the part's editor using an <see cref="Enum"/> parameter.
/// </summary>
public static ContentTypePartDefinitionBuilder WithEditor(this ContentTypePartDefinitionBuilder builder, Enum editor) =>
builder.MergeSettings<ContentTypePartSettings>(x => x.Editor = editor.ToString());
}