diff --git a/.npmrc b/.npmrc deleted file mode 100644 index c5dcfc4..0000000 --- a/.npmrc +++ /dev/null @@ -1,6 +0,0 @@ -proxy=http://: -https-proxy=http://: -proxy=http://: -https-proxy=http://: -proxy=http://: -https-proxy=http://: diff --git a/index.html b/index.html index ff2932e..5265c31 100644 --- a/index.html +++ b/index.html @@ -12,15 +12,16 @@
-
- Write here -
+
Write here
diff --git a/index.js b/index.js index 2993b05..226b233 100644 --- a/index.js +++ b/index.js @@ -7,20 +7,59 @@ if (process.platform === 'darwin') { document.getElementById('') } -function saveFile(content) { - dialog.showSaveDialog((fileName) => { - if (fileName === undefined){ - console.log("You didn't save the file"); - return; - } +var current_file = ""; +function saveFile() { +let writable_content = document.getElementById('editor').innerHTML + .replace(/&/g, '&') + .replace(/</g, '<') + .replace(/>/g, '>') + .replace(/"/g, '"'); + if (current_file === "") { + dialog.showSaveDialog((fileName) => { + if (fileName === undefined){ + return; + } + + - // fileName is a string that contains the path and filename created in the save file dialog. - fs.writeFile(fileName, content, (err) => { + // fileName is a string that contains the path and filename created in the save file dialog. + fs.writeFile(fileName, writable_content, (err) => { + if (err) { + alert("An error occurred creating the file "+ err.message) + } + document.getElementsByTagName('title')[0].innerHTML = fileName; + document.getElementById('title').innerHTML = fileName; + current_file = fileName; + }); + }); + } + else { + fs.writeFile(current_file, writable_content, (err) => { if (err) { - alert("An error ocurred creating the file "+ err.message) + alert("An error occurred saving the file "+ err.message) } - document.getElementsByTagName('title')[0].innerHTML = fileName; - document.getElementById('title').innerHTML = fileName; }); -}); + } +} + +function openFile() { + dialog.showOpenDialog((filePaths) => { + if (filePaths === undefined) { + return; + } + + var filePath = filePaths[0]; + + fs.readFile(filePath, 'utf-8', (err, data) => { + if (err) alert('Error reading the file: ' + err); + document.getElementById('editor').innerHTML = data + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"'); + }); + document.getElementsByTagName('title')[0].innerHTML = filePath; + document.getElementById('title').innerHTML = filePath; + current_file = filePath; + }); } diff --git a/main.js b/main.js index 5071c77..939d02a 100644 --- a/main.js +++ b/main.js @@ -20,9 +20,7 @@ app.on('ready', () => { win = new BrowserWindow({ width: 800, height: 600, - - frame: 'false', - titleBarStyle: 'hiddenInset', + frame: false, show: false }) } diff --git a/style/main.scss b/style/main.scss index 632ac14..96bd821 100644 --- a/style/main.scss +++ b/style/main.scss @@ -6,7 +6,7 @@ body { font-family: $body-font; margin: 0; padding: none; - #electron-titlebar .title { + #electron-titlebar #title { color: $header-text-color; -webkit-app-region: drag; height: 70px; @@ -44,6 +44,7 @@ body { max-width: 800px; text-align: left; display: inline-block; + white-space: pre; } } .footer { @@ -59,6 +60,7 @@ body { color: $text-color; height: 20px; margin: 10px; + margin-right: 0px; } } }