Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: canvasDivider can't work #1075

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions packages/canvas/container/src/components/CanvasDivider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

<script>
import { reactive, watch } from 'vue'
import { useCanvas } from '@opentiny/tiny-engine-meta-register'
import { extend } from '@opentiny/vue-renderless/common/object'
import { getCurrent, updateRect } from '../container'

Expand Down Expand Up @@ -86,6 +87,12 @@ export default {
const index = parent.children.findIndex(({ id }) => id === schema.id)

parent.children.splice(index + 1, 0, extend(true, {}, COL_SNIPPET))

useCanvas().operateNode({
type: 'updateAttributes',
id: parent.id,
value: { children: parent.children }
})
updateRect()
}

Expand All @@ -97,6 +104,12 @@ export default {
if (schema.componentName === 'CanvasRow') {
parent.children.splice(index + 1, 0, extend(true, {}, ROW_SNIPPET))

useCanvas().operateNode({
type: 'updateAttributes',
id: parent.id,
value: { children: parent.children }
})

return
}

Expand All @@ -123,6 +136,12 @@ export default {
// 已经切割过了,直接加一行
schema.children.push(extend(true, {}, ROW_SNIPPET))
}

useCanvas().operateNode({
type: 'updateAttributes',
id: parent.id,
value: { children: parent.children }
})
}

updateRect()
Expand Down
32 changes: 21 additions & 11 deletions packages/canvas/container/src/components/CanvasResizeBorder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<script>
import { reactive, watch } from 'vue'
import { useLayout } from '@opentiny/tiny-engine-meta-register'
import { useLayout, useCanvas } from '@opentiny/tiny-engine-meta-register'
import { getCurrent, updateRect, selectState, querySelectById } from '../container'

export default {
Expand Down Expand Up @@ -54,10 +54,6 @@ export default {

const { parent, schema } = getCurrent()

if (!schema.props) {
schema.props = {}
}

if (state.direction === 'horizontal') {
let dis = state.startPosition.x - clientX

Expand All @@ -75,18 +71,32 @@ export default {
// 最小宽度32
newWidth = Math.max(newWidth, 32)

schema.props.flexBasis = `${newWidth}px`
schema.props.widthType = 'fixed'
useCanvas().operateNode({
type: 'changeProps',
id: schema.id,
value: {
props: {
flexBasis: `${newWidth}px`,
widthType: 'fixed'
}
}
})
}

if (state.direction === 'vertical') {
let target = schema.componentName === 'CanvasRow' ? schema : parent
if (!target.props) {
target.props = {}
}
const dis = clientY - state.startPosition.y
const minHeight = state.startPosition.height + dis
target.props.minHeight = `${minHeight}px`

useCanvas().operateNode({
type: 'changeProps',
id: target.id,
value: {
props: {
minHeight: `${minHeight}px`
}
}
})
}

updateRect()
Expand Down