Skip to content

Commit

Permalink
FIXED: Cannot remove boxel when widget unmounted
Browse files Browse the repository at this point in the history
  • Loading branch information
Quorafind committed Oct 11, 2022
1 parent 7dcca73 commit 9a5f0bc
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 36 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

## From BRAT

🚗: Add `Quorafind/obsidian-sakana-widget` to BRAT.
🚗: Add `Quorafind/obsidian-sakana-sakanaWidget` to BRAT.

## Download Manually

🚚: Download the latest release. Extract and put the three files (main.js, manifest.json, styles.css) to folder `{{obsidian_vault}}/.obsidian/plugins/Obsidian-Sakana-Widget`.

# License

Released under MIT License, please note that the 2 default images **should not be used for any commercial activities**. This project used to be a secondary development based on https://github.com/itorr/sakana | https://github.com/dsrkafuu/sakana-widget.
Released under MIT License, please note that the 2 default images **should not be used for any commercial activities**. This project used to be a secondary development based on https://github.com/itorr/sakana | https://github.com/dsrkafuu/sakana-sakanaWidget.

Image source: 大伏アオ [@blue00f4](https://twitter.com/blue00f4) [pixiv](https://pixiv.me/aoiroblue1340)
2 changes: 1 addition & 1 deletion esbuild.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ esbuild.build({
banner: {
js: banner,
},
entryPoints: ['main.ts'],
entryPoints: ['sakanaWidgetIndex.ts'],
bundle: true,
external: [
'obsidian',
Expand Down
30 changes: 0 additions & 30 deletions main.ts

This file was deleted.

2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-sakana-widget",
"name": "Sakana Widget",
"version": "1.0.1",
"version": "1.1.0",
"minAppVersion": "0.15.0",
"description": "Add the Sakana! Widget to your own Obsidian!",
"author": "Boninall",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obsidian-sakana-widget",
"version": "1.0.1",
"version": "1.1.0",
"description": "Add the Sakana! Widget to your own Obsidian!",
"main": "main.js",
"scripts": {
Expand Down
29 changes: 29 additions & 0 deletions sakanaWidgetIndex.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Plugin } from 'obsidian';
import SakanaWidget from "sakana-widget";

export default class SakanaWidgetPlugin extends Plugin {
sakanaBoxEl: HTMLElement;
sakanaEl: HTMLElement;
sakanaWidget: SakanaWidget;

async onload() {
this.app.workspace.onLayoutReady(()=> this.addSakanaWidget());
}

private addSakanaWidget() {

this.sakanaBoxEl = document.body.createEl('div', { attr: { id: 'sakana-widget-box' }, cls: 'sakana-widget-box' });
this.sakanaEl = this.sakanaBoxEl.createEl('div', { attr: { id: 'sakana-widget' }, cls: 'sakana-widget' });
this.sakanaWidget = new SakanaWidget({autoFit: true}).setState({ i: 0.03, d: 0.99, }).mount('#sakana-widget');

}

onunload() {
if(this.sakanaWidget) {
this.sakanaWidget.unmount();
}
if(this.sakanaBoxEl) {
this.sakanaBoxEl.detach();
}
}
}
5 changes: 5 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,8 @@ If your plugin does not need CSS, delete this file.
width: 150px;
height: 150px;
}

.sakana-widget {
width: 100%;
height: 100%;
}
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"1.0.0": "0.15.0",
"1.0.1": "0.15.0"
"1.0.1": "0.15.0",
"1.1.0": "0.15.0"
}

0 comments on commit 9a5f0bc

Please sign in to comment.