- Linting: Add `ignore` folder to ignore file; ensure license versions are valid semver

- npm: Update devDeps
master
Brett Zamir 2019-11-13 14:16:06 +08:00
parent d808cc22de
commit a09c47283e
37 changed files with 12859 additions and 15105 deletions

View File

@ -1,4 +1,5 @@
node_modules
ignore
dist
docs/jsdoc

92
dist/canvg.js vendored
View File

@ -15,42 +15,6 @@ var canvg = (function (exports) {
return _typeof(obj);
}
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
@ -4684,36 +4648,26 @@ var canvg = (function (exports) {
}; // load from url
svg.load =
/*#__PURE__*/
function () {
var _ref12 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(ctx, url) {
var dom;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return svg.ajax(url, true);
svg.load = function _callee(ctx, url) {
var dom;
return regeneratorRuntime.async(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return regeneratorRuntime.awrap(svg.ajax(url, true));
case 2:
dom = _context.sent;
return _context.abrupt("return", svg.loadXml(ctx, dom));
case 2:
dom = _context.sent;
return _context.abrupt("return", svg.loadXml(ctx, dom));
case 4:
case "end":
return _context.stop();
}
case 4:
case "end":
return _context.stop();
}
}, _callee);
}));
return function (_x2, _x3) {
return _ref12.apply(this, arguments);
};
}(); // load from xml
}
});
}; // load from xml
svg.loadXml = function (ctx, xml) {
@ -4934,9 +4888,9 @@ var canvg = (function (exports) {
checkPath: function checkPath(element, ctx) {
var _this26 = this;
this.events.forEach(function (_ref13, i) {
var x = _ref13.x,
y = _ref13.y;
this.events.forEach(function (_ref12, i) {
var x = _ref12.x,
y = _ref12.y;
if (ctx.isPointInPath && ctx.isPointInPath(x, y)) {
_this26.eventElements[i] = element;
@ -4946,9 +4900,9 @@ var canvg = (function (exports) {
checkBoundingBox: function checkBoundingBox(element, bb) {
var _this27 = this;
this.events.forEach(function (_ref14, i) {
var x = _ref14.x,
y = _ref14.y;
this.events.forEach(function (_ref13, i) {
var x = _ref13.x,
y = _ref13.y;
if (bb.isPointInBox(x, y)) {
_this27.eventElements[i] = element;

View File

@ -1,42 +1,6 @@
var svgEditorExtension_arrows = (function () {
'use strict';
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
@ -211,366 +175,346 @@ var svgEditorExtension_arrows = (function () {
*/
var extArrows = {
name: 'arrows',
init: function () {
var _init = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee2(S) {
var strings, svgEditor, svgCanvas, addElem, nonce, $, prefix, selElems, arrowprefix, randomizeIds, setArrowNonce, unsetArrowNonce, pathdata, getLinked, showPanel, resetMarker, addMarker, setArrow, colorChanged, contextTools;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
colorChanged = function _ref10(elem) {
var color = elem.getAttribute('stroke');
var mtypes = ['start', 'mid', 'end'];
var defs = svgCanvas.findDefs();
$.each(mtypes, function (i, type) {
var marker = getLinked(elem, 'marker-' + type);
init: function init(S) {
var strings, svgEditor, svgCanvas, addElem, nonce, $, prefix, selElems, arrowprefix, randomizeIds, setArrowNonce, unsetArrowNonce, pathdata, getLinked, showPanel, resetMarker, addMarker, setArrow, colorChanged, contextTools;
return regeneratorRuntime.async(function init$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
colorChanged = function _ref10(elem) {
var color = elem.getAttribute('stroke');
var mtypes = ['start', 'mid', 'end'];
var defs = svgCanvas.findDefs();
$.each(mtypes, function (i, type) {
var marker = getLinked(elem, 'marker-' + type);
if (!marker) {
return;
if (!marker) {
return;
}
var curColor = $(marker).children().attr('fill');
var curD = $(marker).children().attr('d');
if (curColor === color) {
return;
}
var allMarkers = $(defs).find('marker');
var newMarker = null; // Different color, check if already made
allMarkers.each(function () {
var attrs = $(this).children().attr(['fill', 'd']);
if (attrs.fill === color && attrs.d === curD) {
// Found another marker with this color and this path
newMarker = this; // eslint-disable-line consistent-this
}
});
var curColor = $(marker).children().attr('fill');
var curD = $(marker).children().attr('d');
if (!newMarker) {
// Create a new marker with this color
var lastId = marker.id;
var dir = lastId.includes('_fw') ? 'fw' : 'bk';
newMarker = addMarker(dir, type, arrowprefix + dir + allMarkers.length);
$(newMarker).children().attr('fill', color);
}
if (curColor === color) {
return;
}
$(elem).attr('marker-' + type, 'url(#' + newMarker.id + ')'); // Check if last marker can be removed
var allMarkers = $(defs).find('marker');
var newMarker = null; // Different color, check if already made
var remove = true;
$(S.svgcontent).find('line, polyline, path, polygon').each(function () {
var element = this; // eslint-disable-line consistent-this
allMarkers.each(function () {
var attrs = $(this).children().attr(['fill', 'd']);
if (attrs.fill === color && attrs.d === curD) {
// Found another marker with this color and this path
newMarker = this; // eslint-disable-line consistent-this
}
});
if (!newMarker) {
// Create a new marker with this color
var lastId = marker.id;
var dir = lastId.includes('_fw') ? 'fw' : 'bk';
newMarker = addMarker(dir, type, arrowprefix + dir + allMarkers.length);
$(newMarker).children().attr('fill', color);
}
$(elem).attr('marker-' + type, 'url(#' + newMarker.id + ')'); // Check if last marker can be removed
var remove = true;
$(S.svgcontent).find('line, polyline, path, polygon').each(function () {
var element = this; // eslint-disable-line consistent-this
$.each(mtypes, function (j, mtype) {
if ($(element).attr('marker-' + mtype) === 'url(#' + marker.id + ')') {
remove = false;
return remove;
}
return undefined;
});
if (!remove) {
return false;
$.each(mtypes, function (j, mtype) {
if ($(element).attr('marker-' + mtype) === 'url(#' + marker.id + ')') {
remove = false;
return remove;
}
return undefined;
}); // Not found, so can safely remove
if (remove) {
$(marker).remove();
}
});
};
setArrow = function _ref9() {
resetMarker();
var type = this.value;
if (type === 'none') {
return;
} // Set marker on element
var dir = 'fw';
if (type === 'mid_bk') {
type = 'mid';
dir = 'bk';
} else if (type === 'both') {
addMarker('bk', type);
svgCanvas.changeSelectedAttribute('marker-start', 'url(#' + pathdata.bk.id + ')');
type = 'end';
dir = 'fw';
} else if (type === 'start') {
dir = 'bk';
}
addMarker(dir, type);
svgCanvas.changeSelectedAttribute('marker-' + type, 'url(#' + pathdata[dir].id + ')');
svgCanvas.call('changed', selElems);
};
addMarker = function _ref8(dir, type, id) {
// TODO: Make marker (or use?) per arrow type, since refX can be different
id = id || arrowprefix + dir;
var data = pathdata[dir];
if (type === 'mid') {
data.refx = 5;
}
var marker = svgCanvas.getElem(id);
if (!marker) {
marker = addElem({
element: 'marker',
attr: {
viewBox: '0 0 10 10',
id: id,
refY: 5,
markerUnits: 'strokeWidth',
markerWidth: 5,
markerHeight: 5,
orient: 'auto',
style: 'pointer-events:none' // Currently needed for Opera
}
});
var arrow = addElem({
element: 'path',
attr: {
d: data.d,
fill: '#000000'
}
});
marker.append(arrow);
svgCanvas.findDefs().append(marker);
}
marker.setAttribute('refX', data.refx);
return marker;
};
resetMarker = function _ref7() {
var el = selElems[0];
el.removeAttribute('marker-start');
el.removeAttribute('marker-mid');
el.removeAttribute('marker-end');
};
showPanel = function _ref6(on) {
$('#arrow_panel').toggle(on);
if (on) {
var el = selElems[0];
var end = el.getAttribute('marker-end');
var start = el.getAttribute('marker-start');
var mid = el.getAttribute('marker-mid');
var val;
if (end && start) {
val = 'both';
} else if (end) {
val = 'end';
} else if (start) {
val = 'start';
} else if (mid) {
val = 'mid';
if (mid.includes('bk')) {
val = 'mid_bk';
}
if (!remove) {
return false;
}
if (!start && !mid && !end) {
val = 'none';
}
return undefined;
}); // Not found, so can safely remove
$('#arrow_list').val(val);
if (remove) {
$(marker).remove();
}
};
});
};
getLinked = function _ref5(elem, attr) {
var str = elem.getAttribute(attr);
setArrow = function _ref9() {
resetMarker();
var type = this.value;
if (!str) {
return null;
}
if (type === 'none') {
return;
} // Set marker on element
var m = str.match(_wrapRegExp(/\(#(.+)\)/, {
id: 1
}));
if (!m || !m.groups.id) {
return null;
}
var dir = 'fw';
return svgCanvas.getElem(m.groups.id);
};
unsetArrowNonce = function _ref4(win) {
randomizeIds = false;
arrowprefix = prefix;
pathdata.fw.id = arrowprefix + 'fw';
pathdata.bk.id = arrowprefix + 'bk';
};
setArrowNonce = function _ref3(win, n) {
randomizeIds = true;
arrowprefix = prefix + n + '_';
pathdata.fw.id = arrowprefix + 'fw';
pathdata.bk.id = arrowprefix + 'bk';
};
_context2.next = 10;
return S.importLocale();
case 10:
strings = _context2.sent;
svgEditor = this;
svgCanvas = svgEditor.canvas;
// {svgcontent} = S,
addElem = svgCanvas.addSVGElementFromJson, nonce = S.nonce, $ = S.$, prefix = 'se_arrow_';
randomizeIds = S.randomize_ids;
/**
* @param {Window} win
* @param {!(string|Integer)} n
* @returns {void}
*/
svgCanvas.bind('setnonce', setArrowNonce);
svgCanvas.bind('unsetnonce', unsetArrowNonce);
if (randomizeIds) {
arrowprefix = prefix + nonce + '_';
} else {
arrowprefix = prefix;
if (type === 'mid_bk') {
type = 'mid';
dir = 'bk';
} else if (type === 'both') {
addMarker('bk', type);
svgCanvas.changeSelectedAttribute('marker-start', 'url(#' + pathdata.bk.id + ')');
type = 'end';
dir = 'fw';
} else if (type === 'start') {
dir = 'bk';
}
pathdata = {
fw: {
d: 'm0,0l10,5l-10,5l5,-5l-5,-5z',
refx: 8,
id: arrowprefix + 'fw'
},
bk: {
d: 'm10,0l-10,5l10,5l-5,-5l5,-5z',
refx: 2,
id: arrowprefix + 'bk'
}
};
/**
* Gets linked element.
* @param {Element} elem
* @param {string} attr
* @returns {Element}
*/
addMarker(dir, type);
svgCanvas.changeSelectedAttribute('marker-' + type, 'url(#' + pathdata[dir].id + ')');
svgCanvas.call('changed', selElems);
};
contextTools = [{
type: 'select',
panel: 'arrow_panel',
id: 'arrow_list',
defval: 'none',
events: {
change: setArrow
}
}];
return _context2.abrupt("return", {
name: strings.name,
context_tools: strings.contextTools.map(function (contextTool, i) {
return Object.assign(contextTools[i], contextTool);
}),
callback: function callback() {
$('#arrow_panel').hide(); // Set ID so it can be translated in locale file
addMarker = function _ref8(dir, type, id) {
// TODO: Make marker (or use?) per arrow type, since refX can be different
id = id || arrowprefix + dir;
var data = pathdata[dir];
$('#arrow_list option')[0].id = 'connector_no_arrow';
},
addLangData: function () {
var _addLangData = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(_ref) {
var lang, importLocale, _ref2, langList;
if (type === 'mid') {
data.refx = 5;
}
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
lang = _ref.lang, importLocale = _ref.importLocale;
_context.next = 3;
return importLocale();
var marker = svgCanvas.getElem(id);
case 3:
_ref2 = _context.sent;
langList = _ref2.langList;
return _context.abrupt("return", {
data: langList
});
if (!marker) {
marker = addElem({
element: 'marker',
attr: {
viewBox: '0 0 10 10',
id: id,
refY: 5,
markerUnits: 'strokeWidth',
markerWidth: 5,
markerHeight: 5,
orient: 'auto',
style: 'pointer-events:none' // Currently needed for Opera
case 6:
case "end":
return _context.stop();
}
}
}, _callee);
}));
function addLangData(_x2) {
return _addLangData.apply(this, arguments);
}
});
var arrow = addElem({
element: 'path',
attr: {
d: data.d,
fill: '#000000'
}
});
marker.append(arrow);
svgCanvas.findDefs().append(marker);
}
return addLangData;
}(),
selectedChanged: function selectedChanged(opts) {
// Use this to update the current selected elements
selElems = opts.elems;
var markerElems = ['line', 'path', 'polyline', 'polygon'];
var i = selElems.length;
marker.setAttribute('refX', data.refx);
return marker;
};
while (i--) {
var elem = selElems[i];
resetMarker = function _ref7() {
var el = selElems[0];
el.removeAttribute('marker-start');
el.removeAttribute('marker-mid');
el.removeAttribute('marker-end');
};
if (elem && markerElems.includes(elem.tagName)) {
if (opts.selectedElement && !opts.multiselected) {
showPanel(true);
} else {
showPanel(false);
}
showPanel = function _ref6(on) {
$('#arrow_panel').toggle(on);
if (on) {
var el = selElems[0];
var end = el.getAttribute('marker-end');
var start = el.getAttribute('marker-start');
var mid = el.getAttribute('marker-mid');
var val;
if (end && start) {
val = 'both';
} else if (end) {
val = 'end';
} else if (start) {
val = 'start';
} else if (mid) {
val = 'mid';
if (mid.includes('bk')) {
val = 'mid_bk';
}
}
if (!start && !mid && !end) {
val = 'none';
}
$('#arrow_list').val(val);
}
};
getLinked = function _ref5(elem, attr) {
var str = elem.getAttribute(attr);
if (!str) {
return null;
}
var m = str.match(_wrapRegExp(/\(#(.+)\)/, {
id: 1
}));
if (!m || !m.groups.id) {
return null;
}
return svgCanvas.getElem(m.groups.id);
};
unsetArrowNonce = function _ref4(win) {
randomizeIds = false;
arrowprefix = prefix;
pathdata.fw.id = arrowprefix + 'fw';
pathdata.bk.id = arrowprefix + 'bk';
};
setArrowNonce = function _ref3(win, n) {
randomizeIds = true;
arrowprefix = prefix + n + '_';
pathdata.fw.id = arrowprefix + 'fw';
pathdata.bk.id = arrowprefix + 'bk';
};
_context2.next = 10;
return regeneratorRuntime.awrap(S.importLocale());
case 10:
strings = _context2.sent;
svgEditor = this;
svgCanvas = svgEditor.canvas;
// {svgcontent} = S,
addElem = svgCanvas.addSVGElementFromJson, nonce = S.nonce, $ = S.$, prefix = 'se_arrow_';
randomizeIds = S.randomize_ids;
/**
* @param {Window} win
* @param {!(string|Integer)} n
* @returns {void}
*/
svgCanvas.bind('setnonce', setArrowNonce);
svgCanvas.bind('unsetnonce', unsetArrowNonce);
if (randomizeIds) {
arrowprefix = prefix + nonce + '_';
} else {
arrowprefix = prefix;
}
pathdata = {
fw: {
d: 'm0,0l10,5l-10,5l5,-5l-5,-5z',
refx: 8,
id: arrowprefix + 'fw'
},
bk: {
d: 'm10,0l-10,5l10,5l-5,-5l5,-5z',
refx: 2,
id: arrowprefix + 'bk'
}
};
/**
* Gets linked element.
* @param {Element} elem
* @param {string} attr
* @returns {Element}
*/
contextTools = [{
type: 'select',
panel: 'arrow_panel',
id: 'arrow_list',
defval: 'none',
events: {
change: setArrow
}
}];
return _context2.abrupt("return", {
name: strings.name,
context_tools: strings.contextTools.map(function (contextTool, i) {
return Object.assign(contextTools[i], contextTool);
}),
callback: function callback() {
$('#arrow_panel').hide(); // Set ID so it can be translated in locale file
$('#arrow_list option')[0].id = 'connector_no_arrow';
},
addLangData: function addLangData(_ref) {
var lang, importLocale, _ref2, langList;
return regeneratorRuntime.async(function addLangData$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
lang = _ref.lang, importLocale = _ref.importLocale;
_context.next = 3;
return regeneratorRuntime.awrap(importLocale());
case 3:
_ref2 = _context.sent;
langList = _ref2.langList;
return _context.abrupt("return", {
data: langList
});
case 6:
case "end":
return _context.stop();
}
}
});
},
selectedChanged: function selectedChanged(opts) {
// Use this to update the current selected elements
selElems = opts.elems;
var markerElems = ['line', 'path', 'polyline', 'polygon'];
var i = selElems.length;
while (i--) {
var elem = selElems[i];
if (elem && markerElems.includes(elem.tagName)) {
if (opts.selectedElement && !opts.multiselected) {
showPanel(true);
} else {
showPanel(false);
}
}
},
elementChanged: function elementChanged(opts) {
var elem = opts.elems[0];
if (elem && (elem.getAttribute('marker-start') || elem.getAttribute('marker-mid') || elem.getAttribute('marker-end'))) {
// const start = elem.getAttribute('marker-start');
// const mid = elem.getAttribute('marker-mid');
// const end = elem.getAttribute('marker-end');
// Has marker, so see if it should match color
colorChanged(elem);
} else {
showPanel(false);
}
}
});
},
elementChanged: function elementChanged(opts) {
var elem = opts.elems[0];
case 21:
case "end":
return _context2.stop();
}
if (elem && (elem.getAttribute('marker-start') || elem.getAttribute('marker-mid') || elem.getAttribute('marker-end'))) {
// const start = elem.getAttribute('marker-start');
// const mid = elem.getAttribute('marker-mid');
// const end = elem.getAttribute('marker-end');
// Has marker, so see if it should match color
colorChanged(elem);
}
}
});
case 21:
case "end":
return _context2.stop();
}
}, _callee2, this);
}));
function init(_x) {
return _init.apply(this, arguments);
}
return init;
}()
}
}, null, this);
}
};
return extArrows;

View File

@ -1,42 +1,6 @@
var svgEditorExtension_closepath = (function () {
'use strict';
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
/**
* ext-closepath.js
*
@ -49,125 +13,115 @@ var svgEditorExtension_closepath = (function () {
// The button toggles whether the path is open or closed
var extClosepath = {
name: 'closepath',
init: function () {
var _init = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(_ref) {
var importLocale, $, strings, svgEditor, selElems, updateButton, showPanel, toggleClosed, buttons;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
importLocale = _ref.importLocale, $ = _ref.$;
_context.next = 3;
return importLocale();
init: function init(_ref) {
var importLocale, $, strings, svgEditor, selElems, updateButton, showPanel, toggleClosed, buttons;
return regeneratorRuntime.async(function init$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
importLocale = _ref.importLocale, $ = _ref.$;
_context.next = 3;
return regeneratorRuntime.awrap(importLocale());
case 3:
strings = _context.sent;
svgEditor = this;
case 3:
strings = _context.sent;
svgEditor = this;
updateButton = function updateButton(path) {
var seglist = path.pathSegList,
closed = seglist.getItem(seglist.numberOfItems - 1).pathSegType === 1,
showbutton = closed ? '#tool_openpath' : '#tool_closepath',
hidebutton = closed ? '#tool_closepath' : '#tool_openpath';
$(hidebutton).hide();
$(showbutton).show();
};
updateButton = function updateButton(path) {
var seglist = path.pathSegList,
closed = seglist.getItem(seglist.numberOfItems - 1).pathSegType === 1,
showbutton = closed ? '#tool_openpath' : '#tool_closepath',
hidebutton = closed ? '#tool_closepath' : '#tool_openpath';
$(hidebutton).hide();
$(showbutton).show();
};
showPanel = function showPanel(on) {
$('#closepath_panel').toggle(on);
showPanel = function showPanel(on) {
$('#closepath_panel').toggle(on);
if (on) {
var path = selElems[0];
if (path) {
updateButton(path);
}
}
};
toggleClosed = function toggleClosed() {
if (on) {
var path = selElems[0];
if (path) {
var seglist = path.pathSegList,
last = seglist.numberOfItems - 1; // is closed
if (seglist.getItem(last).pathSegType === 1) {
seglist.removeItem(last);
} else {
seglist.appendItem(path.createSVGPathSegClosePath());
}
updateButton(path);
}
};
}
};
buttons = [{
id: 'tool_openpath',
icon: svgEditor.curConfig.extIconsPath + 'openpath.png',
type: 'context',
panel: 'closepath_panel',
events: {
click: function click() {
toggleClosed();
}
toggleClosed = function toggleClosed() {
var path = selElems[0];
if (path) {
var seglist = path.pathSegList,
last = seglist.numberOfItems - 1; // is closed
if (seglist.getItem(last).pathSegType === 1) {
seglist.removeItem(last);
} else {
seglist.appendItem(path.createSVGPathSegClosePath());
}
}, {
id: 'tool_closepath',
icon: svgEditor.curConfig.extIconsPath + 'closepath.png',
type: 'context',
panel: 'closepath_panel',
events: {
click: function click() {
toggleClosed();
}
updateButton(path);
}
};
buttons = [{
id: 'tool_openpath',
icon: svgEditor.curConfig.extIconsPath + 'openpath.png',
type: 'context',
panel: 'closepath_panel',
events: {
click: function click() {
toggleClosed();
}
}];
return _context.abrupt("return", {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'closepath_icons.svg',
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
}),
callback: function callback() {
$('#closepath_panel').hide();
},
selectedChanged: function selectedChanged(opts) {
selElems = opts.elems;
var i = selElems.length;
}
}, {
id: 'tool_closepath',
icon: svgEditor.curConfig.extIconsPath + 'closepath.png',
type: 'context',
panel: 'closepath_panel',
events: {
click: function click() {
toggleClosed();
}
}
}];
return _context.abrupt("return", {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'closepath_icons.svg',
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
}),
callback: function callback() {
$('#closepath_panel').hide();
},
selectedChanged: function selectedChanged(opts) {
selElems = opts.elems;
var i = selElems.length;
while (i--) {
var elem = selElems[i];
while (i--) {
var elem = selElems[i];
if (elem && elem.tagName === 'path') {
if (opts.selectedElement && !opts.multiselected) {
showPanel(true);
} else {
showPanel(false);
}
if (elem && elem.tagName === 'path') {
if (opts.selectedElement && !opts.multiselected) {
showPanel(true);
} else {
showPanel(false);
}
} else {
showPanel(false);
}
}
});
}
});
case 10:
case "end":
return _context.stop();
}
case 10:
case "end":
return _context.stop();
}
}, _callee, this);
}));
function init(_x) {
return _init.apply(this, arguments);
}
return init;
}()
}
}, null, this);
}
};
return extClosepath;

File diff suppressed because it is too large Load Diff

View File

@ -1,42 +1,6 @@
var svgEditorExtension_eyedropper = (function () {
'use strict';
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
/**
* ext-eyedropper.js
*
@ -47,160 +11,150 @@ var svgEditorExtension_eyedropper = (function () {
*/
var extEyedropper = {
name: 'eyedropper',
init: function () {
var _init = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(S) {
var strings, svgEditor, $, ChangeElementCommand, svgCanvas, addToHistory, currentStyle, getStyle, buttons;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
getStyle = function _ref(opts) {
// if we are in eyedropper mode, we don't want to disable the eye-dropper tool
init: function init(S) {
var strings, svgEditor, $, ChangeElementCommand, svgCanvas, addToHistory, currentStyle, getStyle, buttons;
return regeneratorRuntime.async(function init$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
getStyle = function _ref(opts) {
// if we are in eyedropper mode, we don't want to disable the eye-dropper tool
var mode = svgCanvas.getMode();
if (mode === 'eyedropper') {
return;
}
var tool = $('#tool_eyedropper'); // enable-eye-dropper if one element is selected
var elem = null;
if (!opts.multiselected && opts.elems[0] && !['svg', 'g', 'use'].includes(opts.elems[0].nodeName)) {
elem = opts.elems[0];
tool.removeClass('disabled'); // grab the current style
currentStyle.fillPaint = elem.getAttribute('fill') || 'black';
currentStyle.fillOpacity = elem.getAttribute('fill-opacity') || 1.0;
currentStyle.strokePaint = elem.getAttribute('stroke');
currentStyle.strokeOpacity = elem.getAttribute('stroke-opacity') || 1.0;
currentStyle.strokeWidth = elem.getAttribute('stroke-width');
currentStyle.strokeDashArray = elem.getAttribute('stroke-dasharray');
currentStyle.strokeLinecap = elem.getAttribute('stroke-linecap');
currentStyle.strokeLinejoin = elem.getAttribute('stroke-linejoin');
currentStyle.opacity = elem.getAttribute('opacity') || 1.0; // disable eye-dropper tool
} else {
tool.addClass('disabled');
}
};
_context.next = 3;
return regeneratorRuntime.awrap(S.importLocale());
case 3:
strings = _context.sent;
svgEditor = this;
$ = S.$, ChangeElementCommand = S.ChangeElementCommand, svgCanvas = svgEditor.canvas, addToHistory = function addToHistory(cmd) {
svgCanvas.undoMgr.addCommandToHistory(cmd);
}, currentStyle = {
fillPaint: 'red',
fillOpacity: 1.0,
strokePaint: 'black',
strokeOpacity: 1.0,
strokeWidth: 5,
strokeDashArray: null,
opacity: 1.0,
strokeLinecap: 'butt',
strokeLinejoin: 'miter'
};
/**
*
* @param {module:svgcanvas.SvgCanvas#event:ext_selectedChanged|module:svgcanvas.SvgCanvas#event:ext_elementChanged} opts
* @returns {void}
*/
buttons = [{
id: 'tool_eyedropper',
icon: svgEditor.curConfig.extIconsPath + 'eyedropper.png',
type: 'mode',
events: {
click: function click() {
svgCanvas.setMode('eyedropper');
}
}
}];
return _context.abrupt("return", {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'eyedropper-icon.xml',
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
}),
// if we have selected an element, grab its paint and enable the eye dropper button
selectedChanged: getStyle,
elementChanged: getStyle,
mouseDown: function mouseDown(opts) {
var mode = svgCanvas.getMode();
if (mode === 'eyedropper') {
return;
}
var e = opts.event;
var target = e.target;
var tool = $('#tool_eyedropper'); // enable-eye-dropper if one element is selected
if (!['svg', 'g', 'use'].includes(target.nodeName)) {
var changes = {};
var elem = null;
var change = function change(elem, attrname, newvalue) {
changes[attrname] = elem.getAttribute(attrname);
elem.setAttribute(attrname, newvalue);
};
if (!opts.multiselected && opts.elems[0] && !['svg', 'g', 'use'].includes(opts.elems[0].nodeName)) {
elem = opts.elems[0];
tool.removeClass('disabled'); // grab the current style
currentStyle.fillPaint = elem.getAttribute('fill') || 'black';
currentStyle.fillOpacity = elem.getAttribute('fill-opacity') || 1.0;
currentStyle.strokePaint = elem.getAttribute('stroke');
currentStyle.strokeOpacity = elem.getAttribute('stroke-opacity') || 1.0;
currentStyle.strokeWidth = elem.getAttribute('stroke-width');
currentStyle.strokeDashArray = elem.getAttribute('stroke-dasharray');
currentStyle.strokeLinecap = elem.getAttribute('stroke-linecap');
currentStyle.strokeLinejoin = elem.getAttribute('stroke-linejoin');
currentStyle.opacity = elem.getAttribute('opacity') || 1.0; // disable eye-dropper tool
} else {
tool.addClass('disabled');
}
};
_context.next = 3;
return S.importLocale();
case 3:
strings = _context.sent;
svgEditor = this;
$ = S.$, ChangeElementCommand = S.ChangeElementCommand, svgCanvas = svgEditor.canvas, addToHistory = function addToHistory(cmd) {
svgCanvas.undoMgr.addCommandToHistory(cmd);
}, currentStyle = {
fillPaint: 'red',
fillOpacity: 1.0,
strokePaint: 'black',
strokeOpacity: 1.0,
strokeWidth: 5,
strokeDashArray: null,
opacity: 1.0,
strokeLinecap: 'butt',
strokeLinejoin: 'miter'
};
/**
*
* @param {module:svgcanvas.SvgCanvas#event:ext_selectedChanged|module:svgcanvas.SvgCanvas#event:ext_elementChanged} opts
* @returns {void}
*/
buttons = [{
id: 'tool_eyedropper',
icon: svgEditor.curConfig.extIconsPath + 'eyedropper.png',
type: 'mode',
events: {
click: function click() {
svgCanvas.setMode('eyedropper');
}
}
}];
return _context.abrupt("return", {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'eyedropper-icon.xml',
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
}),
// if we have selected an element, grab its paint and enable the eye dropper button
selectedChanged: getStyle,
elementChanged: getStyle,
mouseDown: function mouseDown(opts) {
var mode = svgCanvas.getMode();
if (mode === 'eyedropper') {
var e = opts.event;
var target = e.target;
if (!['svg', 'g', 'use'].includes(target.nodeName)) {
var changes = {};
var change = function change(elem, attrname, newvalue) {
changes[attrname] = elem.getAttribute(attrname);
elem.setAttribute(attrname, newvalue);
};
if (currentStyle.fillPaint) {
change(target, 'fill', currentStyle.fillPaint);
}
if (currentStyle.fillOpacity) {
change(target, 'fill-opacity', currentStyle.fillOpacity);
}
if (currentStyle.strokePaint) {
change(target, 'stroke', currentStyle.strokePaint);
}
if (currentStyle.strokeOpacity) {
change(target, 'stroke-opacity', currentStyle.strokeOpacity);
}
if (currentStyle.strokeWidth) {
change(target, 'stroke-width', currentStyle.strokeWidth);
}
if (currentStyle.strokeDashArray) {
change(target, 'stroke-dasharray', currentStyle.strokeDashArray);
}
if (currentStyle.opacity) {
change(target, 'opacity', currentStyle.opacity);
}
if (currentStyle.strokeLinecap) {
change(target, 'stroke-linecap', currentStyle.strokeLinecap);
}
if (currentStyle.strokeLinejoin) {
change(target, 'stroke-linejoin', currentStyle.strokeLinejoin);
}
addToHistory(new ChangeElementCommand(target, changes));
if (currentStyle.fillPaint) {
change(target, 'fill', currentStyle.fillPaint);
}
if (currentStyle.fillOpacity) {
change(target, 'fill-opacity', currentStyle.fillOpacity);
}
if (currentStyle.strokePaint) {
change(target, 'stroke', currentStyle.strokePaint);
}
if (currentStyle.strokeOpacity) {
change(target, 'stroke-opacity', currentStyle.strokeOpacity);
}
if (currentStyle.strokeWidth) {
change(target, 'stroke-width', currentStyle.strokeWidth);
}
if (currentStyle.strokeDashArray) {
change(target, 'stroke-dasharray', currentStyle.strokeDashArray);
}
if (currentStyle.opacity) {
change(target, 'opacity', currentStyle.opacity);
}
if (currentStyle.strokeLinecap) {
change(target, 'stroke-linecap', currentStyle.strokeLinecap);
}
if (currentStyle.strokeLinejoin) {
change(target, 'stroke-linejoin', currentStyle.strokeLinejoin);
}
addToHistory(new ChangeElementCommand(target, changes));
}
}
});
}
});
case 8:
case "end":
return _context.stop();
}
case 8:
case "end":
return _context.stop();
}
}, _callee, this);
}));
function init(_x) {
return _init.apply(this, arguments);
}
return init;
}()
}
}, null, this);
}
};
return extEyedropper;

View File

@ -1,42 +1,6 @@
var svgEditorExtension_foreignobject = (function () {
'use strict';
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
/**
* ext-foreignobject.js
*
@ -47,325 +11,311 @@ var svgEditorExtension_foreignobject = (function () {
*/
var extForeignobject = {
name: 'foreignobject',
init: function () {
var _init = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee2(S) {
var svgEditor, $, text2xml, NS, importLocale, svgCanvas, svgdoc, strings, properlySourceSizeTextArea, showPanel, toggleSourceButtons, selElems, started, newFO, editingforeign, setForeignString, showForeignEditor, setAttr, buttons, contextTools;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
setAttr = function _ref6(attr, val) {
svgCanvas.changeSelectedAttribute(attr, val);
svgCanvas.call('changed', selElems);
};
init: function init(S) {
var svgEditor, $, text2xml, NS, importLocale, svgCanvas, svgdoc, strings, properlySourceSizeTextArea, showPanel, toggleSourceButtons, selElems, started, newFO, editingforeign, setForeignString, showForeignEditor, setAttr, buttons, contextTools;
return regeneratorRuntime.async(function init$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
setAttr = function _ref5(attr, val) {
svgCanvas.changeSelectedAttribute(attr, val);
svgCanvas.call('changed', selElems);
};
showForeignEditor = function _ref5() {
var elt = selElems[0];
showForeignEditor = function _ref4() {
var elt = selElems[0];
if (!elt || editingforeign) {
return;
if (!elt || editingforeign) {
return;
}
editingforeign = true;
toggleSourceButtons(true);
elt.removeAttribute('fill');
var str = svgCanvas.svgToString(elt, 0);
$('#svg_source_textarea').val(str);
$('#svg_source_editor').fadeIn();
properlySourceSizeTextArea();
$('#svg_source_textarea').focus();
};
setForeignString = function _ref3(xmlString) {
var elt = selElems[0]; // The parent `Element` to append to
try {
// 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
svgCanvas.sanitizeSvg(newDoc.documentElement);
elt.replaceWith(svgdoc.importNode(newDoc.documentElement.firstChild, true));
svgCanvas.call('changed', [elt]);
svgCanvas.clearSelection();
} catch (e) {
// Todo: Surface error to user
console.log(e); // eslint-disable-line no-console
return false;
}
return true;
};
toggleSourceButtons = function _ref2(on) {
$('#tool_source_save, #tool_source_cancel').toggle(!on);
$('#foreign_save, #foreign_cancel').toggle(on);
};
showPanel = function _ref(on) {
var fcRules = $('#fc_rules');
if (!fcRules.length) {
fcRules = $('<style id="fc_rules"></style>').appendTo('head');
}
fcRules.text(!on ? '' : ' #tool_topath { display: none !important; }');
$('#foreignObject_panel').toggle(on);
};
svgEditor = this;
$ = S.$, text2xml = S.text2xml, NS = S.NS, importLocale = S.importLocale;
svgCanvas = svgEditor.canvas;
svgdoc = S.svgroot.parentNode.ownerDocument;
_context2.next = 11;
return regeneratorRuntime.awrap(importLocale());
case 11:
strings = _context2.sent;
properlySourceSizeTextArea = function properlySourceSizeTextArea() {
// TODO: remove magic numbers here and get values from CSS
var height = $('#svg_source_container').height() - 80;
$('#svg_source_textarea').css('height', height);
};
/**
* @param {boolean} on
* @returns {void}
*/
editingforeign = false;
/**
* This function sets the content of element elt to the input XML.
* @param {string} xmlString - The XML text
* @returns {boolean} This function returns false if the set was unsuccessful, true otherwise.
*/
buttons = [{
id: 'tool_foreign',
icon: svgEditor.curConfig.extIconsPath + 'foreignobject-tool.png',
type: 'mode',
events: {
click: function click() {
svgCanvas.setMode('foreign');
}
editingforeign = true;
toggleSourceButtons(true);
elt.removeAttribute('fill');
var str = svgCanvas.svgToString(elt, 0);
$('#svg_source_textarea').val(str);
$('#svg_source_editor').fadeIn();
properlySourceSizeTextArea();
$('#svg_source_textarea').focus();
};
setForeignString = function _ref4(xmlString) {
var elt = selElems[0]; // The parent `Element` to append to
try {
// 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
svgCanvas.sanitizeSvg(newDoc.documentElement);
elt.replaceWith(svgdoc.importNode(newDoc.documentElement.firstChild, true));
svgCanvas.call('changed', [elt]);
svgCanvas.clearSelection();
} catch (e) {
// Todo: Surface error to user
console.log(e); // eslint-disable-line no-console
return false;
}
}, {
id: 'edit_foreign',
icon: svgEditor.curConfig.extIconsPath + 'foreignobject-edit.png',
type: 'context',
panel: 'foreignObject_panel',
events: {
click: function click() {
showForeignEditor();
}
return true;
};
toggleSourceButtons = function _ref3(on) {
$('#tool_source_save, #tool_source_cancel').toggle(!on);
$('#foreign_save, #foreign_cancel').toggle(on);
};
showPanel = function _ref2(on) {
var fcRules = $('#fc_rules');
if (!fcRules.length) {
fcRules = $('<style id="fc_rules"></style>').appendTo('head');
}
}];
contextTools = [{
type: 'input',
panel: 'foreignObject_panel',
id: 'foreign_width',
size: 3,
events: {
change: function change() {
setAttr('width', this.value);
}
fcRules.text(!on ? '' : ' #tool_topath { display: none !important; }');
$('#foreignObject_panel').toggle(on);
};
svgEditor = this;
$ = S.$, text2xml = S.text2xml, NS = S.NS, importLocale = S.importLocale;
svgCanvas = svgEditor.canvas;
svgdoc = S.svgroot.parentNode.ownerDocument;
_context2.next = 11;
return importLocale();
case 11:
strings = _context2.sent;
properlySourceSizeTextArea = function properlySourceSizeTextArea() {
// TODO: remove magic numbers here and get values from CSS
var height = $('#svg_source_container').height() - 80;
$('#svg_source_textarea').css('height', height);
};
/**
* @param {boolean} on
* @returns {void}
*/
editingforeign = false;
/**
* This function sets the content of element elt to the input XML.
* @param {string} xmlString - The XML text
* @returns {boolean} This function returns false if the set was unsuccessful, true otherwise.
*/
buttons = [{
id: 'tool_foreign',
icon: svgEditor.curConfig.extIconsPath + 'foreignobject-tool.png',
type: 'mode',
events: {
click: function click() {
svgCanvas.setMode('foreign');
}
}
}, {
type: 'input',
panel: 'foreignObject_panel',
id: 'foreign_height',
events: {
change: function change() {
setAttr('height', this.value);
}
}, {
id: 'edit_foreign',
icon: svgEditor.curConfig.extIconsPath + 'foreignobject-edit.png',
type: 'context',
panel: 'foreignObject_panel',
events: {
click: function click() {
showForeignEditor();
}
}
}, {
type: 'input',
panel: 'foreignObject_panel',
id: 'foreign_font_size',
size: 2,
defval: 16,
events: {
change: function change() {
setAttr('font-size', this.value);
}
}];
contextTools = [{
type: 'input',
panel: 'foreignObject_panel',
id: 'foreign_width',
size: 3,
events: {
change: function change() {
setAttr('width', this.value);
}
}
}, {
type: 'input',
panel: 'foreignObject_panel',
id: 'foreign_height',
events: {
change: function change() {
setAttr('height', this.value);
}
}
}, {
type: 'input',
panel: 'foreignObject_panel',
id: 'foreign_font_size',
size: 2,
defval: 16,
events: {
change: function change() {
setAttr('font-size', this.value);
}
}
}];
return _context2.abrupt("return", {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'foreignobject-icons.xml',
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
}),
context_tools: strings.contextTools.map(function (contextTool, i) {
return Object.assign(contextTools[i], contextTool);
}),
callback: function callback() {
$('#foreignObject_panel').hide();
}
}];
return _context2.abrupt("return", {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'foreignobject-icons.xml',
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
}),
context_tools: strings.contextTools.map(function (contextTool, i) {
return Object.assign(contextTools[i], contextTool);
}),
callback: function callback() {
$('#foreignObject_panel').hide();
var endChanges = function endChanges() {
$('#svg_source_editor').hide();
editingforeign = false;
$('#svg_source_textarea').blur();
toggleSourceButtons(false);
}; // TODO: Needs to be done after orig icon loads
var endChanges = function endChanges() {
$('#svg_source_editor').hide();
editingforeign = false;
$('#svg_source_textarea').blur();
toggleSourceButtons(false);
}; // TODO: Needs to be done after orig icon loads
setTimeout(function () {
// Create source save/cancel buttons
setTimeout(function () {
// Create source save/cancel buttons
/* const save = */
$('#tool_source_save').clone().hide().attr('id', 'foreign_save').unbind().appendTo('#tool_source_back').click(
/*#__PURE__*/
_asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee() {
var ok;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
if (editingforeign) {
_context.next = 2;
break;
}
return _context.abrupt("return");
case 2:
if (setForeignString($('#svg_source_textarea').val())) {
_context.next = 11;
break;
}
_context.next = 5;
return $.confirm('Errors found. Revert to original?');
case 5:
ok = _context.sent;
if (ok) {
_context.next = 8;
break;
}
return _context.abrupt("return");
case 8:
endChanges();
_context.next = 12;
/* const save = */
$('#tool_source_save').clone().hide().attr('id', 'foreign_save').unbind().appendTo('#tool_source_back').click(function _callee() {
var ok;
return regeneratorRuntime.async(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
if (editingforeign) {
_context.next = 2;
break;
}
case 11:
endChanges();
return _context.abrupt("return");
case 12:
case "end":
return _context.stop();
}
case 2:
if (setForeignString($('#svg_source_textarea').val())) {
_context.next = 11;
break;
}
_context.next = 5;
return regeneratorRuntime.awrap($.confirm('Errors found. Revert to original?'));
case 5:
ok = _context.sent;
if (ok) {
_context.next = 8;
break;
}
return _context.abrupt("return");
case 8:
endChanges();
_context.next = 12;
break;
case 11:
endChanges();
case 12:
case "end":
return _context.stop();
}
}, _callee);
})));
/* const cancel = */
$('#tool_source_cancel').clone().hide().attr('id', 'foreign_cancel').unbind().appendTo('#tool_source_back').click(function () {
endChanges();
});
}, 3000);
},
mouseDown: function mouseDown(opts) {
// const e = opts.event;
if (svgCanvas.getMode() !== 'foreign') {
return undefined;
}
started = true;
newFO = svgCanvas.addSVGElementFromJson({
element: 'foreignObject',
attr: {
x: opts.start_x,
y: opts.start_y,
id: svgCanvas.getNextId(),
'font-size': 16,
// cur_text.font_size,
width: '48',
height: '20',
style: 'pointer-events:inherit'
}
});
var m = svgdoc.createElementNS(NS.MATH, 'math');
m.setAttributeNS(NS.XMLNS, 'xmlns', NS.MATH);
m.setAttribute('display', 'inline');
var mi = svgdoc.createElementNS(NS.MATH, 'mi');
mi.setAttribute('mathvariant', 'normal');
mi.textContent = "\u03A6";
var mo = svgdoc.createElementNS(NS.MATH, 'mo');
mo.textContent = "\u222A";
var mi2 = svgdoc.createElementNS(NS.MATH, 'mi');
mi2.textContent = "\u2133";
m.append(mi, mo, mi2);
newFO.append(m);
return {
started: true
};
},
mouseUp: function mouseUp(opts) {
// const e = opts.event;
if (svgCanvas.getMode() !== 'foreign' || !started) {
return undefined;
}
var attrs = $(newFO).attr(['width', 'height']);
var keep = attrs.width !== '0' || attrs.height !== '0';
svgCanvas.addToSelection([newFO], true);
return {
keep: keep,
element: newFO
};
},
selectedChanged: function selectedChanged(opts) {
// Use this to update the current selected elements
selElems = opts.elems;
var i = selElems.length;
while (i--) {
var elem = selElems[i];
if (elem && elem.tagName === 'foreignObject') {
if (opts.selectedElement && !opts.multiselected) {
$('#foreign_font_size').val(elem.getAttribute('font-size'));
$('#foreign_width').val(elem.getAttribute('width'));
$('#foreign_height').val(elem.getAttribute('height'));
showPanel(true);
} else {
showPanel(false);
}
});
});
/* const cancel = */
$('#tool_source_cancel').clone().hide().attr('id', 'foreign_cancel').unbind().appendTo('#tool_source_back').click(function () {
endChanges();
});
}, 3000);
},
mouseDown: function mouseDown(opts) {
// const e = opts.event;
if (svgCanvas.getMode() !== 'foreign') {
return undefined;
}
started = true;
newFO = svgCanvas.addSVGElementFromJson({
element: 'foreignObject',
attr: {
x: opts.start_x,
y: opts.start_y,
id: svgCanvas.getNextId(),
'font-size': 16,
// cur_text.font_size,
width: '48',
height: '20',
style: 'pointer-events:inherit'
}
});
var m = svgdoc.createElementNS(NS.MATH, 'math');
m.setAttributeNS(NS.XMLNS, 'xmlns', NS.MATH);
m.setAttribute('display', 'inline');
var mi = svgdoc.createElementNS(NS.MATH, 'mi');
mi.setAttribute('mathvariant', 'normal');
mi.textContent = "\u03A6";
var mo = svgdoc.createElementNS(NS.MATH, 'mo');
mo.textContent = "\u222A";
var mi2 = svgdoc.createElementNS(NS.MATH, 'mi');
mi2.textContent = "\u2133";
m.append(mi, mo, mi2);
newFO.append(m);
return {
started: true
};
},
mouseUp: function mouseUp(opts) {
// const e = opts.event;
if (svgCanvas.getMode() !== 'foreign' || !started) {
return undefined;
}
var attrs = $(newFO).attr(['width', 'height']);
var keep = attrs.width !== '0' || attrs.height !== '0';
svgCanvas.addToSelection([newFO], true);
return {
keep: keep,
element: newFO
};
},
selectedChanged: function selectedChanged(opts) {
// Use this to update the current selected elements
selElems = opts.elems;
var i = selElems.length;
while (i--) {
var elem = selElems[i];
if (elem && elem.tagName === 'foreignObject') {
if (opts.selectedElement && !opts.multiselected) {
$('#foreign_font_size').val(elem.getAttribute('font-size'));
$('#foreign_width').val(elem.getAttribute('width'));
$('#foreign_height').val(elem.getAttribute('height'));
showPanel(true);
} else {
showPanel(false);
}
} else {
showPanel(false);
}
},
elementChanged: function elementChanged(opts) {// const elem = opts.elems[0];
}
});
},
elementChanged: function elementChanged(opts) {// const elem = opts.elems[0];
}
});
case 17:
case "end":
return _context2.stop();
}
case 17:
case "end":
return _context2.stop();
}
}, _callee2, this);
}));
function init(_x) {
return _init.apply(this, arguments);
}
return init;
}()
}
}, null, this);
}
};
return extForeignobject;

