Skip to content
OGE logoOGE

Diff Viewer API

Full surface of oge-diff-viewer: its inputs, methods and output, the comparison model and the config provider.

Properties Methods Events Types

OgeDiffViewer

oge-diff-viewer

Properties 9

Name Type DefaultDescription
oldValue / newValueunknown''The two sides: texts, or with language="json" JSON text or values.
language'text' | 'json''text'language="json" parses JSON text (or takes values) and compares canonical, two-space text with keys sorted (sortKeys), so key order is never a change; diff().changes lists the changed paths ($.items[2].price). A side that is not JSON shows the invalidJson message.
mode'split' | 'inline' (model)'split'Two-way: side by side, or one column with removed lines above the added ones.
contextnumber | undefinedconfig ?? 3Unchanged lines kept around each change; Infinity folds nothing.
ignoreWhitespace / ignoreCasebooleanfalseLines differing only in whitespace, or only in letter case, count as equal.
wordDiffbooleantrueHighlight the changed words inside changed lines.
sortKeysbooleantrueJSON: sort object keys before comparing.
toolbarbooleantrueThe added / removed counts, the layout switch and previous / next change (announced politely).
messagesPartial<OgeDiffViewerMessages>—Per-instance overrides of the config catalog.

Methods 2

Name Type Description
nextChange() / previousChange()() => voidScrolls to the next or previous change (wrapping) and announces “Change 2 of 5”.
diff()() => OgeDiffModelWhat the viewer shows: { rows, stats: { added, removed, changes }, changes, error } — a signal in Angular.

Events 1

Name Type Description
modeChange'split' | 'inline'The banana half of [(mode)].

Types 9

How it compares

Name Type Description
Lines and wordsMyers O(ND)A Myers line diff (the shortest edit script); within a changed pair of lines the changed words are highlighted. Unchanged runs fold to context lines around each change and open on a click. Every changed line carries a visually hidden “Added” / “Removed” for screen readers — the colour is never the only signal — and the scroll area takes focus for keyboard scrolling.

Vocabulary

Name Type Description
OgeDiffModel{ rows; stats; changes; error }What diff() returns.
OgeDiffRow{ kind: 'line'; old; new; change } | { kind: 'fold'; count; oldLine; newLine }A drawn row: a line (a cell per side, with its word segments), or folded unchanged lines.
OgeJsonChange{ path; kind: 'added' | 'removed' | 'changed'; before?; after? }One changed path of two JSON values.
OgeDiffLanguage'text' | 'json'What the viewer compares.
ogeDiffModel / ogeJsonChangesfunctions (@oge-ui/behavior, re-exported)The model without a view (servers, tests, a change log), and the changed paths of two JSON values.

Behavior building blocks (@oge-ui/behavior)

Name Type Description
ogeDiffLines / ogeDiffWords / ogeDiffSplitLines / OgeDiffOp / OgeDiffOptionsfunctionsThe line diff (runs of equal, deleted and inserted lines), the word diff, the line splitter (any newline style).
ogeDiffRows / OgeDiffRowOptions / OgeDiffCell / OgeDiffSegmentfunctionsThe rows a split or inline view draws, folds and word highlights included.
ogeDiffStats / ogeJsonDiffText / ogeParseJsonfunctionsCounts of added, removed and changed; canonical JSON text; JSON parsing with the error message.

Configuration

Properties 2

provideOgeDiffViewerConfig()

Name Type Description
messagesOgeDiffViewerMessagesEvery user-facing string: label, oldLabel / newLabel (the column headings), split, inline, previousChange, nextChange, expand (an ICU plural over {count}), stats, changePosition ({index} / {count}), noChanges, invalidJson ({side}, {error}), added and removed. Translated in every @oge-ui/locales pack (layout.diffViewer).
contextnumber | undefinedDefault unchanged lines around a change. Pass a function for a live config.

Types 8

Name Type Description
provideOgeDiffViewerConfig(config: OgeDiffViewerConfigInput | (() => OgeDiffViewerConfigInput)) => ProviderApplication- or component-scoped defaults; a function makes the config live.
OGE_DIFF_VIEWER_CONFIGInjectionToken<OgeDiffViewerConfig>The resolved config the viewer injects.
OGE_DEFAULT_DIFF_VIEWER_CONFIGOgeDiffViewerConfigThe defaults (from @oge-ui/behavior).
OGE_DEFAULT_DIFF_VIEWER_MESSAGESOgeDiffViewerMessagesThe English catalog.
resolveOgeDiffViewerConfig(input?, base?) => OgeDiffViewerConfigMerges a partial config over a base (the defaults).
OgeDiffViewerConfig{ messages: OgeDiffViewerMessages; context? }Resolved config shape.
OgeDiffViewerConfigInputPartial<OgeDiffViewerConfig> with partial messagesWhat the provider accepts.
OgeDiffViewerMessages{ label; oldLabel; newLabel; split; inline; previousChange; nextChange; expand; stats; changePosition; noChanges; invalidJson; added; removed }The diff viewer catalog.