mirror of
https://github.com/google/blockly.git
synced 2026-01-08 01:20:12 +01:00
* feat: add serialization to procedure base event * feat: add serialization to procedure change return event * feat: add serialization to procedure create event * feat: add serialization of the procedure delete event * feat: add serialization of procedure enable events * feat: add serialization of procedure parameter create events * feat: add serialization of the parameter delete event * feat: add serialization of procedure parameter rename events * feat: add serialization for procedure rename events
38 lines
903 B
TypeScript
38 lines
903 B
TypeScript
/**
|
|
* @license
|
|
* Copyright 2022 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import {Abstract as AbstractEvent, AbstractEventJson} from './events_abstract.js';
|
|
import type {IProcedureModel} from '../interfaces/i_procedure_model.js';
|
|
import type {Workspace} from '../workspace.js';
|
|
|
|
|
|
/**
|
|
* The base event for an event associated with a procedure.
|
|
*/
|
|
export abstract class ProcedureBase extends AbstractEvent {
|
|
isBlank = false;
|
|
|
|
constructor(workspace: Workspace, public readonly model: IProcedureModel) {
|
|
super();
|
|
this.workspaceId = workspace.id;
|
|
}
|
|
|
|
/**
|
|
* Encode the event as JSON.
|
|
*
|
|
* @returns JSON representation.
|
|
*/
|
|
toJson(): ProcedureBaseJson {
|
|
const json = super.toJson() as ProcedureBaseJson;
|
|
json['procedureId'] = this.model.getId();
|
|
return json;
|
|
}
|
|
}
|
|
|
|
export interface ProcedureBaseJson extends AbstractEventJson {
|
|
procedureId: string;
|
|
}
|