This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%* | |
//v1.0: Original script | |
//Get the content of the new note | |
let fileContent = await tp.system.prompt("New Note Content"); | |
//Leave this blank if you want to use the default file path location (set to '/' to use root of vault) | |
let folderOverride = '/'; | |
//Name of the note |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%* | |
const search = app.workspace.getLeavesOfType("search")[0]; | |
const editor = app.workspace.activeLeaf.view.editor; | |
const getCur = editor.getCursor(); | |
const curLineNum = getCur.line; | |
const curPos = getCur.ch; | |
let thisFile = app.workspace.getActiveFile(); | |
let mdCache = this.app.metadataCache.getFileCache(thisFile); | |
let mdLinks = mdCache.links; | |
if (mdLinks) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%* | |
const curSelection = tp.file.selection(); | |
const cmEditorAct = app.workspace.activeLeaf.view.editor; | |
const curLineNum = cmEditorAct.getCursor().line; | |
const curLine = cmEditorAct.getLine(curLineNum); | |
cmEditorAct.setSelection({ line: curLineNum, ch: 0 }, { line: curLineNum, ch: 9999 }); | |
const blockRef = curLine.match(/ \^(.*)/); | |
let id; | |
if (!blockRef) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%* | |
const dateFormat = "YYYY-MM-DD"; | |
const dateBasisStr = await tp.system.prompt("When is the meeting?"); | |
if (dateBasisStr) { | |
function createMessage(daysBefore, dateFormat, dateBasisStr) { | |
let parseResult; | |
let newDate; | |
let parseResultLink; | |
let nlDatesPlugin = app.plugins.getPlugin('nldates-obsidian'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%* | |
//v0.2 - bug fix: when search results match just a file name and no line contents under it | |
//User can set the following two parameters | |
const resultFilePrefix = '## '; | |
const folderLocation = '/search'; | |
const search = app.workspace.getLeavesOfType("search")[0]; | |
const searchTerms = search.view.getQuery(); | |
const arrCount = Array.from(search.view.dom.resultDomLookup); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%* | |
//v0.3 - Allow for Include and Exclude variables to have multiple criteria -- Define Qty of results | |
//VARIABLES TO SET | |
//How many results to return | |
const howMany = 1; | |
//Include the "#" for tags and brackets "[" for pages | |
const pageOrTag = "#quote"; | |
//The Including and Excluding variables are arrays []. To add multiple values use format: ["one","two"] | |
//This is a plain text filter of the resulting blocks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%* | |
//v0.1 - open search pane and add the logseq block ref ID automatically to see block ref source and locations | |
const search = app.workspace.getLeavesOfType("search")[0]; | |
const editor = app.workspace.activeLeaf.view.editor; | |
const curLineNum = editor.getCursor().line; | |
const curLine = editor.getLine(curLineNum); | |
const blockRef = curLine.match(/\(\([a-zA-Z0-9\-]*\)\)/); | |
let searchString = ""; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%* | |
const search = app.workspace.getLeavesOfType("search")[0]; | |
let thisFile = app.workspace.getActiveFile(); | |
search.view.setSortOrder("byCreatedTime"); | |
search.view.setCollapseAll(false); | |
search.view.setExtraContext(true); | |
let myString = thisFile.basename; | |
myString = myString.replace(/[-[\]{}()+?.,\\^$|#]/g, '\\$&'); | |
search.view.setQuery(`/\\[\\[${myString}(\\]\\]|\\|)/`); | |
app.workspace.revealLeaf(search); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%* | |
const search = app.workspace.getLeavesOfType("search")[0]; | |
const files = await app.vault.getMarkdownFiles(); | |
const links = []; | |
files.sort(function(a,b){return b.stat.mtime - a.stat.mtime}); | |
files.forEach(file => { | |
links.push(file.basename); | |
}); | |
const unResLinks = Object.entries(app.metadataCache.unresolvedLinks); | |
unResLinks.forEach((eachLink) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%* | |
const search = app.workspace.getLeavesOfType("search")[0]; | |
let thisFile = app.workspace.getActiveFile(); | |
search.view.setSortOrder("byCreatedTime"); | |
search.view.setCollapseAll(false); | |
search.view.setExtraContext(true); | |
let myString = thisFile.basename; | |
search.view.setQuery(`file:("${myString}") task-todo:(/^./)`); | |
app.workspace.revealLeaf(search); | |
%> |