mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2024-11-21 17:26:29 -05: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
eacd81cb9c
commit
e2c4e2eccf
4 changed files with 44 additions and 12 deletions
|
@ -222,7 +222,8 @@
|
||||||
"sequence": "The use of 'sequence' as code block language is deprecated and will be removed in a future release.",
|
"sequence": "The use of 'sequence' as code block language is deprecated and will be removed in a future release.",
|
||||||
"shortcode": "The {{shortcode}} short-code is deprecated and will be removed in a future release. Use a single line URL instead.",
|
"shortcode": "The {{shortcode}} short-code is deprecated and will be removed in a future release. Use a single line URL instead.",
|
||||||
"frontmatter": "The yaml-metadata is invalid.",
|
"frontmatter": "The yaml-metadata is invalid.",
|
||||||
"frontmatter-tags": "The comma-separated definition of tags in the yaml-metadata is deprecated. Use a yaml-array instead."
|
"frontmatter-tags": "The comma-separated definition of tags in the yaml-metadata is deprecated. Use a yaml-array instead.",
|
||||||
|
"fork-awesome": "Fork Awesome is deprecated and will be removed in future release. Please use the new bootstrap icons instead. See {{link}} for more information."
|
||||||
},
|
},
|
||||||
"upload": {
|
"upload": {
|
||||||
"uploadFile": {
|
"uploadFile": {
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
import type { Linter } from './linter'
|
import type { Linter } from './linter'
|
||||||
import type { Diagnostic } from '@codemirror/lint'
|
import type { Action, Diagnostic } from '@codemirror/lint'
|
||||||
import type { EditorView } from '@codemirror/view'
|
import type { EditorView } from '@codemirror/view'
|
||||||
import { t } from 'i18next'
|
import { t } from 'i18next'
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ export class SingleLineRegexLinter implements Linter {
|
||||||
constructor(
|
constructor(
|
||||||
private regex: RegExp,
|
private regex: RegExp,
|
||||||
private message: string,
|
private message: string,
|
||||||
private replace: (match: string) => string,
|
private replace?: (match: string) => string,
|
||||||
private actionLabel?: string
|
private actionLabel?: string
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
@ -52,11 +52,10 @@ export class SingleLineRegexLinter implements Linter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private createDiagnostic(from: number, found: RegExpExecArray): Diagnostic {
|
private createDiagnostic(from: number, found: RegExpExecArray): Diagnostic {
|
||||||
const replacedText = this.replace(found[1])
|
let actions: Action[] = []
|
||||||
return {
|
if (this.replace !== undefined) {
|
||||||
from: from,
|
const replacedText = this.replace(found[1])
|
||||||
to: from + found[0].length,
|
actions = [
|
||||||
actions: [
|
|
||||||
{
|
{
|
||||||
name: t(this.actionLabel ?? 'editor.linter.defaultAction'),
|
name: t(this.actionLabel ?? 'editor.linter.defaultAction'),
|
||||||
apply: (view: EditorView, from: number, to: number) => {
|
apply: (view: EditorView, from: number, to: number) => {
|
||||||
|
@ -65,7 +64,12 @@ export class SingleLineRegexLinter implements Linter {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
],
|
]
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
from: from,
|
||||||
|
to: from + found[0].length,
|
||||||
|
actions: actions,
|
||||||
message: this.message,
|
message: this.message,
|
||||||
severity: 'warning'
|
severity: 'warning'
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
*/
|
||||||
|
import type { Linter } from '../../../components/editor-page/editor-pane/linter/linter'
|
||||||
|
import { SingleLineRegexLinter } from '../../../components/editor-page/editor-pane/linter/single-line-regex-linter'
|
||||||
|
import { AppExtension } from '../../base/app-extension'
|
||||||
|
import { t } from 'i18next'
|
||||||
|
|
||||||
|
export const forkAwesomeRegex = /<i class=["']fa fa-[\w-]+["'](?: aria-hidden=["']true["'])?\/?>(?:<\/i>)?/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds support for flow charts to the markdown rendering.
|
||||||
|
*/
|
||||||
|
export class ForkAwesomeAppExtension extends AppExtension {
|
||||||
|
buildCodeMirrorLinter(): Linter[] {
|
||||||
|
return [
|
||||||
|
new SingleLineRegexLinter(
|
||||||
|
forkAwesomeRegex,
|
||||||
|
t('editor.linter.fork-awesome', { link: 'https://docs.hedgedoc.org' }) // ToDo: Add correct link here
|
||||||
|
)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
* SPDX-FileCopyrightText: 2023 The HedgeDoc developers (see AUTHORS file)
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: AGPL-3.0-only
|
* SPDX-License-Identifier: AGPL-3.0-only
|
||||||
*/
|
*/
|
||||||
|
@ -9,6 +9,7 @@ import { AlertAppExtension } from './alert/alert-app-extension'
|
||||||
import { BlockquoteAppExtension } from './blockquote/blockquote-app-extension'
|
import { BlockquoteAppExtension } from './blockquote/blockquote-app-extension'
|
||||||
import { CsvTableAppExtension } from './csv/csv-table-app-extension'
|
import { CsvTableAppExtension } from './csv/csv-table-app-extension'
|
||||||
import { FlowchartAppExtension } from './flowchart/flowchart-app-extension'
|
import { FlowchartAppExtension } from './flowchart/flowchart-app-extension'
|
||||||
|
import { ForkAwesomeAppExtension } from './fork-awesome/fork-awesome-app-extension'
|
||||||
import { GistAppExtension } from './gist/gist-app-extension'
|
import { GistAppExtension } from './gist/gist-app-extension'
|
||||||
import { GraphvizAppExtension } from './graphviz/graphviz-app-extension'
|
import { GraphvizAppExtension } from './graphviz/graphviz-app-extension'
|
||||||
import { HighlightedCodeFenceAppExtension } from './highlighted-code-fence/highlighted-code-fence-app-extension'
|
import { HighlightedCodeFenceAppExtension } from './highlighted-code-fence/highlighted-code-fence-app-extension'
|
||||||
|
@ -44,5 +45,6 @@ export const optionalAppExtensions: AppExtension[] = [
|
||||||
new VimeoAppExtension(),
|
new VimeoAppExtension(),
|
||||||
new YoutubeAppExtension(),
|
new YoutubeAppExtension(),
|
||||||
new TaskListCheckboxAppExtension(),
|
new TaskListCheckboxAppExtension(),
|
||||||
new HighlightedCodeFenceAppExtension()
|
new HighlightedCodeFenceAppExtension(),
|
||||||
|
new ForkAwesomeAppExtension()
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in a new issue