mirror of
https://github.com/penpot/penpot.git
synced 2025-05-11 18:46:39 +02:00
Merge remote-tracking branch 'origin/main' into develop
This commit is contained in:
commit
a80120278e
15 changed files with 91 additions and 60 deletions
|
@ -89,7 +89,7 @@
|
|||
{:content {:data (js/Uint8Array. data)
|
||||
:name name
|
||||
:type type}
|
||||
:font-family family
|
||||
:font-family (or family "")
|
||||
:font-weight (cm/parse-font-weight variant)
|
||||
:font-style (cm/parse-font-style variant)}))
|
||||
|
||||
|
|
|
@ -1238,7 +1238,6 @@
|
|||
qparams {:page-id page-id}]
|
||||
(rx/of (rt/nav :workspace pparams qparams))))))
|
||||
|
||||
|
||||
(defn go-to-viewer
|
||||
([] (go-to-viewer {}))
|
||||
([{:keys [file-id page-id]}]
|
||||
|
|
|
@ -228,7 +228,7 @@
|
|||
ptk/WatchEvent
|
||||
(watch [it state stream]
|
||||
(let [[path name] (cp/parse-path-name (:name typography))
|
||||
typography (assoc typography :path path :name name)
|
||||
typography (assoc typography :path path :name name)
|
||||
prev (get-in state [:workspace-data :typographies (:id typography)])
|
||||
rchg {:type :mod-typography
|
||||
:typography typography}
|
||||
|
|
|
@ -88,10 +88,10 @@
|
|||
(let [objects (wsh/lookup-page-objects state)
|
||||
page-id (:current-page-id state)
|
||||
id (get-in state [:workspace-local :edition])
|
||||
old-content (get-in state [:workspace-local :edit-path id :old-content])]
|
||||
(if (some? old-content)
|
||||
(let [shape (get-in state (st/get-path state))
|
||||
[rch uch] (generate-path-changes objects page-id shape old-content (:content shape))]
|
||||
old-content (get-in state [:workspace-local :edit-path id :old-content])
|
||||
shape (get-in state (st/get-path state))]
|
||||
(if (and (some? old-content) (some? shape))
|
||||
(let [[rch uch] (generate-path-changes objects page-id shape old-content (:content shape))]
|
||||
(rx/of (dch/commit-changes {:redo-changes rch
|
||||
:undo-changes uch
|
||||
:origin it})))
|
||||
|
|
|
@ -60,20 +60,20 @@
|
|||
|
||||
old-points (->> content upg/content->points)
|
||||
new-points (->> new-content upg/content->points)
|
||||
point-change (->> (map hash-map old-points new-points) (reduce merge))
|
||||
point-change (->> (map hash-map old-points new-points) (reduce merge))]
|
||||
|
||||
[rch uch] (changes/generate-path-changes objects page-id shape (:content shape) new-content)]
|
||||
|
||||
(if (empty? new-content)
|
||||
(rx/of (dch/commit-changes {:redo-changes rch
|
||||
:undo-changes uch
|
||||
:origin it})
|
||||
dwc/clear-edition-mode)
|
||||
(rx/of (dch/commit-changes {:redo-changes rch
|
||||
:undo-changes uch
|
||||
:origin it})
|
||||
(selection/update-selection point-change)
|
||||
(fn [state] (update-in state [:workspace-local :edit-path id] dissoc :content-modifiers :moving-nodes :moving-handler))))))))
|
||||
(when (and (some? new-content) (some? shape))
|
||||
(let [[rch uch] (changes/generate-path-changes objects page-id shape (:content shape) new-content)]
|
||||
(if (empty? new-content)
|
||||
(rx/of (dch/commit-changes {:redo-changes rch
|
||||
:undo-changes uch
|
||||
:origin it})
|
||||
dwc/clear-edition-mode)
|
||||
(rx/of (dch/commit-changes {:redo-changes rch
|
||||
:undo-changes uch
|
||||
:origin it})
|
||||
(selection/update-selection point-change)
|
||||
(fn [state] (update-in state [:workspace-local :edit-path id] dissoc :content-modifiers :moving-nodes :moving-handler))))))))))
|
||||
|
||||
(defn modify-content-point
|
||||
[content {dx :x dy :y} modifiers point]
|
||||
|
@ -263,7 +263,8 @@
|
|||
(streams/drag-stream
|
||||
(rx/concat
|
||||
(->> (streams/move-handler-stream snap-toggled start-point point handler opposite points)
|
||||
(rx/take-until (->> stream (rx/filter ms/mouse-up?)))
|
||||
(rx/take-until (->> stream (rx/filter #(or (ms/mouse-up? %)
|
||||
(streams/finish-edition? %)))))
|
||||
(rx/map
|
||||
(fn [{:keys [x y alt? shift?]}]
|
||||
(let [pos (cond-> (gpt/point x y)
|
||||
|
|
|
@ -24,6 +24,9 @@
|
|||
(fn [current]
|
||||
(>= (gpt/distance start current) (/ drag-threshold zoom))))
|
||||
|
||||
(defn finish-edition? [event]
|
||||
(= (ptk/type event) :app.main.data.workspace.common/clear-edition-mode))
|
||||
|
||||
(defn drag-stream
|
||||
([to-stream]
|
||||
(drag-stream to-stream (rx/empty)))
|
||||
|
@ -31,7 +34,8 @@
|
|||
([to-stream not-drag-stream]
|
||||
(let [start @ms/mouse-position
|
||||
zoom (get-in @st/state [:workspace-local :zoom] 1)
|
||||
mouse-up (->> st/stream (rx/filter #(ms/mouse-up? %)))
|
||||
mouse-up (->> st/stream (rx/filter #(or (finish-edition? %)
|
||||
(ms/mouse-up? %))))
|
||||
|
||||
position-stream
|
||||
(->> ms/mouse-position
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
selected-points (get-in state [:workspace-local :edit-path id :selected-points] #{})
|
||||
points (or points selected-points)]
|
||||
(when-not (empty? points)
|
||||
(when (and (not (empty? points)) (some? shape))
|
||||
(let [new-content (-> (tool-fn (:content shape) points)
|
||||
(ups/close-subpaths))
|
||||
[rch uch] (changes/generate-path-changes objects page-id shape (:content shape) new-content)]
|
||||
|
|
|
@ -192,9 +192,10 @@
|
|||
on-save
|
||||
(fn [event]
|
||||
(let [font-family @state]
|
||||
(st/emit! (df/update-font
|
||||
{:id font-id
|
||||
:name font-family}))
|
||||
(when-not (str/blank? font-family)
|
||||
(st/emit! (df/update-font
|
||||
{:id font-id
|
||||
:name font-family})))
|
||||
(reset! edit? false)))
|
||||
|
||||
on-key-down
|
||||
|
|
|
@ -428,26 +428,27 @@
|
|||
[:> text-transform-options opts]]]))
|
||||
|
||||
|
||||
;; TODO: this need to be refactored, right now combines too much logic
|
||||
;; and has a dropdown that behaves like a modal but is not a modal.
|
||||
;; In summary, this need to a good UX/UI/IMPL rework.
|
||||
|
||||
(mf/defc typography-entry
|
||||
[{:keys [typography read-only? selected? on-click on-change on-detach on-context-menu editting? focus-name? file]}]
|
||||
(let [open? (mf/use-state editting?)
|
||||
hover-detach (mf/use-state false)
|
||||
name-input-ref (mf/use-ref nil)
|
||||
value (mf/use-state (cp/merge-path-item (:path typography) (:name typography)))
|
||||
(let [open? (mf/use-state editting?)
|
||||
hover-detach (mf/use-state false)
|
||||
name-input-ref (mf/use-ref)
|
||||
|
||||
#_(rt/resolve router :workspace
|
||||
{:project-id (:project-id file)
|
||||
:file-id (:id file)}
|
||||
{:page-id (get-in file [:data :pages 0])})
|
||||
|
||||
handle-change
|
||||
on-name-blur
|
||||
(fn [event]
|
||||
(reset! value (dom/get-target-val event)))
|
||||
(let [content (dom/get-target-val event)]
|
||||
(when-not (str/blank? content)
|
||||
(on-change {:name content}))))
|
||||
|
||||
handle-go-to-edit
|
||||
(fn [] (st/emit! (rt/nav :workspace {:project-id (:project-id file)
|
||||
:file-id (:id file)}
|
||||
{:page-id (get-in file [:data :pages 0])})))]
|
||||
(fn []
|
||||
(let [pparams {:project-id (:project-id file)
|
||||
:file-id (:id file)}]
|
||||
(st/emit! (rt/nav :workspace pparams))))]
|
||||
|
||||
(mf/use-effect
|
||||
(mf/deps editting?)
|
||||
|
@ -459,7 +460,7 @@
|
|||
(mf/deps focus-name?)
|
||||
(fn []
|
||||
(when focus-name?
|
||||
(ts/schedule 100
|
||||
(ts/schedule
|
||||
#(when-let [node (mf/ref-val name-input-ref)]
|
||||
(dom/focus! node)
|
||||
(dom/select-text! node))))))
|
||||
|
@ -530,8 +531,7 @@
|
|||
[:input.element-name.adv-typography-name
|
||||
{:type "text"
|
||||
:ref name-input-ref
|
||||
:value @value
|
||||
:on-change handle-change
|
||||
:on-blur #(on-change {:name @value})}]]]
|
||||
:default-value (cp/merge-path-item (:path typography) (:name typography))
|
||||
:on-blur on-name-blur}]]]
|
||||
[:& typography-options {:values typography
|
||||
:on-change on-change}]])]]))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue