2016-01-15 10:02:48 -05:00
|
|
|
module Gitlab
|
|
|
|
module Diff
|
2016-07-10 16:10:59 -04:00
|
|
|
class InlineDiffMarker < Gitlab::StringRangeMarker
|
2018-04-03 05:57:31 -04:00
|
|
|
def initialize(line, rich_line = nil)
|
|
|
|
super(line, rich_line || line)
|
|
|
|
end
|
|
|
|
|
2016-07-10 16:10:59 -04:00
|
|
|
def mark(line_inline_diffs, mode: nil)
|
2018-04-03 05:57:31 -04:00
|
|
|
super(line_inline_diffs) do |text, left:, right:|
|
2016-07-10 16:10:59 -04:00
|
|
|
%{<span class="#{html_class_names(left, right, mode)}">#{text}</span>}
|
2016-01-15 10:02:48 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-01-15 10:29:26 -05:00
|
|
|
private
|
|
|
|
|
2016-07-10 16:10:59 -04:00
|
|
|
def html_class_names(left, right, mode)
|
2016-04-06 15:37:09 -04:00
|
|
|
class_names = ["idiff"]
|
2016-07-10 16:10:59 -04:00
|
|
|
class_names << "left" if left
|
|
|
|
class_names << "right" if right
|
2016-04-06 15:37:09 -04:00
|
|
|
class_names << mode if mode
|
|
|
|
class_names.join(" ")
|
|
|
|
end
|
2016-01-15 10:02:48 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|