diff --git a/src/editor/dialogs/imagePropertiesDialog.js b/src/editor/dialogs/imagePropertiesDialog.js index 6cc9b8bd..042ee3b0 100644 --- a/src/editor/dialogs/imagePropertiesDialog.js +++ b/src/editor/dialogs/imagePropertiesDialog.js @@ -1,5 +1,6 @@ /* eslint-disable node/no-unpublished-import */ import 'elix/define/Dialog.js'; +import {isValidUnit} from '../../common/units.js'; const template = document.createElement('template'); template.innerHTML = ` @@ -298,6 +299,18 @@ export class SeImgPropDialog extends HTMLElement { }; const onSaveHandler = (ev) => { let saveOpt = ''; + const w = this.$canvasWidth.value; + const h = this.$canvasHeight.value; + if (w !== 'fit' && !isValidUnit('width', w)) { + this.$canvasWidth.parentElement.classList.add('error'); + } else { + this.$canvasWidth.parentElement.classList.remove('error'); + } + if (h !== 'fit' && !isValidUnit('height', w)) { + this.$canvasHeight.parentElement.classList.add('error'); + } else { + this.$canvasHeight.parentElement.classList.remove('error'); + } if (this.$imageOptEmbed.getAttribute('checked') === 'true') { saveOpt = 'embed'; } diff --git a/src/editor/svgedit.js b/src/editor/svgedit.js index baa76d86..60503dfa 100644 --- a/src/editor/svgedit.js +++ b/src/editor/svgedit.js @@ -3914,22 +3914,18 @@ editor.init = () => { */ const saveDocProperties = function (e) { // set title - const {title, w, h, save} = e.detail; + const {title, w, h, save} = e.detail; // set document title svgCanvas.setDocumentTitle(title); if (w !== 'fit' && !isValidUnit('width', w)) { - // width.parentElement.classList.add('error'); /* await */ $.alert(uiStrings.notification.invalidAttrValGiven); return false; } - // width.parentElement.classList.remove('error'); if (h !== 'fit' && !isValidUnit('height', h)) { - // height.parentElement.classList.add('error'); /* await */ $.alert(uiStrings.notification.invalidAttrValGiven); return false; } - // height.parentElement.classList.remove('error'); if (!svgCanvas.setResolution(w, h)) { /* await */ $.alert(uiStrings.notification.noContentToFitTo); return false;