Files
blockly/core/interfaces/i_copyable.ts
2025-06-10 11:12:04 -07:00

39 lines
801 B
TypeScript

/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
// Former goog.module ID: Blockly.ICopyable
import type {ISelectable} from './i_selectable.js';
export interface ICopyable<T extends ICopyData> extends ISelectable {
/**
* Encode for copying.
*
* @returns Copy metadata.
*/
toCopyData(): T | null;
/**
* Whether this instance is currently copyable.
*
* @returns True if it can currently be copied.
*/
isCopyable?(): boolean;
}
export namespace ICopyable {
export interface ICopyData {
paster: string;
}
}
export type ICopyData = ICopyable.ICopyData;
/** @returns true if the given object is an ICopyable. */
export function isCopyable(obj: any): obj is ICopyable<ICopyData> {
return obj.toCopyData !== undefined;
}