Merge pull request #517 from OptimistikSAS/issues/103

master
JFH 2021-05-22 18:34:14 +02:00 committed by GitHub
commit 5989a4cbd9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 16 additions and 20 deletions

View File

@ -655,7 +655,7 @@ class EditorStartup {
editorObj.svgCanvas.selectOnly([ newImage ]); editorObj.svgCanvas.selectOnly([ newImage ]);
editorObj.svgCanvas.alignSelectedElements('m', 'page'); editorObj.svgCanvas.alignSelectedElements('m', 'page');
editorObj.svgCanvas.alignSelectedElements('c', 'page'); editorObj.svgCanvas.alignSelectedElements('c', 'page');
editorObj.topPanelHandlers.updateContextPanel(); editorObj.topPanel.updateContextPanel();
document.getElementById('se-prompt-dialog').setAttribute('close', true); document.getElementById('se-prompt-dialog').setAttribute('close', true);
}; };
// create dummy img so we know the default dimensions // create dummy img so we know the default dimensions

View File

@ -325,7 +325,8 @@ class LayersPanel {
* @returns {void} * @returns {void}
*/ */
layerRename() { layerRename() {
const oldName = document.querySelector("#layerlist tr.layersel td.layername").textContent; const ele = document.querySelector("#layerlist tr.layersel td.layername");
const oldName = (ele) ? ele.textContent : '';
const newName = prompt(this.editor.i18next.t('notification.enterNewLayerName'), ""); const newName = prompt(this.editor.i18next.t('notification.enterNewLayerName'), "");
if (!newName) { if (!newName) {
return; return;
@ -425,7 +426,8 @@ class LayersPanel {
const elements = $id('layerlist').querySelectorAll("td.layervis"); const elements = $id('layerlist').querySelectorAll("td.layervis");
Array.from(elements).forEach(function(element) { Array.from(elements).forEach(function(element) {
element.addEventListener('click', function(evt) { element.addEventListener('click', function(evt) {
const name = evt.currentTarget.parentNode.querySelector("td.layername").textContent; const ele = evt.currentTarget.parentNode.querySelector("td.layername");
const name = (ele)? ele.textContent : '';
const vis = evt.currentTarget.classList.contains("layerinvis"); const vis = evt.currentTarget.classList.contains("layerinvis");
self.editor.svgCanvas.setLayerVisibility(name, vis); self.editor.svgCanvas.setLayerVisibility(name, vis);
evt.currentTarget.classList.toggle("layerinvis"); evt.currentTarget.classList.toggle("layerinvis");

View File

@ -3,12 +3,8 @@
* @license MIT * @license MIT
* @copyright 2011 Jeff Schiller * @copyright 2011 Jeff Schiller
*/ */
/* globals jQuery */
import { jGraduate } from '../editor/components/jgraduate/jQuery.jGraduate.js'; import { jGraduate } from '../editor/components/jgraduate/jQuery.jGraduate.js';
import * as hstry from './history.js'; import * as hstry from './history.js';
import jQueryPluginSVG from './jQuery.attr.js';
import { NS } from '../common/namespaces.js'; import { NS } from '../common/namespaces.js';
import { import {
getVisibleElements, getStrokedBBoxDefaultVisible, findDefs, getVisibleElements, getStrokedBBoxDefaultVisible, findDefs,
@ -19,8 +15,6 @@ import {
} from '../common/units.js'; } from '../common/units.js';
import { getParents } from '../editor/components/jgraduate/Util.js'; import { getParents } from '../editor/components/jgraduate/Util.js';
const $ = jQueryPluginSVG(jQuery);
const { const {
InsertElementCommand, RemoveElementCommand, InsertElementCommand, RemoveElementCommand,
ChangeElementCommand, BatchCommand ChangeElementCommand, BatchCommand
@ -272,7 +266,7 @@ export const setBBoxZoomMethod = function (val, editorW, editorH) {
switch (val) { switch (val) {
case 'selection': { case 'selection': {
if (!selectedElements[0]) { return undefined; } if (!selectedElements[0]) { return undefined; }
const selectedElems = $.map(selectedElements, function (n) { const selectedElems = selectedElements.map(function (n, _) {
if (n) { if (n) {
return n; return n;
} }
@ -722,7 +716,7 @@ export const getTextMethod = function () {
const selectedElements = elemContext_.getSelectedElements(); const selectedElements = elemContext_.getSelectedElements();
const selected = selectedElements[0]; const selected = selectedElements[0];
if (isNullish(selected)) { return ''; } if (isNullish(selected)) { return ''; }
return selected.textContent; return (selected) ? selected.textContent : '';
}; };
/** /**

View File

@ -294,7 +294,7 @@ export class ChangeElementCommand extends Command {
this.oldValues = attrs; this.oldValues = attrs;
for (const attr in attrs) { for (const attr in attrs) {
if (attr === '#text') { if (attr === '#text') {
this.newValues[attr] = elem.textContent; this.newValues[attr] = (elem) ? elem.textContent : '';
} else if (attr === '#href') { } else if (attr === '#href') {
this.newValues[attr] = getHref(elem); this.newValues[attr] = getHref(elem);
} else { } else {

View File

@ -735,8 +735,11 @@ export const convertToGroup = function (elem) {
} else if (dataStorage.has($elem, 'symbol')) { } else if (dataStorage.has($elem, 'symbol')) {
elem = dataStorage.get($elem, 'symbol'); elem = dataStorage.get($elem, 'symbol');
ts = $elem.attr('transform'); ts = $elem.getAttribute('transform');
const pos = $elem.attr([ 'x', 'y' ]); const pos = {
x: $elem.getAttribute('x'),
y: $elem.getAttribute('y')
};
const vb = elem.getAttribute('viewBox'); const vb = elem.getAttribute('viewBox');

View File

@ -351,7 +351,7 @@ export const setSvgString = function (xmlString, preventUndo) {
const elements = content.querySelectorAll('image'); const elements = content.querySelectorAll('image');
Array.prototype.forEach.call(elements, function (image) { Array.prototype.forEach.call(elements, function (image) {
preventClickDefault(image); preventClickDefault(image);
const val = svgContext_.getCanvas().getHref(this); const val = svgContext_.getCanvas().getHref(image);
if (val) { if (val) {
if (val.startsWith('data:')) { if (val.startsWith('data:')) {
// Check if an SVG-edit data URI // Check if an SVG-edit data URI

View File

@ -1324,11 +1324,8 @@ export const snapToGrid = function (value) {
* @returns {void} * @returns {void}
*/ */
export const preventClickDefault = function (img) { export const preventClickDefault = function (img) {
const elements = document.querySelectorAll(img); img.addEventListener('click', function (e) {
Array.from(elements).forEach(function (element) { e.preventDefault();
element.addEventListener('click', function (e) {
e.preventDefault();
});
}); });
}; };