@leafer-in/editor 1.5.2 → 1.5.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 +19 -11
- package/dist/editor.cjs.map +1 -1
- package/dist/editor.esm.js +19 -11
- package/dist/editor.esm.js.map +1 -1
- package/dist/editor.esm.min.js +1 -1
- package/dist/editor.esm.min.js.map +1 -1
- package/dist/editor.js +19 -11
- package/dist/editor.js.map +1 -1
- 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 +5 -5
- package/src/decorator/data.ts +20 -4
- package/src/editor/target.ts +2 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leafer-in/editor",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.3",
|
|
4
4
|
"description": "@leafer-in/editor",
|
|
5
5
|
"author": "Chao (Leafer) Wan",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"leaferjs"
|
|
35
35
|
],
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@leafer-ui/core": "^1.5.
|
|
38
|
-
"@leafer-in/resize": "^1.5.
|
|
39
|
-
"@leafer-ui/interface": "^1.5.
|
|
40
|
-
"@leafer-in/interface": "^1.5.
|
|
37
|
+
"@leafer-ui/core": "^1.5.3",
|
|
38
|
+
"@leafer-in/resize": "^1.5.3",
|
|
39
|
+
"@leafer-ui/interface": "^1.5.3",
|
|
40
|
+
"@leafer-in/interface": "^1.5.3"
|
|
41
41
|
}
|
|
42
42
|
}
|
package/src/decorator/data.ts
CHANGED
|
@@ -5,17 +5,33 @@ import { defineKey } from '@leafer-ui/draw'
|
|
|
5
5
|
import { EditorEvent } from '../event/EditorEvent'
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|
export function targetAttr(fn: IFunction) {
|
|
10
9
|
return (target: ILeaf, key: string) => {
|
|
11
10
|
const privateKey = '_' + key
|
|
12
11
|
defineKey(target, key, {
|
|
13
12
|
get() { return (this as IObject)[privateKey] },
|
|
14
|
-
set(value:
|
|
13
|
+
set(value: IUI | IUI[]) {
|
|
15
14
|
const old = (this as IObject)[privateKey]
|
|
16
15
|
if (old !== value) {
|
|
17
|
-
|
|
18
|
-
if (
|
|
16
|
+
|
|
17
|
+
if ((this as IEditor).config) { // Editor
|
|
18
|
+
|
|
19
|
+
const isSelect = key === 'target'
|
|
20
|
+
if (isSelect) {
|
|
21
|
+
if (value instanceof Array && value.length > 1 && value[0].locked) value.splice(0, 1) // fix: 单个锁定 + shift多选
|
|
22
|
+
|
|
23
|
+
const { beforeSelect } = (this as IEditor).config
|
|
24
|
+
if (beforeSelect) {
|
|
25
|
+
const check = beforeSelect({ target: value })
|
|
26
|
+
if (typeof check === 'object') value = check
|
|
27
|
+
else if (check === false) return
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const type = isSelect ? EditorEvent.BEFORE_SELECT : EditorEvent.BEFORE_HOVER
|
|
32
|
+
if (this.hasEvent(type)) this.emitEvent(new EditorEvent(type, { editor: this as IEditor, value: value as IUI, oldValue: old }))
|
|
33
|
+
}
|
|
34
|
+
|
|
19
35
|
(this as IObject)[privateKey] = value, fn(this, old)
|
|
20
36
|
}
|
|
21
37
|
}
|
package/src/editor/target.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LeafList } from '@leafer-ui/draw'
|
|
2
2
|
|
|
3
|
-
import { IEditor,
|
|
3
|
+
import { IEditor, IUI } from '@leafer-in/interface'
|
|
4
4
|
|
|
5
5
|
import { simulate } from './simulate'
|
|
6
6
|
import { updateMoveCursor } from './cursor'
|
|
@@ -10,11 +10,7 @@ import { EditorEvent } from '../event/EditorEvent'
|
|
|
10
10
|
export function onTarget(editor: IEditor, oldValue: IUI | IUI[]): void {
|
|
11
11
|
const { target } = editor
|
|
12
12
|
if (target) {
|
|
13
|
-
|
|
14
|
-
if (!list.every(checkEditable)) { // 过滤不合格的元素
|
|
15
|
-
editor.target = list.filter(checkEditable) as IUI[]
|
|
16
|
-
return
|
|
17
|
-
}
|
|
13
|
+
editor.leafList = target instanceof LeafList ? target : new LeafList(target)
|
|
18
14
|
if (editor.multiple) simulate(editor) // 更新模拟元素
|
|
19
15
|
} else {
|
|
20
16
|
editor.simulateTarget.remove()
|
|
@@ -41,9 +37,4 @@ export function onTarget(editor: IEditor, oldValue: IUI | IUI[]): void {
|
|
|
41
37
|
|
|
42
38
|
export function onHover(editor: IEditor, oldValue: IUI): void {
|
|
43
39
|
editor.emitEvent(new EditorEvent(EditorEvent.HOVER, { editor, value: editor.hoverTarget, oldValue }))
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
function checkEditable(item: ILeaf): boolean {
|
|
48
|
-
return item.editable && !item.locked
|
|
49
40
|
}
|