X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/d85313d7ac6ab318a237df3987ea92f0e42d41c7..6c3dfb35e4a92d05de9ffcfd7d6e23a9a9cb32fe:/modules/visualEditor.transformations.js?ds=inline diff --git a/modules/visualEditor.transformations.js b/modules/visualEditor.transformations.js index c2b0d3a..7374f2e 100644 --- a/modules/visualEditor.transformations.js +++ b/modules/visualEditor.transformations.js @@ -20,16 +20,24 @@ if(typeof module !== 'undefined' && module.exports) { tagName = tagName.toLowerCase(); console.log('running ' + tagName); toret.find(tagName).replaceWith(function() { - var suffix = tagName !== 'div' ? tagName : 'block'; - return $('
').attr('wlxml-tag', suffix).append($(this).contents()); + var toret = $('
').attr('wlxml-tag', tagName); + var currentTag = $(this); + if(currentTag.attr('class')) + toret.attr('wlxml-class', currentTag.attr('class')); + toret.append(currentTag.contents()); + return toret; }); }); toInline.forEach(function(tagName) { tagName = tagName.toLowerCase(); toret.find(tagName).replaceWith(function() { - var node = this; - return $('').attr('wlxml-tag', tagName).append($(this).contents()); + var currentTag = $(this); + var toret = $('').attr('wlxml-tag', tagName); + if(currentTag.attr('class')) + toret.attr('wlxml-class', currentTag.attr('class')); + toret.append(currentTag.contents()); + return toret; }); }); return toret.children(); @@ -60,7 +68,11 @@ if(typeof module !== 'undefined' && module.exports) { toret.find('div, span').replaceWith(function() { var div = $(this); var tagName = div.attr('wlxml-tag'); - return $('<'+tagName+'>').append(div.contents()); + var toret = $('<'+tagName+'>'); + if(div.attr('wlxml-class')) + toret.attr('class', div.attr('wlxml-class')) + toret.append(div.contents()); + return toret; }); var meta = $('');