mirror of
https://github.com/penpot/penpot.git
synced 2026-01-22 05:10:21 -05:00
Compare commits
2 Commits
develop
...
superalex-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1a3966d7b | ||
|
|
5b1766835f |
@@ -90,7 +90,8 @@
|
||||
instance
|
||||
(dwt/create-editor editor-node canvas-node options)
|
||||
|
||||
update-name? (nil? content)
|
||||
;; Store original content to compare name later
|
||||
original-content content
|
||||
|
||||
on-key-up
|
||||
(fn [event]
|
||||
@@ -101,10 +102,22 @@
|
||||
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
|
||||
:update-name? update-name?
|
||||
:name (gen-name instance)
|
||||
:finalize? true)))
|
||||
(let [state @st/state
|
||||
objects (dsh/lookup-page-objects state)
|
||||
shape (get objects shape-id)
|
||||
current-name (:name shape)
|
||||
generated-name (gen-name instance)
|
||||
;; Update name if: (1) it's a new shape (nil original content), or
|
||||
;; (2) the current name matches the generated name from original content
|
||||
;; (meaning it was never manually renamed)
|
||||
update-name? (or (nil? original-content)
|
||||
(and (some? current-name)
|
||||
(some? original-content)
|
||||
(= current-name (txt/generate-shape-name (txt/content->text original-content)))))]
|
||||
(st/emit! (dwt/v2-update-text-shape-content shape-id content
|
||||
:update-name? update-name?
|
||||
:name generated-name
|
||||
:finalize? true))))
|
||||
|
||||
(let [container-node (mf/ref-val container-ref)]
|
||||
(dom/set-style! container-node "opacity" 0)))
|
||||
|
||||
@@ -227,7 +227,7 @@
|
||||
:svg-attrs
|
||||
(do
|
||||
(api/set-shape-svg-attrs v)
|
||||
;; Always update fills/blur/shadow to clear previous state if filters disappear
|
||||
;; Always update fills/blur/shadow to clear previous state if filters disappear
|
||||
(api/set-shape-fills id (:fills shape) false)
|
||||
(api/set-shape-blur (:blur shape))
|
||||
(api/set-shape-shadows (:shadow shape)))
|
||||
@@ -397,12 +397,18 @@
|
||||
(next es))
|
||||
(throw (js/Error. "conj on a map takes map entries or seqables of map entries"))))))))
|
||||
|
||||
(def ^:private xf:without-id-and-type
|
||||
(remove (fn [kvpair]
|
||||
(let [k (key kvpair)]
|
||||
(or (= k :id)
|
||||
(= k :type))))))
|
||||
|
||||
(defn create-shape
|
||||
"Instanciate a shape from a map"
|
||||
[attrs]
|
||||
(ShapeProxy. (:id attrs)
|
||||
(:type attrs)
|
||||
(dissoc attrs :id :type)))
|
||||
(into {} xf:without-id-and-type attrs)))
|
||||
|
||||
(t/add-handlers!
|
||||
;; We only add a write handler, read handler uses the dynamic dispatch
|
||||
|
||||
@@ -58,6 +58,8 @@
|
||||
|
||||
(swap! state update ::snap snap/update-page old-page new-page)
|
||||
(swap! state update ::selection selection/update-page old-page new-page))
|
||||
(catch :default cause
|
||||
(log/error :hint "error updating page index" :id page-id :cause cause))
|
||||
(finally
|
||||
(let [elapsed (tpoint)]
|
||||
(log/dbg :hint "page index updated" :id page-id :elapsed elapsed ::log/sync? true))))
|
||||
|
||||
Reference in New Issue
Block a user