Preserve paragraphs in RTE
What does this MR do and why?
Preserve paragraphs in RTE
Allow preservation of original paragraph style (whether markdown or HTML) and also allow preservation of reference style link definitions
This is a multi-MR effort to split and merge !149930 (closed) (issue: #455457 (closed)) and other work related to issues in &7722 behind a feature flag.
- Improve sourcemap generation in RTE (!160709 - merged)
- Improve preservation of marks in RTE (!160721 - merged)
-
Preserve paragraphs in RTE (!161014 - merged) (
👈 this MR)
Related to issues:
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Included in the setup instructions below:
How to set up and validate locally
Setup
- Enable feature flag
:preserve_markdown
. - In an issue comment, switch to plain text editor.
- Enter the following test markdown:
This paragraph has **bold**, `code`, _italic_ text in it.
It also has text spread over multiple lines. Oh, and it has
a [link](https://gitlab.com) too, and [another one][1] that
is a reference link.
And this is a second paragraph with some ~~striked~~ content and
another [reference style link][2]. Also has some differently
styled __bold__ and *italic* tags.
[1]: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/161014
[2]: https://gitlab.com/gitlab-org/gitlab/-/issues/455388
Testing unchanged paragraphs
- Switch to the rich text editor.
- Press
Enter
and add a third paragraph:This is a third paragraph.
- Switch back to plain text editing. The first three paragraphs are preserved because they were unchanged.
Expected output:
This paragraph has **bold**, `code`, _italic_ text in it.
It also has text spread over multiple lines. Oh, and it has
a [link](https://gitlab.com) too, and [another one][1] that
is a reference link.
And this is a second paragraph with some ~~striked~~ content and
another [reference style link][2]. Also has some differently
styled __bold__ and *italic* tags.
This is a third paragraph.
[1]: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/161014
[2]: https://gitlab.com/gitlab-org/gitlab/-/issues/455388
Testing inline content in paragraphs that are changed
- Switch to the rich text editor.
- Add
New content
next to each paragraph. - The paragraph styles (splitting of content into multiple lines) can no longer be preserved because the paragraphs are now changed. Every paragraph is now displayed in a single line. But the inline content styles including reference style links and their definitions are preserved.
Expected output:
This paragraph has **bold**, `code`, _italic_ text in it. It also has text spread over multiple lines. Oh, and it has a [link](https://gitlab.com) too, and [another one][1] that is a reference link. New content.
And this is a second paragraph with some ~~striked~~ content and another [reference style link][2]. Also has some differently styled __bold__ and *italic* tags. New content.
This is a third paragraph. New content.
[1]: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/161014
[2]: https://gitlab.com/gitlab-org/gitlab/-/issues/455388
Not covered in this MR:
If you create a paragraph using <p>
tags in plain text editor and regardless of whether you change it when editing in RTE or not, it will always be changed to a Markdown paragraph. This is because paragraphs created with <p>
tags in HTML cannot support Markdown content, but we cannot have such restriction on any paragraph in rich text editor.