Shamoon
Shamoon

Reputation: 43531

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:

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.

But not with a space. Why not?

Upvotes: 0

Views: 1262

Answers (1)

Kuf
Kuf

Reputation: 17828

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:

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

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

Upvotes: 1

Related Questions