mirror of
https://github.com/white7292/obsidian-hd-unfilled-stats-highlighter.git
synced 2026-07-22 07:40:23 +00:00
Compare commits
3 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e678e6e60 | ||
|
|
29d8ebcf90 | ||
|
|
d79270eeb6 |
3 changed files with 46 additions and 54 deletions
11
README.md
11
README.md
|
|
@ -18,17 +18,6 @@ MIT
|
|||
- **Real-time Updates**: As you fill out the missing information, the plugin automatically removes the prefix, keeping your notes clean and up-to-date.
|
||||
- **Configurable**: The Unfilled Stats Highlighter plugin seamlessly integrates with Obsidian, allowing you to easily configure the highlighter to only target your stat files.
|
||||
|
||||
## Releasing new releases
|
||||
|
||||
- Update your `manifest.json` with your new version number, such as `1.0.1`, and the minimum Obsidian version required for your latest release.
|
||||
- Update your `versions.json` file with `"new-plugin-version": "minimum-obsidian-version"` so older versions of Obsidian can download an older version of your plugin that's compatible.
|
||||
- Create new GitHub release using your new version number as the "Tag version". Use the exact version number, don't include a prefix `v`. See here for an example: https://github.com/obsidianmd/obsidian-sample-plugin/releases
|
||||
- Upload the files `manifest.json`, `main.js`, `styles.css` as binary attachments. Note: The manifest.json file must be in two places, first the root path of your repository and also in the release.
|
||||
- Publish the release.
|
||||
|
||||
> You can simplify the version bump process by running `npm version patch`, `npm version minor` or `npm version major` after updating `minAppVersion` manually in `manifest.json`.
|
||||
> The command will bump version in `manifest.json` and `package.json`, and add the entry for the new version to `versions.json`
|
||||
|
||||
## Adding your plugin to the community plugin list
|
||||
|
||||
- Check https://github.com/obsidianmd/obsidian-releases/blob/master/plugin-review.md
|
||||
|
|
|
|||
87
main.ts
87
main.ts
|
|
@ -40,55 +40,58 @@ export default class UnfilledStatsHighlighter extends Plugin {
|
|||
// doesn't belong to this plugin)
|
||||
// Using this function will automatically remove the event listener when
|
||||
// this plugin is disabled.
|
||||
this.registerDomEvent(document, "keyup", (evt: KeyboardEvent) => {
|
||||
const activeFile = this.app.workspace.getActiveFile();
|
||||
this.registerEvent(
|
||||
this.app.workspace.on("editor-change", () => {
|
||||
const activeFile = this.app.workspace.getActiveFile();
|
||||
|
||||
if (
|
||||
!activeFile?.path.contains(
|
||||
`${this.settings.templatesDirectory}/`
|
||||
) &&
|
||||
activeFile?.path.contains(
|
||||
`${this.settings.targetHighlightingDirectory}/`
|
||||
)
|
||||
) {
|
||||
const view =
|
||||
this.app.workspace.getActiveViewOfType(MarkdownView);
|
||||
if (
|
||||
!activeFile?.path.contains(
|
||||
`${this.settings.templatesDirectory}/`
|
||||
) &&
|
||||
activeFile?.path.contains(
|
||||
`${this.settings.targetHighlightingDirectory}/`
|
||||
)
|
||||
) {
|
||||
const view =
|
||||
this.app.workspace.getActiveViewOfType(MarkdownView);
|
||||
|
||||
// Make sure the user is editing a Markdown file.
|
||||
if (view) {
|
||||
const editor = view.editor;
|
||||
if (editor) {
|
||||
for (let i = 0; i < editor.lineCount(); i++) {
|
||||
const line = editor.getLine(i);
|
||||
// Make sure the user is editing a Markdown file.
|
||||
if (view) {
|
||||
const editor = view.editor;
|
||||
if (editor) {
|
||||
for (let i = 0; i < editor.lineCount(); i++) {
|
||||
const line = editor.getLine(i);
|
||||
|
||||
if (
|
||||
!line.startsWith(
|
||||
this.settings.unfilledStatPrefix
|
||||
) &&
|
||||
line.match(this.settings.statRegex)
|
||||
) {
|
||||
editor.setLine(
|
||||
i,
|
||||
`${this.settings.unfilledStatPrefix}${line}`
|
||||
);
|
||||
} else if (
|
||||
line.startsWith(
|
||||
this.settings.unfilledStatPrefix
|
||||
) &&
|
||||
!line.match(this.settings.statRegex)
|
||||
) {
|
||||
editor.setLine(
|
||||
i,
|
||||
line.substring(
|
||||
this.settings.unfilledStatPrefix.length
|
||||
)
|
||||
);
|
||||
if (
|
||||
!line.startsWith(
|
||||
this.settings.unfilledStatPrefix
|
||||
) &&
|
||||
line.match(this.settings.statRegex)
|
||||
) {
|
||||
editor.setLine(
|
||||
i,
|
||||
`${this.settings.unfilledStatPrefix}${line}`
|
||||
);
|
||||
} else if (
|
||||
line.startsWith(
|
||||
this.settings.unfilledStatPrefix
|
||||
) &&
|
||||
!line.match(this.settings.statRegex)
|
||||
) {
|
||||
editor.setLine(
|
||||
i,
|
||||
line.substring(
|
||||
this.settings.unfilledStatPrefix
|
||||
.length
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
// Runs when the plugin is disabled.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"id": "obsidian-hd-unfilled-stats-highlighter",
|
||||
"id": "unfilled-stats-highlighter",
|
||||
"name": "Unfilled Stats Highlighter",
|
||||
"version": "1.0.0",
|
||||
"minAppVersion": "0.15.0",
|
||||
|
|
|
|||
Loading…
Reference in a new issue