mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-01 05:02:50 +08:00
Fix smart annotations and links styling
This commit is contained in:
parent
a19e0ef846
commit
e748e1eff3
7 changed files with 16 additions and 9 deletions
|
@ -22,7 +22,8 @@ module Reports::Docx::DrawExperiment
|
||||||
link_style
|
link_style
|
||||||
end
|
end
|
||||||
html = custom_auto_link(experiment.description, team: @report_team)
|
html = custom_auto_link(experiment.description, team: @report_team)
|
||||||
Reports::HtmlToWordConverter.new(@docx).html_to_word_converter(html)
|
Reports::HtmlToWordConverter.new(@docx, { scinote_url: scinote_url,
|
||||||
|
link_style: link_style }).html_to_word_converter(html)
|
||||||
@docx.p
|
@docx.p
|
||||||
subject['children'].each do |child|
|
subject['children'].each do |child|
|
||||||
public_send("draw_#{child['type_of']}", child, experiment)
|
public_send("draw_#{child['type_of']}", child, experiment)
|
||||||
|
|
|
@ -66,7 +66,8 @@ module Reports::Docx::DrawMyModule
|
||||||
|
|
||||||
if my_module.description.present?
|
if my_module.description.present?
|
||||||
html = custom_auto_link(my_module.description, team: @report_team)
|
html = custom_auto_link(my_module.description, team: @report_team)
|
||||||
Reports::HtmlToWordConverter.new(@docx).html_to_word_converter(html)
|
Reports::HtmlToWordConverter.new(@docx, { scinote_url: scinote_url,
|
||||||
|
link_style: link_style }).html_to_word_converter(html)
|
||||||
else
|
else
|
||||||
@docx.p I18n.t('projects.reports.elements.module.no_description')
|
@docx.p I18n.t('projects.reports.elements.module.no_description')
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,7 +17,8 @@ module Reports::Docx::DrawResultComments
|
||||||
date: I18n.l(comment_ts, format: :full_date),
|
date: I18n.l(comment_ts, format: :full_date),
|
||||||
time: I18n.l(comment_ts, format: :time)), italic: true
|
time: I18n.l(comment_ts, format: :time)), italic: true
|
||||||
html = custom_auto_link(comment.message, team: @report_team)
|
html = custom_auto_link(comment.message, team: @report_team)
|
||||||
Reports::HtmlToWordConverter.new(@docx).html_to_word_converter(html)
|
Reports::HtmlToWordConverter.new(@docx, { scinote_url: @scinote_url,
|
||||||
|
link_style: @link_style }).html_to_word_converter(html)
|
||||||
@docx.p
|
@docx.p
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,7 +17,8 @@ module Reports::Docx::DrawResultText
|
||||||
timestamp: I18n.l(timestamp, format: :full), user: result.user.full_name), color: color[:gray]
|
timestamp: I18n.l(timestamp, format: :full), user: result.user.full_name), color: color[:gray]
|
||||||
end
|
end
|
||||||
html = custom_auto_link(result_text.text, team: @report_team)
|
html = custom_auto_link(result_text.text, team: @report_team)
|
||||||
Reports::HtmlToWordConverter.new(@docx).html_to_word_converter(html)
|
Reports::HtmlToWordConverter.new(@docx, { scinote_url: @scinote_url,
|
||||||
|
link_style: @link_style }).html_to_word_converter(html)
|
||||||
|
|
||||||
subject['children'].each do |child|
|
subject['children'].each do |child|
|
||||||
public_send("draw_#{child['type_of']}", child, result)
|
public_send("draw_#{child['type_of']}", child, result)
|
||||||
|
|
|
@ -27,7 +27,8 @@ module Reports::Docx::DrawStep
|
||||||
end
|
end
|
||||||
if step.description.present?
|
if step.description.present?
|
||||||
html = custom_auto_link(step.description, team: @report_team)
|
html = custom_auto_link(step.description, team: @report_team)
|
||||||
Reports::HtmlToWordConverter.new(@docx).html_to_word_converter(html)
|
Reports::HtmlToWordConverter.new(@docx, { scinote_url: @scinote_url,
|
||||||
|
link_style: @link_style }).html_to_word_converter(html)
|
||||||
else
|
else
|
||||||
@docx.p I18n.t 'projects.reports.elements.step.no_description'
|
@docx.p I18n.t 'projects.reports.elements.step.no_description'
|
||||||
end
|
end
|
||||||
|
|
|
@ -17,7 +17,8 @@ module Reports::Docx::DrawStepComments
|
||||||
date: I18n.l(comment_ts, format: :full_date),
|
date: I18n.l(comment_ts, format: :full_date),
|
||||||
time: I18n.l(comment_ts, format: :time)), italic: true
|
time: I18n.l(comment_ts, format: :time)), italic: true
|
||||||
html = custom_auto_link(comment.message, team: @report_team)
|
html = custom_auto_link(comment.message, team: @report_team)
|
||||||
Reports::HtmlToWordConverter.new(@docx).html_to_word_converter(html)
|
Reports::HtmlToWordConverter.new(@docx, { scinote_url: @scinote_url,
|
||||||
|
link_style: @link_style }).html_to_word_converter(html)
|
||||||
@docx.p
|
@docx.p
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,13 +2,15 @@
|
||||||
|
|
||||||
module Reports
|
module Reports
|
||||||
class HtmlToWordConverter
|
class HtmlToWordConverter
|
||||||
def initialize(document)
|
def initialize(document, options = {})
|
||||||
@docx = document
|
@docx = document
|
||||||
|
@scinote_url = options[:scinote_url]
|
||||||
|
@link_style = options[:link_style]
|
||||||
end
|
end
|
||||||
|
|
||||||
def html_to_word_converter(text)
|
def html_to_word_converter(text)
|
||||||
html = Nokogiri::HTML(text)
|
html = Nokogiri::HTML(text)
|
||||||
raw_elements = recursive_children(html.css('body').children, [])
|
raw_elements = recursive_children(html.css('body').children, []).compact
|
||||||
|
|
||||||
# Combined raw text blocks in paragraphs
|
# Combined raw text blocks in paragraphs
|
||||||
elements = combine_docx_elements(raw_elements)
|
elements = combine_docx_elements(raw_elements)
|
||||||
|
@ -106,7 +108,6 @@ module Reports
|
||||||
elements.push(list_element(elem))
|
elements.push(list_element(elem))
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
elements = recursive_children(elem.children, elements) if elem.children
|
elements = recursive_children(elem.children, elements) if elem.children
|
||||||
end
|
end
|
||||||
elements
|
elements
|
||||||
|
|
Loading…
Reference in a new issue