@leafer-in/editor 2.0.2 → 2.0.4
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 +30 -14
- package/dist/editor.esm.js +30 -14
- package/dist/editor.esm.min.js +1 -1
- package/dist/editor.esm.min.js.map +1 -1
- package/dist/editor.js +30 -14
- 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 -0
- package/src/config.ts +3 -0
- package/src/decorator/data.ts +10 -3
- package/src/display/EditBox.ts +23 -12
- package/src/tool/InnerEditor.ts +3 -1
- package/types/index.d.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-in/editor",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
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.0.
|
|
38
|
-
"@leafer-ui/core": "^2.0.
|
|
39
|
-
"@leafer-in/resize": "^2.0.
|
|
40
|
-
"@leafer-ui/interface": "^2.0.
|
|
41
|
-
"@leafer-in/interface": "^2.0.
|
|
37
|
+
"@leafer-ui/draw": "^2.0.4",
|
|
38
|
+
"@leafer-ui/core": "^2.0.4",
|
|
39
|
+
"@leafer-in/resize": "^2.0.4",
|
|
40
|
+
"@leafer-ui/interface": "^2.0.4",
|
|
41
|
+
"@leafer-in/interface": "^2.0.4"
|
|
42
42
|
}
|
|
43
43
|
}
|
package/src/Editor.ts
CHANGED
|
@@ -80,6 +80,8 @@ export class Editor extends Group implements IEditor {
|
|
|
80
80
|
public selector: EditSelect = new EditSelect(this)
|
|
81
81
|
public editMask: EditMask = new EditMask(this)
|
|
82
82
|
|
|
83
|
+
public hasDimOthers?: boolean
|
|
84
|
+
|
|
83
85
|
public get targetLeafer() { const first = this.list[0]; return first && first.leafer }
|
|
84
86
|
public targetChanged: boolean
|
|
85
87
|
public targetEventIds: IEventListenerId[] = []
|
package/src/config.ts
CHANGED
package/src/decorator/data.ts
CHANGED
|
@@ -28,8 +28,11 @@ export function targetAttr(fn: IFunction) {
|
|
|
28
28
|
else if (check === false) return
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
t.
|
|
32
|
-
|
|
31
|
+
if (t.hasDimOthers) {
|
|
32
|
+
t.setDimOthers(false)
|
|
33
|
+
t.setBright(false)
|
|
34
|
+
t.hasDimOthers = undefined
|
|
35
|
+
}
|
|
33
36
|
|
|
34
37
|
if (isArray(value) && value.length > 1 && value[0].locked) value.splice(0, 1) // fix: 单个锁定 + shift多选
|
|
35
38
|
if (t.single) {
|
|
@@ -54,7 +57,11 @@ export function mergeConfigAttr() {
|
|
|
54
57
|
return (target: IEditor, key: string) => {
|
|
55
58
|
defineKey(target, key, {
|
|
56
59
|
get() {
|
|
57
|
-
const { config, element, dragPoint, editBox, app } = this, mergeConfig = { ...config } // 实时合并,后期可优化
|
|
60
|
+
const { config, element, dragPoint, editBox, editTool, innerEditor, app } = this, mergeConfig = { ...config } // 实时合并,后期可优化
|
|
61
|
+
|
|
62
|
+
if (innerEditor) innerEditor.editConfig && Object.assign(mergeConfig, innerEditor.editConfig) // innerEditor 上的配置
|
|
63
|
+
else if (editTool) editTool.editConfig && Object.assign(mergeConfig, editTool.editConfig) // editTool 上的配置
|
|
64
|
+
|
|
58
65
|
if (element && element.editConfig) {
|
|
59
66
|
let { editConfig } = element
|
|
60
67
|
if (editConfig.hover || editConfig.hoverStyle) { // 元素的hover样式,不能覆盖到总配置里
|
package/src/display/EditBox.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IRect, IEventListenerId, IBoundsData, IPointData, IKeyEvent, IGroup, IBox, IBoxInputData, IAlign, IUI, IEditorConfig, IEditorDragStartData, ITransformTool, IUIEvent, IEditPointInputData } from '@leafer-ui/interface'
|
|
2
|
-
import { Group, Text, AroundHelper, Direction9, ResizeEvent, BoundsHelper, DataHelper, isArray, isString, isNumber, isNull, getPointData } from '@leafer-ui/draw'
|
|
2
|
+
import { Group, Text, AroundHelper, Direction9, ResizeEvent, BoundsHelper, DataHelper, isArray, isString, isNumber, isNull, getPointData, isUndefined } from '@leafer-ui/draw'
|
|
3
3
|
import { DragEvent, PointerEvent, KeyEvent, RotateEvent, ZoomEvent, MoveEvent } from '@leafer-ui/core'
|
|
4
4
|
|
|
5
5
|
import { IEditBox, IEditor, IEditPoint, IEditPointType } from '@leafer-in/interface'
|
|
@@ -171,8 +171,11 @@ export class EditBox extends Group implements IEditBox {
|
|
|
171
171
|
|
|
172
172
|
editMask.visible = mask ? true : 0
|
|
173
173
|
|
|
174
|
-
|
|
175
|
-
|
|
174
|
+
if (!isUndefined(dimOthers) || !isUndefined(bright)) { // 没有配置时不强制bright
|
|
175
|
+
editor.setDimOthers(dimOthers)
|
|
176
|
+
editor.setBright(!!dimOthers || bright)
|
|
177
|
+
editor.hasDimOthers = true
|
|
178
|
+
}
|
|
176
179
|
|
|
177
180
|
if (spread) BoundsHelper.spread(bounds, spread)
|
|
178
181
|
|
|
@@ -201,7 +204,8 @@ export class EditBox extends Group implements IEditBox {
|
|
|
201
204
|
resizeL.set(point)
|
|
202
205
|
|
|
203
206
|
resizeL.visible = resizeP.visible && !hideResizeLines
|
|
204
|
-
resizeP.visible
|
|
207
|
+
if (resizeP.visible) resizeP.visible = !!middlePoint
|
|
208
|
+
if (rotateP.visible) rotateP.visible = !!middlePoint
|
|
205
209
|
|
|
206
210
|
if (((i + 1) / 2) % 2) { // top, bottom
|
|
207
211
|
resizeL.width = width + resizeL.height
|
|
@@ -297,10 +301,12 @@ export class EditBox extends Group implements IEditBox {
|
|
|
297
301
|
public onDragStart(e: DragEvent): void {
|
|
298
302
|
this.dragging = true
|
|
299
303
|
const point = this.dragPoint = e.current as IEditPoint, { pointType } = point
|
|
300
|
-
const { moveable, resizeable, rotateable, skewable } = this.mergeConfig
|
|
304
|
+
const { moveable, resizeable, rotateable, skewable, onCopy } = this.mergeConfig
|
|
301
305
|
|
|
302
306
|
// 确定模式
|
|
303
307
|
if (pointType === 'move') {
|
|
308
|
+
// alt复制钩子
|
|
309
|
+
if (e.altKey && onCopy && onCopy() && this.editor.single) this.app.interaction.replaceDownTarget(this.target)
|
|
304
310
|
moveable && (this.moving = true)
|
|
305
311
|
} else {
|
|
306
312
|
if (pointType.includes('rotate') || this.isHoldRotateKey(e) || !resizeable) {
|
|
@@ -414,23 +420,28 @@ export class EditBox extends Group implements IEditBox {
|
|
|
414
420
|
}
|
|
415
421
|
|
|
416
422
|
public onArrow(e: IKeyEvent): void {
|
|
417
|
-
if (this.canUse
|
|
423
|
+
if (this.canUse) {
|
|
418
424
|
let x = 0, y = 0
|
|
419
|
-
const distance = e.shiftKey ? 10 : 1
|
|
420
425
|
switch (e.code) {
|
|
421
426
|
case 'ArrowDown':
|
|
422
|
-
y =
|
|
427
|
+
y = 1
|
|
423
428
|
break
|
|
424
429
|
case 'ArrowUp':
|
|
425
|
-
y = -
|
|
430
|
+
y = -1
|
|
426
431
|
break
|
|
427
432
|
case 'ArrowLeft':
|
|
428
|
-
x = -
|
|
433
|
+
x = -1
|
|
429
434
|
break
|
|
430
435
|
case 'ArrowRight':
|
|
431
|
-
x =
|
|
436
|
+
x = 1
|
|
437
|
+
}
|
|
438
|
+
if (x || y) {
|
|
439
|
+
const { keyEvent, arrowStep, arrowFastStep } = this.mergeConfig
|
|
440
|
+
if (keyEvent) {
|
|
441
|
+
const step = e.shiftKey ? arrowFastStep : arrowStep
|
|
442
|
+
this.transformTool.move(x * step, y * step)
|
|
443
|
+
}
|
|
432
444
|
}
|
|
433
|
-
if (x || y) this.transformTool.move(x, y)
|
|
434
445
|
}
|
|
435
446
|
}
|
|
436
447
|
|
package/src/tool/InnerEditor.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { IGroup, IEventListenerId, IUI, IObject } from '@leafer-ui/interface'
|
|
1
|
+
import { IGroup, IEventListenerId, IUI, IObject, IEditorConfig } from '@leafer-ui/interface'
|
|
2
2
|
import { IInnerEditor, IEditor, IEditBox, IInnerEditorMode } from '@leafer-in/interface'
|
|
3
3
|
|
|
4
4
|
import { Group } from '@leafer-ui/draw'
|
|
@@ -19,6 +19,8 @@ export class InnerEditor implements IInnerEditor {
|
|
|
19
19
|
|
|
20
20
|
public config: IObject
|
|
21
21
|
|
|
22
|
+
public editConfig?: IEditorConfig
|
|
23
|
+
|
|
22
24
|
public editor: IEditor
|
|
23
25
|
|
|
24
26
|
protected _editBox: IEditBox
|
package/types/index.d.ts
CHANGED
|
@@ -82,6 +82,7 @@ declare class Editor extends Group implements IEditor {
|
|
|
82
82
|
editToolList: IObject;
|
|
83
83
|
selector: EditSelect;
|
|
84
84
|
editMask: EditMask;
|
|
85
|
+
hasDimOthers?: boolean;
|
|
85
86
|
get targetLeafer(): _leafer_ui_interface.ILeafer;
|
|
86
87
|
targetChanged: boolean;
|
|
87
88
|
targetEventIds: IEventListenerId[];
|
|
@@ -321,6 +322,7 @@ declare class InnerEditor implements IInnerEditor {
|
|
|
321
322
|
get mode(): IInnerEditorMode;
|
|
322
323
|
editTarget: IUI;
|
|
323
324
|
config: IObject;
|
|
325
|
+
editConfig?: IEditorConfig$1;
|
|
324
326
|
editor: IEditor;
|
|
325
327
|
protected _editBox: IEditBox;
|
|
326
328
|
get editBox(): IEditBox;
|