Obsidian Execute Code 插件使用教程

Obsidian Execute Code 插件使用教程

obsidian-execute-codeObsidian Plugin to execute code in a note.项目地址:https://gitcode.com/gh_mirrors/ob/obsidian-execute-code

项目的目录结构及介绍

Obsidian Execute Code 插件的目录结构相对简单,主要包含以下几个部分:

obsidian-execute-code/
├── main.ts
├── manifest.json
├── styles.css
└── README.md
  • main.ts: 这是插件的主文件,包含了插件的核心逻辑。
  • manifest.json: 这是插件的清单文件,包含了插件的元数据,如名称、版本、作者等信息。
  • styles.css: 这是插件的样式文件,定义了插件的外观和样式。
  • README.md: 这是项目的说明文档,包含了插件的介绍、安装方法、使用说明等。

项目的启动文件介绍

插件的启动文件是 main.ts,它负责初始化插件并注册各种事件处理程序。以下是 main.ts 文件的主要内容:

import { Plugin } from 'obsidian';
import { ExecuteCodeSettings, ExecuteCodeSettingTab, DEFAULT_SETTINGS } from './settings';

export default class ExecuteCodePlugin extends Plugin {
    settings: ExecuteCodeSettings;

    async onload() {
        await this.loadSettings();

        this.addCommand({
            id: 'execute-code-block',
            name: 'Execute Code Block',
            callback: () => {
                this.executeCodeBlock();
            }
        });

        this.addSettingTab(new ExecuteCodeSettingTab(this.app, this));
    }

    async loadSettings() {
        this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
    }

    async saveSettings() {
        await this.saveData(this.settings);
    }

    executeCodeBlock() {
        // 执行代码块的逻辑
    }
}
  • onload(): 插件加载时调用的方法,负责注册命令和设置选项卡。
  • loadSettings(): 加载插件的配置。
  • saveSettings(): 保存插件的配置。
  • executeCodeBlock(): 执行代码块的逻辑。

项目的配置文件介绍

插件的配置文件是 manifest.json,它包含了插件的基本信息和依赖项。以下是 manifest.json 文件的内容:

{
  "id": "execute-code",
  "name": "Execute Code",
  "version": "1.0.0",
  "minAppVersion": "0.12.0",
  "description": "This plugin allows you to execute code blocks in your notes.",
  "author": "twibiral",
  "authorUrl": "https://github.com/twibiral",
  "isDesktopOnly": false
}
  • id: 插件的唯一标识符。
  • name: 插件的名称。
  • version: 插件的版本号。
  • minAppVersion: 插件支持的最低 Obsidian 版本。
  • description: 插件的描述。
  • author: 插件的作者。
  • authorUrl: 作者的网址。
  • isDesktopOnly: 是否仅支持桌面版 Obsidian。

以上是 Obsidian Execute Code 插件的基本介绍和使用教程,希望对你有所帮助。

obsidian-execute-codeObsidian Plugin to execute code in a note.项目地址:https://gitcode.com/gh_mirrors/ob/obsidian-execute-code

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

霍日江Eagle-Eyed

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值