import {PolylineEdgeModel, PolylineEdge, h} from '@logicflow/core';

export const CUSTOM_LINE = {
	LINE_TYPE: 'line'
};

// 自定义连线模型
export class CustomLineModel extends PolylineEdgeModel {
	initEdgeData(data) {
		super.initEdgeData(data)
		// 禁止编辑标签
		this.text.editable = false
		this.text.draggable = false
	}

	getEdgeStyle() {
		const style = super.getEdgeStyle()
		const {isSelected} = this

		if (isSelected) {
			style.strokeWidth = 3
			style.stroke = "#909399"
		} else {
			style.strokeWidth = 2
			style.stroke = "#B1B3B8"
		}
		return style
	}

	setAttributes() {
		this.isAnimation = true
	}

	getEdgeAnimationStyle() {
		const style = super.getEdgeAnimationStyle()
		style.strokeDasharray = '15 5'
		style.animationDuration = '10s'
		style.stroke = '#B1B3B8'
		return style
	}
}

export class CustomLine extends PolylineEdge {

}

