|
62 | 62 | (not redos?)]]]))
|
63 | 63 |
|
64 | 64 | (defn close-button
|
65 |
| - [key saved?] |
| 65 | + [k saved?] |
66 | 66 | [:button.close-document-button.small.hover:bg-transparent
|
67 |
| - {:key key |
| 67 | + {:key k |
68 | 68 | :title "Close document"
|
69 | 69 | :on-pointer-down #(.stopPropagation %)
|
70 | 70 | :on-pointer-up (fn [e]
|
71 | 71 | (.stopPropagation e)
|
72 |
| - (rf/dispatch [::document.e/close key true]))} |
| 72 | + (rf/dispatch [::document.e/close k true]))} |
73 | 73 | [ui/icon "times"]
|
74 | 74 | (when-not saved?
|
75 | 75 | [ui/icon "dot" {:class "icon dot"}])])
|
76 | 76 |
|
77 | 77 | (defn context-menu
|
78 |
| - [key] |
79 |
| - (let [document @(rf/subscribe [::document.s/document key]) |
| 78 | + [k] |
| 79 | + (let [document @(rf/subscribe [::document.s/document k]) |
80 | 80 | path (:path document)
|
81 | 81 | document-tabs @(rf/subscribe [:document-tabs])]
|
82 | 82 | [{:label "Close"
|
83 |
| - :action [::document.e/close key true]} |
| 83 | + :action [::document.e/close k true]} |
84 | 84 | {:label "Close others"
|
85 |
| - :action [::document.e/close-others key] |
| 85 | + :action [::document.e/close-others k] |
86 | 86 | :disabled? (empty? (rest document-tabs))}
|
87 | 87 | {:label "Close all"
|
88 | 88 | :action [::document.e/close-all]}
|
|
94 | 94 | :disabled? (not (and path platform/electron?))}]))
|
95 | 95 |
|
96 | 96 | (defn tab
|
97 |
| - [key document active?] |
| 97 | + [k document active?] |
98 | 98 | (ra/with-let [dragged-over? (ra/atom false)]
|
99 |
| - (let [saved? @(rf/subscribe [::document.s/saved? key])] |
| 99 | + (let [saved? @(rf/subscribe [::document.s/saved? k])] |
100 | 100 | [:> ContextMenu/Root
|
101 | 101 | [:> ContextMenu/Trigger
|
102 | 102 | [:div.document-tab
|
103 | 103 | {:class [(when active? "active")
|
104 | 104 | (when saved? "saved")]
|
105 | 105 | :on-wheel #(rf/dispatch [::document.e/scroll (.-deltaY %)])
|
106 | 106 | :on-pointer-down #(case (.-buttons %)
|
107 |
| - 4 (rf/dispatch [::document.e/close key true]) |
108 |
| - 1 (rf/dispatch [::document.e/set-active key]) |
| 107 | + 4 (rf/dispatch [::document.e/close k true]) |
| 108 | + 1 (rf/dispatch [::document.e/set-active k]) |
109 | 109 | nil)
|
110 | 110 | :draggable true
|
111 |
| - :on-drag-start #(.setData (.-dataTransfer %) "key" (name key)) |
| 111 | + :on-drag-start #(.setData (.-dataTransfer %) "key" (name k)) |
112 | 112 | :on-drag-over #(.preventDefault %)
|
113 | 113 | :on-drag-enter #(reset! dragged-over? true)
|
114 | 114 | :on-drag-leave #(reset! dragged-over? false)
|
|
118 | 118 | (rf/dispatch [::document.e/swap-position
|
119 | 119 | (-> (.getData (.-dataTransfer evt) "key")
|
120 | 120 | keyword)
|
121 |
| - key]))} |
| 121 | + k]))} |
122 | 122 | [:span.truncate.pointer-events-none
|
123 | 123 | (:title document)]
|
124 |
| - [close-button key saved?]]] |
| 124 | + [close-button k saved?]]] |
125 | 125 | [:> ContextMenu/Portal
|
126 | 126 | (into
|
127 | 127 | [:> ContextMenu/Content
|
128 | 128 | {:class "menu-content context-menu-content"}]
|
129 | 129 | (map (fn [item]
|
130 | 130 | [ui/context-menu-item item])
|
131 |
| - (context-menu key)))]]))) |
| 131 | + (context-menu k)))]]))) |
132 | 132 |
|
133 | 133 | (defn tab-bar []
|
134 | 134 | (let [documents @(rf/subscribe [:documents])
|
|
0 commit comments