From 9e4c0cadb30e7e8c0ecda34f70dd40cd321e660d Mon Sep 17 00:00:00 2001
From: chris <kokosias@yahoo.gr>
Date: Tue, 12 Dec 2023 18:36:45 +0200
Subject: [PATCH] fix matching deletion

---
 .../defaultServices/ShortCutsService/ShortCuts.js    |  3 ++-
 .../src/MatchingService/MatchingQuestion.js          | 12 ++++++------
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/wax-prosemirror-core/src/config/defaultServices/ShortCutsService/ShortCuts.js b/wax-prosemirror-core/src/config/defaultServices/ShortCutsService/ShortCuts.js
index 3c70f371c..f6b9ec07a 100644
--- a/wax-prosemirror-core/src/config/defaultServices/ShortCutsService/ShortCuts.js
+++ b/wax-prosemirror-core/src/config/defaultServices/ShortCutsService/ShortCuts.js
@@ -39,7 +39,8 @@ const backSpaceShortCut = (state, dispatch, view) => {
       node.type.name === 'fill_the_gap_container' ||
       node.type.name === 'multiple_drop_down_container' ||
       node.type.name === 'numerical_answer_container' ||
-      node.type.name === 'essay_container'
+      node.type.name === 'essay_container' ||
+      node.type.name === 'matching_container'
     ) {
       dispatch(state.tr.delete(from, from + node.nodeSize));
       // const index = $from.index($from.depth);
diff --git a/wax-questions-service/src/MatchingService/MatchingQuestion.js b/wax-questions-service/src/MatchingService/MatchingQuestion.js
index 57a60d7f8..c0f605532 100644
--- a/wax-questions-service/src/MatchingService/MatchingQuestion.js
+++ b/wax-questions-service/src/MatchingService/MatchingQuestion.js
@@ -30,13 +30,13 @@ class MatchingQuestion extends Tools {
       if (!wrapping) return false;
       tr.wrap(range, wrapping);
 
-      const map = tr.mapping.maps[0];
-      let newPos = 0;
-      map.forEach((_from, _to, _newFrom, newTo) => {
-        newPos = newTo;
-      });
+      // const map = tr.mapping.maps[0];
+      // let newPos = 0;
+      // map.forEach((_from, _to, _newFrom, newTo) => {
+      //   newPos = newTo;
+      // });
 
-      tr.setSelection(TextSelection.create(tr.doc, range.$to.pos));
+      tr.setSelection(TextSelection.create(tr.doc, range.$to.pos + 1));
       const option = state.config.schema.nodes.matching_option.create(
         { id: uuidv4(), isfirst: true },
         Fragment.empty,
-- 
GitLab