mirror of
https://github.com/penpot/penpot.git
synced 2025-03-28 23:51:29 -05:00
Merge pull request #5704 from penpot/ddb-copy-text
✨ Copy text content to clipboard
This commit is contained in:
commit
48b225f3fe
5 changed files with 45 additions and 1 deletions
|
@ -14,6 +14,7 @@
|
||||||
- Shareable link pointing to an specific board. [Taiga #3219](https://tree.taiga.io/project/penpot/us/3219)
|
- 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 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/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)
|
- 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)
|
- Rename selected layer via Board name [Taiga #9430](https://tree.taiga.io/project/penpot/us/9430)
|
||||||
|
|
||||||
|
|
|
@ -1537,6 +1537,37 @@
|
||||||
css (css/generate-style objects selected selected {:with-prelude? false})]
|
css (css/generate-style objects selected selected {:with-prelude? false})]
|
||||||
(wapi/write-to-clipboard css)))))
|
(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
|
(defn copy-selected-props
|
||||||
[]
|
[]
|
||||||
(ptk/reify ::copy-selected-props
|
(ptk/reify ::copy-selected-props
|
||||||
|
|
|
@ -161,6 +161,9 @@
|
||||||
handle-paste-props
|
handle-paste-props
|
||||||
(mf/use-callback #(st/emit! (dw/paste-selected-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
|
handle-hover-copy-paste
|
||||||
(mf/use-callback
|
(mf/use-callback
|
||||||
(fn []
|
(fn []
|
||||||
|
@ -204,6 +207,9 @@
|
||||||
|
|
||||||
[:> menu-separator* {}]
|
[:> 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")
|
[:> menu-entry* {:title (tr "workspace.shape.menu.copy-props")
|
||||||
:shortcut (sc/get-tooltip :copy-props)
|
:shortcut (sc/get-tooltip :copy-props)
|
||||||
:disabled (> (count shapes) 1)
|
:disabled (> (count shapes) 1)
|
||||||
|
|
|
@ -5990,6 +5990,9 @@ msgstr "Copy as CSS (nested layers)"
|
||||||
msgid "workspace.shape.menu.copy-props"
|
msgid "workspace.shape.menu.copy-props"
|
||||||
msgstr "Copy properties"
|
msgstr "Copy properties"
|
||||||
|
|
||||||
|
msgid "workspace.shape.menu.copy-text"
|
||||||
|
msgstr "Copy as text"
|
||||||
|
|
||||||
msgid "workspace.shape.menu.paste-props"
|
msgid "workspace.shape.menu.paste-props"
|
||||||
msgstr "Paste properties"
|
msgstr "Paste properties"
|
||||||
|
|
||||||
|
@ -6984,4 +6987,4 @@ msgstr "No people found for @%s"
|
||||||
|
|
||||||
#: src/app/main/ui/dashboard/placeholder.cljs:48
|
#: src/app/main/ui/dashboard/placeholder.cljs:48
|
||||||
msgid "dashboard.add-file"
|
msgid "dashboard.add-file"
|
||||||
msgstr "Add file"
|
msgstr "Add file"
|
||||||
|
|
|
@ -6016,6 +6016,9 @@ msgstr "Copiar como CSS (capas anidadas)"
|
||||||
msgid "workspace.shape.menu.copy-props"
|
msgid "workspace.shape.menu.copy-props"
|
||||||
msgstr "Copiar propiedades"
|
msgstr "Copiar propiedades"
|
||||||
|
|
||||||
|
msgid "workspace.shape.menu.copy-text"
|
||||||
|
msgstr "Copiar como texto"
|
||||||
|
|
||||||
msgid "workspace.shape.menu.paste-props"
|
msgid "workspace.shape.menu.paste-props"
|
||||||
msgstr "Pegar propiedades"
|
msgstr "Pegar propiedades"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue