diff --git a/index.html b/index.html index ca318cc..5b78a5a 100644 --- a/index.html +++ b/index.html @@ -237,7 +237,7 @@ Publish - + @@ -1301,6 +1301,89 @@ getRef('preview__body').append(frag) window.location.hash = `#/preview?articleID=${currentArticle.id}` } + + function downloadHTML(string, options = {}) { + const { title } = options + const element = createElement('a', { + attributes: { + 'href': 'data:text/html;charset=utf-8,' + encodeURIComponent(string), + 'download': `${title ? title : 'article'}.html`, + 'style': 'display:none' + } + }); + + document.body.appendChild(element); + + element.click(); + + document.body.removeChild(element); + } + + function exportSelection() { + const bodyTemplate = getRef('body_template').content.cloneNode(true) + const composedDocumentStructure = {} + floGlobals.appObjects[currentArticle.id].sections.forEach(section => composedDocumentStructure[section.id] = []) + selectedContent.forEach(({ content, sectionID }, uid) => { + composedDocumentStructure[sectionID].push({ content, uid }) + }) + for (const section in composedDocumentStructure) { + if (!composedDocumentStructure[section].length) + delete composedDocumentStructure[section] + } + let frag = document.createDocumentFragment() + + for (const section in composedDocumentStructure) { + frag.append(createElement('h3', { + textContent: currentArticle.sections[section].title + })) + composedDocumentStructure[section].forEach(({ content, uid }) => { + const group = createElement('section', { + className: 'grid gap-1', + innerHTML: content + }) + frag.append(group) + }) + } + const articleTitle = floGlobals.appObjects.cc.articleList[currentArticle.id].title + bodyTemplate.querySelector('#exported_title').textContent = articleTitle + bodyTemplate.querySelector('#exported_time').textContent = `Exported on ${getFormattedTime(Date.now())}` + bodyTemplate.querySelector('#export_body').innerHTML = '' + bodyTemplate.querySelector('#export_body').append(frag) + let bodyAttributes = '' + let extraScripts = '' + if (isSubAdmin) { + bodyAttributes = `data-article-id="${currentArticle.id}" onload="onLoadStartUp()"` + // copy script already present in this file instead of storing a duplicate + extraScripts = ` + ${getRef('voting_enabled').innerHTML} + + + + + + + + + + + + + + + + + + + + RanchiMall Times + + + + + + + + + + + + + + + + + + Article by - + + created with RanchiMall Content collaboration app + + + + + + + + + + + + + + + + + + Sign in to like this article + Liking an article supports the creators. + + + + Sign In + + + New here? Generate your FLO credentials below to continue + + Get FLO credentials + + + + + + + + + + + + + + + + FLO credentials + You can use FLO credentials with RanchiMall Times and all RanchiMall FLO apps. + + + + FLO ID + + + + Private key + + + + Sign in with these credentials + + Keep your private key secure and don't share with anyone. + Once lost there is no way to recover private key. + + + + + + + + +
Liking an article supports the creators.
New here? Generate your FLO credentials below to continue
You can use FLO credentials with RanchiMall Times and all RanchiMall FLO apps.