- BREAKING CHANGE: Remove `$.pref` in favor of new `svgEditor.pref`
(avoiding polluting jQuery). (Might be moved to own module in future.) - BREAKING CHANGE: `putLocale` (a function called automatically by `svg-editor.js`) no longer checks `pref`. Should not impact average consumers. `putLocale` now also logs lang and checks `goodLangs` even if an explicit lang param is providedmaster
parent
e356b95a03
commit
37424278d1
|
@ -1,6 +1,6 @@
|
|||
# SVG-Edit CHANGES
|
||||
|
||||
## ?
|
||||
## 6.0.0 (unreleased)
|
||||
|
||||
- License: Relicense ext-mathjax from Apache-2.0 to MIT per
|
||||
<https://github.com/josegaert/ext-mathjax/issues/6>
|
||||
|
@ -8,6 +8,12 @@
|
|||
"(MIT OR GPL-2.0-or-later)" per subsequent text
|
||||
- License: Reorder license listing in `jquery.contextMenu.js` so
|
||||
that more permissive is noticeable first
|
||||
- BREAKING CHANGE: Remove `$.pref` in favor of new `svgEditor.pref`
|
||||
(avoiding polluting jQuery). (Might be moved to own module in
|
||||
future.)
|
||||
- BREAKING CHANGE: `putLocale` (a function called automatically by
|
||||
`svg-editor.js`) no longer checks `pref`. Should not impact
|
||||
average consumers.
|
||||
- Fix: main menu style and text #371
|
||||
- Fix (Accessibility): Avoid duplicate IDs
|
||||
- Fix (openclipart browser): Redirect on lacking browser support
|
||||
|
|
|
@ -14,9 +14,9 @@
|
|||
* @license MIT
|
||||
*
|
||||
* @copyright 2010 Brett Zamir
|
||||
* @todo Revisit on whether to use $.pref over directly setting curConfig in all
|
||||
* extensions for a more public API (not only for extPath and imagePath,
|
||||
* but other currently used config in the extensions)
|
||||
* @todo Revisit on whether to use `svgEditor.pref` over directly setting
|
||||
* `curConfig` in all extensions for a more public API (not only for `extPath`
|
||||
* and `imagePath`, but other currently used config in the extensions)
|
||||
* @todo We might provide control of storage settings through the UI besides the
|
||||
* initial (or URL-forced) dialog. *
|
||||
*/
|
||||
|
|
|
@ -374,28 +374,17 @@ export const readLang = async function (langData) {
|
|||
export const putLocale = async function (givenParam, goodLangs, conf) {
|
||||
if (givenParam) {
|
||||
langParam = givenParam;
|
||||
} else {
|
||||
langParam = $.pref('lang');
|
||||
if (!langParam) {
|
||||
if (navigator.userLanguage) { // Explorer
|
||||
langParam = navigator.userLanguage;
|
||||
} else if (navigator.language) { // FF, Opera, ...
|
||||
langParam = navigator.language;
|
||||
}
|
||||
}
|
||||
} else if (navigator.userLanguage) { // Explorer
|
||||
langParam = navigator.userLanguage;
|
||||
} else if (navigator.language) { // FF, Opera, ...
|
||||
langParam = navigator.language;
|
||||
}
|
||||
|
||||
console.log('Lang: ' + langParam); // eslint-disable-line no-console
|
||||
console.log('Lang: ' + langParam); // eslint-disable-line no-console
|
||||
|
||||
// Set to English if language is not in list of good langs
|
||||
if (!goodLangs.includes(langParam) && langParam !== 'test') {
|
||||
langParam = 'en';
|
||||
}
|
||||
|
||||
// don't bother on first run if language is English
|
||||
// The following line prevents setLang from running
|
||||
// extensions which depend on updated uiStrings,
|
||||
// so commenting it out.
|
||||
// if (langParam.startsWith('en')) {return;}
|
||||
// Set to English if language is not in list of good langs
|
||||
if (!goodLangs.includes(langParam) && langParam !== 'test') {
|
||||
langParam = 'en';
|
||||
}
|
||||
|
||||
const url = conf.langPath + 'lang.' + langParam + '.js';
|
||||
|
|
|
@ -392,14 +392,14 @@ function getImportLocale ({defaultLang, defaultName}) {
|
|||
* @param {boolean} [mayBeEmpty] If value may be falsey.
|
||||
* @returns {string|void} If val is missing or falsey and `mayBeEmpty` is not set, the
|
||||
* value of the previously stored preference will be returned.
|
||||
* @todo Can we change setting on the jQuery namespace (onto editor) to avoid conflicts?
|
||||
* @todo Review whether any remaining existing direct references to
|
||||
* getting `curPrefs` can be changed to use `$.pref()` getting to ensure
|
||||
* `defaultPrefs` fallback (also for sake of `allowInitialUserOverride`); specifically, `bkgd_color` could be changed so that
|
||||
* the pref dialog has a button to auto-calculate background, but otherwise uses `$.pref()` to be able to get default prefs
|
||||
* or overridable settings
|
||||
* getting `curPrefs` can be changed to use `svgEditor.pref()` getting to ensure
|
||||
* `defaultPrefs` fallback (also for sake of `allowInitialUserOverride`);
|
||||
* specifically, `bkgd_color` could be changed so that the pref dialog has a
|
||||
* button to auto-calculate background, but otherwise uses `svgEditor.pref()` to
|
||||
* be able to get default prefs or overridable settings
|
||||
*/
|
||||
$.pref = function (key, val, mayBeEmpty) {
|
||||
editor.pref = function (key, val, mayBeEmpty) {
|
||||
if (mayBeEmpty || val) {
|
||||
curPrefs[key] = val;
|
||||
/**
|
||||
|
@ -526,7 +526,7 @@ editor.setConfig = function (opts, cfgCfg) {
|
|||
if (cfgCfg.allowInitialUserOverride === true) {
|
||||
defaultPrefs[key] = val;
|
||||
} else {
|
||||
$.pref(key, val);
|
||||
editor.pref(key, val);
|
||||
}
|
||||
} else if (['extensions', 'stylesheets', 'allowedOrigins'].includes(key)) {
|
||||
if (cfgCfg.overwrite === false &&
|
||||
|
@ -816,7 +816,9 @@ editor.init = function () {
|
|||
*/
|
||||
const extAndLocaleFunc = async function () {
|
||||
// const lang = ('lang' in curPrefs) ? curPrefs.lang : null;
|
||||
const {langParam, langData} = await editor.putLocale(null, goodLangs, curConfig);
|
||||
const {langParam, langData} = await editor.putLocale(
|
||||
editor.pref('lang'), goodLangs, curConfig
|
||||
);
|
||||
await setLang(langParam, langData);
|
||||
|
||||
const {ok, cancel} = uiStrings.common;
|
||||
|
@ -1012,7 +1014,7 @@ editor.init = function () {
|
|||
hiddenPs.css('visibility', 'visible').hide();
|
||||
// return;
|
||||
|
||||
$.pref('iconsize', size);
|
||||
editor.pref('iconsize', size);
|
||||
$('#iconsize').val(size);
|
||||
|
||||
// Change icon size
|
||||
|
@ -1397,7 +1399,7 @@ editor.init = function () {
|
|||
minHeight = tleft.offset().top + tleft.outerHeight();
|
||||
}
|
||||
|
||||
const size = $.pref('iconsize');
|
||||
const size = editor.pref('iconsize');
|
||||
editor.setIconSize(size || ($(window).height() < minHeight ? 's' : 'm'));
|
||||
|
||||
// Look for any missing flyout icons from plugins
|
||||
|
@ -1724,7 +1726,7 @@ editor.init = function () {
|
|||
|
||||
// Alert will only appear the first time saved OR the
|
||||
// first time the bug is encountered
|
||||
let done = $.pref('save_notice_done');
|
||||
let done = editor.pref('save_notice_done');
|
||||
|
||||
if (done !== 'all') {
|
||||
let note = uiStrings.notification.saveFromBrowser.replace('%s', 'SVG');
|
||||
|
@ -1733,13 +1735,13 @@ editor.init = function () {
|
|||
if (svg.includes('<defs')) {
|
||||
// warning about Mozilla bug #308590 when applicable (seems to be fixed now in Feb 2013)
|
||||
note += '\n\n' + uiStrings.notification.defsFailOnSave;
|
||||
$.pref('save_notice_done', 'all');
|
||||
editor.pref('save_notice_done', 'all');
|
||||
done = 'all';
|
||||
} else {
|
||||
$.pref('save_notice_done', 'part');
|
||||
editor.pref('save_notice_done', 'part');
|
||||
}
|
||||
} else {
|
||||
$.pref('save_notice_done', 'all');
|
||||
editor.pref('save_notice_done', 'all');
|
||||
}
|
||||
if (done !== 'part') {
|
||||
$.alert(note);
|
||||
|
@ -1764,7 +1766,7 @@ editor.init = function () {
|
|||
}
|
||||
|
||||
exportWindow.location.href = data.bloburl || data.datauri;
|
||||
const done = $.pref('export_notice_done');
|
||||
const done = editor.pref('export_notice_done');
|
||||
if (done !== 'all') {
|
||||
let note = uiStrings.notification.saveFromBrowser.replace('%s', data.type);
|
||||
|
||||
|
@ -1776,7 +1778,7 @@ editor.init = function () {
|
|||
|
||||
// Note that this will also prevent the notice even though new issues may appear later.
|
||||
// May want to find a way to deal with that without annoying the user
|
||||
$.pref('export_notice_done', 'all');
|
||||
editor.pref('export_notice_done', 'all');
|
||||
exportWindow.alert(note);
|
||||
}
|
||||
};
|
||||
|
@ -1894,9 +1896,9 @@ editor.init = function () {
|
|||
* @returns {void}
|
||||
*/
|
||||
function setBackground (color, url) {
|
||||
// if (color == $.pref('bkgd_color') && url == $.pref('bkgd_url')) { return; }
|
||||
$.pref('bkgd_color', color);
|
||||
$.pref('bkgd_url', url, true);
|
||||
// if (color == editor.pref('bkgd_color') && url == editor.pref('bkgd_url')) { return; }
|
||||
editor.pref('bkgd_color', color);
|
||||
editor.pref('bkgd_url', url, true);
|
||||
|
||||
// This should be done in svgcanvas.js for the borderRect fill
|
||||
svgCanvas.setBackground(color, url);
|
||||
|
@ -3073,7 +3075,7 @@ editor.init = function () {
|
|||
|
||||
if (ext.langReady) {
|
||||
if (editor.langChanged) { // We check for this since the "lang" pref could have been set by storage
|
||||
const lang = $.pref('lang');
|
||||
const lang = editor.pref('lang');
|
||||
await ext.langReady({
|
||||
lang,
|
||||
uiStrings,
|
||||
|
@ -3098,7 +3100,7 @@ editor.init = function () {
|
|||
if (!resizeDone) {
|
||||
resizeTimer = setTimeout(function () {
|
||||
resizeDone = true;
|
||||
setIconSize($.pref('iconsize'));
|
||||
setIconSize(editor.pref('iconsize'));
|
||||
}, 50);
|
||||
}
|
||||
}
|
||||
|
@ -3483,7 +3485,7 @@ editor.init = function () {
|
|||
callback (icons) {
|
||||
// Non-ideal hack to make the icon match the current size
|
||||
// if (curPrefs.iconsize && curPrefs.iconsize !== 'm') {
|
||||
if ($.pref('iconsize') !== 'm') {
|
||||
if (editor.pref('iconsize') !== 'm') {
|
||||
prepResize();
|
||||
}
|
||||
runCallback();
|
||||
|
@ -3589,9 +3591,9 @@ editor.init = function () {
|
|||
});
|
||||
});
|
||||
|
||||
setBackground($.pref('bkgd_color'), $.pref('bkgd_url'));
|
||||
setBackground(editor.pref('bkgd_color'), editor.pref('bkgd_url'));
|
||||
|
||||
$('#image_save_opts input').val([$.pref('img_save')]);
|
||||
$('#image_save_opts input').val([editor.pref('img_save')]);
|
||||
|
||||
/**
|
||||
* @type {module:jQuerySpinButton.ValueCallback}
|
||||
|
@ -4499,7 +4501,7 @@ editor.init = function () {
|
|||
const clickSave = function () {
|
||||
// In the future, more options can be provided here
|
||||
const saveOpts = {
|
||||
images: $.pref('img_save'),
|
||||
images: editor.pref('img_save'),
|
||||
round_digits: 6
|
||||
};
|
||||
svgCanvas.save(saveOpts);
|
||||
|
@ -4688,7 +4690,7 @@ editor.init = function () {
|
|||
docprops = true;
|
||||
|
||||
// This selects the correct radio button by using the array notation
|
||||
$('#image_save_opts input').val([$.pref('img_save')]);
|
||||
$('#image_save_opts input').val([editor.pref('img_save')]);
|
||||
|
||||
// update resolution option with actual resolution
|
||||
const res = svgCanvas.getResolution();
|
||||
|
@ -4715,7 +4717,7 @@ editor.init = function () {
|
|||
|
||||
// Update background color with current one
|
||||
const canvasBg = curPrefs.bkgd_color;
|
||||
const url = $.pref('bkgd_url');
|
||||
const url = editor.pref('bkgd_url');
|
||||
blocks.each(function () {
|
||||
const blk = $(this);
|
||||
const isBg = blk.css('background-color') === canvasBg;
|
||||
|
@ -4787,7 +4789,7 @@ editor.init = function () {
|
|||
$('#svg_docprops').hide();
|
||||
$('#canvas_width,#canvas_height').removeAttr('disabled');
|
||||
$('#resolution')[0].selectedIndex = 0;
|
||||
$('#image_save_opts input').val([$.pref('img_save')]);
|
||||
$('#image_save_opts input').val([editor.pref('img_save')]);
|
||||
docprops = false;
|
||||
};
|
||||
|
||||
|
@ -4836,7 +4838,7 @@ editor.init = function () {
|
|||
}
|
||||
|
||||
// Set image save option
|
||||
$.pref('img_save', $('#image_save_opts :checked').val());
|
||||
editor.pref('img_save', $('#image_save_opts :checked').val());
|
||||
updateCanvas();
|
||||
hideDocProperties();
|
||||
return true;
|
||||
|
@ -4854,7 +4856,7 @@ editor.init = function () {
|
|||
|
||||
// set language
|
||||
const lang = $('#lang_select').val();
|
||||
if (lang !== $.pref('lang')) {
|
||||
if (lang && lang !== editor.pref('lang')) {
|
||||
const {langParam, langData} = await editor.putLocale(lang, goodLangs, curConfig);
|
||||
await setLang(langParam, langData);
|
||||
}
|
||||
|
@ -5227,7 +5229,7 @@ editor.init = function () {
|
|||
// Disable option
|
||||
$('#image_save_opts [value=embed]').attr('disabled', 'disabled');
|
||||
$('#image_save_opts input').val(['ref']);
|
||||
$.pref('img_save', 'ref');
|
||||
editor.pref('img_save', 'ref');
|
||||
$('#image_opt_embed').css('color', '#666').attr(
|
||||
'title',
|
||||
uiStrings.notification.featNotSupported
|
||||
|
@ -6255,7 +6257,7 @@ editor.init = function () {
|
|||
*/
|
||||
const setLang = editor.setLang = async function (lang, allStrings) {
|
||||
editor.langChanged = true;
|
||||
$.pref('lang', lang);
|
||||
editor.pref('lang', lang);
|
||||
$('#lang_select').val(lang);
|
||||
if (!allStrings) {
|
||||
return;
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
// TO svgedit-config-es.js.
|
||||
|
||||
/*
|
||||
The svgedit-config-es.js file is intended for the setting of configuration or
|
||||
preferences which must run early on; if this is not needed, it is
|
||||
The svgedit-config-es.js file is intended for the setting of configuration
|
||||
or preferences which must run early on; if this is not needed, it is
|
||||
recommended that you create an extension instead (for greater
|
||||
reusability and modularity). This file needs to be in the parent
|
||||
folder of the editor folder. It is referenced in the code as
|
||||
|
@ -51,8 +51,14 @@ svgEditor.setConfig({
|
|||
// EXTENSION CONFIG
|
||||
svgEditor.setConfig({
|
||||
extensions: [
|
||||
// 'ext-overview_window.js', 'ext-markers.js', 'ext-connector.js', 'ext-eyedropper.js', 'ext-shapes.js', 'ext-imagelib.js', 'ext-grid.js', 'ext-polygon.js', 'ext-star.js', 'ext-panning.js', 'ext-storage.js'
|
||||
], noDefaultExtensions: false, // noDefaultExtensions can only be meaningfully used in svgedit-config-es.js or in the URL
|
||||
// 'ext-overview_window.js', 'ext-markers.js', 'ext-connector.js',
|
||||
// 'ext-eyedropper.js', 'ext-shapes.js', 'ext-imagelib.js',
|
||||
// 'ext-grid.js', 'ext-polygon.js', 'ext-star.js', 'ext-panning.js',
|
||||
// 'ext-storage.js'
|
||||
],
|
||||
// noDefaultExtensions can only be meaningfully used in
|
||||
// `svgedit-config-es.js` or in the URL
|
||||
noDefaultExtensions: false,
|
||||
});
|
||||
|
||||
// STYLESHEET CONFIG
|
||||
|
@ -91,7 +97,8 @@ svgEditor.setConfig({
|
|||
Setting as `['*']` would allow any domain to access but would be unsafe to
|
||||
data privacy and integrity.
|
||||
*/
|
||||
// allowedOrigins: [location.origin || 'null'], // May be 'null' (as a string) when used as a `file:///` URL
|
||||
// May be 'null' (as a string) when used as a `file:///` URL
|
||||
// allowedOrigins: [location.origin || 'null'],
|
||||
// DOCUMENT PROPERTIES
|
||||
// dimensions: [640, 480],
|
||||
// EDITOR OPTIONS
|
||||
|
@ -103,9 +110,16 @@ svgEditor.setConfig({
|
|||
// EXTENSION-RELATED (GRID)
|
||||
// showGrid: false, // Set by ext-grid.js
|
||||
// EXTENSION-RELATED (STORAGE)
|
||||
// noStorageOnLoad: false, // Some interaction with ext-storage.js; prevent even the loading of previously saved local storage
|
||||
// forceStorage: false, // Some interaction with ext-storage.js; strongly discouraged from modification as it bypasses user privacy by preventing them from choosing whether to keep local storage or not
|
||||
// emptyStorageOnDecline: true, // Used by ext-storage.js; empty any prior storage if the user declines to store
|
||||
// Some interaction with `ext-storage.js`; prevent even the loading of
|
||||
// previously saved local storage
|
||||
// noStorageOnLoad: false,
|
||||
// Some interaction with `ext-storage.js`; strongly discouraged from
|
||||
// modification as it bypasses user privacy by preventing them from
|
||||
// choosing whether to keep local storage or not
|
||||
// forceStorage: false,
|
||||
// Used by `ext-storage.js`; empty any prior storage if the user
|
||||
// declines to store
|
||||
// emptyStorageOnDecline: true,
|
||||
});
|
||||
|
||||
// PREF CHANGES
|
||||
|
@ -123,14 +137,17 @@ As with configuration, one may use allowInitialUserOverride, but
|
|||
are hard-coded here regardless of URL or prior user storage setting.
|
||||
*/
|
||||
svgEditor.setConfig({
|
||||
// lang: '', // Set dynamically within locale.js if not previously set
|
||||
// iconsize: '', // Will default to 's' if the window height is smaller than the minimum height and 'm' otherwise
|
||||
// Set dynamically within locale.js if not previously set
|
||||
// lang: '',
|
||||
// Will default to 's' if the window height is smaller than the minimum
|
||||
// height and 'm' otherwise
|
||||
// iconsize: '',
|
||||
/**
|
||||
* When showing the preferences dialog, svg-editor.js currently relies
|
||||
* on curPrefs instead of $.pref, so allowing an override for bkgd_color
|
||||
* means that this value won't have priority over block auto-detection as
|
||||
* far as determining which color shows initially in the preferences
|
||||
* dialog (though it can be changed and saved).
|
||||
* on `curPrefs` instead of `svgEditor.pref`, so allowing an override for
|
||||
* `bkgd_color` means that this value won't have priority over block
|
||||
* auto-detection as far as determining which color shows initially
|
||||
* in the preferences dialog (though it can be changed and saved).
|
||||
*/
|
||||
// bkgd_color: '#FFF',
|
||||
// bkgd_url: '',
|
||||
|
@ -141,9 +158,10 @@ svgEditor.setConfig({
|
|||
});
|
||||
svgEditor.setConfig(
|
||||
{
|
||||
// Indicate pref settings here if you wish to allow user storage or URL settings
|
||||
// to be able to override your default preferences (unless other config options
|
||||
// have already explicitly prevented one or the other)
|
||||
// Indicate pref settings here if you wish to allow user storage or URL
|
||||
// settings to be able to override your default preferences (unless
|
||||
// other config options have already explicitly prevented one or the
|
||||
// other)
|
||||
},
|
||||
{allowInitialUserOverride: true}
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue