File tree Expand file tree Collapse file tree 4 files changed +35
-13
lines changed
demo/nextjournal/clojure_mode
main/nextjournal/clojure_mode Expand file tree Collapse file tree 4 files changed +35
-13
lines changed Original file line number Diff line number Diff line change 108
108
(cond-> {" ArrowUp" " ↑"
109
109
" ArrowDown" " ↓"
110
110
" ArrowRight" " →"
111
- " ArrowLeft" " ←" }
111
+ " ArrowLeft" " ←"
112
+ " Mod" " Ctrl" }
112
113
(mac? )
113
114
(merge {" Alt" " ⌥"
114
115
" Shift" " ⇧"
115
116
" Enter" " ⏎"
116
- " Ctrl" " ⌃" })))
117
+ " Ctrl" " ⌃"
118
+ " Mod" " ⌘" })))
117
119
118
120
(defn render-key [key]
119
121
(let [keys (into [] (map #(get ((memoize key-mapping)) % %) (str/split key #"-" )))]
126
128
:innerHTML
127
129
(tag :div
128
130
(tag :h3 {:class " m-3" } " Keybindings" )
129
- (tag :table {:cellpadding 0 :class " w-full" }
131
+ (tag :table {:cellpadding 0 :class " w-full text-sm" }
132
+ (tag :tr
133
+ {:class " border-t even:bg-gray-100" }
134
+ (tag :td {:class " px-3 py-1 align-top text-sm" } " Command" )
135
+ (tag :td {:class " px-3 py-1 align-top text-sm" } " Keybinding" )
136
+ (tag :td {:class " px-3 py-1 align-top text-sm" } " Alternate Binding" )
137
+ (tag :td {:class " px-3 py-1 align-top text-sm" } " Description" ))
130
138
(->> keymap/paredit-keymap*
139
+ (merge (sci/keymap* " Alt" ))
131
140
(sort-by first)
132
- (reduce (fn [out [command [{:keys [key shift doc]}]]]
141
+ (reduce (fn [out [command [{:keys [key shift doc]} & [{alternate-key :key }] ]]]
133
142
(str out
134
143
(tag :tr
135
144
{:class " border-t even:bg-gray-100" }
136
145
(tag :td {:class " px-3 py-1 align-top" } (tag :b (name command)))
137
146
(tag :td {:class " px-3 py-1 align-top text-sm" } (render-key key))
147
+ (tag :td {:class " px-3 py-1 align-top text-sm" } (some-> alternate-key render-key))
138
148
(tag :td {:class " px-3 py-1 align-top" } doc))
139
149
(when shift
140
150
(tag :tr
141
151
{:class " border-t even:bg-gray-100" }
142
152
(tag :td {:class " px-3 py-1 align-top" } (tag :b (name shift)))
143
153
(tag :td {:class " px-3 py-1 align-top text-sm" }
144
154
(render-key (str " Shift-" key)))
155
+ (tag :td {:class " px-3 py-1 align-top text-sm" })
145
156
(tag :td {:class " px-3 py-1 align-top" } " " ))))) " " ))
146
157
" </table>" ))))
147
158
Original file line number Diff line number Diff line change 31
31
(on-result ))
32
32
true )
33
33
34
+ (defn keymap* [modifier]
35
+ {:eval-cell
36
+ [{:key " Mod-Enter"
37
+ :doc " Evaluate cell" }]
38
+ :eval-at-cursor
39
+ [{:key (str modifier " -Enter" )
40
+ :doc " Evaluates form at cursor" }]
41
+ :eval-top-level
42
+ [{:key (str modifier " -Shift-Enter" )
43
+ :doc " Evaluates top-level form at cursor" }]})
44
+
34
45
(defn extension [{:keys [modifier
35
46
on-result]}]
36
47
(.of view/keymap
Original file line number Diff line number Diff line change 28
28
29
29
(defn copy-to-clipboard! [text]
30
30
(let [^js focus-el (j/get js/document :activeElement )
31
- input-el (js/document.createElement " input " )]
31
+ input-el (js/document.createElement " textarea " )]
32
32
(.setAttribute input-el " class" " clipboard-input" )
33
- (.setAttribute input-el " value " text)
33
+ (j/assoc! input-el :innerHTML text)
34
34
(-> js/document .-body (.appendChild input-el))
35
35
(.focus input-el)
36
36
(.select input-el)
37
37
(js/document.execCommand " copy" )
38
- (-> js/document .-body ( .removeChild input-el) )
39
- (.focus focus -el)))
38
+ (.focus focus-el #js { :preventScroll true } )
39
+ (-> js/document .-body ( .removeChild input -el) )))
40
40
41
41
(defn kill* [^js state]
42
42
(u/update-ranges state
Original file line number Diff line number Diff line change 210
210
([^js state node]
211
211
(string state (start node) (end node)))
212
212
([^js state from to]
213
- (.slice (.-doc state) from to)))
213
+ (.sliceString (.-doc state) from to \newline )))
214
214
215
215
(defn ancestor? [parent child]
216
216
(boolean
373
373
L
374
374
R
375
375
mid)
376
- -1 (or (u/guard L (every-pred some? #(or (same-edge? %) (not (left-edge? %)))))
377
- R
378
- L
379
- mid))))
376
+ -1 (or (u/guard L (every-pred some? #(or (same-edge? %) (not (left-edge? %)))))
377
+ R
378
+ L
379
+ mid))))
You can’t perform that action at this time.
0 commit comments