MMOframework
Why AI Playground Libraries Documentation Search Agency
FR EN
Index

DiffView

MMO.git · 1 symbol · generated 27 Oct 2026

class

DiffView

DiffView.js:21

One file of a diff, drawn: side by side (the old version on the left, the new one on the right) or unified, each side with its line numbers, the removals on red and the insertions on green, the words that changed inside a line darker, the code in its colours. The unchanged lines the hunks leave out are folded, and unfold on a click when the file's texts are there. Over several commits, each changed line has the colour of the commit that made the change in its gutter (commit of DiffController's lines), its subject on hover.

class MMO.git.DiffView
Namespace
MMO.git
It draws a table of the classes `<mmo-diff>` styles: `.diff`, `tr.fold`, `td.ln`, `td.cm`, `td.code`, `.add`, `.del`, `.none`, `mark`, and Prism's `.token`.
const view = new MMO.git.DiffView({file, oldText, newText, commits}); container.appendChild(await view.render()); view.layout = 'unified'; view.redraw();

Index

constructor(options)
render() asyncColour the texts, then draw.
redraw()Draw again, in the current layout.
focus(hash)Fade the changes of the other commits.
table()[internal] @return {HTMLElement} the file's table, or what it has instead of lines
splitRows(lines)[internal] removals paired with the additions after them, side by side
pair(left, right, kind)[internal] one row of the split layout: a line on each side, or none
unifiedRows(lines)[internal] the lines one after the other, two numbers in the gutter
single(line, ranges)[internal] one row of the unified layout
tag(row, lines)[internal] the commits of a row's lines, for focus
mark(line, cls, sep)[internal] the gutter's mark of the commit that made a change
number(n, cls, sep)[internal] a line number
code(line, side, cls, ranges)[internal] a line's code, coloured, its changed words marked
fold(oldFrom, oldTo, newFrom, context, end)[internal] the unchanged lines between two hunks, folded: they unfold on a click when the texts are there
unfolded(oldFrom, oldTo, newFrom)[internal] the rows of unchanged lines a fold held
submodule()[internal] a submodule: the commits it pointed to
message(text)[internal] what a file without lines shows

Methods17

constructor(options)

DiffView.js:31
constructor(options = {})
options = {}Object- file {Object} a DiffController file: {status, path, oldPath, newPath, binary, submodule, hunks, ...} - oldText {?string} the whole old file, to colour it and unfold what the hunks leave out - newText {?string} the whole new file - commits {Array<Object>} the commits of the range, in the order of their colours: {hash, short, subject} - layout {string} split or unified - language {?string} Prism's; none: from the file's name

render()

asyncDiffView.js:46

Colour the texts, then draw.

async render()
returnsPromise<HTMLElement>node

focus(hash)

DiffView.js:65

Fade the changes of the other commits.

focus(hash)
hash?stringa commit's; null: show them all alike

table()

DiffView.js:76

[internal] @return {HTMLElement} the file's table, or what it has instead of lines

table()

splitRows(lines)

DiffView.js:111

[internal] removals paired with the additions after them, side by side

splitRows(lines)
lines

pair(left, right, kind)

DiffView.js:124

[internal] one row of the split layout: a line on each side, or none

pair(left, right, kind)
left
right
kind

unifiedRows(lines)

DiffView.js:137

[internal] the lines one after the other, two numbers in the gutter

unifiedRows(lines)
lines

single(line, ranges)

DiffView.js:152

[internal] one row of the unified layout

single(line, ranges)
line
ranges

tag(row, lines)

DiffView.js:162

[internal] the commits of a row's lines, for focus

tag(row, lines)
row
lines

mark(line, cls, sep)

DiffView.js:168

[internal] the gutter's mark of the commit that made a change

mark(line, cls, sep = false)
line
cls
sep = false

number(n, cls, sep)

DiffView.js:180

[internal] a line number

number(n, cls, sep = false)
n
cls
sep = false

code(line, side, cls, ranges)

DiffView.js:185

[internal] a line's code, coloured, its changed words marked

code(line, side, cls, ranges)
line
side
cls
ranges

fold(oldFrom, oldTo, newFrom, context, end)

DiffView.js:197

[internal] the unchanged lines between two hunks, folded: they unfold on a click when the texts are there

fold(oldFrom, oldTo, newFrom, context, end = false)
oldFrom
oldTo
newFrom
context
end = false

unfolded(oldFrom, oldTo, newFrom)

DiffView.js:215

[internal] the rows of unchanged lines a fold held

unfolded(oldFrom, oldTo, newFrom)
oldFrom
oldTo
newFrom

submodule()

DiffView.js:226

[internal] a submodule: the commits it pointed to

submodule()

message(text)

DiffView.js:233

[internal] what a file without lines shows

message(text)
text