View File

@ -1,42 +1,6 @@
var svgEditorExtension_grid = (function () {
'use strict';
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
/**
* ext-grid.js
*
@ -47,180 +11,170 @@ var svgEditorExtension_grid = (function () {
*/
var extGrid = {
name: 'grid',
init: function () {
var _init = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(_ref) {
var $, NS, getTypeMap, importLocale, strings, svgEditor, svgCanvas, svgdoc, assignAttributes, hcanvas, canvBG, units, intervals, showGrid, canvasGrid, gridDefs, gridPattern, gridimg, gridBox, updateGrid, gridUpdate, buttons;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
gridUpdate = function _ref3() {
init: function init(_ref) {
var $, NS, getTypeMap, importLocale, strings, svgEditor, svgCanvas, svgdoc, assignAttributes, hcanvas, canvBG, units, intervals, showGrid, canvasGrid, gridDefs, gridPattern, gridimg, gridBox, updateGrid, gridUpdate, buttons;
return regeneratorRuntime.async(function init$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
gridUpdate = function _ref3() {
if (showGrid) {
updateGrid(svgCanvas.getZoom());
}
$('#canvasGrid').toggle(showGrid);
$('#view_grid').toggleClass('push_button_pressed tool_button');
};
updateGrid = function _ref2(zoom) {
// TODO: Try this with <line> elements, then compare performance difference
var unit = units[svgEditor.curConfig.baseUnit]; // 1 = 1px
var uMulti = unit * zoom; // Calculate the main number interval
var rawM = 100 / uMulti;
var multi = 1;
intervals.some(function (num) {
multi = num;
return rawM <= num;
});
var bigInt = multi * uMulti; // Set the canvas size to the width of the container
hcanvas.width = bigInt;
hcanvas.height = bigInt;
var ctx = hcanvas.getContext('2d');
var curD = 0.5;
var part = bigInt / 10;
ctx.globalAlpha = 0.2;
ctx.strokeStyle = svgEditor.curConfig.gridColor;
for (var i = 1; i < 10; i++) {
var subD = Math.round(part * i) + 0.5; // const lineNum = (i % 2)?12:10;
var lineNum = 0;
ctx.moveTo(subD, bigInt);
ctx.lineTo(subD, lineNum);
ctx.moveTo(bigInt, subD);
ctx.lineTo(lineNum, subD);
}
ctx.stroke();
ctx.beginPath();
ctx.globalAlpha = 0.5;
ctx.moveTo(curD, bigInt);
ctx.lineTo(curD, 0);
ctx.moveTo(bigInt, curD);
ctx.lineTo(0, curD);
ctx.stroke();
var datauri = hcanvas.toDataURL('image/png');
gridimg.setAttribute('width', bigInt);
gridimg.setAttribute('height', bigInt);
gridimg.parentNode.setAttribute('width', bigInt);
gridimg.parentNode.setAttribute('height', bigInt);
svgCanvas.setHref(gridimg, datauri);
};
$ = _ref.$, NS = _ref.NS, getTypeMap = _ref.getTypeMap, importLocale = _ref.importLocale;
_context.next = 5;
return regeneratorRuntime.awrap(importLocale());
case 5:
strings = _context.sent;
svgEditor = this;
svgCanvas = svgEditor.canvas;
svgdoc = document.getElementById('svgcanvas').ownerDocument, assignAttributes = svgCanvas.assignAttributes, hcanvas = document.createElement('canvas'), canvBG = $('#canvasBackground'), units = getTypeMap(), intervals = [0.01, 0.1, 1, 10, 100, 1000];
showGrid = svgEditor.curConfig.showGrid || false;
$(hcanvas).hide().appendTo('body');
canvasGrid = svgdoc.createElementNS(NS.SVG, 'svg');
assignAttributes(canvasGrid, {
id: 'canvasGrid',
width: '100%',
height: '100%',
x: 0,
y: 0,
overflow: 'visible',
display: 'none'
});
canvBG.append(canvasGrid);
gridDefs = svgdoc.createElementNS(NS.SVG, 'defs'); // grid-pattern
gridPattern = svgdoc.createElementNS(NS.SVG, 'pattern');
assignAttributes(gridPattern, {
id: 'gridpattern',
patternUnits: 'userSpaceOnUse',
x: 0,
// -(value.strokeWidth / 2), // position for strokewidth
y: 0,
// -(value.strokeWidth / 2), // position for strokewidth
width: 100,
height: 100
});
gridimg = svgdoc.createElementNS(NS.SVG, 'image');
assignAttributes(gridimg, {
x: 0,
y: 0,
width: 100,
height: 100
});
gridPattern.append(gridimg);
gridDefs.append(gridPattern);
$('#canvasGrid').append(gridDefs); // grid-box
gridBox = svgdoc.createElementNS(NS.SVG, 'rect');
assignAttributes(gridBox, {
width: '100%',
height: '100%',
x: 0,
y: 0,
'stroke-width': 0,
stroke: 'none',
fill: 'url(#gridpattern)',
style: 'pointer-events: none; display:visible;'
});
$('#canvasGrid').append(gridBox);
/**
*
* @param {Float} zoom
* @returns {void}
*/
buttons = [{
id: 'view_grid',
icon: svgEditor.curConfig.extIconsPath + 'grid.png',
type: 'context',
panel: 'editor_panel',
events: {
click: function click() {
svgEditor.curConfig.showGrid = showGrid = !showGrid;
gridUpdate();
}
}
}];
return _context.abrupt("return", {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'grid-icon.xml',
zoomChanged: function zoomChanged(zoom) {
if (showGrid) {
updateGrid(svgCanvas.getZoom());
updateGrid(zoom);
}
$('#canvasGrid').toggle(showGrid);
$('#view_grid').toggleClass('push_button_pressed tool_button');
};
updateGrid = function _ref2(zoom) {
// TODO: Try this with <line> elements, then compare performance difference
var unit = units[svgEditor.curConfig.baseUnit]; // 1 = 1px
var uMulti = unit * zoom; // Calculate the main number interval
var rawM = 100 / uMulti;
var multi = 1;
intervals.some(function (num) {
multi = num;
return rawM <= num;
});
var bigInt = multi * uMulti; // Set the canvas size to the width of the container
hcanvas.width = bigInt;
hcanvas.height = bigInt;
var ctx = hcanvas.getContext('2d');
var curD = 0.5;
var part = bigInt / 10;
ctx.globalAlpha = 0.2;
ctx.strokeStyle = svgEditor.curConfig.gridColor;
for (var i = 1; i < 10; i++) {
var subD = Math.round(part * i) + 0.5; // const lineNum = (i % 2)?12:10;
var lineNum = 0;
ctx.moveTo(subD, bigInt);
ctx.lineTo(subD, lineNum);
ctx.moveTo(bigInt, subD);
ctx.lineTo(lineNum, subD);
},
callback: function callback() {
if (showGrid) {
gridUpdate();
}
},
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
})
});
ctx.stroke();
ctx.beginPath();
ctx.globalAlpha = 0.5;
ctx.moveTo(curD, bigInt);
ctx.lineTo(curD, 0);
ctx.moveTo(bigInt, curD);
ctx.lineTo(0, curD);
ctx.stroke();
var datauri = hcanvas.toDataURL('image/png');
gridimg.setAttribute('width', bigInt);
gridimg.setAttribute('height', bigInt);
gridimg.parentNode.setAttribute('width', bigInt);
gridimg.parentNode.setAttribute('height', bigInt);
svgCanvas.setHref(gridimg, datauri);
};
$ = _ref.$, NS = _ref.NS, getTypeMap = _ref.getTypeMap, importLocale = _ref.importLocale;
_context.next = 5;
return importLocale();
case 5:
strings = _context.sent;
svgEditor = this;
svgCanvas = svgEditor.canvas;
svgdoc = document.getElementById('svgcanvas').ownerDocument, assignAttributes = svgCanvas.assignAttributes, hcanvas = document.createElement('canvas'), canvBG = $('#canvasBackground'), units = getTypeMap(), intervals = [0.01, 0.1, 1, 10, 100, 1000];
showGrid = svgEditor.curConfig.showGrid || false;
$(hcanvas).hide().appendTo('body');
canvasGrid = svgdoc.createElementNS(NS.SVG, 'svg');
assignAttributes(canvasGrid, {
id: 'canvasGrid',
width: '100%',
height: '100%',
x: 0,
y: 0,
overflow: 'visible',
display: 'none'
});
canvBG.append(canvasGrid);
gridDefs = svgdoc.createElementNS(NS.SVG, 'defs'); // grid-pattern
gridPattern = svgdoc.createElementNS(NS.SVG, 'pattern');
assignAttributes(gridPattern, {
id: 'gridpattern',
patternUnits: 'userSpaceOnUse',
x: 0,
// -(value.strokeWidth / 2), // position for strokewidth
y: 0,
// -(value.strokeWidth / 2), // position for strokewidth
width: 100,
height: 100
});
gridimg = svgdoc.createElementNS(NS.SVG, 'image');
assignAttributes(gridimg, {
x: 0,
y: 0,
width: 100,
height: 100
});
gridPattern.append(gridimg);
gridDefs.append(gridPattern);
$('#canvasGrid').append(gridDefs); // grid-box
gridBox = svgdoc.createElementNS(NS.SVG, 'rect');
assignAttributes(gridBox, {
width: '100%',
height: '100%',
x: 0,
y: 0,
'stroke-width': 0,
stroke: 'none',
fill: 'url(#gridpattern)',
style: 'pointer-events: none; display:visible;'
});
$('#canvasGrid').append(gridBox);
/**
*
* @param {Float} zoom
* @returns {void}
*/
buttons = [{
id: 'view_grid',
icon: svgEditor.curConfig.extIconsPath + 'grid.png',
type: 'context',
panel: 'editor_panel',
events: {
click: function click() {
svgEditor.curConfig.showGrid = showGrid = !showGrid;
gridUpdate();
}
}
}];
return _context.abrupt("return", {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'grid-icon.xml',
zoomChanged: function zoomChanged(zoom) {
if (showGrid) {
updateGrid(zoom);
}
},
callback: function callback() {
if (showGrid) {
gridUpdate();
}
},
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
})
});
case 27:
case "end":
return _context.stop();
}
case 27:
case "end":
return _context.stop();
}
}, _callee, this);
}));
function init(_x) {
return _init.apply(this, arguments);
}
return init;
}()
}
}, null, this);
}
};
return extGrid;

View File

@ -1,42 +1,6 @@
var svgEditorExtension_helloworld = (function () {
'use strict';
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
}
@ -95,101 +59,91 @@ var svgEditorExtension_helloworld = (function () {
*/
var extHelloworld = {
name: 'helloworld',
init: function () {
var _init = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(_ref) {
var $, importLocale, strings, svgEditor, svgCanvas;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
$ = _ref.$, importLocale = _ref.importLocale;
_context.next = 3;
return importLocale();
init: function init(_ref) {
var $, importLocale, strings, svgEditor, svgCanvas;
return regeneratorRuntime.async(function init$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
$ = _ref.$, importLocale = _ref.importLocale;
_context.next = 3;
return regeneratorRuntime.awrap(importLocale());
case 3:
strings = _context.sent;
svgEditor = this;
svgCanvas = svgEditor.canvas;
return _context.abrupt("return", {
name: strings.name,
// For more notes on how to make an icon file, see the source of
// the helloworld-icon.xml
svgicons: svgEditor.curConfig.extIconsPath + 'helloworld-icon.xml',
// Multiple buttons can be added in this array
buttons: [{
// Must match the icon ID in helloworld-icon.xml
id: 'hello_world',
// Fallback, e.g., for `file:///` access
icon: svgEditor.curConfig.extIconsPath + 'helloworld.png',
// This indicates that the button will be added to the "mode"
// button panel on the left side
type: 'mode',
// Tooltip text
title: strings.buttons[0].title,
// Events
events: {
click: function click() {
// The action taken when the button is clicked on.
// For "mode" buttons, any other button will
// automatically be de-pressed.
svgCanvas.setMode('hello_world');
}
}
}],
// This is triggered when the main mouse button is pressed down
// on the editor canvas (not the tool panels)
mouseDown: function mouseDown() {
// Check the mode on mousedown
if (svgCanvas.getMode() === 'hello_world') {
// The returned object must include "started" with
// a value of true in order for mouseUp to be triggered
return {
started: true
};
}
return undefined;
},
// This is triggered from anywhere, but "started" must have been set
// to true (see above). Note that "opts" is an object with event info
mouseUp: function mouseUp(opts) {
// Check the mode on mouseup
if (svgCanvas.getMode() === 'hello_world') {
var zoom = svgCanvas.getZoom(); // Get the actual coordinate by dividing by the zoom value
var x = opts.mouse_x / zoom;
var y = opts.mouse_y / zoom; // We do our own formatting
var text = strings.text;
[['x', x], ['y', y]].forEach(function (_ref2) {
var _ref3 = _slicedToArray(_ref2, 2),
prop = _ref3[0],
val = _ref3[1];
text = text.replace('{' + prop + '}', val);
}); // Show the text using the custom alert function
$.alert(text);
case 3:
strings = _context.sent;
svgEditor = this;
svgCanvas = svgEditor.canvas;
return _context.abrupt("return", {
name: strings.name,
// For more notes on how to make an icon file, see the source of
// the helloworld-icon.xml
svgicons: svgEditor.curConfig.extIconsPath + 'helloworld-icon.xml',
// Multiple buttons can be added in this array
buttons: [{
// Must match the icon ID in helloworld-icon.xml
id: 'hello_world',
// Fallback, e.g., for `file:///` access
icon: svgEditor.curConfig.extIconsPath + 'helloworld.png',
// This indicates that the button will be added to the "mode"
// button panel on the left side
type: 'mode',
// Tooltip text
title: strings.buttons[0].title,
// Events
events: {
click: function click() {
// The action taken when the button is clicked on.
// For "mode" buttons, any other button will
// automatically be de-pressed.
svgCanvas.setMode('hello_world');
}
}
});
}],
// This is triggered when the main mouse button is pressed down
// on the editor canvas (not the tool panels)
mouseDown: function mouseDown() {
// Check the mode on mousedown
if (svgCanvas.getMode() === 'hello_world') {
// The returned object must include "started" with
// a value of true in order for mouseUp to be triggered
return {
started: true
};
}
case 7:
case "end":
return _context.stop();
}
return undefined;
},
// This is triggered from anywhere, but "started" must have been set
// to true (see above). Note that "opts" is an object with event info
mouseUp: function mouseUp(opts) {
// Check the mode on mouseup
if (svgCanvas.getMode() === 'hello_world') {
var zoom = svgCanvas.getZoom(); // Get the actual coordinate by dividing by the zoom value
var x = opts.mouse_x / zoom;
var y = opts.mouse_y / zoom; // We do our own formatting
var text = strings.text;
[['x', x], ['y', y]].forEach(function (_ref2) {
var _ref3 = _slicedToArray(_ref2, 2),
prop = _ref3[0],
val = _ref3[1];
text = text.replace('{' + prop + '}', val);
}); // Show the text using the custom alert function
$.alert(text);
}
}
});
case 7:
case "end":
return _context.stop();
}
}, _callee, this);
}));
function init(_x) {
return _init.apply(this, arguments);
}
return init;
}()
}
}, null, this);
}
};
return extHelloworld;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,42 +1,6 @@
var svgEditorExtension_mathjax = (function () {
'use strict';
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
/**
* Add any of the whitelisted attributes to the script tag.
* @param {HTMLScriptElement} script
@ -52,6 +16,14 @@ var svgEditorExtension_mathjax = (function () {
}
});
} // Additions by Brett
/**
*
* @author Brett Zamir (other items are from `dynamic-import-polyfill`)
* @param {string|string[]} url
* @param {PlainObject} [atts={}]
* @returns {Promise<void|Error>} Resolves to `undefined` or rejects with an `Error` upon a
* script loading error
*/
function importScript(url) {
var atts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@ -101,272 +73,253 @@ var svgEditorExtension_mathjax = (function () {
});
}
/* globals MathJax */
var extMathjax = {
name: 'mathjax',
init: function () {
var _init = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee2(_ref) {
var $, importLocale, strings, svgEditor, svgCanvas, mathjaxSrcSecure, uiStrings, math, locationX, locationY, mathjaxLoaded, saveMath, buttons;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
saveMath = function _ref2() {
var code = $('#mathjax_code_textarea').val(); // displaystyle to force MathJax NOT to use the inline style. Because it is
// less fancy!
init: function init(_ref) {
var $, importLocale, strings, svgEditor, svgCanvas, mathjaxSrcSecure, uiStrings, math, locationX, locationY, mathjaxLoaded, saveMath, buttons;
return regeneratorRuntime.async(function init$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
saveMath = function _ref2() {
var code = $('#mathjax_code_textarea').val(); // displaystyle to force MathJax NOT to use the inline style. Because it is
// less fancy!
MathJax.Hub.queue.Push(['Text', math, '\\displaystyle{' + code + '}']);
/*
* The MathJax library doesn't want to bloat your webpage so it creates
* every symbol (glymph) you need only once. These are saved in a `<svg>` on
* the top of your html document, just under the body tag. Each glymph has
* its unique id and is saved as a `<path>` in the `<defs>` tag of the `<svg>`
*
* Then when the symbols are needed in the rest of your html document they
* are refferd to by a `<use>` tag.
* Because of bug 1076 we can't just grab the defs tag on the top and add it
* to your formula's `<svg>` and copy the lot. So we have to replace each
* `<use>` tag by its `<path>`.
*/
MathJax.Hub.queue.Push(function () {
var mathjaxMath = $('.MathJax_SVG');
var svg = $(mathjaxMath.html());
svg.find('use').each(function () {
// TODO: find a less pragmatic and more elegant solution to this.
var id = $(this).attr('href') ? $(this).attr('href').slice(1) // Works in Chrome.
: $(this).attr('xlink:href').slice(1); // Works in Firefox.
var glymph = $('#' + id).clone().removeAttr('id');
var x = $(this).attr('x');
var y = $(this).attr('y');
var transform = $(this).attr('transform');
if (transform && (x || y)) {
glymph.attr('transform', transform + ' translate(' + x + ',' + y + ')');
} else if (transform) {
glymph.attr('transform', transform);
} else if (x || y) {
glymph.attr('transform', 'translate(' + x + ',' + y + ')');
}
$(this).replaceWith(glymph);
}); // Remove the style tag because it interferes with SVG-Edit.
svg.removeAttr('style');
svg.attr('xmlns', 'http://www.w3.org/2000/svg');
svgCanvas.importSvgString($('<div>').append(svg.clone()).html(), true);
svgCanvas.ungroupSelectedElement(); // TODO: To undo the adding of the Formula you now have to undo twice.
// This should only be once!
svgCanvas.moveSelectedElements(locationX, locationY, true);
});
};
$ = _ref.$, importLocale = _ref.importLocale;
_context2.next = 4;
return importLocale();
case 4:
strings = _context2.sent;
svgEditor = this;
svgCanvas = svgEditor.canvas; // Configuration of the MathJax extention.
// This will be added to the head tag before MathJax is loaded.
/* mathjaxConfiguration = `<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ['tex2jax.js'],
jax: ['input/TeX', 'output/SVG'],
showProcessingMessages: true,
showMathMenu: false,
showMathMenuMSIE: false,
errorSettings: {
message: ['[Math Processing Error]'],
style: {color: '#CC0000', 'font-style': 'italic'}
},
elements: [],
tex2jax: {
ignoreClass: 'tex2jax_ignore2', processClass: 'tex2jax_process2',
},
TeX: {
extensions: ['AMSmath.js', 'AMSsymbols.js', 'noErrors.js', 'noUndefined.js']
},
SVG: {
}
});
</script>`, */
// mathjaxSrc = 'http://cdn.mathjax.org/mathjax/latest/MathJax.js',
// Had been on https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_SVG.js
// Obtained Text-AMS-MML_SVG.js from https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.3/config/TeX-AMS-MML_SVG.js
mathjaxSrcSecure = 'mathjax/MathJax.min.js?config=TeX-AMS-MML_SVG.js', uiStrings = svgEditor.uiStrings;
mathjaxLoaded = false; // TODO: Implement language support. Move these uiStrings to the locale files and
// the code to the langReady callback. Also i18nize alert and HTML below
$.extend(uiStrings, {
mathjax: {
embed_svg: 'Save as mathematics',
embed_mathml: 'Save as figure',
svg_save_warning: 'The math will be transformed into a figure is manipulatable like everything else. You will not be able to manipulate the TeX-code anymore. ',
mathml_save_warning: 'Advised. The math will be saved as a figure.',
title: 'Mathematics code editor'
}
});
/**
MathJax.Hub.queue.Push(['Text', math, '\\displaystyle{' + code + '}']);
/*
* The MathJax library doesn't want to bloat your webpage so it creates
* every symbol (glymph) you need only once. These are saved in a `<svg>` on
* the top of your html document, just under the body tag. Each glymph has
* its unique id and is saved as a `<path>` in the `<defs>` tag of the `<svg>`
*
* @returns {void}
* Then when the symbols are needed in the rest of your html document they
* are refferd to by a `<use>` tag.
* Because of bug 1076 we can't just grab the defs tag on the top and add it
* to your formula's `<svg>` and copy the lot. So we have to replace each
* `<use>` tag by its `<path>`.
*/
buttons = [{
id: 'tool_mathjax',
type: 'mode',
icon: svgEditor.curConfig.extIconsPath + 'mathjax.png',
events: {
click: function () {
var _click = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee() {
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
// Set the mode.
svgCanvas.setMode('mathjax'); // Only load Mathjax when needed, we don't want to strain Svg-Edit any more.
// From this point on it is very probable that it will be needed, so load it.
MathJax.Hub.queue.Push(function () {
var mathjaxMath = $('.MathJax_SVG');
var svg = $(mathjaxMath.html());
svg.find('use').each(function () {
// TODO: find a less pragmatic and more elegant solution to this.
var id = $(this).attr('href') ? $(this).attr('href').slice(1) // Works in Chrome.
: $(this).attr('xlink:href').slice(1); // Works in Firefox.
if (!(mathjaxLoaded === false)) {
_context.next = 17;
break;
}
var glymph = $('#' + id).clone().removeAttr('id');
var x = $(this).attr('x');
var y = $(this).attr('y');
var transform = $(this).attr('transform');
$('<div id="mathjax">' + '<!-- Here is where MathJax creates the math -->' + '<div id="mathjax_creator" class="tex2jax_process" style="display:none">' + '$${}$$' + '</div>' + '<div id="mathjax_overlay"></div>' + '<div id="mathjax_container">' + '<div id="tool_mathjax_back" class="toolbar_button">' + '<button id="tool_mathjax_save">OK</button>' + '<button id="tool_mathjax_cancel">Cancel</button>' + '</div>' + '<fieldset>' + '<legend id="mathjax_legend">Mathematics Editor</legend>' + '<label>' + '<span id="mathjax_explication">Please type your mathematics in ' + '<a href="https://en.wikipedia.org/wiki/Help:Displaying_a_formula" target="_blank">TeX</a> code.</span></label>' + '<textarea id="mathjax_code_textarea" spellcheck="false"></textarea>' + '</fieldset>' + '</div>' + '</div>').insertAfter('#svg_prefs').hide(); // Make the MathEditor draggable.
$('#mathjax_container').draggable({
cancel: 'button,fieldset',
containment: 'window'
}); // Add functionality and picture to cancel button.
$('#tool_mathjax_cancel').prepend($.getSvgIcon('cancel', true)).on('click touched', function () {
$('#mathjax').hide();
}); // Add functionality and picture to the save button.
$('#tool_mathjax_save').prepend($.getSvgIcon('ok', true)).on('click touched', function () {
saveMath();
$('#mathjax').hide();
}); // MathJax preprocessing has to ignore most of the page.
$('body').addClass('tex2jax_ignore'); // Now get (and run) the MathJax Library.
// Todo: insert script with modules once widely supported
// and if MathJax (and its `TeX-AMS-MML_SVG.js` dependency) ends up
// providing an ES6 module export: https://github.com/mathjax/MathJax/issues/1998
/*
const modularVersion = !('svgEditor' in window) ||
!window.svgEditor ||
window.svgEditor.modules !== false;
// Add as second argument to `importScript`
{
type: modularVersion
? 'module' // Make this the default when widely supported
: 'text/javascript'
}
// If only using modules, just use this:
const {default: MathJax} = await importModule( // or `import()` when widely supported
svgEditor.curConfig.extIconsPath + mathjaxSrcSecure
);
*/
// We use `extIconsPath` here for now as it does not vary with
// the modular type as does `extPath`
_context.prev = 7;
_context.next = 10;
return importScript(svgEditor.curConfig.extIconsPath + mathjaxSrcSecure);
case 10:
// 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];
console.log(math); // eslint-disable-line no-console
mathjaxLoaded = true;
console.log('MathJax Loaded'); // eslint-disable-line no-console
});
_context.next = 17;
break;
case 13:
_context.prev = 13;
_context.t0 = _context["catch"](7);
console.log('Failed loading MathJax.'); // eslint-disable-line no-console
$.alert('Failed loading MathJax. You will not be able to change the mathematics.');
case 17:
case "end":
return _context.stop();
}
}
}, _callee, null, [[7, 13]]);
}));
function click() {
return _click.apply(this, arguments);
}
return click;
}()
}
}];
return _context2.abrupt("return", {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'mathjax-icons.xml',
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
}),
mouseDown: function mouseDown() {
if (svgCanvas.getMode() === 'mathjax') {
return {
started: true
};
if (transform && (x || y)) {
glymph.attr('transform', transform + ' translate(' + x + ',' + y + ')');
} else if (transform) {
glymph.attr('transform', transform);
} else if (x || y) {
glymph.attr('transform', 'translate(' + x + ',' + y + ')');
}
return undefined;
},
mouseUp: function mouseUp(opts) {
if (svgCanvas.getMode() === 'mathjax') {
// Get the coordinates from your mouse.
var zoom = svgCanvas.getZoom(); // Get the actual coordinate by dividing by the zoom value
$(this).replaceWith(glymph);
}); // Remove the style tag because it interferes with SVG-Edit.
locationX = opts.mouse_x / zoom;
locationY = opts.mouse_y / zoom;
$('#mathjax').show();
return {
started: false
}; // Otherwise the last selected object dissapears.
}
svg.removeAttr('style');
svg.attr('xmlns', 'http://www.w3.org/2000/svg');
svgCanvas.importSvgString($('<div>').append(svg.clone()).html(), true);
svgCanvas.ungroupSelectedElement(); // TODO: To undo the adding of the Formula you now have to undo twice.
// This should only be once!
return undefined;
},
callback: function callback() {
$('<style>').text('#mathjax fieldset{' + 'padding: 5px;' + 'margin: 5px;' + 'border: 1px solid #DDD;' + '}' + '#mathjax label{' + 'display: block;' + 'margin: .5em;' + '}' + '#mathjax legend {' + 'max-width:195px;' + '}' + '#mathjax_overlay {' + 'position: absolute;' + 'top: 0;' + 'left: 0;' + 'right: 0;' + 'bottom: 0;' + 'background-color: black;' + 'opacity: 0.6;' + 'z-index: 20000;' + '}' + '#mathjax_container {' + 'position: absolute;' + 'top: 50px;' + 'padding: 10px;' + 'background-color: #B0B0B0;' + 'border: 1px outset #777;' + 'opacity: 1.0;' + 'font-family: Verdana, Helvetica, sans-serif;' + 'font-size: .8em;' + 'z-index: 20001;' + '}' + '#tool_mathjax_back {' + 'margin-left: 1em;' + 'overflow: auto;' + '}' + '#mathjax_legend{' + 'font-weight: bold;' + 'font-size:1.1em;' + '}' + '#mathjax_code_textarea {\\n' + 'margin: 5px .7em;' + 'overflow: hidden;' + 'width: 416px;' + 'display: block;' + 'height: 100px;' + '}').appendTo('head'); // Add the MathJax configuration.
// $(mathjaxConfiguration).appendTo('head');
}
svgCanvas.moveSelectedElements(locationX, locationY, true);
});
};
case 12:
case "end":
return _context2.stop();
}
$ = _ref.$, importLocale = _ref.importLocale;
_context2.next = 4;
return regeneratorRuntime.awrap(importLocale());
case 4:
strings = _context2.sent;
svgEditor = this;
svgCanvas = svgEditor.canvas; // Configuration of the MathJax extention.
// This will be added to the head tag before MathJax is loaded.
/* mathjaxConfiguration = `<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ['tex2jax.js'],
jax: ['input/TeX', 'output/SVG'],
showProcessingMessages: true,
showMathMenu: false,
showMathMenuMSIE: false,
errorSettings: {
message: ['[Math Processing Error]'],
style: {color: '#CC0000', 'font-style': 'italic'}
},
elements: [],
tex2jax: {
ignoreClass: 'tex2jax_ignore2', processClass: 'tex2jax_process2',
},
TeX: {
extensions: ['AMSmath.js', 'AMSsymbols.js', 'noErrors.js', 'noUndefined.js']
},
SVG: {
}
});
</script>`, */
// mathjaxSrc = 'http://cdn.mathjax.org/mathjax/latest/MathJax.js',
// Had been on https://c328740.ssl.cf1.rackcdn.com/mathjax/latest/MathJax.js?config=TeX-AMS-MML_SVG.js
// Obtained Text-AMS-MML_SVG.js from https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.3/config/TeX-AMS-MML_SVG.js
mathjaxSrcSecure = 'mathjax/MathJax.min.js?config=TeX-AMS-MML_SVG.js', uiStrings = svgEditor.uiStrings;
mathjaxLoaded = false; // TODO: Implement language support. Move these uiStrings to the locale files and
// the code to the langReady callback. Also i18nize alert and HTML below
$.extend(uiStrings, {
mathjax: {
embed_svg: 'Save as mathematics',
embed_mathml: 'Save as figure',
svg_save_warning: 'The math will be transformed into a figure is manipulatable like everything else. You will not be able to manipulate the TeX-code anymore. ',
mathml_save_warning: 'Advised. The math will be saved as a figure.',
title: 'Mathematics code editor'
}
});
/**
*
* @returns {void}
*/
buttons = [{
id: 'tool_mathjax',
type: 'mode',
icon: svgEditor.curConfig.extIconsPath + 'mathjax.png',
events: {
click: function click() {
return regeneratorRuntime.async(function click$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
// Set the mode.
svgCanvas.setMode('mathjax'); // Only load Mathjax when needed, we don't want to strain Svg-Edit any more.
// From this point on it is very probable that it will be needed, so load it.
if (!(mathjaxLoaded === false)) {
_context.next = 17;
break;
}
$('<div id="mathjax">' + '<!-- Here is where MathJax creates the math -->' + '<div id="mathjax_creator" class="tex2jax_process" style="display:none">' + '$${}$$' + '</div>' + '<div id="mathjax_overlay"></div>' + '<div id="mathjax_container">' + '<div id="tool_mathjax_back" class="toolbar_button">' + '<button id="tool_mathjax_save">OK</button>' + '<button id="tool_mathjax_cancel">Cancel</button>' + '</div>' + '<fieldset>' + '<legend id="mathjax_legend">Mathematics Editor</legend>' + '<label>' + '<span id="mathjax_explication">Please type your mathematics in ' + '<a href="https://en.wikipedia.org/wiki/Help:Displaying_a_formula" target="_blank">TeX</a> code.</span></label>' + '<textarea id="mathjax_code_textarea" spellcheck="false"></textarea>' + '</fieldset>' + '</div>' + '</div>').insertAfter('#svg_prefs').hide(); // Make the MathEditor draggable.
$('#mathjax_container').draggable({
cancel: 'button,fieldset',
containment: 'window'
}); // Add functionality and picture to cancel button.
$('#tool_mathjax_cancel').prepend($.getSvgIcon('cancel', true)).on('click touched', function () {
$('#mathjax').hide();
}); // Add functionality and picture to the save button.
$('#tool_mathjax_save').prepend($.getSvgIcon('ok', true)).on('click touched', function () {
saveMath();
$('#mathjax').hide();
}); // MathJax preprocessing has to ignore most of the page.
$('body').addClass('tex2jax_ignore'); // Now get (and run) the MathJax Library.
// Todo: insert script with modules once widely supported
// and if MathJax (and its `TeX-AMS-MML_SVG.js` dependency) ends up
// providing an ES6 module export: https://github.com/mathjax/MathJax/issues/1998
/*
const modularVersion = !('svgEditor' in window) ||
!window.svgEditor ||
window.svgEditor.modules !== false;
// Add as second argument to `importScript`
{
type: modularVersion
? 'module' // Make this the default when widely supported
: 'text/javascript'
}
// If only using modules, just use this:
const {default: MathJax} = await importModule( // or `import()` when widely supported
svgEditor.curConfig.extIconsPath + mathjaxSrcSecure
);
*/
// We use `extIconsPath` here for now as it does not vary with
// the modular type as does `extPath`
_context.prev = 7;
_context.next = 10;
return regeneratorRuntime.awrap(importScript(svgEditor.curConfig.extIconsPath + mathjaxSrcSecure));
case 10:
// 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];
console.log(math); // eslint-disable-line no-console
mathjaxLoaded = true;
console.log('MathJax Loaded'); // eslint-disable-line no-console
});
_context.next = 17;
break;
case 13:
_context.prev = 13;
_context.t0 = _context["catch"](7);
console.log('Failed loading MathJax.'); // eslint-disable-line no-console
$.alert('Failed loading MathJax. You will not be able to change the mathematics.');
case 17:
case "end":
return _context.stop();
}
}
}, null, null, [[7, 13]]);
}
}
}];
return _context2.abrupt("return", {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'mathjax-icons.xml',
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
}),
mouseDown: function mouseDown() {
if (svgCanvas.getMode() === 'mathjax') {
return {
started: true
};
}
return undefined;
},
mouseUp: function mouseUp(opts) {
if (svgCanvas.getMode() === 'mathjax') {
// Get the coordinates from your mouse.
var zoom = svgCanvas.getZoom(); // Get the actual coordinate by dividing by the zoom value
locationX = opts.mouse_x / zoom;
locationY = opts.mouse_y / zoom;
$('#mathjax').show();
return {
started: false
}; // Otherwise the last selected object dissapears.
}
return undefined;
},
callback: function callback() {
$('<style>').text('#mathjax fieldset{' + 'padding: 5px;' + 'margin: 5px;' + 'border: 1px solid #DDD;' + '}' + '#mathjax label{' + 'display: block;' + 'margin: .5em;' + '}' + '#mathjax legend {' + 'max-width:195px;' + '}' + '#mathjax_overlay {' + 'position: absolute;' + 'top: 0;' + 'left: 0;' + 'right: 0;' + 'bottom: 0;' + 'background-color: black;' + 'opacity: 0.6;' + 'z-index: 20000;' + '}' + '#mathjax_container {' + 'position: absolute;' + 'top: 50px;' + 'padding: 10px;' + 'background-color: #B0B0B0;' + 'border: 1px outset #777;' + 'opacity: 1.0;' + 'font-family: Verdana, Helvetica, sans-serif;' + 'font-size: .8em;' + 'z-index: 20001;' + '}' + '#tool_mathjax_back {' + 'margin-left: 1em;' + 'overflow: auto;' + '}' + '#mathjax_legend{' + 'font-weight: bold;' + 'font-size:1.1em;' + '}' + '#mathjax_code_textarea {\\n' + 'margin: 5px .7em;' + 'overflow: hidden;' + 'width: 416px;' + 'display: block;' + 'height: 100px;' + '}').appendTo('head'); // Add the MathJax configuration.
// $(mathjaxConfiguration).appendTo('head');
}
});
case 12:
case "end":
return _context2.stop();
}
}, _callee2, this);
}));
function init(_x) {
return _init.apply(this, arguments);
}
return init;
}()
}
}, null, this);
}
};
return extMathjax;

View File

@ -1,42 +1,6 @@
var svgEditorExtension_panning = (function () {
'use strict';
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
/**
* ext-panning.js
*
@ -51,76 +15,66 @@ var svgEditorExtension_panning = (function () {
*/
var extPanning = {
name: 'panning',
init: function () {
var _init = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(_ref) {
var importLocale, strings, svgEditor, svgCanvas, buttons;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
importLocale = _ref.importLocale;
_context.next = 3;
return importLocale();
init: function init(_ref) {
var importLocale, strings, svgEditor, svgCanvas, buttons;
return regeneratorRuntime.async(function init$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
importLocale = _ref.importLocale;
_context.next = 3;
return regeneratorRuntime.awrap(importLocale());
case 3:
strings = _context.sent;
svgEditor = this;
svgCanvas = svgEditor.canvas;
buttons = [{
id: 'ext-panning',
icon: svgEditor.curConfig.extIconsPath + 'panning.png',
type: 'mode',
events: {
click: function click() {
svgCanvas.setMode('ext-panning');
}
case 3:
strings = _context.sent;
svgEditor = this;
svgCanvas = svgEditor.canvas;
buttons = [{
id: 'ext-panning',
icon: svgEditor.curConfig.extIconsPath + 'panning.png',
type: 'mode',
events: {
click: function click() {
svgCanvas.setMode('ext-panning');
}
}];
return _context.abrupt("return", {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'ext-panning.xml',
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
}),
mouseDown: function mouseDown() {
if (svgCanvas.getMode() === 'ext-panning') {
svgEditor.setPanning(true);
return {
started: true
};
}
return undefined;
},
mouseUp: function mouseUp() {
if (svgCanvas.getMode() === 'ext-panning') {
svgEditor.setPanning(false);
return {
keep: false,
element: null
};
}
return undefined;
}
}];
return _context.abrupt("return", {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'ext-panning.xml',
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
}),
mouseDown: function mouseDown() {
if (svgCanvas.getMode() === 'ext-panning') {
svgEditor.setPanning(true);
return {
started: true
};
}
});
case 8:
case "end":
return _context.stop();
}
return undefined;
},
mouseUp: function mouseUp() {
if (svgCanvas.getMode() === 'ext-panning') {
svgEditor.setPanning(false);
return {
keep: false,
element: null
};
}
return undefined;
}
});
case 8:
case "end":
return _context.stop();
}
}, _callee, this);
}));
function init(_x) {
return _init.apply(this, arguments);
}
return init;
}()
}
}, null, this);
}
};
return extPanning;

File diff suppressed because it is too large Load Diff

View File

