gitlab-org--gitlab-foss/app/assets/javascripts/behaviors/markdown/marks/link.js
Douwe Maan a7e77e10fe
Add tiptap/prosemirror nodes and marks for all Markdown and GFM features
The schema is built on top of the default schema and Node and Mark
classes provided by tiptap-extensions. prosemirror-model is used to
parse HTML/DOM into a prosemirror document, and prosemirror-markdown is
used to serialize this document to (GitLab Flavored) Markdown.
2019-01-24 12:06:52 +01:00

21 lines
726 B
JavaScript

/* eslint-disable class-methods-use-this */
import { Link as BaseLink } from 'tiptap-extensions';
import { defaultMarkdownSerializer } from 'prosemirror-markdown';
// Transforms generated HTML back to GFM for Banzai::Filter::MarkdownFilter
export default class Link extends BaseLink {
get toMarkdown() {
return {
mixable: true,
open(state, mark, parent, index) {
const open = defaultMarkdownSerializer.marks.link.open(state, mark, parent, index);
return open === '<' ? '' : open;
},
close(state, mark, parent, index) {
const close = defaultMarkdownSerializer.marks.link.close(state, mark, parent, index);
return close === '>' ? '' : close;
},
};
}
}