🐛 Fix paste shapes while editing text

This commit is contained in:
Andrés Moya 2022-03-31 14:07:37 +02:00 committed by Andrey Antukh
parent 5633291ab0
commit 1bcb0128f0
2 changed files with 19 additions and 16 deletions

View file

@ -39,6 +39,7 @@
- Allow registration with invitation token when registration is disabled
- Add the ability to disable standard, password login [Taiga #2999](https://tree.taiga.io/project/penpot/us/2999)
- Don't stop SVG import when an image cannot be imported [#1531](https://github.com/penpot/penpot/issues/1531)
- Fix paste shapes while editing text [Taiga #2396](https://tree.taiga.io/project/penpot/issue/2396)
### :bug: Bugs fixed

View file

@ -1357,6 +1357,9 @@
edit-id (get-in state [:workspace-local :edition])
is-editing-text? (and edit-id (= :text (get-in objects [edit-id :type])))]
;; Some paste events can be fired while we're editing a text
;; we forbid that scenario so the default behaviour is executed
(when-not is-editing-text?
(cond
(and (string? text-data)
(str/includes? text-data "<svg"))
@ -1370,13 +1373,12 @@
(rx/filter #(= :copied-shapes (:type %)))
(rx/map #(paste-shape % in-viewport?)))
;; Some paste events can be fired while we're editing a text
;; we forbid that scenario so the default behaviour is executed
(and (string? text-data) (not is-editing-text?))
(string? text-data)
(rx/of (paste-text text-data))
:else
(rx/empty)))
(rx/empty))))
(catch :default err
(js/console.error "Clipboard error:" err))))))