Commit be4351fa authored by Giannis Kopanas's avatar Giannis Kopanas

Changing Prosemirrror state on new Content

parent bb40334e
Pipeline #4865 passed with stages
in 7 minutes and 54 seconds
......@@ -137,5 +137,6 @@ export default compose(
form: 'decision',
onChange: debounce(onChange, 1000, { maxWait: 5000 }),
onSubmit,
destroyOnUnmount: false,
}),
)(DecisionLayout)
......@@ -30,10 +30,9 @@ const DecisionLayout = ({
versions.forEach(version => {
// TODO: allow multiple decisions, e.g. appeals
const { decision } = version
if (decision && decision.submitted) {
const submittedMoment = moment(decision.submitted)
const key = submittedMoment.format('x')
// const key = submittedMoment.format('x')
const label = submittedMoment.format('YYYY-MM-DD')
decisionSections.push({
......@@ -44,7 +43,7 @@ const DecisionLayout = ({
<Decision decision={decision} />
</div>
),
key,
key: version.id,
label,
})
......@@ -53,12 +52,12 @@ const DecisionLayout = ({
<SimpleEditor
content={version.source}
editing="selection"
key={key}
key={version.id}
layout="bare"
readOnly
/>
),
key,
key: version.id,
label,
})
}
......@@ -68,7 +67,7 @@ const DecisionLayout = ({
if (currentVersion.submitted && (!decision || !decision.submitted)) {
const submittedMoment = moment()
const key = submittedMoment.format('x')
// const key = submittedMoment.format('x')
const label = submittedMoment.format('YYYY-MM-DD')
decisionSections.push({
content: (
......@@ -90,7 +89,7 @@ const DecisionLayout = ({
/>
</div>
),
key,
key: currentVersion.id,
label,
})
......@@ -99,12 +98,12 @@ const DecisionLayout = ({
<SimpleEditor
content={currentVersion.source}
editing="selection"
key={key}
key={currentVersion.id}
layout="bare"
readOnly
/>
),
key,
key: currentVersion.id,
label,
})
}
......@@ -118,12 +117,11 @@ const DecisionLayout = ({
title="Versions"
/>
</div>
<div className={classes.column}>
<Tabs
activeKey={decisionSections[decisionSections.length - 1].key}
sections={decisionSections}
title="Versions"
title="Versions1"
/>
</div>
</div>
......
......@@ -18,14 +18,6 @@ class Tabs extends React.Component {
this.setState({ activeKey })
}
componentWillReceiveProps(nextProps) {
const { activeKey } = nextProps
if (activeKey !== this.props.activeKey) {
this.setState({ activeKey })
}
}
setActiveKey(activeKey) {
this.setState({ activeKey })
}
......
......@@ -24,8 +24,11 @@ class HtmlViewer extends React.Component {
}
render() {
const { options, className } = this.props
const { options, className, value } = this.props
const { schema } = options
const parse = parser(schema)
options.doc = parse(value)
return <Viewer className={className} options={options} />
}
}
......
......@@ -14,6 +14,11 @@ class Viewer extends React.Component {
}
}
componentDidUpdate(props) {
const newState = EditorState.create(props.options)
this.view.updateState(newState)
}
createEditorView = node => {
const { className } = this.props
const { state } = this.state
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment