mirror of
https://github.com/ytliu74/obsidian-pseudocode.git
synced 2026-07-22 07:40:25 +00:00
feat: Add new command to auto-gen pseudocode block.
This commit is contained in:
parent
244a53a0c0
commit
6f1ddb618c
2 changed files with 13 additions and 5 deletions
16
main.ts
16
main.ts
|
|
@ -5,6 +5,7 @@ import {
|
|||
EditorSuggest,
|
||||
EditorSuggestContext,
|
||||
EditorSuggestTriggerInfo,
|
||||
MarkdownView,
|
||||
Plugin,
|
||||
PluginSettingTab,
|
||||
Setting,
|
||||
|
|
@ -31,6 +32,9 @@ const DEFAULT_SETTINGS: PseudocodeSettings = {
|
|||
captionCount: undefined,
|
||||
};
|
||||
|
||||
const PseudocodeBlockInit =
|
||||
"```pseudo\n\t\\begin{algorithm}\n\t\\caption{Algo Caption}\n\t\\begin{algorithmic}\n\n\t\\end{algorithmic}\n\t\\end{algorithm} \n```";
|
||||
|
||||
const BLOCK_NAME = "pseudo";
|
||||
|
||||
export default class PseudocodePlugin extends Plugin {
|
||||
|
|
@ -60,10 +64,14 @@ export default class PseudocodePlugin extends Plugin {
|
|||
// This adds a settings tab so the user can configure various aspects of the plugin
|
||||
this.addSettingTab(new PseudocodeSettingTab(this.app, this));
|
||||
|
||||
// When registering intervals, this function will automatically clear the interval when the plugin is disabled.
|
||||
// this.registerInterval(
|
||||
// window.setInterval(() => console.log("setInterval"), 5 * 60 * 1000)
|
||||
// );
|
||||
// Auto-gen pseudocode block command.
|
||||
this.addCommand({
|
||||
id: "pseudocode-in-obs",
|
||||
name: "Insert a new pseudocode block",
|
||||
editorCallback: (editor: Editor, view: MarkdownView) => {
|
||||
editor.replaceSelection(PseudocodeBlockInit);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
onunload() {}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"name": "pseudocode-obsidian",
|
||||
"name": "pseudocode-in-obs",
|
||||
"version": "1.1.3",
|
||||
"description": "This is an obsidian plugin that helps to render a LaTeX-style pseudocode inside a code block.",
|
||||
"main": "main.js",
|
||||
|
|
|
|||
Loading…
Reference in a new issue