Skip to content

Commit 1d91ee5

Browse files
committed
fix(历史记录): 数据格式不一致问题
1 parent 56d67f1 commit 1d91ee5

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

packages/core/plugin/HistoryPlugin.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* @Author: 秦少卫
44
* @Date: 2023-06-20 13:06:31
55
* @LastEditors: 秦少卫
6-
* @LastEditTime: 2024-04-10 17:33:25
6+
* @LastEditTime: 2024-04-17 12:26:45
77
* @Description: 历史记录插件
88
*/
99
import { fabric } from 'fabric';
@@ -30,12 +30,13 @@ class HistoryPlugin {
3030
this.canvas = canvas;
3131
this.editor = editor;
3232
this._init();
33+
34+
fabric.Canvas.prototype._historyNext = () => {
35+
return this.editor.getJson();
36+
};
3337
}
3438

3539
_init() {
36-
this.canvas.getObjects().forEach((item) => {
37-
this.canvas.add(item);
38-
});
3940
this.canvas.on('history:append', () => {
4041
this.historyUpdate();
4142
});

typings/extends.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ declare namespace fabric {
66
isDragging: boolean;
77
_currentTransform: unknown;
88
clearHistory(): void;
9+
_historyNext(): void;
910
_centerObject: (obj: fabric.Object, center: fabric.Point) => fabric.Canvas;
1011
_setupCurrentTransform(e: Event, target: fabric.Object, alreadySelected: boolean): void;
1112
}

0 commit comments

Comments
 (0)