Skip to content
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

[Feature Request] Allow internal [[wiki-links]] as annotation-target links ? #318

Open
born2discover opened this issue May 9, 2023 · 0 comments · May be fixed by #336
Open

[Feature Request] Allow internal [[wiki-links]] as annotation-target links ? #318

born2discover opened this issue May 9, 2023 · 0 comments · May be fixed by #336

Comments

@born2discover
Copy link

Would it be possible to allow for annotation-target link to be a wiki-link ?

For example:

---
annotation-target: [[some/folder/file.pdf]]
---

That would allow Obsidian to automatically update the link whenever the file path changes (as seems to be requested by #292) and would simplify the overall work-flow for vanilla use cases.

From my poking around the source, it seems the change would only require changes to getAnnotationTarget function in annotatorView.tsx:

getAnnotationTarget(file: TFile): string {
    const annotationTargetPropertyValue = this.plugin.getPropertyValue(ANNOTATION_TARGET_PROPERTY, file);

    if (!annotationTargetPropertyValue) {
        this.plugin.log('Invalid annotation target!');
        return '';
    }

    for (let target of [
        annotationTargetPropertyValue,
        `${this.plugin.settings.customDefaultPath}${annotationTargetPropertyValue}`
    ])
    {
        //unpack target if it is is an array (For Metaedit compatability)
        if (Array.isArray(target)) {
            target = target[0];
        }

        if (isUrl(target)) {
            return target;
        }

        let destFile: TFile;
        try {
            destFile = this.app.metadataCache.getFirstLinkpathDest(target, file?.path || '');
        } finally {
            if (destFile) {
                return destFile.path;
            }
        }
    }
}

Unfortunately I am not a TypeScript developer, nor am I familiar with inner workings of Obsidian or Annotator to attempt an implementation myself.

@nathonius nathonius linked a pull request Aug 16, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant