Path: blob/main/src/vs/workbench/contrib/notebook/browser/diff/eventDispatcher.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { Emitter } from '../../../../../base/common/event.js';6import { Disposable } from '../../../../../base/common/lifecycle.js';7import { IDiffElementLayoutInfo } from './notebookDiffEditorBrowser.js';8import { NotebookLayoutChangeEvent, NotebookLayoutInfo } from '../notebookViewEvents.js';910export enum NotebookDiffViewEventType {11LayoutChanged = 1,12CellLayoutChanged = 213// MetadataChanged = 2,14// CellStateChanged = 315}1617export class NotebookDiffLayoutChangedEvent {18public readonly type = NotebookDiffViewEventType.LayoutChanged;1920constructor(readonly source: NotebookLayoutChangeEvent, readonly value: NotebookLayoutInfo) {2122}23}2425export class NotebookCellLayoutChangedEvent {26public readonly type = NotebookDiffViewEventType.CellLayoutChanged;2728constructor(readonly source: IDiffElementLayoutInfo) {2930}31}3233export type NotebookDiffViewEvent = NotebookDiffLayoutChangedEvent | NotebookCellLayoutChangedEvent;3435export class NotebookDiffEditorEventDispatcher extends Disposable {36protected readonly _onDidChangeLayout = this._register(new Emitter<NotebookDiffLayoutChangedEvent>());37readonly onDidChangeLayout = this._onDidChangeLayout.event;3839protected readonly _onDidChangeCellLayout = this._register(new Emitter<NotebookCellLayoutChangedEvent>());40readonly onDidChangeCellLayout = this._onDidChangeCellLayout.event;4142emit(events: NotebookDiffViewEvent[]) {43for (let i = 0, len = events.length; i < len; i++) {44const e = events[i];4546switch (e.type) {47case NotebookDiffViewEventType.LayoutChanged:48this._onDidChangeLayout.fire(e);49break;50case NotebookDiffViewEventType.CellLayoutChanged:51this._onDidChangeCellLayout.fire(e);52break;53}54}55}56}575859