1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-07-28 01:29:42 +02:00

Editorjs checklist tool (#98)

Co-authored-by: Peter Savchenko <specc.dev@gmail.com>
This commit is contained in:
Alexander Menshikov 2020-05-09 05:38:25 +03:00 committed by GitHub
parent c0a4f6f3fd
commit b744ed592a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
30 changed files with 2628 additions and 2152 deletions

View file

@ -6,7 +6,6 @@ const Alias = require('../models/alias');
*/
class Aliases {
/**
* @static
* Find and return entity with given alias
*
* @param {string} aliasName - alias name of entity

View file

@ -7,7 +7,6 @@ const Alias = require('../models/alias');
*/
class Pages {
/**
* @static
* Fields required for page model creation
*
* @returns {['title', 'body']}
@ -17,7 +16,6 @@ class Pages {
}
/**
* @static
* Find and return page model with passed id
*
* @param {string} id - page id
@ -43,20 +41,18 @@ class Pages {
}
/**
* @static
* Return all pages without children of passed page
*
* @param {string} parent - id of current page
* @returns {Promise<Page[]>}
*/
static async getAllExceptChildren(parent) {
let pagesAvailable = this.removeChildren(await Pages.getAll(), parent);
const pagesAvailable = this.removeChildren(await Pages.getAll(), parent);
return pagesAvailable.filter((item) => item !== null);
}
/**
* @static
* Set all children elements to null
*
* @param {Page[]} [pagesAvailable] - Array of all pages
@ -71,6 +67,7 @@ class Pages {
pagesAvailable[index] = null;
pagesAvailable = Pages.removeChildren(pagesAvailable, item._id);
});
return pagesAvailable;
}
@ -91,7 +88,7 @@ class Pages {
if (insertedPage.uri) {
const alias = new Alias({
id: insertedPage._id,
type: Alias.types.PAGE
type: Alias.types.PAGE,
}, insertedPage.uri);
alias.save();
@ -161,7 +158,7 @@ class Pages {
if (updatedPage.uri) {
const alias = new Alias({
id: updatedPage._id,
type: Alias.types.PAGE
type: Alias.types.PAGE,
}, updatedPage.uri);
alias.save();

View file

@ -70,8 +70,8 @@ class PagesOrder {
* @param {Page[]} pages - list of all available pages
* @param {string} currentPageId - page's id around which we are ordering
* @param {string} parentPageId - parent page's id that contains page above
* @param {Boolean} ignoreSelf - should we ignore current page in list or not
* @return {Page[]}
* @param {boolean} ignoreSelf - should we ignore current page in list or not
* @returns {Page[]}
*/
static async getOrderedChildren(pages, currentPageId, parentPageId, ignoreSelf = false) {
const children = await Model.get(parentPageId);

View file

@ -17,6 +17,7 @@ const config = require('../../config');
class Transport {
/**
* Saves file passed from client
*
* @param {object} multerData - file data from multer
* @param {string} multerData.originalname - original name of the file
* @param {string} multerData.filename - name of the uploaded file
@ -25,12 +26,18 @@ class Transport {
* @param {string} multerData.mimetype - MIME type of the uploaded file
*
* @param {object} map - object that represents how should fields of File object should be mapped to response
* @return {Promise<FileData>}
* @returns {Promise<FileData>}
*/
static async save(multerData, map) {
const { originalname: name, path, filename, size, mimetype } = multerData;
const file = new Model({ name, filename, path, size, mimetype });
const file = new Model({
name,
filename,
path,
size,
mimetype,
});
await file.save();
@ -45,9 +52,10 @@ class Transport {
/**
* Fetches file by passed URL
*
* @param {string} url - URL of the file
* @param {object} map - object that represents how should fields of File object should be mapped to response
* @return {Promise<FileData>}
* @returns {Promise<FileData>}
*/
static async fetch(url, map) {
const fetchedFile = await fetch(url);
@ -64,7 +72,7 @@ class Transport {
filename: `${filename}.${ext}`,
path: `${config.uploads}/${filename}.${ext}`,
size: buffer.length,
mimetype: type ? type.mime : fetchedFile.headers.get('content-type')
mimetype: type ? type.mime : fetchedFile.headers.get('content-type'),
});
await file.save();
@ -94,11 +102,12 @@ class Transport {
if (fields.length > 1) {
let object = {};
let result = object;
const result = object;
fields.forEach((field, i) => {
if (i === fields.length - 1) {
object[field] = data[name];
return;
}

View file

@ -6,7 +6,6 @@ const Model = require('../models/user');
*/
class Users {
/**
* @static
* Find and return user model.
*
* @returns {Promise<User>}