如何解决为什么QullJS增量出现乱序?
生成的增量看起来像:
{"ops":[{"retain":710},{"insert":" yesterday,and she says—”\n“The clinic?","attributes":{"prediction":"prediction"}},{"delete":28}]}
我的代码是:
const delta = new Delta()
.retain(documentData?.prediction?.currentPosition)
.delete(previousPredictionText?.length || 0)
.insert(predictionText,{ prediction: 'prediction' })
console.log('delta',JSON.stringify(delta))
quillEditor.updateContents(delta)
似乎我应该先retain
,然后delete
,然后insert
,但是生成的delta
似乎以不同的顺序执行。我在做什么错了?
解决方法
这与您https://github.com/quilljs/delta/issues/12所遇到的几乎相同的问题,他们没有分步执行,它们都引用当前文档。
在链接中甚至还提供了有关如何执行此操作的指南,import {LitElement,html,customElement,property,css} from 'lit-element';
@customElement('my-test-element')
export class MyTestElement extends LitElement {
static styles = css`
:host {
display: block;
border: solid 1px gray;
padding: 16px;
max-width: 800px;
}
`;
/**
* The name to say "Hello" to.
*/
@property()
name = 'World';
/**
* The number of times the button has been clicked.
*/
@property({type: Number})
count = 0;
render() {
return html`
<h1>Hello,${this.name}!</h1>
`;
}
}
declare global {
interface HTMLElementTagNameMap {
'my-test-element': MyTestElement;
}
}
https://quilljs.com/guides/designing-the-delta-format/
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。