Functions supported by Marvin.

interface Marvin {
    addTemplate(template: TemplateSettings): Promise<void>;
    applySettings(settings: MarvinSettings): Promise<void>;
    center(): void;
    clear(): void;
    clearHistory(): void;
    exportDocument(documentType: DocumentType): Promise<ExportResult>;
    exportImage(
        imageType: ImageType,
        exportOptions?: ExportOptions,
    ): Promise<ExportResult>;
    getSettings(): Promise<MarvinSettings>;
    importDocument(
        documentSource: string,
        importOptions?: ImportOptions,
    ): Promise<void>;
    isEmpty(): boolean;
    off(eventType: EventType, eventHandler?: EventHandler): void;
    on(
        eventType: EventType,
        eventHandler: EventHandler,
        eventInit?: ReopenEventInitializer,
    ): void;
    removeTemplate(template: TemplateSettings): void;
    removeUI(): void;
}

Methods

  • Add a new template to the template list on the left sidebar.

    Parameters

    • template: TemplateSettings

      the template definition including name, structure and icon

    Returns Promise<void>

    error if a structure is invalid or does not contain any molecules or a template with the given name was already added before

  • Applies editor settings.

    Parameters

    Returns Promise<void>

  • Moves to drawing center if not empty.

    Returns void

  • Clears canvas.

    Returns void

  • Resets undo stack.

    Returns void

  • Exports the current content of the canvas as a document format.

    Parameters

    • documentType: DocumentType

      the document type in which to export, currently supported types: cxon.

    Returns Promise<ExportResult>

    The generated document as a string value.

  • Exports the current content of the canvas as an image.

    Parameters

    • imageType: ImageType

      currently supported image types: JPG, PNG, SVG, WEBP (WebP image format is partially supported on Safari).

    • OptionalexportOptions: ExportOptions

      settings to be used for image export.

    Returns Promise<ExportResult>

    The generated image as a string value.

  • Imports document. Content is displayed on the previously cleared canvas.

    Parameters

    • documentSource: string

      the document content. Source format determined automatically.

    • OptionalimportOptions: ImportOptions

      to configure import if differ from default. Default values are { clearCanvas: true, select: false, throwError: true, placement: 'TOP_LEFT', scale: 'NONE' }

    Returns Promise<void>

    error if document or its content is invalid

  • Determines whether the canvas is empty or not.

    Returns boolean

    true if nothing on the canvas, else false.

  • Deregister a previously registered event handler.

    Parameters

    • eventType: EventType

      the event type associated to the client event handler.

    • OptionaleventHandler: EventHandler

      the event handler function.

    Returns void

  • Remove a template from the template list on the left sidebar.

    Parameters

    • template: TemplateSettings

      the template definition including name, structure and icon

    Returns void

  • Removes Marvin from the dom.

    Returns void