mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-10 02:49:40 +02:00
Add new parameter to the console client to override the svg configuration in sequence diagrams
This commit is contained in:
@@ -29,12 +29,13 @@ var system = require('system')
|
||||
, webpage = require('webpage')
|
||||
|
||||
var page = webpage.create()
|
||||
, files = phantom.args.slice(4, phantom.args.length)
|
||||
, files = phantom.args.slice(5, phantom.args.length)
|
||||
, options = {
|
||||
outputDir: phantom.args[0]
|
||||
, png: phantom.args[1] === 'true' ? true : false
|
||||
, svg: phantom.args[2] === 'true' ? true : false
|
||||
, verbose: phantom.args[3] === 'true' ? true : false
|
||||
, sequenceConfig: phantom.args[3]
|
||||
, verbose: phantom.args[4] === 'true' ? true : false
|
||||
}
|
||||
, log = logger(options.verbose)
|
||||
|
||||
@@ -51,7 +52,9 @@ page.content = [
|
||||
].join('\n')
|
||||
|
||||
page.injectJs('../dist/mermaid.full.js')
|
||||
|
||||
page.onConsoleMessage = function(msg, lineNum, sourceId) {
|
||||
console.log('CONSOLE: ' + msg + ' (from line #' + lineNum + ' in "' + sourceId + '")');
|
||||
};
|
||||
files.forEach(function(file) {
|
||||
var contents = fs.read(file)
|
||||
, filename = file.split(fs.separator).slice(-1)
|
||||
@@ -63,7 +66,10 @@ files.forEach(function(file) {
|
||||
// this JS is executed in this statement is sandboxed, even though it doesn't
|
||||
// look like it. we need to serialize then unserialize the svgContent that's
|
||||
// taken from the DOM
|
||||
svgContent = page.evaluate(executeInPage, contents)
|
||||
svgContent = page.evaluate(executeInPage, {
|
||||
contents: contents,
|
||||
sequenceConfig: options.sequenceConfig
|
||||
})
|
||||
oDOM = oParser.parseFromString(svgContent, "text/xml")
|
||||
|
||||
resolveSVGElement(oDOM.firstChild)
|
||||
@@ -182,8 +188,10 @@ function resolveForeignObjects(element) {
|
||||
}
|
||||
|
||||
// The sandboxed function that's executed in-page by phantom
|
||||
function executeInPage(contents) {
|
||||
function executeInPage(data) {
|
||||
var xmlSerializer = new XMLSerializer()
|
||||
, contents = data.contents
|
||||
, sequenceConfig = data.sequenceConfig
|
||||
, toRemove
|
||||
, el
|
||||
, elContent
|
||||
@@ -204,7 +212,7 @@ function executeInPage(contents) {
|
||||
|
||||
document.body.appendChild(el)
|
||||
|
||||
mermaid.init()
|
||||
mermaid.init(sequenceConfig)
|
||||
|
||||
svg = document.querySelector('svg')
|
||||
svgValue = xmlSerializer.serializeToString(svg)
|
||||
|
Reference in New Issue
Block a user