From 0139feeafed8dc019f22db41bc032df24de09529 Mon Sep 17 00:00:00 2001 From: sam Date: Tue, 3 Sep 2024 16:50:02 +0200 Subject: [PATCH 1/2] Added support for "classList" data field on node source --- src/jsmind.view_provider.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/jsmind.view_provider.js b/src/jsmind.view_provider.js index 325a730c..e0d5804f 100644 --- a/src/jsmind.view_provider.js +++ b/src/jsmind.view_provider.js @@ -505,6 +505,11 @@ export class ViewProvider { this._reset_node_custom_style(node._data.view.element, node.data); } _reset_node_custom_style(node_element, node_data) { + if ('classList' in node_data && Array.isArray(node_data['classList'])) { + node_data['classList'].forEach((className) => { + node_element.classList.add(className); + }); + } if ('background-color' in node_data) { node_element.style.backgroundColor = node_data['background-color']; } From a1e2605379d3e77bd22ca7558fc9bf722e84ffb0 Mon Sep 17 00:00:00 2001 From: sam Date: Tue, 3 Sep 2024 19:01:05 +0200 Subject: [PATCH 2/2] node data accepts nodeClassList=[] and lineClassList[] (svg only) (cherry picked from commit db7287d02478c4bb1adea36667908a84cae11cfd) --- src/jsmind.graph.js | 7 ++++++- src/jsmind.view_provider.js | 10 +++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/jsmind.graph.js b/src/jsmind.graph.js index b1873eb1..3eea7e8a 100644 --- a/src/jsmind.graph.js +++ b/src/jsmind.graph.js @@ -59,11 +59,16 @@ class SvgGraph { } this.lines.length = 0; } - draw_line(pout, pin, offset, color) { + draw_line(pout, pin, offset, color, classList) { var line = SvgGraph.c('path'); line.setAttribute('stroke', color || this.opts.line_color); line.setAttribute('stroke-width', this.opts.line_width); line.setAttribute('fill', 'transparent'); + if (classList) { + classList.forEach(className => { + line.classList.add(className); + }); + } this.lines.push(line); this.e_svg.appendChild(line); this.drawing( diff --git a/src/jsmind.view_provider.js b/src/jsmind.view_provider.js index e0d5804f..9b09211f 100644 --- a/src/jsmind.view_provider.js +++ b/src/jsmind.view_provider.js @@ -505,8 +505,8 @@ export class ViewProvider { this._reset_node_custom_style(node._data.view.element, node.data); } _reset_node_custom_style(node_element, node_data) { - if ('classList' in node_data && Array.isArray(node_data['classList'])) { - node_data['classList'].forEach((className) => { + if (Array.isArray(node_data['nodeClassList'])) { + node_data['nodeClassList'].forEach(className => { node_element.classList.add(className); }); } @@ -591,6 +591,7 @@ export class ViewProvider { var pin = null; var pout = null; var color = null; + var classList = null; var _offset = this.get_view_offset(); for (var nodeid in nodes) { node = nodes[nodeid]; @@ -603,7 +604,10 @@ export class ViewProvider { pin = this.layout.get_node_point_in(node); pout = this.layout.get_node_point_out(node.parent); color = node.data['leading-line-color']; - this.graph.draw_line(pout, pin, _offset, color); + classList = Array.isArray(node.data['lineClassList']) + ? node.data['lineClassList'] + : null; + this.graph.draw_line(pout, pin, _offset, color, classList); } } // Drag the whole mind map with your mouse, when it's larger that the container