Commit 0f4a2cbcd85e744539bcac6b3fc6a820a389e9a2

Authored by ly525
1 parent 51c0ab1a

fix(editor): update mutation type for undo-redo

front-end/h5/src/store/plugins/undo-redo/index.js
... ... @@ -5,7 +5,11 @@ import undoRedoHistory from './History'
5 5 * #!zh: setElementCommonStyle 因为是在 mousemove 时候触发的,执行过于频繁,没有必要计入history,因此需要过滤。
6 6 * 主要记录:拖动完成时候(mouseup)时候的位置、删除元素之前的状态等
7 7 */
8   -const unRecordHistoryMutationTypes = ['editor/setElementCommonStyle']
  8 +// const unRecordHistoryMutationTypes = ['editor/setElementCommonStyle']
  9 +const recordHistoryMutationTypes = [
  10 + 'editor/recordRect',
  11 + 'editor/elementManager'
  12 +]
9 13  
10 14 const undoRedoPlugin = (store) => {
11 15 // initialize and save the starting stage
... ... @@ -15,7 +19,7 @@ const undoRedoPlugin = (store) => {
15 19  
16 20 store.subscribe((mutation, state) => {
17 21 const { type } = mutation
18   - if (unRecordHistoryMutationTypes.includes(type)) return
  22 + if (!recordHistoryMutationTypes.includes(type)) return
19 23 // is called AFTER every mutation
20 24 undoRedoHistory.addState(cloneDeep(state))
21 25 })
... ...