@atlaskit/adf-schema
Version:
Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs
39 lines (37 loc) • 1.2 kB
JavaScript
import { uuid } from '../../utils/uuid';
import { status as statusFactory } from '../../next-schema/generated/nodeTypes';
/**
* @name status_node
*/
export var status = statusFactory({
parseDOM: [{
tag: 'span[data-node-type="status"]',
getAttrs: function getAttrs(domNode) {
// eslint-disable-next-line @atlaskit/editor/no-as-casting
var dom = domNode;
return {
// @ts-ignore TS1501: This regular expression flag is only available when targeting 'es6' or later.
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
text: dom.textContent.replace(/\n/, '').trim(),
color: dom.getAttribute('data-color'),
localId: uuid.generate(),
style: dom.getAttribute('data-style')
};
}
}],
toDOM: function toDOM(node) {
var _node$attrs = node.attrs,
text = _node$attrs.text,
color = _node$attrs.color,
localId = _node$attrs.localId,
style = _node$attrs.style;
var attrs = {
'data-node-type': 'status',
'data-color': color,
'data-local-id': localId,
'data-style': style,
contenteditable: 'false'
};
return ['span', attrs, text];
}
});