How to use the prosemirror-markdown.MarkdownSerializer function in prosemirror-markdown

To help you get started, we’ve selected a few prosemirror-markdown examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gitlabhq / gitlabhq / app / assets / javascripts / content_editor / services / markdown_serializer.js View on Github external
serialize: ({ schema, content }) => {
      const document = schema.nodeFromJSON(content);
      const serializer = new ProseMirrorMarkdownSerializer(defaultMarkdownSerializer.nodes, {
        ...defaultMarkdownSerializer.marks,
        bold: {
          // creates a bold alias for the strong mark converter
          ...defaultMarkdownSerializer.marks.strong,
        },
        italic: { open: '_', close: '_', mixable: true, expelEnclosingWhitespace: true },
      });

      return serializer.serialize(document, {
        tightLists: true,
      });
    },
  };
github pubpub / pubpub-editor / packages / pubpub-editor / src / addons / MarkdownAddon / markdown / markdownSerializer.js View on Github external
import { MarkdownSerializer } from 'prosemirror-markdown';
import { generateBibTexString } from '../references/citationConversion';

// serialize to markdown and keep stack?
export const markdownSerializer = new MarkdownSerializer({
	blockquote(state, node) {
		state.wrapBlock('> ', null, node, () => state.renderContent(node));
	},
	code_block(state, node) {
		if (node.attrs.params === null) {
			state.wrapBlock('    ', null, node, () => state.text(node.textContent, false));
		} else {
			state.write('```' + node.attrs.params + '\n');
			state.text(node.textContent, false);
			state.ensureNewLine();
			state.write('```');
			state.closeBlock(node);
		}
	},
	heading(state, node) {
		state.write(state.repeat('#', node.attrs.level) + ' ');
github pubpub / pubpub-editor / packages / pubpub-editor / dist / markdown / markdownSerializer.js View on Github external
Object.defineProperty(exports, "__esModule", {
	value: true
});
exports.markdownSerializer = undefined;

var _ref;

var _prosemirrorMarkdown = require('prosemirror-markdown');

var _citationConversion = require('../references/citationConversion');

function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }

// serialize to markdown and keep stack?
var markdownSerializer = exports.markdownSerializer = new _prosemirrorMarkdown.MarkdownSerializer((_ref = {
	blockquote: function blockquote(state, node) {
		state.wrapBlock('> ', null, node, function () {
			return state.renderContent(node);
		});
	},
	code_block: function code_block(state, node) {
		if (node.attrs.params === null) {
			state.wrapBlock('    ', null, node, function () {
				return state.text(node.textContent, false);
			});
		} else {
			state.write('```' + node.attrs.params + '\n');
			state.text(node.textContent, false);
			state.ensureNewLine();
			state.write('```');
			state.closeBlock(node);
github quartzy / prosemirror-suggestions / src / mentions.js View on Github external
export function addMentionsToMarkdownSerializer(serializer) {
  return new MarkdownSerializer(
    {
      ...serializer.nodes,
      mention: markdownSerializer(),
    },
    serializer.marks,
  );
}
github gitlabhq / gitlabhq / app / assets / javascripts / behaviors / markdown / serializer.js View on Github external
[name]: toMarkdown,
    }),
    {},
  );

const marks = editorExtensions
  .filter((extension) => extension.type === 'mark')
  .reduce(
    (ms, { name, toMarkdown }) => ({
      ...ms,
      [name]: toMarkdown,
    }),
    {},
  );

export default new MarkdownSerializer(nodes, marks);
github ifiokjr / remirror / @remirror / editor-markdown / src / to-markdown.ts View on Github external
export const toMarkdown = (content: ProsemirrorNode) =>
  new MarkdownSerializer(
    {
      blockquote(state, node) {
        state.wrapBlock('> ', undefined, node, () => state.renderContent(node));
      },
      codeBlock(state, node) {
        const language: string | undefined = node.attrs.language;
        state.write(`\`\`\`${language ?? ''}\n`);
        state.text(node.textContent, false);
        state.ensureNewLine();
        state.write('```');
        state.closeBlock(node);
      },
      heading(state, node) {
        state.write(`${state.repeat('#', node.attrs.level)} `);
        state.renderInline(node);
        state.closeBlock(node);