@tmagic/editor 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1417,12 +1417,15 @@ class Editor$1 extends BaseService {
1417
1417
  const node = this.get("node");
1418
1418
  const brothers = parent?.items || [];
1419
1419
  const index = brothers.findIndex((item) => `${item.id}` === `${node?.id}`);
1420
+ const layout = await this.getLayout(parent, node);
1421
+ const isRelative = layout === Layout.RELATIVE;
1422
+ brothers.splice(index, 1);
1420
1423
  if (offset === LayerOffset.TOP) {
1421
- brothers.splice(brothers.length - 1, 0, brothers.splice(index, 1)[0]);
1424
+ brothers.splice(isRelative ? 0 : brothers.length - 1, 0, node);
1422
1425
  } else if (offset === LayerOffset.BOTTOM) {
1423
- brothers.splice(0, 0, brothers.splice(index, 1)[0]);
1426
+ brothers.splice(isRelative ? brothers.length - 1 : 0, 0, node);
1424
1427
  } else {
1425
- brothers.splice(index + parseInt(`${offset}`, 10), 0, brothers.splice(index, 1)[0]);
1428
+ brothers.splice(index + (isRelative ? -offset : offset), 0, node);
1426
1429
  }
1427
1430
  const grandparent = this.getParentById(parent.id);
1428
1431
  this.get("stage")?.update({