فهرست منبع

Add Focus mode
Fix Image Drag bug
other change

zhuzhuyule 8 سال پیش
والد
کامیت
9b1771e03e

+ 2 - 1
app/index.js

@@ -27,10 +27,11 @@ var moeApp = null, openFile = null;
 
 app.on("ready", () => {
     moeApp = new MoeditorApplication();
-    if (openFile !== null) moeApp.osxOpenFile = openFile;
     global.moeApp = moeApp;
     global.app = app;
     app.moeApp = moeApp;
+    if (openFile !== null)
+        moeApp.osxOpenFile = openFile;
 	moeApp.run();
 });
 

+ 69 - 69
app/moe-action.js

@@ -31,11 +31,11 @@ let lastDir = '';
 class MoeditorAction {
     static openNew() {
         let windows = require('electron').BrowserWindow.getAllWindows();
-        let w, i;
+        let hexoWindow, i;
         for (i = windows.length - 1; i > -1; i--) {
-            w = windows[i];
-            if (w.moeditorWindow && w.moeditorWindow.content.length < 1 &&!w.moeditorWindow.changed) {
-                w.focus();
+            hexoWindow = windows[i];
+            if (hexoWindow.hexoeditorWindow && hexoWindow.hexoeditorWindow.content.length < 1 &&!hexoWindow.hexoeditorWindow.changed) {
+                hexoWindow.focus();
                 break;
             }
         }
@@ -79,19 +79,19 @@ class MoeditorAction {
                 lastDir = fileDir;
                 MoeditorFile.write(fileName, content);
                 if (fs.existsSync(fileName)) {
-                    let w = require('electron').BrowserWindow.getFocusedWindow();
-                    if (typeof w.moeditorWindow == 'undefined' || w.moeditorWindow.changed || w.moeditorWindow.content) {
+                    let hexoWindow = require('electron').BrowserWindow.getFocusedWindow();
+                    if (typeof hexoWindow.hexoeditorWindow == 'undefined' || hexoWindow.hexoeditorWindow.changed || hexoWindow.hexoeditorWindow.content) {
                         app.addRecentDocument(fileName);
                         moeApp.open(fileName,fileName);
                     } else {
-                        w.moeditorWindow.defName = fileName;
-                        w.moeditorWindow.fileName = fileName;
-                        w.moeditorWindow.directory = lastDir;
-                        w.moeditorWindow.fileContent = w.moeditorWindow.content = MoeditorFile.read(fileName).toString();
-                        w.moeditorWindow.changed = false;
-                        w.moeditorWindow.window.setDocumentEdited(false);
-                        w.moeditorWindow.window.setRepresentedFilename(w.moeditorWindow.fileName);
-                        w.moeditorWindow.window.webContents.send('refresh-editor', {});
+                        hexoWindow.hexoeditorWindow.defName = fileName;
+                        hexoWindow.hexoeditorWindow.fileName = fileName;
+                        hexoWindow.hexoeditorWindow.directory = lastDir;
+                        hexoWindow.hexoeditorWindow.fileContent = hexoWindow.hexoeditorWindow.content = MoeditorFile.read(fileName).toString();
+                        hexoWindow.hexoeditorWindow.changed = false;
+                        hexoWindow.hexoeditorWindow.window.setDocumentEdited(false);
+                        hexoWindow.hexoeditorWindow.window.setRepresentedFilename(hexoWindow.hexoeditorWindow.fileName);
+                        hexoWindow.hexoeditorWindow.window.webContents.send('refresh-editor', {});
                         app.addRecentDocument(fileName);
                     }
                     notOpened = false;
@@ -121,24 +121,24 @@ class MoeditorAction {
         let filename = files[0];
         if (filename) {
             let windows = require('electron').BrowserWindow.getAllWindows();
-            let w, i;
+            let hexoWindow, i;
             for (i = windows.length - 1; i > -1; i--) {
-                w = windows[i];
-                if (w.moeditorWindow) {
-                    if (w.moeditorWindow.fileName == filename) {
-                        w.focus();
+                hexoWindow = windows[i];
+                if (hexoWindow.hexoeditorWindow) {
+                    if (hexoWindow.hexoeditorWindow.fileName == filename) {
+                        hexoWindow.focus();
                         break;
-                    } else if (w.moeditorWindow.fileName == '' && !w.moeditorWindow.changed) {
+                    } else if (hexoWindow.hexoeditorWindow.fileName == '' && !hexoWindow.hexoeditorWindow.changed) {
                         try {
-                            w.moeditorWindow.fileName = filename;
-                            w.moeditorWindow.directory = lastDir;
-                            w.moeditorWindow.fileContent = w.moeditorWindow.content = MoeditorFile.read(filename).toString();
-                            w.moeditorWindow.changed = false;
-                            w.moeditorWindow.window.setDocumentEdited(false);
-                            w.moeditorWindow.window.setRepresentedFilename(w.moeditorWindow.fileName);
-                            w.moeditorWindow.window.webContents.send('refresh-editor', {});
+                            hexoWindow.hexoeditorWindow.fileName = filename;
+                            hexoWindow.hexoeditorWindow.directory = lastDir;
+                            hexoWindow.hexoeditorWindow.fileContent = hexoWindow.hexoeditorWindow.content = MoeditorFile.read(filename).toString();
+                            hexoWindow.hexoeditorWindow.changed = false;
+                            hexoWindow.hexoeditorWindow.window.setDocumentEdited(false);
+                            hexoWindow.hexoeditorWindow.window.setRepresentedFilename(hexoWindow.hexoeditorWindow.fileName);
+                            hexoWindow.hexoeditorWindow.window.webContents.send('refresh-editor', {});
                             app.addRecentDocument(filename);
-                            w.focus();
+                            hexoWindow.focus();
                             break;
                         } catch (e) {
                             console.log(e);
@@ -153,28 +153,28 @@ class MoeditorAction {
         }
     }
 
-    static save(w) {
-        if (typeof w == 'undefined') w = require('electron').BrowserWindow.getFocusedWindow();
-        if (typeof w.moeditorWindow == 'undefined') return false;
+    static save(hexoWindow) {
+        if (typeof hexoWindow == 'undefined') hexoWindow = require('electron').BrowserWindow.getFocusedWindow();
+        if (typeof hexoWindow.hexoeditorWindow == 'undefined') return false;
 
-        if (typeof w.moeditorWindow.fileName == 'undefined' || w.moeditorWindow.fileName == '') {
-            return MoeditorAction.saveAs(w);
+        if (typeof hexoWindow.hexoeditorWindow.fileName == 'undefined' || hexoWindow.hexoeditorWindow.fileName == '') {
+            return MoeditorAction.saveAs(hexoWindow);
         } else {
             try {
-                MoeditorFile.write(w.moeditorWindow.fileName, w.moeditorWindow.content);
-                w.moeditorWindow.isSaved = true;
-                w.moeditorWindow.fileContent = w.moeditorWindow.content;
-                w.moeditorWindow.changed = false;
-                w.moeditorWindow.window.setDocumentEdited(false);
-                w.moeditorWindow.window.setRepresentedFilename(w.moeditorWindow.fileName);
-                w.moeditorWindow.window.webContents.send('pop-message', {
+                MoeditorFile.write(hexoWindow.hexoeditorWindow.fileName, hexoWindow.hexoeditorWindow.content);
+                hexoWindow.hexoeditorWindow.isSaved = true;
+                hexoWindow.hexoeditorWindow.fileContent = hexoWindow.hexoeditorWindow.content;
+                hexoWindow.hexoeditorWindow.changed = false;
+                hexoWindow.hexoeditorWindow.window.setDocumentEdited(false);
+                hexoWindow.hexoeditorWindow.window.setRepresentedFilename(hexoWindow.hexoeditorWindow.fileName);
+                hexoWindow.hexoeditorWindow.window.webContents.send('pop-message', {
                     type: 'success',
                     content: __('Saved successfully.')
                 });
-                moeApp.addRecentDocument(w.moeditorWindow.fileName);
+                moeApp.addRecentDocument(hexoWindow.hexoeditorWindow.fileName);
                 return true;
             } catch (e) {
-                w.moeditorWindow.window.webContents.send('pop-message', {
+                hexoWindow.hexoeditorWindow.window.webContents.send('pop-message', {
                     type: 'error',
                     content: __('Can\'t save file') + ', ' + e.toString()
                 });
@@ -185,11 +185,11 @@ class MoeditorAction {
         return false;
     }
 
-    static saveAs(w) {
-        if (typeof w == 'undefined') w = require('electron').BrowserWindow.getFocusedWindow();
-        if (typeof w.moeditorWindow == 'undefined') return false;
+    static saveAs(hexoWindow) {
+        if (typeof hexoWindow == 'undefined') hexoWindow = require('electron').BrowserWindow.getFocusedWindow();
+        if (typeof hexoWindow.hexoeditorWindow == 'undefined') return false;
 
-        const fileName = dialog.showSaveDialog(w,
+        const fileName = dialog.showSaveDialog(hexoWindow,
             {
                 defaultPath: lastDir,
                 filters: [
@@ -202,23 +202,23 @@ class MoeditorAction {
         lastDir = path.dirname(fileName);
 
         try {
-            MoeditorFile.write(fileName, w.moeditorWindow.content);
-            w.moeditorWindow.isSaved = true;
-            w.moeditorWindow.directory = lastDir;
-            w.moeditorWindow.fileContent = w.moeditorWindow.content;
-            w.moeditorWindow.fileName = fileName;
-            w.moeditorWindow.changed = false;
+            MoeditorFile.write(fileName, hexoWindow.hexoeditorWindow.content);
+            hexoWindow.hexoeditorWindow.isSaved = true;
+            hexoWindow.hexoeditorWindow.directory = lastDir;
+            hexoWindow.hexoeditorWindow.fileContent = hexoWindow.hexoeditorWindow.content;
+            hexoWindow.hexoeditorWindow.fileName = fileName;
+            hexoWindow.hexoeditorWindow.changed = false;
             moeApp.addRecentDocument(fileName);
-            w.moeditorWindow.window.setDocumentEdited(false);
-            w.moeditorWindow.window.setRepresentedFilename(fileName);
-            w.moeditorWindow.window.webContents.send('pop-message', {
+            hexoWindow.hexoeditorWindow.window.setDocumentEdited(false);
+            hexoWindow.hexoeditorWindow.window.setRepresentedFilename(fileName);
+            hexoWindow.hexoeditorWindow.window.webContents.send('pop-message', {
                 type: 'success',
                 content: __('Saved successfully.')
             });
-            w.moeditorWindow.window.webContents.send('set-title', fileName);
+            hexoWindow.hexoeditorWindow.window.webContents.send('set-title', fileName);
             return true;
         } catch (e) {
-            w.moeditorWindow.window.webContents.send('pop-message', {
+            hexoWindow.hexoeditorWindow.window.webContents.send('pop-message', {
                 type: 'error',
                 content: __('Can\'t save file') + ', ' + e.toString()
             });
@@ -227,11 +227,11 @@ class MoeditorAction {
         }
     }
 
-    static exportAsHTML(w, f) {
-        if (typeof w == 'undefined') w = require('electron').BrowserWindow.getFocusedWindow();
-        if (typeof w.moeditorWindow == 'undefined') return;
+    static exportAsHTML(hexoWindow, f) {
+        if (typeof hexoWindow == 'undefined') hexoWindow = require('electron').BrowserWindow.getFocusedWindow();
+        if (typeof hexoWindow.hexoeditorWindow == 'undefined') return;
 
-        const fileName = dialog.showSaveDialog(w,
+        const fileName = dialog.showSaveDialog(hexoWindow,
             {
                 defaultPath: lastDir,
                 filters: [
@@ -244,7 +244,7 @@ class MoeditorAction {
 
         f((s) => {
             try {
-                w.moeditorWindow.window.webContents.send('pop-message', {
+                hexoWindow.hexoeditorWindow.window.webContents.send('pop-message', {
                     type: 'info',
                     content: __('Exporting as HTML, please wait ...')
                 });
@@ -252,7 +252,7 @@ class MoeditorAction {
                 const {shell} = require('electron');
                 shell.openItem(fileName);
             } catch (e) {
-                w.moeditorWindow.window.webContents.send('pop-message', {
+                hexoWindow.hexoeditorWindow.window.webContents.send('pop-message', {
                     type: 'error',
                     content: __('Can\'t export as HTML') + ', ' + e.toString()
                 });
@@ -261,11 +261,11 @@ class MoeditorAction {
         });
     }
 
-    static exportAsPDF(w, f) {
-        if (typeof w == 'undefined') w = require('electron').BrowserWindow.getFocusedWindow();
-        if (typeof w.moeditorWindow == 'undefined') return;
+    static exportAsPDF(hexoWindow, f) {
+        if (typeof hexoWindow == 'undefined') hexoWindow = require('electron').BrowserWindow.getFocusedWindow();
+        if (typeof hexoWindow.hexoeditorWindow == 'undefined') return;
 
-        const fileName = dialog.showSaveDialog(w,
+        const fileName = dialog.showSaveDialog(hexoWindow,
             {
                 defaultPath: lastDir,
                 filters: [
@@ -278,14 +278,14 @@ class MoeditorAction {
 
         f((s) => {
             let errorHandler = (e) => {
-                w.moeditorWindow.window.webContents.send('pop-message', {
+                hexoWindow.hexoeditorWindow.window.webContents.send('pop-message', {
                     type: 'error',
                     content: __('Can\'t export as PDF') + ', ' + e.toString()
                 });
                 console.log('Can\'t export as PDF: ' + e.toString());
             }
             try {
-                w.moeditorWindow.window.webContents.send('pop-message', {
+                hexoWindow.hexoeditorWindow.window.webContents.send('pop-message', {
                     type: 'info',
                     content: __('Exporting as PDF, please wait ...')
                 });

+ 39 - 34
app/moe-app.js

@@ -35,7 +35,7 @@ const MoeditorWindow = require('./moe-window'),
 class MoeditorApplication {
 	constructor() {
 		this.windows = new Array();
-        this.newWindow = null;
+        this.hexoWindow = null;
 	}
 
 	open(fileName,defName) {
@@ -105,40 +105,40 @@ class MoeditorApplication {
     registerAppMenu() {
         require('./moe-menu')(
             {
-                fileNew: (w) => {
+                fileNew: (hexoWindow) => {
                     MoeditorAction.openNew();
                 },
-                fileNewHexo: (w) => {
+                fileNewHexo: (hexoWindow) => {
                     MoeditorAction.openNewHexo();
                 },
-                fileOpen: (w) => {
+                fileOpen: (hexoWindow) => {
                     MoeditorAction.open();
                 },
-                fileSave: (w) => {
-                    MoeditorAction.save(w);
+                fileSave: (hexoWindow) => {
+                    MoeditorAction.save(hexoWindow);
                 },
-                fileSaveAs: (w) => {
-                    MoeditorAction.saveAs(w);
+                fileSaveAs: (hexoWindow) => {
+                    MoeditorAction.saveAs(hexoWindow);
                 },
-                fileExportHTML: (w) => {
-                    w.webContents.send('action-export-html');
+                fileExportHTML: (hexoWindow) => {
+                    hexoWindow.webContents.send('action-export-html');
                 },
-                fileExportPDF: (w) => {
-                    w.webContents.send('action-export-pdf');
+                fileExportPDF: (hexoWindow) => {
+                    hexoWindow.webContents.send('action-export-pdf');
                 },
-                modeToRead: (w) => {
-                    w.webContents.send('change-edit-mode', 'read');
+                modeToRead: (hexoWindow) => {
+                    hexoWindow.webContents.send('change-edit-mode', 'read');
                 },
-                modeToWrite: (w) => {
-                    w.webContents.send('change-edit-mode', 'write');
+                modeToWrite: (hexoWindow) => {
+                    hexoWindow.webContents.send('change-edit-mode', 'write');
                 },
-                modeToPreview: (w) => {
-                    w.webContents.send('change-edit-mode', 'preview');
+                modeToPreview: (hexoWindow) => {
+                    hexoWindow.webContents.send('change-edit-mode', 'preview');
                 },
-                about: (w) => {
+                about: (hexoWindow) => {
                     MoeditorAbout();
                 },
-                settings: (w) => {
+                settings: (hexoWindow) => {
                     MoeditorSettings();
                 }
             }
@@ -167,40 +167,45 @@ class MoeditorApplication {
         });
 
         // shortcut.register('CmdOrCtrl + R', () => {
-        //     let w = require('electron').BrowserWindow.getFocusedWindow();
-        //     if (w) w.webContents.send('change-edit-mode', 'read');
+        //     let hexoWindow = require('electron').BrowserWindow.getFocusedWindow();
+        //     if (hexoWindow) hexoWindow.webContents.send('change-edit-mode', 'read');
         // });
 
         shortcut.register('CmdOrCtrl + W', () => {
-            let w = require('electron').BrowserWindow.getFocusedWindow();
-            if (w) w.webContents.send('change-edit-mode', 'change');
+            let hexoWindow = require('electron').BrowserWindow.getFocusedWindow();
+            if (hexoWindow) hexoWindow.webContents.send('change-edit-mode', 'change');
         });
 
         shortcut.register('CmdOrCtrl + P', () => {
-            let w = require('electron').BrowserWindow.getFocusedWindow();
-            if (w) w.webContents.send('change-edit-mode', 'preview');
+            let hexoWindow = require('electron').BrowserWindow.getFocusedWindow();
+            if (hexoWindow) hexoWindow.webContents.send('change-edit-mode', 'preview');
         });
 
         shortcut.register('CmdOrCtrl + Shift + P', () => {
-            let w = require('electron').BrowserWindow.getFocusedWindow();
-            if (w) w.webContents.send('change-edit-mode', 'changepreview');
+            let hexoWindow = require('electron').BrowserWindow.getFocusedWindow();
+            if (hexoWindow) hexoWindow.webContents.send('change-edit-mode', 'changepreview');
         });
 
         shortcut.register('CmdOrCtrl + Alt + Shift + R', () => {
-            let w = require('electron').BrowserWindow.getFocusedWindow();
-            w.reload();
+            let hexoWindow = require('electron').BrowserWindow.getFocusedWindow();
+            hexoWindow.reload();
+        });
+
+        shortcut.register('CmdOrCtrl + Alt + S', () => {
+            let hexoWindow = require('electron').BrowserWindow.getFocusedWindow();
+            MoeditorSettings();
         });
 
         shortcut.register('CmdOrCtrl + Alt + Shift + F12', () => {
-            let w = require('electron').BrowserWindow.getFocusedWindow();
-            w.webContents.openDevTools();
+            let hexoWindow = require('electron').BrowserWindow.getFocusedWindow();
+            hexoWindow.webContents.openDevTools();
         });
 
 
         /*
         shortcut.register('CmdOrCtrl + Shift + P', () => {
-            let w = require('electron').BrowserWindow.getFocusedWindow();
-            if (w) w.webContents.send('change-edit-mode', 'preview');
+            let hexoWindow = require('electron').BrowserWindow.getFocusedWindow();
+            if (hexoWindow) hexoWindow.webContents.send('change-edit-mode', 'preview');
         });
         */
     }

+ 1 - 1
app/moe-config-default.js

@@ -34,7 +34,7 @@ module.exports = {
     'editor-line-height': 2,
     'math': true,
     'uml-diagrams': true,
-    'auto-reload': 'auto',
+    'auto-reload': 'prompt',
     'auto-save': 'prompt',
     'highlight-theme': 'github',
     'render-theme': '*GitHub',

+ 14 - 14
app/moe-menu.js

@@ -25,22 +25,22 @@ module.exports = (cb) => {
                 {
                     localize() { this.label = __('New'); },
                     accelerator: 'CmdOrCtrl+N',
-                    click(item, w) {
-                        cb.fileNew(w);
+                    click(item, hexoWindow) {
+                        cb.fileNew(hexoWindow);
                     }
                 },
                 {
                     localize() { this.label = __('New Post'); },
                     accelerator: 'CmdOrCtrl+H',
-                    click(item, w) {
-                        cb.fileNewHexo(w);
+                    click(item, hexoWindow) {
+                        cb.fileNewHexo(hexoWindow);
                     }
                 },
                 {
                     localize() { this.label = __('Open') + '...'; },
                     accelerator: 'CmdOrCtrl+O',
-                    click(item, w) {
-                        cb.fileOpen(w);
+                    click(item, hexoWindow) {
+                        cb.fileOpen(hexoWindow);
                     }
                 },
                 {
@@ -49,14 +49,14 @@ module.exports = (cb) => {
                 {
                     localize() { this.label = __('Save'); },
                     accelerator: 'CmdOrCtrl+S',
-                    click(item, w) {
-                        cb.fileSave(w);
+                    click(item, hexoWindow) {
+                        cb.fileSave(hexoWindow);
                     }
                 },{
                     localize() { this.label = __('Save as'); },
                     accelerator: 'CmdOrCtrl+Shift+S',
-                    click(item, w) {
-                        cb.fileSaveAs(w);
+                    click(item, hexoWindow) {
+                        cb.fileSaveAs(hexoWindow);
                     }
                 },{
                     type: 'separator'
@@ -66,14 +66,14 @@ module.exports = (cb) => {
                         {
                             localize() { this.label = 'HTML...'; },
                             accelerator: 'CmdOrCtrl+Shift+E',
-                            click(item, w) {
-                                cb.fileExportHTML(w);
+                            click(item, hexoWindow) {
+                                cb.fileExportHTML(hexoWindow);
                             }
                         }, {
                             localize() { this.label = 'PDF...'; },
                             accelerator: 'CmdOrCtrl+Shift+P',
-                            click(item, w) {
-                                cb.fileExportPDF(w);
+                            click(item, hexoWindow) {
+                                cb.fileExportPDF(hexoWindow);
                             }
                         }
                     ]

+ 1 - 1
app/moe-shell.js

@@ -70,7 +70,7 @@ class ShellServer {
     sendConsole(content, type, btnTip) {
         if (moeApp.shellServer.closeMsg) return;
         try {
-            moeApp.shellServer.lastWindow.moeditorWindow.window.webContents.send('pop-message-shell', {
+            moeApp.shellServer.lastWindow.hexoeditorWindow.window.webContents.send('pop-message-shell', {
                 subProcess: this.shellProcess,
                 content: content,
                 type: type,

+ 2 - 2
app/moe-window.js

@@ -27,7 +27,7 @@ const BrowserWindow = require('electron').BrowserWindow,
 
 class MoeditorWindow {
 	constructor(path,defName) {
-        moeApp.newWindow = this;
+        moeApp.hexoWindow = this;
 
         if (MoeditorFile.isDirectory(path)) {
             this.directory = path
@@ -59,7 +59,7 @@ class MoeditorWindow {
         else conf.frame = false;
 
 		this.window = new BrowserWindow(conf);
-        this.window.moeditorWindow = this;
+        this.window.hexoeditorWindow = this;
 
         this.registerEvents();
         this.window.loadURL('file://' + Const.path + '/views/main/index.html');

+ 1 - 1
views/about/about.html

@@ -21,7 +21,7 @@
     <head>
         <meta charset="UTF-8">
         <base href="../href.html">
-        <title>About Moeditor</title>
+        <title>About HexoEditor</title>
 
 		<script>
 		window.$ = window.jQuery = require("jquery");

+ 3 - 3
views/main/hexo/previewer.js

@@ -86,7 +86,7 @@ Previewer.prototype.render = function (content, MoeMark, options, callback) {
             if (src && (url.parse(src).protocol === null)) {
                 if (!fs.existsSync(src)) {
                     srcLocal = (imgRelativePathToID[src] ? imgRelativeToAbsolute[src] : '');
-                    if (!srcLocal && !moeApp.defTheme && hexo.config.__basedir) {
+                    if (!srcLocal && !moeApp.useHexo && hexo.config.__basedir) {
                         srcLocal = path.join(hexo.config.__basedir, 'source', src);
                         if (!fs.existsSync(srcLocal))
                             srcLocal = '';
@@ -97,7 +97,7 @@ Previewer.prototype.render = function (content, MoeMark, options, callback) {
                             srcLocal = '';
                     }
                     if (!srcLocal)
-                        srcLocal = path.join(w.directory, src);
+                        srcLocal = path.join(hexoWindow.directory, src);
                     img.id = src;
                     img.setAttribute('localImg', true);
                     src = url.resolve('file://', srcLocal);
@@ -108,7 +108,7 @@ Previewer.prototype.render = function (content, MoeMark, options, callback) {
         data.content = contentHtml.html();
     }
 
-    if (moeApp.defTheme) {
+    if (moeApp.useHexo) {
         Promise.resolve()
             .then(escapeTag).catch(console.log)
             .then(markdownContent, markdownContent).catch(console.log)

+ 20 - 21
views/main/index.html

@@ -131,9 +131,9 @@
                         }
                     </script>
 
-                    <!--<div class="button-bottom l10n-title" id="button-bottom-focus" title="Toggle focus mode">-->
-                    <!--<i class="fa fa-dot-circle-o" aria-hidden="true"></i>-->
-                    <!--</div>-->
+                    <div class="button-bottom l10n-title" id="button-bottom-focus" title="Toggle focus mode">
+                        <i class="fa fa-dot-circle-o" aria-hidden="true"></i>
+                    </div>
 
                     <div class="button-bottom l10n-title"  title="Write Mode" exdata="(Ctrl+W)" onclick="clickItem(0)">
                         <i class="fa fa-pencil" aria-hidden="true"></i>
@@ -171,6 +171,7 @@
         <link rel="stylesheet" href="../node_modules/biu.js/dist/biu.css">
 
         <script src="../node_modules/codemirror/lib/codemirror.js"></script>
+        <!--Mode-->
         <script src="../node_modules/codemirror/addon/mode/simple.js"></script>
         <script src="../node_modules/codemirror/mode/markdown/markdown.js"></script>
         <script src="../node_modules/codemirror/mode/yaml/yaml.js"></script>
@@ -180,26 +181,24 @@
         <script src="../node_modules/codemirror/mode/css/css.js"></script>
         <script src="../node_modules/codemirror/mode/htmlmixed/htmlmixed.js"></script>
         <script src="../node_modules/codemirror/mode/javascript/javascript.js"></script>
-
+        <script src="../node_modules/codemirror/mode/javascript/javascript.js"></script>
         <script src="../node_modules/codemirror/mode/clike/clike.js"></script>
-        <script src="../node_modules/codemirror/mode/haml/haml.js"></script>
-        <script src="../node_modules/codemirror/mode/jsx/jsx.js"></script>
-        <script src="../node_modules/codemirror/mode/php/php.js"></script>
-        <script src="../node_modules/codemirror/mode/python/python.js"></script>
-        <script src="../node_modules/codemirror/mode/powershell/powershell.js"></script>
-        <script src="../node_modules/codemirror/mode/ruby/ruby.js"></script>
-        <script src="../node_modules/codemirror/mode/shell/shell.js"></script>
-        <script src="../node_modules/codemirror/mode/slim/slim.js"></script>
         <script src="../node_modules/codemirror/mode/sql/sql.js"></script>
-        <script src="../node_modules/codemirror/mode/stex/stex.js"></script>
-        <script src="../node_modules/codemirror/mode/textile/textile.js"></script>
-        <script src="../node_modules/codemirror/mode/verilog/verilog.js"></script>
-        <script src="../node_modules/codemirror/mode/xquery/xquery.js"></script>
-        <script src="../node_modules/codemirror/mode/rust/rust.js"></script>
-        <script src="../node_modules/codemirror/mode/mscgen/mscgen.js"></script>
-        <script src="../node_modules/codemirror/mode/dylan/dylan.js"></script>
-        <script src="../node_modules/codemirror/mode/meta.js"></script>
-
+        <script src="../node_modules/codemirror/mode/python/python.js"></script>
+        <script src="../node_modules/codemirror/mode/php/php.js"></script>
+        <!--hint-->
+        <!--<script src="../node_modules/codemirror/addon/hint/anyword-hint.js"></script>-->
+        <!--<script src="../node_modules/codemirror/addon/hint/javascript-hint.js"></script>-->
+        <!--<script src="../node_modules/codemirror/addon/hint/sql-hint.js"></script>-->
+        <!--<script src="../node_modules/codemirror/addon/hint/show-hint.js"></script>-->
+        <!--brackets-->
+        <script src="../node_modules/codemirror/addon/edit/closebrackets.js"></script>
+        <!--fold-->
+        <script src="../node_modules/codemirror/addon/fold/foldcode.js"></script>
+        <script src="../node_modules/codemirror/addon/fold/foldgutter.js"></script>
+        <script src="../node_modules/codemirror/addon/fold/brace-fold.js"></script>
+        <script src="../node_modules/codemirror/addon/fold/comment-fold.js"></script>
+        <!--other-->
         <script src="../node_modules/codemirror/addon/mode/overlay.js"></script>
         <script src="../node_modules/codemirror/addon/mode/multiplex.js"></script>
         <script src="../node_modules/codemirror/addon/scroll/simplescrollbars.js"></script>

+ 20 - 20
views/main/moe-contextmenu.js

@@ -35,7 +35,7 @@ document.addEventListener('DOMContentLoaded', () => {
                 {
                     label: __('Undo'),
                     enabled: window.editor.doc.historySize().undo !== 0,
-                    click(item, w) {
+                    click(item, hexoWindow) {
                         window.editor.undo();
                     }
                 },
@@ -56,16 +56,16 @@ document.addEventListener('DOMContentLoaded', () => {
                     label: __('Paste'),
                     enabled: inEditor && (require('electron').clipboard.readText().length !== 0||
                         !clipboard.readImage().isEmpty()),
-                    click(item, w){
+                    click(item, hexoWindow){
                         pasteData();
                     }
                 },
                 {
                     label: __('Delete'),
                     enabled: inEditor && window.editor.doc.somethingSelected(),
-                    click(item, w) {
-                        w.webContents.sendInputEvent({ type: 'keyDown', modifiers: [], keyCode: 'Delete' });
-                        w.webContents.sendInputEvent({ type: 'keyUp', modifiers: [], keyCode: 'Delete' });
+                    click(item, hexoWindow) {
+                        hexoWindow.webContents.sendInputEvent({ type: 'keyDown', modifiers: [], keyCode: 'Delete' });
+                        hexoWindow.webContents.sendInputEvent({ type: 'keyUp', modifiers: [], keyCode: 'Delete' });
                     }
                 },
                 {
@@ -73,7 +73,7 @@ document.addEventListener('DOMContentLoaded', () => {
                 },
                 {
                     label: __('Select All'),
-                    click(item, w) {
+                    click(item, hexoWindow) {
                         if (inEditor) {
                             window.editor.execCommand('selectAll');
                         } else {
@@ -92,7 +92,7 @@ document.addEventListener('DOMContentLoaded', () => {
                     label: __('Show Number'),
                     type: 'checkbox',
                     checked: window.editor.getOption('lineNumbers'),
-                    click(item, w) {
+                    click(item, hexoWindow) {
                         let editor = document.querySelector('#editor');
                         if (item.checked) {
                             editor.classList.add('gutter');
@@ -107,39 +107,39 @@ document.addEventListener('DOMContentLoaded', () => {
                     label: __('Scroll Sync'),
                     type: 'checkbox',
                     checked: window.scrollTogether,
-                    click(item, w) {
+                    click(item, hexoWindow) {
                         window.scrollTogether = !window.scrollTogether;
                     }
                 },
                 {
-                    type: moeApp.defTheme ? 'normal' : 'separator',
-                    visible: !moeApp.defTheme,
+                    type: moeApp.useHexo ? 'normal' : 'separator',
+                    visible: !moeApp.useHexo,
                 },
                 {
                     label: "HEXO",
-                    visible: !moeApp.defTheme,
+                    visible: !moeApp.useHexo,
                     enabled: !shellServer.processRunning(),
-                    click(item, w) {
+                    click(item, hexoWindow) {
                         const shell = require('electron').shell
                         shell.showItemInFolder(path.join(hexo.config.__basedir, '*'))
                     },
                     submenu: [
                         {
                             label: __('File Rename'),
-                            click(item, w) {
+                            click(item, hexoWindow) {
                                 window.changeFileName(true);
                             }
                         },
                         {
                             label: __('HEXOOpenPath'),
-                            click(item, w) {
+                            click(item, hexoWindow) {
                                 const shell = require('electron').shell
                                 shell.showItemInFolder(path.join(hexo.config.__basedir, '*'))
                             }
                         },
                         {
                             label: __('HEXOQuickPublish'),
-                            click(item, w) {
+                            click(item, hexoWindow) {
                                 shellServer.generalAndDeploy();
                             }
                         },
@@ -148,31 +148,31 @@ document.addEventListener('DOMContentLoaded', () => {
                         },
                         {
                             label: __('HEXOServer'),
-                            click(item, w) {
+                            click(item, hexoWindow) {
                                 shellServer.server();
                             }
                         },
                         {
                             label: __('HEXOClean'),
-                            click(item, w) {
+                            click(item, hexoWindow) {
                                 shellServer.clean();
                             }
                         },
                         {
                             label: __('HEXOGenerate'),
-                            click(item, w) {
+                            click(item, hexoWindow) {
                                 shellServer.general();
                             }
                         },
                         {
                             label: __('HEXODeploy'),
-                            click(item, w) {
+                            click(item, hexoWindow) {
                                 shellServer.deploy();
                             }
                         },
                         {
                             label: __('HEXOKillPort'),
-                            click(item, w) {
+                            click(item, hexoWindow) {
                                 shellServer.stopServerForce();
                             }
                         }

+ 84 - 74
views/main/moe-document.js

@@ -22,13 +22,13 @@
 require('electron-titlebar');
 window.app = require('electron').remote.app;
 window.moeApp = app.moeApp;
-window.w = moeApp.newWindow;
+window.hexoWindow = moeApp.hexoWindow;
 window.imgRelativePathToID = {};
 window.imgIDToRelativePath = {};
 window.imgRelativeToAbsolute = {};
 window.clipboard = require('electron').clipboard;
 
-let gSavedContent;
+hexoWindow.savedContent;
 
 $(() => {
     const fs = require('fs');
@@ -38,10 +38,10 @@ $(() => {
 
     const MoeditorPreview = require('./moe-preview');
 
-    if (w.fileName !== '') {
-        document.getElementsByTagName('title')[0].innerText = 'Moeditor - ' + path.basename(w.fileName);
+    if (hexoWindow.fileName !== '') {
+        document.getElementsByTagName('title')[0].innerText = 'HexoEditor - ' + path.basename(hexoWindow.fileName);
     }
-    document.querySelector('#editor textarea').innerText = w.content;
+    document.querySelector('#editor textarea').innerText = hexoWindow.content;
 
     var editor = CodeMirror.fromTextArea(document.querySelector('#editor textarea'), {
         lineNumbers: false,
@@ -60,6 +60,11 @@ $(() => {
             'Shift-Tab': 'indentLess',
         },
         fixedGutter: false,
+        // foldGutter: true,
+        // gutters:["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
+        // auto:"auto",
+        // autoCloseBrackets: true,
+
         tabSize: moeApp.config.get('tab-size'),
         indentUnit: moeApp.config.get('tab-size'),
         viewportMargin: Infinity,
@@ -68,6 +73,9 @@ $(() => {
     });
 
     editor.focus();
+    editor.on('keypress', ()=>{
+        editor.showHint();
+    });
 
     window.mkdirsSync = (dirpath, mode) => {
         if (!fs.existsSync(dirpath)) {
@@ -94,19 +102,19 @@ $(() => {
     };
     window.imgRootPath = (extendPath) => {
         let rootPaht = '';
-        if (!moeApp.defTheme && hexo.config.__basedir) {
+        if (!moeApp.useHexo && hexo.config.__basedir) {
             rootPaht = path.join(hexo.config.__basedir, 'source', extendPath || '');
         } else if (moeApp.config.get('image-path')) {
             rootPaht = moeApp.config.get('image-path');
         } else {
-            rootPaht = w.directory;
+            rootPaht = hexoWindow.directory;
         }
         return rootPaht;
     }
 
     function replaceImgSelection(codeMirror, title, relativePath, imageID, absolutePath) {
         if (!relativePath) {
-            if (!moeApp.defTheme && hexo.config.__basedir)
+            if (!moeApp.useHexo && hexo.config.__basedir)
                 relativePath = '/' + path.relative(imgRootPath(), absolutePath).replace(/\\+/g, '/')
             else
                 relativePath = '/' + path.relative(imgRootPath(), absolutePath).replace(/\\+/g, '/')
@@ -137,7 +145,7 @@ $(() => {
             let imageName = imageTitle || require('moment')().format('YYYYMMDDhhmmssSSS');
 
             let count = 0;
-            let currFileName = path.basename(w.fileName, path.extname(w.fileName)) || w.ID;
+            let currFileName = path.basename(hexoWindow.fileName, path.extname(hexoWindow.fileName)) || hexoWindow.ID;
             let imageAbsolutePath = path.join(rootPaht, currFileName, imageName + '.png');
             do {
                 if (count > 0)
@@ -183,42 +191,42 @@ $(() => {
     };
 
     window.changeFileName = (force) => {
-        if (!force && w.defName !== w.fileName) return;
+        if (!force && hexoWindow.defName !== hexoWindow.fileName) return;
 
         let title, fileNameNew;
-        let filename = path.basename(w.fileName, path.extname(w.fileName));
+        let filename = path.basename(hexoWindow.fileName, path.extname(hexoWindow.fileName));
         let oldName = filename;
 
-        w.content.replace(/^---+([\w\W]+?)---+/, function () {
+        hexoWindow.content.replace(/^---+([\w\W]+?)---+/, function () {
             title = YMAL.parse(arguments[1]).title;
             return '';
         });
 
         if (filename === title) {
             if (force)
-                w.isSaved = true;
+                hexoWindow.isSaved = true;
             return
         }
 
         try {
             filename = title.toString().replace(/[ \\\/:\*\?"<>\|]+/g, '-');
-            let dir = path.dirname(w.fileName);
-            let ext = path.extname(w.fileName);
+            let dir = path.dirname(hexoWindow.fileName);
+            let ext = path.extname(hexoWindow.fileName);
             let count = -1;
             do {
                 count++;
                 fileNameNew = filename + (count > 0 ? count : '');
                 fileNameNew = path.resolve(dir, fileNameNew + ext);
-                if (w.fileName == fileNameNew || count > 50) {
+                if (hexoWindow.fileName == fileNameNew || count > 50) {
                     return;
                 }
             } while (fs.existsSync(fileNameNew))
 
-            fs.renameSync(w.fileName, fileNameNew);
-            w.fileName = fileNameNew;
+            fs.renameSync(hexoWindow.fileName, fileNameNew);
+            hexoWindow.fileName = fileNameNew;
 
-            w.window.setRepresentedFilename(fileNameNew);
-            document.getElementsByTagName('title')[0].innerText = 'Moeditor - ' + path.basename(fileNameNew);
+            hexoWindow.window.setRepresentedFilename(fileNameNew);
+            document.getElementsByTagName('title')[0].innerText = 'HexoEditor - ' + path.basename(fileNameNew);
 
             let irp = imgRootPath('images');
             let imgFilePathOld = path.join(irp, oldName);
@@ -229,26 +237,31 @@ $(() => {
                     fs.stat(imgFilePathNew, (err, stats) => {
                         if (err) console.error(err);
                         console.log('stats: ' + JSON.stringify(stats));
-                        let relativePathOld = path.relative(imgRootPath(),imgFilePathOld).replace(/[\/\\]/g,'\\[\\\\/\\\\\\\\\\]');
-                        let relativePathNew = path.relative(imgRootPath(),imgFilePathNew).replace(/[\/\\]/g,'\\\\/');
-                        editor.setValue(editor.getValue().replace(new RegExp('\\]\\(/'+relativePathOld),'g'),'](/'+relativePathNew)
+                        let relativePathOld = path.relative(imgRootPath(),imgFilePathOld).replace(/[\/\\]/g,'/');
+                        let relativePathNew = path.relative(imgRootPath(),imgFilePathNew).replace(/[\/\\]/g,'/');
+                        editor.setValue(editor.getValue().replace(new RegExp('\\]\\(/'+relativePathOld,'g'),'](/'+relativePathNew))
+                        renameFinished(relativePathOld,relativePathNew,)
+
+                        window.imgIDToRelativePath = JSON.parse(JSON.stringify(imgIDToRelativePath).replace(new RegExp(relativePathOld,'g'),relativePathNew));
+                        window.imgRelativePathToID = JSON.parse(JSON.stringify(imgRelativePathToID).replace(new RegExp(relativePathOld,'g'),relativePathNew));
+                        window.imgRelativeToAbsolute = JSON.parse(JSON.stringify(imgRelativeToAbsolute).replace(new RegExp(relativePathOld,'g'),relativePathNew));
                     })
                 })
             }
 
 
             if (force) {
-                fs.writeFile(w.fileName, w.content, (err) => {
+                fs.writeFile(hexoWindow.fileName, hexoWindow.content, (err) => {
                     if (err) {
-                        w.changed = true;
-                        w.window.setDocumentEdited(true);
+                        hexoWindow.changed = true;
+                        hexoWindow.window.setDocumentEdited(true);
                         return;
                     }
-                    w.isSaved = true;
-                    w.changed = false;
-                    w.window.setDocumentEdited(false);
+                    hexoWindow.isSaved = true;
+                    hexoWindow.changed = false;
+                    hexoWindow.window.setDocumentEdited(false);
                     app.addRecentDocument(fileNameNew);
-                    gSavedContent = w.content;
+                    hexoWindow.savedContent = hexoWindow.content;
                 });
             }
         } catch (e) {
@@ -258,16 +271,16 @@ $(() => {
 
     window.autoSave = () => {
         const option = moeApp.config.get('auto-save');
-        if (option === 'auto' && w.content !== gSavedContent) {
-            fs.writeFile(w.fileName, w.content, (err) => {
+        if (option === 'auto' && hexoWindow.content !== hexoWindow.savedContent) {
+            fs.writeFile(hexoWindow.fileName, hexoWindow.content, (err) => {
                 if (err) {
-                    w.changed = true;
-                    w.window.setDocumentEdited(true);
+                    hexoWindow.changed = true;
+                    hexoWindow.window.setDocumentEdited(true);
                     return;
                 }
-                w.isSaved = true;
-                w.changed = false;
-                w.window.setDocumentEdited(false);
+                hexoWindow.isSaved = true;
+                hexoWindow.changed = false;
+                hexoWindow.window.setDocumentEdited(false);
             });
         }
     }
@@ -277,7 +290,7 @@ $(() => {
     });
 
     editor.on('blur', () => {
-        if (w.fileName === '') return;
+        if (hexoWindow.fileName === '') return;
         window.changeFileName(false);
         window.autoSave();
     });
@@ -330,28 +343,20 @@ $(() => {
         if (e.target === leftPanel) editor.focus();
     });
 
-    // if (moeApp.config.get('focus-mode') === true) document.getElementById('editor').classList.add('focus');
-    // document.getElementById('button-bottom-focus').addEventListener('click', function() {
-    //     document.getElementById('editor').classList.toggle('focus');
-    //     moeApp.config.set('focus-mode', document.getElementById('editor').classList.contains('focus'));
-    // });
+    if (moeApp.config.get('focus-mode') === true) document.getElementById('editor').classList.add('focus');
+    document.getElementById('button-bottom-focus').addEventListener('click', function() {
+        document.getElementById('editor').classList.toggle('focus');
+        moeApp.config.set('focus-mode', document.getElementById('editor').classList.contains('focus'));
+    });
 
     require('electron').ipcRenderer.on('set-title', (e, fileName) => {
-        document.getElementsByTagName('title')[0].innerText = 'Moeditor - ' + path.basename(fileName);
+        document.getElementsByTagName('title')[0].innerText = 'HexoEditor - ' + path.basename(fileName);
     });
 
     require('./moe-settings');
 
-    w.window.show();
+    hexoWindow.window.show();
 
-    // $(".CodeMirror-vscrollbar").hover(
-    //     function () {
-    //         $(this).addClass('hoverScroll')
-    //     },
-    //     function () {
-    //         $(this).removeClass('hoverScroll')
-    //     }
-    // );
 
     $("#main-container div").mousemove(function (e) {
         // $('.scrolling').removeClass('scrolling');
@@ -396,6 +401,17 @@ $(() => {
         renameForm.querySelector('input').value = '';
         renameForm.classList.add('show');
     }
+    window.renameFinished = (oldRelative,newRelative,oldAbsolute,newAbsolute)=>{
+        if (!newAbsolute)
+            newAbsolute = path.join(imgRootPath(), newRelative).replace(/\\/g, '/');
+        let oldImgID = imgRelativePathToID[oldRelative];
+        imgIDToRelativePath[oldImgID] = newRelative;
+        imgRelativePathToID[newRelative] = oldImgID;
+        imgRelativeToAbsolute[newRelative] = newAbsolute;
+        delete imgRelativePathToID[oldRelative];
+        delete imgRelativeToAbsolute[oldRelative];
+        delete imgIDToRelativePath[oldImgID];
+    }
 
     document.querySelector('#renameForm .button-check').addEventListener("click", e => {
         let rootPaht = window.imgRootPath();
@@ -410,7 +426,6 @@ $(() => {
             const newAbsolutePath = path.join(path.dirname(absolutePath), newName).replace(/\\/g, '/');
             const newRelativePath = path.normalize('/' + path.relative(rootPaht, newAbsolutePath)).replace(/\\/g, '/');
 
-            let content;
             if (fs.existsSync(newAbsolutePath)) {
                 window.popMessageShell(e, {
                     content: 'FileExist',
@@ -420,13 +435,8 @@ $(() => {
                 renameForm.querySelector('input').select();
             } else {
                 fs.renameSync(absolutePath, newAbsolutePath);
-                let oldImgID = imgRelativePathToID[relativePath];
-                imgIDToRelativePath[oldImgID] = newRelativePath;
-                imgRelativePathToID[newRelativePath] = oldImgID;
-                imgRelativeToAbsolute[newRelativePath] = newAbsolutePath;
-                delete imgRelativePathToID[relativePath];
-                delete imgRelativeToAbsolute[relativePath];
-                delete imgIDToRelativePath[oldImgID];
+
+                renameFinished(relativePath,newRelativePath,newAbsolutePath)
 
                 let reg = new RegExp('(!\\[[^\\[\\]]*\\]\\()' + relativePath.replace(/\\/g, '\\\\') + '\\)', 'g')
                 editor.setValue(editor.getValue().replace(reg, '$1' + newRelativePath + ')'));
@@ -438,8 +448,6 @@ $(() => {
                     autoHide: true
                 })
             }
-
-
         }
     })
 
@@ -475,6 +483,8 @@ $(() => {
         if (e.ctrlKey) {
             $('span.cm-string.cm-url').unbind('click').click(e => {
                 if (e.ctrlKey) {
+                    e.stopPropagation();
+                    // e.defaultPrevented();
                     const innerLink = e.target.innerText.replace(/^\((.*)\)$/, '$1');
                     if (innerLink.startsWith('http://') || innerLink.startsWith('https://'))
                         require('electron').shell.openItem(innerLink);
@@ -502,22 +512,22 @@ $(() => {
     })
 
     window.onfocus = (e) => {
-        if (w.fileName === '') return;
-        fs.readFile(w.fileName, (err, res) => {
+        if (hexoWindow.fileName === '') return;
+        fs.readFile(hexoWindow.fileName, (err, res) => {
             if (err) {
-                w.changed = true;
-                w.window.setDocumentEdited(true);
+                hexoWindow.changed = true;
+                hexoWindow.window.setDocumentEdited(true);
                 return;
             }
             let s = res.toString();
-            if (s !== w.fileContent) {
+            if (s !== hexoWindow.fileContent) {
                 const option = moeApp.config.get('auto-reload');
                 let flag = false;
                 if (option === 'auto') flag = true;
                 else if (option === 'never') flag = false;
                 else {
                     flag = dialog.showMessageBox(
-                        w.window,
+                        hexoWindow.window,
                         {
                             type: 'question',
                             buttons: [__("Yes"), __("No")],
@@ -528,11 +538,11 @@ $(() => {
                     ) === 0;
                 }
 
-                w.fileContent = w.content = s;
+                hexoWindow.fileContent = hexoWindow.content = s;
 
                 if (!flag) {
-                    w.changed = true;
-                    w.window.setDocumentEdited(true);
+                    hexoWindow.changed = true;
+                    hexoWindow.window.setDocumentEdited(true);
                     return;
                 }
 
@@ -545,8 +555,8 @@ $(() => {
                 if (scrollpos > 0)
                     editorScroll.scrollTop = scrollpos;
 
-                w.changed = false;
-                w.window.setDocumentEdited(false);
+                hexoWindow.changed = false;
+                hexoWindow.window.setDocumentEdited(false);
                 window.updatePreview(true);
             }
         });

+ 4 - 4
views/main/moe-export.js

@@ -70,7 +70,7 @@ function render(s, type, cb) {
 }
 
 function html(cb) {
-    render(w.content, 'html', (res, haveMath, haveCode) => {
+    render(hexoWindow.content, 'html', (res, haveMath, haveCode) => {
         const doc = document.implementation.createHTMLDocument();
         const head = doc.querySelector('head');
         const meta = doc.createElement('meta');
@@ -103,7 +103,7 @@ function html(cb) {
 }
 
 function pdf(cb) {
-    render(w.content, 'pdf', (res, haveMath, haveCode) => {
+    render(hexoWindow.content, 'pdf', (res, haveMath, haveCode) => {
         const doc = document.implementation.createHTMLDocument();
         const head = doc.querySelector('head');
         const meta = doc.createElement('meta');
@@ -154,13 +154,13 @@ if (!flag) {
     const ipcRenderer = require('electron').ipcRenderer;
     const MoeditorAction = require('electron').remote.require('./moe-action');
     ipcRenderer.on('action-export-html', () => {
-        MoeditorAction.exportAsHTML(w.window, (cb) => {
+        MoeditorAction.exportAsHTML(hexoWindow.window, (cb) => {
             html(cb);
         });
     });
 
     ipcRenderer.on('action-export-pdf', () => {
-        MoeditorAction.exportAsPDF(w.window, (cb) => {
+        MoeditorAction.exportAsPDF(hexoWindow.window, (cb) => {
             pdf(cb);
         });
     });

+ 5 - 5
views/main/moe-popmessage.js

@@ -66,12 +66,12 @@ document.addEventListener('DOMContentLoaded', () => {
     ipcRenderer.on('pop-message-shell',popMessageShell)  ;
 
     ipcRenderer.on('refresh-editor', function () {
-        let w  = window.w;
-        if (w.fileName !== '') {
-            document.getElementsByTagName('title')[0].innerText = 'Moeditor - ' + require('path').basename(w.fileName);
+        let hexoWindow  = window.hexoWindow;
+        if (hexoWindow.fileName !== '') {
+            document.getElementsByTagName('title')[0].innerText = 'Moeditor - ' + require('path').basename(hexoWindow.fileName);
         }
-        document.querySelector('#editor textarea').innerText = w.content;
-        window.editor.setValue(w.content);
+        document.querySelector('#editor textarea').innerText = hexoWindow.content;
+        window.editor.setValue(hexoWindow.content);
         window.updatePreview(true);
     })
 });

+ 5 - 5
views/main/moe-preview.js

@@ -31,17 +31,17 @@ module.exports = (cm, force, cb) => {
         updatePreviewRunning = true;
 
         const content = cm.getValue();
-        if (w.content === content && !force) {
+        if (hexoWindow.content === content && !force) {
             updatePreviewRunning = false;
             if (updatePreview) setTimeout(updateAsync, 0);
             cb();
             return;
         }
 
-        if (w.content !== content) {
-            w.content = content;
-            w.changed = true;
-            w.window.setDocumentEdited(true);
+        if (hexoWindow.content !== content) {
+            hexoWindow.content = content;
+            hexoWindow.changed = true;
+            hexoWindow.window.setDocumentEdited(true);
         }
 
         if (window.editMode && !window.editMode.startsWith('preview') && !window.editMode.startsWith('read')) {

+ 1 - 1
views/main/moe-rendertheme.js

@@ -26,7 +26,7 @@ const url = require('url');
 module.exports = {
     getCSS(forURL) {
         const theme = moeApp.config.get('render-theme');
-        moeApp.defTheme = ['*GitHub','*No Theme'].indexOf(theme) > -1;
+        moeApp.useHexo = ['*GitHub','*No Theme'].indexOf(theme) > -1;
 
         let res;
         if (theme.startsWith('*')) {

+ 8 - 2
views/main/moe-settings.js

@@ -89,6 +89,11 @@ function setEditorLineHeight(val) {
     window.editor.refresh();
 }
 
+function setImagePath(val) {
+    console.log(val)
+    window.editor.refresh();
+}
+
 function setMath(val) {
     window.editor.refresh();
     window.updatePreview(true);
@@ -126,11 +131,9 @@ function setRenderTheme(val) {
     if (['*GitHub','*No Theme'].indexOf(val) > -1){
         $(container).addClass('_def');
         $(container).removeClass('post-body');
-        moeApp.defTheme = true;
     } else /*if ( 'post-body' == val )*/{
         $(container).removeClass('_def');
         $(container).addClass('post-body');
-        moeApp.defTheme = false;
     }
     moeApp.containerClasss = container.className.replace('preview','');
 
@@ -150,6 +153,7 @@ function setHexoAutoSetting(val) {
 };
 
 function setHexoConfigEnable(val) {
+    moeApp.useHexo = val;                                  us
     hexo.enable = val;
     hexo.changeConfig();
     window.updatePreview(true);
@@ -217,6 +221,8 @@ ipcRenderer.on('setting-changed', (e, arg) => {
         tryRun(setEditorFontSize, arg.val);
     } else if (arg.key === 'editor-line-height') {
         tryRun(setEditorLineHeight, arg.val);
+    } else if (arg.key === 'image-path') {
+        tryRun(setImagePath, arg.val);
     } else if (arg.key === 'math') {
         tryRun(setMath, arg.val);
     } else if (arg.key === 'uml-diagrams') {

+ 5 - 5
views/main/moe-sidemenu.js

@@ -71,27 +71,27 @@ document.addEventListener('DOMContentLoaded', () => {
     });
 
     sideMenu.querySelector('li[data-action=open]').itemClicked = (() => {
-        MoeditorAction.open(w.window);
+        MoeditorAction.open(hexoWindow.window);
     });
 
     sideMenu.querySelector('li[data-action=save]').itemClicked = (() => {
-        MoeditorAction.save(w.window);
+        MoeditorAction.save(hexoWindow.window);
     });
 
     sideMenu.querySelector('li[data-action=save-as]').itemClicked = (() => {
-        MoeditorAction.saveAs(w.window);
+        MoeditorAction.saveAs(hexoWindow.window);
     });
 
     sideMenu.querySelector('li[data-action=export-as-html]').itemClicked = (() => {
         const MoeditorExport = require('./moe-export');
-        MoeditorAction.exportAsHTML(w.window, (cb) => {
+        MoeditorAction.exportAsHTML(hexoWindow.window, (cb) => {
             MoeditorExport.html(cb);
         });
     });
 
     sideMenu.querySelector('li[data-action=export-as-pdf]').itemClicked = (() => {
         const MoeditorExport = require('./moe-export');
-        MoeditorAction.exportAsPDF(w.window, (cb) => {
+        MoeditorAction.exportAsPDF(hexoWindow.window, (cb) => {
             MoeditorExport.pdf(cb);
         });
     });

+ 20 - 18
views/main/moe-style.css

@@ -231,10 +231,29 @@ html, body {
     position: absolute;
     top: 0;
     width: 100%;
-    height: 50px;
+    height: 40px;
     z-index: 1000;
 }
 
+
+#drag-left {
+    z-index: -1;
+    position: absolute;
+    top: 0;
+    left: 0;
+    width: calc(50% - 10px);
+    height: 100%;
+}
+
+#drag-right {
+    z-index: -1;
+    position: absolute;
+    top: 0;
+    right: 0;
+    width: 50%;
+    height: 100%;
+}
+
 #left-panel .cover-top {
     left: 0;
 }
@@ -465,23 +484,6 @@ moemark-linenumber{
     word-wrap: break-word !important;
 }
 
-#drag-left {
-    z-index: -1;
-    position: absolute;
-    top: 0;
-    left: 0;
-    width: calc(50% - 6px);
-    height: 100%;
-}
-
-#drag-right {
-    z-index: -1;
-    position: absolute;
-    top: 0;
-    right: 0;
-    width: 50%;
-    height: 100%;
-}
 
 #renameForm input {
     background-color: #fff;

+ 1 - 1
views/main/moe-treeview.js

@@ -70,7 +70,7 @@ document.addEventListener('DOMContentLoaded', () => {
         items.appendChild(newNode);
     }
 
-    const MoeditorPath = require('./moe-path'), rootPath = new MoeditorPath(w.directory);
+    const MoeditorPath = require('./moe-path'), rootPath = new MoeditorPath(hexoWindow.directory);
 
     function clickItem(e) {
         if (e.getAttribute('data-isdir') === 'true') {

+ 121 - 105
views/settings/moe-settings.js

@@ -20,6 +20,7 @@
 'use strict';
 
 require('electron-titlebar');
+const dialog = require('electron').remote.dialog;
 
 document.addEventListener('DOMContentLoaded', () => {
     window.localized.push(() => {
@@ -48,7 +49,7 @@ document.addEventListener('DOMContentLoaded', () => {
                     }
                 }
             });
-            ipcRenderer.send('setting-changed', { key: 'locale', val: selectLocale.value });
+            ipcRenderer.send('setting-changed', {key: 'locale', val: selectLocale.value});
         });
         document.querySelector("#hexo-auto-setting").value = '<i class="fa fa-hand-pointer-o" aria-hidden="true"></i>';
         require('electron').remote.getCurrentWindow().show();
@@ -70,23 +71,35 @@ document.addEventListener('DOMContentLoaded', () => {
                 else val = item.value;
                 console.log(key + ': ' + val);
                 moeApp.config.set(key, val);
-                if (!item.classList.contains('dont-notify')) ipcRenderer.send('setting-changed', { key: key, val: val });
+                if (!item.classList.contains('dont-notify')) ipcRenderer.send('setting-changed', {key: key, val: val});
             });
         }
     }
 
+    // Image Path
+    let defImagePath =  document.querySelector('.settings-item[data-key="image-path"]');
+    defImagePath.value = moeApp.config.get('image-path');
+    document.querySelector('#image-path-button').addEventListener('click', () => {
+        dialog.showOpenDialog(window.hexoWindow, {properties: ['openDirectory']}, (dirPath) => {
+            if (!dirPath || dirPath.length === 0) return;
+            defImagePath.value = dirPath;
+            moeApp.config.set('image-path', dirPath.replace(/\\/g, '/'));
+            ipcRenderer.send('image-path', {key: "image-path", val: dirPath});
+        });
+    });
+
     // Custom render themes
     let renderThemeSelect = document.querySelector('select[data-key="render-theme"]');
 
-    function setCurrentTheme(currTheme, changeConfig){
-        if (!currTheme){
+    function setCurrentTheme(currTheme, changeConfig) {
+        if (!currTheme) {
             currTheme = moeApp.config.get('render-theme');
         } else {
             if (changeConfig)
                 moeApp.config.set("render-theme", currTheme);
         }
         renderThemeSelect.value = currTheme;
-        ipcRenderer.send('setting-changed', { key: "render-theme", val: currTheme });
+        ipcRenderer.send('setting-changed', {key: "render-theme", val: currTheme});
     }
 
     function reloadRenderThemeSelect() {
@@ -95,7 +108,7 @@ document.addEventListener('DOMContentLoaded', () => {
         for (const item in custom) {
             const option = document.createElement('option');
             option.value = option.text = item;
-            if (!fs.existsSync(path.resolve( custom[item],'main.css')))
+            if (!fs.existsSync(path.resolve(custom[item], 'main.css')))
                 option.classList.add('invalidFile');
             renderThemeSelect.appendChild(option);
         }
@@ -104,36 +117,40 @@ document.addEventListener('DOMContentLoaded', () => {
 
     let renderThemeButtonAdd = document.querySelector('select[data-key="render-theme"] ~ button.button-add');
     let renderThemeButtonRemove = document.querySelector('select[data-key="render-theme"] ~ button.button-remove');
+
     function setRenderThemeButtons() {
-        if (renderThemeSelect.selectedOptions[0].classList.contains('builtin')) {
-            renderThemeButtonRemove.setAttribute('disabled', null);
-        } else {
-            renderThemeButtonRemove.removeAttribute('disabled');
+        try {
+            if (renderThemeSelect.selectedOptions[0].classList.contains('builtin')) {
+                renderThemeButtonRemove.setAttribute('disabled', null);
+            } else {
+                renderThemeButtonRemove.removeAttribute('disabled');
+            }
+            reloadHighlightSelect(renderThemeSelect.value);
+        } catch (e) {
+            console.error(e)
         }
-        reloadHighlightSelect(renderThemeSelect.value);
     }
-    setRenderThemeButtons();
 
+    setRenderThemeButtons();
 
     renderThemeSelect.addEventListener('change', setRenderThemeButtons);
-    const dialog = require('electron').remote.dialog;
     renderThemeButtonAdd.addEventListener('click', () => {
-        dialog.showOpenDialog(window.w, { properties: ['openDirectory', 'multiSelections'] }, (fileNames) => {
+        dialog.showOpenDialog(window.hexoWindow, {properties: ['openDirectory', 'multiSelections']}, (fileNames) => {
             if (!fileNames || fileNames.length === 0) return;
             const a = fileNames.filter((s) => {
                 try {
                     let files = fs.readdirSync(s);
-                    if (files.includes('main.css')){
+                    if (files.includes('main.css')) {
                         return true;
-                    } else if (files.includes('.css')){
+                    } else if (files.includes('.css')) {
                         let stylecss = [];
                         files.filter(function (file) {
-                           if ( file.endsWith('.css')){
-                               stylecss.push(fs.readFileSync(path.join(s,file)));
-                           }
-                           return false;
+                            if (file.endsWith('.css')) {
+                                stylecss.push(fs.readFileSync(path.join(s, file)));
+                            }
+                            return false;
                         })
-                        fs.writeFileSync(path.join(s,'main.css'),stylecss);
+                        fs.writeFileSync(path.join(s, 'main.css'), stylecss);
                         return true;
                     }
                     return false;
@@ -145,7 +162,7 @@ document.addEventListener('DOMContentLoaded', () => {
             for (const s of a) themes[path.basename(s)] = s;
             moeApp.config.set('custom-render-themes', themes);
             console.log(themes);
-            if (a.length > 0){
+            if (a.length > 0) {
                 moeApp.config.set('render-theme', path.basename(a[0]));
             }
             reloadRenderThemeSelect();
@@ -164,14 +181,14 @@ document.addEventListener('DOMContentLoaded', () => {
     // Highlight Theme
     function reloadHighlightSelect(currTheme) {
         let highlightSelect = document.querySelector('select[data-key="highlight-theme"]');
-        const oldvar =  moeApp.config.get("highlight-theme") || highlightSelect.value;
+        const oldvar = moeApp.config.get("highlight-theme") || highlightSelect.value;
         let flagValid = false;
         highlightSelect.innerHTML = '';
         const themedir = moeApp.getHighlightThemesDir();
-        if (themedir){
-            var arr=['default','none','normal','github','github-gist'];
+        if (themedir) {
+            var arr = ['default', 'none', 'normal', 'github', 'github-gist'];
             arr.forEach(s => {
-                if (fs.existsSync(path.join(themedir,s+'.css')) || s == 'none')    {
+                if (fs.existsSync(path.join(themedir, s + '.css')) || s == 'none') {
                     if (!flagValid && s == oldvar) flagValid = true;
                     const option = document.createElement('option');
                     option.value = option.text = s;
@@ -189,17 +206,17 @@ document.addEventListener('DOMContentLoaded', () => {
                     option.value = option.text = s;
                     highlightSelect.appendChild(option);
                 });
-            if (flagValid && oldvar){
+            if (flagValid && oldvar) {
                 highlightSelect.value = oldvar;
             } else if (currTheme == 'GitHub') {
                 highlightSelect.value = 'github';
-            } else{
-                highlightSelect.value = moeApp.hexo.config.highlight_theme  || highlightSelect.children[0] && highlightSelect.children[0].value;
+            } else {
+                highlightSelect.value = moeApp.hexo.config.highlight_theme || highlightSelect.children[0] && highlightSelect.children[0].value;
             }
             highlightSelect.removeAttribute('disabled');
         } else {
-            highlightSelect.setAttribute('disabled',null);
-            ipcRenderer.send('setting-changed', { key: 'highlight-theme', val: "" });
+            highlightSelect.setAttribute('disabled', null);
+            ipcRenderer.send('setting-changed', {key: 'highlight-theme', val: ""});
         }
 
     }
@@ -209,35 +226,25 @@ document.addEventListener('DOMContentLoaded', () => {
     let hexoConfigLoadButton = document.querySelector('#hexo-config-btn');
     let hexoConfigInput = document.querySelector('input[data-key="hexo-config"]');
     hexoConfigLoadButton.addEventListener('click', () => {
-        dialog.showOpenDialog(window.w, {
+        dialog.showOpenDialog(window.hexoWindow, {
             properties: ['openFile'],
             filters: [
-                { name: __('All Files'), extensions: ['yml'] },
-                { name: __('All Files'), extensions: ['*'] }
+                {name: __('All Files'), extensions: ['yml']},
+                {name: __('All Files'), extensions: ['*']}
             ]
         }, (fileName) => {
             if (!fileName || fileName.length === 0) return;
             moeApp.config.set('hexo-config', fileName);
             console.log(fileName);
-            if(hexoConfigInput.value !== fileName)
-                ipcRenderer.send('setting-changed', { key: 'hexo-config', val: fileName });
+            if (hexoConfigInput.value !== fileName)
+                ipcRenderer.send('setting-changed', {key: 'hexo-config', val: fileName});
             hexoConfigInput.value = fileName;
         });
     });
-    hexoConfigEnableButton.addEventListener('change', () => {
-        if  (hexoConfigEnableButton.checked){
-            hexoConfigInput.style.display = 'inline-block';;
-            hexoConfigLoadButton.style.display = 'inline-block';;
-            btnAddTagClick('ConfigChange');
-        }  else {
-            hexoConfigInput.style.display = 'none';;
-            hexoConfigLoadButton.style.display = 'none';;
-            btnRemoveTagClick('ConfigChange');
-        }
-    });
 
     // Hexo setting
     let customTagsSelect = document.querySelector('select#custom-tags');
+
     function renderHexoTagsSelect(e) {
         customTagsSelect.querySelectorAll('option:not(.builtin)').forEach((a) => customTagsSelect.removeChild(a));
         const tagPaths = moeApp.config.get('hexo-tag-paths');
@@ -247,10 +254,12 @@ document.addEventListener('DOMContentLoaded', () => {
             customTagsSelect.appendChild(option);
         });
         if (e === 'tagschanges')
-            ipcRenderer.send('setting-changed', { key: 'hexo-tag-paths', val: '' });
+            ipcRenderer.send('setting-changed', {key: 'hexo-tag-paths', val: ''});
     }
+
     let renderTagsButtonAdd = document.querySelector('select#custom-tags ~ div button.button-add');
     let renderTagsButtonRemove = document.querySelector('select#custom-tags ~ div button.button-remove');
+
     function setRenderTagButtons() {
         if (customTagsSelect.selectedOptions.length === 0) {
             renderTagsButtonRemove.setAttribute('disabled', null);
@@ -258,12 +267,13 @@ document.addEventListener('DOMContentLoaded', () => {
             renderTagsButtonRemove.removeAttribute('disabled');
         }
     }
+
     setRenderTagButtons();
     customTagsSelect.addEventListener('change', setRenderTagButtons);
 
-    function btnAddTagClick(t){
+    function btnAddTagClick(t) {
         if (t !== 'ConfigChange') {
-            dialog.showOpenDialog(window.w, {properties: ['openDirectory', 'multiSelections']}, (fileNames) => {
+            dialog.showOpenDialog(window.hexoWindow, {properties: ['openDirectory', 'multiSelections']}, (fileNames) => {
                 if (!fileNames || fileNames.length === 0) return;
                 const a = fileNames.filter((s) => {
                     try {
@@ -273,7 +283,7 @@ document.addEventListener('DOMContentLoaded', () => {
                     }
                 });
                 let paths = JSON.parse(JSON.stringify(moeApp.config.get('hexo-tag-paths')));
-                if(! (paths instanceof Array))
+                if (!(paths instanceof Array))
                     paths = [];
                 paths = [...new Set(paths.concat(a))];
                 moeApp.config.set('hexo-tag-paths', paths);
@@ -282,6 +292,7 @@ document.addEventListener('DOMContentLoaded', () => {
             });
         }
     }
+
     function btnRemoveTagClick(t) {
         if (t === 'ConfigChange') {
             return
@@ -306,12 +317,14 @@ document.addEventListener('DOMContentLoaded', () => {
         e.initEvent('change', false, true);
         customTagsSelect.dispatchEvent(e);
     }
-    renderTagsButtonAdd.addEventListener('click',btnAddTagClick);
-    renderTagsButtonRemove.addEventListener('click',btnRemoveTagClick);
+
+    renderTagsButtonAdd.addEventListener('click', btnAddTagClick);
+    renderTagsButtonRemove.addEventListener('click', btnRemoveTagClick);
 
 
     // Custom CSSs
     let customCSSsSelect = document.querySelector('select#custom-csss');
+
     function reloadCustomCSSsSelect() {
         customCSSsSelect.innerHTML = '';
         const custom = moeApp.config.get('custom-csss');
@@ -322,8 +335,10 @@ document.addEventListener('DOMContentLoaded', () => {
             customCSSsSelect.appendChild(option);
         }
     }
+
     let customCSSsButtonAdd = document.querySelector('select#custom-csss ~ div button.button-add');
     let customCSSsButtonRemove = document.querySelector('select#custom-csss ~ div button.button-remove');
+
     function setCustomCSSsButtons() {
         if (customCSSsSelect.selectedOptions.length === 0) {
             customCSSsButtonRemove.setAttribute('disabled', null);
@@ -331,19 +346,20 @@ document.addEventListener('DOMContentLoaded', () => {
             customCSSsButtonRemove.removeAttribute('disabled');
         }
     }
+
     setCustomCSSsButtons();
     customCSSsSelect.addEventListener('change', setCustomCSSsButtons);
     customCSSsButtonAdd.addEventListener('click', () => {
-        dialog.showOpenDialog(window.w, {
+        dialog.showOpenDialog(window.hexoWindow, {
             properties: ['openFile', 'multiSelections'],
             filters: [
-                { name: __('CSS Files'), extensions: ['css'] },
-                { name: __('All Files'), extensions: ['*'] }
+                {name: __('CSS Files'), extensions: ['css']},
+                {name: __('All Files'), extensions: ['*']}
             ]
         }, (fileNames) => {
             if (!fileNames || fileNames.length === 0) return;
             let csss = JSON.parse(JSON.stringify(moeApp.config.get('custom-csss')));
-            for (const s of fileNames) csss[path.basename(s)] = { fileName: s, selected: false };
+            for (const s of fileNames) csss[path.basename(s)] = {fileName: s, selected: false};
             moeApp.config.set('custom-csss', csss);
             console.log(csss);
             reloadCustomCSSsSelect();
@@ -368,15 +384,15 @@ document.addEventListener('DOMContentLoaded', () => {
         }
         moeApp.config.set('custom-csss', csss);
         console.log(csss);
-        ipcRenderer.send('setting-changed', { key: 'custom-csss', val: csss });
+        ipcRenderer.send('setting-changed', {key: 'custom-csss', val: csss});
     });
 
-    function newCustomeTheme(dir){
+    function newCustomeTheme(dir) {
         try {
-            if ( !fs.existsSync(dir ))
+            if (!fs.existsSync(dir))
                 return false;
             let fileNames = fs.readdirSync(dir);
-            if (fileNames.includes('main.css') )
+            if (fileNames.includes('main.css'))
                 return true;
             let stylecss = [];
             fileNames.filter(function (file) {
@@ -395,58 +411,58 @@ document.addEventListener('DOMContentLoaded', () => {
     }
 
     let hexoAutoSettingButton = document.querySelector('#hexo-auto-setting');
-    hexoAutoSettingButton.addEventListener('click',function (e) {
-            hexoConfigEnableButton.checked || hexoConfigEnableButton.click();
-            hexoConfigInput.value || hexoConfigLoadButton.click();
-            let mathCheck = document.querySelector('input[data-key="math"]');
-            !mathCheck.checked || mathCheck.click();
+    hexoAutoSettingButton.addEventListener('click', function (e) {
+        hexoConfigEnableButton.checked || hexoConfigEnableButton.click();
+        hexoConfigInput.value || hexoConfigLoadButton.click();
+        let mathCheck = document.querySelector('input[data-key="math"]');
+        !mathCheck.checked || mathCheck.click();
 
-            let umlCheck = document.querySelector('input[data-key="uml-diagrams"]');
-            !umlCheck.checked || umlCheck.click();
+        let umlCheck = document.querySelector('input[data-key="uml-diagrams"]');
+        !umlCheck.checked || umlCheck.click();
 
-            let breaksCheck = document.querySelector('input[data-key="breaks"]');
-            breaksCheck.checked || breaksCheck.click();
+        let breaksCheck = document.querySelector('input[data-key="breaks"]');
+        breaksCheck.checked || breaksCheck.click();
 
-            let hexoConfig = moeApp.getHexo().config;
-            let themes = JSON.parse(JSON.stringify(moeApp.config.get('custom-render-themes')));
-            let hexoTheme = hexoConfig.theme;
-            let isFindStyle = false;
+        let hexoConfig = moeApp.getHexo().config;
+        let themes = JSON.parse(JSON.stringify(moeApp.config.get('custom-render-themes')));
+        let hexoTheme = hexoConfig.theme;
+        let isFindStyle = false;
 
-            if (themes[hexoTheme]){
-                    isFindStyle = newCustomeTheme(themes[hexoTheme])
+        if (themes[hexoTheme]) {
+            isFindStyle = newCustomeTheme(themes[hexoTheme])
+        }
+        //未配置主题,自动配置
+        let classDir = path.join(hexoConfig.__basedir, hexoConfig.public_dir, 'css');
+        if (!isFindStyle) {
+            if (fs.existsSync(classDir) && fs.lstatSync(classDir).isDirectory()) {
+                isFindStyle = newCustomeTheme(classDir);
             }
-            //未配置主题,自动配置
-            let classDir = path.join(hexoConfig.__basedir,hexoConfig.public_dir,'css');
-            if (!isFindStyle){
-                if ( fs.existsSync(classDir) && fs.lstatSync(classDir).isDirectory()){
-                    isFindStyle = newCustomeTheme(classDir);
+        }
+        if (isFindStyle) {
+            for (let item in themes) {
+                if (themes.hasOwnProperty(item) && themes[item] == classDir) {
+                    delete themes[item];
                 }
             }
-            if (isFindStyle) {
-                for (let item in themes){
-                    if (themes.hasOwnProperty(item) && themes[item] == classDir) {
-                            delete themes[item];
-                    }
-                }
 
-                themes[hexoTheme] = classDir;
-                moeApp.config.set('custom-render-themes', themes);
-                moeApp.config.set("render-theme", hexoTheme);
+            themes[hexoTheme] = classDir;
+            moeApp.config.set('custom-render-themes', themes);
+            moeApp.config.set("render-theme", hexoTheme);
 
-                reloadRenderThemeSelect(hexoTheme);
-                reloadHighlightSelect(hexoTheme);
-            } else {
-                dialog.showMessageBox(
-                    window.w,
-                    {
-                        type: 'warning',
-                        title: __('Waring'),
-                        message: __("WaringNoFile"),
-                        detail: __("WaringNoFileDetail1") + classDir +  __("WaringNoFileDetail2")
-                    } ,
-                    function (res) {
-                    }
-                )
-            }
+            reloadRenderThemeSelect(hexoTheme);
+            reloadHighlightSelect(hexoTheme);
+        } else {
+            dialog.showMessageBox(
+                window.hexoWindow,
+                {
+                    type: 'warning',
+                    title: __('Waring'),
+                    message: __("WaringNoFile"),
+                    detail: __("WaringNoFileDetail1") + classDir + __("WaringNoFileDetail2")
+                },
+                function (res) {
+                }
+            )
+        }
     })
 });

+ 4 - 4
views/settings/moe-tabview.js

@@ -21,7 +21,7 @@ document.addEventListener('DOMContentLoaded', () => {
     const tabView = document.getElementsByClassName('tabview')[0];
     const tabs = tabView.getElementsByClassName('item');
     const panels = tabView.getElementsByClassName('panel');
-    const w = require('electron').remote.getCurrentWindow();
+    const hexoWindow = require('electron').remote.getCurrentWindow();
 
     for (const tab of tabs) {
         const s = tab.getAttribute('data-tab');
@@ -45,7 +45,7 @@ document.addEventListener('DOMContentLoaded', () => {
             tab.classList.add('selected');
 
             if (oldHeight !== null && newHeight !== null && oldHeight !== newHeight) {
-                let size = w.getSize();
+                let size = hexoWindow.getSize();
                 /*
                 // The animate has flickering issue
                 let delta = newHeight - oldHeight;
@@ -56,12 +56,12 @@ document.addEventListener('DOMContentLoaded', () => {
                     if (delta < unit) unit = delta;
                     size[1] += unit * sgn;
                     delta -= unit;
-                    w.setSize(size[0], size[1], false);
+                    hexoWindow.setSize(size[0], size[1], false);
                     if (delta) setTimeout(ani, 20);
                 }
                 ani();
                 */
-                w.setSize(size[0], size[1] + newHeight - oldHeight, true);
+                hexoWindow.setSize(size[0], size[1] + newHeight - oldHeight, true);
             }
         });
     }

+ 10 - 5
views/settings/settings.html

@@ -85,7 +85,7 @@
                                 <td width="40%" class="l10n">Reload when file changed</td>
                                 <td width="60%">
                                     <select class="settings-item" data-key="auto-reload">
-                                        <option value="auto" class="l10n">Auto</option>
+                                        <!--<option value="auto" class="l10n">Auto</option>-->
                                         <option value="prompt" class="l10n">Prompt</option>
                                         <option value="never" class="l10n">Never</option>
                                     </select>
@@ -125,13 +125,13 @@
                             <tr>
                                 <td width="40%" class="l10n">Font Size</td>
                                 <td width="60%">
-                                    <input class="settings-item" type="text" data-key="editor-font-size" value="14">
+                                    <input class="settings-item" type="number" data-key="editor-font-size" value="14">
                                 </td>
                             </tr>
                             <tr>
                                 <td width="40%" class="l10n">Line Height</td>
                                 <td width="60%">
-                                    <input class="settings-item" type="text" data-key="editor-line-height" value="2">
+                                    <input class="settings-item" type="number" data-key="editor-line-height" value="2">
                                 </td>
                             </tr>
                             <tr>
@@ -170,10 +170,15 @@
                                 </td>
                             </tr>
                             <tr>
-                                <td width="30%" class="l10n">Hexo Config</td>
+                                <td width="30%" class="l10n">Hexo Mode</td>
                                 <td width="70%">
                                     <input type="checkbox" class="settings-item" data-key="hexo-config-enable">
-                                    <input type="text" class="settings-item" disabled="disabled"  data-key="hexo-config" style="width: calc(100% - 50px);">
+                                </td>
+                            </tr>
+                            <tr>
+                                <td width="30%" class="l10n">Hexo Config</td>
+                                <td width="70%">
+                                    <input type="text" class="settings-item" disabled="disabled"  data-key="hexo-config" style="width: calc(100% - 25px);">
                                     <div style="display: inline-block; margin-left: -1px; position: absolute; " id="hexo-config-btn">
                                         <button class="button-add-remove button-add" ><i class="fa fa-folder-o" aria-hidden="true"></i></button>
                                     </div>