diff --git a/frontend/locales/en.json b/frontend/locales/en.json index d6217b915..21374de11 100644 --- a/frontend/locales/en.json +++ b/frontend/locales/en.json @@ -222,7 +222,8 @@ "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.", "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": { "uploadFile": { diff --git a/frontend/src/components/editor-page/editor-pane/linter/single-line-regex-linter.ts b/frontend/src/components/editor-page/editor-pane/linter/single-line-regex-linter.ts index c659fe434..d8d826128 100644 --- a/frontend/src/components/editor-page/editor-pane/linter/single-line-regex-linter.ts +++ b/frontend/src/components/editor-page/editor-pane/linter/single-line-regex-linter.ts @@ -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 */ 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 { t } from 'i18next' @@ -25,7 +25,7 @@ export class SingleLineRegexLinter implements Linter { constructor( private regex: RegExp, private message: string, - private replace: (match: string) => string, + private replace?: (match: string) => string, private actionLabel?: string ) {} @@ -52,11 +52,10 @@ export class SingleLineRegexLinter implements Linter { } private createDiagnostic(from: number, found: RegExpExecArray): Diagnostic { - const replacedText = this.replace(found[1]) - return { - from: from, - to: from + found[0].length, - actions: [ + 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) => { @@ -65,7 +64,12 @@ export class SingleLineRegexLinter implements Linter { }) } } - ], + ] + } + return { + from: from, + to: from + found[0].length, + actions: actions, message: this.message, severity: 'warning' } diff --git a/frontend/src/extensions/extra-integrations/fork-awesome/fork-awesome-app-extension.ts b/frontend/src/extensions/extra-integrations/fork-awesome/fork-awesome-app-extension.ts new file mode 100644 index 000000000..b01f5185c --- /dev/null +++ b/frontend/src/extensions/extra-integrations/fork-awesome/fork-awesome-app-extension.ts @@ -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>)?/ + +/** + * 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 + ) + ] + } +} diff --git a/frontend/src/extensions/extra-integrations/optional-app-extensions.ts b/frontend/src/extensions/extra-integrations/optional-app-extensions.ts index c24e0c766..f8d3258c5 100644 --- a/frontend/src/extensions/extra-integrations/optional-app-extensions.ts +++ b/frontend/src/extensions/extra-integrations/optional-app-extensions.ts @@ -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 */ @@ -9,6 +9,7 @@ import { AlertAppExtension } from './alert/alert-app-extension' import { BlockquoteAppExtension } from './blockquote/blockquote-app-extension' import { CsvTableAppExtension } from './csv/csv-table-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 { GraphvizAppExtension } from './graphviz/graphviz-app-extension' import { HighlightedCodeFenceAppExtension } from './highlighted-code-fence/highlighted-code-fence-app-extension' @@ -44,5 +45,6 @@ export const optionalAppExtensions: AppExtension[] = [ new VimeoAppExtension(), new YoutubeAppExtension(), new TaskListCheckboxAppExtension(), - new HighlightedCodeFenceAppExtension() + new HighlightedCodeFenceAppExtension(), + new ForkAwesomeAppExtension() ]