Skip to content

Commit

Permalink
Add JsonEditorHandler to UI hint handlers
Browse files Browse the repository at this point in the history
A new JsonEditorHandler class is added under the "Handlers" directory of Elsa.Studio.UIHints module. This handler class is designed to support "json-editor" UI hint in the application. It has been included in the default UI hint handlers registration in the "ServiceCollectionExtensions" class.
  • Loading branch information
sfmskywalker committed Dec 28, 2023
1 parent 23817c7 commit e1626cf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ public static class ServiceCollectionExtensions
/// <summary>
/// Adds the default UI hint handlers.
/// </summary>
/// <param name="services"></param>
/// <returns></returns>
public static IServiceCollection AddDefaultUIHintHandlers(this IServiceCollection services)
{
return services
Expand All @@ -24,6 +22,7 @@ public static IServiceCollection AddDefaultUIHintHandlers(this IServiceCollectio
.AddUIHintHandler<MultiLineHandler>()
.AddUIHintHandler<DropDownHandler>()
.AddUIHintHandler<CodeEditorHandler>()
.AddUIHintHandler<JsonEditorHandler>()
.AddUIHintHandler<SwitchEditorHandler>()
.AddUIHintHandler<HttpStatusCodesHandler>()
.AddUIHintHandler<VariablePickerHandler>()
Expand Down
22 changes: 22 additions & 0 deletions src/modules/Elsa.Studio.UIHints/Handlers/JsonEditorHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Elsa.Studio.Contracts;
using Elsa.Studio.Models;
using Elsa.Studio.UIHints.Components;
using Microsoft.AspNetCore.Components;

namespace Elsa.Studio.UIHints.Handlers;

public class JsonEditorHandler : IUIHintHandler
{
public bool GetSupportsUIHint(string uiHint) => uiHint == "json-editor";
public string UISyntax => WellKnownSyntaxNames.Literal;

public RenderFragment DisplayInputEditor(DisplayInputEditorContext context)
{
return builder =>
{
builder.OpenComponent(0, typeof(Code));
builder.AddAttribute(1, nameof(Code.EditorContext), context);
builder.CloseComponent();
};
}
}

0 comments on commit e1626cf

Please sign in to comment.