Sidebar-Light.js 2.91 KB

(function () {
	// Adds Atlassian shapes
	// light 灯
	Sidebar.prototype.addLightPalette = function () {
		const { COMPONENT_TYPE } = this.enumCellBasicAttribute
		const { DEFAULT } = this.enumComponentType
		const gn = 'mxgraph.light';
		const dt = 'light';
		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: '1.png', path: 'light/1.png' },
			{ name: '10.png', path: 'light/10.png' },
			{ name: '11.png', path: 'light/11.png' },
			{ name: '12.png', path: 'light/12.png' },
			{ name: '13.png', path: 'light/13.png' },
			{ name: '14.png', path: 'light/14.png' },
			{ name: '15.png', path: 'light/15.png' },
			{ name: '16.png', path: 'light/16.png' },
			{ name: '17.png', path: 'light/17.png' },
			{ name: '18.png', path: 'light/18.png' },
			{ name: '19.png', path: 'light/19.png' },
			{ name: '2.png', path: 'light/2.png' },
			{ name: '20.png', path: 'light/20.png' },
			{ name: '21.png', path: 'light/21.png' },
			{ name: '22.png', path: 'light/22.png' },
			{ name: '23.png', path: 'light/23.png' },
			{ name: '24.png', path: 'light/24.png' },
			{ name: '25.png', path: 'light/25.png' },
			{ name: '26.png', path: 'light/26.png' },
			{ name: '27.png', path: 'light/27.png' },
			{ name: '28.png', path: 'light/28.png' },
			{ name: '29.png', path: 'light/29.png' },
			{ name: '3.png', path: 'light/3.png' },
			{ name: '30.png', path: 'light/30.png' },
			{ name: '31.png', path: 'light/31.png' },
			{ name: '32.png', path: 'light/32.png' },
			{ name: '33.png', path: 'light/33.png' },
			{ name: '34.png', path: 'light/34.png' },
			{ name: '35.png', path: 'light/35.png' },
			{ name: '36.png', path: 'light/36.png' },
			{ name: '37.png', path: 'light/37.png' },
			{ name: '4.png', path: 'light/4.png' },
			{ name: '5.png', path: 'light/5.png' },
			{ name: '6.png', path: 'light/6.png' },
			{ name: '7.png', path: 'light/7.png' },
			{ name: '8.png', path: 'light/8.png' },
			{ name: '9.png', path: 'light/9.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();
	};
})();