Repository: penpot/penpot
File: frontend/src/uxbox/main/data/workspace.cljs (ClojureScript)

Code before:
                          rchanges)]
        (rx/of (commit-changes (vec rchanges)
                               (vec (reverse uchanges))
                               {:commit-local? true})
               (select-pasted-objs rchanges)))))))

(def paste
  (ptk/reify ::paste
    ptk/WatchEvent
    (watch [_ state stream]
      (->> (rx/from (wapi/read-from-clipboard))
           (rx/filter #(= :copied-shapes (:type %)))
           (rx/pr-log "pasting:")
           (rx/map :data)
           (rx/map paste-impl)
           (rx/catch (fn [err]
                       (js/console.error "Clipboard blocked:" err)
                       (rx/empty)))))))

(defn select-pasted-objs
  [rchanges]
  (ptk/reify ::select-pasted-objs
    ptk/UpdateEvent
    (update [_ state]
      (assoc-in state [:workspace-local :selected]
                (map #(get-in % [:obj :id]) rchanges)))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Page Changes Reactions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; --- Change Page Order (D&D Ordering)

(defn change-page-order
  [{:keys [id index] :as params}]
  {:pre [(uuid? id) (number? index)]}
  (ptk/reify ::change-page-order
    ptk/UpdateEvent
    (update [_ state]
      (let [page (get-in state [:pages id])
            pages (get-in state [:projects (:project-id page) :pages])
            pages (into [] (remove #(= % id)) pages)
            [before after] (split-at index pages)
            pages (vec (concat before [id] after))]
        (assoc-in state [:projects (:project-id page) :pages] pages)))))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Shortcuts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Review comment (suggestion):
estas cambiando el tipo de dato de selected. Selected es un Set, y `map` devuelve un `Seq`. Creo que esto deberia ser: 
```clojure
(assoc-in state [:workspace-local :selected] 
                (into #{} (map #(get-in % [:obj :id])) rchanges)
```

Code after:
        (rx/of (commit-changes (vec rchanges)
                               (vec (reverse uchanges))
                               {:commit-local? true})
               (select-pasted-objs rchanges)))))))

(def paste
  (ptk/reify ::paste
    ptk/WatchEvent
    (watch [_ state stream]
      (->> (rx/from (wapi/read-from-clipboard))
           (rx/filter #(= :copied-shapes (:type %)))
           (rx/pr-log "pasting:")
           (rx/map :data)
           (rx/map paste-impl)
           (rx/catch (fn [err]
                       (js/console.error "Clipboard blocked:" err)
                       (rx/empty)))))))

(defn select-pasted-objs
  [rchanges]
  (ptk/reify ::select-pasted-objs
    ptk/UpdateEvent
    (update [_ state]
      (assoc-in state [:workspace-local :selected]
                (into #{} (map #(get-in % [:obj :id])) rchanges)))))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Page Changes Reactions
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; --- Change Page Order (D&D Ordering)

(defn change-page-order
  [{:keys [id index] :as params}]
  {:pre [(uuid? id) (number? index)]}
  (ptk/reify ::change-page-order
    ptk/UpdateEvent
    (update [_ state]
      (let [page (get-in state [:pages id])
            pages (get-in state [:projects (:project-id page) :pages])
            pages (into [] (remove #(= % id)) pages)
            [before after] (split-at index pages)
            pages (vec (concat before [id] after))]
        (assoc-in state [:projects (:project-id page) :pages] pages)))))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Shortcuts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(def shortcuts