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 `alignment` attribute is ambiguous and doesn't have the right value #83

Closed malomarrec closed 11 months ago

malomarrec commented 2 years ago

Raising this here, although it's unclear if this is an issue with delta or quill itself.

Problem

The delta value doesn't seem to have the right align attribute. For example, I'd expect this:

image

to have a delta value of:

{"ops":[
{"insert":"right", "attributes":{"align":"right"}},
{"insert":"\ncenter\n", "attributes":{"align":"center"}}
]}

But it has the value:

{"ops":[
{"insert":"right"},
{"attributes":{"align":"right"},"insert":"\n"},
{"insert":"center"},
{"attributes":{"align":"center"},"insert":"\n"}
]}

which is very ambiguous: reading this value from outside quill, there's no way I can determine that the word "right" needs to be aligned right.

Codesandbox: https://codesandbox.io/s/blissful-kalam-u04hsn?file=/src/App.tsx

Versions

I was able to reproduce this with a wide combination of versions of react-quill, and delta. The codesandbox example is using:

luin commented 1 year ago

Block-level attributes apply to the \n of the line so I think that explains the question.