Skip to content

Instantly share code, notes, and snippets.

@jkhaui
Created January 4, 2019 13:58
Show Gist options
  • Save jkhaui/c8e45bc7beabedf705c56e1f2b2c4fe8 to your computer and use it in GitHub Desktop.
Save jkhaui/c8e45bc7beabedf705c56e1f2b2c4fe8 to your computer and use it in GitHub Desktop.
import React, { Component } from 'react';
import 'whatwg-fetch';
import MediumEditor from 'medium-editor';
import Citation from './citation.js';
class BookCitation extends Component {
constructor( props ) {
super( props )
this.state = {
editor : null,
}
this.editorContainer = React.createRef()
}
componentDidMount() {
this.setState({ editor : new MediumEditor( this.editorContainer.current ) })
}
render() {
return(
<Citation
editor={ this.state.editor }
bookNotFound={
book => document.getElementById("editor").innerHTML =
'No book was found. Try refining the title or author names.'
}
>
<div id="editor" ref={ this.editorContainer } />
</Citation>
)
}
}
export default BookCitation;
@donjajo
Copy link

donjajo commented Jan 4, 2019

import React, { Component } from 'react';
import 'whatwg-fetch';
import MediumEditor from 'medium-editor';
import Citation from './citation.js';

class BookCitation extends Component {
    
    constructor( props ) {
        super( props )
        this.state = {
            editor : null,
        }
        this.editorContainer = React.createRef()
    }

    componentDidMount() {
        this.setState({ editor : new MediumEditor( this.editorContainer.current, { placeholder : {} } ) })
    }

    render() {
        return(
                <Citation 
                    editor={ this.state.editor } 
                    bookNotFound={ 
                        book => document.getElementById("editor").innerHTML = 
                        'No book was found. Try refining the title or author names.' 
                    }
                >
                    <div id="editor" ref={ this.editorContainer } />
                </Citation>
        )
    }
}

export default BookCitation;

@jkhaui
Copy link
Author

jkhaui commented Jan 4, 2019

import React, { Component } from 'react';
import 'whatwg-fetch';
import MediumEditor from 'medium-editor';
import Citation from './citation.js';

class BookCitation extends Component {
    
    constructor( props ) {
        super( props )
        this.state = {
            editor : null,
        }
        this.editorContainer = React.createRef()
    }

    componentDidMount() {
        this.setState({ editor : new MediumEditor( this.editorContainer.current, { placeholder : {} } ) })
    }

    render() {
        return(
                <Citation 
                    editor={ this.state.editor } 
                    bookNotFound={ 
                        book => document.getElementById("editor").innerHTML = 
                        'No book was found. Try refining the title or author names.' 
                    }
                >
                    <div id="editor" ref={ this.editorContainer } />
                </Citation>
        )
    }
}

export default BookCitation;

Omg yassssss

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment