|
|
@ -25,7 +25,7 @@ |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
import UndoManager from 'backbone-undo'; |
|
|
import UndoManager from 'backbone-undo'; |
|
|
import { isArray, isBoolean, isEmpty, unique } from 'underscore'; |
|
|
import { isArray, isBoolean, isEmpty, unique, times } from 'underscore'; |
|
|
|
|
|
|
|
|
export default () => { |
|
|
export default () => { |
|
|
let em; |
|
|
let em; |
|
|
@ -319,13 +319,13 @@ export default () => { |
|
|
getGroupedStack() { |
|
|
getGroupedStack() { |
|
|
const result = {}; |
|
|
const result = {}; |
|
|
const stack = this.getStack(); |
|
|
const stack = this.getStack(); |
|
|
const createItem = item => { |
|
|
const createItem = (item, index) => { |
|
|
const { type, after, before, object, options = {} } = item.attributes; |
|
|
const { type, after, before, object, options = {} } = item.attributes; |
|
|
return { type, after, before, object, options }; |
|
|
return { index, type, after, before, object, options }; |
|
|
}; |
|
|
}; |
|
|
stack.forEach(item => { |
|
|
stack.forEach((item, i) => { |
|
|
const index = item.get('magicFusionIndex'); |
|
|
const index = item.get('magicFusionIndex'); |
|
|
const value = createItem(item); |
|
|
const value = createItem(item, i); |
|
|
|
|
|
|
|
|
if (!result[index]) { |
|
|
if (!result[index]) { |
|
|
result[index] = [value]; |
|
|
result[index] = [value]; |
|
|
@ -337,8 +337,7 @@ export default () => { |
|
|
return Object.keys(result).map(index => { |
|
|
return Object.keys(result).map(index => { |
|
|
const actions = result[index]; |
|
|
const actions = result[index]; |
|
|
return { |
|
|
return { |
|
|
// index: stack.models.indexOf(actions[0]),
|
|
|
index: actions[actions.length - 1].index, |
|
|
index, |
|
|
|
|
|
actions, |
|
|
actions, |
|
|
labels: unique( |
|
|
labels: unique( |
|
|
actions.reduce((res, item) => { |
|
|
actions.reduce((res, item) => { |
|
|
@ -351,6 +350,15 @@ export default () => { |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
goToPointer(group) { |
|
|
|
|
|
if (!group) return; |
|
|
|
|
|
const current = this.getPointer(); |
|
|
|
|
|
const goTo = group.index - current; |
|
|
|
|
|
times(Math.abs(goTo), () => { |
|
|
|
|
|
this[goTo < 0 ? 'undo' : 'redo'](false); |
|
|
|
|
|
}); |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
getPointer() { |
|
|
getPointer() { |
|
|
return this.getStack().pointer; |
|
|
return this.getStack().pointer; |
|
|
}, |
|
|
}, |
|
|
|