Skip to content

Commit

Permalink
feat(text editor mentions): serialize mention nodes in markdown
Browse files Browse the repository at this point in the history
  • Loading branch information
john-traas committed Sep 5, 2024
1 parent b94a1a8 commit 0c32b7c
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/components/text-editor/utils/markdown-converter.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
import { ContentTypeConverter } from './content-type-converter';
import { EditorView } from 'prosemirror-view';
import { Node as ProseMirrorNode } from 'prosemirror-model';
import {
MarkdownSerializer,
MarkdownSerializerState,
defaultMarkdownSerializer,
} from 'prosemirror-markdown';
import { markdownToHTML } from '../../markdown/markdown-parser';

const mentionSerializer = {
mention: (state: MarkdownSerializerState, node: ProseMirrorNode) => {
state.write(`@${node.attrs.name}:${node.attrs.type}:${node.attrs.id}`);
},
};

const customMarkdownSerializer = new MarkdownSerializer(
{
...defaultMarkdownSerializer.nodes,
mention: mentionSerializer.mention,
},
{
...defaultMarkdownSerializer.marks,
Expand Down

0 comments on commit 0c32b7c

Please sign in to comment.