UNPKG

992 BTypeScriptView Raw
1import type { Node } from '@atlaskit/editor-prosemirror/model';
2export interface GetAttrsChange<T, V> {
3 node: Node;
4 prevAttrs?: T;
5 newAttrs: T | false | undefined;
6 options: V;
7}
8export type GetAttrsWithChangesRecorder<T, V> = {
9 getAttrs(prevAttrs?: T | undefined, node?: Node): T | false | undefined;
10 getAndResetAttrsChanges(): GetAttrsChange<T, V>[];
11};
12/**
13 * Create a new getAttrs handler who will wrap the original function,
14 * and store the changes internally to be used for other
15 * tools like Analytics later in the code.
16 *
17 * @param getAttrs - Function who gets the new attributes
18 * @return object
19 * @property handler - New handler to get indentation attributes (It wraps the original)
20 * @property getChanges - Return all the stored changes.
21 * @property clear - Clear the changes
22 */
23export default function getAttrsWithChangesRecorder<T, V>(getAttrs: (prevAttrs?: T, node?: Node) => T | false | undefined, options: V): GetAttrsWithChangesRecorder<T, V>;