diff --git a/src/editor/ConfigObj.js b/src/editor/ConfigObj.js index 2c5927e6..2d292a94 100644 --- a/src/editor/ConfigObj.js +++ b/src/editor/ConfigObj.js @@ -462,10 +462,10 @@ export default class ConfigObj { * @returns {string|void} If val is missing or falsey and `mayBeEmpty` is not set, the * value of the previously stored preference will be returned. * @todo Review whether any remaining existing direct references to - * getting `curPrefs` can be changed to use `svgEditor.pref()` getting to ensure + * getting `curPrefs` can be changed to use `svgEditor.configObj.pref()` getting to ensure * `defaultPrefs` fallback (also for sake of `allowInitialUserOverride`); * specifically, `bkgd_color` could be changed so that the pref dialog has a - * button to auto-calculate background, but otherwise uses `svgEditor.pref()` to + * button to auto-calculate background, but otherwise uses `svgEditor.configObj.pref()` to * be able to get default prefs or overridable settings */ pref (key, val, mayBeEmpty) { diff --git a/src/editor/extensions/ext-arrows/ext-arrows.js b/src/editor/extensions/ext-arrows/ext-arrows.js index 4bba6c06..32c259e1 100644 --- a/src/editor/extensions/ext-arrows/ext-arrows.js +++ b/src/editor/extensions/ext-arrows/ext-arrows.js @@ -23,7 +23,7 @@ export default { name: 'arrows', async init (S) { const svgEditor = this; - const strings = await loadExtensionTranslation(svgEditor.pref('lang')); + const strings = await loadExtensionTranslation(svgEditor.configObj.pref('lang')); const {svgCanvas} = svgEditor; const addElem = svgCanvas.addSVGElementFromJson, diff --git a/src/editor/extensions/ext-closepath/ext-closepath.js b/src/editor/extensions/ext-closepath/ext-closepath.js index 4e690c1b..79bcc14c 100644 --- a/src/editor/extensions/ext-closepath/ext-closepath.js +++ b/src/editor/extensions/ext-closepath/ext-closepath.js @@ -25,7 +25,7 @@ export default { name: 'closepath', async init ({importLocale, $}) { const svgEditor = this; - const strings = await loadExtensionTranslation(svgEditor.pref('lang')); + const strings = await loadExtensionTranslation(svgEditor.configObj.pref('lang')); let selElems; const updateButton = function (path) { const seglist = path.pathSegList, diff --git a/src/editor/extensions/ext-connector/ext-connector.js b/src/editor/extensions/ext-connector/ext-connector.js index 3571a785..5215040a 100644 --- a/src/editor/extensions/ext-connector/ext-connector.js +++ b/src/editor/extensions/ext-connector/ext-connector.js @@ -356,7 +356,7 @@ export default { } } }]; - const strings = await loadExtensionTranslation(svgEditor.pref('lang')); + const strings = await loadExtensionTranslation(svgEditor.configObj.pref('lang')); return { /** @todo JFH special flag */ newUI: true, diff --git a/src/editor/extensions/ext-eyedropper/ext-eyedropper.js b/src/editor/extensions/ext-eyedropper/ext-eyedropper.js index d4a03ddd..d1f53ad7 100644 --- a/src/editor/extensions/ext-eyedropper/ext-eyedropper.js +++ b/src/editor/extensions/ext-eyedropper/ext-eyedropper.js @@ -23,7 +23,7 @@ export default { name: 'eyedropper', async init (S) { const svgEditor = this; - const strings = await loadExtensionTranslation(svgEditor.pref('lang')); + const strings = await loadExtensionTranslation(svgEditor.configObj.pref('lang')); const {$, ChangeElementCommand} = S, // , svgcontent, // svgdoc = S.svgroot.parentNode.ownerDocument, {svgCanvas} = svgEditor, diff --git a/src/editor/extensions/ext-foreignobject/ext-foreignobject.js b/src/editor/extensions/ext-foreignobject/ext-foreignobject.js index bfe98e32..5a28bd53 100644 --- a/src/editor/extensions/ext-foreignobject/ext-foreignobject.js +++ b/src/editor/extensions/ext-foreignobject/ext-foreignobject.js @@ -31,7 +31,7 @@ export default { // addElem = svgCanvas.addSVGElementFromJson, svgdoc = S.svgroot.parentNode.ownerDocument; - const strings = await loadExtensionTranslation(svgEditor.pref('lang')); + const strings = await loadExtensionTranslation(svgEditor.configObj.pref('lang')); const properlySourceSizeTextArea = function () { // TODO: remove magic numbers here and get values from CSS diff --git a/src/editor/extensions/ext-grid/ext-grid.js b/src/editor/extensions/ext-grid/ext-grid.js index ac01caf4..e869038d 100644 --- a/src/editor/extensions/ext-grid/ext-grid.js +++ b/src/editor/extensions/ext-grid/ext-grid.js @@ -23,7 +23,7 @@ export default { name: 'grid', async init ({$, NS, getTypeMap}) { const svgEditor = this; - const strings = await loadExtensionTranslation(svgEditor.pref('lang')); + const strings = await loadExtensionTranslation(svgEditor.configObj.pref('lang')); const {svgCanvas} = svgEditor; const svgdoc = document.getElementById('svgcanvas').ownerDocument, {assignAttributes} = svgCanvas, diff --git a/src/editor/extensions/ext-helloworld/ext-helloworld.js b/src/editor/extensions/ext-helloworld/ext-helloworld.js index a4b7d86c..8425a1a0 100644 --- a/src/editor/extensions/ext-helloworld/ext-helloworld.js +++ b/src/editor/extensions/ext-helloworld/ext-helloworld.js @@ -29,7 +29,7 @@ export default { name: 'helloworld', async init ({$, importLocale}) { const svgEditor = this; - const strings = await loadExtensionTranslation(svgEditor.pref('lang')); + const strings = await loadExtensionTranslation(svgEditor.configObj.pref('lang')); const {svgCanvas} = svgEditor; return { name: strings.name, diff --git a/src/editor/extensions/ext-imagelib/ext-imagelib.js b/src/editor/extensions/ext-imagelib/ext-imagelib.js index e9931c16..99deaf88 100644 --- a/src/editor/extensions/ext-imagelib/ext-imagelib.js +++ b/src/editor/extensions/ext-imagelib/ext-imagelib.js @@ -23,7 +23,7 @@ export default { name: 'imagelib', async init ({$, decode64, dropXMLInternalSubset}) { const svgEditor = this; - const imagelibStrings = await loadExtensionTranslation(svgEditor.pref('lang')); + const imagelibStrings = await loadExtensionTranslation(svgEditor.configObj.pref('lang')); const {uiStrings, canvas: svgCanvas} = svgEditor; diff --git a/src/editor/extensions/ext-markers/ext-markers.js b/src/editor/extensions/ext-markers/ext-markers.js index cf54822b..b47cf795 100644 --- a/src/editor/extensions/ext-markers/ext-markers.js +++ b/src/editor/extensions/ext-markers/ext-markers.js @@ -45,7 +45,7 @@ export default { name: 'markers', async init (S) { const svgEditor = this; - const strings = await loadExtensionTranslation(svgEditor.pref('lang')); + const strings = await loadExtensionTranslation(svgEditor.configObj.pref('lang')); const {$} = S; const {svgCanvas} = svgEditor; const // {svgcontent} = S, diff --git a/src/editor/extensions/ext-mathjax/ext-mathjax.js b/src/editor/extensions/ext-mathjax/ext-mathjax.js index 6d5d8e0a..87ba5a61 100644 --- a/src/editor/extensions/ext-mathjax/ext-mathjax.js +++ b/src/editor/extensions/ext-mathjax/ext-mathjax.js @@ -24,7 +24,7 @@ export default { name: 'mathjax', async init ({$}) { const svgEditor = this; - const strings = await loadExtensionTranslation(svgEditor.pref('lang')); + const strings = await loadExtensionTranslation(svgEditor.configObj.pref('lang')); const {svgCanvas} = svgEditor; // Configuration of the MathJax extention. diff --git a/src/editor/extensions/ext-panning/ext-panning.js b/src/editor/extensions/ext-panning/ext-panning.js index 9b96148c..d1f84b34 100644 --- a/src/editor/extensions/ext-panning/ext-panning.js +++ b/src/editor/extensions/ext-panning/ext-panning.js @@ -26,7 +26,7 @@ export default { name: 'panning', async init ({importLocale}) { const svgEditor = this; - const strings = await loadExtensionTranslation(svgEditor.pref('lang')); + const strings = await loadExtensionTranslation(svgEditor.configObj.pref('lang')); const {svgCanvas} = svgEditor; const buttons = [{ id: 'ext-panning', diff --git a/src/editor/extensions/ext-placemark/ext-placemark.js b/src/editor/extensions/ext-placemark/ext-placemark.js index 807634a6..c5f59760 100644 --- a/src/editor/extensions/ext-placemark/ext-placemark.js +++ b/src/editor/extensions/ext-placemark/ext-placemark.js @@ -35,7 +35,7 @@ export default { // newFOG, newFOGParent, newDef, newImageName, newMaskID, // undoCommand = 'Not image', // modeChangeG, ccZoom, wEl, hEl, wOffset, hOffset, ccRgbEl, brushW, brushH; - const strings = await loadExtensionTranslation(svgEditor.pref('lang')); + const strings = await loadExtensionTranslation(svgEditor.configObj.pref('lang')); const markerTypes = { nomarker: {}, forwardslash: diff --git a/src/editor/extensions/ext-polygon/ext-polygon.js b/src/editor/extensions/ext-polygon/ext-polygon.js index b22ebd79..9d3c1766 100644 --- a/src/editor/extensions/ext-polygon/ext-polygon.js +++ b/src/editor/extensions/ext-polygon/ext-polygon.js @@ -26,7 +26,7 @@ export default { const {$} = S, // {svgcontent} // addElem = svgCanvas.addSVGElementFromJson, editingitex = false; - const strings = await loadExtensionTranslation(svgEditor.pref('lang')); + const strings = await loadExtensionTranslation(svgEditor.configObj.pref('lang')); let selElems, // svgdoc = S.svgroot.parentNode.ownerDocument, // newFOG, newFOGParent, newDef, newImageName, newMaskID, modeChangeG, diff --git a/src/editor/extensions/ext-server_moinsave/ext-server_moinsave.js b/src/editor/extensions/ext-server_moinsave/ext-server_moinsave.js index 88f85a23..a4482175 100644 --- a/src/editor/extensions/ext-server_moinsave/ext-server_moinsave.js +++ b/src/editor/extensions/ext-server_moinsave/ext-server_moinsave.js @@ -25,7 +25,7 @@ export default { name: 'server_moinsave', async init ({$, encode64, importLocale}) { const svgEditor = this; - const strings = await loadExtensionTranslation(svgEditor.pref('lang')); + const strings = await loadExtensionTranslation(svgEditor.configObj.pref('lang')); const {svgCanvas} = svgEditor; const saveSvgAction = '/+modify'; diff --git a/src/editor/extensions/ext-server_opensave/ext-server_opensave.js b/src/editor/extensions/ext-server_opensave/ext-server_opensave.js index 5310aca4..51c437c7 100644 --- a/src/editor/extensions/ext-server_opensave/ext-server_opensave.js +++ b/src/editor/extensions/ext-server_opensave/ext-server_opensave.js @@ -24,7 +24,7 @@ export default { name: 'server_opensave', async init ({$, decode64, encode64}) { const svgEditor = this; - const strings = await loadExtensionTranslation(svgEditor.pref('lang')); + const strings = await loadExtensionTranslation(svgEditor.configObj.pref('lang')); const { curConfig: { avoidClientSide, // Deprecated diff --git a/src/editor/extensions/ext-star/ext-star.js b/src/editor/extensions/ext-star/ext-star.js index 2d0a5292..8be4dff3 100644 --- a/src/editor/extensions/ext-star/ext-star.js +++ b/src/editor/extensions/ext-star/ext-star.js @@ -35,7 +35,7 @@ export default { // newFOG, newFOGParent, newDef, newImageName, newMaskID, // undoCommand = 'Not image', // modeChangeG, ccZoom, wEl, hEl, wOffset, hOffset, ccRgbEl, brushW, brushH; - const strings = await loadExtensionTranslation(svgEditor.pref('lang')); + const strings = await loadExtensionTranslation(svgEditor.configObj.pref('lang')); /** * diff --git a/src/editor/extensions/ext-webappfind/ext-webappfind.js b/src/editor/extensions/ext-webappfind/ext-webappfind.js index ac4831a1..946f6813 100644 --- a/src/editor/extensions/ext-webappfind/ext-webappfind.js +++ b/src/editor/extensions/ext-webappfind/ext-webappfind.js @@ -22,7 +22,7 @@ export default { name: 'webappfind', async init ({$}) { const svgEditor = this; - const strings = await loadExtensionTranslation(svgEditor.pref('lang')); + const strings = await loadExtensionTranslation(svgEditor.configObj.pref('lang')); const saveMessage = 'save', readMessage = 'read', excludedMessages = [readMessage, saveMessage]; diff --git a/src/editor/panels/TopPanelHandlers.js b/src/editor/panels/TopPanelHandlers.js index cffddb3b..0366a0b1 100644 --- a/src/editor/panels/TopPanelHandlers.js +++ b/src/editor/panels/TopPanelHandlers.js @@ -411,13 +411,13 @@ class TopPanelHandlers { if (attr !== 'id' && attr !== 'class') { if (isNaN(val)) { val = this.svgCanvas.convertToNum(attr, val); - } else if (this.configObj.curConfig.baseUnit !== 'px') { + } else if (this.editor.configObj.curConfig.baseUnit !== 'px') { // Convert unitless value to one with given unit const unitData = getTypeMap(); if (this.selectedElement[attr] || this.svgCanvas.getMode() === 'pathedit' || attr === 'x' || attr === 'y') { - val *= unitData[this.configObj.curConfig.baseUnit]; + val *= unitData[this.editor.configObj.curConfig.baseUnit]; } } } diff --git a/src/editor/svgedit.js b/src/editor/svgedit.js index 1508cd7a..c34a5463 100644 --- a/src/editor/svgedit.js +++ b/src/editor/svgedit.js @@ -88,13 +88,13 @@ class Editor { this.customExportImage = false; this.customExportPDF = false; this.configObj = new ConfigObj(this); - this.pref = this.configObj.pref.bind(this.configObj); + this.configObj.pref = this.configObj.pref.bind(this.configObj); this.setConfig = this.configObj.setConfig.bind(this.configObj); this.callbacks = []; this.curContext = null; this.exportWindowName = null; this.docprops = false; - this.preferences = false; + this.configObj.preferences = false; this.canvMenu = null; // eslint-disable-next-line max-len this.goodLangs = ['ar', 'cs', 'de', 'en', 'es', 'fa', 'fr', 'fy', 'hi', 'it', 'ja', 'nl', 'pl', 'pt-BR', 'ro', 'ru', 'sk', 'sl', 'zh-CN', 'zh-TW']; @@ -349,7 +349,7 @@ class Editor { * @returns {Promise} Resolves to result of {@link module:locale.readLang} */ async extAndLocaleFunc () { - const {langParam, langData} = await this.putLocale(this.pref('lang'), this.goodLangs); + const {langParam, langData} = await this.putLocale(this.configObj.pref('lang'), this.goodLangs); await this.setLang(langParam, langData); $id('svg_container').style.visibility = 'visible'; @@ -589,7 +589,7 @@ class Editor { this.svgCanvas.bind('extension_added', this.extAdded.bind(this)); this.svgCanvas.textActions.setInputElem($('#text')[0]); - this.setBackground(this.pref('bkgd_color'), this.pref('bkgd_url')); + this.setBackground(this.configObj.pref('bkgd_color'), this.configObj.pref('bkgd_url')); // update resolution option with actual resolution const res = this.svgCanvas.getResolution(); @@ -601,7 +601,7 @@ class Editor { $('#se-img-prop').attr('title', this.svgCanvas.getDocumentTitle()); $('#se-img-prop').attr('width', res.w); $('#se-img-prop').attr('height', res.h); - $('#se-img-prop').attr('save', this.pref('img_save')); + $('#se-img-prop').attr('save', this.configObj.pref('img_save')); // Lose focus for select elements when changed (Allows keyboard shortcuts to work better) $('select').change((evt) => { $(evt.currentTarget).blur(); }); @@ -1197,7 +1197,7 @@ class Editor { // Alert will only appear the first time saved OR the // first time the bug is encountered - let done = this.pref('save_notice_done'); + let done = this.configObj.pref('save_notice_done'); if (done !== 'all') { let note = this.uiStrings.notification.saveFromBrowser.replace('%s', 'SVG'); @@ -1206,13 +1206,13 @@ class Editor { if (svg.includes('