@leafer-in/editor 2.3.2 → 2.3.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 +15 -13
- package/dist/editor.esm.js +15 -13
- package/dist/editor.esm.min.js +1 -1
- package/dist/editor.esm.min.js.map +1 -1
- package/dist/editor.js +15 -13
- 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 +1 -1
- package/src/decorator/data.ts +2 -2
- package/src/display/EditBox.ts +6 -3
- package/src/display/EditSelect.ts +2 -2
- package/src/helper/EditSelectHelper.ts +5 -5
- package/types/index.d.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-in/editor",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.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.3.
|
|
38
|
-
"@leafer-ui/core": "^2.3.
|
|
39
|
-
"@leafer-in/resize": "^2.3.
|
|
40
|
-
"@leafer-ui/interface": "^2.3.
|
|
41
|
-
"@leafer-in/interface": "^2.3.
|
|
37
|
+
"@leafer-ui/draw": "^2.3.4",
|
|
38
|
+
"@leafer-ui/core": "^2.3.4",
|
|
39
|
+
"@leafer-in/resize": "^2.3.4",
|
|
40
|
+
"@leafer-ui/interface": "^2.3.4",
|
|
41
|
+
"@leafer-in/interface": "^2.3.4"
|
|
42
42
|
}
|
|
43
43
|
}
|
package/src/Editor.ts
CHANGED
|
@@ -118,7 +118,7 @@ export class Editor extends Group implements IEditor {
|
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
public addItem(item: IUI): void {
|
|
121
|
-
if (!this.hasItem(item) && !item.locked) this.leafList.add(item), this.target = this.leafList.list as IUI[]
|
|
121
|
+
if (!this.hasItem(item) && !(item.locked && !this.mergedConfig.multipleSelectLocked)) this.leafList.add(item), this.target = this.leafList.list as IUI[]
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
public removeItem(item: IUI): void {
|
package/src/decorator/data.ts
CHANGED
|
@@ -22,7 +22,7 @@ export function targetAttr(fn: IFunction) {
|
|
|
22
22
|
|
|
23
23
|
const isSelect = key === 'target'
|
|
24
24
|
if (isSelect) {
|
|
25
|
-
const { beforeSelect, skipNested } = t.config
|
|
25
|
+
const { beforeSelect, skipNested, multipleSelectLocked } = t.config
|
|
26
26
|
|
|
27
27
|
if (isArray(value)) {
|
|
28
28
|
if (skipNested) { // 过滤嵌套关系的元素
|
|
@@ -35,7 +35,7 @@ export function targetAttr(fn: IFunction) {
|
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
if (value.length > 1 && value.some(item => item.locked || item.editable === 'single')) {
|
|
38
|
+
if (value.length > 1 && value.some(item => (item.locked && !multipleSelectLocked) || item.editable === 'single')) {
|
|
39
39
|
value = value.filter(item => !(item.locked || item.editable === 'single')) // 锁定、单选元素不能参与多选
|
|
40
40
|
}
|
|
41
41
|
}
|
package/src/display/EditBox.ts
CHANGED
|
@@ -77,6 +77,8 @@ export class EditBox extends Group implements IEditBox {
|
|
|
77
77
|
|
|
78
78
|
protected __eventIds: IEventListenerId[] = []
|
|
79
79
|
|
|
80
|
+
public isLocked?: boolean
|
|
81
|
+
|
|
80
82
|
constructor(editor: IEditor) {
|
|
81
83
|
super()
|
|
82
84
|
this.editor = editor
|
|
@@ -125,13 +127,14 @@ export class EditBox extends Group implements IEditBox {
|
|
|
125
127
|
|
|
126
128
|
public load(): void {
|
|
127
129
|
const { target, mergeConfig, single, rect, circle, resizePoints, resizeLines } = this
|
|
128
|
-
const { stroke, strokeWidth, ignorePixelSnap } = mergeConfig
|
|
130
|
+
const { stroke, strokeWidth, ignorePixelSnap, multipleSelectLocked } = mergeConfig
|
|
129
131
|
|
|
130
132
|
const pointsStyle = this.getPointsStyle()
|
|
131
133
|
const middlePointsStyle = this.getMiddlePointsStyle()
|
|
132
134
|
const resizeLinesStyle = this.getResizeLinesStyle()
|
|
133
135
|
|
|
134
|
-
this.
|
|
136
|
+
this.isLocked = target.locked || (multipleSelectLocked && this.editor.list.some(item => item.locked))
|
|
137
|
+
this.visible = !this.isLocked
|
|
135
138
|
|
|
136
139
|
let resizeP: IBox
|
|
137
140
|
|
|
@@ -167,7 +170,7 @@ export class EditBox extends Group implements IEditBox {
|
|
|
167
170
|
const { editor, target } = this
|
|
168
171
|
if (!target) return
|
|
169
172
|
const { x, y, scaleX, scaleY, rotation, skewX, skewY, width, height } = target.getLayoutBounds('box', editor, true)
|
|
170
|
-
this.visible = !this.target.locked
|
|
173
|
+
this.visible = !(this.target.locked || this.isLocked)
|
|
171
174
|
this.set({ x, y, scaleX, scaleY, rotation, skewX, skewY })
|
|
172
175
|
this.updateBounds({ x: 0, y: 0, width, height })
|
|
173
176
|
this.updateWidgets()
|
|
@@ -165,11 +165,11 @@ export class EditSelect extends Group implements IEditSelect {
|
|
|
165
165
|
if (this.editor.dragging) return this.onDragEnd(e)
|
|
166
166
|
|
|
167
167
|
if (this.dragging) {
|
|
168
|
-
const { editor } = this
|
|
168
|
+
const { editor } = this, { mergedConfig } = editor
|
|
169
169
|
const total = e.getInnerTotal(this)
|
|
170
170
|
|
|
171
171
|
const dragBounds = this.bounds.clone().unsign()
|
|
172
|
-
const list = new LeafList(findByBounds(editor.app, dragBounds,
|
|
172
|
+
const list = new LeafList(findByBounds(editor.app, dragBounds, mergedConfig.boxSelect === 'includes' ? 'includes' : 'hit', mergedConfig.multipleSelectLocked))
|
|
173
173
|
|
|
174
174
|
this.bounds.width = total.x
|
|
175
175
|
this.bounds.height = total.y
|
|
@@ -7,20 +7,20 @@ export const EditSelectHelper = {
|
|
|
7
7
|
return path.list.find((leaf) => leaf.editable) as IUI
|
|
8
8
|
},
|
|
9
9
|
|
|
10
|
-
findByBounds(branch: IUI, bounds: IBounds, mode: 'hit' | 'includes' = 'hit'): IUI[] {
|
|
10
|
+
findByBounds(branch: IUI, bounds: IBounds, mode: 'hit' | 'includes' = 'hit', multipleSelectLocked?: boolean): IUI[] {
|
|
11
11
|
const list: IUI[] = []
|
|
12
|
-
eachFind([branch], list, bounds, mode)
|
|
12
|
+
eachFind([branch], list, bounds, mode, multipleSelectLocked)
|
|
13
13
|
return list
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
|
|
19
|
-
function eachFind(children: IUI[], list: IUI[], bounds: IBounds, mode: 'hit' | 'includes'): void {
|
|
19
|
+
function eachFind(children: IUI[], list: IUI[], bounds: IBounds, mode: 'hit' | 'includes', multipleSelectLocked?: boolean): void {
|
|
20
20
|
let child: IUI, data: IUIData, isFind: boolean
|
|
21
21
|
for (let i = 0, len = children.length; i < len; i++) {
|
|
22
22
|
child = children[i], data = child.__
|
|
23
|
-
if (data.hittable && data.visible && !data.locked && bounds.hit(child.__world)) {
|
|
23
|
+
if (data.hittable && data.visible && !(data.locked && !multipleSelectLocked) && bounds.hit(child.__world)) {
|
|
24
24
|
|
|
25
25
|
if (data.editable && data.editable !== 'single') {
|
|
26
26
|
if (child.isFrame) {
|
|
@@ -41,7 +41,7 @@ function eachFind(children: IUI[], list: IUI[], bounds: IBounds, mode: 'hit' | '
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
if (child.isBranch) eachFind(child.children, list, bounds, mode)
|
|
44
|
+
if (child.isBranch) eachFind(child.children, list, bounds, mode, multipleSelectLocked)
|
|
45
45
|
|
|
46
46
|
}
|
|
47
47
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -178,6 +178,7 @@ declare class EditBox extends Group implements IEditBox {
|
|
|
178
178
|
get canGesture(): boolean;
|
|
179
179
|
get canDragLimitAnimate(): boolean;
|
|
180
180
|
protected __eventIds: IEventListenerId[];
|
|
181
|
+
isLocked?: boolean;
|
|
181
182
|
constructor(editor: IEditor);
|
|
182
183
|
create(): void;
|
|
183
184
|
showView(): void;
|
|
@@ -454,7 +455,7 @@ declare const EditDataHelper: {
|
|
|
454
455
|
|
|
455
456
|
declare const EditSelectHelper: {
|
|
456
457
|
findOne(path: ILeafList): IUI;
|
|
457
|
-
findByBounds(branch: IUI, bounds: IBounds, mode?: "hit" | "includes"): IUI[];
|
|
458
|
+
findByBounds(branch: IUI, bounds: IBounds, mode?: "hit" | "includes", multipleSelectLocked?: boolean): IUI[];
|
|
458
459
|
};
|
|
459
460
|
|
|
460
461
|
export { EditBox, EditDataHelper, EditPoint, EditSelect, EditSelectHelper, EditTool, EditToolCreator, Editor, EditorEvent, EditorGroupEvent, EditorHelper, EditorMoveEvent, EditorRotateEvent, EditorScaleEvent, EditorSkewEvent, InnerEditor, InnerEditorEvent, LineEditTool, SelectArea, Stroker, TransformTool, editToolMergeConfigAttr, registerEditTool, registerInnerEditor };
|