From 2aa6c949fb44f94b0d0a271157a38d466f2beb5b Mon Sep 17 00:00:00 2001 From: ransurf <80801637+ransurf@users.noreply.github.com> Date: Sat, 23 Oct 2021 14:54:50 -0600 Subject: [PATCH 01/42] Update README.md --- README.md | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 92fc6d4..ce90528 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,23 @@ # Habitica Sync in Obsidian This plugin for Obsidian incorporates a view to display and interact with the task management app Habitica. +Please open issues for any bugs/functionality requests :) + ## Usage -The plugin's view is enabled by clicking on the "Open Habitica Pane" option in the side ribbon. To sync your account, go to the settings page of the plugin and enter your user ID and API token credentials. +The plugin's view is enabled by clicking on the "Open Habitica Pane" option in the side ribbon (default hotkey is `Ctrl+Shift+H`). + +To sync your Habitica account, go to the settings page of the plugin and enter your user ID and API token credentials. ## Features -- View current HP and XP -- View todos, dailies, and habits -- Check off tasks/dailies in the view, which sync to habitica website -- Modify habit counters (+/-) +### Pane View +#### View HP, XP, todos, dailies, and habits +[![Image from Gyazo](https://i.gyazo.com/4266d01941e71fef41819ea8a6b6592e.png)](https://gyazo.com/4266d01941e71fef41819ea8a6b6592e) +[![Image from Gyazo](https://i.gyazo.com/697a58b8e7ffd3df86a2944b6abbaa92.png)](https://gyazo.com/697a58b8e7ffd3df86a2944b6abbaa92) +- Tab for active/completed tasks + +#### Check off tasks/dailies in the view, modify habit counters (+/-) +[![Image from Gyazo](https://i.gyazo.com/5759e12bc5267711c5e03485a6d72c2f.gif)](https://gyazo.com/5759e12bc5267711c5e03485a6d72c2f) +- Can uncheck completed habits/todos as shown above + ## Settings - **Habitica User ID:** You can find this by clicking on the "User" icon in the top right of the Habitica webapp, "Settings", then "API" - **Habitica Token API:** You can find this by clicking on the "User" icon in the top right of the Habitica webapp, "Settings", then "API" @@ -19,6 +29,6 @@ We will be implementing additional features including: - Add/delete/customize tasks and habits - View/claim rewards -Feeling generous? +*Feel free to support us and donate!* Buy Me a Coffee at ko-fi.com From f1a130077a7a17277ed785bbcfbe5244193082b7 Mon Sep 17 00:00:00 2001 From: Leoh Date: Sun, 24 Oct 2021 12:02:02 +0530 Subject: [PATCH 02/42] CSS change - fixed rogue li symbols --- styles.css | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/styles.css b/styles.css index 680c446..1f12342 100644 --- a/styles.css +++ b/styles.css @@ -149,3 +149,13 @@ input[type=checkbox]:focus { .react-tabs__tab-panel--selected { display: block; } +ul li:not(.task-list-item)::before { + content: "•"; + color: transparent; + display: inline-block; + width: 1em; + margin-left: -1em; + padding: 0; + font-weight: bold; + text-shadow: 0 0 0.5em transparent; +} \ No newline at end of file From 86f4fd0d744c70e99cac0b27e4d0336e1b054a40 Mon Sep 17 00:00:00 2001 From: Leoh Date: Sun, 24 Oct 2021 12:03:11 +0530 Subject: [PATCH 03/42] updated version patch no --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 8b6413f..bfa0b32 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-habitica-integration", "name": "Habitica Sync", - "version": "0.9.5", + "version": "0.9.6", "minAppVersion": "0.9.12", "description": "This plugin helps integrate Habitica user tasks and stats into Obsidian", "author": "Leoh and Ran", From 6a7651c04ae0dadf3ddffec13ba3434f4fa11b08 Mon Sep 17 00:00:00 2001 From: ransurf <80801637+ransurf@users.noreply.github.com> Date: Sun, 24 Oct 2021 13:50:42 -0600 Subject: [PATCH 04/42] Revert CSS Changes --- styles.css | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/styles.css b/styles.css index 1f12342..680c446 100644 --- a/styles.css +++ b/styles.css @@ -149,13 +149,3 @@ input[type=checkbox]:focus { .react-tabs__tab-panel--selected { display: block; } -ul li:not(.task-list-item)::before { - content: "•"; - color: transparent; - display: inline-block; - width: 1em; - margin-left: -1em; - padding: 0; - font-weight: bold; - text-shadow: 0 0 0.5em transparent; -} \ No newline at end of file From faa33a5655450221ee18bd73dfacee09bf75abe0 Mon Sep 17 00:00:00 2001 From: ransurf Date: Thu, 28 Oct 2021 21:53:15 -0700 Subject: [PATCH 05/42] Encapsulated user information into App class --- src/view/App.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/view/App.tsx b/src/view/App.tsx index fd8bdff..5243df5 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -4,14 +4,15 @@ import { getStats, scoreTask } from "./habiticaAPI" import Statsview from "./Components/Statsview" import Taskview from "./Components/Taskview" -let username = "" -let credentials = "" + class App extends React.Component { + username = "" + credentials = "" constructor(props: any) { super(props) - username = this.props.plugin.settings.userID - credentials = this.props.plugin.settings.apiToken + this.username = this.props.plugin.settings.userID + this.credentials = this.props.plugin.settings.apiToken this.state = { isLoaded: false, user_data: { @@ -37,11 +38,11 @@ class App extends React.Component { new Notice(message) } async reloadData() { - const result = (await getStats(username, credentials)).json() + const result = (await getStats(this.username, this.credentials)).json() result.then( result => { if(result.success === false){ - this.sendNotice("Login Failed, Please check credentials and try again!") + this.sendNotice("Login Failed, Please check this.credentials and try again!") } else { this.setState({ isLoaded: true, @@ -63,7 +64,7 @@ class App extends React.Component { } async sendScore(id:string , score: string, message: string){ - const result = (await scoreTask(username, credentials, id, score)).json() + const result = (await scoreTask(this.username, this.credentials, id, score)).json() result.then( result => { if(result.success) { From e8b010a3c5aeb3e735be31c4f8b5f58e98ab981b Mon Sep 17 00:00:00 2001 From: Zain Date: Sat, 30 Oct 2021 10:04:59 +0530 Subject: [PATCH 06/42] Changed sync syntax and removed uncessary function --- manifest.json | 2 +- src/view/App.tsx | 70 +++++++++++++++++++++--------------------------- 2 files changed, 31 insertions(+), 41 deletions(-) diff --git a/manifest.json b/manifest.json index bfa0b32..b537c6e 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-habitica-integration", "name": "Habitica Sync", - "version": "0.9.6", + "version": "0.9.7", "minAppVersion": "0.9.12", "description": "This plugin helps integrate Habitica user tasks and stats into Obsidian", "author": "Leoh and Ran", diff --git a/src/view/App.tsx b/src/view/App.tsx index 5243df5..3b1882d 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -4,8 +4,6 @@ import { getStats, scoreTask } from "./habiticaAPI" import Statsview from "./Components/Statsview" import Taskview from "./Components/Taskview" - - class App extends React.Component { username = "" credentials = "" @@ -33,53 +31,45 @@ class App extends React.Component { this.handleChangeHabits = this.handleChangeHabits.bind(this) - } - sendNotice(message: string){ - new Notice(message) } async reloadData() { - const result = (await getStats(this.username, this.credentials)).json() - result.then( - result => { - if(result.success === false){ - this.sendNotice("Login Failed, Please check this.credentials and try again!") - } else { - this.setState({ - isLoaded: true, - user_data: result, - tasks: result.tasks, - }) - } - }, - (error) => { - this.setState({ - isLoaded: true, - error - }) - } - ) + try { + let response = await getStats(this.username, this.credentials); + let result = await response.json(); + if (result.success === false) { + new Notice('Login Failed, Please check credentials and try again!'); + } + else { + this.setState({ + isLoaded: true, + user_data: result, + tasks: result.tasks, + }); + } + } catch (e) { + console.log(e); + new Notice("API Error: Please check credentials") + } } componentDidMount() { this.reloadData() } async sendScore(id:string , score: string, message: string){ - const result = (await scoreTask(this.username, this.credentials, id, score)).json() - result.then( - result => { - if(result.success) { - this.sendNotice(message) - this.reloadData() - } else { - this.sendNotice("Resyncing, please try again") - this.reloadData() - } - }, - (error) => { - this.sendNotice("API Error: Please Check crendentials and try again") - console.log(error) + try { + let response = await scoreTask(this.username, this.credentials, id, score); + let result = await response.json(); + if(result.success === true){ + new Notice(message); + this.reloadData(); + } else { + new Notice("Resyncing, please try again"); + this.reloadData(); } - ) + } catch (e) { + console.log(e); + new Notice("API Error: Please check credentials") + } } handleChangeTodos(event: any){ From b7b1c3848f127eeb5570199e23c11975bb087771 Mon Sep 17 00:00:00 2001 From: Zain Date: Sat, 30 Oct 2021 21:10:09 +0530 Subject: [PATCH 07/42] Changed Application name in Plugin and Added function to run Cron --- src/view/habiticaAPI.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/view/habiticaAPI.ts b/src/view/habiticaAPI.ts index 36f2b25..db4e2a8 100644 --- a/src/view/habiticaAPI.ts +++ b/src/view/habiticaAPI.ts @@ -6,7 +6,7 @@ export async function getStats(username: string, credentials: string){ method: 'GET', headers: { "Content-Type": "application/json", - "x-client": username.concat("-testAPI"), + "x-client": "278e719e-5f9c-43b1-9dba-8b73343dc062-HabiticaSync", "x-api-user": username, "x-api-key": credentials, }, @@ -20,7 +20,20 @@ export async function scoreTask(username: string, credentials: string, taskID: s method: 'POST', headers: { "Content-Type": "application/json", - "x-client": username.concat("-testAPI"), + "x-client": "278e719e-5f9c-43b1-9dba-8b73343dc062-HabiticaSync", + "x-api-user": username, + "x-api-key": credentials, + } + }) + return(response) +} +export async function makeCronReq(username: string, credentials: string, taskID: string){ + const url = "https://habitica.com/api/v3/cron"; + const response = fetch(url, { + method: 'POST', + headers: { + "Content-Type": "application/json", + "x-client": "278e719e-5f9c-43b1-9dba-8b73343dc062-HabiticaSync", "x-api-user": username, "x-api-key": credentials, } From 04f207db5dc53fb0281bf0a118494b76ce590ee4 Mon Sep 17 00:00:00 2001 From: Zain Date: Sat, 30 Oct 2021 22:34:41 +0530 Subject: [PATCH 08/42] Implemented Cron - untested --- src/view/App.tsx | 33 +++++++++++++++++++++++++++++++-- src/view/habiticaAPI.ts | 2 +- styles.css | 20 ++++++++++++++++++++ 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/src/view/App.tsx b/src/view/App.tsx index 3b1882d..ea5e9a9 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -1,6 +1,6 @@ import * as React from "react"; import { Notice } from "obsidian"; -import { getStats, scoreTask } from "./habiticaAPI" +import { getStats, scoreTask, makeCronReq } from "./habiticaAPI" import Statsview from "./Components/Statsview" import Taskview from "./Components/Taskview" @@ -12,6 +12,7 @@ class App extends React.Component { this.username = this.props.plugin.settings.userID this.credentials = this.props.plugin.settings.apiToken this.state = { + needCron: false, isLoaded: false, user_data: { profile: { @@ -20,7 +21,8 @@ class App extends React.Component { stats: { hp: 0, lvl: 0, - } + }, + lastCron: "", }, todos: [], dailys: [], @@ -32,6 +34,31 @@ class App extends React.Component { } + CheckCron(props: any) { + let cronDate = new Date(props.lastCron).getTime(); + let now = new Date().getTime(); + if (now > cronDate + 86400000) { + return( +
+
Welcome back! Please check your tasks for the last day and hit continue to get your daily rewards.
+ +
+ ); + } + else { + console.log("Cron is up to date"); + return null + }; + } + runCron() { + makeCronReq(this.username, this.credentials) + .then(res => { + this.setState({ + needCron: false + }) + }); + this.reloadData(); + } async reloadData() { try { let response = await getStats(this.username, this.credentials); @@ -40,6 +67,7 @@ class App extends React.Component { new Notice('Login Failed, Please check credentials and try again!'); } else { + console.log(result); this.setState({ isLoaded: true, user_data: result, @@ -124,6 +152,7 @@ class App extends React.Component { + ); } diff --git a/src/view/habiticaAPI.ts b/src/view/habiticaAPI.ts index db4e2a8..142a923 100644 --- a/src/view/habiticaAPI.ts +++ b/src/view/habiticaAPI.ts @@ -27,7 +27,7 @@ export async function scoreTask(username: string, credentials: string, taskID: s }) return(response) } -export async function makeCronReq(username: string, credentials: string, taskID: string){ +export async function makeCronReq(username: string, credentials: string){ const url = "https://habitica.com/api/v3/cron"; const response = fetch(url, { method: 'POST', diff --git a/styles.css b/styles.css index 1f12342..bdb8bd1 100644 --- a/styles.css +++ b/styles.css @@ -158,4 +158,24 @@ ul li:not(.task-list-item)::before { padding: 0; font-weight: bold; text-shadow: 0 0 0.5em transparent; +} +body > div.app-container.is-left-sidedock-collapsed.is-right-sidedock-collapsed > div.horizontal-main-container > div > div.workspace-split.mod-horizontal.mod-right-split > div.workspace-tabs > div.workspace-leaf > div > div.view-content > div > div.cron > button { + margin: auto; + margin-bottom: 5px; +} +.cron { + display: inline-grid; + justify-content: center; + text-align: center;; + margin-top: 5px; + margin-left: 10%; + margin-right: 10%; + margin-bottom: 10px; + background-color: var(--background-secondary-alt); + border-radius: 10px; +} +#cronMessage { + margin: 20px; + margin-bottom: 10px; + color: var(--text-normal) } \ No newline at end of file From af3b2fe53beab32e8b28b009538dd7fc3159c304 Mon Sep 17 00:00:00 2001 From: Zain Date: Sun, 31 Oct 2021 16:33:58 +0530 Subject: [PATCH 09/42] Cron implementation 2: Untested --- src/view/App.tsx | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/view/App.tsx b/src/view/App.tsx index ea5e9a9..72f4a31 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -28,20 +28,20 @@ class App extends React.Component { dailys: [], habits: [], } - this.handleChangeTodos = this.handleChangeTodos.bind(this) - this.handleChangeDailys = this.handleChangeDailys.bind(this) - this.handleChangeHabits = this.handleChangeHabits.bind(this) - + this.handleChangeTodos = this.handleChangeTodos.bind(this); + this.handleChangeDailys = this.handleChangeDailys.bind(this); + this.handleChangeHabits = this.handleChangeHabits.bind(this); + this.runCron = this.runCron.bind(this); } - CheckCron(props: any) { - let cronDate = new Date(props.lastCron).getTime(); - let now = new Date().getTime(); - if (now > cronDate + 86400000) { + CheckCron(lastCron: string) { + let cronDate = new Date(lastCron).getDate(); + let now = new Date().getDate(); + if (cronDate < now) { return(
Welcome back! Please check your tasks for the last day and hit continue to get your daily rewards.
- +
); } @@ -51,6 +51,7 @@ class App extends React.Component { }; } runCron() { + console.log("running cron"); makeCronReq(this.username, this.credentials) .then(res => { this.setState({ @@ -143,6 +144,7 @@ class App extends React.Component { } render(){ + let content = this.CheckCron(this.state.user_data.lastCron); if(this.state.error) return(
Loading....
) else if(!this.state.isLoaded) @@ -152,7 +154,7 @@ class App extends React.Component { - + {content} ); } From b3282a360c12c7534d336d046d82c0ee8cd02f6a Mon Sep 17 00:00:00 2001 From: Zain Date: Sun, 31 Oct 2021 16:39:47 +0530 Subject: [PATCH 10/42] Cron Implementation - tested --- src/view/App.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/view/App.tsx b/src/view/App.tsx index 72f4a31..b8f8814 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -41,7 +41,7 @@ class App extends React.Component { return(
Welcome back! Please check your tasks for the last day and hit continue to get your daily rewards.
- +
); } @@ -55,7 +55,7 @@ class App extends React.Component { makeCronReq(this.username, this.credentials) .then(res => { this.setState({ - needCron: false + needCron: false, }) }); this.reloadData(); From e0f400b761df61ba08be65c01e7f7862c7ad0d33 Mon Sep 17 00:00:00 2001 From: Zain Date: Mon, 1 Nov 2021 11:41:31 +0530 Subject: [PATCH 11/42] CronImplementation 3: tested --- src/view/App.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/view/App.tsx b/src/view/App.tsx index b8f8814..c49cae7 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -37,7 +37,8 @@ class App extends React.Component { CheckCron(lastCron: string) { let cronDate = new Date(lastCron).getDate(); let now = new Date().getDate(); - if (cronDate < now) { + console.log(cronDate, now); + if (cronDate != now) { return(
Welcome back! Please check your tasks for the last day and hit continue to get your daily rewards.
@@ -50,14 +51,17 @@ class App extends React.Component { return null }; } - runCron() { + async runCron() { console.log("running cron"); - makeCronReq(this.username, this.credentials) - .then(res => { + try { + let response = await makeCronReq(this.username, this.credentials); this.setState({ needCron: false, }) - }); + } catch (error) { + console.log(error); + new Notice("There was an error running the cron. Please try again later."); + } this.reloadData(); } async reloadData() { From 412f9ed431ea192bbf68b182845af5f3747614b3 Mon Sep 17 00:00:00 2001 From: Zain Date: Mon, 1 Nov 2021 11:53:35 +0530 Subject: [PATCH 12/42] MAdded getter and setter methods for username and credentials --- src/view/App.tsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/view/App.tsx b/src/view/App.tsx index c49cae7..a36d771 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -5,8 +5,20 @@ import Statsview from "./Components/Statsview" import Taskview from "./Components/Taskview" class App extends React.Component { - username = "" - credentials = "" + private _username = ""; + public get username() { + return this._username; + } + public set username(value) { + this._username = value; + } + private _credentials = ""; + public get credentials() { + return this._credentials; + } + public set credentials(value) { + this._credentials = value; + } constructor(props: any) { super(props) this.username = this.props.plugin.settings.userID From 25a1505fd06f5ad2505ec502325e0abceadc4eb0 Mon Sep 17 00:00:00 2001 From: Zain Date: Tue, 16 Nov 2021 18:29:31 +0530 Subject: [PATCH 13/42] Cron-Implementation: Tested! --- src/view/App.tsx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/view/App.tsx b/src/view/App.tsx index a36d771..6dda418 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -47,10 +47,9 @@ class App extends React.Component { } CheckCron(lastCron: string) { - let cronDate = new Date(lastCron).getDate(); - let now = new Date().getDate(); - console.log(cronDate, now); - if (cronDate != now) { + let cronDate = new Date(lastCron); + let now = new Date(); + if (cronDate.getDate() != now.getDate() || (cronDate.getMonth() != now.getMonth() || cronDate.getFullYear() != now.getFullYear())) { return(
Welcome back! Please check your tasks for the last day and hit continue to get your daily rewards.
From 3d61b94932e02d6990212e28584aa452e4a2847b Mon Sep 17 00:00:00 2001 From: Zain Date: Tue, 16 Nov 2021 18:53:03 +0530 Subject: [PATCH 14/42] Added Emoji Support --- package.json | 1 + src/view/Components/Taskview/Dailiesview/DailyItem.tsx | 5 +++-- src/view/Components/Taskview/Habitsview/HabitItem.tsx | 5 +++-- src/view/Components/Taskview/TodoItem.tsx | 5 +++-- src/view/Components/Taskview/Todoview/TodoItem.tsx | 5 +++-- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 4acb414..344ca09 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "node-fetch": "^3.0.0", "react": "^17.0.2", "react-dom": "^17.0.2", + "react-emoji-render": "^1.2.4", "react-tabs": "^3.2.2" } } diff --git a/src/view/Components/Taskview/Dailiesview/DailyItem.tsx b/src/view/Components/Taskview/Dailiesview/DailyItem.tsx index 40650af..d2d308e 100644 --- a/src/view/Components/Taskview/Dailiesview/DailyItem.tsx +++ b/src/view/Components/Taskview/Dailiesview/DailyItem.tsx @@ -1,10 +1,11 @@ - import * as React from "react"; +import Emoji from "react-emoji-render"; +import * as React from "react"; function DailyItem(props: any) { return (
-

{props.daily_text}

+

) } diff --git a/src/view/Components/Taskview/Habitsview/HabitItem.tsx b/src/view/Components/Taskview/Habitsview/HabitItem.tsx index faff665..fa397cc 100644 --- a/src/view/Components/Taskview/Habitsview/HabitItem.tsx +++ b/src/view/Components/Taskview/Habitsview/HabitItem.tsx @@ -1,4 +1,5 @@ - import * as React from "react"; +import Emoji from "react-emoji-render"; +import * as React from "react"; function HabitItem(props: any) { return ( @@ -6,7 +7,7 @@ function HabitItem(props: any) { -

{props.habit_text}

+

diff --git a/src/view/Components/Taskview/TodoItem.tsx b/src/view/Components/Taskview/TodoItem.tsx index 4adc70f..c02e230 100644 --- a/src/view/Components/Taskview/TodoItem.tsx +++ b/src/view/Components/Taskview/TodoItem.tsx @@ -1,10 +1,11 @@ - import * as React from "react"; +import { Emoji } from 'react-emoji-render'; +import * as React from "react"; function TodoItem(props: any) { return (
-

{props.todo_text}

+
) } diff --git a/src/view/Components/Taskview/Todoview/TodoItem.tsx b/src/view/Components/Taskview/Todoview/TodoItem.tsx index 4adc70f..2766dbe 100644 --- a/src/view/Components/Taskview/Todoview/TodoItem.tsx +++ b/src/view/Components/Taskview/Todoview/TodoItem.tsx @@ -1,10 +1,11 @@ - import * as React from "react"; +import Emoji from "react-emoji-render"; +import * as React from "react"; function TodoItem(props: any) { return (
-

{props.todo_text}

+

) } From 9d6c50ef88e7e4b6a9fcd155c3a4f159d0b98515 Mon Sep 17 00:00:00 2001 From: Zain Date: Tue, 16 Nov 2021 18:59:11 +0530 Subject: [PATCH 15/42] fixed css problem: habit content width too thin --- styles.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/styles.css b/styles.css index bdb8bd1..423fe18 100644 --- a/styles.css +++ b/styles.css @@ -23,7 +23,7 @@ .habit-text { text-align: center !important; padding: 0px; - width: 80px; + width: 50%; margin-right: 20px; } From 288f0a0b09fa628dd76e741ab8931ba1b74f69b9 Mon Sep 17 00:00:00 2001 From: Zain Date: Tue, 16 Nov 2021 19:06:15 +0530 Subject: [PATCH 16/42] updated version number --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index b537c6e..c9b0afa 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-habitica-integration", "name": "Habitica Sync", - "version": "0.9.7", + "version": "0.9.15", "minAppVersion": "0.9.12", "description": "This plugin helps integrate Habitica user tasks and stats into Obsidian", "author": "Leoh and Ran", From ffa79454a07577e0c0ef6e7bd2a8e4f515ef381f Mon Sep 17 00:00:00 2001 From: Zain Date: Tue, 16 Nov 2021 19:15:25 +0530 Subject: [PATCH 17/42] Removed unnecessary logs --- src/view/App.tsx | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/view/App.tsx b/src/view/App.tsx index 6dda418..aaf4cc0 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -58,7 +58,6 @@ class App extends React.Component { ); } else { - console.log("Cron is up to date"); return null }; } @@ -83,7 +82,6 @@ class App extends React.Component { new Notice('Login Failed, Please check credentials and try again!'); } else { - console.log(result); this.setState({ isLoaded: true, user_data: result, From bc97bcfc3f12770b077db825d9defeec8ff6f2e0 Mon Sep 17 00:00:00 2001 From: kkzzhizhou <806508401@qq.com> Date: Thu, 18 Nov 2021 14:16:20 +0800 Subject: [PATCH 18/42] add rewards panels and change styles --- src/main.ts | 3 +- src/view.tsx | 6 +- src/view/App.tsx | 130 +++++++++++------- src/view/Components/Statsview/index.tsx | 8 +- .../Taskview/Habitsview/HabitItem.tsx | 7 +- src/view/Components/Taskview/index.tsx | 22 ++- src/view/habiticaAPI.ts | 16 ++- styles.css | 47 +++++-- 8 files changed, 163 insertions(+), 76 deletions(-) diff --git a/src/main.ts b/src/main.ts index bdf0312..7e628b9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -15,6 +15,7 @@ export default class HabiticaSync extends Plugin { view: HabiticaSyncView; async onload() { + console.log("正在加载habitica-sync") await this.loadSettings(); this.addSettingTab(new HabiticaSyncSettingsTab(this.app, this)); this.registerView( @@ -40,7 +41,7 @@ export default class HabiticaSync extends Plugin { await this.saveData(this.settings); } async onunload() { - await this.view.onClose(); + // await this.view.onClose(); this.app.workspace .getLeavesOfType(VIEW_TYPE) diff --git a/src/view.tsx b/src/view.tsx index e73dbb7..827b893 100644 --- a/src/view.tsx +++ b/src/view.tsx @@ -32,7 +32,7 @@ export class HabiticaSyncView extends ItemView { ) } - async onClose(){ - ReactDOM.unmountComponentAtNode(this.containerEl.children[1]); - } + // async onClose(){ + // ReactDOM.unmountComponentAtNode(this.containerEl.children[1]); + // } } \ No newline at end of file diff --git a/src/view/App.tsx b/src/view/App.tsx index aaf4cc0..e456b0b 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -1,10 +1,10 @@ import * as React from "react"; import { Notice } from "obsidian"; -import { getStats, scoreTask, makeCronReq } from "./habiticaAPI" +import { getStats, scoreTask, makeCronReq, costReward } from "./habiticaAPI" import Statsview from "./Components/Statsview" import Taskview from "./Components/Taskview" -class App extends React.Component { +class App extends React.Component { private _username = ""; public get username() { return this._username; @@ -43,6 +43,7 @@ class App extends React.Component { this.handleChangeTodos = this.handleChangeTodos.bind(this); this.handleChangeDailys = this.handleChangeDailys.bind(this); this.handleChangeHabits = this.handleChangeHabits.bind(this); + this.handleChangeRewards = this.handleChangeRewards.bind(this); this.runCron = this.runCron.bind(this); } @@ -50,7 +51,7 @@ class App extends React.Component { let cronDate = new Date(lastCron); let now = new Date(); if (cronDate.getDate() != now.getDate() || (cronDate.getMonth() != now.getMonth() || cronDate.getFullYear() != now.getFullYear())) { - return( + return (
Welcome back! Please check your tasks for the last day and hit continue to get your daily rewards.
@@ -73,102 +74,131 @@ class App extends React.Component { new Notice("There was an error running the cron. Please try again later."); } this.reloadData(); - } + } async reloadData() { try { - let response = await getStats(this.username, this.credentials); - let result = await response.json(); - if (result.success === false) { - new Notice('Login Failed, Please check credentials and try again!'); - } - else { - this.setState({ - isLoaded: true, - user_data: result, - tasks: result.tasks, - }); - } - } catch (e) { + let response = await getStats(this.username, this.credentials); + let result = await response.json(); + if (result.success === false) { + new Notice('Login Failed, Please check credentials and try again!'); + } + else { + this.setState({ + isLoaded: true, + user_data: result, + tasks: result.tasks, + }); + } + } catch (e) { console.log(e); new Notice("API Error: Please check credentials") - } + } } componentDidMount() { this.reloadData() } - - async sendScore(id:string , score: string, message: string){ + + async sendScore(id: string, score: string, message: string) { try { - let response = await scoreTask(this.username, this.credentials, id, score); - let result = await response.json(); - if(result.success === true){ + let response = await scoreTask(this.username, this.credentials, id, score); + let result = await response.json(); + if (result.success === true) { new Notice(message); this.reloadData(); } else { new Notice("Resyncing, please try again"); this.reloadData(); } - } catch (e) { + } catch (e) { console.log(e); new Notice("API Error: Please check credentials") - } + } } - handleChangeTodos(event: any){ + async sendReward(id: string, score: string, message: string) { + try { + let response = await costReward(this.username, this.credentials, id, score); + let result = await response.json(); + if (result.success === true) { + new Notice(message); + this.reloadData(); + } else { + new Notice("Resyncing, please try again"); + this.reloadData(); + } + } catch (e) { + console.log(e); + new Notice("API Error: Please check credentials") + } + } + + handleChangeTodos(event: any) { this.state.tasks.todos.forEach((element: any) => { - if(element.id == event.target.id){ - if(!element.completed){ - this.sendScore(event.target.id,"up", "Checked!") + if (element.id == event.target.id) { + if (!element.completed) { + this.sendScore(event.target.id, "up", "Checked!") } else { - this.sendScore(event.target.id,"down", "Un-Checked!") + this.sendScore(event.target.id, "down", "Un-Checked!") } } }) } - handleChangeDailys(event: any){ + + + handleChangeDailys(event: any) { this.state.tasks.dailys.forEach((element: any) => { - if(element.id == event.target.id){ - if(element.id == event.target.id){ - if(!element.completed){ - this.sendScore(event.target.id,"up", "Checked!") + if (element.id == event.target.id) { + if (element.id == event.target.id) { + if (!element.completed) { + this.sendScore(event.target.id, "up", "Checked!") } else { - this.sendScore(event.target.id,"down", "Un-Checked!") + this.sendScore(event.target.id, "down", "Un-Checked!") } } } }) } - handleChangeHabits(event: any){ + handleChangeHabits(event: any) { const target_id = event.target.id.slice(4) - if(event.target.id.slice(0,4) == "plus"){ + if (event.target.id.slice(0, 4) == "plus") { this.state.tasks.habits.forEach((element: any) => { - if(element.id == target_id){ - this.sendScore(target_id,"up", "Plus!") + if (element.id == target_id) { + this.sendScore(target_id, "up", "Plus!") } }) } else { this.state.tasks.habits.forEach((element: any) => { - if(element.id == target_id){ - this.sendScore(target_id,"down", "Minus :(") + if (element.id == target_id) { + this.sendScore(target_id, "down", "Minus :(") } }) } } - - render(){ + handleChangeRewards(event: any) { + const target_id = event.target.id + this.state.tasks.rewards.forEach((element: any) => { + if (element.id == event.target.id) { + if (element.id == target_id) { + this.sendReward(target_id, "down", "Cost!") + } + } + }) + } + render() { let content = this.CheckCron(this.state.user_data.lastCron); - if(this.state.error) - return(
Loading....
) - else if(!this.state.isLoaded) + if (this.state.error) + return (
Loading....
) + else if (!this.state.isLoaded) return
Loading....
else { return (
- - + {content} -
+
+ +
); } } diff --git a/src/view/Components/Statsview/index.tsx b/src/view/Components/Statsview/index.tsx index f15d886..c84d10e 100644 --- a/src/view/Components/Statsview/index.tsx +++ b/src/view/Components/Statsview/index.tsx @@ -3,9 +3,11 @@ import * as React from 'react'; export default function Index(props: any) { return(
-
{props.user_data.profile.name}
-
favoriteHP: {(props.user_data.stats.hp).toPrecision(3)}
-
starLVL: {props.user_data.stats.lvl}
+ {/*
{props.user_data.profile.name}
*/} + {console.log(props)} +
HP: {(props.user_data.stats.hp).toPrecision(3)}
+
LEVEL: {props.user_data.stats.lvl}
+
GOLD: {(props.user_data.stats.gp).toPrecision(3)}
); } \ No newline at end of file diff --git a/src/view/Components/Taskview/Habitsview/HabitItem.tsx b/src/view/Components/Taskview/Habitsview/HabitItem.tsx index fa397cc..b09c217 100644 --- a/src/view/Components/Taskview/Habitsview/HabitItem.tsx +++ b/src/view/Components/Taskview/Habitsview/HabitItem.tsx @@ -4,13 +4,14 @@ import * as React from "react"; function HabitItem(props: any) { return (
- -

- +

+
) } diff --git a/src/view/Components/Taskview/index.tsx b/src/view/Components/Taskview/index.tsx index 9546979..64898b2 100644 --- a/src/view/Components/Taskview/index.tsx +++ b/src/view/Components/Taskview/index.tsx @@ -2,31 +2,39 @@ import * as React from "react"; import Dailiesview from "./Dailiesview" import Habitsview from "./Habitsview" import Todoview from "./Todoview" +import Rewardview from "./Rewardview" import { Tab, Tabs, TabList, TabPanel } from "react-tabs"; export default function Index(props: any){ const display =
- - task_alt - + today + + add_chart + - add_circle_outline + assignment_turned_in + + + account_balance - - - + + + + + +
return(display); diff --git a/src/view/habiticaAPI.ts b/src/view/habiticaAPI.ts index 142a923..478211b 100644 --- a/src/view/habiticaAPI.ts +++ b/src/view/habiticaAPI.ts @@ -39,4 +39,18 @@ export async function makeCronReq(username: string, credentials: string){ } }) return(response) -} \ No newline at end of file +} + +export async function costReward(username: string, credentials: string, taskID: string, direction: string) { + const url = "https://habitica.com/api/v4/tasks/".concat(taskID).concat("/score/").concat(direction) + const response = fetch(url, { + method: 'POST', + headers: { + "Content-Type": "application/json", + "x-client": "278e719e-5f9c-43b1-9dba-8b73343dc062-HabiticaSync", + "x-api-user": username, + "x-api-key": credentials, + } + }) + return(response) +} diff --git a/styles.css b/styles.css index b31b4a2..f2c7e5c 100644 --- a/styles.css +++ b/styles.css @@ -1,3 +1,8 @@ +* { + margin: 0; + padding: 0; +} + #profile-name { font-size: x-large; @@ -5,7 +10,8 @@ padding-bottom: 3%; } .stats { - padding-bottom: 6px; + display: flex; + justify-content: space-between; } .todo-item { @@ -13,25 +19,38 @@ justify-content: flex-start; align-items: center; padding: 0px 0px 0; - width: 80%; + width: 100%; border-bottom: 1px solid #cecece; font-family: Roboto, sans-serif; font-weight: normal; font-size: 16px; } +.reward-item { + display: flex; + justify-content: flex-start; + align-items: center; + padding: 0px 0px 0; + width: 100%; + border-bottom: 1px solid #cecece; + font-family: Roboto, sans-serif; + font-weight: normal; + font-size: 16px; +} + + .habit-text { - text-align: center !important; + text-align: left !important; padding: 0px; - width: 50%; + width: 80%; margin-right: 20px; } .habit-plus { /* background-color: #fff; */ border: none; - color: white; - padding: 7px 10px; + color: black; + padding: 7px 5px; text-align: center; text-decoration: none; font-size: 16px; @@ -41,8 +60,8 @@ /* background-color: #fff; */ /* border-radius: 50%; */ border: none; - color: white; - padding: 7px 10px; + color: black; + padding: 7px 5px; text-align: center; text-decoration: none; font-size: 16px; @@ -70,8 +89,19 @@ input[type=checkbox]:focus { outline: 0; } +.task-view { + overflow: scroll; +} + +::-webkit-scrollbar { + display: none; /* Chrome Safari */ +} + .plugin-root { min-width: 260px; + display: grid; + grid-template-rows: 93% 5% 2%; + height: inherit; } .substats { @@ -144,6 +174,7 @@ input[type=checkbox]:focus { .react-tabs__tab-panel { display: none; + left: 0px; } .react-tabs__tab-panel--selected { From 9b15bb12361904af9a504f2457b36a1142e8eaa9 Mon Sep 17 00:00:00 2001 From: kkzzhizhou <806508401@qq.com> Date: Sat, 20 Nov 2021 13:49:24 +0800 Subject: [PATCH 19/42] add Rewardview Panel --- .gitignore | 3 +++ .hotreload | 0 .../Taskview/Rewardview/RewardItem.tsx | 13 ++++++++++++ .../Components/Taskview/Rewardview/index.tsx | 21 +++++++++++++++++++ 4 files changed, 37 insertions(+) create mode 100644 .hotreload create mode 100644 src/view/Components/Taskview/Rewardview/RewardItem.tsx create mode 100644 src/view/Components/Taskview/Rewardview/index.tsx diff --git a/.gitignore b/.gitignore index f36d0a2..de7c3d1 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,9 @@ node_modules package-lock.json +# yarn +yarn.lock + *.js.map diff --git a/.hotreload b/.hotreload new file mode 100644 index 0000000..e69de29 diff --git a/src/view/Components/Taskview/Rewardview/RewardItem.tsx b/src/view/Components/Taskview/Rewardview/RewardItem.tsx new file mode 100644 index 0000000..0a23b2d --- /dev/null +++ b/src/view/Components/Taskview/Rewardview/RewardItem.tsx @@ -0,0 +1,13 @@ +import Emoji from "react-emoji-render"; +import * as React from "react"; + +function RewardItem(props: any) { + return ( +
+ +

+
+ ) +} + +export default RewardItem \ No newline at end of file diff --git a/src/view/Components/Taskview/Rewardview/index.tsx b/src/view/Components/Taskview/Rewardview/index.tsx new file mode 100644 index 0000000..6ef7a61 --- /dev/null +++ b/src/view/Components/Taskview/Rewardview/index.tsx @@ -0,0 +1,21 @@ +import * as React from "react"; +import RewardItem from "./RewardItem" + +export default function Index(props: any){ + if(props.rewards == undefined) { + return (
+ No Rewards present. +
) + } + else { + const allRewards = props.rewards.map((reward: any) => { + return + }) + const display =
+
    {allRewards}
+
+ + return(display); + } +} + From e45182547f1993b15a1648632ff378cb5969ebad Mon Sep 17 00:00:00 2001 From: kkzzhizhou <806508401@qq.com> Date: Sat, 20 Nov 2021 17:11:13 +0800 Subject: [PATCH 20/42] add markdown render --- package.json | 5 ++++- src/main.ts | 7 +++++-- src/view.tsx | 7 +++---- src/view/App.tsx | 13 ++++++++----- .../Components/Taskview/Dailiesview/DailyItem.tsx | 9 +++++++-- src/view/Components/Taskview/Dailiesview/index.tsx | 4 ++-- .../Components/Taskview/Habitsview/HabitItem.tsx | 7 +++++-- src/view/Components/Taskview/Habitsview/index.tsx | 2 +- .../Components/Taskview/Rewardview/RewardItem.tsx | 6 +++++- src/view/Components/Taskview/Rewardview/index.tsx | 2 +- src/view/Components/Taskview/TodoItem.tsx | 2 +- src/view/Components/Taskview/Todoview/TodoItem.tsx | 7 ++++++- src/view/Components/Taskview/Todoview/index.tsx | 4 ++-- styles.css | 6 +++--- 14 files changed, 53 insertions(+), 28 deletions(-) diff --git a/package.json b/package.json index 344ca09..174f5f6 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "main": "main.js", "scripts": { "dev": "rollup --config rollup.config.js -w", - "build": "rollup --config rollup.config.js --environment BUILD:production" + "build": "rollup --config rollup.config.js --environment BUILD:production", + "dev2": "obsidian-plugin dev src/main.ts" }, "keywords": [], "author": "Leonard and Ran", @@ -21,6 +22,7 @@ "css-loader": "^6.4.0", "extract-text-webpack-plugin": "^2.1.2", "obsidian": "^0.12.0", + "obsidian-plugin-cli": "^0.4.3", "rollup": "^2.32.1", "style-loader": "^3.3.0", "tslib": "^2.2.0", @@ -32,6 +34,7 @@ "react": "^17.0.2", "react-dom": "^17.0.2", "react-emoji-render": "^1.2.4", + "react-markdown": "^7.1.0", "react-tabs": "^3.2.2" } } diff --git a/src/main.ts b/src/main.ts index 7e628b9..7fdc89b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -15,7 +15,7 @@ export default class HabiticaSync extends Plugin { view: HabiticaSyncView; async onload() { - console.log("正在加载habitica-sync") + console.log("load plugin: habitica-sync") await this.loadSettings(); this.addSettingTab(new HabiticaSyncSettingsTab(this.app, this)); this.registerView( @@ -33,6 +33,8 @@ export default class HabiticaSync extends Plugin { this.activateView(); } }); + this.activateView(); + } async loadSettings() { this.settings = Object.assign(DEFAULT_SETTINGS, await this.loadData()) @@ -40,9 +42,10 @@ export default class HabiticaSync extends Plugin { async saveSettings() { await this.saveData(this.settings); } + async onunload() { // await this.view.onClose(); - + this.app.workspace .getLeavesOfType(VIEW_TYPE) .forEach((leaf) => leaf.detach()); diff --git a/src/view.tsx b/src/view.tsx index 827b893..be66720 100644 --- a/src/view.tsx +++ b/src/view.tsx @@ -31,8 +31,7 @@ export class HabiticaSyncView extends ItemView { this.containerEl.children[1] ) } - - // async onClose(){ - // ReactDOM.unmountComponentAtNode(this.containerEl.children[1]); - // } + async onClose(){ + ReactDOM.unmountComponentAtNode(this.containerEl.children[1]); + } } \ No newline at end of file diff --git a/src/view/App.tsx b/src/view/App.tsx index e456b0b..36879c9 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -51,12 +51,15 @@ class App extends React.Component { let cronDate = new Date(lastCron); let now = new Date(); if (cronDate.getDate() != now.getDate() || (cronDate.getMonth() != now.getMonth() || cronDate.getFullYear() != now.getFullYear())) { + // return ( + //
+ //
Welcome back! Please check your tasks for the last day and hit continue to get your daily rewards.
+ // + //
+ // ); return ( -
-
Welcome back! Please check your tasks for the last day and hit continue to get your daily rewards.
- -
- ); +
+ ) } else { return null diff --git a/src/view/Components/Taskview/Dailiesview/DailyItem.tsx b/src/view/Components/Taskview/Dailiesview/DailyItem.tsx index d2d308e..741eb8c 100644 --- a/src/view/Components/Taskview/Dailiesview/DailyItem.tsx +++ b/src/view/Components/Taskview/Dailiesview/DailyItem.tsx @@ -1,11 +1,16 @@ import Emoji from "react-emoji-render"; import * as React from "react"; +import ReactMarkdown from "react-markdown"; function DailyItem(props: any) { return (
- -

+ +
+

+ +
+
) } diff --git a/src/view/Components/Taskview/Dailiesview/index.tsx b/src/view/Components/Taskview/Dailiesview/index.tsx index 0d0f192..e45c421 100644 --- a/src/view/Components/Taskview/Dailiesview/index.tsx +++ b/src/view/Components/Taskview/Dailiesview/index.tsx @@ -9,11 +9,11 @@ export default function Index(props: any){ else { const incompleteDailies = props.dailys.map((daily: any) => { if(!daily.completed) - return + return }) const completedDailies = props.dailys.map((daily: any) => { if(daily.completed) - return + return }) const display =
diff --git a/src/view/Components/Taskview/Habitsview/HabitItem.tsx b/src/view/Components/Taskview/Habitsview/HabitItem.tsx index b09c217..f458752 100644 --- a/src/view/Components/Taskview/Habitsview/HabitItem.tsx +++ b/src/view/Components/Taskview/Habitsview/HabitItem.tsx @@ -1,5 +1,6 @@ import Emoji from "react-emoji-render"; import * as React from "react"; +import ReactMarkdown from "react-markdown"; function HabitItem(props: any) { return ( @@ -10,8 +11,10 @@ function HabitItem(props: any) { -

- +
+

+ +
) } diff --git a/src/view/Components/Taskview/Habitsview/index.tsx b/src/view/Components/Taskview/Habitsview/index.tsx index dc322bb..1ee9eab 100644 --- a/src/view/Components/Taskview/Habitsview/index.tsx +++ b/src/view/Components/Taskview/Habitsview/index.tsx @@ -9,7 +9,7 @@ export default function Index(props: any){ } else { const allHabits = props.habits.map((habit: any) => { - return + return }) const display =
    {allHabits}
diff --git a/src/view/Components/Taskview/Rewardview/RewardItem.tsx b/src/view/Components/Taskview/Rewardview/RewardItem.tsx index 0a23b2d..0d86c01 100644 --- a/src/view/Components/Taskview/Rewardview/RewardItem.tsx +++ b/src/view/Components/Taskview/Rewardview/RewardItem.tsx @@ -1,11 +1,15 @@ import Emoji from "react-emoji-render"; import * as React from "react"; - +import ReactMarkdown from "react-markdown"; function RewardItem(props: any) { return (
+

+ +
+
) } diff --git a/src/view/Components/Taskview/Rewardview/index.tsx b/src/view/Components/Taskview/Rewardview/index.tsx index 6ef7a61..ff60917 100644 --- a/src/view/Components/Taskview/Rewardview/index.tsx +++ b/src/view/Components/Taskview/Rewardview/index.tsx @@ -9,7 +9,7 @@ export default function Index(props: any){ } else { const allRewards = props.rewards.map((reward: any) => { - return + return }) const display =
    {allRewards}
diff --git a/src/view/Components/Taskview/TodoItem.tsx b/src/view/Components/Taskview/TodoItem.tsx index c02e230..586fdc9 100644 --- a/src/view/Components/Taskview/TodoItem.tsx +++ b/src/view/Components/Taskview/TodoItem.tsx @@ -5,7 +5,7 @@ function TodoItem(props: any) { return (
- +
) } diff --git a/src/view/Components/Taskview/Todoview/TodoItem.tsx b/src/view/Components/Taskview/Todoview/TodoItem.tsx index 2766dbe..92b3d7f 100644 --- a/src/view/Components/Taskview/Todoview/TodoItem.tsx +++ b/src/view/Components/Taskview/Todoview/TodoItem.tsx @@ -1,11 +1,16 @@ import Emoji from "react-emoji-render"; import * as React from "react"; +import ReactMarkdown from "react-markdown"; function TodoItem(props: any) { return (
-

+ {/*

*/} +
+

+ +
) } diff --git a/src/view/Components/Taskview/Todoview/index.tsx b/src/view/Components/Taskview/Todoview/index.tsx index 7ce2edf..ec61448 100644 --- a/src/view/Components/Taskview/Todoview/index.tsx +++ b/src/view/Components/Taskview/Todoview/index.tsx @@ -9,11 +9,11 @@ export default function Index(props: any){ else { const incompleteTodos = props.todos.map((todo: any) => { if(!todo.completed) - return + return }) const completedTodos = props.todos.map((todo: any) => { if(todo.completed) - return + return }) const display =
diff --git a/styles.css b/styles.css index f2c7e5c..10a2bd6 100644 --- a/styles.css +++ b/styles.css @@ -1,5 +1,5 @@ * { - margin: 0; + /* margin: 0; */ padding: 0; } @@ -49,7 +49,7 @@ .habit-plus { /* background-color: #fff; */ border: none; - color: black; + /* color: black; */ padding: 7px 5px; text-align: center; text-decoration: none; @@ -60,7 +60,7 @@ /* background-color: #fff; */ /* border-radius: 50%; */ border: none; - color: black; + /* color: black; */ padding: 7px 5px; text-align: center; text-decoration: none; From d10a2ca747c1ada5e255bef6d39eddc45b0dcf26 Mon Sep 17 00:00:00 2001 From: Zain Date: Sun, 21 Nov 2021 12:17:46 +0530 Subject: [PATCH 21/42] Fixed cron and minor CSS tweaks --- src/view/App.tsx | 15 ++++++--------- styles.css | 31 +++++++++++++++++-------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/view/App.tsx b/src/view/App.tsx index 36879c9..616beed 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -51,15 +51,12 @@ class App extends React.Component { let cronDate = new Date(lastCron); let now = new Date(); if (cronDate.getDate() != now.getDate() || (cronDate.getMonth() != now.getMonth() || cronDate.getFullYear() != now.getFullYear())) { - // return ( - //
- //
Welcome back! Please check your tasks for the last day and hit continue to get your daily rewards.
- // - //
- // ); return ( -
- ) +
+
Welcome back! Please check your tasks for the last day and hit continue to get your daily rewards.
+ +
+ ); } else { return null @@ -196,9 +193,9 @@ class App extends React.Component { return
Loading....
else { return (
+ {content} - {content}
diff --git a/styles.css b/styles.css index 10a2bd6..99bb4b5 100644 --- a/styles.css +++ b/styles.css @@ -1,14 +1,3 @@ -* { - /* margin: 0; */ - padding: 0; -} - - -#profile-name { - font-size: x-large; - font-weight: bold; - padding-bottom: 3%; -} .stats { display: flex; justify-content: space-between; @@ -42,7 +31,6 @@ .habit-text { text-align: left !important; padding: 0px; - width: 80%; margin-right: 20px; } @@ -51,6 +39,7 @@ border: none; /* color: black; */ padding: 7px 5px; + width: 40px; text-align: center; text-decoration: none; font-size: 16px; @@ -65,6 +54,7 @@ text-align: center; text-decoration: none; font-size: 16px; + width: 40px; } .habit-item { @@ -100,7 +90,6 @@ input[type=checkbox]:focus { .plugin-root { min-width: 260px; display: grid; - grid-template-rows: 93% 5% 2%; height: inherit; } @@ -195,6 +184,7 @@ body > div.app-container.is-left-sidedock-collapsed.is-right-sidedock-collapsed margin-bottom: 5px; } .cron { + height: fit-content; display: inline-grid; justify-content: center; text-align: center;; @@ -202,7 +192,7 @@ body > div.app-container.is-left-sidedock-collapsed.is-right-sidedock-collapsed margin-left: 10%; margin-right: 10%; margin-bottom: 10px; - background-color: var(--background-secondary-alt); + background-color: var(--background-primary-alt); border-radius: 10px; } #cronMessage { @@ -210,3 +200,16 @@ body > div.app-container.is-left-sidedock-collapsed.is-right-sidedock-collapsed margin-bottom: 10px; color: var(--text-normal) } + +button { + color: var(--text-normal); + background-color: var(--background-secondary-alt); + border-radius: 4px; + border: none; + padding: 6px 20px; + cursor: pointer; + margin-right: 12px; + font-family: 'Inter', sans-serif; + outline: none; + user-select: none; +} \ No newline at end of file From 54e6000eb8811968a7e3082a4995c6e40f96654e Mon Sep 17 00:00:00 2001 From: Zain Date: Sun, 21 Nov 2021 12:47:21 +0530 Subject: [PATCH 22/42] Fixed empty space at the bottom, fixed warning at main.ts --- src/main.ts | 4 ++-- src/view/App.tsx | 1 - styles.css | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index 7fdc89b..193f9f1 100644 --- a/src/main.ts +++ b/src/main.ts @@ -33,7 +33,7 @@ export default class HabiticaSync extends Plugin { this.activateView(); } }); - this.activateView(); + // this.activateView(); } async loadSettings() { @@ -44,7 +44,7 @@ export default class HabiticaSync extends Plugin { } async onunload() { - // await this.view.onClose(); + await this.view.onClose(); this.app.workspace .getLeavesOfType(VIEW_TYPE) diff --git a/src/view/App.tsx b/src/view/App.tsx index 616beed..080bd70 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -196,7 +196,6 @@ class App extends React.Component { {content} -
); diff --git a/styles.css b/styles.css index 99bb4b5..c0feb7f 100644 --- a/styles.css +++ b/styles.css @@ -90,6 +90,7 @@ input[type=checkbox]:focus { .plugin-root { min-width: 260px; display: grid; + grid-template-rows: auto 1fr auto; height: inherit; } From 6384c98181cfc3f61fa8891a11591fefcea8c915 Mon Sep 17 00:00:00 2001 From: ransurf Date: Sat, 20 Nov 2021 23:39:09 -0800 Subject: [PATCH 23/42] Added "Show Task Description" Setting --- src/main.ts | 1 + src/settings.ts | 13 +++++++++++++ src/view/App.tsx | 2 +- src/view/Components/Taskview/Dailiesview/index.tsx | 6 +++++- src/view/Components/Taskview/Habitsview/index.tsx | 4 ++++ src/view/Components/Taskview/Rewardview/index.tsx | 6 +++++- src/view/Components/Taskview/Todoview/index.tsx | 10 ++++++++-- src/view/Components/Taskview/index.tsx | 8 ++++---- 8 files changed, 41 insertions(+), 9 deletions(-) diff --git a/src/main.ts b/src/main.ts index 7fdc89b..45e1054 100644 --- a/src/main.ts +++ b/src/main.ts @@ -5,6 +5,7 @@ import { HabiticaSyncView, VIEW_TYPE} from "./view" interface HabiticaSyncSettings { userID: string apiToken: string + showTaskDescription: boolean } const DEFAULT_SETTINGS: Partial = { userID: "", diff --git a/src/settings.ts b/src/settings.ts index bd298e5..6957237 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -38,5 +38,18 @@ export class HabiticaSyncSettingsTab extends PluginSettingTab { await this.plugin.saveSettings(); }) ); + + new Setting(containerEl) + .setName("Show Task Descriptions") + .setDesc("Updates require pane re-opening") + .addToggle(cb => { + cb + .setValue(this.plugin.settings.showTaskDescription) + .onChange(async (isEnable) => { + this.plugin.settings.showTaskDescription = isEnable; + await this.plugin.saveSettings(); + }) + }); + } } \ No newline at end of file diff --git a/src/view/App.tsx b/src/view/App.tsx index 616beed..445268e 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -195,7 +195,7 @@ class App extends React.Component { return (
{content} - +
diff --git a/src/view/Components/Taskview/Dailiesview/index.tsx b/src/view/Components/Taskview/Dailiesview/index.tsx index e45c421..9faafc2 100644 --- a/src/view/Components/Taskview/Dailiesview/index.tsx +++ b/src/view/Components/Taskview/Dailiesview/index.tsx @@ -9,8 +9,12 @@ export default function Index(props: any){ else { const incompleteDailies = props.dailys.map((daily: any) => { if(!daily.completed) + if (props.settings.showTaskDescription) { return - }) + } else { + return + } + }) const completedDailies = props.dailys.map((daily: any) => { if(daily.completed) return diff --git a/src/view/Components/Taskview/Habitsview/index.tsx b/src/view/Components/Taskview/Habitsview/index.tsx index 1ee9eab..1d0107c 100644 --- a/src/view/Components/Taskview/Habitsview/index.tsx +++ b/src/view/Components/Taskview/Habitsview/index.tsx @@ -9,7 +9,11 @@ export default function Index(props: any){ } else { const allHabits = props.habits.map((habit: any) => { + if (props.settings.showTaskDescription) { return + } else { + return + } }) const display =
    {allHabits}
diff --git a/src/view/Components/Taskview/Rewardview/index.tsx b/src/view/Components/Taskview/Rewardview/index.tsx index ff60917..4ddc21a 100644 --- a/src/view/Components/Taskview/Rewardview/index.tsx +++ b/src/view/Components/Taskview/Rewardview/index.tsx @@ -9,7 +9,11 @@ export default function Index(props: any){ } else { const allRewards = props.rewards.map((reward: any) => { - return + if (props.settings.showTaskDescription) { + return + } else { + return + } }) const display =
    {allRewards}
diff --git a/src/view/Components/Taskview/Todoview/index.tsx b/src/view/Components/Taskview/Todoview/index.tsx index ec61448..4f8c4e9 100644 --- a/src/view/Components/Taskview/Todoview/index.tsx +++ b/src/view/Components/Taskview/Todoview/index.tsx @@ -8,8 +8,14 @@ export default function Index(props: any){ } else { const incompleteTodos = props.todos.map((todo: any) => { - if(!todo.completed) - return + if(!todo.completed) { + if (props.settings.showTaskDescription) { + return + } else { + return + } + } + }) const completedTodos = props.todos.map((todo: any) => { if(todo.completed) diff --git a/src/view/Components/Taskview/index.tsx b/src/view/Components/Taskview/index.tsx index 64898b2..7001ac9 100644 --- a/src/view/Components/Taskview/index.tsx +++ b/src/view/Components/Taskview/index.tsx @@ -24,16 +24,16 @@ export default function Index(props: any){ - + - + - + - +
From 4878ed8aa8eec29d439f92c4210f3969a3db8287 Mon Sep 17 00:00:00 2001 From: ransurf <80801637+ransurf@users.noreply.github.com> Date: Sun, 21 Nov 2021 01:47:32 -0600 Subject: [PATCH 24/42] Semi-update readme visuals are outdated --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ce90528..a8c7b8c 100644 --- a/README.md +++ b/README.md @@ -9,25 +9,30 @@ The plugin's view is enabled by clicking on the "Open Habitica Pane" option in t To sync your Habitica account, go to the settings page of the plugin and enter your user ID and API token credentials. ## Features ### Pane View -#### View HP, XP, todos, dailies, and habits [![Image from Gyazo](https://i.gyazo.com/4266d01941e71fef41819ea8a6b6592e.png)](https://gyazo.com/4266d01941e71fef41819ea8a6b6592e) [![Image from Gyazo](https://i.gyazo.com/697a58b8e7ffd3df86a2944b6abbaa92.png)](https://gyazo.com/697a58b8e7ffd3df86a2944b6abbaa92) -- Tab for active/completed tasks +- View stats (HP, XP, coins) +- View to do's, dailies, and habits + - Tab for active/completed tasks and dailies #### Check off tasks/dailies in the view, modify habit counters (+/-) [![Image from Gyazo](https://i.gyazo.com/5759e12bc5267711c5e03485a6d72c2f.gif)](https://gyazo.com/5759e12bc5267711c5e03485a6d72c2f) - Can uncheck completed habits/todos as shown above ## Settings + +The following two inputs help fetch your user data to be displayed in the Obsidian view: - **Habitica User ID:** You can find this by clicking on the "User" icon in the top right of the Habitica webapp, "Settings", then "API" - **Habitica Token API:** You can find this by clicking on the "User" icon in the top right of the Habitica webapp, "Settings", then "API" -The following two inputs help fetch your user data to be displayed in the Obsidian view. + +**Show Task Descriptions:** Toggles whether description/notes for tasks will be shown or not + + ## Roadmap We will be implementing additional features including: - Add/delete/customize tasks and habits -- View/claim rewards *Feel free to support us and donate!* From 6865d4f080abb7308631d01b88a160829f2c1bc5 Mon Sep 17 00:00:00 2001 From: Zain Date: Sun, 21 Nov 2021 13:18:07 +0530 Subject: [PATCH 25/42] Fixed merge conflict error made by Ran lol --- src/view/App.tsx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/view/App.tsx b/src/view/App.tsx index f81736f..7ca62c3 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -195,12 +195,7 @@ class App extends React.Component { return (
{content} -<<<<<<< HEAD -
-======= - ->>>>>>> 54e6000eb8811968a7e3082a4995c6e40f96654e
); From 0ac05ef6d399625b70bf2d1e88615f1215623d56 Mon Sep 17 00:00:00 2001 From: ransurf <80801637+ransurf@users.noreply.github.com> Date: Sun, 21 Nov 2021 02:14:41 -0600 Subject: [PATCH 26/42] Update README.md --- README.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ce90528..ffd8731 100644 --- a/README.md +++ b/README.md @@ -9,26 +9,32 @@ The plugin's view is enabled by clicking on the "Open Habitica Pane" option in t To sync your Habitica account, go to the settings page of the plugin and enter your user ID and API token credentials. ## Features ### Pane View -#### View HP, XP, todos, dailies, and habits [![Image from Gyazo](https://i.gyazo.com/4266d01941e71fef41819ea8a6b6592e.png)](https://gyazo.com/4266d01941e71fef41819ea8a6b6592e) [![Image from Gyazo](https://i.gyazo.com/697a58b8e7ffd3df86a2944b6abbaa92.png)](https://gyazo.com/697a58b8e7ffd3df86a2944b6abbaa92) -- Tab for active/completed tasks +- View stats (HP, XP, coins) +- View to do's, dailies, and habits + - Tab for active/completed tasks and dailies #### Check off tasks/dailies in the view, modify habit counters (+/-) [![Image from Gyazo](https://i.gyazo.com/5759e12bc5267711c5e03485a6d72c2f.gif)](https://gyazo.com/5759e12bc5267711c5e03485a6d72c2f) - Can uncheck completed habits/todos as shown above ## Settings + +The following two inputs help fetch your user data to be displayed in the Obsidian view: - **Habitica User ID:** You can find this by clicking on the "User" icon in the top right of the Habitica webapp, "Settings", then "API" - **Habitica Token API:** You can find this by clicking on the "User" icon in the top right of the Habitica webapp, "Settings", then "API" -The following two inputs help fetch your user data to be displayed in the Obsidian view. + +**Show Task Descriptions:** Toggles whether description/notes for tasks will be shown or not + + ## Roadmap We will be implementing additional features including: - Add/delete/customize tasks and habits -- View/claim rewards *Feel free to support us and donate!*
Buy Me a Coffee at ko-fi.com + From e31d103dd789c278c1782b6f63e32879566e3109 Mon Sep 17 00:00:00 2001 From: ransurf <80801637+ransurf@users.noreply.github.com> Date: Sun, 21 Nov 2021 02:15:53 -0600 Subject: [PATCH 27/42] Update README.md --- README.md | 4 ---- 1 file changed, 4 deletions(-) diff --git a/README.md b/README.md index a8c7b8c..395678d 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,6 @@ The following two inputs help fetch your user data to be displayed in the Obsidi - **Habitica Token API:** You can find this by clicking on the "User" icon in the top right of the Habitica webapp, "Settings", then "API" -**Show Task Descriptions:** Toggles whether description/notes for tasks will be shown or not - - - ## Roadmap We will be implementing additional features including: - Add/delete/customize tasks and habits From 916236db5d6c5822dc69d13e2c08d60196fb1672 Mon Sep 17 00:00:00 2001 From: ransurf Date: Thu, 13 Jan 2022 12:47:36 -0800 Subject: [PATCH 28/42] Implement subtasks view and settings option, clean up CSS --- src/main.ts | 1 + src/settings.ts | 12 + src/view/App.tsx | 3 +- src/view/Components/Statsview/index.tsx | 1 - .../Taskview/Dailiesview/DailyItem.tsx | 5 +- .../Taskview/Dailiesview/DailySubTasks.tsx | 20 ++ .../Components/Taskview/Dailiesview/index.tsx | 18 +- .../Taskview/Habitsview/HabitItem.tsx | 16 +- .../Taskview/Rewardview/RewardItem.tsx | 10 +- .../Components/Taskview/Todoview/TodoItem.tsx | 4 +- .../Taskview/Todoview/TodoSubTasks.tsx | 20 ++ .../Components/Taskview/Todoview/index.tsx | 14 +- styles.css | 223 ++++++++++++------ 13 files changed, 257 insertions(+), 90 deletions(-) create mode 100644 src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx create mode 100644 src/view/Components/Taskview/Todoview/TodoSubTasks.tsx diff --git a/src/main.ts b/src/main.ts index a0f350a..5b370f7 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,6 +6,7 @@ interface HabiticaSyncSettings { userID: string apiToken: string showTaskDescription: boolean + showSubTasks: boolean } const DEFAULT_SETTINGS: Partial = { userID: "", diff --git a/src/settings.ts b/src/settings.ts index 6957237..b223be2 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -50,6 +50,18 @@ export class HabiticaSyncSettingsTab extends PluginSettingTab { await this.plugin.saveSettings(); }) }); + + new Setting(containerEl) + .setName("Show Sub-Tasks") + .setDesc("Updates require pane re-opening") + .addToggle(cb => { + cb + .setValue(this.plugin.settings.showSubTasks) + .onChange(async (isEnable) => { + this.plugin.settings.showSubTasks = isEnable; + await this.plugin.saveSettings(); + }) + }); } } \ No newline at end of file diff --git a/src/view/App.tsx b/src/view/App.tsx index 7ca62c3..2f0abc5 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -194,9 +194,10 @@ class App extends React.Component { else { return (
{content} + - +
); } diff --git a/src/view/Components/Statsview/index.tsx b/src/view/Components/Statsview/index.tsx index c84d10e..6f5fc9e 100644 --- a/src/view/Components/Statsview/index.tsx +++ b/src/view/Components/Statsview/index.tsx @@ -4,7 +4,6 @@ export default function Index(props: any) { return(
{/*
{props.user_data.profile.name}
*/} - {console.log(props)}
HP: {(props.user_data.stats.hp).toPrecision(3)}
LEVEL: {props.user_data.stats.lvl}
GOLD: {(props.user_data.stats.gp).toPrecision(3)}
diff --git a/src/view/Components/Taskview/Dailiesview/DailyItem.tsx b/src/view/Components/Taskview/Dailiesview/DailyItem.tsx index 741eb8c..d5b2a93 100644 --- a/src/view/Components/Taskview/Dailiesview/DailyItem.tsx +++ b/src/view/Components/Taskview/Dailiesview/DailyItem.tsx @@ -1,6 +1,7 @@ import Emoji from "react-emoji-render"; import * as React from "react"; import ReactMarkdown from "react-markdown"; +import DailySubTasks from "./DailySubTasks"; function DailyItem(props: any) { return ( @@ -8,7 +9,9 @@ function DailyItem(props: any) {

- + + {console.log(props.checklist)} +
diff --git a/src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx b/src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx new file mode 100644 index 0000000..63d97d2 --- /dev/null +++ b/src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx @@ -0,0 +1,20 @@ +import Emoji from "react-emoji-render"; +import * as React from "react"; + +function DailySubTasks(props: any) { + if (props.subtasks) { + const subtasks = props.subtasks.map((subtask: any) => { + return ( +
+ +

+
+ ) + }); + return subtasks + } + else { + return
+ } +} +export default DailySubTasks \ No newline at end of file diff --git a/src/view/Components/Taskview/Dailiesview/index.tsx b/src/view/Components/Taskview/Dailiesview/index.tsx index 9faafc2..27a988a 100644 --- a/src/view/Components/Taskview/Dailiesview/index.tsx +++ b/src/view/Components/Taskview/Dailiesview/index.tsx @@ -8,13 +8,21 @@ export default function Index(props: any){ } else { const incompleteDailies = props.dailys.map((daily: any) => { - if(!daily.completed) + if (!daily.completed) { + let daily_notes = ''; + let daily_subtasks = ''; if (props.settings.showTaskDescription) { - return - } else { - return + daily_notes = daily.notes; } - }) + + if (props.settings.showSubTasks) { + daily_subtasks = daily.checklist; + } + return + } + }) const completedDailies = props.dailys.map((daily: any) => { if(daily.completed) return diff --git a/src/view/Components/Taskview/Habitsview/HabitItem.tsx b/src/view/Components/Taskview/Habitsview/HabitItem.tsx index f458752..557adf6 100644 --- a/src/view/Components/Taskview/Habitsview/HabitItem.tsx +++ b/src/view/Components/Taskview/Habitsview/HabitItem.tsx @@ -5,15 +5,17 @@ import ReactMarkdown from "react-markdown"; function HabitItem(props: any) { return (
- - +
+ + +

- +
) diff --git a/src/view/Components/Taskview/Rewardview/RewardItem.tsx b/src/view/Components/Taskview/Rewardview/RewardItem.tsx index 0d86c01..983c909 100644 --- a/src/view/Components/Taskview/Rewardview/RewardItem.tsx +++ b/src/view/Components/Taskview/Rewardview/RewardItem.tsx @@ -3,11 +3,13 @@ import * as React from "react"; import ReactMarkdown from "react-markdown"; function RewardItem(props: any) { return ( -
- +
+
+ +
-

- +

+
diff --git a/src/view/Components/Taskview/Todoview/TodoItem.tsx b/src/view/Components/Taskview/Todoview/TodoItem.tsx index 92b3d7f..4c31505 100644 --- a/src/view/Components/Taskview/Todoview/TodoItem.tsx +++ b/src/view/Components/Taskview/Todoview/TodoItem.tsx @@ -1,6 +1,7 @@ import Emoji from "react-emoji-render"; import * as React from "react"; import ReactMarkdown from "react-markdown"; +import TodoSubTasks from "./TodoSubTasks"; function TodoItem(props: any) { return ( @@ -9,7 +10,8 @@ function TodoItem(props: any) { {/*

*/}

- + +
) diff --git a/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx b/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx new file mode 100644 index 0000000..79c7161 --- /dev/null +++ b/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx @@ -0,0 +1,20 @@ +import Emoji from "react-emoji-render"; +import * as React from "react"; + +function TodoSubTasks(props: any) { + if (props.subtasks) { + const subtasks = props.subtasks.map((subtask: any) => { + return ( +
+ +

+
+ ) + }); + return subtasks + } + else { + return
+ } +} +export default TodoSubTasks \ No newline at end of file diff --git a/src/view/Components/Taskview/Todoview/index.tsx b/src/view/Components/Taskview/Todoview/index.tsx index 4f8c4e9..8c1f236 100644 --- a/src/view/Components/Taskview/Todoview/index.tsx +++ b/src/view/Components/Taskview/Todoview/index.tsx @@ -8,12 +8,20 @@ export default function Index(props: any){ } else { const incompleteTodos = props.todos.map((todo: any) => { + if(!todo.completed) { + let todo_notes = ''; + let todo_subtasks = ''; if (props.settings.showTaskDescription) { - return - } else { - return + todo_notes = todo.notes; } + + if (props.settings.showSubTasks) { + todo_subtasks = todo.checklist; + } + return } }) diff --git a/styles.css b/styles.css index c0feb7f..eef70b1 100644 --- a/styles.css +++ b/styles.css @@ -1,103 +1,156 @@ +@import url('https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@1,300&display=swap'); +@import url('https://fonts.googleapis.com/css2?family=Open Sans:ital,wght@0,400;1,100&family=Roboto&display=swap'); + +* { + padding: 0; +} + +.add-task-input { + display: flex; +} + +#profile-name { + font-size: x-large; + font-weight: bold; + padding-bottom: 3%; +} .stats { + width: 95%; display: flex; justify-content: space-between; + font-weight: bold; + padding-bottom: 5px; +} + +.stats-view { + border-bottom: 1px; +} +.modify-todo { + align-self: center; +} + +.delete-todo { + align-self: center; } .todo-item { - display: flex; - justify-content: flex-start; - align-items: center; - padding: 0px 0px 0; - width: 100%; - border-bottom: 1px solid #cecece; - font-family: Roboto, sans-serif; - font-weight: normal; - font-size: 16px; + display: grid; + grid-template-columns: 1fr 30fr 1fr 1fr; + justify-content: left; + align-items: flex-start; + padding-top: 5px; + padding-bottom: 5px; + width: 100%; + border-bottom: 1px solid #cecece; + font-family: Roboto, sans-serif; + font-weight: bold; + font-size: 16px; } -.reward-item { - display: flex; - justify-content: flex-start; - align-items: center; - padding: 0px 0px 0; - width: 100%; - border-bottom: 1px solid #cecece; - font-family: Roboto, sans-serif; - font-weight: normal; - font-size: 16px; +.description { + font-family: Open Sans, sans-serif; + font-style: italic; + font-weight: 100; +} +.description > ul { + list-style-type: none; +} +p { + margin: 0; } - .habit-text { text-align: left !important; - padding: 0px; + font-weight: bold; + padding-top: 5px; + width: 80%; margin-right: 20px; } -.habit-plus { +.habit-button { /* background-color: #fff; */ border: none; /* color: black; */ - padding: 7px 5px; - width: 40px; text-align: center; text-decoration: none; font-size: 16px; -} - -.habit-minus { - /* background-color: #fff; */ - /* border-radius: 50%; */ - border: none; - /* color: black; */ - padding: 7px 5px; - text-align: center; - text-decoration: none; - font-size: 16px; - width: 40px; + display: block; + width: 100%; } .habit-item { display: flex; - /* justify-content: center; */ - align-content: space-between; - align-items: center; - padding: 0px 0px 0; + grid-template-columns: 60px 1fr; width: 100%; + gap: 5px; border-bottom: 1px solid #cecece; - font-family: Roboto, sans-serif; - font-weight: 50%; + font-family: Open Sans, sans-serif; + font-weight: 100%; font-size: 16px; - + padding-top: 5px; + padding-bottom: 5px; +} + +.habit-button-grp { + display: flex; + flex-direction: column; + justify-content: flex-start; + align-content: stretch; + height: 100%; } input[type=checkbox] { margin-right: 10px; + margin-top: 5px; + align-self: start; +} + +.todo-content { + align-self: center; +} + +.submit-button { + /* padding: 5px 5px; */ + font-size: 15px; + border: 1px solid #aaa; + /* white-space: nowrap; */ + /* margin: 10px; */ + margin: 0; } input[type=checkbox]:focus { outline: 0; } -.task-view { - overflow: scroll; -} - ::-webkit-scrollbar { display: none; /* Chrome Safari */ } .plugin-root { min-width: 260px; - display: grid; - grid-template-rows: auto 1fr auto; - height: inherit; + display: flex; + flex-direction: column; + justify-content: flex-start; + align-items: center; +} + +#classDisplay { + height: 100%; +} + + +.view-content { + margin-bottom: 0; } .substats { font-size: medium; } +ul { + margin: 0; +} + /* react-tabs internal file :wink: */ .material-icons { font-size: 12px !important; @@ -114,12 +167,12 @@ input[type=checkbox]:focus { .react-tabs { -webkit-tap-highlight-color: transparent; - + height: 100%; } .react-tabs__tab-list { border-bottom: 1px solid #aaa; - margin: 0 0 10px; + margin: 0 0 5px; padding: 0; } @@ -165,6 +218,13 @@ input[type=checkbox]:focus { .react-tabs__tab-panel { display: none; left: 0px; + height: 88%; + /* overflow: scroll; */ +} + +.task-panel { + overflow: scroll; + height: 100%; } .react-tabs__tab-panel--selected { @@ -180,12 +240,47 @@ ul li:not(.task-list-item)::before { font-weight: bold; text-shadow: 0 0 0.5em transparent; } -body > div.app-container.is-left-sidedock-collapsed.is-right-sidedock-collapsed > div.horizontal-main-container > div > div.workspace-split.mod-horizontal.mod-right-split > div.workspace-tabs > div.workspace-leaf > div > div.view-content > div > div.cron > button { + +.task-operation { + align-self: center; + margin: 0; + padding: 0; +} + +.edit-item { + display: flex; + flex-direction: column; + width: 100%; +} + +.edit-button { + display: flex; + flex-direction: row; + justify-content: flex-end; +} + +.task-submit { + display: grid; + grid-template-columns: 10fr 5fr; +} + +.add-task-input { + display: block; + width: 100%; +} + +.task-input-box { + margin-right: 10px; +} + +button { margin: auto; margin-bottom: 5px; + white-space: nowrap; + padding: 5px 5px; + margin-right: 0; } .cron { - height: fit-content; display: inline-grid; justify-content: center; text-align: center;; @@ -193,7 +288,6 @@ body > div.app-container.is-left-sidedock-collapsed.is-right-sidedock-collapsed margin-left: 10%; margin-right: 10%; margin-bottom: 10px; - background-color: var(--background-primary-alt); border-radius: 10px; } #cronMessage { @@ -202,15 +296,10 @@ body > div.app-container.is-left-sidedock-collapsed.is-right-sidedock-collapsed color: var(--text-normal) } -button { - color: var(--text-normal); - background-color: var(--background-secondary-alt); - border-radius: 4px; - border: none; - padding: 6px 20px; - cursor: pointer; - margin-right: 12px; - font-family: 'Inter', sans-serif; - outline: none; - user-select: none; -} \ No newline at end of file +.subtask { + display: flex; + flex-direction: row; + font-weight: normal; + font-family: Roboto, sans-serif; + justify-content: flex-start; +} From 88fdde519dbaae4f7e919d6b4fbd07776deea20a Mon Sep 17 00:00:00 2001 From: SuperChamp234 Date: Fri, 14 Jan 2022 14:39:21 +0530 Subject: [PATCH 29/42] Added a wrapper Markdown Rendered to render BOTH Emojis and Mardown as HTML --- package.json | 11 ++++++++++- rollup.config.js | 2 ++ src/main.ts | 3 +-- src/view/App.tsx | 1 + .../Taskview/Dailiesview/DailyItem.tsx | 9 +++++---- .../Taskview/Dailiesview/DailySubTasks.tsx | 6 ++++-- .../Taskview/Habitsview/HabitItem.tsx | 9 +++++---- .../Taskview/Rewardview/RewardItem.tsx | 10 ++++++---- src/view/Components/Taskview/TodoItem.tsx | 13 ------------- .../Components/Taskview/Todoview/TodoItem.tsx | 10 +++++----- .../Taskview/Todoview/TodoSubTasks.tsx | 5 +++-- src/view/Components/Taskview/Todoview/index.tsx | 2 +- src/view/Components/Taskview/Todoview/tabs.ts | 1 - src/view/Components/Taskview/index.tsx | 2 +- src/view/Components/Taskview/markdownRender.ts | 17 +++++++++++++++++ styles.css | 4 +++- tsconfig.json | 1 + 17 files changed, 65 insertions(+), 41 deletions(-) delete mode 100644 src/view/Components/Taskview/TodoItem.tsx delete mode 100644 src/view/Components/Taskview/Todoview/tabs.ts create mode 100644 src/view/Components/Taskview/markdownRender.ts diff --git a/package.json b/package.json index 174f5f6..7dbcea4 100644 --- a/package.json +++ b/package.json @@ -13,12 +13,17 @@ "license": "MIT", "devDependencies": { "@rollup/plugin-commonjs": "^18.0.0", + "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-node-resolve": "^11.2.1", "@rollup/plugin-typescript": "^8.2.1", + "@types/markdown-it": "^12.2.3", + "@types/markdown-it-emoji": "^2.0.2", "@types/node": "^14.14.37", + "@types/node-emoji": "^1.8.1", "@types/react": "^17.0.27", "@types/react-dom": "^17.0.9", "@types/react-tabs": "^2.3.3", + "@types/twemoji": "^12.1.2", "css-loader": "^6.4.0", "extract-text-webpack-plugin": "^2.1.2", "obsidian": "^0.12.0", @@ -29,12 +34,16 @@ "typescript": "^4.2.4" }, "dependencies": { + "markdown-it": "^12.3.2", + "markdown-it-emoji": "^2.0.0", "node": "^16.10.0", + "node-emoji": "^1.11.0", "node-fetch": "^3.0.0", "react": "^17.0.2", "react-dom": "^17.0.2", "react-emoji-render": "^1.2.4", "react-markdown": "^7.1.0", - "react-tabs": "^3.2.2" + "react-tabs": "^3.2.2", + "twemoji": "^13.1.0" } } diff --git a/rollup.config.js b/rollup.config.js index 8e28e8d..6da9767 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,6 +1,7 @@ import typescript from '@rollup/plugin-typescript'; import {nodeResolve} from '@rollup/plugin-node-resolve'; import commonjs from '@rollup/plugin-commonjs'; +import json from '@rollup/plugin-json'; const isProd = (process.env.BUILD === 'production'); @@ -26,5 +27,6 @@ export default { typescript(), nodeResolve({browser: true}), commonjs(), + json(), ] }; \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 5b370f7..5677142 100644 --- a/src/main.ts +++ b/src/main.ts @@ -24,7 +24,7 @@ export default class HabiticaSync extends Plugin { VIEW_TYPE, (leaf) => (new HabiticaSyncView(leaf, this)) ); - this.addRibbonIcon("popup-open", "Open Habitica Pane", () => { //activate view + this.addRibbonIcon("popup-open", "Open Habitica Pane", () => { this.activateView(); }); this.addCommand({ @@ -35,7 +35,6 @@ export default class HabiticaSync extends Plugin { this.activateView(); } }); - // this.activateView(); } async loadSettings() { diff --git a/src/view/App.tsx b/src/view/App.tsx index 2f0abc5..149304c 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -83,6 +83,7 @@ class App extends React.Component { new Notice('Login Failed, Please check credentials and try again!'); } else { + console.log(result); this.setState({ isLoaded: true, user_data: result, diff --git a/src/view/Components/Taskview/Dailiesview/DailyItem.tsx b/src/view/Components/Taskview/Dailiesview/DailyItem.tsx index d5b2a93..a59d02c 100644 --- a/src/view/Components/Taskview/Dailiesview/DailyItem.tsx +++ b/src/view/Components/Taskview/Dailiesview/DailyItem.tsx @@ -1,15 +1,16 @@ -import Emoji from "react-emoji-render"; import * as React from "react"; -import ReactMarkdown from "react-markdown"; import DailySubTasks from "./DailySubTasks"; +import renderMarkdown from "../markdownRender"; function DailyItem(props: any) { + var text_html = renderMarkdown(props.daily_text); + var note_html = renderMarkdown(props.daily_notes); return (
-

- +

+
{console.log(props.checklist)}
diff --git a/src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx b/src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx index 63d97d2..cd30f13 100644 --- a/src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx +++ b/src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx @@ -1,13 +1,15 @@ -import Emoji from "react-emoji-render"; import * as React from "react"; +import renderMarkdown from "../markdownRender"; function DailySubTasks(props: any) { + if (props.subtasks) { const subtasks = props.subtasks.map((subtask: any) => { + let subtask_text = renderMarkdown(subtask.text); return (
-

+

) }); diff --git a/src/view/Components/Taskview/Habitsview/HabitItem.tsx b/src/view/Components/Taskview/Habitsview/HabitItem.tsx index 557adf6..37d672c 100644 --- a/src/view/Components/Taskview/Habitsview/HabitItem.tsx +++ b/src/view/Components/Taskview/Habitsview/HabitItem.tsx @@ -1,8 +1,9 @@ -import Emoji from "react-emoji-render"; import * as React from "react"; -import ReactMarkdown from "react-markdown"; +import renderMarkdown from "../markdownRender"; function HabitItem(props: any) { + let habit_text = renderMarkdown(props.habit_text); + let habit_notes = renderMarkdown(props.habit_notes); return (
@@ -14,8 +15,8 @@ function HabitItem(props: any) {
-

- +

+
) diff --git a/src/view/Components/Taskview/Rewardview/RewardItem.tsx b/src/view/Components/Taskview/Rewardview/RewardItem.tsx index 983c909..5f331e2 100644 --- a/src/view/Components/Taskview/Rewardview/RewardItem.tsx +++ b/src/view/Components/Taskview/Rewardview/RewardItem.tsx @@ -1,15 +1,17 @@ -import Emoji from "react-emoji-render"; import * as React from "react"; -import ReactMarkdown from "react-markdown"; +import renderMarkdown from "../markdownRender"; + function RewardItem(props: any) { + let reward_text = renderMarkdown(props.reward_text); + let reward_notes = renderMarkdown(props.reward_notes); return (
-

- +

+
diff --git a/src/view/Components/Taskview/TodoItem.tsx b/src/view/Components/Taskview/TodoItem.tsx deleted file mode 100644 index 586fdc9..0000000 --- a/src/view/Components/Taskview/TodoItem.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { Emoji } from 'react-emoji-render'; -import * as React from "react"; - -function TodoItem(props: any) { - return ( -
- - -
- ) -} - -export default TodoItem \ No newline at end of file diff --git a/src/view/Components/Taskview/Todoview/TodoItem.tsx b/src/view/Components/Taskview/Todoview/TodoItem.tsx index 4c31505..0843657 100644 --- a/src/view/Components/Taskview/Todoview/TodoItem.tsx +++ b/src/view/Components/Taskview/Todoview/TodoItem.tsx @@ -1,16 +1,16 @@ -import Emoji from "react-emoji-render"; import * as React from "react"; -import ReactMarkdown from "react-markdown"; import TodoSubTasks from "./TodoSubTasks"; +import renderMarkdown from "../markdownRender" function TodoItem(props: any) { + var text_html = renderMarkdown(props.todo_text); + var note_html = renderMarkdown(props.todo_notes); return (
- {/*

*/}
-

- +

+
diff --git a/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx b/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx index 79c7161..ef74d92 100644 --- a/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx +++ b/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx @@ -1,13 +1,14 @@ -import Emoji from "react-emoji-render"; import * as React from "react"; +import renderMarkdown from "../markdownRender"; function TodoSubTasks(props: any) { if (props.subtasks) { const subtasks = props.subtasks.map((subtask: any) => { + let subtask_text = renderMarkdown(subtask.text); return (
-

+

) }); diff --git a/src/view/Components/Taskview/Todoview/index.tsx b/src/view/Components/Taskview/Todoview/index.tsx index 8c1f236..682e2ef 100644 --- a/src/view/Components/Taskview/Todoview/index.tsx +++ b/src/view/Components/Taskview/Todoview/index.tsx @@ -20,7 +20,7 @@ export default function Index(props: any){ todo_subtasks = todo.checklist; } return } diff --git a/src/view/Components/Taskview/Todoview/tabs.ts b/src/view/Components/Taskview/Todoview/tabs.ts deleted file mode 100644 index 55153e7..0000000 --- a/src/view/Components/Taskview/Todoview/tabs.ts +++ /dev/null @@ -1 +0,0 @@ -import * as React from "react" diff --git a/src/view/Components/Taskview/index.tsx b/src/view/Components/Taskview/index.tsx index 7001ac9..58f95fb 100644 --- a/src/view/Components/Taskview/index.tsx +++ b/src/view/Components/Taskview/index.tsx @@ -38,5 +38,5 @@ export default function Index(props: any){
return(display); -} //yes +} diff --git a/src/view/Components/Taskview/markdownRender.ts b/src/view/Components/Taskview/markdownRender.ts new file mode 100644 index 0000000..9e95a59 --- /dev/null +++ b/src/view/Components/Taskview/markdownRender.ts @@ -0,0 +1,17 @@ +import MarkdownIt from "markdown-it"; +import markdownitEmoji from "markdown-it-emoji" +import twemoji from "twemoji"; + +export default function renderMarkdown(markdown: string) { + const md = new MarkdownIt({ + html: true, + breaks: true, + linkify: true, + typographer: true + }); + md.use(markdownitEmoji); + md.renderer.rules.emoji = function(token, idx) { + return twemoji.parse(token[idx].content); + }; + return md.render(markdown); +} \ No newline at end of file diff --git a/styles.css b/styles.css index eef70b1..118caa0 100644 --- a/styles.css +++ b/styles.css @@ -49,7 +49,6 @@ .description { font-family: Open Sans, sans-serif; - font-style: italic; font-weight: 100; } .description > ul { @@ -303,3 +302,6 @@ button { font-family: Roboto, sans-serif; justify-content: flex-start; } +.emoji { + height: 1em; +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 48f3cf9..95b95d2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,6 +9,7 @@ "noImplicitAny": true, "moduleResolution": "node", "importHelpers": true, + "allowSyntheticDefaultImports": true, "lib": [ "dom", "es5", From 22616cbed9acb708abb39e7ea5d3b94d9c15a169 Mon Sep 17 00:00:00 2001 From: SuperChamp234 Date: Fri, 14 Jan 2022 17:55:47 +0530 Subject: [PATCH 30/42] Commit to dev branch includes - Due date on Todos - Dailies segragation to not include non-due Dailies - Checklist-items are now working - Made a completely new wrapper for markdown+emojis, can render emojis in description as well as task name --- package.json | 1 + src/main.ts | 6 ++- src/settings.ts | 13 ++++++ src/view/App.tsx | 28 +++++++++++-- .../Taskview/Dailiesview/DailyItem.tsx | 4 +- .../Taskview/Dailiesview/DailySubTasks.tsx | 2 +- .../Components/Taskview/Dailiesview/index.tsx | 42 +++++++++++++++++-- .../Components/Taskview/Todoview/TodoItem.tsx | 5 ++- .../Taskview/Todoview/TodoSubTasks.tsx | 2 +- .../Components/Taskview/Todoview/index.tsx | 2 +- src/view/Components/Taskview/index.tsx | 4 +- src/view/habiticaAPI.ts | 14 +++++++ styles.css | 4 ++ 13 files changed, 110 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 7dbcea4..870cee1 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "dependencies": { "markdown-it": "^12.3.2", "markdown-it-emoji": "^2.0.0", + "moment": "^2.29.1", "node": "^16.10.0", "node-emoji": "^1.11.0", "node-fetch": "^3.0.0", diff --git a/src/main.ts b/src/main.ts index 5677142..13cae87 100644 --- a/src/main.ts +++ b/src/main.ts @@ -7,10 +7,14 @@ interface HabiticaSyncSettings { apiToken: string showTaskDescription: boolean showSubTasks: boolean + dueDateFormat: string } const DEFAULT_SETTINGS: Partial = { userID: "", - apiToken: "" + apiToken: "", + showTaskDescription: true, + showSubTasks: true, + dueDateFormat: "DD-MM-YYYY" } export default class HabiticaSync extends Plugin { settings: HabiticaSyncSettings; diff --git a/src/settings.ts b/src/settings.ts index b223be2..974fe44 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -1,5 +1,6 @@ import HabiticaSync from "./main"; import { App, PluginSettingTab, Setting } from "obsidian"; +import moment from "moment"; export class HabiticaSyncSettingsTab extends PluginSettingTab { plugin: HabiticaSync; @@ -62,6 +63,18 @@ export class HabiticaSyncSettingsTab extends PluginSettingTab { await this.plugin.saveSettings(); }) }); + new Setting(containerEl) + .setName("Due Date Format") + .setDesc("Update requires pane re-opening, check moment.js docs for formatting. Current Format: " + moment().format(this.plugin.settings.dueDateFormat)) + .addText((text) => + text + .setPlaceholder("DD-MM-YYYY") + .setValue(this.plugin.settings.dueDateFormat) + .onChange(async (value) => { + this.plugin.settings.dueDateFormat = value; + await this.plugin.saveSettings(); + }) + ); } } \ No newline at end of file diff --git a/src/view/App.tsx b/src/view/App.tsx index 149304c..fdb748d 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -1,8 +1,9 @@ import * as React from "react"; import { Notice } from "obsidian"; -import { getStats, scoreTask, makeCronReq, costReward } from "./habiticaAPI" +import { getStats, scoreTask, makeCronReq, costReward, scoreChecklistItem } from "./habiticaAPI" import Statsview from "./Components/Statsview" import Taskview from "./Components/Taskview" +import ReactDOM from "react-dom"; class App extends React.Component { private _username = ""; @@ -44,6 +45,7 @@ class App extends React.Component { this.handleChangeDailys = this.handleChangeDailys.bind(this); this.handleChangeHabits = this.handleChangeHabits.bind(this); this.handleChangeRewards = this.handleChangeRewards.bind(this); + this.handleChangeChecklistItem = this.handleChangeChecklistItem.bind(this); this.runCron = this.runCron.bind(this); } @@ -144,8 +146,6 @@ class App extends React.Component { } }) } - - handleChangeDailys(event: any) { this.state.tasks.dailys.forEach((element: any) => { if (element.id == event.target.id) { @@ -186,6 +186,26 @@ class App extends React.Component { } }) } + async handleChangeChecklistItem(event: any){ + let parentID = event.target.parentNode.parentNode.parentNode.getAttribute("id") + let targetID = event.target.id + console.log(parentID+ " , " + targetID) + try{ + let response = await scoreChecklistItem(this.username, this.credentials, targetID, parentID); + let result = await response.json(); + if (result.success === true) { + new Notice("Checked!"); + this.reloadData(); + } else { + new Notice("Resyncing, please try again"); + this.reloadData(); + } + } catch (e) { + console.log(e); + new Notice("API Error: Please check credentials") + } + } + render() { let content = this.CheckCron(this.state.user_data.lastCron); if (this.state.error) @@ -197,7 +217,7 @@ class App extends React.Component { {content} - +
); diff --git a/src/view/Components/Taskview/Dailiesview/DailyItem.tsx b/src/view/Components/Taskview/Dailiesview/DailyItem.tsx index a59d02c..ac950ee 100644 --- a/src/view/Components/Taskview/Dailiesview/DailyItem.tsx +++ b/src/view/Components/Taskview/Dailiesview/DailyItem.tsx @@ -11,8 +11,8 @@ function DailyItem(props: any) {

- {console.log(props.checklist)} - + {/* {console.log(props.checklist)} */} +
diff --git a/src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx b/src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx index cd30f13..71b2b09 100644 --- a/src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx +++ b/src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx @@ -8,7 +8,7 @@ function DailySubTasks(props: any) { let subtask_text = renderMarkdown(subtask.text); return (
- +

) diff --git a/src/view/Components/Taskview/Dailiesview/index.tsx b/src/view/Components/Taskview/Dailiesview/index.tsx index 27a988a..bf8b952 100644 --- a/src/view/Components/Taskview/Dailiesview/index.tsx +++ b/src/view/Components/Taskview/Dailiesview/index.tsx @@ -7,8 +7,24 @@ export default function Index(props: any){ return
No Dailies Present
} else { + const notDueDailies = props.dailys.map((daily: any) => { + if (!daily.isDue) { + let daily_notes = ''; + let daily_subtasks = ''; + if (props.settings.showTaskDescription) { + daily_notes = daily.notes; + } + + if (props.settings.showSubTasks) { + daily_subtasks = daily.checklist; + } + return + } + }) const incompleteDailies = props.dailys.map((daily: any) => { - if (!daily.completed) { + if (!daily.completed&&daily.isDue) { let daily_notes = ''; let daily_subtasks = ''; if (props.settings.showTaskDescription) { @@ -20,18 +36,33 @@ export default function Index(props: any){ } return + onChange={props.onChange} completed={daily.completed} onChangeChecklistItem={props.onChangeChecklistItem}/> } }) const completedDailies = props.dailys.map((daily: any) => { - if(daily.completed) - return + // if(daily.completed) + // return + if (!daily.completed) { + let daily_notes = ''; + let daily_subtasks = ''; + if (props.settings.showTaskDescription) { + daily_notes = daily.notes; + } + + if (props.settings.showSubTasks) { + daily_subtasks = daily.checklist; + } + return + } }) const display =
Active Completed + Not Due
    {incompleteDailies}
@@ -39,6 +70,9 @@ export default function Index(props: any){
    {completedDailies}
+ +
    {notDueDailies}
+
return(display); diff --git a/src/view/Components/Taskview/Todoview/TodoItem.tsx b/src/view/Components/Taskview/Todoview/TodoItem.tsx index 0843657..7c1653b 100644 --- a/src/view/Components/Taskview/Todoview/TodoItem.tsx +++ b/src/view/Components/Taskview/Todoview/TodoItem.tsx @@ -1,8 +1,10 @@ import * as React from "react"; import TodoSubTasks from "./TodoSubTasks"; import renderMarkdown from "../markdownRender" +import moment from "moment"; function TodoItem(props: any) { + var dueDate = (props.dueDate==null)?"":("Due Date:"+(moment(props.dueDate).format(props.dueDateFormat))); var text_html = renderMarkdown(props.todo_text); var note_html = renderMarkdown(props.todo_notes); return ( @@ -11,7 +13,8 @@ function TodoItem(props: any) {

- + +
{dueDate}
) diff --git a/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx b/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx index ef74d92..0ba83d7 100644 --- a/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx +++ b/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx @@ -7,7 +7,7 @@ function TodoSubTasks(props: any) { let subtask_text = renderMarkdown(subtask.text); return (
- +

) diff --git a/src/view/Components/Taskview/Todoview/index.tsx b/src/view/Components/Taskview/Todoview/index.tsx index 682e2ef..a050528 100644 --- a/src/view/Components/Taskview/Todoview/index.tsx +++ b/src/view/Components/Taskview/Todoview/index.tsx @@ -21,7 +21,7 @@ export default function Index(props: any){ } return + onChange={props.onChange} onChangeChecklistItem={props.onChangeChecklistItem} completed={todo.completed} dueDate={todo.date} dueDateFormat={props.settings.dueDateFormat}/> } }) diff --git a/src/view/Components/Taskview/index.tsx b/src/view/Components/Taskview/index.tsx index 58f95fb..06d2874 100644 --- a/src/view/Components/Taskview/index.tsx +++ b/src/view/Components/Taskview/index.tsx @@ -24,13 +24,13 @@ export default function Index(props: any){ - + - + diff --git a/src/view/habiticaAPI.ts b/src/view/habiticaAPI.ts index 478211b..eae3ab8 100644 --- a/src/view/habiticaAPI.ts +++ b/src/view/habiticaAPI.ts @@ -54,3 +54,17 @@ export async function costReward(username: string, credentials: string, taskID: }) return(response) } + +export async function scoreChecklistItem(username: string, credentials: string, checklistItemID: string, taskID: string) { + const url = "https://habitica.com/api/v3/tasks/".concat(taskID).concat("/checklist/").concat(checklistItemID).concat("/score") + const response = fetch(url, { + method: 'POST', + headers: { + "Content-Type": "application/json", + "x-client": "278e719e-5f9c-43b1-9dba-8b73343dc062-HabiticaSync", + "x-api-user": username, + "x-api-key": credentials, + } + }) + return(response) +} \ No newline at end of file diff --git a/styles.css b/styles.css index 118caa0..c265c56 100644 --- a/styles.css +++ b/styles.css @@ -304,4 +304,8 @@ button { } .emoji { height: 1em; +} +.description>ul { + list-style-type: disc; + margin-left: 10% !important; } \ No newline at end of file From 932562ab2ec676efa2183d2e84a06dc7ba070eb2 Mon Sep 17 00:00:00 2001 From: ransurf Date: Fri, 14 Jan 2022 15:53:03 -0800 Subject: [PATCH 31/42] fix flexbox issue for empty tabs --- src/view/Components/Taskview/Dailiesview/index.tsx | 8 ++++++-- styles.css | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/view/Components/Taskview/Dailiesview/index.tsx b/src/view/Components/Taskview/Dailiesview/index.tsx index bf8b952..9785888 100644 --- a/src/view/Components/Taskview/Dailiesview/index.tsx +++ b/src/view/Components/Taskview/Dailiesview/index.tsx @@ -3,11 +3,14 @@ import DailyItem from "./DailyItem" import { Tab, Tabs, TabList, TabPanel } from "react-tabs"; export default function Index(props: any){ + if(props.dailys == undefined) { return
No Dailies Present
} else { + const notDueDailies = props.dailys.map((daily: any) => { + if (!daily.isDue) { let daily_notes = ''; let daily_subtasks = ''; @@ -23,6 +26,7 @@ export default function Index(props: any){ onChange={props.onChange} completed={daily.completed} onChangeChecklistItem={props.onChangeChecklistItem}/> } }) + const incompleteDailies = props.dailys.map((daily: any) => { if (!daily.completed&&daily.isDue) { let daily_notes = ''; @@ -42,7 +46,7 @@ export default function Index(props: any){ const completedDailies = props.dailys.map((daily: any) => { // if(daily.completed) // return - if (!daily.completed) { + if (daily.completed) { let daily_notes = ''; let daily_subtasks = ''; if (props.settings.showTaskDescription) { @@ -57,6 +61,7 @@ export default function Index(props: any){ onChange={props.onChange} completed={daily.completed} onChangeChecklistItem={props.onChangeChecklistItem}/> } }) + const display =
@@ -79,4 +84,3 @@ export default function Index(props: any){ } } - diff --git a/styles.css b/styles.css index c265c56..9cc820b 100644 --- a/styles.css +++ b/styles.css @@ -130,11 +130,12 @@ input[type=checkbox]:focus { display: flex; flex-direction: column; justify-content: flex-start; - align-items: center; + align-items: stretch; } #classDisplay { height: 100%; + width: 100%; } From e4d3c78a9feae6cfb0e05a0f977d0d966d199f86 Mon Sep 17 00:00:00 2001 From: SuperChamp234 Date: Sat, 15 Jan 2022 09:00:21 +0530 Subject: [PATCH 32/42] Small CSS changes to cron button --- styles.css | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/styles.css b/styles.css index 9cc820b..8bf78e5 100644 --- a/styles.css +++ b/styles.css @@ -295,6 +295,14 @@ button { margin-bottom: 10px; color: var(--text-normal) } +#cronButton { + margin: auto; + margin-bottom: 5px; + white-space: nowrap; + padding: 5px 5px; + color: var(--interactive-accent); + margin-right: auto; +} .subtask { display: flex; From 82780ba589a70e51d71ae62f08a9ffe4e6c08f6b Mon Sep 17 00:00:00 2001 From: SuperChamp234 Date: Sat, 15 Jan 2022 09:23:35 +0530 Subject: [PATCH 33/42] CSS changes for buttons, fixed numbers in stats --- src/view/App.tsx | 1 + src/view/Components/Statsview/index.tsx | 7 +++++-- styles.css | 10 ++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/view/App.tsx b/src/view/App.tsx index fdb748d..ed3e62c 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -34,6 +34,7 @@ class App extends React.Component { stats: { hp: 0, lvl: 0, + gold: 0, }, lastCron: "", }, diff --git a/src/view/Components/Statsview/index.tsx b/src/view/Components/Statsview/index.tsx index 6f5fc9e..506cae4 100644 --- a/src/view/Components/Statsview/index.tsx +++ b/src/view/Components/Statsview/index.tsx @@ -4,9 +4,12 @@ export default function Index(props: any) { return(
{/*
{props.user_data.profile.name}
*/} -
HP: {(props.user_data.stats.hp).toPrecision(3)}
+
HP: {numberWithCommas((props.user_data.stats.hp).toFixed(0))}
LEVEL: {props.user_data.stats.lvl}
-
GOLD: {(props.user_data.stats.gp).toPrecision(3)}
+
GOLD: {numberWithCommas(props.user_data.stats.gp.toFixed(2))}
); +} +function numberWithCommas(x: any) { + return x.toString().replace(/\B(? Date: Sat, 15 Jan 2022 09:45:50 +0530 Subject: [PATCH 34/42] Minor error fixes --- src/view/App.tsx | 1 - src/view/Components/Taskview/Dailiesview/DailyItem.tsx | 2 +- src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx | 2 +- src/view/Components/Taskview/Todoview/TodoSubTasks.tsx | 2 +- src/view/Components/Taskview/markdownRender.ts | 4 ++++ 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/view/App.tsx b/src/view/App.tsx index ed3e62c..9ae5826 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -86,7 +86,6 @@ class App extends React.Component { new Notice('Login Failed, Please check credentials and try again!'); } else { - console.log(result); this.setState({ isLoaded: true, user_data: result, diff --git a/src/view/Components/Taskview/Dailiesview/DailyItem.tsx b/src/view/Components/Taskview/Dailiesview/DailyItem.tsx index ac950ee..4443cd3 100644 --- a/src/view/Components/Taskview/Dailiesview/DailyItem.tsx +++ b/src/view/Components/Taskview/Dailiesview/DailyItem.tsx @@ -12,7 +12,7 @@ function DailyItem(props: any) {

{/* {console.log(props.checklist)} */} - +
diff --git a/src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx b/src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx index 71b2b09..09e4c99 100644 --- a/src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx +++ b/src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx @@ -7,7 +7,7 @@ function DailySubTasks(props: any) { const subtasks = props.subtasks.map((subtask: any) => { let subtask_text = renderMarkdown(subtask.text); return ( -
+

diff --git a/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx b/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx index 0ba83d7..92ab97a 100644 --- a/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx +++ b/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx @@ -6,7 +6,7 @@ function TodoSubTasks(props: any) { const subtasks = props.subtasks.map((subtask: any) => { let subtask_text = renderMarkdown(subtask.text); return ( -
+

diff --git a/src/view/Components/Taskview/markdownRender.ts b/src/view/Components/Taskview/markdownRender.ts index 9e95a59..e09aa1f 100644 --- a/src/view/Components/Taskview/markdownRender.ts +++ b/src/view/Components/Taskview/markdownRender.ts @@ -3,6 +3,10 @@ import markdownitEmoji from "markdown-it-emoji" import twemoji from "twemoji"; export default function renderMarkdown(markdown: string) { + //check if markdown is empty or not a string + if (markdown === "" || markdown === undefined) { + return ""; + } const md = new MarkdownIt({ html: true, breaks: true, From 615f3e8a78c76faa53e2bf20327498419f6f2cab Mon Sep 17 00:00:00 2001 From: SuperChamp234 Date: Sat, 15 Jan 2022 09:47:49 +0530 Subject: [PATCH 35/42] Bumped up the version no(1.0.0) --- manifest.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index c9b0afa..19dbe5b 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-habitica-integration", "name": "Habitica Sync", - "version": "0.9.15", + "version": "1.0.0", "minAppVersion": "0.9.12", "description": "This plugin helps integrate Habitica user tasks and stats into Obsidian", "author": "Leoh and Ran", diff --git a/package.json b/package.json index 870cee1..80f9f65 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-habitica-integration", - "version": "0.12.0", + "version": "1.0.0", "description": "This plugin allows for Habitica integration into Obsidian", "main": "main.js", "scripts": { From eadd8d9f8c6374bc2946bd648fe4edf6536ad0ac Mon Sep 17 00:00:00 2001 From: SuperChamp234 Date: Sat, 15 Jan 2022 11:23:00 +0530 Subject: [PATCH 36/42] fixed messages --- src/view/App.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/view/App.tsx b/src/view/App.tsx index 9ae5826..1406d23 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -181,7 +181,7 @@ class App extends React.Component { this.state.tasks.rewards.forEach((element: any) => { if (element.id == event.target.id) { if (element.id == target_id) { - this.sendReward(target_id, "down", "Cost!") + this.sendReward(target_id, "down", "Redeemed!") } } }) From 3d09f20d847557e329b2640d8c09db12def69404 Mon Sep 17 00:00:00 2001 From: ransurf <80801637+ransurf@users.noreply.github.com> Date: Fri, 14 Jan 2022 23:53:19 -0600 Subject: [PATCH 37/42] Update README.md --- README.md | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 85ab4b5..43497e5 100644 --- a/README.md +++ b/README.md @@ -9,29 +9,36 @@ The plugin's view is enabled by clicking on the "Open Habitica Pane" option in t To sync your Habitica account, go to the settings page of the plugin and enter your user ID and API token credentials. ## Features ### Pane View -[![Image from Gyazo](https://i.gyazo.com/4266d01941e71fef41819ea8a6b6592e.png)](https://gyazo.com/4266d01941e71fef41819ea8a6b6592e) -[![Image from Gyazo](https://i.gyazo.com/697a58b8e7ffd3df86a2944b6abbaa92.png)](https://gyazo.com/697a58b8e7ffd3df86a2944b6abbaa92) -- View stats (HP, XP, coins) -- View to do's, dailies, and habits - - Tab for active/completed tasks and dailies +#### View stats (HP, XP, coins) +#### Views +Task Information: +- Title, description, subtasks + - Markdown and emoji support -#### Check off tasks/dailies in the view, modify habit counters (+/-) -[![Image from Gyazo](https://i.gyazo.com/5759e12bc5267711c5e03485a6d72c2f.gif)](https://gyazo.com/5759e12bc5267711c5e03485a6d72c2f) -- Can uncheck completed habits/todos as shown above +Tabs: +- To Do's + - Active/Completed +- Dailies + - Due/Not Due/Completed + - [![Image from Gyazo](https://i.gyazo.com/1966b17f954dcffa954922570e860a06.png)](https://gyazo.com/1966b17f954dcffa954922570e860a06) +- Habits + - [![Image from Gyazo](https://i.gyazo.com/280494e620fc91548838d5b29a62652b.png)](https://gyazo.com/280494e620fc91548838d5b29a62652b) +- Rewards +#### Interactivity +- Check off tasks/dailies in the view + - Can uncheck completed habits/todos + - [![Image from Gyazo](https://i.gyazo.com/efb858cd9d54f9d9df936da1bd5858ed.gif)](https://gyazo.com/efb858cd9d54f9d9df936da1bd5858ed) +- modify habit counters (+/-) -## Settings +### Settings The following two inputs help fetch your user data to be displayed in the Obsidian view: - **Habitica User ID:** You can find this by clicking on the "User" icon in the top right of the Habitica webapp, "Settings", then "API" - **Habitica Token API:** You can find this by clicking on the "User" icon in the top right of the Habitica webapp, "Settings", then "API" - **Show Task Descriptions:** Toggles whether description/notes for tasks will be shown or not -- **Due date format:** Format in which the due date is displayed -- **Show Checklist items:** Toggles the checklist items for a task. - +- **Show Subtasks:** Toggles whether subtasks for to do's/dailies will be shown or not ## Roadmap -We will be implementing additional features including: -- Add/delete/customize tasks and habits *Feel free to support us and donate!* From b80d2f8dc1fcda2bcb6701209c24051929fd6803 Mon Sep 17 00:00:00 2001 From: SuperChamp234 Date: Sat, 15 Jan 2022 11:50:27 +0530 Subject: [PATCH 38/42] Bug: Indent CSS bug --- manifest.json | 2 +- styles.css | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/manifest.json b/manifest.json index 19dbe5b..96c0557 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-habitica-integration", "name": "Habitica Sync", - "version": "1.0.0", + "version": "1.0.1", "minAppVersion": "0.9.12", "description": "This plugin helps integrate Habitica user tasks and stats into Obsidian", "author": "Leoh and Ran", diff --git a/styles.css b/styles.css index 64be137..935ffb9 100644 --- a/styles.css +++ b/styles.css @@ -54,9 +54,6 @@ .description > ul { list-style-type: none; } -p { - margin: 0; -} .habit-text { text-align: left !important; From fc6506525cceafb8df5ffc0cf1786634eab70645 Mon Sep 17 00:00:00 2001 From: SuperChamp234 Date: Sat, 15 Jan 2022 12:26:29 +0530 Subject: [PATCH 39/42] Fixed Indent issue --- src/view/Components/Taskview/Todoview/index.tsx | 4 ++-- styles.css | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/view/Components/Taskview/Todoview/index.tsx b/src/view/Components/Taskview/Todoview/index.tsx index a050528..035b52e 100644 --- a/src/view/Components/Taskview/Todoview/index.tsx +++ b/src/view/Components/Taskview/Todoview/index.tsx @@ -36,10 +36,10 @@ export default function Index(props: any){ Completed -
    {incompleteTodos}
+
    {incompleteTodos}
-
    {completedTodos}
+
    {completedTodos}
diff --git a/styles.css b/styles.css index 935ffb9..90c9ec1 100644 --- a/styles.css +++ b/styles.css @@ -1,10 +1,6 @@ @import url('https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@1,300&display=swap'); @import url('https://fonts.googleapis.com/css2?family=Open Sans:ital,wght@0,400;1,100&family=Roboto&display=swap'); -* { - padding: 0; -} - .add-task-input { display: flex; } @@ -45,6 +41,7 @@ font-family: Roboto, sans-serif; font-weight: bold; font-size: 16px; + padding-left: 0; } .description { @@ -54,6 +51,9 @@ .description > ul { list-style-type: none; } +p { + margin: 0; +} .habit-text { text-align: left !important; @@ -320,4 +320,4 @@ button { .description>ul { list-style-type: disc; margin-left: 10% !important; -} \ No newline at end of file +} From 64d045bbc54b6bb80c9cc25d46284a541549c143 Mon Sep 17 00:00:00 2001 From: SuperChamp234 Date: Sat, 15 Jan 2022 12:27:25 +0530 Subject: [PATCH 40/42] upped version to 1.0.1 --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 96c0557..2ae5bfe 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-habitica-integration", "name": "Habitica Sync", - "version": "1.0.1", + "version": "1.0.2", "minAppVersion": "0.9.12", "description": "This plugin helps integrate Habitica user tasks and stats into Obsidian", "author": "Leoh and Ran", From 44893508dcba7b97afee9e3a88598fa60feebb7a Mon Sep 17 00:00:00 2001 From: Ethanil <69218171+Ethanil@users.noreply.github.com> Date: Wed, 13 Apr 2022 16:36:56 +0200 Subject: [PATCH 41/42] added all-Tab --- .../Components/Taskview/Dailiesview/index.tsx | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/view/Components/Taskview/Dailiesview/index.tsx b/src/view/Components/Taskview/Dailiesview/index.tsx index 9785888..db5944b 100644 --- a/src/view/Components/Taskview/Dailiesview/index.tsx +++ b/src/view/Components/Taskview/Dailiesview/index.tsx @@ -62,12 +62,30 @@ export default function Index(props: any){ } }) + const allDailies = props.dailys.map((daily: any) => { + // if(daily.completed) + // return + let daily_notes = ''; + let daily_subtasks = ''; + if (props.settings.showTaskDescription) { + daily_notes = daily.notes; + } + + if (props.settings.showSubTasks) { + daily_subtasks = daily.checklist; + } + return + }) + const display =
Active Completed Not Due + All
    {incompleteDailies}
@@ -78,6 +96,9 @@ export default function Index(props: any){
    {notDueDailies}
+ +
    {allDailies}
+
return(display); From c63f039b1110a848a7f1fafa482e54137f537e68 Mon Sep 17 00:00:00 2001 From: Ferrhat <30701390+Ferrhat@users.noreply.github.com> Date: Fri, 12 Jan 2024 00:23:48 +0100 Subject: [PATCH 42/42] Update packages --- package.json | 69 ++++++++++++++------------- rollup.config.js => rollup.config.mjs | 62 ++++++++++++------------ src/main.ts | 10 ++-- tsconfig.json | 1 + 4 files changed, 72 insertions(+), 70 deletions(-) rename rollup.config.js => rollup.config.mjs (95%) diff --git a/package.json b/package.json index 80f9f65..37371e6 100644 --- a/package.json +++ b/package.json @@ -4,47 +4,48 @@ "description": "This plugin allows for Habitica integration into Obsidian", "main": "main.js", "scripts": { - "dev": "rollup --config rollup.config.js -w", - "build": "rollup --config rollup.config.js --environment BUILD:production", + "dev": "rollup --config rollup.config.mjs -w", + "build": "rollup --config rollup.config.mjs --environment BUILD:production", "dev2": "obsidian-plugin dev src/main.ts" }, "keywords": [], "author": "Leonard and Ran", "license": "MIT", "devDependencies": { - "@rollup/plugin-commonjs": "^18.0.0", - "@rollup/plugin-json": "^4.1.0", - "@rollup/plugin-node-resolve": "^11.2.1", - "@rollup/plugin-typescript": "^8.2.1", - "@types/markdown-it": "^12.2.3", - "@types/markdown-it-emoji": "^2.0.2", - "@types/node": "^14.14.37", - "@types/node-emoji": "^1.8.1", - "@types/react": "^17.0.27", - "@types/react-dom": "^17.0.9", - "@types/react-tabs": "^2.3.3", - "@types/twemoji": "^12.1.2", - "css-loader": "^6.4.0", - "extract-text-webpack-plugin": "^2.1.2", - "obsidian": "^0.12.0", - "obsidian-plugin-cli": "^0.4.3", - "rollup": "^2.32.1", - "style-loader": "^3.3.0", - "tslib": "^2.2.0", - "typescript": "^4.2.4" + "@rollup/plugin-commonjs": "^25.0.7", + "@rollup/plugin-json": "^6.1.0", + "@rollup/plugin-node-resolve": "^15.2.3", + "@rollup/plugin-typescript": "^11.1.6", + "@types/markdown-it": "^13.0.7", + "@types/markdown-it-emoji": "^2.0.4", + "@types/node": "^20.11.0", + "@types/node-emoji": "^1.8.2", + "@types/react": "^18.2.47", + "@types/react-dom": "^18.2.18", + "@types/react-tabs": "^5.0.4", + "@types/twemoji": "^13.1.1", + "css-loader": "^6.9.0", + "mini-css-extract-plugin": "^2.7.7", + "obsidian": "^1.4.11", + "obsidian-plugin-cli": "^0.0.5", + "rollup": "^4.9.4", + "style-loader": "^3.3.4", + "tslib": "^2.6.2", + "typescript": "^5.3.3", + "webpack": "^5.89.0" }, "dependencies": { - "markdown-it": "^12.3.2", - "markdown-it-emoji": "^2.0.0", - "moment": "^2.29.1", - "node": "^16.10.0", - "node-emoji": "^1.11.0", - "node-fetch": "^3.0.0", - "react": "^17.0.2", - "react-dom": "^17.0.2", - "react-emoji-render": "^1.2.4", - "react-markdown": "^7.1.0", - "react-tabs": "^3.2.2", - "twemoji": "^13.1.0" + "markdown-it": "^14.0.0", + "markdown-it-emoji": "^2.0.2", + "moment": "^2.30.1", + "node": "^21.2.0", + "node-emoji": "^2.1.3", + "node-fetch": "^3.3.2", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "react-emoji-render": "^2.0.1", + "react-markdown": "^9.0.1", + "react-tabs": "^6.0.2", + "twemoji": "^14.0.2" } } diff --git a/rollup.config.js b/rollup.config.mjs similarity index 95% rename from rollup.config.js rename to rollup.config.mjs index 6da9767..1551460 100644 --- a/rollup.config.js +++ b/rollup.config.mjs @@ -1,32 +1,32 @@ -import typescript from '@rollup/plugin-typescript'; -import {nodeResolve} from '@rollup/plugin-node-resolve'; -import commonjs from '@rollup/plugin-commonjs'; -import json from '@rollup/plugin-json'; - -const isProd = (process.env.BUILD === 'production'); - -const banner = -`/* -THIS IS A GENERATED/BUNDLED FILE BY ROLLUP -if you want to view the source visit the plugins github repository -*/ -`; - -export default { - input: 'src/main.ts', - output: { - dir: '.', - sourcemap: 'inline', - sourcemapExcludeSources: isProd, - format: 'cjs', - exports: 'default', - banner, - }, - external: ['obsidian'], - plugins: [ - typescript(), - nodeResolve({browser: true}), - commonjs(), - json(), - ] +import typescript from '@rollup/plugin-typescript'; +import {nodeResolve} from '@rollup/plugin-node-resolve'; +import commonjs from '@rollup/plugin-commonjs'; +import json from '@rollup/plugin-json'; + +const isProd = (process.env.BUILD === 'production'); + +const banner = +`/* +THIS IS A GENERATED/BUNDLED FILE BY ROLLUP +if you want to view the source visit the plugins github repository +*/ +`; + +export default { + input: 'src/main.ts', + output: { + dir: '.', + sourcemap: 'inline', + sourcemapExcludeSources: isProd, + format: 'cjs', + exports: 'default', + banner, + }, + external: ['obsidian'], + plugins: [ + typescript(), + nodeResolve({browser: true}), + commonjs(), + json(), + ] }; \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 13cae87..b8eaff4 100644 --- a/src/main.ts +++ b/src/main.ts @@ -39,7 +39,7 @@ export default class HabiticaSync extends Plugin { this.activateView(); } }); - + } async loadSettings() { this.settings = Object.assign(DEFAULT_SETTINGS, await this.loadData()) @@ -50,22 +50,22 @@ export default class HabiticaSync extends Plugin { async onunload() { await this.view.onClose(); - + this.app.workspace .getLeavesOfType(VIEW_TYPE) .forEach((leaf) => leaf.detach()); } async activateView() { this.app.workspace.detachLeavesOfType(VIEW_TYPE); - + await this.app.workspace.getRightLeaf(false).setViewState({ type: VIEW_TYPE, active: true, }); - + this.app.workspace.revealLeaf( this.app.workspace.getLeavesOfType(VIEW_TYPE)[0] ); } - + } diff --git a/tsconfig.json b/tsconfig.json index 95b95d2..c6bbfcb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,6 +10,7 @@ "moduleResolution": "node", "importHelpers": true, "allowSyntheticDefaultImports": true, + "esModuleInterop": true, "lib": [ "dom", "es5",