You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Fipamo/src/com/actions/PageActions.js

54 lines
1.8 KiB
JavaScript

import StringUtils from '../utils/StringUtils';
export default class PostActions {
//--------------------------
// constructor
//--------------------------
constructor() {}
//--------------------------
// methods
//--------------------------
collectInfo(files) {
return new Promise((resolve, reject) => {
let pageInfo = [];
let pageRef = document.querySelector('[role="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
//--------------------------
}