X-Git-Url: https://git.mdrn.pl/fnpeditor.git/blobdiff_plain/bf8e16e2a24ce9828193a3b4145dfdbc5b94a935..246796c:/src/editor/modules/data/document.js?ds=inline diff --git a/src/editor/modules/data/document.js b/src/editor/modules/data/document.js index 0dbff14..15dd608 100644 --- a/src/editor/modules/data/document.js +++ b/src/editor/modules/data/document.js @@ -14,6 +14,7 @@ var logger = logging.getLogger('document'); var Document = function() { wlxml.WLXMLDocument.apply(this, Array.prototype.slice.call(arguments, 0)); + this.properties = {}; }; Document.prototype = Object.create(wlxml.WLXMLDocument.prototype); @@ -38,9 +39,44 @@ _.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; + }, + setProperty: function(propName, propValue) { + if(this.properties[propName] !== propValue) { + this.properties[propName] = propValue; + this.trigger('propertyChanged', propName, propValue); + } } }); -return Document; +var DumbDocument = function() { + Document.apply(this, Array.prototype.slice.call(arguments, 0)); +}; +DumbDocument.prototype = Object.create(Document.prototype); +_.extend(DumbDocument.prototype, { + loadXML: function(xml) { + this._xml = xml; + this.trigger('contentSet'); + }, + toXML: function() { + return this._xml; + } +}); + +return {Document: Document, DumbDocument: DumbDocument}; }); \ No newline at end of file