- Refactoring: Reduce BBQ dependency (not yet removable as used still in svgeditor)

master
Brett Zamir 2020-01-05 10:32:31 +08:00
parent 56197a493c
commit d0d7efabc4
12 changed files with 606 additions and 613 deletions

View File

@ -4909,15 +4909,15 @@ var svgEditorExtension_server_moinsave = (function () {
var _save = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(win, data) {
var svg, qstr, _qstr$substr$split, _qstr$substr$split2, name, svgData, c, datauri, pngData;
var svg, _ref2, pathname, name, svgData, c, datauri, pngData;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
svg = '<?xml version="1.0"?>\n' + data;
qstr = $.param.querystring();
_qstr$substr$split = qstr.substr(9).split('/+get/'), _qstr$substr$split2 = _slicedToArray(_qstr$substr$split, 2), name = _qstr$substr$split2[1];
_ref2 = new URL(location), pathname = _ref2.pathname;
name = pathname.replace(/\/+get\//, '');
svgData = encode64(svg);
if (!$('#export_canvas').length) {

View File

@ -89,15 +89,13 @@ var svgEditorExtension_storage = (function () {
* The functionality was originally part of the SVG Editor, but moved to a
* separate extension to make the setting behavior optional, and adapted
* to inform the user of its setting of local data.
* Dependencies:
*
* 1. jQuery BBQ (for deparam)
* @license MIT
*
* @copyright 2010 Brett Zamir
* @todo Revisit on whether to use $.pref over directly setting curConfig in all
* extensions for a more public API (not only for extPath and imagePath,
* but other currently used config in the extensions)
* @todo Revisit on whether to use `svgEditor.pref` over directly setting
* `curConfig` in all extensions for a more public API (not only for `extPath`
* and `imagePath`, but other currently used config in the extensions)
* @todo We might provide control of storage settings through the UI besides the
* initial (or URL-forced) dialog. *
*/
@ -122,6 +120,7 @@ var svgEditorExtension_storage = (function () {
* Replace `storagePrompt` parameter within URL.
* @param {string} val
* @returns {void}
* @todo Replace the string manipulation with `searchParams.set`
*/
function replaceStoragePrompt(val) {
@ -257,14 +256,14 @@ var svgEditorExtension_storage = (function () {
var _langReady = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee(_ref4) {
var importLocale, _$$deparam$querystrin, storagePrompt, confirmSetStorage, message, storagePrefsAndContent, storagePrefsOnly, storagePrefs, storageNoPrefsOrContent, storageNoPrefs, rememberLabel, rememberTooltip, options, oldContainerWidth, oldContainerMarginLeft, oldContentHeight, oldContainerHeight, _ref5, pref, checked;
var importLocale, storagePrompt, confirmSetStorage, message, storagePrefsAndContent, storagePrefsOnly, storagePrefs, storageNoPrefsOrContent, storageNoPrefs, rememberLabel, rememberTooltip, options, oldContainerWidth, oldContainerMarginLeft, oldContentHeight, oldContainerHeight, _ref5, pref, checked;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
importLocale = _ref4.importLocale;
_$$deparam$querystrin = $.deparam.querystring(true), storagePrompt = _$$deparam$querystrin.storagePrompt;
storagePrompt = new URL(top.location).searchParams.get('storagePrompt');
_context.next = 4;
return importLocale();
@ -289,11 +288,11 @@ var svgEditorExtension_storage = (function () {
if (!(!forceStorage && ( // If the URL has been explicitly set to always prompt the
// user (e.g., so one can be pointed to a URL where one
// can alter one's settings, say to prevent future storage)...
storagePrompt === true || // ...or...if the URL at least doesn't explicitly prevent a
storagePrompt === 'true' || // ...or...if the URL at least doesn't explicitly prevent a
// storage prompt (as we use for users who
// don't want to set cookies at all but who don't want
// continual prompts about it)...
storagePrompt !== false && // ...and this user hasn't previously indicated a desire for storage
storagePrompt !== 'false' && // ...and this user hasn't previously indicated a desire for storage
!document.cookie.match(/(?:^|;\s*)svgeditstore=(?:prefsAndContent|prefsOnly)/) // ...then show the storage prompt.
))) {
_context.next = 44;
@ -361,7 +360,7 @@ var svgEditorExtension_storage = (function () {
// 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)) {
if (!(storagePrompt === 'true' && checked)) {
_context.next = 28;
break;
}

279
dist/index-es.js vendored
View File

@ -28615,44 +28615,33 @@ function () {
case 0:
if (givenParam) {
langParam = givenParam;
} else {
langParam = $$a.pref('lang');
} else if (navigator.userLanguage) {
// Explorer
langParam = navigator.userLanguage;
} else if (navigator.language) {
// FF, Opera, ...
langParam = navigator.language;
}
if (!langParam) {
if (navigator.userLanguage) {
// Explorer
langParam = navigator.userLanguage;
} else if (navigator.language) {
// FF, Opera, ...
langParam = navigator.language;
}
}
console.log('Lang: ' + langParam); // eslint-disable-line no-console
// Set to English if language is not in list of good langs
if (!goodLangs.includes(langParam) && langParam !== 'test') {
langParam = 'en';
} // don't bother on first run if language is English
// The following line prevents setLang from running
// extensions which depend on updated uiStrings,
// so commenting it out.
// if (langParam.startsWith('en')) {return;}
console.log('Lang: ' + langParam); // eslint-disable-line no-console
// Set to English if language is not in list of good langs
if (!goodLangs.includes(langParam) && langParam !== 'test') {
langParam = 'en';
}
url = conf.langPath + 'lang.' + langParam + '.js';
_context2.t0 = readLang;
_context2.next = 5;
_context2.next = 7;
return importSetGlobalDefault(url, {
global: 'svgEditorLang_' + langParam.replace(/-/g, '_')
});
case 5:
case 7:
_context2.t1 = _context2.sent;
return _context2.abrupt("return", (0, _context2.t0)(_context2.t1));
case 7:
case 9:
case "end":
return _context2.stop();
}
@ -29152,7 +29141,7 @@ function _loadSvgString() {
_loadSvgString = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee23(str) {
var _ref46,
var _ref47,
noAlert,
success,
_args23 = arguments;
@ -29161,7 +29150,7 @@ function _loadSvgString() {
while (1) {
switch (_context23.prev = _context23.next) {
case 0:
_ref46 = _args23.length > 1 && _args23[1] !== undefined ? _args23[1] : {}, noAlert = _ref46.noAlert;
_ref47 = _args23.length > 1 && _args23[1] !== undefined ? _args23[1] : {}, noAlert = _ref47.noAlert;
success = svgCanvas.setSvgString(str) !== false;
if (!success) {
@ -29273,16 +29262,16 @@ function getImportLocale(_ref) {
* @param {boolean} [mayBeEmpty] If value may be falsey.
* @returns {string|void} If val is missing or falsey and `mayBeEmpty` is not set, the
* value of the previously stored preference will be returned.
* @todo Can we change setting on the jQuery namespace (onto editor) to avoid conflicts?
* @todo Review whether any remaining existing direct references to
* getting `curPrefs` can be changed to use `$.pref()` getting to ensure
* `defaultPrefs` fallback (also for sake of `allowInitialUserOverride`); specifically, `bkgd_color` could be changed so that
* the pref dialog has a button to auto-calculate background, but otherwise uses `$.pref()` to be able to get default prefs
* or overridable settings
* getting `curPrefs` can be changed to use `svgEditor.pref()` getting to ensure
* `defaultPrefs` fallback (also for sake of `allowInitialUserOverride`);
* specifically, `bkgd_color` could be changed so that the pref dialog has a
* button to auto-calculate background, but otherwise uses `svgEditor.pref()` to
* be able to get default prefs or overridable settings
*/
$$b.pref = function (key, val, mayBeEmpty) {
editor.pref = function (key, val, mayBeEmpty) {
if (mayBeEmpty || val) {
curPrefs[key] = val;
/**
@ -29411,7 +29400,7 @@ editor.setConfig = function (opts, cfgCfg) {
if (cfgCfg.allowInitialUserOverride === true) {
defaultPrefs[key] = val;
} else {
$$b.pref(key, val);
editor.pref(key, val);
}
} else if (['extensions', 'stylesheets', 'allowedOrigins'].includes(key)) {
if (cfgCfg.overwrite === false && (curConfig.preventAllURLConfig || ['allowedOrigins', 'stylesheets'].includes(key) || key === 'extensions' && curConfig.lockExtensions)) {
@ -29623,7 +29612,6 @@ editor.init = function () {
(function () {
// Load config/data from URL if given
var src, qstr;
urldata = $$b.deparam.querystring(true);
if (!$$b.isEmptyObject(urldata)) {
@ -29656,21 +29644,26 @@ editor.init = function () {
setupCurConfig();
if (!curConfig.preventURLContentLoading) {
src = urldata.source;
qstr = $$b.param.querystring();
var _urldata = urldata,
source = _urldata.source;
if (!src) {
if (!source) {
// urldata.source may have been null if it ended with '='
if (qstr.includes('source=data:')) {
src = qstr.match(/source=(data:[^&]*)/)[1]; // ({src} = qstr.match(/source=(?<src>data:[^&]*)/).groups);
var _ref4 = new URL(location),
searchParams = _ref4.searchParams;
var src = searchParams.get('source');
if (src.startsWith('data:')) {
source = src;
}
}
if (src) {
if (src.startsWith('data:')) {
editor.loadFromDataURI(src);
if (source) {
if (source.startsWith('data:')) {
editor.loadFromDataURI(source);
} else {
editor.loadFromString(src);
editor.loadFromString(source);
}
return;
@ -29725,22 +29718,22 @@ editor.init = function () {
var extAndLocaleFunc =
/*#__PURE__*/
function () {
var _ref4 = _asyncToGenerator(
var _ref5 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee3() {
var _ref5, langParam, langData, _uiStrings$common, ok, cancel;
var _ref6, langParam, langData, _uiStrings$common, ok, cancel;
return regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.next = 2;
return editor.putLocale(null, goodLangs, curConfig);
return editor.putLocale(editor.pref('lang'), goodLangs, curConfig);
case 2:
_ref5 = _context3.sent;
langParam = _ref5.langParam;
langData = _ref5.langData;
_ref6 = _context3.sent;
langParam = _ref6.langParam;
langData = _ref6.langData;
_context3.next = 7;
return setLang(langParam, langData);
@ -29757,7 +29750,7 @@ editor.init = function () {
return Promise.all(curConfig.extensions.map(
/*#__PURE__*/
function () {
var _ref6 = _asyncToGenerator(
var _ref7 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee2(extname) {
var extName, url, imported, _imported$name, _name2, init, importLocale;
@ -29825,7 +29818,7 @@ editor.init = function () {
}));
return function (_x2) {
return _ref6.apply(this, arguments);
return _ref7.apply(this, arguments);
};
}()));
@ -29877,7 +29870,7 @@ editor.init = function () {
}));
return function extAndLocaleFunc() {
return _ref4.apply(this, arguments);
return _ref5.apply(this, arguments);
};
}();
@ -30011,7 +30004,7 @@ editor.init = function () {
scaleElements(elems, scale);
hiddenPs.css('visibility', 'visible').hide(); // return;
$$b.pref('iconsize', size);
editor.pref('iconsize', size);
$$b('#iconsize').val(size); // Change icon size
// $('.tool_button, .push_button, .tool_button_current, .disabled, .icon_label, #url_notice, #tool_open')
// .find('> svg, > img').each(function () {
@ -30371,7 +30364,7 @@ editor.init = function () {
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
getStylesheetPriority = function _ref8(stylesheetFile) {
getStylesheetPriority = function _ref9(stylesheetFile) {
switch (stylesheetFile) {
case 'jgraduate/css/jPicker.css':
return 1;
@ -30399,7 +30392,7 @@ editor.init = function () {
minHeight = tleft.offset().top + tleft.outerHeight();
}
size = $$b.pref('iconsize');
size = editor.pref('iconsize');
editor.setIconSize(size || ($$b(window).height() < minHeight ? 's' : 'm')); // Look for any missing flyout icons from plugins
$$b('.tools_flyout').each(function () {
@ -30446,10 +30439,10 @@ editor.init = function () {
_context4.next = 11;
return loadStylesheets(stylesheets, {
acceptErrors: function acceptErrors(_ref7) {
var stylesheetURL = _ref7.stylesheetURL,
reject = _ref7.reject,
resolve = _ref7.resolve;
acceptErrors: function acceptErrors(_ref8) {
var stylesheetURL = _ref8.stylesheetURL,
reject = _ref8.reject,
resolve = _ref8.resolve;
if ($$b.loadingStylesheets.includes(stylesheetURL)) {
reject(new Error("Missing expected stylesheet: ".concat(stylesheetURL)));
@ -30736,7 +30729,7 @@ editor.init = function () {
a.click(); // Alert will only appear the first time saved OR the
// first time the bug is encountered
var done = $$b.pref('save_notice_done');
var done = editor.pref('save_notice_done');
if (done !== 'all') {
var note = uiStrings$1.notification.saveFromBrowser.replace('%s', 'SVG'); // Check if FF and has <defs/>
@ -30745,13 +30738,13 @@ editor.init = function () {
if (svg.includes('<defs')) {
// warning about Mozilla bug #308590 when applicable (seems to be fixed now in Feb 2013)
note += '\n\n' + uiStrings$1.notification.defsFailOnSave;
$$b.pref('save_notice_done', 'all');
editor.pref('save_notice_done', 'all');
done = 'all';
} else {
$$b.pref('save_notice_done', 'part');
editor.pref('save_notice_done', 'part');
}
} else {
$$b.pref('save_notice_done', 'all');
editor.pref('save_notice_done', 'all');
}
if (done !== 'part') {
@ -30779,7 +30772,7 @@ editor.init = function () {
}
exportWindow.location.href = data.bloburl || data.datauri;
var done = $$b.pref('export_notice_done');
var done = editor.pref('export_notice_done');
if (done !== 'all') {
var note = uiStrings$1.notification.saveFromBrowser.replace('%s', data.type); // Check if there are issues
@ -30791,7 +30784,7 @@ editor.init = function () {
// May want to find a way to deal with that without annoying the user
$$b.pref('export_notice_done', 'all');
editor.pref('export_notice_done', 'all');
exportWindow.alert(note);
}
};
@ -30921,9 +30914,9 @@ editor.init = function () {
function setBackground(color, url) {
// if (color == $.pref('bkgd_color') && url == $.pref('bkgd_url')) { return; }
$$b.pref('bkgd_color', color);
$$b.pref('bkgd_url', url, true); // This should be done in svgcanvas.js for the borderRect fill
// if (color == editor.pref('bkgd_color') && url == editor.pref('bkgd_url')) { return; }
editor.pref('bkgd_color', color);
editor.pref('bkgd_url', url, true); // This should be done in svgcanvas.js for the borderRect fill
svgCanvas.setBackground(color, url);
}
@ -30947,8 +30940,8 @@ editor.init = function () {
_promptImgURL = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee18() {
var _ref32,
_ref32$cancelDeletes,
var _ref33,
_ref33$cancelDeletes,
cancelDeletes,
curhref,
url,
@ -30958,7 +30951,7 @@ editor.init = function () {
while (1) {
switch (_context18.prev = _context18.next) {
case 0:
_ref32 = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : {}, _ref32$cancelDeletes = _ref32.cancelDeletes, cancelDeletes = _ref32$cancelDeletes === void 0 ? false : _ref32$cancelDeletes;
_ref33 = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : {}, _ref33$cancelDeletes = _ref33.cancelDeletes, cancelDeletes = _ref33$cancelDeletes === void 0 ? false : _ref33$cancelDeletes;
curhref = svgCanvas.getHref(selectedElement);
curhref = curhref.startsWith('data:') ? '' : curhref;
_context18.next = 5;
@ -31966,10 +31959,10 @@ editor.init = function () {
// Get this button's options
var idSel = '#' + this.getAttribute('id');
var _Object$entries$find = Object.entries(btnOpts).find(function (_ref9) {
var _ref10 = _slicedToArray(_ref9, 2),
_ = _ref10[0],
sel = _ref10[1].sel;
var _Object$entries$find = Object.entries(btnOpts).find(function (_ref10) {
var _ref11 = _slicedToArray(_ref10, 2),
_ = _ref11[0],
sel = _ref11[1].sel;
return sel === idSel;
}),
@ -31996,10 +31989,10 @@ editor.init = function () {
if (ev.type === 'keydown') {
var flyoutIsSelected = $$b(options.parent + '_show').hasClass('tool_button_current');
var currentOperation = $$b(options.parent + '_show').attr('data-curopt');
Object.entries(holders[opts.parent]).some(function (_ref11) {
var _ref12 = _slicedToArray(_ref11, 2),
j = _ref12[0],
tool = _ref12[1];
Object.entries(holders[opts.parent]).some(function (_ref12) {
var _ref13 = _slicedToArray(_ref12, 2),
j = _ref13[0],
tool = _ref13[1];
if (tool.sel !== currentOperation) {
return false;
@ -32212,7 +32205,7 @@ editor.init = function () {
var extAdded =
/*#__PURE__*/
function () {
var _ref13 = _asyncToGenerator(
var _ref14 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee5(win, ext) {
var cbCalled, resizeDone, lang, prepResize, runCallback, btnSelects, svgicons, fallbackObj, altsObj, placementObj, holders;
@ -32220,7 +32213,7 @@ editor.init = function () {
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
prepResize = function _ref14() {
prepResize = function _ref15() {
if (resizeTimer) {
clearTimeout(resizeTimer);
resizeTimer = null;
@ -32229,7 +32222,7 @@ editor.init = function () {
if (!resizeDone) {
resizeTimer = setTimeout(function () {
resizeDone = true;
setIconSize($$b.pref('iconsize'));
setIconSize(editor.pref('iconsize'));
}, 50);
}
};
@ -32256,7 +32249,7 @@ editor.init = function () {
}
// We check for this since the "lang" pref could have been set by storage
lang = $$b.pref('lang');
lang = editor.pref('lang');
_context5.next = 10;
return ext.langReady({
lang: lang,
@ -32673,7 +32666,7 @@ editor.init = function () {
callback: function callback(icons) {
// Non-ideal hack to make the icon match the current size
// if (curPrefs.iconsize && curPrefs.iconsize !== 'm') {
if ($$b.pref('iconsize') !== 'm') {
if (editor.pref('iconsize') !== 'm') {
prepResize();
}
@ -32695,7 +32688,7 @@ editor.init = function () {
}));
return function extAdded(_x4, _x5) {
return _ref13.apply(this, arguments);
return _ref14.apply(this, arguments);
};
}();
/**
@ -32770,9 +32763,9 @@ editor.init = function () {
* @listens module:svgcanvas.SvgCanvas#event:updateCanvas
* @returns {void}
*/
function (win, _ref15) {
var center = _ref15.center,
newCtr = _ref15.newCtr;
function (win, _ref16) {
var center = _ref16.center,
newCtr = _ref16.newCtr;
updateCanvas(center, newCtr);
});
svgCanvas.bind('contextset', contextChanged);
@ -32801,8 +32794,8 @@ editor.init = function () {
$$b(this).addClass(curBg);
});
});
setBackground($$b.pref('bkgd_color'), $$b.pref('bkgd_url'));
$$b('#image_save_opts input').val([$$b.pref('img_save')]);
setBackground(editor.pref('bkgd_color'), editor.pref('bkgd_url'));
$$b('#image_save_opts input').val([editor.pref('img_save')]);
/**
* @type {module:jQuerySpinButton.ValueCallback}
*/
@ -33653,7 +33646,7 @@ editor.init = function () {
var makeHyperlink =
/*#__PURE__*/
function () {
var _ref17 = _asyncToGenerator(
var _ref18 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee7() {
var url;
@ -33685,7 +33678,7 @@ editor.init = function () {
}));
return function makeHyperlink() {
return _ref17.apply(this, arguments);
return _ref18.apply(this, arguments);
};
}();
/**
@ -33808,7 +33801,7 @@ editor.init = function () {
var clickClear =
/*#__PURE__*/
function () {
var _ref18 = _asyncToGenerator(
var _ref19 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee8() {
var _curConfig$dimensions, x, y, ok;
@ -33851,7 +33844,7 @@ editor.init = function () {
}));
return function clickClear() {
return _ref18.apply(this, arguments);
return _ref19.apply(this, arguments);
};
}();
/**
@ -33885,7 +33878,7 @@ editor.init = function () {
var clickSave = function clickSave() {
// In the future, more options can be provided here
var saveOpts = {
images: $$b.pref('img_save'),
images: editor.pref('img_save'),
round_digits: 6
};
svgCanvas.save(saveOpts);
@ -33900,7 +33893,7 @@ editor.init = function () {
var clickExport =
/*#__PURE__*/
function () {
var _ref19 = _asyncToGenerator(
var _ref20 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee9() {
var imgType, exportWindowName, openExportWindow, chrome, quality;
@ -33908,7 +33901,7 @@ editor.init = function () {
while (1) {
switch (_context9.prev = _context9.next) {
case 0:
openExportWindow = function _ref20() {
openExportWindow = function _ref21() {
var loadingImage = uiStrings$1.notification.loadingImage;
if (curConfig.exportWindowType === 'new') {
@ -33999,7 +33992,7 @@ editor.init = function () {
}));
return function clickExport() {
return _ref19.apply(this, arguments);
return _ref20.apply(this, arguments);
};
}();
/**
@ -34123,7 +34116,7 @@ editor.init = function () {
docprops = true; // This selects the correct radio button by using the array notation
$$b('#image_save_opts input').val([$$b.pref('img_save')]); // update resolution option with actual resolution
$$b('#image_save_opts input').val([editor.pref('img_save')]); // update resolution option with actual resolution
var res = svgCanvas.getResolution();
@ -34152,7 +34145,7 @@ editor.init = function () {
$$b('#main_menu').hide(); // Update background color with current one
var canvasBg = curPrefs.bkgd_color;
var url = $$b.pref('bkgd_url');
var url = editor.pref('bkgd_url');
blocks.each(function () {
var blk = $$b(this);
var isBg = blk.css('background-color') === canvasBg;
@ -34205,7 +34198,7 @@ editor.init = function () {
var saveSourceEditor =
/*#__PURE__*/
function () {
var _ref21 = _asyncToGenerator(
var _ref22 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee10() {
var saveChanges, ok;
@ -34265,7 +34258,7 @@ editor.init = function () {
}));
return function saveSourceEditor() {
return _ref21.apply(this, arguments);
return _ref22.apply(this, arguments);
};
}();
/**
@ -34278,7 +34271,7 @@ editor.init = function () {
$$b('#svg_docprops').hide();
$$b('#canvas_width,#canvas_height').removeAttr('disabled');
$$b('#resolution')[0].selectedIndex = 0;
$$b('#image_save_opts input').val([$$b.pref('img_save')]);
$$b('#image_save_opts input').val([editor.pref('img_save')]);
docprops = false;
};
/**
@ -34335,7 +34328,7 @@ editor.init = function () {
} // Set image save option
$$b.pref('img_save', $$b('#image_save_opts :checked').val());
editor.pref('img_save', $$b('#image_save_opts :checked').val());
updateCanvas();
hideDocProperties();
return true;
@ -34352,7 +34345,7 @@ editor.init = function () {
_asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee11() {
var color, lang, _ref23, langParam, langData;
var color, lang, _ref24, langParam, langData;
return regeneratorRuntime.wrap(function _callee11$(_context11) {
while (1) {
@ -34364,7 +34357,7 @@ editor.init = function () {
lang = $$b('#lang_select').val();
if (!(lang !== $$b.pref('lang'))) {
if (!(lang && lang !== editor.pref('lang'))) {
_context11.next = 11;
break;
}
@ -34373,9 +34366,9 @@ editor.init = function () {
return editor.putLocale(lang, goodLangs, curConfig);
case 6:
_ref23 = _context11.sent;
langParam = _ref23.langParam;
langData = _ref23.langData;
_ref24 = _context11.sent;
langParam = _ref24.langParam;
langData = _ref24.langData;
_context11.next = 11;
return setLang(langParam, langData);
@ -34415,7 +34408,7 @@ editor.init = function () {
var cancelOverlays =
/*#__PURE__*/
function () {
var _ref24 = _asyncToGenerator(
var _ref25 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee12() {
var ok;
@ -34486,7 +34479,7 @@ editor.init = function () {
}));
return function cancelOverlays() {
return _ref24.apply(this, arguments);
return _ref25.apply(this, arguments);
};
}();
@ -34814,7 +34807,7 @@ editor.init = function () {
// Disable option
$$b('#image_save_opts [value=embed]').attr('disabled', 'disabled');
$$b('#image_save_opts input').val(['ref']);
$$b.pref('img_save', 'ref');
editor.pref('img_save', 'ref');
$$b('#image_opt_embed').css('color', '#666').attr('title', uiStrings$1.notification.featNotSupported);
}
});
@ -36228,8 +36221,8 @@ editor.init = function () {
// bitmap handling
reader = new FileReader();
reader.onloadend = function (_ref27) {
var result = _ref27.target.result;
reader.onloadend = function (_ref28) {
var result = _ref28.target.result;
/**
* Insert the new image until we know its dimensions.
@ -36281,7 +36274,7 @@ editor.init = function () {
var open = $$b('<input type="file">').change(
/*#__PURE__*/
function () {
var _ref28 = _asyncToGenerator(
var _ref29 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee16(e) {
var ok, reader;
@ -36312,15 +36305,15 @@ editor.init = function () {
reader.onloadend =
/*#__PURE__*/
function () {
var _ref30 = _asyncToGenerator(
var _ref31 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee15(_ref29) {
regeneratorRuntime.mark(function _callee15(_ref30) {
var target;
return regeneratorRuntime.wrap(function _callee15$(_context15) {
while (1) {
switch (_context15.prev = _context15.next) {
case 0:
target = _ref29.target;
target = _ref30.target;
_context15.next = 3;
return loadSvgString(target.result);
@ -36336,7 +36329,7 @@ editor.init = function () {
}));
return function (_x7) {
return _ref30.apply(this, arguments);
return _ref31.apply(this, arguments);
};
}();
@ -36352,7 +36345,7 @@ editor.init = function () {
}));
return function (_x6) {
return _ref28.apply(this, arguments);
return _ref29.apply(this, arguments);
};
}());
$$b('#tool_open').show();
@ -36383,7 +36376,7 @@ editor.init = function () {
var setLang = editor.setLang =
/*#__PURE__*/
function () {
var _ref31 = _asyncToGenerator(
var _ref32 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee17(lang, allStrings) {
var oldLayerName, renameLayer, elems;
@ -36392,7 +36385,7 @@ editor.init = function () {
switch (_context17.prev = _context17.next) {
case 0:
editor.langChanged = true;
$$b.pref('lang', lang);
editor.pref('lang', lang);
$$b('#lang_select').val(lang);
if (allStrings) {
@ -36491,7 +36484,7 @@ editor.init = function () {
}));
return function (_x8, _x9) {
return _ref31.apply(this, arguments);
return _ref32.apply(this, arguments);
};
}();
@ -36585,9 +36578,9 @@ regeneratorRuntime.mark(function _callee20() {
case 0:
_context20.prev = 0;
_context20.next = 3;
return Promise.all(callbacks.map(function (_ref34) {
var _ref35 = _slicedToArray(_ref34, 1),
cb = _ref35[0];
return Promise.all(callbacks.map(function (_ref35) {
var _ref36 = _slicedToArray(_ref35, 1),
cb = _ref36[0];
return cb(); // eslint-disable-line promise/prefer-await-to-callbacks
}));
@ -36599,18 +36592,18 @@ regeneratorRuntime.mark(function _callee20() {
case 5:
_context20.prev = 5;
_context20.t0 = _context20["catch"](0);
callbacks.forEach(function (_ref36) {
var _ref37 = _slicedToArray(_ref36, 3),
reject = _ref37[2];
callbacks.forEach(function (_ref37) {
var _ref38 = _slicedToArray(_ref37, 3),
reject = _ref38[2];
reject();
});
throw _context20.t0;
case 9:
callbacks.forEach(function (_ref38) {
var _ref39 = _slicedToArray(_ref38, 2),
resolve = _ref39[1];
callbacks.forEach(function (_ref39) {
var _ref40 = _slicedToArray(_ref39, 2),
resolve = _ref40[1];
resolve();
});
@ -36631,8 +36624,8 @@ regeneratorRuntime.mark(function _callee20() {
*/
editor.loadFromString = function (str) {
var _ref40 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
noAlert = _ref40.noAlert;
var _ref41 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
noAlert = _ref41.noAlert;
return editor.ready(
/*#__PURE__*/
@ -36702,9 +36695,9 @@ editor.disableUI = function (featList) {// $(function () {
editor.loadFromURL = function (url) {
var _ref42 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
cache = _ref42.cache,
noAlert = _ref42.noAlert;
var _ref43 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
cache = _ref43.cache,
noAlert = _ref43.noAlert;
return editor.ready(function () {
return new Promise(function (resolve, reject) {
@ -36753,8 +36746,8 @@ editor.loadFromURL = function (url) {
editor.loadFromDataURI = function (str) {
var _ref43 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
noAlert = _ref43.noAlert;
var _ref44 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
noAlert = _ref44.noAlert;
return editor.ready(function () {
var base64 = false;
@ -36811,9 +36804,9 @@ var messageQueue = [];
* @returns {void}
*/
var messageListener = function messageListener(_ref44) {
var data = _ref44.data,
origin = _ref44.origin;
var messageListener = function messageListener(_ref45) {
var data = _ref45.data,
origin = _ref45.origin;
// eslint-disable-line no-shadow
// console.log('data, origin, extensionsAdded', data, origin, extensionsAdded);
var messageObj = {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

279
dist/index-umd.js vendored
View File

@ -28621,44 +28621,33 @@
case 0:
if (givenParam) {
langParam = givenParam;
} else {
langParam = $$a.pref('lang');
} else if (navigator.userLanguage) {
// Explorer
langParam = navigator.userLanguage;
} else if (navigator.language) {
// FF, Opera, ...
langParam = navigator.language;
}
if (!langParam) {
if (navigator.userLanguage) {
// Explorer
langParam = navigator.userLanguage;
} else if (navigator.language) {
// FF, Opera, ...
langParam = navigator.language;
}
}
console.log('Lang: ' + langParam); // eslint-disable-line no-console
// Set to English if language is not in list of good langs
if (!goodLangs.includes(langParam) && langParam !== 'test') {
langParam = 'en';
} // don't bother on first run if language is English
// The following line prevents setLang from running
// extensions which depend on updated uiStrings,
// so commenting it out.
// if (langParam.startsWith('en')) {return;}
console.log('Lang: ' + langParam); // eslint-disable-line no-console
// Set to English if language is not in list of good langs
if (!goodLangs.includes(langParam) && langParam !== 'test') {
langParam = 'en';
}
url = conf.langPath + 'lang.' + langParam + '.js';
_context2.t0 = readLang;
_context2.next = 5;
_context2.next = 7;
return importSetGlobalDefault(url, {
global: 'svgEditorLang_' + langParam.replace(/-/g, '_')
});
case 5:
case 7:
_context2.t1 = _context2.sent;
return _context2.abrupt("return", (0, _context2.t0)(_context2.t1));
case 7:
case 9:
case "end":
return _context2.stop();
}
@ -29158,7 +29147,7 @@
_loadSvgString = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee23(str) {
var _ref46,
var _ref47,
noAlert,
success,
_args23 = arguments;
@ -29167,7 +29156,7 @@
while (1) {
switch (_context23.prev = _context23.next) {
case 0:
_ref46 = _args23.length > 1 && _args23[1] !== undefined ? _args23[1] : {}, noAlert = _ref46.noAlert;
_ref47 = _args23.length > 1 && _args23[1] !== undefined ? _args23[1] : {}, noAlert = _ref47.noAlert;
success = svgCanvas.setSvgString(str) !== false;
if (!success) {
@ -29279,16 +29268,16 @@
* @param {boolean} [mayBeEmpty] If value may be falsey.
* @returns {string|void} If val is missing or falsey and `mayBeEmpty` is not set, the
* value of the previously stored preference will be returned.
* @todo Can we change setting on the jQuery namespace (onto editor) to avoid conflicts?
* @todo Review whether any remaining existing direct references to
* getting `curPrefs` can be changed to use `$.pref()` getting to ensure
* `defaultPrefs` fallback (also for sake of `allowInitialUserOverride`); specifically, `bkgd_color` could be changed so that
* the pref dialog has a button to auto-calculate background, but otherwise uses `$.pref()` to be able to get default prefs
* or overridable settings
* getting `curPrefs` can be changed to use `svgEditor.pref()` getting to ensure
* `defaultPrefs` fallback (also for sake of `allowInitialUserOverride`);
* specifically, `bkgd_color` could be changed so that the pref dialog has a
* button to auto-calculate background, but otherwise uses `svgEditor.pref()` to
* be able to get default prefs or overridable settings
*/
$$b.pref = function (key, val, mayBeEmpty) {
editor.pref = function (key, val, mayBeEmpty) {
if (mayBeEmpty || val) {
curPrefs[key] = val;
/**
@ -29417,7 +29406,7 @@
if (cfgCfg.allowInitialUserOverride === true) {
defaultPrefs[key] = val;
} else {
$$b.pref(key, val);
editor.pref(key, val);
}
} else if (['extensions', 'stylesheets', 'allowedOrigins'].includes(key)) {
if (cfgCfg.overwrite === false && (curConfig.preventAllURLConfig || ['allowedOrigins', 'stylesheets'].includes(key) || key === 'extensions' && curConfig.lockExtensions)) {
@ -29629,7 +29618,6 @@
(function () {
// Load config/data from URL if given
var src, qstr;
urldata = $$b.deparam.querystring(true);
if (!$$b.isEmptyObject(urldata)) {
@ -29662,21 +29650,26 @@
setupCurConfig();
if (!curConfig.preventURLContentLoading) {
src = urldata.source;
qstr = $$b.param.querystring();
var _urldata = urldata,
source = _urldata.source;
if (!src) {
if (!source) {
// urldata.source may have been null if it ended with '='
if (qstr.includes('source=data:')) {
src = qstr.match(/source=(data:[^&]*)/)[1]; // ({src} = qstr.match(/source=(?<src>data:[^&]*)/).groups);
var _ref4 = new URL(location),
searchParams = _ref4.searchParams;
var src = searchParams.get('source');
if (src.startsWith('data:')) {
source = src;
}
}
if (src) {
if (src.startsWith('data:')) {
editor.loadFromDataURI(src);
if (source) {
if (source.startsWith('data:')) {
editor.loadFromDataURI(source);
} else {
editor.loadFromString(src);
editor.loadFromString(source);
}
return;
@ -29731,22 +29724,22 @@
var extAndLocaleFunc =
/*#__PURE__*/
function () {
var _ref4 = _asyncToGenerator(
var _ref5 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee3() {
var _ref5, langParam, langData, _uiStrings$common, ok, cancel;
var _ref6, langParam, langData, _uiStrings$common, ok, cancel;
return regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.next = 2;
return editor.putLocale(null, goodLangs, curConfig);
return editor.putLocale(editor.pref('lang'), goodLangs, curConfig);
case 2:
_ref5 = _context3.sent;
langParam = _ref5.langParam;
langData = _ref5.langData;
_ref6 = _context3.sent;
langParam = _ref6.langParam;
langData = _ref6.langData;
_context3.next = 7;
return setLang(langParam, langData);
@ -29763,7 +29756,7 @@
return Promise.all(curConfig.extensions.map(
/*#__PURE__*/
function () {
var _ref6 = _asyncToGenerator(
var _ref7 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee2(extname) {
var extName, url, imported, _imported$name, _name2, init, importLocale;
@ -29831,7 +29824,7 @@
}));
return function (_x2) {
return _ref6.apply(this, arguments);
return _ref7.apply(this, arguments);
};
}()));
@ -29883,7 +29876,7 @@
}));
return function extAndLocaleFunc() {
return _ref4.apply(this, arguments);
return _ref5.apply(this, arguments);
};
}();
@ -30017,7 +30010,7 @@
scaleElements(elems, scale);
hiddenPs.css('visibility', 'visible').hide(); // return;
$$b.pref('iconsize', size);
editor.pref('iconsize', size);
$$b('#iconsize').val(size); // Change icon size
// $('.tool_button, .push_button, .tool_button_current, .disabled, .icon_label, #url_notice, #tool_open')
// .find('> svg, > img').each(function () {
@ -30377,7 +30370,7 @@
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
getStylesheetPriority = function _ref8(stylesheetFile) {
getStylesheetPriority = function _ref9(stylesheetFile) {
switch (stylesheetFile) {
case 'jgraduate/css/jPicker.css':
return 1;
@ -30405,7 +30398,7 @@
minHeight = tleft.offset().top + tleft.outerHeight();
}
size = $$b.pref('iconsize');
size = editor.pref('iconsize');
editor.setIconSize(size || ($$b(window).height() < minHeight ? 's' : 'm')); // Look for any missing flyout icons from plugins
$$b('.tools_flyout').each(function () {
@ -30452,10 +30445,10 @@
_context4.next = 11;
return loadStylesheets(stylesheets, {
acceptErrors: function acceptErrors(_ref7) {
var stylesheetURL = _ref7.stylesheetURL,
reject = _ref7.reject,
resolve = _ref7.resolve;
acceptErrors: function acceptErrors(_ref8) {
var stylesheetURL = _ref8.stylesheetURL,
reject = _ref8.reject,
resolve = _ref8.resolve;
if ($$b.loadingStylesheets.includes(stylesheetURL)) {
reject(new Error("Missing expected stylesheet: ".concat(stylesheetURL)));
@ -30742,7 +30735,7 @@
a.click(); // Alert will only appear the first time saved OR the
// first time the bug is encountered
var done = $$b.pref('save_notice_done');
var done = editor.pref('save_notice_done');
if (done !== 'all') {
var note = uiStrings$1.notification.saveFromBrowser.replace('%s', 'SVG'); // Check if FF and has <defs/>
@ -30751,13 +30744,13 @@
if (svg.includes('<defs')) {
// warning about Mozilla bug #308590 when applicable (seems to be fixed now in Feb 2013)
note += '\n\n' + uiStrings$1.notification.defsFailOnSave;
$$b.pref('save_notice_done', 'all');
editor.pref('save_notice_done', 'all');
done = 'all';
} else {
$$b.pref('save_notice_done', 'part');
editor.pref('save_notice_done', 'part');
}
} else {
$$b.pref('save_notice_done', 'all');
editor.pref('save_notice_done', 'all');
}
if (done !== 'part') {
@ -30785,7 +30778,7 @@
}
exportWindow.location.href = data.bloburl || data.datauri;
var done = $$b.pref('export_notice_done');
var done = editor.pref('export_notice_done');
if (done !== 'all') {
var note = uiStrings$1.notification.saveFromBrowser.replace('%s', data.type); // Check if there are issues
@ -30797,7 +30790,7 @@
// May want to find a way to deal with that without annoying the user
$$b.pref('export_notice_done', 'all');
editor.pref('export_notice_done', 'all');
exportWindow.alert(note);
}
};
@ -30927,9 +30920,9 @@
function setBackground(color, url) {
// if (color == $.pref('bkgd_color') && url == $.pref('bkgd_url')) { return; }
$$b.pref('bkgd_color', color);
$$b.pref('bkgd_url', url, true); // This should be done in svgcanvas.js for the borderRect fill
// if (color == editor.pref('bkgd_color') && url == editor.pref('bkgd_url')) { return; }
editor.pref('bkgd_color', color);
editor.pref('bkgd_url', url, true); // This should be done in svgcanvas.js for the borderRect fill
svgCanvas.setBackground(color, url);
}
@ -30953,8 +30946,8 @@
_promptImgURL = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee18() {
var _ref32,
_ref32$cancelDeletes,
var _ref33,
_ref33$cancelDeletes,
cancelDeletes,
curhref,
url,
@ -30964,7 +30957,7 @@
while (1) {
switch (_context18.prev = _context18.next) {
case 0:
_ref32 = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : {}, _ref32$cancelDeletes = _ref32.cancelDeletes, cancelDeletes = _ref32$cancelDeletes === void 0 ? false : _ref32$cancelDeletes;
_ref33 = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : {}, _ref33$cancelDeletes = _ref33.cancelDeletes, cancelDeletes = _ref33$cancelDeletes === void 0 ? false : _ref33$cancelDeletes;
curhref = svgCanvas.getHref(selectedElement);
curhref = curhref.startsWith('data:') ? '' : curhref;
_context18.next = 5;
@ -31972,10 +31965,10 @@
// Get this button's options
var idSel = '#' + this.getAttribute('id');
var _Object$entries$find = Object.entries(btnOpts).find(function (_ref9) {
var _ref10 = _slicedToArray(_ref9, 2),
_ = _ref10[0],
sel = _ref10[1].sel;
var _Object$entries$find = Object.entries(btnOpts).find(function (_ref10) {
var _ref11 = _slicedToArray(_ref10, 2),
_ = _ref11[0],
sel = _ref11[1].sel;
return sel === idSel;
}),
@ -32002,10 +31995,10 @@
if (ev.type === 'keydown') {
var flyoutIsSelected = $$b(options.parent + '_show').hasClass('tool_button_current');
var currentOperation = $$b(options.parent + '_show').attr('data-curopt');
Object.entries(holders[opts.parent]).some(function (_ref11) {
var _ref12 = _slicedToArray(_ref11, 2),
j = _ref12[0],
tool = _ref12[1];
Object.entries(holders[opts.parent]).some(function (_ref12) {
var _ref13 = _slicedToArray(_ref12, 2),
j = _ref13[0],
tool = _ref13[1];
if (tool.sel !== currentOperation) {
return false;
@ -32218,7 +32211,7 @@
var extAdded =
/*#__PURE__*/
function () {
var _ref13 = _asyncToGenerator(
var _ref14 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee5(win, ext) {
var cbCalled, resizeDone, lang, prepResize, runCallback, btnSelects, svgicons, fallbackObj, altsObj, placementObj, holders;
@ -32226,7 +32219,7 @@
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
prepResize = function _ref14() {
prepResize = function _ref15() {
if (resizeTimer) {
clearTimeout(resizeTimer);
resizeTimer = null;
@ -32235,7 +32228,7 @@
if (!resizeDone) {
resizeTimer = setTimeout(function () {
resizeDone = true;
setIconSize($$b.pref('iconsize'));
setIconSize(editor.pref('iconsize'));
}, 50);
}
};
@ -32262,7 +32255,7 @@
}
// We check for this since the "lang" pref could have been set by storage
lang = $$b.pref('lang');
lang = editor.pref('lang');
_context5.next = 10;
return ext.langReady({
lang: lang,
@ -32679,7 +32672,7 @@
callback: function callback(icons) {
// Non-ideal hack to make the icon match the current size
// if (curPrefs.iconsize && curPrefs.iconsize !== 'm') {
if ($$b.pref('iconsize') !== 'm') {
if (editor.pref('iconsize') !== 'm') {
prepResize();
}
@ -32701,7 +32694,7 @@
}));
return function extAdded(_x4, _x5) {
return _ref13.apply(this, arguments);
return _ref14.apply(this, arguments);
};
}();
/**
@ -32776,9 +32769,9 @@
* @listens module:svgcanvas.SvgCanvas#event:updateCanvas
* @returns {void}
*/
function (win, _ref15) {
var center = _ref15.center,
newCtr = _ref15.newCtr;
function (win, _ref16) {
var center = _ref16.center,
newCtr = _ref16.newCtr;
updateCanvas(center, newCtr);
});
svgCanvas.bind('contextset', contextChanged);
@ -32807,8 +32800,8 @@
$$b(this).addClass(curBg);
});
});
setBackground($$b.pref('bkgd_color'), $$b.pref('bkgd_url'));
$$b('#image_save_opts input').val([$$b.pref('img_save')]);
setBackground(editor.pref('bkgd_color'), editor.pref('bkgd_url'));
$$b('#image_save_opts input').val([editor.pref('img_save')]);
/**
* @type {module:jQuerySpinButton.ValueCallback}
*/
@ -33659,7 +33652,7 @@
var makeHyperlink =
/*#__PURE__*/
function () {
var _ref17 = _asyncToGenerator(
var _ref18 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee7() {
var url;
@ -33691,7 +33684,7 @@
}));
return function makeHyperlink() {
return _ref17.apply(this, arguments);
return _ref18.apply(this, arguments);
};
}();
/**
@ -33814,7 +33807,7 @@
var clickClear =
/*#__PURE__*/
function () {
var _ref18 = _asyncToGenerator(
var _ref19 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee8() {
var _curConfig$dimensions, x, y, ok;
@ -33857,7 +33850,7 @@
}));
return function clickClear() {
return _ref18.apply(this, arguments);
return _ref19.apply(this, arguments);
};
}();
/**
@ -33891,7 +33884,7 @@
var clickSave = function clickSave() {
// In the future, more options can be provided here
var saveOpts = {
images: $$b.pref('img_save'),
images: editor.pref('img_save'),
round_digits: 6
};
svgCanvas.save(saveOpts);
@ -33906,7 +33899,7 @@
var clickExport =
/*#__PURE__*/
function () {
var _ref19 = _asyncToGenerator(
var _ref20 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee9() {
var imgType, exportWindowName, openExportWindow, chrome, quality;
@ -33914,7 +33907,7 @@
while (1) {
switch (_context9.prev = _context9.next) {
case 0:
openExportWindow = function _ref20() {
openExportWindow = function _ref21() {
var loadingImage = uiStrings$1.notification.loadingImage;
if (curConfig.exportWindowType === 'new') {
@ -34005,7 +33998,7 @@
}));
return function clickExport() {
return _ref19.apply(this, arguments);
return _ref20.apply(this, arguments);
};
}();
/**
@ -34129,7 +34122,7 @@
docprops = true; // This selects the correct radio button by using the array notation
$$b('#image_save_opts input').val([$$b.pref('img_save')]); // update resolution option with actual resolution
$$b('#image_save_opts input').val([editor.pref('img_save')]); // update resolution option with actual resolution
var res = svgCanvas.getResolution();
@ -34158,7 +34151,7 @@
$$b('#main_menu').hide(); // Update background color with current one
var canvasBg = curPrefs.bkgd_color;
var url = $$b.pref('bkgd_url');
var url = editor.pref('bkgd_url');
blocks.each(function () {
var blk = $$b(this);
var isBg = blk.css('background-color') === canvasBg;
@ -34211,7 +34204,7 @@
var saveSourceEditor =
/*#__PURE__*/
function () {
var _ref21 = _asyncToGenerator(
var _ref22 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee10() {
var saveChanges, ok;
@ -34271,7 +34264,7 @@
}));
return function saveSourceEditor() {
return _ref21.apply(this, arguments);
return _ref22.apply(this, arguments);
};
}();
/**
@ -34284,7 +34277,7 @@
$$b('#svg_docprops').hide();
$$b('#canvas_width,#canvas_height').removeAttr('disabled');
$$b('#resolution')[0].selectedIndex = 0;
$$b('#image_save_opts input').val([$$b.pref('img_save')]);
$$b('#image_save_opts input').val([editor.pref('img_save')]);
docprops = false;
};
/**
@ -34341,7 +34334,7 @@
} // Set image save option
$$b.pref('img_save', $$b('#image_save_opts :checked').val());
editor.pref('img_save', $$b('#image_save_opts :checked').val());
updateCanvas();
hideDocProperties();
return true;
@ -34358,7 +34351,7 @@
_asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee11() {
var color, lang, _ref23, langParam, langData;
var color, lang, _ref24, langParam, langData;
return regeneratorRuntime.wrap(function _callee11$(_context11) {
while (1) {
@ -34370,7 +34363,7 @@
lang = $$b('#lang_select').val();
if (!(lang !== $$b.pref('lang'))) {
if (!(lang && lang !== editor.pref('lang'))) {
_context11.next = 11;
break;
}
@ -34379,9 +34372,9 @@
return editor.putLocale(lang, goodLangs, curConfig);
case 6:
_ref23 = _context11.sent;
langParam = _ref23.langParam;
langData = _ref23.langData;
_ref24 = _context11.sent;
langParam = _ref24.langParam;
langData = _ref24.langData;
_context11.next = 11;
return setLang(langParam, langData);
@ -34421,7 +34414,7 @@
var cancelOverlays =
/*#__PURE__*/
function () {
var _ref24 = _asyncToGenerator(
var _ref25 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee12() {
var ok;
@ -34492,7 +34485,7 @@
}));
return function cancelOverlays() {
return _ref24.apply(this, arguments);
return _ref25.apply(this, arguments);
};
}();
@ -34820,7 +34813,7 @@
// Disable option
$$b('#image_save_opts [value=embed]').attr('disabled', 'disabled');
$$b('#image_save_opts input').val(['ref']);
$$b.pref('img_save', 'ref');
editor.pref('img_save', 'ref');
$$b('#image_opt_embed').css('color', '#666').attr('title', uiStrings$1.notification.featNotSupported);
}
});
@ -36234,8 +36227,8 @@
// bitmap handling
reader = new FileReader();
reader.onloadend = function (_ref27) {
var result = _ref27.target.result;
reader.onloadend = function (_ref28) {
var result = _ref28.target.result;
/**
* Insert the new image until we know its dimensions.
@ -36287,7 +36280,7 @@
var open = $$b('<input type="file">').change(
/*#__PURE__*/
function () {
var _ref28 = _asyncToGenerator(
var _ref29 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee16(e) {
var ok, reader;
@ -36318,15 +36311,15 @@
reader.onloadend =
/*#__PURE__*/
function () {
var _ref30 = _asyncToGenerator(
var _ref31 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee15(_ref29) {
regeneratorRuntime.mark(function _callee15(_ref30) {
var target;
return regeneratorRuntime.wrap(function _callee15$(_context15) {
while (1) {
switch (_context15.prev = _context15.next) {
case 0:
target = _ref29.target;
target = _ref30.target;
_context15.next = 3;
return loadSvgString(target.result);
@ -36342,7 +36335,7 @@
}));
return function (_x7) {
return _ref30.apply(this, arguments);
return _ref31.apply(this, arguments);
};
}();
@ -36358,7 +36351,7 @@
}));
return function (_x6) {
return _ref28.apply(this, arguments);
return _ref29.apply(this, arguments);
};
}());
$$b('#tool_open').show();
@ -36389,7 +36382,7 @@
var setLang = editor.setLang =
/*#__PURE__*/
function () {
var _ref31 = _asyncToGenerator(
var _ref32 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee17(lang, allStrings) {
var oldLayerName, renameLayer, elems;
@ -36398,7 +36391,7 @@
switch (_context17.prev = _context17.next) {
case 0:
editor.langChanged = true;
$$b.pref('lang', lang);
editor.pref('lang', lang);
$$b('#lang_select').val(lang);
if (allStrings) {
@ -36497,7 +36490,7 @@
}));
return function (_x8, _x9) {
return _ref31.apply(this, arguments);
return _ref32.apply(this, arguments);
};
}();
@ -36591,9 +36584,9 @@
case 0:
_context20.prev = 0;
_context20.next = 3;
return Promise.all(callbacks.map(function (_ref34) {
var _ref35 = _slicedToArray(_ref34, 1),
cb = _ref35[0];
return Promise.all(callbacks.map(function (_ref35) {
var _ref36 = _slicedToArray(_ref35, 1),
cb = _ref36[0];
return cb(); // eslint-disable-line promise/prefer-await-to-callbacks
}));
@ -36605,18 +36598,18 @@
case 5:
_context20.prev = 5;
_context20.t0 = _context20["catch"](0);
callbacks.forEach(function (_ref36) {
var _ref37 = _slicedToArray(_ref36, 3),
reject = _ref37[2];
callbacks.forEach(function (_ref37) {
var _ref38 = _slicedToArray(_ref37, 3),
reject = _ref38[2];
reject();
});
throw _context20.t0;
case 9:
callbacks.forEach(function (_ref38) {
var _ref39 = _slicedToArray(_ref38, 2),
resolve = _ref39[1];
callbacks.forEach(function (_ref39) {
var _ref40 = _slicedToArray(_ref39, 2),
resolve = _ref40[1];
resolve();
});
@ -36637,8 +36630,8 @@
*/
editor.loadFromString = function (str) {
var _ref40 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
noAlert = _ref40.noAlert;
var _ref41 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
noAlert = _ref41.noAlert;
return editor.ready(
/*#__PURE__*/
@ -36708,9 +36701,9 @@
editor.loadFromURL = function (url) {
var _ref42 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
cache = _ref42.cache,
noAlert = _ref42.noAlert;
var _ref43 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
cache = _ref43.cache,
noAlert = _ref43.noAlert;
return editor.ready(function () {
return new Promise(function (resolve, reject) {
@ -36759,8 +36752,8 @@
editor.loadFromDataURI = function (str) {
var _ref43 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
noAlert = _ref43.noAlert;
var _ref44 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
noAlert = _ref44.noAlert;
return editor.ready(function () {
var base64 = false;
@ -36817,9 +36810,9 @@
* @returns {void}
*/
var messageListener = function messageListener(_ref44) {
var data = _ref44.data,
origin = _ref44.origin;
var messageListener = function messageListener(_ref45) {
var data = _ref45.data,
origin = _ref45.origin;
// eslint-disable-line no-shadow
// console.log('data, origin, extensionsAdded', data, origin, extensionsAdded);
var messageObj = {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -8,9 +8,7 @@
* The functionality was originally part of the SVG Editor, but moved to a
* separate extension to make the setting behavior optional, and adapted
* to inform the user of its setting of local data.
* Dependencies:
*
* 1. jQuery BBQ (for deparam)
* @license MIT
*
* @copyright 2010 Brett Zamir
@ -20,6 +18,7 @@
* @todo We might provide control of storage settings through the UI besides the
* initial (or URL-forced) dialog. *
*/
export default {
name: 'storage',
init ({$}) {
@ -51,6 +50,7 @@ export default {
* Replace `storagePrompt` parameter within URL.
* @param {string} val
* @returns {void}
* @todo Replace the string manipulation with `searchParams.set`
*/
function replaceStoragePrompt (val) {
val = val ? 'storagePrompt=' + val : '';
@ -166,7 +166,7 @@ export default {
return {
name: 'storage',
async langReady ({importLocale}) {
const {storagePrompt} = $.deparam.querystring(true);
const storagePrompt = new URL(top.location).searchParams.get('storagePrompt');
const confirmSetStorage = await importLocale();
const {
@ -190,13 +190,13 @@ export default {
// 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 ||
storagePrompt === 'true' ||
(
// ...or...if the URL at least doesn't explicitly prevent a
// storage prompt (as we use for users who
// don't want to set cookies at all but who don't want
// continual prompts about it)...
storagePrompt !== false &&
storagePrompt !== 'false' &&
// ...and this user hasn't previously indicated a desire for storage
!document.cookie.match(/(?:^|;\s*)svgeditstore=(?:prefsAndContent|prefsOnly)/)
)
@ -252,7 +252,7 @@ export default {
// 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) {
if (storagePrompt === 'true' && checked) {
replaceStoragePrompt();
return;
}

View File

@ -15,6 +15,12 @@
* @borrows module:locale.setStrings as setStrings
*/
/*
* Dependencies to remove:
*
* 1. jQuery BBQ (for deparam)
*/
import './touch.js';
import {NS} from './namespaces.js';
import {isWebkit, isChrome, isGecko, isIE, isMac, isTouch} from './browser.js';

View File

@ -28618,44 +28618,33 @@
case 0:
if (givenParam) {
langParam = givenParam;
} else {
langParam = $$a.pref('lang');
} else if (navigator.userLanguage) {
// Explorer
langParam = navigator.userLanguage;
} else if (navigator.language) {
// FF, Opera, ...
langParam = navigator.language;
}
if (!langParam) {
if (navigator.userLanguage) {
// Explorer
langParam = navigator.userLanguage;
} else if (navigator.language) {
// FF, Opera, ...
langParam = navigator.language;
}
}
console.log('Lang: ' + langParam); // eslint-disable-line no-console
// Set to English if language is not in list of good langs
if (!goodLangs.includes(langParam) && langParam !== 'test') {
langParam = 'en';
} // don't bother on first run if language is English
// The following line prevents setLang from running
// extensions which depend on updated uiStrings,
// so commenting it out.
// if (langParam.startsWith('en')) {return;}
console.log('Lang: ' + langParam); // eslint-disable-line no-console
// Set to English if language is not in list of good langs
if (!goodLangs.includes(langParam) && langParam !== 'test') {
langParam = 'en';
}
url = conf.langPath + 'lang.' + langParam + '.js';
_context2.t0 = readLang;
_context2.next = 5;
_context2.next = 7;
return importSetGlobalDefault(url, {
global: 'svgEditorLang_' + langParam.replace(/-/g, '_')
});
case 5:
case 7:
_context2.t1 = _context2.sent;
return _context2.abrupt("return", (0, _context2.t0)(_context2.t1));
case 7:
case 9:
case "end":
return _context2.stop();
}
@ -29155,7 +29144,7 @@
_loadSvgString = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee23(str) {
var _ref46,
var _ref47,
noAlert,
success,
_args23 = arguments;
@ -29164,7 +29153,7 @@
while (1) {
switch (_context23.prev = _context23.next) {
case 0:
_ref46 = _args23.length > 1 && _args23[1] !== undefined ? _args23[1] : {}, noAlert = _ref46.noAlert;
_ref47 = _args23.length > 1 && _args23[1] !== undefined ? _args23[1] : {}, noAlert = _ref47.noAlert;
success = svgCanvas.setSvgString(str) !== false;
if (!success) {
@ -29276,16 +29265,16 @@
* @param {boolean} [mayBeEmpty] If value may be falsey.
* @returns {string|void} If val is missing or falsey and `mayBeEmpty` is not set, the
* value of the previously stored preference will be returned.
* @todo Can we change setting on the jQuery namespace (onto editor) to avoid conflicts?
* @todo Review whether any remaining existing direct references to
* getting `curPrefs` can be changed to use `$.pref()` getting to ensure
* `defaultPrefs` fallback (also for sake of `allowInitialUserOverride`); specifically, `bkgd_color` could be changed so that
* the pref dialog has a button to auto-calculate background, but otherwise uses `$.pref()` to be able to get default prefs
* or overridable settings
* getting `curPrefs` can be changed to use `svgEditor.pref()` getting to ensure
* `defaultPrefs` fallback (also for sake of `allowInitialUserOverride`);
* specifically, `bkgd_color` could be changed so that the pref dialog has a
* button to auto-calculate background, but otherwise uses `svgEditor.pref()` to
* be able to get default prefs or overridable settings
*/
$$b.pref = function (key, val, mayBeEmpty) {
editor.pref = function (key, val, mayBeEmpty) {
if (mayBeEmpty || val) {
curPrefs[key] = val;
/**
@ -29414,7 +29403,7 @@
if (cfgCfg.allowInitialUserOverride === true) {
defaultPrefs[key] = val;
} else {
$$b.pref(key, val);
editor.pref(key, val);
}
} else if (['extensions', 'stylesheets', 'allowedOrigins'].includes(key)) {
if (cfgCfg.overwrite === false && (curConfig.preventAllURLConfig || ['allowedOrigins', 'stylesheets'].includes(key) || key === 'extensions' && curConfig.lockExtensions)) {
@ -29626,7 +29615,6 @@
(function () {
// Load config/data from URL if given
var src, qstr;
urldata = $$b.deparam.querystring(true);
if (!$$b.isEmptyObject(urldata)) {
@ -29659,21 +29647,26 @@
setupCurConfig();
if (!curConfig.preventURLContentLoading) {
src = urldata.source;
qstr = $$b.param.querystring();
var _urldata = urldata,
source = _urldata.source;
if (!src) {
if (!source) {
// urldata.source may have been null if it ended with '='
if (qstr.includes('source=data:')) {
src = qstr.match(/source=(data:[^&]*)/)[1]; // ({src} = qstr.match(/source=(?<src>data:[^&]*)/).groups);
var _ref4 = new URL(location),
searchParams = _ref4.searchParams;
var src = searchParams.get('source');
if (src.startsWith('data:')) {
source = src;
}
}
if (src) {
if (src.startsWith('data:')) {
editor.loadFromDataURI(src);
if (source) {
if (source.startsWith('data:')) {
editor.loadFromDataURI(source);
} else {
editor.loadFromString(src);
editor.loadFromString(source);
}
return;
@ -29728,22 +29721,22 @@
var extAndLocaleFunc =
/*#__PURE__*/
function () {
var _ref4 = _asyncToGenerator(
var _ref5 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee3() {
var _ref5, langParam, langData, _uiStrings$common, ok, cancel;
var _ref6, langParam, langData, _uiStrings$common, ok, cancel;
return regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.next = 2;
return editor.putLocale(null, goodLangs, curConfig);
return editor.putLocale(editor.pref('lang'), goodLangs, curConfig);
case 2:
_ref5 = _context3.sent;
langParam = _ref5.langParam;
langData = _ref5.langData;
_ref6 = _context3.sent;
langParam = _ref6.langParam;
langData = _ref6.langData;
_context3.next = 7;
return setLang(langParam, langData);
@ -29760,7 +29753,7 @@
return Promise.all(curConfig.extensions.map(
/*#__PURE__*/
function () {
var _ref6 = _asyncToGenerator(
var _ref7 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee2(extname) {
var extName, url, imported, _imported$name, _name2, init, importLocale;
@ -29828,7 +29821,7 @@
}));
return function (_x2) {
return _ref6.apply(this, arguments);
return _ref7.apply(this, arguments);
};
}()));
@ -29880,7 +29873,7 @@
}));
return function extAndLocaleFunc() {
return _ref4.apply(this, arguments);
return _ref5.apply(this, arguments);
};
}();
@ -30014,7 +30007,7 @@
scaleElements(elems, scale);
hiddenPs.css('visibility', 'visible').hide(); // return;
$$b.pref('iconsize', size);
editor.pref('iconsize', size);
$$b('#iconsize').val(size); // Change icon size
// $('.tool_button, .push_button, .tool_button_current, .disabled, .icon_label, #url_notice, #tool_open')
// .find('> svg, > img').each(function () {
@ -30374,7 +30367,7 @@
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
getStylesheetPriority = function _ref8(stylesheetFile) {
getStylesheetPriority = function _ref9(stylesheetFile) {
switch (stylesheetFile) {
case 'jgraduate/css/jPicker.css':
return 1;
@ -30402,7 +30395,7 @@
minHeight = tleft.offset().top + tleft.outerHeight();
}
size = $$b.pref('iconsize');
size = editor.pref('iconsize');
editor.setIconSize(size || ($$b(window).height() < minHeight ? 's' : 'm')); // Look for any missing flyout icons from plugins
$$b('.tools_flyout').each(function () {
@ -30449,10 +30442,10 @@
_context4.next = 11;
return loadStylesheets(stylesheets, {
acceptErrors: function acceptErrors(_ref7) {
var stylesheetURL = _ref7.stylesheetURL,
reject = _ref7.reject,
resolve = _ref7.resolve;
acceptErrors: function acceptErrors(_ref8) {
var stylesheetURL = _ref8.stylesheetURL,
reject = _ref8.reject,
resolve = _ref8.resolve;
if ($$b.loadingStylesheets.includes(stylesheetURL)) {
reject(new Error("Missing expected stylesheet: ".concat(stylesheetURL)));
@ -30739,7 +30732,7 @@
a.click(); // Alert will only appear the first time saved OR the
// first time the bug is encountered
var done = $$b.pref('save_notice_done');
var done = editor.pref('save_notice_done');
if (done !== 'all') {
var note = uiStrings$1.notification.saveFromBrowser.replace('%s', 'SVG'); // Check if FF and has <defs/>
@ -30748,13 +30741,13 @@
if (svg.includes('<defs')) {
// warning about Mozilla bug #308590 when applicable (seems to be fixed now in Feb 2013)
note += '\n\n' + uiStrings$1.notification.defsFailOnSave;
$$b.pref('save_notice_done', 'all');
editor.pref('save_notice_done', 'all');
done = 'all';
} else {
$$b.pref('save_notice_done', 'part');
editor.pref('save_notice_done', 'part');
}
} else {
$$b.pref('save_notice_done', 'all');
editor.pref('save_notice_done', 'all');
}
if (done !== 'part') {
@ -30782,7 +30775,7 @@
}
exportWindow.location.href = data.bloburl || data.datauri;
var done = $$b.pref('export_notice_done');
var done = editor.pref('export_notice_done');
if (done !== 'all') {
var note = uiStrings$1.notification.saveFromBrowser.replace('%s', data.type); // Check if there are issues
@ -30794,7 +30787,7 @@
// May want to find a way to deal with that without annoying the user
$$b.pref('export_notice_done', 'all');
editor.pref('export_notice_done', 'all');
exportWindow.alert(note);
}
};
@ -30924,9 +30917,9 @@
function setBackground(color, url) {
// if (color == $.pref('bkgd_color') && url == $.pref('bkgd_url')) { return; }
$$b.pref('bkgd_color', color);
$$b.pref('bkgd_url', url, true); // This should be done in svgcanvas.js for the borderRect fill
// if (color == editor.pref('bkgd_color') && url == editor.pref('bkgd_url')) { return; }
editor.pref('bkgd_color', color);
editor.pref('bkgd_url', url, true); // This should be done in svgcanvas.js for the borderRect fill
svgCanvas.setBackground(color, url);
}
@ -30950,8 +30943,8 @@
_promptImgURL = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee18() {
var _ref32,
_ref32$cancelDeletes,
var _ref33,
_ref33$cancelDeletes,
cancelDeletes,
curhref,
url,
@ -30961,7 +30954,7 @@
while (1) {
switch (_context18.prev = _context18.next) {
case 0:
_ref32 = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : {}, _ref32$cancelDeletes = _ref32.cancelDeletes, cancelDeletes = _ref32$cancelDeletes === void 0 ? false : _ref32$cancelDeletes;
_ref33 = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : {}, _ref33$cancelDeletes = _ref33.cancelDeletes, cancelDeletes = _ref33$cancelDeletes === void 0 ? false : _ref33$cancelDeletes;
curhref = svgCanvas.getHref(selectedElement);
curhref = curhref.startsWith('data:') ? '' : curhref;
_context18.next = 5;
@ -31969,10 +31962,10 @@
// Get this button's options
var idSel = '#' + this.getAttribute('id');
var _Object$entries$find = Object.entries(btnOpts).find(function (_ref9) {
var _ref10 = _slicedToArray(_ref9, 2),
_ = _ref10[0],
sel = _ref10[1].sel;
var _Object$entries$find = Object.entries(btnOpts).find(function (_ref10) {
var _ref11 = _slicedToArray(_ref10, 2),
_ = _ref11[0],
sel = _ref11[1].sel;
return sel === idSel;
}),
@ -31999,10 +31992,10 @@
if (ev.type === 'keydown') {
var flyoutIsSelected = $$b(options.parent + '_show').hasClass('tool_button_current');
var currentOperation = $$b(options.parent + '_show').attr('data-curopt');
Object.entries(holders[opts.parent]).some(function (_ref11) {
var _ref12 = _slicedToArray(_ref11, 2),
j = _ref12[0],
tool = _ref12[1];
Object.entries(holders[opts.parent]).some(function (_ref12) {
var _ref13 = _slicedToArray(_ref12, 2),
j = _ref13[0],
tool = _ref13[1];
if (tool.sel !== currentOperation) {
return false;
@ -32215,7 +32208,7 @@
var extAdded =
/*#__PURE__*/
function () {
var _ref13 = _asyncToGenerator(
var _ref14 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee5(win, ext) {
var cbCalled, resizeDone, lang, prepResize, runCallback, btnSelects, svgicons, fallbackObj, altsObj, placementObj, holders;
@ -32223,7 +32216,7 @@
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
prepResize = function _ref14() {
prepResize = function _ref15() {
if (resizeTimer) {
clearTimeout(resizeTimer);
resizeTimer = null;
@ -32232,7 +32225,7 @@
if (!resizeDone) {
resizeTimer = setTimeout(function () {
resizeDone = true;
setIconSize($$b.pref('iconsize'));
setIconSize(editor.pref('iconsize'));
}, 50);
}
};
@ -32259,7 +32252,7 @@
}
// We check for this since the "lang" pref could have been set by storage
lang = $$b.pref('lang');
lang = editor.pref('lang');
_context5.next = 10;
return ext.langReady({
lang: lang,
@ -32676,7 +32669,7 @@
callback: function callback(icons) {
// Non-ideal hack to make the icon match the current size
// if (curPrefs.iconsize && curPrefs.iconsize !== 'm') {
if ($$b.pref('iconsize') !== 'm') {
if (editor.pref('iconsize') !== 'm') {
prepResize();
}
@ -32698,7 +32691,7 @@
}));
return function extAdded(_x4, _x5) {
return _ref13.apply(this, arguments);
return _ref14.apply(this, arguments);
};
}();
/**
@ -32773,9 +32766,9 @@
* @listens module:svgcanvas.SvgCanvas#event:updateCanvas
* @returns {void}
*/
function (win, _ref15) {
var center = _ref15.center,
newCtr = _ref15.newCtr;
function (win, _ref16) {
var center = _ref16.center,
newCtr = _ref16.newCtr;
updateCanvas(center, newCtr);
});
svgCanvas.bind('contextset', contextChanged);
@ -32804,8 +32797,8 @@
$$b(this).addClass(curBg);
});
});
setBackground($$b.pref('bkgd_color'), $$b.pref('bkgd_url'));
$$b('#image_save_opts input').val([$$b.pref('img_save')]);
setBackground(editor.pref('bkgd_color'), editor.pref('bkgd_url'));
$$b('#image_save_opts input').val([editor.pref('img_save')]);
/**
* @type {module:jQuerySpinButton.ValueCallback}
*/
@ -33656,7 +33649,7 @@
var makeHyperlink =
/*#__PURE__*/
function () {
var _ref17 = _asyncToGenerator(
var _ref18 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee7() {
var url;
@ -33688,7 +33681,7 @@
}));
return function makeHyperlink() {
return _ref17.apply(this, arguments);
return _ref18.apply(this, arguments);
};
}();
/**
@ -33811,7 +33804,7 @@
var clickClear =
/*#__PURE__*/
function () {
var _ref18 = _asyncToGenerator(
var _ref19 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee8() {
var _curConfig$dimensions, x, y, ok;
@ -33854,7 +33847,7 @@
}));
return function clickClear() {
return _ref18.apply(this, arguments);
return _ref19.apply(this, arguments);
};
}();
/**
@ -33888,7 +33881,7 @@
var clickSave = function clickSave() {
// In the future, more options can be provided here
var saveOpts = {
images: $$b.pref('img_save'),
images: editor.pref('img_save'),
round_digits: 6
};
svgCanvas.save(saveOpts);
@ -33903,7 +33896,7 @@
var clickExport =
/*#__PURE__*/
function () {
var _ref19 = _asyncToGenerator(
var _ref20 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee9() {
var imgType, exportWindowName, openExportWindow, chrome, quality;
@ -33911,7 +33904,7 @@
while (1) {
switch (_context9.prev = _context9.next) {
case 0:
openExportWindow = function _ref20() {
openExportWindow = function _ref21() {
var loadingImage = uiStrings$1.notification.loadingImage;
if (curConfig.exportWindowType === 'new') {
@ -34002,7 +33995,7 @@
}));
return function clickExport() {
return _ref19.apply(this, arguments);
return _ref20.apply(this, arguments);
};
}();
/**
@ -34126,7 +34119,7 @@
docprops = true; // This selects the correct radio button by using the array notation
$$b('#image_save_opts input').val([$$b.pref('img_save')]); // update resolution option with actual resolution
$$b('#image_save_opts input').val([editor.pref('img_save')]); // update resolution option with actual resolution
var res = svgCanvas.getResolution();
@ -34155,7 +34148,7 @@
$$b('#main_menu').hide(); // Update background color with current one
var canvasBg = curPrefs.bkgd_color;
var url = $$b.pref('bkgd_url');
var url = editor.pref('bkgd_url');
blocks.each(function () {
var blk = $$b(this);
var isBg = blk.css('background-color') === canvasBg;
@ -34208,7 +34201,7 @@
var saveSourceEditor =
/*#__PURE__*/
function () {
var _ref21 = _asyncToGenerator(
var _ref22 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee10() {
var saveChanges, ok;
@ -34268,7 +34261,7 @@
}));
return function saveSourceEditor() {
return _ref21.apply(this, arguments);
return _ref22.apply(this, arguments);
};
}();
/**
@ -34281,7 +34274,7 @@
$$b('#svg_docprops').hide();
$$b('#canvas_width,#canvas_height').removeAttr('disabled');
$$b('#resolution')[0].selectedIndex = 0;
$$b('#image_save_opts input').val([$$b.pref('img_save')]);
$$b('#image_save_opts input').val([editor.pref('img_save')]);
docprops = false;
};
/**
@ -34338,7 +34331,7 @@
} // Set image save option
$$b.pref('img_save', $$b('#image_save_opts :checked').val());
editor.pref('img_save', $$b('#image_save_opts :checked').val());
updateCanvas();
hideDocProperties();
return true;
@ -34355,7 +34348,7 @@
_asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee11() {
var color, lang, _ref23, langParam, langData;
var color, lang, _ref24, langParam, langData;
return regeneratorRuntime.wrap(function _callee11$(_context11) {
while (1) {
@ -34367,7 +34360,7 @@
lang = $$b('#lang_select').val();
if (!(lang !== $$b.pref('lang'))) {
if (!(lang && lang !== editor.pref('lang'))) {
_context11.next = 11;
break;
}
@ -34376,9 +34369,9 @@
return editor.putLocale(lang, goodLangs, curConfig);
case 6:
_ref23 = _context11.sent;
langParam = _ref23.langParam;
langData = _ref23.langData;
_ref24 = _context11.sent;
langParam = _ref24.langParam;
langData = _ref24.langData;
_context11.next = 11;
return setLang(langParam, langData);
@ -34418,7 +34411,7 @@
var cancelOverlays =
/*#__PURE__*/
function () {
var _ref24 = _asyncToGenerator(
var _ref25 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee12() {
var ok;
@ -34489,7 +34482,7 @@
}));
return function cancelOverlays() {
return _ref24.apply(this, arguments);
return _ref25.apply(this, arguments);
};
}();
@ -34817,7 +34810,7 @@
// Disable option
$$b('#image_save_opts [value=embed]').attr('disabled', 'disabled');
$$b('#image_save_opts input').val(['ref']);
$$b.pref('img_save', 'ref');
editor.pref('img_save', 'ref');
$$b('#image_opt_embed').css('color', '#666').attr('title', uiStrings$1.notification.featNotSupported);
}
});
@ -36231,8 +36224,8 @@
// bitmap handling
reader = new FileReader();
reader.onloadend = function (_ref27) {
var result = _ref27.target.result;
reader.onloadend = function (_ref28) {
var result = _ref28.target.result;
/**
* Insert the new image until we know its dimensions.
@ -36284,7 +36277,7 @@
var open = $$b('<input type="file">').change(
/*#__PURE__*/
function () {
var _ref28 = _asyncToGenerator(
var _ref29 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee16(e) {
var ok, reader;
@ -36315,15 +36308,15 @@
reader.onloadend =
/*#__PURE__*/
function () {
var _ref30 = _asyncToGenerator(
var _ref31 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee15(_ref29) {
regeneratorRuntime.mark(function _callee15(_ref30) {
var target;
return regeneratorRuntime.wrap(function _callee15$(_context15) {
while (1) {
switch (_context15.prev = _context15.next) {
case 0:
target = _ref29.target;
target = _ref30.target;
_context15.next = 3;
return loadSvgString(target.result);
@ -36339,7 +36332,7 @@
}));
return function (_x7) {
return _ref30.apply(this, arguments);
return _ref31.apply(this, arguments);
};
}();
@ -36355,7 +36348,7 @@
}));
return function (_x6) {
return _ref28.apply(this, arguments);
return _ref29.apply(this, arguments);
};
}());
$$b('#tool_open').show();
@ -36386,7 +36379,7 @@
var setLang = editor.setLang =
/*#__PURE__*/
function () {
var _ref31 = _asyncToGenerator(
var _ref32 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee17(lang, allStrings) {
var oldLayerName, renameLayer, elems;
@ -36395,7 +36388,7 @@
switch (_context17.prev = _context17.next) {
case 0:
editor.langChanged = true;
$$b.pref('lang', lang);
editor.pref('lang', lang);
$$b('#lang_select').val(lang);
if (allStrings) {
@ -36494,7 +36487,7 @@
}));
return function (_x8, _x9) {
return _ref31.apply(this, arguments);
return _ref32.apply(this, arguments);
};
}();
@ -36588,9 +36581,9 @@
case 0:
_context20.prev = 0;
_context20.next = 3;
return Promise.all(callbacks.map(function (_ref34) {
var _ref35 = _slicedToArray(_ref34, 1),
cb = _ref35[0];
return Promise.all(callbacks.map(function (_ref35) {
var _ref36 = _slicedToArray(_ref35, 1),
cb = _ref36[0];
return cb(); // eslint-disable-line promise/prefer-await-to-callbacks
}));
@ -36602,18 +36595,18 @@
case 5:
_context20.prev = 5;
_context20.t0 = _context20["catch"](0);
callbacks.forEach(function (_ref36) {
var _ref37 = _slicedToArray(_ref36, 3),
reject = _ref37[2];
callbacks.forEach(function (_ref37) {
var _ref38 = _slicedToArray(_ref37, 3),
reject = _ref38[2];
reject();
});
throw _context20.t0;
case 9:
callbacks.forEach(function (_ref38) {
var _ref39 = _slicedToArray(_ref38, 2),
resolve = _ref39[1];
callbacks.forEach(function (_ref39) {
var _ref40 = _slicedToArray(_ref39, 2),
resolve = _ref40[1];
resolve();
});
@ -36634,8 +36627,8 @@
*/
editor.loadFromString = function (str) {
var _ref40 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
noAlert = _ref40.noAlert;
var _ref41 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
noAlert = _ref41.noAlert;
return editor.ready(
/*#__PURE__*/
@ -36705,9 +36698,9 @@
editor.loadFromURL = function (url) {
var _ref42 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
cache = _ref42.cache,
noAlert = _ref42.noAlert;
var _ref43 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
cache = _ref43.cache,
noAlert = _ref43.noAlert;
return editor.ready(function () {
return new Promise(function (resolve, reject) {
@ -36756,8 +36749,8 @@
editor.loadFromDataURI = function (str) {
var _ref43 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
noAlert = _ref43.noAlert;
var _ref44 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
noAlert = _ref44.noAlert;
return editor.ready(function () {
var base64 = false;
@ -36814,9 +36807,9 @@
* @returns {void}
*/
var messageListener = function messageListener(_ref44) {
var data = _ref44.data,
origin = _ref44.origin;
var messageListener = function messageListener(_ref45) {
var data = _ref45.data,
origin = _ref45.origin;
// eslint-disable-line no-shadow
// console.log('data, origin, extensionsAdded', data, origin, extensionsAdded);
var messageObj = {

View File

@ -28618,44 +28618,33 @@
case 0:
if (givenParam) {
langParam = givenParam;
} else {
langParam = $$a.pref('lang');
} else if (navigator.userLanguage) {
// Explorer
langParam = navigator.userLanguage;
} else if (navigator.language) {
// FF, Opera, ...
langParam = navigator.language;
}
if (!langParam) {
if (navigator.userLanguage) {
// Explorer
langParam = navigator.userLanguage;
} else if (navigator.language) {
// FF, Opera, ...
langParam = navigator.language;
}
}
console.log('Lang: ' + langParam); // eslint-disable-line no-console
// Set to English if language is not in list of good langs
if (!goodLangs.includes(langParam) && langParam !== 'test') {
langParam = 'en';
} // don't bother on first run if language is English
// The following line prevents setLang from running
// extensions which depend on updated uiStrings,
// so commenting it out.
// if (langParam.startsWith('en')) {return;}
console.log('Lang: ' + langParam); // eslint-disable-line no-console
// Set to English if language is not in list of good langs
if (!goodLangs.includes(langParam) && langParam !== 'test') {
langParam = 'en';
}
url = conf.langPath + 'lang.' + langParam + '.js';
_context2.t0 = readLang;
_context2.next = 5;
_context2.next = 7;
return importSetGlobalDefault(url, {
global: 'svgEditorLang_' + langParam.replace(/-/g, '_')
});
case 5:
case 7:
_context2.t1 = _context2.sent;
return _context2.abrupt("return", (0, _context2.t0)(_context2.t1));
case 7:
case 9:
case "end":
return _context2.stop();
}
@ -29155,7 +29144,7 @@
_loadSvgString = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee23(str) {
var _ref46,
var _ref47,
noAlert,
success,
_args23 = arguments;
@ -29164,7 +29153,7 @@
while (1) {
switch (_context23.prev = _context23.next) {
case 0:
_ref46 = _args23.length > 1 && _args23[1] !== undefined ? _args23[1] : {}, noAlert = _ref46.noAlert;
_ref47 = _args23.length > 1 && _args23[1] !== undefined ? _args23[1] : {}, noAlert = _ref47.noAlert;
success = svgCanvas.setSvgString(str) !== false;
if (!success) {
@ -29276,16 +29265,16 @@
* @param {boolean} [mayBeEmpty] If value may be falsey.
* @returns {string|void} If val is missing or falsey and `mayBeEmpty` is not set, the
* value of the previously stored preference will be returned.
* @todo Can we change setting on the jQuery namespace (onto editor) to avoid conflicts?
* @todo Review whether any remaining existing direct references to
* getting `curPrefs` can be changed to use `$.pref()` getting to ensure
* `defaultPrefs` fallback (also for sake of `allowInitialUserOverride`); specifically, `bkgd_color` could be changed so that
* the pref dialog has a button to auto-calculate background, but otherwise uses `$.pref()` to be able to get default prefs
* or overridable settings
* getting `curPrefs` can be changed to use `svgEditor.pref()` getting to ensure
* `defaultPrefs` fallback (also for sake of `allowInitialUserOverride`);
* specifically, `bkgd_color` could be changed so that the pref dialog has a
* button to auto-calculate background, but otherwise uses `svgEditor.pref()` to
* be able to get default prefs or overridable settings
*/
$$b.pref = function (key, val, mayBeEmpty) {
editor.pref = function (key, val, mayBeEmpty) {
if (mayBeEmpty || val) {
curPrefs[key] = val;
/**
@ -29414,7 +29403,7 @@
if (cfgCfg.allowInitialUserOverride === true) {
defaultPrefs[key] = val;
} else {
$$b.pref(key, val);
editor.pref(key, val);
}
} else if (['extensions', 'stylesheets', 'allowedOrigins'].includes(key)) {
if (cfgCfg.overwrite === false && (curConfig.preventAllURLConfig || ['allowedOrigins', 'stylesheets'].includes(key) || key === 'extensions' && curConfig.lockExtensions)) {
@ -29626,7 +29615,6 @@
(function () {
// Load config/data from URL if given
var src, qstr;
urldata = $$b.deparam.querystring(true);
if (!$$b.isEmptyObject(urldata)) {
@ -29659,21 +29647,26 @@
setupCurConfig();
if (!curConfig.preventURLContentLoading) {
src = urldata.source;
qstr = $$b.param.querystring();
var _urldata = urldata,
source = _urldata.source;
if (!src) {
if (!source) {
// urldata.source may have been null if it ended with '='
if (qstr.includes('source=data:')) {
src = qstr.match(/source=(data:[^&]*)/)[1]; // ({src} = qstr.match(/source=(?<src>data:[^&]*)/).groups);
var _ref4 = new URL(location),
searchParams = _ref4.searchParams;
var src = searchParams.get('source');
if (src.startsWith('data:')) {
source = src;
}
}
if (src) {
if (src.startsWith('data:')) {
editor.loadFromDataURI(src);
if (source) {
if (source.startsWith('data:')) {
editor.loadFromDataURI(source);
} else {
editor.loadFromString(src);
editor.loadFromString(source);
}
return;
@ -29728,22 +29721,22 @@
var extAndLocaleFunc =
/*#__PURE__*/
function () {
var _ref4 = _asyncToGenerator(
var _ref5 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee3() {
var _ref5, langParam, langData, _uiStrings$common, ok, cancel;
var _ref6, langParam, langData, _uiStrings$common, ok, cancel;
return regeneratorRuntime.wrap(function _callee3$(_context3) {
while (1) {
switch (_context3.prev = _context3.next) {
case 0:
_context3.next = 2;
return editor.putLocale(null, goodLangs, curConfig);
return editor.putLocale(editor.pref('lang'), goodLangs, curConfig);
case 2:
_ref5 = _context3.sent;
langParam = _ref5.langParam;
langData = _ref5.langData;
_ref6 = _context3.sent;
langParam = _ref6.langParam;
langData = _ref6.langData;
_context3.next = 7;
return setLang(langParam, langData);
@ -29760,7 +29753,7 @@
return Promise.all(curConfig.extensions.map(
/*#__PURE__*/
function () {
var _ref6 = _asyncToGenerator(
var _ref7 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee2(extname) {
var extName, url, imported, _imported$name, _name2, init, importLocale;
@ -29828,7 +29821,7 @@
}));
return function (_x2) {
return _ref6.apply(this, arguments);
return _ref7.apply(this, arguments);
};
}()));
@ -29880,7 +29873,7 @@
}));
return function extAndLocaleFunc() {
return _ref4.apply(this, arguments);
return _ref5.apply(this, arguments);
};
}();
@ -30014,7 +30007,7 @@
scaleElements(elems, scale);
hiddenPs.css('visibility', 'visible').hide(); // return;
$$b.pref('iconsize', size);
editor.pref('iconsize', size);
$$b('#iconsize').val(size); // Change icon size
// $('.tool_button, .push_button, .tool_button_current, .disabled, .icon_label, #url_notice, #tool_open')
// .find('> svg, > img').each(function () {
@ -30374,7 +30367,7 @@
while (1) {
switch (_context4.prev = _context4.next) {
case 0:
getStylesheetPriority = function _ref8(stylesheetFile) {
getStylesheetPriority = function _ref9(stylesheetFile) {
switch (stylesheetFile) {
case 'jgraduate/css/jPicker.css':
return 1;
@ -30402,7 +30395,7 @@
minHeight = tleft.offset().top + tleft.outerHeight();
}
size = $$b.pref('iconsize');
size = editor.pref('iconsize');
editor.setIconSize(size || ($$b(window).height() < minHeight ? 's' : 'm')); // Look for any missing flyout icons from plugins
$$b('.tools_flyout').each(function () {
@ -30449,10 +30442,10 @@
_context4.next = 11;
return loadStylesheets(stylesheets, {
acceptErrors: function acceptErrors(_ref7) {
var stylesheetURL = _ref7.stylesheetURL,
reject = _ref7.reject,
resolve = _ref7.resolve;
acceptErrors: function acceptErrors(_ref8) {
var stylesheetURL = _ref8.stylesheetURL,
reject = _ref8.reject,
resolve = _ref8.resolve;
if ($$b.loadingStylesheets.includes(stylesheetURL)) {
reject(new Error("Missing expected stylesheet: ".concat(stylesheetURL)));
@ -30739,7 +30732,7 @@
a.click(); // Alert will only appear the first time saved OR the
// first time the bug is encountered
var done = $$b.pref('save_notice_done');
var done = editor.pref('save_notice_done');
if (done !== 'all') {
var note = uiStrings$1.notification.saveFromBrowser.replace('%s', 'SVG'); // Check if FF and has <defs/>
@ -30748,13 +30741,13 @@
if (svg.includes('<defs')) {
// warning about Mozilla bug #308590 when applicable (seems to be fixed now in Feb 2013)
note += '\n\n' + uiStrings$1.notification.defsFailOnSave;
$$b.pref('save_notice_done', 'all');
editor.pref('save_notice_done', 'all');
done = 'all';
} else {
$$b.pref('save_notice_done', 'part');
editor.pref('save_notice_done', 'part');
}
} else {
$$b.pref('save_notice_done', 'all');
editor.pref('save_notice_done', 'all');
}
if (done !== 'part') {
@ -30782,7 +30775,7 @@
}
exportWindow.location.href = data.bloburl || data.datauri;
var done = $$b.pref('export_notice_done');
var done = editor.pref('export_notice_done');
if (done !== 'all') {
var note = uiStrings$1.notification.saveFromBrowser.replace('%s', data.type); // Check if there are issues
@ -30794,7 +30787,7 @@
// May want to find a way to deal with that without annoying the user
$$b.pref('export_notice_done', 'all');
editor.pref('export_notice_done', 'all');
exportWindow.alert(note);
}
};
@ -30924,9 +30917,9 @@
function setBackground(color, url) {
// if (color == $.pref('bkgd_color') && url == $.pref('bkgd_url')) { return; }
$$b.pref('bkgd_color', color);
$$b.pref('bkgd_url', url, true); // This should be done in svgcanvas.js for the borderRect fill
// if (color == editor.pref('bkgd_color') && url == editor.pref('bkgd_url')) { return; }
editor.pref('bkgd_color', color);
editor.pref('bkgd_url', url, true); // This should be done in svgcanvas.js for the borderRect fill
svgCanvas.setBackground(color, url);
}
@ -30950,8 +30943,8 @@
_promptImgURL = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee18() {
var _ref32,
_ref32$cancelDeletes,
var _ref33,
_ref33$cancelDeletes,
cancelDeletes,
curhref,
url,
@ -30961,7 +30954,7 @@
while (1) {
switch (_context18.prev = _context18.next) {
case 0:
_ref32 = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : {}, _ref32$cancelDeletes = _ref32.cancelDeletes, cancelDeletes = _ref32$cancelDeletes === void 0 ? false : _ref32$cancelDeletes;
_ref33 = _args18.length > 0 && _args18[0] !== undefined ? _args18[0] : {}, _ref33$cancelDeletes = _ref33.cancelDeletes, cancelDeletes = _ref33$cancelDeletes === void 0 ? false : _ref33$cancelDeletes;
curhref = svgCanvas.getHref(selectedElement);
curhref = curhref.startsWith('data:') ? '' : curhref;
_context18.next = 5;
@ -31969,10 +31962,10 @@
// Get this button's options
var idSel = '#' + this.getAttribute('id');
var _Object$entries$find = Object.entries(btnOpts).find(function (_ref9) {
var _ref10 = _slicedToArray(_ref9, 2),
_ = _ref10[0],
sel = _ref10[1].sel;
var _Object$entries$find = Object.entries(btnOpts).find(function (_ref10) {
var _ref11 = _slicedToArray(_ref10, 2),
_ = _ref11[0],
sel = _ref11[1].sel;
return sel === idSel;
}),
@ -31999,10 +31992,10 @@
if (ev.type === 'keydown') {
var flyoutIsSelected = $$b(options.parent + '_show').hasClass('tool_button_current');
var currentOperation = $$b(options.parent + '_show').attr('data-curopt');
Object.entries(holders[opts.parent]).some(function (_ref11) {
var _ref12 = _slicedToArray(_ref11, 2),
j = _ref12[0],
tool = _ref12[1];
Object.entries(holders[opts.parent]).some(function (_ref12) {
var _ref13 = _slicedToArray(_ref12, 2),
j = _ref13[0],
tool = _ref13[1];
if (tool.sel !== currentOperation) {
return false;
@ -32215,7 +32208,7 @@
var extAdded =
/*#__PURE__*/
function () {
var _ref13 = _asyncToGenerator(
var _ref14 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee5(win, ext) {
var cbCalled, resizeDone, lang, prepResize, runCallback, btnSelects, svgicons, fallbackObj, altsObj, placementObj, holders;
@ -32223,7 +32216,7 @@
while (1) {
switch (_context5.prev = _context5.next) {
case 0:
prepResize = function _ref14() {
prepResize = function _ref15() {
if (resizeTimer) {
clearTimeout(resizeTimer);
resizeTimer = null;
@ -32232,7 +32225,7 @@
if (!resizeDone) {
resizeTimer = setTimeout(function () {
resizeDone = true;
setIconSize($$b.pref('iconsize'));
setIconSize(editor.pref('iconsize'));
}, 50);
}
};
@ -32259,7 +32252,7 @@
}
// We check for this since the "lang" pref could have been set by storage
lang = $$b.pref('lang');
lang = editor.pref('lang');
_context5.next = 10;
return ext.langReady({
lang: lang,
@ -32676,7 +32669,7 @@
callback: function callback(icons) {
// Non-ideal hack to make the icon match the current size
// if (curPrefs.iconsize && curPrefs.iconsize !== 'm') {
if ($$b.pref('iconsize') !== 'm') {
if (editor.pref('iconsize') !== 'm') {
prepResize();
}
@ -32698,7 +32691,7 @@
}));
return function extAdded(_x4, _x5) {
return _ref13.apply(this, arguments);
return _ref14.apply(this, arguments);
};
}();
/**
@ -32773,9 +32766,9 @@
* @listens module:svgcanvas.SvgCanvas#event:updateCanvas
* @returns {void}
*/
function (win, _ref15) {
var center = _ref15.center,
newCtr = _ref15.newCtr;
function (win, _ref16) {
var center = _ref16.center,
newCtr = _ref16.newCtr;
updateCanvas(center, newCtr);
});
svgCanvas.bind('contextset', contextChanged);
@ -32804,8 +32797,8 @@
$$b(this).addClass(curBg);
});
});
setBackground($$b.pref('bkgd_color'), $$b.pref('bkgd_url'));
$$b('#image_save_opts input').val([$$b.pref('img_save')]);
setBackground(editor.pref('bkgd_color'), editor.pref('bkgd_url'));
$$b('#image_save_opts input').val([editor.pref('img_save')]);
/**
* @type {module:jQuerySpinButton.ValueCallback}
*/
@ -33656,7 +33649,7 @@
var makeHyperlink =
/*#__PURE__*/
function () {
var _ref17 = _asyncToGenerator(
var _ref18 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee7() {
var url;
@ -33688,7 +33681,7 @@
}));
return function makeHyperlink() {
return _ref17.apply(this, arguments);
return _ref18.apply(this, arguments);
};
}();
/**
@ -33811,7 +33804,7 @@
var clickClear =
/*#__PURE__*/
function () {
var _ref18 = _asyncToGenerator(
var _ref19 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee8() {
var _curConfig$dimensions, x, y, ok;
@ -33854,7 +33847,7 @@
}));
return function clickClear() {
return _ref18.apply(this, arguments);
return _ref19.apply(this, arguments);
};
}();
/**
@ -33888,7 +33881,7 @@
var clickSave = function clickSave() {
// In the future, more options can be provided here
var saveOpts = {
images: $$b.pref('img_save'),
images: editor.pref('img_save'),
round_digits: 6
};
svgCanvas.save(saveOpts);
@ -33903,7 +33896,7 @@
var clickExport =
/*#__PURE__*/
function () {
var _ref19 = _asyncToGenerator(
var _ref20 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee9() {
var imgType, exportWindowName, openExportWindow, chrome, quality;
@ -33911,7 +33904,7 @@
while (1) {
switch (_context9.prev = _context9.next) {
case 0:
openExportWindow = function _ref20() {
openExportWindow = function _ref21() {
var loadingImage = uiStrings$1.notification.loadingImage;
if (curConfig.exportWindowType === 'new') {
@ -34002,7 +33995,7 @@
}));
return function clickExport() {
return _ref19.apply(this, arguments);
return _ref20.apply(this, arguments);
};
}();
/**
@ -34126,7 +34119,7 @@
docprops = true; // This selects the correct radio button by using the array notation
$$b('#image_save_opts input').val([$$b.pref('img_save')]); // update resolution option with actual resolution
$$b('#image_save_opts input').val([editor.pref('img_save')]); // update resolution option with actual resolution
var res = svgCanvas.getResolution();
@ -34155,7 +34148,7 @@
$$b('#main_menu').hide(); // Update background color with current one
var canvasBg = curPrefs.bkgd_color;
var url = $$b.pref('bkgd_url');
var url = editor.pref('bkgd_url');
blocks.each(function () {
var blk = $$b(this);
var isBg = blk.css('background-color') === canvasBg;
@ -34208,7 +34201,7 @@
var saveSourceEditor =
/*#__PURE__*/
function () {
var _ref21 = _asyncToGenerator(
var _ref22 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee10() {
var saveChanges, ok;
@ -34268,7 +34261,7 @@
}));
return function saveSourceEditor() {
return _ref21.apply(this, arguments);
return _ref22.apply(this, arguments);
};
}();
/**
@ -34281,7 +34274,7 @@
$$b('#svg_docprops').hide();
$$b('#canvas_width,#canvas_height').removeAttr('disabled');
$$b('#resolution')[0].selectedIndex = 0;
$$b('#image_save_opts input').val([$$b.pref('img_save')]);
$$b('#image_save_opts input').val([editor.pref('img_save')]);
docprops = false;
};
/**
@ -34338,7 +34331,7 @@
} // Set image save option
$$b.pref('img_save', $$b('#image_save_opts :checked').val());
editor.pref('img_save', $$b('#image_save_opts :checked').val());
updateCanvas();
hideDocProperties();
return true;
@ -34355,7 +34348,7 @@
_asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee11() {
var color, lang, _ref23, langParam, langData;
var color, lang, _ref24, langParam, langData;
return regeneratorRuntime.wrap(function _callee11$(_context11) {
while (1) {
@ -34367,7 +34360,7 @@
lang = $$b('#lang_select').val();
if (!(lang !== $$b.pref('lang'))) {
if (!(lang && lang !== editor.pref('lang'))) {
_context11.next = 11;
break;
}
@ -34376,9 +34369,9 @@
return editor.putLocale(lang, goodLangs, curConfig);
case 6:
_ref23 = _context11.sent;
langParam = _ref23.langParam;
langData = _ref23.langData;
_ref24 = _context11.sent;
langParam = _ref24.langParam;
langData = _ref24.langData;
_context11.next = 11;
return setLang(langParam, langData);
@ -34418,7 +34411,7 @@
var cancelOverlays =
/*#__PURE__*/
function () {
var _ref24 = _asyncToGenerator(
var _ref25 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee12() {
var ok;
@ -34489,7 +34482,7 @@
}));
return function cancelOverlays() {
return _ref24.apply(this, arguments);
return _ref25.apply(this, arguments);
};
}();
@ -34817,7 +34810,7 @@
// Disable option
$$b('#image_save_opts [value=embed]').attr('disabled', 'disabled');
$$b('#image_save_opts input').val(['ref']);
$$b.pref('img_save', 'ref');
editor.pref('img_save', 'ref');
$$b('#image_opt_embed').css('color', '#666').attr('title', uiStrings$1.notification.featNotSupported);
}
});
@ -36231,8 +36224,8 @@
// bitmap handling
reader = new FileReader();
reader.onloadend = function (_ref27) {
var result = _ref27.target.result;
reader.onloadend = function (_ref28) {
var result = _ref28.target.result;
/**
* Insert the new image until we know its dimensions.
@ -36284,7 +36277,7 @@
var open = $$b('<input type="file">').change(
/*#__PURE__*/
function () {
var _ref28 = _asyncToGenerator(
var _ref29 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee16(e) {
var ok, reader;
@ -36315,15 +36308,15 @@
reader.onloadend =
/*#__PURE__*/
function () {
var _ref30 = _asyncToGenerator(
var _ref31 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee15(_ref29) {
regeneratorRuntime.mark(function _callee15(_ref30) {
var target;
return regeneratorRuntime.wrap(function _callee15$(_context15) {
while (1) {
switch (_context15.prev = _context15.next) {
case 0:
target = _ref29.target;
target = _ref30.target;
_context15.next = 3;
return loadSvgString(target.result);
@ -36339,7 +36332,7 @@
}));
return function (_x7) {
return _ref30.apply(this, arguments);
return _ref31.apply(this, arguments);
};
}();
@ -36355,7 +36348,7 @@
}));
return function (_x6) {
return _ref28.apply(this, arguments);
return _ref29.apply(this, arguments);
};
}());
$$b('#tool_open').show();
@ -36386,7 +36379,7 @@
var setLang = editor.setLang =
/*#__PURE__*/
function () {
var _ref31 = _asyncToGenerator(
var _ref32 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee17(lang, allStrings) {
var oldLayerName, renameLayer, elems;
@ -36395,7 +36388,7 @@
switch (_context17.prev = _context17.next) {
case 0:
editor.langChanged = true;
$$b.pref('lang', lang);
editor.pref('lang', lang);
$$b('#lang_select').val(lang);
if (allStrings) {
@ -36494,7 +36487,7 @@
}));
return function (_x8, _x9) {
return _ref31.apply(this, arguments);
return _ref32.apply(this, arguments);
};
}();
@ -36588,9 +36581,9 @@
case 0:
_context20.prev = 0;
_context20.next = 3;
return Promise.all(callbacks.map(function (_ref34) {
var _ref35 = _slicedToArray(_ref34, 1),
cb = _ref35[0];
return Promise.all(callbacks.map(function (_ref35) {
var _ref36 = _slicedToArray(_ref35, 1),
cb = _ref36[0];
return cb(); // eslint-disable-line promise/prefer-await-to-callbacks
}));
@ -36602,18 +36595,18 @@
case 5:
_context20.prev = 5;
_context20.t0 = _context20["catch"](0);
callbacks.forEach(function (_ref36) {
var _ref37 = _slicedToArray(_ref36, 3),
reject = _ref37[2];
callbacks.forEach(function (_ref37) {
var _ref38 = _slicedToArray(_ref37, 3),
reject = _ref38[2];
reject();
});
throw _context20.t0;
case 9:
callbacks.forEach(function (_ref38) {
var _ref39 = _slicedToArray(_ref38, 2),
resolve = _ref39[1];
callbacks.forEach(function (_ref39) {
var _ref40 = _slicedToArray(_ref39, 2),
resolve = _ref40[1];
resolve();
});
@ -36634,8 +36627,8 @@
*/
editor.loadFromString = function (str) {
var _ref40 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
noAlert = _ref40.noAlert;
var _ref41 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
noAlert = _ref41.noAlert;
return editor.ready(
/*#__PURE__*/
@ -36705,9 +36698,9 @@
editor.loadFromURL = function (url) {
var _ref42 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
cache = _ref42.cache,
noAlert = _ref42.noAlert;
var _ref43 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
cache = _ref43.cache,
noAlert = _ref43.noAlert;
return editor.ready(function () {
return new Promise(function (resolve, reject) {
@ -36756,8 +36749,8 @@
editor.loadFromDataURI = function (str) {
var _ref43 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
noAlert = _ref43.noAlert;
var _ref44 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
noAlert = _ref44.noAlert;
return editor.ready(function () {
var base64 = false;
@ -36814,9 +36807,9 @@
* @returns {void}
*/
var messageListener = function messageListener(_ref44) {
var data = _ref44.data,
origin = _ref44.origin;
var messageListener = function messageListener(_ref45) {
var data = _ref45.data,
origin = _ref45.origin;
// eslint-disable-line no-shadow
// console.log('data, origin, extensionsAdded', data, origin, extensionsAdded);
var messageObj = {
@ -36900,10 +36893,14 @@
}); // EXTENSION CONFIG
editor.setConfig({
extensions: [// 'ext-overview_window.js', 'ext-markers.js', 'ext-connector.js', 'ext-eyedropper.js', 'ext-shapes.js', 'ext-imagelib.js', 'ext-grid.js', 'ext-polygon.js', 'ext-star.js', 'ext-panning.js', 'ext-storage.js'
extensions: [// 'ext-overview_window.js', 'ext-markers.js', 'ext-connector.js',
// 'ext-eyedropper.js', 'ext-shapes.js', 'ext-imagelib.js',
// 'ext-grid.js', 'ext-polygon.js', 'ext-star.js', 'ext-panning.js',
// 'ext-storage.js'
],
noDefaultExtensions: false // noDefaultExtensions can only be meaningfully used in svgedit-config-iife.js or in the URL
// noDefaultExtensions can only be meaningfully used in
// `svgedit-config-iife.js` or in the URL
noDefaultExtensions: false
}); // STYLESHEET CONFIG
editor.setConfig({
@ -36940,7 +36937,8 @@
Setting as `['*']` would allow any domain to access but would be unsafe to
data privacy and integrity.
*/
// allowedOrigins: [location.origin || 'null'], // May be 'null' (as a string) when used as a `file:///` URL
// May be 'null' (as a string) when used as a `file:///` URL
// allowedOrigins: [location.origin || 'null'],
// DOCUMENT PROPERTIES
// dimensions: [640, 480],
// EDITOR OPTIONS
@ -36952,9 +36950,16 @@
// EXTENSION-RELATED (GRID)
// showGrid: false, // Set by ext-grid.js
// EXTENSION-RELATED (STORAGE)
// noStorageOnLoad: false, // Some interaction with ext-storage.js; prevent even the loading of previously saved local storage
// forceStorage: false, // Some interaction with ext-storage.js; strongly discouraged from modification as it bypasses user privacy by preventing them from choosing whether to keep local storage or not
// emptyStorageOnDecline: true, // Used by ext-storage.js; empty any prior storage if the user declines to store
// Some interaction with `ext-storage.js`; prevent even the loading of
// previously saved local storage
// noStorageOnLoad: false,
// Some interaction with `ext-storage.js`; strongly discouraged from
// modification as it bypasses user privacy by preventing them from
// choosing whether to keep local storage or not
// forceStorage: false,
// Used by `ext-storage.js`; empty any prior storage if the user
// declines to store
// emptyStorageOnDecline: true,
}); // PREF CHANGES
/**
@ -36971,15 +36976,18 @@
are hard-coded here regardless of URL or prior user storage setting.
*/
editor.setConfig({// lang: '', // Set dynamically within locale.js if not previously set
// iconsize: '', // Will default to 's' if the window height is smaller than the minimum height and 'm' otherwise
editor.setConfig({// Set dynamically within locale.js if not previously set
// lang: '',
// Will default to 's' if the window height is smaller than the minimum
// height and 'm' otherwise
// iconsize: '',
/**
* When showing the preferences dialog, svg-editor.js currently relies
* on curPrefs instead of $.pref, so allowing an override for bkgd_color
* means that this value won't have priority over block auto-detection as
* far as determining which color shows initially in the preferences
* dialog (though it can be changed and saved).
* on `curPrefs` instead of `svgEditor.pref`, so allowing an override for
* `bkgd_color` means that this value won't have priority over block
* auto-detection as far as determining which color shows initially
* in the preferences dialog (though it can be changed and saved).
*/
// bkgd_color: '#FFF',
// bkgd_url: '',
@ -36988,9 +36996,10 @@
// save_notice_done: false,
// export_notice_done: false
});
editor.setConfig({// Indicate pref settings here if you wish to allow user storage or URL settings
// to be able to override your default preferences (unless other config options
// have already explicitly prevented one or the other)
editor.setConfig({// Indicate pref settings here if you wish to allow user storage or URL
// settings to be able to override your default preferences (unless
// other config options have already explicitly prevented one or the
// other)
}, {
allowInitialUserOverride: true
});