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 path from 'path';
|
||||||
import sass from 'node-sass';
|
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 deepmerge from 'deepmerge';
|
||||||
import ContentSecurityPolicy from 'csp-parse';
|
import ContentSecurityPolicy from 'csp-parse';
|
||||||
import keytar from 'keytar';
|
import keytar from 'keytar';
|
||||||
|
@ -97,6 +97,21 @@ class Comms {
|
||||||
const rf = await FileUtils.readFile(path.resolve(configProxy().getPath('data'), fileName));
|
const rf = await FileUtils.readFile(path.resolve(configProxy().getPath('data'), fileName));
|
||||||
event.reply(rf);
|
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) {
|
async send(channel, message) {
|
||||||
|
|
|
@ -12,10 +12,8 @@
|
||||||
<button title="Close CSS Editor" @click="close">X</button>
|
<button title="Close CSS Editor" @click="close">X</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="spinner" v-if="loading">
|
<BDEdit :files="files"
|
||||||
<div class="valign">Loading Please Wait...</div>
|
:parentLoading="loading"
|
||||||
</div>
|
|
||||||
<BDEdit v-else :files="files"
|
|
||||||
:snippets="snippets"
|
:snippets="snippets"
|
||||||
:updateContent="updateContent"
|
:updateContent="updateContent"
|
||||||
:runScript="runScript"
|
:runScript="runScript"
|
||||||
|
@ -26,17 +24,18 @@
|
||||||
:readFile="readFile"
|
:readFile="readFile"
|
||||||
:readSnippet="readSnippet"
|
:readSnippet="readSnippet"
|
||||||
:injectStyle="injectStyle"
|
:injectStyle="injectStyle"
|
||||||
:toggleLiveUpdate="toggleLiveUpdate"/>
|
:toggleLiveUpdate="toggleLiveUpdate"
|
||||||
|
:ctxAction="ctxAction"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import { ClientIPC } from 'common';
|
import { ClientIPC } from 'common';
|
||||||
import { remote } from 'electron';
|
import { remote } from 'electron';
|
||||||
|
|
||||||
import { BDEdit } from 'bdedit';
|
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;
|
ace.acequire = ace.require;
|
||||||
|
|
||||||
const modes = {
|
const modes = {
|
||||||
|
@ -95,12 +94,10 @@ import { FileUtils } from '../../core/src/modules/utils';
|
||||||
if (f) f.changed = true;
|
if (f) f.changed = true;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
mounted() {
|
async mounted() {
|
||||||
(async () => {
|
this.files = await ClientIPC.send('bd-editor-getFiles');
|
||||||
this.files = await ClientIPC.send('bd-editor-getFiles');
|
this.snippets = await ClientIPC.send('bd-editor-getSnippets');
|
||||||
this.snippets = await ClientIPC.send('bd-editor-getSnippets');
|
this.loading = false;
|
||||||
this.loading = false;
|
|
||||||
})();
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
addFile(file) {
|
addFile(file) {
|
||||||
|
@ -201,6 +198,24 @@ import { FileUtils } from '../../core/src/modules/utils';
|
||||||
return result;
|
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) {
|
toggleLiveUpdate(item) {
|
||||||
item.liveUpdateEnabled = !item.liveUpdateEnabled;
|
item.liveUpdateEnabled = !item.liveUpdateEnabled;
|
||||||
return item;
|
return item;
|
||||||
|
|
Loading…
Reference in New Issue