UNPKG

@atlaskit/editor-plugin-collab-edit

Version:

Collab Edit plugin for @atlaskit/editor-core

41 lines (40 loc) • 1.31 kB
import type { Step } from '@atlaskit/editor-prosemirror/transform-override'; export type SanitizedStep = { attr?: string; markType?: string; stepType: string; }; /** * Sanitizes a given ProseMirror step by extracting its type and non-UCG relevant attributes. * * @param {Step} step - The ProseMirror step to be sanitized. * @returns {SanitizedStep} - The sanitized step with only necessary information. * * @example * ``` * const step = new AttrStep(10, 'colwidth', [123, 451] ); * const sanitized = sanitizeStep(step); * * // Output: { stepType: 'attr', attr: 'example' } * ``` */ export declare const sanitizeStep: (step: Step) => SanitizedStep; /** * Groups sanitized steps by their type and counts their occurrences. * * @param {SanitizedStep[]} sanitizedSteps - An array of sanitized steps. * @returns {Record<string, number>} - An object where keys are step types and values are their counts. * * @example * ``` * const input = [ * { stepType: 'attr', attr: 'colwidth' }, * { stepType: 'mark', markType: 'bold' }, * { stepType: 'attr', attr: 'colwidth' } * ]; * * const grouped = groupSteps(input); * // Output: { 'attr_example': 2, 'mark_bold': 1 } * ``` */ export declare const groupSteps: (sanitizedSteps: SanitizedStep[]) => Record<string, number>;