Refactor canvas in multiple pieces to increase maintainability (#446)

* #refactor-canvas getJsonFromSvgElement and svgroot code moved to separate file
* #refactor-canvas build files changes
* #refactor-canvas addSVGElementsFromJson move to json file
* #refactor-canvas selected element option function move separate file
* #refactor-canvas moveUpDownSelected move to select-elem
* ##refactor-canvas build file updated
* #refactor-canvas moveSelectedElements  move to selected-elem
* #refactor-canvas cloneSelectedElements move to slected-elem
* #refactor-canvas alignSelectedElements move to selected-elem
* #refactor-canvas deleteSelectedElements move to selected-elem
* #refactor-canvas copySelectedElements and groupSelectedElements move to selected-elem
* #refactor-canvas pushGroupProperty, ungroupSelectedElement move to selected-elem
* #refactor-canvas comment changes
* #refactor-canvas UndoManager move to separate file
* #refactor-canvas event file move to mouseMove, mouseUpEvent and dblClickEvent
* #refactor-canvas mouseDown move to event
* #refactor-canvas move to undo file
* #refactor alignment changes  and set function revert return
* #refactor-canvas textaction move to separate file
* #refactor-canvas paste-element function move to separate file
* #refactor-canvas set and get  method move to separate file
* #refactor-canvas set and get function moved changes
* #refactor clear file import and regaring function moved changes changes
* #refactor-canvas svg related function move to separate file
* #refactor-canvas setBackground methos move to elem-get-set file
* #refactor-canvas getBsplinePoint method move to event file
* #refactor-canvas export functions move to svg-exec
* #refactor-canvas svg related function moved separate file
* #refactor-canvas updateCanvas,  cycleElement move to selected-elem file
* #refactor-canvas removeUnusedDefElems move to svg-exec file
* #refactor-canvas blur method move to separate file blur-event.js
* #refactor-canvas selection related function move to separate file slection.js
* #refactor-canvas convertGradients, mousewheelmove event bind function move to other files
* #refactor-canvas extension function move to selection file
* #refactor-canvas svg tag long string changes to es6 format
* eslint fixes
* eslint and test fixes
* add netlify logo per their requirements
* #refactor-canvas path file separate to path-method.js and path-actions.js
* #refactor-canvas lint issue fixed
* #refactor-canvas path.js file class and const move to path-method.js
* #refactor-canvas eslint issue fixed. 'jsdoc/check-examples': 'off' already so removed eslint-disable jsdoc/check-examples
* #refactor-canvas path class moved changes and copy-elem.js file cypress test issue fixed
* #refactor-canvas UI - Clipboard paste element  cypress issue fixed
* #refactor-canvas cypress test cases issue fixed changes
* #refactor-canvas cypress test cases issue fixed changes
* #refactor-canvas cypress test case issue fixed
* npm update and fix a few eslint new errors
* fix snapshot and run tests
* add star tool to cypress
* #refactor-canvas shapelibrary, star, polygon and panning tool issue fixed
* build
* Update layer.js
* revert proper declarations

Authored-by OptimistikSAS
This commit is contained in:
JFH
2020-11-11 11:38:45 +01:00
committed by GitHub
parent 087fa44cea
commit 28019eef07
106 changed files with 10353 additions and 7877 deletions

View File

@@ -58,11 +58,7 @@ export default {
svgCanvas.bind('setnonce', setArrowNonce);
svgCanvas.bind('unsetnonce', unsetArrowNonce);
if (randomizeIds) {
arrowprefix = prefix + nonce + '_';
} else {
arrowprefix = prefix;
}
arrowprefix = randomizeIds ? prefix + nonce + '_' : prefix;
const pathdata = {
fw: {d: 'm0,0l10,5l-10,5l5,-5l-5,-5z', refx: 8, id: arrowprefix + 'fw'},

View File

@@ -189,10 +189,7 @@ export default {
let viewBox = '0 0 100 100';
let markerWidth = 5;
let markerHeight = 5;
let seType;
if (val.substr(0, 1) === '\\') {
seType = val.substr(1);
} else { seType = 'textmarker'; }
const seType = val.substr(0, 1) === '\\' ? val.substr(1) : 'textmarker';
if (!markerTypes[seType]) { return undefined; } // an unknown type!

View File

@@ -2577,11 +2577,7 @@ editor.init = () => {
$(context).parentsUntil('#svgcontent > g').andSelf().each(function () {
if (this.id) {
str += ' > ' + this.id;
if (this !== context) {
linkStr += ' > <a href="#">' + this.id + '</a>';
} else {
linkStr += ' > ' + this.id;
}
linkStr += this !== context ? ' > <a href="#">' + this.id + '</a>' : ' > ' + this.id;
}
});
@@ -2684,12 +2680,7 @@ editor.init = () => {
if (toolButtonClick(showSel)) {
options.fn();
}
let icon;
if (options.icon) {
icon = $.getSvgIcon(options.icon, true);
} else {
icon = $(options.sel).children().eq(0).clone();
}
const icon = options.icon ? $.getSvgIcon(options.icon, true) : $(options.sel).children().eq(0).clone();
icon[0].setAttribute('width', shower.width());
icon[0].setAttribute('height', shower.height());
@@ -3280,11 +3271,7 @@ editor.init = () => {
const opts = {alpha: opac};
if (color.startsWith('url(#')) {
let refElem = svgCanvas.getRefElem(color);
if (refElem) {
refElem = refElem.cloneNode(true);
} else {
refElem = $('#' + type + '_color defs *')[0];
}
refElem = refElem ? refElem.cloneNode(true) : $('#' + type + '_color defs *')[0];
opts[refElem.tagName] = refElem;
} else if (color.startsWith('#')) {
opts.solidColor = color.substr(1);
@@ -3348,14 +3335,12 @@ editor.init = () => {
const colorBlocks = ['#FFF', '#888', '#000', 'chessboard'];
str = '';
$.each(colorBlocks, function (i, e) {
if (e === 'chessboard') {
str += '<div class="color_block" data-bgcolor="' + e +
str += e === 'chessboard'
? '<div class="color_block" data-bgcolor="' + e +
'" style="background-image:url(data:image/gif;base64,' +
'R0lGODlhEAAQAIAAAP///9bW1iH5BAAAAAAALAAAAAAQABAAAAIfjG+' +
'gq4jM3IFLJgpswNly/XkcBpIiVaInlLJr9FZWAQA7);"></div>';
} else {
str += '<div class="color_block" data-bgcolor="' + e + '" style="background-color:' + e + ';"></div>';
}
'gq4jM3IFLJgpswNly/XkcBpIiVaInlLJr9FZWAQA7);"></div>'
: '<div class="color_block" data-bgcolor="' + e + '" style="background-color:' + e + ';"></div>';
});
$('#bg_blocks').append(str);
const blocks = $('#bg_blocks div');
@@ -5627,12 +5612,7 @@ editor.init = () => {
const menu = ($(sel).parents('#main_menu').length);
$(sel).each(function () {
let t;
if (menu) {
t = $(this).text().split(' [')[0];
} else {
t = this.title.split(' [')[0];
}
const t = menu ? $(this).text().split(' [')[0] : this.title.split(' [')[0];
let keyStr = '';
// Shift+Up
$.each(keyval.split('/'), function (i, key) {