Sidebar-PlantComponent.js
4.6 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
(function () {
// Adds Atlassian shapes
// plant label
Sidebar.prototype.addThingsKitPlantPalette = function () {
const gn = 'mxgraph.plant';
const dt = 'plant';
const label = '植物'
const width = 66;
const height = 74;
const prefix = `image;image=${window?.PROJECT_ENV.base}/webapp/images/thingskit/libs/`
const defaultStyle = ';imageAspect=0;'
this.setCurrentSearchEntryLibrary(dt);
const { COMPONENT_KEY, CATEGORY } = window.CellAttributeKeyEnum
function createUserObject(attribute) {
attribute = Object.assign({ [COMPONENT_KEY]: '', [CATEGORY]: '' }, attribute || {})
var xmlElement = mxUtils.createXmlDocument().createElement('UserObject');
Object.keys(attribute).forEach(key => {
xmlElement.setAttribute(key, attribute[key]);
})
return xmlElement
}
// 自定义属性
const cellAttribute = {
[COMPONENT_KEY]: 'Image',
[CATEGORY]: 'DEFAULT'
}
const graphPathLib = [
{ name: '植物 1.svg', path: 'plant/植物 1.svg' },
{ name: '植物 10.svg', path: 'plant/植物 10.svg' },
{ name: '植物 11.svg', path: 'plant/植物 11.svg' },
{ name: '植物 12.svg', path: 'plant/植物 12.svg' },
{ name: '植物 13.svg', path: 'plant/植物 13.svg' },
{ name: '植物 14.svg', path: 'plant/植物 14.svg' },
{ name: '植物 15.svg', path: 'plant/植物 15.svg' },
{ name: '植物 16.svg', path: 'plant/植物 16.svg' },
{ name: '植物 17.svg', path: 'plant/植物 17.svg' },
{ name: '植物 18.svg', path: 'plant/植物 18.svg' },
{ name: '植物 19.svg', path: 'plant/植物 19.svg' },
{ name: '植物 2.svg', path: 'plant/植物 2.svg' },
{ name: '植物 20.svg', path: 'plant/植物 20.svg' },
{ name: '植物 21.svg', path: 'plant/植物 21.svg' },
{ name: '植物 22.svg', path: 'plant/植物 22.svg' },
{ name: '植物 23.svg', path: 'plant/植物 23.svg' },
{ name: '植物 24.svg', path: 'plant/植物 24.svg' },
{ name: '植物 25.svg', path: 'plant/植物 25.svg' },
{ name: '植物 26.svg', path: 'plant/植物 26.svg' },
{ name: '植物 27.svg', path: 'plant/植物 27.svg' },
{ name: '植物 28.svg', path: 'plant/植物 28.svg' },
{ name: '植物 29.svg', path: 'plant/植物 29.svg' },
{ name: '植物 3.svg', path: 'plant/植物 3.svg' },
{ name: '植物 30.svg', path: 'plant/植物 30.svg' },
{ name: '植物 31.svg', path: 'plant/植物 31.svg' },
{ name: '植物 32.svg', path: 'plant/植物 32.svg' },
{ name: '植物 33.svg', path: 'plant/植物 33.svg' },
{ name: '植物 34.svg', path: 'plant/植物 34.svg' },
{ name: '植物 35.svg', path: 'plant/植物 35.svg' },
{ name: '植物 36.svg', path: 'plant/植物 36.svg' },
{ name: '植物 37.svg', path: 'plant/植物 37.svg' },
{ name: '植物 38.svg', path: 'plant/植物 38.svg' },
{ name: '植物 39.svg', path: 'plant/植物 39.svg' },
{ name: '植物 4.svg', path: 'plant/植物 4.svg' },
{ name: '植物 40.svg', path: 'plant/植物 40.svg' },
{ name: '植物 41.svg', path: 'plant/植物 41.svg' },
{ name: '植物 42.svg', path: 'plant/植物 42.svg' },
{ name: '植物 43.svg', path: 'plant/植物 43.svg' },
{ name: '植物 44.svg', path: 'plant/植物 44.svg' },
{ name: '植物 45.svg', path: 'plant/植物 45.svg' },
{ name: '植物 46.svg', path: 'plant/植物 46.svg' },
{ name: '植物 47.svg', path: 'plant/植物 47.svg' },
{ name: '植物 48.svg', path: 'plant/植物 48.svg' },
{ name: '植物 49.svg', path: 'plant/植物 49.svg' },
{ name: '植物 5.svg', path: 'plant/植物 5.svg' },
{ name: '植物 50.svg', path: 'plant/植物 50.svg' },
{ name: '植物 51.svg', path: 'plant/植物 51.svg' },
{ name: '植物 52.svg', path: 'plant/植物 52.svg' },
{ name: '植物 53.svg', path: 'plant/植物 53.svg' },
{ name: '植物 54.svg', path: 'plant/植物 54.svg' },
{ name: '植物 6.svg', path: 'plant/植物 6.svg' },
{ name: '植物 7.svg', path: 'plant/植物 7.svg' },
{ name: '植物 8.svg', path: 'plant/植物 8.svg' },
{ name: '植物 9.svg', path: 'plant/植物 9.svg' },
]
const fns = graphPathLib.map(item => {
return this.addEntry(this.getTagsForStencil(gn, item.name, dt).join(' '), mxUtils.bind(this, function () {
const cell = new mxCell(createUserObject(cellAttribute), new mxGeometry(0, 0, width, height), `${ prefix }${ item.path }${ defaultStyle }`);
cell.setVertex(true)
return this.createVertexTemplateFromCells([ cell ], cell.geometry.width, cell.geometry.height, item.name);
}));
})
this.setGalleryLib(dt, label, graphPathLib)
this.addPaletteFunctions(dt, label, false, fns);
this.setCurrentSearchEntryLibrary();
};
})();