diff --git a/src/canvas/model/Frame.js b/src/canvas/model/Frame.js index 71ad571b8..e54458b9e 100644 --- a/src/canvas/model/Frame.js +++ b/src/canvas/model/Frame.js @@ -43,6 +43,16 @@ export default Model.extend({ !props.width && this.set(keyAutoW, 1); !props.height && this.set(keyAutoH, 1); + + // this._initUm(); + }, + + _initUm() { + const um = this.em.get('UndoManager'); + const component = this.getComponent(); + if (!um) return; + um.add(component); + console.log({ component, um }); }, getComponent() { diff --git a/src/undo_manager/index.js b/src/undo_manager/index.js index 14e03c930..8cd1c7994 100644 --- a/src/undo_manager/index.js +++ b/src/undo_manager/index.js @@ -307,6 +307,26 @@ export default () => { return result; }, + __getStackRead() { + const result = {}; + const createItem = item => { + const { type, after, before, object } = item.attributes; + return { + type, + after, + before, + object + }; + }; + this.getStack().forEach(item => { + const index = item.get('magicFusionIndex'); + const value = createItem(item); + if (!result[index]) result[index] = [value]; + else result[index].push(value); + }); + return Object.keys(result).map(i => result[i]); + }, + getPointer() { return this.getStack().pointer; },