Browse Source

fix: dnd block into whiteboard should also persist the source id

Peng Xiao 3 years ago
parent
commit
7fc649dd08

+ 1 - 1
src/main/frontend/extensions/tldraw.cljs

@@ -39,7 +39,7 @@
     (let [uuid (:block/uuid block)
           client-x (gobj/get e "clientX")
           client-y (gobj/get e "clientY")]
-      (whiteboard-handler/add-new-block-shape! uuid client-x client-y))))
+      (whiteboard-handler/add-new-block-portal-shape! uuid client-x client-y))))
 
 (defn search-handler
   [q]

+ 4 - 1
src/main/frontend/handler/whiteboard.cljs

@@ -2,6 +2,7 @@
   (:require [datascript.core :as d]
             [frontend.db.model :as model]
             [frontend.db.utils :as db-utils]
+            [frontend.handler.editor :as editor-handler]
             [frontend.modules.outliner.file :as outliner-file]
             [frontend.state :as state]
             [frontend.util :as util]
@@ -162,11 +163,13 @@
    :size [400, 0]
    :type "logseq-portal"})
 
-(defn add-new-block-shape!
+(defn add-new-block-portal-shape!
+  "Given the block id and the point, add a new shape to the referenced block."
   [block-id client-x client-y]
   (let [api (get-tldr-api)
         point (js->clj (.. (get-tldr-app) -viewport (getPagePoint #js[client-x client-y])))
         shape (->logseq-portal-shape block-id point)]
+    (editor-handler/set-blocks-id! [block-id])
     (.createShapes api (clj->js shape))))
 
 (defn add-new-block!