mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-14 07:04:45 -04:00
Adjust editor config (#976)
* Adjust editor config Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> Co-authored-by: Erik Michelson <github@erik.michelson.eu>
This commit is contained in:
parent
0180c75e55
commit
e12dc523f8
301 changed files with 4393 additions and 3741 deletions
|
@ -13,36 +13,37 @@ import { LineMarkers } from '../replace-components/linemarker/line-number-marker
|
|||
export const calculateLineMarkerPositions = (documentElement: HTMLDivElement, currentLineMarkers: LineMarkers[], offset?: number): LineMarkerPosition[] => {
|
||||
const lineMarkers = currentLineMarkers
|
||||
const children: HTMLCollection = documentElement.children
|
||||
const lineMarkerPositions:LineMarkerPosition[] = []
|
||||
const lineMarkerPositions: LineMarkerPosition[] = []
|
||||
|
||||
Array.from(children).forEach((child, childIndex) => {
|
||||
const htmlChild = (child as HTMLElement)
|
||||
if (htmlChild.offsetTop === undefined) {
|
||||
return
|
||||
}
|
||||
const currentLineMarker = lineMarkers[childIndex]
|
||||
if (currentLineMarker === undefined) {
|
||||
return
|
||||
}
|
||||
Array.from(children)
|
||||
.forEach((child, childIndex) => {
|
||||
const htmlChild = (child as HTMLElement)
|
||||
if (htmlChild.offsetTop === undefined) {
|
||||
return
|
||||
}
|
||||
const currentLineMarker = lineMarkers[childIndex]
|
||||
if (currentLineMarker === undefined) {
|
||||
return
|
||||
}
|
||||
|
||||
const lastPosition = lineMarkerPositions[lineMarkerPositions.length - 1]
|
||||
if (!lastPosition || lastPosition.line !== currentLineMarker.startLine) {
|
||||
lineMarkerPositions.push({
|
||||
line: currentLineMarker.startLine,
|
||||
position: htmlChild.offsetTop + (offset ?? 0)
|
||||
})
|
||||
}
|
||||
const lastPosition = lineMarkerPositions[lineMarkerPositions.length - 1]
|
||||
if (!lastPosition || lastPosition.line !== currentLineMarker.startLine) {
|
||||
lineMarkerPositions.push({
|
||||
line: currentLineMarker.startLine,
|
||||
position: htmlChild.offsetTop + (offset ?? 0)
|
||||
})
|
||||
}
|
||||
|
||||
lineMarkerPositions.push({
|
||||
line: currentLineMarker.endLine,
|
||||
position: htmlChild.offsetTop + htmlChild.offsetHeight + (offset ?? 0)
|
||||
})
|
||||
})
|
||||
lineMarkerPositions.push({
|
||||
line: currentLineMarker.endLine,
|
||||
position: htmlChild.offsetTop + htmlChild.offsetHeight + (offset ?? 0)
|
||||
})
|
||||
})
|
||||
|
||||
return lineMarkerPositions
|
||||
}
|
||||
|
||||
export const useCalculateLineMarkerPosition = (documentElement: RefObject<HTMLDivElement>, lineMarkers?: LineMarkers[], onLineMarkerPositionChanged?: (lineMarkerPosition: LineMarkerPosition[]) => void, offset?: number) : void => {
|
||||
export const useCalculateLineMarkerPosition = (documentElement: RefObject<HTMLDivElement>, lineMarkers?: LineMarkers[], onLineMarkerPositionChanged?: (lineMarkerPosition: LineMarkerPosition[]) => void, offset?: number): void => {
|
||||
const lastLineMarkerPositions = useRef<LineMarkerPosition[]>()
|
||||
|
||||
const calculateNewLineMarkerPositions = useCallback(() => {
|
||||
|
|
|
@ -42,7 +42,7 @@ export const calculateKeyFromLineMarker = (node: DomElement, lineKeys?: LineKeys
|
|||
return
|
||||
}
|
||||
|
||||
return `${lineKeys[startLine].id}_${lineKeys[endLine].id}`
|
||||
return `${ lineKeys[startLine].id }_${ lineKeys[endLine].id }`
|
||||
}
|
||||
|
||||
export const findNodeReplacement = (node: DomElement, key: string, allReplacers: ComponentReplacer[], subNodeTransform: SubNodeTransform, nativeRenderer: NativeRenderer): ReactElement | null | undefined => {
|
||||
|
@ -72,8 +72,8 @@ export const buildTransformer = (lineKeys: (LineKeys[] | undefined), allReplacer
|
|||
} else if (tryReplacement === undefined) {
|
||||
return nativeRenderer()
|
||||
} else {
|
||||
return <Suspense key={key} fallback={<span>Loading...</span>}>
|
||||
{tryReplacement}
|
||||
return <Suspense key={ key } fallback={ <span>Loading...</span> }>
|
||||
{ tryReplacement }
|
||||
</Suspense>
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import { LineKeys } from '../types'
|
|||
|
||||
export const calculateNewLineNumberMapping = (newMarkdownLines: string[], oldLineKeys: LineKeys[], lastUsedLineId: number): TextDifferenceResult => {
|
||||
const lineDifferences = diffArrays<string, LineKeys>(newMarkdownLines, oldLineKeys, {
|
||||
comparator: (left:string|LineKeys, right:string|LineKeys) => {
|
||||
comparator: (left: string | LineKeys, right: string | LineKeys) => {
|
||||
const leftLine = (left as LineKeys).line ?? (left as string)
|
||||
const rightLine = (right as LineKeys).line ?? (right as string)
|
||||
return leftLine === rightLine
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue