-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
56 lines (51 loc) · 1.74 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* INTER-Mediator
* Copyright (c) INTER-Mediator Directive Committee (http://inter-mediator.org)
* This project started at the end of 2009 by Masayuki Nii [email protected].
*
* INTER-Mediator is supplied under MIT License.
* Please see the full license for details:
* https://github.com/INTER-Mediator/INTER-Mediator/blob/master/dist-docs/License.txt
*/
IMParts_Catalog.mermaid = {
// https://github.com/mermaid-js/mermaid/blob/develop/docs/usage.md
options: {
startOnLoad: false
},
instantiate: function (parentNode) {
'use strict'
const classOfParent = parentNode.getAttribute('class')
if (!classOfParent || classOfParent.length == 0 || classOfParent.indexOf('_im_widget_mermaid') < 0) {
const sp = (classOfParent && classOfParent.length > 0) ? ' ' : ''
parentNode.setAttribute('class', `${classOfParent}${sp}_im_widget_mermaid`)
const node = document.createElement('PRE')
const newId = parentNode.getAttribute('id') + '-mermaid'
node.setAttribute('id', newId)
node.setAttribute('class', 'mermaid marmaid-generated')
parentNode.appendChild(node)
IMParts_Catalog.mermaid.ids.push(newId)
parentNode._im_getComponentId = (function () {
const theId = newId
return function () {
return theId
}
})()
parentNode._im_setValue = (function () {
const theId = newId
const target = node
return function (str) {
IMParts_Catalog.mermaid.values[theId] = str
target.appendChild(document.createTextNode(str))
}
})()
}
},
ids: [],
values: [],
lib: null,
finish: function () {
IMParts_Catalog.mermaid.lib.run({
nodes: document.querySelectorAll('.marmaid-generated')
});
}
}