reveal, copy and copypath handlers
This commit is contained in:
parent
b1e8b591ba
commit
99ec82795c
|
@ -30,7 +30,7 @@ const TEST_EDITOR = true;
|
|||
|
||||
import path from 'path';
|
||||
import sass from 'node-sass';
|
||||
import { BrowserWindow as OriginalBrowserWindow, dialog, session } from 'electron';
|
||||
import { BrowserWindow as OriginalBrowserWindow, dialog, session, shell } from 'electron';
|
||||
import deepmerge from 'deepmerge';
|
||||
import ContentSecurityPolicy from 'csp-parse';
|
||||
import keytar from 'keytar';
|
||||
|
@ -97,6 +97,21 @@ class Comms {
|
|||
const rf = await FileUtils.readFile(path.resolve(configProxy().getPath('data'), fileName));
|
||||
event.reply(rf);
|
||||
});
|
||||
|
||||
BDIpc.on('bd-explorer', (_, _path) => {
|
||||
if (_path.static) _path = this.bd.config.getPath(_path.static);
|
||||
else if (_path.full) _path = _path.full;
|
||||
else if (_path.sub) _path = path.resolve(this.bd.config.getPath(_path.sub.base), [..._path.sub.subs]);
|
||||
try {
|
||||
shell.openItem(_path);
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
}
|
||||
});
|
||||
|
||||
BDIpc.on('bd-getPath', (event, paths) => {
|
||||
event.reply(path.resolve(this.bd.config.getPath(paths[0]), ...paths.splice(1)));
|
||||
});
|
||||
}
|
||||
|
||||
async send(channel, message) {
|
||||
|
|
|
@ -12,10 +12,8 @@
|
|||
<button title="Close CSS Editor" @click="close">X</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="spinner" v-if="loading">
|
||||
<div class="valign">Loading Please Wait...</div>
|
||||
</div>
|
||||
<BDEdit v-else :files="files"
|
||||
<BDEdit :files="files"
|
||||
:parentLoading="loading"
|
||||
:snippets="snippets"
|
||||
:updateContent="updateContent"
|
||||
:runScript="runScript"
|
||||
|
@ -26,17 +24,18 @@
|
|||
:readFile="readFile"
|
||||
:readSnippet="readSnippet"
|
||||
:injectStyle="injectStyle"
|
||||
:toggleLiveUpdate="toggleLiveUpdate"/>
|
||||
:toggleLiveUpdate="toggleLiveUpdate"
|
||||
:ctxAction="ctxAction"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import { ClientIPC } from 'common';
|
||||
import { remote } from 'electron';
|
||||
|
||||
import { BDEdit } from 'bdedit';
|
||||
import { FileUtils } from '../../core/src/modules/utils';
|
||||
import { FileUtils } from '../../core/src/modules/utils';
|
||||
import { setTimeout } from 'timers';
|
||||
ace.acequire = ace.require;
|
||||
|
||||
const modes = {
|
||||
|
@ -95,12 +94,10 @@ import { FileUtils } from '../../core/src/modules/utils';
|
|||
if (f) f.changed = true;
|
||||
});
|
||||
},
|
||||
mounted() {
|
||||
(async () => {
|
||||
this.files = await ClientIPC.send('bd-editor-getFiles');
|
||||
this.snippets = await ClientIPC.send('bd-editor-getSnippets');
|
||||
this.loading = false;
|
||||
})();
|
||||
async mounted() {
|
||||
this.files = await ClientIPC.send('bd-editor-getFiles');
|
||||
this.snippets = await ClientIPC.send('bd-editor-getSnippets');
|
||||
this.loading = false;
|
||||
},
|
||||
methods: {
|
||||
addFile(file) {
|
||||
|
@ -201,6 +198,24 @@ import { FileUtils } from '../../core/src/modules/utils';
|
|||
return result;
|
||||
},
|
||||
|
||||
async ctxAction(action, item) {
|
||||
if (action === 'reveal') {
|
||||
ClientIPC.send('explorer', { 'static': 'userfiles' });
|
||||
return;
|
||||
}
|
||||
|
||||
if (action === 'copy') {
|
||||
remote.clipboard.writeText(item.content);
|
||||
return;
|
||||
}
|
||||
|
||||
if (action === 'copyPath') {
|
||||
const fullPath = await ClientIPC.send('getPath', ['userfiles', item.name]);
|
||||
remote.clipboard.writeText(fullPath);
|
||||
return;
|
||||
}
|
||||
},
|
||||
|
||||
toggleLiveUpdate(item) {
|
||||
item.liveUpdateEnabled = !item.liveUpdateEnabled;
|
||||
return item;
|
||||
|
|
Loading…
Reference in New Issue