-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #223 from tfsojon/chandu
Worked on mindmap click support #105
- Loading branch information
Showing
7 changed files
with
164 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,7 @@ <h2 class="mb-4 font-weight-medium mt-5">{{ .Title }}</h2> | |
{{ range .Data.Pages }} | ||
<div | ||
class="offcanvas offcanvas-end fade" | ||
data-bs-scroll="true" | ||
tabindex="-1" | ||
id="{{.Title | urlize}}" | ||
aria-labelledby="{{.Title | urlize}}" | ||
|
@@ -107,8 +108,12 @@ <h4 class="offcanvas-title" id="offcanvasExampleLabel">{{.Title}}</h4> | |
mermaid.initialize({ | ||
startOnLoad: true, | ||
securityLevel: 'loose', | ||
theme: 'forest', | ||
}); | ||
|
||
import zenuml from 'https://cdn.jsdelivr.net/npm/@mermaid-js/[email protected]/dist/mermaid-zenuml.esm.min.mjs'; | ||
await mermaid.registerExternalDiagrams([zenuml]); | ||
|
||
function urlize(str) { | ||
str = str.trim(); | ||
str = str.replace(/\s+/g, '-'); | ||
|
@@ -119,28 +124,71 @@ <h4 class="offcanvas-title" id="offcanvasExampleLabel">{{.Title}}</h4> | |
} | ||
|
||
window.addEventListener('load', (event) => { | ||
const body = document.querySelector('body'); | ||
const contentLoader = document.querySelector('.content-loader'); | ||
const content = document.querySelector('.content'); | ||
contentLoader.remove(); | ||
content.classList.remove('content-hidden'); | ||
|
||
let addDataAttribute = (el, textID) => { | ||
el.setAttribute('type', 'button'); | ||
el.setAttribute('data-roadmap', ''); | ||
el.setAttribute('data-bs-toggle', 'offcanvas'); | ||
el.setAttribute('data-bs-target', '#'+urlize(textID)); | ||
el.setAttribute('aria-controls', urlize(textID)); | ||
} | ||
|
||
setTimeout(function() { | ||
let node = document.querySelectorAll('.mindmap-node:not(.section-root):not(.node)'); | ||
node.forEach(function(el) { | ||
// maindmap | ||
let mindmapNode = document.querySelectorAll('.mindmap-node:not(.section-root):not(.node)'); | ||
mindmapNode.forEach(function(el) { | ||
let innerText = el.querySelectorAll('.text-inner-tspan'); | ||
const textArray = []; | ||
innerText.forEach((text) => { | ||
textArray.push(text.textContent); | ||
}); | ||
const textID = textArray.join(' '); | ||
let id = document.getElementById(urlize(textID)); | ||
if (id) { addDataAttribute(el, textID) } | ||
}); | ||
|
||
// flowchart | ||
let flowchartLabel = document.querySelectorAll('.flowchart-label'); | ||
let flowchartEdgeLabel = document.querySelectorAll('g.edgeLabel'); | ||
let flowchartLabels = [...flowchartLabel, ...flowchartEdgeLabel]; | ||
flowchartLabels.forEach(function(el) { | ||
let nodeLabel = el.querySelectorAll('.nodeLabel'); | ||
let edgeLabel = el.querySelectorAll('.edgeLabel'); | ||
let allLabel = [...nodeLabel, ...edgeLabel]; | ||
const textArray = []; | ||
allLabel.forEach((text) => { | ||
textArray.push(text.textContent); | ||
}); | ||
const textID = textArray.join(' '); | ||
let id = document.getElementById(urlize(textID)); | ||
if (id) { addDataAttribute(el, textID) } | ||
}); | ||
|
||
// C4Context | ||
let personMan = document.querySelectorAll('.person-man'); | ||
let personManLabel = document.querySelectorAll('g.edgeLabel'); | ||
personMan.forEach(function(el) { | ||
|
||
const textArray = []; | ||
let allLabel = el.querySelectorAll('text'); | ||
allLabel.forEach((text) => { | ||
let fontSize = window.getComputedStyle(text).fontSize; | ||
if (fontSize == '16px') { | ||
textArray.push(text.textContent); | ||
} | ||
}); | ||
|
||
el.setAttribute('type', 'button'); | ||
el.setAttribute('data-roadmap', ''); | ||
el.setAttribute('data-bs-toggle', 'offcanvas'); | ||
el.setAttribute('data-bs-target', '#'+urlize(textID)); | ||
el.setAttribute('aria-controls', urlize(textID)); | ||
|
||
const textID = textArray.join(' '); | ||
let id = document.querySelector(`[aria-labelledby="${urlize(textID)}"]`); | ||
if (id) { addDataAttribute(el, textID) } | ||
}); | ||
|
||
|
||
}, 1000); | ||
}); | ||
|
||
|