@atlaskit/adf-schema
Version:
Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs
53 lines (51 loc) • 980 B
JavaScript
import { uuid } from '../../utils/uuid';
/**
* @name status_node
*/
export const status = {
inline: true,
group: 'inline',
selectable: true,
attrs: {
text: {
default: ''
},
color: {
default: ''
},
localId: {
default: uuid.generate()
},
style: {
default: ''
}
},
parseDOM: [{
tag: 'span[data-node-type="status"]',
getAttrs: domNode => {
const dom = domNode;
return {
text: dom.textContent.replace(/\n/, '').trim(),
color: dom.getAttribute('data-color'),
localId: uuid.generate(),
style: dom.getAttribute('data-style')
};
}
}],
toDOM(node) {
const {
text,
color,
localId,
style
} = node.attrs;
const attrs = {
'data-node-type': 'status',
'data-color': color,
'data-local-id': localId,
'data-style': style,
contenteditable: 'false'
};
return ['span', attrs, text];
}
};