Skip to content

Commit

Permalink
Add setting to search kanban board by clicking tags (#875)
Browse files Browse the repository at this point in the history
  • Loading branch information
pryley authored Apr 18, 2024
1 parent 9569e80 commit 37cfda3
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
23 changes: 23 additions & 0 deletions src/Settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export interface KanbanSettings {
'hide-date-in-title'?: boolean;
'hide-tags-display'?: boolean;
'hide-tags-in-title'?: boolean;
'tag-action'?: 'kanban' | 'obsidian';
'lane-width'?: number;
'full-list-lane-width'?: boolean;
'link-date-to-daily-note'?: boolean;
Expand Down Expand Up @@ -96,6 +97,7 @@ export const settingKeyLookup: Set<keyof KanbanSettings> = new Set([
'hide-date-in-title',
'hide-tags-display',
'hide-tags-in-title',
'tag-action',
'lane-width',
'link-date-to-daily-note',
'list-collapse',
Expand Down Expand Up @@ -535,6 +537,27 @@ export class SettingsManager {
});
});

new Setting(contentEl)
.setName(t('Tag action'))
.setDesc(
t('This setting controls whether clicking the tags displayed below the card title opens the Obsidian search or the Kanban board search.')
)
.addDropdown((dropdown) => {
dropdown.addOption('kanban', t('Search Kanban Board'));
dropdown.addOption('obsidian', t('Search Obsidian Vault'));

const [value, globalValue] = this.getSetting('tag-action', local);

dropdown.setValue((value as string) || (globalValue as string) || 'obsidian');
dropdown.onChange((value) => {
this.applySettingsUpdate({
'tag-action': {
$set: value as 'kanban' | 'obsidian',
},
});
});
});

new Setting(contentEl)
.setName(t('Display tag colors'))
.setDesc(t('Set colors for the tags displayed below the card title.'))
Expand Down
13 changes: 12 additions & 1 deletion src/components/MarkdownRenderer/MarkdownRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,20 @@ export const StaticMarkdownRenderer = memo(function StaticMarkdownRenderer({
// Open a tag search
if (closestAnchor.hasClass('tag')) {
e.preventDefault();
const tag = closestAnchor.getAttr('href');
const tagAction = stateManager.getSetting('tag-action');

if (tagAction === 'kanban') {
setSearchQuery(tag);
setDebouncedSearchQuery(tag);
setIsSearching(true);

return;
}

(stateManager.app as any).internalPlugins
.getPluginById('global-search')
.instance.openGlobalSearch(`tag:${closestAnchor.getAttr('href')}`);
.instance.openGlobalSearch(`tag:${tag}`);
return;
}

Expand Down
5 changes: 5 additions & 0 deletions src/lang/locale/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ export default {
'Hide card display tags': 'Hide card display tags',
'When toggled, tags will not be displayed below the card title.':
'When toggled, tags will not be displayed below the card title.',
'Tag action': 'Tag action',
'Search Kanban Board': 'Search Kanban Board',
'Search Obsidian Vault': 'Search Obsidian Vault',
'This setting controls whether clicking the tags displayed below the card title opens the Obsidian search or the Kanban board search.':
'This setting controls whether clicking the tags displayed below the card title opens the Obsidian search or the Kanban board search.',
'Display tag colors': 'Display tag colors',
'Set colors for the tags displayed below the card title.':
'Set colors for the tags displayed below the card title.',
Expand Down

0 comments on commit 37cfda3

Please sign in to comment.