Skip to content
This repository has been archived by the owner on Nov 23, 2022. It is now read-only.

use types from markdown-it-toc-done-right plugin #665

Merged
merged 2 commits into from
Nov 23, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<TocAst|undefined>, onTocChange?: (ast: TocAst) => void): void => {
const lastTocAst = useRef<TocAst>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<DocumentTocPluginOptions> = (markdownIt, onToc) => {
export const documentToc: MarkdownIt.PluginWithOptions<DocumentTocPluginOptions> = (markdownIt, onToc) => {
if (!onToc) {
return
}
Expand Down
12 changes: 0 additions & 12 deletions src/external-types/markdown-it-toc-done-right/index.d.ts
Original file line number Diff line number Diff line change
@@ -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<TocOptions>
export = markdownItTocDoneRight
}
25 changes: 0 additions & 25 deletions src/external-types/markdown-it-toc-done-right/interface.ts
Original file line number Diff line number Diff line change
@@ -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[]
}