UNPKG

@blinkk/editor

Version:

Structured content editor with live previews.

100 lines (99 loc) 4.4 kB
import { ApiError, DeviceData, EditorFileData, FileData, LiveEditorApiComponent, ProjectData, PublishResult, SiteData, UserData, WorkspaceData } from './api'; import { AmagakiState } from '../projectType/amagaki/amagakiState'; import { Base } from '@blinkk/selective-edit/dist/src/mixins'; import { FeatureManager } from '../utility/featureManager'; import { GrowState } from '../projectType/grow/growState'; declare const EditorState_base: { new (...args: any[]): { _listeners?: Record<string, ((...args: any) => void)[]> | undefined; addListener(eventName: string, callback: (...args: any) => void): void; readonly listeners: Record<string, ((...args: any) => void)[]>; triggerListener(eventName: string, ...args: any): void; }; } & typeof Base; /** * Track the references to the editor state. * * These is done as a property of a class so that it can be used * with part configs and always have access to the latest * value without each part having to request the same information. */ export declare class EditorState extends EditorState_base { /** * API for retrieving data for the editor. */ api: LiveEditorApiComponent; /** * Array of devices supported for previews. */ devices?: Array<DeviceData>; /** * Editor experiments mangager. */ experiments: FeatureManager; /** * Editor feature mangager. */ features: FeatureManager; /** * Files in the project that can be edited by the editor. */ files?: Array<FileData>; /** * Editor file loaded in the editor. */ file?: EditorFileData; /** * Project information. */ project?: ProjectData; /** * Project types states. */ projectTypes: StateProjectTypes; /** * Keep track of active promises to keep from requesting the same data * multiple times. */ protected promises: Record<string, Promise<any>>; /** * Site configuration for the editor. */ site?: SiteData; /** * Users in the project that have access to the editor. */ users?: Array<UserData>; /** * Workspace in use in the editor. */ workspace?: WorkspaceData; /** * Workspaces available to use in the editor. */ workspaces?: Array<WorkspaceData>; constructor(api: LiveEditorApiComponent); copyFile(originalPath: string, path: string, callback?: (file: FileData) => void, callbackError?: (error: ApiError) => void): void; createFile(path: string, callback?: (file: FileData) => void, callbackError?: (error: ApiError) => void): void; createWorkspace(base: WorkspaceData, workspace: string, callback?: (workspace: WorkspaceData) => void, callbackError?: (error: ApiError) => void): void; deleteFile(file: FileData, callback?: () => void, callbackError?: (error: ApiError) => void): void; getDevices(callback?: (devices: Array<DeviceData>) => void, callbackError?: (error: ApiError) => void): Array<DeviceData> | undefined; getFile(file: FileData, callback?: (file: EditorFileData) => void, callbackError?: (error: ApiError) => void): EditorFileData | undefined; getFiles(callback?: (files: Array<FileData>) => void, callbackError?: (error: ApiError) => void): Array<FileData> | undefined; getProject(callback?: (project: ProjectData) => void, callbackError?: (error: ApiError) => void): ProjectData | undefined; getWorkspace(callback?: (project: WorkspaceData) => void, callbackError?: (error: ApiError) => void): WorkspaceData | undefined; getWorkspaces(callback?: (workspaces: Array<WorkspaceData>) => void, callbackError?: (error: ApiError) => void): Array<WorkspaceData> | undefined; loadWorkspace(workspace: WorkspaceData, callback?: (workspace: WorkspaceData) => void, callbackError?: (error: ApiError) => void): void; publish(workspace: WorkspaceData, data: Record<string, any>, callback?: (result: PublishResult) => void, callbackError?: (error: ApiError) => void): void; /** * Signal for the editor to re-render. */ render(): void; saveFile(file: EditorFileData, isRawEdit: boolean, callback?: (file: EditorFileData) => void, callbackError?: (error: ApiError) => void): void; } export interface StateProjectTypes { amagaki: AmagakiState; grow: GrowState; } export declare const DEFAULT_DEVICES: DeviceData[]; export {};