UNPKG

@atlaskit/adf-schema

Version:

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

47 lines (45 loc) 1.09 kB
/** * @name layoutColumn_node */ export const layoutColumn = { content: '(block|unsupportedBlock)+', isolating: true, marks: 'alignment indentation dataConsumer fragment unsupportedMark unsupportedNodeAttribute', selectable: false, attrs: { width: { default: undefined } }, parseDOM: [{ context: 'layoutColumn//', tag: 'div[data-layout-column]', skip: true }, { tag: 'div[data-layout-column]', getAttrs: domNode => { const dom = domNode; return { width: Number(dom.getAttribute('data-column-width')) || undefined }; } }], toDOM(node) { const attrs = { 'data-layout-column': 'true' }; const { width } = node.attrs; if (width) { attrs['style'] = `flex-basis: ${width}%`; attrs['data-column-width'] = width; } // We need to apply a attribute to the inner most child to help // ProseMirror identify its boundaries better. const contentAttrs = { 'data-layout-content': 'true' }; return ['div', attrs, ['div', contentAttrs, 0]]; } };