- Breaking change: Remove `storagePromptClosed` state boolean in favor of

`storagePromptState`; used by `ext-storage.js`
- Fix (regression): Ensure storage dialog will not be blocked because of
    canvas updating done for sake of centering background
- Fix (extensions): Ensure `langReady` changes are available by time prefs
  dialog is closed and that its changes have occurred by time extensions
  have first loaded (`setLang` now returns a Promise rather than `undefined`
  as it waits for extension's `langReady` to resolve); this is also useful
  with `ext-storage.js` so we know that `extensions_loaded` (which
  conditionally updates the canvas based on `storagePromptState`) has seen
  `langReady` and the storage extension hasn't set a `storagePromptState`
  of "waiting"
master
Brett Zamir 2018-10-21 18:33:23 +08:00
parent c37e60fd87
commit d13f99bb5e
12 changed files with 2580 additions and 2171 deletions

View File

@ -4,6 +4,8 @@
- Breaking change: For checkbox for persisting choice of initial use storage - Breaking change: For checkbox for persisting choice of initial use storage
approval in storage extension dialog, turn on by default for convenience of approval in storage extension dialog, turn on by default for convenience of
most users (must still hit "ok" and users can still turn off the checkbox) most users (must still hit "ok" and users can still turn off the checkbox)
- Breaking change: Remove `storagePromptClosed` state boolean in favor of
`storagePromptState`; used by `ext-storage.js`
- Fix: Map extension click events to "mousedown" so they can be received - Fix: Map extension click events to "mousedown" so they can be received
on touch devices (since `touch.js` changes `touchstart` to on touch devices (since `touch.js` changes `touchstart` to
`mousedown`) (@ClemArt); closes #168 `mousedown`) (@ClemArt); closes #168
@ -13,6 +15,14 @@
retaining preference (and ensure language changes are available before retaining preference (and ensure language changes are available before
dialog closed) dialog closed)
- Fix: Centering of canvas wasn't being set at proper time; fixes #272 - Fix: Centering of canvas wasn't being set at proper time; fixes #272
- Fix (extensions): Ensure `langReady` changes are available by time prefs
dialog is closed and that its changes have occurred by time extensions
have first loaded (`setLang` now returns a Promise rather than `undefined`
as it waits for extension's `langReady` to resolve); this is also useful
with `ext-storage.js` so we know that `extensions_loaded` (which
conditionally updates the canvas based on `storagePromptState`) has seen
`langReady` and the storage extension hasn't set a `storagePromptState`
of "waiting"
- Fix (regression): Extension locale loading for non-English locales - Fix (regression): Extension locale loading for non-English locales
- Enhancement: Allow "Escape" to work with hotkeys within text boxes; - Enhancement: Allow "Escape" to work with hotkeys within text boxes;
allows escaping out of source textarea (part of #291) allows escaping out of source textarea (part of #291)

View File

@ -76,7 +76,8 @@ var svgEditorExtension_storage = (function () {
emptyStorageOnDecline = _svgEditor$curConfig.emptyStorageOnDecline, emptyStorageOnDecline = _svgEditor$curConfig.emptyStorageOnDecline,
noStorageOnLoad = _svgEditor$curConfig.noStorageOnLoad, noStorageOnLoad = _svgEditor$curConfig.noStorageOnLoad,
forceStorage = _svgEditor$curConfig.forceStorage; forceStorage = _svgEditor$curConfig.forceStorage;
var storage = svgEditor.storage; var storage = svgEditor.storage,
updateCanvas = svgEditor.updateCanvas;
function replaceStoragePrompt(val) { function replaceStoragePrompt(val) {
val = val ? 'storagePrompt=' + val : ''; val = val ? 'storagePrompt=' + val : '';
@ -304,12 +305,14 @@ var svgEditorExtension_storage = (function () {
// the prompt gives the user the option to store data // the prompt gives the user the option to store data
setupBeforeUnloadListener(); setupBeforeUnloadListener();
svgEditor.storagePromptClosed = true; svgEditor.storagePromptState = 'closed';
updateCanvas(true);
}, null, null, { }, null, null, {
label: rememberLabel, label: rememberLabel,
checked: true, checked: true,
tooltip: rememberTooltip tooltip: rememberTooltip
}); });
svgEditor.storagePromptState = 'waiting';
} else if (!noStorageOnLoad || forceStorage) { } else if (!noStorageOnLoad || forceStorage) {
setupBeforeUnloadListener(); setupBeforeUnloadListener();
} }

309
dist/index-es.js vendored
View File

@ -27561,11 +27561,11 @@ editor.langChanged = false;
editor.showSaveWarning = false; editor.showSaveWarning = false;
/** /**
* @type {boolean} * Will be set to a boolean by `ext-storage.js`
* @type {"ignore"|"waiting"|"closed"}
*/ */
editor.storagePromptClosed = false; // For use with ext-storage.js editor.storagePromptState = 'ignore';
var callbacks = [], var callbacks = [],
/** /**
@ -28367,9 +28367,12 @@ editor.init = function () {
_ref6 = _context4.sent; _ref6 = _context4.sent;
langParam = _ref6.langParam; langParam = _ref6.langParam;
langData = _ref6.langData; langData = _ref6.langData;
setLang(langParam, langData); _context4.next = 7;
_context4.prev = 6; return setLang(langParam, langData);
_context4.next = 9;
case 7:
_context4.prev = 7;
_context4.next = 10;
return Promise.all(curConfig.extensions.map( return Promise.all(curConfig.extensions.map(
/*#__PURE__*/ /*#__PURE__*/
function () { function () {
@ -28436,7 +28439,7 @@ editor.init = function () {
}; };
}())); }()));
case 9: case 10:
svgCanvas.bind('extensions_added', svgCanvas.bind('extensions_added',
/** /**
* @param {external:Window} win * @param {external:Window} win
@ -28450,7 +28453,11 @@ editor.init = function () {
$$b('.flyout_arrow_horiz:empty').each(function () { $$b('.flyout_arrow_horiz:empty').each(function () {
$$b(this).append($$b.getSvgIcon('arrow_right', true).width(5).height(5)); $$b(this).append($$b.getSvgIcon('arrow_right', true).width(5).height(5));
}); });
if (editor.storagePromptState === 'ignore') {
updateCanvas(true); updateCanvas(true);
}
messageQueue.forEach( messageQueue.forEach(
/** /**
* @param {module:svgcanvas.SvgCanvas#event:message} messageObj * @param {module:svgcanvas.SvgCanvas#event:message} messageObj
@ -28462,20 +28469,20 @@ editor.init = function () {
}); });
}); });
svgCanvas.call('extensions_added'); svgCanvas.call('extensions_added');
_context4.next = 16; _context4.next = 17;
break; break;
case 13: case 14:
_context4.prev = 13; _context4.prev = 14;
_context4.t0 = _context4["catch"](6); _context4.t0 = _context4["catch"](7);
console.log(_context4.t0); console.log(_context4.t0);
case 16: case 17:
case "end": case "end":
return _context4.stop(); return _context4.stop();
} }
} }
}, _callee4, this, [[6, 13]]); }, _callee4, this, [[7, 14]]);
})); }));
return function extAndLocaleFunc() { return function extAndLocaleFunc() {
@ -29797,7 +29804,7 @@ editor.init = function () {
workarea.scroll(); workarea.scroll();
} }
if (urldata.storagePrompt !== true && !editor.storagePromptClosed) { if (urldata.storagePrompt !== true && editor.storagePromptState === 'ignore') {
$$b('#dialog_box').hide(); $$b('#dialog_box').hide();
} }
}; };
@ -30725,33 +30732,18 @@ editor.init = function () {
* @returns {Promise} Resolves to `undefined` * @returns {Promise} Resolves to `undefined`
*/ */
var extAdded = function extAdded(win, ext) { var extAdded =
if (!ext) { /*#__PURE__*/
return; function () {
} var _ref14 = _asyncToGenerator(
/*#__PURE__*/
var cbCalled = false; regeneratorRuntime.mark(function _callee5(win, ext) {
var resizeDone = false; var cbCalled, resizeDone, lang, prepResize, runCallback, btnSelects, svgicons, fallbackObj, placementObj, holders;
return regeneratorRuntime.wrap(function _callee5$(_context5) {
if (ext.langReady) { while (1) {
if (editor.langChanged) { switch (_context5.prev = _context5.next) {
// We check for this since the "lang" pref could have been set by storage case 0:
var lang = $$b.pref('lang'); prepResize = function _ref15() {
ext.langReady({
lang: lang,
uiStrings: uiStrings$1,
importLocale: getImportLocale({
defaultLang: lang,
defaultName: ext.name
})
});
loadedExtensionNames.push(ext.name);
} else {
extsPreLang.push(ext);
}
}
function prepResize() {
if (resizeTimer) { if (resizeTimer) {
clearTimeout(resizeTimer); clearTimeout(resizeTimer);
resizeTimer = null; resizeTimer = null;
@ -30763,16 +30755,58 @@ editor.init = function () {
setIconSize($$b.pref('iconsize')); setIconSize($$b.pref('iconsize'));
}, 50); }, 50);
} }
};
if (ext) {
_context5.next = 3;
break;
} }
var runCallback = function runCallback() { return _context5.abrupt("return");
case 3:
cbCalled = false;
resizeDone = false;
if (!ext.langReady) {
_context5.next = 14;
break;
}
if (!editor.langChanged) {
_context5.next = 13;
break;
}
// We check for this since the "lang" pref could have been set by storage
lang = $$b.pref('lang');
_context5.next = 10;
return ext.langReady({
lang: lang,
uiStrings: uiStrings$1,
importLocale: getImportLocale({
defaultLang: lang,
defaultName: ext.name
})
});
case 10:
loadedExtensionNames.push(ext.name);
_context5.next = 14;
break;
case 13:
extsPreLang.push(ext);
case 14:
runCallback = function runCallback() {
if (ext.callback && !cbCalled) { if (ext.callback && !cbCalled) {
cbCalled = true; cbCalled = true;
ext.callback.call(editor); ext.callback.call(editor);
} }
}; };
var btnSelects = []; btnSelects = [];
/** /**
* @typedef {PlainObject} module:SVGEditor.ContextTool * @typedef {PlainObject} module:SVGEditor.ContextTool
* @property {string} panel The ID of the existing panel to which the tool is being added. Required. * @property {string} panel The ID of the existing panel to which the tool is being added. Required.
@ -30875,12 +30909,14 @@ editor.init = function () {
}); });
} }
var svgicons = ext.svgicons; svgicons = ext.svgicons;
if (ext.buttons) { if (!ext.buttons) {
var fallbackObj = {}, _context5.next = 24;
placementObj = {}, break;
holders = {}; }
fallbackObj = {}, placementObj = {}, holders = {};
/** /**
* @typedef {GenericArray} module:SVGEditor.KeyArray * @typedef {GenericArray} module:SVGEditor.KeyArray
* @property {string} 0 The key to bind (on `keydown`) * @property {string} 0 The key to bind (on `keydown`)
@ -31133,8 +31169,12 @@ editor.init = function () {
}); });
}); });
if (svgicons) { if (!svgicons) {
return new Promise(function (resolve, reject) { _context5.next = 24;
break;
}
return _context5.abrupt("return", new Promise(function (resolve, reject) {
$$b.svgIcons(svgicons, { $$b.svgIcons(svgicons, {
w: 24, w: 24,
h: 24, h: 24,
@ -31153,12 +31193,23 @@ editor.init = function () {
resolve(); resolve();
} }
}); });
}); }));
}
}
return runCallback(); case 24:
return _context5.abrupt("return", runCallback());
case 25:
case "end":
return _context5.stop();
}
}
}, _callee5, this);
}));
return function extAdded(_x3, _x4) {
return _ref14.apply(this, arguments);
}; };
}();
var getPaint = function getPaint(color, opac, type) { var getPaint = function getPaint(color, opac, type) {
// update the editor's fill paint // update the editor's fill paint
@ -31222,9 +31273,9 @@ editor.init = function () {
* @listens module:svgcanvas.SvgCanvas#event:updateCanvas * @listens module:svgcanvas.SvgCanvas#event:updateCanvas
* @returns {undefined} * @returns {undefined}
*/ */
function (win, _ref14) { function (win, _ref16) {
var center = _ref14.center, var center = _ref16.center,
newCtr = _ref14.newCtr; newCtr = _ref16.newCtr;
updateCanvas(center, newCtr); updateCanvas(center, newCtr);
}); });
svgCanvas.bind('contextset', contextChanged); svgCanvas.bind('contextset', contextChanged);
@ -32032,15 +32083,15 @@ editor.init = function () {
'PNG', 'JPEG', 'BMP', 'WEBP', 'PDF'], 'PNG', 'JPEG', 'BMP', 'WEBP', 'PDF'],
/*#__PURE__*/ /*#__PURE__*/
function () { function () {
var _ref15 = _asyncToGenerator( var _ref17 = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee5(imgType) { regeneratorRuntime.mark(function _callee6(imgType) {
var exportWindowName, openExportWindow, chrome, quality; var exportWindowName, openExportWindow, chrome, quality;
return regeneratorRuntime.wrap(function _callee5$(_context5) { return regeneratorRuntime.wrap(function _callee6$(_context6) {
while (1) { while (1) {
switch (_context5.prev = _context5.next) { switch (_context6.prev = _context6.next) {
case 0: case 0:
openExportWindow = function _ref16() { openExportWindow = function _ref18() {
var str = uiStrings$1.notification.loadingImage; var str = uiStrings$1.notification.loadingImage;
if (curConfig.exportWindowType === 'new') { if (curConfig.exportWindowType === 'new') {
@ -32071,17 +32122,17 @@ editor.init = function () {
}; };
if (imgType) { if (imgType) {
_context5.next = 3; _context6.next = 3;
break; break;
} }
return _context5.abrupt("return"); return _context6.abrupt("return");
case 3: case 3:
chrome = isChrome(); chrome = isChrome();
if (!(imgType === 'PDF')) { if (!(imgType === 'PDF')) {
_context5.next = 9; _context6.next = 9;
break; break;
} }
@ -32090,7 +32141,7 @@ editor.init = function () {
} }
svgCanvas.exportPDF(exportWindowName, chrome ? 'save' : undefined); svgCanvas.exportPDF(exportWindowName, chrome ? 'save' : undefined);
_context5.next = 13; _context6.next = 13;
break; break;
case 9: case 9:
@ -32101,19 +32152,19 @@ editor.init = function () {
quality = parseInt($$b('#image-slider').val(), 10) / 100; quality = parseInt($$b('#image-slider').val(), 10) / 100;
/* const results = */ /* const results = */
_context5.next = 13; _context6.next = 13;
return svgCanvas.rasterExport(imgType, quality, exportWindowName); return svgCanvas.rasterExport(imgType, quality, exportWindowName);
case 13: case 13:
case "end": case "end":
return _context5.stop(); return _context6.stop();
} }
} }
}, _callee5, this); }, _callee6, this);
})); }));
return function (_x3) { return function (_x5) {
return _ref15.apply(this, arguments); return _ref17.apply(this, arguments);
}; };
}(), function () { }(), function () {
var sel = $$b(this); var sel = $$b(this);
@ -32350,12 +32401,12 @@ editor.init = function () {
/*#__PURE__*/ /*#__PURE__*/
_asyncToGenerator( _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee6() { regeneratorRuntime.mark(function _callee7() {
var color, lang, _ref18, langParam, langData; var color, lang, _ref20, langParam, langData;
return regeneratorRuntime.wrap(function _callee6$(_context6) { return regeneratorRuntime.wrap(function _callee7$(_context7) {
while (1) { while (1) {
switch (_context6.prev = _context6.next) { switch (_context7.prev = _context7.next) {
case 0: case 0:
// Set background // Set background
color = $$b('#bg_blocks div.cur_background').css('background-color') || '#FFF'; color = $$b('#bg_blocks div.cur_background').css('background-color') || '#FFF';
@ -32364,20 +32415,21 @@ editor.init = function () {
lang = $$b('#lang_select').val(); lang = $$b('#lang_select').val();
if (!(lang !== $$b.pref('lang'))) { if (!(lang !== $$b.pref('lang'))) {
_context6.next = 10; _context7.next = 11;
break; break;
} }
_context6.next = 6; _context7.next = 6;
return editor.putLocale(lang, goodLangs, curConfig); return editor.putLocale(lang, goodLangs, curConfig);
case 6: case 6:
_ref18 = _context6.sent; _ref20 = _context7.sent;
langParam = _ref18.langParam; langParam = _ref20.langParam;
langData = _ref18.langData; langData = _ref20.langData;
setLang(langParam, langData); _context7.next = 11;
return setLang(langParam, langData);
case 10: case 11:
// set icon size // set icon size
setIconSize($$b('#iconsize').val()); // set grid setting setIconSize($$b('#iconsize').val()); // set grid setting
@ -32396,12 +32448,12 @@ editor.init = function () {
updateCanvas(); updateCanvas();
hidePreferences(); hidePreferences();
case 21: case 22:
case "end": case "end":
return _context6.stop(); return _context7.stop();
} }
} }
}, _callee6, this); }, _callee7, this);
})); }));
var resetScrollPos = $$b.noop; var resetScrollPos = $$b.noop;
@ -33969,8 +34021,8 @@ editor.init = function () {
// bitmap handling // bitmap handling
reader = new FileReader(); reader = new FileReader();
reader.onloadend = function (_ref19) { reader.onloadend = function (_ref21) {
var result = _ref19.target.result; var result = _ref21.target.result;
// let's insert the new image until we know its dimensions // let's insert the new image until we know its dimensions
var insertNewImage = function insertNewImage(width, height) { var insertNewImage = function insertNewImage(width, height) {
@ -34042,11 +34094,12 @@ editor.init = function () {
$$b('#tool_open').show().prepend(open); $$b('#tool_open').show().prepend(open);
var imgImport = $$b('<input type="file">').change(importImage); var imgImport = $$b('<input type="file">').change(importImage);
$$b('#tool_import').show().prepend(imgImport); $$b('#tool_import').show().prepend(imgImport);
} // const revnums = 'svg-editor.js ($Rev$) '; }
updateCanvas(true); // const revnums = 'svg-editor.js ($Rev$) ';
// revnums += svgCanvas.getVersion(); // revnums += svgCanvas.getVersion();
// $('#copyright')[0].setAttribute('title', revnums); // $('#copyright')[0].setAttribute('title', revnums);
var loadedExtensionNames = []; var loadedExtensionNames = [];
/** /**
* @function module:SVGEditor.setLang * @function module:SVGEditor.setLang
@ -34054,23 +34107,37 @@ editor.init = function () {
* @param {module:locale.LocaleStrings} allStrings See {@tutorial LocaleDocs} * @param {module:locale.LocaleStrings} allStrings See {@tutorial LocaleDocs}
* @fires module:svgcanvas.SvgCanvas#event:ext-langReady * @fires module:svgcanvas.SvgCanvas#event:ext-langReady
* @fires module:svgcanvas.SvgCanvas#event:ext-langChanged * @fires module:svgcanvas.SvgCanvas#event:ext-langChanged
* @returns {undefined} * @returns {Promise} A Promise which resolves to `undefined`
*/ */
var setLang = editor.setLang = function (lang, allStrings) { var setLang = editor.setLang =
/*#__PURE__*/
function () {
var _ref22 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee8(lang, allStrings) {
var oldLayerName, renameLayer, ext, elems;
return regeneratorRuntime.wrap(function _callee8$(_context8) {
while (1) {
switch (_context8.prev = _context8.next) {
case 0:
editor.langChanged = true; editor.langChanged = true;
$$b.pref('lang', lang); $$b.pref('lang', lang);
$$b('#lang_select').val(lang); $$b('#lang_select').val(lang);
if (!allStrings) { if (allStrings) {
return; _context8.next = 5;
break;
} }
return _context8.abrupt("return");
case 5:
$$b.extend(uiStrings$1, allStrings); // const notif = allStrings.notification; // Currently unused $$b.extend(uiStrings$1, allStrings); // const notif = allStrings.notification; // Currently unused
// $.extend will only replace the given strings // $.extend will only replace the given strings
var oldLayerName = $$b('#layerlist tr.layersel td.layername').text(); oldLayerName = $$b('#layerlist tr.layersel td.layername').text();
var renameLayer = oldLayerName === uiStrings$1.common.layer + ' 1'; renameLayer = oldLayerName === uiStrings$1.common.layer + ' 1';
svgCanvas.setUiStrings(allStrings); svgCanvas.setUiStrings(allStrings);
Actions.setTitles(); Actions.setTitles();
@ -34080,11 +34147,21 @@ editor.init = function () {
} // In case extensions loaded before the locale, now we execute a callback on them } // In case extensions loaded before the locale, now we execute a callback on them
if (extsPreLang.length) { if (!extsPreLang.length) {
while (extsPreLang.length) { _context8.next = 21;
var ext = extsPreLang.shift(); break;
}
case 12:
if (!extsPreLang.length) {
_context8.next = 19;
break;
}
ext = extsPreLang.shift();
loadedExtensionNames.push(ext.name); loadedExtensionNames.push(ext.name);
ext.langReady({ _context8.next = 17;
return ext.langReady({
lang: lang, lang: lang,
uiStrings: uiStrings$1, uiStrings: uiStrings$1,
importLocale: getImportLocale({ importLocale: getImportLocale({
@ -34092,8 +34169,16 @@ editor.init = function () {
defaultName: ext.name defaultName: ext.name
}) })
}); });
}
} else { case 17:
_context8.next = 12;
break;
case 19:
_context8.next = 22;
break;
case 21:
loadedExtensionNames.forEach(function (loadedExtensionName) { loadedExtensionNames.forEach(function (loadedExtensionName) {
svgCanvas.runExtensions('langReady', svgCanvas.runExtensions('langReady',
/** @type {module:svgcanvas.SvgCanvas#event:ext-langReady} */ /** @type {module:svgcanvas.SvgCanvas#event:ext-langReady} */
@ -34106,15 +34191,15 @@ editor.init = function () {
}) })
}); });
}); });
}
case 22:
svgCanvas.runExtensions('langChanged', svgCanvas.runExtensions('langChanged',
/** @type {module:svgcanvas.SvgCanvas#event:ext-langChanged} */ /** @type {module:svgcanvas.SvgCanvas#event:ext-langChanged} */
lang); // Update flyout tooltips lang); // Update flyout tooltips
setFlyoutTitles(); // Copy title for certain tool elements setFlyoutTitles(); // Copy title for certain tool elements
var elems = { elems = {
'#stroke_color': '#tool_stroke .icon_label, #tool_stroke .color_block', '#stroke_color': '#tool_stroke .icon_label, #tool_stroke .color_block',
'#fill_color': '#tool_fill label, #tool_fill .color_block', '#fill_color': '#tool_fill label, #tool_fill .color_block',
'#linejoin_miter': '#cur_linejoin', '#linejoin_miter': '#cur_linejoin',
@ -34127,7 +34212,19 @@ editor.init = function () {
$$b('#multiselected_panel div[id^=tool_align]').each(function () { $$b('#multiselected_panel div[id^=tool_align]').each(function () {
$$b('#tool_pos' + this.id.substr(10))[0].title = this.title; $$b('#tool_pos' + this.id.substr(10))[0].title = this.title;
}); });
case 27:
case "end":
return _context8.stop();
}
}
}, _callee8, this);
}));
return function (_x6, _x7) {
return _ref22.apply(this, arguments);
}; };
}();
init$7( init$7(
/** /**
@ -34336,9 +34433,9 @@ var messageQueue = [];
* @returns {undefined} * @returns {undefined}
*/ */
var messageListener = function messageListener(_ref20) { var messageListener = function messageListener(_ref23) {
var data = _ref20.data, var data = _ref23.data,
origin = _ref20.origin; origin = _ref23.origin;
// console.log('data, origin, extensionsAdded', data, origin, extensionsAdded); // console.log('data, origin, extensionsAdded', data, origin, extensionsAdded);
var messageObj = { var messageObj = {
data: data, data: data,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

309
dist/index-umd.js vendored
View File

@ -27567,11 +27567,11 @@
editor.showSaveWarning = false; editor.showSaveWarning = false;
/** /**
* @type {boolean} * Will be set to a boolean by `ext-storage.js`
* @type {"ignore"|"waiting"|"closed"}
*/ */
editor.storagePromptClosed = false; // For use with ext-storage.js editor.storagePromptState = 'ignore';
var callbacks = [], var callbacks = [],
/** /**
@ -28373,9 +28373,12 @@
_ref6 = _context4.sent; _ref6 = _context4.sent;
langParam = _ref6.langParam; langParam = _ref6.langParam;
langData = _ref6.langData; langData = _ref6.langData;
setLang(langParam, langData); _context4.next = 7;
_context4.prev = 6; return setLang(langParam, langData);
_context4.next = 9;
case 7:
_context4.prev = 7;
_context4.next = 10;
return Promise.all(curConfig.extensions.map( return Promise.all(curConfig.extensions.map(
/*#__PURE__*/ /*#__PURE__*/
function () { function () {
@ -28442,7 +28445,7 @@
}; };
}())); }()));
case 9: case 10:
svgCanvas.bind('extensions_added', svgCanvas.bind('extensions_added',
/** /**
* @param {external:Window} win * @param {external:Window} win
@ -28456,7 +28459,11 @@
$$b('.flyout_arrow_horiz:empty').each(function () { $$b('.flyout_arrow_horiz:empty').each(function () {
$$b(this).append($$b.getSvgIcon('arrow_right', true).width(5).height(5)); $$b(this).append($$b.getSvgIcon('arrow_right', true).width(5).height(5));
}); });
if (editor.storagePromptState === 'ignore') {
updateCanvas(true); updateCanvas(true);
}
messageQueue.forEach( messageQueue.forEach(
/** /**
* @param {module:svgcanvas.SvgCanvas#event:message} messageObj * @param {module:svgcanvas.SvgCanvas#event:message} messageObj
@ -28468,20 +28475,20 @@
}); });
}); });
svgCanvas.call('extensions_added'); svgCanvas.call('extensions_added');
_context4.next = 16; _context4.next = 17;
break; break;
case 13: case 14:
_context4.prev = 13; _context4.prev = 14;
_context4.t0 = _context4["catch"](6); _context4.t0 = _context4["catch"](7);
console.log(_context4.t0); console.log(_context4.t0);
case 16: case 17:
case "end": case "end":
return _context4.stop(); return _context4.stop();
} }
} }
}, _callee4, this, [[6, 13]]); }, _callee4, this, [[7, 14]]);
})); }));
return function extAndLocaleFunc() { return function extAndLocaleFunc() {
@ -29803,7 +29810,7 @@
workarea.scroll(); workarea.scroll();
} }
if (urldata.storagePrompt !== true && !editor.storagePromptClosed) { if (urldata.storagePrompt !== true && editor.storagePromptState === 'ignore') {
$$b('#dialog_box').hide(); $$b('#dialog_box').hide();
} }
}; };
@ -30731,33 +30738,18 @@
* @returns {Promise} Resolves to `undefined` * @returns {Promise} Resolves to `undefined`
*/ */
var extAdded = function extAdded(win, ext) { var extAdded =
if (!ext) { /*#__PURE__*/
return; function () {
} var _ref14 = _asyncToGenerator(
/*#__PURE__*/
var cbCalled = false; regeneratorRuntime.mark(function _callee5(win, ext) {
var resizeDone = false; var cbCalled, resizeDone, lang, prepResize, runCallback, btnSelects, svgicons, fallbackObj, placementObj, holders;
return regeneratorRuntime.wrap(function _callee5$(_context5) {
if (ext.langReady) { while (1) {
if (editor.langChanged) { switch (_context5.prev = _context5.next) {
// We check for this since the "lang" pref could have been set by storage case 0:
var lang = $$b.pref('lang'); prepResize = function _ref15() {
ext.langReady({
lang: lang,
uiStrings: uiStrings$1,
importLocale: getImportLocale({
defaultLang: lang,
defaultName: ext.name
})
});
loadedExtensionNames.push(ext.name);
} else {
extsPreLang.push(ext);
}
}
function prepResize() {
if (resizeTimer) { if (resizeTimer) {
clearTimeout(resizeTimer); clearTimeout(resizeTimer);
resizeTimer = null; resizeTimer = null;
@ -30769,16 +30761,58 @@
setIconSize($$b.pref('iconsize')); setIconSize($$b.pref('iconsize'));
}, 50); }, 50);
} }
};
if (ext) {
_context5.next = 3;
break;
} }
var runCallback = function runCallback() { return _context5.abrupt("return");
case 3:
cbCalled = false;
resizeDone = false;
if (!ext.langReady) {
_context5.next = 14;
break;
}
if (!editor.langChanged) {
_context5.next = 13;
break;
}
// We check for this since the "lang" pref could have been set by storage
lang = $$b.pref('lang');
_context5.next = 10;
return ext.langReady({
lang: lang,
uiStrings: uiStrings$1,
importLocale: getImportLocale({
defaultLang: lang,
defaultName: ext.name
})
});
case 10:
loadedExtensionNames.push(ext.name);
_context5.next = 14;
break;
case 13:
extsPreLang.push(ext);
case 14:
runCallback = function runCallback() {
if (ext.callback && !cbCalled) { if (ext.callback && !cbCalled) {
cbCalled = true; cbCalled = true;
ext.callback.call(editor); ext.callback.call(editor);
} }
}; };
var btnSelects = []; btnSelects = [];
/** /**
* @typedef {PlainObject} module:SVGEditor.ContextTool * @typedef {PlainObject} module:SVGEditor.ContextTool
* @property {string} panel The ID of the existing panel to which the tool is being added. Required. * @property {string} panel The ID of the existing panel to which the tool is being added. Required.
@ -30881,12 +30915,14 @@
}); });
} }
var svgicons = ext.svgicons; svgicons = ext.svgicons;
if (ext.buttons) { if (!ext.buttons) {
var fallbackObj = {}, _context5.next = 24;
placementObj = {}, break;
holders = {}; }
fallbackObj = {}, placementObj = {}, holders = {};
/** /**
* @typedef {GenericArray} module:SVGEditor.KeyArray * @typedef {GenericArray} module:SVGEditor.KeyArray
* @property {string} 0 The key to bind (on `keydown`) * @property {string} 0 The key to bind (on `keydown`)
@ -31139,8 +31175,12 @@
}); });
}); });
if (svgicons) { if (!svgicons) {
return new Promise(function (resolve, reject) { _context5.next = 24;
break;
}
return _context5.abrupt("return", new Promise(function (resolve, reject) {
$$b.svgIcons(svgicons, { $$b.svgIcons(svgicons, {
w: 24, w: 24,
h: 24, h: 24,
@ -31159,12 +31199,23 @@
resolve(); resolve();
} }
}); });
}); }));
}
}
return runCallback(); case 24:
return _context5.abrupt("return", runCallback());
case 25:
case "end":
return _context5.stop();
}
}
}, _callee5, this);
}));
return function extAdded(_x3, _x4) {
return _ref14.apply(this, arguments);
}; };
}();
var getPaint = function getPaint(color, opac, type) { var getPaint = function getPaint(color, opac, type) {
// update the editor's fill paint // update the editor's fill paint
@ -31228,9 +31279,9 @@
* @listens module:svgcanvas.SvgCanvas#event:updateCanvas * @listens module:svgcanvas.SvgCanvas#event:updateCanvas
* @returns {undefined} * @returns {undefined}
*/ */
function (win, _ref14) { function (win, _ref16) {
var center = _ref14.center, var center = _ref16.center,
newCtr = _ref14.newCtr; newCtr = _ref16.newCtr;
updateCanvas(center, newCtr); updateCanvas(center, newCtr);
}); });
svgCanvas.bind('contextset', contextChanged); svgCanvas.bind('contextset', contextChanged);
@ -32038,15 +32089,15 @@
'PNG', 'JPEG', 'BMP', 'WEBP', 'PDF'], 'PNG', 'JPEG', 'BMP', 'WEBP', 'PDF'],
/*#__PURE__*/ /*#__PURE__*/
function () { function () {
var _ref15 = _asyncToGenerator( var _ref17 = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee5(imgType) { regeneratorRuntime.mark(function _callee6(imgType) {
var exportWindowName, openExportWindow, chrome, quality; var exportWindowName, openExportWindow, chrome, quality;
return regeneratorRuntime.wrap(function _callee5$(_context5) { return regeneratorRuntime.wrap(function _callee6$(_context6) {
while (1) { while (1) {
switch (_context5.prev = _context5.next) { switch (_context6.prev = _context6.next) {
case 0: case 0:
openExportWindow = function _ref16() { openExportWindow = function _ref18() {
var str = uiStrings$1.notification.loadingImage; var str = uiStrings$1.notification.loadingImage;
if (curConfig.exportWindowType === 'new') { if (curConfig.exportWindowType === 'new') {
@ -32077,17 +32128,17 @@
}; };
if (imgType) { if (imgType) {
_context5.next = 3; _context6.next = 3;
break; break;
} }
return _context5.abrupt("return"); return _context6.abrupt("return");
case 3: case 3:
chrome = isChrome(); chrome = isChrome();
if (!(imgType === 'PDF')) { if (!(imgType === 'PDF')) {
_context5.next = 9; _context6.next = 9;
break; break;
} }
@ -32096,7 +32147,7 @@
} }
svgCanvas.exportPDF(exportWindowName, chrome ? 'save' : undefined); svgCanvas.exportPDF(exportWindowName, chrome ? 'save' : undefined);
_context5.next = 13; _context6.next = 13;
break; break;
case 9: case 9:
@ -32107,19 +32158,19 @@
quality = parseInt($$b('#image-slider').val(), 10) / 100; quality = parseInt($$b('#image-slider').val(), 10) / 100;
/* const results = */ /* const results = */
_context5.next = 13; _context6.next = 13;
return svgCanvas.rasterExport(imgType, quality, exportWindowName); return svgCanvas.rasterExport(imgType, quality, exportWindowName);
case 13: case 13:
case "end": case "end":
return _context5.stop(); return _context6.stop();
} }
} }
}, _callee5, this); }, _callee6, this);
})); }));
return function (_x3) { return function (_x5) {
return _ref15.apply(this, arguments); return _ref17.apply(this, arguments);
}; };
}(), function () { }(), function () {
var sel = $$b(this); var sel = $$b(this);
@ -32356,12 +32407,12 @@
/*#__PURE__*/ /*#__PURE__*/
_asyncToGenerator( _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee6() { regeneratorRuntime.mark(function _callee7() {
var color, lang, _ref18, langParam, langData; var color, lang, _ref20, langParam, langData;
return regeneratorRuntime.wrap(function _callee6$(_context6) { return regeneratorRuntime.wrap(function _callee7$(_context7) {
while (1) { while (1) {
switch (_context6.prev = _context6.next) { switch (_context7.prev = _context7.next) {
case 0: case 0:
// Set background // Set background
color = $$b('#bg_blocks div.cur_background').css('background-color') || '#FFF'; color = $$b('#bg_blocks div.cur_background').css('background-color') || '#FFF';
@ -32370,20 +32421,21 @@
lang = $$b('#lang_select').val(); lang = $$b('#lang_select').val();
if (!(lang !== $$b.pref('lang'))) { if (!(lang !== $$b.pref('lang'))) {
_context6.next = 10; _context7.next = 11;
break; break;
} }
_context6.next = 6; _context7.next = 6;
return editor.putLocale(lang, goodLangs, curConfig); return editor.putLocale(lang, goodLangs, curConfig);
case 6: case 6:
_ref18 = _context6.sent; _ref20 = _context7.sent;
langParam = _ref18.langParam; langParam = _ref20.langParam;
langData = _ref18.langData; langData = _ref20.langData;
setLang(langParam, langData); _context7.next = 11;
return setLang(langParam, langData);
case 10: case 11:
// set icon size // set icon size
setIconSize($$b('#iconsize').val()); // set grid setting setIconSize($$b('#iconsize').val()); // set grid setting
@ -32402,12 +32454,12 @@
updateCanvas(); updateCanvas();
hidePreferences(); hidePreferences();
case 21: case 22:
case "end": case "end":
return _context6.stop(); return _context7.stop();
} }
} }
}, _callee6, this); }, _callee7, this);
})); }));
var resetScrollPos = $$b.noop; var resetScrollPos = $$b.noop;
@ -33975,8 +34027,8 @@
// bitmap handling // bitmap handling
reader = new FileReader(); reader = new FileReader();
reader.onloadend = function (_ref19) { reader.onloadend = function (_ref21) {
var result = _ref19.target.result; var result = _ref21.target.result;
// let's insert the new image until we know its dimensions // let's insert the new image until we know its dimensions
var insertNewImage = function insertNewImage(width, height) { var insertNewImage = function insertNewImage(width, height) {
@ -34048,11 +34100,12 @@
$$b('#tool_open').show().prepend(open); $$b('#tool_open').show().prepend(open);
var imgImport = $$b('<input type="file">').change(importImage); var imgImport = $$b('<input type="file">').change(importImage);
$$b('#tool_import').show().prepend(imgImport); $$b('#tool_import').show().prepend(imgImport);
} // const revnums = 'svg-editor.js ($Rev$) '; }
updateCanvas(true); // const revnums = 'svg-editor.js ($Rev$) ';
// revnums += svgCanvas.getVersion(); // revnums += svgCanvas.getVersion();
// $('#copyright')[0].setAttribute('title', revnums); // $('#copyright')[0].setAttribute('title', revnums);
var loadedExtensionNames = []; var loadedExtensionNames = [];
/** /**
* @function module:SVGEditor.setLang * @function module:SVGEditor.setLang
@ -34060,23 +34113,37 @@
* @param {module:locale.LocaleStrings} allStrings See {@tutorial LocaleDocs} * @param {module:locale.LocaleStrings} allStrings See {@tutorial LocaleDocs}
* @fires module:svgcanvas.SvgCanvas#event:ext-langReady * @fires module:svgcanvas.SvgCanvas#event:ext-langReady
* @fires module:svgcanvas.SvgCanvas#event:ext-langChanged * @fires module:svgcanvas.SvgCanvas#event:ext-langChanged
* @returns {undefined} * @returns {Promise} A Promise which resolves to `undefined`
*/ */
var setLang = editor.setLang = function (lang, allStrings) { var setLang = editor.setLang =
/*#__PURE__*/
function () {
var _ref22 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee8(lang, allStrings) {
var oldLayerName, renameLayer, ext, elems;
return regeneratorRuntime.wrap(function _callee8$(_context8) {
while (1) {
switch (_context8.prev = _context8.next) {
case 0:
editor.langChanged = true; editor.langChanged = true;
$$b.pref('lang', lang); $$b.pref('lang', lang);
$$b('#lang_select').val(lang); $$b('#lang_select').val(lang);
if (!allStrings) { if (allStrings) {
return; _context8.next = 5;
break;
} }
return _context8.abrupt("return");
case 5:
$$b.extend(uiStrings$1, allStrings); // const notif = allStrings.notification; // Currently unused $$b.extend(uiStrings$1, allStrings); // const notif = allStrings.notification; // Currently unused
// $.extend will only replace the given strings // $.extend will only replace the given strings
var oldLayerName = $$b('#layerlist tr.layersel td.layername').text(); oldLayerName = $$b('#layerlist tr.layersel td.layername').text();
var renameLayer = oldLayerName === uiStrings$1.common.layer + ' 1'; renameLayer = oldLayerName === uiStrings$1.common.layer + ' 1';
svgCanvas.setUiStrings(allStrings); svgCanvas.setUiStrings(allStrings);
Actions.setTitles(); Actions.setTitles();
@ -34086,11 +34153,21 @@
} // In case extensions loaded before the locale, now we execute a callback on them } // In case extensions loaded before the locale, now we execute a callback on them
if (extsPreLang.length) { if (!extsPreLang.length) {
while (extsPreLang.length) { _context8.next = 21;
var ext = extsPreLang.shift(); break;
}
case 12:
if (!extsPreLang.length) {
_context8.next = 19;
break;
}
ext = extsPreLang.shift();
loadedExtensionNames.push(ext.name); loadedExtensionNames.push(ext.name);
ext.langReady({ _context8.next = 17;
return ext.langReady({
lang: lang, lang: lang,
uiStrings: uiStrings$1, uiStrings: uiStrings$1,
importLocale: getImportLocale({ importLocale: getImportLocale({
@ -34098,8 +34175,16 @@
defaultName: ext.name defaultName: ext.name
}) })
}); });
}
} else { case 17:
_context8.next = 12;
break;
case 19:
_context8.next = 22;
break;
case 21:
loadedExtensionNames.forEach(function (loadedExtensionName) { loadedExtensionNames.forEach(function (loadedExtensionName) {
svgCanvas.runExtensions('langReady', svgCanvas.runExtensions('langReady',
/** @type {module:svgcanvas.SvgCanvas#event:ext-langReady} */ /** @type {module:svgcanvas.SvgCanvas#event:ext-langReady} */
@ -34112,15 +34197,15 @@
}) })
}); });
}); });
}
case 22:
svgCanvas.runExtensions('langChanged', svgCanvas.runExtensions('langChanged',
/** @type {module:svgcanvas.SvgCanvas#event:ext-langChanged} */ /** @type {module:svgcanvas.SvgCanvas#event:ext-langChanged} */
lang); // Update flyout tooltips lang); // Update flyout tooltips
setFlyoutTitles(); // Copy title for certain tool elements setFlyoutTitles(); // Copy title for certain tool elements
var elems = { elems = {
'#stroke_color': '#tool_stroke .icon_label, #tool_stroke .color_block', '#stroke_color': '#tool_stroke .icon_label, #tool_stroke .color_block',
'#fill_color': '#tool_fill label, #tool_fill .color_block', '#fill_color': '#tool_fill label, #tool_fill .color_block',
'#linejoin_miter': '#cur_linejoin', '#linejoin_miter': '#cur_linejoin',
@ -34133,7 +34218,19 @@
$$b('#multiselected_panel div[id^=tool_align]').each(function () { $$b('#multiselected_panel div[id^=tool_align]').each(function () {
$$b('#tool_pos' + this.id.substr(10))[0].title = this.title; $$b('#tool_pos' + this.id.substr(10))[0].title = this.title;
}); });
case 27:
case "end":
return _context8.stop();
}
}
}, _callee8, this);
}));
return function (_x6, _x7) {
return _ref22.apply(this, arguments);
}; };
}();
init$7( init$7(
/** /**
@ -34342,9 +34439,9 @@
* @returns {undefined} * @returns {undefined}
*/ */
var messageListener = function messageListener(_ref20) { var messageListener = function messageListener(_ref23) {
var data = _ref20.data, var data = _ref23.data,
origin = _ref20.origin; origin = _ref23.origin;
// console.log('data, origin, extensionsAdded', data, origin, extensionsAdded); // console.log('data, origin, extensionsAdded', data, origin, extensionsAdded);
var messageObj = { var messageObj = {
data: data, data: data,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -47,7 +47,7 @@ export default {
noStorageOnLoad, noStorageOnLoad,
forceStorage forceStorage
} = svgEditor.curConfig; } = svgEditor.curConfig;
const {storage} = svgEditor; const {storage, updateCanvas} = svgEditor;
function replaceStoragePrompt (val) { function replaceStoragePrompt (val) {
val = val ? 'storagePrompt=' + val : ''; val = val ? 'storagePrompt=' + val : '';
@ -255,7 +255,8 @@ export default {
// the prompt gives the user the option to store data // the prompt gives the user the option to store data
setupBeforeUnloadListener(); setupBeforeUnloadListener();
svgEditor.storagePromptClosed = true; svgEditor.storagePromptState = 'closed';
updateCanvas(true);
}, },
null, null,
null, null,
@ -265,6 +266,7 @@ export default {
tooltip: rememberTooltip tooltip: rememberTooltip
} }
); );
svgEditor.storagePromptState = 'waiting';
} else if (!noStorageOnLoad || forceStorage) { } else if (!noStorageOnLoad || forceStorage) {
setupBeforeUnloadListener(); setupBeforeUnloadListener();
} }

View File

@ -87,9 +87,10 @@ editor.langChanged = false;
*/ */
editor.showSaveWarning = false; editor.showSaveWarning = false;
/** /**
* @type {boolean} * Will be set to a boolean by `ext-storage.js`
* @type {"ignore"|"waiting"|"closed"}
*/ */
editor.storagePromptClosed = false; // For use with ext-storage.js editor.storagePromptState = 'ignore';
const callbacks = [], const callbacks = [],
/** /**
@ -771,7 +772,7 @@ editor.init = function () {
const extAndLocaleFunc = async function () { const extAndLocaleFunc = async function () {
// const lang = ('lang' in curPrefs) ? curPrefs.lang : null; // const lang = ('lang' in curPrefs) ? curPrefs.lang : null;
const {langParam, langData} = await editor.putLocale(null, goodLangs, curConfig); const {langParam, langData} = await editor.putLocale(null, goodLangs, curConfig);
setLang(langParam, langData); await setLang(langParam, langData);
try { try {
await Promise.all( await Promise.all(
@ -819,7 +820,11 @@ editor.init = function () {
$('.flyout_arrow_horiz:empty').each(function () { $('.flyout_arrow_horiz:empty').each(function () {
$(this).append($.getSvgIcon('arrow_right', true).width(5).height(5)); $(this).append($.getSvgIcon('arrow_right', true).width(5).height(5));
}); });
if (editor.storagePromptState === 'ignore') {
updateCanvas(true); updateCanvas(true);
}
messageQueue.forEach( messageQueue.forEach(
/** /**
* @param {module:svgcanvas.SvgCanvas#event:message} messageObj * @param {module:svgcanvas.SvgCanvas#event:message} messageObj
@ -2091,7 +2096,7 @@ editor.init = function () {
workarea.scroll(); workarea.scroll();
} }
if (urldata.storagePrompt !== true && !editor.storagePromptClosed) { if (urldata.storagePrompt !== true && editor.storagePromptState === 'ignore') {
$('#dialog_box').hide(); $('#dialog_box').hide();
} }
}; };
@ -2944,7 +2949,7 @@ editor.init = function () {
* @listens module:svgcanvas.SvgCanvas#event:extension_added * @listens module:svgcanvas.SvgCanvas#event:extension_added
* @returns {Promise} Resolves to `undefined` * @returns {Promise} Resolves to `undefined`
*/ */
const extAdded = function (win, ext) { const extAdded = async function (win, ext) {
if (!ext) { if (!ext) {
return; return;
} }
@ -2954,7 +2959,7 @@ editor.init = function () {
if (ext.langReady) { if (ext.langReady) {
if (editor.langChanged) { // We check for this since the "lang" pref could have been set by storage if (editor.langChanged) { // We check for this since the "lang" pref could have been set by storage
const lang = $.pref('lang'); const lang = $.pref('lang');
ext.langReady({ await ext.langReady({
lang, lang,
uiStrings, uiStrings,
importLocale: getImportLocale({defaultLang: lang, defaultName: ext.name}) importLocale: getImportLocale({defaultLang: lang, defaultName: ext.name})
@ -4453,7 +4458,7 @@ editor.init = function () {
const lang = $('#lang_select').val(); const lang = $('#lang_select').val();
if (lang !== $.pref('lang')) { if (lang !== $.pref('lang')) {
const {langParam, langData} = await editor.putLocale(lang, goodLangs, curConfig); const {langParam, langData} = await editor.putLocale(lang, goodLangs, curConfig);
setLang(langParam, langData); await setLang(langParam, langData);
} }
// set icon size // set icon size
@ -5721,6 +5726,7 @@ editor.init = function () {
$('#tool_import').show().prepend(imgImport); $('#tool_import').show().prepend(imgImport);
} }
updateCanvas(true);
// const revnums = 'svg-editor.js ($Rev$) '; // const revnums = 'svg-editor.js ($Rev$) ';
// revnums += svgCanvas.getVersion(); // revnums += svgCanvas.getVersion();
// $('#copyright')[0].setAttribute('title', revnums); // $('#copyright')[0].setAttribute('title', revnums);
@ -5732,9 +5738,9 @@ editor.init = function () {
* @param {module:locale.LocaleStrings} allStrings See {@tutorial LocaleDocs} * @param {module:locale.LocaleStrings} allStrings See {@tutorial LocaleDocs}
* @fires module:svgcanvas.SvgCanvas#event:ext-langReady * @fires module:svgcanvas.SvgCanvas#event:ext-langReady
* @fires module:svgcanvas.SvgCanvas#event:ext-langChanged * @fires module:svgcanvas.SvgCanvas#event:ext-langChanged
* @returns {undefined} * @returns {Promise} A Promise which resolves to `undefined`
*/ */
const setLang = editor.setLang = function (lang, allStrings) { const setLang = editor.setLang = async function (lang, allStrings) {
editor.langChanged = true; editor.langChanged = true;
$.pref('lang', lang); $.pref('lang', lang);
$('#lang_select').val(lang); $('#lang_select').val(lang);
@ -5761,7 +5767,7 @@ editor.init = function () {
while (extsPreLang.length) { while (extsPreLang.length) {
const ext = extsPreLang.shift(); const ext = extsPreLang.shift();
loadedExtensionNames.push(ext.name); loadedExtensionNames.push(ext.name);
ext.langReady({ await ext.langReady({
lang, lang,
uiStrings, uiStrings,
importLocale: getImportLocale({defaultLang: lang, defaultName: ext.name}) importLocale: getImportLocale({defaultLang: lang, defaultName: ext.name})

View File

@ -27564,11 +27564,11 @@
editor.showSaveWarning = false; editor.showSaveWarning = false;
/** /**
* @type {boolean} * Will be set to a boolean by `ext-storage.js`
* @type {"ignore"|"waiting"|"closed"}
*/ */
editor.storagePromptClosed = false; // For use with ext-storage.js editor.storagePromptState = 'ignore';
var callbacks = [], var callbacks = [],
/** /**
@ -28370,9 +28370,12 @@
_ref6 = _context4.sent; _ref6 = _context4.sent;
langParam = _ref6.langParam; langParam = _ref6.langParam;
langData = _ref6.langData; langData = _ref6.langData;
setLang(langParam, langData); _context4.next = 7;
_context4.prev = 6; return setLang(langParam, langData);
_context4.next = 9;
case 7:
_context4.prev = 7;
_context4.next = 10;
return Promise.all(curConfig.extensions.map( return Promise.all(curConfig.extensions.map(
/*#__PURE__*/ /*#__PURE__*/
function () { function () {
@ -28439,7 +28442,7 @@
}; };
}())); }()));
case 9: case 10:
svgCanvas.bind('extensions_added', svgCanvas.bind('extensions_added',
/** /**
* @param {external:Window} win * @param {external:Window} win
@ -28453,7 +28456,11 @@
$$b('.flyout_arrow_horiz:empty').each(function () { $$b('.flyout_arrow_horiz:empty').each(function () {
$$b(this).append($$b.getSvgIcon('arrow_right', true).width(5).height(5)); $$b(this).append($$b.getSvgIcon('arrow_right', true).width(5).height(5));
}); });
if (editor.storagePromptState === 'ignore') {
updateCanvas(true); updateCanvas(true);
}
messageQueue.forEach( messageQueue.forEach(
/** /**
* @param {module:svgcanvas.SvgCanvas#event:message} messageObj * @param {module:svgcanvas.SvgCanvas#event:message} messageObj
@ -28465,20 +28472,20 @@
}); });
}); });
svgCanvas.call('extensions_added'); svgCanvas.call('extensions_added');
_context4.next = 16; _context4.next = 17;
break; break;
case 13: case 14:
_context4.prev = 13; _context4.prev = 14;
_context4.t0 = _context4["catch"](6); _context4.t0 = _context4["catch"](7);
console.log(_context4.t0); console.log(_context4.t0);
case 16: case 17:
case "end": case "end":
return _context4.stop(); return _context4.stop();
} }
} }
}, _callee4, this, [[6, 13]]); }, _callee4, this, [[7, 14]]);
})); }));
return function extAndLocaleFunc() { return function extAndLocaleFunc() {
@ -29800,7 +29807,7 @@
workarea.scroll(); workarea.scroll();
} }
if (urldata.storagePrompt !== true && !editor.storagePromptClosed) { if (urldata.storagePrompt !== true && editor.storagePromptState === 'ignore') {
$$b('#dialog_box').hide(); $$b('#dialog_box').hide();
} }
}; };
@ -30728,33 +30735,18 @@
* @returns {Promise} Resolves to `undefined` * @returns {Promise} Resolves to `undefined`
*/ */
var extAdded = function extAdded(win, ext) { var extAdded =
if (!ext) { /*#__PURE__*/
return; function () {
} var _ref14 = _asyncToGenerator(
/*#__PURE__*/
var cbCalled = false; regeneratorRuntime.mark(function _callee5(win, ext) {
var resizeDone = false; var cbCalled, resizeDone, lang, prepResize, runCallback, btnSelects, svgicons, fallbackObj, placementObj, holders;
return regeneratorRuntime.wrap(function _callee5$(_context5) {
if (ext.langReady) { while (1) {
if (editor.langChanged) { switch (_context5.prev = _context5.next) {
// We check for this since the "lang" pref could have been set by storage case 0:
var lang = $$b.pref('lang'); prepResize = function _ref15() {
ext.langReady({
lang: lang,
uiStrings: uiStrings$1,
importLocale: getImportLocale({
defaultLang: lang,
defaultName: ext.name
})
});
loadedExtensionNames.push(ext.name);
} else {
extsPreLang.push(ext);
}
}
function prepResize() {
if (resizeTimer) { if (resizeTimer) {
clearTimeout(resizeTimer); clearTimeout(resizeTimer);
resizeTimer = null; resizeTimer = null;
@ -30766,16 +30758,58 @@
setIconSize($$b.pref('iconsize')); setIconSize($$b.pref('iconsize'));
}, 50); }, 50);
} }
};
if (ext) {
_context5.next = 3;
break;
} }
var runCallback = function runCallback() { return _context5.abrupt("return");
case 3:
cbCalled = false;
resizeDone = false;
if (!ext.langReady) {
_context5.next = 14;
break;
}
if (!editor.langChanged) {
_context5.next = 13;
break;
}
// We check for this since the "lang" pref could have been set by storage
lang = $$b.pref('lang');
_context5.next = 10;
return ext.langReady({
lang: lang,
uiStrings: uiStrings$1,
importLocale: getImportLocale({
defaultLang: lang,
defaultName: ext.name
})
});
case 10:
loadedExtensionNames.push(ext.name);
_context5.next = 14;
break;
case 13:
extsPreLang.push(ext);
case 14:
runCallback = function runCallback() {
if (ext.callback && !cbCalled) { if (ext.callback && !cbCalled) {
cbCalled = true; cbCalled = true;
ext.callback.call(editor); ext.callback.call(editor);
} }
}; };
var btnSelects = []; btnSelects = [];
/** /**
* @typedef {PlainObject} module:SVGEditor.ContextTool * @typedef {PlainObject} module:SVGEditor.ContextTool
* @property {string} panel The ID of the existing panel to which the tool is being added. Required. * @property {string} panel The ID of the existing panel to which the tool is being added. Required.
@ -30878,12 +30912,14 @@
}); });
} }
var svgicons = ext.svgicons; svgicons = ext.svgicons;
if (ext.buttons) { if (!ext.buttons) {
var fallbackObj = {}, _context5.next = 24;
placementObj = {}, break;
holders = {}; }
fallbackObj = {}, placementObj = {}, holders = {};
/** /**
* @typedef {GenericArray} module:SVGEditor.KeyArray * @typedef {GenericArray} module:SVGEditor.KeyArray
* @property {string} 0 The key to bind (on `keydown`) * @property {string} 0 The key to bind (on `keydown`)
@ -31136,8 +31172,12 @@
}); });
}); });
if (svgicons) { if (!svgicons) {
return new Promise(function (resolve, reject) { _context5.next = 24;
break;
}
return _context5.abrupt("return", new Promise(function (resolve, reject) {
$$b.svgIcons(svgicons, { $$b.svgIcons(svgicons, {
w: 24, w: 24,
h: 24, h: 24,
@ -31156,12 +31196,23 @@
resolve(); resolve();
} }
}); });
}); }));
}
}
return runCallback(); case 24:
return _context5.abrupt("return", runCallback());
case 25:
case "end":
return _context5.stop();
}
}
}, _callee5, this);
}));
return function extAdded(_x3, _x4) {
return _ref14.apply(this, arguments);
}; };
}();
var getPaint = function getPaint(color, opac, type) { var getPaint = function getPaint(color, opac, type) {
// update the editor's fill paint // update the editor's fill paint
@ -31225,9 +31276,9 @@
* @listens module:svgcanvas.SvgCanvas#event:updateCanvas * @listens module:svgcanvas.SvgCanvas#event:updateCanvas
* @returns {undefined} * @returns {undefined}
*/ */
function (win, _ref14) { function (win, _ref16) {
var center = _ref14.center, var center = _ref16.center,
newCtr = _ref14.newCtr; newCtr = _ref16.newCtr;
updateCanvas(center, newCtr); updateCanvas(center, newCtr);
}); });
svgCanvas.bind('contextset', contextChanged); svgCanvas.bind('contextset', contextChanged);
@ -32035,15 +32086,15 @@
'PNG', 'JPEG', 'BMP', 'WEBP', 'PDF'], 'PNG', 'JPEG', 'BMP', 'WEBP', 'PDF'],
/*#__PURE__*/ /*#__PURE__*/
function () { function () {
var _ref15 = _asyncToGenerator( var _ref17 = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee5(imgType) { regeneratorRuntime.mark(function _callee6(imgType) {
var exportWindowName, openExportWindow, chrome, quality; var exportWindowName, openExportWindow, chrome, quality;
return regeneratorRuntime.wrap(function _callee5$(_context5) { return regeneratorRuntime.wrap(function _callee6$(_context6) {
while (1) { while (1) {
switch (_context5.prev = _context5.next) { switch (_context6.prev = _context6.next) {
case 0: case 0:
openExportWindow = function _ref16() { openExportWindow = function _ref18() {
var str = uiStrings$1.notification.loadingImage; var str = uiStrings$1.notification.loadingImage;
if (curConfig.exportWindowType === 'new') { if (curConfig.exportWindowType === 'new') {
@ -32074,17 +32125,17 @@
}; };
if (imgType) { if (imgType) {
_context5.next = 3; _context6.next = 3;
break; break;
} }
return _context5.abrupt("return"); return _context6.abrupt("return");
case 3: case 3:
chrome = isChrome(); chrome = isChrome();
if (!(imgType === 'PDF')) { if (!(imgType === 'PDF')) {
_context5.next = 9; _context6.next = 9;
break; break;
} }
@ -32093,7 +32144,7 @@
} }
svgCanvas.exportPDF(exportWindowName, chrome ? 'save' : undefined); svgCanvas.exportPDF(exportWindowName, chrome ? 'save' : undefined);
_context5.next = 13; _context6.next = 13;
break; break;
case 9: case 9:
@ -32104,19 +32155,19 @@
quality = parseInt($$b('#image-slider').val(), 10) / 100; quality = parseInt($$b('#image-slider').val(), 10) / 100;
/* const results = */ /* const results = */
_context5.next = 13; _context6.next = 13;
return svgCanvas.rasterExport(imgType, quality, exportWindowName); return svgCanvas.rasterExport(imgType, quality, exportWindowName);
case 13: case 13:
case "end": case "end":
return _context5.stop(); return _context6.stop();
} }
} }
}, _callee5, this); }, _callee6, this);
})); }));
return function (_x3) { return function (_x5) {
return _ref15.apply(this, arguments); return _ref17.apply(this, arguments);
}; };
}(), function () { }(), function () {
var sel = $$b(this); var sel = $$b(this);
@ -32353,12 +32404,12 @@
/*#__PURE__*/ /*#__PURE__*/
_asyncToGenerator( _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee6() { regeneratorRuntime.mark(function _callee7() {
var color, lang, _ref18, langParam, langData; var color, lang, _ref20, langParam, langData;
return regeneratorRuntime.wrap(function _callee6$(_context6) { return regeneratorRuntime.wrap(function _callee7$(_context7) {
while (1) { while (1) {
switch (_context6.prev = _context6.next) { switch (_context7.prev = _context7.next) {
case 0: case 0:
// Set background // Set background
color = $$b('#bg_blocks div.cur_background').css('background-color') || '#FFF'; color = $$b('#bg_blocks div.cur_background').css('background-color') || '#FFF';
@ -32367,20 +32418,21 @@
lang = $$b('#lang_select').val(); lang = $$b('#lang_select').val();
if (!(lang !== $$b.pref('lang'))) { if (!(lang !== $$b.pref('lang'))) {
_context6.next = 10; _context7.next = 11;
break; break;
} }
_context6.next = 6; _context7.next = 6;
return editor.putLocale(lang, goodLangs, curConfig); return editor.putLocale(lang, goodLangs, curConfig);
case 6: case 6:
_ref18 = _context6.sent; _ref20 = _context7.sent;
langParam = _ref18.langParam; langParam = _ref20.langParam;
langData = _ref18.langData; langData = _ref20.langData;
setLang(langParam, langData); _context7.next = 11;
return setLang(langParam, langData);
case 10: case 11:
// set icon size // set icon size
setIconSize($$b('#iconsize').val()); // set grid setting setIconSize($$b('#iconsize').val()); // set grid setting
@ -32399,12 +32451,12 @@
updateCanvas(); updateCanvas();
hidePreferences(); hidePreferences();
case 21: case 22:
case "end": case "end":
return _context6.stop(); return _context7.stop();
} }
} }
}, _callee6, this); }, _callee7, this);
})); }));
var resetScrollPos = $$b.noop; var resetScrollPos = $$b.noop;
@ -33972,8 +34024,8 @@
// bitmap handling // bitmap handling
reader = new FileReader(); reader = new FileReader();
reader.onloadend = function (_ref19) { reader.onloadend = function (_ref21) {
var result = _ref19.target.result; var result = _ref21.target.result;
// let's insert the new image until we know its dimensions // let's insert the new image until we know its dimensions
var insertNewImage = function insertNewImage(width, height) { var insertNewImage = function insertNewImage(width, height) {
@ -34045,11 +34097,12 @@
$$b('#tool_open').show().prepend(open); $$b('#tool_open').show().prepend(open);
var imgImport = $$b('<input type="file">').change(importImage); var imgImport = $$b('<input type="file">').change(importImage);
$$b('#tool_import').show().prepend(imgImport); $$b('#tool_import').show().prepend(imgImport);
} // const revnums = 'svg-editor.js ($Rev$) '; }
updateCanvas(true); // const revnums = 'svg-editor.js ($Rev$) ';
// revnums += svgCanvas.getVersion(); // revnums += svgCanvas.getVersion();
// $('#copyright')[0].setAttribute('title', revnums); // $('#copyright')[0].setAttribute('title', revnums);
var loadedExtensionNames = []; var loadedExtensionNames = [];
/** /**
* @function module:SVGEditor.setLang * @function module:SVGEditor.setLang
@ -34057,23 +34110,37 @@
* @param {module:locale.LocaleStrings} allStrings See {@tutorial LocaleDocs} * @param {module:locale.LocaleStrings} allStrings See {@tutorial LocaleDocs}
* @fires module:svgcanvas.SvgCanvas#event:ext-langReady * @fires module:svgcanvas.SvgCanvas#event:ext-langReady
* @fires module:svgcanvas.SvgCanvas#event:ext-langChanged * @fires module:svgcanvas.SvgCanvas#event:ext-langChanged
* @returns {undefined} * @returns {Promise} A Promise which resolves to `undefined`
*/ */
var setLang = editor.setLang = function (lang, allStrings) { var setLang = editor.setLang =
/*#__PURE__*/
function () {
var _ref22 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee8(lang, allStrings) {
var oldLayerName, renameLayer, ext, elems;
return regeneratorRuntime.wrap(function _callee8$(_context8) {
while (1) {
switch (_context8.prev = _context8.next) {
case 0:
editor.langChanged = true; editor.langChanged = true;
$$b.pref('lang', lang); $$b.pref('lang', lang);
$$b('#lang_select').val(lang); $$b('#lang_select').val(lang);
if (!allStrings) { if (allStrings) {
return; _context8.next = 5;
break;
} }
return _context8.abrupt("return");
case 5:
$$b.extend(uiStrings$1, allStrings); // const notif = allStrings.notification; // Currently unused $$b.extend(uiStrings$1, allStrings); // const notif = allStrings.notification; // Currently unused
// $.extend will only replace the given strings // $.extend will only replace the given strings
var oldLayerName = $$b('#layerlist tr.layersel td.layername').text(); oldLayerName = $$b('#layerlist tr.layersel td.layername').text();
var renameLayer = oldLayerName === uiStrings$1.common.layer + ' 1'; renameLayer = oldLayerName === uiStrings$1.common.layer + ' 1';
svgCanvas.setUiStrings(allStrings); svgCanvas.setUiStrings(allStrings);
Actions.setTitles(); Actions.setTitles();
@ -34083,11 +34150,21 @@
} // In case extensions loaded before the locale, now we execute a callback on them } // In case extensions loaded before the locale, now we execute a callback on them
if (extsPreLang.length) { if (!extsPreLang.length) {
while (extsPreLang.length) { _context8.next = 21;
var ext = extsPreLang.shift(); break;
}
case 12:
if (!extsPreLang.length) {
_context8.next = 19;
break;
}
ext = extsPreLang.shift();
loadedExtensionNames.push(ext.name); loadedExtensionNames.push(ext.name);
ext.langReady({ _context8.next = 17;
return ext.langReady({
lang: lang, lang: lang,
uiStrings: uiStrings$1, uiStrings: uiStrings$1,
importLocale: getImportLocale({ importLocale: getImportLocale({
@ -34095,8 +34172,16 @@
defaultName: ext.name defaultName: ext.name
}) })
}); });
}
} else { case 17:
_context8.next = 12;
break;
case 19:
_context8.next = 22;
break;
case 21:
loadedExtensionNames.forEach(function (loadedExtensionName) { loadedExtensionNames.forEach(function (loadedExtensionName) {
svgCanvas.runExtensions('langReady', svgCanvas.runExtensions('langReady',
/** @type {module:svgcanvas.SvgCanvas#event:ext-langReady} */ /** @type {module:svgcanvas.SvgCanvas#event:ext-langReady} */
@ -34109,15 +34194,15 @@
}) })
}); });
}); });
}
case 22:
svgCanvas.runExtensions('langChanged', svgCanvas.runExtensions('langChanged',
/** @type {module:svgcanvas.SvgCanvas#event:ext-langChanged} */ /** @type {module:svgcanvas.SvgCanvas#event:ext-langChanged} */
lang); // Update flyout tooltips lang); // Update flyout tooltips
setFlyoutTitles(); // Copy title for certain tool elements setFlyoutTitles(); // Copy title for certain tool elements
var elems = { elems = {
'#stroke_color': '#tool_stroke .icon_label, #tool_stroke .color_block', '#stroke_color': '#tool_stroke .icon_label, #tool_stroke .color_block',
'#fill_color': '#tool_fill label, #tool_fill .color_block', '#fill_color': '#tool_fill label, #tool_fill .color_block',
'#linejoin_miter': '#cur_linejoin', '#linejoin_miter': '#cur_linejoin',
@ -34130,7 +34215,19 @@
$$b('#multiselected_panel div[id^=tool_align]').each(function () { $$b('#multiselected_panel div[id^=tool_align]').each(function () {
$$b('#tool_pos' + this.id.substr(10))[0].title = this.title; $$b('#tool_pos' + this.id.substr(10))[0].title = this.title;
}); });
case 27:
case "end":
return _context8.stop();
}
}
}, _callee8, this);
}));
return function (_x6, _x7) {
return _ref22.apply(this, arguments);
}; };
}();
init$7( init$7(
/** /**
@ -34339,9 +34436,9 @@
* @returns {undefined} * @returns {undefined}
*/ */
var messageListener = function messageListener(_ref20) { var messageListener = function messageListener(_ref23) {
var data = _ref20.data, var data = _ref23.data,
origin = _ref20.origin; origin = _ref23.origin;
// console.log('data, origin, extensionsAdded', data, origin, extensionsAdded); // console.log('data, origin, extensionsAdded', data, origin, extensionsAdded);
var messageObj = { var messageObj = {
data: data, data: data,

View File

@ -27564,11 +27564,11 @@
editor.showSaveWarning = false; editor.showSaveWarning = false;
/** /**
* @type {boolean} * Will be set to a boolean by `ext-storage.js`
* @type {"ignore"|"waiting"|"closed"}
*/ */
editor.storagePromptClosed = false; // For use with ext-storage.js editor.storagePromptState = 'ignore';
var callbacks = [], var callbacks = [],
/** /**
@ -28370,9 +28370,12 @@
_ref6 = _context4.sent; _ref6 = _context4.sent;
langParam = _ref6.langParam; langParam = _ref6.langParam;
langData = _ref6.langData; langData = _ref6.langData;
setLang(langParam, langData); _context4.next = 7;
_context4.prev = 6; return setLang(langParam, langData);
_context4.next = 9;
case 7:
_context4.prev = 7;
_context4.next = 10;
return Promise.all(curConfig.extensions.map( return Promise.all(curConfig.extensions.map(
/*#__PURE__*/ /*#__PURE__*/
function () { function () {
@ -28439,7 +28442,7 @@
}; };
}())); }()));
case 9: case 10:
svgCanvas.bind('extensions_added', svgCanvas.bind('extensions_added',
/** /**
* @param {external:Window} win * @param {external:Window} win
@ -28453,7 +28456,11 @@
$$b('.flyout_arrow_horiz:empty').each(function () { $$b('.flyout_arrow_horiz:empty').each(function () {
$$b(this).append($$b.getSvgIcon('arrow_right', true).width(5).height(5)); $$b(this).append($$b.getSvgIcon('arrow_right', true).width(5).height(5));
}); });
if (editor.storagePromptState === 'ignore') {
updateCanvas(true); updateCanvas(true);
}
messageQueue.forEach( messageQueue.forEach(
/** /**
* @param {module:svgcanvas.SvgCanvas#event:message} messageObj * @param {module:svgcanvas.SvgCanvas#event:message} messageObj
@ -28465,20 +28472,20 @@
}); });
}); });
svgCanvas.call('extensions_added'); svgCanvas.call('extensions_added');
_context4.next = 16; _context4.next = 17;
break; break;
case 13: case 14:
_context4.prev = 13; _context4.prev = 14;
_context4.t0 = _context4["catch"](6); _context4.t0 = _context4["catch"](7);
console.log(_context4.t0); console.log(_context4.t0);
case 16: case 17:
case "end": case "end":
return _context4.stop(); return _context4.stop();
} }
} }
}, _callee4, this, [[6, 13]]); }, _callee4, this, [[7, 14]]);
})); }));
return function extAndLocaleFunc() { return function extAndLocaleFunc() {
@ -29800,7 +29807,7 @@
workarea.scroll(); workarea.scroll();
} }
if (urldata.storagePrompt !== true && !editor.storagePromptClosed) { if (urldata.storagePrompt !== true && editor.storagePromptState === 'ignore') {
$$b('#dialog_box').hide(); $$b('#dialog_box').hide();
} }
}; };
@ -30728,33 +30735,18 @@
* @returns {Promise} Resolves to `undefined` * @returns {Promise} Resolves to `undefined`
*/ */
var extAdded = function extAdded(win, ext) { var extAdded =
if (!ext) { /*#__PURE__*/
return; function () {
} var _ref14 = _asyncToGenerator(
/*#__PURE__*/
var cbCalled = false; regeneratorRuntime.mark(function _callee5(win, ext) {
var resizeDone = false; var cbCalled, resizeDone, lang, prepResize, runCallback, btnSelects, svgicons, fallbackObj, placementObj, holders;
return regeneratorRuntime.wrap(function _callee5$(_context5) {
if (ext.langReady) { while (1) {
if (editor.langChanged) { switch (_context5.prev = _context5.next) {
// We check for this since the "lang" pref could have been set by storage case 0:
var lang = $$b.pref('lang'); prepResize = function _ref15() {
ext.langReady({
lang: lang,
uiStrings: uiStrings$1,
importLocale: getImportLocale({
defaultLang: lang,
defaultName: ext.name
})
});
loadedExtensionNames.push(ext.name);
} else {
extsPreLang.push(ext);
}
}
function prepResize() {
if (resizeTimer) { if (resizeTimer) {
clearTimeout(resizeTimer); clearTimeout(resizeTimer);
resizeTimer = null; resizeTimer = null;
@ -30766,16 +30758,58 @@
setIconSize($$b.pref('iconsize')); setIconSize($$b.pref('iconsize'));
}, 50); }, 50);
} }
};
if (ext) {
_context5.next = 3;
break;
} }
var runCallback = function runCallback() { return _context5.abrupt("return");
case 3:
cbCalled = false;
resizeDone = false;
if (!ext.langReady) {
_context5.next = 14;
break;
}
if (!editor.langChanged) {
_context5.next = 13;
break;
}
// We check for this since the "lang" pref could have been set by storage
lang = $$b.pref('lang');
_context5.next = 10;
return ext.langReady({
lang: lang,
uiStrings: uiStrings$1,
importLocale: getImportLocale({
defaultLang: lang,
defaultName: ext.name
})
});
case 10:
loadedExtensionNames.push(ext.name);
_context5.next = 14;
break;
case 13:
extsPreLang.push(ext);
case 14:
runCallback = function runCallback() {
if (ext.callback && !cbCalled) { if (ext.callback && !cbCalled) {
cbCalled = true; cbCalled = true;
ext.callback.call(editor); ext.callback.call(editor);
} }
}; };
var btnSelects = []; btnSelects = [];
/** /**
* @typedef {PlainObject} module:SVGEditor.ContextTool * @typedef {PlainObject} module:SVGEditor.ContextTool
* @property {string} panel The ID of the existing panel to which the tool is being added. Required. * @property {string} panel The ID of the existing panel to which the tool is being added. Required.
@ -30878,12 +30912,14 @@
}); });
} }
var svgicons = ext.svgicons; svgicons = ext.svgicons;
if (ext.buttons) { if (!ext.buttons) {
var fallbackObj = {}, _context5.next = 24;
placementObj = {}, break;
holders = {}; }
fallbackObj = {}, placementObj = {}, holders = {};
/** /**
* @typedef {GenericArray} module:SVGEditor.KeyArray * @typedef {GenericArray} module:SVGEditor.KeyArray
* @property {string} 0 The key to bind (on `keydown`) * @property {string} 0 The key to bind (on `keydown`)
@ -31136,8 +31172,12 @@
}); });
}); });
if (svgicons) { if (!svgicons) {
return new Promise(function (resolve, reject) { _context5.next = 24;
break;
}
return _context5.abrupt("return", new Promise(function (resolve, reject) {
$$b.svgIcons(svgicons, { $$b.svgIcons(svgicons, {
w: 24, w: 24,
h: 24, h: 24,
@ -31156,12 +31196,23 @@
resolve(); resolve();
} }
}); });
}); }));
}
}
return runCallback(); case 24:
return _context5.abrupt("return", runCallback());
case 25:
case "end":
return _context5.stop();
}
}
}, _callee5, this);
}));
return function extAdded(_x3, _x4) {
return _ref14.apply(this, arguments);
}; };
}();
var getPaint = function getPaint(color, opac, type) { var getPaint = function getPaint(color, opac, type) {
// update the editor's fill paint // update the editor's fill paint
@ -31225,9 +31276,9 @@
* @listens module:svgcanvas.SvgCanvas#event:updateCanvas * @listens module:svgcanvas.SvgCanvas#event:updateCanvas
* @returns {undefined} * @returns {undefined}
*/ */
function (win, _ref14) { function (win, _ref16) {
var center = _ref14.center, var center = _ref16.center,
newCtr = _ref14.newCtr; newCtr = _ref16.newCtr;
updateCanvas(center, newCtr); updateCanvas(center, newCtr);
}); });
svgCanvas.bind('contextset', contextChanged); svgCanvas.bind('contextset', contextChanged);
@ -32035,15 +32086,15 @@
'PNG', 'JPEG', 'BMP', 'WEBP', 'PDF'], 'PNG', 'JPEG', 'BMP', 'WEBP', 'PDF'],
/*#__PURE__*/ /*#__PURE__*/
function () { function () {
var _ref15 = _asyncToGenerator( var _ref17 = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee5(imgType) { regeneratorRuntime.mark(function _callee6(imgType) {
var exportWindowName, openExportWindow, chrome, quality; var exportWindowName, openExportWindow, chrome, quality;
return regeneratorRuntime.wrap(function _callee5$(_context5) { return regeneratorRuntime.wrap(function _callee6$(_context6) {
while (1) { while (1) {
switch (_context5.prev = _context5.next) { switch (_context6.prev = _context6.next) {
case 0: case 0:
openExportWindow = function _ref16() { openExportWindow = function _ref18() {
var str = uiStrings$1.notification.loadingImage; var str = uiStrings$1.notification.loadingImage;
if (curConfig.exportWindowType === 'new') { if (curConfig.exportWindowType === 'new') {
@ -32074,17 +32125,17 @@
}; };
if (imgType) { if (imgType) {
_context5.next = 3; _context6.next = 3;
break; break;
} }
return _context5.abrupt("return"); return _context6.abrupt("return");
case 3: case 3:
chrome = isChrome(); chrome = isChrome();
if (!(imgType === 'PDF')) { if (!(imgType === 'PDF')) {
_context5.next = 9; _context6.next = 9;
break; break;
} }
@ -32093,7 +32144,7 @@
} }
svgCanvas.exportPDF(exportWindowName, chrome ? 'save' : undefined); svgCanvas.exportPDF(exportWindowName, chrome ? 'save' : undefined);
_context5.next = 13; _context6.next = 13;
break; break;
case 9: case 9:
@ -32104,19 +32155,19 @@
quality = parseInt($$b('#image-slider').val(), 10) / 100; quality = parseInt($$b('#image-slider').val(), 10) / 100;
/* const results = */ /* const results = */
_context5.next = 13; _context6.next = 13;
return svgCanvas.rasterExport(imgType, quality, exportWindowName); return svgCanvas.rasterExport(imgType, quality, exportWindowName);
case 13: case 13:
case "end": case "end":
return _context5.stop(); return _context6.stop();
} }
} }
}, _callee5, this); }, _callee6, this);
})); }));
return function (_x3) { return function (_x5) {
return _ref15.apply(this, arguments); return _ref17.apply(this, arguments);
}; };
}(), function () { }(), function () {
var sel = $$b(this); var sel = $$b(this);
@ -32353,12 +32404,12 @@
/*#__PURE__*/ /*#__PURE__*/
_asyncToGenerator( _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee6() { regeneratorRuntime.mark(function _callee7() {
var color, lang, _ref18, langParam, langData; var color, lang, _ref20, langParam, langData;
return regeneratorRuntime.wrap(function _callee6$(_context6) { return regeneratorRuntime.wrap(function _callee7$(_context7) {
while (1) { while (1) {
switch (_context6.prev = _context6.next) { switch (_context7.prev = _context7.next) {
case 0: case 0:
// Set background // Set background
color = $$b('#bg_blocks div.cur_background').css('background-color') || '#FFF'; color = $$b('#bg_blocks div.cur_background').css('background-color') || '#FFF';
@ -32367,20 +32418,21 @@
lang = $$b('#lang_select').val(); lang = $$b('#lang_select').val();
if (!(lang !== $$b.pref('lang'))) { if (!(lang !== $$b.pref('lang'))) {
_context6.next = 10; _context7.next = 11;
break; break;
} }
_context6.next = 6; _context7.next = 6;
return editor.putLocale(lang, goodLangs, curConfig); return editor.putLocale(lang, goodLangs, curConfig);
case 6: case 6:
_ref18 = _context6.sent; _ref20 = _context7.sent;
langParam = _ref18.langParam; langParam = _ref20.langParam;
langData = _ref18.langData; langData = _ref20.langData;
setLang(langParam, langData); _context7.next = 11;
return setLang(langParam, langData);
case 10: case 11:
// set icon size // set icon size
setIconSize($$b('#iconsize').val()); // set grid setting setIconSize($$b('#iconsize').val()); // set grid setting
@ -32399,12 +32451,12 @@
updateCanvas(); updateCanvas();
hidePreferences(); hidePreferences();
case 21: case 22:
case "end": case "end":
return _context6.stop(); return _context7.stop();
} }
} }
}, _callee6, this); }, _callee7, this);
})); }));
var resetScrollPos = $$b.noop; var resetScrollPos = $$b.noop;
@ -33972,8 +34024,8 @@
// bitmap handling // bitmap handling
reader = new FileReader(); reader = new FileReader();
reader.onloadend = function (_ref19) { reader.onloadend = function (_ref21) {
var result = _ref19.target.result; var result = _ref21.target.result;
// let's insert the new image until we know its dimensions // let's insert the new image until we know its dimensions
var insertNewImage = function insertNewImage(width, height) { var insertNewImage = function insertNewImage(width, height) {
@ -34045,11 +34097,12 @@
$$b('#tool_open').show().prepend(open); $$b('#tool_open').show().prepend(open);
var imgImport = $$b('<input type="file">').change(importImage); var imgImport = $$b('<input type="file">').change(importImage);
$$b('#tool_import').show().prepend(imgImport); $$b('#tool_import').show().prepend(imgImport);
} // const revnums = 'svg-editor.js ($Rev$) '; }
updateCanvas(true); // const revnums = 'svg-editor.js ($Rev$) ';
// revnums += svgCanvas.getVersion(); // revnums += svgCanvas.getVersion();
// $('#copyright')[0].setAttribute('title', revnums); // $('#copyright')[0].setAttribute('title', revnums);
var loadedExtensionNames = []; var loadedExtensionNames = [];
/** /**
* @function module:SVGEditor.setLang * @function module:SVGEditor.setLang
@ -34057,23 +34110,37 @@
* @param {module:locale.LocaleStrings} allStrings See {@tutorial LocaleDocs} * @param {module:locale.LocaleStrings} allStrings See {@tutorial LocaleDocs}
* @fires module:svgcanvas.SvgCanvas#event:ext-langReady * @fires module:svgcanvas.SvgCanvas#event:ext-langReady
* @fires module:svgcanvas.SvgCanvas#event:ext-langChanged * @fires module:svgcanvas.SvgCanvas#event:ext-langChanged
* @returns {undefined} * @returns {Promise} A Promise which resolves to `undefined`
*/ */
var setLang = editor.setLang = function (lang, allStrings) { var setLang = editor.setLang =
/*#__PURE__*/
function () {
var _ref22 = _asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee8(lang, allStrings) {
var oldLayerName, renameLayer, ext, elems;
return regeneratorRuntime.wrap(function _callee8$(_context8) {
while (1) {
switch (_context8.prev = _context8.next) {
case 0:
editor.langChanged = true; editor.langChanged = true;
$$b.pref('lang', lang); $$b.pref('lang', lang);
$$b('#lang_select').val(lang); $$b('#lang_select').val(lang);
if (!allStrings) { if (allStrings) {
return; _context8.next = 5;
break;
} }
return _context8.abrupt("return");
case 5:
$$b.extend(uiStrings$1, allStrings); // const notif = allStrings.notification; // Currently unused $$b.extend(uiStrings$1, allStrings); // const notif = allStrings.notification; // Currently unused
// $.extend will only replace the given strings // $.extend will only replace the given strings
var oldLayerName = $$b('#layerlist tr.layersel td.layername').text(); oldLayerName = $$b('#layerlist tr.layersel td.layername').text();
var renameLayer = oldLayerName === uiStrings$1.common.layer + ' 1'; renameLayer = oldLayerName === uiStrings$1.common.layer + ' 1';
svgCanvas.setUiStrings(allStrings); svgCanvas.setUiStrings(allStrings);
Actions.setTitles(); Actions.setTitles();
@ -34083,11 +34150,21 @@
} // In case extensions loaded before the locale, now we execute a callback on them } // In case extensions loaded before the locale, now we execute a callback on them
if (extsPreLang.length) { if (!extsPreLang.length) {
while (extsPreLang.length) { _context8.next = 21;
var ext = extsPreLang.shift(); break;
}
case 12:
if (!extsPreLang.length) {
_context8.next = 19;
break;
}
ext = extsPreLang.shift();
loadedExtensionNames.push(ext.name); loadedExtensionNames.push(ext.name);
ext.langReady({ _context8.next = 17;
return ext.langReady({
lang: lang, lang: lang,
uiStrings: uiStrings$1, uiStrings: uiStrings$1,
importLocale: getImportLocale({ importLocale: getImportLocale({
@ -34095,8 +34172,16 @@
defaultName: ext.name defaultName: ext.name
}) })
}); });
}
} else { case 17:
_context8.next = 12;
break;
case 19:
_context8.next = 22;
break;
case 21:
loadedExtensionNames.forEach(function (loadedExtensionName) { loadedExtensionNames.forEach(function (loadedExtensionName) {
svgCanvas.runExtensions('langReady', svgCanvas.runExtensions('langReady',
/** @type {module:svgcanvas.SvgCanvas#event:ext-langReady} */ /** @type {module:svgcanvas.SvgCanvas#event:ext-langReady} */
@ -34109,15 +34194,15 @@
}) })
}); });
}); });
}
case 22:
svgCanvas.runExtensions('langChanged', svgCanvas.runExtensions('langChanged',
/** @type {module:svgcanvas.SvgCanvas#event:ext-langChanged} */ /** @type {module:svgcanvas.SvgCanvas#event:ext-langChanged} */
lang); // Update flyout tooltips lang); // Update flyout tooltips
setFlyoutTitles(); // Copy title for certain tool elements setFlyoutTitles(); // Copy title for certain tool elements
var elems = { elems = {
'#stroke_color': '#tool_stroke .icon_label, #tool_stroke .color_block', '#stroke_color': '#tool_stroke .icon_label, #tool_stroke .color_block',
'#fill_color': '#tool_fill label, #tool_fill .color_block', '#fill_color': '#tool_fill label, #tool_fill .color_block',
'#linejoin_miter': '#cur_linejoin', '#linejoin_miter': '#cur_linejoin',
@ -34130,7 +34215,19 @@
$$b('#multiselected_panel div[id^=tool_align]').each(function () { $$b('#multiselected_panel div[id^=tool_align]').each(function () {
$$b('#tool_pos' + this.id.substr(10))[0].title = this.title; $$b('#tool_pos' + this.id.substr(10))[0].title = this.title;
}); });
case 27:
case "end":
return _context8.stop();
}
}
}, _callee8, this);
}));
return function (_x6, _x7) {
return _ref22.apply(this, arguments);
}; };
}();
init$7( init$7(
/** /**
@ -34339,9 +34436,9 @@
* @returns {undefined} * @returns {undefined}
*/ */
var messageListener = function messageListener(_ref20) { var messageListener = function messageListener(_ref23) {
var data = _ref20.data, var data = _ref23.data,
origin = _ref20.origin; origin = _ref23.origin;
// console.log('data, origin, extensionsAdded', data, origin, extensionsAdded); // console.log('data, origin, extensionsAdded', data, origin, extensionsAdded);
var messageObj = { var messageObj = {
data: data, data: data,