GithubHelp home page GithubHelp logo

florian03-1 / blazorsvgeditor Goto Github PK

View Code? Open in Web Editor NEW
16.0 16.0 5.0 9.58 MB

Blazor Svg Editor

Home Page: https://florian03-1.github.io/BlazorSvgEditor/

License: MIT License

C# 49.37% HTML 27.53% JavaScript 0.50% CSS 22.60%
blazor blazorcomponent svg svgeditor

blazorsvgeditor's People

Contributors

emiliosanchis avatar florian03-1 avatar thomas-illiet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

blazorsvgeditor's Issues

Allow to export export SVG editor configuration

I'm current search solution to export the configuration of shapes in order to inject the configuration into any data source ( database / form /etc.. )

if you have a simple solution I'll take it!

Add feature to duplicate shape

I write following line do add this feature.

SvgEditor.PublicMethods.cs

public async Task DuplicateSelectedShape()
    {
        if (SelectedShape != null)
        {
            int deletedShapeId = SelectedShape.CustomId;
            Shape ? shape = Shapes.FirstOrDefault(s => s.CustomId == deletedShapeId);

            if (shape != null)
            {
                var newShape = shape.Clone();
                if (Shapes.Count > 0) newShape.CustomId = Math.Min(Enumerable.Min<Shape>(Shapes, x => x.CustomId) - 1, newShape.CustomId);

                Shapes.Add(newShape);
                await OnShapeChanged.InvokeAsync(ShapeChangedEventArgs.ShapeAdded(newShape));
            }
        }
        else
        {
            if (ShowDiagnosticInformation) Console.WriteLine("No shape selected - so nothing to duplicate");
        }
    }

preview.razor

<div class="inline-flex mt-2" role="group">
  <button @onclick="DuplicateShape" type="button" class="shadow-sm flex-grow focus:outline-none text-white bg-yellow-400 hover:bg-yellow-500 focus:ring-4 focus:ring-yellow-300 font-medium rounded-lg text-sm px-5 py-2 mr-2">Duplicate Shape</button>
  <button @onclick="DeleteShape" type="button" class="shadow-sm flex-grow focus:outline-none text-white bg-red-700 hover:bg-red-800 focus:ring-4 focus:ring-red-300 font-medium rounded-lg text-sm px-5 py-2">Delete Shape</button>
</div>

preview.razor.cs

private void DuplicateShape()
{
    svgEditor?.DuplicateSelectedShape();
}

shape.cs

public Shape Clone()
{
    Shape temp = (Shape)this.MemberwiseClone();
    return temp;
}

Why use int for shape identification, when Guid is simpler?

Possibility to receive the SelectedShapeIdChanged event when the readonly property is true

Possibility to receive the SelectedShapeIdChanged event when the readonly property is true.

Or have an event that indicates that a shape has been clicked regardless of the value of the ReadOnly property

This is useful for once the shapes have been defined in an editor, to show a viewer to the user so that they can select one of the shapes.

Modifying the SelectAsync method of the ShapeEditor class as follows also raises the event when the property ReadOnly=true

 protected async Task SelectAsync(PointerEventArgs eventArgs)
 {
     if(eventArgs.PointerType == "touch") return; //Touch events are handled separately

     if (SvgElement.SvgEditor.EditMode == EditMode.Add) return;
     if (SvgElement.SvgEditor.ReadOnly)
     {
         await SvgElement.SvgEditor.SelectedShapeIdChanged.InvokeAsync(SvgElement.CustomId);
         return;
     }
    
     SvgElement.SelectShape();
     SvgElement.SvgEditor.SelectShape(SvgElement, eventArgs);
 }

Image not centred after rendered

As you can see in the demo site, the image is not automatically centred in first render. With "centred" I mean is just like what "Reset Transformation" button does.
I tried to use the method ResetTransform() in OnAfterRenderAsync, after the ReloadImage(), and it does not do the same transformation as if i click the "Reset Transformation" button.

Shape Position

Hello!
I am wondering if it's possible somehow to get the position and size of each shape in the SvgEditor?
For example X, Y, Width and Height of a Rectangle.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.