Skip to content

Commit 0fe81ce

Browse files
committed
Merge branch 'release/1.2.1'
2 parents 24e6344 + d34eb59 commit 0fe81ce

File tree

9 files changed

+140
-111
lines changed

9 files changed

+140
-111
lines changed

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "sentinel",
33
"name": "Sentinel",
4-
"version": "1.2.0",
4+
"version": "1.2.1",
55
"minAppVersion": "1.7.7",
66
"description": "Trigger actions based on document visibility changes.",
77
"author": "Giorgos Sarigiannidis",

package-lock.json

Lines changed: 50 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sentinel",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"description": "Trigger actions based on document visibility changes.",
55
"main": "dist/main.js",
66
"scripts": {
@@ -13,9 +13,9 @@
1313
"license": "MIT",
1414
"devDependencies": {
1515
"@types/js-yaml": "^4.0.9",
16-
"@types/node": "^22.13.10",
17-
"@typescript-eslint/eslint-plugin": "8.26.1",
18-
"@typescript-eslint/parser": "8.26.1",
16+
"@types/node": "^22.13.14",
17+
"@typescript-eslint/eslint-plugin": "8.28.0",
18+
"@typescript-eslint/parser": "8.28.0",
1919
"builtin-modules": "5.0.0",
2020
"esbuild": "0.25.1",
2121
"js-yaml": "^4.1.0",

src/handlers/leafChangeHandler.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {FileTrackingInfo} from '../types/FileTrackingInfo';
33
import {safeReadFile} from './fileContentHandler';
44
import {Action} from '../types/actions';
55
import {isSplitViewActive} from '../utils/isSplitViewActive';
6+
import {stripFrontmatter} from '../utils/stripFrontmatter';
67

78
export async function handleLeafChange(
89
leaf: WorkspaceLeaf,
@@ -34,6 +35,22 @@ export async function handleLeafChange(
3435
previousFileInfo &&
3536
previousFileInfo.lastModified !== previousFile.stat.mtime
3637
) {
38+
// File has been modified, check if changes are only in frontmatter
39+
const currentContent = await safeReadFile(app, previousFile);
40+
41+
if (currentContent !== null && previousFileInfo.lastContent) {
42+
// Check if content outside frontmatter has changed
43+
const previousContentWithoutFrontmatter = stripFrontmatter(previousFileInfo.lastContent);
44+
const currentContentWithoutFrontmatter = stripFrontmatter(currentContent);
45+
46+
// Only trigger if content outside frontmatter changed
47+
if (previousContentWithoutFrontmatter !== currentContentWithoutFrontmatter) {
48+
onFileChanged(previousFile, 'leaveChangedNoFrontmatter');
49+
}
50+
51+
// Update stored content regardless
52+
previousFileInfo.lastContent = currentContent;
53+
}
3754
onFileChanged(previousFile, 'leaveChanged');
3855
previousFileInfo.lastModified = previousFile.stat.mtime;
3956
}

src/settings/settingsActions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export function addAction(
3737
everyLeave: 'Leaving a note',
3838
firstLeave: 'Leaving a note once, reset on reopening Obsidian',
3939
leaveChanged: 'Leaving a note with changes',
40+
leaveChangedNoFrontmatter: 'Leaving a note with changes, exclude Frontmatter',
4041
})
4142
.setValue(action.when)
4243
.onChange(async (value: Action['when']) => {

src/types/actions.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
interface Action {
22
where: string;
3-
when: 'everyOpen' | 'firstLeave' | 'firstOpen' | 'everyLeave' | 'everyClose' | 'leaveChanged' | 'firstOpenWithReset';
3+
when: 'everyOpen' | 'firstLeave' | 'firstOpen' | 'everyLeave' | 'everyClose' | 'leaveChanged' | 'leaveChangedNoFrontmatter' | 'firstOpenWithReset';
44
what: 'property' | 'command';
55
propertyName?: string;
66
propertyValue?: string;

0 commit comments

Comments
 (0)