mirror of
https://github.com/taskgenius/taskgenius-plugin.git
synced 2026-07-22 06:40:25 +00:00
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.
This commit is contained in:
parent
ff006034bb
commit
cd36c228cd
2 changed files with 51 additions and 57 deletions
102
src/index.ts
102
src/index.ts
|
|
@ -487,60 +487,10 @@ export default class TaskProgressBarPlugin extends Plugin {
|
|||
await this.saveSettings();
|
||||
}
|
||||
|
||||
// Add a global command for quick capture from anywhere
|
||||
// Add command for quick capture with metadata
|
||||
this.addCommand({
|
||||
id: "global-quick-capture",
|
||||
name: t("Quick capture (Global)"),
|
||||
callback: () => {
|
||||
// Get the active leaf if available
|
||||
const activeLeaf =
|
||||
this.app.workspace.getActiveViewOfType(MarkdownView);
|
||||
|
||||
if (activeLeaf && activeLeaf.editor) {
|
||||
// If we're in a markdown editor, use the editor command
|
||||
const editorView = activeLeaf.editor.cm as EditorView;
|
||||
|
||||
// Import necessary functions dynamically to avoid circular dependencies
|
||||
|
||||
try {
|
||||
// Show the quick capture panel
|
||||
editorView.dispatch({
|
||||
effects: toggleQuickCapture.of(true),
|
||||
});
|
||||
} catch (e) {
|
||||
// No quick capture state found, try to add the extension first
|
||||
// This is a simplified approach and might not work in all cases
|
||||
this.registerEditorExtension([
|
||||
quickCaptureExtension(this.app, this),
|
||||
]);
|
||||
|
||||
// Try again after registering the extension
|
||||
setTimeout(() => {
|
||||
try {
|
||||
editorView.dispatch({
|
||||
effects: toggleQuickCapture.of(true),
|
||||
});
|
||||
} catch (e) {
|
||||
new Notice(
|
||||
t(
|
||||
"Could not open quick capture panel in the current editor"
|
||||
)
|
||||
);
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
} else {
|
||||
// No active markdown view, show a floating capture window instead
|
||||
// Create a simple modal with capture functionality
|
||||
new QuickCaptureModal(this.app, this).open();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
// Add command for full-featured task capture
|
||||
this.addCommand({
|
||||
id: "full-featured-task-capture",
|
||||
name: t("Task capture with metadata"),
|
||||
id: "quick-capture",
|
||||
name: t("Quick Capture"),
|
||||
callback: () => {
|
||||
// Create a modal with full task metadata options
|
||||
new QuickCaptureModal(this.app, this, {}, true).open();
|
||||
|
|
@ -888,7 +838,7 @@ export default class TaskProgressBarPlugin extends Plugin {
|
|||
// Add command for toggling quick capture panel in editor
|
||||
this.addCommand({
|
||||
id: "toggle-quick-capture",
|
||||
name: t("Toggle quick capture panel"),
|
||||
name: t("Toggle quick capture panel in editor"),
|
||||
editorCallback: (editor) => {
|
||||
const editorView = editor.cm as EditorView;
|
||||
|
||||
|
|
@ -910,6 +860,50 @@ export default class TaskProgressBarPlugin extends Plugin {
|
|||
},
|
||||
});
|
||||
|
||||
this.addCommand({
|
||||
id: "toggle-quick-capture-globally",
|
||||
name: t("Toggle quick capture panel in editor (Globally)"),
|
||||
callback: () => {
|
||||
const activeLeaf =
|
||||
this.app.workspace.getActiveViewOfType(MarkdownView);
|
||||
|
||||
if (activeLeaf && activeLeaf.editor) {
|
||||
// If we're in a markdown editor, use the editor command
|
||||
const editorView = activeLeaf.editor.cm as EditorView;
|
||||
|
||||
// Import necessary functions dynamically to avoid circular dependencies
|
||||
|
||||
try {
|
||||
// Show the quick capture panel
|
||||
editorView.dispatch({
|
||||
effects: toggleQuickCapture.of(true),
|
||||
});
|
||||
} catch (e) {
|
||||
// No quick capture state found, try to add the extension first
|
||||
// This is a simplified approach and might not work in all cases
|
||||
this.registerEditorExtension([
|
||||
quickCaptureExtension(this.app, this),
|
||||
]);
|
||||
|
||||
// Try again after registering the extension
|
||||
setTimeout(() => {
|
||||
try {
|
||||
editorView.dispatch({
|
||||
effects: toggleQuickCapture.of(true),
|
||||
});
|
||||
} catch (e) {
|
||||
new Notice(
|
||||
t(
|
||||
"Could not open quick capture panel in the current editor"
|
||||
)
|
||||
);
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
// Workflow commands
|
||||
if (this.settings.workflow.enableWorkflow) {
|
||||
this.addCommand({
|
||||
|
|
|
|||
|
|
@ -334,8 +334,8 @@ const translations = {
|
|||
"Move direct incomplete subtasks to another file",
|
||||
"moved on": "moved on",
|
||||
"Set priority": "Set priority",
|
||||
"Toggle quick capture panel": "Toggle quick capture panel",
|
||||
"Quick capture (Global)": "Quick capture (Global)",
|
||||
"Toggle quick capture panel in editor": "Toggle quick capture panel in editor",
|
||||
"Quick Capture": "Quick Capture",
|
||||
"Toggle task filter panel": "Toggle task filter panel",
|
||||
"Filter Mode": "Filter Mode",
|
||||
"Choose whether to include or exclude tasks that match the filters":
|
||||
|
|
@ -859,7 +859,7 @@ const translations = {
|
|||
"No tasks with the selected tags": "No tasks with the selected tags",
|
||||
"Select a tag to see related tasks": "Select a tag to see related tasks",
|
||||
"Open Task Genius view": "Open Task Genius view",
|
||||
"Task capture with metadata": "Task capture with metadata",
|
||||
"Minimal Quick Capture": "Minimal Quick Capture",
|
||||
"Refresh task index": "Refresh task index",
|
||||
"Refreshing task index...": "Refreshing task index...",
|
||||
"Task index refreshed": "Task index refreshed",
|
||||
|
|
|
|||
Loading…
Reference in a new issue