-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa9bf8e
commit b0de118
Showing
12 changed files
with
246 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module.exports = { | ||
extends: [require.resolve("project-tool/baseLint"), require.resolve("project-tool/reactLint")], | ||
env: { | ||
browser: true, | ||
es2021: true, | ||
}, | ||
parserOptions: { | ||
ecmaFeatures: { | ||
jsx: true, | ||
}, | ||
sourceType: "module", | ||
tsconfigRootDir: __dirname, | ||
project: "./tsconfig.json", | ||
}, | ||
rules: { | ||
"@typescript-eslint/no-unused-vars": [ | ||
"error", | ||
{ | ||
varsIgnorePattern: "React", | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,48 @@ | ||
import * as React from "react"; | ||
|
||
import { useDiffViewContext, SplitSide } from ".."; | ||
import { useDomWidth } from "../hooks/useDomWidth"; | ||
|
||
import type { DiffFileExtends } from "../utils"; | ||
|
||
export const DiffUnifiedExtendLine = ({ index, diffFile, lineNumber }: { index: number; diffFile: DiffFileExtends; lineNumber: number }) => { | ||
const { enableWrap, extendData, renderExtendLine } = useDiffViewContext(); | ||
const _DiffUnifiedExtendLine = ({ index, diffFile, lineNumber }: { index: number; diffFile: DiffFileExtends; lineNumber: number }) => { | ||
const { extendData, renderExtendLine } = useDiffViewContext(); | ||
|
||
const unifiedItem = diffFile.getUnifiedLine(index); | ||
|
||
const oldExtend = extendData?.oldFile?.[unifiedItem.oldLineNumber]; | ||
|
||
const newExtend = extendData?.newFile?.[unifiedItem.newLineNumber]; | ||
|
||
if ((!oldExtend && !newExtend) || !unifiedItem || unifiedItem.isHidden || !unifiedItem.diff) return null; | ||
const width = useDomWidth({ | ||
selector: ".unified-diff-table-wrapper", | ||
enable: true, | ||
}); | ||
|
||
return ( | ||
<tr data-line={`${lineNumber}-extend`} data-state="extend" className="diff-line diff-line-extend"> | ||
<td className="diff-line-extend-content align-top" style={{ position: enableWrap ? "relative" : "sticky" }} colSpan={4}> | ||
{oldExtend && renderExtendLine({ diffFile, side: SplitSide.old, lineNumber: oldExtend.lineNumber, data: oldExtend.data, onUpdate: diffFile.notifyAll })} | ||
{newExtend && renderExtendLine({ diffFile, side: SplitSide.new, lineNumber: newExtend.lineNumber, data: newExtend.data, onUpdate: diffFile.notifyAll })} | ||
<td className="diff-line-extend-content align-top p-[0]" colSpan={4}> | ||
<div className="diff-line-extend-wrapper sticky left-0" style={{ width }}> | ||
{oldExtend && | ||
renderExtendLine({ diffFile, side: SplitSide.old, lineNumber: oldExtend.lineNumber, data: oldExtend.data, onUpdate: diffFile.notifyAll })} | ||
{newExtend && | ||
renderExtendLine({ diffFile, side: SplitSide.new, lineNumber: newExtend.lineNumber, data: newExtend.data, onUpdate: diffFile.notifyAll })} | ||
</div> | ||
</td> | ||
</tr> | ||
); | ||
}; | ||
|
||
export const DiffUnifiedExtendLine = ({ index, diffFile, lineNumber }: { index: number; diffFile: DiffFileExtends; lineNumber: number }) => { | ||
const { extendData } = useDiffViewContext(); | ||
|
||
const unifiedItem = diffFile.getUnifiedLine(index); | ||
|
||
const oldExtend = extendData?.oldFile?.[unifiedItem.oldLineNumber]; | ||
|
||
const newExtend = extendData?.newFile?.[unifiedItem.newLineNumber]; | ||
|
||
if ((!oldExtend && !newExtend) || !unifiedItem || unifiedItem.isHidden || !unifiedItem.diff) return null; | ||
|
||
return <_DiffUnifiedExtendLine index={index} diffFile={diffFile} lineNumber={lineNumber} />; | ||
}; |
Oops, something went wrong.