UNPKG

@atlaskit/adf-schema

Version:

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

53 lines (50 loc) 1.53 kB
import { listItem as listItemFactory, listItemWithFlexibleFirstChildStage0 as listItemWithFlexibleFirstChildStage0Factory } from '../../next-schema/generated/nodeTypes'; import { uuid } from '../../utils'; /** * @name list_item * @description this node allows task-list to be nested inside list-item */ export const listItem = listItemFactory({ parseDOM: [{ tag: 'li' }], toDOM() { return ['li', 0]; } }); /** * @name list_item_with_local_id * @description this node allows list items to have a localId attribute */ export const listItemWithLocalId = listItemFactory({ parseDOM: [{ tag: 'li', getAttrs: () => ({ localId: uuid.generate() }) }], toDOM(node) { var _node$attrs; return ['li', { '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 }, 0]; } }); /** * @name list_item_with_flexible_first_child_stage0 * @description stage0 listItem with flexible first child (see EDITOR-5417) */ export const listItemWithFlexibleFirstChildStage0 = listItemWithFlexibleFirstChildStage0Factory({ parseDOM: [{ tag: 'li', getAttrs: () => ({ localId: uuid.generate() }) }], toDOM(node) { var _node$attrs2; return ['li', { 'data-local-id': (node === null || node === void 0 ? void 0 : (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.localId) || undefined }, 0]; } });