@ -1,42 +1,6 @@
var svgEditorExtension_polygon = (function () {
'use strict';
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
/**
* ext-polygon.js
*
@ -46,268 +10,258 @@ var svgEditorExtension_polygon = (function () {
*/
var extPolygon = {
name: 'polygon',
init: function () {
var _init = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(S) {
var svgEditor, svgCanvas, $, importLocale, editingitex, strings, selElems, started, newFO, showPanel, setAttr, cot, sec, buttons, contextTools;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
sec = function _ref4(n) {
return 1 / Math.cos(n);
};
init: function init(S) {
var svgEditor, svgCanvas, $, importLocale, editingitex, strings, selElems, started, newFO, showPanel, setAttr, cot, sec, buttons, contextTools;
return regeneratorRuntime.async(function init$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
sec = function _ref4(n) {
return 1 / Math.cos(n);
};
cot = function _ref3(n) {
return 1 / Math.tan(n);
};
cot = function _ref3(n) {
return 1 / Math.tan(n);
};
setAttr = function _ref2(attr, val) {
svgCanvas.changeSelectedAttribute(attr, val);
svgCanvas.call('changed', selElems);
};
setAttr = function _ref2(attr, val) {
svgCanvas.changeSelectedAttribute(attr, val);
svgCanvas.call('changed', selElems);
};
showPanel = function _ref(on) {
var fcRules = $('#fc_rules');
showPanel = function _ref(on) {
var fcRules = $('#fc_rules');
if (!fcRules.length) {
fcRules = $('<style id="fc_rules"></style>').appendTo('head');
}
fcRules.text(!on ? '' : ' #tool_topath { display: none !important; }');
$('#polygon_panel').toggle(on);
};
svgEditor = this;
svgCanvas = svgEditor.canvas;
$ = S.$, importLocale = S.importLocale, editingitex = false;
_context.next = 9;
return importLocale();
case 9:
strings = _context.sent;
/**
* Obtained from http://code.google.com/p/passenger-top/source/browse/instiki/public/svg-edit/editor/extensions/ext-itex.js?r=3
* This function sets the content of of the currently-selected foreignObject element,
* based on the itex contained in string.
* @param {string} tex The itex text.
* @returns {boolean} This function returns false if the set was unsuccessful, true otherwise.
*/
/*
function setItexString(tex) {
const mathns = 'http://www.w3.org/1998/Math/MathML',
xmlnsns = 'http://www.w3.org/2000/xmlns/',
ajaxEndpoint = '../../itex';
const elt = selElems[0];
try {
const math = svgdoc.createElementNS(mathns, 'math');
math.setAttributeNS(xmlnsns, 'xmlns', mathns);
math.setAttribute('display', 'inline');
const semantics = document.createElementNS(mathns, 'semantics');
const annotation = document.createElementNS(mathns, 'annotation');
annotation.setAttribute('encoding', 'application/x-tex');
annotation.textContent = tex;
const mrow = document.createElementNS(mathns, 'mrow');
semantics.append(mrow, annotation);
math.append(semantics);
// make an AJAX request to the server, to get the MathML
$.post(ajaxEndpoint, {tex, display: 'inline'}, function(data){
const children = data.documentElement.childNodes;
while (children.length > 0) {
mrow.append(svgdoc.adoptNode(children[0], true));
}
svgCanvas.sanitizeSvg(math);
svgCanvas.call('changed', [elt]);
});
elt.firstChild.replaceWith(math);
svgCanvas.call('changed', [elt]);
svgCanvas.clearSelection();
} catch(e) {
console.log(e);
return false;
}
return true;
if (!fcRules.length) {
fcRules = $('<style id="fc_rules"></style>').appendTo('head');
}
*/
buttons = [{
id: 'tool_polygon',
icon: svgEditor.curConfig.extIconsPath + 'polygon.png',
type: 'mode',
position: 11,
events: {
click: function click() {
svgCanvas.setMode('polygon');
showPanel(true);
fcRules.text(!on ? '' : ' #tool_topath { display: none !important; }');
$('#polygon_panel').toggle(on);
};
svgEditor = this;
svgCanvas = svgEditor.canvas;
$ = S.$, importLocale = S.importLocale, editingitex = false;
_context.next = 9;
return regeneratorRuntime.awrap(importLocale());
case 9:
strings = _context.sent;
/**
* Obtained from http://code.google.com/p/passenger-top/source/browse/instiki/public/svg-edit/editor/extensions/ext-itex.js?r=3
* This function sets the content of of the currently-selected foreignObject element,
* based on the itex contained in string.
* @param {string} tex The itex text.
* @returns {boolean} This function returns false if the set was unsuccessful, true otherwise.
*/
/*
function setItexString(tex) {
const mathns = 'http://www.w3.org/1998/Math/MathML',
xmlnsns = 'http://www.w3.org/2000/xmlns/',
ajaxEndpoint = '../../itex';
const elt = selElems[0];
try {
const math = svgdoc.createElementNS(mathns, 'math');
math.setAttributeNS(xmlnsns, 'xmlns', mathns);
math.setAttribute('display', 'inline');
const semantics = document.createElementNS(mathns, 'semantics');
const annotation = document.createElementNS(mathns, 'annotation');
annotation.setAttribute('encoding', 'application/x-tex');
annotation.textContent = tex;
const mrow = document.createElementNS(mathns, 'mrow');
semantics.append(mrow, annotation);
math.append(semantics);
// make an AJAX request to the server, to get the MathML
$.post(ajaxEndpoint, {tex, display: 'inline'}, function(data){
const children = data.documentElement.childNodes;
while (children.length > 0) {
mrow.append(svgdoc.adoptNode(children[0], true));
}
svgCanvas.sanitizeSvg(math);
svgCanvas.call('changed', [elt]);
});
elt.firstChild.replaceWith(math);
svgCanvas.call('changed', [elt]);
svgCanvas.clearSelection();
} catch(e) {
console.log(e);
return false;
}
return true;
}
*/
buttons = [{
id: 'tool_polygon',
icon: svgEditor.curConfig.extIconsPath + 'polygon.png',
type: 'mode',
position: 11,
events: {
click: function click() {
svgCanvas.setMode('polygon');
showPanel(true);
}
}];
contextTools = [{
type: 'input',
panel: 'polygon_panel',
id: 'polySides',
size: 3,
defval: 5,
events: {
change: function change() {
setAttr('sides', this.value);
}
}
}];
contextTools = [{
type: 'input',
panel: 'polygon_panel',
id: 'polySides',
size: 3,
defval: 5,
events: {
change: function change() {
setAttr('sides', this.value);
}
}];
return _context.abrupt("return", {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'polygon-icons.svg',
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
}),
context_tools: strings.contextTools.map(function (contextTool, i) {
return Object.assign(contextTools[i], contextTool);
}),
callback: function callback() {
$('#polygon_panel').hide();
}
}];
return _context.abrupt("return", {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'polygon-icons.svg',
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
}),
context_tools: strings.contextTools.map(function (contextTool, i) {
return Object.assign(contextTools[i], contextTool);
}),
callback: function callback() {
$('#polygon_panel').hide();
setTimeout(function () {
// Create source save/cancel buttons
setTimeout(function () {
// Create source save/cancel buttons
/* const save = */
$('#tool_source_save').clone().hide().attr('id', 'polygon_save').unbind().appendTo('#tool_source_back').click(function () {
if (!editingitex) {
return;
} // Todo: Uncomment the setItexString() function above and handle ajaxEndpoint?
// setSelectMode();
});
/* const cancel = */
$('#tool_source_cancel').clone().hide().attr('id', 'polygon_cancel').unbind().appendTo('#tool_source_back').click(function () {
});
}, 3000);
},
mouseDown: function mouseDown(opts) {
if (svgCanvas.getMode() !== 'polygon') {
return undefined;
} // const e = opts.event;
var rgb = svgCanvas.getColor('fill'); // const ccRgbEl = rgb.substring(1, rgb.length);
var sRgb = svgCanvas.getColor('stroke'); // ccSRgbEl = sRgb.substring(1, rgb.length);
var sWidth = svgCanvas.getStrokeWidth();
started = true;
newFO = svgCanvas.addSVGElementFromJson({
element: 'polygon',
attr: {
cx: opts.start_x,
cy: opts.start_y,
id: svgCanvas.getNextId(),
shape: 'regularPoly',
sides: document.getElementById('polySides').value,
orient: 'x',
edge: 0,
fill: rgb,
strokecolor: sRgb,
strokeWidth: sWidth
}
/* const save = */
$('#tool_source_save').clone().hide().attr('id', 'polygon_save').unbind().appendTo('#tool_source_back').click(function () {
if (!editingitex) {
return;
} // Todo: Uncomment the setItexString() function above and handle ajaxEndpoint?
// setSelectMode();
});
return {
started: true
};
},
mouseMove: function mouseMove(opts) {
if (!started || svgCanvas.getMode() !== 'polygon') {
return undefined;
} // const e = opts.event;
/* const cancel = */
$('#tool_source_cancel').clone().hide().attr('id', 'polygon_cancel').unbind().appendTo('#tool_source_back').click(function () {
});
}, 3000);
},
mouseDown: function mouseDown(opts) {
if (svgCanvas.getMode() !== 'polygon') {
return undefined;
} // const e = opts.event;
var c = $(newFO).attr(['cx', 'cy', 'sides', 'orient', 'fill', 'strokecolor', 'strokeWidth']);
var x = opts.mouse_x;
var y = opts.mouse_y;
var cx = c.cx,
cy = c.cy,
fill = c.fill,
strokecolor = c.strokecolor,
strokeWidth = c.strokeWidth,
sides = c.sides,
edg = Math.sqrt((x - cx) * (x - cx) + (y - cy) * (y - cy)) / 1.5;
newFO.setAttribute('edge', edg);
var inradius = edg / 2 * cot(Math.PI / sides);
var circumradius = inradius * sec(Math.PI / sides);
var points = '';
var rgb = svgCanvas.getColor('fill'); // const ccRgbEl = rgb.substring(1, rgb.length);
for (var s = 0; sides >= s; s++) {
var angle = 2.0 * Math.PI * s / sides;
x = circumradius * Math.cos(angle) + cx;
y = circumradius * Math.sin(angle) + cy;
points += x + ',' + y + ' ';
} // const poly = newFO.createElementNS(NS.SVG, 'polygon');
var sRgb = svgCanvas.getColor('stroke'); // ccSRgbEl = sRgb.substring(1, rgb.length);
newFO.setAttribute('points', points);
newFO.setAttribute('fill', fill);
newFO.setAttribute('stroke', strokecolor);
newFO.setAttribute('stroke-width', strokeWidth); // newFO.setAttribute('transform', 'rotate(-90)');
// const shape = newFO.getAttribute('shape');
// newFO.append(poly);
// DrawPoly(cx, cy, sides, edg, orient);
return {
started: true
};
},
mouseUp: function mouseUp(opts) {
if (svgCanvas.getMode() !== 'polygon') {
return undefined;
var sWidth = svgCanvas.getStrokeWidth();
started = true;
newFO = svgCanvas.addSVGElementFromJson({
element: 'polygon',
attr: {
cx: opts.start_x,
cy: opts.start_y,
id: svgCanvas.getNextId(),
shape: 'regularPoly',
sides: document.getElementById('polySides').value,
orient: 'x',
edge: 0,
fill: rgb,
strokecolor: sRgb,
strokeWidth: sWidth
}
});
return {
started: true
};
},
mouseMove: function mouseMove(opts) {
if (!started || svgCanvas.getMode() !== 'polygon') {
return undefined;
} // const e = opts.event;
var attrs = $(newFO).attr('edge');
var keep = attrs.edge !== '0'; // svgCanvas.addToSelection([newFO], true);
return {
keep: keep,
element: newFO
};
},
selectedChanged: function selectedChanged(opts) {
// Use this to update the current selected elements
selElems = opts.elems;
var i = selElems.length;
var c = $(newFO).attr(['cx', 'cy', 'sides', 'orient', 'fill', 'strokecolor', 'strokeWidth']);
var x = opts.mouse_x;
var y = opts.mouse_y;
var cx = c.cx,
cy = c.cy,
fill = c.fill,
strokecolor = c.strokecolor,
strokeWidth = c.strokeWidth,
sides = c.sides,
edg = Math.sqrt((x - cx) * (x - cx) + (y - cy) * (y - cy)) / 1.5;
newFO.setAttribute('edge', edg);
var inradius = edg / 2 * cot(Math.PI / sides);
var circumradius = inradius * sec(Math.PI / sides);
var points = '';
while (i--) {
var elem = selElems[i];
for (var s = 0; sides >= s; s++) {
var angle = 2.0 * Math.PI * s / sides;
x = circumradius * Math.cos(angle) + cx;
y = circumradius * Math.sin(angle) + cy;
points += x + ',' + y + ' ';
} // const poly = newFO.createElementNS(NS.SVG, 'polygon');
if (elem && elem.getAttribute('shape') === 'regularPoly') {
if (opts.selectedElement && !opts.multiselected) {
$('#polySides').val(elem.getAttribute('sides'));
showPanel(true);
} else {
showPanel(false);
}
newFO.setAttribute('points', points);
newFO.setAttribute('fill', fill);
newFO.setAttribute('stroke', strokecolor);
newFO.setAttribute('stroke-width', strokeWidth); // newFO.setAttribute('transform', 'rotate(-90)');
// const shape = newFO.getAttribute('shape');
// newFO.append(poly);
// DrawPoly(cx, cy, sides, edg, orient);
return {
started: true
};
},
mouseUp: function mouseUp(opts) {
if (svgCanvas.getMode() !== 'polygon') {
return undefined;
}
var attrs = $(newFO).attr('edge');
var keep = attrs.edge !== '0'; // svgCanvas.addToSelection([newFO], true);
return {
keep: keep,
element: newFO
};
},
selectedChanged: function selectedChanged(opts) {
// Use this to update the current selected elements
selElems = opts.elems;
var i = selElems.length;
while (i--) {
var elem = selElems[i];
if (elem && elem.getAttribute('shape') === 'regularPoly') {
if (opts.selectedElement && !opts.multiselected) {
$('#polySides').val(elem.getAttribute('sides'));
showPanel(true);
} else {
showPanel(false);
}
} else {
showPanel(false);
}
},
elementChanged: function elementChanged(opts) {// const elem = opts.elems[0];
}
});
},
elementChanged: function elementChanged(opts) {// const elem = opts.elems[0];
}
});
case 13:
case "end":
return _context.stop();
}
case 13:
case "end":
return _context.stop();
}
}, _callee, this);
}));
function init(_x) {
return _init.apply(this, arguments);
}
return init;
}()
}
}, null, this);
}
};
return extPolygon;

View File

@ -15,42 +15,6 @@ var svgEditorExtension_server_moinsave = (function () {
return _typeof(obj);
}
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
@ -4684,36 +4648,26 @@ var svgEditorExtension_server_moinsave = (function () {
}; // load from url
svg.load =
/*#__PURE__*/
function () {
var _ref12 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(ctx, url) {
var dom;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return svg.ajax(url, true);
svg.load = function _callee(ctx, url) {
var dom;
return regeneratorRuntime.async(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return regeneratorRuntime.awrap(svg.ajax(url, true));
case 2:
dom = _context.sent;
return _context.abrupt("return", svg.loadXml(ctx, dom));
case 2:
dom = _context.sent;
return _context.abrupt("return", svg.loadXml(ctx, dom));
case 4:
case "end":
return _context.stop();
}
case 4:
case "end":
return _context.stop();
}
}, _callee);
}));
return function (_x2, _x3) {
return _ref12.apply(this, arguments);
};
}(); // load from xml
}
});
}; // load from xml
svg.loadXml = function (ctx, xml) {
@ -4934,9 +4888,9 @@ var svgEditorExtension_server_moinsave = (function () {
checkPath: function checkPath(element, ctx) {
var _this26 = this;
this.events.forEach(function (_ref13, i) {
var x = _ref13.x,
y = _ref13.y;
this.events.forEach(function (_ref12, i) {
var x = _ref12.x,
y = _ref12.y;
if (ctx.isPointInPath && ctx.isPointInPath(x, y)) {
_this26.eventElements[i] = element;
@ -4946,9 +4900,9 @@ var svgEditorExtension_server_moinsave = (function () {
checkBoundingBox: function checkBoundingBox(element, bb) {
var _this27 = this;
this.events.forEach(function (_ref14, i) {
var x = _ref14.x,
y = _ref14.y;
this.events.forEach(function (_ref13, i) {
var x = _ref13.x,
y = _ref13.y;
if (bb.isPointInBox(x, y)) {
_this27.eventElements[i] = element;
@ -4992,103 +4946,83 @@ var svgEditorExtension_server_moinsave = (function () {
var extServer_moinsave = {
name: 'server_moinsave',
init: function () {
var _init = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee2(_ref) {
var $, encode64, importLocale, strings, svgEditor, svgCanvas, saveSvgAction;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
$ = _ref.$, encode64 = _ref.encode64, importLocale = _ref.importLocale;
_context2.next = 3;
return importLocale();
init: function init(_ref) {
var $, encode64, importLocale, strings, svgEditor, svgCanvas, saveSvgAction;
return regeneratorRuntime.async(function init$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
$ = _ref.$, encode64 = _ref.encode64, importLocale = _ref.importLocale;
_context2.next = 3;
return regeneratorRuntime.awrap(importLocale());
case 3:
strings = _context2.sent;
svgEditor = this;
svgCanvas = svgEditor.canvas;
saveSvgAction = '/+modify'; // Create upload target (hidden iframe)
// Hiding by size instead of display to avoid FF console errors
// with `getBBox` in browser.js `supportsPathBBox_`)
case 3:
strings = _context2.sent;
svgEditor = this;
svgCanvas = svgEditor.canvas;
saveSvgAction = '/+modify'; // Create upload target (hidden iframe)
// Hiding by size instead of display to avoid FF console errors
// with `getBBox` in browser.js `supportsPathBBox_`)
/* const target = */
/* const target = */
$("<iframe name=\"output_frame\" title=\"".concat(strings.hiddenframe, "\"\n style=\"width: 0; height: 0;\" src=\"#\"/>")).appendTo('body');
svgEditor.setCustomHandlers({
save: function () {
var _save = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(win, data) {
var svg, qstr, _qstr$substr$split, _qstr$substr$split2, name, svgData, c, datauri, pngData;
$("<iframe name=\"output_frame\" title=\"".concat(strings.hiddenframe, "\"\n style=\"width: 0; height: 0;\" src=\"#\"/>")).appendTo('body');
svgEditor.setCustomHandlers({
save: function save(win, data) {
var svg, qstr, _qstr$substr$split, _qstr$substr$split2, name, svgData, c, datauri, pngData;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
svg = '<?xml version="1.0"?>\n' + data;
qstr = $.param.querystring();
_qstr$substr$split = qstr.substr(9).split('/+get/'), _qstr$substr$split2 = _slicedToArray(_qstr$substr$split, 2), name = _qstr$substr$split2[1];
svgData = encode64(svg);
return regeneratorRuntime.async(function save$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
svg = '<?xml version="1.0"?>\n' + data;
qstr = $.param.querystring();
_qstr$substr$split = qstr.substr(9).split('/+get/'), _qstr$substr$split2 = _slicedToArray(_qstr$substr$split, 2), name = _qstr$substr$split2[1];
svgData = encode64(svg);
if (!$('#export_canvas').length) {
$('<canvas>', {
id: 'export_canvas'
}).hide().appendTo('body');
}
c = $('#export_canvas')[0];
c.width = svgCanvas.contentW;
c.height = svgCanvas.contentH;
_context.next = 10;
return canvg(c, svg);
case 10:
datauri = c.toDataURL('image/png'); // const {uiStrings} = svgEditor;
pngData = encode64(datauri); // Brett: This encoding seems unnecessary
/* const form = */
$('<form>').attr({
method: 'post',
action: saveSvgAction + '/' + name,
target: 'output_frame'
}).append("\n <input type=\"hidden\" name=\"png_data\" value=\"".concat(pngData, "\">\n <input type=\"hidden\" name=\"filepath\" value=\"").concat(svgData, "\">\n <input type=\"hidden\" name=\"filename\" value=\"drawing.svg\">\n <input type=\"hidden\" name=\"contenttype\" value=\"application/x-svgdraw\">\n ")).appendTo('body').submit().remove();
$.alert(strings.saved);
top.window.location = '/' + name;
case 15:
case "end":
return _context.stop();
if (!$('#export_canvas').length) {
$('<canvas>', {
id: 'export_canvas'
}).hide().appendTo('body');
}
}
}, _callee);
}));
function save(_x2, _x3) {
return _save.apply(this, arguments);
c = $('#export_canvas')[0];
c.width = svgCanvas.contentW;
c.height = svgCanvas.contentH;
_context.next = 10;
return regeneratorRuntime.awrap(canvg(c, svg));
case 10:
datauri = c.toDataURL('image/png'); // const {uiStrings} = svgEditor;
pngData = encode64(datauri); // Brett: This encoding seems unnecessary
/* const form = */
$('<form>').attr({
method: 'post',
action: saveSvgAction + '/' + name,
target: 'output_frame'
}).append("\n <input type=\"hidden\" name=\"png_data\" value=\"".concat(pngData, "\">\n <input type=\"hidden\" name=\"filepath\" value=\"").concat(svgData, "\">\n <input type=\"hidden\" name=\"filename\" value=\"drawing.svg\">\n <input type=\"hidden\" name=\"contenttype\" value=\"application/x-svgdraw\">\n ")).appendTo('body').submit().remove();
$.alert(strings.saved);
top.window.location = '/' + name;
case 15:
case "end":
return _context.stop();
}
}
});
}
});
return save;
}()
});
case 9:
case "end":
return _context2.stop();
}
case 9:
case "end":
return _context2.stop();
}
}, _callee2, this);
}));
function init(_x) {
return _init.apply(this, arguments);
}
return init;
}()
}
}, null, this);
}
};
return extServer_moinsave;

View File

@ -15,42 +15,6 @@ var svgEditorExtension_server_opensave = (function () {
return _typeof(obj);
}
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
@ -4684,36 +4648,26 @@ var svgEditorExtension_server_opensave = (function () {
}; // load from url
svg.load =
/*#__PURE__*/
function () {
var _ref12 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(ctx, url) {
var dom;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return svg.ajax(url, true);
svg.load = function _callee(ctx, url) {
var dom;
return regeneratorRuntime.async(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
_context.next = 2;
return regeneratorRuntime.awrap(svg.ajax(url, true));
case 2:
dom = _context.sent;
return _context.abrupt("return", svg.loadXml(ctx, dom));
case 2:
dom = _context.sent;
return _context.abrupt("return", svg.loadXml(ctx, dom));
case 4:
case "end":
return _context.stop();
}
case 4:
case "end":
return _context.stop();
}
}, _callee);
}));
return function (_x2, _x3) {
return _ref12.apply(this, arguments);
};
}(); // load from xml
}
});
}; // load from xml
svg.loadXml = function (ctx, xml) {
@ -4934,9 +4888,9 @@ var svgEditorExtension_server_opensave = (function () {
checkPath: function checkPath(element, ctx) {
var _this26 = this;
this.events.forEach(function (_ref13, i) {
var x = _ref13.x,
y = _ref13.y;
this.events.forEach(function (_ref12, i) {
var x = _ref12.x,
y = _ref12.y;
if (ctx.isPointInPath && ctx.isPointInPath(x, y)) {
_this26.eventElements[i] = element;
@ -4946,9 +4900,9 @@ var svgEditorExtension_server_opensave = (function () {
checkBoundingBox: function checkBoundingBox(element, bb) {
var _this27 = this;
this.events.forEach(function (_ref14, i) {
var x = _ref14.x,
y = _ref14.y;
this.events.forEach(function (_ref13, i) {
var x = _ref13.x,
y = _ref13.y;
if (bb.isPointInBox(x, y)) {
_this27.eventElements[i] = element;
@ -4990,363 +4944,334 @@ var svgEditorExtension_server_opensave = (function () {
};
}
/**
* ext-server_opensave.js
*
* @license MIT
*
* @copyright 2010 Alexis Deveria
*
*/
var extServer_opensave = {
name: 'server_opensave',
init: function () {
var _init = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee5(_ref) {
var $, decode64, encode64, importLocale, strings, svgEditor, _svgEditor$curConfig, extPath, avoidClientSide, avoidClientSideDownload, avoidClientSideOpen, svgCanvas, getFileNameFromTitle, xhtmlEscape, clientDownloadSupport, saveSvgAction, saveImgAction, cancelled, openSvgAction, importSvgAction, importImgAction, openSvgForm, importSvgForm, importImgForm, rebuildInput;
init: function init(_ref) {
var $, decode64, encode64, importLocale, strings, svgEditor, _svgEditor$curConfig, extPath, avoidClientSide, avoidClientSideDownload, avoidClientSideOpen, svgCanvas, getFileNameFromTitle, xhtmlEscape, clientDownloadSupport, saveSvgAction, saveImgAction, cancelled, openSvgAction, importSvgAction, importImgAction, openSvgForm, importSvgForm, importImgForm, rebuildInput;
return regeneratorRuntime.wrap(function _callee5$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
rebuildInput = function _ref7(form) {
form.empty();
var inp = $('<input type="file" name="svg_file">').appendTo(form);
/**
* Submit the form, empty its contents for reuse and show
* uploading message.
* @returns {Promise<void>}
*/
function submit() {
return _submit.apply(this, arguments);
}
function _submit() {
_submit = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee4() {
return regeneratorRuntime.wrap(function _callee4$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
// This submits the form, which returns the file data using `svgEditor.processFile()`
form.submit();
rebuildInput(form);
_context4.next = 4;
return $.process_cancel(strings.uploading);
case 4:
cancelled = true;
$('#dialog_box').hide();
case 6:
case "end":
return _context4.stop();
}
}
}, _callee4);
}));
return _submit.apply(this, arguments);
}
if (form[0] === openSvgForm[0]) {
inp.change(
/*#__PURE__*/
_asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee2() {
var ok;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
_context2.next = 2;
return svgEditor.openPrep();
case 2:
ok = _context2.sent;
if (ok) {
_context2.next = 6;
break;
}
rebuildInput(form);
return _context2.abrupt("return");
case 6:
_context2.next = 8;
return submit();
case 8:
case "end":
return _context2.stop();
}
}
}, _callee2);
})));
} else {
inp.change(
/*#__PURE__*/
_asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee3() {
return regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.next = 2;
return submit();
case 2:
case "end":
return _context3.stop();
}
}
}, _callee3);
})));
}
};
clientDownloadSupport = function _ref6(filename, suffix, uri) {
if (avoidClientSide || avoidClientSideDownload) {
return false;
}
var support = $('<a>')[0].download === '';
var a;
if (support) {
a = $('<a>hidden</a>').attr({
download: (filename || 'image') + suffix,
href: uri
}).css('display', 'none').appendTo('body');
a[0].click();
return true;
}
return false;
};
xhtmlEscape = function _ref5(str) {
return str.replace(/&(?!amp;)/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;'); // < is actually disallowed above anyways
};
getFileNameFromTitle = function _ref4() {
var title = svgCanvas.getDocumentTitle(); // We convert (to underscore) only those disallowed Win7 file name characters
return title.trim().replace(/[/\\:*?"<>|]/g, '_');
};
$ = _ref.$, decode64 = _ref.decode64, encode64 = _ref.encode64, importLocale = _ref.importLocale;
_context5.next = 7;
return importLocale();
case 7:
strings = _context5.sent;
svgEditor = this;
_svgEditor$curConfig = svgEditor.curConfig, extPath = _svgEditor$curConfig.extPath, avoidClientSide = _svgEditor$curConfig.avoidClientSide, avoidClientSideDownload = _svgEditor$curConfig.avoidClientSideDownload, avoidClientSideOpen = _svgEditor$curConfig.avoidClientSideOpen, svgCanvas = svgEditor.canvas;
return regeneratorRuntime.async(function init$(_context5) {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
rebuildInput = function _ref5(form) {
form.empty();
var inp = $('<input type="file" name="svg_file">').appendTo(form);
/**
*
* @returns {string}
* Submit the form, empty its contents for reuse and show
* uploading message.
* @returns {Promise<void>}
*/
saveSvgAction = extPath + 'filesave.php', saveImgAction = extPath + 'filesave.php'; // Create upload target (hidden iframe)
function submit() {
return regeneratorRuntime.async(function submit$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
// This submits the form, which returns the file data using `svgEditor.processFile()`
form.submit();
rebuildInput(form);
_context2.next = 4;
return regeneratorRuntime.awrap($.process_cancel(strings.uploading));
cancelled = false; // Hiding by size instead of display to avoid FF console errors
// with `getBBox` in browser.js `supportsPathBBox_`)
case 4:
cancelled = true;
$('#dialog_box').hide();
$("<iframe name=\"output_frame\" title=\"".concat(strings.hiddenframe, "\"\n style=\"width: 0; height: 0;\" src=\"#\"/>")).appendTo('body');
svgEditor.setCustomHandlers({
save: function save(win, data) {
var svg = '<?xml version="1.0" encoding="UTF-8"?>\n' + data,
// Firefox doesn't seem to know it is UTF-8 (no matter whether we use or skip the clientDownload code) despite the Content-Disposition header containing UTF-8, but adding the encoding works
filename = getFileNameFromTitle();
if (clientDownloadSupport(filename, '.svg', 'data:image/svg+xml;charset=UTF-8;base64,' + encode64(svg))) {
return;
case 6:
case "end":
return _context2.stop();
}
}
$('<form>').attr({
method: 'post',
action: saveSvgAction,
target: 'output_frame'
}).append("\n <input type=\"hidden\" name=\"output_svg\" value=\"".concat(xhtmlEscape(svg), "\">\n <input type=\"hidden\" name=\"filename\" value=\"").concat(xhtmlEscape(filename), "\">\n ")).appendTo('body').submit().remove();
},
exportPDF: function exportPDF(win, data) {
var filename = getFileNameFromTitle(),
datauri = data.output;
if (clientDownloadSupport(filename, '.pdf', datauri)) {
return;
}
$('<form>').attr({
method: 'post',
action: saveImgAction,
target: 'output_frame'
}).append("\n <input type=\"hidden\" name=\"output_img\" value=\"".concat(datauri, "\">\n <input type=\"hidden\" name=\"mime\" value=\"application/pdf\">\n <input type=\"hidden\" name=\"filename\" value=\"").concat(xhtmlEscape(filename), "\">\n ")).appendTo('body').submit().remove();
},
// Todo: Integrate this extension with a new built-in exportWindowType, "download"
exportImage: function () {
var _exportImage = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(win, data) {
var issues, mimeType, quality, c, datauri, pre, note, filename, suffix;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
issues = data.issues, mimeType = data.mimeType, quality = data.quality;
if (!$('#export_canvas').length) {
$('<canvas>', {
id: 'export_canvas'
}).hide().appendTo('body');
}
c = $('#export_canvas')[0];
c.width = svgCanvas.contentW;
c.height = svgCanvas.contentH;
_context.next = 7;
return canvg(c, data.svg);
case 7:
datauri = quality ? c.toDataURL(mimeType, quality) : c.toDataURL(mimeType); // {uiStrings} = svgEditor;
// Check if there are issues
note = '';
if (issues.length) {
pre = "\n \u2022 "; // Bullet
note += '\n\n' + pre + issues.join(pre);
}
if (!note.length) {
_context.next = 13;
break;
}
_context.next = 13;
return $.alert(note);
case 13:
filename = getFileNameFromTitle();
suffix = '.' + data.type.toLowerCase();
if (!clientDownloadSupport(filename, suffix, datauri)) {
_context.next = 17;
break;
}
return _context.abrupt("return");
case 17:
$('<form>').attr({
method: 'post',
action: saveImgAction,
target: 'output_frame'
}).append("\n <input type=\"hidden\" name=\"output_img\" value=\"".concat(datauri, "\">\n <input type=\"hidden\" name=\"mime\" value=\"").concat(mimeType, "\">\n <input type=\"hidden\" name=\"filename\" value=\"").concat(xhtmlEscape(filename), "\">\n ")).appendTo('body').submit().remove();
case 18:
case "end":
return _context.stop();
}
}
}, _callee);
}));
function exportImage(_x2, _x3) {
return _exportImage.apply(this, arguments);
}
return exportImage;
}()
}); // Do nothing if client support is found
if (!(window.FileReader && !avoidClientSideOpen)) {
_context5.next = 16;
break;
});
}
return _context5.abrupt("return");
if (form[0] === openSvgForm[0]) {
inp.change(function _callee() {
var ok;
return regeneratorRuntime.async(function _callee$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.next = 2;
return regeneratorRuntime.awrap(svgEditor.openPrep());
case 16:
// Change these to appropriate script file
openSvgAction = extPath + 'fileopen.php?type=load_svg';
importSvgAction = extPath + 'fileopen.php?type=import_svg';
importImgAction = extPath + 'fileopen.php?type=import_img'; // Set up function for PHP uploader to use
case 2:
ok = _context3.sent;
svgEditor.processFile = function (str64, type) {
var xmlstr;
if (ok) {
_context3.next = 6;
break;
}
if (cancelled) {
cancelled = false;
rebuildInput(form);
return _context3.abrupt("return");
case 6:
_context3.next = 8;
return regeneratorRuntime.awrap(submit());
case 8:
case "end":
return _context3.stop();
}
}
});
});
} else {
inp.change(function _callee2() {
return regeneratorRuntime.async(function _callee2$(_context4) {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
_context4.next = 2;
return regeneratorRuntime.awrap(submit());
case 2:
case "end":
return _context4.stop();
}
}
});
});
}
};
clientDownloadSupport = function _ref4(filename, suffix, uri) {
if (avoidClientSide || avoidClientSideDownload) {
return false;
}
var support = $('<a>')[0].download === '';
var a;
if (support) {
a = $('<a>hidden</a>').attr({
download: (filename || 'image') + suffix,
href: uri
}).css('display', 'none').appendTo('body');
a[0].click();
return true;
}
return false;
};
xhtmlEscape = function _ref3(str) {
return str.replace(/&(?!amp;)/g, '&amp;').replace(/"/g, '&quot;').replace(/</g, '&lt;'); // < is actually disallowed above anyways
};
getFileNameFromTitle = function _ref2() {
var title = svgCanvas.getDocumentTitle(); // We convert (to underscore) only those disallowed Win7 file name characters
return title.trim().replace(/[/\\:*?"<>|]/g, '_');
};
$ = _ref.$, decode64 = _ref.decode64, encode64 = _ref.encode64, importLocale = _ref.importLocale;
_context5.next = 7;
return regeneratorRuntime.awrap(importLocale());
case 7:
strings = _context5.sent;
svgEditor = this;
_svgEditor$curConfig = svgEditor.curConfig, extPath = _svgEditor$curConfig.extPath, avoidClientSide = _svgEditor$curConfig.avoidClientSide, avoidClientSideDownload = _svgEditor$curConfig.avoidClientSideDownload, avoidClientSideOpen = _svgEditor$curConfig.avoidClientSideOpen, svgCanvas = svgEditor.canvas;
/**
*
* @returns {string}
*/
saveSvgAction = extPath + 'filesave.php', saveImgAction = extPath + 'filesave.php'; // Create upload target (hidden iframe)
cancelled = false; // Hiding by size instead of display to avoid FF console errors
// with `getBBox` in browser.js `supportsPathBBox_`)
$("<iframe name=\"output_frame\" title=\"".concat(strings.hiddenframe, "\"\n style=\"width: 0; height: 0;\" src=\"#\"/>")).appendTo('body');
svgEditor.setCustomHandlers({
save: function save(win, data) {
var svg = '<?xml version="1.0" encoding="UTF-8"?>\n' + data,
// Firefox doesn't seem to know it is UTF-8 (no matter whether we use or skip the clientDownload code) despite the Content-Disposition header containing UTF-8, but adding the encoding works
filename = getFileNameFromTitle();
if (clientDownloadSupport(filename, '.svg', 'data:image/svg+xml;charset=UTF-8;base64,' + encode64(svg))) {
return;
}
$('#dialog_box').hide();
$('<form>').attr({
method: 'post',
action: saveSvgAction,
target: 'output_frame'
}).append("\n <input type=\"hidden\" name=\"output_svg\" value=\"".concat(xhtmlEscape(svg), "\">\n <input type=\"hidden\" name=\"filename\" value=\"").concat(xhtmlEscape(filename), "\">\n ")).appendTo('body').submit().remove();
},
exportPDF: function exportPDF(win, data) {
var filename = getFileNameFromTitle(),
datauri = data.output;
if (type !== 'import_img') {
xmlstr = decode64(str64);
if (clientDownloadSupport(filename, '.pdf', datauri)) {
return;
}
switch (type) {
case 'load_svg':
svgCanvas.clear();
svgCanvas.setSvgString(xmlstr);
svgEditor.updateCanvas();
break;
$('<form>').attr({
method: 'post',
action: saveImgAction,
target: 'output_frame'
}).append("\n <input type=\"hidden\" name=\"output_img\" value=\"".concat(datauri, "\">\n <input type=\"hidden\" name=\"mime\" value=\"application/pdf\">\n <input type=\"hidden\" name=\"filename\" value=\"").concat(xhtmlEscape(filename), "\">\n ")).appendTo('body').submit().remove();
},
// Todo: Integrate this extension with a new built-in exportWindowType, "download"
exportImage: function exportImage(win, data) {
var issues, mimeType, quality, c, datauri, pre, note, filename, suffix;
return regeneratorRuntime.async(function exportImage$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
issues = data.issues, mimeType = data.mimeType, quality = data.quality;
case 'import_svg':
svgCanvas.importSvgString(xmlstr);
svgEditor.updateCanvas();
break;
if (!$('#export_canvas').length) {
$('<canvas>', {
id: 'export_canvas'
}).hide().appendTo('body');
}
case 'import_img':
svgCanvas.setGoodImage(str64);
break;
}
}; // Create upload form
c = $('#export_canvas')[0];
c.width = svgCanvas.contentW;
c.height = svgCanvas.contentH;
_context.next = 7;
return regeneratorRuntime.awrap(canvg(c, data.svg));
case 7:
datauri = quality ? c.toDataURL(mimeType, quality) : c.toDataURL(mimeType); // {uiStrings} = svgEditor;
// Check if there are issues
note = '';
if (issues.length) {
pre = "\n \u2022 "; // Bullet
note += '\n\n' + pre + issues.join(pre);
}
if (!note.length) {
_context.next = 13;
break;
}
_context.next = 13;
return regeneratorRuntime.awrap($.alert(note));
case 13:
filename = getFileNameFromTitle();
suffix = '.' + data.type.toLowerCase();
if (!clientDownloadSupport(filename, suffix, datauri)) {
_context.next = 17;
break;
}
return _context.abrupt("return");
case 17:
$('<form>').attr({
method: 'post',
action: saveImgAction,
target: 'output_frame'
}).append("\n <input type=\"hidden\" name=\"output_img\" value=\"".concat(datauri, "\">\n <input type=\"hidden\" name=\"mime\" value=\"").concat(mimeType, "\">\n <input type=\"hidden\" name=\"filename\" value=\"").concat(xhtmlEscape(filename), "\">\n ")).appendTo('body').submit().remove();
case 18:
case "end":
return _context.stop();
}
}
});
}
}); // Do nothing if client support is found
if (!(window.FileReader && !avoidClientSideOpen)) {
_context5.next = 16;
break;
}
return _context5.abrupt("return");
case 16:
// Change these to appropriate script file
openSvgAction = extPath + 'fileopen.php?type=load_svg';
importSvgAction = extPath + 'fileopen.php?type=import_svg';
importImgAction = extPath + 'fileopen.php?type=import_img'; // Set up function for PHP uploader to use
svgEditor.processFile = function (str64, type) {
var xmlstr;
if (cancelled) {
cancelled = false;
return;
}
$('#dialog_box').hide();
if (type !== 'import_img') {
xmlstr = decode64(str64);
}
switch (type) {
case 'load_svg':
svgCanvas.clear();
svgCanvas.setSvgString(xmlstr);
svgEditor.updateCanvas();
break;
case 'import_svg':
svgCanvas.importSvgString(xmlstr);
svgEditor.updateCanvas();
break;
case 'import_img':
svgCanvas.setGoodImage(str64);
break;
}
}; // Create upload form
openSvgForm = $('<form>');
openSvgForm.attr({
enctype: 'multipart/form-data',
method: 'post',
action: openSvgAction,
target: 'output_frame'
}); // Create import form
openSvgForm = $('<form>');
openSvgForm.attr({
enctype: 'multipart/form-data',
method: 'post',
action: openSvgAction,
target: 'output_frame'
}); // Create import form
importSvgForm = openSvgForm.clone().attr('action', importSvgAction); // Create image form
importSvgForm = openSvgForm.clone().attr('action', importSvgAction); // Create image form
importImgForm = openSvgForm.clone().attr('action', importImgAction); // It appears necessary to rebuild this input every time a file is
// selected so the same file can be picked and the change event can fire.
importImgForm = openSvgForm.clone().attr('action', importImgAction); // It appears necessary to rebuild this input every time a file is
// selected so the same file can be picked and the change event can fire.
/**
*
* @param {external:jQuery} form
* @returns {void}
*/
/**
*
* @param {external:jQuery} form
* @returns {void}
*/
// Create the input elements
rebuildInput(openSvgForm);
rebuildInput(importSvgForm);
rebuildInput(importImgForm); // Add forms to buttons
// Create the input elements
rebuildInput(openSvgForm);
rebuildInput(importSvgForm);
rebuildInput(importImgForm); // Add forms to buttons
$('#tool_open').show().prepend(openSvgForm);
$('#tool_import').show().prepend(importSvgForm);
$('#tool_image').prepend(importImgForm);
$('#tool_open').show().prepend(openSvgForm);
$('#tool_import').show().prepend(importSvgForm);
$('#tool_image').prepend(importImgForm);
case 30:
case "end":
return _context5.stop();
}
case 30:
case "end":
return _context5.stop();
}
}, _callee5, this);
}));
function init(_x) {
return _init.apply(this, arguments);
}
return init;
}()
}
}, null, this);
}
};
return extServer_opensave;

View File

@ -1,42 +1,6 @@
var svgEditorExtension_shapes = (function () {
'use strict';
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
function _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
}
@ -89,339 +53,329 @@ var svgEditorExtension_shapes = (function () {
*/
var extShapes = {
name: 'shapes',
init: function () {
var _init = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(_ref) {
var $, importLocale, strings, svgEditor, canv, svgroot, lastBBox, categories, library, modeId, startClientPos, currentD, curShapeId, curShape, startX, startY, curLib, loadIcons, makeButtons, loadLibrary, buttons;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
loadLibrary = function _ref8(catId) {
var lib = library[catId];
init: function init(_ref) {
var $, importLocale, strings, svgEditor, canv, svgroot, lastBBox, categories, library, modeId, startClientPos, currentD, curShapeId, curShape, startX, startY, curLib, loadIcons, makeButtons, loadLibrary, buttons;
return regeneratorRuntime.async(function init$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
loadLibrary = function _ref8(catId) {
var lib = library[catId];
if (!lib) {
$('#shape_buttons').html(strings.loading);
$.getJSON(svgEditor.curConfig.extIconsPath + 'shapelib/' + catId + '.json', function (result) {
curLib = library[catId] = {
data: result.data,
size: result.size,
fill: result.fill
};
makeButtons(catId, result);
loadIcons();
});
return;
}
curLib = lib;
if (!lib.buttons.length) {
makeButtons(catId, lib);
}
loadIcons();
};
makeButtons = function _ref7(cat, shapes) {
var size = curLib.size || 300;
var fill = curLib.fill || false;
var off = size * 0.05;
var vb = [-off, -off, size + off * 2, size + off * 2].join(' ');
var stroke = fill ? 0 : size / 30;
var shapeIcon = new DOMParser().parseFromString('<svg xmlns="http://www.w3.org/2000/svg">' + '<svg viewBox="' + vb + '">' + '<path fill="' + (fill ? '#333' : 'none') + '" stroke="#000" stroke-width="' + stroke + '" /></svg></svg>', 'text/xml');
var width = 24;
var height = 24;
shapeIcon.documentElement.setAttribute('width', width);
shapeIcon.documentElement.setAttribute('height', height);
var svgElem = $(document.importNode(shapeIcon.documentElement, true));
var data = shapes.data;
curLib.buttons = Object.entries(data).map(function (_ref2) {
var _ref3 = _slicedToArray(_ref2, 2),
id = _ref3[0],
pathD = _ref3[1];
var icon = svgElem.clone();
icon.find('path').attr('d', pathD);
var iconBtn = icon.wrap('<div class="tool_button">').parent().attr({
id: modeId + '_' + id,
title: id
}); // Store for later use
return iconBtn[0];
});
};
loadIcons = function _ref6() {
$('#shape_buttons').empty().append(curLib.buttons);
};
$ = _ref.$, importLocale = _ref.importLocale;
_context.next = 6;
return importLocale();
case 6:
strings = _context.sent;
svgEditor = this;
canv = svgEditor.canvas;
svgroot = canv.getRootElem();
lastBBox = {}; // This populates the category list
categories = strings.categories;
library = {
basic: {
data: {
heart: 'm150,73c61,-175 300,0 0,225c-300,-225 -61,-400 0,-225z',
frame: 'm0,0l300,0l0,300l-300,0zm35,-265l0,230l230,0l0,-230z',
donut: 'm1,150l0,0c0,-82.29042 66.70958,-149 149,-149l0,0c39.51724,0 77.41599,15.69816 105.35889,43.64108c27.94293,27.94293 43.64111,65.84165 43.64111,105.35892l0,0c0,82.29041 -66.70958,149 -149,149l0,0c-82.29041,0 -149,-66.70959 -149,-149zm74.5,0l0,0c0,41.1452 33.35481,74.5 74.5,74.5c41.14522,0 74.5,-33.3548 74.5,-74.5c0,-41.1452 -33.3548,-74.5 -74.5,-74.5l0,0c-41.14519,0 -74.5,33.35481 -74.5,74.5z',
triangle: 'm1,280.375l149,-260.75l149,260.75z',
right_triangle: 'm1,299l0,-298l298,298z',
diamond: 'm1,150l149,-149l149,149l-149,149l-149,-149z',
pentagon: 'm1.00035,116.97758l148.99963,-108.4053l148.99998,108.4053l-56.91267,175.4042l-184.1741,0l-56.91284,-175.4042z',
hexagon: 'm1,149.99944l63.85715,-127.71428l170.28572,0l63.85713,127.71428l-63.85713,127.71428l-170.28572,0l-63.85715,-127.71428z',
septagon1: 'm0.99917,191.06511l29.51249,-127.7108l119.48833,-56.83673l119.48836,56.83673l29.51303,127.7108l-82.69087,102.41679l-132.62103,0l-82.69031,-102.41679z',
heptagon: 'm1,88.28171l87.28172,-87.28171l123.43653,0l87.28172,87.28171l0,123.43654l-87.28172,87.28172l-123.43653,0l-87.28172,-87.28172l0,-123.43654z',
decagon: 'm1,150.00093l28.45646,-88.40318l74.49956,-54.63682l92.08794,0l74.50002,54.63682l28.45599,88.40318l-28.45599,88.40318l-74.50002,54.63681l-92.08794,0l-74.49956,-54.63681l-28.45646,-88.40318z',
dodecagon: 'm1,110.07421l39.92579,-69.14842l69.14842,-39.92579l79.85159,0l69.14842,39.92579l39.92578,69.14842l0,79.85159l-39.92578,69.14842l-69.14842,39.92578l-79.85159,0l-69.14842,-39.92578l-39.92579,-69.14842l0,-79.85159z',
star_points_5: 'm1,116.58409l113.82668,0l35.17332,-108.13487l35.17334,108.13487l113.82666,0l-92.08755,66.83026l35.17514,108.13487l-92.08759,-66.83208l-92.08757,66.83208l35.17515,-108.13487l-92.08758,-66.83026z',
trapezoid: 'm1,299l55.875,-298l186.25001,0l55.87498,298z',
arrow_up: 'm1.49805,149.64304l148.50121,-148.00241l148.50121,148.00241l-74.25061,0l0,148.71457l-148.5012,0l0,-148.71457z',
vertical_scrool: 'm37.375,261.625l0,-242.9375l0,0c0,-10.32083 8.36669,-18.6875 18.6875,-18.6875l224.25,0c10.32083,0 18.6875,8.36667 18.6875,18.6875c0,10.32081 -8.36667,18.6875 -18.6875,18.6875l-18.6875,0l0,242.9375c0,10.32083 -8.36668,18.6875 -18.6875,18.6875l-224.25,0l0,0c-10.32083,0 -18.6875,-8.36667 -18.6875,-18.6875c0,-10.32083 8.36667,-18.6875 18.6875,-18.6875zm37.375,-261.625l0,0c10.32081,0 18.6875,8.36667 18.6875,18.6875c0,10.32081 -8.36669,18.6875 -18.6875,18.6875c-5.1604,0 -9.34375,-4.18335 -9.34375,-9.34375c0,-5.16041 4.18335,-9.34375 9.34375,-9.34375l18.6875,0m186.875,18.6875l-205.5625,0m-37.375,224.25l0,0c5.1604,0 9.34375,4.18335 9.34375,9.34375c0,5.1604 -4.18335,9.34375 -9.34375,9.34375l18.6875,0m-18.6875,18.6875l0,0c10.32081,0 18.6875,-8.36667 18.6875,-18.6875l0,-18.6875',
smiley: 'm68.49886,214.78838q81.06408,55.67332 161.93891,0m-144.36983,-109.9558c0,-8.60432 6.97517,-15.57949 15.57948,-15.57949c8.60431,0 15.57948,6.97517 15.57948,15.57949c0,8.60431 -6.97517,15.57947 -15.57948,15.57947c-8.60431,0 -15.57948,-6.97516 -15.57948,-15.57947m95.83109,0c0,-8.60432 6.97517,-15.57949 15.57948,-15.57949c8.60431,0 15.57947,6.97517 15.57947,15.57949c0,8.60431 -6.97516,15.57947 -15.57947,15.57947c-8.60429,0 -15.57948,-6.97516 -15.57948,-15.57947m-181.89903,44.73038l0,0c0,-82.60133 66.96162,-149.56296 149.56296,-149.56296c82.60135,0 149.56296,66.96162 149.56296,149.56296c0,82.60135 -66.96161,149.56296 -149.56296,149.56296c-82.60133,0 -149.56296,-66.96161 -149.56296,-149.56296zm0,0l0,0c0,-82.60133 66.96162,-149.56296 149.56296,-149.56296c82.60135,0 149.56296,66.96162 149.56296,149.56296c0,82.60135 -66.96161,149.56296 -149.56296,149.56296c-82.60133,0 -149.56296,-66.96161 -149.56296,-149.56296z',
left_braket: 'm174.24565,298.5c-13.39009,0 -24.24489,-1.80908 -24.24489,-4.04065l0,-140.4187c0,-2.23158 -10.85481,-4.04065 -24.2449,-4.04065l0,0c13.39009,0 24.2449,-1.80907 24.2449,-4.04065l0,-140.4187l0,0c0,-2.23159 10.8548,-4.04066 24.24489,-4.04066',
uml_actor: 'm40.5,100l219,0m-108.99991,94.00006l107,105m-107.00009,-106.00006l-100,106m99.5,-231l0,125m33.24219,-158.75781c0,18.35916 -14.88303,33.24219 -33.24219,33.24219c-18.35916,0 -33.2422,-14.88303 -33.2422,-33.24219c0.00002,-18.35915 14.88304,-33.24219 33.2422,-33.24219c18.35916,0 33.24219,14.88304 33.24219,33.24219z',
dialog_balloon_1: 'm0.99786,35.96579l0,0c0,-19.31077 15.28761,-34.96524 34.14583,-34.96524l15.52084,0l0,0l74.50001,0l139.68748,0c9.05606,0 17.74118,3.68382 24.14478,10.24108c6.40356,6.55726 10.00107,15.45081 10.00107,24.72416l0,87.41311l0,0l0,52.44785l0,0c0,19.31078 -15.2876,34.96524 -34.14584,34.96524l-139.68748,0l-97.32507,88.90848l22.82506,-88.90848l-15.52084,0c-18.85822,0 -34.14583,-15.65446 -34.14583,-34.96524l0,0l0,-52.44785l0,0z',
cloud: 'm182.05086,34.31005c-0.64743,0.02048 -1.27309,0.07504 -1.92319,0.13979c-10.40161,1.03605 -19.58215,7.63722 -24.24597,17.4734l-2.47269,7.44367c0.53346,-2.57959 1.35258,-5.08134 2.47269,-7.44367c-8.31731,-8.61741 -19.99149,-12.59487 -31.52664,-10.72866c-11.53516,1.8662 -21.55294,9.3505 -27.02773,20.19925c-15.45544,-9.51897 -34.72095,-8.94245 -49.62526,1.50272c-14.90431,10.44516 -22.84828,28.93916 -20.43393,47.59753l1.57977,7.58346c-0.71388,-2.48442 -1.24701,-5.01186 -1.57977,-7.58346l-0.2404,0.69894c-12.95573,1.4119 -23.58103,11.46413 -26.34088,24.91708c-2.75985,13.45294 2.9789,27.25658 14.21789,34.21291l17.54914,4.26352c-6.1277,0.50439 -12.24542,-0.9808 -17.54914,-4.26352c-8.66903,9.71078 -10.6639,24.08736 -4.94535,35.96027c5.71854,11.87289 17.93128,18.70935 30.53069,17.15887l7.65843,-2.02692c-2.46413,1.0314 -5.02329,1.70264 -7.65843,2.02692c7.15259,13.16728 19.01251,22.77237 32.93468,26.5945c13.92217,3.82214 28.70987,1.56322 41.03957,-6.25546c10.05858,15.86252 27.91113,24.19412 45.81322,21.38742c17.90208,-2.8067 32.66954,-16.26563 37.91438,-34.52742l1.82016,-10.20447c-0.27254,3.46677 -0.86394,6.87508 -1.82016,10.20447c12.31329,8.07489 27.80199,8.52994 40.52443,1.18819c12.72244,-7.34175 20.6609,-21.34155 20.77736,-36.58929l-4.56108,-22.7823l-17.96776,-15.41455c13.89359,8.70317 22.6528,21.96329 22.52884,38.19685c16.5202,0.17313 30.55292,-13.98268 36.84976,-30.22897c6.29684,-16.24631 3.91486,-34.76801 -6.2504,-48.68089c4.21637,-10.35873 3.96622,-22.14172 -0.68683,-32.29084c-4.65308,-10.14912 -13.23602,-17.69244 -23.55914,-20.65356c-2.31018,-13.45141 -11.83276,-24.27162 -24.41768,-27.81765c-12.58492,-3.54603 -25.98557,0.82654 -34.41142,11.25287l-5.11707,8.63186c1.30753,-3.12148 3.01521,-6.03101 5.11707,-8.63186c-5.93959,-8.19432 -15.2556,-12.8181 -24.96718,-12.51096z',
cylinder: 'm299.0007,83.77844c0,18.28676 -66.70958,33.11111 -149.00002,33.11111m149.00002,-33.11111l0,0c0,18.28676 -66.70958,33.11111 -149.00002,33.11111c-82.29041,0 -148.99997,-14.82432 -148.99997,-33.11111m0,0l0,0c0,-18.28674 66.70956,-33.1111 148.99997,-33.1111c82.29044,0 149.00002,14.82436 149.00002,33.1111l0,132.44449c0,18.28674 -66.70958,33.11105 -149.00002,33.11105c-82.29041,0 -148.99997,-14.82431 -148.99997,-33.11105z',
arrow_u_turn: 'm1.00059,299.00055l0,-167.62497l0,0c0,-72.00411 58.37087,-130.37499 130.375,-130.37499l0,0l0,0c34.57759,0 67.73898,13.7359 92.18906,38.18595c24.45006,24.45005 38.18593,57.61144 38.18593,92.18904l0,18.625l37.24997,0l-74.49995,74.50002l-74.50002,-74.50002l37.25,0l0,-18.625c0,-30.8589 -25.0161,-55.87498 -55.87498,-55.87498l0,0l0,0c-30.85892,0 -55.875,25.01608 -55.875,55.87498l0,167.62497z',
arrow_left_up: 'm0.99865,224.5l74.50004,-74.5l0,37.25l111.74991,0l0,-111.75l-37.25,0l74.5,-74.5l74.5,74.5l-37.25,0l0,186.25l-186.24989,0l0,37.25l-74.50005,-74.5z',
maximize: 'm1.00037,150.34581l55.30305,-55.30267l0,27.65093l22.17356,0l0,-44.21833l44.21825,0l0,-22.17357l-27.65095,0l55.30267,-55.30292l55.3035,55.30292l-27.65175,0l0,22.17357l44.21835,0l0,44.21833l22.17357,0l0,-27.65093l55.30345,55.30267l-55.30345,55.3035l0,-27.65175l-22.17357,0l0,44.21834l-44.21835,0l0,22.17355l27.65175,0l-55.3035,55.30348l-55.30267,-55.30348l27.65095,0l0,-22.17355l-44.21825,0l0,-44.21834l-22.17356,0l0,27.65175l-55.30305,-55.3035z',
cross: 'm0.99844,99.71339l98.71494,0l0,-98.71495l101.26279,0l0,98.71495l98.71495,0l0,101.2628l-98.71495,0l0,98.71494l-101.26279,0l0,-98.71494l-98.71494,0z',
plaque: 'm-0.00197,49.94376l0,0c27.5829,0 49.94327,-22.36036 49.94327,-49.94327l199.76709,0l0,0c0,27.5829 22.36037,49.94327 49.94325,49.94327l0,199.7671l0,0c-27.58289,0 -49.94325,22.36034 -49.94325,49.94325l-199.76709,0c0,-27.58292 -22.36037,-49.94325 -49.94327,-49.94325z',
page: 'm249.3298,298.99744l9.9335,-39.73413l39.73413,-9.93355l-49.66763,49.66768l-248.33237,0l0,-298.00001l298.00001,0l0,248.33234'
},
buttons: []
}
};
modeId = 'shapelib';
startClientPos = {};
curLib = library.basic;
/**
*
* @returns {void}
*/
buttons = [{
id: 'tool_shapelib',
icon: svgEditor.curConfig.extIconsPath + 'shapes.png',
type: 'mode_flyout',
// _flyout
position: 6,
events: {
click: function click() {
canv.setMode(modeId);
}
}
}];
return _context.abrupt("return", {
svgicons: svgEditor.curConfig.extIconsPath + 'ext-shapes.xml',
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
}),
callback: function callback() {
$('<style>').text("\n #shape_buttons {\n overflow: auto;\n width: 180px;\n max-height: 300px;\n display: table-cell;\n vertical-align: middle;\n }\n #shape_cats {\n min-width: 110px;\n display: table-cell;\n vertical-align: middle;\n height: 300px;\n }\n #shape_cats > div {\n line-height: 1em;\n padding: .5em;\n border:1px solid #B0B0B0;\n background: #E8E8E8;\n margin-bottom: -1px;\n }\n #shape_cats div:hover {\n background: #FFFFCC;\n }\n #shape_cats div.current {\n font-weight: bold;\n }\n ").appendTo('head');
var btnDiv = $('<div id="shape_buttons">');
$('#tools_shapelib > *').wrapAll(btnDiv);
var shower = $('#tools_shapelib_show');
loadLibrary('basic'); // Do mouseup on parent element rather than each button
$('#shape_buttons').mouseup(function (evt) {
var btn = $(evt.target).closest('div.tool_button');
if (!btn.length) {
return;
}
var copy = btn.children().clone();
shower.children(':not(.flyout_arrow_horiz)').remove();
shower.append(copy).attr('data-curopt', '#' + btn[0].id) // This sets the current mode
.mouseup();
canv.setMode(modeId);
curShapeId = btn[0].id.substr((modeId + '_').length);
currentD = curLib.data[curShapeId];
$('.tools_flyout').fadeOut();
});
var shapeCats = $('<div id="shape_cats">');
var catStr = '';
$.each(categories, function (id, label) {
catStr += '<div data-cat=' + id + '>' + label + '</div>';
});
shapeCats.html(catStr).children().bind('mouseup', function () {
var catlink = $(this);
catlink.siblings().removeClass('current');
catlink.addClass('current');
loadLibrary(catlink.attr('data-cat')); // Get stuff
return false;
});
shapeCats.children().eq(0).addClass('current');
$('#tools_shapelib').append(shapeCats);
shower.mouseup(function () {
canv.setMode(currentD ? modeId : 'select');
});
$('#tool_shapelib').remove();
var h = $('#tools_shapelib').height();
$('#tools_shapelib').css({
'margin-top': -(h / 2 - 15),
'margin-left': 3
}); // Now add shape categories from locale
var cats = {};
Object.entries(categories).forEach(function (_ref4) {
var _ref5 = _slicedToArray(_ref4, 2),
o = _ref5[0],
categoryName = _ref5[1];
cats['#shape_cats [data-cat="' + o + '"]'] = categoryName;
});
this.setStrings('content', cats);
},
mouseDown: function mouseDown(opts) {
var mode = canv.getMode();
if (mode !== modeId) {
return undefined;
}
startX = opts.start_x;
var x = startX;
startY = opts.start_y;
var y = startY;
var curStyle = canv.getStyle();
startClientPos.x = opts.event.clientX;
startClientPos.y = opts.event.clientY;
curShape = canv.addSVGElementFromJson({
element: 'path',
curStyles: true,
attr: {
d: currentD,
id: canv.getNextId(),
opacity: curStyle.opacity / 2,
style: 'pointer-events:none'
}
}); // Make sure shape uses absolute values
if (/[a-z]/.test(currentD)) {
currentD = curLib.data[curShapeId] = canv.pathActions.convertPath(curShape);
curShape.setAttribute('d', currentD);
canv.pathActions.fixEnd(curShape);
}
curShape.setAttribute('transform', 'translate(' + x + ',' + y + ') scale(0.005) translate(' + -x + ',' + -y + ')');
canv.recalculateDimensions(curShape);
/* const tlist = */
canv.getTransformList(curShape);
lastBBox = curShape.getBBox();
return {
started: true
if (!lib) {
$('#shape_buttons').html(strings.loading);
$.getJSON(svgEditor.curConfig.extIconsPath + 'shapelib/' + catId + '.json', function (result) {
curLib = library[catId] = {
data: result.data,
size: result.size,
fill: result.fill
};
},
mouseMove: function mouseMove(opts) {
var mode = canv.getMode();
makeButtons(catId, result);
loadIcons();
});
return;
}
if (mode !== modeId) {
curLib = lib;
if (!lib.buttons.length) {
makeButtons(catId, lib);
}
loadIcons();
};
makeButtons = function _ref7(cat, shapes) {
var size = curLib.size || 300;
var fill = curLib.fill || false;
var off = size * 0.05;
var vb = [-off, -off, size + off * 2, size + off * 2].join(' ');
var stroke = fill ? 0 : size / 30;
var shapeIcon = new DOMParser().parseFromString('<svg xmlns="http://www.w3.org/2000/svg">' + '<svg viewBox="' + vb + '">' + '<path fill="' + (fill ? '#333' : 'none') + '" stroke="#000" stroke-width="' + stroke + '" /></svg></svg>', 'text/xml');
var width = 24;
var height = 24;
shapeIcon.documentElement.setAttribute('width', width);
shapeIcon.documentElement.setAttribute('height', height);
var svgElem = $(document.importNode(shapeIcon.documentElement, true));
var data = shapes.data;
curLib.buttons = Object.entries(data).map(function (_ref2) {
var _ref3 = _slicedToArray(_ref2, 2),
id = _ref3[0],
pathD = _ref3[1];
var icon = svgElem.clone();
icon.find('path').attr('d', pathD);
var iconBtn = icon.wrap('<div class="tool_button">').parent().attr({
id: modeId + '_' + id,
title: id
}); // Store for later use
return iconBtn[0];
});
};
loadIcons = function _ref6() {
$('#shape_buttons').empty().append(curLib.buttons);
};
$ = _ref.$, importLocale = _ref.importLocale;
_context.next = 6;
return regeneratorRuntime.awrap(importLocale());
case 6:
strings = _context.sent;
svgEditor = this;
canv = svgEditor.canvas;
svgroot = canv.getRootElem();
lastBBox = {}; // This populates the category list
categories = strings.categories;
library = {
basic: {
data: {
heart: 'm150,73c61,-175 300,0 0,225c-300,-225 -61,-400 0,-225z',
frame: 'm0,0l300,0l0,300l-300,0zm35,-265l0,230l230,0l0,-230z',
donut: 'm1,150l0,0c0,-82.29042 66.70958,-149 149,-149l0,0c39.51724,0 77.41599,15.69816 105.35889,43.64108c27.94293,27.94293 43.64111,65.84165 43.64111,105.35892l0,0c0,82.29041 -66.70958,149 -149,149l0,0c-82.29041,0 -149,-66.70959 -149,-149zm74.5,0l0,0c0,41.1452 33.35481,74.5 74.5,74.5c41.14522,0 74.5,-33.3548 74.5,-74.5c0,-41.1452 -33.3548,-74.5 -74.5,-74.5l0,0c-41.14519,0 -74.5,33.35481 -74.5,74.5z',
triangle: 'm1,280.375l149,-260.75l149,260.75z',
right_triangle: 'm1,299l0,-298l298,298z',
diamond: 'm1,150l149,-149l149,149l-149,149l-149,-149z',
pentagon: 'm1.00035,116.97758l148.99963,-108.4053l148.99998,108.4053l-56.91267,175.4042l-184.1741,0l-56.91284,-175.4042z',
hexagon: 'm1,149.99944l63.85715,-127.71428l170.28572,0l63.85713,127.71428l-63.85713,127.71428l-170.28572,0l-63.85715,-127.71428z',
septagon1: 'm0.99917,191.06511l29.51249,-127.7108l119.48833,-56.83673l119.48836,56.83673l29.51303,127.7108l-82.69087,102.41679l-132.62103,0l-82.69031,-102.41679z',
heptagon: 'm1,88.28171l87.28172,-87.28171l123.43653,0l87.28172,87.28171l0,123.43654l-87.28172,87.28172l-123.43653,0l-87.28172,-87.28172l0,-123.43654z',
decagon: 'm1,150.00093l28.45646,-88.40318l74.49956,-54.63682l92.08794,0l74.50002,54.63682l28.45599,88.40318l-28.45599,88.40318l-74.50002,54.63681l-92.08794,0l-74.49956,-54.63681l-28.45646,-88.40318z',
dodecagon: 'm1,110.07421l39.92579,-69.14842l69.14842,-39.92579l79.85159,0l69.14842,39.92579l39.92578,69.14842l0,79.85159l-39.92578,69.14842l-69.14842,39.92578l-79.85159,0l-69.14842,-39.92578l-39.92579,-69.14842l0,-79.85159z',
star_points_5: 'm1,116.58409l113.82668,0l35.17332,-108.13487l35.17334,108.13487l113.82666,0l-92.08755,66.83026l35.17514,108.13487l-92.08759,-66.83208l-92.08757,66.83208l35.17515,-108.13487l-92.08758,-66.83026z',
trapezoid: 'm1,299l55.875,-298l186.25001,0l55.87498,298z',
arrow_up: 'm1.49805,149.64304l148.50121,-148.00241l148.50121,148.00241l-74.25061,0l0,148.71457l-148.5012,0l0,-148.71457z',
vertical_scrool: 'm37.375,261.625l0,-242.9375l0,0c0,-10.32083 8.36669,-18.6875 18.6875,-18.6875l224.25,0c10.32083,0 18.6875,8.36667 18.6875,18.6875c0,10.32081 -8.36667,18.6875 -18.6875,18.6875l-18.6875,0l0,242.9375c0,10.32083 -8.36668,18.6875 -18.6875,18.6875l-224.25,0l0,0c-10.32083,0 -18.6875,-8.36667 -18.6875,-18.6875c0,-10.32083 8.36667,-18.6875 18.6875,-18.6875zm37.375,-261.625l0,0c10.32081,0 18.6875,8.36667 18.6875,18.6875c0,10.32081 -8.36669,18.6875 -18.6875,18.6875c-5.1604,0 -9.34375,-4.18335 -9.34375,-9.34375c0,-5.16041 4.18335,-9.34375 9.34375,-9.34375l18.6875,0m186.875,18.6875l-205.5625,0m-37.375,224.25l0,0c5.1604,0 9.34375,4.18335 9.34375,9.34375c0,5.1604 -4.18335,9.34375 -9.34375,9.34375l18.6875,0m-18.6875,18.6875l0,0c10.32081,0 18.6875,-8.36667 18.6875,-18.6875l0,-18.6875',
smiley: 'm68.49886,214.78838q81.06408,55.67332 161.93891,0m-144.36983,-109.9558c0,-8.60432 6.97517,-15.57949 15.57948,-15.57949c8.60431,0 15.57948,6.97517 15.57948,15.57949c0,8.60431 -6.97517,15.57947 -15.57948,15.57947c-8.60431,0 -15.57948,-6.97516 -15.57948,-15.57947m95.83109,0c0,-8.60432 6.97517,-15.57949 15.57948,-15.57949c8.60431,0 15.57947,6.97517 15.57947,15.57949c0,8.60431 -6.97516,15.57947 -15.57947,15.57947c-8.60429,0 -15.57948,-6.97516 -15.57948,-15.57947m-181.89903,44.73038l0,0c0,-82.60133 66.96162,-149.56296 149.56296,-149.56296c82.60135,0 149.56296,66.96162 149.56296,149.56296c0,82.60135 -66.96161,149.56296 -149.56296,149.56296c-82.60133,0 -149.56296,-66.96161 -149.56296,-149.56296zm0,0l0,0c0,-82.60133 66.96162,-149.56296 149.56296,-149.56296c82.60135,0 149.56296,66.96162 149.56296,149.56296c0,82.60135 -66.96161,149.56296 -149.56296,149.56296c-82.60133,0 -149.56296,-66.96161 -149.56296,-149.56296z',
left_braket: 'm174.24565,298.5c-13.39009,0 -24.24489,-1.80908 -24.24489,-4.04065l0,-140.4187c0,-2.23158 -10.85481,-4.04065 -24.2449,-4.04065l0,0c13.39009,0 24.2449,-1.80907 24.2449,-4.04065l0,-140.4187l0,0c0,-2.23159 10.8548,-4.04066 24.24489,-4.04066',
uml_actor: 'm40.5,100l219,0m-108.99991,94.00006l107,105m-107.00009,-106.00006l-100,106m99.5,-231l0,125m33.24219,-158.75781c0,18.35916 -14.88303,33.24219 -33.24219,33.24219c-18.35916,0 -33.2422,-14.88303 -33.2422,-33.24219c0.00002,-18.35915 14.88304,-33.24219 33.2422,-33.24219c18.35916,0 33.24219,14.88304 33.24219,33.24219z',
dialog_balloon_1: 'm0.99786,35.96579l0,0c0,-19.31077 15.28761,-34.96524 34.14583,-34.96524l15.52084,0l0,0l74.50001,0l139.68748,0c9.05606,0 17.74118,3.68382 24.14478,10.24108c6.40356,6.55726 10.00107,15.45081 10.00107,24.72416l0,87.41311l0,0l0,52.44785l0,0c0,19.31078 -15.2876,34.96524 -34.14584,34.96524l-139.68748,0l-97.32507,88.90848l22.82506,-88.90848l-15.52084,0c-18.85822,0 -34.14583,-15.65446 -34.14583,-34.96524l0,0l0,-52.44785l0,0z',
cloud: 'm182.05086,34.31005c-0.64743,0.02048 -1.27309,0.07504 -1.92319,0.13979c-10.40161,1.03605 -19.58215,7.63722 -24.24597,17.4734l-2.47269,7.44367c0.53346,-2.57959 1.35258,-5.08134 2.47269,-7.44367c-8.31731,-8.61741 -19.99149,-12.59487 -31.52664,-10.72866c-11.53516,1.8662 -21.55294,9.3505 -27.02773,20.19925c-15.45544,-9.51897 -34.72095,-8.94245 -49.62526,1.50272c-14.90431,10.44516 -22.84828,28.93916 -20.43393,47.59753l1.57977,7.58346c-0.71388,-2.48442 -1.24701,-5.01186 -1.57977,-7.58346l-0.2404,0.69894c-12.95573,1.4119 -23.58103,11.46413 -26.34088,24.91708c-2.75985,13.45294 2.9789,27.25658 14.21789,34.21291l17.54914,4.26352c-6.1277,0.50439 -12.24542,-0.9808 -17.54914,-4.26352c-8.66903,9.71078 -10.6639,24.08736 -4.94535,35.96027c5.71854,11.87289 17.93128,18.70935 30.53069,17.15887l7.65843,-2.02692c-2.46413,1.0314 -5.02329,1.70264 -7.65843,2.02692c7.15259,13.16728 19.01251,22.77237 32.93468,26.5945c13.92217,3.82214 28.70987,1.56322 41.03957,-6.25546c10.05858,15.86252 27.91113,24.19412 45.81322,21.38742c17.90208,-2.8067 32.66954,-16.26563 37.91438,-34.52742l1.82016,-10.20447c-0.27254,3.46677 -0.86394,6.87508 -1.82016,10.20447c12.31329,8.07489 27.80199,8.52994 40.52443,1.18819c12.72244,-7.34175 20.6609,-21.34155 20.77736,-36.58929l-4.56108,-22.7823l-17.96776,-15.41455c13.89359,8.70317 22.6528,21.96329 22.52884,38.19685c16.5202,0.17313 30.55292,-13.98268 36.84976,-30.22897c6.29684,-16.24631 3.91486,-34.76801 -6.2504,-48.68089c4.21637,-10.35873 3.96622,-22.14172 -0.68683,-32.29084c-4.65308,-10.14912 -13.23602,-17.69244 -23.55914,-20.65356c-2.31018,-13.45141 -11.83276,-24.27162 -24.41768,-27.81765c-12.58492,-3.54603 -25.98557,0.82654 -34.41142,11.25287l-5.11707,8.63186c1.30753,-3.12148 3.01521,-6.03101 5.11707,-8.63186c-5.93959,-8.19432 -15.2556,-12.8181 -24.96718,-12.51096z',
cylinder: 'm299.0007,83.77844c0,18.28676 -66.70958,33.11111 -149.00002,33.11111m149.00002,-33.11111l0,0c0,18.28676 -66.70958,33.11111 -149.00002,33.11111c-82.29041,0 -148.99997,-14.82432 -148.99997,-33.11111m0,0l0,0c0,-18.28674 66.70956,-33.1111 148.99997,-33.1111c82.29044,0 149.00002,14.82436 149.00002,33.1111l0,132.44449c0,18.28674 -66.70958,33.11105 -149.00002,33.11105c-82.29041,0 -148.99997,-14.82431 -148.99997,-33.11105z',
arrow_u_turn: 'm1.00059,299.00055l0,-167.62497l0,0c0,-72.00411 58.37087,-130.37499 130.375,-130.37499l0,0l0,0c34.57759,0 67.73898,13.7359 92.18906,38.18595c24.45006,24.45005 38.18593,57.61144 38.18593,92.18904l0,18.625l37.24997,0l-74.49995,74.50002l-74.50002,-74.50002l37.25,0l0,-18.625c0,-30.8589 -25.0161,-55.87498 -55.87498,-55.87498l0,0l0,0c-30.85892,0 -55.875,25.01608 -55.875,55.87498l0,167.62497z',
arrow_left_up: 'm0.99865,224.5l74.50004,-74.5l0,37.25l111.74991,0l0,-111.75l-37.25,0l74.5,-74.5l74.5,74.5l-37.25,0l0,186.25l-186.24989,0l0,37.25l-74.50005,-74.5z',
maximize: 'm1.00037,150.34581l55.30305,-55.30267l0,27.65093l22.17356,0l0,-44.21833l44.21825,0l0,-22.17357l-27.65095,0l55.30267,-55.30292l55.3035,55.30292l-27.65175,0l0,22.17357l44.21835,0l0,44.21833l22.17357,0l0,-27.65093l55.30345,55.30267l-55.30345,55.3035l0,-27.65175l-22.17357,0l0,44.21834l-44.21835,0l0,22.17355l27.65175,0l-55.3035,55.30348l-55.30267,-55.30348l27.65095,0l0,-22.17355l-44.21825,0l0,-44.21834l-22.17356,0l0,27.65175l-55.30305,-55.3035z',
cross: 'm0.99844,99.71339l98.71494,0l0,-98.71495l101.26279,0l0,98.71495l98.71495,0l0,101.2628l-98.71495,0l0,98.71494l-101.26279,0l0,-98.71494l-98.71494,0z',
plaque: 'm-0.00197,49.94376l0,0c27.5829,0 49.94327,-22.36036 49.94327,-49.94327l199.76709,0l0,0c0,27.5829 22.36037,49.94327 49.94325,49.94327l0,199.7671l0,0c-27.58289,0 -49.94325,22.36034 -49.94325,49.94325l-199.76709,0c0,-27.58292 -22.36037,-49.94325 -49.94327,-49.94325z',
page: 'm249.3298,298.99744l9.9335,-39.73413l39.73413,-9.93355l-49.66763,49.66768l-248.33237,0l0,-298.00001l298.00001,0l0,248.33234'
},
buttons: []
}
};
modeId = 'shapelib';
startClientPos = {};
curLib = library.basic;
/**
*
* @returns {void}
*/
buttons = [{
id: 'tool_shapelib',
icon: svgEditor.curConfig.extIconsPath + 'shapes.png',
type: 'mode_flyout',
// _flyout
position: 6,
events: {
click: function click() {
canv.setMode(modeId);
}
}
}];
return _context.abrupt("return", {
svgicons: svgEditor.curConfig.extIconsPath + 'ext-shapes.xml',
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
}),
callback: function callback() {
$('<style>').text("\n #shape_buttons {\n overflow: auto;\n width: 180px;\n max-height: 300px;\n display: table-cell;\n vertical-align: middle;\n }\n #shape_cats {\n min-width: 110px;\n display: table-cell;\n vertical-align: middle;\n height: 300px;\n }\n #shape_cats > div {\n line-height: 1em;\n padding: .5em;\n border:1px solid #B0B0B0;\n background: #E8E8E8;\n margin-bottom: -1px;\n }\n #shape_cats div:hover {\n background: #FFFFCC;\n }\n #shape_cats div.current {\n font-weight: bold;\n }\n ").appendTo('head');
var btnDiv = $('<div id="shape_buttons">');
$('#tools_shapelib > *').wrapAll(btnDiv);
var shower = $('#tools_shapelib_show');
loadLibrary('basic'); // Do mouseup on parent element rather than each button
$('#shape_buttons').mouseup(function (evt) {
var btn = $(evt.target).closest('div.tool_button');
if (!btn.length) {
return;
}
var zoom = canv.getZoom();
var evt = opts.event;
var x = opts.mouse_x / zoom;
var y = opts.mouse_y / zoom;
var tlist = canv.getTransformList(curShape),
box = curShape.getBBox(),
left = box.x,
top = box.y; // {width, height} = box,
// const dx = (x - startX), dy = (y - startY);
var copy = btn.children().clone();
shower.children(':not(.flyout_arrow_horiz)').remove();
shower.append(copy).attr('data-curopt', '#' + btn[0].id) // This sets the current mode
.mouseup();
canv.setMode(modeId);
curShapeId = btn[0].id.substr((modeId + '_').length);
currentD = curLib.data[curShapeId];
$('.tools_flyout').fadeOut();
});
var shapeCats = $('<div id="shape_cats">');
var catStr = '';
$.each(categories, function (id, label) {
catStr += '<div data-cat=' + id + '>' + label + '</div>';
});
shapeCats.html(catStr).children().bind('mouseup', function () {
var catlink = $(this);
catlink.siblings().removeClass('current');
catlink.addClass('current');
loadLibrary(catlink.attr('data-cat')); // Get stuff
var newbox = {
x: Math.min(startX, x),
y: Math.min(startY, y),
width: Math.abs(x - startX),
height: Math.abs(y - startY)
};
/*
// This is currently serving no purpose, so commenting out
let sy = height ? (height + dy) / height : 1,
sx = width ? (width + dx) / width : 1;
*/
return false;
});
shapeCats.children().eq(0).addClass('current');
$('#tools_shapelib').append(shapeCats);
shower.mouseup(function () {
canv.setMode(currentD ? modeId : 'select');
});
$('#tool_shapelib').remove();
var h = $('#tools_shapelib').height();
$('#tools_shapelib').css({
'margin-top': -(h / 2 - 15),
'margin-left': 3
}); // Now add shape categories from locale
var sx = newbox.width / lastBBox.width || 1;
var sy = newbox.height / lastBBox.height || 1; // Not perfect, but mostly works...
var cats = {};
Object.entries(categories).forEach(function (_ref4) {
var _ref5 = _slicedToArray(_ref4, 2),
o = _ref5[0],
categoryName = _ref5[1];
var tx = 0;
cats['#shape_cats [data-cat="' + o + '"]'] = categoryName;
});
this.setStrings('content', cats);
},
mouseDown: function mouseDown(opts) {
var mode = canv.getMode();
if (x < startX) {
tx = lastBBox.width;
}
var ty = 0;
if (y < startY) {
ty = lastBBox.height;
} // update the transform list with translate,scale,translate
var translateOrigin = svgroot.createSVGTransform(),
scale = svgroot.createSVGTransform(),
translateBack = svgroot.createSVGTransform();
translateOrigin.setTranslate(-(left + tx), -(top + ty));
if (!evt.shiftKey) {
var max = Math.min(Math.abs(sx), Math.abs(sy));
sx = max * (sx < 0 ? -1 : 1);
sy = max * (sy < 0 ? -1 : 1);
}
scale.setScale(sx, sy);
translateBack.setTranslate(left + tx, top + ty);
tlist.appendItem(translateBack);
tlist.appendItem(scale);
tlist.appendItem(translateOrigin);
canv.recalculateDimensions(curShape);
lastBBox = curShape.getBBox();
},
mouseUp: function mouseUp(opts) {
var mode = canv.getMode();
if (mode !== modeId) {
return undefined;
}
var keepObject = opts.event.clientX !== startClientPos.x && opts.event.clientY !== startClientPos.y;
return {
keep: keepObject,
element: curShape,
started: false
};
if (mode !== modeId) {
return undefined;
}
});
case 18:
case "end":
return _context.stop();
}
startX = opts.start_x;
var x = startX;
startY = opts.start_y;
var y = startY;
var curStyle = canv.getStyle();
startClientPos.x = opts.event.clientX;
startClientPos.y = opts.event.clientY;
curShape = canv.addSVGElementFromJson({
element: 'path',
curStyles: true,
attr: {
d: currentD,
id: canv.getNextId(),
opacity: curStyle.opacity / 2,
style: 'pointer-events:none'
}
}); // Make sure shape uses absolute values
if (/[a-z]/.test(currentD)) {
currentD = curLib.data[curShapeId] = canv.pathActions.convertPath(curShape);
curShape.setAttribute('d', currentD);
canv.pathActions.fixEnd(curShape);
}
curShape.setAttribute('transform', 'translate(' + x + ',' + y + ') scale(0.005) translate(' + -x + ',' + -y + ')');
canv.recalculateDimensions(curShape);
/* const tlist = */
canv.getTransformList(curShape);
lastBBox = curShape.getBBox();
return {
started: true
};
},
mouseMove: function mouseMove(opts) {
var mode = canv.getMode();
if (mode !== modeId) {
return;
}
var zoom = canv.getZoom();
var evt = opts.event;
var x = opts.mouse_x / zoom;
var y = opts.mouse_y / zoom;
var tlist = canv.getTransformList(curShape),
box = curShape.getBBox(),
left = box.x,
top = box.y; // {width, height} = box,
// const dx = (x - startX), dy = (y - startY);
var newbox = {
x: Math.min(startX, x),
y: Math.min(startY, y),
width: Math.abs(x - startX),
height: Math.abs(y - startY)
};
/*
// This is currently serving no purpose, so commenting out
let sy = height ? (height + dy) / height : 1,
sx = width ? (width + dx) / width : 1;
*/
var sx = newbox.width / lastBBox.width || 1;
var sy = newbox.height / lastBBox.height || 1; // Not perfect, but mostly works...
var tx = 0;
if (x < startX) {
tx = lastBBox.width;
}
var ty = 0;
if (y < startY) {
ty = lastBBox.height;
} // update the transform list with translate,scale,translate
var translateOrigin = svgroot.createSVGTransform(),
scale = svgroot.createSVGTransform(),
translateBack = svgroot.createSVGTransform();
translateOrigin.setTranslate(-(left + tx), -(top + ty));
if (!evt.shiftKey) {
var max = Math.min(Math.abs(sx), Math.abs(sy));
sx = max * (sx < 0 ? -1 : 1);
sy = max * (sy < 0 ? -1 : 1);
}
scale.setScale(sx, sy);
translateBack.setTranslate(left + tx, top + ty);
tlist.appendItem(translateBack);
tlist.appendItem(scale);
tlist.appendItem(translateOrigin);
canv.recalculateDimensions(curShape);
lastBBox = curShape.getBBox();
},
mouseUp: function mouseUp(opts) {
var mode = canv.getMode();
if (mode !== modeId) {
return undefined;
}
var keepObject = opts.event.clientX !== startClientPos.x && opts.event.clientY !== startClientPos.y;
return {
keep: keepObject,
element: curShape,
started: false
};
}
});
case 18:
case "end":
return _context.stop();
}
}, _callee, this);
}));
function init(_x) {
return _init.apply(this, arguments);
}
return init;
}()
}
}, null, this);
}
};
return extShapes;

View File

@ -1,42 +1,6 @@
var svgEditorExtension_star = (function () {
'use strict';
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
/**
* ext-star.js
*
@ -46,160 +10,170 @@ var svgEditorExtension_star = (function () {
*/
var extStar = {
name: 'star',
init: function () {
var _init = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(S) {
var svgEditor, svgCanvas, $, importLocale, selElems, started, newFO, strings, showPanel, setAttr, buttons, contextTools;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
setAttr = function _ref2(attr, val) {
svgCanvas.changeSelectedAttribute(attr, val);
svgCanvas.call('changed', selElems);
};
init: function init(S) {
var svgEditor, svgCanvas, $, importLocale, selElems, started, newFO, strings, showPanel, setAttr, buttons, contextTools;
return regeneratorRuntime.async(function init$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
setAttr = function _ref2(attr, val) {
svgCanvas.changeSelectedAttribute(attr, val);
svgCanvas.call('changed', selElems);
};
showPanel = function _ref(on) {
var fcRules = $('#fc_rules');
showPanel = function _ref(on) {
var fcRules = $('#fc_rules');
if (!fcRules.length) {
fcRules = $('<style id="fc_rules"></style>').appendTo('head');
}
fcRules.text(!on ? '' : ' #tool_topath { display: none !important; }');
$('#star_panel').toggle(on);
};
svgEditor = this;
svgCanvas = svgEditor.canvas;
$ = S.$, importLocale = S.importLocale; // {svgcontent},
_context.next = 7;
return importLocale();
case 7:
strings = _context.sent;
/*
function cot(n){
return 1 / Math.tan(n);
if (!fcRules.length) {
fcRules = $('<style id="fc_rules"></style>').appendTo('head');
}
function sec(n){
return 1 / Math.cos(n);
fcRules.text(!on ? '' : ' #tool_topath { display: none !important; }');
$('#star_panel').toggle(on);
};
svgEditor = this;
svgCanvas = svgEditor.canvas;
$ = S.$, importLocale = S.importLocale; // {svgcontent},
_context.next = 7;
return regeneratorRuntime.awrap(importLocale());
case 7:
strings = _context.sent;
/*
function cot(n){
return 1 / Math.tan(n);
}
function sec(n){
return 1 / Math.cos(n);
}
*/
buttons = [{
id: 'tool_star',
icon: svgEditor.curConfig.extIconsPath + 'star.png',
type: 'mode',
position: 12,
events: {
click: function click() {
showPanel(true);
svgCanvas.setMode('star');
}
}
*/
buttons = [{
id: 'tool_star',
icon: svgEditor.curConfig.extIconsPath + 'star.png',
type: 'mode',
position: 12,
events: {
click: function click() {
showPanel(true);
svgCanvas.setMode('star');
}
}];
contextTools = [{
type: 'input',
panel: 'star_panel',
id: 'starNumPoints',
size: 3,
defval: 5,
events: {
change: function change() {
setAttr('point', this.value);
}
}];
contextTools = [{
type: 'input',
panel: 'star_panel',
id: 'starNumPoints',
size: 3,
defval: 5,
events: {
change: function change() {
setAttr('point', this.value);
}
}
}, {
type: 'input',
panel: 'star_panel',
id: 'starRadiusMulitplier',
size: 3,
defval: 2.5
}, {
type: 'input',
panel: 'star_panel',
id: 'radialShift',
size: 3,
defval: 0,
events: {
change: function change() {
setAttr('radialshift', this.value);
}
}, {
type: 'input',
panel: 'star_panel',
id: 'starRadiusMulitplier',
size: 3,
defval: 2.5
}, {
type: 'input',
panel: 'star_panel',
id: 'radialShift',
size: 3,
defval: 0,
events: {
change: function change() {
setAttr('radialshift', this.value);
}
}
}];
return _context.abrupt("return", {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'star-icons.svg',
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
}),
context_tools: strings.contextTools.map(function (contextTool, i) {
return Object.assign(contextTools[i], contextTool);
}),
callback: function callback() {
$('#star_panel').hide(); // const endChanges = function(){};
},
mouseDown: function mouseDown(opts) {
var rgb = svgCanvas.getColor('fill'); // const ccRgbEl = rgb.substring(1, rgb.length);
var sRgb = svgCanvas.getColor('stroke'); // const ccSRgbEl = sRgb.substring(1, rgb.length);
var sWidth = svgCanvas.getStrokeWidth();
if (svgCanvas.getMode() === 'star') {
started = true;
newFO = svgCanvas.addSVGElementFromJson({
element: 'polygon',
attr: {
cx: opts.start_x,
cy: opts.start_y,
id: svgCanvas.getNextId(),
shape: 'star',
point: document.getElementById('starNumPoints').value,
r: 0,
radialshift: document.getElementById('radialShift').value,
r2: 0,
orient: 'point',
fill: rgb,
strokecolor: sRgb,
strokeWidth: sWidth
}
});
return {
started: true
};
}
}];
return _context.abrupt("return", {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'star-icons.svg',
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
}),
context_tools: strings.contextTools.map(function (contextTool, i) {
return Object.assign(contextTools[i], contextTool);
}),
callback: function callback() {
$('#star_panel').hide(); // const endChanges = function(){};
},
mouseDown: function mouseDown(opts) {
var rgb = svgCanvas.getColor('fill'); // const ccRgbEl = rgb.substring(1, rgb.length);
var sRgb = svgCanvas.getColor('stroke'); // const ccSRgbEl = sRgb.substring(1, rgb.length);
var sWidth = svgCanvas.getStrokeWidth();
if (svgCanvas.getMode() === 'star') {
started = true;
newFO = svgCanvas.addSVGElementFromJson({
element: 'polygon',
attr: {
cx: opts.start_x,
cy: opts.start_y,
id: svgCanvas.getNextId(),
shape: 'star',
point: document.getElementById('starNumPoints').value,
r: 0,
radialshift: document.getElementById('radialShift').value,
r2: 0,
orient: 'point',
fill: rgb,
strokecolor: sRgb,
strokeWidth: sWidth
}
});
return {
started: true
};
}
return undefined;
},
mouseMove: function mouseMove(opts) {
if (!started) {
return undefined;
},
mouseMove: function mouseMove(opts) {
if (!started) {
return undefined;
}
}
if (svgCanvas.getMode() === 'star') {
var c = $(newFO).attr(['cx', 'cy', 'point', 'orient', 'fill', 'strokecolor', 'strokeWidth', 'radialshift']);
var x = opts.mouse_x;
var y = opts.mouse_y;
var cx = c.cx,
cy = c.cy,
fill = c.fill,
strokecolor = c.strokecolor,
strokeWidth = c.strokeWidth,
radialshift = c.radialshift,
point = c.point,
orient = c.orient,
circumradius = Math.sqrt((x - cx) * (x - cx) + (y - cy) * (y - cy)) / 1.5,
inradius = circumradius / document.getElementById('starRadiusMulitplier').value;
newFO.setAttribute('r', circumradius);
newFO.setAttribute('r2', inradius);
var polyPoints = '';
if (svgCanvas.getMode() === 'star') {
var c = $(newFO).attr(['cx', 'cy', 'point', 'orient', 'fill', 'strokecolor', 'strokeWidth', 'radialshift']);
var x = opts.mouse_x;
var y = opts.mouse_y;
var cx = c.cx,
cy = c.cy,
fill = c.fill,
strokecolor = c.strokecolor,
strokeWidth = c.strokeWidth,
radialshift = c.radialshift,
point = c.point,
orient = c.orient,
circumradius = Math.sqrt((x - cx) * (x - cx) + (y - cy) * (y - cy)) / 1.5,
inradius = circumradius / document.getElementById('starRadiusMulitplier').value;
newFO.setAttribute('r', circumradius);
newFO.setAttribute('r2', inradius);
var polyPoints = '';
for (var s = 0; point >= s; s++) {
var angle = 2.0 * Math.PI * (s / point);
for (var s = 0; point >= s; s++) {
var angle = 2.0 * Math.PI * (s / point);
if (orient === 'point') {
angle -= Math.PI / 2;
} else if (orient === 'edge') {
angle = angle + Math.PI / point - Math.PI / 2;
}
x = circumradius * Math.cos(angle) + cx;
y = circumradius * Math.sin(angle) + cy;
polyPoints += x + ',' + y + ' ';
if (!isNaN(inradius)) {
angle = 2.0 * Math.PI * (s / point) + Math.PI / point;
if (orient === 'point') {
angle -= Math.PI / 2;
@ -207,92 +181,72 @@ var svgEditorExtension_star = (function () {
angle = angle + Math.PI / point - Math.PI / 2;
}
x = circumradius * Math.cos(angle) + cx;
y = circumradius * Math.sin(angle) + cy;
angle += radialshift;
x = inradius * Math.cos(angle) + cx;
y = inradius * Math.sin(angle) + cy;
polyPoints += x + ',' + y + ' ';
if (!isNaN(inradius)) {
angle = 2.0 * Math.PI * (s / point) + Math.PI / point;
if (orient === 'point') {
angle -= Math.PI / 2;
} else if (orient === 'edge') {
angle = angle + Math.PI / point - Math.PI / 2;
}
angle += radialshift;
x = inradius * Math.cos(angle) + cx;
y = inradius * Math.sin(angle) + cy;
polyPoints += x + ',' + y + ' ';
}
}
newFO.setAttribute('points', polyPoints);
newFO.setAttribute('fill', fill);
newFO.setAttribute('stroke', strokecolor);
newFO.setAttribute('stroke-width', strokeWidth);
/* const shape = */
newFO.getAttribute('shape');
return {
started: true
};
}
return undefined;
},
mouseUp: function mouseUp() {
if (svgCanvas.getMode() === 'star') {
var attrs = $(newFO).attr(['r']); // svgCanvas.addToSelection([newFO], true);
newFO.setAttribute('points', polyPoints);
newFO.setAttribute('fill', fill);
newFO.setAttribute('stroke', strokecolor);
newFO.setAttribute('stroke-width', strokeWidth);
/* const shape = */
return {
keep: attrs.r !== '0',
element: newFO
};
}
newFO.getAttribute('shape');
return {
started: true
};
}
return undefined;
},
selectedChanged: function selectedChanged(opts) {
// Use this to update the current selected elements
selElems = opts.elems;
var i = selElems.length;
return undefined;
},
mouseUp: function mouseUp() {
if (svgCanvas.getMode() === 'star') {
var attrs = $(newFO).attr(['r']); // svgCanvas.addToSelection([newFO], true);
while (i--) {
var elem = selElems[i];
return {
keep: attrs.r !== '0',
element: newFO
};
}
if (elem && elem.getAttribute('shape') === 'star') {
if (opts.selectedElement && !opts.multiselected) {
// $('#starRadiusMulitplier').val(elem.getAttribute('r2'));
$('#starNumPoints').val(elem.getAttribute('point'));
$('#radialShift').val(elem.getAttribute('radialshift'));
showPanel(true);
} else {
showPanel(false);
}
return undefined;
},
selectedChanged: function selectedChanged(opts) {
// Use this to update the current selected elements
selElems = opts.elems;
var i = selElems.length;
while (i--) {
var elem = selElems[i];
if (elem && elem.getAttribute('shape') === 'star') {
if (opts.selectedElement && !opts.multiselected) {
// $('#starRadiusMulitplier').val(elem.getAttribute('r2'));
$('#starNumPoints').val(elem.getAttribute('point'));
$('#radialShift').val(elem.getAttribute('radialshift'));
showPanel(true);
} else {
showPanel(false);
}
} else {
showPanel(false);
}
},
elementChanged: function elementChanged(opts) {// const elem = opts.elems[0];
}
});
},
elementChanged: function elementChanged(opts) {// const elem = opts.elems[0];
}
});
case 11:
case "end":
return _context.stop();
}
case 11:
case "end":
return _context.stop();
}
}, _callee, this);
}));
function init(_x) {
return _init.apply(this, arguments);
}
return init;
}()
}
}, null, this);
}
};
return extStar;

View File

@ -1,42 +1,6 @@
var svgEditorExtension_storage = (function () {
'use strict';
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
function _inherits(subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function");
@ -415,184 +379,174 @@ var svgEditorExtension_storage = (function () {
var loaded = false;
return {
name: 'storage',
langReady: function () {
var _langReady = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(_ref4) {
var importLocale, _$$deparam$querystrin, storagePrompt, confirmSetStorage, message, storagePrefsAndContent, storagePrefsOnly, storagePrefs, storageNoPrefsOrContent, storageNoPrefs, rememberLabel, rememberTooltip, options, oldContainerWidth, oldContainerMarginLeft, oldContentHeight, oldContainerHeight, _ref5, pref, checked;
langReady: function langReady(_ref4) {
var importLocale, _$$deparam$querystrin, storagePrompt, confirmSetStorage, message, storagePrefsAndContent, storagePrefsOnly, storagePrefs, storageNoPrefsOrContent, storageNoPrefs, rememberLabel, rememberTooltip, options, oldContainerWidth, oldContainerMarginLeft, oldContentHeight, oldContainerHeight, _ref5, pref, checked;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
importLocale = _ref4.importLocale;
_$$deparam$querystrin = $.deparam.querystring(true), storagePrompt = _$$deparam$querystrin.storagePrompt;
_context.next = 4;
return importLocale();
return regeneratorRuntime.async(function langReady$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
importLocale = _ref4.importLocale;
_$$deparam$querystrin = $.deparam.querystring(true), storagePrompt = _$$deparam$querystrin.storagePrompt;
_context.next = 4;
return regeneratorRuntime.awrap(importLocale());
case 4:
confirmSetStorage = _context.sent;
message = confirmSetStorage.message, storagePrefsAndContent = confirmSetStorage.storagePrefsAndContent, storagePrefsOnly = confirmSetStorage.storagePrefsOnly, storagePrefs = confirmSetStorage.storagePrefs, storageNoPrefsOrContent = confirmSetStorage.storageNoPrefsOrContent, storageNoPrefs = confirmSetStorage.storageNoPrefs, rememberLabel = confirmSetStorage.rememberLabel, rememberTooltip = confirmSetStorage.rememberTooltip; // No need to run this one-time dialog again just because the user
// changes the language
case 4:
confirmSetStorage = _context.sent;
message = confirmSetStorage.message, storagePrefsAndContent = confirmSetStorage.storagePrefsAndContent, storagePrefsOnly = confirmSetStorage.storagePrefsOnly, storagePrefs = confirmSetStorage.storagePrefs, storageNoPrefsOrContent = confirmSetStorage.storageNoPrefsOrContent, storageNoPrefs = confirmSetStorage.storageNoPrefs, rememberLabel = confirmSetStorage.rememberLabel, rememberTooltip = confirmSetStorage.rememberTooltip; // No need to run this one-time dialog again just because the user
// changes the language
if (!loaded) {
_context.next = 8;
break;
}
if (!loaded) {
_context.next = 8;
break;
}
return _context.abrupt("return");
return _context.abrupt("return");
case 8:
loaded = true; // Note that the following can load even if "noStorageOnLoad" is
// set to false; to avoid any chance of storage, avoid this
// extension! (and to avoid using any prior storage, set the
// config option "noStorageOnLoad" to true).
case 8:
loaded = true; // Note that the following can load even if "noStorageOnLoad" is
// set to false; to avoid any chance of storage, avoid this
// extension! (and to avoid using any prior storage, set the
// config option "noStorageOnLoad" to true).
if (!(!forceStorage && ( // If the URL has been explicitly set to always prompt the
// user (e.g., so one can be pointed to a URL where one
// can alter one's settings, say to prevent future storage)...
storagePrompt === true || // ...or...if the URL at least doesn't explicitly prevent a
// storage prompt (as we use for users who
// don't want to set cookies at all but who don't want
// continual prompts about it)...
storagePrompt !== false && // ...and this user hasn't previously indicated a desire for storage
!document.cookie.match(/(?:^|;\s*)svgeditstore=(?:prefsAndContent|prefsOnly)/) // ...then show the storage prompt.
))) {
_context.next = 44;
break;
}
if (!(!forceStorage && ( // If the URL has been explicitly set to always prompt the
// user (e.g., so one can be pointed to a URL where one
// can alter one's settings, say to prevent future storage)...
storagePrompt === true || // ...or...if the URL at least doesn't explicitly prevent a
// storage prompt (as we use for users who
// don't want to set cookies at all but who don't want
// continual prompts about it)...
storagePrompt !== false && // ...and this user hasn't previously indicated a desire for storage
!document.cookie.match(/(?:^|;\s*)svgeditstore=(?:prefsAndContent|prefsOnly)/) // ...then show the storage prompt.
))) {
_context.next = 44;
break;
}
options = [];
options = [];
if (storage) {
options.unshift({
value: 'prefsAndContent',
text: storagePrefsAndContent
}, {
value: 'prefsOnly',
text: storagePrefsOnly
}, {
value: 'noPrefsOrContent',
text: storageNoPrefsOrContent
});
} else {
options.unshift({
value: 'prefsOnly',
text: storagePrefs
}, {
value: 'noPrefsOrContent',
text: storageNoPrefs
});
} // Hack to temporarily provide a wide and high enough dialog
oldContainerWidth = $('#dialog_container')[0].style.width, oldContainerMarginLeft = $('#dialog_container')[0].style.marginLeft, oldContentHeight = $('#dialog_content')[0].style.height, oldContainerHeight = $('#dialog_container')[0].style.height;
$('#dialog_content')[0].style.height = '120px';
$('#dialog_container')[0].style.height = '170px';
$('#dialog_container')[0].style.width = '800px';
$('#dialog_container')[0].style.marginLeft = '-400px'; // Open select-with-checkbox dialog
// From svg-editor.js
svgEditor.storagePromptState = 'waiting';
_context.next = 20;
return $.select(message, options, null, null, {
label: rememberLabel,
checked: true,
tooltip: rememberTooltip
if (storage) {
options.unshift({
value: 'prefsAndContent',
text: storagePrefsAndContent
}, {
value: 'prefsOnly',
text: storagePrefsOnly
}, {
value: 'noPrefsOrContent',
text: storageNoPrefsOrContent
});
} else {
options.unshift({
value: 'prefsOnly',
text: storagePrefs
}, {
value: 'noPrefsOrContent',
text: storageNoPrefs
});
} // Hack to temporarily provide a wide and high enough dialog
case 20:
_ref5 = _context.sent;
pref = _ref5.response;
checked = _ref5.checked;
if (!(pref && pref !== 'noPrefsOrContent')) {
_context.next = 30;
break;
}
oldContainerWidth = $('#dialog_container')[0].style.width, oldContainerMarginLeft = $('#dialog_container')[0].style.marginLeft, oldContentHeight = $('#dialog_content')[0].style.height, oldContainerHeight = $('#dialog_container')[0].style.height;
$('#dialog_content')[0].style.height = '120px';
$('#dialog_container')[0].style.height = '170px';
$('#dialog_container')[0].style.width = '800px';
$('#dialog_container')[0].style.marginLeft = '-400px'; // Open select-with-checkbox dialog
// From svg-editor.js
// Regardless of whether the user opted
// to remember the choice (and move to a URL which won't
// ask them again), we have to assume the user
// doesn't even want to remember their not wanting
// storage, so we don't set the cookie or continue on with
// setting storage on beforeunload
// eslint-disable-next-line require-atomic-updates
document.cookie = 'svgeditstore=' + encodeURIComponent(pref) + '; expires=Fri, 31 Dec 9999 23:59:59 GMT'; // 'prefsAndContent' | 'prefsOnly'
// If the URL was configured to always insist on a prompt, if
// the user does indicate a wish to store their info, we
// don't want ask them again upon page refresh so move
// them instead to a URL which does not always prompt
svgEditor.storagePromptState = 'waiting';
_context.next = 20;
return regeneratorRuntime.awrap($.select(message, options, null, null, {
label: rememberLabel,
checked: true,
tooltip: rememberTooltip
}));
if (!(storagePrompt === true && checked)) {
_context.next = 28;
break;
}
case 20:
_ref5 = _context.sent;
pref = _ref5.response;
checked = _ref5.checked;
replaceStoragePrompt();
return _context.abrupt("return");
if (!(pref && pref !== 'noPrefsOrContent')) {
_context.next = 30;
break;
}
case 28:
// Regardless of whether the user opted
// to remember the choice (and move to a URL which won't
// ask them again), we have to assume the user
// doesn't even want to remember their not wanting
// storage, so we don't set the cookie or continue on with
// setting storage on beforeunload
// eslint-disable-next-line require-atomic-updates
document.cookie = 'svgeditstore=' + encodeURIComponent(pref) + '; expires=Fri, 31 Dec 9999 23:59:59 GMT'; // 'prefsAndContent' | 'prefsOnly'
// If the URL was configured to always insist on a prompt, if
// the user does indicate a wish to store their info, we
// don't want ask them again upon page refresh so move
// them instead to a URL which does not always prompt
if (!(storagePrompt === true && checked)) {
_context.next = 28;
break;
}
replaceStoragePrompt();
return _context.abrupt("return");
case 28:
_context.next = 35;
break;
case 30:
// The user does not wish storage (or cancelled, which we treat equivalently)
removeStoragePrefCookie();
if (pref && // If the user explicitly expresses wish for no storage
emptyStorageOnDecline) {
emptyStorage();
}
if (!(pref && checked)) {
_context.next = 35;
break;
}
case 30:
// The user does not wish storage (or cancelled, which we treat equivalently)
removeStoragePrefCookie();
// Open a URL which won't set storage and won't prompt user about storage
replaceStoragePrompt('false');
return _context.abrupt("return");
if (pref && // If the user explicitly expresses wish for no storage
emptyStorageOnDecline) {
emptyStorage();
}
case 35:
// Reset width/height of dialog (e.g., for use by Export)
$('#dialog_container')[0].style.width = oldContainerWidth;
$('#dialog_container')[0].style.marginLeft = oldContainerMarginLeft;
$('#dialog_content')[0].style.height = oldContentHeight;
$('#dialog_container')[0].style.height = oldContainerHeight; // It should be enough to (conditionally) add to storage on
// beforeunload, but if we wished to update immediately,
// we might wish to try setting:
// svgEditor.setConfig({noStorageOnLoad: true});
// and then call:
// svgEditor.loadContentAndPrefs();
// We don't check for noStorageOnLoad here because
// the prompt gives the user the option to store data
if (!(pref && checked)) {
_context.next = 35;
break;
}
// Open a URL which won't set storage and won't prompt user about storage
replaceStoragePrompt('false');
return _context.abrupt("return");
case 35:
// Reset width/height of dialog (e.g., for use by Export)
$('#dialog_container')[0].style.width = oldContainerWidth;
$('#dialog_container')[0].style.marginLeft = oldContainerMarginLeft;
$('#dialog_content')[0].style.height = oldContentHeight;
$('#dialog_container')[0].style.height = oldContainerHeight; // It should be enough to (conditionally) add to storage on
// beforeunload, but if we wished to update immediately,
// we might wish to try setting:
// svgEditor.setConfig({noStorageOnLoad: true});
// and then call:
// svgEditor.loadContentAndPrefs();
// We don't check for noStorageOnLoad here because
// the prompt gives the user the option to store data
setupBeforeUnloadListener();
svgEditor.storagePromptState = 'closed';
updateCanvas(true);
_context.next = 45;
break;
case 44:
if (!noStorageOnLoad || forceStorage) {
setupBeforeUnloadListener();
svgEditor.storagePromptState = 'closed';
updateCanvas(true);
_context.next = 45;
break;
}
case 44:
if (!noStorageOnLoad || forceStorage) {
setupBeforeUnloadListener();
}
case 45:
case "end":
return _context.stop();
}
case 45:
case "end":
return _context.stop();
}
}, _callee);
}));
function langReady(_x) {
return _langReady.apply(this, arguments);
}
return langReady;
}()
}
});
}
};
}
};

View File

@ -1,42 +1,6 @@
var svgEditorExtension_webappfind = (function () {
'use strict';
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
/**
* Depends on Firefox add-on and executables from {@link https://github.com/brettz9/webappfind}
* @author Brett Zamir
@ -45,133 +9,123 @@ var svgEditorExtension_webappfind = (function () {
*/
var extWebappfind = {
name: 'webappfind',
init: function () {
var _init = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(_ref) {
var importLocale, $, strings, svgEditor, saveMessage, readMessage, excludedMessages, pathID, buttons;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
importLocale = _ref.importLocale, $ = _ref.$;
_context.next = 3;
return importLocale();
init: function init(_ref) {
var importLocale, $, strings, svgEditor, saveMessage, readMessage, excludedMessages, pathID, buttons;
return regeneratorRuntime.async(function init$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
importLocale = _ref.importLocale, $ = _ref.$;
_context.next = 3;
return regeneratorRuntime.awrap(importLocale());
case 3:
strings = _context.sent;
svgEditor = this;
saveMessage = 'save', readMessage = 'read', excludedMessages = [readMessage, saveMessage];
this.canvas.bind('message',
/**
* @param {external:Window} win
* @param {module:svgcanvas.SvgCanvas#event:message} data
* @listens module:svgcanvas.SvgCanvas#event:message
* @throws {Error} Unexpected event type
* @returns {void}
*/
function (win, _ref2) {
var data = _ref2.data,
origin = _ref2.origin;
// eslint-disable-line no-shadow
// console.log('data, origin', data, origin);
var type, content;
case 3:
strings = _context.sent;
svgEditor = this;
saveMessage = 'save', readMessage = 'read', excludedMessages = [readMessage, saveMessage];
this.canvas.bind('message',
/**
* @param {external:Window} win
* @param {module:svgcanvas.SvgCanvas#event:message} data
* @listens module:svgcanvas.SvgCanvas#event:message
* @throws {Error} Unexpected event type
* @returns {void}
*/
function (win, _ref2) {
var data = _ref2.data,
origin = _ref2.origin;
// eslint-disable-line no-shadow
// console.log('data, origin', data, origin);
var type, content;
try {
var _data$webappfind = data.webappfind;
type = _data$webappfind.type;
pathID = _data$webappfind.pathID;
content = _data$webappfind.content;
try {
var _data$webappfind = data.webappfind;
type = _data$webappfind.type;
pathID = _data$webappfind.pathID;
content = _data$webappfind.content;
// May throw if data is not an object
if (origin !== location.origin || // We are only interested in a message sent as though within this URL by our browser add-on
excludedMessages.includes(type) // Avoid our post below (other messages might be possible in the future which may also need to be excluded if your subsequent code makes assumptions on the type of message this is)
) {
return;
}
} catch (err) {
return;
}
switch (type) {
case 'view':
// Populate the contents
svgEditor.loadFromString(content);
/* if ($('#tool_save_file')) {
$('#tool_save_file').disabled = false;
} */
break;
case 'save-end':
$.alert("save complete for pathID ".concat(pathID, "!"));
break;
default:
throw new Error('Unexpected WebAppFind event type');
}
});
/*
window.postMessage({
webappfind: {
type: readMessage
}
}, window.location.origin === 'null'
// Avoid "null" string error for `file:` protocol (even though
// file protocol not currently supported by Firefox)
? '*'
: window.location.origin
);
*/
buttons = [{
id: 'webappfind_save',
//
icon: svgEditor.curConfig.extIconsPath + 'webappfind.png',
type: 'app_menu',
position: 4,
// Before 0-based index position 4 (after the regular "Save Image (S)")
events: {
click: function click() {
if (!pathID) {
// Not ready yet as haven't received first payload
return;
}
window.postMessage({
webappfind: {
type: saveMessage,
pathID: pathID,
content: svgEditor.canvas.getSvgString()
}
}, window.location.origin === 'null' // Avoid "null" string error for `file:` protocol (even
// though file protocol not currently supported by add-on)
? '*' : window.location.origin);
// May throw if data is not an object
if (origin !== location.origin || // We are only interested in a message sent as though within this URL by our browser add-on
excludedMessages.includes(type) // Avoid our post below (other messages might be possible in the future which may also need to be excluded if your subsequent code makes assumptions on the type of message this is)
) {
return;
}
} catch (err) {
return;
}
switch (type) {
case 'view':
// Populate the contents
svgEditor.loadFromString(content);
/* if ($('#tool_save_file')) {
$('#tool_save_file').disabled = false;
} */
break;
case 'save-end':
$.alert("save complete for pathID ".concat(pathID, "!"));
break;
default:
throw new Error('Unexpected WebAppFind event type');
}
});
/*
window.postMessage({
webappfind: {
type: readMessage
}
}, window.location.origin === 'null'
// Avoid "null" string error for `file:` protocol (even though
// file protocol not currently supported by Firefox)
? '*'
: window.location.origin
);
*/
buttons = [{
id: 'webappfind_save',
//
icon: svgEditor.curConfig.extIconsPath + 'webappfind.png',
type: 'app_menu',
position: 4,
// Before 0-based index position 4 (after the regular "Save Image (S)")
events: {
click: function click() {
if (!pathID) {
// Not ready yet as haven't received first payload
return;
}
window.postMessage({
webappfind: {
type: saveMessage,
pathID: pathID,
content: svgEditor.canvas.getSvgString()
}
}, window.location.origin === 'null' // Avoid "null" string error for `file:` protocol (even
// though file protocol not currently supported by add-on)
? '*' : window.location.origin);
}
}];
return _context.abrupt("return", {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'webappfind-icon.svg',
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
})
});
}
}];
return _context.abrupt("return", {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'webappfind-icon.svg',
buttons: strings.buttons.map(function (button, i) {
return Object.assign(buttons[i], button);
})
});
case 9:
case "end":
return _context.stop();
}
case 9:
case "end":
return _context.stop();
}
}, _callee, this);
}));
function init(_x) {
return _init.apply(this, arguments);
}
return init;
}()
}
}, null, this);
}
};
return extWebappfind;

View File

@ -15,42 +15,6 @@
return _typeof(obj);
}
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
@ -303,20 +267,35 @@
return obj;
}
function _objectSpread(target) {
function ownKeys(object, enumerableOnly) {
var keys = Object.keys(object);
if (Object.getOwnPropertySymbols) {
var symbols = Object.getOwnPropertySymbols(object);
if (enumerableOnly) symbols = symbols.filter(function (sym) {
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
});
keys.push.apply(keys, symbols);
}
return keys;
}
function _objectSpread2(target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i] != null ? arguments[i] : {};
var ownKeys = Object.keys(source);
if (typeof Object.getOwnPropertySymbols === 'function') {
ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
return Object.getOwnPropertyDescriptor(source, sym).enumerable;
}));
if (i % 2) {
ownKeys(source, true).forEach(function (key) {
_defineProperty(target, key, source[key]);
});
} else if (Object.getOwnPropertyDescriptors) {
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
} else {
ownKeys(source).forEach(function (key) {
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
});
}
ownKeys.forEach(function (key) {
_defineProperty(target, key, source[key]);
});
}
return target;
@ -494,6 +473,10 @@
}
function _iterableToArrayLimit$1(arr, i) {
if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) {
return;
}
var _arr = [];
var _n = true;
var _d = false;
@ -683,7 +666,7 @@
* @static
* @param {Element} el DOM element to which to attach the event
* @param {string} type The DOM event (without 'on') to attach to the element
* @param {Function} handler The event handler to attach to the element
* @param {EventListener} handler The event handler to attach to the element
* @param {boolean} [capturing] Whether or not the event should be
* capturing (W3C-browsers only); default is false; NOT IN USE
* @returns {void}
@ -725,7 +708,7 @@
} // Todo: Make as public utility
/**
* @param {*} o
* @param {any} o
* @returns {boolean}
*/
@ -737,7 +720,7 @@
/**
* @private
* @static
* @param {string|object|Array|Element|DocumentFragment} item
* @param {string|JamilihAttributes|JamilihArray|Element|DocumentFragment} item
* @returns {"string"|"null"|"array"|"element"|"fragment"|"object"}
*/
@ -833,7 +816,7 @@
return jml(arg);
}
/**
* @typedef {Array} AttributeArray
* @typedef {JamilihAttributes} AttributeArray
* @property {string} 0 The key
* @property {string} 1 The value
*/
@ -921,10 +904,10 @@
* @private
* @static
function _DOMfromJMLOrString (childNodeJML) {
if (typeof childNodeJML === 'string') {
return doc.createTextNode(childNodeJML);
}
return jml(...childNodeJML);
if (typeof childNodeJML === 'string') {
return doc.createTextNode(childNodeJML);
}
return jml(...childNodeJML);
}
*/
@ -932,12 +915,16 @@
* @typedef {Element|DocumentFragment} JamilihReturn
*/
/**
* @typedef {PlainObject} JamilihAttributes
*/
/**
* @typedef {GenericArray} JamilihArray
* @property {string} 0 The element to create (by lower-case name)
* @property {Object} [1] Attributes to add with the key as the attribute name
* and value as the attribute value; important for IE where the input
* element's type cannot be added later after already added to the page
* @property {JamilihAttributes} [1] Attributes to add with the key as the
* attribute name and value as the attribute value; important for IE where
* the input element's type cannot be added later after already added to the page
* @param {Element[]} [children] The optional children of this element
* (but raw DOM elements required to be specified within arrays since
* could not otherwise be distinguished from siblings being added)
@ -999,9 +986,9 @@
0. {$xmlDocument: []} // doc.implementation.createDocument
0. Accept array for any attribute with first item as prefix and second as value?
0. {$: ['xhtml', 'div']} for prefixed elements
case '$': // Element with prefix?
nodes[nodes.length] = elem = doc.createElementNS(attVal[0], attVal[1]);
break;
case '$': // Element with prefix?
nodes[nodes.length] = elem = doc.createElementNS(attVal[0], attVal[1]);
break;
*/
case '#':
{
@ -1287,7 +1274,7 @@
/*
// Todo:
if (attVal.internalSubset) {
node = {};
node = {};
}
else
*/
@ -1320,13 +1307,13 @@
/*
// Todo: Should we auto-copy another node's properties/methods (like DocumentType) excluding or changing its non-entity node values?
const node = {
nodeName: attVal.name,
nodeValue: null,
publicId: attVal.publicId,
systemId: attVal.systemId,
notationName: attVal.notationName,
nodeType: 6,
childNodes: attVal.childNodes.map(_DOMfromJMLOrString)
nodeName: attVal.name,
nodeValue: null,
publicId: attVal.publicId,
systemId: attVal.systemId,
notationName: attVal.notationName,
nodeType: 6,
childNodes: attVal.childNodes.map(_DOMfromJMLOrString)
};
*/
break;
@ -1472,9 +1459,9 @@
/*
// The following reorders which is troublesome for serialization, e.g., as used in our testing
if (elem.style.cssText !== undefined) {
elem.style.cssText += attVal;
elem.style.cssText += attVal;
} else { // Opera
elem.style += attVal;
elem.style += attVal;
}
*/
@ -1569,8 +1556,6 @@
obj = dataVal[1] || defaultMap[1];
} // Map
/* eslint-disable-next-line unicorn/no-unsafe-regex */
} else if (/^\[object (?:Weak)?Map\]$/.test([].toString.call(dataVal))) {
map = dataVal;
obj = defaultMap[1]; // Non-map data object
@ -1823,11 +1808,11 @@
/**
* Converts a DOM object or a string of HTML into a Jamilih object (or string).
* @param {string|HTMLElement} [dom=document.documentElement] Defaults to converting the current document.
* @param {object} [config={stringOutput:false}] Configuration object
* @param {PlainObject} [config] Configuration object
* @param {boolean} [config.stringOutput=false] Whether to output the Jamilih object as a string.
* @returns {Array|string} Array containing the elements which represent a Jamilih object, or,
if `stringOutput` is true, it will be the stringified version of
such an object
* @returns {JamilihArray|string} Array containing the elements which represent
* a Jamilih object, or, if `stringOutput` is true, it will be the stringified
* version of such an object
*/
@ -1890,7 +1875,7 @@
}
/**
*
* @param {*} val
* @param {any} val
* @returns {void}
*/
@ -1938,11 +1923,11 @@
/*
if ((node.prefix && node.prefix.includes(':')) || (node.localName && node.localName.includes(':'))) {
invalidStateError();
invalidStateError();
}
*/
var type = 'nodeType' in node ? node.nodeType : null;
namespaces = _objectSpread({}, namespaces);
namespaces = _objectSpread2({}, namespaces);
var xmlChars = /([\t\n\r -\uD7FF\uE000-\uFFFD]|(?:[\uD800-\uDBFF](?![\uDC00-\uDFFF]))(?:(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]))*$/; // eslint-disable-line no-control-regex
if ([2, 3, 4, 7, 8].includes(type) && !xmlChars.test(node.nodeValue)) {
@ -2018,7 +2003,7 @@
break;
}
case undefined: // Treat as attribute node until this is fixed: https://github.com/tmpvar/jsdom/issues/1641 / https://github.com/tmpvar/jsdom/pull/1822
case undefined: // Treat as attribute node until this is fixed: https://github.com/jsdom/jsdom/issues/1641 / https://github.com/jsdom/jsdom/pull/1822
case 2:
// ATTRIBUTE (should only get here if passing in an attribute node)
@ -3235,256 +3220,227 @@
* @returns {Promise<void>}
*/
function processResults(_x) {
return _processResults.apply(this, arguments);
}
function processResults(url) {
var queryLink, r, json, payload, _json$info, numResults, pages, currentPage, semiColonSep;
function _processResults() {
_processResults = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee3(url) {
var queryLink, r, json, payload, _json$info, numResults, pages, currentPage, semiColonSep;
return regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
queryLink = function _ref4(query) {
return ['a', {
href: jsVoid,
dataset: {
value: query
},
$on: {
click: function click(e) {
e.preventDefault();
var value = this.dataset.value;
$$1('#query')[0].$set(value);
$$1('#openclipart')[0].$submit();
}
return regeneratorRuntime.async(function processResults$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
queryLink = function _ref2(query) {
return ['a', {
href: jsVoid,
dataset: {
value: query
},
$on: {
click: function click(e) {
e.preventDefault();
var value = this.dataset.value;
$$1('#query')[0].$set(value);
$$1('#openclipart')[0].$submit();
}
}, [query]];
};
}
}, [query]];
};
_context3.next = 3;
return fetch(url);
_context2.next = 3;
return regeneratorRuntime.awrap(fetch(url));
case 3:
r = _context3.sent;
_context3.next = 6;
return r.json();
case 3:
r = _context2.sent;
_context2.next = 6;
return regeneratorRuntime.awrap(r.json());
case 6:
json = _context3.sent;
case 6:
json = _context2.sent;
if (!(!json || json.msg !== 'success')) {
_context3.next = 10;
break;
}
if (!(!json || json.msg !== 'success')) {
_context2.next = 10;
break;
}
// Todo: This could use a generic alert library instead
alert('There was a problem downloading the results'); // eslint-disable-line no-alert
// Todo: This could use a generic alert library instead
alert('There was a problem downloading the results'); // eslint-disable-line no-alert
return _context3.abrupt("return");
return _context2.abrupt("return");
case 10:
payload = json.payload, _json$info = json.info, numResults = _json$info.results, pages = _json$info.pages, currentPage = _json$info.current_page; // $('#page')[0].value = currentPage;
// $('#page')[0].max = pages;
// Unused properties:
// - `svg_filesize` always 0?
// - `dimensions: {
// png_thumb: {width, height},
// png_full_lossy: {width, height}
// }` object of relevance?
// - No need for `tags` with `tags_array`
// - `svg`'s: `png_thumb`, `png_full_lossy`, `png_2400px`
case 10:
payload = json.payload, _json$info = json.info, numResults = _json$info.results, pages = _json$info.pages, currentPage = _json$info.current_page; // $('#page')[0].value = currentPage;
// $('#page')[0].max = pages;
// Unused properties:
// - `svg_filesize` always 0?
// - `dimensions: {
// png_thumb: {width, height},
// png_full_lossy: {width, height}
// }` object of relevance?
// - No need for `tags` with `tags_array`
// - `svg`'s: `png_thumb`, `png_full_lossy`, `png_2400px`
semiColonSep = '; ' + nbsp;
$$1('#results').jml('div', [['span', ['Number of results: ', numResults]], semiColonSep, ['span', ['page ', currentPage, ' out of ', pages]]].concat(_toConsumableArray(payload.map(function (_ref3) {
var title = _ref3.title,
description = _ref3.description,
id = _ref3.id,
uploader = _ref3.uploader,
created = _ref3.created,
svgURL = _ref3.svg.url,
detailLink = _ref3.detail_link,
tagsArray = _ref3.tags_array,
downloadedBy = _ref3.downloaded_by,
totalFavorites = _ref3.total_favorites;
var imgHW = '100px';
var colonSep = ': ' + nbsp;
return ['div', [['button', {
style: 'margin-right: 8px; border: 2px solid black;',
dataset: {
id: id,
value: svgURL
},
$on: {
click: function () {
var _click = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee2(e) {
var svgurl, post, result, svg;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
e.preventDefault();
svgurl = this.dataset.value; // console.log('this', id, svgurl);
semiColonSep = '; ' + nbsp;
$$1('#results').jml('div', [['span', ['Number of results: ', numResults]], semiColonSep, ['span', ['page ', currentPage, ' out of ', pages]]].concat(_toConsumableArray(payload.map(function (_ref) {
var title = _ref.title,
description = _ref.description,
id = _ref.id,
uploader = _ref.uploader,
created = _ref.created,
svgURL = _ref.svg.url,
detailLink = _ref.detail_link,
tagsArray = _ref.tags_array,
downloadedBy = _ref.downloaded_by,
totalFavorites = _ref.total_favorites;
var imgHW = '100px';
var colonSep = ': ' + nbsp;
return ['div', [['button', {
style: 'margin-right: 8px; border: 2px solid black;',
dataset: {
id: id,
value: svgURL
},
$on: {
click: function click(e) {
var svgurl, post, result, svg;
return regeneratorRuntime.async(function click$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
e.preventDefault();
svgurl = this.dataset.value; // console.log('this', id, svgurl);
post = function post(message) {
// Todo: Make origin customizable as set by opening window
// Todo: If dropping IE9, avoid stringifying
window.parent.postMessage(JSON.stringify(_extends({
namespace: 'imagelib'
}, message)), '*');
}; // Send metadata (also indicates file is about to be sent)
post = function post(message) {
// Todo: Make origin customizable as set by opening window
// Todo: If dropping IE9, avoid stringifying
window.parent.postMessage(JSON.stringify(_extends({
namespace: 'imagelib'
}, message)), '*');
}; // Send metadata (also indicates file is about to be sent)
post({
name: title,
id: svgurl
});
_context2.next = 6;
return fetch(svgurl);
post({
name: title,
id: svgurl
});
_context.next = 6;
return regeneratorRuntime.awrap(fetch(svgurl));
case 6:
result = _context2.sent;
_context2.next = 9;
return result.text();
case 6:
result = _context.sent;
_context.next = 9;
return regeneratorRuntime.awrap(result.text());
case 9:
svg = _context2.sent;
// console.log('url and svg', svgurl, svg);
post({
href: svgurl,
data: svg
});
case 9:
svg = _context.sent;
// console.log('url and svg', svgurl, svg);
post({
href: svgurl,
data: svg
});
case 11:
case "end":
return _context2.stop();
}
}
}, _callee2, this);
}));
function click(_x2) {
return _click.apply(this, arguments);
case 11:
case "end":
return _context.stop();
}
}
}, null, this);
}
}
}, [// If we wanted interactive versions despite security risk:
// ['object', {data: svgURL, type: 'image/svg+xml'}]
['img', {
src: svgURL,
style: "width: ".concat(imgHW, "; height: ").concat(imgHW, ";")
}]]], ['b', [title]], ' ', ['i', [description]], ' ', ['span', ['(ID: ', ['a', {
href: jsVoid,
dataset: {
value: id
},
$on: {
click: function click(e) {
e.preventDefault();
var value = this.dataset.value;
$$1('#byids')[0].$set(value);
$$1('#openclipart')[0].$submit();
}
}
}, [id]], ')']], ' ', ['i', [['a', {
href: detailLink,
target: '_blank'
}, ['Details']]]], ['br'], ['span', [['u', ['Uploaded by']], colonSep, queryLink(uploader), semiColonSep]], ['span', [['u', ['Download count']], colonSep, downloadedBy, semiColonSep]], ['span', [['u', ['Times used as favorite']], colonSep, totalFavorites, semiColonSep]], ['span', [['u', ['Created date']], colonSep, created]], ['br'], ['u', ['Tags']], colonSep].concat(_toConsumableArray(tagsArray.map(function (tag) {
return ['span', [' ', queryLink(tag)]];
})))];
})), [['br'], ['br'], currentPage === 1 || pages <= 2 ? '' : ['span', [['a', {
href: jsVoid,
$on: {
click: function click(e) {
e.preventDefault();
$$1('#page')[0].value = 1;
$$1('#openclipart')[0].$submit();
}
}
}, ['First']], ' ']], currentPage === 1 ? '' : ['span', [['a', {
href: jsVoid,
$on: {
click: function click(e) {
e.preventDefault();
$$1('#page')[0].value = currentPage - 1;
$$1('#openclipart')[0].$submit();
}
}
}, ['Prev']], ' ']], currentPage === pages ? '' : ['span', [['a', {
href: jsVoid,
$on: {
click: function click(e) {
e.preventDefault();
$$1('#page')[0].value = currentPage + 1;
$$1('#openclipart')[0].$submit();
}
}
}, ['Next']], ' ']], currentPage === pages || pages <= 2 ? '' : ['span', [['a', {
href: jsVoid,
$on: {
click: function click(e) {
e.preventDefault();
$$1('#page')[0].value = pages;
$$1('#openclipart')[0].$submit();
}
}
}, ['Last']], ' ']]]));
return click;
}()
}
}, [// If we wanted interactive versions despite security risk:
// ['object', {data: svgURL, type: 'image/svg+xml'}]
['img', {
src: svgURL,
style: "width: ".concat(imgHW, "; height: ").concat(imgHW, ";")
}]]], ['b', [title]], ' ', ['i', [description]], ' ', ['span', ['(ID: ', ['a', {
href: jsVoid,
dataset: {
value: id
},
$on: {
click: function click(e) {
e.preventDefault();
var value = this.dataset.value;
$$1('#byids')[0].$set(value);
$$1('#openclipart')[0].$submit();
}
}
}, [id]], ')']], ' ', ['i', [['a', {
href: detailLink,
target: '_blank'
}, ['Details']]]], ['br'], ['span', [['u', ['Uploaded by']], colonSep, queryLink(uploader), semiColonSep]], ['span', [['u', ['Download count']], colonSep, downloadedBy, semiColonSep]], ['span', [['u', ['Times used as favorite']], colonSep, totalFavorites, semiColonSep]], ['span', [['u', ['Created date']], colonSep, created]], ['br'], ['u', ['Tags']], colonSep].concat(_toConsumableArray(tagsArray.map(function (tag) {
return ['span', [' ', queryLink(tag)]];
})))];
})), [['br'], ['br'], currentPage === 1 || pages <= 2 ? '' : ['span', [['a', {
href: jsVoid,
$on: {
click: function click(e) {
e.preventDefault();
$$1('#page')[0].value = 1;
$$1('#openclipart')[0].$submit();
}
}
}, ['First']], ' ']], currentPage === 1 ? '' : ['span', [['a', {
href: jsVoid,
$on: {
click: function click(e) {
e.preventDefault();
$$1('#page')[0].value = currentPage - 1;
$$1('#openclipart')[0].$submit();
}
}
}, ['Prev']], ' ']], currentPage === pages ? '' : ['span', [['a', {
href: jsVoid,
$on: {
click: function click(e) {
e.preventDefault();
$$1('#page')[0].value = currentPage + 1;
$$1('#openclipart')[0].$submit();
}
}
}, ['Next']], ' ']], currentPage === pages || pages <= 2 ? '' : ['span', [['a', {
href: jsVoid,
$on: {
click: function click(e) {
e.preventDefault();
$$1('#page')[0].value = pages;
$$1('#openclipart')[0].$submit();
}
}
}, ['Last']], ' ']]]));
case 13:
case "end":
return _context3.stop();
}
case 13:
case "end":
return _context2.stop();
}
}, _callee3);
}));
return _processResults.apply(this, arguments);
}
});
}
jml('div', [['style', [".control {\n padding-top: 10px;\n }"]], ['form', {
id: 'openclipart',
$custom: {
$submit: function () {
var _$submit = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee() {
var url;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
url = new URL(baseAPIURL);
['query', 'sort', 'amount', 'page', 'byids'].forEach(function (prop) {
var value = $$1('#' + prop)[0].value;
$submit: function $submit() {
var url;
return regeneratorRuntime.async(function $submit$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
url = new URL(baseAPIURL);
['query', 'sort', 'amount', 'page', 'byids'].forEach(function (prop) {
var value = $$1('#' + prop)[0].value;
if (value) {
url.searchParams.set(prop, value);
}
});
_context.next = 4;
return processResults(url);
if (value) {
url.searchParams.set(prop, value);
}
});
_context3.next = 4;
return regeneratorRuntime.awrap(processResults(url));
case 4:
case "end":
return _context.stop();
}
case 4:
case "end":
return _context3.stop();
}
}, _callee);
}));
function $submit() {
return _$submit.apply(this, arguments);
}
return $submit;
}()
}
});
}
},
$on: {
submit: function submit(e) {
@ -3532,11 +3488,11 @@
}, [['label', ['Sort by: ', ['select', {
id: 'sort'
}, [// Todo: i18nize first values
['Date', 'date'], ['Downloads', 'downloads'], ['Favorited', 'favorites']].map(function (_ref) {
var _ref2 = _slicedToArray(_ref, 2),
text = _ref2[0],
_ref2$ = _ref2[1],
value = _ref2$ === void 0 ? text : _ref2$;
['Date', 'date'], ['Downloads', 'downloads'], ['Favorited', 'favorites']].map(function (_ref3) {
var _ref4 = _slicedToArray(_ref3, 2),
text = _ref4[0],
_ref4$ = _ref4[1],
value = _ref4$ === void 0 ? text : _ref4$;
return ['option', {
value: value

3905
dist/index-es.js vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

3909
dist/index-umd.js vendored

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

597
dist/svgcanvas-iife.js vendored
View File

@ -15,42 +15,6 @@ var SvgCanvas = (function () {
return _typeof(obj);
}
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
@ -11449,8 +11413,38 @@ var SvgCanvas = (function () {
* any other value depends on the export of the targeted module.
*/
function importSetGlobal(_x, _x2) {
return _importSetGlobal.apply(this, arguments);
function importSetGlobal(url, _ref) {
var glob, returnDefault, modularVersion;
return regeneratorRuntime.async(function importSetGlobal$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
glob = _ref.global, returnDefault = _ref.returnDefault;
// Todo: Replace calls to this function with `import()` when supported
modularVersion = !('svgEditor' in window) || !window.svgEditor || window.svgEditor.modules !== false;
if (!modularVersion) {
_context.next = 4;
break;
}
return _context.abrupt("return", importModule(url, undefined, {
returnDefault: returnDefault
}));
case 4:
_context.next = 6;
return regeneratorRuntime.awrap(importScript(url));
case 6:
return _context.abrupt("return", window[glob]);
case 7:
case "end":
return _context.stop();
}
}
});
}
/**
*
@ -11461,45 +11455,6 @@ var SvgCanvas = (function () {
* script loading error
*/
function _importSetGlobal() {
_importSetGlobal = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(url, _ref) {
var glob, returnDefault, modularVersion;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
glob = _ref.global, returnDefault = _ref.returnDefault;
// Todo: Replace calls to this function with `import()` when supported
modularVersion = !('svgEditor' in window) || !window.svgEditor || window.svgEditor.modules !== false;
if (!modularVersion) {
_context.next = 4;
break;
}
return _context.abrupt("return", importModule(url, undefined, {
returnDefault: returnDefault
}));
case 4:
_context.next = 6;
return importScript(url);
case 6:
return _context.abrupt("return", window[glob]);
case 7:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return _importSetGlobal.apply(this, arguments);
}
function importScript(url) {
var atts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@ -12351,16 +12306,16 @@ var SvgCanvas = (function () {
// }
var angle = getRotationAngle(child);
oldStartTransform = context_.getStartTransform();
var childxforms = [];
oldStartTransform = context_.getStartTransform(); // const childxforms = [];
context_.setStartTransform(child.getAttribute('transform'));
if (angle || hasMatrixTransform(childTlist)) {
var e2t = svgroot.createSVGTransform();
e2t.setMatrix(matrixMultiply(tm, sm, tmn, _m));
childTlist.clear();
childTlist.appendItem(e2t);
childxforms.push(e2t); // if not rotated or skewed, push the [T][S][-T] down to the child
childTlist.appendItem(e2t); // childxforms.push(e2t);
// if not rotated or skewed, push the [T][S][-T] down to the child
} else {
// update the transform list with translate,scale,translate
// slide the [T][S][-T] from the front to the back
@ -12384,10 +12339,10 @@ var SvgCanvas = (function () {
translateBack.setTranslate(t2.e, t2.f);
childTlist.appendItem(translateBack);
childTlist.appendItem(scale);
childTlist.appendItem(translateOrigin);
childxforms.push(translateBack);
childxforms.push(scale);
childxforms.push(translateOrigin); // logMatrix(translateBack.matrix);
childTlist.appendItem(translateOrigin); // childxforms.push(translateBack);
// childxforms.push(scale);
// childxforms.push(translateOrigin);
// logMatrix(translateBack.matrix);
// logMatrix(scale.matrix);
} // not rotated
@ -14628,84 +14583,74 @@ var SvgCanvas = (function () {
*/
this.addExtension =
/*#__PURE__*/
function () {
var _ref4 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(name, extInitFunc, _ref3) {
var jq, importLocale, argObj, extObj;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
jq = _ref3.$, importLocale = _ref3.importLocale;
this.addExtension = function _callee(name, extInitFunc, _ref3) {
var jq, importLocale, argObj, extObj;
return regeneratorRuntime.async(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
jq = _ref3.$, importLocale = _ref3.importLocale;
if (!(typeof extInitFunc !== 'function')) {
_context.next = 3;
break;
}
if (!(typeof extInitFunc !== 'function')) {
_context.next = 3;
break;
}
throw new TypeError('Function argument expected for `svgcanvas.addExtension`');
throw new TypeError('Function argument expected for `svgcanvas.addExtension`');
case 3:
if (!(name in extensions)) {
_context.next = 5;
break;
}
case 3:
if (!(name in extensions)) {
_context.next = 5;
break;
}
throw new Error('Cannot add extension "' + name + '", an extension by that name already exists.');
throw new Error('Cannot add extension "' + name + '", an extension by that name already exists.');
case 5:
// Provide private vars/funcs here. Is there a better way to do this?
case 5:
// Provide private vars/funcs here. Is there a better way to do this?
/**
* @typedef {module:svgcanvas.PrivateMethods} module:svgcanvas.ExtensionArgumentObject
* @property {SVGSVGElement} svgroot See {@link module:svgcanvas~svgroot}
* @property {SVGSVGElement} svgcontent See {@link module:svgcanvas~svgcontent}
* @property {!(string|Integer)} nonce See {@link module:draw.Drawing#getNonce}
* @property {module:select.SelectorManager} selectorManager
* @property {module:SVGEditor~ImportLocale} importLocale
*/
/**
* @typedef {module:svgcanvas.PrivateMethods} module:svgcanvas.ExtensionArgumentObject
* @property {SVGSVGElement} svgroot See {@link module:svgcanvas~svgroot}
* @property {SVGSVGElement} svgcontent See {@link module:svgcanvas~svgcontent}
* @property {!(string|Integer)} nonce See {@link module:draw.Drawing#getNonce}
* @property {module:select.SelectorManager} selectorManager
* @property {module:SVGEditor~ImportLocale} importLocale
*/
/**
* @type {module:svgcanvas.ExtensionArgumentObject}
* @see {@link module:svgcanvas.PrivateMethods} source for the other methods/properties
*/
argObj = $$8.extend(canvas.getPrivateMethods(), {
$: jq,
importLocale: importLocale,
svgroot: svgroot,
svgcontent: svgcontent,
nonce: getCurrentDrawing().getNonce(),
selectorManager: selectorManager
});
_context.next = 8;
return extInitFunc(argObj);
/**
* @type {module:svgcanvas.ExtensionArgumentObject}
* @see {@link module:svgcanvas.PrivateMethods} source for the other methods/properties
*/
argObj = $$8.extend(canvas.getPrivateMethods(), {
$: jq,
importLocale: importLocale,
svgroot: svgroot,
svgcontent: svgcontent,
nonce: getCurrentDrawing().getNonce(),
selectorManager: selectorManager
});
_context.next = 8;
return regeneratorRuntime.awrap(extInitFunc(argObj));
case 8:
extObj = _context.sent;
case 8:
extObj = _context.sent;
if (extObj) {
extObj.name = name;
} // eslint-disable-next-line require-atomic-updates
if (extObj) {
extObj.name = name;
} // eslint-disable-next-line require-atomic-updates
extensions[name] = extObj;
return _context.abrupt("return", call('extension_added', extObj));
extensions[name] = extObj;
return _context.abrupt("return", call('extension_added', extObj));
case 12:
case "end":
return _context.stop();
}
case 12:
case "end":
return _context.stop();
}
}, _callee);
}));
return function (_x, _x2, _x3) {
return _ref4.apply(this, arguments);
};
}();
}
});
};
/**
* This method sends back an array or a NodeList full of elements that
* intersect the multi-select rubber-band-box on the currentLayer only.
@ -17826,115 +17771,105 @@ var SvgCanvas = (function () {
* @returns {Promise<module:svgcanvas.ImageExportedResults>} Resolves to {@link module:svgcanvas.ImageExportedResults}
*/
this.rasterExport =
/*#__PURE__*/
function () {
var _ref5 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee2(imgType, quality, exportWindowName) {
var opts,
type,
mimeType,
_getIssues,
issues,
issueCodes,
svg,
_ref6,
c,
_args2 = arguments;
this.rasterExport = function _callee2(imgType, quality, exportWindowName) {
var opts,
type,
mimeType,
_getIssues,
issues,
issueCodes,
svg,
_ref4,
c,
_args2 = arguments;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
opts = _args2.length > 3 && _args2[3] !== undefined ? _args2[3] : {};
type = imgType === 'ICO' ? 'BMP' : imgType || 'PNG';
mimeType = 'image/' + type.toLowerCase();
_getIssues = getIssues(), issues = _getIssues.issues, issueCodes = _getIssues.issueCodes;
svg = this.svgCanvasToString();
return regeneratorRuntime.async(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
opts = _args2.length > 3 && _args2[3] !== undefined ? _args2[3] : {};
type = imgType === 'ICO' ? 'BMP' : imgType || 'PNG';
mimeType = 'image/' + type.toLowerCase();
_getIssues = getIssues(), issues = _getIssues.issues, issueCodes = _getIssues.issueCodes;
svg = this.svgCanvasToString();
if (canvg) {
_context2.next = 10;
break;
}
if (canvg) {
_context2.next = 10;
break;
}
_context2.next = 8;
return importSetGlobal(curConfig.canvgPath + 'canvg.js', {
global: 'canvg'
});
_context2.next = 8;
return regeneratorRuntime.awrap(importSetGlobal(curConfig.canvgPath + 'canvg.js', {
global: 'canvg'
}));
case 8:
_ref6 = _context2.sent;
canvg = _ref6.canvg;
case 8:
_ref4 = _context2.sent;
canvg = _ref4.canvg;
case 10:
if (!$$8('#export_canvas').length) {
$$8('<canvas>', {
id: 'export_canvas'
}).hide().appendTo('body');
}
case 10:
if (!$$8('#export_canvas').length) {
$$8('<canvas>', {
id: 'export_canvas'
}).hide().appendTo('body');
}
c = $$8('#export_canvas')[0];
c.width = canvas.contentW;
c.height = canvas.contentH;
_context2.next = 16;
return canvg(c, svg);
c = $$8('#export_canvas')[0];
c.width = canvas.contentW;
c.height = canvas.contentH;
_context2.next = 16;
return regeneratorRuntime.awrap(canvg(c, svg));
case 16:
return _context2.abrupt("return", new Promise(function (resolve, reject) {
// eslint-disable-line promise/avoid-new
var dataURLType = type.toLowerCase();
var datauri = quality ? c.toDataURL('image/' + dataURLType, quality) : c.toDataURL('image/' + dataURLType);
var bloburl;
/**
* Called when `bloburl` is available for export.
* @returns {void}
*/
case 16:
return _context2.abrupt("return", new Promise(function (resolve, reject) {
// eslint-disable-line promise/avoid-new
var dataURLType = type.toLowerCase();
var datauri = quality ? c.toDataURL('image/' + dataURLType, quality) : c.toDataURL('image/' + dataURLType);
var bloburl;
/**
* Called when `bloburl` is available for export.
* @returns {void}
*/
function done() {
var obj = {
datauri: datauri,
bloburl: bloburl,
svg: svg,
issues: issues,
issueCodes: issueCodes,
type: imgType,
mimeType: mimeType,
quality: quality,
exportWindowName: exportWindowName
};
function done() {
var obj = {
datauri: datauri,
bloburl: bloburl,
svg: svg,
issues: issues,
issueCodes: issueCodes,
type: imgType,
mimeType: mimeType,
quality: quality,
exportWindowName: exportWindowName
};
if (!opts.avoidEvent) {
call('exported', obj);
}
resolve(obj);
if (!opts.avoidEvent) {
call('exported', obj);
}
if (c.toBlob) {
c.toBlob(function (blob) {
bloburl = createObjectURL(blob);
done();
}, mimeType, quality);
return;
}
resolve(obj);
}
bloburl = dataURLToObjectURL(datauri);
done();
}));
if (c.toBlob) {
c.toBlob(function (blob) {
bloburl = createObjectURL(blob);
done();
}, mimeType, quality);
return;
}
case 17:
case "end":
return _context2.stop();
}
bloburl = dataURLToObjectURL(datauri);
done();
}));
case 17:
case "end":
return _context2.stop();
}
}, _callee2, this);
}));
return function (_x4, _x5, _x6) {
return _ref5.apply(this, arguments);
};
}();
}
}, null, this);
};
/**
* @external jsPDF
*/
@ -17974,103 +17909,93 @@ var SvgCanvas = (function () {
*/
this.exportPDF =
/*#__PURE__*/
function () {
var _ref7 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee3(exportWindowName) {
var outputType,
modularVersion,
res,
orientation,
unit,
doc,
docTitle,
_getIssues2,
issues,
issueCodes,
svg,
obj,
_args3 = arguments;
this.exportPDF = function _callee3(exportWindowName) {
var outputType,
modularVersion,
res,
orientation,
unit,
doc,
docTitle,
_getIssues2,
issues,
issueCodes,
svg,
obj,
_args3 = arguments;
return regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
outputType = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : isChrome() ? 'save' : undefined;
if (window.jsPDF) {
_context3.next = 7;
break;
}
_context3.next = 4;
return importScript([// We do not currently have these paths configurable as they are
// currently global-only, so not Rolled-up
'jspdf/underscore-min.js', 'jspdf/jspdf.min.js']);
case 4:
modularVersion = !('svgEditor' in window) || !window.svgEditor || window.svgEditor.modules !== false; // Todo: Switch to `import()` when widely supported and available (also allow customization of path)
return regeneratorRuntime.async(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
outputType = _args3.length > 1 && _args3[1] !== undefined ? _args3[1] : isChrome() ? 'save' : undefined;
if (window.jsPDF) {
_context3.next = 7;
return importScript(curConfig.jspdfPath + 'jspdf.plugin.svgToPdf.js', {
type: modularVersion ? 'module' : 'text/javascript'
});
break;
}
case 7:
res = getResolution();
orientation = res.w > res.h ? 'landscape' : 'portrait';
unit = 'pt'; // curConfig.baseUnit; // We could use baseUnit, but that is presumably not intended for export purposes
// Todo: Give options to use predefined jsPDF formats like "a4", etc. from pull-down (with option to keep customizable)
_context3.next = 4;
return regeneratorRuntime.awrap(importScript([// We do not currently have these paths configurable as they are
// currently global-only, so not Rolled-up
'jspdf/underscore-min.js', 'jspdf/jspdf.min.js']));
doc = jsPDF({
orientation: orientation,
unit: unit,
format: [res.w, res.h] // , compressPdf: true
case 4:
modularVersion = !('svgEditor' in window) || !window.svgEditor || window.svgEditor.modules !== false; // Todo: Switch to `import()` when widely supported and available (also allow customization of path)
});
docTitle = getDocumentTitle();
doc.setProperties({
title: docTitle
/* ,
subject: '',
author: '',
keywords: '',
creator: '' */
_context3.next = 7;
return regeneratorRuntime.awrap(importScript(curConfig.jspdfPath + 'jspdf.plugin.svgToPdf.js', {
type: modularVersion ? 'module' : 'text/javascript'
}));
});
_getIssues2 = getIssues(), issues = _getIssues2.issues, issueCodes = _getIssues2.issueCodes;
svg = this.svgCanvasToString();
doc.addSVG(svg, 0, 0); // doc.output('save'); // Works to open in a new
// window; todo: configure this and other export
// options to optionally work in this manner as
// opposed to opening a new tab
case 7:
res = getResolution();
orientation = res.w > res.h ? 'landscape' : 'portrait';
unit = 'pt'; // curConfig.baseUnit; // We could use baseUnit, but that is presumably not intended for export purposes
// Todo: Give options to use predefined jsPDF formats like "a4", etc. from pull-down (with option to keep customizable)
outputType = outputType || 'dataurlstring';
obj = {
svg: svg,
issues: issues,
issueCodes: issueCodes,
exportWindowName: exportWindowName,
outputType: outputType
};
obj.output = doc.output(outputType, outputType === 'save' ? exportWindowName || 'svg.pdf' : undefined);
call('exportedPDF', obj);
return _context3.abrupt("return", obj);
doc = jsPDF({
orientation: orientation,
unit: unit,
format: [res.w, res.h] // , compressPdf: true
case 21:
case "end":
return _context3.stop();
}
});
docTitle = getDocumentTitle();
doc.setProperties({
title: docTitle
/* ,
subject: '',
author: '',
keywords: '',
creator: '' */
});
_getIssues2 = getIssues(), issues = _getIssues2.issues, issueCodes = _getIssues2.issueCodes;
svg = this.svgCanvasToString();
doc.addSVG(svg, 0, 0); // doc.output('save'); // Works to open in a new
// window; todo: configure this and other export
// options to optionally work in this manner as
// opposed to opening a new tab
outputType = outputType || 'dataurlstring';
obj = {
svg: svg,
issues: issues,
issueCodes: issueCodes,
exportWindowName: exportWindowName,
outputType: outputType
};
obj.output = doc.output(outputType, outputType === 'save' ? exportWindowName || 'svg.pdf' : undefined);
call('exportedPDF', obj);
return _context3.abrupt("return", obj);
case 21:
case "end":
return _context3.stop();
}
}, _callee3, this);
}));
return function (_x7) {
return _ref7.apply(this, arguments);
};
}();
}
}, null, this);
};
/**
* Returns the current drawing as raw SVG XML text.
* @function module:svgcanvas.SvgCanvas#getSvgString
@ -18798,10 +18723,10 @@ var SvgCanvas = (function () {
leaveContext: leaveContext,
setContext: setContext
};
Object.entries(dr).forEach(function (_ref8) {
var _ref9 = _slicedToArray(_ref8, 2),
prop = _ref9[0],
propVal = _ref9[1];
Object.entries(dr).forEach(function (_ref5) {
var _ref6 = _slicedToArray(_ref5, 2),
prop = _ref6[0],
propVal = _ref6[1];
canvas[prop] = propVal;
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -8,10 +8,9 @@
*
* @module jQueryContextMenu
* @todo Update to latest version and adapt (and needs jQuery update as well): {@link https://github.com/swisnl/jQuery-contextMenu}
* @version 1.01
* @version 1.0.1
*
* @license
* Terms of Use
* @license (GPL-2.0-or-later OR MIT)
*
* This plugin is dual-licensed under the GNU General Public License
* and the MIT License and is copyright A Beautiful Site, LLC.

View File

@ -2,7 +2,7 @@
/**
* ext-mathjax.js
*
* @license Apache
* @license Apache-2.0
*
* @copyright 2013 Jo Segaert
*

File diff suppressed because it is too large Load Diff

38
package-lock.json generated
View File

@ -4011,9 +4011,9 @@
}
},
"eslint-config-ash-nazg": {
"version": "11.3.0",
"resolved": "https://registry.npmjs.org/eslint-config-ash-nazg/-/eslint-config-ash-nazg-11.3.0.tgz",
"integrity": "sha512-mQ6yQXBCxSy2nVk0LRNfyJWxUGMwXRhtOJyQJjF3lIHyjUdjYd2IMDpPBg7Ie/tftkkk6zEzQ+TBuUsHVHEtfg==",
"version": "11.4.0",
"resolved": "https://registry.npmjs.org/eslint-config-ash-nazg/-/eslint-config-ash-nazg-11.4.0.tgz",
"integrity": "sha512-5HvR9GtShur4y1+QFzpF6v3aB4juRtAA8vi+cQA1gIPd6/rq3zSVwKgjefsU1DY3LttnE68DTLgfoYPnvDgPiA==",
"dev": true
},
"eslint-config-standard": {
@ -4229,17 +4229,27 @@
}
},
"eslint-plugin-jsdoc": {
"version": "17.1.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-17.1.1.tgz",
"integrity": "sha512-astLOTsj87UIzvDyiuAKbkgQgtChutazTDVxdG254tAtcvIVlWnPmlN7/dLnMYld/aHBhB4SWiUalMuKwTaynQ==",
"version": "18.0.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-18.0.1.tgz",
"integrity": "sha512-ofNW3JmuZD9Gqn+qp/M6vPUfyaWHtfiNdmuoYmjyBcf5Xh2SMe1dnFa+gTGpfZLrjvBCdIbjxryRiF2QdqlQ0g==",
"dev": true,
"requires": {
"comment-parser": "^0.7.0",
"debug": "^4.1.1",
"jsdoctypeparser": "^5.1.1",
"jsdoctypeparser": "^6.0.0",
"lodash": "^4.17.15",
"object.entries-ponyfill": "^1.0.1",
"regextras": "^0.6.1"
"regextras": "^0.6.1",
"semver": "^6.3.0",
"spdx-expression-parse": "^3.0.0"
},
"dependencies": {
"semver": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz",
"integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==",
"dev": true
}
}
},
"eslint-plugin-markdown": {
@ -5942,9 +5952,9 @@
}
},
"jsdoctypeparser": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/jsdoctypeparser/-/jsdoctypeparser-5.1.1.tgz",
"integrity": "sha512-APGygIJrT5bbz5lsVt8vyLJC0miEbQf/z9ZBfTr4RYvdia8AhWMRlYgivvwHG5zKD/VW3d6qpChCy64hpQET3A==",
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/jsdoctypeparser/-/jsdoctypeparser-6.0.0.tgz",
"integrity": "sha512-61VtBXLkHfOFSIdp/VDVNMksxK0ID0cPTNvxDR92tPA6K7r2AX0OcJegYxhJIwtpWKU4p3D9L3U02hhlP1kQLQ==",
"dev": true
},
"jsdom": {
@ -8042,9 +8052,9 @@
}
},
"rollup": {
"version": "1.26.5",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-1.26.5.tgz",
"integrity": "sha512-c6Pv0yWzjYNpy2DIhLFUnyP6e1UTGownr4IfpJcPY/k186RJjpaGGPRwKQ62KCauctG6dgtHt88pw1EGrPRkuA==",
"version": "1.27.0",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-1.27.0.tgz",
"integrity": "sha512-yaMna4MJ8LLEHhHl1ilgHakylf0LKeQctDxhngZLQ+W57GnXa5vtH7XKaK8zlAhNEhlWiH5YFVFt+QCDPUmNkw==",
"dev": true,
"requires": {
"@types/estree": "*",

View File

@ -88,14 +88,14 @@
"babel-plugin-transform-object-rest-spread": "^7.0.0-beta.3",
"core-js-bundle": "^3.4.1",
"eslint": "6.6.0",
"eslint-config-ash-nazg": "11.3.0",
"eslint-config-ash-nazg": "11.4.0",
"eslint-config-standard": "14.1.0",
"eslint-plugin-array-func": "^3.1.3",
"eslint-plugin-compat": "^3.3.0",
"eslint-plugin-eslint-comments": "^3.1.2",
"eslint-plugin-html": "^6.0.0",
"eslint-plugin-import": "2.18.2",
"eslint-plugin-jsdoc": "^17.1.1",
"eslint-plugin-jsdoc": "^18.0.1",
"eslint-plugin-markdown": "^1.0.1",
"eslint-plugin-no-use-extend-native": "^0.4.1",
"eslint-plugin-node": "10.0.0",
@ -118,7 +118,7 @@
"regenerator-runtime": "^0.13.3",
"remark-cli": "^7.0.1",
"remark-lint-ordered-list-marker-value": "^1.0.3",
"rollup": "1.26.5",
"rollup": "1.27.0",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-re": "^1.0.7",
"rollup-plugin-terser": "^5.1.2",

File diff suppressed because it is too large Load Diff