|
1 | 1 | import { fillParent, refreshIds, unionTopics } from './utils/index' |
2 | 2 | import { findEle, createExpander, shapeTpc } from './utils/dom' |
3 | 3 | import { deepClone } from './utils/index' |
4 | | -import type { Topic } from './types/dom' |
| 4 | +import type { Children, Topic } from './types/dom' |
5 | 5 | import { DirectionClass, type MindElixirInstance, type NodeObj } from './types/index' |
6 | 6 | import { insertNodeObj, insertParentNodeObj, moveUpObj, moveDownObj, removeNodeObj, moveNodeObj } from './utils/objectManipulation' |
7 | 7 | import { addChildDom, removeNodeDom } from './utils/domManipulation' |
@@ -292,14 +292,25 @@ const moveNode = (from: Topic[], type: 'before' | 'after', to: Topic, mei: MindE |
292 | 292 | from = from.reverse() |
293 | 293 | } |
294 | 294 | const toObj = to.nodeObj |
| 295 | + const c: Children[] = [] |
295 | 296 | for (const f of from) { |
296 | 297 | const obj = f.nodeObj |
297 | 298 | moveNodeObj(type, obj, toObj) |
298 | 299 | fillParent(mei.nodeData) |
299 | 300 | rmSubline(f) |
300 | | - const fromGrp = f.parentElement.parentNode |
301 | | - const toGrp = to.parentElement.parentNode |
302 | | - toGrp.insertAdjacentElement(typeMap[type], fromGrp) |
| 301 | + const fromWrp = f.parentElement.parentNode |
| 302 | + if (!c.includes(fromWrp.parentElement)) { |
| 303 | + c.push(fromWrp.parentElement) |
| 304 | + } |
| 305 | + const toWrp = to.parentElement.parentNode |
| 306 | + toWrp.insertAdjacentElement(typeMap[type], fromWrp) |
| 307 | + } |
| 308 | + // remove expander and empty wrapper |
| 309 | + for (const item of c) { |
| 310 | + if (item.childElementCount === 0 && item.tagName !== 'ME-MAIN') { |
| 311 | + item.previousSibling.children[1]!.remove() |
| 312 | + item.remove() |
| 313 | + } |
303 | 314 | } |
304 | 315 | mei.linkDiv() |
305 | 316 | mei.bus.fire('operation', { |
|
0 commit comments