Skip to content

Commit

Permalink
remove passProps injected to non-jsx content
Browse files Browse the repository at this point in the history
  • Loading branch information
utku-ozturk committed Aug 8, 2024
1 parent 37136e0 commit b24c2f1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions es/components/static-pages/BasicStaticSectionBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import _ from 'underscore';
import { htmlToJSX } from './../util/object';
import { patchedConsoleInstance as console } from './../util/patched-console';
import { compiler } from 'markdown-to-jsx';
export var BasicStaticSectionBody = /*#__PURE__*/React.memo(function (props) {
var content = props.content,
Expand All @@ -16,9 +17,9 @@ export var BasicStaticSectionBody = /*#__PURE__*/React.memo(function (props) {
passProps = _objectWithoutProperties(props, _excluded);
//In some cases, markdown to html conversion is handled by backend by assigning the content_as_html. For the rest, use markdown-to-jsx compiler.
if (filetype === 'md' && typeof content === 'string' && !content_as_html) {
return /*#__PURE__*/React.createElement(element, passProps, compiler(content, markdownCompilerOptions || undefined));
return /*#__PURE__*/React.createElement(element, null, compiler(content, markdownCompilerOptions || undefined));
} else if ((filetype === 'html' || filetype === 'rst' || filetype === 'md') && (typeof content_as_html === 'string' || typeof content === 'string')) {
return /*#__PURE__*/React.createElement(element, passProps, htmlToJSX(content_as_html || content));
return /*#__PURE__*/React.createElement(element, null, htmlToJSX(content_as_html || content));
} else if (filetype === 'jsx' && typeof content === 'string') {
return placeholderReplacementFxn(content.trim(), passProps);
} else if (filetype === 'txt' && typeof content === 'string' && content.slice(0, 12) === 'placeholder:') {
Expand Down
5 changes: 3 additions & 2 deletions src/components/static-pages/BasicStaticSectionBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ import React from 'react';
import PropTypes from 'prop-types';
import _ from 'underscore';
import { htmlToJSX } from './../util/object';
import { patchedConsoleInstance as console } from './../util/patched-console';
import { compiler } from 'markdown-to-jsx';


export const BasicStaticSectionBody = React.memo(function BasicStaticSectionBody(props){
const { content, content_as_html, children, filetype, element, markdownCompilerOptions, placeholderReplacementFxn, ...passProps } = props;
//In some cases, markdown to html conversion is handled by backend by assigning the content_as_html. For the rest, use markdown-to-jsx compiler.
if (filetype === 'md' && typeof content === 'string' && !content_as_html){
return React.createElement(element, passProps, compiler(content, markdownCompilerOptions || undefined) );
return React.createElement(element, null, compiler(content, markdownCompilerOptions || undefined) );
} else if ((filetype === 'html' || filetype === 'rst' || filetype === 'md') && (typeof content_as_html === 'string' || typeof content === 'string')){
return React.createElement(element, passProps, htmlToJSX(content_as_html || content));
return React.createElement(element, null, htmlToJSX(content_as_html || content));
} else if (filetype === 'jsx' && typeof content === 'string'){
return placeholderReplacementFxn(content.trim(), passProps);
} else if (filetype === 'txt' && typeof content === 'string' && content.slice(0,12) === 'placeholder:'){
Expand Down

0 comments on commit b24c2f1

Please sign in to comment.