~talon/gmi-web

ref: 92b14274c6c9565300c42c09138a1c83d87eceee gmi-web/docs/js.gmi -rw-r--r-- 1.4 KiB
92b14274 — Talon Poole documentation a month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# gmi.js
## A bridge between the DOM and Gemini

gmi.js is made up of lines!
```js
const line = Gemini.line("manipulate the dom\nbut like in a Gemini way\ntry it!")
document.body.prepend(line.dom)
```
> now try changing the type and content and observing the effects.  
```js
line.type = "UL"
line.content = "now\nit's\na\nlist"
```

A document provides a way to handle many lines together:
```js
window.gmi = new Gemini(document.body)
window.gmi.lines = [
  Gemini.line("interesting", "H1"),
  Gemini.line("that's convenient"),
  Gemini.line("http://talon.computer/js/ now... take me back please", "A"),
]
window.gmi.lines[0].type = "H3"
```
> the gemtext source is available via .source
```js
window.gmi.source
```
> or maybe a .gmi file would be easier?
```js
window.gmi.download()
```

All the gmi.css variables are also available as properties.
```
let foreground = window.gmi.foreground
let background = window.gmi.background
window.gmi.foreground = background
window.gmi.background = foreground
```
=> /css/ learn more about gmi.css

=> https://git.sr.ht/~talon/gmi-web/tree gmi.js is licensed under CC0 and available on sourcehut as apart of gmi-web

### [WIP] editing!
* enter creates new P
* shift + enter creates newline
* backspace at beginning of line doesn't remove DOM (+ delete on empty lines)
* cross-platform action for changing line type?
* cross-platform action for toggling editable?