簡體   English   中英

tinymce 不適用於 React Hook 表單

[英]tinymce is not working with react hook form

我在 NextJS typescript 項目中使用 TinyMCE markdown 編輯器和 React Hook Form。 如果我在沒有react-hook-form情況下使用它,TinyMCE 工作正常。

我在將它與react-hook-form一起使用時遇到問題。 我可以看到editorRef.current.getContent() Html 數據 output。但是data output 是空的 object。

任何想法這里可能有什么問題?

 import { useRef } from 'react'; import { Editor } from '@tinymce/tinymce-react'; import { useForm } from 'react-hook-form'; export default function App() { const editorRef = useRef<any>(null); const { register, handleSubmit } = useForm(); const submitData = (data) => { if (editorRef.current) { console.log(editorRef.current.getContent()); } console.log(data); }; return ( <> <form onSubmit={handleSubmit(submitData)}> <Editor onInit={(evt, editor) => (editorRef.current = editor)} initialValue="" 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', ] }} /> <input type="submit" /> </form> </> ); }

如果有幫助的話,我在 tinyMCE 編輯器 (v5.10) 周圍使用RHF Controller包裝器 (v7.25) 取得了成功

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM