mirror of
https://github.com/yildbs/obsidian-harada-method-plugin.git
synced 2026-07-22 07:40:28 +00:00
update
This commit is contained in:
parent
c6e5d2265f
commit
d1430635d9
11 changed files with 2529 additions and 235 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -20,3 +20,5 @@ data.json
|
|||
|
||||
# Exclude macOS Finder (System Explorer) View States
|
||||
.DS_Store
|
||||
|
||||
copy.sh
|
||||
|
|
|
|||
117
README.md
117
README.md
|
|
@ -1,96 +1,35 @@
|
|||
# Obsidian Sample Plugin
|
||||
# Obsidian Harada Method Plugin
|
||||
This plugin is a tool to visualize The Harada Method famously used by Shohei Otani, a Japanese baseball player. The Harada Method has various names such as Mandara chart, Mandal-art, and Open window 64 chart. Anyway, the key point of The Harada Method is that it helps you set goals, break them down, and achieve them.
|
||||
|
||||
This is a sample plugin for Obsidian (https://obsidian.md).
|
||||
# Installation
|
||||
Install from the Community Plugin list by searching "harada method"
|
||||
|
||||
This project uses Typescript to provide type checking and documentation.
|
||||
The repo depends on the latest plugin API (obsidian.d.ts) in Typescript Definition format, which contains TSDoc comments describing what it does.
|
||||
# Usage
|
||||
- Open code block with name "harada"
|
||||
- Plan your goal and actions
|
||||
- Use two-space indentation
|
||||
|
||||
**Note:** The Obsidian API is still in early alpha and is subject to change at any time!
|
||||
~~~
|
||||
```harada
|
||||
Main goal
|
||||
Key plan 1
|
||||
Action 1
|
||||
Action 2
|
||||
Action 3
|
||||
...
|
||||
Key plan 2
|
||||
Action 1
|
||||
Action 2
|
||||
Action 3
|
||||
...
|
||||
```
|
||||
~~~
|
||||
|
||||
This sample plugin demonstrates some of the basic functionality the plugin API can do.
|
||||
- Changes the default font color to red using `styles.css`.
|
||||
- Adds a ribbon icon, which shows a Notice when clicked.
|
||||
- Adds a command "Open Sample Modal" which opens a Modal.
|
||||
- Adds a plugin setting tab to the settings page.
|
||||
- Registers a global click event and output 'click' to the console.
|
||||
- Registers a global interval which logs 'setInterval' to the console.
|
||||

|
||||
|
||||
## First time developing plugins?
|
||||
|
||||
Quick starting guide for new plugin devs:
|
||||
# TODO
|
||||
- Handling text that does not conform to the rules
|
||||
- Supports various indentation characters
|
||||
- Option related
|
||||
|
||||
- Check if [someone already developed a plugin for what you want](https://obsidian.md/plugins)! There might be an existing plugin similar enough that you can partner up with.
|
||||
- Make a copy of this repo as a template with the "Use this template" button (login to GitHub if you don't see it).
|
||||
- Clone your repo to a local development folder. For convenience, you can place this folder in your `.obsidian/plugins/your-plugin-name` folder.
|
||||
- Install NodeJS, then run `npm i` in the command line under your repo folder.
|
||||
- Run `npm run dev` to compile your plugin from `main.ts` to `main.js`.
|
||||
- Make changes to `main.ts` (or create new `.ts` files). Those changes should be automatically compiled into `main.js`.
|
||||
- Reload Obsidian to load the new version of your plugin.
|
||||
- Enable plugin in settings window.
|
||||
- For updates to the Obsidian API run `npm update` in the command line under your repo folder.
|
||||
|
||||
## Releasing new releases
|
||||
|
||||
- Update your `manifest.json` with your new version number, such as `1.0.1`, and the minimum Obsidian version required for your latest release.
|
||||
- Update your `versions.json` file with `"new-plugin-version": "minimum-obsidian-version"` so older versions of Obsidian can download an older version of your plugin that's compatible.
|
||||
- Create new GitHub release using your new version number as the "Tag version". Use the exact version number, don't include a prefix `v`. See here for an example: https://github.com/obsidianmd/obsidian-sample-plugin/releases
|
||||
- Upload the files `manifest.json`, `main.js`, `styles.css` as binary attachments. Note: The manifest.json file must be in two places, first the root path of your repository and also in the release.
|
||||
- Publish the release.
|
||||
|
||||
> You can simplify the version bump process by running `npm version patch`, `npm version minor` or `npm version major` after updating `minAppVersion` manually in `manifest.json`.
|
||||
> The command will bump version in `manifest.json` and `package.json`, and add the entry for the new version to `versions.json`
|
||||
|
||||
## Adding your plugin to the community plugin list
|
||||
|
||||
- Check https://github.com/obsidianmd/obsidian-releases/blob/master/plugin-review.md
|
||||
- Publish an initial version.
|
||||
- Make sure you have a `README.md` file in the root of your repo.
|
||||
- Make a pull request at https://github.com/obsidianmd/obsidian-releases to add your plugin.
|
||||
|
||||
## How to use
|
||||
|
||||
- Clone this repo.
|
||||
- `npm i` or `yarn` to install dependencies
|
||||
- `npm run dev` to start compilation in watch mode.
|
||||
|
||||
## Manually installing the plugin
|
||||
|
||||
- Copy over `main.js`, `styles.css`, `manifest.json` to your vault `VaultFolder/.obsidian/plugins/your-plugin-id/`.
|
||||
|
||||
## Improve code quality with eslint (optional)
|
||||
- [ESLint](https://eslint.org/) is a tool that analyzes your code to quickly find problems. You can run ESLint against your plugin to find common bugs and ways to improve your code.
|
||||
- To use eslint with this project, make sure to install eslint from terminal:
|
||||
- `npm install -g eslint`
|
||||
- To use eslint to analyze this project use this command:
|
||||
- `eslint main.ts`
|
||||
- eslint will then create a report with suggestions for code improvement by file and line number.
|
||||
- If your source code is in a folder, such as `src`, you can use eslint with this command to analyze all files in that folder:
|
||||
- `eslint .\src\`
|
||||
|
||||
## Funding URL
|
||||
|
||||
You can include funding URLs where people who use your plugin can financially support it.
|
||||
|
||||
The simple way is to set the `fundingUrl` field to your link in your `manifest.json` file:
|
||||
|
||||
```json
|
||||
{
|
||||
"fundingUrl": "https://buymeacoffee.com"
|
||||
}
|
||||
```
|
||||
|
||||
If you have multiple URLs, you can also do:
|
||||
|
||||
```json
|
||||
{
|
||||
"fundingUrl": {
|
||||
"Buy Me a Coffee": "https://buymeacoffee.com",
|
||||
"GitHub Sponsor": "https://github.com/sponsors",
|
||||
"Patreon": "https://www.patreon.com/"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## API Documentation
|
||||
|
||||
See https://github.com/obsidianmd/obsidian-api
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ const context = await esbuild.context({
|
|||
banner: {
|
||||
js: banner,
|
||||
},
|
||||
entryPoints: ["main.ts"],
|
||||
entryPoints: ["src/main.ts"],
|
||||
bundle: true,
|
||||
external: [
|
||||
"obsidian",
|
||||
|
|
|
|||
BIN
example.gif
Normal file
BIN
example.gif
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.8 MiB |
137
main.ts
137
main.ts
|
|
@ -1,137 +0,0 @@
|
|||
import { App, Editor, MarkdownView, Modal, Notice, Plugin, PluginSettingTab, Setting } from 'obsidian';
|
||||
|
||||
// Remember to rename these classes and interfaces!
|
||||
|
||||
interface MyPluginSettings {
|
||||
mySetting: string;
|
||||
}
|
||||
|
||||
const DEFAULT_SETTINGS: MyPluginSettings = {
|
||||
mySetting: 'default'
|
||||
}
|
||||
|
||||
export default class MyPlugin extends Plugin {
|
||||
settings: MyPluginSettings;
|
||||
|
||||
async onload() {
|
||||
await this.loadSettings();
|
||||
|
||||
// This creates an icon in the left ribbon.
|
||||
const ribbonIconEl = this.addRibbonIcon('dice', 'Sample Plugin', (evt: MouseEvent) => {
|
||||
// Called when the user clicks the icon.
|
||||
new Notice('This is a notice!');
|
||||
});
|
||||
// Perform additional things with the ribbon
|
||||
ribbonIconEl.addClass('my-plugin-ribbon-class');
|
||||
|
||||
// This adds a status bar item to the bottom of the app. Does not work on mobile apps.
|
||||
const statusBarItemEl = this.addStatusBarItem();
|
||||
statusBarItemEl.setText('Status Bar Text');
|
||||
|
||||
// This adds a simple command that can be triggered anywhere
|
||||
this.addCommand({
|
||||
id: 'open-sample-modal-simple',
|
||||
name: 'Open sample modal (simple)',
|
||||
callback: () => {
|
||||
new SampleModal(this.app).open();
|
||||
}
|
||||
});
|
||||
// This adds an editor command that can perform some operation on the current editor instance
|
||||
this.addCommand({
|
||||
id: 'sample-editor-command',
|
||||
name: 'Sample editor command',
|
||||
editorCallback: (editor: Editor, view: MarkdownView) => {
|
||||
console.log(editor.getSelection());
|
||||
editor.replaceSelection('Sample Editor Command');
|
||||
}
|
||||
});
|
||||
// This adds a complex command that can check whether the current state of the app allows execution of the command
|
||||
this.addCommand({
|
||||
id: 'open-sample-modal-complex',
|
||||
name: 'Open sample modal (complex)',
|
||||
checkCallback: (checking: boolean) => {
|
||||
// Conditions to check
|
||||
const markdownView = this.app.workspace.getActiveViewOfType(MarkdownView);
|
||||
if (markdownView) {
|
||||
// If checking is true, we're simply "checking" if the command can be run.
|
||||
// If checking is false, then we want to actually perform the operation.
|
||||
if (!checking) {
|
||||
new SampleModal(this.app).open();
|
||||
}
|
||||
|
||||
// This command will only show up in Command Palette when the check function returns true
|
||||
return true;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// This adds a settings tab so the user can configure various aspects of the plugin
|
||||
this.addSettingTab(new SampleSettingTab(this.app, this));
|
||||
|
||||
// If the plugin hooks up any global DOM events (on parts of the app that doesn't belong to this plugin)
|
||||
// Using this function will automatically remove the event listener when this plugin is disabled.
|
||||
this.registerDomEvent(document, 'click', (evt: MouseEvent) => {
|
||||
console.log('click', evt);
|
||||
});
|
||||
|
||||
// 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));
|
||||
}
|
||||
|
||||
onunload() {
|
||||
|
||||
}
|
||||
|
||||
async loadSettings() {
|
||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
|
||||
}
|
||||
|
||||
async saveSettings() {
|
||||
await this.saveData(this.settings);
|
||||
}
|
||||
}
|
||||
|
||||
class SampleModal extends Modal {
|
||||
constructor(app: App) {
|
||||
super(app);
|
||||
}
|
||||
|
||||
onOpen() {
|
||||
const {contentEl} = this;
|
||||
contentEl.setText('Woah!');
|
||||
}
|
||||
|
||||
onClose() {
|
||||
const {contentEl} = this;
|
||||
contentEl.empty();
|
||||
}
|
||||
}
|
||||
|
||||
class SampleSettingTab extends PluginSettingTab {
|
||||
plugin: MyPlugin;
|
||||
|
||||
constructor(app: App, plugin: MyPlugin) {
|
||||
super(app, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
display(): void {
|
||||
const {containerEl} = this;
|
||||
|
||||
containerEl.empty();
|
||||
|
||||
containerEl.createEl('h2', {text: 'Settings for my awesome plugin.'});
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Setting #1')
|
||||
.setDesc('It\'s a secret')
|
||||
.addText(text => text
|
||||
.setPlaceholder('Enter your secret')
|
||||
.setValue(this.plugin.settings.mySetting)
|
||||
.onChange(async (value) => {
|
||||
console.log('Secret: ' + value);
|
||||
this.plugin.settings.mySetting = value;
|
||||
await this.plugin.saveSettings();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
{
|
||||
"id": "obsidian-sample-plugin",
|
||||
"name": "Sample Plugin",
|
||||
"id": "obsidian-harada-method-plugin",
|
||||
"name": "Obsidian Harada Method Plugin",
|
||||
"version": "1.0.0",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "This is a sample plugin for Obsidian. This plugin demonstrates some of the capabilities of the Obsidian API.",
|
||||
"author": "Obsidian",
|
||||
"authorUrl": "https://obsidian.md",
|
||||
"fundingUrl": "https://obsidian.md/pricing",
|
||||
"description": "This plugin is used to visualize the harada method. Create your own 1 goal, 8 plans, and 64 actions",
|
||||
"author": "yildbs",
|
||||
"authorUrl": "https://github.com/yildbs",
|
||||
"fundingUrl": "https://paypal.me/yildbs?country.x=KR&locale.x=ko_KR",
|
||||
"isDesktopOnly": false
|
||||
}
|
||||
|
|
|
|||
2214
package-lock.json
generated
Normal file
2214
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "obsidian-sample-plugin",
|
||||
"name": "obsidian-harada-method-plugin",
|
||||
"version": "1.0.0",
|
||||
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
|
||||
"description": "This plugin is used to visualize the harada method. Create your own 1 goal, 8 plans, and 64 actions",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
"dev": "node esbuild.config.mjs",
|
||||
|
|
|
|||
146
src/harada.ts
Normal file
146
src/harada.ts
Normal file
|
|
@ -0,0 +1,146 @@
|
|||
import { MarkdownRenderChild } from "obsidian";
|
||||
|
||||
export class HaradaMethod extends MarkdownRenderChild {
|
||||
text: string;
|
||||
|
||||
constructor(containerEl: HTMLElement, text: string) {
|
||||
super(containerEl);
|
||||
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
parse(){
|
||||
|
||||
let goal = '';
|
||||
const keyplans: string[] = new Array<string>(8).fill("-");
|
||||
const actions: string[][] = new Array<string[]>(8);
|
||||
for (let i = 0; i < actions.length; i++) {
|
||||
actions[i] = new Array<string>(8).fill("-");
|
||||
}
|
||||
|
||||
const lines = this.text.split("\n");
|
||||
let current_keyplans_index = -1;
|
||||
let current_actions_index = -1;
|
||||
for (const line of lines){
|
||||
const leading_space = line.match(/^(\s+)/);
|
||||
let leading_space_length = 0;
|
||||
if (leading_space != null){
|
||||
leading_space_length = leading_space[0].length;
|
||||
}
|
||||
const level = leading_space_length / 2;
|
||||
if( Number.isInteger(level) == false) {
|
||||
// error
|
||||
break;
|
||||
}
|
||||
|
||||
if (level == 0){
|
||||
if (goal == ''){
|
||||
goal = line;
|
||||
}
|
||||
}
|
||||
else if (level == 1){
|
||||
current_keyplans_index += 1;
|
||||
current_actions_index = -1;
|
||||
if (current_keyplans_index <= 8){
|
||||
keyplans[current_keyplans_index] = line.trim();
|
||||
}
|
||||
}
|
||||
else if (level == 2){
|
||||
current_actions_index += 1;
|
||||
if (current_actions_index <= 8){
|
||||
actions[current_keyplans_index][current_actions_index] = line.trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
"goal": goal,
|
||||
"keyplans" :keyplans,
|
||||
"actions": actions
|
||||
}
|
||||
}
|
||||
|
||||
onload() {
|
||||
|
||||
const table = document.createElement('table');
|
||||
table.id = 'harada';
|
||||
const {goal, keyplans, actions} = this.parse();
|
||||
|
||||
// Create 9 rows and 9 cells in each row
|
||||
for (let y = 0; y < 9; y++) {
|
||||
// Create a table row keyplan
|
||||
const row = document.createElement('tr');
|
||||
|
||||
// Create 9 table cell keyplans and add them to the row
|
||||
for (let x = 0; x < 9; x++) {
|
||||
let content = '';
|
||||
|
||||
const box_index = Math.floor(x / 3) + Math.floor(y / 3) * 3;
|
||||
const inbox_index = (x % 3) + (y % 3) * 3;
|
||||
|
||||
const cell = document.createElement('td');
|
||||
cell.classList.add('cell');
|
||||
|
||||
if((y % 3) == 0){
|
||||
cell.classList.add('top');
|
||||
}
|
||||
if((y % 3) == 2){
|
||||
cell.classList.add('bottom');
|
||||
}
|
||||
if((x % 3) == 0){
|
||||
cell.classList.add('left');
|
||||
}
|
||||
if((x % 3) == 2){
|
||||
cell.classList.add('right');
|
||||
}
|
||||
|
||||
if(box_index == 4 && inbox_index == 4){
|
||||
content = goal;
|
||||
cell.id = 'goal';
|
||||
}
|
||||
else if(box_index == 4){
|
||||
let keyplan_index = inbox_index;
|
||||
if(inbox_index > 4){
|
||||
keyplan_index = inbox_index - 1;
|
||||
}
|
||||
content = keyplans[keyplan_index];
|
||||
cell.id = 'keyplan';
|
||||
}
|
||||
else if(inbox_index == 4){
|
||||
let keyplan_index = box_index;
|
||||
if(box_index > 4){
|
||||
keyplan_index = box_index - 1;
|
||||
}
|
||||
content = keyplans[keyplan_index];
|
||||
cell.id = 'keyplan';
|
||||
}
|
||||
else{
|
||||
let keyplan_index = box_index;
|
||||
if(box_index > 4){
|
||||
keyplan_index = box_index - 1;
|
||||
}
|
||||
let action_index = inbox_index;
|
||||
if(inbox_index > 4){
|
||||
action_index = inbox_index - 1;
|
||||
}
|
||||
|
||||
try{
|
||||
content = actions[keyplan_index][action_index];
|
||||
}
|
||||
catch(err){
|
||||
console.log(err);
|
||||
}
|
||||
cell.id = 'action';
|
||||
}
|
||||
|
||||
cell.textContent = content;
|
||||
row.appendChild(cell);
|
||||
}
|
||||
|
||||
// Add the row to the table
|
||||
table.appendChild(row);
|
||||
}
|
||||
|
||||
this.containerEl.replaceWith(table);
|
||||
}
|
||||
}
|
||||
84
src/main.ts
Normal file
84
src/main.ts
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
// import { App, Modal, Plugin, PluginSettingTab, Setting, MarkdownPostProcessorContext } from 'obsidian';
|
||||
import { Plugin, MarkdownPostProcessorContext } from 'obsidian';
|
||||
import { HaradaMethod } from "./harada";
|
||||
|
||||
// Remember to rename these classes and interfaces!
|
||||
|
||||
// interface ObsidianHaradaMethodPluginSettings {
|
||||
// mySetting: string;
|
||||
// }
|
||||
|
||||
// const DEFAULT_SETTINGS: ObsidianHaradaMethodPluginSettings = {
|
||||
// mySetting: 'default'
|
||||
// }
|
||||
|
||||
export default class ObsidianHaradaMethodPlugin extends Plugin {
|
||||
// settings: ObsidianHaradaMethodPluginSettings;
|
||||
|
||||
async process (source: string, element: HTMLElement, context: MarkdownPostProcessorContext) {
|
||||
context.addChild(new HaradaMethod(element, source));
|
||||
}
|
||||
|
||||
async onload() {
|
||||
// await this.loadSettings();
|
||||
|
||||
this.registerMarkdownCodeBlockProcessor("harada", this.process)
|
||||
}
|
||||
|
||||
onunload() {
|
||||
|
||||
}
|
||||
|
||||
// async loadSettings() {
|
||||
// this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
|
||||
// }
|
||||
|
||||
// async saveSettings() {
|
||||
// await this.saveData(this.settings);
|
||||
// }
|
||||
}
|
||||
|
||||
// class SampleModal extends Modal {
|
||||
// constructor(app: App) {
|
||||
// super(app);
|
||||
// }
|
||||
|
||||
// onOpen() {
|
||||
// const {contentEl} = this;
|
||||
// contentEl.setText('Woah!');
|
||||
// }
|
||||
|
||||
// onClose() {
|
||||
// const {contentEl} = this;
|
||||
// contentEl.empty();
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
// class SampleSettingTab extends PluginSettingTab {
|
||||
// plugin: ObsidianHaradaMethodPlugin;
|
||||
|
||||
// constructor(app: App, plugin: ObsidianHaradaMethodPlugin) {
|
||||
// super(app, plugin);
|
||||
// this.plugin = plugin;
|
||||
// }
|
||||
|
||||
// display(): void {
|
||||
// const {containerEl} = this;
|
||||
|
||||
// containerEl.empty();
|
||||
// containerEl.createEl('h2', {text: 'Settings for my awesome plugin.'});
|
||||
|
||||
// new Setting(containerEl)
|
||||
// .setName('Setting #1')
|
||||
// .setDesc('It\'s a secret')
|
||||
// .addText(text => text
|
||||
// .setPlaceholder('Enter your secret')
|
||||
// .setValue(this.plugin.settings.mySetting)
|
||||
// .onChange(async (value) => {
|
||||
// console.log('Secret: ' + value);
|
||||
// this.plugin.settings.mySetting = value;
|
||||
// await this.plugin.saveSettings();
|
||||
// }));
|
||||
// }
|
||||
// }
|
||||
46
styles.css
46
styles.css
|
|
@ -6,3 +6,49 @@ available in the app when your plugin is enabled.
|
|||
If your plugin does not need CSS, delete this file.
|
||||
|
||||
*/
|
||||
|
||||
table.harada{
|
||||
width: 100%;
|
||||
table-layout: fixed;
|
||||
padding-bottom: 100%;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
td.cell{
|
||||
width: 11%;
|
||||
height: 100px;
|
||||
overflow: hidden;
|
||||
text-align: center;
|
||||
border: 1px dotted rgb(63, 63, 63);
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
td.left{
|
||||
border-left: 3px solid black;
|
||||
}
|
||||
|
||||
td.right{
|
||||
border-right: 3px solid black;
|
||||
}
|
||||
|
||||
td.top{
|
||||
border-top: 3px solid black;
|
||||
}
|
||||
|
||||
td.bottom{
|
||||
border-bottom: 3px solid black;
|
||||
}
|
||||
|
||||
#action{
|
||||
background-color: rgb(255, 255, 255);
|
||||
}
|
||||
|
||||
#plan{
|
||||
background-color: rgb(239, 255, 201);
|
||||
font-size: 25px;
|
||||
}
|
||||
|
||||
#goal{
|
||||
background-color: rgb(255, 229, 172);
|
||||
font-size: 30px;
|
||||
}
|
||||
Loading…
Reference in a new issue