Skip to content

Commit

Permalink
feat(menu): add Reveal current file in navigation menu
Browse files Browse the repository at this point in the history
add Reveal current file in navigation menu
  • Loading branch information
JuckZ committed Mar 5, 2023
1 parent 6e71794 commit 51ac849
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/locale/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default {
setBannerForTheFolder: 'Set random banner for this path',
planPomodoro: 'Plan a pomodoro',
defaultTask: 'Default task: ',
showPomodoroHistory: 'Show pomodoro history',
showPomodoro: 'Show pomodoro',
},
command: {
'check-in': 'Habit Check In',
Expand Down
5 changes: 3 additions & 2 deletions src/locale/zh-cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ export default {
setBannerForTheFolder: '切换当前路径下文件的banner图',
planPomodoro: '规划一个番茄钟',
defaultTask: '默认任务:',
showPomodoro: '展示番茄钟',
},
command: {
'check-in': '习惯打卡',
'remove-check-in': '移除习惯打卡',
'query-openai': '询问OpenAI',
'open-emoji-picker': '输入表情'
'query-openai': '询问OpenAI',
'open-emoji-picker': '输入表情',
},
setting: {
cursorEffect: {
Expand Down
26 changes: 10 additions & 16 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export default class AwesomeBrainManagerPlugin extends Plugin {
},
{
title: 'Notify this to ntfy',
icon: 'bell',
icon: 'megaphone',
clickFn: (menu: Menu, editor: Editor, info: MarkdownView | MarkdownFileInfo) => {
notifyNtfy(this.getCurrentSelection(editor));
},
Expand All @@ -242,7 +242,7 @@ export default class AwesomeBrainManagerPlugin extends Plugin {
},
{
title: t.menu.planPomodoro,
icon: 'clock',
icon: 'send',
clickFn: async (menu: Menu, editor: Editor, info: MarkdownView | MarkdownFileInfo) => {
let task = this.getCurrentSelection(editor);
task = task.replace('- [x] ', '');
Expand All @@ -254,7 +254,7 @@ export default class AwesomeBrainManagerPlugin extends Plugin {
},
},
{
title: t.menu.showPomodoroHistory,
title: t.menu.showPomodoro,
icon: 'alarm-clock',
clickFn: async (menu: Menu, editor: Editor, info: MarkdownView | MarkdownFileInfo) => {
this.app.workspace.detachLeavesOfType(POMODORO_HISTORY_VIEW);
Expand All @@ -266,6 +266,13 @@ export default class AwesomeBrainManagerPlugin extends Plugin {
this.app.workspace.getLeavesOfType(POMODORO_HISTORY_VIEW)[0] as WorkspaceLeaf,
);
},
},
{
title: 'Reveal current file in navigation',
icon: 'navigation',
clickFn: async (menu: Menu, editor: Editor, info: MarkdownView | MarkdownFileInfo) => {
this.app.commands.executeCommandById('file-explorer:reveal-active-file')
},
},
];
}
Expand Down Expand Up @@ -455,19 +462,6 @@ export default class AwesomeBrainManagerPlugin extends Plugin {
const ignorePath = [];
// FIXME 找到并使用更高性能api this.app.vault.getMarkdownFiles();
const allFilePathNeededHandle: TFile[] = await getAllFiles(this.app, path, ignorePath, ['md'], []);
// allFilePathNeededHandle = allFilePathNeededHandle.filter(file => {
// const banner =
// this.app.metadataCache.metadataCache[this.app.metadataCache.fileCache[file.path].hash].frontmatter
// ?.banner;
// return (
// banner &&
// typeof banner == 'string' &&
// (banner.startsWith('https://dummyimage') ||
// banner.startsWith('https://images.unsplash') ||
// banner.startsWith('https://pixabay.com') ||
// banner.startsWith('/'))
// );
// });
allFilePathNeededHandle.forEach(async file => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
Expand Down

0 comments on commit 51ac849

Please sign in to comment.