var loadDocument = function(text, isDraft, draftTimestamp) {
logger.debug('loading document');
try {
- wlxmlDocument = wlxml.WLXMLDocumentFromXML(text, {}, Document);
+ wlxmlDocument = wlxml.WLXMLDocumentFromXML(text, {editorConfig: sandbox.getConfig()}, Document);
} catch(e) {
logger.exception(e);
alert(gettext('This document contains errors and can\'t be loaded. :(')); // TODO
});
}.bind(this);
return wlxml.WLXMLDocument.prototype.transaction.call(this, body, params);
+ },
+ getUrlForLink: function(link) {
+ var cfg = this.options.editorConfig;
+ if(link.substr(0, 7) === 'file://' && cfg && cfg.documentAttachmentUrl) {
+ link = cfg.documentAttachmentUrl(link.substr(7));
+ }
+ return link;
}
});
<div contenteditable="false" link-box style="white-space: nowrap">
- <a link target="blank" href="<%= href %>"><%= href %></a> --
+ <a link target="blank" href="<%= url %>"><%= text %></a> --
<span>
<a class="change" href="#"><%= gettext('change') %></a> |
<a class="delete" href="#"><%= gettext('remove') %></a>
genericElement.init.call(this);
_.bindAll(this, 'changeLink', 'deleteLink');
- this.box = $(_.template(boxTemplate)({href: this.wlxmlNode.getAttr('href')}));
+ var linkText = this.wlxmlNode.getAttr('href'),
+ linkUrl = this.wlxmlNode.document.getUrlForLink(linkText);
+
+ this.box = $(_.template(boxTemplate)({text: linkText, url: linkUrl}));
this.box.find('.change').on('click', this.changeLink);
this.box.find('.delete').on('click', this.deleteLink);
this.box.hide();
if(event.meta.attr === 'href') {
var link = this.box.find('[link]');
link.text(event.meta.newVal);
- link.attr('href', event.meta.newVal);
+ link.attr('href', this.wlxmlNode.document.getUrlForLink(event.meta.newVal));
}
},