Commit fd13f8ad authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'fix-mermaid-width' into 'master'

Fix mermaid flowchart width

Closes #199132 and #199423

See merge request gitlab-org/gitlab!26848
parents b79fb2a3 9b873276
...@@ -35,6 +35,7 @@ function renderMermaids($els) { ...@@ -35,6 +35,7 @@ function renderMermaids($els) {
// mermaidAPI options // mermaidAPI options
theme: 'neutral', theme: 'neutral',
flowchart: { flowchart: {
useMaxWidth: true,
htmlLabels: false, htmlLabels: false,
}, },
securityLevel: 'strict', securityLevel: 'strict',
......
---
title: Fix Mermaid flowchart width
merge_request: 26848
author: julien MILLAU
type: fixed
...@@ -94,8 +94,31 @@ describe 'Mermaid rendering', :js do ...@@ -94,8 +94,31 @@ describe 'Mermaid rendering', :js do
page.find('summary').click page.find('summary').click
svg = page.find('svg.mermaid') svg = page.find('svg.mermaid')
expect(svg[:width].to_i).to be_within(5).of(120) expect(svg[:style]).to match(/max-width/)
expect(svg[:height].to_i).to be_within(5).of(220) expect(svg[:width].to_i).to eq(100)
expect(svg[:height].to_i).to eq(0)
end end
end end
it 'correctly sizes mermaid diagram block', :js do
description = <<~MERMAID
```mermaid
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
```
MERMAID
project = create(:project, :public)
issue = create(:issue, project: project, description: description)
visit project_issue_path(project, issue)
svg = page.find('svg.mermaid')
expect(svg[:style]).to match(/max-width/)
expect(svg[:width].to_i).to eq(100)
expect(svg[:height].to_i).to eq(0)
end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment