Skip to content

Commit

Permalink
fix(历史记录): 数据格式不一致问题
Browse files Browse the repository at this point in the history
  • Loading branch information
nihaojob committed Apr 17, 2024
1 parent 56d67f1 commit 1d91ee5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/core/plugin/HistoryPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @Author: 秦少卫
* @Date: 2023-06-20 13:06:31
* @LastEditors: 秦少卫
* @LastEditTime: 2024-04-10 17:33:25
* @LastEditTime: 2024-04-17 12:26:45
* @Description: 历史记录插件
*/
import { fabric } from 'fabric';
Expand All @@ -30,12 +30,13 @@ class HistoryPlugin {
this.canvas = canvas;
this.editor = editor;
this._init();

fabric.Canvas.prototype._historyNext = () => {
return this.editor.getJson();
};
}

_init() {
this.canvas.getObjects().forEach((item) => {
this.canvas.add(item);
});
this.canvas.on('history:append', () => {
this.historyUpdate();
});
Expand Down
1 change: 1 addition & 0 deletions typings/extends.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ declare namespace fabric {
isDragging: boolean;
_currentTransform: unknown;
clearHistory(): void;
_historyNext(): void;
_centerObject: (obj: fabric.Object, center: fabric.Point) => fabric.Canvas;
_setupCurrentTransform(e: Event, target: fabric.Object, alreadySelected: boolean): void;
}
Expand Down

0 comments on commit 1d91ee5

Please sign in to comment.