rng.modules.visualEditor = function(sandbox) {\r
+ var transformations = rng.modules.visualEditor.transformations;\r
\r
- var data = sandbox.getBootstrappedData();\r
- var view = $(sandbox.getTemplate('main')({title: data.title, content: data.text}));\r
+ var view = $(sandbox.getTemplate('main')());\r
+ var isDirty = false;\r
+ \r
+ \r
+ $('#rng-visualEditor-content', view).on('keyup', function() {\r
+ isDirty = true;\r
+ });\r
\r
-\r
return {\r
start: function() {\r
sandbox.publish('ready');\r
},\r
getView: function() {\r
return view;\r
+ },\r
+ setDocument: function(xml) {\r
+ var transformed = transformations.fromXML.getDocumentDescription(xml);\r
+ $('#rng-visualEditor-content', view).html(transformed.HTMLTree);\r
+ isDirty = false;\r
+ },\r
+ getDocument: function() {\r
+ return transformations.toXML.getXML({HTMLTree: $('#rng-visualEditor-content').text(), metadata: {}});\r
+ },\r
+ isDirty: function() {\r
+ return isDirty;\r
+ },\r
+ setDirty: function(dirty) {\r
+ isDirty = dirty;\r
}\r
\r
}\r