From: Aleksander Ɓukasz Date: Mon, 6 May 2013 21:09:11 +0000 (+0200) Subject: Visual editor - adding metadata node if missing X-Git-Url: https://git.mdrn.pl/fnpeditor.git/commitdiff_plain/8867ca067b8cd6d88eee386f00f15a031c297a79?ds=sidebyside Visual editor - adding metadata node if missing --- diff --git a/modules/visualEditor.transformations.js b/modules/visualEditor.transformations.js index d45109f..8a32831 100644 --- a/modules/visualEditor.transformations.js +++ b/modules/visualEditor.transformations.js @@ -91,7 +91,16 @@ if(typeof module !== 'undefined' && module.exports) { }); meta.append('\n'); - toret.find('metadata').replaceWith(meta); + var metadata = toret.find('metadata'); + if(metadata.length === 0) { + var section = toret.find('section'); + section = section.length ? $(section[0]) : null; + if(section) { + section.prepend(meta) + } + } else { + metadata.replaceWith(meta); + } return vkbeautify.xml(toret.html());