mirror of
https://github.com/devonthesofa/obsidian-note-status.git
synced 2026-07-22 05:45:04 +00:00
Merge branch 'master' into feature/templates-marketplace
This commit is contained in:
commit
76a2e2bac2
8 changed files with 191 additions and 66 deletions
|
|
@ -1,7 +1,8 @@
|
|||
import { PluginSettings } from "@/types/pluginSettings";
|
||||
import React from "react";
|
||||
import React, { useMemo } from "react";
|
||||
import { SettingItem } from "./SettingItem";
|
||||
import { FrontmatterMappingsSettings } from "./FrontmatterMappingsSettings";
|
||||
import { BaseNoteStatusService } from "@/core/noteStatusService";
|
||||
|
||||
export type Props = {
|
||||
settings: PluginSettings;
|
||||
|
|
@ -9,10 +10,51 @@ export type Props = {
|
|||
};
|
||||
|
||||
export const BehaviourSettings: React.FC<Props> = ({ settings, onChange }) => {
|
||||
const availableStatuses = useMemo(() => {
|
||||
return BaseNoteStatusService.getAllAvailableStatuses();
|
||||
}, [
|
||||
settings.templates,
|
||||
settings.customStatuses,
|
||||
settings.enabledTemplates,
|
||||
]);
|
||||
|
||||
return (
|
||||
<div>
|
||||
<h3>Status tag</h3>
|
||||
|
||||
<SettingItem
|
||||
name="Default status for new notes"
|
||||
description="Automatically apply this status to newly created notes."
|
||||
>
|
||||
<select
|
||||
value={settings.defaultStatusForNewNotes || ""}
|
||||
onChange={(e) => {
|
||||
const value = e.target.value;
|
||||
onChange(
|
||||
"defaultStatusForNewNotes",
|
||||
value === "" ? null : value,
|
||||
);
|
||||
}}
|
||||
>
|
||||
<option value="">None</option>
|
||||
{availableStatuses.map((status) => {
|
||||
const identifier =
|
||||
BaseNoteStatusService.formatStatusIdentifier({
|
||||
templateId: status.templateId,
|
||||
name: status.name,
|
||||
});
|
||||
const displayName = status.templateId
|
||||
? `${status.name} (${status.templateId})`
|
||||
: status.name;
|
||||
return (
|
||||
<option key={identifier} value={identifier}>
|
||||
{displayName}
|
||||
</option>
|
||||
);
|
||||
})}
|
||||
</select>
|
||||
</SettingItem>
|
||||
|
||||
<SettingItem
|
||||
name="Enable multiple statuses"
|
||||
description="Allow notes to have multiple statuses at the same time"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import React, { useEffect, useState } from "react";
|
||||
import { Notice } from "obsidian";
|
||||
import { PluginSettings } from "@/types/pluginSettings";
|
||||
import { TemplateSettings } from "./TemplateSettings";
|
||||
import { BehaviourSettings } from "./BehaviourSettings";
|
||||
|
|
@ -51,6 +52,13 @@ const SettingsUI: React.FC<Props> = ({ settings, onChange }) => {
|
|||
onChange(key, value);
|
||||
};
|
||||
|
||||
const handleSupportClick = (url: string, label: string) => {
|
||||
window.open(url);
|
||||
navigator.clipboard.writeText(url).then(() => {
|
||||
new Notice(`Copied ${label} URL to clipboard!`);
|
||||
});
|
||||
};
|
||||
|
||||
const sections: SectionDefinition[] = [
|
||||
{
|
||||
id: "templates-statuses",
|
||||
|
|
@ -217,35 +225,64 @@ const SettingsUI: React.FC<Props> = ({ settings, onChange }) => {
|
|||
you review notes, surface statuses, and keep storage tidy.
|
||||
</p>
|
||||
<div className="note-status-settings__support">
|
||||
<a
|
||||
href="https://paypal.me/aleixsoler"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="note-status-settings__badge"
|
||||
<button
|
||||
className="note-status-settings__support-link"
|
||||
onClick={() =>
|
||||
handleSupportClick(
|
||||
"https://paypal.me/aleixsoler",
|
||||
"PayPal",
|
||||
)
|
||||
}
|
||||
>
|
||||
<img
|
||||
src="https://img.shields.io/badge/PayPal-00457C?style=for-the-badge&logo=paypal&logoColor=white"
|
||||
alt="Support via PayPal"
|
||||
alt="PayPal"
|
||||
style={{ height: "20px" }}
|
||||
/>
|
||||
</a>
|
||||
<a
|
||||
href="https://buymeacoffee.com/aleixsoler"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
className="note-status-settings__badge"
|
||||
<span className="note-status-settings__support-link-label">
|
||||
Support via PayPal
|
||||
</span>
|
||||
<span className="note-status-settings__support-link-url">
|
||||
paypal.me/aleixsoler
|
||||
</span>
|
||||
</button>
|
||||
<button
|
||||
className="note-status-settings__support-link"
|
||||
onClick={() =>
|
||||
handleSupportClick(
|
||||
"https://buymeacoffee.com/aleixsoler",
|
||||
"Buy Me a Coffee",
|
||||
)
|
||||
}
|
||||
>
|
||||
<img
|
||||
src="https://img.shields.io/badge/Buy%20Me%20a%20Coffee-FFDD00?style=for-the-badge&logo=buy-me-a-coffee&logoColor=black"
|
||||
alt="Buy me a coffee"
|
||||
style={{ height: "20px" }}
|
||||
/>
|
||||
</a>
|
||||
<a
|
||||
href="https://github.com/devonthesofa/obsidian-note-status"
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
<span className="note-status-settings__support-link-label">
|
||||
Buy me a coffee
|
||||
</span>
|
||||
<span className="note-status-settings__support-link-url">
|
||||
buymeacoffee.com/aleixsoler
|
||||
</span>
|
||||
</button>
|
||||
<button
|
||||
className="note-status-settings__support-link"
|
||||
onClick={() =>
|
||||
handleSupportClick(
|
||||
"https://github.com/devonthesofa/obsidian-note-status",
|
||||
"GitHub",
|
||||
)
|
||||
}
|
||||
>
|
||||
Star the project on GitHub
|
||||
</a>
|
||||
<span className="note-status-settings__support-link-label">
|
||||
Star on GitHub
|
||||
</span>
|
||||
<span className="note-status-settings__support-link-url">
|
||||
github.com/devonthesofa/obsidian-note-status
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -64,4 +64,5 @@ export const DEFAULT_PLUGIN_SETTINGS: PluginSettings = {
|
|||
],
|
||||
enableNonMarkdownSync: false,
|
||||
nonMarkdownSyncPath: "_note-status-data.json",
|
||||
defaultStatusForNewNotes: null,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ export const SETTINGS_GROUPS: Record<SyncGroup, (keyof PluginSettings)[]> = {
|
|||
"singleStatusStorageMode",
|
||||
"strictStatuses",
|
||||
"enableStatusOverviewPopup",
|
||||
"defaultStatusForNewNotes",
|
||||
],
|
||||
storage: [
|
||||
"tagPrefix",
|
||||
|
|
|
|||
41
main.tsx
41
main.tsx
|
|
@ -3,7 +3,10 @@ import StatusBarIntegration from "integrations/status-bar/status-bar";
|
|||
import eventBus from "core/eventBus";
|
||||
import { PluginSettingIntegration } from "./integrations/settings/pluginSettings";
|
||||
import settingsService from "./core/settingsService";
|
||||
import { BaseNoteStatusService } from "./core/noteStatusService";
|
||||
import {
|
||||
BaseNoteStatusService,
|
||||
NoteStatusService,
|
||||
} from "./core/noteStatusService";
|
||||
import { StatusModalIntegration } from "./integrations/modals/statusModalIntegration";
|
||||
import ContextMenuIntegration from "./integrations/context-menu/contextMenuIntegration";
|
||||
import { FileExplorerIntegration } from "./integrations/file-explorer/file-explorer-integration";
|
||||
|
|
@ -240,6 +243,42 @@ export default class NoteStatusPlugin extends Plugin {
|
|||
"main-status-popup-setting-subscriptor",
|
||||
);
|
||||
|
||||
this.registerEvent(
|
||||
this.app.vault.on("create", async (file) => {
|
||||
if (
|
||||
file instanceof TFile &&
|
||||
file.extension === "md" &&
|
||||
settingsService.settings.defaultStatusForNewNotes
|
||||
) {
|
||||
// Wait a bit to ensure metadata is processed or templates are applied
|
||||
setTimeout(async () => {
|
||||
// Ensure file still exists
|
||||
if (!this.app.vault.getAbstractFileByPath(file.path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const noteStatusService = new NoteStatusService(file);
|
||||
// Populate statuses to see if it already has any
|
||||
noteStatusService.populateStatuses();
|
||||
|
||||
const groupedStatuses =
|
||||
noteStatusService.getStatusesByAllKeys();
|
||||
const hasStatuses = Object.values(groupedStatuses).some(
|
||||
(statuses) => statuses.length > 0,
|
||||
);
|
||||
|
||||
if (!hasStatuses) {
|
||||
await noteStatusService.addStatus(
|
||||
settingsService.settings.tagPrefix,
|
||||
settingsService.settings
|
||||
.defaultStatusForNewNotes as string,
|
||||
);
|
||||
}
|
||||
}, 500); // Increased delay to allow more time for templates
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
this.registerEvent(
|
||||
this.app.vault.on("rename", (file) => {
|
||||
if (file instanceof TFile) {
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -23,60 +23,63 @@
|
|||
|
||||
.note-status-settings__support {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--size-4-2);
|
||||
flex-direction: column;
|
||||
gap: var(--size-4-1);
|
||||
margin-top: var(--size-4-1);
|
||||
}
|
||||
|
||||
.note-status-settings__badge {
|
||||
padding: 0;
|
||||
border: none;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.note-status-settings__badge img {
|
||||
display: block;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.note-status-settings__badge:hover {
|
||||
background: transparent;
|
||||
border-color: transparent;
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.note-status-settings__badge:focus-visible {
|
||||
outline: 2px solid var(--interactive-accent);
|
||||
outline-offset: 2px;
|
||||
border-radius: var(--radius-s);
|
||||
}
|
||||
|
||||
.note-status-settings__support a:not(.note-status-settings__badge) {
|
||||
display: inline-flex;
|
||||
.note-status-settings__support-link {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: var(--size-2-2);
|
||||
padding: var(--size-2-3) var(--size-4-2);
|
||||
border-radius: var(--radius-s);
|
||||
border: 1px solid var(--background-modifier-border);
|
||||
text-decoration: none;
|
||||
color: var(--text-normal);
|
||||
gap: var(--size-4-2);
|
||||
padding: var(--size-2-3) var(--size-4-3);
|
||||
background: var(--background-primary);
|
||||
transition:
|
||||
background var(--anim-duration-fast) ease,
|
||||
border-color var(--anim-duration-fast) ease,
|
||||
transform var(--anim-duration-fast) ease;
|
||||
border: 1px solid var(--background-modifier-border);
|
||||
border-radius: var(--radius-m);
|
||||
color: var(--text-normal);
|
||||
font-size: var(--font-ui-small);
|
||||
cursor: pointer;
|
||||
transition: all var(--anim-duration-fast) ease;
|
||||
text-align: left;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.note-status-settings__support a:not(.note-status-settings__badge):hover {
|
||||
.note-status-settings__support-link img {
|
||||
display: block;
|
||||
border-radius: var(--radius-s);
|
||||
}
|
||||
|
||||
.note-status-settings__support-link:hover {
|
||||
background: var(--background-modifier-hover);
|
||||
border-color: var(--interactive-accent);
|
||||
transform: translateY(-1px);
|
||||
transform: translateX(4px);
|
||||
}
|
||||
|
||||
.note-status-settings__support
|
||||
a:not(.note-status-settings__badge):focus-visible {
|
||||
outline: 2px solid var(--interactive-accent);
|
||||
outline-offset: 2px;
|
||||
.note-status-settings__support-link .status-icon {
|
||||
color: var(--interactive-accent);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.note-status-settings__support-link-label {
|
||||
font-weight: var(--font-medium);
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.note-status-settings__support-link-url {
|
||||
font-family: var(--font-monospace);
|
||||
font-size: 0.85em;
|
||||
color: var(--text-muted);
|
||||
margin-left: auto;
|
||||
opacity: 0.7;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.note-status-settings__support-link:hover
|
||||
.note-status-settings__support-link-url {
|
||||
color: var(--text-accent);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.note-status-section {
|
||||
|
|
@ -88,6 +91,7 @@
|
|||
}
|
||||
|
||||
.note-status-section__header {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
|
|
|
|||
|
|
@ -85,5 +85,6 @@ export type PluginSettings = {
|
|||
syncGroups: SyncGroup[]; // Selected groups of settings to synchronize
|
||||
enableNonMarkdownSync: boolean; // Whether to sync non-markdown statuses to a vault file
|
||||
nonMarkdownSyncPath: string; // Path to the non-markdown sync file
|
||||
defaultStatusForNewNotes: string | null; // Default status to apply to new notes
|
||||
[key: string]: unknown;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue