编辑的撤销重做算法
// 定义撤销和重做命令的基类
class Command {
execute() {}
undo() {}
redo() {}
}
// 示例命令类
class ChangeTextCommand extends Command {
constructor(receiver, newText) {
super()
this.receiver = receiver
this.newText = newText
this.oldText = receiver.text