mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2026-05-30 04:08:04 +00:00
fix(editor): 修复移动到菜单导致节点引用异常的问题
This commit is contained in:
parent
6c40425d8c
commit
d01a28ce76
@ -1,7 +1,7 @@
|
||||
import { computed, markRaw, type ShallowRef } from 'vue';
|
||||
import { CopyDocument, Delete, DocumentCopy } from '@element-plus/icons-vue';
|
||||
|
||||
import { Id, MContainer, NodeType } from '@tmagic/core';
|
||||
import { cloneDeep, Id, MContainer, NodeType } from '@tmagic/core';
|
||||
import { calcValueByFontsize, isPage, isPageFragment } from '@tmagic/utils';
|
||||
|
||||
import ContentMenu from '@editor/components/ContentMenu.vue';
|
||||
@ -59,14 +59,19 @@ export const usePasteMenu = (menu?: ShallowRef<InstanceType<typeof ContentMenu>
|
||||
},
|
||||
});
|
||||
|
||||
const moveTo = (id: Id, { editorService }: Services) => {
|
||||
const moveTo = async (id: Id, { editorService }: Services) => {
|
||||
const nodes = editorService.get('nodes') || [];
|
||||
const parent = editorService.getNodeById(id) as MContainer;
|
||||
|
||||
if (!parent) return;
|
||||
const newNodes = cloneDeep(nodes);
|
||||
|
||||
editorService.add(nodes, parent);
|
||||
editorService.remove(nodes);
|
||||
await editorService.remove(nodes);
|
||||
|
||||
await editorService.add(newNodes, parent, {
|
||||
doNotSelect: true,
|
||||
doNotSwitchPage: true,
|
||||
});
|
||||
};
|
||||
|
||||
export const useMoveToMenu = ({ editorService }: Services): MenuButton => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user