mirror of https://github.com/logseq/logseq
fix: editor not saved when zoom in/out
parent
7a1b1a17f8
commit
3c9d77088b
|
@ -1155,6 +1155,8 @@
|
||||||
(:db/id page)
|
(:db/id page)
|
||||||
:page))))))
|
:page))))))
|
||||||
|
|
||||||
|
(declare save-current-block!)
|
||||||
|
|
||||||
(defn zoom-in! []
|
(defn zoom-in! []
|
||||||
(if (state/editing?)
|
(if (state/editing?)
|
||||||
(when-let [id (some-> (state/get-edit-block)
|
(when-let [id (some-> (state/get-edit-block)
|
||||||
|
@ -1162,9 +1164,12 @@
|
||||||
((fn [id] [:block/uuid id]))
|
((fn [id] [:block/uuid id]))
|
||||||
db/entity
|
db/entity
|
||||||
:block/uuid)]
|
:block/uuid)]
|
||||||
(let [pos (state/get-edit-pos)]
|
(state/clear-editor-action!)
|
||||||
|
(p/do!
|
||||||
|
(save-current-block!)
|
||||||
|
(let [pos (state/get-edit-pos)]
|
||||||
(route-handler/redirect-to-page! id)
|
(route-handler/redirect-to-page! id)
|
||||||
(util/schedule #(edit-block! {:block/uuid id} pos nil))))
|
(util/schedule #(edit-block! {:block/uuid id} pos nil)))))
|
||||||
(js/window.history.forward)))
|
(js/window.history.forward)))
|
||||||
|
|
||||||
(defn zoom-out!
|
(defn zoom-out!
|
||||||
|
@ -1172,21 +1177,24 @@
|
||||||
(if (state/editing?)
|
(if (state/editing?)
|
||||||
(let [page (state/get-current-page)
|
(let [page (state/get-current-page)
|
||||||
block-id (and (string? page) (parse-uuid page))]
|
block-id (and (string? page) (parse-uuid page))]
|
||||||
(when block-id
|
(p/do!
|
||||||
(let [block-parent (db/get-block-parent block-id)]
|
(state/clear-editor-action!)
|
||||||
(if-let [id (and
|
(save-current-block!)
|
||||||
(nil? (:block/name block-parent))
|
(when block-id
|
||||||
(:block/uuid block-parent))]
|
(let [block-parent (db/get-block-parent block-id)]
|
||||||
(do
|
(if-let [id (and
|
||||||
(route-handler/redirect-to-page! id)
|
(nil? (:block/name block-parent))
|
||||||
(util/schedule #(edit-block! {:block/uuid block-id} :max nil)))
|
(:block/uuid block-parent))]
|
||||||
(let [page-id (some-> (db/entity [:block/uuid block-id])
|
(do
|
||||||
:block/page
|
(route-handler/redirect-to-page! id)
|
||||||
:db/id)]
|
(util/schedule #(edit-block! {:block/uuid block-id} :max nil)))
|
||||||
|
(let [page-id (some-> (db/entity [:block/uuid block-id])
|
||||||
|
:block/page
|
||||||
|
:db/id)]
|
||||||
|
|
||||||
(when-let [page-name (:block/name (db/entity page-id))]
|
(when-let [page-name (:block/name (db/entity page-id))]
|
||||||
(route-handler/redirect-to-page! page-name)
|
(route-handler/redirect-to-page! page-name)
|
||||||
(util/schedule #(edit-block! {:block/uuid block-id} :max nil))))))))
|
(util/schedule #(edit-block! {:block/uuid block-id} :max nil)))))))))
|
||||||
(js/window.history.back)))
|
(js/window.history.back)))
|
||||||
|
|
||||||
(defn cut-block!
|
(defn cut-block!
|
||||||
|
@ -1307,39 +1315,41 @@
|
||||||
(save-current-block! {}))
|
(save-current-block! {}))
|
||||||
([{:keys [force? skip-properties? current-block] :as opts}]
|
([{:keys [force? skip-properties? current-block] :as opts}]
|
||||||
;; non English input method
|
;; non English input method
|
||||||
(when-not (or (state/editor-in-composition?)
|
(let [result (when-not (or (state/editor-in-composition?)
|
||||||
@(:editor/skip-saving-current-block? @state/state))
|
@(:editor/skip-saving-current-block? @state/state))
|
||||||
(when (state/get-current-repo)
|
(when (state/get-current-repo)
|
||||||
(when-not (state/get-editor-action)
|
(when-not (state/get-editor-action)
|
||||||
(try
|
(try
|
||||||
(let [input-id (state/get-edit-input-id)
|
(let [input-id (state/get-edit-input-id)
|
||||||
block (state/get-edit-block)
|
block (state/get-edit-block)
|
||||||
db-block (when-let [block-id (:block/uuid block)]
|
db-block (when-let [block-id (:block/uuid block)]
|
||||||
(db/pull [:block/uuid block-id]))
|
(db/pull [:block/uuid block-id]))
|
||||||
elem (and input-id (gdom/getElement input-id))
|
elem (and input-id (gdom/getElement input-id))
|
||||||
db-content (:block/content db-block)
|
db-content (:block/content db-block)
|
||||||
db-content-without-heading (and db-content
|
db-content-without-heading (and db-content
|
||||||
(common-util/safe-subs db-content (:block/level db-block)))
|
(common-util/safe-subs db-content (:block/level db-block)))
|
||||||
value (if (= (:block/uuid current-block) (:block/uuid block))
|
value (if (= (:block/uuid current-block) (:block/uuid block))
|
||||||
(:block/content current-block)
|
(:block/content current-block)
|
||||||
(and elem (gobj/get elem "value")))]
|
(and elem (gobj/get elem "value")))]
|
||||||
(when value
|
(prn :debug :value value)
|
||||||
(cond
|
(when value
|
||||||
force?
|
(cond
|
||||||
(save-block-aux! db-block value opts)
|
force?
|
||||||
|
(save-block-aux! db-block value opts)
|
||||||
|
|
||||||
(and skip-properties?
|
(and skip-properties?
|
||||||
(db-model/top-block? block)
|
(db-model/top-block? block)
|
||||||
(when elem (thingatpt/properties-at-point elem)))
|
(when elem (thingatpt/properties-at-point elem)))
|
||||||
nil
|
nil
|
||||||
|
|
||||||
(and block value db-content-without-heading
|
(and block value db-content-without-heading
|
||||||
(not= (string/trim db-content-without-heading)
|
(not= (string/trim db-content-without-heading)
|
||||||
(string/trim value)))
|
(string/trim value)))
|
||||||
(save-block-aux! db-block value opts))))
|
(save-block-aux! db-block value opts))))
|
||||||
(catch :default error
|
(catch :default error
|
||||||
(log/error :save-block-failed error))))))
|
(log/error :save-block-failed error))))))]
|
||||||
(state/set-state! :editor/skip-saving-current-block? false)))
|
(state/set-state! :editor/skip-saving-current-block? false)
|
||||||
|
result)))
|
||||||
|
|
||||||
(defn- clean-content!
|
(defn- clean-content!
|
||||||
[repo format content]
|
[repo format content]
|
||||||
|
|
Loading…
Reference in New Issue