const Inline = Quill.import('blots/inline');
export class Track extends Inline {
static blotName = 'track';
static tagName = 'span';
static formats(node) {
return {
color: node.getAttribute('color'),
cid: node.getAttribute('cid'),
uid: node.getAttribute('uid'),
name: node.getAttribute('name')
};
}
static create({name, uid, cid, color}) {
const node = super.create();
node.setAttribute('name', name);
node.setAttribute('uid', uid);
node.setAttribute('cid', cid);
node.style.backgroundColor = color;
return node;
}
Quill.register(Track);
我已经为 quill 的跟踪更改创建了一个自定义跨度印迹,但是每次有一个新用户时,所有属性(即 cid、uid、名称)都保持一致,除了从前一个跨度印迹继承的背景颜色。尽管是不同的跨度印迹,但我看不到新用户的不同颜色的建议。如何在我的定制跨度印迹中为不同用户执行内联样式?这就是我在代码中添加作者的方式
author() {
this.trackChanges = !this.trackChanges;
const range = this.editor.quillEditor.getSelection();
if (range) {
if (this.trackChanges) {
this.editor.quillEditor.format('track', {name: this.name, uid: this.id, cid: this.chance.guid(), color: this.color});
}
}
}