mirror of
https://github.com/wekan/wekan.git
synced 2025-12-28 21:28:49 +01:00
Merge pull request #5252 from Lewiscowles1986/fix/export-html-popup
Fix: export html popup
This commit is contained in:
commit
554bec4f1e
1 changed files with 48 additions and 0 deletions
|
|
@ -57,6 +57,9 @@ window.ExportHtml = Popup => {
|
|||
Array.from(
|
||||
document.querySelectorAll('#header-main-bar .board-header-btns'),
|
||||
).forEach(elem => elem.remove());
|
||||
Array.from(
|
||||
document.querySelectorAll('.js-pop-over, .pop-over'),
|
||||
).forEach(elem => elem.remove());
|
||||
Array.from(document.querySelectorAll('.list-composer')).forEach(elem =>
|
||||
elem.remove(),
|
||||
);
|
||||
|
|
@ -152,6 +155,50 @@ window.ExportHtml = Popup => {
|
|||
);
|
||||
};
|
||||
|
||||
const getWebFonts = () => {
|
||||
fontUrls = [];
|
||||
|
||||
for (let sheet of document.styleSheets) {
|
||||
// Get the base URL of the stylesheet
|
||||
let baseUrl = sheet.href ? new URL(sheet.href).origin : window.location.origin;
|
||||
|
||||
try {
|
||||
for (let rule of sheet.cssRules) {
|
||||
if (rule.type === CSSRule.FONT_FACE_RULE) {
|
||||
let src = rule.style.getPropertyValue('src');
|
||||
let urlMatch = src.match(/url\(["']?(.+?)["']?\)/);
|
||||
if (urlMatch) {
|
||||
let fontUrl = urlMatch[1];
|
||||
|
||||
// Resolve the URL relative to the stylesheet's base URL
|
||||
let resolvedUrl = new URL(fontUrl, baseUrl);
|
||||
fontUrls.push(resolvedUrl.href); // Using .href to get the absolute URL
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log('Access to stylesheet blocked:', e);
|
||||
}
|
||||
}
|
||||
|
||||
return fontUrls;
|
||||
};
|
||||
|
||||
const downloadFonts = async(elements, zip) => {
|
||||
await asyncForEach(elements, async elem => {
|
||||
const response = await fetch(elem);
|
||||
const responseBody = await response.blob();
|
||||
const filename = elem.split('/')
|
||||
.pop()
|
||||
.split('?')
|
||||
.shift()
|
||||
.split('#')
|
||||
.shift();
|
||||
const fileFullPath = `webfonts/${filename}`;
|
||||
zip.file(fileFullPath, responseBody);
|
||||
});
|
||||
}
|
||||
|
||||
const downloadCardCovers = async (elements, zip, boardSlug) => {
|
||||
await asyncForEach(elements, async elem => {
|
||||
const response = await fetch(
|
||||
|
|
@ -194,6 +241,7 @@ window.ExportHtml = Popup => {
|
|||
await downloadStylesheets(getStylesheetList(), zip);
|
||||
await downloadSrcAttached(getSrcAttached(), zip, boardSlug);
|
||||
await downloadCardCovers(getCardCovers(), zip, boardSlug);
|
||||
await downloadFonts(getWebFonts(), zip);
|
||||
|
||||
addBoardHTMLToZip(boardSlug, zip);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue