Feature request: "Bidirectional" Pushing of Block Reference
See original GitHub issueI was very happy to see you linking this plugin in Discord, as I have been tinkering with Templater to achieve something similar. I am not sure what would be the proper name for it, but what I was trying to accomplish some sort of “bidirectional linking command” – to push an embedded block reference to a target note, but also leave a link to the target note at the end of the block of the current note. (probably easier to show via code than to explain it, so I attached the relevant part of the templater script.)
Linking this way is actually quite useful, as it allows to replicate the so called “coding” of qualitative analysis software like atlas.ti or MAXQDA. This would get Obsidian a big step closer to the idea of being used as qualitative analysis software, as described by @ryanjamurphy in this blog post.
As your plugin is already very close to what my Templater Script is trying to achieve, could you maybe add this sort of “bidirectional” linking to this plugin’s features? It wouldn’t be just a “nice-to-have” feature, but rather a feature for which there already is a very real use case.
<%*
// set delimiter Icon for meta-information at the end of a block
const delimiter = "♦︎";
// the search scope is restricted to notes beginning with the string set here.
const filterString = "°";
// select target note
var targetNote = await tp.system.suggester((item) => item.path, this.app.vault.getMarkdownFiles().filter(file => file.name.startsWith(filterString)), true);
// select & get current Block
let cmEditorAct = this.app.workspace.activeLeaf.view.editor;
const curLine = cmEditorAct.getCursor().line;
cmEditorAct.setSelection({ line: curLine, ch: 0 }, { line: curLine, ch: 9999 });
let blockText = tp.file.selection();
//Create link to target note
let targetNoteLink = "[[" + targetNote.name.replace (/\.md$/,"") + "]]";
//function to create block-ID
function createBlockHash() {
let result = '';
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < 8; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
// Check whether block already has already been referenced
// append accordingly to source note
let blockIDExists = (blockText.match(/\^\w*$/) != null)
if (blockIDExists == true){
var id = blockText.match(/\^\w*$/)[0];
tR = blockText.split(delimiter)[0] + delimiter + blockText.split(delimiter)[1] + targetNoteLink + " " + delimiter + " " + id + "\n";
} else {
var id = "^" + createBlockHash();
tR = blockText + " " + delimiter + " " + targetNoteLink + " " + delimiter + " " + `${id}`;
}
// write to target note
let blockRef = `![[${tp.file.title}#${id}]]`;
const curContent = await this.app.vault.read(targetNote);
let newContents = curContent + "**" + tp.file.title + "** " + blockRef + "\n\n";
await this.app.vault.modify(targetNote, newContents);
%>
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:10 (3 by maintainers)
Top GitHub Comments
So this is fascinating. Could you do a loom walking through how it would look?
But if i follow, it is similar to “push a block ref” to another file, but also block ref the destination in the current file?
Sorry if I didn’t get it right.
As we discussed, thank you for this idea. but it is to specific for the broader target audience.