move docs to own folder
This commit is contained in:
40
docs/src/demos/React/index.jsx
Normal file
40
docs/src/demos/React/index.jsx
Normal file
@@ -0,0 +1,40 @@
|
||||
import React, { Component } from 'react'
|
||||
import { Editor } from '@tiptap/core'
|
||||
import extensions from '@tiptap/starter-kit'
|
||||
|
||||
export default class TestComponent extends Component {
|
||||
constructor() {
|
||||
super()
|
||||
this.editorNode = React.createRef()
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.editor = new Editor({
|
||||
element: this.editorNode.current,
|
||||
content: '<p>rendered in <strong>react</strong>!</p>',
|
||||
extensions: extensions(),
|
||||
})
|
||||
this.forceUpdate()
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
{this.editor &&
|
||||
<div>
|
||||
<button onClick={() => this.editor.focus().removeMarks()}>
|
||||
clear formatting
|
||||
</button>
|
||||
<button
|
||||
onClick={() => this.editor.focus().bold()}
|
||||
className={`${this.editor.isActive('bold') ? 'is-active' : ''}`}
|
||||
>
|
||||
bold
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
<div ref={this.editorNode} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user