- Fix (regression): Fix storage namespace; update build files to get regression fix applied

This commit is contained in:
Brett Zamir
2018-11-16 13:33:13 +08:00
parent c42791b2b2
commit b0fad3d765
9 changed files with 149 additions and 117 deletions

64
dist/index-es.js vendored
View File

@@ -14602,12 +14602,18 @@ function SvgCanvas(container, config) {
* @returns {Promise} Resolves to [ExtensionInitResponse]{@link module:svgcanvas.ExtensionInitResponse} or `undefined` * @returns {Promise} Resolves to [ExtensionInitResponse]{@link module:svgcanvas.ExtensionInitResponse} or `undefined`
*/ */
/**
* @typedef {PlainObject} module:svgcanvas.ExtensionInitArgs
* @param {external:jQuery} initArgs.$
* @param {module:SVGEditor~ImportLocale} initArgs.importLocale
*/
/** /**
* Add an extension to the editor. * Add an extension to the editor.
* @function module:svgcanvas.SvgCanvas#addExtension * @function module:svgcanvas.SvgCanvas#addExtension
* @param {string} name - String with the ID of the extension. Used internally; no need for i18n. * @param {string} name - String with the ID of the extension. Used internally; no need for i18n.
* @param {module:svgcanvas.ExtensionInitCallback} [extInitFunc] - Function supplied by the extension with its data * @param {module:svgcanvas.ExtensionInitCallback} [extInitFunc] - Function supplied by the extension with its data
* @param {module:SVGEditor~ImportLocale} importLocale * @param {module:svgcanvas.ExtensionInitArgs} initArgs
* @fires module:svgcanvas.SvgCanvas#event:extension_added * @fires module:svgcanvas.SvgCanvas#event:extension_added
* @throws {TypeError|Error} `TypeError` if `extInitFunc` is not a function, `Error` * @throws {TypeError|Error} `TypeError` if `extInitFunc` is not a function, `Error`
* if extension of supplied name already exists * if extension of supplied name already exists
@@ -14618,30 +14624,32 @@ function SvgCanvas(container, config) {
this.addExtension = this.addExtension =
/*#__PURE__*/ /*#__PURE__*/
function () { function () {
var _ref3 = _asyncToGenerator( var _ref4 = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee(name, extInitFunc, importLocale) { regeneratorRuntime.mark(function _callee(name, extInitFunc, _ref3) {
var argObj, extObj; var jq, importLocale, argObj, extObj;
return regeneratorRuntime.wrap(function _callee$(_context) { return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) { while (1) {
switch (_context.prev = _context.next) { switch (_context.prev = _context.next) {
case 0: case 0:
jq = _ref3.$, importLocale = _ref3.importLocale;
if (!(typeof extInitFunc !== 'function')) { if (!(typeof extInitFunc !== 'function')) {
_context.next = 2; _context.next = 3;
break; break;
} }
throw new TypeError('Function argument expected for `svgcanvas.addExtension`'); throw new TypeError('Function argument expected for `svgcanvas.addExtension`');
case 2: case 3:
if (!(name in extensions)) { if (!(name in extensions)) {
_context.next = 4; _context.next = 5;
break; break;
} }
throw new Error('Cannot add extension "' + name + '", an extension by that name already exists.'); throw new Error('Cannot add extension "' + name + '", an extension by that name already exists.');
case 4: case 5:
// Provide private vars/funcs here. Is there a better way to do this? // Provide private vars/funcs here. Is there a better way to do this?
/** /**
@@ -14658,17 +14666,17 @@ function SvgCanvas(container, config) {
* @see {@link module:svgcanvas.PrivateMethods} source for the other methods/properties * @see {@link module:svgcanvas.PrivateMethods} source for the other methods/properties
*/ */
argObj = $$9.extend(canvas.getPrivateMethods(), { argObj = $$9.extend(canvas.getPrivateMethods(), {
$: $$9, $: jq,
importLocale: importLocale, importLocale: importLocale,
svgroot: svgroot, svgroot: svgroot,
svgcontent: svgcontent, svgcontent: svgcontent,
nonce: getCurrentDrawing().getNonce(), nonce: getCurrentDrawing().getNonce(),
selectorManager: selectorManager selectorManager: selectorManager
}); });
_context.next = 7; _context.next = 8;
return extInitFunc(argObj); return extInitFunc(argObj);
case 7: case 8:
extObj = _context.sent; extObj = _context.sent;
if (extObj) { if (extObj) {
@@ -14678,7 +14686,7 @@ function SvgCanvas(container, config) {
extensions[name] = extObj; extensions[name] = extObj;
return _context.abrupt("return", call('extension_added', extObj)); return _context.abrupt("return", call('extension_added', extObj));
case 11: case 12:
case "end": case "end":
return _context.stop(); return _context.stop();
} }
@@ -14687,7 +14695,7 @@ function SvgCanvas(container, config) {
})); }));
return function (_x, _x2, _x3) { return function (_x, _x2, _x3) {
return _ref3.apply(this, arguments); return _ref4.apply(this, arguments);
}; };
}(); }();
/** /**
@@ -17802,7 +17810,7 @@ function SvgCanvas(container, config) {
this.rasterExport = this.rasterExport =
/*#__PURE__*/ /*#__PURE__*/
function () { function () {
var _ref4 = _asyncToGenerator( var _ref5 = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee2(imgType, quality, exportWindowName) { regeneratorRuntime.mark(function _callee2(imgType, quality, exportWindowName) {
var opts, var opts,
@@ -17812,7 +17820,7 @@ function SvgCanvas(container, config) {
issues, issues,
issueCodes, issueCodes,
svg, svg,
_ref5, _ref6,
c, c,
_args2 = arguments; _args2 = arguments;
@@ -17837,8 +17845,8 @@ function SvgCanvas(container, config) {
}); });
case 8: case 8:
_ref5 = _context2.sent; _ref6 = _context2.sent;
canvg = _ref5.canvg; canvg = _ref6.canvg;
case 10: case 10:
if (!$$9('#export_canvas').length) { if (!$$9('#export_canvas').length) {
@@ -17905,7 +17913,7 @@ function SvgCanvas(container, config) {
})); }));
return function (_x4, _x5, _x6) { return function (_x4, _x5, _x6) {
return _ref4.apply(this, arguments); return _ref5.apply(this, arguments);
}; };
}(); }();
/** /**
@@ -17950,7 +17958,7 @@ function SvgCanvas(container, config) {
this.exportPDF = this.exportPDF =
/*#__PURE__*/ /*#__PURE__*/
function () { function () {
var _ref6 = _asyncToGenerator( var _ref7 = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee3(exportWindowName) { regeneratorRuntime.mark(function _callee3(exportWindowName) {
var outputType, var outputType,
@@ -18041,7 +18049,7 @@ function SvgCanvas(container, config) {
})); }));
return function (_x7) { return function (_x7) {
return _ref6.apply(this, arguments); return _ref7.apply(this, arguments);
}; };
}(); }();
/** /**
@@ -18750,10 +18758,10 @@ function SvgCanvas(container, config) {
leaveContext: leaveContext, leaveContext: leaveContext,
setContext: setContext setContext: setContext
}; };
Object.entries(dr).forEach(function (_ref7) { Object.entries(dr).forEach(function (_ref8) {
var _ref8 = _slicedToArray(_ref7, 2), var _ref9 = _slicedToArray(_ref8, 2),
prop = _ref8[0], prop = _ref9[0],
propVal = _ref8[1]; propVal = _ref9[1];
canvas[prop] = propVal; canvas[prop] = propVal;
}); });
@@ -28959,7 +28967,7 @@ editor.loadContentAndPrefs = function () {
if (editor.storage && ( // Cookies do not have enough available memory to hold large documents if (editor.storage && ( // Cookies do not have enough available memory to hold large documents
curConfig.forceStorage || !curConfig.noStorageOnLoad && document.cookie.match(/(?:^|;\s*)svgeditstorestore=prefsAndContent/))) { curConfig.forceStorage || !curConfig.noStorageOnLoad && document.cookie.match(/(?:^|;\s*)svgeditstore=prefsAndContent/))) {
var name = 'svgedit-' + curConfig.canvasName; var name = 'svgedit-' + curConfig.canvasName;
var cached = editor.storage.getItem(name); var cached = editor.storage.getItem(name);
@@ -36341,13 +36349,13 @@ editor.loadFromDataURI = function (str) {
/** /**
* @param {string} name Used internally; no need for i18n. * @param {string} name Used internally; no need for i18n.
* @param {module:svgcanvas.ExtensionInitCallback} init Config to be invoked on this module * @param {module:svgcanvas.ExtensionInitCallback} init Config to be invoked on this module
* @param {module:SVGEditor~ImportLocale} importLocale Importer defaulting to pth with current extension name and locale * @param {module:svgcanvas.ExtensionInitArgs} initArgs
* @throws {Error} If called too early * @throws {Error} If called too early
* @returns {Promise} Resolves to `undefined` * @returns {Promise} Resolves to `undefined`
*/ */
editor.addExtension = function (name, init$$1, importLocale) { editor.addExtension = function (name, init$$1, initArgs) {
// Note that we don't want this on editor.ready since some extensions // Note that we don't want this on editor.ready since some extensions
// may want to run before then (like server_opensave). // may want to run before then (like server_opensave).
// $(function () { // $(function () {
@@ -36355,7 +36363,7 @@ editor.addExtension = function (name, init$$1, importLocale) {
throw new Error('Extension added too early'); throw new Error('Extension added too early');
} }
return svgCanvas.addExtension.call(this, name, init$$1, importLocale); // }); return svgCanvas.addExtension.call(this, name, init$$1, initArgs); // });
}; // Defer injection to wait out initial menu processing. This probably goes }; // Defer injection to wait out initial menu processing. This probably goes
// away once all context menu behavior is brought to context menu. // away once all context menu behavior is brought to context menu.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

64
dist/index-umd.js vendored
View File

@@ -14608,12 +14608,18 @@
* @returns {Promise} Resolves to [ExtensionInitResponse]{@link module:svgcanvas.ExtensionInitResponse} or `undefined` * @returns {Promise} Resolves to [ExtensionInitResponse]{@link module:svgcanvas.ExtensionInitResponse} or `undefined`
*/ */
/**
* @typedef {PlainObject} module:svgcanvas.ExtensionInitArgs
* @param {external:jQuery} initArgs.$
* @param {module:SVGEditor~ImportLocale} initArgs.importLocale
*/
/** /**
* Add an extension to the editor. * Add an extension to the editor.
* @function module:svgcanvas.SvgCanvas#addExtension * @function module:svgcanvas.SvgCanvas#addExtension
* @param {string} name - String with the ID of the extension. Used internally; no need for i18n. * @param {string} name - String with the ID of the extension. Used internally; no need for i18n.
* @param {module:svgcanvas.ExtensionInitCallback} [extInitFunc] - Function supplied by the extension with its data * @param {module:svgcanvas.ExtensionInitCallback} [extInitFunc] - Function supplied by the extension with its data
* @param {module:SVGEditor~ImportLocale} importLocale * @param {module:svgcanvas.ExtensionInitArgs} initArgs
* @fires module:svgcanvas.SvgCanvas#event:extension_added * @fires module:svgcanvas.SvgCanvas#event:extension_added
* @throws {TypeError|Error} `TypeError` if `extInitFunc` is not a function, `Error` * @throws {TypeError|Error} `TypeError` if `extInitFunc` is not a function, `Error`
* if extension of supplied name already exists * if extension of supplied name already exists
@@ -14624,30 +14630,32 @@
this.addExtension = this.addExtension =
/*#__PURE__*/ /*#__PURE__*/
function () { function () {
var _ref3 = _asyncToGenerator( var _ref4 = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee(name, extInitFunc, importLocale) { regeneratorRuntime.mark(function _callee(name, extInitFunc, _ref3) {
var argObj, extObj; var jq, importLocale, argObj, extObj;
return regeneratorRuntime.wrap(function _callee$(_context) { return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) { while (1) {
switch (_context.prev = _context.next) { switch (_context.prev = _context.next) {
case 0: case 0:
jq = _ref3.$, importLocale = _ref3.importLocale;
if (!(typeof extInitFunc !== 'function')) { if (!(typeof extInitFunc !== 'function')) {
_context.next = 2; _context.next = 3;
break; break;
} }
throw new TypeError('Function argument expected for `svgcanvas.addExtension`'); throw new TypeError('Function argument expected for `svgcanvas.addExtension`');
case 2: case 3:
if (!(name in extensions)) { if (!(name in extensions)) {
_context.next = 4; _context.next = 5;
break; break;
} }
throw new Error('Cannot add extension "' + name + '", an extension by that name already exists.'); throw new Error('Cannot add extension "' + name + '", an extension by that name already exists.');
case 4: case 5:
// Provide private vars/funcs here. Is there a better way to do this? // Provide private vars/funcs here. Is there a better way to do this?
/** /**
@@ -14664,17 +14672,17 @@
* @see {@link module:svgcanvas.PrivateMethods} source for the other methods/properties * @see {@link module:svgcanvas.PrivateMethods} source for the other methods/properties
*/ */
argObj = $$9.extend(canvas.getPrivateMethods(), { argObj = $$9.extend(canvas.getPrivateMethods(), {
$: $$9, $: jq,
importLocale: importLocale, importLocale: importLocale,
svgroot: svgroot, svgroot: svgroot,
svgcontent: svgcontent, svgcontent: svgcontent,
nonce: getCurrentDrawing().getNonce(), nonce: getCurrentDrawing().getNonce(),
selectorManager: selectorManager selectorManager: selectorManager
}); });
_context.next = 7; _context.next = 8;
return extInitFunc(argObj); return extInitFunc(argObj);
case 7: case 8:
extObj = _context.sent; extObj = _context.sent;
if (extObj) { if (extObj) {
@@ -14684,7 +14692,7 @@
extensions[name] = extObj; extensions[name] = extObj;
return _context.abrupt("return", call('extension_added', extObj)); return _context.abrupt("return", call('extension_added', extObj));
case 11: case 12:
case "end": case "end":
return _context.stop(); return _context.stop();
} }
@@ -14693,7 +14701,7 @@
})); }));
return function (_x, _x2, _x3) { return function (_x, _x2, _x3) {
return _ref3.apply(this, arguments); return _ref4.apply(this, arguments);
}; };
}(); }();
/** /**
@@ -17808,7 +17816,7 @@
this.rasterExport = this.rasterExport =
/*#__PURE__*/ /*#__PURE__*/
function () { function () {
var _ref4 = _asyncToGenerator( var _ref5 = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee2(imgType, quality, exportWindowName) { regeneratorRuntime.mark(function _callee2(imgType, quality, exportWindowName) {
var opts, var opts,
@@ -17818,7 +17826,7 @@
issues, issues,
issueCodes, issueCodes,
svg, svg,
_ref5, _ref6,
c, c,
_args2 = arguments; _args2 = arguments;
@@ -17843,8 +17851,8 @@
}); });
case 8: case 8:
_ref5 = _context2.sent; _ref6 = _context2.sent;
canvg = _ref5.canvg; canvg = _ref6.canvg;
case 10: case 10:
if (!$$9('#export_canvas').length) { if (!$$9('#export_canvas').length) {
@@ -17911,7 +17919,7 @@
})); }));
return function (_x4, _x5, _x6) { return function (_x4, _x5, _x6) {
return _ref4.apply(this, arguments); return _ref5.apply(this, arguments);
}; };
}(); }();
/** /**
@@ -17956,7 +17964,7 @@
this.exportPDF = this.exportPDF =
/*#__PURE__*/ /*#__PURE__*/
function () { function () {
var _ref6 = _asyncToGenerator( var _ref7 = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee3(exportWindowName) { regeneratorRuntime.mark(function _callee3(exportWindowName) {
var outputType, var outputType,
@@ -18047,7 +18055,7 @@
})); }));
return function (_x7) { return function (_x7) {
return _ref6.apply(this, arguments); return _ref7.apply(this, arguments);
}; };
}(); }();
/** /**
@@ -18756,10 +18764,10 @@
leaveContext: leaveContext, leaveContext: leaveContext,
setContext: setContext setContext: setContext
}; };
Object.entries(dr).forEach(function (_ref7) { Object.entries(dr).forEach(function (_ref8) {
var _ref8 = _slicedToArray(_ref7, 2), var _ref9 = _slicedToArray(_ref8, 2),
prop = _ref8[0], prop = _ref9[0],
propVal = _ref8[1]; propVal = _ref9[1];
canvas[prop] = propVal; canvas[prop] = propVal;
}); });
@@ -28965,7 +28973,7 @@
if (editor.storage && ( // Cookies do not have enough available memory to hold large documents if (editor.storage && ( // Cookies do not have enough available memory to hold large documents
curConfig.forceStorage || !curConfig.noStorageOnLoad && document.cookie.match(/(?:^|;\s*)svgeditstorestore=prefsAndContent/))) { curConfig.forceStorage || !curConfig.noStorageOnLoad && document.cookie.match(/(?:^|;\s*)svgeditstore=prefsAndContent/))) {
var name = 'svgedit-' + curConfig.canvasName; var name = 'svgedit-' + curConfig.canvasName;
var cached = editor.storage.getItem(name); var cached = editor.storage.getItem(name);
@@ -36347,13 +36355,13 @@
/** /**
* @param {string} name Used internally; no need for i18n. * @param {string} name Used internally; no need for i18n.
* @param {module:svgcanvas.ExtensionInitCallback} init Config to be invoked on this module * @param {module:svgcanvas.ExtensionInitCallback} init Config to be invoked on this module
* @param {module:SVGEditor~ImportLocale} importLocale Importer defaulting to pth with current extension name and locale * @param {module:svgcanvas.ExtensionInitArgs} initArgs
* @throws {Error} If called too early * @throws {Error} If called too early
* @returns {Promise} Resolves to `undefined` * @returns {Promise} Resolves to `undefined`
*/ */
editor.addExtension = function (name, init$$1, importLocale) { editor.addExtension = function (name, init$$1, initArgs) {
// Note that we don't want this on editor.ready since some extensions // Note that we don't want this on editor.ready since some extensions
// may want to run before then (like server_opensave). // may want to run before then (like server_opensave).
// $(function () { // $(function () {
@@ -36361,7 +36369,7 @@
throw new Error('Extension added too early'); throw new Error('Extension added too early');
} }
return svgCanvas.addExtension.call(this, name, init$$1, importLocale); // }); return svgCanvas.addExtension.call(this, name, init$$1, initArgs); // });
}; // Defer injection to wait out initial menu processing. This probably goes }; // Defer injection to wait out initial menu processing. This probably goes
// away once all context menu behavior is brought to context menu. // away once all context menu behavior is brought to context menu.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -435,7 +435,7 @@ editor.loadContentAndPrefs = function () {
if (editor.storage && // Cookies do not have enough available memory to hold large documents if (editor.storage && // Cookies do not have enough available memory to hold large documents
(curConfig.forceStorage || (curConfig.forceStorage ||
(!curConfig.noStorageOnLoad && (!curConfig.noStorageOnLoad &&
document.cookie.match(/(?:^|;\s*)svgeditstorestore=prefsAndContent/)) document.cookie.match(/(?:^|;\s*)svgeditstore=prefsAndContent/))
) )
) { ) {
const name = 'svgedit-' + curConfig.canvasName; const name = 'svgedit-' + curConfig.canvasName;

View File

@@ -14605,12 +14605,18 @@
* @returns {Promise} Resolves to [ExtensionInitResponse]{@link module:svgcanvas.ExtensionInitResponse} or `undefined` * @returns {Promise} Resolves to [ExtensionInitResponse]{@link module:svgcanvas.ExtensionInitResponse} or `undefined`
*/ */
/**
* @typedef {PlainObject} module:svgcanvas.ExtensionInitArgs
* @param {external:jQuery} initArgs.$
* @param {module:SVGEditor~ImportLocale} initArgs.importLocale
*/
/** /**
* Add an extension to the editor. * Add an extension to the editor.
* @function module:svgcanvas.SvgCanvas#addExtension * @function module:svgcanvas.SvgCanvas#addExtension
* @param {string} name - String with the ID of the extension. Used internally; no need for i18n. * @param {string} name - String with the ID of the extension. Used internally; no need for i18n.
* @param {module:svgcanvas.ExtensionInitCallback} [extInitFunc] - Function supplied by the extension with its data * @param {module:svgcanvas.ExtensionInitCallback} [extInitFunc] - Function supplied by the extension with its data
* @param {module:SVGEditor~ImportLocale} importLocale * @param {module:svgcanvas.ExtensionInitArgs} initArgs
* @fires module:svgcanvas.SvgCanvas#event:extension_added * @fires module:svgcanvas.SvgCanvas#event:extension_added
* @throws {TypeError|Error} `TypeError` if `extInitFunc` is not a function, `Error` * @throws {TypeError|Error} `TypeError` if `extInitFunc` is not a function, `Error`
* if extension of supplied name already exists * if extension of supplied name already exists
@@ -14621,30 +14627,32 @@
this.addExtension = this.addExtension =
/*#__PURE__*/ /*#__PURE__*/
function () { function () {
var _ref3 = _asyncToGenerator( var _ref4 = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee(name, extInitFunc, importLocale) { regeneratorRuntime.mark(function _callee(name, extInitFunc, _ref3) {
var argObj, extObj; var jq, importLocale, argObj, extObj;
return regeneratorRuntime.wrap(function _callee$(_context) { return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) { while (1) {
switch (_context.prev = _context.next) { switch (_context.prev = _context.next) {
case 0: case 0:
jq = _ref3.$, importLocale = _ref3.importLocale;
if (!(typeof extInitFunc !== 'function')) { if (!(typeof extInitFunc !== 'function')) {
_context.next = 2; _context.next = 3;
break; break;
} }
throw new TypeError('Function argument expected for `svgcanvas.addExtension`'); throw new TypeError('Function argument expected for `svgcanvas.addExtension`');
case 2: case 3:
if (!(name in extensions)) { if (!(name in extensions)) {
_context.next = 4; _context.next = 5;
break; break;
} }
throw new Error('Cannot add extension "' + name + '", an extension by that name already exists.'); throw new Error('Cannot add extension "' + name + '", an extension by that name already exists.');
case 4: case 5:
// Provide private vars/funcs here. Is there a better way to do this? // Provide private vars/funcs here. Is there a better way to do this?
/** /**
@@ -14661,17 +14669,17 @@
* @see {@link module:svgcanvas.PrivateMethods} source for the other methods/properties * @see {@link module:svgcanvas.PrivateMethods} source for the other methods/properties
*/ */
argObj = $$9.extend(canvas.getPrivateMethods(), { argObj = $$9.extend(canvas.getPrivateMethods(), {
$: $$9, $: jq,
importLocale: importLocale, importLocale: importLocale,
svgroot: svgroot, svgroot: svgroot,
svgcontent: svgcontent, svgcontent: svgcontent,
nonce: getCurrentDrawing().getNonce(), nonce: getCurrentDrawing().getNonce(),
selectorManager: selectorManager selectorManager: selectorManager
}); });
_context.next = 7; _context.next = 8;
return extInitFunc(argObj); return extInitFunc(argObj);
case 7: case 8:
extObj = _context.sent; extObj = _context.sent;
if (extObj) { if (extObj) {
@@ -14681,7 +14689,7 @@
extensions[name] = extObj; extensions[name] = extObj;
return _context.abrupt("return", call('extension_added', extObj)); return _context.abrupt("return", call('extension_added', extObj));
case 11: case 12:
case "end": case "end":
return _context.stop(); return _context.stop();
} }
@@ -14690,7 +14698,7 @@
})); }));
return function (_x, _x2, _x3) { return function (_x, _x2, _x3) {
return _ref3.apply(this, arguments); return _ref4.apply(this, arguments);
}; };
}(); }();
/** /**
@@ -17805,7 +17813,7 @@
this.rasterExport = this.rasterExport =
/*#__PURE__*/ /*#__PURE__*/
function () { function () {
var _ref4 = _asyncToGenerator( var _ref5 = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee2(imgType, quality, exportWindowName) { regeneratorRuntime.mark(function _callee2(imgType, quality, exportWindowName) {
var opts, var opts,
@@ -17815,7 +17823,7 @@
issues, issues,
issueCodes, issueCodes,
svg, svg,
_ref5, _ref6,
c, c,
_args2 = arguments; _args2 = arguments;
@@ -17840,8 +17848,8 @@
}); });
case 8: case 8:
_ref5 = _context2.sent; _ref6 = _context2.sent;
canvg = _ref5.canvg; canvg = _ref6.canvg;
case 10: case 10:
if (!$$9('#export_canvas').length) { if (!$$9('#export_canvas').length) {
@@ -17908,7 +17916,7 @@
})); }));
return function (_x4, _x5, _x6) { return function (_x4, _x5, _x6) {
return _ref4.apply(this, arguments); return _ref5.apply(this, arguments);
}; };
}(); }();
/** /**
@@ -17953,7 +17961,7 @@
this.exportPDF = this.exportPDF =
/*#__PURE__*/ /*#__PURE__*/
function () { function () {
var _ref6 = _asyncToGenerator( var _ref7 = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee3(exportWindowName) { regeneratorRuntime.mark(function _callee3(exportWindowName) {
var outputType, var outputType,
@@ -18044,7 +18052,7 @@
})); }));
return function (_x7) { return function (_x7) {
return _ref6.apply(this, arguments); return _ref7.apply(this, arguments);
}; };
}(); }();
/** /**
@@ -18753,10 +18761,10 @@
leaveContext: leaveContext, leaveContext: leaveContext,
setContext: setContext setContext: setContext
}; };
Object.entries(dr).forEach(function (_ref7) { Object.entries(dr).forEach(function (_ref8) {
var _ref8 = _slicedToArray(_ref7, 2), var _ref9 = _slicedToArray(_ref8, 2),
prop = _ref8[0], prop = _ref9[0],
propVal = _ref8[1]; propVal = _ref9[1];
canvas[prop] = propVal; canvas[prop] = propVal;
}); });
@@ -28962,7 +28970,7 @@
if (editor.storage && ( // Cookies do not have enough available memory to hold large documents if (editor.storage && ( // Cookies do not have enough available memory to hold large documents
curConfig.forceStorage || !curConfig.noStorageOnLoad && document.cookie.match(/(?:^|;\s*)svgeditstorestore=prefsAndContent/))) { curConfig.forceStorage || !curConfig.noStorageOnLoad && document.cookie.match(/(?:^|;\s*)svgeditstore=prefsAndContent/))) {
var name = 'svgedit-' + curConfig.canvasName; var name = 'svgedit-' + curConfig.canvasName;
var cached = editor.storage.getItem(name); var cached = editor.storage.getItem(name);
@@ -36344,13 +36352,13 @@
/** /**
* @param {string} name Used internally; no need for i18n. * @param {string} name Used internally; no need for i18n.
* @param {module:svgcanvas.ExtensionInitCallback} init Config to be invoked on this module * @param {module:svgcanvas.ExtensionInitCallback} init Config to be invoked on this module
* @param {module:SVGEditor~ImportLocale} importLocale Importer defaulting to pth with current extension name and locale * @param {module:svgcanvas.ExtensionInitArgs} initArgs
* @throws {Error} If called too early * @throws {Error} If called too early
* @returns {Promise} Resolves to `undefined` * @returns {Promise} Resolves to `undefined`
*/ */
editor.addExtension = function (name, init$$1, importLocale) { editor.addExtension = function (name, init$$1, initArgs) {
// Note that we don't want this on editor.ready since some extensions // Note that we don't want this on editor.ready since some extensions
// may want to run before then (like server_opensave). // may want to run before then (like server_opensave).
// $(function () { // $(function () {
@@ -36358,7 +36366,7 @@
throw new Error('Extension added too early'); throw new Error('Extension added too early');
} }
return svgCanvas.addExtension.call(this, name, init$$1, importLocale); // }); return svgCanvas.addExtension.call(this, name, init$$1, initArgs); // });
}; // Defer injection to wait out initial menu processing. This probably goes }; // Defer injection to wait out initial menu processing. This probably goes
// away once all context menu behavior is brought to context menu. // away once all context menu behavior is brought to context menu.

View File

@@ -14605,12 +14605,18 @@
* @returns {Promise} Resolves to [ExtensionInitResponse]{@link module:svgcanvas.ExtensionInitResponse} or `undefined` * @returns {Promise} Resolves to [ExtensionInitResponse]{@link module:svgcanvas.ExtensionInitResponse} or `undefined`
*/ */
/**
* @typedef {PlainObject} module:svgcanvas.ExtensionInitArgs
* @param {external:jQuery} initArgs.$
* @param {module:SVGEditor~ImportLocale} initArgs.importLocale
*/
/** /**
* Add an extension to the editor. * Add an extension to the editor.
* @function module:svgcanvas.SvgCanvas#addExtension * @function module:svgcanvas.SvgCanvas#addExtension
* @param {string} name - String with the ID of the extension. Used internally; no need for i18n. * @param {string} name - String with the ID of the extension. Used internally; no need for i18n.
* @param {module:svgcanvas.ExtensionInitCallback} [extInitFunc] - Function supplied by the extension with its data * @param {module:svgcanvas.ExtensionInitCallback} [extInitFunc] - Function supplied by the extension with its data
* @param {module:SVGEditor~ImportLocale} importLocale * @param {module:svgcanvas.ExtensionInitArgs} initArgs
* @fires module:svgcanvas.SvgCanvas#event:extension_added * @fires module:svgcanvas.SvgCanvas#event:extension_added
* @throws {TypeError|Error} `TypeError` if `extInitFunc` is not a function, `Error` * @throws {TypeError|Error} `TypeError` if `extInitFunc` is not a function, `Error`
* if extension of supplied name already exists * if extension of supplied name already exists
@@ -14621,30 +14627,32 @@
this.addExtension = this.addExtension =
/*#__PURE__*/ /*#__PURE__*/
function () { function () {
var _ref3 = _asyncToGenerator( var _ref4 = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee(name, extInitFunc, importLocale) { regeneratorRuntime.mark(function _callee(name, extInitFunc, _ref3) {
var argObj, extObj; var jq, importLocale, argObj, extObj;
return regeneratorRuntime.wrap(function _callee$(_context) { return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) { while (1) {
switch (_context.prev = _context.next) { switch (_context.prev = _context.next) {
case 0: case 0:
jq = _ref3.$, importLocale = _ref3.importLocale;
if (!(typeof extInitFunc !== 'function')) { if (!(typeof extInitFunc !== 'function')) {
_context.next = 2; _context.next = 3;
break; break;
} }
throw new TypeError('Function argument expected for `svgcanvas.addExtension`'); throw new TypeError('Function argument expected for `svgcanvas.addExtension`');
case 2: case 3:
if (!(name in extensions)) { if (!(name in extensions)) {
_context.next = 4; _context.next = 5;
break; break;
} }
throw new Error('Cannot add extension "' + name + '", an extension by that name already exists.'); throw new Error('Cannot add extension "' + name + '", an extension by that name already exists.');
case 4: case 5:
// Provide private vars/funcs here. Is there a better way to do this? // Provide private vars/funcs here. Is there a better way to do this?
/** /**
@@ -14661,17 +14669,17 @@
* @see {@link module:svgcanvas.PrivateMethods} source for the other methods/properties * @see {@link module:svgcanvas.PrivateMethods} source for the other methods/properties
*/ */
argObj = $$9.extend(canvas.getPrivateMethods(), { argObj = $$9.extend(canvas.getPrivateMethods(), {
$: $$9, $: jq,
importLocale: importLocale, importLocale: importLocale,
svgroot: svgroot, svgroot: svgroot,
svgcontent: svgcontent, svgcontent: svgcontent,
nonce: getCurrentDrawing().getNonce(), nonce: getCurrentDrawing().getNonce(),
selectorManager: selectorManager selectorManager: selectorManager
}); });
_context.next = 7; _context.next = 8;
return extInitFunc(argObj); return extInitFunc(argObj);
case 7: case 8:
extObj = _context.sent; extObj = _context.sent;
if (extObj) { if (extObj) {
@@ -14681,7 +14689,7 @@
extensions[name] = extObj; extensions[name] = extObj;
return _context.abrupt("return", call('extension_added', extObj)); return _context.abrupt("return", call('extension_added', extObj));
case 11: case 12:
case "end": case "end":
return _context.stop(); return _context.stop();
} }
@@ -14690,7 +14698,7 @@
})); }));
return function (_x, _x2, _x3) { return function (_x, _x2, _x3) {
return _ref3.apply(this, arguments); return _ref4.apply(this, arguments);
}; };
}(); }();
/** /**
@@ -17805,7 +17813,7 @@
this.rasterExport = this.rasterExport =
/*#__PURE__*/ /*#__PURE__*/
function () { function () {
var _ref4 = _asyncToGenerator( var _ref5 = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee2(imgType, quality, exportWindowName) { regeneratorRuntime.mark(function _callee2(imgType, quality, exportWindowName) {
var opts, var opts,
@@ -17815,7 +17823,7 @@
issues, issues,
issueCodes, issueCodes,
svg, svg,
_ref5, _ref6,
c, c,
_args2 = arguments; _args2 = arguments;
@@ -17840,8 +17848,8 @@
}); });
case 8: case 8:
_ref5 = _context2.sent; _ref6 = _context2.sent;
canvg = _ref5.canvg; canvg = _ref6.canvg;
case 10: case 10:
if (!$$9('#export_canvas').length) { if (!$$9('#export_canvas').length) {
@@ -17908,7 +17916,7 @@
})); }));
return function (_x4, _x5, _x6) { return function (_x4, _x5, _x6) {
return _ref4.apply(this, arguments); return _ref5.apply(this, arguments);
}; };
}(); }();
/** /**
@@ -17953,7 +17961,7 @@
this.exportPDF = this.exportPDF =
/*#__PURE__*/ /*#__PURE__*/
function () { function () {
var _ref6 = _asyncToGenerator( var _ref7 = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee3(exportWindowName) { regeneratorRuntime.mark(function _callee3(exportWindowName) {
var outputType, var outputType,
@@ -18044,7 +18052,7 @@
})); }));
return function (_x7) { return function (_x7) {
return _ref6.apply(this, arguments); return _ref7.apply(this, arguments);
}; };
}(); }();
/** /**
@@ -18753,10 +18761,10 @@
leaveContext: leaveContext, leaveContext: leaveContext,
setContext: setContext setContext: setContext
}; };
Object.entries(dr).forEach(function (_ref7) { Object.entries(dr).forEach(function (_ref8) {
var _ref8 = _slicedToArray(_ref7, 2), var _ref9 = _slicedToArray(_ref8, 2),
prop = _ref8[0], prop = _ref9[0],
propVal = _ref8[1]; propVal = _ref9[1];
canvas[prop] = propVal; canvas[prop] = propVal;
}); });
@@ -28962,7 +28970,7 @@
if (editor.storage && ( // Cookies do not have enough available memory to hold large documents if (editor.storage && ( // Cookies do not have enough available memory to hold large documents
curConfig.forceStorage || !curConfig.noStorageOnLoad && document.cookie.match(/(?:^|;\s*)svgeditstorestore=prefsAndContent/))) { curConfig.forceStorage || !curConfig.noStorageOnLoad && document.cookie.match(/(?:^|;\s*)svgeditstore=prefsAndContent/))) {
var name = 'svgedit-' + curConfig.canvasName; var name = 'svgedit-' + curConfig.canvasName;
var cached = editor.storage.getItem(name); var cached = editor.storage.getItem(name);
@@ -36344,13 +36352,13 @@
/** /**
* @param {string} name Used internally; no need for i18n. * @param {string} name Used internally; no need for i18n.
* @param {module:svgcanvas.ExtensionInitCallback} init Config to be invoked on this module * @param {module:svgcanvas.ExtensionInitCallback} init Config to be invoked on this module
* @param {module:SVGEditor~ImportLocale} importLocale Importer defaulting to pth with current extension name and locale * @param {module:svgcanvas.ExtensionInitArgs} initArgs
* @throws {Error} If called too early * @throws {Error} If called too early
* @returns {Promise} Resolves to `undefined` * @returns {Promise} Resolves to `undefined`
*/ */
editor.addExtension = function (name, init$$1, importLocale) { editor.addExtension = function (name, init$$1, initArgs) {
// Note that we don't want this on editor.ready since some extensions // Note that we don't want this on editor.ready since some extensions
// may want to run before then (like server_opensave). // may want to run before then (like server_opensave).
// $(function () { // $(function () {
@@ -36358,7 +36366,7 @@
throw new Error('Extension added too early'); throw new Error('Extension added too early');
} }
return svgCanvas.addExtension.call(this, name, init$$1, importLocale); // }); return svgCanvas.addExtension.call(this, name, init$$1, initArgs); // });
}; // Defer injection to wait out initial menu processing. This probably goes }; // Defer injection to wait out initial menu processing. This probably goes
// away once all context menu behavior is brought to context menu. // away once all context menu behavior is brought to context menu.