Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing issues #36

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
- [Create a task](#create-a-task)
- [Add normal attributes to a task](#add-normal-attributes-to-a-task)
- [Add special attributes to a task](#add-special-attributes-to-a-task)
- [](#)
- [Task Modification](#task-modification)
- [Installation](#installation)
- [Obsidian Plugins](#obsidian-plugins)
- [Manual](#manual)
- [Beta Testing](#beta-testing)
- [License](#license)
- [](#-1)
- [](#)

## Highlights

Expand All @@ -48,6 +48,8 @@ Obsidian-TaskCard is an Obsidian plugin designed to revolutionize your task mana

### Usage Preview



![quick-start](assets/Quick%20Start.gif)

### Add a task
Expand All @@ -59,16 +61,25 @@ Obsidian-TaskCard is an Obsidian plugin designed to revolutionize your task mana
![edit-a-task](assets/Modify%20A%20Task.gif)

### Query
- How to create a query;

![query](assets/Add%20A%20Query.gif)


## Usage

### Task Creation

Attributes | Addition | Example |
--- | --- | ---
Content | Task in markdown | `- [ ] some content` |
Tag | Tag in markdown | `- [ ] some content #tag` |
Description | Description in markdown (change line + indent) | `- [ ] some content \n - some description` |
Due Date | Special attribute: `due` | `%%* due: 2021-01-01 *%%` |
Project | Special attribute: `project` | `%%* project: project name *%%` |

#### Create a task
- Create a task in the normal way by typing `- [ ] some content`;
- To make it recognizable as a task card, add a tag (indicator tag in the settings, default to "#TaskCard") to the task.
- To make it recognizable as a task card, add a tag (indicator tag in the settings, default to "`#TaskCard`") to the task.

#### Add normal attributes to a task
Some attributes are native for a markdown task, we can add them to the task in the same way as normal markdown.
Expand All @@ -85,7 +96,17 @@ Some added ingredients for a task card, we can add them in a special way: `%%* k
- Due Date: Add a due date to the task. e.g. `%%* due: 2021-01-01 *%%`
- Project: Add a project to the task. e.g. `%%* project: project name *%%`

####
### Task Modification
- Tasks are shown in two view: preview and detailed views. Most attributes are editable in the detailed view.
- Add `description`, `due`, and `project`: click the ⋮ button in the bottom right corner.
- Add `tags`: click the + button.
- Add `priority`: right click the checkbox.
- Modify `description`, `due`: click on them.
- Modify `tags`: right click on the tag and select `edit`.
- Modify `project`: click on the project color dot.
- Modify `priority`: right click on the checkbox.



## Installation

Expand Down
Binary file added assets/Add A Query.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 14 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { App, Plugin } from 'obsidian';
import type { Editor, PluginManifest, Workspace, WorkspaceLeaf } from 'obsidian';
import type { Editor, EditorPosition, PluginManifest, Workspace, WorkspaceLeaf } from 'obsidian';
import type { TaskCardSettings } from './settings';
import { DefaultSettings, SettingStore, SettingsTab } from './settings';
import { logger } from './utils/log';
Expand Down Expand Up @@ -121,6 +121,19 @@ export default class TaskCardPlugin extends Plugin {
)
}
})

this.addCommand({
id: 'task-card-add-task',
name: 'Add Task',
editorCallback: (editor: Editor) => {
const editorPos: EditorPosition = editor.getCursor();
editor.replaceRange(
`\n- [ ] #${this.settings.parsingSettings.indicatorTag}\n`,
editorPos
)
editor.setCursor(editor.getCursor().line + 1, 6)
}
})
}

registerPostProcessors() {
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/postProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export { TaskItemSvelteAdapter } from './taskItemSvelteAdapter';

export type TaskDisplayMode = 'single-line' | 'multi-line';
export interface TaskDisplayParams {
mode: TaskDisplayMode | null;
mode?: TaskDisplayMode | null;
}


Expand Down
21 changes: 17 additions & 4 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,8 +308,10 @@ export class SettingsTab extends PluginSettingTab {
if (isEditMode) {
// Save changes
isEditMode = false;
logger.info(`Project updated: ${project.name}`);
new Notice(`[TaskCard] Project updated: ${project.name}.`);
// new Notice(`[TaskCard] Project updated: ${project.name}.`);
const originalProject: Project = this.plugin.projectModule.getProjectById(project.id);
this.announceProjectChange(originalProject, project);
this.plugin.projectModule.updateProject(project);
this.display();
} else if (isDeleteWarning) {
// Cancel delete warning
Expand All @@ -326,6 +328,17 @@ export class SettingsTab extends PluginSettingTab {
// Initialize the UI
updateUI();
}

announceProjectChange(originalProject: Project, newProject: Project) {
// if name changed, if color changed, if name + color changed
if (originalProject.name !== newProject.name && originalProject.color !== newProject.color) {
new Notice(`[TaskCard] Project name and color updated: ${newProject.name}.`);
} else if (originalProject.name !== newProject.name) {
new Notice(`[TaskCard] Project name updated: ${newProject.name}.`);
} else if (originalProject.color !== newProject.color) {
new Notice(`[TaskCard] Project color updated: ${newProject.color}.`);
}
}


cardParsingSettings() {
Expand Down Expand Up @@ -483,8 +496,8 @@ export class SettingsTab extends PluginSettingTab {
.addDropdown((dropdown) => {
dropdown
.addOptions({
'single-line': 'Single Line',
'multi-line': 'Multi Line'
'single-line': 'Preview Mode',
'multi-line': 'Detailed Mode'
})
.setValue(this.plugin.settings.displaySettings.defaultMode)
.onChange(async (value: string) => {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/Due.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
logger.error(e);
}
if (!newDue) {
new Notice(`Invalid due date: ${dueString}`);
new Notice(`[TaskCard] Invalid due date: ${dueString}`);
dueString = due ? due.string : '';
} else {
due = newDue;
Expand Down
14 changes: 11 additions & 3 deletions src/ui/TaskItem.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,21 @@
import TaskCard from "./TaskCard.svelte";
import TaskCardPlugin from "..";
import { ObsidianTaskSyncManager } from "../taskModule/taskSyncManager";
import { SettingStore } from "../settings";

export let taskSyncManager: ObsidianTaskSyncManager;
export let plugin: TaskCardPlugin;
// export let defaultParams: TaskDisplayParams;
let params: TaskDisplayParams;

params = { ...taskSyncManager.obsidianTask.metadata.taskDisplayParams };
let params: TaskDisplayParams = { ...taskSyncManager.obsidianTask.metadata.taskDisplayParams };

let defaultMode: TaskDisplayMode = 'single-line';
SettingStore.subscribe(settings => {
defaultMode = settings.displaySettings.defaultMode as TaskDisplayMode;
});

if (!('mode' in params)) {
params.mode = defaultMode
}

// Find the input element with class "task-list-item-checkbox" within taskItemEl
const inputElement = taskSyncManager.taskItemEl.querySelector('input.task-list-item-checkbox');
Expand Down