slab / delta

Simple and expressive JSON format for describing rich-text content and their changes
https://quilljs.com/docs/delta
BSD 3-Clause "New" or "Revised" License
914 stars 130 forks source link

Delta doesn't insert empty line #88

Open wisammechano opened 1 year ago

wisammechano commented 1 year ago

I'm building a Markdown to Delta tool, and for code-blocks, empty lines have to be preserved. I noticed quill.getContents() returns a delta with '' empty insert to preserve empty lines in code-blocks. However, running delta.insert('') doesn't append a new Op to that delta. However, a space character works ok.

example:

const delta = new Delta()
delta.insert('text')
delta.insert('') // delta.insert(' ') works though
delta.insert('another text')

console.log(delta.ops.length) // 2 but expected 3