1. A method comprising: applying a first change within a document; determining a context of the first change within the document; storing first data related to the first change in a first stack corresponding to a first context in response to determining that the first change is associated with the first context; applying a second change within the document, the second change occurring after the first change; determining a context of the second change within the document, wherein the context of the second change is a different type of context than the context of the first change; storing second data relating to the second change in a second stack corresponding to a second context that is different than the first context in response to determining that the second change is associated with the second context; determining a current context type based on a hierarchy of criteria, wherein the hierarchy of criteria comprises a first priority criterion being an active selection of the current context and a second priority criterion being an insertion point of the current context; receiving an instruction to undo a change associated with the current context type; determining that the instruction to undo is associated with the first context; and performing an undo function to undo the first change based on the first data without affecting the second change in response to determining that the undo instruction is associated with the first context.