UNPKG

@wordpress/undo-manager

Version:
8 lines (7 loc) 1.75 kB
{ "version": 3, "sources": ["../src/types.ts"], "sourcesContent": ["/**\n * Represents a single change in history.\n */\nexport interface HistoryChange< From = unknown, To = From > {\n\t/** The previous value */\n\tfrom: From;\n\t/** The new value */\n\tto: To;\n}\n\n/**\n * Represents changes for a single item.\n */\nexport interface HistoryChanges< T = unknown > {\n\t/** The identifier for the item being changed */\n\tid: string | Record< string, unknown >;\n\t/** The changes made to the item */\n\tchanges: Record< string, HistoryChange< T > >;\n}\n\n/**\n * Represents a record of history changes.\n */\nexport type HistoryRecord< T = unknown > = HistoryChanges< T >[];\n\n/**\n * The undo manager interface.\n */\nexport interface UndoManager< T = unknown > {\n\t/**\n\t * Record changes into the history.\n\t *\n\t * @param record A record of changes to record.\n\t * @param isStaged Whether to immediately create an undo point or not.\n\t */\n\taddRecord: ( record?: HistoryRecord< T >, isStaged?: boolean ) => void;\n\n\t/**\n\t * Undo the last recorded changes.\n\t *\n\t * @return The undone record or undefined if nothing to undo.\n\t */\n\tundo: () => HistoryRecord< T > | undefined;\n\n\t/**\n\t * Redo the last undone changes.\n\t *\n\t * @return The redone record or undefined if nothing to redo.\n\t */\n\tredo: () => HistoryRecord< T > | undefined;\n\n\t/**\n\t * Check if there are changes that can be undone.\n\t *\n\t * @return Whether there are changes to undo.\n\t */\n\thasUndo: () => boolean;\n\n\t/**\n\t * Check if there are changes that can be redone.\n\t *\n\t * @return Whether there are changes to redo.\n\t */\n\thasRedo: () => boolean;\n}\n"], "mappings": ";;;;;;;;;;;;;;;;AAAA;AAAA;", "names": [] }