Sidebar-Control-Components.js
1.76 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
(function () {
// Adds Atlassian shapes
// Control Component 控制元件
Sidebar.prototype.addControlComponentsPalette = function () {
const { COMPONENT_TYPE } = this.enumCellBasicAttribute
const { DEFAULT } = this.enumComponentType
const gn = 'mxgraph.control';
const dt = 'control';
const label = '控制元件'
const width = 66;
const height = 74;
const staticPath = '/thingskit-drawio/img/lib/thingskit/'
const prefix = 'image;image=img/lib/thingskit/'
const defaultStyle = ';imageAspect=0;'
this.setCurrentSearchEntryLibrary(dt);
// 自定义属性
const cellAttribute = {
[COMPONENT_TYPE]: DEFAULT
}
const graphPathLib = [
{ name: '风机1.png', path: 'fan/风机1.png' },
{ name: '风机2.png', path: 'fan/风机2.png' },
{ name: '风机3.png', path: 'fan/风机3.png' },
{ name: '风机4.png', path: 'fan/风机4.png' },
{ name: '风机5.gif', path: 'fan/风机5.gif' },
{ name: '风机6.gif', path: 'fan/风机6.gif' },
{ name: '风机7.gif', path: 'fan/风机7.gif' },
{ name: '风机8.png', path: 'fan/风机8.png' },
]
const lib = graphPathLib.map(item => {
item.staticPath = staticPath + item.path
return item
})
const fns = graphPathLib.map(item => {
return this.addEntry(this.getTagsForStencil(gn, item.name, dt).join(' '), mxUtils.bind(this, function () {
const cell = new mxCell('', new mxGeometry(0, 0, width, height), `${prefix}${item.path}${defaultStyle}`);
cell.setVertex(true)
this.setCellAttributes(cell, cellAttribute)
return this.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, item.name);
}));
})
this.setVariableImageLib(dt, label, lib)
this.addPaletteFunctions(dt, label, false, fns);
this.setCurrentSearchEntryLibrary();
};
})();