设置CodeMirror的缩进单位

问题描述 投票:0回答:0

我想将 indentUnit 设置为 x 个空格,而不是 CM 6 中的默认两个空格

这是我在我正在使用的 JSON 查看器中将其设置为 10 的尝试:

let state = EditorState.create({
          extensions: [
            basicSetup,       
            json({ jsx: true }),     
            indentUnit.of("          "),
            tabSize.of(EditorState.tabSize.of(10))
          ]
        })
        
        let view = new EditorView({
          state,
          parent: document.body
        })

但是它不起作用,有没有人可以提供一个例子并修复我上面的尝试?

codemirror
© www.soinside.com 2019 - 2024. All rights reserved.