- Breaking change: Avoid adding `assignAttributes`, `addSVGElementFromJson`,

`call`, `copyElem`, `findDefs`, `getElem`, `getId`, `getIntersectionList`,
  `getMouseTarget`, `getNextId`, `getUrlFromAttr`, `hasMatrixTransform`,
  `matrixMultiply`, `recalculateAllSelectedDimensions`,
  `recalculateDimensions`, `remapElement`, `removeUnusedDefElems`, `round`,
  `runExtensions`, `sanitizeSvg`, `setGradient` `transformListToTransform`
  (and mistaken `toString` export) to `getPrivateMethods` (passed to
  extensions) as available as public ones
- Build: Update ext-xdomain-messaging
- Fix (extension): ForeignObject editor
- Docs: Avoid reporting deliberate "Any" type
- Docs: Further docs (`logMatrix`, `getPrivateMethods`)
- Docs: Suggest `npm pack`
master
Brett Zamir 2018-07-19 14:58:30 -07:00
parent 233ca8c6eb
commit 0a25236477
24 changed files with 225 additions and 185 deletions

View File

@ -47,6 +47,14 @@
(have them import)
- Breaking change: Have `readLang` return lang and data but do not call
`setLang`
- Breaking change: Avoid adding `assignAttributes`, `addSVGElementFromJson`,
`call`, `copyElem`, `findDefs`, `getElem`, `getId`, `getIntersectionList`,
`getMouseTarget`, `getNextId`, `getUrlFromAttr`, `hasMatrixTransform`,
`matrixMultiply`, `recalculateAllSelectedDimensions`,
`recalculateDimensions`, `remapElement`, `removeUnusedDefElems`, `round`,
`runExtensions`, `sanitizeSvg`, `setGradient` `transformListToTransform`
(and mistaken `toString` export) to `getPrivateMethods` (passed to
extensions) as available as public ones
- npm: Add `prepublishOnly` script to ensure building/testing before publish
- npm: Update devDeps including Rollup, Sinon
- Fix: Remove redundant (and incorrect) length set. (#256 ; fixes #255)
@ -70,7 +78,8 @@
- Fix: Alert if no `exportWindow` for PDF (e.g., if blocked)
- Fix: Ensure call to `rasterExport` without `imgType` properly sets MIME
type to PNG
- Fix: Wrong name for moinsave
- Fix (extension): Wrong name for moinsave
- Fix (extension): ForeignObject editor
- Fix (Embedded API): Cross-domain may fail to even access `origin` or
`contentDocument`
- Fix (Embedded API): Avoid adding URL to iframe src if there are no arguments

View File

@ -51,7 +51,7 @@ var svgEditorExtension_arrows = (function () {
colorChanged = function colorChanged(elem) {
var color = elem.getAttribute('stroke');
var mtypes = ['start', 'mid', 'end'];
var defs = S.findDefs();
var defs = svgCanvas.findDefs();
$.each(mtypes, function (i, type) {
var marker = getLinked(elem, 'marker-' + type);
@ -134,7 +134,7 @@ var svgEditorExtension_arrows = (function () {
addMarker(dir, type);
svgCanvas.changeSelectedAttribute('marker-' + type, 'url(#' + pathdata[dir].id + ')');
S.call('changed', selElems);
svgCanvas.call('changed', selElems);
};
addMarker = function addMarker(dir, type, id) {
@ -147,7 +147,7 @@ var svgEditorExtension_arrows = (function () {
data.refx = 5;
}
var marker = S.getElem(id);
var marker = svgCanvas.getElem(id);
if (!marker) {
marker = addElem({
element: 'marker',
@ -170,7 +170,7 @@ var svgEditorExtension_arrows = (function () {
}
});
marker.append(arrow);
S.findDefs().append(marker);
svgCanvas.findDefs().append(marker);
}
marker.setAttribute('refX', data.refx);
@ -223,7 +223,7 @@ var svgEditorExtension_arrows = (function () {
if (!m || m.length !== 2) {
return null;
}
return S.getElem(m[1]);
return svgCanvas.getElem(m[1]);
};
unsetArrowNonce = function unsetArrowNonce(window) {
@ -249,7 +249,7 @@ var svgEditorExtension_arrows = (function () {
svgCanvas = svgEditor.canvas;
$ = jQuery;
// {svgcontent} = S,
addElem = S.addSVGElementFromJson, nonce = S.nonce, prefix = 'se_arrow_';
addElem = svgCanvas.addSVGElementFromJson, nonce = S.nonce, prefix = 'se_arrow_';
selElems = void 0, arrowprefix = void 0, randomizeIds = S.randomize_ids;

View File

@ -44,7 +44,7 @@ var svgEditorExtension_connector = (function () {
name: 'connector',
init: function () {
var _ref = asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(S) {
var $, svgEditor, svgCanvas, svgroot, getNextId, getElem, importLocale, addElem, selManager, connSel, elData, strings, startX, startY, curLine, startElem, endElem, seNs, svgcontent, started, connections, selElems, getBBintersect, getOffset, showPanel, setPoint, updateLine, findConnectors, updateConnectors, init, buttons;
var $, svgEditor, svgCanvas, getElem, svgroot, importLocale, addElem, selManager, connSel, elData, strings, startX, startY, curLine, startElem, endElem, seNs, svgcontent, started, connections, selElems, getBBintersect, getOffset, showPanel, setPoint, updateLine, findConnectors, updateConnectors, init, buttons;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
@ -288,11 +288,12 @@ var svgEditorExtension_connector = (function () {
$ = jQuery;
svgEditor = this;
svgCanvas = svgEditor.canvas;
svgroot = S.svgroot, getNextId = S.getNextId, getElem = S.getElem, importLocale = S.importLocale, addElem = S.addSVGElementFromJson, selManager = S.selectorManager, connSel = '.se_connector', elData = $.data;
_context2.next = 14;
getElem = svgCanvas.getElem;
svgroot = S.svgroot, importLocale = S.importLocale, addElem = svgCanvas.addSVGElementFromJson, selManager = S.selectorManager, connSel = '.se_connector', elData = $.data;
_context2.next = 15;
return importLocale();
case 14:
case 15:
strings = _context2.sent;
startX = void 0, startY = void 0, curLine = void 0, startElem = void 0, endElem = void 0, seNs = void 0, svgcontent = S.svgcontent, started = false, connections = [], selElems = [];
@ -415,7 +416,7 @@ var svgEditorExtension_connector = (function () {
curLine = addElem({
element: 'polyline',
attr: {
id: getNextId(),
id: svgCanvas.getNextId(),
points: x + ',' + y + ' ' + x + ',' + y + ' ' + startX + ',' + startY,
stroke: '#' + initStroke.color,
'stroke-width': !startElem.stroke_width || startElem.stroke_width === 0 ? initStroke.width : startElem.stroke_width,
@ -660,7 +661,7 @@ var svgEditorExtension_connector = (function () {
}
});
case 19:
case 20:
case 'end':
return _context2.stop();
}

View File

@ -51,7 +51,7 @@ var svgEditorExtension_foreignobject = (function () {
case 0:
setAttr = function setAttr(attr, val) {
svgCanvas.changeSelectedAttribute(attr, val);
S.call('changed', selElems);
svgCanvas.call('changed', selElems);
};
showForeignEditor = function showForeignEditor() {
@ -63,7 +63,7 @@ var svgEditorExtension_foreignobject = (function () {
toggleSourceButtons(true);
elt.removeAttribute('fill');
var str = S.svgToString(elt, 0);
var str = svgCanvas.svgToString(elt, 0);
$('#svg_source_textarea').val(str);
$('#svg_source_editor').fadeIn();
properlySourceSizeTextArea();
@ -76,9 +76,9 @@ var svgEditorExtension_foreignobject = (function () {
// convert string into XML document
var newDoc = text2xml('<svg xmlns="' + NS.SVG + '" xmlns:xlink="' + NS.XLINK + '">' + xmlString + '</svg>');
// run it through our sanitizer to remove anything we do not support
S.sanitizeSvg(newDoc.documentElement);
svgCanvas.sanitizeSvg(newDoc.documentElement);
elt.replaceWith(svgdoc.importNode(newDoc.documentElement.firstChild, true));
S.call('changed', [elt]);
svgCanvas.call('changed', [elt]);
svgCanvas.clearSelection();
} catch (e) {
console.log(e);
@ -227,12 +227,12 @@ var svgEditorExtension_foreignobject = (function () {
if (svgCanvas.getMode() === 'foreign') {
started = true;
newFO = S.addSVGElementFromJson({
newFO = svgCanvas.addSVGElementFromJson({
element: 'foreignObject',
attr: {
x: opts.start_x,
y: opts.start_y,
id: S.getNextId(),
id: svgCanvas.getNextId(),
'font-size': 16, // cur_text.font_size,
width: '48',
height: '20',

View File

@ -180,7 +180,7 @@ var svgEditorExtension_markers = (function () {
if (el.tagName === 'line' && pos === 'mid') {
el = convertline(el);
}
S.call('changed', selElems);
svgCanvas.call('changed', selElems);
}
}
});
@ -228,7 +228,7 @@ var svgEditorExtension_markers = (function () {
}
if (val === '\\nomarker') {
setIcon(pos, val);
S.call('changed', selElems);
svgCanvas.call('changed', selElems);
return;
}
// Set marker on element
@ -238,7 +238,7 @@ var svgEditorExtension_markers = (function () {
if (el.tagName === 'line' && pos === 'mid') {
el = convertline(el);
}
S.call('changed', selElems);
svgCanvas.call('changed', selElems);
setIcon(pos, val);
};
@ -295,7 +295,7 @@ var svgEditorExtension_markers = (function () {
var txtBoxBorder = 'none';
var txtBoxStrokeWidth = 0;
var marker = S.getElem(id);
var marker = svgCanvas.getElem(id);
if (marker) {
return;
}
@ -389,7 +389,7 @@ var svgEditorExtension_markers = (function () {
marker.setAttribute('markerHeight', markerHeight);
marker.setAttribute('refX', refX);
marker.setAttribute('refY', refY);
S.findDefs().append(marker);
svgCanvas.findDefs().append(marker);
return marker;
};
@ -446,7 +446,7 @@ var svgEditorExtension_markers = (function () {
if (!m || m.length !== 2) {
return null;
}
return S.getElem(m[1]);
return svgCanvas.getElem(m[1]);
};
_context2.next = 15;
@ -457,7 +457,7 @@ var svgEditorExtension_markers = (function () {
svgEditor = this;
$ = jQuery;
svgCanvas = svgEditor.canvas;
addElem = S.addSVGElementFromJson;
addElem = svgCanvas.addSVGElementFromJson;
mtypes = ['start', 'mid', 'end'];
markerPrefix = 'se_marker_';
idPrefix = 'mkr_';

View File

@ -57,7 +57,7 @@ var svgEditorExtension_polygon = (function () {
setAttr = function setAttr(attr, val) {
svgCanvas.changeSelectedAttribute(attr, val);
S.call('changed', selElems);
svgCanvas.call('changed', selElems);
};
showPanel = function showPanel(on) {
@ -133,11 +133,11 @@ var svgEditorExtension_polygon = (function () {
while (children.length > 0) {
mrow.append(svgdoc.adoptNode(children[0], true));
}
S.sanitizeSvg(math);
S.call('changed', [elt]);
svgCanvas.sanitizeSvg(math);
svgCanvas.call('changed', [elt]);
});
elt.firstChild.replaceWith(math);
S.call('changed', [elt]);
svgCanvas.call('changed', [elt]);
svgCanvas.clearSelection();
} catch(e) {
console.log(e);
@ -208,12 +208,12 @@ var svgEditorExtension_polygon = (function () {
if (svgCanvas.getMode() === 'polygon') {
started = true;
newFO = S.addSVGElementFromJson({
newFO = svgCanvas.addSVGElementFromJson({
element: 'polygon',
attr: {
cx: opts.start_x,
cy: opts.start_y,
id: S.getNextId(),
id: svgCanvas.getNextId(),
shape: 'regularPoly',
sides: document.getElementById('polySides').value,
orient: 'x',

View File

@ -49,7 +49,7 @@ var svgEditorExtension_star = (function () {
case 0:
setAttr = function setAttr(attr, val) {
svgCanvas.changeSelectedAttribute(attr, val);
S.call('changed', selElems);
svgCanvas.call('changed', selElems);
};
showPanel = function showPanel(on) {
@ -150,12 +150,12 @@ var svgEditorExtension_star = (function () {
if (svgCanvas.getMode() === 'star') {
started = true;
newFO = S.addSVGElementFromJson({
newFO = svgCanvas.addSVGElementFromJson({
element: 'polygon',
attr: {
cx: opts.start_x,
cy: opts.start_y,
id: S.getNextId(),
id: svgCanvas.getNextId(),
shape: 'star',
point: document.getElementById('starNumPoints').value,
r: 0,

View File

@ -27,11 +27,13 @@ var svgEditorExtension_xdomain_messaging = (function () {
if (!data || (typeof data === 'undefined' ? 'undefined' : _typeof(data)) !== 'object' || data.namespace !== 'svgCanvas') {
return;
}
// The default is not to allow any origins, including even the same domain or if run on a file:// URL
// See svgedit-config-es.js for an example of how to configure
// The default is not to allow any origins, including even the same domain or
// if run on a file:// URL See svgedit-config-es.js for an example of how
// to configure
var allowedOrigins = svgEditor.curConfig.allowedOrigins;
if (!allowedOrigins.includes('*') && !allowedOrigins.includes(e.origin)) {
console.log('Origin ' + e.origin + ' not whitelisted for posting to ' + window.origin);
return;
}
var cbid = data.id;

61
dist/index-es.js vendored
View File

@ -13735,6 +13735,7 @@ function SvgCanvas(container, config) {
* 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.
* @function module:svgcanvas~ffClone
* @todo Test for this bug on load and add it to "support" object instead of
* browser sniffing
* @param {Element} elem - The (text) DOM element to clone
@ -13844,7 +13845,12 @@ function SvgCanvas(container, config) {
}
};
// Debug tool to easily see the current matrix in the browser's console
/**
* Debug tool to easily see the current matrix in the browser's console
* @function module:svgcanvas~logMatrix
* @param {SVGMatrix} m The matrix
* @returns {undefined}
*/
var logMatrix = function logMatrix(m) {
console.log([m.a, m.b, m.c, m.d, m.e, m.f]);
};
@ -17805,6 +17811,7 @@ function SvgCanvas(container, config) {
/**
* Check if exact gradient already exists
* @function module:svgcanvas~findDuplicateGradient
* @param {SVGGradientElement} grad - The gradient DOM element to compare to others
* @returns {SVGGradientElement} The existing gradient if found, `null` if not
*/
@ -19739,9 +19746,31 @@ function SvgCanvas(container, config) {
/**
* @interface module:svgcanvas.PrivateMethods
* @type {object}
* @todo If keeping, should document this interface
* @see The source
* @type {PlainObject}
* @property {module:svgcanvas~addCommandToHistory} addCommandToHistory
* @property {module:history.HistoryCommand} BatchCommand
* @property {module:history.HistoryCommand} ChangeElementCommand
* @property {module:utilities.decode64} decode64
* @property {module:utilities.encode64} encode64
* @property {module:svgcanvas~ffClone} ffClone
* @property {module:svgcanvas~findDuplicateGradient} findDuplicateGradient
* @property {module:utilities.getPathBBox} getPathBBox
* @property {module:units.getTypeMap} getTypeMap
* @property {module:draw.identifyLayers} identifyLayers
* @property {module:history.HistoryCommand} InsertElementCommand
* @property {module:browser.isChrome} isChrome
* @property {module:math.isIdentity} isIdentity
* @property {module:browser.isIE} isIE
* @property {module:svgcanvas~logMatrix} logMatrix
* @property {module:history.HistoryCommand} MoveElementCommand
* @property {module:namespaces.NS} NS
* @property {module:utilities.preventClickDefault} preventClickDefault
* @property {module:history.HistoryCommand} RemoveElementCommand
* @property {module:SVGTransformList.SVGEditTransformList} SVGEditTransformList
* @property {module:utilities.text2xml} text2xml
* @property {module:math.transformBox} transformBox
* @property {module:math.transformPoint} transformPoint
* @property {module:utilities.walkTree} walkTree
*/
/**
* @deprecated getPrivateMethods
@ -19754,58 +19783,34 @@ function SvgCanvas(container, config) {
* access to them to plugins.
* @function module:svgcanvas.SvgCanvas#getPrivateMethods
* @returns {module:svgcanvas.PrivateMethods}
* @see Source for the methods
*/
this.getPrivateMethods = function () {
var obj = {
addCommandToHistory: addCommandToHistory,
setGradient: setGradient,
addSVGElementFromJson: addSVGElementFromJson,
assignAttributes: assignAttributes,
BatchCommand: BatchCommand$1,
call: call,
ChangeElementCommand: ChangeElementCommand$1,
copyElem: function copyElem$$1(elem) {
return getCurrentDrawing().copyElem(elem);
},
decode64: decode64,
encode64: encode64,
ffClone: ffClone,
findDefs: findDefs,
findDuplicateGradient: findDuplicateGradient,
getElem: getElem,
getId: getId,
getIntersectionList: getIntersectionList,
getMouseTarget: getMouseTarget,
getNextId: getNextId,
getPathBBox: getPathBBox,
getTypeMap: getTypeMap,
getUrlFromAttr: getUrlFromAttr,
hasMatrixTransform: hasMatrixTransform,
identifyLayers: identifyLayers,
InsertElementCommand: InsertElementCommand$1,
isChrome: isChrome,
isIdentity: isIdentity,
isIE: isIE,
logMatrix: logMatrix,
matrixMultiply: matrixMultiply,
MoveElementCommand: MoveElementCommand$1,
NS: NS,
preventClickDefault: preventClickDefault,
recalculateAllSelectedDimensions: recalculateAllSelectedDimensions,
recalculateDimensions: recalculateDimensions,
remapElement: remapElement,
RemoveElementCommand: RemoveElementCommand$1,
removeUnusedDefElems: removeUnusedDefElems,
round: round,
runExtensions: runExtensions,
sanitizeSvg: sanitizeSvg,
SVGEditTransformList: SVGTransformList,
text2xml: text2xml,
toString: toString,
transformBox: transformBox,
transformListToTransform: transformListToTransform,
transformPoint: transformPoint,
walkTree: walkTree
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

61
dist/index-umd.js vendored
View File

@ -13741,6 +13741,7 @@
* 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.
* @function module:svgcanvas~ffClone
* @todo Test for this bug on load and add it to "support" object instead of
* browser sniffing
* @param {Element} elem - The (text) DOM element to clone
@ -13850,7 +13851,12 @@
}
};
// Debug tool to easily see the current matrix in the browser's console
/**
* Debug tool to easily see the current matrix in the browser's console
* @function module:svgcanvas~logMatrix
* @param {SVGMatrix} m The matrix
* @returns {undefined}
*/
var logMatrix = function logMatrix(m) {
console.log([m.a, m.b, m.c, m.d, m.e, m.f]);
};
@ -17811,6 +17817,7 @@
/**
* Check if exact gradient already exists
* @function module:svgcanvas~findDuplicateGradient
* @param {SVGGradientElement} grad - The gradient DOM element to compare to others
* @returns {SVGGradientElement} The existing gradient if found, `null` if not
*/
@ -19745,9 +19752,31 @@
/**
* @interface module:svgcanvas.PrivateMethods
* @type {object}
* @todo If keeping, should document this interface
* @see The source
* @type {PlainObject}
* @property {module:svgcanvas~addCommandToHistory} addCommandToHistory
* @property {module:history.HistoryCommand} BatchCommand
* @property {module:history.HistoryCommand} ChangeElementCommand
* @property {module:utilities.decode64} decode64
* @property {module:utilities.encode64} encode64
* @property {module:svgcanvas~ffClone} ffClone
* @property {module:svgcanvas~findDuplicateGradient} findDuplicateGradient
* @property {module:utilities.getPathBBox} getPathBBox
* @property {module:units.getTypeMap} getTypeMap
* @property {module:draw.identifyLayers} identifyLayers
* @property {module:history.HistoryCommand} InsertElementCommand
* @property {module:browser.isChrome} isChrome
* @property {module:math.isIdentity} isIdentity
* @property {module:browser.isIE} isIE
* @property {module:svgcanvas~logMatrix} logMatrix
* @property {module:history.HistoryCommand} MoveElementCommand
* @property {module:namespaces.NS} NS
* @property {module:utilities.preventClickDefault} preventClickDefault
* @property {module:history.HistoryCommand} RemoveElementCommand
* @property {module:SVGTransformList.SVGEditTransformList} SVGEditTransformList
* @property {module:utilities.text2xml} text2xml
* @property {module:math.transformBox} transformBox
* @property {module:math.transformPoint} transformPoint
* @property {module:utilities.walkTree} walkTree
*/
/**
* @deprecated getPrivateMethods
@ -19760,58 +19789,34 @@
* access to them to plugins.
* @function module:svgcanvas.SvgCanvas#getPrivateMethods
* @returns {module:svgcanvas.PrivateMethods}
* @see Source for the methods
*/
this.getPrivateMethods = function () {
var obj = {
addCommandToHistory: addCommandToHistory,
setGradient: setGradient,
addSVGElementFromJson: addSVGElementFromJson,
assignAttributes: assignAttributes,
BatchCommand: BatchCommand$1,
call: call,
ChangeElementCommand: ChangeElementCommand$1,
copyElem: function copyElem$$1(elem) {
return getCurrentDrawing().copyElem(elem);
},
decode64: decode64,
encode64: encode64,
ffClone: ffClone,
findDefs: findDefs,
findDuplicateGradient: findDuplicateGradient,
getElem: getElem,
getId: getId,
getIntersectionList: getIntersectionList,
getMouseTarget: getMouseTarget,
getNextId: getNextId,
getPathBBox: getPathBBox,
getTypeMap: getTypeMap,
getUrlFromAttr: getUrlFromAttr,
hasMatrixTransform: hasMatrixTransform,
identifyLayers: identifyLayers,
InsertElementCommand: InsertElementCommand$1,
isChrome: isChrome,
isIdentity: isIdentity,
isIE: isIE,
logMatrix: logMatrix,
matrixMultiply: matrixMultiply,
MoveElementCommand: MoveElementCommand$1,
NS: NS,
preventClickDefault: preventClickDefault,
recalculateAllSelectedDimensions: recalculateAllSelectedDimensions,
recalculateDimensions: recalculateDimensions,
remapElement: remapElement,
RemoveElementCommand: RemoveElementCommand$1,
removeUnusedDefElems: removeUnusedDefElems,
round: round,
runExtensions: runExtensions,
sanitizeSvg: sanitizeSvg,
SVGEditTransformList: SVGTransformList,
text2xml: text2xml,
toString: toString,
transformBox: transformBox,
transformListToTransform: transformListToTransform,
transformPoint: transformPoint,
walkTree: walkTree
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -3,7 +3,7 @@
## Prepare
1. `npm test` - Ensure tests are passing
1. `npm run build-doc` - Ensure JSDoc can build
1. `npm run build-doc` - Ensure JSDoc can build and is available for site build
1. `npm run grep-doc` - For JSDoc, we ensure that a minimum of generic types
have been added (e.g., "number" should instead be "Float" or "Array",
and "object", "function", or "array" should be replaced by more specific
@ -63,6 +63,9 @@ You will need to be a member of the SVG-Edit GitHub group to do this step.
## Publish to npm
1. To preview which files will be included once published (taking into
account `.npmignore`), you may use `npm pack` (taking care to remove
the `.tgz` tarball file that it creates).
1. `npm publish`
## Update the project docs

View File

@ -15,7 +15,7 @@ export default {
const svgCanvas = svgEditor.canvas;
const $ = jQuery;
const // {svgcontent} = S,
addElem = S.addSVGElementFromJson,
addElem = svgCanvas.addSVGElementFromJson,
{nonce} = S,
prefix = 'se_arrow_';
@ -56,7 +56,7 @@ export default {
if (!m || m.length !== 2) {
return null;
}
return S.getElem(m[1]);
return svgCanvas.getElem(m[1]);
}
function showPanel (on) {
@ -105,7 +105,7 @@ export default {
data.refx = 5;
}
let marker = S.getElem(id);
let marker = svgCanvas.getElem(id);
if (!marker) {
marker = addElem({
element: 'marker',
@ -128,7 +128,7 @@ export default {
}
});
marker.append(arrow);
S.findDefs().append(marker);
svgCanvas.findDefs().append(marker);
}
marker.setAttribute('refX', data.refx);
@ -160,13 +160,13 @@ export default {
addMarker(dir, type);
svgCanvas.changeSelectedAttribute('marker-' + type, 'url(#' + pathdata[dir].id + ')');
S.call('changed', selElems);
svgCanvas.call('changed', selElems);
}
function colorChanged (elem) {
const color = elem.getAttribute('stroke');
const mtypes = ['start', 'mid', 'end'];
const defs = S.findDefs();
const defs = svgCanvas.findDefs();
$.each(mtypes, function (i, type) {
const marker = getLinked(elem, 'marker-' + type);

View File

@ -14,8 +14,9 @@ export default {
const $ = jQuery;
const svgEditor = this;
const svgCanvas = svgEditor.canvas;
const {svgroot, getNextId, getElem, importLocale} = S,
addElem = S.addSVGElementFromJson,
const {getElem} = svgCanvas;
const {svgroot, importLocale} = S,
addElem = svgCanvas.addSVGElementFromJson,
selManager = S.selectorManager,
connSel = '.se_connector',
// connect_str = '-SE_CONNECT-',
@ -364,7 +365,7 @@ export default {
curLine = addElem({
element: 'polyline',
attr: {
id: getNextId(),
id: svgCanvas.getNextId(),
points: (x + ',' + y + ' ' + x + ',' + y + ' ' + startX + ',' + startY),
stroke: '#' + initStroke.color,
'stroke-width': (!startElem.stroke_width || startElem.stroke_width === 0)

View File

@ -17,7 +17,7 @@ export default {
const svgCanvas = svgEditor.canvas;
const
// {svgcontent} = S,
// addElem = S.addSVGElementFromJson,
// addElem = svgCanvas.addSVGElementFromJson,
svgdoc = S.svgroot.parentNode.ownerDocument;
const strings = await importLocale();
@ -58,9 +58,9 @@ export default {
// convert string into XML document
const newDoc = text2xml('<svg xmlns="' + NS.SVG + '" xmlns:xlink="' + NS.XLINK + '">' + xmlString + '</svg>');
// run it through our sanitizer to remove anything we do not support
S.sanitizeSvg(newDoc.documentElement);
svgCanvas.sanitizeSvg(newDoc.documentElement);
elt.replaceWith(svgdoc.importNode(newDoc.documentElement.firstChild, true));
S.call('changed', [elt]);
svgCanvas.call('changed', [elt]);
svgCanvas.clearSelection();
} catch (e) {
console.log(e);
@ -77,7 +77,7 @@ export default {
toggleSourceButtons(true);
elt.removeAttribute('fill');
const str = S.svgToString(elt, 0);
const str = svgCanvas.svgToString(elt, 0);
$('#svg_source_textarea').val(str);
$('#svg_source_editor').fadeIn();
properlySourceSizeTextArea();
@ -86,7 +86,7 @@ export default {
function setAttr (attr, val) {
svgCanvas.changeSelectedAttribute(attr, val);
S.call('changed', selElems);
svgCanvas.call('changed', selElems);
}
const buttons = [{
@ -192,12 +192,12 @@ export default {
if (svgCanvas.getMode() === 'foreign') {
started = true;
newFO = S.addSVGElementFromJson({
newFO = svgCanvas.addSVGElementFromJson({
element: 'foreignObject',
attr: {
x: opts.start_x,
y: opts.start_y,
id: S.getNextId(),
id: svgCanvas.getNextId(),
'font-size': 16, // cur_text.font_size,
width: '48',
height: '20',

View File

@ -37,7 +37,7 @@ export default {
const $ = jQuery;
const svgCanvas = svgEditor.canvas;
const // {svgcontent} = S,
addElem = S.addSVGElementFromJson;
addElem = svgCanvas.addSVGElementFromJson;
const mtypes = ['start', 'mid', 'end'];
const markerPrefix = 'se_marker_';
const idPrefix = 'mkr_';
@ -91,7 +91,7 @@ export default {
if (!m || m.length !== 2) {
return null;
}
return S.getElem(m[1]);
return svgCanvas.getElem(m[1]);
}
function setIcon (pos, id) {
@ -140,7 +140,7 @@ export default {
const txtBoxBorder = 'none';
const txtBoxStrokeWidth = 0;
let marker = S.getElem(id);
let marker = svgCanvas.getElem(id);
if (marker) { return; }
if (val === '' || val === '\\nomarker') { return; }
@ -228,7 +228,7 @@ export default {
marker.setAttribute('markerHeight', markerHeight);
marker.setAttribute('refX', refX);
marker.setAttribute('refY', refY);
S.findDefs().append(marker);
svgCanvas.findDefs().append(marker);
return marker;
}
@ -287,7 +287,7 @@ export default {
if (val === '') { val = '\\nomarker'; }
if (val === '\\nomarker') {
setIcon(pos, val);
S.call('changed', selElems);
svgCanvas.call('changed', selElems);
return;
}
// Set marker on element
@ -295,7 +295,7 @@ export default {
addMarker(id, val);
svgCanvas.changeSelectedAttribute(markerName, 'url(#' + id + ')');
if (el.tagName === 'line' && pos === 'mid') { el = convertline(el); }
S.call('changed', selElems);
svgCanvas.call('changed', selElems);
setIcon(pos, val);
}
@ -334,7 +334,7 @@ export default {
addMarker(id, val);
svgCanvas.changeSelectedAttribute(markerName, 'url(#' + id + ')');
if (el.tagName === 'line' && pos === 'mid') { el = convertline(el); }
S.call('changed', selElems);
svgCanvas.call('changed', selElems);
}
}
});

View File

@ -13,7 +13,7 @@ export default {
const $ = jQuery;
const svgCanvas = svgEditor.canvas;
const {importLocale} = S, // {svgcontent}
// addElem = S.addSVGElementFromJson,
// addElem = svgCanvas.addSVGElementFromJson,
editingitex = false;
const strings = await importLocale();
let selElems,
@ -55,7 +55,7 @@ export default {
function setAttr (attr, val) {
svgCanvas.changeSelectedAttribute(attr, val);
S.call('changed', selElems);
svgCanvas.call('changed', selElems);
}
function cot (n) {
@ -96,11 +96,11 @@ export default {
while (children.length > 0) {
mrow.append(svgdoc.adoptNode(children[0], true));
}
S.sanitizeSvg(math);
S.call('changed', [elt]);
svgCanvas.sanitizeSvg(math);
svgCanvas.call('changed', [elt]);
});
elt.firstChild.replaceWith(math);
S.call('changed', [elt]);
svgCanvas.call('changed', [elt]);
svgCanvas.clearSelection();
} catch(e) {
console.log(e);
@ -187,12 +187,12 @@ export default {
if (svgCanvas.getMode() === 'polygon') {
started = true;
newFO = S.addSVGElementFromJson({
newFO = svgCanvas.addSVGElementFromJson({
element: 'polygon',
attr: {
cx: opts.start_x,
cy: opts.start_y,
id: S.getNextId(),
id: svgCanvas.getNextId(),
shape: 'regularPoly',
sides: document.getElementById('polySides').value,
orient: 'x',

View File

@ -42,7 +42,7 @@ export default {
function setAttr (attr, val) {
svgCanvas.changeSelectedAttribute(attr, val);
S.call('changed', selElems);
svgCanvas.call('changed', selElems);
}
/*
@ -118,12 +118,12 @@ export default {
if (svgCanvas.getMode() === 'star') {
started = true;
newFO = S.addSVGElementFromJson({
newFO = svgCanvas.addSVGElementFromJson({
element: 'polygon',
attr: {
cx: opts.start_x,
cy: opts.start_y,
id: S.getNextId(),
id: svgCanvas.getNextId(),
shape: 'star',
point: document.getElementById('starNumPoints').value,
r: 0,

View File

@ -1425,6 +1425,7 @@ this.prepareSvg = function (newDoc) {
* 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.
* @function module:svgcanvas~ffClone
* @todo Test for this bug on load and add it to "support" object instead of
* browser sniffing
* @param {Element} elem - The (text) DOM element to clone
@ -1531,7 +1532,12 @@ const recalculateAllSelectedDimensions = this.recalculateAllSelectedDimensions =
}
};
// Debug tool to easily see the current matrix in the browser's console
/**
* Debug tool to easily see the current matrix in the browser's console
* @function module:svgcanvas~logMatrix
* @param {SVGMatrix} m The matrix
* @returns {undefined}
*/
const logMatrix = function (m) {
console.log([m.a, m.b, m.c, m.d, m.e, m.f]);
};
@ -5278,6 +5284,7 @@ const setGradient = this.setGradient = function (type) {
/**
* Check if exact gradient already exists
* @function module:svgcanvas~findDuplicateGradient
* @param {SVGGradientElement} grad - The gradient DOM element to compare to others
* @returns {SVGGradientElement} The existing gradient if found, `null` if not
*/
@ -7114,9 +7121,31 @@ this.clear();
/**
* @interface module:svgcanvas.PrivateMethods
* @type {object}
* @todo If keeping, should document this interface
* @see The source
* @type {PlainObject}
* @property {module:svgcanvas~addCommandToHistory} addCommandToHistory
* @property {module:history.HistoryCommand} BatchCommand
* @property {module:history.HistoryCommand} ChangeElementCommand
* @property {module:utilities.decode64} decode64
* @property {module:utilities.encode64} encode64
* @property {module:svgcanvas~ffClone} ffClone
* @property {module:svgcanvas~findDuplicateGradient} findDuplicateGradient
* @property {module:utilities.getPathBBox} getPathBBox
* @property {module:units.getTypeMap} getTypeMap
* @property {module:draw.identifyLayers} identifyLayers
* @property {module:history.HistoryCommand} InsertElementCommand
* @property {module:browser.isChrome} isChrome
* @property {module:math.isIdentity} isIdentity
* @property {module:browser.isIE} isIE
* @property {module:svgcanvas~logMatrix} logMatrix
* @property {module:history.HistoryCommand} MoveElementCommand
* @property {module:namespaces.NS} NS
* @property {module:utilities.preventClickDefault} preventClickDefault
* @property {module:history.HistoryCommand} RemoveElementCommand
* @property {module:SVGTransformList.SVGEditTransformList} SVGEditTransformList
* @property {module:utilities.text2xml} text2xml
* @property {module:math.transformBox} transformBox
* @property {module:math.transformPoint} transformPoint
* @property {module:utilities.walkTree} walkTree
*/
/**
* @deprecated getPrivateMethods
@ -7129,55 +7158,34 @@ this.clear();
* access to them to plugins.
* @function module:svgcanvas.SvgCanvas#getPrivateMethods
* @returns {module:svgcanvas.PrivateMethods}
* @see Source for the methods
*/
this.getPrivateMethods = function () {
const obj = {
addCommandToHistory,
setGradient,
addSVGElementFromJson,
assignAttributes,
BatchCommand,
call,
ChangeElementCommand,
copyElem (elem) { return getCurrentDrawing().copyElem(elem); },
decode64,
encode64,
ffClone,
findDefs,
findDuplicateGradient,
getElem,
getId,
getIntersectionList,
getMouseTarget,
getNextId,
getPathBBox,
getTypeMap,
getUrlFromAttr,
hasMatrixTransform,
identifyLayers: draw.identifyLayers,
InsertElementCommand,
isChrome,
isIdentity,
isIE,
logMatrix,
matrixMultiply,
MoveElementCommand,
NS,
preventClickDefault,
recalculateAllSelectedDimensions,
recalculateDimensions,
remapElement,
RemoveElementCommand,
removeUnusedDefElems,
round,
runExtensions,
sanitizeSvg,
SVGEditTransformList,
text2xml,
toString,
transformBox,
transformListToTransform,
transformPoint,
walkTree
};

View File

@ -71,7 +71,8 @@ function reduceFalseMatches (file, res) {
return ![
'* @typedef {number} Float',
'* @typedef {object} ArbitraryObject',
'* @typedef {object} ArbitraryModule'
'* @typedef {object} ArbitraryModule',
'* @typedef {*} Any'
].includes(line);
});
break;

View File

@ -13738,6 +13738,7 @@
* 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.
* @function module:svgcanvas~ffClone
* @todo Test for this bug on load and add it to "support" object instead of
* browser sniffing
* @param {Element} elem - The (text) DOM element to clone
@ -13847,7 +13848,12 @@
}
};
// Debug tool to easily see the current matrix in the browser's console
/**
* Debug tool to easily see the current matrix in the browser's console
* @function module:svgcanvas~logMatrix
* @param {SVGMatrix} m The matrix
* @returns {undefined}
*/
var logMatrix = function logMatrix(m) {
console.log([m.a, m.b, m.c, m.d, m.e, m.f]);
};
@ -17808,6 +17814,7 @@
/**
* Check if exact gradient already exists
* @function module:svgcanvas~findDuplicateGradient
* @param {SVGGradientElement} grad - The gradient DOM element to compare to others
* @returns {SVGGradientElement} The existing gradient if found, `null` if not
*/
@ -19742,9 +19749,31 @@
/**
* @interface module:svgcanvas.PrivateMethods
* @type {object}
* @todo If keeping, should document this interface
* @see The source
* @type {PlainObject}
* @property {module:svgcanvas~addCommandToHistory} addCommandToHistory
* @property {module:history.HistoryCommand} BatchCommand
* @property {module:history.HistoryCommand} ChangeElementCommand
* @property {module:utilities.decode64} decode64
* @property {module:utilities.encode64} encode64
* @property {module:svgcanvas~ffClone} ffClone
* @property {module:svgcanvas~findDuplicateGradient} findDuplicateGradient
* @property {module:utilities.getPathBBox} getPathBBox
* @property {module:units.getTypeMap} getTypeMap
* @property {module:draw.identifyLayers} identifyLayers
* @property {module:history.HistoryCommand} InsertElementCommand
* @property {module:browser.isChrome} isChrome
* @property {module:math.isIdentity} isIdentity
* @property {module:browser.isIE} isIE
* @property {module:svgcanvas~logMatrix} logMatrix
* @property {module:history.HistoryCommand} MoveElementCommand
* @property {module:namespaces.NS} NS
* @property {module:utilities.preventClickDefault} preventClickDefault
* @property {module:history.HistoryCommand} RemoveElementCommand
* @property {module:SVGTransformList.SVGEditTransformList} SVGEditTransformList
* @property {module:utilities.text2xml} text2xml
* @property {module:math.transformBox} transformBox
* @property {module:math.transformPoint} transformPoint
* @property {module:utilities.walkTree} walkTree
*/
/**
* @deprecated getPrivateMethods
@ -19757,58 +19786,34 @@
* access to them to plugins.
* @function module:svgcanvas.SvgCanvas#getPrivateMethods
* @returns {module:svgcanvas.PrivateMethods}
* @see Source for the methods
*/
this.getPrivateMethods = function () {
var obj = {
addCommandToHistory: addCommandToHistory,
setGradient: setGradient,
addSVGElementFromJson: addSVGElementFromJson,
assignAttributes: assignAttributes,
BatchCommand: BatchCommand$1,
call: call,
ChangeElementCommand: ChangeElementCommand$1,
copyElem: function copyElem$$1(elem) {
return getCurrentDrawing().copyElem(elem);
},
decode64: decode64,
encode64: encode64,
ffClone: ffClone,
findDefs: findDefs,
findDuplicateGradient: findDuplicateGradient,
getElem: getElem,
getId: getId,
getIntersectionList: getIntersectionList,
getMouseTarget: getMouseTarget,
getNextId: getNextId,
getPathBBox: getPathBBox,
getTypeMap: getTypeMap,
getUrlFromAttr: getUrlFromAttr,
hasMatrixTransform: hasMatrixTransform,
identifyLayers: identifyLayers,
InsertElementCommand: InsertElementCommand$1,
isChrome: isChrome,
isIdentity: isIdentity,
isIE: isIE,
logMatrix: logMatrix,
matrixMultiply: matrixMultiply,
MoveElementCommand: MoveElementCommand$1,
NS: NS,
preventClickDefault: preventClickDefault,
recalculateAllSelectedDimensions: recalculateAllSelectedDimensions,
recalculateDimensions: recalculateDimensions,
remapElement: remapElement,
RemoveElementCommand: RemoveElementCommand$1,
removeUnusedDefElems: removeUnusedDefElems,
round: round,
runExtensions: runExtensions,
sanitizeSvg: sanitizeSvg,
SVGEditTransformList: SVGTransformList,
text2xml: text2xml,
toString: toString,
transformBox: transformBox,
transformListToTransform: transformListToTransform,
transformPoint: transformPoint,
walkTree: walkTree
};