generated from obsidianmd/obsidian-sample-plugin
-
-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Latest release broken on Obsidian Mobile #99
Comments
I ran into this issue after setting up a number of buttons to edit my metadata more easily on mobile. For the time being I patched this in my local version. If you open diff --git a/main.js b/main.js
index 45766ac..731fad5 100644
--- a/main.js
+++ b/main.js
@@ -4407,7 +4407,7 @@ class MetaEditParser {
if (!frontmatter)
return [];
//@ts-ignore - this is part of the new Obsidian API as of v1.4.1
- const { start, end } = fileCache === null || fileCache === void 0 ? void 0 : fileCache.frontmatterPosition;
+ const { start, end } = fileCache === null || fileCache === void 0 ? void 0 : fileCache.frontmatterPosition ?? fileCache.frontmatter.position;
const filecontent = await this.app.vault.cachedRead(file);
const yamlContent = filecontent.split("\n").slice(start.line, end.line).join("\n");
const parsedYaml = obsidian.parseYaml(yamlContent);
@@ -4927,10 +4927,12 @@ class MetaController {
async updatePropertyInFile(property, newValue, file) {
// I'm aware this is hacky. Didn't want to spend a bunch of time rewriting old logic.
// This uses the new frontmatter API to update the frontmatter. Later TODO: rewrite old logic to just do this & clean.
- if (property.type === MetaType.YAML) {
- const updatedMetaData = `---\n${this.updateYamlProperty(property, newValue, file)}\n---`;
- //@ts-ignore
- const frontmatterPosition = this.app.metadataCache.getFileCache(file).frontmatterPosition;
+ //@ts-ignore
+ const frontmatterPosition = this.app.metadataCache.getFileCache(file).frontmatterPosition;
+
+ if (property.type === MetaType.YAML && frontmatterPosition) {
+ const updatedMetaData = `---\n${this.updateYamlProperty(property, newValue, file)}---`;
+
const fileContents = await this.app.vault.read(file);
const deleteFrom = frontmatterPosition.start.offset;
const deleteTo = frontmatterPosition.end.offset; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for MetaEdit! I use it a lot in scripts and other places through QuickAdd and its fantastic.
The latest round of updates to fix the plugin with 1.4.x have unfortunately broken MetaEdit on mobile for me with an error only saying:
Any hints on how I can help to debug this at all?
I'm running Obsidian's TestFlight edition on iOS which is according to the about page 1.4.7 (106) API version v.1.3.7.
Reverting back to MetaEdit 1.8.0 fixes the problem for me but this means its broken on desktop.
The text was updated successfully, but these errors were encountered: