UNPKG

@atlaskit/adf-schema

Version:

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

44 lines (42 loc) 1.16 kB
import { date as dateFactory } from '../../next-schema/generated/nodeTypes'; import { uuid } from '../../utils'; /** * @name date_node */ export var date = dateFactory({ parseDOM: [{ tag: 'span[data-node-type="date"]', getAttrs: function getAttrs(dom) { return { timestamp: dom.getAttribute('data-timestamp') }; } }], toDOM: function toDOM(node) { var attrs = { 'data-node-type': 'date', 'data-timestamp': node.attrs.timestamp }; return ['span', attrs]; } }); export var dateWithLocalId = dateFactory({ parseDOM: [{ tag: 'span[data-node-type="date"]', getAttrs: function getAttrs(dom) { return { timestamp: dom.getAttribute('data-timestamp'), localId: uuid.generate() }; } }], toDOM: function toDOM(node) { var _node$attrs; var attrs = { 'data-node-type': 'date', 'data-timestamp': node.attrs.timestamp, 'data-local-id': (node === null || node === void 0 ? void 0 : (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.localId) || undefined }; return ['span', attrs]; } });