mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
Merge branch 'master' into export-yfm
This commit is contained in:
@@ -4,8 +4,7 @@ import resolveStorageNotes from './resolveStorageNotes'
|
||||
import filenamify from 'filenamify'
|
||||
import path from 'path'
|
||||
import exportNote from './exportNote'
|
||||
import formatMarkdown from './formatMarkdown'
|
||||
import formatHTML from './formatHTML'
|
||||
import getContentFormatter from './getContentFormatter'
|
||||
|
||||
/**
|
||||
* @param {String} storageKey
|
||||
@@ -25,7 +24,7 @@ import formatHTML from './formatHTML'
|
||||
* ```
|
||||
*/
|
||||
|
||||
function exportFolder (storageKey, folderKey, fileType, exportDir, config) {
|
||||
function exportFolder(storageKey, folderKey, fileType, exportDir, config) {
|
||||
let targetStorage
|
||||
try {
|
||||
targetStorage = findStorage(storageKey)
|
||||
@@ -37,48 +36,32 @@ function exportFolder (storageKey, folderKey, fileType, exportDir, config) {
|
||||
.then(storage => {
|
||||
return resolveStorageNotes(storage).then(notes => ({
|
||||
storage,
|
||||
notes: notes.filter(note => note.folder === folderKey && !note.isTrashed && note.type === 'MARKDOWN_NOTE')
|
||||
notes: notes.filter(
|
||||
note =>
|
||||
note.folder === folderKey &&
|
||||
!note.isTrashed &&
|
||||
note.type === 'MARKDOWN_NOTE'
|
||||
)
|
||||
}))
|
||||
})
|
||||
.then(({ storage, notes }) => {
|
||||
let contentFormatter = null
|
||||
if (fileType === 'md') {
|
||||
contentFormatter = formatMarkdown({
|
||||
storagePath: storage.path,
|
||||
export: config.export
|
||||
})
|
||||
} else if (fileType === 'html') {
|
||||
contentFormatter = formatHTML({
|
||||
theme: config.ui.theme,
|
||||
fontSize: config.preview.fontSize,
|
||||
fontFamily: config.preview.fontFamily,
|
||||
codeBlockTheme: config.preview.codeBlockTheme,
|
||||
codeBlockFontFamily: config.editor.fontFamily,
|
||||
lineNumber: config.preview.lineNumber,
|
||||
indentSize: config.editor.indentSize,
|
||||
scrollPastEnd: config.preview.scrollPastEnd,
|
||||
smartQuotes: config.preview.smartQuotes,
|
||||
breaks: config.preview.breaks,
|
||||
sanitize: config.preview.sanitize,
|
||||
customCSS: config.preview.customCSS,
|
||||
allowCustomCSS: config.preview.allowCustomCSS,
|
||||
storagePath: storage.path,
|
||||
export: config.export
|
||||
})
|
||||
}
|
||||
const contentFormatter = getContentFormatter(storage, fileType, config)
|
||||
|
||||
return Promise
|
||||
.all(notes.map(note => {
|
||||
const targetPath = path.join(exportDir, `${filenamify(note.title, {replacement: '_'})}.${fileType}`)
|
||||
return Promise.all(
|
||||
notes.map(note => {
|
||||
const targetPath = path.join(
|
||||
exportDir,
|
||||
`${filenamify(note.title, { replacement: '_' })}.${fileType}`
|
||||
)
|
||||
|
||||
return exportNote(storage.key, note, targetPath, contentFormatter)
|
||||
}))
|
||||
.then(() => ({
|
||||
storage,
|
||||
folderKey,
|
||||
fileType,
|
||||
exportDir
|
||||
}))
|
||||
})
|
||||
).then(() => ({
|
||||
storage,
|
||||
folderKey,
|
||||
fileType,
|
||||
exportDir
|
||||
}))
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user