Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Permit adding specific classes to nodes & SVG lines #628

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/jsmind.graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
11 changes: 10 additions & 1 deletion src/jsmind.view_provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (Array.isArray(node_data['nodeClassList'])) {
node_data['nodeClassList'].forEach(className => {
node_element.classList.add(className);
});
}
if ('background-color' in node_data) {
node_element.style.backgroundColor = node_data['background-color'];
}
Expand Down Expand Up @@ -586,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];
Expand All @@ -598,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
Expand Down
Loading