@leafer-in/editor 1.5.0 → 1.5.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-in/editor",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
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.0",
38
- "@leafer-in/resize": "^1.5.0",
39
- "@leafer-ui/interface": "^1.5.0",
40
- "@leafer-in/interface": "^1.5.0"
37
+ "@leafer-ui/core": "^1.5.1",
38
+ "@leafer-in/resize": "^1.5.1",
39
+ "@leafer-ui/interface": "^1.5.1",
40
+ "@leafer-in/interface": "^1.5.1"
41
41
  }
42
42
  }
@@ -1,6 +1,10 @@
1
- import { IFunction, ILeaf, IObject } from '@leafer-ui/interface'
1
+ import { IFunction, ILeaf, IObject, IUI, } from '@leafer-ui/interface'
2
+ import { IEditor } from '@leafer-in/interface'
2
3
  import { defineKey } from '@leafer-ui/draw'
3
4
 
5
+ import { EditorEvent } from '../event/EditorEvent'
6
+
7
+
4
8
 
5
9
  export function targetAttr(fn: IFunction) {
6
10
  return (target: ILeaf, key: string) => {
@@ -9,7 +13,11 @@ export function targetAttr(fn: IFunction) {
9
13
  get() { return (this as IObject)[privateKey] },
10
14
  set(value: unknown) {
11
15
  const old = (this as IObject)[privateKey]
12
- if (old !== value) (this as IObject)[privateKey] = value, fn(this, old)
16
+ if (old !== value) {
17
+ const type = key === 'target' ? EditorEvent.BEFORE_SELECT : EditorEvent.BEFORE_HOVER
18
+ if (this.hasEvent(type)) this.emitEvent(new EditorEvent(type, { editor: this as IEditor, value: value as IUI, oldValue: old }));
19
+ (this as IObject)[privateKey] = value, fn(this, old)
20
+ }
13
21
  }
14
22
  } as ThisType<ILeaf>)
15
23
  }
@@ -10,7 +10,10 @@ function toList(value: IUI | IUI[]): IUI[] {
10
10
 
11
11
  export class EditorEvent extends Event implements IEditorEvent {
12
12
 
13
+ static BEFORE_SELECT = 'editor.before_select'
13
14
  static SELECT = 'editor.select'
15
+
16
+ static BEFORE_HOVER = 'editor.before_hover'
14
17
  static HOVER = 'editor.hover'
15
18
 
16
19
  declare readonly target: IUI
package/types/index.d.ts CHANGED
@@ -118,7 +118,9 @@ declare class Editor extends Group implements IEditor {
118
118
  }
119
119
 
120
120
  declare class EditorEvent extends Event implements IEditorEvent {
121
+ static BEFORE_SELECT: string;
121
122
  static SELECT: string;
123
+ static BEFORE_HOVER: string;
122
124
  static HOVER: string;
123
125
  readonly target: IUI;
124
126
  readonly editor: IEditor;