fix more linting errors
This commit is contained in:
@@ -1,11 +1,15 @@
|
||||
import React, { useState, useRef, useEffect, createContext, useContext } from 'react'
|
||||
import {
|
||||
useState, useRef, useEffect, createContext, useContext,
|
||||
} from 'react'
|
||||
import { Editor as Tiptap } from '@tiptap/core'
|
||||
|
||||
export const EditorContext = createContext({})
|
||||
|
||||
export const useEditor = () => useContext(EditorContext)
|
||||
|
||||
export const Editor = ({ value, onChange, children, ...props }) => {
|
||||
export const Editor = ({
|
||||
value, onChange, children, ...props
|
||||
}) => {
|
||||
const [editor, setEditor] = useState(null)
|
||||
const editorRef = useRef(null)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { useState } from 'react'
|
||||
import { useEditor, Editor } from './components/Editor'
|
||||
import { useState } from 'react'
|
||||
import extensions from '@tiptap/starter-kit'
|
||||
import { useEditor, Editor } from './components/Editor'
|
||||
|
||||
// Menu bar example component
|
||||
// useEditor only works for child components of <Editor />
|
||||
@@ -24,39 +24,39 @@ const MenuBar = () => {
|
||||
|
||||
export default () => {
|
||||
const [value, setValue] = useState({
|
||||
'type': 'document',
|
||||
'content': [
|
||||
{
|
||||
'type': 'paragraph',
|
||||
'content': [
|
||||
{
|
||||
'type': 'text',
|
||||
'text': 'rendered in '
|
||||
},
|
||||
{
|
||||
'type': 'text',
|
||||
'marks': [
|
||||
{
|
||||
'type': 'bold'
|
||||
}
|
||||
],
|
||||
'text': 'react'
|
||||
},
|
||||
{
|
||||
'type': 'text',
|
||||
'text': '!'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
})
|
||||
type: 'document',
|
||||
content: [
|
||||
{
|
||||
type: 'paragraph',
|
||||
content: [
|
||||
{
|
||||
type: 'text',
|
||||
text: 'rendered in ',
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
marks: [
|
||||
{
|
||||
type: 'bold',
|
||||
},
|
||||
],
|
||||
text: 'react',
|
||||
},
|
||||
{
|
||||
type: 'text',
|
||||
text: '!',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
})
|
||||
|
||||
return (
|
||||
<>
|
||||
<p>
|
||||
<button onClick={() => alert(JSON.stringify(value))}>Alert state</button>
|
||||
</p>
|
||||
<hr style={{ margin: '0.85rem 0'}} />
|
||||
<hr style={{ margin: '0.85rem 0' }} />
|
||||
<Editor
|
||||
value={value}
|
||||
onChange={setValue}
|
||||
|
||||
Reference in New Issue
Block a user