X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/bf8e16e2a24ce9828193a3b4145dfdbc5b94a935..fb1b343bcfc05dbdd9f5d4d2d6ad9f243bb21300:/src/editor/modules/data/document.js diff --git a/src/editor/modules/data/document.js b/src/editor/modules/data/document.js index 0dbff14..23aa000 100644 --- a/src/editor/modules/data/document.js +++ b/src/editor/modules/data/document.js @@ -38,6 +38,21 @@ _.extend(Document.prototype, { }); }.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; + }, + getLinkForUrl: function(url) { + /* globals window */ + var baseUrl = function(url) {return url.split('/').slice(0,-1).join('/');}; + if(baseUrl(url) === baseUrl(window.location.origin + this.getUrlForLink('file://test'))) { + return 'file://' + _.last(url.split('/')); + } + return url; } });