From 3bf54e5a95c051a5ac9793dcf7a7e96b36563907 Mon Sep 17 00:00:00 2001 From: Agriya Dev5 Date: Mon, 24 May 2021 11:39:06 +0530 Subject: [PATCH 01/21] #104 jquery extend change to javascript --- src/svgcanvas/svgcanvas.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/svgcanvas/svgcanvas.js b/src/svgcanvas/svgcanvas.js index bb573e95..74e1c149 100644 --- a/src/svgcanvas/svgcanvas.js +++ b/src/svgcanvas/svgcanvas.js @@ -169,15 +169,16 @@ class SvgCanvas { // Alias Namespace constants // Default configuration options - const curConfig = { + let curConfig = { show_outside_canvas: true, selectNew: true, dimensions: [ 640, 480 ] }; // Update config with new one if given + this.mergeDeep = mergeDeep; if (config) { - $.extend(curConfig, config); + curConfig = this.mergeDeep(curConfig, config); } // Array with width/height of canvas @@ -188,7 +189,6 @@ class SvgCanvas { this.$id = $id; this.$qq = $qq; this.$qa = $qa; - this.mergeDeep = mergeDeep; this.getClosest = getClosest; this.getParents = getParents; /** A storage solution aimed at replacing jQuerys data function. From 78b5ea101076dcce15d4686f479e2d05c3ac03bb Mon Sep 17 00:00:00 2001 From: Agriya Dev5 Date: Mon, 24 May 2021 12:12:26 +0530 Subject: [PATCH 02/21] #104 jquery extend convert changes --- src/svgcanvas/svgcanvas.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/svgcanvas/svgcanvas.js b/src/svgcanvas/svgcanvas.js index 74e1c149..a77639f0 100644 --- a/src/svgcanvas/svgcanvas.js +++ b/src/svgcanvas/svgcanvas.js @@ -322,9 +322,8 @@ class SvgCanvas { opacity: curConfig.initOpacity } }; - - allProperties.text = $.extend(true, {}, allProperties.shape); - $.extend(allProperties.text, { + allProperties.text = this.mergeDeep({}, allProperties.shape); + allProperties.text = this.mergeDeep(allProperties.text, { fill: '#000000', stroke_width: curConfig.text && curConfig.text.stroke_width, font_size: curConfig.text && curConfig.text.font_size, @@ -892,7 +891,7 @@ class SvgCanvas { * @type {module:svgcanvas.ExtensionArgumentObject} * @see {@link module:svgcanvas.PrivateMethods} source for the other methods/properties */ - const argObj = $.extend(canvas.getPrivateMethods(), { + const argObj = canvas.mergeDeep(canvas.getPrivateMethods(), { $: jq, importLocale, svgroot, @@ -904,7 +903,6 @@ class SvgCanvas { if (extObj) { extObj.name = name; } - extensions[name] = extObj; return call('extension_added', extObj); }; From 2a0666aa1c970228b04267a82fe4f7458bbff72c Mon Sep 17 00:00:00 2001 From: Agriya Dev5 Date: Mon, 24 May 2021 12:38:46 +0530 Subject: [PATCH 03/21] #104 extend jquery convert to javascript --- src/editor/ConfigObj.js | 2 -- src/svgcanvas/recalculate.js | 3 ++- src/svgcanvas/svgcanvas.js | 3 ++- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/editor/ConfigObj.js b/src/editor/ConfigObj.js index 72bd5636..94c7c238 100644 --- a/src/editor/ConfigObj.js +++ b/src/editor/ConfigObj.js @@ -402,7 +402,6 @@ export default class ConfigObj { */ const extendOrAdd = (cfgObj, key, val) => { if (cfgObj[key] && typeof cfgObj[key] === 'object') { - // $.extend(true, cfgObj[key], val); cfgObj[key] = mergeDeep(cfgObj[key], val); } else { cfgObj[key] = val; @@ -452,7 +451,6 @@ export default class ConfigObj { } else if (this.defaultConfig[key] && typeof this.defaultConfig[key] === 'object') { this.curConfig[key] = Array.isArray(this.defaultConfig[key]) ? [] : {}; this.curConfig[key] = mergeDeep(this.curConfig[key], val); - // $.extend(true, this.curConfig[key], val); // Merge properties recursively, e.g., on initFill, initStroke objects } else { this.curConfig[key] = val; } diff --git a/src/svgcanvas/recalculate.js b/src/svgcanvas/recalculate.js index 815e8254..796c3927 100644 --- a/src/svgcanvas/recalculate.js +++ b/src/svgcanvas/recalculate.js @@ -239,7 +239,8 @@ export const recalculateDimensions = function (selected) { // if we haven't created an initial array in polygon/polyline/path, then // make a copy of initial values and include the transform if (isNullish(initial)) { - initial = $.extend(true, {}, changes); + const canvas = context_.getCanvas(); + initial = canvas.mergeDeep({}, changes); for (const [ attr, val ] of Object.entries(initial)) { initial[attr] = convertToNum(attr, val); } diff --git a/src/svgcanvas/svgcanvas.js b/src/svgcanvas/svgcanvas.js index a77639f0..dc82a15f 100644 --- a/src/svgcanvas/svgcanvas.js +++ b/src/svgcanvas/svgcanvas.js @@ -480,7 +480,8 @@ class SvgCanvas { getSVGRoot, getStartTransform() { return startTransform; }, setStartTransform(transform) { startTransform = transform; }, - getDataStorage + getDataStorage, + getCanvas() { return canvas; }, } ); this.recalculateDimensions = recalculateDimensions; From d455eef840b7b9e6a018e4512761af9cb3d528f9 Mon Sep 17 00:00:00 2001 From: Agriya Dev5 Date: Mon, 24 May 2021 14:10:24 +0530 Subject: [PATCH 04/21] #104 jquery extend convert to pure javascript --- src/svgcanvas/recalculate.js | 6 ++++-- src/svgcanvas/svg-exec.js | 8 ++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/svgcanvas/recalculate.js b/src/svgcanvas/recalculate.js index 796c3927..bd9da8a0 100644 --- a/src/svgcanvas/recalculate.js +++ b/src/svgcanvas/recalculate.js @@ -16,6 +16,9 @@ import { isIdentity, matrixMultiply, transformPoint, transformListToTransform, hasMatrixTransform } from './math.js'; +import { + mergeDeep +} from '../editor/components/jgraduate/Util.js'; let context_; @@ -239,8 +242,7 @@ export const recalculateDimensions = function (selected) { // if we haven't created an initial array in polygon/polyline/path, then // make a copy of initial values and include the transform if (isNullish(initial)) { - const canvas = context_.getCanvas(); - initial = canvas.mergeDeep({}, changes); + initial = mergeDeep({}, changes); for (const [ attr, val ] of Object.entries(initial)) { initial[attr] = convertToNum(attr, val); } diff --git a/src/svgcanvas/svg-exec.js b/src/svgcanvas/svg-exec.js index e493c5ef..2cc949fd 100644 --- a/src/svgcanvas/svg-exec.js +++ b/src/svgcanvas/svg-exec.js @@ -1,4 +1,3 @@ -/* globals $ */ /** * Tools for svg. * @module svg @@ -670,7 +669,12 @@ export const save = function (opts) { // remove the selected outline before serializing svgContext_.getCanvas().clearSelection(); // Update save options if provided - if (opts) { $.extend(svgContext_.getSvgOption(), opts); } + if (opts) { + const saveOptions = svgContext_.getCanvas().mergeDeep(svgContext_.getSvgOption(), opts); + for (const [ key, value ] of Object.entries(saveOptions)) { + svgContext_.setSvgOption(key, value); + } + } svgContext_.setSvgOption('apply', true); // no need for doctype, see https://jwatt.org/svg/authoring/#doctype-declaration From ed12ea7e7603f0c6724b4ae0326419e78b739f34 Mon Sep 17 00:00:00 2001 From: Agriya Dev5 Date: Mon, 24 May 2021 15:39:57 +0530 Subject: [PATCH 05/21] #104 jquery extend convert to javascript --- src/svgcanvas/utilities.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/svgcanvas/utilities.js b/src/svgcanvas/utilities.js index 1e904615..41448556 100644 --- a/src/svgcanvas/utilities.js +++ b/src/svgcanvas/utilities.js @@ -17,7 +17,7 @@ import { isWebkit, supportsHVLineContainerBBox, supportsPathBBox, supportsXpath, supportsSelectors } from '../common/browser.js'; -import { getClosest } from '../editor/components/jgraduate/Util.js'; +import { getClosest, mergeDeep } from '../editor/components/jgraduate/Util.js'; // String used to encode base64. const KEYSTR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='; @@ -899,7 +899,7 @@ export const convertToPath = function ( const batchCmd = new hstry.BatchCommand('Convert element to Path'); // Any attribute on the element not covered by the passed-in attributes - attrs = $.extend({}, attrs, getExtraAttributesForConvertToPath(elem)); + attrs = mergeDeep(attrs, getExtraAttributesForConvertToPath(elem)); const path = addSVGElementFromJson({ element: 'path', From 8de1746b58c07d0bf8d63536922218e49f34ab8f Mon Sep 17 00:00:00 2001 From: Agriya Dev5 Date: Mon, 24 May 2021 15:46:54 +0530 Subject: [PATCH 06/21] #104 canvas no need so removed --- src/svgcanvas/svgcanvas.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/svgcanvas/svgcanvas.js b/src/svgcanvas/svgcanvas.js index dc82a15f..a77639f0 100644 --- a/src/svgcanvas/svgcanvas.js +++ b/src/svgcanvas/svgcanvas.js @@ -480,8 +480,7 @@ class SvgCanvas { getSVGRoot, getStartTransform() { return startTransform; }, setStartTransform(transform) { startTransform = transform; }, - getDataStorage, - getCanvas() { return canvas; }, + getDataStorage } ); this.recalculateDimensions = recalculateDimensions; From 2ef57a31cee0335fa495485795870fe65a7b75d3 Mon Sep 17 00:00:00 2001 From: Agriya Dev5 Date: Mon, 24 May 2021 16:05:08 +0530 Subject: [PATCH 07/21] #104 jquery convert to javascript changes --- src/svgcanvas/utilities.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/svgcanvas/utilities.js b/src/svgcanvas/utilities.js index 41448556..ce81325a 100644 --- a/src/svgcanvas/utilities.js +++ b/src/svgcanvas/utilities.js @@ -719,7 +719,7 @@ export const getBBox = function (elem) { export const getPathDFromSegments = function (pathSegments) { let d = ''; - $.each(pathSegments, function (j, [ singleChar, pts ]) { + pathSegments.forEach(function([ singleChar, pts ], _j){ d += singleChar; for (let i = 0; i < pts.length; i += 2) { d += (pts[i] + ',' + pts[i + 1]) + ' '; From 38483cc6c479d9cc19fab2986895e76047d0f84a Mon Sep 17 00:00:00 2001 From: Agriya Dev5 Date: Mon, 24 May 2021 16:06:04 +0530 Subject: [PATCH 08/21] #104 globals jquery removed --- src/svgcanvas/utilities.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/svgcanvas/utilities.js b/src/svgcanvas/utilities.js index ce81325a..9de1df1b 100644 --- a/src/svgcanvas/utilities.js +++ b/src/svgcanvas/utilities.js @@ -1,4 +1,3 @@ -/* globals $ */ /** * Miscellaneous utilities. * @module utilities From d69abde06870b0f3722cdfc7b2422872f1ecf93a Mon Sep 17 00:00:00 2001 From: Agriya Dev5 Date: Mon, 24 May 2021 16:39:43 +0530 Subject: [PATCH 09/21] #104 jquery convert to javascript --- src/svgcanvas/path-actions.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/svgcanvas/path-actions.js b/src/svgcanvas/path-actions.js index 8426bc4a..9969efb5 100644 --- a/src/svgcanvas/path-actions.js +++ b/src/svgcanvas/path-actions.js @@ -456,10 +456,9 @@ export const pathActionsMethod = (function () { // else, create a new point, update path element } else { // Checks if current target or parents are #svgcontent - if (!$.contains( - editorContext_.getContainer(), + if (!(editorContext_.getContainer() !== editorContext_.getMouseTarget(evt) && editorContext_.getContainer().contains( editorContext_.getMouseTarget(evt) - )) { + ))) { // Clicked outside canvas, so don't make point return false; } From 37cca800261ad56a29890c52f2b5cdfd0c327ebe Mon Sep 17 00:00:00 2001 From: Agriya Dev5 Date: Mon, 24 May 2021 16:44:43 +0530 Subject: [PATCH 10/21] #104 jquery convert to javascript --- src/editor/extensions/ext-connector/ext-connector.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/editor/extensions/ext-connector/ext-connector.js b/src/editor/extensions/ext-connector/ext-connector.js index 50183c5b..cfc31792 100644 --- a/src/editor/extensions/ext-connector/ext-connector.js +++ b/src/editor/extensions/ext-connector/ext-connector.js @@ -393,7 +393,7 @@ export default { const parents = svgCanvas.getParents(mouseTarget.parentNode); - if ($.inArray(svgcontent, parents) !== -1) { + if (parents.indexOf(svgcontent) !== -1) { // Connectable element // If child of foreignObject, use parent From 5830fed793de730d47a48b24b71f17f6dd7682e7 Mon Sep 17 00:00:00 2001 From: Agriya Dev5 Date: Mon, 24 May 2021 19:46:43 +0530 Subject: [PATCH 11/21] #104 jquery convert to jaascript --- src/editor/extensions/ext-imagelib/index.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/editor/extensions/ext-imagelib/index.js b/src/editor/extensions/ext-imagelib/index.js index 8275bfd0..b296045b 100644 --- a/src/editor/extensions/ext-imagelib/index.js +++ b/src/editor/extensions/ext-imagelib/index.js @@ -1,4 +1,3 @@ -/* globals $ */ const atags = document.querySelectorAll('a'); Array.prototype.forEach.call(atags, function (aEle) { aEle.addEventListener('click', function (event) { @@ -41,10 +40,22 @@ Array.prototype.forEach.call(atags, function (aEle) { }); img.src = href; } else { + const xhr = new XMLHttpRequest(); + xhr.onreadystatechange = function() { + if (xhr.readyState == 4) { + let data = xhr.responseText; + post({ href, data }); + return data; + } else { + return false; + } + }; + xhr.open('GET', href, false); + xhr.send(null); // Do ajax request for image's href value - $.get(href, function (data) { + /* $.get(href, function (data) { post({ href, data }); - }, 'html'); // 'html' is necessary to keep returned data as a string + }, 'html'); */ // 'html' is necessary to keep returned data as a string } return false; }); From 205caea40e4392f7fdf09b588d3c364340fb98be Mon Sep 17 00:00:00 2001 From: Agriya Dev5 Date: Mon, 24 May 2021 20:11:41 +0530 Subject: [PATCH 12/21] #104 lint issue fixed --- src/editor/extensions/ext-connector/ext-connector.js | 2 +- src/svgcanvas/path-actions.js | 1 - src/svgcanvas/recalculate.js | 1 - src/svgcanvas/svgcanvas.js | 1 - 4 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/editor/extensions/ext-connector/ext-connector.js b/src/editor/extensions/ext-connector/ext-connector.js index cfc31792..34a7a76e 100644 --- a/src/editor/extensions/ext-connector/ext-connector.js +++ b/src/editor/extensions/ext-connector/ext-connector.js @@ -30,7 +30,7 @@ export default { const svgEditor = this; const { svgCanvas } = svgEditor; const { getElem, $id, mergeDeep } = svgCanvas; - const { $, svgroot } = S, + const { svgroot } = S, addElem = svgCanvas.addSVGElementFromJson, selManager = S.selectorManager; await loadExtensionTranslation(svgEditor); diff --git a/src/svgcanvas/path-actions.js b/src/svgcanvas/path-actions.js index 9969efb5..dd85f4b9 100644 --- a/src/svgcanvas/path-actions.js +++ b/src/svgcanvas/path-actions.js @@ -1,4 +1,3 @@ -/* globals $ */ /** * Path functionality. * @module path diff --git a/src/svgcanvas/recalculate.js b/src/svgcanvas/recalculate.js index bd9da8a0..11034e39 100644 --- a/src/svgcanvas/recalculate.js +++ b/src/svgcanvas/recalculate.js @@ -1,4 +1,3 @@ -/* globals $ */ /** * Recalculate. * @module recalculate diff --git a/src/svgcanvas/svgcanvas.js b/src/svgcanvas/svgcanvas.js index a77639f0..1457f583 100644 --- a/src/svgcanvas/svgcanvas.js +++ b/src/svgcanvas/svgcanvas.js @@ -1,4 +1,3 @@ -/* globals $ */ /** * Numerous tools for working with the editor's "canvas". * @module svgcanvas From deafa04d2ef2de5c4fd0f3db5a7f57588820daf8 Mon Sep 17 00:00:00 2001 From: Agriya Dev5 Date: Tue, 25 May 2021 12:54:59 +0530 Subject: [PATCH 13/21] #104 jquery convert as javascript --- .../extensions/ext-server_opensave/ext-php_savefile.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/editor/extensions/ext-server_opensave/ext-php_savefile.js b/src/editor/extensions/ext-server_opensave/ext-php_savefile.js index 9284b7d0..48564e47 100644 --- a/src/editor/extensions/ext-server_opensave/ext-php_savefile.js +++ b/src/editor/extensions/ext-server_opensave/ext-php_savefile.js @@ -22,7 +22,15 @@ export default { const svg = '\n' + data, filename = getFileNameFromTitle(); - $.post(saveSvgAction, { output_svg: svg, filename }); + // $.post(saveSvgAction, { output_svg: svg, filename }); + let postData = { output_svg: svg, filename }; + fetch(saveSvgAction, { + method: "POST", + body: JSON.stringify(postData) + }).then( (res) => { + return res; + }) + .catch( (error) => { console.info('error =', error);}); } }); } From a8400dfd01b217b32fe485661792e535a1aaf4cf Mon Sep 17 00:00:00 2001 From: Agriya Dev5 Date: Tue, 25 May 2021 15:24:21 +0530 Subject: [PATCH 14/21] #104 unsed variable removed --- src/editor/extensions/ext-server_opensave/ext-php_savefile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/editor/extensions/ext-server_opensave/ext-php_savefile.js b/src/editor/extensions/ext-server_opensave/ext-php_savefile.js index 48564e47..b6a188ec 100644 --- a/src/editor/extensions/ext-server_opensave/ext-php_savefile.js +++ b/src/editor/extensions/ext-server_opensave/ext-php_savefile.js @@ -3,7 +3,7 @@ export default { name: 'php_savefile', - init ({ $ }) { + init () { const svgEditor = this; const { canvas: svgCanvas From 9e8cce86f963c6c54424d4398d20d8bdc56a9aff Mon Sep 17 00:00:00 2001 From: Agriya Dev5 Date: Tue, 25 May 2021 16:07:00 +0530 Subject: [PATCH 15/21] #104 clearselection undefind issue fixed --- src/svgcanvas/selected-elem.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/svgcanvas/selected-elem.js b/src/svgcanvas/selected-elem.js index 79bd7bd3..f052ad43 100644 --- a/src/svgcanvas/selected-elem.js +++ b/src/svgcanvas/selected-elem.js @@ -261,7 +261,7 @@ export const cloneSelectedElements = function (x, y) { } // use slice to quickly get the subset of elements we need const copiedElements = selectedElements.slice(0, i); - this.clearSelection(true); + elementContext_.clearSelection(true); // note that we loop in the reverse way because of the way elements are added // to the selectedElements array (top-first) const drawing = elementContext_.getDrawing(); From ea308c25bf9b7130c597f6154aa49cd61ed91d99 Mon Sep 17 00:00:00 2001 From: Agriya Dev5 Date: Tue, 25 May 2021 17:21:54 +0530 Subject: [PATCH 16/21] #104 unwrap changes --- src/svgcanvas/selected-elem.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/svgcanvas/selected-elem.js b/src/svgcanvas/selected-elem.js index f052ad43..c5980626 100644 --- a/src/svgcanvas/selected-elem.js +++ b/src/svgcanvas/selected-elem.js @@ -722,7 +722,12 @@ export const convertToGroup = function (elem) { y: svg.getAttribute('y'), }; - $(elem.firstChild.firstChild).unwrap(); + // $(elem.firstChild.firstChild).unwrap(); + const firstChild = elem.firstChild.firstChild; + if (firstChild) { + // eslint-disable-next-line no-unsanitized/property + firstChild.outerHTML = firstChild.innerHTML; + } dataStorage.remove(elem, 'gsvg'); const tlist = getTransformList(elem); From 935aaec34409e6c90ac10ed8e8cee71b32d38547 Mon Sep 17 00:00:00 2001 From: Agriya Dev5 Date: Tue, 25 May 2021 19:58:25 +0530 Subject: [PATCH 17/21] #104 unused variable removed --- src/svgcanvas/selected-elem.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/svgcanvas/selected-elem.js b/src/svgcanvas/selected-elem.js index c5980626..7a8ece8f 100644 --- a/src/svgcanvas/selected-elem.js +++ b/src/svgcanvas/selected-elem.js @@ -1,4 +1,3 @@ -/* globals $ */ /** * Tools for SVG selected element operation. * @module selected-elem From adca890d17203d7357ca2390ae688bc209317e4a Mon Sep 17 00:00:00 2001 From: Agriya Dev5 Date: Thu, 27 May 2021 12:01:13 +0530 Subject: [PATCH 18/21] #104 indexof change to includes --- src/editor/extensions/ext-connector/ext-connector.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/editor/extensions/ext-connector/ext-connector.js b/src/editor/extensions/ext-connector/ext-connector.js index 34a7a76e..b9f05266 100644 --- a/src/editor/extensions/ext-connector/ext-connector.js +++ b/src/editor/extensions/ext-connector/ext-connector.js @@ -392,8 +392,7 @@ export default { const mouseTarget = e.target; const parents = svgCanvas.getParents(mouseTarget.parentNode); - - if (parents.indexOf(svgcontent) !== -1) { + if (parents.includes(svgcontent)) { // Connectable element // If child of foreignObject, use parent From 1abd55a6986c99a83050d2436872724d493c5711 Mon Sep 17 00:00:00 2001 From: Agriya Dev5 Date: Thu, 27 May 2021 12:46:01 +0530 Subject: [PATCH 19/21] #104 XMLHttpRequest change to fetch --- .../extensions/ext-imagelib/ext-imagelib.js | 6 ++--- src/editor/extensions/ext-imagelib/index.js | 23 +++++++------------ 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/editor/extensions/ext-imagelib/ext-imagelib.js b/src/editor/extensions/ext-imagelib/ext-imagelib.js index f49d6b06..6564ed2f 100644 --- a/src/editor/extensions/ext-imagelib/ext-imagelib.js +++ b/src/editor/extensions/ext-imagelib/ext-imagelib.js @@ -425,7 +425,7 @@ export default { const header = document.createElement('h1'); browser.prepend(header); header.textContent = allLibs; - header.setAttribute('style', `position: absolute;top: 0;left: 0;width: 100%;`); + header.setAttribute('style', `position: absolute;top: 0px;left: 0px;width: 100%;`); const button = document.createElement('button'); // eslint-disable-next-line max-len @@ -437,10 +437,10 @@ export default { button.addEventListener('touchend', function () { $id("imgbrowse_holder").style.display = 'none'; }); - button.setAttribute('style', `position: absolute;top: 5;right: -10;`); + button.setAttribute('style', `position: absolute;top: 5px;right: 10px;`); const leftBlock = document.createElement('span'); - leftBlock.setAttribute('style', `position: absolute;top: 5;left: 10;`); + leftBlock.setAttribute('style', `position: absolute;top: 5px;left: 10px;display: inline-flex;`); browser.appendChild(leftBlock); const back = document.createElement('button'); diff --git a/src/editor/extensions/ext-imagelib/index.js b/src/editor/extensions/ext-imagelib/index.js index b296045b..91bbb0cb 100644 --- a/src/editor/extensions/ext-imagelib/index.js +++ b/src/editor/extensions/ext-imagelib/index.js @@ -40,22 +40,15 @@ Array.prototype.forEach.call(atags, function (aEle) { }); img.src = href; } else { - const xhr = new XMLHttpRequest(); - xhr.onreadystatechange = function() { - if (xhr.readyState == 4) { - let data = xhr.responseText; - post({ href, data }); - return data; - } else { - return false; - } - }; - xhr.open('GET', href, false); - xhr.send(null); - // Do ajax request for image's href value - /* $.get(href, function (data) { + fetch(href) + .then( (r) => r.text()) + // eslint-disable-next-line promise/always-return + .then( (data) => { post({ href, data }); - }, 'html'); */ // 'html' is necessary to keep returned data as a string + return data; + }) + // eslint-disable-next-line no-console + .catch( (error) => console.log(error)); } return false; }); From f3ee6379036c40f4bee7fb2207487069601da948 Mon Sep 17 00:00:00 2001 From: Agriya Dev5 Date: Thu, 27 May 2021 14:17:01 +0530 Subject: [PATCH 20/21] #104 deparam changed ref: https://www.sitepoint.com/get-url-parameters-with-javascript/ --- licenseInfo.json | 3 +-- package.json | 1 - src/editor/ConfigObj.js | 8 +++++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/licenseInfo.json b/licenseInfo.json index 9573bfe8..e71fa2f1 100644 --- a/licenseInfo.json +++ b/licenseInfo.json @@ -7,8 +7,7 @@ "stackblur-canvas", "regenerator-runtime", "core-js-bundle", - "underscore", - "deparam" + "underscore" ], "filesByLicense": { "(MIT OR GPL-2.0)": ["src/editor/jquerybbq/jquery.bbq.min.js"], diff --git a/package.json b/package.json index b39a795f..a30906e5 100644 --- a/package.json +++ b/package.json @@ -96,7 +96,6 @@ "@web/dev-server-rollup": "0.3.4", "canvg": "3.0.7", "core-js": "3.12.1", - "deparam": "1.0.5", "elix": "15.0.0", "i18next": "20.3.0", "jquery": "3.6.0", diff --git a/src/editor/ConfigObj.js b/src/editor/ConfigObj.js index 94c7c238..c29a5e34 100644 --- a/src/editor/ConfigObj.js +++ b/src/editor/ConfigObj.js @@ -1,5 +1,4 @@ // eslint-disable-next-line node/no-unpublished-import -import deparam from 'deparam'; import { mergeDeep } from './components/jgraduate/Util.js'; /** @@ -240,9 +239,12 @@ export default class ConfigObj { */ loadFromURL () { const { search, searchParams } = new URL(location); - if (search) { - this.urldata = deparam(searchParams.toString()); + this.urldata = {}; + const entries = searchParams.entries(); + for(const entry of entries) { + this.urldata[entry[0]] = entry[1]; + } [ 'initStroke', 'initFill' ].forEach((prop) => { if (searchParams.has(`${prop}[color]`)) { From 5c5cf5ddd1331283a1bce19ca9c44b0a14fa6583 Mon Sep 17 00:00:00 2001 From: Agriya Dev5 Date: Thu, 27 May 2021 16:25:38 +0530 Subject: [PATCH 21/21] #104 undefined issue fixed --- src/editor/ConfigObj.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/editor/ConfigObj.js b/src/editor/ConfigObj.js index c29a5e34..f49a7ac8 100644 --- a/src/editor/ConfigObj.js +++ b/src/editor/ConfigObj.js @@ -238,6 +238,7 @@ export default class ConfigObj { * @returns {void} */ loadFromURL () { + const self = this; const { search, searchParams } = new URL(location); if (search) { this.urldata = {}; @@ -276,8 +277,8 @@ export default class ConfigObj { // ways with other script resources [ 'userExtensions', 'imgPath' ] .forEach(function (pathConfig) { - if (this.urldata[pathConfig]) { - delete this.urldata[pathConfig]; + if (self.urldata[pathConfig]) { + delete self.urldata[pathConfig]; } });