mirror of
https://github.com/penpot/penpot.git
synced 2025-01-09 00:10:11 -05:00
🐛 Fix text layer default name with v2 text editor
This commit is contained in:
parent
afcfbdedda
commit
a8ee9be7b9
1 changed files with 10 additions and 1 deletions
|
@ -27,6 +27,13 @@
|
||||||
[app.util.text.content.styles :as styles]
|
[app.util.text.content.styles :as styles]
|
||||||
[rumext.v2 :as mf]))
|
[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
|
(defn- initialize-event-handlers
|
||||||
"Internal editor events handler initializer/destructor"
|
"Internal editor events handler initializer/destructor"
|
||||||
[shape-id content selection-ref editor-ref container-ref]
|
[shape-id content selection-ref editor-ref container-ref]
|
||||||
|
@ -51,6 +58,8 @@
|
||||||
instance
|
instance
|
||||||
(dwt/create-editor editor-node options)
|
(dwt/create-editor editor-node options)
|
||||||
|
|
||||||
|
update-name? (nil? content)
|
||||||
|
|
||||||
on-key-up
|
on-key-up
|
||||||
(fn [event]
|
(fn [event]
|
||||||
(dom/stop-propagation event)
|
(dom/stop-propagation event)
|
||||||
|
@ -60,7 +69,7 @@
|
||||||
on-blur
|
on-blur
|
||||||
(fn []
|
(fn []
|
||||||
(when-let [content (content/dom->cljs (dwt/get-editor-root instance))]
|
(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)]
|
(let [container-node (mf/ref-val container-ref)]
|
||||||
(dom/set-style! container-node "opacity" 0)))
|
(dom/set-style! container-node "opacity" 0)))
|
||||||
|
|
Loading…
Reference in a new issue