Skip to content

Commit 40e6dd8

Browse files
committed
add folding to editor
1 parent f7c9ab4 commit 40e6dd8

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

packages/editor/lib/setup.js

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1-
import { EditorView, highlightActiveLine, showPanel } from '@codemirror/view'
1+
import { foldGutter, toggleFold } from '@codemirror/language'
2+
import {
3+
EditorView,
4+
highlightActiveLine,
5+
keymap,
6+
showPanel,
7+
} from '@codemirror/view'
28
import { org } from '@orgajs/cm-lang'
3-
import theme from './theme.js'
49
import { cleanupPlugin } from './plugins/cleanup.js'
10+
import theme from './theme.js'
511

612
/**
7-
* @returns {import('@codemirror/view').Panel')}
13+
* @returns {import('@codemirror/view').Panel}
814
*/
915
function footer() {
1016
const dom = document.createElement('div')
@@ -17,11 +23,20 @@ function footer() {
1723
}
1824
}
1925

26+
const keys = [
27+
{
28+
key: 'Tab',
29+
run: toggleFold,
30+
},
31+
]
32+
2033
export const setup = (() => [
2134
highlightActiveLine(),
35+
foldGutter(),
2236
org(),
2337
theme,
2438
EditorView.lineWrapping,
2539
cleanupPlugin,
2640
showPanel.of(footer),
41+
keymap.of(keys),
2742
])()

0 commit comments

Comments
 (0)