diff --git a/packages/map/src/geometry/editor/GeometryEditor.ts b/packages/map/src/geometry/editor/GeometryEditor.ts index ed89b87138..30a19a8201 100644 --- a/packages/map/src/geometry/editor/GeometryEditor.ts +++ b/packages/map/src/geometry/editor/GeometryEditor.ts @@ -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]; @@ -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]; @@ -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; + } } diff --git a/packages/map/src/geometry/ext/Geometry.Edit.ts b/packages/map/src/geometry/ext/Geometry.Edit.ts index 1318250e16..ff7eb64acb 100644 --- a/packages/map/src/geometry/ext/Geometry.Edit.ts +++ b/packages/map/src/geometry/ext/Geometry.Edit.ts @@ -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(); + } } });