mirror of
https://github.com/penpot/penpot.git
synced 2026-01-22 13:20:23 -05:00
Compare commits
1 Commits
staging-re
...
superalex-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
326341d3b0 |
@@ -90,8 +90,7 @@
|
||||
instance
|
||||
(dwt/create-editor editor-node canvas-node options)
|
||||
|
||||
;; Store original content to compare name later
|
||||
original-content content
|
||||
update-name? (nil? content)
|
||||
|
||||
on-key-up
|
||||
(fn [event]
|
||||
@@ -102,22 +101,10 @@
|
||||
on-blur
|
||||
(fn []
|
||||
(when-let [content (content/dom->cljs (dwt/get-editor-root instance))]
|
||||
(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))))
|
||||
(st/emit! (dwt/v2-update-text-shape-content shape-id content
|
||||
:update-name? update-name?
|
||||
:name (gen-name instance)
|
||||
:finalize? true)))
|
||||
|
||||
(let [container-node (mf/ref-val container-ref)]
|
||||
(dom/set-style! container-node "opacity" 0)))
|
||||
|
||||
@@ -61,7 +61,7 @@
|
||||
|
||||
(mf/defc page-item
|
||||
{::mf/wrap-props false}
|
||||
[{:keys [page index deletable? selected? editing? hovering? current-page-id]}]
|
||||
[{:keys [page index deletable? selected? editing? hovering?]}]
|
||||
(let [input-ref (mf/use-ref)
|
||||
id (:id page)
|
||||
delete-fn (mf/use-fn (mf/deps id) #(st/emit! (dw/delete-page id)))
|
||||
@@ -72,10 +72,8 @@
|
||||
(mf/use-fn
|
||||
(mf/deps id)
|
||||
(fn []
|
||||
;; For the wasm renderer, apply a blur effect to the viewport canvas
|
||||
;; when we navigate to a different page.
|
||||
(if (and (features/active-feature? @st/state "render-wasm/v1")
|
||||
(not= id current-page-id))
|
||||
;; when using the wasm renderer, apply a blur effect to the viewport canvas
|
||||
(if (features/active-feature? @st/state "render-wasm/v1")
|
||||
(do
|
||||
(wasm.api/capture-canvas-pixels)
|
||||
(wasm.api/apply-canvas-blur)
|
||||
@@ -205,13 +203,12 @@
|
||||
|
||||
(mf/defc page-item-wrapper
|
||||
{::mf/wrap-props false}
|
||||
[{:keys [page-id index deletable? selected? editing? current-page-id]}]
|
||||
[{:keys [page-id index deletable? selected? editing?]}]
|
||||
(let [page-ref (mf/with-memo [page-id]
|
||||
(make-page-ref page-id))
|
||||
page (mf/deref page-ref)]
|
||||
[:& page-item {:page page
|
||||
:index index
|
||||
:current-page-id current-page-id
|
||||
:deletable? deletable?
|
||||
:selected? selected?
|
||||
:editing? editing?}]))
|
||||
@@ -234,7 +231,6 @@
|
||||
:deletable? deletable?
|
||||
:editing? (= page-id editing-page-id)
|
||||
:selected? (= page-id current-page-id)
|
||||
:current-page-id current-page-id
|
||||
:key page-id}])]]))
|
||||
|
||||
;; --- Sitemap Toolbox
|
||||
|
||||
@@ -144,7 +144,7 @@
|
||||
modifiers (hooks/use-equal-memo modifiers)
|
||||
shapes (hooks/use-equal-memo shapes)]
|
||||
|
||||
[:g.outlines.blurrable
|
||||
[:g.outlines
|
||||
[:& shape-outlines-render {:shapes shapes
|
||||
:zoom zoom
|
||||
:modifiers modifiers}]]))
|
||||
|
||||
@@ -252,7 +252,7 @@
|
||||
edition (mf/deref refs/selected-edition)
|
||||
grid-edition? (ctl/grid-layout? objects edition)]
|
||||
|
||||
[:g.frame-titles.blurrable
|
||||
[:g.frame-titles
|
||||
(for [{:keys [id parent-id] :as shape} shapes]
|
||||
(when (and
|
||||
(not= id uuid/zero)
|
||||
|
||||
@@ -424,7 +424,6 @@
|
||||
:xmlnsXlink "http://www.w3.org/1999/xlink"
|
||||
:preserveAspectRatio "xMidYMid meet"
|
||||
:key (str "viewport" page-id)
|
||||
:id "viewport-controls"
|
||||
:view-box (utils/format-viewbox vbox)
|
||||
:ref on-viewport-ref
|
||||
:class (dm/str @cursor (when drawing-tool " drawing") " " (stl/css :viewport-controls))
|
||||
@@ -474,7 +473,7 @@
|
||||
:zoom zoom}]
|
||||
|
||||
(when (ctl/any-layout? outlined-frame)
|
||||
[:g.ghost-outline.blurrable
|
||||
[:g.ghost-outline
|
||||
[:& outline/shape-outlines
|
||||
{:objects base-objects
|
||||
:selected selected
|
||||
|
||||
@@ -1429,9 +1429,8 @@
|
||||
|
||||
(defn apply-canvas-blur
|
||||
[]
|
||||
(when wasm/canvas (dom/set-style! wasm/canvas "filter" "blur(4px)"))
|
||||
(let [controls-to-blur (dom/query-all (dom/get-element "viewport-controls") ".blurrable")]
|
||||
(run! #(dom/set-style! % "filter" "blur(4px)") controls-to-blur)))
|
||||
(when wasm/canvas
|
||||
(dom/set-style! wasm/canvas "filter" "blur(4px)")))
|
||||
|
||||
|
||||
(defn init-wasm-module
|
||||
|
||||
@@ -151,8 +151,6 @@ void main() {
|
||||
(.clear ^js context (.-DEPTH_BUFFER_BIT ^js context))
|
||||
(.clear ^js context (.-STENCIL_BUFFER_BIT ^js context)))
|
||||
(dom/set-style! wasm/canvas "filter" "none")
|
||||
(let [controls-to-unblur (dom/query-all (dom/get-element "viewport-controls") ".blurrable")]
|
||||
(run! #(dom/set-style! % "filter" "none") controls-to-unblur))
|
||||
(set! wasm/canvas-pixels nil)))
|
||||
|
||||
(defn capture-canvas-pixels
|
||||
|
||||
@@ -190,7 +190,11 @@ fn propagate_transform(
|
||||
if let Type::Text(text_content) = &mut shape.shape_type.clone() {
|
||||
match text_content.grow_type() {
|
||||
GrowType::AutoHeight => {
|
||||
if text_content.needs_update_layout() {
|
||||
// For auto-height, always update layout when width changes
|
||||
// because the new width affects how text wraps
|
||||
let width_changed =
|
||||
!is_close_to(shape_bounds_before.width(), shape_bounds_after.width());
|
||||
if width_changed || text_content.needs_update_layout() {
|
||||
text_content.update_layout(shape.selrect);
|
||||
}
|
||||
let height = text_content.size.height;
|
||||
@@ -204,7 +208,11 @@ fn propagate_transform(
|
||||
transform.post_concat(&resize_transform);
|
||||
}
|
||||
GrowType::AutoWidth => {
|
||||
if text_content.needs_update_layout() {
|
||||
// For auto-width, always update layout when height changes
|
||||
// because the new height affects how text flows
|
||||
let height_changed =
|
||||
!is_close_to(shape_bounds_before.height(), shape_bounds_after.height());
|
||||
if height_changed || text_content.needs_update_layout() {
|
||||
text_content.update_layout(shape.selrect);
|
||||
}
|
||||
let width = text_content.width();
|
||||
|
||||
Reference in New Issue
Block a user