fix: can't paste pictures in the first block of any new page

pull/1862/head
Tienson Qin 2021-05-14 15:35:30 +08:00
parent 7949b7de9f
commit 9f552514ee
3 changed files with 11 additions and 19 deletions

View File

@ -38,8 +38,8 @@
delete-file! delete-file-blocks! delete-file-pages! delete-file-tx delete-files delete-pages-by-files
filter-only-public-pages-and-blocks get-all-block-contents get-all-tagged-pages
get-all-templates get-block-and-children get-block-by-uuid get-block-children sort-by-left
get-block-children-ids get-block-file get-block-immediate-children get-block-page
get-block-page-end-pos get-block-parent get-block-parents parents-collapsed? get-block-referenced-blocks get-block-refs-count
get-block-children-ids get-block-immediate-children get-block-page
get-blocks-by-priority get-blocks-contents get-custom-css
get-date-scheduled-or-deadlines get-db-type get-empty-pages get-file
get-file-blocks get-file-contents get-file-last-modified-at get-file-no-sub get-file-page get-file-page-id file-exists?

View File

@ -688,13 +688,6 @@
(db-utils/entity [:block/original-name page-name]))
:block/file))
(defn get-block-file
[block-id]
(let [page-id (some-> (db-utils/entity [:block/uuid block-id])
:block/page
:db/id)]
(:block/file (db-utils/entity page-id))))
(defn get-file-page-id
[file-path]
(when-let [repo (state/get-current-repo)]

View File

@ -1277,17 +1277,16 @@
(defn save-assets!
([{block-id :block/uuid} repo files]
(when-let [block-file (db-model/get-block-file block-id)]
(p/let [[repo-dir assets-dir] (ensure-assets-dir! repo)]
(save-assets! repo repo-dir assets-dir files
(fn [index file-base]
;; TODO: maybe there're other chars we need to handle?
(let [file-base (-> file-base
(string/replace " " "_")
(string/replace "%" "_")
(string/replace "/" "_"))
file-name (str file-base "_" (.now js/Date) "_" index)]
(string/replace file-name #"_+" "_")))))))
(p/let [[repo-dir assets-dir] (ensure-assets-dir! repo)]
(save-assets! repo repo-dir assets-dir files
(fn [index file-base]
;; TODO: maybe there're other chars we need to handle?
(let [file-base (-> file-base
(string/replace " " "_")
(string/replace "%" "_")
(string/replace "/" "_"))
file-name (str file-base "_" (.now js/Date) "_" index)]
(string/replace file-name #"_+" "_"))))))
([repo dir path files gen-filename]
(p/all
(for [[index ^js file] (map-indexed vector files)]