一个基于 Blazor 编写的基本 SVG 编辑器。
A basic HTML SVG Editor written in Blazor.
The WASM sample project can be demoed at https://kristofferstrube.github.io/Blazor.SVGEditor/
You need to install .NET 7.0 or newer to use the library.
You can install the package via NuGet with the Package Manager in your IDE or alternatively using the command line:
dotnet add package KristofferStrube.Blazor.SVGEditorThe package can be used in Blazor WebAssembly and Blazor Server projects. In the samples folder of this repository, you can find two projects that show how to use the SVGEditor component in both Blazor Server and WASM.
You need to reference the package to use it in your pages. This can be done in _Import.razor by adding the following.
@using KristofferStrube.Blazor.SVGEditorTo use the component in your pages you also need to register som services in your service collection. We have made a single method that allows you to add the needed service which you use like so:
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add("#app");
builder.RootComponents.Add("head::after");
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
// Adding the needed services.
builder.Services.AddSVGEditor();
await builder.Build().RunAsync();The libraries that the component uses also need to have some stylesheets and scripts added to function.
For this, you need to insert the following tags in the `` section of your index.html or Host.cshtml file:
The library uses Scoped CSS, so you must include your project-specific .styles.css CSS file in your project for the scoped styles of the library components. An example is in the test project in this repo:
At the end of the file, after you have referenced the Blazor Server or Wasm bootstrapper, insert the following:
Now, you are ready to use the component in your page. A minimal example of this would be the following:
@code {
private string Input = @"";
}Feel free to open issues on the repository if you find any errors with the package or have wishes for features.
…暂无开放 Issues,或尚未同步最近议题。