-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from JonasSchatz/quick-inserts
Quick Inserts
- Loading branch information
Showing
25 changed files
with
140 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import * as vscode from 'vscode'; | ||
|
||
import { NoteGraph } from "../core"; | ||
import { insertTextInCurrentNote } from '../vscode/note-actions'; | ||
|
||
import { Feature } from "./feature"; | ||
|
||
|
||
const snippets = [ | ||
{ | ||
label: 'HTML Snippets', | ||
content: [ | ||
{ | ||
label: 'Two-column HTML table', | ||
content: "<table><tr><td>\n\n\n</td><td>\n\n\n</td></tr></table>" | ||
}, { | ||
label: 'Two-column HTML row', | ||
content: "</td></tr><tr><td>\n\n\n</td><td>\n\n" | ||
} | ||
] | ||
}, { | ||
label: 'Emojis', | ||
content: [ | ||
{ | ||
label: 'Rejection', | ||
content: '❌' | ||
}, { | ||
label: 'Waiting', | ||
content: '🕒' | ||
}, { | ||
label: 'Checkmark', | ||
content: '✔️' | ||
} | ||
] | ||
} | ||
]; | ||
|
||
const feature: Feature = { | ||
activate: (context: vscode.ExtensionContext, graph: NoteGraph) => { | ||
context.subscriptions.push( | ||
vscode.commands.registerCommand( | ||
'codekasten.insert-snippet', | ||
async () => { | ||
|
||
let options = snippets; | ||
while (true) { | ||
const quickPickItems: vscode.QuickPickItem[] = options.map( optionElement => { | ||
if (typeof optionElement.content === 'string') { | ||
return {label: optionElement.label, description: optionElement.content}; | ||
} else { | ||
return {label: optionElement.label}; | ||
} | ||
}); | ||
const selectedItem: vscode.QuickPickItem = await vscode.window.showQuickPick(quickPickItems, {placeHolder: "Choose Snippet/Category..."}); | ||
const selectedItemContent: string | any[] = options.filter(x => x.label === selectedItem.label)[0].content; | ||
|
||
if (typeof selectedItemContent === 'string') { | ||
insertTextInCurrentNote(selectedItemContent); | ||
break; | ||
} else { | ||
options = selectedItemContent; | ||
} | ||
} | ||
} | ||
) | ||
); | ||
} | ||
}; | ||
|
||
export default feature; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.