Sidebar-AirComponent.js
1.84 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
(function () {
	// Adds Atlassian shapes
	// Air label
	Sidebar.prototype.addThingsKitAirPalette = function () {
		const gn = 'mxgraph.air';
		const dt = 'air';
		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: '上.gif', path: 'Air/上.gif' },
			{ name: '上.png', path: 'Air/上.png' },
			{ name: '下.gif', path: 'Air/下.gif' },
			{ name: '下.png', path: 'Air/下.png' },
			{ name: '右.gif', path: 'Air/右.gif' },
			{ name: '右.png', path: 'Air/右.png' },
			{ name: '左.gif', path: 'Air/左.gif' },
			{ name: '左.png', path: 'Air/左.png' },
		]
		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();
	};
})();