Skip to content

Commit

Permalink
feat: add blocks to extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
StepanSSA committed May 22, 2024
1 parent d9fa00a commit db153e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions apps/Sitko.Blockly.Demo.Client/EditorJsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
using Sitko.EditorJS.Blocks.Header;
using Sitko.EditorJS.Blocks.Image;
using Sitko.EditorJS.Blocks.List;
using Sitko.EditorJS.Blocks.Marker;
using Sitko.EditorJS.Blocks.Paragraph;
using Sitko.EditorJS.Blocks.Quote;
using Sitko.EditorJS.Blocks.SimpleImage;
using Sitko.EditorJS.Blocks.Strikethrough;
using Sitko.EditorJS.Blocks.Table;
using Sitko.EditorJS.Blocks.Underline;

namespace Sitko.Blockly.Demo.Client;

Expand All @@ -15,12 +18,16 @@ public static class EditorJsExtensions
public static IServiceCollection AddEditorJSBlocks(this IServiceCollection serviceCollection)
{
serviceCollection.AddEditorJS()
.AddBlock<StrikethroughBlock, StrikethroughBlockOptions>()
.AddBlock<MarkerBlock, MarkerBlockOptions>()
.AddBlock<UnderlineTool, UnderlineBlockOptions>()
.AddBlock<QuoteBlock, QuoteBlockOptions>()
.AddBlock<TableBlock, TableBlockOptions>()
.AddBlock<ListBlock, ListBlockOptions>()
.AddBlock<ParagraphBlock, ParagraphBlockOptions>()
.AddBlock<HeaderBlock, HeaderBlockOptions>()
.AddBlock<SimpleImageBlock, SimpleImageBlockOptions>()
.AddGalleryBlock<StorageItem>()
.AddImageBlock<StorageItem>();
return serviceCollection;
}
Expand Down
5 changes: 5 additions & 0 deletions src/Sitko.EditorJS/Blocks/Image/BuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.Configuration;
using Sitko.EditorJS.Blocks.Gallery;
using Sitko.EditorJS.Configuration;

namespace Sitko.EditorJS.Blocks.Image;
Expand All @@ -8,4 +9,8 @@ public static class BuilderExtensions
public static IEditorJSBuilder AddImageBlock<TData>(this IEditorJSBuilder builder,
Action<IConfiguration, ImageBlockOptions<TData>>? configure = null) where TData : class, new() =>
builder.AddBlock<ImageBlock<TData>, ImageBlockOptions<TData>>(configure);

public static IEditorJSBuilder AddGalleryBlock<TData>(this IEditorJSBuilder builder,
Action<IConfiguration, GalleryBlockOptions<TData>>? configure = null) where TData : class, new() =>
builder.AddBlock<GalleryBlock<TData>, GalleryBlockOptions<TData>>(configure);
}

0 comments on commit db153e9

Please sign in to comment.