UNPKG

@limetech/lime-elements

Version:
29 lines (28 loc) 836 B
export const createNodeSpec = (config) => { const attributeSpecs = {}; for (const attribute of config.attributes) attributeSpecs[attribute] = {}; const tag = `${config.tagName}[${config.attributes.map((attr) => attr).join('][')}]`; return { group: 'inline', content: '(text* | inline*)', inline: true, atom: true, selectable: true, attrs: attributeSpecs, toDOM: (node) => [config.tagName, node.attrs], parseDOM: [ { tag: tag, getAttrs: (dom) => { const attributes = {}; // eslint-disable-next-line unicorn/no-array-for-each config.attributes.forEach((attribute) => (attributes[attribute] = dom.getAttribute(attribute))); return attributes; }, }, ], }; }; //# sourceMappingURL=plugin-factory.js.map