tiptap/demos/src/Experiments/Linter/Vue/extension/LinterPlugin.ts
2024-12-31 11:18:19 +01:00

38 lines
685 B
TypeScript

import { Node as ProsemirrorNode } from '@tiptap/pm/model'
export interface Result {
message: string
from: number
to: number
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
fix?: Function
}
export default class LinterPlugin {
protected doc
private results: Array<Result> = []
constructor(doc: ProsemirrorNode) {
this.doc = doc
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
record(message: string, from: number, to: number, fix?: Function) {
this.results.push({
message,
from,
to,
fix,
})
}
scan() {
return this
}
getResults() {
return this.results
}
}