+ var documentDirty = false;
+ var draftDirty = false;
+
+ var documentProperties = {};
+ var data = sandbox.getBootstrappedData();
+ Object.keys(data)
+ .filter(function(key) {
+ return key !== 'history' && key !== 'document';
+ })
+ .forEach(function(key) {
+ documentProperties[key] = data[key];
+ });
+
+ var wlxmlDocument, text;
+
+ var loadDocument = function(text, isDraft, draftTimestamp) {
+ logger.debug('loading document');
+ try {
+ wlxmlDocument = wlxml.WLXMLDocumentFromXML(text, {}, Document);
+ } catch(e) {
+ logger.exception(e);
+ alert(gettext('This document contains errors and can\'t be loaded. :(')); // TODO
+ wlxmlDocument = wlxml.WLXMLDocumentFromXML(stubDocument, {}, Document);
+ }
+
+ wlxmlDocument.registerExtension(listExtension);
+ sandbox.getPlugins().forEach(function(plugin) {
+ if(plugin.documentExtension) {
+ wlxmlDocument.registerExtension(plugin.documentExtension);
+ }
+ });
+
+ var modificationFlag = true;
+ var handleChange = function() {
+ documentDirty = true;
+ draftDirty = true;
+ modificationFlag = true;
+ };
+ wlxmlDocument.on('change', handleChange);
+ wlxmlDocument.on('contentSet', handleChange);