mirror of
https://github.com/mnaoumov/obsidian-smart-rename.git
synced 2026-07-22 07:40:32 +00:00
Update libs
This commit is contained in:
parent
5bfb3258af
commit
df0da2b487
4 changed files with 1711 additions and 673 deletions
2346
package-lock.json
generated
2346
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -16,10 +16,10 @@
|
|||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@tsconfig/strictest": "^2.0.5",
|
||||
"@types/node": "^22.9.1",
|
||||
"@types/node": "^22.10.2",
|
||||
"obsidian": "^1.7.2",
|
||||
"obsidian-dev-utils": "^4.13.0",
|
||||
"obsidian-typings": "^2.3.3"
|
||||
"obsidian-dev-utils": "^9.0.0",
|
||||
"obsidian-typings": "^2.7.0"
|
||||
},
|
||||
"type": "module"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import type {
|
|||
TAbstractFile
|
||||
} from 'obsidian';
|
||||
import type { MaybePromise } from 'obsidian-dev-utils/Async';
|
||||
import type { GenerateMarkdownLinkOptions } from 'obsidian-dev-utils/obsidian/Link';
|
||||
import type { CustomArrayDict } from 'obsidian-typings';
|
||||
|
||||
import {
|
||||
|
|
@ -13,16 +14,20 @@ import {
|
|||
TFile
|
||||
} from 'obsidian';
|
||||
import { invokeAsyncSafely } from 'obsidian-dev-utils/Async';
|
||||
import { toJson } from 'obsidian-dev-utils/Object';
|
||||
import {
|
||||
normalizeOptionalProperties,
|
||||
toJson
|
||||
} from 'obsidian-dev-utils/Object';
|
||||
import {
|
||||
addAlias,
|
||||
processFrontMatter
|
||||
processFrontmatter
|
||||
} from 'obsidian-dev-utils/obsidian/FileManager';
|
||||
import { getFile } from 'obsidian-dev-utils/obsidian/FileSystem';
|
||||
import {
|
||||
editLinks,
|
||||
extractLinkFile,
|
||||
generateMarkdownLink
|
||||
|
||||
} from 'obsidian-dev-utils/obsidian/Link';
|
||||
import {
|
||||
getBacklinksForFileSafe,
|
||||
|
|
@ -51,8 +56,8 @@ export class SmartRenamePlugin extends PluginBase<SmartRenamePluginSettings> {
|
|||
return this.invalidCharactersRegExp.test(str);
|
||||
}
|
||||
|
||||
protected override createDefaultPluginSettings(): SmartRenamePluginSettings {
|
||||
return new SmartRenamePluginSettings();
|
||||
protected override createPluginSettings(data: unknown): SmartRenamePluginSettings {
|
||||
return new SmartRenamePluginSettings(data);
|
||||
}
|
||||
|
||||
protected override createPluginSettingsTab(): null | PluginSettingTab {
|
||||
|
|
@ -145,13 +150,13 @@ export class SmartRenamePlugin extends PluginBase<SmartRenamePluginSettings> {
|
|||
|
||||
const alias = (link.displayText ?? '').toLowerCase() === newTitle.toLowerCase() ? oldTitle : link.displayText;
|
||||
|
||||
return generateMarkdownLink({
|
||||
return generateMarkdownLink(normalizeOptionalProperties<GenerateMarkdownLinkOptions>({
|
||||
alias,
|
||||
app: this.app,
|
||||
originalLink: link.original,
|
||||
pathOrFile: newPath,
|
||||
sourcePathOrFile: backlinkNotePath
|
||||
});
|
||||
sourcePathOrFile: backlinkNotePath,
|
||||
targetPathOrFile: newPath
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -256,7 +261,7 @@ export class SmartRenamePlugin extends PluginBase<SmartRenamePluginSettings> {
|
|||
if (!this.settings.shouldUpdateTitleKey) {
|
||||
return;
|
||||
}
|
||||
await processFrontMatter(this.app, newPath, (frontMatter) => {
|
||||
await processFrontmatter(this.app, newPath, (frontMatter) => {
|
||||
frontMatter['title'] = titleToStore;
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,16 @@
|
|||
import { PluginSettingsBase } from 'obsidian-dev-utils/obsidian/Plugin/PluginSettingsBase';
|
||||
|
||||
import { InvalidCharacterAction } from './InvalidCharacterAction.ts';
|
||||
|
||||
export class SmartRenamePluginSettings {
|
||||
export class SmartRenamePluginSettings extends PluginSettingsBase {
|
||||
public invalidCharacterAction = InvalidCharacterAction.Error;
|
||||
|
||||
public replacementCharacter = '_';
|
||||
public shouldStoreInvalidTitle = true;
|
||||
public shouldUpdateFirstHeader = false;
|
||||
public shouldUpdateTitleKey = false;
|
||||
public constructor(data: unknown) {
|
||||
super();
|
||||
this.init(data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue