简体   繁体   English

为什么我的 QuillJS Delta 不能插入空格?

[英]Why won't my QuillJS Delta insert a space?

I have:我有:

    const delta = quill.formatText(documentData?.prediction?.range?.index, documentData?.prediction?.range?.length, { accepted: 'accepted' })
    delta.insert('\t')
    quill.updateContents(delta)

which creates a delta that looks like:它创建了一个看起来像这样的delta

ops: [
  {retain: 1617},
  {retain: 63, attributes: {…}},
  {insert: "    "}
]

But when my editor doesn't add that space at the end.但是当我的编辑器最后没有添加那个空间时。 If I change it to some text (like hello ), then it inserts hello .如果我将它更改为一些文本(如hello ),那么它会插入hello

But not with a space.但不带空格。 Why not?为什么不?

The question is not very clear - not sure what is the entered data and what is the expected output, but if that's space you want to add, why not use:问题不是很清楚 - 不确定输入的数据是什么以及预期的 output 是什么,但如果这是您要添加的空间,为什么不使用:

var quill = new Quill('#editor-container', {
  theme: 'snow'
});

var ops = [{
    insert: 'This is a test'
  },
];
quill.updateContents(ops)
quill.insertText(0, ' ')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM