Fixed crashing at load

This commit is contained in:
Signynt 2026-07-18 14:27:47 +02:00
parent 5ee6617053
commit 2a32c85b33
3 changed files with 38 additions and 31 deletions

20
main.ts
View file

@ -13,6 +13,7 @@ import {
getAllTags,
ItemView,
WorkspaceLeaf,
SettingDefinitionItem,
} from 'obsidian';
declare module 'obsidian' {
@ -1268,8 +1269,7 @@ export default class VirtualFooterPlugin extends Plugin {
const specialClass = isHeader ? 'virtual-footer-above-properties' : 'virtual-footer-above-backlinks';
// Create new content container
const activeDocument = this.getActiveDocument();
const groupDiv = activeDocument.createDiv() as HTMLElementWithComponent;
const groupDiv = container.createDiv() as HTMLElementWithComponent;
groupDiv.className = `${CSS_DYNAMIC_CONTENT_ELEMENT} ${cssClass}`;
groupDiv.dataset.sourcePath = filePath;
if (special) {
@ -1452,8 +1452,7 @@ export default class VirtualFooterPlugin extends Plugin {
const component = new Component();
component.load();
const activeDocument = this.getActiveDocument();
const groupDiv = activeDocument.createDiv() as HTMLElementWithComponent;
const groupDiv = container.createDiv() as HTMLElementWithComponent;
groupDiv.className = `${CSS_DYNAMIC_CONTENT_ELEMENT} ${CSS_SECTION_HEADER_GROUP_ELEMENT}`;
this.setSectionHeaderDataset(groupDiv, rule, ruleIndex);
groupDiv.dataset.sourcePath = filePath;
@ -1918,8 +1917,7 @@ export default class VirtualFooterPlugin extends Plugin {
const component = new Component();
component.load();
const activeDocument = this.getActiveDocument();
const groupDiv = activeDocument.createDiv() as HTMLElementWithComponent;
const groupDiv = view.containerEl.createDiv() as HTMLElementWithComponent;
groupDiv.className = `${CSS_DYNAMIC_CONTENT_ELEMENT} ${CSS_SECTION_HEADER_GROUP_ELEMENT}`;
this.setSectionHeaderDataset(groupDiv, rule, ruleIndex);
groupDiv.dataset.sourcePath = sourcePath;
@ -1996,8 +1994,7 @@ export default class VirtualFooterPlugin extends Plugin {
const sourcePath = view.file?.path || ''; // For MarkdownRenderer context
// Create container div for the content
const activeDocument = this.getActiveDocument();
const groupDiv = activeDocument.createDiv() as HTMLElementWithComponent;
const groupDiv = view.containerEl.createDiv() as HTMLElementWithComponent;
groupDiv.className = CSS_DYNAMIC_CONTENT_ELEMENT; // Base class for all injected content
groupDiv.classList.add(
isRenderInHeader ? CSS_HEADER_GROUP_ELEMENT : CSS_FOOTER_GROUP_ELEMENT,
@ -3756,13 +3753,14 @@ class RuleEditorModal extends Modal {
* Manages the settings tab UI for the VirtualFooter plugin.
* Allows users to configure rules for dynamic content injection.
*/
class VirtualFooterSettingTab {
class VirtualFooterSettingTab extends PluginSettingTab {
// Caches for suggestion lists to improve performance
private allFolderPathsCache: Set<string> | null = null;
private allTagsCache: Set<string> | null = null;
private allMarkdownFilePathsCache: Set<string> | null = null;
private allPropertyNamesCache: Set<string> | null = null;
constructor(private app: App, private plugin: VirtualFooterPlugin) {
constructor(app: App, private plugin: VirtualFooterPlugin) {
super(app, plugin);
}
/**
@ -3838,7 +3836,7 @@ class VirtualFooterSettingTab {
return this.allPropertyNamesCache;
}
getSettingDefinitions() {
getSettingDefinitions(): SettingDefinitionItem[] {
this.clearSuggestionCaches();
const rules = this.plugin.settings.rules ?? [];
return [

47
package-lock.json generated
View file

@ -13,15 +13,15 @@
"@typescript-eslint/eslint-plugin": "5.29.0",
"@typescript-eslint/parser": "5.29.0",
"esbuild": "^0.25.8",
"obsidian": "latest",
"obsidian": "^1.13.1",
"tslib": "2.4.0",
"typescript": "4.7.4"
}
},
"node_modules/@codemirror/state": {
"version": "6.5.2",
"resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.5.2.tgz",
"integrity": "sha512-FVqsPqtPWKVVL3dPSxy8wEF/ymIEuVzF1PK3VbUgrxXpJUSHQWWZz4JMToquRxnkw+36LTamCZG2iua2Ptq0fA==",
"version": "6.5.0",
"resolved": "https://registry.npmjs.org/@codemirror/state/-/state-6.5.0.tgz",
"integrity": "sha512-MwBHVK60IiIHDcoMet78lxt6iw5gJOGSbNbOIVBHWVXIH4/Nq1+GQgLLGgI1KlnN86WDXsPudVaqYHKBIx7Eyw==",
"dev": true,
"license": "MIT",
"peer": true,
@ -30,14 +30,15 @@
}
},
"node_modules/@codemirror/view": {
"version": "6.35.0",
"resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.35.0.tgz",
"integrity": "sha512-I0tYy63q5XkaWsJ8QRv5h6ves7kvtrBWjBcnf/bzohFJQc5c14a1AQRdE8QpPF9eMp5Mq2FMm59TCj1gDfE7kw==",
"version": "6.38.6",
"resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.38.6.tgz",
"integrity": "sha512-qiS0z1bKs5WOvHIAC0Cybmv4AJSkAXgX5aD6Mqd2epSLlVJsQl8NG23jCVouIgkh4All/mrbdsf2UOLFnJw0tw==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"@codemirror/state": "^6.4.0",
"@codemirror/state": "^6.5.0",
"crelt": "^1.0.6",
"style-mod": "^4.1.0",
"w3c-keyname": "^2.2.4"
}
@ -593,9 +594,9 @@
"peer": true
},
"node_modules/@marijn/find-cluster-break": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@marijn/find-cluster-break/-/find-cluster-break-1.0.2.tgz",
"integrity": "sha512-l0h88YhZFyKdXIFNfSWpyjStDjGHwZ/U7iobcK1cQQD8sejsONdQtTVU+1wVN1PBw40PiiHB1vA5S7VTfQiP9g==",
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@marijn/find-cluster-break/-/find-cluster-break-1.0.3.tgz",
"integrity": "sha512-FY+MKLBoTsLNJF/eLWaOsXGdz6uh3Iu1axjPf6TUq92IYumcTcXWHoS747JARLkcdlJ/Waiaxc5wQfFO8jC6NA==",
"dev": true,
"license": "MIT",
"peer": true
@ -1060,6 +1061,14 @@
"license": "MIT",
"peer": true
},
"node_modules/crelt": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/crelt/-/crelt-1.0.7.tgz",
"integrity": "sha512-aK6BbWfhf4U/wCcLHKPJl/xa6VkVstRaPywWtMKGwuOLc/wZTyQYuoxgvZnNsBvv7Kg3YTBQYYBCggcviQczuA==",
"dev": true,
"license": "MIT",
"peer": true
},
"node_modules/cross-spawn": {
"version": "7.0.6",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
@ -1923,9 +1932,9 @@
"peer": true
},
"node_modules/obsidian": {
"version": "1.8.7",
"resolved": "https://registry.npmjs.org/obsidian/-/obsidian-1.8.7.tgz",
"integrity": "sha512-h4bWwNFAGRXlMlMAzdEiIM2ppTGlrh7uGOJS6w4gClrsjc+ei/3YAtU2VdFUlCiPuTHpY4aBpFJJW75S1Tl/JA==",
"version": "1.13.1",
"resolved": "https://registry.npmjs.org/obsidian/-/obsidian-1.13.1.tgz",
"integrity": "sha512-qtTEA2pmhJzhuhJqzbBFRYhpIOqvW+krDYjtFynv66KbxBbumHBlsJfWw3I4jtnK/6fZwbQhCrmmDdRwXmX56w==",
"dev": true,
"license": "MIT",
"dependencies": {
@ -1933,8 +1942,8 @@
"moment": "2.29.4"
},
"peerDependencies": {
"@codemirror/state": "^6.0.0",
"@codemirror/view": "^6.0.0"
"@codemirror/state": "6.5.0",
"@codemirror/view": "6.38.6"
}
},
"node_modules/once": {
@ -2268,9 +2277,9 @@
}
},
"node_modules/style-mod": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.2.tgz",
"integrity": "sha512-wnD1HyVqpJUI2+eKZ+eo1UwghftP6yuFheBqqe+bWCotBjC2K1YnteJILRMs3SM4V/0dLEW1SC27MWP5y+mwmw==",
"version": "4.1.3",
"resolved": "https://registry.npmjs.org/style-mod/-/style-mod-4.1.3.tgz",
"integrity": "sha512-i/n8VsZydrugj3Iuzll8+x/00GH2vnYsk1eomD8QiRrSAeW6ItbCQDtfXCeJHd0iwiNagqjQkvpvREEPtW3IoQ==",
"dev": true,
"license": "MIT",
"peer": true

View file

@ -16,7 +16,7 @@
"@typescript-eslint/eslint-plugin": "5.29.0",
"@typescript-eslint/parser": "5.29.0",
"esbuild": "^0.25.8",
"obsidian": "latest",
"obsidian": "^1.13.1",
"tslib": "2.4.0",
"typescript": "4.7.4"
}