From c4a622badb29c75d9e8294b1e12b9bbf9b77f6f5 Mon Sep 17 00:00:00 2001 From: Fernando Date: Mon, 24 Aug 2020 09:49:05 -0300 Subject: [PATCH] Adicionada ImageLegacy (temp) --- components/Article/TextBody.js | 5 ++- components/Article/Utils/parseBody.js | 4 ++- components/Image/Legacy.js | 24 +++++++++++++ index.js | 49 ++++++++++++++++++++++++--- 4 files changed, 75 insertions(+), 7 deletions(-) create mode 100644 components/Image/Legacy.js diff --git a/components/Article/TextBody.js b/components/Article/TextBody.js index 902df7d23..17a25e6fc 100644 --- a/components/Article/TextBody.js +++ b/components/Article/TextBody.js @@ -5,6 +5,7 @@ import React from 'react'; import AdBlock from '../AdBlock'; import Block from '../Block'; import Image from '../Image'; +import ImageLegacy from '../Image/Legacy'; import Paragraph from './Paragraph'; import {parseBody} from './Utils'; @@ -44,7 +45,9 @@ const TextBody = ({adsblocks, content, domain, embeds}) => { case 'Facebook': return embeds && embeds.Facebook && ; case 'Image': - return ; + return ; + case 'ImageLegacy': + return ; case 'Instagram': return embeds && embeds.Instagram && ; case 'Tweet': diff --git a/components/Article/Utils/parseBody.js b/components/Article/Utils/parseBody.js index 7dd072133..7e0e53508 100644 --- a/components/Article/Utils/parseBody.js +++ b/components/Article/Utils/parseBody.js @@ -62,6 +62,9 @@ const parseBody = (content) => { } // render image + if(tag === 'img' && attr.src && attr.src.startsWith('/legacy/image')) + bodyItems.push({type: 'ImageLegacy', value: {'image-legacy': attr.src}}) + if(tag === 'a' && attr.class && attr.class === 'p-smartembed') { const childImage = find(child, {tag: 'img'}); if(childImage) { @@ -75,7 +78,6 @@ const parseBody = (content) => { bodyItems.push({type: 'Image', value: propsImage}); } } - // render embed if(tag === 'a' && attr.href && !attr.class && attr.href !== '') { diff --git a/components/Image/Legacy.js b/components/Image/Legacy.js new file mode 100644 index 000000000..d2043a835 --- /dev/null +++ b/components/Image/Legacy.js @@ -0,0 +1,24 @@ +import PropTypes from 'prop-types' +import React from 'react' + +import Block from '../Block' + +const Image = ({domain, value}) => { + + if(!value || !value['image-legacy']) + return false + + const imagePath = `${value['image-legacy']}` + return ( + + {`Imagem + + ) +} + +Image.propTypes = { + value: PropTypes.object.isRequired +} +Image.defaultProps = {value: {}} + +export default Image \ No newline at end of file diff --git a/index.js b/index.js index 72630aade..419be5a18 100644 --- a/index.js +++ b/index.js @@ -510,6 +510,28 @@ AdBlock.propTypes = { content: PropTypes.object }; +var Image$1 = function Image(_ref) { + var domain = _ref.domain, + value = _ref.value; + if (!value || !value['image-legacy']) return false; + var imagePath = "".concat(value['image-legacy']); + return /*#__PURE__*/React__default.createElement(Block, { + custom: "article-image-box", + w: "100p" + }, /*#__PURE__*/React__default.createElement("img", { + className: "image-article", + src: imagePath, + alt: "Imagem importada do sistema legado" + })); +}; + +Image$1.propTypes = { + value: PropTypes.object.isRequired +}; +Image$1.defaultProps = { + value: {} +}; + var Paragraph = function Paragraph(_ref) { var value = _ref.value; return /*#__PURE__*/React__default.createElement(Typography, { @@ -583,6 +605,13 @@ var parseBody = function parseBody(content) { } // render image + if (tag === 'img' && attr.src && attr.src.startsWith('/legacy/image')) bodyItems.push({ + type: 'ImageLegacy', + value: { + 'image-legacy': attr.src + } + }); + if (tag === 'a' && attr["class"] && attr["class"] === 'p-smartembed') { var childImage = lodash.find(child, { tag: 'img' @@ -694,11 +723,21 @@ var TextBody = function TextBody(_ref) { case 'Image': return /*#__PURE__*/React__default.createElement(Block, { + key: key, custom: "article-image-embed", mb: "3" }, /*#__PURE__*/React__default.createElement(Image, { domain: domain, + value: value + })); + + case 'ImageLegacy': + return /*#__PURE__*/React__default.createElement(Block, { key: key, + custom: "article-image-embed", + mb: "3" + }, /*#__PURE__*/React__default.createElement(Image$1, { + domain: domain, value: value })); @@ -865,7 +904,7 @@ Button.defaultProps = { style: 'primary' }; -var Image$1 = function Image(_ref) { +var Image$2 = function Image(_ref) { var children = _ref.children, custom = _ref.custom, domain = _ref.domain, @@ -890,13 +929,13 @@ var Image$1 = function Image(_ref) { }, children && children)); }; -Image$1.propTypes = { +Image$2.propTypes = { children: PropTypes.node, custom: PropTypes.string, domain: PropTypes.string, value: PropTypes.object.isRequired }; -Image$1.defaultProps = { +Image$2.defaultProps = { value: {} }; @@ -918,7 +957,7 @@ var ColumnHeader = function ColumnHeader(_ref) { className: "teaser-aria", href: path, "aria-label": "Imagem do colunista ".concat(column_name) - }, /*#__PURE__*/React__default.createElement(Image$1, { + }, /*#__PURE__*/React__default.createElement(Image$2, { domain: domain, value: image }))), /*#__PURE__*/React__default.createElement(Block, { @@ -4605,7 +4644,7 @@ exports.ColumnHeader = ColumnHeader; exports.Form = index; exports.Grid = Grid; exports.Image = Image; -exports.ImageBackground = Image$1; +exports.ImageBackground = Image$2; exports.ImageGallery = ImageGallery; exports.SearchForm = SearchForm; exports.SearchMenu = SearchMenu;