我有一个自定义的羊皮纸,看起来像:
import { Quill } from 'react-quill';
const Parchment = Quill.import('parchment');
let config = { scope: Parchment.Scope.INLINE };
let AcceptedPredictionClass = new Parchment.Attributor.Class('accepted', 'ql', config);
Quill.register(AcceptedPredictionClass)并使用它:
const delta = new Delta()
.retain(currentSelection.index)
.delete(predictionLength)
.insert(previousPredictionText, { accepted: 'accepted' })
quill.updateContents(delta)但问题是,如果我开始输入,它会保持ql-accepted样式。我需要它恢复正常。
发布于 2020-08-09 13:15:06
简单地在最后一次插入之后再添加一个.insert(' ', {})怎么样?这应该会在插入的类之后添加一个正常的跨度。
它将是这样的:
const delta = new Delta()
.retain(currentSelection.index)
.delete(predictionLength)
.insert(previousPredictionText, { accepted: 'accepted' })
.insert(' ', {})
quill.updateContents(delta)仅供参考:我还没有测试它,但一般的想法是,光标将在新的跨度内,没有添加的类。
https://stackoverflow.com/questions/63001390
复制相似问题