Starting Branch to simplify Build process

This commit is contained in:
JFH
2020-08-05 19:58:06 +02:00
parent 8f827c973f
commit 31bca25b1c
344 changed files with 24742 additions and 179621 deletions

4915
dist/canvg.js vendored

File diff suppressed because it is too large Load Diff

165
dist/dom-polyfill.js vendored
View File

@@ -1,165 +0,0 @@
(function () {
'use strict';
function _typeof(obj) {
"@babel/helpers - typeof";
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
// From https://github.com/inexorabletash/polyfill/blob/master/dom.js
/**
* @module DOMPolyfill
*/
/**
*
* @param {Node} o
* @param {module:DOMPolyfill~ParentNode|module:DOMPolyfill~ChildNode} ps
* @returns {void}
*/
function mixin(o, ps) {
if (!o) return;
Object.keys(ps).forEach(function (p) {
if (p in o || p in o.prototype) {
return;
}
try {
Object.defineProperty(o.prototype, p, Object.getOwnPropertyDescriptor(ps, p));
} catch (ex) {
// Throws in IE8; just copy it
o[p] = ps[p];
}
});
}
/**
*
* @param {Node[]} nodes
* @returns {Node}
*/
function convertNodesIntoANode(nodes) {
nodes = nodes.map(function (node) {
var isNode = node && _typeof(node) === 'object' && 'nodeType' in node;
return isNode ? node : document.createTextNode(node);
});
if (nodes.length === 1) {
return nodes[0];
}
var node = document.createDocumentFragment();
nodes.forEach(function (n) {
// // eslint-disable-next-line unicorn/prefer-node-append
node.appendChild(n);
});
return node;
}
var ParentNode = {
prepend: function prepend() {
for (var _len = arguments.length, nodes = new Array(_len), _key = 0; _key < _len; _key++) {
nodes[_key] = arguments[_key];
}
nodes = convertNodesIntoANode(nodes);
this.insertBefore(nodes, this.firstChild);
},
append: function append() {
for (var _len2 = arguments.length, nodes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
nodes[_key2] = arguments[_key2];
}
nodes = convertNodesIntoANode(nodes); // // eslint-disable-next-line unicorn/prefer-node-append
this.appendChild(nodes);
}
};
mixin(Document || HTMLDocument, ParentNode); // HTMLDocument for IE8
mixin(DocumentFragment, ParentNode);
mixin(Element, ParentNode); // Mixin ChildNode
// https://dom.spec.whatwg.org/#interface-childnode
var ChildNode = {
before: function before() {
var parent = this.parentNode;
if (!parent) return;
var viablePreviousSibling = this.previousSibling;
for (var _len3 = arguments.length, nodes = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
nodes[_key3] = arguments[_key3];
}
while (nodes.includes(viablePreviousSibling)) {
viablePreviousSibling = viablePreviousSibling.previousSibling;
}
var node = convertNodesIntoANode(nodes);
parent.insertBefore(node, viablePreviousSibling ? viablePreviousSibling.nextSibling : parent.firstChild);
},
after: function after() {
var parent = this.parentNode;
if (!parent) return;
var viableNextSibling = this.nextSibling;
for (var _len4 = arguments.length, nodes = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
nodes[_key4] = arguments[_key4];
}
while (nodes.includes(viableNextSibling)) {
viableNextSibling = viableNextSibling.nextSibling;
}
var node = convertNodesIntoANode(nodes); // eslint-disable-next-line unicorn/prefer-modern-dom-apis
parent.insertBefore(node, viableNextSibling);
},
replaceWith: function replaceWith() {
var parent = this.parentNode;
if (!parent) return;
var viableNextSibling = this.nextSibling;
for (var _len5 = arguments.length, nodes = new Array(_len5), _key5 = 0; _key5 < _len5; _key5++) {
nodes[_key5] = arguments[_key5];
}
while (nodes.includes(viableNextSibling)) {
viableNextSibling = viableNextSibling.nextSibling;
}
var node = convertNodesIntoANode(nodes);
if (this.parentNode === parent) {
parent.replaceChild(node, this);
} else {
// eslint-disable-next-line unicorn/prefer-modern-dom-apis
parent.insertBefore(node, viableNextSibling);
}
},
remove: function remove() {
if (!this.parentNode) {
return;
}
this.parentNode.removeChild(this); // eslint-disable-line unicorn/prefer-node-remove
}
};
mixin(DocumentType, ChildNode);
mixin(Element, ChildNode);
mixin(CharacterData, ChildNode);
}());

BIN
dist/extensions/closepath.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

41
dist/extensions/closepath_icons.svg vendored Normal file
View File

@@ -0,0 +1,41 @@
<svg xmlns="http://www.w3.org/2000/svg">
<g id="tool_closepath">
<svg viewBox="0 0 300 300" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g>
<title>Layer 1</title>
<path stroke="#000" stroke-width="15" fill="#ffc8c8" d="m121.5,40l-84,106l27,115l166,2l29,-111"/>
<line x1="240" y1="136" x2="169.5" y2="74" stroke="#A00" stroke-width="25" fill="none"/>
<path stroke="none" fill ="#A00" d="m158,65l31,74l-3,-50l51,-3z"/>
<g stroke-width="15" stroke="#00f" fill="#0ff">
<circle r="30" cy="41" cx="123"/>
<circle r="30" cy="146" cx="40"/>
<circle r="30" cy="260" cx="69"/>
<circle r="30" cy="260" cx="228"/>
<circle r="30" cy="148" cx="260"/>
</g>
</g>
</svg>
</g>
<g id="tool_openpath">
<svg viewBox="0 0 300 300" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g>
<title>Layer 1</title>
<path stroke="#000" stroke-width="15" fill="#ffc8c8" d="m123.5,38l-84,106l27,115l166,2l29,-111"/>
<line x1="276.5" y1="153" x2="108.5" y2="24" stroke="#000" stroke-width="10" fill="none"/>
<g stroke-width="15" stroke="#00f" fill="#0ff">
<circle r="30" cy="41" cx="123"/>
<circle r="30" cy="146" cx="40"/>
<circle r="30" cy="260" cx="69"/>
<circle r="30" cy="260" cx="228"/>
<circle r="30" cy="148" cx="260"/>
</g>
<g stroke="#A00" stroke-width="15" fill="none">
<line x1="168" y1="24" x2="210" y2="150"/>
<line x1="210" y1="24" x2="168" y2="150"/>
</g>
</g>
</svg>
</g>
<g id="svg_eof"/>
</svg>

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -1,43 +1,4 @@
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);
});
};
}
/**
/**
* @file ext-arrows.js
*
* @license MIT
@@ -45,93 +6,181 @@ var svgEditorExtension_arrows = (function () {
* @copyright 2010 Alexis Deveria
*
*/
var extArrows = {
export default {
name: 'arrows',
init: function init(S) {
var _this = this;
async init (S) {
const strings = await S.importLocale();
const svgEditor = this;
const svgCanvas = svgEditor.canvas;
const // {svgcontent} = S,
addElem = svgCanvas.addSVGElementFromJson,
{nonce, $} = S,
prefix = 'se_arrow_';
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
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 _colorChanged(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);
let selElems, arrowprefix, randomizeIds = S.randomize_ids;
if (!marker) {
return;
/**
* @param {Window} win
* @param {!(string|Integer)} n
* @returns {void}
*/
function setArrowNonce (win, n) {
randomizeIds = true;
arrowprefix = prefix + n + '_';
pathdata.fw.id = arrowprefix + 'fw';
pathdata.bk.id = arrowprefix + 'bk';
}
var curColor = $(marker).children().attr('fill');
var curD = $(marker).children().attr('d');
if (curColor === color) {
return;
/**
* @param {Window} win
* @returns {void}
*/
function unsetArrowNonce (win) {
randomizeIds = false;
arrowprefix = prefix;
pathdata.fw.id = arrowprefix + 'fw';
pathdata.bk.id = arrowprefix + 'bk';
}
var allMarkers = $(defs).find('marker');
var newMarker = null; // Different color, check if already made
svgCanvas.bind('setnonce', setArrowNonce);
svgCanvas.bind('unsetnonce', unsetArrowNonce);
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;
}
});
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 (randomizeIds) {
arrowprefix = prefix + nonce + '_';
} else {
arrowprefix = prefix;
}
$(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;
$.each(mtypes, function (j, mtype) {
if ($(element).attr('marker-' + mtype) === 'url(#' + marker.id + ')') {
remove = false;
return remove;
}
return undefined;
});
if (!remove) {
return false;
}
return undefined;
}); // Not found, so can safely remove
if (remove) {
$(marker).remove();
}
});
const 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'}
};
setArrow = function _setArrow() {
resetMarker();
var type = this.value;
/**
* Gets linked element.
* @param {Element} elem
* @param {string} attr
* @returns {Element}
*/
function getLinked (elem, attr) {
const str = elem.getAttribute(attr);
if (!str) { return null; }
const m = str.match(/\(#(.*)\)/);
// const m = str.match(/\(#(?<id>.+)\)/);
// if (!m || !m.groups.id) {
if (!m || m.length !== 2) {
return null;
}
return svgCanvas.getElem(m[1]);
// return svgCanvas.getElem(m.groups.id);
}
/**
* @param {boolean} on
* @returns {void}
*/
function showPanel (on) {
$('#arrow_panel').toggle(on);
if (on) {
const el = selElems[0];
const end = el.getAttribute('marker-end');
const start = el.getAttribute('marker-start');
const mid = el.getAttribute('marker-mid');
let 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);
}
}
/**
*
* @returns {void}
*/
function resetMarker () {
const el = selElems[0];
el.removeAttribute('marker-start');
el.removeAttribute('marker-mid');
el.removeAttribute('marker-end');
}
/**
* @param {"bk"|"fw"} dir
* @param {"both"|"mid"|"end"|"start"} type
* @param {string} id
* @returns {Element}
*/
function addMarker (dir, type, id) {
// TODO: Make marker (or use?) per arrow type, since refX can be different
id = id || arrowprefix + dir;
const data = pathdata[dir];
if (type === 'mid') {
data.refx = 5;
}
let marker = svgCanvas.getElem(id);
if (!marker) {
marker = addElem({
element: 'marker',
attr: {
viewBox: '0 0 10 10',
id,
refY: 5,
markerUnits: 'strokeWidth',
markerWidth: 5,
markerHeight: 5,
orient: 'auto',
style: 'pointer-events:none' // Currently needed for Opera
}
});
const arrow = addElem({
element: 'path',
attr: {
d: data.d,
fill: '#000000'
}
});
marker.append(arrow);
svgCanvas.findDefs().append(marker);
}
marker.setAttribute('refX', data.refx);
return marker;
}
/**
*
* @returns {void}
*/
function setArrow () {
resetMarker();
let type = this.value;
if (type === 'none') {
return;
} // Set marker on element
var dir = 'fw';
}
// Set marker on element
let dir = 'fw';
if (type === 'mid_bk') {
type = 'mid';
dir = 'bk';
@@ -147,164 +196,72 @@ var svgEditorExtension_arrows = (function () {
addMarker(dir, type);
svgCanvas.changeSelectedAttribute('marker-' + type, 'url(#' + pathdata[dir].id + ')');
svgCanvas.call('changed', selElems);
};
addMarker = function _addMarker(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 _resetMarker() {
var el = selElems[0];
el.removeAttribute('marker-start');
el.removeAttribute('marker-mid');
el.removeAttribute('marker-end');
};
showPanel = function _showPanel(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 _getLinked(elem, attr) {
var str = elem.getAttribute(attr);
if (!str) {
return null;
}
var m = str.match(/\(#(.*)\)/); // const m = str.match(/\(#(?<id>.+)\)/);
// if (!m || !m.groups.id) {
if (!m || m.length !== 2) {
return null;
}
return svgCanvas.getElem(m[1]); // return svgCanvas.getElem(m.groups.id);
};
unsetArrowNonce = function _unsetArrowNonce(win) {
randomizeIds = false;
arrowprefix = prefix;
pathdata.fw.id = arrowprefix + 'fw';
pathdata.bk.id = arrowprefix + 'bk';
};
setArrowNonce = function _setArrowNonce(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
* @param {Element} elem
* @returns {void}
*/
function colorChanged (elem) {
const color = elem.getAttribute('stroke');
const mtypes = ['start', 'mid', 'end'];
const defs = svgCanvas.findDefs();
svgCanvas.bind('setnonce', setArrowNonce);
svgCanvas.bind('unsetnonce', unsetArrowNonce);
$.each(mtypes, function (i, type) {
const marker = getLinked(elem, 'marker-' + type);
if (!marker) { return; }
if (randomizeIds) {
arrowprefix = prefix + nonce + '_';
} else {
arrowprefix = prefix;
const curColor = $(marker).children().attr('fill');
const curD = $(marker).children().attr('d');
if (curColor === color) { return; }
const allMarkers = $(defs).find('marker');
let newMarker = null;
// Different color, check if already made
allMarkers.each(function () {
const attrs = $(this).children().attr(['fill', 'd']);
if (attrs.fill === color && attrs.d === curD) {
// Found another marker with this color and this path
newMarker = this;
}
});
if (!newMarker) {
// Create a new marker with this color
const lastId = marker.id;
const dir = lastId.includes('_fw') ? 'fw' : 'bk';
newMarker = addMarker(dir, type, arrowprefix + dir + allMarkers.length);
$(newMarker).children().attr('fill', color);
}
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}
*/
$(elem).attr('marker-' + type, 'url(#' + newMarker.id + ')');
contextTools = [{
// Check if last marker can be removed
let remove = true;
$(S.svgcontent).find('line, polyline, path, polygon').each(function () {
const element = this;
$.each(mtypes, function (j, mtype) {
if ($(element).attr('marker-' + mtype) === 'url(#' + marker.id + ')') {
remove = false;
return remove;
}
return undefined;
});
if (!remove) { return false; }
return undefined;
});
// Not found, so can safely remove
if (remove) {
$(marker).remove();
}
});
}
const contextTools = [
{
type: 'select',
panel: 'arrow_panel',
id: 'arrow_list',
@@ -312,53 +269,33 @@ var svgEditorExtension_arrows = (function () {
events: {
change: setArrow
}
}];
return _context2.abrupt("return", {
}
];
return {
name: strings.name,
context_tools: strings.contextTools.map(function (contextTool, i) {
context_tools: strings.contextTools.map((contextTool, i) => {
return Object.assign(contextTools[i], contextTool);
}),
callback: function callback() {
$('#arrow_panel').hide(); // Set ID so it can be translated in locale file
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) {
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
var lang, importLocale, _yield$importLocale, langList;
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();
case 3:
_yield$importLocale = _context.sent;
langList = _yield$importLocale.langList;
return _context.abrupt("return", {
async addLangData ({lang, importLocale}) {
const {langList} = await importLocale();
return {
data: langList
});
case 6:
case "end":
return _context.stop();
}
}
}, _callee);
}))();
};
},
selectedChanged: function selectedChanged(opts) {
selectedChanged (opts) {
// Use this to update the current selected elements
selElems = opts.elems;
var markerElems = ['line', 'path', 'polyline', 'polygon'];
var i = selElems.length;
const markerElems = ['line', 'path', 'polyline', 'polygon'];
let i = selElems.length;
while (i--) {
var elem = selElems[i];
const elem = selElems[i];
if (elem && markerElems.includes(elem.tagName)) {
if (opts.selectedElement && !opts.multiselected) {
showPanel(true);
@@ -370,10 +307,13 @@ var svgEditorExtension_arrows = (function () {
}
}
},
elementChanged: function elementChanged(opts) {
var elem = opts.elems[0];
if (elem && (elem.getAttribute('marker-start') || elem.getAttribute('marker-mid') || elem.getAttribute('marker-end'))) {
elementChanged (opts) {
const 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');
@@ -381,18 +321,6 @@ var svgEditorExtension_arrows = (function () {
colorChanged(elem);
}
}
});
case 21:
case "end":
return _context2.stop();
}
}
}, _callee2);
}))();
}
};
return extArrows;
}());
}
};

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,43 +1,4 @@
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);
});
};
}
/**
/**
* @file ext-eyedropper.js
*
* @license MIT
@@ -45,33 +6,44 @@ var svgEditorExtension_eyedropper = (function () {
* @copyright 2010 Jeff Schiller
*
*/
var extEyedropper = {
export default {
name: 'eyedropper',
init: function init(S) {
var _this = this;
async init (S) {
const strings = await S.importLocale();
const svgEditor = this;
const {$, ChangeElementCommand} = S, // , svgcontent,
// svgdoc = S.svgroot.parentNode.ownerDocument,
svgCanvas = svgEditor.canvas,
addToHistory = function (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'
};
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
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 _getStyle(opts) {
/**
*
* @param {module:svgcanvas.SvgCanvas#event:ext_selectedChanged|module:svgcanvas.SvgCanvas#event:ext_elementChanged} opts
* @returns {void}
*/
function getStyle (opts) {
// if we are in eyedropper mode, we don't want to disable the eye-dropper tool
var mode = svgCanvas.getMode();
const mode = svgCanvas.getMode();
if (mode === 'eyedropper') { return; }
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)) {
const tool = $('#tool_eyedropper');
// enable-eye-dropper if one element is selected
let 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
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');
@@ -80,123 +52,64 @@ var svgEditorExtension_eyedropper = (function () {
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
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 = [{
const buttons = [
{
id: 'tool_eyedropper',
icon: svgEditor.curConfig.extIconsPath + 'eyedropper.png',
type: 'mode',
events: {
click: function click() {
click () {
svgCanvas.setMode('eyedropper');
}
}
}];
return _context.abrupt("return", {
}
];
return {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'eyedropper-icon.xml',
buttons: strings.buttons.map(function (button, i) {
buttons: strings.buttons.map((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();
mouseDown (opts) {
const mode = svgCanvas.getMode();
if (mode === 'eyedropper') {
var e = opts.event;
var target = e.target;
const e = opts.event;
const {target} = e;
if (!['svg', 'g', 'use'].includes(target.nodeName)) {
var changes = {};
const changes = {};
var change = function change(elem, attrname, newvalue) {
const change = function (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);
}
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();
}
}
}, _callee);
}))();
}
};
return extEyedropper;
}());
}
};

View File

@@ -1,43 +1,4 @@
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);
});
};
}
/**
/**
* @file ext-foreignobject.js
*
* @license Apache-2.0
@@ -45,46 +6,63 @@ var svgEditorExtension_foreignobject = (function () {
* @copyright 2010 Jacques Distler, 2010 Alexis Deveria
*
*/
var extForeignobject = {
name: 'foreignobject',
init: function init(S) {
var _this = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
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 _setAttr(attr, val) {
svgCanvas.changeSelectedAttribute(attr, val);
svgCanvas.call('changed', selElems);
export default {
name: 'foreignobject',
async init (S) {
const svgEditor = this;
const {$, text2xml, NS, importLocale} = S;
const svgCanvas = svgEditor.canvas;
const
// {svgcontent} = S,
// addElem = svgCanvas.addSVGElementFromJson,
svgdoc = S.svgroot.parentNode.ownerDocument;
const strings = await importLocale();
const properlySourceSizeTextArea = function () {
// TODO: remove magic numbers here and get values from CSS
const height = $('#svg_source_container').height() - 80;
$('#svg_source_textarea').css('height', height);
};
showForeignEditor = function _showForeignEditor() {
var elt = selElems[0];
if (!elt || editingforeign) {
return;
/**
* @param {boolean} on
* @returns {void}
*/
function showPanel (on) {
let 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);
}
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();
};
/**
* @param {boolean} on
* @returns {void}
*/
function toggleSourceButtons (on) {
$('#tool_source_save, #tool_source_cancel').toggle(!on);
$('#foreign_save, #foreign_cancel').toggle(on);
}
setForeignString = function _setForeignString(xmlString) {
var elt = selElems[0]; // The parent `Element` to append to
let selElems,
started,
newFO,
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.
*/
function setForeignString (xmlString) {
const 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
const newDoc = text2xml('<svg xmlns="' + NS.SVG + '" xmlns:xlink="' + NS.XLINK + '">' + xmlString + '</svg>');
// run it through our sanitizer to remove anything we do not support
svgCanvas.sanitizeSvg(newDoc.documentElement);
elt.replaceWith(svgdoc.importNode(newDoc.documentElement.firstChild, true));
svgCanvas.call('changed', [elt]);
@@ -92,63 +70,46 @@ var svgEditorExtension_foreignobject = (function () {
} catch (e) {
// Todo: Surface error to user
console.log(e); // eslint-disable-line no-console
return false;
}
return true;
};
toggleSourceButtons = function _toggleSourceButtons(on) {
$('#tool_source_save, #tool_source_cancel').toggle(!on);
$('#foreign_save, #foreign_cancel').toggle(on);
};
showPanel = function _showPanel(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 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}
*/
function showForeignEditor () {
const elt = selElems[0];
if (!elt || editingforeign) { return; }
editingforeign = true;
toggleSourceButtons(true);
elt.removeAttribute('fill');
const str = svgCanvas.svgToString(elt, 0);
$('#svg_source_textarea').val(str);
$('#svg_source_editor').fadeIn();
properlySourceSizeTextArea();
$('#svg_source_textarea').focus();
}
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.
* @param {string} attr
* @param {string|Float} val
* @returns {void}
*/
function setAttr (attr, val) {
svgCanvas.changeSelectedAttribute(attr, val);
svgCanvas.call('changed', selElems);
}
buttons = [{
const buttons = [{
id: 'tool_foreign',
icon: svgEditor.curConfig.extIconsPath + 'foreignobject-tool.png',
type: 'mode',
events: {
click: function click() {
click () {
svgCanvas.setMode('foreign');
}
}
@@ -158,18 +119,20 @@ var svgEditorExtension_foreignobject = (function () {
type: 'context',
panel: 'foreignObject_panel',
events: {
click: function click() {
click () {
showForeignEditor();
}
}
}];
contextTools = [{
const contextTools = [
{
type: 'input',
panel: 'foreignObject_panel',
id: 'foreign_width',
size: 3,
events: {
change: function change() {
change () {
setAttr('width', this.value);
}
}
@@ -178,7 +141,7 @@ var svgEditorExtension_foreignobject = (function () {
panel: 'foreignObject_panel',
id: 'foreign_height',
events: {
change: function change() {
change () {
setAttr('height', this.value);
}
}
@@ -189,95 +152,62 @@ var svgEditorExtension_foreignobject = (function () {
size: 2,
defval: 16,
events: {
change: function change() {
change () {
setAttr('font-size', this.value);
}
}
}];
return _context2.abrupt("return", {
}
];
return {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'foreignobject-icons.xml',
buttons: strings.buttons.map(function (button, i) {
buttons: strings.buttons.map((button, i) => {
return Object.assign(buttons[i], button);
}),
context_tools: strings.contextTools.map(function (contextTool, i) {
context_tools: strings.contextTools.map((contextTool, i) => {
return Object.assign(contextTools[i], contextTool);
}),
callback: function callback() {
callback () {
$('#foreignObject_panel').hide();
var endChanges = function endChanges() {
const endChanges = function () {
$('#svg_source_editor').hide();
editingforeign = false;
$('#svg_source_textarea').blur();
toggleSourceButtons(false);
}; // TODO: Needs to be done after orig icon loads
};
// TODO: Needs to be done after orig icon loads
setTimeout(function () {
// Create source save/cancel buttons
/* const save = */ $('#tool_source_save').clone()
.hide().attr('id', 'foreign_save').unbind()
.appendTo('#tool_source_back').click(async function () {
if (!editingforeign) { return; }
/* 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:
if (!setForeignString($('#svg_source_textarea').val())) {
const ok = await $.confirm('Errors found. Revert to original?');
if (!ok) { return; }
endChanges();
_context.next = 12;
break;
case 11:
} else {
endChanges();
case 12:
case "end":
return _context.stop();
}
}
}, _callee);
})));
/* const cancel = */
// setSelectMode();
});
$('#tool_source_cancel').clone().hide().attr('id', 'foreign_cancel').unbind().appendTo('#tool_source_back').click(function () {
/* const cancel = */ $('#tool_source_cancel').clone()
.hide().attr('id', 'foreign_cancel').unbind()
.appendTo('#tool_source_back').click(function () {
endChanges();
});
}, 3000);
},
mouseDown: function mouseDown(opts) {
mouseDown (opts) {
// const e = opts.event;
if (svgCanvas.getMode() !== 'foreign') {
return undefined;
}
started = true;
newFO = svgCanvas.addSVGElementFromJson({
element: 'foreignObject',
@@ -285,51 +215,49 @@ var svgEditorExtension_foreignobject = (function () {
x: opts.start_x,
y: opts.start_y,
id: svgCanvas.getNextId(),
'font-size': 16,
// cur_text.font_size,
'font-size': 16, // cur_text.font_size,
width: '48',
height: '20',
style: 'pointer-events:inherit'
}
});
var m = svgdoc.createElementNS(NS.MATH, 'math');
const m = svgdoc.createElementNS(NS.MATH, 'math');
m.setAttributeNS(NS.XMLNS, 'xmlns', NS.MATH);
m.setAttribute('display', 'inline');
var mi = svgdoc.createElementNS(NS.MATH, 'mi');
const 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";
mi.textContent = '\u03A6';
const mo = svgdoc.createElementNS(NS.MATH, 'mo');
mo.textContent = '\u222A';
const mi2 = svgdoc.createElementNS(NS.MATH, 'mi');
mi2.textContent = '\u2133';
m.append(mi, mo, mi2);
newFO.append(m);
return {
started: true
};
},
mouseUp: function mouseUp(opts) {
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';
const attrs = $(newFO).attr(['width', 'height']);
const keep = (attrs.width !== '0' || attrs.height !== '0');
svgCanvas.addToSelection([newFO], true);
return {
keep: keep,
keep,
element: newFO
};
},
selectedChanged: function selectedChanged(opts) {
selectedChanged (opts) {
// Use this to update the current selected elements
selElems = opts.elems;
var i = selElems.length;
let i = selElems.length;
while (i--) {
var elem = selElems[i];
const elem = selElems[i];
if (elem && elem.tagName === 'foreignObject') {
if (opts.selectedElement && !opts.multiselected) {
$('#foreign_font_size').val(elem.getAttribute('font-size'));
@@ -344,20 +272,9 @@ var svgEditorExtension_foreignobject = (function () {
}
}
},
elementChanged: function elementChanged(opts) {// const elem = opts.elems[0];
}
});
case 17:
case "end":
return _context2.stop();
}
}
}, _callee2);
}))();
elementChanged (opts) {
// const elem = opts.elems[0];
}
};
return extForeignobject;
}());
}
};

View File

@@ -1,43 +1,4 @@
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);
});
};
}
/**
/**
* @file ext-grid.js
*
* @license Apache-2.0
@@ -45,86 +6,24 @@ var svgEditorExtension_grid = (function () {
* @copyright 2010 Redou Mine, 2010 Alexis Deveria
*
*/
var extGrid = {
export default {
name: 'grid',
init: function init(_ref) {
var _this = this;
async init ({$, NS, getTypeMap, importLocale}) {
const strings = await importLocale();
const svgEditor = this;
const svgCanvas = svgEditor.canvas;
const svgdoc = document.getElementById('svgcanvas').ownerDocument,
{assignAttributes} = svgCanvas,
hcanvas = document.createElement('canvas'),
canvBG = $('#canvasBackground'),
units = getTypeMap(), // Assumes prior `init()` call on `units.js` module
intervals = [0.01, 0.1, 1, 10, 100, 1000];
let showGrid = svgEditor.curConfig.showGrid || false;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
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 _gridUpdate() {
if (showGrid) {
updateGrid(svgCanvas.getZoom());
}
$('#canvasGrid').toggle(showGrid);
$('#view_grid').toggleClass('push_button_pressed tool_button');
};
updateGrid = function _updateGrid(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 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');
const canvasGrid = svgdoc.createElementNS(NS.SVG, 'svg');
assignAttributes(canvasGrid, {
id: 'canvasGrid',
width: '100%',
@@ -135,20 +34,19 @@ var svgEditorExtension_grid = (function () {
display: 'none'
});
canvBG.append(canvasGrid);
gridDefs = svgdoc.createElementNS(NS.SVG, 'defs'); // grid-pattern
gridPattern = svgdoc.createElementNS(NS.SVG, 'pattern');
const gridDefs = svgdoc.createElementNS(NS.SVG, 'defs');
// grid-pattern
const 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
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');
const gridimg = svgdoc.createElementNS(NS.SVG, 'image');
assignAttributes(gridimg, {
x: 0,
y: 0,
@@ -157,9 +55,10 @@ var svgEditorExtension_grid = (function () {
});
gridPattern.append(gridimg);
gridDefs.append(gridPattern);
$('#canvasGrid').append(gridDefs); // grid-box
$('#canvasGrid').append(gridDefs);
gridBox = svgdoc.createElementNS(NS.SVG, 'rect');
// grid-box
const gridBox = svgdoc.createElementNS(NS.SVG, 'rect');
assignAttributes(gridBox, {
width: '100%',
height: '100%',
@@ -171,52 +70,99 @@ var svgEditorExtension_grid = (function () {
style: 'pointer-events: none; display:visible;'
});
$('#canvasGrid').append(gridBox);
/**
*
* @param {Float} zoom
* @returns {void}
*/
function updateGrid (zoom) {
// TODO: Try this with <line> elements, then compare performance difference
const unit = units[svgEditor.curConfig.baseUnit]; // 1 = 1px
const uMulti = unit * zoom;
// Calculate the main number interval
const rawM = 100 / uMulti;
let multi = 1;
intervals.some((num) => {
multi = num;
return rawM <= num;
});
const bigInt = multi * uMulti;
buttons = [{
// Set the canvas size to the width of the container
hcanvas.width = bigInt;
hcanvas.height = bigInt;
const ctx = hcanvas.getContext('2d');
const curD = 0.5;
const part = bigInt / 10;
ctx.globalAlpha = 0.2;
ctx.strokeStyle = svgEditor.curConfig.gridColor;
for (let i = 1; i < 10; i++) {
const subD = Math.round(part * i) + 0.5;
// const lineNum = (i % 2)?12:10;
const 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();
const 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);
}
/**
*
* @returns {void}
*/
function gridUpdate () {
if (showGrid) {
updateGrid(svgCanvas.getZoom());
}
$('#canvasGrid').toggle(showGrid);
$('#view_grid').toggleClass('push_button_pressed tool_button');
}
const buttons = [{
id: 'view_grid',
icon: svgEditor.curConfig.extIconsPath + 'grid.png',
type: 'context',
panel: 'editor_panel',
events: {
click: function click() {
click () {
svgEditor.curConfig.showGrid = showGrid = !showGrid;
gridUpdate();
}
}
}];
return _context.abrupt("return", {
return {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'grid-icon.xml',
zoomChanged: function zoomChanged(zoom) {
if (showGrid) {
updateGrid(zoom);
}
zoomChanged (zoom) {
if (showGrid) { updateGrid(zoom); }
},
callback: function callback() {
callback () {
if (showGrid) {
gridUpdate();
}
},
buttons: strings.buttons.map(function (button, i) {
buttons: strings.buttons.map((button, i) => {
return Object.assign(buttons[i], button);
})
});
case 27:
case "end":
return _context.stop();
}
}
}, _callee);
}))();
}
};
return extGrid;
}());
}
};

View File

@@ -1,99 +1,4 @@
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) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArrayLimit(arr, i) {
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
/**
/**
* @file ext-helloworld.js
*
* @license MIT
@@ -102,49 +7,42 @@ var svgEditorExtension_helloworld = (function () {
*
*/
/**
* This is a very basic SVG-Edit extension. It adds a "Hello World" button in
* the left ("mode") panel. Clicking on the button, and then the canvas
* will show the user the point on the canvas that was clicked on.
*/
var extHelloworld = {
/**
* This is a very basic SVG-Edit extension. It adds a "Hello World" button in
* the left ("mode") panel. Clicking on the button, and then the canvas
* will show the user the point on the canvas that was clicked on.
*/
export default {
name: 'helloworld',
init: function init(_ref) {
var _this = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
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();
case 3:
strings = _context.sent;
svgEditor = _this;
svgCanvas = svgEditor.canvas;
return _context.abrupt("return", {
async init ({$, importLocale}) {
// See `/editor/extensions/ext-locale/helloworld/`
const strings = await importLocale();
const svgEditor = this;
const svgCanvas = svgEditor.canvas;
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() {
click () {
// The action taken when the button is clicked on.
// For "mode" buttons, any other button will
// automatically be de-pressed.
@@ -154,52 +52,40 @@ var svgEditorExtension_helloworld = (function () {
}],
// This is triggered when the main mouse button is pressed down
// on the editor canvas (not the tool panels)
mouseDown: function mouseDown() {
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 {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) {
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
const zoom = svgCanvas.getZoom();
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];
// Get the actual coordinate by dividing by the zoom value
const x = opts.mouse_x / zoom;
const y = opts.mouse_y / zoom;
// We do our own formatting
let {text} = strings;
[
['x', x],
['y', y]
].forEach(([prop, val]) => {
text = text.replace('{' + prop + '}', val);
}); // Show the text using the custom alert function
});
// Show the text using the custom alert function
$.alert(text);
}
}
});
case 7:
case "end":
return _context.stop();
}
}
}, _callee);
}))();
}
};
return extHelloworld;
}());
}
};

View File

@@ -1,59 +1,4 @@
var svgEditorExtension_imagelib = (function () {
'use strict';
function _typeof(obj) {
"@babel/helpers - typeof";
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
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);
});
};
}
/**
/**
* @file ext-imagelib.js
*
* @license MIT
@@ -61,360 +6,294 @@ var svgEditorExtension_imagelib = (function () {
* @copyright 2010 Alexis Deveria
*
*/
var extImagelib = {
export default {
name: 'imagelib',
init: function init(_ref) {
var _this = this;
async init ({$, decode64, importLocale, dropXMLInternalSubset}) {
const imagelibStrings = await importLocale();
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
var $, decode64, importLocale, dropXMLInternalSubset, imagelibStrings, modularVersion, svgEditor, uiStrings, svgCanvas, extIconsPath, allowedImageLibOrigins, closeBrowser, importImage, pending, mode, multiArr, transferStopped, preview, submit, onMessage, _onMessage, toggleMulti, showBrowser, buttons;
const modularVersion = !('svgEditor' in window) ||
!window.svgEditor ||
window.svgEditor.modules !== false;
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
showBrowser = function _showBrowser() {
var browser = $('#imgbrowse');
const svgEditor = this;
if (!browser.length) {
$('<div id=imgbrowse_holder><div id=imgbrowse class=toolbar_button>' + '</div></div>').insertAfter('#svg_docprops');
browser = $('#imgbrowse');
var allLibs = imagelibStrings.select_lib;
var libOpts = $('<ul id=imglib_opts>').appendTo(browser);
var frame = $('<iframe src="javascript:0"/>').prependTo(browser).hide().wrap('<div id=lib_framewrap>');
var header = $('<h1>').prependTo(browser).text(allLibs).css({
position: 'absolute',
top: 0,
left: 0,
width: '100%'
const {uiStrings, canvas: svgCanvas, curConfig: {extIconsPath}} = svgEditor;
imagelibStrings.imgLibs = imagelibStrings.imgLibs.map(({name, url, description}) => {
// Todo: Adopt some standard formatting library like `fluent.js` instead
url = url
// Keep these regexes as is in prep. for switching to `u` flag
// which will require escaping
// eslint-disable-next-line unicorn/better-regex
.replace(/\{path\}/g, extIconsPath)
.replace(
// eslint-disable-next-line unicorn/better-regex
/\{modularVersion\}/g,
modularVersion
? (imagelibStrings.moduleEnding || '-es')
: ''
);
return {name, url, description};
});
var cancel = $('<button>' + uiStrings.common.cancel + '</button>').appendTo(browser).on('click touchend', function () {
const allowedImageLibOrigins = imagelibStrings.imgLibs.map(({url}) => {
try {
return new URL(url).origin;
} catch (err) {
return location.origin;
}
});
/**
*
* @returns {void}
*/
function closeBrowser () {
$('#imgbrowse_holder').hide();
}).css({
position: 'absolute',
top: 5,
right: -10
});
var leftBlock = $('<span>').css({
position: 'absolute',
top: 5,
left: 10
}).appendTo(browser);
var back = $('<button hidden>' + imagelibStrings.show_list + '</button>').appendTo(leftBlock).on('click touchend', function () {
frame.attr('src', 'about:blank').hide();
libOpts.show();
header.text(allLibs);
back.hide();
}).css({
'margin-right': 5
}).hide();
/* const type = */
$('<select><option value=s>' + imagelibStrings.import_single + '</option><option value=m>' + imagelibStrings.import_multi + '</option><option value=o>' + imagelibStrings.open + '</option></select>').appendTo(leftBlock).change(function () {
mode = $(this).val();
switch (mode) {
case 's':
case 'o':
toggleMulti(false);
break;
case 'm':
// Import multiple
toggleMulti(true);
break;
}
}).css({
'margin-top': 10
});
cancel.prepend($.getSvgIcon('cancel', true));
back.prepend($.getSvgIcon('tool_imagelib', true));
imagelibStrings.imgLibs.forEach(function (_ref5) {
var name = _ref5.name,
url = _ref5.url,
description = _ref5.description;
$('<li>').appendTo(libOpts).text(name).on('click touchend', function () {
frame.attr('src', url).show();
header.text(name);
libOpts.hide();
back.show();
}).append("<span>".concat(description, "</span>"));
});
} else {
$('#imgbrowse_holder').show();
}
};
toggleMulti = function _toggleMulti(show) {
$('#lib_framewrap, #imglib_opts').css({
right: show ? 200 : 10
});
if (!preview) {
preview = $('<div id=imglib_preview>').css({
position: 'absolute',
top: 45,
right: 10,
width: 180,
bottom: 45,
background: '#fff',
overflow: 'auto'
}).insertAfter('#lib_framewrap');
submit = $('<button disabled>Import selected</button>').appendTo('#imgbrowse').on('click touchend', function () {
$.each(multiArr, function (i) {
var type = this[0];
var data = this[1];
if (type === 'svg') {
svgCanvas.importSvgString(data);
} else {
importImage(data);
document.activeElement.blur(); // make sure focus is the body to correct issue #417
}
svgCanvas.moveSelectedElements(i * 20, i * 20, false);
});
preview.empty();
multiArr = [];
$('#imgbrowse_holder').hide();
}).css({
position: 'absolute',
bottom: 10,
right: -10
/**
* @param {string} url
* @returns {void}
*/
function importImage (url) {
const newImage = svgCanvas.addSVGElementFromJson({
element: 'image',
attr: {
x: 0,
y: 0,
width: 0,
height: 0,
id: svgCanvas.getNextId(),
style: 'pointer-events:inherit'
}
});
svgCanvas.clearSelection();
svgCanvas.addToSelection([newImage]);
svgCanvas.setImageURL(url);
}
preview.toggle(show);
submit.toggle(show);
};
const pending = {};
_onMessage = function _onMessage3() {
_onMessage = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(_ref4) {
var origin, response, id, type, hasName, hasHref, char1, secondpos, entry, curMeta, svgStr, imgStr, name, message, pre, src, title, xml, ok;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
origin = _ref4.origin, response = _ref4.data;
let mode = 's';
let multiArr = [];
let transferStopped = false;
let preview, submit;
if (!(!response || !['string', 'object'].includes(_typeof(response)))) {
_context.next = 3;
break;
/**
* Contains the SVG to insert.
* @typedef {PlainObject} ImageLibMessage
* @property {"imagelib"} namespace Required to distinguish from any other messages of app.
* @property {string} href Set to same value as previous `ImageLibMetaMessage` `id`.
* @property {string} data The response (as an SVG string or URL)
*/
/**
* Used for setting meta-data before images are retrieved.
* @typedef {PlainObject} ImageLibMetaMessage
* @property {"imagelib"} namespace Required to distinguish from any other messages of app.
* @property {string} name If the subsequent response is an SVG string or if `preview_url`
* is present, will be used as the title for the preview image. When an
* SVG string is present, will default to the first `<title>`'s contents or
* "(SVG #<Length of response>)" if none is present. Otherwise, if `preview_url`
* is present, will default to the empty string. Though `name` may be falsy,
* it is always expected to be present for meta messages.
* @property {string} id Identifier (the expected `href` for a subsequent response message);
* used for ensuring the subsequent response can be tied to this `ImageLibMetaMessage` object.
* @property {string} [preview_url] When import mode is multiple, used to set an image
* source along with the name/title. If the subsequent response is an SVG string
* and there is no `preview_url`, the default will just be to show the
* name/title. If the response is not an SVG string, the default will be to
* show that response (i.e., the URL).
* @property {string} entry Set automatically with div holding retrieving
* message (until ready to delete)
* @todo Should use a separate Map instead of `entry`
*/
/**
* @param {PlainObject} cfg
* @param {string} cfg.origin
* @param {ImageLibMetaMessage|ImageLibMessage|string} cfg.data String is deprecated when parsed to JSON `ImageLibMessage`
* @returns {void}
*/
async function onMessage ({origin, data: response}) { // eslint-disable-line no-shadow
if (!response || !['string', 'object'].includes(typeof response)) {
// Do nothing
return;
}
return _context.abrupt("return");
case 3:
_context.prev = 3;
let id;
let type;
try {
// Todo: This block can be removed (and the above check changed to
// insist on an object) if embedAPI moves away from a string to
// an object (if IE9 support not needed)
response = _typeof(response) === 'object' ? response : JSON.parse(response);
if (!(response.namespace !== 'imagelib')) {
_context.next = 7;
break;
response = typeof response === 'object' ? response : JSON.parse(response);
if (response.namespace !== 'imagelib') {
return;
}
return _context.abrupt("return");
case 7:
if (!(!allowedImageLibOrigins.includes('*') && !allowedImageLibOrigins.includes(origin))) {
_context.next = 10;
break;
}
if (!allowedImageLibOrigins.includes('*') && !allowedImageLibOrigins.includes(origin)) {
// Todo: Surface this error to user?
console.log("Origin ".concat(origin, " not whitelisted for posting to ").concat(window.origin)); // eslint-disable-line no-console
console.log(`Origin ${origin} not whitelisted for posting to ${window.origin}`); // eslint-disable-line no-console
return;
}
const hasName = 'name' in response;
const hasHref = 'href' in response;
return _context.abrupt("return");
case 10:
hasName = 'name' in response;
hasHref = 'href' in response;
if (!(!hasName && transferStopped)) {
_context.next = 15;
break;
if (!hasName && transferStopped) {
transferStopped = false;
return;
}
transferStopped = false;
return _context.abrupt("return");
case 15:
if (hasHref) {
id = response.href;
response = response.data;
} // Hide possible transfer dialog box
}
// Hide possible transfer dialog box
$('#dialog_box').hide();
type = hasName ? 'meta' : response.charAt(0);
_context.next = 28;
break;
case 20:
_context.prev = 20;
_context.t0 = _context["catch"](3);
if (!(typeof response === 'string')) {
_context.next = 28;
break;
}
char1 = response.charAt(0);
if (!(char1 !== '{' && transferStopped)) {
_context.next = 27;
break;
}
type = hasName
? 'meta'
: response.charAt(0);
} catch (e) {
// This block is for backward compatibility (for IAN and Openclipart);
// should otherwise return
if (typeof response === 'string') {
const char1 = response.charAt(0);
if (char1 !== '{' && transferStopped) {
transferStopped = false;
return _context.abrupt("return");
return;
}
case 27:
if (char1 === '|') {
secondpos = response.indexOf('|', 1);
const secondpos = response.indexOf('|', 1);
id = response.substr(1, secondpos - 1);
response = response.substr(secondpos + 1);
type = response.charAt(0);
}
case 28:
_context.t1 = type;
_context.next = _context.t1 === 'meta' ? 31 : _context.t1 === '<' ? 47 : _context.t1 === 'd' ? 49 : 60;
break;
case 31:
// Metadata
transferStopped = false;
curMeta = response; // Should be safe to add dynamic property as passed metadata
pending[curMeta.id] = curMeta; // lgtm [js/remote-property-injection]
name = curMeta.name || 'file';
message = uiStrings.notification.retrieving.replace('%s', name);
if (!(mode !== 'm')) {
_context.next = 43;
break;
}
}
_context.next = 39;
return $.process_cancel(message);
let entry, curMeta, svgStr, imgStr;
switch (type) {
case 'meta': {
// Metadata
transferStopped = false;
curMeta = response;
case 39:
transferStopped = true; // Should a message be sent back to the frame?
// Should be safe to add dynamic property as passed metadata
pending[curMeta.id] = curMeta; // lgtm [js/remote-property-injection]
const name = (curMeta.name || 'file');
const message = uiStrings.notification.retrieving.replace('%s', name);
if (mode !== 'm') {
await $.process_cancel(message);
transferStopped = true;
// Should a message be sent back to the frame?
$('#dialog_box').hide();
_context.next = 46;
break;
case 43:
} else {
entry = $('<div>').text(message).data('id', curMeta.id);
preview.append(entry);
curMeta.entry = entry;
case 46:
return _context.abrupt("return");
case 47:
svgStr = true;
return _context.abrupt("break", 62);
case 49:
if (!response.startsWith('data:image/svg+xml')) {
_context.next = 57;
break;
}
pre = 'data:image/svg+xml;base64,';
src = response.substring(pre.length);
return;
}
case '<':
svgStr = true;
break;
case 'd': {
if (response.startsWith('data:image/svg+xml')) {
const pre = 'data:image/svg+xml;base64,';
const src = response.substring(pre.length);
response = decode64(src);
svgStr = true;
return _context.abrupt("break", 62);
case 57:
if (!response.startsWith('data:image/')) {
_context.next = 60;
break;
} else if (response.startsWith('data:image/')) {
imgStr = true;
break;
}
imgStr = true;
return _context.abrupt("break", 62);
case 60:
}
// Else fall through
default:
// TODO: See if there's a way to base64 encode the binary data stream
// const str = 'data:;base64,' + svgedit.utilities.encode64(response, true);
// Assume it's raw image data
// importImage(str);
// Don't give warning as postMessage may have been used by something else
if (mode !== 'm') {
closeBrowser();
} else {
pending[id].entry.remove();
} // await $.alert('Unexpected data was returned: ' + response, function() {
}
// await $.alert('Unexpected data was returned: ' + response, function() {
// if (mode !== 'm') {
// closeBrowser();
// } else {
// pending[id].entry.remove();
// }
// });
return;
}
return _context.abrupt("return");
case 62:
_context.t2 = mode;
_context.next = _context.t2 === 's' ? 65 : _context.t2 === 'm' ? 68 : _context.t2 === 'o' ? 72 : 83;
break;
case 65:
switch (mode) {
case 's':
// Import one
if (svgStr) {
svgCanvas.importSvgString(response);
} else if (imgStr) {
importImage(response);
}
closeBrowser();
return _context.abrupt("break", 83);
case 68:
break;
case 'm': {
// Import multiple
multiArr.push([svgStr ? 'svg' : 'img', response]);
multiArr.push([(svgStr ? 'svg' : 'img'), response]);
curMeta = pending[id];
let title;
if (svgStr) {
if (curMeta && curMeta.name) {
title = curMeta.name;
} else {
// Try to find a title
// `dropXMLInternalSubset` is to help prevent the billion laughs attack
xml = new DOMParser().parseFromString(dropXMLInternalSubset(response), 'text/xml').documentElement; // lgtm [js/xml-bomb]
const xml = new DOMParser().parseFromString(dropXMLInternalSubset(response), 'text/xml').documentElement; // lgtm [js/xml-bomb]
title = $(xml).children('title').first().text() || '(SVG #' + response.length + ')';
}
if (curMeta) {
preview.children().each(function () {
if ($(this).data('id') === id) {
if (curMeta.preview_url) {
$(this).html($('<span>').append($('<img>').attr('src', curMeta.preview_url), title));
$(this).html(
$('<span>').append(
$('<img>').attr('src', curMeta.preview_url),
title
)
);
} else {
$(this).text(title);
}
submit.removeAttr('disabled');
}
});
} else {
preview.append($('<div>').text(title));
preview.append(
$('<div>').text(title)
);
submit.removeAttr('disabled');
}
} else {
if (curMeta && curMeta.preview_url) {
title = curMeta.name || '';
entry = $('<span>').append($('<img>').attr('src', curMeta.preview_url), title);
entry = $('<span>').append(
$('<img>').attr('src', curMeta.preview_url),
title
);
} else {
entry = $('<img>').attr('src', response);
}
@@ -431,154 +310,248 @@ var svgEditorExtension_imagelib = (function () {
submit.removeAttr('disabled');
}
}
return _context.abrupt("break", 83);
case 72:
if (svgStr) {
_context.next = 74;
break;
}
return _context.abrupt("break", 83);
case 74:
} case 'o': {
// Open
if (!svgStr) { break; }
closeBrowser();
_context.next = 77;
return svgEditor.openPrep();
case 77:
ok = _context.sent;
if (ok) {
_context.next = 80;
const ok = await svgEditor.openPrep();
if (!ok) { return; }
svgCanvas.clear();
svgCanvas.setSvgString(response);
// updateCanvas();
break;
}
return _context.abrupt("return");
case 80:
svgCanvas.clear();
svgCanvas.setSvgString(response); // updateCanvas();
return _context.abrupt("break", 83);
case 83:
case "end":
return _context.stop();
}
}
}, _callee, null, [[3, 20]]);
}));
return _onMessage.apply(this, arguments);
};
onMessage = function _onMessage2(_x) {
return _onMessage.apply(this, arguments);
};
importImage = function _importImage(url) {
var newImage = svgCanvas.addSVGElementFromJson({
element: 'image',
attr: {
x: 0,
y: 0,
width: 0,
height: 0,
id: svgCanvas.getNextId(),
style: 'pointer-events:inherit'
}
});
svgCanvas.clearSelection();
svgCanvas.addToSelection([newImage]);
svgCanvas.setImageURL(url);
};
closeBrowser = function _closeBrowser() {
$('#imgbrowse_holder').hide();
document.activeElement.blur(); // make sure focus is the body to correct issue #417
};
$ = _ref.$, decode64 = _ref.decode64, importLocale = _ref.importLocale, dropXMLInternalSubset = _ref.dropXMLInternalSubset;
_context2.next = 9;
return importLocale();
case 9:
imagelibStrings = _context2.sent;
modularVersion = !('svgEditor' in window) || !window.svgEditor || window.svgEditor.modules !== false;
svgEditor = _this;
uiStrings = svgEditor.uiStrings, svgCanvas = svgEditor.canvas, extIconsPath = svgEditor.curConfig.extIconsPath;
imagelibStrings.imgLibs = imagelibStrings.imgLibs.map(function (_ref2) {
var name = _ref2.name,
url = _ref2.url,
description = _ref2.description;
// Todo: Adopt some standard formatting library like `fluent.js` instead
url = url // Keep these regexes as is in prep. for switching to `u` flag
// which will require escaping
// eslint-disable-next-line unicorn/better-regex
.replace(/\{path\}/g, extIconsPath).replace( // eslint-disable-next-line unicorn/better-regex
/\{modularVersion\}/g, modularVersion ? imagelibStrings.moduleEnding || '-es' : '');
return {
name: name,
url: url,
description: description
};
});
allowedImageLibOrigins = imagelibStrings.imgLibs.map(function (_ref3) {
var url = _ref3.url;
try {
return new URL(url).origin;
} catch (err) {
return location.origin;
}
});
/**
*
* @returns {void}
*/
pending = {};
mode = 's';
multiArr = [];
transferStopped = false;
// Receive `postMessage` data
window.addEventListener('message', onMessage, true);
/**
* @param {boolean} show
* @returns {void}
*/
function toggleMulti (show) {
$('#lib_framewrap, #imglib_opts').css({right: (show ? 200 : 10)});
if (!preview) {
preview = $('<div id=imglib_preview>').css({
position: 'absolute',
top: 45,
right: 10,
width: 180,
bottom: 45,
background: '#fff',
overflow: 'auto'
}).insertAfter('#lib_framewrap');
buttons = [{
submit = $('<button disabled>Import selected</button>')
.appendTo('#imgbrowse')
.on('click touchend', function () {
$.each(multiArr, function (i) {
const type = this[0];
const data = this[1];
if (type === 'svg') {
svgCanvas.importSvgString(data);
} else {
importImage(data);
}
svgCanvas.moveSelectedElements(i * 20, i * 20, false);
});
preview.empty();
multiArr = [];
$('#imgbrowse_holder').hide();
}).css({
position: 'absolute',
bottom: 10,
right: -10
});
}
preview.toggle(show);
submit.toggle(show);
}
/**
*
* @returns {void}
*/
function showBrowser () {
let browser = $('#imgbrowse');
if (!browser.length) {
$('<div id=imgbrowse_holder><div id=imgbrowse class=toolbar_button>' +
'</div></div>').insertAfter('#svg_docprops');
browser = $('#imgbrowse');
const allLibs = imagelibStrings.select_lib;
const libOpts = $('<ul id=imglib_opts>').appendTo(browser);
const frame = $('<iframe src="javascript:0"/>').prependTo(browser).hide().wrap('<div id=lib_framewrap>');
const header = $('<h1>').prependTo(browser).text(allLibs).css({
position: 'absolute',
top: 0,
left: 0,
width: '100%'
});
const cancel = $('<button>' + uiStrings.common.cancel + '</button>')
.appendTo(browser)
.on('click touchend', function () {
$('#imgbrowse_holder').hide();
}).css({
position: 'absolute',
top: 5,
right: -10
});
const leftBlock = $('<span>').css({position: 'absolute', top: 5, left: 10}).appendTo(browser);
const back = $('<button hidden>' + imagelibStrings.show_list + '</button>')
.appendTo(leftBlock)
.on('click touchend', function () {
frame.attr('src', 'about:blank').hide();
libOpts.show();
header.text(allLibs);
back.hide();
}).css({
'margin-right': 5
}).hide();
/* const type = */ $('<select><option value=s>' +
imagelibStrings.import_single + '</option><option value=m>' +
imagelibStrings.import_multi + '</option><option value=o>' +
imagelibStrings.open + '</option></select>').appendTo(leftBlock).change(function () {
mode = $(this).val();
switch (mode) {
case 's':
case 'o':
toggleMulti(false);
break;
case 'm':
// Import multiple
toggleMulti(true);
break;
}
}).css({
'margin-top': 10
});
cancel.prepend($.getSvgIcon('cancel', true));
back.prepend($.getSvgIcon('tool_imagelib', true));
imagelibStrings.imgLibs.forEach(function ({name, url, description}) {
$('<li>')
.appendTo(libOpts)
.text(name)
.on('click touchend', function () {
frame.attr(
'src',
url
).show();
header.text(name);
libOpts.hide();
back.show();
}).append(`<span>${description}</span>`);
});
} else {
$('#imgbrowse_holder').show();
}
}
const buttons = [{
id: 'tool_imagelib',
type: 'app_menu',
// _flyout
type: 'app_menu', // _flyout
icon: extIconsPath + 'imagelib.png',
position: 4,
events: {
mouseup: showBrowser
}
}];
return _context2.abrupt("return", {
return {
svgicons: extIconsPath + 'ext-imagelib.xml',
buttons: imagelibStrings.buttons.map(function (button, i) {
buttons: imagelibStrings.buttons.map((button, i) => {
return Object.assign(buttons[i], button);
}),
callback: function callback() {
$('<style>').text('#imgbrowse_holder {' + 'position: absolute;' + 'top: 0;' + 'left: 0;' + 'width: 100%;' + 'height: 100%;' + 'background-color: rgba(0, 0, 0, .5);' + 'z-index: 5;' + '}' + '#imgbrowse {' + 'position: absolute;' + 'top: 25px;' + 'left: 25px;' + 'right: 25px;' + 'bottom: 25px;' + 'min-width: 300px;' + 'min-height: 200px;' + 'background: #B0B0B0;' + 'border: 1px outset #777;' + '}' + '#imgbrowse h1 {' + 'font-size: 20px;' + 'margin: .4em;' + 'text-align: center;' + '}' + '#lib_framewrap,' + '#imgbrowse > ul {' + 'position: absolute;' + 'top: 45px;' + 'left: 10px;' + 'right: 10px;' + 'bottom: 10px;' + 'background: white;' + 'margin: 0;' + 'padding: 0;' + '}' + '#imgbrowse > ul {' + 'overflow: auto;' + '}' + '#imgbrowse > div {' + 'border: 1px solid #666;' + '}' + '#imglib_preview > div {' + 'padding: 5px;' + 'font-size: 12px;' + '}' + '#imglib_preview img {' + 'display: block;' + 'margin: 0 auto;' + 'max-height: 100px;' + '}' + '#imgbrowse li {' + 'list-style: none;' + 'padding: .5em;' + 'background: #E8E8E8;' + 'border-bottom: 1px solid #B0B0B0;' + 'line-height: 1.2em;' + 'font-style: sans-serif;' + '}' + '#imgbrowse li > span {' + 'color: #666;' + 'font-size: 15px;' + 'display: block;' + '}' + '#imgbrowse li:hover {' + 'background: #FFC;' + 'cursor: pointer;' + '}' + '#imgbrowse iframe {' + 'width: 100%;' + 'height: 100%;' + 'border: 0;' + '}').appendTo('head');
}
});
case 22:
case "end":
return _context2.stop();
}
}
}, _callee2);
}))();
callback () {
$('<style>').text(
'#imgbrowse_holder {' +
'position: absolute;' +
'top: 0;' +
'left: 0;' +
'width: 100%;' +
'height: 100%;' +
'background-color: rgba(0, 0, 0, .5);' +
'z-index: 5;' +
'}' +
'#imgbrowse {' +
'position: absolute;' +
'top: 25px;' +
'left: 25px;' +
'right: 25px;' +
'bottom: 25px;' +
'min-width: 300px;' +
'min-height: 200px;' +
'background: #B0B0B0;' +
'border: 1px outset #777;' +
'}' +
'#imgbrowse h1 {' +
'font-size: 20px;' +
'margin: .4em;' +
'text-align: center;' +
'}' +
'#lib_framewrap,' +
'#imgbrowse > ul {' +
'position: absolute;' +
'top: 45px;' +
'left: 10px;' +
'right: 10px;' +
'bottom: 10px;' +
'background: white;' +
'margin: 0;' +
'padding: 0;' +
'}' +
'#imgbrowse > ul {' +
'overflow: auto;' +
'}' +
'#imgbrowse > div {' +
'border: 1px solid #666;' +
'}' +
'#imglib_preview > div {' +
'padding: 5px;' +
'font-size: 12px;' +
'}' +
'#imglib_preview img {' +
'display: block;' +
'margin: 0 auto;' +
'max-height: 100px;' +
'}' +
'#imgbrowse li {' +
'list-style: none;' +
'padding: .5em;' +
'background: #E8E8E8;' +
'border-bottom: 1px solid #B0B0B0;' +
'line-height: 1.2em;' +
'font-style: sans-serif;' +
'}' +
'#imgbrowse li > span {' +
'color: #666;' +
'font-size: 15px;' +
'display: block;' +
'}' +
'#imgbrowse li:hover {' +
'background: #FFC;' +
'cursor: pointer;' +
'}' +
'#imgbrowse iframe {' +
'width: 100%;' +
'height: 100%;' +
'border: 0;' +
'}'
).appendTo('head');
}
};
return extImagelib;
}());
}
};

14
dist/extensions/ext-imagelib.xml vendored Normal file
View File

@@ -0,0 +1,14 @@
<svg xmlns="http://www.w3.org/2000/svg">
<g id="tool_imagelib">
<svg width="201" height="211" xmlns="http://www.w3.org/2000/svg">
<g>
<path fill="#efe8b8" stroke="#d6c47c" stroke-linecap="round" d="m2.75,49.51761l56.56,-46.26761c12.73,8.25 25.71001,7 46.44,0.75l-56.03999,47.23944l-22.72002,25.01056l-24.23999,-26.73239z" id="svg_2" stroke-width="7"/>
<path fill="#a03333" stroke="#3f3f3f" d="m3.75,203.25002c14.33301,7 30.66699,7 46,0l0,-152.00002c-14.66699,8 -32.33301,8 -47,0l1,152.00002zm45.75,-152.25002l56.25,-46.75l0,151l-56,48.00002m-47.25,-154.25002l57.25,-46.5" id="svg_1" stroke-width="7" stroke-linecap="round"/>
<path fill="#efe8b8" stroke="#d6c47c" stroke-linecap="round" d="m49.75,49.51801l56.56,-46.26801c12.72998,8.25 25.71002,7 46.44,0.75l-56.03998,47.239l-22.72003,25.011l-24.23999,-26.73199z" stroke-width="7" id="svg_5"/>
<path fill="#2f8e2f" stroke="#3f3f3f" d="m50.75,202.25c14.33301,7 30.66699,7.04253 46,0.04253l0,-151.04253c-14.66699,8 -32.33301,8 -47,0l1,151zm45.75,-151.25l56.25,-46.75l0,144.01219l-56,51.98782m-47.25,-151.25002l57.25,-46.5" stroke-width="7" stroke-linecap="round" id="svg_6"/>
<path fill="#efe8b8" stroke="#d6c47c" stroke-linecap="round" d="m95.75,49.51801l56.56,-46.26801c12.72998,8.25 25.71002,7 46.44,0.75l-56.03998,47.239l-22.72003,25.011l-24.23999,-26.73199z" stroke-width="7" id="svg_10"/>
<path fill="#336393" stroke="#3f3f3f" d="m96.75,200.29445c14.33301,7 30.66699,7 46,0l0,-149.04445c-14.66699,8 -32.33301,8 -47,0l1,149.04445zm45.75,-149.29445l56.25,-46.75l0,148.04445l-56,48m-47.25,-151.29445l57.25,-46.5" stroke-width="7" stroke-linecap="round" id="svg_11"/>
</g>
</svg>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@@ -1,13 +1,10 @@
var svgEditorExtensionLocale_arrows_en = (function () {
'use strict';
var en = {
export default {
name: 'Arrows',
langList: [{
id: 'arrow_none',
textContent: 'No arrow'
}],
contextTools: [{
langList: [
{id: 'arrow_none', textContent: 'No arrow'}
],
contextTools: [
{
title: 'Select arrow type',
options: {
none: 'No arrow',
@@ -17,9 +14,6 @@ var svgEditorExtensionLocale_arrows_en = (function () {
mid: '--&gt;--',
mid_bk: '--&lt;--'
}
}]
};
return en;
}());
}
]
};

View File

@@ -1,13 +1,10 @@
var svgEditorExtensionLocale_arrows_fr = (function () {
'use strict';
var fr = {
export default {
name: 'Arrows',
langList: [{
id: 'arrow_none',
textContent: 'Sans flèche'
}],
contextTools: [{
langList: [
{id: 'arrow_none', textContent: 'Sans flèche'}
],
contextTools: [
{
title: 'Select arrow type',
options: {
none: 'No arrow',
@@ -17,9 +14,6 @@ var svgEditorExtensionLocale_arrows_fr = (function () {
mid: '--&gt;--',
mid_bk: '--&lt;--'
}
}]
};
return fr;
}());
}
]
};

24
dist/extensions/ext-locale/arrows/zh-CN.js vendored Normal file → Executable file
View File

@@ -1,13 +1,10 @@
var svgEditorExtensionLocale_arrows_zh_CN = (function () {
'use strict';
var zhCN = {
export default {
name: '箭头',
langList: [{
id: 'arrow_none',
textContent: '无箭头'
}],
contextTools: [{
langList: [
{id: 'arrow_none', textContent: '无箭头'}
],
contextTools: [
{
title: '选择箭头类型',
options: {
none: '无箭头',
@@ -17,9 +14,6 @@ var svgEditorExtensionLocale_arrows_zh_CN = (function () {
mid: '--&gt;--',
mid_bk: '--&lt;--'
}
}]
};
return zhCN;
}());
}
]
};

View File

@@ -1,15 +1,11 @@
var svgEditorExtensionLocale_closepath_en = (function () {
'use strict';
var en = {
export default {
name: 'ClosePath',
buttons: [{
buttons: [
{
title: 'Open path'
}, {
},
{
title: 'Close path'
}]
};
return en;
}());
}
]
};

20
dist/extensions/ext-locale/closepath/zh-CN.js vendored Normal file → Executable file
View File

@@ -1,15 +1,11 @@
var svgEditorExtensionLocale_closepath_zh_CN = (function () {
'use strict';
var zhCN = {
export default {
name: '闭合路径',
buttons: [{
buttons: [
{
title: '打开路径'
}, {
},
{
title: '关闭路径'
}]
};
return zhCN;
}());
}
]
};

View File

@@ -1,17 +1,11 @@
var svgEditorExtensionLocale_connector_en = (function () {
'use strict';
var en = {
export default {
name: 'Connector',
langList: [{
id: 'mode_connect',
langList: [
{id: 'mode_connect', title: 'Connect two objects'}
],
buttons: [
{
title: 'Connect two objects'
}],
buttons: [{
title: 'Connect two objects'
}]
};
return en;
}());
}
]
};

View File

@@ -1,17 +1,11 @@
var svgEditorExtensionLocale_connector_fr = (function () {
'use strict';
var fr = {
export default {
name: 'Connector',
langList: [{
id: 'mode_connect',
title: 'Connecter deux objets'
}],
buttons: [{
langList: [
{id: 'mode_connect', title: 'Connecter deux objets'}
],
buttons: [
{
title: 'Connect two objects'
}]
};
return fr;
}());
}
]
};

24
dist/extensions/ext-locale/connector/zh-CN.js vendored Normal file → Executable file
View File

@@ -1,17 +1,11 @@
var svgEditorExtensionLocale_connector_zh_CN = (function () {
'use strict';
var zhCN = {
export default {
name: '连接器',
langList: [{
id: 'mode_connect',
langList: [
{id: 'mode_connect', title: '连接两个对象'}
],
buttons: [
{
title: '连接两个对象'
}],
buttons: [{
title: '连接两个对象'
}]
};
return zhCN;
}());
}
]
};

View File

@@ -1,14 +1,9 @@
var svgEditorExtensionLocale_eyedropper_en = (function () {
'use strict';
var en = {
export default {
name: 'eyedropper',
buttons: [{
buttons: [
{
title: 'Eye Dropper Tool',
key: 'I'
}]
};
return en;
}());
}
]
};

17
dist/extensions/ext-locale/eyedropper/zh-CN.js vendored Normal file → Executable file
View File

@@ -1,14 +1,9 @@
var svgEditorExtensionLocale_eyedropper_zh_CN = (function () {
'use strict';
var zhCN = {
export default {
name: '滴管',
buttons: [{
buttons: [
{
title: '滴管工具',
key: 'I'
}]
};
return zhCN;
}());
}
]
};

View File

@@ -1,25 +1,25 @@
var svgEditorExtensionLocale_foreignobject_en = (function () {
'use strict';
var en = {
export default {
name: 'foreignObject',
buttons: [{
buttons: [
{
title: 'Foreign Object Tool'
}, {
},
{
title: 'Edit ForeignObject Content'
}],
contextTools: [{
}
],
contextTools: [
{
title: "Change foreignObject's width",
label: 'w'
}, {
},
{
title: "Change foreignObject's height",
label: 'h'
}, {
},
{
title: "Change foreignObject's font size",
label: 'font-size'
}]
};
return en;
}());
}
]
};

32
dist/extensions/ext-locale/foreignobject/zh-CN.js vendored Normal file → Executable file
View File

@@ -1,25 +1,25 @@
var svgEditorExtensionLocale_foreignobject_zh_CN = (function () {
'use strict';
var zhCN = {
export default {
name: '外部对象',
buttons: [{
buttons: [
{
title: '外部对象工具'
}, {
},
{
title: '编辑外部对象内容'
}],
contextTools: [{
}
],
contextTools: [
{
title: '改变外部对象宽度',
label: 'w'
}, {
},
{
title: '改变外部对象高度',
label: 'h'
}, {
},
{
title: '改变外部对象文字大小',
label: '文字大小'
}]
};
return zhCN;
}());
}
]
};

View File

@@ -1,13 +1,8 @@
var svgEditorExtensionLocale_grid_en = (function () {
'use strict';
var en = {
export default {
name: 'View Grid',
buttons: [{
buttons: [
{
title: 'Show/Hide Grid'
}]
};
return en;
}());
}
]
};

17
dist/extensions/ext-locale/grid/zh-CN.js vendored Normal file → Executable file
View File

@@ -1,13 +1,8 @@
var svgEditorExtensionLocale_grid_zh_CN = (function () {
'use strict';
var zhCN = {
export default {
name: '网格视图',
buttons: [{
buttons: [
{
title: '显示/隐藏网格'
}]
};
return zhCN;
}());
}
]
};

View File

@@ -1,14 +1,9 @@
var svgEditorExtensionLocale_helloworld_en = (function () {
'use strict';
var en = {
export default {
name: 'Hello World',
text: 'Hello World!\n\nYou clicked here: {x}, {y}',
buttons: [{
buttons: [
{
title: "Say 'Hello World'"
}]
};
return en;
}());
}
]
};

17
dist/extensions/ext-locale/helloworld/zh-CN.js vendored Normal file → Executable file
View File

@@ -1,14 +1,9 @@
var svgEditorExtensionLocale_helloworld_zh_CN = (function () {
'use strict';
var zhCN = {
export default {
name: 'Hello World',
text: 'Hello World!\n\n 请点击: {x}, {y}',
buttons: [{
buttons: [
{
title: "输出 'Hello World'"
}]
};
return zhCN;
}());
}
]
};

View File

@@ -1,20 +1,21 @@
var svgEditorExtensionLocale_imagelib_de = (function () {
'use strict';
var de = {
export default {
select_lib: 'Select an image library',
show_list: 'Show library list',
import_single: 'Import single',
import_multi: 'Import multiple',
open: 'Open as new document',
buttons: [{
buttons: [
{
title: 'Bilder-Bibliothek'
}],
imgLibs: [{
}
],
imgLibs: [
{
name: 'Demo library (local)',
url: '{path}imagelib/index{modularVersion}.html',
description: 'Demonstration library for SVG-edit on this server'
}, {
},
{
name: 'IAN Symbol Libraries',
url: 'https://ian.umces.edu/symbols/catalog/svgedit/album_chooser.php?svgedit=3',
description: 'Free library of illustrations'
@@ -29,8 +30,4 @@ var svgEditorExtensionLocale_imagelib_de = (function () {
}
*/
]
};
return de;
}());
};

View File

@@ -1,31 +1,32 @@
var svgEditorExtensionLocale_imagelib_en = (function () {
'use strict';
var en = {
export default {
select_lib: 'Select an image library',
show_list: 'Show library list',
import_single: 'Import single',
import_multi: 'Import multiple',
open: 'Open as new document',
buttons: [{
buttons: [
{
title: 'Image library'
}],
imgLibs: [{
}
],
imgLibs: [
{
name: 'Demo library (local)',
url: '{path}imagelib/index{modularVersion}.html',
description: 'Demonstration library for SVG-edit on this server'
}, {
},
{
name: 'IAN Symbol Libraries',
url: 'https://ian.umces.edu/symbols/catalog/svgedit/album_chooser.php?svgedit=3',
description: 'Free library of illustrations'
} // The site is no longer using our API, and they have added an
}
// The site is no longer using our API, and they have added an
// `X-Frame-Options` header which prevents our usage cross-origin:
// Getting messages like this in console:
// Refused to display 'https://openclipart.org/detail/307176/sign-bike' in a frame
// because it set 'X-Frame-Options' to 'sameorigin'.
// url: 'https://openclipart.org/svgedit',
// However, they do have a custom API which we are using here:
/*
{
name: 'Openclipart',
@@ -34,8 +35,4 @@ var svgEditorExtensionLocale_imagelib_en = (function () {
}
*/
]
};
return en;
}());
};

View File

@@ -1,20 +1,21 @@
var svgEditorExtensionLocale_imagelib_fr = (function () {
'use strict';
var fr = {
export default {
select_lib: "Choisir une bibliothèque d'images",
show_list: 'show_list',
import_single: 'import_single',
import_multi: 'import_multi',
open: 'open',
buttons: [{
buttons: [
{
title: "Bibliothèque d'images"
}],
imgLibs: [{
}
],
imgLibs: [
{
name: 'Demo library (local)',
url: '{path}imagelib/index{modularVersion}.html',
description: 'Demonstration library for SVG-edit on this server'
}, {
},
{
name: 'IAN Symbol Libraries',
url: 'https://ian.umces.edu/symbols/catalog/svgedit/album_chooser.php?svgedit=3',
description: 'Free library of illustrations'
@@ -29,8 +30,4 @@ var svgEditorExtensionLocale_imagelib_fr = (function () {
}
*/
]
};
return fr;
}());
};

View File

@@ -1,20 +1,21 @@
var svgEditorExtensionLocale_imagelib_pl = (function () {
'use strict';
var pl = {
export default {
select_lib: 'Select an image library',
show_list: 'Show library list',
import_single: 'Import single',
import_multi: 'Import multiple',
open: 'Open as new document',
buttons: [{
buttons: [
{
title: 'Biblioteka obrazów'
}],
imgLibs: [{
}
],
imgLibs: [
{
name: 'Demo library (local)',
url: '{path}imagelib/index{modularVersion}.html',
description: 'Demonstration library for SVG-edit on this server'
}, {
},
{
name: 'IAN Symbol Libraries',
url: 'https://ian.umces.edu/symbols/catalog/svgedit/album_chooser.php?svgedit=3',
description: 'Free library of illustrations'
@@ -29,8 +30,4 @@ var svgEditorExtensionLocale_imagelib_pl = (function () {
}
*/
]
};
return pl;
}());
};

View File

@@ -1,20 +1,21 @@
var svgEditorExtensionLocale_imagelib_pt_BR = (function () {
'use strict';
var ptBR = {
export default {
select_lib: 'Select an image library',
show_list: 'Show library list',
import_single: 'Import single',
import_multi: 'Import multiple',
open: 'Open as new document',
buttons: [{
buttons: [
{
title: 'Biblioteca de Imagens'
}],
imgLibs: [{
}
],
imgLibs: [
{
name: 'Demo library (local)',
url: '{path}imagelib/index{modularVersion}.html',
description: 'Demonstration library for SVG-edit on this server'
}, {
},
{
name: 'IAN Symbol Libraries',
url: 'https://ian.umces.edu/symbols/catalog/svgedit/album_chooser.php?svgedit=3',
description: 'Free library of illustrations'
@@ -29,8 +30,4 @@ var svgEditorExtensionLocale_imagelib_pt_BR = (function () {
}
*/
]
};
return ptBR;
}());
};

View File

@@ -1,20 +1,21 @@
var svgEditorExtensionLocale_imagelib_ro = (function () {
'use strict';
var ro = {
export default {
select_lib: 'Select an image library',
show_list: 'Show library list',
import_single: 'Import single',
import_multi: 'Import multiple',
open: 'Open as new document',
buttons: [{
buttons: [
{
title: 'Bibliotecă de Imagini'
}],
imgLibs: [{
}
],
imgLibs: [
{
name: 'Demo library (local)',
url: '{path}imagelib/index{modularVersion}.html',
description: 'Demonstration library for SVG-edit on this server'
}, {
},
{
name: 'IAN Symbol Libraries',
url: 'https://ian.umces.edu/symbols/catalog/svgedit/album_chooser.php?svgedit=3',
description: 'Free library of illustrations'
@@ -29,8 +30,4 @@ var svgEditorExtensionLocale_imagelib_ro = (function () {
}
*/
]
};
return ro;
}());
};

View File

@@ -1,20 +1,21 @@
var svgEditorExtensionLocale_imagelib_sk = (function () {
'use strict';
var sk = {
export default {
select_lib: 'Select an image library',
show_list: 'Show library list',
import_single: 'Import single',
import_multi: 'Import multiple',
open: 'Open as new document',
buttons: [{
buttons: [
{
title: 'Knižnica obrázkov'
}],
imgLibs: [{
}
],
imgLibs: [
{
name: 'Demo library (local)',
url: '{path}imagelib/index{modularVersion}.html',
description: 'Demonstration library for SVG-edit on this server'
}, {
},
{
name: 'IAN Symbol Libraries',
url: 'https://ian.umces.edu/symbols/catalog/svgedit/album_chooser.php?svgedit=3',
description: 'Free library of illustrations'
@@ -29,8 +30,4 @@ var svgEditorExtensionLocale_imagelib_sk = (function () {
}
*/
]
};
return sk;
}());
};

View File

@@ -1,20 +1,21 @@
var svgEditorExtensionLocale_imagelib_sl = (function () {
'use strict';
var sl = {
export default {
select_lib: 'Select an image library',
show_list: 'Show library list',
import_single: 'Import single',
import_multi: 'Import multiple',
open: 'Open as new document',
buttons: [{
buttons: [
{
title: 'Knjižnica slik'
}],
imgLibs: [{
}
],
imgLibs: [
{
name: 'Demo library (local)',
url: '{path}imagelib/index{modularVersion}.html',
description: 'Demonstration library for SVG-edit on this server'
}, {
},
{
name: 'IAN Symbol Libraries',
url: 'https://ian.umces.edu/symbols/catalog/svgedit/album_chooser.php?svgedit=3',
description: 'Free library of illustrations'
@@ -29,8 +30,4 @@ var svgEditorExtensionLocale_imagelib_sl = (function () {
}
*/
]
};
return sl;
}());
};

View File

@@ -1,20 +1,21 @@
var svgEditorExtensionLocale_imagelib_zh_CN = (function () {
'use strict';
var zhCN = {
export default {
select_lib: 'Select an image library',
show_list: 'Show library list',
import_single: 'Import single',
import_multi: 'Import multiple',
open: 'Open as new document',
buttons: [{
buttons: [
{
title: '图像库'
}],
imgLibs: [{
}
],
imgLibs: [
{
name: 'Demo library (local)',
url: '{path}imagelib/index{modularVersion}.html',
description: 'Demonstration library for SVG-edit on this server'
}, {
},
{
name: 'IAN Symbol Libraries',
url: 'https://ian.umces.edu/symbols/catalog/svgedit/album_chooser.php?svgedit=3',
description: 'Free library of illustrations'
@@ -29,8 +30,4 @@ var svgEditorExtensionLocale_imagelib_zh_CN = (function () {
}
*/
]
};
return zhCN;
}());
};

View File

@@ -1,81 +1,46 @@
var svgEditorExtensionLocale_markers_en = (function () {
'use strict';
var en = {
export default {
name: 'Markers',
langList: [{
id: 'nomarker',
title: 'No Marker'
}, {
id: 'leftarrow',
title: 'Left Arrow'
}, {
id: 'rightarrow',
title: 'Right Arrow'
}, {
id: 'textmarker',
title: 'Text Marker'
}, {
id: 'forwardslash',
title: 'Forward Slash'
}, {
id: 'reverseslash',
title: 'Reverse Slash'
}, {
id: 'verticalslash',
title: 'Vertical Slash'
}, {
id: 'box',
title: 'Box'
}, {
id: 'star',
title: 'Star'
}, {
id: 'xmark',
title: 'X'
}, {
id: 'triangle',
title: 'Triangle'
}, {
id: 'mcircle',
title: 'Circle'
}, {
id: 'leftarrow_o',
title: 'Open Left Arrow'
}, {
id: 'rightarrow_o',
title: 'Open Right Arrow'
}, {
id: 'box_o',
title: 'Open Box'
}, {
id: 'star_o',
title: 'Open Star'
}, {
id: 'triangle_o',
title: 'Open Triangle'
}, {
id: 'mcircle_o',
title: 'Open Circle'
}],
contextTools: [{
langList: [
{id: 'nomarker', title: 'No Marker'},
{id: 'leftarrow', title: 'Left Arrow'},
{id: 'rightarrow', title: 'Right Arrow'},
{id: 'textmarker', title: 'Text Marker'},
{id: 'forwardslash', title: 'Forward Slash'},
{id: 'reverseslash', title: 'Reverse Slash'},
{id: 'verticalslash', title: 'Vertical Slash'},
{id: 'box', title: 'Box'},
{id: 'star', title: 'Star'},
{id: 'xmark', title: 'X'},
{id: 'triangle', title: 'Triangle'},
{id: 'mcircle', title: 'Circle'},
{id: 'leftarrow_o', title: 'Open Left Arrow'},
{id: 'rightarrow_o', title: 'Open Right Arrow'},
{id: 'box_o', title: 'Open Box'},
{id: 'star_o', title: 'Open Star'},
{id: 'triangle_o', title: 'Open Triangle'},
{id: 'mcircle_o', title: 'Open Circle'}
],
contextTools: [
{
title: 'Start marker',
label: 's'
}, {
},
{
title: 'Select start marker type'
}, {
},
{
title: 'Middle marker',
label: 'm'
}, {
},
{
title: 'Select mid marker type'
}, {
},
{
title: 'End marker',
label: 'e'
}, {
},
{
title: 'Select end marker type'
}]
};
return en;
}());
}
]
};

107
dist/extensions/ext-locale/markers/zh-CN.js vendored Normal file → Executable file
View File

@@ -1,81 +1,46 @@
var svgEditorExtensionLocale_markers_zh_CN = (function () {
'use strict';
var zhCN = {
export default {
name: '标记',
langList: [{
id: 'nomarker',
title: '无标记'
}, {
id: 'leftarrow',
title: '左箭头'
}, {
id: 'rightarrow',
title: '右箭头'
}, {
id: 'textmarker',
title: '文本'
}, {
id: 'forwardslash',
title: '斜杠'
}, {
id: 'reverseslash',
title: '反斜杠'
}, {
id: 'verticalslash',
title: '垂直线'
}, {
id: 'box',
title: '方块'
}, {
id: 'star',
title: '星形'
}, {
id: 'xmark',
title: 'X'
}, {
id: 'triangle',
title: '三角形'
}, {
id: 'mcircle',
title: '圆形'
}, {
id: 'leftarrow_o',
title: '左箭头(空心)'
}, {
id: 'rightarrow_o',
title: '右箭头(空心)'
}, {
id: 'box_o',
title: '方块(空心)'
}, {
id: 'star_o',
title: '星形(空心)'
}, {
id: 'triangle_o',
title: '三角形(空心)'
}, {
id: 'mcircle_o',
title: '圆形(空心)'
}],
contextTools: [{
langList: [
{id: 'nomarker', title: '无标记'},
{id: 'leftarrow', title: '左箭头'},
{id: 'rightarrow', title: '右箭头'},
{id: 'textmarker', title: '文本'},
{id: 'forwardslash', title: '斜杠'},
{id: 'reverseslash', title: '反斜杠'},
{id: 'verticalslash', title: '垂直线'},
{id: 'box', title: '方块'},
{id: 'star', title: '星形'},
{id: 'xmark', title: 'X'},
{id: 'triangle', title: '三角形'},
{id: 'mcircle', title: '圆形'},
{id: 'leftarrow_o', title: '左箭头(空心)'},
{id: 'rightarrow_o', title: '右箭头(空心)'},
{id: 'box_o', title: '方块(空心)'},
{id: 'star_o', title: '星形(空心)'},
{id: 'triangle_o', title: '三角形(空心)'},
{id: 'mcircle_o', title: '圆形(空心)'}
],
contextTools: [
{
title: '起始标记',
label: 's'
}, {
},
{
title: '选择起始标记类型'
}, {
},
{
title: '中段标记',
label: 'm'
}, {
},
{
title: '选择中段标记类型'
}, {
},
{
title: '末端标记',
label: 'e'
}, {
},
{
title: '选择末端标记类型'
}]
};
return zhCN;
}());
}
]
};

View File

@@ -1,13 +1,8 @@
var svgEditorExtensionLocale_mathjax_en = (function () {
'use strict';
var en = {
export default {
name: 'MathJax',
buttons: [{
buttons: [
{
title: 'Add Mathematics'
}]
};
return en;
}());
}
]
};

17
dist/extensions/ext-locale/mathjax/zh-CN.js vendored Normal file → Executable file
View File

@@ -1,13 +1,8 @@
var svgEditorExtensionLocale_mathjax_zh_CN = (function () {
'use strict';
var zhCN = {
export default {
name: '数学',
buttons: [{
buttons: [
{
title: '添加数学计算'
}]
};
return zhCN;
}());
}
]
};

View File

@@ -1,13 +1,8 @@
var svgEditorExtensionLocale_panning_en = (function () {
'use strict';
var en = {
export default {
name: 'Extension Panning',
buttons: [{
buttons: [
{
title: 'Panning'
}]
};
return en;
}());
}
]
};

17
dist/extensions/ext-locale/panning/zh-CN.js vendored Normal file → Executable file
View File

@@ -1,13 +1,8 @@
var svgEditorExtensionLocale_panning_zh_CN = (function () {
'use strict';
var zhCN = {
export default {
name: '移动',
buttons: [{
buttons: [
{
title: '移动'
}]
};
return zhCN;
}());
}
]
};

View File

@@ -1,74 +1,40 @@
var svgEditorExtensionLocale_placemark_en = (function () {
'use strict';
var en = {
export default {
name: 'placemark',
langList: [{
id: 'nomarker',
title: 'No Marker'
}, {
id: 'leftarrow',
title: 'Left Arrow'
}, {
id: 'rightarrow',
title: 'Right Arrow'
}, {
id: 'forwardslash',
title: 'Forward Slash'
}, {
id: 'reverseslash',
title: 'Reverse Slash'
}, {
id: 'verticalslash',
title: 'Vertical Slash'
}, {
id: 'box',
title: 'Box'
}, {
id: 'star',
title: 'Star'
}, {
id: 'xmark',
title: 'X'
}, {
id: 'triangle',
title: 'Triangle'
}, {
id: 'mcircle',
title: 'Circle'
}, {
id: 'leftarrow_o',
title: 'Open Left Arrow'
}, {
id: 'rightarrow_o',
title: 'Open Right Arrow'
}, {
id: 'box_o',
title: 'Open Box'
}, {
id: 'star_o',
title: 'Open Star'
}, {
id: 'triangle_o',
title: 'Open Triangle'
}, {
id: 'mcircle_o',
title: 'Open Circle'
}],
buttons: [{
langList: [
{id: 'nomarker', title: 'No Marker'},
{id: 'leftarrow', title: 'Left Arrow'},
{id: 'rightarrow', title: 'Right Arrow'},
{id: 'forwardslash', title: 'Forward Slash'},
{id: 'reverseslash', title: 'Reverse Slash'},
{id: 'verticalslash', title: 'Vertical Slash'},
{id: 'box', title: 'Box'},
{id: 'star', title: 'Star'},
{id: 'xmark', title: 'X'},
{id: 'triangle', title: 'Triangle'},
{id: 'mcircle', title: 'Circle'},
{id: 'leftarrow_o', title: 'Open Left Arrow'},
{id: 'rightarrow_o', title: 'Open Right Arrow'},
{id: 'box_o', title: 'Open Box'},
{id: 'star_o', title: 'Open Star'},
{id: 'triangle_o', title: 'Open Triangle'},
{id: 'mcircle_o', title: 'Open Circle'}
],
buttons: [
{
title: 'Placemark Tool'
}],
contextTools: [{
}
],
contextTools: [
{
title: 'Select Place marker type'
}, {
},
{
title: 'Text on separated with ; ',
label: 'Text'
}, {
},
{
title: 'Font for text',
label: ''
}]
};
return en;
}());
}
]
};

View File

@@ -1,17 +1,14 @@
var svgEditorExtensionLocale_polygon_en = (function () {
'use strict';
var en = {
export default {
name: 'polygon',
buttons: [{
buttons: [
{
title: 'Polygon Tool'
}],
contextTools: [{
}
],
contextTools: [
{
title: 'Number of Sides',
label: 'sides'
}]
};
return en;
}());
}
]
};

23
dist/extensions/ext-locale/polygon/zh-CN.js vendored Normal file → Executable file
View File

@@ -1,17 +1,14 @@
var svgEditorExtensionLocale_polygon_zh_CN = (function () {
'use strict';
var zhCN = {
export default {
name: '多边形',
buttons: [{
buttons: [
{
title: '多边形工具'
}],
contextTools: [{
}
],
contextTools: [
{
title: '边数',
label: '边数'
}]
};
return zhCN;
}());
}
]
};

View File

@@ -1,11 +1,4 @@
var svgEditorExtensionLocale_server_moinsave_en = (function () {
'use strict';
var en = {
export default {
saved: 'Saved! Return to Item View!',
hiddenframe: 'Moinsave frame to store hidden values'
};
return en;
}());
};

11
dist/extensions/ext-locale/server_moinsave/zh-CN.js vendored Normal file → Executable file
View File

@@ -1,11 +1,4 @@
var svgEditorExtensionLocale_server_moinsave_zh_CN = (function () {
'use strict';
var zhCN = {
export default {
saved: '已保存! 返回视图!',
hiddenframe: 'Moinsave frame to store hidden values'
};
return zhCN;
}());
};

View File

@@ -1,11 +1,4 @@
var svgEditorExtensionLocale_server_opensave_en = (function () {
'use strict';
var en = {
export default {
uploading: 'Uploading...',
hiddenframe: 'Opensave frame to store hidden values'
};
return en;
}());
};

11
dist/extensions/ext-locale/server_opensave/zh-CN.js vendored Normal file → Executable file
View File

@@ -1,11 +1,4 @@
var svgEditorExtensionLocale_server_opensave_zh_CN = (function () {
'use strict';
var zhCN = {
export default {
uploading: '正在上传...',
hiddenframe: 'Opensave frame to store hidden values'
};
return zhCN;
}());
};

View File

@@ -1,7 +1,4 @@
var svgEditorExtensionLocale_shapes_en = (function () {
'use strict';
var en = {
export default {
loading: 'Loading...',
categories: {
basic: 'Basic',
@@ -19,11 +16,9 @@ var svgEditorExtensionLocale_shapes_en = (function () {
raphael_1: 'raphaeljs.com set 1',
raphael_2: 'raphaeljs.com set 2'
},
buttons: [{
buttons: [
{
title: 'Shape library'
}]
};
return en;
}());
}
]
};

View File

@@ -1,7 +1,4 @@
var svgEditorExtensionLocale_shapes_fr = (function () {
'use strict';
var fr = {
export default {
loading: 'Loading...',
categories: {
basic: 'Basic',
@@ -19,11 +16,9 @@ var svgEditorExtensionLocale_shapes_fr = (function () {
raphael_1: 'raphaeljs.com set 1',
raphael_2: 'raphaeljs.com set 2'
},
buttons: [{
buttons: [
{
title: "Bibliothèque d'images"
}]
};
return fr;
}());
}
]
};

17
dist/extensions/ext-locale/shapes/zh-CN.js vendored Normal file → Executable file
View File

@@ -1,7 +1,4 @@
var svgEditorExtensionLocale_shapes_zh_CN = (function () {
'use strict';
var zhCN = {
export default {
loading: '正在加载...',
categories: {
basic: '基本',
@@ -19,11 +16,9 @@ var svgEditorExtensionLocale_shapes_zh_CN = (function () {
raphael_1: 'raphaeljs.com 集合 1',
raphael_2: 'raphaeljs.com 集合 2'
},
buttons: [{
buttons: [
{
title: '图元库'
}]
};
return zhCN;
}());
}
]
};

View File

@@ -1,23 +1,22 @@
var svgEditorExtensionLocale_star_en = (function () {
'use strict';
var en = {
export default {
name: 'star',
buttons: [{
buttons: [
{
title: 'Star Tool'
}],
contextTools: [{
}
],
contextTools: [
{
title: 'Number of Sides',
label: 'points'
}, {
},
{
title: 'Pointiness',
label: 'Pointiness'
}, {
},
{
title: 'Twists the star',
label: 'Radial Shift'
}]
};
return en;
}());
}
]
};

29
dist/extensions/ext-locale/star/zh-CN.js vendored Normal file → Executable file
View File

@@ -1,23 +1,22 @@
var svgEditorExtensionLocale_star_zh_CN = (function () {
'use strict';
var zhCN = {
export default {
name: '星形',
buttons: [{
buttons: [
{
title: '星形工具'
}],
contextTools: [{
}
],
contextTools: [
{
title: '顶点',
label: '顶点'
}, {
},
{
title: '钝度',
label: '钝度'
}, {
},
{
title: '径向',
label: '径向'
}]
};
return zhCN;
}());
}
]
};

View File

@@ -1,8 +1,9 @@
var svgEditorExtensionLocale_storage_de = (function () {
'use strict';
var de = {
message: 'Standardmäßig kann SVG-Edit Ihre Editor-Einstellungen ' + 'und die SVG-Inhalte lokal auf Ihrem Gerät abspeichern. So brauchen Sie ' + 'nicht jedes Mal die SVG neu laden. Falls Sie aus Datenschutzgründen ' + 'dies nicht wollen, ' + 'können Sie die Standardeinstellung im Folgenden ändern.',
export default {
message: 'Standardmäßig kann SVG-Edit Ihre Editor-Einstellungen ' +
'und die SVG-Inhalte lokal auf Ihrem Gerät abspeichern. So brauchen Sie ' +
'nicht jedes Mal die SVG neu laden. Falls Sie aus Datenschutzgründen ' +
'dies nicht wollen, ' +
'können Sie die Standardeinstellung im Folgenden ändern.',
storagePrefsAndContent: 'Store preferences and SVG content locally',
storagePrefsOnly: 'Only store preferences locally',
storagePrefs: 'Store preferences locally',
@@ -10,8 +11,4 @@ var svgEditorExtensionLocale_storage_de = (function () {
storageNoPrefs: 'Do not store my preferences locally',
rememberLabel: 'Remember this choice?',
rememberTooltip: 'If you choose to opt out of storage while remembering this choice, the URL will change so as to avoid asking again.'
};
return de;
}());
};

View File

@@ -1,8 +1,9 @@
var svgEditorExtensionLocale_storage_en = (function () {
'use strict';
var en = {
message: 'By default and where supported, SVG-Edit can store your editor ' + 'preferences and SVG content locally on your machine so you do not ' + 'need to add these back each time you load SVG-Edit. If, for privacy ' + 'reasons, you do not wish to store this information on your machine, ' + 'you can change away from the default option below.',
export default {
message: 'By default and where supported, SVG-Edit can store your editor ' +
'preferences and SVG content locally on your machine so you do not ' +
'need to add these back each time you load SVG-Edit. If, for privacy ' +
'reasons, you do not wish to store this information on your machine, ' +
'you can change away from the default option below.',
storagePrefsAndContent: 'Store preferences and SVG content locally',
storagePrefsOnly: 'Only store preferences locally',
storagePrefs: 'Store preferences locally',
@@ -10,8 +11,4 @@ var svgEditorExtensionLocale_storage_en = (function () {
storageNoPrefs: 'Do not store my preferences locally',
rememberLabel: 'Remember this choice?',
rememberTooltip: 'If you choose to opt out of storage while remembering this choice, the URL will change so as to avoid asking again.'
};
return en;
}());
};

View File

@@ -1,8 +1,9 @@
var svgEditorExtensionLocale_storage_fr = (function () {
'use strict';
var fr = {
message: "Par défaut et si supporté, SVG-Edit peut stocker les préférences de l'éditeur " + "et le contenu SVG localement sur votre machine de sorte que vous n'ayez pas besoin de les " + 'rajouter chaque fois que vous chargez SVG-Edit. Si, pour des raisons de confidentialité, ' + 'vous ne souhaitez pas stocker ces données sur votre machine, vous pouvez changer ce ' + 'comportement ci-dessous.',
export default {
message: "Par défaut et si supporté, SVG-Edit peut stocker les préférences de l'éditeur " +
"et le contenu SVG localement sur votre machine de sorte que vous n'ayez pas besoin de les " +
'rajouter chaque fois que vous chargez SVG-Edit. Si, pour des raisons de confidentialité, ' +
'vous ne souhaitez pas stocker ces données sur votre machine, vous pouvez changer ce ' +
'comportement ci-dessous.',
storagePrefsAndContent: 'Store preferences and SVG content locally',
storagePrefsOnly: 'Only store preferences locally',
storagePrefs: 'Store preferences locally',
@@ -10,8 +11,4 @@ var svgEditorExtensionLocale_storage_fr = (function () {
storageNoPrefs: 'Do not store my preferences locally',
rememberLabel: 'Remember this choice?',
rememberTooltip: "Si vous choisissez de désactiver le stockage en mémorisant le choix, l'URL va changer afin que la question ne vous soit plus reposée."
};
return fr;
}());
};

14
dist/extensions/ext-locale/storage/zh-CN.js vendored Normal file → Executable file
View File

@@ -1,8 +1,6 @@
var svgEditorExtensionLocale_storage_zh_CN = (function () {
'use strict';
var zhCN = {
message: '默认情况下, SVG-Edit 在本地保存配置参数和画布内容. 如果基于隐私考虑, ' + '您可以勾选以下选项修改配置.',
export default {
message: '默认情况下, SVG-Edit 在本地保存配置参数和画布内容. 如果基于隐私考虑, ' +
'您可以勾选以下选项修改配置.',
storagePrefsAndContent: '本地存储配置参数和SVG图',
storagePrefsOnly: '本地只存储配置参数',
storagePrefs: '本地存储配置参数',
@@ -10,8 +8,4 @@ var svgEditorExtensionLocale_storage_zh_CN = (function () {
storageNoPrefs: '本地不保存配置参数',
rememberLabel: '记住选择?',
rememberTooltip: '如果您勾选记住选择,将不再弹出本窗口.'
};
return zhCN;
}());
};

View File

@@ -1,13 +1,8 @@
var svgEditorExtensionLocale_webappfind_en = (function () {
'use strict';
var en = {
export default {
name: 'WebAppFind',
buttons: [{
buttons: [
{
title: 'Save Image back to Disk'
}]
};
return en;
}());
}
]
};

17
dist/extensions/ext-locale/webappfind/zh-CN.js vendored Normal file → Executable file
View File

@@ -1,13 +1,8 @@
var svgEditorExtensionLocale_webappfind_zh_CN = (function () {
'use strict';
var zhCN = {
export default {
name: 'WebAppFind',
buttons: [{
buttons: [
{
title: '保存图片到磁盘'
}]
};
return zhCN;
}());
}
]
};

File diff suppressed because it is too large Load Diff

View File

@@ -1,180 +1,26 @@
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
* @param {PlainObject<string, string>} atts
* @returns {void}
*/
function addScriptAtts(script, atts) {
['id', 'class', 'type'].forEach(function (prop) {
if (prop in atts) {
script[prop] = atts[prop];
}
});
} // Additions by Brett
function importScript(url) {
var atts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
if (Array.isArray(url)) {
return Promise.all(url.map(function (u) {
return importScript(u, atts);
}));
}
return new Promise(function (resolve, reject) {
// eslint-disable-line promise/avoid-new
var script = document.createElement('script');
/**
/* globals MathJax */
/**
* @file ext-mathjax.js
*
* @returns {void}
*/
function scriptOnError() {
reject(new Error("Failed to import: ".concat(url)));
destructor();
}
/**
* @license MIT
*
* @copyright 2013 Jo Segaert
*
* @returns {void}
*/
// Todo: Wait for Mathjax 3.0 to get ES Module/avoid global
import {importScript} from '../../external/dynamic-import-polyfill/importModule.js';
function scriptOnLoad() {
resolve();
destructor();
}
var destructor = function destructor() {
script.removeEventListener('error', scriptOnError);
script.removeEventListener('load', scriptOnLoad);
script.remove();
script.src = '';
};
script.defer = 'defer';
addScriptAtts(script, atts);
script.addEventListener('error', scriptOnError);
script.addEventListener('load', scriptOnLoad);
script.src = url;
document.head.append(script);
});
}
var extMathjax = {
export default {
name: 'mathjax',
init: function init(_ref) {
var _this = this;
async init ({$, importLocale}) {
const strings = await importLocale();
const svgEditor = this;
const svgCanvas = svgEditor.canvas;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
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 _saveMath() {
var code = $('#mathjax_code_textarea').val(); // displaystyle to force MathJax NOT to use the inline style. Because it is
// less fancy!
// Configuration of the MathJax extention.
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">
const /* mathjaxConfiguration = `<script type="text/x-mathjax-config">
MathJax.Hub.Config({
extensions: ['tex2jax.js'],
jax: ['input/TeX', 'output/SVG'],
@@ -199,65 +45,147 @@ var svgEditorExtension_mathjax = (function () {
// 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
mathjaxSrcSecure = 'mathjax/MathJax.min.js?config=TeX-AMS-MML_SVG.js',
{uiStrings} = svgEditor;
let
math,
locationX,
locationY,
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.',
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}
*/
function saveMath () {
const 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 + '}']);
buttons = [{
/*
* 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 () {
const mathjaxMath = $('.MathJax_SVG');
const svg = $(mathjaxMath.html());
svg.find('use').each(function () {
// TODO: find a less pragmatic and more elegant solution to this.
const id = $(this).attr('href')
? $(this).attr('href').slice(1) // Works in Chrome.
: $(this).attr('xlink:href').slice(1); // Works in Firefox.
const glymph = $('#' + id).clone().removeAttr('id');
const x = $(this).attr('x');
const y = $(this).attr('y');
const 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);
}
);
}
const buttons = [{
id: 'tool_mathjax',
type: 'mode',
icon: svgEditor.curConfig.extIconsPath + 'mathjax.png',
events: {
click: function click() {
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
async click () {
// Set the mode.
svgCanvas.setMode('mathjax'); // Only load Mathjax when needed, we don't want to strain Svg-Edit any more.
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) {
$(
'<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();
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.
// 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 () {
// 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 () {
// 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.
// 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 ||
@@ -275,86 +203,105 @@ var svgEditorExtension_mathjax = (function () {
*/
// 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:
try {
await importScript(svgEditor.curConfig.extIconsPath + mathjaxSrcSecure);
// 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);
} catch (e) {
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]]);
}))();
}
}
}];
return _context2.abrupt("return", {
return {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'mathjax-icons.xml',
buttons: strings.buttons.map(function (button, i) {
buttons: strings.buttons.map((button, i) => {
return Object.assign(buttons[i], button);
}),
mouseDown: function mouseDown() {
if (svgCanvas.getMode() === 'mathjax') {
return {
started: true
};
}
mouseDown () {
if (svgCanvas.getMode() === 'mathjax') {
return {started: true};
}
return undefined;
},
mouseUp: function mouseUp(opts) {
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
const 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.
}
$('#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.
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);
}))();
}
};
return extMathjax;
}());
}
};

View File

@@ -1,7 +1,4 @@
var svgEditorExtension_overview_window = (function () {
'use strict';
/**
/**
* @file ext-overview_window.js
*
* @license MIT
@@ -9,61 +6,79 @@ var svgEditorExtension_overview_window = (function () {
* @copyright 2013 James Sacksteder
*
*/
var extOverview_window = {
export default {
name: 'overview_window',
init: function init(_ref) {
var $ = _ref.$,
isChrome = _ref.isChrome,
isIE = _ref.isIE;
var overviewWindowGlobals = {}; // Disabled in Chrome 48-, see https://github.com/SVG-Edit/svgedit/issues/26 and
init ({$, isChrome, isIE}) {
const overviewWindowGlobals = {};
// Disabled in Chrome 48-, see https://github.com/SVG-Edit/svgedit/issues/26 and
// https://code.google.com/p/chromium/issues/detail?id=565120.
if (isChrome()) {
var verIndex = navigator.userAgent.indexOf('Chrome/') + 7;
var chromeVersion = Number.parseInt(navigator.userAgent.substring(verIndex));
const verIndex = navigator.userAgent.indexOf('Chrome/') + 7;
const chromeVersion = Number.parseInt(navigator.userAgent.substring(verIndex));
if (chromeVersion < 49) {
return undefined;
}
} // Define and insert the base html element.
}
// Define and insert the base html element.
const propsWindowHtml =
'<div id="overview_window_content_pane" style="width:100%; ' +
'word-wrap:break-word; display:inline-block; margin-top:20px;">' +
'<div id="overview_window_content" style="position:relative; ' +
'left:12px; top:0px;">' +
'<div style="background-color:#A0A0A0; display:inline-block; ' +
'overflow:visible;">' +
'<svg id="overviewMiniView" width="150" height="100" x="0" ' +
'y="0" viewBox="0 0 4800 3600" ' +
'xmlns="http://www.w3.org/2000/svg" ' +
'xmlns:xlink="http://www.w3.org/1999/xlink">' +
'<use x="0" y="0" xlink:href="#svgroot"> </use>' +
'</svg>' +
'<div id="overview_window_view_box" style="min-width:50px; ' +
'min-height:50px; position:absolute; top:30px; left:30px; ' +
'z-index:5; background-color:rgba(255,0,102,0.3);">' +
'</div>' +
'</div>' +
'</div>' +
'</div>';
$('#sidepanels').append(propsWindowHtml);
var propsWindowHtml = '<div id="overview_window_content_pane" style="width:100%; ' + 'word-wrap:break-word; display:inline-block; margin-top:20px;">' + '<div id="overview_window_content" style="position:relative; ' + 'left:12px; top:0px;">' + '<div style="background-color:#A0A0A0; display:inline-block; ' + 'overflow:visible;">' + '<svg id="overviewMiniView" width="150" height="100" x="0" ' + 'y="0" viewBox="0 0 4800 3600" ' + 'xmlns="http://www.w3.org/2000/svg" ' + 'xmlns:xlink="http://www.w3.org/1999/xlink">' + '<use x="0" y="0" xlink:href="#svgroot"> </use>' + '</svg>' + '<div id="overview_window_view_box" style="min-width:50px; ' + 'min-height:50px; position:absolute; top:30px; left:30px; ' + 'z-index:5; background-color:rgba(255,0,102,0.3);">' + '</div>' + '</div>' + '</div>' + '</div>';
$('#sidepanels').append(propsWindowHtml); // Define dynamic animation of the view box.
// Define dynamic animation of the view box.
const updateViewBox = function () {
const portHeight = Number.parseFloat($('#workarea').css('height'));
const portWidth = Number.parseFloat($('#workarea').css('width'));
const portX = $('#workarea').scrollLeft();
const portY = $('#workarea').scrollTop();
const windowWidth = Number.parseFloat($('#svgcanvas').css('width'));
const windowHeight = Number.parseFloat($('#svgcanvas').css('height'));
const overviewWidth = $('#overviewMiniView').attr('width');
const overviewHeight = $('#overviewMiniView').attr('height');
const viewBoxX = portX / windowWidth * overviewWidth;
const viewBoxY = portY / windowHeight * overviewHeight;
const viewBoxWidth = portWidth / windowWidth * overviewWidth;
const viewBoxHeight = portHeight / windowHeight * overviewHeight;
var updateViewBox = function updateViewBox() {
var portHeight = Number.parseFloat($('#workarea').css('height'));
var portWidth = Number.parseFloat($('#workarea').css('width'));
var portX = $('#workarea').scrollLeft();
var portY = $('#workarea').scrollTop();
var windowWidth = Number.parseFloat($('#svgcanvas').css('width'));
var windowHeight = Number.parseFloat($('#svgcanvas').css('height'));
var overviewWidth = $('#overviewMiniView').attr('width');
var overviewHeight = $('#overviewMiniView').attr('height');
var viewBoxX = portX / windowWidth * overviewWidth;
var viewBoxY = portY / windowHeight * overviewHeight;
var viewBoxWidth = portWidth / windowWidth * overviewWidth;
var viewBoxHeight = portHeight / windowHeight * overviewHeight;
$('#overview_window_view_box').css('min-width', viewBoxWidth + 'px');
$('#overview_window_view_box').css('min-height', viewBoxHeight + 'px');
$('#overview_window_view_box').css('top', viewBoxY + 'px');
$('#overview_window_view_box').css('left', viewBoxX + 'px');
};
$('#workarea').scroll(function () {
if (!overviewWindowGlobals.viewBoxDragging) {
if (!(overviewWindowGlobals.viewBoxDragging)) {
updateViewBox();
}
});
$('#workarea').resize(updateViewBox);
updateViewBox(); // Compensate for changes in zoom and canvas size.
updateViewBox();
var updateViewDimensions = function updateViewDimensions() {
var viewWidth = $('#svgroot').attr('width');
var viewHeight = $('#svgroot').attr('height');
var viewX = 640;
var viewY = 480;
// Compensate for changes in zoom and canvas size.
const updateViewDimensions = function () {
const viewWidth = $('#svgroot').attr('width');
const viewHeight = $('#svgroot').attr('height');
let viewX = 640;
let viewY = 480;
if (isIE()) {
// This has only been tested with Firefox 10 and IE 9 (without chrome frame).
// I am not sure if if is Firefox or IE that is being non compliant here.
@@ -75,63 +90,57 @@ var svgEditorExtension_overview_window = (function () {
viewY = 0;
}
var svgWidthOld = $('#overviewMiniView').attr('width');
var svgHeightNew = viewHeight / viewWidth * svgWidthOld;
const svgWidthOld = $('#overviewMiniView').attr('width');
const svgHeightNew = viewHeight / viewWidth * svgWidthOld;
$('#overviewMiniView').attr('viewBox', viewX + ' ' + viewY + ' ' + viewWidth + ' ' + viewHeight);
$('#overviewMiniView').attr('height', svgHeightNew);
updateViewBox();
};
updateViewDimensions();
updateViewDimensions(); // Set up the overview window as a controller for the view port.
// Set up the overview window as a controller for the view port.
overviewWindowGlobals.viewBoxDragging = false;
const updateViewPortFromViewBox = function () {
const windowWidth = Number.parseFloat($('#svgcanvas').css('width'));
const windowHeight = Number.parseFloat($('#svgcanvas').css('height'));
const overviewWidth = $('#overviewMiniView').attr('width');
const overviewHeight = $('#overviewMiniView').attr('height');
const viewBoxX = Number.parseFloat($('#overview_window_view_box').css('left'));
const viewBoxY = Number.parseFloat($('#overview_window_view_box').css('top'));
const portX = viewBoxX / overviewWidth * windowWidth;
const portY = viewBoxY / overviewHeight * windowHeight;
var updateViewPortFromViewBox = function updateViewPortFromViewBox() {
var windowWidth = Number.parseFloat($('#svgcanvas').css('width'));
var windowHeight = Number.parseFloat($('#svgcanvas').css('height'));
var overviewWidth = $('#overviewMiniView').attr('width');
var overviewHeight = $('#overviewMiniView').attr('height');
var viewBoxX = Number.parseFloat($('#overview_window_view_box').css('left'));
var viewBoxY = Number.parseFloat($('#overview_window_view_box').css('top'));
var portX = viewBoxX / overviewWidth * windowWidth;
var portY = viewBoxY / overviewHeight * windowHeight;
$('#workarea').scrollLeft(portX);
$('#workarea').scrollTop(portY);
};
$('#overview_window_view_box').draggable({
containment: 'parent',
drag: updateViewPortFromViewBox,
start: function start() {
overviewWindowGlobals.viewBoxDragging = true;
},
stop: function stop() {
overviewWindowGlobals.viewBoxDragging = false;
}
start () { overviewWindowGlobals.viewBoxDragging = true; },
stop () { overviewWindowGlobals.viewBoxDragging = false; }
});
$('#overviewMiniView').click(function (evt) {
// Firefox doesn't support evt.offsetX and evt.offsetY.
var mouseX = evt.offsetX || evt.originalEvent.layerX;
var mouseY = evt.offsetY || evt.originalEvent.layerY;
var overviewWidth = $('#overviewMiniView').attr('width');
var overviewHeight = $('#overviewMiniView').attr('height');
var viewBoxWidth = Number.parseFloat($('#overview_window_view_box').css('min-width'));
var viewBoxHeight = Number.parseFloat($('#overview_window_view_box').css('min-height'));
var viewBoxX = mouseX - 0.5 * viewBoxWidth;
var viewBoxY = mouseY - 0.5 * viewBoxHeight; // deal with constraints
const mouseX = (evt.offsetX || evt.originalEvent.layerX);
const mouseY = (evt.offsetY || evt.originalEvent.layerY);
const overviewWidth = $('#overviewMiniView').attr('width');
const overviewHeight = $('#overviewMiniView').attr('height');
const viewBoxWidth = Number.parseFloat($('#overview_window_view_box').css('min-width'));
const viewBoxHeight = Number.parseFloat($('#overview_window_view_box').css('min-height'));
let viewBoxX = mouseX - 0.5 * viewBoxWidth;
let viewBoxY = mouseY - 0.5 * viewBoxHeight;
// deal with constraints
if (viewBoxX < 0) {
viewBoxX = 0;
}
if (viewBoxY < 0) {
viewBoxY = 0;
}
if (viewBoxX + viewBoxWidth > overviewWidth) {
viewBoxX = overviewWidth - viewBoxWidth;
}
if (viewBoxY + viewBoxHeight > overviewHeight) {
viewBoxY = overviewHeight - viewBoxHeight;
}
@@ -140,14 +149,11 @@ var svgEditorExtension_overview_window = (function () {
$('#overview_window_view_box').css('left', viewBoxX + 'px');
updateViewPortFromViewBox();
});
return {
name: 'overview window',
canvasUpdated: updateViewDimensions,
workareaResized: updateViewBox
};
}
};
return extOverview_window;
}());
};

View File

@@ -1,43 +1,4 @@
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);
});
};
}
/**
/**
* @file ext-panning.js
*
* @license MIT
@@ -45,56 +6,39 @@ var svgEditorExtension_panning = (function () {
* @copyright 2013 Luis Aguirre
*
*/
/*
/*
This is a very basic SVG-Edit extension to let tablet/mobile devices pan without problem
*/
var extPanning = {
*/
export default {
name: 'panning',
init: function init(_ref) {
var _this = this;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
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();
case 3:
strings = _context.sent;
svgEditor = _this;
svgCanvas = svgEditor.canvas;
buttons = [{
async init ({importLocale}) {
const strings = await importLocale();
const svgEditor = this;
const svgCanvas = svgEditor.canvas;
const buttons = [{
id: 'ext-panning',
icon: svgEditor.curConfig.extIconsPath + 'panning.png',
type: 'mode',
events: {
click: function click() {
click () {
svgCanvas.setMode('ext-panning');
}
}
}];
return _context.abrupt("return", {
return {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'ext-panning.xml',
buttons: strings.buttons.map(function (button, i) {
buttons: strings.buttons.map((button, i) => {
return Object.assign(buttons[i], button);
}),
mouseDown: function mouseDown() {
mouseDown () {
if (svgCanvas.getMode() === 'ext-panning') {
svgEditor.setPanning(true);
return {
started: true
};
return {started: true};
}
return undefined;
},
mouseUp: function mouseUp() {
mouseUp () {
if (svgCanvas.getMode() === 'ext-panning') {
svgEditor.setPanning(false);
return {
@@ -102,21 +46,8 @@ var svgEditorExtension_panning = (function () {
element: null
};
}
return undefined;
}
});
case 8:
case "end":
return _context.stop();
}
}
}, _callee);
}))();
}
};
return extPanning;
}());
}
};

6
dist/extensions/ext-panning.xml vendored Normal file
View File

@@ -0,0 +1,6 @@
<svg xmlns="http://www.w3.org/2000/svg">
<g id="ext-panning">
<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
<path d="m8.00038,150.84583l51.60005,-51.78485l0,25.89205l26.28711,0l35.45559,-0.20444l-0.72941,-24.34613l0.93304,-37.61812l-25.79949,0l51.5997,-51.78508l51.60047,51.78508l-25.80024,0l0,33.87256l1.13677,26.21891l21.45996,2.07722l39.3497,0l0,-25.89205l51.60043,51.78485l-51.60043,51.78563l0,-25.89281l-38.41666,-0.93639l-20.52692,0.20445l-3.00285,42.13754l0,20.76308l25.80024,0l-51.60047,51.78561l-51.5997,-51.78561l25.79949,0l0,-20.76308l0.72941,-41.20115l-41.98688,-0.20445l-20.68886,0l0,25.89281l-51.60005,-51.78563z" fill="#b2b2b2" id="svg_1" stroke="#000000" stroke-width="10"/> </svg>
</g>
</svg>

After

Width:  |  Height:  |  Size: 789 B

View File

@@ -1,39 +1,30 @@
var svgEditorExtension_php_savefile = (function () {
'use strict';
// TODO: Might add support for "exportImage" custom
// handler as in "ext-server_opensave.js" (and in savefile.php)
// TODO: Might add support for "exportImage" custom
// handler as in "ext-server_opensave.js" (and in savefile.php)
var extPhp_savefile = {
export default {
name: 'php_savefile',
init: function init(_ref) {
var $ = _ref.$;
var svgEditor = this;
var extPath = svgEditor.curConfig.extPath,
svgCanvas = svgEditor.canvas;
init ({$}) {
const svgEditor = this;
const {
curConfig: {extPath},
canvas: svgCanvas
} = svgEditor;
/**
* Get file name out of SVGEdit document title.
* @returns {string}
*/
function getFileNameFromTitle() {
var title = svgCanvas.getDocumentTitle();
function getFileNameFromTitle () {
const title = svgCanvas.getDocumentTitle();
return title.trim();
}
var saveSvgAction = extPath + 'savefile.php';
const saveSvgAction = extPath + 'savefile.php';
svgEditor.setCustomHandlers({
save: function save(win, data) {
var svg = '<?xml version="1.0" encoding="UTF-8"?>\n' + data,
save (win, data) {
const svg = '<?xml version="1.0" encoding="UTF-8"?>\n' + data,
filename = getFileNameFromTitle();
$.post(saveSvgAction, {
output_svg: svg,
filename: filename
});
$.post(saveSvgAction, {output_svg: svg, filename});
}
});
}
};
return extPhp_savefile;
}());
};

File diff suppressed because it is too large Load Diff

View File

@@ -1,92 +1,86 @@
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);
});
};
}
/**
/**
* @file ext-polygon.js
*
*
* @copyright 2010 CloudCanvas, Inc. All rights reserved
*
*/
var extPolygon = {
export default {
name: 'polygon',
init: function init(S) {
var _this = this;
async init (S) {
const svgEditor = this;
const svgCanvas = svgEditor.canvas;
const {$, importLocale} = S, // {svgcontent}
// addElem = svgCanvas.addSVGElementFromJson,
editingitex = false;
const strings = await importLocale();
let selElems,
// svgdoc = S.svgroot.parentNode.ownerDocument,
// newFOG, newFOGParent, newDef, newImageName, newMaskID, modeChangeG,
// edg = 0,
// undoCommand = 'Not image';
started, newFO;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
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 _sec(n) {
return 1 / Math.cos(n);
};
// const ccZoom;
// const wEl, hEl;
// const wOffset, hOffset;
// const ccRBG;
// const ccOpacity;
// const brushW, brushH;
cot = function _cot(n) {
return 1 / Math.tan(n);
};
// const ccDebug = document.getElementById('debugpanel');
setAttr = function _setAttr(attr, val) {
svgCanvas.changeSelectedAttribute(attr, val);
svgCanvas.call('changed', selElems);
};
showPanel = function _showPanel(on) {
var fcRules = $('#fc_rules');
/* const properlySourceSizeTextArea = function(){
// TODO: remove magic numbers here and get values from CSS
const height = $('#svg_source_container').height() - 80;
$('#svg_source_textarea').css('height', height);
}; */
/**
* @param {boolean} on
* @returns {void}
*/
function showPanel (on) {
let 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();
/*
function toggleSourceButtons(on){
$('#tool_source_save, #tool_source_cancel').toggle(!on);
$('#polygon_save, #polygon_cancel').toggle(on);
}
*/
case 9:
strings = _context.sent;
/**
* @param {string} attr
* @param {string|Float} val
* @returns {void}
*/
function setAttr (attr, val) {
svgCanvas.changeSelectedAttribute(attr, val);
svgCanvas.call('changed', selElems);
}
/**
* @param {Float} n
* @returns {Float}
*/
function cot (n) {
return 1 / Math.tan(n);
}
/**
* @param {Float} n
* @returns {Float}
*/
function sec (n) {
return 1 / Math.cos(n);
}
/**
* Obtained from http://code.google.com/p/passenger-top/source/browse/instiki/public/svg-edit/editor/extensions/ext-itex.js?r=3
@@ -95,7 +89,6 @@ var svgEditorExtension_polygon = (function () {
* @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',
@@ -129,74 +122,96 @@ var svgEditorExtension_polygon = (function () {
console.log(e);
return false;
}
return true;
}
*/
buttons = [{
const buttons = [{
id: 'tool_polygon',
icon: svgEditor.curConfig.extIconsPath + 'polygon.png',
type: 'mode',
position: 11,
events: {
click: function click() {
click () {
svgCanvas.setMode('polygon');
showPanel(true);
}
}
}];
contextTools = [{
const contextTools = [{
type: 'input',
panel: 'polygon_panel',
id: 'polySides',
size: 3,
defval: 5,
events: {
change: function change() {
change () {
setAttr('sides', this.value);
}
}
}];
return _context.abrupt("return", {
return {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'polygon-icons.svg',
buttons: strings.buttons.map(function (button, i) {
buttons: strings.buttons.map((button, i) => {
return Object.assign(buttons[i], button);
}),
context_tools: strings.contextTools.map(function (contextTool, i) {
context_tools: strings.contextTools.map((contextTool, i) => {
return Object.assign(contextTools[i], contextTool);
}),
callback: function callback() {
callback () {
$('#polygon_panel').hide();
const endChanges = function () {
// Todo: Missing?
};
// TODO: Needs to be done after orig icon loads
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 () {
/* 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?
}
// Todo: Uncomment the setItexString() function above and handle ajaxEndpoint?
/*
if (!setItexString($('#svg_source_textarea').val())) {
const ok = await $.confirm('Errors found. Revert to original?', function (ok) {
if (!ok) {
return false;
}
endChanges();
} else { */
endChanges();
// }
// setSelectMode();
});
/* const cancel = */
$('#tool_source_cancel').clone().hide().attr('id', 'polygon_cancel').unbind().appendTo('#tool_source_back').click(function () {
/* const cancel = */ $('#tool_source_cancel').clone().hide().attr(
'id', 'polygon_cancel'
).unbind().appendTo('#tool_source_back').click(function () {
endChanges();
});
}, 3000);
},
mouseDown: function mouseDown(opts) {
mouseDown (opts) {
if (svgCanvas.getMode() !== 'polygon') {
return undefined;
} // const e = opts.event;
}
// const e = opts.event;
const rgb = svgCanvas.getColor('fill');
// const ccRgbEl = rgb.substring(1, rgb.length);
const sRgb = svgCanvas.getColor('stroke');
// ccSRgbEl = sRgb.substring(1, rgb.length);
const sWidth = svgCanvas.getStrokeWidth();
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: {
@@ -212,75 +227,71 @@ var svgEditorExtension_polygon = (function () {
strokeWidth: sWidth
}
});
return {
started: true
};
},
mouseMove: function mouseMove(opts) {
mouseMove (opts) {
if (!started || 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;
}
// const e = opts.event;
const c = $(newFO).attr(['cx', 'cy', 'sides', 'orient', 'fill', 'strokecolor', 'strokeWidth']);
let x = opts.mouse_x;
let y = opts.mouse_y;
const {cx, cy, fill, strokecolor, strokeWidth, sides} = c, // {orient} = c,
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 = '';
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;
const inradius = (edg / 2) * cot(Math.PI / sides);
const circumradius = inradius * sec(Math.PI / sides);
let points = '';
for (let s = 0; sides >= s; s++) {
const 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');
}
// const poly = newFO.createElementNS(NS.SVG, 'polygon');
newFO.setAttribute('points', points);
newFO.setAttribute('fill', fill);
newFO.setAttribute('stroke', strokecolor);
newFO.setAttribute('stroke-width', strokeWidth); // newFO.setAttribute('transform', 'rotate(-90)');
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) {
mouseUp (opts) {
if (svgCanvas.getMode() !== 'polygon') {
return undefined;
}
var attrs = $(newFO).attr('edge');
var keep = attrs.edge !== '0'; // svgCanvas.addToSelection([newFO], true);
const attrs = $(newFO).attr('edge');
const keep = (attrs.edge !== '0');
// svgCanvas.addToSelection([newFO], true);
return {
keep: keep,
keep,
element: newFO
};
},
selectedChanged: function selectedChanged(opts) {
selectedChanged (opts) {
// Use this to update the current selected elements
selElems = opts.elems;
var i = selElems.length;
let i = selElems.length;
while (i--) {
var elem = selElems[i];
const elem = selElems[i];
if (elem && elem.getAttribute('shape') === 'regularPoly') {
if (opts.selectedElement && !opts.multiselected) {
$('#polySides').val(elem.getAttribute('sides'));
showPanel(true);
} else {
showPanel(false);
@@ -290,20 +301,9 @@ var svgEditorExtension_polygon = (function () {
}
}
},
elementChanged: function elementChanged(opts) {// const elem = opts.elems[0];
}
});
case 13:
case "end":
return _context.stop();
}
}
}, _callee);
}))();
elementChanged (opts) {
// const elem = opts.elems[0];
}
};
return extPolygon;
}());
}
};

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,99 +1,4 @@
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) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArrayLimit(arr, i) {
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
/**
/**
* @file ext-shapes.js
*
* @license MIT
@@ -101,91 +6,19 @@ var svgEditorExtension_shapes = (function () {
* @copyright 2010 Christian Tzurcanu, 2010 Alexis Deveria
*
*/
var extShapes = {
export default {
name: 'shapes',
init: function init(_ref) {
var _this = this;
async init ({$, importLocale}) {
const strings = await importLocale();
const svgEditor = this;
const canv = svgEditor.canvas;
const svgroot = canv.getRootElem();
let lastBBox = {};
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
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 _loadLibrary(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 _makeButtons(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 _loadIcons() {
$('#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;
// This populates the category list
const {categories} = strings;
/* eslint-disable max-len */
library = {
const library = {
basic: {
data: {
heart: 'm150,73c61,-175 300,0 0,225c-300,-225 -61,-400 0,-225z',
@@ -216,109 +49,222 @@ var svgEditorExtension_shapes = (function () {
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: []
}
};
/* eslint-enable max-len */
const modeId = 'shapelib';
const startClientPos = {};
let currentD, curShapeId, curShape, startX, startY;
let curLib = library.basic;
modeId = 'shapelib';
startClientPos = {};
curLib = library.basic;
/**
*
* @returns {void}
*/
function loadIcons () {
$('#shape_buttons').empty().append(curLib.buttons);
}
buttons = [{
/**
* @typedef {PlainObject} module:Extension.Shapes.Shapes
* @property {PlainObject<string, string>} data
* @property {Integer} [size]
* @property {boolean} [fill]
*/
/**
* @param {string|"basic"} cat Category ID
* @param {module:Extension.Shapes.Shapes} shapes
* @returns {void}
*/
function makeButtons (cat, shapes) {
const size = curLib.size || 300;
const fill = curLib.fill || false;
const off = size * 0.05;
const vb = [-off, -off, size + off * 2, size + off * 2].join(' ');
const stroke = fill ? 0 : (size / 30);
const 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'
);
const width = 24;
const height = 24;
shapeIcon.documentElement.setAttribute('width', width);
shapeIcon.documentElement.setAttribute('height', height);
const svgElem = $(document.importNode(shapeIcon.documentElement, true));
const {data} = shapes;
curLib.buttons = Object.entries(data).map(([id, pathD]) => {
const icon = svgElem.clone();
icon.find('path').attr('d', pathD);
const iconBtn = icon.wrap('<div class="tool_button">').parent().attr({
id: modeId + '_' + id,
title: id
});
// Store for later use
return iconBtn[0];
});
}
/**
* @param {string|"basic"} catId
* @returns {void}
*/
function loadLibrary (catId) {
const 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();
}
const buttons = [{
id: 'tool_shapelib',
icon: svgEditor.curConfig.extIconsPath + 'shapes.png',
type: 'mode_flyout',
// _flyout
type: 'mode_flyout', // _flyout
position: 6,
events: {
click: function click() {
click () {
canv.setMode(modeId);
}
}
}];
return _context.abrupt("return", {
return {
svgicons: svgEditor.curConfig.extIconsPath + 'ext-shapes.xml',
buttons: strings.buttons.map(function (button, i) {
buttons: strings.buttons.map((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;
callback () {
$('<style>').text(`
#shape_buttons {
overflow: auto;
width: 180px;
max-height: 300px;
display: table-cell;
vertical-align: middle;
}
#shape_cats {
min-width: 110px;
display: table-cell;
vertical-align: middle;
height: 300px;
}
#shape_cats > div {
line-height: 1em;
padding: .5em;
border:1px solid #B0B0B0;
background: #E8E8E8;
margin-bottom: -1px;
}
#shape_cats div:hover {
background: #FFFFCC;
}
#shape_cats div.current {
font-weight: bold;
}
`).appendTo('head');
var copy = btn.children().clone();
const btnDiv = $('<div id="shape_buttons">');
$('#tools_shapelib > *').wrapAll(btnDiv);
const shower = $('#tools_shapelib_show');
loadLibrary('basic');
// Do mouseup on parent element rather than each button
$('#shape_buttons').mouseup(function (evt) {
const btn = $(evt.target).closest('div.tool_button');
if (!btn.length) { return; }
const 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
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 = '';
const shapeCats = $('<div id="shape_cats">');
let catStr = '';
$.each(categories, function (id, label) {
catStr += '<div data-cat=' + id + '>' + label + '</div>';
});
shapeCats.html(catStr).children().bind('mouseup', function () {
var catlink = $(this);
const catlink = $(this);
catlink.siblings().removeClass('current');
catlink.addClass('current');
loadLibrary(catlink.attr('data-cat')); // Get stuff
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();
const 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];
});
// Now add shape categories from locale
const cats = {};
Object.entries(categories).forEach(([o, categoryName]) => {
cats['#shape_cats [data-cat="' + o + '"]'] = categoryName;
});
this.setStrings('content', cats);
},
mouseDown: function mouseDown(opts) {
var mode = canv.getMode();
if (mode !== modeId) {
return undefined;
}
mouseDown (opts) {
const mode = canv.getMode();
if (mode !== modeId) { return undefined; }
startX = opts.start_x;
var x = startX;
const x = startX;
startY = opts.start_y;
var y = startY;
var curStyle = canv.getStyle();
const y = startY;
const curStyle = canv.getStyle();
startClientPos.x = opts.event.clientX;
startClientPos.y = opts.event.clientY;
curShape = canv.addSVGElementFromJson({
element: 'path',
curStyles: true,
@@ -328,114 +274,103 @@ var svgEditorExtension_shapes = (function () {
opacity: curStyle.opacity / 2,
style: 'pointer-events:none'
}
}); // Make sure shape uses absolute values
});
if (/[a-z]/.test(currentD)) {
// 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);
canv.recalculateDimensions(curShape);
/* const tlist = */ canv.getTransformList(curShape);
lastBBox = curShape.getBBox();
return {
started: true
};
},
mouseMove: function mouseMove(opts) {
var mode = canv.getMode();
mouseMove (opts) {
const mode = canv.getMode();
if (mode !== modeId) { return; }
if (mode !== modeId) {
return;
}
const zoom = canv.getZoom();
const evt = opts.event;
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),
const x = opts.mouse_x / zoom;
const y = opts.mouse_y / zoom;
const tlist = canv.getTransformList(curShape),
box = curShape.getBBox(),
left = box.x,
top = box.y; // {width, height} = box,
left = box.x, top = box.y;
// {width, height} = box,
// const dx = (x - startX), dy = (y - startY);
var newbox = {
const 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;
let sx = (newbox.width / lastBBox.width) || 1;
let sy = (newbox.height / lastBBox.height) || 1;
// Not perfect, but mostly works...
let tx = 0;
if (x < startX) {
tx = lastBBox.width;
}
var ty = 0;
let ty = 0;
if (y < startY) {
ty = lastBBox.height;
} // update the transform list with translate,scale,translate
}
var translateOrigin = svgroot.createSVGTransform(),
// update the transform list with translate,scale,translate
const translateOrigin = svgroot.createSVGTransform(),
scale = svgroot.createSVGTransform(),
translateBack = svgroot.createSVGTransform();
translateOrigin.setTranslate(-(left + tx), -(top + ty));
translateOrigin.setTranslate(-(left + tx), -(top + ty));
if (!evt.shiftKey) {
var max = Math.min(Math.abs(sx), Math.abs(sy));
const 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();
mouseUp (opts) {
const mode = canv.getMode();
if (mode !== modeId) { return undefined; }
if (mode !== modeId) {
return undefined;
}
const keepObject = (opts.event.clientX !== startClientPos.x && opts.event.clientY !== startClientPos.y);
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);
}))();
}
};
return extShapes;
}());
}
};

10
dist/extensions/ext-shapes.xml vendored Normal file
View File

@@ -0,0 +1,10 @@
<svg xmlns="http://www.w3.org/2000/svg">
<g id="tool_shapelib">
<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 300 300">
<path fill="#c0c0c0" stroke-linejoin="round" stroke-width="14" stroke="#202020" fill-rule="nonzero" d="m70,194.72501l0,0c0,-10.30901 35.8172,-18.666 80,-18.666c44.18298,0 80,8.35699 80,18.666l0,74.66699c0,10.30899 -35.81702,18.66699 -80,18.66699c-44.1828,0 -80,-8.358 -80,-18.66699l0,-74.66699z"/>
<path fill="#c0c0c0" stroke-linejoin="round" stroke-width="14" stroke="#202020" fill-rule="nonzero" d="m70,114.608l0,0c0,-10.309 35.8172,-18.6668 80,-18.6668c44.18298,0 80,8.3578 80,18.6668l0,74.66699c0,10.30901 -35.81702,18.666 -80,18.666c-44.1828,0 -80,-8.35699 -80,-18.666l0,-74.66699z"/>
<path fill="#c0c0c0" stroke-linejoin="round" stroke-width="14" stroke="#202020" fill-rule="nonzero" d="m70,33.6667l0,0c0,-10.3094 35.8172,-18.6667 80,-18.6667c44.18298,0 80,8.3573 80,18.6667l0,74.6663c0,10.31 -35.81702,18.667 -80,18.667c-44.1828,0 -80,-8.357 -80,-18.667l0,-74.6663z"/>
<path id="svg_1" fill="#c0c0c0" stroke-linejoin="round" stroke-width="14" stroke="#202020" fill-rule="nonzero" d="m230,32.33334c0,10.30931 -35.81726,18.66666 -80,18.66666c-44.1828,0 -80,-8.35735 -80,-18.66666"/>
</svg>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -1,114 +1,89 @@
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);
});
};
}
/**
/**
* @file ext-star.js
*
*
* @copyright 2010 CloudCanvas, Inc. All rights reserved
*
*/
var extStar = {
export default {
name: 'star',
init: function init(S) {
var _this = this;
async init (S) {
const svgEditor = this;
const svgCanvas = svgEditor.canvas;
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
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 _setAttr(attr, val) {
svgCanvas.changeSelectedAttribute(attr, val);
svgCanvas.call('changed', selElems);
};
showPanel = function _showPanel(on) {
var fcRules = $('#fc_rules');
const {$, importLocale} = S; // {svgcontent},
let
selElems,
// editingitex = false,
// svgdoc = S.svgroot.parentNode.ownerDocument,
started,
newFO;
// edg = 0,
// newFOG, newFOGParent, newDef, newImageName, newMaskID,
// undoCommand = 'Not image',
// modeChangeG, ccZoom, wEl, hEl, wOffset, hOffset, ccRgbEl, brushW, brushH;
const strings = await importLocale();
/**
*
* @param {boolean} on
* @returns {void}
*/
function showPanel (on) {
let 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},
/*
function toggleSourceButtons(on){
$('#star_save, #star_cancel').toggle(on);
}
*/
_context.next = 7;
return importLocale();
case 7:
strings = _context.sent;
/**
*
* @param {string} attr
* @param {string|Float} val
* @returns {void}
*/
function setAttr (attr, val) {
svgCanvas.changeSelectedAttribute(attr, val);
svgCanvas.call('changed', selElems);
}
/*
function cot(n){
return 1 / Math.tan(n);
}
function sec(n){
return 1 / Math.cos(n);
}
*/
buttons = [{
const buttons = [{
id: 'tool_star',
icon: svgEditor.curConfig.extIconsPath + 'star.png',
type: 'mode',
position: 12,
events: {
click: function click() {
click () {
showPanel(true);
svgCanvas.setMode('star');
}
}
}];
contextTools = [{
const contextTools = [{
type: 'input',
panel: 'star_panel',
id: 'starNumPoints',
size: 3,
defval: 5,
events: {
change: function change() {
change () {
setAttr('point', this.value);
}
}
@@ -125,32 +100,35 @@ var svgEditorExtension_star = (function () {
size: 3,
defval: 0,
events: {
change: function change() {
change () {
setAttr('radialshift', this.value);
}
}
}];
return _context.abrupt("return", {
return {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'star-icons.svg',
buttons: strings.buttons.map(function (button, i) {
buttons: strings.buttons.map((button, i) => {
return Object.assign(buttons[i], button);
}),
context_tools: strings.contextTools.map(function (contextTool, i) {
context_tools: strings.contextTools.map((contextTool, i) => {
return Object.assign(contextTools[i], contextTool);
}),
callback: function callback() {
$('#star_panel').hide(); // const endChanges = 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();
mouseDown (opts) {
const rgb = svgCanvas.getColor('fill');
// const ccRgbEl = rgb.substring(1, rgb.length);
const sRgb = svgCanvas.getColor('stroke');
// const ccSRgbEl = sRgb.substring(1, rgb.length);
const sWidth = svgCanvas.getStrokeWidth();
if (svgCanvas.getMode() === 'star') {
started = true;
newFO = svgCanvas.addSVGElementFromJson({
element: 'polygon',
attr: {
@@ -172,95 +150,82 @@ var svgEditorExtension_star = (function () {
started: true
};
}
return undefined;
},
mouseMove: function mouseMove(opts) {
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,
const c = $(newFO).attr(['cx', 'cy', 'point', 'orient', 'fill', 'strokecolor', 'strokeWidth', 'radialshift']);
let x = opts.mouse_x;
let y = opts.mouse_y;
const {cx, cy, fill, strokecolor, strokeWidth, radialshift, point, orient} = c,
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);
let polyPoints = '';
for (let s = 0; point >= s; s++) {
let angle = 2.0 * Math.PI * (s / point);
if (orient === 'point') {
angle -= Math.PI / 2;
angle -= (Math.PI / 2);
} else if (orient === 'edge') {
angle = angle + Math.PI / point - Math.PI / 2;
angle = (angle + (Math.PI / point)) - (Math.PI / 2);
}
x = circumradius * Math.cos(angle) + cx;
y = circumradius * Math.sin(angle) + cy;
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;
angle = (2.0 * Math.PI * (s / point)) + (Math.PI / point);
if (orient === 'point') {
angle -= Math.PI / 2;
angle -= (Math.PI / 2);
} else if (orient === 'edge') {
angle = angle + Math.PI / point - Math.PI / 2;
angle = (angle + (Math.PI / point)) - (Math.PI / 2);
}
angle += radialshift;
x = inradius * Math.cos(angle) + cx;
y = inradius * Math.sin(angle) + cy;
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 = */
/* const shape = */ newFO.getAttribute('shape');
newFO.getAttribute('shape');
return {
started: true
};
}
return undefined;
},
mouseUp: function mouseUp() {
mouseUp () {
if (svgCanvas.getMode() === 'star') {
var attrs = $(newFO).attr(['r']); // svgCanvas.addToSelection([newFO], true);
const attrs = $(newFO).attr(['r']);
// svgCanvas.addToSelection([newFO], true);
return {
keep: attrs.r !== '0',
keep: (attrs.r !== '0'),
element: newFO
};
}
return undefined;
},
selectedChanged: function selectedChanged(opts) {
selectedChanged (opts) {
// Use this to update the current selected elements
selElems = opts.elems;
var i = selElems.length;
let i = selElems.length;
while (i--) {
var elem = selElems[i];
const elem = selElems[i];
if (elem && elem.getAttribute('shape') === 'star') {
if (opts.selectedElement && !opts.multiselected) {
// $('#starRadiusMulitplier').val(elem.getAttribute('r2'));
@@ -275,20 +240,9 @@ var svgEditorExtension_star = (function () {
}
}
},
elementChanged: function elementChanged(opts) {// const elem = opts.elems[0];
}
});
case 11:
case "end":
return _context.stop();
}
}
}, _callee);
}))();
elementChanged (opts) {
// const elem = opts.elems[0];
}
};
return extStar;
}());
}
};

View File

@@ -1,99 +1,4 @@
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 _slicedToArray(arr, i) {
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
}
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
function _iterableToArrayLimit(arr, i) {
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
var _arr = [];
var _n = true;
var _d = false;
var _e = undefined;
try {
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
_arr.push(_s.value);
if (i && _arr.length === i) break;
}
} catch (err) {
_d = true;
_e = err;
} finally {
try {
if (!_n && _i["return"] != null) _i["return"]();
} finally {
if (_d) throw _e;
}
}
return _arr;
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableRest() {
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
/**
/**
* @file ext-storage.js
*
* This extension allows automatic saving of the SVG canvas contents upon
@@ -112,35 +17,44 @@ var svgEditorExtension_storage = (function () {
* and `imagePath`, but other currently used config in the extensions)
* @todo We might provide control of storage settings through the UI besides the
* initial (or URL-forced) dialog. *
*/
var extStorage = {
*/
export default {
name: 'storage',
init: function init(_ref) {
var $ = _ref.$;
var svgEditor = this;
var svgCanvas = svgEditor.canvas; // We could empty any already-set data for users when they decline storage,
init ({$}) {
const svgEditor = this;
const svgCanvas = svgEditor.canvas;
// We could empty any already-set data for users when they decline storage,
// but it would be a risk for users who wanted to store but accidentally
// said "no"; instead, we'll let those who already set it, delete it themselves;
// to change, set the "emptyStorageOnDecline" config setting to true
// in svgedit-config-iife.js/svgedit-config-es.js.
const {
emptyStorageOnDecline,
// When the code in svg-editor.js prevents local storage on load per
// user request, we also prevent storing on unload here so as to
// avoid third-party sites making XSRF requests or providing links
// which would cause the user's local storage not to load and then
// upon page unload (such as the user closing the window), the storage
// would thereby be set with an empty value, erasing any of the
// user's prior work. To change this behavior so that no use of storage
// or adding of new storage takes place regardless of settings, set
// the "noStorageOnLoad" config setting to true in svgedit-config-*.js.
noStorageOnLoad,
forceStorage
} = svgEditor.curConfig;
const {storage, updateCanvas} = svgEditor;
var _svgEditor$curConfig = svgEditor.curConfig,
emptyStorageOnDecline = _svgEditor$curConfig.emptyStorageOnDecline,
noStorageOnLoad = _svgEditor$curConfig.noStorageOnLoad,
forceStorage = _svgEditor$curConfig.forceStorage;
var storage = svgEditor.storage,
updateCanvas = svgEditor.updateCanvas;
/**
* Replace `storagePrompt` parameter within URL.
* @param {string} val
* @returns {void}
* @todo Replace the string manipulation with `searchParams.set`
*/
function replaceStoragePrompt(val) {
function replaceStoragePrompt (val) {
val = val ? 'storagePrompt=' + val : '';
var loc = top.location; // Allow this to work with the embedded editor as well
const loc = top.location; // Allow this to work with the embedded editor as well
if (loc.href.includes('storagePrompt=')) {
/*
loc.href = loc.href.replace(/(?<sep>[&?])storagePrompt=[^&]*(?<amp>&?)/, function (n0, sep, amp) {
@@ -148,24 +62,22 @@ var svgEditorExtension_storage = (function () {
});
*/
loc.href = loc.href.replace(/([&?])storagePrompt=[^&]*(&?)/, function (n0, n1, amp) {
return (val ? n1 : '') + val + (!val && amp ? n1 : amp || '');
return (val ? n1 : '') + val + (!val && amp ? n1 : (amp || ''));
});
} else {
loc.href += (loc.href.includes('?') ? '&' : '?') + val;
}
}
/**
* Sets SVG content as a string with "svgedit-" and the current
* canvas name as namespace.
* @param {string} val
* @returns {void}
*/
function setSVGContentStorage(val) {
function setSVGContentStorage (val) {
if (storage) {
var name = 'svgedit-' + svgEditor.curConfig.canvasName;
const name = 'svgedit-' + svgEditor.curConfig.canvasName;
if (!val) {
storage.removeItem(name);
} else {
@@ -173,43 +85,40 @@ var svgEditorExtension_storage = (function () {
}
}
}
/**
* Set the cookie to expire.
* @param {string} cookie
* @returns {void}
*/
function expireCookie(cookie) {
function expireCookie (cookie) {
document.cookie = encodeURIComponent(cookie) + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT';
}
/**
* Expire the storage cookie.
* @returns {void}
*/
function removeStoragePrefCookie() {
function removeStoragePrefCookie () {
expireCookie('svgeditstore');
}
/**
* Empties storage for each of the current preferences.
* @returns {void}
*/
function emptyStorage() {
function emptyStorage () {
setSVGContentStorage('');
Object.keys(svgEditor.curPrefs).forEach(function (name) {
Object.keys(svgEditor.curPrefs).forEach((name) => {
name = 'svg-edit-' + name;
if (storage) {
storage.removeItem(name);
}
expireCookie(name);
});
} // emptyStorage();
}
// emptyStorage();
/**
* Listen for unloading: If and only if opted in by the user, set the content
@@ -220,37 +129,27 @@ var svgEditorExtension_storage = (function () {
* 3. Use localStorage (where available) or cookies to set preferences.
* @returns {void}
*/
function setupBeforeUnloadListener() {
function setupBeforeUnloadListener () {
window.addEventListener('beforeunload', function (e) {
// Don't save anything unless the user opted in to storage
if (!document.cookie.match(/(?:^|;\s*)svgeditstore=(?:prefsAndContent|prefsOnly)/)) {
return;
}
if (document.cookie.match(/(?:^|;\s*)svgeditstore=prefsAndContent/)) {
setSVGContentStorage(svgCanvas.getSvgString());
}
svgEditor.setConfig({
no_save_warning: true
}); // No need for explicit saving at all once storage is on
svgEditor.setConfig({no_save_warning: true}); // No need for explicit saving at all once storage is on
// svgEditor.showSaveWarning = false;
var curPrefs = svgEditor.curPrefs;
Object.entries(curPrefs).forEach(function (_ref2) {
var _ref3 = _slicedToArray(_ref2, 2),
key = _ref3[0],
val = _ref3[1];
const {curPrefs} = svgEditor;
var store = val !== undefined;
Object.entries(curPrefs).forEach(([key, val]) => {
const store = (val !== undefined);
key = 'svg-edit-' + key;
if (!store) {
return;
}
if (storage) {
storage.setItem(key, val);
} else if (window.widget) {
@@ -263,103 +162,85 @@ var svgEditorExtension_storage = (function () {
});
}
var loaded = false;
let loaded = false;
return {
name: 'storage',
langReady: function langReady(_ref4) {
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
var importLocale, storagePrompt, confirmSetStorage, message, storagePrefsAndContent, storagePrefsOnly, storagePrefs, storageNoPrefsOrContent, storageNoPrefs, rememberLabel, rememberTooltip, options, oldContainerWidth, oldContainerMarginLeft, oldContentHeight, oldContainerHeight, _yield$$$select, pref, checked;
async langReady ({importLocale}) {
const storagePrompt = new URL(top.location).searchParams.get('storagePrompt');
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
importLocale = _ref4.importLocale;
storagePrompt = new URL(top.location).searchParams.get('storagePrompt');
_context.next = 4;
return importLocale();
const confirmSetStorage = await importLocale();
const {
message, storagePrefsAndContent, storagePrefsOnly,
storagePrefs, storageNoPrefsOrContent, storageNoPrefs,
rememberLabel, rememberTooltip
} = confirmSetStorage;
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
// No need to run this one-time dialog again just because the user
// changes the language
if (!loaded) {
_context.next = 8;
break;
if (loaded) {
return;
}
loaded = true;
return _context.abrupt("return");
case 8:
loaded = true; // Note that the following can load even if "noStorageOnLoad" is
// 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
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
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;
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.
)) {
const 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}
);
}
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;
// Hack to temporarily provide a wide and high enough dialog
const 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
$('#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, {
const {response: pref, checked} = await $.select(
message,
options,
null,
null,
{
label: rememberLabel,
checked: true,
tooltip: rememberTooltip
});
case 20:
_yield$$$select = _context.sent;
pref = _yield$$$select.response;
checked = _yield$$$select.checked;
if (!(pref && pref !== 'noPrefsOrContent')) {
_context.next = 30;
break;
}
);
if (pref && pref !== 'noPrefsOrContent') {
// 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
@@ -371,74 +252,47 @@ var svgEditorExtension_storage = (function () {
// 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;
}
if (storagePrompt === 'true' && checked) {
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)
return;
}
} else { // 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) {
emptyStorageOnDecline
) {
emptyStorage();
}
if (!(pref && checked)) {
_context.next = 35;
break;
}
if (pref && checked) {
// Open a URL which won't set storage and won't prompt user about storage
replaceStoragePrompt('false');
return _context.abrupt("return");
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
$('#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) {
} else if (!noStorageOnLoad || forceStorage) {
setupBeforeUnloadListener();
}
case 45:
case "end":
return _context.stop();
}
}
}, _callee);
}))();
}
};
}
};
return extStorage;
}());
};

View File

@@ -1,70 +1,23 @@
var svgEditorExtension_webappfind = (function () {
'use strict';
/**
* Depends on Firefox add-on and executables from
* {@link https://github.com/brettz9/webappfind}.
* @author Brett Zamir
* @license MIT
* @todo See WebAppFind Readme for SVG-related todos
*/
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
* @license MIT
* @todo See WebAppFind Readme for SVG-related todos
*/
var extWebappfind = {
export default {
name: 'webappfind',
init: function init(_ref) {
var _this = this;
async init ({importLocale, $}) {
const strings = await importLocale();
const svgEditor = this;
const saveMessage = 'save',
readMessage = 'read',
excludedMessages = [readMessage, saveMessage];
return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
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();
case 3:
strings = _context.sent;
svgEditor = _this;
saveMessage = 'save', readMessage = 'read', excludedMessages = [readMessage, saveMessage];
_this.canvas.bind('message',
let pathID;
this.canvas.bind(
'message',
/**
* @param {external:Window} win
* @param {PlainObject} info
@@ -74,20 +27,11 @@ var svgEditorExtension_webappfind = (function () {
* @throws {Error} Unexpected event type
* @returns {void}
*/
function (win, _ref2) {
var data = _ref2.data,
origin = _ref2.origin;
// eslint-disable-line no-shadow
(win, {data, origin}) => { // eslint-disable-line no-shadow
// console.log('data, origin', data, origin);
var type, content;
let type, 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
({type, pathID, content} = data.webappfind); // 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)
) {
@@ -101,20 +45,20 @@ var svgEditorExtension_webappfind = (function () {
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, "!"));
$.alert(`save complete for pathID ${pathID}!`);
break;
default:
throw new Error('Unexpected WebAppFind event type');
}
});
}
);
/*
window.postMessage({
webappfind: {
@@ -127,52 +71,39 @@ var svgEditorExtension_webappfind = (function () {
: window.location.origin
);
*/
buttons = [{
id: 'webappfind_save',
//
const 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)")
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
click () {
if (!pathID) { // Not ready yet as haven't received first payload
return;
}
window.postMessage({
window.postMessage(
{
webappfind: {
type: saveMessage,
pathID: pathID,
pathID,
content: svgEditor.canvas.getSvgString()
}
}, window.location.origin === 'null' // Avoid "null" string error for `file:` protocol (even
}, window.location.origin === 'null'
// Avoid "null" string error for `file:` protocol (even
// though file protocol not currently supported by add-on)
? '*' : window.location.origin);
? '*'
: window.location.origin
);
}
}
}];
return _context.abrupt("return", {
return {
name: strings.name,
svgicons: svgEditor.curConfig.extIconsPath + 'webappfind-icon.svg',
buttons: strings.buttons.map(function (button, i) {
buttons: strings.buttons.map((button, i) => {
return Object.assign(buttons[i], button);
})
});
case 9:
case "end":
return _context.stop();
}
}
}, _callee);
}))();
}
};
return extWebappfind;
}());
}
};

View File

@@ -1,114 +1,48 @@
var svgEditorExtension_xdomain_messaging = (function () {
'use strict';
function _typeof(obj) {
"@babel/helpers - typeof";
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
_typeof = function (obj) {
return typeof obj;
};
} else {
_typeof = function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
}
return _typeof(obj);
}
function _toConsumableArray(arr) {
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
}
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
}
function _iterableToArray(iter) {
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
}
function _unsupportedIterableToArray(o, minLen) {
if (!o) return;
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
var n = Object.prototype.toString.call(o).slice(8, -1);
if (n === "Object" && o.constructor) n = o.constructor.name;
if (n === "Map" || n === "Set") return Array.from(o);
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
return arr2;
}
function _nonIterableSpread() {
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
/**
* Should not be needed for same domain control (just call via child frame),
* but an API common for cross-domain and same domain use can be found
* in embedapi.js with a demo at embedapi.html.
*/
var extXdomainMessaging = {
/**
* Should not be needed for same domain control (just call via child frame),
* but an API common for cross-domain and same domain use can be found
* in embedapi.js with a demo at embedapi.html.
*/
export default {
name: 'xdomain-messaging',
init: function init() {
var svgEditor = this;
var svgCanvas = svgEditor.canvas;
init () {
const svgEditor = this;
const svgCanvas = svgEditor.canvas;
try {
window.addEventListener('message', function (e) {
// We accept and post strings for the sake of IE9 support
if (!e.data || !['string', 'object'].includes(_typeof(e.data)) || e.data.charAt() === '|') {
if (!e.data || !['string', 'object'].includes(typeof e.data) || e.data.charAt() === '|') {
return;
}
var data = _typeof(e.data) === 'object' ? e.data : JSON.parse(e.data);
if (!data || _typeof(data) !== 'object' || data.namespace !== 'svgCanvas') {
const data = typeof e.data === 'object' ? e.data : JSON.parse(e.data);
if (!data || typeof data !== 'object' || data.namespace !== 'svgCanvas') {
return;
} // The default is not to allow any origins, including even the same domain or
}
// The default is not to allow any origins, including even the same domain or
// if run on a `file:///` URL. See `svgedit-config-es.js` for an example of how
// to configure
var allowedOrigins = svgEditor.curConfig.allowedOrigins;
const {allowedOrigins} = svgEditor.curConfig;
if (!allowedOrigins.includes('*') && !allowedOrigins.includes(e.origin)) {
console.log("Origin ".concat(e.origin, " not whitelisted for posting to ").concat(window.origin)); // eslint-disable-line no-console
console.log(`Origin ${e.origin} not whitelisted for posting to ${window.origin}`); // eslint-disable-line no-console
return;
}
var cbid = data.id;
var name = data.name,
args = data.args;
var message = {
const cbid = data.id;
const {name, args} = data;
const message = {
namespace: 'svg-edit',
id: cbid
};
try {
// Now that we know the origin is trusted, we perform otherwise
// unsafe arbitrary canvas method execution
message.result = svgCanvas[name].apply(svgCanvas, _toConsumableArray(args)); // lgtm [js/remote-property-injection]
message.result = svgCanvas[name](...args); // lgtm [js/remote-property-injection]
} catch (err) {
message.error = err.message;
}
e.source.postMessage(JSON.stringify(message), '*');
});
} catch (err) {
console.log('Error with xdomain message listener: ' + err); // eslint-disable-line no-console
}
}
};
return extXdomainMessaging;
}());
};

34
dist/extensions/eyedropper-icon.xml vendored Normal file
View File

@@ -0,0 +1,34 @@
<svg xmlns="http://www.w3.org/2000/svg">
<g id="tool_eyedropper">
<svg viewBox="0 0 320 320" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Created with SVG-edit - https://github.com/SVG-Edit/svgedit -->
<defs>
<radialGradient id="eyedropper_svg_6" cx="0.5" cy="0.5" r="0.5">
<stop offset="0" stop-color="#ffffff" stop-opacity="1"/>
<stop offset="1" stop-color="#e5e5e5" stop-opacity="0.38"/>
</radialGradient>
<linearGradient id="eyedropper_svg_15" x1="0" y1="0" x2="0.58594" y2="0.55078">
<stop offset="0" stop-color="#ffffff" stop-opacity="0.57"/>
<stop offset="1" stop-color="#000056" stop-opacity="1"/>
</linearGradient>
<linearGradient id="eyedropper_svg_19" x1="0" y1="0" x2="1" y2="1">
<stop offset="0" stop-color="#ffffff" stop-opacity="1"/>
<stop offset="1" stop-color="#ffffff" stop-opacity="0"/>
</linearGradient>
</defs>
<g display="inline">
<title>Layer 1</title>
<path d="m193.899994,73l-119.899979,118l-15,39.5l10.25,4.5l43.750015,-20l108.999969,-112l-28.100006,-30z" id="svg_3" fill="none" stroke="#000000" stroke-width="5"/>
<path d="m58.649994,232c-2.75,28.200012 -26.399994,28.950012 -21.899994,59c4.5,30.049988 55,28 55.5,-1.25c0.5,-29.25 -20.25,-28.75 -22.25,-54.75l-11.350006,-3z" id="svg_4" fill="#aa56ff" stroke="#000000" stroke-width="7"/>
<path d="m45.474976,269.275024l13.775024,0.474976l-0.75,16.75l-14.25,-1.25l1.224976,-15.974976z" id="svg_5" fill="url(#eyedropper_svg_6)" stroke-width="5" fill-opacity="0.73"/>
<path d="m217.899994,46c21.5,-101.549999 141.600006,20.449997 28.100006,33l-5,44l-63,-66l39.899994,-11z" id="svg_2" fill="#000000" stroke-width="5"/>
<path d="m206.825012,61.075008c3.712494,-2.46249 7.637482,-3.53751 14.424988,-5.575008c10.125,-16.5 32.875,-41.5 40.5,-35c7.625,6.5 -21.25,35.625 -37.5,39.25c-5.5,10.125 -8,13.875 -17.25,16.5c-2.837494,-8.162514 -4.262482,-12.337486 -0.174988,-15.174992z" id="svg_7" fill="url(#eyedropper_svg_15)" stroke-width="5"/>
<path d="m133.049988,134.75l46.950012,9.25l-66,70l-42.5,20.5l-11.5,-5l14,-37.5l59.049988,-57.25z" id="svg_11" fill="#aa56ff" stroke="#000000" stroke-width="7"/>
<path d="m71.425034,212.350006l9.050888,-20.022537l51.516724,-49.327469l8.507355,0.97197l-69.074966,68.378036z" id="svg_16" fill="url(#eyedropper_svg_19)" stroke-width="5"/>
</g>
</svg>
</g>
<g id="svg_eof"/>
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
dist/extensions/eyedropper.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 568 B

BIN
dist/extensions/foreignobject-edit.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 62 KiB

96
dist/extensions/foreignobject-icons.xml vendored Normal file
View File

@@ -0,0 +1,96 @@
<svg xmlns="http://www.w3.org/2000/svg">
<g id="tool_foreign">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 84 84">
<g fill="#444" opacity="0.2" transform="translate(6,6)">
<path d="M42.8,74.3c0,4.3,0,5.9,11.8,5.9l4.1,0l0,3.8c-4.5-0.4-16.1-0.4-21.2-0.3c-5.1,0-16.6,0-21,0.4l0-3.8l4.1,0
c11.8,0,11.8-1.7,11.8-5.9l0-6.9C13.9,65.6,0,54.6,0,42c0-12.2,13.3-23.5,32.4-25.4l0-6.9c0-4.3,0-5.9-11.8-5.9l-4.1,0l0-3.8
c4.5,0.4,16.1,0.4,21.2,0.3c5.1,0,16.6,0,21-0.4l0,3.8l-4.1,0c-11.8,0-11.8,1.7-11.8,5.9l0,6.9C61.6,18.1,75.8,29.2,75.8,42
c0,12.4-13.8,23.9-33.1,25.4L42.8,74.3z M32.4,19.4c-18.7,2.5-19.9,16.2-19.9,22.6c0,7.6,2.3,20.2,20,22.5L32.4,19.4z M42.7,64.7
c18.8-2.2,20.7-15.4,20.6-22.8c0-9.3-3.5-20.6-20.7-22.6L42.7,64.7z"/>
</g>
<g fill="#444" opacity="0.3" transform="translate(4,4)">
<path d="M42.8,74.3c0,4.3,0,5.9,11.8,5.9l4.1,0l0,3.8c-4.5-0.4-16.1-0.4-21.2-0.3c-5.1,0-16.6,0-21,0.4l0-3.8l4.1,0
c11.8,0,11.8-1.7,11.8-5.9l0-6.9C13.9,65.6,0,54.6,0,42c0-12.2,13.3-23.5,32.4-25.4l0-6.9c0-4.3,0-5.9-11.8-5.9l-4.1,0l0-3.8
c4.5,0.4,16.1,0.4,21.2,0.3c5.1,0,16.6,0,21-0.4l0,3.8l-4.1,0c-11.8,0-11.8,1.7-11.8,5.9l0,6.9C61.6,18.1,75.8,29.2,75.8,42
c0,12.4-13.8,23.9-33.1,25.4L42.8,74.3z M32.4,19.4c-18.7,2.5-19.9,16.2-19.9,22.6c0,7.6,2.3,20.2,20,22.5L32.4,19.4z M42.7,64.7
c18.8-2.2,20.7-15.4,20.6-22.8c0-9.3-3.5-20.6-20.7-22.6L42.7,64.7z"/>
</g>
<g fill="#444" opacity="0.5" transform="translate(2,2)">
<path d="M42.8,74.3c0,4.3,0,5.9,11.8,5.9l4.1,0l0,3.8c-4.5-0.4-16.1-0.4-21.2-0.3c-5.1,0-16.6,0-21,0.4l0-3.8l4.1,0
c11.8,0,11.8-1.7,11.8-5.9l0-6.9C13.9,65.6,0,54.6,0,42c0-12.2,13.3-23.5,32.4-25.4l0-6.9c0-4.3,0-5.9-11.8-5.9l-4.1,0l0-3.8
c4.5,0.4,16.1,0.4,21.2,0.3c5.1,0,16.6,0,21-0.4l0,3.8l-4.1,0c-11.8,0-11.8,1.7-11.8,5.9l0,6.9C61.6,18.1,75.8,29.2,75.8,42
c0,12.4-13.8,23.9-33.1,25.4L42.8,74.3z M32.4,19.4c-18.7,2.5-19.9,16.2-19.9,22.6c0,7.6,2.3,20.2,20,22.5L32.4,19.4z M42.7,64.7
c18.8-2.2,20.7-15.4,20.6-22.8c0-9.3-3.5-20.6-20.7-22.6L42.7,64.7z"/>
</g>
<g fill="#0000CC">
<path id="xyz321" d="M42.8,74.3c0,4.3,0,5.9,11.8,5.9l4.1,0l0,3.8c-4.5-0.4-16.1-0.4-21.2-0.3c-5.1,0-16.6,0-21,0.4l0-3.8l4.1,0
c11.8,0,11.8-1.7,11.8-5.9l0-6.9C13.9,65.6,0,54.6,0,42c0-12.2,13.3-23.5,32.4-25.4l0-6.9c0-4.3,0-5.9-11.8-5.9l-4.1,0l0-3.8
c4.5,0.4,16.1,0.4,21.2,0.3c5.1,0,16.6,0,21-0.4l0,3.8l-4.1,0c-11.8,0-11.8,1.7-11.8,5.9l0,6.9C61.6,18.1,75.8,29.2,75.8,42
c0,12.4-13.8,23.9-33.1,25.4L42.8,74.3z M32.4,19.4c-18.7,2.5-19.9,16.2-19.9,22.6c0,7.6,2.3,20.2,20,22.5L32.4,19.4z M42.7,64.7
c18.8-2.2,20.7-15.4,20.6-22.8c0-9.3-3.5-20.6-20.7-22.6L42.7,64.7z"/>
</g>
</svg>
</g>
<g id="edit_foreign">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="34 38 170 170" overflow="hidden">
<g fill="#000088">
<path d="M30.1,63.9v-4.3l30.2-14.9V50L36.5,61.7l23.8,11.7v5.3L30.1,63.9z"/>
<path d="M106.1,79.7v-1.1c4.2-0.5,4.8-1.1,4.8-5.2V58.2c0-6-1.3-7.9-5.4-7.9c-3.3,0-5.7,1.3-7.8,4.4v18.1
c0,4.5,1.1,5.7,5.2,5.8v1.1H86.8v-1.1c4.1-0.3,4.9-1.1,4.9-5.1V57.9c0-5-1.6-7.6-4.8-7.6c-2.5,0-5.6,1.2-7.4,2.9
c-0.5,0.5-1.1,1.4-1.1,1.4v20.3c0,2.8,1.1,3.6,4.9,3.7v1.1h-16v-1.1c4-0.1,5-1.2,5-5V55.4c0-3.5-0.6-4.6-2.5-4.6
c-0.8,0-1.4,0.1-2.3,0.3v-1.2c4-1.1,6.4-1.9,10.1-3.2l0.5,0.1v5.4c6-4.5,8-5.5,11.2-5.5c3.9,0,6.3,1.9,7.6,6c3.9-4.2,7.6-6,11.7-6
c5.5,0,8.4,4.3,8.4,12.8v14.8c0,2.8,0.9,4.1,3.1,4.2l1.9,0.1v1.1H106.1z"/>
<path d="M147.3,80.5c-3,0-4.2-1.4-4.6-5.3c-4.4,3.7-7.3,5.3-10.5,5.3c-4.5,0-7.6-3.2-7.6-7.7c0-2.4,1-4.8,2.6-6.3
c3.1-2.7,4.3-3.3,15.4-7.8v-4.4c0-3.9-1.9-6-5.5-6c-2.9,0-5.2,1.6-5.2,3.5c0,0.5,0.1,1.1,0.2,1.7c0.1,0.5,0.1,0.9,0.1,1.2
c0,1.6-1.5,3-3.2,3s-3.1-1.4-3.1-3.1c0-1.8,1.2-3.9,3-5.4c2-1.7,5.5-2.7,9.1-2.7c4.4,0,7.5,1.4,9,4.2c1,1.7,1.4,3.7,1.4,7.3v14
c0,3.2,0.5,4.2,2.2,4.2c1.1,0,1.9-0.4,3.2-1.4v1.9C151.3,79.6,149.8,80.5,147.3,80.5z M142.6,60.5c-8.7,3.2-11.7,5.8-11.7,10v0.3
c0,3.1,2,5.5,4.5,5.5c1.5,0,3.5-0.6,5.3-1.6c1.5-0.9,1.9-1.6,1.9-3.8V60.5z"/>
<path d="M165.3,80.5c-4.2,0-6.3-3.1-6.3-9.1V49.7h-3.8c-0.2-0.1-0.3-0.3-0.3-0.5c0-0.4,0.4-0.9,1.2-1.4
c1.9-1.1,4.3-3.7,7-7.7c0.5-0.6,1-1.3,1.4-2c0.4,0,0.5,0.2,0.5,0.9v8.4h7.3v2.3h-7.3v20.6c0,4.6,1.1,6.5,3.7,6.5
c1.6,0,2.7-0.6,4.3-2.5l0.9,0.8C171.8,78.7,169,80.5,165.3,80.5z"/>
<path d="M193.8,79.7v-1.1c4.1-0.4,4.9-1.3,4.9-6.2V58.1c0-5-1.8-7.6-5.4-7.6c-2.8,0-5,1.2-8,4.5v17.4
c0,5,0.7,5.8,4.9,6.3v1.1h-15.6v-1.1c4.2-0.6,4.6-1.2,4.6-6.3V38.5c0-3.1-0.6-3.7-3.7-3.7c-0.4,0-0.6,0-0.9,0.1v-1.2l1.9-0.6
c4-1.2,5.8-1.7,8.3-2.6l0.4,0.2v21.9c3.3-4.3,6.3-6,10.6-6c5.9,0,8.9,3.9,8.9,11.5v14.3c0,5,0.4,5.5,4.3,6.3v1.1h-15.2V79.7z"/>
<path d="M59.1,116.1v-4.3l30.2-14.9v5.3l-23.8,11.7l23.8,11.7v5.3L59.1,116.1z"/>
<path d="M135.1,131.9v-1.1c4.2-0.5,4.8-1.1,4.8-5.2v-15.1c0-6-1.3-7.9-5.4-7.9c-3.3,0-5.7,1.3-7.8,4.4v18.1
c0,4.5,1.1,5.7,5.2,5.8v1.1h-16.1v-1.1c4.1-0.3,4.9-1.1,4.9-5.1v-15.7c0-5-1.6-7.6-4.8-7.6c-2.5,0-5.6,1.2-7.4,2.9
c-0.5,0.5-1.1,1.4-1.1,1.4v20.3c0,2.8,1.1,3.6,4.9,3.7v1.1h-16v-1.1c4-0.1,5-1.2,5-5v-18.2c0-3.5-0.6-4.6-2.5-4.6
c-0.8,0-1.4,0.1-2.3,0.3v-1.2c4-1.1,6.4-1.9,10.1-3.2l0.5,0.1v5.4c6-4.5,8-5.5,11.2-5.5c3.9,0,6.3,1.9,7.6,6c3.9-4.2,7.6-6,11.7-6
c5.5,0,8.4,4.3,8.4,12.8v14.8c0,2.8,0.9,4.1,3.1,4.2l1.9,0.1v1.1H135.1z"/>
<path d="M152.1,131.9v-1.1c5-0.3,5.7-1.1,5.7-6.3v-16.6c0-3.2-0.6-4.3-2.4-4.3c-0.6,0-1.6,0.1-2.4,0.2l-0.6,0.1v-1.1
l11.2-4L164,99v25.6c0,5.2,0.6,5.9,5.3,6.3v1.1L152.1,131.9L152.1,131.9z M160.8,93.1c-2,0-3.7-1.6-3.7-3.7c0-2,1.7-3.7,3.7-3.7
c2.1,0,3.7,1.7,3.7,3.7C164.6,91.6,163,93.1,160.8,93.1z"/>
<path d="M175.8,131v-5.3l23.7-11.8l-23.7-11.7v-5.3l30.1,14.9v4.3L175.8,131z"/>
<path d="M31.1,169.5v-4.3l30.2-14.9v5.3l-23.8,11.7L61.3,179v5.3L31.1,169.5z"/>
<path d="M71.3,186.4h-4.9l16.5-49.7h4.8L71.3,186.4z"/>
<path d="M127.1,185.3v-1.1c4.2-0.5,4.8-1.1,4.8-5.2v-15.2c0-6-1.3-7.9-5.4-7.9c-3.3,0-5.7,1.3-7.8,4.4v18.1
c0,4.5,1.1,5.7,5.2,5.8v1.1h-16.1v-1.1c4.1-0.3,4.9-1.1,4.9-5.1v-15.6c0-5-1.6-7.6-4.8-7.6c-2.5,0-5.6,1.2-7.4,2.9
c-0.5,0.5-1.1,1.4-1.1,1.4v20.3c0,2.8,1.1,3.6,4.9,3.7v1.1h-16v-1.1c4-0.1,5-1.2,5-5V161c0-3.5-0.6-4.6-2.5-4.6
c-0.8,0-1.4,0.1-2.3,0.3v-1.2c4-1.1,6.4-1.9,10.1-3.2l0.5,0.1v5.4c6-4.5,8-5.5,11.2-5.5c3.9,0,6.3,1.9,7.6,6c3.9-4.2,7.6-6,11.7-6
c5.5,0,8.4,4.3,8.4,12.8v14.8c0,2.8,0.9,4.1,3.1,4.2l1.9,0.1v1.1H127.1L127.1,185.3z"/>
<path d="M168.3,186.1c-3,0-4.2-1.4-4.6-5.3c-4.4,3.7-7.3,5.3-10.5,5.3c-4.5,0-7.6-3.2-7.6-7.7c0-2.4,1-4.8,2.6-6.3
c3.1-2.7,4.3-3.3,15.4-7.8v-4.4c0-3.9-1.9-6-5.5-6c-2.9,0-5.2,1.6-5.2,3.5c0,0.5,0.1,1.1,0.2,1.7c0.1,0.5,0.1,0.9,0.1,1.2
c0,1.6-1.5,3-3.2,3s-3.1-1.4-3.1-3.1c0-1.8,1.2-3.9,3-5.4c2-1.7,5.5-2.7,9.1-2.7c4.4,0,7.5,1.4,9,4.2c1,1.7,1.4,3.7,1.4,7.3v14
c0,3.2,0.5,4.2,2.2,4.2c1.1,0,1.9-0.4,3.2-1.4v1.9C172.3,185.2,170.8,186.1,168.3,186.1z M163.8,166.1c-8.7,3.2-11.7,5.8-11.7,10
v0.3c0,3.1,2,5.5,4.5,5.5c1.5,0,3.5-0.6,5.3-1.6c1.5-0.9,1.9-1.6,1.9-3.8V166.1z"/>
<path d="M186.3,186.1c-4.2,0-6.3-3.1-6.3-9.1v-21.7h-3.8c-0.2-0.1-0.3-0.3-0.3-0.5c0-0.4,0.4-0.9,1.2-1.4
c1.9-1.1,4.3-3.7,7-7.7c0.5-0.6,1-1.3,1.4-2c0.4,0,0.5,0.2,0.5,0.9v8.4h7.3v2.3h-7.3v20.6c0,4.6,1.1,6.5,3.7,6.5
c1.6,0,2.7-0.6,4.3-2.5l0.9,0.8C192.8,184.3,190,186.1,186.3,186.1z"/>
<path d="M209.1,185.3h-13.4v-1.1c4.2-0.6,4.6-1.2,4.6-6.3V144c0-3.1-0.6-3.7-3.7-3.7c-0.4,0-0.6,0-0.9,0.1v-1.2
l1.9-0.6c4-1.2,5.8-1.7,8.3-2.6l0.4,0.2v21.9c0.9-1.2,1.9-2.2,2.8-3.1"/>
<path d="M209.1,157.9c-0.8,0.7-1.7,1.5-2.7,2.6v17.4c0,4,0.4,5.3,2.7,5.9"/>
</g>
<g>
<polyline opacity="0.2" fill="#231F20" points="209.1,76.4 118.7,186.5 139.1,186.4 209.1,121 209.1,76.4 "/>
<polyline opacity="0.4" fill="#231F20" points="209.1,76.2 118.5,186.5 129.7,186.4 200.2,120.3 209.1,100.8 209.1,76.4 "/>
<path fill="#FFD761" d="M121.6,88.7l0.8,87.5l62.3-56.7c0,0-15.3-25.8-24.8-30C151.1,85.6,121.6,88.7,121.6,88.7z"/>
<path fill="#FEA01E" d="M209.1,19.5h-54l-33.5,69.2c0,0,29.7-3.4,38.3,0.8c8.9,4.4,25,30.8,25,30.8l24.2-50V19.5z"/>
<path d="M120.4,153.7l-0.6,25l23.8-16.9c0,0-8-7-11.2-8.1C129.4,152.8,120.4,153.7,120.4,153.7z"/>
<polyline fill="none" stroke="#231F20" stroke-width="5" points="153.9,19.5 121.6,88.7 120.7,181.2 186.6,120.3 209.1,70.3 "/>
</g>
</svg>
</g>
<g id="svg_eof"/>
</svg>

After

Width:  |  Height:  |  Size: 8.4 KiB

BIN
dist/extensions/foreignobject-tool.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

30
dist/extensions/grid-icon.xml vendored Normal file
View File

@@ -0,0 +1,30 @@
<svg xmlns="http://www.w3.org/2000/svg">
<!--
Sample icons file. This file looks like an SVG file with groups as its
children. Each group element has an ID that must match the ID of the button given
in the extension. The SVG inside the group makes up the actual icon, and
needs use a viewBox instead of width/height for it to scale properly.
Multiple icons can be included, each within their own group.
-->
<g id="view_grid">
<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<g>
<rect fill="#ffffff" stroke="#848484" x="2" y="2" width="20" height="20"/>
<line fill="none" stroke="#848484" x1="11.84375" y1="-1.53125" x2="11.84375" y2="18.46875" transform="rotate(90, 11.8429, 8.46955)"/>
<line fill="none" stroke="#848484" x1="11.90625" y1="5.21875" x2="11.90625" y2="25.21875" transform="rotate(90, 11.9054, 15.2196)"/>
<line fill="none" stroke="#848484" x1="8.5" y1="2.03125" x2="8.5" y2="22.03125"/>
<line fill="none" stroke="#848484" x1="15.5" y1="2.03125" x2="15.5" y2="22.03125"/>
<rect fill="#d8d8d8" stroke="#000000" stroke-width="0" x="3.25" y="3.28125" width="4" height="4"/>
<rect fill="#d8d8d8" stroke="#000000" stroke-width="0" x="10" y="3.28125" width="4" height="4"/>
<rect fill="#d8d8d8" stroke="#000000" stroke-width="0" x="16.75" y="3.28125" width="4" height="4"/>
<rect fill="#d8d8d8" stroke="#000000" stroke-width="0" x="3.28125" y="9.75" width="4" height="4"/>
<rect fill="#d8d8d8" stroke="#000000" stroke-width="0" x="10.03125" y="9.75" width="4" height="4"/>
<rect fill="#d8d8d8" stroke="#000000" stroke-width="0" x="16.78125" y="9.75" width="4" height="4"/>
<rect fill="#d8d8d8" stroke="#000000" stroke-width="0" x="3.3125" y="16.59375" width="4" height="4"/>
<rect fill="#d8d8d8" stroke="#000000" stroke-width="0" x="10.0625" y="16.59375" width="4" height="4"/>
<rect fill="#d8d8d8" stroke="#000000" stroke-width="0" x="16.8125" y="16.59375" width="4" height="4"/>
</g>
</svg>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
dist/extensions/grid.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

21
dist/extensions/helloworld-icon.xml vendored Normal file
View File

@@ -0,0 +1,21 @@
<svg xmlns="http://www.w3.org/2000/svg">
<!--
Sample icons file. This file looks like an SVG file with groups as its
children. Each group element has an ID that must match the ID of the button given
in the extension. The SVG inside the group makes up the actual icon, and
needs use a viewBox instead of width/height for it to scale properly.
Multiple icons can be included, each within their own group.
-->
<g id="hello_world">
<svg width="102" height="102" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Created with SVG-edit - https://github.com/SVG-Edit/svgedit -->
<g>
<title>Layer 1</title>
<rect ry="30" rx="30" x="2.5" y="2.5" width="97" height="97" id="svg_3" fill="#008000" stroke="#000000" stroke-width="5"/>
<text x="52.668" y="42.5" id="svg_1" fill="#ffffff" stroke="#000000" stroke-width="0" font-size="24" font-family="Monospace" text-anchor="middle" xml:space="preserve">Hello</text>
<text x="52.668" y="71.5" fill="#ffffff" stroke="#000000" stroke-width="0" font-size="24" font-family="Monospace" text-anchor="middle" xml:space="preserve" id="svg_2">World!</text>
</g>
</svg>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
dist/extensions/helloworld.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
dist/extensions/imagelib.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

29
dist/extensions/imagelib/index-es.html vendored Normal file
View File

@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>-</title>
<link rel="icon" type="image/png" href="../../images/logo.png" />
<!-- Lacking browser support -->
<script nomodule="" src="../../redirect-on-no-module-support.js"></script>
<script type="module" src="../../redirect-on-lacking-support.js"></script>
<!-- As yet no ES6 -->
<script src="../../jquery.min.js"></script>
<!-- ES6+ polyfills (Babel) -->
<script src="../../external/core-js-bundle/minified.js"></script>
<script src="../../external/regenerator-runtime/runtime.js"></script>
<script type="module" src="index.js"></script>
</head>
<body>
<h1>Select an image:</h1>
<a href="smiley.svg">smiley.svg</a>
<br/>
<a href="../../images/logo.png">logo.png</a>
</body>
</html>

30
dist/extensions/imagelib/index.html vendored Normal file
View File

@@ -0,0 +1,30 @@
<!DOCTYPE html>
<!-- AUTO-GENERATED FROM imagelib/index-es.html; DO NOT EDIT; use build/build-html.js to build -->
<html>
<head>
<meta charset="utf-8" />
<title>-</title>
<link rel="icon" type="image/png" href="../../images/logo.png" />
<!-- Lacking browser support -->
<script nomodule="" src="../../redirect-on-no-module-support.js"></script>
<script type="module" src="../../redirect-on-lacking-support.js"></script>
<!-- As yet no ES6 -->
<script src="../../jquery.min.js"></script>
<!-- ES6+ polyfills (Babel) -->
<script src="../../external/core-js-bundle/minified.js"></script>
<script src="../../external/regenerator-runtime/runtime.js"></script>
<script defer="defer" src="../../../../dist/extensions/imagelib/index.js"></script>
</head>
<body>
<h1>Select an image:</h1>
<a href="smiley.svg">smiley.svg</a>
<br/>
<a href="../../images/logo.png">logo.png</a>
</body>
</html>

View File

@@ -1,84 +1,49 @@
(function () {
'use strict';
function _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
/* globals jQuery */
var $ = jQuery;
$('a').click(function () {
var href = this.href;
var target = window.parent;
var post = function post(message) {
/* globals jQuery */
const $ = jQuery;
$('a').click(function () {
const {href} = this;
const target = window.parent;
const post = (message) => {
// Todo: Make origin customizable as set by opening window
// Todo: If dropping IE9, avoid stringifying
target.postMessage(JSON.stringify(_extends({
namespace: 'imagelib'
}, message)), '*');
}; // Convert Non-SVG images to data URL first
target.postMessage(JSON.stringify({
namespace: 'imagelib',
...message
}), '*');
};
// Convert Non-SVG images to data URL first
// (this could also have been done server-side by the library)
// Send metadata (also indicates file is about to be sent)
post({
name: $(this).text(),
id: href
});
if (!href.includes('.svg')) {
var img = new Image();
const img = new Image();
img.addEventListener('load', function () {
var canvas = document.createElement('canvas');
const canvas = document.createElement('canvas');
canvas.width = this.width;
canvas.height = this.height; // load the raster image into the canvas
canvas.getContext('2d').drawImage(this, 0, 0); // retrieve the data: URL
var data;
canvas.height = this.height;
// load the raster image into the canvas
canvas.getContext('2d').drawImage(this, 0, 0);
// retrieve the data: URL
let data;
try {
data = canvas.toDataURL();
} catch (err) {
// This fails in Firefox with `file:///` URLs :(
// Todo: This could use a generic alert library instead
alert('Data URL conversion failed: ' + err); // eslint-disable-line no-alert
data = '';
}
post({
href: href,
data: data
});
post({href, data});
});
img.src = href;
} else {
// Do ajax request for image's href value
$.get(href, function (data) {
post({
href: href,
data: data
});
post({href, data});
}, 'html'); // 'html' is necessary to keep returned data as a string
}
return false;
});
}());
});

View File

@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8" />
<title>-</title>
<link rel="icon" type="image/png" href="../../images/logo.png" />
<!-- Lacking browser support -->
<script nomodule="" src="../../redirect-on-no-module-support.js"></script>
<script type="module" src="../../redirect-on-lacking-support.js"></script>
<!-- Browser polyfills -->
<script src="../../external/dom-polyfill/dom-polyfill.js"></script>
<!-- ES6+ polyfills (Babel) -->
<script src="../../external/core-js-bundle/minified.js"></script>
<script src="../../external/regenerator-runtime/runtime.js"></script>
<script type="module" src="openclipart.js"></script>
</head>
<body>
</body>
</html>

View File

@@ -0,0 +1,25 @@
<!DOCTYPE html>
<!-- AUTO-GENERATED FROM imagelib/openclipart-es.html; DO NOT EDIT; use build/build-html.js to build -->
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8" />
<title>-</title>
<link rel="icon" type="image/png" href="../../images/logo.png" />
<!-- Lacking browser support -->
<script nomodule="" src="../../redirect-on-no-module-support.js"></script>
<script type="module" src="../../redirect-on-lacking-support.js"></script>
<!-- Browser polyfills -->
<script src="../../../../dist/dom-polyfill.js"></script>
<!-- ES6+ polyfills (Babel) -->
<script src="../../external/core-js-bundle/minified.js"></script>
<script src="../../external/regenerator-runtime/runtime.js"></script>
<script defer="defer" src="../../../../dist/extensions/imagelib/openclipart.js"></script>
</head>
<body>
</body>
</html>

File diff suppressed because it is too large Load Diff

12
dist/extensions/imagelib/smiley.svg vendored Normal file
View File

@@ -0,0 +1,12 @@
<svg width="137" height="137" xmlns="http://www.w3.org/2000/svg">
<title>Cool smiley</title>
<path fill="url(#svg_4)" stroke="#000000" stroke-width="3" d="m32.18682,97.71674q36.3159,24.94076 72.54585,0m-64.67542,-49.25576c0,-3.8554 3.12526,-6.98079 6.98068,-6.98079c3.85449,0 6.97872,3.12539 6.97872,6.98079c0,3.85346 -3.12423,6.97867 -6.97872,6.97867c-3.85542,0 -6.98068,-3.12521 -6.98068,-6.97867m42.93047,0c0,-3.8554 3.12529,-6.98079 6.97963,-6.98079c3.8544,0 6.97971,3.12539 6.97971,6.98079c0,3.85346 -3.12531,6.97867 -6.97971,6.97867c-3.85434,0 -6.97963,-3.12521 -6.97963,-6.97867m-81.48596,20.036l0,0c0,-37.00197 29.99679,-66.99892 67.00095,-66.99892c37.00303,0 66.99998,29.99695 66.99998,66.99892c0,37.00409 -29.99695,67.00101 -66.99998,67.00101c-37.00416,0 -67.00095,-29.99692 -67.00095,-67.00101zm0,0l0,0c0,-37.00197 29.99679,-66.99892 67.00095,-66.99892c37.00303,0 66.99998,29.99695 66.99998,66.99892c0,37.00409 -29.99695,67.00101 -66.99998,67.00101c-37.00416,0 -67.00095,-29.99692 -67.00095,-67.00101z" id="svg_1"/>
<path id="svg_5" d="m23.84005,41.03445l17.57052,0l5.42937,-19.67914l5.42941,19.67914l17.5706,0l-14.21488,12.16242l5.42982,19.67939l-14.21495,-12.16281l-14.21489,12.16281l5.42991,-19.67939l-14.21491,-12.16242l0,0z" stroke-width="3" fill="#000000"/>
<path id="svg_6" d="m65.84005,41.03445l17.57052,0l5.42937,-19.67914l5.42941,19.67914l17.5706,0l-14.21487,12.16242l5.42982,19.67939l-14.21496,-12.1628l-14.2149,12.1628l5.42992,-19.67939l-14.21491,-12.16242l0,0z" stroke-width="3" fill="#000000"/>
<defs>
<linearGradient y2="0.25391" x2="0.46484" y1="0.94922" x1="0.44531" id="svg_4">
<stop stop-color="#ff0000" offset="0"/>
<stop stop-color="#ffff00" offset="1"/>
</linearGradient>
</defs>
</svg>

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
dist/extensions/markers-box.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.3 KiB

BIN
dist/extensions/markers-box_o.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
dist/extensions/markers-forwardslash.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

115
dist/extensions/markers-icons.xml vendored Normal file
View File

@@ -0,0 +1,115 @@
<svg xmlns="http://www.w3.org/2000/svg">
<!-- Created with SVG-edit - https://github.com/SVG-Edit/svgedit -->
<g id="nomarker">
<svg viewBox="-60 -60 120 120" xmlns="http://www.w3.org/2000/svg">
<path stroke-width="10" stroke="#ff7f00" fill="#ff7f00" d="m-50,0l100,0"/>
</svg>
</g>
<g id="leftarrow">
<svg viewBox="-60 -60 120 120" xmlns="http://www.w3.org/2000/svg">
<path stroke-width="10" stroke="#ff7f00" fill="#ff7f00" d="m-50,0l100,40l-30,-40l30,-40z"/>
</svg>
</g>
<g id="rightarrow">
<svg viewBox="-60 -60 120 120" xmlns="http://www.w3.org/2000/svg">
<path stroke-width="10" stroke="#ff7f00" fill="#ff7f00" d="m50,0l-100,40l30,-40l-30,-40z"/>
</svg>
</g>
<g id="leftarrow_o">
<svg viewBox="-60 -60 120 120" xmlns="http://www.w3.org/2000/svg">
<path stroke-width="10" stroke="#ff7f00" fill="none" d="m-50,0l100,40l-30,-40l30,-40z"/>
</svg>
</g>
<g id="rightarrow_o">
<svg viewBox="-60 -60 120 120" xmlns="http://www.w3.org/2000/svg">
<path stroke-width="10" stroke="#ff7f00" fill="none" d="m50,0l-100,40l30,-40l-30,-40z"/>
</svg>
</g>
<g id="forwardslash">
<svg viewBox="-60 -60 120 120" xmlns="http://www.w3.org/2000/svg">
<path stroke-width="10" stroke="#ff7f00" fill="none" d="m-20,50l40,-100"/>
</svg>
</g>
<g id="reverseslash">
<svg viewBox="-60 -60 120 120" xmlns="http://www.w3.org/2000/svg">
<path stroke-width="10" stroke="#ff7f00" fill="none" d="m-20,-50l40,100"/>
</svg>
</g>
<g id="verticalslash">
<svg viewBox="-60 -60 120 120" xmlns="http://www.w3.org/2000/svg">
<path stroke-width="10" stroke="#ff7f00" fill="none" d="m0,-50l0,100"/>
</svg>
</g>
<g id="mcircle">
<svg viewBox="-60 -60 120 120" xmlns="http://www.w3.org/2000/svg">
<circle stroke-width="10" stroke="#ff7f00" fill="#ff7f00" cy="0" cx="0" r="30"/>
</svg>
</g>
<g id="mcircle_o">
<svg viewBox="-60 -60 120 120" xmlns="http://www.w3.org/2000/svg">
<circle stroke-width="10" stroke="#ff7f00" fill="none" cy="0" cx="0" r="30"/>
</svg>
</g>
<g id="xmark">
<svg viewBox="-60 -60 120 120" xmlns="http://www.w3.org/2000/svg">
<path stroke-width="10" stroke="#ff7f00" fill="#ff7f00" d="m-30,30l60,-60m0,60l-60,-60"/>
</svg>
</g>
<g id="box">
<svg viewBox="-60 -60 120 120" xmlns="http://www.w3.org/2000/svg">
<path stroke-width="10" stroke="#ff7f00" fill="#ff7f00" d="m-30,-30l0,60l60,0l0,-60z"/>
</svg>
</g>
<g id="star">
<svg viewBox="-60 -60 120 120" xmlns="http://www.w3.org/2000/svg">
<path stroke-width="10" stroke="#ff7f00" fill="#ff7f00" d="m-40,-20l80,0l-70,60l30,-80l30,80z"/>
</svg>
</g>
<g id="box_o">
<svg viewBox="-60 -60 120 120" xmlns="http://www.w3.org/2000/svg">
<path stroke-width="10" stroke="#ff7f00" fill="none" d="m-30,-30l0,60l60,0l0,-60z"/>
</svg>
</g>
<g id="star_o">
<svg viewBox="-60 -60 120 120" xmlns="http://www.w3.org/2000/svg">
<path stroke-width="10" stroke="#ff7f00" fill="none" d="m-40,-20l80,0l-70,60l30,-80l30,80z"/>
</svg>
</g>
<g id="triangle_o">
<svg viewBox="-60 -60 120 120" xmlns="http://www.w3.org/2000/svg">
<path stroke-width="10" stroke="#ff7f00" fill="none" d="M-30,30 L0,-30 L30,30 Z"/>
</svg>
</g>
<g id="triangle">
<svg viewBox="-60 -60 120 120" xmlns="http://www.w3.org/2000/svg">
<path stroke-width="10" stroke="#ff7f00" fill="#ff7f00" d="M-30,30 L0,-30 L30,30 Z"/>
</svg>
</g>
<g id="textmarker">
<svg viewBox="-60 -60 120 120" xmlns="http://www.w3.org/2000/svg">
<text xml:space="preserve" text-anchor="middle" font-family="serif" font-size="120" y="40" x="0" stroke-width="0" stroke="#ff7f00" fill="#ff7f00">T</text>
</svg>
</g>
<g id="mkr_markers_off">
<svg viewBox="-60 -60 120 120" xmlns="http://www.w3.org/2000/svg">
<line y2="0" x2="50" y1="0" x1="-50" stroke-width="5" stroke="#ff7f00" fill="none"/>
</svg>
</g>
<g id="mkr_markers_dimension">
<svg viewBox="-60 -60 120 120" xmlns="http://www.w3.org/2000/svg">
<line y2="0" x2="40" y1="0" x1="20" stroke-width="5" stroke="#ff7f00" fill="none"/>
<line y2="0" x2="-40" y1="0" x1="-20" stroke-width="5" stroke="#ff7f00" fill="none"/>
<text text-anchor="middle" font-family="serif" font-size="80" y="20" x="0" stroke-width="0" stroke="#ff7f00" fill="#ff7f00">T</text>
<path stroke-width="5" stroke="#ff7f00" fill="#ff7f00" d="M-50,0 L-30,-15 L-30,15 Z"/>
<path stroke-width="5" stroke="#ff7f00" fill="#ff7f00" d="M50,0 L30,-15 L30,15 Z"/>
</svg>
</g>
<g id="mkr_markers_label">
<svg viewBox="-60 -60 120 120" xmlns="http://www.w3.org/2000/svg">
<line y2="0" x2="40" y1="0" x1="-20" stroke-width="5" stroke="#ff7f00" fill="none"/>
<text text-anchor="middle" font-family="serif" font-size="80" y="20" x="-40" stroke-width="0" stroke="#ff7f00" fill="#ff7f00">T</text>
<path stroke-width="5" stroke="#ff7f00" fill="#ff7f00" d="M50,0 L30,-15 L30,15 Z"/>
</svg>
</g>
<g id="svg_eof"/>
</svg>

After

Width:  |  Height:  |  Size: 5.3 KiB

BIN
dist/extensions/markers-leftarrow.png vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Some files were not shown because too many files have changed in this diff Show More