generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support to view images on a new window
- Loading branch information
Showing
15 changed files
with
1,024 additions
and
508 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import {ContainerView} from "../ui/container/container.view"; | ||
|
||
export class ContainerFactory { | ||
|
||
// main window container | ||
private mainContainer: ContainerView; | ||
|
||
// popout window containers: hash -> ContainerView | ||
private popoutContainers: Map<string, ContainerView> = new Map<string, ContainerView>(); | ||
|
||
|
||
public setMainContainer = (container: ContainerView): void => { | ||
this.mainContainer = container; | ||
} | ||
public getMainContainer = (): ContainerView => { | ||
return this.mainContainer; | ||
} | ||
|
||
public setPopoutContainer = (key: string, container: ContainerView): void => { | ||
this.popoutContainers.set(key, container); | ||
} | ||
public getPopoutContainer = (key: string): ContainerView => { | ||
return this.popoutContainers.get(key); | ||
} | ||
public getPopoutContainers = (): Map<string, ContainerView> => { | ||
return this.popoutContainers; | ||
} | ||
|
||
public getContainer = (targetEl: HTMLImageElement): ContainerView => { | ||
const bodyEl = targetEl?.matchParent('body'); | ||
if (!bodyEl) return null; | ||
const oitEventKey = bodyEl.getAttribute('data-oit-event'); | ||
if (oitEventKey) { | ||
//popout window | ||
return this.getPopoutContainer(oitEventKey); | ||
} | ||
return this.mainContainer; | ||
} | ||
|
||
public getAllContainers = (): ContainerView[] => { | ||
let allContainerViews = [this.mainContainer]; | ||
for (let value of this.popoutContainers.values()) { | ||
allContainerViews.push(value); | ||
} | ||
return allContainerViews; | ||
} | ||
|
||
public clearAll = () => { | ||
this.mainContainer = null; | ||
this.popoutContainers.clear(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.