Skip to content

Commit 6014bf7

Browse files
authored
feat:Geomerty adds two function: undoEditcheck and redoEditcheck, which are used to determine whether the edit can continue to undo and redo, respectively (#2483)
1 parent eb66c44 commit 6014bf7

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

packages/map/src/geometry/editor/GeometryEditor.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,7 +1476,7 @@ class GeometryEditor extends Eventable(Class) {
14761476
* @return {Object} map view
14771477
*/
14781478
undo(): any {
1479-
if (!this._history || this._historyPointer === 0) {
1479+
if (this._isundoEdit()) {
14801480
return this;
14811481
}
14821482
const record = this._history[--this._historyPointer];
@@ -1491,7 +1491,7 @@ class GeometryEditor extends Eventable(Class) {
14911491
* @return {Object} map view
14921492
*/
14931493
redo(): any {
1494-
if (!this._history || this._historyPointer === this._history.length - 1) {
1494+
if (this._isRedoEdit()) {
14951495
return this;
14961496
}
14971497
const record = this._history[++this._historyPointer];
@@ -1549,6 +1549,18 @@ class GeometryEditor extends Eventable(Class) {
15491549
}
15501550
this._updating = updating;
15511551
}
1552+
_isRedoEdit(): boolean {
1553+
if (!this._history || this._historyPointer === this._history.length - 1) {
1554+
return true;
1555+
}
1556+
return false;
1557+
}
1558+
_isundoEdit(): boolean {
1559+
if (!this._history || this._historyPointer === 0) {
1560+
return true;
1561+
}
1562+
return false;
1563+
}
15521564

15531565
}
15541566

packages/map/src/geometry/ext/Geometry.Edit.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,5 +195,27 @@ Geometry.include(/** @lends Geometry.prototype */ {
195195
return this._editor.isEditing();
196196
}
197197
return false;
198+
},
199+
/**
200+
* 编辑是否已经全部撤回
201+
* @english
202+
* Whether the geometry is being edited.
203+
* @return {boolean}
204+
*/
205+
undoEditcheck(): boolean {
206+
if (this.isEditing()) {
207+
return this._editor._isundoEdit();
208+
}
209+
},
210+
/**
211+
* 编辑是否已经全部重做
212+
* @english
213+
* Whether the geometry is being edited.
214+
* @return {boolean}
215+
*/
216+
redoEditcheck(): boolean {
217+
if (this.isEditing()) {
218+
return this._editor._isRedoEdit();
219+
}
198220
}
199221
});

0 commit comments

Comments
 (0)