Initial commit
This commit is contained in:
29
.obsidian/plugins/better-export-pdf/data.json
vendored
Normal file
29
.obsidian/plugins/better-export-pdf/data.json
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"showTitle": true,
|
||||
"maxLevel": "6",
|
||||
"displayHeader": true,
|
||||
"displayFooter": true,
|
||||
"headerTemplate": "<div style=\"width: 100vw;font-size:10px;text-align:center;\"><span class=\"title\"></span></div>",
|
||||
"footerTemplate": "<div style=\"width: 100vw;font-size:10px;text-align:center;\"><span class=\"pageNumber\"></span> / <span class=\"totalPages\"></span></div>",
|
||||
"printBackground": false,
|
||||
"generateTaggedPDF": false,
|
||||
"displayMetadata": false,
|
||||
"debug": false,
|
||||
"isTimestamp": false,
|
||||
"enabledCss": false,
|
||||
"prevConfig": {
|
||||
"pageSize": "A4",
|
||||
"marginType": "1",
|
||||
"showTitle": true,
|
||||
"open": true,
|
||||
"scale": 100,
|
||||
"landscape": false,
|
||||
"marginTop": "10",
|
||||
"marginBottom": "10",
|
||||
"marginLeft": "10",
|
||||
"marginRight": "10",
|
||||
"displayHeader": true,
|
||||
"displayFooter": true,
|
||||
"cssSnippet": "0"
|
||||
}
|
||||
}
|
21258
.obsidian/plugins/better-export-pdf/main.js
vendored
Normal file
21258
.obsidian/plugins/better-export-pdf/main.js
vendored
Normal file
File diff suppressed because one or more lines are too long
11
.obsidian/plugins/better-export-pdf/manifest.json
vendored
Normal file
11
.obsidian/plugins/better-export-pdf/manifest.json
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"id": "better-export-pdf",
|
||||
"name": "Better Export PDF",
|
||||
"version": "1.10.0",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "Export your notes to PDF, support export preview, add bookmarks outline and header/footer.",
|
||||
"author": "l1xnan",
|
||||
"authorUrl": "https://github.com/l1xnan",
|
||||
"fundingUrl": "https://www.buymeacoffee.com/l1xnan",
|
||||
"isDesktopOnly": true
|
||||
}
|
52
.obsidian/plugins/better-export-pdf/styles.css
vendored
Normal file
52
.obsidian/plugins/better-export-pdf/styles.css
vendored
Normal file
@ -0,0 +1,52 @@
|
||||
#better-export-pdf {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
height: 75vh;
|
||||
}
|
||||
|
||||
#better-export-pdf .pdf-preview {
|
||||
flex: auto;
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
align-content: flex-start;
|
||||
}
|
||||
|
||||
#better-export-pdf .pdf-preview .webview-wrapper {
|
||||
position: relative;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#better-export-pdf .pdf-preview .print-size {
|
||||
position: absolute;
|
||||
right: 8px;
|
||||
top: 8px;
|
||||
z-index: 99;
|
||||
font-size: 0.6rem;
|
||||
white-space: pre-wrap;
|
||||
text-align: right;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
#better-export-pdf .pdf-preview > div {
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#better-export-pdf .pdf-preview .filename {
|
||||
font-size: 0.75rem;
|
||||
color: var(--color-base-60);
|
||||
}
|
||||
#better-export-pdf .pdf-preview .filename:not(:first-child) {
|
||||
padding-top: calc(var(--p-spacing));
|
||||
}
|
||||
|
||||
#better-export-pdf webview {
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
16
.obsidian/plugins/consistent-attachments-and-links/data.json
vendored
Normal file
16
.obsidian/plugins/consistent-attachments-and-links/data.json
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"autoCollectAttachments": false,
|
||||
"changeNoteBacklinksAlt": false,
|
||||
"consistencyReportFile": "consistency-report.md",
|
||||
"deleteAttachmentsWithNote": true,
|
||||
"deleteEmptyFolders": true,
|
||||
"deleteExistFilesWhenMoveNote": true,
|
||||
"moveAttachmentsWithNote": true,
|
||||
"showBackupWarning": false,
|
||||
"updateLinks": true,
|
||||
"excludePaths": [
|
||||
".git/",
|
||||
".obsidian/"
|
||||
],
|
||||
"includePaths": []
|
||||
}
|
87
.obsidian/plugins/consistent-attachments-and-links/main.js
vendored
Normal file
87
.obsidian/plugins/consistent-attachments-and-links/main.js
vendored
Normal file
File diff suppressed because one or more lines are too long
11
.obsidian/plugins/consistent-attachments-and-links/manifest.json
vendored
Normal file
11
.obsidian/plugins/consistent-attachments-and-links/manifest.json
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"id": "consistent-attachments-and-links",
|
||||
"name": "Consistent Attachments and Links",
|
||||
"version": "3.24.1",
|
||||
"minAppVersion": "1.7.7",
|
||||
"description": "This plugin ensures the consistency of attachments and links",
|
||||
"author": "Dmitry Savosh",
|
||||
"authorUrl": "https://github.com/dy-sh/",
|
||||
"isDesktopOnly": false,
|
||||
"fundingUrl": "https://www.buymeacoffee.com/mnaoumov"
|
||||
}
|
4
.obsidian/plugins/hidden-folder-obsidian/data.json
vendored
Normal file
4
.obsidian/plugins/hidden-folder-obsidian/data.json
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"folders": "assets",
|
||||
"enable": true
|
||||
}
|
248
.obsidian/plugins/hidden-folder-obsidian/main.js
vendored
Normal file
248
.obsidian/plugins/hidden-folder-obsidian/main.js
vendored
Normal file
@ -0,0 +1,248 @@
|
||||
/*
|
||||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||||
if you want to view the source, please visit the github repository of this plugin
|
||||
*/
|
||||
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// main.ts
|
||||
var main_exports = {};
|
||||
__export(main_exports, {
|
||||
default: () => main_default
|
||||
});
|
||||
module.exports = __toCommonJS(main_exports);
|
||||
|
||||
// src/plugin.ts
|
||||
var import_obsidian2 = require("obsidian");
|
||||
|
||||
// src/lang/en.ts
|
||||
var en_default = {};
|
||||
|
||||
// src/lang/zh.ts
|
||||
var zh_default = {
|
||||
"Not Found Files List": "\u627E\u4E0D\u5230\u6587\u4EF6\u5217\u8868",
|
||||
"Hidden Folder": "\u6587\u4EF6\u9690\u85CF",
|
||||
"Restore display": "\u6062\u590D\u663E\u793A",
|
||||
"folders": "\u6587\u4EF6\u5939",
|
||||
"Folders": "\u6587\u4EF6\u5939",
|
||||
"folder": "\u6587\u4EF6\u5939",
|
||||
"Hidden display": "\u9690\u85CF\u663E\u793A",
|
||||
"Show Folders": "\u663E\u793A\u6587\u4EF6\u5939",
|
||||
"Hidden Folders": "\u9690\u85CF\u6587\u4EF6\u5939",
|
||||
"Rules": "\u89C4\u5219",
|
||||
"Regular expression": "\u6B63\u5219\u8868\u8FBE\u5F0F",
|
||||
"Example": "\u4F8B\u5B50",
|
||||
"Enable": "\u5F00\u542F",
|
||||
"Enable to hidden folder": "\u662F\u5426\u5F00\u542F\u9690\u85CF",
|
||||
"Saving": "\u4FDD\u5B58\u4E2D",
|
||||
"Settings is saved": "\u914D\u7F6E\u5DF2\u4FDD\u5B58",
|
||||
"Save": "\u4FDD\u5B58"
|
||||
};
|
||||
|
||||
// src/lang/index.ts
|
||||
var lang = {
|
||||
en: en_default,
|
||||
zh: zh_default,
|
||||
get
|
||||
};
|
||||
function get(text, args) {
|
||||
var _a;
|
||||
const language = ((_a = window.i18next) == null ? void 0 : _a.language) || "en";
|
||||
const map = lang[language] || en_default;
|
||||
let result = map[text] || en_default[text] || text;
|
||||
if (args) {
|
||||
for (let i in args) {
|
||||
result = result.replace(new RegExp(`\\{\\{${i}\\}\\}`, "g"), args[i]);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
lang.get = get;
|
||||
var lang_default = lang;
|
||||
|
||||
// src/setting.ts
|
||||
var import_obsidian = require("obsidian");
|
||||
var HiddenFolderSettingTab = class extends import_obsidian.PluginSettingTab {
|
||||
constructor(app, plugin) {
|
||||
super(app, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
display() {
|
||||
const { containerEl } = this;
|
||||
containerEl.empty();
|
||||
containerEl.createEl("h2", { text: lang_default.get("Hidden Folder") });
|
||||
const settings = {
|
||||
folders: this.plugin.settings.folders,
|
||||
enable: this.plugin.settings.enable
|
||||
};
|
||||
new import_obsidian.Setting(containerEl).setName(lang_default.get("Rules")).setDesc(lang_default.get("Regular expression")).addTextArea((text) => {
|
||||
text.inputEl.style.minWidth = "350px";
|
||||
text.inputEl.style.minHeight = "150px";
|
||||
text.setPlaceholder(lang_default.get("Example") + ":\n.*\\/?attachments\n^abc$\nuse multi lines for multi folders").setValue(this.plugin.settings.folders).onChange(async (value) => {
|
||||
settings.folders = value;
|
||||
});
|
||||
return text;
|
||||
});
|
||||
new import_obsidian.Setting(containerEl).setName(lang_default.get("Enable")).setDesc(lang_default.get("Enable to hidden folder")).addToggle((toggle) => toggle.setValue(this.plugin.settings.enable).onChange((enable) => {
|
||||
settings.enable = enable;
|
||||
}));
|
||||
new import_obsidian.Setting(containerEl).addButton((button) => button.setButtonText(lang_default.get("Save")).onClick(async () => {
|
||||
new import_obsidian.Notice(lang_default.get("Hidden Folder") + " - " + lang_default.get("Saving"));
|
||||
this.plugin.settings.folders = settings.folders;
|
||||
this.plugin.settings.enable = settings.enable;
|
||||
await this.plugin.saveSettings();
|
||||
this.plugin.restoreFolder();
|
||||
if (this.plugin.settings.enable) {
|
||||
this.plugin.hiddenFolder();
|
||||
}
|
||||
new import_obsidian.Notice(lang_default.get("Hidden Folder") + " - " + lang_default.get("Settings is saved"));
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
// src/plugin.ts
|
||||
var DEFAULT_SETTINGS = {
|
||||
folders: "",
|
||||
enable: false
|
||||
};
|
||||
var HiddenFolder = class extends import_obsidian2.Plugin {
|
||||
getFilters() {
|
||||
if (!this.settings.folders)
|
||||
return null;
|
||||
const result = [];
|
||||
const folders = this.settings.folders.split("\n");
|
||||
if (folders.length) {
|
||||
for (let i of folders) {
|
||||
result.push(new RegExp(i));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
getFolderElements() {
|
||||
const folders = document.querySelectorAll(".nav-folder");
|
||||
const result = [];
|
||||
for (let i = 0; i < folders.length; i++) {
|
||||
const el = folders[i];
|
||||
if (el.classList.contains("mod-root"))
|
||||
continue;
|
||||
result.push(el);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
restoreFolder() {
|
||||
const folders = document.querySelectorAll(".hidden-folder-flag-hidden");
|
||||
if (folders == null ? void 0 : folders.length) {
|
||||
new import_obsidian2.Notice(lang_default.get("Restore display") + "\r\n" + folders.length + " " + lang_default.get(folders.length > 1 ? "folders" : "folder"));
|
||||
for (let i = 0; i < folders.length; i++) {
|
||||
const el = folders[i];
|
||||
el.classList.remove("hidden-folder-flag-hidden");
|
||||
}
|
||||
}
|
||||
}
|
||||
hiddenFolder() {
|
||||
if (!this.settings.enable)
|
||||
return;
|
||||
const filters = this.getFilters();
|
||||
if (!(filters == null ? void 0 : filters.length))
|
||||
return;
|
||||
const elements = this.getFolderElements();
|
||||
let count = 0;
|
||||
for (let el of elements) {
|
||||
const title = el.querySelector(".nav-folder-title");
|
||||
const path = title == null ? void 0 : title.getAttribute("data-path");
|
||||
if (!path)
|
||||
continue;
|
||||
if (el.classList.contains("hidden-folder-flag-hidden"))
|
||||
continue;
|
||||
for (let filter of filters) {
|
||||
if (filter.test(path)) {
|
||||
el.classList.add("hidden-folder-flag-hidden");
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count) {
|
||||
new import_obsidian2.Notice(lang_default.get("Hidden display") + "\r\n" + count + " " + lang_default.get(count > 1 ? "folders" : "folder"));
|
||||
}
|
||||
}
|
||||
async onload() {
|
||||
await this.loadSettings();
|
||||
this.start(0);
|
||||
}
|
||||
observe() {
|
||||
if (!this.container)
|
||||
return;
|
||||
this.observer = new MutationObserver(() => {
|
||||
this.hiddenFolder();
|
||||
});
|
||||
this.observer.observe(this.container, { attributes: true, childList: true, subtree: true });
|
||||
}
|
||||
start(loop) {
|
||||
if (loop > 20) {
|
||||
new import_obsidian2.Notice(lang_default.get("Not Found Files List"));
|
||||
return;
|
||||
}
|
||||
this.container = document.querySelector(".nav-files-container");
|
||||
if (!this.container) {
|
||||
setTimeout(() => {
|
||||
this.start(loop + 1);
|
||||
}, 100);
|
||||
return;
|
||||
}
|
||||
this.observe();
|
||||
this.app.workspace.on("layout-change", () => {
|
||||
const container = document.querySelector(".nav-files-container");
|
||||
if (container !== this.container) {
|
||||
this.container = container;
|
||||
this.observe();
|
||||
}
|
||||
});
|
||||
this.addSettingTab(new HiddenFolderSettingTab(this.app, this));
|
||||
this.hiddenFolder();
|
||||
setTimeout(() => {
|
||||
const el = this.addRibbonIcon("ghost", lang_default.get(this.settings.enable ? "Show Folders" : "Hidden Folders"), (evt) => {
|
||||
this.settings.enable = !this.settings.enable;
|
||||
this.saveSettings();
|
||||
el.setAttribute("aria-label", lang_default.get(this.settings.enable ? "Show Folders" : "Hidden Folders"));
|
||||
if (this.settings.enable) {
|
||||
this.hiddenFolder();
|
||||
} else {
|
||||
this.restoreFolder();
|
||||
}
|
||||
});
|
||||
}, 10);
|
||||
}
|
||||
onunload() {
|
||||
if (!this.observer)
|
||||
return;
|
||||
this.restoreFolder();
|
||||
this.observer.disconnect();
|
||||
}
|
||||
async loadSettings() {
|
||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
|
||||
}
|
||||
async saveSettings() {
|
||||
await this.saveData(this.settings);
|
||||
}
|
||||
};
|
||||
|
||||
// main.ts
|
||||
var main_default = HiddenFolder;
|
||||
|
||||
/* nosourcemap */
|
9
.obsidian/plugins/hidden-folder-obsidian/manifest.json
vendored
Normal file
9
.obsidian/plugins/hidden-folder-obsidian/manifest.json
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"id": "hidden-folder-obsidian",
|
||||
"name": "Hidden Folder",
|
||||
"version": "1.0.7",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "Hidden Folder",
|
||||
"author": "ptrsvltns",
|
||||
"isDesktopOnly": true
|
||||
}
|
3
.obsidian/plugins/hidden-folder-obsidian/styles.css
vendored
Normal file
3
.obsidian/plugins/hidden-folder-obsidian/styles.css
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
.hidden-folder-flag-hidden {
|
||||
display: none;
|
||||
}
|
11
.obsidian/plugins/nuke-orphans/data.json
vendored
Normal file
11
.obsidian/plugins/nuke-orphans/data.json
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"attachmentsPaths": [
|
||||
"./assets"
|
||||
],
|
||||
"trashFolderOverride": "",
|
||||
"ignorePatterns": [
|
||||
"./Files",
|
||||
".md"
|
||||
],
|
||||
"alternativeAttachmentAlg": false
|
||||
}
|
314
.obsidian/plugins/nuke-orphans/main.js
vendored
Normal file
314
.obsidian/plugins/nuke-orphans/main.js
vendored
Normal file
@ -0,0 +1,314 @@
|
||||
/*
|
||||
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 __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 __async = (__this, __arguments, generator) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
var fulfilled = (value) => {
|
||||
try {
|
||||
step(generator.next(value));
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
};
|
||||
var rejected = (value) => {
|
||||
try {
|
||||
step(generator.throw(value));
|
||||
} catch (e) {
|
||||
reject(e);
|
||||
}
|
||||
};
|
||||
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
||||
step((generator = generator.apply(__this, __arguments)).next());
|
||||
});
|
||||
};
|
||||
|
||||
// src/main.ts
|
||||
__export(exports, {
|
||||
default: () => NukeOrphansPlugin
|
||||
});
|
||||
var import_obsidian3 = __toModule(require("obsidian"));
|
||||
|
||||
// src/settings.ts
|
||||
var import_obsidian = __toModule(require("obsidian"));
|
||||
var DEFAULT_SETTINGS = {
|
||||
attachmentsPaths: [],
|
||||
trashFolderOverride: "",
|
||||
ignorePatterns: [],
|
||||
alternativeAttachmentAlg: false
|
||||
};
|
||||
var CSS_CLASS_CHECK_PASS = "nuke-orphans-pass";
|
||||
var CSS_CLASS_CHECK_FAIL = "nuke-orphans-fail";
|
||||
var NukeOrphansSettingsTab = class extends import_obsidian.PluginSettingTab {
|
||||
constructor(app, plugin) {
|
||||
super(app, plugin);
|
||||
this.plugin = plugin;
|
||||
}
|
||||
display() {
|
||||
const { containerEl } = this;
|
||||
containerEl.empty();
|
||||
containerEl.createEl("h3", {
|
||||
attr: {
|
||||
"style": "text-align: center;"
|
||||
},
|
||||
text: "Nuke Orphans Plugin Settings"
|
||||
});
|
||||
new import_obsidian.Setting(containerEl).setName("Override Attachment Folder").setDesc("Where attachments are stored").addTextArea((text) => text.setPlaceholder(this.app.vault.config.attachmentFolderPath).setValue(this.plugin.settings.attachmentsPaths.join("\n")).onChange((value) => __async(this, null, function* () {
|
||||
this.plugin.settings.attachmentsPaths = value.split("\n").map((x) => x.trim()).filter((x) => x.length > 0);
|
||||
yield this.plugin.saveSettings();
|
||||
})));
|
||||
new import_obsidian.Setting(containerEl).setName("Override Trash Folder").setDesc("Trash folder path, will be created if it does not exist").addText((text) => text.setPlaceholder(this.plugin.shouldUseSystemTrash() ? "system trash" : ".trash/").setValue(this.plugin.settings.trashFolderOverride).onChange((value) => __async(this, null, function* () {
|
||||
this.plugin.settings.trashFolderOverride = value;
|
||||
yield this.plugin.saveSettings();
|
||||
})));
|
||||
new import_obsidian.Setting(containerEl).setName("Ignore Patterns").setDesc("Add regex patterns to ignore when searching for orphans").addTextArea((text) => text.setValue(this.plugin.settings.ignorePatterns.join("\n")).onChange((value) => __async(this, null, function* () {
|
||||
this.plugin.settings.ignorePatterns = value.split("\n").map((x) => x.trim()).filter((x) => x.length > 0);
|
||||
yield this.plugin.saveSettings();
|
||||
})));
|
||||
new import_obsidian.Setting(containerEl).setName("Test Settings").setDesc("If the path is ignored it will be red, otherwise green").addText((text) => {
|
||||
function resetColor() {
|
||||
text.inputEl.classList.remove(CSS_CLASS_CHECK_PASS, CSS_CLASS_CHECK_FAIL);
|
||||
}
|
||||
text.onChange((value) => {
|
||||
resetColor();
|
||||
if (value.length == 0)
|
||||
return;
|
||||
if (this.plugin.getIgnoreFilter().test(value))
|
||||
text.inputEl.classList.add(CSS_CLASS_CHECK_FAIL);
|
||||
else
|
||||
text.inputEl.classList.add(CSS_CLASS_CHECK_PASS);
|
||||
});
|
||||
text.inputEl.addEventListener("focusout", () => resetColor());
|
||||
text.inputEl.addEventListener("focusin", () => text.onChanged());
|
||||
});
|
||||
containerEl.createEl("h3", {
|
||||
attr: {
|
||||
style: "font-weight: bold"
|
||||
},
|
||||
text: "Advanced Settings"
|
||||
});
|
||||
new import_obsidian.Setting(containerEl).setName("Alternative Attachments Finding Algorithm").setDesc("Try enabling this if attachments are not found in subfolders").addToggle((btn) => btn.setValue(this.plugin.settings.alternativeAttachmentAlg).onChange((value) => __async(this, null, function* () {
|
||||
this.plugin.settings.alternativeAttachmentAlg = value;
|
||||
yield this.plugin.saveSettings();
|
||||
})));
|
||||
}
|
||||
};
|
||||
|
||||
// src/trash_modal.ts
|
||||
var import_obsidian2 = __toModule(require("obsidian"));
|
||||
var path = __toModule(require("path"));
|
||||
var TrashFilesModal = class extends import_obsidian2.Modal {
|
||||
constructor(app, files, trashFolderPath, useSystemTrash) {
|
||||
super(app);
|
||||
this.files = files;
|
||||
this.trashFolderPath = trashFolderPath;
|
||||
this.useSystemTrash = useSystemTrash;
|
||||
}
|
||||
onOpen() {
|
||||
let { contentEl, titleEl } = this;
|
||||
titleEl.setText("Move " + this.files.length + " files to trash?");
|
||||
const div = contentEl.createDiv({
|
||||
cls: "trash-modal-file-links"
|
||||
});
|
||||
this.files.forEach((file) => {
|
||||
div.createEl("p", {
|
||||
cls: "trash-modal-link",
|
||||
text: file.path
|
||||
}).addEventListener("click", () => __async(this, null, function* () {
|
||||
this.close();
|
||||
yield this.app.workspace.activeLeaf.openFile(file);
|
||||
}));
|
||||
});
|
||||
contentEl.createEl("button", {
|
||||
cls: ["trash-modal-button"],
|
||||
text: "Cancel"
|
||||
}).addEventListener("click", () => this.close());
|
||||
contentEl.createEl("button", {
|
||||
cls: ["trash-modal-button"],
|
||||
text: "Copy list to clipboard"
|
||||
}).addEventListener("click", () => __async(this, null, function* () {
|
||||
yield navigator.clipboard.writeText(this.files.map((file) => file.path).join("\n"));
|
||||
new import_obsidian2.Notice("Copied list to clipboard");
|
||||
}));
|
||||
contentEl.createEl("button", {
|
||||
cls: ["mod-cta", "trash-modal-button"],
|
||||
text: "Trash"
|
||||
}).addEventListener("click", () => __async(this, null, function* () {
|
||||
if (this.trashFolderPath.length > 0) {
|
||||
if (!(yield this.app.vault.adapter.exists(this.trashFolderPath)))
|
||||
yield this.app.vault.createFolder(this.trashFolderPath);
|
||||
this.files.forEach((file) => __async(this, null, function* () {
|
||||
return yield this.app.fileManager.renameFile(file, path.join(this.trashFolderPath, file.name));
|
||||
}));
|
||||
} else
|
||||
this.files.forEach((file) => __async(this, null, function* () {
|
||||
return yield this.app.vault.trash(file, this.useSystemTrash);
|
||||
}));
|
||||
new import_obsidian2.Notice("Trashed " + this.files.length + " files");
|
||||
this.close();
|
||||
}));
|
||||
}
|
||||
onClose() {
|
||||
let { contentEl } = this;
|
||||
contentEl.empty();
|
||||
}
|
||||
};
|
||||
|
||||
// src/main.ts
|
||||
var CustomFilter = class {
|
||||
constructor(regexes, strings) {
|
||||
this.regexes = new Set(regexes.map((x) => RegExp(x)));
|
||||
this.strings = new Set(strings);
|
||||
}
|
||||
test(input) {
|
||||
return Array.from(this.regexes).some((x) => x.test(input)) || Array.from(this.strings).some((x) => x === input);
|
||||
}
|
||||
};
|
||||
var NukeOrphansPlugin = class extends import_obsidian3.Plugin {
|
||||
getIgnoreFilter() {
|
||||
let strings = [];
|
||||
if (this.settings.trashFolderOverride.length > 0)
|
||||
strings.push(this.settings.trashFolderOverride);
|
||||
return new CustomFilter(this.settings.ignorePatterns, strings);
|
||||
}
|
||||
shouldUseSystemTrash() {
|
||||
switch (this.app.vault.config.trashOption) {
|
||||
case "system":
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
getAttachmentsPaths() {
|
||||
if (this.settings.attachmentsPaths.length === 0)
|
||||
return [this.app.vault.config.attachmentFolderPath];
|
||||
return this.settings.attachmentsPaths;
|
||||
}
|
||||
isAttachment(file) {
|
||||
return this.getAttachmentsPaths().some((element) => {
|
||||
console.log(file.path);
|
||||
if (element.startsWith("./")) {
|
||||
if (this.settings.alternativeAttachmentAlg) {
|
||||
let path2 = file.parent;
|
||||
while (path2.name !== void 0 && path2.name.length > 0) {
|
||||
if (path2.name == element.substring(2))
|
||||
return true;
|
||||
path2 = path2.parent;
|
||||
}
|
||||
} else {
|
||||
return file.path.startsWith(element.substring(2)) || file.path.contains(element.substring(1) + "/");
|
||||
}
|
||||
} else {
|
||||
if (file.parent.path == element)
|
||||
return true;
|
||||
if (file.path.startsWith(element))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
getCanvasLinks() {
|
||||
return __async(this, null, function* () {
|
||||
let links = new Set();
|
||||
yield Promise.all(this.app.vault.getFiles().filter((f) => f.extension === "canvas").map((f) => __async(this, null, function* () {
|
||||
const content = yield this.app.vault.read(f);
|
||||
try {
|
||||
const canvas = JSON.parse(content);
|
||||
canvas.nodes.filter((node) => node.type === "file").forEach((node) => links.add(node.file));
|
||||
} catch (e) {
|
||||
console.error("Error parsing canvas file " + f.path + "\n", e);
|
||||
}
|
||||
return Promise.resolve();
|
||||
})));
|
||||
return links;
|
||||
});
|
||||
}
|
||||
getOrphans() {
|
||||
return __async(this, null, function* () {
|
||||
const links = new Set(Object.values(this.app.metadataCache.resolvedLinks).flatMap((x) => Object.keys(x)));
|
||||
const canvasLinks = yield this.getCanvasLinks();
|
||||
const filter = this.getIgnoreFilter();
|
||||
return this.app.vault.getFiles().filter((file) => {
|
||||
return ![
|
||||
links.has(file.path),
|
||||
canvasLinks.has(file.path),
|
||||
filter.test(file.path)
|
||||
].some((x) => x === true);
|
||||
});
|
||||
});
|
||||
}
|
||||
trash(files) {
|
||||
if (files.length > 0)
|
||||
new TrashFilesModal(this.app, files, this.settings.trashFolderOverride, this.shouldUseSystemTrash()).open();
|
||||
else
|
||||
new import_obsidian3.Notice("No orphaned files have been found");
|
||||
}
|
||||
onload() {
|
||||
return __async(this, null, function* () {
|
||||
yield this.loadSettings();
|
||||
this.addCommand({
|
||||
id: "nuke-orphaned-attachments",
|
||||
name: "Trash orphaned attachments",
|
||||
callback: () => __async(this, null, function* () {
|
||||
new import_obsidian3.Notice("Gathering orphaned attachments..");
|
||||
this.trash((yield this.getOrphans()).filter((file) => this.isAttachment(file)));
|
||||
})
|
||||
});
|
||||
this.addCommand({
|
||||
id: "nuke-orphaned-notes",
|
||||
name: "Trash orphaned notes",
|
||||
callback: () => __async(this, null, function* () {
|
||||
new import_obsidian3.Notice("Gathering orphaned notes..");
|
||||
this.trash((yield this.getOrphans()).filter((file) => file.extension === "md"));
|
||||
})
|
||||
});
|
||||
this.addCommand({
|
||||
id: "nuke-orphaned",
|
||||
name: "Trash orphaned files",
|
||||
callback: () => __async(this, null, function* () {
|
||||
new import_obsidian3.Notice("Gathering orphaned files..");
|
||||
this.trash(yield this.getOrphans());
|
||||
})
|
||||
});
|
||||
this.addSettingTab(new NukeOrphansSettingsTab(this.app, this));
|
||||
});
|
||||
}
|
||||
onunload() {
|
||||
}
|
||||
loadSettings() {
|
||||
return __async(this, null, function* () {
|
||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, yield this.loadData());
|
||||
});
|
||||
}
|
||||
saveSettings() {
|
||||
return __async(this, null, function* () {
|
||||
yield this.saveData(this.settings);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/* nosourcemap */
|
10
.obsidian/plugins/nuke-orphans/manifest.json
vendored
Normal file
10
.obsidian/plugins/nuke-orphans/manifest.json
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"id": "nuke-orphans",
|
||||
"name": "Nuke Orphans",
|
||||
"version": "1.2.5",
|
||||
"minAppVersion": "1.3.0",
|
||||
"description": "Plugin that trashes orphaned files and attachments",
|
||||
"author": "Sandorex",
|
||||
"authorUrl": "https://github.com/sandorex",
|
||||
"isDesktopOnly": false
|
||||
}
|
33
.obsidian/plugins/nuke-orphans/styles.css
vendored
Normal file
33
.obsidian/plugins/nuke-orphans/styles.css
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
.trash-modal-button {
|
||||
margin-left: 5px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
/* this is the confirm button so it should be separated */
|
||||
.trash-modal-button:last-of-type {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.trash-modal-file-links {
|
||||
overflow-y: scroll;
|
||||
max-height: 30vw;
|
||||
margin: 1vw;
|
||||
}
|
||||
|
||||
.trash-modal-link {
|
||||
color: var(--text-accent);
|
||||
text-decoration: underline;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.trash-modal-link:hover {
|
||||
color: var(--text-accent-hover, var(--text-accent));
|
||||
}
|
||||
|
||||
.nuke-orphans-pass {
|
||||
color: lightgreen !important;
|
||||
}
|
||||
|
||||
.nuke-orphans-fail {
|
||||
color: red !important;
|
||||
}
|
174
.obsidian/plugins/update-relative-links/main.js
vendored
Normal file
174
.obsidian/plugins/update-relative-links/main.js
vendored
Normal file
@ -0,0 +1,174 @@
|
||||
/*
|
||||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||||
if you want to view the source, please visit the github repository of this plugin
|
||||
*/
|
||||
|
||||
var __defProp = Object.defineProperty;
|
||||
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
||||
var __getOwnPropNames = Object.getOwnPropertyNames;
|
||||
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
||||
var __export = (target, all) => {
|
||||
for (var name in all)
|
||||
__defProp(target, name, { get: all[name], enumerable: true });
|
||||
};
|
||||
var __copyProps = (to, from, except, desc) => {
|
||||
if (from && typeof from === "object" || typeof from === "function") {
|
||||
for (let key of __getOwnPropNames(from))
|
||||
if (!__hasOwnProp.call(to, key) && key !== except)
|
||||
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
||||
}
|
||||
return to;
|
||||
};
|
||||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
||||
|
||||
// main.ts
|
||||
var main_exports = {};
|
||||
__export(main_exports, {
|
||||
default: () => UpdateRelativeLinksPlugin
|
||||
});
|
||||
module.exports = __toCommonJS(main_exports);
|
||||
var import_obsidian = require("obsidian");
|
||||
|
||||
// lib/path.ts
|
||||
var SEP = "/";
|
||||
function dirname(path) {
|
||||
return stackToPath(pathToStack(path).slice(0, -1));
|
||||
}
|
||||
function relative(from, to) {
|
||||
if (!from) {
|
||||
return to;
|
||||
}
|
||||
const fromStack = pathToStack(from);
|
||||
const toStack = pathToStack(to);
|
||||
const firstDiffIdx = fromStack.findIndex((value, idx) => value != toStack[idx]);
|
||||
const resultStack = [];
|
||||
for (let i = firstDiffIdx; i < fromStack.length - 1; i++) {
|
||||
resultStack.push("..");
|
||||
}
|
||||
for (let i = firstDiffIdx; i < toStack.length; i++) {
|
||||
resultStack.push(toStack[i]);
|
||||
}
|
||||
return stackToPath(resultStack);
|
||||
}
|
||||
function pathToStack(path) {
|
||||
return path.split(SEP);
|
||||
}
|
||||
function stackToPath(stack) {
|
||||
return stack.join(SEP);
|
||||
}
|
||||
|
||||
// main.ts
|
||||
var ConfirmModal = class extends import_obsidian.Modal {
|
||||
constructor(app, content, onConfirm) {
|
||||
super(app);
|
||||
this.content = content;
|
||||
this.onConfirm = onConfirm;
|
||||
}
|
||||
onOpen() {
|
||||
const { contentEl } = this;
|
||||
contentEl.createEl("h1", { text: "Update Releate Links Plugin" });
|
||||
contentEl.createEl("p", { text: this.content });
|
||||
new import_obsidian.Setting(contentEl).addButton((btn) => btn.setButtonText("Yes").setCta().onClick(() => {
|
||||
this.close();
|
||||
this.onConfirm();
|
||||
})).addButton((btn) => btn.setButtonText("No").onClick(() => {
|
||||
this.close();
|
||||
}));
|
||||
}
|
||||
onClose() {
|
||||
this.contentEl.empty();
|
||||
}
|
||||
};
|
||||
var UpdateRelativeLinksPlugin = class extends import_obsidian.Plugin {
|
||||
async onload() {
|
||||
const { app } = this;
|
||||
const { metadataCache, vault } = app;
|
||||
const message = "This command will modify all links in the entire vault (not just the current file) to relative paths, and this action cannot be undone. It is recommended that you back up the vault in advance. Please confirm whether you want to execute the command.";
|
||||
this.addCommand({
|
||||
id: "update-all-relative-links",
|
||||
name: "Update all relative links",
|
||||
callback() {
|
||||
new ConfirmModal(app, message, () => {
|
||||
const promises = vault.getMarkdownFiles().map((file) => replace(file, false));
|
||||
Promise.all(promises).then((linkCounts) => {
|
||||
const updatedLinkCounts = linkCounts.filter((count) => count > 0);
|
||||
const linkCount = updatedLinkCounts.reduce((sum, count) => sum + count, 0);
|
||||
const fileCount = updatedLinkCounts.length;
|
||||
new import_obsidian.Notice(`Update ${linkCount} links in ${fileCount} file${fileCount > 1 ? "s" : ""}.`);
|
||||
}).catch((err) => {
|
||||
new import_obsidian.Notice("Update links error, see console.");
|
||||
console.error(err);
|
||||
});
|
||||
}).open();
|
||||
}
|
||||
});
|
||||
this.registerEvent(vault.on("rename", (file, oldPath) => {
|
||||
var _a;
|
||||
if (!oldPath || !file.path.toLocaleLowerCase().endsWith(".md") || ((_a = file.parent) == null ? void 0 : _a.path) === dirname(oldPath)) {
|
||||
return;
|
||||
}
|
||||
if (file instanceof import_obsidian.TFile) {
|
||||
setTimeout(() => replace(file, true), 100);
|
||||
}
|
||||
}));
|
||||
async function replace(file, notice) {
|
||||
var _a, _b;
|
||||
const metadata = metadataCache.getFileCache(file);
|
||||
const links = [...(_a = metadata == null ? void 0 : metadata.links) != null ? _a : [], ...(_b = metadata == null ? void 0 : metadata.embeds) != null ? _b : []];
|
||||
const replacePairs = links.map(({ link, original }) => {
|
||||
var _a2;
|
||||
const linkPath = link.replace(/#.*$/, "");
|
||||
if (!linkPath) {
|
||||
return null;
|
||||
}
|
||||
const linkFile = metadataCache.getFirstLinkpathDest(linkPath, file.path);
|
||||
if (!linkFile) {
|
||||
return null;
|
||||
}
|
||||
const newLinkPath = ((_a2 = file.parent) == null ? void 0 : _a2.path) === "/" ? linkFile.path : relative(file.path, linkFile.path);
|
||||
if (linkPath === newLinkPath) {
|
||||
return null;
|
||||
}
|
||||
const newOriginal = replaceOriginal(original, linkPath, newLinkPath);
|
||||
return [original, newOriginal];
|
||||
}).filter((pair) => pair);
|
||||
if (!(replacePairs == null ? void 0 : replacePairs.length)) {
|
||||
return 0;
|
||||
}
|
||||
try {
|
||||
const content = await vault.read(file);
|
||||
const replacedContent = replacePairs.reduce((tmpContent, pair) => {
|
||||
return (pair == null ? void 0 : pair.length) === 2 ? tmpContent.replace(pair[0], pair[1]) : tmpContent;
|
||||
}, content);
|
||||
await vault.modify(file, replacedContent);
|
||||
const msg = `Update ${replacePairs.length} links in ${file.path}.`;
|
||||
console.log(msg);
|
||||
if (notice) {
|
||||
new import_obsidian.Notice(msg);
|
||||
}
|
||||
return replacePairs.length;
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
if (notice) {
|
||||
new import_obsidian.Notice("Update links error, see console.");
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
function replaceOriginal(original, link, newLink) {
|
||||
let newOriginal = replaceWithFormat(original, link, newLink, (s) => s.replace(/ /g, "%20"));
|
||||
if (original === newOriginal) {
|
||||
newOriginal = replaceWithFormat(original, link, newLink, encodeURI);
|
||||
}
|
||||
if (original === newOriginal) {
|
||||
newOriginal = original.replace(/^(!?\[.*?\]).*$/, `$1(${encodeURI(newLink)})`);
|
||||
}
|
||||
return newOriginal;
|
||||
}
|
||||
function replaceWithFormat(str, from, to, format) {
|
||||
return str.replace(format(from), format(to));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/* nosourcemap */
|
10
.obsidian/plugins/update-relative-links/manifest.json
vendored
Normal file
10
.obsidian/plugins/update-relative-links/manifest.json
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"id": "update-relative-links",
|
||||
"name": "Update Relative Links",
|
||||
"version": "2.1.3",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "Update relative links.",
|
||||
"author": "val",
|
||||
"authorUrl": "https://github.com/val3344/obsidian-update-relative-links",
|
||||
"isDesktopOnly": false
|
||||
}
|
Reference in New Issue
Block a user