gpt4 book ai didi

reactjs - react-quill 将最初传递的包装元素分解为单独的元素

转载 作者:行者123 更新时间:2023-12-05 07:01:56 25 4
gpt4 key购买 nike

我将初始状态传递给 quill editor 是这样的

<blockquote class="quote-aufjd">
<div>
On Wednesday, September 2nd 2020 <a rel="noopener noreferrer" href="mailto:mail">mail</a> wrote: <br>
<div>This is my reply</div>
</div>
</blockquote>

但是当调用 onChange 处理程序时,它会破坏上面传递的 html 到

<blockquote>On Wednesday, September 2nd 2020 
<a href="mailto:nikhil.ponduri@gmail.com" rel="noopener noreferrer" target="_blank">mail</a> wrote:</blockquote>
<blockquote>ok</blockquote>
<blockquote><br></blockquote>

有什么方法可以阻止 quill 分解最初传递的 html 吗??

最佳答案

你提到当 onChange 被调用时你会得到一个错误,但你没有在你的问题中发布该函数的代码!无论如何,我已经尝试回答但无法重现该问题。下面的代码对我来说工作正常,让我知道,

import React from "react";
import ReactQuill from "react-quill";
import "react-quill/dist/quill.snow.css";
import "./styles.css";

const html = `
<blockquote class="quote-aufjd">
<div>
On Wednesday, September 2nd 2020
<a rel="noopener noreferrer" href="mailto:mail">mail</a>
wrote:
<br>
<div>This is my reply</div>
</div>
</blockquote>
`;

export default function App() {
const [text, setText] = React.useState(html);

return (
<div className="App">
<h1>Quill Editor</h1>
<ReactQuill value={text} onChange={setText} />
</div>
);
}


关于reactjs - react-quill 将最初传递的包装元素分解为单独的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63710405/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com