This commit is contained in:
@@ -8,11 +8,10 @@ async function ayPreRender(ayAllData) {
|
|||||||
PreParedReportDataObject = await ayPrepareData(ayAllData);
|
PreParedReportDataObject = await ayPrepareData(ayAllData);
|
||||||
} else {
|
} else {
|
||||||
PreParedReportDataObject = ayAllData;
|
PreParedReportDataObject = ayAllData;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////
|
///////////////////////////////////////
|
||||||
// Set our stock handlebars helpers
|
// Set our stock handlebars helpers
|
||||||
//
|
//
|
||||||
@@ -45,8 +44,13 @@ function ayRegisterHelpers() {
|
|||||||
if (ayValue == null) {
|
if (ayValue == null) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//replace attachment urls with tokenized local urls
|
||||||
|
let src = ayValue.replace(/\[ATTACH:(.*)\]/g, function (match, p1) {
|
||||||
|
return attachmentDownloadUrl(p1);
|
||||||
|
});
|
||||||
return new Handlebars.SafeString(
|
return new Handlebars.SafeString(
|
||||||
DOMPurify.sanitize(marked(ayValue, { breaks: true }))
|
DOMPurify.sanitize(marked(src, { breaks: true }))
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -319,3 +323,24 @@ function ayPad(n, width, z) {
|
|||||||
n = n + "";
|
n = n + "";
|
||||||
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
|
return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////////////////////////////
|
||||||
|
// attachment download URL
|
||||||
|
//
|
||||||
|
function attachmentDownloadUrl(fileId, ctype) {
|
||||||
|
//http://localhost:7575/api/v8/attachment/download/100?t=sssss
|
||||||
|
//Ctype is optional and is the MIME content type, used to detect image urls at client for drag and drop ops
|
||||||
|
//in wiki but ignored by server
|
||||||
|
|
||||||
|
let url =
|
||||||
|
"attachment/download/" +
|
||||||
|
fileId +
|
||||||
|
"?t=" +
|
||||||
|
AYMETA.ayClientMetaData.DownloadToken;
|
||||||
|
|
||||||
|
if (ctype && ctype.includes("image")) {
|
||||||
|
url += "&i=1";
|
||||||
|
}
|
||||||
|
|
||||||
|
return AYMETA.ayServerMetaData.ayApiUrl + url;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user