vault backup: 2026-03-11 17:25:16
This commit is contained in:
Vendored
+1
-1
@@ -4,7 +4,7 @@
|
||||
"interfaceFontFamily": "",
|
||||
"cssTheme": "Typewriter",
|
||||
"theme": "moonstone",
|
||||
"baseFontSize": 16,
|
||||
"baseFontSize": 15,
|
||||
"enabledCssSnippets": [
|
||||
"tables"
|
||||
]
|
||||
|
||||
Vendored
-1
@@ -16,7 +16,6 @@
|
||||
"lilypond",
|
||||
"novel-word-count",
|
||||
"easy-copy",
|
||||
"anchor-display-text",
|
||||
"calendar",
|
||||
"periodic-notes",
|
||||
"spellcheck-toggler",
|
||||
|
||||
Vendored
+3
-3
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"collapse-filter": false,
|
||||
"search": "",
|
||||
"search": "tag:#type/periodic ",
|
||||
"showTags": false,
|
||||
"showAttachments": false,
|
||||
"hideUnresolved": true,
|
||||
"hideUnresolved": false,
|
||||
"showOrphans": true,
|
||||
"collapse-color-groups": false,
|
||||
"colorGroups": [
|
||||
@@ -25,6 +25,6 @@
|
||||
"repelStrength": 10,
|
||||
"linkStrength": 1,
|
||||
"linkDistance": 250,
|
||||
"scale": 0.18454855383603416,
|
||||
"scale": 0.18454855383603405,
|
||||
"close": false
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
{
|
||||
"includeNoteName": "headersOnly",
|
||||
"titleProperty": "title",
|
||||
"whichHeadings": "allHeaders",
|
||||
"includeNotice": false,
|
||||
"sep": " ",
|
||||
"suggest": true,
|
||||
"ignoreEmbedded": true
|
||||
}
|
||||
-306
@@ -1,306 +0,0 @@
|
||||
/*
|
||||
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: () => AnchorDisplayText
|
||||
});
|
||||
module.exports = __toCommonJS(main_exports);
|
||||
var import_obsidian = require("obsidian");
|
||||
var RE_ANCHOR_NO_DISPLAY = /!?\[\[([^\]]+#[^|\n\r\]]+)\]\]$/;
|
||||
var RE_ANCHOR_DISPLAY = /(\[\[([^\]]+#[^\n\r\]]+)\]\])$/;
|
||||
var RE_DISPLAY = /\|([^\]]+)/;
|
||||
var DEFAULT_SETTINGS = {
|
||||
includeNoteName: "headersOnly",
|
||||
titleProperty: "",
|
||||
whichHeadings: "allHeaders",
|
||||
includeNotice: false,
|
||||
sep: " ",
|
||||
suggest: true,
|
||||
ignoreEmbedded: true
|
||||
};
|
||||
var AnchorDisplayText = class extends import_obsidian.Plugin {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.suggestionsRegistered = false;
|
||||
}
|
||||
async onload() {
|
||||
await this.loadSettings();
|
||||
this.addSettingTab(new AnchorDisplayTextSettingTab(this.app, this));
|
||||
if (this.settings.suggest) {
|
||||
this.registerEditorSuggest(new AnchorDisplaySuggest(this));
|
||||
this.suggestionsRegistered = true;
|
||||
}
|
||||
this.registerEvent(
|
||||
this.app.workspace.on("editor-change", (editor) => {
|
||||
var _a;
|
||||
const cursor = editor.getCursor();
|
||||
const currentLine = editor.getLine(cursor.line);
|
||||
const lastChars = currentLine.slice(cursor.ch - 2, cursor.ch);
|
||||
if (lastChars !== "]]")
|
||||
return;
|
||||
const match = currentLine.slice(0, cursor.ch).match(RE_ANCHOR_NO_DISPLAY);
|
||||
if (match) {
|
||||
if (this.settings.ignoreEmbedded && match[0].charAt(0) === "!")
|
||||
return;
|
||||
const headings = match[1].split("#");
|
||||
let notename = headings[0];
|
||||
if (this.settings.titleProperty) {
|
||||
notename = this.getTitleFromFile(notename);
|
||||
}
|
||||
let displayText = "";
|
||||
if (this.settings.whichHeadings === "lastHeader") {
|
||||
displayText = headings[headings.length - 1];
|
||||
} else {
|
||||
displayText = headings[1];
|
||||
if (this.settings.whichHeadings === "allHeaders") {
|
||||
for (let i = 2; i < headings.length; i++) {
|
||||
displayText += this.settings.sep + headings[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
const startIndex = ((_a = match.index) != null ? _a : 0) + match[0].length - 2;
|
||||
if (this.settings.includeNoteName === "noteNameFirst") {
|
||||
displayText = `${notename}${this.settings.sep}${displayText}`;
|
||||
} else if (this.settings.includeNoteName === "noteNameLast") {
|
||||
displayText = `${displayText}${this.settings.sep}${notename}`;
|
||||
}
|
||||
if (displayText.startsWith("^")) {
|
||||
displayText = displayText.slice(1);
|
||||
}
|
||||
editor.replaceRange(`|${displayText}`, { line: cursor.line, ch: startIndex }, void 0, "headerDisplayText");
|
||||
if (this.settings.includeNotice) {
|
||||
new import_obsidian.Notice(`Updated anchor link display text.`);
|
||||
}
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
onunload() {
|
||||
}
|
||||
/**
|
||||
* Get title property value from file's frontmatter
|
||||
* @param filename - The filename to look up
|
||||
* @returns The title property value if found, otherwise returns the original filename
|
||||
*/
|
||||
getTitleFromFile(filename) {
|
||||
if (this.settings.titleProperty) {
|
||||
const file = this.app.metadataCache.getFirstLinkpathDest(filename, "");
|
||||
if (file) {
|
||||
const cache = this.app.metadataCache.getFileCache(file);
|
||||
if (cache && cache.frontmatter && cache.frontmatter[this.settings.titleProperty]) {
|
||||
return String(cache.frontmatter[this.settings.titleProperty]);
|
||||
}
|
||||
}
|
||||
}
|
||||
return filename;
|
||||
}
|
||||
async loadSettings() {
|
||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData());
|
||||
}
|
||||
async saveSettings() {
|
||||
await this.saveData(this.settings);
|
||||
}
|
||||
};
|
||||
var AnchorDisplaySuggest = class extends import_obsidian.EditorSuggest {
|
||||
constructor(plugin) {
|
||||
super(plugin.app);
|
||||
this.suggestionSelected = null;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
onTrigger(cursor, editor) {
|
||||
if (!this.plugin.settings.suggest)
|
||||
return null;
|
||||
if (this.suggestionSelected) {
|
||||
if (this.suggestionSelected.ch === cursor.ch && this.suggestionSelected.line === cursor.line)
|
||||
return null;
|
||||
this.suggestionSelected = null;
|
||||
return null;
|
||||
}
|
||||
const currentLine = editor.getLine(cursor.line);
|
||||
const lastChars = currentLine.slice(cursor.ch - 2, cursor.ch);
|
||||
if (lastChars !== "]]")
|
||||
return null;
|
||||
const slice = currentLine.slice(0, cursor.ch);
|
||||
const match = slice.match(RE_ANCHOR_DISPLAY);
|
||||
if (!match)
|
||||
return null;
|
||||
if (this.plugin.settings.ignoreEmbedded && slice.charAt(match.index - 1) === "!")
|
||||
return null;
|
||||
return {
|
||||
start: {
|
||||
line: cursor.line,
|
||||
ch: match.index + match[1].length - 2
|
||||
// 2 less to keep closing brackets
|
||||
},
|
||||
end: {
|
||||
line: cursor.line,
|
||||
ch: match.index + match[1].length - 2
|
||||
},
|
||||
query: match[2]
|
||||
};
|
||||
}
|
||||
getSuggestions(context) {
|
||||
const headings = context.query.split("|")[0].split("#");
|
||||
let notename = headings[0];
|
||||
if (this.plugin.settings.titleProperty) {
|
||||
notename = this.plugin.getTitleFromFile(notename);
|
||||
}
|
||||
let displayText = headings[1];
|
||||
if (displayText.startsWith("^")) {
|
||||
displayText = displayText.slice(1);
|
||||
}
|
||||
for (let i = 2; i < headings.length; i++) {
|
||||
displayText += this.plugin.settings.sep + headings[i];
|
||||
}
|
||||
const suggestion1 = {
|
||||
displayText,
|
||||
source: "Don't include note name"
|
||||
};
|
||||
const suggestion2 = {
|
||||
displayText: `${notename}${this.plugin.settings.sep}${displayText}`,
|
||||
source: "Note name and than heading(s)"
|
||||
};
|
||||
const suggestion3 = {
|
||||
displayText: `${displayText}${this.plugin.settings.sep}${notename}`,
|
||||
source: "Heading(s) and than note name"
|
||||
};
|
||||
return [suggestion1, suggestion2, suggestion3];
|
||||
}
|
||||
renderSuggestion(value, el) {
|
||||
const suggestionEl = el.parentElement;
|
||||
const suggestionContainerEl = suggestionEl.parentElement;
|
||||
if (suggestionContainerEl.childElementCount < 2) {
|
||||
const promptInstructionsEl = suggestionContainerEl.createDiv({ cls: "prompt-instructions" });
|
||||
const instructionEl = promptInstructionsEl.createDiv({ cls: "prompt-instruction" });
|
||||
instructionEl.createEl("span", { cls: "prompt-instruction-command", text: "\u21B5" });
|
||||
instructionEl.createEl("span", { text: "to accept" });
|
||||
}
|
||||
el.setAttribute("class", "suggestion-item mod-complex");
|
||||
const suggestionContentEl = el.createDiv({ cls: "suggestion-content" });
|
||||
suggestionContentEl.createDiv({ cls: "suggestion-title", text: value.displayText });
|
||||
suggestionContentEl.createDiv({ cls: "suggestion-note", text: value.source });
|
||||
}
|
||||
selectSuggestion(value, evt) {
|
||||
const editor = this.context.editor;
|
||||
const match = this.context.query.match(RE_DISPLAY);
|
||||
if (match) {
|
||||
this.context.start.ch = this.context.start.ch - match[0].length;
|
||||
}
|
||||
editor.replaceRange(`|${value.displayText}`, this.context.start, this.context.end, "headerDisplayText");
|
||||
this.suggestionSelected = this.context.end;
|
||||
}
|
||||
};
|
||||
var AnchorDisplayTextSettingTab = class extends import_obsidian.PluginSettingTab {
|
||||
constructor(app, plugin) {
|
||||
super(app, plugin);
|
||||
this.sepWarning = null;
|
||||
this.plugin = plugin;
|
||||
}
|
||||
validateSep(value) {
|
||||
let validValue = value;
|
||||
for (const c of value) {
|
||||
if ("[]#^|".includes(c)) {
|
||||
validValue = validValue.replace(c, "");
|
||||
}
|
||||
}
|
||||
if (validValue != value) {
|
||||
if (!this.sepWarning) {
|
||||
this.sepWarning = new import_obsidian.Notice(`Separators cannot contain any of the following characters: []#^|`, 0);
|
||||
}
|
||||
} else {
|
||||
if (this.sepWarning) {
|
||||
this.sepWarning.hide();
|
||||
this.sepWarning = null;
|
||||
}
|
||||
}
|
||||
return validValue;
|
||||
}
|
||||
display() {
|
||||
const { containerEl } = this;
|
||||
containerEl.empty();
|
||||
new import_obsidian.Setting(containerEl).setName("Include note name").setDesc("Include the title of the note in the display text.").addDropdown((dropdown) => {
|
||||
dropdown.addOption("headersOnly", "Don't include note name");
|
||||
dropdown.addOption("noteNameFirst", "Note name and then heading(s)");
|
||||
dropdown.addOption("noteNameLast", "Heading(s) and then note name");
|
||||
dropdown.setValue(this.plugin.settings.includeNoteName);
|
||||
dropdown.onChange((value) => {
|
||||
this.plugin.settings.includeNoteName = value;
|
||||
this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
new import_obsidian.Setting(containerEl).setName("Title property").setDesc("If set, use the value of this property as the note name. (Leave blank to use file name)").addText((text) => {
|
||||
text.setValue(this.plugin.settings.titleProperty);
|
||||
text.onChange((value) => {
|
||||
this.plugin.settings.titleProperty = value;
|
||||
this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
new import_obsidian.Setting(containerEl).setName("Include subheadings").setDesc("Change which headings and subheadings are in the display text.").addDropdown((dropdown) => {
|
||||
dropdown.addOption("allHeaders", "All linked headings");
|
||||
dropdown.addOption("lastHeader", "Last heading only");
|
||||
dropdown.addOption("firstHeader", "First heading only");
|
||||
dropdown.setValue(this.plugin.settings.whichHeadings);
|
||||
dropdown.onChange((value) => {
|
||||
this.plugin.settings.whichHeadings = value;
|
||||
this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
new import_obsidian.Setting(containerEl).setName("Separator").setDesc("Choose what to insert between headings instead of #.").addText((text) => {
|
||||
text.setValue(this.plugin.settings.sep);
|
||||
text.onChange((value) => {
|
||||
this.plugin.settings.sep = this.validateSep(value);
|
||||
this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
new import_obsidian.Setting(containerEl).setName("Enable notifications").setDesc("Have a notice pop up whenever an anchor link is automatically changed.").addToggle((toggle) => {
|
||||
toggle.setValue(this.plugin.settings.includeNotice);
|
||||
toggle.onChange((value) => {
|
||||
this.plugin.settings.includeNotice = value;
|
||||
this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
new import_obsidian.Setting(containerEl).setName("Suggest alternatives").setDesc("Have a suggestion window to present alternative display text options when the cursor is directly after an anchor link.").addToggle((toggle) => {
|
||||
toggle.setValue(this.plugin.settings.suggest);
|
||||
toggle.onChange((value) => {
|
||||
this.plugin.settings.suggest = value;
|
||||
this.plugin.saveSettings();
|
||||
if (!this.plugin.suggestionsRegistered) {
|
||||
this.plugin.registerEditorSuggest(new AnchorDisplaySuggest(this.plugin));
|
||||
this.plugin.suggestionsRegistered = true;
|
||||
}
|
||||
});
|
||||
});
|
||||
new import_obsidian.Setting(containerEl).setName("Ignore embedded files").setDesc("Don't add or change display text for embedded files.").addToggle((toggle) => {
|
||||
toggle.setValue(this.plugin.settings.ignoreEmbedded);
|
||||
toggle.onChange((value) => {
|
||||
this.plugin.settings.ignoreEmbedded = value;
|
||||
this.plugin.saveSettings();
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/* nosourcemap */
|
||||
@@ -1,10 +0,0 @@
|
||||
{
|
||||
"id": "anchor-display-text",
|
||||
"name": "Anchor Link Display Text",
|
||||
"version": "1.4.0",
|
||||
"minAppVersion": "0.15.0",
|
||||
"description": "Automatically uses the linked heading as the display text for anchor links.",
|
||||
"author": "Robert C Arsenault",
|
||||
"authorUrl": "https://github.com/rca-umb",
|
||||
"isDesktopOnly": false
|
||||
}
|
||||
+2
-2
@@ -14,7 +14,7 @@
|
||||
"targetFolders": "",
|
||||
"scanDelay": 250,
|
||||
"useTitle": true,
|
||||
"reduceNestedParent": true,
|
||||
"reduceNestedParent": false,
|
||||
"frontmatterKey": "title",
|
||||
"useTagInfo": false,
|
||||
"tagInfo": "pininfo.md",
|
||||
@@ -26,7 +26,7 @@
|
||||
"useMultiPaneList": false,
|
||||
"archiveTags": "",
|
||||
"disableNarrowingDown": true,
|
||||
"expandUntaggedToRoot": false,
|
||||
"expandUntaggedToRoot": true,
|
||||
"disableDragging": false,
|
||||
"linkConfig": {
|
||||
"incoming": {
|
||||
|
||||
Reference in New Issue
Block a user