import { CommandProps, RawCommands } from '../types.js' declare module '@tiptap/core' { interface Commands { forEach: { /** * Loop through an array of items. */ forEach: ( items: T[], fn: ( item: T, props: CommandProps & { index: number, }, ) => boolean, ) => ReturnType, } } } export const forEach: RawCommands['forEach'] = (items, fn) => props => { return items.every((item, index) => fn(item, { ...props, index })) }