Allow overriding sequence diagram configuration (SVG properties) - handling of non existent configuration

This commit is contained in:
knsv 2015-01-14 19:10:39 +01:00
parent 8e050d4223
commit 48500652b3
7 changed files with 1256 additions and 101 deletions

659
dist/mermaid.full.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

649
dist/mermaid.slim.js vendored
View File

@ -293,7 +293,7 @@ function createNodes(selection, g, shapes) {
labelGroup = thisGroup.append("g").attr("class", "label"),
labelDom = addLabel(labelGroup, node),
shape = shapes[node.shape],
bbox = _.pick(labelDom.node().getBBox(), "width", "height");
bbox = labelDom.node().getBBox();
node.elem = this;
@ -363,7 +363,7 @@ if (!graphlib) {
module.exports = graphlib;
},{"graphlib":57}],10:[function(require,module,exports){
},{"graphlib":77}],10:[function(require,module,exports){
module.exports = {
node: require("./intersect-node"),
circle: require("./intersect-circle"),
@ -712,7 +712,7 @@ if (!lodash) {
module.exports = lodash;
},{"lodash":81}],21:[function(require,module,exports){
},{"lodash":101}],21:[function(require,module,exports){
"use strict";
var util = require("./util"),
@ -1041,7 +1041,7 @@ function applyTransition(selection, g) {
}
},{"./lodash":20}],26:[function(require,module,exports){
module.exports = "0.3.3";
module.exports = "0.3.2";
},{}],27:[function(require,module,exports){
/*
@ -1873,7 +1873,7 @@ function canonicalize(attrs) {
},{"./acyclic":28,"./add-border-segments":29,"./coordinate-system":30,"./graphlib":33,"./lodash":36,"./nesting-graph":37,"./normalize":38,"./order":43,"./parent-dummy-chains":48,"./position":50,"./rank":52,"./util":55}],36:[function(require,module,exports){
module.exports=require(20)
},{"lodash":81}],37:[function(require,module,exports){
},{"lodash":101}],37:[function(require,module,exports){
var _ = require("./lodash"),
util = require("./util");
@ -5046,12 +5046,512 @@ function read(json) {
},{"./graph":72,"./lodash":75}],75:[function(require,module,exports){
module.exports=require(20)
},{"lodash":81}],76:[function(require,module,exports){
},{"lodash":101}],76:[function(require,module,exports){
module.exports = '1.0.1';
},{}],77:[function(require,module,exports){
arguments[4][57][0].apply(exports,arguments)
},{"./lib":93,"./lib/alg":84,"./lib/json":94}],78:[function(require,module,exports){
module.exports=require(58)
},{"../lodash":95}],79:[function(require,module,exports){
module.exports=require(59)
},{"../lodash":95}],80:[function(require,module,exports){
module.exports=require(60)
},{"../lodash":95,"./dijkstra":81}],81:[function(require,module,exports){
module.exports=require(61)
},{"../data/priority-queue":91,"../lodash":95}],82:[function(require,module,exports){
module.exports=require(62)
},{"../lodash":95,"./tarjan":89}],83:[function(require,module,exports){
module.exports=require(63)
},{"../lodash":95}],84:[function(require,module,exports){
arguments[4][64][0].apply(exports,arguments)
},{"./components":78,"./dijkstra":81,"./dijkstra-all":80,"./find-cycles":82,"./floyd-warshall":83,"./is-acyclic":85,"./postorder":86,"./preorder":87,"./prim":88,"./tarjan":89,"./topsort":90}],85:[function(require,module,exports){
module.exports=require(65)
},{"./topsort":90}],86:[function(require,module,exports){
module.exports=require(66)
},{"./dfs":79}],87:[function(require,module,exports){
module.exports=require(67)
},{"./dfs":79}],88:[function(require,module,exports){
arguments[4][68][0].apply(exports,arguments)
},{"../data/priority-queue":91,"../graph":92,"../lodash":95}],89:[function(require,module,exports){
module.exports=require(69)
},{"../lodash":95}],90:[function(require,module,exports){
module.exports=require(70)
},{"../lodash":95}],91:[function(require,module,exports){
module.exports=require(71)
},{"../lodash":95}],92:[function(require,module,exports){
"use strict";
},{}],78:[function(require,module,exports){
var _ = require("./lodash");
module.exports = Graph;
var DEFAULT_EDGE_NAME = "\x00",
GRAPH_NODE = "\x00",
EDGE_KEY_DELIM = "\x01";
// Implementation notes:
//
// * Node id query functions should return string ids for the nodes
// * Edge id query functions should return an "edgeObj", edge object, that is
// composed of enough information to uniquely identify an edge: {v, w, name}.
// * Internally we use an "edgeId", a stringified form of the edgeObj, to
// reference edges. This is because we need a performant way to look these
// edges up and, object properties, which have string keys, are the closest
// we're going to get to a performant hashtable in JavaScript.
function Graph(opts) {
this._isDirected = _.has(opts, "directed") ? opts.directed : true;
this._isMultigraph = _.has(opts, "multigraph") ? opts.multigraph : false;
this._isCompound = _.has(opts, "compound") ? opts.compound : false;
// Label for the graph itself
this._label = undefined;
// Defaults to be set when creating a new node
this._defaultNodeLabelFn = _.constant(undefined);
// Defaults to be set when creating a new edge
this._defaultEdgeLabelFn = _.constant(undefined);
// v -> label
this._nodes = {};
if (this._isCompound) {
// v -> parent
this._parent = {};
// v -> children
this._children = {};
this._children[GRAPH_NODE] = {};
}
// v -> edgeObj
this._in = {};
// u -> v -> Number
this._preds = {};
// v -> edgeObj
this._out = {};
// v -> w -> Number
this._sucs = {};
// e -> edgeObj
this._edgeObjs = {};
// e -> label
this._edgeLabels = {};
}
/* Number of nodes in the graph. Should only be changed by the implementation. */
Graph.prototype._nodeCount = 0;
/* Number of edges in the graph. Should only be changed by the implementation. */
Graph.prototype._edgeCount = 0;
/* === Graph functions ========= */
Graph.prototype.isDirected = function() {
return this._isDirected;
};
Graph.prototype.isMultigraph = function() {
return this._isMultigraph;
};
Graph.prototype.isCompound = function() {
return this._isCompound;
};
Graph.prototype.setGraph = function(label) {
this._label = label;
return this;
};
Graph.prototype.graph = function() {
return this._label;
};
/* === Node functions ========== */
Graph.prototype.setDefaultNodeLabel = function(newDefault) {
if (!_.isFunction(newDefault)) {
newDefault = _.constant(newDefault);
}
this._defaultNodeLabelFn = newDefault;
return this;
};
Graph.prototype.nodeCount = function() {
return this._nodeCount;
};
Graph.prototype.nodes = function() {
return _.keys(this._nodes);
};
Graph.prototype.sources = function() {
return _.filter(this.nodes(), function(v) {
return _.isEmpty(this._in[v]);
}, this);
};
Graph.prototype.sinks = function() {
return _.filter(this.nodes(), function(v) {
return _.isEmpty(this._out[v]);
}, this);
};
Graph.prototype.setNodes = function(vs, value) {
var args = arguments;
_.each(vs, function(v) {
if (args.length > 1) {
this.setNode(v, value);
} else {
this.setNode(v);
}
}, this);
return this;
};
Graph.prototype.setNode = function(v, value) {
if (_.has(this._nodes, v)) {
if (arguments.length > 1) {
this._nodes[v] = value;
}
return this;
}
this._nodes[v] = arguments.length > 1 ? value : this._defaultNodeLabelFn(v);
if (this._isCompound) {
this._parent[v] = GRAPH_NODE;
this._children[v] = {};
this._children[GRAPH_NODE][v] = true;
}
this._in[v] = {};
this._preds[v] = {};
this._out[v] = {};
this._sucs[v] = {};
++this._nodeCount;
return this;
};
Graph.prototype.node = function(v) {
return this._nodes[v];
};
Graph.prototype.hasNode = function(v) {
return _.has(this._nodes, v);
};
Graph.prototype.removeNode = function(v) {
var self = this;
if (_.has(this._nodes, v)) {
var removeEdge = function(e) { self.removeEdge(self._edgeObjs[e]); };
delete this._nodes[v];
if (this._isCompound) {
this._removeFromParentsChildList(v);
delete this._parent[v];
_.each(this.children(v), function(child) {
this.setParent(child);
}, this);
delete this._children[v];
}
_.each(_.keys(this._in[v]), removeEdge);
delete this._in[v];
delete this._preds[v];
_.each(_.keys(this._out[v]), removeEdge);
delete this._out[v];
delete this._sucs[v];
--this._nodeCount;
}
return this;
};
Graph.prototype.setParent = function(v, parent) {
if (!this._isCompound) {
throw new Error("Cannot set parent in a non-compound graph");
}
if (_.isUndefined(parent)) {
parent = GRAPH_NODE;
} else {
for (var ancestor = parent;
!_.isUndefined(ancestor);
ancestor = this.parent(ancestor)) {
if (ancestor === v) {
throw new Error("Setting " + parent+ " as parent of " + v +
" would create create a cycle");
}
}
this.setNode(parent);
}
this.setNode(v);
this._removeFromParentsChildList(v);
this._parent[v] = parent;
this._children[parent][v] = true;
return this;
};
Graph.prototype._removeFromParentsChildList = function(v) {
delete this._children[this._parent[v]][v];
};
Graph.prototype.parent = function(v) {
if (this._isCompound) {
var parent = this._parent[v];
if (parent !== GRAPH_NODE) {
return parent;
}
}
};
Graph.prototype.children = function(v) {
if (_.isUndefined(v)) {
v = GRAPH_NODE;
}
if (this._isCompound) {
var children = this._children[v];
if (children) {
return _.keys(children);
}
} else if (v === GRAPH_NODE) {
return this.nodes();
} else if (this.hasNode(v)) {
return [];
}
};
Graph.prototype.predecessors = function(v) {
var predsV = this._preds[v];
if (predsV) {
return _.keys(predsV);
}
};
Graph.prototype.successors = function(v) {
var sucsV = this._sucs[v];
if (sucsV) {
return _.keys(sucsV);
}
};
Graph.prototype.neighbors = function(v) {
var preds = this.predecessors(v);
if (preds) {
return _.union(preds, this.successors(v));
}
};
/* === Edge functions ========== */
Graph.prototype.setDefaultEdgeLabel = function(newDefault) {
if (!_.isFunction(newDefault)) {
newDefault = _.constant(newDefault);
}
this._defaultEdgeLabelFn = newDefault;
return this;
};
Graph.prototype.edgeCount = function() {
return this._edgeCount;
};
Graph.prototype.edges = function() {
return _.values(this._edgeObjs);
};
Graph.prototype.setPath = function(vs, value) {
var self = this,
args = arguments;
_.reduce(vs, function(v, w) {
if (args.length > 1) {
self.setEdge(v, w, value);
} else {
self.setEdge(v, w);
}
return w;
});
return this;
};
/*
* setEdge(v, w, [value, [name]])
* setEdge({ v, w, [name] }, [value])
*/
Graph.prototype.setEdge = function(v, w, value, name) {
var valueSpecified = arguments.length > 2;
v = String(v);
w = String(w);
if (!_.isUndefined(name)) {
name = String(name);
}
if (_.isPlainObject(arguments[0])) {
v = arguments[0].v;
w = arguments[0].w;
name = arguments[0].name;
if (arguments.length === 2) {
value = arguments[1];
valueSpecified = true;
}
}
var e = edgeArgsToId(this._isDirected, v, w, name);
if (_.has(this._edgeLabels, e)) {
if (valueSpecified) {
this._edgeLabels[e] = value;
}
return this;
}
if (!_.isUndefined(name) && !this._isMultigraph) {
throw new Error("Cannot set a named edge when isMultigraph = false");
}
// It didn't exist, so we need to create it.
// First ensure the nodes exist.
this.setNode(v);
this.setNode(w);
this._edgeLabels[e] = valueSpecified ? value : this._defaultEdgeLabelFn(v, w, name);
var edgeObj = edgeArgsToObj(this._isDirected, v, w, name);
// Ensure we add undirected edges in a consistent way.
v = edgeObj.v;
w = edgeObj.w;
Object.freeze(edgeObj);
this._edgeObjs[e] = edgeObj;
incrementOrInitEntry(this._preds[w], v);
incrementOrInitEntry(this._sucs[v], w);
this._in[w][e] = edgeObj;
this._out[v][e] = edgeObj;
this._edgeCount++;
return this;
};
Graph.prototype.edge = function(v, w, name) {
var e = (arguments.length === 1
? edgeObjToId(this._isDirected, arguments[0])
: edgeArgsToId(this._isDirected, v, w, name));
return this._edgeLabels[e];
};
Graph.prototype.hasEdge = function(v, w, name) {
var e = (arguments.length === 1
? edgeObjToId(this._isDirected, arguments[0])
: edgeArgsToId(this._isDirected, v, w, name));
return _.has(this._edgeLabels, e);
};
Graph.prototype.removeEdge = function(v, w, name) {
var e = (arguments.length === 1
? edgeObjToId(this._isDirected, arguments[0])
: edgeArgsToId(this._isDirected, v, w, name)),
edge = this._edgeObjs[e];
if (edge) {
v = edge.v;
w = edge.w;
delete this._edgeLabels[e];
delete this._edgeObjs[e];
decrementOrRemoveEntry(this._preds[w], v);
decrementOrRemoveEntry(this._sucs[v], w);
delete this._in[w][e];
delete this._out[v][e];
this._edgeCount--;
}
return this;
};
Graph.prototype.inEdges = function(v, u) {
var inV = this._in[v];
if (inV) {
var edges = _.values(inV);
if (!u) {
return edges;
}
return _.filter(edges, function(edge) { return edge.v === u; });
}
};
Graph.prototype.outEdges = function(v, w) {
var outV = this._out[v];
if (outV) {
var edges = _.values(outV);
if (!w) {
return edges;
}
return _.filter(edges, function(edge) { return edge.w === w; });
}
};
Graph.prototype.nodeEdges = function(v, w) {
var inEdges = this.inEdges(v, w);
if (inEdges) {
return inEdges.concat(this.outEdges(v, w));
}
};
function incrementOrInitEntry(map, k) {
if (_.has(map, k)) {
map[k]++;
} else {
map[k] = 1;
}
}
function decrementOrRemoveEntry(map, k) {
if (!--map[k]) { delete map[k]; }
}
function edgeArgsToId(isDirected, v, w, name) {
if (!isDirected && v > w) {
var tmp = v;
v = w;
w = tmp;
}
return v + EDGE_KEY_DELIM + w + EDGE_KEY_DELIM +
(_.isUndefined(name) ? DEFAULT_EDGE_NAME : name);
}
function edgeArgsToObj(isDirected, v, w, name) {
if (!isDirected && v > w) {
var tmp = v;
v = w;
w = tmp;
}
var edgeObj = { v: v, w: w };
if (name) {
edgeObj.name = name;
}
return edgeObj;
}
function edgeObjToId(isDirected, edgeObj) {
return edgeArgsToId(isDirected, edgeObj.v, edgeObj.w, edgeObj.name);
}
},{"./lodash":95}],93:[function(require,module,exports){
arguments[4][73][0].apply(exports,arguments)
},{"./graph":92,"./version":96}],94:[function(require,module,exports){
arguments[4][74][0].apply(exports,arguments)
},{"./graph":92,"./lodash":95}],95:[function(require,module,exports){
module.exports=require(20)
},{"lodash":101}],96:[function(require,module,exports){
module.exports = '0.9.1';
},{}],97:[function(require,module,exports){
},{}],98:[function(require,module,exports){
(function (process){
// Copyright Joyent, Inc. and other Node contributors.
//
@ -5279,7 +5779,7 @@ var substr = 'ab'.substr(-1) === 'b'
;
}).call(this,require("1YiZ5S"))
},{"1YiZ5S":79}],79:[function(require,module,exports){
},{"1YiZ5S":99}],99:[function(require,module,exports){
// shim for using process in browser
var process = module.exports = {};
@ -5344,7 +5844,7 @@ process.chdir = function (dir) {
throw new Error('process.chdir is not supported');
};
},{}],80:[function(require,module,exports){
},{}],100:[function(require,module,exports){
(function (global){
/*! http://mths.be/he v0.5.0 by @mathias | MIT license */
;(function(root) {
@ -5677,7 +6177,7 @@ process.chdir = function (dir) {
}(this));
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{}],81:[function(require,module,exports){
},{}],101:[function(require,module,exports){
(function (global){
/**
* @license
@ -12466,7 +12966,7 @@ process.chdir = function (dir) {
}.call(this));
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{}],82:[function(require,module,exports){
},{}],102:[function(require,module,exports){
module.exports={
"name": "mermaid",
"version": "0.3.2",
@ -12547,14 +13047,32 @@ module.exports={
}
}
},{}],83:[function(require,module,exports){
},{}],103:[function(require,module,exports){
/* global window */
var dagreD3;
if (require) {
try {
dagreD3 = require("dagre-d3");
} catch (e) {}
}
if (!dagreD3) {
dagreD3 = window.dagreD3;
}
module.exports = dagreD3;
},{"dagre-d3":1}],104:[function(require,module,exports){
(function (global){
/**
* Created by knut on 14-12-11.
*/
var graph = require('./graphDb');
var flow = require('./parser/flow');
var dot = require('./parser/dot');
var dagreD3 = require('dagre-d3');
var dagreD3 = require('./dagre-d3');
/**
* Function that adds the vertices found in the graph definition to the graph to be rendered.
* @param vert Object containing the vertices.
@ -12610,7 +13128,13 @@ exports.addVertices = function (vert, g) {
verticeText = vertice.text;
}
console.log(verticeText);
var labelTypeStr = '';
if(global.mermaid.htmlLabels) {
labelTypeStr = 'html';
} else {
verticeText = verticeText.replace(/<br>/g, "\n");
labelTypeStr = 'text';
}
var radious = 0;
var _shape = '';
@ -12630,6 +13154,9 @@ exports.addVertices = function (vert, g) {
case 'odd':
_shape = 'rect_left_inv_arrow';
break;
case 'odd_right':
_shape = 'rect_left_inv_arrow';
break;
case 'circle':
_shape = 'circle';
break;
@ -12637,7 +13164,7 @@ exports.addVertices = function (vert, g) {
_shape = 'rect';
}
// Add the node
g.setNode(vertice.id, {labelType: "html",shape:_shape, label: verticeText, rx: radious, ry: radious, class: classStr, style: style, id:vertice.id});
g.setNode(vertice.id, {labelType: labelTypeStr, shape:_shape, label: verticeText, rx: radious, ry: radious, class: classStr, style: style, id:vertice.id});
});
};
@ -12697,12 +13224,16 @@ exports.addEdges = function (edges, g) {
}
// Edge with text
else {
var edgeText = edge.text.replace(/<br>/g, "\n");
if(typeof edge.style === 'undefined'){
g.setEdge(edge.start, edge.end,{labelType: "html",style: style, labelpos:'c', label: '<span style="background:#e8e8e8">'+edge.text+'</span>', arrowheadStyle: "fill: #333", arrowhead: aHead},cnt);
}else{
if (global.mermaid.htmlLabels){
g.setEdge(edge.start, edge.end,{labelType: "html",style: style, labelpos:'c', label: '<span style="background:#e8e8e8">'+edge.text+'</span>', arrowheadStyle: "fill: #333", arrowhead: aHead},cnt);
}else{
g.setEdge(edge.start, edge.end,{labelType: "text", style: "stroke: #333; stroke-width: 1.5px;fill:none", labelpos:'c', label: edgeText, arrowheadStyle: "fill: #333", arrowhead: aHead},cnt);
}
}else{
g.setEdge(edge.start, edge.end, {
labelType: "html",style: style, arrowheadStyle: "fill: #333", label: edge.text, arrowhead: aHead
labelType: "text", style: style, arrowheadStyle: "fill: #333", label: edgeText, arrowhead: aHead
},cnt);
}
}
@ -12733,10 +13264,12 @@ exports.getClasses = function (text, isDot) {
var classes = graph.getClasses();
// Add default class if undefined
if(typeof classes.default === 'undefined') {
if(typeof(classes.default) === 'undefined') {
classes.default = {id:'default'};
classes.default.styles = ['fill:#eaeaea','stroke:#666','stroke-width:1.5px'];
}
classes.default.styles = ['fill:#ffa','stroke:#666','stroke-width:3px'];
classes.default.nodeLabelStyles = ['fill:#000','stroke:none','font-weight:300','font-family:"Helvetica Neue",Helvetica,Arial,sans-serf','font-size:14px'];
classes.default.edgeLabelStyles = ['fill:#000','stroke:none','font-weight:300','font-family:"Helvetica Neue",Helvetica,Arial,sans-serf','font-size:14px'];
}
return classes;
};
@ -12862,6 +13395,28 @@ exports.draw = function (text, id,isDot) {
return shapeSvg;
};
// Add custom shape for box with inverted arrow on right side
render.shapes().rect_right_inv_arrow = function (parent, bbox, node) {
var w = bbox.width,
h = bbox.height,
points = [
{x: 0, y: 0},
{x: w+h/2, y: 0},
{x: w, y: -h/2},
{x: w+h/2, y: -h},
{x: 0, y: -h},
];
var shapeSvg = parent.insert("polygon", ":first-child")
.attr("points", points.map(function (d) {
return d.x + "," + d.y;
}).join(" "))
.attr("transform", "translate(" + (-w / 2) + "," + (h * 2 / 4) + ")");
node.intersect = function (point) {
return dagreD3.intersect.polygon(node, points, point);
};
return shapeSvg;
};
// Add our custom arrow - an empty arrowhead
render.arrows().none = function normal(parent, id, edge, type) {
var marker = parent.append("marker")
@ -12939,7 +13494,8 @@ exports.draw = function (text, id,isDot) {
});
},200);
};
},{"./graphDb":84,"./parser/dot":85,"./parser/flow":86,"dagre-d3":1}],84:[function(require,module,exports){
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"./dagre-d3":103,"./graphDb":105,"./parser/dot":106,"./parser/flow":107}],105:[function(require,module,exports){
/**
* Created by knut on 14-11-03.
*/
@ -13178,7 +13734,7 @@ exports.getSubGraphs = function (list) {
return subGraphs;
};
},{}],85:[function(require,module,exports){
},{}],106:[function(require,module,exports){
(function (process){
/* parser generated by jison 0.4.15 */
/*
@ -13916,7 +14472,7 @@ if (typeof module !== 'undefined' && require.main === module) {
}
}
}).call(this,require("1YiZ5S"))
},{"1YiZ5S":79,"fs":77,"path":78}],86:[function(require,module,exports){
},{"1YiZ5S":99,"fs":97,"path":98}],107:[function(require,module,exports){
(function (process){
/* parser generated by jison 0.4.15 */
/*
@ -14801,7 +15357,7 @@ if (typeof module !== 'undefined' && require.main === module) {
}
}
}).call(this,require("1YiZ5S"))
},{"1YiZ5S":79,"fs":77,"path":78}],87:[function(require,module,exports){
},{"1YiZ5S":99,"fs":97,"path":98}],108:[function(require,module,exports){
(function (process){
/* parser generated by jison 0.4.15 */
/*
@ -15545,7 +16101,7 @@ if (typeof module !== 'undefined' && require.main === module) {
}
}
}).call(this,require("1YiZ5S"))
},{"1YiZ5S":79,"fs":77,"path":78}],88:[function(require,module,exports){
},{"1YiZ5S":99,"fs":97,"path":98}],109:[function(require,module,exports){
/**
* Created by knut on 14-11-19.
*/
@ -15678,7 +16234,7 @@ exports.apply = function(param){
// console.log('xxx',param);
}
};
},{}],89:[function(require,module,exports){
},{}],110:[function(require,module,exports){
/* globals d3 */
/**
* Created by knut on 14-11-23.
@ -16025,7 +16581,7 @@ module.exports.draw = function (text, id) {
diagram.attr("viewBox", (box.startx-conf.diagramMarginX) + ' -' +conf.diagramMarginY + ' ' + width + ' ' + height);
};
},{"./parser/sequenceDiagram":87,"./sequenceDb":88,"./svgDraw":90}],90:[function(require,module,exports){
},{"./parser/sequenceDiagram":108,"./sequenceDb":109,"./svgDraw":111}],111:[function(require,module,exports){
/**
* Created by knut on 14-12-20.
*/
@ -16255,7 +16811,7 @@ exports.getNoteRect = function(){
return rect;
};
},{}],91:[function(require,module,exports){
},{}],112:[function(require,module,exports){
(function (global){
var graph = require('./diagrams/flowchart/graphDb');
var flow = require('./diagrams/flowchart/parser/flow');
@ -16280,8 +16836,8 @@ var he = require('he');
var init = function (sequenceConfig) {
var arr = document.querySelectorAll('.mermaid');
var i;
if (sequenceConfig) {
if (sequenceConfig !== 'undefined') {
seq.setConf(JSON.parse(sequenceConfig));
}
@ -16357,6 +16913,7 @@ var equals = function (val, variable){
global.mermaid = {
startOnLoad:true,
htmlLabels:true,
init:function(sequenceConfig){
init(sequenceConfig);
},
@ -16372,6 +16929,12 @@ exports.contentLoaded = function(){
// Check state of start config mermaid namespece
//console.log('global.mermaid.startOnLoad',global.mermaid.startOnLoad);
//console.log('mermaid_config',mermaid_config);
if (typeof mermaid_config !== 'undefined') {
if (equals(false, mermaid_config.htmlLabels)) {
global.mermaid.htmlLabels = false;
}
}
if(global.mermaid.startOnLoad) {
// For backwards compatability reasons also check mermaid_config variable
@ -16391,7 +16954,7 @@ exports.contentLoaded = function(){
if(typeof document !== 'undefined'){
/**
* Wait for coument loaded before starting the execution
* Wait for document loaded before starting the execution
*/
document.addEventListener('DOMContentLoaded', function(){
exports.contentLoaded();
@ -16401,7 +16964,7 @@ if(typeof document !== 'undefined'){
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"../package.json":82,"./diagrams/flowchart/flowRenderer":83,"./diagrams/flowchart/graphDb":84,"./diagrams/flowchart/parser/flow":86,"./diagrams/sequenceDiagram/sequenceRenderer":89,"./utils":92,"he":80}],92:[function(require,module,exports){
},{"../package.json":102,"./diagrams/flowchart/flowRenderer":104,"./diagrams/flowchart/graphDb":105,"./diagrams/flowchart/parser/flow":107,"./diagrams/sequenceDiagram/sequenceRenderer":110,"./utils":113,"he":100}],113:[function(require,module,exports){
/**
* Created by knut on 14-11-23.
*/
@ -16462,10 +17025,19 @@ module.exports.cloneCssStyles = function(svg, classes){
for (var className in classes) {
if (classes.hasOwnProperty(className) && typeof(className) != "undefined") {
if (className === 'default') {
defaultStyles = '.node' + ' { ' + classes[className].styles.join("; ") + '; }\n';
if (classes.default.styles instanceof Array) {
defaultStyles += "#" + svg.id.trim() + ' .node' + ' { ' + classes[className].styles.join("; ") + '; }\n';
}
if (classes.default.nodeLabelStyles instanceof Array) {
defaultStyles += "#" + svg.id.trim() + ' .node text ' + ' { ' + classes[className].nodeLabelStyles.join("; ") + '; }\n';
}
if (classes.default.edgeLabelStyles instanceof Array) {
defaultStyles += "#" + svg.id.trim() + ' .edgeLabel text ' + ' { ' + classes[className].edgeLabelStyles.join("; ") + '; }\n';
}
} else {
embeddedStyles += '.' + className + ' { ' + classes[className].styles.join("; ") + '; }\n';
//embeddedStyles += svg.id.trim() + ' .' + className + ' { ' + classes[className].styles.join("; ") + '; }\n';
if (classes[className].styles instanceof Array) {
embeddedStyles += "#" + svg.id.trim() + ' .' + className + ' { ' + classes[className].styles.join("; ") + '; }\n';
}
}
}
}
@ -16475,6 +17047,7 @@ module.exports.cloneCssStyles = function(svg, classes){
s.setAttribute('type', 'text/css');
s.setAttribute('title', 'mermaid-svg-internal-css');
s.innerHTML = "/* <![CDATA[ */\n";
// Make this CSS local to this SVG
if (defaultStyles !== "") {
s.innerHTML += defaultStyles;
}
@ -16489,4 +17062,4 @@ module.exports.cloneCssStyles = function(svg, classes){
}
};
},{}]},{},[91])
},{}]},{},[112])

File diff suppressed because one or more lines are too long

View File

@ -211,7 +211,6 @@ function executeInPage(data) {
el.appendChild(elContent)
document.body.appendChild(el)
mermaid.init(sequenceConfig)
svg = document.querySelector('svg')

View File

@ -473,7 +473,7 @@ describe('when parsing ',function(){
expect(edges[0].stroke).toBe('dotted');
});
it('it should handle text on lines', function () {
var res = flow.parser.parse('graph TD;A== test text with -- ==>B;');
var res = flow.parser.parse('graph TD;A== test text with - ==>B;');
var vert = flow.parser.yy.getVertices();
var edges = flow.parser.yy.getEdges();
@ -577,7 +577,15 @@ describe('when parsing ',function(){
expect(edges[0].text).toBe('text including graph space');
});
xit('should handle text on open links',function(){
var res = flow.parser.parse('graph TD;A-- text including graph space --B');
var vert = flow.parser.yy.getVertices();
var edges = flow.parser.yy.getEdges();
expect(edges[0].text).toBe('text including graph space');
});
});

View File

@ -22,7 +22,7 @@ var init = function (sequenceConfig) {
var arr = document.querySelectorAll('.mermaid');
var i;
if (sequenceConfig) {
if (sequenceConfig !== 'undefined') {
seq.setConf(JSON.parse(sequenceConfig));
}