@leafer-in/editor 2.0.1 → 2.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leafer-in/editor",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
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.1",
38
- "@leafer-ui/core": "^2.0.1",
39
- "@leafer-in/resize": "^2.0.1",
40
- "@leafer-ui/interface": "^2.0.1",
41
- "@leafer-in/interface": "^2.0.1"
37
+ "@leafer-ui/draw": "^2.0.3",
38
+ "@leafer-ui/core": "^2.0.3",
39
+ "@leafer-in/resize": "^2.0.3",
40
+ "@leafer-ui/interface": "^2.0.3",
41
+ "@leafer-in/interface": "^2.0.3"
42
42
  }
43
43
  }
@@ -28,8 +28,11 @@ export function targetAttr(fn: IFunction) {
28
28
  else if (check === false) return
29
29
  }
30
30
 
31
- t.setDimOthers(false)
32
- t.setBright(false)
31
+ const { dimOthers, bright } = t.editBox.mergedConfig || t.config // 没有配置时不强制取消bright
32
+ if (!isUndefined(dimOthers) || !isUndefined(bright)) {
33
+ t.setDimOthers(false)
34
+ t.setBright(false)
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样式,不能覆盖到总配置里
@@ -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,10 @@ export class EditBox extends Group implements IEditBox {
171
171
 
172
172
  editMask.visible = mask ? true : 0
173
173
 
174
- editor.setDimOthers(dimOthers)
175
- editor.setBright(!!dimOthers || bright)
174
+ if (!isUndefined(dimOthers) || !isUndefined(bright)) { // 没有配置时不强制bright
175
+ editor.setDimOthers(dimOthers)
176
+ editor.setBright(!!dimOthers || bright)
177
+ }
176
178
 
177
179
  if (spread) BoundsHelper.spread(bounds, spread)
178
180
 
@@ -201,7 +203,8 @@ export class EditBox extends Group implements IEditBox {
201
203
  resizeL.set(point)
202
204
 
203
205
  resizeL.visible = resizeP.visible && !hideResizeLines
204
- resizeP.visible = rotateP.visible = showPoints && !!middlePoint
206
+ if (resizeP.visible) resizeP.visible = !!middlePoint
207
+ if (rotateP.visible) rotateP.visible = !!middlePoint
205
208
 
206
209
  if (((i + 1) / 2) % 2) { // top, bottom
207
210
  resizeL.width = width + resizeL.height
@@ -125,6 +125,8 @@ export class EditSelect extends Group implements IEditSelect {
125
125
  editor.target = find
126
126
  }
127
127
 
128
+ e.path.needUpdate = true // 需要更新一下path
129
+
128
130
  } else if (this.allow(e.target)) {
129
131
 
130
132
  if (!this.isHoldMultipleSelectKey(e) && !this.editor.mergedConfig.selectKeep) editor.target = null
@@ -22,6 +22,7 @@ export class SimulateElement extends Rect implements ISimulateElement {
22
22
  super()
23
23
 
24
24
  this.visible = this.hittable = false
25
+ this.skipJSON = true
25
26
 
26
27
  this.on(PropertyEvent.CHANGE, (event: PropertyEvent) => {
27
28
 
@@ -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
@@ -321,6 +321,7 @@ declare class InnerEditor implements IInnerEditor {
321
321
  get mode(): IInnerEditorMode;
322
322
  editTarget: IUI;
323
323
  config: IObject;
324
+ editConfig?: IEditorConfig$1;
324
325
  editor: IEditor;
325
326
  protected _editBox: IEditBox;
326
327
  get editBox(): IEditBox;