npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

jsyg-fulleditor

v1.1.0

Published

complete and very simple API to create svg editor

Downloads

837

Readme

JSYG.FullEditor

Provides a complete and very simple API to create your own svg online editor. UI is your concern.

Demo

http://yannickbochatay.github.io/JSYG.FullEditor

Installation

npm install jsyg-fulleditor

Example

HTML

<svg width="500" height="500" id="editor"></svg>

Shape :
<select name="shape">
    <option>circle</option>
    <option>rect</option>
    <option>line</option>
    <option>polyline</option>
</select>

<button id="importImage">Import image</button>

<button id="download">Download</button>

Javascript

var svgEditor = new JSYG.FullEditor("#editor");

svgEditor.enable();

svgEditor.newDocument(600,600);

$("[name=shape]").on("change",function() {
    svgEditor.shapeDrawerModel = '<'+this.value+'>';
}).trigger("change");

svgEditor.enableShapeDrawer();

$("#importImage").on("click",function() {
    svgEditor.chooseFile().then(svgEditor.insertImageFile);
});

$("#download").on("click",function() {
    svgEditor.download("svg");
});

Full example script

https://github.com/YannickBochatay/JSYG.FullEditor/blob/master/script.js

API

Table of Contents

registerKeyShortCut

You can also pass an object with several key shortcuts as keys/values

Parameters
  • key string jquery hotkeys syntax (example : "ctrl+i")
  • fct function callback called when key or combination keys are pressed

Returns JSYG.FullEditor

unregisterKeyShortCut

Unregister a key shortcut

Parameters
  • key string jquery hotkeys syntax (example : "ctrl+i")

Returns JSYG.FullEditor

selectAll

Select all editable elements in document

Returns JSYG.FullEditor

deselectAll

Deselect all editable elements

Returns JSYG.FullEditor

enableKeyShortCuts

  • See: JSYG.prototype.registerKeyShortCut

Enable all key shorcuts registered by registerKeyShortCut method

Returns JSYG.FullEditor

disableKeyShortCuts

  • See: JSYG.prototype.registerKeyShortCut

Disable all key shorcuts registered by registerKeyShortCut method

Returns JSYG.FullEditor

getLayers

Get all layers defined

Returns JSYG

addLayer

Add and use a new layer

Returns JSYG.FullEditor

removeLayer

Remove a layer

Returns JSYG.FullEditor

getDocument

Get document as a DOM node

Returns Element

hideEditors

Hide shape and text editors

Returns JSYG.FullEditor

enableSelection

Enable mouse pointer selection

Returns JSYG.FullEditor

disableSelection

Disable mouse pointer selection

Returns JSYG.FullEditor

disableInsertion

Disable mouse pointer insertion

Returns JSYG.FullEditor

disableEdition

Enable edition functionalities

Returns JSYG.FullEditor

duplicate

Duplicate selected element

Returns JSYG.FullEditor

dim

You can also pass an object

Parameters

rotate

Rotate selected element

Parameters

Returns JSYG.FullEditor

css

Get or set css property

Parameters
  • prop string name of css property
  • value

triggerChange

Trigger change event

Returns JSYG.FullEditor

cursorDrawing

Properties
  • cursorDrawing string name of css cursor when drawing is active

drawShape

Draw one shape

Parameters
  • modele type

Returns Promise

align

Aligne les éléments sélectionnés

Parameters
  • type String (top,middle,bottom,left,center,right)

Returns undefined

load

Load a document from a file, an url, a xml string or a xml node

Parameters
  • arg

Returns Promise

loadString

Load a document from a svg string

Parameters

Returns JSYG.FullEditor

readFile

Read a File instance

Parameters
  • file File
  • readAs string optional, "DataURL" or "Text" ("Text" by default)

Returns Promise

loadFile

Load a document from a File instance

Parameters
  • file File

Returns Promise

loadURL

Load a document from an url

Parameters

Returns Promise

loadXML

Load a document from a xml node

Parameters
  • svg DOMElement

Returns JSYG.FullEditor

newDocument

Create a new document

Parameters

Returns JSYG.FullEditor

toCanvas

Convert document to a canvas element

Returns Promise

toSVGString

Convert document to a SVG string (keep links)

Parameters
  • opt object options (for the moment only "standalone" as boolean, to converts links to dataURLs)
Examples
fullEditor.toSVGString({standalone:true})

Returns Promise

toSVGDataURL

Convert document to a SVG data url

Returns Promise

toPNGDataURL

Convert document to a PNG data url

Parameters
  • format

Returns Promise

toDataURL

Convert document to data URL

Parameters

Returns Promise

print

Print document

Returns Promise

downloadPNG

Download document as PNG

Returns Promise

downloadSVG

Download document as SVG

Returns Promise

download

Download document

Parameters

Returns JSYG.FullEditor

remove

Remove selection

Returns JSYG.FullEditor

group

Group selected elements

Returns JSYG.FullEditor

ungroup

Ungroup selection

Returns JSYG.FullEditor

center

Center selected elements

Parameters
  • orientation string "vertical" or "horizontal"

Returns JSYG.FullEditor

centerVertically

Center selected elements vertically

Returns JSYG.FullEditor

centerHorizontally

Center selected elements horizontally

Returns JSYG.FullEditor

registerPlugin

Register a plugin

Parameters

Returns JSYG.FullEditor

defineProperty

Properties
  • editText boolean set if text elements can be edited or not

defineProperty

Properties
  • editPosition boolean set if elements position can be edited or not

defineProperty

Properties
  • editSize boolean set if elements size can be edited or not

defineProperty

Properties
  • editRotation boolean set if elements rotation can be edited or not

defineProperty

Properties
  • editPathMainPoints boolean set if main points of paths can be edited or not

defineProperty

Properties
  • editPathCtrlPoints boolean set if control points of paths can be edited or not

defineProperty

Properties
  • canvasResizable boolean set if the editor can be resized or not

defineProperty

Properties
  • keepShapesRatio boolean set if ratio must be kept when resizing

defineProperty

Properties
  • drawingPathMethod string "freehand" or "point2point". Set method of drawing paths

defineProperty

Properties
  • autoSmoothPaths boolean set if paths must be smoothed automatically when drawing

defineProperty

Properties
  • useTransformAttr boolean set if transform attribute must be affected when editing size and position, instead of position and size attributes

defineProperty

Properties
  • currentLayer number set current layer of edition

defineProperty

Properties
  • shapeDrawerModel object dom node to clone when starting drawing