Module: svgcanvas

Numerous tools for working with the editor's "canvas"

License:
  • MIT
Source:

Classes

SvgCanvas

Interfaces

ExtensionInitResponse
PrivateMethods

Members

(inner) addCommandToHistory :module:path.EditorContext#addCommandToHistory|module:draw.DrawCanvasInit#addCommandToHistory

This should really be an intersection applying to all types rather than a union.

Type:
Source:

(inner) svgcontent :SVGSVGElement

The actual element that represents the final output SVG element

Type:
  • SVGSVGElement
Source:

(inner) svgroot :SVGSVGElement

Type:
  • SVGSVGElement
Source:

Methods

(inner) addPtsToSelection(ptsInfo) → {void}

Parameters:
Name Type Description
ptsInfo PlainObject
Properties
Name Type Description
closedSubpath boolean
grips Array.<SVGCircleElement>
Source:
Fires:
Returns:
Type
void

(inner) changeSVGContent() → {void}

Source:
Fires:
Returns:
Type
void

(inner) endChanges(changes) → {void}

Parameters:
Name Type Description
changes PlainObject
Properties
Name Type Description
cmd ChangeElementCommand
elem SVGPathElement
Source:
Fires:
Returns:
Type
void

(inner) ffClone(elem) → {Element}

Hack for Firefox bugs where text element features aren't updated or get messed up. See issue 136 and issue 137. This function clones the element and re-selects it.

Parameters:
Name Type Description
elem Element

The (text) DOM element to clone

Source:
To Do:
  • Test for this bug on load and add it to "support" object instead of browser sniffing
Returns:

Cloned element

Type
Element

(inner) findDuplicateGradient(grad) → {SVGGradientElement}

Check if exact gradient already exists.

Parameters:
Name Type Description
grad SVGGradientElement

The gradient DOM element to compare to others

Source:
Returns:

The existing gradient if found, null if not

Type
SVGGradientElement

(inner) handleHistoryEvent(eventType, cmd) → {void}

Parameters:
Name Type Description
eventType string

One of the HistoryEvent types

cmd module:history.HistoryCommand

Fulfills the HistoryCommand interface

Source:
Fires:
Returns:
Type
void

(inner) logMatrix(m) → {void}

Debug tool to easily see the current matrix in the browser's console.

Parameters:
Name Type Description
m SVGMatrix

The matrix

Source:
Returns:
Type
void

Type Definitions

CanvasInfo

Type:
Properties:
Name Type Description
x Float

The canvas' new x coordinate

y Float

The canvas' new y coordinate

oldX string

The canvas' old x coordinate

oldY string

The canvas' old y coordinate

d_x Float

The x position difference

d_y Float

The y position difference

Source:

ChangedIDs

Type:
Source:

ElementPositionInCanvas

Type:
Properties:
Name Type Description
x Float
y Float
Source:

EventHandler(win, arg) → {module:svgcanvas.EventHandlerReturn}

Parameters:
Name Type Description
win external:Window
arg module:svgcanvas.SvgCanvas#event:GenericCanvasEvent
Source:
Listens to Events:
Returns:
Type
module:svgcanvas.EventHandlerReturn

EventHandlerReturn

The promise return, if present, resolves to undefined (extension_added, exported, saved)

Type:
  • Promise.<void> | void
Source:

ExtensionArgumentObject

Type:
Properties:
Name Type Description
svgroot SVGSVGElement

See module:svgcanvas~svgroot

svgcontent SVGSVGElement

See module:svgcanvas~svgcontent

nonce string | Integer

See module:draw.Drawing#getNonce

selectorManager module:select.SelectorManager
importLocale module:SVGEditor~ImportLocale
Source:

ExtensionIDsUpdatedStatus

Type:
Properties:
Name Type Description
remove Array.<string>

Contains string IDs (used by ext-connector.js)

Source:

ExtensionInitArgs

Type:
Source:

ExtensionInitCallback(arg) → {Promise.<(module:svgcanvas.ExtensionInitResponse|void)>}

This:
Parameters:
Name Type Description
arg module:svgcanvas.ExtensionArgumentObject
Source:
Returns:

Resolves to ExtensionInitResponse or undefined

Type
Promise.<(module:svgcanvas.ExtensionInitResponse|void)>

ExtensionInitResponsePlusName

Type:
Properties:
Name Type Description
name string

The extension's resolved ID (whether explicit or based on file name)

Implements:
Source:

ExtensionMouseDownStatus

Type:
Properties:
Name Type Description
started boolean

Indicates that creating/editing has started

Source:

ExtensionMouseUpStatus

Type:
Properties:
Name Type Description
keep boolean

Indicates if the current element should be kept

started boolean

Indicates if editing should still be considered as "started"

element Element

The element being affected

Source:

ExtensionNameFilter(name) → {boolean}

Parameters:
Name Type Description
name string
Source:
Returns:
Type
boolean

ExtensionStatus

Type:
Source:
Tutorials:

ExtensionVarBuilder(name) → {module:svgcanvas.SvgCanvas#event:ext_addLangData}

Parameters:
Name Type Description
name string

The name of the extension

Source:
Returns:
Type
module:svgcanvas.SvgCanvas#event:ext_addLangData

ImageEmbeddedCallback(result) → {void}

Function to run when image data is found

Parameters:
Name Type Description
result string | false

Data URL

Source:
Returns:
Type
void

ImageExportedResults

Type:
Properties:
Name Type Description
datauri string

Contents as a Data URL

bloburl string

May be the empty string

svg string

The SVG contents as a string

issues Array.<string>

The localization messages of issueCodes

issueCodes Array.<module:svgcanvas.IssueCode>

CanVG issues found with the SVG

type "PNG" | "JPEG" | "BMP" | "WEBP" | "ICO"

The chosen image type

mimeType "image/png" | "image/jpeg" | "image/bmp" | "image/webp"

The image MIME type

quality Float

A decimal between 0 and 1 (for use with JPEG or WEBP)

exportWindowName string

A convenience for passing along a window.name to target a window on which the export could be added

Source:

IssueCode

Type:
  • "feGaussianBlur" | "foreignObject" | "[stroke-dasharray]" | "text"
Source:

IssuesAndCodes

Type:
Properties:
Name Type Description
issueCodes Array.<string>

The locale-independent code names

issues Array.<string>

The localized descriptions

Source:

Message

Type:
Properties:
Name Type Description
data any

The data

origin string

The origin

Source:

PaintOptions

Type:
Properties:
Name Type Description
type "solidColor"
Source:

PDFExportedResults

Type:
Properties:
Name Type Description
svg string

The SVG PDF output

output string | ArrayBuffer | Blob | window

The output based on the outputType; if undefined, "datauristring", "dataurlstring", "datauri", or "dataurl", will be a string (undefined gives a document, while the others build as Data URLs; "datauri" and "dataurl" change the location of the current page); if "arraybuffer", will return ArrayBuffer; if "blob", returns a Blob; if "dataurlnewwindow", will change the current page's location and return a string if in Safari and no window object is found; otherwise opens in, and returns, a new window object; if "save", will have the same return as "dataurlnewwindow" if navigator.getUserMedia support is found without URL.createObjectURL support; otherwise returns undefined but attempts to save

outputType external:jsPDF.OutputType
issues Array.<string>

The human-readable localization messages of corresponding issueCodes

issueCodes Array.<module:svgcanvas.IssueCode>
exportWindowName string
Source:

SaveOptions

Type:
Properties:
Name Type Attributes Description
apply boolean
image "embed" <optional>
round_digits Integer
Source:

StyleOptions

Type:
Properties:
Name Type Description
fill string
fill_opacity Float
stroke string
stroke_width Float
stroke_dasharray string
stroke_linejoin string
stroke_linecap string
stroke_opacity Float
opacity Float
Source:

SVGAsJSON

Type:
Properties:
Name Type Description
element string
attr PlainObject.<string, string>
children Array.<module:svgcanvas.SVGAsJSON>
Source:

ZoomAndBBox

Type:
Properties:
Name Type Description
zoom Float
bbox module:utilities.BBoxObject
Source:

DimensionsAndZoom

Type:
Properties:
Name Type Description
w Float

Width

h Float

Height

zoom Float

Zoom

Source:

ElementAndBBox

Type:
Properties:
Name Type Description
elem Element

The element

bbox module:utilities.BBoxObject

The element's BBox as retrieved from getStrokedBBoxDefaultVisible

Source: