mirror of
https://github.com/leanote/desktop-app.git
synced 2025-10-15 07:31:33 +00:00
Merge pull request #351 from chaosue/master
fix compatibilies with electron9 for plugins; auto hide default menubar
This commit is contained in:
1
main.js
1
main.js
@@ -204,6 +204,7 @@ function openIt() {
|
|||||||
height: 595,
|
height: 595,
|
||||||
frame: process.platform != 'darwin',
|
frame: process.platform != 'darwin',
|
||||||
transparent: false,
|
transparent: false,
|
||||||
|
autoHideMenuBar: true,
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
nodeIntegration: true
|
nodeIntegration: true
|
||||||
}
|
}
|
||||||
|
27
node_modules/pdf_main.js
generated
vendored
27
node_modules/pdf_main.js
generated
vendored
@@ -15,11 +15,7 @@ var exportPdf = {
|
|||||||
win.webContents.on('did-finish-load', function() {
|
win.webContents.on('did-finish-load', function() {
|
||||||
console.log('load ok');
|
console.log('load ok');
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
win.webContents.printToPDF({
|
var callback = function(err, data) {
|
||||||
printBackground: true,
|
|
||||||
landscape: false,
|
|
||||||
pageSize: 'A4'
|
|
||||||
}, function(err, data) {
|
|
||||||
fs.writeFile(targetPdfPath, data, function(err) {
|
fs.writeFile(targetPdfPath, data, function(err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
callbcak(false);
|
callbcak(false);
|
||||||
@@ -29,7 +25,26 @@ var exportPdf = {
|
|||||||
}
|
}
|
||||||
// win.close();
|
// win.close();
|
||||||
});
|
});
|
||||||
})
|
};
|
||||||
|
var po = win.webContents.printToPDF({
|
||||||
|
printBackground: true,
|
||||||
|
landscape: false,
|
||||||
|
pageSize: 'A4'
|
||||||
|
},
|
||||||
|
callbcak
|
||||||
|
);
|
||||||
|
|
||||||
|
if(typeof(po) != "object"){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
po.then(data => {
|
||||||
|
callback(null, data);
|
||||||
|
}
|
||||||
|
).catch( err => {
|
||||||
|
callback(err, null);
|
||||||
|
}
|
||||||
|
);
|
||||||
}, isMarkdown ? 1000 : 100);
|
}, isMarkdown ? 1000 : 100);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -405,7 +405,7 @@ define(function() {
|
|||||||
|
|
||||||
getTargetPath: function(callback) {
|
getTargetPath: function(callback) {
|
||||||
// showSaveDialog 不支持property选择文件夹
|
// showSaveDialog 不支持property选择文件夹
|
||||||
Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
|
var po = Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
|
||||||
{
|
{
|
||||||
defaultPath: Api.gui.app.getPath('userDesktop') + '/',
|
defaultPath: Api.gui.app.getPath('userDesktop') + '/',
|
||||||
properties: ['openDirectory']
|
properties: ['openDirectory']
|
||||||
@@ -414,6 +414,21 @@ define(function() {
|
|||||||
callback(targetPath);
|
callback(targetPath);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if(typeof(po) != "object"){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
po.then(function(re){
|
||||||
|
if(re.canceled !== false || re.filePaths.length < 1){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
callback(re.filePaths[0]);
|
||||||
|
},
|
||||||
|
function(err){
|
||||||
|
alert(err);
|
||||||
|
}
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
loadingIsClosed: false,
|
loadingIsClosed: false,
|
||||||
|
@@ -185,7 +185,7 @@ define(function() {
|
|||||||
|
|
||||||
getTargetPath: function(callback) {
|
getTargetPath: function(callback) {
|
||||||
// showSaveDialog 不支持property选择文件夹
|
// showSaveDialog 不支持property选择文件夹
|
||||||
Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
|
var po = Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
|
||||||
{
|
{
|
||||||
defaultPath: Api.gui.app.getPath('userDesktop') + '/',
|
defaultPath: Api.gui.app.getPath('userDesktop') + '/',
|
||||||
properties: ['openDirectory']
|
properties: ['openDirectory']
|
||||||
@@ -194,6 +194,20 @@ define(function() {
|
|||||||
callback(targetPath);
|
callback(targetPath);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
if(typeof(po) != "object"){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
po.then(function(re){
|
||||||
|
if(re.canceled !== false || re.filePaths.length < 1){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
callback(re.filePaths[0]);
|
||||||
|
},
|
||||||
|
function(err){
|
||||||
|
alert(err);
|
||||||
|
}
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
loadingIsClosed: false,
|
loadingIsClosed: false,
|
||||||
|
@@ -419,7 +419,7 @@ define(function() {
|
|||||||
|
|
||||||
getTargetPath: function(callback) {
|
getTargetPath: function(callback) {
|
||||||
// showSaveDialog 不支持property选择文件夹
|
// showSaveDialog 不支持property选择文件夹
|
||||||
Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
|
var po = Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
|
||||||
{
|
{
|
||||||
defaultPath: Api.gui.app.getPath('userDesktop') + '/',
|
defaultPath: Api.gui.app.getPath('userDesktop') + '/',
|
||||||
properties: ['openDirectory']
|
properties: ['openDirectory']
|
||||||
@@ -428,6 +428,21 @@ define(function() {
|
|||||||
callback(targetPath);
|
callback(targetPath);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if(typeof(po) != "object"){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
po.then(function(re){
|
||||||
|
if(re.canceled !== false || re.filePaths.length < 1){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
callback(re.filePaths[0]);
|
||||||
|
},
|
||||||
|
function(err){
|
||||||
|
alert(err);
|
||||||
|
}
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
loadingIsClosed: false,
|
loadingIsClosed: false,
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
* 选择目录, 将图片保存到文件夹中, 有个html文件(以笔记名命名)
|
* 选择目录, 将图片保存到文件夹中, 有个html文件(以笔记名命名)
|
||||||
* 注意, fs.existsSync总返回false, readFileSync可用
|
* 注意, fs.existsSync总返回false, readFileSync可用
|
||||||
*/
|
*/
|
||||||
define(function() {
|
define(function () {
|
||||||
var async; // = require('async');
|
var async; // = require('async');
|
||||||
|
|
||||||
var exportPDF = {
|
var exportPDF = {
|
||||||
@@ -40,7 +40,7 @@ define(function() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
_inited: false,
|
_inited: false,
|
||||||
init: function() {
|
init: function () {
|
||||||
var me = this;
|
var me = this;
|
||||||
if (me._inited) {
|
if (me._inited) {
|
||||||
return;
|
return;
|
||||||
@@ -56,7 +56,7 @@ define(function() {
|
|||||||
_initExportPdf: function () {
|
_initExportPdf: function () {
|
||||||
var me = this;
|
var me = this;
|
||||||
// console.log('_initExportPdf');
|
// console.log('_initExportPdf');
|
||||||
Api.ipc.on('export-pdf-ret', function(event, arg) {
|
Api.ipc.on('export-pdf-ret', function (event, arg) {
|
||||||
var seq = arg.seq;
|
var seq = arg.seq;
|
||||||
// console.log('export-pdf-ret');
|
// console.log('export-pdf-ret');
|
||||||
// console.log(arg);
|
// console.log(arg);
|
||||||
@@ -70,18 +70,18 @@ define(function() {
|
|||||||
this._exportPdfSeq++;
|
this._exportPdfSeq++;
|
||||||
this._exportPdfCallback[this._exportPdfSeq] = callback;
|
this._exportPdfCallback[this._exportPdfSeq] = callback;
|
||||||
Api.ipc.send('export-pdf',
|
Api.ipc.send('export-pdf',
|
||||||
{htmlPath: htmlPath, targetPdfPath: targetPdfPath, isMarkdown: isMarkdown, seq: this._exportPdfSeq});
|
{ htmlPath: htmlPath, targetPdfPath: targetPdfPath, isMarkdown: isMarkdown, seq: this._exportPdfSeq });
|
||||||
},
|
},
|
||||||
|
|
||||||
getPluginPath: function() {
|
getPluginPath: function () {
|
||||||
return Api.evtService.getProjectBasePath() + '/public/plugins/export_pdf' ;
|
return Api.evtService.getProjectBasePath() + '/public/plugins/export_pdf';
|
||||||
},
|
},
|
||||||
|
|
||||||
htmlTpl: '',
|
htmlTpl: '',
|
||||||
markdownTpl: '',
|
markdownTpl: '',
|
||||||
getTpl: function(isMarkdown) {
|
getTpl: function (isMarkdown) {
|
||||||
var tpl = isMarkdown ? this.markdownTpl : this.htmlTpl;
|
var tpl = isMarkdown ? this.markdownTpl : this.htmlTpl;
|
||||||
if(tpl) {
|
if (tpl) {
|
||||||
return tpl;
|
return tpl;
|
||||||
}
|
}
|
||||||
var basePluginPath = this.getPluginPath();
|
var basePluginPath = this.getPluginPath();
|
||||||
@@ -93,7 +93,7 @@ define(function() {
|
|||||||
return tpl;
|
return tpl;
|
||||||
},
|
},
|
||||||
// 生成html或markdown
|
// 生成html或markdown
|
||||||
render: function(note) {
|
render: function (note) {
|
||||||
var tpl = this.getTpl(note.IsMarkdown);
|
var tpl = this.getTpl(note.IsMarkdown);
|
||||||
var title = note.Title || getMsg('Untitled');
|
var title = note.Title || getMsg('Untitled');
|
||||||
tpl = tpl.replace(/\{title\}/g, title);
|
tpl = tpl.replace(/\{title\}/g, title);
|
||||||
@@ -103,24 +103,24 @@ define(function() {
|
|||||||
return tpl;
|
return tpl;
|
||||||
},
|
},
|
||||||
|
|
||||||
replaceAll: function(src, pattern, to) {
|
replaceAll: function (src, pattern, to) {
|
||||||
if(!src) {
|
if (!src) {
|
||||||
return src;
|
return src;
|
||||||
}
|
}
|
||||||
while(true) {
|
while (true) {
|
||||||
var oldSrc = src;
|
var oldSrc = src;
|
||||||
src = src.replace(pattern, to);
|
src = src.replace(pattern, to);
|
||||||
if(oldSrc === src) {
|
if (oldSrc === src) {
|
||||||
return src;
|
return src;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
fixFilename: function(filename) {
|
fixFilename: function (filename) {
|
||||||
var reg = new RegExp("/|#|\\$|!|\\^|\\*|'| |\"|%|&|\\(|\\)|\\+|\\,|/|:|;|<|>|=|\\?|@|\\||\\\\", 'g');
|
var reg = new RegExp("/|#|\\$|!|\\^|\\*|'| |\"|%|&|\\(|\\)|\\+|\\,|/|:|;|<|>|=|\\?|@|\\||\\\\", 'g');
|
||||||
filename = filename.replace(reg, "-");
|
filename = filename.replace(reg, "-");
|
||||||
// 防止出现两个连续的-
|
// 防止出现两个连续的-
|
||||||
while(filename.indexOf('--') != -1) {
|
while (filename.indexOf('--') != -1) {
|
||||||
filename = this.replaceAll(filename, '--', '-');
|
filename = this.replaceAll(filename, '--', '-');
|
||||||
}
|
}
|
||||||
if (filename.length > 1) {
|
if (filename.length > 1) {
|
||||||
@@ -131,36 +131,50 @@ define(function() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// 得到可用的文件名, 避免冲突
|
// 得到可用的文件名, 避免冲突
|
||||||
getPdfFilePath: function(pathInfo, n, cb) {
|
getPdfFilePath: function (pathInfo, n, cb) {
|
||||||
var me = this;
|
var me = this;
|
||||||
if(n > 1) {
|
if (n > 1) {
|
||||||
pathInfo.nameNotExt = pathInfo.nameNotExtRaw + '-' + n;
|
pathInfo.nameNotExt = pathInfo.nameNotExtRaw + '-' + n;
|
||||||
}
|
}
|
||||||
var absPath = pathInfo.getFullPath();
|
var absPath = pathInfo.getFullPath();
|
||||||
|
|
||||||
// Api.nodeFs.existsSync(absPath) 总是返回false, 不知道什么原因
|
// Api.nodeFs.existsSync(absPath) 总是返回false, 不知道什么原因
|
||||||
// 在控制台上是可以的
|
// 在控制台上是可以的
|
||||||
Api.nodeFs.exists(absPath, function(exists) {
|
Api.nodeFs.exists(absPath, function (exists) {
|
||||||
if(!exists) {
|
if (!exists) {
|
||||||
cb(absPath);
|
cb(absPath);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
me.getPdfFilePath(pathInfo, n+1, cb);
|
me.getPdfFilePath(pathInfo, n + 1, cb);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
getTargetPath: function(callback) {
|
getTargetPath: function (callback) {
|
||||||
// showSaveDialog 不支持property选择文件夹
|
// showSaveDialog 不支持property选择文件夹
|
||||||
Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
|
var po = Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
|
||||||
{
|
{
|
||||||
defaultPath: Api.gui.app.getPath('userDesktop') + '/',
|
defaultPath: Api.gui.app.getPath('userDesktop') + '/',
|
||||||
properties: ['openDirectory']
|
properties: ['openDirectory']
|
||||||
},
|
},
|
||||||
function(targetPath) {
|
function (targetPath) {
|
||||||
callback(targetPath);
|
callback(targetPath);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
if(typeof(po) != "object"){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
po.then(function(re){
|
||||||
|
if(re.canceled !== false || re.filePaths.length < 1){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
callback(re.filePaths[0]);
|
||||||
|
},
|
||||||
|
function(err){
|
||||||
|
alert(err);
|
||||||
|
}
|
||||||
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
loadingIsClosed: false,
|
loadingIsClosed: false,
|
||||||
@@ -170,7 +184,7 @@ define(function() {
|
|||||||
if (!notebookId) {
|
if (!notebookId) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
me.getTargetPath(function(targetPath) {
|
me.getTargetPath(function (targetPath) {
|
||||||
if (!targetPath) {
|
if (!targetPath) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -182,13 +196,14 @@ define(function() {
|
|||||||
isLarge: true,
|
isLarge: true,
|
||||||
onClose: function () {
|
onClose: function () {
|
||||||
me.loadingIsClosed = true;
|
me.loadingIsClosed = true;
|
||||||
setTimeout(function() {
|
setTimeout(function () {
|
||||||
me.hideLoading();
|
me.hideLoading();
|
||||||
});
|
});
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
Api.loading.setProgress(1);
|
Api.loading.setProgress(1);
|
||||||
|
|
||||||
Api.noteService.getNotes(notebookId, function(notes) {
|
Api.noteService.getNotes(notebookId, function (notes) {
|
||||||
if (!notes) {
|
if (!notes) {
|
||||||
me.hideLoading();
|
me.hideLoading();
|
||||||
return;
|
return;
|
||||||
@@ -196,7 +211,7 @@ define(function() {
|
|||||||
|
|
||||||
var total = notes.length;
|
var total = notes.length;
|
||||||
var i = 0;
|
var i = 0;
|
||||||
async.eachSeries(notes, function(note, cb) {
|
async.eachSeries(notes, function (note, cb) {
|
||||||
if (me.loadingIsClosed) {
|
if (me.loadingIsClosed) {
|
||||||
cb();
|
cb();
|
||||||
me.hideLoading();
|
me.hideLoading();
|
||||||
@@ -204,12 +219,12 @@ define(function() {
|
|||||||
}
|
}
|
||||||
i++;
|
i++;
|
||||||
Api.loading.setProgress(100 * i / total);
|
Api.loading.setProgress(100 * i / total);
|
||||||
me._exportPDF(note, targetPath, function() {
|
me._exportPDF(note, targetPath, function () {
|
||||||
cb();
|
cb();
|
||||||
}, i, total);
|
}, i, total);
|
||||||
}, function() {
|
}, function () {
|
||||||
me.hideLoading();
|
me.hideLoading();
|
||||||
Notify.show({title: 'Info', body: getMsg('plugin.export_pdf.exportSuccess')});
|
Notify.show({ title: 'Info', body: getMsg('plugin.export_pdf.exportSuccess') });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -226,7 +241,7 @@ define(function() {
|
|||||||
if (!noteIds || noteIds.length == 0) {
|
if (!noteIds || noteIds.length == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
me.getTargetPath(function(targetPath) {
|
me.getTargetPath(function (targetPath) {
|
||||||
if (!targetPath) {
|
if (!targetPath) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -238,16 +253,17 @@ define(function() {
|
|||||||
isLarge: true,
|
isLarge: true,
|
||||||
onClose: function () {
|
onClose: function () {
|
||||||
me.loadingIsClosed = true;
|
me.loadingIsClosed = true;
|
||||||
setTimeout(function() {
|
setTimeout(function () {
|
||||||
me.hideLoading();
|
me.hideLoading();
|
||||||
});
|
});
|
||||||
}});
|
}
|
||||||
|
});
|
||||||
Api.loading.setProgress(1);
|
Api.loading.setProgress(1);
|
||||||
|
|
||||||
var i = 0;
|
var i = 0;
|
||||||
var total = noteIds.length;
|
var total = noteIds.length;
|
||||||
|
|
||||||
async.eachSeries(noteIds, function(noteId, cb) {
|
async.eachSeries(noteIds, function (noteId, cb) {
|
||||||
if (me.loadingIsClosed) {
|
if (me.loadingIsClosed) {
|
||||||
cb();
|
cb();
|
||||||
return;
|
return;
|
||||||
@@ -255,30 +271,30 @@ define(function() {
|
|||||||
|
|
||||||
i++;
|
i++;
|
||||||
Api.loading.setProgress(100 * i / total);
|
Api.loading.setProgress(100 * i / total);
|
||||||
Api.noteService.getNote(noteId, function(note) {
|
Api.noteService.getNote(noteId, function (note) {
|
||||||
|
|
||||||
me._exportPDF(note, targetPath, function(ok) {
|
me._exportPDF(note, targetPath, function (ok) {
|
||||||
cb();
|
cb();
|
||||||
}, i, total);
|
}, i, total);
|
||||||
});
|
});
|
||||||
|
|
||||||
}, function () {
|
}, function () {
|
||||||
me.hideLoading();
|
me.hideLoading();
|
||||||
Notify.show({title: 'Info', body: getMsg('plugin.export_pdf.exportSuccess')});
|
Notify.show({ title: 'Info', body: getMsg('plugin.export_pdf.exportSuccess') });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
_exportPDF: function(note, path, callback, i, total) {
|
_exportPDF: function (note, path, callback, i, total) {
|
||||||
var me = this;
|
var me = this;
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
me._exportPDF(note, path, callback, i, total);
|
me._exportPDF(note, path, callback, i, total);
|
||||||
}, 1000);
|
}, 1000);
|
||||||
},
|
},
|
||||||
|
|
||||||
_exportPDF: function(note, path, callback, i, total) {
|
_exportPDF: function (note, path, callback, i, total) {
|
||||||
var me = this;
|
var me = this;
|
||||||
if(!note) {
|
if (!note) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,12 +320,12 @@ define(function() {
|
|||||||
pathInfo.nameNotExtRaw = pathInfo.nameNotExt;
|
pathInfo.nameNotExtRaw = pathInfo.nameNotExt;
|
||||||
|
|
||||||
// 得到可用文件的绝对路径
|
// 得到可用文件的绝对路径
|
||||||
me.getPdfFilePath(pathInfo, 1, function(absPdfFilePath) {
|
me.getPdfFilePath(pathInfo, 1, function (absPdfFilePath) {
|
||||||
// 得到存放assets的目录
|
// 得到存放assets的目录
|
||||||
var html = me.render(note);
|
var html = me.render(note);
|
||||||
var tempPath = Api.gui.app.getPath('temp');
|
var tempPath = Api.gui.app.getPath('temp');
|
||||||
var last = tempPath[tempPath.length-1];
|
var last = tempPath[tempPath.length - 1];
|
||||||
if ( last == '/' || last == '\\') {
|
if (last == '/' || last == '\\') {
|
||||||
tempPath = tempPath.substr(0, tempPath.length - 1);
|
tempPath = tempPath.substr(0, tempPath.length - 1);
|
||||||
}
|
}
|
||||||
var targetHtmlPath = tempPath + '/' + (new Date().getTime()) + '.html';
|
var targetHtmlPath = tempPath + '/' + (new Date().getTime()) + '.html';
|
||||||
@@ -324,17 +340,17 @@ define(function() {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// 打开前要执行的
|
// 打开前要执行的
|
||||||
onOpen: function() {
|
onOpen: function () {
|
||||||
var me = this;
|
var me = this;
|
||||||
var gui = Api.gui;
|
var gui = Api.gui;
|
||||||
|
|
||||||
var menu = {
|
var menu = {
|
||||||
label: Api.getMsg('plugin.export_pdf.export'),
|
label: Api.getMsg('plugin.export_pdf.export'),
|
||||||
enabled: function(noteIds) {
|
enabled: function (noteIds) {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
click: (function() {
|
click: (function () {
|
||||||
return function(noteIds) {
|
return function (noteIds) {
|
||||||
me.init();
|
me.init();
|
||||||
me.exportPDF(noteIds);
|
me.exportPDF(noteIds);
|
||||||
}
|
}
|
||||||
@@ -344,11 +360,11 @@ define(function() {
|
|||||||
|
|
||||||
Api.addExportMenuForNotebook({
|
Api.addExportMenuForNotebook({
|
||||||
label: Api.getMsg('plugin.export_pdf.export'),
|
label: Api.getMsg('plugin.export_pdf.export'),
|
||||||
enabled: function(notebookId) {
|
enabled: function (notebookId) {
|
||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
click: (function() {
|
click: (function () {
|
||||||
return function(notebookId) {
|
return function (notebookId) {
|
||||||
me.init();
|
me.init();
|
||||||
me.exportPDFForNotebook(notebookId);
|
me.exportPDFForNotebook(notebookId);
|
||||||
}
|
}
|
||||||
@@ -356,10 +372,10 @@ define(function() {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
// 打开后
|
// 打开后
|
||||||
onOpenAfter: function() {
|
onOpenAfter: function () {
|
||||||
},
|
},
|
||||||
// 关闭时需要运行的
|
// 关闭时需要运行的
|
||||||
onClose: function() {
|
onClose: function () {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -118,15 +118,7 @@ define(function() {
|
|||||||
|
|
||||||
// 导入, 选择文件
|
// 导入, 选择文件
|
||||||
$('#chooseEvernoteFile').click(function() {
|
$('#chooseEvernoteFile').click(function() {
|
||||||
|
var callback = function(paths) {
|
||||||
Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
|
|
||||||
{
|
|
||||||
properties: ['openFile', 'multiSelections'],
|
|
||||||
filters: [
|
|
||||||
{ name: 'Evernote', extensions: ['enex'] }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
function(paths) {
|
|
||||||
if(!paths) {
|
if(!paths) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -170,9 +162,33 @@ define(function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
var po = Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
|
||||||
|
{
|
||||||
|
properties: ['openFile', 'multiSelections'],
|
||||||
|
filters: [
|
||||||
|
{ name: 'Evernote', extensions: ['enex'] }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
callback
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if(typeof(po) != "object"){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
po.then(
|
||||||
|
function(re){
|
||||||
|
if(re.canceled !== false || re.filePaths.length < 1){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
callback(re.filePaths);
|
||||||
|
},
|
||||||
|
function(err){
|
||||||
|
alert(err);
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@@ -118,15 +118,7 @@ define(function() {
|
|||||||
|
|
||||||
// 导入, 选择文件
|
// 导入, 选择文件
|
||||||
$('#chooseHTMLFile').click(function() {
|
$('#chooseHTMLFile').click(function() {
|
||||||
|
var callback = function(paths) {
|
||||||
Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
|
|
||||||
{
|
|
||||||
properties: ['openFile', 'multiSelections'],
|
|
||||||
filters: [
|
|
||||||
{ name: 'HTML', extensions: ['html'] }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
function(paths) {
|
|
||||||
if(!paths) {
|
if(!paths) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -170,9 +162,32 @@ define(function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
var po = Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
|
||||||
|
{
|
||||||
|
properties: ['openFile', 'multiSelections'],
|
||||||
|
filters: [
|
||||||
|
{ name: 'HTML', extensions: ['html'] }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
, callback
|
||||||
|
);
|
||||||
|
if(typeof(po) != "object"){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
po.then(
|
||||||
|
function(re){
|
||||||
|
if(re.canceled !== false || re.filePaths.length < 1){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
callback(re.filePaths);
|
||||||
|
},
|
||||||
|
function(err){
|
||||||
|
alert(err);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@@ -118,15 +118,8 @@ define(function() {
|
|||||||
|
|
||||||
// 导入, 选择文件
|
// 导入, 选择文件
|
||||||
$('#chooseLeanoteFile').click(function() {
|
$('#chooseLeanoteFile').click(function() {
|
||||||
|
var callback = function(paths) {
|
||||||
|
|
||||||
Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
|
|
||||||
{
|
|
||||||
properties: ['openFile', 'multiSelections'],
|
|
||||||
filters: [
|
|
||||||
{ name: 'Leanote', extensions: ['leanote'] }
|
|
||||||
]
|
|
||||||
},
|
|
||||||
function(paths) {
|
|
||||||
if(!paths) {
|
if(!paths) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -173,8 +166,30 @@ define(function() {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
var po = Api.gui.dialog.showOpenDialog(Api.gui.getCurrentWindow(),
|
||||||
|
{
|
||||||
|
properties: ['openFile', 'multiSelections'],
|
||||||
|
filters: [
|
||||||
|
{ name: 'Leanote', extensions: ['leanote'] }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
callback
|
||||||
);
|
);
|
||||||
|
if(typeof(po) != "object"){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
po.then(
|
||||||
|
function(re){
|
||||||
|
if(re.canceled !== false || re.filePaths.length < 1){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
callback(re.filePaths);
|
||||||
|
},
|
||||||
|
function(err){
|
||||||
|
alert(err);
|
||||||
|
}
|
||||||
|
);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user