Add ext path to config (#815)
* Add extPath to config object * Update ext-shapes.js * Update EditorStartup.js * Fix linter issue * Update EditorStartup.js
This commit is contained in:
@@ -132,6 +132,7 @@ export default class ConfigObj {
|
|||||||
// PATH CONFIGURATION
|
// PATH CONFIGURATION
|
||||||
// The following path configuration items are disallowed in the URL (as should any future path configurations)
|
// The following path configuration items are disallowed in the URL (as should any future path configurations)
|
||||||
imgPath: './images',
|
imgPath: './images',
|
||||||
|
extPath: './extensions',
|
||||||
// DOCUMENT PROPERTIES
|
// DOCUMENT PROPERTIES
|
||||||
// Change the following to a preference (already in the Document Properties dialog)?
|
// Change the following to a preference (already in the Document Properties dialog)?
|
||||||
dimensions: [640, 480],
|
dimensions: [640, 480],
|
||||||
|
|||||||
@@ -628,7 +628,8 @@ class EditorStartup {
|
|||||||
/**
|
/**
|
||||||
* @type {module:SVGthis.ExtensionObject}
|
* @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
|
const { name = extname, init: initfn } = imported.default
|
||||||
return this.addExtension(name, (initfn && initfn.bind(this)), { langParam: 'en' }) /** @todo change to current lng */
|
return this.addExtension(name, (initfn && initfn.bind(this)), { langParam: 'en' }) /** @todo change to current lng */
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
@@ -40,8 +40,9 @@ export default {
|
|||||||
return {
|
return {
|
||||||
callback () {
|
callback () {
|
||||||
if ($id('tool_shapelib') === null) {
|
if ($id('tool_shapelib') === null) {
|
||||||
|
const extPath = svgEditor.configObj.curConfig.extPath
|
||||||
const buttonTemplate = `
|
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>
|
src="shapelib.svg"></se-explorerbutton>
|
||||||
`
|
`
|
||||||
canv.insertChildAtIndex($id('tools_left'), buttonTemplate, 9)
|
canv.insertChildAtIndex($id('tools_left'), buttonTemplate, 9)
|
||||||
|
|||||||
Reference in New Issue
Block a user