File tree 5 files changed +34
-30
lines changed
5 files changed +34
-30
lines changed Original file line number Diff line number Diff line change 153
153
(element.h/create {:tag :svg
154
154
:attrs {:width " 800" :height " 600" }})
155
155
(history.h/finalize " Create document" ))
156
- :dispatch [:frame/center ]}))
156
+ :fx [[:dispatch [:frame/center ]]
157
+ [:focus nil ]]}))
157
158
158
159
(def file-picker-options
159
160
{:startIn " documents"
195
196
:always
196
197
(-> (h/add-recent (:path document))
197
198
(assoc :active-document (:key document))))
198
- :dispatch [:frame/center ]})))
199
+ :fx [[:dispatch [:frame/center ]]
200
+ [:focus nil ]]})))
199
201
200
202
(rf/reg-fx
201
203
::save-as
223
225
(let [document (save-format db)]
224
226
(if platform/electron?
225
227
{:send-to-main {:action " saveDocument" :data (pr-str document)}}
226
- ; ; The path is not available when we use web APIs for security reasons,
228
+ ; ; The path is not available when we use web APIs for security reasons,
227
229
; ; so we always dispatch save-as.
228
230
{::save-as document}))))
229
231
Original file line number Diff line number Diff line change 7
7
[renderer.handlers :as h]
8
8
[renderer.frame.handlers :as frame-h]
9
9
[renderer.tool.base :as tool]
10
+ [renderer.utils.dom :as dom]
10
11
[renderer.utils.drop :as drop]
11
12
[renderer.utils.local-storage :as local-storage]
12
13
[renderer.utils.pointer :as pointer]))
49
50
(fn [db [_ mdn]]
50
51
(assoc db :mdn mdn)))
51
52
52
- (rf/reg-event-db
53
+ (rf/reg-event-fx
53
54
:set-tool
54
- (fn [db [_ tool]]
55
- (h/set-tool db tool)))
55
+ (fn [{:keys [db]} [_ tool]]
56
+ {:db (h/set-tool db tool)
57
+ :focus nil }))
56
58
57
59
(rf/reg-event-db
58
60
:clear-restored
210
212
(js/Blob.
211
213
[text-html]
212
214
#js {:type [" text/html" ]}))})]))))
215
+
216
+ (rf/reg-fx
217
+ :focus
218
+ (fn [id]
219
+ (when-let [element (if id (.getElementById js/document id) (dom/canvas-element ))]
220
+ (js/setTimeout #(.focus element)))))
Original file line number Diff line number Diff line change 22
22
(fn [db [_ zoom]]
23
23
(h/focus-selection db zoom)))
24
24
25
- (rf/reg-event-db
25
+ (rf/reg-event-fx
26
26
:frame/set-zoom
27
- (fn [{active-document :active-document :as db} [_ zoom]]
28
- (let [current-zoom (get-in db [:documents active-document :zoom ])]
29
- (h/zoom db (/ zoom current-zoom)))))
27
+ (fn [{:keys [db]} [_ zoom]]
28
+ (let [current-zoom (get-in db [:documents (:active-document db) :zoom ])]
29
+ {:db (h/zoom db (/ zoom current-zoom))
30
+ :focus nil })))
30
31
31
- (rf/reg-event-db
32
+ (rf/reg-event-fx
32
33
:frame/zoom-in
33
- (fn [db [_ _]]
34
- (h/zoom db (/ 1 (:zoom-sensitivity db)))))
34
+ (fn [{:keys [db]} [_ _]]
35
+ {:db (h/zoom db (/ 1 (:zoom-sensitivity db)))
36
+ :focus nil }))
35
37
36
- (rf/reg-event-db
38
+ (rf/reg-event-fx
37
39
:frame/zoom-out
38
- (fn [db [_ _]]
39
- (h/zoom db (:zoom-sensitivity db))))
40
+ (fn [{:keys [db]} [_ _]]
41
+ {:db (h/zoom db (:zoom-sensitivity db))
42
+ :focus nil }))
40
43
41
44
(rf/reg-event-db
42
45
:frame/pan-to-bounds
Original file line number Diff line number Diff line change 1
1
(ns renderer.menubar.events
2
2
(:require
3
- [re-frame.core :as rf]
4
- [renderer.utils.dom :as dom]))
5
-
6
- (rf/reg-fx
7
- ::focus
8
- (fn [id]
9
- (when-let [element (if id (.getElementById js/document id) (dom/canvas-element ))]
10
- (js/setTimeout #(.focus element)))))
3
+ [re-frame.core :as rf]))
11
4
12
5
(rf/reg-event-fx
13
6
:menubar/focus
14
7
(fn [_ [_ id]]
15
- {:: focus id}))
8
+ {:focus id}))
Original file line number Diff line number Diff line change 9
9
[renderer.history.handlers :as history.h]
10
10
[renderer.tool.base :as tool]
11
11
[renderer.utils.bounds :as bounds]
12
- [renderer.utils.dom :as dom]
13
12
[renderer.utils.element :as element]
14
13
[renderer.utils.units :as units]))
15
14
18
17
(defmethod tool /properties :text
19
18
[]
20
19
{:icon " text"
21
- :description " The SVG <text> element draws a graphics element consisting
22
- of text. It's possible to apply a gradient, pattern,
23
- clipping path, mask, or filter to <text>, like any other SVG
20
+ :description " The SVG <text> element draws a graphics element consisting
21
+ of text. It's possible to apply a gradient, pattern,
22
+ clipping path, mask, or filter to <text>, like any other SVG
24
23
graphics element."
25
24
:attrs [:font-family
26
25
:font-size
69
68
70
69
(defn set-text-and-select-element
71
70
[e el-k]
72
- (.focus (dom/canvas-element )) ; REVIEW
73
71
(rf/dispatch [:element/set-prop el-k :content (get-text e)])
74
72
(rf/dispatch [:set-tool :select ]))
75
73
You can’t perform that action at this time.
0 commit comments