info:To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
info:To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
---
---
# Content Editor **(FREE)**
# Content Editor development guidelines **(FREE)**
The Content Editor is a UI component that provides a WYSIWYG editing
The Content Editor is a UI component that provides a WYSIWYG editing
experience for [GitLab Flavored Markdown](../../user/markdown.md)(GFM)in the GitLab application.
experience for [GitLab Flavored Markdown](../../user/markdown.md) in the GitLab application.
It also serves as the foundation for implementing Markdown-focused editors
It also serves as the foundation for implementing Markdown-focused editors
that target other engines, like static site generators.
that target other engines, like static site generators.
...
@@ -16,103 +16,324 @@ to build the Content Editor. These frameworks provide a level of abstraction on
...
@@ -16,103 +16,324 @@ to build the Content Editor. These frameworks provide a level of abstraction on
the native
the native
[`contenteditable`](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Editable_content) web technology.
[`contenteditable`](https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Editable_content) web technology.
## Architecture remarks
## Usage guide
At a high level, the Content Editor:
Follow these instructions to include the Content Editor in a feature.
- Imports arbitrary Markdown.
### Include the Content Editor component
- Renders it in a HTML editing area.
- Exports it back to Markdown with changes introduced by the user.
The Content Editor relies on the
Import the `ContentEditor` Vue component. We recommend using asynchronous named imports to
[Markdown API endpoint](../../api/markdown.md) to transform Markdown
take advantage of caching as the ContentEditor is a big dependency.
into HTML. It sends the Markdown input to the REST API and displays the API's
HTML output in the editing area. The editor exports the content back to Markdown
using a client-side library that serializes editable documents into Markdown.

```html
<script>
Check the [Content Editor technical design document](https://docs.google.com/document/d/1fKOiWpdHned4KOLVOOFYVvX1euEjMP5rTntUhpapdBg)
exportdefault{
for more information about the design decisions that drive the development of the editor.
components:{
ContentEditor:()=>
**NOTE**: We also designed the Content Editor to be extensible. We intend to provide
import(
more information about extension development for supporting new types of content in upcoming
-`uploadsPath` is a URL that points to a [GitLab upload service](../uploads.md#upload-encodings) with `multipart/form-data` support.
## Usage
See the [`WikiForm.vue`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/app/assets/javascripts/pages/shared/wikis/components/wiki_form.vue#L207) component for a production example of these two properties.
To include the Content Editor in your feature, import the `createContentEditor` factory
### Set and get Markdown
function and the `ContentEditor` Vue component. `createContentEditor` sets up an instance
of [tiptap's Editor class](https://www.tiptap.dev/api/editor/) with all the necessary
extensions to support editing GitLab Flavored Markdown content. It also creates
a Markdown serializer that allows exporting tiptap's document format to Markdown.
`createContentEditor` requires a `renderMarkdown` parameter invoked
The `ContentEditor` Vue component doesn't implement Vue data binding flow (v-model)
by the editor every time it needs to convert Markdown to HTML. The Content Editor
because setting and getting Markdown are expensive operations. Data binding would
does not provide a default value for this function yet.
trigger these operations every time that the user interacts with the component.
**NOTE**: The Content Editor is in an early development stage. Usage and development
Instead, you should obtain an instance of the `ContentEditor` class by listening to the
guidelines are subject to breaking changes in the upcoming months.