import { CommonmarkOptions } from "../commonmark/editor"; import { RichTextOptions } from "../rich-text/editor"; import { View, CommonViewOptions, EditorType } from "../shared/view"; import type { Node as ProseMirrorNode } from "prosemirror-model"; import { EditorView } from "prosemirror-view"; /** * StacksEditor options that are passed to both editors * Any value set on the respective child options objects will override the values set on this object */ export interface StacksEditorOptions extends CommonViewOptions { /** The editor to show on instantiation */ defaultView?: EditorType; /** The list of classes to add to the backing editor's target */ targetClassList?: string[]; /** The specific options to pass to the CommonmarkEditor; overrides any values on the parent options */ commonmarkOptions?: CommonmarkOptions; /** The specific options to pass to the RichTextEditor; overrides any values on the parent options */ richTextOptions?: RichTextOptions; } /** * A full editor that wraps and manages the state of both RichText and Commonmark editors */ export declare class StacksEditor implements View { /** The element to render this view into */ private target; /** The element to render the backing view into */ private innerTarget; /** The element to render the menu into */ private pluginContainer; /** The current backing view instance */ private backingView; /** The fully filled out (passed merged with default) options */ private options; /** An internal-only, randomly generated id for selector targeting */ private internalId; /** Singleton instance of a plugin provider that is passed to backing views */ private pluginProvider; constructor(target: HTMLElement, content: string, options?: StacksEditorOptions); get editorView(): EditorView; get content(): string; set content(value: string); appendContent(value: string): void; get document(): ProseMirrorNode; get dom(): Element; get readonly(): boolean; get currentViewType(): EditorType; static get defaultOptions(): StacksEditorOptions; focus(): void; destroy(): void; /** * Sets the editor view the the passed type * @param type The type of editor to set the view to */ setView(type: EditorType): void; /** * Enables the editor view */ enable(): void; /** * Disables the editor view */ disable(): void; /** * Reinitializes the editor with a subset of options that are merged into the current options * @param options The options that are changing between initializations */ reinitialize(options?: StacksEditorOptions): void; /** * Sets up the plugin and menu containers at the top of the editor. These are areas set aside for * plugins to render their content in a reliable manner. This area cancels mousedown events to keep the editor * from blurring and also handles sticking the content to the top of the editor on scroll. */ private setupPluginContainer; /** * Sets the backing editor view to the passed type filled with the passed content * @param type The type to set the backing view to * @param content The markdown content to fill the editor with */ private setBackingView; /** * Creates the button that toggles the backing view type * @param defaultItem The type that is set as the default * @param menuTarget The container to append the created element to */ private createEditorSwitcher; /** * Handles toggling the editor when the switcher is clicked * and fires a change event from the target element for consumers to listen for * @param e The click event */ private editorSwitcherChangeHandler; }