UNPKG

@atlaskit/adf-schema

Version:

Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs

28 lines 612 B
/** * Factory method to attach custom parseDOM and/or toDOM for nodeSpec * * @example * createPMNodeSpecFactory<SomeNode>(node)({parseDOM: {}, toDOM: (node) => {} }); * * @param nodeSpec - NodeSpec without toDom and parseDom * @returns A function for a node which allows the consumer to define toDom and parseDom */ export const createPMNodeSpecFactory = nodeSpec => ({ parseDOM, toDOM, toDebugString }) => { // @ts-ignore return { ...nodeSpec, ...(parseDOM && { parseDOM }), ...(toDOM && { toDOM }), ...(toDebugString && { toDebugString }) }; };