How to use the prosemirror-model.DOMSerializer 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 / packages / pubpub-prose / dist / prosemirror-setup / clipboard.js View on Github external
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var markSerializer = _prosemirrorModel.DOMSerializer.marksFromSchema(_schema.schema);
var nodeSerializer = _prosemirrorModel.DOMSerializer.nodesFromSchema(_schema.schema);

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

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

var clipboardSerializer = new _prosemirrorModel.DOMSerializer(nodeSerializer, markSerializer);

var defaultRules = _prosemirrorModel.DOMParser.schemaRules(_schema.schema);

var getSize = function getSize(dom) {
  var width = dom.getAttribute("width");
  if (width) {
    return width;
  }
  return undefined;
};

// require('split-html');
// Needs to lift out image blocks in their own div
var transformPastedHTML = function transformPastedHTML(htmlStr) {
  var markdown = (0, _markdownToHTML.markdowntoHTML)(htmlStr);
  return markdown;
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);
    // 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 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;
  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,