style: layout improvements

This commit is contained in:
Oleh Lustenko 2023-02-18 20:29:46 +02:00
parent 50648190cc
commit c1199c18ab
3 changed files with 40 additions and 43 deletions

74
main.ts
View File

@ -159,23 +159,20 @@ export class BulkRenameSettingsTab extends PluginSettingTab {
if (!isViewTypeFolder(this.plugin.settings)) { if (!isViewTypeFolder(this.plugin.settings)) {
return; return;
} }
new Setting(this.containerEl) new Setting(this.containerEl).setName('Folder location').addSearch((cb) => {
.setName('Folder location') new FolderSuggest(this.app, cb.inputEl, this.plugin);
.setDesc('Find files within the folder') cb.setPlaceholder('Example: folder1/')
.addSearch((cb) => { .setValue(this.plugin.settings.folderName)
new FolderSuggest(this.app, cb.inputEl, this.plugin); .onChange((newFolder) => {
cb.setPlaceholder('Example: folder1/') this.plugin.settings.folderName = newFolder;
.setValue(this.plugin.settings.folderName) this.plugin.saveSettings();
.onChange((newFolder) => { this.getFilesByFolder();
this.plugin.settings.folderName = newFolder; });
this.plugin.saveSettings(); // @ts-ignore
this.getFilesByFolder(); cb.containerEl.addClass('bulk_rename');
}); cb.inputEl.addClass('bulk_input');
// @ts-ignore cb.inputEl.onblur = this.reRenderPreview;
cb.containerEl.addClass('bulk_rename'); });
cb.inputEl.addClass('bulk_input');
cb.inputEl.onblur = this.reRenderPreview;
});
} }
renderTagNames() { renderTagNames() {
@ -183,31 +180,28 @@ export class BulkRenameSettingsTab extends PluginSettingTab {
return; return;
} }
new Setting(this.containerEl) new Setting(this.containerEl).setName('Tag names ').addSearch((cb) => {
.setName('Tag names ') cb.inputEl.addEventListener('keydown', (event) => {
.setDesc('all files with the tags will be found') if (event.key !== 'Enter') {
.addSearch((cb) => { return;
cb.inputEl.addEventListener('keydown', (event) => { }
if (event.key !== 'Enter') { const target = event.target as HTMLInputElement;
return;
}
const target = event.target as HTMLInputElement;
this.plugin.settings.tags = target.value.replace(/ /g, '').split(','); this.plugin.settings.tags = target.value.replace(/ /g, '').split(',');
this.plugin.saveSettings(); this.plugin.saveSettings();
});
cb.setPlaceholder('Example: #tag, #tag2')
.setValue(this.plugin.settings.tags.join(','))
.onChange((newFolder) => {
this.plugin.settings.tags = newFolder.replace(/ /g, '').split(',');
this.plugin.saveSettings();
this.getFilesByTags();
});
// @ts-ignore
cb.containerEl.addClass('bulk_rename');
cb.inputEl.addClass('bulk_input');
cb.inputEl.onblur = this.reRenderPreview;
}); });
cb.setPlaceholder('Example: #tag, #tag2')
.setValue(this.plugin.settings.tags.join(','))
.onChange((newFolder) => {
this.plugin.settings.tags = newFolder.replace(/ /g, '').split(',');
this.plugin.saveSettings();
this.getFilesByTags();
});
// @ts-ignore
cb.containerEl.addClass('bulk_rename');
cb.inputEl.addClass('bulk_input');
cb.inputEl.onblur = this.reRenderPreview;
});
} }
renderRegExpInput() { renderRegExpInput() {

View File

@ -29,7 +29,7 @@ export const getObsidianFilesByRegExp = (
const abstractFiles = app.vault.getAllLoadedFiles(); const abstractFiles = app.vault.getAllLoadedFiles();
const matchedFileNames = abstractFiles.filter((file) => { const matchedFileNames = abstractFiles.filter((file) => {
if (file instanceof TFile && XRegExp.match(file.path, regExp)) { if (file instanceof TFile && XRegExp.exec(file.path, regExp)) {
return true; return true;
} }
}) as TFile[]; }) as TFile[];

View File

@ -45,7 +45,11 @@
.replaceRenderSymbols { .replaceRenderSymbols {
display: flex; display: flex;
width: 100%; width: 100%;
padding-top: 1rem; padding-top: 0.5rem;
}
.setting-item-control.replaceRenderSymbols .bulk_input {
min-height: 80px;
} }
.setting-item-control .bulk_preview_textarea { .setting-item-control .bulk_preview_textarea {
@ -74,7 +78,6 @@
width: 100%; width: 100%;
resize: none; resize: none;
min-width: auto; min-width: auto;
min-height: auto;
} }
.setting-item-control .bulk_input:first-child { .setting-item-control .bulk_input:first-child {