custom css inject and file saved state

This commit is contained in:
Jiiks 2019-02-25 17:56:56 +02:00
parent 1b6f3005f5
commit 109eb31aa5
3 changed files with 31 additions and 3 deletions

View File

@ -22,6 +22,20 @@ export default new class extends Module {
};
}
initialize() {
super.initialize();
(async () => {
try {
// TODO this is temporary
const userScss = await this.send('readDataFile', 'user.scss');
const compiled = await this.send('compileSass', { data: userScss });
this.injectStyle('customcss', compiled.css.toString());
} catch (err) {
console.warn('SCSS Compilation error', err);
}
})();
}
events(ipc) {
ipc.on('editor-runScript', (e, script) => {
try {
@ -33,11 +47,15 @@ export default new class extends Module {
});
ipc.on('editor-injectStyle', (e, { id, style }) => {
DOM.injectStyle(style, `userstyle-${id}`);
this.injectStyle(id, style);
e.reply('ok');
});
}
injectStyle(id, style) {
return DOM.injectStyle(style, `userstyle-${id}`);
}
/**
* Show editor, flashes if already visible.
*/

View File

@ -92,6 +92,11 @@ class Comms {
BDIpc.on('bd-keytar-set', (event, { service, account, password }) => keytar.setPassword(service, account, password), true);
BDIpc.on('bd-keytar-delete', (event, { service, account }) => keytar.deletePassword(service, account), true);
BDIpc.on('bd-keytar-find-credentials', (event, { service }) => keytar.findCredentials(service), true);
BDIpc.on('bd-readDataFile', async (event, fileName) => {
const rf = await FileUtils.readFile(path.resolve(configProxy().getPath('data'), fileName));
event.reply(rf);
});
}
async send(channel, message) {

View File

@ -123,8 +123,13 @@
},
async saveFile(file) {
const result = await ClientIPC.send('bd-editor-saveFile', file);
console.log(result);
try {
const result = await ClientIPC.send('bd-editor-saveFile', file);
file.savedContent = file.content;
file.saved = true;
} catch (err) {
console.log(err);
}
},
async saveSnippet(snippet) {