Skip to content

Commit

Permalink
fix: revert canvasFlag
Browse files Browse the repository at this point in the history
  • Loading branch information
yy-wow committed Nov 11, 2024
1 parent 23028c7 commit 622f4ca
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 45 deletions.
34 changes: 10 additions & 24 deletions packages/canvas/container/src/CanvasContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,6 @@ export default {
}
}
const isCanvasEvent = (event, handler) => {
const canvasFlag = canvasApi.getRenderer().getCanvasFlag()
if (!canvasFlag) {
return
}
return handler(event)
}
const canvasReady = ({ detail }) => {
if (iframe.value) {
// 设置monitor报错埋点
Expand All @@ -141,17 +131,15 @@ export default {
// 以下是内部iframe监听的事件
win.addEventListener('mousedown', (event) => {
isCanvasEvent(event, (e) => {
// html元素使用scroll和mouseup事件处理
if (e.target === doc.documentElement) {
isScrolling = false
return
}
insertPosition.value = false
setCurrentNode(e)
target.value = e.target
})
// html元素使用scroll和mouseup事件处理
if (event.target === doc.documentElement) {
isScrolling = false
return
}
insertPosition.value = false
setCurrentNode(event)
target.value = event.target
})
win.addEventListener('scroll', () => {
Expand Down Expand Up @@ -180,9 +168,7 @@ export default {
})
win.addEventListener('mousemove', (ev) => {
isCanvasEvent(ev, (e) => {
dragMove(e, true)
})
dragMove(ev, true)
})
// 阻止浏览器默认的右键菜单功能
Expand Down
8 changes: 2 additions & 6 deletions packages/renderer/src/RenderMain.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ import {
getCondition,
getConditions,
context,
setNode,
getCanvasFlag,
setCanvasFlag
setNode
} from './context'
import CanvasEmpty from './CanvasEmpty.vue'

Expand Down Expand Up @@ -494,7 +492,5 @@ export const api = {
generateFn,
getCollectionMethodsMap,
getBlockSlotDataMap,
getComponent,
getCanvasFlag,
setCanvasFlag
getComponent
}
7 changes: 0 additions & 7 deletions packages/renderer/src/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export const context = shallowReactive({})
export const conditions = shallowReactive({})

const nodes = {}
let canvasFlag = true // 是否表现画布内特征的标志,如拖拽事件、原生事件是否触发等

export const setNode = (schema, parent) => {
schema.id = schema.id || utils.guid()
Expand Down Expand Up @@ -56,9 +55,3 @@ export const setCondition = (id, visible = false) => {
export const getCondition = (id) => conditions[id] !== false

export const getConditions = () => conditions

export const getCanvasFlag = () => canvasFlag

export const setCanvasFlag = (flag) => {
canvasFlag = flag
}
13 changes: 5 additions & 8 deletions packages/renderer/src/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import i18nHost from '@opentiny/tiny-engine-i18n-host'
import { CanvasRow, CanvasCol, CanvasRowColContainer } from '@opentiny/tiny-engine-builtin-component'

import { NODE_UID as DESIGN_UIDKEY, NODE_TAG as DESIGN_TAGKEY, NODE_LOOP as DESIGN_LOOPID } from './constants'
import { context, conditions, setNode, getCanvasFlag } from './context'
import { context, conditions, setNode } from './context'
import {
CanvasBox,
CanvasCollection,
Expand Down Expand Up @@ -562,20 +562,17 @@ const getBindProps = (schema, scope) => {
const bindProps = {
...parseData(schema.props, scope),
[DESIGN_UIDKEY]: id,
[DESIGN_TAGKEY]: componentName
}

if (getCanvasFlag()) {
bindProps.onMouseover = stopEvent
bindProps.onFocus = stopEvent
[DESIGN_TAGKEY]: componentName,
onMouseover: stopEvent,
onFocus: stopEvent
}

if (scope) {
bindProps[DESIGN_LOOPID] = scope.index === undefined ? scope.idx : scope.index
}

// 在捕获阶段阻止事件的传播
if (clickCapture(componentName) && getCanvasFlag()) {
if (clickCapture(componentName)) {
bindProps.onClickCapture = stopEvent
}

Expand Down

0 comments on commit 622f4ca

Please sign in to comment.