mirror of https://github.com/status-im/codimd.git
Updated to ignore process image which already wrapped by link node
This commit is contained in:
parent
8b16e0723d
commit
1c859248e0
|
@ -260,19 +260,22 @@ function finishView(view) {
|
||||||
//image href new window(emoji not included)
|
//image href new window(emoji not included)
|
||||||
var images = view.find("img.raw[src]").removeClass("raw");
|
var images = view.find("img.raw[src]").removeClass("raw");
|
||||||
images.each(function (key, value) {
|
images.each(function (key, value) {
|
||||||
|
// if it's already wrapped by link, then ignore
|
||||||
|
var $value = $(value);
|
||||||
|
if ($value.parent()[0].nodeName === 'A') return;
|
||||||
var src = $(value).attr('src');
|
var src = $(value).attr('src');
|
||||||
var a = $('<a>');
|
var a = $('<a>');
|
||||||
if (src) {
|
if (src) {
|
||||||
a.attr('href', src);
|
a.attr('href', src);
|
||||||
a.attr('target', "_blank");
|
a.attr('target', "_blank");
|
||||||
}
|
}
|
||||||
var clone = $(value).clone();
|
var clone = $value.clone();
|
||||||
clone[0].onload = function (e) {
|
clone[0].onload = function (e) {
|
||||||
if(viewAjaxCallback)
|
if(viewAjaxCallback)
|
||||||
viewAjaxCallback();
|
viewAjaxCallback();
|
||||||
};
|
};
|
||||||
a.html(clone);
|
a.html(clone);
|
||||||
$(value).replaceWith(a);
|
$value.replaceWith(a);
|
||||||
});
|
});
|
||||||
//blockquote
|
//blockquote
|
||||||
var blockquote = view.find("blockquote.raw").removeClass("raw");
|
var blockquote = view.find("blockquote.raw").removeClass("raw");
|
||||||
|
|
Loading…
Reference in New Issue