|
@@ -43,31 +43,32 @@
|
|
|
|
|
|
(defn undo!
|
|
|
[]
|
|
|
- (let [route (get-in (:route-match @state/state) [:data :name])]
|
|
|
- (if (and (contains? #{:home :page :file} route)
|
|
|
- (state/get-current-repo))
|
|
|
- (let [repo (state/get-current-repo)
|
|
|
- chan (async/promise-chan)
|
|
|
- save-commited? (atom nil)
|
|
|
- undo-fn (fn []
|
|
|
- (history/undo! repo file/alter-file restore-cursor!))]
|
|
|
- (editor/save-current-block-when-idle! {:check-idle? false
|
|
|
- :chan chan
|
|
|
- :chan-callback (fn []
|
|
|
- (reset! save-commited? true))})
|
|
|
- (if @save-commited?
|
|
|
- (async/go
|
|
|
- (let [_ (async/<! chan)]
|
|
|
- ;; FIXME:
|
|
|
- (js/setTimeout undo-fn 20)))
|
|
|
- (undo-fn)))
|
|
|
- (default-undo))))
|
|
|
+ (when-not (state/get-editor-op)
|
|
|
+ (let [route (get-in (:route-match @state/state) [:data :name])]
|
|
|
+ (if (and (contains? #{:home :page :file} route)
|
|
|
+ (state/get-current-repo))
|
|
|
+ (let [repo (state/get-current-repo)
|
|
|
+ chan (async/promise-chan)
|
|
|
+ save-commited? (atom nil)
|
|
|
+ undo-fn (fn []
|
|
|
+ (history/undo! repo file/alter-file restore-cursor!))]
|
|
|
+ (editor/save-current-block-when-idle! {:check-idle? false
|
|
|
+ :chan chan
|
|
|
+ :chan-callback (fn []
|
|
|
+ (reset! save-commited? true))})
|
|
|
+ (if @save-commited?
|
|
|
+ (async/go
|
|
|
+ (let [_ (async/<! chan)]
|
|
|
+ (undo-fn)))
|
|
|
+ (undo-fn)))
|
|
|
+ (default-undo)))))
|
|
|
|
|
|
(defn redo!
|
|
|
[]
|
|
|
- (let [route (get-in (:route-match @state/state) [:data :name])]
|
|
|
- (if (and (contains? #{:home :page :file} route)
|
|
|
- (state/get-current-repo))
|
|
|
- (let [repo (state/get-current-repo)]
|
|
|
- (history/redo! repo file/alter-file restore-cursor!))
|
|
|
- (default-redo))))
|
|
|
+ (when-not (state/get-editor-op)
|
|
|
+ (let [route (get-in (:route-match @state/state) [:data :name])]
|
|
|
+ (if (and (contains? #{:home :page :file} route)
|
|
|
+ (state/get-current-repo))
|
|
|
+ (let [repo (state/get-current-repo)]
|
|
|
+ (history/redo! repo file/alter-file restore-cursor!))
|
|
|
+ (default-redo)))))
|