2
0
mirror of https://github.com/Ionaru/easy-markdown-editor synced 2025-06-27 13:11:01 -06:00

Fix relative image url fetched from stylesheet domain

Partial URLs are interpreted relative to the source of
the style sheet, not relative to the document
https://www.w3.org/TR/CSS1/
This commit is contained in:
S1m 2024-06-04 10:43:57 +02:00
parent f039bae67f
commit 9b420ac103

View File

@ -2233,8 +2233,9 @@ EasyMDE.prototype.render = function (el) {
function assignImageBlockAttributes(parentEl, img) {
parentEl.setAttribute('data-img-src', img.url);
parentEl.setAttribute('style', '--bg-image:url(' + img.url + ');--width:' + img.naturalWidth + 'px;--height:' + calcHeight(img.naturalWidth, img.naturalHeight));
var url = (new URL(img.url, document.baseURI)).href;
parentEl.setAttribute('data-img-src', url);
parentEl.setAttribute('style', '--bg-image:url(' + url + ');--width:' + img.naturalWidth + 'px;--height:' + calcHeight(img.naturalWidth, img.naturalHeight));
_vm.codemirror.setSize();
}