mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-16 16:14:43 -04:00
feat(frontend): add fork awesome linter
This linter will tell users that their fork awesome icon is deprecated and will stop working in the future and that they should replace it with a new bootstrap icon. Signed-off-by: Philip Molares <philip.molares@udo.edu>
This commit is contained in:
parent
e2c4e2eccf
commit
16b1065a51
4 changed files with 21 additions and 17 deletions
|
@ -51,25 +51,28 @@ export class SingleLineRegexLinter implements Linter {
|
|||
.map(({ lineStartIndex, regexResult }) => this.createDiagnostic(lineStartIndex, regexResult as RegExpExecArray))
|
||||
}
|
||||
|
||||
private createDiagnostic(from: number, found: RegExpExecArray): Diagnostic {
|
||||
let actions: Action[] = []
|
||||
if (this.replace !== undefined) {
|
||||
const replacedText = this.replace(found[1])
|
||||
actions = [
|
||||
{
|
||||
name: t(this.actionLabel ?? 'editor.linter.defaultAction'),
|
||||
apply: (view: EditorView, from: number, to: number) => {
|
||||
view.dispatch({
|
||||
changes: { from, to, insert: replacedText }
|
||||
})
|
||||
}
|
||||
}
|
||||
]
|
||||
private buildActions(found: RegExpExecArray): Action[] {
|
||||
if (this.replace === undefined) {
|
||||
return []
|
||||
}
|
||||
const replacedText = this.replace(found[1])
|
||||
return [
|
||||
{
|
||||
name: t(this.actionLabel ?? 'editor.linter.defaultAction'),
|
||||
apply: (view: EditorView, from: number, to: number) => {
|
||||
view.dispatch({
|
||||
changes: { from, to, insert: replacedText }
|
||||
})
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
private createDiagnostic(from: number, found: RegExpExecArray): Diagnostic {
|
||||
return {
|
||||
from: from,
|
||||
to: from + found[0].length,
|
||||
actions: actions,
|
||||
actions: this.buildActions(found),
|
||||
message: this.message,
|
||||
severity: 'warning'
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue