chore(metaagent): рабочее пространство агента и заготовка тестов
CI / Lint & Test (push) Canceled after 0s
CI / Lint & Test (push) Canceled after 0s
- .agent/: контекст, запросы, роадмап, задачи, шаблоны и протоколы - заготовка тестовой инфраструктуры: vitest, eslint, prettier, ci-workflow
This commit is contained in:
1 parent
7443ec059f
commit
3e1d9776c3
66 files changed
+7150
-696
No files matched your search
+1
-2
@@ -42,8 +42,7 @@ export const en: Locale = {
|
||||
},
|
||||
'preserve-link-aliases': {
|
||||
name: 'Preserve Link Aliases',
|
||||
description:
|
||||
'Preserves original link aliases when attachments are renamed',
|
||||
description: 'Preserves original link aliases when attachments are renamed',
|
||||
processEmbedsLabel: 'Process embed links',
|
||||
processEmbedsDesc: 'Also process ![[embed]] links (disabled by default)',
|
||||
processCanvasLabel: 'Process Canvas files',
|
||||
|
||||
+1
-2
@@ -19,8 +19,7 @@ export const ru: Locale = {
|
||||
},
|
||||
'preserve-link-aliases': {
|
||||
name: 'Сохранение алиасов ссылок',
|
||||
description:
|
||||
'Сохраняет оригинальные алиасы ссылок при переименовании вложений',
|
||||
description: 'Сохраняет оригинальные алиасы ссылок при переименовании вложений',
|
||||
processEmbedsLabel: 'Обрабатывать embed-ссылки',
|
||||
processEmbedsDesc: 'Также обрабатывать ![[embed]] ссылки (по умолчанию выключено)',
|
||||
processCanvasLabel: 'Обрабатывать Canvas-файлы',
|
||||
|
||||
+1
-5
@@ -27,11 +27,7 @@ export default class ZeroQoLModulesPlugin extends Plugin {
|
||||
}
|
||||
|
||||
async loadSettings() {
|
||||
this.settings = Object.assign(
|
||||
{},
|
||||
DEFAULT_SETTINGS,
|
||||
await this.loadData(),
|
||||
) as ZeroQSettings;
|
||||
this.settings = Object.assign({}, DEFAULT_SETTINGS, await this.loadData()) as ZeroQSettings;
|
||||
|
||||
for (const module of MODULES) {
|
||||
if (!this.settings.modules[module.id]) {
|
||||
|
||||
@@ -40,10 +40,7 @@ export class AttachmentCleanPasteModule extends BaseModule {
|
||||
);
|
||||
this.registerCleanup(() => plugin.app.workspace.offref(pasteRef));
|
||||
|
||||
const dropRef = plugin.app.workspace.on(
|
||||
'editor-drop',
|
||||
this.createDropHandler(rawSettings),
|
||||
);
|
||||
const dropRef = plugin.app.workspace.on('editor-drop', this.createDropHandler(rawSettings));
|
||||
this.registerCleanup(() => plugin.app.workspace.offref(dropRef));
|
||||
}
|
||||
|
||||
@@ -77,9 +74,7 @@ export class AttachmentCleanPasteModule extends BaseModule {
|
||||
settings: AttachmentCleanPasteSettings,
|
||||
evt: ClipboardEvent | DragEvent,
|
||||
): Promise<void> {
|
||||
const matchingFiles = Array.from(files).filter((f) =>
|
||||
this.shouldProcess(f.name, settings),
|
||||
);
|
||||
const matchingFiles = Array.from(files).filter((f) => this.shouldProcess(f.name, settings));
|
||||
if (matchingFiles.length === 0) return;
|
||||
|
||||
evt.preventDefault();
|
||||
@@ -121,10 +116,7 @@ export class AttachmentCleanPasteModule extends BaseModule {
|
||||
};
|
||||
}
|
||||
|
||||
private shouldProcess(
|
||||
filename: string,
|
||||
settings: AttachmentCleanPasteSettings,
|
||||
): boolean {
|
||||
private shouldProcess(filename: string, settings: AttachmentCleanPasteSettings): boolean {
|
||||
const dotIndex = filename.lastIndexOf('.');
|
||||
if (dotIndex === -1) return false;
|
||||
const ext = filename.slice(dotIndex + 1).toLowerCase();
|
||||
@@ -149,9 +141,7 @@ export class AttachmentCleanPasteModule extends BaseModule {
|
||||
const filename = file.name;
|
||||
const nameWithoutExt = filename.replace(/\.[^/.]+$/, '');
|
||||
|
||||
let attachmentFolder = this.app.vault.getConfig(
|
||||
'attachmentFolderPath',
|
||||
) as string;
|
||||
let attachmentFolder = this.app.vault.getConfig('attachmentFolderPath') as string;
|
||||
if (!attachmentFolder) attachmentFolder = 'attachments';
|
||||
|
||||
const folderPath = normalizePath(attachmentFolder);
|
||||
@@ -162,10 +152,7 @@ export class AttachmentCleanPasteModule extends BaseModule {
|
||||
const ext = filename.slice(filename.lastIndexOf('.') + 1);
|
||||
const basePath = normalizePath(`${folderPath}/${nameWithoutExt}`);
|
||||
|
||||
const availablePath = await this.app.vault.getAvailablePath(
|
||||
basePath,
|
||||
ext,
|
||||
);
|
||||
const availablePath = await this.app.vault.getAvailablePath(basePath, ext);
|
||||
|
||||
await this.app.vault.createBinary(availablePath, arrayBuffer);
|
||||
|
||||
|
||||
@@ -28,9 +28,8 @@ export class PreserveLinkAliasesModule extends BaseModule {
|
||||
this.vault = plugin.app.vault;
|
||||
const rawSettings = moduleSettings as PreserveLinkAliasesSettings;
|
||||
|
||||
const renameRef = plugin.app.vault.on(
|
||||
'rename',
|
||||
(file: TFile, oldPath: string) => this.handleRename(file, oldPath, rawSettings),
|
||||
const renameRef = plugin.app.vault.on('rename', (file: TFile, oldPath: string) =>
|
||||
this.handleRename(file, oldPath, rawSettings),
|
||||
);
|
||||
this.registerCleanup(() => plugin.app.vault.offref(renameRef));
|
||||
}
|
||||
@@ -47,24 +46,20 @@ export class PreserveLinkAliasesModule extends BaseModule {
|
||||
.setName(loc.processEmbedsLabel)
|
||||
.setDesc(loc.processEmbedsDesc)
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(s.processEmbeds)
|
||||
.onChange(async (value) => {
|
||||
s.processEmbeds = value;
|
||||
await saveSettings();
|
||||
}),
|
||||
toggle.setValue(s.processEmbeds).onChange(async (value) => {
|
||||
s.processEmbeds = value;
|
||||
await saveSettings();
|
||||
}),
|
||||
);
|
||||
|
||||
new Setting(containerEl)
|
||||
.setName(loc.processCanvasLabel)
|
||||
.setDesc(loc.processCanvasDesc)
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(s.processCanvas)
|
||||
.onChange(async (value) => {
|
||||
s.processCanvas = value;
|
||||
await saveSettings();
|
||||
}),
|
||||
toggle.setValue(s.processCanvas).onChange(async (value) => {
|
||||
s.processCanvas = value;
|
||||
await saveSettings();
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -85,7 +80,13 @@ export class PreserveLinkAliasesModule extends BaseModule {
|
||||
|
||||
for (const f of files) {
|
||||
const content = await this.vault.read(f);
|
||||
const updated = this.processContent(content, newName, newBasename, oldBasename, settings);
|
||||
const updated = this.processContent(
|
||||
content,
|
||||
newName,
|
||||
newBasename,
|
||||
oldBasename,
|
||||
settings,
|
||||
);
|
||||
|
||||
if (updated !== content) {
|
||||
await this.vault.modify(f, updated);
|
||||
|
||||
+18
-22
@@ -51,31 +51,27 @@ export class ZeroQSettingTab extends PluginSettingTab {
|
||||
.setName(module.name)
|
||||
.setDesc(module.description)
|
||||
.addToggle((toggle) =>
|
||||
toggle
|
||||
.setValue(moduleCfg?.enabled ?? true)
|
||||
.onChange(async (value) => {
|
||||
if (!this.plugin.settings.modules[module.id]) {
|
||||
this.plugin.settings.modules[module.id] = {
|
||||
enabled: value,
|
||||
settings: { ...module.defaultSettings },
|
||||
};
|
||||
} else {
|
||||
this.plugin.settings.modules[module.id].enabled = value;
|
||||
}
|
||||
await this.plugin.saveSettings();
|
||||
if (value) {
|
||||
this.plugin.loadModule(module);
|
||||
} else {
|
||||
this.plugin.unloadModule(module);
|
||||
}
|
||||
}),
|
||||
toggle.setValue(moduleCfg?.enabled ?? true).onChange(async (value) => {
|
||||
if (!this.plugin.settings.modules[module.id]) {
|
||||
this.plugin.settings.modules[module.id] = {
|
||||
enabled: value,
|
||||
settings: { ...module.defaultSettings },
|
||||
};
|
||||
} else {
|
||||
this.plugin.settings.modules[module.id].enabled = value;
|
||||
}
|
||||
await this.plugin.saveSettings();
|
||||
if (value) {
|
||||
this.plugin.loadModule(module);
|
||||
} else {
|
||||
this.plugin.unloadModule(module);
|
||||
}
|
||||
}),
|
||||
);
|
||||
|
||||
if (moduleCfg) {
|
||||
module.renderInlineSettings(
|
||||
containerEl,
|
||||
moduleCfg.settings,
|
||||
() => this.plugin.saveSettings(),
|
||||
module.renderInlineSettings(containerEl, moduleCfg.settings, () =>
|
||||
this.plugin.saveSettings(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user