forked from projects/fipamo
ro
a53723f7c8
the role attribute is being used incorrectly through out the site, which is bad for screen reader, so they need to be removed and replaced with the class attribute the page editor was the biggest culprit, so that one has been converted first
54 lines
1.8 KiB
JavaScript
54 lines
1.8 KiB
JavaScript
import StringUtils from '../utils/StringUtils.js';
|
|
export default class PostActions {
|
|
//--------------------------
|
|
// constructor
|
|
//--------------------------
|
|
constructor() {}
|
|
//--------------------------
|
|
// methods
|
|
//--------------------------
|
|
collectInfo(files) {
|
|
return new Promise((resolve, reject) => {
|
|
let pageInfo = [];
|
|
let pageRef = document.querySelector('.file-manager');
|
|
//process html content for storage
|
|
let txt = document.createElement('textarea');
|
|
txt.innerHTML = document.getElementById('highlight-content').innerHTML;
|
|
let html = txt.value;
|
|
html = html.replace(/<\/?span[^>]*>/g, ''); //removes prism styling
|
|
html = html.replace(/<\/?br[^>]*>/g, '\n'); //convert back to encoded line break for storage
|
|
//build data object
|
|
pageInfo = {
|
|
id: pageRef.getAttribute('data-index'),
|
|
uuid: pageRef.getAttribute('data-uuid'),
|
|
layout: document.getElementById('page-templates').value,
|
|
current_title: pageRef.getAttribute('data-slug'),
|
|
content: html,
|
|
title: document.getElementById('post-title-text').value,
|
|
created: document.getElementById('post-date').getAttribute('data-raw'),
|
|
slug: new StringUtils().cleanString(
|
|
document.getElementById('post-title-text').value
|
|
),
|
|
tags: document.getElementById('post-tags').value,
|
|
menu: document
|
|
.getElementById('option-menu-pin')
|
|
.getAttribute('data-active'),
|
|
featured: document
|
|
.getElementById('option-feature')
|
|
.getAttribute('data-active'),
|
|
published: document
|
|
.getElementById('option-published')
|
|
.getAttribute('data-active'),
|
|
form_token: document.getElementById('form_token').value,
|
|
imageList: files.images,
|
|
fileList: files.files
|
|
};
|
|
|
|
resolve(pageInfo);
|
|
});
|
|
}
|
|
//--------------------------
|
|
// event handlers
|
|
//--------------------------
|
|
}
|