Skip to content

Refactor Content Editor Markdown Serializer

What does this MR do?

Refactors the Content Editor’s Markdown Serializer to delegate the serialization of individual node types to each Content Type extension. What do I mean by this?

The current MarkdownSerializer implements how every node type should be converted into Markdown, for example: It specifies how a Bold node should be converted into **text**. Everything is in a single place.

The advantage of this approach is that all the serialization logic in encapsulated in a single module. Do you want to change something about how serialization works? Go to the markdown_serializer.js module. Why are we changing it though?

The MR also adds a new test that ensures:

  • The markdown serializer specs are properly built by the content editor factory.
  • The content editor supports external extensions.

Extension-focused architecture

One of the core goals of the Content Editor’s architecture is extensibility. We want to allow extensions to augment the editor without changing the Editor’s core. For example, if a developer implements a GlLabelReference extension, we want that extension to specify how to serialize this node type as Markdown.

Why are we implementing this refactoring now?

We recently upgraded to TipTap v2. This upgrade allow us to extend TipTap’s built-in extensions easily. We are taking advantage of this extensibility to build serialization into every extension that represents a Node Type.

Screenshots (strongly suggested)

Does this MR meet the acceptance criteria?

Conformity

Availability and Testing

Security

If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:

  • Label as security and @ mention @gitlab-com/gl-security/appsec
  • The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
  • Security reports checked/validated by a reviewer from the AppSec team
Edited by Enrique Alcántara

Merge request reports