52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
/**
|
|
* BetterDiscord CSSEditor Module
|
|
* Copyright (c) 2015-present JsSucks - https://github.com/JsSucks
|
|
* All rights reserved.
|
|
* https://github.com/JsSucks - https://betterdiscord.net
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
const path = require('path');
|
|
const { BrowserWindow } = require('electron');
|
|
|
|
const { Module } = require('./modulebase');
|
|
|
|
class CSSEditor extends Module {
|
|
|
|
openEditor() {
|
|
if (this.editor && this.editor.open) {
|
|
this.editor.focus();
|
|
this.editor.flashFrame(true);
|
|
return true;
|
|
}
|
|
|
|
this.editor = new BrowserWindow(this.options);
|
|
this.editor.loadURL(`file://${this.editorPath}/index.html`);
|
|
this.editor.open = true;
|
|
|
|
this.editor.webContents.on('close', () => {
|
|
this.editor.open = false;
|
|
});
|
|
|
|
return true;
|
|
}
|
|
|
|
//TODO user options from config
|
|
get options() {
|
|
return {
|
|
width: 800,
|
|
height: 600,
|
|
frame: false
|
|
};
|
|
}
|
|
|
|
//TODO Currently uses a development path
|
|
get editorPath() {
|
|
return path.resolve(__dirname, '..', '..', '..', 'tests', 'csseditor');
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = { 'CSSEditor': new CSSEditor() }; |