import type * as Diff2Html from 'diff2html'
// import { Diff2HtmlUI } from 'diff2html/lib-esm/ui/js/diff2html-ui'
import HoganJsUtils from 'diff2html/lib/hoganjs-utils'
// import type { DiffLine } from 'diff2html/lib/types'
import type { CommentItem } from 'components/CommentBox/CommentBox'
import type { TypesPullReqActivity } from 'services/code'
import type { DiffFileEntry } from 'utils/types'
export enum ViewStyle {
SIDE_BY_SIDE = 'side-by-side',
LINE_BY_LINE = 'line-by-line'
}
export enum CommentType {
COMMENT = 'comment',
CODE_COMMENT = 'code-comment',
TITLE_CHANGE = 'title-change',
REVIEW_SUBMIT = 'review-submit',
MERGE = 'merge'
}
export const PR_CODE_COMMENT_PAYLOAD_VERSION = '0.1'
export interface PullRequestCodeCommentPayload {
type: CommentType
version: string // used to avoid rendering old payload structure
file_id: string // unique id of the changed file
file_title: string
language: string
is_on_left: boolean // comment made on the left side pane
at_line_number: number
line_number_range: number[]
range_text_content: string // raw text content where the comment is made
diff_html_snapshot: string // snapshot used to render diff in comment (PR Conversation). Could be used to send email notification too (with more work on capturing CSS styles and put them inline)
}
export const DIFF_VIEWER_HEADER_HEIGHT = 36
// const DIFF_MAX_CHANGES = 100
// const DIFF_MAX_LINE_LENGTH = 100
export interface DiffCommentItem {
left: boolean
right: boolean
lineNumber: number
height: number
commentItems: CommentItem[]
}
export const DIFF2HTML_CONFIG = {
outputFormat: 'side-by-side',
drawFileList: false,
fileListStartVisible: false,
fileContentToggle: true,
// diffMaxChanges: DIFF_MAX_CHANGES,
// diffMaxLineLength: DIFF_MAX_LINE_LENGTH,
// diffTooBigMessage: index => `${index} - is too big`,
matching: 'lines',
synchronisedScroll: true,
highlight: true,
renderNothingWhenEmpty: false,
compiledTemplates: {
'generic-line': HoganJsUtils.compile(`