0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-24 05:31:25 -05:00

Merge pull request #5704 from penpot/ddb-copy-text

 Copy text content to clipboard
This commit is contained in:
María Valderrama 2025-01-29 12:00:26 +01:00 committed by GitHub
commit 48b225f3fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 45 additions and 1 deletions

View file

@ -14,6 +14,7 @@
- Shareable link pointing to an specific board. [Taiga #3219](https://tree.taiga.io/project/penpot/us/3219)
- Copy styles in CSS [Taiga #9401](https://tree.taiga.io/project/penpot/us/9401)
- Copy/paste shape styles (fills, strokes, shadows, etc..) [Taiga #8937](https://tree.taiga.io/project/penpot/us/8937)
- Copy text content to clipboard [Taiga #9970](https://tree.taiga.io/project/penpot/us/9970?milestone=424203)
- Resize board to fit content option [Taiga #4707](https://tree.taiga.io/project/penpot/us/4707)
- Rename selected layer via Board name [Taiga #9430](https://tree.taiga.io/project/penpot/us/9430)

View file

@ -1537,6 +1537,37 @@
css (css/generate-style objects selected selected {:with-prelude? false})]
(wapi/write-to-clipboard css)))))
(defn copy-selected-text
[]
(ptk/reify ::copy-selected-text
ptk/EffectEvent
(effect [_ state _]
(let [selected (dsh/lookup-selected state)
objects (dsh/lookup-page-objects state)
text-shapes
(->> (cfh/selected-with-children objects selected)
(keep (d/getf objects))
(filter cfh/text-shape?))
selected (into (d/ordered-set) (map :id) text-shapes)
;; Narrow the objects map so it contains only relevant data for
;; selected and its parents
objects (cfh/selected-subtree objects selected)
selected (->> (ctst/sort-z-index objects selected)
(into (d/ordered-set)))
text
(->> selected
(map
(fn [id]
(let [shape (get objects id)]
(-> shape :content txt/content->text))))
(str/join "\n"))]
(wapi/write-to-clipboard text)))))
(defn copy-selected-props
[]
(ptk/reify ::copy-selected-props

View file

@ -161,6 +161,9 @@
handle-paste-props
(mf/use-callback #(st/emit! (dw/paste-selected-props)))
handle-copy-text
(mf/use-callback #(st/emit! (dw/copy-selected-text)))
handle-hover-copy-paste
(mf/use-callback
(fn []
@ -204,6 +207,9 @@
[:> menu-separator* {}]
[:> menu-entry* {:title (tr "workspace.shape.menu.copy-text")
:on-click handle-copy-text}]
[:> menu-entry* {:title (tr "workspace.shape.menu.copy-props")
:shortcut (sc/get-tooltip :copy-props)
:disabled (> (count shapes) 1)

View file

@ -5990,6 +5990,9 @@ msgstr "Copy as CSS (nested layers)"
msgid "workspace.shape.menu.copy-props"
msgstr "Copy properties"
msgid "workspace.shape.menu.copy-text"
msgstr "Copy as text"
msgid "workspace.shape.menu.paste-props"
msgstr "Paste properties"
@ -6984,4 +6987,4 @@ msgstr "No people found for @%s"
#: src/app/main/ui/dashboard/placeholder.cljs:48
msgid "dashboard.add-file"
msgstr "Add file"
msgstr "Add file"

View file

@ -6016,6 +6016,9 @@ msgstr "Copiar como CSS (capas anidadas)"
msgid "workspace.shape.menu.copy-props"
msgstr "Copiar propiedades"
msgid "workspace.shape.menu.copy-text"
msgstr "Copiar como texto"
msgid "workspace.shape.menu.paste-props"
msgstr "Pegar propiedades"