- 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`
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user