import React, { Component, type ReactElement } from 'react'; import type { editor } from 'monaco-editor'; import { type DropdownAction } from '@deephaven/components'; import { ScriptEditor } from '@deephaven/console'; import { type FileStorage, type File } from '@deephaven/file-explorer'; import { type WorkspaceSettings } from '@deephaven/redux'; import { type DashboardPanelProps, type PanelMetadata } from '@deephaven/dashboard'; import { Pending } from '@deephaven/utils'; import type { Tab } from '@deephaven/golden-layout'; import type { dh } from '@deephaven/jsapi-types'; import { type CoreConsoleSession } from '../ConsoleEvents'; import './NotebookPanel.scss'; interface Metadata extends PanelMetadata { id: string; } interface NotebookSetting { isMinimapEnabled?: boolean; formatOnSave?: boolean; } interface FileMetadata { itemName: string; id: string; } interface PanelState { isPreview?: boolean; settings: editor.IStandaloneEditorConstructionOptions; fileMetadata: FileMetadata | null; } interface NotebookPanelMappedProps { notebookSettings: NotebookSetting; fileStorage: FileStorage; session?: dh.IdeSession; sessionLanguage?: string; } interface NotebookPanelProps extends DashboardPanelProps, NotebookPanelMappedProps { isDashboardActive: boolean; isPreview: boolean; metadata: Metadata; panelState: PanelState; notebooksUrl: string; updateNotebookSettings: (settings: Partial) => void; } interface NotebookPanelState { error?: { message?: string | undefined; }; isDashboardActive: boolean; isLoading: boolean; isLoaded: boolean; isPreview: boolean; savedChangeCount: number; changeCount: number; fileMetadata: FileMetadata | null; settings: editor.IStandaloneEditorConstructionOptions; session?: dh.IdeSession; sessionLanguage?: string; panelState: PanelState; showCloseModal: boolean; showDeleteModal: boolean; showSaveAsModal: boolean; scriptCode: string; itemName?: string; formatOnSave: boolean; } declare class NotebookPanel extends Component { static COMPONENT: string; static POPPER_OPTIONS: { readonly placement: "bottom-end"; }; static DEFAULT_NAME: string; static UNSAVED_INDICATOR_CLASS_NAME: string; static UNSAVED_STATUS_CLASS_NAME: string; static handleError(error: unknown): void; /** * Returns number of unsaved notebooks. */ static unsavedNotebookCount(): number; static defaultProps: { isDashboardActive: boolean; isPreview: boolean; session: null; sessionLanguage: null; notebookSettings: { isMinimapEnabled: boolean; }; }; static languageFromFileName(fileName: string): string | null; constructor(props: NotebookPanelProps); componentDidMount(): void; componentDidUpdate(prevProps: NotebookPanelProps, prevState: NotebookPanelState): void; componentWillUnmount(): void; pending: Pending; debouncedSavePanelState: import("lodash").DebouncedFunc<() => void>; debouncedLoad: import("lodash").DebouncedFunc<() => void>; notebook: ScriptEditor | null; tabTitleElement: Element | null; tabInitOnce: boolean; editor?: editor.IStandaloneCodeEditor; initTab(tab: Tab): void; /** * Adds a beforeClose handler to check if a notebook needs to be saved * Call panel close with force if the check can be skipped * * Note that firing a close event manually may trigger before state update occurs * In those instances, use force */ initTabCloseOverride(): void; initTabClasses(tab: Tab): void; getNotebookValue(): string | undefined; initNotebookContent(): void; closeFileTabById(id: string): void; registerFileMetadata(fileMetadata: FileMetadata, isPreview: boolean): void; renameTab(id: string, title: string): void; load(): void; /** * Attempts to save the notebook. * @returns Returns true if save has begun, false if user needed to be prompted */ save(): boolean; /** * Update existing file content * @param filename The name of the file * @param content New file content */ saveContent(filename: string, content: string): void; updateSavedChangeCount(): void; setPreviewStatus(): void; handlePreviewPromotion(): void; getSettings: (initialSettings: editor.IStandaloneEditorConstructionOptions, isMinimapEnabled: boolean) => editor.IStandaloneEditorConstructionOptions; getOverflowActions: (isMinimapEnabled: boolean, isWordWrapEnabled: boolean, formatOnSave: boolean, runButtonsDisabled: boolean, toolbarDisabled: boolean) => DropdownAction[]; savePanelState(): void; handleCloseDiscard(): void; handleCloseSave(): void; handleCloseCancel(): void; /** * Closes overwritten tabs * @param fileName The name of the file to be overwritten */ handleOverwrite(fileName: string): void; handleCopy(): Promise; handleDelete(): void; handleDeleteConfirm(): Promise; handleDeleteCancel(): void; handleEditorInitialized(innerEditor: editor.IStandaloneCodeEditor): void; handleEditorWillDestroy(): void; handleEditorChange(e: editor.IModelContentChangedEvent): void; handleFind(): void; updateEditorMinimap(): void; handleMinimapChange(): void; updateEditorWordWrap(): void; handleWordWrapChange(): void; handleFormatOnSaveChange(): void; /** * @param event The click event from clicking on the link */ handleLinkClick(event: React.MouseEvent): void; handleLoadSuccess(): void; handleLoadError(errorParam: { message?: string | undefined; }): void; handleSave(): Promise; handleSaveSuccess(file: File): void; handleSaveError(error: unknown): void; handleSaveAsCancel(): void; handleSaveAsSubmit(name: string, isOverwrite?: boolean): void; canFormat(): boolean; handleFormat(): Promise; handleRenameFile(oldName: string, newName: string, panelState?: PanelState): void; handleResize(): void; handleRunCommand(command?: string): void; handleRunAll(): void; handleRunSelected(): void; handleSessionOpened({ session, language }: CoreConsoleSession): void; handleSessionClosed(): void; handleShow(): void; handlePanelDropped(droppedId: string): void; handleShowRename(): void; handleTab(tab: Tab): void; handleTabFocus(...args: unknown[]): void; handleTabBlur(): void; handleTabClick(e: MouseEvent): void; /** * Transform the link URI to load from where the notebook is if it's relative * @param src The link to transform * @returns String the transformed link */ handleTransformLinkUri(src: string): string; focus(): void; createNotebook(itemName: string, language: string | undefined, content?: string): void; runCommand(command?: string): void; removePreviewStatus(): void; getDropdownOverflowActions(): DropdownAction[]; render(): ReactElement; } declare const ConnectedNotebookPanel: import("react-redux").ConnectedComponent & { notebookSettings?: NotebookSetting | undefined; session?: dh.IdeSession | undefined; isDashboardActive?: boolean | undefined; isPreview?: boolean | undefined; sessionLanguage?: string | undefined; } & {}, "notebookSettings" | "session" | "fileStorage" | "updateNotebookSettings" | "sessionLanguage"> & { localDashboardId: string; }>; export default ConnectedNotebookPanel; //# sourceMappingURL=NotebookPanel.d.ts.map