commit
9dd0b8e639
|
@ -7,8 +7,7 @@
|
||||||
"stackblur-canvas",
|
"stackblur-canvas",
|
||||||
"regenerator-runtime",
|
"regenerator-runtime",
|
||||||
"core-js-bundle",
|
"core-js-bundle",
|
||||||
"underscore",
|
"underscore"
|
||||||
"deparam"
|
|
||||||
],
|
],
|
||||||
"filesByLicense": {
|
"filesByLicense": {
|
||||||
"(MIT OR GPL-2.0)": ["src/editor/jquerybbq/jquery.bbq.min.js"],
|
"(MIT OR GPL-2.0)": ["src/editor/jquerybbq/jquery.bbq.min.js"],
|
||||||
|
|
|
@ -96,7 +96,6 @@
|
||||||
"@web/dev-server-rollup": "0.3.4",
|
"@web/dev-server-rollup": "0.3.4",
|
||||||
"canvg": "3.0.7",
|
"canvg": "3.0.7",
|
||||||
"core-js": "3.12.1",
|
"core-js": "3.12.1",
|
||||||
"deparam": "1.0.5",
|
|
||||||
"elix": "15.0.0",
|
"elix": "15.0.0",
|
||||||
"i18next": "20.3.0",
|
"i18next": "20.3.0",
|
||||||
"jquery": "3.6.0",
|
"jquery": "3.6.0",
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
// eslint-disable-next-line node/no-unpublished-import
|
// eslint-disable-next-line node/no-unpublished-import
|
||||||
import deparam from 'deparam';
|
|
||||||
import { mergeDeep } from './components/jgraduate/Util.js';
|
import { mergeDeep } from './components/jgraduate/Util.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -239,10 +238,14 @@ export default class ConfigObj {
|
||||||
* @returns {void}
|
* @returns {void}
|
||||||
*/
|
*/
|
||||||
loadFromURL () {
|
loadFromURL () {
|
||||||
|
const self = this;
|
||||||
const { search, searchParams } = new URL(location);
|
const { search, searchParams } = new URL(location);
|
||||||
|
|
||||||
if (search) {
|
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) => {
|
[ 'initStroke', 'initFill' ].forEach((prop) => {
|
||||||
if (searchParams.has(`${prop}[color]`)) {
|
if (searchParams.has(`${prop}[color]`)) {
|
||||||
|
@ -274,8 +277,8 @@ export default class ConfigObj {
|
||||||
// ways with other script resources
|
// ways with other script resources
|
||||||
[ 'userExtensions', 'imgPath' ]
|
[ 'userExtensions', 'imgPath' ]
|
||||||
.forEach(function (pathConfig) {
|
.forEach(function (pathConfig) {
|
||||||
if (this.urldata[pathConfig]) {
|
if (self.urldata[pathConfig]) {
|
||||||
delete this.urldata[pathConfig];
|
delete self.urldata[pathConfig];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -402,7 +405,6 @@ export default class ConfigObj {
|
||||||
*/
|
*/
|
||||||
const extendOrAdd = (cfgObj, key, val) => {
|
const extendOrAdd = (cfgObj, key, val) => {
|
||||||
if (cfgObj[key] && typeof cfgObj[key] === 'object') {
|
if (cfgObj[key] && typeof cfgObj[key] === 'object') {
|
||||||
// $.extend(true, cfgObj[key], val);
|
|
||||||
cfgObj[key] = mergeDeep(cfgObj[key], val);
|
cfgObj[key] = mergeDeep(cfgObj[key], val);
|
||||||
} else {
|
} else {
|
||||||
cfgObj[key] = val;
|
cfgObj[key] = val;
|
||||||
|
@ -452,7 +454,6 @@ export default class ConfigObj {
|
||||||
} else if (this.defaultConfig[key] && typeof this.defaultConfig[key] === 'object') {
|
} else if (this.defaultConfig[key] && typeof this.defaultConfig[key] === 'object') {
|
||||||
this.curConfig[key] = Array.isArray(this.defaultConfig[key]) ? [] : {};
|
this.curConfig[key] = Array.isArray(this.defaultConfig[key]) ? [] : {};
|
||||||
this.curConfig[key] = mergeDeep(this.curConfig[key], val);
|
this.curConfig[key] = mergeDeep(this.curConfig[key], val);
|
||||||
// $.extend(true, this.curConfig[key], val); // Merge properties recursively, e.g., on initFill, initStroke objects
|
|
||||||
} else {
|
} else {
|
||||||
this.curConfig[key] = val;
|
this.curConfig[key] = val;
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ export default {
|
||||||
const svgEditor = this;
|
const svgEditor = this;
|
||||||
const { svgCanvas } = svgEditor;
|
const { svgCanvas } = svgEditor;
|
||||||
const { getElem, $id, mergeDeep } = svgCanvas;
|
const { getElem, $id, mergeDeep } = svgCanvas;
|
||||||
const { $, svgroot } = S,
|
const { svgroot } = S,
|
||||||
addElem = svgCanvas.addSVGElementFromJson,
|
addElem = svgCanvas.addSVGElementFromJson,
|
||||||
selManager = S.selectorManager;
|
selManager = S.selectorManager;
|
||||||
await loadExtensionTranslation(svgEditor);
|
await loadExtensionTranslation(svgEditor);
|
||||||
|
@ -392,8 +392,7 @@ export default {
|
||||||
const mouseTarget = e.target;
|
const mouseTarget = e.target;
|
||||||
|
|
||||||
const parents = svgCanvas.getParents(mouseTarget.parentNode);
|
const parents = svgCanvas.getParents(mouseTarget.parentNode);
|
||||||
|
if (parents.includes(svgcontent)) {
|
||||||
if ($.inArray(svgcontent, parents) !== -1) {
|
|
||||||
// Connectable element
|
// Connectable element
|
||||||
|
|
||||||
// If child of foreignObject, use parent
|
// If child of foreignObject, use parent
|
||||||
|
|
|
@ -425,7 +425,7 @@ export default {
|
||||||
const header = document.createElement('h1');
|
const header = document.createElement('h1');
|
||||||
browser.prepend(header);
|
browser.prepend(header);
|
||||||
header.textContent = allLibs;
|
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');
|
const button = document.createElement('button');
|
||||||
// eslint-disable-next-line max-len
|
// eslint-disable-next-line max-len
|
||||||
|
@ -437,10 +437,10 @@ export default {
|
||||||
button.addEventListener('touchend', function () {
|
button.addEventListener('touchend', function () {
|
||||||
$id("imgbrowse_holder").style.display = 'none';
|
$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');
|
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);
|
browser.appendChild(leftBlock);
|
||||||
|
|
||||||
const back = document.createElement('button');
|
const back = document.createElement('button');
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/* globals $ */
|
|
||||||
const atags = document.querySelectorAll('a');
|
const atags = document.querySelectorAll('a');
|
||||||
Array.prototype.forEach.call(atags, function (aEle) {
|
Array.prototype.forEach.call(atags, function (aEle) {
|
||||||
aEle.addEventListener('click', function (event) {
|
aEle.addEventListener('click', function (event) {
|
||||||
|
@ -41,10 +40,15 @@ Array.prototype.forEach.call(atags, function (aEle) {
|
||||||
});
|
});
|
||||||
img.src = href;
|
img.src = href;
|
||||||
} else {
|
} else {
|
||||||
// Do ajax request for image's href value
|
fetch(href)
|
||||||
$.get(href, function (data) {
|
.then( (r) => r.text())
|
||||||
|
// eslint-disable-next-line promise/always-return
|
||||||
|
.then( (data) => {
|
||||||
post({ href, 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;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'php_savefile',
|
name: 'php_savefile',
|
||||||
init ({ $ }) {
|
init () {
|
||||||
const svgEditor = this;
|
const svgEditor = this;
|
||||||
const {
|
const {
|
||||||
canvas: svgCanvas
|
canvas: svgCanvas
|
||||||
|
@ -22,7 +22,15 @@ export default {
|
||||||
const svg = '<?xml version="1.0" encoding="UTF-8"?>\n' + data,
|
const svg = '<?xml version="1.0" encoding="UTF-8"?>\n' + data,
|
||||||
filename = getFileNameFromTitle();
|
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);});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/* globals $ */
|
|
||||||
/**
|
/**
|
||||||
* Path functionality.
|
* Path functionality.
|
||||||
* @module path
|
* @module path
|
||||||
|
@ -456,10 +455,9 @@ export const pathActionsMethod = (function () {
|
||||||
// else, create a new point, update path element
|
// else, create a new point, update path element
|
||||||
} else {
|
} else {
|
||||||
// Checks if current target or parents are #svgcontent
|
// Checks if current target or parents are #svgcontent
|
||||||
if (!$.contains(
|
if (!(editorContext_.getContainer() !== editorContext_.getMouseTarget(evt) && editorContext_.getContainer().contains(
|
||||||
editorContext_.getContainer(),
|
|
||||||
editorContext_.getMouseTarget(evt)
|
editorContext_.getMouseTarget(evt)
|
||||||
)) {
|
))) {
|
||||||
// Clicked outside canvas, so don't make point
|
// Clicked outside canvas, so don't make point
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/* globals $ */
|
|
||||||
/**
|
/**
|
||||||
* Recalculate.
|
* Recalculate.
|
||||||
* @module recalculate
|
* @module recalculate
|
||||||
|
@ -16,6 +15,9 @@ import {
|
||||||
isIdentity, matrixMultiply, transformPoint, transformListToTransform,
|
isIdentity, matrixMultiply, transformPoint, transformListToTransform,
|
||||||
hasMatrixTransform
|
hasMatrixTransform
|
||||||
} from './math.js';
|
} from './math.js';
|
||||||
|
import {
|
||||||
|
mergeDeep
|
||||||
|
} from '../editor/components/jgraduate/Util.js';
|
||||||
|
|
||||||
let context_;
|
let context_;
|
||||||
|
|
||||||
|
@ -239,7 +241,7 @@ export const recalculateDimensions = function (selected) {
|
||||||
// if we haven't created an initial array in polygon/polyline/path, then
|
// if we haven't created an initial array in polygon/polyline/path, then
|
||||||
// make a copy of initial values and include the transform
|
// make a copy of initial values and include the transform
|
||||||
if (isNullish(initial)) {
|
if (isNullish(initial)) {
|
||||||
initial = $.extend(true, {}, changes);
|
initial = mergeDeep({}, changes);
|
||||||
for (const [ attr, val ] of Object.entries(initial)) {
|
for (const [ attr, val ] of Object.entries(initial)) {
|
||||||
initial[attr] = convertToNum(attr, val);
|
initial[attr] = convertToNum(attr, val);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/* globals $ */
|
|
||||||
/**
|
/**
|
||||||
* Tools for SVG selected element operation.
|
* Tools for SVG selected element operation.
|
||||||
* @module selected-elem
|
* @module selected-elem
|
||||||
|
@ -261,7 +260,7 @@ export const cloneSelectedElements = function (x, y) {
|
||||||
}
|
}
|
||||||
// use slice to quickly get the subset of elements we need
|
// use slice to quickly get the subset of elements we need
|
||||||
const copiedElements = selectedElements.slice(0, i);
|
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
|
// note that we loop in the reverse way because of the way elements are added
|
||||||
// to the selectedElements array (top-first)
|
// to the selectedElements array (top-first)
|
||||||
const drawing = elementContext_.getDrawing();
|
const drawing = elementContext_.getDrawing();
|
||||||
|
@ -723,7 +722,12 @@ export const convertToGroup = function (elem) {
|
||||||
y: svg.getAttribute('y'),
|
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');
|
dataStorage.remove(elem, 'gsvg');
|
||||||
|
|
||||||
const tlist = getTransformList(elem);
|
const tlist = getTransformList(elem);
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/* globals $ */
|
|
||||||
/**
|
/**
|
||||||
* Tools for svg.
|
* Tools for svg.
|
||||||
* @module svg
|
* @module svg
|
||||||
|
@ -670,7 +669,12 @@ export const save = function (opts) {
|
||||||
// remove the selected outline before serializing
|
// remove the selected outline before serializing
|
||||||
svgContext_.getCanvas().clearSelection();
|
svgContext_.getCanvas().clearSelection();
|
||||||
// Update save options if provided
|
// 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);
|
svgContext_.setSvgOption('apply', true);
|
||||||
|
|
||||||
// no need for doctype, see https://jwatt.org/svg/authoring/#doctype-declaration
|
// no need for doctype, see https://jwatt.org/svg/authoring/#doctype-declaration
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/* globals $ */
|
|
||||||
/**
|
/**
|
||||||
* Numerous tools for working with the editor's "canvas".
|
* Numerous tools for working with the editor's "canvas".
|
||||||
* @module svgcanvas
|
* @module svgcanvas
|
||||||
|
@ -169,15 +168,16 @@ class SvgCanvas {
|
||||||
// Alias Namespace constants
|
// Alias Namespace constants
|
||||||
|
|
||||||
// Default configuration options
|
// Default configuration options
|
||||||
const curConfig = {
|
let curConfig = {
|
||||||
show_outside_canvas: true,
|
show_outside_canvas: true,
|
||||||
selectNew: true,
|
selectNew: true,
|
||||||
dimensions: [ 640, 480 ]
|
dimensions: [ 640, 480 ]
|
||||||
};
|
};
|
||||||
|
|
||||||
// Update config with new one if given
|
// Update config with new one if given
|
||||||
|
this.mergeDeep = mergeDeep;
|
||||||
if (config) {
|
if (config) {
|
||||||
$.extend(curConfig, config);
|
curConfig = this.mergeDeep(curConfig, config);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Array with width/height of canvas
|
// Array with width/height of canvas
|
||||||
|
@ -188,7 +188,6 @@ class SvgCanvas {
|
||||||
this.$id = $id;
|
this.$id = $id;
|
||||||
this.$qq = $qq;
|
this.$qq = $qq;
|
||||||
this.$qa = $qa;
|
this.$qa = $qa;
|
||||||
this.mergeDeep = mergeDeep;
|
|
||||||
this.getClosest = getClosest;
|
this.getClosest = getClosest;
|
||||||
this.getParents = getParents;
|
this.getParents = getParents;
|
||||||
/** A storage solution aimed at replacing jQuerys data function.
|
/** A storage solution aimed at replacing jQuerys data function.
|
||||||
|
@ -322,9 +321,8 @@ class SvgCanvas {
|
||||||
opacity: curConfig.initOpacity
|
opacity: curConfig.initOpacity
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
allProperties.text = this.mergeDeep({}, allProperties.shape);
|
||||||
allProperties.text = $.extend(true, {}, allProperties.shape);
|
allProperties.text = this.mergeDeep(allProperties.text, {
|
||||||
$.extend(allProperties.text, {
|
|
||||||
fill: '#000000',
|
fill: '#000000',
|
||||||
stroke_width: curConfig.text && curConfig.text.stroke_width,
|
stroke_width: curConfig.text && curConfig.text.stroke_width,
|
||||||
font_size: curConfig.text && curConfig.text.font_size,
|
font_size: curConfig.text && curConfig.text.font_size,
|
||||||
|
@ -892,7 +890,7 @@ class SvgCanvas {
|
||||||
* @type {module:svgcanvas.ExtensionArgumentObject}
|
* @type {module:svgcanvas.ExtensionArgumentObject}
|
||||||
* @see {@link module:svgcanvas.PrivateMethods} source for the other methods/properties
|
* @see {@link module:svgcanvas.PrivateMethods} source for the other methods/properties
|
||||||
*/
|
*/
|
||||||
const argObj = $.extend(canvas.getPrivateMethods(), {
|
const argObj = canvas.mergeDeep(canvas.getPrivateMethods(), {
|
||||||
$: jq,
|
$: jq,
|
||||||
importLocale,
|
importLocale,
|
||||||
svgroot,
|
svgroot,
|
||||||
|
@ -904,7 +902,6 @@ class SvgCanvas {
|
||||||
if (extObj) {
|
if (extObj) {
|
||||||
extObj.name = name;
|
extObj.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
extensions[name] = extObj;
|
extensions[name] = extObj;
|
||||||
return call('extension_added', extObj);
|
return call('extension_added', extObj);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
/* globals $ */
|
|
||||||
/**
|
/**
|
||||||
* Miscellaneous utilities.
|
* Miscellaneous utilities.
|
||||||
* @module utilities
|
* @module utilities
|
||||||
|
@ -17,7 +16,7 @@ import {
|
||||||
isWebkit, supportsHVLineContainerBBox, supportsPathBBox, supportsXpath,
|
isWebkit, supportsHVLineContainerBBox, supportsPathBBox, supportsXpath,
|
||||||
supportsSelectors
|
supportsSelectors
|
||||||
} from '../common/browser.js';
|
} 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.
|
// String used to encode base64.
|
||||||
const KEYSTR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
const KEYSTR = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
||||||
|
@ -719,7 +718,7 @@ export const getBBox = function (elem) {
|
||||||
export const getPathDFromSegments = function (pathSegments) {
|
export const getPathDFromSegments = function (pathSegments) {
|
||||||
let d = '';
|
let d = '';
|
||||||
|
|
||||||
$.each(pathSegments, function (j, [ singleChar, pts ]) {
|
pathSegments.forEach(function([ singleChar, pts ], _j){
|
||||||
d += singleChar;
|
d += singleChar;
|
||||||
for (let i = 0; i < pts.length; i += 2) {
|
for (let i = 0; i < pts.length; i += 2) {
|
||||||
d += (pts[i] + ',' + pts[i + 1]) + ' ';
|
d += (pts[i] + ',' + pts[i + 1]) + ' ';
|
||||||
|
@ -899,7 +898,7 @@ export const convertToPath = function (
|
||||||
const batchCmd = new hstry.BatchCommand('Convert element to Path');
|
const batchCmd = new hstry.BatchCommand('Convert element to Path');
|
||||||
|
|
||||||
// Any attribute on the element not covered by the passed-in attributes
|
// 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({
|
const path = addSVGElementFromJson({
|
||||||
element: 'path',
|
element: 'path',
|
||||||
|
|
Loading…
Reference in New Issue