Add ext path to config (#815)

* Add extPath to config object

* Update ext-shapes.js

* Update EditorStartup.js

* Fix linter issue

* Update EditorStartup.js
master
pmkrawczyk 2022-07-05 23:47:07 +02:00 committed by GitHub
parent cdc85a515b
commit 6d804f2fb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 5 additions and 2 deletions

View File

@ -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],

View File

@ -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) {

View File

@ -40,8 +40,9 @@ export default {
return {
callback () {
if ($id('tool_shapelib') === null) {
const extPath = svgEditor.configObj.curConfig.extPath
const buttonTemplate = `
<se-explorerbutton id="tool_shapelib" title="${svgEditor.i18next.t(`${name}:buttons.0.title`)}" lib="./extensions/ext-shapes/shapelib/"
<se-explorerbutton id="tool_shapelib" title="${svgEditor.i18next.t(`${name}:buttons.0.title`)}" lib="${extPath}/ext-shapes/shapelib/"
src="shapelib.svg"></se-explorerbutton>
`
canv.insertChildAtIndex($id('tools_left'), buttonTemplate, 9)