Skip to content

Commit 740aa4c

Browse files
authored
Multi select (StefH#1)
* . * fix multi * update wasm
1 parent 005ca87 commit 740aa4c

File tree

89 files changed

+481
-315
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+481
-315
lines changed

Directory.Build.props

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
</PropertyGroup>
55

66
<PropertyGroup>
7-
<VersionPrefix>0.0.1</VersionPrefix>
7+
<VersionPrefix>0.0.2</VersionPrefix>
88
</PropertyGroup>
99

1010
<Choose>

docs/_content/jsMind.Blazor/jsmind-interop.js

+97-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ MindMap.show = function (dotnetReference, containerId, mindMapOptions, mindMapDa
1414
"version": "1.0"
1515
},
1616
"format": mindMapData.format,
17-
"data": mindMapData.data,
17+
"data": mindMapData.data
1818
};
1919

2020
const options = {
@@ -23,8 +23,8 @@ MindMap.show = function (dotnetReference, containerId, mindMapOptions, mindMapDa
2323
theme: mindMapOptions.theme
2424
}
2525

26-
// Keep a reference to the javascript MindMap object
27-
instances[containerId] = window.jsMind.show(options, mind);
26+
const mm = window.jsMind.show(options, mind);;
27+
mm["multiSelect"] = mindMapOptions.multiSelect;
2828

2929
// Call a callback to indicate that the MindMap is shown
3030
dotnetReference.invokeMethodAsync("OnShowCallback", { evt: "done", node: "", data: [] });
@@ -50,15 +50,67 @@ MindMap.show = function (dotnetReference, containerId, mindMapOptions, mindMapDa
5050
}
5151
}
5252

53-
instances[containerId].add_event_listener(eventHandler);
54-
};
53+
// Custom
54+
if (mindMapOptions.multiSelect) {
55+
mm.selectedNodes = [];
56+
57+
const mousedownHandleMultiSelect = function (e) {
58+
e.preventDefault();
59+
60+
const element = e.target || event.srcElement;
61+
const id = this.view.get_binded_nodeid(element);
62+
if (id && element.tagName.toLowerCase() === "jmnode") {
63+
const node = mm.get_node(id);
64+
65+
var selectedNodeId;
66+
67+
// Check if already selected
68+
const index = mm.selectedNodes.indexOf(id);
69+
if (index > -1) {
70+
// Remove from list
71+
mm.selectedNodes.splice(index, 1);
72+
73+
// Remove the 'selected' class
74+
updateSelectedClass(node, false);
75+
76+
// Set selectedId to null
77+
selectedNodeId = null;
78+
} else {
79+
// Add to list
80+
mm.selectedNodes.push(id);
81+
82+
// Set selectedId to this node
83+
selectedNodeId = id;
84+
}
85+
86+
mm.selectedNodes.forEach(selectedId => {
87+
const selectedNode = mm.get_node(selectedId);
88+
updateSelectedClass(selectedNode, true);
89+
});
90+
91+
dotnetReference.invokeMethodAsync("OnMultiSelectCallback", { id: selectedNodeId, ids: mm.selectedNodes });
92+
}
93+
}
94+
95+
mm.view.add_event(mm, "mousedown", mousedownHandleMultiSelect);
96+
}
97+
98+
mm.add_event_listener(eventHandler);
99+
100+
// Keep a reference to the javascript MindMap object
101+
instances[containerId] = mm;
102+
}
55103

56104
MindMap.destroy = function (containerId) {
57105
instances[containerId] = null;
106+
delete instances[containerId];
58107
}
59108

