Using 2 modals to display the different kinds of results

This commit is contained in:
Simon Cambier
2022-04-18 10:28:13 +02:00
parent cfa24b9617
commit 6cb113b87e
8 changed files with 218 additions and 81 deletions

View File

@@ -1,11 +1,13 @@
import { Modal, TFile } from 'obsidian'
import type OmnisearchPlugin from './main'
import CmpModal from './CmpModal.svelte'
import CmpModalVault from './CmpModalVault.svelte'
import CmpModalFile from './CmpModalFile.svelte'
import { inFileSearch, modal } from './stores'
export class OmnisearchModal extends Modal {
constructor(plugin: OmnisearchPlugin, file?: TFile) {
super(plugin.app)
// Remove all the default modal's children (except the close button)
// so that we can more easily customize it
const closeEl = this.containerEl.find('.modal-close-button')
@@ -14,11 +16,17 @@ export class OmnisearchModal extends Modal {
this.modalEl.addClass('omnisearch-modal', 'prompt')
inFileSearch.set(file ?? null)
modal.set(this)
new CmpModal({
target: this.modalEl,
})
if (file) {
new CmpModalFile({
target: this.modalEl,
})
}
else {
new CmpModalVault({
target: this.modalEl,
})
}
}
}