@atlaskit/adf-schema
Version:
Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs
31 lines (29 loc) • 902 B
JavaScript
import { uuid } from '../../utils/uuid';
import { taskItem as taskItemFactory } from '../../next-schema/generated/nodeTypes';
/**
* @name taskItem_node
*/
export var taskItem = taskItemFactory({
parseDOM: [{
tag: 'div[data-task-local-id]',
// Default priority is 50. We normally don't change this but since this node type is
// also used by list-item we need to make sure that we run this parser first.
priority: 100,
getAttrs: function getAttrs(dom) {
return {
localId: uuid.generate(),
state: dom.getAttribute('data-task-state') || 'TODO'
};
}
}],
toDOM: function toDOM(node) {
var _node$attrs = node.attrs,
localId = _node$attrs.localId,
state = _node$attrs.state;
var attrs = {
'data-task-local-id': localId || 'local-task',
'data-task-state': state || 'TODO'
};
return ['div', attrs, 0];
}
});