Visual editor: fixing transformations
authorAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 18 Apr 2013 14:12:37 +0000 (16:12 +0200)
committerAleksander Łukasz <aleksander.lukasz@nowoczesnapolska.org.pl>
Thu, 18 Apr 2013 14:12:37 +0000 (16:12 +0200)
modules/visualEditor.transformations.js

index 725aaea..0f89641 100644 (file)
@@ -20,8 +20,10 @@ if(typeof module !== 'undefined' && module.exports) {
                 tagName = tagName.toLowerCase();
                 console.log('running ' + tagName);
                 toret.find(tagName).replaceWith(function() {
-                    var toret = $('<div></div>').attr('wlxml-tag', tagName);
                     var currentTag = $(this);
+                    if(currentTag.attr('wlxml-tag'))
+                        return;
+                    var toret = $('<div></div>').attr('wlxml-tag', tagName);
                     if(currentTag.attr('class'))
                         toret.attr('wlxml-class', currentTag.attr('class').replace(/\./g, '-'));
                     toret.append(currentTag.contents());
@@ -33,6 +35,8 @@ if(typeof module !== 'undefined' && module.exports) {
                 tagName = tagName.toLowerCase();
                 toret.find(tagName).replaceWith(function() {
                     var currentTag = $(this);
+                    if(currentTag.attr('wlxml-tag'))
+                        return;
                     var toret = $('<span></span>').attr('wlxml-tag', tagName);
                     if(currentTag.attr('class'))
                         toret.attr('wlxml-class', currentTag.attr('class').replace(/\./g, '-'));