vault backup: 2022-12-12 17:34:00

This commit is contained in:
Bram Adams
2022-12-12 17:34:00 -06:00
parent f2f26968ec
commit 21107d4bdc
11 changed files with 970 additions and 22 deletions

View File

@@ -25,5 +25,7 @@
"simple-embeds",
"luhman",
"obsidian-timestamper",
"obsidian-hotkeys-for-templates"
"obsidian-hotkeys-for-templates",
"settings-search",
"recent-files-obsidian"
]

View File

@@ -0,0 +1,14 @@
{
"globalFilter": "",
"removeGlobalFilter": false,
"setDoneDate": true,
"autoSuggestInEditor": true,
"autoSuggestMinMatch": 0,
"autoSuggestMaxItems": 6,
"provideAccessKeys": true,
"useFilenameAsScheduledDate": false,
"filenameAsDateFolders": [],
"features": {
"INTERNAL_TESTING_ENABLED_BY_DEFAULT": true
}
}

View File

@@ -0,0 +1,11 @@
{
"recentFiles": [
{
"basename": "202212120002",
"path": "202212120002.md"
}
],
"omittedPaths": [],
"maxLength": null,
"openType": "tab"
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
{
"id": "recent-files-obsidian",
"name": "Recent Files",
"version": "1.3.5",
"minAppVersion": "0.16.3",
"description": "List files by most recently opened",
"author": "Tony Grosinger",
"authorUrl": "https://grosinger.net",
"isDesktopOnly": false
}

View File

@@ -0,0 +1,33 @@
.recent-files-title {
display: flex;
justify-content: space-between;
}
.recent-files-title-content {
flex-grow: 1;
}
.recent-files-file-delete {
display: none;
color: var(--nav-item-color);
height: 17px;
}
.recent-files-title:hover .recent-files-file-delete {
display: block;
cursor: pointer;
}
.recent-files-file-delete:hover {
color: var(--nav-item-color-hover);
}
.recent-files-donation {
width: 70%;
margin: 0 auto;
text-align: center;
}
.recent-files-donate-button {
margin: 10px;
}

View File

@@ -0,0 +1,436 @@
/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
var __export = (target, all) => {
__markAsModule(target);
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __reExport = (target, module2, desc) => {
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
for (let key of __getOwnPropNames(module2))
if (!__hasOwnProp.call(target, key) && key !== "default")
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
}
return target;
};
var __toModule = (module2) => {
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
};
var __publicField = (obj, key, value) => {
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
// src/main.ts
__export(exports, {
default: () => SettingsSearch
});
var import_obsidian = __toModule(require("obsidian"));
// node_modules/monkey-around/mjs/index.js
function around(obj, factories) {
const removers = Object.keys(factories).map((key) => around1(obj, key, factories[key]));
return removers.length === 1 ? removers[0] : function() {
removers.forEach((r) => r());
};
}
function around1(obj, method, createWrapper) {
const original = obj[method], hadOwn = obj.hasOwnProperty(method);
let current = createWrapper(original);
if (original)
Object.setPrototypeOf(current, original);
Object.setPrototypeOf(wrapper, current);
obj[method] = wrapper;
return remove;
function wrapper(...args) {
if (current === original && obj[method] === wrapper)
remove();
return current.apply(this, args);
}
function remove() {
if (obj[method] === wrapper) {
if (hadOwn)
obj[method] = original;
else
delete obj[method];
}
if (current === original)
return;
current = original;
Object.setPrototypeOf(wrapper, original || Function);
}
}
// src/main.ts
var SettingsSearch = class extends import_obsidian.Plugin {
constructor() {
super(...arguments);
__publicField(this, "settingsSearchEl", createDiv("settings-search-container vertical-tab-header-group"));
__publicField(this, "settingsResultsContainerEl", createDiv("settings-search-results-container vertical-tab-content"));
__publicField(this, "settingsNavItemContainer", this.settingsSearchEl.createDiv("vertical-tab-header-group-items").createDiv("vertical-tab-nav-item settings-search-input"));
__publicField(this, "settingsResultsEl");
__publicField(this, "search");
__publicField(this, "locale");
__publicField(this, "resources", []);
__publicField(this, "results", []);
__publicField(this, "tabIndex", 0);
__publicField(this, "pluginTabIndex", 0);
__publicField(this, "settingCache", new Map());
__publicField(this, "searchAppended", false);
__publicField(this, "activeIndex", -1);
__publicField(this, "activeSetting");
__publicField(this, "scope", new import_obsidian.Scope(this.app.scope));
__publicField(this, "mobileContainers", []);
}
async onload() {
this.app.workspace.onLayoutReady(async () => {
this.settingsResultsContainerEl.createEl("h3", {
text: "Settings Search Results"
});
this.settingsResultsEl = this.settingsResultsContainerEl.createDiv("settings-search-results");
this.buildScope();
this.buildSearch();
this.buildResources();
this.buildPluginResources();
this.patchSettings();
});
}
buildResources() {
const tab = this.app.setting.settingTabs[this.tabIndex];
if (tab) {
this.getTabResources(tab);
this.tabIndex++;
setTimeout(() => this.buildResources());
}
}
buildPluginResources() {
const tab = this.app.setting.pluginTabs[this.pluginTabIndex];
if (tab) {
this.getTabResources(tab);
this.pluginTabIndex++;
setTimeout(() => this.buildPluginResources());
}
}
get manifests() {
return Object.values(this.app.plugins.manifests);
}
addResourceToCache(resource) {
const setting = new import_obsidian.Setting(createDiv()).setName(resource.text).setDesc(createFragment((e) => e.createDiv().innerHTML = resource.desc ?? ""));
if (resource.tab == "community-plugins") {
let plugin = this.manifests.find((p) => p.name == resource.text);
if (plugin && this.app.plugins.getPlugin(plugin.id)?._loaded && this.app.setting.pluginTabs.find((t) => t.id == plugin.id)) {
setting.addExtraButton((b) => {
b.setTooltip(`Open ${resource.text} Settings`).onClick(() => {
this.app.setting.openTabById(plugin.id);
});
});
}
}
if (resource.tab == "plugins") {
const plugins = Object.values(this.app.internalPlugins.plugins);
const plugin = plugins.find((p) => p._loaded && p.instance.name == resource.text);
if (plugin && this.app.setting.pluginTabs.find((t) => t.id == plugin.instance.id)) {
setting.addExtraButton((b) => {
b.setTooltip(`Open ${resource.text} Settings`).onClick(() => {
this.app.setting.openTabById(plugin.instance.id);
});
});
}
}
setting.addExtraButton((b) => {
b.setIcon("forward-arrow").onClick(() => {
this.showResult(resource);
});
});
this.settingCache.set(resource.text, setting);
}
getResourceFromCache(resource) {
if (!this.settingCache.has(resource.text)) {
this.addResourceToCache(resource);
}
return this.settingCache.get(resource.text);
}
removeResourcesFromCache(resources) {
for (const resource of resources) {
this.settingCache.delete(resource.text);
}
}
async getTabResources(tab) {
await tab.display();
const settings = tab.containerEl.querySelectorAll(".setting-item:not(.setting-item-header)");
for (const el of Array.from(settings)) {
const text = el.querySelector(".setting-item-name")?.textContent;
if (!text)
continue;
const desc = el.querySelector(".setting-item-description")?.innerHTML ?? "";
const resource = {
tab: tab.id,
name: tab.name,
text,
desc
};
this.resources.push(resource);
this.addResourceToCache(resource);
}
if (this.app.setting.activeTab?.id == tab.id)
return;
tab.containerEl.detach();
tab.hide();
}
patchSettings() {
const self = this;
this.register(around(this.app.setting, {
onOpen: function(next) {
return function() {
next.apply(this);
if (!import_obsidian.Platform.isMobile)
self.search.inputEl.focus();
return next;
};
}
}));
this.register(around(this.app.setting, {
addSettingTab: function(next) {
return function(tab) {
self.getTabResources(tab);
return next.call(this, tab);
};
}
}));
this.register(around(this.app.setting, {
removeSettingTab: function(next) {
return function(tab) {
if (this.isPluginSettingTab(tab)) {
const removing = self.resources.filter((t) => t.tab == tab.id);
self.resources = self.resources.filter((t) => t.tab != tab.id);
self.removeResourcesFromCache(removing);
}
return next.call(this, tab);
};
}
}));
this.register(around(this.app.setting, {
openTab: function(next) {
return function(tab) {
self.searchAppended = false;
self.app.keymap.popScope(self.scope);
return next.call(this, tab);
};
},
openTabById: function(next) {
return function(tab) {
self.searchAppended = false;
self.app.keymap.popScope(self.scope);
return next.call(this, tab);
};
},
onClose: function(next) {
return function() {
if (import_obsidian.Platform.isMobile) {
self.detach();
}
return next.call(this);
};
}
}));
}
buildSearch() {
const tempSetting = new import_obsidian.Setting(createDiv()).addSearch((s) => {
this.search = s;
});
this.settingsNavItemContainer.append(tempSetting.controlEl);
tempSetting.settingEl.detach();
this.search.onChange((v) => {
this.onChange(v);
});
this.search.setPlaceholder("Search settings...");
this.app.setting.tabHeadersEl.prepend(this.settingsSearchEl);
}
buildScope() {
this.scope.register([], "ArrowDown", () => {
if (this.activeSetting) {
this.activeSetting.settingEl.removeClass("active");
}
this.activeIndex = ((this.activeIndex + 1) % this.results.length + this.results.length) % this.results.length;
this.centerActiveSetting();
});
this.scope.register([], "ArrowUp", () => {
if (this.activeSetting) {
this.activeSetting.settingEl.removeClass("active");
}
this.activeIndex = ((this.activeIndex - 1) % this.results.length + this.results.length) % this.results.length;
this.centerActiveSetting();
});
this.scope.register([], "Enter", () => {
if (this.activeSetting) {
this.showResult(this.results[this.activeIndex]);
}
});
}
centerActiveSetting() {
const result = this.results[this.activeIndex];
this.activeSetting = this.getResourceFromCache(result);
this.activeSetting.settingEl.addClass("active");
this.activeSetting.settingEl.scrollIntoView({
behavior: "auto",
block: "nearest"
});
}
detachFromMobile() {
if (import_obsidian.Platform.isMobile) {
this.settingsResultsContainerEl.detach();
for (const header of this.mobileContainers) {
this.app.setting.tabHeadersEl.append(header);
}
this.search.setValue("");
}
}
detachFromDesktop() {
if (import_obsidian.Platform.isDesktop) {
this.app.setting.openTabById(this.app.setting.lastTabId);
}
}
detach() {
this.detachFromDesktop();
this.detachFromMobile();
this.searchAppended = false;
}
onChange(v) {
if (!v) {
this.detach();
this.app.keymap.popScope(this.scope);
return;
}
if (!this.searchAppended) {
this.activeIndex = -1;
this.app.keymap.popScope(this.scope);
this.app.keymap.pushScope(this.scope);
if (this.activeSetting) {
this.activeSetting.settingEl.removeClass("active");
this.activeSetting = null;
}
if (!import_obsidian.Platform.isMobile) {
this.app.setting.activeTab.navEl.removeClass("is-active");
this.app.setting.tabContentContainer.empty();
this.app.setting.tabContentContainer.append(this.settingsResultsContainerEl);
} else {
const headers = this.app.setting.tabHeadersEl.querySelectorAll(".vertical-tab-header-group:not(.settings-search-container)");
for (const header of Array.from(headers)) {
this.mobileContainers.push(header);
header.detach();
}
this.app.setting.tabHeadersEl.append(this.settingsResultsContainerEl);
}
this.searchAppended = true;
}
this.appendResults(this.performFuzzySearch(v));
}
getMatchText(text, result) {
const matchElements = {};
return createFragment((content) => {
for (let i = 0; i < text.length; i++) {
let match = result.matches.find((m) => m[0] === i);
if (match) {
const index = result.matches.indexOf(match);
if (!matchElements[index]) {
matchElements[index] = createSpan("suggestion-highlight");
}
let element = matchElements[index];
content.appendChild(element);
element.appendText(text.substring(match[0], match[1]));
i += match[1] - match[0] - 1;
continue;
}
content.appendText(text[i]);
}
});
}
appendResults(results) {
this.settingsResultsEl.empty();
if (results.length) {
const headers = {};
for (const resource of results) {
if (!(resource.tab in headers)) {
headers[resource.tab] = this.settingsResultsEl.createDiv();
new import_obsidian.Setting(headers[resource.tab]).setHeading().setName(resource.name);
}
const setting = this.getResourceFromCache(resource);
headers[resource.tab].append(setting.settingEl);
}
} else {
this.settingsResultsEl.setText("No results found :(");
}
}
showResult(result) {
this.search.setValue("");
const tab = this.app.setting.settingTabs.find((t) => t.id == result.tab) ?? this.app.setting.pluginTabs.find((t) => t.id == result.tab);
if (!tab) {
new import_obsidian.Notice("There was an issue opening the setting tab.");
return;
}
this.app.setting.openTabById(tab.id);
this.app.keymap.popScope(this.scope);
setTimeout(() => this.detach());
try {
const names = tab.containerEl.querySelectorAll(".setting-item-name");
const el = Array.from(names).find((n) => n.textContent == result.text);
if (!el)
return;
const setting = el.closest(".setting-item");
if (!setting)
return;
if (tab.id == "obsidian-style-settings") {
let collapsed = setting.closest(".style-settings-container");
let previous = collapsed?.previousElementSibling;
while (previous != null && previous.hasClass("is-collapsed") && previous.hasClass("style-settings-heading")) {
previous.removeClass("is-collapsed");
collapsed = collapsed.parentElement?.closest(".style-settings-container");
previous = collapsed?.previousElementSibling;
}
}
let details = setting.closest("details");
while (details) {
details.setAttr("open", "open");
details = details.parentElement?.closest("details");
}
setting.scrollIntoView(true);
setting.addClass("is-flashing");
this.registerInterval(window.setTimeout(() => setting.removeClass("is-flashing"), 3e3));
} catch (e) {
console.error(e);
}
}
performFuzzySearch(input) {
const results = [], hotkeys = [];
for (const resource of this.resources) {
let result = (0, import_obsidian.prepareSimpleSearch)(input)(resource.text) ?? (0, import_obsidian.prepareSimpleSearch)(input)(resource.desc);
if (result) {
if (resource.tab == "hotkeys") {
hotkeys.push(resource);
} else {
results.push(resource);
}
}
}
this.results = [...results, ...hotkeys];
return this.results;
}
onunload() {
this.settingsSearchEl.detach();
this.settingsResultsEl.detach();
this.detach();
if (this.searchAppended && import_obsidian.Platform.isDesktop)
this.app.setting.openTabById(this.app.setting.lastTabId);
}
};

View File

@@ -0,0 +1,10 @@
{
"id": "settings-search",
"name": "Settings Search",
"version": "1.2.0",
"minAppVersion": "0.12.17",
"author": "Jeremy Valentine",
"description": "Globally search settings in Obsidian.md",
"authorUrl": "https://github.com/valentine195",
"isDesktopOnly": false
}

View File

@@ -0,0 +1,21 @@
/* src/assets/main.css */
.settings-search-container.vertical-tab-header-group {
padding-bottom: 0;
}
.settings-search-input {
padding-left: 6px;
}
.vertical-tab-nav-item.settings-search-input {
background-color: inherit !important;
}
.settings-search-input .setting-item-control {
display: block;
}
.settings-search-input .search-input-container {
margin: 0;
}
.settings-search-results .setting-item.active {
background-color: var(--background-secondary);
}
/* src/styles.css */

View File

@@ -13,26 +13,13 @@
"state": {
"type": "markdown",
"state": {
"file": "202212090136.md",
"mode": "source",
"source": false
}
}
},
{
"id": "d824060a7ca705fa",
"type": "leaf",
"state": {
"type": "markdown",
"state": {
"file": "Templates/People.md",
"file": "202212120002.md",
"mode": "source",
"source": false
}
}
}
],
"currentTab": 1
]
}
],
"direction": "vertical"
@@ -44,6 +31,7 @@
{
"id": "3e1fc648f46914c4",
"type": "tabs",
"dimension": 70.0925925925926,
"children": [
{
"id": "cdbe46f476d5c797",
@@ -80,6 +68,21 @@
}
],
"currentTab": 2
},
{
"id": "4af83666f6f49517",
"type": "tabs",
"dimension": 29.907407407407405,
"children": [
{
"id": "d51c28db626a700f",
"type": "leaf",
"state": {
"type": "recent-files",
"state": {}
}
}
]
}
],
"direction": "horizontal",
@@ -99,7 +102,7 @@
"state": {
"type": "backlink",
"state": {
"file": "Templates/People.md",
"file": "202212120002.md",
"collapseAll": false,
"extraContext": false,
"sortOrder": "alphabetical",
@@ -116,7 +119,7 @@
"state": {
"type": "outgoing-link",
"state": {
"file": "Templates/People.md",
"file": "202212120002.md",
"linksCollapsed": false,
"unlinkedCollapsed": true
}
@@ -139,7 +142,7 @@
"state": {
"type": "outline",
"state": {
"file": "Templates/People.md"
"file": "202212120002.md"
}
}
},
@@ -180,17 +183,17 @@
"periodic-notes:Open today": false
}
},
"active": "c102a50492c64997",
"active": "4b2d9504cca5ea7f",
"lastOpenFiles": [
"README.md",
"Templates/People.md",
"Templates/Quarterly.md",
"Templates/Weekly.md",
"202212090136.md",
"Templates/People.md",
"Templates/Daily.md",
"202212120002.md",
"202212090137.md",
"Daily/2022-12-12.md",
"README.md",
"_tutorial/Hotkeys.md"
]
}

View File

@@ -557,6 +557,7 @@ Truly nothing in this vault is *required*, but if you want the full experience,
- QuickAdd
- Random Note
- Readwise (*look -- I really hate to put a paid subscription plugin on the "required" list, but this app is **so** good, it's really revolutionized my reading experience across Twitter/Kindle/blogs/podcasts. Plus their new [Reader](https://readwise.io/read) app is straight up awesome. A lot of the ease of this vault derives from Readwise, so don't use it at your own risk*)
- Recent Files
- Style Settings
- Supercharged Links
- Templater
@@ -578,6 +579,7 @@ These plugins aren't needed, as some are QoL and others have a steep price tag a
- Obsidian Linter
- Ozan's Image in Editor Plugin
- Simple Embeds
- Settings Search
- Tag Wrangler
- Zotero (requires [Better BibTeX for Zotero plugin](https://github.com/retorquere/zotero-better-bibtex))
- Tracker