Removed modal from stores

This commit is contained in:
Simon Cambier
2022-04-20 08:38:16 +02:00
parent 035d4ff957
commit 359292de5c
4 changed files with 32 additions and 24 deletions

View File

@@ -2,10 +2,14 @@ import { Modal, TFile } from 'obsidian'
import type OmnisearchPlugin from './main'
import CmpModalVault from './CmpModalVault.svelte'
import CmpModalInFile from './CmpModalInFile.svelte'
import { modal } from './stores'
export class OmnisearchModal extends Modal {
constructor(plugin: OmnisearchPlugin, file?: TFile, canGoBack = false) {
constructor(
plugin: OmnisearchPlugin,
file?: TFile,
canGoBack = false,
parent?: OmnisearchModal,
) {
super(plugin.app)
// Remove all the default modal's children (except the close button)
@@ -15,20 +19,23 @@ export class OmnisearchModal extends Modal {
this.modalEl.append(closeEl)
this.modalEl.addClass('omnisearch-modal', 'prompt')
modal.set(this)
if (file) {
new CmpModalInFile({
target: this.modalEl,
props: {
modal: this,
canGoBack,
singleFilePath: file.path,
parent: parent,
},
})
}
else {
new CmpModalVault({
target: this.modalEl,
props: {
modal: this,
},
})
}
}