Skip to content

Commit

Permalink
fix: TinyGrid slot children can not operate
Browse files Browse the repository at this point in the history
修复 TinyGrid 组件列插槽拖入内容保存后,再次选中无法进行操作的 bug
  • Loading branch information
chilingling committed Feb 7, 2025
1 parent 3c8ba63 commit a73706a
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions packages/canvas/DesignCanvas/src/api/useCanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,37 @@ const rootSchema = ref([
}
])

const handleTinyGridColumnsSlots = (node) => {
for (const columnItem of node.props?.columns || []) {
if (!columnItem?.slots) {
continue
}

for (const slotItem of Object.values(columnItem.slots)) {
if (Array.isArray(slotItem?.value)) {
slotItem.value.forEach((item) => {
if (!item.id) {
item.id = utils.guid()
}

nodesMap.value.set(item.id, { node: item, parent: node })

if (Array.isArray(item.children)) {
// eslint-disable-next-line no-use-before-define
generateNodesMap(item.children, item)
}
})
}
}
}
}

const handleNodesInProps = (node) => {
if (node.componentName === 'TinyGrid') {
handleTinyGridColumnsSlots(node)
}
}

const generateNodesMap = (nodes, parent) => {
nodes.forEach((nodeItem) => {
if (!nodeItem.id) {
Expand All @@ -84,6 +115,8 @@ const generateNodesMap = (nodes, parent) => {
parent
})

handleNodesInProps(nodeItem)

if (Array.isArray(nodeItem.children) && nodeItem.children.length) {
generateNodesMap(nodeItem.children, nodeItem)
}
Expand Down

0 comments on commit a73706a

Please sign in to comment.