UNPKG

@atlaskit/editor-plugin-list

Version:

List plugin for @atlaskit/editor-core

30 lines (29 loc) 1.49 kB
import { getFirstParagraphBlockMarkAttrs, reconcileBlockMarkForContainerAtPos } from '@atlaskit/editor-common/lists'; import { isListNode } from '@atlaskit/editor-common/utils'; import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals'; export function mergeNextListAtPosition(_ref) { var tr = _ref.tr, listPosition = _ref.listPosition; var listNodeAtPosition = tr.doc.nodeAt(listPosition); if (!isListNode(listNodeAtPosition)) { return; } // Ignored via go/ees005 // eslint-disable-next-line @typescript-eslint/no-non-null-assertion var listPositionResolved = tr.doc.resolve(listPosition + listNodeAtPosition.nodeSize); var pos = listPositionResolved.pos, nodeAfter = listPositionResolved.nodeAfter, nodeBefore = listPositionResolved.nodeBefore; if (!isListNode(nodeBefore) || !isListNode(nodeAfter)) { return; } var previousListPosition = pos - nodeBefore.nodeSize; if (nodeAfter && nodeAfter.type.name !== (nodeBefore === null || nodeBefore === void 0 ? void 0 : nodeBefore.type.name)) { tr.setNodeMarkup(previousListPosition, nodeAfter.type); } tr.join(pos); if (tr.doc.type.schema.marks.fontSize && expValEquals('platform_editor_small_font_size', 'isEnabled', true)) { var upperListFontSizeAttrs = getFirstParagraphBlockMarkAttrs(nodeBefore, tr.doc.type.schema.marks.fontSize); reconcileBlockMarkForContainerAtPos(tr, previousListPosition, tr.doc.type.schema.marks.fontSize, upperListFontSizeAttrs); } }