File tree Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Expand file tree Collapse file tree 2 files changed +11
-2
lines changed Original file line number Diff line number Diff line change 33 * @Author : 秦少卫
44 * @Date : 2023-06-20 13:06:31
55 * @LastEditors : 秦少卫
6- * @LastEditTime : 2024-04-17 12:26:45
6+ * @LastEditTime : 2024-04-17 13:22:48
77 * @Description : 历史记录插件
88 */
99import { fabric } from 'fabric' ;
@@ -29,11 +29,12 @@ class HistoryPlugin {
2929 constructor ( canvas : fabric . Canvas & extendCanvas , editor : IEditor ) {
3030 this . canvas = canvas ;
3131 this . editor = editor ;
32- this . _init ( ) ;
3332
3433 fabric . Canvas . prototype . _historyNext = ( ) => {
3534 return this . editor . getJson ( ) ;
3635 } ;
36+
37+ this . _init ( ) ;
3738 }
3839
3940 _init ( ) {
@@ -59,6 +60,12 @@ class HistoryPlugin {
5960 }
6061
6162 undo ( ) {
63+ // fix 历史记录退回到第一步时,画布区域可被拖拽
64+ if ( this . canvas . historyUndo . length === 1 ) {
65+ this . editor . clear ( ) ;
66+ this . canvas . clearHistory ( ) ;
67+ return ;
68+ }
6269 this . canvas . undo ( ) ;
6370 this . historyUpdate ( ) ;
6471 }
Original file line number Diff line number Diff line change @@ -5,8 +5,10 @@ declare namespace fabric {
55 wrapperEl : HTMLElement ;
66 isDragging : boolean ;
77 _currentTransform : unknown ;
8+ extraProps : any ;
89 clearHistory ( ) : void ;
910 _historyNext ( ) : void ;
11+ _historyInit ( ) : void ;
1012 _centerObject : ( obj : fabric . Object , center : fabric . Point ) => fabric . Canvas ;
1113 _setupCurrentTransform ( e : Event , target : fabric . Object , alreadySelected : boolean ) : void ;
1214 }
You can’t perform that action at this time.
0 commit comments