mirror of
https://github.com/logseq/logseq.git
synced 2026-05-01 01:16:27 +00:00
feat(paste): toggle between pasting text or file when they both exist (#7198)
* feat(paste): toggle between pasting text or file when they both exist
This commit is contained in:
@@ -178,26 +178,30 @@
|
||||
(state/set-state! :editor/on-paste? true)
|
||||
(let [input (state/get-input)]
|
||||
(if raw-paste?
|
||||
(utils/getClipText
|
||||
(fn [clipboard-data]
|
||||
(when-let [_ (state/get-input)]
|
||||
(let [text (or (when (gp-util/url? clipboard-data)
|
||||
(wrap-macro-url clipboard-data))
|
||||
clipboard-data)]
|
||||
(paste-text-or-blocks-aux input e text nil))))
|
||||
(fn [error]
|
||||
(js/console.error error)))
|
||||
(let [clipboard-data (gobj/get e "clipboardData")
|
||||
html (when-not raw-paste? (.getData clipboard-data "text/html"))
|
||||
text (.getData clipboard-data "text")]
|
||||
(if-not (and (string/blank? text) (string/blank? html))
|
||||
(paste-text-or-blocks-aux input e text html)
|
||||
(when id
|
||||
(let [_handled
|
||||
(let [clipboard-data (gobj/get e "clipboardData")
|
||||
files (.-files clipboard-data)]
|
||||
(when-let [file (first files)]
|
||||
(when-let [block (state/get-edit-block)]
|
||||
(editor-handler/upload-asset id #js[file] (:block/format block)
|
||||
editor-handler/*asset-uploading? true))))]
|
||||
(util/stop e))))))))))
|
||||
(utils/getClipText
|
||||
(fn [clipboard-data]
|
||||
(when-let [_ (state/get-input)]
|
||||
(let [text (or (when (gp-util/url? clipboard-data)
|
||||
(wrap-macro-url clipboard-data))
|
||||
clipboard-data)]
|
||||
(paste-text-or-blocks-aux input e text nil))))
|
||||
(fn [error]
|
||||
(js/console.error error)))
|
||||
(let [clipboard-data (gobj/get e "clipboardData")
|
||||
html (when-not raw-paste? (.getData clipboard-data "text/html"))
|
||||
text (.getData clipboard-data "text")
|
||||
files (.-files clipboard-data)
|
||||
paste-file-if-exiist (fn []
|
||||
(when id
|
||||
(let [_handled
|
||||
(let [clipboard-data (gobj/get e "clipboardData")
|
||||
files (.-files clipboard-data)]
|
||||
(when-let [file (first files)]
|
||||
(when-let [block (state/get-edit-block)]
|
||||
(editor-handler/upload-asset id #js[file] (:block/format block)
|
||||
editor-handler/*asset-uploading? true))))]
|
||||
(util/stop e))))]
|
||||
(cond
|
||||
(and (string/blank? text) (string/blank? html)) (paste-file-if-exiist)
|
||||
(and (seq files) (state/perferred-pasting-file?)) (paste-file-if-exiist)
|
||||
:else (paste-text-or-blocks-aux input e text html))))))))
|
||||
|
||||
Reference in New Issue
Block a user