Skip to content

Commit

Permalink
Fix/tex example (facebookarchive#699)
Browse files Browse the repository at this point in the history
this pull request fixed broken Tex example by removing outdated syntax that changed
in facebookarchive#376.

refer issue to facebookarchive#697
  • Loading branch information
mzbac authored and flarnie committed Oct 4, 2016
1 parent 8c9afc4 commit 1559e9f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
13 changes: 6 additions & 7 deletions examples/tex/js/components/TeXBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

import katex from 'katex';
import React from 'react';
import {Entity} from 'draft-js';

class KatexOutput extends React.Component {
constructor(props) {
Expand Down Expand Up @@ -93,12 +92,12 @@ export default class TeXBlock extends React.Component {

this._save = () => {
var entityKey = this.props.block.getEntityAt(0);
Entity.mergeData(entityKey, {content: this.state.texValue});
var newContentState = this.props.contentState.mergeEntityData(entityKey, {content: this.state.texValue});
this.setState({
invalidTeX: false,
editMode: false,
texValue: null,
}, this._finishEdit);
}, this._finishEdit.bind(this, newContentState));
};

this._remove = () => {
Expand All @@ -107,14 +106,14 @@ export default class TeXBlock extends React.Component {
this._startEdit = () => {
this.props.blockProps.onStartEdit(this.props.block.getKey());
};
this._finishEdit = () => {
this.props.blockProps.onFinishEdit(this.props.block.getKey());
this._finishEdit = (newContentState) => {
this.props.blockProps.onFinishEdit(this.props.block.getKey(), newContentState);
};
}

_getValue() {
return Entity
.get(this.props.block.getEntityAt(0))
return this.props.contentState
.getEntity(this.props.block.getEntityAt(0))
.getData()['content'];
}

Expand Down
7 changes: 5 additions & 2 deletions examples/tex/js/components/TeXEditorExample.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ export default class TeXEditorExample extends React.Component {
var {liveTeXEdits} = this.state;
this.setState({liveTeXEdits: liveTeXEdits.set(blockKey, true)});
},
onFinishEdit: (blockKey) => {
onFinishEdit: (blockKey, newContentState) => {
var {liveTeXEdits} = this.state;
this.setState({liveTeXEdits: liveTeXEdits.remove(blockKey)});
this.setState({
liveTeXEdits: liveTeXEdits.remove(blockKey),
editorState:EditorState.createWithContent(newContentState),
});
},
onRemove: (blockKey) => this._removeTeX(blockKey),
},
Expand Down

0 comments on commit 1559e9f

Please sign in to comment.