This repository has been archived by the owner on Nov 6, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
nb-mermaid.js
66 lines (54 loc) · 1.99 KB
/
nb-mermaid.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
57
58
59
60
61
62
63
64
65
66
// Generated by CoffeeScript 1.9.3
(function() {
var bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
define(["module"], function(module) {
var NotebookMermaid, _dot, d3, init, mermaid;
_dot = module.uri.replace(/\/[^\/]*$/, "");
mermaid = d3 = null;
NotebookMermaid = (function() {
function NotebookMermaid() {
this.initNotebook = bind(this.initNotebook, this);
this.initDeps = bind(this.initDeps, this);
require([this.toUrl(this.mmp("mermaid.min.js"))], this.initDeps);
}
NotebookMermaid.prototype.toUrl = function(url) {
return _dot + "/" + url;
};
NotebookMermaid.prototype.mmp = function(f) {
return "lib/mermaid/dist/" + f;
};
NotebookMermaid.prototype.initDeps = function(_m) {
mermaid = _m;
d3 = window.d3;
this.initCSS();
return this.initEnv();
};
NotebookMermaid.prototype.initCSS = function() {
return d3.select("head").selectAll("link.mermaid_style").data([this.mmp("mermaid.css"), this.mmp("mermaid.forest.css"), "./nb-mermaid.css"]).enter().append("link").attr({
rel: "stylesheet",
href: this.toUrl
});
};
NotebookMermaid.prototype.initEnv = function() {
return require(["base/js/events"], this.initNotebook, this.initStatic);
};
NotebookMermaid.prototype.initStatic = function() {
return mermaid.init();
};
NotebookMermaid.prototype.initNotebook = function(events) {
this.initStatic();
return events.on("rendered.MarkdownCell", this.markdownRendered);
};
NotebookMermaid.prototype.markdownRendered = function(evt, arg) {
var cell;
cell = arg.cell;
return mermaid.init(void 0, cell.element.find(".mermaid"));
};
return NotebookMermaid;
})();
init = function() {
return new NotebookMermaid;
};
return init.load_ipython_extension = init;
});
}).call(this);