canvas manager wip - setting cursor at the beginning of a new node
[fnpeditor.git] / modules / documentCanvas / tests / utils.js
1 define(['libs/jquery-1.9.1.min'], function($) {\r
2     return {\r
3         cleanUp: function(xml) {\r
4             \r
5             var rmws = function(node) {\r
6                 if(node.nodeType === 3) {\r
7                     node.data = $.trim(node.data);\r
8                 }\r
9                 else {\r
10                     $(node).contents().each(function() {\r
11                         rmws(this);\r
12                     });\r
13                 }\r
14             }\r
15             \r
16             xml = $($.trim(xml));\r
17             xml.each(function() {\r
18                 rmws(this);\r
19             });\r
20             \r
21             /*var toret = xml\r
22                 .replace(/(<.*>)\s*(<.*>)/gm, '$1$2')\r
23                 .replace(/(<\/.*>)\s*(<\/.*>)/gm, '$1$2')\r
24                 .replace(/(<\/.*>)\s*(<.*>)/gm, '$1$2');\r
25             return $.trim(toret);*/\r
26             return $('<div>').append(xml).html();\r
27         }\r
28     }\r
29 });