Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions packages/map/src/geometry/editor/GeometryEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1476,7 +1476,7 @@ class GeometryEditor extends Eventable(Class) {
* @return {Object} map view
*/
undo(): any {
if (!this._history || this._historyPointer === 0) {
if (this._isundoEdit()) {
return this;
}
const record = this._history[--this._historyPointer];
Expand All @@ -1491,7 +1491,7 @@ class GeometryEditor extends Eventable(Class) {
* @return {Object} map view
*/
redo(): any {
if (!this._history || this._historyPointer === this._history.length - 1) {
if (this._isRedoEdit()) {
return this;
}
const record = this._history[++this._historyPointer];
Expand Down Expand Up @@ -1549,6 +1549,18 @@ class GeometryEditor extends Eventable(Class) {
}
this._updating = updating;
}
_isRedoEdit(): boolean {
if (!this._history || this._historyPointer === this._history.length - 1) {
return true;
}
return false;
}
_isundoEdit(): boolean {
if (!this._history || this._historyPointer === 0) {
return true;
}
return false;
}

}

Expand Down
22 changes: 22 additions & 0 deletions packages/map/src/geometry/ext/Geometry.Edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,5 +195,27 @@ Geometry.include(/** @lends Geometry.prototype */ {
return this._editor.isEditing();
}
return false;
},
/**
* 编辑是否已经全部撤回
* @english
* Whether the geometry is being edited.
* @return {boolean}
*/
undoEditcheck(): boolean {
if (this.isEditing()) {
return this._editor._isundoEdit();
}
},
/**
* 编辑是否已经全部重做
* @english
* Whether the geometry is being edited.
* @return {boolean}
*/
redoEditcheck(): boolean {
if (this.isEditing()) {
return this._editor._isRedoEdit();
}
}
});