2016-01-15 10:02:48 -05:00
|
|
|
module Gitlab
|
|
|
|
module Diff
|
2016-07-10 16:10:59 -04:00
|
|
|
class InlineDiffMarker < Gitlab::StringRangeMarker
|
|
|
|
def mark(line_inline_diffs, mode: nil)
|
2017-09-12 13:42:40 -04:00
|
|
|
mark = 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
|
2017-09-12 13:42:40 -04:00
|
|
|
mark.html_safe
|
2016-01-15 10:02:48 -05:00
|
|
|
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
|