├── src ├── Sitko.Blazor.CKEditor.Bundle │ ├── .gitignore │ ├── Web │ │ ├── src │ │ │ ├── ckeditor.js │ │ │ ├── ckeditor.base.js │ │ │ └── ckeditor.dark.css │ │ ├── package.json │ │ └── webpack.config.js │ ├── CKEditorConfigExtensions.cs │ ├── ServiceCollectionExtensions.cs │ ├── Sitko.Blazor.CKEditor.Bundle.csproj │ └── CKEditorBundleOptions.cs └── Sitko.Blazor.CKEditor │ ├── _Imports.razor │ ├── CKEditor.razor │ ├── CKEditorOptions.cs │ ├── CKEditorOptionsProvider.cs │ ├── CKEditorConfig.cs │ ├── ServiceCollectionExtensions.cs │ ├── ckeditor.js │ ├── Sitko.Blazor.CKEditor.csproj │ └── BaseCKEditor.cs ├── packageIcon.png ├── release.config.js ├── apps ├── Sitko.Blazor.CKEditor.Demo │ ├── wwwroot │ │ ├── favicon.png │ │ └── app.css │ ├── Components │ │ ├── Pages │ │ │ ├── Home.razor │ │ │ ├── Error.razor │ │ │ └── Weather.razor │ │ ├── Routes.razor │ │ ├── _Imports.razor │ │ ├── App.razor │ │ └── Layout │ │ │ ├── MainLayout.razor │ │ │ ├── NavMenu.razor │ │ │ ├── MainLayout.razor.css │ │ │ └── NavMenu.razor.css │ ├── appsettings.Development.json │ ├── appsettings.json │ ├── Sitko.Blazor.CKEditor.Demo.csproj │ └── Program.cs └── Sitko.Blazor.CKEditor.Demo.Client │ ├── wwwroot │ ├── appsettings.json │ └── appsettings.Development.json │ ├── Program.cs │ ├── _Imports.razor │ ├── Sitko.Blazor.CKEditor.Demo.Client.csproj │ └── Pages │ └── Editor.razor ├── .github ├── dependabot.yml └── workflows │ ├── release.yml │ └── main.yml ├── LICENSE.md ├── README.md ├── .gitignore ├── Sitko.Blazor.CKEditor.sln └── .editorconfig /src/Sitko.Blazor.CKEditor.Bundle/.gitignore: -------------------------------------------------------------------------------- 1 | wwwroot 2 | -------------------------------------------------------------------------------- /packageIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitkoru/Sitko.Blazor.CKEditor/HEAD/packageIcon.png -------------------------------------------------------------------------------- /src/Sitko.Blazor.CKEditor.Bundle/Web/src/ckeditor.js: -------------------------------------------------------------------------------- 1 | export { default } from "./ckeditor.base"; 2 | -------------------------------------------------------------------------------- /release.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | "extends": "@sitkoru/semantic-release-config", 3 | tagFormat: "${version}" 4 | }; 5 | -------------------------------------------------------------------------------- /apps/Sitko.Blazor.CKEditor.Demo/wwwroot/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sitkoru/Sitko.Blazor.CKEditor/HEAD/apps/Sitko.Blazor.CKEditor.Demo/wwwroot/favicon.png -------------------------------------------------------------------------------- /apps/Sitko.Blazor.CKEditor.Demo/Components/Pages/Home.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 | Home 4 | 5 |

Hello, world!

