diff --git a/ea-scripts/Convert tex to link with folder and alias.md b/ea-scripts/Convert tex to link with folder and alias.md new file mode 100644 index 0000000..401a947 --- /dev/null +++ b/ea-scripts/Convert tex to link with folder and alias.md @@ -0,0 +1,29 @@ +/* +![](https://raw.githubusercontent.com/zsviczian/obsidian-excalidraw-plugin/master/images/scripts-download-raw.jpg) + +Download this file and save to your Obsidian Vault including the first line, or open it in "Raw" and copy the entire contents to Obsidian. + +Converts text elements to links pointing to a file in a selected folder and with the alias set as the original text. The script will prompt the user to select an existing folder from the vault. +`original text` => `[[selected folder/original text|original text]]` + +See documentation for more details: +https://zsviczian.github.io/obsidian-excalidraw-plugin/ExcalidrawScriptsEngine.html + +```javascript +*/ +folders = new Set(); +app.vault.getFiles().forEach((f)=> + folders.add(f.path.substring(0,f.path.lastIndexOf("/"))) +); + +f = Array.from(folders); +folder = await utils.suggester(f,f); +folder = folder === "" ? folder : folder + "/"; + +elements = ea.getViewSelectedElements().filter((el)=>el.type==="text"); + +elements.forEach((el)=>{ + el.rawText = "[["+folder+el.rawText+"|"+el.rawText+"]]"; +}) +ea.copyViewElementsToEAforEditing(elements); +ea.addElementsToView(); \ No newline at end of file