mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-23 19:47:03 -04:00
![renovate[bot]](/assets/img/avatar_default.png)
* Update dependency eslint-plugin-import to v2.25.2 Signed-off-by: Renovate Bot <bot@renovateapp.com> Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Make type imports more explicit Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> * Enforce use of type imports Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de> Co-authored-by: Renovate Bot <bot@renovateapp.com> Co-authored-by: Tilman Vatteroth <git@tilmanvatteroth.de>
35 lines
858 B
TypeScript
35 lines
858 B
TypeScript
/*
|
|
* SPDX-FileCopyrightText: 2021 The HedgeDoc developers (see AUTHORS file)
|
|
*
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
import type { LineMarkerPosition } from '../../markdown-renderer/types'
|
|
|
|
export const findLineMarks = (
|
|
lineMarks: LineMarkerPosition[],
|
|
lineNumber: number
|
|
): { lastMarkBefore: LineMarkerPosition | undefined; firstMarkAfter: LineMarkerPosition | undefined } => {
|
|
let lastMarkBefore
|
|
let firstMarkAfter
|
|
for (let i = 0; i < lineMarks.length; i++) {
|
|
const currentMark = lineMarks[i]
|
|
if (!currentMark) {
|
|
continue
|
|
}
|
|
|
|
if (currentMark.line <= lineNumber) {
|
|
lastMarkBefore = currentMark
|
|
}
|
|
if (currentMark.line > lineNumber) {
|
|
firstMarkAfter = currentMark
|
|
}
|
|
if (!!firstMarkAfter && !!lastMarkBefore) {
|
|
break
|
|
}
|
|
}
|
|
return {
|
|
lastMarkBefore,
|
|
firstMarkAfter
|
|
}
|
|
}
|