From c09aaf010cb0c91900fb8d7caae6ae0b2b1ec999 Mon Sep 17 00:00:00 2001 From: Philip Molares Date: Mon, 23 Nov 2020 12:40:54 +0100 Subject: [PATCH] use types from markdown-it-toc-done-right plugin (#665) Signed-off-by: Philip Molares --- .../document-render-pane.tsx | 2 +- .../table-of-contents/table-of-contents.tsx | 2 +- .../full-markdown-renderer.tsx | 2 +- .../hooks/use-post-toc-ast-on-change.ts | 2 +- .../FullMarkdownItConfigurator.tsx | 2 +- .../markdown-it-plugins/document-toc.ts | 5 ++-- .../markdown-it-toc-done-right/index.d.ts | 12 --------- .../markdown-it-toc-done-right/interface.ts | 25 ------------------- 8 files changed, 7 insertions(+), 45 deletions(-) delete mode 100644 src/external-types/markdown-it-toc-done-right/index.d.ts delete mode 100644 src/external-types/markdown-it-toc-done-right/interface.ts diff --git a/src/components/editor/document-renderer-pane/document-render-pane.tsx b/src/components/editor/document-renderer-pane/document-render-pane.tsx index cbf7638c5..55e89359f 100644 --- a/src/components/editor/document-renderer-pane/document-render-pane.tsx +++ b/src/components/editor/document-renderer-pane/document-render-pane.tsx @@ -8,7 +8,7 @@ import React, { RefObject, useState } from 'react' import { Dropdown } from 'react-bootstrap' import { useSelector } from 'react-redux' import useResizeObserver from 'use-resize-observer' -import { TocAst } from '../../../external-types/markdown-it-toc-done-right/interface' +import { TocAst } from 'markdown-it-toc-done-right' import { ApplicationState } from '../../../redux' import { ForkAwesomeIcon } from '../../common/fork-awesome/fork-awesome-icon' import { ShowIf } from '../../common/show-if/show-if' diff --git a/src/components/editor/table-of-contents/table-of-contents.tsx b/src/components/editor/table-of-contents/table-of-contents.tsx index 799b32b5b..7e67e7d5c 100644 --- a/src/components/editor/table-of-contents/table-of-contents.tsx +++ b/src/components/editor/table-of-contents/table-of-contents.tsx @@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only import React, { Fragment, ReactElement, useMemo } from 'react' import { Trans, useTranslation } from 'react-i18next' -import { TocAst } from '../../../external-types/markdown-it-toc-done-right/interface' +import { TocAst } from 'markdown-it-toc-done-right' import { ShowIf } from '../../common/show-if/show-if' import './table-of-contents.scss' diff --git a/src/components/markdown-renderer/full-markdown-renderer.tsx b/src/components/markdown-renderer/full-markdown-renderer.tsx index 468f36d81..411160cdc 100644 --- a/src/components/markdown-renderer/full-markdown-renderer.tsx +++ b/src/components/markdown-renderer/full-markdown-renderer.tsx @@ -7,7 +7,7 @@ SPDX-License-Identifier: AGPL-3.0-only import React, { useCallback, useMemo, useRef, useState } from 'react' import { Alert } from 'react-bootstrap' import { Trans } from 'react-i18next' -import { TocAst } from '../../external-types/markdown-it-toc-done-right/interface' +import { TocAst } from 'markdown-it-toc-done-right' import { InternalLink } from '../common/links/internal-link' import { ShowIf } from '../common/show-if/show-if' import { RawYAMLMetadata, YAMLMetaData } from '../editor/yaml-metadata/yaml-metadata' diff --git a/src/components/markdown-renderer/hooks/use-post-toc-ast-on-change.ts b/src/components/markdown-renderer/hooks/use-post-toc-ast-on-change.ts index d1e0d5770..fe8969eca 100644 --- a/src/components/markdown-renderer/hooks/use-post-toc-ast-on-change.ts +++ b/src/components/markdown-renderer/hooks/use-post-toc-ast-on-change.ts @@ -6,7 +6,7 @@ import equal from 'fast-deep-equal' import { RefObject, useEffect, useRef } from 'react' -import { TocAst } from '../../../external-types/markdown-it-toc-done-right/interface' +import { TocAst } from 'markdown-it-toc-done-right' export const usePostTocAstOnChange = (tocAst: RefObject, onTocChange?: (ast: TocAst) => void): void => { const lastTocAst = useRef() diff --git a/src/components/markdown-renderer/markdown-it-configurator/FullMarkdownItConfigurator.tsx b/src/components/markdown-renderer/markdown-it-configurator/FullMarkdownItConfigurator.tsx index a6debc4a5..2a7fdb2ee 100644 --- a/src/components/markdown-renderer/markdown-it-configurator/FullMarkdownItConfigurator.tsx +++ b/src/components/markdown-renderer/markdown-it-configurator/FullMarkdownItConfigurator.tsx @@ -5,7 +5,7 @@ SPDX-License-Identifier: AGPL-3.0-only */ import MarkdownIt from 'markdown-it' -import { TocAst } from '../../../external-types/markdown-it-toc-done-right/interface' +import { TocAst } from 'markdown-it-toc-done-right' import { RawYAMLMetadata } from '../../editor/yaml-metadata/yaml-metadata' import { documentToc } from '../markdown-it-plugins/document-toc' import { frontmatterExtract } from '../markdown-it-plugins/frontmatter' diff --git a/src/components/markdown-renderer/markdown-it-plugins/document-toc.ts b/src/components/markdown-renderer/markdown-it-plugins/document-toc.ts index 8042f148f..12c7ecb06 100644 --- a/src/components/markdown-renderer/markdown-it-plugins/document-toc.ts +++ b/src/components/markdown-renderer/markdown-it-plugins/document-toc.ts @@ -5,13 +5,12 @@ */ import MarkdownIt from 'markdown-it' -import toc from 'markdown-it-toc-done-right' -import { TocAst } from '../../../external-types/markdown-it-toc-done-right/interface' +import toc, { TocAst } from 'markdown-it-toc-done-right' import { slugify } from '../../editor/table-of-contents/table-of-contents' export type DocumentTocPluginOptions = (ast: TocAst) => void -export const documentToc:MarkdownIt.PluginWithOptions = (markdownIt, onToc) => { +export const documentToc: MarkdownIt.PluginWithOptions = (markdownIt, onToc) => { if (!onToc) { return } diff --git a/src/external-types/markdown-it-toc-done-right/index.d.ts b/src/external-types/markdown-it-toc-done-right/index.d.ts deleted file mode 100644 index a2f3f4612..000000000 --- a/src/external-types/markdown-it-toc-done-right/index.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2020 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ - -declare module 'markdown-it-toc-done-right' { - import MarkdownIt from 'markdown-it/lib' - import { TocOptions } from './interface' - const markdownItTocDoneRight: MarkdownIt.PluginWithOptions - export = markdownItTocDoneRight - } diff --git a/src/external-types/markdown-it-toc-done-right/interface.ts b/src/external-types/markdown-it-toc-done-right/interface.ts deleted file mode 100644 index 6f1b74db1..000000000 --- a/src/external-types/markdown-it-toc-done-right/interface.ts +++ /dev/null @@ -1,25 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2020 The HedgeDoc developers (see AUTHORS file) - * - * SPDX-License-Identifier: AGPL-3.0-only - */ - -export interface TocOptions { - placeholder: string - slugify: (s: string) => string - containerClass: string - containerId: string - listClass: string - itemClass: string - linkClass: string - level: number | number[] - listType: 'ol' | 'ul' - format: (s: string) => string - callback: (tocCode: string, ast: TocAst) => void -} - -export interface TocAst { - l: number - n: string - c: TocAst[] -}