@leafer-in/editor 1.3.1 → 1.3.3
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 +40 -28
- package/dist/editor.esm.js +43 -31
- package/dist/editor.esm.min.js +1 -1
- package/dist/editor.js +40 -27
- package/dist/editor.min.cjs +1 -1
- package/dist/editor.min.js +1 -1
- package/package.json +5 -6
- package/src/Editor.ts +1 -0
- package/src/display/EditBox.ts +1 -0
- package/src/display/EditSelect.ts +4 -4
- package/src/editor/target.ts +1 -1
- package/src/helper/EditSelectHelper.ts +27 -20
- package/src/index.ts +1 -2
- package/types/index.d.ts +2 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IBounds, ILeaf, ILeafList, IUI, IEventListenerId, IPointerEvent, IFunction } from '@leafer-ui/interface'
|
|
2
|
-
import { Bounds, LeafList, Group
|
|
2
|
+
import { Bounds, LeafList, Group } from '@leafer-ui/draw'
|
|
3
3
|
import { PointerEvent, DragEvent, MoveEvent, ZoomEvent } from '@leafer-ui/core'
|
|
4
4
|
|
|
5
5
|
import { IEditSelect, IEditor, ISelectArea, IStroker } from '@leafer-in/interface'
|
|
@@ -10,7 +10,7 @@ import { EditSelectHelper } from '../helper/EditSelectHelper'
|
|
|
10
10
|
import { EditorEvent } from '../event/EditorEvent'
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
const { findOne } = EditSelectHelper
|
|
13
|
+
const { findOne, findByBounds } = EditSelectHelper
|
|
14
14
|
|
|
15
15
|
export class EditSelect extends Group implements IEditSelect {
|
|
16
16
|
|
|
@@ -160,7 +160,7 @@ export class EditSelect extends Group implements IEditSelect {
|
|
|
160
160
|
const total = e.getInnerTotal(this)
|
|
161
161
|
|
|
162
162
|
const dragBounds = this.bounds.clone().unsign()
|
|
163
|
-
const list = new LeafList(editor.app
|
|
163
|
+
const list = new LeafList(findByBounds(editor.app, dragBounds))
|
|
164
164
|
|
|
165
165
|
this.bounds.width = total.x
|
|
166
166
|
this.bounds.height = total.y
|
|
@@ -207,7 +207,7 @@ export class EditSelect extends Group implements IEditSelect {
|
|
|
207
207
|
}
|
|
208
208
|
|
|
209
209
|
protected allowDrag(e: DragEvent) {
|
|
210
|
-
if (this.running && (this.editor.mergeConfig.boxSelect
|
|
210
|
+
if (this.running && (this.editor.mergeConfig.boxSelect) && !e.target.draggable) {
|
|
211
211
|
return (!this.editor.editing && this.allow(e.target)) || (e.shiftKey && !findOne(e.path))
|
|
212
212
|
} else {
|
|
213
213
|
return false
|
package/src/editor/target.ts
CHANGED
|
@@ -11,6 +11,7 @@ export function onTarget(editor: IEditor, oldValue: IUI | IUI[]): void {
|
|
|
11
11
|
const { target } = editor
|
|
12
12
|
if (target) {
|
|
13
13
|
editor.leafList = target instanceof LeafList ? target : new LeafList(target instanceof Array ? target : target as IUI)
|
|
14
|
+
if (editor.multiple) simulate(editor) // 更新模拟元素
|
|
14
15
|
} else {
|
|
15
16
|
editor.simulateTarget.remove()
|
|
16
17
|
editor.leafList.reset()
|
|
@@ -22,7 +23,6 @@ export function onTarget(editor: IEditor, oldValue: IUI | IUI[]): void {
|
|
|
22
23
|
|
|
23
24
|
if (editor.editing) {
|
|
24
25
|
editor.waitLeafer(() => {
|
|
25
|
-
if (editor.multiple) simulate(editor)
|
|
26
26
|
updateMoveCursor(editor)
|
|
27
27
|
editor.updateEditTool()
|
|
28
28
|
editor.update()
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import { IBounds, ILeafList, IUI } from '@leafer-ui/interface'
|
|
2
|
-
import { Answer } from '@leafer-ui/draw'
|
|
1
|
+
import { IBounds, ILeafList, IUI, IUIData } from '@leafer-ui/interface'
|
|
3
2
|
|
|
4
|
-
const { No, Yes, NoAndSkip, YesAndSkip } = Answer
|
|
5
3
|
|
|
6
4
|
export const EditSelectHelper = {
|
|
7
5
|
|
|
@@ -9,26 +7,35 @@ export const EditSelectHelper = {
|
|
|
9
7
|
return path.list.find((leaf) => leaf.editable) as IUI
|
|
10
8
|
},
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return leaf.__.hitSelf ? YesAndSkip : NoAndSkip
|
|
18
|
-
} else if (leaf.isFrame) {
|
|
19
|
-
return bounds.includes(leaf.__layout.boxBounds, leaf.__world) ? YesAndSkip : No
|
|
20
|
-
} else {
|
|
21
|
-
if (bounds.hit(leaf.__layout.boxBounds, leaf.__world) && leaf.__.hitSelf) return Yes
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return No
|
|
10
|
+
findByBounds(branch: IUI, bounds: IBounds): IUI[] {
|
|
11
|
+
const list: IUI[] = []
|
|
12
|
+
eachFind([branch], list, bounds)
|
|
13
|
+
return list
|
|
14
|
+
}
|
|
26
15
|
|
|
27
|
-
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
function eachFind(children: IUI[], list: IUI[], bounds: IBounds): void {
|
|
20
|
+
let child: IUI, data: IUIData
|
|
21
|
+
for (let i = 0, len = children.length; i < len; i++) {
|
|
22
|
+
child = children[i], data = child.__
|
|
23
|
+
if (data.hittable && data.visible && !data.locked && bounds.hit(child.__world)) {
|
|
24
|
+
|
|
25
|
+
if (data.editable) {
|
|
26
|
+
if (child.isBranch && !data.hitChildren) {
|
|
27
|
+
if (data.hitSelf) list.push(child)
|
|
28
|
+
continue
|
|
29
|
+
} else if (child.isFrame) {
|
|
30
|
+
if (bounds.includes(child.__layout.boxBounds, child.__world)) {
|
|
31
|
+
list.push(child)
|
|
32
|
+
continue
|
|
33
|
+
}
|
|
34
|
+
} else if (bounds.hit(child.__layout.boxBounds, child.__world) && data.hitSelf) list.push(child)
|
|
35
|
+
}
|
|
28
36
|
|
|
29
|
-
|
|
37
|
+
if (child.isBranch) eachFind(child.children, list, bounds)
|
|
30
38
|
|
|
31
39
|
}
|
|
32
40
|
}
|
|
33
|
-
|
|
34
41
|
}
|
package/src/index.ts
CHANGED
|
@@ -29,12 +29,11 @@ import { IEditor, IEditorConfig, IEditToolFunction, IEditorConfigFunction } from
|
|
|
29
29
|
import { Creator, UI, Group, Text, Box, dataType, defineKey, Plugin } from '@leafer-ui/draw'
|
|
30
30
|
|
|
31
31
|
import '@leafer-in/resize'
|
|
32
|
-
import '@leafer-in/find'
|
|
33
32
|
|
|
34
33
|
import { Editor } from './Editor'
|
|
35
34
|
|
|
36
35
|
|
|
37
|
-
Plugin.add('editor', 'resize'
|
|
36
|
+
Plugin.add('editor', 'resize')
|
|
38
37
|
|
|
39
38
|
|
|
40
39
|
Creator.editor = function (options?: IEditorConfig): IEditor { return new Editor(options) }
|
package/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IBounds, ILeafList, IUI, IFunction, IEventListenerId, ILeaf, IPointerEvent, ILeaferCanvas, IRenderOptions, IGroup, IObject, IPointData, ILayoutBoundsData, IGroupInputData, IEditSize, IAlign, IAxis, IMatrix, IBox, IBoundsData, IEditorConfig as IEditorConfig$1, IBoxInputData, IKeyEvent, IRect, IRectInputData, IMatrixData, IDragEvent, IAround } from '@leafer-ui/interface';
|
|
2
|
-
import { Group, UI, Direction9, Event, Box
|
|
2
|
+
import { Group, UI, Direction9, Event, Box } from '@leafer-ui/draw';
|
|
3
3
|
import { PointerEvent, DragEvent, MoveEvent, ZoomEvent, RotateEvent } from '@leafer-ui/core';
|
|
4
4
|
import { IEditSelect, IEditor, IStroker, ISelectArea, IEditorConfig, ISimulateElement, IEditBox, IEditTool, IInnerEditor, IEditorScaleEvent, IEditorEvent, IEditPoint, IEditPointType, IEditorMoveEvent, IEditorRotateEvent, IEditorSkewEvent, IEditorGroupEvent, IInnerEditorEvent, IUI as IUI$1, IDragEvent as IDragEvent$1, IPointData as IPointData$1, IPathCommandData, IFromToData, IAround as IAround$1 } from '@leafer-in/interface';
|
|
5
5
|
|
|
@@ -321,7 +321,7 @@ declare const EditDataHelper: {
|
|
|
321
321
|
|
|
322
322
|
declare const EditSelectHelper: {
|
|
323
323
|
findOne(path: ILeafList): IUI;
|
|
324
|
-
|
|
324
|
+
findByBounds(branch: IUI, bounds: IBounds): IUI[];
|
|
325
325
|
};
|
|
326
326
|
|
|
327
327
|
export { EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, InnerEditor, InnerEditorEvent, LineEditTool, SelectArea, Stroker, registerEditTool, registerInnerEditor };
|