- Fix (regression): Arg names not being passed on properly for `addExtension`
parent
2e5c7557a9
commit
c42791b2b2
|
@ -6441,18 +6441,18 @@ editor.loadFromDataURI = function (str, {noAlert} = {}) {
|
||||||
/**
|
/**
|
||||||
* @param {string} name Used internally; no need for i18n.
|
* @param {string} name Used internally; no need for i18n.
|
||||||
* @param {module:svgcanvas.ExtensionInitCallback} init Config to be invoked on this module
|
* @param {module:svgcanvas.ExtensionInitCallback} init Config to be invoked on this module
|
||||||
* @param {module:SVGEditor~ImportLocale} importLocale Importer defaulting to pth with current extension name and locale
|
* @param {module:svgcanvas.ExtensionInitArgs} initArgs
|
||||||
* @throws {Error} If called too early
|
* @throws {Error} If called too early
|
||||||
* @returns {Promise} Resolves to `undefined`
|
* @returns {Promise} Resolves to `undefined`
|
||||||
*/
|
*/
|
||||||
editor.addExtension = function (name, init, importLocale) {
|
editor.addExtension = function (name, init, initArgs) {
|
||||||
// Note that we don't want this on editor.ready since some extensions
|
// Note that we don't want this on editor.ready since some extensions
|
||||||
// may want to run before then (like server_opensave).
|
// may want to run before then (like server_opensave).
|
||||||
// $(function () {
|
// $(function () {
|
||||||
if (!svgCanvas) {
|
if (!svgCanvas) {
|
||||||
throw new Error('Extension added too early');
|
throw new Error('Extension added too early');
|
||||||
}
|
}
|
||||||
return svgCanvas.addExtension.call(this, name, init, importLocale);
|
return svgCanvas.addExtension.call(this, name, init, initArgs);
|
||||||
// });
|
// });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1139,17 +1139,22 @@ const runExtensions = this.runExtensions = function (action, vars, returnArray,
|
||||||
* @returns {Promise} Resolves to [ExtensionInitResponse]{@link module:svgcanvas.ExtensionInitResponse} or `undefined`
|
* @returns {Promise} Resolves to [ExtensionInitResponse]{@link module:svgcanvas.ExtensionInitResponse} or `undefined`
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
|
* @typedef {PlainObject} module:svgcanvas.ExtensionInitArgs
|
||||||
|
* @param {external:jQuery} initArgs.$
|
||||||
|
* @param {module:SVGEditor~ImportLocale} initArgs.importLocale
|
||||||
|
*/
|
||||||
|
/**
|
||||||
* Add an extension to the editor.
|
* Add an extension to the editor.
|
||||||
* @function module:svgcanvas.SvgCanvas#addExtension
|
* @function module:svgcanvas.SvgCanvas#addExtension
|
||||||
* @param {string} name - String with the ID of the extension. Used internally; no need for i18n.
|
* @param {string} name - String with the ID of the extension. Used internally; no need for i18n.
|
||||||
* @param {module:svgcanvas.ExtensionInitCallback} [extInitFunc] - Function supplied by the extension with its data
|
* @param {module:svgcanvas.ExtensionInitCallback} [extInitFunc] - Function supplied by the extension with its data
|
||||||
* @param {module:SVGEditor~ImportLocale} importLocale
|
* @param {module:svgcanvas.ExtensionInitArgs} initArgs
|
||||||
* @fires module:svgcanvas.SvgCanvas#event:extension_added
|
* @fires module:svgcanvas.SvgCanvas#event:extension_added
|
||||||
* @throws {TypeError|Error} `TypeError` if `extInitFunc` is not a function, `Error`
|
* @throws {TypeError|Error} `TypeError` if `extInitFunc` is not a function, `Error`
|
||||||
* if extension of supplied name already exists
|
* if extension of supplied name already exists
|
||||||
* @returns {Promise} Resolves to `undefined`
|
* @returns {Promise} Resolves to `undefined`
|
||||||
*/
|
*/
|
||||||
this.addExtension = async function (name, extInitFunc, importLocale) {
|
this.addExtension = async function (name, extInitFunc, {$: jq, importLocale}) {
|
||||||
if (typeof extInitFunc !== 'function') {
|
if (typeof extInitFunc !== 'function') {
|
||||||
throw new TypeError('Function argument expected for `svgcanvas.addExtension`');
|
throw new TypeError('Function argument expected for `svgcanvas.addExtension`');
|
||||||
}
|
}
|
||||||
|
@ -1170,7 +1175,7 @@ this.addExtension = async function (name, extInitFunc, importLocale) {
|
||||||
* @see {@link module:svgcanvas.PrivateMethods} source for the other methods/properties
|
* @see {@link module:svgcanvas.PrivateMethods} source for the other methods/properties
|
||||||
*/
|
*/
|
||||||
const argObj = $.extend(canvas.getPrivateMethods(), {
|
const argObj = $.extend(canvas.getPrivateMethods(), {
|
||||||
$,
|
$: jq,
|
||||||
importLocale,
|
importLocale,
|
||||||
svgroot,
|
svgroot,
|
||||||
svgcontent,
|
svgcontent,
|
||||||
|
|
Loading…
Reference in New Issue