Sidebar-Control-Components.js 1.15 KB

(function () {
	// Adds Atlassian shapes
	// Control Component 控制元件
	Sidebar.prototype.addControlComponentsPalette = function () {
		const { COMPONENT_TYPE } = this.enumCellBasicAttribute
		const { SWITCH } = this.enumComponentType
		const gn = 'mxgraph.control';
		const dt = 'control';
		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]: SWITCH
		}

		const fns = [
			this.addEntry(this.getTagsForStencil(gn, 'Switch', dt).join(' '), mxUtils.bind(this, function () {
				const cell = new mxCell('', new mxGeometry(0, 0, 48, 48), `image;image=images/thingskit/switch-on.svg;${defaultStyle}`);
				cell.setVertex(true)
				this.setCellAttributes(cell, cellAttribute)
				return this.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, '开关');
			})),
		]


		this.addPaletteFunctions(dt, label, false, fns);

		this.setCurrentSearchEntryLibrary();
	};
})();