0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-08 07:50:43 -05:00

Merge pull request #5354 from penpot/superalex-fix-text-layer-default-name-with-v2-editor

🐛 Fix text layer default name with v2 text editor
This commit is contained in:
Aitor Moreno 2024-11-22 12:20:59 +01:00 committed by GitHub
commit ba832389d1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -27,6 +27,13 @@
[app.util.text.content.styles :as styles]
[rumext.v2 :as mf]))
(defn- gen-name
[editor]
(when (some? editor)
(let [editor-root (.-root editor)
result (.-textContent editor-root)]
(when (not= result "") result))))
(defn- initialize-event-handlers
"Internal editor events handler initializer/destructor"
[shape-id content selection-ref editor-ref container-ref]
@ -51,6 +58,8 @@
instance
(dwt/create-editor editor-node options)
update-name? (nil? content)
on-key-up
(fn [event]
(dom/stop-propagation event)
@ -60,7 +69,7 @@
on-blur
(fn []
(when-let [content (content/dom->cljs (dwt/get-editor-root instance))]
(st/emit! (dwt/v2-update-text-shape-content shape-id content true)))
(st/emit! (dwt/v2-update-text-shape-content shape-id content update-name? (gen-name instance))))
(let [container-node (mf/ref-val container-ref)]
(dom/set-style! container-node "opacity" 0)))