Skip to content

Commit

Permalink
refactor: remove unused components
Browse files Browse the repository at this point in the history
Refs: BLOCKLY-T-5
  • Loading branch information
StepanSSA committed May 24, 2024
1 parent f483b5f commit 4a4f4cd
Show file tree
Hide file tree
Showing 28 changed files with 57 additions and 175 deletions.
4 changes: 1 addition & 3 deletions apps/Sitko.Blockly.Demo/Components/Pages/Index.razor
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@page "/"
@using Sitko.Blockly.Data.Entities
@using Sitko.Core.Repository
@using BlocksListMode=Sitko.EditorJS.Blazor.Display.BlocksListMode
@inherits BaseComponent
<AppPageLayout Title="@LocalizationProvider["Posts"]">
<Extra>
Expand All @@ -21,8 +20,7 @@
@* <MudBlocksList *@
@* EntityBlocks="post.Blocks" Options="@(new MudBlazorBlocklyListOptions(BlocksListMode.Preview, GetService<IStorage>(), $"Posts/{post.Id}"))"> *@
@* </MudBlocksList> *@
<MudBlocksList EntityBlocks="post.EditorJSBlocks.Blocks" Options="@(new MudBlazorEditorJSListOptions(BlocksListMode.Full, $"Posts/{post.Id}"))">
</MudBlocksList>
<MudBlocksList EntityBlocks="post.EditorJSBlocks.Blocks"/>
</MudCardContent>
</MudCard>
}
Expand Down

This file was deleted.

8 changes: 0 additions & 8 deletions src/Sitko.EditorJS.Blazor/Display/BlockComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,3 @@ public abstract class BlockComponent<TBlock> : BaseComponent
[Parameter]
public TBlock Block { get; set; } = null!;
}
public abstract class BlockComponent<TBlock, TListOptions> : BlockComponent<TBlock>
where TListOptions : BlazorEditorJSListOptions
where TBlock : ContentBlock
{
[EditorRequired]
[Parameter]
public TListOptions Options { get; set; } = null!;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@

namespace Sitko.EditorJS.Blazor.Display.Blocks;

public abstract class GalleryBlockComponent<TData, TListOptions> : BlockComponent<GalleryBlock<TData>, TListOptions>
where TData : class, new()
where TListOptions : BlazorEditorJSListOptions;
public abstract class GalleryBlockComponent<TData> : BlockComponent<GalleryBlock<TData>>
where TData : class, new();
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@

namespace Sitko.EditorJS.Blazor.Display.Blocks;

public abstract class HeaderBlockComponent<TListOptions> : BlockComponent<HeaderBlock, TListOptions>
where TListOptions : BlazorEditorJSListOptions;
public abstract class HeaderBlockComponent : BlockComponent<HeaderBlock>;
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,5 @@

namespace Sitko.EditorJS.Blazor.Display.Blocks;

public abstract class ImageBlockComponent<TData, TListOptions> : BlockComponent<ImageBlock<TData>, TListOptions>
where TData : class, new()
where TListOptions : BlazorEditorJSListOptions;
public abstract class ImageBlockComponent<TData> : BlockComponent<ImageBlock<TData>>
where TData : class, new();
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@

namespace Sitko.EditorJS.Blazor.Display.Blocks;

public abstract class ListBlockComponent<TListOptions> : BlockComponent<ListBlock, TListOptions>
where TListOptions : BlazorEditorJSListOptions;
public abstract class ListBlockComponent : BlockComponent<ListBlock>;
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@

namespace Sitko.EditorJS.Blazor.Display.Blocks;

public abstract class ParagraphBlockComponent<TListOptions> : BlockComponent<ParagraphBlock, TListOptions>
where TListOptions : BlazorEditorJSListOptions;
public abstract class ParagraphBlockComponent : BlockComponent<ParagraphBlock>;
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@

namespace Sitko.EditorJS.Blazor.Display.Blocks;

public abstract class QuoteBlockComponent<TListOptions> : BlockComponent<QuoteBlock, TListOptions>
where TListOptions : BlazorEditorJSListOptions;
public abstract class QuoteBlockComponent: BlockComponent<QuoteBlock>;
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@

namespace Sitko.EditorJS.Blazor.Display.Blocks;

public abstract class SimpleImageBlockComponent<TListOptions> : BlockComponent<SimpleImageBlock, TListOptions>
where TListOptions : BlazorEditorJSListOptions;
public abstract class SimpleImageBlockComponent : BlockComponent<SimpleImageBlock>;
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@

namespace Sitko.EditorJS.Blazor.Display.Blocks;

public abstract class TableBlockComponent<TListOptions> : BlockComponent<TableBlock, TListOptions>
where TListOptions : BlazorEditorJSListOptions;
public abstract class TableBlockComponent : BlockComponent<TableBlock>;
13 changes: 2 additions & 11 deletions src/Sitko.EditorJS.Blazor/Display/BlocksList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Sitko.EditorJS.Blazor.Display;

public class BlocksList<TOptions> : BaseComponent where TOptions : BlazorEditorJSListOptions
public class BlocksList : BaseComponent
{
[EditorRequired]
[Parameter]
Expand All @@ -19,28 +19,19 @@ public class BlocksList<TOptions> : BaseComponent where TOptions : BlazorEditorJ

protected ContentBlock[] Blocks => EntityBlocks.ToArray();

[Parameter] public TOptions Options { get; set; } = null!;

protected override void Initialize()
{
base.Initialize();

if (Options is null)
{
throw new InvalidOperationException("Provide options for BlocksList");
}

BlockDescriptors = Blockly.Descriptors.ToArray();
}

[PublicAPI]
public RenderFragment RenderBlock(IBlazorBlockDescriptor blockDescriptor, ContentBlock block) =>
public static RenderFragment RenderBlock(IBlazorBlockDescriptor blockDescriptor, ContentBlock block) =>
builder =>
{
var component = blockDescriptor.DisplayComponent;
builder.OpenComponent(0, component);
builder.AddAttribute(1, "Block", block);
builder.AddAttribute(2, "Options", Options);
builder.CloseComponent();
};
}
18 changes: 0 additions & 18 deletions src/Sitko.EditorJS.Blazor/Display/EditorJSListOptions.cs

This file was deleted.

6 changes: 0 additions & 6 deletions src/Sitko.EditorJS.MudBlazor/Display/BlockDescriptor.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@inherits GalleryBlockComponent<Sitko.Core.Storage.StorageItem, BlazorEditorJSListOptions>
@inherits GalleryBlockComponent<Sitko.Core.Storage.StorageItem>


@if (Block.Data.Style == "slider")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@using global::MudBlazor
@inherits HeaderBlockComponent<BlazorEditorJSListOptions>
@inherits HeaderBlockComponent

@switch (Block.Data.Level)
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@inherits ImageBlockComponent<Sitko.Core.Storage.StorageItem, BlazorEditorJSListOptions>
@inherits ImageBlockComponent<Sitko.Core.Storage.StorageItem>

<div class="@(Block.Data.WithBackground ? "single-image-with-background" : "single-image")">
<img class="@(Block.Data.Stretched ? "stretched " : "") @(Block.Data.WithBorder ? "with-border" : "")" src="@Block.Data.File.Url" alt="Image: @Block.Data.Caption"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@inherits ListBlockComponent<BlazorEditorJSListOptions>
@inherits ListBlockComponent

<div style="margin-left: 20px">
@if (Block.Data.Style != "ordered")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
@inherits ParagraphBlockComponent<BlazorEditorJSListOptions>
@inherits ParagraphBlockComponent
@((MarkupString)Block.Data.Text)
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@inherits QuoteBlockComponent<BlazorEditorJSListOptions>
@inherits QuoteBlockComponent

<blockquote class="blockquote">
<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@inherits SimpleImageBlockComponent<BlazorEditorJSListOptions>
@inherits SimpleImageBlockComponent

<div class="single-image">
<img src="@Block.Data.Url" alt="Image: @Block.Data.Caption"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@inherits TableBlockComponent<BlazorEditorJSListOptions>
@inherits TableBlockComponent

@if (Block.Data.Content != null)
{
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion src/Sitko.EditorJS.MudBlazor/Display/MudBlocksList.razor
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@inherits BlocksList<MudBlazorEditorJSListOptions>
@inherits BlocksList
<link rel="stylesheet" href="@MudBlazorEditorJSModule.CssUrl">
@foreach (var block in Blocks)
{
Expand Down
77 changes: 0 additions & 77 deletions src/Sitko.EditorJS.MudBlazor/MudBlazorBlocklyModule.cs

This file was deleted.

34 changes: 34 additions & 0 deletions src/Sitko.EditorJS.MudBlazor/MudBlazorEditorJSModule.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Microsoft.Extensions.DependencyInjection;
using Sitko.Core.App;
using Sitko.Core.App.Localization;
using Sitko.EditorJS.Blazor;
using Sitko.EditorJS.Blazor.Display;

namespace Sitko.EditorJS.MudBlazor;

public class MudBlazorEditorJSModule : BlazorEditorJSModule<IBlazorBlockDescriptor, MudBlazorEditorJSModuleOptions>
{
public static readonly string CssUrl = "/_content/Sitko.EditorJS.MudBlazor/Sitko.EditorJS.MudBlazor.bundle.scp.css";

public override string OptionsKey => "EditorJS:MudBlazor";

public override void ConfigureServices(IApplicationContext context, IServiceCollection services,
MudBlazorEditorJSModuleOptions startupOptions)
{
base.ConfigureServices(context, services, startupOptions);
services.Configure<JsonLocalizationModuleOptions>(options =>
{
options.AddDefaultResource<MudBlazorEditorJSModule>();
});
}
}
public class MudBlazorEditorJSModuleOptions : BlazorEditorJSModuleOptions<IBlazorBlockDescriptor>
{
public MudBlazorEditorJSTheme Theme { get; set; } = MudBlazorEditorJSTheme.Light;
}

public enum MudBlazorEditorJSTheme
{
Light,
Dark
}
4 changes: 0 additions & 4 deletions src/Sitko.EditorJS.MudBlazor/Sitko.EditorJS.MudBlazor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,4 @@
<PackageReference Include="Sitko.Core.Blazor.MudBlazor" Version="11.0.0-beta.7" />
</ItemGroup>

<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>

</Project>
4 changes: 1 addition & 3 deletions src/Sitko.EditorJS/Blocks/Image/ImageBlockConfig.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System.Text.Json.Serialization;

namespace Sitko.EditorJS.Blocks.Image;
namespace Sitko.EditorJS.Blocks.Image;

public record ImageBlockConfig : ContentBlockConfig
{
Expand Down

0 comments on commit 4a4f4cd

Please sign in to comment.