| 1 |
import { defineMode, getMode, registerHelper } from 'codemirror' |
| 2 |
import { Linter } from './utils/Linter' |
| 3 |
import type { EditorConfiguration, ModeSpec } from 'codemirror' |
| 4 |
|
| 5 |
interface ModeSpecOptions { |
| 6 |
startOpen: boolean |
| 7 |
} |
| 8 |
|
| 9 |
const mode: ModeSpec<ModeSpecOptions> = { |
| 10 |
name: 'application/x-httpd-php', |
| 11 |
startOpen: true |
| 12 |
} |
| 13 |
|
| 14 |
defineMode('php-snippet', (config: EditorConfiguration) => getMode(config, mode)) |
| 15 |
|
| 16 |
registerHelper('lint', 'php', (text: string) => { |
| 17 |
const linter = new Linter(text) |
| 18 |
linter.lint() |
| 19 |
|
| 20 |
return linter.annotations |
| 21 |
}) |
| 22 |
|