mirror of
https://github.com/google/blockly.git
synced 2026-01-10 02:17:09 +01:00
feat: add basic pasters (#7331)
* feat: implement basic IPaster interface * feat: add pasters for blocks and workspace comments
This commit is contained in:
23
core/interfaces/i_paster.ts
Normal file
23
core/interfaces/i_paster.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* @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, CopyData} from './i_copyable.js';
|
||||
|
||||
/** An object that can paste data into a workspace. */
|
||||
export interface IPaster<U extends CopyData, T extends ICopyable> {
|
||||
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<CopyData, ICopyable> {
|
||||
return obj.paste !== undefined;
|
||||
}
|
||||
Reference in New Issue
Block a user