mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 09:46:22 +00:00
add targetDir parameter to outputFormatter
This commit is contained in:
@@ -295,7 +295,7 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
this.exportAsDocument('md')
|
this.exportAsDocument('md')
|
||||||
}
|
}
|
||||||
|
|
||||||
htmlContentFormatter (noteContent, exportTasks) {
|
htmlContentFormatter (noteContent, exportTasks, targetDir) {
|
||||||
const {
|
const {
|
||||||
fontFamily,
|
fontFamily,
|
||||||
fontSize,
|
fontSize,
|
||||||
@@ -339,6 +339,7 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
|
|
||||||
return `<html>
|
return `<html>
|
||||||
<head>
|
<head>
|
||||||
|
<base href="file://${targetDir}/">
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name = "viewport" content = "width = device-width, initial-scale = 1, maximum-scale = 1">
|
<meta name = "viewport" content = "width = device-width, initial-scale = 1, maximum-scale = 1">
|
||||||
<style id="style">${inlineStyles}</style>
|
<style id="style">${inlineStyles}</style>
|
||||||
@@ -349,13 +350,13 @@ export default class MarkdownPreview extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleSaveAsHtml () {
|
handleSaveAsHtml () {
|
||||||
this.exportAsDocument('html', (noteContent, exportTasks) => Promise.resolve(this.htmlContentFormatter(noteContent, exportTasks)))
|
this.exportAsDocument('html', (noteContent, exportTasks, targetDir) => Promise.resolve(this.htmlContentFormatter(noteContent, exportTasks, targetDir)))
|
||||||
}
|
}
|
||||||
|
|
||||||
handleSaveAsPdf () {
|
handleSaveAsPdf () {
|
||||||
this.exportAsDocument('pdf', (noteContent, exportTasks) => {
|
this.exportAsDocument('pdf', (noteContent, exportTasks, targetDir) => {
|
||||||
const printout = new remote.BrowserWindow({show: false})
|
const printout = new remote.BrowserWindow({show: true})
|
||||||
printout.loadURL('data:text/html;charset=UTF-8,' + this.htmlContentFormatter(noteContent, exportTasks))
|
printout.loadURL('data:text/html;charset=UTF-8,' + this.htmlContentFormatter(noteContent, exportTasks, targetDir))
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
printout.webContents.on('did-finish-load', () => {
|
printout.webContents.on('did-finish-load', () => {
|
||||||
printout.webContents.printToPDF({}, (err, data) => {
|
printout.webContents.printToPDF({}, (err, data) => {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ function exportNote (nodeKey, storageKey, noteContent, targetPath, outputFormatt
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (outputFormatter) {
|
if (outputFormatter) {
|
||||||
exportedData = outputFormatter(exportedData, exportTasks)
|
exportedData = outputFormatter(exportedData, exportTasks, path.dirname(targetPath))
|
||||||
} else {
|
} else {
|
||||||
exportedData = Promise.resolve(exportedData)
|
exportedData = Promise.resolve(exportedData)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user