mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-24 03:57:06 -04:00
Added synced scrolling (#386)
Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de>
This commit is contained in:
parent
164b5436ae
commit
73007ef597
10 changed files with 413 additions and 38 deletions
25
src/components/editor/scroll/utils.ts
Normal file
25
src/components/editor/scroll/utils.ts
Normal file
|
@ -0,0 +1,25 @@
|
|||
import { LineMarkerPosition } from '../../markdown-renderer/markdown-renderer'
|
||||
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
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue