Skip to content

Commit 8509ca2

Browse files
committed
1.4.6
Fix #30
1 parent 90403a1 commit 8509ca2

File tree

5 files changed

+19
-16
lines changed

5 files changed

+19
-16
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": "frontmatter-modified-date",
33
"name": "Update modified date",
4-
"version": "1.4.5",
4+
"version": "1.4.6",
55
"minAppVersion": "0.15.0",
66
"description": "Automatically update a frontmatter modified date field when you modify your note. This will not use the filesystem time, but only when you modify the file through Obsidian. Optionally store a history of edit times.",
77
"author": "Alan Grainger",

package-lock.json

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "frontmatter-modified-date",
3-
"version": "1.4.5",
3+
"version": "1.4.6",
44
"description": "Automatically update a frontmatter modified date field when you modify your note. This will not use the filesystem time, but only when you modify the file through Obsidian.",
55
"main": "main.js",
66
"scripts": {

src/main.ts

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,23 @@ export default class FrontmatterModified extends Plugin {
3838
* The way I am doing this is probably a "bad" way. Anyone who knows the best practice
3939
* here, please let me know! It works just fine but perhaps there's a better way.
4040
*/
41-
this.registerDomEvent(document, 'keyup', ev => {
41+
this.registerDomEvent(document, 'input', (event: InputEvent) => {
4242
// Check to see if the inputted key is a single, visible Unicode character.
4343
// This is to prevent matching arrow keys, etc. Using Unicode is necessary
4444
// to match on emoji and other 2-byte characters.
45-
if (!ev.ctrlKey && !ev.altKey && !ev.metaKey && /^.$/u.test(ev.key)) {
46-
try {
47-
// Check to see if the typing event was in the editor DOM element
48-
// @ts-ignore
49-
if (ev.target.closest('.markdown-source-view .cm-editor')) {
50-
// Find the active TFile inside the editor view
51-
// @ts-ignore
52-
this.updateFrontmatter(ev.view.app.workspace.activeEditor.file)
45+
try {
46+
if ((event?.target as HTMLElement)?.closest('.markdown-source-view > .cm-editor')) {
47+
// Check to see if the inputted key is a single, visible Unicode character.
48+
// This is to prevent matching arrow keys, etc. Using Unicode is necessary
49+
// to match on emoji and other 2-byte characters.
50+
if (/^.$/u.test(event.data || '')) {
51+
const file = this.app.workspace.getActiveFile()
52+
if (file instanceof TFile) {
53+
this.updateFrontmatter(file).then()
54+
}
5355
}
54-
} catch (e) { }
55-
}
56+
}
57+
} catch (e) {}
5658
})
5759
}
5860

versions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@
1919
"1.4.2": "0.15.0",
2020
"1.4.3": "0.15.0",
2121
"1.4.4": "0.15.0",
22-
"1.4.5": "0.15.0"
22+
"1.4.5": "0.15.0",
23+
"1.4.6": "0.15.0"
2324
}

0 commit comments

Comments
 (0)