From 88eafeb363f495faae7d915aa1f8867c86a5f1d6 Mon Sep 17 00:00:00 2001 From: Miu Razvan Date: Wed, 26 Apr 2023 14:03:26 +0300 Subject: [PATCH] Revert changes on AttachedImageWidget --- package.json | 8 +------- src/Widget/AttachedImageWidget.jsx | 30 ++++++++++-------------------- 2 files changed, 11 insertions(+), 27 deletions(-) diff --git a/package.json b/package.json index e3a2f78..59fd48d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@eeacms/volto-object-widget", - "version": "5.2.0", + "version": "5.1.0", "description": "volto-object-widget: Volto add-on", "main": "src/index.js", "author": "European Environment Agency: IDM2 A-Team", @@ -17,12 +17,6 @@ "type": "git", "url": "git@github.com:eea/volto-object-widget.git" }, - "addons": [ - "@eeacms/volto-widgets-view" - ], - "dependencies": { - "@eeacms/volto-widgets-view": "*" - }, "devDependencies": { "@cypress/code-coverage": "^3.10.0", "@plone/scripts": "*", diff --git a/src/Widget/AttachedImageWidget.jsx b/src/Widget/AttachedImageWidget.jsx index b54ed3b..ce67b73 100644 --- a/src/Widget/AttachedImageWidget.jsx +++ b/src/Widget/AttachedImageWidget.jsx @@ -17,8 +17,6 @@ import { isInternalURL, } from '@plone/volto/helpers'; -import { getURL } from '@eeacms/volto-widgets-view/helpers'; - import imageBlockSVG from '@plone/volto/components/manage/Blocks/Image/block-image.svg'; import clearSVG from '@plone/volto/icons/clear.svg'; import navTreeSVG from '@plone/volto/icons/nav.svg'; @@ -77,10 +75,7 @@ export class AttachedImageWidget extends Component { this.setState({ uploading: false, }); - this.props.onChange(this.props.id, { - '@type': 'URL', - value: nextProps.content['@id'], - }); + this.props.onChange(this.props.id, nextProps.content['@id']); } } @@ -146,10 +141,7 @@ export class AttachedImageWidget extends Component { * @returns {undefined} */ onSubmitUrl = () => { - this.props.onChange(this.props.id, { - '@type': 'URL', - value: flattenToAppURL(this.state.url), - }); + this.props.onChange(this.props.id, flattenToAppURL(this.state.url)); }; resetSubmitUrl = () => { @@ -205,8 +197,6 @@ export class AttachedImageWidget extends Component { messages.AttachedImageWidgetInputPlaceholder, ); - const imgSrc = getURL(this.props.value); - return ( - {imgSrc && ( + {this.props.value && (
Preview @@ -243,7 +235,7 @@ export class AttachedImageWidget extends Component {
)} - {!imgSrc && ( + {!this.props.value && ( { - this.setState({ url }, () => { - this.onSubmitUrl(); - }); + this.setState({ url }); }, }); }}