Sidebar-Control-Components.js 1.95 KB

(function () {
	// Adds Atlassian shapes
	// Control Component 控制元件
	Sidebar.prototype.addControlComponentsPalette = function () {
		const { COMPONENT_TYPE } = this.enumCellBasicAttribute
		const { SWITCH, PARAMS_SETTING_BUTTON, SWITCH_VALUE, SWITCH_STATE } = this.enumComponentType
		const { SWITCH_STATE_NONE } = this.enumComponentTypeValue
		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 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}`);
				// 自定义属性
				const cellAttribute = {
					[COMPONENT_TYPE]: SWITCH,
					[SWITCH_VALUE]: 1,
					[SWITCH_STATE]: SWITCH_STATE_NONE
				}
				cell.setVertex(true)
				this.setCellAttributes(cell, cellAttribute)
				return this.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, '开关');
			})),
			this.addEntry(this.getTagsForStencil(gn, 'Params Setting', dt).join(' '), mxUtils.bind(this, function () {
				const cell = new mxCell('参数设置', new mxGeometry(0, 0, 60, 32), 'text;html=1;strokeColor=#1890ff;fillColor=#1890ff;align=center;verticalAlign=middle;whiteSpace=wrap;overflow=hidden;fontColor=#FFFFFF;rounded=1;shadow=0;');
				// 自定义属性
				const cellAttribute = {
					[COMPONENT_TYPE]: PARAMS_SETTING_BUTTON
				}
				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();
	};
})();