Selaa lähdekoodia

allow page's block/content to be it's original name

Tienson Qin 2 vuotta sitten
vanhempi
sitoutus
58fc4bca28

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

@@ -2198,7 +2198,7 @@
                (do
                (do
                  (editor-handler/clear-selection!)
                  (editor-handler/clear-selection!)
                  (editor-handler/unhighlight-blocks!)
                  (editor-handler/unhighlight-blocks!)
-                 (let [f #(let [block (or (db/pull [:block/uuid (:block/uuid block)]) block)
+                 (let [f #(let [block (or (db/entity [:block/uuid (:block/uuid block)]) block)
                                 cursor-range (some-> (gdom/getElement block-id)
                                 cursor-range (some-> (gdom/getElement block-id)
                                                      (dom/by-class "block-content-wrapper")
                                                      (dom/by-class "block-content-wrapper")
                                                      first
                                                      first

+ 4 - 0
src/main/frontend/db/datascript/entity_plus.cljs

@@ -11,6 +11,10 @@
   ([e k] (lookup-kv-then-entity e k nil))
   ([e k] (lookup-kv-then-entity e k nil))
   ([^Entity e k default-value]
   ([^Entity e k default-value]
    (cond
    (cond
+     (and (contains? #{:block/raw-content :block/content} k) (config/db-based-graph? (state/get-current-repo))
+          (:block/name e))
+     (:block/original-name e)
+
      (and (= k :block/raw-content) (config/db-based-graph? (state/get-current-repo)))
      (and (= k :block/raw-content) (config/db-based-graph? (state/get-current-repo)))
      (lookup-entity e :block/content default-value)
      (lookup-entity e :block/content default-value)
 
 

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

@@ -90,6 +90,7 @@ and handles unexpected failure."
                                                    :or {with-id? true}}]
                                                    :or {with-id? true}}]
    (when-not (string/blank? content)
    (when-not (string/blank? content)
      (let [block (dissoc block :block/pre-block?)
      (let [block (dissoc block :block/pre-block?)
+           format (or format :markdown)
            ast (format/to-edn content format nil)
            ast (format/to-edn content format nil)
            blocks (extract-blocks ast content format {:with-id? with-id?})
            blocks (extract-blocks ast content format {:with-id? with-id?})
            new-block (first blocks)
            new-block (first blocks)

+ 1 - 1
src/main/frontend/handler/block.cljs

@@ -342,7 +342,7 @@
    (when-not (> retry-times 2)
    (when-not (> retry-times 2)
      (when-not config/publishing?
      (when-not config/publishing?
        (when-let [block-id (:block/uuid block)]
        (when-let [block-id (:block/uuid block)]
-         (let [block (or (db/pull [:block/uuid block-id]) block)
+         (let [block (or (db/entity [:block/uuid block-id]) block)
                edit-input-id (if (uuid? id)
                edit-input-id (if (uuid? id)
                                (get-edit-input-id-with-block-id id)
                                (get-edit-input-id-with-block-id id)
                                (-> (str (subs id 0 (- (count id) 36)) block-id)
                                (-> (str (subs id 0 (- (count id) 36)) block-id)

+ 1 - 2
src/main/frontend/persist_db/node.cljs

@@ -9,7 +9,7 @@
     (prn ::new repo)
     (prn ::new repo)
     (ipc/ipc :db-new repo))
     (ipc/ipc :db-new repo))
   (<transact-data [_this repo added-blocks deleted-block-uuids]
   (<transact-data [_this repo added-blocks deleted-block-uuids]
-    (prn ::transact-data repo added-blocks deleted-block-uuids)
+    ;; (prn ::transact-data repo added-blocks deleted-block-uuids)
     (ipc/ipc :db-transact-data repo
     (ipc/ipc :db-transact-data repo
              (pr-str
              (pr-str
               {:blocks added-blocks
               {:blocks added-blocks
@@ -20,4 +20,3 @@
   (<fetch-blocks-excluding [_this repo exclude-uuids _opts]
   (<fetch-blocks-excluding [_this repo exclude-uuids _opts]
     (prn ::fetch-by-exclude repo exclude-uuids)
     (prn ::fetch-by-exclude repo exclude-uuids)
     (ipc/ipc :get-other-data repo exclude-uuids)))
     (ipc/ipc :get-other-data repo exclude-uuids)))
-