@promptbook/remote-server
Version:
Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action
234 lines (233 loc) • 7.25 kB
TypeScript
import { CSSProperties } from 'react';
import type { Promisable } from 'type-fest';
import type { string_book } from '../../book-2.0/agent-source/string_book';
import type { number_percent } from '../../types/number_percent';
import type { number_positive } from '../../types/number_positive';
import type { string_knowledge_source_content } from '../../types/string_knowledge_source_content';
import type { string_css_value } from '../../types/string_markdown';
import type { HoistedMenuItem } from '../_common/MenuHoisting/MenuHoistingContext';
/**
* Monaco diagnostic shown inside `BookEditor`.
*
* @private internal type of `BookEditor`
*/
type BookEditorDiagnostic = {
/**
* 1-based start line.
*/
readonly startLineNumber: number;
/**
* 1-based start column.
*/
readonly startColumn: number;
/**
* 1-based end line.
*/
readonly endLineNumber: number;
/**
* 1-based end column.
*/
readonly endColumn: number;
/**
* Diagnostic message shown by Monaco.
*/
readonly message: string;
/**
* Marker severity used for color coding in Monaco.
*
* @default 'error'
*/
readonly severity?: 'error' | 'warning' | 'info' | 'hint';
/**
* Optional source label shown in Monaco hover.
*/
readonly source?: string;
};
/**
* Default height of the book editor
*
* Note: This height is computed based on the number of lines in the default book + padding multiplied by an estimated line height.
*
* @public exported from `@promptbook/components`
*/
export declare const DEFAULT_BOOK_EDITOR_HEIGHT: number;
/**
* Upload progress callback for BookEditor uploads.
*
* @public exported from `@promptbook/components`
*/
export type BookEditorUploadProgressCallback = (progress: number_percent, stats?: {
loadedBytes: number;
totalBytes: number;
}) => void;
/**
* Options for BookEditor uploads.
*
* @public exported from `@promptbook/components`
*/
export type BookEditorUploadOptions = {
/**
* Progress callback invoked during upload.
*/
readonly onProgress?: BookEditorUploadProgressCallback;
/**
* Optional abort signal for canceling an upload.
*/
readonly abortSignal?: AbortSignal;
};
/**
* Props of `BookEditor`
*
* @public exported from `@promptbook/components`
*/
export type BookEditorProps = {
/**
* The source of the agent to be displayed in the editor.
*/
readonly agentSource?: string_book;
/**
* Additional CSS classes to apply to the editor container.
*/
readonly className?: string;
/**
* Optional CSS style which will be added to root <div/> element
*/
readonly style?: CSSProperties;
/**
* Resolved visual theme used for the editor wrapper and Monaco instance.
*
* Host applications should pass the final light/dark theme instead of relying on
* browser media-query inference inside `<BookEditor/>`.
*
* @default 'LIGHT'
*/
readonly theme?: 'LIGHT' | 'DARK';
/**
* Height of the `BookEditor` component
*
* - You can use any valid CSS value, e.g., `500px`, `100%`, `50vh`, etc.
* - If not set, the default height is `DEFAULT_BOOK_EDITOR_HEIGHT`.
* - If set to `null`, the height should be controlled entirely via `className` or `style`, otherwise the editor will have zero height.
*
* @default `DEFAULT_BOOK_EDITOR_HEIGHT`
*/
readonly height?: string_css_value | null;
/**
* Zoom level of the editor
*
* @default 1 (100%)
*/
readonly zoom?: number_percent & number_positive;
/**
* The book which is being edited.
*/
readonly value?: string_book;
/**
* Callback function to handle changes in the book content.
*/
onChange?(value: string_book): void;
/**
* Optional Monaco diagnostics shown as squiggle markers in the editor.
*/
readonly diagnostics?: ReadonlyArray<BookEditorDiagnostic>;
/**
* Returns the URL of the uploaded file on CDN or storage.
*/
onFileUpload?(file: File, options?: BookEditorUploadOptions | BookEditorUploadProgressCallback): Promisable<string_knowledge_source_content>;
/**
* If true, logs verbose debug info to the console and shows additional visual cues
*/
readonly isVerbose?: boolean;
/**
* If true, disables border radius making the editor have sharp corners
*/
readonly isBorderRadiusDisabled?: boolean;
/**
* If true, the editor is in read-only mode
*
* @default false
*/
readonly isReadonly?: boolean;
/**
* Optional translations for the component
*/
readonly translations?: {
/**
* Message to show when trying to edit a readonly editor
*
* @default "You cannot edit this book"
*/
readonly readonlyMessage?: string;
};
/**
* If true, shows the upload button in the action bar.
* By default, the upload button is shown.
*/
readonly isUploadButtonShown?: boolean;
/**
* If true, shows the camera button in the action bar.
* By default, the camera button is shown on mobile devices.
*/
readonly isCameraButtonShown?: boolean;
/**
* If true, shows the download button in the action bar.
* By default, the download button is shown.
*/
readonly isDownloadButtonShown?: boolean;
/**
* If true, shows the about button in the action bar.
* By default, the about button is shown.
*/
readonly isAboutButtonShown?: boolean;
/**
* If true, shows the fullscreen button in the action bar.
* By default, the fullscreen button is shown.
*/
readonly isFullscreenButtonShown?: boolean;
/**
* Callback function to handle fullscreen button click.
* Note: This is for internal use between BookEditor and BookEditorMonaco
* @private
*/
onFullscreenClick?(): void;
/**
* If true, the editor is in fullscreen mode.
* Note: This is for internal use between BookEditor and BookEditorMonaco
* @private
*/
readonly isFullscreen?: boolean;
/**
* If defined, the editor will be synced with other editors with the same sync configuration.
*/
readonly sync?: {
/**
* The URL of the y-websocket server.
*/
readonly serverUrl: string;
/**
* The name of the room to join.
*/
readonly roomName: string;
};
/**
* Stable Monaco model path used to restore cursor/scroll view state across remounts.
*
* Keep this unique per logical book editor document.
*
* @private Internal to Promptbook app integrations.
*/
readonly monacoModelPath?: string;
/**
* Additional actions merged into the BookEditor actionbar and hoisted header menu.
*
* @private Internal to Promptbook app integrations.
*/
readonly hoistedMenuItems?: ReadonlyArray<HoistedMenuItem>;
};
/**
* Renders a book editor
*
* @public exported from `@promptbook/components`
*/
export declare function BookEditor(props: BookEditorProps): import("react/jsx-runtime").JSX.Element;
export {};