gpt4 book ai didi

reactjs - 从 DraftJS 中的粘贴文本中去除所有样式?

转载 作者:行者123 更新时间:2023-12-05 00:58:52 25 4
gpt4 key购买 nike

当将 word 或其他来源的文本粘贴到 Draftjs 中时,格式随之而来,我尝试像这样剥离样式数据:

onChange={(newEditorState) => {
const raw = convertToRaw(newEditorState.getCurrentContent())
for (let i = 0; i < raw.blocks.length; i++){
raw.blocks[i].type = "unstyled"
}
let newContent = convertFromRaw(raw)
newEditorState
const newState = EditorState.push(state, newContent, "change-block-type")

setState(newState)
}} />

这很有效,只是在那之后输入最终会被反转,这非常令人困惑。

最佳答案

好像是 stripPastedStyles option就是你要找的东西:

Set whether to remove all information except plaintext from pasted content.

This should be used if your editor does not support rich styles.

Default is false.

关于reactjs - 从 DraftJS 中的粘贴文本中去除所有样式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56005514/

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