X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/3185249361cacf28b88b00093f8b262795c8fa3c..6c3dfb35e4a92d05de9ffcfd7d6e23a9a9cb32fe:/modules/visualEditor.transformations.js diff --git a/modules/visualEditor.transformations.js b/modules/visualEditor.transformations.js index cfb5877..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 $('
').addClass('rng rng-' + 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 $('').addClass('rng rng-' + 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(); @@ -59,8 +67,12 @@ if(typeof module !== 'undefined' && module.exports) { toret.find('div, span').replaceWith(function() { var div = $(this); - var tagName = div.attr('class').split('rng-')[1]; - return $('<'+tagName+'>').append(div.contents()); + var tagName = div.attr('wlxml-tag'); + var toret = $('<'+tagName+'>'); + if(div.attr('wlxml-class')) + toret.attr('class', div.attr('wlxml-class')) + toret.append(div.contents()); + return toret; }); var meta = $('');