How to use the prosemirror-model.DOMSerializer.nodesFromSchema 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 configureClipboard = ({schema}) => {

  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);
github pubpub / pubpub / src / components / AtomTypes / Document / proseEditor / clipboardSerializer.js View on Github external
import {DOMSerializer, DOMParser} from 'prosemirror-model';

import ElementSchema from './elementSchema';
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;