Get rid of global.mermaid_config
This commit is contained in:
parent
048b39ae16
commit
7c970d6ff0
|
@ -730,8 +730,6 @@ describe('when rendering a sequenceDiagram', function () {
|
||||||
parser.yy = sequenceDb
|
parser.yy = sequenceDb
|
||||||
parser.yy.clear()
|
parser.yy.clear()
|
||||||
|
|
||||||
delete global.mermaid_config
|
|
||||||
|
|
||||||
NewD3 = function () {
|
NewD3 = function () {
|
||||||
const o = {
|
const o = {
|
||||||
append: function () {
|
append: function () {
|
||||||
|
|
|
@ -66,9 +66,6 @@ const init = function () {
|
||||||
: nodes instanceof window.Node ? [nodes]
|
: nodes instanceof window.Node ? [nodes]
|
||||||
: nodes // Last case - sequence config was passed pick next
|
: nodes // Last case - sequence config was passed pick next
|
||||||
|
|
||||||
if (typeof global.mermaid_config !== 'undefined') {
|
|
||||||
mermaidAPI.initialize(global.mermaid_config)
|
|
||||||
}
|
|
||||||
logger.debug('Start On Load before: ' + mermaid.startOnLoad)
|
logger.debug('Start On Load before: ' + mermaid.startOnLoad)
|
||||||
if (typeof mermaid.startOnLoad !== 'undefined') {
|
if (typeof mermaid.startOnLoad !== 'undefined') {
|
||||||
logger.debug('Start On Load inner: ' + mermaid.startOnLoad)
|
logger.debug('Start On Load inner: ' + mermaid.startOnLoad)
|
||||||
|
@ -133,26 +130,12 @@ const initialize = function (config) {
|
||||||
*/
|
*/
|
||||||
const contentLoaded = function () {
|
const contentLoaded = function () {
|
||||||
let config
|
let config
|
||||||
// Check state of start config mermaid namespace
|
|
||||||
if (typeof global.mermaid_config !== 'undefined') {
|
|
||||||
if (global.mermaid_config.htmlLabels === false) {
|
|
||||||
mermaid.htmlLabels = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mermaid.startOnLoad) {
|
if (mermaid.startOnLoad) {
|
||||||
// For backwards compatability reasons also check mermaid_config variable
|
// No config found, do check API config
|
||||||
if (typeof global.mermaid_config !== 'undefined') {
|
config = mermaidAPI.getConfig()
|
||||||
// Check if property startOnLoad is set
|
if (config.startOnLoad) {
|
||||||
if (global.mermaid_config.startOnLoad === true) {
|
mermaid.init()
|
||||||
mermaid.init()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// No config found, do check API config
|
|
||||||
config = mermaidAPI.getConfig()
|
|
||||||
if (config.startOnLoad) {
|
|
||||||
mermaid.init()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (typeof mermaid.startOnLoad === 'undefined') {
|
if (typeof mermaid.startOnLoad === 'undefined') {
|
||||||
|
|
|
@ -6,19 +6,8 @@ import flowRenderer from './diagrams/flowchart/flowRenderer'
|
||||||
|
|
||||||
describe('when using mermaid and ', function () {
|
describe('when using mermaid and ', function () {
|
||||||
describe('when detecting chart type ', function () {
|
describe('when detecting chart type ', function () {
|
||||||
it('should not start rendering with mermaid_config.startOnLoad set to false', function () {
|
|
||||||
global.mermaid_config = { startOnLoad: false }
|
|
||||||
|
|
||||||
document.body.innerHTML = '<div class="mermaid">graph TD;\na;</div>'
|
|
||||||
spyOn(mermaid, 'init')
|
|
||||||
mermaid.contentLoaded()
|
|
||||||
expect(mermaid.init).not.toHaveBeenCalled()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('should not start rendering with mermaid.startOnLoad set to false', function () {
|
it('should not start rendering with mermaid.startOnLoad set to false', function () {
|
||||||
mermaid.startOnLoad = false
|
mermaid.startOnLoad = false
|
||||||
global.mermaid_config = { startOnLoad: true }
|
|
||||||
|
|
||||||
document.body.innerHTML = '<div class="mermaid">graph TD;\na;</div>'
|
document.body.innerHTML = '<div class="mermaid">graph TD;\na;</div>'
|
||||||
spyOn(mermaid, 'init')
|
spyOn(mermaid, 'init')
|
||||||
mermaid.contentLoaded()
|
mermaid.contentLoaded()
|
||||||
|
@ -27,14 +16,13 @@ describe('when using mermaid and ', function () {
|
||||||
|
|
||||||
it('should start rendering with both startOnLoad set', function () {
|
it('should start rendering with both startOnLoad set', function () {
|
||||||
mermaid.startOnLoad = true
|
mermaid.startOnLoad = true
|
||||||
global.mermaid_config = { startOnLoad: true }
|
|
||||||
document.body.innerHTML = '<div class="mermaid">graph TD;\na;</div>'
|
document.body.innerHTML = '<div class="mermaid">graph TD;\na;</div>'
|
||||||
spyOn(mermaid, 'init')
|
spyOn(mermaid, 'init')
|
||||||
mermaid.contentLoaded()
|
mermaid.contentLoaded()
|
||||||
expect(mermaid.init).toHaveBeenCalled()
|
expect(mermaid.init).toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should start rendering with mermaid.startOnLoad set and no mermaid_config defined', function () {
|
it('should start rendering with mermaid.startOnLoad', function () {
|
||||||
mermaid.startOnLoad = true
|
mermaid.startOnLoad = true
|
||||||
document.body.innerHTML = '<div class="mermaid">graph TD;\na;</div>'
|
document.body.innerHTML = '<div class="mermaid">graph TD;\na;</div>'
|
||||||
spyOn(mermaid, 'init')
|
spyOn(mermaid, 'init')
|
||||||
|
@ -52,7 +40,6 @@ describe('when using mermaid and ', function () {
|
||||||
|
|
||||||
describe('when calling addEdges ', function () {
|
describe('when calling addEdges ', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
global.mermaid_config = { startOnLoad: false }
|
|
||||||
flowParser.parser.yy = graphDb
|
flowParser.parser.yy = graphDb
|
||||||
graphDb.clear()
|
graphDb.clear()
|
||||||
})
|
})
|
||||||
|
|
|
@ -4,7 +4,6 @@ import mermaidAPI from './mermaidAPI'
|
||||||
describe('when using mermaidAPI and ', function () {
|
describe('when using mermaidAPI and ', function () {
|
||||||
describe('doing initialize ', function () {
|
describe('doing initialize ', function () {
|
||||||
beforeEach(function () {
|
beforeEach(function () {
|
||||||
delete global.mermaid_config
|
|
||||||
document.body.innerHTML = ''
|
document.body.innerHTML = ''
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
1
todo.md
1
todo.md
|
@ -1,6 +1,5 @@
|
||||||
- Get familar with jison
|
- Get familar with jison
|
||||||
- git graph requires a blank line at the end. why?
|
- git graph requires a blank line at the end. why?
|
||||||
- global.mermaid_config
|
|
||||||
- rewrite logger
|
- rewrite logger
|
||||||
- rewrite less code
|
- rewrite less code
|
||||||
- Setup code coverage
|
- Setup code coverage
|
||||||
|
|
Loading…
Reference in New Issue