fix: dragged video doesn't render by default

This commit is contained in:
Tienson Qin
2022-11-25 22:25:25 +08:00
parent 410381c820
commit df2b9fc53c
5 changed files with 11 additions and 118 deletions

View File

@@ -17,13 +17,11 @@
[frontend.handler.block :as block-handler]
[frontend.handler.common :as common-handler]
[frontend.handler.export :as export]
[frontend.handler.image :as image-handler]
[frontend.handler.notification :as notification]
[frontend.handler.repeated :as repeated]
[frontend.handler.route :as route-handler]
[frontend.handler.assets :as assets-handler]
[frontend.idb :as idb]
[frontend.image :as image]
[frontend.mobile.util :as mobile-util]
[frontend.modules.outliner.core :as outliner-core]
[frontend.modules.outliner.transaction :as outliner-tx]
@@ -1322,9 +1320,10 @@
(defn get-asset-file-link
[format url file-name image?]
(let [pdf? (and url (string/ends-with? (string/lower-case url) ".pdf"))]
(let [pdf? (and url (string/ends-with? (string/lower-case url) ".pdf"))
video? (and url (util/ext-of-video? url))]
(case (keyword format)
:markdown (util/format (str (when (or image? pdf?) "!") "[%s](%s)") file-name url)
:markdown (util/format (str (when (or image? video? pdf?) "!") "[%s](%s)") file-name url)
:org (if image?
(util/format "[[%s]]" url)
(util/format "[[%s][%s]]" url file-name))
@@ -1464,7 +1463,7 @@
[id ^js files format uploading? drop-or-paste?]
(let [repo (state/get-current-repo)
block (state/get-edit-block)]
(if (config/local-db? repo)
(when (config/local-db? repo)
(-> (save-assets! block repo (js->clj files))
(p/then
(fn [res]
@@ -1487,28 +1486,7 @@
(fn []
(reset! uploading? false)
(reset! *asset-uploading? false)
(reset! *asset-uploading-process 0))))
(image/upload
files
(fn [file file-name file-type]
(image-handler/request-presigned-url
file file-name file-type
uploading?
(fn [signed-url]
(insert-command! id
(get-asset-file-link format signed-url file-name true)
format
{:last-pattern (if drop-or-paste? "" (state/get-editor-command-trigger))
:restore? true})
(reset! *asset-uploading? false)
(reset! *asset-uploading-process 0))
(fn [e]
(let [process (* (/ (gobj/get e "loaded")
(gobj/get e "total"))
100)]
(reset! *asset-uploading? false)
(reset! *asset-uploading-process process)))))))))
(reset! *asset-uploading-process 0)))))))
;; Editor should track some useful information, like editor modes.
;; For example: