Skip to content

Commit

Permalink
Merge branch 'master' into fix-test-script
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippRaab committed Sep 17, 2020
2 parents 13b1e61 + 1f56e7e commit 1d24e3e
Show file tree
Hide file tree
Showing 6 changed files with 22,627 additions and 27 deletions.
23 changes: 4 additions & 19 deletions demo.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
import {EditorView} from "@codemirror/next/view"
import {EditorState} from "@codemirror/next/state"
import {defaultHighlighter} from "@codemirror/next/highlight"
import {lineNumbers} from "@codemirror/next/gutter"
import {keymap} from "@codemirror/next/keymap"
import {baseKeymap} from "@codemirror/next/commands"
import {bracketMatching} from "@codemirror/next/matchbrackets"
import {closeBrackets} from "@codemirror/next/closebrackets"
import {specialChars} from "@codemirror/next/special-chars"
import {foldGutter} from "@codemirror/next/fold"
import { basicSetup, EditorState, EditorView } from '@codemirror/next/basic-setup';

let json = String.raw`{
"literals": [true, false, null],
Expand All @@ -24,12 +15,12 @@ let json = String.raw`{
}
}`

import {parser} from "./dist/index"
import {parser} from "./dist/index.es"
import {Subtree} from "lezer-tree"
import {LezerSyntax, foldNodeProp} from "@codemirror/next/syntax"
import {styleTags} from "@codemirror/next/highlight"

let jsonSyntax = new LezerSyntax(parser.withProps(
let jsonSyntax = LezerSyntax.define(parser.withProps(
foldNodeProp.add({
Array(tree) { return {from: tree.start + 1, to: tree.end - 1} },
Object(tree) { return {from: tree.start + 1, to: tree.end - 1} }
Expand All @@ -46,13 +37,7 @@ let jsonSyntax = new LezerSyntax(parser.withProps(
let view = new EditorView({state: EditorState.create({
doc: json,
extensions: [
lineNumbers(),
defaultHighlighter,
keymap(baseKeymap),
specialChars(),
closeBrackets,
bracketMatching(),
foldGutter(),
basicSetup,
jsonSyntax
]
})})
Expand Down
3 changes: 3 additions & 0 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import {Parser} from "lezer"

export const parser: Parser

0 comments on commit 1d24e3e

Please sign in to comment.