fix: dragging image boundary error within the control
This commit is contained in:
@@ -1,9 +1,12 @@
|
|||||||
import { EDITOR_ELEMENT_STYLE_ATTR } from '../../../dataset/constant/Element'
|
import {
|
||||||
|
CONTROL_CONTEXT_ATTR,
|
||||||
|
EDITOR_ELEMENT_STYLE_ATTR
|
||||||
|
} from '../../../dataset/constant/Element'
|
||||||
import { ImageDisplay } from '../../../dataset/enum/Common'
|
import { ImageDisplay } from '../../../dataset/enum/Common'
|
||||||
import { ControlComponent, ControlType } from '../../../dataset/enum/Control'
|
import { ControlComponent, ControlType } from '../../../dataset/enum/Control'
|
||||||
import { ElementType } from '../../../dataset/enum/Element'
|
import { ElementType } from '../../../dataset/enum/Element'
|
||||||
import { IElement } from '../../../interface/Element'
|
import { IElement } from '../../../interface/Element'
|
||||||
import { deepClone, getUUID } from '../../../utils'
|
import { deepClone, getUUID, omitObject } from '../../../utils'
|
||||||
import { formatElementContext, formatElementList } from '../../../utils/element'
|
import { formatElementContext, formatElementList } from '../../../utils/element'
|
||||||
import { CanvasEvent } from '../CanvasEvent'
|
import { CanvasEvent } from '../CanvasEvent'
|
||||||
|
|
||||||
@@ -134,11 +137,7 @@ export function mouseup(evt: MouseEvent, host: CanvasEvent) {
|
|||||||
const editorOptions = draw.getOptions()
|
const editorOptions = draw.getOptions()
|
||||||
const elementList = draw.getElementList()
|
const elementList = draw.getElementList()
|
||||||
const replaceElementList = dragElementList.map(el => {
|
const replaceElementList = dragElementList.map(el => {
|
||||||
if (
|
if (!el.type || el.type === ElementType.TEXT) {
|
||||||
!el.type ||
|
|
||||||
el.type === ElementType.TEXT ||
|
|
||||||
el.control?.type === ControlType.TEXT
|
|
||||||
) {
|
|
||||||
const newElement: IElement = {
|
const newElement: IElement = {
|
||||||
value: el.value
|
value: el.value
|
||||||
}
|
}
|
||||||
@@ -150,7 +149,8 @@ export function mouseup(evt: MouseEvent, host: CanvasEvent) {
|
|||||||
})
|
})
|
||||||
return newElement
|
return newElement
|
||||||
} else {
|
} else {
|
||||||
const newElement = deepClone(el)
|
// 移除控件上下文属性
|
||||||
|
const newElement = omitObject(deepClone(el), CONTROL_CONTEXT_ATTR)
|
||||||
formatElementList([newElement], {
|
formatElementList([newElement], {
|
||||||
isHandleFirstElement: false,
|
isHandleFirstElement: false,
|
||||||
editorOptions
|
editorOptions
|
||||||
|
|||||||
@@ -90,6 +90,12 @@ export const LIST_CONTEXT_ATTR: Array<keyof IElement> = [
|
|||||||
'listStyle'
|
'listStyle'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
export const CONTROL_CONTEXT_ATTR: Array<keyof IElement> = [
|
||||||
|
'control',
|
||||||
|
'controlId',
|
||||||
|
'controlComponent'
|
||||||
|
]
|
||||||
|
|
||||||
export const EDITOR_ELEMENT_CONTEXT_ATTR: Array<keyof IElement> = [
|
export const EDITOR_ELEMENT_CONTEXT_ATTR: Array<keyof IElement> = [
|
||||||
...TABLE_CONTEXT_ATTR,
|
...TABLE_CONTEXT_ATTR,
|
||||||
...TITLE_CONTEXT_ATTR,
|
...TITLE_CONTEXT_ATTR,
|
||||||
|
|||||||
Reference in New Issue
Block a user