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

Add Option to Disable a.internal-links (i.e. Table Elements) for Supercharged Links #237

Open
RicSanOP opened this issue Nov 11, 2024 · 0 comments

Comments

@RicSanOP
Copy link

I love using this plugin to add some color and context to my live editor and side interfaces in obsidian. However, having supercharged links in tables and dataview tables simply adds too much bloat. Currently I simply customized the plugin code (as seen below) to disable rendering on a.internal-link elements. I would recommend an option in settings for toggling this ability in case anyone else might appreciate this.

// to prevent rendering on a.internal-links comment out and replace with empty list the following
// the rest of the options (i.e. live preview and interface panels) still work fine
// this means tables won't get bloated with supercharged links
function updateElLinks(app, plugin, el, ctx) {
    const settings = plugin.settings;
    //const links = el.querySelectorAll('a.internal-link');
    const links = []
    const destName = ctx.sourcePath.replace(/(.*).md/, "$1");
    links.forEach((link) => {
        updateLinkExtraAttributes(app, settings, link, destName);
    });
}
function updateVisibleLinks(app, plugin) {
    const settings = plugin.settings;
    app.workspace.iterateRootLeaves((leaf) => {
        if (leaf.view instanceof obsidian.MarkdownView && leaf.view.file) {
            const file = leaf.view.file;
            const cachedFile = app.metadataCache.getFileCache(file);
            if (cachedFile.links) {
                cachedFile.links.forEach((link) => {
                    const fileName = file.path.replace(/(.*).md/, "$1");
                    const dest = app.metadataCache.getFirstLinkpathDest(link.link, fileName);
                    if (dest) {
                        const new_props = fetchTargetAttributesSync(app, settings, dest, false);
                        //const internalLinks = leaf.view.containerEl.querySelectorAll(`a.internal-link[href="${link.link}"]`);
                        const internalLinks = []
                        internalLinks.forEach((internalLink) => setLinkNewProps(internalLink, new_props));
                    }
                });
            }
        }
    });
}
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

No branches or pull requests

1 participant