Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Proposal: Previewers #36

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,40 @@ export interface Configuration {
setValues(configurationValues: ConfigurationValues): void
}

export namespace Preview {
export interface PreviewContext {
filePath: string
language: string
}

/**
* Previewer
*
* Interface for a preview strategy
*/
export interface Previewer {
render(context: PreviewContext): JSX.Element
}

export interface Api {
/**
* Register a preview strategy
*/
registerPreviewer(identifier: string, previewer: Previewer): void

/**
* Set the default preview strategy for a filetype
*/
registerDefaultPreviewerForLanguage(language: string, previewIdentifier: string): void


/**
* Open the preview experience
*/
openPreview(openMode: FileOpenMode): Promise<void>
}
}

export namespace Notifications {

export interface Notification {
Expand Down Expand Up @@ -684,6 +718,7 @@ export namespace Plugin {
overlays: Overlays.Api
plugins: IPluginManager
menu: Menu.Api
preview: Preview.Api
process: Process
recorder: Recorder
snippets: Snippets.SnippetManager
Expand Down