1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
| import { HtmlNodeModel, HtmlNode } from '@logicflow/core'
| import { h, createApp } from 'vue'
| import BaseNode from './BaseNode'
| import styles from './index.module.scss'
| import { NODES } from '../../core/enum'
|
| interface NodeOptionType {
| icon?: string
| background?: string
| color?: string
| width?: string
| height?: string
| }
|
| export class NodeModel extends HtmlNodeModel {
| setAttributes() {
| this.text.editable = false
| const width = 206
| const height = 136
|
| this.width = width
| this.height = height
| this.anchorsOffset = [
| // [width / 2, 0], //右边
| [0, height / 2], //下边
| // [-width / 2, 0], //左边
| [0, -height / 2], //上边
| ]
| }
| }
|
| export class Node extends HtmlNode {
| [key: string]: any
| constructor(props: any, option: NodeOptionType) {
| super(props)
| const nodeProps: NodeOptionType = {
| icon: 'lightsetting',
| background: '#fff',
| color: '#000000a6',
| ...option,
| }
| this.isMounted = false
| this.app = createApp(() => {
| const { properties } = this.props.model
| return <BaseNode node={properties} {...nodeProps} type="node" />
| })
| }
|
| setHtml(rootEl: HTMLElement) {
| const dom = document.createElement('div')
| rootEl.appendChild(dom)
| if (!this.isMounted) {
| this.app.mount(dom)
| }
|
| this.isMounted = true
| }
| }
|
|