6 | 7 | Welcome to your new app. 8 | -------------------------------------------------------------------------------- /apps/Sitko.Blazor.CKEditor.Demo/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /apps/Sitko.Blazor.CKEditor.Demo.Client/wwwroot/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /apps/Sitko.Blazor.CKEditor.Demo/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "AllowedHosts": "*" 9 | } 10 | -------------------------------------------------------------------------------- /apps/Sitko.Blazor.CKEditor.Demo.Client/wwwroot/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.AspNetCore": "Warning" 6 | } 7 | }, 8 | "CKEditorBundle": { 9 | "Theme": "Dark" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /src/Sitko.Blazor.CKEditor/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using Microsoft.AspNetCore.Authorization 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.JSInterop 7 | @using System 8 | -------------------------------------------------------------------------------- /src/Sitko.Blazor.CKEditor/CKEditor.razor: -------------------------------------------------------------------------------- 1 | @inherits BaseCKEditorComponent 2 |
3 | 9 |
10 | -------------------------------------------------------------------------------- /apps/Sitko.Blazor.CKEditor.Demo.Client/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 2 | using Sitko.Blazor.CKEditor.Bundle; 3 | 4 | var builder = WebAssemblyHostBuilder.CreateDefault(args); 5 | 6 | builder.Services.AddCKEditorBundle(builder.Configuration); 7 | 8 | await builder.Build().RunAsync(); 9 | -------------------------------------------------------------------------------- /apps/Sitko.Blazor.CKEditor.Demo/Components/Routes.razor: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/Sitko.Blazor.CKEditor.Bundle/CKEditorConfigExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace Sitko.Blazor.CKEditor.Bundle; 2 | 3 | 4 | public static class CKEditorConfigExtensions 5 | { 6 | public static CKEditorConfig WithHtmlEditing(this CKEditorConfig config) 7 | { 8 | config.Toolbar ??= new CKEditorToolbar(); 9 | 10 | config.Toolbar.PrependItems(new[] { "sourceEditing", "|" }); 11 | 12 | return config; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /apps/Sitko.Blazor.CKEditor.Demo.Client/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using static Microsoft.AspNetCore.Components.Web.RenderMode 7 | @using Microsoft.AspNetCore.Components.Web.Virtualization 8 | @using Microsoft.JSInterop 9 | @using Sitko.Blazor.CKEditor.Demo.Client 10 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "nuget" 4 | directory: "/" 5 | schedule: 6 | interval: "daily" 7 | assignees: 8 | - "sonicgd" 9 | - package-ecosystem: "github-actions" 10 | directory: "/" 11 | schedule: 12 | interval: "daily" 13 | assignees: 14 | - "sonicgd" 15 | - package-ecosystem: npm 16 | directory: "/" 17 | schedule: 18 | interval: "daily" 19 | assignees: 20 | - "sonicgd" 21 | -------------------------------------------------------------------------------- /apps/Sitko.Blazor.CKEditor.Demo/Components/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using static Microsoft.AspNetCore.Components.Web.RenderMode 7 | @using Microsoft.AspNetCore.Components.Web.Virtualization 8 | @using Microsoft.JSInterop 9 | @using Sitko.Blazor.CKEditor.Demo 10 | @using Sitko.Blazor.CKEditor.Demo.Client 11 | @using Sitko.Blazor.CKEditor.Demo.Components 12 | -------------------------------------------------------------------------------- /apps/Sitko.Blazor.CKEditor.Demo/Sitko.Blazor.CKEditor.Demo.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /src/Sitko.Blazor.CKEditor/CKEditorOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Sitko.Blazor.CKEditor; 2 | 3 | using System.Collections.Generic; 4 | using System.ComponentModel.DataAnnotations; 5 | 6 | public class CKEditorOptions 7 | { 8 | [Required] public virtual string ScriptPath { get; set; } = ""; 9 | [Required] public virtual Dictionary StylePaths { get; set; } = []; 10 | public virtual Dictionary GetAdditionalScripts(CKEditorConfig? config) => new(); 11 | [Required] public virtual string EditorClassName { get; set; } = ""; 12 | public virtual CKEditorConfig? CKEditorConfig { get; set; } 13 | } 14 | -------------------------------------------------------------------------------- /src/Sitko.Blazor.CKEditor/CKEditorOptionsProvider.cs: -------------------------------------------------------------------------------- 1 | namespace Sitko.Blazor.CKEditor; 2 | 3 | using Microsoft.Extensions.Options; 4 | 5 | public interface ICKEditorOptionsProvider 6 | { 7 | CKEditorOptions Options { get; } 8 | } 9 | 10 | public class CKEditorOptionsProvider : ICKEditorOptionsProvider where TOptions : CKEditorOptions 11 | { 12 | private readonly IOptionsMonitor optionsMonitor; 13 | 14 | public CKEditorOptionsProvider(IOptionsMonitor optionsMonitor) => 15 | this.optionsMonitor = optionsMonitor; 16 | 17 | public CKEditorOptions Options => optionsMonitor.CurrentValue; 18 | } 19 | -------------------------------------------------------------------------------- /apps/Sitko.Blazor.CKEditor.Demo/Components/App.razor: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /src/Sitko.Blazor.CKEditor.Bundle/Web/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sitko-blazor-ckeditor-minimal", 3 | "version": "1.0.0", 4 | "description": "", 5 | "scripts": { 6 | "dev": "webpack --mode=development", 7 | "prod": "webpack --mode=production" 8 | }, 9 | "author": "George Drak", 10 | "license": "MIT", 11 | "devDependencies": { 12 | "css-loader": "7.1.2", 13 | "ignore-emit-webpack-plugin": "^2.0.6", 14 | "mini-css-extract-plugin": "^2.9.4", 15 | "raw-loader": "^4.0.2", 16 | "webpack": "^5.101.3", 17 | "webpack-cli": "^6.0.1" 18 | }, 19 | "dependencies": { 20 | "ckeditor5": "^46.1.1" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /apps/Sitko.Blazor.CKEditor.Demo/Components/Layout/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 | About 11 |
12 | 13 |
14 | @Body 15 |
16 |
17 |
18 | 19 |
20 | An unhandled error has occurred. 21 | Reload 22 | 🗙 23 |
24 | -------------------------------------------------------------------------------- /src/Sitko.Blazor.CKEditor.Bundle/ServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace Sitko.Blazor.CKEditor.Bundle; 2 | 3 | using System; 4 | using Microsoft.Extensions.Configuration; 5 | using Microsoft.Extensions.DependencyInjection; 6 | 7 | public static class ServiceCollectionExtensions 8 | { 9 | public static IServiceCollection AddCKEditorBundle(this IServiceCollection serviceCollection, 10 | IConfiguration configuration, Action? postConfigure = null) 11 | { 12 | serviceCollection.AddCKEditor(configuration, 13 | "CKEditorBundle", options => 14 | { 15 | postConfigure?.Invoke(options); 16 | }); 17 | return serviceCollection; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /apps/Sitko.Blazor.CKEditor.Demo.Client/Sitko.Blazor.CKEditor.Demo.Client.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | true 8 | Default 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015-present Dan Abramov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /src/Sitko.Blazor.CKEditor/CKEditorConfig.cs: -------------------------------------------------------------------------------- 1 | namespace Sitko.Blazor.CKEditor; 2 | 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | 6 | 7 | public class CKEditorConfig 8 | { 9 | public string? InitialData { get; set; } 10 | public string? Language { get; set; } 11 | public string? Placeholder { get; set; } 12 | public CKEditorToolbar? Toolbar { get; set; } 13 | public string LicenseKey { get; set; } = "GPL"; // Open Source license 14 | } 15 | 16 | public class CKEditorToolbar 17 | { 18 | public List Items { get; set; } = new(); 19 | 20 | public CKEditorToolbar AppendItem(string item) => AppendItems(new[] { item }); 21 | 22 | public CKEditorToolbar AppendItems(IEnumerable items) 23 | { 24 | Items.AddRange(items); 25 | return this; 26 | } 27 | 28 | public CKEditorToolbar PrependItem(string item) => PrependItems(new[] { item }); 29 | 30 | public CKEditorToolbar PrependItems(IEnumerable items) 31 | { 32 | Items.Reverse(); 33 | var list = items.Reverse(); 34 | AppendItems(list); 35 | Items.Reverse(); 36 | return this; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /apps/Sitko.Blazor.CKEditor.Demo/Program.cs: -------------------------------------------------------------------------------- 1 | using Sitko.Blazor.CKEditor.Bundle; 2 | using Sitko.Blazor.CKEditor.Demo.Client.Pages; 3 | using Sitko.Blazor.CKEditor.Demo.Components; 4 | 5 | var builder = WebApplication.CreateBuilder(args); 6 | 7 | // Add services to the container. 8 | builder.Services.AddRazorComponents() 9 | .AddInteractiveServerComponents() 10 | .AddInteractiveWebAssemblyComponents(); 11 | 12 | builder.Services.AddCKEditorBundle(builder.Configuration); 13 | 14 | var app = builder.Build(); 15 | 16 | // Configure the HTTP request pipeline. 17 | if (app.Environment.IsDevelopment()) 18 | { 19 | app.UseWebAssemblyDebugging(); 20 | } 21 | else 22 | { 23 | app.UseExceptionHandler("/Error", createScopeForErrors: true); 24 | // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. 25 | app.UseHsts(); 26 | } 27 | 28 | app.UseHttpsRedirection(); 29 | 30 | app.UseStaticFiles(); 31 | app.UseAntiforgery(); 32 | 33 | app.MapRazorComponents() 34 | .AddInteractiveServerRenderMode() 35 | .AddInteractiveWebAssemblyRenderMode() 36 | .AddAdditionalAssemblies(typeof(Editor).Assembly); 37 | 38 | app.Run(); 39 | -------------------------------------------------------------------------------- /apps/Sitko.Blazor.CKEditor.Demo/Components/Layout/NavMenu.razor: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 30 | 31 | -------------------------------------------------------------------------------- /apps/Sitko.Blazor.CKEditor.Demo/Components/Pages/Error.razor: -------------------------------------------------------------------------------- 1 | @page "/Error" 2 | @using System.Diagnostics 3 | 4 | Error 5 | 6 |

Error.

7 |

An error occurred while processing your request.

8 | 9 | @if (ShowRequestId) 10 | { 11 |

12 | Request ID: @RequestId 13 |

14 | } 15 | 16 |

Development Mode

17 |

18 | Swapping to Development environment will display more detailed information about the error that occurred. 19 |

20 |

21 | The Development environment shouldn't be enabled for deployed applications. 22 | It can result in displaying sensitive information from exceptions to end users. 23 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 24 | and restarting the app. 25 |

26 | 27 | @code{ 28 | [CascadingParameter] 29 | private HttpContext? HttpContext { get; set; } 30 | 31 | private string? RequestId { get; set; } 32 | private bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 33 | 34 | protected override void OnInitialized() => 35 | RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier; 36 | } 37 | -------------------------------------------------------------------------------- /src/Sitko.Blazor.CKEditor/ServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace Sitko.Blazor.CKEditor; 2 | 3 | using System; 4 | using Microsoft.Extensions.Configuration; 5 | using Microsoft.Extensions.DependencyInjection; 6 | using ScriptInjector; 7 | 8 | public static class ServiceCollectionExtensions 9 | { 10 | public static IServiceCollection AddCKEditor( 11 | this IServiceCollection serviceCollection, 12 | IConfiguration configuration, 13 | string optionsKey = "CKEditor", 14 | Action? postConfigure = null) where TOptions : CKEditorOptions 15 | { 16 | var builder = serviceCollection.AddOptions().Bind(configuration.GetSection(optionsKey)); 17 | if (postConfigure is not null) 18 | { 19 | builder.PostConfigure(postConfigure); 20 | } 21 | 22 | serviceCollection.AddTransient>(); 23 | serviceCollection.AddScriptInjector(); 24 | builder.ValidateDataAnnotations(); 25 | 26 | return serviceCollection; 27 | } 28 | 29 | public static IServiceCollection AddCKEditor(this IServiceCollection serviceCollection, 30 | IConfiguration configuration, 31 | Action? postConfigure = null) => 32 | serviceCollection.AddCKEditor( 33 | configuration, postConfigure: postConfigure); 34 | } 35 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | release: 5 | types: 6 | - published 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | container: ghcr.io/sitkoru/actions-container 12 | permissions: 13 | id-token: write 14 | packages: write 15 | env: 16 | PROJECT: Sitko.Blazor.CKEditor 17 | BUNDLE_PROJECT: Sitko.Blazor.CKEditor.Bundle 18 | steps: 19 | - name: Checkout code 20 | uses: actions/checkout@v5 21 | - name: Prepare 22 | id: prep 23 | shell: bash 24 | run: | 25 | VERSION=${GITHUB_REF#refs/tags/} 26 | echo "version=${VERSION}" >> $GITHUB_OUTPUT 27 | - name: Install node.js 28 | uses: actions/setup-node@v5 29 | with: 30 | node-version: '18' 31 | - name: Build bundle js 32 | working-directory: src/${{ env.BUNDLE_PROJECT }}/Web 33 | shell: bash 34 | run: | 35 | npm ci 36 | npm run prod 37 | - name: Create packages 38 | run: dotnet pack /p:Version=${{ steps.prep.outputs.version }} -c Release -o $(pwd)/packages 39 | - name: NuGet login (OIDC → temp API key) 40 | uses: NuGet/login@v1 41 | id: login 42 | with: 43 | user: ${{ secrets.NUGET_USER }} 44 | - name: Push to Nuget 45 | run: find packages -name *.nupkg -exec dotnet nuget push {} -s https://api.nuget.org/v3/index.json -k ${{ steps.login.outputs.NUGET_API_KEY }} \; 46 | 47 | -------------------------------------------------------------------------------- /src/Sitko.Blazor.CKEditor.Bundle/Web/webpack.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license Copyright (c) 2014-2020, CKSource - Frederico Knabben. All rights reserved. 3 | * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license 4 | */ 5 | 6 | 'use strict'; 7 | 8 | /* eslint-env node */ 9 | 10 | const path = require('path'); 11 | const MiniCssExtractPlugin = require( 'mini-css-extract-plugin' ); 12 | const IgnoreEmitPlugin = require('ignore-emit-webpack-plugin'); 13 | 14 | 15 | module.exports = { 16 | performance: {hints: false}, 17 | entry: { 18 | "ckeditor": path.resolve(__dirname, 'src', 'ckeditor.js'), 19 | "ckeditor.dark": path.resolve(__dirname, 'src', 'ckeditor.dark.css'), 20 | }, 21 | output: { 22 | // The name under which the editor will be exported. 23 | library: 'BlazorEditor', 24 | 25 | path: path.resolve(__dirname, '..', 'wwwroot'), 26 | filename: '[name].js', 27 | libraryTarget: 'umd', 28 | libraryExport: 'default' 29 | }, 30 | plugins: [ 31 | new MiniCssExtractPlugin( { 32 | filename: '[name].css' 33 | } ), 34 | new IgnoreEmitPlugin('ckeditor.dark.js') 35 | ], 36 | module: { 37 | rules: [ 38 | { 39 | test: /ckeditor5-[^/\\]+[/\\]theme[/\\]icons[/\\][^/\\]+\.svg$/, 40 | use: ['raw-loader'] 41 | }, 42 | { 43 | test: /\.css$/, 44 | use: [ 45 | MiniCssExtractPlugin.loader, 46 | 'css-loader' 47 | ] 48 | } 49 | ] 50 | } 51 | }; 52 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | runs-on: ubuntu-latest 12 | container: ghcr.io/sitkoru/actions-container 13 | env: 14 | PROJECT: Sitko.Blazor.CKEditor 15 | BUNDLE_PROJECT: Sitko.Blazor.CKEditor.Bundle 16 | steps: 17 | - name: Checkout code 18 | uses: actions/checkout@v5 19 | - name: Install node.js 20 | uses: actions/setup-node@v5 21 | with: 22 | node-version: '18' 23 | - name: Build bundle js 24 | working-directory: src/${{ env.BUNDLE_PROJECT }}/Web 25 | shell: bash 26 | run: | 27 | npm ci 28 | npm run prod 29 | - name: Create main package 30 | run: dotnet pack -c Release src/${{ env.PROJECT}} 31 | - name: Create bundle package 32 | run: dotnet pack -c Release src/${{ env.BUNDLE_PROJECT}} 33 | 34 | release: 35 | name: Release 36 | runs-on: ubuntu-latest 37 | needs: [ build ] 38 | if: ${{ github.event_name == 'push' }} 39 | steps: 40 | - name: Checkout 41 | uses: actions/checkout@v5 42 | with: 43 | fetch-depth: 0 44 | persist-credentials: false 45 | - name: Semantic Release 46 | uses: sitkoru/semantic-release-action@v2 47 | env: 48 | GH_TOKEN: ${{ secrets.BOT_TOKEN }} 49 | GIT_AUTHOR_NAME: ${{ secrets.BOT_NAME }} 50 | GIT_AUTHOR_EMAIL: ${{ secrets.BOT_EMAIL }} 51 | GIT_COMMITTER_NAME: ${{ secrets.BOT_NAME }} 52 | GIT_COMMITTER_EMAIL: ${{ secrets.BOT_EMAIL }} 53 | -------------------------------------------------------------------------------- /apps/Sitko.Blazor.CKEditor.Demo.Client/Pages/Editor.razor: -------------------------------------------------------------------------------- 1 | @page "/editor" 2 | @using Sitko.Blazor.CKEditor.Bundle 3 | @rendermode InteractiveAuto 4 | 5 | Editor 6 | 7 |

CKEditor

8 | 9 |

Default editor

10 | 11 |
12 |

Customized editor

13 | 18 |
19 |

Editor with html mode

20 | 21 |
22 |
23 |

Model value

24 |
25 |     @ModelInstance.Html
26 | 
27 | 28 | @code{ 29 | public Model ModelInstance { get; set; } = new(); 30 | 31 | public class Model 32 | { 33 | public string Html { get; set; } = "Hello, world!"; 34 | } 35 | 36 | private CKEditorConfig config; 37 | private CKEditorConfig configCustom; 38 | 39 | public Editor() 40 | { 41 | config = CKEditorBundleOptions.DefaultConfig.WithHtmlEditing(); 42 | config.Language = "ru"; 43 | 44 | configCustom = CKEditorBundleOptions.DefaultConfig; 45 | configCustom.Toolbar = new CKEditorToolbar 46 | { 47 | Items = 48 | [ 49 | "bold", 50 | "italic", 51 | "strikethrough", 52 | "underline", 53 | "|", 54 | "removeFormat" 55 | ] 56 | }; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/Sitko.Blazor.CKEditor.Bundle/Sitko.Blazor.CKEditor.Bundle.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | latest 6 | enable 7 | MIT 8 | George Drak 9 | Sitko.Ru 10 | Sitko.Blazor.CKEditor.Bundle 11 | Sitko.Blazor.CKEditor.Bundle is Blazor wrapper for CKEditor with bundled CKEditor build 12 | Sitko.Blazor.CKEditor is Blazor wrapper for CKEditor with bundled CKEditor build 13 | Copyright © Sitko.ru 2023 14 | https://github.com/sitkoru/Sitko.Blazor.CKEditor 15 | https://github.com/sitkoru/Sitko.Blazor.CKEditor 16 | packageIcon.png 17 | true 18 | true 19 | snupkg 20 | true 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/Sitko.Blazor.CKEditor/ckeditor.js: -------------------------------------------------------------------------------- 1 | if (!window.SitkoBlazorCKEditor) { 2 | window.SitkoBlazorCKEditor = { 3 | editors: [], 4 | timeouts: [], 5 | init: function (element, editorClass, instance, id, configJson) { 6 | var config = {}; 7 | if (configJson) { 8 | config = JSON.parse(configJson) ?? {}; 9 | } 10 | //console.debug('CKEditor config', id, config); 11 | window[editorClass] 12 | .create(element, config) 13 | .then(editor => { 14 | window.SitkoBlazorCKEditor.editors[id] = editor; 15 | editor.model.document.on('change:data', () => { 16 | if (window.SitkoBlazorCKEditor.timeouts[id]) { 17 | clearTimeout(window.SitkoBlazorCKEditor.timeouts[id]); 18 | } 19 | window.SitkoBlazorCKEditor.timeouts[id] = setTimeout(function () { 20 | //console.debug(id, 'Update text'); 21 | instance.invokeMethodAsync('UpdateText', editor.getData()); 22 | delete window.SitkoBlazorCKEditor.timeouts[id]; 23 | }, 50) 24 | 25 | }); 26 | }) 27 | .catch(error => { 28 | //console.error('Error initializing CKEditor', error); 29 | }); 30 | }, 31 | update: function (id, content) { 32 | if (this.editors.hasOwnProperty(id)) { 33 | var editor = this.editors[id]; 34 | var oldData = editor.getData(); 35 | if (oldData !== content) { 36 | //console.debug(id, 'Update value', oldData, content); 37 | editor.setData(content); 38 | } 39 | } 40 | }, 41 | destroy: function (id) { 42 | if (this.editors.hasOwnProperty(id)) { 43 | //console.debug('Destroy editor'); 44 | this.editors[id].destroy(); 45 | delete this.editors[id]; 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /src/Sitko.Blazor.CKEditor/Sitko.Blazor.CKEditor.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net8.0 5 | latest 6 | enable 7 | MIT 8 | George Drak 9 | Sitko.Ru 10 | Sitko.Blazor.CKEditor 11 | Sitko.Blazor.CKEditor is Blazor wrapper for CKEditor 12 | Sitko.Blazor.CKEditor is Blazor wrapper for CKEditor 13 | Copyright © Sitko.ru 2023 14 | https://github.com/sitkoru/Sitko.Blazor.CKEditor 15 | https://github.com/sitkoru/Sitko.Blazor.CKEditor 16 | packageIcon.png 17 | true 18 | true 19 | snupkg 20 | true 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /apps/Sitko.Blazor.CKEditor.Demo/Components/Pages/Weather.razor: -------------------------------------------------------------------------------- 1 | @page "/weather" 2 | @attribute [StreamRendering] 3 | 4 | Weather 5 | 6 |

Weather

7 | 8 |

This component demonstrates showing data.

9 | 10 | @if (forecasts == null) 11 | { 12 |

Loading...

13 | } 14 | else 15 | { 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | @foreach (var forecast in forecasts) 27 | { 28 | 29 | 30 | 31 | 32 | 33 | 34 | } 35 | 36 |
DateTemp. (C)Temp. (F)Summary
@forecast.Date.ToShortDateString()@forecast.TemperatureC@forecast.TemperatureF@forecast.Summary
37 | } 38 | 39 | @code { 40 | private WeatherForecast[]? forecasts; 41 | 42 | protected override async Task OnInitializedAsync() 43 | { 44 | // Simulate asynchronous loading to demonstrate streaming rendering 45 | await Task.Delay(500); 46 | 47 | var startDate = DateOnly.FromDateTime(DateTime.Now); 48 | var summaries = new[] { "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" }; 49 | forecasts = Enumerable.Range(1, 5).Select(index => new WeatherForecast 50 | { 51 | Date = startDate.AddDays(index), 52 | TemperatureC = Random.Shared.Next(-20, 55), 53 | Summary = summaries[Random.Shared.Next(summaries.Length)] 54 | }).ToArray(); 55 | } 56 | 57 | private class WeatherForecast 58 | { 59 | public DateOnly Date { get; set; } 60 | public int TemperatureC { get; set; } 61 | public string? Summary { get; set; } 62 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /src/Sitko.Blazor.CKEditor.Bundle/CKEditorBundleOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Sitko.Blazor.CKEditor.Bundle; 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | public class CKEditorBundleOptions : CKEditorOptions 7 | { 8 | public CKEditorTheme Theme { get; set; } = CKEditorTheme.Light; 9 | 10 | public static CKEditorConfig DefaultConfig => new() 11 | { 12 | Toolbar = new CKEditorToolbar 13 | { 14 | Items = new List 15 | { 16 | "undo", 17 | "redo", 18 | "|", 19 | "heading", 20 | "|", 21 | "bold", 22 | "italic", 23 | "strikethrough", 24 | "underline", 25 | "subscript", 26 | "superscript", 27 | "alignment", 28 | "|", 29 | "bulletedList", 30 | "numberedList", 31 | "|", 32 | "insertTable", 33 | "link", 34 | "code", 35 | "codeBlock", 36 | "horizontalLine", 37 | "specialCharacters", 38 | "|", 39 | "removeFormat" 40 | } 41 | }, 42 | Language = "en" 43 | }; 44 | 45 | public override string ScriptPath => $"{BasePath}/ckeditor.js"; 46 | 47 | public override Dictionary StylePaths 48 | { 49 | get 50 | { 51 | var styles = new Dictionary(); 52 | styles.Add("basic", $"{BasePath}/ckeditor.css"); 53 | if (Theme == CKEditorTheme.Dark) 54 | { 55 | styles.Add("dark", $"{BasePath}/ckeditor.dark.css"); 56 | } 57 | 58 | return styles; 59 | } 60 | } 61 | 62 | public override string EditorClassName { get; set; } = "BlazorEditor"; 63 | private string BasePath => $"/_content/{typeof(CKEditorTheme).Assembly.GetName().Name}"; 64 | } 65 | 66 | public enum CKEditorTheme 67 | { 68 | Light, 69 | Dark 70 | } 71 | -------------------------------------------------------------------------------- /apps/Sitko.Blazor.CKEditor.Demo/Components/Layout/MainLayout.razor.css: -------------------------------------------------------------------------------- 1 | .page { 2 | position: relative; 3 | display: flex; 4 | flex-direction: column; 5 | } 6 | 7 | main { 8 | flex: 1; 9 | } 10 | 11 | .sidebar { 12 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); 13 | } 14 | 15 | .top-row { 16 | background-color: #f7f7f7; 17 | border-bottom: 1px solid #d6d5d5; 18 | justify-content: flex-end; 19 | height: 3.5rem; 20 | display: flex; 21 | align-items: center; 22 | } 23 | 24 | .top-row ::deep a, .top-row ::deep .btn-link { 25 | white-space: nowrap; 26 | margin-left: 1.5rem; 27 | text-decoration: none; 28 | } 29 | 30 | .top-row ::deep a:hover, .top-row ::deep .btn-link:hover { 31 | text-decoration: underline; 32 | } 33 | 34 | .top-row ::deep a:first-child { 35 | overflow: hidden; 36 | text-overflow: ellipsis; 37 | } 38 | 39 | @media (max-width: 640.98px) { 40 | .top-row { 41 | justify-content: space-between; 42 | } 43 | 44 | .top-row ::deep a, .top-row ::deep .btn-link { 45 | margin-left: 0; 46 | } 47 | } 48 | 49 | @media (min-width: 641px) { 50 | .page { 51 | flex-direction: row; 52 | } 53 | 54 | .sidebar { 55 | width: 250px; 56 | height: 100vh; 57 | position: sticky; 58 | top: 0; 59 | } 60 | 61 | .top-row { 62 | position: sticky; 63 | top: 0; 64 | z-index: 1; 65 | } 66 | 67 | .top-row.auth ::deep a:first-child { 68 | flex: 1; 69 | text-align: right; 70 | width: 0; 71 | } 72 | 73 | .top-row, article { 74 | padding-left: 2rem !important; 75 | padding-right: 1.5rem !important; 76 | } 77 | } 78 | 79 | #blazor-error-ui { 80 | background: lightyellow; 81 | bottom: 0; 82 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 83 | display: none; 84 | left: 0; 85 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 86 | position: fixed; 87 | width: 100%; 88 | z-index: 1000; 89 | } 90 | 91 | #blazor-error-ui .dismiss { 92 | cursor: pointer; 93 | position: absolute; 94 | right: 0.75rem; 95 | top: 0.5rem; 96 | } 97 | -------------------------------------------------------------------------------- /apps/Sitko.Blazor.CKEditor.Demo/wwwroot/app.css: -------------------------------------------------------------------------------- 1 | html, body { 2 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 3 | } 4 | 5 | a, .btn-link { 6 | color: #006bb7; 7 | } 8 | 9 | .btn-primary { 10 | color: #fff; 11 | background-color: #1b6ec2; 12 | border-color: #1861ac; 13 | } 14 | 15 | .btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus { 16 | box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb; 17 | } 18 | 19 | .content { 20 | padding-top: 1.1rem; 21 | } 22 | 23 | h1:focus { 24 | outline: none; 25 | } 26 | 27 | .valid.modified:not([type=checkbox]) { 28 | outline: 1px solid #26b050; 29 | } 30 | 31 | .invalid { 32 | outline: 1px solid #e50000; 33 | } 34 | 35 | .validation-message { 36 | color: #e50000; 37 | } 38 | 39 | .blazor-error-boundary { 40 | background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; 41 | padding: 1rem 1rem 1rem 3.7rem; 42 | color: white; 43 | } 44 | 45 | .blazor-error-boundary::after { 46 | content: "An error has occurred." 47 | } 48 | 49 | .darker-border-checkbox.form-check-input { 50 | border-color: #929292; 51 | } 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Sitko.Blazor.CKEditor 2 | 3 | ![Nuget](https://img.shields.io/nuget/dt/Sitko.Blazor.CKEditor) ![Nuget](https://img.shields.io/nuget/v/Sitko.Blazor.CKEditor) 4 | 5 | CKEditor component for Blazor Applications 6 | 7 | # Installation 8 | 9 | ``` 10 | dotnet add package Sitko.Blazor.CKEditor 11 | ``` 12 | 13 | Register in DI and configure in `Program.cs` 14 | 15 | ```c# 16 | builder.Services.AddCKEditor(builder.Configuration); 17 | ``` 18 | 19 | and `appsettings.json`: 20 | 21 | ```json 22 | { 23 | "CKEditor": { 24 | "ScriptPath": "https://cdn.ckeditor.com/ckeditor5/28.0.0/classic/ckeditor.js", 25 | "EditorClassName": "ClassicEditor" 26 | } 27 | } 28 | ``` 29 | 30 | Or in code: 31 | 32 | ```c# 33 | services.AddCKEditor(Configuration, options => 34 | { 35 | options.ScriptPath = "https://cdn.ckeditor.com/ckeditor5/28.0.0/classic/ckeditor.js"; 36 | options.EditorClassName = "ClassicEditor"; 37 | }); 38 | ``` 39 | 40 | If you have custom build or separate css files - configure it via StylePaths: 41 | 42 | ```json 43 | { 44 | "CKEditor": { 45 | "ScriptPath": "/ckeditor/ckeditor.js", 46 | "StylePaths": { 47 | "base": "/ckeditor/ckeditor.css", 48 | "dark": "/ckeditor/ckeditor.dark.css" 49 | }, 50 | "EditorClassName": "ClassicEditor" 51 | } 52 | } 53 | ``` 54 | ```c# 55 | services.AddCKEditor(Configuration, options => 56 | { 57 | options.ScriptPath = "/ckeditor/ckeditor.js"; 58 | options.StylePaths = new Dictionary 59 | { 60 | { "base", "/ckeditor/ckeditor.css" }, { "dark", "/ckeditor/ckeditor.dark.css" }, 61 | }; 62 | options.EditorClassName = "ClassicEditor"; 63 | }); 64 | ``` 65 | 66 | **It is recommended to use separate css file with new blazor navigation and Auto render mode.** 67 | 68 | Add to `App.razor` 69 | 70 | ```html 71 | 72 | ``` 73 | 74 | **Don't forget to link ckeditor js/css files** 75 | 76 | Add to `_Imports.razor` 77 | 78 | ```c# 79 | @using Sitko.Blazor.CKEditor 80 | ``` 81 | 82 | # Usage 83 | 84 | ```c# 85 | 86 | ``` 87 | 88 | # Sitko.Blazor.CKEditor.Bundle 89 | 90 | ![Nuget](https://img.shields.io/nuget/dt/Sitko.Blazor.CKEditor.Bundle) ![Nuget](https://img.shields.io/nuget/v/Sitko.Blazor.CKEditor.Bundle) 91 | 92 | This package includes basic ckeditor build with light and dark themes. Install: 93 | 94 | ``` 95 | dotnet add package Sitko.Blazor.CKEditor.Bundle 96 | ``` 97 | 98 | Instead of `AddCKEditor` use: 99 | 100 | ```c# 101 | builder.Services.AddCKEditorBundle(builder.Configuration); 102 | ``` 103 | 104 | and to `appsettings.json` 105 | 106 | ```json 107 | { 108 | "CKEditorBundle": { 109 | "Theme": "Dark" 110 | } 111 | } 112 | ``` 113 | -------------------------------------------------------------------------------- /src/Sitko.Blazor.CKEditor.Bundle/Web/src/ckeditor.base.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved. 3 | * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license 4 | */ 5 | 6 | // The editor creator to use. 7 | import { 8 | ClassicEditor as ClassicEditorBase, 9 | Alignment, 10 | Autoformat, 11 | AutoLink, 12 | Bold, 13 | Code, 14 | CodeBlock, 15 | Essentials, 16 | GeneralHtmlSupport, 17 | Heading, 18 | HorizontalLine, 19 | Indent, 20 | Italic, 21 | Link, 22 | List, 23 | Paragraph, 24 | RemoveFormat, 25 | SourceEditing, 26 | SpecialCharacters, 27 | SpecialCharactersArrows, 28 | SpecialCharactersCurrency, 29 | SpecialCharactersEssentials, 30 | SpecialCharactersText, 31 | Strikethrough, 32 | Subscript, 33 | Superscript, 34 | Table, 35 | TableToolbar, 36 | TextTransformation, 37 | Underline, 38 | WordCount, 39 | } from 'ckeditor5'; 40 | 41 | import enTranslations from 'ckeditor5/translations/en.js'; 42 | import ruTranslations from 'ckeditor5/translations/ru.js'; 43 | import 'ckeditor5/ckeditor5.css'; 44 | 45 | export default class BlazorEditor extends ClassicEditorBase { 46 | // Plugins to include in the build. 47 | static builtinPlugins = [ 48 | Alignment, 49 | Autoformat, 50 | AutoLink, 51 | Bold, 52 | Code, 53 | CodeBlock, 54 | Essentials, 55 | GeneralHtmlSupport, 56 | Heading, 57 | HorizontalLine, 58 | Indent, 59 | Italic, 60 | Link, 61 | List, 62 | Paragraph, 63 | RemoveFormat, 64 | SourceEditing, 65 | SpecialCharacters, 66 | SpecialCharactersArrows, 67 | SpecialCharactersCurrency, 68 | SpecialCharactersEssentials, 69 | SpecialCharactersText, 70 | Strikethrough, 71 | Subscript, 72 | Superscript, 73 | Table, 74 | TableToolbar, 75 | TextTransformation, 76 | Underline, 77 | WordCount 78 | ]; 79 | // Editor configuration. 80 | static defaultConfig = { 81 | toolbar: { 82 | items: [ 83 | 'sourceEditing', 84 | '|', 85 | 'undo', 86 | 'redo', 87 | '|', 88 | 'heading', 89 | '|', 90 | 'bold', 91 | 'italic', 92 | 'strikethrough', 93 | 'underline', 94 | 'subscript', 95 | 'superscript', 96 | 'alignment', 97 | '|', 98 | 'bulletedList', 99 | 'numberedList', 100 | '|', 101 | 'insertTable', 102 | 'link', 103 | 'code', 104 | 'codeBlock', 105 | 'horizontalLine', 106 | 'specialCharacters', 107 | '|', 108 | 'removeFormat' 109 | ] 110 | }, 111 | table: { 112 | contentToolbar: [ 113 | 'tableColumn', 114 | 'tableRow', 115 | 'mergeTableCells' 116 | ] 117 | }, 118 | translations: [ 119 | ruTranslations, enTranslations 120 | ] 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /apps/Sitko.Blazor.CKEditor.Demo/Components/Layout/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | appearance: none; 3 | cursor: pointer; 4 | width: 3.5rem; 5 | height: 2.5rem; 6 | color: white; 7 | position: absolute; 8 | top: 0.5rem; 9 | right: 1rem; 10 | border: 1px solid rgba(255, 255, 255, 0.1); 11 | background: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='rgba%28255, 255, 255, 0.55%29' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") no-repeat center/1.75rem rgba(255, 255, 255, 0.1); 12 | } 13 | 14 | .navbar-toggler:checked { 15 | background-color: rgba(255, 255, 255, 0.5); 16 | } 17 | 18 | .top-row { 19 | height: 3.5rem; 20 | background-color: rgba(0,0,0,0.4); 21 | } 22 | 23 | .navbar-brand { 24 | font-size: 1.1rem; 25 | } 26 | 27 | .bi { 28 | display: inline-block; 29 | position: relative; 30 | width: 1.25rem; 31 | height: 1.25rem; 32 | margin-right: 0.75rem; 33 | top: -1px; 34 | background-size: cover; 35 | } 36 | 37 | .bi-house-door-fill-nav-menu { 38 | background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-house-door-fill' viewBox='0 0 16 16'%3E%3Cpath d='M6.5 14.5v-3.505c0-.245.25-.495.5-.495h2c.25 0 .5.25.5.5v3.5a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293L8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4a.5.5 0 0 0 .5-.5Z'/%3E%3C/svg%3E"); 39 | } 40 | 41 | .bi-plus-square-fill-nav-menu { 42 | background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-plus-square-fill' viewBox='0 0 16 16'%3E%3Cpath d='M2 0a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2zm6.5 4.5v3h3a.5.5 0 0 1 0 1h-3v3a.5.5 0 0 1-1 0v-3h-3a.5.5 0 0 1 0-1h3v-3a.5.5 0 0 1 1 0z'/%3E%3C/svg%3E"); 43 | } 44 | 45 | .bi-list-nested-nav-menu { 46 | background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='white' class='bi bi-list-nested' viewBox='0 0 16 16'%3E%3Cpath fill-rule='evenodd' d='M4.5 11.5A.5.5 0 0 1 5 11h10a.5.5 0 0 1 0 1H5a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 3 7h10a.5.5 0 0 1 0 1H3a.5.5 0 0 1-.5-.5zm-2-4A.5.5 0 0 1 1 3h10a.5.5 0 0 1 0 1H1a.5.5 0 0 1-.5-.5z'/%3E%3C/svg%3E"); 47 | } 48 | 49 | .nav-item { 50 | font-size: 0.9rem; 51 | padding-bottom: 0.5rem; 52 | } 53 | 54 | .nav-item:first-of-type { 55 | padding-top: 1rem; 56 | } 57 | 58 | .nav-item:last-of-type { 59 | padding-bottom: 1rem; 60 | } 61 | 62 | .nav-item ::deep .nav-link { 63 | color: #d7d7d7; 64 | background: none; 65 | border: none; 66 | border-radius: 4px; 67 | height: 3rem; 68 | display: flex; 69 | align-items: center; 70 | line-height: 3rem; 71 | width: 100%; 72 | } 73 | 74 | .nav-item ::deep a.active { 75 | background-color: rgba(255,255,255,0.37); 76 | color: white; 77 | } 78 | 79 | .nav-item ::deep .nav-link:hover { 80 | background-color: rgba(255,255,255,0.1); 81 | color: white; 82 | } 83 | 84 | .nav-scrollable { 85 | display: none; 86 | } 87 | 88 | .navbar-toggler:checked ~ .nav-scrollable { 89 | display: block; 90 | } 91 | 92 | @media (min-width: 641px) { 93 | .navbar-toggler { 94 | display: none; 95 | } 96 | 97 | .nav-scrollable { 98 | /* Never collapse the sidebar for wide screens */ 99 | display: block; 100 | 101 | /* Allow sidebar to scroll for tall menus */ 102 | height: calc(100vh - 3.5rem); 103 | overflow-y: auto; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/Sitko.Blazor.CKEditor/BaseCKEditor.cs: -------------------------------------------------------------------------------- 1 | namespace Sitko.Blazor.CKEditor; 2 | 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text.Json; 6 | using System.Text.Json.Serialization; 7 | using System.Threading; 8 | using System.Threading.Tasks; 9 | using Microsoft.AspNetCore.Components; 10 | using Microsoft.AspNetCore.Components.Forms; 11 | using Microsoft.Extensions.Logging; 12 | using Microsoft.JSInterop; 13 | using ScriptInjector; 14 | 15 | public abstract class BaseCKEditorComponent : InputText, IAsyncDisposable 16 | { 17 | private DotNetObjectReference? instance; 18 | 19 | private JsonSerializerOptions jsonOptions = new() 20 | { 21 | PropertyNamingPolicy = JsonNamingPolicy.CamelCase, 22 | DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull 23 | }; 24 | 25 | private bool rendered; 26 | protected string EditorValue { get; private set; } = ""; 27 | [Inject] protected ICKEditorOptionsProvider OptionsProvider { get; set; } = null!; 28 | [Inject] protected IJSRuntime JsRuntime { get; set; } = null!; 29 | [Inject] protected IScriptInjector ScriptInjector { get; set; } = null!; 30 | [Inject] protected ILogger Logger { get; set; } = null!; 31 | [Parameter] public string Placeholder { get; set; } = "Enter text"; 32 | [Parameter] public string Class { get; set; } = ""; 33 | [Parameter] public string Style { get; set; } = ""; 34 | 35 | [Parameter] public CKEditorConfig? Config { get; set; } 36 | 37 | protected ElementReference EditorRef { get; set; } 38 | public Guid Id { get; } = Guid.NewGuid(); 39 | 40 | public async ValueTask DisposeAsync() 41 | { 42 | GC.SuppressFinalize(this); 43 | try 44 | { 45 | instance?.Dispose(); 46 | if (rendered) 47 | { 48 | await DestroyEditor(); 49 | } 50 | } 51 | catch (JSDisconnectedException) 52 | { 53 | // on server render page refresh could cause this exception, just ignoring it 54 | } 55 | } 56 | 57 | protected override async Task OnParametersSetAsync() 58 | { 59 | await base.OnParametersSetAsync(); 60 | if (Value != EditorValue) 61 | { 62 | EditorValue = Value ?? ""; 63 | if (rendered) 64 | { 65 | await UpdateEditorAsync(); 66 | } 67 | } 68 | } 69 | 70 | protected override async Task OnAfterRenderAsync(bool firstRender) 71 | { 72 | await base.OnAfterRenderAsync(firstRender); 73 | if (firstRender) 74 | { 75 | instance = DotNetObjectReference.Create(this); 76 | 77 | var config = GetConfig(); 78 | var injectRequests = new List 79 | { 80 | ScriptInjectRequest.FromResource("BlazorCkEditor", GetType().Assembly, "ckeditor.js", 81 | InjectScope.Scoped), 82 | ScriptInjectRequest.FromUrl(OptionsProvider.Options.EditorClassName, 83 | OptionsProvider.Options.ScriptPath, InjectScope.Scoped) 84 | }; 85 | if (OptionsProvider.Options.StylePaths.Count != 0) 86 | { 87 | foreach (var (styleName, stylePath) in OptionsProvider.Options.StylePaths) 88 | { 89 | injectRequests.Add( 90 | CssInjectRequest.FromUrl($"{OptionsProvider.Options.EditorClassName}{styleName}Css", 91 | stylePath, InjectScope.Scoped)); 92 | } 93 | } 94 | 95 | foreach (var (key, path) in OptionsProvider.Options.GetAdditionalScripts(config)) 96 | { 97 | injectRequests.Add(ScriptInjectRequest.FromUrl(key, path, InjectScope.Scoped)); 98 | } 99 | 100 | await ScriptInjector.InjectAsync(injectRequests, InitializeEditorAsync); 101 | } 102 | } 103 | 104 | private async Task InitializeEditorAsync(CancellationToken cancellationToken) 105 | { 106 | try 107 | { 108 | await JsRuntime.InvokeVoidAsync("window.SitkoBlazorCKEditor.init", cancellationToken, EditorRef, 109 | OptionsProvider.Options.EditorClassName, instance!, Id, 110 | JsonSerializer.Serialize(GetConfig(), jsonOptions)); 111 | rendered = true; 112 | } 113 | catch (Exception ex) 114 | { 115 | Logger.LogError(ex, ex.Message); 116 | } 117 | } 118 | 119 | private CKEditorConfig? GetConfig() => Config ?? OptionsProvider.Options.CKEditorConfig ?? new CKEditorConfig(); 120 | 121 | 122 | protected ValueTask DestroyEditor() 123 | { 124 | rendered = false; 125 | return JsRuntime.InvokeVoidAsync("window.SitkoBlazorCKEditor.destroy", Id); 126 | } 127 | 128 | [JSInvokable] 129 | public Task UpdateText(string editorText) 130 | { 131 | if (EditorValue != editorText) 132 | { 133 | EditorValue = editorText; 134 | CurrentValue = EditorValue; 135 | } 136 | 137 | return Task.CompletedTask; 138 | } 139 | 140 | private async ValueTask UpdateEditorAsync() => 141 | await JsRuntime.InvokeVoidAsync("window.SitkoBlazorCKEditor.update", Id, EditorValue); 142 | } 143 | -------------------------------------------------------------------------------- /src/Sitko.Blazor.CKEditor.Bundle/Web/src/ckeditor.dark.css: -------------------------------------------------------------------------------- 1 | :root { 2 | /* Overrides the border radius setting in the theme. */ 3 | --ck-border-radius: 4px; 4 | 5 | /* Overrides the default font size in the theme. */ 6 | --ck-font-size-base: 14px; 7 | 8 | /* Helper variables to avoid duplication in the colors. */ 9 | --ck-custom-background: hsl(270, 1%, 29%); 10 | --ck-custom-foreground: hsl(255, 3%, 18%); 11 | --ck-custom-border: hsl(300, 1%, 22%); 12 | --ck-custom-white: hsl(0, 0%, 100%); 13 | 14 | /* -- Overrides generic colors. ------------------------------------------------------------- */ 15 | 16 | --ck-color-base-foreground: var(--ck-custom-background); 17 | --ck-color-focus-border: hsl(208, 90%, 62%); 18 | --ck-color-text: hsl(0, 0%, 98%); 19 | --ck-color-shadow-drop: hsla(0, 0%, 0%, 0.2); 20 | --ck-color-shadow-inner: hsla(0, 0%, 0%, 0.1); 21 | --ck-color-base-border: hsla(270, 1%, 29%, 1); 22 | --ck-color-base-background: hsla(0, 0%, 8%, 1); 23 | 24 | /* -- Overrides the default .ck-button class colors. ---------------------------------------- */ 25 | 26 | --ck-color-button-default-background: var(--ck-custom-background); 27 | --ck-color-button-default-hover-background: hsl(270, 1%, 22%); 28 | --ck-color-button-default-active-background: hsl(270, 2%, 20%); 29 | --ck-color-button-default-active-shadow: hsl(270, 2%, 23%); 30 | --ck-color-button-default-disabled-background: var(--ck-custom-background); 31 | 32 | --ck-color-button-on-background: var(--ck-custom-foreground); 33 | --ck-color-button-on-hover-background: hsl(255, 4%, 16%); 34 | --ck-color-button-on-active-background: hsl(255, 4%, 14%); 35 | --ck-color-button-on-active-shadow: hsl(240, 3%, 19%); 36 | --ck-color-button-on-disabled-background: var(--ck-custom-foreground); 37 | 38 | --ck-color-button-action-background: hsl(168, 76%, 42%); 39 | --ck-color-button-action-hover-background: hsl(168, 76%, 38%); 40 | --ck-color-button-action-active-background: hsl(168, 76%, 36%); 41 | --ck-color-button-action-active-shadow: hsl(168, 75%, 34%); 42 | --ck-color-button-action-disabled-background: hsl(168, 76%, 42%); 43 | --ck-color-button-action-text: var(--ck-custom-white); 44 | 45 | --ck-color-button-save: hsl(120, 100%, 46%); 46 | --ck-color-button-cancel: hsl(15, 100%, 56%); 47 | 48 | /* -- Overrides the default .ck-dropdown class colors. -------------------------------------- */ 49 | 50 | --ck-color-dropdown-panel-background: var(--ck-custom-background); 51 | --ck-color-dropdown-panel-border: var(--ck-custom-foreground); 52 | 53 | /* -- Overrides the default .ck-splitbutton class colors. ----------------------------------- */ 54 | 55 | --ck-color-split-button-hover-background: var(--ck-color-button-default-hover-background); 56 | --ck-color-split-button-hover-border: var(--ck-custom-foreground); 57 | 58 | /* -- Overrides the default .ck-input class colors. ----------------------------------------- */ 59 | 60 | --ck-color-input-background: var(--ck-custom-background); 61 | --ck-color-input-border: hsl(257, 3%, 43%); 62 | --ck-color-input-text: hsl(0, 0%, 98%); 63 | --ck-color-input-disabled-background: hsl(255, 4%, 21%); 64 | --ck-color-input-disabled-border: hsl(250, 3%, 38%); 65 | --ck-color-input-disabled-text: hsl(0, 0%, 78%); 66 | 67 | /* -- Overrides the default .ck-labeled-field-view class colors. ---------------------------- */ 68 | 69 | --ck-color-labeled-field-label-background: var(--ck-custom-background); 70 | 71 | /* -- Overrides the default .ck-list class colors. ------------------------------------------ */ 72 | 73 | --ck-color-list-background: var(--ck-custom-background); 74 | --ck-color-list-button-hover-background: var(--ck-color-base-foreground); 75 | --ck-color-list-button-on-background: var(--ck-color-base-active); 76 | --ck-color-list-button-on-background-focus: var(--ck-color-base-active-focus); 77 | --ck-color-list-button-on-text: var(--ck-color-base-background); 78 | 79 | /* -- Overrides the default .ck-balloon-panel class colors. --------------------------------- */ 80 | 81 | --ck-color-panel-background: var(--ck-custom-background); 82 | --ck-color-panel-border: var(--ck-custom-border); 83 | 84 | /* -- Overrides the default .ck-toolbar class colors. --------------------------------------- */ 85 | 86 | --ck-color-toolbar-background: var(--ck-custom-background); 87 | --ck-color-toolbar-border: var(--ck-custom-border); 88 | 89 | /* -- Overrides the default .ck-tooltip class colors. --------------------------------------- */ 90 | 91 | --ck-color-tooltip-background: hsl(252, 7%, 14%); 92 | --ck-color-tooltip-text: hsl(0, 0%, 93%); 93 | 94 | /* -- Overrides the default colors used by the ckeditor5-image package. --------------------- */ 95 | 96 | --ck-color-image-caption-background: hsl(0, 0%, 97%); 97 | --ck-color-image-caption-text: hsl(0, 0%, 20%); 98 | 99 | /* -- Overrides the default colors used by the ckeditor5-widget package. -------------------- */ 100 | 101 | --ck-color-widget-blurred-border: hsl(0, 0%, 87%); 102 | --ck-color-widget-hover-border: hsl(43, 100%, 68%); 103 | --ck-color-widget-editable-focus-background: var(--ck-custom-white); 104 | 105 | /* -- Overrides the default colors used by the ckeditor5-link package. ---------------------- */ 106 | 107 | --ck-color-link-default: hsl(190, 100%, 75%); 108 | } 109 | 110 | .ck-source-editing-area textarea { 111 | background: var(--ck-color-base-background); 112 | color: var(--ck-color-text); 113 | } 114 | 115 | .ck.ck-content { 116 | color: var(--ck-color-text); 117 | } 118 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | hunspell 2 | 3 | ## Ignore Visual Studio temporary files, build results, and 4 | ## files generated by popular Visual Studio add-ons. 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | 27 | # Visual Studio 2015 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # MSTest test Results 33 | [Tt]est[Rr]esult*/ 34 | [Bb]uild[Ll]og.* 35 | 36 | # NUNIT 37 | *.VisualState.xml 38 | TestResult.xml 39 | 40 | # Build Results of an ATL Project 41 | [Dd]ebugPS/ 42 | [Rr]eleasePS/ 43 | dlldata.c 44 | 45 | # Benchmark Results 46 | BenchmarkDotNet.Artifacts/ 47 | 48 | # .NET Core 49 | project.lock.json 50 | project.fragment.lock.json 51 | artifacts/ 52 | **/Properties/launchSettings.json 53 | 54 | *_i.c 55 | *_p.c 56 | *_i.h 57 | *.ilk 58 | *.meta 59 | *.obj 60 | *.pch 61 | *.pdb 62 | *.pgc 63 | *.pgd 64 | *.rsp 65 | *.sbr 66 | *.tlb 67 | *.tli 68 | *.tlh 69 | *.tmp 70 | *.tmp_proj 71 | *.log 72 | *.vspscc 73 | *.vssscc 74 | .builds 75 | *.pidb 76 | *.svclog 77 | *.scc 78 | 79 | # Chutzpah Test files 80 | _Chutzpah* 81 | 82 | # Visual C++ cache files 83 | ipch/ 84 | *.aps 85 | *.ncb 86 | *.opendb 87 | *.opensdf 88 | *.sdf 89 | *.cachefile 90 | *.VC.db 91 | *.VC.VC.opendb 92 | 93 | # Visual Studio profiler 94 | *.psess 95 | *.vsp 96 | *.vspx 97 | *.sap 98 | 99 | # TFS 2012 Local Workspace 100 | $tf/ 101 | 102 | # Guidance Automation Toolkit 103 | *.gpState 104 | 105 | # ReSharper is a .NET coding add-in 106 | _ReSharper*/ 107 | *.[Rr]e[Ss]harper 108 | *.DotSettings.user 109 | 110 | # JustCode is a .NET coding add-in 111 | .JustCode 112 | 113 | # TeamCity is a build add-in 114 | _TeamCity* 115 | 116 | # DotCover is a Code Coverage Tool 117 | *.dotCover 118 | 119 | # Visual Studio code coverage results 120 | *.coverage 121 | *.coveragexml 122 | 123 | # NCrunch 124 | _NCrunch_* 125 | .*crunch*.local.xml 126 | nCrunchTemp_* 127 | 128 | # MightyMoose 129 | *.mm.* 130 | AutoTest.Net/ 131 | 132 | # Web workbench (sass) 133 | .sass-cache/ 134 | 135 | # Installshield output folder 136 | [Ee]xpress/ 137 | 138 | # DocProject is a documentation generator add-in 139 | DocProject/buildhelp/ 140 | DocProject/Help/*.HxT 141 | DocProject/Help/*.HxC 142 | DocProject/Help/*.hhc 143 | DocProject/Help/*.hhk 144 | DocProject/Help/*.hhp 145 | DocProject/Help/Html2 146 | DocProject/Help/html 147 | 148 | # Click-Once directory 149 | publish/ 150 | 151 | # Publish Web Output 152 | *.[Pp]ublish.xml 153 | *.azurePubxml 154 | # TODO: Comment the next line if you want to checkin your web deploy settings 155 | # but database connection strings (with potential passwords) will be unencrypted 156 | *.pubxml 157 | *.publishproj 158 | 159 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 160 | # checkin your Azure Web App publish settings, but sensitive information contained 161 | # in these scripts will be unencrypted 162 | PublishScripts/ 163 | 164 | # NuGet Packages 165 | *.nupkg 166 | # The packages folder can be ignored because of Package Restore 167 | **/packages/* 168 | # except build/, which is used as an MSBuild target. 169 | !**/packages/build/ 170 | # Uncomment if necessary however generally it will be regenerated when needed 171 | #!**/packages/repositories.config 172 | # NuGet v3's project.json files produces more ignorable files 173 | *.nuget.props 174 | *.nuget.targets 175 | 176 | # Microsoft Azure Build Output 177 | csx/ 178 | *.build.csdef 179 | 180 | # Microsoft Azure Emulator 181 | ecf/ 182 | rcf/ 183 | 184 | # Windows Store app package directories and files 185 | AppPackages/ 186 | BundleArtifacts/ 187 | Package.StoreAssociation.xml 188 | _pkginfo.txt 189 | *.appx 190 | 191 | # Visual Studio cache files 192 | # files ending in .cache can be ignored 193 | *.[Cc]ache 194 | # but keep track of directories ending in .cache 195 | !*.[Cc]ache/ 196 | 197 | # Others 198 | ClientBin/ 199 | ~$* 200 | *~ 201 | *.dbmdl 202 | *.dbproj.schemaview 203 | *.jfm 204 | *.pfx 205 | *.publishsettings 206 | orleans.codegen.cs 207 | 208 | # Since there are multiple workflows, uncomment next line to ignore bower_components 209 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 210 | #bower_components/ 211 | 212 | # RIA/Silverlight projects 213 | Generated_Code/ 214 | 215 | # Backup & report files from converting an old project file 216 | # to a newer Visual Studio version. Backup files are not needed, 217 | # because we have git ;-) 218 | _UpgradeReport_Files/ 219 | Backup*/ 220 | UpgradeLog*.XML 221 | UpgradeLog*.htm 222 | 223 | # SQL Server files 224 | *.mdf 225 | *.ldf 226 | *.ndf 227 | 228 | # Business Intelligence projects 229 | *.rdl.data 230 | *.bim.layout 231 | *.bim_*.settings 232 | 233 | # Microsoft Fakes 234 | FakesAssemblies/ 235 | 236 | # GhostDoc plugin setting file 237 | *.GhostDoc.xml 238 | 239 | # Node.js Tools for Visual Studio 240 | .ntvs_analysis.dat 241 | node_modules/ 242 | 243 | # Typescript v1 declaration files 244 | typings/ 245 | 246 | # Visual Studio 6 build log 247 | *.plg 248 | 249 | # Visual Studio 6 workspace options file 250 | *.opt 251 | 252 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 253 | *.vbw 254 | 255 | # Visual Studio LightSwitch build output 256 | **/*.HTMLClient/GeneratedArtifacts 257 | **/*.DesktopClient/GeneratedArtifacts 258 | **/*.DesktopClient/ModelManifest.xml 259 | **/*.Server/GeneratedArtifacts 260 | **/*.Server/ModelManifest.xml 261 | _Pvt_Extensions 262 | 263 | # Paket dependency manager 264 | .paket/paket.exe 265 | paket-files/ 266 | 267 | # FAKE - F# Make 268 | .fake/ 269 | 270 | # JetBrains Rider 271 | .idea/ 272 | *.sln.iml 273 | 274 | # VS Code 275 | .vscode/ 276 | 277 | # CodeRush 278 | .cr/ 279 | 280 | # Python Tools for Visual Studio (PTVS) 281 | __pycache__/ 282 | *.pyc 283 | 284 | # Cake - Uncomment if you are using it 285 | # tools/** 286 | # !tools/packages.config 287 | 288 | # Tabs Studio 289 | *.tss 290 | 291 | # Telerik's JustMock configuration file 292 | *.jmconfig 293 | 294 | # BizTalk build output 295 | *.btp.cs 296 | *.btm.cs 297 | *.odx.cs 298 | *.xsd.cs 299 | -------------------------------------------------------------------------------- /Sitko.Blazor.CKEditor.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30114.105 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4A807DE2-B122-4A4D-BA49-F42D5AA3489B}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sitko.Blazor.CKEditor", "src\Sitko.Blazor.CKEditor\Sitko.Blazor.CKEditor.csproj", "{A8685A4E-EB38-4763-AD69-C9ED1E0222EB}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Files", "Solution Files", "{0A7A09E8-DCF4-42CD-9FDD-138CB023CAD1}" 11 | ProjectSection(SolutionItems) = preProject 12 | .editorconfig = .editorconfig 13 | .gitignore = .gitignore 14 | LICENSE.md = LICENSE.md 15 | packageIcon.png = packageIcon.png 16 | README.md = README.md 17 | release.config.js = release.config.js 18 | EndProjectSection 19 | EndProject 20 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "apps", "apps", "{CA8D9BBC-EB23-4072-AD35-B6D9FC216129}" 21 | EndProject 22 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sitko.Blazor.CKEditor.Demo", "apps\Sitko.Blazor.CKEditor.Demo\Sitko.Blazor.CKEditor.Demo.csproj", "{650B1160-BF2E-425E-B078-C0244F7E62DD}" 23 | EndProject 24 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{6746178F-2829-404A-A2E8-D8DE1B44AE31}" 25 | ProjectSection(SolutionItems) = preProject 26 | .github\dependabot.yml = .github\dependabot.yml 27 | EndProjectSection 28 | EndProject 29 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{E6AD3D57-5CD8-442D-945A-3EC6FB232D51}" 30 | ProjectSection(SolutionItems) = preProject 31 | .github\workflows\main.yml = .github\workflows\main.yml 32 | .github\workflows\release.yml = .github\workflows\release.yml 33 | EndProjectSection 34 | EndProject 35 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sitko.Blazor.CKEditor.Bundle", "src\Sitko.Blazor.CKEditor.Bundle\Sitko.Blazor.CKEditor.Bundle.csproj", "{23E2912C-9DB7-4587-8C8A-CF8C275E4287}" 36 | EndProject 37 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sitko.Blazor.CKEditor.Demo.Client", "apps\Sitko.Blazor.CKEditor.Demo.Client\Sitko.Blazor.CKEditor.Demo.Client.csproj", "{2B367ECD-34B4-409A-8E2F-A7BE7C9BB488}" 38 | EndProject 39 | Global 40 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 41 | Debug|Any CPU = Debug|Any CPU 42 | Debug|x64 = Debug|x64 43 | Debug|x86 = Debug|x86 44 | Release|Any CPU = Release|Any CPU 45 | Release|x64 = Release|x64 46 | Release|x86 = Release|x86 47 | EndGlobalSection 48 | GlobalSection(SolutionProperties) = preSolution 49 | HideSolutionNode = FALSE 50 | EndGlobalSection 51 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 52 | {A8685A4E-EB38-4763-AD69-C9ED1E0222EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 53 | {A8685A4E-EB38-4763-AD69-C9ED1E0222EB}.Debug|Any CPU.Build.0 = Debug|Any CPU 54 | {A8685A4E-EB38-4763-AD69-C9ED1E0222EB}.Debug|x64.ActiveCfg = Debug|Any CPU 55 | {A8685A4E-EB38-4763-AD69-C9ED1E0222EB}.Debug|x64.Build.0 = Debug|Any CPU 56 | {A8685A4E-EB38-4763-AD69-C9ED1E0222EB}.Debug|x86.ActiveCfg = Debug|Any CPU 57 | {A8685A4E-EB38-4763-AD69-C9ED1E0222EB}.Debug|x86.Build.0 = Debug|Any CPU 58 | {A8685A4E-EB38-4763-AD69-C9ED1E0222EB}.Release|Any CPU.ActiveCfg = Release|Any CPU 59 | {A8685A4E-EB38-4763-AD69-C9ED1E0222EB}.Release|Any CPU.Build.0 = Release|Any CPU 60 | {A8685A4E-EB38-4763-AD69-C9ED1E0222EB}.Release|x64.ActiveCfg = Release|Any CPU 61 | {A8685A4E-EB38-4763-AD69-C9ED1E0222EB}.Release|x64.Build.0 = Release|Any CPU 62 | {A8685A4E-EB38-4763-AD69-C9ED1E0222EB}.Release|x86.ActiveCfg = Release|Any CPU 63 | {A8685A4E-EB38-4763-AD69-C9ED1E0222EB}.Release|x86.Build.0 = Release|Any CPU 64 | {650B1160-BF2E-425E-B078-C0244F7E62DD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 65 | {650B1160-BF2E-425E-B078-C0244F7E62DD}.Debug|Any CPU.Build.0 = Debug|Any CPU 66 | {650B1160-BF2E-425E-B078-C0244F7E62DD}.Debug|x64.ActiveCfg = Debug|Any CPU 67 | {650B1160-BF2E-425E-B078-C0244F7E62DD}.Debug|x64.Build.0 = Debug|Any CPU 68 | {650B1160-BF2E-425E-B078-C0244F7E62DD}.Debug|x86.ActiveCfg = Debug|Any CPU 69 | {650B1160-BF2E-425E-B078-C0244F7E62DD}.Debug|x86.Build.0 = Debug|Any CPU 70 | {650B1160-BF2E-425E-B078-C0244F7E62DD}.Release|Any CPU.ActiveCfg = Release|Any CPU 71 | {650B1160-BF2E-425E-B078-C0244F7E62DD}.Release|Any CPU.Build.0 = Release|Any CPU 72 | {650B1160-BF2E-425E-B078-C0244F7E62DD}.Release|x64.ActiveCfg = Release|Any CPU 73 | {650B1160-BF2E-425E-B078-C0244F7E62DD}.Release|x64.Build.0 = Release|Any CPU 74 | {650B1160-BF2E-425E-B078-C0244F7E62DD}.Release|x86.ActiveCfg = Release|Any CPU 75 | {650B1160-BF2E-425E-B078-C0244F7E62DD}.Release|x86.Build.0 = Release|Any CPU 76 | {23E2912C-9DB7-4587-8C8A-CF8C275E4287}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 77 | {23E2912C-9DB7-4587-8C8A-CF8C275E4287}.Debug|Any CPU.Build.0 = Debug|Any CPU 78 | {23E2912C-9DB7-4587-8C8A-CF8C275E4287}.Debug|x64.ActiveCfg = Debug|Any CPU 79 | {23E2912C-9DB7-4587-8C8A-CF8C275E4287}.Debug|x64.Build.0 = Debug|Any CPU 80 | {23E2912C-9DB7-4587-8C8A-CF8C275E4287}.Debug|x86.ActiveCfg = Debug|Any CPU 81 | {23E2912C-9DB7-4587-8C8A-CF8C275E4287}.Debug|x86.Build.0 = Debug|Any CPU 82 | {23E2912C-9DB7-4587-8C8A-CF8C275E4287}.Release|Any CPU.ActiveCfg = Release|Any CPU 83 | {23E2912C-9DB7-4587-8C8A-CF8C275E4287}.Release|Any CPU.Build.0 = Release|Any CPU 84 | {23E2912C-9DB7-4587-8C8A-CF8C275E4287}.Release|x64.ActiveCfg = Release|Any CPU 85 | {23E2912C-9DB7-4587-8C8A-CF8C275E4287}.Release|x64.Build.0 = Release|Any CPU 86 | {23E2912C-9DB7-4587-8C8A-CF8C275E4287}.Release|x86.ActiveCfg = Release|Any CPU 87 | {23E2912C-9DB7-4587-8C8A-CF8C275E4287}.Release|x86.Build.0 = Release|Any CPU 88 | {2B367ECD-34B4-409A-8E2F-A7BE7C9BB488}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 89 | {2B367ECD-34B4-409A-8E2F-A7BE7C9BB488}.Debug|Any CPU.Build.0 = Debug|Any CPU 90 | {2B367ECD-34B4-409A-8E2F-A7BE7C9BB488}.Debug|x64.ActiveCfg = Debug|Any CPU 91 | {2B367ECD-34B4-409A-8E2F-A7BE7C9BB488}.Debug|x64.Build.0 = Debug|Any CPU 92 | {2B367ECD-34B4-409A-8E2F-A7BE7C9BB488}.Debug|x86.ActiveCfg = Debug|Any CPU 93 | {2B367ECD-34B4-409A-8E2F-A7BE7C9BB488}.Debug|x86.Build.0 = Debug|Any CPU 94 | {2B367ECD-34B4-409A-8E2F-A7BE7C9BB488}.Release|Any CPU.ActiveCfg = Release|Any CPU 95 | {2B367ECD-34B4-409A-8E2F-A7BE7C9BB488}.Release|Any CPU.Build.0 = Release|Any CPU 96 | {2B367ECD-34B4-409A-8E2F-A7BE7C9BB488}.Release|x64.ActiveCfg = Release|Any CPU 97 | {2B367ECD-34B4-409A-8E2F-A7BE7C9BB488}.Release|x64.Build.0 = Release|Any CPU 98 | {2B367ECD-34B4-409A-8E2F-A7BE7C9BB488}.Release|x86.ActiveCfg = Release|Any CPU 99 | {2B367ECD-34B4-409A-8E2F-A7BE7C9BB488}.Release|x86.Build.0 = Release|Any CPU 100 | EndGlobalSection 101 | GlobalSection(NestedProjects) = preSolution 102 | {A8685A4E-EB38-4763-AD69-C9ED1E0222EB} = {4A807DE2-B122-4A4D-BA49-F42D5AA3489B} 103 | {650B1160-BF2E-425E-B078-C0244F7E62DD} = {CA8D9BBC-EB23-4072-AD35-B6D9FC216129} 104 | {E6AD3D57-5CD8-442D-945A-3EC6FB232D51} = {6746178F-2829-404A-A2E8-D8DE1B44AE31} 105 | {23E2912C-9DB7-4587-8C8A-CF8C275E4287} = {4A807DE2-B122-4A4D-BA49-F42D5AA3489B} 106 | {2B367ECD-34B4-409A-8E2F-A7BE7C9BB488} = {CA8D9BBC-EB23-4072-AD35-B6D9FC216129} 107 | EndGlobalSection 108 | EndGlobal 109 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Version: 2.1.0 (Using https://semver.org/) 2 | # Updated: 2021-03-03 3 | # See https://github.com/RehanSaeed/EditorConfig/releases for release notes. 4 | # See https://github.com/RehanSaeed/EditorConfig for updates to this file. 5 | # See http://EditorConfig.org for more information about .editorconfig files. 6 | 7 | ########################################## 8 | # Common Settings 9 | ########################################## 10 | 11 | # This file is the top-most EditorConfig file 12 | root = true 13 | 14 | # All Files 15 | [*] 16 | charset = utf-8 17 | indent_style = space 18 | indent_size = 4 19 | insert_final_newline = true 20 | trim_trailing_whitespace = true 21 | 22 | ########################################## 23 | # File Extension Settings 24 | ########################################## 25 | 26 | # Visual Studio Solution Files 27 | [*.sln] 28 | indent_style = tab 29 | 30 | # Visual Studio XML Project Files 31 | [*.{csproj,vbproj,vcxproj.filters,proj,projitems,shproj}] 32 | indent_size = 2 33 | 34 | # XML Configuration Files 35 | [*.{xml,config,props,targets,nuspec,resx,ruleset,vsixmanifest,vsct}] 36 | indent_size = 2 37 | 38 | # JSON Files 39 | [*.{json,json5,webmanifest}] 40 | indent_size = 2 41 | 42 | # YAML Files 43 | [*.{yml,yaml}] 44 | indent_size = 2 45 | 46 | # Markdown Files 47 | [*.md] 48 | trim_trailing_whitespace = false 49 | 50 | # Web Files 51 | [*.{htm,html,js,jsm,ts,tsx,css,sass,scss,less,pcss,svg,vue}] 52 | indent_size = 2 53 | 54 | # Batch Files 55 | [*.{cmd,bat}] 56 | end_of_line = crlf 57 | 58 | # Bash Files 59 | [*.sh] 60 | end_of_line = lf 61 | 62 | # Makefiles 63 | [Makefile] 64 | indent_style = tab 65 | 66 | ########################################## 67 | # Default .NET Code Style Severities 68 | # https://docs.microsoft.com/dotnet/fundamentals/code-analysis/configuration-options#scope 69 | ########################################## 70 | 71 | [*.{cs,csx,cake,vb,vbx}] 72 | # Default Severity for all .NET Code Style rules below 73 | dotnet_analyzer_diagnostic.severity = warning 74 | 75 | ########################################## 76 | # Language Rules 77 | # https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/language-rules 78 | ########################################## 79 | 80 | # .NET Style Rules 81 | # https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/language-rules#net-style-rules 82 | [*.{cs,csx,cake,vb,vbx}] 83 | # "this." and "Me." qualifiers 84 | #dotnet_style_qualification_for_field = true:warning 85 | #dotnet_style_qualification_for_property = true:warning 86 | #dotnet_style_qualification_for_method = true:warning 87 | #dotnet_style_qualification_for_event = true:warning 88 | # Language keywords instead of framework type names for type references 89 | dotnet_style_predefined_type_for_locals_parameters_members = true:warning 90 | dotnet_style_predefined_type_for_member_access = true:warning 91 | # Modifier preferences 92 | dotnet_style_require_accessibility_modifiers = always:warning 93 | csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:warning 94 | visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public,Friend,NotOverridable,Overridable,MustOverride,Overloads,Overrides,MustInherit,NotInheritable,Static,Shared,Shadows,ReadOnly,WriteOnly,Dim,Const,WithEvents,Widening,Narrowing,Custom,Async:warning 95 | dotnet_style_readonly_field = true:warning 96 | # Parentheses preferences 97 | dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:warning 98 | dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:warning 99 | dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:warning 100 | dotnet_style_parentheses_in_other_operators = always_for_clarity:suggestion 101 | # Expression-level preferences 102 | dotnet_style_object_initializer = true:warning 103 | dotnet_style_collection_initializer = true:warning 104 | dotnet_style_explicit_tuple_names = true:warning 105 | dotnet_style_prefer_inferred_tuple_names = true:warning 106 | dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning 107 | dotnet_style_prefer_auto_properties = true:warning 108 | dotnet_style_prefer_conditional_expression_over_assignment = false:suggestion 109 | dotnet_diagnostic.IDE0045.severity = suggestion 110 | dotnet_style_prefer_conditional_expression_over_return = false:suggestion 111 | dotnet_diagnostic.IDE0046.severity = suggestion 112 | dotnet_style_prefer_compound_assignment = true:warning 113 | dotnet_style_prefer_simplified_interpolation = true:warning 114 | dotnet_style_prefer_simplified_boolean_expressions = true:warning 115 | # Null-checking preferences 116 | dotnet_style_coalesce_expression = true:warning 117 | dotnet_style_null_propagation = true:warning 118 | dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning 119 | # File header preferences 120 | # file_header_template = \n© PROJECT-AUTHOR\n 121 | # If you use StyleCop, you'll need to disable SA1636: File header copyright text should match. 122 | # dotnet_diagnostic.SA1636.severity = none 123 | # Undocumented 124 | dotnet_style_operator_placement_when_wrapping = end_of_line 125 | 126 | # C# Style Rules 127 | # https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/language-rules#c-style-rules 128 | [*.{cs,csx,cake}] 129 | # 'var' preferences 130 | csharp_style_var_for_built_in_types = true:warning 131 | csharp_style_var_when_type_is_apparent = true:warning 132 | csharp_style_var_elsewhere = true:warning 133 | # Expression-bodied members 134 | csharp_style_expression_bodied_methods = true:warning 135 | csharp_style_expression_bodied_constructors = true:warning 136 | csharp_style_expression_bodied_operators = true:warning 137 | csharp_style_expression_bodied_properties = true:warning 138 | csharp_style_expression_bodied_indexers = true:warning 139 | csharp_style_expression_bodied_accessors = true:warning 140 | csharp_style_expression_bodied_lambdas = true:warning 141 | csharp_style_expression_bodied_local_functions = true:warning 142 | # Pattern matching preferences 143 | csharp_style_pattern_matching_over_is_with_cast_check = true:warning 144 | csharp_style_pattern_matching_over_as_with_null_check = true:warning 145 | csharp_style_prefer_switch_expression = true:warning 146 | csharp_style_prefer_pattern_matching = true:warning 147 | csharp_style_prefer_not_pattern = true:warning 148 | # Expression-level preferences 149 | csharp_style_inlined_variable_declaration = true:warning 150 | csharp_prefer_simple_default_expression = true:warning 151 | csharp_style_pattern_local_over_anonymous_function = true:warning 152 | csharp_style_deconstructed_variable_declaration = true:warning 153 | csharp_style_prefer_index_operator = true:warning 154 | csharp_style_prefer_range_operator = true:warning 155 | csharp_style_implicit_object_creation_when_type_is_apparent = true:warning 156 | # "Null" checking preferences 157 | csharp_style_throw_expression = true:warning 158 | csharp_style_conditional_delegate_call = true:warning 159 | # Code block preferences 160 | csharp_prefer_braces = true:warning 161 | csharp_prefer_simple_using_statement = true:suggestion 162 | dotnet_diagnostic.IDE0063.severity = suggestion 163 | # 'using' directive preferences 164 | csharp_using_directive_placement = inside_namespace:warning 165 | # Modifier preferences 166 | csharp_prefer_static_local_function = true:warning 167 | 168 | ########################################## 169 | # Unnecessary Code Rules 170 | # https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/unnecessary-code-rules 171 | ########################################## 172 | 173 | # .NET Unnecessary code rules 174 | [*.{cs,csx,cake,vb,vbx}] 175 | dotnet_code_quality_unused_parameters = all:warning 176 | dotnet_remove_unnecessary_suppression_exclusions = none:warning 177 | 178 | # C# Unnecessary code rules 179 | [*.{cs,csx,cake}] 180 | csharp_style_unused_value_expression_statement_preference = discard_variable:suggestion 181 | dotnet_diagnostic.IDE0058.severity = suggestion 182 | csharp_style_unused_value_assignment_preference = discard_variable:suggestion 183 | dotnet_diagnostic.IDE0059.severity = suggestion 184 | 185 | ########################################## 186 | # Formatting Rules 187 | # https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules 188 | ########################################## 189 | 190 | # .NET formatting rules 191 | # https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#net-formatting-rules 192 | [*.{cs,csx,cake,vb,vbx}] 193 | # Organize using directives 194 | dotnet_sort_system_directives_first = true 195 | dotnet_separate_import_directive_groups = false 196 | 197 | # C# formatting rules 198 | # https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/formatting-rules#c-formatting-rules 199 | [*.{cs,csx,cake}] 200 | # Newline options 201 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#new-line-options 202 | csharp_new_line_before_open_brace = all 203 | csharp_new_line_before_else = true 204 | csharp_new_line_before_catch = true 205 | csharp_new_line_before_finally = true 206 | csharp_new_line_before_members_in_object_initializers = true 207 | csharp_new_line_before_members_in_anonymous_types = true 208 | csharp_new_line_between_query_expression_clauses = true 209 | # Indentation options 210 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#indentation-options 211 | csharp_indent_case_contents = true 212 | csharp_indent_switch_labels = true 213 | csharp_indent_labels = no_change 214 | csharp_indent_block_contents = true 215 | csharp_indent_braces = false 216 | csharp_indent_case_contents_when_block = false 217 | # Spacing options 218 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#spacing-options 219 | csharp_space_after_cast = false 220 | csharp_space_after_keywords_in_control_flow_statements = true 221 | csharp_space_between_parentheses = false 222 | csharp_space_before_colon_in_inheritance_clause = true 223 | csharp_space_after_colon_in_inheritance_clause = true 224 | csharp_space_around_binary_operators = before_and_after 225 | csharp_space_between_method_declaration_parameter_list_parentheses = false 226 | csharp_space_between_method_declaration_empty_parameter_list_parentheses = false 227 | csharp_space_between_method_declaration_name_and_open_parenthesis = false 228 | csharp_space_between_method_call_parameter_list_parentheses = false 229 | csharp_space_between_method_call_empty_parameter_list_parentheses = false 230 | csharp_space_between_method_call_name_and_opening_parenthesis = false 231 | csharp_space_after_comma = true 232 | csharp_space_before_comma = false 233 | csharp_space_after_dot = false 234 | csharp_space_before_dot = false 235 | csharp_space_after_semicolon_in_for_statement = true 236 | csharp_space_before_semicolon_in_for_statement = false 237 | csharp_space_around_declaration_statements = false 238 | csharp_space_before_open_square_brackets = false 239 | csharp_space_between_empty_square_brackets = false 240 | csharp_space_between_square_brackets = false 241 | # Wrap options 242 | # https://docs.microsoft.com/visualstudio/ide/editorconfig-formatting-conventions#wrap-options 243 | csharp_preserve_single_line_statements = false 244 | csharp_preserve_single_line_blocks = true 245 | 246 | ########################################## 247 | # .NET Naming Rules 248 | # https://docs.microsoft.com/dotnet/fundamentals/code-analysis/style-rules/naming-rules 249 | ########################################## 250 | 251 | [*.{cs,csx,cake,vb,vbx}] 252 | 253 | ########################################## 254 | # Styles 255 | ########################################## 256 | 257 | # camel_case_style - Define the camelCase style 258 | dotnet_naming_style.camel_case_style.capitalization = camel_case 259 | # pascal_case_style - Define the PascalCase style 260 | dotnet_naming_style.pascal_case_style.capitalization = pascal_case 261 | # first_upper_style - The first character must start with an upper-case character 262 | dotnet_naming_style.first_upper_style.capitalization = first_word_upper 263 | # prefix_interface_with_i_style - Interfaces must be PascalCase and the first character of an interface must be an 'I' 264 | dotnet_naming_style.prefix_interface_with_i_style.capitalization = pascal_case 265 | dotnet_naming_style.prefix_interface_with_i_style.required_prefix = I 266 | # prefix_type_parameters_with_t_style - Generic Type Parameters must be PascalCase and the first character must be a 'T' 267 | dotnet_naming_style.prefix_type_parameters_with_t_style.capitalization = pascal_case 268 | dotnet_naming_style.prefix_type_parameters_with_t_style.required_prefix = T 269 | # disallowed_style - Anything that has this style applied is marked as disallowed 270 | dotnet_naming_style.disallowed_style.capitalization = pascal_case 271 | dotnet_naming_style.disallowed_style.required_prefix = ____RULE_VIOLATION____ 272 | dotnet_naming_style.disallowed_style.required_suffix = ____RULE_VIOLATION____ 273 | # internal_error_style - This style should never occur... if it does, it indicates a bug in file or in the parser using the file 274 | dotnet_naming_style.internal_error_style.capitalization = pascal_case 275 | dotnet_naming_style.internal_error_style.required_prefix = ____INTERNAL_ERROR____ 276 | dotnet_naming_style.internal_error_style.required_suffix = ____INTERNAL_ERROR____ 277 | 278 | ########################################## 279 | # .NET Design Guideline Field Naming Rules 280 | # Naming rules for fields follow the .NET Framework design guidelines 281 | # https://docs.microsoft.com/dotnet/standard/design-guidelines/index 282 | ########################################## 283 | 284 | # All public/protected/protected_internal constant fields must be PascalCase 285 | # https://docs.microsoft.com/dotnet/standard/design-guidelines/field 286 | dotnet_naming_symbols.public_protected_constant_fields_group.applicable_accessibilities = public, protected, protected_internal 287 | dotnet_naming_symbols.public_protected_constant_fields_group.required_modifiers = const 288 | dotnet_naming_symbols.public_protected_constant_fields_group.applicable_kinds = field 289 | dotnet_naming_rule.public_protected_constant_fields_must_be_pascal_case_rule.symbols = public_protected_constant_fields_group 290 | dotnet_naming_rule.public_protected_constant_fields_must_be_pascal_case_rule.style = pascal_case_style 291 | dotnet_naming_rule.public_protected_constant_fields_must_be_pascal_case_rule.severity = warning 292 | 293 | # All public/protected/protected_internal static readonly fields must be PascalCase 294 | # https://docs.microsoft.com/dotnet/standard/design-guidelines/field 295 | dotnet_naming_symbols.public_protected_static_readonly_fields_group.applicable_accessibilities = public, protected, protected_internal 296 | dotnet_naming_symbols.public_protected_static_readonly_fields_group.required_modifiers = static, readonly 297 | dotnet_naming_symbols.public_protected_static_readonly_fields_group.applicable_kinds = field 298 | dotnet_naming_rule.public_protected_static_readonly_fields_must_be_pascal_case_rule.symbols = public_protected_static_readonly_fields_group 299 | dotnet_naming_rule.public_protected_static_readonly_fields_must_be_pascal_case_rule.style = pascal_case_style 300 | dotnet_naming_rule.public_protected_static_readonly_fields_must_be_pascal_case_rule.severity = warning 301 | 302 | # No other public/protected/protected_internal fields are allowed 303 | # https://docs.microsoft.com/dotnet/standard/design-guidelines/field 304 | dotnet_naming_symbols.other_public_protected_fields_group.applicable_accessibilities = public, protected, protected_internal 305 | dotnet_naming_symbols.other_public_protected_fields_group.applicable_kinds = field 306 | dotnet_naming_rule.other_public_protected_fields_disallowed_rule.symbols = other_public_protected_fields_group 307 | dotnet_naming_rule.other_public_protected_fields_disallowed_rule.style = disallowed_style 308 | dotnet_naming_rule.other_public_protected_fields_disallowed_rule.severity = error 309 | 310 | ########################################## 311 | # StyleCop Field Naming Rules 312 | # Naming rules for fields follow the StyleCop analyzers 313 | # This does not override any rules using disallowed_style above 314 | # https://github.com/DotNetAnalyzers/StyleCopAnalyzers 315 | ########################################## 316 | 317 | # All constant fields must be PascalCase 318 | # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1303.md 319 | dotnet_naming_symbols.stylecop_constant_fields_group.applicable_accessibilities = public, internal, protected_internal, protected, private_protected, private 320 | dotnet_naming_symbols.stylecop_constant_fields_group.required_modifiers = const 321 | dotnet_naming_symbols.stylecop_constant_fields_group.applicable_kinds = field 322 | dotnet_naming_rule.stylecop_constant_fields_must_be_pascal_case_rule.symbols = stylecop_constant_fields_group 323 | dotnet_naming_rule.stylecop_constant_fields_must_be_pascal_case_rule.style = pascal_case_style 324 | dotnet_naming_rule.stylecop_constant_fields_must_be_pascal_case_rule.severity = warning 325 | 326 | # All static readonly fields must be PascalCase 327 | # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1311.md 328 | dotnet_naming_symbols.stylecop_static_readonly_fields_group.applicable_accessibilities = public, internal, protected_internal, protected, private_protected, private 329 | dotnet_naming_symbols.stylecop_static_readonly_fields_group.required_modifiers = static, readonly 330 | dotnet_naming_symbols.stylecop_static_readonly_fields_group.applicable_kinds = field 331 | dotnet_naming_rule.stylecop_static_readonly_fields_must_be_pascal_case_rule.symbols = stylecop_static_readonly_fields_group 332 | dotnet_naming_rule.stylecop_static_readonly_fields_must_be_pascal_case_rule.style = pascal_case_style 333 | dotnet_naming_rule.stylecop_static_readonly_fields_must_be_pascal_case_rule.severity = warning 334 | 335 | # No non-private instance fields are allowed 336 | # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1401.md 337 | dotnet_naming_symbols.stylecop_fields_must_be_private_group.applicable_accessibilities = public, internal, protected_internal, protected, private_protected 338 | dotnet_naming_symbols.stylecop_fields_must_be_private_group.applicable_kinds = field 339 | dotnet_naming_rule.stylecop_instance_fields_must_be_private_rule.symbols = stylecop_fields_must_be_private_group 340 | dotnet_naming_rule.stylecop_instance_fields_must_be_private_rule.style = disallowed_style 341 | dotnet_naming_rule.stylecop_instance_fields_must_be_private_rule.severity = error 342 | 343 | # Private fields must be camelCase 344 | # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1306.md 345 | dotnet_naming_symbols.stylecop_private_fields_group.applicable_accessibilities = private 346 | dotnet_naming_symbols.stylecop_private_fields_group.applicable_kinds = field 347 | dotnet_naming_rule.stylecop_private_fields_must_be_camel_case_rule.symbols = stylecop_private_fields_group 348 | dotnet_naming_rule.stylecop_private_fields_must_be_camel_case_rule.style = camel_case_style 349 | dotnet_naming_rule.stylecop_private_fields_must_be_camel_case_rule.severity = warning 350 | 351 | # Local variables must be camelCase 352 | # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1312.md 353 | dotnet_naming_symbols.stylecop_local_fields_group.applicable_accessibilities = local 354 | dotnet_naming_symbols.stylecop_local_fields_group.applicable_kinds = local 355 | dotnet_naming_rule.stylecop_local_fields_must_be_camel_case_rule.symbols = stylecop_local_fields_group 356 | dotnet_naming_rule.stylecop_local_fields_must_be_camel_case_rule.style = camel_case_style 357 | dotnet_naming_rule.stylecop_local_fields_must_be_camel_case_rule.severity = silent 358 | 359 | # This rule should never fire. However, it's included for at least two purposes: 360 | # First, it helps to understand, reason about, and root-case certain types of issues, such as bugs in .editorconfig parsers. 361 | # Second, it helps to raise immediate awareness if a new field type is added (as occurred recently in C#). 362 | dotnet_naming_symbols.sanity_check_uncovered_field_case_group.applicable_accessibilities = * 363 | dotnet_naming_symbols.sanity_check_uncovered_field_case_group.applicable_kinds = field 364 | dotnet_naming_rule.sanity_check_uncovered_field_case_rule.symbols = sanity_check_uncovered_field_case_group 365 | dotnet_naming_rule.sanity_check_uncovered_field_case_rule.style = internal_error_style 366 | dotnet_naming_rule.sanity_check_uncovered_field_case_rule.severity = error 367 | 368 | 369 | ########################################## 370 | # Other Naming Rules 371 | ########################################## 372 | 373 | # All of the following must be PascalCase: 374 | # - Namespaces 375 | # https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-namespaces 376 | # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1300.md 377 | # - Classes and Enumerations 378 | # https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces 379 | # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1300.md 380 | # - Delegates 381 | # https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces#names-of-common-types 382 | # - Constructors, Properties, Events, Methods 383 | # https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-type-members 384 | dotnet_naming_symbols.element_group.applicable_kinds = namespace, class, enum, struct, delegate, event, method, property 385 | dotnet_naming_rule.element_rule.symbols = element_group 386 | dotnet_naming_rule.element_rule.style = pascal_case_style 387 | dotnet_naming_rule.element_rule.severity = warning 388 | 389 | # Interfaces use PascalCase and are prefixed with uppercase 'I' 390 | # https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces 391 | dotnet_naming_symbols.interface_group.applicable_kinds = interface 392 | dotnet_naming_rule.interface_rule.symbols = interface_group 393 | dotnet_naming_rule.interface_rule.style = prefix_interface_with_i_style 394 | dotnet_naming_rule.interface_rule.severity = warning 395 | 396 | # Generics Type Parameters use PascalCase and are prefixed with uppercase 'T' 397 | # https://docs.microsoft.com/dotnet/standard/design-guidelines/names-of-classes-structs-and-interfaces 398 | dotnet_naming_symbols.type_parameter_group.applicable_kinds = type_parameter 399 | dotnet_naming_rule.type_parameter_rule.symbols = type_parameter_group 400 | dotnet_naming_rule.type_parameter_rule.style = prefix_type_parameters_with_t_style 401 | dotnet_naming_rule.type_parameter_rule.severity = warning 402 | 403 | # Function parameters use camelCase 404 | # https://docs.microsoft.com/dotnet/standard/design-guidelines/naming-parameters 405 | dotnet_naming_symbols.parameters_group.applicable_kinds = parameter 406 | dotnet_naming_rule.parameters_rule.symbols = parameters_group 407 | dotnet_naming_rule.parameters_rule.style = camel_case_style 408 | dotnet_naming_rule.parameters_rule.severity = warning 409 | 410 | ########################################## 411 | # License 412 | ########################################## 413 | # The following applies as to the .editorconfig file ONLY, and is 414 | # included below for reference, per the requirements of the license 415 | # corresponding to this .editorconfig file. 416 | # See: https://github.com/RehanSaeed/EditorConfig 417 | # 418 | # MIT License 419 | # 420 | # Copyright (c) 2017-2019 Muhammad Rehan Saeed 421 | # Copyright (c) 2019 Henry Gabryjelski 422 | # 423 | # Permission is hereby granted, free of charge, to any 424 | # person obtaining a copy of this software and associated 425 | # documentation files (the "Software"), to deal in the 426 | # Software without restriction, including without limitation 427 | # the rights to use, copy, modify, merge, publish, distribute, 428 | # sublicense, and/or sell copies of the Software, and to permit 429 | # persons to whom the Software is furnished to do so, subject 430 | # to the following conditions: 431 | # 432 | # The above copyright notice and this permission notice shall be 433 | # included in all copies or substantial portions of the Software. 434 | # 435 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 436 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 437 | # OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 438 | # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 439 | # HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 440 | # WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 441 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 442 | # OTHER DEALINGS IN THE SOFTWARE. 443 | ########################################## 444 | --------------------------------------------------------------------------------