Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 };
}
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,
};