mirror of
https://github.com/rivea0/obsidian-match-syntax.git
synced 2026-07-22 12:40:28 +00:00
fix: replace incomplete setting with a simpler one to show number of match results in notification
This commit is contained in:
parent
70e04d5f75
commit
1e65237652
2 changed files with 10 additions and 8 deletions
16
src/main.ts
16
src/main.ts
|
|
@ -1,4 +1,4 @@
|
|||
import { App, MarkdownView, Plugin, PluginSettingTab, Setting } from 'obsidian';
|
||||
import { App, MarkdownView, Notice, Plugin, PluginSettingTab, Setting } from 'obsidian';
|
||||
import { EditorView, ViewPlugin, Decoration } from '@codemirror/view';
|
||||
import { MatchTextModal } from './modal';
|
||||
import { getMatchRanges } from './utils';
|
||||
|
|
@ -6,7 +6,7 @@ import type { PluginValue, DecorationSet, PluginSpec } from '@codemirror/view';
|
|||
import type { MatchSyntaxPluginSettings, IRange } from './types';
|
||||
|
||||
const DEFAULT_SETTINGS: MatchSyntaxPluginSettings = {
|
||||
showHighlightsOnReadingView: false,
|
||||
showNumberOfMatchesNotification: false,
|
||||
};
|
||||
|
||||
export default class MatchSyntaxPlugin extends Plugin {
|
||||
|
|
@ -15,7 +15,6 @@ export default class MatchSyntaxPlugin extends Plugin {
|
|||
async onload() {
|
||||
await this.loadSettings();
|
||||
this.addSettingTab(new MatchSyntaxSettingTab(this.app, this));
|
||||
console.log(this.settings.showHighlightsOnReadingView);
|
||||
|
||||
const highlightViewPlugin = ViewPlugin.fromClass(
|
||||
HighlighterPlugin,
|
||||
|
|
@ -41,6 +40,9 @@ export default class MatchSyntaxPlugin extends Plugin {
|
|||
if (plugin) {
|
||||
plugin.makeDeco(ranges);
|
||||
}
|
||||
if (this.settings.showNumberOfMatchesNotification) {
|
||||
new Notice(`${ranges.length} matches found.`);
|
||||
}
|
||||
}).open();
|
||||
}
|
||||
return true;
|
||||
|
|
@ -97,13 +99,13 @@ class MatchSyntaxSettingTab extends PluginSettingTab {
|
|||
containerEl.empty();
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName('Show highlights on reading view')
|
||||
.setDesc('The match results will show both in editing and reading views')
|
||||
.setName('Notify the number of matches found')
|
||||
.setDesc('The number of match results will be shown in a notification when you search for a match syntax')
|
||||
.addToggle((toggle) => {
|
||||
toggle
|
||||
.setValue(this.plugin.settings.showHighlightsOnReadingView)
|
||||
.setValue(this.plugin.settings.showNumberOfMatchesNotification)
|
||||
.onChange(async (value) => {
|
||||
this.plugin.settings.showHighlightsOnReadingView = value;
|
||||
this.plugin.settings.showNumberOfMatchesNotification = value;
|
||||
await this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
export interface MatchSyntaxPluginSettings {
|
||||
showHighlightsOnReadingView: boolean;
|
||||
showNumberOfMatchesNotification: boolean;
|
||||
}
|
||||
|
||||
export interface IOffsetOutput {
|
||||
|
|
|
|||
Loading…
Reference in a new issue