slab / quill

Quill is a modern WYSIWYG editor built for compatibility and extensibility
https://quilljs.com
BSD 3-Clause "New" or "Revised" License
43.18k stars 3.35k forks source link

Line-breaks in a Delta Format #2469

Closed npcole closed 5 months ago

npcole commented 5 years ago

In common with #1511 and also with #252, I think there is a compelling reason to decide on a way to represent a line-break within a line. Even within a heading, it may be necessary to specify a line-break that is not in fact a paragraph break, but for many applications, the ability to have line-breaks within table cells, list items, etc. is important. In other words, the need is more general than the one outlined by #1511 .

The easiest way to represent this would seem to be to pick a character to represent a line-break. In #252 someone suggested the Unicode \u000b character, which seems appropriate.

As for a compelling use-case: I'm looking at adapting quilljs to work as an editor for TEI -- and in the document-editing world it is absolutely essential to be able to distinguish line-breaks from paragraph blocks.

From a technical point of view, is there any reason not to adopt this proposal? A line-break character could be treated by delta formats as just another character, couldn't it? There's no reason to treat it as special in any way that I can see. However, if there is a technical reason this is difficult, I'd be really interested in understanding it.

ile commented 5 years ago

I made this and it seems to work to some extent: https://gist.github.com/ile/8a08c23b5ae0f331dee8ca062fdef40d

martijndekuijper commented 5 years ago

I still can't believe line-breaks are not supported :(

@ile you say:

To some extent

What are the limitations?

ile commented 5 years ago

What are the limitations?

The whole thing is a bit of a guesswork. And it needs my fork of Quill which has a "dirty hack".

There are no real tests to verify that it works 100 %. And I noticed that it seems to get confused if there are a lot of styles and undo/redo is applied. "A lot of styles" means here that I tested it with a template from Google Docs, edited that and tried undo/redo.

But the problems were quite minor that I could find so at the moment I'm using it. Improvements are welcome of course.

Of, and the soft linebreak is created with Ctrl+Shift+Enter because for some reason Shift+Enter didn't seem to be able to trigger the keyboard handler function.

quill-bot commented 5 months ago

Quill 2.0 has been released (announcement post) with many changes and fixes. If this is still an issue please create a new issue after reviewing our updated Contributing guide :pray: