How to use the prosemirror-model.DOMParser.schemaRules function in prosemirror-model

To help you get started, we’ve selected a few prosemirror-model 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 pubpub / pubpub-editor / src / schema / setup / clipboard.js View on Github external
const markSerializer = DOMSerializer.marksFromSchema(schema);
  const nodeSerializer = DOMSerializer.nodesFromSchema(schema);

  /*
  nodeSerializer.block_embed = function toDOM(node) {
    return null;
  };

  nodeSerializer.embed = function toDOM(node) {
    return null;
  };
  */

  const clipboardSerializer = new DOMSerializer(nodeSerializer, markSerializer);
  const defaultRules = DOMParser.schemaRules(schema);
  const transformPastedHTML = function(htmlStr) {
    return htmlStr;
    // const markdown = markdowntoHTML(htmlStr);
    // return markdown;
  }

  const clipboardParser = new DOMParser(schema, defaultRules);

  return { transformPastedHTML, clipboardSerializer, clipboardParser };

}
github pubpub / pubpub / src / components / AtomTypes / Document / proseEditor / clipboardSerializer.js View on Github external
import {schema} from './schema';

const markSerializer = DOMSerializer.marksFromSchema(schema);
const nodeSerializer = DOMSerializer.nodesFromSchema(schema);

nodeSerializer.block_embed = function toDOM(node) {
  return ElementSchema.serializeNode(node);
};

nodeSerializer.embed = function toDOM(node) {
  return ElementSchema.serializeNode(node);
};

const clipboardSerializer = new DOMSerializer(nodeSerializer, markSerializer);

const defaultRules = DOMParser.schemaRules(schema);

const getNodeAttrs = (dom) => {
  const nodeId = dom.getAttribute('data-nodeId');
  const nodeAttrs = ElementSchema.findNodeById(nodeId).attrs;
  const randomId = Math.floor(Math.random()*10000000);
  return {
    source: nodeAttrs.source,
    data: nodeAttrs.data,
    align: nodeAttrs.align,
    size: nodeAttrs.size,
    caption: nodeAttrs.caption,
    mode: nodeAttrs.mode,
    className: nodeAttrs.className,
    figureName: nodeAttrs.figureName,
    nodeId: randomId,
  };