From 05349a5deb3f85bb2ecc40457ff12413e0a830d1 Mon Sep 17 00:00:00 2001 From: Lauri Ojansivu Date: Mon, 25 May 2020 18:04:32 +0300 Subject: Prettifier fixes. --- client/components/sidebar/sidebar.js | 2 +- client/lib/exportHTML.js | 67 ++++++++++++++++++++---------------- 2 files changed, 38 insertions(+), 31 deletions(-) diff --git a/client/components/sidebar/sidebar.js b/client/components/sidebar/sidebar.js index 7b14c1e0..b36ee6a7 100644 --- a/client/components/sidebar/sidebar.js +++ b/client/components/sidebar/sidebar.js @@ -467,7 +467,7 @@ Template.exportBoard.events({ 'click .html-export-board': async event => { event.preventDefault(); await ExportHtml(Popup)(); - } + }, }); Template.labelsWidget.events({ diff --git a/client/lib/exportHTML.js b/client/lib/exportHTML.js index fe15b6aa..b3c8d011 100644 --- a/client/lib/exportHTML.js +++ b/client/lib/exportHTML.js @@ -1,6 +1,6 @@ const JSZip = require('jszip'); -window.ExportHtml = (Popup) => { +window.ExportHtml = Popup => { const saveAs = function(blob, filename) { let dl = document.createElement('a'); dl.href = window.URL.createObjectURL(blob); @@ -12,21 +12,22 @@ window.ExportHtml = (Popup) => { dl.click(); }; - const asyncForEach = async function (array, callback) { + const asyncForEach = async function(array, callback) { for (let index = 0; index < array.length; index++) { await callback(array[index], index, array); } }; const getPageHtmlString = () => { - return `${ - window.document.querySelector('html').outerHTML - }`; + return `${window.document.querySelector('html').outerHTML}`; }; const removeAnchors = htmlString => { - const replaceOpenAnchor = htmlString.replace(new RegExp(' { @@ -83,9 +84,8 @@ window.ExportHtml = (Popup) => { elem.src = elem.src; }); Array.from(document.querySelectorAll('.is-editable')).forEach(elem => { - elem.classList.remove('is-editable') - }) - + elem.classList.remove('is-editable'); + }); }; const getBoardSlug = () => { @@ -104,7 +104,8 @@ window.ExportHtml = (Popup) => { const responseBody = await response.text(); const finalResponse = responseBody.replace( - new RegExp('packages\/[^\/]+\/upstream\/', 'gim'), '../' + new RegExp('packages/[^/]+/upstream/', 'gim'), + '../', ); const filename = elem.href @@ -138,30 +139,33 @@ window.ExportHtml = (Popup) => { }; const removeCssUrlSurround = url => { - const working = url || ""; + const working = url || ''; return working - .split("url(") - .join("") - .split("\")") - .join("") - .split("\"") - .join("") + .split('url(') + .join('') + .split('")') + .join('') + .split('"') + .join('') .split("')") - .join("") + .join('') .split("'") - .join("") - .split(")") - .join(""); + .join('') + .split(')') + .join(''); }; const getCardCovers = () => { - return Array.from(document.querySelectorAll('.minicard-cover')) - .filter(elem => elem.style['background-image']) - } + return Array.from(document.querySelectorAll('.minicard-cover')).filter( + elem => elem.style['background-image'], + ); + }; const downloadCardCovers = async (elements, zip, boardSlug) => { await asyncForEach(elements, async elem => { - const response = await fetch(removeCssUrlSurround(elem.style['background-image'])); + const response = await fetch( + removeCssUrlSurround(elem.style['background-image']), + ); const responseBody = await response.blob(); const filename = removeCssUrlSurround(elem.style['background-image']) .split('/') @@ -179,9 +183,12 @@ window.ExportHtml = (Popup) => { const addBoardHTMLToZip = (boardSlug, zip) => { ensureSidebarRemoved(); const htmlOutputPath = `${boardSlug}/index.html`; - zip.file(htmlOutputPath, new Blob([ - removeAnchors(getPageHtmlString()) - ], { type: 'application/html' })); + zip.file( + htmlOutputPath, + new Blob([removeAnchors(getPageHtmlString())], { + type: 'application/html', + }), + ); }; return async () => { @@ -202,5 +209,5 @@ window.ExportHtml = (Popup) => { const content = await zip.generateAsync({ type: 'blob' }); saveAs(content, `${boardSlug}.zip`); window.location.reload(); - } + }; }; -- cgit v1.2.3-1-g7c22