Skip to content

Commit 919b531

Browse files
committed
refactor(commands): reorganize quick capture command structure
- Remove global-quick-capture and full-featured-task-capture commands - Add new quick-capture command that directly opens metadata modal - Rename toggle-quick-capture to clarify it's for editor only - Add toggle-quick-capture-globally for global editor capture access - Update command translations to reflect new structure This improves command clarity by separating editor-specific from global quick capture functionality.
1 parent 1c172f1 commit 919b531

2 files changed

Lines changed: 51 additions & 57 deletions

File tree

src/index.ts

Lines changed: 48 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -487,60 +487,10 @@ export default class TaskProgressBarPlugin extends Plugin {
487487
await this.saveSettings();
488488
}
489489

490-
// Add a global command for quick capture from anywhere
490+
// Add command for quick capture with metadata
491491
this.addCommand({
492-
id: "global-quick-capture",
493-
name: t("Quick capture (Global)"),
494-
callback: () => {
495-
// Get the active leaf if available
496-
const activeLeaf =
497-
this.app.workspace.getActiveViewOfType(MarkdownView);
498-
499-
if (activeLeaf && activeLeaf.editor) {
500-
// If we're in a markdown editor, use the editor command
501-
const editorView = activeLeaf.editor.cm as EditorView;
502-
503-
// Import necessary functions dynamically to avoid circular dependencies
504-
505-
try {
506-
// Show the quick capture panel
507-
editorView.dispatch({
508-
effects: toggleQuickCapture.of(true),
509-
});
510-
} catch (e) {
511-
// No quick capture state found, try to add the extension first
512-
// This is a simplified approach and might not work in all cases
513-
this.registerEditorExtension([
514-
quickCaptureExtension(this.app, this),
515-
]);
516-
517-
// Try again after registering the extension
518-
setTimeout(() => {
519-
try {
520-
editorView.dispatch({
521-
effects: toggleQuickCapture.of(true),
522-
});
523-
} catch (e) {
524-
new Notice(
525-
t(
526-
"Could not open quick capture panel in the current editor"
527-
)
528-
);
529-
}
530-
}, 100);
531-
}
532-
} else {
533-
// No active markdown view, show a floating capture window instead
534-
// Create a simple modal with capture functionality
535-
new QuickCaptureModal(this.app, this).open();
536-
}
537-
},
538-
});
539-
540-
// Add command for full-featured task capture
541-
this.addCommand({
542-
id: "full-featured-task-capture",
543-
name: t("Task capture with metadata"),
492+
id: "quick-capture",
493+
name: t("Quick Capture"),
544494
callback: () => {
545495
// Create a modal with full task metadata options
546496
new QuickCaptureModal(this.app, this, {}, true).open();
@@ -888,7 +838,7 @@ export default class TaskProgressBarPlugin extends Plugin {
888838
// Add command for toggling quick capture panel in editor
889839
this.addCommand({
890840
id: "toggle-quick-capture",
891-
name: t("Toggle quick capture panel"),
841+
name: t("Toggle quick capture panel in editor"),
892842
editorCallback: (editor) => {
893843
const editorView = editor.cm as EditorView;
894844

@@ -910,6 +860,50 @@ export default class TaskProgressBarPlugin extends Plugin {
910860
},
911861
});
912862

863+
this.addCommand({
864+
id: "toggle-quick-capture-globally",
865+
name: t("Toggle quick capture panel in editor (Globally)"),
866+
callback: () => {
867+
const activeLeaf =
868+
this.app.workspace.getActiveViewOfType(MarkdownView);
869+
870+
if (activeLeaf && activeLeaf.editor) {
871+
// If we're in a markdown editor, use the editor command
872+
const editorView = activeLeaf.editor.cm as EditorView;
873+
874+
// Import necessary functions dynamically to avoid circular dependencies
875+
876+
try {
877+
// Show the quick capture panel
878+
editorView.dispatch({
879+
effects: toggleQuickCapture.of(true),
880+
});
881+
} catch (e) {
882+
// No quick capture state found, try to add the extension first
883+
// This is a simplified approach and might not work in all cases
884+
this.registerEditorExtension([
885+
quickCaptureExtension(this.app, this),
886+
]);
887+
888+
// Try again after registering the extension
889+
setTimeout(() => {
890+
try {
891+
editorView.dispatch({
892+
effects: toggleQuickCapture.of(true),
893+
});
894+
} catch (e) {
895+
new Notice(
896+
t(
897+
"Could not open quick capture panel in the current editor"
898+
)
899+
);
900+
}
901+
}, 100);
902+
}
903+
}
904+
},
905+
});
906+
913907
// Workflow commands
914908
if (this.settings.workflow.enableWorkflow) {
915909
this.addCommand({

src/translations/locale/en.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,8 @@ const translations = {
334334
"Move direct incomplete subtasks to another file",
335335
"moved on": "moved on",
336336
"Set priority": "Set priority",
337-
"Toggle quick capture panel": "Toggle quick capture panel",
338-
"Quick capture (Global)": "Quick capture (Global)",
337+
"Toggle quick capture panel in editor": "Toggle quick capture panel in editor",
338+
"Quick Capture": "Quick Capture",
339339
"Toggle task filter panel": "Toggle task filter panel",
340340
"Filter Mode": "Filter Mode",
341341
"Choose whether to include or exclude tasks that match the filters":
@@ -859,7 +859,7 @@ const translations = {
859859
"No tasks with the selected tags": "No tasks with the selected tags",
860860
"Select a tag to see related tasks": "Select a tag to see related tasks",
861861
"Open Task Genius view": "Open Task Genius view",
862-
"Task capture with metadata": "Task capture with metadata",
862+
"Minimal Quick Capture": "Minimal Quick Capture",
863863
"Refresh task index": "Refresh task index",
864864
"Refreshing task index...": "Refreshing task index...",
865865
"Task index refreshed": "Task index refreshed",

0 commit comments

Comments
 (0)