UNPKG

owl-bt

Version:

owl-bt is editor for Behavior trees. It has been inspired by Unreal engine behavior trees in a way, that it supports special node items like decorators and services. This makes trees smaller and much more readable.

46 lines (37 loc) 1.02 kB
'use strict'; import UndoManager from 'undo-manager'; angular.module('editorApp') .service('UndoRedoManager', class UndoRedoManager { constructor(undoStackSize) { this._undoManager = new UndoManager(); this._undoManager.setLimit(undoStackSize); } /** * Add undo/redo command to stack * @param {undoRedoCommand} undoRedoCommand * @param {function} undoRedoCommand.undo - function to undo change * @param {function} undoRedoCommand.exec - function to redo change */ add(undoRedoCommand) { this._undoManager.add({ undo: undoRedoCommand.undo, redo: undoRedoCommand.exec }); } undo() { this._undoManager.undo(); } redo() { this._undoManager.redo(); } clear() { this._undoManager.clear(); } hasUndo() { return this._undoManager.hasUndo(); } hasRedo() { return this._undoManager.hasRedo(); } });