From 6d804f2fb9ce9537bfef91f5d75fc4184740b1f6 Mon Sep 17 00:00:00 2001 From: pmkrawczyk <63370626+pmkrawczyk@users.noreply.github.com> Date: Tue, 5 Jul 2022 23:47:07 +0200 Subject: [PATCH] Add ext path to config (#815) * Add extPath to config object * Update ext-shapes.js * Update EditorStartup.js * Fix linter issue * Update EditorStartup.js --- src/editor/ConfigObj.js | 1 + src/editor/EditorStartup.js | 3 ++- src/editor/extensions/ext-shapes/ext-shapes.js | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/editor/ConfigObj.js b/src/editor/ConfigObj.js index 81330035..abd1d4c6 100644 --- a/src/editor/ConfigObj.js +++ b/src/editor/ConfigObj.js @@ -132,6 +132,7 @@ export default class ConfigObj { // PATH CONFIGURATION // The following path configuration items are disallowed in the URL (as should any future path configurations) imgPath: './images', + extPath: './extensions', // DOCUMENT PROPERTIES // Change the following to a preference (already in the Document Properties dialog)? dimensions: [640, 480], diff --git a/src/editor/EditorStartup.js b/src/editor/EditorStartup.js index 3cb84981..c9b09b3c 100644 --- a/src/editor/EditorStartup.js +++ b/src/editor/EditorStartup.js @@ -628,7 +628,8 @@ class EditorStartup { /** * @type {module:SVGthis.ExtensionObject} */ - const imported = await import(`./extensions/${encodeURIComponent(extname)}/${encodeURIComponent(extname)}.js`) + const extPath = this.configObj.curConfig.extPath + const imported = await import(`${extPath}/${encodeURIComponent(extname)}/${encodeURIComponent(extname)}.js`) const { name = extname, init: initfn } = imported.default return this.addExtension(name, (initfn && initfn.bind(this)), { langParam: 'en' }) /** @todo change to current lng */ } catch (err) { diff --git a/src/editor/extensions/ext-shapes/ext-shapes.js b/src/editor/extensions/ext-shapes/ext-shapes.js index 1a929152..36dd0de8 100644 --- a/src/editor/extensions/ext-shapes/ext-shapes.js +++ b/src/editor/extensions/ext-shapes/ext-shapes.js @@ -40,8 +40,9 @@ export default { return { callback () { if ($id('tool_shapelib') === null) { + const extPath = svgEditor.configObj.curConfig.extPath const buttonTemplate = ` - ` canv.insertChildAtIndex($id('tools_left'), buttonTemplate, 9)