diff --git a/src/editor/MainMenu.js b/src/editor/MainMenu.js
index 37bac189..336c06e5 100644
--- a/src/editor/MainMenu.js
+++ b/src/editor/MainMenu.js
@@ -277,25 +277,21 @@ class MainMenu {
init() {
// add Top panel
const template = document.createElement("template");
- const { i18next } = this.editor;
- const { imgPath } = this.editor.configObj.curConfig;
// eslint-disable-next-line no-unsanitized/property
template.innerHTML = `
-
-
-
-
-
-
-
- `;
+
+
+
+
+
+
+ `;
this.editor.$svgEditor.append(template.content.cloneNode(true));
// register action to main menu entries
/**
* Associate all button actions as well as non-button keyboard shortcuts.
*/
-
$id("tool_import").addEventListener("click", () => {
this.clickImport();
window.dispatchEvent(new CustomEvent("importImages"));
diff --git a/src/editor/components/index.js b/src/editor/components/index.js
index e59f23c2..01644416 100644
--- a/src/editor/components/index.js
+++ b/src/editor/components/index.js
@@ -10,5 +10,6 @@ import './seMenuItem.js';
import './seList.js';
import './seListItem.js';
import './seColorPicker.js';
-import './seSelect';
+import './seSelect.js';
+import './seText.js';
diff --git a/src/editor/components/seButton.js b/src/editor/components/seButton.js
index 2b91e39f..72d5f1f5 100644
--- a/src/editor/components/seButton.js
+++ b/src/editor/components/seButton.js
@@ -1,3 +1,5 @@
+/* globals svgEditor */
+import { t } from '../locale.js';
const template = document.createElement('template');
// eslint-disable-next-line no-unsanitized/property
template.innerHTML = `
@@ -54,6 +56,7 @@ export class ToolButton extends HTMLElement {
// locate the component
this.$div = this._shadowRoot.querySelector('div');
this.$img = this._shadowRoot.querySelector('img');
+ this.imgPath = svgEditor.configObj.curConfig.imgPath;
}
/**
* @function observedAttributes
@@ -75,14 +78,18 @@ export class ToolButton extends HTMLElement {
case 'title':
{
const shortcut = this.getAttribute('shortcut');
- this.$div.setAttribute('title', `${newValue} ${shortcut ? `[${shortcut}]` : ''}`);
+ this.$div.setAttribute('title', `${t(newValue)} ${shortcut ? `[${t(shortcut)}]` : ''}`);
}
break;
case 'style':
this.$div.style = newValue;
break;
case 'src':
- this.$img.setAttribute('src', newValue);
+ if (newValue.indexOf("data:") !== -1) {
+ this.$img.setAttribute('src', newValue);
+ } else {
+ this.$img.setAttribute('src', this.imgPath + "/" + newValue);
+ }
break;
case 'pressed':
if (newValue === null) {
diff --git a/src/editor/components/seColorPicker.js b/src/editor/components/seColorPicker.js
index 8aab6862..5c88d8e4 100644
--- a/src/editor/components/seColorPicker.js
+++ b/src/editor/components/seColorPicker.js
@@ -1,6 +1,8 @@
+/* globals svgEditor */
/* eslint-disable max-len */
import { jGraduate, jGraduateMethod } from './jgraduate/jQuery.jGraduate.js';
import PaintBox from './PaintBox.js';
+import { t } from '../locale.js';
const template = document.createElement('template');
// eslint-disable-next-line no-unsanitized/property
@@ -665,6 +667,7 @@ export class SeColorPicker extends HTMLElement {
this.i18next = null;
this.$picker = this._shadowRoot.getElementById('picker');
this.$color_picker = this._shadowRoot.getElementById('color_picker');
+ this.imgPath = svgEditor.configObj.curConfig.imgPath;
}
/**
* @function init
@@ -673,7 +676,7 @@ export class SeColorPicker extends HTMLElement {
*/
init (i18next) {
this.i18next = i18next;
- this.setAttribute('config-change_xxx_color', i18next.t('config.change_xxx_color'));
+ this.setAttribute('config-change_xxx_color', t('config.change_xxx_color'));
}
/**
* @function observedAttributes
@@ -693,10 +696,10 @@ export class SeColorPicker extends HTMLElement {
if (oldValue === newValue) return;
switch (name) {
case 'src':
- this.$logo.setAttribute('src', newValue);
+ this.$logo.setAttribute('src', this.imgPath + '/' + newValue);
break;
case 'label':
- this.setAttribute('title', newValue);
+ this.setAttribute('title', t(newValue));
break;
case 'type':
this.$label.setAttribute('title', 'config.pick_paint_opavity');
diff --git a/src/editor/components/seExplorerButton.js b/src/editor/components/seExplorerButton.js
index dee91b25..8434f94e 100644
--- a/src/editor/components/seExplorerButton.js
+++ b/src/editor/components/seExplorerButton.js
@@ -1,3 +1,4 @@
+/* globals svgEditor */
/* eslint-disable no-unsanitized/property */
const template = document.createElement('template');
template.innerHTML = `
@@ -119,6 +120,7 @@ export class ExplorerButton extends HTMLElement {
this.$lib = this._shadowRoot.querySelector('.image-lib');
this.files = [];
this.request = new XMLHttpRequest();
+ this.imgPath = svgEditor.configObj.curConfig.imgPath;
}
/**
* @function observedAttributes
@@ -172,7 +174,7 @@ export class ExplorerButton extends HTMLElement {
}
break;
case 'src':
- this.$img.setAttribute('src', newValue);
+ this.$img.setAttribute('src', this.imgPath + '/' + newValue);
break;
default:
// eslint-disable-next-line no-console
diff --git a/src/editor/components/seFlyingButton.js b/src/editor/components/seFlyingButton.js
index ddcc957b..6de46c88 100644
--- a/src/editor/components/seFlyingButton.js
+++ b/src/editor/components/seFlyingButton.js
@@ -1,3 +1,5 @@
+/* globals svgEditor */
+import { t } from '../locale.js';
const template = document.createElement('template');
template.innerHTML = `
+
`;
@@ -30,13 +33,16 @@ export class SeListItem extends HTMLElement {
this.$menuitem = this._shadowRoot.querySelector('elix-option');
this.$svg = this.$menuitem.shadowRoot.querySelector('#checkmark');
this.$svg.setAttribute('style', 'display: none;');
+ this.$img = this._shadowRoot.querySelector('img');
+ this.$img.setAttribute('style', 'display: none;');
+ this.imgPath = svgEditor.configObj.curConfig.imgPath;
}
/**
* @function observedAttributes
* @returns {any} observed
*/
static get observedAttributes () {
- return [ 'option' ];
+ return [ 'option', 'src', 'title', 'img-height' ];
}
/**
@@ -51,6 +57,17 @@ export class SeListItem extends HTMLElement {
switch (name) {
case 'option':
this.$menuitem.setAttribute('option', newValue);
+ this.$menuitem.textContent = t(newValue);
+ break;
+ case 'src':
+ this.$img.setAttribute('style', 'display: block;');
+ this.$img.setAttribute('src', this.imgPath + '/' + newValue);
+ break;
+ case 'title':
+ this.$img.setAttribute('title', t(newValue));
+ break;
+ case 'img-height':
+ this.$img.setAttribute('height', newValue);
break;
default:
// eslint-disable-next-line no-console
@@ -73,6 +90,51 @@ export class SeListItem extends HTMLElement {
set option (value) {
this.setAttribute('option', value);
}
+ /**
+ * @function get
+ * @returns {any}
+ */
+ get title () {
+ return this.getAttribute('title');
+ }
+
+ /**
+ * @function set
+ * @returns {void}
+ */
+ set title (value) {
+ this.setAttribute('title', value);
+ }
+ /**
+ * @function get
+ * @returns {any}
+ */
+ get imgHeight () {
+ return this.getAttribute('img-height');
+ }
+
+ /**
+ * @function set
+ * @returns {void}
+ */
+ set imgHeight (value) {
+ this.setAttribute('img-height', value);
+ }
+ /**
+ * @function get
+ * @returns {any}
+ */
+ get src () {
+ return this.getAttribute('src');
+ }
+
+ /**
+ * @function set
+ * @returns {void}
+ */
+ set src (value) {
+ this.setAttribute('src', value);
+ }
}
// Register
diff --git a/src/editor/components/seMenu.js b/src/editor/components/seMenu.js
index 3b5fef77..3c1fe7dc 100644
--- a/src/editor/components/seMenu.js
+++ b/src/editor/components/seMenu.js
@@ -1,3 +1,4 @@
+/* globals svgEditor */
import 'elix/define/MenuItem.js';
import './sePlainMenuButton.js';
@@ -43,6 +44,7 @@ export class SeMenu extends HTMLElement {
this._shadowRoot.append(template.content.cloneNode(true));
this.$menu = this._shadowRoot.querySelector('elix-menu-button');
this.$label = this.$menu.shadowRoot.querySelector('#popupToggle').shadowRoot;
+ this.imgPath = svgEditor.configObj.curConfig.imgPath;
}
/**
* @function observedAttributes
@@ -64,7 +66,7 @@ export class SeMenu extends HTMLElement {
if (oldValue === newValue) return;
switch (name) {
case 'src':
- image.src = newValue;
+ image.src = this.imgPath + '/' + newValue;
image.width = 24;
image.height = 24;
this.$label.prepend(image);
diff --git a/src/editor/components/seMenuItem.js b/src/editor/components/seMenuItem.js
index d005fb8e..cfdcd9b6 100644
--- a/src/editor/components/seMenuItem.js
+++ b/src/editor/components/seMenuItem.js
@@ -1,6 +1,7 @@
+/* globals svgEditor */
import 'elix/define/Menu.js';
import 'elix/define/MenuItem.js';
-
+import { t } from '../locale.js';
const template = document.createElement('template');
template.innerHTML = `
+
+`;
+/**
+ * @class SeText
+ */
+export class SeText extends HTMLElement {
+ /**
+ * @function constructor
+ */
+ constructor () {
+ super();
+ // create the shadowDom and insert the template
+ this._shadowRoot = this.attachShadow({ mode: 'open' });
+ this._shadowRoot.append(template.content.cloneNode(true));
+ // locate the component
+ this.$div = this._shadowRoot.querySelector('div');
+ }
+ /**
+ * @function observedAttributes
+ * @returns {any} observed
+ */
+ static get observedAttributes () {
+ return [ 'text', 'value', 'style' ];
+ }
+ /**
+ * @function attributeChangedCallback
+ * @param {string} name
+ * @param {string} oldValue
+ * @param {string} newValue
+ * @returns {void}
+ */
+ attributeChangedCallback (name, oldValue, newValue) {
+ if (oldValue === newValue) return;
+ switch (name) {
+ case 'text':
+ this.$div.setAttribute('title', t(newValue));
+ break;
+ case 'style':
+ this.$div.style = newValue;
+ break;
+ case 'value':
+ this.$div.value = newValue;
+ break;
+ default:
+ // eslint-disable-next-line no-console
+ console.error(`unknown attribute: ${name}`);
+ break;
+ }
+ }
+ /**
+ * @function get
+ * @returns {any}
+ */
+ get text () {
+ return this.getAttribute('text');
+ }
+
+ /**
+ * @function set
+ * @returns {void}
+ */
+ set text (value) {
+ this.setAttribute('text', value);
+ }
+ /**
+ * @function get
+ * @returns {any}
+ */
+ get value () {
+ return this.value;
+ }
+
+ /**
+ * @function set
+ * @returns {void}
+ */
+ set value (value) {
+ this.value = value;
+ }
+
+ /**
+ * @function connectedCallback
+ * @returns {void}
+ */
+ connectedCallback () {
+ // capture shortcuts
+ }
+}
+
+// Register
+customElements.define('se-text', SeText);
diff --git a/src/editor/components/seZoom.js b/src/editor/components/seZoom.js
index 34cc54d9..49006e42 100644
--- a/src/editor/components/seZoom.js
+++ b/src/editor/components/seZoom.js
@@ -1,3 +1,4 @@
+/* globals svgEditor */
import ListComboBox from 'elix/define/ListComboBox.js';
import * as internal from 'elix/src/base/internal.js';
import { templateFrom, fragmentFrom } from 'elix/src/core/htmlLiterals.js';
@@ -74,13 +75,16 @@ class Zoom extends ListComboBox {
* @returns {void}
*/
attributeChangedCallback (name, oldValue, newValue) {
- if (oldValue === newValue) return;
+ if (oldValue === newValue && name !== "src") return;
switch (name) {
case 'title':
// this.$span.setAttribute('title', `${newValue} ${shortcut ? `[${shortcut}]` : ''}`);
break;
case 'src':
- this.src = newValue;
+ {
+ const { imgPath } = svgEditor.configObj.curConfig;
+ this.src = imgPath + '/' + newValue;
+ }
break;
case 'inputsize':
this.inputsize = newValue;
diff --git a/src/editor/dialogs/cmenuLayersDialog.js b/src/editor/dialogs/cmenuLayersDialog.js
index 95c02782..b50d6d9c 100644
--- a/src/editor/dialogs/cmenuLayersDialog.js
+++ b/src/editor/dialogs/cmenuLayersDialog.js
@@ -182,7 +182,7 @@ export class SeCMenuLayerDialog extends HTMLElement {
const onMenuOpenHandler = (e) => {
e.preventDefault();
current.$dialog.style.top = e.pageY + 'px';
- current.$dialog.style.left = e.pageX + 'px';
+ current.$dialog.style.left = e.pageX - 126 + 'px';
current.$dialog.style.display = 'block';
};
const onMenuCloseHandler = (e) => {
diff --git a/src/editor/extensions/ext-connector/ext-connector.js b/src/editor/extensions/ext-connector/ext-connector.js
index ebd3394a..ad8fabfb 100644
--- a/src/editor/extensions/ext-connector/ext-connector.js
+++ b/src/editor/extensions/ext-connector/ext-connector.js
@@ -31,7 +31,6 @@ export default {
const { svgCanvas } = svgEditor;
const { getElem, $id, mergeDeep } = svgCanvas;
const { svgroot } = S;
- const { imgPath } = svgEditor.configObj.curConfig;
const addElem = svgCanvas.addSVGElementFromJson;
const selManager = S.selectorManager;
await loadExtensionTranslation(svgEditor);
@@ -354,10 +353,10 @@ export default {
return {
name: svgEditor.i18next.t(`${name}:name`),
callback() {
- const btitle = svgEditor.i18next.t(`${name}:langListTitle`);
+ const btitle = `${name}:langListTitle`;
// eslint-disable-next-line no-unsanitized/property
const buttonTemplate = `
-
+
`;
svgCanvas.insertChildAtIndex($id('tools_left'), buttonTemplate, 13);
$id('mode_connect').addEventListener("click", () => {
diff --git a/src/editor/extensions/ext-eyedropper/ext-eyedropper.js b/src/editor/extensions/ext-eyedropper/ext-eyedropper.js
index 0bb6bbb7..c81b9073 100644
--- a/src/editor/extensions/ext-eyedropper/ext-eyedropper.js
+++ b/src/editor/extensions/ext-eyedropper/ext-eyedropper.js
@@ -29,7 +29,6 @@ export default {
name,
async init(S) {
const svgEditor = this;
- const { imgPath } = svgEditor.configObj.curConfig;
await loadExtensionTranslation(svgEditor);
const { ChangeElementCommand } = S; // , svgcontent,
// svgdoc = S.svgroot.parentNode.ownerDocument,
@@ -83,11 +82,11 @@ export default {
name: svgEditor.i18next.t(`${name}:name`),
callback() {
// Add the button and its handler(s)
- const title = svgEditor.i18next.t(`${name}:buttons.0.title`);
- const key = svgEditor.i18next.t(`${name}:buttons.0.key`);
+ const title = `${name}:buttons.0.title`;
+ const key = `${name}:buttons.0.key`;
// eslint-disable-next-line no-unsanitized/property
const buttonTemplate = `
-
+
`;
svgCanvas.insertChildAtIndex($id('tools_left'), buttonTemplate, 12);
$id('tool_eyedropper').addEventListener("click", () => {
diff --git a/src/editor/extensions/ext-grid/ext-grid.js b/src/editor/extensions/ext-grid/ext-grid.js
index 7c11b72f..5154272b 100644
--- a/src/editor/extensions/ext-grid/ext-grid.js
+++ b/src/editor/extensions/ext-grid/ext-grid.js
@@ -28,7 +28,6 @@ export default {
name,
async init ({ NS, getTypeMap }) {
const svgEditor = this;
- const { imgPath } = svgEditor.configObj.curConfig;
await loadExtensionTranslation(svgEditor);
const { svgCanvas } = svgEditor;
const { $id } = svgCanvas;
@@ -164,11 +163,11 @@ export default {
callback () {
// Add the button and its handler(s)
const buttonTemplate = document.createElement("template");
- const title = svgEditor.i18next.t(`${name}:buttons.0.title`);
+ const title = `${name}:buttons.0.title`;
// eslint-disable-next-line no-unsanitized/property
buttonTemplate.innerHTML = `
-
+
`;
$id('editor_panel').append(buttonTemplate.content.cloneNode(true));
$id('view_grid').addEventListener("click", () => {
diff --git a/src/editor/extensions/ext-helloworld/ext-helloworld.js b/src/editor/extensions/ext-helloworld/ext-helloworld.js
index 297a70eb..d7a17e00 100644
--- a/src/editor/extensions/ext-helloworld/ext-helloworld.js
+++ b/src/editor/extensions/ext-helloworld/ext-helloworld.js
@@ -34,7 +34,6 @@ export default {
name,
async init ({ _importLocale }) {
const svgEditor = this;
- const { imgPath } = svgEditor.configObj.curConfig;
await loadExtensionTranslation(svgEditor);
const { svgCanvas } = svgEditor;
const { $id } = svgCanvas;
@@ -43,10 +42,10 @@ export default {
callback() {
// Add the button and its handler(s)
const buttonTemplate = document.createElement("template");
- const title = svgEditor.i18next.t(`${name}:buttons.0.title`);
+ const title = `${name}:buttons.0.title`;
// eslint-disable-next-line no-unsanitized/property
buttonTemplate.innerHTML = `
-
+
`;
$id('tools_left').append(buttonTemplate.content.cloneNode(true));
$id('hello_world').addEventListener("click", () => {
diff --git a/src/editor/extensions/ext-imagelib/ext-imagelib.js b/src/editor/extensions/ext-imagelib/ext-imagelib.js
index 09dc11f8..e9cc44f3 100644
--- a/src/editor/extensions/ext-imagelib/ext-imagelib.js
+++ b/src/editor/extensions/ext-imagelib/ext-imagelib.js
@@ -522,8 +522,9 @@ export default {
callback() {
// Add the button and its handler(s)
const buttonTemplate = document.createElement("template");
+ const key = name + `:buttons.0.title`;
buttonTemplate.innerHTML = `
-
+
`;
insertAfter($id('tool_export'), buttonTemplate.content.cloneNode(true));
$id('tool_imagelib').addEventListener("click", () => {
diff --git a/src/editor/extensions/ext-opensave/ext-opensave.js b/src/editor/extensions/ext-opensave/ext-opensave.js
index fd9a463f..d042d56a 100644
--- a/src/editor/extensions/ext-opensave/ext-opensave.js
+++ b/src/editor/extensions/ext-opensave/ext-opensave.js
@@ -39,7 +39,6 @@ export default {
name,
async init(_S) {
const svgEditor = this;
- const { imgPath } = svgEditor.configObj.curConfig;
const { svgCanvas } = svgEditor;
const { $id } = svgCanvas;
await loadExtensionTranslation(svgEditor);
@@ -162,13 +161,13 @@ export default {
callback() {
// eslint-disable-next-line no-unsanitized/property
const buttonTemplate = `
- `;
+ `;
svgCanvas.insertChildAtIndex($id('main_button'), buttonTemplate, 0);
- const openButtonTemplate = ``;
+ const openButtonTemplate = ``;
svgCanvas.insertChildAtIndex($id('main_button'), openButtonTemplate, 1);
- const saveButtonTemplate = ``;
+ const saveButtonTemplate = ``;
svgCanvas.insertChildAtIndex($id('main_button'), saveButtonTemplate, 2);
- const saveAsButtonTemplate = ``;
+ const saveAsButtonTemplate = ``;
svgCanvas.insertChildAtIndex($id('main_button'), saveAsButtonTemplate, 3);
// handler
$id("tool_clear").addEventListener("click", clickClear.bind(this));
diff --git a/src/editor/extensions/ext-panning/ext-panning.js b/src/editor/extensions/ext-panning/ext-panning.js
index 7f4ba2a0..aa9a4555 100644
--- a/src/editor/extensions/ext-panning/ext-panning.js
+++ b/src/editor/extensions/ext-panning/ext-panning.js
@@ -31,8 +31,6 @@ export default {
name,
async init() {
const svgEditor = this;
- const { imgPath } = svgEditor.configObj.curConfig;
-
await loadExtensionTranslation(svgEditor);
const {
svgCanvas
@@ -46,12 +44,12 @@ export default {
return {
name: svgEditor.i18next.t(`${name}:name`),
callback() {
- const btitle = svgEditor.i18next.t(`${name}:buttons.0.title`);
+ const btitle = `${name}:buttons.0.title`;
// Add the button and its handler(s)
const buttonTemplate = document.createElement("template");
// eslint-disable-next-line no-unsanitized/property
buttonTemplate.innerHTML = `
-
+
`;
insertAfter($id('tool_zoom'), buttonTemplate.content.cloneNode(true));
$id('ext-panning').addEventListener("click", () => {
diff --git a/src/editor/extensions/ext-polystar/ext-polystar.js b/src/editor/extensions/ext-polystar/ext-polystar.js
index 74b224ce..b93f909e 100644
--- a/src/editor/extensions/ext-polystar/ext-polystar.js
+++ b/src/editor/extensions/ext-polystar/ext-polystar.js
@@ -29,7 +29,6 @@ export default {
name,
async init(_S) {
const svgEditor = this;
- const { imgPath } = svgEditor.configObj.curConfig;
const { ChangeElementCommand } = _S; // , svgcontent,
const addToHistory = function (cmd) { svgCanvas.undoMgr.addCommandToHistory(cmd); };
const { svgCanvas } = svgEditor;
@@ -81,15 +80,15 @@ export default {
callback() {
// Add the button and its handler(s)
// Note: the star extension needs to be loaded before the polygon extension
- const fbtitle = svgEditor.i18next.t(`${name}:title`);
- const title_star = svgEditor.i18next.t(`${name}:buttons.0.title`);
- const title_polygon = svgEditor.i18next.t(`${name}:buttons.1.title`);
+ const fbtitle = `${name}:title`;
+ const title_star = `${name}:buttons.0.title`;
+ const title_polygon = `${name}:buttons.1.title`;
// eslint-disable-next-line no-unsanitized/property
const buttonTemplate = `
-
+
-
+
`;
@@ -109,15 +108,14 @@ export default {
showPanel(false, "star");
}
});
-
- const label0 = svgEditor.i18next.t(`${name}:contextTools.0.label`);
- const title0 = svgEditor.i18next.t(`${name}:contextTools.0.title`);
- const label1 = svgEditor.i18next.t(`${name}:contextTools.1.label`);
- const title1 = svgEditor.i18next.t(`${name}:contextTools.1.title`);
- const label2 = svgEditor.i18next.t(`${name}:contextTools.2.label`);
- const title2 = svgEditor.i18next.t(`${name}:contextTools.2.title`);
- const label3 = svgEditor.i18next.t(`${name}:contextTools.3.label`);
- const title3 = svgEditor.i18next.t(`${name}:contextTools.3.title`);
+ const label0 = `${name}:contextTools.0.label`;
+ const title0 = `${name}:contextTools.0.title`;
+ const label1 = `${name}:contextTools.1.label`;
+ const title1 = `${name}:contextTools.1.title`;
+ const label2 = `${name}:contextTools.2.label`;
+ const title2 = `${name}:contextTools.2.title`;
+ const label3 = `${name}:contextTools.3.label`;
+ const title3 = `${name}:contextTools.3.title`;
// Add the context panel and its handler(s)
const panelTemplate = document.createElement("template");
// eslint-disable-next-line no-unsanitized/property
diff --git a/src/editor/extensions/ext-shapes/ext-shapes.js b/src/editor/extensions/ext-shapes/ext-shapes.js
index b94f254a..5153264c 100644
--- a/src/editor/extensions/ext-shapes/ext-shapes.js
+++ b/src/editor/extensions/ext-shapes/ext-shapes.js
@@ -27,7 +27,6 @@ export default {
name,
async init () {
const svgEditor = this;
- const { imgPath } = svgEditor.configObj.curConfig;
const canv = svgEditor.svgCanvas;
const { $id } = canv;
const svgroot = canv.getRootElem();
@@ -47,7 +46,7 @@ export default {
// eslint-disable-next-line no-unsanitized/property
const buttonTemplate = `
+ src="shapelib.svg">
`;
canv.insertChildAtIndex($id('tools_left'), buttonTemplate, 9);
$id('tool_shapelib').addEventListener("click", () => {
diff --git a/src/editor/locale.js b/src/editor/locale.js
index 7be840a4..0d372f9f 100644
--- a/src/editor/locale.js
+++ b/src/editor/locale.js
@@ -86,3 +86,7 @@ export const putLocale = async function (givenParam, goodLangs) {
console.info(`Lang: ${i18next.t('lang')}`);
return { langParam, i18next };
};
+
+export const t = function (key) {
+ return i18next.t(key);
+};
\ No newline at end of file
diff --git a/src/editor/locale/lang.en.js b/src/editor/locale/lang.en.js
index 93230482..c9d05b41 100644
--- a/src/editor/locale/lang.en.js
+++ b/src/editor/locale/lang.en.js
@@ -70,13 +70,30 @@ export default {
straight_segments: 'Straight',
curve_segments: 'Curve',
text_contents: 'Change text contents',
+ font_family_label: 'Font',
font_family: 'Change Font Family',
font_size: 'Change Font Size',
- bold: 'Bold Text [B]',
- italic: 'Italic Text [I]',
+ bold: 'Bold Text',
+ italic: 'Italic Text',
text_anchor_start: 'Align the text in start',
text_anchor_middle: 'Align the text in middle',
text_anchor_end: 'Align the text in end',
+ r_label: 'r',
+ x_label: 'x',
+ y_label: 'y',
+ x1_label: 'x1',
+ y1_label: 'y1',
+ x2_label: 'x2',
+ y2_label: 'y2',
+ rx_label: 'rx',
+ ry_label: 'ry',
+ cx_label: 'cx',
+ cy_label: 'cy',
+ w_label: 'w',
+ h_label: 'h',
+ id_label: 'id',
+ class_label: 'class',
+ label: 'label',
class: 'Element class',
serif: 'Serif',
sans_serif: 'Sans-serif',
@@ -129,21 +146,21 @@ export default {
mode_path: 'Path Tool',
mode_text: 'Text Tool',
mode_image: 'Image Tool',
- mode_zoom: 'Zoom Tool [Ctrl+Up/Down]',
+ mode_zoom: 'Zoom Tool',
no_embed: 'NOTE: This image cannot be embedded. It will depend on this path to be displayed',
- undo: 'Undo [Z]',
- redo: 'Redo [Y]',
+ undo: 'Undo',
+ redo: 'Redo',
tool_source: 'Edit Source',
wireframe_mode: 'Wireframe Mode',
- clone: 'Duplicate Element(s) [D]',
+ clone: 'Duplicate Element(s)',
del: 'Delete Element(s)',
- group_elements: 'Group Elements [G]',
+ group_elements: 'Group Elements',
make_link: 'Make (hyper)link',
set_link_url: 'Set link URL (leave empty to remove)',
to_path: 'Convert to Path',
reorient_path: 'Reorient path',
ungroup: 'Ungroup Elements',
- docprops: 'Document Properties [D]',
+ docprops: 'Document Properties',
editor_homepage: 'SVG-Edit Home Page',
move_bottom: 'Send to Back',
move_top: 'Bring to Front',
diff --git a/src/editor/panels/BottomPanel.js b/src/editor/panels/BottomPanel.js
index 801742e3..07790e55 100644
--- a/src/editor/panels/BottomPanel.js
+++ b/src/editor/panels/BottomPanel.js
@@ -164,50 +164,41 @@ class BottomPanel {
// register actions for Bottom panel
const template = document.createElement('template');
const { i18next } = this.editor;
- const { imgPath } = this.editor.configObj.curConfig;
// eslint-disable-next-line no-unsanitized/property
template.innerHTML = `
`;
diff --git a/src/editor/panels/LayersPanel.js b/src/editor/panels/LayersPanel.js
index 31995bfa..c12a2edf 100644
--- a/src/editor/panels/LayersPanel.js
+++ b/src/editor/panels/LayersPanel.js
@@ -44,7 +44,6 @@ class LayersPanel {
init() {
const template = document.createElement("template");
const { i18next } = this.editor;
- const { imgPath } = this.editor.configObj.curConfig;
// eslint-disable-next-line no-unsanitized/property
template.innerHTML = `
@@ -54,12 +53,12 @@ class LayersPanel {
${i18next.t('layers.layers')}
@@ -90,31 +89,14 @@ class LayersPanel {
menuLayerBox.setAttribute("leftclick", false);
this.editor.$container.append(menuLayerBox);
menuLayerBox.init(i18next);
- document
- .getElementById("layer_new")
- .addEventListener("click", this.newLayer.bind(this));
- document
- .getElementById("layer_delete")
- .addEventListener("click", this.deleteLayer.bind(this));
- document
- .getElementById("layer_up")
- .addEventListener("click", () => this.moveLayer.bind(this)(-1));
- document
- .getElementById("layer_down")
- .addEventListener("click", () => this.moveLayer.bind(this)(1));
- document
- .getElementById("layer_rename")
- .addEventListener("click", this.layerRename.bind(this));
- $id("se-cmenu-layers-more").addEventListener(
- "change",
- this.lmenuFunc.bind(this)
- );
- $id("se-cmenu-layers-list").addEventListener("change", (e) => {
- this.lmenuFunc(e);
- });
- $id("sidepanel_handle").addEventListener(
- "click", () => this.toggleSidePanel()
- );
+ $id("layer_new").addEventListener("click", this.newLayer.bind(this));
+ $id("layer_delete").addEventListener("click", this.deleteLayer.bind(this));
+ $id("layer_up").addEventListener("click", () => this.moveLayer.bind(this)(-1));
+ $id("layer_down").addEventListener("click", () => this.moveLayer.bind(this)(1));
+ $id("layer_rename").addEventListener("click", this.layerRename.bind(this));
+ $id("se-cmenu-layers-more").addEventListener("change", this.lmenuFunc.bind(this));
+ $id("se-cmenu-layers-list").addEventListener("change", (e) => { this.lmenuFunc(e); });
+ $id("sidepanel_handle").addEventListener("click", () => this.toggleSidePanel());
this.toggleSidePanel(this.editor.configObj.curConfig.showlayers);
}
toggleSidePanel(displayFlag) {
diff --git a/src/editor/panels/LeftPanel.js b/src/editor/panels/LeftPanel.js
index 8a16642e..6e311771 100644
--- a/src/editor/panels/LeftPanel.js
+++ b/src/editor/panels/LeftPanel.js
@@ -195,53 +195,51 @@ class LeftPanel {
* @type {module}
*/
init() {
- const { i18next } = this.editor;
- const { imgPath } = this.editor.configObj.curConfig;
// add Left panel
const leftMenu = [
{
- menu: ``,
+ menu: ``,
position: 1
},
{
- menu: ``,
+ menu: ``,
position: 2
},
{
- menu: ``,
+ menu: ``,
position: 3
},
{
- menu: ``,
+ menu: ``,
position: 4
},
{
- menu: ``,
+ menu: ``,
position: 5
},
{
- menu: `
-
-
-
+ menu: `
+
+
+
`,
position: 6
},
{
- menu: `
-
-
-
+ menu: `
+
+
+
`,
position: 7
},
{
- menu: ``,
+ menu: ``,
position: 8
},
{
- menu: ``,
+ menu: ``,
position: 11
}
];
@@ -269,10 +267,7 @@ class LeftPanel {
$id("tool_fhrect").addEventListener("click", this.clickFHRect.bind(this));
$id("tool_ellipse").addEventListener("click", this.clickEllipse.bind(this));
$id("tool_circle").addEventListener("click", this.clickCircle.bind(this));
- $id("tool_fhellipse").addEventListener(
- "click",
- this.clickFHEllipse.bind(this)
- );
+ $id("tool_fhellipse").addEventListener("click", this.clickFHEllipse.bind(this));
}
}
diff --git a/src/editor/panels/TopPanel.js b/src/editor/panels/TopPanel.js
index d132b36e..788b88c3 100644
--- a/src/editor/panels/TopPanel.js
+++ b/src/editor/panels/TopPanel.js
@@ -111,18 +111,20 @@ class TopPanel {
$id("stroke_width").value = this.selectedElement.getAttribute("stroke-width") || 1;
$id("stroke_style").value = this.selectedElement.getAttribute("stroke-dasharray") || "none";
+ $id("stroke_style").setAttribute("value", $id("stroke_style").value);
let attr =
this.selectedElement.getAttribute("stroke-linejoin") || "miter";
- if ($id("linejoin_" + attr).length) {
+ if ($id("linejoin_" + attr)) {
this.setStrokeOpt($id("linejoin_" + attr));
+ $id("stroke_linejoin").setAttribute("value", attr);
}
attr = this.selectedElement.getAttribute("stroke-linecap") || "butt";
-
- if ($id("linecap_" + attr).length) {
+ if ($id("linecap_" + attr)) {
this.setStrokeOpt($id("linecap_" + attr));
+ $id("stroke_linecap").setAttribute("value", attr);
}
}
}
@@ -343,7 +345,7 @@ class TopPanel {
this.displayTool("text_panel");
$id("tool_italic").pressed = this.editor.svgCanvas.getItalic();
$id("tool_bold").pressed = this.editor.svgCanvas.getBold();
- $id("tool_font_family").value = elem.getAttribute("font-family");
+ $id("tool_font_family").setAttribute("value", elem.getAttribute("font-family"));
$id("font_size").value = elem.getAttribute("font-size");
$id("text").value = elem.textContent;
const textAnchorStart = $id("tool_text_anchor_start");
@@ -795,7 +797,6 @@ class TopPanel {
* @returns {void}
*/
togglePathEditMode(editMode, elems) {
- const { imgPath } = this.editor.configObj.curConfig;
if (editMode) {
this.displayTool('path_node_panel');
} else {
@@ -805,14 +806,14 @@ class TopPanel {
// Change select icon
$id('tool_path').pressed = false;
$id('tool_select').pressed = true;
- $id('tool_select').setAttribute('src', `${imgPath}/select_node.svg`);
+ $id('tool_select').setAttribute('src', `select_node.svg`);
this.editor.multiselected = false;
if (elems.length) {
this.editor.selectedElement = elems[0];
}
} else {
setTimeout(() => {
- $id('tool_select').setAttribute('src', `${imgPath}/select.svg`);
+ $id('tool_select').setAttribute('src', `select.svg`);
}, 1000);
}
}
@@ -824,101 +825,75 @@ class TopPanel {
// add Top panel
const template = document.createElement("template");
const { i18next } = this.editor;
- const { imgPath } = this.editor.configObj.curConfig;
// eslint-disable-next-line no-unsanitized/property
template.innerHTML = `
@@ -1050,121 +1000,45 @@ class TopPanel {
this.editor.$container.append(newSeEditorDialog);
newSeEditorDialog.init(i18next);
// register action to top panel buttons
- $id("tool_source").addEventListener(
- "click",
- this.showSourceEditor.bind(this)
- );
- $id("tool_wireframe").addEventListener(
- "click",
- this.clickWireframe.bind(this)
- );
+ $id("tool_source").addEventListener("click", this.showSourceEditor.bind(this));
+ $id("tool_wireframe").addEventListener("click", this.clickWireframe.bind(this));
$id("tool_undo").addEventListener("click", this.clickUndo.bind(this));
$id("tool_redo").addEventListener("click", this.clickRedo.bind(this));
$id("tool_clone").addEventListener("click", this.clickClone.bind(this));
- $id("tool_clone_multi").addEventListener(
- "click",
- this.clickClone.bind(this)
- );
- $id("tool_delete").addEventListener(
- "click",
- this.deleteSelected.bind(this)
- );
- $id("tool_delete_multi").addEventListener(
- "click",
- this.deleteSelected.bind(this)
- );
- $id("tool_move_top").addEventListener(
- "click",
- this.moveToTopSelected.bind(this)
- );
- $id("tool_move_bottom").addEventListener(
- "click",
- this.moveToBottomSelected.bind(this)
- );
+ $id("tool_clone_multi").addEventListener("click", this.clickClone.bind(this));
+ $id("tool_delete").addEventListener("click", this.deleteSelected.bind(this));
+ $id("tool_delete_multi").addEventListener("click", this.deleteSelected.bind(this));
+ $id("tool_move_top").addEventListener("click", this.moveToTopSelected.bind(this));
+ $id("tool_move_bottom").addEventListener("click", this.moveToBottomSelected.bind(this));
$id("tool_topath").addEventListener("click", this.convertToPath.bind(this));
- $id("tool_make_link").addEventListener(
- "click",
- this.makeHyperlink.bind(this)
- );
- $id("tool_make_link_multi").addEventListener(
- "click",
- this.makeHyperlink.bind(this)
- );
- $id("tool_reorient").addEventListener(
- "click",
- this.reorientPath.bind(this)
- );
- $id("tool_group_elements").addEventListener(
- "click",
- this.clickGroup.bind(this)
- );
- $id("tool_position").addEventListener("change", (evt) =>
- this.clickAlignEle.bind(this)(evt)
- );
- $id("tool_align_left").addEventListener("click", () =>
- this.clickAlign.bind(this)("left")
- );
- $id("tool_align_right").addEventListener("click", () =>
- this.clickAlign.bind(this)("right")
- );
- $id("tool_align_center").addEventListener("click", () =>
- this.clickAlign.bind(this)("center")
- );
- $id("tool_align_top").addEventListener("click", () =>
- this.clickAlign.bind(this)("top")
- );
- $id("tool_align_bottom").addEventListener("click", () =>
- this.clickAlign.bind(this)("bottom")
- );
- $id("tool_align_middle").addEventListener("click", () =>
- this.clickAlign.bind(this)("middle")
- );
- $id("tool_node_clone").addEventListener(
- "click",
- this.clonePathNode.bind(this)
- );
- $id("tool_node_delete").addEventListener(
- "click",
- this.deletePathNode.bind(this)
- );
- $id("tool_openclose_path").addEventListener(
- "click",
- this.opencloseSubPath.bind(this)
- );
- $id("tool_add_subpath").addEventListener(
- "click",
- this.addSubPath.bind(this)
- );
- $id("tool_node_link").addEventListener(
- "click",
- this.linkControlPoints.bind(this)
- );
- $id("angle").addEventListener(
- "change",
- this.changeRotationAngle.bind(this)
- );
+ $id("tool_make_link").addEventListener("click", this.makeHyperlink.bind(this));
+ $id("tool_make_link_multi").addEventListener("click", this.makeHyperlink.bind(this));
+ $id("tool_reorient").addEventListener("click", this.reorientPath.bind(this));
+ $id("tool_group_elements").addEventListener("click", this.clickGroup.bind(this));
+ $id("tool_position").addEventListener("change", (evt) => this.clickAlignEle.bind(this)(evt));
+ $id("tool_align_left").addEventListener("click", () => this.clickAlign.bind(this)("left"));
+ $id("tool_align_right").addEventListener("click", () => this.clickAlign.bind(this)("right"));
+ $id("tool_align_center").addEventListener("click", () => this.clickAlign.bind(this)("center"));
+ $id("tool_align_top").addEventListener("click", () => this.clickAlign.bind(this)("top"));
+ $id("tool_align_bottom").addEventListener("click", () => this.clickAlign.bind(this)("bottom"));
+ $id("tool_align_middle").addEventListener("click", () => this.clickAlign.bind(this)("middle"));
+ $id("tool_node_clone").addEventListener("click", this.clonePathNode.bind(this));
+ $id("tool_node_delete").addEventListener("click", this.deletePathNode.bind(this));
+ $id("tool_openclose_path").addEventListener("click", this.opencloseSubPath.bind(this));
+ $id("tool_add_subpath").addEventListener("click", this.addSubPath.bind(this));
+ $id("tool_node_link").addEventListener("click", this.linkControlPoints.bind(this));
+ $id("angle").addEventListener("change", this.changeRotationAngle.bind(this));
$id("blur").addEventListener("change", this.changeBlur.bind(this));
$id("rect_rx").addEventListener("change", this.changeRectRadius.bind(this));
$id("font_size").addEventListener("change", this.changeFontSize.bind(this));
$id("tool_ungroup").addEventListener("click", this.clickGroup.bind(this));
$id("tool_bold").addEventListener("click", this.clickBold.bind(this));
$id("tool_italic").addEventListener("click", this.clickItalic.bind(this));
- $id("tool_text_anchor_start").addEventListener("click", () =>
- this.clickTextAnchor.bind(this)("start")
- );
- $id("tool_text_anchor_middle").addEventListener("click", () =>
- this.clickTextAnchor.bind(this)("middle")
- );
- $id("tool_text_anchor_end").addEventListener("click", () =>
- this.clickTextAnchor.bind(this)("end")
- );
- $id("tool_unlink_use").addEventListener(
- "click",
- this.clickGroup.bind(this)
- );
- $id('image_url').addEventListener('change', (evt) => {
- this.setImageURL(evt.currentTarget.value);
- });
+ $id("tool_text_anchor_start").addEventListener("click", () => this.clickTextAnchor.bind(this)("start"));
+ $id("tool_text_anchor_middle").addEventListener("click", () => this.clickTextAnchor.bind(this)("middle"));
+ $id("tool_text_anchor_end").addEventListener("click", () => this.clickTextAnchor.bind(this)("end"));
+ $id("tool_unlink_use").addEventListener("click", this.clickGroup.bind(this));
+ $id('image_url').addEventListener('change', (evt) => { this.setImageURL(evt.currentTarget.value);});
// all top panel attributes
[