mirror of
https://github.com/guicattani/obsidian-countdown-to.git
synced 2026-07-22 05:42:39 +00:00
Add new line support, bugfixes
Fixed a bug where the container was duplicated on error Removed the default background for upcoming since it can't adhere to the user theme
This commit is contained in:
parent
e6f1a0dffb
commit
0246016b48
4 changed files with 18 additions and 6 deletions
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "countdown-to",
|
||||
"name": "Countdown To",
|
||||
"version": "1.4.0",
|
||||
"version": "1.4.1",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "Create countdown progress bars in your notes",
|
||||
"author": "Gui Cattani",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "obsidian-countdown-to",
|
||||
"version": "1.3.0",
|
||||
"version": "1.4.1",
|
||||
"description": "Create countdown progress bars in your notes",
|
||||
"main": "main.js",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ export class CountdownToMarkdownRenderChild extends MarkdownRenderChild {
|
|||
const isUpcoming = startDate > DateTime.now();
|
||||
if (isUpcoming) {
|
||||
containerEl.addClass('countdown-to-upcoming');
|
||||
|
||||
document.documentElement.style.setProperty(
|
||||
'--countdown-to-upcoming-bg',
|
||||
this.plugin.settings.defaultUpcomingBackgroundColor
|
||||
|
|
@ -113,7 +114,12 @@ export class CountdownToMarkdownRenderChild extends MarkdownRenderChild {
|
|||
|
||||
if (params.title) {
|
||||
const titleEl = containerEl.createDiv({ cls: 'countdown-to-title' });
|
||||
titleEl.setText(params.title);
|
||||
const titleLines = params.title.split('\\n');
|
||||
titleLines.forEach(line => {
|
||||
const lineEl = titleEl.createDiv({ cls: 'countdown-to-title-line' });
|
||||
lineEl.setText(line);
|
||||
});
|
||||
|
||||
containerEl.prepend(titleEl);
|
||||
}
|
||||
|
||||
|
|
@ -149,6 +155,7 @@ export class CountdownToMarkdownRenderChild extends MarkdownRenderChild {
|
|||
}
|
||||
|
||||
} catch (error) {
|
||||
this.containerEl.empty();
|
||||
const containerEl = this.containerEl.createDiv({ cls: ['countdown-to-plugin', 'countdown-to-container'] });
|
||||
containerEl.setText('Error rendering countdown to: ' + error.message);
|
||||
}
|
||||
|
|
@ -246,7 +253,12 @@ export class CountdownToMarkdownRenderChild extends MarkdownRenderChild {
|
|||
infoText = infoText.replace(/{total}/g, this.formatDuration(totalDuration))
|
||||
}
|
||||
|
||||
countdownTo.infoEl.setText(infoText);
|
||||
countdownTo.infoEl.empty();
|
||||
const infoLines = infoText.split('\\n');
|
||||
infoLines.forEach(line => {
|
||||
const lineEl = countdownTo.infoEl.createDiv({ cls: 'countdown-to-info-line' });
|
||||
lineEl.setText(line);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ export interface CountdownToSettings {
|
|||
export const DEFAULT_SETTINGS: CountdownToSettings = {
|
||||
defaultBarColor: '#4CAF50',
|
||||
defaultTrailColor: '#e0e0e0',
|
||||
defaultUpcomingBackgroundColor: '#e3e3e3',
|
||||
defaultUpcomingBackgroundColor: '#gggggg', // invalid color so that we know the user didn't set it
|
||||
defaultBarType: 'Line',
|
||||
defaultProgressType: 'Forward',
|
||||
defaultOnCompleteText: '{title} is done!',
|
||||
|
|
@ -202,7 +202,7 @@ export class CountdownToSettingTab extends PluginSettingTab {
|
|||
|
||||
new Setting(containerEl)
|
||||
.setName('Default upcoming background color')
|
||||
.setDesc('Default background color for countdowns that are upcoming (start date in the future)')
|
||||
.setDesc('Default background color for countdowns that are upcoming (start date in the future). Needs manual reload of notes to take effect.')
|
||||
.addColorPicker(color => color
|
||||
.setValue(this.plugin.settings.defaultUpcomingBackgroundColor)
|
||||
.onChange(async (value) => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue