diff --git a/dist/extensions/ext-connector.js b/dist/extensions/ext-connector.js
index bfec9742..56c085a2 100644
--- a/dist/extensions/ext-connector.js
+++ b/dist/extensions/ext-connector.js
@@ -17,7 +17,6 @@
var svgroot = S.svgroot,
getNextId = S.getNextId,
getElem = S.getElem,
- curConfig = S.curConfig,
addElem = S.addSvgElementFromJson,
selManager = S.selectorManager,
connSel = '.se_connector',
@@ -60,7 +59,7 @@
if (slope < bb.height / bb.width) {
ratio = bb.width / 2 / Math.abs(lenX);
} else {
- ratio = bb.height / 2 / Math.abs(lenY);
+ ratio = lenY ? bb.height / 2 / Math.abs(lenY) : 0;
}
return {
@@ -340,6 +339,9 @@
startX = opts.start_x;
startY = opts.start_y;
var mode = svgCanvas.getMode();
+ var _svgEditor = svgEditor,
+ initStroke = _svgEditor.curConfig.initStroke;
+
if (mode === 'connector') {
if (started) {
@@ -368,10 +370,10 @@
attr: {
id: getNextId(),
points: x + ',' + y + ' ' + x + ',' + y + ' ' + startX + ',' + startY,
- stroke: '#' + curConfig.initStroke.color,
- 'stroke-width': !startElem.stroke_width || startElem.stroke_width === 0 ? curConfig.initStroke.width : startElem.stroke_width,
+ stroke: '#' + initStroke.color,
+ 'stroke-width': !startElem.stroke_width || startElem.stroke_width === 0 ? initStroke.width : startElem.stroke_width,
fill: 'none',
- opacity: curConfig.initStroke.opacity,
+ opacity: initStroke.opacity,
style: 'pointer-events:none'
}
});
diff --git a/dist/extensions/ext-foreignobject.js b/dist/extensions/ext-foreignobject.js
index 77f12a8a..d8e65921 100644
--- a/dist/extensions/ext-foreignobject.js
+++ b/dist/extensions/ext-foreignobject.js
@@ -48,15 +48,12 @@
newFO = void 0,
editingforeign = false;
- // Function: setForeignString(xmlString, elt)
- // This function sets the content of element elt to the input XML.
- //
- // Parameters:
- // xmlString - The XML text.
- // elt - the parent element to append to
- //
- // Returns:
- // This function returns false if the set was unsuccessful, true otherwise.
+ /**
+ * This function sets the content of element elt to the input XML.
+ * @param {String} xmlString - The XML text.
+ * @param elt - the parent element to append to
+ * @returns {Boolean} This function returns false if the set was unsuccessful, true otherwise.
+ */
function setForeignString(xmlString) {
var elt = selElems[0];
try {
diff --git a/dist/extensions/ext-markers.js b/dist/extensions/ext-markers.js
index 44c0ab8f..a7439111 100644
--- a/dist/extensions/ext-markers.js
+++ b/dist/extensions/ext-markers.js
@@ -73,9 +73,11 @@
markerTypes[v + '_o'] = markerTypes[v];
});
- // elem = a graphic element will have an attribute like marker-start
- // attr - marker-start, marker-mid, or marker-end
- // returns the marker element that is linked to the graphic element
+ /**
+ * @param elem - A graphic element will have an attribute like marker-start
+ * @param attr - marker-start, marker-mid, or marker-end
+ * @returns The marker element that is linked to the graphic element
+ */
function getLinked(elem, attr) {
var str = elem.getAttribute(attr);
if (!str) {
diff --git a/dist/extensions/ext-mathjax.js b/dist/extensions/ext-mathjax.js
index a45c15bc..9bfcb80d 100644
--- a/dist/extensions/ext-mathjax.js
+++ b/dist/extensions/ext-mathjax.js
@@ -158,7 +158,7 @@
s.src = curConfig.extPath + mathjaxSrcSecure;
// See `executeAfterLoads` in `svgutils.js`
*/
- $.getScript(mathjaxSrcSecure).done(function (script, textStatus) {
+ $.getScript(svgEditor.curConfig.extIconsPath + mathjaxSrcSecure).done(function (script, textStatus) {
// When MathJax is loaded get the div where the math will be rendered.
MathJax.Hub.queue.Push(function () {
math = MathJax.Hub.getAllJax('#mathjax_creator')[0];
diff --git a/dist/extensions/ext-shapes.js b/dist/extensions/ext-shapes.js
index 92512abe..b8579c99 100644
--- a/dist/extensions/ext-shapes.js
+++ b/dist/extensions/ext-shapes.js
@@ -124,7 +124,7 @@
if (!lib) {
$('#shape_buttons').html('Loading...');
- $.getJSON(svgEditor.curConfig.extPath + 'shapelib/' + catId + '.json', function (result) {
+ $.getJSON(svgEditor.curConfig.extIconsPath + 'shapelib/' + catId + '.json', function (result) {
curLib = library[catId] = {
data: result.data,
size: result.size,
diff --git a/dist/index-es.js b/dist/index-es.js
index e85a8ab7..9c967dfd 100644
--- a/dist/index-es.js
+++ b/dist/index-es.js
@@ -2911,11 +2911,10 @@ var removeElementFromListMap = function removeElementFromListMap(elem) {
}
};
-// Function: getTransformList
-// Returns an object that behaves like a SVGTransformList for the given DOM element
-//
-// Parameters:
-// elem - DOM element to get a transformlist from
+/**
+* Returns an object that behaves like a SVGTransformList for the given DOM element
+* @param elem - DOM element to get a transformlist from
+*/
var getTransformList = function getTransformList(elem) {
if (!supportsNativeTransformLists()) {
var id = elem.id || 'temp';
@@ -3017,7 +3016,9 @@ var init = function init(elementContainer) {
};
};
-// Group: Unit conversion functions
+/**
+* Group: Unit conversion functions
+*/
/**
* @returns The unit object with values for each unit
@@ -3185,7 +3186,9 @@ var isValidUnit = function isValidUnit(attr, val, selectedElement) {
* Copyright(c) 2010 Jeff Schiller
*/
-// Group: Undo/Redo history management
+/**
+* Group: Undo/Redo history management
+*/
var HistoryEventTypes = {
BEFORE_APPLY: 'before_apply',
AFTER_APPLY: 'after_apply',
@@ -3251,7 +3254,7 @@ var MoveElementCommand = function () {
/**
* Re-positions the element
- * @param {handleHistoryEvent: function}
+ * @param {{handleHistoryEvent: function}} handler
*/
}, {
@@ -3271,7 +3274,7 @@ var MoveElementCommand = function () {
/**
* Positions the element back to its original location
- * @param {handleHistoryEvent: function}
+ * @param {{handleHistoryEvent: function}} handler
*/
}, {
@@ -3288,7 +3291,9 @@ var MoveElementCommand = function () {
}
}
- // Returns array with element associated with this command
+ /**
+ * @returns {Array} Array with element associated with this command
+ */
}, {
key: 'elements',
@@ -3300,12 +3305,13 @@ var MoveElementCommand = function () {
}();
MoveElementCommand.type = MoveElementCommand.prototype.type;
-// implements svgedit.history.HistoryCommand
-// History command for an element that was added to the DOM
-//
-// Parameters:
-// elem - The newly added DOM element
-// text - An optional string visible to user related to this change
+/**
+* @implements svgedit.history.HistoryCommand
+* History command for an element that was added to the DOM
+*
+* @param elem - The newly added DOM element
+* @param text - An optional string visible to user related to this change
+*/
var InsertElementCommand = function () {
function InsertElementCommand(elem, text) {
classCallCheck(this, InsertElementCommand);
@@ -3360,7 +3366,9 @@ var InsertElementCommand = function () {
}
}
- // Returns array with element associated with this command
+ /**
+ * @returns {Array} Array with element associated with this command
+ */
}, {
key: 'elements',
@@ -3372,14 +3380,14 @@ var InsertElementCommand = function () {
}();
InsertElementCommand.type = InsertElementCommand.prototype.type;
-// implements svgedit.history.HistoryCommand
-// History command for an element removed from the DOM
-//
-// Parameters:
-// elem - The removed DOM element
-// oldNextSibling - the DOM element's nextSibling when it was in the DOM
-// oldParent - The DOM element's parent
-// text - An optional string visible to user related to this change
+/**
+* @implements svgedit.history.HistoryCommand
+* History command for an element removed from the DOM
+* @param elem - The removed DOM element
+* @param oldNextSibling - The DOM element's nextSibling when it was in the DOM
+* @param oldParent - The DOM element's parent
+* @param {String} [text] - An optional string visible to user related to this change
+*/
var RemoveElementCommand = function () {
function RemoveElementCommand(elem, oldNextSibling, oldParent, text) {
classCallCheck(this, RemoveElementCommand);
@@ -3444,8 +3452,9 @@ var RemoveElementCommand = function () {
}
}
- // Function: RemoveElementCommand.elements
- // Returns array with element associated with this command
+ /**
+ * @returns {Array} Array with element associated with this command
+ */
}, {
key: 'elements',
@@ -3457,14 +3466,14 @@ var RemoveElementCommand = function () {
}();
RemoveElementCommand.type = RemoveElementCommand.prototype.type;
-// implements svgedit.history.HistoryCommand
-// History command to make a change to an element.
-// Usually an attribute change, but can also be textcontent.
-//
-// Parameters:
-// elem - The DOM element that was changed
-// attrs - An object with the attributes to be changed and the values they had *before* the change
-// text - An optional string visible to user related to this change
+/**
+* @implements svgedit.history.HistoryCommand
+* History command to make a change to an element.
+* Usually an attribute change, but can also be textcontent.
+* @param elem - The DOM element that was changed
+* @param attrs - An object with the attributes to be changed and the values they had *before* the change
+* @param {String} text - An optional string visible to user related to this change
+*/
var ChangeElementCommand = function () {
function ChangeElementCommand(elem, attrs, text) {
classCallCheck(this, ChangeElementCommand);
@@ -3603,7 +3612,9 @@ var ChangeElementCommand = function () {
return true;
}
- // Returns array with element associated with this command
+ /**
+ * @returns {Array} Array with element associated with this command
+ */
}, {
key: 'elements',
@@ -3619,11 +3630,11 @@ ChangeElementCommand.type = ChangeElementCommand.prototype.type;
// if a new Typing command is created and the top command on the stack is also a Typing
// and they both affect the same element, then collapse the two commands into one
-// implements svgedit.history.HistoryCommand
-// History command that can contain/execute multiple other commands
-//
-// Parameters:
-// text - An optional string visible to user related to this change
+/**
+* @implements svgedit.history.HistoryCommand
+* History command that can contain/execute multiple other commands
+* @param {String} [text] - An optional string visible to user related to this change
+*/
var BatchCommand = function () {
function BatchCommand(text) {
classCallCheck(this, BatchCommand);
@@ -3699,10 +3710,10 @@ var BatchCommand = function () {
return elems;
}
- // Adds a given command to the history stack
- //
- // Parameters:
- // cmd - The undo command object to add
+ /**
+ * Adds a given command to the history stack
+ * @param cmd - The undo command object to add
+ */
}, {
key: 'addSubCommand',
@@ -3710,7 +3721,9 @@ var BatchCommand = function () {
this.stack.push(cmd);
}
- // Returns a boolean indicating whether or not the batch command is empty
+ /**
+ * @returns {Boolean} Indicates whether or not the batch command is empty
+ */
}, {
key: 'isEmpty',
@@ -3722,9 +3735,10 @@ var BatchCommand = function () {
}();
BatchCommand.type = BatchCommand.prototype.type;
-// Parameters:
-// historyEventHandler - an object that conforms to the HistoryEventHandler interface
-// (see above)
+/**
+* @param historyEventHandler - an object that conforms to the HistoryEventHandler interface
+* (see above)
+*/
var UndoManager = function () {
function UndoManager(historyEventHandler) {
classCallCheck(this, UndoManager);
@@ -3749,8 +3763,9 @@ var UndoManager = function () {
this.undoStackPointer = 0;
}
- // Returns:
- // Integer with the current size of the undo history stack
+ /**
+ * @returns {Number} Integer with the current size of the undo history stack
+ */
}, {
key: 'getUndoStackSize',
@@ -3758,8 +3773,9 @@ var UndoManager = function () {
return this.undoStackPointer;
}
- // Returns:
- // Integer with the current size of the redo history stack
+ /**
+ * @returns {Number} Integer with the current size of the redo history stack
+ */
}, {
key: 'getRedoStackSize',
@@ -3767,8 +3783,9 @@ var UndoManager = function () {
return this.undoStack.length - this.undoStackPointer;
}
- // Returns:
- // String associated with the next undo command
+ /**
+ * @returns {String} String associated with the next undo command
+ */
}, {
key: 'getNextUndoCommandText',
@@ -3776,8 +3793,9 @@ var UndoManager = function () {
return this.undoStackPointer > 0 ? this.undoStack[this.undoStackPointer - 1].getText() : '';
}
- // Returns:
- // String associated with the next redo command
+ /**
+ * @returns {String} String associated with the next redo command
+ */
}, {
key: 'getNextRedoCommandText',
@@ -3829,15 +3847,15 @@ var UndoManager = function () {
this.undoStackPointer = this.undoStack.length;
}
- // This function tells the canvas to remember the old values of the
- // attrName attribute for each element sent in. The elements and values
- // are stored on a stack, so the next call to finishUndoableChange() will
- // pop the elements and old values off the stack, gets the current values
- // from the DOM and uses all of these to construct the undo-able command.
- //
- // Parameters:
- // attrName - The name of the attribute being changed
- // elems - Array of DOM elements being changed
+ /**
+ * This function tells the canvas to remember the old values of the
+ * attrName attribute for each element sent in. The elements and values
+ * are stored on a stack, so the next call to finishUndoableChange() will
+ * pop the elements and old values off the stack, gets the current values
+ * from the DOM and uses all of these to construct the undo-able command.
+ * @param attrName - The name of the attribute being changed
+ * @param elems - Array of DOM elements being changed
+ */
}, {
key: 'beginUndoableChange',
@@ -3861,12 +3879,12 @@ var UndoManager = function () {
};
}
- // This function returns a BatchCommand object which summarizes the
- // change since beginUndoableChange was called. The command can then
- // be added to the command history
- //
- // Returns:
- // Batch command object with resulting changes
+ /**
+ * This function returns a BatchCommand object which summarizes the
+ * change since beginUndoableChange was called. The command can then
+ * be added to the command history
+ * @returns Batch command object with resulting changes
+ */
}, {
key: 'finishUndoableChange',
@@ -4477,16 +4495,13 @@ var getSegSelector = function getSegSelector(seg, update) {
return segLine;
};
-// Function: smoothControlPoints
-// Takes three points and creates a smoother line based on them
-//
-// Parameters:
-// ct1 - Object with x and y values (first control point)
-// ct2 - Object with x and y values (second control point)
-// pt - Object with x and y values (third point)
-//
-// Returns:
-// Array of two "smoothed" point objects
+/**
+* Takes three points and creates a smoother line based on them
+* @param ct1 - Object with x and y values (first control point)
+* @param ct2 - Object with x and y values (second control point)
+* @param pt - Object with x and y values (third point)
+* @returns Array of two "smoothed" point objects
+*/
var smoothControlPoints = function smoothControlPoints(ct1, ct2, pt) {
// each point must not be the origin
var x1 = ct1.x - pt.x,
@@ -5484,8 +5499,10 @@ function pathDSegment(letter, points, morePoints, lastPoint) {
return segment;
}
-// Group: Path edit functions
-// Functions relating to editing path elements
+/**
+* Group: Path edit functions
+* Functions relating to editing path elements
+*/
var pathActions = function () {
var subpath = false;
var newPoint = void 0,
@@ -6435,15 +6452,12 @@ var init$2 = function init$$1(editorContext) {
svgroot_ = editorContext.getSVGRoot();
};
-// Converts characters in a string to XML-friendly entities.
-//
-// Example: '&' becomes '&'
-//
-// Parameters:
-// str - The string to be converted
-//
-// Returns:
-// The converted string
+/**
+* Converts characters in a string to XML-friendly entities.
+* @example: '&' becomes '&'
+* @param str - The string to be converted
+* @returns {String} The converted string
+*/
var toXml = function toXml(str) {
// ' is ok in XML, but not HTML
// > does not normally need escaping, though it can if within a CDATA expression (and preceded by "]]")
@@ -6610,13 +6624,11 @@ var text2xml = function text2xml(sXML) {
return out;
};
-// Converts a SVGRect into an object.
-//
-// Parameters:
-// bbox - a SVGRect
-//
-// Returns:
-// An object with properties names x, y, width, height.
+/**
+* Converts a SVGRect into an object.
+* @param bbox - a SVGRect
+* @returns An object with properties names x, y, width, height.
+*/
var bboxToObj = function bboxToObj(bbox) {
return {
x: bbox.x,
@@ -6626,11 +6638,11 @@ var bboxToObj = function bboxToObj(bbox) {
};
};
-// Walks the tree and executes the callback on each element in a top-down fashion
-//
-// Parameters:
-// elem - DOM element to traverse
-// cbFn - Callback function to run on each element
+/**
+* Walks the tree and executes the callback on each element in a top-down fashion
+* @param elem - DOM element to traverse
+* @param {Function} cbFn - Callback function to run on each element
+*/
var walkTree = function walkTree(elem, cbFn) {
if (elem && elem.nodeType === 1) {
cbFn(elem);
@@ -6641,12 +6653,12 @@ var walkTree = function walkTree(elem, cbFn) {
}
};
-// Walks the tree and executes the callback on each element in a depth-first fashion
-// TODO: FIXME: Shouldn't this be calling walkTreePost?
-//
-// Parameters:
-// elem - DOM element to traverse
-// cbFn - Callback function to run on each element
+/**
+* Walks the tree and executes the callback on each element in a depth-first fashion
+* @todo FIXME: Shouldn't this be calling walkTreePost?
+* @param elem - DOM element to traverse
+* @param {Function} cbFn - Callback function to run on each element
+*/
var walkTreePost = function walkTreePost(elem, cbFn) {
if (elem && elem.nodeType === 1) {
var i = elem.childNodes.length;
@@ -6657,17 +6669,15 @@ var walkTreePost = function walkTreePost(elem, cbFn) {
}
};
-// Extracts the URL from the url(...) syntax of some attributes.
-// Three variants:
-// *
-// *
-// *
-//
-// Parameters:
-// attrVal - The attribute value as a string
-//
-// Returns:
-// String with just the URL, like someFile.svg#foo
+/**
+* Extracts the URL from the url(...) syntax of some attributes.
+* Three variants:
+* -
+* -
+* -
+* @param attrVal - The attribute value as a string
+* @returns {String} String with just the URL, like "someFile.svg#foo"
+*/
var getUrlFromAttr = function getUrlFromAttr(attrVal) {
if (attrVal) {
// url("#somegrad")
@@ -6685,18 +6695,25 @@ var getUrlFromAttr = function getUrlFromAttr(attrVal) {
return null;
};
-// Returns the given element's xlink:href value
+/**
+* @returns The given element's xlink:href value
+*/
var getHref = function getHref(elem) {
return elem.getAttributeNS(NS.XLINK, 'href');
};
-// Sets the given element's xlink:href value
+/**
+* Sets the given element's xlink:href value
+* @param elem
+* @param {String} val
+*/
var setHref = function setHref(elem, val) {
elem.setAttributeNS(NS.XLINK, 'xlink:href', val);
};
-// Returns:
-// The document's element, create it first if necessary
+/**
+* @returns The document's <defs> element, create it first if necessary
+*/
var findDefs = function findDefs() {
var svgElement = editorContext_$1.getSVGContent();
var defs = svgElement.getElementsByTagNameNS(NS.SVG, 'defs');
@@ -6716,15 +6733,13 @@ var findDefs = function findDefs() {
// TODO(codedread): Consider moving the next to functions to bbox.js
-// Get correct BBox for a path in Webkit
-// Converted from code found here:
-// http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html
-//
-// Parameters:
-// path - The path DOM element to get the BBox for
-//
-// Returns:
-// A BBox-like object
+/**
+* Get correct BBox for a path in Webkit
+* Converted from code found here:
+* http://blog.hackers-cafe.net/2009/06/how-to-calculate-bezier-curves-bounding.html
+* @param path - The path DOM element to get the BBox for
+* @returns A BBox-like object
+*/
var getPathBBox = function getPathBBox(path$$1) {
var seglist = path$$1.pathSegList;
var tot = seglist.numberOfItems;
@@ -6808,13 +6823,14 @@ var getPathBBox = function getPathBBox(path$$1) {
};
};
-// Get the given/selected element's bounding box object, checking for
-// horizontal/vertical lines (see issue 717)
-// Note that performance is currently terrible, so some way to improve would
-// be great.
-//
-// Parameters:
-// selected - Container or