1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-07-21 06:09:41 +02:00

Babel eslint parser (#9)

* Move testing to 3001 port
Create separate database for testing
Add runtime configuration file support

* Add babel-eslint parser
This commit is contained in:
George Berezhnoy 2018-10-07 19:25:12 +03:00 committed by GitHub
parent 452d0ae816
commit ff09f695d0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 43 additions and 14 deletions

View file

@ -7,18 +7,21 @@
* @property {string} version - used Editor version
* @property {number} time - saving time
*/
/**
* @class Writing
* @classdesc Class for create/edit pages
*/
export default class Writing {
/**
* Creates base properties
*/
constructor(){
constructor() {
this.editor = null;
this.nodes = {
editorWrapper: null,
saveButton: null,
parentIdSelector: null,
}
parentIdSelector: null
};
}
/**
@ -53,7 +56,7 @@ export default class Writing {
* Loads class for working with Editor
* @return {Promise<Editor>}
*/
async loadEditor(){
async loadEditor() {
const {default: Editor} = await import(/* webpackChunkName: "editor" */ './../classes/editor');
return new Editor();
@ -64,7 +67,7 @@ export default class Writing {
* @throws {Error} - validation error
* @return {Promise.<{parent: string, body: {editorData}}>}
*/
async getData(){
async getData() {
const editorData = await this.editor.save();
const firstBlock = editorData.blocks.length ? editorData.blocks[0] : null;
const title = firstBlock && firstBlock.type === 'header' ? firstBlock.data.text : null;
@ -82,7 +85,7 @@ export default class Writing {
/**
* Handler for clicks on the Save button
*/
async saveButtonClicked(){
async saveButtonClicked() {
try {
const writingData = await this.getData();
@ -90,24 +93,23 @@ export default class Writing {
let response = await fetch('/page', {
method: 'PUT',
headers: {
"Content-Type": "application/json; charset=utf-8",
'Content-Type': 'application/json; charset=utf-8'
},
body: JSON.stringify(writingData),
body: JSON.stringify(writingData)
});
response = await response.json();
if (response.success){
if (response.success) {
document.location = '/page/' + response.result._id;
} else {
alert(response.error);
console.log('Validation failed:', response.error);
}
} catch (sendingError) {
console.log('Saving request failed:', sendingError);
}
} catch (savingError){
} catch (savingError) {
alert(savingError);
console.log('Saving error: ', savingError);
}