@leafer-in/editor 2.1.9 → 2.1.11
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/dist/editor.cjs +50 -63
- package/dist/editor.esm.js +50 -63
- package/dist/editor.esm.min.js +1 -1
- package/dist/editor.esm.min.js.map +1 -1
- package/dist/editor.js +50 -63
- package/dist/editor.min.cjs +1 -1
- package/dist/editor.min.cjs.map +1 -1
- package/dist/editor.min.js +1 -1
- package/dist/editor.min.js.map +1 -1
- package/package.json +6 -6
- package/src/Editor.ts +2 -4
- package/src/display/EditBox.ts +10 -6
- package/src/helper/EditDataHelper.ts +16 -38
- package/src/index.ts +6 -4
- package/src/tool/EditTool.ts +7 -7
- package/src/tool/EditToolCreator.ts +5 -0
- package/src/tool/TransformTool.ts +12 -12
- package/types/index.d.ts +7 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-in/editor",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.11",
|
|
4
4
|
"description": "@leafer-in/editor",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"leaferjs"
|
|
35
35
|
],
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@leafer-ui/draw": "^2.1.
|
|
38
|
-
"@leafer-ui/core": "^2.1.
|
|
39
|
-
"@leafer-in/resize": "^2.1.
|
|
40
|
-
"@leafer-ui/interface": "^2.1.
|
|
41
|
-
"@leafer-in/interface": "^2.1.
|
|
37
|
+
"@leafer-ui/draw": "^2.1.11",
|
|
38
|
+
"@leafer-ui/core": "^2.1.11",
|
|
39
|
+
"@leafer-in/resize": "^2.1.11",
|
|
40
|
+
"@leafer-ui/interface": "^2.1.11",
|
|
41
|
+
"@leafer-in/interface": "^2.1.11"
|
|
42
42
|
}
|
|
43
43
|
}
|
package/src/Editor.ts
CHANGED
|
@@ -199,11 +199,9 @@ export class Editor extends Group implements IEditor {
|
|
|
199
199
|
public unloadEditTool(onlyTool?: boolean): void {
|
|
200
200
|
let tool = this.editTool
|
|
201
201
|
if (tool) {
|
|
202
|
-
if (!onlyTool)
|
|
203
|
-
this.editBox.unload()
|
|
204
|
-
this.editTool = null
|
|
205
|
-
}
|
|
202
|
+
if (!onlyTool) this.editBox.unload()
|
|
206
203
|
tool.unload()
|
|
204
|
+
if (!onlyTool) this.editTool = null
|
|
207
205
|
tool.editTarget = null
|
|
208
206
|
}
|
|
209
207
|
}
|
package/src/display/EditBox.ts
CHANGED
|
@@ -165,10 +165,17 @@ export class EditBox extends Group implements IEditBox {
|
|
|
165
165
|
|
|
166
166
|
|
|
167
167
|
public updateBounds(bounds: IBoundsData): void {
|
|
168
|
-
const { editor, mergeConfig, single, rect, circle, buttons, resizePoints, rotatePoints, resizeLines } = this
|
|
168
|
+
const { editor, target, mergeConfig, single, rect, circle, buttons, resizePoints, rotatePoints, resizeLines } = this
|
|
169
169
|
const { editMask } = editor
|
|
170
170
|
const { middlePoint, resizeable, rotateable, hideOnSmall, editBox, editBoxType, mask, dimOthers, bright, spread, hideRotatePoints, hideResizeLines } = mergeConfig
|
|
171
171
|
|
|
172
|
+
if (editBoxType === 'stroke') {
|
|
173
|
+
const { scaleX, scaleY } = target.worldTransform, { strokeBoxSpread } = target.__layout
|
|
174
|
+
strokeBoxSpread && BoundsHelper.spread(bounds, [strokeBoxSpread * Math.abs(scaleY), strokeBoxSpread * Math.abs(scaleX)])
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (spread) BoundsHelper.spread(bounds, spread)
|
|
178
|
+
|
|
172
179
|
editMask.visible = mask ? true : 0
|
|
173
180
|
|
|
174
181
|
if (!isUndefined(dimOthers) || !isUndefined(bright)) { // 没有配置时不强制bright
|
|
@@ -179,9 +186,6 @@ export class EditBox extends Group implements IEditBox {
|
|
|
179
186
|
editor.cancelDimOthers()
|
|
180
187
|
}
|
|
181
188
|
|
|
182
|
-
if (editBoxType === 'stroke') BoundsHelper.spread(bounds, editor.element.__layout.strokeBoxSpread)
|
|
183
|
-
if (spread) BoundsHelper.spread(bounds, spread)
|
|
184
|
-
|
|
185
189
|
if (this.view.worldOpacity) {
|
|
186
190
|
const { width, height } = bounds
|
|
187
191
|
const smallSize = isNumber(hideOnSmall) ? hideOnSmall : 10
|
|
@@ -345,7 +349,7 @@ export class EditBox extends Group implements IEditBox {
|
|
|
345
349
|
// 操作事件共用
|
|
346
350
|
|
|
347
351
|
public onTransformStart(e: IUIEvent): void {
|
|
348
|
-
const { hideOnMove
|
|
352
|
+
const { hideOnMove } = this.mergedConfig
|
|
349
353
|
if (this.moving || this.gesturing) this.editor.opacity = hideOnMove ? 0 : 1 // move
|
|
350
354
|
if (this.resizing) ResizeEvent.resizingKeys = this.editor.leafList.keys // 记录正在resize中的元素列表
|
|
351
355
|
|
|
@@ -354,7 +358,7 @@ export class EditBox extends Group implements IEditBox {
|
|
|
354
358
|
dragStartData.y = e.y
|
|
355
359
|
dragStartData.totalOffset = getPointData() // 缩放、旋转造成的总偏移量,一般用于手势操作的move纠正
|
|
356
360
|
dragStartData.point = { x: target.x, y: target.y } // 用于移动
|
|
357
|
-
dragStartData.bounds = { ...target.getLayoutBounds(
|
|
361
|
+
dragStartData.bounds = { ...target.getLayoutBounds('box', 'local') } // 用于resize
|
|
358
362
|
dragStartData.rotation = target.rotation // 用于旋转
|
|
359
363
|
}
|
|
360
364
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IPointData, IAround, IAlign, IUI, ILayoutBoundsData
|
|
1
|
+
import { IPointData, IAround, IAlign, IUI, ILayoutBoundsData } from '@leafer-ui/interface'
|
|
2
2
|
import { AroundHelper, MathHelper, PointHelper, Direction9, isNumber } from '@leafer-ui/draw'
|
|
3
3
|
import { DragBoundsHelper } from '@leafer-ui/core'
|
|
4
4
|
|
|
@@ -10,12 +10,11 @@ const { toPoint } = AroundHelper, { within, sign } = MathHelper, { abs } = Math
|
|
|
10
10
|
|
|
11
11
|
export const EditDataHelper = {
|
|
12
12
|
|
|
13
|
-
getScaleData(target: IUI, startBounds: ILayoutBoundsData, direction: Direction9, totalMoveOrScale: IPointData | number, lockRatio: boolean | 'corner', around: IAround, flipable: boolean, scaleMode: boolean
|
|
13
|
+
getScaleData(target: IUI, startBounds: ILayoutBoundsData, direction: Direction9, totalMoveOrScale: IPointData | number, lockRatio: boolean | 'corner', around: IAround, flipable: boolean, scaleMode: boolean): IEditorScaleEvent {
|
|
14
14
|
let align: IAlign, origin = {} as IPointData, scaleX: number = 1, scaleY: number = 1, lockScale: number
|
|
15
15
|
|
|
16
16
|
const { widthRange, heightRange, dragBounds, worldTransform, boxBounds } = target
|
|
17
17
|
const { width, height } = startBounds, worldScaleX = abs(worldTransform.scaleX), worldScaleY = abs(worldTransform.scaleY)
|
|
18
|
-
const innerBounds = target.getBounds(boundsType, 'inner')
|
|
19
18
|
|
|
20
19
|
// 获取已经改变的比例
|
|
21
20
|
const originChangedScaleX = target.scaleX / startBounds.scaleX
|
|
@@ -23,8 +22,8 @@ export const EditDataHelper = {
|
|
|
23
22
|
const signX = sign(originChangedScaleX)
|
|
24
23
|
const signY = sign(originChangedScaleY)
|
|
25
24
|
|
|
26
|
-
const changedScaleX = scaleMode ? originChangedScaleX : signX *
|
|
27
|
-
const changedScaleY = scaleMode ? originChangedScaleY : signY *
|
|
25
|
+
const changedScaleX = scaleMode ? originChangedScaleX : signX * boxBounds.width / width
|
|
26
|
+
const changedScaleY = scaleMode ? originChangedScaleY : signY * boxBounds.height / height
|
|
28
27
|
|
|
29
28
|
if (isNumber(totalMoveOrScale)) {
|
|
30
29
|
|
|
@@ -112,15 +111,13 @@ export const EditDataHelper = {
|
|
|
112
111
|
if (useScaleY) scaleY /= changedScaleY
|
|
113
112
|
|
|
114
113
|
if (!flipable) {
|
|
115
|
-
if (scaleX < 0) scaleX = 1 /
|
|
116
|
-
if (scaleY < 0) scaleY = 1 /
|
|
114
|
+
if (scaleX < 0) scaleX = 1 / boxBounds.width / worldScaleX
|
|
115
|
+
if (scaleY < 0) scaleY = 1 / boxBounds.height / worldScaleY
|
|
117
116
|
}
|
|
118
117
|
|
|
119
118
|
// 检查限制
|
|
120
119
|
|
|
121
|
-
toPoint(around || align,
|
|
122
|
-
|
|
123
|
-
this.checkOrigin(target, origin, boundsType)
|
|
120
|
+
toPoint(around || align, boxBounds, origin, true)
|
|
124
121
|
|
|
125
122
|
if (dragBounds) {
|
|
126
123
|
const scaleData = { x: scaleX, y: scaleY }
|
|
@@ -130,24 +127,19 @@ export const EditDataHelper = {
|
|
|
130
127
|
}
|
|
131
128
|
|
|
132
129
|
if (useScaleX && widthRange) {
|
|
133
|
-
const nowWidth =
|
|
130
|
+
const nowWidth = boxBounds.width * target.scaleX
|
|
134
131
|
scaleX = within(nowWidth * scaleX, widthRange) / nowWidth
|
|
135
132
|
}
|
|
136
133
|
|
|
137
134
|
if (useScaleY && heightRange) {
|
|
138
|
-
const nowHeight =
|
|
135
|
+
const nowHeight = boxBounds.height * target.scaleY
|
|
139
136
|
scaleY = within(nowHeight * scaleY, heightRange) / nowHeight
|
|
140
137
|
}
|
|
141
138
|
|
|
142
139
|
// 防止小于1px, 需要考虑 editSize 的各种情况
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
if (boundsType !== 'box') {
|
|
146
|
-
minWidth += (innerBounds.width - boxBounds.width) * worldScaleX
|
|
147
|
-
minHeight += (innerBounds.height - boxBounds.height) * worldScaleY
|
|
148
|
-
}
|
|
140
|
+
const minWidth = 1, minHeight = 1
|
|
149
141
|
|
|
150
|
-
const worldWidth = worldScaleX *
|
|
142
|
+
const worldWidth = worldScaleX * boxBounds.width, worldHeight = worldScaleY * boxBounds.height
|
|
151
143
|
if (useScaleX && abs(scaleX * worldWidth) < minWidth) scaleX = sign(scaleX) * minWidth / worldWidth
|
|
152
144
|
if (useScaleY && abs(scaleY * worldHeight) < minHeight) scaleY = sign(scaleY) * minHeight / worldHeight
|
|
153
145
|
|
|
@@ -163,7 +155,7 @@ export const EditDataHelper = {
|
|
|
163
155
|
return { origin, scaleX, scaleY, direction, lockRatio, around }
|
|
164
156
|
},
|
|
165
157
|
|
|
166
|
-
getRotateData(target: IUI, direction: Direction9, current: IPointData, last: IPointData, around: IAround
|
|
158
|
+
getRotateData(target: IUI, direction: Direction9, current: IPointData, last: IPointData, around: IAround): IEditorRotateEvent {
|
|
167
159
|
let align: IAlign, origin = {} as IPointData
|
|
168
160
|
|
|
169
161
|
switch (direction) {
|
|
@@ -183,14 +175,12 @@ export const EditDataHelper = {
|
|
|
183
175
|
align = 'center'
|
|
184
176
|
}
|
|
185
177
|
|
|
186
|
-
toPoint(around || align, target.
|
|
187
|
-
|
|
188
|
-
this.checkOrigin(target, origin, boundsType)
|
|
178
|
+
toPoint(around || align, target.boxBounds, origin, true)
|
|
189
179
|
|
|
190
180
|
return { origin, rotation: PointHelper.getRotation(last, target.getWorldPointByBox(origin), current) }
|
|
191
181
|
},
|
|
192
182
|
|
|
193
|
-
getSkewData(target: IUI, direction: Direction9, move: IPointData, around: IAround
|
|
183
|
+
getSkewData(target: IUI, direction: Direction9, move: IPointData, around: IAround): IEditorSkewEvent {
|
|
194
184
|
let align: IAlign, origin = {} as IPointData, skewX = 0, skewY = 0
|
|
195
185
|
let last: IPointData
|
|
196
186
|
|
|
@@ -220,15 +210,12 @@ export const EditDataHelper = {
|
|
|
220
210
|
skewY = 1
|
|
221
211
|
}
|
|
222
212
|
|
|
223
|
-
const
|
|
224
|
-
const { width, height } = innerBounds
|
|
213
|
+
const { boxBounds } = target, { width, height } = boxBounds
|
|
225
214
|
|
|
226
215
|
last.x = last.x * width
|
|
227
216
|
last.y = last.y * height
|
|
228
217
|
|
|
229
|
-
toPoint(around || align,
|
|
230
|
-
|
|
231
|
-
this.checkOrigin(target, origin, boundsType)
|
|
218
|
+
toPoint(around || align, boxBounds, origin, true)
|
|
232
219
|
|
|
233
220
|
const rotation = PointHelper.getRotation(last, origin, { x: last.x + (skewX ? move.x : 0), y: last.y + (skewY ? move.y : 0) })
|
|
234
221
|
skewX ? skewX = -rotation : skewY = rotation
|
|
@@ -237,15 +224,6 @@ export const EditDataHelper = {
|
|
|
237
224
|
},
|
|
238
225
|
|
|
239
226
|
|
|
240
|
-
checkOrigin(target: IUI, origin: IPointData, boundsType: IBoundsType): void {
|
|
241
|
-
if (boundsType !== 'box') {
|
|
242
|
-
const { boxBounds } = target, innerBounds = target.getBounds(boundsType, 'inner')
|
|
243
|
-
origin.x += innerBounds.x - boxBounds.x
|
|
244
|
-
origin.y += innerBounds.y - boxBounds.y
|
|
245
|
-
}
|
|
246
|
-
},
|
|
247
|
-
|
|
248
|
-
|
|
249
227
|
getAround(around: IAround, altKey: boolean): IAround {
|
|
250
228
|
return (altKey && !around) ? 'center' : around
|
|
251
229
|
},
|
package/src/index.ts
CHANGED
|
@@ -27,7 +27,7 @@ export { EditDataHelper } from './helper/EditDataHelper'
|
|
|
27
27
|
export { EditSelectHelper } from './helper/EditSelectHelper'
|
|
28
28
|
|
|
29
29
|
|
|
30
|
-
import { IEditor, IEditorConfig, IEditToolFunction, IEditorConfigFunction, IApp,
|
|
30
|
+
import { IEditor, IEditorConfig, IEditToolFunction, IEditorConfigFunction, IApp, IUI } from '@leafer-in/interface'
|
|
31
31
|
import { Creator, UI, Group, Text, Box, dataType, Plugin } from '@leafer-ui/draw'
|
|
32
32
|
|
|
33
33
|
import '@leafer-in/resize'
|
|
@@ -48,10 +48,12 @@ Creator.editor = function (options?: IEditorConfig, app?: IApp): IEditor {
|
|
|
48
48
|
Box.addAttr('textBox', false, dataType)
|
|
49
49
|
|
|
50
50
|
UI.addAttr('editConfig', undefined, dataType)
|
|
51
|
-
UI.addAttr('editOuter', (ui:
|
|
51
|
+
UI.addAttr('editOuter', (ui: IUI) => {
|
|
52
52
|
ui.updateLayout() // fix: Line 需要更新布局才能精准确定
|
|
53
|
-
const
|
|
54
|
-
|
|
53
|
+
const { EditTool, LineEditTool, PointsEditTool } = EditToolCreator
|
|
54
|
+
const name = (ui.pathInputed || ui.isPointsMode) ? PointsEditTool : ui.tag + 'EditTool'
|
|
55
|
+
const hasTool = EditToolCreator.list[name]
|
|
56
|
+
return ui.__.__isLinePath && !(name == PointsEditTool && hasTool) ? LineEditTool : (hasTool ? name : EditTool)
|
|
55
57
|
}, dataType)
|
|
56
58
|
|
|
57
59
|
UI.addAttr('editInner', 'PathEditor', dataType)
|
package/src/tool/EditTool.ts
CHANGED
|
@@ -28,36 +28,36 @@ export class EditTool extends InnerEditor implements IEditTool {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
public onScale(e: IEditorScaleEvent): void {
|
|
31
|
-
const { scaleX, scaleY, transform, worldOrigin, editor
|
|
31
|
+
const { scaleX, scaleY, transform, worldOrigin, editor } = e
|
|
32
32
|
const { app, list } = editor
|
|
33
33
|
app.lockLayout()
|
|
34
34
|
list.forEach(target => {
|
|
35
35
|
const resize = editor.getEditSize(target) !== 'scale'
|
|
36
|
-
if (transform) target.transformWorld(transform, resize, false
|
|
37
|
-
else target.scaleOfWorld(worldOrigin, scaleX, scaleY, resize, false
|
|
36
|
+
if (transform) target.transformWorld(transform, resize, false)
|
|
37
|
+
else target.scaleOfWorld(worldOrigin, scaleX, scaleY, resize, false)
|
|
38
38
|
})
|
|
39
39
|
app.unlockLayout()
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
public onRotate(e: IEditorRotateEvent): void {
|
|
43
|
-
const { rotation, transform, worldOrigin, editor
|
|
43
|
+
const { rotation, transform, worldOrigin, editor } = e
|
|
44
44
|
const { app, list } = editor
|
|
45
45
|
app.lockLayout()
|
|
46
46
|
list.forEach(target => {
|
|
47
47
|
const resize = editor.getEditSize(target) !== 'scale'
|
|
48
|
-
if (transform) target.transformWorld(transform, resize, false
|
|
48
|
+
if (transform) target.transformWorld(transform, resize, false)
|
|
49
49
|
else target.rotateOfWorld(worldOrigin, rotation)
|
|
50
50
|
})
|
|
51
51
|
app.unlockLayout()
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
public onSkew(e: IEditorSkewEvent): void {
|
|
55
|
-
const { skewX, skewY, transform, worldOrigin, editor
|
|
55
|
+
const { skewX, skewY, transform, worldOrigin, editor } = e
|
|
56
56
|
const { app, list } = editor
|
|
57
57
|
app.lockLayout()
|
|
58
58
|
list.forEach(target => {
|
|
59
59
|
const resize = editor.getEditSize(target) !== 'scale'
|
|
60
|
-
if (transform) target.transformWorld(transform, resize, false
|
|
60
|
+
if (transform) target.transformWorld(transform, resize, false)
|
|
61
61
|
else target.skewOfWorld(worldOrigin, skewX, skewY, resize)
|
|
62
62
|
})
|
|
63
63
|
app.unlockLayout()
|
|
@@ -16,6 +16,11 @@ export const registerInnerEditor = registerEditTool
|
|
|
16
16
|
|
|
17
17
|
export const EditToolCreator = {
|
|
18
18
|
|
|
19
|
+
// 默认名称
|
|
20
|
+
EditTool: 'EditTool',
|
|
21
|
+
LineEditTool: 'LineEditTool',
|
|
22
|
+
PointsEditTool: 'PointsEditTool',
|
|
23
|
+
|
|
19
24
|
list: {} as IObject,
|
|
20
25
|
|
|
21
26
|
register(EditTool: IObject, name?: string): void {
|
|
@@ -54,7 +54,7 @@ export class TransformTool implements ITransformTool { // Editor use
|
|
|
54
54
|
public onScale(e: DragEvent | ZoomEvent): void {
|
|
55
55
|
|
|
56
56
|
const { target, mergeConfig, single, dragStartData } = this.editBox
|
|
57
|
-
let { around, lockRatio, flipable, editSize
|
|
57
|
+
let { around, lockRatio, flipable, editSize } = mergeConfig, totalMove: IPointData | number
|
|
58
58
|
|
|
59
59
|
if (e instanceof ZoomEvent) {
|
|
60
60
|
if (!around) around = target.getBoxPoint(e)
|
|
@@ -66,7 +66,7 @@ export class TransformTool implements ITransformTool { // Editor use
|
|
|
66
66
|
const { direction } = e.current as IEditPoint
|
|
67
67
|
if (e.shiftKey || target.lockRatio) lockRatio = true
|
|
68
68
|
|
|
69
|
-
const data = EditDataHelper.getScaleData(target, dragStartData.bounds, direction, totalMove, lockRatio, EditDataHelper.getAround(around, e.altKey), flipable, !single || editSize === 'scale'
|
|
69
|
+
const data = EditDataHelper.getScaleData(target, dragStartData.bounds, direction, totalMove, lockRatio, EditDataHelper.getAround(around, e.altKey), flipable, !single || editSize === 'scale')
|
|
70
70
|
|
|
71
71
|
const targetX = target.x, targetY = target.y
|
|
72
72
|
|
|
@@ -83,7 +83,7 @@ export class TransformTool implements ITransformTool { // Editor use
|
|
|
83
83
|
public onRotate(e: DragEvent | RotateEvent): void {
|
|
84
84
|
|
|
85
85
|
const { target, mergeConfig, dragStartData } = this.editBox
|
|
86
|
-
const { around, rotateAround, rotateGap, diagonalRotateKey
|
|
86
|
+
const { around, rotateAround, rotateGap, diagonalRotateKey } = mergeConfig
|
|
87
87
|
const { direction } = e.current as IEditPoint
|
|
88
88
|
|
|
89
89
|
let origin: IPointData, rotation: number
|
|
@@ -97,7 +97,7 @@ export class TransformTool implements ITransformTool { // Editor use
|
|
|
97
97
|
|
|
98
98
|
const isDiagonalRotate = diagonalRotateKey ? e.isHoldKeys(diagonalRotateKey) : e.shiftKey // 对角旋转
|
|
99
99
|
|
|
100
|
-
const data = EditDataHelper.getRotateData(target, direction, e, dragStartData, isDiagonalRotate ? null : (rotateAround || target.around || target.origin || around || 'center')
|
|
100
|
+
const data = EditDataHelper.getRotateData(target, direction, e, dragStartData, isDiagonalRotate ? null : (rotateAround || target.around || target.origin || around || 'center'))
|
|
101
101
|
rotation = dragStartData.rotation + data.rotation - target.rotation
|
|
102
102
|
origin = data.origin
|
|
103
103
|
|
|
@@ -116,9 +116,9 @@ export class TransformTool implements ITransformTool { // Editor use
|
|
|
116
116
|
public onSkew(e: DragEvent): void {
|
|
117
117
|
|
|
118
118
|
const { target, mergeConfig } = this.editBox
|
|
119
|
-
const { around
|
|
119
|
+
const { around } = mergeConfig
|
|
120
120
|
|
|
121
|
-
const { origin, skewX, skewY } = EditDataHelper.getSkewData(target, (e.current as IEditPoint).direction, e.getInnerMove(target), EditDataHelper.getAround(around, e.altKey)
|
|
121
|
+
const { origin, skewX, skewY } = EditDataHelper.getSkewData(target, (e.current as IEditPoint).direction, e.getInnerMove(target), EditDataHelper.getAround(around, e.altKey))
|
|
122
122
|
if (!skewX && !skewY) return
|
|
123
123
|
|
|
124
124
|
this.skewOf(origin, skewX, skewY)
|
|
@@ -173,7 +173,7 @@ export class TransformTool implements ITransformTool { // Editor use
|
|
|
173
173
|
|
|
174
174
|
const { target, mergeConfig, single, editor } = this.editBox
|
|
175
175
|
|
|
176
|
-
const { beforeScale
|
|
176
|
+
const { beforeScale } = mergeConfig
|
|
177
177
|
if (beforeScale) {
|
|
178
178
|
const check = beforeScale({ target, origin, scaleX, scaleY })
|
|
179
179
|
if (isObject(check)) scaleX = check.scaleX, scaleY = check.scaleY
|
|
@@ -182,7 +182,7 @@ export class TransformTool implements ITransformTool { // Editor use
|
|
|
182
182
|
|
|
183
183
|
const worldOrigin = this.getWorldOrigin(origin)
|
|
184
184
|
const transform = !single && this.getChangedTransform(() => (target as ISimulateElement).safeChange(() => target.scaleOf(origin, scaleX, scaleY)))
|
|
185
|
-
const data: IEditorScaleEvent = { target, editor, worldOrigin, scaleX, scaleY, transform
|
|
185
|
+
const data: IEditorScaleEvent = { target, editor, worldOrigin, scaleX, scaleY, transform }
|
|
186
186
|
|
|
187
187
|
this.emitEvent(new EditorScaleEvent(EditorScaleEvent.BEFORE_SCALE, data))
|
|
188
188
|
const event = new EditorScaleEvent(EditorScaleEvent.SCALE, data)
|
|
@@ -210,7 +210,7 @@ export class TransformTool implements ITransformTool { // Editor use
|
|
|
210
210
|
|
|
211
211
|
const { target, mergeConfig, single, editor } = this.editBox
|
|
212
212
|
|
|
213
|
-
const { beforeRotate
|
|
213
|
+
const { beforeRotate } = mergeConfig
|
|
214
214
|
if (beforeRotate) {
|
|
215
215
|
const check = beforeRotate({ target, origin, rotation })
|
|
216
216
|
if (isNumber(check)) rotation = check
|
|
@@ -219,7 +219,7 @@ export class TransformTool implements ITransformTool { // Editor use
|
|
|
219
219
|
|
|
220
220
|
const worldOrigin = this.getWorldOrigin(origin)
|
|
221
221
|
const transform = !single && this.getChangedTransform(() => (target as ISimulateElement).safeChange(() => target.rotateOf(origin, rotation)))
|
|
222
|
-
const data: IEditorRotateEvent = { target, editor, worldOrigin, rotation, transform
|
|
222
|
+
const data: IEditorRotateEvent = { target, editor, worldOrigin, rotation, transform }
|
|
223
223
|
|
|
224
224
|
this.emitEvent(new EditorRotateEvent(EditorRotateEvent.BEFORE_ROTATE, data))
|
|
225
225
|
const event = new EditorRotateEvent(EditorRotateEvent.ROTATE, data)
|
|
@@ -232,7 +232,7 @@ export class TransformTool implements ITransformTool { // Editor use
|
|
|
232
232
|
|
|
233
233
|
const { target, mergeConfig, single, editor } = this.editBox
|
|
234
234
|
|
|
235
|
-
const { beforeSkew
|
|
235
|
+
const { beforeSkew } = mergeConfig
|
|
236
236
|
if (beforeSkew) {
|
|
237
237
|
const check = beforeSkew({ target, origin, skewX, skewY })
|
|
238
238
|
if (isObject(check)) skewX = check.skewX, skewY = check.skewY
|
|
@@ -241,7 +241,7 @@ export class TransformTool implements ITransformTool { // Editor use
|
|
|
241
241
|
|
|
242
242
|
const worldOrigin = this.getWorldOrigin(origin)
|
|
243
243
|
const transform = !single && this.getChangedTransform(() => (target as ISimulateElement).safeChange(() => target.skewOf(origin, skewX, skewY)))
|
|
244
|
-
const data: IEditorSkewEvent = { target, editor, worldOrigin, skewX, skewY, transform
|
|
244
|
+
const data: IEditorSkewEvent = { target, editor, worldOrigin, skewX, skewY, transform }
|
|
245
245
|
|
|
246
246
|
this.emitEvent(new EditorSkewEvent(EditorSkewEvent.BEFORE_SKEW, data))
|
|
247
247
|
const event = new EditorSkewEvent(EditorSkewEvent.SKEW, data)
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _leafer_ui_interface from '@leafer-ui/interface';
|
|
2
|
-
import { IBounds, ILeafList, IUI, IFunction, IEventListenerId, ILeaf, IPointerEvent, ILeaferCanvas, IRenderOptions, IGroup, IObject, IGroupInputData, IEditSize, IPointData, IAlign, IAxis, IMatrix, IApp, IEditorDragStartData, IEditorConfig as IEditorConfig$1, ITransformTool, IBoundsData, IBoxInputData, IUIEvent, IKeyEvent, IRect, IRectInputData, IUIInputData, IMatrixData, IDragEvent, IAround, IEvent, ILayoutBoundsData
|
|
2
|
+
import { IBounds, ILeafList, IUI, IFunction, IEventListenerId, ILeaf, IPointerEvent, ILeaferCanvas, IRenderOptions, IGroup, IObject, IGroupInputData, IEditSize, IPointData, IAlign, IAxis, IMatrix, IApp, IEditorDragStartData, IEditorConfig as IEditorConfig$1, ITransformTool, IBoundsData, IBoxInputData, IUIEvent, IKeyEvent, IRect, IRectInputData, IUIInputData, IMatrixData, IDragEvent, IAround, IEvent, ILayoutBoundsData } from '@leafer-ui/interface';
|
|
3
3
|
import { Group, UI, Direction9, Box, Event } from '@leafer-ui/draw';
|
|
4
4
|
import { PointerEvent, DragEvent, MoveEvent, ZoomEvent, RotateEvent, KeyEvent } from '@leafer-ui/core';
|
|
5
5
|
import { IEditSelect, IEditor, IStroker, ISelectArea, IEditorConfig, IEditPoint, ISimulateElement, IEditBox, IEditTool, IInnerEditor, IEditorScaleEvent, IEditPointType, IEditPointInputData, IEditorEvent, IEditorMoveEvent, IEditorRotateEvent, IEditorSkewEvent, IEditorGroupEvent, IInnerEditorEvent, IInnerEditorMode, IUI as IUI$1, IDragEvent as IDragEvent$1, IPointData as IPointData$1, IPathCommandData, IFromToData, IAround as IAround$1 } from '@leafer-in/interface';
|
|
@@ -312,6 +312,9 @@ declare class InnerEditorEvent extends EditorEvent implements IInnerEditorEvent
|
|
|
312
312
|
declare function registerEditTool(): (target: IObject) => void;
|
|
313
313
|
declare const registerInnerEditor: typeof registerEditTool;
|
|
314
314
|
declare const EditToolCreator: {
|
|
315
|
+
EditTool: string;
|
|
316
|
+
LineEditTool: string;
|
|
317
|
+
PointsEditTool: string;
|
|
315
318
|
list: IObject;
|
|
316
319
|
register(EditTool: IObject, name?: string): void;
|
|
317
320
|
get(tag: string, editor: IEditor): IEditTool;
|
|
@@ -398,10 +401,9 @@ declare const EditorHelper: {
|
|
|
398
401
|
};
|
|
399
402
|
|
|
400
403
|
declare const EditDataHelper: {
|
|
401
|
-
getScaleData(target: IUI, startBounds: ILayoutBoundsData, direction: Direction9, totalMoveOrScale: IPointData | number, lockRatio: boolean | "corner", around: IAround, flipable: boolean, scaleMode: boolean
|
|
402
|
-
getRotateData(target: IUI, direction: Direction9, current: IPointData, last: IPointData, around: IAround
|
|
403
|
-
getSkewData(target: IUI, direction: Direction9, move: IPointData, around: IAround
|
|
404
|
-
checkOrigin(target: IUI, origin: IPointData, boundsType: IBoundsType): void;
|
|
404
|
+
getScaleData(target: IUI, startBounds: ILayoutBoundsData, direction: Direction9, totalMoveOrScale: IPointData | number, lockRatio: boolean | "corner", around: IAround, flipable: boolean, scaleMode: boolean): IEditorScaleEvent;
|
|
405
|
+
getRotateData(target: IUI, direction: Direction9, current: IPointData, last: IPointData, around: IAround): IEditorRotateEvent;
|
|
406
|
+
getSkewData(target: IUI, direction: Direction9, move: IPointData, around: IAround): IEditorSkewEvent;
|
|
405
407
|
getAround(around: IAround, altKey: boolean): IAround;
|
|
406
408
|
getRotateDirection(direction: number, rotation: number, totalDirection?: number): number;
|
|
407
409
|
getFlipDirection(direction: Direction9, flipedX: boolean, flipedY: boolean): Direction9;
|