git.s-ol.nu mmm / b16751f
clean up editor a bit s-ol 1 year, 11 months ago
2 changed file(s) with 26 addition(s) and 23 deletion(s). Raw diff Collapse all Expand all
210210 key
211211
212212 @inspect_err = ReactiveVar!
213 @editor = ReactiveVar!
213214
214215 with div class: 'view inspector'
215216 -- nav
216217 \append nav {
217218 span 'inspector'
219
220 button 'close', onclick: (_, e) -> @inspect\set false
221 }
222
223 \append div {
224 class: 'subnav'
225
226 ondrop: ->
227 print "dropped"
228
229 onpaste: ->
230 print "pasted"
218231
219232 @inspect_prop\map (current) ->
220233 current = current and current\tostring!
245258 @inspect_prop\set Key facet
246259 @refresh!
247260
248 button 'close', onclick: (_, e) -> @inspect\set false
261 div style: flex: '1'
262
263 @editor\map (e) -> e and e.saveBtn
249264 }
250265
251266 -- error / content
254269 \append @inspect_err
255270 \append with pre class: 'content'
256271 \append keep @inspect_prop\map (prop, old) ->
257 @get_content prop, @inspect_err, (prop) =>
258 value, key = @get prop
272 @get_content prop, @inspect_err, (fileder, prop) ->
273 value, key = fileder\get prop
259274 assert key, "couldn't @get #{prop}"
260275
261276 conversions = get_conversions 'mmm/dom', key.type, get_casts!
262277 assert conversions, "cannot cast '#{key.type}'"
263 apply_conversions conversions, value, @, prop
278 with res = apply_conversions conversions, value, fileder, prop
279 @editor\set if res.EDITOR then res
264280
265281 -- children
266282 \append nav {
88 for k,v in pairs(tbl)
99 obj[k] = v
1010
11 EDITOR: true
12
1113 new: (value, mode, @fileder, @key) =>
12 @node = div {
13 class: 'editor'
14 style:
15 display: 'flex'
16 'flex-direction': 'column'
17 'justify-content': 'space-around'
14 @node = div class: 'editor'
1815
19 div {
20 style:
21 display: 'flex'
22 flex: '0'
23 'justify-content': 'flex-end'
24 'border-bottom': '2px solid var(--gray-dark)'
25 'padding-bottom': '0.5em'
26 'margin': '-0.5em 0 0.5em'
16 @saveBtn = with button 'save'
17 .disabled = true
18 .onclick = (_, e) -> @save e
2719
28 with @saveBtn = button 'save changes'
29 .disabled = true
30 .onclick = (_, e) -> @save e
31 }
32 }
3320 @cm = window\CodeMirror @node, o {
3421 :value
3522 :mode