diff --git a/src/main/frontend/handler/editor.cljs b/src/main/frontend/handler/editor.cljs index 443738b55..0e0b9d601 100644 --- a/src/main/frontend/handler/editor.cljs +++ b/src/main/frontend/handler/editor.cljs @@ -348,7 +348,15 @@ (when refresh? (let [opts {:key :block/change :data [block]}] - (db/refresh! repo opts))))) + (db/refresh! repo opts))) + + ;; page title changed + (when-let [title (get-in block [:block/properties :title])] + (when-let [old-title (:block/name (db/entity (:db/id (:block/page block))))] + (when (and (:block/pre-block? block) + (not (string/blank? title)) + (not= (string/lower-case title) old-title)) + (state/pub-event! [:page/title-property-changed old-title title])))))) (repo-handler/push-if-auto-enabled! repo))) diff --git a/src/main/frontend/handler/events.cljs b/src/main/frontend/handler/events.cljs index 199387d9c..207d861ea 100644 --- a/src/main/frontend/handler/events.cljs +++ b/src/main/frontend/handler/events.cljs @@ -9,6 +9,7 @@ [frontend.handler.notification :as notification] [frontend.handler.common :as common-handler] [frontend.handler.editor :as editor-handler] + [frontend.handler.page :as page-handler] [frontend.components.encryption :as encryption] [frontend.fs.nfs :as nfs] [frontend.db.conn :as conn] @@ -133,6 +134,9 @@ (defmethod handle :modal/show-cards [_] (state/set-modal! srs/global-cards)) +(defmethod handle :page/title-property-changed [[_ old-title new-title]] + (page-handler/rename! old-title new-title)) + (defmethod handle :after-db-restore [[_ repos]] (mapv (fn [{url :url} repo] ;; compare :ast/version