gitlab-org--gitlab-foss/app/assets/javascripts/behaviors/markdown/serializer.js
Douwe Maan 8a03dbf8b7
Use nodes and marks to power Copy-as-GFM
The spec needed to be updated because in some cases the resulting
Markdown is slightly different, though equally valid.
2019-01-24 12:06:53 +01:00

24 lines
545 B
JavaScript

import { MarkdownSerializer } from 'prosemirror-markdown';
import editorExtensions from './editor_extensions';
const nodes = editorExtensions
.filter(extension => extension.type === 'node')
.reduce(
(ns, { name, toMarkdown }) => ({
...ns,
[name]: toMarkdown,
}),
{},
);
const marks = editorExtensions
.filter(extension => extension.type === 'mark')
.reduce(
(ms, { name, toMarkdown }) => ({
...ms,
[name]: toMarkdown,
}),
{},
);
export default new MarkdownSerializer(nodes, marks);