How to use prosemirror-markdown - 10 common examples

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 eljefedelrodeodeljefe / vue-prosemirror-2 / index.js View on Github external
function mtodoc () {
          self.content.editor = defaultMarkdownParser.parse(area.value)
          self.content.markdown = area.value
          self.$emit('_content-change-markdown')
        }
        // emulate v-model
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 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 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 pubpub / pubpub-editor / packages / pubpub-prose / dist / prosemirror-setup / editors / simpleEditor.js View on Github external
exports.createSimpleEditor = function (place, doc) {
  var _require = require('../pubpubSetup'),
      pubpubSetup = _require.pubpubSetup;

  var _require2 = require('prosemirror-state'),
      EditorState = _require2.EditorState;

  var _require3 = require('prosemirror-view'),
      EditorView = _require3.EditorView;

  var _require4 = require("prosemirror-markdown"),
      defaultMarkdownParser = _require4.defaultMarkdownParser,
      defaultMarkdownSerializer = _require4.defaultMarkdownSerializer;

  // const {clipboardParser, clipboardSerializer} = require('./proseEditor/clipboardSerializer');

  /*
  const state = EditorState.create({
    // doc: pubSchema.nodeFromJSON(this.collab.doc.contents),
  	plugins: [pubpubSetup({schema: pubSchema})],
  });
  */


  var view = void 0;
  try {
    view = new EditorView(place, {
      state: EditorState.create({ schema: _schema.schema }),
github pubpub / pubpub-editor / packages / pubpub-prose / dist / prosemirror-setup / editors / simpleEditor.js View on Github external
exports.createSimpleEditor = function (place, doc) {
  var _require = require('../pubpubSetup'),
      pubpubSetup = _require.pubpubSetup;

  var _require2 = require('prosemirror-state'),
      EditorState = _require2.EditorState;

  var _require3 = require('prosemirror-view'),
      EditorView = _require3.EditorView;

  var _require4 = require("prosemirror-markdown"),
      defaultMarkdownParser = _require4.defaultMarkdownParser,
      defaultMarkdownSerializer = _require4.defaultMarkdownSerializer;

  // const {clipboardParser, clipboardSerializer} = require('./proseEditor/clipboardSerializer');

  /*
  const state = EditorState.create({
    // doc: pubSchema.nodeFromJSON(this.collab.doc.contents),
  	plugins: [pubpubSetup({schema: pubSchema})],
  });
  */


  var view = void 0;
  try {
    view = new EditorView(place, {
      state: EditorState.create({ schema: _schema.schema }),
      onAction: function onAction(action) {
github eljefedelrodeodeljefe / vue-prosemirror-2 / index.js View on Github external
'setupProseMirror': function (content, editor) {
        const self = this

        this.view = new MenuBarEditorView(editor, {
          state: EditorState.create({
            doc: defaultMarkdownParser.parse(content),
            plugins: exampleSetup({schema})
          }),
          onAction: (action) => {
            self.$emit('_content-change-editor', action)
            self.content.editor = this.view.editor.state.doc
            self.content.markdown = defaultMarkdownSerializer.serialize(this.view.editor.state.doc)
          }
        })
        this.view.editor.focus()
      },
      'bindTextarea': function (area) {
github eljefedelrodeodeljefe / vue-prosemirror-2 / index.js View on Github external
this.$on('_content-change-markdown', () => {
        if (this.mode === 'all') {
          const state = EditorState.create({
            doc: defaultMarkdownParser.parse(this.content.markdown),
            plugins: exampleSetup({schema})
          })
          this.view.editor.updateState(state)
        }
        this.$emit('content-change-markdown')
      })