editor: edumed exercise - allow for exercise insertion after the edited one
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Wed, 6 Aug 2014 12:33:24 +0000 (14:33 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 14 Aug 2014 14:26:14 +0000 (16:26 +0200)
src/editor/plugins/core/edumed/actions.js

index 97237ba..6d8051e 100644 (file)
@@ -26,6 +26,9 @@ var createAction = function(actionConfig) {
                 if(node.nodeType === Node.TEXT_NODE) {
                     node = node.parent();
                 }
                 if(node.nodeType === Node.TEXT_NODE) {
                     node = node.parent();
                 }
+                if(node.isInside('exercise')) {
+                    node = node.getParent('exercise');
+                }
 
                 node.document.transaction(function() {
                     var exerciseNode = node.after(node.document.edumedCreateExerciseNode(actionConfig.exercise)),
 
                 node.document.transaction(function() {
                     var exerciseNode = node.after(node.document.edumedCreateExerciseNode(actionConfig.exercise)),
@@ -57,7 +60,7 @@ var createAction = function(actionConfig) {
         },
         getState: function(params) {
             return {
         },
         getState: function(params) {
             return {
-                allowed: params.fragment && params.fragment.isValid() && params.fragment instanceof params.fragment.NodeFragment && !params.fragment.node.isInside('exercise'),
+                allowed: params.fragment && params.fragment.isValid() && params.fragment instanceof params.fragment.NodeFragment,
                 description: gettext('Insert exercise: ' + actionConfig.exerciseTitle)
             };
         }
                 description: gettext('Insert exercise: ' + actionConfig.exerciseTitle)
             };
         }