X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/6b27d5301b4995add87d5734e6de2d974007a196..e104b4b87dc39066cbe397984c6f0e6bcc0459f8:/src/editor/modules/data/data.js?ds=inline diff --git a/src/editor/modules/data/data.js b/src/editor/modules/data/data.js index 793d7b4..b3b9fe4 100644 --- a/src/editor/modules/data/data.js +++ b/src/editor/modules/data/data.js @@ -11,8 +11,7 @@ define([ 'use strict'; /* global gettext, alert, window */ -var logger = logging.getLogger('editor.modules.data'), - stubDocument = '
' + gettext('This is an empty document.') + '
'; +var logger = logging.getLogger('editor.modules.data'); return function(sandbox) { @@ -30,12 +29,14 @@ return function(sandbox) { var loadDocument = function(text, isDraft, draftTimestamp) { logger.debug('loading document'); + var xmlValid = true; try { - wlxmlDocument = wlxml.WLXMLDocumentFromXML(text, {editorConfig: sandbox.getConfig()}, Document); + wlxmlDocument = wlxml.WLXMLDocumentFromXML(text, {editorConfig: sandbox.getConfig()}, Document.Document); } catch(e) { logger.exception(e); - alert(gettext('This document contains errors and can\'t be loaded. :(')); // TODO - wlxmlDocument = wlxml.WLXMLDocumentFromXML(stubDocument, {}, Document); + alert(gettext('The content of this document seems to be invalid - only XML source editing will be possible. :(')); // TODO + wlxmlDocument = wlxml.WLXMLDocumentFromXML(text, {}, Document.DumbDocument); + xmlValid = false; } Object.keys(data) @@ -79,7 +80,7 @@ return function(sandbox) { } }, sandbox.getConfig().autoSaveInterval || 2500); } - sandbox.publish('ready', isDraft, draftTimestamp); + sandbox.publish('ready', isDraft, draftTimestamp, xmlValid); }; function readCookie(name) {