minor fix
[fnpeditor.git] / src / editor / plugins / core / switch.js
index ff49eb8..e3ec5c4 100644 (file)
@@ -41,7 +41,7 @@ var createSwitchAction = function(createParams) {
 
             description = gettext('Switch to') + ' ' + createParams.to.name;
             return _.extend(state, {
-                allowed: !!toSwitch,
+                allowed: !!toSwitch || alreadyInTarget,
                 toggled: alreadyInTarget,
                 description: description,
                 execute: alreadyInTarget ? function() {} : function(callback) {
@@ -55,7 +55,8 @@ var createSwitchAction = function(createParams) {
                         return f.document.createFragment(f.CaretFragment, {node: f.document.getNodeByPath(textNodePath), offset: f.offset});
                     }, {
                         metadata: {
-                            description: description
+                            description: description,
+                            fragment: params.fragment
                         },
                         success: callback
                     });
@@ -66,12 +67,14 @@ var createSwitchAction = function(createParams) {
 };
 
 var headerAction = createSwitchAction({name: 'switchToHeader', from: {tagName: 'div', klass: 'p'}, to: {tagName: 'header', klass: '', name: gettext('header')}}),
-    paragraphAction = createSwitchAction({name: 'switchToParagraph', from: {tagName: 'header'}, to: {tagName: 'div', klass: 'p', name: gettext('paragraf')}});
+    paragraphAction = createSwitchAction({name: 'switchToParagraph', from: {tagName: 'header'}, to: {tagName: 'div', klass: 'p', name: gettext('paragraph')}}),
+    imageAction = createSwitchAction({name: 'switchToImage', from: {tagName: 'div'}, to: {tagName: 'div', klass: 'img', name: gettext('image')}}),
+    videoAction = createSwitchAction({name: 'switchToVideo', from: {tagName: 'div'}, to: {tagName: 'div', klass: 'video', name: gettext('video')}});
 
 return {
-    actions: [headerAction, paragraphAction],
+    actions: [headerAction, paragraphAction, imageAction, videoAction],
     canvasActionHandler: {
-        handles: [headerAction, paragraphAction],
+        handles: [headerAction, paragraphAction, imageAction, videoAction]
         // handle: function(canvas, action, ret) {
         //     var params = {},
         //         f;