- Breaking change: loadSvgString now returns a Promise rather than accepting a callback
- Breaking change: Treat callbacks to `editor.ready` as Promises, only resolving after all resolve - Breaking change: Make `editor.runCallbacks` return a `Promise` which resolves upon all callbacks resolving - Breaking change: Require `npx` (used with `babel-node`) to allow Node files for HTML building and JSDoc type checking to be expressed as ESM. - Breaking change: `addExtension` now throws upon a repeated attempt to add an already-added extension - Breaking change (storage preference cookies): Namespace the cookie as "svgeditstore" instead of just "store" - Breaking change (API): Remove `svgCanvas.rasterExport` fourth (callback) argument, collapsing fifth (options) to fourth - Breaking change (API): Remove `svgCanvas.exportPDF` third (callback) argument - Breaking change (API): `editor/contextmenu.js` `add` now throws instead of giving a console error only upon detecting a bad menuitem or preexisting context menu - Breaking change (API): Remove `svgCanvas.embedImage` second (callback) argument - Breaking change (API): Make `getHelpXML` a class instead of instance method of `RGBColor` - Breaking change (internal API): Refactor `dbox` (and `alert`/`confirm`/`process`/`prompt`/`select`) to avoid a callback argument in favor of return a Promise - Fix: Avoid running in extension `langReady` multiple times or serially - Enhancement (API): Add svgCanvas.runExtension to run just one extension and add `nameFilter` callback to `runExtensions` - Enhancement (API): Supply `$` (our wrapped jQuery) to extensions so can use its plugins, e.g., dbox with its `alert` - Enhancement: Use alert dialog in place of `alert` in webappfind - Enhancement: `editor.ready` now returns a Promise resolving when all callbacks have resolved - Enhancement: Allow `noAlert` option as part of second argument to `loadSvgString` (and `loadFromURL` and `loadFromDataURI`) to avoid UI alert (and trigger promise rejection) - Enhancement: Make `dbox` as a separate module for alert, prompt, etc. dialogs - Refactoring: Internal `PaintBox` as class; other misc. tweaks; no bitwise in canvg - Linting (ESLint): Further linting changes (for editor); rename `.eslintrc` -> `.eslintrc.json` per recommendation - Optimization: Recompress images (imageoptim-cli updated) - npm: Update devDeps - npm: Bump to 4.0.0
This commit is contained in:
59
dist/extensions/ext-arrows.js
vendored
59
dist/extensions/ext-arrows.js
vendored
@@ -37,8 +37,6 @@ var svgEditorExtension_arrows = (function () {
|
||||
};
|
||||
}
|
||||
|
||||
/* globals jQuery */
|
||||
|
||||
/**
|
||||
* ext-arrows.js
|
||||
*
|
||||
@@ -53,12 +51,12 @@ var svgEditorExtension_arrows = (function () {
|
||||
var _init = _asyncToGenerator(
|
||||
/*#__PURE__*/
|
||||
regeneratorRuntime.mark(function _callee2(S) {
|
||||
var strings, svgEditor, svgCanvas, $, addElem, nonce, prefix, selElems, arrowprefix, randomizeIds, setArrowNonce, unsetArrowNonce, pathdata, getLinked, showPanel, resetMarker, addMarker, setArrow, colorChanged, contextTools;
|
||||
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 _ref9(elem) {
|
||||
colorChanged = function _ref10(elem) {
|
||||
var color = elem.getAttribute('stroke');
|
||||
var mtypes = ['start', 'mid', 'end'];
|
||||
var defs = svgCanvas.findDefs();
|
||||
@@ -84,7 +82,7 @@ var svgEditorExtension_arrows = (function () {
|
||||
|
||||
if (attrs.fill === color && attrs.d === curD) {
|
||||
// Found another marker with this color and this path
|
||||
newMarker = this;
|
||||
newMarker = this; // eslint-disable-line consistent-this
|
||||
}
|
||||
});
|
||||
|
||||
@@ -100,17 +98,22 @@ var svgEditorExtension_arrows = (function () {
|
||||
|
||||
var remove = true;
|
||||
$(S.svgcontent).find('line, polyline, path, polygon').each(function () {
|
||||
var elem = this;
|
||||
var element = this; // eslint-disable-line consistent-this
|
||||
|
||||
$.each(mtypes, function (j, mtype) {
|
||||
if ($(elem).attr('marker-' + mtype) === 'url(#' + marker.id + ')') {
|
||||
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) {
|
||||
@@ -119,7 +122,7 @@ var svgEditorExtension_arrows = (function () {
|
||||
});
|
||||
};
|
||||
|
||||
setArrow = function _ref8() {
|
||||
setArrow = function _ref9() {
|
||||
resetMarker();
|
||||
var type = this.value;
|
||||
|
||||
@@ -147,7 +150,7 @@ var svgEditorExtension_arrows = (function () {
|
||||
svgCanvas.call('changed', selElems);
|
||||
};
|
||||
|
||||
addMarker = function _ref7(dir, type, id) {
|
||||
addMarker = function _ref8(dir, type, id) {
|
||||
// TODO: Make marker (or use?) per arrow type, since refX can be different
|
||||
id = id || arrowprefix + dir;
|
||||
var data = pathdata[dir];
|
||||
@@ -188,14 +191,14 @@ var svgEditorExtension_arrows = (function () {
|
||||
return marker;
|
||||
};
|
||||
|
||||
resetMarker = function _ref6() {
|
||||
resetMarker = function _ref7() {
|
||||
var el = selElems[0];
|
||||
el.removeAttribute('marker-start');
|
||||
el.removeAttribute('marker-mid');
|
||||
el.removeAttribute('marker-end');
|
||||
};
|
||||
|
||||
showPanel = function _ref5(on) {
|
||||
showPanel = function _ref6(on) {
|
||||
$('#arrow_panel').toggle(on);
|
||||
|
||||
if (on) {
|
||||
@@ -227,7 +230,7 @@ var svgEditorExtension_arrows = (function () {
|
||||
}
|
||||
};
|
||||
|
||||
getLinked = function _ref4(elem, attr) {
|
||||
getLinked = function _ref5(elem, attr) {
|
||||
var str = elem.getAttribute(attr);
|
||||
|
||||
if (!str) {
|
||||
@@ -243,14 +246,14 @@ var svgEditorExtension_arrows = (function () {
|
||||
return svgCanvas.getElem(m[1]);
|
||||
};
|
||||
|
||||
unsetArrowNonce = function _ref3(window) {
|
||||
unsetArrowNonce = function _ref4(win) {
|
||||
randomizeIds = false;
|
||||
arrowprefix = prefix;
|
||||
pathdata.fw.id = arrowprefix + 'fw';
|
||||
pathdata.bk.id = arrowprefix + 'bk';
|
||||
};
|
||||
|
||||
setArrowNonce = function _ref2(window, n) {
|
||||
setArrowNonce = function _ref3(win, n) {
|
||||
randomizeIds = true;
|
||||
arrowprefix = prefix + n + '_';
|
||||
pathdata.fw.id = arrowprefix + 'fw';
|
||||
@@ -264,10 +267,15 @@ var svgEditorExtension_arrows = (function () {
|
||||
strings = _context2.sent;
|
||||
svgEditor = this;
|
||||
svgCanvas = svgEditor.canvas;
|
||||
$ = jQuery;
|
||||
// {svgcontent} = S,
|
||||
addElem = svgCanvas.addSVGElementFromJson, nonce = S.nonce, prefix = 'se_arrow_';
|
||||
addElem = svgCanvas.addSVGElementFromJson, nonce = S.nonce, $ = S.$, prefix = 'se_arrow_';
|
||||
randomizeIds = S.randomize_ids;
|
||||
/**
|
||||
* @param {Window} win
|
||||
* @param {!(string|Integer)} n
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
svgCanvas.bind('setnonce', setArrowNonce);
|
||||
svgCanvas.bind('unsetnonce', unsetArrowNonce);
|
||||
|
||||
@@ -289,6 +297,13 @@ var svgEditorExtension_arrows = (function () {
|
||||
id: arrowprefix + 'bk'
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Gets linked element.
|
||||
* @param {Element} elem
|
||||
* @param {string} attr
|
||||
* @returns {Element}
|
||||
*/
|
||||
|
||||
contextTools = [{
|
||||
type: 'select',
|
||||
panel: 'arrow_panel',
|
||||
@@ -312,7 +327,8 @@ var svgEditorExtension_arrows = (function () {
|
||||
var _addLangData = _asyncToGenerator(
|
||||
/*#__PURE__*/
|
||||
regeneratorRuntime.mark(function _callee(_ref) {
|
||||
var lang, importLocale, strings;
|
||||
var lang, importLocale, _ref2, langList;
|
||||
|
||||
return regeneratorRuntime.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
@@ -322,12 +338,13 @@ var svgEditorExtension_arrows = (function () {
|
||||
return importLocale();
|
||||
|
||||
case 3:
|
||||
strings = _context.sent;
|
||||
_ref2 = _context.sent;
|
||||
langList = _ref2.langList;
|
||||
return _context.abrupt("return", {
|
||||
data: strings.langList
|
||||
data: langList
|
||||
});
|
||||
|
||||
case 5:
|
||||
case 6:
|
||||
case "end":
|
||||
return _context.stop();
|
||||
}
|
||||
@@ -372,7 +389,7 @@ var svgEditorExtension_arrows = (function () {
|
||||
}
|
||||
});
|
||||
|
||||
case 22:
|
||||
case 21:
|
||||
case "end":
|
||||
return _context2.stop();
|
||||
}
|
||||
|
||||
9
dist/extensions/ext-closepath.js
vendored
9
dist/extensions/ext-closepath.js
vendored
@@ -37,8 +37,6 @@ var svgEditorExtension_closepath = (function () {
|
||||
};
|
||||
}
|
||||
|
||||
/* globals jQuery */
|
||||
|
||||
/**
|
||||
* ext-closepath.js
|
||||
*
|
||||
@@ -55,18 +53,17 @@ var svgEditorExtension_closepath = (function () {
|
||||
var _init = _asyncToGenerator(
|
||||
/*#__PURE__*/
|
||||
regeneratorRuntime.mark(function _callee(_ref) {
|
||||
var importLocale, strings, $, svgEditor, selElems, updateButton, showPanel, toggleClosed, buttons;
|
||||
var importLocale, $, strings, svgEditor, selElems, updateButton, showPanel, toggleClosed, buttons;
|
||||
return regeneratorRuntime.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
case 0:
|
||||
importLocale = _ref.importLocale;
|
||||
importLocale = _ref.importLocale, $ = _ref.$;
|
||||
_context.next = 3;
|
||||
return importLocale();
|
||||
|
||||
case 3:
|
||||
strings = _context.sent;
|
||||
$ = jQuery;
|
||||
svgEditor = this;
|
||||
|
||||
updateButton = function updateButton(path) {
|
||||
@@ -157,7 +154,7 @@ var svgEditorExtension_closepath = (function () {
|
||||
}
|
||||
});
|
||||
|
||||
case 11:
|
||||
case 10:
|
||||
case "end":
|
||||
return _context.stop();
|
||||
}
|
||||
|
||||
106
dist/extensions/ext-connector.js
vendored
106
dist/extensions/ext-connector.js
vendored
@@ -37,8 +37,6 @@ var svgEditorExtension_connector = (function () {
|
||||
};
|
||||
}
|
||||
|
||||
/* globals jQuery */
|
||||
|
||||
/**
|
||||
* ext-connector.js
|
||||
*
|
||||
@@ -52,11 +50,11 @@ var svgEditorExtension_connector = (function () {
|
||||
init: function () {
|
||||
var _init = _asyncToGenerator(
|
||||
/*#__PURE__*/
|
||||
regeneratorRuntime.mark(function _callee2(S) {
|
||||
var $, svgEditor, svgCanvas, getElem, svgroot, importLocale, addElem, selManager, connSel, elData, strings, startX, startY, curLine, startElem, endElem, seNs, svgcontent, started, connections, selElems, getBBintersect, getOffset, showPanel, setPoint, updateLine, findConnectors, updateConnectors, init, buttons;
|
||||
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
||||
regeneratorRuntime.mark(function _callee(S) {
|
||||
var svgEditor, svgCanvas, getElem, $, svgroot, importLocale, addElem, selManager, connSel, elData, strings, startX, startY, curLine, startElem, endElem, seNs, svgcontent, started, connections, selElems, getBBintersect, getOffset, showPanel, setPoint, updateLine, findConnectors, updateConnectors, init, buttons;
|
||||
return regeneratorRuntime.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
switch (_context2.prev = _context2.next) {
|
||||
switch (_context.prev = _context.next) {
|
||||
case 0:
|
||||
init = function _ref9() {
|
||||
// Make sure all connectors have data set
|
||||
@@ -133,6 +131,10 @@ var svgEditorExtension_connector = (function () {
|
||||
|
||||
connectors.each(function () {
|
||||
var addThis;
|
||||
/**
|
||||
*
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
function add() {
|
||||
if (elems.includes(this)) {
|
||||
@@ -147,14 +149,15 @@ var svgEditorExtension_connector = (function () {
|
||||
var key = 'c_' + pos;
|
||||
var part = elData(this, key);
|
||||
|
||||
if (part == null) {
|
||||
if (part === null || part === undefined) {
|
||||
// Does this ever return nullish values?
|
||||
part = document.getElementById(this.attributes['se:connector'].value.split(' ')[i]);
|
||||
elData(this, 'c_' + pos, part.id);
|
||||
elData(this, pos + '_bb', svgCanvas.getStrokedBBox([part]));
|
||||
} else part = document.getElementById(part);
|
||||
|
||||
parts.push(part);
|
||||
}.bind(this));
|
||||
}, this);
|
||||
|
||||
for (var i = 0; i < 2; i++) {
|
||||
var cElem = parts[i];
|
||||
@@ -257,7 +260,7 @@ var svgEditorExtension_connector = (function () {
|
||||
};
|
||||
|
||||
getOffset = function _ref3(side, line) {
|
||||
var giveOffset = !!line.getAttribute('marker-' + side); // const giveOffset = $(line).data(side+'_off');
|
||||
var giveOffset = line.getAttribute('marker-' + side); // const giveOffset = $(line).data(side+'_off');
|
||||
// TODO: Make this number (5) be based on marker width/height
|
||||
|
||||
var size = line.getAttribute('stroke-width') * 5;
|
||||
@@ -293,17 +296,24 @@ var svgEditorExtension_connector = (function () {
|
||||
};
|
||||
};
|
||||
|
||||
$ = jQuery;
|
||||
svgEditor = this;
|
||||
svgCanvas = svgEditor.canvas;
|
||||
getElem = svgCanvas.getElem;
|
||||
svgroot = S.svgroot, importLocale = S.importLocale, addElem = svgCanvas.addSVGElementFromJson, selManager = S.selectorManager, connSel = '.se_connector', elData = $.data;
|
||||
_context2.next = 15;
|
||||
$ = S.$, svgroot = S.svgroot, importLocale = S.importLocale, addElem = svgCanvas.addSVGElementFromJson, selManager = S.selectorManager, connSel = '.se_connector', elData = $.data;
|
||||
_context.next = 14;
|
||||
return importLocale();
|
||||
|
||||
case 15:
|
||||
strings = _context2.sent;
|
||||
case 14:
|
||||
strings = _context.sent;
|
||||
svgcontent = S.svgcontent, started = false, connections = [], selElems = [];
|
||||
/**
|
||||
*
|
||||
* @param {Float} x
|
||||
* @param {Float} y
|
||||
* @param {module:utilities.BBoxObject} bb
|
||||
* @param {Float} offset
|
||||
* @returns {module:math.XYObject}
|
||||
*/
|
||||
|
||||
// Do once
|
||||
(function () {
|
||||
@@ -311,19 +321,32 @@ var svgEditorExtension_connector = (function () {
|
||||
|
||||
svgCanvas.groupSelectedElements = function () {
|
||||
svgCanvas.removeFromSelection($(connSel).toArray());
|
||||
return gse.apply(this, arguments);
|
||||
|
||||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
return gse.apply(this, args);
|
||||
};
|
||||
|
||||
var mse = svgCanvas.moveSelectedElements;
|
||||
|
||||
svgCanvas.moveSelectedElements = function () {
|
||||
var cmd = mse.apply(this, arguments);
|
||||
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
||||
args[_key2] = arguments[_key2];
|
||||
}
|
||||
|
||||
var cmd = mse.apply(this, args);
|
||||
updateConnectors();
|
||||
return cmd;
|
||||
};
|
||||
|
||||
seNs = svgCanvas.getEditorNS();
|
||||
})(); // Do on reset
|
||||
})();
|
||||
/**
|
||||
* Do on reset.
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
|
||||
// $(svgroot).parent().mousemove(function (e) {
|
||||
@@ -351,38 +374,21 @@ var svgEditorExtension_connector = (function () {
|
||||
}
|
||||
}
|
||||
}];
|
||||
return _context2.abrupt("return", {
|
||||
return _context.abrupt("return", {
|
||||
name: strings.name,
|
||||
svgicons: svgEditor.curConfig.imgPath + 'conn.svg',
|
||||
buttons: strings.buttons.map(function (button, i) {
|
||||
return Object.assign(buttons[i], button);
|
||||
}),
|
||||
addLangData: function () {
|
||||
var _addLangData = _asyncToGenerator(
|
||||
/*#__PURE__*/
|
||||
regeneratorRuntime.mark(function _callee(_ref) {
|
||||
var lang, importLocale;
|
||||
return regeneratorRuntime.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
case 0:
|
||||
lang = _ref.lang, importLocale = _ref.importLocale;
|
||||
return _context.abrupt("return", {
|
||||
data: strings.langList
|
||||
});
|
||||
|
||||
case 2:
|
||||
case "end":
|
||||
return _context.stop();
|
||||
}
|
||||
}
|
||||
}, _callee, this);
|
||||
}));
|
||||
|
||||
return function addLangData(_x2) {
|
||||
return _addLangData.apply(this, arguments);
|
||||
/* async */
|
||||
addLangData: function addLangData(_ref) {
|
||||
var lang = _ref.lang;
|
||||
// , importLocale: importLoc
|
||||
return {
|
||||
data: strings.langList
|
||||
};
|
||||
}(),
|
||||
},
|
||||
mouseDown: function mouseDown(opts) {
|
||||
var e = opts.event;
|
||||
startX = opts.start_x;
|
||||
@@ -392,7 +398,7 @@ var svgEditorExtension_connector = (function () {
|
||||
|
||||
if (mode === 'connector') {
|
||||
if (started) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var mouseTarget = e.target;
|
||||
@@ -431,6 +437,8 @@ var svgEditorExtension_connector = (function () {
|
||||
if (mode === 'select') {
|
||||
findConnectors();
|
||||
}
|
||||
|
||||
return undefined;
|
||||
},
|
||||
mouseMove: function mouseMove(opts) {
|
||||
var zoom = svgCanvas.getZoom(); // const e = opts.event;
|
||||
@@ -476,7 +484,7 @@ var svgEditorExtension_connector = (function () {
|
||||
var mouseTarget = e.target;
|
||||
|
||||
if (svgCanvas.getMode() !== 'connector') {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var fo = $(mouseTarget).closest('foreignObject');
|
||||
@@ -521,6 +529,8 @@ var svgEditorExtension_connector = (function () {
|
||||
if (conn === connStr || conn === altStr) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
if (dupe.length) {
|
||||
@@ -598,7 +608,7 @@ var svgEditorExtension_connector = (function () {
|
||||
var mid = elem.getAttribute('marker-mid');
|
||||
var end = elem.getAttribute('marker-end');
|
||||
curLine = elem;
|
||||
$(elem).data('start_off', !!start).data('end_off', !!end);
|
||||
$(elem).data('start_off', Boolean(start)).data('end_off', Boolean(end));
|
||||
|
||||
if (elem.tagName === 'line' && mid) {
|
||||
// Convert to polyline to accept mid-arrow
|
||||
@@ -666,12 +676,12 @@ var svgEditorExtension_connector = (function () {
|
||||
}
|
||||
});
|
||||
|
||||
case 20:
|
||||
case 19:
|
||||
case "end":
|
||||
return _context2.stop();
|
||||
return _context.stop();
|
||||
}
|
||||
}
|
||||
}, _callee2, this);
|
||||
}, _callee, this);
|
||||
}));
|
||||
|
||||
return function init(_x) {
|
||||
|
||||
13
dist/extensions/ext-eyedropper.js
vendored
13
dist/extensions/ext-eyedropper.js
vendored
@@ -37,8 +37,6 @@ var svgEditorExtension_eyedropper = (function () {
|
||||
};
|
||||
}
|
||||
|
||||
/* globals jQuery */
|
||||
|
||||
/**
|
||||
* ext-eyedropper.js
|
||||
*
|
||||
@@ -94,8 +92,7 @@ var svgEditorExtension_eyedropper = (function () {
|
||||
case 3:
|
||||
strings = _context.sent;
|
||||
svgEditor = this;
|
||||
$ = jQuery;
|
||||
ChangeElementCommand = S.ChangeElementCommand, svgCanvas = svgEditor.canvas, addToHistory = function addToHistory(cmd) {
|
||||
$ = S.$, ChangeElementCommand = S.ChangeElementCommand, svgCanvas = svgEditor.canvas, addToHistory = function addToHistory(cmd) {
|
||||
svgCanvas.undoMgr.addCommandToHistory(cmd);
|
||||
}, currentStyle = {
|
||||
fillPaint: 'red',
|
||||
@@ -108,6 +105,12 @@ var svgEditorExtension_eyedropper = (function () {
|
||||
strokeLinecap: 'butt',
|
||||
strokeLinejoin: 'miter'
|
||||
};
|
||||
/**
|
||||
*
|
||||
* @param {module:svgcanvas.SvgCanvas#event:ext-selectedChanged|module:svgcanvas.SvgCanvas#event:ext-elementChanged} opts
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
buttons = [{
|
||||
id: 'tool_eyedropper',
|
||||
icon: svgEditor.curConfig.extIconsPath + 'eyedropper.png',
|
||||
@@ -184,7 +187,7 @@ var svgEditorExtension_eyedropper = (function () {
|
||||
}
|
||||
});
|
||||
|
||||
case 9:
|
||||
case 8:
|
||||
case "end":
|
||||
return _context.stop();
|
||||
}
|
||||
|
||||
194
dist/extensions/ext-foreignobject.js
vendored
194
dist/extensions/ext-foreignobject.js
vendored
@@ -37,8 +37,6 @@ var svgEditorExtension_foreignobject = (function () {
|
||||
};
|
||||
}
|
||||
|
||||
/* globals jQuery */
|
||||
|
||||
/**
|
||||
* ext-foreignobject.js
|
||||
*
|
||||
@@ -52,18 +50,18 @@ var svgEditorExtension_foreignobject = (function () {
|
||||
init: function () {
|
||||
var _init = _asyncToGenerator(
|
||||
/*#__PURE__*/
|
||||
regeneratorRuntime.mark(function _callee(S) {
|
||||
var svgEditor, text2xml, NS, importLocale, $, svgCanvas, svgdoc, strings, properlySourceSizeTextArea, showPanel, toggleSourceButtons, selElems, started, newFO, editingforeign, setForeignString, showForeignEditor, setAttr, buttons, contextTools;
|
||||
return regeneratorRuntime.wrap(function _callee$(_context) {
|
||||
regeneratorRuntime.mark(function _callee2(S) {
|
||||
var svgEditor, $, text2xml, NS, importLocale, svgCanvas, svgdoc, strings, properlySourceSizeTextArea, showPanel, toggleSourceButtons, selElems, started, newFO, editingforeign, setForeignString, showForeignEditor, setAttr, buttons, contextTools;
|
||||
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
switch (_context2.prev = _context2.next) {
|
||||
case 0:
|
||||
setAttr = function _ref5(attr, val) {
|
||||
setAttr = function _ref6(attr, val) {
|
||||
svgCanvas.changeSelectedAttribute(attr, val);
|
||||
svgCanvas.call('changed', selElems);
|
||||
};
|
||||
|
||||
showForeignEditor = function _ref4() {
|
||||
showForeignEditor = function _ref5() {
|
||||
var elt = selElems[0];
|
||||
|
||||
if (!elt || editingforeign) {
|
||||
@@ -80,8 +78,8 @@ var svgEditorExtension_foreignobject = (function () {
|
||||
$('#svg_source_textarea').focus();
|
||||
};
|
||||
|
||||
setForeignString = function _ref3(xmlString) {
|
||||
var elt = selElems[0];
|
||||
setForeignString = function _ref4(xmlString) {
|
||||
var elt = selElems[0]; // The parent `Element` to append to
|
||||
|
||||
try {
|
||||
// convert string into XML document
|
||||
@@ -92,19 +90,21 @@ var svgEditorExtension_foreignobject = (function () {
|
||||
svgCanvas.call('changed', [elt]);
|
||||
svgCanvas.clearSelection();
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
// Todo: Surface error to user
|
||||
console.log(e); // eslint-disable-line no-console
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
toggleSourceButtons = function _ref2(on) {
|
||||
toggleSourceButtons = function _ref3(on) {
|
||||
$('#tool_source_save, #tool_source_cancel').toggle(!on);
|
||||
$('#foreign_save, #foreign_cancel').toggle(on);
|
||||
};
|
||||
|
||||
showPanel = function _ref(on) {
|
||||
showPanel = function _ref2(on) {
|
||||
var fcRules = $('#fc_rules');
|
||||
|
||||
if (!fcRules.length) {
|
||||
@@ -116,27 +116,30 @@ var svgEditorExtension_foreignobject = (function () {
|
||||
};
|
||||
|
||||
svgEditor = this;
|
||||
text2xml = S.text2xml, NS = S.NS, importLocale = S.importLocale;
|
||||
$ = jQuery;
|
||||
$ = S.$, text2xml = S.text2xml, NS = S.NS, importLocale = S.importLocale;
|
||||
svgCanvas = svgEditor.canvas;
|
||||
svgdoc = S.svgroot.parentNode.ownerDocument;
|
||||
_context.next = 12;
|
||||
_context2.next = 11;
|
||||
return importLocale();
|
||||
|
||||
case 12:
|
||||
strings = _context.sent;
|
||||
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 {undefined}
|
||||
*/
|
||||
|
||||
|
||||
editingforeign = false;
|
||||
/**
|
||||
* This function sets the content of element elt to the input XML.
|
||||
* @param {string} xmlString - The XML text
|
||||
* @param {Element} elt - the parent element to append to
|
||||
* @returns {boolean} This function returns false if the set was unsuccessful, true otherwise.
|
||||
*/
|
||||
|
||||
@@ -191,7 +194,7 @@ var svgEditorExtension_foreignobject = (function () {
|
||||
}
|
||||
}
|
||||
}];
|
||||
return _context.abrupt("return", {
|
||||
return _context2.abrupt("return", {
|
||||
name: strings.name,
|
||||
svgicons: svgEditor.curConfig.extIconsPath + 'foreignobject-icons.xml',
|
||||
buttons: strings.buttons.map(function (button, i) {
|
||||
@@ -215,24 +218,57 @@ var svgEditorExtension_foreignobject = (function () {
|
||||
// Create source save/cancel buttons
|
||||
|
||||
/* const save = */
|
||||
$('#tool_source_save').clone().hide().attr('id', 'foreign_save').unbind().appendTo('#tool_source_back').click(function () {
|
||||
if (!editingforeign) {
|
||||
return;
|
||||
}
|
||||
$('#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;
|
||||
}
|
||||
|
||||
if (!setForeignString($('#svg_source_textarea').val())) {
|
||||
$.confirm('Errors found. Revert to original?', function (ok) {
|
||||
if (!ok) {
|
||||
return false;
|
||||
return _context.abrupt("return");
|
||||
|
||||
case 2:
|
||||
if (setForeignString($('#svg_source_textarea').val())) {
|
||||
_context.next = 11;
|
||||
break;
|
||||
}
|
||||
|
||||
_context.next = 5;
|
||||
return $.confirm('Errors found. Revert to original?');
|
||||
|
||||
case 5:
|
||||
ok = _context.sent;
|
||||
|
||||
if (ok) {
|
||||
_context.next = 8;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt("return");
|
||||
|
||||
case 8:
|
||||
endChanges();
|
||||
_context.next = 12;
|
||||
break;
|
||||
|
||||
case 11:
|
||||
endChanges();
|
||||
|
||||
case 12:
|
||||
case "end":
|
||||
return _context.stop();
|
||||
}
|
||||
|
||||
endChanges();
|
||||
});
|
||||
} else {
|
||||
endChanges();
|
||||
} // setSelectMode();
|
||||
|
||||
});
|
||||
}
|
||||
}, _callee, this);
|
||||
})));
|
||||
/* const cancel = */
|
||||
|
||||
$('#tool_source_cancel').clone().hide().attr('id', 'foreign_cancel').unbind().appendTo('#tool_source_back').click(function () {
|
||||
@@ -242,49 +278,53 @@ var svgEditorExtension_foreignobject = (function () {
|
||||
},
|
||||
mouseDown: function mouseDown(opts) {
|
||||
// const e = opts.event;
|
||||
if (svgCanvas.getMode() === 'foreign') {
|
||||
started = true;
|
||||
newFO = svgCanvas.addSVGElementFromJson({
|
||||
element: 'foreignObject',
|
||||
attr: {
|
||||
x: opts.start_x,
|
||||
y: opts.start_y,
|
||||
id: svgCanvas.getNextId(),
|
||||
'font-size': 16,
|
||||
// cur_text.font_size,
|
||||
width: '48',
|
||||
height: '20',
|
||||
style: 'pointer-events:inherit'
|
||||
}
|
||||
});
|
||||
var m = svgdoc.createElementNS(NS.MATH, 'math');
|
||||
m.setAttributeNS(NS.XMLNS, 'xmlns', NS.MATH);
|
||||
m.setAttribute('display', 'inline');
|
||||
var mi = svgdoc.createElementNS(NS.MATH, 'mi');
|
||||
mi.setAttribute('mathvariant', 'normal');
|
||||
mi.textContent = "\u03A6";
|
||||
var mo = svgdoc.createElementNS(NS.MATH, 'mo');
|
||||
mo.textContent = "\u222A";
|
||||
var mi2 = svgdoc.createElementNS(NS.MATH, 'mi');
|
||||
mi2.textContent = "\u2133";
|
||||
m.append(mi, mo, mi2);
|
||||
newFO.append(m);
|
||||
return {
|
||||
started: true
|
||||
};
|
||||
if (svgCanvas.getMode() !== 'foreign') {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
started = true;
|
||||
newFO = svgCanvas.addSVGElementFromJson({
|
||||
element: 'foreignObject',
|
||||
attr: {
|
||||
x: opts.start_x,
|
||||
y: opts.start_y,
|
||||
id: svgCanvas.getNextId(),
|
||||
'font-size': 16,
|
||||
// cur_text.font_size,
|
||||
width: '48',
|
||||
height: '20',
|
||||
style: 'pointer-events:inherit'
|
||||
}
|
||||
});
|
||||
var m = svgdoc.createElementNS(NS.MATH, 'math');
|
||||
m.setAttributeNS(NS.XMLNS, 'xmlns', NS.MATH);
|
||||
m.setAttribute('display', 'inline');
|
||||
var mi = svgdoc.createElementNS(NS.MATH, 'mi');
|
||||
mi.setAttribute('mathvariant', 'normal');
|
||||
mi.textContent = "\u03A6";
|
||||
var mo = svgdoc.createElementNS(NS.MATH, 'mo');
|
||||
mo.textContent = "\u222A";
|
||||
var mi2 = svgdoc.createElementNS(NS.MATH, 'mi');
|
||||
mi2.textContent = "\u2133";
|
||||
m.append(mi, mo, mi2);
|
||||
newFO.append(m);
|
||||
return {
|
||||
started: true
|
||||
};
|
||||
},
|
||||
mouseUp: function mouseUp(opts) {
|
||||
// const e = opts.event;
|
||||
if (svgCanvas.getMode() === 'foreign' && started) {
|
||||
var attrs = $(newFO).attr(['width', 'height']);
|
||||
var keep = attrs.width !== '0' || attrs.height !== '0';
|
||||
svgCanvas.addToSelection([newFO], true);
|
||||
return {
|
||||
keep: keep,
|
||||
element: newFO
|
||||
};
|
||||
if (svgCanvas.getMode() !== 'foreign' || !started) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var attrs = $(newFO).attr(['width', 'height']);
|
||||
var keep = attrs.width !== '0' || attrs.height !== '0';
|
||||
svgCanvas.addToSelection([newFO], true);
|
||||
return {
|
||||
keep: keep,
|
||||
element: newFO
|
||||
};
|
||||
},
|
||||
selectedChanged: function selectedChanged(opts) {
|
||||
// Use this to update the current selected elements
|
||||
@@ -311,12 +351,12 @@ var svgEditorExtension_foreignobject = (function () {
|
||||
elementChanged: function elementChanged(opts) {}
|
||||
});
|
||||
|
||||
case 18:
|
||||
case 17:
|
||||
case "end":
|
||||
return _context.stop();
|
||||
return _context2.stop();
|
||||
}
|
||||
}
|
||||
}, _callee, this);
|
||||
}, _callee2, this);
|
||||
}));
|
||||
|
||||
return function init(_x) {
|
||||
|
||||
15
dist/extensions/ext-grid.js
vendored
15
dist/extensions/ext-grid.js
vendored
@@ -37,8 +37,6 @@ var svgEditorExtension_grid = (function () {
|
||||
};
|
||||
}
|
||||
|
||||
/* globals jQuery */
|
||||
|
||||
/**
|
||||
* ext-grid.js
|
||||
*
|
||||
@@ -53,7 +51,7 @@ var svgEditorExtension_grid = (function () {
|
||||
var _init = _asyncToGenerator(
|
||||
/*#__PURE__*/
|
||||
regeneratorRuntime.mark(function _callee(_ref) {
|
||||
var NS, getTypeMap, importLocale, strings, svgEditor, $, svgCanvas, svgdoc, assignAttributes, hcanvas, canvBG, units, intervals, showGrid, canvasGrid, gridPattern, gridimg, gridBox, updateGrid, gridUpdate, buttons;
|
||||
var $, NS, getTypeMap, importLocale, strings, svgEditor, svgCanvas, svgdoc, assignAttributes, hcanvas, canvBG, units, intervals, showGrid, canvasGrid, gridPattern, gridimg, gridBox, updateGrid, gridUpdate, buttons;
|
||||
return regeneratorRuntime.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
@@ -121,14 +119,13 @@ var svgEditorExtension_grid = (function () {
|
||||
svgCanvas.setHref(gridimg, datauri);
|
||||
};
|
||||
|
||||
NS = _ref.NS, getTypeMap = _ref.getTypeMap, importLocale = _ref.importLocale;
|
||||
$ = _ref.$, NS = _ref.NS, getTypeMap = _ref.getTypeMap, importLocale = _ref.importLocale;
|
||||
_context.next = 5;
|
||||
return importLocale();
|
||||
|
||||
case 5:
|
||||
strings = _context.sent;
|
||||
svgEditor = this;
|
||||
$ = jQuery;
|
||||
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;
|
||||
@@ -178,6 +175,12 @@ var svgEditorExtension_grid = (function () {
|
||||
style: 'pointer-events: none; display:visible;'
|
||||
});
|
||||
$('#canvasGrid').append(gridBox);
|
||||
/**
|
||||
*
|
||||
* @param {Float} zoom
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
buttons = [{
|
||||
id: 'view_grid',
|
||||
icon: svgEditor.curConfig.extIconsPath + 'grid.png',
|
||||
@@ -208,7 +211,7 @@ var svgEditorExtension_grid = (function () {
|
||||
})
|
||||
});
|
||||
|
||||
case 26:
|
||||
case 25:
|
||||
case "end":
|
||||
return _context.stop();
|
||||
}
|
||||
|
||||
11
dist/extensions/ext-helloworld.js
vendored
11
dist/extensions/ext-helloworld.js
vendored
@@ -75,8 +75,6 @@ var svgEditorExtension_helloworld = (function () {
|
||||
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
||||
}
|
||||
|
||||
/* globals jQuery */
|
||||
|
||||
/**
|
||||
* ext-helloworld.js
|
||||
*
|
||||
@@ -97,19 +95,18 @@ var svgEditorExtension_helloworld = (function () {
|
||||
var _init = _asyncToGenerator(
|
||||
/*#__PURE__*/
|
||||
regeneratorRuntime.mark(function _callee(_ref) {
|
||||
var importLocale, strings, svgEditor, $, svgCanvas;
|
||||
var $, importLocale, strings, svgEditor, svgCanvas;
|
||||
return regeneratorRuntime.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
case 0:
|
||||
importLocale = _ref.importLocale;
|
||||
$ = _ref.$, importLocale = _ref.importLocale;
|
||||
_context.next = 3;
|
||||
return importLocale();
|
||||
|
||||
case 3:
|
||||
strings = _context.sent;
|
||||
svgEditor = this;
|
||||
$ = jQuery;
|
||||
svgCanvas = svgEditor.canvas;
|
||||
return _context.abrupt("return", {
|
||||
name: strings.name,
|
||||
@@ -148,6 +145,8 @@ var svgEditorExtension_helloworld = (function () {
|
||||
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
|
||||
@@ -173,7 +172,7 @@ var svgEditorExtension_helloworld = (function () {
|
||||
}
|
||||
});
|
||||
|
||||
case 8:
|
||||
case 7:
|
||||
case "end":
|
||||
return _context.stop();
|
||||
}
|
||||
|
||||
486
dist/extensions/ext-imagelib.js
vendored
486
dist/extensions/ext-imagelib.js
vendored
@@ -51,8 +51,6 @@ var svgEditorExtension_imagelib = (function () {
|
||||
};
|
||||
}
|
||||
|
||||
/* globals jQuery */
|
||||
|
||||
/**
|
||||
* ext-imagelib.js
|
||||
*
|
||||
@@ -66,13 +64,13 @@ var svgEditorExtension_imagelib = (function () {
|
||||
init: function () {
|
||||
var _init = _asyncToGenerator(
|
||||
/*#__PURE__*/
|
||||
regeneratorRuntime.mark(function _callee(_ref) {
|
||||
var decode64, importLocale, dropXMLInternalSubset, imagelibStrings, modularVersion, svgEditor, $, uiStrings, svgCanvas, extIconsPath, allowedImageLibOrigins, closeBrowser, importImage, pending, mode, multiArr, transferStopped, preview, submit, toggleMulti, showBrowser, buttons;
|
||||
return regeneratorRuntime.wrap(function _callee$(_context) {
|
||||
regeneratorRuntime.mark(function _callee2(_ref) {
|
||||
var $, decode64, importLocale, dropXMLInternalSubset, imagelibStrings, modularVersion, svgEditor, uiStrings, svgCanvas, extIconsPath, allowedImageLibOrigins, closeBrowser, importImage, pending, mode, multiArr, transferStopped, preview, submit, toggleMulti, showBrowser, buttons;
|
||||
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
switch (_context2.prev = _context2.next) {
|
||||
case 0:
|
||||
showBrowser = function _ref9() {
|
||||
showBrowser = function _ref10() {
|
||||
var browser = $('#imgbrowse');
|
||||
|
||||
if (!browser.length) {
|
||||
@@ -128,10 +126,10 @@ var svgEditorExtension_imagelib = (function () {
|
||||
});
|
||||
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;
|
||||
imagelibStrings.imgLibs.forEach(function (_ref6) {
|
||||
var name = _ref6.name,
|
||||
url = _ref6.url,
|
||||
description = _ref6.description;
|
||||
$('<li>').appendTo(libOpts).text(name).on('click touchend', function () {
|
||||
frame.attr('src', url).show();
|
||||
header.text(name);
|
||||
@@ -144,7 +142,7 @@ var svgEditorExtension_imagelib = (function () {
|
||||
}
|
||||
};
|
||||
|
||||
toggleMulti = function _ref8(show) {
|
||||
toggleMulti = function _ref9(show) {
|
||||
$('#lib_framewrap, #imglib_opts').css({
|
||||
right: show ? 200 : 10
|
||||
});
|
||||
@@ -186,7 +184,7 @@ var svgEditorExtension_imagelib = (function () {
|
||||
submit.toggle(show);
|
||||
};
|
||||
|
||||
importImage = function _ref7(url) {
|
||||
importImage = function _ref8(url) {
|
||||
var newImage = svgCanvas.addSVGElementFromJson({
|
||||
element: 'image',
|
||||
attr: {
|
||||
@@ -203,19 +201,18 @@ var svgEditorExtension_imagelib = (function () {
|
||||
svgCanvas.setImageURL(url);
|
||||
};
|
||||
|
||||
closeBrowser = function _ref6() {
|
||||
closeBrowser = function _ref7() {
|
||||
$('#imgbrowse_holder').hide();
|
||||
};
|
||||
|
||||
decode64 = _ref.decode64, importLocale = _ref.importLocale, dropXMLInternalSubset = _ref.dropXMLInternalSubset;
|
||||
_context.next = 7;
|
||||
$ = _ref.$, decode64 = _ref.decode64, importLocale = _ref.importLocale, dropXMLInternalSubset = _ref.dropXMLInternalSubset;
|
||||
_context2.next = 7;
|
||||
return importLocale();
|
||||
|
||||
case 7:
|
||||
imagelibStrings = _context.sent;
|
||||
imagelibStrings = _context2.sent;
|
||||
modularVersion = !('svgEditor' in window) || !window.svgEditor || window.svgEditor.modules !== false;
|
||||
svgEditor = this;
|
||||
$ = jQuery;
|
||||
uiStrings = svgEditor.uiStrings, svgCanvas = svgEditor.canvas, extIconsPath = svgEditor.curConfig.extIconsPath;
|
||||
imagelibStrings.imgLibs = imagelibStrings.imgLibs.map(function (_ref2) {
|
||||
var name = _ref2.name,
|
||||
@@ -238,233 +235,316 @@ var svgEditorExtension_imagelib = (function () {
|
||||
return location.origin;
|
||||
}
|
||||
});
|
||||
/**
|
||||
*
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
pending = {};
|
||||
mode = 's';
|
||||
multiArr = [];
|
||||
transferStopped = false;
|
||||
// Receive `postMessage` data
|
||||
window.addEventListener('message', function (_ref4) {
|
||||
var origin = _ref4.origin,
|
||||
response = _ref4.data;
|
||||
window.addEventListener('message',
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
var _ref5 = _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;
|
||||
|
||||
if (!response || !['string', 'object'].includes(_typeof(response))) {
|
||||
// Do nothing
|
||||
return;
|
||||
}
|
||||
if (!(!response || !['string', 'object'].includes(_typeof(response)))) {
|
||||
_context.next = 3;
|
||||
break;
|
||||
}
|
||||
|
||||
var id;
|
||||
var type;
|
||||
return _context.abrupt("return");
|
||||
|
||||
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);
|
||||
case 3:
|
||||
_context.prev = 3;
|
||||
// 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') {
|
||||
return;
|
||||
}
|
||||
if (!(response.namespace !== 'imagelib')) {
|
||||
_context.next = 7;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!allowedImageLibOrigins.includes('*') && !allowedImageLibOrigins.includes(origin)) {
|
||||
console.log("Origin ".concat(origin, " not whitelisted for posting to ").concat(window.origin));
|
||||
return;
|
||||
}
|
||||
return _context.abrupt("return");
|
||||
|
||||
var hasName = 'name' in response;
|
||||
var hasHref = 'href' in response;
|
||||
case 7:
|
||||
if (!(!allowedImageLibOrigins.includes('*') && !allowedImageLibOrigins.includes(origin))) {
|
||||
_context.next = 10;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!hasName && transferStopped) {
|
||||
transferStopped = false;
|
||||
return;
|
||||
}
|
||||
// Todo: Surface this error to user?
|
||||
console.log("Origin ".concat(origin, " not whitelisted for posting to ").concat(window.origin)); // eslint-disable-line no-console
|
||||
|
||||
if (hasHref) {
|
||||
id = response.href;
|
||||
response = response.data;
|
||||
} // Hide possible transfer dialog box
|
||||
return _context.abrupt("return");
|
||||
|
||||
case 10:
|
||||
hasName = 'name' in response;
|
||||
hasHref = 'href' in response;
|
||||
|
||||
if (!(!hasName && transferStopped)) {
|
||||
_context.next = 15;
|
||||
break;
|
||||
}
|
||||
|
||||
transferStopped = false;
|
||||
return _context.abrupt("return");
|
||||
|
||||
case 15:
|
||||
if (hasHref) {
|
||||
id = response.href;
|
||||
response = response.data;
|
||||
} // Hide possible transfer dialog box
|
||||
|
||||
|
||||
$('#dialog_box').hide();
|
||||
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') {
|
||||
var char1 = response.charAt(0);
|
||||
$('#dialog_box').hide();
|
||||
type = hasName ? 'meta' : response.charAt(0);
|
||||
_context.next = 28;
|
||||
break;
|
||||
|
||||
if (char1 !== '{' && transferStopped) {
|
||||
transferStopped = false;
|
||||
return;
|
||||
}
|
||||
case 20:
|
||||
_context.prev = 20;
|
||||
_context.t0 = _context["catch"](3);
|
||||
|
||||
if (char1 === '|') {
|
||||
var secondpos = response.indexOf('|', 1);
|
||||
id = response.substr(1, secondpos - 1);
|
||||
response = response.substr(secondpos + 1);
|
||||
type = response.charAt(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!(typeof response === 'string')) {
|
||||
_context.next = 28;
|
||||
break;
|
||||
}
|
||||
|
||||
var entry, curMeta, svgStr, imgStr;
|
||||
char1 = response.charAt(0);
|
||||
|
||||
switch (type) {
|
||||
case 'meta':
|
||||
{
|
||||
// Metadata
|
||||
transferStopped = false;
|
||||
curMeta = response; // Should be safe to add dynamic property as passed metadata
|
||||
if (!(char1 !== '{' && transferStopped)) {
|
||||
_context.next = 27;
|
||||
break;
|
||||
}
|
||||
|
||||
pending[curMeta.id] = curMeta; // lgtm [js/remote-property-injection]
|
||||
transferStopped = false;
|
||||
return _context.abrupt("return");
|
||||
|
||||
var name = curMeta.name || 'file';
|
||||
var message = uiStrings.notification.retrieving.replace('%s', name);
|
||||
case 27:
|
||||
if (char1 === '|') {
|
||||
secondpos = response.indexOf('|', 1);
|
||||
id = response.substr(1, secondpos - 1);
|
||||
response = response.substr(secondpos + 1);
|
||||
type = response.charAt(0);
|
||||
}
|
||||
|
||||
if (mode !== 'm') {
|
||||
$.process_cancel(message, function () {
|
||||
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);
|
||||
|
||||
case 39:
|
||||
transferStopped = true; // Should a message be sent back to the frame?
|
||||
|
||||
$('#dialog_box').hide();
|
||||
});
|
||||
} else {
|
||||
entry = $('<div>').text(message).data('id', curMeta.id);
|
||||
preview.append(entry);
|
||||
curMeta.entry = entry;
|
||||
}
|
||||
_context.next = 46;
|
||||
break;
|
||||
|
||||
return;
|
||||
}
|
||||
case 43:
|
||||
entry = $('<div>').text(message).data('id', curMeta.id);
|
||||
preview.append(entry);
|
||||
curMeta.entry = entry;
|
||||
|
||||
case '<':
|
||||
svgStr = true;
|
||||
break;
|
||||
case 46:
|
||||
return _context.abrupt("return");
|
||||
|
||||
case 'd':
|
||||
{
|
||||
if (response.startsWith('data:image/svg+xml')) {
|
||||
var pre = 'data:image/svg+xml;base64,';
|
||||
var src = response.substring(pre.length);
|
||||
response = decode64(src);
|
||||
svgStr = true;
|
||||
break;
|
||||
} else if (response.startsWith('data:image/')) {
|
||||
imgStr = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Else fall through
|
||||
case 47:
|
||||
svgStr = true;
|
||||
return _context.abrupt("break", 62);
|
||||
|
||||
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();
|
||||
} // $.alert('Unexpected data was returned: ' + response, function() {
|
||||
// if (mode !== 'm') {
|
||||
// closeBrowser();
|
||||
// } else {
|
||||
// pending[id].entry.remove();
|
||||
// }
|
||||
// });
|
||||
case 49:
|
||||
if (!response.startsWith('data:image/svg+xml')) {
|
||||
_context.next = 57;
|
||||
break;
|
||||
}
|
||||
|
||||
pre = 'data:image/svg+xml;base64,';
|
||||
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;
|
||||
}
|
||||
|
||||
imgStr = true;
|
||||
return _context.abrupt("break", 62);
|
||||
|
||||
case 60:
|
||||
// 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() {
|
||||
// if (mode !== 'm') {
|
||||
// closeBrowser();
|
||||
// } else {
|
||||
// pending[id].entry.remove();
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
return _context.abrupt("return");
|
||||
|
||||
switch (mode) {
|
||||
case 's':
|
||||
// Import one
|
||||
if (svgStr) {
|
||||
svgCanvas.importSvgString(response);
|
||||
} else if (imgStr) {
|
||||
importImage(response);
|
||||
}
|
||||
case 62:
|
||||
_context.t2 = mode;
|
||||
_context.next = _context.t2 === 's' ? 65 : _context.t2 === 'm' ? 68 : _context.t2 === 'o' ? 72 : 83;
|
||||
break;
|
||||
|
||||
closeBrowser();
|
||||
break;
|
||||
case 65:
|
||||
// Import one
|
||||
if (svgStr) {
|
||||
svgCanvas.importSvgString(response);
|
||||
} else if (imgStr) {
|
||||
importImage(response);
|
||||
}
|
||||
|
||||
case 'm':
|
||||
// Import multiple
|
||||
multiArr.push([svgStr ? 'svg' : 'img', response]);
|
||||
curMeta = pending[id];
|
||||
var title;
|
||||
closeBrowser();
|
||||
return _context.abrupt("break", 83);
|
||||
|
||||
if (svgStr) {
|
||||
if (curMeta && curMeta.name) {
|
||||
title = curMeta.name;
|
||||
} else {
|
||||
// Try to find a title
|
||||
// `dropXMLInternalSubset` is to help prevent the billion laughs attack
|
||||
var xml = new DOMParser().parseFromString(dropXMLInternalSubset(response), 'text/xml').documentElement; // lgtm [js/xml-bomb]
|
||||
case 68:
|
||||
// Import multiple
|
||||
multiArr.push([svgStr ? 'svg' : 'img', response]);
|
||||
curMeta = pending[id];
|
||||
|
||||
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), document.createTextNode(title)));
|
||||
if (svgStr) {
|
||||
if (curMeta && curMeta.name) {
|
||||
title = curMeta.name;
|
||||
} else {
|
||||
$(this).text(title);
|
||||
// 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]
|
||||
|
||||
title = $(xml).children('title').first().text() || '(SVG #' + response.length + ')';
|
||||
}
|
||||
|
||||
submit.removeAttr('disabled');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
preview.append($('<div>').text(title));
|
||||
submit.removeAttr('disabled');
|
||||
}
|
||||
} else {
|
||||
if (curMeta && curMeta.preview_url) {
|
||||
title = curMeta.name || '';
|
||||
}
|
||||
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), document.createTextNode(title)));
|
||||
} else {
|
||||
$(this).text(title);
|
||||
}
|
||||
|
||||
if (curMeta && curMeta.preview_url) {
|
||||
entry = $('<span>').append($('<img>').attr('src', curMeta.preview_url), document.createTextNode(title));
|
||||
} else {
|
||||
entry = $('<img>').attr('src', response);
|
||||
}
|
||||
submit.removeAttr('disabled');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
preview.append($('<div>').text(title));
|
||||
submit.removeAttr('disabled');
|
||||
}
|
||||
} else {
|
||||
if (curMeta && curMeta.preview_url) {
|
||||
title = curMeta.name || '';
|
||||
}
|
||||
|
||||
if (curMeta) {
|
||||
preview.children().each(function () {
|
||||
if ($(this).data('id') === id) {
|
||||
$(this).html(entry);
|
||||
submit.removeAttr('disabled');
|
||||
if (curMeta && curMeta.preview_url) {
|
||||
entry = $('<span>').append($('<img>').attr('src', curMeta.preview_url), document.createTextNode(title));
|
||||
} else {
|
||||
entry = $('<img>').attr('src', response);
|
||||
}
|
||||
|
||||
if (curMeta) {
|
||||
preview.children().each(function () {
|
||||
if ($(this).data('id') === id) {
|
||||
$(this).html(entry);
|
||||
submit.removeAttr('disabled');
|
||||
}
|
||||
});
|
||||
} else {
|
||||
preview.append($('<div>').append(entry));
|
||||
submit.removeAttr('disabled');
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
preview.append($('<div>').append(entry));
|
||||
submit.removeAttr('disabled');
|
||||
|
||||
return _context.abrupt("break", 83);
|
||||
|
||||
case 72:
|
||||
if (svgStr) {
|
||||
_context.next = 74;
|
||||
break;
|
||||
}
|
||||
|
||||
return _context.abrupt("break", 83);
|
||||
|
||||
case 74:
|
||||
closeBrowser();
|
||||
_context.next = 77;
|
||||
return svgEditor.openPrep();
|
||||
|
||||
case 77:
|
||||
ok = _context.sent;
|
||||
|
||||
if (ok) {
|
||||
_context.next = 80;
|
||||
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, this, [[3, 20]]);
|
||||
}));
|
||||
|
||||
break;
|
||||
return function (_x2) {
|
||||
return _ref5.apply(this, arguments);
|
||||
};
|
||||
}(), true);
|
||||
/**
|
||||
* @param {boolean} show
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
case 'o':
|
||||
// Open
|
||||
if (!svgStr) {
|
||||
break;
|
||||
}
|
||||
|
||||
svgEditor.openPrep(function (ok) {
|
||||
if (!ok) {
|
||||
return;
|
||||
}
|
||||
|
||||
svgCanvas.clear();
|
||||
svgCanvas.setSvgString(response); // updateCanvas();
|
||||
});
|
||||
closeBrowser();
|
||||
break;
|
||||
}
|
||||
}, true);
|
||||
buttons = [{
|
||||
id: 'tool_imagelib',
|
||||
type: 'app_menu',
|
||||
@@ -475,7 +555,7 @@ var svgEditorExtension_imagelib = (function () {
|
||||
mouseup: showBrowser
|
||||
}
|
||||
}];
|
||||
return _context.abrupt("return", {
|
||||
return _context2.abrupt("return", {
|
||||
svgicons: extIconsPath + 'ext-imagelib.xml',
|
||||
buttons: imagelibStrings.buttons.map(function (button, i) {
|
||||
return Object.assign(buttons[i], button);
|
||||
@@ -485,12 +565,12 @@ var svgEditorExtension_imagelib = (function () {
|
||||
}
|
||||
});
|
||||
|
||||
case 21:
|
||||
case 20:
|
||||
case "end":
|
||||
return _context.stop();
|
||||
return _context2.stop();
|
||||
}
|
||||
}
|
||||
}, _callee, this);
|
||||
}, _callee2, this);
|
||||
}));
|
||||
|
||||
return function init(_x) {
|
||||
|
||||
169
dist/extensions/ext-markers.js
vendored
169
dist/extensions/ext-markers.js
vendored
@@ -37,8 +37,6 @@ var svgEditorExtension_markers = (function () {
|
||||
};
|
||||
}
|
||||
|
||||
/* globals jQuery */
|
||||
|
||||
/**
|
||||
* ext-markers.js
|
||||
*
|
||||
@@ -74,13 +72,14 @@ var svgEditorExtension_markers = (function () {
|
||||
init: function () {
|
||||
var _init = _asyncToGenerator(
|
||||
/*#__PURE__*/
|
||||
regeneratorRuntime.mark(function _callee2(S) {
|
||||
var strings, svgEditor, $, svgCanvas, addElem, mtypes, markerPrefix, idPrefix, markerTypes, getLinked, setIcon, selElems, showPanel, addMarker, convertline, setMarker, colorChanged, updateReferences, triggerTextEntry, showTextPrompt, setArrowFromButton, getTitle, buildButtonList, contextTools;
|
||||
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
||||
regeneratorRuntime.mark(function _callee3(S) {
|
||||
var strings, svgEditor, $, svgCanvas, addElem, mtypes, markerPrefix, idPrefix, markerTypes, getLinked, setIcon, selElems, showPanel, addMarker, convertline, setMarker, colorChanged, updateReferences, triggerTextEntry, showTextPrompt, _showTextPrompt, setArrowFromButton, _setArrowFromButton, getTitle, buildButtonList, contextTools;
|
||||
|
||||
return regeneratorRuntime.wrap(function _callee3$(_context3) {
|
||||
while (1) {
|
||||
switch (_context2.prev = _context2.next) {
|
||||
switch (_context3.prev = _context3.next) {
|
||||
case 0:
|
||||
buildButtonList = function _ref14(lang) {
|
||||
buildButtonList = function _ref16() {
|
||||
var buttons = []; // const i = 0;
|
||||
|
||||
/*
|
||||
@@ -131,42 +130,95 @@ var svgEditorExtension_markers = (function () {
|
||||
return buttons;
|
||||
};
|
||||
|
||||
getTitle = function _ref13(id) {
|
||||
getTitle = function _ref15(id) {
|
||||
var langList = strings.langList;
|
||||
var item = langList.find(function (item) {
|
||||
return item.id === id;
|
||||
var item = langList.find(function (itm) {
|
||||
return itm.id === id;
|
||||
});
|
||||
return item ? item.title : id;
|
||||
};
|
||||
|
||||
setArrowFromButton = function _ref12(obj) {
|
||||
var parts = this.id.split('_');
|
||||
var pos = parts[1];
|
||||
var val = parts[2];
|
||||
_setArrowFromButton = function _ref14() {
|
||||
_setArrowFromButton = _asyncToGenerator(
|
||||
/*#__PURE__*/
|
||||
regeneratorRuntime.mark(function _callee2(ev) {
|
||||
var parts, pos, val;
|
||||
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
||||
while (1) {
|
||||
switch (_context2.prev = _context2.next) {
|
||||
case 0:
|
||||
parts = this.id.split('_');
|
||||
pos = parts[1];
|
||||
val = parts[2];
|
||||
|
||||
if (parts[3]) {
|
||||
val += '_' + parts[3];
|
||||
}
|
||||
if (parts[3]) {
|
||||
val += '_' + parts[3];
|
||||
}
|
||||
|
||||
if (val !== 'textmarker') {
|
||||
triggerTextEntry(pos, '\\' + val);
|
||||
} else {
|
||||
showTextPrompt(pos);
|
||||
}
|
||||
if (!(val !== 'textmarker')) {
|
||||
_context2.next = 8;
|
||||
break;
|
||||
}
|
||||
|
||||
triggerTextEntry(pos, '\\' + val);
|
||||
_context2.next = 10;
|
||||
break;
|
||||
|
||||
case 8:
|
||||
_context2.next = 10;
|
||||
return showTextPrompt(pos);
|
||||
|
||||
case 10:
|
||||
case "end":
|
||||
return _context2.stop();
|
||||
}
|
||||
}
|
||||
}, _callee2, this);
|
||||
}));
|
||||
return _setArrowFromButton.apply(this, arguments);
|
||||
};
|
||||
|
||||
showTextPrompt = function _ref11(pos) {
|
||||
var def = $('#' + pos + '_marker').val();
|
||||
setArrowFromButton = function _ref13(_x3) {
|
||||
return _setArrowFromButton.apply(this, arguments);
|
||||
};
|
||||
|
||||
if (def.substr(0, 1) === '\\') {
|
||||
def = '';
|
||||
}
|
||||
_showTextPrompt = function _ref12() {
|
||||
_showTextPrompt = _asyncToGenerator(
|
||||
/*#__PURE__*/
|
||||
regeneratorRuntime.mark(function _callee(pos) {
|
||||
var def, txt;
|
||||
return regeneratorRuntime.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
case 0:
|
||||
def = $('#' + pos + '_marker').val();
|
||||
|
||||
$.prompt('Enter text for ' + pos + ' marker', def, function (txt) {
|
||||
if (txt) {
|
||||
triggerTextEntry(pos, txt);
|
||||
}
|
||||
});
|
||||
if (def.substr(0, 1) === '\\') {
|
||||
def = '';
|
||||
}
|
||||
|
||||
_context.next = 4;
|
||||
return $.prompt('Enter text for ' + pos + ' marker', def);
|
||||
|
||||
case 4:
|
||||
txt = _context.sent;
|
||||
|
||||
if (txt) {
|
||||
triggerTextEntry(pos, txt);
|
||||
}
|
||||
|
||||
case 6:
|
||||
case "end":
|
||||
return _context.stop();
|
||||
}
|
||||
}
|
||||
}, _callee, this);
|
||||
}));
|
||||
return _showTextPrompt.apply(this, arguments);
|
||||
};
|
||||
|
||||
showTextPrompt = function _ref11(_x2) {
|
||||
return _showTextPrompt.apply(this, arguments);
|
||||
};
|
||||
|
||||
triggerTextEntry = function _ref10(pos, val) {
|
||||
@@ -333,11 +385,11 @@ var svgEditorExtension_markers = (function () {
|
||||
var marker = svgCanvas.getElem(id);
|
||||
|
||||
if (marker) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (val === '' || val === '\\nomarker') {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var el = selElems[0];
|
||||
@@ -360,7 +412,7 @@ var svgEditorExtension_markers = (function () {
|
||||
}
|
||||
|
||||
if (!markerTypes[seType]) {
|
||||
return;
|
||||
return undefined;
|
||||
} // an unknown type!
|
||||
// create a generic marker
|
||||
|
||||
@@ -492,13 +544,13 @@ var svgEditorExtension_markers = (function () {
|
||||
return svgCanvas.getElem(m[1]);
|
||||
};
|
||||
|
||||
_context2.next = 15;
|
||||
_context3.next = 17;
|
||||
return S.importLocale();
|
||||
|
||||
case 15:
|
||||
strings = _context2.sent;
|
||||
case 17:
|
||||
strings = _context3.sent;
|
||||
svgEditor = this;
|
||||
$ = jQuery;
|
||||
$ = S.$;
|
||||
svgCanvas = svgEditor.canvas;
|
||||
addElem = svgCanvas.addSVGElementFromJson;
|
||||
mtypes = ['start', 'mid', 'end'];
|
||||
@@ -647,38 +699,21 @@ var svgEditorExtension_markers = (function () {
|
||||
change: setArrowFromButton
|
||||
}
|
||||
}];
|
||||
return _context2.abrupt("return", {
|
||||
return _context3.abrupt("return", {
|
||||
name: strings.name,
|
||||
svgicons: svgEditor.curConfig.extIconsPath + 'markers-icons.xml',
|
||||
callback: function callback() {
|
||||
$('#marker_panel').addClass('toolset').hide();
|
||||
},
|
||||
addLangData: function () {
|
||||
var _addLangData = _asyncToGenerator(
|
||||
/*#__PURE__*/
|
||||
regeneratorRuntime.mark(function _callee(_ref) {
|
||||
var importLocale, lang;
|
||||
return regeneratorRuntime.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
case 0:
|
||||
importLocale = _ref.importLocale, lang = _ref.lang;
|
||||
return _context.abrupt("return", {
|
||||
data: strings.langList
|
||||
});
|
||||
|
||||
case 2:
|
||||
case "end":
|
||||
return _context.stop();
|
||||
}
|
||||
}
|
||||
}, _callee, this);
|
||||
}));
|
||||
|
||||
return function addLangData(_x2) {
|
||||
return _addLangData.apply(this, arguments);
|
||||
/* async */
|
||||
addLangData: function addLangData(_ref) {
|
||||
var importLocale = _ref.importLocale,
|
||||
lang = _ref.lang;
|
||||
return {
|
||||
data: strings.langList
|
||||
};
|
||||
}(),
|
||||
},
|
||||
selectedChanged: function selectedChanged(opts) {
|
||||
// Use this to update the current selected elements
|
||||
// console.log('selectChanged',opts);
|
||||
@@ -716,12 +751,12 @@ var svgEditorExtension_markers = (function () {
|
||||
})
|
||||
});
|
||||
|
||||
case 27:
|
||||
case 29:
|
||||
case "end":
|
||||
return _context2.stop();
|
||||
return _context3.stop();
|
||||
}
|
||||
}
|
||||
}, _callee2, this);
|
||||
}, _callee3, this);
|
||||
}));
|
||||
|
||||
return function init(_x) {
|
||||
|
||||
179
dist/extensions/ext-mathjax.js
vendored
179
dist/extensions/ext-mathjax.js
vendored
@@ -37,6 +37,14 @@ var svgEditorExtension_mathjax = (function () {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Add any of the whitelisted attributes to the script tag.
|
||||
* @param {HTMLScriptElement} script
|
||||
* @param {PlainObject.<string, string>} atts
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
|
||||
function addScriptAtts(script, atts) {
|
||||
['id', 'class', 'type'].forEach(function (prop) {
|
||||
if (prop in atts) {
|
||||
@@ -55,6 +63,7 @@ var svgEditorExtension_mathjax = (function () {
|
||||
}
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
// eslint-disable-line promise/avoid-new
|
||||
var script = document.createElement('script');
|
||||
|
||||
var destructor = function destructor() {
|
||||
@@ -87,11 +96,11 @@ var svgEditorExtension_mathjax = (function () {
|
||||
init: function () {
|
||||
var _init = _asyncToGenerator(
|
||||
/*#__PURE__*/
|
||||
regeneratorRuntime.mark(function _callee(_ref) {
|
||||
var importLocale, strings, svgEditor, $, svgCanvas, mathjaxSrcSecure, uiStrings, math, locationX, locationY, mathjaxLoaded, saveMath, buttons;
|
||||
return regeneratorRuntime.wrap(function _callee$(_context) {
|
||||
regeneratorRuntime.mark(function _callee2(_ref) {
|
||||
var $, importLocale, strings, svgEditor, svgCanvas, mathjaxSrcSecure, uiStrings, math, locationX, locationY, mathjaxLoaded, saveMath, buttons;
|
||||
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
switch (_context2.prev = _context2.next) {
|
||||
case 0:
|
||||
saveMath = function _ref2() {
|
||||
var code = $('#mathjax_code_textarea').val(); // displaystyle to force MathJax NOT to use the inline style. Because it is
|
||||
@@ -145,14 +154,13 @@ var svgEditorExtension_mathjax = (function () {
|
||||
});
|
||||
};
|
||||
|
||||
importLocale = _ref.importLocale;
|
||||
_context.next = 4;
|
||||
$ = _ref.$, importLocale = _ref.importLocale;
|
||||
_context2.next = 4;
|
||||
return importLocale();
|
||||
|
||||
case 4:
|
||||
strings = _context.sent;
|
||||
strings = _context2.sent;
|
||||
svgEditor = this;
|
||||
$ = jQuery;
|
||||
svgCanvas = svgEditor.canvas; // Configuration of the MathJax extention.
|
||||
// This will be added to the head tag before MathJax is loaded.
|
||||
|
||||
@@ -182,7 +190,8 @@ var svgEditorExtension_mathjax = (function () {
|
||||
// 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.
|
||||
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: {
|
||||
@@ -193,74 +202,110 @@ var svgEditorExtension_mathjax = (function () {
|
||||
title: 'Mathematics code editor'
|
||||
}
|
||||
});
|
||||
/**
|
||||
*
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
buttons = [{
|
||||
id: 'tool_mathjax',
|
||||
type: 'mode',
|
||||
icon: svgEditor.curConfig.extIconsPath + 'mathjax.png',
|
||||
events: {
|
||||
click: function click() {
|
||||
// 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(); // Make the MathEditor draggable.
|
||||
click: function () {
|
||||
var _click = _asyncToGenerator(
|
||||
/*#__PURE__*/
|
||||
regeneratorRuntime.mark(function _callee() {
|
||||
return regeneratorRuntime.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
case 0:
|
||||
// Set the mode.
|
||||
svgCanvas.setMode('mathjax'); // Only load Mathjax when needed, we don't want to strain Svg-Edit any more.
|
||||
// From this point on it is very probable that it will be needed, so load it.
|
||||
|
||||
$('#mathjax_container').draggable({
|
||||
cancel: 'button,fieldset',
|
||||
containment: 'window'
|
||||
}); // Add functionality and picture to cancel button.
|
||||
if (!(mathjaxLoaded === false)) {
|
||||
_context.next = 17;
|
||||
break;
|
||||
}
|
||||
|
||||
$('#tool_mathjax_cancel').prepend($.getSvgIcon('cancel', true)).on('click touched', function () {
|
||||
$('#mathjax').hide();
|
||||
}); // Add functionality and picture to the save button.
|
||||
$('<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.
|
||||
|
||||
$('#tool_mathjax_save').prepend($.getSvgIcon('ok', true)).on('click touched', function () {
|
||||
saveMath();
|
||||
$('#mathjax').hide();
|
||||
}); // MathJax preprocessing has to ignore most of the page.
|
||||
$('#mathjax_container').draggable({
|
||||
cancel: 'button,fieldset',
|
||||
containment: 'window'
|
||||
}); // Add functionality and picture to cancel button.
|
||||
|
||||
$('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
|
||||
$('#tool_mathjax_cancel').prepend($.getSvgIcon('cancel', true)).on('click touched', function () {
|
||||
$('#mathjax').hide();
|
||||
}); // Add functionality and picture to the save button.
|
||||
|
||||
/*
|
||||
const modularVersion = !('svgEditor' in window) ||
|
||||
!window.svgEditor ||
|
||||
window.svgEditor.modules !== false;
|
||||
// Add as second argument to `importScript`
|
||||
{
|
||||
type: modularVersion
|
||||
? 'module' // Make this the default when widely supported
|
||||
: 'text/javascript'
|
||||
}
|
||||
// If only using modules, just use this:
|
||||
const {default: MathJax} = await importModule( // or `import()` when widely supported
|
||||
svgEditor.curConfig.extIconsPath + mathjaxSrcSecure
|
||||
);
|
||||
*/
|
||||
// We use `extIconsPath` here for now as it does not vary with
|
||||
// the modular type as does `extPath`
|
||||
$('#tool_mathjax_save').prepend($.getSvgIcon('ok', true)).on('click touched', function () {
|
||||
saveMath();
|
||||
$('#mathjax').hide();
|
||||
}); // MathJax preprocessing has to ignore most of the page.
|
||||
|
||||
importScript(svgEditor.curConfig.extIconsPath + mathjaxSrcSecure).then(function () {
|
||||
// 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);
|
||||
mathjaxLoaded = true;
|
||||
console.log('MathJax Loaded');
|
||||
});
|
||||
}).catch(function () {
|
||||
console.log('Failed loadeing MathJax.');
|
||||
$.alert('Failed loading MathJax. You will not be able to change the mathematics.');
|
||||
});
|
||||
} // Set the mode.
|
||||
$('body').addClass('tex2jax_ignore'); // Now get (and run) the MathJax Library.
|
||||
// Todo: insert script with modules once widely supported
|
||||
// and if MathJax (and its `TeX-AMS-MML_SVG.js` dependency) ends up
|
||||
// providing an ES6 module export: https://github.com/mathjax/MathJax/issues/1998
|
||||
|
||||
/*
|
||||
const modularVersion = !('svgEditor' in window) ||
|
||||
!window.svgEditor ||
|
||||
window.svgEditor.modules !== false;
|
||||
// Add as second argument to `importScript`
|
||||
{
|
||||
type: modularVersion
|
||||
? 'module' // Make this the default when widely supported
|
||||
: 'text/javascript'
|
||||
}
|
||||
// If only using modules, just use this:
|
||||
const {default: MathJax} = await importModule( // or `import()` when widely supported
|
||||
svgEditor.curConfig.extIconsPath + mathjaxSrcSecure
|
||||
);
|
||||
*/
|
||||
// We use `extIconsPath` here for now as it does not vary with
|
||||
// the modular type as does `extPath`
|
||||
|
||||
svgCanvas.setMode('mathjax');
|
||||
}
|
||||
_context.prev = 7;
|
||||
_context.next = 10;
|
||||
return importScript(svgEditor.curConfig.extIconsPath + mathjaxSrcSecure);
|
||||
|
||||
case 10:
|
||||
// When MathJax is loaded get the div where the math will be rendered.
|
||||
MathJax.Hub.queue.Push(function () {
|
||||
math = MathJax.Hub.getAllJax('#mathjax_creator')[0];
|
||||
console.log(math); // eslint-disable-line no-console
|
||||
|
||||
mathjaxLoaded = true;
|
||||
console.log('MathJax Loaded'); // eslint-disable-line no-console
|
||||
});
|
||||
_context.next = 17;
|
||||
break;
|
||||
|
||||
case 13:
|
||||
_context.prev = 13;
|
||||
_context.t0 = _context["catch"](7);
|
||||
console.log('Failed loading MathJax.'); // eslint-disable-line no-console
|
||||
|
||||
$.alert('Failed loading MathJax. You will not be able to change the mathematics.');
|
||||
|
||||
case 17:
|
||||
case "end":
|
||||
return _context.stop();
|
||||
}
|
||||
}
|
||||
}, _callee, this, [[7, 13]]);
|
||||
}));
|
||||
|
||||
return function click() {
|
||||
return _click.apply(this, arguments);
|
||||
};
|
||||
}()
|
||||
}
|
||||
}];
|
||||
return _context.abrupt("return", {
|
||||
return _context2.abrupt("return", {
|
||||
name: strings.name,
|
||||
svgicons: svgEditor.curConfig.extIconsPath + 'mathjax-icons.xml',
|
||||
buttons: strings.buttons.map(function (button, i) {
|
||||
@@ -272,6 +317,8 @@ var svgEditorExtension_mathjax = (function () {
|
||||
started: true
|
||||
};
|
||||
}
|
||||
|
||||
return undefined;
|
||||
},
|
||||
mouseUp: function mouseUp(opts) {
|
||||
if (svgCanvas.getMode() === 'mathjax') {
|
||||
@@ -285,6 +332,8 @@ var svgEditorExtension_mathjax = (function () {
|
||||
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.
|
||||
@@ -292,12 +341,12 @@ var svgEditorExtension_mathjax = (function () {
|
||||
}
|
||||
});
|
||||
|
||||
case 13:
|
||||
case 12:
|
||||
case "end":
|
||||
return _context.stop();
|
||||
return _context2.stop();
|
||||
}
|
||||
}
|
||||
}, _callee, this);
|
||||
}, _callee2, this);
|
||||
}));
|
||||
|
||||
return function init(_x) {
|
||||
|
||||
10
dist/extensions/ext-overview_window.js
vendored
10
dist/extensions/ext-overview_window.js
vendored
@@ -1,8 +1,6 @@
|
||||
var svgEditorExtension_overview_window = (function () {
|
||||
'use strict';
|
||||
|
||||
/* globals jQuery */
|
||||
|
||||
/**
|
||||
* ext-overview_window.js
|
||||
*
|
||||
@@ -14,18 +12,18 @@ var svgEditorExtension_overview_window = (function () {
|
||||
var extOverview_window = {
|
||||
name: 'overview_window',
|
||||
init: function init(_ref) {
|
||||
var isChrome = _ref.isChrome,
|
||||
var $ = _ref.$,
|
||||
isChrome = _ref.isChrome,
|
||||
isIE = _ref.isIE;
|
||||
var $ = jQuery;
|
||||
var 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 = parseInt(navigator.userAgent.substring(verIndex), 10);
|
||||
var chromeVersion = parseInt(navigator.userAgent.substring(verIndex));
|
||||
|
||||
if (chromeVersion < 49) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
} // Define and insert the base html element.
|
||||
|
||||
|
||||
4
dist/extensions/ext-panning.js
vendored
4
dist/extensions/ext-panning.js
vendored
@@ -91,6 +91,8 @@ var svgEditorExtension_panning = (function () {
|
||||
started: true
|
||||
};
|
||||
}
|
||||
|
||||
return undefined;
|
||||
},
|
||||
mouseUp: function mouseUp() {
|
||||
if (svgCanvas.getMode() === 'ext-panning') {
|
||||
@@ -100,6 +102,8 @@ var svgEditorExtension_panning = (function () {
|
||||
element: null
|
||||
};
|
||||
}
|
||||
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
9
dist/extensions/ext-php_savefile.js
vendored
9
dist/extensions/ext-php_savefile.js
vendored
@@ -1,15 +1,18 @@
|
||||
var svgEditorExtension_php_savefile = (function () {
|
||||
'use strict';
|
||||
|
||||
/* globals jQuery */
|
||||
// TODO: Might add support for "exportImage" custom
|
||||
// handler as in "ext-server_opensave.js" (and in savefile.php)
|
||||
var extPhp_savefile = {
|
||||
name: 'php_savefile',
|
||||
init: function init() {
|
||||
init: function init(_ref) {
|
||||
var $ = _ref.$;
|
||||
var svgEditor = this;
|
||||
var $ = jQuery;
|
||||
var svgCanvas = svgEditor.canvas;
|
||||
/**
|
||||
* Get file name out of SVGEdit document title.
|
||||
* @returns {string}
|
||||
*/
|
||||
|
||||
function getFileNameFromTitle() {
|
||||
var title = svgCanvas.getDocumentTitle();
|
||||
|
||||
152
dist/extensions/ext-polygon.js
vendored
152
dist/extensions/ext-polygon.js
vendored
@@ -37,8 +37,6 @@ var svgEditorExtension_polygon = (function () {
|
||||
};
|
||||
}
|
||||
|
||||
/* globals jQuery */
|
||||
|
||||
/**
|
||||
* ext-polygon.js
|
||||
*
|
||||
@@ -52,7 +50,7 @@ var svgEditorExtension_polygon = (function () {
|
||||
var _init = _asyncToGenerator(
|
||||
/*#__PURE__*/
|
||||
regeneratorRuntime.mark(function _callee(S) {
|
||||
var svgEditor, $, svgCanvas, importLocale, editingitex, strings, selElems, started, newFO, showPanel, setAttr, cot, sec, buttons, contextTools;
|
||||
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) {
|
||||
@@ -82,13 +80,12 @@ var svgEditorExtension_polygon = (function () {
|
||||
};
|
||||
|
||||
svgEditor = this;
|
||||
$ = jQuery;
|
||||
svgCanvas = svgEditor.canvas;
|
||||
importLocale = S.importLocale, editingitex = false;
|
||||
_context.next = 10;
|
||||
$ = S.$, importLocale = S.importLocale, editingitex = false;
|
||||
_context.next = 9;
|
||||
return importLocale();
|
||||
|
||||
case 10:
|
||||
case 9:
|
||||
strings = _context.sent;
|
||||
|
||||
/**
|
||||
@@ -189,88 +186,89 @@ var svgEditorExtension_polygon = (function () {
|
||||
}, 3000);
|
||||
},
|
||||
mouseDown: function mouseDown(opts) {
|
||||
// const e = opts.event;
|
||||
if (svgCanvas.getMode() !== 'polygon') {
|
||||
return undefined;
|
||||
} // const e = opts.event;
|
||||
|
||||
|
||||
var rgb = svgCanvas.getColor('fill'); // const ccRgbEl = rgb.substring(1, rgb.length);
|
||||
|
||||
var sRgb = svgCanvas.getColor('stroke'); // ccSRgbEl = sRgb.substring(1, rgb.length);
|
||||
|
||||
var sWidth = svgCanvas.getStrokeWidth();
|
||||
|
||||
if (svgCanvas.getMode() === 'polygon') {
|
||||
started = true;
|
||||
newFO = svgCanvas.addSVGElementFromJson({
|
||||
element: 'polygon',
|
||||
attr: {
|
||||
cx: opts.start_x,
|
||||
cy: opts.start_y,
|
||||
id: svgCanvas.getNextId(),
|
||||
shape: 'regularPoly',
|
||||
sides: document.getElementById('polySides').value,
|
||||
orient: 'x',
|
||||
edge: 0,
|
||||
fill: rgb,
|
||||
strokecolor: sRgb,
|
||||
strokeWidth: sWidth
|
||||
}
|
||||
});
|
||||
return {
|
||||
started: true
|
||||
};
|
||||
}
|
||||
started = true;
|
||||
newFO = svgCanvas.addSVGElementFromJson({
|
||||
element: 'polygon',
|
||||
attr: {
|
||||
cx: opts.start_x,
|
||||
cy: opts.start_y,
|
||||
id: svgCanvas.getNextId(),
|
||||
shape: 'regularPoly',
|
||||
sides: document.getElementById('polySides').value,
|
||||
orient: 'x',
|
||||
edge: 0,
|
||||
fill: rgb,
|
||||
strokecolor: sRgb,
|
||||
strokeWidth: sWidth
|
||||
}
|
||||
});
|
||||
return {
|
||||
started: true
|
||||
};
|
||||
},
|
||||
mouseMove: function mouseMove(opts) {
|
||||
if (!started) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (svgCanvas.getMode() === 'polygon') {
|
||||
// const e = opts.event;
|
||||
var c = $(newFO).attr(['cx', 'cy', 'sides', 'orient', 'fill', 'strokecolor', 'strokeWidth']);
|
||||
var x = opts.mouse_x;
|
||||
var y = opts.mouse_y;
|
||||
var cx = c.cx,
|
||||
cy = c.cy,
|
||||
fill = c.fill,
|
||||
strokecolor = c.strokecolor,
|
||||
strokeWidth = c.strokeWidth,
|
||||
sides = c.sides,
|
||||
edg = Math.sqrt((x - cx) * (x - cx) + (y - cy) * (y - cy)) / 1.5;
|
||||
newFO.setAttribute('edge', edg);
|
||||
var inradius = edg / 2 * cot(Math.PI / sides);
|
||||
var circumradius = inradius * sec(Math.PI / sides);
|
||||
var points = '';
|
||||
|
||||
for (var s = 0; sides >= s; s++) {
|
||||
var angle = 2.0 * Math.PI * s / sides;
|
||||
x = circumradius * Math.cos(angle) + cx;
|
||||
y = circumradius * Math.sin(angle) + cy;
|
||||
points += x + ',' + y + ' ';
|
||||
} // const poly = newFO.createElementNS(NS.SVG, 'polygon');
|
||||
if (!started || svgCanvas.getMode() !== 'polygon') {
|
||||
return undefined;
|
||||
} // const e = opts.event;
|
||||
|
||||
|
||||
newFO.setAttribute('points', points);
|
||||
newFO.setAttribute('fill', fill);
|
||||
newFO.setAttribute('stroke', strokecolor);
|
||||
newFO.setAttribute('stroke-width', strokeWidth); // newFO.setAttribute('transform', 'rotate(-90)');
|
||||
// const shape = newFO.getAttribute('shape');
|
||||
// newFO.append(poly);
|
||||
// DrawPoly(cx, cy, sides, edg, orient);
|
||||
var c = $(newFO).attr(['cx', 'cy', 'sides', 'orient', 'fill', 'strokecolor', 'strokeWidth']);
|
||||
var x = opts.mouse_x;
|
||||
var y = opts.mouse_y;
|
||||
var cx = c.cx,
|
||||
cy = c.cy,
|
||||
fill = c.fill,
|
||||
strokecolor = c.strokecolor,
|
||||
strokeWidth = c.strokeWidth,
|
||||
sides = c.sides,
|
||||
edg = Math.sqrt((x - cx) * (x - cx) + (y - cy) * (y - cy)) / 1.5;
|
||||
newFO.setAttribute('edge', edg);
|
||||
var inradius = edg / 2 * cot(Math.PI / sides);
|
||||
var circumradius = inradius * sec(Math.PI / sides);
|
||||
var points = '';
|
||||
|
||||
return {
|
||||
started: true
|
||||
};
|
||||
}
|
||||
for (var s = 0; sides >= s; s++) {
|
||||
var angle = 2.0 * Math.PI * s / sides;
|
||||
x = circumradius * Math.cos(angle) + cx;
|
||||
y = circumradius * Math.sin(angle) + cy;
|
||||
points += x + ',' + y + ' ';
|
||||
} // const poly = newFO.createElementNS(NS.SVG, 'polygon');
|
||||
|
||||
|
||||
newFO.setAttribute('points', points);
|
||||
newFO.setAttribute('fill', fill);
|
||||
newFO.setAttribute('stroke', strokecolor);
|
||||
newFO.setAttribute('stroke-width', strokeWidth); // newFO.setAttribute('transform', 'rotate(-90)');
|
||||
// const shape = newFO.getAttribute('shape');
|
||||
// newFO.append(poly);
|
||||
// DrawPoly(cx, cy, sides, edg, orient);
|
||||
|
||||
return {
|
||||
started: true
|
||||
};
|
||||
},
|
||||
mouseUp: function mouseUp(opts) {
|
||||
if (svgCanvas.getMode() === 'polygon') {
|
||||
var attrs = $(newFO).attr('edge');
|
||||
var keep = attrs.edge !== '0'; // svgCanvas.addToSelection([newFO], true);
|
||||
|
||||
return {
|
||||
keep: keep,
|
||||
element: newFO
|
||||
};
|
||||
if (svgCanvas.getMode() !== 'polygon') {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var attrs = $(newFO).attr('edge');
|
||||
var keep = attrs.edge !== '0'; // svgCanvas.addToSelection([newFO], true);
|
||||
|
||||
return {
|
||||
keep: keep,
|
||||
element: newFO
|
||||
};
|
||||
},
|
||||
selectedChanged: function selectedChanged(opts) {
|
||||
// Use this to update the current selected elements
|
||||
@@ -295,7 +293,7 @@ var svgEditorExtension_polygon = (function () {
|
||||
elementChanged: function elementChanged(opts) {}
|
||||
});
|
||||
|
||||
case 14:
|
||||
case 13:
|
||||
case "end":
|
||||
return _context.stop();
|
||||
}
|
||||
|
||||
654
dist/extensions/ext-server_moinsave.js
vendored
654
dist/extensions/ext-server_moinsave.js
vendored
File diff suppressed because it is too large
Load Diff
816
dist/extensions/ext-server_opensave.js
vendored
816
dist/extensions/ext-server_opensave.js
vendored
File diff suppressed because it is too large
Load Diff
83
dist/extensions/ext-shapes.js
vendored
83
dist/extensions/ext-shapes.js
vendored
@@ -37,7 +37,43 @@ var svgEditorExtension_shapes = (function () {
|
||||
};
|
||||
}
|
||||
|
||||
/* globals jQuery */
|
||||
function _slicedToArray(arr, i) {
|
||||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
|
||||
}
|
||||
|
||||
function _arrayWithHoles(arr) {
|
||||
if (Array.isArray(arr)) return arr;
|
||||
}
|
||||
|
||||
function _iterableToArrayLimit(arr, i) {
|
||||
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 _nonIterableRest() {
|
||||
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
||||
}
|
||||
|
||||
/**
|
||||
* ext-shapes.js
|
||||
@@ -53,12 +89,12 @@ var svgEditorExtension_shapes = (function () {
|
||||
var _init = _asyncToGenerator(
|
||||
/*#__PURE__*/
|
||||
regeneratorRuntime.mark(function _callee(_ref) {
|
||||
var importLocale, strings, svgEditor, $, canv, svgroot, lastBBox, categories, library, modeId, startClientPos, currentD, curShapeId, curShape, startX, startY, curLib, loadIcons, makeButtons, loadLibrary, buttons;
|
||||
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 _ref4(catId) {
|
||||
loadLibrary = function _ref8(catId) {
|
||||
var lib = library[catId];
|
||||
|
||||
if (!lib) {
|
||||
@@ -84,7 +120,7 @@ var svgEditorExtension_shapes = (function () {
|
||||
loadIcons();
|
||||
};
|
||||
|
||||
makeButtons = function _ref3(cat, shapes) {
|
||||
makeButtons = function _ref7(cat, shapes) {
|
||||
var size = curLib.size || 300;
|
||||
var fill = curLib.fill || false;
|
||||
var off = size * 0.05;
|
||||
@@ -97,10 +133,11 @@ var svgEditorExtension_shapes = (function () {
|
||||
shapeIcon.documentElement.setAttribute('height', height);
|
||||
var svgElem = $(document.importNode(shapeIcon.documentElement, true));
|
||||
var data = shapes.data;
|
||||
curLib.buttons = [];
|
||||
curLib.buttons = Object.entries(data).map(function (_ref2) {
|
||||
var _ref3 = _slicedToArray(_ref2, 2),
|
||||
id = _ref3[0],
|
||||
pathD = _ref3[1];
|
||||
|
||||
for (var id in data) {
|
||||
var pathD = data[id];
|
||||
var icon = svgElem.clone();
|
||||
icon.find('path').attr('d', pathD);
|
||||
var iconBtn = icon.wrap('<div class="tool_button">').parent().attr({
|
||||
@@ -108,22 +145,21 @@ var svgEditorExtension_shapes = (function () {
|
||||
title: id
|
||||
}); // Store for later use
|
||||
|
||||
curLib.buttons.push(iconBtn[0]);
|
||||
}
|
||||
return iconBtn[0];
|
||||
});
|
||||
};
|
||||
|
||||
loadIcons = function _ref2() {
|
||||
loadIcons = function _ref6() {
|
||||
$('#shape_buttons').empty().append(curLib.buttons);
|
||||
};
|
||||
|
||||
importLocale = _ref.importLocale;
|
||||
$ = _ref.$, importLocale = _ref.importLocale;
|
||||
_context.next = 6;
|
||||
return importLocale();
|
||||
|
||||
case 6:
|
||||
strings = _context.sent;
|
||||
svgEditor = this;
|
||||
$ = jQuery;
|
||||
canv = svgEditor.canvas;
|
||||
svgroot = canv.getRootElem();
|
||||
lastBBox = {}; // This populates the category list
|
||||
@@ -167,6 +203,11 @@ var svgEditorExtension_shapes = (function () {
|
||||
modeId = 'shapelib';
|
||||
startClientPos = {};
|
||||
curLib = library.basic;
|
||||
/**
|
||||
*
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
buttons = [{
|
||||
id: 'tool_shapelib',
|
||||
icon: svgEditor.curConfig.extIconsPath + 'shapes.png',
|
||||
@@ -185,7 +226,7 @@ var svgEditorExtension_shapes = (function () {
|
||||
return Object.assign(buttons[i], button);
|
||||
}),
|
||||
callback: function 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');
|
||||
$('<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');
|
||||
@@ -233,18 +274,20 @@ var svgEditorExtension_shapes = (function () {
|
||||
}); // 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];
|
||||
|
||||
for (var o in categories) {
|
||||
cats['#shape_cats [data-cat="' + o + '"]'] = categories[o];
|
||||
}
|
||||
|
||||
cats['#shape_cats [data-cat="' + o + '"]'] = categoryName;
|
||||
});
|
||||
this.setStrings('content', cats);
|
||||
},
|
||||
mouseDown: function mouseDown(opts) {
|
||||
var mode = canv.getMode();
|
||||
|
||||
if (mode !== modeId) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
startX = opts.start_x;
|
||||
@@ -349,7 +392,7 @@ var svgEditorExtension_shapes = (function () {
|
||||
var mode = canv.getMode();
|
||||
|
||||
if (mode !== modeId) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var keepObject = opts.event.clientX !== startClientPos.x && opts.event.clientY !== startClientPos.y;
|
||||
@@ -361,7 +404,7 @@ var svgEditorExtension_shapes = (function () {
|
||||
}
|
||||
});
|
||||
|
||||
case 19:
|
||||
case 18:
|
||||
case "end":
|
||||
return _context.stop();
|
||||
}
|
||||
|
||||
21
dist/extensions/ext-star.js
vendored
21
dist/extensions/ext-star.js
vendored
@@ -37,8 +37,6 @@ var svgEditorExtension_star = (function () {
|
||||
};
|
||||
}
|
||||
|
||||
/* globals jQuery */
|
||||
|
||||
/**
|
||||
* ext-star.js
|
||||
*
|
||||
@@ -52,7 +50,7 @@ var svgEditorExtension_star = (function () {
|
||||
var _init = _asyncToGenerator(
|
||||
/*#__PURE__*/
|
||||
regeneratorRuntime.mark(function _callee(S) {
|
||||
var svgEditor, $, svgCanvas, importLocale, selElems, started, newFO, strings, showPanel, setAttr, buttons, contextTools;
|
||||
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) {
|
||||
@@ -74,14 +72,13 @@ var svgEditorExtension_star = (function () {
|
||||
};
|
||||
|
||||
svgEditor = this;
|
||||
$ = jQuery;
|
||||
svgCanvas = svgEditor.canvas;
|
||||
importLocale = S.importLocale; // {svgcontent},
|
||||
$ = S.$, importLocale = S.importLocale; // {svgcontent},
|
||||
|
||||
_context.next = 8;
|
||||
_context.next = 7;
|
||||
return importLocale();
|
||||
|
||||
case 8:
|
||||
case 7:
|
||||
strings = _context.sent;
|
||||
|
||||
/*
|
||||
@@ -175,10 +172,12 @@ var svgEditorExtension_star = (function () {
|
||||
started: true
|
||||
};
|
||||
}
|
||||
|
||||
return undefined;
|
||||
},
|
||||
mouseMove: function mouseMove(opts) {
|
||||
if (!started) {
|
||||
return;
|
||||
return undefined;
|
||||
}
|
||||
|
||||
if (svgCanvas.getMode() === 'star') {
|
||||
@@ -239,6 +238,8 @@ var svgEditorExtension_star = (function () {
|
||||
started: true
|
||||
};
|
||||
}
|
||||
|
||||
return undefined;
|
||||
},
|
||||
mouseUp: function mouseUp() {
|
||||
if (svgCanvas.getMode() === 'star') {
|
||||
@@ -249,6 +250,8 @@ var svgEditorExtension_star = (function () {
|
||||
element: newFO
|
||||
};
|
||||
}
|
||||
|
||||
return undefined;
|
||||
},
|
||||
selectedChanged: function selectedChanged(opts) {
|
||||
// Use this to update the current selected elements
|
||||
@@ -275,7 +278,7 @@ var svgEditorExtension_star = (function () {
|
||||
elementChanged: function elementChanged(opts) {}
|
||||
});
|
||||
|
||||
case 12:
|
||||
case 11:
|
||||
case "end":
|
||||
return _context.stop();
|
||||
}
|
||||
|
||||
343
dist/extensions/ext-storage.js
vendored
343
dist/extensions/ext-storage.js
vendored
@@ -37,7 +37,43 @@ var svgEditorExtension_storage = (function () {
|
||||
};
|
||||
}
|
||||
|
||||
/* globals jQuery */
|
||||
function _slicedToArray(arr, i) {
|
||||
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest();
|
||||
}
|
||||
|
||||
function _arrayWithHoles(arr) {
|
||||
if (Array.isArray(arr)) return arr;
|
||||
}
|
||||
|
||||
function _iterableToArrayLimit(arr, i) {
|
||||
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 _nonIterableRest() {
|
||||
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
||||
}
|
||||
|
||||
/**
|
||||
* ext-storage.js
|
||||
@@ -63,9 +99,9 @@ var svgEditorExtension_storage = (function () {
|
||||
*/
|
||||
var extStorage = {
|
||||
name: 'storage',
|
||||
init: function init() {
|
||||
init: function init(_ref) {
|
||||
var $ = _ref.$;
|
||||
var svgEditor = this;
|
||||
var $ = jQuery;
|
||||
var 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;
|
||||
@@ -78,6 +114,11 @@ var svgEditorExtension_storage = (function () {
|
||||
forceStorage = _svgEditor$curConfig.forceStorage;
|
||||
var storage = svgEditor.storage,
|
||||
updateCanvas = svgEditor.updateCanvas;
|
||||
/**
|
||||
* Replace `storagePrompt` parameter within URL.
|
||||
* @param {string} val
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
function replaceStoragePrompt(val) {
|
||||
val = val ? 'storagePrompt=' + val : '';
|
||||
@@ -91,6 +132,13 @@ var svgEditorExtension_storage = (function () {
|
||||
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 {undefined}
|
||||
*/
|
||||
|
||||
|
||||
function setSVGContentStorage(val) {
|
||||
if (storage) {
|
||||
@@ -103,29 +151,42 @@ var svgEditorExtension_storage = (function () {
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Set the cookie to expire.
|
||||
* @param {string} cookie
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
|
||||
function expireCookie(cookie) {
|
||||
document.cookie = encodeURIComponent(cookie) + '=; expires=Thu, 01 Jan 1970 00:00:00 GMT';
|
||||
}
|
||||
/**
|
||||
* Expire the storage cookie.
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
|
||||
function removeStoragePrefCookie() {
|
||||
expireCookie('store');
|
||||
expireCookie('svgeditstore');
|
||||
}
|
||||
/**
|
||||
* Empties storage for each of the current preferences.
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
|
||||
function emptyStorage() {
|
||||
setSVGContentStorage('');
|
||||
Object.keys(svgEditor.curPrefs).forEach(function (name) {
|
||||
name = 'svg-edit-' + name;
|
||||
|
||||
for (var name in svgEditor.curPrefs) {
|
||||
if (svgEditor.curPrefs.hasOwnProperty(name)) {
|
||||
name = 'svg-edit-' + name;
|
||||
|
||||
if (storage) {
|
||||
storage.removeItem(name);
|
||||
}
|
||||
|
||||
expireCookie(name);
|
||||
if (storage) {
|
||||
storage.removeItem(name);
|
||||
}
|
||||
}
|
||||
|
||||
expireCookie(name);
|
||||
});
|
||||
} // emptyStorage();
|
||||
|
||||
/**
|
||||
@@ -142,11 +203,11 @@ var svgEditorExtension_storage = (function () {
|
||||
function setupBeforeUnloadListener() {
|
||||
window.addEventListener('beforeunload', function (e) {
|
||||
// Don't save anything unless the user opted in to storage
|
||||
if (!document.cookie.match(/(?:^|;\s*)store=(?:prefsAndContent|prefsOnly)/)) {
|
||||
if (!document.cookie.match(/(?:^|;\s*)svgeditstore=(?:prefsAndContent|prefsOnly)/)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (document.cookie.match(/(?:^|;\s*)store=prefsAndContent/)) {
|
||||
if (document.cookie.match(/(?:^|;\s*)svgeditstore=prefsAndContent/)) {
|
||||
setSVGContentStorage(svgCanvas.getSvgString());
|
||||
}
|
||||
|
||||
@@ -156,28 +217,27 @@ var svgEditorExtension_storage = (function () {
|
||||
// svgEditor.showSaveWarning = false;
|
||||
|
||||
var curPrefs = svgEditor.curPrefs;
|
||||
Object.entries(curPrefs).forEach(function (_ref2) {
|
||||
var _ref3 = _slicedToArray(_ref2, 2),
|
||||
key = _ref3[0],
|
||||
val = _ref3[1];
|
||||
|
||||
for (var key in curPrefs) {
|
||||
if (curPrefs.hasOwnProperty(key)) {
|
||||
// It's our own config, so we don't need to iterate up the prototype chain
|
||||
var val = curPrefs[key];
|
||||
var store = val !== undefined;
|
||||
key = 'svg-edit-' + key;
|
||||
var store = val !== undefined;
|
||||
key = 'svg-edit-' + key;
|
||||
|
||||
if (!store) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (storage) {
|
||||
storage.setItem(key, val);
|
||||
} else if (window.widget) {
|
||||
window.widget.setPreferenceForKey(val, key);
|
||||
} else {
|
||||
val = encodeURIComponent(val);
|
||||
document.cookie = encodeURIComponent(key) + '=' + val + '; expires=Fri, 31 Dec 9999 23:59:59 GMT';
|
||||
}
|
||||
if (!store) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (storage) {
|
||||
storage.setItem(key, val);
|
||||
} else if (window.widget) {
|
||||
window.widget.setPreferenceForKey(val, key);
|
||||
} else {
|
||||
val = encodeURIComponent(val);
|
||||
document.cookie = encodeURIComponent(key) + '=' + val + '; expires=Fri, 31 Dec 9999 23:59:59 GMT';
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -187,14 +247,14 @@ var svgEditorExtension_storage = (function () {
|
||||
langReady: function () {
|
||||
var _langReady = _asyncToGenerator(
|
||||
/*#__PURE__*/
|
||||
regeneratorRuntime.mark(function _callee(_ref) {
|
||||
var importLocale, _$$deparam$querystrin, storagePrompt, confirmSetStorage, message, storagePrefsAndContent, storagePrefsOnly, storagePrefs, storageNoPrefsOrContent, storageNoPrefs, rememberLabel, rememberTooltip, options, oldContainerWidth, oldContainerMarginLeft, oldContentHeight, oldContainerHeight;
|
||||
regeneratorRuntime.mark(function _callee(_ref4) {
|
||||
var importLocale, _$$deparam$querystrin, storagePrompt, confirmSetStorage, message, storagePrefsAndContent, storagePrefsOnly, storagePrefs, storageNoPrefsOrContent, storageNoPrefs, rememberLabel, rememberTooltip, options, oldContainerWidth, oldContainerMarginLeft, oldContentHeight, oldContainerHeight, _ref5, pref, checked;
|
||||
|
||||
return regeneratorRuntime.wrap(function _callee$(_context) {
|
||||
while (1) {
|
||||
switch (_context.prev = _context.next) {
|
||||
case 0:
|
||||
importLocale = _ref.importLocale;
|
||||
importLocale = _ref4.importLocale;
|
||||
_$$deparam$querystrin = $.deparam.querystring(true), storagePrompt = _$$deparam$querystrin.storagePrompt;
|
||||
_context.next = 4;
|
||||
return importLocale();
|
||||
@@ -217,7 +277,7 @@ var svgEditorExtension_storage = (function () {
|
||||
// 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
|
||||
@@ -225,100 +285,129 @@ var svgEditorExtension_storage = (function () {
|
||||
// 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*)store=(?:prefsAndContent|prefsOnly)/) // ...then show the storage prompt.
|
||||
)) {
|
||||
options = [];
|
||||
!document.cookie.match(/(?:^|;\s*)svgeditstore=(?:prefsAndContent|prefsOnly)/) // ...then show the storage prompt.
|
||||
))) {
|
||||
_context.next = 44;
|
||||
break;
|
||||
}
|
||||
|
||||
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
|
||||
options = [];
|
||||
|
||||
|
||||
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
|
||||
|
||||
$.select(message, options, function (pref, checked) {
|
||||
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
|
||||
// doesn't even want to remember their not wanting
|
||||
// storage, so we don't set the cookie or continue on with
|
||||
// setting storage on beforeunload
|
||||
document.cookie = 'store=' + encodeURIComponent(pref) + '; expires=Fri, 31 Dec 9999 23:59:59 GMT'; // 'prefsAndContent' | 'prefsOnly'
|
||||
// If the URL was configured to always insist on a prompt, if
|
||||
// the user does indicate a wish to store their info, we
|
||||
// don't want ask them again upon page refresh so move
|
||||
// them instead to a URL which does not always prompt
|
||||
|
||||
if (storagePrompt === true && checked) {
|
||||
replaceStoragePrompt();
|
||||
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) {
|
||||
emptyStorage();
|
||||
}
|
||||
|
||||
if (pref && checked) {
|
||||
// Open a URL which won't set storage and won't prompt user about storage
|
||||
replaceStoragePrompt('false');
|
||||
return;
|
||||
}
|
||||
} // Reset width/height of dialog (e.g., for use by Export)
|
||||
|
||||
|
||||
$('#dialog_container')[0].style.width = oldContainerWidth;
|
||||
$('#dialog_container')[0].style.marginLeft = oldContainerMarginLeft;
|
||||
$('#dialog_content')[0].style.height = oldContentHeight;
|
||||
$('#dialog_container')[0].style.height = oldContainerHeight; // It should be enough to (conditionally) add to storage on
|
||||
// beforeunload, but if we wished to update immediately,
|
||||
// we might wish to try setting:
|
||||
// svgEditor.setConfig({noStorageOnLoad: true});
|
||||
// and then call:
|
||||
// svgEditor.loadContentAndPrefs();
|
||||
// We don't check for noStorageOnLoad here because
|
||||
// the prompt gives the user the option to store data
|
||||
|
||||
setupBeforeUnloadListener();
|
||||
svgEditor.storagePromptState = 'closed';
|
||||
updateCanvas(true);
|
||||
}, null, null, {
|
||||
label: rememberLabel,
|
||||
checked: true,
|
||||
tooltip: rememberTooltip
|
||||
if (storage) {
|
||||
options.unshift({
|
||||
value: 'prefsAndContent',
|
||||
text: storagePrefsAndContent
|
||||
}, {
|
||||
value: 'prefsOnly',
|
||||
text: storagePrefsOnly
|
||||
}, {
|
||||
value: 'noPrefsOrContent',
|
||||
text: storageNoPrefsOrContent
|
||||
});
|
||||
svgEditor.storagePromptState = 'waiting';
|
||||
} else if (!noStorageOnLoad || forceStorage) {
|
||||
} else {
|
||||
options.unshift({
|
||||
value: 'prefsOnly',
|
||||
text: storagePrefs
|
||||
}, {
|
||||
value: 'noPrefsOrContent',
|
||||
text: storageNoPrefs
|
||||
});
|
||||
} // Hack to temporarily provide a wide and high enough dialog
|
||||
|
||||
|
||||
oldContainerWidth = $('#dialog_container')[0].style.width, oldContainerMarginLeft = $('#dialog_container')[0].style.marginLeft, oldContentHeight = $('#dialog_content')[0].style.height, oldContainerHeight = $('#dialog_container')[0].style.height;
|
||||
$('#dialog_content')[0].style.height = '120px';
|
||||
$('#dialog_container')[0].style.height = '170px';
|
||||
$('#dialog_container')[0].style.width = '800px';
|
||||
$('#dialog_container')[0].style.marginLeft = '-400px'; // Open select-with-checkbox dialog
|
||||
// From svg-editor.js
|
||||
|
||||
svgEditor.storagePromptState = 'waiting';
|
||||
_context.next = 20;
|
||||
return $.select(message, options, null, null, {
|
||||
label: rememberLabel,
|
||||
checked: true,
|
||||
tooltip: rememberTooltip
|
||||
});
|
||||
|
||||
case 20:
|
||||
_ref5 = _context.sent;
|
||||
pref = _ref5.response;
|
||||
checked = _ref5.checked;
|
||||
|
||||
if (!(pref && pref !== 'noPrefsOrContent')) {
|
||||
_context.next = 30;
|
||||
break;
|
||||
}
|
||||
|
||||
// Regardless of whether the user opted
|
||||
// to remember the choice (and move to a URL which won't
|
||||
// ask them again), we have to assume the user
|
||||
// doesn't even want to remember their not wanting
|
||||
// storage, so we don't set the cookie or continue on with
|
||||
// setting storage on beforeunload
|
||||
document.cookie = 'svgeditstore=' + encodeURIComponent(pref) + '; expires=Fri, 31 Dec 9999 23:59:59 GMT'; // 'prefsAndContent' | 'prefsOnly'
|
||||
// If the URL was configured to always insist on a prompt, if
|
||||
// the user does indicate a wish to store their info, we
|
||||
// don't want ask them again upon page refresh so move
|
||||
// them instead to a URL which does not always prompt
|
||||
|
||||
if (!(storagePrompt === true && checked)) {
|
||||
_context.next = 28;
|
||||
break;
|
||||
}
|
||||
|
||||
replaceStoragePrompt();
|
||||
return _context.abrupt("return");
|
||||
|
||||
case 28:
|
||||
_context.next = 35;
|
||||
break;
|
||||
|
||||
case 30:
|
||||
// The user does not wish storage (or cancelled, which we treat equivalently)
|
||||
removeStoragePrefCookie();
|
||||
|
||||
if (pref && // If the user explicitly expresses wish for no storage
|
||||
emptyStorageOnDecline) {
|
||||
emptyStorage();
|
||||
}
|
||||
|
||||
if (!(pref && checked)) {
|
||||
_context.next = 35;
|
||||
break;
|
||||
}
|
||||
|
||||
// Open a URL which won't set storage and won't prompt user about storage
|
||||
replaceStoragePrompt('false');
|
||||
return _context.abrupt("return");
|
||||
|
||||
case 35:
|
||||
// Reset width/height of dialog (e.g., for use by Export)
|
||||
$('#dialog_container')[0].style.width = oldContainerWidth;
|
||||
$('#dialog_container')[0].style.marginLeft = oldContainerMarginLeft;
|
||||
$('#dialog_content')[0].style.height = oldContentHeight;
|
||||
$('#dialog_container')[0].style.height = oldContainerHeight; // It should be enough to (conditionally) add to storage on
|
||||
// beforeunload, but if we wished to update immediately,
|
||||
// we might wish to try setting:
|
||||
// svgEditor.setConfig({noStorageOnLoad: true});
|
||||
// and then call:
|
||||
// svgEditor.loadContentAndPrefs();
|
||||
// We don't check for noStorageOnLoad here because
|
||||
// the prompt gives the user the option to store data
|
||||
|
||||
setupBeforeUnloadListener();
|
||||
svgEditor.storagePromptState = 'closed';
|
||||
updateCanvas(true);
|
||||
_context.next = 45;
|
||||
break;
|
||||
|
||||
case 44:
|
||||
if (!noStorageOnLoad || forceStorage) {
|
||||
setupBeforeUnloadListener();
|
||||
}
|
||||
|
||||
case 10:
|
||||
case 45:
|
||||
case "end":
|
||||
return _context.stop();
|
||||
}
|
||||
|
||||
7
dist/extensions/ext-webappfind.js
vendored
7
dist/extensions/ext-webappfind.js
vendored
@@ -49,12 +49,12 @@ var svgEditorExtension_webappfind = (function () {
|
||||
var _init = _asyncToGenerator(
|
||||
/*#__PURE__*/
|
||||
regeneratorRuntime.mark(function _callee(_ref) {
|
||||
var importLocale, strings, svgEditor, saveMessage, readMessage, excludedMessages, pathID, buttons;
|
||||
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;
|
||||
importLocale = _ref.importLocale, $ = _ref.$;
|
||||
_context.next = 3;
|
||||
return importLocale();
|
||||
|
||||
@@ -73,6 +73,7 @@ var svgEditorExtension_webappfind = (function () {
|
||||
function (win, _ref2) {
|
||||
var data = _ref2.data,
|
||||
origin = _ref2.origin;
|
||||
// eslint-disable-line no-shadow
|
||||
// console.log('data, origin', data, origin);
|
||||
var type, content;
|
||||
|
||||
@@ -103,7 +104,7 @@ var svgEditorExtension_webappfind = (function () {
|
||||
break;
|
||||
|
||||
case 'save-end':
|
||||
alert("save complete for pathID ".concat(pathID, "!"));
|
||||
$.alert("save complete for pathID ".concat(pathID, "!"));
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
5
dist/extensions/ext-xdomain-messaging.js
vendored
5
dist/extensions/ext-xdomain-messaging.js
vendored
@@ -65,7 +65,8 @@ var svgEditorExtension_xdomain_messaging = (function () {
|
||||
var allowedOrigins = svgEditor.curConfig.allowedOrigins;
|
||||
|
||||
if (!allowedOrigins.includes('*') && !allowedOrigins.includes(e.origin)) {
|
||||
console.log("Origin ".concat(e.origin, " not whitelisted for posting to ").concat(window.origin));
|
||||
console.log("Origin ".concat(e.origin, " not whitelisted for posting to ").concat(window.origin)); // eslint-disable-line no-console
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -88,7 +89,7 @@ var svgEditorExtension_xdomain_messaging = (function () {
|
||||
e.source.postMessage(JSON.stringify(message), '*');
|
||||
});
|
||||
} catch (err) {
|
||||
console.log('Error with xdomain message listener: ' + err);
|
||||
console.log('Error with xdomain message listener: ' + err); // eslint-disable-line no-console
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
4
dist/extensions/imagelib/index.js
vendored
4
dist/extensions/imagelib/index.js
vendored
@@ -57,7 +57,9 @@
|
||||
data = canvas.toDataURL();
|
||||
} catch (err) {
|
||||
// This fails in Firefox with `file:///` URLs :(
|
||||
alert('Data URL conversion failed: ' + err);
|
||||
// Todo: This could use a generic alert library instead
|
||||
alert('Data URL conversion failed: ' + err); // eslint-disable-line no-alert
|
||||
|
||||
data = '';
|
||||
}
|
||||
|
||||
|
||||
54
dist/extensions/imagelib/openclipart.js
vendored
54
dist/extensions/imagelib/openclipart.js
vendored
@@ -3004,6 +3004,13 @@
|
||||
|
||||
manipulation($$1, jml);
|
||||
var baseAPIURL = 'https://openclipart.org/search/json/';
|
||||
var jsVoid = 'javascript: void(0);'; // eslint-disable-line no-script-url
|
||||
|
||||
/**
|
||||
* Shows results after query submission.
|
||||
* @param {string} url
|
||||
* @returns {undefined}
|
||||
*/
|
||||
|
||||
function processResults(_x) {
|
||||
return _processResults.apply(this, arguments);
|
||||
@@ -3021,7 +3028,7 @@
|
||||
case 0:
|
||||
queryLink = function _ref4(query) {
|
||||
return ['a', {
|
||||
href: 'javascript: void(0);',
|
||||
href: jsVoid,
|
||||
dataset: {
|
||||
value: query
|
||||
},
|
||||
@@ -3046,17 +3053,18 @@
|
||||
|
||||
case 6:
|
||||
json = _context3.sent;
|
||||
console.log('json', json);
|
||||
|
||||
if (!(!json || json.msg !== 'success')) {
|
||||
_context3.next = 11;
|
||||
_context3.next = 10;
|
||||
break;
|
||||
}
|
||||
|
||||
alert('There was a problem downloading the results');
|
||||
// Todo: This could use a generic alert library instead
|
||||
alert('There was a problem downloading the results'); // eslint-disable-line no-alert
|
||||
|
||||
return _context3.abrupt("return");
|
||||
|
||||
case 11:
|
||||
case 10:
|
||||
payload = json.payload, _json$info = json.info, numResults = _json$info.results, pages = _json$info.pages, currentPage = _json$info.current_page; // $('#page')[0].value = currentPage;
|
||||
// $('#page')[0].max = pages;
|
||||
// Unused properties:
|
||||
@@ -3093,15 +3101,13 @@
|
||||
var _click = _asyncToGenerator(
|
||||
/*#__PURE__*/
|
||||
regeneratorRuntime.mark(function _callee2(e) {
|
||||
var _this$dataset, svgURL, id, post, result, svg;
|
||||
|
||||
var svgurl, post, result, svg;
|
||||
return regeneratorRuntime.wrap(function _callee2$(_context2) {
|
||||
while (1) {
|
||||
switch (_context2.prev = _context2.next) {
|
||||
case 0:
|
||||
e.preventDefault();
|
||||
_this$dataset = this.dataset, svgURL = _this$dataset.value, id = _this$dataset.id;
|
||||
console.log('this', id, svgURL);
|
||||
svgurl = this.dataset.value; // console.log('this', id, svgurl);
|
||||
|
||||
post = function post(message) {
|
||||
// Todo: Make origin customizable as set by opening window
|
||||
@@ -3114,25 +3120,25 @@
|
||||
|
||||
post({
|
||||
name: title,
|
||||
id: svgURL
|
||||
id: svgurl
|
||||
});
|
||||
_context2.next = 7;
|
||||
return fetch(svgURL);
|
||||
_context2.next = 6;
|
||||
return fetch(svgurl);
|
||||
|
||||
case 7:
|
||||
case 6:
|
||||
result = _context2.sent;
|
||||
_context2.next = 10;
|
||||
_context2.next = 9;
|
||||
return result.text();
|
||||
|
||||
case 10:
|
||||
case 9:
|
||||
svg = _context2.sent;
|
||||
console.log('h', svgURL, svg);
|
||||
// console.log('url and svg', svgurl, svg);
|
||||
post({
|
||||
href: svgURL,
|
||||
href: svgurl,
|
||||
data: svg
|
||||
});
|
||||
|
||||
case 13:
|
||||
case 11:
|
||||
case "end":
|
||||
return _context2.stop();
|
||||
}
|
||||
@@ -3151,7 +3157,7 @@
|
||||
src: svgURL,
|
||||
style: "width: ".concat(imgHW, "; height: ").concat(imgHW, ";")
|
||||
}]]], ['b', [title]], ' ', ['i', [description]], ' ', ['span', ['(ID: ', ['a', {
|
||||
href: 'javascript: void(0);',
|
||||
href: jsVoid,
|
||||
dataset: {
|
||||
value: id
|
||||
},
|
||||
@@ -3170,7 +3176,7 @@
|
||||
return ['span', [' ', queryLink(tag)]];
|
||||
})))];
|
||||
})), [['br'], ['br'], currentPage === 1 || pages <= 2 ? '' : ['span', [['a', {
|
||||
href: 'javascript: void(0);',
|
||||
href: jsVoid,
|
||||
$on: {
|
||||
click: function click(e) {
|
||||
e.preventDefault();
|
||||
@@ -3179,7 +3185,7 @@
|
||||
}
|
||||
}
|
||||
}, ['First']], ' ']], currentPage === 1 ? '' : ['span', [['a', {
|
||||
href: 'javascript: void(0);',
|
||||
href: jsVoid,
|
||||
$on: {
|
||||
click: function click(e) {
|
||||
e.preventDefault();
|
||||
@@ -3188,7 +3194,7 @@
|
||||
}
|
||||
}
|
||||
}, ['Prev']], ' ']], currentPage === pages ? '' : ['span', [['a', {
|
||||
href: 'javascript: void(0);',
|
||||
href: jsVoid,
|
||||
$on: {
|
||||
click: function click(e) {
|
||||
e.preventDefault();
|
||||
@@ -3197,7 +3203,7 @@
|
||||
}
|
||||
}
|
||||
}, ['Next']], ' ']], currentPage === pages || pages <= 2 ? '' : ['span', [['a', {
|
||||
href: 'javascript: void(0);',
|
||||
href: jsVoid,
|
||||
$on: {
|
||||
click: function click(e) {
|
||||
e.preventDefault();
|
||||
@@ -3207,7 +3213,7 @@
|
||||
}
|
||||
}, ['Last']], ' ']]]));
|
||||
|
||||
case 14:
|
||||
case 13:
|
||||
case "end":
|
||||
return _context3.stop();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user