Introduce Markdown extensions (#1614)

* Introduce markdown extensions

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2021-11-15 17:04:49 +01:00 committed by GitHub
parent e9defd60dc
commit 8a8bacc0aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
148 changed files with 1878 additions and 1128 deletions

View file

@ -8,8 +8,8 @@ import equal from 'fast-deep-equal'
import type { RefObject } from 'react'
import { useCallback, useEffect, useRef } from 'react'
import useResizeObserver from 'use-resize-observer'
import type { LineMarkerPosition } from '../types'
import type { LineMarkers } from '../replace-components/linemarker/line-number-marker'
import type { LineMarkerPosition } from '../markdown-extension/linemarker/types'
import type { LineMarkers } from '../markdown-extension/linemarker/add-line-marker-markdown-it-plugin'
export const calculateLineMarkerPositions = (
documentElement: HTMLDivElement,

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: AGPL-3.0-only
*/
import type { LineWithId } from '../types'
import type { LineWithId } from '../markdown-extension/linemarker/types'
import type { ArrayChange } from 'diff'
import { diffArrays } from 'diff'

View file

@ -10,8 +10,9 @@ import { convertNodeToReactElement } from '@hedgedoc/html-to-react/dist/convertN
import type { ComponentReplacer, NodeReplacement, ValidReactDomElement } from '../replace-components/component-replacer'
import { DO_NOT_REPLACE, REPLACE_WITH_NOTHING } from '../replace-components/component-replacer'
import React from 'react'
import type { LineWithId } from '../types'
import type { LineWithId } from '../markdown-extension/linemarker/types'
import Optional from 'optional-js'
import { LinemarkerMarkdownExtension } from '../markdown-extension/linemarker/linemarker-markdown-extension'
type LineIndexPair = [startLineIndex: number, endLineIndex: number]
@ -116,7 +117,7 @@ export class NodeToReactTransformer {
* @return the extracted line indexes
*/
private static extractLineIndexFromLineMarker(lineMarker: Node): LineIndexPair | undefined {
if (!isTag(lineMarker) || lineMarker.tagName !== 'app-linemarker' || !lineMarker.attribs) {
if (!isTag(lineMarker) || lineMarker.tagName !== LinemarkerMarkdownExtension.tagName || !lineMarker.attribs) {
return
}
const startLineInMarkdown = lineMarker.attribs['data-start-line']