- Fix: Background URL was not settable back to nothing; fixes #376

master
Brett Zamir 2020-01-04 22:32:52 +08:00
parent 0029a932b2
commit e356b95a03
13 changed files with 148 additions and 134 deletions

View File

@ -65,12 +65,13 @@ var svgEditorExtension_imagelib = (function () {
var _init = _asyncToGenerator( var _init = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee2(_ref) { regeneratorRuntime.mark(function _callee2(_ref) {
var $, decode64, importLocale, dropXMLInternalSubset, imagelibStrings, modularVersion, svgEditor, uiStrings, svgCanvas, extIconsPath, allowedImageLibOrigins, closeBrowser, importImage, pending, mode, multiArr, transferStopped, preview, submit, toggleMulti, showBrowser, buttons; var $, decode64, importLocale, dropXMLInternalSubset, imagelibStrings, modularVersion, svgEditor, uiStrings, svgCanvas, extIconsPath, allowedImageLibOrigins, closeBrowser, importImage, pending, mode, multiArr, transferStopped, preview, submit, onMessage, _onMessage, toggleMulti, showBrowser, buttons;
return regeneratorRuntime.wrap(function _callee2$(_context2) { return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) { while (1) {
switch (_context2.prev = _context2.next) { switch (_context2.prev = _context2.next) {
case 0: case 0:
showBrowser = function _ref10() { showBrowser = function _ref11() {
var browser = $('#imgbrowse'); var browser = $('#imgbrowse');
if (!browser.length) { if (!browser.length) {
@ -126,10 +127,10 @@ var svgEditorExtension_imagelib = (function () {
}); });
cancel.prepend($.getSvgIcon('cancel', true)); cancel.prepend($.getSvgIcon('cancel', true));
back.prepend($.getSvgIcon('tool_imagelib', true)); back.prepend($.getSvgIcon('tool_imagelib', true));
imagelibStrings.imgLibs.forEach(function (_ref6) { imagelibStrings.imgLibs.forEach(function (_ref5) {
var name = _ref6.name, var name = _ref5.name,
url = _ref6.url, url = _ref5.url,
description = _ref6.description; description = _ref5.description;
$('<li>').appendTo(libOpts).text(name).on('click touchend', function () { $('<li>').appendTo(libOpts).text(name).on('click touchend', function () {
frame.attr('src', url).show(); frame.attr('src', url).show();
header.text(name); header.text(name);
@ -142,7 +143,7 @@ var svgEditorExtension_imagelib = (function () {
} }
}; };
toggleMulti = function _ref9(show) { toggleMulti = function _ref10(show) {
$('#lib_framewrap, #imglib_opts').css({ $('#lib_framewrap, #imglib_opts').css({
right: show ? 200 : 10 right: show ? 200 : 10
}); });
@ -184,71 +185,8 @@ var svgEditorExtension_imagelib = (function () {
submit.toggle(show); submit.toggle(show);
}; };
importImage = function _ref8(url) { _onMessage = function _ref9() {
var newImage = svgCanvas.addSVGElementFromJson({ _onMessage = _asyncToGenerator(
element: 'image',
attr: {
x: 0,
y: 0,
width: 0,
height: 0,
id: svgCanvas.getNextId(),
style: 'pointer-events:inherit'
}
});
svgCanvas.clearSelection();
svgCanvas.addToSelection([newImage]);
svgCanvas.setImageURL(url);
};
closeBrowser = function _ref7() {
$('#imgbrowse_holder').hide();
};
$ = _ref.$, decode64 = _ref.decode64, importLocale = _ref.importLocale, dropXMLInternalSubset = _ref.dropXMLInternalSubset;
_context2.next = 7;
return importLocale();
case 7:
imagelibStrings = _context2.sent;
modularVersion = !('svgEditor' in window) || !window.svgEditor || window.svgEditor.modules !== false;
svgEditor = this;
uiStrings = svgEditor.uiStrings, svgCanvas = svgEditor.canvas, extIconsPath = svgEditor.curConfig.extIconsPath;
imagelibStrings.imgLibs = imagelibStrings.imgLibs.map(function (_ref2) {
var name = _ref2.name,
url = _ref2.url,
description = _ref2.description;
// Todo: Adopt some standard formatting library like `fluent.js` instead
url = url.replace(/\{path\}/g, extIconsPath).replace(/\{modularVersion\}/g, modularVersion ? imagelibStrings.moduleEnding || '-es' : '');
return {
name: name,
url: url,
description: description
};
});
allowedImageLibOrigins = imagelibStrings.imgLibs.map(function (_ref3) {
var url = _ref3.url;
try {
return new URL(url).origin;
} catch (err) {
return location.origin;
}
});
/**
*
* @returns {void}
*/
pending = {};
mode = 's';
multiArr = [];
transferStopped = false;
// Receive `postMessage` data
window.addEventListener('message',
/*#__PURE__*/
function () {
var _ref5 = _asyncToGenerator(
/*#__PURE__*/ /*#__PURE__*/
regeneratorRuntime.mark(function _callee(_ref4) { regeneratorRuntime.mark(function _callee(_ref4) {
var origin, response, id, type, hasName, hasHref, char1, secondpos, entry, curMeta, svgStr, imgStr, name, message, pre, src, title, xml, ok; var origin, response, id, type, hasName, hasHref, char1, secondpos, entry, curMeta, svgStr, imgStr, name, message, pre, src, title, xml, ok;
@ -461,7 +399,7 @@ var svgEditorExtension_imagelib = (function () {
preview.children().each(function () { preview.children().each(function () {
if ($(this).data('id') === id) { if ($(this).data('id') === id) {
if (curMeta.preview_url) { if (curMeta.preview_url) {
$(this).html($('<span>').append($('<img>').attr('src', curMeta.preview_url), document.createTextNode(title))); $(this).html($('<span>').append($('<img>').attr('src', curMeta.preview_url), title));
} else { } else {
$(this).text(title); $(this).text(title);
} }
@ -476,10 +414,7 @@ var svgEditorExtension_imagelib = (function () {
} else { } else {
if (curMeta && curMeta.preview_url) { if (curMeta && curMeta.preview_url) {
title = curMeta.name || ''; title = curMeta.name || '';
} entry = $('<span>').append($('<img>').attr('src', curMeta.preview_url), title);
if (curMeta && curMeta.preview_url) {
entry = $('<span>').append($('<img>').attr('src', curMeta.preview_url), document.createTextNode(title));
} else { } else {
entry = $('<img>').attr('src', response); entry = $('<img>').attr('src', response);
} }
@ -535,11 +470,75 @@ var svgEditorExtension_imagelib = (function () {
} }
}, _callee, null, [[3, 20]]); }, _callee, null, [[3, 20]]);
})); }));
return _onMessage.apply(this, arguments);
};
return function (_x2) { onMessage = function _ref8(_x2) {
return _ref5.apply(this, arguments); return _onMessage.apply(this, arguments);
};
importImage = function _ref7(url) {
var newImage = svgCanvas.addSVGElementFromJson({
element: 'image',
attr: {
x: 0,
y: 0,
width: 0,
height: 0,
id: svgCanvas.getNextId(),
style: 'pointer-events:inherit'
}
});
svgCanvas.clearSelection();
svgCanvas.addToSelection([newImage]);
svgCanvas.setImageURL(url);
};
closeBrowser = function _ref6() {
$('#imgbrowse_holder').hide();
};
$ = _ref.$, decode64 = _ref.decode64, importLocale = _ref.importLocale, dropXMLInternalSubset = _ref.dropXMLInternalSubset;
_context2.next = 9;
return importLocale();
case 9:
imagelibStrings = _context2.sent;
modularVersion = !('svgEditor' in window) || !window.svgEditor || window.svgEditor.modules !== false;
svgEditor = this;
uiStrings = svgEditor.uiStrings, svgCanvas = svgEditor.canvas, extIconsPath = svgEditor.curConfig.extIconsPath;
imagelibStrings.imgLibs = imagelibStrings.imgLibs.map(function (_ref2) {
var name = _ref2.name,
url = _ref2.url,
description = _ref2.description;
// Todo: Adopt some standard formatting library like `fluent.js` instead
url = url.replace(/\{path\}/g, extIconsPath).replace(/\{modularVersion\}/g, modularVersion ? imagelibStrings.moduleEnding || '-es' : '');
return {
name: name,
url: url,
description: description
}; };
}(), true); });
allowedImageLibOrigins = imagelibStrings.imgLibs.map(function (_ref3) {
var url = _ref3.url;
try {
return new URL(url).origin;
} catch (err) {
return location.origin;
}
});
/**
*
* @returns {void}
*/
pending = {};
mode = 's';
multiArr = [];
transferStopped = false;
// Receive `postMessage` data
window.addEventListener('message', onMessage, true);
/** /**
* @param {boolean} show * @param {boolean} show
* @returns {void} * @returns {void}
@ -565,7 +564,7 @@ var svgEditorExtension_imagelib = (function () {
} }
}); });
case 20: case 22:
case "end": case "end":
return _context2.stop(); return _context2.stop();
} }

21
dist/index-es.js vendored
View File

@ -7974,13 +7974,13 @@ var init$2 = function init(editorContext) {
}; };
/** /**
* Used to prevent the [Billion laughs attack]{@link https://en.wikipedia.org/wiki/Billion_laughs_attack}. * Used to prevent the [Billion laughs attack]{@link https://en.wikipedia.org/wiki/Billion_laughs_attack}.
* @function module:utilities.dropXMLInteralSubset * @function module:utilities.dropXMLInternalSubset
* @param {string} str String to be processed * @param {string} str String to be processed
* @returns {string} The string with entity declarations in the internal subset removed * @returns {string} The string with entity declarations in the internal subset removed
* @todo This might be needed in other places `parseFromString` is used even without LGTM flagging * @todo This might be needed in other places `parseFromString` is used even without LGTM flagging
*/ */
var dropXMLInteralSubset = function dropXMLInteralSubset(str) { var dropXMLInternalSubset = function dropXMLInternalSubset(str) {
return str.replace(/(<!DOCTYPE\s+\w*\s*\[).*(\?]>)/, '$1$2'); // return str.replace(/(?<doctypeOpen><!DOCTYPE\s+\w*\s*\[).*(?<doctypeClose>\?\]>)/, '$<doctypeOpen>$<doctypeClose>'); return str.replace(/(<!DOCTYPE\s+\w*\s*\[).*(\?]>)/, '$1$2'); // return str.replace(/(?<doctypeOpen><!DOCTYPE\s+\w*\s*\[).*(?<doctypeClose>\?\]>)/, '$<doctypeOpen>$<doctypeClose>');
}; };
/** /**
@ -21731,7 +21731,7 @@ function SvgCanvas(container, config) {
* @property {module:history.HistoryCommand} BatchCommand * @property {module:history.HistoryCommand} BatchCommand
* @property {module:history.HistoryCommand} ChangeElementCommand * @property {module:history.HistoryCommand} ChangeElementCommand
* @property {module:utilities.decode64} decode64 * @property {module:utilities.decode64} decode64
* @property {module:utilities.dropXMLInteralSubset} dropXMLInteralSubset * @property {module:utilities.dropXMLInternalSubset} dropXMLInternalSubset
* @property {module:utilities.encode64} encode64 * @property {module:utilities.encode64} encode64
* @property {module:svgcanvas~ffClone} ffClone * @property {module:svgcanvas~ffClone} ffClone
* @property {module:svgcanvas~findDuplicateGradient} findDuplicateGradient * @property {module:svgcanvas~findDuplicateGradient} findDuplicateGradient
@ -21773,7 +21773,7 @@ function SvgCanvas(container, config) {
BatchCommand: BatchCommand$1, BatchCommand: BatchCommand$1,
ChangeElementCommand: ChangeElementCommand$1, ChangeElementCommand: ChangeElementCommand$1,
decode64: decode64, decode64: decode64,
dropXMLInteralSubset: dropXMLInteralSubset, dropXMLInternalSubset: dropXMLInternalSubset,
encode64: encode64, encode64: encode64,
ffClone: ffClone, ffClone: ffClone,
findDefs: findDefs, findDefs: findDefs,
@ -29268,8 +29268,11 @@ function getImportLocale(_ref) {
/** /**
* Store and retrieve preferences. * Store and retrieve preferences.
* @param {string} key The preference name to be retrieved or set * @param {string} key The preference name to be retrieved or set
* @param {string} [val] The value. If the value supplied is missing or falsey, no change to the preference will be made. * @param {string} [val] The value. If the value supplied is missing or falsey, no change to the preference will
* @returns {string|void} If val is missing or falsey, the value of the previously stored preference will be returned. * be made unless `mayBeEmpty` is set.
* @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 Can we change setting on the jQuery namespace (onto editor) to avoid conflicts?
* @todo Review whether any remaining existing direct references to * @todo Review whether any remaining existing direct references to
* getting `curPrefs` can be changed to use `$.pref()` getting to ensure * getting `curPrefs` can be changed to use `$.pref()` getting to ensure
@ -29279,8 +29282,8 @@ function getImportLocale(_ref) {
*/ */
$$b.pref = function (key, val) { $$b.pref = function (key, val, mayBeEmpty) {
if (val) { if (mayBeEmpty || val) {
curPrefs[key] = val; curPrefs[key] = val;
/** /**
* @name curPrefs * @name curPrefs
@ -30920,7 +30923,7 @@ editor.init = function () {
function setBackground(color, url) { function setBackground(color, url) {
// if (color == $.pref('bkgd_color') && url == $.pref('bkgd_url')) { return; } // if (color == $.pref('bkgd_color') && url == $.pref('bkgd_url')) { return; }
$$b.pref('bkgd_color', color); $$b.pref('bkgd_color', color);
$$b.pref('bkgd_url', url); // This should be done in svgcanvas.js for the borderRect fill $$b.pref('bkgd_url', url, true); // This should be done in svgcanvas.js for the borderRect fill
svgCanvas.setBackground(color, url); svgCanvas.setBackground(color, url);
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

21
dist/index-umd.js vendored
View File

@ -7980,13 +7980,13 @@
}; };
/** /**
* Used to prevent the [Billion laughs attack]{@link https://en.wikipedia.org/wiki/Billion_laughs_attack}. * Used to prevent the [Billion laughs attack]{@link https://en.wikipedia.org/wiki/Billion_laughs_attack}.
* @function module:utilities.dropXMLInteralSubset * @function module:utilities.dropXMLInternalSubset
* @param {string} str String to be processed * @param {string} str String to be processed
* @returns {string} The string with entity declarations in the internal subset removed * @returns {string} The string with entity declarations in the internal subset removed
* @todo This might be needed in other places `parseFromString` is used even without LGTM flagging * @todo This might be needed in other places `parseFromString` is used even without LGTM flagging
*/ */
var dropXMLInteralSubset = function dropXMLInteralSubset(str) { var dropXMLInternalSubset = function dropXMLInternalSubset(str) {
return str.replace(/(<!DOCTYPE\s+\w*\s*\[).*(\?]>)/, '$1$2'); // return str.replace(/(?<doctypeOpen><!DOCTYPE\s+\w*\s*\[).*(?<doctypeClose>\?\]>)/, '$<doctypeOpen>$<doctypeClose>'); return str.replace(/(<!DOCTYPE\s+\w*\s*\[).*(\?]>)/, '$1$2'); // return str.replace(/(?<doctypeOpen><!DOCTYPE\s+\w*\s*\[).*(?<doctypeClose>\?\]>)/, '$<doctypeOpen>$<doctypeClose>');
}; };
/** /**
@ -21737,7 +21737,7 @@
* @property {module:history.HistoryCommand} BatchCommand * @property {module:history.HistoryCommand} BatchCommand
* @property {module:history.HistoryCommand} ChangeElementCommand * @property {module:history.HistoryCommand} ChangeElementCommand
* @property {module:utilities.decode64} decode64 * @property {module:utilities.decode64} decode64
* @property {module:utilities.dropXMLInteralSubset} dropXMLInteralSubset * @property {module:utilities.dropXMLInternalSubset} dropXMLInternalSubset
* @property {module:utilities.encode64} encode64 * @property {module:utilities.encode64} encode64
* @property {module:svgcanvas~ffClone} ffClone * @property {module:svgcanvas~ffClone} ffClone
* @property {module:svgcanvas~findDuplicateGradient} findDuplicateGradient * @property {module:svgcanvas~findDuplicateGradient} findDuplicateGradient
@ -21779,7 +21779,7 @@
BatchCommand: BatchCommand$1, BatchCommand: BatchCommand$1,
ChangeElementCommand: ChangeElementCommand$1, ChangeElementCommand: ChangeElementCommand$1,
decode64: decode64, decode64: decode64,
dropXMLInteralSubset: dropXMLInteralSubset, dropXMLInternalSubset: dropXMLInternalSubset,
encode64: encode64, encode64: encode64,
ffClone: ffClone, ffClone: ffClone,
findDefs: findDefs, findDefs: findDefs,
@ -29274,8 +29274,11 @@
/** /**
* Store and retrieve preferences. * Store and retrieve preferences.
* @param {string} key The preference name to be retrieved or set * @param {string} key The preference name to be retrieved or set
* @param {string} [val] The value. If the value supplied is missing or falsey, no change to the preference will be made. * @param {string} [val] The value. If the value supplied is missing or falsey, no change to the preference will
* @returns {string|void} If val is missing or falsey, the value of the previously stored preference will be returned. * be made unless `mayBeEmpty` is set.
* @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 Can we change setting on the jQuery namespace (onto editor) to avoid conflicts?
* @todo Review whether any remaining existing direct references to * @todo Review whether any remaining existing direct references to
* getting `curPrefs` can be changed to use `$.pref()` getting to ensure * getting `curPrefs` can be changed to use `$.pref()` getting to ensure
@ -29285,8 +29288,8 @@
*/ */
$$b.pref = function (key, val) { $$b.pref = function (key, val, mayBeEmpty) {
if (val) { if (mayBeEmpty || val) {
curPrefs[key] = val; curPrefs[key] = val;
/** /**
* @name curPrefs * @name curPrefs
@ -30926,7 +30929,7 @@
function setBackground(color, url) { function setBackground(color, url) {
// if (color == $.pref('bkgd_color') && url == $.pref('bkgd_url')) { return; } // if (color == $.pref('bkgd_color') && url == $.pref('bkgd_url')) { return; }
$$b.pref('bkgd_color', color); $$b.pref('bkgd_color', color);
$$b.pref('bkgd_url', url); // This should be done in svgcanvas.js for the borderRect fill $$b.pref('bkgd_url', url, true); // This should be done in svgcanvas.js for the borderRect fill
svgCanvas.setBackground(color, url); svgCanvas.setBackground(color, url);
} }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -8046,13 +8046,13 @@ var SvgCanvas = (function () {
}; };
/** /**
* Used to prevent the [Billion laughs attack]{@link https://en.wikipedia.org/wiki/Billion_laughs_attack}. * Used to prevent the [Billion laughs attack]{@link https://en.wikipedia.org/wiki/Billion_laughs_attack}.
* @function module:utilities.dropXMLInteralSubset * @function module:utilities.dropXMLInternalSubset
* @param {string} str String to be processed * @param {string} str String to be processed
* @returns {string} The string with entity declarations in the internal subset removed * @returns {string} The string with entity declarations in the internal subset removed
* @todo This might be needed in other places `parseFromString` is used even without LGTM flagging * @todo This might be needed in other places `parseFromString` is used even without LGTM flagging
*/ */
var dropXMLInteralSubset = function dropXMLInteralSubset(str) { var dropXMLInternalSubset = function dropXMLInternalSubset(str) {
return str.replace(/(<!DOCTYPE\s+\w*\s*\[).*(\?]>)/, '$1$2'); // return str.replace(/(?<doctypeOpen><!DOCTYPE\s+\w*\s*\[).*(?<doctypeClose>\?\]>)/, '$<doctypeOpen>$<doctypeClose>'); return str.replace(/(<!DOCTYPE\s+\w*\s*\[).*(\?]>)/, '$1$2'); // return str.replace(/(?<doctypeOpen><!DOCTYPE\s+\w*\s*\[).*(?<doctypeClose>\?\]>)/, '$<doctypeOpen>$<doctypeClose>');
}; };
/** /**
@ -21509,7 +21509,7 @@ var SvgCanvas = (function () {
* @property {module:history.HistoryCommand} BatchCommand * @property {module:history.HistoryCommand} BatchCommand
* @property {module:history.HistoryCommand} ChangeElementCommand * @property {module:history.HistoryCommand} ChangeElementCommand
* @property {module:utilities.decode64} decode64 * @property {module:utilities.decode64} decode64
* @property {module:utilities.dropXMLInteralSubset} dropXMLInteralSubset * @property {module:utilities.dropXMLInternalSubset} dropXMLInternalSubset
* @property {module:utilities.encode64} encode64 * @property {module:utilities.encode64} encode64
* @property {module:svgcanvas~ffClone} ffClone * @property {module:svgcanvas~ffClone} ffClone
* @property {module:svgcanvas~findDuplicateGradient} findDuplicateGradient * @property {module:svgcanvas~findDuplicateGradient} findDuplicateGradient
@ -21551,7 +21551,7 @@ var SvgCanvas = (function () {
BatchCommand: BatchCommand$1, BatchCommand: BatchCommand$1,
ChangeElementCommand: ChangeElementCommand$1, ChangeElementCommand: ChangeElementCommand$1,
decode64: decode64, decode64: decode64,
dropXMLInteralSubset: dropXMLInteralSubset, dropXMLInternalSubset: dropXMLInternalSubset,
encode64: encode64, encode64: encode64,
ffClone: ffClone, ffClone: ffClone,
findDefs: findDefs, findDefs: findDefs,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -387,8 +387,11 @@ function getImportLocale ({defaultLang, defaultName}) {
/** /**
* Store and retrieve preferences. * Store and retrieve preferences.
* @param {string} key The preference name to be retrieved or set * @param {string} key The preference name to be retrieved or set
* @param {string} [val] The value. If the value supplied is missing or falsey, no change to the preference will be made. * @param {string} [val] The value. If the value supplied is missing or falsey, no change to the preference will
* @returns {string|void} If val is missing or falsey, the value of the previously stored preference will be returned. * be made unless `mayBeEmpty` is set.
* @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 Can we change setting on the jQuery namespace (onto editor) to avoid conflicts?
* @todo Review whether any remaining existing direct references to * @todo Review whether any remaining existing direct references to
* getting `curPrefs` can be changed to use `$.pref()` getting to ensure * getting `curPrefs` can be changed to use `$.pref()` getting to ensure
@ -396,8 +399,8 @@ function getImportLocale ({defaultLang, defaultName}) {
* the pref dialog has a button to auto-calculate background, but otherwise uses `$.pref()` to be able to get default prefs * the pref dialog has a button to auto-calculate background, but otherwise uses `$.pref()` to be able to get default prefs
* or overridable settings * or overridable settings
*/ */
$.pref = function (key, val) { $.pref = function (key, val, mayBeEmpty) {
if (val) { if (mayBeEmpty || val) {
curPrefs[key] = val; curPrefs[key] = val;
/** /**
* @name curPrefs * @name curPrefs
@ -1893,7 +1896,7 @@ editor.init = function () {
function setBackground (color, url) { function setBackground (color, url) {
// if (color == $.pref('bkgd_color') && url == $.pref('bkgd_url')) { return; } // if (color == $.pref('bkgd_color') && url == $.pref('bkgd_url')) { return; }
$.pref('bkgd_color', color); $.pref('bkgd_color', color);
$.pref('bkgd_url', url); $.pref('bkgd_url', url, true);
// This should be done in svgcanvas.js for the borderRect fill // This should be done in svgcanvas.js for the borderRect fill
svgCanvas.setBackground(color, url); svgCanvas.setBackground(color, url);

View File

@ -7977,13 +7977,13 @@
}; };
/** /**
* Used to prevent the [Billion laughs attack]{@link https://en.wikipedia.org/wiki/Billion_laughs_attack}. * Used to prevent the [Billion laughs attack]{@link https://en.wikipedia.org/wiki/Billion_laughs_attack}.
* @function module:utilities.dropXMLInteralSubset * @function module:utilities.dropXMLInternalSubset
* @param {string} str String to be processed * @param {string} str String to be processed
* @returns {string} The string with entity declarations in the internal subset removed * @returns {string} The string with entity declarations in the internal subset removed
* @todo This might be needed in other places `parseFromString` is used even without LGTM flagging * @todo This might be needed in other places `parseFromString` is used even without LGTM flagging
*/ */
var dropXMLInteralSubset = function dropXMLInteralSubset(str) { var dropXMLInternalSubset = function dropXMLInternalSubset(str) {
return str.replace(/(<!DOCTYPE\s+\w*\s*\[).*(\?]>)/, '$1$2'); // return str.replace(/(?<doctypeOpen><!DOCTYPE\s+\w*\s*\[).*(?<doctypeClose>\?\]>)/, '$<doctypeOpen>$<doctypeClose>'); return str.replace(/(<!DOCTYPE\s+\w*\s*\[).*(\?]>)/, '$1$2'); // return str.replace(/(?<doctypeOpen><!DOCTYPE\s+\w*\s*\[).*(?<doctypeClose>\?\]>)/, '$<doctypeOpen>$<doctypeClose>');
}; };
/** /**
@ -21734,7 +21734,7 @@
* @property {module:history.HistoryCommand} BatchCommand * @property {module:history.HistoryCommand} BatchCommand
* @property {module:history.HistoryCommand} ChangeElementCommand * @property {module:history.HistoryCommand} ChangeElementCommand
* @property {module:utilities.decode64} decode64 * @property {module:utilities.decode64} decode64
* @property {module:utilities.dropXMLInteralSubset} dropXMLInteralSubset * @property {module:utilities.dropXMLInternalSubset} dropXMLInternalSubset
* @property {module:utilities.encode64} encode64 * @property {module:utilities.encode64} encode64
* @property {module:svgcanvas~ffClone} ffClone * @property {module:svgcanvas~ffClone} ffClone
* @property {module:svgcanvas~findDuplicateGradient} findDuplicateGradient * @property {module:svgcanvas~findDuplicateGradient} findDuplicateGradient
@ -21776,7 +21776,7 @@
BatchCommand: BatchCommand$1, BatchCommand: BatchCommand$1,
ChangeElementCommand: ChangeElementCommand$1, ChangeElementCommand: ChangeElementCommand$1,
decode64: decode64, decode64: decode64,
dropXMLInteralSubset: dropXMLInteralSubset, dropXMLInternalSubset: dropXMLInternalSubset,
encode64: encode64, encode64: encode64,
ffClone: ffClone, ffClone: ffClone,
findDefs: findDefs, findDefs: findDefs,
@ -29271,8 +29271,11 @@
/** /**
* Store and retrieve preferences. * Store and retrieve preferences.
* @param {string} key The preference name to be retrieved or set * @param {string} key The preference name to be retrieved or set
* @param {string} [val] The value. If the value supplied is missing or falsey, no change to the preference will be made. * @param {string} [val] The value. If the value supplied is missing or falsey, no change to the preference will
* @returns {string|void} If val is missing or falsey, the value of the previously stored preference will be returned. * be made unless `mayBeEmpty` is set.
* @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 Can we change setting on the jQuery namespace (onto editor) to avoid conflicts?
* @todo Review whether any remaining existing direct references to * @todo Review whether any remaining existing direct references to
* getting `curPrefs` can be changed to use `$.pref()` getting to ensure * getting `curPrefs` can be changed to use `$.pref()` getting to ensure
@ -29282,8 +29285,8 @@
*/ */
$$b.pref = function (key, val) { $$b.pref = function (key, val, mayBeEmpty) {
if (val) { if (mayBeEmpty || val) {
curPrefs[key] = val; curPrefs[key] = val;
/** /**
* @name curPrefs * @name curPrefs
@ -30923,7 +30926,7 @@
function setBackground(color, url) { function setBackground(color, url) {
// if (color == $.pref('bkgd_color') && url == $.pref('bkgd_url')) { return; } // if (color == $.pref('bkgd_color') && url == $.pref('bkgd_url')) { return; }
$$b.pref('bkgd_color', color); $$b.pref('bkgd_color', color);
$$b.pref('bkgd_url', url); // This should be done in svgcanvas.js for the borderRect fill $$b.pref('bkgd_url', url, true); // This should be done in svgcanvas.js for the borderRect fill
svgCanvas.setBackground(color, url); svgCanvas.setBackground(color, url);
} }

View File

@ -7977,13 +7977,13 @@
}; };
/** /**
* Used to prevent the [Billion laughs attack]{@link https://en.wikipedia.org/wiki/Billion_laughs_attack}. * Used to prevent the [Billion laughs attack]{@link https://en.wikipedia.org/wiki/Billion_laughs_attack}.
* @function module:utilities.dropXMLInteralSubset * @function module:utilities.dropXMLInternalSubset
* @param {string} str String to be processed * @param {string} str String to be processed
* @returns {string} The string with entity declarations in the internal subset removed * @returns {string} The string with entity declarations in the internal subset removed
* @todo This might be needed in other places `parseFromString` is used even without LGTM flagging * @todo This might be needed in other places `parseFromString` is used even without LGTM flagging
*/ */
var dropXMLInteralSubset = function dropXMLInteralSubset(str) { var dropXMLInternalSubset = function dropXMLInternalSubset(str) {
return str.replace(/(<!DOCTYPE\s+\w*\s*\[).*(\?]>)/, '$1$2'); // return str.replace(/(?<doctypeOpen><!DOCTYPE\s+\w*\s*\[).*(?<doctypeClose>\?\]>)/, '$<doctypeOpen>$<doctypeClose>'); return str.replace(/(<!DOCTYPE\s+\w*\s*\[).*(\?]>)/, '$1$2'); // return str.replace(/(?<doctypeOpen><!DOCTYPE\s+\w*\s*\[).*(?<doctypeClose>\?\]>)/, '$<doctypeOpen>$<doctypeClose>');
}; };
/** /**
@ -21734,7 +21734,7 @@
* @property {module:history.HistoryCommand} BatchCommand * @property {module:history.HistoryCommand} BatchCommand
* @property {module:history.HistoryCommand} ChangeElementCommand * @property {module:history.HistoryCommand} ChangeElementCommand
* @property {module:utilities.decode64} decode64 * @property {module:utilities.decode64} decode64
* @property {module:utilities.dropXMLInteralSubset} dropXMLInteralSubset * @property {module:utilities.dropXMLInternalSubset} dropXMLInternalSubset
* @property {module:utilities.encode64} encode64 * @property {module:utilities.encode64} encode64
* @property {module:svgcanvas~ffClone} ffClone * @property {module:svgcanvas~ffClone} ffClone
* @property {module:svgcanvas~findDuplicateGradient} findDuplicateGradient * @property {module:svgcanvas~findDuplicateGradient} findDuplicateGradient
@ -21776,7 +21776,7 @@
BatchCommand: BatchCommand$1, BatchCommand: BatchCommand$1,
ChangeElementCommand: ChangeElementCommand$1, ChangeElementCommand: ChangeElementCommand$1,
decode64: decode64, decode64: decode64,
dropXMLInteralSubset: dropXMLInteralSubset, dropXMLInternalSubset: dropXMLInternalSubset,
encode64: encode64, encode64: encode64,
ffClone: ffClone, ffClone: ffClone,
findDefs: findDefs, findDefs: findDefs,
@ -29271,8 +29271,11 @@
/** /**
* Store and retrieve preferences. * Store and retrieve preferences.
* @param {string} key The preference name to be retrieved or set * @param {string} key The preference name to be retrieved or set
* @param {string} [val] The value. If the value supplied is missing or falsey, no change to the preference will be made. * @param {string} [val] The value. If the value supplied is missing or falsey, no change to the preference will
* @returns {string|void} If val is missing or falsey, the value of the previously stored preference will be returned. * be made unless `mayBeEmpty` is set.
* @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 Can we change setting on the jQuery namespace (onto editor) to avoid conflicts?
* @todo Review whether any remaining existing direct references to * @todo Review whether any remaining existing direct references to
* getting `curPrefs` can be changed to use `$.pref()` getting to ensure * getting `curPrefs` can be changed to use `$.pref()` getting to ensure
@ -29282,8 +29285,8 @@
*/ */
$$b.pref = function (key, val) { $$b.pref = function (key, val, mayBeEmpty) {
if (val) { if (mayBeEmpty || val) {
curPrefs[key] = val; curPrefs[key] = val;
/** /**
* @name curPrefs * @name curPrefs
@ -30923,7 +30926,7 @@
function setBackground(color, url) { function setBackground(color, url) {
// if (color == $.pref('bkgd_color') && url == $.pref('bkgd_url')) { return; } // if (color == $.pref('bkgd_color') && url == $.pref('bkgd_url')) { return; }
$$b.pref('bkgd_color', color); $$b.pref('bkgd_color', color);
$$b.pref('bkgd_url', url); // This should be done in svgcanvas.js for the borderRect fill $$b.pref('bkgd_url', url, true); // This should be done in svgcanvas.js for the borderRect fill
svgCanvas.setBackground(color, url); svgCanvas.setBackground(color, url);
} }