From dd9ec12b36140ecf66d78c14cba62c4809d7b00d Mon Sep 17 00:00:00 2001 From: Jiiks Date: Mon, 22 Jan 2018 13:10:09 +0200 Subject: [PATCH] Implement all functionality that master has --- csseditor/src/Editor.vue | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/csseditor/src/Editor.vue b/csseditor/src/Editor.vue index 9c120493..7d675b18 100644 --- a/csseditor/src/Editor.vue +++ b/csseditor/src/Editor.vue @@ -8,7 +8,7 @@
CSS Editor
- +
@@ -28,7 +28,7 @@
- Live Update + Live Update
@@ -45,6 +45,12 @@ import '../../node_modules/codemirror/addon/dialog/dialog.js'; import '../../node_modules/codemirror/addon/hint/show-hint.js'; + const { remote } = window.require('electron'); + const { BDIpc } = require('./bdipc'); + function sendToDiscord(channel, message) { + BDIpc.send('bd-sendToDiscord', { channel, message }); + } + const ExcludedIntelliSenseTriggerKeys = { '8': 'backspace', '9': 'tab', @@ -103,7 +109,8 @@ } function toggleaot() { - console.log(VueCodemirror); + this.alwaysOnTop = !this.alwaysOnTop; + remote.getCurrentWindow().setAlwaysOnTop(this.alwaysOnTop); } function close() { @@ -112,10 +119,11 @@ function setCss(css) { this.loading = false; - this.codemirror.setValue("body { background: red; }"); + this.codemirror.setValue(css); } function cmOnChange(value) { + if(this.liveUpdate) sendToDiscord('update-css', value); } function cmOnKeyUp(editor, event) { @@ -124,7 +132,11 @@ cmCommands.autocomplete(editor, null, { completeSingle: false }); } - const methods = { save, toggleaot, close, setCss, cmOnChange, cmOnKeyUp }; + function toggleLiveUpdate(e) { + this.liveUpdate = !this.liveUpdate; + } + + const methods = { save, toggleaot, close, setCss, cmOnChange, cmOnKeyUp, toggleLiveUpdate }; export default { methods, @@ -132,13 +144,21 @@ return { loading: true, codeMirror: null, + alwaysOnTop: false, + liveUpdate: false, cmOptions: { indentUnit: 4, tabSize: 4, mode: 'css', lineNumbers: true, theme: 'material', - scrollbarStyle: 'overlay' + scrollbarStyle: 'overlay', + extraKeys: { + 'Ctrl-Space': 'autocomplete' + }, + dialog: { + 'position': 'bottom' + } } } }, @@ -153,7 +173,7 @@ mounted: function () { this.codemirror.on('keyup', this.cmOnKeyUp); this.setCss(); - /* BDIpc.on('set-css', (_, data) => { + BDIpc.on('set-css', (_, data) => { if (data.error) { console.log(data.error); return; @@ -161,7 +181,7 @@ this.setCss(data.css); }); - BDIpc.send('get-css');*/ + BDIpc.send('get-css'); } }