- Fix: Ensure PHP files are present in dist/extensions alongside JavaScript files using them
- Fix: Bug in obtaining `extPath` in ext-server_opensave.js - Enhancement: Add config `avoidClientSide` to avoid using client-side support by default (and always require server) - Build: Require Node 8.5
This commit is contained in:
@@ -14,7 +14,7 @@ export default {
|
||||
const strings = await importLocale();
|
||||
const svgEditor = this;
|
||||
const {
|
||||
curConfig: extPath,
|
||||
curConfig: {extPath, avoidClientSide},
|
||||
canvas: svgCanvas
|
||||
} = svgEditor;
|
||||
|
||||
@@ -44,6 +44,9 @@ export default {
|
||||
* @returns {boolean}
|
||||
*/
|
||||
function clientDownloadSupport (filename, suffix, uri) {
|
||||
if (avoidClientSide) {
|
||||
return false;
|
||||
}
|
||||
const support = $('<a>')[0].download === '';
|
||||
let a;
|
||||
if (support) {
|
||||
|
||||
@@ -181,6 +181,7 @@ const callbacks = [],
|
||||
* @property {boolean} [noStorageOnLoad=false] Some interaction with `ext-storage.js`; prevent even the loading of previously saved local storage.
|
||||
* @property {boolean} [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 (and may be required by law in some regions)
|
||||
* @property {boolean} [emptyStorageOnDecline=false] Used by `ext-storage.js`; empty any prior storage if the user declines to store
|
||||
* @property {boolean} [avoidClientSide=false] Used by `ext-server_opensave.js`; set to `true` if you wish to always save to server and not only as fallback when client support is lacking
|
||||
* @property {string[]} [extensions=module:SVGEditor~defaultExtensions] Extensions to load on startup. Use an array in `setConfig` and comma separated file names in the URL. Extension names must begin with "ext-". Note that as of version 2.7, paths containing "/", "\", or ":", are disallowed for security reasons. Although previous versions of this list would entirely override the default list, as of version 2.7, the defaults will always be added to this explicit list unless the configuration `noDefaultExtensions` is included.
|
||||
* @property {module:SVGEditor.Stylesheet[]} [stylesheets=["@default"]] An array of required stylesheets to load in parallel; include the value `"@default"` within this array to ensure all default stylesheets are loaded.
|
||||
* @property {string[]} [allowedOrigins=[]] Used by `ext-xdomain-messaging.js` to indicate which origins are permitted for cross-domain messaging (e.g., between the embedded editor and main editor code). Besides explicit domains, one might add '*' to allow all domains (not recommended for privacy/data integrity of your user's content!), `window.location.origin` for allowing the same origin (should be safe if you trust all apps on your domain), 'null' to allow `file:///` URL usage
|
||||
@@ -273,7 +274,9 @@ const callbacks = [],
|
||||
// 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: false // Used by ext-storage.js; empty any prior storage if the user declines to store
|
||||
emptyStorageOnDecline: false, // Used by ext-storage.js; empty any prior storage if the user declines to store
|
||||
// EXTENSION (CLIENT VS. SERVER SAVING)
|
||||
avoidClientSide: false
|
||||
},
|
||||
/**
|
||||
* LOCALE
|
||||
@@ -499,53 +502,54 @@ editor.setConfig = function (opts, cfgCfg) {
|
||||
}
|
||||
}
|
||||
$.each(opts, function (key, val) {
|
||||
if ({}.hasOwnProperty.call(opts, key)) {
|
||||
// Only allow prefs defined in defaultPrefs
|
||||
if ({}.hasOwnProperty.call(defaultPrefs, key)) {
|
||||
if (cfgCfg.overwrite === false && (
|
||||
if (!{}.hasOwnProperty.call(opts, key)) {
|
||||
return;
|
||||
}
|
||||
// Only allow prefs defined in defaultPrefs
|
||||
if ({}.hasOwnProperty.call(defaultPrefs, key)) {
|
||||
if (cfgCfg.overwrite === false && (
|
||||
curConfig.preventAllURLConfig ||
|
||||
{}.hasOwnProperty.call(curPrefs, key)
|
||||
)) {
|
||||
return;
|
||||
}
|
||||
if (cfgCfg.allowInitialUserOverride === true) {
|
||||
defaultPrefs[key] = val;
|
||||
} else {
|
||||
$.pref(key, val);
|
||||
}
|
||||
} else if (['extensions', 'stylesheets', 'allowedOrigins'].includes(key)) {
|
||||
if (cfgCfg.overwrite === false &&
|
||||
(
|
||||
curConfig.preventAllURLConfig ||
|
||||
{}.hasOwnProperty.call(curPrefs, key)
|
||||
)) {
|
||||
['allowedOrigins', 'stylesheets'].includes(key) ||
|
||||
(key === 'extensions' && curConfig.lockExtensions)
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
curConfig[key] = curConfig[key].concat(val); // We will handle any dupes later
|
||||
// Only allow other curConfig if defined in defaultConfig
|
||||
} else if ({}.hasOwnProperty.call(defaultConfig, key)) {
|
||||
if (cfgCfg.overwrite === false && (
|
||||
curConfig.preventAllURLConfig ||
|
||||
{}.hasOwnProperty.call(curConfig, key)
|
||||
)) {
|
||||
return;
|
||||
}
|
||||
// Potentially overwriting of previously set config
|
||||
if ({}.hasOwnProperty.call(curConfig, key)) {
|
||||
if (cfgCfg.overwrite === false) {
|
||||
return;
|
||||
}
|
||||
if (cfgCfg.allowInitialUserOverride === true) {
|
||||
defaultPrefs[key] = val;
|
||||
} else {
|
||||
$.pref(key, val);
|
||||
}
|
||||
} else if (['extensions', 'stylesheets', 'allowedOrigins'].includes(key)) {
|
||||
if (cfgCfg.overwrite === false &&
|
||||
(
|
||||
curConfig.preventAllURLConfig ||
|
||||
['allowedOrigins', 'stylesheets'].includes(key) ||
|
||||
(key === 'extensions' && curConfig.lockExtensions)
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
curConfig[key] = curConfig[key].concat(val); // We will handle any dupes later
|
||||
// Only allow other curConfig if defined in defaultConfig
|
||||
} else if ({}.hasOwnProperty.call(defaultConfig, key)) {
|
||||
if (cfgCfg.overwrite === false && (
|
||||
curConfig.preventAllURLConfig ||
|
||||
{}.hasOwnProperty.call(curConfig, key)
|
||||
)) {
|
||||
return;
|
||||
}
|
||||
// Potentially overwriting of previously set config
|
||||
if ({}.hasOwnProperty.call(curConfig, key)) {
|
||||
if (cfgCfg.overwrite === false) {
|
||||
return;
|
||||
}
|
||||
extendOrAdd(curConfig, key, val);
|
||||
} else if (cfgCfg.allowInitialUserOverride === true) {
|
||||
extendOrAdd(defaultConfig, key, val);
|
||||
} else if (defaultConfig[key] && typeof defaultConfig[key] === 'object') {
|
||||
curConfig[key] = Array.isArray(defaultConfig[key]) ? [] : {};
|
||||
$.extend(true, curConfig[key], val); // Merge properties recursively, e.g., on initFill, initStroke objects
|
||||
} else {
|
||||
curConfig[key] = val;
|
||||
}
|
||||
extendOrAdd(curConfig, key, val);
|
||||
} else if (cfgCfg.allowInitialUserOverride === true) {
|
||||
extendOrAdd(defaultConfig, key, val);
|
||||
} else if (defaultConfig[key] && typeof defaultConfig[key] === 'object') {
|
||||
curConfig[key] = Array.isArray(defaultConfig[key]) ? [] : {};
|
||||
$.extend(true, curConfig[key], val); // Merge properties recursively, e.g., on initFill, initStroke objects
|
||||
} else {
|
||||
curConfig[key] = val;
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -742,7 +746,6 @@ editor.init = function () {
|
||||
});
|
||||
|
||||
editor.setConfig(urldata, {overwrite: false}); // Note: source and url (as with storagePrompt later) are not set on config but are used below
|
||||
|
||||
setupCurConfig();
|
||||
|
||||
if (!curConfig.preventURLContentLoading) {
|
||||
|
||||
@@ -28790,6 +28790,7 @@
|
||||
* @property {boolean} [noStorageOnLoad=false] Some interaction with `ext-storage.js`; prevent even the loading of previously saved local storage.
|
||||
* @property {boolean} [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 (and may be required by law in some regions)
|
||||
* @property {boolean} [emptyStorageOnDecline=false] Used by `ext-storage.js`; empty any prior storage if the user declines to store
|
||||
* @property {boolean} [avoidClientSide=false] Used by `ext-server_opensave.js`; set to `true` if you wish to always save to server and not only as fallback when client support is lacking
|
||||
* @property {string[]} [extensions=module:SVGEditor~defaultExtensions] Extensions to load on startup. Use an array in `setConfig` and comma separated file names in the URL. Extension names must begin with "ext-". Note that as of version 2.7, paths containing "/", "\", or ":", are disallowed for security reasons. Although previous versions of this list would entirely override the default list, as of version 2.7, the defaults will always be added to this explicit list unless the configuration `noDefaultExtensions` is included.
|
||||
* @property {module:SVGEditor.Stylesheet[]} [stylesheets=["@default"]] An array of required stylesheets to load in parallel; include the value `"@default"` within this array to ensure all default stylesheets are loaded.
|
||||
* @property {string[]} [allowedOrigins=[]] Used by `ext-xdomain-messaging.js` to indicate which origins are permitted for cross-domain messaging (e.g., between the embedded editor and main editor code). Besides explicit domains, one might add '*' to allow all domains (not recommended for privacy/data integrity of your user's content!), `window.location.origin` for allowing the same origin (should be safe if you trust all apps on your domain), 'null' to allow `file:///` URL usage
|
||||
@@ -28896,8 +28897,10 @@
|
||||
// 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: false // Used by ext-storage.js; empty any prior storage if the user declines to store
|
||||
|
||||
emptyStorageOnDecline: false,
|
||||
// Used by ext-storage.js; empty any prior storage if the user declines to store
|
||||
// EXTENSION (CLIENT VS. SERVER SAVING)
|
||||
avoidClientSide: false
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -29206,45 +29209,47 @@
|
||||
}
|
||||
|
||||
$$b.each(opts, function (key, val) {
|
||||
if ({}.hasOwnProperty.call(opts, key)) {
|
||||
// Only allow prefs defined in defaultPrefs
|
||||
if ({}.hasOwnProperty.call(defaultPrefs, key)) {
|
||||
if (cfgCfg.overwrite === false && (curConfig.preventAllURLConfig || {}.hasOwnProperty.call(curPrefs, key))) {
|
||||
if (!{}.hasOwnProperty.call(opts, key)) {
|
||||
return;
|
||||
} // Only allow prefs defined in defaultPrefs
|
||||
|
||||
|
||||
if ({}.hasOwnProperty.call(defaultPrefs, key)) {
|
||||
if (cfgCfg.overwrite === false && (curConfig.preventAllURLConfig || {}.hasOwnProperty.call(curPrefs, key))) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cfgCfg.allowInitialUserOverride === true) {
|
||||
defaultPrefs[key] = val;
|
||||
} else {
|
||||
$$b.pref(key, val);
|
||||
}
|
||||
} else if (['extensions', 'stylesheets', 'allowedOrigins'].includes(key)) {
|
||||
if (cfgCfg.overwrite === false && (curConfig.preventAllURLConfig || ['allowedOrigins', 'stylesheets'].includes(key) || key === 'extensions' && curConfig.lockExtensions)) {
|
||||
return;
|
||||
}
|
||||
|
||||
curConfig[key] = curConfig[key].concat(val); // We will handle any dupes later
|
||||
// Only allow other curConfig if defined in defaultConfig
|
||||
} else if ({}.hasOwnProperty.call(defaultConfig, key)) {
|
||||
if (cfgCfg.overwrite === false && (curConfig.preventAllURLConfig || {}.hasOwnProperty.call(curConfig, key))) {
|
||||
return;
|
||||
} // Potentially overwriting of previously set config
|
||||
|
||||
|
||||
if ({}.hasOwnProperty.call(curConfig, key)) {
|
||||
if (cfgCfg.overwrite === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cfgCfg.allowInitialUserOverride === true) {
|
||||
defaultPrefs[key] = val;
|
||||
} else {
|
||||
$$b.pref(key, val);
|
||||
}
|
||||
} else if (['extensions', 'stylesheets', 'allowedOrigins'].includes(key)) {
|
||||
if (cfgCfg.overwrite === false && (curConfig.preventAllURLConfig || ['allowedOrigins', 'stylesheets'].includes(key) || key === 'extensions' && curConfig.lockExtensions)) {
|
||||
return;
|
||||
}
|
||||
|
||||
curConfig[key] = curConfig[key].concat(val); // We will handle any dupes later
|
||||
// Only allow other curConfig if defined in defaultConfig
|
||||
} else if ({}.hasOwnProperty.call(defaultConfig, key)) {
|
||||
if (cfgCfg.overwrite === false && (curConfig.preventAllURLConfig || {}.hasOwnProperty.call(curConfig, key))) {
|
||||
return;
|
||||
} // Potentially overwriting of previously set config
|
||||
|
||||
|
||||
if ({}.hasOwnProperty.call(curConfig, key)) {
|
||||
if (cfgCfg.overwrite === false) {
|
||||
return;
|
||||
}
|
||||
|
||||
extendOrAdd(curConfig, key, val);
|
||||
} else if (cfgCfg.allowInitialUserOverride === true) {
|
||||
extendOrAdd(defaultConfig, key, val);
|
||||
} else if (defaultConfig[key] && _typeof(defaultConfig[key]) === 'object') {
|
||||
curConfig[key] = Array.isArray(defaultConfig[key]) ? [] : {};
|
||||
$$b.extend(true, curConfig[key], val); // Merge properties recursively, e.g., on initFill, initStroke objects
|
||||
} else {
|
||||
curConfig[key] = val;
|
||||
}
|
||||
extendOrAdd(curConfig, key, val);
|
||||
} else if (cfgCfg.allowInitialUserOverride === true) {
|
||||
extendOrAdd(defaultConfig, key, val);
|
||||
} else if (defaultConfig[key] && _typeof(defaultConfig[key]) === 'object') {
|
||||
curConfig[key] = Array.isArray(defaultConfig[key]) ? [] : {};
|
||||
$$b.extend(true, curConfig[key], val); // Merge properties recursively, e.g., on initFill, initStroke objects
|
||||
} else {
|
||||
curConfig[key] = val;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user