- Fix (regression): Extension locale loading for non-English locales

- Fix: Allow language to be properly set back to a different locale and
  retaining preference (and ensure language changes are available before
  dialog closed)
- Refactoring: array extra/spread operator
- npm: Update devDep (sinon-test)
master
Brett Zamir 2018-10-20 22:04:39 +08:00
parent 0dc0324104
commit fb9eb80798
13 changed files with 355 additions and 177 deletions

View File

@ -1,10 +1,15 @@
# ?
# 3.0.0
- See pre-release version notes for other changes that occurred with 3.0.0
- Fix: Map extension click events to "mousedown" so they can be received
on touch devices (since `touch.js` changes `touchstart` to
`mousedown`) (@ClemArt); closes #168
- Fix: Ensure extension `mouseup` events run on "zoom" and "select"
modes (@iuyiuy); closes #159
- Fix: Allow language to be properly set back to a different locale and
retaining preference (and ensure language changes are available before
dialog closed)
- Fix (regression): Extension locale loading for non-English locales
- Enhancement: Allow "Escape" to work with hotkeys within text boxes;
allows escaping out of source textarea (part of #291)
- Enhancement: Allow 'a' also with meta key (command in Mac, ctrl otherwise)
@ -12,6 +17,7 @@
- Enhancement: Add a global escape key listener to clear the selection
- Refactoring: Change 'a' to lower case in key command to avoid impression
that shift is needed
- Refactoring: array extra/spread operator
- npm: Update devDeps
# 3.0.0-rc.3

121
dist/index-es.js vendored
View File

@ -27033,12 +27033,12 @@ var setStrings = function setStrings(type, obj, ids) {
switch (type) {
case 'content':
for (var i = 0, node; node = elem.childNodes[i]; i++) {
_toConsumableArray(elem.childNodes).some(function (node) {
if (node.nodeType === 3 && node.textContent.trim()) {
node.textContent = val;
break;
return true;
}
}
});
break;
@ -27879,19 +27879,23 @@ function getImportLocale(_ref) {
_ref2 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, _ref2$name = _ref2.name, name = _ref2$name === void 0 ? defaultName : _ref2$name, _ref2$lang = _ref2.lang, lang = _ref2$lang === void 0 ? defaultLang : _ref2$lang;
_context2.prev = 3;
return _context2.abrupt("return", importLocale(lang));
_context2.next = 6;
return importLocale(lang);
case 7:
_context2.prev = 7;
case 6:
return _context2.abrupt("return", _context2.sent);
case 9:
_context2.prev = 9;
_context2.t0 = _context2["catch"](3);
return _context2.abrupt("return", importLocale('en'));
case 10:
case 12:
case "end":
return _context2.stop();
}
}
}, _callee2, this, [[3, 7]]);
}, _callee2, this, [[3, 9]]);
}));
return function importLocale() {
@ -30740,6 +30744,7 @@ editor.init = function () {
defaultName: ext.name
})
});
loadedExtensionNames.push(ext.name);
} else {
extsPreLang.push(ext);
}
@ -32340,35 +32345,63 @@ editor.init = function () {
*/
var savePreferences = editor.savePreferences = function () {
// Set background
var color = $$b('#bg_blocks div.cur_background').css('background-color') || '#FFF';
setBackground(color, $$b('#canvas_bg_url').val()); // set language
var savePreferences = editor.savePreferences =
/*#__PURE__*/
_asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee6() {
var color, lang, _ref18, langParam, langData;
var lang = $$b('#lang_select').val();
return regeneratorRuntime.wrap(function _callee6$(_context6) {
while (1) {
switch (_context6.prev = _context6.next) {
case 0:
// Set background
color = $$b('#bg_blocks div.cur_background').css('background-color') || '#FFF';
setBackground(color, $$b('#canvas_bg_url').val()); // set language
if (lang !== $$b.pref('lang')) {
editor.putLocale(lang, goodLangs, curConfig);
} // set icon size
lang = $$b('#lang_select').val();
if (!(lang !== $$b.pref('lang'))) {
_context6.next = 10;
break;
}
setIconSize($$b('#iconsize').val()); // set grid setting
_context6.next = 6;
return editor.putLocale(lang, goodLangs, curConfig);
curConfig.gridSnapping = $$b('#grid_snapping_on')[0].checked;
curConfig.snappingStep = $$b('#grid_snapping_step').val();
curConfig.gridColor = $$b('#grid_color').val();
curConfig.showRulers = $$b('#show_rulers')[0].checked;
$$b('#rulers').toggle(curConfig.showRulers);
case 6:
_ref18 = _context6.sent;
langParam = _ref18.langParam;
langData = _ref18.langData;
setLang(langParam, langData);
if (curConfig.showRulers) {
updateRulers();
}
case 10:
// set icon size
setIconSize($$b('#iconsize').val()); // set grid setting
curConfig.baseUnit = $$b('#base_unit').val();
svgCanvas.setConfig(curConfig);
updateCanvas();
hidePreferences();
};
curConfig.gridSnapping = $$b('#grid_snapping_on')[0].checked;
curConfig.snappingStep = $$b('#grid_snapping_step').val();
curConfig.gridColor = $$b('#grid_color').val();
curConfig.showRulers = $$b('#show_rulers')[0].checked;
$$b('#rulers').toggle(curConfig.showRulers);
if (curConfig.showRulers) {
updateRulers();
}
curConfig.baseUnit = $$b('#base_unit').val();
svgCanvas.setConfig(curConfig);
updateCanvas();
hidePreferences();
case 21:
case "end":
return _context6.stop();
}
}
}, _callee6, this);
}));
var resetScrollPos = $$b.noop;
@ -33941,8 +33974,8 @@ editor.init = function () {
// bitmap handling
reader = new FileReader();
reader.onloadend = function (_ref17) {
var result = _ref17.target.result;
reader.onloadend = function (_ref19) {
var result = _ref19.target.result;
// let's insert the new image until we know its dimensions
var insertNewImage = function insertNewImage(width, height) {
@ -34022,6 +34055,7 @@ editor.init = function () {
// revnums += svgCanvas.getVersion();
// $('#copyright')[0].setAttribute('title', revnums);
var loadedExtensionNames = [];
/**
* @function module:SVGEditor.setLang
* @param {string} lang The language code
@ -34057,6 +34091,7 @@ editor.init = function () {
if (extsPreLang.length) {
while (extsPreLang.length) {
var ext = extsPreLang.shift();
loadedExtensionNames.push(ext.name);
ext.langReady({
lang: lang,
uiStrings: uiStrings$1,
@ -34067,11 +34102,17 @@ editor.init = function () {
});
}
} else {
svgCanvas.runExtensions('langReady',
/** @type {module:svgcanvas.SvgCanvas#event:ext-langReady} */
{
lang: lang,
uiStrings: uiStrings$1
loadedExtensionNames.forEach(function (loadedExtensionName) {
svgCanvas.runExtensions('langReady',
/** @type {module:svgcanvas.SvgCanvas#event:ext-langReady} */
{
lang: lang,
uiStrings: uiStrings$1,
importLocale: getImportLocale({
defaultLang: lang,
defaultName: loadedExtensionName
})
});
});
}
@ -34303,9 +34344,9 @@ var messageQueue = [];
* @returns {undefined}
*/
var messageListener = function messageListener(_ref18) {
var data = _ref18.data,
origin = _ref18.origin;
var messageListener = function messageListener(_ref20) {
var data = _ref20.data,
origin = _ref20.origin;
// console.log('data, origin, extensionsAdded', data, origin, extensionsAdded);
var messageObj = {
data: data,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

121
dist/index-umd.js vendored
View File

@ -27039,12 +27039,12 @@
switch (type) {
case 'content':
for (var i = 0, node; node = elem.childNodes[i]; i++) {
_toConsumableArray(elem.childNodes).some(function (node) {
if (node.nodeType === 3 && node.textContent.trim()) {
node.textContent = val;
break;
return true;
}
}
});
break;
@ -27885,19 +27885,23 @@
_ref2 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, _ref2$name = _ref2.name, name = _ref2$name === void 0 ? defaultName : _ref2$name, _ref2$lang = _ref2.lang, lang = _ref2$lang === void 0 ? defaultLang : _ref2$lang;
_context2.prev = 3;
return _context2.abrupt("return", importLocale(lang));
_context2.next = 6;
return importLocale(lang);
case 7:
_context2.prev = 7;
case 6:
return _context2.abrupt("return", _context2.sent);
case 9:
_context2.prev = 9;
_context2.t0 = _context2["catch"](3);
return _context2.abrupt("return", importLocale('en'));
case 10:
case 12:
case "end":
return _context2.stop();
}
}
}, _callee2, this, [[3, 7]]);
}, _callee2, this, [[3, 9]]);
}));
return function importLocale() {
@ -30746,6 +30750,7 @@
defaultName: ext.name
})
});
loadedExtensionNames.push(ext.name);
} else {
extsPreLang.push(ext);
}
@ -32346,35 +32351,63 @@
*/
var savePreferences = editor.savePreferences = function () {
// Set background
var color = $$b('#bg_blocks div.cur_background').css('background-color') || '#FFF';
setBackground(color, $$b('#canvas_bg_url').val()); // set language
var savePreferences = editor.savePreferences =
/*#__PURE__*/
_asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee6() {
var color, lang, _ref18, langParam, langData;
var lang = $$b('#lang_select').val();
return regeneratorRuntime.wrap(function _callee6$(_context6) {
while (1) {
switch (_context6.prev = _context6.next) {
case 0:
// Set background
color = $$b('#bg_blocks div.cur_background').css('background-color') || '#FFF';
setBackground(color, $$b('#canvas_bg_url').val()); // set language
if (lang !== $$b.pref('lang')) {
editor.putLocale(lang, goodLangs, curConfig);
} // set icon size
lang = $$b('#lang_select').val();
if (!(lang !== $$b.pref('lang'))) {
_context6.next = 10;
break;
}
setIconSize($$b('#iconsize').val()); // set grid setting
_context6.next = 6;
return editor.putLocale(lang, goodLangs, curConfig);
curConfig.gridSnapping = $$b('#grid_snapping_on')[0].checked;
curConfig.snappingStep = $$b('#grid_snapping_step').val();
curConfig.gridColor = $$b('#grid_color').val();
curConfig.showRulers = $$b('#show_rulers')[0].checked;
$$b('#rulers').toggle(curConfig.showRulers);
case 6:
_ref18 = _context6.sent;
langParam = _ref18.langParam;
langData = _ref18.langData;
setLang(langParam, langData);
if (curConfig.showRulers) {
updateRulers();
}
case 10:
// set icon size
setIconSize($$b('#iconsize').val()); // set grid setting
curConfig.baseUnit = $$b('#base_unit').val();
svgCanvas.setConfig(curConfig);
updateCanvas();
hidePreferences();
};
curConfig.gridSnapping = $$b('#grid_snapping_on')[0].checked;
curConfig.snappingStep = $$b('#grid_snapping_step').val();
curConfig.gridColor = $$b('#grid_color').val();
curConfig.showRulers = $$b('#show_rulers')[0].checked;
$$b('#rulers').toggle(curConfig.showRulers);
if (curConfig.showRulers) {
updateRulers();
}
curConfig.baseUnit = $$b('#base_unit').val();
svgCanvas.setConfig(curConfig);
updateCanvas();
hidePreferences();
case 21:
case "end":
return _context6.stop();
}
}
}, _callee6, this);
}));
var resetScrollPos = $$b.noop;
@ -33947,8 +33980,8 @@
// bitmap handling
reader = new FileReader();
reader.onloadend = function (_ref17) {
var result = _ref17.target.result;
reader.onloadend = function (_ref19) {
var result = _ref19.target.result;
// let's insert the new image until we know its dimensions
var insertNewImage = function insertNewImage(width, height) {
@ -34028,6 +34061,7 @@
// revnums += svgCanvas.getVersion();
// $('#copyright')[0].setAttribute('title', revnums);
var loadedExtensionNames = [];
/**
* @function module:SVGEditor.setLang
* @param {string} lang The language code
@ -34063,6 +34097,7 @@
if (extsPreLang.length) {
while (extsPreLang.length) {
var ext = extsPreLang.shift();
loadedExtensionNames.push(ext.name);
ext.langReady({
lang: lang,
uiStrings: uiStrings$1,
@ -34073,11 +34108,17 @@
});
}
} else {
svgCanvas.runExtensions('langReady',
/** @type {module:svgcanvas.SvgCanvas#event:ext-langReady} */
{
lang: lang,
uiStrings: uiStrings$1
loadedExtensionNames.forEach(function (loadedExtensionName) {
svgCanvas.runExtensions('langReady',
/** @type {module:svgcanvas.SvgCanvas#event:ext-langReady} */
{
lang: lang,
uiStrings: uiStrings$1,
importLocale: getImportLocale({
defaultLang: lang,
defaultName: loadedExtensionName
})
});
});
}
@ -34309,9 +34350,9 @@
* @returns {undefined}
*/
var messageListener = function messageListener(_ref18) {
var data = _ref18.data,
origin = _ref18.origin;
var messageListener = function messageListener(_ref20) {
var data = _ref20.data,
origin = _ref20.origin;
// console.log('data, origin, extensionsAdded', data, origin, extensionsAdded);
var messageObj = {
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

@ -48,12 +48,12 @@ export const setStrings = function (type, obj, ids) {
switch (type) {
case 'content':
for (let i = 0, node; (node = elem.childNodes[i]); i++) {
[...elem.childNodes].some((node) => {
if (node.nodeType === 3 && node.textContent.trim()) {
node.textContent = val;
break;
return true;
}
}
});
break;
case 'title':

View File

@ -342,7 +342,7 @@ function getImportLocale ({defaultLang, defaultName}) {
});
}
try {
return importLocale(lang);
return await importLocale(lang);
} catch (err) {
return importLocale('en');
}
@ -2957,6 +2957,7 @@ editor.init = function () {
uiStrings,
importLocale: getImportLocale({defaultLang: lang, defaultName: ext.name})
});
loadedExtensionNames.push(ext.name);
} else {
extsPreLang.push(ext);
}
@ -4441,7 +4442,7 @@ editor.init = function () {
* @function module:SVGEditor.savePreferences
* @returns {undefined}
*/
const savePreferences = editor.savePreferences = function () {
const savePreferences = editor.savePreferences = async function () {
// Set background
const color = $('#bg_blocks div.cur_background').css('background-color') || '#FFF';
setBackground(color, $('#canvas_bg_url').val());
@ -4449,7 +4450,8 @@ editor.init = function () {
// set language
const lang = $('#lang_select').val();
if (lang !== $.pref('lang')) {
editor.putLocale(lang, goodLangs, curConfig);
const {langParam, langData} = await editor.putLocale(lang, goodLangs, curConfig);
setLang(langParam, langData);
}
// set icon size
@ -5729,6 +5731,7 @@ editor.init = function () {
// revnums += svgCanvas.getVersion();
// $('#copyright')[0].setAttribute('title', revnums);
const loadedExtensionNames = [];
/**
* @function module:SVGEditor.setLang
* @param {string} lang The language code
@ -5763,6 +5766,7 @@ editor.init = function () {
if (extsPreLang.length) {
while (extsPreLang.length) {
const ext = extsPreLang.shift();
loadedExtensionNames.push(ext.name);
ext.langReady({
lang,
uiStrings,
@ -5770,7 +5774,11 @@ editor.init = function () {
});
}
} else {
svgCanvas.runExtensions('langReady', /** @type {module:svgcanvas.SvgCanvas#event:ext-langReady} */ {lang, uiStrings});
loadedExtensionNames.forEach((loadedExtensionName) => {
svgCanvas.runExtensions('langReady', /** @type {module:svgcanvas.SvgCanvas#event:ext-langReady} */ {
lang, uiStrings, importLocale: getImportLocale({defaultLang: lang, defaultName: loadedExtensionName})
});
});
}
svgCanvas.runExtensions('langChanged', /** @type {module:svgcanvas.SvgCanvas#event:ext-langChanged} */ lang);

View File

@ -27036,12 +27036,12 @@
switch (type) {
case 'content':
for (var i = 0, node; node = elem.childNodes[i]; i++) {
_toConsumableArray(elem.childNodes).some(function (node) {
if (node.nodeType === 3 && node.textContent.trim()) {
node.textContent = val;
break;
return true;
}
}
});
break;
@ -27882,19 +27882,23 @@
_ref2 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, _ref2$name = _ref2.name, name = _ref2$name === void 0 ? defaultName : _ref2$name, _ref2$lang = _ref2.lang, lang = _ref2$lang === void 0 ? defaultLang : _ref2$lang;
_context2.prev = 3;
return _context2.abrupt("return", importLocale(lang));
_context2.next = 6;
return importLocale(lang);
case 7:
_context2.prev = 7;
case 6:
return _context2.abrupt("return", _context2.sent);
case 9:
_context2.prev = 9;
_context2.t0 = _context2["catch"](3);
return _context2.abrupt("return", importLocale('en'));
case 10:
case 12:
case "end":
return _context2.stop();
}
}
}, _callee2, this, [[3, 7]]);
}, _callee2, this, [[3, 9]]);
}));
return function importLocale() {
@ -30743,6 +30747,7 @@
defaultName: ext.name
})
});
loadedExtensionNames.push(ext.name);
} else {
extsPreLang.push(ext);
}
@ -32343,35 +32348,63 @@
*/
var savePreferences = editor.savePreferences = function () {
// Set background
var color = $$b('#bg_blocks div.cur_background').css('background-color') || '#FFF';
setBackground(color, $$b('#canvas_bg_url').val()); // set language
var savePreferences = editor.savePreferences =
/*#__PURE__*/
_asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee6() {
var color, lang, _ref18, langParam, langData;
var lang = $$b('#lang_select').val();
return regeneratorRuntime.wrap(function _callee6$(_context6) {
while (1) {
switch (_context6.prev = _context6.next) {
case 0:
// Set background
color = $$b('#bg_blocks div.cur_background').css('background-color') || '#FFF';
setBackground(color, $$b('#canvas_bg_url').val()); // set language
if (lang !== $$b.pref('lang')) {
editor.putLocale(lang, goodLangs, curConfig);
} // set icon size
lang = $$b('#lang_select').val();
if (!(lang !== $$b.pref('lang'))) {
_context6.next = 10;
break;
}
setIconSize($$b('#iconsize').val()); // set grid setting
_context6.next = 6;
return editor.putLocale(lang, goodLangs, curConfig);
curConfig.gridSnapping = $$b('#grid_snapping_on')[0].checked;
curConfig.snappingStep = $$b('#grid_snapping_step').val();
curConfig.gridColor = $$b('#grid_color').val();
curConfig.showRulers = $$b('#show_rulers')[0].checked;
$$b('#rulers').toggle(curConfig.showRulers);
case 6:
_ref18 = _context6.sent;
langParam = _ref18.langParam;
langData = _ref18.langData;
setLang(langParam, langData);
if (curConfig.showRulers) {
updateRulers();
}
case 10:
// set icon size
setIconSize($$b('#iconsize').val()); // set grid setting
curConfig.baseUnit = $$b('#base_unit').val();
svgCanvas.setConfig(curConfig);
updateCanvas();
hidePreferences();
};
curConfig.gridSnapping = $$b('#grid_snapping_on')[0].checked;
curConfig.snappingStep = $$b('#grid_snapping_step').val();
curConfig.gridColor = $$b('#grid_color').val();
curConfig.showRulers = $$b('#show_rulers')[0].checked;
$$b('#rulers').toggle(curConfig.showRulers);
if (curConfig.showRulers) {
updateRulers();
}
curConfig.baseUnit = $$b('#base_unit').val();
svgCanvas.setConfig(curConfig);
updateCanvas();
hidePreferences();
case 21:
case "end":
return _context6.stop();
}
}
}, _callee6, this);
}));
var resetScrollPos = $$b.noop;
@ -33944,8 +33977,8 @@
// bitmap handling
reader = new FileReader();
reader.onloadend = function (_ref17) {
var result = _ref17.target.result;
reader.onloadend = function (_ref19) {
var result = _ref19.target.result;
// let's insert the new image until we know its dimensions
var insertNewImage = function insertNewImage(width, height) {
@ -34025,6 +34058,7 @@
// revnums += svgCanvas.getVersion();
// $('#copyright')[0].setAttribute('title', revnums);
var loadedExtensionNames = [];
/**
* @function module:SVGEditor.setLang
* @param {string} lang The language code
@ -34060,6 +34094,7 @@
if (extsPreLang.length) {
while (extsPreLang.length) {
var ext = extsPreLang.shift();
loadedExtensionNames.push(ext.name);
ext.langReady({
lang: lang,
uiStrings: uiStrings$1,
@ -34070,11 +34105,17 @@
});
}
} else {
svgCanvas.runExtensions('langReady',
/** @type {module:svgcanvas.SvgCanvas#event:ext-langReady} */
{
lang: lang,
uiStrings: uiStrings$1
loadedExtensionNames.forEach(function (loadedExtensionName) {
svgCanvas.runExtensions('langReady',
/** @type {module:svgcanvas.SvgCanvas#event:ext-langReady} */
{
lang: lang,
uiStrings: uiStrings$1,
importLocale: getImportLocale({
defaultLang: lang,
defaultName: loadedExtensionName
})
});
});
}
@ -34306,9 +34347,9 @@
* @returns {undefined}
*/
var messageListener = function messageListener(_ref18) {
var data = _ref18.data,
origin = _ref18.origin;
var messageListener = function messageListener(_ref20) {
var data = _ref20.data,
origin = _ref20.origin;
// console.log('data, origin, extensionsAdded', data, origin, extensionsAdded);
var messageObj = {
data: data,

8
package-lock.json generated
View File

@ -8996,9 +8996,9 @@
}
},
"sinon-test": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/sinon-test/-/sinon-test-2.3.0.tgz",
"integrity": "sha512-dhy6lbkZAvVW6XVsngX9HY0MNBurNPP3vqVdXGYAN4B3BNq3eXO6d5V1nuS7UsjX2tXSk7QhMEb6cUk/Fia95g==",
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/sinon-test/-/sinon-test-2.4.0.tgz",
"integrity": "sha512-oQnO02I7JDbtrSKN8Qs3upobCQRythJCBn3DzPmv4m/SoPvhZJDVqHDFkRZ1lZhN2GkBqOR3m7WT79190z9kEg==",
"dev": true
},
"slash": {
@ -9934,7 +9934,7 @@
},
"text-encoding": {
"version": "0.6.4",
"resolved": "http://registry.npmjs.org/text-encoding/-/text-encoding-0.6.4.tgz",
"resolved": "https://registry.npmjs.org/text-encoding/-/text-encoding-0.6.4.tgz",
"integrity": "sha1-45mpgiV6J22uQou5KEXLcb3CbRk=",
"dev": true
},

View File

@ -90,7 +90,7 @@
"rollup-plugin-re": "^1.0.7",
"rollup-plugin-terser": "^3.0.0",
"sinon": "^7.0.0",
"sinon-test": "^2.3.0",
"sinon-test": "^2.4.0",
"testcafe": "^0.22.0"
}
}

View File

@ -27036,12 +27036,12 @@
switch (type) {
case 'content':
for (var i = 0, node; node = elem.childNodes[i]; i++) {
_toConsumableArray(elem.childNodes).some(function (node) {
if (node.nodeType === 3 && node.textContent.trim()) {
node.textContent = val;
break;
return true;
}
}
});
break;
@ -27882,19 +27882,23 @@
_ref2 = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {}, _ref2$name = _ref2.name, name = _ref2$name === void 0 ? defaultName : _ref2$name, _ref2$lang = _ref2.lang, lang = _ref2$lang === void 0 ? defaultLang : _ref2$lang;
_context2.prev = 3;
return _context2.abrupt("return", importLocale(lang));
_context2.next = 6;
return importLocale(lang);
case 7:
_context2.prev = 7;
case 6:
return _context2.abrupt("return", _context2.sent);
case 9:
_context2.prev = 9;
_context2.t0 = _context2["catch"](3);
return _context2.abrupt("return", importLocale('en'));
case 10:
case 12:
case "end":
return _context2.stop();
}
}
}, _callee2, this, [[3, 7]]);
}, _callee2, this, [[3, 9]]);
}));
return function importLocale() {
@ -30743,6 +30747,7 @@
defaultName: ext.name
})
});
loadedExtensionNames.push(ext.name);
} else {
extsPreLang.push(ext);
}
@ -32343,35 +32348,63 @@
*/
var savePreferences = editor.savePreferences = function () {
// Set background
var color = $$b('#bg_blocks div.cur_background').css('background-color') || '#FFF';
setBackground(color, $$b('#canvas_bg_url').val()); // set language
var savePreferences = editor.savePreferences =
/*#__PURE__*/
_asyncToGenerator(
/*#__PURE__*/
regeneratorRuntime.mark(function _callee6() {
var color, lang, _ref18, langParam, langData;
var lang = $$b('#lang_select').val();
return regeneratorRuntime.wrap(function _callee6$(_context6) {
while (1) {
switch (_context6.prev = _context6.next) {
case 0:
// Set background
color = $$b('#bg_blocks div.cur_background').css('background-color') || '#FFF';
setBackground(color, $$b('#canvas_bg_url').val()); // set language
if (lang !== $$b.pref('lang')) {
editor.putLocale(lang, goodLangs, curConfig);
} // set icon size
lang = $$b('#lang_select').val();
if (!(lang !== $$b.pref('lang'))) {
_context6.next = 10;
break;
}
setIconSize($$b('#iconsize').val()); // set grid setting
_context6.next = 6;
return editor.putLocale(lang, goodLangs, curConfig);
curConfig.gridSnapping = $$b('#grid_snapping_on')[0].checked;
curConfig.snappingStep = $$b('#grid_snapping_step').val();
curConfig.gridColor = $$b('#grid_color').val();
curConfig.showRulers = $$b('#show_rulers')[0].checked;
$$b('#rulers').toggle(curConfig.showRulers);
case 6:
_ref18 = _context6.sent;
langParam = _ref18.langParam;
langData = _ref18.langData;
setLang(langParam, langData);
if (curConfig.showRulers) {
updateRulers();
}
case 10:
// set icon size
setIconSize($$b('#iconsize').val()); // set grid setting
curConfig.baseUnit = $$b('#base_unit').val();
svgCanvas.setConfig(curConfig);
updateCanvas();
hidePreferences();
};
curConfig.gridSnapping = $$b('#grid_snapping_on')[0].checked;
curConfig.snappingStep = $$b('#grid_snapping_step').val();
curConfig.gridColor = $$b('#grid_color').val();
curConfig.showRulers = $$b('#show_rulers')[0].checked;
$$b('#rulers').toggle(curConfig.showRulers);
if (curConfig.showRulers) {
updateRulers();
}
curConfig.baseUnit = $$b('#base_unit').val();
svgCanvas.setConfig(curConfig);
updateCanvas();
hidePreferences();
case 21:
case "end":
return _context6.stop();
}
}
}, _callee6, this);
}));
var resetScrollPos = $$b.noop;
@ -33944,8 +33977,8 @@
// bitmap handling
reader = new FileReader();
reader.onloadend = function (_ref17) {
var result = _ref17.target.result;
reader.onloadend = function (_ref19) {
var result = _ref19.target.result;
// let's insert the new image until we know its dimensions
var insertNewImage = function insertNewImage(width, height) {
@ -34025,6 +34058,7 @@
// revnums += svgCanvas.getVersion();
// $('#copyright')[0].setAttribute('title', revnums);
var loadedExtensionNames = [];
/**
* @function module:SVGEditor.setLang
* @param {string} lang The language code
@ -34060,6 +34094,7 @@
if (extsPreLang.length) {
while (extsPreLang.length) {
var ext = extsPreLang.shift();
loadedExtensionNames.push(ext.name);
ext.langReady({
lang: lang,
uiStrings: uiStrings$1,
@ -34070,11 +34105,17 @@
});
}
} else {
svgCanvas.runExtensions('langReady',
/** @type {module:svgcanvas.SvgCanvas#event:ext-langReady} */
{
lang: lang,
uiStrings: uiStrings$1
loadedExtensionNames.forEach(function (loadedExtensionName) {
svgCanvas.runExtensions('langReady',
/** @type {module:svgcanvas.SvgCanvas#event:ext-langReady} */
{
lang: lang,
uiStrings: uiStrings$1,
importLocale: getImportLocale({
defaultLang: lang,
defaultName: loadedExtensionName
})
});
});
}
@ -34306,9 +34347,9 @@
* @returns {undefined}
*/
var messageListener = function messageListener(_ref18) {
var data = _ref18.data,
origin = _ref18.origin;
var messageListener = function messageListener(_ref20) {
var data = _ref20.data,
origin = _ref20.origin;
// console.log('data, origin, extensionsAdded', data, origin, extensionsAdded);
var messageObj = {
data: data,