Skip to content

Preserve paragraphs in RTE

Himanshu Kapoor requested to merge himkp-improve-paragraph-serialization into master

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.

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

  1. Enable feature flag :preserve_markdown.
  2. In an issue comment, switch to plain text editor.
  3. 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

  1. Switch to the rich text editor.
  2. Press Enter and add a third paragraph: This is a third paragraph.
  3. Switch back to plain text editing. The first three paragraphs are preserved because they were unchanged.

Expected output:

image

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

  1. Switch to the rich text editor.
  2. Add New content next to each paragraph.
  3. 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:

image

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.

Edited by Himanshu Kapoor

Merge request reports

Loading