mirror of
https://github.com/google/blockly.git
synced 2026-01-10 18:37:09 +01:00
* chore: rename module-local variables to not conflict * feat: make ICopyable generic and update clipboard APIs * chore: switch over more things to use generic ICopyables * chore: fix shortcut items using copy paste * chore: add test for interface between clipboard and pasters * chore: export isCopyable * chore: format * chore: fixup PR comments * chore: add deprecation tags
33 lines
704 B
TypeScript
33 lines
704 B
TypeScript
/**
|
|
* @license
|
|
* Copyright 2019 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import * as goog from '../../closure/goog/goog.js';
|
|
goog.declareModuleId('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;
|
|
}
|
|
|
|
export namespace ICopyable {
|
|
export interface ICopyData {
|
|
paster: string;
|
|
}
|
|
}
|
|
|
|
export type ICopyData = ICopyable.ICopyData;
|
|
|
|
/** @returns true if the given object is copyable. */
|
|
export function isCopyable(obj: any): obj is ICopyable<ICopyData> {
|
|
return obj.toCopyData !== undefined;
|
|
}
|