فهرست منبع

fix: don't preview page if current container is the same page

Tienson Qin 1 سال پیش
والد
کامیت
7931f4cc1a
2فایلهای تغییر یافته به همراه7 افزوده شده و 2 حذف شده
  1. 1 0
      src/main/frontend/components/block.cljs
  2. 6 2
      src/main/frontend/handler/editor/lifecycle.cljs

+ 1 - 0
src/main/frontend/components/block.cljs

@@ -719,6 +719,7 @@
                             page-entity contents-page? children html-export? label whiteboard-page?)
                             page-entity contents-page? children html-export? label whiteboard-page?)
           modal? (:modal/show? @state/state)]
           modal? (:modal/show? @state/state)]
       (if (and (not (util/mobile?))
       (if (and (not (util/mobile?))
+               (not= (util/page-name-sanity-lc page-name-in-block) (:id config))
                (not preview?)
                (not preview?)
                (not disable-preview?)
                (not disable-preview?)
                (not modal?))
                (not modal?))

+ 6 - 2
src/main/frontend/handler/editor/lifecycle.cljs

@@ -31,9 +31,13 @@
 (defn will-remount!
 (defn will-remount!
   [_old-state state]
   [_old-state state]
   (let [new-block (:block (first (:rum/args state)))
   (let [new-block (:block (first (:rum/args state)))
+        edit-block (state/get-edit-content)
         repo (state/get-current-repo)]
         repo (state/get-current-repo)]
-    (when (not= (some-> (state/get-edit-content) string/trim)
-                (some-> (:block/content new-block) string/trim))
+    (when (and edit-block
+           (= (:block/uuid new-block)
+              (:block/uuid edit-block))
+           (not= (some-> edit-block string/trim)
+                 (some-> (:block/content new-block) string/trim)))
       (when-let [input (state/get-input)]
       (when-let [input (state/get-input)]
         (util/set-change-value input
         (util/set-change-value input
                                (block-handler/sanity-block-content repo (get new-block :block/format :markdown) (:block/content new-block))))))
                                (block-handler/sanity-block-content repo (get new-block :block/format :markdown) (:block/content new-block))))))