Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
fix: don't catch error to handle ie11 bugs
Browse files Browse the repository at this point in the history
affects: @stylegator/app
  • Loading branch information
farism committed Dec 20, 2019
1 parent 7c8fc81 commit 9accfba
Showing 1 changed file with 10 additions and 20 deletions.
30 changes: 10 additions & 20 deletions packages/app/src/partials/LiveMarkdown/LiveMarkdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,33 @@ import { LiveProvider, LiveEditor, LiveError, LivePreview } from 'react-live'

import styles from './liveMarkdown.scss'

const fixStyleProps = content => content.replace(/style(?!=\{)/g, 'style={{}}')

class LiveMarkdown extends React.Component {
constructor(props) {
super(props)

this.state = {
expanded: false,
content: props.content,
contentEditing: props.content,
}
}

componentDidCatch(error, info) {
this.setState({
content: fixStyleProps(this.state.contentEditing),
})
}

render() {
const { attributes, scope } = this.props

const { content, expanded } = this.state

return (
<div className={styles['live-markdown']}>
<LiveProvider code={content} scope={scope}>
<div className={styles['live-markdown-preview']}>
<LivePreview />
</div>
{expanded && (
<div className={styles['live-markdown-editor']}>
<LiveEditor />
</div>
)}
<LiveError />
{attributes.interactive === 'true' && (
<div
{...{
Expand All @@ -41,17 +42,6 @@ class LiveMarkdown extends React.Component {
{expanded ? '</>' : '< >'}
</div>
)}
<div className={styles['live-markdown-preview']}>
<LivePreview />
</div>
{expanded && (
<div className={styles['live-markdown-editor']}>
<LiveEditor
onChange={contentEditing => this.setState({ contentEditing })}
/>
</div>
)}
<LiveError />
</LiveProvider>
</div>
)
Expand Down

0 comments on commit 9accfba

Please sign in to comment.