debian-mirror-gitlab/app/assets/javascripts/behaviors/markdown/serializer.js

25 lines
549 B
JavaScript
Raw Normal View History

2019-03-02 22:35:43 +05:30
import { MarkdownSerializer } from 'prosemirror-markdown';
import editorExtensions from './editor_extensions';
const nodes = editorExtensions
2021-03-08 18:12:59 +05:30
.filter((extension) => extension.type === 'node')
2019-03-02 22:35:43 +05:30
.reduce(
(ns, { name, toMarkdown }) => ({
...ns,
[name]: toMarkdown,
}),
{},
);
const marks = editorExtensions
2021-03-08 18:12:59 +05:30
.filter((extension) => extension.type === 'mark')
2019-03-02 22:35:43 +05:30
.reduce(
(ms, { name, toMarkdown }) => ({
...ms,
[name]: toMarkdown,
}),
{},
);
export default new MarkdownSerializer(nodes, marks);