This file contains 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 | |
//To apply TODO filter, use Shift + Click on the query syntax when a query is loaded with results | |
//Use this link to see GIF of DEMO: https://user-images.githubusercontent.com/64155612/95497690-9c0f8680-0957-11eb-94a7-e0cd49d62a06.gif | |
//The goal of this script is to filter out TODOs that only show up because they were added on daily notes page | |
//Mainly it is if you want to find overdue tasks, like from the last week, by default a TODO due next week will still | |
//show up if you added that TODO on a daily notes page from last week (within the between range) | |
//Resources about the script: | |
//For detailed discussion, see this Slack thread: https://roamresearch.slack.com/archives/C012WK8E9DK/p1601992542022100 | |
//Here is my github repo: https://github.com/GitMurf/roam-javascript |
This file contains 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
document.addEventListener('click', function (evt) { | |
if (evt.target.className === 'bp3-icon bp3-icon-filter') { | |
function sleep(ms) { | |
return new Promise(resolve => setTimeout(resolve, ms)); | |
} | |
async function removeFilters(event) { | |
var filteredButtons = event.target.parentElement.parentElement.parentElement.getElementsByTagName('BUTTON') | |
if (filteredButtons.length == 0 || filteredButtons == null) { return } |
This file contains 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.2: For block refs / embeds need to add line breaks above and below otherwise block ref extends to lines around it | |
//"pull" = default: removes the line, "pull-copy" leaves line, "pull-embed" leaves embed, "pull-ref" adds block ref | |
const pullMode = "pull"; | |
const pullFromFile = await tp.system.suggester((item) => item.path, this.app.vault.getMarkdownFiles(), false); | |
if(pullFromFile) { | |
let cmEditorAct = this.app.workspace.activeLeaf.view.editor; |
This file contains 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 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 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 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 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); | |
%> |
This file contains 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 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]; | |
search.view.setSortOrder("byCreatedTime"); | |
search.view.setCollapseAll(false); | |
search.view.setExtraContext(true); | |
const dnp = tp.date.now('YYYY-MM-DD'); | |
const dnp2 = tp.date.now('YYYY_MM_DD'); | |
let myString = `((file:${dnp2} task-todo:"[ ]") OR ((/Due Date: .*\\[\\[${dnp}\\]\\].*/ OR /due date: \\[[0-9, -]*${dnp}[0-9, -]*\\]/) task-todo:"[ ]") OR (file:${dnp} task-todo:"[ ]") OR (task-todo:"${dnp}") OR section:(/^\#.*${dnp}/ "[ ]") OR section:(/^\#.*${dnp}/ section:("[ ]"))) -file:("weekly review")`; | |
search.view.setQuery(`${myString}`); | |
app.workspace.revealLeaf(search); |
OlderNewer