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
e2c4e2eccf
commit
16b1065a51
4 changed files with 21 additions and 17 deletions
|
@ -19,6 +19,7 @@ SPDX-License-Identifier: CC-BY-SA-4.0
|
||||||
- `{%pdf https://example.org/example-pdf.pdf %}` -> Embedding removed
|
- `{%pdf https://example.org/example-pdf.pdf %}` -> Embedding removed
|
||||||
- The use of `sequence` as code block language ([Why?](https://github.com/hedgedoc/react-client/issues/488#issuecomment-683262875))
|
- The use of `sequence` as code block language ([Why?](https://github.com/hedgedoc/react-client/issues/488#issuecomment-683262875))
|
||||||
- Comma-separated definition of tags in the yaml-frontmatter
|
- Comma-separated definition of tags in the yaml-frontmatter
|
||||||
|
- Fork Awesome Icons will be removed in a future release
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
|
|
@ -223,7 +223,7 @@
|
||||||
"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."
|
"fork-awesome": "Fork Awesome is deprecated and will be removed in a future release. Please use bootstrap icons instead. See {{link}} for more information."
|
||||||
},
|
},
|
||||||
"upload": {
|
"upload": {
|
||||||
"uploadFile": {
|
"uploadFile": {
|
||||||
|
|
|
@ -51,25 +51,28 @@ export class SingleLineRegexLinter implements Linter {
|
||||||
.map(({ lineStartIndex, regexResult }) => this.createDiagnostic(lineStartIndex, regexResult as RegExpExecArray))
|
.map(({ lineStartIndex, regexResult }) => this.createDiagnostic(lineStartIndex, regexResult as RegExpExecArray))
|
||||||
}
|
}
|
||||||
|
|
||||||
private createDiagnostic(from: number, found: RegExpExecArray): Diagnostic {
|
private buildActions(found: RegExpExecArray): Action[] {
|
||||||
let actions: Action[] = []
|
if (this.replace === undefined) {
|
||||||
if (this.replace !== undefined) {
|
return []
|
||||||
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 }
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
|
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 {
|
return {
|
||||||
from: from,
|
from: from,
|
||||||
to: from + found[0].length,
|
to: from + found[0].length,
|
||||||
actions: actions,
|
actions: this.buildActions(found),
|
||||||
message: this.message,
|
message: this.message,
|
||||||
severity: 'warning'
|
severity: 'warning'
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import { SingleLineRegexLinter } from '../../../components/editor-page/editor-pa
|
||||||
import { AppExtension } from '../../base/app-extension'
|
import { AppExtension } from '../../base/app-extension'
|
||||||
import { t } from 'i18next'
|
import { t } from 'i18next'
|
||||||
|
|
||||||
export const forkAwesomeRegex = /<i class=["']fa fa-[\w-]+["'](?: aria-hidden=["']true["'])?\/?>(?:<\/i>)?/
|
const forkAwesomeRegex = /<i class=["'][\w\s]*fa-[\w-]+[\w\s-]*["'][^>]*\/?>(?:<\/i>)?/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds support for flow charts to the markdown rendering.
|
* Adds support for flow charts to the markdown rendering.
|
||||||
|
|
Loading…
Reference in a new issue