fix: use mod+shift+c for raw text copy

This commit is contained in:
Tienson Qin
2022-05-30 16:39:58 +08:00
parent f8fd6544d4
commit d49eec78a4
4 changed files with 26 additions and 6 deletions

View File

@@ -976,7 +976,7 @@
(into [] (state/get-export-block-text-remove-options)))))
(defn copy-selection-blocks
[]
[html?]
(when-let [blocks (seq (state/get-selection-blocks))]
(let [repo (state/get-current-repo)
ids (distinct (keep #(when-let [id (dom/attr % "blockid")]
@@ -985,7 +985,7 @@
block (db/entity [:block/uuid (first ids)])]
(when block
(let [html (export/export-blocks-as-html repo ids)]
(common-handler/copy-to-clipboard-without-id-property! (:block/format block) content html))
(common-handler/copy-to-clipboard-without-id-property! (:block/format block) content (when html? html)))
(state/set-copied-blocks content ids)
(notification/show! "Copied!" :success)))))
@@ -1054,7 +1054,7 @@
(defn cut-selection-blocks
[copy?]
(when copy? (copy-selection-blocks))
(when copy? (copy-selection-blocks true))
(when-let [blocks (seq (get-selected-blocks))]
;; remove embeds, references and queries
(let [dom-blocks (remove (fn [block]
@@ -2988,7 +2988,7 @@
(defn shortcut-copy-selection
[_e]
(copy-selection-blocks))
(copy-selection-blocks true))
(defn shortcut-cut-selection
[e]
@@ -3036,6 +3036,19 @@
:else
(js/document.execCommand "copy"))))
(defn shortcut-copy-text
"shortcut copy action:
* when in selection mode, copy selected blocks
* when in edit mode with text selected, copy selected text as normal"
[_e]
(when-not (auto-complete?)
(cond
(state/selection?)
(copy-selection-blocks false)
:else
(js/document.execCommand "copy"))))
(defn shortcut-cut
"shortcut cut action:
* when in selection mode, cut selected blocks