From 740e12cfcbd71be16f48acbe7f2328dc7e009e21 Mon Sep 17 00:00:00 2001 From: Muhammad Junaid <61476900+m-jojo-s@users.noreply.github.com> Date: Wed, 30 Mar 2022 10:29:11 +0500 Subject: [PATCH 1/2] append block on click next to selected component --- src/block_manager/view/BlockView.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/block_manager/view/BlockView.js b/src/block_manager/view/BlockView.js index 4adee76f7..bde80e554 100644 --- a/src/block_manager/view/BlockView.js +++ b/src/block_manager/view/BlockView.js @@ -38,7 +38,7 @@ export default Backbone.View.extend({ const content = model.get('content'); const selected = em.getSelected(); sorter.setDropContent(content); - let target, valid; + let target, valid, insertAt; // If there is a selected component, try first to append // the block inside, otherwise, try to place it as a next sibling @@ -50,7 +50,10 @@ export default Backbone.View.extend({ } else { const parent = selected.parent(); valid = sorter.validTarget(parent.getEl(), content); - if (valid.valid) target = parent; + if (valid.valid) { + target = parent; + insertAt = parent.components().indexOf(selected); + } } } @@ -61,7 +64,7 @@ export default Backbone.View.extend({ if (valid.valid) target = wrapper; } - const result = target && target.append(content)[0]; + const result = target && target.append(content, {at: insertAt})[0]; result && em.setSelected(result, { scroll: 1 }); }, From 583eae73adb716fbba84c749ef01675e07825540 Mon Sep 17 00:00:00 2001 From: Muhammad Junaid <61476900+m-jojo-s@users.noreply.github.com> Date: Wed, 30 Mar 2022 10:29:48 +0500 Subject: [PATCH 2/2] fixed index --- src/block_manager/view/BlockView.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/block_manager/view/BlockView.js b/src/block_manager/view/BlockView.js index bde80e554..f82b59589 100644 --- a/src/block_manager/view/BlockView.js +++ b/src/block_manager/view/BlockView.js @@ -52,7 +52,7 @@ export default Backbone.View.extend({ valid = sorter.validTarget(parent.getEl(), content); if (valid.valid) { target = parent; - insertAt = parent.components().indexOf(selected); + insertAt = parent.components().indexOf(selected) + 1; } } }