mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-01-14 06:43:25 +08:00
#Adjustments of init - **could break some integrations!!**
* Configuration are picked up from the mermaid object and is not passed as arguments. Same handling for all diagram types, sequenceDiagrams were handled in a different way before this commit. When init is called with: * 0 arguments - all mermaid divs are processed * 1 argument - this is interpreted as a definition of what nodes to process * 2 arguments - for (some) backwards compatability the second argument is interpreted as the definition of nodes to process. The first argument (prrobably a sequence config is ignored) A definition of nodes to process can be * a css selector for what elements to be processed * a list of nodes as in the result of a command like the one below ``` document.querySelectorAll('.tbProcessed'); ```
This commit is contained in:
parent
c966aad496
commit
78d8ee01ac
48
dist/mermaid.full.js
vendored
48
dist/mermaid.full.js
vendored
@ -30861,25 +30861,34 @@ var parse = function(text){
|
||||
* c-->|No |d(Transform);
|
||||
* ```
|
||||
*/
|
||||
var init = function (sequenceConfig, arr) {
|
||||
arr = arr == null ? document.querySelectorAll('.mermaid')
|
||||
: typeof arr === "string" ? document.querySelectorAll(arr)
|
||||
: arr instanceof Node ? [arr]
|
||||
: arr;
|
||||
|
||||
//arr = document.querySelectorAll('.mermaid');
|
||||
var i;
|
||||
|
||||
if (sequenceConfig !== 'undefined' && (typeof sequenceConfig !== 'undefined')) {
|
||||
if(typeof sequenceConfig === 'object'){
|
||||
seq.setConf(sequenceConfig);
|
||||
} else{
|
||||
seq.setConf(JSON.parse(sequenceConfig));
|
||||
/**
|
||||
* Renders the mermaid diagrams
|
||||
* @* param nodes- a css selector or an array of nodes
|
||||
*/
|
||||
var init = function () {
|
||||
var nodes;
|
||||
if(arguments.length === 2){
|
||||
// sequence config was passed as #1
|
||||
if(typeof arguments[0] !== 'undefined'){
|
||||
mermaid.sequenceConfig = arguments[0];
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < arr.length; i++) {
|
||||
var element = arr[i];
|
||||
nodes = arguments[1];
|
||||
}
|
||||
else{
|
||||
nodes = arguments[0];
|
||||
}
|
||||
|
||||
nodes = nodes === undefined ? document.querySelectorAll('.mermaid')
|
||||
: typeof nodes === "string" ? document.querySelectorAll(nodes)
|
||||
: nodes instanceof Node ? [nodes]
|
||||
// Last case - sequence config was passed pick next
|
||||
: nodes;
|
||||
|
||||
var i;
|
||||
for (i = 0; i < nodes.length; i++) {
|
||||
var element = nodes[i];
|
||||
|
||||
// Check if previously processed
|
||||
if(!element.getAttribute("data-processed")) {
|
||||
@ -30888,7 +30897,7 @@ var init = function (sequenceConfig, arr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
id = 'mermaidChart' + nextId++;
|
||||
var id = 'mermaidChart' + nextId++;
|
||||
|
||||
var txt = element.innerHTML;
|
||||
txt = txt.replace(/>/g,'>');
|
||||
@ -30919,6 +30928,9 @@ var init = function (sequenceConfig, arr) {
|
||||
utils.cloneCssStyles(element.firstChild, classes);
|
||||
break;
|
||||
case 'sequenceDiagram':
|
||||
if(typeof mermaid.sequenceConfig === 'object'){
|
||||
seq.setConf(mermaid.sequenceConfig);
|
||||
}
|
||||
seq.draw(txt,id);
|
||||
utils.cloneCssStyles(element.firstChild, []);
|
||||
break;
|
||||
@ -31016,8 +31028,6 @@ if(typeof document !== 'undefined'){
|
||||
}, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||||
},{"../package.json":84,"./diagrams/example/exampleDb":85,"./diagrams/example/exampleRenderer":86,"./diagrams/example/parser/example":87,"./diagrams/flowchart/flowRenderer":90,"./diagrams/flowchart/graphDb":91,"./diagrams/flowchart/parser/dot":92,"./diagrams/flowchart/parser/flow":93,"./diagrams/gantt/ganttDb":95,"./diagrams/gantt/ganttRenderer":96,"./diagrams/gantt/parser/gantt":97,"./diagrams/sequenceDiagram/parser/sequenceDiagram":99,"./diagrams/sequenceDiagram/sequenceDb":100,"./diagrams/sequenceDiagram/sequenceRenderer":101,"./utils":104,"he":81}],104:[function(require,module,exports){
|
||||
/**
|
||||
|
2
dist/mermaid.full.min.js
vendored
2
dist/mermaid.full.min.js
vendored
File diff suppressed because one or more lines are too long
48
dist/mermaid.slim.js
vendored
48
dist/mermaid.slim.js
vendored
@ -30829,25 +30829,34 @@ var parse = function(text){
|
||||
* c-->|No |d(Transform);
|
||||
* ```
|
||||
*/
|
||||
var init = function (sequenceConfig, arr) {
|
||||
arr = arr == null ? document.querySelectorAll('.mermaid')
|
||||
: typeof arr === "string" ? document.querySelectorAll(arr)
|
||||
: arr instanceof Node ? [arr]
|
||||
: arr;
|
||||
|
||||
//arr = document.querySelectorAll('.mermaid');
|
||||
var i;
|
||||
|
||||
if (sequenceConfig !== 'undefined' && (typeof sequenceConfig !== 'undefined')) {
|
||||
if(typeof sequenceConfig === 'object'){
|
||||
seq.setConf(sequenceConfig);
|
||||
} else{
|
||||
seq.setConf(JSON.parse(sequenceConfig));
|
||||
/**
|
||||
* Renders the mermaid diagrams
|
||||
* @* param nodes- a css selector or an array of nodes
|
||||
*/
|
||||
var init = function () {
|
||||
var nodes;
|
||||
if(arguments.length === 2){
|
||||
// sequence config was passed as #1
|
||||
if(typeof arguments[0] !== 'undefined'){
|
||||
mermaid.sequenceConfig = arguments[0];
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < arr.length; i++) {
|
||||
var element = arr[i];
|
||||
nodes = arguments[1];
|
||||
}
|
||||
else{
|
||||
nodes = arguments[0];
|
||||
}
|
||||
|
||||
nodes = nodes === undefined ? document.querySelectorAll('.mermaid')
|
||||
: typeof nodes === "string" ? document.querySelectorAll(nodes)
|
||||
: nodes instanceof Node ? [nodes]
|
||||
// Last case - sequence config was passed pick next
|
||||
: nodes;
|
||||
|
||||
var i;
|
||||
for (i = 0; i < nodes.length; i++) {
|
||||
var element = nodes[i];
|
||||
|
||||
// Check if previously processed
|
||||
if(!element.getAttribute("data-processed")) {
|
||||
@ -30856,7 +30865,7 @@ var init = function (sequenceConfig, arr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
id = 'mermaidChart' + nextId++;
|
||||
var id = 'mermaidChart' + nextId++;
|
||||
|
||||
var txt = element.innerHTML;
|
||||
txt = txt.replace(/>/g,'>');
|
||||
@ -30887,6 +30896,9 @@ var init = function (sequenceConfig, arr) {
|
||||
utils.cloneCssStyles(element.firstChild, classes);
|
||||
break;
|
||||
case 'sequenceDiagram':
|
||||
if(typeof mermaid.sequenceConfig === 'object'){
|
||||
seq.setConf(mermaid.sequenceConfig);
|
||||
}
|
||||
seq.draw(txt,id);
|
||||
utils.cloneCssStyles(element.firstChild, []);
|
||||
break;
|
||||
@ -30984,8 +30996,6 @@ if(typeof document !== 'undefined'){
|
||||
}, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}).call(this,typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
|
||||
},{"../package.json":84,"./diagrams/example/exampleDb":85,"./diagrams/example/exampleRenderer":86,"./diagrams/example/parser/example":87,"./diagrams/flowchart/flowRenderer":90,"./diagrams/flowchart/graphDb":91,"./diagrams/flowchart/parser/dot":92,"./diagrams/flowchart/parser/flow":93,"./diagrams/gantt/ganttDb":95,"./diagrams/gantt/ganttRenderer":96,"./diagrams/gantt/parser/gantt":97,"./diagrams/sequenceDiagram/parser/sequenceDiagram":99,"./diagrams/sequenceDiagram/sequenceDb":100,"./diagrams/sequenceDiagram/sequenceRenderer":101,"./utils":104,"he":81}],104:[function(require,module,exports){
|
||||
/**
|
||||
|
2
dist/mermaid.slim.min.js
vendored
2
dist/mermaid.slim.min.js
vendored
File diff suppressed because one or more lines are too long
48
src/main.js
48
src/main.js
@ -75,25 +75,34 @@ var parse = function(text){
|
||||
* c-->|No |d(Transform);
|
||||
* ```
|
||||
*/
|
||||
var init = function (sequenceConfig, arr) {
|
||||
arr = arr == null ? document.querySelectorAll('.mermaid')
|
||||
: typeof arr === "string" ? document.querySelectorAll(arr)
|
||||
: arr instanceof Node ? [arr]
|
||||
: arr;
|
||||
|
||||
//arr = document.querySelectorAll('.mermaid');
|
||||
var i;
|
||||
|
||||
if (sequenceConfig !== 'undefined' && (typeof sequenceConfig !== 'undefined')) {
|
||||
if(typeof sequenceConfig === 'object'){
|
||||
seq.setConf(sequenceConfig);
|
||||
} else{
|
||||
seq.setConf(JSON.parse(sequenceConfig));
|
||||
/**
|
||||
* Renders the mermaid diagrams
|
||||
* @* param nodes- a css selector or an array of nodes
|
||||
*/
|
||||
var init = function () {
|
||||
var nodes;
|
||||
if(arguments.length === 2){
|
||||
// sequence config was passed as #1
|
||||
if(typeof arguments[0] !== 'undefined'){
|
||||
mermaid.sequenceConfig = arguments[0];
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < arr.length; i++) {
|
||||
var element = arr[i];
|
||||
nodes = arguments[1];
|
||||
}
|
||||
else{
|
||||
nodes = arguments[0];
|
||||
}
|
||||
|
||||
nodes = nodes === undefined ? document.querySelectorAll('.mermaid')
|
||||
: typeof nodes === "string" ? document.querySelectorAll(nodes)
|
||||
: nodes instanceof Node ? [nodes]
|
||||
// Last case - sequence config was passed pick next
|
||||
: nodes;
|
||||
|
||||
var i;
|
||||
for (i = 0; i < nodes.length; i++) {
|
||||
var element = nodes[i];
|
||||
|
||||
// Check if previously processed
|
||||
if(!element.getAttribute("data-processed")) {
|
||||
@ -102,7 +111,7 @@ var init = function (sequenceConfig, arr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
id = 'mermaidChart' + nextId++;
|
||||
var id = 'mermaidChart' + nextId++;
|
||||
|
||||
var txt = element.innerHTML;
|
||||
txt = txt.replace(/>/g,'>');
|
||||
@ -133,6 +142,9 @@ var init = function (sequenceConfig, arr) {
|
||||
utils.cloneCssStyles(element.firstChild, classes);
|
||||
break;
|
||||
case 'sequenceDiagram':
|
||||
if(typeof mermaid.sequenceConfig === 'object'){
|
||||
seq.setConf(mermaid.sequenceConfig);
|
||||
}
|
||||
seq.draw(txt,id);
|
||||
utils.cloneCssStyles(element.firstChild, []);
|
||||
break;
|
||||
@ -229,5 +241,3 @@ if(typeof document !== 'undefined'){
|
||||
exports.contentLoaded();
|
||||
}, false);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user