mirror of
https://github.com/devonthesofa/obsidian-note-status.git
synced 2026-07-22 12:30:24 +00:00
chore: remove insert metadata command; no status icon
This commit is contained in:
parent
a2a4a796dc
commit
bdb8ce457f
6 changed files with 32 additions and 67 deletions
|
|
@ -23,7 +23,15 @@ export const StatusBar: FC<Props> = ({
|
|||
|
||||
if (!hasStatuses) {
|
||||
if (hideIfNotStatuses) return null;
|
||||
return <span className="status-bar-item">❓</span>;
|
||||
return (
|
||||
<span
|
||||
className="status-bar-item mod-clickable"
|
||||
onClick={() => onStatusClick({ name: "", icon: "" })}
|
||||
style={{ cursor: "pointer" }}
|
||||
>
|
||||
No status
|
||||
</span>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ export type DashboardAction =
|
|||
| "open-grouped-view"
|
||||
| "find-unassigned"
|
||||
| "change-status"
|
||||
| "insert-metadata"
|
||||
| "cycle-status"
|
||||
| "clear-status"
|
||||
| "copy-status"
|
||||
|
|
@ -88,14 +87,6 @@ export const QuickActionsPanel = ({
|
|||
>
|
||||
📝 Change Status
|
||||
</button>
|
||||
<button
|
||||
className="quick-action-btn"
|
||||
onClick={() => onAction("insert-metadata")}
|
||||
disabled={!hasCurrentFile}
|
||||
title="Insert status metadata in editor"
|
||||
>
|
||||
📝 Insert Metadata
|
||||
</button>
|
||||
<button
|
||||
className="quick-action-btn"
|
||||
onClick={() => onAction("cycle-status")}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { Plugin, Notice, Editor, MarkdownView, TFile, App } from "obsidian";
|
||||
import { Plugin, Notice, TFile, App } from "obsidian";
|
||||
import { NoteStatusService, BaseNoteStatusService } from "./noteStatusService";
|
||||
import settingsService from "./settingsService";
|
||||
import eventBus from "./eventBus";
|
||||
|
|
@ -40,42 +40,6 @@ export class CommandsService {
|
|||
});
|
||||
this.registeredCommands.add("change-status");
|
||||
|
||||
// Insert status metadata
|
||||
this.plugin.addCommand({
|
||||
id: "insert-status-metadata",
|
||||
name: "Insert status metadata",
|
||||
editorCheckCallback: (
|
||||
checking: boolean,
|
||||
editor: Editor,
|
||||
view: MarkdownView,
|
||||
) => {
|
||||
if (!view.file) return false;
|
||||
|
||||
const cache = this.plugin.app.metadataCache.getFileCache(
|
||||
view.file,
|
||||
);
|
||||
const frontmatter = cache?.frontmatter;
|
||||
|
||||
// Check if any frontmatter property starts with tagPrefix
|
||||
let hasFronttmatter = false;
|
||||
if (frontmatter) {
|
||||
hasFronttmatter = Object.keys(frontmatter).some((key) =>
|
||||
key.startsWith(settingsService.settings.tagPrefix),
|
||||
);
|
||||
}
|
||||
|
||||
if (!checking && !hasFronttmatter) {
|
||||
BaseNoteStatusService.insertStatusMetadataInEditor(
|
||||
view.file,
|
||||
).then(() => {
|
||||
new Notice("Status metadata inserted");
|
||||
});
|
||||
}
|
||||
return !hasFronttmatter;
|
||||
},
|
||||
});
|
||||
this.registeredCommands.add("insert-status-metadata");
|
||||
|
||||
// Cycle through statuses
|
||||
this.plugin.addCommand({
|
||||
id: "cycle-status",
|
||||
|
|
|
|||
|
|
@ -38,20 +38,20 @@ export abstract class BaseNoteStatusService {
|
|||
return availableStatuses;
|
||||
}
|
||||
|
||||
static async insertStatusMetadataInEditor(file: TFile): Promise<void> {
|
||||
const tagPrefix = settingsService.settings.tagPrefix;
|
||||
|
||||
await BaseNoteStatusService.app.fileManager.processFrontMatter(
|
||||
file,
|
||||
(frontmatter) => {
|
||||
const noteStatusFrontmatter =
|
||||
(frontmatter?.[tagPrefix] as string[]) || [];
|
||||
if (!noteStatusFrontmatter.length) {
|
||||
frontmatter[tagPrefix] = [];
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
// static async insertStatusMetadataInEditor(file: TFile): Promise<void> {
|
||||
// const tagPrefix = settingsService.settings.tagPrefix;
|
||||
//
|
||||
// await BaseNoteStatusService.app.fileManager.processFrontMatter(
|
||||
// file,
|
||||
// (frontmatter) => {
|
||||
// const noteStatusFrontmatter =
|
||||
// (frontmatter?.[tagPrefix] as string[]) || [];
|
||||
// if (!noteStatusFrontmatter.length) {
|
||||
// frontmatter[tagPrefix] = [];
|
||||
// }
|
||||
// },
|
||||
// );
|
||||
// }
|
||||
|
||||
protected statusNameToObject(statusName: NoteStatusType["name"]) {
|
||||
const availableStatuses =
|
||||
|
|
@ -204,6 +204,14 @@ export class NoteStatusService extends BaseNoteStatusService {
|
|||
frontmatter[frontmatterTagName] = [statusIdentifier];
|
||||
added = true;
|
||||
} else {
|
||||
// Ensure frontmatter property exists as an array
|
||||
if (
|
||||
!frontmatter[frontmatterTagName] ||
|
||||
!Array.isArray(frontmatter[frontmatterTagName])
|
||||
) {
|
||||
frontmatter[frontmatterTagName] = [];
|
||||
}
|
||||
|
||||
const i = noteStatusFrontmatter.findIndex(
|
||||
(statusName: string) => statusName === statusIdentifier,
|
||||
);
|
||||
|
|
|
|||
|
|
@ -169,11 +169,6 @@ export class StatusDashboardView extends ItemView {
|
|||
"note-status:change-status",
|
||||
);
|
||||
break;
|
||||
case "insert-metadata":
|
||||
appWithCommands.commands.executeCommandById(
|
||||
"note-status:insert-status-metadata",
|
||||
);
|
||||
break;
|
||||
case "cycle-status":
|
||||
appWithCommands.commands.executeCommandById(
|
||||
"note-status:cycle-status",
|
||||
|
|
|
|||
|
|
@ -177,7 +177,6 @@ All commands available via Command Palette:
|
|||
- `Open status pane` - Show status sidebar
|
||||
- `Change status of current note` - Open dropdown
|
||||
- `Add status to current note` - Add mode dropdown
|
||||
- `Insert status metadata` - Add frontmatter
|
||||
- `Cycle to next status` - Rotate through statuses
|
||||
- `Clear status` - Set to unknown
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue