Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const fromMarkdown = (markdown: string, schema: EditorSchema) =>
new MarkdownParser(schema, md('commonmark'), {
blockquote: { block: 'blockquote' },
paragraph: { block: 'paragraph' },
list_item: { block: 'listItem' },
bullet_list: { block: 'bulletList' },
ordered_list: {
block: 'orderedList',
getAttrs: tok => ({ order: parseInt(tok.attrGet('order') ?? '1', 10) }),
},
heading: { block: 'heading', getAttrs: tok => ({ level: +tok.tag.slice(1) }) },
code_block: { block: 'codeBlock' },
fence: { block: 'codeBlock', getAttrs: tok => ({ language: tok.info }) },
hr: { node: 'horizontalRule' },
image: {
node: 'image',
getAttrs: tok => ({
src: tok.attrGet('src'),
import { CitationEngine } from '../references';
import { MarkdownParser } from 'prosemirror-markdown';
import { Schema } from 'prosemirror-model';
import markdownit from './markdownitInstance';
import { schema as pubSchema } from '../prosemirror-setup/schema';
const markdownSchema = pubSchema;
export const markdownParser = new MarkdownParser(markdownSchema,
markdownit,
{
article: {block: 'article'},
blockquote: {block: 'blockquote'},
paragraph: {block: 'paragraph'},
list_item: {block: 'list_item'},
bullet_list: {block: 'bullet_list'},
ordered_list: {block: 'ordered_list', attrs: tok => ({order: +tok.attrGet('order') || 1})},
heading: {block: 'heading', attrs: tok => ({level: +tok.tag.slice(1)})},
code_block: {block: 'code_block'},
fence: {block: 'code_block'},
html_inline: {node: 'code_block'},
html_block: {node: 'html_block', attrs: tok => {
return {content: tok.content};
}},
var _prosemirrorMarkdown = require('prosemirror-markdown');
var _prosemirrorModel = require('prosemirror-model');
var _markdownitInstance = require('./markdownitInstance');
var _markdownitInstance2 = _interopRequireDefault(_markdownitInstance);
var _schema = require('../prosemirror-setup/schema');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var markdownSchema = _schema.schema;
var markdownParser = exports.markdownParser = new _prosemirrorMarkdown.MarkdownParser(markdownSchema, _markdownitInstance2.default, {
article: { block: 'article' },
blockquote: { block: 'blockquote' },
paragraph: { block: 'paragraph' },
list_item: { block: 'list_item' },
bullet_list: { block: 'bullet_list' },
ordered_list: { block: 'ordered_list', attrs: function attrs(tok) {
return { order: +tok.attrGet('order') || 1 };
} },
heading: { block: 'heading', attrs: function attrs(tok) {
return { level: +tok.tag.slice(1) };
} },
code_block: { block: 'code_block' },
fence: { block: 'code_block' },
html_inline: { node: 'code_block' },
html_block: { node: 'html_block', attrs: function attrs(tok) {
export function addMentionsToMarkdownParser(parser) {
return new MarkdownParser(parser.schema, parser.tokenizer, {
...parser.tokens,
mention: markdownParser(),
});
}