mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-09-18 03:20:03 +08:00
fix(editor): 多选后拖动,组件树会收缩
This commit is contained in:
parent
a6ecbb66d1
commit
40410292d7
@ -33,7 +33,7 @@
|
||||
</slot>
|
||||
</template>
|
||||
|
||||
<template v-if="pageLength > 0" #right>
|
||||
<template v-if="pageLength > 0 && nodes.length === 1" #right>
|
||||
<TMagicScrollbar>
|
||||
<slot name="props-panel"></slot>
|
||||
</TMagicScrollbar>
|
||||
@ -68,6 +68,7 @@ withDefaults(
|
||||
const { editorService, uiService } = inject<Services>('services') || {};
|
||||
|
||||
const root = computed(() => editorService?.get<MApp>('root'));
|
||||
const nodes = computed(() => editorService?.get<Node[]>('nodes') || []);
|
||||
|
||||
const pageLength = computed(() => editorService?.get<number>('pageLength') || 0);
|
||||
const showSrc = computed(() => uiService?.get<boolean>('showSrc'));
|
||||
|
@ -215,31 +215,26 @@ const expandNodes = () => {
|
||||
});
|
||||
};
|
||||
|
||||
watch(
|
||||
() => editorService?.get('nodes'),
|
||||
(nodes) => {
|
||||
if (!tree.value) return;
|
||||
if (!editorService) return;
|
||||
if (!nodes) return;
|
||||
selectedNodes.value = nodes as unknown as MNode[];
|
||||
watch([() => editorService?.get('nodes'), tree], ([nodes]) => {
|
||||
if (!tree.value || !editorService || !nodes) return;
|
||||
selectedNodes.value = nodes as unknown as MNode[];
|
||||
|
||||
const parent = editorService.get('parent');
|
||||
if (!parent?.id) return;
|
||||
const parent = editorService.get('parent');
|
||||
if (!parent?.id) return;
|
||||
|
||||
const treeNode = tree.value.getNode(parent.id);
|
||||
treeNode?.updateChildren();
|
||||
const treeNode = tree.value.getNode(parent.id);
|
||||
treeNode?.updateChildren();
|
||||
|
||||
setTimeout(() => {
|
||||
tree.value &&
|
||||
Object.entries(tree.value.getStore().nodesMap).forEach(([id, node]: [string, any]) => {
|
||||
if (node.expanded && node.data.items) {
|
||||
expandedKeys.set(id, id);
|
||||
}
|
||||
});
|
||||
expandNodes();
|
||||
});
|
||||
},
|
||||
);
|
||||
setTimeout(() => {
|
||||
tree.value &&
|
||||
Object.entries(tree.value.getStore().nodesMap).forEach(([id, node]: [string, any]) => {
|
||||
if (node.expanded && node.data.items) {
|
||||
expandedKeys.set(id, id);
|
||||
}
|
||||
});
|
||||
expandNodes();
|
||||
});
|
||||
});
|
||||
|
||||
// 设置树节点选中状态
|
||||
const setTreeKeyStatus = () => {
|
||||
|
@ -484,10 +484,10 @@ class Editor extends BaseService {
|
||||
parentNodeItems[index] = newConfig;
|
||||
|
||||
// 将update后的配置更新到nodes中
|
||||
const nodes = this.get('nodes');
|
||||
const nodes = this.get<MNode[]>('nodes') || [];
|
||||
const targetIndex = nodes.findIndex((nodeItem: MNode) => `${nodeItem.id}` === `${newConfig.id}`);
|
||||
nodes.splice(targetIndex, 1, newConfig);
|
||||
this.set('nodes', nodes);
|
||||
this.set('nodes', [...nodes]);
|
||||
|
||||
this.get<StageCore | null>('stage')?.update({
|
||||
config: cloneDeep(newConfig),
|
||||
|
@ -46,6 +46,7 @@ export const useStage = (stageOptions: StageOptions) => {
|
||||
]);
|
||||
|
||||
stage.on('select', (el: HTMLElement) => {
|
||||
if (`${editorService.get('node')?.id}` === el.id) return;
|
||||
editorService.select(el.id);
|
||||
});
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user