mirror of
https://github.com/google/blockly.git
synced 2026-01-04 15:40:08 +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
26 lines
655 B
TypeScript
26 lines
655 B
TypeScript
/**
|
|
* @license
|
|
* Copyright 2023 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import {Coordinate} from '../utils/coordinate.js';
|
|
import {WorkspaceSvg} from '../workspace_svg.js';
|
|
import {ICopyable, ICopyData} from './i_copyable.js';
|
|
|
|
/** An object that can paste data into a workspace. */
|
|
export interface IPaster<U extends ICopyData, T extends ICopyable<U>> {
|
|
paste(
|
|
copyData: U,
|
|
workspace: WorkspaceSvg,
|
|
coordinate?: Coordinate,
|
|
): T | null;
|
|
}
|
|
|
|
/** @returns True if the given object is a paster. */
|
|
export function isPaster(
|
|
obj: any,
|
|
): obj is IPaster<ICopyData, ICopyable<ICopyData>> {
|
|
return obj.paste !== undefined;
|
|
}
|