@@ -36,7 +36,8 @@ define(function (require, exports, module) {
3636 StringUtils = require ( "utils/StringUtils" ) ,
3737 TokenUtils = require ( "utils/TokenUtils" ) ,
3838 CodeMirror = require ( "thirdparty/CodeMirror/lib/codemirror" ) ,
39- _ = require ( "thirdparty/lodash" ) ;
39+ _ = require ( "thirdparty/lodash" ) ,
40+ ChangeHelper = require ( "editor/EditorHelper/ChangeHelper" ) ;
4041
4142 /**
4243 * List of constants
@@ -1190,44 +1191,20 @@ define(function (require, exports, module) {
11901191 return result . promise ( ) ;
11911192 }
11921193
1193- let _undoInterceptor = null ;
1194- let _redoInterceptor = null ;
1195-
1196- /**
1197- * Use require("editor/EditorHelper/ChangeHelper") to intercept. this for internal use only
1198- * @private
1199- * @param {Function } interceptor - Function(editor, cm, event) that returns true to preventDefault
1200- */
1201- function _setUndoInterceptor ( interceptor ) {
1202- _undoInterceptor = interceptor ;
1203- }
1204-
1205- /**
1206- * Use require("editor/EditorHelper/ChangeHelper") to intercept. this for internal use only
1207- * @param {Function } interceptor - Function(editor, cm, event) that returns true to preventDefault
1208- */
1209- function _setRedoInterceptor ( interceptor ) {
1210- _redoInterceptor = interceptor ;
1211- }
1212-
12131194 function handleUndo ( ) {
1214- if ( _undoInterceptor ) {
1215- const focusedEditor = EditorManager . getFocusedEditor ( ) ;
1216- const codeMirror = focusedEditor && focusedEditor . _codeMirror ;
1217- if ( _undoInterceptor ( focusedEditor , codeMirror , null ) ) {
1218- return ;
1219- }
1195+ const focusedEditor = EditorManager . getFocusedEditor ( ) ;
1196+ const codeMirror = focusedEditor && focusedEditor . _codeMirror ;
1197+ if ( ChangeHelper . _onBeforeUndo ( focusedEditor , codeMirror , null ) ) {
1198+ return ;
12201199 }
12211200 return handleUndoRedo ( "undo" ) ;
12221201 }
12231202
12241203 function handleRedo ( ) {
1225- if ( _redoInterceptor ) {
1226- const focusedEditor = EditorManager . getFocusedEditor ( ) ;
1227- const codeMirror = focusedEditor && focusedEditor . _codeMirror ;
1228- if ( _redoInterceptor ( focusedEditor , codeMirror , null ) ) {
1229- return ;
1230- }
1204+ const focusedEditor = EditorManager . getFocusedEditor ( ) ;
1205+ const codeMirror = focusedEditor && focusedEditor . _codeMirror ;
1206+ if ( ChangeHelper . _onBeforeRedo ( focusedEditor , codeMirror , null ) ) {
1207+ return ;
12311208 }
12321209 return handleUndoRedo ( "redo" ) ;
12331210 }
@@ -1307,7 +1284,4 @@ define(function (require, exports, module) {
13071284 CommandManager . register ( Strings . CMD_COPY , Commands . EDIT_COPY , _execCommandCopy ) ;
13081285 CommandManager . register ( Strings . CMD_PASTE , Commands . EDIT_PASTE , _execCommandPaste ) ;
13091286 CommandManager . register ( Strings . CMD_SELECT_ALL , Commands . EDIT_SELECT_ALL , _handleSelectAll ) ;
1310-
1311- exports . _setUndoInterceptor = _setUndoInterceptor ;
1312- exports . _setRedoInterceptor = _setRedoInterceptor ;
13131287} ) ;
0 commit comments