Compare commits

...

3 commits

Author SHA1 Message Date
Zachary Hynes
4e678e6e60 Replaced keyup event handler with editor-change event handler. 2023-03-28 06:30:43 -04:00
Zachary Hynes
29d8ebcf90 Removed Releasing new releases section from the README.md. 2023-03-28 06:29:40 -04:00
Zachary Hynes
d79270eeb6 Removed obisidian from the plugin id. 2023-03-26 11:57:13 -04:00
3 changed files with 46 additions and 54 deletions

View file

@ -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
View file

@ -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.

View file

@ -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",