feat: add basic pasters (#7331)

* feat: implement basic IPaster interface

* feat: add pasters for blocks and workspace comments
This commit is contained in:
Beka Westberg
2023-07-31 09:22:24 -07:00
committed by GitHub
parent 889310726e
commit 68a8a5ff19
3 changed files with 84 additions and 0 deletions

View 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;
}