Skip to content

Rename default Markdown deserializer in the Content Editor

Context

The Content Editor is a WYSIWYG editor for GitLab Flavored Markdown. The Content Editor converts Markdown into a data structure called ProseMirror document to allow editing in a WYSIWYG style. We call the process of converting Markdown into a ProseMirror document "deserialization".

What does this MR do?

We are introducing a new Markdown deserializer in the Content Editor that uses a different strategy from the current one. This MR renames the current deserializer to convey its deserialization strategy. The current deserializer uses the GitLab Markdown API while the new one will process Markdown in the client.

This MR also changes the return value of the current deserializer. Before this change, the serialize method had the following type signature:

({ schema: ProseMirror.Schema, content: String }) -> { document: ProseMirror.Node, dom: DOMFragment }

We returned a DOM fragment that resulted from converting the Markdown into HTML. We need both serializers to return a value with the same type signature. The new serializer can’t and shouldn’t return a DOMFragment because it doesn’t convert Markdown to HTML.

Why do we return a DOM fragment anyways?

We use the DOM fragment outside of the deserializer to detect which code block languages the content editor should preload. Instead of returning a DOM fragment, the current deserializer will return an Array with the languages it finds in the DOM Fragment:

({ schema: ProseMirror.Schema, content: String }) -> { document: ProseMirror.Node, languages: String[] }

This is a type signature that both deserializers can satisfy

Screenshots or screen recordings

This MR doesn’t introduce user-facing changes

How to set up and validate locally

This MR doesn’t introduce user-facing changes

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #355787 (closed)

Edited by Enrique Alcántara

Merge request reports

Loading