@logicflow/core 2.2.0-alpha.7 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -1
- package/.turbo/turbo-build$colon$dev.log +0 -10
- package/.turbo/turbo-build.log +0 -33
- package/CHANGELOG.md +0 -1901
- package/__tests__/algorithm/egde.test.ts +0 -131
- package/__tests__/algorithm/index.test.ts +0 -74
- package/__tests__/algorithm/outline.test.ts +0 -43
- package/__tests__/bugs/1545-spec.test.ts +0 -42
- package/__tests__/event/event.test.ts +0 -22
- package/__tests__/history/history.test.ts +0 -28
- package/__tests__/logicflow.test.ts +0 -575
- package/__tests__/model/graphmodel.test.ts +0 -87
- package/__tests__/util/compatible.test.ts +0 -48
- package/__tests__/util/edge.test.ts +0 -224
- package/__tests__/util/geometry.test.ts +0 -14
- package/__tests__/util/graph.test.ts +0 -16
- package/__tests__/util/matrix.test.ts +0 -41
- package/__tests__/util/node.test.ts +0 -68
- package/__tests__/util/sampling.test.ts +0 -12
- package/__tests__/util/vector.test.ts +0 -50
- package/__tests__/util/zIndex.test.ts +0 -10
- package/src/LogicFlow.tsx +0 -2017
- package/src/algorithm/edge.ts +0 -67
- package/src/algorithm/index.ts +0 -70
- package/src/algorithm/outline.ts +0 -77
- package/src/algorithm/rotate.ts +0 -55
- package/src/common/drag.ts +0 -219
- package/src/common/history.ts +0 -108
- package/src/common/index.ts +0 -6
- package/src/common/keyboard.ts +0 -108
- package/src/common/matrix.ts +0 -122
- package/src/common/vector.ts +0 -93
- package/src/constant/index.ts +0 -179
- package/src/constant/theme.ts +0 -708
- package/src/event/event.md +0 -66
- package/src/event/eventArgs.ts +0 -643
- package/src/event/eventEmitter.ts +0 -156
- package/src/history/index.ts +0 -119
- package/src/index.less +0 -1
- package/src/index.ts +0 -26
- package/src/keyboard/index.ts +0 -112
- package/src/keyboard/shortcut.ts +0 -200
- package/src/model/BaseModel.ts +0 -250
- package/src/model/EditConfigModel.ts +0 -334
- package/src/model/GraphModel.ts +0 -1824
- package/src/model/NestedTransformModel.ts +0 -121
- package/src/model/SnaplineModel.ts +0 -256
- package/src/model/TransformModel.ts +0 -258
- package/src/model/edge/BaseEdgeModel.ts +0 -785
- package/src/model/edge/BezierEdgeModel.ts +0 -197
- package/src/model/edge/LineEdgeModel.ts +0 -36
- package/src/model/edge/PolylineEdgeModel.ts +0 -817
- package/src/model/edge/index.ts +0 -4
- package/src/model/index.ts +0 -9
- package/src/model/node/BaseNodeModel.ts +0 -959
- package/src/model/node/CircleNodeModel.ts +0 -91
- package/src/model/node/DiamondNodeModel.ts +0 -132
- package/src/model/node/EllipseNodeModel.ts +0 -98
- package/src/model/node/HtmlNodeModel.ts +0 -64
- package/src/model/node/PolygonNodeModel.ts +0 -152
- package/src/model/node/RectNodeModel.ts +0 -69
- package/src/model/node/TextNodeModel.ts +0 -54
- package/src/model/node/index.ts +0 -8
- package/src/options.ts +0 -150
- package/src/style/index.less +0 -262
- package/src/style/raw.ts +0 -221
- package/src/tool/MultipleSelectTool.tsx +0 -140
- package/src/tool/TextEditTool.tsx +0 -193
- package/src/tool/index.ts +0 -101
- package/src/typings.d.ts +0 -5
- package/src/util/animation.ts +0 -29
- package/src/util/browser.ts +0 -4
- package/src/util/compatible.ts +0 -15
- package/src/util/drag.ts +0 -219
- package/src/util/edge.ts +0 -1094
- package/src/util/geometry.ts +0 -154
- package/src/util/graph.ts +0 -46
- package/src/util/index.ts +0 -17
- package/src/util/matrix.ts +0 -129
- package/src/util/mobx.ts +0 -23
- package/src/util/node.ts +0 -543
- package/src/util/raf.ts +0 -28
- package/src/util/resize.ts +0 -606
- package/src/util/sampling.ts +0 -85
- package/src/util/theme.ts +0 -84
- package/src/util/uuid.ts +0 -26
- package/src/util/vector.ts +0 -93
- package/src/util/zIndex.ts +0 -6
- package/src/view/Anchor.tsx +0 -462
- package/src/view/Control.tsx +0 -510
- package/src/view/Graph.tsx +0 -141
- package/src/view/Rotate.tsx +0 -113
- package/src/view/behavior/dnd.ts +0 -162
- package/src/view/behavior/index.ts +0 -2
- package/src/view/behavior/snapline.ts +0 -16
- package/src/view/edge/AdjustPoint.tsx +0 -425
- package/src/view/edge/Arrow.tsx +0 -54
- package/src/view/edge/BaseEdge.tsx +0 -660
- package/src/view/edge/BezierEdge.tsx +0 -101
- package/src/view/edge/LineEdge.tsx +0 -81
- package/src/view/edge/PolylineEdge.tsx +0 -311
- package/src/view/edge/index.ts +0 -6
- package/src/view/index.ts +0 -8
- package/src/view/node/BaseNode.tsx +0 -585
- package/src/view/node/CircleNode.tsx +0 -21
- package/src/view/node/DiamondNode.tsx +0 -24
- package/src/view/node/EllipseNode.tsx +0 -22
- package/src/view/node/HtmlNode.tsx +0 -112
- package/src/view/node/PolygonNode.tsx +0 -28
- package/src/view/node/RectNode.tsx +0 -30
- package/src/view/node/TextNode.tsx +0 -39
- package/src/view/node/index.ts +0 -8
- package/src/view/overlay/BackgroundOverlay.tsx +0 -34
- package/src/view/overlay/BezierAdjustOverlay.tsx +0 -150
- package/src/view/overlay/CanvasOverlay.tsx +0 -290
- package/src/view/overlay/Grid.tsx +0 -319
- package/src/view/overlay/ModificationOverlay.tsx +0 -31
- package/src/view/overlay/OutlineOverlay.tsx +0 -158
- package/src/view/overlay/SnaplineOverlay.tsx +0 -44
- package/src/view/overlay/ToolOverlay.tsx +0 -65
- package/src/view/overlay/getTransformHoc.tsx +0 -50
- package/src/view/overlay/gridConfig.ts +0 -103
- package/src/view/overlay/index.ts +0 -8
- package/src/view/shape/Circle.tsx +0 -41
- package/src/view/shape/Ellipse.tsx +0 -42
- package/src/view/shape/Line.tsx +0 -39
- package/src/view/shape/Path.tsx +0 -22
- package/src/view/shape/Polygon.tsx +0 -54
- package/src/view/shape/Polyline.tsx +0 -31
- package/src/view/shape/Rect.tsx +0 -44
- package/src/view/shape/Text.tsx +0 -168
- package/src/view/shape/index.ts +0 -8
- package/src/view/text/BaseText.tsx +0 -134
- package/src/view/text/LineText.tsx +0 -168
- package/src/view/text/index.ts +0 -2
- package/stats.html +0 -4842
- package/tsconfig.json +0 -18
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
import { createElement as h } from 'preact/compat'
|
|
2
|
-
import { Text, ITextProps, Rect, IRectProps } from '..'
|
|
3
|
-
import { BaseText } from '.'
|
|
4
|
-
import { BaseEdgeModel, GraphModel } from '../../model'
|
|
5
|
-
import { getHtmlTextHeight, getSvgTextSize } from '../../util'
|
|
6
|
-
|
|
7
|
-
export type ILineTextProps = {
|
|
8
|
-
model: BaseEdgeModel
|
|
9
|
-
graphModel: GraphModel
|
|
10
|
-
draggable: boolean
|
|
11
|
-
editable: boolean
|
|
12
|
-
[key: string]: unknown
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export type ILineTextState = {
|
|
16
|
-
isHovered: boolean
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export class LineText extends BaseText<ILineTextProps, ILineTextState> {
|
|
20
|
-
constructor(props: ILineTextProps) {
|
|
21
|
-
super(props)
|
|
22
|
-
this.state = {
|
|
23
|
-
isHovered: false,
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Hover 状态相关
|
|
28
|
-
setHoverOn = () => {
|
|
29
|
-
this.setState({
|
|
30
|
-
isHovered: true,
|
|
31
|
-
})
|
|
32
|
-
}
|
|
33
|
-
setHoverOff = () => {
|
|
34
|
-
this.setState({
|
|
35
|
-
isHovered: false,
|
|
36
|
-
})
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
getBackground(): h.JSX.Element | null {
|
|
40
|
-
const { isHovered } = this.state
|
|
41
|
-
const { model } = this.props
|
|
42
|
-
const { text } = model
|
|
43
|
-
const style = model.getTextStyle()
|
|
44
|
-
|
|
45
|
-
let backgroundStyle = style.background || {}
|
|
46
|
-
if (isHovered && style.hover && style.hover.background) {
|
|
47
|
-
backgroundStyle = { ...backgroundStyle, ...style.hover.background }
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// 当存在文本并且文本背景不为透明时,计算背景框
|
|
51
|
-
if (text?.value && backgroundStyle?.fill !== 'transparent') {
|
|
52
|
-
const { fontSize, textWidth, lineHeight, overflowMode } = style
|
|
53
|
-
const { wrapPadding } = backgroundStyle
|
|
54
|
-
const rows = text?.value.split(/[\r\n]/g)
|
|
55
|
-
const rowsLength = rows.length
|
|
56
|
-
|
|
57
|
-
let { x, y } = text
|
|
58
|
-
let rectAttr: unknown = {}
|
|
59
|
-
|
|
60
|
-
if (overflowMode === 'autoWrap' && textWidth) {
|
|
61
|
-
const textHeight = getHtmlTextHeight({
|
|
62
|
-
rows,
|
|
63
|
-
style: {
|
|
64
|
-
fontSize: `${fontSize}px`,
|
|
65
|
-
width: `${textWidth}px`,
|
|
66
|
-
lineHeight,
|
|
67
|
-
padding: wrapPadding,
|
|
68
|
-
},
|
|
69
|
-
rowsLength,
|
|
70
|
-
className: 'lf-get-text-height',
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
rectAttr = {
|
|
74
|
-
...backgroundStyle,
|
|
75
|
-
x,
|
|
76
|
-
y,
|
|
77
|
-
width: textWidth,
|
|
78
|
-
height: textHeight,
|
|
79
|
-
}
|
|
80
|
-
} else {
|
|
81
|
-
// 背景框宽度,最长一行字节数 / 2 * fontSize + 2
|
|
82
|
-
// 背景框宽度,行数 * fontSize + 2
|
|
83
|
-
let { width, height } = getSvgTextSize({ rows, rowsLength, fontSize })
|
|
84
|
-
if (overflowMode === 'ellipsis') {
|
|
85
|
-
// https://github.com/didi/LogicFlow/issues/1151
|
|
86
|
-
// 边上的文字过长(使用"ellipsis"模式)出现省略号,背景也需要进行宽度的重新计算
|
|
87
|
-
|
|
88
|
-
// 跟Text.tsx保持同样的计算逻辑(overflowMode === 'ellipsis')
|
|
89
|
-
// Text.tsx使用textRealWidth=textWidth || width
|
|
90
|
-
// Text.tsx使用foreignObjectHeight = fontSize + 2;
|
|
91
|
-
width = textWidth
|
|
92
|
-
height = fontSize + 2
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// 根据设置的 padding 调整 width, height, x, y 的值
|
|
96
|
-
// TODO: 下面方法感觉可以提取成工具方法
|
|
97
|
-
if (typeof backgroundStyle.wrapPadding === 'string') {
|
|
98
|
-
let padding = backgroundStyle.wrapPadding
|
|
99
|
-
.split(',')
|
|
100
|
-
.filter((padding) => padding.trim())
|
|
101
|
-
.map((padding) => parseFloat(padding.trim()))
|
|
102
|
-
|
|
103
|
-
if (padding.length > 0 && padding.length <= 4) {
|
|
104
|
-
if (padding.length === 1) {
|
|
105
|
-
const [allSides] = padding
|
|
106
|
-
padding = [allSides, allSides, allSides, allSides]
|
|
107
|
-
} else if (padding.length === 2) {
|
|
108
|
-
const [vertical, horizontal] = padding
|
|
109
|
-
padding = [vertical, horizontal, vertical, horizontal]
|
|
110
|
-
} else if (padding.length === 3) {
|
|
111
|
-
const [top, horizontal, bottom] = padding
|
|
112
|
-
padding = [top, horizontal, bottom, horizontal]
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const [top, right, bottom, left] = padding
|
|
116
|
-
width += right + left
|
|
117
|
-
height += top + bottom
|
|
118
|
-
x = x + (right - left) / 2
|
|
119
|
-
y = y + (bottom - top) / 2
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
rectAttr = {
|
|
124
|
-
...backgroundStyle,
|
|
125
|
-
x: x - 1,
|
|
126
|
-
y: y - 1,
|
|
127
|
-
width,
|
|
128
|
-
height,
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
return <Rect {...(rectAttr as IRectProps)} />
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return null
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
getShape(): h.JSX.Element | null {
|
|
139
|
-
const { model } = this.props
|
|
140
|
-
const {
|
|
141
|
-
text: { x, y, value },
|
|
142
|
-
} = model
|
|
143
|
-
if (!value) return null
|
|
144
|
-
|
|
145
|
-
const style = model.getTextStyle()
|
|
146
|
-
const attrs: ITextProps = {
|
|
147
|
-
x,
|
|
148
|
-
y,
|
|
149
|
-
value,
|
|
150
|
-
model,
|
|
151
|
-
className: 'lf-element-text',
|
|
152
|
-
...style, // 透传 edgeText 属性,如:color, fontSize, fontWeight, fontFamily, textAnchor 等
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
return (
|
|
156
|
-
<g
|
|
157
|
-
className="lf-line-text"
|
|
158
|
-
onMouseEnter={this.setHoverOn}
|
|
159
|
-
onMouseLeave={this.setHoverOff}
|
|
160
|
-
>
|
|
161
|
-
{this.getBackground()}
|
|
162
|
-
<Text {...attrs} />
|
|
163
|
-
</g>
|
|
164
|
-
)
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
export default LineText
|
package/src/view/text/index.ts
DELETED