Sidebar-Air.js 1.66 KB

(function () {
	// Adds Atlassian shapes
	// Air label
	Sidebar.prototype.addAirPalette = function () {
		const { COMPONENT_TYPE } = this.enumCellBasicAttribute
		const { DEFAULT } = this.enumComponentType
		const gn = 'mxgraph.air';
		const dt = 'air';
		const label = '空气'
		const width = 66;
		const height = 74;
		const staticPath = `${Proxy_Prefix}/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: '上.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 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();
	};
})();