Skip to content

Commit 2b161d3

Browse files
committed
Updated to support latest acode
1 parent 85f6222 commit 2b161d3

4 files changed

Lines changed: 55 additions & 3482 deletions

File tree

.vscode/settings.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,14 @@
44
"cSpell.words": [
55
"acode",
66
"Ajit",
7+
"clearcache",
78
"deadlyjack",
8-
"Kumar"
9+
"deletegist",
10+
"deletegistfile",
11+
"Kumar",
12+
"opengist",
13+
"pallete",
14+
"selectrepo",
15+
"updatetoken"
916
],
1017
}

plugin.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id": "acode.plugin.github",
33
"name": "Github",
44
"main": "dist/main.js",
5-
"version": "1.1.6",
5+
"version": "1.1.7",
66
"readme": "readme.md",
77
"icon": "icon.png",
88
"files": [],

src/main.js

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@ import githubFs from './githubFs';
44

55
const prompt = acode.require('prompt');
66
const confirm = acode.require('confirm');
7-
const palette = acode.require('pallete');
7+
const palette = acode.require('palette') || acode.require('pallete');
88
const helpers = acode.require('helpers');
99
const multiPrompt = acode.require('multiPrompt');
1010
const openFolder = acode.require('openFolder');
1111
const EditorFile = acode.require('EditorFile');
1212
const appSettings = acode.require('settings');
13+
const toast = acode.require('toast');
14+
const fsOperation = acode.require('fsOperation');
1315

1416
if (!Blob.prototype.arrayBuffer) {
1517
Blob.prototype.arrayBuffer = function () {
@@ -36,6 +38,28 @@ class AcodePlugin {
3638

3739
this.token = localStorage.getItem('github-token');
3840
await this.initFs();
41+
42+
tutorial(plugin.id, (hide) => {
43+
const commands = editorManager.editor.commands.byName;
44+
const openCommandPalette = commands.openCommandPalette || commands.openCommandPallete;
45+
const message = "Github plugin is installed successfully, open command palette and search 'open repository' to open a github repository.";
46+
let key = 'Ctrl+Shift+P';
47+
if (openCommandPalette) {
48+
key = openCommandPalette.bindKey.win;
49+
}
50+
51+
if (!key) {
52+
const onclick = async () => {
53+
const EditorFile = acode.require('EditorFile');
54+
const fileInfo = await fsOperation(KEYBINDING_FILE).stat();
55+
new EditorFile(fileInfo.name, { uri: KEYBINDING_FILE, render: true });
56+
hide();
57+
};
58+
return <p>{message} Shortcut to open command pallete is not set, <span className='link' onclick={onclick}>Click here</span> set shortcut or use '...' icon in quick tools.</p>
59+
}
60+
61+
return <p>{message} To open command palette use combination {key} or use '...' icon in quick tools.</p>;
62+
});
3963
}
4064

4165
async initFs() {
@@ -373,7 +397,7 @@ class AcodePlugin {
373397

374398
if (showAddNew) {
375399
list.push({
376-
text: this.#highlitedText('New gist'),
400+
text: this.#highlightedText('New gist'),
377401
value: this.NEW,
378402
});
379403
}
@@ -405,15 +429,15 @@ class AcodePlugin {
405429

406430
if (showAddNew) {
407431
list.push({
408-
text: this.#highlitedText('New file'),
432+
text: this.#highlightedText('New file'),
409433
value: this.NEW,
410434
});
411435
}
412436

413437
return list;
414438
}
415439

416-
#highlitedText(text) {
440+
#highlightedText(text) {
417441
return `<span style='text-transform: uppercase; color: var(--popup-active-color)'>${text}</span>`;
418442
}
419443

@@ -508,6 +532,24 @@ class AcodePlugin {
508532
}
509533
}
510534

535+
/**
536+
* Create a toast message
537+
* @param {string} id
538+
* @param {string|HTMLElement|(hide: ()=>void)=>HTMLElement} message
539+
* @returns
540+
*/
541+
function tutorial(id, message) {
542+
if (!toast) return;
543+
if (localStorage.getItem(id) === 'true') return;
544+
localStorage.setItem(id, 'true');
545+
546+
if (typeof message === 'function') {
547+
message = message(toast.hide);
548+
}
549+
550+
toast(message, false, '#17c', '#fff');
551+
}
552+
511553
if (window.acode) {
512554
const acodePlugin = new AcodePlugin();
513555
acode.setPluginInit(plugin.id, async (baseUrl, $page, { cacheFileUrl, cacheFile }) => {

0 commit comments

Comments
 (0)