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