60-
MindMap.addNode = function (containerId, id, parentId, topic, data) {
61-
instances[containerId].add_node(id, parentId, topic, data);
109+
MindMap.addNode = function (containerId, parentId, id, topic, data) {
110+
instances[containerId].add_node(parentId, id, topic, data);
111+
112+
var n = instances[containerId].get_node(id);
113+
var x = 9;
62114
}
63115

64116
MindMap.removeNode = function (containerId, id) {
@@ -89,6 +141,23 @@ MindMap.selectNode = function (containerId, id) {
89141
instances[containerId].select_node(id);
90142
}
91143

144+
MindMap.selectNodes = function (containerId, nodes) {
145+
if (instances[containerId].multiSelect) {
146+
instances[containerId].selectedNodes = [];
147+
148+
nodes.forEach(node => {
149+
const foundNode = instances[containerId].get_node(node.id);
150+
updateSelectedClass(foundNode, true);
151+
152+
instances[containerId].selectedNodes.push(node.id);
153+
});
154+
}
155+
}
156+
157+
MindMap.getNode = function (containerId, id) {
158+
return mapNode(instances[containerId].get_node(id));
159+
}
160+
92161
MindMap.clearSelect = function (containerId) {
93162
instances[containerId].select_clear();
94163
}
@@ -107,4 +176,25 @@ MindMap.enableEdit = function (containerId) {
107176

108177
MindMap.isEditable = function (containerId) {
109178
return instances[containerId].get_editable();
179+
}
180+
181+
updateSelectedClass = function(node, set) {
182+
if (set && !(/\s*selected\b/i).test(node._data.view.element.className)) {
183+
node._data.view.element.className += " selected";
184+
}
185+
else if (!set) {
186+
node._data.view.element.className = node._data.view.element.className.replace(/\s*selected\b/ig, "");
187+
}
188+
}
189+
190+
mapNode = function (node) {
191+
// Skip children property (TypeError: Converting circular structure to JSON)
192+
return {
193+
id: node.id,
194+
topic: node.topic,
195+
expanded: node.expanded,
196+
direction: node.direction,
197+
data: node.data,
198+
parentId: node.parentId
199+
};
110200
}

docs/_content/jsMind.Blazor/jsmind-interop.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

docs/_framework/_bin/System.Core.dll

0 Bytes
Binary file not shown.
-102 Bytes
Binary file not shown.
1 Byte
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.
1 Byte
Binary file not shown.
2 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
0 Bytes
Binary file not shown.
-71 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.

docs/_framework/_bin/System.dll

0 Bytes
Binary file not shown.

docs/_framework/_bin/System.dll.br

-70 Bytes
Binary file not shown.

docs/_framework/_bin/System.dll.gz

-1 Bytes
Binary file not shown.
0 Bytes
Binary file not shown.
Binary file not shown.
Binary file not shown.
2.5 KB
Binary file not shown.
792 Bytes
Binary file not shown.
1005 Bytes
Binary file not shown.
1.5 KB
Binary file not shown.
652 Bytes
Binary file not shown.
757 Bytes
Binary file not shown.

docs/_framework/_bin/mscorlib.dll

0 Bytes
Binary file not shown.

docs/_framework/_bin/mscorlib.dll.br

-220 Bytes
Binary file not shown.

docs/_framework/_bin/mscorlib.dll.gz

-1 Bytes
Binary file not shown.

docs/_framework/blazor.boot.json

+23-23
Original file line numberDiff line numberDiff line change
@@ -6,32 +6,32 @@
66
"linkerEnabled": true,
77
"resources": {
88
"assembly": {
9-
"jsMind.Blazor.dll": "sha256-vpALAtEl3jhPhe2m8RDHG37j0OMX2B8rYJl1aRHc+M0=",
10-
"jsMind.WASM.App.dll": "sha256-0IgK8yyvcOd9d4VXb+1\/EDR18dSQmmEKbZAX6Ya7RoE=",
11-
"Microsoft.AspNetCore.Components.dll": "sha256-IUeusN1Jp7KFGsJqqIDGedScto5Qb1lWtL3RQ1++dR8=",
12-
"Microsoft.AspNetCore.Components.Web.dll": "sha256-E6HboXrya9xcsDDZGvSpyb7OJjYQ2tqNEA4J+SlNJsc=",
13-
"Microsoft.AspNetCore.Components.WebAssembly.dll": "sha256-LucukUJzeSD\/IJlGLmQBWZRrPJuH\/T6pgO\/b6e7DjNM=",
9+
"jsMind.Blazor.dll": "sha256-amOymwCsV6VAzkrU0SOUVnFgAgEcbjwYbD1aTe+Aj6Q=",
10+
"jsMind.WASM.App.dll": "sha256-3TrPHNqVN573OpNGNxkRM4CXy5LVR5FmFmIROUtda6k=",
11+
"Microsoft.AspNetCore.Components.dll": "sha256-uBytAhaMOooP7hFGiMsxtDSaJDUDF7DsJKlqxaZfXpw=",
12+
"Microsoft.AspNetCore.Components.Web.dll": "sha256-HYtKfWnAVqx16zhFwYpfWAGeItOLm4oDTmqRHOVtM7A=",
13+
"Microsoft.AspNetCore.Components.WebAssembly.dll": "sha256-XuoiwFycj0FnuDqT7MH10iMINjPXE0qTktguQYYMK1A=",
1414
"Microsoft.Bcl.AsyncInterfaces.dll": "sha256-jzHgXWAvWMkKIGFjZoT84tbe72E+H7CvTr\/Dryh4QPs=",
15-
"Microsoft.Extensions.Configuration.Abstractions.dll": "sha256-Rw5V3xaDK9gE\/M9z\/IvZCnSBQDFBEbKSaqfmyhJulzk=",
16-
"Microsoft.Extensions.Configuration.dll": "sha256-Mj6rh3mNPqeot9GBszyDD8XcOLdvqS8bxqjocj5M9uw=",
17-
"Microsoft.Extensions.Configuration.Json.dll": "sha256-P+OLlapaq0hIGxpX8JpTvYvsgQpNnqsLOtW2qUZOZF0=",
18-
"Microsoft.Extensions.DependencyInjection.Abstractions.dll": "sha256-qNpL4eTRjEBbSpMl\/mQjriek5S0CELZZ4g4ZMSj54cc=",
19-
"Microsoft.Extensions.DependencyInjection.dll": "sha256-D13ai+iLMFB9m1fozAwhQYxT58cMDhcN5UzJkb8MXMQ=",
20-
"Microsoft.Extensions.Logging.Abstractions.dll": "sha256-bW4j5dwANFy978GJdh94psPtZOuhy\/9lg7tXCvDGqW8=",
21-
"Microsoft.Extensions.Logging.dll": "sha256-vRJJbIEpA8a3L78vVaHiSJP6SyTymNkpo3fSNyB5jMk=",
22-
"Microsoft.Extensions.Options.dll": "sha256-fdHESUVMLnJLpyXE0WFtTG\/8MweeVVbTRh9D5IIE7BE=",
23-
"Microsoft.Extensions.Primitives.dll": "sha256-fSyT0CUxW68PC83D7XkB3UWLq5V6LgvQEO9g\/XWHkus=",
15+
"Microsoft.Extensions.Configuration.Abstractions.dll": "sha256-9KAEpyaoBvxqZ9qcjHEWjCTgG04zlg3Eb2MvTmt\/J7g=",
16+
"Microsoft.Extensions.Configuration.dll": "sha256-Ilq\/7ctPtk833qs6VrQ220WHEtfuQTKHJQnNKG+RjKQ=",
17+
"Microsoft.Extensions.Configuration.Json.dll": "sha256-i5Ba6XXOqNsyD5n87E7cGjwhRRbv7Xkxo9exEgfvQ4k=",
18+
"Microsoft.Extensions.DependencyInjection.Abstractions.dll": "sha256-Z\/m2LGwciLR19ITXTpUuMTLxBzkwC\/6aQiXq3roME0A=",
19+
"Microsoft.Extensions.DependencyInjection.dll": "sha256-cVmKj00vnYwIxH68DPugG70RacPEC99enRmg6Rjj0zk=",
20+
"Microsoft.Extensions.Logging.Abstractions.dll": "sha256-UD2A7bxtaVmd\/u\/ImkyxnlNaXizy6wFV6HzlcOC0WaE=",
21+
"Microsoft.Extensions.Logging.dll": "sha256-dbqWhEKZ1ze1aHlU7AQPz2SnLbMTW78j3ojDiWJypUA=",
22+
"Microsoft.Extensions.Options.dll": "sha256-JWMiOACs7cgW93HjTnie19bfOKwY2PbZNSS60lCIa2k=",
23+
"Microsoft.Extensions.Primitives.dll": "sha256-cvI\/BD6vX6EDhSDL0ab6iFJtKNqggWdheY273ozsa2Q=",
2424
"Microsoft.JSInterop.dll": "sha256-GFqkJmxwbf7WMrZ+MCRzaOADzSsVQ9tcMrMt19fsEeo=",
2525
"Microsoft.JSInterop.WebAssembly.dll": "sha256-6g2dLhGUTDM61qYCCZ0XbEEq1ph7WIGsa0EGamodSZQ=",
26-
"mscorlib.dll": "sha256-wmwb97RsHpKxq37bedNSDuZ1X6iusYlWUYkyYgViCZ0=",
27-
"System.Core.dll": "sha256-qszRLSJ8pJ7yO7UKjBYK1B+vDs2VwlKx7AotIDV9v9E=",
28-
"System.dll": "sha256-Ih+UBTLqljbt7KyGfqRzJibH48sbs3DxOls9lhay448=",
29-
"System.Net.Http.dll": "sha256-RAzxCIXxtHE6Sc5A1xI8Q4ssOR6Ug3EVP0KQtNsc4CQ=",
30-
"System.Net.Http.WebAssemblyHttpHandler.dll": "sha256-MLSHCbXcK0QJ6ZqB3zQoIpSENELRf1Np7E89xEBlL7w=",
31-
"System.Runtime.CompilerServices.Unsafe.dll": "sha256-XkSCqkkvp4C8KfmlGpEQmQvohTI4m5tBhZ8XoP04s3U=",
32-
"System.Text.Encodings.Web.dll": "sha256-nn+EICkbEXq7uwbhrhWlwEZ0unNdgl9U7N8CFpfLU3U=",
33-
"System.Text.Json.dll": "sha256-Al2kYkWkDmxue0GAFftyWUq0llYn\/hCjSVW4vboHjJg=",
34-
"WebAssembly.Bindings.dll": "sha256-RMJ8PkQ2jbYHL9+7T4kgBrhjRCc3OvsULy5bAzfcXUc="
26+
"mscorlib.dll": "sha256-PupCO5v1STtBl29nVzMJ56yE1p0qygzI5NVmJAADWSM=",
27+
"System.Core.dll": "sha256-fakE9GGTKC7YhxtvYaT42mZlvRO0RY0HOzTe8TCjoT0=",
28+
"System.dll": "sha256-oRPuuNbCQ1YxVJ1Rjm158Nwx3vVNWJt\/Q8y8VYeQyeo=",
29+
"System.Net.Http.dll": "sha256-FWWH1\/GtaLH0ch43xOiMM7zGVOft4QGvXruNjIB1NZM=",
30+
"System.Net.Http.WebAssemblyHttpHandler.dll": "sha256-gh8lD77gLK+jrjgEwHie9EOLDga\/UxQEmRwI2qMGuFo=",
31+
"System.Runtime.CompilerServices.Unsafe.dll": "sha256-5IYo0WGxkD217TIzgXe9aQmLZXvMvJP9QQG16waw1TI=",
32+
"System.Text.Encodings.Web.dll": "sha256-R7oGOFv9KyXlW\/NKGzxk1UUO1OBgkX8jA7FbdKmdC6w=",
33+
"System.Text.Json.dll": "sha256-io0XemIRHU7+uMdKlPecPRyC3LsjW17NcDAhQfZyyPk=",
34+
"WebAssembly.Bindings.dll": "sha256-GdqxSx3U6t5iJiag4t2PJBzA4u\/U2C+CYf00mMnGWH4="
3535
},
3636
"pdb": null,
3737
"runtime": {

docs/_framework/blazor.boot.json.br

-4 Bytes
Binary file not shown.

docs/_framework/blazor.boot.json.gz

3 Bytes
Binary file not shown.

docs/manifest.json

+1-8
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,5 @@
44
"start_url": "./",
55
"display": "standalone",
66
"background_color": "#ffffff",
7-
"theme_color": "#03173d",
8-
"icons": [
9-
{
10-
"src": "icon-512.png",
11-
"type": "image/png",
12-
"sizes": "512x512"
13-
}
14-
]
7+
"theme_color": "#03173d"
158
}

0 commit comments

Comments
 (0)