import * as vscode from 'vscode' ; import { Command } from '../util/commandManager' ; import { PreviewSecuritySelector } from '../util/security' ; import { isRSTFile } from '../util/file' ; import { RSTPreviewManager } from '../preview/previewManager' ; export class ShowPreviewSecuritySelectorCommand implements Command { public readonly id = 'restructuredtext.showPreviewSecuritySelector' ; public constructor ( private readonly previewSecuritySelector , private readonly previewManager ) { } public execute ( resource ) { if ( this . previewManager . activePreviewResource ) { this . previewSecuritySelector . showSecuritySelectorForResource ( this . previewManager . activePreviewResource ) ; } else if ( resource ) { const source = vscode . Uri . parse ( resource ) ; this . previewSecuritySelector . showSecuritySelectorForResource ( source . query ? vscode . Uri . parse ( source . query ) : source ) ; } else if ( vscode . window . activeTextEditor && isRSTFile ( vscode . window . activeTextEditor . document ) ) { this . previewSecuritySelector . showSecuritySelectorForResource ( vscode . window . activeTextEditor . document . uri ) ; } } }