fnp
/
fnpeditor.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
wlxml: small fix in list extension
[fnpeditor.git]
/
src
/
editor
/
modules
/
data
/
data.js
diff --git
a/src/editor/modules/data/data.js
b/src/editor/modules/data/data.js
index
4a9bc72
..
db17955
100644
(file)
--- a/
src/editor/modules/data/data.js
+++ b/
src/editor/modules/data/data.js
@@
-2,11
+2,16
@@
define([
'libs/jquery',
'./dialog',
'wlxml/wlxml',
'libs/jquery',
'./dialog',
'wlxml/wlxml',
- 'wlxml/extensions/list/list'
-], function($, Dialog, wlxml, listExtension) {
+ 'wlxml/extensions/list/list',
+ 'fnpjs/logging/logging',
+], function($, Dialog, wlxml, listExtension, logging) {
'use strict';
'use strict';
-/* global gettext */
+/* global gettext, alert */
+
+var logger = logging.getLogger('editor.modules.data'),
+ stubDocument = '<section><div>' + gettext('This is an empty document.') + '</div></section>';
+
return function(sandbox) {
return function(sandbox) {
@@
-14,7
+19,14
@@
return function(sandbox) {
var document_version = sandbox.getBootstrappedData().version;
var history = sandbox.getBootstrappedData().history;
var document_version = sandbox.getBootstrappedData().version;
var history = sandbox.getBootstrappedData().history;
- var wlxmlDocument = wlxml.WLXMLDocumentFromXML(sandbox.getBootstrappedData().document);
+ var wlxmlDocument;
+ try {
+ wlxmlDocument = wlxml.WLXMLDocumentFromXML(sandbox.getBootstrappedData().document);
+ } catch(e) {
+ logger.exception(e);
+ alert(gettext('This document contains errors and can\'t be loaded. :(')); // TODO
+ wlxmlDocument = wlxml.WLXMLDocumentFromXML(stubDocument);
+ }
wlxmlDocument.registerExtension(listExtension);
sandbox.getPlugins().forEach(function(plugin) {
wlxmlDocument.registerExtension(listExtension);
sandbox.getPlugins().forEach(function(plugin) {