Diffdown is a real-time collaborative Markdown editor/previewer built on the AT Protocol diffdown.com
1import * as _codemirror_state from '@codemirror/state'; 2import { LRLanguage, LanguageSupport } from '@codemirror/language'; 3import { Completion, CompletionContext, CompletionResult, CompletionSource } from '@codemirror/autocomplete'; 4import { Diagnostic } from '@codemirror/lint'; 5import { EditorView } from '@codemirror/view'; 6 7/** 8A language provider based on the [Lezer JavaScript 9parser](https://github.com/lezer-parser/javascript), extended with 10highlighting and indentation information. 11*/ 12declare const javascriptLanguage: LRLanguage; 13/** 14A language provider for TypeScript. 15*/ 16declare const typescriptLanguage: LRLanguage; 17/** 18Language provider for JSX. 19*/ 20declare const jsxLanguage: LRLanguage; 21/** 22Language provider for JSX + TypeScript. 23*/ 24declare const tsxLanguage: LRLanguage; 25/** 26JavaScript support. Includes [snippet](https://codemirror.net/6/docs/ref/#lang-javascript.snippets) 27and local variable completion. 28*/ 29declare function javascript(config?: { 30 jsx?: boolean; 31 typescript?: boolean; 32}): LanguageSupport; 33/** 34Extension that will automatically insert JSX close tags when a `>` or 35`/` is typed. 36*/ 37declare const autoCloseTags: _codemirror_state.Extension; 38 39/** 40A collection of JavaScript-related 41[snippets](https://codemirror.net/6/docs/ref/#autocomplete.snippet). 42*/ 43declare const snippets: readonly Completion[]; 44/** 45A collection of snippet completions for TypeScript. Includes the 46JavaScript [snippets](https://codemirror.net/6/docs/ref/#lang-javascript.snippets). 47*/ 48declare const typescriptSnippets: Completion[]; 49 50/** 51Connects an [ESLint](https://eslint.org/) linter to CodeMirror's 52[lint](https://codemirror.net/6/docs/ref/#lint) integration. `eslint` should be an instance of the 53[`Linter`](https://eslint.org/docs/developer-guide/nodejs-api#linter) 54class, and `config` an optional ESLint configuration. The return 55value of this function can be passed to [`linter`](https://codemirror.net/6/docs/ref/#lint.linter) 56to create a JavaScript linting extension. 57 58Note that ESLint targets node, and is tricky to run in the 59browser. The 60[eslint-linter-browserify](https://github.com/UziTech/eslint-linter-browserify) 61package may help with that (see 62[example](https://github.com/UziTech/eslint-linter-browserify/blob/master/example/script.js)). 63*/ 64declare function esLint(eslint: any, config?: any): (view: EditorView) => Diagnostic[]; 65 66/** 67Completion source that looks up locally defined names in 68JavaScript code. 69*/ 70declare function localCompletionSource(context: CompletionContext): CompletionResult | null; 71/** 72Helper function for defining JavaScript completion sources. It 73returns the completable name and object path for a completion 74context, or null if no name/property completion should happen at 75that position. For example, when completing after `a.b.c` it will 76return `{path: ["a", "b"], name: "c"}`. When completing after `x` 77it will return `{path: [], name: "x"}`. When not in a property or 78name, it will return null if `context.explicit` is false, and 79`{path: [], name: ""}` otherwise. 80*/ 81declare function completionPath(context: CompletionContext): { 82 path: readonly string[]; 83 name: string; 84} | null; 85/** 86Defines a [completion source](https://codemirror.net/6/docs/ref/#autocomplete.CompletionSource) that 87completes from the given scope object (for example `globalThis`). 88Will enter properties of the object when completing properties on 89a directly-named path. 90*/ 91declare function scopeCompletionSource(scope: any): CompletionSource; 92 93export { autoCloseTags, completionPath, esLint, javascript, javascriptLanguage, jsxLanguage, localCompletionSource, scopeCompletionSource, snippets, tsxLanguage, typescriptLanguage, typescriptSnippets };