@univerjs-pro/edit-history-loader

GitHubEdit on GitHub

Edit history loading integration for Univer Pro.

import { UniverEditHistoryLoaderPlugin } from '@univerjs-pro/edit-history-loader'

univer.registerPlugin(UniverEditHistoryLoaderPlugin, IUniverEditHistoryLoaderConfig)

IUniverEditHistoryLoaderConfig

import type { MenuConfig } from '@univerjs/ui'

export interface IUniverEditHistoryLoaderConfig {
  menu?: MenuConfig
  univerContainerId?: string
  /**
   * @description The server url of the history list
   * @default ''
   */
  historyListServerUrl?: string

  historyPanelComponentKey?: string

  historyPanelHidden?: boolean

  historyAIassistantEnabled?: boolean
  /**
   * The Web Worker used in edit history.
   * If the workerURL is provided and workerURL is a Worker instance, it will be destroyed when history is closed.
   * So a new Worker instance need to be created when history is opened again. For example:
   * ```ts
   * import { EDIT_HISTORY_LOADER_PLUGIN_CONFIG_KEY, ToggleEditHistoryOperation } from '@univerjs-pro/edit-history-loader';
   *
   * univerAPI.addEvent(univerAPI.Event.BeforeCommandExecute, (event) => {
   *   if (event.id === ToggleEditHistoryOperation.id) {
   *     const workerURL = new Worker(new URL('./worker.ts', import.meta.url));
   *     const configService = univer.__getInjector().get(IConfigService);
   *     configService.setConfig(EDIT_HISTORY_LOADER_PLUGIN_CONFIG_KEY, {
   *       workerURL,
   *     });
   *   }
   * });
   *
   * If the workerURL is a string or URL, no additional processing is required.
   * ```
   */
  workerURL?: string | URL | Worker
}