-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ff2c5c
commit 90d938b
Showing
9 changed files
with
229 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
# Obsidian Timeline Schedule | ||
|
||
Inline timelines generated from human-readable todos e.g. 'Walk dog (30min)' in a ```schedule codeblock for [Obsidian](https://obsidian.md/) | ||
![Time Schedule example](./docs/time-schedule-demo-1.0.0.gif) | ||
|
||
Inline timelines generated from human-readable time strings, e.g. 'Walk dog (30min)' in a ```schedule codeblock. For [Obsidian](https://obsidian.md). | ||
|
||
## Styling | ||
|
||
See [styles.css](./styles.css) for a list of classes you can override. | ||
|
||
## Installing | ||
|
||
Search "Timeline Schedule" via the [built-in community plugin browser](https://help.obsidian.md/Extending+Obsidian/Community+plugins) in Obsidian. | ||
|
||
## Contributing | ||
## Contributing | ||
|
||
Please [open an issue](https://github.com/Ebonsignori/obsidian-timeline-schedule/issues/new) with any suggestions or bug reports. | ||
|
||
See [developer docs](docs/development.md) if you'd like to open a PR. | ||
See [developer docs](docs/development.md) if you'd like to open a PR. | ||
|
||
## Acknowledgements | ||
|
||
[The Obsidian team](https://obsidian.md/about) for creating a wonderful product :purple_heart: | ||
|
||
The implementation borrows from: | ||
|
||
- |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const matchBlockRegex = /^(\[.*\]:)(.*)/gi; | ||
export const matchHumanTimeRegex = /\(.*?\)(\s*?)$/gi; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { MarkdownRenderChild } from "obsidian"; | ||
import { matchBlockRegex } from "./constants"; | ||
|
||
export class PrettyRender extends MarkdownRenderChild { | ||
body: string; | ||
|
||
constructor(containerEl: HTMLElement, body: string) { | ||
super(containerEl); | ||
|
||
this.body = body; | ||
} | ||
|
||
onload() { | ||
const lines = this.body.trim().split("\n"); | ||
const listEl = this.containerEl.createEl("ul", { | ||
cls: "timeline-schedule-list", | ||
}); | ||
for (let i = 0; i < lines.length; i++) { | ||
const line = lines[i]; | ||
const [, block, contents] = | ||
[...line.matchAll(matchBlockRegex)]?.[0] || []; | ||
|
||
if (block && contents.trim()) { | ||
let listItemClassName = "timeline-schedule-list-item"; | ||
if (i === 0) { | ||
listItemClassName += " timeline-schedule-start"; | ||
} else if (i === lines.length - 1) { | ||
listItemClassName += " timeline-schedule-end"; | ||
} | ||
|
||
const listItem = this.containerEl.createEl("li", { | ||
cls: listItemClassName, | ||
}); | ||
|
||
listItem.appendChild( | ||
this.containerEl.createEl("span", { | ||
cls: "timeline-schedule-list-item-block", | ||
text: block | ||
.replace(/[[\]]/gi, "") | ||
.trim() | ||
.replace(/:$/, ""), | ||
}) | ||
); | ||
listItem.appendChild( | ||
this.containerEl.createEl("span", { | ||
cls: "timeline-schedule-list-item-contents", | ||
text: contents, | ||
}) | ||
); | ||
listEl.appendChild(listItem); | ||
} | ||
} | ||
this.containerEl.appendChild(listEl); | ||
} | ||
} |
Oops, something went wrong.