Skip to content

Commit

Permalink
Do clipboard copy in the right js document
Browse files Browse the repository at this point in the history
  • Loading branch information
kimo-k committed Nov 30, 2023
1 parent e503088 commit 8ca928f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ All notable changes to this project will be documented in this file. This change
#### Fixed

- Right-click popup menu is positioned more accurately. See #348.
- Right-click popup menu now works in the popout window.

## 1.8.1 (2023-07-26)

Expand Down
13 changes: 8 additions & 5 deletions src/day8/re_frame_10x/fx/clipboard.cljs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
(ns day8.re-frame-10x.fx.clipboard)
(ns day8.re-frame-10x.fx.clipboard
(:require
[day8.re-frame-10x.fx.window :refer [popout-window]]))

(defn copy!
[text]
(let [el (.createElement js/document "textarea")]
(let [doc (or (some-> @popout-window .-document) js/document)
el (.createElement doc "textarea")]
(set! (.-value el) text)
(set! (-> el .-style .-position) "absolute")
(set! (-> el .-style .-left) "-9999px")
(.appendChild (.-body js/document) el)
(.appendChild (.-body doc) el)
(.select el)
(.execCommand js/document "copy")
(.removeChild (.-body js/document) el)))
(.execCommand doc "copy")
(.removeChild (.-body doc) el)))

0 comments on commit 8ca928f

Please sign in to comment.