1 | import { d as sanitizeText$1, c as getConfig, l as log, p as setupGraphViewbox } from "./mermaid-a953d906.js";
|
2 | import { select } from "d3";
|
3 | import { c as createText } from "./createText-2f679d62.js";
|
4 | import cytoscape from "cytoscape/dist/cytoscape.umd.js";
|
5 | import coseBilkent from "cytoscape-cose-bilkent";
|
6 | import { isDark, lighten, darken } from "khroma";
|
7 | import "ts-dedent";
|
8 | import "dayjs/esm/index.js";
|
9 | import "@braintree/sanitize-url";
|
10 | import "dompurify";
|
11 | import "lodash-es/memoize.js";
|
12 | import "stylis";
|
13 | import "lodash-es/isEmpty.js";
|
14 | import "mdast-util-from-markdown";
|
15 | var parser = function() {
|
16 | var o = function(k, v, o2, l) {
|
17 | for (o2 = o2 || {}, l = k.length; l--; o2[k[l]] = v)
|
18 | ;
|
19 | return o2;
|
20 | }, $V0 = [1, 4], $V1 = [1, 13], $V2 = [1, 12], $V3 = [1, 15], $V4 = [1, 16], $V5 = [1, 20], $V6 = [1, 19], $V7 = [6, 7, 8], $V8 = [1, 26], $V9 = [1, 24], $Va = [1, 25], $Vb = [6, 7, 11], $Vc = [1, 6, 13, 15, 16, 19, 22], $Vd = [1, 33], $Ve = [1, 34], $Vf = [1, 6, 7, 11, 13, 15, 16, 19, 22];
|
21 | var parser2 = {
|
22 | trace: function trace() {
|
23 | },
|
24 | yy: {},
|
25 | symbols_: { "error": 2, "start": 3, "mindMap": 4, "spaceLines": 5, "SPACELINE": 6, "NL": 7, "MINDMAP": 8, "document": 9, "stop": 10, "EOF": 11, "statement": 12, "SPACELIST": 13, "node": 14, "ICON": 15, "CLASS": 16, "nodeWithId": 17, "nodeWithoutId": 18, "NODE_DSTART": 19, "NODE_DESCR": 20, "NODE_DEND": 21, "NODE_ID": 22, "$accept": 0, "$end": 1 },
|
26 | terminals_: { 2: "error", 6: "SPACELINE", 7: "NL", 8: "MINDMAP", 11: "EOF", 13: "SPACELIST", 15: "ICON", 16: "CLASS", 19: "NODE_DSTART", 20: "NODE_DESCR", 21: "NODE_DEND", 22: "NODE_ID" },
|
27 | productions_: [0, [3, 1], [3, 2], [5, 1], [5, 2], [5, 2], [4, 2], [4, 3], [10, 1], [10, 1], [10, 1], [10, 2], [10, 2], [9, 3], [9, 2], [12, 2], [12, 2], [12, 2], [12, 1], [12, 1], [12, 1], [12, 1], [12, 1], [14, 1], [14, 1], [18, 3], [17, 1], [17, 4]],
|
28 | performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) {
|
29 | var $0 = $$.length - 1;
|
30 | switch (yystate) {
|
31 | case 6:
|
32 | case 7:
|
33 | return yy;
|
34 | case 8:
|
35 | yy.getLogger().trace("Stop NL ");
|
36 | break;
|
37 | case 9:
|
38 | yy.getLogger().trace("Stop EOF ");
|
39 | break;
|
40 | case 11:
|
41 | yy.getLogger().trace("Stop NL2 ");
|
42 | break;
|
43 | case 12:
|
44 | yy.getLogger().trace("Stop EOF2 ");
|
45 | break;
|
46 | case 15:
|
47 | yy.getLogger().info("Node: ", $$[$0].id);
|
48 | yy.addNode($$[$0 - 1].length, $$[$0].id, $$[$0].descr, $$[$0].type);
|
49 | break;
|
50 | case 16:
|
51 | yy.getLogger().trace("Icon: ", $$[$0]);
|
52 | yy.decorateNode({ icon: $$[$0] });
|
53 | break;
|
54 | case 17:
|
55 | case 21:
|
56 | yy.decorateNode({ class: $$[$0] });
|
57 | break;
|
58 | case 18:
|
59 | yy.getLogger().trace("SPACELIST");
|
60 | break;
|
61 | case 19:
|
62 | yy.getLogger().trace("Node: ", $$[$0].id);
|
63 | yy.addNode(0, $$[$0].id, $$[$0].descr, $$[$0].type);
|
64 | break;
|
65 | case 20:
|
66 | yy.decorateNode({ icon: $$[$0] });
|
67 | break;
|
68 | case 25:
|
69 | yy.getLogger().trace("node found ..", $$[$0 - 2]);
|
70 | this.$ = { id: $$[$0 - 1], descr: $$[$0 - 1], type: yy.getType($$[$0 - 2], $$[$0]) };
|
71 | break;
|
72 | case 26:
|
73 | this.$ = { id: $$[$0], descr: $$[$0], type: yy.nodeType.DEFAULT };
|
74 | break;
|
75 | case 27:
|
76 | yy.getLogger().trace("node found ..", $$[$0 - 3]);
|
77 | this.$ = { id: $$[$0 - 3], descr: $$[$0 - 1], type: yy.getType($$[$0 - 2], $$[$0]) };
|
78 | break;
|
79 | }
|
80 | },
|
81 | table: [{ 3: 1, 4: 2, 5: 3, 6: [1, 5], 8: $V0 }, { 1: [3] }, { 1: [2, 1] }, { 4: 6, 6: [1, 7], 7: [1, 8], 8: $V0 }, { 6: $V1, 7: [1, 10], 9: 9, 12: 11, 13: $V2, 14: 14, 15: $V3, 16: $V4, 17: 17, 18: 18, 19: $V5, 22: $V6 }, o($V7, [2, 3]), { 1: [2, 2] }, o($V7, [2, 4]), o($V7, [2, 5]), { 1: [2, 6], 6: $V1, 12: 21, 13: $V2, 14: 14, 15: $V3, 16: $V4, 17: 17, 18: 18, 19: $V5, 22: $V6 }, { 6: $V1, 9: 22, 12: 11, 13: $V2, 14: 14, 15: $V3, 16: $V4, 17: 17, 18: 18, 19: $V5, 22: $V6 }, { 6: $V8, 7: $V9, 10: 23, 11: $Va }, o($Vb, [2, 22], { 17: 17, 18: 18, 14: 27, 15: [1, 28], 16: [1, 29], 19: $V5, 22: $V6 }), o($Vb, [2, 18]), o($Vb, [2, 19]), o($Vb, [2, 20]), o($Vb, [2, 21]), o($Vb, [2, 23]), o($Vb, [2, 24]), o($Vb, [2, 26], { 19: [1, 30] }), { 20: [1, 31] }, { 6: $V8, 7: $V9, 10: 32, 11: $Va }, { 1: [2, 7], 6: $V1, 12: 21, 13: $V2, 14: 14, 15: $V3, 16: $V4, 17: 17, 18: 18, 19: $V5, 22: $V6 }, o($Vc, [2, 14], { 7: $Vd, 11: $Ve }), o($Vf, [2, 8]), o($Vf, [2, 9]), o($Vf, [2, 10]), o($Vb, [2, 15]), o($Vb, [2, 16]), o($Vb, [2, 17]), { 20: [1, 35] }, { 21: [1, 36] }, o($Vc, [2, 13], { 7: $Vd, 11: $Ve }), o($Vf, [2, 11]), o($Vf, [2, 12]), { 21: [1, 37] }, o($Vb, [2, 25]), o($Vb, [2, 27])],
|
82 | defaultActions: { 2: [2, 1], 6: [2, 2] },
|
83 | parseError: function parseError2(str, hash) {
|
84 | if (hash.recoverable) {
|
85 | this.trace(str);
|
86 | } else {
|
87 | var error = new Error(str);
|
88 | error.hash = hash;
|
89 | throw error;
|
90 | }
|
91 | },
|
92 | parse: function parse(input) {
|
93 | var self = this, stack = [0], tstack = [], vstack = [null], lstack = [], table = this.table, yytext = "", yylineno = 0, yyleng = 0, TERROR = 2, EOF = 1;
|
94 | var args = lstack.slice.call(arguments, 1);
|
95 | var lexer2 = Object.create(this.lexer);
|
96 | var sharedState = { yy: {} };
|
97 | for (var k in this.yy) {
|
98 | if (Object.prototype.hasOwnProperty.call(this.yy, k)) {
|
99 | sharedState.yy[k] = this.yy[k];
|
100 | }
|
101 | }
|
102 | lexer2.setInput(input, sharedState.yy);
|
103 | sharedState.yy.lexer = lexer2;
|
104 | sharedState.yy.parser = this;
|
105 | if (typeof lexer2.yylloc == "undefined") {
|
106 | lexer2.yylloc = {};
|
107 | }
|
108 | var yyloc = lexer2.yylloc;
|
109 | lstack.push(yyloc);
|
110 | var ranges = lexer2.options && lexer2.options.ranges;
|
111 | if (typeof sharedState.yy.parseError === "function") {
|
112 | this.parseError = sharedState.yy.parseError;
|
113 | } else {
|
114 | this.parseError = Object.getPrototypeOf(this).parseError;
|
115 | }
|
116 | function lex() {
|
117 | var token;
|
118 | token = tstack.pop() || lexer2.lex() || EOF;
|
119 | if (typeof token !== "number") {
|
120 | if (token instanceof Array) {
|
121 | tstack = token;
|
122 | token = tstack.pop();
|
123 | }
|
124 | token = self.symbols_[token] || token;
|
125 | }
|
126 | return token;
|
127 | }
|
128 | var symbol, state, action, r, yyval = {}, p, len, newState, expected;
|
129 | while (true) {
|
130 | state = stack[stack.length - 1];
|
131 | if (this.defaultActions[state]) {
|
132 | action = this.defaultActions[state];
|
133 | } else {
|
134 | if (symbol === null || typeof symbol == "undefined") {
|
135 | symbol = lex();
|
136 | }
|
137 | action = table[state] && table[state][symbol];
|
138 | }
|
139 | if (typeof action === "undefined" || !action.length || !action[0]) {
|
140 | var errStr = "";
|
141 | expected = [];
|
142 | for (p in table[state]) {
|
143 | if (this.terminals_[p] && p > TERROR) {
|
144 | expected.push("'" + this.terminals_[p] + "'");
|
145 | }
|
146 | }
|
147 | if (lexer2.showPosition) {
|
148 | errStr = "Parse error on line " + (yylineno + 1) + ":\n" + lexer2.showPosition() + "\nExpecting " + expected.join(", ") + ", got '" + (this.terminals_[symbol] || symbol) + "'";
|
149 | } else {
|
150 | errStr = "Parse error on line " + (yylineno + 1) + ": Unexpected " + (symbol == EOF ? "end of input" : "'" + (this.terminals_[symbol] || symbol) + "'");
|
151 | }
|
152 | this.parseError(errStr, {
|
153 | text: lexer2.match,
|
154 | token: this.terminals_[symbol] || symbol,
|
155 | line: lexer2.yylineno,
|
156 | loc: yyloc,
|
157 | expected
|
158 | });
|
159 | }
|
160 | if (action[0] instanceof Array && action.length > 1) {
|
161 | throw new Error("Parse Error: multiple actions possible at state: " + state + ", token: " + symbol);
|
162 | }
|
163 | switch (action[0]) {
|
164 | case 1:
|
165 | stack.push(symbol);
|
166 | vstack.push(lexer2.yytext);
|
167 | lstack.push(lexer2.yylloc);
|
168 | stack.push(action[1]);
|
169 | symbol = null;
|
170 | {
|
171 | yyleng = lexer2.yyleng;
|
172 | yytext = lexer2.yytext;
|
173 | yylineno = lexer2.yylineno;
|
174 | yyloc = lexer2.yylloc;
|
175 | }
|
176 | break;
|
177 | case 2:
|
178 | len = this.productions_[action[1]][1];
|
179 | yyval.$ = vstack[vstack.length - len];
|
180 | yyval._$ = {
|
181 | first_line: lstack[lstack.length - (len || 1)].first_line,
|
182 | last_line: lstack[lstack.length - 1].last_line,
|
183 | first_column: lstack[lstack.length - (len || 1)].first_column,
|
184 | last_column: lstack[lstack.length - 1].last_column
|
185 | };
|
186 | if (ranges) {
|
187 | yyval._$.range = [
|
188 | lstack[lstack.length - (len || 1)].range[0],
|
189 | lstack[lstack.length - 1].range[1]
|
190 | ];
|
191 | }
|
192 | r = this.performAction.apply(yyval, [
|
193 | yytext,
|
194 | yyleng,
|
195 | yylineno,
|
196 | sharedState.yy,
|
197 | action[1],
|
198 | vstack,
|
199 | lstack
|
200 | ].concat(args));
|
201 | if (typeof r !== "undefined") {
|
202 | return r;
|
203 | }
|
204 | if (len) {
|
205 | stack = stack.slice(0, -1 * len * 2);
|
206 | vstack = vstack.slice(0, -1 * len);
|
207 | lstack = lstack.slice(0, -1 * len);
|
208 | }
|
209 | stack.push(this.productions_[action[1]][0]);
|
210 | vstack.push(yyval.$);
|
211 | lstack.push(yyval._$);
|
212 | newState = table[stack[stack.length - 2]][stack[stack.length - 1]];
|
213 | stack.push(newState);
|
214 | break;
|
215 | case 3:
|
216 | return true;
|
217 | }
|
218 | }
|
219 | return true;
|
220 | }
|
221 | };
|
222 | var lexer = function() {
|
223 | var lexer2 = {
|
224 | EOF: 1,
|
225 | parseError: function parseError2(str, hash) {
|
226 | if (this.yy.parser) {
|
227 | this.yy.parser.parseError(str, hash);
|
228 | } else {
|
229 | throw new Error(str);
|
230 | }
|
231 | },
|
232 |
|
233 | setInput: function(input, yy) {
|
234 | this.yy = yy || this.yy || {};
|
235 | this._input = input;
|
236 | this._more = this._backtrack = this.done = false;
|
237 | this.yylineno = this.yyleng = 0;
|
238 | this.yytext = this.matched = this.match = "";
|
239 | this.conditionStack = ["INITIAL"];
|
240 | this.yylloc = {
|
241 | first_line: 1,
|
242 | first_column: 0,
|
243 | last_line: 1,
|
244 | last_column: 0
|
245 | };
|
246 | if (this.options.ranges) {
|
247 | this.yylloc.range = [0, 0];
|
248 | }
|
249 | this.offset = 0;
|
250 | return this;
|
251 | },
|
252 |
|
253 | input: function() {
|
254 | var ch = this._input[0];
|
255 | this.yytext += ch;
|
256 | this.yyleng++;
|
257 | this.offset++;
|
258 | this.match += ch;
|
259 | this.matched += ch;
|
260 | var lines = ch.match(/(?:\r\n?|\n).*/g);
|
261 | if (lines) {
|
262 | this.yylineno++;
|
263 | this.yylloc.last_line++;
|
264 | } else {
|
265 | this.yylloc.last_column++;
|
266 | }
|
267 | if (this.options.ranges) {
|
268 | this.yylloc.range[1]++;
|
269 | }
|
270 | this._input = this._input.slice(1);
|
271 | return ch;
|
272 | },
|
273 |
|
274 | unput: function(ch) {
|
275 | var len = ch.length;
|
276 | var lines = ch.split(/(?:\r\n?|\n)/g);
|
277 | this._input = ch + this._input;
|
278 | this.yytext = this.yytext.substr(0, this.yytext.length - len);
|
279 | this.offset -= len;
|
280 | var oldLines = this.match.split(/(?:\r\n?|\n)/g);
|
281 | this.match = this.match.substr(0, this.match.length - 1);
|
282 | this.matched = this.matched.substr(0, this.matched.length - 1);
|
283 | if (lines.length - 1) {
|
284 | this.yylineno -= lines.length - 1;
|
285 | }
|
286 | var r = this.yylloc.range;
|
287 | this.yylloc = {
|
288 | first_line: this.yylloc.first_line,
|
289 | last_line: this.yylineno + 1,
|
290 | first_column: this.yylloc.first_column,
|
291 | last_column: lines ? (lines.length === oldLines.length ? this.yylloc.first_column : 0) + oldLines[oldLines.length - lines.length].length - lines[0].length : this.yylloc.first_column - len
|
292 | };
|
293 | if (this.options.ranges) {
|
294 | this.yylloc.range = [r[0], r[0] + this.yyleng - len];
|
295 | }
|
296 | this.yyleng = this.yytext.length;
|
297 | return this;
|
298 | },
|
299 |
|
300 | more: function() {
|
301 | this._more = true;
|
302 | return this;
|
303 | },
|
304 |
|
305 | reject: function() {
|
306 | if (this.options.backtrack_lexer) {
|
307 | this._backtrack = true;
|
308 | } else {
|
309 | return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n" + this.showPosition(), {
|
310 | text: "",
|
311 | token: null,
|
312 | line: this.yylineno
|
313 | });
|
314 | }
|
315 | return this;
|
316 | },
|
317 |
|
318 | less: function(n) {
|
319 | this.unput(this.match.slice(n));
|
320 | },
|
321 |
|
322 | pastInput: function() {
|
323 | var past = this.matched.substr(0, this.matched.length - this.match.length);
|
324 | return (past.length > 20 ? "..." : "") + past.substr(-20).replace(/\n/g, "");
|
325 | },
|
326 |
|
327 | upcomingInput: function() {
|
328 | var next = this.match;
|
329 | if (next.length < 20) {
|
330 | next += this._input.substr(0, 20 - next.length);
|
331 | }
|
332 | return (next.substr(0, 20) + (next.length > 20 ? "..." : "")).replace(/\n/g, "");
|
333 | },
|
334 |
|
335 | showPosition: function() {
|
336 | var pre = this.pastInput();
|
337 | var c = new Array(pre.length + 1).join("-");
|
338 | return pre + this.upcomingInput() + "\n" + c + "^";
|
339 | },
|
340 |
|
341 | test_match: function(match, indexed_rule) {
|
342 | var token, lines, backup;
|
343 | if (this.options.backtrack_lexer) {
|
344 | backup = {
|
345 | yylineno: this.yylineno,
|
346 | yylloc: {
|
347 | first_line: this.yylloc.first_line,
|
348 | last_line: this.last_line,
|
349 | first_column: this.yylloc.first_column,
|
350 | last_column: this.yylloc.last_column
|
351 | },
|
352 | yytext: this.yytext,
|
353 | match: this.match,
|
354 | matches: this.matches,
|
355 | matched: this.matched,
|
356 | yyleng: this.yyleng,
|
357 | offset: this.offset,
|
358 | _more: this._more,
|
359 | _input: this._input,
|
360 | yy: this.yy,
|
361 | conditionStack: this.conditionStack.slice(0),
|
362 | done: this.done
|
363 | };
|
364 | if (this.options.ranges) {
|
365 | backup.yylloc.range = this.yylloc.range.slice(0);
|
366 | }
|
367 | }
|
368 | lines = match[0].match(/(?:\r\n?|\n).*/g);
|
369 | if (lines) {
|
370 | this.yylineno += lines.length;
|
371 | }
|
372 | this.yylloc = {
|
373 | first_line: this.yylloc.last_line,
|
374 | last_line: this.yylineno + 1,
|
375 | first_column: this.yylloc.last_column,
|
376 | last_column: lines ? lines[lines.length - 1].length - lines[lines.length - 1].match(/\r?\n?/)[0].length : this.yylloc.last_column + match[0].length
|
377 | };
|
378 | this.yytext += match[0];
|
379 | this.match += match[0];
|
380 | this.matches = match;
|
381 | this.yyleng = this.yytext.length;
|
382 | if (this.options.ranges) {
|
383 | this.yylloc.range = [this.offset, this.offset += this.yyleng];
|
384 | }
|
385 | this._more = false;
|
386 | this._backtrack = false;
|
387 | this._input = this._input.slice(match[0].length);
|
388 | this.matched += match[0];
|
389 | token = this.performAction.call(this, this.yy, this, indexed_rule, this.conditionStack[this.conditionStack.length - 1]);
|
390 | if (this.done && this._input) {
|
391 | this.done = false;
|
392 | }
|
393 | if (token) {
|
394 | return token;
|
395 | } else if (this._backtrack) {
|
396 | for (var k in backup) {
|
397 | this[k] = backup[k];
|
398 | }
|
399 | return false;
|
400 | }
|
401 | return false;
|
402 | },
|
403 |
|
404 | next: function() {
|
405 | if (this.done) {
|
406 | return this.EOF;
|
407 | }
|
408 | if (!this._input) {
|
409 | this.done = true;
|
410 | }
|
411 | var token, match, tempMatch, index;
|
412 | if (!this._more) {
|
413 | this.yytext = "";
|
414 | this.match = "";
|
415 | }
|
416 | var rules = this._currentRules();
|
417 | for (var i = 0; i < rules.length; i++) {
|
418 | tempMatch = this._input.match(this.rules[rules[i]]);
|
419 | if (tempMatch && (!match || tempMatch[0].length > match[0].length)) {
|
420 | match = tempMatch;
|
421 | index = i;
|
422 | if (this.options.backtrack_lexer) {
|
423 | token = this.test_match(tempMatch, rules[i]);
|
424 | if (token !== false) {
|
425 | return token;
|
426 | } else if (this._backtrack) {
|
427 | match = false;
|
428 | continue;
|
429 | } else {
|
430 | return false;
|
431 | }
|
432 | } else if (!this.options.flex) {
|
433 | break;
|
434 | }
|
435 | }
|
436 | }
|
437 | if (match) {
|
438 | token = this.test_match(match, rules[index]);
|
439 | if (token !== false) {
|
440 | return token;
|
441 | }
|
442 | return false;
|
443 | }
|
444 | if (this._input === "") {
|
445 | return this.EOF;
|
446 | } else {
|
447 | return this.parseError("Lexical error on line " + (this.yylineno + 1) + ". Unrecognized text.\n" + this.showPosition(), {
|
448 | text: "",
|
449 | token: null,
|
450 | line: this.yylineno
|
451 | });
|
452 | }
|
453 | },
|
454 |
|
455 | lex: function lex() {
|
456 | var r = this.next();
|
457 | if (r) {
|
458 | return r;
|
459 | } else {
|
460 | return this.lex();
|
461 | }
|
462 | },
|
463 |
|
464 | begin: function begin(condition) {
|
465 | this.conditionStack.push(condition);
|
466 | },
|
467 |
|
468 | popState: function popState() {
|
469 | var n = this.conditionStack.length - 1;
|
470 | if (n > 0) {
|
471 | return this.conditionStack.pop();
|
472 | } else {
|
473 | return this.conditionStack[0];
|
474 | }
|
475 | },
|
476 |
|
477 | _currentRules: function _currentRules() {
|
478 | if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {
|
479 | return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;
|
480 | } else {
|
481 | return this.conditions["INITIAL"].rules;
|
482 | }
|
483 | },
|
484 |
|
485 | topState: function topState(n) {
|
486 | n = this.conditionStack.length - 1 - Math.abs(n || 0);
|
487 | if (n >= 0) {
|
488 | return this.conditionStack[n];
|
489 | } else {
|
490 | return "INITIAL";
|
491 | }
|
492 | },
|
493 |
|
494 | pushState: function pushState(condition) {
|
495 | this.begin(condition);
|
496 | },
|
497 |
|
498 | stateStackSize: function stateStackSize() {
|
499 | return this.conditionStack.length;
|
500 | },
|
501 | options: { "case-insensitive": true },
|
502 | performAction: function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) {
|
503 | switch ($avoiding_name_collisions) {
|
504 | case 0:
|
505 | yy.getLogger().trace("Found comment", yy_.yytext);
|
506 | return 6;
|
507 | case 1:
|
508 | return 8;
|
509 | case 2:
|
510 | this.begin("CLASS");
|
511 | break;
|
512 | case 3:
|
513 | this.popState();
|
514 | return 16;
|
515 | case 4:
|
516 | this.popState();
|
517 | break;
|
518 | case 5:
|
519 | yy.getLogger().trace("Begin icon");
|
520 | this.begin("ICON");
|
521 | break;
|
522 | case 6:
|
523 | yy.getLogger().trace("SPACELINE");
|
524 | return 6;
|
525 | case 7:
|
526 | return 7;
|
527 | case 8:
|
528 | return 15;
|
529 | case 9:
|
530 | yy.getLogger().trace("end icon");
|
531 | this.popState();
|
532 | break;
|
533 | case 10:
|
534 | yy.getLogger().trace("Exploding node");
|
535 | this.begin("NODE");
|
536 | return 19;
|
537 | case 11:
|
538 | yy.getLogger().trace("Cloud");
|
539 | this.begin("NODE");
|
540 | return 19;
|
541 | case 12:
|
542 | yy.getLogger().trace("Explosion Bang");
|
543 | this.begin("NODE");
|
544 | return 19;
|
545 | case 13:
|
546 | yy.getLogger().trace("Cloud Bang");
|
547 | this.begin("NODE");
|
548 | return 19;
|
549 | case 14:
|
550 | this.begin("NODE");
|
551 | return 19;
|
552 | case 15:
|
553 | this.begin("NODE");
|
554 | return 19;
|
555 | case 16:
|
556 | this.begin("NODE");
|
557 | return 19;
|
558 | case 17:
|
559 | this.begin("NODE");
|
560 | return 19;
|
561 | case 18:
|
562 | return 13;
|
563 | case 19:
|
564 | return 22;
|
565 | case 20:
|
566 | return 11;
|
567 | case 21:
|
568 | this.begin("NSTR2");
|
569 | break;
|
570 | case 22:
|
571 | return "NODE_DESCR";
|
572 | case 23:
|
573 | this.popState();
|
574 | break;
|
575 | case 24:
|
576 | yy.getLogger().trace("Starting NSTR");
|
577 | this.begin("NSTR");
|
578 | break;
|
579 | case 25:
|
580 | yy.getLogger().trace("description:", yy_.yytext);
|
581 | return "NODE_DESCR";
|
582 | case 26:
|
583 | this.popState();
|
584 | break;
|
585 | case 27:
|
586 | this.popState();
|
587 | yy.getLogger().trace("node end ))");
|
588 | return "NODE_DEND";
|
589 | case 28:
|
590 | this.popState();
|
591 | yy.getLogger().trace("node end )");
|
592 | return "NODE_DEND";
|
593 | case 29:
|
594 | this.popState();
|
595 | yy.getLogger().trace("node end ...", yy_.yytext);
|
596 | return "NODE_DEND";
|
597 | case 30:
|
598 | this.popState();
|
599 | yy.getLogger().trace("node end ((");
|
600 | return "NODE_DEND";
|
601 | case 31:
|
602 | this.popState();
|
603 | yy.getLogger().trace("node end (-");
|
604 | return "NODE_DEND";
|
605 | case 32:
|
606 | this.popState();
|
607 | yy.getLogger().trace("node end (-");
|
608 | return "NODE_DEND";
|
609 | case 33:
|
610 | this.popState();
|
611 | yy.getLogger().trace("node end ((");
|
612 | return "NODE_DEND";
|
613 | case 34:
|
614 | this.popState();
|
615 | yy.getLogger().trace("node end ((");
|
616 | return "NODE_DEND";
|
617 | case 35:
|
618 | yy.getLogger().trace("Long description:", yy_.yytext);
|
619 | return 20;
|
620 | case 36:
|
621 | yy.getLogger().trace("Long description:", yy_.yytext);
|
622 | return 20;
|
623 | }
|
624 | },
|
625 | rules: [/^(?:\s*%%.*)/i, /^(?:mindmap\b)/i, /^(?::::)/i, /^(?:.+)/i, /^(?:\n)/i, /^(?:::icon\()/i, /^(?:[\s]+[\n])/i, /^(?:[\n]+)/i, /^(?:[^\)]+)/i, /^(?:\))/i, /^(?:-\))/i, /^(?:\(-)/i, /^(?:\)\))/i, /^(?:\))/i, /^(?:\(\()/i, /^(?:\{\{)/i, /^(?:\()/i, /^(?:\[)/i, /^(?:[\s]+)/i, /^(?:[^\(\[\n\-\)\{\}]+)/i, /^(?:$)/i, /^(?:["][`])/i, /^(?:[^`"]+)/i, /^(?:[`]["])/i, /^(?:["])/i, /^(?:[^"]+)/i, /^(?:["])/i, /^(?:[\)]\))/i, /^(?:[\)])/i, /^(?:[\]])/i, /^(?:\}\})/i, /^(?:\(-)/i, /^(?:-\))/i, /^(?:\(\()/i, /^(?:\()/i, /^(?:[^\)\]\(\}]+)/i, /^(?:.+(?!\(\())/i],
|
626 | conditions: { "CLASS": { "rules": [3, 4], "inclusive": false }, "ICON": { "rules": [8, 9], "inclusive": false }, "NSTR2": { "rules": [22, 23], "inclusive": false }, "NSTR": { "rules": [25, 26], "inclusive": false }, "NODE": { "rules": [21, 24, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36], "inclusive": false }, "INITIAL": { "rules": [0, 1, 2, 5, 6, 7, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20], "inclusive": true } }
|
627 | };
|
628 | return lexer2;
|
629 | }();
|
630 | parser2.lexer = lexer;
|
631 | function Parser() {
|
632 | this.yy = {};
|
633 | }
|
634 | Parser.prototype = parser2;
|
635 | parser2.Parser = Parser;
|
636 | return new Parser();
|
637 | }();
|
638 | parser.parser = parser;
|
639 | const mindmapParser = parser;
|
640 | const sanitizeText = (text) => sanitizeText$1(text, getConfig());
|
641 | let nodes = [];
|
642 | let cnt = 0;
|
643 | let elements = {};
|
644 | const clear = () => {
|
645 | nodes = [];
|
646 | cnt = 0;
|
647 | elements = {};
|
648 | };
|
649 | const getParent = function(level) {
|
650 | for (let i = nodes.length - 1; i >= 0; i--) {
|
651 | if (nodes[i].level < level) {
|
652 | return nodes[i];
|
653 | }
|
654 | }
|
655 | return null;
|
656 | };
|
657 | const getMindmap = () => {
|
658 | return nodes.length > 0 ? nodes[0] : null;
|
659 | };
|
660 | const addNode = (level, id, descr, type) => {
|
661 | log.info("addNode", level, id, descr, type);
|
662 | const conf = getConfig();
|
663 | const node = {
|
664 | id: cnt++,
|
665 | nodeId: sanitizeText(id),
|
666 | level,
|
667 | descr: sanitizeText(descr),
|
668 | type,
|
669 | children: [],
|
670 | width: getConfig().mindmap.maxNodeWidth
|
671 | };
|
672 | switch (node.type) {
|
673 | case nodeType.ROUNDED_RECT:
|
674 | node.padding = 2 * conf.mindmap.padding;
|
675 | break;
|
676 | case nodeType.RECT:
|
677 | node.padding = 2 * conf.mindmap.padding;
|
678 | break;
|
679 | case nodeType.HEXAGON:
|
680 | node.padding = 2 * conf.mindmap.padding;
|
681 | break;
|
682 | default:
|
683 | node.padding = conf.mindmap.padding;
|
684 | }
|
685 | const parent = getParent(level);
|
686 | if (parent) {
|
687 | parent.children.push(node);
|
688 | nodes.push(node);
|
689 | } else {
|
690 | if (nodes.length === 0) {
|
691 | nodes.push(node);
|
692 | } else {
|
693 | let error = new Error(
|
694 | 'There can be only one root. No parent could be found for ("' + node.descr + '")'
|
695 | );
|
696 | error.hash = {
|
697 | text: "branch " + name,
|
698 | token: "branch " + name,
|
699 | line: "1",
|
700 | loc: { first_line: 1, last_line: 1, first_column: 1, last_column: 1 },
|
701 | expected: ['"checkout ' + name + '"']
|
702 | };
|
703 | throw error;
|
704 | }
|
705 | }
|
706 | };
|
707 | const nodeType = {
|
708 | DEFAULT: 0,
|
709 | NO_BORDER: 0,
|
710 | ROUNDED_RECT: 1,
|
711 | RECT: 2,
|
712 | CIRCLE: 3,
|
713 | CLOUD: 4,
|
714 | BANG: 5,
|
715 | HEXAGON: 6
|
716 | };
|
717 | const getType = (startStr, endStr) => {
|
718 | log.debug("In get type", startStr, endStr);
|
719 | switch (startStr) {
|
720 | case "[":
|
721 | return nodeType.RECT;
|
722 | case "(":
|
723 | return endStr === ")" ? nodeType.ROUNDED_RECT : nodeType.CLOUD;
|
724 | case "((":
|
725 | return nodeType.CIRCLE;
|
726 | case ")":
|
727 | return nodeType.CLOUD;
|
728 | case "))":
|
729 | return nodeType.BANG;
|
730 | case "{{":
|
731 | return nodeType.HEXAGON;
|
732 | default:
|
733 | return nodeType.DEFAULT;
|
734 | }
|
735 | };
|
736 | const setElementForId = (id, element) => {
|
737 | elements[id] = element;
|
738 | };
|
739 | const decorateNode = (decoration) => {
|
740 | const node = nodes[nodes.length - 1];
|
741 | if (decoration && decoration.icon) {
|
742 | node.icon = sanitizeText(decoration.icon);
|
743 | }
|
744 | if (decoration && decoration.class) {
|
745 | node.class = sanitizeText(decoration.class);
|
746 | }
|
747 | };
|
748 | const type2Str = (type) => {
|
749 | switch (type) {
|
750 | case nodeType.DEFAULT:
|
751 | return "no-border";
|
752 | case nodeType.RECT:
|
753 | return "rect";
|
754 | case nodeType.ROUNDED_RECT:
|
755 | return "rounded-rect";
|
756 | case nodeType.CIRCLE:
|
757 | return "circle";
|
758 | case nodeType.CLOUD:
|
759 | return "cloud";
|
760 | case nodeType.BANG:
|
761 | return "bang";
|
762 | case nodeType.HEXAGON:
|
763 | return "hexgon";
|
764 | default:
|
765 | return "no-border";
|
766 | }
|
767 | };
|
768 | let parseError;
|
769 | const setErrorHandler = (handler) => {
|
770 | parseError = handler;
|
771 | };
|
772 | const getLogger = () => log;
|
773 | const getNodeById = (id) => nodes[id];
|
774 | const getElementById = (id) => elements[id];
|
775 | const mindmapDb = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
776 | __proto__: null,
|
777 | addNode,
|
778 | clear,
|
779 | decorateNode,
|
780 | getElementById,
|
781 | getLogger,
|
782 | getMindmap,
|
783 | getNodeById,
|
784 | getType,
|
785 | nodeType,
|
786 | get parseError() {
|
787 | return parseError;
|
788 | },
|
789 | sanitizeText,
|
790 | setElementForId,
|
791 | setErrorHandler,
|
792 | type2Str
|
793 | }, Symbol.toStringTag, { value: "Module" }));
|
794 | const MAX_SECTIONS = 12;
|
795 | const defaultBkg = function(elem, node, section) {
|
796 | const rd = 5;
|
797 | elem.append("path").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + type2Str(node.type)).attr(
|
798 | "d",
|
799 | `M0 ${node.height - rd} v${-node.height + 2 * rd} q0,-5 5,-5 h${node.width - 2 * rd} q5,0 5,5 v${node.height - rd} H0 Z`
|
800 | );
|
801 | elem.append("line").attr("class", "node-line-" + section).attr("x1", 0).attr("y1", node.height).attr("x2", node.width).attr("y2", node.height);
|
802 | };
|
803 | const rectBkg = function(elem, node) {
|
804 | elem.append("rect").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + type2Str(node.type)).attr("height", node.height).attr("width", node.width);
|
805 | };
|
806 | const cloudBkg = function(elem, node) {
|
807 | const w = node.width;
|
808 | const h = node.height;
|
809 | const r1 = 0.15 * w;
|
810 | const r2 = 0.25 * w;
|
811 | const r3 = 0.35 * w;
|
812 | const r4 = 0.2 * w;
|
813 | elem.append("path").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + type2Str(node.type)).attr(
|
814 | "d",
|
815 | `M0 0 a${r1},${r1} 0 0,1 ${w * 0.25},${-1 * w * 0.1}
|
816 | a${r3},${r3} 1 0,1 ${w * 0.4},${-1 * w * 0.1}
|
817 | a${r2},${r2} 1 0,1 ${w * 0.35},${1 * w * 0.2}
|
818 |
|
819 | a${r1},${r1} 1 0,1 ${w * 0.15},${1 * h * 0.35}
|
820 | a${r4},${r4} 1 0,1 ${-1 * w * 0.15},${1 * h * 0.65}
|
821 |
|
822 | a${r2},${r1} 1 0,1 ${-1 * w * 0.25},${w * 0.15}
|
823 | a${r3},${r3} 1 0,1 ${-1 * w * 0.5},${0}
|
824 | a${r1},${r1} 1 0,1 ${-1 * w * 0.25},${-1 * w * 0.15}
|
825 |
|
826 | a${r1},${r1} 1 0,1 ${-1 * w * 0.1},${-1 * h * 0.35}
|
827 | a${r4},${r4} 1 0,1 ${w * 0.1},${-1 * h * 0.65}
|
828 |
|
829 | H0 V0 Z`
|
830 | );
|
831 | };
|
832 | const bangBkg = function(elem, node) {
|
833 | const w = node.width;
|
834 | const h = node.height;
|
835 | const r = 0.15 * w;
|
836 | elem.append("path").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + type2Str(node.type)).attr(
|
837 | "d",
|
838 | `M0 0 a${r},${r} 1 0,0 ${w * 0.25},${-1 * h * 0.1}
|
839 | a${r},${r} 1 0,0 ${w * 0.25},${0}
|
840 | a${r},${r} 1 0,0 ${w * 0.25},${0}
|
841 | a${r},${r} 1 0,0 ${w * 0.25},${1 * h * 0.1}
|
842 |
|
843 | a${r},${r} 1 0,0 ${w * 0.15},${1 * h * 0.33}
|
844 | a${r * 0.8},${r * 0.8} 1 0,0 ${0},${1 * h * 0.34}
|
845 | a${r},${r} 1 0,0 ${-1 * w * 0.15},${1 * h * 0.33}
|
846 |
|
847 | a${r},${r} 1 0,0 ${-1 * w * 0.25},${h * 0.15}
|
848 | a${r},${r} 1 0,0 ${-1 * w * 0.25},${0}
|
849 | a${r},${r} 1 0,0 ${-1 * w * 0.25},${0}
|
850 | a${r},${r} 1 0,0 ${-1 * w * 0.25},${-1 * h * 0.15}
|
851 |
|
852 | a${r},${r} 1 0,0 ${-1 * w * 0.1},${-1 * h * 0.33}
|
853 | a${r * 0.8},${r * 0.8} 1 0,0 ${0},${-1 * h * 0.34}
|
854 | a${r},${r} 1 0,0 ${w * 0.1},${-1 * h * 0.33}
|
855 |
|
856 | H0 V0 Z`
|
857 | );
|
858 | };
|
859 | const circleBkg = function(elem, node) {
|
860 | elem.append("circle").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + type2Str(node.type)).attr("r", node.width / 2);
|
861 | };
|
862 | function insertPolygonShape(parent, w, h, points, node) {
|
863 | return parent.insert("polygon", ":first-child").attr(
|
864 | "points",
|
865 | points.map(function(d) {
|
866 | return d.x + "," + d.y;
|
867 | }).join(" ")
|
868 | ).attr("transform", "translate(" + (node.width - w) / 2 + ", " + h + ")");
|
869 | }
|
870 | const hexagonBkg = function(elem, node) {
|
871 | const h = node.height;
|
872 | const f = 4;
|
873 | const m = h / f;
|
874 | const w = node.width - node.padding + 2 * m;
|
875 | const points = [
|
876 | { x: m, y: 0 },
|
877 | { x: w - m, y: 0 },
|
878 | { x: w, y: -h / 2 },
|
879 | { x: w - m, y: -h },
|
880 | { x: m, y: -h },
|
881 | { x: 0, y: -h / 2 }
|
882 | ];
|
883 | insertPolygonShape(elem, w, h, points, node);
|
884 | };
|
885 | const roundedRectBkg = function(elem, node) {
|
886 | elem.append("rect").attr("id", "node-" + node.id).attr("class", "node-bkg node-" + type2Str(node.type)).attr("height", node.height).attr("rx", node.padding).attr("ry", node.padding).attr("width", node.width);
|
887 | };
|
888 | const drawNode = function(elem, node, fullSection, conf) {
|
889 | const htmlLabels = conf.htmlLabels;
|
890 | const section = fullSection % (MAX_SECTIONS - 1);
|
891 | const nodeElem = elem.append("g");
|
892 | node.section = section;
|
893 | let sectionClass = "section-" + section;
|
894 | if (section < 0) {
|
895 | sectionClass += " section-root";
|
896 | }
|
897 | nodeElem.attr("class", (node.class ? node.class + " " : "") + "mindmap-node " + sectionClass);
|
898 | const bkgElem = nodeElem.append("g");
|
899 | const textElem = nodeElem.append("g");
|
900 | const description = node.descr.replace(/(<br\/*>)/g, "\n");
|
901 | createText(textElem, description, {
|
902 | useHtmlLabels: htmlLabels,
|
903 | width: node.width,
|
904 | classes: "mindmap-node-label"
|
905 | });
|
906 | if (!htmlLabels) {
|
907 | textElem.attr("dy", "1em").attr("alignment-baseline", "middle").attr("dominant-baseline", "middle").attr("text-anchor", "middle");
|
908 | }
|
909 | const bbox = textElem.node().getBBox();
|
910 | const fontSize = conf.fontSize.replace ? conf.fontSize.replace("px", "") : conf.fontSize;
|
911 | node.height = bbox.height + fontSize * 1.1 * 0.5 + node.padding;
|
912 | node.width = bbox.width + 2 * node.padding;
|
913 | if (node.icon) {
|
914 | if (node.type === nodeType.CIRCLE) {
|
915 | node.height += 50;
|
916 | node.width += 50;
|
917 | const icon = nodeElem.append("foreignObject").attr("height", "50px").attr("width", node.width).attr("style", "text-align: center;");
|
918 | icon.append("div").attr("class", "icon-container").append("i").attr("class", "node-icon-" + section + " " + node.icon);
|
919 | textElem.attr(
|
920 | "transform",
|
921 | "translate(" + node.width / 2 + ", " + (node.height / 2 - 1.5 * node.padding) + ")"
|
922 | );
|
923 | } else {
|
924 | node.width += 50;
|
925 | const orgHeight = node.height;
|
926 | node.height = Math.max(orgHeight, 60);
|
927 | const heightDiff = Math.abs(node.height - orgHeight);
|
928 | const icon = nodeElem.append("foreignObject").attr("width", "60px").attr("height", node.height).attr("style", "text-align: center;margin-top:" + heightDiff / 2 + "px;");
|
929 | icon.append("div").attr("class", "icon-container").append("i").attr("class", "node-icon-" + section + " " + node.icon);
|
930 | textElem.attr(
|
931 | "transform",
|
932 | "translate(" + (25 + node.width / 2) + ", " + (heightDiff / 2 + node.padding / 2) + ")"
|
933 | );
|
934 | }
|
935 | } else {
|
936 | if (!htmlLabels) {
|
937 | const dx = node.width / 2;
|
938 | const dy = node.padding / 2;
|
939 | textElem.attr("transform", "translate(" + dx + ", " + dy + ")");
|
940 | } else {
|
941 | const dx = (node.width - bbox.width) / 2;
|
942 | const dy = (node.height - bbox.height) / 2;
|
943 | textElem.attr("transform", "translate(" + dx + ", " + dy + ")");
|
944 | }
|
945 | }
|
946 | switch (node.type) {
|
947 | case nodeType.DEFAULT:
|
948 | defaultBkg(bkgElem, node, section);
|
949 | break;
|
950 | case nodeType.ROUNDED_RECT:
|
951 | roundedRectBkg(bkgElem, node);
|
952 | break;
|
953 | case nodeType.RECT:
|
954 | rectBkg(bkgElem, node);
|
955 | break;
|
956 | case nodeType.CIRCLE:
|
957 | bkgElem.attr("transform", "translate(" + node.width / 2 + ", " + +node.height / 2 + ")");
|
958 | circleBkg(bkgElem, node);
|
959 | break;
|
960 | case nodeType.CLOUD:
|
961 | cloudBkg(bkgElem, node);
|
962 | break;
|
963 | case nodeType.BANG:
|
964 | bangBkg(bkgElem, node);
|
965 | break;
|
966 | case nodeType.HEXAGON:
|
967 | hexagonBkg(bkgElem, node);
|
968 | break;
|
969 | }
|
970 | setElementForId(node.id, nodeElem);
|
971 | return node.height;
|
972 | };
|
973 | const drawEdge = function drawEdge2(edgesElem, mindmap, parent, depth, fullSection) {
|
974 | const section = fullSection % (MAX_SECTIONS - 1);
|
975 | const sx = parent.x + parent.width / 2;
|
976 | const sy = parent.y + parent.height / 2;
|
977 | const ex = mindmap.x + mindmap.width / 2;
|
978 | const ey = mindmap.y + mindmap.height / 2;
|
979 | const mx = ex > sx ? sx + Math.abs(sx - ex) / 2 : sx - Math.abs(sx - ex) / 2;
|
980 | const my = ey > sy ? sy + Math.abs(sy - ey) / 2 : sy - Math.abs(sy - ey) / 2;
|
981 | const qx = ex > sx ? Math.abs(sx - mx) / 2 + sx : -Math.abs(sx - mx) / 2 + sx;
|
982 | const qy = ey > sy ? Math.abs(sy - my) / 2 + sy : -Math.abs(sy - my) / 2 + sy;
|
983 | edgesElem.append("path").attr(
|
984 | "d",
|
985 | parent.direction === "TB" || parent.direction === "BT" ? `M${sx},${sy} Q${sx},${qy} ${mx},${my} T${ex},${ey}` : `M${sx},${sy} Q${qx},${sy} ${mx},${my} T${ex},${ey}`
|
986 | ).attr("class", "edge section-edge-" + section + " edge-depth-" + depth);
|
987 | };
|
988 | const positionNode = function(node) {
|
989 | const nodeElem = getElementById(node.id);
|
990 | const x = node.x || 0;
|
991 | const y = node.y || 0;
|
992 | nodeElem.attr("transform", "translate(" + x + "," + y + ")");
|
993 | };
|
994 | const svgDraw = { drawNode, positionNode, drawEdge };
|
995 | cytoscape.use(coseBilkent);
|
996 | function drawNodes(svg, mindmap, section, conf) {
|
997 | svgDraw.drawNode(svg, mindmap, section, conf);
|
998 | if (mindmap.children) {
|
999 | mindmap.children.forEach((child, index) => {
|
1000 | drawNodes(svg, child, section < 0 ? index : section, conf);
|
1001 | });
|
1002 | }
|
1003 | }
|
1004 | function drawEdges(edgesEl, cy) {
|
1005 | cy.edges().map((edge, id) => {
|
1006 | const data = edge.data();
|
1007 | if (edge[0]._private.bodyBounds) {
|
1008 | const bounds = edge[0]._private.rscratch;
|
1009 | log.trace("Edge: ", id, data);
|
1010 | edgesEl.insert("path").attr(
|
1011 | "d",
|
1012 | `M ${bounds.startX},${bounds.startY} L ${bounds.midX},${bounds.midY} L${bounds.endX},${bounds.endY} `
|
1013 | ).attr("class", "edge section-edge-" + data.section + " edge-depth-" + data.depth);
|
1014 | }
|
1015 | });
|
1016 | }
|
1017 | function addNodes(mindmap, cy, conf, level) {
|
1018 | cy.add({
|
1019 | group: "nodes",
|
1020 | data: {
|
1021 | id: mindmap.id,
|
1022 | labelText: mindmap.descr,
|
1023 | height: mindmap.height,
|
1024 | width: mindmap.width,
|
1025 | level,
|
1026 | nodeId: mindmap.id,
|
1027 | padding: mindmap.padding,
|
1028 | type: mindmap.type
|
1029 | },
|
1030 | position: {
|
1031 | x: mindmap.x,
|
1032 | y: mindmap.y
|
1033 | }
|
1034 | });
|
1035 | if (mindmap.children) {
|
1036 | mindmap.children.forEach((child) => {
|
1037 | addNodes(child, cy, conf, level + 1);
|
1038 | cy.add({
|
1039 | group: "edges",
|
1040 | data: {
|
1041 | id: `${mindmap.id}_${child.id}`,
|
1042 | source: mindmap.id,
|
1043 | target: child.id,
|
1044 | depth: level,
|
1045 | section: child.section
|
1046 | }
|
1047 | });
|
1048 | });
|
1049 | }
|
1050 | }
|
1051 | function layoutMindmap(node, conf) {
|
1052 | return new Promise((resolve) => {
|
1053 | const renderEl = select("body").append("div").attr("id", "cy").attr("style", "display:none");
|
1054 | const cy = cytoscape({
|
1055 | container: document.getElementById("cy"),
|
1056 | // container to render in
|
1057 | style: [
|
1058 | {
|
1059 | selector: "edge",
|
1060 | style: {
|
1061 | "curve-style": "bezier"
|
1062 | }
|
1063 | }
|
1064 | ]
|
1065 | });
|
1066 | renderEl.remove();
|
1067 | addNodes(node, cy, conf, 0);
|
1068 | cy.nodes().forEach(function(n) {
|
1069 | n.layoutDimensions = () => {
|
1070 | const data = n.data();
|
1071 | return { w: data.width, h: data.height };
|
1072 | };
|
1073 | });
|
1074 | cy.layout({
|
1075 | name: "cose-bilkent",
|
1076 | quality: "proof",
|
1077 | // headless: true,
|
1078 | styleEnabled: false,
|
1079 | animate: false
|
1080 | }).run();
|
1081 | cy.ready((e) => {
|
1082 | log.info("Ready", e);
|
1083 | resolve(cy);
|
1084 | });
|
1085 | });
|
1086 | }
|
1087 | function positionNodes(cy) {
|
1088 | cy.nodes().map((node, id) => {
|
1089 | const data = node.data();
|
1090 | data.x = node.position().x;
|
1091 | data.y = node.position().y;
|
1092 | svgDraw.positionNode(data);
|
1093 | const el = getElementById(data.nodeId);
|
1094 | log.info("Id:", id, "Position: (", node.position().x, ", ", node.position().y, ")", data);
|
1095 | el.attr(
|
1096 | "transform",
|
1097 | `translate(${node.position().x - data.width / 2}, ${node.position().y - data.height / 2})`
|
1098 | );
|
1099 | el.attr("attr", `apa-${id})`);
|
1100 | });
|
1101 | }
|
1102 | const draw = async (text, id, version, diagObj) => {
|
1103 | const conf = getConfig();
|
1104 | conf.htmlLabels = false;
|
1105 | diagObj.db.clear();
|
1106 | diagObj.parser.parse(text);
|
1107 | log.debug("Rendering mindmap diagram\n" + text, diagObj.parser);
|
1108 | const securityLevel = getConfig().securityLevel;
|
1109 | let sandboxElement;
|
1110 | if (securityLevel === "sandbox") {
|
1111 | sandboxElement = select("#i" + id);
|
1112 | }
|
1113 | const root = securityLevel === "sandbox" ? select(sandboxElement.nodes()[0].contentDocument.body) : select("body");
|
1114 | const svg = root.select("#" + id);
|
1115 | svg.append("g");
|
1116 | const mm = diagObj.db.getMindmap();
|
1117 | const edgesElem = svg.append("g");
|
1118 | edgesElem.attr("class", "mindmap-edges");
|
1119 | const nodesElem = svg.append("g");
|
1120 | nodesElem.attr("class", "mindmap-nodes");
|
1121 | drawNodes(nodesElem, mm, -1, conf);
|
1122 | const cy = await layoutMindmap(mm, conf);
|
1123 | drawEdges(edgesElem, cy);
|
1124 | positionNodes(cy);
|
1125 | setupGraphViewbox(void 0, svg, conf.mindmap.padding, conf.mindmap.useMaxWidth);
|
1126 | };
|
1127 | const mindmapRenderer = {
|
1128 | draw
|
1129 | };
|
1130 | const genSections = (options) => {
|
1131 | let sections = "";
|
1132 | for (let i = 0; i < options.THEME_COLOR_LIMIT; i++) {
|
1133 | options["lineColor" + i] = options["lineColor" + i] || options["cScaleInv" + i];
|
1134 | if (isDark(options["lineColor" + i])) {
|
1135 | options["lineColor" + i] = lighten(options["lineColor" + i], 20);
|
1136 | } else {
|
1137 | options["lineColor" + i] = darken(options["lineColor" + i], 20);
|
1138 | }
|
1139 | }
|
1140 | for (let i = 0; i < options.THEME_COLOR_LIMIT; i++) {
|
1141 | const sw = "" + (17 - 3 * i);
|
1142 | sections += `
|
1143 | .section-${i - 1} rect, .section-${i - 1} path, .section-${i - 1} circle, .section-${i - 1} polygon, .section-${i - 1} path {
|
1144 | fill: ${options["cScale" + i]};
|
1145 | }
|
1146 | .section-${i - 1} text {
|
1147 | fill: ${options["cScaleLabel" + i]};
|
1148 | }
|
1149 | .node-icon-${i - 1} {
|
1150 | font-size: 40px;
|
1151 | color: ${options["cScaleLabel" + i]};
|
1152 | }
|
1153 | .section-edge-${i - 1}{
|
1154 | stroke: ${options["cScale" + i]};
|
1155 | }
|
1156 | .edge-depth-${i - 1}{
|
1157 | stroke-width: ${sw};
|
1158 | }
|
1159 | .section-${i - 1} line {
|
1160 | stroke: ${options["cScaleInv" + i]} ;
|
1161 | stroke-width: 3;
|
1162 | }
|
1163 |
|
1164 | .disabled, .disabled circle, .disabled text {
|
1165 | fill: lightgray;
|
1166 | }
|
1167 | .disabled text {
|
1168 | fill: #efefef;
|
1169 | }
|
1170 | `;
|
1171 | }
|
1172 | return sections;
|
1173 | };
|
1174 | const getStyles = (options) => `
|
1175 | .edge {
|
1176 | stroke-width: 3;
|
1177 | }
|
1178 | ${genSections(options)}
|
1179 | .section-root rect, .section-root path, .section-root circle, .section-root polygon {
|
1180 | fill: ${options.git0};
|
1181 | }
|
1182 | .section-root text {
|
1183 | fill: ${options.gitBranchLabel0};
|
1184 | }
|
1185 | .icon-container {
|
1186 | height:100%;
|
1187 | display: flex;
|
1188 | justify-content: center;
|
1189 | align-items: center;
|
1190 | }
|
1191 | .edge {
|
1192 | fill: none;
|
1193 | }
|
1194 | .mindmap-node-label {
|
1195 | dy: 1em;
|
1196 | alignment-baseline: middle;
|
1197 | text-anchor: middle;
|
1198 | dominant-baseline: middle;
|
1199 | text-align: center;
|
1200 | }
|
1201 | `;
|
1202 | const mindmapStyles = getStyles;
|
1203 | const diagram = {
|
1204 | db: mindmapDb,
|
1205 | renderer: mindmapRenderer,
|
1206 | parser: mindmapParser,
|
1207 | styles: mindmapStyles
|
1208 | };
|
1209 | export {
|
1210 | diagram
|
1211 | };
|
1212 |
|
\ | No newline at end of file |