Created
October 25, 2021 02:39
-
-
Save jaccon/7b82d6bed9c40fc33c79a17ea93c8585 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useRef } from 'react'; | |
import { Editor } from '@tinymce/tinymce-react'; | |
export default function App() { | |
const editorRef = useRef(null); | |
const log = () => { | |
if (editorRef.current) { | |
console.log(editorRef.current.getContent()); | |
} | |
}; | |
return ( | |
<> | |
<Editor | |
onInit={(evt, editor) => editorRef.current = editor} | |
initialValue="<p>This is the initial content of the editor.</p>" | |
init={{ | |
height: 500, | |
menubar: false, | |
plugins: [ | |
'advlist autolink lists link image charmap print preview anchor', | |
'searchreplace visualblocks code fullscreen', | |
'insertdatetime media table paste code help wordcount' | |
], | |
toolbar: 'undo redo | formatselect | ' + | |
'bold italic backcolor | alignleft aligncenter ' + | |
'alignright alignjustify | bullist numlist outdent indent | ' + | |
'removeformat | help', | |
content_style: 'body { font-family:Helvetica,Arial,sans-serif; font-size:14px }' | |
}} | |
/> | |
<button onClick={log}>Log editor content</button> | |
</> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment