@@ -4,12 +4,14 @@ import githubFs from './githubFs';
44
55const prompt = acode . require ( 'prompt' ) ;
66const confirm = acode . require ( 'confirm' ) ;
7- const palette = acode . require ( 'pallete' ) ;
7+ const palette = acode . require ( 'palette' ) || acode . require ( ' pallete') ;
88const helpers = acode . require ( 'helpers' ) ;
99const multiPrompt = acode . require ( 'multiPrompt' ) ;
1010const openFolder = acode . require ( 'openFolder' ) ;
1111const EditorFile = acode . require ( 'EditorFile' ) ;
1212const appSettings = acode . require ( 'settings' ) ;
13+ const toast = acode . require ( 'toast' ) ;
14+ const fsOperation = acode . require ( 'fsOperation' ) ;
1315
1416if ( ! 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+
511553if ( window . acode ) {
512554 const acodePlugin = new AcodePlugin ( ) ;
513555 acode . setPluginInit ( plugin . id , async ( baseUrl , $page , { cacheFileUrl, cacheFile } ) => {
0 commit comments