fnp
/
fnpeditor.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
deeb9be
)
editor: links - proper linking to document attachments
author
Aleksander Łukasz
<aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 6 May 2014 14:40:05 +0000
(16:40 +0200)
committer
Aleksander Łukasz
<aleksander.lukasz@nowoczesnapolska.org.pl>
Tue, 6 May 2014 14:51:58 +0000
(16:51 +0200)
src/editor/modules/data/data.js
patch
|
blob
|
history
src/editor/modules/data/document.js
patch
|
blob
|
history
src/editor/plugins/core/links/box.html
patch
|
blob
|
history
src/editor/plugins/core/links/linkElement.js
patch
|
blob
|
history
diff --git
a/src/editor/modules/data/data.js
b/src/editor/modules/data/data.js
index
38a80a9
..
8b8851a
100644
(file)
--- a/
src/editor/modules/data/data.js
+++ b/
src/editor/modules/data/data.js
@@
-37,7
+37,7
@@
return function(sandbox) {
var loadDocument = function(text, isDraft, draftTimestamp) {
logger.debug('loading document');
try {
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
} catch(e) {
logger.exception(e);
alert(gettext('This document contains errors and can\'t be loaded. :(')); // TODO
diff --git
a/src/editor/modules/data/document.js
b/src/editor/modules/data/document.js
index
0dbff14
..
db2b7a8
100644
(file)
--- a/
src/editor/modules/data/document.js
+++ b/
src/editor/modules/data/document.js
@@
-38,6
+38,13
@@
_.extend(Document.prototype, {
});
}.bind(this);
return wlxml.WLXMLDocument.prototype.transaction.call(this, body, params);
});
}.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;
}
});
}
});
diff --git
a/src/editor/plugins/core/links/box.html
b/src/editor/plugins/core/links/box.html
index
d4594a7
..
6cf2200
100644
(file)
--- a/
src/editor/plugins/core/links/box.html
+++ b/
src/editor/plugins/core/links/box.html
@@
-1,5
+1,5
@@
<div contenteditable="false" link-box style="white-space: nowrap">
<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>
<span>
<a class="change" href="#"><%= gettext('change') %></a> |
<a class="delete" href="#"><%= gettext('remove') %></a>
diff --git
a/src/editor/plugins/core/links/linkElement.js
b/src/editor/plugins/core/links/linkElement.js
index
1214e95
..
0600733
100644
(file)
--- a/
src/editor/plugins/core/links/linkElement.js
+++ b/
src/editor/plugins/core/links/linkElement.js
@@
-17,7
+17,10
@@
_.extend(linkElement, {
genericElement.init.call(this);
_.bindAll(this, 'changeLink', 'deleteLink');
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();
this.box.find('.change').on('click', this.changeLink);
this.box.find('.delete').on('click', this.deleteLink);
this.box.hide();
@@
-30,7
+33,7
@@
_.extend(linkElement, {
if(event.meta.attr === 'href') {
var link = this.box.find('[link]');
link.text(event.meta.newVal);
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)
);
}
},
}
},